⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 meldapp.py

📁 LINUX下的文件比较工具
💻 PY
📖 第 1 页 / 共 3 页
字号:
        if radio.get_active():            idx = self.editor_command.index(radio)            for k,v in self.editor_radio_values.items():                if v == idx:                    self.prefs.edit_command_type = k                    break    #    # display    #    def on_draw_style_toggled(self, radio):        if radio.get_active():            self.prefs.draw_style = self.draw_style.index(radio)    def on_toolbar_style_toggled(self, radio):        if radio.get_active():            self.prefs.toolbar_style = self.toolbar_style.index(radio)    #    # filters    #    def on_checkbutton_ignore_symlinks_toggled(self, check):        self.prefs.ignore_symlinks = check.get_active()    def on_checkbutton_ignore_blank_lines_toggled(self, check):        self.prefs.ignore_blank_lines = check.get_active()    #    # encoding    #    def on_save_encoding_toggled(self, radio):        if radio.get_active():            self.prefs.save_encoding = self.save_encoding.index(radio)    #    # cvs    #    def on_cvs_quiet_toggled(self, toggle):        self.prefs.cvs_quiet = toggle.get_active()    def on_cvs_compression_toggled(self, toggle):        self.prefs.cvs_compression = toggle.get_active()    def on_cvs_compression_value_changed(self, spin):        self.prefs.cvs_compression_value = int(spin.get_value())    def on_cvs_ignore_cvsrc_toggled(self, toggle):        self.prefs.cvs_ignore_cvsrc = toggle.get_active()    def on_cvs_binary_activate(self, fileentry):        self.prefs.cvs_binary = fileentry.gtk_entry().get_text()    def on_cvs_create_missing_toggled(self, toggle):        self.prefs.cvs_create_missing = toggle.get_active()    def on_cvs_prune_empty_toggled(self, toggle):        self.prefs.cvs_prune_empty = toggle.get_active()    def on_response(self, dialog, arg):        if arg==gtk.RESPONSE_CLOSE:            self.prefs.text_codecs = self.entry_text_codecs.get_property("text")            self.prefs.edit_command_custom = self.custom_edit_command_entry.get_property("text")        self.widget.destroy()################################################################################## MeldStatusBar#################################################################################class MeldStatusBar(object):    def __init__(self, task_progress, task_status, doc_status):        self.task_progress = task_progress        self.task_status = task_status        self.doc_status = doc_status    def set_task_status(self, status):        self.task_status.pop(1)        self.task_status.push(1, status)    def set_doc_status(self, status):        self.doc_status.pop(1)        self.doc_status.push(1, status)################################################################################## NotebookLabel#################################################################################class NotebookLabel(gtk.HBox):    def __init__(self, iconname, text="", onclose=None):        gtk.HBox.__init__(self)        self.label = gtk.Label(text)        self.button = gtk.Button()        icon = gtk.Image()        icon.set_from_file( paths.share_dir("glade2/pixmaps/%s" % iconname) )        icon.set_from_pixbuf( icon.get_pixbuf().scale_simple(15, 15, 2) ) #TODO font height        image = gtk.Image()        image.set_from_file( paths.share_dir("glade2/pixmaps/button_delete.xpm") )        image.set_from_pixbuf( image.get_pixbuf().scale_simple(9, 9, 2) ) #TODO font height        self.button.add( image )        self.pack_start( icon )        self.pack_start( self.label )        self.pack_start( self.button, expand=0 )        self.show_all()        if onclose:            self.button.connect("clicked", onclose)################################################################################## MeldPreferences#################################################################################class MeldPreferences(prefs.Preferences):    defaults = {        "window_size_x": prefs.Value(prefs.INT, 600),        "window_size_y": prefs.Value(prefs.INT, 600),        "use_custom_font": prefs.Value(prefs.BOOL,0),        "custom_font": prefs.Value(prefs.STRING,"monospace, 14"),        "tab_size": prefs.Value(prefs.INT, 4),        "show_line_numbers": prefs.Value(prefs.BOOL, 0),        "use_syntax_highlighting": prefs.Value(prefs.BOOL, 0),        "edit_wrap_lines" : prefs.Value(prefs.INT, 0),        "edit_command_type" : prefs.Value(prefs.STRING, "internal"), #internal, gnome, custom        "edit_command_custom" : prefs.Value(prefs.STRING, "gedit"),        "supply_newline": prefs.Value(prefs.BOOL,1),        "text_codecs": prefs.Value(prefs.STRING, "utf8 latin1"),        "save_encoding": prefs.Value(prefs.INT, 0),        "draw_style": prefs.Value(prefs.INT,2),        "toolbar_style": prefs.Value(prefs.INT,0),        "ignore_symlinks": prefs.Value(prefs.BOOL,0),        "cvs_quiet": prefs.Value(prefs.BOOL, 1),        "cvs_compression": prefs.Value(prefs.BOOL, 1),        "cvs_compression_value": prefs.Value(prefs.INT, 3),        "cvs_ignore_cvsrc": prefs.Value(prefs.BOOL, 0),        "cvs_binary": prefs.Value(prefs.STRING, "/usr/bin/cvs"),        "cvs_create_missing": prefs.Value(prefs.BOOL, 1),        "cvs_prune_empty": prefs.Value(prefs.BOOL, 1),        "vc_console_visible": prefs.Value(prefs.BOOL, 0),        "color_delete_bg" : prefs.Value(prefs.STRING, "DarkSeaGreen1"),        "color_delete_fg" : prefs.Value(prefs.STRING, "Red"),        "color_replace_bg" : prefs.Value(prefs.STRING, "#ddeeff"),        "color_replace_fg" : prefs.Value(prefs.STRING, "Black"),        "color_conflict_bg" : prefs.Value(prefs.STRING, "Pink"),        "color_conflict_fg" : prefs.Value(prefs.STRING, "Black"),        "color_inline_bg" : prefs.Value(prefs.STRING, "LightSteelBlue2"),        "color_inline_fg" : prefs.Value(prefs.STRING, "Red"),        "color_edited_bg" : prefs.Value(prefs.STRING, "gray90"),        "color_edited_fg" : prefs.Value(prefs.STRING, "Black"),        "filters" : prefs.Value(prefs.STRING,            #TRANSLATORS: translate this string ONLY to the first "\t", leave it and the following parts intact            _("Backups\t1\t#*# .#* ~* *~ *.{orig,bak,swp}\n") + \            #TRANSLATORS: translate this string ONLY to the first "\t", leave it and the following parts intact            _("CVS\t1\tCVS\n") + \            #TRANSLATORS: translate this string ONLY to the first "\t", leave it and the following parts intact            _("SVN\t1\t.svn\n") + \            #TRANSLATORS: translate this string ONLY to the first "\t", leave it and the following parts intact            _("Monotone\t1\tMT\n") + \            #TRANSLATORS: translate this string ONLY to the first "\t", leave it and the following parts intact            _("Binaries\t1\t*.{pyc,a,obj,o,so,la,lib,dll}\n") + \            #TRANSLATORS: translate this string ONLY to the first "\t", leave it and the following parts intact            _("Media\t0\t*.{jpg,gif,png,wav,mp3,ogg,xcf,xpm}")),            #TRANSLATORS: translate this string ONLY to the first "\t", leave it and the following parts intact            "regexes" : prefs.Value(prefs.STRING, _("CVS keywords\t0\t\$\\w+(:[^\\n$]+)?\$\n") + \            #TRANSLATORS: translate this string ONLY to the first "\t", leave it and the following parts intact            _("C++ comment\t0\t//.*\n") + \            #TRANSLATORS: translate this string ONLY to the first "\t", leave it and the following parts intact            _("C comment\t0\t/\*.*?\*/\n") + \            #TRANSLATORS: translate this string ONLY to the first "\t", leave it and the following parts intact            _("All whitespace\t0\t[ \\t\\r\\f\\v]*\n") + \            #TRANSLATORS: translate this string ONLY to the first "\t", leave it and the following parts intact            _("Leading whitespace\t0\t^[ \\t\\r\\f\\v]*\n") + \            #TRANSLATORS: translate this string ONLY to the first "\t", leave it and the following parts intact            _("Script comment\t0\t#.*")),        "ignore_blank_lines" : prefs.Value(prefs.BOOL, 1)    }    def __init__(self):        prefs.Preferences.__init__(self, "/apps/meld", self.defaults)    def get_cvs_command(self, op=None):        cmd = [self.cvs_binary]        if self.cvs_quiet:            cmd.append("-q")        if self.cvs_compression:            cmd.append("-z%i" % self.cvs_compression_value)        if self.cvs_ignore_cvsrc:            cmd.append("-f")        if op:            cmd.append(op)            if op == "update":                if self.cvs_create_missing:                    cmd.append("-d")                if self.cvs_prune_empty:                    cmd.append("-P")        return cmd    def get_current_font(self):        if self.use_custom_font:            return self.custom_font        else:            return self._gconf.get_string('/desktop/gnome/interface/monospace_font_name') or "Monospace 10"    def get_toolbar_style(self):        if self.toolbar_style == 0:            style = self._gconf.get_string('/desktop/gnome/interface/toolbar_style') or "both"            style = style.replace("-","_")            style = {"both":gtk.TOOLBAR_BOTH, "text":gtk.TOOLBAR_TEXT,                     "icon":gtk.TOOLBAR_ICONS, "icons":gtk.TOOLBAR_ICONS,                     "both_horiz":gtk.TOOLBAR_BOTH_HORIZ,                     "both-horiz":gtk.TOOLBAR_BOTH_HORIZ                     }[style]        else:            style = self.toolbar_style - 1        return style    def get_gnome_editor_command(self, files):        argv = []        editor = self._gconf.get_string('/desktop/gnome/applications/editor/exec') or "gedit"        if self._gconf.get_bool("/desktop/gnome/applications/editor/needs_term"):            texec = self._gconf.get_string("/desktop/gnome/applications/terminal/exec")            if texec:                argv.append(texec)                targ = self._gconf.get_string("/desktop/gnome/applications/terminal/exec_arg")                if targ:                    argv.append(targ)            argv.append( "%s %s" % (editor, " ".join( [f.replace(" ","\\ ") for f in files]) ) )        else:            argv = [editor] + files        return argv    def get_custom_editor_command(self, files):        return self.edit_command_custom.split() + files################################################################################## MeldApp#################################################################################class MeldApp(gnomeglade.GnomeApp):    #    # init    #    def __init__(self):        gladefile = paths.share_dir("glade2/meldapp.glade")        gnomeglade.GnomeApp.__init__(self, "meld", version, gladefile, "meldapp")        self._map_widgets_into_lists( "settings_drawstyle".split() )        self.statusbar = MeldStatusBar(self.task_progress, self.task_status, self.doc_status)        self.prefs = MeldPreferences()        if not developer:#hide magic testing button            self.toolbar_magic.hide()        elif 1:            def showPrefs(): PreferencesDialog(self)            gobject.idle_add(showPrefs)        self.toolbar.set_style( self.prefs.get_toolbar_style() )        self.prefs.notify_add(self.on_preference_changed)        self.idle_hooked = 0        self.scheduler = task.LifoScheduler()        self.scheduler.connect("runnable", self.on_scheduler_runnable )        self.widget.set_default_size(self.prefs.window_size_x, self.prefs.window_size_y)        self.widget.show()    def on_idle(self):        ret = self.scheduler.iteration()        if ret:            if type(ret) in (type(""), type(u"")):                self.statusbar.set_task_status(ret)            elif type(ret) == type(0.0):                self.statusbar.task_progress.set_fraction(ret)            else:                self.statusbar.task_progress.pulse()        else:            self.statusbar.task_progress.set_fraction(0)        if self.scheduler.tasks_pending():            self.toolbar_stop.set_sensitive(1)            return 1        else:            self.statusbar.set_task_status("")            self.idle_hooked = 0            self.toolbar_stop.set_sensitive(0)            return 0    def on_scheduler_runnable(self, sched):        if not self.idle_hooked:            self.idle_hooked = 1            gobject.idle_add( self.on_idle )    def on_preference_changed(self, key, value):        if key == "toolbar_style":            self.toolbar.set_style( self.prefs.get_toolbar_style() )    #    # General events and callbacks    #    def on_delete_event(self, *extra):        return self.on_menu_quit_activate()    def on_switch_page(self, notebook, page, which):        newdoc = notebook.get_nth_page(which).get_data("pyobject")        newseq = newdoc.undosequence        self.button_undo.set_sensitive(newseq.can_undo())        self.button_redo.set_sensitive(newseq.can_redo())        nbl = self.notebook.get_tab_label( newdoc.widget )        self.widget.set_title( nbl.label.get_text() + " - Meld")        self.statusbar.set_doc_status("")        newdoc.on_switch_event()        self.scheduler.add_task( newdoc.scheduler )

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -