pidgin: 1fde8168: Make the Send button insensitive when th...

qulogic at pidgin.im qulogic at pidgin.im
Fri Nov 14 02:00:39 EST 2008


-----------------------------------------------------------------
Revision: 1fde8168a6eb08e558dabefc069a0eba15a5a6ee
Ancestor: 37765988fd42bcd48342876626906fd125e3f611
Author: qulogic at pidgin.im
Date: 2008-11-13T05:33:24
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/1fde8168a6eb08e558dabefc069a0eba15a5a6ee

Modified files:
        pidgin/plugins/sendbutton.c

ChangeLog: 

Make the Send button insensitive when there is no text in the input buffer.
Has a few minor format changes from the original patch by Gabriel.

Fixes #7529.

-------------- next part --------------
============================================================
--- pidgin/plugins/sendbutton.c	3c6de1f95947418e11c7d5d728757cabd52f5503
+++ pidgin/plugins/sendbutton.c	abedaeb186be86dfdef9ffe4b8ebb55af87a6a73
@@ -37,9 +37,20 @@ static void
 }
 
 static void
+input_buffer_changed(GtkTextBuffer *text_buffer, GtkWidget *send_button)
+{
+	if (gtk_text_buffer_get_char_count(text_buffer) != 0)
+		gtk_widget_set_sensitive(send_button, TRUE);
+	else
+		gtk_widget_set_sensitive(send_button, FALSE);
+}
+
+static void
 create_send_button_pidgin(PidginConversation *gtkconv)
 {
 	GtkWidget *send_button;
+	GtkTextBuffer *buf;
+	guint signal_id;
 
 	send_button = g_object_get_data(G_OBJECT(gtkconv->lower_hbox),
 	                                "send_button");
@@ -54,6 +65,16 @@ create_send_button_pidgin(PidginConversa
 	                 FALSE, 0);
 	gtk_widget_show(send_button);
 
+	buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry));
+	if (buf) {
+		signal_id = g_signal_connect(G_OBJECT(buf), "changed",
+		                             G_CALLBACK(input_buffer_changed),
+		                             send_button);
+		g_object_set_data(G_OBJECT(send_button), "buffer-signal",
+		                  GINT_TO_POINTER(signal_id));
+		input_buffer_changed(buf, send_button);
+	}
+ 
 	g_object_set_data(G_OBJECT(gtkconv->lower_hbox), "send_button",
 	                  send_button);
 }
@@ -66,6 +87,15 @@ remove_send_button_pidgin(PidginConversa
 	send_button = g_object_get_data(G_OBJECT(gtkconv->lower_hbox),
 	                                "send_button");
 	if (send_button != NULL) {
+		GtkTextBuffer *buf;
+		guint signal_id;
+
+		buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry));
+		signal_id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(send_button),
+		                                              "buffer-signal"));
+		if (buf && signal_id)
+			g_signal_handler_disconnect(G_OBJECT(buf), signal_id);
+
 		gtk_widget_destroy(send_button);
 		g_object_set_data(G_OBJECT(gtkconv->lower_hbox),
 		                  "send_button", NULL);


More information about the Commits mailing list