class ShowWindowButtons(GSettingsSwitchTweakValue):

    def __init__(self, name, value, **options):
        self.value = value
        self._xsettings = XSettingsOverrides()
        GSettingsSwitchTweakValue.__init__(self,
                                           name,
                                           "org.gnome.desktop.wm.preferences",
                                           "button-layout",
                                           loaded=_shell_loaded,
                                           **options)
    def get_active(self):
        return self.value in self.settings.get_string(self.key_name)
            
    def set_active(self, v):
        val = self.settings.get_string(self.key_name)
        if v:
            if val == ":close":
                val = val.replace(":", ":"+self.value+",")
            else:
                val = ":minimize,maximize,close"
        else:
            val = val.replace(self.value+",", "")

        self.settings.set_string(self.key_name, val)
        self._xsettings.set_window_buttons(val.replace(":", "menu:"))
class ApplicationMenuTweak(GetterSetterSwitchTweak):
    def __init__(self, **options):
        self._xsettings = XSettingsOverrides()
        GetterSetterSwitchTweak.__init__(self, _("Show Application Menu"), **options)

    def get_active(self):
        return self._xsettings.get_shell_shows_app_menu()

    def set_active(self, v):
        self._xsettings.set_shell_shows_app_menu(v)
class PrimaryPasteTweak(GetterSetterSwitchTweak):
    def __init__(self, **options):
        self._xsettings = XSettingsOverrides()
        GetterSetterSwitchTweak.__init__(self, _("Middle-click Paste"), **options)

    def get_active(self):
        return self._xsettings.get_enable_primary_paste()

    def set_active(self, v):
        self._xsettings.set_enable_primary_paste(v)
Exemple #4
0
class ApplicationMenuTweak(GetterSetterSwitchTweak):
    def __init__(self, **options):
        self._xsettings = XSettingsOverrides()
        name = _("Application Menu")
        GetterSetterSwitchTweak.__init__(self, name, **options)

        _GSettingsTweak.__init__(self,
                                 name,
                                 "org.gnome.desktop.wm.preferences",
                                 "button-layout",
                                 loaded=_shell_loaded,
                                 **options)

    def get_active(self):
        return self._xsettings.get_shell_shows_app_menu()

    def set_active(self, v):
        self._xsettings.set_shell_shows_app_menu(v)

        if v:
            self.notify_logout()
            return
        val = self.settings.get_string(self.key_name)
        if "appmenu" in val:
            self.notify_logout()
            return
        else:
            (left, colon, right) = val.partition(":")

            if "close" in right:
                rsplit = right.split(",")
                rsplit = [
                    x for x in rsplit
                    if x in ["minimize", "maximize", "close"]
                ]
                rsplit.append("appmenu")
                rsplit.sort(
                    key=lambda x: ["appmenu", "minimize", "maximize", "close"
                                   ].index(x))
                self.settings.set_string(self.key_name,
                                         left + colon + ",".join(rsplit))

            else:
                rsplit = left.split(",")
                rsplit = [
                    x for x in rsplit
                    if x in ["minimize", "maximize", "close"]
                ]
                rsplit.append("appmenu")
                rsplit.sort(
                    key=lambda x: ["close", "minimize", "maximize", "appmenu"
                                   ].index(x))
                self.settings.set_string(self.key_name,
                                         ",".join(rsplit) + colon + right)
        self.notify_logout()
class PrimaryPasteTweak(GetterSetterSwitchTweak):
    def __init__(self, **options):
        self._xsettings = XSettingsOverrides()
        GetterSetterSwitchTweak.__init__(self, _("Middle-click Paste"),
                                         **options)

    def get_active(self):
        return self._xsettings.get_enable_primary_paste()

    def set_active(self, v):
        self._xsettings.set_enable_primary_paste(v)
Exemple #6
0
    def __init__(self, **options):
        self._xsettings = XSettingsOverrides()
        name = _("Application Menu")
        GetterSetterSwitchTweak.__init__(self, name, **options)

        _GSettingsTweak.__init__(self,
                                 name,
                                 "org.gnome.desktop.wm.preferences",
                                 "button-layout",
                                 loaded=_shell_loaded,
                                 **options)
    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()
        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()
        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 __init__(self, name, value, **options):
     self.value = value
     self._xsettings = XSettingsOverrides()
     GSettingsSwitchTweakValue.__init__(self,
                                        name,
                                        "org.gnome.desktop.wm.preferences",
                                        "button-layout",
                                        loaded=_shell_loaded,
                                        **options)
Exemple #9
0
    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()
        self._original_factor = self._xsettings.get_window_scaling_factor()

        w = Gtk.SpinButton.new_with_range(1, 2, 1)
        w.set_numeric(True)
        w.set_digits(0)
        w.set_update_policy(Gtk.SpinButtonUpdatePolicy.IF_VALID)
        w.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
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())
 def __init__(self, **options):
     self._xsettings = XSettingsOverrides()
     GetterSetterSwitchTweak.__init__(self, _("Show Application Menu"), **options)
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()
        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()
        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 _timeout_func (self):
        self._countdown -= 1

        if self._countdown == 0:
            self._source = 0
            self._dialog.response(Gtk.ResponseType.NO)
            return False

        self._update_countdown_message()
        self._dialog.format_secondary_text(self._second_message % self._countdown)
        return True

    def _update_countdown_message(self):
        self._second_message = gettext.ngettext("Settings will be reverted in %d second",
                                                "Settings will be reverted in %d seconds",
                                                self._countdown)

    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._update_countdown_message()

        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()
 def __init__(self, **options):
     self._xsettings = XSettingsOverrides()
     GetterSetterSwitchTweak.__init__(self, _("Middle-click Paste"),
                                      **options)
 def __init__(self, **options):
     self._xsettings = XSettingsOverrides()
     GetterSetterSwitchTweak.__init__(self, _("Middle-click Paste"), **options)