Mercurial > pidgin.yaz
comparison pidgin/gtkimhtmltoolbar.c @ 30580:7a28e9b12038
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.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Thu, 03 Jun 2010 03:22:09 +0000 |
parents | 45a94940c122 |
children | 89de882d25b1 dd6575f20790 |
comparison
equal
deleted
inserted
replaced
30579:e9f4deddddd8 | 30580:7a28e9b12038 |
---|---|
47 | 47 |
48 static void toggle_button_set_active_block(GtkToggleButton *button, | 48 static void toggle_button_set_active_block(GtkToggleButton *button, |
49 gboolean is_active, | 49 gboolean is_active, |
50 GtkIMHtmlToolbar *toolbar); | 50 GtkIMHtmlToolbar *toolbar); |
51 | 51 |
52 static gboolean | |
53 gtk_imhtmltoolbar_popup_menu(GtkWidget *widget, | |
54 GdkEventButton *event, GtkIMHtmlToolbar *toolbar); | |
52 | 55 |
53 static void do_bold(GtkWidget *bold, GtkIMHtmlToolbar *toolbar) | 56 static void do_bold(GtkWidget *bold, GtkIMHtmlToolbar *toolbar) |
54 { | 57 { |
55 g_return_if_fail(toolbar != NULL); | 58 g_return_if_fail(toolbar != NULL); |
56 gtk_imhtml_toggle_bold(GTK_IMHTML(toolbar->imhtml)); | 59 gtk_imhtml_toggle_bold(GTK_IMHTML(toolbar->imhtml)); |
1094 | 1097 |
1095 pidgin_menu_position_func_helper(menu, x, y, push_in, data); | 1098 pidgin_menu_position_func_helper(menu, x, y, push_in, data); |
1096 | 1099 |
1097 if (savy > *y + ythickness + 1) | 1100 if (savy > *y + ythickness + 1) |
1098 *y -= widget->allocation.height; | 1101 *y -= widget->allocation.height; |
1102 } | |
1103 | |
1104 static gboolean | |
1105 button_activate_on_click(GtkWidget *button, GdkEventButton *event, GtkIMHtmlToolbar *toolbar) | |
1106 { | |
1107 if (event->button == 1 && GTK_IS_TOGGLE_BUTTON(button)) | |
1108 gtk_widget_activate(button); | |
1109 else if (event->button == 3) | |
1110 return gtk_imhtmltoolbar_popup_menu(button, event, toolbar); | |
1111 return FALSE; | |
1099 } | 1112 } |
1100 | 1113 |
1101 static void pidgin_menu_clicked(GtkWidget *button, GtkMenu *menu) | 1114 static void pidgin_menu_clicked(GtkWidget *button, GtkMenu *menu) |
1102 { | 1115 { |
1103 gtk_widget_show_all(GTK_WIDGET(menu)); | 1116 gtk_widget_show_all(GTK_WIDGET(menu)); |
1239 hbox = gtk_hbox_new(FALSE, 0); | 1252 hbox = gtk_hbox_new(FALSE, 0); |
1240 | 1253 |
1241 for (iter = 0; buttons[iter].stock; iter++) { | 1254 for (iter = 0; buttons[iter].stock; iter++) { |
1242 if (buttons[iter].stock[0]) { | 1255 if (buttons[iter].stock[0]) { |
1243 button = pidgin_pixbuf_toolbar_button_from_stock(buttons[iter].stock); | 1256 button = pidgin_pixbuf_toolbar_button_from_stock(buttons[iter].stock); |
1257 g_signal_connect(G_OBJECT(button), "button-press-event", G_CALLBACK(button_activate_on_click), toolbar); | |
1244 g_signal_connect(G_OBJECT(button), "clicked", | 1258 g_signal_connect(G_OBJECT(button), "clicked", |
1245 G_CALLBACK(buttons[iter].callback), toolbar); | 1259 G_CALLBACK(buttons[iter].callback), toolbar); |
1246 *(buttons[iter].button) = button; | 1260 *(buttons[iter].button) = button; |
1247 gtk_tooltips_set_tip(toolbar->tooltips, button, buttons[iter].tooltip, NULL); | 1261 gtk_tooltips_set_tip(toolbar->tooltips, button, buttons[iter].tooltip, NULL); |
1248 } else | 1262 } else |
1249 button = gtk_vseparator_new(); | 1263 button = gtk_vseparator_new(); |
1250 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | 1264 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
1251 } | 1265 } |
1252 /* create the attention button (this is a bit hacky to not break ABI) */ | 1266 /* create the attention button (this is a bit hacky to not break ABI) */ |
1253 button = pidgin_pixbuf_toolbar_button_from_stock(PIDGIN_STOCK_TOOLBAR_SEND_ATTENTION); | 1267 button = pidgin_pixbuf_toolbar_button_from_stock(PIDGIN_STOCK_TOOLBAR_SEND_ATTENTION); |
1268 g_signal_connect(G_OBJECT(button), "button-press-event", G_CALLBACK(button_activate_on_click), toolbar); | |
1254 g_signal_connect(G_OBJECT(button), "clicked", | 1269 g_signal_connect(G_OBJECT(button), "clicked", |
1255 G_CALLBACK(send_attention_cb), toolbar); | 1270 G_CALLBACK(send_attention_cb), toolbar); |
1256 g_object_set_data(G_OBJECT(toolbar), "attention", button); | 1271 g_object_set_data(G_OBJECT(toolbar), "attention", button); |
1257 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Send Attention"), NULL); | 1272 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Send Attention"), NULL); |
1258 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | 1273 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
1380 g_signal_connect(G_OBJECT(old), "notify::sensitive", | 1395 g_signal_connect(G_OBJECT(old), "notify::sensitive", |
1381 G_CALLBACK(button_sensitiveness_changed), menuitem); | 1396 G_CALLBACK(button_sensitiveness_changed), menuitem); |
1382 gtk_container_foreach(GTK_CONTAINER(menuitem), (GtkCallback)enable_markup, NULL); | 1397 gtk_container_foreach(GTK_CONTAINER(menuitem), (GtkCallback)enable_markup, NULL); |
1383 } | 1398 } |
1384 | 1399 |
1385 g_signal_connect_swapped(G_OBJECT(font_button), "button-press-event", G_CALLBACK(gtk_widget_activate), font_button); | 1400 g_signal_connect(G_OBJECT(font_button), "button-press-event", G_CALLBACK(button_activate_on_click), toolbar); |
1386 g_signal_connect(G_OBJECT(font_button), "activate", G_CALLBACK(pidgin_menu_clicked), font_menu); | 1401 g_signal_connect(G_OBJECT(font_button), "activate", G_CALLBACK(pidgin_menu_clicked), font_menu); |
1387 g_signal_connect(G_OBJECT(font_menu), "deactivate", G_CALLBACK(pidgin_menu_deactivate), font_button); | 1402 g_signal_connect(G_OBJECT(font_menu), "deactivate", G_CALLBACK(pidgin_menu_deactivate), font_button); |
1388 | 1403 |
1389 /* Sep */ | 1404 /* Sep */ |
1390 sep = gtk_vseparator_new(); | 1405 sep = gtk_vseparator_new(); |
1421 menuitem = gtk_menu_item_new_with_mnemonic(_("_Horizontal rule")); | 1436 menuitem = gtk_menu_item_new_with_mnemonic(_("_Horizontal rule")); |
1422 g_signal_connect(G_OBJECT(menuitem), "activate" , G_CALLBACK(insert_hr_cb), toolbar); | 1437 g_signal_connect(G_OBJECT(menuitem), "activate" , G_CALLBACK(insert_hr_cb), toolbar); |
1423 gtk_menu_shell_append(GTK_MENU_SHELL(insert_menu), menuitem); | 1438 gtk_menu_shell_append(GTK_MENU_SHELL(insert_menu), menuitem); |
1424 toolbar->insert_hr = menuitem; | 1439 toolbar->insert_hr = menuitem; |
1425 | 1440 |
1426 g_signal_connect_swapped(G_OBJECT(insert_button), "button-press-event", G_CALLBACK(gtk_widget_activate), insert_button); | 1441 g_signal_connect(G_OBJECT(insert_button), "button-press-event", G_CALLBACK(button_activate_on_click), toolbar); |
1427 g_signal_connect(G_OBJECT(insert_button), "activate", G_CALLBACK(pidgin_menu_clicked), insert_menu); | 1442 g_signal_connect(G_OBJECT(insert_button), "activate", G_CALLBACK(pidgin_menu_clicked), insert_menu); |
1428 g_signal_connect(G_OBJECT(insert_menu), "deactivate", G_CALLBACK(pidgin_menu_deactivate), insert_button); | 1443 g_signal_connect(G_OBJECT(insert_menu), "deactivate", G_CALLBACK(pidgin_menu_deactivate), insert_button); |
1429 toolbar->sml = NULL; | 1444 toolbar->sml = NULL; |
1430 | 1445 |
1431 /* Sep */ | 1446 /* Sep */ |
1441 image = gtk_image_new_from_stock(PIDGIN_STOCK_TOOLBAR_SMILEY, gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL)); | 1456 image = gtk_image_new_from_stock(PIDGIN_STOCK_TOOLBAR_SMILEY, gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL)); |
1442 gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0); | 1457 gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0); |
1443 label = gtk_label_new_with_mnemonic(_("_Smile!")); | 1458 label = gtk_label_new_with_mnemonic(_("_Smile!")); |
1444 gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0); | 1459 gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0); |
1445 gtk_box_pack_start(GTK_BOX(box), smiley_button, FALSE, FALSE, 0); | 1460 gtk_box_pack_start(GTK_BOX(box), smiley_button, FALSE, FALSE, 0); |
1461 g_signal_connect(G_OBJECT(smiley_button), "button-press-event", G_CALLBACK(button_activate_on_click), toolbar); | |
1446 g_signal_connect_swapped(G_OBJECT(smiley_button), "clicked", G_CALLBACK(gtk_button_clicked), toolbar->smiley); | 1462 g_signal_connect_swapped(G_OBJECT(smiley_button), "clicked", G_CALLBACK(gtk_button_clicked), toolbar->smiley); |
1447 gtk_widget_show_all(smiley_button); | 1463 gtk_widget_show_all(smiley_button); |
1448 | 1464 |
1449 /* Sep */ | 1465 /* Sep */ |
1450 sep = gtk_vseparator_new(); | 1466 sep = gtk_vseparator_new(); |