def load_document(self, doc_id: int) -> None: """Load :model:`Document` from storage with given `doc_id`. :param doc_id: id of the document to load :type doc_id: int :return: None """ self.document = storage.get(doc_id) self.buffer.set_text(self.document.content) self.buffer.end_not_undoable_action() self.buffer.set_modified(False) self.buffer.place_cursor(self.buffer.get_start_iter()) self.view.grab_focus()
def on_button_pressed(self, widget: Gtk.Widget, event: Gdk.EventButton): self.selected_path = self.view.get_path_at_pos(event.x, event.y) if not self.selected_path: self.selected_document = None return self.view.unselect_all() if event.button == Gdk.BUTTON_SECONDARY: self.view.select_path(self.selected_path) self.selected_document = storage.get( self.model.get_value(self.model.get_iter(self.selected_path), 3)) menu = DocumentContextMenu(self.view) menu.popup(None, None, None, None, event.button, event.time) return self.view.unselect_all() self.selected_document = None
def on_button_pressed(self, widget: Gtk.Widget, event: Gdk.EventButton): self.selected_path = self.view.get_path_at_pos(event.x, event.y) if not self.selected_path: self.selected_document = None self.view.unselect_all() return True if event.button == Gdk.BUTTON_SECONDARY: self.view.select_path(self.selected_path) self.selected_document = storage.get( self.model.get_value(self.model.get_iter(self.selected_path), 3)) found, rect = self.view.get_cell_rect(self.selected_path) builder = Gtk.Builder() builder.add_from_resource( '/com/github/tenderowl/norka/ui/documents_grid_context_menu.ui' ) menu_popover: Gtk.PopoverMenu = builder.get_object('popover-menu') find_child( menu_popover, "archive").set_visible(not self.selected_document.archived) find_child(menu_popover, "unarchive").set_visible( self.selected_document.archived) menu_popover.set_relative_to(self.view) menu_popover.set_pointing_to(rect) menu_popover.popup() return True self.view.unselect_all() self.selected_document = None