Ejemplo n.º 1
0
    def __init__(self, plugin, window):
        self._window = window
        self._plugin = plugin
        self.find_ui = None
        self.find_history = []
        self.replace_history = []
        self.file_type_history = []
        self.file_path_history = []
        self.current_search_pattern = ""
        self.current_replace_text = ""
        #self.current_file_pattern = ""
        #self.current_path = ""
        self.forwardFlg = True
        self.scopeFlg = 0
        '''
		self.result_highlight_tag = gtk.TextTag('result_highlight')
		self.result_highlight_tag.set_properties(foreground='yellow',background='red')
		self.result_highlight_tag.set_property('family', 'Serif')
		self.result_highlight_tag.set_property('size-points', 12)
		self.result_highlight_tag.set_property('weight', pango.WEIGHT_BOLD)
		self.result_highlight_tag.set_property('underline', pango.UNDERLINE_DOUBLE)
		self.result_highlight_tag.set_property('style', pango.STYLE_ITALIC)
		#'''

        configfile = os.path.join(os.path.dirname(__file__), "config.xml")
        self.config_manager = config_manager.ConfigManager(configfile)
        self.find_options = self.config_manager.load_configure('FindOption')
        self.config_manager.to_bool(self.find_options)

        self.find_dlg_setting = self.config_manager.load_configure('FindGUI')
        self.config_manager.to_bool(self.find_dlg_setting)

        self.shortcuts = self.config_manager.load_configure('Shortcut')
        self.result_highlight = self.config_manager.load_configure(
            'ResultDisplay')

        self.result_gui_settings = self.config_manager.load_configure(
            'ResultGUI')
        self.config_manager.to_bool(self.result_gui_settings)

        self.find_history = self.config_manager.load_list('FindHistory')
        self.replace_history = self.config_manager.load_list('ReplaceHistory')
        self.file_type_history = self.config_manager.load_list('FilterHistory')
        self.file_path_history = self.config_manager.load_list('PathHistory')

        self._results_view = FindResultView(window, self.result_gui_settings)
        self._window.get_bottom_panel().add_item(self._results_view,
                                                 _("Advanced Find/Replace"),
                                                 "gtk-find-and-replace")

        self.msgDialog = gtk.MessageDialog(
            self._window, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, None)

        # Insert menu items
        self._insert_menu()
Ejemplo n.º 2
0
    def __init__(self, plugin, window):
        self._window = window
        self._plugin = plugin
        self.find_ui = None
        self.find_history = []
        self.replace_history = []
        self.filter_history = []
        self.path_history = []
        self.find_bookmarks = []
        self.replace_bookmarks = []
        self.filter_bookmarks = []
        self.path_bookmarks = []
        self.current_search_pattern = ""
        self.current_replace_text = ""
        self.current_file_pattern = "*"
        #self.current_path = ""
        self.forwardFlg = True
        self.scopeFlg = 0
        '''
		self.result_highlight_tag = Gtk.TextTag('result_highlight')
		self.result_highlight_tag.set_properties(foreground='yellow',background='red')
		self.result_highlight_tag.set_property('family', 'Serif')
		self.result_highlight_tag.set_property('size-points', 12)
		self.result_highlight_tag.set_property('weight', pango.WEIGHT_BOLD)
		self.result_highlight_tag.set_property('underline', pango.UNDERLINE_DOUBLE)
		self.result_highlight_tag.set_property('style', pango.STYLE_ITALIC)
		#'''

        user_configfile = os.path.join(CONFIG_DIR, 'config.xml')
        if not os.path.exists(user_configfile):
            if not os.path.exists(os.path.dirname(user_configfile)):
                os.makedirs(os.path.dirname(user_configfile))
            shutil.copy2(
                os.path.dirname(__file__) + "/config/config.xml",
                os.path.dirname(user_configfile))
        #print os.path.dirname(user_configfile)
        configfile = user_configfile
        #print configfile

        self.config_manager = config_manager.ConfigManager(configfile)
        self.find_options = self.config_manager.load_configure('FindOption')
        self.config_manager.to_bool(self.find_options)

        self.find_dlg_setting = self.config_manager.load_configure('FindGUI')
        self.config_manager.to_bool(self.find_dlg_setting)

        self.shortcuts = self.config_manager.load_configure('Shortcut')
        self.result_highlight = self.config_manager.load_configure(
            'ResultDisplay')

        self.result_gui_settings = self.config_manager.load_configure(
            'ResultGUI')
        self.config_manager.to_bool(self.result_gui_settings)

        user_patterns = os.path.join(CONFIG_DIR, 'patterns.xml')
        if not os.path.exists(user_patterns):
            if not os.path.exists(os.path.dirname(user_patterns)):
                os.makedirs(os.path.dirname(user_patterns))
            shutil.copy2(
                os.path.dirname(__file__) + "/config/patterns.xml",
                os.path.dirname(user_patterns))
        #print os.path.dirname(user_patterns)
        patternsfile = user_patterns
        #print patternsfile

        self.patterns_manager = config_manager.ConfigManager(patternsfile)
        self.find_history = self.patterns_manager.load_list('FindHistory')
        self.replace_history = self.patterns_manager.load_list(
            'ReplaceHistory')
        self.filter_history = self.patterns_manager.load_list('FilterHistory')
        self.path_history = self.patterns_manager.load_list('PathHistory')
        self.find_bookmarks = self.patterns_manager.load_list('FindBookmark')
        self.replace_bookmarks = self.patterns_manager.load_list(
            'ReplaceBookmark')
        self.filter_bookmarks = self.patterns_manager.load_list(
            'FilterBookmark')
        self.path_bookmarks = self.patterns_manager.load_list('PathBookmark')

        self._results_view = FindResultView(window, self.result_gui_settings)
        icon = Gtk.Image.new_from_stock(Gtk.STOCK_FIND_AND_REPLACE,
                                        Gtk.IconSize.MENU)
        self._window.get_bottom_panel().add_item(self._results_view,
                                                 'AdvancedFindBottomPanel',
                                                 _("Advanced Find/Replace"),
                                                 icon)

        self.msgDialog = Gtk.MessageDialog(
            self._window,
            Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
            Gtk.MessageType.INFO, Gtk.ButtonsType.CLOSE, None)

        # Insert menu items
        self._insert_menu()