Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /newedit/src/images/, /newedit/src/modules/

newedit
Discussion topic

Back to topic list

CVS update: /newedit/src/images/, /newedit/src/modules/

Reply

Author limodou
Full name limodou
Date 2004-05-10 22:14:28 PDT
Message User: limodou
Date: 04/05/10 22:14:28

Added:
 /newedit/src/images/
  prop.gif
 /newedit/src/modules/
  RecentFile.py

Log:
 Issue number:
 Obtained from:
 Submitted by:
 Reviewed by:

File Changes:

Directory: /newedit/src/images/
===============================

File [added]: prop.gif
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/images/p​rop.gif?rev=1.1&​content-type=text/vn​d.viewcvs-markup
Directory: /newedit/src/modules/
====================​============

File [added]: RecentFile.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/modules/​RecentFile.py?rev=1.​1&content-type=t​ext/vnd.viewcvs-mark​up
Added lines: 67
---------------
import Mixin
import wx
import os.path
import makemenu

menulist = [
    (100,
    [
        (112, 'IDM_FILE_RECENTFILES', 'Open Recent', wx.ITEM_NORMAL, None, ''),
    ]),
    (112,
    [
        (100, 'IDM_FILE_RECENTFILES_ITEMS', 'Empty', wx.ITEM_NORMAL, 'OnOpenRecentFiles', ''),
    ]),
]
Mixin.setMixin('mainframe', 'menulist', menulist)

def main_init(win):
    create_recent_menu(win)
Mixin.setPlugin('mainframe', 'init', main_init)

def pref_init(pref):
    pref.last_dir = ''
    pref.recent_files = []
    pref.recent_files_num = 10
    pref.preflist.append​(('generic', 100, 'num', 'recent_files_num', 'Max number of recent files:', None))
Mixin.setPlugin('preference', 'init', pref_init)

def afteropen(win, filename):
    if win.pref.recent_file​s.count(filename) > 0:
        win.pref.recent_file​s.remove(filename)
    win.pref.recent_files.insert(0, filename)
    while len(win.pref.recent_​files)>win.pref.r​ecent_files_num:
        win.pref.recent_files.pop(-1)
    win.pref.last_dir = os.path.dirname(filename)
    win.pref.save()
    create_recent_menu(win)
Mixin.setPlugin('mainframe', 'afteropen', afteropen)
Mixin.setPlugin('mainframe', 'aftersave', afteropen)

def create_recent_menu(win):
    menu = makemenu.findmenu(wi​n.menuitems, 'IDM_FILE_RECENTFILES')
    items = menu.GetMenuItems()
    x = len(items) - 1
    while x > -1:
        menu.Remove(win.IDM_​FILE_RECENTFILES_ITE​MS + x)
        x -= 1
    for i in items:
        i.Destroy()

    if len(win.pref.recent_files) == 0:
        id = win.IDM_FILE_RECENTFILES_ITEMS
        menu.Append(id, 'Empty')
        menu.Enable(id, False)
    else:
        for i, filename in enumerate(win.pref.r​ecent_files):
            id = win.IDM_FILE_RECENTF​ILES_ITEMS+i
            menu.Append(id, "&%d %s" % (i+1, filename))
            wx.EVT_MENU(win, id, getattr(win, 'OnOpenRecentFiles'))

def OnOpenRecentFiles(win, event):
    eid = event.GetId()
    index = eid - win.IDM_FILE_RECENTFILES_ITEMS
    filename = win.pref.recent_files[index]
    win.editctrl.new(filename)
    afteropen(win, filename)
Mixin.setMixin('mainframe', 'OnOpenRecentFiles', OnOpenRecentFiles)




--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@newe​dit.tigris.org
For additional commands, e-mail: cvs-help at newedit dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /newedit/src/images/, /newedit/src/modules/ limodou limodou 2004-05-10 22:14:28 PDT
Messages per page: