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

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

Issue 6732007: Native menu implementation for bug 5679. Followup to http://codereview.chromium.org/2928005/ Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: More code review updates. Created 9 years, 8 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/ui/gtk/menu_gtk.h ('k') | views/controls/menu/native_menu_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/menu_gtk.cc
diff --git a/chrome/browser/ui/gtk/menu_gtk.cc b/chrome/browser/ui/gtk/menu_gtk.cc
index 19e4d1264494556eebd6e4a2238be1f6d8c1bf55..49fc9e5e3ea35b36cb8ede09de534ead129fd609 100644
--- a/chrome/browser/ui/gtk/menu_gtk.cc
+++ b/chrome/browser/ui/gtk/menu_gtk.cc
@@ -284,6 +284,7 @@ MenuGtk::MenuGtk(MenuGtk::Delegate* delegate,
DCHECK(model);
g_object_ref_sink(menu_);
ConnectSignalHandlers();
+ model_->SetMenuModelDelegate(this);
BuildMenuFromModel();
}
@@ -400,6 +401,20 @@ void MenuGtk::Cancel() {
gtk_menu_popdown(GTK_MENU(menu_));
}
+void MenuGtk::OnIconChanged(int model_index) {
+ GList* items = gtk_container_get_children(GTK_CONTAINER(menu_));
+ GtkWidget* menu_item = GTK_WIDGET(g_list_nth(items, model_index)->data);
+ g_list_free(items);
+ SkBitmap icon;
+ ui::MenuModel* model = ModelForMenuItem(GTK_MENU_ITEM(menu_item));
Evan Stade 2011/04/08 16:45:19 I'd just use model_
+ if (model->GetIconAt(model_index, &icon)) {
+ GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&icon);
+ gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),
+ gtk_image_new_from_pixbuf(pixbuf));
+ g_object_unref(pixbuf);
+ }
+}
+
void MenuGtk::UpdateMenu() {
gtk_container_foreach(GTK_CONTAINER(menu_), SetMenuItemInfo, this);
}
@@ -723,6 +738,7 @@ void MenuGtk::OnMenuShow(GtkWidget* widget) {
}
void MenuGtk::OnMenuHidden(GtkWidget* widget) {
+ model_->SetMenuModelDelegate(NULL);
if (delegate_)
delegate_->StoppedShowing();
model_->MenuClosed();
@@ -830,3 +846,4 @@ void MenuGtk::SetMenuItemInfo(GtkWidget* widget, gpointer userdata) {
}
}
}
+
« no previous file with comments | « chrome/browser/ui/gtk/menu_gtk.h ('k') | views/controls/menu/native_menu_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698