~ubuntu-branches/ubuntu/trusty/boa-constructor/trusty

« back to all changes in this revision

Viewing changes to Models/EditorHelper.py

  • Committer: Bazaar Package Importer
  • Author(s): Cédric Delfosse
  • Date: 2007-01-23 21:32:29 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070123213229-1d9lxp9c4dutjwv5
Add a .desktop file (Closes: #349081)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#-----------------------------------------------------------------------------
2
 
# Name:        EditorHelper.py
3
 
# Purpose:
4
 
#
5
 
# Author:      Riaan Booysen
6
 
#
7
 
# Created:     2001
8
 
# RCS-ID:      $Id: EditorHelper.py,v 1.9 2004/08/16 13:28:13 riaan Exp $
9
 
# Copyright:   (c) 2001 - 2004
10
 
# Licence:     GPL
11
 
#-----------------------------------------------------------------------------
12
 
 
13
 
""" Global namespace for general IDE window ids, image indexes and registries """
14
 
 
15
 
import Preferences, Utils
16
 
 
17
 
(wxID_EDITOROPEN, wxID_EDITORSAVE, wxID_EDITORSAVEAS, wxID_EDITORCLOSEPAGE,
18
 
 wxID_EDITORREFRESH, wxID_EDITORDESIGNER, wxID_EDITORDEBUG, wxID_EDITORHELP,
19
 
 wxID_DEFAULTVIEWS, wxID_EDITORSWITCHTO, wxID_EDITORDIFF, wxID_EDITORPATCH,
20
 
 wxID_EDITORTOGGLEVIEW, wxID_EDITORSWITCHEXPLORER, wxID_EDITORSWITCHSHELL,
21
 
 wxID_EDITORSWITCHPALETTE, wxID_EDITORSWITCHINSPECTOR,
22
 
 wxID_EDITORTOGGLERO, wxID_EDITORHELPFIND, wxID_EDITORRELOAD,
23
 
 wxID_EDITORHELPABOUT, wxID_EDITORHELPGUIDE, wxID_EDITORHELPTIPS,
24
 
 wxID_EDITORHELPOPENEX,
25
 
 wxID_EDITORPREVPAGE, wxID_EDITORNEXTPAGE,
26
 
 wxID_EDITORBROWSEFWD, wxID_EDITORBROWSEBACK,
27
 
 wxID_EDITOREXITBOA, wxID_EDITOROPENRECENT,
28
 
 wxID_EDITORHIDEPALETTE, wxID_EDITORWINDIMS, wxID_EDITORWINDIMSLOAD,
29
 
 wxID_EDITORWINDIMSSAVE, wxID_EDITORWINDIMSRESDEFS,
30
 
 wxID_EDITORSWITCHPREFS,
31
 
) = Utils.wxNewIds(36)
32
 
 
33
 
imgCounter=0
34
 
def imgIdxRange(cnt=0):
35
 
    """ Allocates either a range of image indexes or a single one """
36
 
    global imgCounter
37
 
    if cnt:
38
 
        rng = range(imgCounter, imgCounter + cnt)
39
 
        imgCounter = imgCounter + cnt
40
 
        return rng
41
 
    else:
42
 
        imgCounter = imgCounter + 1
43
 
        return imgCounter - 1
44
 
 
45
 
builtinImgs =('Images/Modules/FolderUp_s.png',
46
 
              'Images/Modules/Folder_s.png',
47
 
              'Images/Modules/Folder_green_s.png',
48
 
              'Images/Modules/Folder_cyan_s.png',
49
 
              'Images/Shared/SystemObj.png',
50
 
              'Images/Shared/SystemObjOrdered.png',
51
 
              'Images/Shared/SystemObjBroken.png',
52
 
              'Images/Shared/SystemObjPending.png',
53
 
              'Images/Shared/SystemObjDisabled.png',
54
 
              'Images/Modules/ZopeConn_s.png',
55
 
              'Images/Shared/BoaLogo.png',
56
 
              'Images/Modules/Drive_s.png',
57
 
              'Images/Modules/NetDrive_s.png',
58
 
              'Images/Modules/FolderBookmark_s.png',
59
 
              'Images/Modules/OpenEditorModels_s.png',
60
 
              'Images/Modules/PrefsFolder_s.png',
61
 
              'Images/Shared/PrefsSTCStyles.png',
62
 
              'Images/Editor/RecentFiles.png',
63
 
              'Images/Editor/Shell.png',
64
 
              'Images/Editor/Explorer.png',
65
 
              'Images/Modules/HelpBook_s.png',
66
 
            )
67
 
# Like builtinImgs, but stores list of tuples, (imgIdx, name)
68
 
pluginImgs = []
69
 
 
70
 
def addPluginImgs(imgPath):
71
 
    imgIdx = imgIdxRange()
72
 
    pluginImgs.append( (imgIdx, imgPath) )
73
 
    
74
 
    return imgIdx
75
 
 
76
 
 
77
 
# Indexes for the imagelist
78
 
(imgFolderUp, imgFolder, imgPathFolder, imgCVSFolder, imgSystemObj,
79
 
 imgSystemObjOrdered, imgSystemObjBroken, imgSystemObjPending, imgSystemObjDisabled,
80
 
 imgZopeConnection, imgBoaLogo, imgFSDrive, imgNetDrive, imgFolderBookmark,
81
 
 imgOpenEditorModels, imgPrefsFolder, imgPrefsSTCStyles, imgRecentFiles,
82
 
 imgShell, imgExplorer, imgHelpBook,
83
 
 
84
 
 imgTextModel, imgBitmapFileModel, imgUnknownFileModel, imgInternalFileModel,
85
 
) = imgIdxRange(25)
86
 
 
87
 
# List of name, func tuples that will be installed under the Tools menu.
88
 
editorToolsReg = []
89
 
 
90
 
# Registry of all modules {modelIdentifier : Model} (populated by EditorModels)
91
 
# Used for images and header identifier
92
 
modelReg = {}
93
 
# Mapping of file extension to model (populated by EditorModels)
94
 
extMap = {}
95
 
# List of image file extensions
96
 
imageExtReg = []
97
 
# Dict of ext:Model entries. For types where not all files of that ext are images
98
 
imageSubTypeExtReg = {}
99
 
# List of extensions for internal filetypes created by Boa
100
 
internalFilesReg = []
101
 
# Dict of ext:Model entries which can be further identified by reading a header from the source
102
 
inspectableFilesReg = {}
103
 
# List of extensions for additional binary files (will not be searched)
104
 
binaryFilesReg = []
105
 
def getBinaryFiles():
106
 
    return imageExtReg + binaryFilesReg
107
 
 
108
 
def initExtMap():
109
 
    # All non python files identified by extension
110
 
    for mod in modelReg.values():
111
 
        if mod.ext not in ['.*', '.intfile', '.pybin'] +inspectableFilesReg.keys():
112
 
            extMap[mod.ext] = mod
 
1
#-----------------------------------------------------------------------------
 
2
# Name:        EditorHelper.py
 
3
# Purpose:
 
4
#
 
5
# Author:      Riaan Booysen
 
6
#
 
7
# Created:     2001
 
8
# RCS-ID:      $Id: EditorHelper.py,v 1.11 2005/05/18 12:05:11 riaan Exp $
 
9
# Copyright:   (c) 2001 - 2005
 
10
# Licence:     GPL
 
11
#-----------------------------------------------------------------------------
 
12
 
 
13
""" Global namespace for general IDE window ids, image indexes and registries """
 
14
 
 
15
import Preferences, Utils
 
16
 
 
17
(wxID_EDITOROPEN, wxID_EDITORSAVE, wxID_EDITORSAVEAS, wxID_EDITORCLOSEPAGE,
 
18
 wxID_EDITORREFRESH, wxID_EDITORDESIGNER, wxID_EDITORDEBUG, wxID_EDITORHELP,
 
19
 wxID_DEFAULTVIEWS, wxID_EDITORSWITCHTO, wxID_EDITORDIFF, wxID_EDITORPATCH,
 
20
 wxID_EDITORTOGGLEVIEW, wxID_EDITORSWITCHEXPLORER, wxID_EDITORSWITCHSHELL,
 
21
 wxID_EDITORSWITCHPALETTE, wxID_EDITORSWITCHINSPECTOR,
 
22
 wxID_EDITORTOGGLERO, wxID_EDITORHELPFIND, wxID_EDITORRELOAD,
 
23
 wxID_EDITORHELPABOUT, wxID_EDITORHELPGUIDE, wxID_EDITORHELPTIPS,
 
24
 wxID_EDITORHELPOPENEX,
 
25
 wxID_EDITORPREVPAGE, wxID_EDITORNEXTPAGE,
 
26
 wxID_EDITORBROWSEFWD, wxID_EDITORBROWSEBACK,
 
27
 wxID_EDITOREXITBOA, wxID_EDITOROPENRECENT,
 
28
 wxID_EDITORHIDEPALETTE, wxID_EDITORWINDIMS, wxID_EDITORWINDIMSLOAD,
 
29
 wxID_EDITORWINDIMSSAVE, wxID_EDITORWINDIMSRESDEFS,
 
30
 wxID_EDITORSWITCHPREFS,
 
31
) = Utils.wxNewIds(36)
 
32
 
 
33
imgCounter=0
 
34
def imgIdxRange(cnt=0):
 
35
    """ Allocates either a range of image indexes or a single one """
 
36
    global imgCounter
 
37
    if cnt:
 
38
        rng = range(imgCounter, imgCounter + cnt)
 
39
        imgCounter = imgCounter + cnt
 
40
        return rng
 
41
    else:
 
42
        imgCounter = imgCounter + 1
 
43
        return imgCounter - 1
 
44
 
 
45
builtinImgs =('Images/Modules/FolderUp.png',
 
46
              'Images/Modules/Folder.png',
 
47
              'Images/Modules/Folder_green.png',
 
48
              'Images/Modules/Folder_cyan.png',
 
49
              'Images/Shared/SystemObj.png',
 
50
              'Images/Shared/SystemObjOrdered.png',
 
51
              'Images/Shared/SystemObjBroken.png',
 
52
              'Images/Shared/SystemObjPending.png',
 
53
              'Images/Shared/SystemObjDisabled.png',
 
54
              'Images/Modules/ZopeConn.png',
 
55
              'Images/Shared/BoaLogo.png',
 
56
              'Images/Modules/Drive.png',
 
57
              'Images/Modules/NetDrive.png',
 
58
              'Images/Modules/FolderBookmark.png',
 
59
              'Images/Modules/OpenEditorModels.png',
 
60
              'Images/Modules/PrefsFolder.png',
 
61
              'Images/Shared/PrefsSTCStyles.png',
 
62
              'Images/Editor/RecentFiles.png',
 
63
              'Images/Editor/Shell.png',
 
64
              'Images/Editor/Explorer.png',
 
65
              'Images/Modules/HelpBook.png',
 
66
            )
 
67
# Like builtinImgs, but stores list of tuples, (imgIdx, name)
 
68
pluginImgs = []
 
69
 
 
70
def addPluginImgs(imgPath):
 
71
    imgIdx = imgIdxRange()
 
72
    pluginImgs.append( (imgIdx, imgPath) )
 
73
 
 
74
    return imgIdx
 
75
 
 
76
 
 
77
# Indexes for the imagelist
 
78
(imgFolderUp, imgFolder, imgPathFolder, imgCVSFolder, imgSystemObj,
 
79
 imgSystemObjOrdered, imgSystemObjBroken, imgSystemObjPending, imgSystemObjDisabled,
 
80
 imgZopeConnection, imgBoaLogo, imgFSDrive, imgNetDrive, imgFolderBookmark,
 
81
 imgOpenEditorModels, imgPrefsFolder, imgPrefsSTCStyles, imgRecentFiles,
 
82
 imgShell, imgExplorer, imgHelpBook,
 
83
 
 
84
 imgTextModel, imgBitmapFileModel, imgUnknownFileModel, imgInternalFileModel,
 
85
) = imgIdxRange(25)
 
86
 
 
87
# List of name, func tuples that will be installed under the Tools menu.
 
88
editorToolsReg = []
 
89
 
 
90
# Registry of all modules {modelIdentifier : Model} (populated by EditorModels)
 
91
# Used for images and header identifier
 
92
modelReg = {}
 
93
# Mapping of file extension to model (populated by EditorModels)
 
94
extMap = {}
 
95
# List of image file extensions
 
96
imageExtReg = []
 
97
# Dict of ext:Model entries. For types where not all files of that ext are images
 
98
imageSubTypeExtReg = {}
 
99
# List of extensions for internal filetypes created by Boa
 
100
internalFilesReg = []
 
101
# Dict of ext:Model entries which can be further identified by reading a header from the source
 
102
inspectableFilesReg = {}
 
103
# List of extensions for additional binary files (will not be searched)
 
104
binaryFilesReg = []
 
105
def getBinaryFiles():
 
106
    return imageExtReg + binaryFilesReg
 
107
 
 
108
def initExtMap():
 
109
    # All non python files identified by extension
 
110
    for mod in modelReg.values():
 
111
        if mod.ext not in ['.*', '.intfile', '.pybin'] +inspectableFilesReg.keys():
 
112
            extMap[mod.ext] = mod