示例#1
0
文件: pedtask.py 项目: pglen/pyedpro
    def start_edit(self, filex):

        old = os.getcwd()
        fdir = os.path.dirname(os.path.realpath(__file__))
        #print("fdir:", fdir)
        mydir = os.path.dirname(os.path.join(fdir, "../"))
        #print("mydir:", mydir)
        os.chdir(mydir)
        myscript = os.path.realpath(os.path.join(mydir, 'pyedpro.py'))
        if pedconfig.conf.verbose:
            print("myscript:", myscript, "filex:", filex)

        ret = 0
        try:
            if platform.system().find("Win") >= 0:
                print("No exec function on windows. (TODO)")
                pedync.message("\n   No exec function on windows. \n\n")
            else:
                # Stumble until editor found
                ret = subprocess.Popen(["python3", myscript, filex])
                if ret.returncode:
                    ret = subprocess.Popen(["python", myscript, filex])
                    if not ret.returncode:
                        raise OSError
        except:
            print("Cannot launch new editor instance", sys.exc_info())
            pedync.message("\n   Cannot launch new editor instance \n\n")

        # Back to original dir
        os.chdir(os.path.dirname(old))
示例#2
0
文件: pedtask.py 项目: pglen/pyedpro
    def start_htmlstr(self):
        try:
            xfname = os.path.dirname(__file__) + os.sep + "webwin.py"

            sumstr = ""
            for bb in self.text:
                sumstr += bb + "\n"

            comline3 = [
                "python",
                xfname,
                sumstr,
            ]
            try:
                ret = subprocess.Popen(comline3)
            except:
                print("Cannot start browser %s" % str(comline3),
                      sys.exc_info())
                pedync.message("\n   Cannot start %s \n\n" % str(comline3) +
                               str(sys.exc_info()))
                return
        except:
            print("Cannot start HTML Win %s" % str(newfname), sys.exc_info())
            pedync.message("\n   Cannot start %s \n\n" % str(newfname) +
                           str(sys.exc_info()))
            return
示例#3
0
文件: acthand.py 项目: pglen/pgpygtk
 def f2(self, self2):
     #print "F2"
     self2.mained.update_statusbar("Opening DEV help file ...")
     try:
         ret = subprocess.Popen(["devhelp",])
     except:
         pedync.message("\n   Cannot launch devhelp   \n\n"
                        "              (Please install)")
示例#4
0
文件: pedwin.py 项目: pglen/pgpygtk
 def activate_qhelp(self, action):
     self.update_statusbar("Showing quick help")
     try:
         rr = get_exec_path("README")
         #pid = os.spawnlp(os.P_NOWAIT, "pangview.py", "pangview",  rr)
         ret = subprocess.Popen(["pangview.py", rr])
     except:
         pedync.message("\n   Cannot launch the pangview.py utility.   \n\n"
                        "              (Please install)")
示例#5
0
 def f2(self, self2):
     #print "F2"
     try:
         ret = subprocess.Popen([
             "devhelp",
         ])
     except:
         pedync.message("\n   Cannot launch devhelp   \n\n"
                        "              (Please install)")
示例#6
0
文件: acthand.py 项目: pglen/pgpygtk
 def alt_y(self, self2):
     #print "Compile"
     writefile("tmp", self2.text)
     try:
        py_compile.compile('tmp', doraise = True)
     except py_compile.PyCompileError, msg:
         ln  = msg[2][1][1]; col = msg[2][1][2]
         mmm = msg[2][0] + "\n\n    Ln: " +  str(ln) + " Col: " + str(col)
         pedync.message("    " + mmm + "    ", msg[1])
         self2.gotoxy(col - 1, ln - 1)
示例#7
0
文件: pedtask.py 项目: pglen/pyedpro
 def start_browser(self, newfname):
     comline2 = [
         "firefox",
         newfname,
     ]
     try:
         ret = subprocess.Popen(comline2)
     except:
         print("Cannot start browser %s" % str(comline2), sys.exc_info())
         pedync.message("\n   Cannot start %s \n\n" % str(comline2) +
                        str(sys.exc_info()))
         return
示例#8
0
 def activate_qhelp(self, action):
     self.update_statusbar("Showing quick help")
     rr = get_exec_path("QHELP")
     try:
         if platform.system().find("Win") >= 0:
             xxx = get_exec_path(".." + os.sep + "pangview.py")
             print xxx, rr
             ret = subprocess.Popen(["python", xxx, rr])
         else:
             ret = subprocess.Popen(["pangview.py", rr])
     except:
         pedync.message("\n   Cannot launch the pangview.py utility.   \n\n"
                        "              (Please install)")
示例#9
0
 def f3(self, self2):
     #print "F3"
     self2.mained.update_statusbar("Opening KEYS help file ...")
     rr = get_exec_path("KEYS")
     try:
         ret = subprocess.Popen(["pangview.py", rr])
     except:
         try:  # Try  local
             xxx = get_exec_path("../pangview.py")
             print "Rrying local", xxx
             ret = subprocess.Popen([xxx, rr])
         except:
             pedync.message("\n   Cannot launch pangview.py   \n\n"
                            "              (Please install)")
示例#10
0
def launch_pangview(docx):

    ret = 0
    pname = get_pangview_path()

    if pedconfig.conf.verbose:
        print("launching pangview:", pname, "with", docx)
    try:
        ret = subprocess.Popen(["python", pname,  docx])

    except:
        print("except on pang",  sys.exc_info())
        pedync.message("\n   Cannot launch the pangview.py utility.   \n\n"
                       "              (Please install)\n")
    return ret
示例#11
0
def tree_sel(xtree, xiter, xpath, dialog):
    #print "tree_sel", xtree, xiter, xpath
    sel = xtree.get_selection()
    xmodel, xiter = sel.get_selected()
    xstr = xmodel.get_value(xiter, 0)

    #xstr2 = xmodel.get_value(xiter, 1)
    #xstr3 = xmodel.get_value(xiter, 2)
    #print xstr, xstr2, xstr3

    if xstr[0] == "[":
        xstr = xstr[1:len(xstr) - 1]
    if os.path.isdir(xstr):
        #print "dir", xstr
        try:
            os.chdir(xstr)
        except:
            dlg = pedync.message(
            "\n   Canont change to directory:                           \n\n" \
            "    %s" % (sys.exc_info()[1] ), \
                            None, gtk.MESSAGE_ERROR)
            dlg.run()
            return
        populate(dialog)

    else:
        dialog.entry.set_text(xstr)
        dialog.response(gtk.RESPONSE_ACCEPT)
示例#12
0
文件: pedtask.py 项目: pglen/pyedpro
    def start_external(self, linprog, winprog):

        #print("start_external", linprog)

        try:
            if platform.system().find("Win") >= 0:
                ret = subprocess.Popen(winprog)
                #if not ret.returncode:
                #    raise OSError
            else:
                ret = subprocess.Popen(linprog)
                #if not ret.returncode:
                #    raise OSError
        except:
            print("Cannot launch %s" % str(linprog), sys.exc_info())
            pedync.message("\n   Cannot launch %s \n\n" % str(linprog) +
                           str(sys.exc_info()))
示例#13
0
def find_show(self, self2):

    #print "search", "'" + self.srctxt + "'"

    if self.srctxt == "":
        self2.mained.update_statusbar("Must specify search string")
        return          
        
    if self.dialog.checkbox.get_active():
        try:
            self.regex = re.compile(self.srctxt)
        except re.error, msg:
            #print  sys.exc_info()        
            pedync.message("\n   Error in regular expression: \n\n"\
                            "    '%s' -- %s" % (self.srctxt, msg),\
                            None, gtk.MESSAGE_ERROR)
            return                    
示例#14
0
文件: pedtask.py 项目: pglen/pyedpro
    def start_m4filter(self):

        #print("Filter called.")
        self.save()
        comline = [
            "m4",
            self.fname,
        ]
        try:
            ret = subprocess.Popen(comline,
                                   stderr=subprocess.PIPE,
                                   stdout=subprocess.PIPE)
        except:
            print("Cannot filter %s" % str(comline), sys.exc_info())
            pedync.message("\n   Cannot filter %s \n\n" % str(comline) +
                           str(sys.exc_info()))
            return
        try:
            outs, errs = ret.communicate()
        except:
            print("Cannot communicate with filter %s" % str(comline),
                  sys.exc_info())
            return

        res = outs.decode("cp437")
        #print("res", res)

        www = self.mained.get_width()
        if self.mained.hpaned3.get_position() > www - 20:
            self.mained.hpaned3.set_position(www - www / 4)
            self.mained.update_statusbar("Filter output active")

        newfname = os.path.splitext(self.fname)[0] + ".html"

        pppp = self.notebook3.get_nth_page(0)
        self.notebook3.set_tab_label(
            pppp,
            self.mained.make_label("Filter on M4 '" +
                                   os.path.basename(newfname) + "'"))
        arrx = res.split("\n")
        self.mained.diffpane.area.loadbuff(arrx)
        self.mained.diffpane.area.fname = newfname
        self.mained.update_statusbar("M4 filter output activated.")
        self.start_htmlwin(res)
示例#15
0
    def newfile(self, newname=""):

        if newname == "":
            # Find non existing file
            cnt = self.fcount + 1
            fff = ""
            base, ext = os.path.splitext(pedconfig.conf.UNTITLED)
            while True:
                fff = "%s_%d.txt" % (base, cnt)
                #print fff
                if not os.path.isfile(fff):
                    break
                cnt += 1

            self.fcount = cnt
        else:
            fff = newname
            # Touch
            try:
                open(fff, "w").close()
            except:
                sss = "Cannot create file %s" % newname
                self.update_statusbar(sss)
                print sss, sys.exc_info()
                pedync.message("\n" + sss + "\n")
                return

        vpaned = edPane([])
        vpaned.area.fname = os.path.realpath(fff)
        global notebook
        notebook.append_page(vpaned)
        vpaned.area.set_tablabel()

        #label = gtk.Label(" " + os.path.basename(aa) + " ")
        #notebook.set_tab_label(vpaned, label)
        self.window.show_all()

        # Make it current
        nn = notebook.get_n_pages()
        if nn:
            vcurr = notebook.set_current_page(nn - 1)
            vcurr = notebook.get_nth_page(nn - 1)
            self.window.set_focus(vcurr.vbox.area)
示例#16
0
文件: pedtask.py 项目: pglen/pyedpro
    def start_mdfilter(self):

        #print("MD Filter called.", os.getcwd())

        yfname = os.path.dirname(__file__) + os.sep + "default.yml"

        print(yfname)

        comline = [
            "md2html",
            "-s",
            yfname,
            self.fname,
        ]
        try:
            ret = subprocess.Popen(comline,
                                   stderr=subprocess.PIPE,
                                   stdout=subprocess.PIPE)
        except:
            print("Cannot start MD filter %s" % str(comline), sys.exc_info())
            pedync.message("\n   Cannot filter %s \n\n" % str(comline) +
                           str(sys.exc_info()))
            return
        try:
            outs, errs = ret.communicate()
        except:
            print("Cannot communicate with MD filter %s" % str(comline),
                  sys.exc_info())
            return

        newfname = os.path.splitext(self.fname)[0] + ".html"
        #print("processed:", self.fname, newfname)

        if not os.path.isfile(newfname):
            print("No conversion on %s" % self.fname)
            pedync.message("\n   Cannot convert '%s' \n"
                           "   to MD / HTML file\n\n" % self.fname)
            return

        self.start_htmlwin(newfname)
示例#17
0
def done_sess2_fc(win, resp, fc):

    #print  ("done_sess2_fc", resp)
    ddd = fc.old
    sesslist = []

    # Gather list of files
    if resp == Gtk.ButtonsType.OK:
        try:
            fname = win.get_filename()
            if not fname:
                print("Must have filename.")
            else:
                pedconfig.conf.pedwin.opensess(fname)
        except:
            print("Cannot load session file", sys.exc_info())
            pedync.message("Cannot load session file")
    else:
        pass
        #print("Cancelled")

    win.destroy()
示例#18
0
文件: pedtask.py 项目: pglen/pyedpro
 def start_htmlwin(self, newfname):
     try:
         xfname = os.path.dirname(__file__) + os.sep + "webwin.py"
         #print("xfname", )
         comline3 = [
             "python",
             xfname,
             "-d",
             newfname,
         ]
         try:
             ret = subprocess.Popen(comline3)
         except:
             print("Cannot start browser %s" % str(comline3),
                   sys.exc_info())
             pedync.message("\n   Cannot start %s \n\n" % str(comline3) +
                            str(sys.exc_info()))
             return
     except:
         print("Cannot start HTML Win %s" % str(newfname), sys.exc_info())
         pedync.message("\n   Cannot start %s \n\n" % str(newfname) +
                        str(sys.exc_info()))
         return
示例#19
0
文件: pedfind.py 项目: pglen/pgpygtk
def find(self, self2):

    self.treestore = None

    dialog = gtk.Dialog("pyedit: Find in text",
                   None,
                   gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                   (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                    gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
    dialog.set_default_response(gtk.RESPONSE_ACCEPT)

    # Spacers
    label1 = gtk.Label("   ");  label2 = gtk.Label("   ") 
    label3 = gtk.Label("   ");  label4 = gtk.Label("   ") 
    label5 = gtk.Label("   ");  label6 = gtk.Label("   ") 
    label7 = gtk.Label("   ");  label8 = gtk.Label("   ") 

    entry = gtk.Entry(); entry.set_activates_default(True)
    
    if  self2.oldsearch == "":
            self2.oldsearch = gconf.client_get_default().\
                    get_string(config_reg + "/src")
            if  self2.oldsearch == None:
                self2.oldsearch = ""

    # See if we have a selection for search
    if self2.xsel != -1:
        xssel = min(self2.xsel, self2.xsel2)
        xesel = max(self2.xsel, self2.xsel2)
        yssel = min(self2.ysel, self2.ysel2)
        yesel = max(self2.ysel, self2.ysel2)

        if yssel == yesel:
            self2.oldsearch = self2.text[yssel][xssel:xesel]
            
    entry.set_text(self2.oldsearch)
    dialog.vbox.pack_start(label4)  

    hbox2 = gtk.HBox()
    hbox2.pack_start(label6, False)  
    hbox2.pack_start(entry)  
    hbox2.pack_start(label7, False)  

    dialog.vbox.pack_start(hbox2)

    checkbox = gtk.CheckButton("Use _regular expression")
    checkbox2 = gtk.CheckButton("Case In_sensitive")
    dialog.vbox.pack_start(label5)  

    hbox = gtk.HBox()
    hbox.pack_start(label1);  hbox.pack_start(checkbox)
    hbox.pack_start(label2);  hbox.pack_start(checkbox2)
    hbox.pack_start(label3);  
    dialog.vbox.pack_start(hbox)
    dialog.vbox.pack_start(label8)  

    #label1.show(); label2.show();  label3.show(); 
    #hbox.show(); checkbox.show(); checkbox2.show(); entry.show()
    dialog.show_all()
    response = dialog.run()   
    self2.oldsearch = entry.get_text()
    self.srctxt = entry.get_text()     
    dialog.destroy()

    if response == gtk.RESPONSE_ACCEPT:
        #print "search", "'" + self.srctxt + "'"
        #print "checkbox", checkbox.get_active()
        #print "checkbox2", checkbox2.get_active()

        if self.srctxt == "":
            self2.mained.update_statusbar("Must specify search string")
            return          

        self2.oldsearch = entry.get_text()
                
        if checkbox.get_active():
            try:
                regex = re.compile(self.srctxt)
            except re.error, msg:
                #print "regex error", msd
                print  sys.exc_info()        
                pedync.message("\n   Error in regular expression: \n\n"\
                                "    '%s' -- %s" % (self.srctxt, msg),\
                                None, gtk.MESSAGE_ERROR)
                #win2.destroy()
                return                    

        self.peddoc = self2
        win2 = gtk.Window()
        win2.set_position(gtk.WIN_POS_CENTER)
        
        win2.set_events(    
                        gtk.gdk.POINTER_MOTION_MASK |
                        gtk.gdk.POINTER_MOTION_HINT_MASK |
                        gtk.gdk.BUTTON_PRESS_MASK |
                        gtk.gdk.BUTTON_RELEASE_MASK |
                        gtk.gdk.KEY_PRESS_MASK |
                        gtk.gdk.KEY_RELEASE_MASK |
                        gtk.gdk.FOCUS_CHANGE_MASK )

        win2.connect("key-press-event", area_key, self)
        win2.connect("key-release-event", area_key, self)

        # Position it out of the way
        sxx, syy = self2.mained.window.get_position()
        wxx, wyy = self2.mained.window.get_size()
        #print sxx, syy, wxx, wyy

        myww = 2 * wxx / 4; myhh = 2 * wyy / 4
        win2.set_default_size(myww, myhh)
        win2.move(sxx + wxx - myww - 25, syy + 25)        

        vbox = gtk.VBox()
        self.tree = create_tree(self, self.srctxt)
        self.tree.connect("row-activated",  tree_sel, self)
        self.tree.connect("cursor-changed",  tree_sel_row, self)
    
        stree = gtk.ScrolledWindow()
        stree.add(self.tree)
        vbox.pack_start(stree)                                        
        win2.add(vbox)
        win2.show_all()
        
        self2.accum = []; 
        cnt = 0; cnt2 = 0; was = -1
        curr = self2.caret[1] + self2.ypos
        
        for line in self2.text:
            if checkbox2.get_active():
                #print "case search"
                idx = line.lower().find(self.srctxt.lower())
            elif checkbox.get_active():
                res = regex.search(line)
                if res:
                    idx = res.start()
                else:
                    cnt += 1;           # Cont would skip this
                    continue
            else:
                idx = line.find(self.srctxt)

            if  idx >= 0:
                if cnt > curr and was == -1:
                    #self2.accum.append("curr"); 
                    was = cnt2
                line2 =  str(idx) + ":"  + str(cnt) + " " + line
                cnt2 += 1
                self2.accum.append(line2)
            cnt += 1; 
            
        update_treestore(self, self2.accum, was)                    

        gconf.client_get_default().\
                    set_string(config_reg + "/src", self.srctxt)
        
        #aa, bb, cc, dd = tree.get_path_at_pos(0, 0)
        #tree.set_cursor(aa)
        #print tree.get_cursor()
        self.tree.grab_focus()
示例#20
0
    def activate_action(self, action):

        #dialog = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT,
        #    gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE,
        #    'Action: "%s" of type "%s"' % (action.get_name(), type(action)))
        # Close dialog on user response
        #dialog.connect ("response", lambda d, r: d.destroy())
        #dialog.show()

        strx = action.get_name()
        #print "activate_action", strx

        if strx == "New":
            self.newfile()

        if strx == "Open":
            self.open()

        if strx == "Save":
            self.save()

        if strx == "SaveAs":
            self.save(True)

        if strx == "Close":
            self.closedoc()

        if strx == "Copy":
            self.copy()

        if strx == "Cut":
            self.cut()

        if strx == "Paste":
            self.paste()

        if strx == "Goto":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.alt_g(vcurr2.area)

        if strx == "Find":
            #print "find"
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.ctrl_f(vcurr2.area)

        if strx == "Record":
            #print "record"
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.f7(vcurr2.area)

        if strx == "Play":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.f8(vcurr2.area)

        if strx == "Spell":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.f9(vcurr2.area)

        if strx == "Spell2":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.f9(vcurr2.area, True)

        if strx == "Animate":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.f8(vcurr2.area, True)

        if strx == "Undo":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.ctrl_z(vcurr2.area)

        if strx == "Redo":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.ctrl_y(vcurr2.area)

        if strx == "SaveAll":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.alt_a(vcurr2.area)

        if strx == "Discard Undo":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                vcurr2.area.delundo()

        if strx == "Savemacro":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                vcurr2.area.savemacro()

        if strx == "Loadmacro":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                vcurr2.area.loadmacro()

        if strx == "NextWin":
            self.nextwin()

        if strx == "PrevWin":
            self.prevwin()

        if strx == "ShowLog":
            log.show_log()

        if strx.find("/sess_") >= 0:
            fname = pedconfig.conf.sql.get_str(strx)
            self.openfile(fname)

        if strx == "Colors":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedcolor.colors(self, vcurr2.area)

        if strx == "Fonts":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedfont.selfont(self, vcurr2.area)

        if strx == "Settings":
            pedync.message("\n    Settings: Work in progress    \n")

        if strx == "Help":
            #pedync.message("\n    Help: Work in progress    \n")
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.f1(vcurr2.area)

        if strx == "Settings":
            pedync.message("\n    Settings: Work in progress    \n")

        if strx == "KeyDoc":
            self.update_statusbar("Showing Keyboard Help")
            fname = get_exec_path("KEYS.TXT")
            self.openfile(fname)
示例#21
0
    def activate_action(self, action):

        #dialog = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT,
        #    gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE,
        #    'Action: "%s" of type "%s"' % (action.get_name(), type(action)))
        # Close dialog on user response
        #dialog.connect ("response", lambda d, r: d.destroy())
        #dialog.show()

        strx = action.get_name()
        print "activate_action", strx

        if strx == "New":
            aa = pedconfig.conf.UNTITLED
            vpaned = edPane([])
            vpaned.area.fname = os.path.realpath(aa)
            global notebook
            notebook.append_page(vpaned)
            vpaned.area.set_tablabel()

            #label = gtk.Label(" " + os.path.basename(aa) + " ")
            #notebook.set_tab_label(vpaned, label)
            self.window.show_all()

            # Make it current
            nn = notebook.get_n_pages()
            if nn:
                vcurr = notebook.set_current_page(nn - 1)
                vcurr = notebook.get_nth_page(nn - 1)
                self.window.set_focus(vcurr.vbox.area)

        if strx == "Open":
            #print "open"
            # Traditional open file
            '''but =   "Cancel", gtk.BUTTONS_CANCEL, "Open File", gtk.BUTTONS_OK
            fc = gtk.FileChooserDialog("Open file", self.window, \
                gtk.FILE_CHOOSER_ACTION_OPEN, but)
            fc.set_default_response(gtk.BUTTONS_OK)
            fc.connect("response", self.done_open_fc)                
            #fc.set_current_name(self.fname)
            fc.run()    '''
            # Simplified
            fname = pedofd.ofd("")
            if fname != "":
                self.openfile(fname)

        if strx == "Save":
            vcurr = notebook.get_nth_page(notebook.get_current_page())
            vcurr.area.save()

        if strx == "SaveAs":
            vcurr = notebook.get_nth_page(notebook.get_current_page())
            vcurr.area.saveas()

        if strx == "Close":
            cc = notebook.get_n_pages()
            nn = notebook.get_current_page()
            vcurr = notebook.get_nth_page(nn)
            # Disable close
            if vcurr.area.closedoc():
                return

            # Wrap around
            if nn == 0: mm = cc - 1
            else: mm = nn - 1

            notebook.set_current_page(mm)
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            self.window.set_focus(vcurr2.vbox.area)
            notebook.remove_page(nn)
            self.window.show_all()

        if strx == "Copy":
            #print "copy"
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.ctrl_c(vcurr2.area)

        if strx == "Cut":
            #print "cut"
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.ctrl_x(vcurr2.area)

        if strx == "Paste":
            #print "paste"
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.ctrl_v(vcurr2.area)

        if strx == "Goto":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.alt_g(vcurr2.area)

        if strx == "Find":
            print "find"
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.ctrl_f(vcurr2.area)

        if strx == "Record":
            #print "record"
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.f7(vcurr2.area)

        if strx == "Play":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.f8(vcurr2.area)

        if strx == "Animate":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.f8(vcurr2.area, True)

        if strx == "Undo":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.ctrl_z(vcurr2.area)

        if strx == "Redo":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.ctrl_y(vcurr2.area)

        if strx == "SaveAll":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.alt_a(vcurr2.area)

        if strx == "Discard Undo":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                vcurr2.area.delundo()

        if strx == "NextWin":
            self.nextwin()

        if strx == "PrevWin":
            self.prevwin()

        if strx.find("/sess_") >= 0:
            fname = gconf.client_get_default().get_string\
                        (pedconfig.conf.config_reg + strx)
            self.openfile(fname)

        if strx == "Help":
            #pedync.message("\n    Help: Work in progress    \n")
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.f1(vcurr2.area)

        if strx == "Settings":
            pedync.message("\n    Settings: Work in progress    \n")
示例#22
0
文件: pedwin.py 项目: pglen/pgpygtk
    def activate_action(self, action):

        #dialog = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT,
        #    gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE,
        #    'Action: "%s" of type "%s"' % (action.get_name(), type(action)))
        # Close dialog on user response
        #dialog.connect ("response", lambda d, r: d.destroy())
        #dialog.show()

        strx = action.get_name()
        #print "activate_action", strx

        if strx == "New":
            # Find non existing file
            cnt = self.fcount + 1
            fff = ""
            base, ext = os.path.splitext(pedconfig.conf.UNTITLED)
            while True:
                fff = "%s_%d.txt" % (base, cnt)
                #print fff
                if not os.path.isfile(fff):
                    break
                cnt += 1

            self.fcount = cnt
            # Touch
            #open(fff, "w").close()

            vpaned = edPane([])
            vpaned.area.fname = os.path.realpath(fff)
            global notebook
            notebook.append_page(vpaned)
            vpaned.area.set_tablabel()

            #label = gtk.Label(" " + os.path.basename(aa) + " ")
            #notebook.set_tab_label(vpaned, label)
            self.window.show_all()

            # Make it current
            nn = notebook.get_n_pages()
            if nn:
                vcurr = notebook.set_current_page(nn - 1)
                vcurr = notebook.get_nth_page(nn - 1)
                self.window.set_focus(vcurr.vbox.area)

        if strx == "Open":
            #print "open"
            # Traditional open file
            but = "Cancel", gtk.BUTTONS_CANCEL, "Open File", gtk.BUTTONS_OK
            fc = gtk.FileChooserDialog("Open file", self.window, \
                gtk.FILE_CHOOSER_ACTION_OPEN, but)
            fc.set_default_response(gtk.BUTTONS_OK)
            fc.connect("response", self.done_open_fc)
            #fc.set_current_name(self.fname)
            fc.run()

        if strx == "Save":
            vcurr = notebook.get_nth_page(notebook.get_current_page())
            vcurr.area.save()

        if strx == "SaveAs":
            vcurr = notebook.get_nth_page(notebook.get_current_page())
            vcurr.area.saveas()

        if strx == "Close":
            self.closedoc()

        if strx == "Copy":
            #print "copy"
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.ctrl_c(vcurr2.area)

        if strx == "Cut":
            #print "cut"
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.ctrl_x(vcurr2.area)

        if strx == "Paste":
            #print "paste"
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.ctrl_v(vcurr2.area)

        if strx == "Goto":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.alt_g(vcurr2.area)

        if strx == "Find":
            print "find"
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.ctrl_f(vcurr2.area)

        if strx == "Record":
            #print "record"
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.f7(vcurr2.area)

        if strx == "Play":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.f8(vcurr2.area)

        if strx == "Animate":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.f8(vcurr2.area, True)

        if strx == "Undo":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.ctrl_z(vcurr2.area)

        if strx == "Redo":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.ctrl_y(vcurr2.area)

        if strx == "SaveAll":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.alt_a(vcurr2.area)

        if strx == "Discard Undo":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                vcurr2.area.delundo()

        if strx == "Savemacro":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                vcurr2.area.savemacro()

        if strx == "Loadmacro":
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                vcurr2.area.loadmacro()

        if strx == "NextWin":
            self.nextwin()

        if strx == "PrevWin":
            self.prevwin()

        if strx.find("/sess_") >= 0:
            fname = gconf.client_get_default().get_string\
                        (pedconfig.conf.config_reg + strx)
            self.openfile(fname)

        if strx == "Help":
            #pedync.message("\n    Help: Work in progress    \n")
            nn2 = notebook.get_current_page()
            vcurr2 = notebook.get_nth_page(nn2)
            if vcurr2:
                pedconfig.conf.keyh.act.f1(vcurr2.area)

        if strx == "Settings":
            pedync.message("\n    Settings: Work in progress    \n")