Mercurial > pidgin.yaz
comparison pidgin/plugins/sendbutton.c @ 24322:f0d5d78e8e47
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.
| author | Elliott Sales de Andrade <qulogic@pidgin.im> |
|---|---|
| date | Thu, 13 Nov 2008 05:33:24 +0000 |
| parents | 068557dd121a |
| children | 73c8e1964eef |
comparison
equal
deleted
inserted
replaced
| 24321:068557dd121a | 24322:f0d5d78e8e47 |
|---|---|
| 35 { | 35 { |
| 36 g_signal_emit_by_name(gtkconv->entry, "message_send"); | 36 g_signal_emit_by_name(gtkconv->entry, "message_send"); |
| 37 } | 37 } |
| 38 | 38 |
| 39 static void | 39 static void |
| 40 input_buffer_changed(GtkTextBuffer *text_buffer, GtkWidget *send_button) | |
| 41 { | |
| 42 if (gtk_text_buffer_get_char_count(text_buffer) != 0) | |
| 43 gtk_widget_set_sensitive(send_button, TRUE); | |
| 44 else | |
| 45 gtk_widget_set_sensitive(send_button, FALSE); | |
| 46 } | |
| 47 | |
| 48 static void | |
| 40 create_send_button_pidgin(PidginConversation *gtkconv) | 49 create_send_button_pidgin(PidginConversation *gtkconv) |
| 41 { | 50 { |
| 42 GtkWidget *send_button; | 51 GtkWidget *send_button; |
| 52 GtkTextBuffer *buf; | |
| 53 guint signal_id; | |
| 43 | 54 |
| 44 send_button = g_object_get_data(G_OBJECT(gtkconv->lower_hbox), | 55 send_button = g_object_get_data(G_OBJECT(gtkconv->lower_hbox), |
| 45 "send_button"); | 56 "send_button"); |
| 46 | 57 |
| 47 if (send_button != NULL) | 58 if (send_button != NULL) |
| 52 G_CALLBACK(send_button_cb), gtkconv); | 63 G_CALLBACK(send_button_cb), gtkconv); |
| 53 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), send_button, FALSE, | 64 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), send_button, FALSE, |
| 54 FALSE, 0); | 65 FALSE, 0); |
| 55 gtk_widget_show(send_button); | 66 gtk_widget_show(send_button); |
| 56 | 67 |
| 68 buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
| 69 if (buf) { | |
| 70 signal_id = g_signal_connect(G_OBJECT(buf), "changed", | |
| 71 G_CALLBACK(input_buffer_changed), | |
| 72 send_button); | |
| 73 g_object_set_data(G_OBJECT(send_button), "buffer-signal", | |
| 74 GINT_TO_POINTER(signal_id)); | |
| 75 input_buffer_changed(buf, send_button); | |
| 76 } | |
| 77 | |
| 57 g_object_set_data(G_OBJECT(gtkconv->lower_hbox), "send_button", | 78 g_object_set_data(G_OBJECT(gtkconv->lower_hbox), "send_button", |
| 58 send_button); | 79 send_button); |
| 59 } | 80 } |
| 60 | 81 |
| 61 static void | 82 static void |
| 64 GtkWidget *send_button = NULL; | 85 GtkWidget *send_button = NULL; |
| 65 | 86 |
| 66 send_button = g_object_get_data(G_OBJECT(gtkconv->lower_hbox), | 87 send_button = g_object_get_data(G_OBJECT(gtkconv->lower_hbox), |
| 67 "send_button"); | 88 "send_button"); |
| 68 if (send_button != NULL) { | 89 if (send_button != NULL) { |
| 90 GtkTextBuffer *buf; | |
| 91 guint signal_id; | |
| 92 | |
| 93 buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
| 94 signal_id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(send_button), | |
| 95 "buffer-signal")); | |
| 96 if (buf && signal_id) | |
| 97 g_signal_handler_disconnect(G_OBJECT(buf), signal_id); | |
| 98 | |
| 69 gtk_widget_destroy(send_button); | 99 gtk_widget_destroy(send_button); |
| 70 g_object_set_data(G_OBJECT(gtkconv->lower_hbox), | 100 g_object_set_data(G_OBJECT(gtkconv->lower_hbox), |
| 71 "send_button", NULL); | 101 "send_button", NULL); |
| 72 } | 102 } |
| 73 } | 103 } |
