Exemple #1
0
    def __init__(self,
                 icon_name,
                 orders,
                 current_order,
                 enabled=False,
                 tooltip=None,
                 arrow_down=False):
        """arrow_down -- the direction of the menu and arrow icon"""
        assert issubclass(current_order, Order)
        if current_order not in orders:
            raise ValueError("%s is not supported by %s" %
                             (current_order.__name__, orders))

        super(ToggledPlayOrderMenu, self).__init__()
        self.__inhibit = True

        context = self.get_style_context()
        context.add_class(Gtk.STYLE_CLASS_LINKED)

        self._toggle_button = toggle = HighlightToggleButton(
            image=SymbolicIconImage(icon_name, Gtk.IconSize.SMALL_TOOLBAR))

        if tooltip:
            toggle.set_tooltip_text(tooltip)
        toggle.set_active(enabled)
        toggle.show_all()
        qltk.remove_padding(toggle)
        toggle.set_size_request(26, 26)
        self.pack_start(toggle, True, True, 0)

        def forward_signal(*args):
            if not self.__inhibit:
                self.emit("toggled")

        toggle.connect("toggled", forward_signal)
        self._toggle_button = toggle

        from quodlibet.qltk.menubutton import MenuButton
        arrow = MenuButton(arrow=True, down=arrow_down)
        arrow.show_all()
        arrow.set_size_request(20, 26)
        qltk.remove_padding(arrow)
        self.pack_start(arrow, True, True, 0)
        self._menu_button = arrow
        self.__current = current_order
        self.__orders = orders
        self.__rebuild_menu()
        self.__inhibit = False
Exemple #2
0
    def __init__(self, icon_name, orders, current_order, enabled=False,
                 tooltip=None, arrow_down=False):
        """arrow_down -- the direction of the menu and arrow icon"""
        assert issubclass(current_order, Order)
        if current_order not in orders:
            raise ValueError("%s is not supported by %s"
                             % (current_order.__name__, orders))

        super(ToggledPlayOrderMenu, self).__init__()
        self.__inhibit = True

        context = self.get_style_context()
        context.add_class(Gtk.STYLE_CLASS_LINKED)

        self._toggle_button = toggle = HighlightToggleButton(
            image=SymbolicIconImage(icon_name, Gtk.IconSize.SMALL_TOOLBAR))

        if tooltip:
            toggle.set_tooltip_text(tooltip)
        toggle.set_active(enabled)
        toggle.show_all()
        qltk.remove_padding(toggle)
        toggle.set_size_request(26, 26)
        self.pack_start(toggle, True, True, 0)

        def forward_signal(*args):
            if not self.__inhibit:
                self.emit("toggled")

        toggle.connect("toggled", forward_signal)
        self._toggle_button = toggle

        from quodlibet.qltk.menubutton import MenuButton
        arrow = MenuButton(arrow=True, down=arrow_down)
        arrow.show_all()
        arrow.set_size_request(20, 26)
        qltk.remove_padding(arrow)
        self.pack_start(arrow, True, True, 0)
        self._menu_button = arrow
        self.__current = current_order
        self.__orders = orders
        self.__rebuild_menu()
        self.__inhibit = False