def on_timeout(self, player): """ Triggers "reached" signal of markers """ if player.current is None: self.__timeout_id = None return track_length = player.current.get_tag_raw('__length') if track_length is None: return True playback_time = player.get_time() reached_markers = ( m for m in providers.get('playback-markers') if int(m.props.position * track_length) == playback_time ) for marker in reached_markers: marker.emit('reached') return True
def __init__(self, playlist, parent=None): """ :param playlist: the playlist to export :type playlist: :class:`xl.playlist.Playlist` :param parent: a parent window for modal operation or None :type parent: :class:`gtk.Window` """ FileOperationDialog.__init__(self, title=_('Export Current Playlist'), parent=parent, action=gtk.FILE_CHOOSER_ACTION_SAVE, buttons=( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK ) ) self.set_local_only(False) self.relative_checkbox = gtk.CheckButton(_('Use relative paths to tracks')) self.relative_checkbox.set_active(True) self.extras_box.pack_start(self.relative_checkbox, False, False, 3) self.relative_checkbox.show() self.playlist = playlist extensions = {} for provider in providers.get('playlist-format-converter'): extensions[provider.name] = provider.title self.add_extensions(extensions) self.set_current_name('%s.m3u' % playlist.name) self.connect('response', self.on_response)
def remove_menu(self): # self.menu_entry.disconnect(self.menu_conn) for item in providers.get('menubar-tools-menu'): if item.name == 'scrobbler': providers.unregister('menubar-tools-menu', item) break
def on_timeout(self, player): """ Triggers "reached" signal of markers """ if player.current is None: self.__timeout_id = None return track_length = player.current.get_tag_raw('__length') if track_length is None: return True playback_time = int(player.get_time()) reached_markers = ( m for m in providers.get('playback-markers') if int(m.props.position * track_length) == playback_time ) for marker in reached_markers: marker.emit('reached') return True
def remove_menu(self): # self.menu_entry.disconnect(self.menu_conn) for item in providers.get("menubar-tools-menu"): if item.name == "scrobbler": providers.unregister("menubar-tools-menu", item) break
def __init__(self, parent=None): """ :param parent: a parent window for modal operation or None :type parent: :class:`gtk.Window` """ gtk.FileChooserDialog.__init__(self, title=_('Import Playlist'), parent=parent, buttons=( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) self.set_position(gtk.WIN_POS_CENTER_ON_PARENT) self.set_local_only(False) self.set_select_multiple(True) playlist_filter = gtk.FileFilter() playlist_filter.set_name(_('Playlist Files')) all_filter = gtk.FileFilter() all_filter.set_name(_('All Files')) all_filter.add_pattern('*') playlist_file_extensions = sum([p.file_extensions \ for p in providers.get('playlist-format-converter')], []) for extension in playlist_file_extensions: pattern = '*.%s' % extension playlist_filter.add_pattern(pattern) self.add_filter(playlist_filter) self.add_filter(all_filter) self.connect('response', self.on_response)
def disable(exaile): """ Called when the plugin is disabled. Destroy menu. """ for item in providers.get('menubar-tools-menu'): if item.name == 'bookmarks': providers.unregister('menubar-tools-menu', item) break
def disable(self, exaile): """ Called when the plugin is disabled """ for item in providers.get('menubar-tools-menu'): if item.name == 'ipconsole': providers.unregister('menubar-tools-menu', item) break self.teardown(exaile)
def disable(self, exaile): ''' Plugin Disabled. ''' self.teardown(exaile) for item in providers.get('menubar-tools-menu'): if item.name == 'daap': providers.unregister('menubar-tools-menu', item) break
def disable(self, _exaile): """ Called when the plugin is disabled. Destroy menu. """ self.__manager.menu = None # used to mark plugin shutdown to display_bookmark for item in providers.get('menubar-tools-menu'): if item.name == 'bookmarks': providers.unregister('menubar-tools-menu', item) break self.__manager = None
def create_menu(self): sep = menu.simple_separator('furas-item-sep', ['properties']) #sep._pos = 'normal' self.provider_register(sep, 'playlist-context-menu') for n, (name, url) in enumerate(DATA): item = menu.simple_menu_item( 'furas-item-%i' % n, # unique name ['furas-item-sep'], # after ie. [] or ['properties'] name, # displayed text 'gtk-save', # icon name # ie. 'document-properties' self.webbrowser_cb, # callback function callback_args=[url] # callback extra arguments ) #print(dir(item)) self.provider_register(item, 'playlist-context-menu') print '---------------------------------' print 'TESTING: register menu #1' ### submenu ### self.submenu = menu.Menu(self, inherit_context=True) for n, (name, url) in enumerate(DATA): self.submenu.add_item(menu.simple_menu_item( 'furas-item-sub-%i' % n, # unique name [], # after ie. [] or ['properties'] name, # displayed text 'gtk-save', # icon name # ie. 'document-properties' self.webbrowser_cb, # callback function callback_args=[url] # callback extra arguments )) item = menu.simple_menu_item( 'furas-item-sub', # unique name ['furas-item-sep'], # after ie. [] or ['properties'] 'Szukaj', submenu=self.submenu) self.provider_register(item, 'playlist-context-menu') print 'TESTING: self.submenu._items:' print self.submenu._items print '---------------------------------' print 'TESTING: register menu #2' for p in providers.get('playlist-context-menu'): print 'TESTING: -> menu:', p.name, p._pos, p.after print '---------------------------------'
def destroy(self): """ Cleans up """ if self.countdown is not None: GLib.source_remove(self.countdown) event.remove_callback(self.on_playback_player_end, 'playback_player_end') for item in providers.get('menubar-tools-menu'): if item.name == 'shutdown': providers.unregister('menubar-tools-menu', item) break
def disable(exaile): """ Called when the plugin is disabled """ for item in providers.get('menubar-tools-menu'): if item.name == 'ipconsole': providers.unregister('menubar-tools-menu', item) break # if window is open, kill it if PLUGIN is not None: PLUGIN.destroy()
def destroy(self): """ Cleans up """ if self.countdown is not None: glib.source_remove(self.countdown) event.remove_callback(self.on_playback_player_end, 'playback_player_end') for item in providers.get('menubar-tools-menu'): if item.name == 'shutdown': providers.unregister('menubar-tools-menu', item) break
def destroy(self): """ Cleans up """ if self.countdown is not None: GLib.source_remove(self.countdown) event.remove_callback(self.on_playback_player_end, "playback_player_end") for item in providers.get("menubar-tools-menu"): if item.name == "shutdown": providers.unregister("menubar-tools-menu", item) break
def create_menu(self): sep = menu.simple_separator('furas-item-sep', ['properties']) #sep._pos = 'normal' self.provider_register(sep, 'playlist-context-menu') for n, (name, url) in enumerate(DATA): item = menu.simple_menu_item( 'furas-item-%i' % n, # unique name ['furas-item-sep'], # after ie. [] or ['properties'] name, # displayed text 'gtk-save', # icon name # ie. 'document-properties' self.webbrowser_cb, # callback function callback_args=[url] # callback extra arguments ) #print(dir(item)) self.provider_register(item, 'playlist-context-menu') print '---------------------------------' print 'TESTING: register menu #1' ### submenu ### self.submenu = menu.Menu(self, inherit_context=True) for n, (name, url) in enumerate(DATA): self.submenu.add_item( menu.simple_menu_item( 'furas-item-sub-%i' % n, # unique name [], # after ie. [] or ['properties'] name, # displayed text 'gtk-save', # icon name # ie. 'document-properties' self.webbrowser_cb, # callback function callback_args=[url] # callback extra arguments )) item = menu.simple_menu_item( 'furas-item-sub', # unique name ['furas-item-sep'], # after ie. [] or ['properties'] 'Szukaj', submenu=self.submenu) self.provider_register(item, 'playlist-context-menu') print 'TESTING: self.submenu._items:' print self.submenu._items print '---------------------------------' print 'TESTING: register menu #2' for p in providers.get('playlist-context-menu'): print 'TESTING: -> menu:', p.name, p._pos, p.after print '---------------------------------'
def save_closed_tab(self, playlist): # don't let the list grow indefinitely items = providers.get('playlist-closed-tab-menu', self) if len(self.tab_history) > settings.get_option('gui/max_closed_tabs', 10): self.remove_closed_tab(-1) # remove last item item_name = 'playlist%05d' % self.history_counter close_time = datetime.now() # define a MenuItem factory that supports dynamic labels def factory(menu_, parent, context): item = None dt = (datetime.now() - close_time) if dt.seconds > 60: display_name = _( '{playlist_name} ({track_count} tracks, closed {minutes} min ago)' ).format(playlist_name=playlist.name, track_count=len(playlist), minutes=dt.seconds // 60) else: display_name = _( '{playlist_name} ({track_count} tracks, closed {seconds} sec ago)' ).format(playlist_name=playlist.name, track_count=len(playlist), seconds=dt.seconds) item = gtk.ImageMenuItem(display_name) item.set_image( gtk.image_new_from_icon_name('music-library', gtk.ICON_SIZE_MENU)) # Add accelerator to top item if self.tab_history[0][1].name == item_name: key, mods = gtk.accelerator_parse(self.accelerator.keys) item.add_accelerator('activate', menu.FAKEACCELGROUP, key, mods, gtk.ACCEL_VISIBLE) item.connect( 'activate', lambda w: self.restore_closed_tab(item_name=item_name)) return item # create menuitem item = menu.MenuItem(item_name, factory, []) providers.register('playlist-closed-tab-menu', item, self) self.history_counter -= 1 # add self.tab_history.insert(0, (playlist, item))
def disable(exaile): ''' Plugin Disabled. ''' # disconnect from active shares if MANAGER is not None: # MANAGER.clear() MANAGER.close(True) for item in providers.get('menubar-tools-menu'): if item.name == 'daap': providers.unregister('menubar-tools-menu', item) break event.remove_callback(__enb, 'gui_loaded')
def save_closed_tab(self, playlist): # don't let the list grow indefinitely items = providers.get('playlist-closed-tab-menu', self) if len(self.tab_history) > settings.get_option('gui/max_closed_tabs', 10): self.remove_closed_tab(-1) # remove last item item_name = 'playlist%05d'%self.history_counter close_time = datetime.now() # define a MenuItem factory that supports dynamic labels def factory(menu_, parent, context): item = None dt = (datetime.now() - close_time) if dt.seconds > 60: display_name = _('{playlist_name} ({track_count} tracks, closed {minutes} min ago)').format( playlist_name=playlist.name, track_count=len(playlist), minutes=dt.seconds // 60 ) else: display_name = _('{playlist_name} ({track_count} tracks, closed {seconds} sec ago)').format( playlist_name=playlist.name, track_count=len(playlist), seconds=dt.seconds ) item = gtk.ImageMenuItem(display_name) item.set_image(gtk.image_new_from_icon_name('music-library', gtk.ICON_SIZE_MENU)) # Add accelerator to top item if self.tab_history[0][1].name == item_name: key, mods = gtk.accelerator_parse(self.accelerator.keys) item.add_accelerator('activate', menu.FAKEACCELGROUP, key, mods, gtk.ACCEL_VISIBLE) item.connect('activate', lambda w: self.restore_closed_tab(item_name=item_name)) return item # create menuitem item = menu.MenuItem(item_name, factory, []) providers.register('playlist-closed-tab-menu', item, self) self.history_counter -= 1 # add self.tab_history.insert(0, (playlist,item))
def get_markers_at(self, position): """ Gets all markers located at a position :param position: the mark position :type position: float :returns: (m1, m2, ...) :rtype: (:class:`Marker`, ...) * *m1*: the first marker * *m2*: the second marker * ... """ # Reproduce value modifications position = Marker(position).props.position markers = () for marker in providers.get('playback-markers'): if marker.props.position == position: markers += (marker,) return markers
def __init__(self, preferences, widget): self.items = [ self.Item(p.name, p.title, p.description, p.fixed) for p in providers.get('minimode-controls') ] widgets.SelectionListPreference.__init__(self, preferences, widget)
def __register_playlist_columns_menuitems(): """ Registers standard menu items for playlist columns """ def is_column_selected(name, parent, context): """ Returns whether a menu item should be checked """ return name in settings.get_option("gui/columns", DEFAULT_COLUMNS) def is_resizable(name, parent, context): """ Returns whether manual or automatic sizing is requested """ resizable = settings.get_option("gui/resizable_cols", False) if name == "resizable": return resizable elif name == "autosize": return not resizable def on_column_item_activate(menu_item, name, parent, context): """ Updates columns setting """ columns = settings.get_option("gui/columns", DEFAULT_COLUMNS) if name in columns: columns.remove(name) else: columns.append(name) settings.set_option("gui/columns", columns) def on_sizing_item_activate(menu_item, name, parent, context): """ Updates column sizing setting """ if name == "resizable": settings.set_option("gui/resizable_cols", True) elif name == "autosize": settings.set_option("gui/resizable_cols", False) columns = ["tracknumber", "title", "artist", "album", "__length", "genre", "__rating", "date"] for provider in providers.get("playlist-columns"): if provider.name not in columns: columns += [provider.name] menu_items = [] after = [] for name in columns: column = providers.get_provider("playlist-columns", name) menu_item = ColumnMenuItem(column, after) menu_items += [menu_item] after = [menu_item.name] separator_item = menu.simple_separator("columns_separator", after) menu_items += [separator_item] after = [separator_item.name] sizing_item = menu.radio_menu_item( "resizable", after, _("_Resizable"), "column-sizing", is_resizable, on_sizing_item_activate ) menu_items += [sizing_item] after = [sizing_item.name] sizing_item = menu.radio_menu_item( "autosize", after, _("_Autosize"), "column-sizing", is_resizable, on_sizing_item_activate ) menu_items += [sizing_item] for menu_item in menu_items: providers.register("playlist-columns-menu", menu_item)
def get_menu(self, menu_id): return providers.get(menu_id)
def __init__(self, preferences, widget): self.items = [self.Item(p.name, p.title, p.description, p.fixed) \ for p in providers.get('minimode-controls')] widgets.SelectionListPreference.__init__(self, preferences, widget)
def __register_playlist_columns_menuitems(): """ Registers standard menu items for playlist columns """ def is_column_selected(name, parent, context): """ Returns whether a menu item should be checked """ return name in settings.get_option('gui/columns', DEFAULT_COLUMNS) def is_resizable(name, parent, context): """ Returns whether manual or automatic sizing is requested """ resizable = settings.get_option('gui/resizable_cols', False) if name == 'resizable': return resizable elif name == 'autosize': return not resizable def on_column_item_activate(menu_item, name, parent, context): """ Updates columns setting """ columns = settings.get_option('gui/columns', DEFAULT_COLUMNS) if name in columns: columns.remove(name) else: columns.append(name) settings.set_option('gui/columns', columns) def on_sizing_item_activate(menu_item, name, parent, context): """ Updates column sizing setting """ if name == 'resizable': settings.set_option('gui/resizable_cols', True) elif name == 'autosize': settings.set_option('gui/resizable_cols', False) columns = [ 'tracknumber', 'title', 'artist', 'album', '__length', 'genre', '__rating', 'date' ] for provider in providers.get('playlist-columns'): if provider.name not in columns: columns += [provider.name] menu_items = [] after = [] for name in columns: column = providers.get_provider('playlist-columns', name) menu_item = ColumnMenuItem(column, after) menu_items += [menu_item] after = [menu_item.name] separator_item = menu.simple_separator('columns_separator', after) menu_items += [separator_item] after = [separator_item.name] sizing_item = menu.radio_menu_item('resizable', after, _('_Resizable'), 'column-sizing', is_resizable, on_sizing_item_activate) menu_items += [sizing_item] after = [sizing_item.name] sizing_item = menu.radio_menu_item('autosize', after, _('_Autosize'), 'column-sizing', is_resizable, on_sizing_item_activate) menu_items += [sizing_item] for menu_item in menu_items: providers.register('playlist-columns-menu', menu_item)
def __register_playlist_columns_menuitems(): """ Registers standard menu items for playlist columns """ def is_column_selected(name, parent, context): """ Returns whether a menu item should be checked """ return name in settings.get_option('gui/columns', DEFAULT_COLUMNS) def is_resizable(name, parent, context): """ Returns whether manual or automatic sizing is requested """ resizable = settings.get_option('gui/resizable_cols', False) if name == 'resizable': return resizable elif name == 'autosize': return not resizable def on_column_item_activate(menu_item, name, parent, context): """ Updates columns setting """ columns = settings.get_option('gui/columns', DEFAULT_COLUMNS) if name in columns: columns.remove(name) else: columns.append(name) settings.set_option('gui/columns', columns) def on_sizing_item_activate(menu_item, name, parent, context): """ Updates column sizing setting """ # Ignore the activation if the menu item is not actually active if not menu_item.get_active(): return if name == 'resizable': settings.set_option('gui/resizable_cols', True) elif name == 'autosize': settings.set_option('gui/resizable_cols', False) columns = [ 'tracknumber', 'title', 'artist', 'album', '__length', 'genre', '__rating', 'date', ] for provider in providers.get('playlist-columns'): if provider.name not in columns: columns += [provider.name] menu_items = [] after = [] for name in columns: column = providers.get_provider('playlist-columns', name) menu_item = ColumnMenuItem(column, after) menu_items += [menu_item] after = [menu_item.name] separator_item = menu.simple_separator('columns_separator', after) menu_items += [separator_item] after = [separator_item.name] sizing_item = menu.radio_menu_item( 'resizable', after, _('_Resizable'), 'column-sizing', is_resizable, on_sizing_item_activate, ) menu_items += [sizing_item] after = [sizing_item.name] sizing_item = menu.radio_menu_item( 'autosize', after, _('_Autosize'), 'column-sizing', is_resizable, on_sizing_item_activate, ) menu_items += [sizing_item] for menu_item in menu_items: providers.register('playlist-columns-menu', menu_item)