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

Side by Side Diff: chrome/browser/gtk/browser_toolbar_gtk.cc

Issue 244029: GTK: Implement popup favicon menu. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 | « chrome/browser/gtk/browser_toolbar_gtk.h ('k') | chrome/browser/gtk/standard_menus.h » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/gtk/browser_toolbar_gtk.h" 5 #include "chrome/browser/gtk/browser_toolbar_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 #include <X11/XF86keysym.h> 8 #include <X11/XF86keysym.h>
9 9
10 #include "app/gtk_dnd_util.h" 10 #include "app/gtk_dnd_util.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 // When we created our MenuGtk objects, we pass them a pointer to our accel 97 // When we created our MenuGtk objects, we pass them a pointer to our accel
98 // group. Make sure to tear them down before |accel_group_|. 98 // group. Make sure to tear them down before |accel_group_|.
99 page_menu_.reset(); 99 page_menu_.reset();
100 app_menu_.reset(); 100 app_menu_.reset();
101 page_menu_button_.Destroy(); 101 page_menu_button_.Destroy();
102 app_menu_button_.Destroy(); 102 app_menu_button_.Destroy();
103 g_object_unref(accel_group_); 103 g_object_unref(accel_group_);
104 } 104 }
105 105
106 // Construct an "encodings" menu based on profile settings.
107 static MenuGtk* BuildEncodingsMenu(Profile* profile,
108 MenuGtk::Delegate* delegate) {
109 EncodingMenuController controller;
110 EncodingMenuController::EncodingMenuItemList items;
111 controller.GetEncodingMenuItems(profile, &items);
112
113 MenuGtk* menu = new MenuGtk(delegate, false);
114 GSList* radio_group = NULL;
115 for (EncodingMenuController::EncodingMenuItemList::const_iterator i =
116 items.begin();
117 i != items.end(); ++i) {
118 if (i == items.begin()) {
119 menu->AppendCheckMenuItemWithLabel(i->first, UTF16ToUTF8(i->second));
120 } else if (i->first == 0) {
121 menu->AppendSeparator();
122 } else {
123 GtkWidget* item =
124 gtk_radio_menu_item_new_with_label(radio_group,
125 UTF16ToUTF8(i->second).c_str());
126 radio_group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(item));
127 menu->AppendMenuItem(i->first, item);
128 }
129 }
130 return menu;
131 }
132
133 void BrowserToolbarGtk::Init(Profile* profile, 106 void BrowserToolbarGtk::Init(Profile* profile,
134 GtkWindow* top_level_window) { 107 GtkWindow* top_level_window) {
135 // Make sure to tell the location bar the profile before calling its Init. 108 // Make sure to tell the location bar the profile before calling its Init.
136 SetProfile(profile); 109 SetProfile(profile);
137 110
138 theme_provider_ = GtkThemeProvider::GetFrom(profile); 111 theme_provider_ = GtkThemeProvider::GetFrom(profile);
139 offscreen_entry_.Own(gtk_entry_new()); 112 offscreen_entry_.Own(gtk_entry_new());
140 113
141 show_home_button_.Init(prefs::kShowHomeButton, profile->GetPrefs(), this); 114 show_home_button_.Init(prefs::kShowHomeButton, profile->GetPrefs(), this);
142 115
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 // Group the menu buttons together in an hbox. 188 // Group the menu buttons together in an hbox.
216 GtkWidget* menus_hbox_ = gtk_hbox_new(FALSE, 0); 189 GtkWidget* menus_hbox_ = gtk_hbox_new(FALSE, 0);
217 GtkWidget* page_menu = BuildToolbarMenuButton( 190 GtkWidget* page_menu = BuildToolbarMenuButton(
218 l10n_util::GetStringUTF8(IDS_PAGEMENU_TOOLTIP), 191 l10n_util::GetStringUTF8(IDS_PAGEMENU_TOOLTIP),
219 &page_menu_button_); 192 &page_menu_button_);
220 menu_bar_helper_.Add(page_menu_button_.get()); 193 menu_bar_helper_.Add(page_menu_button_.get());
221 page_menu_image_ = gtk_image_new_from_pixbuf( 194 page_menu_image_ = gtk_image_new_from_pixbuf(
222 theme_provider_->GetRTLEnabledPixbufNamed(IDR_MENU_PAGE)); 195 theme_provider_->GetRTLEnabledPixbufNamed(IDR_MENU_PAGE));
223 gtk_container_add(GTK_CONTAINER(page_menu), page_menu_image_); 196 gtk_container_add(GTK_CONTAINER(page_menu), page_menu_image_);
224 197
225 encodings_menu_.reset(BuildEncodingsMenu(profile, this)); 198 page_menu_.reset(new MenuGtk(this, GetStandardPageMenu(profile_, this),
226 page_menu_.reset(new MenuGtk(this, GetStandardPageMenu(encodings_menu_.get()),
227 accel_group_)); 199 accel_group_));
228 gtk_box_pack_start(GTK_BOX(menus_hbox_), page_menu, FALSE, FALSE, 0); 200 gtk_box_pack_start(GTK_BOX(menus_hbox_), page_menu, FALSE, FALSE, 0);
229 201
230 GtkWidget* chrome_menu = BuildToolbarMenuButton( 202 GtkWidget* chrome_menu = BuildToolbarMenuButton(
231 l10n_util::GetStringFUTF8(IDS_APPMENU_TOOLTIP, 203 l10n_util::GetStringFUTF8(IDS_APPMENU_TOOLTIP,
232 WideToUTF16(l10n_util::GetString(IDS_PRODUCT_NAME))), 204 WideToUTF16(l10n_util::GetString(IDS_PRODUCT_NAME))),
233 &app_menu_button_); 205 &app_menu_button_);
234 menu_bar_helper_.Add(app_menu_button_.get()); 206 menu_bar_helper_.Add(app_menu_button_.get());
235 app_menu_image_ = gtk_image_new_from_pixbuf( 207 app_menu_image_ = gtk_image_new_from_pixbuf(
236 theme_provider_->GetRTLEnabledPixbufNamed(IDR_MENU_CHROME)); 208 theme_provider_->GetRTLEnabledPixbufNamed(IDR_MENU_CHROME));
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 menu->PopupAsFromKeyEvent(button); 667 menu->PopupAsFromKeyEvent(button);
696 menu_bar_helper_.MenuStartedShowing(button, menu->widget()); 668 menu_bar_helper_.MenuStartedShowing(button, menu->widget());
697 } 669 }
698 670
699 void BrowserToolbarGtk::PopupForButtonNextTo(GtkWidget* button, 671 void BrowserToolbarGtk::PopupForButtonNextTo(GtkWidget* button,
700 GtkMenuDirectionType dir) { 672 GtkMenuDirectionType dir) {
701 GtkWidget* other_button = button == page_menu_button_.get() ? 673 GtkWidget* other_button = button == page_menu_button_.get() ?
702 app_menu_button_.get() : page_menu_button_.get(); 674 app_menu_button_.get() : page_menu_button_.get();
703 PopupForButton(other_button); 675 PopupForButton(other_button);
704 } 676 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/browser_toolbar_gtk.h ('k') | chrome/browser/gtk/standard_menus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698