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

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

Issue 7791004: linux: delete code that worked around gtk <2.18 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/controls/combobox/native_combobox_gtk.cc ('k') | webkit/glue/webcursor_gtk.cc » ('j') | 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) 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 "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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 case ui::MenuModel::TYPE_COMMAND: { 386 case ui::MenuModel::TYPE_COMMAND: {
387 SkBitmap icon; 387 SkBitmap icon;
388 // Create menu item with icon if icon exists. 388 // Create menu item with icon if icon exists.
389 if (model_->HasIcons() && model_->GetIconAt(index, &icon)) { 389 if (model_->HasIcons() && model_->GetIconAt(index, &icon)) {
390 menu_item = gtk_image_menu_item_new_with_mnemonic(label.c_str()); 390 menu_item = gtk_image_menu_item_new_with_mnemonic(label.c_str());
391 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&icon); 391 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&icon);
392 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), 392 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),
393 gtk_image_new_from_pixbuf(pixbuf)); 393 gtk_image_new_from_pixbuf(pixbuf));
394 g_object_unref(pixbuf); 394 g_object_unref(pixbuf);
395 395
396 #if GTK_CHECK_VERSION(2,16,0)
397 // Show the image even if the "gtk-menu-images" setting is turned off. 396 // Show the image even if the "gtk-menu-images" setting is turned off.
398 gtk_image_menu_item_set_always_show_image( 397 gtk_image_menu_item_set_always_show_image(
399 GTK_IMAGE_MENU_ITEM(menu_item), TRUE); 398 GTK_IMAGE_MENU_ITEM(menu_item), TRUE);
400 #endif
401 } else { 399 } else {
402 menu_item = gtk_menu_item_new_with_mnemonic(label.c_str()); 400 menu_item = gtk_menu_item_new_with_mnemonic(label.c_str());
403 } 401 }
404 break; 402 break;
405 } 403 }
406 default: 404 default:
407 NOTREACHED(); 405 NOTREACHED();
408 break; 406 break;
409 } 407 }
410 408
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menu_item)); 597 submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menu_item));
600 } 598 }
601 599
602 // Figure out the item index and total number of items. 600 // Figure out the item index and total number of items.
603 GList* items = gtk_container_get_children(GTK_CONTAINER(menu)); 601 GList* items = gtk_container_get_children(GTK_CONTAINER(menu));
604 guint count = g_list_length(items); 602 guint count = g_list_length(items);
605 int index = g_list_index(items, static_cast<gconstpointer>(menu_item)); 603 int index = g_list_index(items, static_cast<gconstpointer>(menu_item));
606 604
607 // Get the menu item's label. 605 // Get the menu item's label.
608 std::string name; 606 std::string name;
609 #if GTK_CHECK_VERSION(2, 16, 0)
610 name = gtk_menu_item_get_label(GTK_MENU_ITEM(menu_item)); 607 name = gtk_menu_item_get_label(GTK_MENU_ITEM(menu_item));
611 #else
612 GList* children = gtk_container_get_children(GTK_CONTAINER(menu_item));
613 for (GList* l = g_list_first(children); l != NULL; l = g_list_next(l)) {
614 GtkWidget* child = static_cast<GtkWidget*>(l->data);
615 if (GTK_IS_LABEL(child)) {
616 name = gtk_label_get_label(GTK_LABEL(child));
617 break;
618 }
619 }
620 #endif
621 608
622 if (ViewsDelegate::views_delegate) { 609 if (ViewsDelegate::views_delegate) {
623 ViewsDelegate::views_delegate->NotifyMenuItemFocused( 610 ViewsDelegate::views_delegate->NotifyMenuItemFocused(
624 L"", 611 L"",
625 UTF8ToWide(name), 612 UTF8ToWide(name),
626 index, 613 index,
627 count, 614 count,
628 submenu != NULL); 615 submenu != NULL);
629 } 616 }
630 } 617 }
631 618
632 // static 619 // static
633 void NativeMenuGtk::MenuDestroyed(GtkWidget* widget, Menu2* menu2) { 620 void NativeMenuGtk::MenuDestroyed(GtkWidget* widget, Menu2* menu2) {
634 NativeMenuGtk* native_menu = 621 NativeMenuGtk* native_menu =
635 static_cast<NativeMenuGtk*>(menu2->wrapper_.get()); 622 static_cast<NativeMenuGtk*>(menu2->wrapper_.get());
636 // The native gtk widget has already been destroyed. 623 // The native gtk widget has already been destroyed.
637 native_menu->menu_ = NULL; 624 native_menu->menu_ = NULL;
638 delete menu2; 625 delete menu2;
639 } 626 }
640 627
641 //////////////////////////////////////////////////////////////////////////////// 628 ////////////////////////////////////////////////////////////////////////////////
642 // MenuWrapper, public: 629 // MenuWrapper, public:
643 630
644 // static 631 // static
645 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { 632 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) {
646 return new NativeMenuGtk(menu); 633 return new NativeMenuGtk(menu);
647 } 634 }
648 635
649 } // namespace views 636 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/combobox/native_combobox_gtk.cc ('k') | webkit/glue/webcursor_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698