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

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

Issue 159815: Refactor bookmark clipboard code to be cross platform. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix UMR Created 11 years, 4 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
« base/clipboard_win.cc ('K') | « 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
===================================================================
--- chrome/browser/gtk/menu_gtk.cc (revision 22359)
+++ chrome/browser/gtk/menu_gtk.cc (working copy)
@@ -7,6 +7,7 @@
#include "app/l10n_util.h"
#include "base/gfx/gtk_util.h"
#include "base/logging.h"
+#include "base/message_loop.h"
#include "base/stl_util-inl.h"
#include "base/string_util.h"
#include "chrome/browser/gtk/standard_menus.h"
@@ -22,7 +23,8 @@
GtkAccelGroup* accel_group)
: delegate_(delegate),
dummy_accel_group_(gtk_accel_group_new()),
- menu_(gtk_menu_new()) {
+ menu_(gtk_menu_new()),
+ factory_(this) {
ConnectSignalHandlers();
BuildMenuIn(menu_.get(), menu_data, accel_group);
}
@@ -30,7 +32,8 @@
MenuGtk::MenuGtk(MenuGtk::Delegate* delegate, bool load)
: delegate_(delegate),
dummy_accel_group_(NULL),
- menu_(gtk_menu_new()) {
+ menu_(gtk_menu_new()),
+ factory_(this) {
ConnectSignalHandlers();
if (load)
BuildMenuFromDelegate();
@@ -43,6 +46,8 @@
}
void MenuGtk::ConnectSignalHandlers() {
+ // We connect afterwards because OnMenuShow calls SetMenuItemInfo, which may
+ // take a long time or even start a nested message loop.
g_signal_connect(menu_.get(), "show", G_CALLBACK(OnMenuShow), this);
g_signal_connect(menu_.get(), "hide", G_CALLBACK(OnMenuHidden), this);
}
@@ -293,10 +298,14 @@
*push_in = FALSE;
}
+void MenuGtk::UpdateMenu() {
+ gtk_container_foreach(GTK_CONTAINER(menu_.get()), SetMenuItemInfo, this);
+}
+
// static
void MenuGtk::OnMenuShow(GtkWidget* widget, MenuGtk* menu) {
- gtk_container_foreach(GTK_CONTAINER(menu->menu_.get()),
- SetMenuItemInfo, menu);
+ MessageLoop::current()->PostTask(FROM_HERE,
+ menu->factory_.NewRunnableMethod(&MenuGtk::UpdateMenu));
}
// static
« base/clipboard_win.cc ('K') | « chrome/browser/gtk/menu_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698