예제 #1
0
    def refresh(self, new_app_data):
        old_app_data = self._app
        self._app = new_app_data

        if old_app_data["icon"] != new_app_data["icon"]:
            self._icon.set_from_pixbuf(
                get_app_icon(new_app_data['icon']).get_pixbuf())

        if "colour" in new_app_data and old_app_data["colour"] != new_app_data[
                "colour"]:
            self.modify_bg(Gtk.StateType.NORMAL,
                           Gdk.color_parse(new_app_data["colour"]))

        self._set_title(new_app_data)
        self._set_tagline(new_app_data)

        # Refresh update button
        if "_update" in old_app_data and "_update" not in new_app_data:
            # remove button
            self._update_btn.destroy()
            self._update_btn = None
        if "_update" not in old_app_data and "_update" in new_app_data:
            # add button
            self._setup_update_button()

        # Refresh description button
        if "description" in old_app_data and "description" not in new_app_data:
            # remove button
            self._more_btn.destroy()
            self._more_btn = None
        if "description" not in old_app_data and "description" in new_app_data:
            # add button
            self._setup_desc_button()

        # Refresh remove button
        if "removable" in old_app_data and "removable" not in new_app_data:
            # remove button
            self._remove_btn.destroy()
            self._remove_btn = None
        if "removable" not in old_app_data and "removable" in new_app_data:
            # add button
            self._setup_remove_button()

        # Refresh desktop button
        if (("_install" in old_app_data and "_install" in new_app_data and
            old_app_data["_install"] == new_app_data["_install"]) or
            "_install" not in old_app_data and "_install" not in new_app_data) and \
            (("desktop" in old_app_data and "desktop" in new_app_data and
             old_app_data["desktop"] == new_app_data["desktop"]) or
             "desktop" not in old_app_data and "desktop" not in new_app_data):
            if self._desktop_btn:
                self._desktop_btn.refresh()
            else:
                self._setup_desktop_button()
        else:
            if self._desktop_btn:
                self._desktop_btn.destroy()
            self._setup_desktop_button()

        self.show_all()
예제 #2
0
    def __init__(self, app, window, apps_obj):
        Gtk.EventBox.__init__(self)

        self.props.valign = Gtk.Align.START

        self._apps = apps_obj

        self._app = app
        self._cmd = app['launch_command']

        self._window = window
        self._entry = entry = Gtk.HBox()

        self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(app['colour']))

        self._icon = get_app_icon(app['icon'])
        self._icon.props.margin = 21
        entry.pack_start(self._icon, False, False, 0)

        texts = Gtk.VBox()

        # Initialise the app title label
        self._app_name = app_name = Gtk.Label("",
                                              halign=Gtk.Align.START,
                                              valign=Gtk.Align.CENTER,
                                              hexpand=True)
        app_name.get_style_context().add_class('app_name')
        app_name.props.margin_top = 28
        texts.pack_start(app_name, False, False, 0)
        self._set_title(app)

        # Initialise the app desc label
        self._app_desc = app_desc = Gtk.Label("",
                                              halign=Gtk.Align.START,
                                              valign=Gtk.Align.START,
                                              hexpand=True)
        app_desc.get_style_context().add_class('app_desc')
        app_desc.props.margin_bottom = 25
        texts.pack_start(app_desc, False, False, 0)
        self._set_tagline(app)

        entry.pack_start(texts, True, True, 0)

        self._update_btn = None
        if "_update" in self._app and self._app["_update"] is True:
            self._setup_update_button()

        self._more_btn = None
        if "description" in self._app:
            self._setup_desc_button()

        self._remove_btn = None
        if "removable" in self._app and self._app["removable"] is True:
            self._setup_remove_button()

        self._setup_desktop_button()

        self.add(entry)
        attach_cursor_events(self)
        self.connect("button-press-event", self._entry_click_cb)
예제 #3
0
    def refresh(self, new_app_data):
        old_app_data = self._app
        self._app = new_app_data

        if old_app_data["icon"] != new_app_data["icon"]:
            self._icon.set_from_pixbuf(get_app_icon(new_app_data['icon']).get_pixbuf())

        if "colour" in new_app_data and old_app_data["colour"] != new_app_data["colour"]:
            self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(new_app_data["colour"]))

        self._set_title(new_app_data)
        self._set_tagline(new_app_data)

        # Refresh update button
        if "_update" in old_app_data and "_update" not in new_app_data:
            # remove button
            self._update_btn.destroy()
            self._update_btn = None
        if "_update" not in old_app_data and "_update" in new_app_data:
            # add button
            self._setup_update_button()

        # Refresh description button
        if "description" in old_app_data and "description" not in new_app_data:
            # remove button
            self._more_btn.destroy()
            self._more_btn = None
        if "description" not in old_app_data and "description" in new_app_data:
            # add button
            self._setup_desc_button()

        # Refresh remove button
        if "removable" in old_app_data and "removable" not in new_app_data:
            # remove button
            self._remove_btn.destroy()
            self._remove_btn = None
        if "removable" not in old_app_data and "removable" in new_app_data:
            # add button
            self._setup_remove_button()

        # Refresh desktop button
        if (("_install" in old_app_data and "_install" in new_app_data and
            old_app_data["_install"] == new_app_data["_install"]) or
            "_install" not in old_app_data and "_install" not in new_app_data) and \
            (("desktop" in old_app_data and "desktop" in new_app_data and
             old_app_data["desktop"] == new_app_data["desktop"]) or
             "desktop" not in old_app_data and "desktop" not in new_app_data):
            if self._desktop_btn:
                self._desktop_btn.refresh()
            else:
                self._setup_desktop_button()
        else:
            if self._desktop_btn:
                self._desktop_btn.destroy()
            self._setup_desktop_button()

        self.show_all()
예제 #4
0
    def __init__(self, app, window, apps_obj):
        Gtk.EventBox.__init__(self)

        self.props.valign = Gtk.Align.START

        self._apps = apps_obj

        self._app = app
        self._cmd = app['launch_command']

        self._window = window
        self._entry = entry = Gtk.HBox()

        self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(app['colour']))

        self._icon = get_app_icon(app['icon'])
        self._icon.props.margin = 21
        entry.pack_start(self._icon, False, False, 0)

        texts = Gtk.VBox()

        # Initialise the app title label
        self._app_name = app_name = Gtk.Label(
            "",
            halign=Gtk.Align.START,
            valign=Gtk.Align.CENTER,
            hexpand=True
        )
        app_name.get_style_context().add_class('app_name')
        app_name.props.margin_top = 28
        texts.pack_start(app_name, False, False, 0)
        self._set_title(app)

        # Initialise the app desc label
        self._app_desc = app_desc = Gtk.Label(
            "",
            halign=Gtk.Align.START,
            valign=Gtk.Align.START,
            hexpand=True
        )
        app_desc.get_style_context().add_class('app_desc')
        app_desc.props.margin_bottom = 25
        texts.pack_start(app_desc, False, False, 0)
        self._set_tagline(app)

        entry.pack_start(texts, True, True, 0)

        self._update_btn = None
        if "_update" in self._app and self._app["_update"] is True:
            self._setup_update_button()

        self._more_btn = None
        if "description" in self._app:
            self._setup_desc_button()

        self._remove_btn = None
        if "removable" in self._app and self._app["removable"] is True:
            self._setup_remove_button()

        self._setup_desktop_button()

        self.add(entry)
        attach_cursor_events(self)
        self.connect("button-press-event", self._entry_click_cb)