/[gnue]/gnue-designer/src/base/MRUManager.py
ViewVC logotype

Diff of /gnue-designer/src/base/MRUManager.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by jamest, Fri Apr 4 23:05:32 2003 UTC revision 1.9 by jcater, Tue Jul 15 22:57:27 2003 UTC
# Line 47  class MRUManager: Line 47  class MRUManager:
47      self.runtime_section = "MRUList"      self.runtime_section = "MRUList"
48    
49      # Load the saved MRU list      # Load the saved MRU list
50      for i in range(self._maxMRUs):      for i in range(self._maxMRUs):
51        location = RuntimeSettings.get(self.runtime_section, "%s" % i, None)        location = RuntimeSettings.get(self.runtime_section, "%s" % i, None)
52        if location is None:        if location is None:
53          break          break
54        self._locations.append (location)        self._locations.append (location)
55        
56      self._refreshMenuList()      self._refreshMenuList()
57    
58    
# Line 77  class MRUManager: Line 77  class MRUManager:
77    
78    def _refreshMenuList(self):    def _refreshMenuList(self):
79      # This figures out the common prefix of all the forms and reduces appropriately.      # This figures out the common prefix of all the forms and reduces appropriately.
80      # i.e., if you have /usr/home/me/form1.gfd, /usr/home/you/form2.gfd then      # i.e., if you have /usr/home/me/form1.gfd, /usr/home/you/form2.gfd then
81      # this will reduce to me/form1.gfd and you/form2.gfd.. This is to keep the      # this will reduce to me/form1.gfd and you/form2.gfd.. This is to keep the
82      # MRU menu list from being too wide!      # MRU menu list from being too wide!
83    
84      commonpos=len(os.path.commonprefix(      commonpos=len(os.path.commonprefix(
85         map(lambda x: os.path.join(os.path.split(x)[0],''),self._locations)))         map(lambda x: os.path.join(os.path.split(x)[0],''),self._locations)))
86    
87      if commonpos > 2:      if commonpos > 2:
88        self.menulist = map(lambda x, pos=commonpos: x[pos:], self._locations)        self.menulist = map(lambda x, pos=commonpos: x[pos:], self._locations)
89      else:      else:
90        self.menulist = self._locations[:]        self.menulist = self._locations[:]
91    
92      self.refreshMenus()      self.refreshMenus()
       
93    
94    def addMenu(self, menu, instance):  
95      def addMenu(self, menu, instance):
96      self._menus.append(menu)      self._menus.append(menu)
97      menu.__instance = instance      menu.__instance = instance
98      self.refreshMenu(menu)      self.refreshMenu(menu)
99    
100      def removeMenu(self, menu, instance):
101        self._menus.remove(menu)
102    
103    def refreshMenus(self):  
104      def refreshMenus(self):
105      map(self.refreshMenu, self._menus)      map(self.refreshMenu, self._menus)
106    
107    
108    def refreshMenu(self, menu):    def refreshMenu(self, menu):
109    
110      # Rid ourselves of old entries      # Rid ourselves of old entries
111      for i in menu.GetMenuItems():      for i in menu.GetMenuItems():
112        menu.Delete(i.GetId())        menu.Delete(i.GetId())
113    
114      i = 0      i = 0
115      for location in self.menulist:      for location in self.menulist:
116        tid = wx.wxNewId()        tid = wx.wxNewId()
117        menu.Append ( tid, '&%s %s' % (i+1, location),        menu.Append ( tid, '&%s %s' % (i+1, location),
118                      _('Open "%s" in a new window') % self._locations[i] )                      _('Open "%s" in a new window') % self._locations[i] )
119    
120        wx.EVT_MENU(menu.__instance, tid, self._app.OnOpenRecent)        wx.EVT_MENU(menu.__instance, tid, self._app.OnOpenRecent)
121        self.mruMenuMap[tid] = self._locations[i]        self.mruMenuMap[tid] = self._locations[i]
122        i += 1        i += 1
123    
124    
125    #    #
126    #  Used by RuntimeSettings    #  Used by RuntimeSettings
# Line 125  class MRUManager: Line 128  class MRUManager:
128    def saveRuntimeSettings(self):    def saveRuntimeSettings(self):
129      results = {}      results = {}
130    
131      for i in range(len(self._locations)):      for i in range(len(self._locations)):
132        results["%s" % i] = self._locations[i]        results["%s" % i] = self._locations[i]
133    
134      return ( self.runtime_section, results )      return ( self.runtime_section, results )
     
135    
136      
137    

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26