class NewFolder(Folder) : def loadFiles( self ) : self.database = Database( self.dbDir , self.shows ) self.database.loadDB() self.fileNames = [] for afile in os.listdir( self.path ) : if os.path.isfile( os.path.join( self.path, afile) ) : aFileName = NewFileName( afile, self.database ) self.fileNames.append( aFileName )
class VeefireGTK: """ Veefire GTK Interface """ def __init__(self): ## # Initialize Glade file ## self.gladefile = "veefire-gtk.glade" self.wTree = gtk.glade.XML(self.gladefile) dic = { "on_MainWindow_destroy": gtk.main_quit, "on_mainRevertButton_clicked": self.mainRevertButtonClicked, "on_mainRenameButton_clicked": self.mainRenameButtonClicked, "on_mainPreferencesButton_clicked": self.mainPreferencesButtonClicked, "on_mainAboutButton_clicked": self.mainAboutButtonClicked, "on_previewPreviewButton_clicked": self.previewPreviewButtonClicked, "on_previewSelectFolderButton_clicked": self.previewSelectFolderButtonClicked, "on_showsNewShowButton_clicked": self.showsNewShowButtonClicked, "on_showsDeleteShowButton_clicked": self.showsDeleteShowButtonClicked, "on_showsEditShowsButton_clicked": self.showsEditShowsButtonClicked, "on_showsUpdateButton_clicked": self.showsUpdateButtonClicked } self.wTree.signal_autoconnect(dic) ## # Initialize Database and Rename ## self.database = Database(Tools.databaseDir) self.database.loadDB() self.rename = NewRename(Tools.databaseDir, Tools.filetypesXML) ## # Main Buttons (Disable those buttons that depends on other functions) ## self.mainRevertButton = self.wTree.get_widget("mainRevertButton") self.mainRevertButton.set_sensitive(False) self.mainRenameButton = self.wTree.get_widget("mainRenameButton") self.mainRenameButton.set_sensitive(False) ## # Preview Buttons (Disable those buttons that depends on other functions) ## self.previewPreviewButton = self.wTree.get_widget( "previewPreviewButton") self.previewPreviewButton.set_sensitive(False) ## # # Initialize previewTree # ## self.previewStore = gtk.ListStore(str, str, str, str, object) self.previewView = self.wTree.get_widget("previewTree") self.previewView.set_model(self.previewStore) render = gtk.CellRendererText() col = gtk.TreeViewColumn("Original Name", render, text=0) col.set_resizable(True) self.previewView.append_column(col) render = gtk.CellRendererText() col = gtk.TreeViewColumn("Current Name", render, text=1) col.set_resizable(True) col.set_visible(False) self.previewView.append_column(col) render = gtk.CellRendererText() col = gtk.TreeViewColumn("Show", render, text=2) col.set_resizable(True) col.set_visible(False) self.previewView.append_column(col) render = gtk.CellRendererText() col = gtk.TreeViewColumn("Preview", render, text=3) col.set_resizable(True) col.set_visible(False) self.previewView.append_column(col) col = gtk.TreeViewColumn() col.set_visible(False) self.previewView.append_column(col) #Set the selection option so that only one row can be selected sel = self.previewView.get_selection() sel.set_mode(gtk.SELECTION_SINGLE) self.previewView.show() ## # # Initialize showsTree # ## self.showsStore = gtk.ListStore(str, str, object) self.showsStore.clear() self.database = Database(Tools.databaseDir) self.database.loadDB() preferences = Preferences(Tools.preferencesXML) preferences.load() if self.to_boolean(preferences['update-on-startup']) == True: #update warning dialog = gtk.MessageDialog( None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK, None) hbox = gtk.HBox() hbox.pack_start( gtk.Label( "The Database is updating. ( The program may appear to freeze during this process. )" ), False, 5, 5) dialog.vbox.pack_end(hbox, True, True, 0) dialog.show_all() dialog.run() if self.to_boolean(preferences['imdbtv-with-tests']) == True: testimdbtv = imdbtvtest() testimdbtv.testDownloadShowList() testimdbtv.testGetShowDetails() se = NewBackendInterface(Tools.databaseDir) se.updateDatabase() self.database.loadDB() dialog.destroy() for Show in self.database.database: self.showsStore.append([Show.name, Show.backend, Show]) self.showsView = self.wTree.get_widget("showsTree") self.showsView.set_model(self.showsStore) render = gtk.CellRendererText() col = gtk.TreeViewColumn("Name", render, text=0) self.showsView.append_column(col) render = gtk.CellRendererText() col = gtk.TreeViewColumn("Backend", render, text=1) self.showsView.append_column(col) col = gtk.TreeViewColumn() col.set_visible(False) self.showsView.append_column(col) #set the selection option so that only one row can be selected sel = self.showsView.get_selection() sel.set_mode(gtk.SELECTION_SINGLE) self.showsView.show() ## # # Initialize the showsTree's right-click menu # ## self.editShowMenu = self.wTree.get_widget("editShowMenu") self.editShowMenuUpdate = self.wTree.get_widget("editShowMenuUpdate") self.editShowMenuRemove = self.wTree.get_widget("editShowMenuRemove") self.showsView.connect('button_press_event', self.showMenu) self.editShowMenuUpdate.connect('activate', self.showMenuUpdate) self.editShowMenuRemove.connect('activate', self.showMenuRemove) ## ## ## def showMenu(self, treeview, event): ''' Right-click menu for Shows. ''' if event.button == 3: x = int(event.x) y = int(event.y) time = event.time pthinfo = treeview.get_path_at_pos(x, y) if pthinfo is not None: path, col, cellx, celly = pthinfo treeview.grab_focus() treeview.set_cursor(path, col, 0) self.editShowMenu.popup(None, None, None, event.button, time) return 1 def showMenuUpdate(self, widget): model, row = self.showsView.get_selection().get_selected() show = self.showsStore[row][2] # 2 is our object column. self.database.write() preferences = Preferences(Tools.preferencesXML) preferences.load() #update warning dialog = gtk.MessageDialog( None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK, None) hbox = gtk.HBox() hbox.pack_start( gtk.Label( "The Database is updating. ( The program may appear to freeze during this process. )" ), False, 5, 5) dialog.vbox.pack_end(hbox, True, True, 0) dialog.show_all() dialog.run() if self.to_boolean(preferences['imdbtv-with-tests']) == True: testimdbtv = imdbtvtest() testimdbtv.testDownloadShowList() testimdbtv.testGetShowDetails() se = NewBackendInterface(Tools.databaseDir, [show]) se.updateDatabase() dialog.destroy() #Fix treeview. Should manipulate, if necessary. self.showsStore.clear() self.database.loadDB() for Show in self.database.database: self.showsStore.append([Show.name, Show.backend, Show]) def showMenuRemove(self, widget): model, row = self.showsView.get_selection().get_selected() if row != None: show = self.showsStore[row][2] # 2 is our object column. self.database.removeShow(show) self.database.delete(show) self.showsStore.remove(row) def to_boolean(self, string): if string == "True" or string == "true" or string == True or string == 1: return True else: return False def mainRevertButtonClicked(self, widget): self.rename.revert() row = self.previewStore.get_iter_first() while (row != None): fileName = self.previewStore.get_value(row, 0) currentFileName = self.previewStore.get_value(row, 1) correctShowName = self.previewStore.get_value(row, 2) generatedFileName = self.previewStore.get_value(row, 3) FileName = self.previewStore.get_value(row, 4) self.previewStore.set_value(row, 0, FileName.fileName) self.previewStore.set_value(row, 1, FileName.currentFileName) self.previewStore.set_value(row, 2, FileName.CorrectShow.name) self.previewStore.set_value(row, 3, FileName.generatedFileName) row = self.previewStore.iter_next(row) self.previewView.columns_autosize() self.mainRevertButton.set_sensitive(False) self.mainRenameButton.set_sensitive(True) def mainRenameButtonClicked(self, widget): preferences = Preferences(Tools.preferencesXML) preferences.load() if self.to_boolean(preferences['confirm-on-rename']) == True: #base this on a message dialog dialog = gtk.MessageDialog( None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, None) hbox = gtk.HBox() hbox.pack_start(gtk.Label("Do You Really Want To Rename?"), False, 5, 5) dialog.vbox.pack_end(hbox, True, True, 0) dialog.show_all() result = dialog.run() dialog.destroy() if result == gtk.RESPONSE_CANCEL: return self.rename.rename() row = self.previewStore.get_iter_first() while (row != None): fileName = self.previewStore.get_value(row, 0) currentFileName = self.previewStore.get_value(row, 1) correctShowName = self.previewStore.get_value(row, 2) generatedFileName = self.previewStore.get_value(row, 3) FileName = self.previewStore.get_value(row, 4) self.previewStore.set_value(row, 0, FileName.fileName) self.previewStore.set_value(row, 1, FileName.currentFileName) self.previewStore.set_value(row, 2, FileName.CorrectShow.name) self.previewStore.set_value(row, 3, FileName.generatedFileName) row = self.previewStore.iter_next(row) currentNameColumn = self.previewView.get_column(1) currentNameColumn.set_visible(True) self.previewView.columns_autosize() self.mainRenameButton.set_sensitive(False) self.mainRevertButton.set_sensitive(True) def mainPreferencesButtonClicked(self, widget): preferencesDlg = PreferencesDialog() result, preferences = preferencesDlg.run() GTK_RESPONSE_SAVE = 0 GTK_RESPONSE_REVERT = -1 if result == GTK_RESPONSE_SAVE: preferences.save() def mainAboutButtonClicked(self, widget): aboutDlg = AboutDialog() aboutDlg.run() def previewSelectFolderButtonClicked(self, widget): ''' Adds the selected folders to the previewView, and generates previews. ''' selectfolder = gtk.FileChooserDialog( title=None, parent=None, action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT), backend=None) selectfolder.set_select_multiple(True) result = selectfolder.run() folderlist = selectfolder.get_filenames() selectfolder.destroy() if result == gtk.RESPONSE_ACCEPT: self.previewStore.clear() self.rename = NewRename(Tools.databaseDir, Tools.filetypesXML) for folder in folderlist: self.rename.addFoldersRecursively(NewFolder(folder)) self.rename.getMatchingShows() for folder in self.rename.folders: for files in folder.fileNames: if files.CorrectShow != None: self.previewStore.append([ files.fileName, files.currentFileName, files.CorrectShow.name, files.generatedFileName, files ]) showNameColumn = self.previewView.get_column(2) showNameColumn.set_visible(True) self.previewView.columns_autosize() if len(self.previewStore) > 0: self.previewPreviewButton.set_sensitive(True) else: # Keep button disables if there are no entries. self.previewPreviewButton.set_sensitive(False) self.mainRenameButton.set_sensitive(False) self.mainRevertButton.set_sensitive(False) def previewPreviewButtonClicked(self, widget): preferences = Preferences(Tools.preferencesXML) preferences.load() self.rename.generatePreviews(preferences['filesystem'], preferences['naming-style']) row = self.previewStore.get_iter_first() while (row != None): fileName = self.previewStore.get_value(row, 0) currentFileName = self.previewStore.get_value(row, 1) correctShowName = self.previewStore.get_value(row, 2) generatedFileName = self.previewStore.get_value(row, 3) FileName = self.previewStore.get_value(row, 4) self.previewStore.set_value(row, 0, FileName.fileName) self.previewStore.set_value(row, 1, FileName.currentFileName) self.previewStore.set_value(row, 2, FileName.CorrectShow.name) self.previewStore.set_value(row, 3, FileName.generatedFileName) row = self.previewStore.iter_next(row) showNameColumn = self.previewView.get_column(2) showNameColumn.set_visible(False) previewNameColumn = self.previewView.get_column(3) previewNameColumn.set_visible(True) self.previewView.columns_autosize() self.mainRenameButton.set_sensitive(True) def showsEditShowsButtonClicked(self, widget): model, row = self.showsView.get_selection().get_selected() show = model.get_value(row, 2) # 2 is our object column. showDialog = EditShowDialog(show, self.database) result = showDialog.run() def showsNewShowButtonClicked(self, widget): show = Show('', '30', '', '') showDialog = EditShowDialog(show, self.database) result = showDialog.run() self.database.addShow(show) self.database.write() self.showsStore.append([show.name, show.backend, show]) def showsDeleteShowButtonClicked(self, widget): model, row = self.showsView.get_selection().get_selected() show = self.showsStore[row][2] # 2 is our object column. self.database.removeShow(show) self.database.delete(show) self.showsStore.remove(row) def showsUpdateButtonClicked(self, widget): self.database.write() preferences = Preferences(Tools.preferencesXML) preferences.load() #update warning dialog = gtk.MessageDialog( None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK, None) hbox = gtk.HBox() hbox.pack_start( gtk.Label( "The Database is updating. ( The program may appear to freeze during this process. )" ), False, 5, 5) dialog.vbox.pack_end(hbox, True, True, 0) dialog.show_all() dialog.run() if self.to_boolean(preferences['imdbtv-with-tests']) == True: testimdbtv = imdbtvtest() testimdbtv.testDownloadShowList() testimdbtv.testGetShowDetails() se = NewBackendInterface(Tools.databaseDir) se.updateDatabase() dialog.destroy() #Fix treeview. Should manipulate, if necessary. self.showsStore.clear() self.database.loadDB() for Show in self.database.database: self.showsStore.append([Show.name, Show.backend, Show])
preview = True elif o in ("-R", "--recursive"): recursive = True elif o in ("-u", "--update"): update = True else: assert False, "Invalid option." if update == True: se = NewBackendInterface(dbpath) se.updateDatabase() print "Database path: " + dbpath DB = Database(dbpath) DB.loadDB() if printlist: DB.printDb() elif rename == True: # Program hasn't exited yet... what can that mean? Maybe it's time to start renaming those episode babies! print "Using filesystem: " + filesystem print "Target directory is: " + directory print "Path to filetypes.xml: " + ftdir rn = Rename(dbpath, ftdir) addFolders(rn, directory, recursive, dbpath) print "" print "Preview"
class VeefireGTK: """ Veefire GTK Interface """ def __init__(self): ## # Initialize Glade file ## self.gladefile = "veefire-gtk.glade" self.wTree = gtk.glade.XML(self.gladefile) dic = { "on_MainWindow_destroy" : gtk.main_quit, "on_mainRevertButton_clicked" : self.mainRevertButtonClicked, "on_mainRenameButton_clicked" : self.mainRenameButtonClicked, "on_mainPreferencesButton_clicked" : self.mainPreferencesButtonClicked, "on_mainAboutButton_clicked" : self.mainAboutButtonClicked, "on_previewPreviewButton_clicked" : self.previewPreviewButtonClicked, "on_previewSelectFolderButton_clicked" : self.previewSelectFolderButtonClicked, "on_showsNewShowButton_clicked" : self.showsNewShowButtonClicked, "on_showsDeleteShowButton_clicked" : self.showsDeleteShowButtonClicked, "on_showsEditShowsButton_clicked" : self.showsEditShowsButtonClicked, "on_showsUpdateButton_clicked" : self.showsUpdateButtonClicked } self.wTree.signal_autoconnect(dic) ## # Initialize Database and Rename ## self.database = Database(Tools.databaseDir) self.database.loadDB() self.rename = NewRename( Tools.databaseDir, Tools.filetypesXML ) ## # Main Buttons (Disable those buttons that depends on other functions) ## self.mainRevertButton = self.wTree.get_widget("mainRevertButton") self.mainRevertButton.set_sensitive(False) self.mainRenameButton = self.wTree.get_widget("mainRenameButton") self.mainRenameButton.set_sensitive(False) ## # Preview Buttons (Disable those buttons that depends on other functions) ## self.previewPreviewButton = self.wTree.get_widget("previewPreviewButton") self.previewPreviewButton.set_sensitive(False) ## # # Initialize previewTree # ## self.previewStore = gtk.ListStore( str, str, str, str, object ) self.previewView = self.wTree.get_widget("previewTree") self.previewView.set_model(self.previewStore) render=gtk.CellRendererText() col=gtk.TreeViewColumn("Original Name",render,text=0) col.set_resizable(True) self.previewView.append_column(col) render=gtk.CellRendererText() col=gtk.TreeViewColumn("Current Name",render,text=1) col.set_resizable(True) col.set_visible(False) self.previewView.append_column(col) render=gtk.CellRendererText() col=gtk.TreeViewColumn("Show",render,text=2) col.set_resizable(True) col.set_visible(False) self.previewView.append_column(col) render=gtk.CellRendererText() col=gtk.TreeViewColumn("Preview",render,text=3) col.set_resizable(True) col.set_visible(False) self.previewView.append_column(col) col=gtk.TreeViewColumn() col.set_visible(False) self.previewView.append_column(col) #Set the selection option so that only one row can be selected sel=self.previewView.get_selection() sel.set_mode(gtk.SELECTION_SINGLE) self.previewView.show() ## # # Initialize showsTree # ## self.showsStore = gtk.ListStore( str, str, object ) self.showsStore.clear() self.database = Database(Tools.databaseDir) self.database.loadDB() preferences = Preferences(Tools.preferencesXML) preferences.load() if self.to_boolean(preferences['update-on-startup']) == True : #update warning dialog = gtk.MessageDialog( None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK, None) hbox = gtk.HBox() hbox.pack_start(gtk.Label("The Database is updating. ( The program may appear to freeze during this process. )"), False, 5, 5) dialog.vbox.pack_end(hbox, True, True, 0) dialog.show_all() dialog.run() if self.to_boolean(preferences['imdbtv-with-tests']) == True : testimdbtv = imdbtvtest() testimdbtv.testDownloadShowList() testimdbtv.testGetShowDetails() se = NewBackendInterface(Tools.databaseDir) se.updateDatabase() self.database.loadDB() dialog.destroy() for Show in self.database.database : self.showsStore.append([ Show.name, Show.backend, Show ]) self.showsView = self.wTree.get_widget("showsTree") self.showsView.set_model(self.showsStore) render=gtk.CellRendererText() col=gtk.TreeViewColumn("Name",render,text=0) self.showsView.append_column(col) render=gtk.CellRendererText() col=gtk.TreeViewColumn("Backend",render,text=1) self.showsView.append_column(col) col=gtk.TreeViewColumn() col.set_visible(False) self.showsView.append_column(col) #set the selection option so that only one row can be selected sel=self.showsView.get_selection() sel.set_mode(gtk.SELECTION_SINGLE) self.showsView.show() ## # # Initialize the showsTree's right-click menu # ## self.editShowMenu = self.wTree.get_widget("editShowMenu") self.editShowMenuUpdate = self.wTree.get_widget("editShowMenuUpdate") self.editShowMenuRemove = self.wTree.get_widget("editShowMenuRemove") self.showsView.connect('button_press_event', self.showMenu ) self.editShowMenuUpdate.connect('activate', self.showMenuUpdate ) self.editShowMenuRemove.connect('activate', self.showMenuRemove ) ## ## ## def showMenu(self, treeview, event): ''' Right-click menu for Shows. ''' if event.button == 3: x = int(event.x) y = int(event.y) time = event.time pthinfo = treeview.get_path_at_pos(x, y) if pthinfo is not None: path, col, cellx, celly = pthinfo treeview.grab_focus() treeview.set_cursor( path, col, 0) self.editShowMenu.popup( None, None, None, event.button, time) return 1 def showMenuUpdate( self, widget ): model, row = self.showsView.get_selection().get_selected() show = self.showsStore[row][2] # 2 is our object column. self.database.write() preferences = Preferences(Tools.preferencesXML) preferences.load() #update warning dialog = gtk.MessageDialog( None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK, None) hbox = gtk.HBox() hbox.pack_start(gtk.Label("The Database is updating. ( The program may appear to freeze during this process. )"), False, 5, 5) dialog.vbox.pack_end(hbox, True, True, 0) dialog.show_all() dialog.run() if self.to_boolean(preferences['imdbtv-with-tests']) == True : testimdbtv = imdbtvtest() testimdbtv.testDownloadShowList() testimdbtv.testGetShowDetails() se = NewBackendInterface(Tools.databaseDir, [ show ]) se.updateDatabase() dialog.destroy() #Fix treeview. Should manipulate, if necessary. self.showsStore.clear() self.database.loadDB() for Show in self.database.database : self.showsStore.append([ Show.name, Show.backend, Show ]) def showMenuRemove( self, widget ): model, row = self.showsView.get_selection().get_selected() if row != None : show = self.showsStore[row][2] # 2 is our object column. self.database.removeShow(show) self.database.delete(show) self.showsStore.remove(row) def to_boolean(self, string ) : if string == "True" or string == "true" or string == True or string == 1 : return True else : return False def mainRevertButtonClicked (self, widget) : self.rename.revert() row = self.previewStore.get_iter_first() while( row != None ) : fileName = self.previewStore.get_value(row, 0) currentFileName = self.previewStore.get_value(row, 1) correctShowName = self.previewStore.get_value(row, 2) generatedFileName = self.previewStore.get_value(row, 3) FileName = self.previewStore.get_value(row, 4) self.previewStore.set_value(row, 0, FileName.fileName) self.previewStore.set_value(row, 1, FileName.currentFileName) self.previewStore.set_value(row, 2, FileName.CorrectShow.name) self.previewStore.set_value(row, 3, FileName.generatedFileName) row = self.previewStore.iter_next(row) self.previewView.columns_autosize() self.mainRevertButton.set_sensitive(False) self.mainRenameButton.set_sensitive(True) def mainRenameButtonClicked (self, widget) : preferences = Preferences(Tools.preferencesXML) preferences.load() if self.to_boolean(preferences['confirm-on-rename']) == True : #base this on a message dialog dialog = gtk.MessageDialog( None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, None) hbox = gtk.HBox() hbox.pack_start(gtk.Label("Do You Really Want To Rename?"), False, 5, 5) dialog.vbox.pack_end(hbox, True, True, 0) dialog.show_all() result = dialog.run() dialog.destroy() if result == gtk.RESPONSE_CANCEL : return self.rename.rename() row = self.previewStore.get_iter_first() while( row != None ) : fileName = self.previewStore.get_value(row, 0) currentFileName = self.previewStore.get_value(row, 1) correctShowName = self.previewStore.get_value(row, 2) generatedFileName = self.previewStore.get_value(row, 3) FileName = self.previewStore.get_value(row, 4) self.previewStore.set_value(row, 0, FileName.fileName) self.previewStore.set_value(row, 1, FileName.currentFileName) self.previewStore.set_value(row, 2, FileName.CorrectShow.name) self.previewStore.set_value(row, 3, FileName.generatedFileName) row = self.previewStore.iter_next(row) currentNameColumn = self.previewView.get_column(1) currentNameColumn.set_visible(True) self.previewView.columns_autosize() self.mainRenameButton.set_sensitive(False) self.mainRevertButton.set_sensitive(True) def mainPreferencesButtonClicked (self, widget) : preferencesDlg = PreferencesDialog() result, preferences = preferencesDlg.run() GTK_RESPONSE_SAVE = 0 GTK_RESPONSE_REVERT = -1 if result == GTK_RESPONSE_SAVE : preferences.save() def mainAboutButtonClicked (self, widget) : aboutDlg = AboutDialog() aboutDlg.run() def previewSelectFolderButtonClicked (self, widget) : ''' Adds the selected folders to the previewView, and generates previews. ''' selectfolder = gtk.FileChooserDialog(title=None, parent=None, action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT), backend=None) selectfolder.set_select_multiple(True) result = selectfolder.run() folderlist = selectfolder.get_filenames() selectfolder.destroy() if result == gtk.RESPONSE_ACCEPT : self.previewStore.clear() self.rename = NewRename( Tools.databaseDir, Tools.filetypesXML ) for folder in folderlist : self.rename.addFoldersRecursively( NewFolder(folder) ) self.rename.getMatchingShows() for folder in self.rename.folders : for files in folder.fileNames : if files.CorrectShow != None : self.previewStore.append( [ files.fileName, files.currentFileName, files.CorrectShow.name, files.generatedFileName, files ] ) showNameColumn = self.previewView.get_column(2) showNameColumn.set_visible(True) self.previewView.columns_autosize() if len(self.previewStore) > 0 : self.previewPreviewButton.set_sensitive(True) else : # Keep button disables if there are no entries. self.previewPreviewButton.set_sensitive(False) self.mainRenameButton.set_sensitive(False) self.mainRevertButton.set_sensitive(False) def previewPreviewButtonClicked (self, widget) : preferences = Preferences(Tools.preferencesXML) preferences.load() self.rename.generatePreviews(preferences['filesystem'], preferences['naming-style']) row = self.previewStore.get_iter_first() while( row != None ) : fileName = self.previewStore.get_value(row, 0) currentFileName = self.previewStore.get_value(row, 1) correctShowName = self.previewStore.get_value(row, 2) generatedFileName = self.previewStore.get_value(row, 3) FileName = self.previewStore.get_value(row, 4) self.previewStore.set_value(row, 0, FileName.fileName) self.previewStore.set_value(row, 1, FileName.currentFileName) self.previewStore.set_value(row, 2, FileName.CorrectShow.name) self.previewStore.set_value(row, 3, FileName.generatedFileName) row = self.previewStore.iter_next(row) showNameColumn = self.previewView.get_column(2) showNameColumn.set_visible(False) previewNameColumn = self.previewView.get_column(3) previewNameColumn.set_visible(True) self.previewView.columns_autosize() self.mainRenameButton.set_sensitive(True) def showsEditShowsButtonClicked (self, widget) : model, row = self.showsView.get_selection().get_selected() show = model.get_value( row, 2 ) # 2 is our object column. showDialog = EditShowDialog(show, self.database) result = showDialog.run() def showsNewShowButtonClicked (self, widget) : show = Show('', '30', '', '') showDialog = EditShowDialog(show, self.database) result = showDialog.run() self.database.addShow(show) self.database.write() self.showsStore.append([ show.name, show.backend, show ]) def showsDeleteShowButtonClicked (self, widget) : model, row = self.showsView.get_selection().get_selected() show = self.showsStore[row][2] # 2 is our object column. self.database.removeShow(show) self.database.delete(show) self.showsStore.remove(row) def showsUpdateButtonClicked (self, widget) : self.database.write() preferences = Preferences(Tools.preferencesXML) preferences.load() #update warning dialog = gtk.MessageDialog( None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK, None) hbox = gtk.HBox() hbox.pack_start(gtk.Label("The Database is updating. ( The program may appear to freeze during this process. )"), False, 5, 5) dialog.vbox.pack_end(hbox, True, True, 0) dialog.show_all() dialog.run() if self.to_boolean(preferences['imdbtv-with-tests']) == True : testimdbtv = imdbtvtest() testimdbtv.testDownloadShowList() testimdbtv.testGetShowDetails() se = NewBackendInterface(Tools.databaseDir) se.updateDatabase() dialog.destroy() #Fix treeview. Should manipulate, if necessary. self.showsStore.clear() self.database.loadDB() for Show in self.database.database : self.showsStore.append([ Show.name, Show.backend, Show ])