Architecture rewrite and new features
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
Night Theme Switcher Gnome Shell extension
|
||||
|
||||
Copyright (C) 2020 Romain Vigier
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation, either version 3 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program. If not, see <http s ://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const { GdkPixbuf, Gio, Gtk } = imports.gi;
|
||||
const { extensionUtils } = imports.misc;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases;
|
||||
|
||||
const Gettext = imports.gettext.domain(Me.metadata.uuid);
|
||||
const _ = Gettext.gettext;
|
||||
|
||||
|
||||
const shell_minor_version = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]);
|
||||
if ( shell_minor_version <= 30 ) {
|
||||
extensionUtils.getSettings = Me.imports.convenience.getSettings;
|
||||
}
|
||||
|
||||
|
||||
var BackgroundsPreferences = class {
|
||||
|
||||
constructor() {
|
||||
const label = _('Backgrounds');
|
||||
const description = _('You can set different backgrounds for day and night.');
|
||||
const content = new SettingsList();
|
||||
|
||||
content.add_row(new SettingsListRow(_('Switch backgrounds'), new BackgroundsEnabledControl()));
|
||||
content.add_row(new SettingsListRow(_('Day background'), new TimeBackgroundControl('day')));
|
||||
content.add_row(new SettingsListRow(_('Night background'), new TimeBackgroundControl('night')));
|
||||
|
||||
return new SettingsPage(label, description, content);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class BackgroundsEnabledControl {
|
||||
|
||||
constructor() {
|
||||
const settings = extensionUtils.getSettings();
|
||||
const toggle = new Gtk.Switch({
|
||||
active: settings.get_boolean('backgrounds-enabled')
|
||||
});
|
||||
settings.bind(
|
||||
'backgrounds-enabled',
|
||||
toggle,
|
||||
'active',
|
||||
Gio.SettingsBindFlags.DEFAULT
|
||||
);
|
||||
return toggle;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class TimeBackgroundControl {
|
||||
|
||||
constructor(time) {
|
||||
const settings = extensionUtils.getSettings();
|
||||
|
||||
const filter = new Gtk.FileFilter();
|
||||
filter.add_mime_type('image/jpeg');
|
||||
filter.add_mime_type('image/png');
|
||||
filter.add_mime_type('image/tiff');
|
||||
|
||||
const preview = new Gtk.Image({
|
||||
pixel_size: 256
|
||||
});
|
||||
|
||||
const button = new Gtk.FileChooserButton({
|
||||
title: _('Select your background image'),
|
||||
action: Gtk.FileChooserAction.OPEN,
|
||||
filter: filter,
|
||||
preview_widget: preview,
|
||||
use_preview_label: false
|
||||
});
|
||||
button.set_uri(settings.get_string(`background-${time}`));
|
||||
button.connect('update-preview', () => {
|
||||
const file = button.get_preview_filename();
|
||||
const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, 256, 256);
|
||||
preview.set_from_pixbuf(pixbuf);
|
||||
});
|
||||
button.connect('file-set', () => settings.set_string(`background-${time}`, button.get_uri()));
|
||||
settings.bind(
|
||||
'backgrounds-enabled',
|
||||
button,
|
||||
'sensitive',
|
||||
Gio.SettingsBindFlags.DEFAULT
|
||||
);
|
||||
settings.connect(`changed::background-${time}`, () => button.set_uri(settings.get_string(`background-${time}`)));
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
Night Theme Switcher Gnome Shell extension
|
||||
|
||||
Copyright (C) 2020 Romain Vigier
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation, either version 3 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program. If not, see <http s ://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const { Gio, Gtk } = imports.gi;
|
||||
const { extensionUtils } = imports.misc;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases;
|
||||
|
||||
const Gettext = imports.gettext.domain(Me.metadata.uuid);
|
||||
const _ = Gettext.gettext;
|
||||
|
||||
|
||||
const shell_minor_version = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]);
|
||||
if ( shell_minor_version <= 30 ) {
|
||||
extensionUtils.getSettings = Me.imports.convenience.getSettings;
|
||||
}
|
||||
|
||||
|
||||
var CommandsPreferences = class {
|
||||
|
||||
constructor() {
|
||||
const label = _('Commands');
|
||||
const description = _('You can set custom commands that will be run when the time of the day changes.');
|
||||
const content = new SettingsList();
|
||||
|
||||
content.add_row(new SettingsListRow(_('Use custom commands'), new CommandsEnabledControl()));
|
||||
content.add_row(new SettingsListRow(_('Sunrise'), new SuntimeCommandControl('sunrise')));
|
||||
content.add_row(new SettingsListRow(_('Sunset'), new SuntimeCommandControl('sunset')));
|
||||
|
||||
return new SettingsPage(label, description, content);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class CommandsEnabledControl {
|
||||
|
||||
constructor() {
|
||||
const settings = extensionUtils.getSettings();
|
||||
const toggle = new Gtk.Switch({
|
||||
active: settings.get_boolean('commands-enabled')
|
||||
});
|
||||
settings.bind(
|
||||
'commands-enabled',
|
||||
toggle,
|
||||
'active',
|
||||
Gio.SettingsBindFlags.DEFAULT
|
||||
);
|
||||
return toggle;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class SuntimeCommandControl {
|
||||
|
||||
constructor(suntime) {
|
||||
const message = new Map([
|
||||
['sunrise', _('Hello sunshine!')],
|
||||
['sunset', _('Hello moonshine!')]
|
||||
]);
|
||||
const settings = extensionUtils.getSettings();
|
||||
const entry = new Gtk.Entry({
|
||||
width_request: 300,
|
||||
placeholder_text: _(`notify-send "${message.get(suntime)}"`)
|
||||
});
|
||||
settings.bind(
|
||||
`command-${suntime}`,
|
||||
entry,
|
||||
'text',
|
||||
Gio.SettingsBindFlags.DEFAULT
|
||||
);
|
||||
settings.bind(
|
||||
'commands-enabled',
|
||||
entry,
|
||||
'sensitive',
|
||||
Gio.SettingsBindFlags.DEFAULT
|
||||
);
|
||||
return entry;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
Night Theme Switcher Gnome Shell extension
|
||||
|
||||
Copyright (C) 2020 Romain Vigier
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation, either version 3 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program. If not, see <http s ://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const { Gio, Gtk } = imports.gi;
|
||||
const { extensionUtils } = imports.misc;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases;
|
||||
const { get_installed_gtk_themes } = Me.imports.utils;
|
||||
|
||||
const Gettext = imports.gettext.domain(Me.metadata.uuid);
|
||||
const _ = Gettext.gettext;
|
||||
|
||||
|
||||
const shell_minor_version = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]);
|
||||
if ( shell_minor_version <= 30 ) {
|
||||
extensionUtils.getSettings = Me.imports.convenience.getSettings;
|
||||
}
|
||||
|
||||
|
||||
var GtkThemePreferences = class {
|
||||
|
||||
constructor() {
|
||||
const label = _('GTK theme');
|
||||
const description = _('The extension will try to automatically detect the day and night variants of your GTK theme.\n\nIf the theme you use isn\'t supported, please <a href="https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension/-/issues">submit a request</a>. You can also manually set variants.');
|
||||
const content = new SettingsList();
|
||||
|
||||
content.add_row(new SettingsListRow(_('Manual variants'), new ManualGtkVariantsControl()));
|
||||
content.add_row(new SettingsListRow(_('Day variant'), new TimeGtkVariantControl('day')));
|
||||
content.add_row(new SettingsListRow(_('Night variant'), new TimeGtkVariantControl('night')));
|
||||
|
||||
return new SettingsPage(label, description, content);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class ManualGtkVariantsControl {
|
||||
|
||||
constructor() {
|
||||
const settings = extensionUtils.getSettings();
|
||||
const toggle = new Gtk.Switch({
|
||||
active: false
|
||||
});
|
||||
settings.bind(
|
||||
'manual-gtk-variants',
|
||||
toggle,
|
||||
'active',
|
||||
Gio.SettingsBindFlags.DEFAULT
|
||||
);
|
||||
return toggle;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class TimeGtkVariantControl {
|
||||
|
||||
constructor(time) {
|
||||
const settings = extensionUtils.getSettings();
|
||||
const combo = new Gtk.ComboBoxText();
|
||||
const themes = Array.from(get_installed_gtk_themes()).sort();
|
||||
themes.forEach(theme => combo.append(theme, theme));
|
||||
settings.bind(
|
||||
`gtk-variant-${time}`,
|
||||
combo,
|
||||
'active-id',
|
||||
Gio.SettingsBindFlags.DEFAULT
|
||||
);
|
||||
settings.bind(
|
||||
'manual-gtk-variants',
|
||||
combo,
|
||||
'sensitive',
|
||||
Gio.SettingsBindFlags.DEFAULT
|
||||
);
|
||||
return combo;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
Night Theme Switcher Gnome Shell extension
|
||||
|
||||
Copyright (C) 2020 Romain Vigier
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation, either version 3 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program. If not, see <http s ://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const { Gio, Gtk } = imports.gi;
|
||||
const { extensionUtils } = imports.misc;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases;
|
||||
|
||||
const Gettext = imports.gettext.domain(Me.metadata.uuid);
|
||||
const _ = Gettext.gettext;
|
||||
|
||||
|
||||
const shell_minor_version = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]);
|
||||
if ( shell_minor_version <= 30 ) {
|
||||
extensionUtils.getSettings = Me.imports.convenience.getSettings;
|
||||
}
|
||||
|
||||
|
||||
var SchedulePreferences = class {
|
||||
|
||||
constructor() {
|
||||
const label = _('Schedule');
|
||||
const description = _('The extension will try to use Night Light or Location Services to automatically set your current sunrise and sunset times if they are enabled.\n\nIf you prefer, you can manually choose a time source.');
|
||||
const content = new SettingsList();
|
||||
|
||||
content.add_row(new SettingsListRow(_('Manual time source'), new ManualTimeSourceControl()));
|
||||
content.add_row(new SettingsListRow(_('Time source'), new TimeSourceControl()));
|
||||
content.add_row(new SettingsListRow(_('Sunrise'), new SuntimeControl('sunrise')));
|
||||
content.add_row(new SettingsListRow(_('Sunset'), new SuntimeControl('sunset')));
|
||||
|
||||
return new SettingsPage(label, description, content);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class ManualTimeSourceControl {
|
||||
|
||||
constructor() {
|
||||
const settings = extensionUtils.getSettings();
|
||||
const toggle = new Gtk.Switch({
|
||||
active: false
|
||||
});
|
||||
settings.bind(
|
||||
'manual-time-source',
|
||||
toggle,
|
||||
'active',
|
||||
Gio.SettingsBindFlags.DEFAULT
|
||||
);
|
||||
return toggle;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class TimeSourceControl {
|
||||
|
||||
constructor() {
|
||||
const settings = extensionUtils.getSettings();
|
||||
const colorSettings = new Gio.Settings({ schema: 'org.gnome.settings-daemon.plugins.color' });
|
||||
const locationSettings = new Gio.Settings({ schema: 'org.gnome.system.location' });
|
||||
|
||||
const box = new Gtk.Box({
|
||||
spacing: 8,
|
||||
orientation: Gtk.Orientation.HORIZONTAL,
|
||||
can_focus: false
|
||||
});
|
||||
|
||||
const nightlight_radio = new Gtk.RadioButton({
|
||||
label: _('Night Light'),
|
||||
active: (settings.get_string('time-source') === 'nightlight')
|
||||
});
|
||||
const update_nightlight_radio_sensitivity = () => nightlight_radio.set_sensitive(!!(settings.get_boolean('manual-time-source') && colorSettings.get_boolean('night-light-enabled')));
|
||||
settings.connect('changed::manual-time-source', update_nightlight_radio_sensitivity);
|
||||
colorSettings.connect('changed::night-light-enabled', update_nightlight_radio_sensitivity);
|
||||
update_nightlight_radio_sensitivity();
|
||||
nightlight_radio.connect('toggled', () => {
|
||||
if ( nightlight_radio.get_active() ) {
|
||||
settings.set_string('time-source', 'nightlight')
|
||||
}
|
||||
});
|
||||
box.pack_start(nightlight_radio, false, false, 0);
|
||||
|
||||
const location_radio = new Gtk.RadioButton({
|
||||
label: _('Location Services'),
|
||||
group: nightlight_radio,
|
||||
active: (settings.get_string('time-source') === 'location')
|
||||
});
|
||||
const update_location_radio_sensitivity = () => location_radio.set_sensitive(!!(settings.get_boolean('manual-time-source') && locationSettings.get_boolean('enabled')));
|
||||
settings.connect('changed::manual-time-source', update_location_radio_sensitivity);
|
||||
locationSettings.connect('changed::enabled', update_location_radio_sensitivity);
|
||||
update_location_radio_sensitivity();
|
||||
location_radio.connect('toggled', () => {
|
||||
if ( location_radio.get_active() ) {
|
||||
settings.set_string('time-source', 'location')
|
||||
}
|
||||
});
|
||||
box.pack_start(location_radio, false, false, 0);
|
||||
|
||||
const schedule_radio = new Gtk.RadioButton({
|
||||
label: _('Manual schedule'),
|
||||
group: nightlight_radio,
|
||||
active: (settings.get_string('time-source') === 'schedule')
|
||||
});
|
||||
settings.bind(
|
||||
'manual-time-source',
|
||||
schedule_radio,
|
||||
'sensitive',
|
||||
Gio.SettingsBindFlags.DEFAULT
|
||||
);
|
||||
schedule_radio.connect('toggled', () => {
|
||||
if ( schedule_radio.get_active() ) {
|
||||
settings.set_string('time-source', 'schedule')
|
||||
}
|
||||
});
|
||||
box.pack_start(schedule_radio, false, false, 0);
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class SuntimeControl {
|
||||
|
||||
constructor(suntime) {
|
||||
const settings = extensionUtils.getSettings();
|
||||
const box = new Gtk.Box({
|
||||
spacing: 8,
|
||||
orientation: Gtk.Orientation.HORIZONTAL,
|
||||
can_focus: false
|
||||
});
|
||||
|
||||
const update_spin_sensitivity = (spin) => spin.set_sensitive(!!(settings.get_boolean('manual-time-source') && settings.get_string('time-source') === 'schedule'));
|
||||
|
||||
const time = settings.get_double(`schedule-${suntime}`);
|
||||
const hours = Math.trunc(time);
|
||||
const minutes = Math.round((time - hours) * 60);
|
||||
|
||||
const hours_spin = new Gtk.SpinButton({
|
||||
adjustment: new Gtk.Adjustment({
|
||||
value: hours,
|
||||
lower: 0,
|
||||
upper: 23,
|
||||
step_increment: 1,
|
||||
page_increment: 0,
|
||||
page_size: 0
|
||||
}),
|
||||
value: hours,
|
||||
numeric: true,
|
||||
wrap: true,
|
||||
orientation: Gtk.Orientation.VERTICAL
|
||||
});
|
||||
hours_spin.connect('output', () => {
|
||||
const text = hours_spin.adjustment.value.toString().padStart(2, '0');
|
||||
hours_spin.set_text(text);
|
||||
return true;
|
||||
});
|
||||
hours_spin.connect('value-changed', () => {
|
||||
const old_time = settings.get_double(`schedule-${suntime}`);
|
||||
const old_hour = Math.trunc(old_time);
|
||||
const minutes = old_time - old_hour;
|
||||
const new_time = hours_spin.value + minutes;
|
||||
settings.set_double(`schedule-${suntime}`, new_time);
|
||||
});
|
||||
settings.connect('changed::manual-time-source', () => update_spin_sensitivity(hours_spin));
|
||||
settings.connect('changed::time-source', () => update_spin_sensitivity(hours_spin));
|
||||
update_spin_sensitivity(hours_spin);
|
||||
|
||||
const separator = new Gtk.Label({ label: ':' });
|
||||
|
||||
const minutes_spin = new Gtk.SpinButton({
|
||||
adjustment: new Gtk.Adjustment({
|
||||
value: minutes,
|
||||
lower: 0,
|
||||
upper: 59,
|
||||
step_increment: 1,
|
||||
page_increment: 0,
|
||||
page_size: 0
|
||||
}),
|
||||
value: minutes,
|
||||
numeric: true,
|
||||
wrap: true,
|
||||
orientation: Gtk.Orientation.VERTICAL
|
||||
});
|
||||
minutes_spin.connect('output', () => {
|
||||
const text = minutes_spin.adjustment.value.toString().padStart(2, '0');
|
||||
minutes_spin.set_text(text);
|
||||
return true;
|
||||
});
|
||||
minutes_spin.connect('value-changed', () => {
|
||||
const hour = Math.trunc(settings.get_double(`schedule-${suntime}`));
|
||||
const minutes = minutes_spin.value / 60;
|
||||
const new_time = hour + minutes;
|
||||
settings.set_double(`schedule-${suntime}`, new_time);
|
||||
});
|
||||
settings.connect('changed::manual-time-source', () => update_spin_sensitivity(minutes_spin));
|
||||
settings.connect('changed::time-source', () => update_spin_sensitivity(minutes_spin));
|
||||
update_spin_sensitivity(minutes_spin);
|
||||
|
||||
box.pack_start(hours_spin, false, false, 0);
|
||||
box.pack_start(separator, false, false, 0);
|
||||
box.pack_start(minutes_spin, false, false, 0);
|
||||
return box;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
Night Theme Switcher Gnome Shell extension
|
||||
|
||||
Copyright (C) 2020 Romain Vigier
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation, either version 3 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program. If not, see <http s ://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const { Gio, Gtk } = imports.gi;
|
||||
const { extensionUtils } = imports.misc;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases;
|
||||
const { get_installed_shell_themes } = Me.imports.utils;
|
||||
|
||||
const Gettext = imports.gettext.domain(Me.metadata.uuid);
|
||||
const _ = Gettext.gettext;
|
||||
|
||||
|
||||
const shell_minor_version = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]);
|
||||
if ( shell_minor_version <= 30 ) {
|
||||
extensionUtils.getSettings = Me.imports.convenience.getSettings;
|
||||
}
|
||||
|
||||
|
||||
var ShellThemePreferences = class {
|
||||
|
||||
constructor() {
|
||||
const label = _('Shell theme');
|
||||
const description = _('The extension will try to automatically detect the day and night variants of your GNOME Shell theme.\n\nIf the theme you use isn\'t supported, please <a href="https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension/-/issues">submit a request</a>. You can also manually set variants.');
|
||||
const content = new SettingsList();
|
||||
|
||||
content.add_row(new SettingsListRow(_('Manual variants'), new ManualShellVariantsControl()));
|
||||
content.add_row(new SettingsListRow(_('Day variant'), new TimeShellVariantControl('day')));
|
||||
content.add_row(new SettingsListRow(_('Night variant'), new TimeShellVariantControl('night')));
|
||||
|
||||
return new SettingsPage(label, description, content);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ManualShellVariantsControl {
|
||||
|
||||
constructor() {
|
||||
const settings = extensionUtils.getSettings();
|
||||
const toggle = new Gtk.Switch({
|
||||
active: false
|
||||
});
|
||||
settings.bind(
|
||||
'manual-shell-variants',
|
||||
toggle,
|
||||
'active',
|
||||
Gio.SettingsBindFlags.DEFAULT
|
||||
);
|
||||
return toggle;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class TimeShellVariantControl {
|
||||
|
||||
constructor(time) {
|
||||
const settings = extensionUtils.getSettings();
|
||||
const combo = new Gtk.ComboBoxText();
|
||||
const themes = Array.from(get_installed_shell_themes()).sort();
|
||||
themes.forEach(theme => combo.append(theme, (theme === '' ? _('Default') : theme)));
|
||||
settings.bind(
|
||||
`shell-variant-${time}`,
|
||||
combo,
|
||||
'active-id',
|
||||
Gio.SettingsBindFlags.DEFAULT
|
||||
);
|
||||
settings.bind(
|
||||
'manual-shell-variants',
|
||||
combo,
|
||||
'sensitive',
|
||||
Gio.SettingsBindFlags.DEFAULT
|
||||
);
|
||||
return combo;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
Night Theme Switcher Gnome Shell extension
|
||||
|
||||
Copyright (C) 2020 Romain Vigier
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation, either version 3 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program. If not, see <http s ://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const { Gtk } = imports.gi;
|
||||
|
||||
|
||||
var SettingsPage = class {
|
||||
|
||||
constructor(label, description, content_widget) {
|
||||
this.label = new Gtk.Label({
|
||||
label: label
|
||||
});
|
||||
|
||||
this.page = new Gtk.Box({
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
spacing: 30,
|
||||
margin_top: 30,
|
||||
margin_end: 36,
|
||||
margin_start: 36,
|
||||
margin_bottom: 36,
|
||||
valign: Gtk.Align.START,
|
||||
halign: Gtk.Align.CENTER
|
||||
});
|
||||
|
||||
const description_widget = new Gtk.Label({
|
||||
label: description,
|
||||
use_markup: true,
|
||||
wrap: true,
|
||||
halign: Gtk.Align.START
|
||||
});
|
||||
this.page.pack_start(description_widget, false, false, 0);
|
||||
|
||||
this.page.pack_start(content_widget, false, false, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var SettingsList = class {
|
||||
|
||||
constructor() {
|
||||
const frame = new Gtk.Frame({
|
||||
can_focus: false
|
||||
});
|
||||
|
||||
const list = new Gtk.ListBox({
|
||||
border_width: 0,
|
||||
margin: 0,
|
||||
can_focus: false,
|
||||
selection_mode: Gtk.SelectionMode.NONE
|
||||
});
|
||||
frame.add(list);
|
||||
|
||||
frame.add_row = (widget) => {
|
||||
if ( list.get_children().length > 0 ) {
|
||||
const separator = new Gtk.Separator({
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
can_focus: false
|
||||
});
|
||||
list.add(separator);
|
||||
}
|
||||
list.add(widget);
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var SettingsListRow = class {
|
||||
|
||||
constructor(label, widget) {
|
||||
const row = new Gtk.Box({
|
||||
margin: 16,
|
||||
spacing: 30,
|
||||
orientation: Gtk.Orientation.HORIZONTAL,
|
||||
can_focus: false
|
||||
});
|
||||
|
||||
const label_widget = new Gtk.Label({
|
||||
label: label,
|
||||
halign: Gtk.Align.START
|
||||
});
|
||||
row.pack_start(label_widget, true, true, 0);
|
||||
|
||||
widget.set_halign(Gtk.Align.END);
|
||||
row.pack_start(widget, false, false, 0);
|
||||
|
||||
return row;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user