mirror of
https://gitlab.gnome.org/jpu/cambalache.git
synced 2025-08-13 00:04:28 -04:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
8ce0ccf64b | ||
|
27f3054601 | ||
|
2b5cbff98c |
@ -27,7 +27,7 @@ import os
|
||||
import locale
|
||||
import tempfile
|
||||
|
||||
from gi.repository import GLib, GObject, Gio, Gdk, Gtk, Pango, Adw
|
||||
from gi.repository import GLib, GObject, Gio, Gdk, Gtk, Pango, Adw, GtkSource
|
||||
from .cmb_tutor import CmbTutor, CmbTutorState
|
||||
from . import cmb_tutorial
|
||||
|
||||
@ -120,6 +120,9 @@ class CmbWindow(Adw.ApplicationWindow):
|
||||
intro_button = Gtk.Template.Child()
|
||||
menu_button = Gtk.Template.Child()
|
||||
|
||||
# Properties
|
||||
source_style = GObject.Property(type=GtkSource.StyleScheme, flags=GObject.ParamFlags.READWRITE)
|
||||
|
||||
# Settings
|
||||
completed_intro = GObject.Property(type=bool, default=False, flags=GObject.ParamFlags.READWRITE)
|
||||
|
||||
@ -302,6 +305,10 @@ class CmbWindow(Adw.ApplicationWindow):
|
||||
self.__load_window_state()
|
||||
self.__update_actions()
|
||||
|
||||
self.source_style_manager = GtkSource.StyleSchemeManager.get_default()
|
||||
app.props.style_manager.connect("notify::dark", lambda o, p: self.__update_dark_mode(app.props.style_manager))
|
||||
self.__update_dark_mode(app.props.style_manager)
|
||||
|
||||
# Bind preview
|
||||
hide_placeholders_button = Gtk.ToggleButton(tooltip_text=_("Hide placeholders"), icon_name="view-conceal-symbolic")
|
||||
self.type_chooser.content.append(hide_placeholders_button)
|
||||
@ -472,6 +479,14 @@ class CmbWindow(Adw.ApplicationWindow):
|
||||
self.np_ui_entry.set_sensitive(sensitive)
|
||||
self.__update_action_new()
|
||||
|
||||
def __update_dark_mode(self, style_manager):
|
||||
if style_manager.props.dark:
|
||||
self.source_style = self.source_style_manager.get_scheme("Adwaita-dark")
|
||||
self.add_css_class("dark")
|
||||
else:
|
||||
self.remove_css_class("dark")
|
||||
self.source_style = self.source_style_manager.get_scheme("Adwaita")
|
||||
|
||||
def __np_name_to_ui(self, binding, value):
|
||||
if len(value):
|
||||
return value.lower().rsplit(".", 1)[0] + ".ui"
|
||||
|
@ -23,7 +23,7 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-only
|
||||
#
|
||||
|
||||
from gi.repository import GObject, GtkSource
|
||||
from gi.repository import GObject, Gtk, GtkSource
|
||||
|
||||
|
||||
class CmbSourceView(GtkSource.View):
|
||||
@ -38,6 +38,27 @@ class CmbSourceView(GtkSource.View):
|
||||
self.props.buffer = self.buffer
|
||||
self.buffer.connect("changed", self.__on_buffer_changed)
|
||||
|
||||
self.connect("notify::root", self.__on_parent_notify)
|
||||
self.__source_style_binding = None
|
||||
|
||||
def __on_parent_notify(self, obj, pspec):
|
||||
if self.__source_style_binding:
|
||||
self.__source_style_binding.unbind()
|
||||
self.__source_style_binding = None
|
||||
|
||||
root = self.props.root
|
||||
if root is None:
|
||||
return
|
||||
|
||||
if isinstance(root, Gtk.ApplicationWindow) and hasattr(root, "source_style"):
|
||||
self.__source_style_binding = GObject.Object.bind_property(
|
||||
root,
|
||||
"source-style",
|
||||
self.buffer,
|
||||
"style-scheme",
|
||||
GObject.BindingFlags.SYNC_CREATE,
|
||||
)
|
||||
|
||||
@GObject.Property(type=str)
|
||||
def lang(self):
|
||||
language = self.buffer.get_language()
|
||||
|
Loading…
x
Reference in New Issue
Block a user