Now About Social Code
aboutsummaryrefslogtreecommitdiff
path: root/src/window.py
diff options
context:
space:
mode:
authorLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2024-10-04 20:53:17 +0100
committerLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2024-10-04 20:53:17 +0100
commitbe71bf80d290c98c0f6a66d3dcab28515b4ea371 (patch)
treed936090c5b5c9435febfe220770ff7f25399a235 /src/window.py
Initial commit
Diffstat (limited to 'src/window.py')
-rw-r--r--src/window.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/window.py b/src/window.py
new file mode 100644
index 0000000..df63e36
--- /dev/null
+++ b/src/window.py
@@ -0,0 +1,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
+