Changeset 4270
- Timestamp:
- 03/04/09 22:12:47 (4 years ago)
- Files:
-
- 1 modified
-
trunk/umit/gui/MainWindow.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/umit/gui/MainWindow.py
r4269 r4270 363 363 364 364 # This is the default, minimal UI 365 365 366 self.default_ui = """<menubar> 366 367 <menu action='Scan'> … … 369 370 <menuitem action='Save Scan'/> 370 371 <menuitem action='Open Scan'/> 371 %(recentscans)s 372 <placeholder name='RecentScans'> 373 </placeholder> 372 374 <menuitem action='Quit'/> 373 375 </menu> … … 421 423 """ 422 424 423 self.get_recent_scans()424 425 425 self.main_action_group.add_actions(self.main_actions) 426 426 … … 431 431 self.ui_manager.insert_action_group(self.main_action_group, 0) 432 432 self.ui_manager.add_ui_from_string(self.default_ui) 433 433 434 self._rscans_actiongroup = gtk.ActionGroup('UIRecentScans') 435 self.ui_manager.insert_action_group(self._rscans_actiongroup, 1) 436 self._rscans_merge_id = 0 437 self.update_recent_scans() 438 434 439 self.schedctrl.ui_action = self.main_action_group.get_action( 435 440 'Sched Control') … … 699 704 raise 700 705 701 702 def get_recent_scans(self): 703 """Shows the most recent saved scans.""" 706 def update_recent_scans(self): 707 """Shows the most recent saved scans in the 'Scan' menu.""" 708 # clean previous recent scans listing, if any 709 if self._rscans_merge_id: 710 for action in self._rscans_actiongroup.list_actions(): 711 self._rscans_actiongroup.remove_action(action) 712 self.ui_manager.remove_ui(self._rscans_merge_id) 713 # ensure_update is used here so we can be sure that the 714 # UIManager updates our UI. Not doing so will cause 715 # new items in the recent scans listing to appear at the 716 # end of the current listing. 717 self.ui_manager.ensure_update() 718 704 719 r_scans = recent_scans.get_recent_scans_list() 720 rscans_ui = """ 721 <menubar> 722 <menu action='Scan'> 723 <placeholder name='RecentScans'> 724 %s 725 </placeholder> 726 </menu> 727 </menubar>""" 705 728 new_rscan_xml = '' 729 730 actions = [] 706 731 707 732 # Add the seven most recent saved scans to the menu. … … 718 743 new_rscan_xml += "<menuitem action='%s'/>\n" % \ 719 744 xml.sax.saxutils.escape(scan) 720 721 self.main_actions.append(new_rscan)722 else: 723 new_rscan_xml += "<separator />\n"724 725 self.default_ui %= {'recentscans': new_rscan_xml}745 actions.append(new_rscan) 746 new_rscan_xml += "<separator />\n" 747 748 self._rscans_actiongroup.add_actions(actions) 749 self._rscans_merge_id = self.ui_manager.add_ui_from_string( 750 rscans_ui % new_rscan_xml) 726 751 727 752 def _create_menubar(self): … … 1091 1116 recent_scans.add_recent_scan(saved_filename) 1092 1117 recent_scans.save() 1118 self.update_recent_scans() 1093 1119 1094 1120 else:
