2007-09-16 Don Allingham <don@gramps-project.org>
* src/DataViews/_EventView.py: connect column editor * src/ViewManager.py: pylint * src/Editors/_EditLdsOrd.py: pylint * src/DisplayTabs/_LdsModel.py: pylint * src/DisplayState.py: pylint * src/GrampsDbUtils/_GedcomParse.py: pylint * src/ListModel.py: pylint * src/LdsUtils.py: pylint * src/PageView.py: fix column editor svn: r8982
This commit is contained in:
		
							
								
								
									
										11
									
								
								ChangeLog
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								ChangeLog
									
									
									
									
									
								
							| @@ -1,3 +1,14 @@ | ||||
| 2007-09-16  Don Allingham  <don@gramps-project.org> | ||||
| 	* src/DataViews/_EventView.py: connect column editor | ||||
| 	* src/ViewManager.py: pylint | ||||
| 	* src/Editors/_EditLdsOrd.py: pylint | ||||
| 	* src/DisplayTabs/_LdsModel.py: pylint | ||||
| 	* src/DisplayState.py: pylint | ||||
| 	* src/GrampsDbUtils/_GedcomParse.py: pylint | ||||
| 	* src/ListModel.py: pylint | ||||
| 	* src/LdsUtils.py: pylint | ||||
| 	* src/PageView.py: fix column editor | ||||
|  | ||||
| 2007-09-16  Benny Malengier  <benny.malengier@gramps-project.org> | ||||
| 	* src/DisplayModels/_BaseModel.py: Add comments | ||||
| 	* src/DisplayModels/_NoteModel.py: Only show unattached notes in note view | ||||
|   | ||||
| @@ -169,6 +169,8 @@ class EventView(PageView.ListView): | ||||
|         PageView.ListView.define_actions(self) | ||||
|         self._add_action('FilterEdit', None, _('Event Filter Editor'), | ||||
|                         callback=self.filter_editor,) | ||||
|         self._add_action('_Column Editor', None, _('_Column Editor'), | ||||
|                         callback=self._column_editor,) | ||||
|  | ||||
|     def get_handle_from_gramps_id(self, gid): | ||||
|         obj = self.dbstate.db.get_event_from_gramps_id(gid) | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
| # the Free Software Foundation; either version 2 of the License, or | ||||
| # (at your option) any later version. | ||||
| # | ||||
| # This program is distributed in the hope that it will be useful, | ||||
| # This program is distributed in the hope that it will be useful,  | ||||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| # GNU General Public License for more details. | ||||
| @@ -64,35 +64,37 @@ DISABLED = -1 | ||||
| # | ||||
| #------------------------------------------------------------------------- | ||||
| class History(GrampsDb.GrampsDBCallback): | ||||
|     """ History manages the objects of a certain type that have been viewed, | ||||
|     """ History manages the objects of a certain type that have been viewed,  | ||||
|         with ability to go back, or forward.  | ||||
|         When accessing an object, it should be pushed on the History. | ||||
|     """ | ||||
|  | ||||
|     __signals__ = { | ||||
|         'changed'      : (list, ), | ||||
|         'menu-changed' : (list, ), | ||||
|         'changed'      : (list, ),  | ||||
|         'menu-changed' : (list, ),  | ||||
|         } | ||||
|  | ||||
|     def __init__(self): | ||||
|         GrampsDb.GrampsDBCallback.__init__(self) | ||||
|         self.history = [] | ||||
|         self.mhistory = [] | ||||
|         self.index = -1 | ||||
|         self.lock = False | ||||
|         self.clear() | ||||
|  | ||||
|     def clear(self): | ||||
|         """ | ||||
|         Cleares the history, resetting the values back to their defaults | ||||
|         """ | ||||
|         self.history = [] | ||||
|         self.mhistory = [] | ||||
|         self.index = -1 | ||||
|         self.lock = False | ||||
|  | ||||
|     def remove(self, person_handle, old_id=None): | ||||
|         """Removes a person from the history list""" | ||||
|     def remove(self, handle, old_id=None): | ||||
|         """ | ||||
|         Removes a handle from the history list | ||||
|         """ | ||||
|         if old_id: | ||||
|             del_id = old_id | ||||
|         else: | ||||
|             del_id = person_handle | ||||
|             del_id = handle | ||||
|  | ||||
|         history_count = self.history.count(del_id) | ||||
|         for c in range(history_count): | ||||
| @@ -105,38 +107,48 @@ class History(GrampsDb.GrampsDBCallback): | ||||
|         self.emit('changed', (self.history, )) | ||||
|         self.emit('menu-changed', (self.mhistory, )) | ||||
|  | ||||
|     def push(self, person_handle): | ||||
|     def push(self, handle): | ||||
|         """ | ||||
|         Pushes the handle on the history stack | ||||
|         """ | ||||
|         self.prune() | ||||
|         if len(self.history) == 0 or person_handle != self.history[-1]: | ||||
|             self.history.append(person_handle) | ||||
|             if person_handle in self.mhistory: | ||||
|                 self.mhistory.remove(person_handle) | ||||
|             self.mhistory.append(person_handle) | ||||
|         if len(self.history) == 0 or handle != self.history[-1]: | ||||
|             self.history.append(handle) | ||||
|             if handle in self.mhistory: | ||||
|                 self.mhistory.remove(handle) | ||||
|             self.mhistory.append(handle) | ||||
|             self.index += 1 | ||||
|         self.emit('menu-changed', (self.mhistory, )) | ||||
|         self.emit('changed', (self.history, )) | ||||
|  | ||||
|     def forward(self, step=1): | ||||
|         """ | ||||
|         Moves forward in the history list | ||||
|         """ | ||||
|         self.index += step | ||||
|         person_handle = self.history[self.index] | ||||
|         if person_handle not in self.mhistory: | ||||
|             self.mhistory.append(person_handle) | ||||
|         handle = self.history[self.index] | ||||
|         if handle not in self.mhistory: | ||||
|             self.mhistory.append(handle) | ||||
|             self.emit('menu-changed', (self.mhistory, )) | ||||
|         return str(self.history[self.index]) | ||||
|  | ||||
|     def back(self, step=1): | ||||
|         """ | ||||
|         Moves backward in the history list | ||||
|         """ | ||||
|         self.index -= step | ||||
|         try: | ||||
|             person_handle = self.history[self.index] | ||||
|             if person_handle not in self.mhistory: | ||||
|                 self.mhistory.append(person_handle) | ||||
|             handle = self.history[self.index] | ||||
|             if handle not in self.mhistory: | ||||
|                 self.mhistory.append(handle) | ||||
|                 self.emit('menu-changed', (self.mhistory, )) | ||||
|             return str(self.history[self.index]) | ||||
|         except IndexError: | ||||
|             return u"" | ||||
|          | ||||
|     def present(self): | ||||
|         '''return the person handle that is now active in the history | ||||
|         ''' | ||||
|         return the person handle that is now active in the history | ||||
|         ''' | ||||
|         try : | ||||
|             if self.history : | ||||
| @@ -147,12 +159,21 @@ class History(GrampsDb.GrampsDBCallback): | ||||
|             return u"" | ||||
|          | ||||
|     def at_end(self): | ||||
|         """ | ||||
|         returns True if we are at the end of the history list | ||||
|         """ | ||||
|         return self.index+1 == len(self.history) | ||||
|  | ||||
|     def at_front(self): | ||||
|         """ | ||||
|         returns True if we are at the front of the history list | ||||
|         """ | ||||
|         return self.index <= 0 | ||||
|  | ||||
|     def prune(self): | ||||
|         """ | ||||
|         Truncates the history list at the current object. | ||||
|         """ | ||||
|         if not self.at_end(): | ||||
|             self.history = self.history[0:self.index+1] | ||||
|  | ||||
| @@ -206,7 +227,7 @@ class RecentDocsMenu: | ||||
|                 filename = os.path.basename(item.get_path()) | ||||
|                 action_id = "RecentMenu%d" % count | ||||
|                 buf.write('<menuitem action="%s"/>' % action_id) | ||||
|                 actions.append((action_id, None, title, None, None, | ||||
|                 actions.append((action_id, None, title, None, None,  | ||||
|                                 make_callback(item, self.load))) | ||||
|                 mitem = gtk.MenuItem(title) | ||||
|                 mitem.connect('activate', make_callback(item, self.load)) | ||||
| @@ -272,10 +293,10 @@ class WarnHandler(RotateHandler): | ||||
| class DisplayState(GrampsDb.GrampsDBCallback): | ||||
|  | ||||
|     __signals__ = { | ||||
|         'filters-changed' : (str, ), | ||||
|         'filter-name-changed' : (str,unicode,unicode), | ||||
|         'nameformat-changed' : None, | ||||
|         'plugins-reloaded' : (list, list), | ||||
|         'filters-changed' : (str, ),  | ||||
|         'filter-name-changed' : (str, unicode, unicode),  | ||||
|         'nameformat-changed' : None,  | ||||
|         'plugins-reloaded' : (list, list),  | ||||
|         } | ||||
|  | ||||
|     def __init__(self, window, status, progress, warnbtn, uimanager,  | ||||
| @@ -302,7 +323,7 @@ class DisplayState(GrampsDb.GrampsDBCallback): | ||||
|         self.rhandler.setLevel(logging.WARNING) | ||||
|         self.log = logging.getLogger() | ||||
|         self.log.addHandler(self.rhandler) | ||||
|         # This call has been moved one level up, | ||||
|         # This call has been moved one level up,  | ||||
|         # but this connection is still made! | ||||
|         # self.dbstate.connect('database-changed', self.db_changed) | ||||
|  | ||||
| @@ -320,7 +341,7 @@ class DisplayState(GrampsDb.GrampsDBCallback): | ||||
|  | ||||
|         pname = name_displayer.display(default_person) | ||||
|         (name, plist) = self.relationship.get_relationship( | ||||
|             dbstate.db,default_person,active) | ||||
|             dbstate.db, default_person, active) | ||||
|  | ||||
|         if name: | ||||
|             if plist == None: | ||||
| @@ -330,7 +351,7 @@ class DisplayState(GrampsDb.GrampsDBCallback): | ||||
|         else: | ||||
|             return u"" | ||||
|  | ||||
|     def clear_history(self,handle=None): | ||||
|     def clear_history(self, handle=None): | ||||
|         '''Clear the history. If handle is given, then the history is  | ||||
|             immediately initialized with a first entry  | ||||
|             (you'd eg want active person you view there as History contains the  | ||||
| @@ -403,13 +424,3 @@ class DisplayState(GrampsDb.GrampsDBCallback): | ||||
|         self.status.push(self.status_id, text) | ||||
|         while gtk.events_pending(): | ||||
|             gtk.main_iteration() | ||||
|  | ||||
|  | ||||
| if __name__ == "__main__": | ||||
|  | ||||
|     import GrampsWidgets | ||||
|      | ||||
|     rhandler = WarnHandler(capacity=400, button=GrampsWidgets.WarnButton()) | ||||
|     _LOG = logging.getLogger() | ||||
|     _LOG.setLevel(logging.WARN) | ||||
|     _LOG.addHandler(rhandler) | ||||
|   | ||||
| @@ -60,7 +60,7 @@ class LdsModel(gtk.ListStore): | ||||
|                 lds_ord.type2str(),  | ||||
|                 DateHandler.get_date(lds_ord),  | ||||
|                 lds_ord.status2str(),  | ||||
|                 LdsUtils.Temples.name(lds_ord.get_temple()), | ||||
|                 LdsUtils.TEMPLES.name(lds_ord.get_temple()), | ||||
|                 self.column_place(lds_ord),  | ||||
|                 lds_ord,  | ||||
|                 ]) | ||||
|   | ||||
| @@ -206,7 +206,7 @@ class EditLdsOrd(EditSecondary): | ||||
|             self.top.get_widget('temple'), | ||||
|             self.obj.set_temple, | ||||
|             self.obj.get_temple, | ||||
|             LdsUtils.Temples.name_code_data(), | ||||
|             LdsUtils.TEMPLES.name_code_data(), | ||||
|             self.db.readonly) | ||||
|  | ||||
|         self.status_menu = MonitoredMenu( | ||||
| @@ -387,7 +387,7 @@ class EditFamilyLdsOrd(EditSecondary): | ||||
|             self.top.get_widget('temple'), | ||||
|             self.obj.set_temple, | ||||
|             self.obj.get_temple, | ||||
|             LdsUtils.Temples.name_code_data(), | ||||
|             LdsUtils.TEMPLES.name_code_data(), | ||||
|             self.db.readonly) | ||||
|  | ||||
|         self.status_menu = MonitoredMenu( | ||||
|   | ||||
| @@ -4392,10 +4392,10 @@ class GedcomParser(UpdateCallback): | ||||
|  | ||||
|     def __extract_temple(self, line): | ||||
|         def get_code(code): | ||||
|             if LdsUtils.Temples.is_valid_code(code): | ||||
|             if LdsUtils.TEMPLES.is_valid_code(code): | ||||
|                 return code | ||||
|             elif LdsUtils.Temples.is_valid_name(code): | ||||
|                 return LdsUtils.Temples.code(code) | ||||
|             elif LdsUtils.TEMPLES.is_valid_name(code): | ||||
|                 return LdsUtils.TEMPLES.code(code) | ||||
|          | ||||
|         code = get_code(line.data) | ||||
|         if code:  | ||||
|   | ||||
| @@ -120,5 +120,5 @@ class LdsTemples: | ||||
|         """ | ||||
|         self.__tlist.append(data) | ||||
|  | ||||
| Temples = LdsTemples() | ||||
| TEMPLES = LdsTemples() | ||||
|  | ||||
|   | ||||
| @@ -50,6 +50,9 @@ NOSORT = -1 | ||||
| # | ||||
| #------------------------------------------------------------------------- | ||||
| class ListModel: | ||||
|     """ | ||||
|     Simple model for lists in smaller dialogs (not DataViews). | ||||
|     """ | ||||
|  | ||||
|     def __init__(self, tree, dlist, select_func=None, event_func=None,  | ||||
|                  mode=gtk.SELECTION_SINGLE): | ||||
| @@ -240,6 +243,9 @@ class ListModel: | ||||
|             return -1 | ||||
|  | ||||
|     def get_selected_objects(self): | ||||
|         """ | ||||
|         Returns the list of selected objects in the list | ||||
|         """ | ||||
|         if self.count == 0: | ||||
|             return [] | ||||
|         elif self.mode == gtk.SELECTION_SINGLE: | ||||
| @@ -250,44 +256,72 @@ class ListModel: | ||||
|                 return [] | ||||
|         else: | ||||
|             mlist = [] | ||||
|             self.selection.selected_foreach(self.blist, mlist) | ||||
|             self.selection.selected_foreach(self.__build_select_list, mlist) | ||||
|             return mlist | ||||
|  | ||||
|     def get_icon(self): | ||||
|         """ | ||||
|         Returns an icond to be used for Drag and drop. | ||||
|         """ | ||||
|         if self.mode == gtk.SELECTION_SINGLE: | ||||
|             store, node = self.selection.get_selected() | ||||
|             path = self.model.get_path(node) | ||||
|         else: | ||||
|             mlist = [] | ||||
|             self.selection.selected_foreach(self.blist, mlist) | ||||
|             self.selection.selected_foreach(self.__build_select_list, mlist) | ||||
|             path = self.model.get_path(mlist[0]) | ||||
|         return self.tree.create_row_drag_icon(path) | ||||
|  | ||||
|     def blist(self, store, path, node, dlist): | ||||
|     def __build_select_list(self, store, path, node, dlist): | ||||
|         """ | ||||
|         GTK callback function for waliking a select list | ||||
|         """ | ||||
|         dlist.append(self.model.get_value(node, self.data_index)) | ||||
|  | ||||
|     def clear(self): | ||||
|         """ | ||||
|         Clears all data in the list | ||||
|         """ | ||||
|         self.count = 0 | ||||
|         self.model.clear() | ||||
|  | ||||
|     def remove(self, node): | ||||
|         """ | ||||
|         Removes the item from the model | ||||
|         """ | ||||
|         self.model.remove(node) | ||||
|         self.count -= 1 | ||||
|          | ||||
|     def get_row(self, node): | ||||
|         """ | ||||
|         Returns the row associated with the selected node | ||||
|         """ | ||||
|         row = self.model.get_path(node) | ||||
|         return row[0] | ||||
|  | ||||
|     def select_row(self, row): | ||||
|         """ | ||||
|         Selects the item based on path | ||||
|         """ | ||||
|         self.selection.select_path((row)) | ||||
|  | ||||
|     def select_iter(self, node): | ||||
|         """ | ||||
|         Selects the item based on iter | ||||
|         """ | ||||
|         self.selection.select_iter(node) | ||||
|      | ||||
|     def get_object(self, node): | ||||
|         """ | ||||
|         Returns the object associated with the node. This is controlled | ||||
|         by extracting the data from the associated data index | ||||
|         """ | ||||
|         return self.model.get_value(node, self.data_index) | ||||
|          | ||||
|     def insert(self, position, data, info=None, select=0): | ||||
|         """ | ||||
|         Inserts the item at the specified position in the model. | ||||
|         """ | ||||
|         self.count += 1 | ||||
|         node = self.model.insert(position) | ||||
|         col = 0 | ||||
| @@ -302,9 +336,15 @@ class ListModel: | ||||
|         return node | ||||
|      | ||||
|     def get_data(self, node, cols): | ||||
|         """ | ||||
|         Returns a list of data from the model associated with the node | ||||
|         """ | ||||
|         return [ self.model.get_value(node, c) for c in cols ] | ||||
|      | ||||
|     def add(self, data, info=None, select=0): | ||||
|         """ | ||||
|         Adds the data to the model at the end of the model | ||||
|         """ | ||||
|         self.count += 1 | ||||
|         node = self.model.append() | ||||
|         col = 0 | ||||
| @@ -320,6 +360,10 @@ class ListModel: | ||||
|         return node | ||||
|  | ||||
|     def set(self, node, data, info=None, select=0): | ||||
|         """ | ||||
|         Changes the data associated with the specific node. It does not | ||||
|         add any data, just alters an existing row. | ||||
|         """ | ||||
|         col = 0 | ||||
|         for obj in data: | ||||
|             self.model.set_value(node, col, obj) | ||||
| @@ -331,24 +375,6 @@ class ListModel: | ||||
|             self.sel_iter = node | ||||
|         return node | ||||
|  | ||||
|     def add_and_select(self, data, info=None): | ||||
|         self.count += 1 | ||||
|         node = self.model.append() | ||||
|         col = 0 | ||||
|         for obj in data: | ||||
|             self.model.set_value(node, col, obj) | ||||
|             col += 1 | ||||
|         if info: | ||||
|             self.idmap[str(info)] = node | ||||
|         self.model.set_value(node, col, info) | ||||
|         self.selection.select_iter(node) | ||||
|  | ||||
|     def center_selected(self): | ||||
|         model, node = self.selection.get_selected() | ||||
|         if node: | ||||
|             path = model.get_path(node) | ||||
|             self.tree.scroll_to_cell(path, None, True, 0.5, 0.5) | ||||
|          | ||||
|     def __button_press(self, obj, event): | ||||
|         """ | ||||
|         Called when a button press is executed | ||||
| @@ -359,6 +385,9 @@ class ListModel: | ||||
|         return False | ||||
|  | ||||
|     def find(self, info): | ||||
|         """ | ||||
|         Selects the item associated with the pass information. | ||||
|         """ | ||||
|         if info in self.idmap.keys(): | ||||
|             node = self.idmap[str(info)] | ||||
|             self.selection.select_iter(node) | ||||
|   | ||||
| @@ -921,8 +921,6 @@ class ListView(BookMarkView): | ||||
| 		 self.ADD_MSG, self.add),  | ||||
|                 ('Remove', gtk.STOCK_REMOVE, _("_Remove"), "<control>Delete",  | ||||
| 		 self.DEL_MSG, self.remove),  | ||||
|                 ('ColumnEdit', gtk.STOCK_PROPERTIES, _('_Column Editor'),  | ||||
| 		 None, None, self._column_editor),  | ||||
|                 ('ExportTab', None, _('Export view'), None, None, self.export),  | ||||
|                 ]) | ||||
|  | ||||
| @@ -941,7 +939,7 @@ class ListView(BookMarkView): | ||||
|         Causes the View to display a column editor. This should be overridden | ||||
|         by any class that provides columns (such as a list based view) | ||||
|         """ | ||||
|         return | ||||
|         raise NotImplemented | ||||
|  | ||||
|     def _button_press(self, obj, event): | ||||
|         from QuickReports import create_quickreport_menu | ||||
|   | ||||
| @@ -218,14 +218,23 @@ class ViewManager: | ||||
|     """ | ||||
|  | ||||
|     def __init__(self, state): | ||||
|  | ||||
|         self.page_is_changing = False | ||||
|         self.state = state | ||||
|         self.active_page = None | ||||
|         self.views = [] | ||||
|         self.pages = [] | ||||
|         self.button_handlers = [] | ||||
|         self.buttons = [] | ||||
|         self.merge_ids = [] | ||||
|         self.tips = gtk.Tooltips() | ||||
|         self._key = None | ||||
|         self.file_loaded = False | ||||
|  | ||||
|         self.show_sidebar = Config.get(Config.VIEW) | ||||
|         self.show_toolbar = Config.get(Config.TOOLBAR_ON) | ||||
|         self.show_filter = Config.get(Config.FILTER) | ||||
|  | ||||
|         self.__build_main_window() | ||||
|         self.__connect_signals() | ||||
|         self.__do_load_plugins() | ||||
| @@ -248,16 +257,10 @@ class ViewManager: | ||||
|         hbox = gtk.HBox() | ||||
|         self.ebox = gtk.EventBox() | ||||
|         self.bbox = gtk.VBox() | ||||
|         self.buttons = [] | ||||
|         self.button_handlers = [] | ||||
|         self.ebox.add(self.bbox) | ||||
|         hbox.pack_start(self.ebox, False) | ||||
|         hbox.show_all() | ||||
|  | ||||
|         self.show_sidebar = Config.get(Config.VIEW) | ||||
|         self.show_toolbar = Config.get(Config.TOOLBAR_ON) | ||||
|         self.show_filter = Config.get(Config.FILTER) | ||||
|  | ||||
|         self.notebook = gtk.Notebook() | ||||
|         self.notebook.set_show_tabs(False) | ||||
|         self.notebook.show() | ||||
| @@ -296,7 +299,7 @@ class ViewManager: | ||||
|         self._navigation_type[PageView.NAVIGATION_PERSON] = (self.person_nav,  | ||||
|                                                              None) | ||||
|         self.recent_manager = DisplayState.RecentDocsMenu( | ||||
|             self.uistate, self.state, self.read_recent_file) | ||||
|             self.uistate, self.state, self.__read_recent_file) | ||||
|         self.recent_manager.build() | ||||
|  | ||||
|         self.db_loader = DbLoader(self.state, self.uistate) | ||||
| @@ -413,7 +416,7 @@ class ViewManager: | ||||
|  | ||||
|         self._readonly_action_list = [ | ||||
|             ('SaveAs', gtk.STOCK_SAVE_AS, _('_Save As'), "<control><shift>s",  | ||||
|              None, self.save_as_activate),  | ||||
|              None, self.__save_as_activate),  | ||||
|             ('Export', 'gramps-export', _('_Export'), "<control>e", None,  | ||||
|              self.export_data),  | ||||
|             ('Abandon', gtk.STOCK_REVERT_TO_SAVED,  | ||||
| @@ -453,7 +456,6 @@ class ViewManager: | ||||
|             ('Tools', 'gramps-tools', _('_Tools'), None,  | ||||
|              _("Open the tools dialog"), self.tools_clicked),  | ||||
|             ('EditMenu', None, _('_Edit')),  | ||||
|             ('ColumnEdit', gtk.STOCK_PROPERTIES, _('_Column Editor')),  | ||||
|             ('BookMenu', None, _('_Bookmarks')),  | ||||
|             ('ToolsMenu', None, _('_Tools')),  | ||||
|             ] | ||||
| @@ -496,7 +498,7 @@ class ViewManager: | ||||
|         name = action.get_name() | ||||
|         try: | ||||
|             self.active_page.call_function(name) | ||||
|         except: | ||||
|         except Exception: | ||||
|             self.uistate.push_message(self.state,  | ||||
|                                       _("Key %s is not bound") % name) | ||||
|  | ||||
| @@ -674,7 +676,6 @@ class ViewManager: | ||||
|         """ | ||||
|         Builds the UIManager, and the associated action groups | ||||
|         """ | ||||
|         self.merge_ids = [] | ||||
|         self.uimanager = gtk.UIManager() | ||||
|  | ||||
|         accelgroup = self.uimanager.get_accel_group() | ||||
| @@ -1032,7 +1033,7 @@ class ViewManager: | ||||
|             self.read_file(filename, 'x-directory/normal') | ||||
|             try: | ||||
|                 os.chdir(os.path.dirname(filename)) | ||||
|             except: | ||||
|             except (IOError, OSError): | ||||
|                 pass | ||||
|             self.__post_load_newdb(filename, 'x-directory/normal', title) | ||||
|  | ||||
| @@ -1089,7 +1090,7 @@ class ViewManager: | ||||
|             self.state.db.set_save_path(filename) | ||||
|             try: | ||||
|                 os.chdir(os.path.dirname(filename)) | ||||
|             except: | ||||
|             except (OSError, IOError): | ||||
|                 print "could not change directory" | ||||
|         except Errors.DbError, msg: | ||||
|             QuestionDialog.DBErrorDialog(str(msg.value)) | ||||
| @@ -1099,7 +1100,7 @@ class ViewManager: | ||||
|  | ||||
|         return True | ||||
|  | ||||
|     def save_as_activate(self, obj): | ||||
|     def __save_as_activate(self, obj): | ||||
|         """ | ||||
|         Called when the SaveAs button is clicked | ||||
|         """ | ||||
| @@ -1107,7 +1108,7 @@ class ViewManager: | ||||
|             (filename, filetype) = self.db_loader.save_as() | ||||
|             self.__post_load_newdb(filename, filetype) | ||||
|  | ||||
|     def read_recent_file(self, filename): | ||||
|     def __read_recent_file(self, filename): | ||||
|         """ | ||||
|         Called when the recent file is loaded | ||||
|         """ | ||||
| @@ -1136,17 +1137,19 @@ class ViewManager: | ||||
|             self.uistate.clear_history(None) | ||||
|         self.uistate.progress.hide() | ||||
|  | ||||
|         self.state.db.undo_callback = self.change_undo_label | ||||
|         self.state.db.redo_callback = self.change_redo_label | ||||
|         self.change_undo_label(None) | ||||
|         self.change_redo_label(None) | ||||
|         self.state.db.undo_callback = self.__change_undo_label | ||||
|         self.state.db.redo_callback = self.__change_redo_label | ||||
|         self.__change_undo_label(None) | ||||
|         self.__change_redo_label(None) | ||||
|         self.state.db.undo_history_callback = self.undo_history_update | ||||
|         self.undo_history_close() | ||||
|  | ||||
|         self.uistate.window.window.set_cursor(None) | ||||
|  | ||||
|     def __post_load_newdb(self, filename, filetype, title=None): | ||||
|  | ||||
|         """ | ||||
|         Called after a new database is loaded. | ||||
|         """ | ||||
|         if not filename: | ||||
|             return | ||||
|  | ||||
| @@ -1206,7 +1209,7 @@ class ViewManager: | ||||
|         # Call common __post_load | ||||
|         self.__post_load() | ||||
|  | ||||
|     def change_undo_label(self, label): | ||||
|     def __change_undo_label(self, label): | ||||
|         """ | ||||
|         Changes the UNDO label | ||||
|         """ | ||||
| @@ -1222,7 +1225,7 @@ class ViewManager: | ||||
|             self.undoactions.set_sensitive(False) | ||||
|         self.uimanager.insert_action_group(self.undoactions, 1) | ||||
|  | ||||
|     def change_redo_label(self, label): | ||||
|     def __change_redo_label(self, label): | ||||
|         """ | ||||
|         Changes the REDO label | ||||
|         """ | ||||
| @@ -1371,11 +1374,11 @@ class ViewManager: | ||||
|         Builds a new tools menu | ||||
|         """ | ||||
|         self.toolactions = gtk.ActionGroup('ToolWindow') | ||||
|         (ui, actions) = self.build_plugin_menu( | ||||
|         (uidef, actions) = self.build_plugin_menu( | ||||
|             'ToolsMenu', tool_menu_list, Tool.tool_categories,  | ||||
|             make_tool_callback) | ||||
|         self.toolactions.add_actions(actions) | ||||
|         self.uistate.uimanager.add_ui_from_string(ui) | ||||
|         self.uistate.uimanager.add_ui_from_string(uidef) | ||||
|         self.uimanager.insert_action_group(self.toolactions, 1) | ||||
|         self.uistate.uimanager.ensure_update() | ||||
|      | ||||
| @@ -1384,11 +1387,11 @@ class ViewManager: | ||||
|         Builds a new reports menu | ||||
|         """ | ||||
|         self.reportactions = gtk.ActionGroup('ReportWindow') | ||||
|         (ui, actions) = self.build_plugin_menu( | ||||
|         (uidef, actions) = self.build_plugin_menu( | ||||
|             'ReportsMenu', report_menu_list, ReportBase.standalone_categories,  | ||||
|             make_report_callback) | ||||
|         self.reportactions.add_actions(actions) | ||||
|         self.uistate.uimanager.add_ui_from_string(ui) | ||||
|         self.uistate.uimanager.add_ui_from_string(uidef) | ||||
|         self.uimanager.insert_action_group(self.reportactions, 1) | ||||
|         self.uistate.uimanager.ensure_update() | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user