diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-12 21:40:49 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-12 21:40:49 +0000 |
commit | 880ce5db31a845b56346a8cb7b8da8f068cd08f7 (patch) | |
tree | aa0361632e566d898ffe61603f57f78c7884f2d1 /chrome/browser/gtk/options/general_page_gtk.cc | |
parent | 35ddf48890db45eb94b113e98fd235561a8a68e4 (diff) | |
download | chromium_src-880ce5db31a845b56346a8cb7b8da8f068cd08f7.zip chromium_src-880ce5db31a845b56346a8cb7b8da8f068cd08f7.tar.gz chromium_src-880ce5db31a845b56346a8cb7b8da8f068cd08f7.tar.bz2 |
Re-apply r41458 | estade@chromium.org | 2010-03-12 11:28:50 -0800 (Fri, 12 Mar 2010) | 8 lines
Fix the rest of the gtk/options directory to use new callback macros.
Problematically, the callback macros don't cover the case where the GObject* isn't a GtkWidget* D:
BUG=None
TEST=compile
with fix for unit test
Review URL: http://codereview.chromium.org/846005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41492 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/options/general_page_gtk.cc')
-rw-r--r-- | chrome/browser/gtk/options/general_page_gtk.cc | 164 |
1 files changed, 69 insertions, 95 deletions
diff --git a/chrome/browser/gtk/options/general_page_gtk.cc b/chrome/browser/gtk/options/general_page_gtk.cc index 8aecafe..15db49f 100644 --- a/chrome/browser/gtk/options/general_page_gtk.cc +++ b/chrome/browser/gtk/options/general_page_gtk.cc @@ -186,14 +186,14 @@ GtkWidget* GeneralPageGtk::InitStartupGroup() { l10n_util::GetStringUTF8( IDS_OPTIONS_STARTUP_SHOW_DEFAULT_AND_NEWTAB).c_str()); g_signal_connect(startup_homepage_radio_, "toggled", - G_CALLBACK(OnStartupRadioToggled), this); + G_CALLBACK(OnStartupRadioToggledThunk), this); gtk_box_pack_start(GTK_BOX(vbox), startup_homepage_radio_, FALSE, FALSE, 0); startup_last_session_radio_ = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(startup_homepage_radio_), l10n_util::GetStringUTF8(IDS_OPTIONS_STARTUP_SHOW_LAST_SESSION).c_str()); g_signal_connect(startup_last_session_radio_, "toggled", - G_CALLBACK(OnStartupRadioToggled), this); + G_CALLBACK(OnStartupRadioToggledThunk), this); gtk_box_pack_start(GTK_BOX(vbox), startup_last_session_radio_, FALSE, FALSE, 0); @@ -201,7 +201,7 @@ GtkWidget* GeneralPageGtk::InitStartupGroup() { GTK_RADIO_BUTTON(startup_homepage_radio_), l10n_util::GetStringUTF8(IDS_OPTIONS_STARTUP_SHOW_PAGES).c_str()); g_signal_connect(startup_custom_radio_, "toggled", - G_CALLBACK(OnStartupRadioToggled), this); + G_CALLBACK(OnStartupRadioToggledThunk), this); gtk_box_pack_start(GTK_BOX(vbox), startup_custom_radio_, FALSE, FALSE, 0); GtkWidget* url_list_container = gtk_hbox_new(FALSE, @@ -259,21 +259,21 @@ GtkWidget* GeneralPageGtk::InitStartupGroup() { gtk_util::ConvertAcceleratorsFromWindowsStyle( l10n_util::GetStringUTF8(IDS_OPTIONS_STARTUP_ADD_BUTTON)).c_str()); g_signal_connect(startup_add_custom_page_button_, "clicked", - G_CALLBACK(OnStartupAddCustomPageClicked), this); + G_CALLBACK(OnStartupAddCustomPageClickedThunk), this); gtk_box_pack_start(GTK_BOX(url_list_buttons), startup_add_custom_page_button_, FALSE, FALSE, 0); startup_remove_custom_page_button_ = gtk_button_new_with_mnemonic( gtk_util::ConvertAcceleratorsFromWindowsStyle( l10n_util::GetStringUTF8(IDS_OPTIONS_STARTUP_REMOVE_BUTTON)).c_str()); g_signal_connect(startup_remove_custom_page_button_, "clicked", - G_CALLBACK(OnStartupRemoveCustomPageClicked), this); + G_CALLBACK(OnStartupRemoveCustomPageClickedThunk), this); gtk_box_pack_start(GTK_BOX(url_list_buttons), startup_remove_custom_page_button_, FALSE, FALSE, 0); startup_use_current_page_button_ = gtk_button_new_with_mnemonic( gtk_util::ConvertAcceleratorsFromWindowsStyle( l10n_util::GetStringUTF8(IDS_OPTIONS_STARTUP_USE_CURRENT)).c_str()); g_signal_connect(startup_use_current_page_button_, "clicked", - G_CALLBACK(OnStartupUseCurrentPageClicked), this); + G_CALLBACK(OnStartupUseCurrentPageClickedThunk), this); gtk_box_pack_start(GTK_BOX(url_list_buttons), startup_use_current_page_button_, FALSE, FALSE, 0); @@ -286,7 +286,7 @@ GtkWidget* GeneralPageGtk::InitHomepageGroup() { homepage_use_newtab_radio_ = gtk_radio_button_new_with_label(NULL, l10n_util::GetStringUTF8(IDS_OPTIONS_HOMEPAGE_USE_NEWTAB).c_str()); g_signal_connect(homepage_use_newtab_radio_, "toggled", - G_CALLBACK(OnNewTabIsHomePageToggled), this); + G_CALLBACK(OnNewTabIsHomePageToggledThunk), this); gtk_container_add(GTK_CONTAINER(vbox), homepage_use_newtab_radio_); GtkWidget* homepage_hbox = gtk_hbox_new(FALSE, gtk_util::kLabelSpacing); @@ -296,20 +296,20 @@ GtkWidget* GeneralPageGtk::InitHomepageGroup() { GTK_RADIO_BUTTON(homepage_use_newtab_radio_), l10n_util::GetStringUTF8(IDS_OPTIONS_HOMEPAGE_USE_URL).c_str()); g_signal_connect(homepage_use_url_radio_, "toggled", - G_CALLBACK(OnNewTabIsHomePageToggled), this); + G_CALLBACK(OnNewTabIsHomePageToggledThunk), this); gtk_box_pack_start(GTK_BOX(homepage_hbox), homepage_use_url_radio_, FALSE, FALSE, 0); homepage_use_url_entry_ = gtk_entry_new(); g_signal_connect(homepage_use_url_entry_, "changed", - G_CALLBACK(OnHomepageUseUrlEntryChanged), this); + G_CALLBACK(OnHomepageUseUrlEntryChangedThunk), this); gtk_box_pack_start(GTK_BOX(homepage_hbox), homepage_use_url_entry_, TRUE, TRUE, 0); homepage_show_home_button_checkbox_ = gtk_check_button_new_with_label( l10n_util::GetStringUTF8(IDS_OPTIONS_HOMEPAGE_SHOW_BUTTON).c_str()); g_signal_connect(homepage_show_home_button_checkbox_, "toggled", - G_CALLBACK(OnShowHomeButtonToggled), this); + G_CALLBACK(OnShowHomeButtonToggledThunk), this); gtk_container_add(GTK_CONTAINER(vbox), homepage_show_home_button_checkbox_); return vbox; @@ -325,7 +325,7 @@ GtkWidget* GeneralPageGtk::InitDefaultSearchGroup() { GTK_TREE_MODEL(default_search_engines_model_)); g_object_unref(default_search_engines_model_); g_signal_connect(default_search_engine_combobox_, "changed", - G_CALLBACK(OnDefaultSearchEngineChanged), this); + G_CALLBACK(OnDefaultSearchEngineChangedThunk), this); gtk_container_add(GTK_CONTAINER(hbox), default_search_engine_combobox_); accessible_widget_helper_->SetWidgetName( default_search_engine_combobox_, IDS_OPTIONS_DEFAULTSEARCH_GROUP_NAME); @@ -349,7 +349,7 @@ GtkWidget* GeneralPageGtk::InitDefaultSearchGroup() { l10n_util::GetStringUTF8( IDS_OPTIONS_DEFAULTSEARCH_MANAGE_ENGINES_LINK).c_str()); g_signal_connect(default_search_manage_engines_button_, "clicked", - G_CALLBACK(OnDefaultSearchManageEnginesClicked), this); + G_CALLBACK(OnDefaultSearchManageEnginesClickedThunk), this); gtk_box_pack_end(GTK_BOX(hbox), default_search_manage_engines_button_, FALSE, FALSE, 0); @@ -369,7 +369,7 @@ GtkWidget* GeneralPageGtk::InitDefaultBrowserGroup() { l10n_util::GetStringFUTF8(IDS_OPTIONS_DEFAULTBROWSER_USEASDEFAULT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)).c_str()); g_signal_connect(default_browser_use_as_default_button_, "clicked", - G_CALLBACK(OnBrowserUseAsDefaultClicked), this); + G_CALLBACK(OnBrowserUseAsDefaultClickedThunk), this); gtk_box_pack_start(GTK_BOX(vbox), default_browser_use_as_default_button_, FALSE, FALSE, 0); @@ -382,133 +382,107 @@ GtkWidget* GeneralPageGtk::InitDefaultBrowserGroup() { return vbox_alignment; } -// static -void GeneralPageGtk::OnStartupRadioToggled(GtkToggleButton* toggle_button, - GeneralPageGtk* general_page) { - if (general_page->initializing_) +void GeneralPageGtk::OnStartupRadioToggled(GtkWidget* toggle_button) { + if (initializing_) return; - if (!gtk_toggle_button_get_active(toggle_button)) { + if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle_button))) { // When selecting a radio button, we get two signals (one for the old radio // being toggled off, one for the new one being toggled on.) Ignore the // signal for toggling off the old button. return; } - general_page->SaveStartupPref(); - GtkWidget* sender = GTK_WIDGET(toggle_button); - if (sender == general_page->startup_homepage_radio_) { - general_page->UserMetricsRecordAction("Options_Startup_Homepage", - general_page->profile()->GetPrefs()); - } else if (sender == general_page->startup_last_session_radio_) { - general_page->UserMetricsRecordAction("Options_Startup_LastSession", - general_page->profile()->GetPrefs()); - } else if (sender == general_page->startup_custom_radio_) { - general_page->UserMetricsRecordAction("Options_Startup_Custom", - general_page->profile()->GetPrefs()); + SaveStartupPref(); + if (toggle_button == startup_homepage_radio_) { + UserMetricsRecordAction("Options_Startup_Homepage", + profile()->GetPrefs()); + } else if (toggle_button == startup_last_session_radio_) { + UserMetricsRecordAction("Options_Startup_LastSession", + profile()->GetPrefs()); + } else if (toggle_button == startup_custom_radio_) { + UserMetricsRecordAction("Options_Startup_Custom", + profile()->GetPrefs()); } } -// static -void GeneralPageGtk::OnStartupAddCustomPageClicked( - GtkButton* button, GeneralPageGtk* general_page) { +void GeneralPageGtk::OnStartupAddCustomPageClicked(GtkWidget* button) { new UrlPickerDialogGtk( - NewCallback(general_page, &GeneralPageGtk::OnAddCustomUrl), - general_page->profile(), - GTK_WINDOW(gtk_widget_get_toplevel(general_page->page_))); + NewCallback(this, &GeneralPageGtk::OnAddCustomUrl), + profile(), + GTK_WINDOW(gtk_widget_get_toplevel(page_))); } -// static -void GeneralPageGtk::OnStartupRemoveCustomPageClicked( - GtkButton* button, GeneralPageGtk* general_page) { - general_page->RemoveSelectedCustomUrls(); +void GeneralPageGtk::OnStartupRemoveCustomPageClicked(GtkWidget* button) { + RemoveSelectedCustomUrls(); } -// static -void GeneralPageGtk::OnStartupUseCurrentPageClicked( - GtkButton* button, GeneralPageGtk* general_page) { - general_page->SetCustomUrlListFromCurrentPages(); +void GeneralPageGtk::OnStartupUseCurrentPageClicked(GtkWidget* button) { + SetCustomUrlListFromCurrentPages(); } // static void GeneralPageGtk::OnStartupPagesSelectionChanged( - GtkTreeSelection *selection, GeneralPageGtk* general_page) { + GtkTreeSelection* selection, GeneralPageGtk* general_page) { general_page->EnableCustomHomepagesControls(true); } -// static -void GeneralPageGtk::OnNewTabIsHomePageToggled(GtkToggleButton* toggle_button, - GeneralPageGtk* general_page) { - if (general_page->initializing_) +void GeneralPageGtk::OnNewTabIsHomePageToggled(GtkWidget* toggle_button) { + if (initializing_) return; - if (!gtk_toggle_button_get_active(toggle_button)) { + if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle_button))) { // Ignore the signal for toggling off the old button. return; } - GtkWidget* sender = GTK_WIDGET(toggle_button); - if (sender == general_page->homepage_use_newtab_radio_) { - general_page->SetHomepage(GURL()); - general_page->UserMetricsRecordAction("Options_Homepage_UseNewTab", - general_page->profile()->GetPrefs()); - gtk_widget_set_sensitive(general_page->homepage_use_url_entry_, FALSE); - } else if (sender == general_page->homepage_use_url_radio_) { - general_page->SetHomepageFromEntry(); - general_page->UserMetricsRecordAction("Options_Homepage_UseURL", - general_page->profile()->GetPrefs()); - gtk_widget_set_sensitive(general_page->homepage_use_url_entry_, TRUE); + if (toggle_button == homepage_use_newtab_radio_) { + SetHomepage(GURL()); + UserMetricsRecordAction("Options_Homepage_UseNewTab", + profile()->GetPrefs()); + gtk_widget_set_sensitive(homepage_use_url_entry_, FALSE); + } else if (toggle_button == homepage_use_url_radio_) { + SetHomepageFromEntry(); + UserMetricsRecordAction("Options_Homepage_UseURL", + profile()->GetPrefs()); + gtk_widget_set_sensitive(homepage_use_url_entry_, TRUE); } } -// static -void GeneralPageGtk::OnHomepageUseUrlEntryChanged( - GtkEditable* editable, - GeneralPageGtk* general_page) { - if (general_page->initializing_) +void GeneralPageGtk::OnHomepageUseUrlEntryChanged(GtkWidget* editable) { + if (initializing_) return; - general_page->SetHomepageFromEntry(); + SetHomepageFromEntry(); } -// static -void GeneralPageGtk::OnShowHomeButtonToggled(GtkToggleButton* toggle_button, - GeneralPageGtk* general_page) { - if (general_page->initializing_) +void GeneralPageGtk::OnShowHomeButtonToggled(GtkWidget* toggle_button) { + if (initializing_) return; - bool enabled = gtk_toggle_button_get_active(toggle_button); - general_page->show_home_button_.SetValue(enabled); + bool enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle_button)); + show_home_button_.SetValue(enabled); if (enabled) { - general_page->UserMetricsRecordAction("Options_Homepage_ShowHomeButton", - general_page->profile()->GetPrefs()); + UserMetricsRecordAction("Options_Homepage_ShowHomeButton", + profile()->GetPrefs()); } else { - general_page->UserMetricsRecordAction("Options_Homepage_HideHomeButton", - general_page->profile()->GetPrefs()); + UserMetricsRecordAction("Options_Homepage_HideHomeButton", + profile()->GetPrefs()); } } -// static -void GeneralPageGtk::OnDefaultSearchEngineChanged( - GtkComboBox* combo_box, - GeneralPageGtk* general_page) { - if (general_page->default_search_initializing_) +void GeneralPageGtk::OnDefaultSearchEngineChanged(GtkWidget* combo_box) { + if (default_search_initializing_) return; - general_page->SetDefaultSearchEngineFromComboBox(); + SetDefaultSearchEngineFromComboBox(); } -// static -void GeneralPageGtk::OnDefaultSearchManageEnginesClicked( - GtkButton* button, GeneralPageGtk* general_page) { - KeywordEditorView::Show(general_page->profile()); +void GeneralPageGtk::OnDefaultSearchManageEnginesClicked(GtkWidget* button) { + KeywordEditorView::Show(profile()); } -// static -void GeneralPageGtk::OnBrowserUseAsDefaultClicked( - GtkButton* button, - GeneralPageGtk* general_page) { - general_page->default_browser_worker_->StartSetAsDefaultBrowser(); +void GeneralPageGtk::OnBrowserUseAsDefaultClicked(GtkWidget* button) { + default_browser_worker_->StartSetAsDefaultBrowser(); // If the user made Chrome the default browser, then he/she arguably wants // to be notified when that changes. - general_page->profile()->GetPrefs()->SetBoolean(prefs::kCheckDefaultBrowser, - true); - general_page->UserMetricsRecordAction("Options_SetAsDefaultBrowser", - general_page->profile()->GetPrefs()); + profile()->GetPrefs()->SetBoolean(prefs::kCheckDefaultBrowser, true); + UserMetricsRecordAction("Options_SetAsDefaultBrowser", + profile()->GetPrefs()); } void GeneralPageGtk::SaveStartupPref() { |