1
/* This file is part of GPump, a Pump.io client.
3
* GPump (THE SOFTWARE) is made available under the terms and conditions of the
4
* GNU Lesser General Public Licence 3.0. A copy of the licence can be read
5
* in the file lgpl-3.0.txt in the root of this project.
8
const Gtk = imports.gi.Gtk;
9
const _ = imports.gettext.gettext;
10
const Lang = imports.lang;
12
const SettingsData = imports.settings_data;
14
const PreferencesUI = Lang.Class ({
22
title: _("GPump preferences"),
27
this._prepare_header_bar ();
28
this._prepare_list_box ();
30
this.set_property ('resizable', false);
35
_prepare_header_bar: function () {
37
this.headerbar = this.get_header_bar ();
38
this.headerbar.set_show_close_button (false);
39
this.headerbar.pack_end ((this.close_btn = new Gtk.Button ({
43
/* Install a custom style */
44
let special_btn_style_ctx = this.close_btn.get_style_context ();
45
special_btn_style_ctx.add_class ("suggested-action");
47
this.close_btn.connect ('clicked', Lang.bind (this, function () {
53
_prepare_list_box: function () {
54
/*this.get_content_area ().pack_start ()),
56
this.get_content_area ().set_center_widget (
57
(this.layout = new Gtk.Box ({
58
orientation: Gtk.Orientation.VERTICAL,
66
this.layout.pack_start (
67
new Gtk.Frame ({child:
68
(this.list_box = new Gtk.ListBox ({
70
selection_mode: Gtk.SelectionMode.NONE,
80
let settings_object = SettingsData.get_settings ();
82
/*************************** Use dark setting *****************************/
83
let edit_clear_icon = new Gtk.Image ({icon_name: 'edit-clear'});
85
this.use_dark_hbox = Gtk.Box.new (Gtk.Orientation.HORIZONTAL, 5);
87
this.list_box.add (this.use_dark_hbox);
89
this.use_dark_hbox.pack_start ((new Gtk.Label ({
90
label: _("Use dark theme")
93
this.use_dark_hbox.pack_end ((this.use_dark_reset =
95
image: edit_clear_icon})),
97
this.use_dark_hbox.pack_end ((this.use_dark_switch = new Gtk.Switch ()),
100
this.use_dark_switch.set_active (
101
settings_object.get_setting("main.use_dark").data
104
this.use_dark_switch.connect("notify::active",
105
Lang.bind (this, function () {
106
var settings = Gtk.Settings.get_default ();
107
var app_settings = SettingsData.get_settings ();
108
if ( this.use_dark_switch.get_active () ) {
109
settings["gtk_application_prefer_dark_theme"] = true;
110
app_settings.set_setting ("main.use_dark", true);
112
settings["gtk_application_prefer_dark_theme"] = false;
113
app_settings.set_setting ("main.use_dark", false);
117
this.use_dark_reset.connect ("clicked", Lang.bind (this,
118
this._reset_use_dark_theme));
120
/*************************** Privacy settings *****************************/
121
this.list_box.add ((new Gtk.Label ({label: _("Privacy settings")})));
123
/************************ show full name setting **************************/
124
let edit_clear_icon = new Gtk.Image ({icon_name: 'edit-clear'});
126
this.show_full_name_hbox = Gtk.Box.new (Gtk.Orientation.HORIZONTAL, 5);
128
this.list_box.add (this.show_full_name_hbox);
130
this.show_full_name_hbox.pack_start ((new Gtk.Label ({
131
label: _("Show full name")
134
this.show_full_name_hbox.pack_end ((this.show_full_name_reset =
136
image: edit_clear_icon})),
138
this.show_full_name_hbox.pack_end (
139
(this.show_full_name_switch = new Gtk.Switch ()),
141
this.show_full_name_switch.set_active (
142
settings_object.get_setting ("main.privacy.show_full_name").data
145
/*********************** only show avatar setting **************************/
146
let edit_clear_icon = new Gtk.Image ({icon_name: 'edit-clear'});
148
this.only_show_avatar_hbox = Gtk.Box.new (Gtk.Orientation.HORIZONTAL, 5);
150
this.list_box.add (this.only_show_avatar_hbox);
152
this.only_show_avatar_hbox.pack_start ((new Gtk.Label ({
153
label: _("Only show avatar")
156
this.only_show_avatar_hbox.pack_end ((this.only_show_avatar_reset =
158
image: edit_clear_icon})),
160
this.only_show_avatar_hbox.pack_end (
161
(this.only_show_avatar_switch = new Gtk.Switch ()),
163
this.only_show_avatar_switch.set_active (
164
settings_object.get_setting ("main.privacy.only_show_avatar").data
168
//this.list_box.add ((new Gtk.Label ()));
170
/* Reset all settings */
171
this.layout.pack_end (
172
(this.reset_all_btn = new Gtk.Button ({
173
label: _("Reset all settings")
180
this.reset_all_btn.connect ("clicked", Lang.bind(this, this._reset_all));
183
_reset_all: function () {
184
this._reset_use_dark_theme ();
187
_reset_use_dark_theme: function () {
188
/* If the switch is active */
189
if ((this.use_dark_switch.get_active ())) {
190
this.use_dark_switch.set_active (false);
192
/* else we do nothing */