def _setup_headerbar(self): # define the main buttons for the headerbar builder = Gtk.Builder() ui = rb.find_plugin_file(self.plugin, 'ui/altlibrary.ui') builder.add_from_file(ui) self.load_builder_content(builder) view_name = "Categories" self.library_browser_radiobutton.set_label(view_name) default = Gtk.Settings.get_default() self.headerbar = Gtk.HeaderBar.new() self.headerbar.set_show_close_button(True) self.main_window.set_titlebar(self.headerbar) # this is needed for gnome-shell to replace the decoration self.main_window.set_show_menubar(False) self.plugin.rb_toolbar.hide() self.start_box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0) # left side box self.headerbar.pack_start(self.start_box) self.headerbar.set_custom_title(self.library_box) self._end_box_controls = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0) # right side box self.end_box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0) # any source defined controls self._end_box_controls.add(self.end_box) if (not default.props.gtk_shell_shows_app_menu) or default.props.gtk_shell_shows_menubar: # for environments that dont support app-menus menu_button = Gtk.MenuButton.new() # menu_button.set_relief(Gtk.ReliefStyle.NONE) if gtk_version() >= 3.14: symbol = "open-menu-symbolic" menu_button.set_margin_start(3) else: symbol = "emblem-system-symbolic" menu_button.set_margin_left(3) image = Gtk.Image.new_from_icon_name(symbol, Gtk.IconSize.SMALL_TOOLBAR) menu_button.add(image) menu = self.shell.props.application.get_shared_menu('app-menu') menu_button.set_menu_model(menu) self._end_box_controls.add(menu_button) self.headerbar.pack_end(self._end_box_controls) self.headerbar.show_all() action = self.plugin.toggle_action_group.get_action('ToggleToolbar') if not self.plugin.start_hidden: action.set_active(True) print("not hidden") else: action.set_active(False) self.set_visible(False)
def request_rtl_icon(self, control, icon_name): if gtk_version() < 3.12: if control.get_direction() == Gtk.TextDirection.RTL: rtl_name = {"media-playback-start-symbolic":"media-playback-start-rtl-symbolic", "media-skip-forward-symbolic":"media-skip-forward-rtl-symbolic", "media-skip-backward-symbolic":"media-skip-backward-rtl-symbolic"} icon_name = rtl_name[icon_name] return icon_name
def post_initialise(self): super(AltToolbarShared, self).post_initialise() self.volume_button.props.value = self.shell.props.shell_player.props.volume self.volume_button.bind_property("value", self.shell.props.shell_player, "volume", Gio.SettingsBindFlags.DEFAULT) self.volume_button.set_visible(self.plugin.volume_control) self.volume_button.set_relief(Gtk.ReliefStyle.NORMAL) child = self.volume_button.get_child() child.set_margin_left(5) child.set_margin_right(5) if self.plugin.inline_label: self.song_box.remove(self.song_button_label) if self.plugin.compact_progressbar: self.song_progress = SmallProgressBar() else: self.song_progress = SmallScale() self.song_progress.connect('control', self._sh_progress_control) self.song_progress.show_all() self.song_progress_box.pack_start(self.song_progress, False, True, 1) # Bring Builtin Actions to plugin for (a, b) in ((self.play_button, "play"), (self.prev_button, "play-previous"), (self.next_button, "play-next"), (self.repeat_toggle, "play-repeat"), (self.shuffle_toggle, "play-shuffle")): a.set_action_name("app." + b) if b == "play-repeat" or b == "play-shuffle": # for some distros you need to set the target_value # for others this would actually disable the action # so work around this by testing if the action is disabled # then reset the action a.set_action_target_value(GLib.Variant("b", True)) print(a.get_sensitive()) if not a.get_sensitive(): a.set_detailed_action_name("app." + b) # The Play-Repeat button is subject to the plugins Repeat All/one song capability self._repeat = Repeat(self.shell, self.repeat_toggle) if gtk_version() >= 3.12: self.cover_popover = Gtk.Popover.new(self.album_cover) image = Gtk.Image.new() self.cover_popover.add(image) self._popover_inprogress = 0 self.cover_popover.set_modal(False) self.cover_popover.connect('leave-notify-event', self._on_cover_popover_mouse_over) self.cover_popover.connect('enter-notify-event', self._on_cover_popover_mouse_over) # detect when mouse moves out of the cover image (it has a parent eventbox) self.album_cover_eventbox.connect('leave-notify-event', self._on_cover_popover_mouse_over) self.album_cover_eventbox.connect('enter-notify-event', self._on_cover_popover_mouse_over)
def _setup_headerbar(self): default = Gtk.Settings.get_default() self.headerbar = Gtk.HeaderBar.new() self.headerbar.set_show_close_button(True) self.main_window.set_titlebar( self.headerbar ) # this is needed for gnome-shell to replace the decoration self.main_window.set_show_menubar(False) self.plugin.rb_toolbar.hide() self.start_box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0) # left side box self.headerbar.pack_start(self.start_box) self.headerbar.set_custom_title(self.library_box) self._end_box_controls = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0) # right side box self.end_box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0) # any source defined controls self._end_box_controls.add(self.end_box) if (not default.props.gtk_shell_shows_app_menu ) or default.props.gtk_shell_shows_menubar: # for environments that dont support app-menus menu_button = Gtk.MenuButton.new() menu_button.set_relief(Gtk.ReliefStyle.NONE) if gtk_version() >= 3.14: symbol = "open-menu-symbolic" else: symbol = "emblem-system-symbolic" image = Gtk.Image.new_from_icon_name(symbol, Gtk.IconSize.SMALL_TOOLBAR) menu_button.add(image) menu = self.shell.props.application.get_shared_menu('app-menu') menu_button.set_menu_model(menu) self._end_box_controls.add(menu_button) self.headerbar.pack_end(self._end_box_controls) self.headerbar.show_all() action = self.plugin.toggle_action_group.get_action('ToggleToolbar') if not self.plugin.start_hidden: action.set_active(True) print("not hidden") else: action.set_active(False) self.set_visible(False)
def show_cover_tooltip(self, tooltip): if ( self.cover_pixbuf is not None ): if gtk_version() >= 3.12: if self.cover_popover.get_visible(): return False image = self.cover_popover.get_child() image.set_from_pixbuf(self.cover_pixbuf.scale_simple(300, 300, GdkPixbuf.InterpType.HYPER)) self.cover_popover.show_all() else: tooltip.set_icon(self.cover_pixbuf.scale_simple(300, 300, GdkPixbuf.InterpType.HYPER)) return True else: return False
def request_rtl_icon(self, control, icon_name): if gtk_version() < 3.12: if control.get_direction() == Gtk.TextDirection.RTL: rtl_name = { "media-playback-start-symbolic": "media-playback-start-rtl-symbolic", "media-skip-forward-symbolic": "media-skip-forward-rtl-symbolic", "media-skip-backward-symbolic": "media-skip-backward-rtl-symbolic" } icon_name = rtl_name[icon_name] return icon_name
def show_cover_tooltip(self, tooltip): if (self.cover_pixbuf is not None): if gtk_version() >= 3.12: if self.cover_popover.get_visible(): return False image = self.cover_popover.get_child() image.set_from_pixbuf( self.cover_pixbuf.scale_simple(300, 300, GdkPixbuf.InterpType.HYPER)) self.cover_popover.show_all() else: tooltip.set_icon( self.cover_pixbuf.scale_simple(300, 300, GdkPixbuf.InterpType.HYPER)) return True else: return False
def post_initialise(self): self.volume_button.bind_property("value", self.shell.props.shell_player, "volume", Gio.SettingsBindFlags.DEFAULT) self.volume_button.props.value = self.shell.props.shell_player.props.volume self.volume_button.set_visible(self.plugin.volume_control) self.volume_button.set_relief(Gtk.ReliefStyle.NORMAL) child = self.volume_button.get_child() child.set_margin_left(5) child.set_margin_right(5) if self.plugin.inline_label: self.song_box.remove(self.song_button_label) if self.plugin.compact_progressbar: self.song_progress = SmallProgressBar() else: self.song_progress = SmallScale() self.song_progress.connect('control', self._sh_progress_control) self.song_progress.show_all() self.song_progress_box.pack_start(self.song_progress, False, True, 1) # Bring Builtin Actions to plugin for (a, b) in ((self.play_button, "play"), (self.prev_button, "play-previous"), (self.next_button, "play-next"), (self.repeat_toggle, "play-repeat"), (self.shuffle_toggle, "play-shuffle")): a.set_action_name("app." + b) if b == "play-repeat" or b == "play-shuffle": # for some distros you need to set the target_value # for others this would actually disable the action # so work around this by testing if the action is disabled # then reset the action a.set_action_target_value(GLib.Variant("b", True)) print(a.get_sensitive()) if not a.get_sensitive(): a.set_detailed_action_name("app." + b) if gtk_version() >= 3.12: self.cover_popover = Gtk.Popover.new(self.album_cover) image = Gtk.Image.new() self.cover_popover.add(image)
def _display_plugins(self, *args): ''' display our implementation of the LibPeas Plugin window ''' has_headerbar = isinstance(self.toolbar_type, AltToolbarHeaderBar) if gtk_version() < 3.12: has_headerbar = False dlg = PluginDialog(self.shell.props.window, has_headerbar) response = 0 dlg.set_default_size(self._plugin_dialog_width, self._plugin_dialog_height) while response >= 0: response = dlg.run() print (response) self._plugin_dialog_width, self._plugin_dialog_height = dlg.get_size() dlg.destroy()
def _display_plugins(self, *args): """ display our implementation of the LibPeas Plugin window """ has_headerbar = isinstance(self.toolbar_type, AltToolbarHeaderBar) if gtk_version() < 3.12: has_headerbar = False dlg = PluginDialog(self.shell.props.window, has_headerbar) response = 0 dlg.set_default_size(self._plugin_dialog_width, self._plugin_dialog_height) while response >= 0: response = dlg.run() print (response) self._plugin_dialog_width, self._plugin_dialog_height = dlg.get_size() dlg.destroy()
def __init__(self, shell, toggle_button): """ :param toggle_button: button that controls the repeat functions :return: """ GObject.Object.__init__(self) # use this to start the repeat-one-song capability (if True) self.repeat_song = False self.shell = shell self.toggle_button = toggle_button # self.one_song_stprint ("adjoining") ate_normal, self.one_song_state_eos = range(2) # self.one_song_state = self.one_song_state_normal player = self.shell.props.shell_player # Please refer to the comments above to understand why those # two callbacks are not being used currently, Rhytmbox 2.99.1 # player.connect('playing-song-changed', self.on_song_change) # player.props.player.connect('eos', self.on_gst_player_eos) player.connect("elapsed-changed", self.on_elapsed_change) if gtk_version() >= 3.12: popover = Gtk.Popover.new(toggle_button) repeat = RepeatPopContainer(popover, toggle_button) popover.add(repeat) popover.set_modal(False) else: # use our custom Popover equivalent for Gtk+3.10 folks popover = CustomPopover(toggle_button) repeat = RepeatPopContainer(popover, toggle_button) popover.add(repeat) toggle_button.connect("toggled", self._on_toggle, popover, repeat) repeat.connect("repeat-type-changed", self._on_repeat_type_changed) self._on_repeat_type_changed(repeat, repeat.get_repeat_type())
def __init__(self, shell, toggle_button): """ :param toggle_button: button that controls the repeat functions :return: """ GObject.Object.__init__(self) # use this to start the repeat-one-song capability (if True) self.repeat_song = False self.shell = shell self.toggle_button = toggle_button # self.one_song_stprint ("adjoining") ate_normal, self.one_song_state_eos = range(2) # self.one_song_state = self.one_song_state_normal player = self.shell.props.shell_player # Please refer to the comments above to understand why those # two callbacks are not being used currently, Rhytmbox 2.99.1 # player.connect('playing-song-changed', self.on_song_change) # player.props.player.connect('eos', self.on_gst_player_eos) player.connect('elapsed-changed', self.on_elapsed_change) if gtk_version() >= 3.12: popover = Gtk.Popover.new(toggle_button) repeat = RepeatPopContainer(popover, toggle_button) popover.add(repeat) popover.set_modal(False) else: # use our custom Popover equivalent for Gtk+3.10 folks popover = CustomPopover(toggle_button) repeat = RepeatPopContainer(popover, toggle_button) popover.add(repeat) toggle_button.connect("toggled", self._on_toggle, popover, repeat) repeat.connect('repeat-type-changed', self._on_repeat_type_changed) self._on_repeat_type_changed(repeat, repeat.get_repeat_type())
def _setup_compactbar(self): # self.window_control_item.add(self._window_controls()) action = self.plugin.toggle_action_group.get_action('ToggleToolbar') self.small_bar.get_style_context().add_class( Gtk.STYLE_CLASS_PRIMARY_TOOLBAR) # add settings menu depending if there is no applications menu # available # appshell = ApplicationShell(self.shell) menu = self.shell.props.application.get_menubar() if not menu: menu_button = Gtk.MenuButton.new() if gtk_version() >= 3.14: symbol = "open-menu-symbolic" menu_button.set_margin_start(3) else: symbol = "emblem-system-symbolic" menu_button.set_margin_left(3) image = Gtk.Image.new_from_icon_name(symbol, Gtk.IconSize.SMALL_TOOLBAR) menu_button.add(image) menu = self.shell.props.application.get_shared_menu('app-menu') menu_button.set_menu_model(menu) self.end_box.add(menu_button) if not self.plugin.start_hidden: self.shell.add_widget(self.small_bar, RB.ShellUILocation.MAIN_TOP, expand=False, fill=False) self.show_small_bar() action.set_active(True) print("not hidden but compact") else: action.set_active(False) self.plugin.rb_toolbar.hide()