def test_basic(self): self.failIf(get_scan_dirs()) if os.name == "nt": set_scan_dirs([u"C:\\foo", u"D:\\bar", u""]) self.failUnlessEqual(get_scan_dirs(), [u"C:\\foo", u"D:\\bar"]) else: set_scan_dirs(["foo", "bar", ""]) self.failUnlessEqual(get_scan_dirs(), ["foo", "bar"])
def test_get_scan_dirs(self): some_path = os.path.join(get_home_dir(), "foo") if os.name != "nt": some_path = unexpand(some_path) config.set('settings', 'scan', some_path) assert expanduser(some_path) in get_scan_dirs() assert all([isinstance(p, fsnative) for p in get_scan_dirs()])
def __init__(self, library): super(FileSystem, self).__init__() sw = ScrolledWindow() sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) sw.set_shadow_type(Gtk.ShadowType.IN) dt = MainDirectoryTree(folders=get_scan_dirs()) targets = [("text/x-quodlibet-songs", Gtk.TargetFlags.SAME_APP, self.TARGET_QL), ("text/uri-list", 0, self.TARGET_EXT)] targets = [Gtk.TargetEntry.new(*t) for t in targets] dt.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, targets, Gdk.DragAction.COPY) dt.connect('drag-data-get', self.__drag_data_get) sel = dt.get_selection() sel.unselect_all() connect_obj(sel, 'changed', copool.add, self.__songs_selected, dt) sel.connect("changed", self._on_selection_changed) dt.connect('row-activated', lambda *a: self.songs_activated()) sw.add(dt) self.pack_start(sw, True, True, 0) self.show_all()
def enabled(self): if not self.running: wm = WatchManager() self.event_handler = LibraryEvent(library=app.library) FLAGS = ['IN_DELETE', 'IN_CLOSE_WRITE', # 'IN_MODIFY', 'IN_MOVED_FROM', 'IN_MOVED_TO', 'IN_CREATE'] masks = [EventsCodes.FLAG_COLLECTIONS['OP_FLAGS'][s] for s in FLAGS] mask = reduce(operator.or_, masks, 0) if self.USE_THREADS: print_d("Using threaded notifier") self.notifier = ThreadedNotifier(wm, self.event_handler) # Daemonize to ensure thread dies on exit self.notifier.daemon = True self.notifier.start() else: self.notifier = Notifier(wm, self.event_handler, timeout=100) GLib.timeout_add(1000, self.unthreaded_callback) for path in get_scan_dirs(): real_path = os.path.realpath(path) print_d('Watching directory %s for %s (mask: %x)' % (real_path, FLAGS, mask)) # See https://github.com/seb-m/pyinotify/wiki/ # Frequently-Asked-Questions wm.add_watch(real_path, mask, rec=True, auto_add=True) self.running = True
def enabled(self): if not self.running: wm = WatchManager() self.event_handler = LibraryEvent(app.library) # Choose event types to watch for # FIXME: watch for IN_CREATE or for some reason folder copies # are missed, --nickb FLAGS = ['IN_DELETE', 'IN_CLOSE_WRITE',# 'IN_MODIFY', 'IN_MOVED_FROM', 'IN_MOVED_TO', 'IN_CREATE'] mask = reduce(lambda x, s: x | EventsCodes.ALL_FLAGS[s], FLAGS, 0) if self.USE_THREADS: print_d("Using threaded notifier") self.notifier = ThreadedNotifier(wm, self.event_handler) # Daemonize to ensure thread dies on exit self.notifier.daemon = True self.notifier.start() else: self.notifier = Notifier(wm, self.event_handler, timeout=100) GLib.timeout_add(1000, self.unthreaded_callback) for path in get_scan_dirs(): print_d('Watching directory %s for %s' % (path, FLAGS)) # See https://github.com/seb-m/pyinotify/wiki/ # Frequently-Asked-Questions wm.add_watch(path, mask, rec=True, auto_add=True) self.running = True
def enabled(self): if not self.running: wm = WatchManager() self.event_handler = LibraryEvent(app.library) # Choose event types to watch for # FIXME: watch for IN_CREATE or for some reason folder copies # are missed, --nickb FLAGS = [ 'IN_DELETE', 'IN_CLOSE_WRITE', # 'IN_MODIFY', 'IN_MOVED_FROM', 'IN_MOVED_TO', 'IN_CREATE' ] mask = reduce(lambda x, s: x | EventsCodes.ALL_FLAGS[s], FLAGS, 0) if self.USE_THREADS: print_d("Using threaded notifier") self.notifier = ThreadedNotifier(wm, self.event_handler) # Daemonize to ensure thread dies on exit self.notifier.daemon = True self.notifier.start() else: self.notifier = Notifier(wm, self.event_handler, timeout=100) GLib.timeout_add(1000, self.unthreaded_callback) for path in get_scan_dirs(): print_d('Watching directory %s for %s' % (path, FLAGS)) # See https://github.com/seb-m/pyinotify/wiki/ # Frequently-Asked-Questions wm.add_watch(path, mask, rec=True, auto_add=True) self.running = True
def __init__(self, parent): if self.is_not_unique(): return super(PreferencesWindow, self).__init__() self.current_scan_dirs = get_scan_dirs() self.set_title(_("Preferences") + " - Quod Libet") self.set_border_width(12) self.set_resizable(False) self.set_transient_for(qltk.get_top_parent(parent)) self.__notebook = notebook = qltk.Notebook() for Page in [self.SongList, self.Browsers, self.Player, self.Library, self.Tagging]: notebook.append_page(Page()) close = Gtk.Button(stock=Gtk.STOCK_CLOSE) close.connect_object('clicked', lambda x: x.destroy(), self) button_box = Gtk.HButtonBox() button_box.set_layout(Gtk.ButtonBoxStyle.END) button_box.pack_start(close, True, True, 0) vbox = Gtk.VBox(spacing=12) vbox.pack_start(notebook, True, True, 0) vbox.pack_start(button_box, False, True, 0) self.add(vbox) self.connect_object('destroy', PreferencesWindow.__destroy, self) self.get_child().show_all()
def get_init_select_dir(): scandirs = get_scan_dirs() if scandirs and os.path.isdir(scandirs[-1]): # start with last added directory return scandirs[-1] else: return get_home_dir()
def get_init_select_dir(): scandirs = get_scan_dirs() if scandirs and os.path.isdir(scandirs[-1]): # start with last added directory return scandirs[-1] else: return const.HOME
def removeEmptyDirs(self, directory): if directory in get_scan_dirs(): return elif not os.listdir(directory): os.rmdir(directory) self.removeEmptyDirs(os.path.abspath(os.path.join(directory, os.pardir)))
def __init__(self): super(ScanBox, self).__init__(spacing=6) self.model = model = Gtk.ListStore(str) view = RCMHintedTreeView(model=model) view.set_fixed_height_mode(True) view.set_headers_visible(False) view.set_tooltip_text( _("Songs in the listed folders will be added " "to the library during a library refresh")) menu = Gtk.Menu() remove_item = Gtk.ImageMenuItem(label=Gtk.STOCK_REMOVE, use_stock=True) menu.append(remove_item) menu.show_all() view.connect('popup-menu', self.__popup, menu) remove_item.connect_object('activate', self.__remove, view) sw = Gtk.ScrolledWindow() sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) sw.set_shadow_type(Gtk.ShadowType.IN) sw.add(view) sw.set_size_request(-1, max(sw.size_request().height, 80)) render = Gtk.CellRendererText() render.set_property('ellipsize', Pango.EllipsizeMode.END) def cdf(column, cell, model, iter, data): row = model[iter] cell.set_property('text', unexpand(row[0])) column = Gtk.TreeViewColumn(None, render) column.set_cell_data_func(render, cdf) column.set_sizing(Gtk.TreeViewColumnSizing.FIXED) view.append_column(column) add = Gtk.Button(stock=Gtk.STOCK_ADD) add.connect("clicked", self.__add) remove = Gtk.Button(stock=Gtk.STOCK_REMOVE) selection = view.get_selection() selection.set_mode(Gtk.SelectionMode.MULTIPLE) selection.connect("changed", self.__select_changed, remove) selection.emit("changed") remove.connect_object("clicked", self.__remove, view) vbox = Gtk.VBox(spacing=6) vbox.pack_start(add, False, True, 0) vbox.pack_start(remove, False, True, 0) self.pack_start(sw, True, True, 0) self.pack_start(vbox, False, True, 0) paths = map(fsdecode, get_scan_dirs()) for path in paths: model.append(row=[path]) for child in self.get_children(): child.show_all()
def __init__(self, parent, init_dir): super(MusicFolderChooser, self).__init__(parent, _("Add Music"), init_dir) cb = Gtk.CheckButton(_("Watch this folder for new songs")) # enable if no folders are being watched cb.set_active(not get_scan_dirs()) cb.show() self.set_extra_widget(cb)
def __init__(self): super(ScanBox, self).__init__(spacing=6) self.model = model = Gtk.ListStore(str) view = RCMHintedTreeView(model=model) view.set_fixed_height_mode(True) view.set_headers_visible(False) view.set_tooltip_text(_("Songs in the listed folders will be added " "to the library during a library refresh")) menu = Gtk.Menu() remove_item = MenuItem(_("_Remove"), Icons.LIST_REMOVE) menu.append(remove_item) menu.show_all() view.connect('popup-menu', self.__popup, menu) connect_obj(remove_item, 'activate', self.__remove, view) sw = Gtk.ScrolledWindow() sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) sw.set_shadow_type(Gtk.ShadowType.IN) sw.add(view) sw.set_size_request(-1, max(sw.size_request().height, 80)) render = Gtk.CellRendererText() render.set_property('ellipsize', Pango.EllipsizeMode.END) def cdf(column, cell, model, iter, data): row = model[iter] cell.set_property('text', unexpand(row[0])) column = Gtk.TreeViewColumn(None, render) column.set_cell_data_func(render, cdf) column.set_sizing(Gtk.TreeViewColumnSizing.FIXED) view.append_column(column) add = Button(_("_Add"), Icons.LIST_ADD) add.connect("clicked", self.__add) remove = Button(_("_Remove"), Icons.LIST_REMOVE) selection = view.get_selection() selection.set_mode(Gtk.SelectionMode.MULTIPLE) selection.connect("changed", self.__select_changed, remove) selection.emit("changed") connect_obj(remove, "clicked", self.__remove, view) vbox = Gtk.VBox(spacing=6) vbox.pack_start(add, False, True, 0) vbox.pack_start(remove, False, True, 0) self.pack_start(sw, True, True, 0) self.pack_start(vbox, False, True, 0) paths = map(fsdecode, get_scan_dirs()) for path in paths: model.append(row=[path]) for child in self.get_children(): child.show_all()
def __destroy(self): config.save() new_dirs = set(get_scan_dirs()) gone_dirs = set(self.current_scan_dirs) - new_dirs if new_dirs - set(self.current_scan_dirs): print_d("Library paths have been added, re-scanning...") scan_library(app.library, force=False) elif gone_dirs: copool.add(app.librarian.remove_roots, gone_dirs)
def __init__(self): super().__init__(spacing=6) self.model = model = ObjectStore() view = RCMHintedTreeView(model=model) view.set_fixed_height_mode(True) view.set_headers_visible(False) menu = Gtk.Menu() remove_item = MenuItem(_("_Remove"), Icons.LIST_REMOVE) menu.append(remove_item) menu.show_all() view.connect('popup-menu', self.__popup, menu) connect_obj(remove_item, 'activate', self.__remove, view) sw = Gtk.ScrolledWindow() sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) sw.set_shadow_type(Gtk.ShadowType.IN) sw.add(view) sw.set_size_request(-1, max(sw.size_request().height, 80)) sw.set_tooltip_text(_("Songs in the listed folders will be added " "to the library during a library refresh")) render = Gtk.CellRendererText() render.set_property('ellipsize', Pango.EllipsizeMode.END) def cdf(column, cell, model, iter_, data): path = model.get_value(iter_) cell.set_property('text', fsn2text(unexpand(path))) column = Gtk.TreeViewColumn(None, render) column.set_cell_data_func(render, cdf) column.set_sizing(Gtk.TreeViewColumnSizing.FIXED) view.append_column(column) add = Button(_("_Add"), Icons.LIST_ADD) add.connect("clicked", self.__add) remove = Button(_("_Remove"), Icons.LIST_REMOVE) selection = view.get_selection() selection.set_mode(Gtk.SelectionMode.MULTIPLE) selection.connect("changed", self.__select_changed, remove) selection.emit("changed") connect_obj(remove, "clicked", self.__remove, view) vbox = Gtk.VBox(spacing=6) vbox.pack_start(add, False, True, 0) vbox.pack_start(remove, False, True, 0) self.pack_start(sw, True, True, 0) self.pack_start(vbox, False, True, 0) for path in get_scan_dirs(): model.append(row=[path]) for child in self.get_children(): child.show_all()
def open_chooser(self, action): last_dir = self.last_dir if not os.path.exists(last_dir): last_dir = get_home_dir() class MusicFolderChooser(FolderChooser): def __init__(self, parent, init_dir): super(MusicFolderChooser, self).__init__(parent, _("Add Music"), init_dir) cb = Gtk.CheckButton(_("Watch this folder for new songs")) # enable if no folders are being watched cb.set_active(not get_scan_dirs()) cb.show() self.set_extra_widget(cb) def run(self): fns = super(MusicFolderChooser, self).run() cb = self.get_extra_widget() return fns, cb.get_active() class MusicFileChooser(FileChooser): def __init__(self, parent, init_dir): super(MusicFileChooser, self).__init__(parent, _("Add Music"), formats.filter, init_dir) if action.get_name() == "AddFolders": dialog = MusicFolderChooser(self, last_dir) fns, do_watch = dialog.run() dialog.destroy() if fns: fns = map(glib2fsnative, fns) # scan them self.last_dir = fns[0] copool.add(self.__library.scan, fns, cofuncid="library", funcid="library") # add them as library scan directory if do_watch: dirs = get_scan_dirs() for fn in fns: if fn not in dirs: dirs.append(fn) set_scan_dirs(dirs) else: dialog = MusicFileChooser(self, last_dir) fns = dialog.run() dialog.destroy() if fns: fns = map(glib2fsnative, fns) self.last_dir = os.path.dirname(fns[0]) for filename in map(os.path.realpath, fns): self.__library.add_filename(filename)
def __configure_scan_dirs(self, library): """Get user to configure scan dirs, if none is set up""" if not get_scan_dirs() and not len(library) and quodlibet.is_first_session("quodlibet"): print_d("Couldn't find any scan dirs") resp = ConfirmLibDirSetup(self).run() if resp == ConfirmLibDirSetup.RESPONSE_SETUP: prefs = PreferencesWindow(self) prefs.set_page("library") prefs.show()
def __configure_scan_dirs(self, library): """Get user to configure scan dirs, if none is set up""" if not get_scan_dirs() and not len(library) and \ quodlibet.is_first_session("quodlibet"): print_d("Couldn't find any scan dirs") resp = ConfirmLibDirSetup(self).run() if resp == ConfirmLibDirSetup.RESPONSE_SETUP: prefs = PreferencesWindow(self) prefs.set_page("library") prefs.show()
def __configure_scan_dirs(self, library): """Get user to configure scan dirs, if none is set up""" if not get_scan_dirs() and not len(library) and \ quodlibet.is_first_session("quodlibet"): print_d("Couldn't find any scan dirs") if qltk.ConfirmAction(self, _("Set up library directories?"), _("You don't have any music library set up. " "Would you like to do that now?")).run(): prefs = PreferencesWindow(self) prefs.set_page("library") prefs.show()
def open_chooser(self, action): last_dir = self.last_dir if not os.path.exists(last_dir): last_dir = get_home_dir() class MusicFolderChooser(FolderChooser): def __init__(self, parent, init_dir): super(MusicFolderChooser, self).__init__( parent, _("Add Music"), init_dir) cb = Gtk.CheckButton(_("Watch this folder for new songs")) # enable if no folders are being watched cb.set_active(not get_scan_dirs()) cb.show() self.set_extra_widget(cb) def run(self): fns = super(MusicFolderChooser, self).run() cb = self.get_extra_widget() return fns, cb.get_active() class MusicFileChooser(FileChooser): def __init__(self, parent, init_dir): super(MusicFileChooser, self).__init__( parent, _("Add Music"), formats.filter, init_dir) if action.get_name() == "AddFolders": dialog = MusicFolderChooser(self, last_dir) fns, do_watch = dialog.run() dialog.destroy() if fns: fns = map(glib2fsnative, fns) # scan them self.last_dir = fns[0] copool.add(self.__library.scan, fns, cofuncid="library", funcid="library") # add them as library scan directory if do_watch: dirs = get_scan_dirs() for fn in fns: if fn not in dirs: dirs.append(fn) set_scan_dirs(dirs) else: dialog = MusicFileChooser(self, last_dir) fns = dialog.run() dialog.destroy() if fns: fns = map(glib2fsnative, fns) self.last_dir = os.path.dirname(fns[0]) for filename in map(os.path.realpath, fns): self.__library.add_filename(filename)
def init(cache_fn=None): """Set up the library and return the main one. Return a main library, and set a librarian for all future SongLibraries. """ SongFileLibrary.librarian = SongLibrary.librarian = SongLibrarian() watch = config.getboolean("library", "watch") library = SongFileLibrary("main", watch_dirs=get_scan_dirs() if watch else []) if cache_fn: library.load(cache_fn) return library
def __init__(self, parent, open_page=None, all_pages=True): if self.is_not_unique(): return super().__init__() self.current_scan_dirs = get_scan_dirs() self.set_title(_("Preferences")) self.set_resizable(False) self.set_transient_for(qltk.get_top_parent(parent)) self.__notebook = notebook = qltk.Notebook() pages = [self.Tagging] if all_pages: pages = [self.SongList, self.Browsers, self.Player, self.Library ] + pages for Page in pages: page = Page() page.show() notebook.append_page(page) if open_page in [page.name for page in pages]: self.set_page(open_page) else: page_name = config.get("memory", "prefs_page", "") self.set_page(page_name) def on_switch_page(notebook, page, page_num): config.set("memory", "prefs_page", page.name) notebook.connect("switch-page", on_switch_page) close = Button(_("_Close"), Icons.WINDOW_CLOSE) connect_obj(close, 'clicked', lambda x: x.destroy(), self) button_box = Gtk.HButtonBox() button_box.set_layout(Gtk.ButtonBoxStyle.END) button_box.pack_start(close, True, True, 0) self.use_header_bar() if self.has_close_button(): self.set_border_width(0) notebook.set_show_border(False) self.add(notebook) else: self.set_border_width(12) vbox = Gtk.VBox(spacing=12) vbox.pack_start(notebook, True, True, 0) vbox.pack_start(button_box, False, True, 0) self.add(vbox) connect_obj(self, 'destroy', PreferencesWindow.__destroy, self) self.get_child().show_all()
def get_init_select_dir(): """Returns a path which might be a good starting point when browsing for a path for library scanning. Returns: fsnative """ scandirs = get_scan_dirs() if scandirs and os.path.isdir(scandirs[-1]): # start with last added directory return scandirs[-1] else: return get_home_dir()
def __init__(self, parent): if self.is_not_unique(): return super(PreferencesWindow, self).__init__() self.current_scan_dirs = get_scan_dirs() self.set_title(_("Preferences")) self.set_resizable(False) self.set_transient_for(qltk.get_top_parent(parent)) self.__notebook = notebook = qltk.Notebook() for Page in [self.SongList, self.Browsers, self.Player, self.Library, self.Tagging]: page = Page() page.show() notebook.append_page(page) page_name = config.get("memory", "prefs_page", "") self.set_page(page_name) def on_switch_page(notebook, page, page_num): config.set("memory", "prefs_page", page.name) notebook.connect("switch-page", on_switch_page) close = Button(_("_Close"), Icons.WINDOW_CLOSE) connect_obj(close, 'clicked', lambda x: x.destroy(), self) button_box = Gtk.HButtonBox() button_box.set_layout(Gtk.ButtonBoxStyle.END) button_box.pack_start(close, True, True, 0) self.use_header_bar() if self.has_close_button(): self.set_border_width(0) notebook.set_show_border(False) self.add(notebook) else: self.set_border_width(12) vbox = Gtk.VBox(spacing=12) vbox.pack_start(notebook, True, True, 0) vbox.pack_start(button_box, False, True, 0) self.add(vbox) connect_obj(self, 'destroy', PreferencesWindow.__destroy, self) self.get_child().show_all()
def test_get_scan_dirs(self): some_path = os.path.join(unexpand(get_home_dir()), "foo") config.set('settings', 'scan', some_path) assert expanduser(some_path) in get_scan_dirs() assert all([isinstance(p, fsnative) for p in get_scan_dirs()])
def _get_ql_base_dir(cls): dirs = get_scan_dirs() return os.path.realpath(dirs[0]) if dirs else ""
class SqueezeboxPluginMixin(PluginConfigMixin): """ All the Squeezebox connection / communication code in one delicious class """ # Maintain a singleton; we only support one SB server live in QL server = None ql_base_dir = (os.path.realpath(get_scan_dirs()[0]) if get_scan_dirs() else "") print_d("Using QL library dir of %s" % ql_base_dir) # We want all derived classes to share the config section CONFIG_SECTION = "squeezebox" @classmethod def get_sb_path(cls, song): """Gets a SB path to `song` by simple substitution""" path = song('~filename') return path.replace(cls.ql_base_dir, cls.server.get_library_dir()) @classmethod def post_reconnect(cls): pass @staticmethod def _show_dialog(dialog_type, msg): dialog = Message(dialog_type, app.window, "Squeezebox", msg) dialog.connect('response', lambda dia, resp: dia.destroy()) dialog.show() @staticmethod def quick_dialog(msg, dialog_type=Gtk.MessageType.INFO): GLib.idle_add(SqueezeboxPluginMixin._show_dialog, dialog_type, msg) @classmethod def set_player(cls, val): cls.server.current_player = val cls.config_set("current_player", val) print_d("Setting player to #%d (%s)" % (val, cls.server.players[val])) @classmethod def check_settings(cls, button): cls.init_server() if cls.server.is_connected: ret = 0 if len(cls.server.players) > 1: dialog = GetPlayerDialog(app.window, cls.server.players, cls.server.current_player) ret = dialog.run() or 0 else: cls.quick_dialog("Squeezebox OK. Using the only player (%s)." % cls.server.players[0]) cls.set_player(ret) # TODO: verify sanity of SB library path # Manage the changeover as best we can... cls.post_reconnect() else: cls.quick_dialog(_("Couldn't connect to %s") % (cls.server,), Gtk.MessageType.ERROR) @classmethod def PluginPreferences(cls, parent): def value_changed(entry, key): if entry.get_property('sensitive'): cls.server.config[key] = entry.get_text() config.set("plugins", "squeezebox_" + key, entry.get_text()) vb = Gtk.VBox(spacing=12) if not cls.server: cls.init_server() cfg = cls.server.config # Server settings Frame cfg_frame = Gtk.Frame(label=_("<b>Squeezebox Server</b>")) cfg_frame.set_shadow_type(Gtk.ShadowType.NONE) cfg_frame.get_label_widget().set_use_markup(True) cfg_frame_align = Gtk.Alignment.new(0, 0, 1, 1) cfg_frame_align.set_padding(6, 6, 12, 12) cfg_frame.add(cfg_frame_align) # Tabulate all settings for neatness table = Gtk.Table(3, 2) table.set_col_spacings(6) table.set_row_spacings(6) rows = [] ve = UndoEntry() ve.set_text(cfg["hostname"]) ve.connect('changed', value_changed, 'server_hostname') rows.append((Gtk.Label(label=_("Hostname:")), ve)) ve = UndoEntry() ve.set_width_chars(5) ve.set_text(str(cfg["port"])) ve.connect('changed', value_changed, 'server_port') rows.append((Gtk.Label(label=_("Port:")), ve)) ve = UndoEntry() ve.set_text(cfg["user"]) ve.connect('changed', value_changed, 'server_user') rows.append((Gtk.Label(label=_("Username:"******"password"])) ve.connect('changed', value_changed, 'server_password') rows.append((Gtk.Label(label=_("Password:"******"library_dir"])) ve.set_tooltip_text(_("Library directory the server connects to.")) ve.connect('changed', value_changed, 'server_library_dir') rows.append((Gtk.Label(label=_("Library path:")), ve)) for (row, (label, entry)) in enumerate(rows): label.set_alignment(0.0, 0.5) table.attach(label, 0, 1, row, row + 1, xoptions=Gtk.AttachOptions.FILL) table.attach(entry, 1, 2, row, row + 1) # Add verify button button = Gtk.Button(_("_Verify settings"), use_underline=True) button.set_sensitive(cls.server is not None) button.connect('clicked', cls.check_settings) table.attach(button, 0, 2, row + 1, row + 2) cfg_frame_align.add(table) vb.pack_start(cfg_frame, True, True, 0) debug = cls.ConfigCheckButton(_("Debug"), "debug") vb.pack_start(debug, True, True, 0) return vb @classmethod def init_server(cls): """Initialises a server, and connects to check if it's alive""" try: cur = int(cls.config_get("current_player", 0)) except ValueError: cur = 0 cls.server = SqueezeboxServer( hostname=cls.config_get("server_hostname", "localhost"), port=cls.config_get("server_port", 9090), user=cls.config_get("server_user", ""), password=cls.config_get("server_password", ""), library_dir=cls.config_get("server_library_dir", cls.ql_base_dir), current_player=cur, debug=cls.config_get_bool("debug", False)) try: ver = cls.server.get_version() if cls.server.is_connected: print_d( "Squeezebox server version: %s. Current player: #%d (%s)." % (ver, cur, cls.server.get_players()[cur]["name"])) except (IndexError, KeyError, SqueezeboxException) as e: print_d("Couldn't get player info (%s)." % e)
def __destroy(self): config.save() if self.current_scan_dirs != get_scan_dirs(): scan_library(app.library, force=False)
def __destroy(self): config.write(const.CONFIG) if self.current_scan_dirs != get_scan_dirs(): scan_library(app.library, force=False)
def __destroy(self): config.save() if self.current_scan_dirs != get_scan_dirs(): print_d("Library paths have changed, re-scanning...") scan_library(app.library, force=False)