[gnome-tweak-tool] Add a confirmation message when changing HiDPI
- From: Gian Mario Tagliaretti <gianmt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tweak-tool] Add a confirmation message when changing HiDPI
- Date: Tue, 30 Dec 2014 09:07:45 +0000 (UTC)
commit cdac8bfc475cd1752fc02024d5466724cb01f0e5
Author: Gian Mario Tagliaretti <gianmt gnome org>
Date: Tue Sep 30 21:38:48 2014 +0200
Add a confirmation message when changing HiDPI
Add a confirmation message that will revert changes after 20 seconds
if the user does not make a choice (keep or revert).
Bug https://bugzilla.gnome.org/show_bug.cgi?id=727675
gtweak/tweaks/tweak_group_windows.py | 47 +++++++++++++++++++++++++++++++++-
1 files changed, 46 insertions(+), 1 deletions(-)
---
diff --git a/gtweak/tweaks/tweak_group_windows.py b/gtweak/tweaks/tweak_group_windows.py
index bea8208..eb94a09 100644
--- a/gtweak/tweaks/tweak_group_windows.py
+++ b/gtweak/tweaks/tweak_group_windows.py
@@ -21,7 +21,7 @@ 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
+from gi.repository import Gtk, GLib
_shell = GnomeShellFactory().get_shell()
_shell_loaded = _shell is not None
@@ -57,6 +57,7 @@ class WindowScalingFactorTweak(Gtk.Box, Tweak):
Tweak.__init__(self, _("Window scaling"), _("Adjust GDK window scaling factor for HiDPI"), **options)
self._xsettings = XSettingsOverrides()
+ self._original_factor = self._xsettings.get_window_scaling_factor()
adjustment = Gtk.Adjustment(lower=1, upper=2, step_increment=1, page_increment=1)
w = Gtk.SpinButton()
@@ -68,8 +69,52 @@ class WindowScalingFactorTweak(Gtk.Box, Tweak):
build_label_beside_widget(self.name, w, hbox=self)
self.widget_for_size_group = w
+ def _timeout_func (self):
+ self._countdown -= 1
+
+ if self._countdown == 0:
+ self._source = 0
+ self._dialog.response(Gtk.ResponseType.NO)
+ return False
+
+ self._dialog.format_secondary_text(self._second_message % self._countdown)
+ return True
+
+ def _close(self):
+ if self._source > 0:
+ GLib.Source.remove(self._source)
+ self._source = 0
+
def _on_value_changed(self, adj):
+ if adj.get_value() == self._original_factor:
+ return
+
self._xsettings.set_window_scaling_factor(adj.get_value())
+ self._countdown = 20
+
+ first_message = _("Do you want to keep these HiDPI settings?")
+ self._second_message = _("Settings will be reverted in %d seconds")
+
+ self._dialog = Gtk.MessageDialog(
+ transient_for=self.main_window,
+ message_type=Gtk.MessageType.QUESTION,
+ text=first_message)
+ self._dialog.add_buttons(_("Revert Settings"), Gtk.ResponseType.NO,
+ _("Keep Changes"), Gtk.ResponseType.YES)
+ self._dialog.format_secondary_text(self._second_message % self._countdown)
+
+ self._source = GLib.timeout_add_seconds(interval=1, function=self._timeout_func)
+
+ response = self._dialog.run()
+
+ if response == Gtk.ResponseType.YES:
+ self._original_factor = self._xsettings.get_window_scaling_factor()
+ else:
+ self._xsettings.set_window_scaling_factor(self._original_factor)
+ adj.set_value(self._original_factor)
+
+ self._close()
+ self._dialog.destroy()
TWEAK_GROUPS = [
ListBoxTweakGroup(TWEAK_GROUP_WINDOWS,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]