OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/tab_contents/render_view_context_menu_gtk.h" | 5 #include "chrome/browser/tab_contents/render_view_context_menu_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 menu_gtk_->PopupAsContext(point, triggering_event_time_); | 121 menu_gtk_->PopupAsContext(point, triggering_event_time_); |
122 } | 122 } |
123 | 123 |
124 bool RenderViewContextMenuGtk::AlwaysShowIconForCmd(int command_id) const { | 124 bool RenderViewContextMenuGtk::AlwaysShowIconForCmd(int command_id) const { |
125 return command_id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && | 125 return command_id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && |
126 command_id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST; | 126 command_id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST; |
127 } | 127 } |
128 | 128 |
129 void RenderViewContextMenuGtk::UpdateMenuItem(int command_id, | 129 void RenderViewContextMenuGtk::UpdateMenuItem(int command_id, |
130 bool enabled, | 130 bool enabled, |
| 131 bool hidden, |
131 const string16& title) { | 132 const string16& title) { |
132 GtkWidget* item = GetMenuItemByID(&menu_model_, menu_gtk_->widget(), | 133 GtkWidget* item = GetMenuItemByID(&menu_model_, menu_gtk_->widget(), |
133 command_id); | 134 command_id); |
134 if (!item || !GTK_IS_MENU_ITEM(item)) | 135 if (!item || !GTK_IS_MENU_ITEM(item)) |
135 return; | 136 return; |
136 | 137 |
137 // Enable (or disable) the menu item and updates its text. | 138 // Enable (or disable) the menu item and updates its text. |
138 gtk_widget_set_sensitive(item, enabled); | 139 gtk_widget_set_sensitive(item, enabled); |
| 140 if (hidden) |
| 141 gtk_widget_hide(item); |
| 142 else |
| 143 gtk_widget_show(item); |
139 gtk_menu_item_set_label(GTK_MENU_ITEM(item), UTF16ToUTF8(title).c_str()); | 144 gtk_menu_item_set_label(GTK_MENU_ITEM(item), UTF16ToUTF8(title).c_str()); |
140 } | 145 } |
OLD | NEW |