def _on_right_down(self, event): def edit_function(): self._store_hit_info(event) for (menu_item, should_be_enabled_fn) in self.context_menu_items: menu_item.Enable(should_be_enabled_fn(self.last_hit_info)) self.PopupMenu(self.context_menu) safe_locking(self.parent, edit_function)
def edit_shortcuts(evt): def edit_function(): dialog = ShortcutsEditorDialog(self, self.shortcut_controller) dialog.ShowModal() dialog.Destroy() safe_locking(self, edit_function)
def open_duplicate_event_dialog_for_event(parent, db, handle_db_error, event): def create_dialog(): return DuplicateEventDialog(parent, db, event) def edit_function(): gui_utils.show_modal(create_dialog, handle_db_error) safe_locking(parent, edit_function)
def open_create_event_editor(parent, config, db, handle_db_error, start=None, end=None): def create_event_editor(): label = _("Create Event") return EditEventDialog(parent, config, label, db, start, end) def edit_function(): gui_utils.show_modal(create_event_editor, handle_db_error) safe_locking(parent, edit_function)
def preferences(evt): def edit_function(): dialog = PreferencesDialog(self, self.config) dialog.ShowModal() dialog.Destroy() safe_locking(self, edit_function)
def _mnu_file_import_on_click(self, menu): def open_import_dialog(): dialog = ImportEventsDialog(self.timeline, self) dialog.ShowModal() dialog.Destroy() safe_locking(self, open_import_dialog)
def _on_key_down(self, e): def edit_function(): self.controller.delete_selected_category() if self.GetFirstVisibleItem() is None: return if e.GetKeyCode() == wx.WXK_DELETE: safe_locking(self.parent, edit_function) e.Skip()
def _on_right_down(self, e): def edit_function(): (item, flags) = self.HitTest(e.GetPosition()) if item is not None: self.SelectItem(item, True) self._update_menu_enableness() self.PopupMenu(self.mnu) safe_locking(self.parent, edit_function)
def open_duplicate_event_dialog_for_event(edit_controller, parent, db, event): def create_dialog(): return DuplicateEventDialog(parent, db, event) def edit_function(): dialog = create_dialog() dialog.ShowModal() dialog.Destroy() safe_locking(edit_controller, edit_function)
def _context_menu_on_done_event(self, evt): def edit_function(): with self.timeline_canvas.GetDb().transaction("Mark events done"): for event in self.timeline_canvas.GetSelectedEvents(): if not event.is_container(): event.set_progress(100) event.save() self.timeline_canvas.ClearSelectedEvents() safe_locking(self._edit_controller, edit_function)
def open_create_event_editor(edit_controller, parent, config, db, start=None, end=None): def create_event_editor(): label = _("Create Event") return EditEventDialog(parent, config, label, db, start, end) def edit_function(): dialog = create_event_editor() dialog.ShowModal() dialog.Destroy() safe_locking(edit_controller, edit_function)
def open_event_editor_for(parent, config, db, handle_db_error, event): def create_event_editor(): if event.is_container(): title = _("Edit Container") return EditContainerDialog(parent, title, db, event) else: return EditEventDialog( parent, config, _("Edit Event"), db, event=event) def edit_function(): gui_utils.show_modal(create_event_editor, handle_db_error) safe_locking(parent, edit_function)
def open_event_editor_for(edit_controller, parent, config, db, event): def create_event_editor(): if event.is_container(): title = _("Edit Container") return EditContainerDialog(parent, title, db, event) else: return EditEventDialog( parent, config, _("Edit Event"), db, event=event) def edit_function(): dialog = create_event_editor() dialog.ShowModal() dialog.Destroy() safe_locking(edit_controller, edit_function)
def open_milestone_editor_for(edit_controller, parent, config, db, event=None): def create_milestone_editor(): if event is None: label = _("Create Milestone") else: label = _("Edit Milestone") return EditMilestoneDialog(parent, label, db, config, event) def edit_function(): dialog = create_milestone_editor() dialog.ShowModal() dialog.Destroy() safe_locking(edit_controller, edit_function)
def _delete_selected_events(self): selected_events = self.timeline_canvas.GetSelectedEvents() number_of_selected_events = len(selected_events) def edit_function(): if user_ack(): with self.timeline_canvas.GetDb().transaction("Delete events"): for event in selected_events: event.delete() self.timeline_canvas.ClearSelectedEvents() def user_ack(): if number_of_selected_events > 1: text = _("Are you sure you want to delete %d events?" % number_of_selected_events) else: text = _("Are you sure you want to delete this event?") return _ask_question(text) == wx.YES safe_locking(self._edit_controller, edit_function)
def _move_event_vertically(self, event, up=True): def edit_function(): (overlapping_event, direction) = self.timeline_canvas.GetClosestOverlappingEvent( event, up=up) if overlapping_event is None: pass elif direction > 0: self.timeline_canvas.GetDb().place_event_after_event( event, overlapping_event) else: self.timeline_canvas.GetDb().place_event_before_event( event, overlapping_event) # GetClosestOverlappingEvent inflates rectangles, so subsequent # calls do calculations on incorrect rectangles. A redraw # recalculates all rectangles. self.redraw_timeline() safe_locking(self._edit_controller, edit_function)
def _move_event_vertically(self, event, up=True): def edit_function(): ( overlapping_event, direction ) = self.timeline_canvas.GetClosestOverlappingEvent(event, up=up) if overlapping_event is None: pass elif direction > 0: self.timeline_canvas.GetDb().place_event_after_event( event, overlapping_event ) else: self.timeline_canvas.GetDb().place_event_before_event( event, overlapping_event ) # GetClosestOverlappingEvent inflates rectangles, so subsequent # calls do calculations on incorrect rectangles. A redraw # recalculates all rectangles. self.redraw_timeline() safe_locking(self._edit_controller, edit_function)
def redo(evt): safe_locking(self, self.timeline.redo)
def edit_eras(evt): def edit_function(): self._edit_eras() safe_locking(self, edit_function)
def undo(evt): safe_locking(self, self.timeline.undo)
def set_category_on_without(evt): def edit_function(): self._set_category() safe_locking(self, edit_function)
def edit_categories(evt): def edit_function(): self._edit_categories() safe_locking(self, edit_function)
def set_categoryon_selected(evt): def edit_function(): self._set_category_to_selected_events() safe_locking(self, edit_function)
def _on_left_doubleclick(self, event): def edit_function(): self._edit_category() safe_locking(self.parent, edit_function)
def compress(evt): safe_locking(self, self.timeline.compress)