blob: df63e366ef1c386b28f310abe27132cc2783e7d9 (
plain)
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
|
# window.py
#
# Copyright 2024 Lucas Fryzek
#
# 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 <https://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: GPL-3.0-or-later
from gi.repository import Adw
from gi.repository import Gtk
@Gtk.Template(resource_path='/com/fryzekconcepts/weegtk/window.ui')
class WeegtkWindow(Adw.ApplicationWindow):
__gtype_name__ = 'WeegtkWindow'
stack = Gtk.Template.Child()
content_page = Gtk.Template.Child()
color_scheme_button = Gtk.Template.Child()
split_view = Gtk.Template.Child()
def __init__(self, **kwargs):
super().__init__(**kwargs)
manager = Adw.StyleManager.get_default()
manager.connect("notify::system-supports-color-schemes",
self.notify_system_supports_color_schemes_cb,
self,
False)
self.notify_system_supports_color_schemes_cb()
self.notify_visible_child_cb()
def notify_system_supports_color_schemes_cb(self):
manager = Adw.StyleManager.get_default()
supports = manager.get_system_supports_color_schemes()
self.color_scheme_button.set_visible(not supports)
if supports:
manager.set_color_scheme(Adw.ColorScheme.DEFAULT)
@Gtk.Template.Callback()
def notify_visible_child_cb(self, *args):
child = self.stack.get_visible_child()
# When application starts up there are no buffers
if child is None:
return
page = self.stack.get_page(child)
self.content_page.set_title(page.get_title())
self.split_view.set_show_content(True)
@Gtk.Template.Callback()
def get_color_scheme_icon_name(self, user_data, dark):
return "light-mode-symbolic" if dark else "dark-mode-symbolic"
@Gtk.Template.Callback()
def color_scheme_button_clicked_cb(self, *args):
raise NotImplementedError
|