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
def __init__(self, arrow_down=False): """arrow_down -- the direction of the menu and arrow icon""" super(ShuffleButton, self).__init__() context = self.get_style_context() context.add_class(Gtk.STYLE_CLASS_LINKED) # shuffle button b = Gtk.ToggleButton(image=SymbolicIconImage( "media-playlist-shuffle", Gtk.IconSize.SMALL_TOOLBAR)) b.set_tooltip_text(_("Toggle shuffle mode")) b.show_all() qltk.add_css( b, """ * { padding: 0px; } """) b.set_size_request(26, 26) self.pack_start(b, True, True, 0) def forward_signal(*args): self.emit("toggled") b.connect("toggled", forward_signal) self._toggle_button = b # arrow from quodlibet.qltk.menubutton import MenuButton b = MenuButton(arrow=True, down=arrow_down) b.show_all() b.set_size_request(20, 26) qltk.add_css( b, """ * { padding: 0px; } """) self.pack_start(b, True, True, 0) self._menu_button = b
def __init__(self, arrow_down=False): """arrow_down -- the direction of the menu and arrow icon""" super(ShuffleButton, self).__init__() context = self.get_style_context() context.add_class(Gtk.STYLE_CLASS_LINKED) # shuffle button b = Gtk.ToggleButton(image=SymbolicIconImage( "media-playlist-shuffle", Gtk.IconSize.SMALL_TOOLBAR)) b.set_tooltip_text(_("Toggle shuffle mode")) b.show_all() qltk.add_css(b, """ * { padding: 0px; } """) b.set_size_request(26, 26) self.pack_start(b, True, True, 0) def forward_signal(*args): self.emit("toggled") b.connect("toggled", forward_signal) self._toggle_button = b # arrow from quodlibet.qltk.menubutton import MenuButton b = MenuButton(arrow=True, down=arrow_down) b.show_all() b.set_size_request(20, 26) qltk.add_css(b, """ * { padding: 0px; } """) self.pack_start(b, True, True, 0) self._menu_button = b