summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/bookmarks/bookmark_menu_controller_gtk.cc12
-rw-r--r--chrome/browser/gtk/menu_gtk.cc34
2 files changed, 30 insertions, 16 deletions
diff --git a/chrome/browser/bookmarks/bookmark_menu_controller_gtk.cc b/chrome/browser/bookmarks/bookmark_menu_controller_gtk.cc
index ffc3953..293dab2 100644
--- a/chrome/browser/bookmarks/bookmark_menu_controller_gtk.cc
+++ b/chrome/browser/bookmarks/bookmark_menu_controller_gtk.cc
@@ -4,11 +4,13 @@
#include "chrome/browser/bookmarks/bookmark_menu_controller_gtk.h"
+#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
#include "base/string_util.h"
#include "chrome/browser/bookmarks/bookmark_context_menu.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/page_navigator.h"
-#include "app/resource_bundle.h"
+#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "webkit/glue/window_open_disposition.h"
@@ -50,7 +52,8 @@ void BookmarkMenuController::BookmarkNodeFavIconLoaded(BookmarkModel* model,
}
bool BookmarkMenuController::IsCommandEnabled(int id) const {
- return true;
+ // -1 is reserved for empty.
+ return id != -1;
}
void BookmarkMenuController::ExecuteCommand(int id) {
@@ -98,4 +101,9 @@ void BookmarkMenuController::BuildMenu(BookmarkNode* parent,
}
menu_id_to_node_map_[id] = node;
}
+
+ if (parent->GetChildCount() == 0) {
+ menu->AppendMenuItemWithLabel(
+ -1, l10n_util::GetStringUTF8(IDS_MENU_EMPTY_SUBMENU));
+ }
}
diff --git a/chrome/browser/gtk/menu_gtk.cc b/chrome/browser/gtk/menu_gtk.cc
index 6d12f26..b6df673 100644
--- a/chrome/browser/gtk/menu_gtk.cc
+++ b/chrome/browser/gtk/menu_gtk.cc
@@ -342,26 +342,32 @@ void MenuGtk::MenuPositionFunc(GtkMenu* menu,
// static
void MenuGtk::SetMenuItemInfo(GtkWidget* widget, gpointer userdata) {
MenuGtk* menu = reinterpret_cast<MenuGtk*>(userdata);
+ int id;
+
const MenuCreateMaterial* data =
reinterpret_cast<const MenuCreateMaterial*>(
g_object_get_data(G_OBJECT(widget), "menu-data"));
-
if (data) {
- if (GTK_IS_CHECK_MENU_ITEM(widget)) {
- GtkCheckMenuItem* item = GTK_CHECK_MENU_ITEM(widget);
- gtk_check_menu_item_set_active(
- item, menu->delegate_->IsItemChecked(data->id));
- }
+ id = data->id;
+ } else {
+ id = reinterpret_cast<int>(
+ g_object_get_data(G_OBJECT(widget), "menu-id"));
+ }
+
+ if (GTK_IS_CHECK_MENU_ITEM(widget)) {
+ GtkCheckMenuItem* item = GTK_CHECK_MENU_ITEM(widget);
+ gtk_check_menu_item_set_active(
+ item, menu->delegate_->IsItemChecked(id));
+ }
- if (GTK_IS_MENU_ITEM(widget)) {
- gtk_widget_set_sensitive(
- widget, menu->delegate_->IsCommandEnabled(data->id));
+ if (GTK_IS_MENU_ITEM(widget)) {
+ gtk_widget_set_sensitive(
+ widget, menu->delegate_->IsCommandEnabled(id));
- GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget));
- if (submenu) {
- gtk_container_foreach(GTK_CONTAINER(submenu), &SetMenuItemInfo,
- userdata);
- }
+ GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget));
+ if (submenu) {
+ gtk_container_foreach(GTK_CONTAINER(submenu), &SetMenuItemInfo,
+ userdata);
}
}
}