gSharkDown / lib /

from gi.repository import Gtk as gtk
from gi.repository import GObject as gobject
from enviroment import config, env
from PlayList import PlayList

class PlayListStyleWidget(gtk.Button):
    def __init__(self):
        gtk.Button.__init__(self) = gtk.Menu()
        group = []
        menu_items = [
            (PlayList.TEXT_BELOW_ICONS, _("Text below icons"),),
            (PlayList.TEXT_BESIDE_ICONS, _("Text beside icons"),),
#            (PlayList.ICONS_BIG, _("Icons only (big)"),),
#            (PlayList.ICONS_SMALL, _("Icons only (small)"),),
            (PlayList.NOT_SHOW, _("Not show"),),

        first_item_widget = None

        for item in menu_items:
            item_widget = gtk.RadioMenuItem.new_with_label(group, item[1])
            if first_item_widget == None:
                first_item_widget = item_widget

            if item[0] == str(config()["playlist_style"]):

            item_widget.connect("activate", self.on_item_activate, item[0])
        self.set_image(gtk.Image.new_from_file("%s/data/playlist_style.png" % env().BASEPATH))

#         if env().have_playlist_style() == True:
#             self.connect("clicked", self.on_clicked)
#             self.set_tooltip_text(_("Change the playlist style"))
#         else:
        self.set_tooltip_text(_("Please update your version of PyGtk\nto change the playlist style"))

    def on_clicked(self, button):, None, self.menu_reposition_callback, 0, 0)

    def menu_reposition_callback(self, menu, data = None):
        return (
            self.get_parent_window().get_origin()[0] + self.get_allocation().x,
            self.get_parent_window().get_origin()[1] + self.get_allocation().y + self.get_allocation().height - 5,

    def on_item_activate(self, menuitem, style):
        if menuitem.get_active() == True:
            config()["playlist_style"] = style
            self.emit("style-changed", style)

gobject.signal_new("style-changed", PlayListStyleWidget, gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_STRING,))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.