Пример #1
0
 def cell_data2(col, render, model, iter_, data):
     plugin = model.get_value(iter_)
     icon = plugin.icon or Gtk.STOCK_EXECUTE
     if Gtk.stock_lookup(icon):
         render.set_property('stock-id', icon)
     else:
         render.set_property('icon-name', icon)
Пример #2
0
    def __init__(self, label, stock=None):
        """An menu item with an (option) icon.

        you can use this in three different ways:

        ContextMenuItem('foo')
        ContextMenuItem('foo', Gtk.STOCK_PASTE)
        ContextMenuItem(Gtk.STOCK_PASTE)

        The first will display an label 'foo'. The second will display the same label with the
        paste icon, and the last will display the paste icon with the default paste label
        """
        Gtk.ImageMenuItem.__init__(self)

        if not stock:
            stock = label
            info = Gtk.stock_lookup(label)
            if info:
                try:
                    label = info.label
                # For PyGTk
                except AttributeError:
                    label = info[1]

        lbl = Gtk.AccelLabel(label=label)
        lbl.set_alignment(0, 0.5)
        lbl.set_use_underline(True)
        lbl.set_use_markup(True)
        self.add(lbl)

        image = Gtk.Image()
        image.set_from_stock(stock, Gtk.IconSize.MENU)
        self.set_image(image)
Пример #3
0
 def cell_data2(col, render, model, iter_, data):
     plugin = model.get_value(iter_)
     icon = plugin.icon or Gtk.STOCK_EXECUTE
     if Gtk.stock_lookup(icon):
         render.set_property('stock-id', icon)
     else:
         render.set_property('icon-name', icon)
Пример #4
0
    def __init__(self, label, stock=None):
        """An menu item with an (option) icon.

        you can use this in three different ways:

        ContextMenuItem('foo')
        ContextMenuItem('foo', Gtk.STOCK_PASTE)
        ContextMenuItem(Gtk.STOCK_PASTE)

        The first will display an label 'foo'. The second will display the same label with the
        paste icon, and the last will display the paste icon with the default paste label
        """
        Gtk.ImageMenuItem.__init__(self)

        if not stock:
            stock = label
            info = Gtk.stock_lookup(label)
            if info:
                try:
                    label = info.label
                # For PyGTk
                except AttributeError:
                    label = info[1]

        lbl = Gtk.AccelLabel(label=label)
        lbl.set_alignment(0, 0.5)
        lbl.set_use_underline(True)
        lbl.set_use_markup(True)
        self.add(lbl)

        image = Gtk.Image()
        image.set_from_stock(stock, Gtk.IconSize.MENU)
        self.set_image(image)
Пример #5
0
		def set_label(*args):
			label = menu_child_gtk.get_label()
			if isinstance(menu_child_gtk, Gtk.ImageMenuItem) and menu_child_gtk.get_use_stock():
				label = Gtk.stock_lookup(label).label
			if isinstance(label, str):
				label = label.decode(locale.getpreferredencoding())
			if menu_child_gtk.get_use_underline():
				label = label.replace("_", "&")
			action.setText(label)
Пример #6
0
    def __set_icon(self):
        """Sets the GTK icon for this plugin item"""
        icon = getattr(self, "PLUGIN_ICON", Gtk.STOCK_EXECUTE)

        image = (Gtk.Image.new_from_stock(icon, Gtk.IconSize.MENU)
                 if Gtk.stock_lookup(icon) else Gtk.Image.new_from_icon_name(
                     icon, Gtk.IconSize.MENU))
        self.set_always_show_image(True)
        self.set_image(image)
Пример #7
0
    def __set_icon(self):
        """Sets the GTK icon for this plugin item"""
        icon = getattr(self, "PLUGIN_ICON", Gtk.STOCK_EXECUTE)

        image = (Gtk.Image.new_from_stock(icon, Gtk.IconSize.MENU)
                 if Gtk.stock_lookup(icon)
                 else Gtk.Image.new_from_icon_name(icon, Gtk.IconSize.MENU))
        self.set_always_show_image(True)
        self.set_image(image)
Пример #8
0
    def __update_paused(self, player, paused):
        menu = self.ui.get_widget("/Menu/Control/PlayPause")

        if paused:
            key = Gtk.STOCK_MEDIA_PLAY
        else:
            key = Gtk.STOCK_MEDIA_PAUSE
        text = Gtk.stock_lookup(key).label
        menu.get_image().set_from_stock(key, Gtk.IconSize.MENU)
        menu.set_label(text)
        menu.set_use_underline(True)
Пример #9
0
 def append_toggle(self, stock, signal, accelerator = None, toggled = True):
     info = Gtk.stock_lookup(stock)
     label = info.label if info else stock
     menuitem = Gtk.CheckMenuItem(label)
     menuitem.set_active(toggled)
     self.submenu.append(menuitem)
     menuitem.connect("toggled", self.activate, signal)
     self.install_signal(signal)
     if accelerator:
         key, mask = Gtk.accelerator_parse(accelerator)
         menuitem.add_accelerator("toggled", self.application.bindings, key, mask, Gtk.AccelFlags.VISIBLE)
Пример #10
0
    def __update_paused(self, player, paused):
        menu = self.ui.get_widget("/Menu/Control/PlayPause")

        if paused:
            key = Gtk.STOCK_MEDIA_PLAY
        else:
            key = Gtk.STOCK_MEDIA_PAUSE
        text = Gtk.stock_lookup(key).label
        menu.get_image().set_from_stock(key, Gtk.IconSize.MENU)
        menu.set_label(text)
        menu.set_use_underline(True)
Пример #11
0
def MenuItem(label, stock_id):
    """An ImageMenuItem with a custom label and stock image."""

    item = Gtk.ImageMenuItem.new_with_mnemonic(label)
    item.set_always_show_image(True)
    if Gtk.stock_lookup(stock_id):
        image = Gtk.Image.new_from_stock(stock_id, Gtk.IconSize.MENU)
    else:
        image = Gtk.Image.new_from_icon_name(stock_id, Gtk.IconSize.MENU)
    image.show()
    item.set_image(image)
    return item
Пример #12
0
def MenuItem(label, stock_id):
    """An ImageMenuItem with a custom label and stock image."""

    item = Gtk.ImageMenuItem.new_with_mnemonic(label)
    item.set_always_show_image(True)
    if Gtk.stock_lookup(stock_id):
        image = Gtk.Image.new_from_stock(stock_id, Gtk.IconSize.MENU)
    else:
        image = Gtk.Image.new_from_icon_name(stock_id, Gtk.IconSize.MENU)
    image.show()
    item.set_image(image)
    return item
Пример #13
0
    def create_stock_icon_store(self):
        stock_id = (Gtk.STOCK_DIALOG_WARNING, Gtk.STOCK_STOP, Gtk.STOCK_NEW,
                    Gtk.STOCK_CLEAR, None, Gtk.STOCK_OPEN)

        cellview = Gtk.CellView()
        store = Gtk.ListStore(GdkPixbuf.Pixbuf, str)

        for id in stock_id:
            if id is not None:
                pixbuf = cellview.render_icon(id, Gtk.IconSize.BUTTON, None)
                item = Gtk.stock_lookup(id)
                label = self.strip_underscore(item.label)
                store.append((pixbuf, label))
            else:
                store.append((None, 'separator'))

        return store
Пример #14
0
def Button(label, stock_id, size=Gtk.IconSize.BUTTON):
    """A Button with a custom label and stock image. It should pack
    exactly like a stock button."""

    align = Align(halign=Gtk.Align.CENTER, valign=Gtk.Align.CENTER)
    hbox = Gtk.HBox(spacing=2)
    if Gtk.stock_lookup(stock_id):
        image = Gtk.Image.new_from_stock(stock_id, size)
    else:
        image = Gtk.Image.new_from_icon_name(stock_id, size)
    hbox.pack_start(image, True, True, 0)
    label = Gtk.Label(label=label)
    label.set_use_underline(True)
    hbox.pack_start(label, True, True, 0)
    align.add(hbox)
    align.show_all()
    button = Gtk.Button()
    button.add(align)
    return button
Пример #15
0
def Button(label, stock_id, size=Gtk.IconSize.BUTTON):
    """A Button with a custom label and stock image. It should pack
    exactly like a stock button."""

    align = Gtk.Alignment(xscale=0.0, yscale=1.0, xalign=0.5, yalign=0.5)
    hbox = Gtk.HBox(spacing=2)
    if Gtk.stock_lookup(stock_id):
        image = Gtk.Image.new_from_stock(stock_id, size)
    else:
        image = Gtk.Image.new_from_icon_name(stock_id, size)
    hbox.pack_start(image, True, True, 0)
    label = Gtk.Label(label=label)
    label.set_use_underline(True)
    hbox.pack_start(label, True, True, 0)
    align.add(hbox)
    align.show_all()
    button = Gtk.Button()
    button.add(align)
    return button
Пример #16
0
    def create_stock_icon_store(self):
        stock_id = (Gtk.STOCK_DIALOG_WARNING,
                    Gtk.STOCK_STOP,
                    Gtk.STOCK_NEW,
                    Gtk.STOCK_CLEAR,
                    None,
                    Gtk.STOCK_OPEN)

        cellview = Gtk.CellView()
        store = Gtk.ListStore(GdkPixbuf.Pixbuf, str)

        for id in stock_id:
            if id is not None:
                pixbuf = cellview.render_icon(id, Gtk.IconSize.BUTTON, None)
                item = Gtk.stock_lookup(id)
                label = self.strip_underscore(item.label)
                store.append((pixbuf, label))
            else:
                store.append((None, 'separator'))

        return store
Пример #17
0
    def __init__(self, parent, main):
        """
            Initializes the preferences dialog
        """
        self.main = main
        self.last_child = None
        self.last_page = None
        self.parent = parent
        self.settings = MANAGER
        self.fields = {}
        self.panes = {}
        self.builders = {}
        self.popup = None

        self.builder = Gtk.Builder()
        self.builder.set_translation_domain('exaile')
        self.builder.add_from_file(
            xdg.get_data_path('ui', 'preferences', 'preferences_dialog.ui'))
        self.builder.connect_signals(self)

        self.window = self.builder.get_object('PreferencesDialog')
        self.window.set_transient_for(parent)
        self.window.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
        self.window.connect('delete-event', lambda *e: self.close())

        self.box = self.builder.get_object('preferences_box')

        self.tree = self.builder.get_object('preferences_tree')
        self.model = self.builder.get_object('model')

        title_cellrenderer = self.builder.get_object('title_cellrenderer')
        title_cellrenderer.props.ypad = 3

        self.default_icon = icons.MANAGER.pixbuf_from_stock(
            Gtk.STOCK_PROPERTIES, Gtk.IconSize.MENU)

        # sets up the default panes
        for page in self.PAGES:
            icon = self.default_icon

            if hasattr(page, 'icon'):
                if isinstance(page.icon, GdkPixbuf.Pixbuf):
                    icon = page.icon
                else:
                    stock = Gtk.stock_lookup(page.icon)

                    if stock is not None:
                        icon = icons.MANAGER.pixbuf_from_stock(
                            stock.stock_id , Gtk.IconSize.MENU)
                    else:
                        icon = icons.MANAGER.pixbuf_from_icon_name(
                            page.icon, Gtk.IconSize.MENU)

            self.model.append(None, [page, page.name, icon])

        # Use icon name to allow overrides
        plugin_icon = icons.MANAGER.pixbuf_from_icon_name(
            'extension', Gtk.IconSize.MENU)
        self.plug_root = self.model.append(None,
            [plugin, _('Plugins'), plugin_icon])

        self._load_plugin_pages()

        selection = self.tree.get_selection()
        selection.connect('changed', self.switch_pane)
        # Disallow selection on rows with no widget to show
        selection.set_select_function(
            (lambda sel, model, path, issel, dat: model[path][0] is not None),
            None)

        GLib.idle_add(selection.select_path, (0,))
Пример #18
0
def _stock (stock_id, mnemonic = True) :
	label = Gtk.stock_lookup(stock_id).label
	if not mnemonic : return label.replace('_', '')
	return label
Пример #19
0
    def __init__(self, parent, main):
        """
            Initializes the preferences dialog
        """
        self.main = main
        self.last_child = None
        self.last_page = None
        self.parent = parent
        self.settings = MANAGER
        self.fields = {}
        self.panes = {}
        self.builders = {}
        self.popup = None

        self.builder = Gtk.Builder()
        self.builder.set_translation_domain('exaile')
        self.builder.add_from_file(
            xdg.get_data_path('ui', 'preferences', 'preferences_dialog.ui'))
        self.builder.connect_signals(self)

        self.window = self.builder.get_object('PreferencesDialog')
        self.window.set_transient_for(parent)
        self.window.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
        self.window.connect('delete-event', lambda *e: self.close())

        self.box = self.builder.get_object('preferences_box')

        self.tree = self.builder.get_object('preferences_tree')
        self.model = self.builder.get_object('model')

        title_cellrenderer = self.builder.get_object('title_cellrenderer')
        title_cellrenderer.props.ypad = 3

        self.default_icon = icons.MANAGER.pixbuf_from_stock(
            Gtk.STOCK_PROPERTIES, Gtk.IconSize.MENU)

        # sets up the default panes
        for page in self.PAGES:
            icon = self.default_icon

            if hasattr(page, 'icon'):
                if isinstance(page.icon, GdkPixbuf.Pixbuf):
                    icon = page.icon
                else:
                    stock = Gtk.stock_lookup(page.icon)

                    if stock is not None:
                        icon = icons.MANAGER.pixbuf_from_stock(
                            stock.stock_id, Gtk.IconSize.MENU)
                    else:
                        icon = icons.MANAGER.pixbuf_from_icon_name(
                            page.icon, Gtk.IconSize.MENU)

            self.model.append(None, [page, page.name, icon])

        # Use icon name to allow overrides
        plugin_icon = icons.MANAGER.pixbuf_from_icon_name(
            'extension', Gtk.IconSize.MENU)
        self.plug_root = self.model.append(
            None, [plugin, _('Plugins'), plugin_icon])

        self._load_plugin_pages()

        selection = self.tree.get_selection()
        selection.connect('changed', self.switch_pane)
        # Disallow selection on rows with no widget to show
        selection.set_select_function(
            (lambda sel, model, path, issel, dat: model[path][0] is not None),
            None)

        GLib.idle_add(selection.select_path, (0, ))