コード例 #1
0
    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)
コード例 #2
0
ファイル: SplitView.py プロジェクト: dynaum/gmate
    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)
コード例 #3
0
ファイル: SplitView.py プロジェクト: xearonet/gedit-2-addons
    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)
コード例 #4
0
    def __init__(self, window, tree_view):
        """Constructor.
        
        Initializes the plugin.
        
        @param window: the Gedit window the plugin should be associated with.
        @type window: a gedit.Window
        
        @raise ValueError: if a valid window or treeview was not passed
        
        """
        if window is None:
            raise ValueError, err0013 
            
        if tree_view is None:
            raise ValueError, err0014       
        
        super(ProjectExplorer, self).__init__()
        
        self.__window = window
        self.__tree_view = tree_view

        # Set up signal handlers
        self.__tree_view.set_activate_file(
            lambda d: self.open_file(d.get_uri()))
        self.__tree_view.set_refresh(
            lambda: self.set_repository(self.get_repository(), True))
        
        self.__settings = Settings()
        self.__encoding = gedit.gedit_encoding_get_current()
コード例 #5
0
    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()
コード例 #6
0
ファイル: __init__.py プロジェクト: xearonet/gedit-2-addons
    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()
コード例 #7
0
    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()
コード例 #8
0
ファイル: geditBRM.py プロジェクト: stvkoch/geditPlugins4Dev
    def __init__(self, window):
        self.ctx = bike.init()

        self.tmpBufferPath = '/tmp/gedit_bicyclerepairman_buffer.py'
        self.window = window
        self.encoding = gedit.gedit_encoding_get_current()

        self.logger = BikeLogger()
        self.ctx.setProgressLogger(self.logger)
        self.ctx.setWarningLogger(self.logger)
コード例 #9
0
ファイル: browserwidget.py プロジェクト: AsherBond/gedit-mate
    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()
コード例 #10
0
	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()
コード例 #11
0
 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()
コード例 #12
0
	def __init__(self, plugin, window):
		self._window = window
		self._plugin = plugin
		self.enc = gedit.gedit_encoding_get_current()
		self.docs=[]
		self.olddocs = []
		# Insert menu items
		self._insert_menu()
		try:
		  os.mkdir(os.path.expanduser('~/.gnome2/gedit'))
		except:
		  pass
コード例 #13
0
	def __init__( self, plugin, window ):
		self._window = window
		self._plugin = plugin
		self._encoding = gedit.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()
コード例 #14
0
ファイル: __init__.py プロジェクト: KimiZhong/gedit-mate
	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()
コード例 #15
0
	def __init__( self, plugin, window ):
		self._window = window
		self._plugin = plugin
		self._project = ProjectData()
		if not is_mate:
			self._encoding = gedit.gedit_encoding_get_current()
			self._history_file = os.path.expanduser( '~' ) + "/.gnome2/gedit/plugins/gedit-project-manager-history"
		else:
			self._encoding = gedit.pluma_encoding_get_current()
			self._history_file = os.path.expanduser( '~' ) + "/.config/pluma/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()
コード例 #16
0
ファイル: SplitView.py プロジェクト: BuloZB/gmate
    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()
コード例 #17
0
ファイル: webkitpanel.py プロジェクト: bamanzi/gedit-2-addons
 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()
コード例 #18
0
ファイル: SplitView.py プロジェクト: lkumar93/dotfiles
    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()
コード例 #19
0
 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()
コード例 #20
0
    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()
コード例 #21
0
ファイル: FindInFiles.py プロジェクト: warp/dotfiles
    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()
コード例 #22
0
ファイル: publican.py プロジェクト: ajtowns/publican
    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)
コード例 #23
0
    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.search_all_files = False
        
        # We save the grep search result data in a ListStore
        # Format:  ID (COUNT)  |  FILE (without path)  |  LINE  |  FILE (with path) | line text was found in (string)
        #    Note: We use the full-path version when opening new tabs (when necessary)
        self.search_data = gtk.ListStore(str, 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("#", gtk.CellRendererText(), markup = 0)
        cell_filename = gtk.TreeViewColumn("File", gtk.CellRendererText(), text = 1)
        cell_line_number = gtk.TreeViewColumn("Line", gtk.CellRendererText(), text = 2)
        cell_preview = gtk.TreeViewColumn("Preview", gtk.CellRendererText(), markup = 4)
        
        # Now add the cell objects to the results_list treeview object
        self.results_list.append_column(cell_id)
        self.results_list.append_column(cell_filename)
        self.results_list.append_column(cell_line_number)
        self.results_list.append_column(cell_preview)
        
        # 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()
        #text_renderer_result_preview = 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)
        #cell_preview.pack_start(text_renderer_result_preview, 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)
        #cell_preview.add_attribute(text_renderer_result_preview, "text", 4)

        # 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, True, True)
        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 combo box for search options (current documents, current directory documents, both, whatever)
        label = gtk.Label("Search Options:")
        self.pack_start(gtk.Label(""), False, False) # A hacky way to insert a line break.  Sorry!
        self.pack_start(label, False, False)

        # We use this to set the tooltip later...
        #tooltip = gtk.Tooltip()

        # This dropdown will allow the user to decide how the search will work
        self.search_setting_dropdown = gtk.combo_box_new_text()

        # Hardcoded tooltip string
        #tooltip.set_text(self.search_setting_dropdown, "Active Documents:  Use grep to search for\nkey terms in all currently open files.\n\nActive Directory:  Use grep to search\n(nonrecursively) through the directory\nof the currently active document.\n\nBoth:  Use grep in both fashions\nsimultaneously.")
        self.search_setting_dropdown.set_tooltip_text("Active Documents:  Use grep to search for\nkey terms in all currently open files.\n\nActive Directory:  Use grep to search\n(nonrecursively) through the directory\nof the currently active document.\n\nBoth:  Use grep in both fashions\nsimultaneously.")

        # See top of file for global variable definitions
        self.search_setting_dropdown.append_text(SEARCH_DOCUMENTS)
        self.search_setting_dropdown.append_text(SEARCH_DIRECTORY)
        self.search_setting_dropdown.append_text(SEARCH_BOTH)

        # Set the first option to active
        self.search_setting_dropdown.set_active(0)

        # Pack it in...
        self.pack_start(self.search_setting_dropdown, False, False)
        
        # Show all UI elements
        self.show_all()
コード例 #24
0
    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()
コード例 #25
0
    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()
コード例 #26
0
ファイル: FindInFiles.py プロジェクト: AceOfDiamond/gmate
    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()