示例#1
0
    def __init__(self, df, **options):

        Gtk.ListBoxRow.__init__(self)
        Tweak.__init__(self, df.get_name(), df.get_description(), **options)

        grid = Gtk.Grid(column_spacing=10)

        icn = df.get_icon()
        if icn:
            img = _image_from_gicon(icn)
            grid.attach(img, 0, 0, 1, 1)
        else:
            img = None  #attach_next_to treats this correctly

        lbl = Gtk.Label(label=df.get_name(), xalign=0.0)
        grid.attach_next_to(lbl, img, Gtk.PositionType.RIGHT, 1, 1)
        lbl.props.hexpand = True
        lbl.props.halign = Gtk.Align.START

        btn = Gtk.Button(label=_("Remove"))
        grid.attach_next_to(btn, lbl, Gtk.PositionType.RIGHT, 1, 1)
        btn.props.vexpand = False
        btn.props.valign = Gtk.Align.CENTER

        self.add(grid)

        self.props.margin_start = 1
        self.props.margin_end = 1
        self.get_style_context().add_class('tweak-startup')

        self.btn = btn
        self.app_id = df.get_id()
        self.connect("key-press-event", self._on_key_press_event)
 def __init__(self, name, desc, **options):
     Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
     Tweak.__init__(self, name, desc, **options)
     widget = Gtk.Label()
     widget.set_markup("<b>"+name+"</b>")
     widget.props.xalign = 0.0
     self.add(widget)
示例#3
0
 def __init__(self, name, desc, **options):
     Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
     Tweak.__init__(self, name, desc, **options)
     widget = Gtk.Label()
     widget.set_markup("<b>" + GLib.markup_escape_text(name) + "</b>")
     widget.props.xalign = 0.0
     self.add(widget)
    def __init__(self, df, **options):

        Gtk.ListBoxRow.__init__(self)
        Tweak.__init__(self, 
                        df.get_name(),
                        df.get_description(),
                        **options)
        
        grid = Gtk.Grid(column_spacing=10)

        icn = df.get_icon()
        if icn:
            img = Gtk.Image.new_from_gicon(icn,Gtk.IconSize.DIALOG)
            grid.attach(img, 0, 0, 1, 1)
        else:
            img = None #attach_next_to treats this correctly

        lbl = Gtk.Label(df.get_name(), xalign=0.0)
        grid.attach_next_to(lbl,img,Gtk.PositionType.RIGHT,1,1)
        lbl.props.hexpand = True
        lbl.props.halign = Gtk.Align.START

        btn = Gtk.Button(_("Remove"))
        grid.attach_next_to(btn,lbl,Gtk.PositionType.RIGHT,1,1)
        btn.props.vexpand = False
        btn.props.valign = Gtk.Align.CENTER

        self.add(grid)

        self.props.margin = 5
        self.get_style_context().add_class('tweak-white')

        self.btn = btn
示例#5
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
    def __init__(self, group_id, parent_settings, xkb_info, **options):
        try:
            desc = xkb_info.description_for_group(group_id)
        except AttributeError:
            desc = group_id
        Gtk.Expander.__init__(self)
        Tweak.__init__(self, desc, desc, **options)

        self.set_label(self.name)
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=3)
        vbox.set_margin_start(15)
        self.add(vbox)

        self._multiple_selection = not group_id in { 'keypad', 'kpdl', 'caps', 'altwin', 'nbsp', 'esperanto' }
        self._group_id = group_id
        self._parent_settings = parent_settings
        self._xkb_info = xkb_info
        self._possible_values = []

        model_values = []
        if not self._multiple_selection:
            model_values.append((None, _("Disabled")))

        for option_id in self._xkb_info.get_options_for_group(group_id):
            desc = self._xkb_info.description_for_option(group_id, option_id)
            model_values.append((option_id, desc))
            self._possible_values.append(option_id)

        def values_cmp((av, ad), (bv, bd)):
            if not av:
                return -1
            elif not bv:
                return 1
            else:
                return cmp(ad, bd)
示例#7
0
    def __init__(self):
        Gtk.Box.__init__(self,
                         orientation=Gtk.Orientation.VERTICAL,
                         spacing=18,
                         valign=Gtk.Align.CENTER)
        Tweak.__init__(self, 'extensions', '')

        self.add(
            Gtk.Image(icon_name="org.gnome.tweaks-symbolic",
                      pixel_size=128,
                      opacity=0.3))

        self.add(
            Gtk.Label(label="<b>" + _("No Extensions Installed") + "</b>",
                      use_markup=True,
                      opacity=0.3))

        try:
            self._swInfo = Gio.DesktopAppInfo.new("org.gnome.Software.desktop")

            if self._swInfo:
                btn = Gtk.Button(
                    label=_("Browse in Software"),
                    always_show_image=True,
                    halign=Gtk.Align.CENTER,
                    image=Gtk.Image(icon_name="org.gnome.Software-symbolic"))
                btn.connect("clicked", self._on_browse_clicked)
                self.add(btn)

        except:
            logging.warning("Error detecting shell", exc_info=True)

        self.show_all()
    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
    def __init__(self, shell, ext, **options):
        Tweak.__init__(self, ext["name"], ext.get("description",""), **options)

        self._shell = shell
        state = ext.get("state")

        sw = Gtk.Switch()
        sw.set_active(self._shell.extension_is_active(state, ext["uuid"]))
        sw.connect('notify::active', self._on_extension_toggled, ext["uuid"])

        info = None
        warning = None
        sensitive = False
        if state == GnomeShell.EXTENSION_STATE["ENABLED"] or \
           state == GnomeShell.EXTENSION_STATE["DISABLED"] or \
           state == GnomeShell.EXTENSION_STATE["INITIALIZED"]:
            sensitive = True
        elif state == GnomeShell.EXTENSION_STATE["DOWNLOADING"]:
            info = _("Extension downloading")
        elif state == GnomeShell.EXTENSION_STATE["ERROR"]:
            warning = _("Error loading extension")
        elif state == GnomeShell.EXTENSION_STATE["OUT_OF_DATE"]:
            warning = _("Extension does not support shell version")
        else:
            warning = _("Unknown extension error")
            logging.critical(warning)
        sw.set_sensitive(sensitive)

        self.widget = build_label_beside_widget(
                        _("%s Extension") % ext["name"],
                        sw,
                        warning=warning)
        self.widget_for_size_group = sw
示例#10
0
    def __init__(self, **options):
        Tweak.__init__(self, "Shell theme", "Install custom or user themes for gnome-shell", **options)

        #check the shell is running and the usertheme extension is present
        error = "Unknown"
        try:
            self._shell = GnomeShell()
        except:
            error = "Shell not running"
        try:
            extensions = self._shell.list_extensions()
            if ThemeInstaller.THEME_EXT_NAME in extensions and extensions[ThemeInstaller.THEME_EXT_NAME]["state"] == 1:
                #check the correct gsettings key is present
                try:
                    self._settings = GSettingsSetting(ThemeInstaller.THEME_GSETTINGS_SCHEMA)
                    name = self._settings.get_value(ThemeInstaller.THEME_GSETTINGS_NAME)
                    print "!!!!", name
                    error = None
                except:
                    error = "User Theme extension schema missing"

            else:
                error = "User Theme extension not enabled"
        except Exception, e:
            error = "Could not list shell extensions"
示例#11
0
    def __init__(self, **options):
        Tweak.__init__(self, "Shell theme", "Install custom or user themes for gnome-shell", **options)

        #check the shell is running and the usertheme extension is present
        error = _("Unknown error")
        try:
            self._shell = GnomeShellFactory().get_shell()
        except:
            logging.warning("Shell not running", exc_info=True)
            error = _("Shell not running")
        try:
            extensions = self._shell.list_extensions()
            if ShellThemeTweak.THEME_EXT_NAME in extensions and extensions[ShellThemeTweak.THEME_EXT_NAME]["state"] == 1:
                #check the correct gsettings key is present
                try:
                    self._settings = GSettingsSetting(ShellThemeTweak.THEME_GSETTINGS_SCHEMA)
                    name = self._settings.get_string(ShellThemeTweak.THEME_GSETTINGS_NAME)

                    ext = extensions[ShellThemeTweak.THEME_EXT_NAME]
                    logging.debug("Shell user-theme extension\n%s" % pprint.pformat(ext))

                    error = None
                except:
                    logging.warning(
                        "Could not find user-theme extension in %s" % ','.join(extensions.keys()),
                        exc_info=True)
                    error = _("Shell user-theme extension incorrectly installed")

            else:
                error = _("Shell user-theme extension not enabled")
        except Exception, e:
            logging.warning("Could not list shell extensions", exc_info=True)
            error = _("Could not list shell extensions")
示例#12
0
 def __init__(self, name, description, **options):
     Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
     Tweak.__init__(self, name, description, **options)
     widget = Gtk.Button(name)
     widget.connect("clicked", self._on_click)
     self.add(widget)
     self._need_action = options.get("_need_action")
     self._need_logout = options.get("_need_logout")
示例#13
0
    def __init__(self, name, description, **options):
        Tweak.__init__(self, name, description, **options)

        self.widget = build_label_beside_widget(
                        name,
                        Gtk.Button(options.get("test_button_name",name)),
                        info=options.get("tweak_info"),
                        warning=options.get("tweak_warning"))
 def __init__(self, name, description, **options):
     Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
     Tweak.__init__(self, name, description, **options)
     widget = Gtk.Button(name)
     widget.connect("clicked", self._on_click)
     self.add(widget)
     self._need_action = options.get("_need_action")
     self._need_logout = options.get("_need_logout")
示例#15
0
 def __init__(self, schema_name, key_name, **options):
     self.schema_name = schema_name
     self.key_name = key_name
     self.settings = GSettingsSetting(schema_name, **options)
     Tweak.__init__(self,
         self.settings.schema_get_summary(key_name),
         self.settings.schema_get_description(key_name),
         **options)
示例#16
0
    def __init__(self, name, **options):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
        Tweak.__init__(self, name, options.get("description",""), **options)

        sw = Gtk.Switch()
        sw.set_active(self.get_active())
        sw.connect("notify::active", self._on_toggled)

        build_label_beside_widget(name, sw, hbox=self)
示例#17
0
    def __init__(self, name, **options):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
        Tweak.__init__(self, name, options.get("description", ""), **options)

        sw = Gtk.Switch()
        sw.set_active(self.get_active())
        sw.connect("notify::active", self._on_toggled)

        build_label_beside_widget(name, sw, hbox=self)
示例#18
0
    def __init__(self, name, description, **options):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
        Tweak.__init__(self, name, description, **options)

        build_label_beside_widget(
                        name,
                        Gtk.Button(options.get("_test_button_name",name)),
                        info=options.get("_tweak_info"),
                        warning=options.get("_tweak_warning"),
                        hbox=self)
    def __init__(self, name, description, **options):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
        Tweak.__init__(self, name, description, **options)

        build_label_beside_widget(
                        name,
                        Gtk.Button(options.get("_test_button_name",name)),
                        info=options.get("_tweak_info"),
                        warning=options.get("_tweak_warning"),
                        hbox=self)
    def __init__(self, shell, **options):
        Tweak.__init__(self, _("Install Shell Extension"), "", **options)

        self._shell = shell

        chooser = ZipFileChooserButton(_("Select an extension"))
        chooser.connect("file-set", self._on_file_set)

        self.widget = build_label_beside_widget(self.name, chooser)
        self.widget_for_size_group = chooser
示例#21
0
    def __init__(self, **options):
        Gtk.Box.__init__(self)
        desc = _(
            "Startup applications are automatically started when you log in.")
        Tweak.__init__(self, _("Startup Applications"), desc, **options)

        label = Gtk.Label(desc)
        label.get_style_context().add_class("dim-label")
        self.props.margin_bottom = 10
        self.add(label)
示例#22
0
    def __init__(self, **options):
        Gtk.ListBoxRow.__init__(self)
        Tweak.__init__(self, _("New startup application"),
                       _("Add a new application to be run at startup"),
                       **options)

        img = Gtk.Image()
        img.set_from_icon_name("list-add-symbolic", Gtk.IconSize.BUTTON)
        self.btn = Gtk.Button(label="", image=img, always_show_image=True)
        self.btn.get_style_context().remove_class("button")
        self.add(self.btn)
        self.get_style_context().add_class('tweak-startup')
示例#23
0
 def __init__(self, schema_name, key_name, **options):
     self.schema_name = schema_name
     self.key_name = key_name
     try:
         self.settings = GSettingsSetting(schema_name, **options)
         Tweak.__init__(self,
             options.get("summary",self.settings.schema_get_summary(key_name)),
             options.get("description",self.settings.schema_get_description(key_name)),
             **options)
     except GSettingsMissingError, e:
         self.settings = GSettingsFakeSetting()
         Tweak.__init__(self,"","")
         self.loaded = False
         logging.info("Missing gsettings %s (key %s)" % (e.message, key_name))
示例#24
0
    def __init__(self, **options):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
        Tweak.__init__(self, _("Shell theme"),
                       _("Install custom or user themes for gnome-shell"),
                       **options)

        #check the shell is running and the usertheme extension is present
        error = _("Unknown error")
        self._shell = _shell

        if self._shell is None:
            logging.warning("Shell not running", exc_info=True)
            error = _("Shell not running")
        else:
            try:
                extensions = self._shell.list_extensions()
                if ShellThemeTweak.THEME_EXT_NAME in extensions and extensions[
                        ShellThemeTweak.THEME_EXT_NAME]["state"] == 1:
                    #check the correct gsettings key is present
                    try:
                        if os.path.exists(ShellThemeTweak.THEME_GSETTINGS_DIR):
                            self._settings = GSettingsSetting(
                                ShellThemeTweak.THEME_GSETTINGS_SCHEMA,
                                schema_dir=ShellThemeTweak.THEME_GSETTINGS_DIR)
                        else:
                            self._settings = GSettingsSetting(
                                ShellThemeTweak.THEME_GSETTINGS_SCHEMA)
                        name = self._settings.get_string(
                            ShellThemeTweak.THEME_GSETTINGS_NAME)

                        ext = extensions[ShellThemeTweak.THEME_EXT_NAME]
                        logging.debug("Shell user-theme extension\n%s" %
                                      pprint.pformat(ext))

                        error = None
                    except:
                        logging.warning(
                            "Could not find user-theme extension in %s" %
                            ','.join(extensions.keys()),
                            exc_info=True)
                        error = _(
                            "Shell user-theme extension incorrectly installed")

                else:
                    error = _("Shell user-theme extension not enabled")
            except Exception, e:
                logging.warning("Could not list shell extensions",
                                exc_info=True)
                error = _("Could not list shell extensions")
    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
示例#26
0
class _GSettingsTweak(Tweak):
    def __init__(self, name, schema_name, key_name, **options):
        schema_name = adjust_schema_for_overrides(schema_name, key_name,
                                                  options)
        self.schema_name = schema_name
        self.key_name = key_name
        self._extra_info = None
        if 'uid' not in options:
            options['uid'] = key_name
        try:
            self.settings = GSettingsSetting(schema_name, **options)
            Tweak.__init__(
                self, name,
                options.get("description",
                            self.settings.schema_get_description(key_name)),
                **options)
        except GSettingsMissingError, e:
            self.settings = GSettingsFakeSetting()
            Tweak.__init__(self, "", "")
            self.loaded = False
            logging.info("GSetting missing %s" % (e.message))
        except KeyError:
            self.settings = GSettingsFakeSetting()
            Tweak.__init__(self, "", "")
            self.loaded = False
            logging.info("GSettings missing key %s (key %s)" %
                         (schema_name, key_name))
    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
示例#28
0
 def __init__(self, name, schema_name, key_name, **options):
     schema_name = adjust_schema_for_overrides(schema_name, key_name, options)
     self.schema_name = schema_name
     self.key_name = key_name
     self._extra_info = None
     if 'uid' not in options:
         options['uid'] = key_name
     try:
         self.settings = GSettingsSetting(schema_name, **options)
         Tweak.__init__(self,
             name,
             options.get("description",self.settings.schema_get_description(key_name)),
             **options)
     except GSettingsMissingError, e:
         self.settings = GSettingsFakeSetting()
         Tweak.__init__(self,"","")
         self.loaded = False
         logging.info("GSetting missing %s" % (e.message))
示例#29
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
    def __init__(self, shell, **options):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
        Tweak.__init__(self, _("Install Shell Extension"), "", **options)

        self._shell = shell

        chooser = FileChooserButton(_("Select an extension"), True,
                                    ["application/zip"])
        chooser.connect("file-set", self._on_file_set)

        hb = Gtk.HBox(spacing=UI_BOX_SPACING)
        hb.pack_start(
            Gtk.LinkButton.new_with_label("https://extensions.gnome.org",
                                          _("Get more extensions")), False,
            False, 0)
        hb.pack_start(chooser, False, False, 0)

        build_label_beside_widget(self.name, hb, hbox=self)
        self.widget_for_size_group = hb

        self.loaded = self._shell is not None
示例#31
0
    def __init__(self, name, schema_name, key_name, **options):
        self.schema_name = schema_name
        self.key_name = key_name
        self._extra_info = None
        if 'uid' not in options:
            options['uid'] = key_name
        try:
            self.settings = GSettingsSetting(schema_name, **options)
            Tweak.__init__(self,
                name,
                options.get("description",self.settings.schema_get_description(key_name)),
                **options)
        except GSettingsMissingError as e:
            self.settings = GSettingsFakeSetting()
            Tweak.__init__(self, "", "")
            self.loaded = False
            logging.info("GSetting missing %s", e)
        except KeyError:
            self.settings = GSettingsFakeSetting()
            Tweak.__init__(self, "", "")
            self.loaded = False
            logging.info("GSettings missing key %s (key %s)" % (schema_name, key_name))

        if options.get("logout_required") and self.loaded:
            self.settings.connect("changed::%s" % key_name, self._on_changed_notify_logout)
    def __init__(self, **options):
        Tweak.__init__(self, "Dynamic workspaces", "Disable gnome-shell dynamic workspace management, use static workspaces", **options)

        settings = GSettingsSetting(self.NUM_WORKSPACES_SCHEMA, **options)
        adj = Gtk.Adjustment(1, 1, 99, 1)
        sb = Gtk.SpinButton(adjustment=adj, digits=0)
        settings.bind(self.NUM_WORKSPACES_KEY, adj, "value", Gio.SettingsBindFlags.DEFAULT)

        settings = GSettingsSetting(self.DYNAMIC_SCHEMA, **options)
        sw = Gtk.Switch()
        settings.bind(self.DYNAMIC_KEY, sw, "active", Gio.SettingsBindFlags.DEFAULT)

        #sw.bind_property ("active", sb, "sensitive", GObject.BindingFlags.SYNC_CREATE)
        sb.set_sensitive(not settings[self.DYNAMIC_KEY])
        sw.connect('notify::active', lambda _sw,_param,_sb: _sb.set_sensitive(not _sw.get_active()), sb)

        hb = Gtk.HBox(spacing = 4)
        hb.pack_start(sw, False, False, 0)
        hb.pack_start(sb, True, True, 0)

        self.widget = build_label_beside_widget(self.name, hb)
        self.widget_for_size_group = hb
    def __init__(self, shell, **options):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
        Tweak.__init__(self, _("Install Shell Extension"), "", **options)

        self._shell = shell

        chooser = FileChooserButton(
                        _("Select an extension"),
                        True,
                        ["application/zip"])
        chooser.connect("file-set", self._on_file_set)

        hb = Gtk.HBox(spacing=UI_BOX_SPACING)
        hb.pack_start(
                Gtk.LinkButton.new_with_label("https://extensions.gnome.org",_("Get more extensions")),
                False, False, 0)
        hb.pack_start(chooser, False, False, 0)

        build_label_beside_widget(self.name, hb, hbox=self)
        self.widget_for_size_group = hb

        self.loaded = self._shell is not None
    def __init__(self, **options):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
        Tweak.__init__(self, _("Shell theme"), _("Install custom or user themes for gnome-shell"), **options)

        #check the shell is running and the usertheme extension is present
        error = _("Unknown error")
        self._shell = _shell

        if self._shell is None:
            logging.warning("Shell not running", exc_info=True)
            error = _("Shell not running")
        else:
            try:
                extensions = self._shell.list_extensions()
                if ShellThemeTweak.THEME_EXT_NAME in extensions and extensions[ShellThemeTweak.THEME_EXT_NAME]["state"] == 1:
                    #check the correct gsettings key is present
                    try:
                        if os.path.exists(ShellThemeTweak.THEME_GSETTINGS_DIR):
                            self._settings = GSettingsSetting(ShellThemeTweak.THEME_GSETTINGS_SCHEMA,
                                                              schema_dir=ShellThemeTweak.THEME_GSETTINGS_DIR)
                        else:
                            self._settings = GSettingsSetting(ShellThemeTweak.THEME_GSETTINGS_SCHEMA)
                        name = self._settings.get_string(ShellThemeTweak.THEME_GSETTINGS_NAME)

                        ext = extensions[ShellThemeTweak.THEME_EXT_NAME]
                        logging.debug("Shell user-theme extension\n%s" % pprint.pformat(ext))

                        error = None
                    except:
                        logging.warning(
                            "Could not find user-theme extension in %s" % ','.join(extensions.keys()),
                            exc_info=True)
                        error = _("Shell user-theme extension incorrectly installed")

                else:
                    error = _("Shell user-theme extension not enabled")
            except Exception, e:
                logging.warning("Could not list shell extensions", exc_info=True)
                error = _("Could not list shell extensions")
    def __init__(self, group_id, parent_settings, xkb_info, **options):
        try:
            desc = xkb_info.description_for_group(group_id)
        except AttributeError:
            desc = group_id
        Gtk.Expander.__init__(self)
        Tweak.__init__(self, desc, desc, **options)

        self.set_label(self.name)
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=3)
        vbox.set_margin_start(15)
        self.add(vbox)

        self._group_id = group_id
        self._parent_settings = parent_settings
        self._xkb_info = xkb_info
        self._value = None
        self._possible_values = []

        model_values = [(None, _("Disabled"))]
        for option_id in self._xkb_info.get_options_for_group(group_id):
            desc = self._xkb_info.description_for_option(group_id, option_id)
            model_values.append((option_id, desc))
            self._possible_values.append(option_id)

        self._radios = dict()
        for (val, name) in model_values:
            self._radios[val] = r = Gtk.RadioButton.new_from_widget(
                self._radios.get(None))
            vbox.add(r)
            l = Gtk.Label(name)
            l.set_line_wrap(True)
            r.add(l)
            r._changed_id = r.connect('toggled', self._on_radio_changed)
            r._val = val

        self.widget_for_size_group = None
        self.reload()
示例#36
0
    def __init__(self, group_id, parent_settings, xkb_info, **options):
        try:
            desc = xkb_info.description_for_group(group_id)
        except AttributeError:
            desc = group_id
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
        Tweak.__init__(self, desc, desc, **options)

        self._group_id = group_id
        self._parent_settings = parent_settings
        self._xkb_info = xkb_info
        self._value = None
        self._possible_values = []

        model_values = [(None, _("Disabled"))]
        for option_id in self._xkb_info.get_options_for_group(group_id):
            desc = self._xkb_info.description_for_option(group_id, option_id)
            model_values.append((option_id, desc))
            self._possible_values.append(option_id)

        store = Gtk.ListStore(str, str)
        store.set_sort_column_id(0, Gtk.SortType.ASCENDING)
        for (val, name) in model_values:
            store.append((val, name))

        self._combo = Gtk.ComboBox(model=store)
        renderer = Gtk.CellRendererText()
        renderer.props.ellipsize = Pango.EllipsizeMode.END
        renderer.props.max_width_chars = 30
        self._combo.pack_start(renderer, True)
        self._combo.add_attribute(renderer, "text", 1)
        self._combo_changed_handler_id = self._combo.connect(
            "changed", self._on_combo_changed)

        build_label_beside_widget(self.name, self._combo, hbox=self)
        self.widget_for_size_group = None

        self.reload()
示例#37
0
    def __init__(self, group_id, parent_settings, xkb_info, **options):
        try:
            desc = xkb_info.description_for_group(group_id)
        except AttributeError:
            desc = group_id
        Gtk.Expander.__init__(self)
        Tweak.__init__(self, desc, desc, **options)

        self.set_label(self.name)
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=3)
        vbox.set_margin_start(15)
        self.add(vbox)

        self._multiple_selection = not group_id in {
            'keypad', 'kpdl', 'caps', 'altwin', 'nbsp', 'esperanto'
        }
        self._group_id = group_id
        self._parent_settings = parent_settings
        self._xkb_info = xkb_info
        self._possible_values = []

        model_values = []
        if not self._multiple_selection:
            model_values.append((None, _("Disabled")))

        for option_id in self._xkb_info.get_options_for_group(group_id):
            desc = self._xkb_info.description_for_option(group_id, option_id)
            model_values.append((option_id, desc))
            self._possible_values.append(option_id)

        def values_cmp((av, ad), (bv, bd)):
            if not av:
                return -1
            elif not bv:
                return 1
            else:
                return cmp(ad, bd)
    def __init__(self, group_id, parent_settings, xkb_info, **options):
        try:
            desc = xkb_info.description_for_group(group_id)
        except AttributeError:
            desc = group_id
        Gtk.Expander.__init__(self)
        Tweak.__init__(self, desc, desc, **options)

        self.set_label(self.name)
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=3)
        vbox.set_margin_start(15)
        self.add(vbox)

        self._group_id = group_id
        self._parent_settings = parent_settings
        self._xkb_info = xkb_info
        self._value = None
        self._possible_values = []

        model_values = [(None, _("Disabled"))]
        for option_id in self._xkb_info.get_options_for_group(group_id):
            desc = self._xkb_info.description_for_option(group_id, option_id)
            model_values.append((option_id, desc))
            self._possible_values.append(option_id)

        self._radios = dict()
        for (val, name) in model_values:
            self._radios[val] = r = Gtk.RadioButton.new_from_widget(self._radios.get(None))
            vbox.add(r)
            l = Gtk.Label(name)
            l.set_line_wrap(True)
            r.add(l)
            r._changed_id = r.connect('toggled', self._on_radio_changed)
            r._val = val

        self.widget_for_size_group = None
        self.reload()
    def __init__(self, group_id, parent_settings, xkb_info, **options):
        try:
            desc = xkb_info.description_for_group(group_id)
        except AttributeError:
            desc = group_id
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
        Tweak.__init__(self, desc, desc, **options)

        self._group_id = group_id
        self._parent_settings = parent_settings
        self._xkb_info = xkb_info
        self._value = None
        self._possible_values = []

        model_values = [(None, _("Disabled"))]
        for option_id in self._xkb_info.get_options_for_group(group_id):
            desc = self._xkb_info.description_for_option(group_id, option_id)
            model_values.append((option_id, desc))
            self._possible_values.append(option_id)

        store = Gtk.ListStore(str, str)
        store.set_sort_column_id(0, Gtk.SortType.ASCENDING)
        for (val, name) in model_values:
            store.append((val, name))

        self._combo = Gtk.ComboBox(model = store)
        renderer = Gtk.CellRendererText()
        renderer.props.ellipsize = Pango.EllipsizeMode.END
        renderer.props.max_width_chars = 30
        self._combo.pack_start(renderer, True)
        self._combo.add_attribute(renderer, "text", 1)
        self._combo_changed_handler_id = self._combo.connect("changed", self._on_combo_changed)

        build_label_beside_widget(self.name, self._combo, hbox=self)
        self.widget_for_size_group = None

        self.reload()
    def __init__(self, df, **options):

        Gtk.ListBoxRow.__init__(self)
        Tweak.__init__(self, 
                        df.get_name(),
                        df.get_description(),
                        **options)
        
        grid = Gtk.Grid(column_spacing=10)

        icn = df.get_icon()
        if icn:
            img = _image_from_gicon(icn)
            grid.attach(img, 0, 0, 1, 1)
        else:
            img = None #attach_next_to treats this correctly

        lbl = Gtk.Label(label=df.get_name(), xalign=0.0)
        grid.attach_next_to(lbl,img,Gtk.PositionType.RIGHT,1,1)
        lbl.props.hexpand = True
        lbl.props.halign = Gtk.Align.START

        btn = Gtk.Button(label=_("Remove"))
        grid.attach_next_to(btn,lbl,Gtk.PositionType.RIGHT,1,1)
        btn.props.vexpand = False
        btn.props.valign = Gtk.Align.CENTER

        self.add(grid)

        self.props.margin_start = 1
        self.props.margin_end = 1
        self.get_style_context().add_class('tweak-startup')

        self.btn = btn
        self.app_id = df.get_id()
        self.connect("key-press-event", self._on_key_press_event)
示例#41
0
    def __init__(self, **options):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
        Tweak.__init__(self, _("Shell"),
                       _("Install custom or user themes for gnome-shell"),
                       **options)

        #check the shell is running and the usertheme extension is present
        error = _("Unknown error")
        self._shell = _shell

        if self._shell is None:
            logging.warning("Shell not running", exc_info=True)
            error = _("Shell not running")
        else:
            try:
                extensions = self._shell.list_extensions()
                if ShellThemeTweak.THEME_EXT_NAME in extensions and extensions[
                        ShellThemeTweak.THEME_EXT_NAME]["state"] == 1:
                    #check the correct gsettings key is present
                    try:
                        if os.path.exists(ShellThemeTweak.THEME_GSETTINGS_DIR):
                            self._settings = GSettingsSetting(
                                ShellThemeTweak.THEME_GSETTINGS_SCHEMA,
                                schema_dir=ShellThemeTweak.THEME_GSETTINGS_DIR)
                        else:
                            self._settings = GSettingsSetting(
                                ShellThemeTweak.THEME_GSETTINGS_SCHEMA)
                        name = self._settings.get_string(
                            ShellThemeTweak.THEME_GSETTINGS_NAME)

                        ext = extensions[ShellThemeTweak.THEME_EXT_NAME]
                        logging.debug("Shell user-theme extension\n%s" %
                                      pprint.pformat(ext))

                        error = None
                    except:
                        logging.warning(
                            "Could not find user-theme extension in %s" %
                            ','.join(list(extensions.keys())),
                            exc_info=True)
                        error = _(
                            "Shell user-theme extension incorrectly installed")

                else:
                    error = _("Shell user-theme extension not enabled")
            except Exception as e:
                logging.warning("Could not list shell extensions",
                                exc_info=True)
                error = _("Could not list shell extensions")

        if error:
            cb = build_combo_box_text(None)
            build_label_beside_widget(self.name, cb, warning=error, hbox=self)
            self.widget_for_size_group = cb
        else:
            #include both system, and user themes
            #note: the default theme lives in /system/data/dir/gnome-shell/theme
            #      and not themes/, so add it manually later
            dirs = [
                os.path.join(d, "themes") for d in GLib.get_system_data_dirs()
            ]
            dirs += [ShellThemeTweak.THEME_DIR]
            dirs += [ShellThemeTweak.LEGACY_THEME_DIR]

            valid = walk_directories(dirs, lambda d:
                        os.path.exists(os.path.join(d, "gnome-shell")) and \
                        os.path.exists(os.path.join(d, "gnome-shell", "gnome-shell.css")))
            #the default value to reset the shell is an empty string
            valid.extend(("", ))
            valid = set(valid)

            #build a combo box with all the valid theme options
            #manually add Adwaita to represent the default
            cb = build_combo_box_text(
                self._settings.get_string(
                    ShellThemeTweak.THEME_GSETTINGS_NAME),
                *make_combo_list_with_default(
                    valid, "", default_text=_("<i>Default</i>")))
            cb.connect('changed', self._on_combo_changed)
            self._combo = cb

            #a filechooser to install new themes
            chooser = FileChooserButton(_("Select a theme"), True,
                                        ["application/zip"])
            chooser.connect("file-set", self._on_file_set)

            build_label_beside_widget(self.name, chooser, cb, hbox=self)
            self.widget_for_size_group = cb
示例#42
0
 def __init__(self, name, description, **options):
     Tweak.__init__(self, name, description, **options)
     self.widget = Gtk.Label("... " + name + " ...")
示例#43
0
 def __init__(self, name, description, **options):
     Tweak.__init__(self, name, description, **options)
     self.widget = Gtk.Button(name)
     self.widget.connect("clicked", self._on_click)
     self._need_action = options.get("need_action")
     self._action_error = options.get("action_error")
示例#44
0
    def __init__(self, **options):
        name = _("Workspaces")
        Gtk.ListBox.__init__(self)
        Tweak.__init__(
            self,
            _("Display Handling"),
            _("Workspaces span displays"),
            loaded=_shell_loaded,
        )
        _GSettingsTweak.__init__(self,
                                 name,
                                 "org.gnome.mutter",
                                 "workspaces-only-on-primary",
                                 loaded=_shell_loaded)

        self.set_selection_mode(Gtk.SelectionMode.NONE)

        # Needs other page elements to get margins too
        # self.props.margin_left = 50
        # self.props.margin_right = 50

        row = Gtk.ListBoxRow()
        hbox = Gtk.Box()
        hbox.props.margin = 10
        row.add(hbox)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        lbl = Gtk.Label(_("Workspaces on primary display only"), xalign=0)
        lbl.props.xalign = 0.0
        desc = _("Additional displays are treated as independent workspaces.")
        lbl_desc = Gtk.Label()
        lbl_desc.set_line_wrap(True)
        lbl_desc.get_style_context().add_class("dim-label")
        lbl_desc.set_markup("<span size='small'>" +
                            GLib.markup_escape_text(desc) + "</span>")

        self.check1 = Gtk.Image.new_from_icon_name("object-select-symbolic",
                                                   Gtk.IconSize.SMALL_TOOLBAR)
        self.check1.set_no_show_all(True)
        self.check1.set_visible(self.settings[self.key_name])

        vbox.pack_start(lbl, False, False, 0)
        vbox.pack_start(lbl_desc, False, False, 0)
        hbox.pack_start(vbox, False, False, 0)
        hbox.pack_end(self.check1, False, False, 0)

        self.add(row)

        row = Gtk.ListBoxRow()
        hbox = Gtk.Box()
        hbox.props.margin = 10
        row.add(hbox)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        lbl = Gtk.Label(_("Workspaces span displays"), xalign=0)
        lbl.props.xalign = 0.0
        desc = _("The current workspace includes additional displays.")
        lbl_desc = Gtk.Label()
        lbl_desc.set_line_wrap(True)
        lbl_desc.get_style_context().add_class("dim-label")
        lbl_desc.set_markup("<span size='small'>" +
                            GLib.markup_escape_text(desc) + "</span>")

        self.check2 = Gtk.Image.new_from_icon_name("object-select-symbolic",
                                                   Gtk.IconSize.SMALL_TOOLBAR)
        self.check2.set_no_show_all(True)
        self.check2.set_visible(not self.settings[self.key_name])

        vbox.pack_start(lbl, False, False, 0)
        vbox.pack_start(lbl_desc, False, False, 0)
        hbox.pack_start(vbox, False, False, 0)
        hbox.pack_end(self.check2, False, False, 0)

        self.add(row)
        self.connect('row-activated', self.on_row_clicked)
示例#45
0
    def __init__(self, shell, ext, **options):
        Gtk.ListBoxRow.__init__(self)
        Tweak.__init__(self, ext["name"], ext.get("description", ""),
                       **options)

        self.hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        self.hbox.props.border_width = 10
        self.hbox.props.spacing = 12

        self._shell = shell
        state = ext.get("state")
        uuid = ext["uuid"]
        self._app_id = "user/*/extensions-web/shell-extension/" + uuid.replace(
            '@', '_') + "/*"

        shell._settings.bind("disable-user-extensions", self, "sensitive",
                             Gio.SettingsBindFlags.INVERT_BOOLEAN)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        lbl_name = Gtk.Label(xalign=0.0)
        name_markup = GLib.markup_escape_text(ext["name"].lower().capitalize())
        lbl_name.set_markup("<span size='medium'><b>" + name_markup +
                            "</b></span>")
        lbl_desc = _ExtensionDescriptionLabel(xalign=0.0,
                                              yalign=0.0,
                                              wrap=True,
                                              lines=2)
        desc = GLib.markup_escape_text(
            ext["description"].lower().capitalize().split('\n')[0])
        lbl_desc.set_markup("<span size='small'>" + desc + "</span>")
        lbl_desc.get_style_context().add_class("dim-label")
        lbl_desc.props.ellipsize = Pango.EllipsizeMode.END

        vbox.pack_start(lbl_name, False, False, 0)
        vbox.pack_start(lbl_desc, False, False, 0)

        self.hbox.pack_start(vbox, True, True, 10)

        info = None
        warning = None
        sensitive = False
        if state == GnomeShell.EXTENSION_STATE["ENABLED"] or \
           state == GnomeShell.EXTENSION_STATE["DISABLED"] or \
           state == GnomeShell.EXTENSION_STATE["INITIALIZED"]:
            sensitive = True
        elif state == GnomeShell.EXTENSION_STATE["DOWNLOADING"]:
            info = _("Extension downloading")
        elif state == GnomeShell.EXTENSION_STATE["ERROR"]:
            warning = _("Error loading extension")
        elif state == GnomeShell.EXTENSION_STATE["OUT_OF_DATE"]:
            warning = _("Extension does not support shell version")
        else:
            warning = _("Unknown extension error")
            logging.critical(warning)

        if info:
            inf = self.make_image("dialog-information-symbolic", info)
            self.hbox.pack_start(inf, False, False, 0)

        if warning:
            wg = self.make_image("dialog-warning-symbolic", warning)
            self.hbox.pack_start(wg, False, False, 0)

        if self._shell.SUPPORTS_EXTENSION_PREFS:
            prefs = os.path.join(ext['path'], "prefs.js")
            if os.path.exists(prefs):
                btn = Gtk.Button.new_from_icon_name("emblem-system-symbolic",
                                                    Gtk.IconSize.BUTTON)
                btn.props.valign = Gtk.Align.CENTER
                btn.connect("clicked", self._on_configure_clicked, uuid)
                self.hbox.pack_start(btn, False, False, 0)

        sw = Gtk.Switch(sensitive=sensitive)
        sw.props.vexpand = False
        sw.props.valign = Gtk.Align.CENTER
        sw.set_active(self._shell.extension_is_active(state, uuid))
        sw.connect('notify::active', self._on_extension_toggled, uuid)
        self.hbox.pack_start(sw, False, False, 0)

        de = DisableExtension()
        de.connect('disable-extension', self._on_disable_extension, sw)

        self.add(self.hbox)
        self.widget_for_size_group = None
示例#46
0
    def __init__(self, **options):
        Gtk.Box.__init__(self)
        Tweak.__init__(self, _("Hinting"), _("Antialiasing"))

        self.settings = Gio.Settings("org.gnome.settings-daemon.plugins.xsettings")

        self.set_spacing(12)
        self.props.margin_top = 12

        label = Gtk.Label(_("Hinting"))
        label.props.yalign = 0.0
        label.padding = 10
        self.pack_start(label, False, False, 0)

        hint_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
        self.pack_start(hint_box, True, True, 0)

        self.btn_full = Gtk.RadioButton.new_from_widget(None)
        self.btn_full.set_label(_("Full"))
        self.btn_full.set_active(self.settings["hinting"] == "full")
        self.btn_full.connect("toggled", self.on_hint_button_toggled)
        hint_box.pack_start(self.btn_full, False, False, 0)

        self.btn_med = Gtk.RadioButton.new_from_widget(self.btn_full)
        self.btn_med.set_label(_("Medium"))
        self.btn_med.set_active(self.settings["hinting"] == "medium")
        self.btn_med.connect("toggled", self.on_hint_button_toggled)
        hint_box.pack_start(self.btn_med, False, False, 0)

        self.btn_slight = Gtk.RadioButton.new_from_widget(self.btn_full)
        self.btn_slight.set_label(_("Slight"))
        self.btn_slight.set_active(self.settings["hinting"] == "slight")
        self.btn_slight.connect("toggled", self.on_hint_button_toggled)
        hint_box.pack_start(self.btn_slight, False, False, 0)

        self.btn_hnone = Gtk.RadioButton.new_from_widget(self.btn_full)
        self.btn_hnone.set_label(_("None"))
        self.btn_hnone.set_active(self.settings["hinting"] == "none")
        self.btn_hnone.connect("toggled", self.on_hint_button_toggled)
        hint_box.pack_start(self.btn_hnone, False, False, 0)

        label = Gtk.Label(_("Antialiasing"))
        label.props.yalign = 0.0
        self.pack_start(label, False, False, 0)

        aa_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
        self.pack_start(aa_box, False, False, 0)

        self.btn_rgba = Gtk.RadioButton.new_from_widget(None)
        self.btn_rgba.set_label(_("Subpixel (for LCD screens)"))
        self.btn_rgba.set_active(self.settings["antialiasing"] == "rgba")
        self.btn_rgba.connect("toggled", self.on_aa_button_toggled)
        aa_box.pack_start(self.btn_rgba, False, False, 0)

        self.btn_gray = Gtk.RadioButton.new_from_widget(self.btn_rgba)
        self.btn_gray.set_label(_("Standard (grayscale)"))
        self.btn_gray.set_active(self.settings["antialiasing"] == "grayscale")
        self.btn_gray.connect("toggled", self.on_aa_button_toggled)
        aa_box.pack_start(self.btn_gray, False, False, 0)

        self.btn_anone = Gtk.RadioButton.new_from_widget(self.btn_rgba)
        self.btn_anone.set_label(_("None"))
        self.btn_anone.set_active(self.settings["antialiasing"] == "none")
        self.btn_anone.connect("toggled", self.on_aa_button_toggled)
        aa_box.pack_start(self.btn_anone, False, False, 0)
示例#47
0
 def __init__(self, name, description, **options):
     Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
     Tweak.__init__(self, name, description, **options)
     self.add(Gtk.Label("... " + name + " ..."))
示例#48
0
    def __init__(self, **options):
        Gtk.ListBox.__init__(self)
        Tweak.__init__(self, _("Window Focus"), _("Click to Focus"))

        self.settings = Gio.Settings("org.gnome.desktop.wm.preferences")
        self.key_name = "focus-mode"

        self.set_selection_mode(Gtk.SelectionMode.NONE)

        # Needs other page elements to get margins too
        # self.props.margin_left = 50
        # self.props.margin_right = 50

        row = Gtk.ListBoxRow()
        hbox = Gtk.Box()
        hbox.props.margin = 10
        row.add(hbox)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        lbl = Gtk.Label(_("Click to Focus"), xalign=0)
        lbl.props.xalign = 0.0
        desc = _("Windows are focused when they are clicked.")
        lbl_desc = Gtk.Label()
        lbl_desc.set_line_wrap(True)
        lbl_desc.get_style_context().add_class("dim-label")
        lbl_desc.set_markup("<span size='small'>" +
                            GLib.markup_escape_text(desc) + "</span>")

        self.check_click = Gtk.Image.new_from_icon_name(
            "object-select-symbolic", Gtk.IconSize.SMALL_TOOLBAR)
        self.check_click.set_no_show_all(True)
        self.check_click.set_visible(self.settings[self.key_name] == "click")

        vbox.pack_start(lbl, False, False, 0)
        vbox.pack_start(lbl_desc, False, False, 0)
        hbox.pack_start(vbox, False, False, 0)
        hbox.pack_end(self.check_click, False, False, 0)

        self.add(row)

        row = Gtk.ListBoxRow()
        hbox = Gtk.Box()
        hbox.props.margin = 10
        row.add(hbox)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        lbl = Gtk.Label(_("Sloppy"), xalign=0)
        lbl.props.xalign = 0.0
        desc = _(
            "Window is focused when hovered with the pointer. Windows remain focused when the desktop is hovered."
        )
        lbl_desc = Gtk.Label()
        lbl_desc.set_line_wrap(True)
        lbl_desc.get_style_context().add_class("dim-label")
        lbl_desc.set_markup("<span size='small'>" +
                            GLib.markup_escape_text(desc) + "</span>")

        self.check_sloppy = Gtk.Image.new_from_icon_name(
            "object-select-symbolic", Gtk.IconSize.SMALL_TOOLBAR)
        self.check_sloppy.set_no_show_all(True)
        self.check_sloppy.set_visible(self.settings[self.key_name] == "sloppy")

        vbox.pack_start(lbl, False, False, 0)
        vbox.pack_start(lbl_desc, False, False, 0)
        hbox.pack_start(vbox, False, False, 0)
        hbox.pack_end(self.check_sloppy, False, False, 0)

        self.add(row)

        row = Gtk.ListBoxRow()
        hbox = Gtk.Box()
        hbox.props.margin = 10
        row.add(hbox)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        lbl = Gtk.Label(_("Secondary-Click"), xalign=0)
        lbl.props.xalign = 0.0
        desc = _(
            "Window is focused when hovered with the pointer. Hovering the desktop removes focus from the previous window."
        )
        lbl_desc = Gtk.Label()
        lbl_desc.set_line_wrap(True)
        lbl_desc.get_style_context().add_class("dim-label")
        lbl_desc.set_markup("<span size='small'>" +
                            GLib.markup_escape_text(desc) + "</span>")

        self.check_mouse = Gtk.Image.new_from_icon_name(
            "object-select-symbolic", Gtk.IconSize.SMALL_TOOLBAR)
        self.check_mouse.set_no_show_all(True)
        self.check_mouse.set_visible(self.settings[self.key_name] == "mouse")

        vbox.pack_start(lbl, False, False, 0)
        vbox.pack_start(lbl_desc, False, False, 0)
        hbox.pack_start(vbox, False, False, 0)
        hbox.pack_end(self.check_mouse, False, False, 0)

        self.add(row)
        self.connect('row-activated', self.on_row_clicked)
    def __init__(self, shell, ext, **options):
        Gtk.ListBoxRow.__init__(self)
        Tweak.__init__(self, ext["name"], ext.get("description", ""),
                       **options)

        self.hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        self.hbox.props.border_width = 10
        self.hbox.props.spacing = UI_BOX_SPACING

        self._shell = shell
        state = ext.get("state")
        uuid = ext["uuid"]

        sw = Gtk.Switch()
        sw.props.vexpand = False
        sw.props.valign = Gtk.Align.CENTER
        sw.set_active(self._shell.extension_is_active(state, uuid))
        sw.connect('notify::active', self._on_extension_toggled, uuid)
        self.hbox.pack_start(sw, False, False, 0)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        lbl_name = Gtk.Label(xalign=0.0)
        lbl_name.set_markup("<span size='medium'><b>" +
                            ext["name"].lower().capitalize() + "</b></span>")
        lbl_desc = Gtk.Label(xalign=0.0)
        desc = ext["description"].lower().capitalize().split('\n')[0]
        lbl_desc.set_markup("<span foreground='#A19C9C' size='small'>" + desc +
                            "</span>")
        lbl_desc.props.ellipsize = Pango.EllipsizeMode.END

        vbox.pack_start(lbl_name, False, False, 0)
        vbox.pack_start(lbl_desc, False, False, 0)

        self.hbox.pack_start(vbox, True, True, 10)

        info = None
        warning = None
        sensitive = False
        if state == GnomeShell.EXTENSION_STATE["ENABLED"] or \
           state == GnomeShell.EXTENSION_STATE["DISABLED"] or \
           state == GnomeShell.EXTENSION_STATE["INITIALIZED"]:
            sensitive = True
        elif state == GnomeShell.EXTENSION_STATE["DOWNLOADING"]:
            info = _("Extension downloading")
        elif state == GnomeShell.EXTENSION_STATE["ERROR"]:
            warning = _("Error loading extension")
        elif state == GnomeShell.EXTENSION_STATE["OUT_OF_DATE"]:
            warning = _("Extension does not support shell version")
        else:
            warning = _("Unknown extension error")
            logging.critical(warning)
        sw.set_sensitive(sensitive)

        if info:
            inf = self.make_image("dialog-information-symbolic", info)
            self.hbox.pack_start(inf, False, False, 0)

        if warning:
            wg = self.make_image("dialog-warning-symbolic", warning)
            self.hbox.pack_start(wg, False, False, 0)

        if self._shell.SUPPORTS_EXTENSION_PREFS:
            prefs = os.path.join(ext['path'], "prefs.js")
            if os.path.exists(prefs):
                icon = Gtk.Image()
                icon.set_from_icon_name("emblem-system-symbolic",
                                        Gtk.IconSize.BUTTON)
                btn = Gtk.Button()
                btn.props.vexpand = False
                btn.props.valign = Gtk.Align.CENTER
                btn.add(icon)
                btn.connect("clicked", self._on_configure_clicked, uuid)
                self.hbox.pack_start(btn, False, False, 0)

        btn = Gtk.Button(_("Remove"))
        btn.props.vexpand = False
        btn.props.valign = Gtk.Align.CENTER
        btn.set_sensitive(False)
        self.hbox.pack_start(btn, False, False, 0)
        if ext.get("type") == GnomeShell.EXTENSION_TYPE["PER_USER"]:
            btn.get_style_context().add_class("suggested-action")
            btn.set_sensitive(True)
            btn.connect("clicked", self._on_extension_delete, uuid,
                        ext["name"])
        self.deleteButton = btn

        de = DisableExtension()
        de.connect('disable-extension', self._on_disable_extension, sw)

        self.add(self.hbox)
        self.widget_for_size_group = None
    def __init__(self, group_id, parent_settings, xkb_info, **options):
        try:
            desc = xkb_info.description_for_group(group_id)
        except AttributeError:
            desc = group_id
        Gtk.Expander.__init__(self)
        Tweak.__init__(self, desc, desc, **options)

        self.set_label(self.name)
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=3)
        vbox.set_margin_start(15)
        self.add(vbox)

        self._multiple_selection = not group_id in {
            'keypad', 'kpdl', 'caps', 'altwin', 'nbsp', 'esperanto'
        }
        self._group_id = group_id
        self._parent_settings = parent_settings
        self._xkb_info = xkb_info
        self._possible_values = []

        model_values = []
        if not self._multiple_selection:
            model_values.append((None, _("Disabled")))

        for option_id in self._xkb_info.get_options_for_group(group_id):
            desc = self._xkb_info.description_for_option(group_id, option_id)
            model_values.append((option_id, desc))
            self._possible_values.append(option_id)

        def values_cmp_py3_wrap(f):
            ''' https://docs.python.org/3/howto/sorting.html#the-old-way-using-the-cmp-parameter '''
            class C:
                def __init__(self, obj, *args):
                    self.obj = obj

                def __lt__(self, other):
                    return f(self.obj, other.obj) < 0

                def __gt__(self, other):
                    return f(self.obj, other.obj) > 0

                def __eq__(self, other):
                    return f(self.obj, other.obj) == 0

                def __le__(self, other):
                    return f(self.obj, other.obj) <= 0

                def __ge__(self, other):
                    return f(self.obj, other.obj) >= 0

                def __ne__(self, other):
                    return f(self.obj, other.obj) != 0

            return C

        def values_cmp(xxx_todo_changeme, xxx_todo_changeme1):
            (av, ad) = xxx_todo_changeme
            (bv, bd) = xxx_todo_changeme1
            if not av:
                return -1
            elif not bv:
                return 1
            else:
                return (ad > bd) - (ad < bd)

        model_values.sort(key=values_cmp_py3_wrap(values_cmp))

        self._widgets = dict()
        for (val, name) in model_values:
            w = None
            if self._multiple_selection:
                w = Gtk.CheckButton.new()
            else:
                w = Gtk.RadioButton.new_from_widget(self._widgets.get(None))
            self._widgets[val] = w
            vbox.add(w)
            l = Gtk.Label(label=name)
            l.set_line_wrap(True)
            w.add(l)
            w._changed_id = w.connect('toggled', self._on_toggled)
            w._val = val

        self.widget_for_size_group = None
        self.reload()
示例#51
0
 def __init__(self, key_name, key_type, **options):
     self.gconf = GConfSetting(key_name, key_type)
     Tweak.__init__(self,
         self.gconf.schema_get_summary(),
         self.gconf.schema_get_description(),
         **options)
    def __init__(self, shell, ext, **options):
        Gtk.ListBoxRow.__init__(self)
        Tweak.__init__(self, ext["name"], ext.get("description",""), **options)

        self.hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        self.hbox.props.border_width = 10
        self.hbox.props.spacing = UI_BOX_SPACING
    
        self._shell = shell
        state = ext.get("state")
        uuid = ext["uuid"]

        sw = Gtk.Switch()
        sw.props.vexpand = False
        sw.props.valign = Gtk.Align.CENTER
        sw.set_active(self._shell.extension_is_active(state, uuid))
        sw.connect('notify::active', self._on_extension_toggled, uuid)
        self.hbox.pack_start(sw, False, False, 0)
                        
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        lbl_name = Gtk.Label(xalign=0.0)
        name_markup = GLib.markup_escape_text(ext["name"].lower().capitalize())
        lbl_name.set_markup("<span size='medium'><b>"+name_markup+"</b></span>")
        lbl_desc = Gtk.Label(xalign=0.0)
        desc = GLib.markup_escape_text(ext["description"].lower().capitalize().split('\n')[0])
        lbl_desc.set_markup("<span foreground='#A19C9C' size='small'>"+desc+"</span>")
        lbl_desc.props.ellipsize = Pango.EllipsizeMode.END 
        
        vbox.pack_start(lbl_name, False, False, 0)
        vbox.pack_start(lbl_desc, False, False, 0)
        
        self.hbox.pack_start(vbox, True, True, 10)

        info = None
        warning = None
        sensitive = False
        if state == GnomeShell.EXTENSION_STATE["ENABLED"] or \
           state == GnomeShell.EXTENSION_STATE["DISABLED"] or \
           state == GnomeShell.EXTENSION_STATE["INITIALIZED"]:
            sensitive = True
        elif state == GnomeShell.EXTENSION_STATE["DOWNLOADING"]:
            info = _("Extension downloading")
        elif state == GnomeShell.EXTENSION_STATE["ERROR"]:
            warning = _("Error loading extension")
        elif state == GnomeShell.EXTENSION_STATE["OUT_OF_DATE"]:
            warning = _("Extension does not support shell version")
        else:
            warning = _("Unknown extension error")
            logging.critical(warning)
        sw.set_sensitive(sensitive)


        if info:
            inf = self.make_image("dialog-information-symbolic", info)
            self.hbox.pack_start(inf, False, False, 0)

        if warning:
            wg = self.make_image("dialog-warning-symbolic", warning)
            self.hbox.pack_start(wg, False, False, 0)

        if self._shell.SUPPORTS_EXTENSION_PREFS:
            prefs = os.path.join(ext['path'], "prefs.js")
            if os.path.exists(prefs):
                btn = Gtk.Button.new_from_icon_name("emblem-system-symbolic", Gtk.IconSize.BUTTON)
                btn.props.valign = Gtk.Align.CENTER
                btn.connect("clicked", self._on_configure_clicked, uuid)
                self.hbox.pack_start(btn, False, False, 0)

        btn = Gtk.Button(label=_("Remove"))
        btn.props.vexpand = False
        btn.props.valign = Gtk.Align.CENTER
        btn.set_sensitive(False)
        self.hbox.pack_start(btn, False, False, 0)
        if ext.get("type") == GnomeShell.EXTENSION_TYPE["PER_USER"]:
            btn.get_style_context().add_class("suggested-action")
            btn.set_sensitive(True)
            btn.connect("clicked", self._on_extension_delete, uuid, ext["name"])
        self.deleteButton = btn

        de = DisableExtension()
        de.connect('disable-extension', self._on_disable_extension, sw)
    
        self.add(self.hbox)
        self.widget_for_size_group = None
 def __init__(self, name, description, **options):
     Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
     Tweak.__init__(self, name, description, **options)
     self.add(Gtk.Label("... " + name + " ..."))