From aeba30900935cfbb729e3124e8e2151a581028d9 Mon Sep 17 00:00:00 2001 From: "tony@chromium.org" Date: Fri, 2 Oct 2009 21:03:15 +0000 Subject: Switch to using radio buttons for toggling the custom frame. Use title case for the context menu on the title bar. BUG=23412 Review URL: http://codereview.chromium.org/255059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27896 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/app/generated_resources.grd | 19 ++++++-- chrome/browser/gtk/browser_titlebar.cc | 2 +- chrome/browser/gtk/options/content_page_gtk.cc | 65 +++++++++++++++++++------- chrome/browser/gtk/options/content_page_gtk.h | 11 +++-- 4 files changed, 71 insertions(+), 26 deletions(-) (limited to 'chrome') diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 0218501..ea1de94 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -4093,6 +4093,12 @@ Keep your key file in a safe place. You will need it to create new versions of y Use Classic theme + + Use system title bar and borders + + + Hide system title bar and use compact borders + Reset to default theme @@ -5134,9 +5140,16 @@ Keep your key file in a safe place. You will need it to create new versions of y Don't ask again - - Use system title bar and borders - + + + Use system title bar and borders + + + + + Use System Title Bar and Borders + + rgba($1, $2, $3, $4) diff --git a/chrome/browser/gtk/browser_titlebar.cc b/chrome/browser/gtk/browser_titlebar.cc index a78954d..791b1f3 100644 --- a/chrome/browser/gtk/browser_titlebar.cc +++ b/chrome/browser/gtk/browser_titlebar.cc @@ -573,7 +573,7 @@ void BrowserTitlebar::ShowContextMenu() { #if !defined(OS_CHROMEOS) { MENU_SEPARATOR }, { MENU_CHECKBOX, kShowWindowDecorationsCommand, - IDS_SHOW_WINDOW_DECORATIONS }, + IDS_SHOW_WINDOW_DECORATIONS_MENU }, #endif { MENU_END }, }; diff --git a/chrome/browser/gtk/options/content_page_gtk.cc b/chrome/browser/gtk/options/content_page_gtk.cc index 6c9b4d2..afc1ca8 100644 --- a/chrome/browser/gtk/options/content_page_gtk.cc +++ b/chrome/browser/gtk/options/content_page_gtk.cc @@ -28,7 +28,6 @@ ContentPageGtk::ContentPageGtk(Profile* profile) : OptionsPageBase(profile), - system_title_bar_checkbox_(NULL), initializing_(true) { // Prepare the group options layout. @@ -89,9 +88,13 @@ void ContentPageGtk::NotifyPrefChanged(const std::wstring* pref_name) { } if (browser_defaults::kCanToggleSystemTitleBar && (!pref_name || *pref_name == prefs::kUseCustomChromeFrame)) { - gtk_toggle_button_set_active( - GTK_TOGGLE_BUTTON(system_title_bar_checkbox_), - !use_custom_chrome_frame_.GetValue()); + if (use_custom_chrome_frame_.GetValue()) { + gtk_toggle_button_set_active( + GTK_TOGGLE_BUTTON(system_title_bar_hide_radio_), TRUE); + } else { + gtk_toggle_button_set_active( + GTK_TOGGLE_BUTTON(system_title_bar_show_radio_), TRUE); + } } initializing_ = false; } @@ -191,16 +194,6 @@ GtkWidget* ContentPageGtk::InitThemesGroup() { GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); GtkWidget* hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing); - // "Use system title bar and borders" checkbox. - if (browser_defaults::kCanToggleSystemTitleBar) { - system_title_bar_checkbox_ = gtk_check_button_new_with_label( - l10n_util::GetStringUTF8(IDS_SHOW_WINDOW_DECORATIONS).c_str()); - g_signal_connect(G_OBJECT(system_title_bar_checkbox_), "clicked", - G_CALLBACK(OnSystemTitleBarCheckboxClicked), this); - gtk_box_pack_start(GTK_BOX(vbox), system_title_bar_checkbox_, - FALSE, FALSE, 0); - } - #if defined(TOOLKIT_GTK) // GTK theme button. GtkWidget* gtk_theme_button = gtk_button_new_with_label( @@ -226,6 +219,26 @@ GtkWidget* ContentPageGtk::InitThemesGroup() { gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + // "Use system title bar and borders" radio buttons. + if (browser_defaults::kCanToggleSystemTitleBar) { + // Use system title bar and borders + system_title_bar_show_radio_ = gtk_radio_button_new_with_label(NULL, + l10n_util::GetStringUTF8(IDS_SHOW_WINDOW_DECORATIONS_RADIO).c_str()); + g_signal_connect(G_OBJECT(system_title_bar_show_radio_), "toggled", + G_CALLBACK(OnSystemTitleBarRadioToggled), this); + gtk_box_pack_start(GTK_BOX(vbox), system_title_bar_show_radio_, FALSE, + FALSE, 0); + + // Hide system title bar and use custom borders + system_title_bar_hide_radio_ = gtk_radio_button_new_with_label_from_widget( + GTK_RADIO_BUTTON(system_title_bar_show_radio_), + l10n_util::GetStringUTF8(IDS_HIDE_WINDOW_DECORATIONS_RADIO).c_str()); + g_signal_connect(G_OBJECT(system_title_bar_hide_radio_), "toggled", + G_CALLBACK(OnSystemTitleBarRadioToggled), this); + gtk_box_pack_start(GTK_BOX(vbox), system_title_bar_hide_radio_, FALSE, + FALSE, 0); + } + return vbox; } @@ -272,10 +285,28 @@ void ContentPageGtk::OnGetThemesButtonClicked(GtkButton* widget, } // static -void ContentPageGtk::OnSystemTitleBarCheckboxClicked(GtkButton* widget, - ContentPageGtk* page) { +void ContentPageGtk::OnSystemTitleBarRadioToggled(GtkToggleButton* widget, + ContentPageGtk* page) { DCHECK(browser_defaults::kCanToggleSystemTitleBar); - bool use_custom = !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + if (page->initializing_) + return; + + // We get two signals when selecting a radio button, one for the old radio + // being toggled off and one for the new one being toggled on. Ignore the + // signal for the toggling off the old button. + if (!gtk_toggle_button_get_active(widget)) + return; + + bool use_custom = gtk_toggle_button_get_active( + GTK_TOGGLE_BUTTON(page->system_title_bar_hide_radio_)); + if (use_custom) { + page->UserMetricsRecordAction(L"Options_CustomFrame_Enable", + page->profile()->GetPrefs()); + } else { + page->UserMetricsRecordAction(L"Options_CustomFrame_Disable", + page->profile()->GetPrefs()); + } + page->use_custom_chrome_frame_.SetValue(use_custom); } diff --git a/chrome/browser/gtk/options/content_page_gtk.h b/chrome/browser/gtk/options/content_page_gtk.h index 4bc27a8..4c7f8d5 100644 --- a/chrome/browser/gtk/options/content_page_gtk.h +++ b/chrome/browser/gtk/options/content_page_gtk.h @@ -49,9 +49,9 @@ class ContentPageGtk : public OptionsPageBase { static void OnGetThemesButtonClicked(GtkButton* widget, ContentPageGtk* page); - // Callback for system title bar checkbox. - static void OnSystemTitleBarCheckboxClicked(GtkButton* widget, - ContentPageGtk* page); + // Callback for system title bar radio buttons. + static void OnSystemTitleBarRadioToggled(GtkToggleButton* widget, + ContentPageGtk* page); // Callback for passwords exceptions button. static void OnPasswordsExceptionsButtonClicked(GtkButton* widget, @@ -73,8 +73,9 @@ class ContentPageGtk : public OptionsPageBase { GtkWidget* form_autofill_asktosave_radio_; GtkWidget* form_autofill_neversave_radio_; - // Widgets for the Themes group. - GtkWidget* system_title_bar_checkbox_; + // Widgets for the Appearance group. + GtkWidget* system_title_bar_show_radio_; + GtkWidget* system_title_bar_hide_radio_; // The parent GtkTable widget GtkWidget* page_; -- cgit v1.1