def goto_file(self, page, frame, request): match = self.protocol.search(request.get_uri()) if match: file_uri = self._path + match.group('file') line_number = match.group('line') gedit.commands.load_uri(self._gedit_window, file_uri, gedit.encoding_get_current(), int(line_number)) # dirty fix to make the file roll to a certain line gedit.commands.load_uri(self._gedit_window, file_uri, gedit.encoding_get_current(), int(line_number)) self._window.hide() return True
def _open_file( self, filename ): #uri = self._rootdir + "/" + filename uri = filename tab = self._window.get_tab_from_uri(uri) if tab == None: tab = self._window.create_tab_from_uri( uri,gedit.encoding_get_current(), 0, False, False ) self._window.set_active_tab( tab )
def _reopen_tabs(self, window): # Get saved active document active = self._config.get("common", "active_document") self._active_tab = None # Get document list docs = self._config.options("documents") docs.sort() # Check if document list is not empty if len(docs) > 0: # Get active document doc = window.get_active_document() # Check if document is untitled (there is empty tab) if doc.is_untitled(): # Close active tab tab = window.get_active_tab() window.close_tab(tab) # Process the rest documents for d in docs: tab = window.create_tab_from_uri( self._config.get("documents", d), gedit.encoding_get_current(), 0, True, False) # Check if document was active if d == active: self._active_tab = tab # Connect handler that switches saved active document tab if self._active_tab: self._active_tab.get_document().connect("loaded", self._on_doc_loaded)
def _reopen_tabs(self, window): # Get saved active document active = self._config.get("common", "active_document") self._active_tab = None # Get document list docs = self._config.options("documents") docs.sort() # Check if document list is not empty if len(docs) > 0: # Get active document doc = window.get_active_document() # Check if document is untitled (there is empty tab) if doc.is_untitled(): # Close active tab tab = window.get_active_tab() window.close_tab(tab) # Process the rest documents for d in docs: tab = window.create_tab_from_uri(self._config.get("documents", d), gedit.encoding_get_current(), 0, True, False) # Check if document was active if d == active: self._active_tab = tab # Connect handler that switches saved active document tab if self._active_tab: self._active_tab.get_document().connect("loaded", self._on_doc_loaded)
def on_navigation_request(self, page, frame, request): file_uri = None uri = request.get_uri() gp = self.mt.search(uri) if gp: file_uri = 'file:///%s' % gp.group('file') line_number = gp.group('line') if file_uri: # Test if document is not already open for doc in self.window.get_documents(): if doc.get_uri() == file_uri: tab = gedit.tab_get_from_document(doc) view = tab.get_view() self.window.set_active_tab(tab) doc.goto_line(int(line_number)) view.scroll_to_cursor() self.todo_window.hide() return 1 # Document isn't open, create a new tab from uri self.window.create_tab_from_uri(file_uri, gedit.encoding_get_current(), int(line_number), False, True) else: print "(%s) not found" % file_uri self.todo_window.hide() return 1
def __init__(self, geditwindow): """ geditwindow -- an instance of gedit.Window """ gtk.VBox.__init__(self) self.geditwindow = geditwindow self.tabs = {} try: self.encoding = gedit.encoding_get_current() except: self.encoding = gedit.gedit_encoding_get_current() self.active_timeout = False self.parser = None self.document_history = [] # contains tuple (doc,line,col) self.history_pos = 0 self.previousline = 0 # add a treeview sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.set_shadow_type(gtk.SHADOW_IN) TARGETS = [ ('text/plain', 0, 1), ('TEXT', 0, 2), ('STRING', 0, 3), ] self.browser = gtk.TreeView() self.browser.set_headers_visible(False) self.browser.enable_model_drag_source(gtk.gdk.BUTTON1_MASK, TARGETS, gtk.gdk.ACTION_DEFAULT| gtk.gdk.ACTION_MOVE) self.browser.enable_model_drag_dest(TARGETS, gtk.gdk.ACTION_DEFAULT) sw.add(self.browser) self.browser.connect("button_press_event", self.__onClick) self.pack_start(sw) # add a text column to the treeview self.column = gtk.TreeViewColumn() self.browser.append_column(self.column) self.cellrendererpixbuf = gtk.CellRendererText() self.column.pack_start(self.cellrendererpixbuf, True) self.column.add_attribute(self.cellrendererpixbuf, 'text', 0) # connect stuff self.browser.connect("row-activated", self._onRowActivated) self.geditwindow.connect("active-tab-state-changed", self._onActiveTabStateChanged) self.geditwindow.connect("tab-removed", self._onTabRemoved) self.show_all()
def __init__(self, window): gtk.HBox.__init__(self, False, 4) gconf_client.add_dir(self.GCONF_PROFILE_DIR, gconf.CLIENT_PRELOAD_RECURSIVE) self._window = window self._encoding = gedit.encoding_get_current() self._vte = vte.Terminal() self.reconfigure_vte() self._vte.set_size(self._vte.get_column_count(), 5) # self._vte.set_size_request(200, 50) self._vte.show() self.pack_start(self._vte) self._scrollbar = gtk.VScrollbar(self._vte.get_adjustment()) self._scrollbar.show() self.pack_start(self._scrollbar, False, False, 0) gconf_client.notify_add(self.GCONF_PROFILE_DIR, self.on_gconf_notification) self._vte.connect("key-press-event", self.on_vte_key_press) self._vte.connect("button-press-event", self.on_vte_button_press) self._vte.connect("popup-menu", self.on_vte_popup_menu) self._vte.connect("child-exited", lambda term: term.fork_command()) self._vte.fork_command()
def __init__(self, plugin, window): self.window = window self.plugin = plugin self.ui_id = None self.ui_popup_id = None self.popup_action = None self.temp_actions = [] self.document_list = [] # Add a "toggle split view" item to the View menu self.insert_menu_item(window) # We're going to keep track of each tab's split view # and, if used, ALT view -- the view of a separate # document -- with a couple of dictionaries. We'll # index each dictionary via the tab objects. self.split_views = {} self.alt_views = {} self.tabs_already_using_splitview = [] # This keeps track of whether the user is viewing an ALT document. self.same_document = {} # I hardly even know how this works, but it gets our encoding. try: self.encoding = gedit.encoding_get_current() except: self.encoding = gedit.gedit_encoding_get_current() self.idle_id = gobject.timeout_add(100, self.monitor_documents)
def _open_file(self, filename): # uri = self._rootdir + "/" + filename uri = filename tab = self._window.get_tab_from_uri(uri) if tab == None: tab = self._window.create_tab_from_uri(uri, gedit.encoding_get_current(), 0, False, False) self._window.set_active_tab(tab)
def __default__(view, new_name): """Rename current file """ win = view.get_toplevel() tab = win.get_active_tab() doc = tab.get_document() buffer = view.get_buffer() uri = doc.get_uri() if not uri: return commands.result.HIDE res = re.findall(r"^file:\/\/(\/.+?)([^\/]+?)$", uri)[0] line = doc.get_iter_at_mark(doc.get_insert()).get_line() encoding = gedit.encoding_get_current() win.close_tab(tab) shutil.move(res[0] + res[1], res[0] + new_name) win.create_tab_from_uri('file://' + res[0] + new_name, encoding, line, False, True) return commands.result.HIDE
def openFile(self, path): uri = urljoin('file://', path) tab = self._geditWindow.get_tab_from_uri(uri) if tab == None: tab = self._geditWindow.create_tab_from_uri( uri, gedit.encoding_get_current(), 0, False, False) self._geditWindow.set_active_tab(tab)
def __init__(self, plugin, window): self.window = window self.plugin = plugin # Any time the user makes a change to the bookmarks, # we'll set this variable to True so that any other # gedit window can get the changes through the # top-level idle function monitor_bookmark_changes. self.bookmark_change = False # Save the document's encoding in a variable for later use (when opening new tabs) try: self.encoding = gedit.encoding_get_current() except: self.encoding = gedit.gedit_encoding_get_current() # Keep track of bookmarks and any existing folders. self.bookmarks = [] self.bookmark_folders = [""] # Keep track of how many bookmarks we have so we can give them # all unique names when adding them to the menu. self.bookmark_count = 0 self.targets = [("example", gtk.TARGET_SAME_WIDGET, 0)] self.insert_menu_item(window) self.add_bookmark_dialog = None # Create an idle function that decides whether or not # the "Add Bookmark" option on the menu should be available. self.idle_id = gobject.timeout_add(100, self.control_add_button_state)
def create_file(self, window, file_uri, text): window.create_tab_from_uri(str(file_uri), gedit.encoding_get_current(), 0, True, True) view = window.get_active_view() buf = view.get_buffer() doc = window.get_active_document() doc.begin_user_action() buf.insert_interactive_at_cursor(text, True) doc.end_user_action()
def callback(s): f = open(local_file, "wb") f.write(s) f.close() tab = self._window.create_tab_from_uri("file://%s" % local_file, gedit.encoding_get_current(), 0, False, True) self._mark_doc_as_ftp(tab.get_document(), local_file, self._get_ftp_path(ftp_file), False) self.update_status("Temp file loaded %s" % local_file)
def __init__( self, plugin, window ): self._window = window self._plugin = plugin self._encoding = gedit.encoding_get_current() self._rootdir = "file://" + os.getcwd() self._show_hidden = False self._liststore = None; self._init_glade() self._insert_menu()
def __init__(self, geditwindow): gtk.VBox.__init__(self) # We have to use .geditwindow specifically here (self.window won't work) self.geditwindow = geditwindow self.geditwindow.connect("active_tab_state_changed", self.__new_tab) self.geditwindow.connect("tab_removed", self.__close_tab) self.commands = { 'pep8': 'pep8 "%s" --repeat --ignore=E501,W191', 'pyflakes': 'pyflakes "%s"', 'csschecker': 'csschecker.py "%s"' } self.extensions = {'.py': ['pep8', 'pyflakes'], '.css': ['csschecker']} self.document_uris = {} # Save the document's encoding in a variable for later use (when opening new tabs) try: self.encoding = gedit.encoding_get_current() except: self.encoding = gedit.gedit_encoding_get_current() self.check_lines = gtk.ListStore(str, str, str) self.results_list = gtk.TreeView(self.check_lines) tree_selection = self.results_list.get_selection() tree_selection.set_mode(gtk.SELECTION_SINGLE) tree_selection.connect("changed", self.__change_line) cell_log = gtk.TreeViewColumn("Logs") # Now add the cell objects to the results_list treeview object self.results_list.append_column(cell_log) # Create text-rendering objects so that we can actually # see the data that we'll put into the objects text_renderer_row = gtk.CellRendererText() text_renderer_col = gtk.CellRendererText() text_renderer_log = gtk.CellRendererText() cell_log.pack_start(text_renderer_log, True) cell_log.add_attribute(text_renderer_log, "text", 2) scrolled_window = gtk.ScrolledWindow() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled_window.add(self.results_list) # Pack in the scrolled window object self.pack_start(scrolled_window) # Show all UI elements self.show_all()
def __init__(self, geditwindow): """ geditwindow -- an instance of gedit.Window """ imagelibrary.initialise() gtk.VBox.__init__(self) self.geditwindow = geditwindow try: self.encoding = gedit.encoding_get_current() except: self.encoding = gedit.gedit_encoding_get_current() self.active_timeout = False self.parser = None self.document_history = [] # contains tuple (doc,line,col) self.history_pos = 0 self.previousline = 0 self.back = gtk.ToolButton(gtk.STOCK_GO_BACK) self.back.connect("clicked", self.history_back) self.back.set_sensitive(False) self.forward = gtk.ToolButton(gtk.STOCK_GO_FORWARD) self.forward.connect("clicked", self.history_forward) self.forward.set_sensitive(False) tb = gtk.Toolbar() tb.add(self.back) tb.add(self.forward) #self.pack_start(tb,False,False) # add a treeview sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.set_shadow_type(gtk.SHADOW_IN) self.browser = gtk.TreeView() self.browser.set_headers_visible(False) sw.add(self.browser) self.browser.connect("button_press_event", self.__onClick) self.pack_start(sw) # add a text column to the treeview self.column = gtk.TreeViewColumn() self.browser.append_column(self.column) self.cellrendererpixbuf = gtk.CellRendererPixbuf() self.column.pack_start(self.cellrendererpixbuf, False) self.crt = gtk.CellRendererText() self.column.pack_start(self.crt, False) # connect stuff self.browser.connect("row-activated", self.on_row_activated) self.show_all()
def __init__(self, window): self.ctx = bike.init() self.tmpBufferPath = '/tmp/gedit_bicyclerepairman_buffer.py' self.window = window self.encoding = gedit.encoding_get_current() self.logger = BikeLogger() self.ctx.setProgressLogger(self.logger) self.ctx.setWarningLogger(self.logger)
def __init__( self, plugin, window ): self._window = window self._plugin = plugin self._encoding = gedit.encoding_get_current() self._rootdir = "file://" + os.getcwd() self._tmpfile = os.path.join(tempfile.gettempdir(), 'snapopen.%s.%s' % (os.getuid(),os.getpid())) self._show_hidden = False self._liststore = None; self._init_glade() self._insert_menu()
def __init__(self, geditwindow): """ geditwindow -- an instance of gedit.Window """ imagelibrary.initialise() gtk.VBox.__init__(self) self.geditwindow = geditwindow try: self.encoding = gedit.encoding_get_current() except: self.encoding = gedit.gedit_encoding_get_current() self.active_timeout = False self.parser = None self.document_history = [] # contains tuple (doc,line,col) self.history_pos = 0 self.previousline = 0 self.back = gtk.ToolButton(gtk.STOCK_GO_BACK) self.back.connect("clicked",self.history_back) self.back.set_sensitive(False) self.forward = gtk.ToolButton(gtk.STOCK_GO_FORWARD) self.forward.connect("clicked",self.history_forward) self.forward.set_sensitive(False) tb = gtk.Toolbar() tb.add(self.back) tb.add(self.forward) #self.pack_start(tb,False,False) # add a treeview sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.set_shadow_type(gtk.SHADOW_IN) self.browser = gtk.TreeView() self.browser.set_headers_visible(False) sw.add(self.browser) self.browser.connect("button_press_event",self.__onClick) self.pack_start(sw) # add a text column to the treeview self.column = gtk.TreeViewColumn() self.browser.append_column(self.column) self.cellrendererpixbuf = gtk.CellRendererPixbuf() self.column.pack_start(self.cellrendererpixbuf,False) self.crt = gtk.CellRendererText() self.column.pack_start(self.crt,False) # connect stuff self.browser.connect("row-activated",self.on_row_activated) self.show_all()
def on_open_example(self, action): example_dir = ide_utils.get_example_dir() filename = os.path.join(example_dir, action.get_name()[len('ShoebotOpenExample'):].strip()) drive, directory = os.path.splitdrive(os.path.abspath(os.path.normpath(filename))) uri = "file:///%s%s" % (drive, directory.replace(os.sep, '/')) self.window.create_tab_from_uri(uri, gedit.encoding_get_current(), 0, False, # Do not create a new file True) # Switch to tab
def __init__(self, plugin, window): self._window = window self._plugin = plugin self._encoding = gedit.encoding_get_current() self._rootdir = "file://" + os.getcwd() self._tmpfile = os.path.join( tempfile.gettempdir(), 'snapopen.%s.%s' % (os.getuid(), os.getpid())) self._show_hidden = False self._liststore = None self._init_glade() self._insert_menu()
def __init__(self, plugin, window): self._window = window self._plugin = plugin self.enc = gedit.encoding_get_current() self.docs=[] self.olddocs = [] # Insert menu items self._insert_menu() try: os.mkdir(os.path.expanduser('~/.gnome2/gedit')) except: pass
def __init__(self, plugin, window): self._window = window self._plugin = plugin if pre216_version: self._encoding = gedit.gedit_encoding_get_current() else: self._encoding = gedit.encoding_get_current() self._rootdir = "file://" + os.getcwd() self._show_hidden = False self._liststore = None self._init_glade() self._insert_menu()
def __init__( self, plugin, window ): self._window = window self._plugin = plugin self._encoding = gedit.encoding_get_current() self._rootpath = os.getcwd() self._rootdir = "file://" + self._rootpath self._show_hidden = False self._suggestion = None self._git = False self._liststore = None self._last_pattern = "" self._init_glade() self._insert_menu()
def on_open_example(self, action): example_dir = ide_utils.get_example_dir() filename = os.path.join( example_dir, action.get_name()[len('ShoebotOpenExample'):].strip()) drive, directory = os.path.splitdrive( os.path.abspath(os.path.normpath(filename))) uri = "file:///%s%s" % (drive, directory.replace(os.sep, '/')) self.window.create_tab_from_uri( uri, gedit.encoding_get_current(), 0, False, # Do not create a new file True) # Switch to tab
def _reopen_tabs(self, window): # Get list of open documents docs = window.get_documents() open_docs = [d.get_uri() for d in docs if d.get_uri()] # Get saved active document active = self._config.get("common", "active_document") self._active_tab = None # Get document list docs = self._config.options("documents") docs.sort() # Check if document list is not empty if len(docs) > 0: # Get active document doc = window.get_active_document() # Check if document is untitled (there is empty tab) tab = window.get_active_tab() if doc.is_untitled(): # Remember empty tab to close it later self._empty_tab = tab else: # Remember active tab (in case if there is file in a command line) self._empty_tab = None self._active_tab = tab # Process the rest documents for d in docs: # Get document uri uri = self._config.get("documents", d) # Check if document is not already opened if open_docs.count(uri) == 0: # Create new tab tab = window.create_tab_from_uri( uri, gedit.encoding_get_current(), 0, True, False) # Check if document was active (and there is NOT file in command line) if d == active and not self._active_tab: self._active_tab = tab # Connect handler that switches saved active document tab if self._active_tab: self._active_tab.get_document().connect("loaded", self._on_doc_loaded)
def __init__( self, plugin, window ): if THREADING: gtk.gdk.threads_init() self._window = window self._plugin = plugin if pre216_version: self._encoding = gedit.gedit_encoding_get_current() else: self._encoding = gedit.encoding_get_current() self._rootdir = "file://" + os.getcwd() self._show_hidden = False self._liststore = None self._finder_thread = None self._last_text = None self._init_glade() self._insert_menu()
def __init__( self, plugin, window ): self._window = window self._plugin = plugin self._encoding = gedit.encoding_get_current() self._project = ProjectData() self._history_file = os.path.expanduser( '~' ) + "/.gnome2/gedit/plugins/gedit-project-manager-history" self._history = list() self._action_group = gtk.ActionGroup( "ProjectPluginActions" ) self._history_action_group = gtk.ActionGroup( "ProjectPluginHistoryActions" ) self._state = self.STATE_PROJECT_NO_FILES_NO self._add_remove_state = None self._message = list() self._init_history() self._insert_menu() self._create_choosers()
def _reopen_tabs(self, window): # Get list of open documents docs = window.get_documents() open_docs = [d.get_uri() for d in docs if d.get_uri()] # Get saved active document active = self._config.get("common", "active_document") self._active_tab = None # Get document list docs = self._config.options("documents") docs.sort() # Check if document list is not empty if len(docs) > 0: # Get active document doc = window.get_active_document() # Check if document is untitled (there is empty tab) tab = window.get_active_tab() if doc.is_untitled(): # Remember empty tab to close it later self._empty_tab = tab else: # Remember active tab (in case if there is file in a command line) self._empty_tab = None self._active_tab = tab # Process the rest documents for d in docs: # Get document uri uri = self._config.get("documents", d) # Check if document is not already opened if open_docs.count(uri) == 0: # Create new tab tab = window.create_tab_from_uri(uri, gedit.encoding_get_current(), 0, True, False) # Check if document was active (and there is NOT file in command line) if d == active and not self._active_tab: self._active_tab = tab # Connect handler that switches saved active document tab if self._active_tab: self._active_tab.get_document().connect("loaded", self._on_doc_loaded)
def __init__( self, plugin, window ): self._window = window self._plugin = plugin self._encoding = gedit.encoding_get_current() #self._rootdir = "file://" + os.getcwd() self._rootdir = gnomevfs.get_uri_from_local_path(os.getcwd()) #self._tmpfile = os.path.join(tempfile.gettempdir(), 'snapopen.%s.%s' % (os.getuid(),os.getpid())) user = "" try: import getpass user = getpass.getuser() except: pass self._tmpfile = os.path.join(tempfile.gettempdir(), 'snapopen.%s.%s' % (user,os.getpid())) self._show_hidden = False self._liststore = None; self._init_glade() self._insert_menu()
def activate_tab(self, file): """ Activate the GeditTab containing the given File or open a new tab for it (this is called by the WindowContext) @param file: a File object """ for tab, tab_decorator in self._tab_decorators.iteritems(): if tab_decorator.file and tab_decorator.file == file: self._window.set_active_tab(tab) return # not found, open file in a new tab... uri = file.uri self._log.debug("GeditWindow.create_tab_from_uri(%s)" % uri) if gedit.utils.uri_is_valid(uri): self._window.create_tab_from_uri(file.uri, gedit.encoding_get_current(), 1, False, True) else: self._log.error("gedit.utils.uri_is_valid(%s) = False" % uri)
def on_save_as(self, btn): """ save as button clicked """ # get the current document and title app = gedit.app_get_default() win = app.get_active_window() doc = win.get_active_document() if doc is None: return title = doc.get_uri() if title is None: title = "" title = title.split(os.sep)[-1] # show the dialog for entering the filename dialog = gtk.MessageDialog(buttons=gtk.BUTTONS_OK_CANCEL, flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT) dialog.set_default_response(gtk.RESPONSE_OK) dialog.set_markup("\nSave as:") entry = gtk.Entry() entry.set_activates_default(True) if title is not None: entry.set_text(title) dialog.vbox.pack_end(entry, True, True, 0) dialog.show_all() # save to the temp file and upload if dialog.run() == gtk.RESPONSE_OK: title = entry.get_text() local_file = self._get_local_file(title) doc.set_modified(True) doc.load("file://%s" % local_file, gedit.encoding_get_current(), 0, True) self._mark_doc_as_ftp(doc, local_file, "%s/%s" % (self.ftp_cwd, title), True) doc.save(True) dialog.destroy()
def __init__(self, plugin, window): self.flag_local_acces = True self.flag_serveur = False self.flag_saving = False self.control_key = False self.alt_key = False self.sb_PID = False self.plugins_list = [] self.connect_list = [] self.current_keys = [] self.auto_refresh = REFRESH self.window = window self.plugin = plugin self.init_cfg() self.init_webview() self.init_mybox() self.init_window(self.window) self.init_plugins() img = gtk.image_new_from_file(IMG_PATH) self.panel.add_item(self.mybox, 'WebKit Panel', img) try: self.encoding = gedit.encoding_get_current() except: self.encoding = gedit.gedit_encoding_get_current()
def __init__(self, plugin, window): self.window = window self.plugin = plugin self.ui_id = None # Add a "toggle split view" item to the View menu self.insert_menu_item(window) # We're going to keep track of each tab's split view # and, if used, ALT view -- the view of a separate # document -- with a couple of dictionaries. We'll # index each dictionary via the tab objects. self.split_views = {} self.alt_views = {} # This keeps track of whether the user is viewing an ALT document. self.same_document = {} # I hardly even know how this works, but it gets our encoding. try: self.encoding = gedit.encoding_get_current() except: self.encoding = gedit.gedit_encoding_get_current()
def _show(self, id_num): self.already_working = True # avoid recursion when changing things self.nav_mark = id_num # update navigation mark = self.marks[id_num] doc = mark.get_buffer() uri = doc.get_uri() line = doc.get_iter_at_mark(mark).get_line() iterator = self.edit_data.get_iter(len(self.edit_data) - id_num) self.edit_data.set_value(iterator, 2, str(line + 1) ) # update shown line to the current line of this mark tab = self.geditwindow.get_tab_from_uri(uri) if tab: self.geditwindow.set_active_tab(tab) else: tab = self.geditwindow.create_tab_from_uri(uri, gedit.encoding_get_current(), line, False, True) # try to scroll to line anyways doc = tab.get_document() doc.goto_line(line) ## FIXME: didn't work better than simple scroll_to_cursor # (start, end) = doc.get_bounds() # view = self.geditwindow.get_active_view() # view.scroll_to_iter(end, 0.0) # x = doc.get_iter_at_line_offset(line-self.scroll_margin, 0) # some lines before the right one, coming from the end # view.scroll_to_iter(x, 0.0) view = self.geditwindow.get_active_view() view.scroll_to_cursor() view.scroll_to_cursor() view.scroll_to_cursor() #update selection on the list self.points_list.set_cursor(len(self.edit_data) - id_num) self.already_working = False # release the lock
def __init__(self, geditwindow): gtk.VBox.__init__(self) # We have to use .geditwindow specifically here (self.window won't work) self.geditwindow = geditwindow # Save the document's encoding in a variable for later use (when opening new tabs) try: self.encoding = gedit.encoding_get_current() except: self.encoding = gedit.gedit_encoding_get_current() # Preferences (we'll control them with toggled checkboxes) self.ignore_comments = False self.case_sensitive = False # We save the grep search result data in a ListStore # Format: ID (COUNT) | FILE (without path) | LINE | FILE (with path) # Note: We use the full-path version when opening new tabs (when necessary) self.search_data = gtk.ListStore(str, str, str, str) # Create a list (a "tree view" without children) to display the results self.results_list = gtk.TreeView(self.search_data) # Get the selection attribute of the results_list and assign a couple of properties tree_selection = self.results_list.get_selection() # Properties... tree_selection.set_mode(gtk.SELECTION_SINGLE) tree_selection.connect("changed", self.view_result) # Create the cells for our results list treeview # Note: We don't need to create a cell or text renderer # for the full-path filename variable because we # won't actually be displaying that information. cell_id = gtk.TreeViewColumn("#") cell_line_number = gtk.TreeViewColumn("Line") cell_filename = gtk.TreeViewColumn("File") # Now add the cell objects to the results_list treeview object self.results_list.append_column(cell_id) self.results_list.append_column(cell_line_number) self.results_list.append_column(cell_filename) # Create text-rendering objects so that we can actually # see the data that we'll put into the objects text_renderer_id = gtk.CellRendererText() text_renderer_filename = gtk.CellRendererText() text_renderer_line_number = gtk.CellRendererText() # Pack the text renderer objects into the cell objects we created cell_id.pack_start(text_renderer_id, True) cell_filename.pack_start(text_renderer_filename, True) cell_line_number.pack_start(text_renderer_line_number, True) # Now set the IDs to each of the text renderer objects and set them to "text" mode cell_id.add_attribute(text_renderer_id, "text", 0) cell_filename.add_attribute(text_renderer_filename, "text", 1) cell_line_number.add_attribute(text_renderer_line_number, "text", 2) # Create a scrolling window object and add our results_list treeview object to it scrolled_window = gtk.ScrolledWindow() scrolled_window.add(self.results_list) # Pack in the scrolled window object self.pack_start(scrolled_window) # Create a "Find" button; we'll pack it into an HBox in a moment... button_find = gtk.Button("Find") button_find.connect("clicked", self.button_press) # Create a "search bar" to type the search string into; we'll pack it # into the HBox as well... self.search_form = gtk.Entry() self.search_form.connect("activate", self.button_press) # Here's the HBox I mentioned... search_box = gtk.HBox(False, 0) search_box.pack_start(self.search_form, False, False) search_box.pack_start(button_find, False, False) # Pack the search box (search bar + Find button) into the side panel self.pack_start(search_box, False, False) # Create a check box to decide whether or not to ignore comments self.check_ignore = gtk.CheckButton("Ignore comments") self.check_ignore.connect("toggled", self.toggle_ignore) # Pack it in... self.pack_start(self.check_ignore, False, False) # Create a check box to determine whether to pay attention to case self.check_case = gtk.CheckButton("Case Sensitive") self.check_case.connect("toggled", self.toggle_case) # Pack it in... self.pack_start(self.check_case, False, False) # Show all UI elements self.show_all()
def __init__(self, plugin, window, file_monitor, config): self._plugin = plugin self._window = window self._file_monitor = file_monitor self._config = config # Get Builder and get xml file self._builder = gtk.Builder() self._builder.add_from_file( os.path.join(os.path.dirname(__file__), "gui", "geditopenfiles_gtk.xml")) #setup window self._plugin_window = self._builder.get_object( "gedit_openfiles_window") self._plugin_window.set_transient_for(self._window) self._notebook = self._builder.get_object('notebook') # Callbacks self._plugin_window.connect("key-release-event", self._on_window_release) self._plugin_window.connect("delete_event", self._plugin_window_delete_event) #setup buttons self._builder.get_object("open_button").connect( "clicked", self._open_selected_item) self._builder.get_object("cancel_button").connect( "clicked", lambda a: self._plugin_window.hide()) # Setup entry field self._file_query = self._builder.get_object("file_query") self._file_query.connect("key-release-event", self._on_query_entry) # Get File TreeView self._file_list = self._builder.get_object("file_list") # Connect Action on TreeView self._file_list.connect("select-cursor-row", self._on_select_from_list) self._file_list.connect("button_press_event", self._on_list_mouse) # Setup File TreeView self._liststore = gtk.ListStore(str, str) self._file_list.set_model(self._liststore) # Path Column column1 = gtk.TreeViewColumn("Path", gtk.CellRendererText(), markup=0) column1.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE) self._file_list.append_column(column1) self._file_list.get_selection().set_mode(gtk.SELECTION_MULTIPLE) # Add Animation icon for building data building_data_spinner = self._builder.get_object('spinner') building_data_spinner.set_from_animation( gtk.gdk.PixbufAnimation( os.path.join(os.path.dirname(__file__), "gui", "progress.gif"))) self._building_data_spinner_box = self._builder.get_object( 'spinner_box') # Setup Configuration Tab self._notebook = self._builder.get_object("notebook") self._file_browser_checkbox = self._builder.get_object( "file_browser_checkbox") self._file_browser_checkbox.connect("toggled", self._file_browser_checkbox_event) self._open_root_hbox = self._builder.get_object("open_root_hbox") # Setup Callback for root path self._open_root_path = self._builder.get_object("open_root_path") self._open_root_path.set_current_folder( self._config.get_value("ROOT_PATH")) self._config_ignore_input = self._builder.get_object( "config_ignore_input") self._reset_config() # Connect the OK Button the config tab self._builder.get_object("config_save_button").connect( "clicked", self._save_config_event) self._builder.get_object("config_cancel_button").connect( "clicked", self._cancel_config_event) self._builder.get_object("config_refresh_button").connect( "clicked", self._refresh_data) use_file_browser = self._config.get_value("USE_FILEBROWSER") if use_file_browser == True or use_file_browser == None: # Defualt self._open_root_hbox.set_sensitive(False) else: self._open_root_hbox.set_sensitive(True) # Set encoding self._encoding = gedit.encoding_get_current() self._insert_menu()
def __init__(self, geditwindow): """ geditwindow -- an instance of gedit.Window """ gtk.VBox.__init__(self) self.geditwindow = geditwindow try: self.encoding = gedit.encoding_get_current() except: self.encoding = gedit.gedit_encoding_get_current() self.build_toolbar() # add a treeview self.treestore = gtk.TreeStore( gobject.TYPE_STRING, # short name gobject.TYPE_STRING, # long name gtk.gdk.Pixbuf) # file/folder icon # build a list of all project files self.filelist = [] self.load_filelist() # get the common prefix of all project files self.prefix = os.path.commonprefix(self.filelist) self.prefixlen = len(self.prefix) # Create a (filename, [list of directories in path) list # to pass to self.add_dir_to_tree dirlist = [] for project_file in self.filelist: separated_dirs = \ self.from_uri(project_file[self.prefixlen:]).split("/") dirlist.append((project_file, separated_dirs)) # Add all files to self.treestore root_iter = self.treestore.get_iter_root() self.add_dir_to_tree(root_iter, self.from_uri(self.prefix), self.prefix, dirlist) # Put a scrolled window in the widget, and fill it with a treeview sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.set_shadow_type(gtk.SHADOW_IN) self.browser = gtk.TreeView(self.treestore) self.browser.set_headers_visible(False) self.browser.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.browser.connect("row-activated", self.row_activated) sw.add(self.browser) self.pack_start(sw) # add a column to the treeview self.column = gtk.TreeViewColumn("File") self.browser.append_column(self.column) # add a pixbuf cell to the column (for file/directory/missing icon) self.cpb = gtk.CellRendererPixbuf() self.column.pack_start(self.cpb, False) self.column.add_attribute(self.cpb, 'pixbuf', 2) # add a text cell to the column (for short filename) self.crt = gtk.CellRendererText() self.column.pack_start(self.crt, True) self.column.add_attribute(self.crt, 'text', 0) # add a text cell to the column (for long filename) #self.long_crt = gtk.CellRendererText() #self.column.pack_start(self.long_crt,True) #self.column.add_attribute(self.long_crt, 'text', 1) # expand root project folder self.browser.expand_row((0, ), False) self.show_all()
def __init__(self, geditwindow, path): def fileExists(f): try: file = open(f) except IOError: exists = 0 else: exists = 1 return exists def traverseDocument(myfilename, level): if fileExists(path+myfilename): doc = minidom.parse(path+myfilename) xi_list = doc.getElementsByTagName('xi:include') for x in xi_list[:]: if fileExists(path+x.attributes["href"].value): mylevel = self.treestore.append(level, ["0", x.attributes["href"].value, gtk.Window().render_icon(gtk.STOCK_FILE, gtk.ICON_SIZE_MENU)]) if x.attributes["href"].value.rpartition('.')[2] == 'xml': traverseDocument(x.attributes["href"].value, mylevel) else: mylevel = self.treestore.append(level, ["-1",x.attributes["href"].value, gtk.Window().render_icon(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_MENU)]) gtk.VBox.__init__(self) self.language_manager = gedit.get_language_manager() self.DEFAULT_LANG = 'en-US' self.thepath = "" self.geditwindow = geditwindow try: self.encoding = gedit.encoding_get_current() except: self.encoding = gedit.gedit_encoding_get_current() self.open_files = [] self.treestore = gtk.TreeStore(str,str,gtk.gdk.Pixbuf) self.treeview = gtk.TreeView(self.treestore) self.treeview.connect("row-activated", self.open_file) self.geditwindow.connect("tab-removed", self.tab_closed) self.geditwindow.connect("active-tab-changed", self.tab_changed) tree_selection = self.treeview.get_selection() tree_selection.set_mode(gtk.SELECTION_SINGLE) tree_selection.connect("changed", self.switch_to_file) self.cell = gtk.CellRendererText() self.tvcolumn = gtk.TreeViewColumn('Files') render_pixbuf = gtk.CellRendererPixbuf() self.tvcolumn.pack_start(render_pixbuf, expand=False) self.tvcolumn.add_attribute(render_pixbuf, 'pixbuf', 2) self.tvcolumn.pack_start(self.cell, expand=True) self.tvcolumn.add_attribute(self.cell, 'text', 1) self.treeview.append_column(self.tvcolumn) self.tvcolumn.set_sort_column_id(0) self.treeview.set_search_column(1) self.treeview.set_reorderable(False) scrolled_window = gtk.ScrolledWindow() scrolled_window.add(self.treeview) self.pack_start(scrolled_window) self.show_all() filename = path.rpartition('/')[2]+'.xml' bookpath = path path = path+'/'+self.DEFAULT_LANG+'/' self.thepath = path self.treestore.clear() self.open_files = [] xmldoc = minidom.parse(path+filename) level = self.treestore.append(None, ["0",filename, gtk.Window().render_icon(gtk.STOCK_FILE, gtk.ICON_SIZE_MENU)]) xi_lista = xmldoc.getElementsByTagName('xi:include') for xa in xi_lista[:]: mylevela = self.treestore.append(level, ["0",xa.attributes["href"].value, gtk.Window().render_icon(gtk.STOCK_FILE, gtk.ICON_SIZE_MENU)]) traverseDocument(xa.attributes["href"].value, mylevela)
def __init__(self, plugin, window): # print "Plugin created for", window self._window = window self._plugin = plugin self.create_menu_item() self.id_name = "CMYKProjectManager_Plugin" self.tree_parser = TreeParser() #imagelibrary.initialise() try: self.encoding = gedit.encoding_get_current() except: self.encoding = gedit.gedit_encoding_get_current() # create tab self._tab = gtk.ScrolledWindow() self._tab.set_property("hscrollbar-policy",gtk.POLICY_AUTOMATIC) self._tab.set_property("vscrollbar-policy",gtk.POLICY_AUTOMATIC) self._tab.set_property("shadow-type",gtk.SHADOW_IN) # self._tab.add(self._area) # self._tab.show_all() # sw = gtk.ScrolledWindow() # sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) # sw.set_shadow_type(gtk.SHADOW_IN) self.projectbrowser = gtk.TreeView() self.projectbrowser.set_headers_visible(False) self._tab.add(self.projectbrowser) self.projectbrowser.connect("button_press_event",self.__onClick) # self.pack_start(self._tab) # add a text column to the treeview self.column = gtk.TreeViewColumn() self.column.set_sort_column_id(0) self.projectbrowser.append_column(self.column) self.cellrendererpixbuf = gtk.CellRendererPixbuf() self.column.pack_start(self.cellrendererpixbuf,False) self.crt = gtk.CellRendererText() self.column.pack_start(self.crt,False) # connect stuff self.projectbrowser.connect("row-activated",self.on_row_activated) # connect Drag & Drop self.projectbrowser.connect('drag_data_received', self.on_tree_view_drag_data_received) # Set it as a drag source for exporting snippets self.projectbrowser.drag_source_set(gdk.BUTTON1_MASK, self.dnd_target_list, gdk.ACTION_DEFAULT | gdk.ACTION_COPY) # Set it as a drag destination for importing snippets self.projectbrowser.drag_dest_set(gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP, self.dnd_target_list, gdk.ACTION_DEFAULT | gdk.ACTION_COPY) # self.show_all() self._tab.show_all() self.putTab() self.getProjectsList()
def find_file_from_error(mrplugin, error_iter, can_msgbox = True): # error_iter = iter do objeto 'storeOutput' # arq = mrplugin.storeOutput.get_value( error_iter, 0 ) linha = mrplugin.storeOutput.get_value( error_iter, 1 ) - 1 arq_full = os.path.abspath( os.path.join( mrplugin.get_src().get_dir(), arq ) ) arq_full_uri = gio.File( arq_full ).get_uri() # procura o documento aberto no gedit que possa ter o mesmo # uri que o arquivo indicado no erro relatado. # for d in mrplugin.window.get_documents(): doc_arq_uri = d.get_uri() if arq_full_uri == doc_arq_uri: # define um novo 'active_document' # tab = gedit.tab_get_from_document( d ) mrplugin.window.set_active_tab( tab ) mrplugin.get_src().remove_error() mrplugin.get_src().mark_error( linha ) return # já que não achou um URI completo, procura um documento aberto # no gedit que possa ter pelo menos o mesmo basename (ex.: a.c). # arq_basename = os.path.basename( gio.File( arq_full ).get_path() ) for d in mrplugin.window.get_documents(): doc_arq_basename = os.path.basename( gio.File( d.get_uri() ).get_path() ) if arq_basename == doc_arq_basename: # define um novo 'active_document' # tab = gedit.tab_get_from_document( d ) mrplugin.window.set_active_tab( tab ) mrplugin.get_src().remove_error() mrplugin.get_src().mark_error( linha ) return # chegou aqui? entao nao achou o arquivo aberto no gedit. # tenta abrir entao.. if not os.path.exists( arq_full ): if can_msgbox: msgbox( "Ir para linha do erro", \ "O arquivo indicado nessa linha do erro não foi encontrado." + \ "\n\n" + \ "<small><b>Arquivo buscado:</b> " + arq_full + " </small>", \ "warning" \ ) return #arq_uri = "file://" + arq_full arq_uri = gio.File( arq_full ).get_uri() new_tab = mrplugin.window.create_tab_from_uri( uri = arq_uri, encoding = gedit.encoding_get_current(), line_pos = linha, create = False, jump_to = True ) # pra variar, mais outro esquema do gedit que eh assincrono, # isto eh, a criacao de tabs (acima) vai emitir signals e etc. # # pra continuar o codigo supondo que tudo isso ja foi processado, # devemos rodar varias iteracoes do looping do gtk. # # sem fazer isso, os comandos em seguida (get_src().mark_error # etc.) nao funcionarao adequadamente. # while gtk.events_pending(): gtk.main_iteration( block=False ) # com a nova tab ativada, o 'active_document' muda. # assim, fazemos get_src() pra ativar o erro nele. # mrplugin.get_src().remove_error() mrplugin.get_src().mark_error( linha )
def __init__(self, geditwindow): gtk.VBox.__init__(self) # We have to use .geditwindow specifically here (self.window won't work) self.geditwindow = geditwindow # Save the document's encoding in a variable for later use (when opening new tabs) try: self.encoding = gedit.encoding_get_current() except: self.encoding = gedit.gedit_encoding_get_current() # Preferences (we'll control them with toggled checkboxes) self.ignore_comments = False self.case_sensitive = False self.scan_logs = False # We save the grep search result data in a ListStore # Format: ID (COUNT) | FILE (without path) | LINE | FILE (with path) # Note: We use the full-path version when opening new tabs (when necessary) self.search_data = gtk.ListStore(str, str, str, str) # Create a list (a "tree view" without children) to display the results self.results_list = gtk.TreeView(self.search_data) # Get the selection attribute of the results_list and assign a couple of properties tree_selection = self.results_list.get_selection() # Properties... tree_selection.set_mode(gtk.SELECTION_SINGLE) tree_selection.connect("changed", self.view_result) # Create the cells for our results list treeview # Note: We don't need to create a cell or text renderer # for the full-path filename variable because we # won't actually be displaying that information. cell_id = gtk.TreeViewColumn("#") cell_line_number = gtk.TreeViewColumn("Line") cell_filename = gtk.TreeViewColumn("File") # Now add the cell objects to the results_list treeview object self.results_list.append_column(cell_id) self.results_list.append_column(cell_line_number) self.results_list.append_column(cell_filename) # Create text-rendering objects so that we can actually # see the data that we'll put into the objects text_renderer_id = gtk.CellRendererText() text_renderer_filename = gtk.CellRendererText() text_renderer_line_number = gtk.CellRendererText() # Pack the text renderer objects into the cell objects we created cell_id.pack_start(text_renderer_id, True) cell_filename.pack_start(text_renderer_filename, True) cell_line_number.pack_start(text_renderer_line_number, True) # Now set the IDs to each of the text renderer objects and set them to "text" mode cell_id.add_attribute(text_renderer_id, "text", 0) cell_filename.add_attribute(text_renderer_filename, "text", 1) cell_line_number.add_attribute(text_renderer_line_number, "text", 2) # Create a scrolling window object and add our results_list treeview object to it scrolled_window = gtk.ScrolledWindow() scrolled_window.add(self.results_list) # Pack in the scrolled window object self.pack_start(scrolled_window) # Create a "Find" button; we'll pack it into an HBox in a moment... button_find = gtk.Button("Find") button_find.connect("clicked", self.button_press) # Create a "search bar" to type the search string into; we'll pack it # into the HBox as well... self.search_form = gtk.Entry() self.search_form.connect("activate", self.button_press) # Here's the HBox I mentioned... search_box = gtk.HBox(False, 0) search_box.pack_start(self.search_form, False, False) search_box.pack_start(button_find, False, False) # Pack the search box (search bar + Find button) into the side panel self.pack_start(search_box, False, False) # Create a check box to decide whether or not to ignore comments self.check_ignore = gtk.CheckButton("Ignore comments") self.check_ignore.connect("toggled", self.toggle_ignore) # Pack it in... self.pack_start(self.check_ignore, False, False) # Create a check box to determine whether to pay attention to case self.check_case = gtk.CheckButton("Case Sensitive") self.check_case.connect("toggled", self.toggle_case) # Pack it in... self.pack_start(self.check_case, False, False) # Create a check box to determine whether to pay attention to case self.check_logs = gtk.CheckButton("Scan log/bak files") self.check_logs.connect("toggled", self.toggle_logs) # Pack it in... self.pack_start(self.check_logs, False, False) # Show all UI elements self.show_all()
def __init__(self, window): self._window = window self.searcher = window.searcher # Get Builder and get xml file self._builder = gtk.Builder() self._builder.add_from_file(os.path.join(os.path.dirname(__file__), "gui", "geditopenfiles.glade")) #setup window self._plugin_window = self._builder.get_object("gedit_openfiles_window") self._plugin_window.set_transient_for(self._window) self._notebook = self._builder.get_object('notebook') # Callbacks self._plugin_window.connect("key-release-event", self._on_window_release) self._plugin_window.connect("delete_event", self._plugin_window_delete_event) #setup buttons self._builder.get_object("open_button").connect("clicked", self._open_selected_item) self._builder.get_object("cancel_button").connect("clicked", lambda a: self._plugin_window.hide()) # Setup entry field self._file_query = self._builder.get_object("file_query") self._file_query.connect("key-release-event", self._on_query_entry) # Get File TreeView self._file_list = self._builder.get_object("file_list") # Connect Action on TreeView self._file_list.connect("select-cursor-row", self._on_select_from_list) self._file_list.connect("button_press_event", self._on_list_mouse) # Setup File TreeView self._liststore = gtk.ListStore(gtk.gdk.Pixbuf, str, str) self._file_list.set_model(self._liststore) # icon Column icon_column = gtk.TreeViewColumn("Icon", gtk.CellRendererPixbuf(), pixbuf=0) # icon_column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE) # type Column # type_column = gtk.TreeViewColumn("Type", gtk.CellRendererText(), markup=1) # type_column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE) # Path Column path_column = gtk.TreeViewColumn("Path", gtk.CellRendererText(), markup=1) path_column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE) self._file_list.append_column(icon_column) # self._file_list.append_column(type_column) self._file_list.append_column(path_column) self._file_list.get_selection().set_mode(gtk.SELECTION_MULTIPLE) # # Add Animation icon for building data # building_data_spinner = self._builder.get_object('spinner') # building_data_spinner.set_from_animation(gtk.gdk.PixbufAnimation( # os.path.join(os.path.dirname(__file__), "gui", "progress.gif"))) # self._building_data_spinner_box = self._builder.get_object('spinner_box') # Setup Configuration Tab self._notebook = self._builder.get_object("notebook") self._file_browser_checkbox = self._builder.get_object("file_browser_checkbox") self._file_browser_checkbox.connect("toggled", self._file_browser_checkbox_event) self._open_root_hbox = self._builder.get_object("open_root_hbox") # Setup Callback for root path self._open_root_path = self._builder.get_object("open_root_path") self._open_root_path.set_current_folder(self.searcher.configuration.get_value("STATIC_ROOT_PATH")) self._config_ignore_input = self._builder.get_object("config_ignore_input") self._reset_config() # Connect the OK Button the config tab self._builder.get_object("config_save_button").connect("clicked", self._save_config_event) self._builder.get_object("config_cancel_button").connect("clicked", self._cancel_config_event) self._builder.get_object("config_refresh_button").connect("clicked", self._refresh_data) use_file_browser = self.searcher.configuration.get_value("USE_FILEBROWSER") if use_file_browser == True or use_file_browser == None: # Defualt self._open_root_hbox.set_sensitive(False) else: self._open_root_hbox.set_sensitive(True) # Set encoding self._encoding = gedit.encoding_get_current() self._insert_menu()