Example #1
0
    def __init__(self, plugin, window):
        self.window = window
        self.plugin = plugin

        self.document_list = []

        self.ui_id = None

        self.action_toggle_orientation = Gtk.Action(name="ToggleSplitViewOrientation",
            label="Toggle Split View Orientation",
            tooltip="Switch between horizontal and vertical splits", 
            stock_id=Gtk.STOCK_REFRESH)

        self.action_toggle_orientation.connect("activate", self.toggle_orientation)
        self.action_toggle_orientation.set_visible(False)

        # 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. We'll
        # index each dictionary via the tab objects.
        self.split_views = {}

        self.tabs_already_using_splitview = []

        self.current_orientation = "horizontal"

        # 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()
Example #2
0
 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 already open
             for doc in self.window.get_documents():
                 doc_uri = "file://%s" % doc.get_uri_for_display()
                 if doc_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
             file_uri = Gio.file_new_for_uri(file_uri)
             self.window.create_tab_from_location(
                 file_uri, Gedit.encoding_get_current(), int(line_number), 0, False, True
             )
             self.todo_window.hide()
             return 1
     else:
         # self.todo_window.hide()
         return 0
Example #3
0
    def __init__(self, plugin, window):
        self.window = window
        self.plugin = plugin

        self.document_list = []

        self.ui_id = None

        self.action_toggle_orientation = Gtk.Action(
            name="ToggleSplitViewOrientation",
            label="Toggle Split View Orientation",
            tooltip="Switch between horizontal and vertical splits",
            stock_id=Gtk.STOCK_REFRESH)

        self.action_toggle_orientation.connect("activate",
                                               self.toggle_orientation)
        self.action_toggle_orientation.set_visible(False)

        # 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. We'll
        # index each dictionary via the tab objects.
        self.split_views = {}

        self.tabs_already_using_splitview = []

        self.current_orientation = "horizontal"

        # 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()
Example #4
0
 def click(self, eventbox, event):
   for doc in self.window.get_documents():
     if 'file://'+doc.get_uri_for_display() == self.file:
       tab = Gedit.Tab.get_from_document(doc)
       view = tab.get_view()
       self.window.set_active_tab(tab)
       doc.goto_line(self.line)
       view.scroll_to_cursor()
       return
   file_uri = Gio.file_new_for_uri(self.file)
   self.window.create_tab_from_location(file_uri,
                                        Gedit.encoding_get_current(),
                                        self.line, 0, False, True)
Example #5
0
 def __init__(self, plugin):
     self._window = plugin.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 = True
     self._liststore = None
     self._last_pattern = ""
     self._init_glade()
     self._insert_menu()
     self.connect_to_fb_bus()
Example #6
0
 def __init__(self, plugin):
     self._window = plugin.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 = True
     self._liststore = None
     self._last_pattern = ""
     self._init_glade()
     self._insert_menu()
     self.connect_to_fb_bus()
Example #7
0
    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
        gfile = Gio.file_new_for_uri(uri)

        if Gedit.utils_is_valid_location(gfile):
            LOG.debug("GeditWindow.create_tab_from_uri(%s)" % uri)
            self.window.create_tab_from_location(gfile,
                                                 Gedit.encoding_get_current(),
                                                 1, 1, False, True)
        else:
            LOG.error("Gedit.utils.uri_is_valid(%s) = False" % uri)
Example #8
0
    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
        gfile = Gio.file_new_for_uri(uri)

        if Gedit.utils_is_valid_location(gfile):
            LOG.debug("GeditWindow.create_tab_from_uri(%s)" % uri)
            self.window.create_tab_from_location(
                            gfile, Gedit.encoding_get_current(),
                            1, 1, False, True)
        else:
            LOG.error("Gedit.utils.uri_is_valid(%s) = False" % uri)
Example #9
0
 def to_utf8(self, action):
     doc = self.window.get_active_document()
     if not doc:
         return
     doc.load(Gio.file_new_for_commandline_arg(doc.get_uri_for_display()), Gedit.encoding_get_current(), 0, 0, False)
Example #10
0
    def __init__(self, geditwindow):
        GObject.GObject.__init__(self)

        # We have to use .geditwindow specifically here
        #(self.window won't work)
        self.window = 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.SelectionMode.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, True, True, 0)

        # 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, 0)
        search_box.pack_start(button_find, False, False, 0)

        # Pack the search box (search bar + Find button) into the side panel
        self.pack_start(search_box, False, False, 0)

        # 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, 0)

        # 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, 0)

        # 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, 0)

        # Show all UI elements
        self.show_all()
Example #11
0
    def __init__(self, geditwindow):
        GObject.GObject.__init__(self)

        # We have to use .geditwindow specifically here
        #(self.window won't work)
        self.window = 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.SelectionMode.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, True, True, 0)

        # 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, 0)
        search_box.pack_start(button_find, False, False, 0)

        # Pack the search box (search bar + Find button) into the side panel
        self.pack_start(search_box, False, False, 0)

        # 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, 0)

        # 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, 0)

        # 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, 0)

        # Show all UI elements
        self.show_all()