[gnome-tweak-tool] tweakview: Update decorations on settings changes
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tweak-tool] tweakview: Update decorations on settings changes
- Date: Mon, 29 Sep 2014 13:51:47 +0000 (UTC)
commit 4c976788ab9bbd3911c95e2091a203eddac1c9cd
Author: Florian Müllner <fmuellner gnome org>
Date: Sun Sep 28 17:21:21 2014 +0200
tweakview: Update decorations on settings changes
It is a bit ironic that Tweak Tool allows users to tweak the
titlebar decorations, but ignores the setting (at least until
a restart). So listen for change notifications and update
decorations accordingly.
https://bugzilla.gnome.org/show_bug.cgi?id=737531
gtweak/tweakview.py | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/gtweak/tweakview.py b/gtweak/tweakview.py
index cc0b914..ee432f5 100644
--- a/gtweak/tweakview.py
+++ b/gtweak/tweakview.py
@@ -55,6 +55,9 @@ class Window(Gtk.ApplicationWindow):
self._model.load_tweaks(self)
self.load_model_data()
+ Gtk.Settings.get_default().connect("notify::gtk-decoration-layout",
+ self._update_decorations);
+
self.connect("key-press-event", self._on_key_press)
self.add(main_box)
@@ -67,16 +70,15 @@ class Window(Gtk.ApplicationWindow):
right_header = Gtk.HeaderBar()
right_header.props.show_close_button = True
+ self._left_header = left_header;
+ self._right_header = right_header;
+
left_header.get_style_context().add_class("titlebar")
left_header.get_style_context().add_class("tweak-titlebar-left")
right_header.get_style_context().add_class("titlebar")
right_header.get_style_context().add_class("tweak-titlebar-right")
- layout_desc = Gtk.Settings.get_default().props.gtk_decoration_layout;
- tokens = layout_desc.split(":", 2)
- if tokens != None:
- right_header.props.decoration_layout = ":" + tokens[1]
- left_header.props.decoration_layout = tokens[0]
+ self._update_decorations (Gtk.Settings.get_default(), None)
self.title = Gtk.Label(label="")
self.title.get_style_context().add_class("title")
@@ -187,6 +189,13 @@ class Window(Gtk.ApplicationWindow):
if before and not row.get_header():
row.set_header (Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL))
+ def _update_decorations(self, settings, pspec):
+ layout_desc = settings.props.gtk_decoration_layout;
+ tokens = layout_desc.split(":", 2)
+ if tokens != None:
+ self._right_header.props.decoration_layout = ":" + tokens[1]
+ self._left_header.props.decoration_layout = tokens[0]
+
def _on_key_press(self, widget, event):
keyname = Gdk.keyval_name(event.keyval)
if keyname == 'Escape':
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]