Example #1
0
    def __init__(self, uuid, data, spices, size_groups):
        super(DownloadSpicesRow, self).__init__()

        self.uuid = uuid
        self.data = data
        self.spices = spices
        self.name = data['name']
        self.description = data['description']
        self.score = data['score']
        self.timestamp = data['last_edited']

        self.status_ids = {}

        self.installed = self.spices.get_is_installed(uuid)

        widget = SettingsWidget()
        widget.set_spacing(15)
        self.add(widget)

        icon = spices.get_icon(uuid)
        widget.pack_start(icon, False, False, 0)

        desc_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        desc_box.set_hexpand(True)
        desc_box.set_halign(Gtk.Align.FILL)
        name_label = Gtk.Label()
        name_markup = GLib.markup_escape_text(self.name)
        name_label.set_markup('<b>{}</b>'.format(name_markup))
        name_label.set_hexpand(True)
        name_label.set_halign(Gtk.Align.START)
        desc_box.pack_start(name_label, False, False, 0)

        description_label = SettingsLabel()
        description_markup = GLib.markup_escape_text(sanitize_html(self.description))
        description_label.set_markup('<small>{}</small>'.format(description_markup))
        desc_box.pack_start(description_label, False, False, 0)

        widget.pack_start(desc_box, True, True, 0)

        score_box = Gtk.Box()
        score_image = Gtk.Image.new_from_icon_name('starred-symbolic', 2)
        score_box.pack_start(score_image, False, False, 0)
        score_label = Gtk.Label(self.score)
        score_box.pack_start(score_label, False, False, 5)
        widget.pack_start(score_box, False, False, 0)
        size_groups[0].add_widget(score_box)

        self.status_box = Gtk.Box()
        self.status_box.set_spacing(4)
        widget.pack_start(self.status_box, False, False, 0)
        size_groups[1].add_widget(self.status_box)

        self.button_box = Gtk.Box()
        self.button_box.set_valign(Gtk.Align.CENTER)
        self.button_box.set_baseline_position(Gtk.BaselinePosition.CENTER)
        widget.pack_start(self.button_box, False, False, 0)
        size_groups[2].add_widget(self.button_box)

        if not self.installed:
            download_button = Gtk.Button.new_from_icon_name('go-down-symbolic', 2)
            self.button_box.pack_start(download_button, False, False, 0)
            download_button.connect('clicked', self.download)
            download_button.set_tooltip_text(_("Install"))
        elif self.spices.get_has_update(uuid):
            download_button = Gtk.Button.new_from_icon_name('view-refresh-symbolic', 2)
            self.button_box.pack_start(download_button, False, False, 0)
            download_button.connect('clicked', self.download)
            download_button.set_tooltip_text(_("Update"))

        if self.installed:
            self.add_status('installed', 'object-select-symbolic', _("Installed"))

        self.show_all()
Example #2
0
    def __init__(self, uuid, data, spices, size_groups):
        super(DownloadSpicesRow, self).__init__()

        self.uuid = uuid
        self.data = data
        self.spices = spices
        self.name = data['name']
        self.description = data['description']
        self.score = data['score']
        self.timestamp = data['last_edited']

        self.status_ids = {}

        self.installed = self.spices.get_is_installed(uuid)

        widget = SettingsWidget()
        widget.set_spacing(15)
        self.add(widget)

        icon = spices.get_icon(uuid)
        widget.pack_start(icon, False, False, 0)

        desc_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        desc_box.set_hexpand(True)
        desc_box.set_halign(Gtk.Align.FILL)
        name_label = Gtk.Label()
        name_markup = GLib.markup_escape_text(self.name)
        name_label.set_markup('<b>{}</b>'.format(name_markup))
        name_label.set_hexpand(True)
        name_label.set_halign(Gtk.Align.START)
        desc_box.pack_start(name_label, False, False, 0)

        description_label = SettingsLabel()
        description_markup = GLib.markup_escape_text(sanitize_html(self.description))
        description_label.set_markup('<small>{}</small>'.format(description_markup))
        desc_box.pack_start(description_label, False, False, 0)

        widget.pack_start(desc_box, True, True, 0)

        score_box = Gtk.Box()
        score_image = Gtk.Image.new_from_icon_name('starred-symbolic', 2)
        score_box.pack_start(score_image, False, False, 0)
        score_label = Gtk.Label(self.score)
        score_box.pack_start(score_label, False, False, 5)
        widget.pack_start(score_box, False, False, 0)
        size_groups[0].add_widget(score_box)

        self.status_box = Gtk.Box()
        self.status_box.set_spacing(4)
        widget.pack_start(self.status_box, False, False, 0)
        size_groups[1].add_widget(self.status_box)

        self.button_box = Gtk.Box()
        self.button_box.set_valign(Gtk.Align.CENTER)
        self.button_box.set_baseline_position(Gtk.BaselinePosition.CENTER)
        widget.pack_start(self.button_box, False, False, 0)
        size_groups[2].add_widget(self.button_box)

        if not self.installed:
            download_button = Gtk.Button.new_from_icon_name('go-down-symbolic', 2)
            self.button_box.pack_start(download_button, False, False, 0)
            download_button.connect('clicked', self.download)
            download_button.set_tooltip_text(_("Install"))
        elif self.spices.get_has_update(uuid):
            download_button = Gtk.Button.new_from_icon_name('view-refresh-symbolic', 2)
            self.button_box.pack_start(download_button, False, False, 0)
            download_button.connect('clicked', self.download)
            download_button.set_tooltip_text(_("Update"))

        if self.installed:
            self.add_status('installed', 'object-select-symbolic', _("Installed"))

        self.show_all()
Example #3
0
    def __init__(self, extension_type, metadata, size_group):
        super(ManageSpicesRow, self).__init__()
        self.extension_type = extension_type
        self.metadata = metadata

        self.status_ids = {}

        self.writable = metadata['writable']

        self.uuid = self.metadata['uuid']
        self.name = translate(self.metadata['uuid'], self.metadata['name'])
        self.description = translate(self.metadata['uuid'], self.metadata['description'])

        try:
            self.max_instances = int(self.metadata['max-instances'])
            if self.max_instances < -1:
                self.max_instances = 1
        except (KeyError, ValueError):
            self.max_instances = 1

        try:
            self.role = self.metadata['role']
        except (KeyError, ValueError):
            self.role = None

        try:
            last_edited = self.metadata['last-edited']
        except (KeyError, ValueError):
            last_edited = -1

        if 'multiversion' in self.metadata and self.metadata['multiversion']:
            self.metadata['path'] = find_extension_subdir(self.metadata['path'])

        # "hide-configuration": true in metadata trumps all
        # otherwise we check for "external-configuration-app" in metadata and settings-schema.json in settings
        self.has_config = False
        self.ext_config_app = None
        if not 'hide-configuration' in self.metadata or self.metadata['hide-configuration'] != True:
            if 'external-configuration-app' in self.metadata:
                self.ext_config_app = os.path.join(self.metadata['path'], self.metadata['external-configuration-app'])

            if self.ext_config_app is not None:
                if os.path.exists(self.ext_config_app):
                    self.has_config = True
                else:
                    self.ext_config_app = None

            if self.ext_config_app is None and os.path.exists('%s/settings-schema.json' % self.metadata['path']):
                self.has_config = True

        widget = SettingsWidget()
        self.add(widget)

        grid = Gtk.Grid()
        grid.set_column_spacing(15)
        widget.pack_start(grid, True, True, 0)

        icon = None
        if 'icon' in self.metadata:
            icon_name = self.metadata['icon']
            if Gtk.IconTheme.get_default().has_icon(icon_name):
                icon = Gtk.Image.new_from_icon_name(icon_name, 3)

        if icon is None and os.path.exists('%s/icon.png' % self.metadata['path']):
            try:
                pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale('%s/icon.png' % self.metadata['path'], 24, 24, True)
                icon = Gtk.Image.new_from_pixbuf(pixbuf)
            except:
                icon = None

        if icon is None:
            icon = Gtk.Image.new_from_icon_name('cs-%ss' % (extension_type), 3)

        grid.attach(icon, 0, 0, 1, 1)

        desc_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        desc_box.props.hexpand = True
        desc_box.props.halign = Gtk.Align.START
        name_label = Gtk.Label()
        name_markup = GLib.markup_escape_text(self.name)
        name_label.set_markup('<b>{}</b>'.format(name_markup))
        name_label.props.xalign = 0.0
        desc_box.add(name_label)

        description_label = SettingsLabel()
        description_markup = GLib.markup_escape_text(sanitize_html(self.description))
        description_label.set_markup('<small>{}</small>'.format(description_markup))
        desc_box.add(description_label)

        grid.attach_next_to(desc_box, icon, Gtk.PositionType.RIGHT, 1, 1)

        self.status_box = Gtk.Box()
        self.status_box.set_spacing(4)
        grid.attach_next_to(self.status_box, desc_box, Gtk.PositionType.RIGHT, 1, 1)

        self.button_box = Gtk.Box()
        self.button_box.set_valign(Gtk.Align.CENTER)
        grid.attach_next_to(self.button_box, self.status_box, Gtk.PositionType.RIGHT, 1, 1)
        size_group.add_widget(self.button_box)

        if self.has_config:
            config_icon = Gtk.Image.new_from_icon_name('system-run-symbolic', 2)
            self.config_button = Gtk.Button(image=config_icon)
            self.config_button.set_tooltip_text(_('Configure'))
            self.button_box.pack_start(self.config_button, False, False, 0)
            self.config_button.connect('clicked', self.configure)
            self.set_can_config()

        if not self.writable:
            if self.extension_type == "applet":
                self.add_status('locked', 'changes-prevent-symbolic', _("This is a system applet. It cannot be removed."))
            elif self.extension_type == "desklet":
                self.add_status('locked', 'changes-prevent-symbolic', _("This is a system desklet. It cannot be removed."))
            elif self.extension_type == "extension":
                self.add_status('locked', 'changes-prevent-symbolic', _("This is a system extension. It cannot be removed."))

        try:
            schema_filename = self.metadata['schema-file']
        except (KeyError, ValueError):
            schema_filename = ''

        if self.writable:
            self.scan_extension_for_danger(self.metadata['path'])

        self.version_supported = False
        try:
            self.version_supported = curr_ver in self.metadata['cinnamon-version'] or curr_ver.rsplit('.', 1)[0] in self.metadata['cinnamon-version']
        except (KeyError, ValueError):
            self.version_supported = True # Don't check version if not specified.
Example #4
0
    def __init__(self, extension_type, metadata, size_group):
        super(ManageSpicesRow, self).__init__()
        self.extension_type = extension_type
        self.metadata = metadata

        self.status_ids = {}

        self.writable = metadata['writable']

        self.uuid = self.metadata['uuid']
        self.name = translate(self.metadata['uuid'], self.metadata['name'])
        self.description = translate(self.metadata['uuid'], self.metadata['description'])

        try:
            self.max_instances = int(self.metadata['max-instances'])
            if self.max_instances < -1:
                self.max_instances = 1
        except (KeyError, ValueError):
            self.max_instances = 1

        try:
            self.role = self.metadata['role']
        except (KeyError, ValueError):
            self.role = None

        try:
            last_edited = self.metadata['last-edited']
        except (KeyError, ValueError):
            last_edited = -1

        if 'multiversion' in self.metadata and self.metadata['multiversion']:
            self.metadata['path'] = find_extension_subdir(self.metadata['path'])

        # "hide-configuration": true in metadata trumps all
        # otherwise we check for "external-configuration-app" in metadata and settings-schema.json in settings
        self.has_config = False
        self.ext_config_app = None
        if not 'hide-configuration' in self.metadata or self.metadata['hide-configuration'] != True:
            if 'external-configuration-app' in self.metadata:
                self.ext_config_app = os.path.join(self.metadata['path'], self.metadata['external-configuration-app'])

            if self.ext_config_app is not None:
                if os.path.exists(self.ext_config_app):
                    self.has_config = True
                else:
                    self.ext_config_app = None

            if self.ext_config_app is None and os.path.exists('%s/settings-schema.json' % self.metadata['path']):
                self.has_config = True

        widget = SettingsWidget()
        self.add(widget)

        grid = Gtk.Grid()
        grid.set_column_spacing(15)
        widget.pack_start(grid, True, True, 0)

        icon = None
        if 'icon' in self.metadata:
            icon_name = self.metadata['icon']
            if Gtk.IconTheme.get_default().has_icon(icon_name):
                icon = Gtk.Image.new_from_icon_name(icon_name, 3)

        if icon is None and os.path.exists('%s/icon.png' % self.metadata['path']):
            try:
                pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale('%s/icon.png' % self.metadata['path'], 24, 24, True)
                icon = Gtk.Image.new_from_pixbuf(pixbuf)
            except:
                icon = None

        if icon is None:
            icon = Gtk.Image.new_from_icon_name('cs-%ss' % (extension_type), 3)

        grid.attach(icon, 0, 0, 1, 1)

        desc_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        desc_box.props.hexpand = True
        desc_box.props.halign = Gtk.Align.START
        name_label = Gtk.Label()
        name_markup = GLib.markup_escape_text(self.name)
        name_label.set_markup('<b>{}</b>'.format(name_markup))
        name_label.props.xalign = 0.0
        desc_box.add(name_label)

        description_label = SettingsLabel()
        description_markup = GLib.markup_escape_text(sanitize_html(self.description))
        description_label.set_markup('<small>{}</small>'.format(description_markup))
        desc_box.add(description_label)

        grid.attach_next_to(desc_box, icon, Gtk.PositionType.RIGHT, 1, 1)

        self.status_box = Gtk.Box()
        self.status_box.set_spacing(4)
        grid.attach_next_to(self.status_box, desc_box, Gtk.PositionType.RIGHT, 1, 1)

        self.button_box = Gtk.Box()
        self.button_box.set_valign(Gtk.Align.CENTER)
        grid.attach_next_to(self.button_box, self.status_box, Gtk.PositionType.RIGHT, 1, 1)
        size_group.add_widget(self.button_box)

        if self.has_config:
            config_icon = Gtk.Image.new_from_icon_name('system-run-symbolic', 2)
            self.config_button = Gtk.Button(image=config_icon)
            self.config_button.set_tooltip_text(_('Configure'))
            self.button_box.pack_start(self.config_button, False, False, 0)
            self.config_button.connect('clicked', self.configure)
            self.set_can_config()

        if not self.writable:
            if self.extension_type == "applet":
                self.add_status('locked', 'changes-prevent-symbolic', _("This is a system applet. It cannot be removed."))
            elif self.extension_type == "desklet":
                self.add_status('locked', 'changes-prevent-symbolic', _("This is a system desklet. It cannot be removed."))
            elif self.extension_type == "extension":
                self.add_status('locked', 'changes-prevent-symbolic', _("This is a system extension. It cannot be removed."))

        try:
            schema_filename = self.metadata['schema-file']
        except (KeyError, ValueError):
            schema_filename = ''

        if self.writable:
            self.scan_extension_for_danger(self.metadata['path'])

        self.version_supported = False
        try:
            self.version_supported = curr_ver in self.metadata['cinnamon-version'] or curr_ver.rsplit('.', 1)[0] in self.metadata['cinnamon-version']
        except (KeyError, ValueError):
            self.version_supported = True # Don't check version if not specified.