Ejemplo n.º 1
0
    def get_icon(self, name):
        # FIXME: Special hacks for current (bad) news file
        if name == "Ximian GNOME":
            name = "Ximian Desktop"

        if name == "OpenOffice":
            name = "OpenOffice.org"

        channels = rcd_util.get_all_channels()
        for c in channels:
            if c["name"] == name:
                return rcd_util.get_channel_icon(c["id"])

        return None
Ejemplo n.º 2
0
    def get_icon(self, name):
        # FIXME: Special hacks for current (bad) news file
        if name == "Ximian GNOME":
            name = "Ximian Desktop"

        if name == "OpenOffice":
            name = "OpenOffice.org"

        channels = rcd_util.get_all_channels()
        for c in channels:
            if c["name"] == name:
                return rcd_util.get_channel_icon(c["id"])

        return None
Ejemplo n.º 3
0
    def __assemble(self):
        self.item_id_list = []
        menu = gtk.Menu()

        channels = rcd_util.get_all_channels()
        channels.sort(lambda x,y:cmp(string.lower(x["name"]),
                                     string.lower(y["name"])))

        if self.__allow_any_channel:
            channels.insert(0, {"name": _("All Catalogs"),
                                "id": MATCH_ANY_CHANNEL})

        if self.__allow_any_subd_channel:
            channels.insert(0,
                            {"name": _("All Subscribed Catalogs"),
                             "id": MATCH_ANY_SUBD_CHANNEL,
                             "subscribed": 1})

        if self.__allow_no_channel:
            channels.append({"name": _("No Catalog/Unknown Catalog"),
                             "id": MATCH_NO_CHANNEL})

        width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU)
        for c in channels:
            hbox = gtk.HBox(0, 0)

            if not is_channel_wildcard(c["id"]):
                pixbuf = rcd_util.get_channel_icon(c["id"], 24, 24)
            else:
                pixbuf = None
                
            img = gtk.Image()
            img.set_size_request(24, 24)
            if pixbuf:
                img.set_from_pixbuf(pixbuf)

            label = gtk.Label(c["name"])

            hbox.pack_start(img, 0, 0, 0)
            hbox.pack_start(label, 0, 0, 4)

            if c.get("subscribed"):
                sub_img = red_pixbuf.get_widget("status-installed",
                                                width=width, height=height)
                hbox.pack_end(sub_img, expand=0, fill=0, padding=2)


            item = gtk.MenuItem()
            item.add(hbox)
            item.show_all()

            self.item_id_list.append(c["id"])

            def activate_cb(item, id, opt):
                if id != self.__last_id:
                    opt.__last_id = id
                    opt.emit("selected", id)
            item.connect("activate", activate_cb, c["id"], self)
            
            menu.append(item)

        menu.show()
        self.set_menu(menu)
Ejemplo n.º 4
0
        alias = string.replace(alias, "-gnome-", "-")
        if string.find(alias, "red-hat") == 0:
            alias = "redhat"

        return alias


COLUMNS = (
    ("CHANNEL", lambda x: x, gobject.TYPE_PYOBJECT),
    ("ID", lambda x: x["id"], gobject.TYPE_STRING),
    ("NAME", lambda x: x["name"], gobject.TYPE_STRING),
    ("ALIAS", lambda x: get_alias(x), gobject.TYPE_STRING),
    ("HIDDEN", lambda x: x["hidden"], gobject.TYPE_BOOLEAN),
    ("SUBSCRIBED", lambda x: x["subscribed"], gobject.TYPE_BOOLEAN),
    ("MOUNTED", lambda x: x["mounted"], gobject.TYPE_BOOLEAN),
    ("ICON", lambda x: rcd_util.get_channel_icon(x["id"], 28, 28),
     gtk.gdk.Pixbuf),
    ("DESCRIPTION", lambda x: x["description"], gobject.TYPE_STRING),
)

for i in range(len(COLUMNS)):
    name = COLUMNS[i][0]
    exec("COLUMN_%s = %d" % (name, i))


def sort_channels_by_name(a, b):
    return cmp(string.lower(a["name"]), string.lower(b["name"]))


class ChannelModel(red_listmodel.ListModel, red_serverlistener.ServerListener):
    def __init__(self, sort_fn=sort_channels_by_name, filter_fn=None):
Ejemplo n.º 5
0
        alias = string.replace(alias, "-gnome-", "-")
        if string.find(alias, "red-hat") == 0:
            alias = "redhat"

        return alias


COLUMNS = (
    ("CHANNEL", lambda x: x, gobject.TYPE_PYOBJECT),
    ("ID", lambda x: x["id"], gobject.TYPE_STRING),
    ("NAME", lambda x: x["name"], gobject.TYPE_STRING),
    ("ALIAS", lambda x: get_alias(x), gobject.TYPE_STRING),
    ("HIDDEN", lambda x: x["hidden"], gobject.TYPE_BOOLEAN),
    ("SUBSCRIBED", lambda x: x["subscribed"], gobject.TYPE_BOOLEAN),
    ("MOUNTED", lambda x: x["mounted"], gobject.TYPE_BOOLEAN),
    ("ICON", lambda x: rcd_util.get_channel_icon(x["id"], 28, 28), gtk.gdk.Pixbuf),
    ("DESCRIPTION", lambda x: x["description"], gobject.TYPE_STRING),
)

for i in range(len(COLUMNS)):
    name = COLUMNS[i][0]
    exec ("COLUMN_%s = %d" % (name, i))


def sort_channels_by_name(a, b):
    return cmp(string.lower(a["name"]), string.lower(b["name"]))


class ChannelModel(red_listmodel.ListModel, red_serverlistener.ServerListener):
    def __init__(self, sort_fn=sort_channels_by_name, filter_fn=None):
        red_listmodel.ListModel.__init__(self, sort_fn, filter_fn)
Ejemplo n.º 6
0
    def __assemble(self):
        self.item_id_list = []
        menu = gtk.Menu()

        channels = rcd_util.get_all_channels()
        channels.sort(
            lambda x, y: cmp(string.lower(x["name"]), string.lower(y["name"])))

        if self.__allow_any_channel:
            channels.insert(0, {
                "name": _("All Catalogs"),
                "id": MATCH_ANY_CHANNEL
            })

        if self.__allow_any_subd_channel:
            channels.insert(
                0, {
                    "name": _("All Subscribed Catalogs"),
                    "id": MATCH_ANY_SUBD_CHANNEL,
                    "subscribed": 1
                })

        if self.__allow_no_channel:
            channels.append({
                "name": _("No Catalog/Unknown Catalog"),
                "id": MATCH_NO_CHANNEL
            })

        width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU)
        for c in channels:
            hbox = gtk.HBox(0, 0)

            if not is_channel_wildcard(c["id"]):
                pixbuf = rcd_util.get_channel_icon(c["id"], 24, 24)
            else:
                pixbuf = None

            img = gtk.Image()
            img.set_size_request(24, 24)
            if pixbuf:
                img.set_from_pixbuf(pixbuf)

            label = gtk.Label(c["name"])

            hbox.pack_start(img, 0, 0, 0)
            hbox.pack_start(label, 0, 0, 4)

            if c.get("subscribed"):
                sub_img = red_pixbuf.get_widget("status-installed",
                                                width=width,
                                                height=height)
                hbox.pack_end(sub_img, expand=0, fill=0, padding=2)

            item = gtk.MenuItem()
            item.add(hbox)
            item.show_all()

            self.item_id_list.append(c["id"])

            def activate_cb(item, id, opt):
                if id != self.__last_id:
                    opt.__last_id = id
                    opt.emit("selected", id)

            item.connect("activate", activate_cb, c["id"], self)

            menu.append(item)

        menu.show()
        self.set_menu(menu)