def __init__(self): self.choose_unique_old_alarms = None self.OLD_THRESHOLD = coreaux_api.get_extension_configuration("organism_alarms").get_int("old_alarms_threshold") self.databases = {} self._create_copy_table() core_api.bind_to_open_database_dirty(self._handle_open_database_dirty) core_api.bind_to_open_database(self._handle_open_database) core_api.bind_to_check_pending_changes(self._handle_check_pending_changes) core_api.bind_to_reset_modified_state(self._handle_reset_modified_state) # No need to bind to close_database, as specific filenames will be # deleted from self.databases in self._handle_history_clean core_api.bind_to_history_remove(self._handle_history_remove) core_api.bind_to_history_clean(self._handle_history_clean) # Do not bind directly to core_api.bind_to_deleted_item because it # would create a race hazard with organism.items.delete_item_rules, # which is bound to the same event organism_api.bind_to_delete_item_rules(self._handle_delete_item_rules) organism_api.bind_to_get_alarms(self._handle_get_alarms) organism_timer_api.bind_to_get_next_occurrences(self._handle_get_next_occurrences) organism_timer_api.bind_to_activate_occurrences_range(self._handle_activate_occurrences_range) organism_timer_api.bind_to_activate_old_occurrences(self._handle_activate_old_occurrences) organism_timer_api.bind_to_activate_occurrences(self._handle_activate_occurrences) if copypaste_api: copypaste_api.bind_to_copy_items(self._handle_copy_items) copypaste_api.bind_to_copy_item(self._handle_copy_item) copypaste_api.bind_to_paste_item(self._handle_paste_item) copypaste_api.bind_to_safe_paste_check(self._handle_safe_paste_check)
def __init__(self): self.open_panels = {} # No need to also bind to "save as" because it closes and opens the # database anyway, thus also closing the property tab if open core_api.bind_to_save_database(self._handle_save_database) core_api.bind_to_history_insert(self._handle_items_number) core_api.bind_to_history_remove(self._handle_items_number) core_api.bind_to_insert_item(self._handle_items_number) core_api.bind_to_deleted_item(self._handle_items_number) # No need to bind to pasting items databases.close_database_event.bind(self._handle_close_database)
def __init__(self): self.choose_unique_old_alarms = None self.OLD_THRESHOLD = coreaux_api.get_extension_configuration( 'organism_alarms').get_int('old_alarms_threshold') self.databases = {} self._create_copy_table() core_api.bind_to_open_database_dirty(self._handle_open_database_dirty) core_api.bind_to_open_database(self._handle_open_database) core_api.bind_to_check_pending_changes( self._handle_check_pending_changes) core_api.bind_to_reset_modified_state( self._handle_reset_modified_state) # No need to bind to close_database, as specific filenames will be # deleted from self.databases in self._handle_history_clean core_api.bind_to_history_remove(self._handle_history_remove) core_api.bind_to_history_clean(self._handle_history_clean) # Do not bind directly to core_api.bind_to_deleted_item because it # would create a race hazard with organism.items.delete_item_rules, # which is bound to the same event organism_api.bind_to_delete_item_rules(self._handle_delete_item_rules) organism_api.bind_to_get_alarms(self._handle_get_alarms) organism_timer_api.bind_to_get_next_occurrences( self._handle_get_next_occurrences) organism_timer_api.bind_to_activate_occurrences_range( self._handle_activate_occurrences_range) organism_timer_api.bind_to_activate_old_occurrences( self._handle_activate_old_occurrences) organism_timer_api.bind_to_activate_occurrences( self._handle_activate_occurrences) if copypaste_api: copypaste_api.bind_to_copy_items(self._handle_copy_items) copypaste_api.bind_to_copy_item(self._handle_copy_item) copypaste_api.bind_to_paste_item(self._handle_paste_item) copypaste_api.bind_to_safe_paste_check( self._handle_safe_paste_check)
def _post_init(self): # The native GTK widget used by DataViewCtrl would have an internal # "live" search feature which steals some keyboard shortcuts: Ctrl+n, # Ctrl+p, Ctrl+f, Ctrl+a, Ctrl+Shift+a # https://groups.google.com/d/msg/wxpython-users/1sUPp766uXU/0J22mUrkzoAJ # Ctrl+f can be recovered with by not overriding the Model's # GetColumnType method # See also bug #349 # See bug #260 for generic issues about DataViewCtrl self.treec = dv.DataViewCtrl(self, style=dv.DV_MULTIPLE | dv.DV_NO_HEADER) self.cmenu = ContextMenu(self) self.ctabmenu = TabContextMenu(self.filename) self.logspanel = logs.LogsPanel(self, self.filename) self.dbhistory = logs.DatabaseHistory(self, self.logspanel, self.logspanel.get_panel(), self.filename, self.treec.GetBackgroundColour()) self.properties = Properties(self.treec) self.base_properties = DBProperties(self.properties) self.accelerators = {} creating_tree_event.signal(filename=self.filename) # Initialize the icons only *after* the various plugins have added # their properties self.properties.post_init() # Initialize the tree only *after* instantiating the class (and # initilizing the icons), because actions like the creation of item # images rely on the filename to be in the dictionary for row in core_api.get_all_items(self.filename): self._init_item_data(row["I_id"], row["I_text"]) self.dvmodel = Model(self.data, self.filename) self.treec.AssociateModel(self.dvmodel) # According to DataViewModel's documentation (as of September 2014) # its reference count must be decreased explicitly to avoid memory # leaks; the wxPython demo, however, doesn't do it, and if done here, # the application crashes with a segfault when closing all databases # See also bug #104 #self.dvmodel.DecRef() dvrenderer = Renderer(self, self.treec) dvcolumn = dv.DataViewColumn("Item", dvrenderer, 0, align=wx.ALIGN_LEFT) self.treec.AppendColumn(dvcolumn) self._init_accelerators() self.Initialize(self.treec) # Initialize the logs panel *after* signalling creating_tree_event, # which is used to add plugin logs self.logspanel.initialize() nb_left = wx.GetApp().nb_left nb_left.add_page(self, os.path.basename(self.filename), select=True) # The logs panel must be shown only *after* adding the page to the # notebook, otherwise *for*some*reason* the databases opened # automatically by the sessions manager (those opened manually aren't # affected) will have the sash of the SplitterWindow not correctly # positioned (only if using SetSashGravity) if wx.GetApp().logs_configuration.is_shown(): self.show_logs() self.history_item_update_requests = [] self.history_tree_reset_request = False # Explicitly set focus on the tree, otherwise after opening a database # no window has focus, and this e.g. prevents F10 from showing the menu # if set on autohide, until a window is manually focused (note that # this would happen only when opening a database manually, it wouldn't # happen when a database is opened automatically by the session # manager) self.treec.SetFocus() self.treec.Bind(dv.EVT_DATAVIEW_ITEM_CONTEXT_MENU, self._popup_item_menu) core_api.bind_to_insert_item(self._handle_insert_item) core_api.bind_to_update_item_text(self._handle_update_item_text) core_api.bind_to_deleting_item(self._handle_deleting_item) core_api.bind_to_deleted_item_2(self._handle_deleted_item) core_api.bind_to_history_insert(self._handle_history_insert) core_api.bind_to_history_update_simple( self._handle_history_update_simple) core_api.bind_to_history_update_deep(self._handle_history_update_deep) core_api.bind_to_history_update_text(self._handle_history_update_text) core_api.bind_to_history_remove(self._handle_history_remove) core_api.bind_to_history(self._handle_history)