comparison pidgin/plugins/sendbutton.c @ 24704:bdd00a7113d7

propagate from branch 'im.pidgin.pidgin' (head f3891f3348abfe90fbe60a054833c12075aa8df4) to branch 'im.pidgin.cpw.malu.xmpp.attention' (head d235bb23dbe13535f85e071d6c4f42e07ac6e0ce)
author Marcus Lundblad <ml@update.uu.se>
date Sun, 16 Nov 2008 15:39:46 +0000
parents f0d5d78e8e47
children 73c8e1964eef
comparison
equal deleted inserted replaced
24703:2f01775c81d5 24704:bdd00a7113d7
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;
54
55 send_button = g_object_get_data(G_OBJECT(gtkconv->lower_hbox),
56 "send_button");
57
58 if (send_button != NULL)
59 return;
43 60
44 send_button = gtk_button_new_with_mnemonic(_("_Send")); 61 send_button = gtk_button_new_with_mnemonic(_("_Send"));
45 g_signal_connect(G_OBJECT(send_button), "clicked", 62 g_signal_connect(G_OBJECT(send_button), "clicked",
46 G_CALLBACK(send_button_cb), gtkconv); 63 G_CALLBACK(send_button_cb), gtkconv);
47 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,
48 FALSE, 0); 65 FALSE, 0);
49 gtk_widget_show(send_button); 66 gtk_widget_show(send_button);
50 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
51 g_object_set_data(G_OBJECT(gtkconv->lower_hbox), "send_button", 78 g_object_set_data(G_OBJECT(gtkconv->lower_hbox), "send_button",
52 send_button); 79 send_button);
53 } 80 }
54 81
55 static void 82 static void
58 GtkWidget *send_button = NULL; 85 GtkWidget *send_button = NULL;
59 86
60 send_button = g_object_get_data(G_OBJECT(gtkconv->lower_hbox), 87 send_button = g_object_get_data(G_OBJECT(gtkconv->lower_hbox),
61 "send_button"); 88 "send_button");
62 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
63 gtk_widget_destroy(send_button); 99 gtk_widget_destroy(send_button);
100 g_object_set_data(G_OBJECT(gtkconv->lower_hbox),
101 "send_button", NULL);
64 } 102 }
65 } 103 }
66 104
67 static void 105 static void
68 conversation_displayed_cb(PidginConversation *gtkconv) 106 conversation_displayed_cb(PidginConversation *gtkconv)