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

Side by Side Diff: chrome/browser/gtk/options/content_page_gtk.cc

Issue 289007: GTK: disable theme buttons in options dialog when we are already using that t... (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/options/content_page_gtk.h ('k') | 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) 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/options/content_page_gtk.h" 5 #include "chrome/browser/gtk/options/content_page_gtk.h"
6 6
7 #include "app/gfx/gtk_util.h" 7 #include "app/gfx/gtk_util.h"
8 #include "app/l10n_util.h" 8 #include "app/l10n_util.h"
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "chrome/browser/browser_list.h" 10 #include "chrome/browser/browser_list.h"
11 #include "chrome/browser/defaults.h" 11 #include "chrome/browser/defaults.h"
12 #include "chrome/browser/gtk/clear_browsing_data_dialog_gtk.h" 12 #include "chrome/browser/gtk/clear_browsing_data_dialog_gtk.h"
13 #include "chrome/browser/gtk/gtk_chrome_link_button.h" 13 #include "chrome/browser/gtk/gtk_chrome_link_button.h"
14 #include "chrome/browser/gtk/gtk_theme_provider.h"
14 #include "chrome/browser/gtk/import_dialog_gtk.h" 15 #include "chrome/browser/gtk/import_dialog_gtk.h"
15 #include "chrome/browser/gtk/options/options_layout_gtk.h" 16 #include "chrome/browser/gtk/options/options_layout_gtk.h"
16 #include "chrome/browser/gtk/options/passwords_exceptions_window_gtk.h" 17 #include "chrome/browser/gtk/options/passwords_exceptions_window_gtk.h"
17 #include "chrome/common/gtk_util.h" 18 #include "chrome/common/gtk_util.h"
19 #include "chrome/common/notification_service.h"
18 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
19 #include "chrome/common/pref_service.h" 21 #include "chrome/common/pref_service.h"
20 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
21 #include "grit/app_resources.h" 23 #include "grit/app_resources.h"
22 #include "grit/chromium_strings.h" 24 #include "grit/chromium_strings.h"
23 #include "grit/generated_resources.h" 25 #include "grit/generated_resources.h"
24 #include "grit/locale_settings.h" 26 #include "grit/locale_settings.h"
25 27
26 /////////////////////////////////////////////////////////////////////////////// 28 ///////////////////////////////////////////////////////////////////////////////
27 // ContentPageGtk, public: 29 // ContentPageGtk, public:
(...skipping 21 matching lines...) Expand all
49 // Add preferences observers. 51 // Add preferences observers.
50 ask_to_save_passwords_.Init(prefs::kPasswordManagerEnabled, 52 ask_to_save_passwords_.Init(prefs::kPasswordManagerEnabled,
51 profile->GetPrefs(), this); 53 profile->GetPrefs(), this);
52 ask_to_save_form_autofill_.Init(prefs::kFormAutofillEnabled, 54 ask_to_save_form_autofill_.Init(prefs::kFormAutofillEnabled,
53 profile->GetPrefs(), this); 55 profile->GetPrefs(), this);
54 if (browser_defaults::kCanToggleSystemTitleBar) { 56 if (browser_defaults::kCanToggleSystemTitleBar) {
55 use_custom_chrome_frame_.Init(prefs::kUseCustomChromeFrame, 57 use_custom_chrome_frame_.Init(prefs::kUseCustomChromeFrame,
56 profile->GetPrefs(), this); 58 profile->GetPrefs(), this);
57 } 59 }
58 60
59 // Load initial values 61 // Load initial values.
60 NotifyPrefChanged(NULL); 62 NotifyPrefChanged(NULL);
63
64 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
65 NotificationService::AllSources());
66 ObserveThemeChanged();
61 } 67 }
62 68
63 ContentPageGtk::~ContentPageGtk() { 69 ContentPageGtk::~ContentPageGtk() {
64 } 70 }
65 71
72 ///////////////////////////////////////////////////////////////////////////////
73 // ContentPageGtk, private:
74
66 // If |pref_name| is NULL, set the state of all the widgets. (This is used 75 // If |pref_name| is NULL, set the state of all the widgets. (This is used
67 // in ContentPageGtk() above to initialize the dialog.) Otherwise, reset the 76 // in ContentPageGtk() above to initialize the dialog.) Otherwise, reset the
68 // state of the widget for the given preference name, as it has changed. 77 // state of the widget for the given preference name, as it has changed.
69 void ContentPageGtk::NotifyPrefChanged(const std::wstring* pref_name) { 78 void ContentPageGtk::NotifyPrefChanged(const std::wstring* pref_name) {
70 initializing_ = true; 79 initializing_ = true;
71 if (!pref_name || *pref_name == prefs::kPasswordManagerEnabled) { 80 if (!pref_name || *pref_name == prefs::kPasswordManagerEnabled) {
72 if (ask_to_save_passwords_.GetValue()) { 81 if (ask_to_save_passwords_.GetValue()) {
73 gtk_toggle_button_set_active( 82 gtk_toggle_button_set_active(
74 GTK_TOGGLE_BUTTON(passwords_asktosave_radio_), TRUE); 83 GTK_TOGGLE_BUTTON(passwords_asktosave_radio_), TRUE);
75 } else { 84 } else {
(...skipping 16 matching lines...) Expand all
92 gtk_toggle_button_set_active( 101 gtk_toggle_button_set_active(
93 GTK_TOGGLE_BUTTON(system_title_bar_hide_radio_), TRUE); 102 GTK_TOGGLE_BUTTON(system_title_bar_hide_radio_), TRUE);
94 } else { 103 } else {
95 gtk_toggle_button_set_active( 104 gtk_toggle_button_set_active(
96 GTK_TOGGLE_BUTTON(system_title_bar_show_radio_), TRUE); 105 GTK_TOGGLE_BUTTON(system_title_bar_show_radio_), TRUE);
97 } 106 }
98 } 107 }
99 initializing_ = false; 108 initializing_ = false;
100 } 109 }
101 110
102 /////////////////////////////////////////////////////////////////////////////// 111 void ContentPageGtk::Observe(NotificationType type,
103 // ContentPageGtk, private: 112 const NotificationSource& source,
113 const NotificationDetails& details) {
114 if (type == NotificationType::BROWSER_THEME_CHANGED)
115 ObserveThemeChanged();
116 else
117 OptionsPageBase::Observe(type, source, details);
118 }
119
120 void ContentPageGtk::ObserveThemeChanged() {
121 #if defined(TOOLKIT_GTK)
122 GtkThemeProvider* provider = GtkThemeProvider::GetFrom(profile());
123 bool is_gtk_theme = provider->UseGtkTheme();
124 gtk_widget_set_sensitive(gtk_theme_button_, !is_gtk_theme);
125 #else
126 BrowserThemeProvider* provider =
127 reinterpret_cast<BrowserThemeProvider*>profile()->GetThemeProvider();
128 bool is_gtk_theme = false;
129 #endif
130
131 bool is_classic_theme = !is_gtk_theme && provider->GetThemeID().empty();
132 gtk_widget_set_sensitive(themes_reset_button_, !is_classic_theme);
133 }
104 134
105 GtkWidget* ContentPageGtk::InitPasswordSavingGroup() { 135 GtkWidget* ContentPageGtk::InitPasswordSavingGroup() {
106 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); 136 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
107 137
108 // Ask to save radio button. 138 // Ask to save radio button.
109 passwords_asktosave_radio_ = gtk_radio_button_new_with_label(NULL, 139 passwords_asktosave_radio_ = gtk_radio_button_new_with_label(NULL,
110 l10n_util::GetStringUTF8(IDS_OPTIONS_PASSWORDS_ASKTOSAVE).c_str()); 140 l10n_util::GetStringUTF8(IDS_OPTIONS_PASSWORDS_ASKTOSAVE).c_str());
111 g_signal_connect(G_OBJECT(passwords_asktosave_radio_), "toggled", 141 g_signal_connect(G_OBJECT(passwords_asktosave_radio_), "toggled",
112 G_CALLBACK(OnPasswordRadioToggled), this); 142 G_CALLBACK(OnPasswordRadioToggled), this);
113 gtk_box_pack_start(GTK_BOX(vbox), passwords_asktosave_radio_, FALSE, 143 gtk_box_pack_start(GTK_BOX(vbox), passwords_asktosave_radio_, FALSE,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 219
190 return vbox; 220 return vbox;
191 } 221 }
192 222
193 GtkWidget* ContentPageGtk::InitThemesGroup() { 223 GtkWidget* ContentPageGtk::InitThemesGroup() {
194 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); 224 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
195 GtkWidget* hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing); 225 GtkWidget* hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing);
196 226
197 #if defined(TOOLKIT_GTK) 227 #if defined(TOOLKIT_GTK)
198 // GTK theme button. 228 // GTK theme button.
199 GtkWidget* gtk_theme_button = gtk_button_new_with_label( 229 gtk_theme_button_ = gtk_button_new_with_label(
200 l10n_util::GetStringUTF8(IDS_THEMES_GTK_BUTTON).c_str()); 230 l10n_util::GetStringUTF8(IDS_THEMES_GTK_BUTTON).c_str());
201 g_signal_connect(G_OBJECT(gtk_theme_button), "clicked", 231 g_signal_connect(G_OBJECT(gtk_theme_button_), "clicked",
202 G_CALLBACK(OnGtkThemeButtonClicked), this); 232 G_CALLBACK(OnGtkThemeButtonClicked), this);
203 gtk_box_pack_start(GTK_BOX(hbox), gtk_theme_button, FALSE, FALSE, 0); 233 gtk_box_pack_start(GTK_BOX(hbox), gtk_theme_button_, FALSE, FALSE, 0);
204 #endif 234 #endif
205 235
206 // Reset theme button. 236 // Reset theme button.
207 GtkWidget* themes_reset_button = gtk_button_new_with_label( 237 themes_reset_button_ = gtk_button_new_with_label(
208 l10n_util::GetStringUTF8(IDS_THEMES_SET_CLASSIC).c_str()); 238 l10n_util::GetStringUTF8(IDS_THEMES_SET_CLASSIC).c_str());
209 g_signal_connect(G_OBJECT(themes_reset_button), "clicked", 239 g_signal_connect(G_OBJECT(themes_reset_button_), "clicked",
210 G_CALLBACK(OnResetDefaultThemeButtonClicked), this); 240 G_CALLBACK(OnResetDefaultThemeButtonClicked), this);
211 gtk_box_pack_start(GTK_BOX(hbox), themes_reset_button, FALSE, FALSE, 0); 241 gtk_box_pack_start(GTK_BOX(hbox), themes_reset_button_, FALSE, FALSE, 0);
212 242
213 // Get themes button. 243 // Get themes button.
214 GtkWidget* themes_gallery_button = gtk_chrome_link_button_new( 244 GtkWidget* themes_gallery_button = gtk_chrome_link_button_new(
215 l10n_util::GetStringUTF8(IDS_THEMES_GALLERY_BUTTON).c_str()); 245 l10n_util::GetStringUTF8(IDS_THEMES_GALLERY_BUTTON).c_str());
216 g_signal_connect(G_OBJECT(themes_gallery_button), "clicked", 246 g_signal_connect(G_OBJECT(themes_gallery_button), "clicked",
217 G_CALLBACK(OnGetThemesButtonClicked), this); 247 G_CALLBACK(OnGetThemesButtonClicked), this);
218 gtk_box_pack_start(GTK_BOX(hbox), themes_gallery_button, FALSE, FALSE, 0); 248 gtk_box_pack_start(GTK_BOX(hbox), themes_gallery_button, FALSE, FALSE, 0);
219 249
220 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 250 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
221 251
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 GTK_TOGGLE_BUTTON(page->form_autofill_asktosave_radio_)); 386 GTK_TOGGLE_BUTTON(page->form_autofill_asktosave_radio_));
357 if (enabled) { 387 if (enabled) {
358 page->UserMetricsRecordAction(L"Options_FormAutofill_Enable", 388 page->UserMetricsRecordAction(L"Options_FormAutofill_Enable",
359 page->profile()->GetPrefs()); 389 page->profile()->GetPrefs());
360 } else { 390 } else {
361 page->UserMetricsRecordAction(L"Options_FormAutofill_Disable", 391 page->UserMetricsRecordAction(L"Options_FormAutofill_Disable",
362 page->profile()->GetPrefs()); 392 page->profile()->GetPrefs());
363 } 393 }
364 page->ask_to_save_form_autofill_.SetValue(enabled); 394 page->ask_to_save_form_autofill_.SetValue(enabled);
365 } 395 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/options/content_page_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698