class GtagsView(PidaView): """ Window wich shows the seach entry and update button for gtags """ key = 'gtags.list' label_text = _('Gtags') def create_ui(self): self._hbox = gtk.HBox(spacing=3) self._hbox.set_border_width(2) self.add_main_widget(self._hbox) self._vbox = gtk.VBox(spacing=3) self._hbox.pack_start(self._vbox) self.create_searchbar() self.create_list() self.create_progressbar() self.create_toolbar() self._hbox.show_all() def create_searchbar(self): h = gtk.HBox(spacing=3) h.set_border_width(2) # label l = gtk.Label() l.set_text(_('Pattern : ')) h.pack_start(l, expand=False) # pattern self._search = gtk.Entry() self._search.connect('changed', self._on_search_changed) self._search.set_sensitive(False) h.pack_start(self._search) # info self._info = gtk.Label() self._info.set_text('-') h.pack_start(self._info, expand=False) self._vbox.pack_start(h, expand=False) self._search.show_all() def create_toolbar(self): self._bar = gtk.VBox(spacing=1) self._refresh_button = create_mini_button( gtk.STOCK_REFRESH, _('Build TAGS database'), self._on_refresh_button_clicked) self._bar.pack_start(self._refresh_button, expand=False) self._hbox.pack_start(self._bar, expand=False) self._bar.show_all() def create_list(self): self._list = ObjectList([ Column('symbol', title=_('Symbol'), use_markup=True), Column('filename', title=_('Location'), use_markup=True), Column('dataline', title=_('Data'), use_markup=True), ]) self._scroll = gtk.ScrolledWindow() self._scroll.add(self._list) self._list.connect('item-double-clicked', self._on_list_double_click) self._vbox.pack_start(self._scroll) self._scroll.show_all() def create_progressbar(self): self._progressbar = gtk.ProgressBar() self._vbox.pack_start(self._progressbar, expand=False) self._progressbar.set_no_show_all(True) self._progressbar.hide() def update_progressbar(self, current, max): if max > 1: self._progressbar.set_fraction(float(current) / float(max)) def show_progressbar(self, show): self._progressbar.set_no_show_all(False) if show: self._progressbar.show() else: self._progressbar.hide() def add_item(self, item): self._list.append(item) #XXX: ngettext self._info.set_text('%d matches' % len(self._list)) def clear_items(self): self._list.clear() self._info.set_text('-') def activate(self, activate): self._search.set_sensitive(activate) self._list.set_sensitive(activate) def can_be_closed(self): self.svc.get_action('show_gtags').set_active(False) def _on_search_changed(self, w): self.svc.tag_search(self._search.get_text()) def _on_refresh_button_clicked(self, w): self.svc.build_db() def _on_list_double_click(self, o, w): file_name = os.path.join(self.svc._project.source_directory, w.file) self.svc.boss.cmd('buffer', 'open_file', file_name=file_name, line=int(w.line))