def OnDownloadFilesTo(self, widget): try: _, dir = self.selected_folder.rsplit("\\", 1) except ValueError: dir = self.selected_folder path = os.path.join( self.frame.np.config.sections["transfers"]["downloaddir"], dir) if os.path.exists(path) and os.path.isdir(path): ldir = ChooseDir(self.frame.MainWindow, path, multichoice=False) else: ldir = ChooseDir( self.frame.MainWindow, self.frame.np.config.sections["transfers"]["downloaddir"], multichoice=False) if ldir is None: return try: self.OnDownloadFiles(widget, ldir[0]) except IOError: # failed to open self.frame.logMessage('failed to open %r for reading', ldir[0]) # notify user
def OnDownloadFilesTo(self, widget): dir = ChooseDir(self.frame.MainWindow, self.frame.np.config.sections["transfers"]["downloaddir"], multichoice=False) if dir is None: return for dirs in dir: self.OnDownloadFiles(widget, dirs) break
def OnDownloadDirectoryRecursiveTo(self, widget): dir = ChooseDir(self.frame.MainWindow, self.frame.np.config.sections["transfers"]["downloaddir"]) if dir is None: return try: self.DownloadDirectory(self.selected_folder, os.path.join(dir[0], ""), 1) except IOError: # failed to open self.frame.logMessage('Failed to open %r for reading', dir[0]) # notify user
def OnDownloadFoldersTo(self, widget): directories = ChooseDir(self.frame.MainWindow, self.frame.np.config.sections["transfers"]["downloaddir"], multichoice=False) if directories is None or directories == []: return destination = directories[0] for i in self.selected_results: user = i[0] folder = i[1].rsplit('\\', 1)[0] if user not in self.frame.np.requestedFolders: self.frame.np.requestedFolders[user] = {} if folder not in self.frame.np.requestedFolders[user]: """ Ensure we don't send folder content requests for a folder more than once, e.g. when several selected resuls belong to the same folder. """ self.frame.np.requestedFolders[user][folder] = destination self.frame.np.ProcessRequestToPeer(user, slskmessages.FolderContentsRequest(None, folder))
def OnDownloadFoldersTo(self, widget): directories = ChooseDir( self.frame.MainWindow, self.frame.np.config.sections["transfers"]["downloaddir"], multichoice=False) if directories is None or directories == []: return destination = directories[0] for i in self.selected_results: user = i[0] dir = '\\'.join(reversed(i[5].split('\\'))) if user not in self.frame.np.requestedFolders: self.frame.np.requestedFolders[user] = {} self.frame.np.requestedFolders[user][dir] = destination self.frame.np.ProcessRequestToPeer( user, slskmessages.FolderContentsRequest(None, dir))
def OnButtonPressed(self, widget): if self.initphase: return name = gtk.Buildable.get_name(widget) if name == "checkmyport": OpenUri( '='.join([ 'http://tools.slsknet.org/porttest.php?port', str(self.frame.np.waitport) ]), self.window) if name == "addshare": selected = ChooseDir(self.window.get_toplevel(), title=_("Add a shared directory")) if selected: for directory in selected: virtual = ComboBoxDialog( parent=self.frame.MainWindow, title=_("Virtual name"), message=_("Enter virtual name for '%(dir)s':") % {'dir': directory}) # If the virtual name is empty if virtual == '' or virtual is None: dlg = gtk.MessageDialog(transient_for=self.window, flags=0, type=gtk.MessageType.WARNING, buttons=gtk.ButtonsType.OK, text=_("Warning")) dlg.format_secondary_text( _("The chosen virtual name is empty")) dlg.run() dlg.destroy() pass else: # We get the current defined shares from the treeview model, paths = self.kids[ 'shareddirectoriestree'].get_selection( ).get_selected_rows() iter = model.get_iter_first() while iter is not None: # We reject the share if the virtual share name is already used if virtual == model.get_value(iter, 0): dlg = gtk.MessageDialog( transient_for=self.window, flags=0, type=gtk.MessageType.WARNING, buttons=gtk.ButtonsType.OK, text=_("Warning")) dlg.format_secondary_text( _("The chosen virtual name already exists") ) dlg.run() dlg.destroy() return # We also reject the share if the directory is already used elif directory == model.get_value(iter, 6): dlg = gtk.MessageDialog( transient_for=self.window, flags=0, type=gtk.MessageType.WARNING, buttons=gtk.ButtonsType.OK, text=_("Warning")) dlg.format_secondary_text( _("The chosen directory is already shared") ) dlg.run() dlg.destroy() return else: iter = model.iter_next(iter) # The share is unique: we can add it self.addshareddir((virtual, directory)) if name == "removeshares": model, paths = self.kids['shareddirectoriestree'].get_selection( ).get_selected_rows() refs = [gtk.TreeRowReference(model, x) for x in paths] for i in refs: self.sharelist.remove(self.sharelist.get_iter(i.get_path())) self.resetcompleteness()
def OnButtonPressed(self, widget): if self.initphase: return name = gtk.Buildable.get_name(widget) if name == "checkmyport": OpenUri('='.join([ 'http://tools.slsknet.org/porttest.php?port', str(self.frame.np.waitport) ])) if name == "addshare": selected = ChooseDir(self.window.get_toplevel(), title=_("Nicotine+") + ": " + _("Add a shared directory")) if selected: for directory in selected: virtual = input_box( self.frame, title=_("Virtual name"), message=_("Enter virtual name for '%(dir)s':") % {'dir': directory}) # If the virtual name is empty if virtual == '' or virtual is None: popupWarning(self.window, _("Warning"), _("The chosen virtual name is empty"), self.frame.images["n"]) pass else: # We get the current defined shares from the treeview model, paths = self.kids[ 'shareddirectoriestree'].get_selection( ).get_selected_rows() iter = model.get_iter_first() while iter is not None: # We reject the share if the virtual share name is already used if virtual == model.get_value(iter, 0): popupWarning( self.window, _("Warning"), _("The chosen virtual name already exist"), self.frame.images["n"]) return # We also reject the share if the directory is already used elif directory == model.get_value(iter, 6): popupWarning( self.window, _("Warning"), _("The chosen directory is already shared" ), self.frame.images["n"]) return else: iter = model.iter_next(iter) # The share is unique: we can add it self.addshareddir((virtual, directory)) if name == "removeshares": model, paths = self.kids['shareddirectoriestree'].get_selection( ).get_selected_rows() refs = [gtk.TreeRowReference(model, x) for x in paths] for i in refs: self.sharelist.remove(self.sharelist.get_iter(i.get_path())) self.resetcompleteness()