def _on_document_added(self, model, idx, content): view = View() view.show() lang = self._language_manager.get_language("gobject-creator") buf = Buffer(language=lang) buf.set_highlight_syntax(True) view.set_buffer(buf) view.set_auto_indent(True) view.set_show_line_numbers(Settings.get().show_line_numbers) font_desc = pango.FontDescription(Settings.get().font_name) view.modify_font(font_desc) doc_container = gtk.ScrolledWindow() doc_container.show() doc_container.add(view) hbox = gtk.HBox() hbox.show() label = gtk.Label("") label.show() hbox.pack_start(label) close_button = gtk.Button() image = gtk.Image() image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU) close_button.set_image(image) close_button.set_relief(gtk.RELIEF_NONE) close_button.show() hbox.pack_start(close_button) self._notebook.insert_page(doc_container, hbox, idx ) self._notebook.set_current_page(idx) view.connect("button_press_event", self._on_button_pressed ) close_button.connect( "clicked", self._on_close_button_clicked ) buf = view.get_buffer() buf.connect( "changed", self._on_buffer_changed ) self._set_document_title(idx) buf.set_text(content)
def __init__(self, model): self._model = model self._model.connect( "document-added", self._on_document_added ) self._model.connect( "document-refreshed", self._on_document_refreshed ) self._model.connect( "document-changed", self._on_document_changed ) Settings.get().connect("settings-changed", self._on_settings_changed ) self._language_manager = LanguageManager() language_path = os.path.dirname(__file__) language_path = os.path.abspath(language_path) language_path += os.sep + "resources" search_path = self._language_manager.get_search_path() search_path.insert(0, language_path) self._language_manager.set_search_path(search_path) self._notebook = gtk.Notebook() self._notebook.set_property("scrollable", True) self._clipboard = gtk.Clipboard() self._popup = None self._create_popup_menu() self._num_new_docs = 0
def __init__(self, app): super().__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.model = Model(self, Item(), Column()) self.ui.treeView.setModel(self.model) self.ui.treeView.setItemDelegate(Delegate()) self.ui.treeView.customContextMenuRequested.connect(self.contextMenu) self.ui.actionAppendChild.triggered.connect(self.append_child) self.ui.actionDelete.triggered.connect(self.remove_items) self.ui.actionImportJSON.triggered.connect( lambda: ImporterJson(self).open()) self.ui.actionImportCSV.triggered.connect( lambda: ImporterCSV(self).exec()) self.ui.actionExportJSON.triggered.connect( lambda: ImporterJson(self).save()) self.ui.actionExportCSV.triggered.connect( lambda: ImporterCSV(self).save()) self.ui.actionSettings.triggered.connect(lambda: Settings(self).exec()) self.ui.actionOpen.triggered.connect(self.open) self.ui.actionSave.triggered.connect(self.save) self.ui.actionImpoertImage.triggered.connect( lambda: importer_image(self)) self.ui.toolButton.clicked.connect(self.append_child) self.ui.toolButton_2.clicked.connect(self.remove_items) self.ui.toolButton_3.clicked.connect(self.ui.treeView.expandAll) self.ui.toolButton_4.clicked.connect(self.search_and_replace) self.ui.treeView.clicked.connect(self.tree_view_clicked) self.partslist = { 'root_item': self.model.root(), 'pixmaps': {}, 'key_column': None, 'quantity_column': None }