pidgin: 2ac6557a: Do not trigger the formatting toolbar bu...

sadrul at pidgin.im sadrul at pidgin.im
Wed Jun 2 23:25:32 EDT 2010


-----------------------------------------------------------------
Revision: 2ac6557a402c32c1c9cc902a500058eb824f0795
Ancestor: 48534a1964f1e97c7be7d751cf33f9edbdf90422
Author: sadrul at pidgin.im
Date: 2010-06-03T03:22:09
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/2ac6557a402c32c1c9cc902a500058eb824f0795

Modified files:
        pidgin/gtkimhtmltoolbar.c

ChangeLog: 

Do not trigger the formatting toolbar buttons on right-click.

Right-clicking the buttons on the formatting toolbar should not trigger
the callback, instead it should pop up the '(Un)Group Items' menu.

-------------- next part --------------
============================================================
--- pidgin/gtkimhtmltoolbar.c	ff592188a0b7b22cd29683fc96b21a5dd43d108c
+++ pidgin/gtkimhtmltoolbar.c	bc5fee66c34d6b952679849fbefcffe34e842ca9
@@ -49,6 +49,9 @@ static void toggle_button_set_active_blo
 										   gboolean is_active,
 										   GtkIMHtmlToolbar *toolbar);
 
+static gboolean
+gtk_imhtmltoolbar_popup_menu(GtkWidget *widget,
+		GdkEventButton *event, GtkIMHtmlToolbar *toolbar);
 
 static void do_bold(GtkWidget *bold, GtkIMHtmlToolbar *toolbar)
 {
@@ -1098,6 +1101,16 @@ menu_position_func (GtkMenu           *m
 		*y -= widget->allocation.height;
 }
 
+static gboolean
+button_activate_on_click(GtkWidget *button, GdkEventButton *event, GtkIMHtmlToolbar *toolbar)
+{
+	if (event->button == 1 && GTK_IS_TOGGLE_BUTTON(button))
+		gtk_widget_activate(button);
+	else if (event->button == 3)
+		return gtk_imhtmltoolbar_popup_menu(button, event, toolbar);
+	return FALSE;
+}
+
 static void pidgin_menu_clicked(GtkWidget *button, GtkMenu *menu)
 {
 	gtk_widget_show_all(GTK_WIDGET(menu));
@@ -1241,6 +1254,7 @@ static void gtk_imhtmltoolbar_create_old
 	for (iter = 0; buttons[iter].stock; iter++) {
 		if (buttons[iter].stock[0]) {
 			button = pidgin_pixbuf_toolbar_button_from_stock(buttons[iter].stock);
+			g_signal_connect(G_OBJECT(button), "button-press-event", G_CALLBACK(button_activate_on_click), toolbar);
 			g_signal_connect(G_OBJECT(button), "clicked",
 					 G_CALLBACK(buttons[iter].callback), toolbar);
 			*(buttons[iter].button) = button;
@@ -1251,6 +1265,7 @@ static void gtk_imhtmltoolbar_create_old
 	}
 	/* create the attention button (this is a bit hacky to not break ABI) */
 	button = pidgin_pixbuf_toolbar_button_from_stock(PIDGIN_STOCK_TOOLBAR_SEND_ATTENTION);
+	g_signal_connect(G_OBJECT(button), "button-press-event", G_CALLBACK(button_activate_on_click), toolbar);
 	g_signal_connect(G_OBJECT(button), "clicked",
 		G_CALLBACK(send_attention_cb), toolbar);
 	g_object_set_data(G_OBJECT(toolbar), "attention", button);
@@ -1382,7 +1397,7 @@ static void gtk_imhtmltoolbar_init (GtkI
 		gtk_container_foreach(GTK_CONTAINER(menuitem), (GtkCallback)enable_markup, NULL);
 	}
 
-	g_signal_connect_swapped(G_OBJECT(font_button), "button-press-event", G_CALLBACK(gtk_widget_activate), font_button);
+	g_signal_connect(G_OBJECT(font_button), "button-press-event", G_CALLBACK(button_activate_on_click), toolbar);
 	g_signal_connect(G_OBJECT(font_button), "activate", G_CALLBACK(pidgin_menu_clicked), font_menu);
 	g_signal_connect(G_OBJECT(font_menu), "deactivate", G_CALLBACK(pidgin_menu_deactivate), font_button);
 
@@ -1423,7 +1438,7 @@ static void gtk_imhtmltoolbar_init (GtkI
 	gtk_menu_shell_append(GTK_MENU_SHELL(insert_menu), menuitem);
 	toolbar->insert_hr = menuitem;
 
-	g_signal_connect_swapped(G_OBJECT(insert_button), "button-press-event", G_CALLBACK(gtk_widget_activate), insert_button);
+	g_signal_connect(G_OBJECT(insert_button), "button-press-event", G_CALLBACK(button_activate_on_click), toolbar);
 	g_signal_connect(G_OBJECT(insert_button), "activate", G_CALLBACK(pidgin_menu_clicked), insert_menu);
 	g_signal_connect(G_OBJECT(insert_menu), "deactivate", G_CALLBACK(pidgin_menu_deactivate), insert_button);
 	toolbar->sml = NULL;
@@ -1443,6 +1458,7 @@ static void gtk_imhtmltoolbar_init (GtkI
 	label = gtk_label_new_with_mnemonic(_("_Smile!"));
 	gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0);
 	gtk_box_pack_start(GTK_BOX(box), smiley_button, FALSE, FALSE, 0);
+	g_signal_connect(G_OBJECT(smiley_button), "button-press-event", G_CALLBACK(button_activate_on_click), toolbar);
 	g_signal_connect_swapped(G_OBJECT(smiley_button), "clicked", G_CALLBACK(gtk_button_clicked), toolbar->smiley);
 	gtk_widget_show_all(smiley_button);
 


More information about the Commits mailing list