Ejemplo n.º 1
0
 def alt_o(self, self2):
     # Simplified open
     fname = pedofd.ofd("")
     if fname != "":
         self2.mained.openfile(fname)
Ejemplo n.º 2
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 strx

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

            #label = gtk.Label(" " + os.path.basename(aa) + " ")
            #self.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"
            '''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()    '''
            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 == "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 == "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)
Ejemplo n.º 3
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":
            # 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()    '''
            # 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":
            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 == "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")