Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Unified Diff: chrome/browser/gtk/menu_gtk.cc

Issue 159822: linux: fix regression where opening the page menu would cause a reload (Closed)
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/gtk/menu_gtk.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gtk/menu_gtk.cc
diff --git a/chrome/browser/gtk/menu_gtk.cc b/chrome/browser/gtk/menu_gtk.cc
index 0063687e1a57f27eed182419389b37c0e429483a..492bc978ca3f75c3df47f934179eff397af4fdd6 100644
--- a/chrome/browser/gtk/menu_gtk.cc
+++ b/chrome/browser/gtk/menu_gtk.cc
@@ -15,6 +15,8 @@
using gtk_util::ConvertAcceleratorsFromWindowsStyle;
+bool MenuGtk::block_activation_ = false;
+
MenuGtk::MenuGtk(MenuGtk::Delegate* delegate,
const MenuCreateMaterial* menu_data,
GtkAccelGroup* accel_group)
@@ -227,25 +229,29 @@ void MenuGtk::BuildMenuFromDelegate() {
// static
void MenuGtk::OnMenuItemActivated(GtkMenuItem* menuitem, MenuGtk* menu) {
+ if (block_activation_)
+ return;
+
// We receive activation messages when highlighting a menu that has a
// submenu. Ignore them.
- if (!gtk_menu_item_get_submenu(menuitem)) {
- const MenuCreateMaterial* data =
- reinterpret_cast<const MenuCreateMaterial*>(
- g_object_get_data(G_OBJECT(menuitem), "menu-data"));
-
- int id;
- if (data) {
- id = data->id;
- } else {
- id = reinterpret_cast<intptr_t>(g_object_get_data(G_OBJECT(menuitem),
- "menu-id"));
- }
+ if (gtk_menu_item_get_submenu(menuitem))
+ return;
Elliot Glaysher 2009/08/03 22:46:34 You may be able to pull this check out; I think th
Evan Martin 2009/08/03 22:58:41 Nope, you get it when mousing through the menu. :
+
+ const MenuCreateMaterial* data =
+ reinterpret_cast<const MenuCreateMaterial*>(
+ g_object_get_data(G_OBJECT(menuitem), "menu-data"));
- // The menu item can still be activated by hotkeys even if it is disabled.
- if (menu->delegate_->IsCommandEnabled(id))
- menu->delegate_->ExecuteCommand(id);
+ int id;
+ if (data) {
+ id = data->id;
+ } else {
+ id = reinterpret_cast<intptr_t>(g_object_get_data(G_OBJECT(menuitem),
+ "menu-id"));
}
+
+ // The menu item can still be activated by hotkeys even if it is disabled.
+ if (menu->delegate_->IsCommandEnabled(id))
+ menu->delegate_->ExecuteCommand(id);
}
// static
@@ -325,20 +331,15 @@ void MenuGtk::SetMenuItemInfo(GtkWidget* widget, gpointer userdata) {
// the underlying "active" property will also call the "activate" handler
// for this menu item. So we prevent the "activate" handler from
// being called while we set the checkbox.
- g_signal_handlers_block_matched(
- item, G_SIGNAL_MATCH_FUNC,
- 0, 0, NULL,
- reinterpret_cast<void*>(OnMenuItemActivated),
- NULL);
-
- gtk_check_menu_item_set_active(
- item, menu->delegate_->IsItemChecked(id));
-
- g_signal_handlers_unblock_matched(
- item, G_SIGNAL_MATCH_FUNC,
- 0, 0, NULL,
- reinterpret_cast<void*>(OnMenuItemActivated),
- NULL);
+ // Why not use one of the glib signal-blocking functions? Because when we
+ // toggle a radio button, it will deactivate one of the other radio buttons,
+ // which we don't have a pointer to.
+ // Wny not make this a member variable? Because "menu" is a pointer to the
+ // root of the MenuGtk and we want to disable *all* MenuGtks, including
+ // submenus.
+ block_activation_ = true;
+ gtk_check_menu_item_set_active(item, menu->delegate_->IsItemChecked(id));
+ block_activation_ = false;
}
if (GTK_IS_MENU_ITEM(widget)) {
« no previous file with comments | « chrome/browser/gtk/menu_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698