def insertRow(arg): """ Insert row below selected row(s) """ rowReferences = getMultiSelection(rightview) try: lastRowSelectedPath = rowReferences[-1].get_path() model = rowReferences[-1].get_model() except: # Well, we got a blank file PackageFile, lModel = getCurrentFile() if PackageFile == None: # No file is actually selected return model = rightview.get_model() if model == None: # A folder is selected return newRow = model.append(["", "", PackageFile]) # Set the cursor on the new row and start editing the name column path = model.get_path(newRow) rightview.set_cursor(path, namecol, True) # Fire off the edited methods fileEdited(PackageFile) return lastRowIter = model.get_iter(lastRowSelectedPath) # We need to link this new row with its PackageFile Object PackageFile = model.get_value(lastRowIter, L_REF) # Insert into the model newRow = model.insert_after(lastRowIter, ["", "", PackageFile]) # Set the cursor on the new row and start editing the name column path = model.get_path(newRow) rightview.set_cursor(path, namecol, True) # Fire off the edited methods fileEdited(PackageFile)
def toggleComment(*args): """ Toggle comments on selected rows based on the first row """ rowReferences = getMultiSelection(rightview) model = rightview.get_model() file, lModel = getCurrentFile() comment = True # Is anything even selected? if len(rowReferences) == 0: return # Lets see what the first comment is ref = rowReferences[0] iter = model.get_iter(ref.get_path()) cText = model.get_value(iter, L_NAME) if cText.startswith("#"): comment = False # Lets proceed now if comment: # Comment all lines for ref in rowReferences: iter = model.get_iter(ref.get_path()) cText = model.get_value(iter, L_NAME) if not cText.startswith("#"): model.set_value(iter, L_NAME, "#" + cText) else: # Uncomment all lines for ref in rowReferences: iter = model.get_iter(ref.get_path()) cText = model.get_value(iter, L_NAME) if cText.startswith("#"): model.set_value(iter, L_NAME, cText[1:]) fileEdited(file)
def toggleComment(*args): """ Toggle comments on selected rows based on the first row """ rowReferences = getMultiSelection(rightview) model = rightview.get_model() file, lModel = getCurrentFile() comment = True # Is anything even selected? if len(rowReferences) == 0: return # Lets see what the first comment is ref = rowReferences[0] iter = model.get_iter(ref.get_path()) cText = model.get_value(iter, L_NAME) if cText.startswith("#"): comment = False # Lets proceed now if comment: # Comment all lines for ref in rowReferences: iter = model.get_iter(ref.get_path()) cText = model.get_value(iter, L_NAME) if not cText.startswith("#"): model.set_value(iter, L_NAME, "#"+cText) else: # Uncomment all lines for ref in rowReferences: iter = model.get_iter(ref.get_path()) cText = model.get_value(iter, L_NAME) if cText.startswith("#"): model.set_value(iter, L_NAME, cText[1:]) fileEdited(file)
def saveModifiedFile(*args): """ Saves the file currently selected """ # Discover file currently selected from helper import getCurrentFile file, model = getCurrentFile() # save it if file in modifiedFiles: __saveFile(file)
def revertAllModified(*args): """ Reverts all files that have been modified """ from helper import getCurrentFile cfile, model = getCurrentFile() for file in modifiedFiles[:]: file.initData() __fileSaved(file) if file == cfile: from rightpanel import setListModel setListModel(file.data)
def revertSelected(*args): """ Reverts the currently selected file """ # Discover file currently selected from helper import getCurrentFile file, model = getCurrentFile() if file in modifiedFiles: file.initData() __fileSaved(file) # Well, it is unedited... from rightpanel import setListModel setListModel(file.data)
def deleteRow(arg): """ Delete selected row(s) """ rowReferences = getMultiSelection(rightview) model = rightview.get_model() PackageFile, lModel = getCurrentFile() for ref in rowReferences: iter = model.get_iter(ref.get_path()) model.remove(iter) # If nothing is deleted we shouldn't show if len(rowReferences) > 0: fileEdited(PackageFile)
def uncommentRow(window): """ Uncomment selected row(s) """ rowReferences = getMultiSelection(rightview) model = rightview.get_model() PackageFile, lModel = getCurrentFile() # Is anything even selected? if len(rowReferences) == 0: return for ref in rowReferences: iter = model.get_iter(ref.get_path()) cText = model.get_value(iter, L_NAME) if cText.startswith("#"): model.set_value(iter, L_NAME, cText[1:]) fileEdited(PackageFile)
def pasteClipboard(self, rightview): """ Pastes the clipboard below the current selection """ rowReferences = getMultiSelection(rightview) model = rightview.get_model() # Grab the actual clipboard text clipText = self.clipboard.wait_for_text() # Get a list to store into the PackageFile newData = self.__formatPaste(clipText) try: # A row has been selected and we should paste below it lastRowSelectedPath = rowReferences[-1].get_path() lastRowIter = model.get_iter(lastRowSelectedPath) # We need to link this new row with its PackageFile Object PackageFile = model.get_value(lastRowIter, L_REF) for row in newData: #insert the new row newRow = model.insert_after(lastRowIter, [row[0], row[1], PackageFile]) newPath = model.get_path(newRow) lastRowIter = model.get_iter(newPath) except IndexError: # No row selected PackageFile, lModel = getCurrentFile() for row in newData: #insert the new row newRow = model.append([row[0], row[1], PackageFile]) # Fire off the edited methods from fileOperations import fileEdited fileEdited(PackageFile)