| 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 <gtk/gtk.h> | 5 #include <gtk/gtk.h> |
| 6 | 6 |
| 7 #include "chrome/browser/options_window.h" | 7 #include "chrome/browser/options_window.h" |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/gtk/options/content_page_gtk.h" |
| 12 #include "chrome/browser/gtk/options/general_page_gtk.h" | 13 #include "chrome/browser/gtk/options/general_page_gtk.h" |
| 13 #include "chrome/browser/profile.h" | 14 #include "chrome/browser/profile.h" |
| 14 #include "chrome/common/gtk_util.h" | 15 #include "chrome/common/gtk_util.h" |
| 15 #include "chrome/common/pref_member.h" | 16 #include "chrome/common/pref_member.h" |
| 16 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 17 #include "chrome/common/pref_service.h" | 18 #include "chrome/common/pref_service.h" |
| 18 #include "chrome/installer/util/google_update_settings.h" | 19 #include "chrome/installer/util/google_update_settings.h" |
| 19 #ifdef CHROME_PERSONALIZATION | 20 #ifdef CHROME_PERSONALIZATION |
| 20 #include "chrome/personalization/personalization.h" | 21 #include "chrome/personalization/personalization.h" |
| 21 #endif | 22 #endif |
| 22 #include "grit/chromium_strings.h" | 23 #include "grit/chromium_strings.h" |
| 23 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
| 24 | 25 |
| 25 /////////////////////////////////////////////////////////////////////////////// | 26 /////////////////////////////////////////////////////////////////////////////// |
| 26 // OptionsWindowGtk | 27 // OptionsWindowGtk |
| 27 // | 28 // |
| 28 // The contents of the Options dialog window. | 29 // The contents of the Options dialog window. |
| 29 | 30 |
| 30 class OptionsWindowGtk { | 31 class OptionsWindowGtk { |
| 31 public: | 32 public: |
| 32 explicit OptionsWindowGtk(Profile* profile); | 33 explicit OptionsWindowGtk(Profile* profile); |
| 33 ~OptionsWindowGtk(); | 34 ~OptionsWindowGtk(); |
| 34 | 35 |
| 35 // Shows the Tab corresponding to the specified OptionsPage. | 36 // Shows the Tab corresponding to the specified OptionsPage. |
| 36 void ShowOptionsPage(OptionsPage page, OptionsGroup highlight_group); | 37 void ShowOptionsPage(OptionsPage page, OptionsGroup highlight_group); |
| 37 | 38 |
| 38 private: | 39 private: |
| 39 // This is the callback function for Stats reporting checkbox. | 40 // This is the callback function for Stats reporting checkbox. |
| 40 static void OnLoggingChange(GtkWidget* widget, | 41 static void OnLoggingChange(GtkWidget* widget, |
| 41 OptionsWindowGtk* options_window); | 42 OptionsWindowGtk* options_window); |
| 42 | 43 |
| 43 static void OnSwitchPage(GtkNotebook* notebook, GtkNotebookPage* page, | 44 static void OnSwitchPage(GtkNotebook* notebook, GtkNotebookPage* page, |
| 44 guint page_num, OptionsWindowGtk* options_window); | 45 guint page_num, OptionsWindowGtk* options_window); |
| 45 | 46 |
| 46 static void OnWindowDestroy(GtkWidget* widget, OptionsWindowGtk* window); | 47 static void OnWindowDestroy(GtkWidget* widget, OptionsWindowGtk* window); |
| 47 | 48 |
| 48 // This function gets called when stats reporting option is changed. | 49 // This function gets called when stats reporting option is changed. |
| 49 void LoggingChanged(GtkWidget* widget); | 50 void LoggingChanged(GtkWidget* widget); |
| 50 | 51 |
| 51 // The options dialog | 52 // The options dialog. |
| 52 GtkWidget *dialog_; | 53 GtkWidget *dialog_; |
| 53 | 54 |
| 54 // The container of the option pages | 55 // The container of the option pages. |
| 55 GtkWidget *notebook_; | 56 GtkWidget *notebook_; |
| 56 | 57 |
| 57 // The Profile associated with these options. | 58 // The Profile associated with these options. |
| 58 Profile* profile_; | 59 Profile* profile_; |
| 59 | 60 |
| 60 // The options pages | 61 // The general page. |
| 61 GeneralPageGtk general_page_; | 62 GeneralPageGtk general_page_; |
| 62 | 63 |
| 64 // The content page. |
| 65 ContentPageGtk content_page_; |
| 66 |
| 63 // The last page the user was on when they opened the Options window. | 67 // The last page the user was on when they opened the Options window. |
| 64 IntegerPrefMember last_selected_page_; | 68 IntegerPrefMember last_selected_page_; |
| 65 | 69 |
| 66 DISALLOW_COPY_AND_ASSIGN(OptionsWindowGtk); | 70 DISALLOW_COPY_AND_ASSIGN(OptionsWindowGtk); |
| 67 }; | 71 }; |
| 68 | 72 |
| 69 static OptionsWindowGtk* instance_ = NULL; | 73 static OptionsWindowGtk* instance_ = NULL; |
| 70 | 74 |
| 71 /////////////////////////////////////////////////////////////////////////////// | 75 /////////////////////////////////////////////////////////////////////////////// |
| 72 // OptionsWindowGtk, public: | 76 // OptionsWindowGtk, public: |
| 73 | 77 |
| 74 OptionsWindowGtk::OptionsWindowGtk(Profile* profile) | 78 OptionsWindowGtk::OptionsWindowGtk(Profile* profile) |
| 75 // Always show preferences for the original profile. Most state when off | 79 // Always show preferences for the original profile. Most state when off |
| 76 // the record comes from the original profile, but we explicitly use | 80 // the record comes from the original profile, but we explicitly use |
| 77 // the original profile to avoid potential problems. | 81 // the original profile to avoid potential problems. |
| 78 : profile_(profile->GetOriginalProfile()), general_page_(profile_) { | 82 : profile_(profile->GetOriginalProfile()), |
| 83 general_page_(profile_), |
| 84 content_page_(profile_) { |
| 79 // The download manager needs to be initialized before the contents of the | 85 // The download manager needs to be initialized before the contents of the |
| 80 // Options Window are created. | 86 // Options Window are created. |
| 81 profile_->GetDownloadManager(); | 87 profile_->GetDownloadManager(); |
| 82 // We don't need to observe changes in this value. | 88 // We don't need to observe changes in this value. |
| 83 last_selected_page_.Init(prefs::kOptionsWindowLastTabIndex, | 89 last_selected_page_.Init(prefs::kOptionsWindowLastTabIndex, |
| 84 g_browser_process->local_state(), NULL); | 90 g_browser_process->local_state(), NULL); |
| 85 | 91 |
| 86 dialog_ = gtk_dialog_new_with_buttons( | 92 dialog_ = gtk_dialog_new_with_buttons( |
| 87 l10n_util::GetStringFUTF8(IDS_OPTIONS_DIALOG_TITLE, | 93 l10n_util::GetStringFUTF8(IDS_OPTIONS_DIALOG_TITLE, |
| 88 WideToUTF16(l10n_util::GetString(IDS_PRODUCT_NAME))).c_str(), | 94 WideToUTF16(l10n_util::GetString(IDS_PRODUCT_NAME))).c_str(), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 100 notebook_ = gtk_notebook_new(); | 106 notebook_ = gtk_notebook_new(); |
| 101 | 107 |
| 102 gtk_notebook_append_page( | 108 gtk_notebook_append_page( |
| 103 GTK_NOTEBOOK(notebook_), | 109 GTK_NOTEBOOK(notebook_), |
| 104 general_page_.get_page_widget(), | 110 general_page_.get_page_widget(), |
| 105 gtk_label_new( | 111 gtk_label_new( |
| 106 l10n_util::GetStringUTF8(IDS_OPTIONS_GENERAL_TAB_LABEL).c_str())); | 112 l10n_util::GetStringUTF8(IDS_OPTIONS_GENERAL_TAB_LABEL).c_str())); |
| 107 | 113 |
| 108 gtk_notebook_append_page( | 114 gtk_notebook_append_page( |
| 109 GTK_NOTEBOOK(notebook_), | 115 GTK_NOTEBOOK(notebook_), |
| 110 gtk_label_new("TODO content"), | 116 content_page_.get_page_widget(), |
| 111 gtk_label_new( | 117 gtk_label_new( |
| 112 l10n_util::GetStringUTF8(IDS_OPTIONS_CONTENT_TAB_LABEL).c_str())); | 118 l10n_util::GetStringUTF8(IDS_OPTIONS_CONTENT_TAB_LABEL).c_str())); |
| 113 | 119 |
| 114 #ifdef CHROME_PERSONALIZATION | 120 #ifdef CHROME_PERSONALIZATION |
| 115 if (!Personalization::IsP13NDisabled(profile)) { | 121 if (!Personalization::IsP13NDisabled(profile)) { |
| 116 gtk_notebook_append_page( | 122 gtk_notebook_append_page( |
| 117 GTK_NOTEBOOK(notebook_), | 123 GTK_NOTEBOOK(notebook_), |
| 118 gtk_label_new("TODO personalization"), | 124 gtk_label_new("TODO personalization"), |
| 119 gtk_label_new( | 125 gtk_label_new( |
| 120 l10n_util::GetStringUTF8(IDS_OPTIONS_USER_DATA_TAB_LABEL).c_str())); | 126 l10n_util::GetStringUTF8(IDS_OPTIONS_USER_DATA_TAB_LABEL).c_str())); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 OptionsGroup highlight_group, | 239 OptionsGroup highlight_group, |
| 234 Profile* profile) { | 240 Profile* profile) { |
| 235 DCHECK(profile); | 241 DCHECK(profile); |
| 236 // If there's already an existing options window, activate it and switch to | 242 // If there's already an existing options window, activate it and switch to |
| 237 // the specified page. | 243 // the specified page. |
| 238 if (!instance_) { | 244 if (!instance_) { |
| 239 instance_ = new OptionsWindowGtk(profile); | 245 instance_ = new OptionsWindowGtk(profile); |
| 240 } | 246 } |
| 241 instance_->ShowOptionsPage(page, highlight_group); | 247 instance_->ShowOptionsPage(page, highlight_group); |
| 242 } | 248 } |
| OLD | NEW |