8
8
const Gtk = imports.gi.Gtk;
9
const _ = imports.gettext.gettext;
9
10
const Lang = imports.lang;
10
const _ = imports.gettext.gettext;
12
12
const SettingsData = imports.settings_data;
14
17
const PreferencesUI = Lang.Class ({
15
18
Name: "PrefrencesUI",
16
19
Extends: Gtk.Dialog,
52
58
/*this.get_content_area ().pack_start ()),
54
60
this.get_content_area ().set_center_widget (
55
(this.list_box = new Gtk.ListBox ({
58
selection_mode: Gtk.SelectionMode.NONE
61
(this.layout = new Gtk.Box ({
62
orientation: Gtk.Orientation.VERTICAL,
70
this.layout.pack_start (
71
new Gtk.Frame ({child:
72
(this.list_box = new Gtk.ListBox ({
74
selection_mode: Gtk.SelectionMode.NONE,
61
84
let settings_object = SettingsData.get_settings ();
68
91
this.list_box.add (this.use_dark_hbox);
70
93
this.use_dark_hbox.pack_start ((new Gtk.Label ({
71
label: _("Use dark theme")
74
this.use_dark_hbox.pack_end ((this.use_dark_reset =
76
image: edit_clear_icon})),
94
label: _("Use dark theme")
97
this.use_dark_hbox.pack_end ((this.use_dark_reset = new Gtk.Button ({
98
image: edit_clear_icon
78
101
this.use_dark_hbox.pack_end ((this.use_dark_switch = new Gtk.Switch ()),
85
108
this.use_dark_switch.connect("notify::active",
86
109
Lang.bind (this, function () {
87
var settings = Gtk.Settings.get_default ();
88
var app_settings = SettingsData.get_settings ();
110
let settings = Gtk.Settings.get_default ();
111
let app_settings = SettingsData.get_settings ();
89
112
if ( this.use_dark_switch.get_active () ) {
90
113
settings["gtk_application_prefer_dark_theme"] = true;
91
114
app_settings.set_setting ("main.use_dark", true);
109
132
this.list_box.add (this.show_full_name_hbox);
111
134
this.show_full_name_hbox.pack_start ((new Gtk.Label ({
112
label: _("Show full name")
135
label: _("Show full name")
136
})),false, false, 3);
115
138
this.show_full_name_hbox.pack_end ((this.show_full_name_reset =
117
image: edit_clear_icon})),
140
image: edit_clear_icon
141
})), false, false, 3);
119
143
this.show_full_name_hbox.pack_end (
120
(this.show_full_name_switch = new Gtk.Switch ()),
144
(this.show_full_name_switch = new Gtk.Switch ()), false, false, 3);
122
146
this.show_full_name_switch.set_active (
123
147
settings_object.get_setting ("main.privacy.show_full_name").data
150
this.show_full_name_switch.connect ("notify::active",
151
Lang.bind (this, function () {
152
let app_settings = SettingsData.get_settings ();
153
if (this.show_full_name_switch.get_active ()) {
154
app_settings.set_setting ("main.privacy.show_full_name", true);
156
app_settings.set_setting ("main.privacy.show_full_name", false);
160
this.show_full_name_reset.connect ("clicked", Lang.bind (this,
161
this._reset_show_full_name));
126
163
/*********************** only show avatar setting **************************/
127
164
let edit_clear_icon = new Gtk.Image ({icon_name: 'edit-clear'});
131
168
this.list_box.add (this.only_show_avatar_hbox);
133
170
this.only_show_avatar_hbox.pack_start ((new Gtk.Label ({
134
label: _("Only show avatar")
137
this.only_show_avatar_hbox.pack_end ((this.only_show_avatar_reset =
139
image: edit_clear_icon})),
171
label: _("Only show avatar")
172
})), false, false, 3);
174
this.only_show_avatar_hbox.pack_end ((this.only_show_avatar_reset =
176
image: edit_clear_icon
177
})), false, false, 3);
141
179
this.only_show_avatar_hbox.pack_end (
142
180
(this.only_show_avatar_switch = new Gtk.Switch ()),
143
181
false, false, 3);
145
183
settings_object.get_setting ("main.privacy.only_show_avatar").data
149
//this.list_box.add ((new Gtk.Label ()));
186
this.only_show_avatar_switch.connect ("notify::active",
187
Lang.bind (this, function () {
188
let app_settings = SettingsData.get_settings ();
189
if (this.only_show_avatar_switch.get_active ()) {
190
app_settings.set_setting ("main.privacy.only_show_avatar", true);
192
app_settings.set_setting ("main.privacy.only_show_avatar", false);
151
196
/* Reset all settings */
152
this.list_box.add ((this.reset_all_btn = new Gtk.Button ({
153
label: _("Reset all settings"),
197
this.layout.pack_end (
198
(this.reset_all_btn = new Gtk.Button ({
199
label: _("Reset all settings")
159
206
this.reset_all_btn.connect ("clicked", Lang.bind(this, this._reset_all));
162
209
_reset_all: function () {
163
210
this._reset_use_dark_theme ();
211
this._reset_show_full_name ();
212
this._reset_only_show_avatar_reset ();
166
215
_reset_use_dark_theme: function () {
168
217
if ((this.use_dark_switch.get_active ())) {
169
218
this.use_dark_switch.set_active (false);
171
/* else we do nothing */
222
_reset_show_full_name: function () {
223
if (!(this.show_full_name_switch.get_active ())) {
224
this.show_full_name_switch.set_active (true);
228
_reset_only_show_avatar_reset: function () {
229
if ((this.only_show_avatar_switch.get_active ())) {
230
this.only_show_avatar_switch.set_active (false);