def __init__(self): providers.ProviderHandler.__init__(self, "lyrics") self.preferred_order = settings.get_option( 'lyrics/preferred_order', []) self.cache = LyricsCache(os.path.join(xdg.get_cache_dir(), 'lyrics.cache')) event.add_callback(self.on_track_tags_changed, 'track_tags_changed')
def __init__(self, exaile): """ Connects events to the player object, loads settings and cache """ scrobbler.set_user_agent(exaile.get_user_agent_string('audioscrobbler')) self.connected = False self.connecting = False self.use_menu = False self.exaile = exaile self.cachefile = os.path.join(xdg.get_data_dirs()[0], "audioscrobbler.cache") self.get_options('', '', 'plugin/ascrobbler/cache_size') self.get_options('', '', 'plugin/ascrobbler/user') self.load_cache() event.add_ui_callback(self.get_options, 'plugin_ascrobbler_option_set') event.add_callback(self._save_cache_cb, 'quit_application') # enable accelerator def toggle_submit(*x): logger.debug('Toggling AudioScrobbler submissions.') settings.set_option('plugin/ascrobbler/submit', not self.submit) self.accelerator = Accelerator( '<Primary>b', _('Toggle AudioScrobbler submit'), toggle_submit ) providers.register('mainwindow-accelerators', self.accelerator)
def __init__(self, name, disable_autoswitch=False): self.queue = None self._name = name self._playtime_stamp = None self._delay_id = None self._stop_id = None self._engine = None self._auto_advance_delay = 0 self._auto_advance = True self._gapless_enabled = True self.__volume = 1.0 options = { '%s/auto_advance_delay' % name: '_auto_advance_delay', '%s/auto_advance' % name: '_auto_advance', '%s/gapless_playback' % name: '_gapless_enabled', '%s/volume' % name: '_volume', } self._settings_unsub = common.subscribe_for_settings( name, options, self) self._setup_engine(disable_autoswitch) event.add_callback(self._on_track_end, 'playback_track_end', self) event.add_callback(self._on_track_tags_changed, 'track_tags_changed')
def on_drag_data_received(self, widget, context, x, y, selection, info, time): """ Handles dropped data """ # Enable display of drop target on re-enter if self._drag_motion_id is not None: glib.source_remove(self._drag_motion_id) self._drag_motion_id = None # Enable hiding of drop target on re-enter if self._drag_leave_id is not None: glib.source_remove(self._drag_leave_id) self._drag_leave_id = None self.drop_target_window.hide() uris = selection.get_uris() page = xlgui.main.get_selected_page() if widget is self.play_target: event.add_callback(self.on_playlist_tracks_added, 'playlist_tracks_added') if widget is self.new_playlist_target: playlist_notebook = xlgui.main.get_playlist_notebook() page = playlist_notebook.create_new_playlist().page if not isinstance(page, PlaylistPage): return page.view.emit('drag-data-received', context, x, y, selection, info, time)
def on_gui_loaded(self): event.add_callback(self.__on_settings_changed, 'plugin_daapclient_option_set') menu_ = menu.Menu(None) providers.register( 'menubar-tools-menu', _sep('plugin-sep', ['track-properties']) ) item = _smi('daap', ['plugin-sep'], _('Connect to DAAP...'), submenu=menu_) providers.register('menubar-tools-menu', item) if AVAHI: try: avahi_interface = DaapAvahiInterface(self.__exaile, menu_) except RuntimeError: # no dbus? avahi_interface = None logger.warning('avahi interface could not be initialized (no dbus?)') except dbus.exceptions.DBusException as s: avahi_interface = None logger.error('Got DBUS error: %s' % s) logger.error('is avahi-daemon running?') else: avahi_interface = None logger.warn( 'AVAHI could not be imported, you will not see broadcast shares.' ) self.__manager = DaapManager(self.__exaile, menu_, avahi_interface)
def __init__(self, location): """ :param location: The directory to load and store data in. """ providers.ProviderHandler.__init__(self, "covers") self.__cache = Cacher(os.path.join(location, 'cache')) self.location = location self.methods = {} self.order = settings.get_option( 'covers/preferred_order', []) self.db = {} self.load() for method in self.get_providers(): self.on_provider_added(method) default_cover_file = open(xdg.get_data_path('images', 'nocover.png'), 'rb') self.default_cover_data = default_cover_file.read() default_cover_file.close() self.tag_fetcher = TagCoverFetcher() self.localfile_fetcher = LocalFileCoverFetcher() if settings.get_option('covers/use_tags', True): providers.register('covers', self.tag_fetcher) if settings.get_option('covers/use_localfile', True): providers.register('covers', self.localfile_fetcher) event.add_callback(self._on_option_set, 'covers_option_set')
def _setup_widgets(self): """ Sets up the widgets for the files panel """ self.directory = self.tree.render_icon( gtk.STOCK_DIRECTORY, gtk.ICON_SIZE_SMALL_TOOLBAR) self.track = icons.MANAGER.pixbuf_from_icon_name( 'audio-x-generic', gtk.ICON_SIZE_SMALL_TOOLBAR) self.back = self.builder.get_object('files_back_button') self.back.connect('clicked', self.go_back) self.forward = self.builder.get_object('files_forward_button') self.forward.connect('clicked', self.go_forward) self.up = self.builder.get_object('files_up_button') self.up.connect('clicked', self.go_up) self.builder.get_object('files_refresh_button').connect('clicked', self.refresh) self.builder.get_object('files_home_button').connect('clicked', self.go_home) # Set up the location bar self.location_bar = self.builder.get_object('files_entry') self.location_bar.connect('changed', self.on_location_bar_changed) event.add_callback(self.fill_libraries_location, 'libraries_modified', self.collection) self.fill_libraries_location() self.entry = self.location_bar.child self.entry.connect('activate', self.entry_activate) # Set up the search entry self.filter = guiutil.SearchEntry(self.builder.get_object('files_search_entry')) self.filter.connect('activate', lambda *e: self.load_directory(self.current, history=False, keyword=unicode(self.filter.get_text(), 'utf-8')))
def __init__(self, exaile, caps): self.__exaile = exaile self.__old_icon = None self.__tray_connection = None notification = Notify.Notification.new("", None, None) if 'sound' in caps: notification.set_hint('suppress-sound', GLib.Variant.new_boolean(True)) self.settings.can_show_markup = 'body-markup' in caps notification.set_urgency(Notify.Urgency.LOW) notification.set_timeout(Notify.EXPIRES_DEFAULT) # default action is invoked on clicking the notification notification.add_action( "default", "this should never be displayed", self.__on_default_action ) self.notification = notification PlaybackAdapter.__init__(self, xl_player.PLAYER) xl_event.add_callback(self.on_option_set, 'plugin_notify_option_set') xl_event.add_callback(self.on_option_set, 'gui_option_set') # initial setup through options: self.on_option_set(None, xl_settings, notifyprefs.TrayHover.name) self.on_option_set(None, xl_settings, notifyprefs.ShowCovers.name)
def __init__(self, exaile): """ Connects events to the player object, loads settings and cache """ scrobbler.set_user_agent( exaile.get_user_agent_string('audioscrobbler')) self.connected = False self.connecting = False self.use_menu = False self.exaile = exaile self.cachefile = os.path.join(xdg.get_data_dirs()[0], "audioscrobbler.cache") self.get_options('', '', 'plugin/ascrobbler/cache_size') self.get_options('', '', 'plugin/ascrobbler/user') self.load_cache() event.add_ui_callback(self.get_options, 'plugin_ascrobbler_option_set') event.add_callback(self._save_cache_cb, 'quit_application') # enable accelerator def toggle_submit(*x): logger.debug('Toggling AudioScrobbler submissions.') settings.set_option('plugin/ascrobbler/submit', not self.submit) self.accelerator = Accelerator('<Primary>b', _('Toggle AudioScrobbler submit'), toggle_submit) providers.register('mainwindow-accelerators', self.accelerator)
def enable(exaile): global APP APP = exaile if (exaile.loading): event.add_callback(_enable, 'exaile_loaded') else: _enable(None, exaile, None)
def __init__(self): """ Sets up the connection to Last.fm as well as the graphical interface """ self.network = None self.user = None self.loved_tracks = [] self.timer = None self.column_menu_item = ColumnMenuItem(column=LoveColumn, after=["__rating"]) self.menu_item = LoveMenuItem(after=["rating"]) def get_tracks_function(): """ Drop in replacement for menu item context to retrieve the currently playing track """ current_track = player.PLAYER.current if current_track is not None: return [current_track] return [] self.tray_menu_item = LoveMenuItem(after=["rating"], get_tracks_function=get_tracks_function) self.setup_network() providers.register("playlist-columns", LoveColumn) providers.register("playlist-columns-menu", self.column_menu_item) providers.register("playlist-context-menu", self.menu_item) providers.register("tray-icon-context", self.tray_menu_item) event.add_callback(self.on_option_set, "plugin_lastfmlove_option_set")
def __init__(self, builder): WebKit2.WebView.__init__(self) self.hometrack = None builder.connect_signals(self) event.add_callback(self.on_playback_start, 'playback_track_start')
def enable(exaile): config.USER_AGENT = exaile.get_user_agent_string('wikipedia') if exaile.loading: event.add_callback(_enable, 'exaile_loaded') else: _enable(None, exaile, None)
def enable(self, exaile): self.player = player.PLAYER self.display('enable', player.PLAYER) self.other('enable') event.add_callback(self.on_playback_start, 'playback_track_start')
def set_auto_update(self, auto_update): """ Sets whether the info pane shall be automatically updated or not :param auto_update: enable or disable automatic updating :type auto_update: bool """ if auto_update != self.__auto_update: self.__auto_update = auto_update p_evts = ['playback_player_end', 'playback_track_start', 'playback_toggle_pause', 'playback_error'] events = ['track_tags_changed', 'cover_set', 'cover_removed'] if auto_update: for e in p_evts: event.add_callback(getattr(self, 'on_%s' % e), e, self.__player) for e in events: event.add_callback(getattr(self, 'on_%s' % e), e) self.set_track(self.__player.current) else: for e in p_evts: event.remove_callback(getattr(self, 'on_%s' % e), e, self.__player) for e in events: event.remove_callback(getattr(self, 'on_%s' % e), e)
def __init__(self, location): """ :param location: The directory to load and store data in. """ providers.ProviderHandler.__init__(self, "covers") self.__cache = Cacher(os.path.join(location, 'cache')) self.location = location self.methods = {} self.order = settings.get_option('covers/preferred_order', []) self.db = {} self.load() for method in self.get_providers(): self.on_provider_added(method) default_cover_file = open(xdg.get_data_path('images', 'nocover.png'), 'rb') self.default_cover_data = default_cover_file.read() default_cover_file.close() self.tag_fetcher = TagCoverFetcher() self.localfile_fetcher = LocalFileCoverFetcher() if settings.get_option('covers/use_tags', True): providers.register('covers', self.tag_fetcher) if settings.get_option('covers/use_localfile', True): providers.register('covers', self.localfile_fetcher) event.add_callback(self._on_option_set, 'covers_option_set')
def __init__(self, exaile, caps): self.__exaile = exaile self.__old_icon = None self.__tray_connection = None notification = Notify.Notification.new("", None, None) if 'sound' in caps: notification.set_hint('suppress-sound', GLib.Variant.new_boolean(True)) self.settings.can_show_markup = 'body-markup' in caps notification.set_urgency(Notify.Urgency.LOW) notification.set_timeout(Notify.EXPIRES_DEFAULT) # default action is invoked on clicking the notification notification.add_action("default", "this should never be displayed", self.__on_default_action) self.notification = notification PlaybackAdapter.__init__(self, xl_player.PLAYER) xl_event.add_callback(self.on_option_set, 'plugin_notify_option_set') xl_event.add_callback(self.on_option_set, 'gui_option_set') # initial setup through options: self.on_option_set(None, xl_settings, notifyprefs.TrayHover.name) self.on_option_set(None, xl_settings, notifyprefs.ShowCovers.name)
def enable(exaile): G15STATUS.exaile = exaile event.add_callback(G15STATUS.on_play, 'playback_player_start') event.add_callback(G15STATUS.on_play, 'playback_track_start') event.add_callback(G15STATUS.on_pause, 'playback_player_pause') event.add_callback(G15STATUS.on_stop, 'playback_player_end') event.add_callback(G15STATUS.on_play, 'playback_player_resume')
def set_auto_update(self, auto_update): """ Sets whether the info pane shall be automatically updated or not :param auto_update: enable or disable automatic updating :type auto_update: bool """ if auto_update != self.__auto_update: self.__auto_update = auto_update p_evts = [ 'playback_player_end', 'playback_track_start', 'playback_toggle_pause', 'playback_error' ] events = ['track_tags_changed', 'cover_set', 'cover_removed'] if auto_update: for e in p_evts: event.add_callback(getattr(self, 'on_%s' % e), e, self.__player) for e in events: event.add_callback(getattr(self, 'on_%s' % e), e) self.set_track(self.__player.current) else: for e in p_evts: event.remove_callback(getattr(self, 'on_%s' % e), e, self.__player) for e in events: event.remove_callback(getattr(self, 'on_%s' % e), e)
def __init__(self): self.__timeout_id = None self.__fade_id = None self.__current_volume = None event.add_callback(self.__on_option_set, 'plugin_alarmclock_option_set') self.__update_timeout()
def __init__(self): CoverSearchMethod.__init__(self) event.add_callback(self.on_option_set, 'covers_localfile_option_set') self.on_option_set( 'covers_localfile_option_set', settings, 'covers/localfile/preferred_names' )
def __init__(self, name): self.queue = None self._name = name self._playtime_stamp = None self._delay_id = None self._stop_id = None self._engine = None self._auto_advance_delay = 0 self._auto_advance = True self._gapless_enabled = True self.__volume = 1.0 options = { '%s/auto_advance_delay' % name: '_auto_advance_delay', '%s/auto_advance' % name: '_auto_advance', '%s/gapless_playback' % name: '_gapless_enabled', '%s/volume' % name: '_volume', } self._settings_unsub = common.subscribe_for_settings(name, options, self) self._setup_engine() event.add_callback(self._on_track_end, 'playback_track_end', self) event.add_callback(self._on_track_tags_changed, 'track_tags_changed')
def enable(exaile): if exaile.loading: from xl import event event.add_callback(_enable, 'gui_loaded') else: _enable(None, exaile, None)
def enable(exaile): '''Called by exaile to enable plugin''' if exaile.loading: logger.debug('waitin for loaded event') event.add_callback(_enable, 'exaile_loaded') else: _enable(None, exaile, None)
def on_gui_loaded(self): event.add_callback(self.__on_settings_changed, 'plugin_daapclient_option_set') menu_ = menu.Menu(None) providers.register('menubar-tools-menu', _sep('plugin-sep', ['track-properties'])) item = _smi('daap', ['plugin-sep'], _('Connect to DAAP...'), submenu=menu_) providers.register('menubar-tools-menu', item) autodiscover = None if ZEROCONF: try: autodiscover = DaapZeroconfInterface(self.__exaile, menu_) except RuntimeError: logger.warning('zeroconf interface could not be initialized') else: logger.warning( 'python-zeroconf is not available; disabling DAAP share auto-discovery!' ) self.__manager = DaapManager(self.__exaile, menu_, autodiscover)
def __init__(self, player): formatter.ProgressTextFormatter.__init__(self, '', player) event.add_callback(self.on_option_set, 'gui_option_set') self.on_option_set('gui_option_set', settings, 'gui/progress_bar_text_format')
def __init__(self, image): """ Initializes the widget :param image: the image to wrap :type image: :class:`Gtk.Image` """ GObject.GObject.__init__(self) self.image = image self.cover_data = None self.menu = CoverMenu(self) self.menu.attach_to_widget(self) self.filename = None guiutil.gtk_widget_replace(image, self) self.add(self.image) self.set_track(None) self.image.show() event.add_callback(self.on_quit_application, 'quit_application') if settings.get_option('gui/use_alpha', False): self.set_app_paintable(True)
def on_gui_loaded(self): event.add_callback(self.__on_settings_changed, 'plugin_daapclient_option_set') menu_ = menu.Menu(None) providers.register('menubar-tools-menu', _sep('plugin-sep', ['track-properties'])) item = _smi('daap', ['plugin-sep'], _('Connect to DAAP...'), submenu=menu_) providers.register('menubar-tools-menu', item) if AVAHI: try: avahi_interface = DaapAvahiInterface(self.__exaile, menu_) except RuntimeError: # no dbus? avahi_interface = None logger.warning( 'avahi interface could not be initialized (no dbus?)') except dbus.exceptions.DBusException as s: avahi_interface = None logger.error('Got DBUS error: %s' % s) logger.error('is avahi-daemon running?') else: avahi_interface = None logger.warning( 'AVAHI could not be imported, you will not see broadcast shares.' ) self.__manager = DaapManager(self.__exaile, menu_, avahi_interface)
def __init__(self): """ Initializes the window """ Gtk.Window.__init__(self, Gtk.WindowType.TOPLEVEL) # for whatever reason, calling set_opacity seems # to crash on Windows when using PyGTK that comes with # the GStreamer SDK. Since this plugin is enabled by # default, just don't fade in/out on windows # # https://bugs.freedesktop.org/show_bug.cgi?id=54682 self.use_fade = True if sys.platform == 'win32': self.use_fade = False self.fadeout_id = None self.drag_origin = None self.hide_id = None self.set_type_hint(Gdk.WindowTypeHint.NOTIFICATION) self.set_title('Exaile OSD') self.set_decorated(False) self.set_keep_above(True) self.set_skip_pager_hint(True) self.set_skip_taskbar_hint(True) self.set_resizable(True) self.set_app_paintable(True) self.stick() self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK | Gdk.EventMask.POINTER_MOTION_MASK) # Cached option values self.__options = { 'background': None, 'display_duration': None, 'border_radius': None } self.info_area = info.TrackInfoPane(player.PLAYER) self.info_area.set_default_text('') self.info_area.set_auto_update(True) self.add(self.info_area) event.add_callback(self.on_track_tags_changed, 'track_tags_changed') event.add_callback(self.on_option_set, 'plugin_osd_option_set') # Trigger initial setup trough options for option in ('format', 'background', 'display_duration', 'show_progress', 'position', 'width', 'height', 'border_radius'): self.on_option_set('plugin_osd_option_set', settings, 'plugin/osd/{option}'.format(option=option)) # Trigger color map update self.emit('screen-changed', self.get_screen()) PlaybackAdapter.__init__(self, player.PLAYER)
def enable(exaile): """ Enables the plugin """ if exaile.loading: event.add_callback(on_gui_loaded, 'gui_loaded') else: on_gui_loaded()
def enable(exaile): ''' Plugin Enabled. ''' if exaile.loading: event.add_callback(__enb, 'gui_loaded') else: __enb(None, exaile, None)
def enable(exaile): """ """ config.USER_AGENT = exaile.get_user_agent_string("wikipedia") if exaile.loading: event.add_callback(_enable, "exaile_loaded") else: _enable(None, exaile, None)
def __init__(self): providers.ProviderHandler.__init__(self, 'playback-markers') self.__events = ('playback_track_start', 'playback_track_end') self.__timeout_id = None for e in self.__events: event.add_callback(getattr(self, 'on_%s' % e), e)
def enable(exaile): """ Enables the drop trayicon plugin """ if exaile.loading: event.add_callback(_enable, 'gui_loaded') else: _enable(None, exaile, None)
def __init__(self): Formatter.__init__(self, self.get_option_value()) self.track_formatter = TrackFormatter('') self.progress_formatter = ProgressTextFormatter( self.props.format, player.PLAYER) event.add_callback(self.on_option_set, 'plugin_minimode_option_set')
def enable(exaile): """ Enable the plugin to fetch lyrics from xiami.com """ if exaile.loading: event.add_callback(_enable, "exaile_loaded") else: _enable(None, exaile, None)
def __init__(self): gtk.HBox.__init__(self) providers.ProviderHandler.__init__(self, 'minimode-controls') self.__dirty = True self.__controls = {} event.add_callback(self.on_option_set, 'plugin_minimode_option_set')
def __init__(self, player): Playlist.__init__( self, _('History') ) # catch the history event.add_callback( self.__on_playback_track_start, 'playback_track_start', player ) if player.is_paused() or player.is_playing(): self.__on_playback_track_start( 'playback_track_start', player, player.current )
def enable(exaile): """ Dummy initialization function, calls _enable when exaile is fully loaded. """ if exaile.loading: event.add_callback(__enb, 'gui_loaded') else: __enb(None, exaile, None)
def _enable(eventname, exaile, nothing): _enable_main_moodbar(exaile) event.add_callback(_enable_preview_moodbar, 'preview_device_enabled') event.add_callback(_disable_preview_moodbar, 'preview_device_disabling') preview_plugin = _get_preview_plugin_if_active(exaile) if getattr(preview_plugin, 'hooked', False): _enable_preview_moodbar('', preview_plugin, None)
def _enable(eventname, exaile, nothing): global TRAY_CONTROL TRAY_CONTROL = TrayControl(exaile) event.add_callback(TRAY_CONTROL.onPlay, TRACK_START_CALLBACK) event.add_callback(TRAY_CONTROL.onPlay, RESUME_CALLBACK) event.add_callback(TRAY_CONTROL.onEnd, END_CALLBACK) event.add_callback(TRAY_CONTROL.onPause, PAUSE_CALLBACK) event.add_callback(TRAY_CONTROL.on_setting_change, OPTIONS_CALLBACK) print "TrayControl plugin enabled"