diff options
-rw-r--r-- | chrome/browser/gtk/bookmark_menu_controller_gtk.cc | 21 | ||||
-rw-r--r-- | chrome/browser/gtk/bookmark_menu_controller_gtk.h | 9 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_chrome_button.cc | 8 |
3 files changed, 36 insertions, 2 deletions
diff --git a/chrome/browser/gtk/bookmark_menu_controller_gtk.cc b/chrome/browser/gtk/bookmark_menu_controller_gtk.cc index 6d2baca..23e198a 100644 --- a/chrome/browser/gtk/bookmark_menu_controller_gtk.cc +++ b/chrome/browser/gtk/bookmark_menu_controller_gtk.cc @@ -12,6 +12,7 @@ #include "base/string_util.h" #include "chrome/browser/gtk/bookmark_context_menu.h" #include "chrome/browser/gtk/bookmark_utils_gtk.h" +#include "chrome/browser/gtk/gtk_chrome_button.h" #include "chrome/browser/gtk/gtk_dnd_util.h" #include "chrome/browser/gtk/gtk_theme_provider.h" #include "chrome/browser/gtk/menu_gtk.h" @@ -55,9 +56,12 @@ BookmarkMenuController::BookmarkMenuController(Browser* browser, page_navigator_(navigator), parent_window_(window), node_(node), - ignore_button_release_(false) { + ignore_button_release_(false), + triggering_widget_(NULL) { menu_.Own(gtk_menu_new()); BuildMenu(node, start_child_index, menu_.get()); + g_signal_connect(menu_.get(), "hide", + G_CALLBACK(OnMenuHidden), this); gtk_widget_show_all(menu_.get()); } @@ -70,6 +74,9 @@ void BookmarkMenuController::Popup(GtkWidget* widget, gint button_type, guint32 timestamp) { profile_->GetBookmarkModel()->AddObserver(this); + triggering_widget_ = widget; + gtk_chrome_button_set_paint_state(GTK_CHROME_BUTTON(widget), + GTK_STATE_ACTIVE); gtk_menu_popup(GTK_MENU(menu_.get()), NULL, NULL, &MenuGtk::MenuPositionFunc, widget, button_type, timestamp); @@ -157,6 +164,7 @@ void BookmarkMenuController::BuildMenu(const BookmarkNode* parent, } } +// static gboolean BookmarkMenuController::OnButtonPressed( GtkWidget* sender, GdkEventButton* event, @@ -181,6 +189,7 @@ gboolean BookmarkMenuController::OnButtonPressed( return FALSE; } +// static gboolean BookmarkMenuController::OnButtonReleased( GtkWidget* sender, GdkEventButton* event, @@ -206,6 +215,16 @@ gboolean BookmarkMenuController::OnButtonReleased( return FALSE; } +// static +void BookmarkMenuController::OnMenuHidden(GtkWidget* menu, + BookmarkMenuController* controller) { + if (controller->triggering_widget_) { + gtk_chrome_button_unset_paint_state( + GTK_CHROME_BUTTON(controller->triggering_widget_)); + } +} + +// static void BookmarkMenuController::OnMenuItemActivated( GtkMenuItem* menu_item, BookmarkMenuController* controller) { controller->NavigateToMenuItem(GTK_WIDGET(menu_item), CURRENT_TAB); diff --git a/chrome/browser/gtk/bookmark_menu_controller_gtk.h b/chrome/browser/gtk/bookmark_menu_controller_gtk.h index d24dcf2..63788f1 100644 --- a/chrome/browser/gtk/bookmark_menu_controller_gtk.h +++ b/chrome/browser/gtk/bookmark_menu_controller_gtk.h @@ -34,7 +34,7 @@ class BookmarkMenuController : public BaseBookmarkModelObserver { bool show_other_folder); virtual ~BookmarkMenuController(); - // Pops up the menu. + // Pops up the menu. |widget| must be a GtkChromeButton. void Popup(GtkWidget* widget, gint button_type, guint32 timestamp); // Overridden from BaseBookmarkModelObserver: @@ -64,6 +64,10 @@ class BookmarkMenuController : public BaseBookmarkModelObserver { GdkEventButton* event, BookmarkMenuController* controller); + // We have to stop drawing |triggering_widget_| as active when the menu + // closes. + static void OnMenuHidden(GtkWidget* menu, BookmarkMenuController* controller); + // We respond to the activate signal because things other than mouse button // events can trigger it. static void OnMenuItemActivated(GtkMenuItem* menuitem, @@ -105,6 +109,9 @@ class BookmarkMenuController : public BaseBookmarkModelObserver { // dragging). bool ignore_button_release_; + // The widget we are showing for (i.e. the bookmark bar folder button). + GtkWidget* triggering_widget_; + // Mapping from node to GtkMenuItem menu id. This only contains entries for // nodes of type URL. std::map<const BookmarkNode*, GtkWidget*> node_to_menu_widget_map_; diff --git a/chrome/browser/gtk/gtk_chrome_button.cc b/chrome/browser/gtk/gtk_chrome_button.cc index 6b35716..0a7942f 100644 --- a/chrome/browser/gtk/gtk_chrome_button.cc +++ b/chrome/browser/gtk/gtk_chrome_button.cc @@ -39,6 +39,13 @@ static gboolean gtk_chrome_button_expose(GtkWidget* widget, GdkEventExpose* event); static void gtk_chrome_button_class_init(GtkChromeButtonClass* button_class) { + gtk_rc_parse_string( + "style \"chrome-button\" {" + " GtkButton::child-displacement-x = 0" + " GtkButton::child-displacement-y = 0" + "}" + "widget \"*chrome-button\" style \"chrome-button\""); + GObjectClass* gobject_class = G_OBJECT_CLASS(button_class); GtkWidgetClass* widget_class = reinterpret_cast<GtkWidgetClass*>(button_class); widget_class->expose_event = gtk_chrome_button_expose; @@ -73,6 +80,7 @@ static void gtk_chrome_button_init(GtkChromeButton* button) { priv->paint_state = -1; priv->use_gtk_rendering = FALSE; + gtk_widget_set_name(GTK_WIDGET(button), "chrome-button"); gtk_widget_set_app_paintable(GTK_WIDGET(button), TRUE); GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); |