| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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/general_page_gtk.h" | 5 #include "chrome/browser/gtk/options/general_page_gtk.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/gfx/gtk_util.h" | 9 #include "base/gfx/gtk_util.h" |
| 10 #include "base/gfx/png_decoder.h" | 10 #include "base/gfx/png_decoder.h" |
| 11 #include "chrome/browser/browser.h" | 11 #include "chrome/browser/browser.h" |
| 12 #include "chrome/browser/browser_list.h" | 12 #include "chrome/browser/browser_list.h" |
| 13 #include "chrome/browser/gtk/keyword_editor_view.h" |
| 13 #include "chrome/browser/gtk/options/options_layout_gtk.h" | 14 #include "chrome/browser/gtk/options/options_layout_gtk.h" |
| 14 #include "chrome/browser/gtk/options/url_picker_dialog_gtk.h" | 15 #include "chrome/browser/gtk/options/url_picker_dialog_gtk.h" |
| 15 #include "chrome/browser/net/url_fixer_upper.h" | 16 #include "chrome/browser/net/url_fixer_upper.h" |
| 16 #include "chrome/browser/search_engines/template_url.h" | 17 #include "chrome/browser/search_engines/template_url.h" |
| 17 #include "chrome/browser/session_startup_pref.h" | 18 #include "chrome/browser/session_startup_pref.h" |
| 18 #include "chrome/browser/shell_integration.h" | 19 #include "chrome/browser/shell_integration.h" |
| 19 #include "chrome/browser/tab_contents/tab_contents.h" | 20 #include "chrome/browser/tab_contents/tab_contents.h" |
| 20 #include "chrome/common/gtk_util.h" | 21 #include "chrome/common/gtk_util.h" |
| 21 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/common/pref_service.h" | 23 #include "chrome/common/pref_service.h" |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 "text", SEARCH_ENGINES_COL_TITLE, | 319 "text", SEARCH_ENGINES_COL_TITLE, |
| 319 NULL); | 320 NULL); |
| 320 | 321 |
| 321 template_url_model_ = profile()->GetTemplateURLModel(); | 322 template_url_model_ = profile()->GetTemplateURLModel(); |
| 322 if (template_url_model_) { | 323 if (template_url_model_) { |
| 323 template_url_model_->Load(); | 324 template_url_model_->Load(); |
| 324 template_url_model_->AddObserver(this); | 325 template_url_model_->AddObserver(this); |
| 325 } | 326 } |
| 326 OnTemplateURLModelChanged(); | 327 OnTemplateURLModelChanged(); |
| 327 | 328 |
| 328 // TODO(mattm): hook this up | |
| 329 default_search_manage_engines_button_ = gtk_button_new_with_label( | 329 default_search_manage_engines_button_ = gtk_button_new_with_label( |
| 330 l10n_util::GetStringUTF8( | 330 l10n_util::GetStringUTF8( |
| 331 IDS_OPTIONS_DEFAULTSEARCH_MANAGE_ENGINES_LINK).c_str()); | 331 IDS_OPTIONS_DEFAULTSEARCH_MANAGE_ENGINES_LINK).c_str()); |
| 332 g_signal_connect(G_OBJECT(default_search_manage_engines_button_), "clicked", |
| 333 G_CALLBACK(OnDefaultSearchManageEnginesClicked), this); |
| 332 gtk_box_pack_end(GTK_BOX(hbox), default_search_manage_engines_button_, | 334 gtk_box_pack_end(GTK_BOX(hbox), default_search_manage_engines_button_, |
| 333 FALSE, FALSE, 0); | 335 FALSE, FALSE, 0); |
| 334 | 336 |
| 335 return hbox; | 337 return hbox; |
| 336 } | 338 } |
| 337 | 339 |
| 338 GtkWidget* GeneralPageGtk::InitDefaultBrowserGroup() { | 340 GtkWidget* GeneralPageGtk::InitDefaultBrowserGroup() { |
| 339 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); | 341 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); |
| 340 | 342 |
| 341 default_browser_status_label_ = gtk_label_new(NULL); | 343 default_browser_status_label_ = gtk_label_new(NULL); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 // static | 463 // static |
| 462 void GeneralPageGtk::OnDefaultSearchEngineChanged( | 464 void GeneralPageGtk::OnDefaultSearchEngineChanged( |
| 463 GtkComboBox* combo_box, | 465 GtkComboBox* combo_box, |
| 464 GeneralPageGtk* general_page) { | 466 GeneralPageGtk* general_page) { |
| 465 if (general_page->default_search_initializing_) | 467 if (general_page->default_search_initializing_) |
| 466 return; | 468 return; |
| 467 general_page->SetDefaultSearchEngineFromComboBox(); | 469 general_page->SetDefaultSearchEngineFromComboBox(); |
| 468 } | 470 } |
| 469 | 471 |
| 470 // static | 472 // static |
| 473 void GeneralPageGtk::OnDefaultSearchManageEnginesClicked( |
| 474 GtkButton* button, GeneralPageGtk* general_page) { |
| 475 KeywordEditorView::Show(general_page->profile()); |
| 476 } |
| 477 |
| 478 // static |
| 471 void GeneralPageGtk::OnBrowserUseAsDefaultClicked( | 479 void GeneralPageGtk::OnBrowserUseAsDefaultClicked( |
| 472 GtkButton* button, | 480 GtkButton* button, |
| 473 GeneralPageGtk* general_page) { | 481 GeneralPageGtk* general_page) { |
| 474 general_page->SetDefaultBrowserUIState( | 482 general_page->SetDefaultBrowserUIState( |
| 475 ShellIntegration::SetAsDefaultBrowser()); | 483 ShellIntegration::SetAsDefaultBrowser()); |
| 476 // If the user made Chrome the default browser, then he/she arguably wants | 484 // If the user made Chrome the default browser, then he/she arguably wants |
| 477 // to be notified when that changes. | 485 // to be notified when that changes. |
| 478 general_page->profile()->GetPrefs()->SetBoolean(prefs::kCheckDefaultBrowser, | 486 general_page->profile()->GetPrefs()->SetBoolean(prefs::kCheckDefaultBrowser, |
| 479 true); | 487 true); |
| 480 general_page->UserMetricsRecordAction(L"Options_SetAsDefaultBrowser", | 488 general_page->UserMetricsRecordAction(L"Options_SetAsDefaultBrowser", |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 text = l10n_util::GetStringFUTF8(IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT, | 753 text = l10n_util::GetStringFUTF8(IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT, |
| 746 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 754 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 747 } | 755 } |
| 748 char* markup = g_markup_printf_escaped(kDefaultBrowserLabelMarkup, | 756 char* markup = g_markup_printf_escaped(kDefaultBrowserLabelMarkup, |
| 749 color, text.c_str()); | 757 color, text.c_str()); |
| 750 gtk_label_set_markup(GTK_LABEL(default_browser_status_label_), markup); | 758 gtk_label_set_markup(GTK_LABEL(default_browser_status_label_), markup); |
| 751 g_free(markup); | 759 g_free(markup); |
| 752 | 760 |
| 753 gtk_widget_set_sensitive(default_browser_use_as_default_button_, !is_default); | 761 gtk_widget_set_sensitive(default_browser_use_as_default_button_, !is_default); |
| 754 } | 762 } |
| OLD | NEW |