[gnome-tweak-tool] add tweak for Gdk/WindowScalingFactor



commit 7137fb3c9e0dd89bf1b701ceced01fe56e474b54
Author: John Stowers <john stowers gmail com>
Date:   Wed Mar 26 21:02:44 2014 +0100

    add tweak for Gdk/WindowScalingFactor

 gtweak/tweaks/tweak_group_windows.py |   28 ++++++++++++++++++++++++++--
 gtweak/utils.py                      |    5 +++++
 2 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/gtweak/tweaks/tweak_group_windows.py b/gtweak/tweaks/tweak_group_windows.py
index 2cab254..f410117 100644
--- a/gtweak/tweaks/tweak_group_windows.py
+++ b/gtweak/tweaks/tweak_group_windows.py
@@ -17,10 +17,12 @@
 
 import gtweak
 from gtweak.gshellwrapper import GnomeShellFactory
-from gtweak.tweakmodel import TWEAK_GROUP_WINDOWS
-from gtweak.widgets import ListBoxTweakGroup, GSettingsComboEnumTweak, GSettingsComboTweak, 
GSettingsSwitchTweak, Title, GSettingsSwitchTweakValue
+from gtweak.tweakmodel import TWEAK_GROUP_WINDOWS, Tweak
+from gtweak.widgets import ListBoxTweakGroup, GSettingsComboEnumTweak, GSettingsComboTweak, 
GSettingsSwitchTweak, Title, GSettingsSwitchTweakValue, build_label_beside_widget
 from gtweak.utils import XSettingsOverrides
 
+from gi.repository import Gtk
+
 _shell = GnomeShellFactory().get_shell()
 _shell_loaded = _shell is not None
             
@@ -51,6 +53,26 @@ class ShowWindowButtons(GSettingsSwitchTweakValue):
         self.settings.set_string(self.key_name, val)
         self._xsettings.set_window_buttons(val.replace(":", "menu:"))
 
+class WindowScalingFactorTweak(Gtk.Box, Tweak):
+    def __init__(self, **options):
+        Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
+        Tweak.__init__(self, _("Window scaling"), _("Adjust GDK window scaling factor for HiDPI"), **options)
+
+        self._xsettings = XSettingsOverrides()
+
+        adjustment = Gtk.Adjustment(lower=1, upper=2, step_increment=1, page_increment=1)
+        w = Gtk.SpinButton()
+        w.set_adjustment(adjustment)
+        w.set_digits(0)
+        adjustment.set_value(self._xsettings.get_window_scaling_factor())
+        w.connect("value-changed", self._on_value_changed)
+
+        build_label_beside_widget(self.name, w, hbox=self)
+        self.widget_for_size_group = w
+
+    def _on_value_changed(self, adj):
+        self._xsettings.set_window_scaling_factor(adj.get_value())
+
 TWEAK_GROUPS = [ 
     ListBoxTweakGroup(TWEAK_GROUP_WINDOWS,
         GSettingsSwitchTweak(_("Attached Modal Dialogs"),"org.gnome.mutter", "attach-modal-dialogs"),
@@ -68,6 +90,8 @@ TWEAK_GROUPS = [
         Title(_("Titlebar Buttons"), "", uid="title-theme"),
         ShowWindowButtons(_("Maximize"), "maximize"),
         ShowWindowButtons(_("Minimize"), "minimize"),
+        Title(_("HiDPI"), "", uid="title-hidpi"),
+        WindowScalingFactorTweak(),
     )
 ]
 
diff --git a/gtweak/utils.py b/gtweak/utils.py
index e18b650..1384afb 100644
--- a/gtweak/utils.py
+++ b/gtweak/utils.py
@@ -236,6 +236,7 @@ class XSettingsOverrides:
         'Gtk/ShellShowsAppMenu': GLib.Variant.new_int32,
         'Gtk/EnablePrimaryPaste': GLib.Variant.new_int32,
         'Gtk/DecorationLayout': GLib.Variant.new_string,
+        'Gdk/WindowScalingFactor': GLib.Variant.new_int32,
     }
 
     def __init__(self):
@@ -282,6 +283,10 @@ class XSettingsOverrides:
         return self._get_override('Gtk/EnablePrimaryPaste', True)
     def set_window_buttons(self, v):
         self._set_override('Gtk/DecorationLayout', v)
+    def set_window_scaling_factor(self, v):
+        self._set_override('Gdk/WindowScalingFactor', int(v))
+    def get_window_scaling_factor(self):
+        return self._get_override('Gdk/WindowScalingFactor', 1)
 
 class Notification:
     def __init__(self, summary, body):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]