pidgin: 73b71edb: Avoid overwriting the PRIMARY clipboard ...

datallah at pidgin.im datallah at pidgin.im
Sun May 3 19:50:27 EDT 2009


-----------------------------------------------------------------
Revision: 73b71edbab431b600826bb63732d89c94ba8f15f
Ancestor: d9973762180bd415b9e93e59fb1772a54552b885
Author: datallah at pidgin.im
Date: 2009-05-03T23:49:25
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/73b71edbab431b600826bb63732d89c94ba8f15f

Modified files:
        pidgin/gtkimhtml.c pidgin/gtkimhtml.h pidgin/gtkstatusbox.c

ChangeLog: 

Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.

-------------- next part --------------
============================================================
--- pidgin/gtkimhtml.c	eb96e663e8e45ecf74a3d401f726034ffbd0c34c
+++ pidgin/gtkimhtml.c	64a940a6ccd2ee245f8f624d3267c06cbec3f014
@@ -5884,3 +5884,16 @@ void gtk_imhtml_set_return_inserts_newli
 	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);
+	}
+}
============================================================
--- pidgin/gtkimhtml.h	a5407edbd0cfe51ca4c69c702d380875ef61e6d8
+++ pidgin/gtkimhtml.h	cbad21bba236795084bd8b340e6dfb39752261f9
@@ -957,6 +957,16 @@ void gtk_imhtml_set_return_inserts_newli
  */
 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
============================================================
--- pidgin/gtkstatusbox.c	01b067be2b6a50ad41e88ce2208baa5ef38c3a80
+++ pidgin/gtkstatusbox.c	9319817081ce60669c1ba2295bedbedcf0e8f4d9
@@ -265,6 +265,9 @@ update_to_reflect_account_status(PidginS
 			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 @@ static gboolean imhtml_remove_focus(GtkW
 	{
 		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 @@ static void remove_typing_cb(PidginStatu
 		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 @@ static void pidgin_status_box_changed(Pi
 			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);


More information about the Commits mailing list