OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // The languages page of the Languages & languages options dialog, which | |
6 // contains accept-languages and spellchecker language options. | |
7 // | |
8 // Note that we intentionally do not implement the application locale setting, | |
9 // as it does not make sense on Linux, where locale is set through the LANG and | |
10 // LC_* environment variables. | |
11 | |
12 #ifndef CHROME_BROWSER_GTK_OPTIONS_LANGUAGES_PAGE_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_OPTIONS_LANGUAGES_PAGE_GTK_H_ |
13 #define CHROME_BROWSER_GTK_OPTIONS_LANGUAGES_PAGE_GTK_H_ | 6 #define CHROME_BROWSER_GTK_OPTIONS_LANGUAGES_PAGE_GTK_H_ |
14 #pragma once | 7 #pragma once |
15 | 8 |
16 #include <gtk/gtk.h> | 9 #include "chrome/browser/ui/gtk/options/languages_page_gtk.h" |
17 | 10 // TODO(msw): remove this file once all includes have been updated. |
18 #include <string> | |
19 | |
20 #include "app/gtk_signal.h" | |
21 #include "base/gtest_prod_util.h" | |
22 #include "base/scoped_ptr.h" | |
23 #include "chrome/browser/gtk/gtk_tree.h" | |
24 #include "chrome/browser/prefs/pref_member.h" | |
25 #include "chrome/browser/ui/options/options_page_base.h" | |
26 | |
27 class LanguageComboboxModel; | |
28 class LanguageOrderTableModel; | |
29 | |
30 class LanguagesPageGtk | |
31 : public OptionsPageBase, | |
32 public gtk_tree::TableAdapter::Delegate { | |
33 public: | |
34 explicit LanguagesPageGtk(Profile* profile); | |
35 virtual ~LanguagesPageGtk(); | |
36 | |
37 GtkWidget* get_page_widget() const { return page_; } | |
38 | |
39 // gtk_tree::TableAdapter::Delegate implementation. | |
40 virtual void OnAnyModelUpdate(); | |
41 virtual void SetColumnValues(int row, GtkTreeIter* iter); | |
42 | |
43 // Callback from AddLanguageDialog. | |
44 void OnAddLanguage(const std::string& new_language); | |
45 | |
46 private: | |
47 // Column ids for |language_order_store_|. | |
48 enum { | |
49 COL_LANG, | |
50 COL_COUNT, | |
51 }; | |
52 | |
53 void Init(); | |
54 | |
55 // Enable buttons based on selection state. | |
56 void EnableControls(); | |
57 | |
58 // Get the row number of the first selected row or -1 if no row is selected. | |
59 int FirstSelectedRowNum(); | |
60 | |
61 // Overridden from OptionsPageBase. | |
62 virtual void NotifyPrefChanged(const std::string* pref_name); | |
63 | |
64 // Callbacks for accept languages widgets. | |
65 CHROMEG_CALLBACK_0(LanguagesPageGtk, void, OnSelectionChanged, | |
66 GtkTreeSelection*); | |
67 CHROMEGTK_CALLBACK_0(LanguagesPageGtk, void, OnAddButtonClicked); | |
68 CHROMEGTK_CALLBACK_0(LanguagesPageGtk, void, OnRemoveButtonClicked); | |
69 CHROMEGTK_CALLBACK_0(LanguagesPageGtk, void, OnMoveUpButtonClicked); | |
70 CHROMEGTK_CALLBACK_0(LanguagesPageGtk, void, OnMoveDownButtonClicked); | |
71 | |
72 // Callbacks for spellchecker option widgets. | |
73 CHROMEGTK_CALLBACK_0(LanguagesPageGtk, void, OnEnableSpellCheckingToggled); | |
74 CHROMEGTK_CALLBACK_0(LanguagesPageGtk, void, | |
75 OnEnableAutoSpellCheckingToggled); | |
76 CHROMEGTK_CALLBACK_0(LanguagesPageGtk, void, OnDictionaryLanguageChanged); | |
77 | |
78 // The accept languages widgets. | |
79 GtkListStore* language_order_store_; | |
80 GtkWidget* language_order_tree_; | |
81 GtkTreeSelection* language_order_selection_; | |
82 GtkWidget* move_up_button_; | |
83 GtkWidget* move_down_button_; | |
84 GtkWidget* add_button_; | |
85 GtkWidget* remove_button_; | |
86 | |
87 // The spell checking widgets. | |
88 GtkWidget* dictionary_language_combobox_; | |
89 GtkWidget* enable_autospellcorrect_checkbox_; | |
90 GtkWidget* enable_spellchecking_checkbox_; | |
91 | |
92 // The widget containing the options for this page. | |
93 GtkWidget* page_; | |
94 | |
95 // The model for |language_order_store_|. | |
96 scoped_ptr<LanguageOrderTableModel> language_order_table_model_; | |
97 scoped_ptr<gtk_tree::TableAdapter> language_order_table_adapter_; | |
98 | |
99 // Accept languages pref. | |
100 StringPrefMember accept_languages_; | |
101 | |
102 // The spellchecker "dictionary language" pref and model. | |
103 StringPrefMember dictionary_language_; | |
104 scoped_ptr<LanguageComboboxModel> dictionary_language_model_; | |
105 | |
106 // If a language was auto-added to accept_languages_ due to being selected as | |
107 // the dictionary language, it is saved in this string, so that it can be | |
108 // removed if the dictionary language is changed again. | |
109 std::string spellcheck_language_added_; | |
110 | |
111 // SpellChecker enable pref. | |
112 BooleanPrefMember enable_spellcheck_; | |
113 | |
114 // Auto spell correction pref. | |
115 BooleanPrefMember enable_autospellcorrect_; | |
116 | |
117 // Flag to ignore gtk callbacks while we are loading prefs, to avoid | |
118 // then turning around and saving them again. | |
119 bool initializing_; | |
120 | |
121 friend class LanguagesPageGtkTest; | |
122 FRIEND_TEST_ALL_PREFIXES(LanguagesPageGtkTest, RemoveAcceptLang); | |
123 FRIEND_TEST_ALL_PREFIXES(LanguagesPageGtkTest, RemoveMultipleAcceptLang); | |
124 FRIEND_TEST_ALL_PREFIXES(LanguagesPageGtkTest, MoveAcceptLang); | |
125 FRIEND_TEST_ALL_PREFIXES(LanguagesPageGtkTest, AddAcceptLang); | |
126 FRIEND_TEST_ALL_PREFIXES(LanguagesPageGtkTest, EnableSpellChecking); | |
127 FRIEND_TEST_ALL_PREFIXES(LanguagesPageGtkTest, DictionaryLanguage); | |
128 | |
129 DISALLOW_COPY_AND_ASSIGN(LanguagesPageGtk); | |
130 }; | |
131 | 11 |
132 #endif // CHROME_BROWSER_GTK_OPTIONS_LANGUAGES_PAGE_GTK_H_ | 12 #endif // CHROME_BROWSER_GTK_OPTIONS_LANGUAGES_PAGE_GTK_H_ |
OLD | NEW |