|
| 1 | +/* |
| 2 | + Copyright © 2023 Aleksandr Mezin |
| 3 | +
|
| 4 | + This file is part of ddterm GNOME Shell extension. |
| 5 | +
|
| 6 | + This program is free software: you can redistribute it and/or modify |
| 7 | + it under the terms of the GNU General Public License as published by |
| 8 | + the Free Software Foundation, either version 3 of the License, or |
| 9 | + (at your option) any later version. |
| 10 | +
|
| 11 | + This program is distributed in the hope that it will be useful, |
| 12 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + GNU General Public License for more details. |
| 15 | +
|
| 16 | + You should have received a copy of the GNU General Public License |
| 17 | + along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 18 | +*/ |
| 19 | + |
| 20 | +'use strict'; |
| 21 | + |
| 22 | +const { GObject, Gtk } = imports.gi; |
| 23 | + |
| 24 | +var GtkThemeManager = GObject.registerClass( |
| 25 | + { |
| 26 | + Properties: { |
| 27 | + 'gtk-settings': GObject.ParamSpec.object( |
| 28 | + 'gtk-settings', |
| 29 | + '', |
| 30 | + '', |
| 31 | + GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT_ONLY, |
| 32 | + Gtk.Settings |
| 33 | + ), |
| 34 | + 'theme-variant': GObject.ParamSpec.string( |
| 35 | + 'theme-variant', |
| 36 | + '', |
| 37 | + '', |
| 38 | + GObject.ParamFlags.WRITABLE, |
| 39 | + null |
| 40 | + ), |
| 41 | + }, |
| 42 | + }, |
| 43 | + class DDTermGtkThemeManager extends GObject.Object { |
| 44 | + set theme_variant(value) { |
| 45 | + switch (value) { |
| 46 | + case 'system': |
| 47 | + this.gtk_settings.reset_property('gtk-application-prefer-dark-theme'); |
| 48 | + break; |
| 49 | + |
| 50 | + case 'dark': |
| 51 | + this.gtk_settings.gtk_application_prefer_dark_theme = true; |
| 52 | + break; |
| 53 | + |
| 54 | + case 'light': |
| 55 | + this.gtk_settings.gtk_application_prefer_dark_theme = false; |
| 56 | + break; |
| 57 | + |
| 58 | + default: |
| 59 | + printerr(`Unknown theme-variant: ${value}`); |
| 60 | + } |
| 61 | + } |
| 62 | + } |
| 63 | +); |
| 64 | + |
| 65 | +/* exported GtkThemeManager */ |
0 commit comments