def __init__(self, plugin, window): self._window = window self._plugin = plugin self._model = SettingsModel(self) self._model.load() self.completion = None self.id_name = 'AutoCompleteID' self.tip = Tip(self._window) self.words = {} self.dictionary_words = [] self.last_typed_line = None self.regex_completion = 0 l_ids = [] for signal in ('tab-added', 'tab-removed'): method = getattr(self, 'on_window_' + signal.replace('-', '_')) l_ids.append(window.connect(signal, method)) window.set_data(self.id_name, l_ids) for view in window.get_views(): self.connect_view(view) for doc in window.get_documents(): self.connect_document(doc) self.scan(doc)
def __init__(self, caller): self._plugin = caller self._model = SettingsModel(self) self._model.load() self.current_source = "" gtk.Dialog.__init__(self, "AutoComplete settings", None, gtk.DIALOG_DESTROY_WITH_PARENT) self.set_resizable(False) # Definitions source_label = gtk.Label("<b>Completion source:</b>") source_label.set_use_markup(True) source_label.set_justify(gtk.JUSTIFY_LEFT) self.mixed_radio = gtk.RadioButton(None, "Mixed") self.all_documents_radio = gtk.RadioButton(self.mixed_radio, "All documents") self.library_radio = gtk.RadioButton(self.mixed_radio, "Library") if self._model.get_source() == "ALL_DOCUMENTS": self.all_documents_radio.set_active(True) if self._model.get_source() == "LIBRARY": self.library_radio.set_active(True) self.mixed_radio.connect("toggled", self.source_change, "MIXED") self.all_documents_radio.connect("toggled", self.source_change, "ALL_DOCUMENTS") self.library_radio.connect("toggled", self.source_change, "LIBRARY") # Positioning option_a_box = gtk.HBox() option_b_box = gtk.HBox() option_c_box = gtk.HBox() option_a_box.pack_start(self.mixed_radio, False, False, 0) option_b_box.pack_start(self.all_documents_radio, False, False, 0) option_c_box.pack_start(self.library_radio, False, False, 0) self.vbox.pack_start(source_label, True, True, 10) self.vbox.pack_start(option_a_box, True, True, 0) self.vbox.pack_start(option_b_box, True, True, 0) self.vbox.pack_start(option_c_box, True, True, 0) # Buttons close_button = self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) close_button.grab_default() close_button.connect_object("clicked", gtk.Widget.destroy, self) help_button = self.add_button(gtk.STOCK_HELP, gtk.RESPONSE_HELP) help_button.connect_object("clicked", self.show_help_dialog, None) # Display self.vbox.show_all() self.show()