def evaluate_ex(acc): command = "".join(acc) print "ex command is %s" % command if command == "w": fileOps.save_file() elif command == "wq": # Need to wait for file to finish saving fileOps.save_file() gobject.timeout_add(100, fileOps.close_quit) elif re.compile("sav (.+)$").match(command): result = re.compile("sav (.+)$").match(command).group(1) # this doesn't seem to work # base.vigtk.doc.save_as(result, gedit.encoding_get_current(), gedit.DOCUMENT_SAVE_PRESERVE_BACKUP) elif re.compile("(\d+).*").match(command): result = re.compile("(\d+).*").match(command).group(1) print "Go to line %s" % result pos.go_to_line(int(result)) elif command == "q": fileOps.close_tab() elif command == "q!": fileOps.close_tab(False) elif command == "tabnew": base.vigtk.window.create_tab(True) elif command == "bn": print "Select next tab" elif command == "bp": print "Select previous tab." elif re.compile("tabnew (.+)$").match(command): # os.getcwd seems to only get the home directory file_name = "file://" + os.getcwd() + "/"+ re.compile("tabnew (.+)$").match(command).group(1) if not base.vigtk.window.get_active_document().get_uri(): base.vigtk.window.close_tab(base.vigtk.window.get_active_tab()) base.vigtk.window.create_tab_from_uri(file_name, gedit.encoding_get_utf8(), 1, True, True) elif re.compile("e (.+)$").match(command): file_name = "file://" + os.getcwd() + "/"+ re.compile("e (.+)$").match(command).group(1) base.vigtk.window.close_tab(base.vigtk.window.get_active_tab()) base.vigtk.window.create_tab_from_uri(file_name, gedit.encoding_get_utf8(), 1, True, True)
def start_commit_edit(self, paths): WindowController._logger.info('Initiated commit message edit') # Create and open a document with the commit msg template # create temp text file to store commit message f = tempfile.NamedTemporaryFile( prefix='gedit-commit-message-', suffix='.commit', delete=False) commit_msg_template = self._repo_manager.get_commit_msg_template(paths) if commit_msg_template == None: return f.write(commit_msg_template) commit_msg_path = f.name f.close() # Open file in gedit tab = self._window.create_tab_from_uri('file://'+commit_msg_path, gedit.encoding_get_utf8(), 0, False, True) self._commit_tabs[tab] = paths tab.get_document().goto_line(0)
import gtk import gedit import functools import gconf # All encodings names enclist_func = lambda i=0: [gedit.encoding_get_from_index(i)] + enclist_func( i + 1) if gedit.encoding_get_from_index(i) else [] shown_enc = gconf.client_get_default().get( "/apps/gedit-2/preferences/encodings/shown_in_menu") # show the full list of encodings if not they not configured in the Open/Save Dialog enclist = sorted(([ gedit.encoding_get_from_charset(enc.to_string()) for enc in shown_enc.get_list() ] if shown_enc else enclist_func()) + [gedit.encoding_get_utf8()], key=lambda enc: enc.to_string()) ui_str = """<ui> <menubar name="MenuBar"> <menu name="FileMenu" action="File"> <placeholder name="FileOps_2"> <menu name="FileEncodingMenu" action="FileEncoding"> <placeholder name="EncodingListHolder"/> <separator/> %s </menu> </placeholder> </menu> </menubar> </ui>
def ex_OpenInCurrentView(act, command, result): fileName = "%s/%s" % (act.fileOps.getCurrentFolder(act), result.group(1)) act.vigtk.window.close_tab(act.vigtk.window.get_active_tab()) act.vigtk.window.create_tab_from_uri(fileName, gedit.encoding_get_utf8(), 1, True, True)
from gettext import gettext as _ import gtk import gedit import functools import gconf # All encodings names enclist_func = lambda i=0: [gedit.encoding_get_from_index(i)] + enclist_func(i+1) if gedit.encoding_get_from_index(i) else [] shown_enc = gconf.client_get_default().get("/apps/gedit-2/preferences/encodings/shown_in_menu") # show the full list of encodings if not they not configured in the Open/Save Dialog enclist = sorted(([gedit.encoding_get_from_charset(enc.to_string()) for enc in shown_enc.get_list()] if shown_enc else enclist_func()) + [gedit.encoding_get_utf8()], key=lambda enc: enc.to_string()) ui_str = """<ui> <menubar name="MenuBar"> <menu name="FileMenu" action="File"> <placeholder name="FileOps_2"> <menu name="FileEncodingMenu" action="FileEncoding"> <placeholder name="EncodingListHolder"/> <separator/> %s </menu> </placeholder> </menu> </menubar> </ui> """ % "\n".join(["<menuitem name=\"Encoding%i\" action=\"Encoding%i\"/>" % (i, i) for i in range(len(enclist))])