def _nec_search_form_received(self, obj): if self.pulse_id: GLib.source_remove(self.pulse_id) self.progressbar.hide() self.label.hide() if obj.is_dataform: self.is_form = True self.data_form_widget = dataforms_widget.DataFormWidget() self.dataform = dataforms.ExtendForm(node=obj.data) self.data_form_widget.set_sensitive(True) try: self.data_form_widget.data_form = self.dataform except dataforms.Error: self.label.set_text(_('Error in received dataform')) self.label.show() return if self.data_form_widget.title: self.window.set_title('%s - Search - Gajim' % \ self.data_form_widget.title) else: self.is_form = False self.data_form_widget = config.FakeDataForm(obj.data) self.data_form_widget.show_all() self.search_vbox.pack_start(self.data_form_widget, True, True, 0) self.search_button.set_sensitive(True)
def __init__(self, account, jid, session, form): self.account = account self.jid = jid self.form = form self.session = session self.xml = gtkgui_helpers.get_gtk_builder('data_form_window.ui', 'data_form_window') self.window = self.xml.get_object('data_form_window') config_vbox = self.xml.get_object('config_vbox') dataform = dataforms.ExtendForm(node=self.form) self.data_form_widget = dataforms_widget.DataFormWidget(dataform) self.data_form_widget.show() config_vbox.pack_start(self.data_form_widget, True, True, 0) self.xml.connect_signals(self) self.window.show_all()
def stage3_next_form(self, command): if not isinstance(command, nbxmpp.Node): self.stage5(error=_('Service sent malformed data'), senderror=True) return self.remove_pulsing() self.sending_form_progressbar.hide() if not self.sessionid: self.sessionid = command.getAttr('sessionid') elif self.sessionid != command.getAttr('sessionid'): self.stage5(error=_('Service changed the session identifier.'), senderror=True) return self.form_status = command.getAttr('status') self.commandnode = command.getAttr('node') if command.getTag('x'): self.dataform = dataforms.ExtendForm(node=command.getTag('x')) self.data_form_widget.set_sensitive(True) try: self.data_form_widget.selectable = True self.data_form_widget.data_form = self.dataform except dataforms.Error: self.stage5(error=_('Service sent malformed data'), senderror=True) return self.data_form_widget.show() if self.data_form_widget.title: self.window.set_title(_('%s - Ad-hoc Commands - Gajim') % \ self.data_form_widget.title) else: self.data_form_widget.hide() actions = command.getTag('actions') if actions: # actions, actions, actions... self.close_button.set_sensitive(True) self.back_button.set_sensitive(actions.getTag('prev') is not None) self.forward_button.set_sensitive( actions.getTag('next') is not None) self.execute_button.set_sensitive(True) self.finish_button.set_sensitive(actions.getTag('complete') is not \ None) else: self.close_button.set_sensitive(True) self.back_button.set_sensitive(False) self.forward_button.set_sensitive(False) self.execute_button.set_sensitive(True) self.finish_button.set_sensitive(False) if self.form_status == 'completed': self.close_button.set_sensitive(True) self.back_button.hide() self.forward_button.hide() self.execute_button.hide() self.finish_button.hide() self.close_button.show() self.stage_window_delete_cb = self.stage3_close_button_clicked note = command.getTag('note') if note: self.notes_label.set_text(note.getData()) self.notes_label.set_no_show_all(False) self.notes_label.show() else: self.notes_label.set_no_show_all(True) self.notes_label.hide()
def _nec_search_result_received(self, obj): if self.pulse_id: GLib.source_remove(self.pulse_id) self.progressbar.hide() self.label.hide() if not obj.is_dataform: if not obj.data: self.label.set_text(_('No result')) self.label.show() return # We suppose all items have the same fields sw = Gtk.ScrolledWindow() sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.result_treeview = Gtk.TreeView() self.result_treeview.connect( 'cursor-changed', self.on_result_treeview_cursor_changed) sw.add(self.result_treeview) # Create model fieldtypes = [str] * len(obj.data[0]) model = Gtk.ListStore(*fieldtypes) # Copy data to model for item in obj.data: model.append(item.values()) # Create columns counter = 0 for field in obj.data[0].keys(): self.result_treeview.append_column( Gtk.TreeViewColumn(field, Gtk.CellRendererText(), text=counter)) if field == 'jid': self.jid_column = counter counter += 1 self.result_treeview.set_model(model) sw.show_all() self.search_vbox.pack_start(sw, True, True, 0) if self.jid_column > -1: self.add_contact_button.show() self.information_button.show() return self.dataform = dataforms.ExtendForm(node=obj.data) if len(self.dataform.items) == 0: # No result self.label.set_text(_('No result')) self.label.show() return self.data_form_widget.set_sensitive(True) try: self.data_form_widget.data_form = self.dataform except dataforms.Error: self.label.set_text(_('Error in received dataform')) self.label.show() return self.result_treeview = self.data_form_widget.records_treeview selection = self.result_treeview.get_selection() selection.set_mode(Gtk.SelectionMode.SINGLE) self.result_treeview.connect('cursor-changed', self.on_result_treeview_cursor_changed) counter = 0 for field in self.dataform.reported.iter_fields(): if field.var == 'jid': self.jid_column = counter break counter += 1 self.search_vbox.pack_start(self.data_form_widget, True, True, 0) self.data_form_widget.show() if self.jid_column > -1: self.add_contact_button.show() self.information_button.show() if self.data_form_widget.title: self.window.set_title('%s - Search - Gajim' % \ self.data_form_widget.title)