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

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

Issue 2864044: GTK: Fix highlight and image colors in the new wrench menu. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: estade comments Created 10 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 e8c856b3583753551a27479ebacf8213b4657853..179b8d6375f4f09c203155be57b71c10eec34e17 100644
--- a/chrome/browser/gtk/menu_gtk.cc
+++ b/chrome/browser/gtk/menu_gtk.cc
@@ -92,7 +92,7 @@ void SetupDynamicLabelMenuButton(GtkWidget* button,
int index) {
if (model->IsLabelDynamicAt(index)) {
g_object_set_data(G_OBJECT(button), "button-model",
- reinterpret_cast<void*>(model));
+ model);
g_object_set_data(G_OBJECT(button), "button-model-id",
GINT_TO_POINTER(index));
g_signal_connect(menu, "show", G_CALLBACK(OnSubmenuShowButtonMenuItem),
@@ -100,6 +100,32 @@ void SetupDynamicLabelMenuButton(GtkWidget* button,
}
}
+void OnSubmenuShowButtonImage(GtkWidget* widget, GtkButton* button) {
+ MenuGtk::Delegate* delegate = reinterpret_cast<MenuGtk::Delegate*>(
+ g_object_get_data(G_OBJECT(button), "menu-gtk-delegate"));
+ int icon_idr = GPOINTER_TO_INT(g_object_get_data(
+ G_OBJECT(button), "button-image-idr"));
+
+ GtkIconSet* icon_set = delegate->GetIconSetForId(icon_idr);
+ if (icon_set) {
+ gtk_button_set_image(
+ button, gtk_image_new_from_icon_set(icon_set,
+ GTK_ICON_SIZE_MENU));
+ }
+}
+
+void SetupImageIcon(GtkWidget* button,
+ GtkWidget* menu,
+ int icon_idr,
+ MenuGtk::Delegate* menu_gtk_delegate) {
+ g_object_set_data(G_OBJECT(button), "button-image-idr",
+ GINT_TO_POINTER(icon_idr));
+ g_object_set_data(G_OBJECT(button), "menu-gtk-delegate",
+ menu_gtk_delegate);
+
+ g_signal_connect(menu, "show", G_CALLBACK(OnSubmenuShowButtonImage), button);
+}
+
// Popup menus may get squished if they open up too close to the bottom of the
// screen. This function takes the size of the screen, the size of the menu,
// an optional widget, the Y position of the mouse click, and adjusts the popup
@@ -329,8 +355,7 @@ void MenuGtk::BuildSubmenuFromModel(menus::MenuModel* model, GtkWidget* menu) {
GTK_ACCEL_VISIBLE);
}
- g_object_set_data(G_OBJECT(menu_item), "model",
- reinterpret_cast<void*>(model));
+ g_object_set_data(G_OBJECT(menu_item), "model", model);
AppendMenuItemToMenu(i, menu_item, menu, connect_to_activate);
if (model->IsLabelDynamicAt(i)) {
@@ -348,8 +373,7 @@ GtkWidget* MenuGtk::BuildButtomMenuItem(menus::ButtonMenuItemModel* model,
RemoveWindowsStyleAccelerators(UTF16ToUTF8(model->label())).c_str());
// Set up the callback to the model for when it is clicked.
- g_object_set_data(G_OBJECT(menu_item), "button-model",
- reinterpret_cast<void*>(model));
+ g_object_set_data(G_OBJECT(menu_item), "button-model", model);
g_signal_connect(menu_item, "button-pushed",
G_CALLBACK(OnMenuButtonPressed), this);
@@ -366,13 +390,7 @@ GtkWidget* MenuGtk::BuildButtomMenuItem(menus::ButtonMenuItemModel* model,
int icon_idr;
if (model->GetIconAt(i, &icon_idr)) {
- // TODO(erg): This should go through the GtkThemeProvider so we can
- // get a version tinted to label color.
- gtk_button_set_image(
- GTK_BUTTON(button),
- gtk_image_new_from_pixbuf(
- ResourceBundle::GetSharedInstance().
- GetPixbufNamed(icon_idr)));
+ SetupImageIcon(button, menu, icon_idr, delegate_);
} else {
gtk_button_set_label(
GTK_BUTTON(button),
« 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