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

Side by Side Diff: chrome/browser/ui/gtk/website_settings/permission_selector.cc

Issue 10966010: [gtk] fix up appearance of website settings dropdown menus (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | « 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/gtk/website_settings/permission_selector.h" 5 #include "chrome/browser/ui/gtk/website_settings/permission_selector.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 10 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // Add a label for the permission type. 66 // Add a label for the permission type.
67 GtkWidget* label = theme_service->BuildLabel(l10n_util::GetStringFUTF8( 67 GtkWidget* label = theme_service->BuildLabel(l10n_util::GetStringFUTF8(
68 IDS_WEBSITE_SETTINGS_PERMISSION_TYPE, 68 IDS_WEBSITE_SETTINGS_PERMISSION_TYPE,
69 WebsiteSettingsUI::PermissionTypeToUIString(type)), 69 WebsiteSettingsUI::PermissionTypeToUIString(type)),
70 ui::kGdkBlack); 70 ui::kGdkBlack);
71 gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD_CHAR); 71 gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD_CHAR);
72 72
73 gtk_box_pack_start(GTK_BOX(widget_), label, FALSE, FALSE, 0); 73 gtk_box_pack_start(GTK_BOX(widget_), label, FALSE, FALSE, 0);
74 74
75 // Add the menu button. 75 // Add the menu button.
76 menu_button_ = gtk_button_new_with_label( 76 menu_button_ = theme_service->BuildChromeButton();
77 GtkWidget* button_hbox = gtk_hbox_new(FALSE, 0);
78 gtk_container_add(GTK_CONTAINER(menu_button_), button_hbox);
79
80 GtkWidget* button_label = theme_service->BuildLabel(
77 UTF16ToUTF8(WebsiteSettingsUI::PermissionActionToUIString( 81 UTF16ToUTF8(WebsiteSettingsUI::PermissionActionToUIString(
78 setting, default_setting, source)).c_str()); 82 setting, default_setting, source)),
83 ui::kGdkBlack);
84 gtk_box_pack_start(GTK_BOX(button_hbox), button_label, FALSE, FALSE,
85 ui::kControlSpacing);
86
79 bool user_setting = source == content_settings::SETTING_SOURCE_USER; 87 bool user_setting = source == content_settings::SETTING_SOURCE_USER;
80 gtk_widget_set_sensitive(GTK_WIDGET(menu_button_), user_setting); 88 gtk_widget_set_sensitive(GTK_WIDGET(menu_button_), user_setting);
81 if (user_setting) { 89 if (user_setting) {
82 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 90 GtkWidget* arrow = NULL;
83 pixbuf = rb.GetNativeImageNamed(IDR_APP_DROPARROW).ToGdkPixbuf(); 91 // We don't handle theme changes, which is a bug but they are very unlikely
84 GtkWidget* arrow = gtk_image_new_from_pixbuf(pixbuf); 92 // to occur while a bubble is grabbing input.
85 gtk_button_set_image(GTK_BUTTON(menu_button_), arrow); 93 if (theme_service->UsingNativeTheme()) {
86 gtk_button_set_image_position(GTK_BUTTON(menu_button_), 94 arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE);
87 base::i18n::IsRTL() ? GTK_POS_LEFT 95 } else {
88 : GTK_POS_RIGHT); 96 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
97 arrow = gtk_image_new_from_pixbuf(
98 rb.GetNativeImageNamed(IDR_APP_DROPARROW).ToGdkPixbuf());
99 }
100 gtk_box_pack_start(GTK_BOX(button_hbox), arrow, FALSE, FALSE, 0);
markusheintz_ 2012/09/20 13:04:49 Does this work for RTL mode?
Evan Stade 2012/09/20 14:15:38 yes
89 } 101 }
90 gtk_button_set_relief(GTK_BUTTON(menu_button_), GTK_RELIEF_NONE); 102 gtk_button_set_relief(GTK_BUTTON(menu_button_), GTK_RELIEF_NONE);
91 gtk_box_pack_start(GTK_BOX(widget_), menu_button_, FALSE, FALSE, 0); 103 gtk_box_pack_start(GTK_BOX(widget_), menu_button_, FALSE, FALSE, 0);
92 104
93 menu_model_.reset(new PermissionMenuModel(this, type, default_setting, 105 menu_model_.reset(new PermissionMenuModel(this, type, default_setting,
94 setting)); 106 setting));
95 MenuGtk::Delegate* delegate = new MenuGtk::Delegate(); 107 MenuGtk::Delegate* delegate = new MenuGtk::Delegate();
96 menu_.reset(new MenuGtk(delegate, menu_model_.get())); 108 menu_.reset(new MenuGtk(delegate, menu_model_.get()));
97 g_signal_connect(menu_button_, "button-press-event", 109 g_signal_connect(menu_button_, "button-press-event",
98 G_CALLBACK(OnMenuButtonPressEventThunk), this); 110 G_CALLBACK(OnMenuButtonPressEventThunk), this);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 content_settings::SETTING_SOURCE_USER)).c_str()); 152 content_settings::SETTING_SOURCE_USER)).c_str());
141 153
142 FOR_EACH_OBSERVER(PermissionSelectorObserver, 154 FOR_EACH_OBSERVER(PermissionSelectorObserver,
143 observer_list_, 155 observer_list_,
144 OnPermissionChanged(this)); 156 OnPermissionChanged(this));
145 } 157 }
146 158
147 bool PermissionSelector::IsCommandIdChecked(int command_id) { 159 bool PermissionSelector::IsCommandIdChecked(int command_id) {
148 return setting_ == CommandIdToContentSetting(command_id); 160 return setting_ == CommandIdToContentSetting(command_id);
149 } 161 }
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