def on_search_entry_activated(self, widget): self.set_status(self.STATUS_SEARCHING) # clear existing search self.model.clear() # get type of search iter = self.search_combobox.get_active_iter() search_type = self.search_combobox.get_model().get_value(iter, 0) iter = self.orderby_type_combobox.get_active_iter() orderby = self.orderby_type_combobox.get_model().get_value(iter, 0) iter = self.orderby_direction_combobox.get_active_iter() direction = self.orderby_direction_combobox.get_model().get_value(iter, 0) orderby += "_" + direction numresults = self.numresults_spinbutton.get_value_as_int() search_term = self.search_textentry.get_text() # save search term settings.set_option('plugin/jamendo/searchterms', search_term) if search_type == 'artist': resultthread = jamapi.get_artist_list(search_term, orderby, numresults, self.response_callback) resultthread.start() if search_type == 'album': resultthread = jamapi.get_album_list(search_term, orderby, numresults, self.response_callback) resultthread.start() if search_type == 'genre_tags': resultthread = jamapi.get_artist_list_by_genre(search_term, orderby, numresults, self.response_callback) resultthread.start() if search_type == 'track': resultthread = jamapi.get_track_list(search_term, orderby, numresults, self.response_callback) resultthread.start()
def __autoconfig(): ''' If the user hasn't used our plugin before, then try to autoconfig their audio settings to use a different audio device if possible.. TODO: It would be cool if we could notify the user that a new device was plugged in... ''' from xl import settings if settings.get_option('preview_device/audiosink', None) is not None: return sink = settings.get_option('player/audiosink', None) if sink is None: return settings.set_option('preview_device/audiosink', sink) main_device = settings.get_option('player/audiosink_device', None) if main_device is None: return from xl.player import pipe devices = pipe.sink_enumerate_devices(sink) if devices is not None: # pick the first one that isn't the main device and isn't 'Auto' # -> if the main device is '', then it's auto. So... we actually # iterate backwards, assuming that the ordering matters for device, name in reversed(devices): if device != main_device and name != _('Auto'): settings.set_option('preview_device/audiosink_device', device) break
def fade_in(main, exaile): '''Fade exaile's volume from min to max''' logger.debug('fade_in() called.') # pull settings temp_volume = ( settings.get_option('plugin/multialarmclock/fade_min_volume', 0) / 100.0 ) fade_max_volume = ( settings.get_option('plugin/multialarmclock/fade_max_volume', 100) / 100.0 ) fade_inc = settings.get_option('plugin/multialarmclock/fade_increment', 1) / 100.0 time_per_inc = settings.get_option('plugin/multialarmclock/fade_time', 30) / ( (fade_max_volume - temp_volume) / fade_inc ) while temp_volume < fade_max_volume: logger.debug('set volume to {0}'.format(temp_volume)) settings.set_option('player/volume', temp_volume) temp_volume += fade_inc time.sleep(time_per_inc) if player.PLAYER.is_paused() or not player.PLAYER.is_playing(): return settings.set_option('player/volume', fade_max_volume)
def __autoconfig(): ''' If the user hasn't used our plugin before, then try to autoconfig their audio settings to use a different audio device if possible.. TODO: It would be cool if we could notify the user that a new device was plugged in... ''' from xl import settings if settings.get_option('preview_device/audiosink', None) is not None: return sink = settings.get_option('player/audiosink', None) if sink is None: return settings.set_option( 'preview_device/audiosink', sink ) main_device = settings.get_option('player/audiosink_device', None) if main_device is None: return from xl.player import pipe devices = pipe.sink_enumerate_devices(sink) if devices is not None: # pick the first one that isn't the main device and isn't 'Auto' # -> if the main device is '', then it's auto. So... we actually # iterate backwards, assuming that the ordering matters for device,name in reversed(devices): if device != main_device and name != _('Auto'): settings.set_option( 'preview_device/audiosink_device', device ) break
def adjust_preamp(self, widget, data): """ Adjust the preamp """ if widget.get_value() != settings.get_option("plugin/equalizer/pre"): settings.set_option("plugin/equalizer/pre", widget.get_value()) self.ui.get_object("combo-presets").set_active(0)
def window_state_change_event(self, window, event): """ Saves the current maximized and fullscreen states and minimizes to tray if requested """ if event.changed_mask & Gdk.WindowState.MAXIMIZED: settings.set_option( 'gui/mainw_maximized', bool(event.new_window_state & Gdk.WindowState.MAXIMIZED), ) if event.changed_mask & Gdk.WindowState.FULLSCREEN: self._fullscreen = bool(event.new_window_state & Gdk.WindowState.FULLSCREEN) self.notify('is-fullscreen') # detect minimization state changes prev_minimized = self.minimized if not self.minimized: if (event.changed_mask & Gdk.WindowState.ICONIFIED and not event.changed_mask & Gdk.WindowState.WITHDRAWN and event.new_window_state & Gdk.WindowState.ICONIFIED and not event.new_window_state & Gdk.WindowState.WITHDRAWN and not self.window_state & Gdk.WindowState.ICONIFIED): self.minimized = True else: if (event.changed_mask & Gdk.WindowState.WITHDRAWN and not event.new_window_state & (Gdk.WindowState.WITHDRAWN)): # and \ self.minimized = False # track this self.window_state = event.new_window_state if settings.get_option('gui/minimize_to_tray', False): # old code to detect minimization # -> it must have worked at some point, perhaps this is a GTK version # specific set of behaviors? Current code works now on 2.24.17 # if wm_state is not None: # if '_NET_WM_STATE_HIDDEN' in wm_state[2]: # show tray # window.hide # else # destroy tray if self.minimized != prev_minimized and self.minimized is True: if (not settings.get_option('gui/use_tray', False) and self.controller.tray_icon is None): self.controller.tray_icon = tray.TrayIcon(self) window.hide() elif (not settings.get_option('gui/use_tray', False) and self.controller.tray_icon is not None): self.controller.tray_icon.destroy() self.controller.tray_icon = None return False
def migrate(): """ Migrate normal/unified engine users to gstreamer """ engine = settings.get_option('player/engine', None) if engine in ['normal', 'unified']: settings.set_option('player/engine', 'gstreamer')
def add_to_playlist(self, widget, start_editing=None, wget=False): playlist_handle = self.play.get_selected_playlist().playlist model, mysel = self.tw.get_selection().get_selected_rows() myTrack = [] for i in mysel: tr = trax.Track(self.comp[i[0]]["mp3"]) tr.set_tag_raw("artist", self.comp[i[0]]["artist"]) tr.set_tag_raw("title", self.comp[i[0]]["track"]) tr.set_tag_raw("album", "Vkontakte.ru") myTrack.append(tr) if not wget: playlist_handle.add_tracks(myTrack, None) else: for i in mysel: path = settings.get_option("vk_exaile/path", os.getenv("HOME")) if path.strip() == "": settings.set_option("vk_exaile/path", os.getenv("HOME")) path = os.getenv("HOME") elif not os.path.exists(path.strip()): os.system("mkdir '%s'" % path.strip()) res = os.system( 'wget -b -O "%s/%s - %s.mp3" %s -o /dev/null' % (path, self.comp[i[0]]["artist"], self.comp[i[0]]["track"], self.comp[i[0]]["mp3"]))
def apply(self, value=None): """ Applies this setting """ if not self.done(): return False if value is None: value = self._get_value() if value is None: return True if value != '': hashfunc = hashlib.new(self.type) hashfunc.update(value) value = hashfunc.hexdigest() oldvalue = settings.get_option(self.name, self.default) if value != oldvalue: settings.set_option(self.name, value) self.widget.set_text(value) self.widget.set_visibility(True) self._delete_text_id = self.widget.connect('delete-text', self.on_delete_text) self._insert_text_id = self.widget.connect('insert-text', self.on_insert_text) return True
def set_column_width(self, col, stuff=None): """ Called when the user resizes a column """ name = {self.colname: 'filename', self.colsize: 'size'}[col] name = "gui/files_%s_col_width" % name settings.set_option(name, col.get_width(), save=False)
def save_panel_settings(self): if self.loading_panels: return param = dict([(k, v.opts) for k, v in self.panels.iteritems()]) settings.set_option('gui/panels', param)
def _destroy_gui_hooks(self): ''' Removes any hooks from the main Exaile GUI ''' if not self.hooked: return info_area = main.mainwindow().info_area play_toolbar = main.mainwindow().builder.get_object('play_toolbar') # detach main GUI elements parent = play_toolbar.get_parent() parent.remove(play_toolbar) parent = info_area.get_parent() parent.remove(info_area) # detach the element we added to hold them parent = self.pane.get_parent() parent.remove(self.pane) # reattach parent.pack_start(info_area, False, False, 0) parent.reorder_child(info_area, 0) parent.pack_start(play_toolbar, False, False, 0) # remove player events self._setup_events(event.remove_callback) self.hooked = False settings.set_option('plugin/previewdevice/shown', False) logger.debug('Preview device unhooked')
def adjust_preamp(self, widget): """ Adjust the preamp """ if widget.get_value() != settings.get_option("plugin/equalizer/pre"): settings.set_option("plugin/equalizer/pre", widget.get_value()) self.combo_presets.set_active(0)
def LoopStatus(self, value): playlist = QUEUE.current_playlist if hasattr(playlist, "set_repeat"): # <= 0.3.2 if value == 'Playlist': enabled, mode = True, 'playlist' elif value == 'Track': enabled, mode = True, 'track' else: enabled, mode = False, 'none' logger.debug("LoopStatus set: old, %r, %r" % (enabled, mode)) playlist.set_repeat(enabled, mode) settings.set_option('playback/repeat', enabled) if enabled: settings.set_option('playback/repeat_mode', mode) else: # >= 0.3.3 if value == 'Playlist': mode = 'all' elif value == 'Track': mode = 'track' else: mode = 'disabled' logger.debug("LoopStatus set: new, %r" % mode) playlist.set_repeat_mode(mode)
def on_playlist_utilities_bar_visible_toggled(self, checkmenuitem): """ Shows or hides the playlist utilities bar """ settings.set_option( 'gui/playlist_utilities_bar_visible', checkmenuitem.get_active() )
def winclose(self,*arg): settings.set_option('plugin/LyricDisp/windowpositionx', self.window.get_position()[0]) settings.set_option('plugin/LyricDisp/windowpositiony', self.window.get_position()[1]) global TIMER, PLUGIN try:gobject.source_remove(TIMER) except:pass PLUGIN = None return False
def engine_notify_user_volume_change(self, vol): """ Engine calls this when something inside the engine changes the user volume. .. note:: Only to be called from engine """ settings.set_option('%s/volume' % self._name, vol)
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)
def VolumeSet(self, volume): """ Sets the volume, arument in the range [0, 100] """ if volume < 0 or volume > 100: pass settings.set_option('player/volume', volume / 100)
def engine_notify_user_volume_change(self, vol): ''' Engine calls this when something inside the engine changes the user volume. .. note:: Only to be called from engine ''' settings.set_option('%s/volume' % self._name, vol)
def window_state_change_event(self, window, event): """ Saves the current maximized and fullscreen states and minimizes to tray if requested """ if event.changed_mask & gtk.gdk.WINDOW_STATE_MAXIMIZED: settings.set_option("gui/mainw_maximized", bool(event.new_window_state & gtk.gdk.WINDOW_STATE_MAXIMIZED)) if event.changed_mask & gtk.gdk.WINDOW_STATE_FULLSCREEN: self._fullscreen = bool(event.new_window_state & gtk.gdk.WINDOW_STATE_FULLSCREEN) # detect minimization state changes prev_minimized = self.minimized if not self.minimized: if ( event.changed_mask & gtk.gdk.WINDOW_STATE_ICONIFIED and not event.changed_mask & gtk.gdk.WINDOW_STATE_WITHDRAWN and event.new_window_state & gtk.gdk.WINDOW_STATE_ICONIFIED and not event.new_window_state & gtk.gdk.WINDOW_STATE_WITHDRAWN and not self.window_state & gtk.gdk.WINDOW_STATE_ICONIFIED ): self.minimized = True else: if event.changed_mask & gtk.gdk.WINDOW_STATE_WITHDRAWN and not event.new_window_state & ( gtk.gdk.WINDOW_STATE_WITHDRAWN ): # and \ self.minimized = False # track this self.window_state = event.new_window_state if settings.get_option("gui/minimize_to_tray", False): # old code to detect minimization # -> it must have worked at some point, perhaps this is a GTK version # specific set of behaviors? Current code works now on 2.24.17 # if wm_state is not None: # if '_NET_WM_STATE_HIDDEN' in wm_state[2]: # show tray # window.hide # else # destroy tray if self.minimized != prev_minimized and self.minimized == True: if not settings.get_option("gui/use_tray", False) and self.controller.tray_icon is None: self.controller.tray_icon = tray.TrayIcon(self) window.hide() elif window.window.property_get("_NET_WM_STATE") is None: if not settings.get_option("gui/use_tray", False) and self.controller.tray_icon is not None: self.controller.tray_icon.destroy() self.controller.tray_icon = None return False
def set_volume(self, volume): """ Sets the current user volume :param volume: the volume percentage :type volume: int """ volume = common.clamp(volume, 0, 100) settings.set_option("%s/volume" % self._name, volume / 100)
def do_configure_event(self, e): """ Stores the window size """ width, height = self.get_size() settings.set_option('plugin/osd/width', width) settings.set_option('plugin/osd/height', height) Gtk.Window.do_configure_event(self, e)
def test_cuts_cb(self): value = [] settings.set_option("collection/strip_list", value) track.Track._the_cuts_cb(None, None, "collection/strip_list") self.assertEqual(track.Track._Track__the_cuts, value) value = ["the", "foo"] settings.set_option("collection/strip_list", value) track.Track._the_cuts_cb(None, None, "collection/strip_list") self.assertEqual(track.Track._Track__the_cuts, value)
def set_volume(self, volume): """ Sets the current user volume :param volume: the volume percentage :type volume: int """ volume = min(volume, 100) volume = max(0, volume) settings.set_option("%s/volume" % self._name, volume / 100.0)
def migrate(): """ Enables the OSD plugin if the builtin OSD was originally enabled """ plugins = settings.get_option('plugins/enabled', []) if settings.get_option('osd/enabled', False) and 'osd' not in plugins: settings.set_option('plugins/enabled', plugins + ['osd']) settings.set_option('osd/enabled', False)
def test_cuts_cb(self): value = [] settings.set_option('collection/strip_list', value) track.Track._the_cuts_cb(None, None, 'collection/strip_list') assert track.Track._Track__the_cuts == value value = ['the', 'foo'] settings.set_option('collection/strip_list', value) track.Track._the_cuts_cb(None, None, 'collection/strip_list') assert track.Track._Track__the_cuts == value
def migrate(): """ Enables the OSD plugin if the builtin OSD was originally enabled """ plugins = settings.get_option('plugins/enabled', []) if settings.get_option('osd/enabled', False) and not 'osd' in plugins: settings.set_option('plugins/enabled', plugins + ['osd']) settings.set_option('osd/enabled', False)
def test_cuts_cb(self): value = [] settings.set_option('collection/strip_list', value) track.Track._the_cuts_cb(None, None, 'collection/strip_list') self.assertEqual(track.Track._Track__the_cuts, value) value = ['the', 'foo'] settings.set_option('collection/strip_list', value) track.Track._the_cuts_cb(None, None, 'collection/strip_list') self.assertEqual(track.Track._Track__the_cuts, value)
def do_configure_event(self, e): """ Stores the window size """ width, height = self.get_size() settings.set_option('plugin/osd/width', width) settings.set_option('plugin/osd/height', height) gtk.Window.do_configure_event(self, e)
def teardown(self, exaile): '''Called when exaile is exiting''' if settings.get_option('plugin/history/save_on_exit', history_preferences.save_on_exit_default ): self.history_playlist.save_to_location( self.history_loc ) settings.set_option( 'plugin/history/shown', self.is_shown() ) else: settings.set_option( 'plugin/history/shown', False ) self.show_history(False)
def set_preferred_order(self, order): """ Sets the preferred search order :param order: a list containing the order you'd like to search first """ if not type(order) in (list, tuple): raise AttributeError("order must be a list or tuple") self.preferred_order = order settings.set_option('lyrics/preferred_order', list(order))
def set_preferred_order(self, order): """ Sets the preferred search order :param order: a list containing the order you'd like to search first """ if not type(order) in (list, tuple): raise TypeError("order must be a list or tuple") self.order = order settings.set_option('covers/preferred_order', list(order))
def migrate(): """ Migrates the old 'miscellaneous/rating_*' to the new 'rating/*' settings """ if settings.MANAGER.has_option('miscellaneous/rating_steps'): value = settings.get_option('miscellaneous/rating_steps', 5) settings.set_option('rating/maximum', value) if settings.MANAGER.has_option('miscellaneous/rating_widget_tracks_limit'): value = settings.get_option('miscellaneous/rating_widget_tracks_limit', 100) settings.set_option('rating/tracks_limit', value)
def do_button_release_event(self, e): """ Finishes the dragging process and saves the window position """ if e.button == 1: settings.set_option('plugin/osd/position', list(self.get_position())) self.set_data('drag-origin', None) self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.ARROW)) return True
def on_panel_switch(self, notebook, page, pagenum): """ Saves the currently selected panel """ if self.exaile.loading: return page = notebook.get_nth_page(pagenum) for i, panel in self.panels.items(): if panel._child == page: settings.set_option('gui/last_selected_panel', i) return
def set_column_width(self, col, stuff=None): """ Called when the user resizes a column """ name = {self.colname: 'filename', self.colsize: 'size'}[col] name = "gui/files_%s_col_width" % name # this option gets triggered all the time, which is annoying when debugging, # so only set it when it actually changes w = col.get_width() if settings.get_option(name, w) != w: settings.set_option(name, w, save=False)
def on_button_toggled(self, button): """ Mutes or unmutes the volume """ if button.get_active(): self.restore_volume = settings.get_option(self.__volume_setting, 1) volume = 0 else: volume = self.restore_volume if self.restore_volume > 0: settings.set_option(self.__volume_setting, volume)
def __on_playback_track_start(self, event, player, track): '''Every time a track plays, add it to the playlist''' maxlen = int(settings.get_option( 'plugin/history/history_length', history_preferences.history_length_default )) if maxlen < 0: maxlen = 0 settings.set_option( 'plugin/history/history_length', 0 ) if len(self) >= maxlen-1: Playlist.__delitem__( self, slice(0, max(0, len(self)-(maxlen-1)), None) ) Playlist.__setitem__( self, slice(len(self),len(self),None), [track] )
def on_panel_switch(self, notebook, page, pagenum): """ Saves the currently selected panel """ if self.exaile.loading: return page = notebook.get_nth_page(pagenum) for name, data in self.panels.iteritems(): if data.tab.page == page: settings.set_option('gui/last_selected_panel', name) return
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 migrate_settings(): '''Automatically migrate group tagger 0.1 settings to 0.2''' if settings.get_option(migrated_option, False): default_groups = settings.get_option('plugin/grouptagger/default_groups', None) if default_groups is not None: group_categories = {_('Uncategorized'): [True, default_groups]} set_group_categories(group_categories) # settings.remove_option( 'plugin/grouptagger/default_groups' ) settings.set_option(migrated_option, True)
def do_button_release_event(self, e): """ Finishes the dragging process and saves the window position """ if e.button == 1: settings.set_option('plugin/osd/position', list(self.get_position())) self.drag_origin = None self.window.set_cursor(Gdk.Cursor.new(Gdk.CursorType.ARROW)) return True