| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // The languages page of the Languages & languages options dialog, which |
| 6 // contains accept-languages and spellchecker language options. |
| 7 |
| 8 #ifndef CHROME_BROWSER_GTK_OPTIONS_LANGUAGES_PAGE_GTK_H_ |
| 9 #define CHROME_BROWSER_GTK_OPTIONS_LANGUAGES_PAGE_GTK_H_ |
| 10 |
| 11 #include <gtk/gtk.h> |
| 12 |
| 13 #include "base/scoped_ptr.h" |
| 14 #include "chrome/browser/options_page_base.h" |
| 15 #include "chrome/common/gtk_tree.h" |
| 16 #include "chrome/common/pref_member.h" |
| 17 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 18 |
| 19 class LanguageOrderTableModel; |
| 20 |
| 21 class LanguagesPageGtk |
| 22 : public OptionsPageBase, |
| 23 public gtk_tree::ModelAdapter::Delegate { |
| 24 public: |
| 25 explicit LanguagesPageGtk(Profile* profile); |
| 26 virtual ~LanguagesPageGtk(); |
| 27 |
| 28 GtkWidget* get_page_widget() const { |
| 29 return page_; |
| 30 } |
| 31 |
| 32 // gtk_tree::ModelAdapter::Delegate implementation. |
| 33 virtual void OnAnyModelUpdate(); |
| 34 virtual void SetColumnValues(int row, GtkTreeIter* iter); |
| 35 |
| 36 // Callback from AddLanguageDialog. |
| 37 void OnAddLanguage(const std::string& new_language); |
| 38 |
| 39 private: |
| 40 // Column ids for |language_order_store_|. |
| 41 enum { |
| 42 COL_LANG, |
| 43 COL_COUNT, |
| 44 }; |
| 45 |
| 46 void Init(); |
| 47 |
| 48 // Enable buttons based on selection state. |
| 49 void EnableControls(); |
| 50 |
| 51 // Get the row number of the first selected row or -1 if no row is selected. |
| 52 int FirstSelectedRowNum(); |
| 53 |
| 54 // Overridden from OptionsPageBase. |
| 55 virtual void NotifyPrefChanged(const std::wstring* pref_name); |
| 56 |
| 57 // Callbacks for accept languages widgets. |
| 58 static void OnSelectionChanged(GtkTreeSelection *selection, |
| 59 LanguagesPageGtk* languages_page); |
| 60 static void OnAddButtonClicked(GtkButton* button, |
| 61 LanguagesPageGtk* languages_page); |
| 62 static void OnRemoveButtonClicked(GtkButton* button, |
| 63 LanguagesPageGtk* languages_page); |
| 64 static void OnMoveUpButtonClicked(GtkButton* button, |
| 65 LanguagesPageGtk* languages_page); |
| 66 static void OnMoveDownButtonClicked(GtkButton* button, |
| 67 LanguagesPageGtk* languages_page); |
| 68 |
| 69 // The accept languages widgets. |
| 70 GtkListStore* language_order_store_; |
| 71 GtkWidget* language_order_tree_; |
| 72 GtkTreeSelection* language_order_selection_; |
| 73 GtkWidget* move_up_button_; |
| 74 GtkWidget* move_down_button_; |
| 75 GtkWidget* add_button_; |
| 76 GtkWidget* remove_button_; |
| 77 |
| 78 // The spell checking widgets. |
| 79 GtkWidget* dictionary_language_combobox_; |
| 80 GtkWidget* enable_autospellcorrect_checkbox_; |
| 81 GtkWidget* enable_spellchecking_checkbox_; |
| 82 |
| 83 // The widget containing the options for this page. |
| 84 GtkWidget* page_; |
| 85 |
| 86 // The model for |language_order_store_|. |
| 87 scoped_ptr<LanguageOrderTableModel> language_order_table_model_; |
| 88 scoped_ptr<gtk_tree::ModelAdapter> language_order_table_adapter_; |
| 89 |
| 90 // Accept languages pref. |
| 91 StringPrefMember accept_languages_; |
| 92 |
| 93 // The spellchecker "dictionary language" pref. |
| 94 StringPrefMember dictionary_language_; |
| 95 |
| 96 // SpellChecker enable pref. |
| 97 BooleanPrefMember enable_spellcheck_; |
| 98 |
| 99 // Auto spell correction pref. |
| 100 BooleanPrefMember enable_autospellcorrect_; |
| 101 |
| 102 // Flag to ignore gtk callbacks while we are loading prefs, to avoid |
| 103 // then turning around and saving them again. |
| 104 bool initializing_; |
| 105 |
| 106 friend class LanguagesPageGtkTest; |
| 107 FRIEND_TEST(LanguagesPageGtkTest, RemoveAcceptLang); |
| 108 FRIEND_TEST(LanguagesPageGtkTest, RemoveMultipleAcceptLang); |
| 109 FRIEND_TEST(LanguagesPageGtkTest, MoveAcceptLang); |
| 110 FRIEND_TEST(LanguagesPageGtkTest, AddAcceptLang); |
| 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(LanguagesPageGtk); |
| 113 }; |
| 114 |
| 115 #endif // CHROME_BROWSER_GTK_OPTIONS_LANGUAGES_PAGE_GTK_H_ |
| OLD | NEW |