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

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

Issue 548074: GTK: respect menu model's radio button groupings.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 11 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 | « no previous file | 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
===================================================================
--- chrome/browser/gtk/menu_gtk.cc (revision 36560)
+++ chrome/browser/gtk/menu_gtk.cc (working copy)
@@ -250,7 +250,7 @@
}
void MenuGtk::BuildSubmenuFromModel(menus::MenuModel* model, GtkWidget* menu) {
- GtkWidget* last_menu_item = NULL;
+ std::map<int, GtkWidget*> radio_groups;
GtkWidget* menu_item = NULL;
for (int i = 0; i < model->GetItemCount(); ++i) {
SkBitmap icon;
@@ -266,16 +266,20 @@
menu_item = gtk_check_menu_item_new_with_mnemonic(label.c_str());
break;
- case menus::MenuModel::TYPE_RADIO:
- if (last_menu_item && GTK_IS_RADIO_MENU_ITEM(last_menu_item)) {
- menu_item = gtk_radio_menu_item_new_with_mnemonic_from_widget(
- GTK_RADIO_MENU_ITEM(last_menu_item), label.c_str());
- } else {
+ case menus::MenuModel::TYPE_RADIO: {
+ std::map<int, GtkWidget*>::iterator iter =
+ radio_groups.find(model->GetGroupIdAt(i));
+
+ if (iter == radio_groups.end()) {
menu_item = gtk_radio_menu_item_new_with_mnemonic(
NULL, label.c_str());
+ radio_groups[model->GetGroupIdAt(i)] = menu_item;
+ } else {
+ menu_item = gtk_radio_menu_item_new_with_mnemonic_from_widget(
+ GTK_RADIO_MENU_ITEM(iter->second), label.c_str());
}
break;
-
+ }
case menus::MenuModel::TYPE_SUBMENU:
case menus::MenuModel::TYPE_COMMAND:
if (model->GetIconAt(i, &icon))
@@ -308,7 +312,6 @@
reinterpret_cast<void*>(model));
AppendMenuItemToMenu(i, menu_item, menu);
- last_menu_item = menu_item;
menu_item = NULL;
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698