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