changeset 26894:3c06cd0e1717

Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
author Daniel Atallah <daniel.atallah@gmail.com>
date Sun, 03 May 2009 23:49:25 +0000
parents c791a82b5bb5
children 5f9c475b57ca
files pidgin/gtkimhtml.c pidgin/gtkimhtml.h pidgin/gtkstatusbox.c
diffstat 3 files changed, 35 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkimhtml.c	Sun May 03 23:46:18 2009 +0000
+++ b/pidgin/gtkimhtml.c	Sun May 03 23:49:25 2009 +0000
@@ -5884,3 +5884,16 @@
 	g_signal_connect(G_OBJECT(imhtml), "message_send",
 		G_CALLBACK(return_add_newline_cb), NULL);
 }
+
+void gtk_imhtml_set_populate_primary_clipboard(GtkIMHtml *imhtml, gboolean populate)
+{
+	if (populate) {
+		g_signal_handlers_unblock_matched(imhtml->text_buffer,
+				G_SIGNAL_MATCH_FUNC, 0, 0, NULL,
+				mark_set_so_update_selection_cb, NULL);
+	} else {
+		g_signal_handlers_block_matched(imhtml->text_buffer,
+				G_SIGNAL_MATCH_FUNC, 0, 0, NULL,
+				mark_set_so_update_selection_cb, NULL);
+	}
+}
--- a/pidgin/gtkimhtml.h	Sun May 03 23:46:18 2009 +0000
+++ b/pidgin/gtkimhtml.h	Sun May 03 23:49:25 2009 +0000
@@ -957,6 +957,16 @@
  */
 void gtk_imhtml_set_return_inserts_newline(GtkIMHtml *imhtml);
 
+/**
+ * By default this widget populates the PRIMARY clipboard with any selected
+ * text (as you would expect).  For scenarios (e.g. select-on-focus) where this
+ * would be problematic, this function can disable the PRIMARY population.
+ *
+ * @oaram imhtml The GtkIMHtml to enable/disable populating PRIMARY
+ * @param populate enable/disable PRIMARY population
+ */
+void gtk_imhtml_set_populate_primary_clipboard(GtkIMHtml *imhtml, gboolean populate);
+
 /*@}*/
 
 #ifdef __cplusplus
--- a/pidgin/gtkstatusbox.c	Sun May 03 23:46:18 2009 +0000
+++ b/pidgin/gtkstatusbox.c	Sun May 03 23:49:25 2009 +0000
@@ -265,6 +265,9 @@
 			break;
 	}
 
+	gtk_imhtml_set_populate_primary_clipboard(
+		GTK_IMHTML(status_box->imhtml), TRUE);
+
 	if (status_no != -1) {
 		GtkTreePath *path;
 		gtk_widget_set_sensitive(GTK_WIDGET(status_box), FALSE);
@@ -1149,6 +1152,8 @@
 	{
 		purple_timeout_remove(status_box->typing);
 		status_box->typing = 0;
+		gtk_imhtml_set_populate_primary_clipboard(
+			GTK_IMHTML(status_box->imhtml), TRUE);
 		if (status_box->account != NULL)
 			update_to_reflect_account_status(status_box, status_box->account,
 							purple_account_get_active_status(status_box->account));
@@ -2583,6 +2588,9 @@
 		return;
 	}
 
+	gtk_imhtml_set_populate_primary_clipboard(
+		GTK_IMHTML(status_box->imhtml), TRUE);
+
 	purple_timeout_remove(status_box->typing);
 	status_box->typing = 0;
 
@@ -2682,6 +2690,10 @@
 			status_box->typing = purple_timeout_add_seconds(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box);
 			gtk_widget_grab_focus(status_box->imhtml);
 			buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(status_box->imhtml));
+
+			gtk_imhtml_set_populate_primary_clipboard(
+				GTK_IMHTML(status_box->imhtml), FALSE);
+
 			gtk_text_buffer_get_bounds(buffer, &start, &end);
 			gtk_text_buffer_move_mark(buffer, gtk_text_buffer_get_mark(buffer, "insert"), &end);
 			gtk_text_buffer_move_mark(buffer, gtk_text_buffer_get_mark(buffer, "selection_bound"), &start);