summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/menu_gtk.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-04 21:52:29 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-04 21:52:29 +0000
commitb08cadb9ab90b41af81b9fd8da65fb52433c8004 (patch)
tree55738edf0c98b596cd6f9a89533e92f5a82c6fff /chrome/browser/gtk/menu_gtk.cc
parent021d688a1e02ae7bd88e54162d5d25e1dae52e7c (diff)
downloadchromium_src-b08cadb9ab90b41af81b9fd8da65fb52433c8004.zip
chromium_src-b08cadb9ab90b41af81b9fd8da65fb52433c8004.tar.gz
chromium_src-b08cadb9ab90b41af81b9fd8da65fb52433c8004.tar.bz2
GTK: implement bookmark manager copy/paste.
- Refactor bookmark util clipboard code to be cross platform. - Add a CBF_DATA format for writing arbitrary data to the clipboard. - Change MenuGtk so that showing a menu only makes the menu items update asynchronously. This way we can show the menu immediately and we won't get in trouble if the delegate's IsCommandEnabled() runs a nested message loop. I did not do any mac-side implementation of the new clipboard stuff. The implementation should be easy when they get around to writing the bookmark manager. Review URL: http://codereview.chromium.org/159815 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22419 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/menu_gtk.cc')
-rw-r--r--chrome/browser/gtk/menu_gtk.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/chrome/browser/gtk/menu_gtk.cc b/chrome/browser/gtk/menu_gtk.cc
index 492bc97..73a3296 100644
--- a/chrome/browser/gtk/menu_gtk.cc
+++ b/chrome/browser/gtk/menu_gtk.cc
@@ -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 @@ MenuGtk::MenuGtk(MenuGtk::Delegate* delegate,
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,
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 @@ MenuGtk::~MenuGtk() {
}
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 @@ void MenuGtk::MenuPositionFunc(GtkMenu* menu,
*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