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()
Exemple #2
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()
Exemple #3
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()
Exemple #4
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()