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

Side by Side Diff: views/controls/menu/native_menu_gtk.cc

Issue 4708008: views: Override gtk-menu-images=0 for menu items with icons. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/views
Patch Set: add GTK_CHECK_VERSION around gtk_image_menu_item_set_always_show_image() Created 10 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "views/controls/menu/native_menu_gtk.h" 5 #include "views/controls/menu/native_menu_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 case menus::MenuModel::TYPE_SUBMENU: 346 case menus::MenuModel::TYPE_SUBMENU:
347 case menus::MenuModel::TYPE_COMMAND: { 347 case menus::MenuModel::TYPE_COMMAND: {
348 SkBitmap icon; 348 SkBitmap icon;
349 // Create menu item with icon if icon exists. 349 // Create menu item with icon if icon exists.
350 if (model_->HasIcons() && model_->GetIconAt(index, &icon)) { 350 if (model_->HasIcons() && model_->GetIconAt(index, &icon)) {
351 menu_item = gtk_image_menu_item_new_with_mnemonic(label.c_str()); 351 menu_item = gtk_image_menu_item_new_with_mnemonic(label.c_str());
352 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&icon); 352 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&icon);
353 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), 353 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),
354 gtk_image_new_from_pixbuf(pixbuf)); 354 gtk_image_new_from_pixbuf(pixbuf));
355 g_object_unref(pixbuf); 355 g_object_unref(pixbuf);
356
357 #if GTK_CHECK_VERSION(2,16,0)
358 // Show the image even if the "gtk-menu-images" setting is turned off.
359 gtk_image_menu_item_set_always_show_image(
360 GTK_IMAGE_MENU_ITEM(menu_item), TRUE);
361 #endif
356 } else { 362 } else {
357 menu_item = gtk_menu_item_new_with_mnemonic(label.c_str()); 363 menu_item = gtk_menu_item_new_with_mnemonic(label.c_str());
358 } 364 }
359 break; 365 break;
360 } 366 }
361 default: 367 default:
362 NOTREACHED(); 368 NOTREACHED();
363 break; 369 break;
364 } 370 }
365 371
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 #if !defined(OS_CHROMEOS) 558 #if !defined(OS_CHROMEOS)
553 559
554 // static 560 // static
555 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { 561 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) {
556 return new NativeMenuGtk(menu); 562 return new NativeMenuGtk(menu);
557 } 563 }
558 564
559 #endif // OS_CHROMEOS 565 #endif // OS_CHROMEOS
560 566
561 } // namespace views 567 } // namespace views
OLDNEW
« 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