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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
/* This file is part of GPump, a Pump.io client.
*
* GPump (THE SOFTWARE) is made available under the terms and conditions of the
* GNU Lesser General Public Licence 3.0. A copy of the licence can be read
* in the file lgpl-3.0.txt in the root of this project.
*/
const Gtk = imports.gi.Gtk;
const _ = imports.gettext.gettext;
const Lang = imports.lang;
const SettingsData = imports.settings_data;
const PreferencesUI = Lang.Class ({
Name: "PrefrencesUI",
Extends: Gtk.Dialog,
_init: function () {
this.parent ({
use_header_bar: true,
modal: true,
title: _("GPump preferences")
});
this._prepare_header_bar ();
this._prepare_list_box ();
this.set_property ('resizable', false);
this.show_all ();
},
_prepare_header_bar: function () {
this.headerbar = this.get_header_bar ();
this.headerbar.set_show_close_button (false);
this.headerbar.pack_end ((this.close_btn = new Gtk.Button ({
label: _("close")
})));
/* Install a custom style */
let special_btn_style_ctx = this.close_btn.get_style_context ();
special_btn_style_ctx.add_class ("suggested-action");
this.close_btn.connect ('clicked', Lang.bind (this, function () {
this.destroy ();
}));
},
_prepare_list_box: function () {
/*this.get_content_area ().pack_start ()),
true, true, 25);*/
this.get_content_area ().set_center_widget (
(this.list_box = new Gtk.ListBox ({
width_request: 400,
margin: 50,
selection_mode: Gtk.SelectionMode.NONE
})));
let settings_object = SettingsData.get_settings ();
/*************************** Use dark setting *****************************/
let edit_clear_icon = new Gtk.Image ({icon_name: 'edit-clear'});
this.use_dark_hbox = Gtk.Box.new (Gtk.Orientation.HORIZONTAL, 5);
this.list_box.add (this.use_dark_hbox);
this.use_dark_hbox.pack_start ((new Gtk.Label ({
label: _("Use dark theme")
})),
false, false, 3);
this.use_dark_hbox.pack_end ((this.use_dark_reset =
new Gtk.Button ({
image: edit_clear_icon})),
false, false, 3);
this.use_dark_hbox.pack_end ((this.use_dark_switch = new Gtk.Switch ()),
false, false, 3);
this.use_dark_switch.set_active (
settings_object.get_setting("main.use_dark").data
);
this.use_dark_switch.connect("notify::active",
Lang.bind (this, function () {
var settings = Gtk.Settings.get_default ();
var app_settings = SettingsData.get_settings ();
if ( this.use_dark_switch.get_active () ) {
settings["gtk_application_prefer_dark_theme"] = true;
app_settings.set_setting ("main.use_dark", true);
} else {
settings["gtk_application_prefer_dark_theme"] = false;
app_settings.set_setting ("main.use_dark", false);
}
}));
this.use_dark_reset.connect ("clicked", Lang.bind (this,
this._reset_use_dark_theme));
/*************************** Privacy settings *****************************/
this.list_box.add ((new Gtk.Label ({label: _("Privacy settings")})));
/************************ show full name setting **************************/
let edit_clear_icon = new Gtk.Image ({icon_name: 'edit-clear'});
this.show_full_name_hbox = Gtk.Box.new (Gtk.Orientation.HORIZONTAL, 5);
this.list_box.add (this.show_full_name_hbox);
this.show_full_name_hbox.pack_start ((new Gtk.Label ({
label: _("Show full name")
})),
false, false, 3);
this.show_full_name_hbox.pack_end ((this.show_full_name_reset =
new Gtk.Button ({
image: edit_clear_icon})),
false, false, 3);
this.show_full_name_hbox.pack_end (
(this.show_full_name_switch = new Gtk.Switch ()),
false, false, 3);
this.show_full_name_switch.set_active (
settings_object.get_setting ("main.privacy.show_full_name").data
);
/*********************** only show avatar setting **************************/
let edit_clear_icon = new Gtk.Image ({icon_name: 'edit-clear'});
this.only_show_avatar_hbox = Gtk.Box.new (Gtk.Orientation.HORIZONTAL, 5);
this.list_box.add (this.only_show_avatar_hbox);
this.only_show_avatar_hbox.pack_start ((new Gtk.Label ({
label: _("Only show avatar")
})),
false, false, 3);
this.only_show_avatar_hbox.pack_end ((this.only_show_avatar_reset =
new Gtk.Button ({
image: edit_clear_icon})),
false, false, 3);
this.only_show_avatar_hbox.pack_end (
(this.only_show_avatar_switch = new Gtk.Switch ()),
false, false, 3);
this.only_show_avatar_switch.set_active (
settings_object.get_setting ("main.privacy.only_show_avatar").data
);
/* Spacer */
//this.list_box.add ((new Gtk.Label ()));
/* Reset all settings */
this.list_box.add ((this.reset_all_btn = new Gtk.Button ({
label: _("Reset all settings"),
margin_left: 50,
margin_right: 50,
margin_top: 20
})));
this.reset_all_btn.connect ("clicked", Lang.bind(this, this._reset_all));
},
_reset_all: function () {
this._reset_use_dark_theme ();
},
_reset_use_dark_theme: function () {
/* If the switch is active */
if ((this.use_dark_switch.get_active ())) {
this.use_dark_switch.set_active (false);
}
/* else we do nothing */
}
});
|