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 Lang = imports.lang;
10
const _ = imports.gettext.gettext;
12
const SettingsData = imports.settings_data;
14
const PreferencesUI = Lang.Class ({
22
title: _("GPump preferences")
25
this._prepare_header_bar ();
26
this._prepare_list_box ();
28
this.set_property ('resizable', false);
33
_prepare_header_bar: function () {
35
this.headerbar = this.get_header_bar ();
36
this.headerbar.set_show_close_button (false);
37
this.headerbar.pack_end ((this.close_btn = new Gtk.Button ({
41
/* Install a custom style */
42
let special_btn_style_ctx = this.close_btn.get_style_context ();
43
special_btn_style_ctx.add_class ("suggested-action");
45
this.close_btn.connect ('clicked', Lang.bind (this, function () {
51
_prepare_list_box: function () {
52
/*this.get_content_area ().pack_start ()),
54
this.get_content_area ().set_center_widget (
55
(this.list_box = new Gtk.ListBox ({
58
selection_mode: Gtk.SelectionMode.NONE
61
let settings_object = SettingsData.get_settings ();
63
/*************************** Use dark setting *****************************/
64
let edit_clear_icon = new Gtk.Image ({icon_name: 'edit-clear'});
66
this.use_dark_hbox = Gtk.Box.new (Gtk.Orientation.HORIZONTAL, 5);
68
this.list_box.add (this.use_dark_hbox);
70
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})),
78
this.use_dark_hbox.pack_end ((this.use_dark_switch = new Gtk.Switch ()),
81
this.use_dark_switch.set_active (
82
settings_object.get_setting("main.use_dark").data
85
this.use_dark_switch.connect("notify::active",
86
Lang.bind (this, function () {
87
var settings = Gtk.Settings.get_default ();
88
var app_settings = SettingsData.get_settings ();
89
if ( this.use_dark_switch.get_active () ) {
90
settings["gtk_application_prefer_dark_theme"] = true;
91
app_settings.set_setting ("main.use_dark", true);
93
settings["gtk_application_prefer_dark_theme"] = false;
94
app_settings.set_setting ("main.use_dark", false);
98
this.use_dark_reset.connect ("clicked", Lang.bind (this,
99
this._reset_use_dark_theme));
101
/*************************** Privacy settings *****************************/
102
this.list_box.add ((new Gtk.Label ({label: _("Privacy settings")})));
104
/************************ show full name setting **************************/
105
let edit_clear_icon = new Gtk.Image ({icon_name: 'edit-clear'});
107
this.show_full_name_hbox = Gtk.Box.new (Gtk.Orientation.HORIZONTAL, 5);
109
this.list_box.add (this.show_full_name_hbox);
111
this.show_full_name_hbox.pack_start ((new Gtk.Label ({
112
label: _("Show full name")
115
this.show_full_name_hbox.pack_end ((this.show_full_name_reset =
117
image: edit_clear_icon})),
119
this.show_full_name_hbox.pack_end (
120
(this.show_full_name_switch = new Gtk.Switch ()),
122
this.show_full_name_switch.set_active (
123
settings_object.get_setting ("main.privacy.show_full_name").data
126
/*********************** only show avatar setting **************************/
127
let edit_clear_icon = new Gtk.Image ({icon_name: 'edit-clear'});
129
this.only_show_avatar_hbox = Gtk.Box.new (Gtk.Orientation.HORIZONTAL, 5);
131
this.list_box.add (this.only_show_avatar_hbox);
133
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})),
141
this.only_show_avatar_hbox.pack_end (
142
(this.only_show_avatar_switch = new Gtk.Switch ()),
144
this.only_show_avatar_switch.set_active (
145
settings_object.get_setting ("main.privacy.only_show_avatar").data
149
//this.list_box.add ((new Gtk.Label ()));
151
/* Reset all settings */
152
this.list_box.add ((this.reset_all_btn = new Gtk.Button ({
153
label: _("Reset all settings"),
159
this.reset_all_btn.connect ("clicked", Lang.bind(this, this._reset_all));
162
_reset_all: function () {
163
this._reset_use_dark_theme ();
166
_reset_use_dark_theme: function () {
167
/* If the switch is active */
168
if ((this.use_dark_switch.get_active ())) {
169
this.use_dark_switch.set_active (false);
171
/* else we do nothing */