def do_button_press_event(self, event): ''' Other than the default behavior, adds an event firing when the mouse has clicked on top of a current item, informing the listeners of the path of the clicked item. ''' x = int(event.x) y = int(event.y) current_path = self.get_path_at_pos(x, y) if event.type is Gdk.EventType.BUTTON_PRESS and current_path: if event.triggers_context_menu(): # if the item being clicked isn't selected, we should clear # the current selection if len(self.get_selected_objects()) > 0 and \ not self.path_is_selected(current_path): self.unselect_all() self.select_path(current_path) self.set_cursor(current_path, None, False) if self.popup: if not self._external_plugins: # initialise external plugin menu support self._external_plugins = \ CreateExternalPluginMenu("ca_covers_view", self.shell) self._external_plugins.create_menu(self.popup, self.ext_menu_pos, True) self.popup.popup(None, None, None, None, event.button, event.time) else: self.emit('item-clicked', event, current_path) Gtk.IconView.do_button_press_event(self, event)
def pre_popup_menu_callback(self, *args): ''' Callback when the popup menu is about to be displayed ''' if not self.external_plugins: self.external_plugins = \ CreateExternalPluginMenu("playlist_entry_view", 1, self.popup) self.external_plugins.create_menu('play_popup_menu')
def add_external_menu(self, *args): ''' Callback when the popup menu is about to be displayed ''' if not self._external_plugins: # initialise external plugin menu support self._external_plugins = \ CreateExternalPluginMenu("ca_covers_view", 7, self.popup_menu) self._external_plugins.create_menu('popup_menu', True) self.playlist_menu_item_callback()
def pre_popup_menu_callback(self, *args): ''' Callback when the popup menu is about to be displayed ''' state, sensitive = self.shell.props.shell_player.get_playing() if not state: sensitive = False self.popup.set_sensitive('ev_full_add_to_playing_menu_item', sensitive) self.popup.set_sensitive('ev_full_play_next_track_menu_item', sensitive) if not self.external_plugins: self.external_plugins = \ CreateExternalPluginMenu("ev_full_entryview", 6, self.popup) self.external_plugins.create_menu('entryview_full_popup_menu') self.playlist_menu_item_callback()
def __init__(self, shell, source): ''' Initializes the entryview. ''' self.shell = shell self.source = source self.plugin = self.source.props.plugin super(RB.EntryView, self).__init__(db=shell.props.db, shell_player=shell.props.shell_player, is_drag_source=True, visible_columns=[]) cl = CoverLocale() cl.switch_locale(cl.Locale.RB) self.append_column(RB.EntryViewColumn.TRACK_NUMBER, False) self.append_column(RB.EntryViewColumn.TITLE, True) # always shown self.append_column(RB.EntryViewColumn.GENRE, False) self.append_column(RB.EntryViewColumn.ARTIST, False) self.append_column(RB.EntryViewColumn.ALBUM, False) self.append_column(RB.EntryViewColumn.DURATION, False) self.append_column(RB.EntryViewColumn.COMMENT, False) self.append_column(RB.EntryViewColumn.RATING, False) self.append_column(RB.EntryViewColumn.QUALITY, False) self.append_column(RB.EntryViewColumn.PLAY_COUNT, False) self.append_column(RB.EntryViewColumn.LAST_PLAYED, False) self.append_column(RB.EntryViewColumn.YEAR, False) self.append_column(RB.EntryViewColumn.FIRST_SEEN, False) self.append_column(RB.EntryViewColumn.LOCATION, False) self.append_column(RB.EntryViewColumn.BPM, False) cl.switch_locale(cl.Locale.LOCALE_DOMAIN) # UI elements need to be imported. ui = Gtk.Builder() ui.set_translation_domain(cl.Locale.LOCALE_DOMAIN) ui.add_from_file(rb.find_plugin_file(self.plugin, 'ui/coverart_entryview.ui')) ui.connect_signals(self) self.popup_menu = ui.get_object('entryview_popup_menu') # connect signals to the shell to know when the playing state changes self.shell.props.shell_player.connect('playing-song-changed', self.playing_song_changed) self.shell.props.shell_player.connect('playing-changed', self.playing_changed) self.playlist_sub_menu_item = ui.get_object('playlist_sub_menu_item') self.actiongroup = Gtk.ActionGroup('coverentryplaylist_submenu') uim = self.shell.props.ui_manager uim.insert_action_group(self.actiongroup) self.external_plugins = \ CreateExternalPluginMenu("ca_entryview", self.shell) # connect the visible-columns global setting to update our entryview gs = GSetting() rhythm_settings = gs.get_setting(gs.Path.RBSOURCE) rhythm_settings.connect('changed::visible-columns', self.on_visible_columns_changed) self.on_visible_columns_changed(rhythm_settings, 'visible-columns') self.qm = RB.RhythmDBQueryModel.new_empty(self.shell.props.db) self.set_model(self.qm) # connect the sort-order to the library source sort library_view = self.shell.props.library_source.get_entry_view() library_view.connect('notify::sort-order', self._on_library_sorting_changed) self._on_library_sorting_changed(library_view, library_view.props.sort_order) # connect to the sort-order property self.connect('notify::sort-order', self._notify_sort_order, library_view)