예제 #1
0
    def __init__(self, **options):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
        Tweak.__init__(
            self, _("Enable dark theme for all applications"),
            _("Enable the dark theme hint for all the applications in the session"
              ), **options)

        self._gtksettings = GtkSettingsManager()

        w = Gtk.Switch()
        w.set_active(
            self._gtksettings.get_integer("gtk-application-prefer-dark-theme"))

        title = _("Global Dark Theme")
        description = _(
            "Applications need to be restarted for change to take effect")
        w.connect("notify::active", self._on_switch_changed)

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        hbox.props.spacing = UI_BOX_SPACING
        lbl = Gtk.Label(label=title)
        lbl.props.ellipsize = Pango.EllipsizeMode.END
        lbl.props.xalign = 0.0
        hbox.pack_start(lbl, True, True, 0)
        hbox.pack_start(w, False, False, 0)

        lbl_des = Gtk.Label()
        lbl_des.props.xalign = 0.0
        lbl_des.set_markup("<span size='x-small'>" +
                           GLib.markup_escape_text(description) + "</span>")

        self.pack_start(hbox, False, False, 0)
        self.pack_start(lbl_des, False, False, 0)
        self.widget_for_size_group = None
예제 #2
0
    def __init__(self, **options):
        GSettingsComboTweak.__init__(
            self, _("Applications"), "org.gnome.desktop.interface",
            "gtk-theme",
            make_combo_list_with_default(self._get_valid_themes(),
                                         "Adwaita"), **options)

        self._gtksettings3 = GtkSettingsManager('3.0')
        self._gtksettings4 = GtkSettingsManager('4.0')
예제 #3
0
    def __init__(self, **options):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
        Tweak.__init__(self, _("Enable dark theme for all applications"),
                       _("Enable the dark theme hint for all the applications in the session"),
                       **options)

        self._gtksettings = GtkSettingsManager()

        w = Gtk.Switch()
        w.set_active(self._gtksettings.get_integer("gtk-application-prefer-dark-theme"))
		
        title = _("Global Dark Theme")
        description = _("Applications need to be restarted for change to take effect")
        w.connect("notify::active", self._on_switch_changed)
        
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        hbox.props.spacing = UI_BOX_SPACING
        lbl = Gtk.Label(label=title)
        lbl.props.ellipsize = Pango.EllipsizeMode.END
        lbl.props.xalign = 0.0
        hbox.pack_start(lbl, True, True, 0)
        hbox.pack_start(w, False, False, 0)
        
        lbl_des = Gtk.Label()
        lbl_des.props.xalign = 0.0
        lbl_des.set_markup("<span size='x-small'>"+description+"</span>")
        
        self.pack_start(hbox, False, False, 0)
        self.pack_start(lbl_des, False, False,0)
        self.widget_for_size_group = None
예제 #4
0
class GtkThemeSwitcher(GSettingsComboTweak):
    def __init__(self, **options):
        GSettingsComboTweak.__init__(
            self, _("Applications"), "org.gnome.desktop.interface",
            "gtk-theme",
            make_combo_list_with_default(self._get_valid_themes(),
                                         "Adwaita"), **options)

        self._gtksettings3 = GtkSettingsManager('3.0')
        self._gtksettings4 = GtkSettingsManager('4.0')

    def _get_valid_themes(self):
        """ Only shows themes that have variations for gtk3"""
        gtk_ver = Gtk.MINOR_VERSION
        if gtk_ver % 2:  # Want even number
            gtk_ver += 1

        valid = ['Adwaita', 'HighContrast', 'HighContrastInverse']
        valid += walk_directories(get_resource_dirs("themes"), lambda d:
                    os.path.exists(os.path.join(d, "gtk-3.0", "gtk.css")) or \
                         os.path.exists(os.path.join(d, "gtk-3.{}".format(gtk_ver))))
        return set(valid)

    def _on_combo_changed(self, combo):
        _iter = combo.get_active_iter()
        if _iter:
            value = combo.get_model().get_value(_iter, 0)
            self.settings.set_string(self.key_name, value)
        # Turn off Global Dark Theme when theme is changed.
        # https://bugzilla.gnome.org/783666
        try:
            self._gtksettings3.set_integer("gtk-application-prefer-dark-theme",
                                           0)
            self._gtksettings4.set_integer("gtk-application-prefer-dark-theme",
                                           0)
        except:
            self.notify_information(_("Error writing setting"))