diff options
author | lovetox <philipp@hoerist.com> | 2022-05-01 09:49:15 +0300 |
---|---|---|
committer | lovetox <philipp@hoerist.com> | 2022-05-06 19:20:51 +0300 |
commit | 5e39c7c2f1e4cc6d0211f6d8f9531af01ebdb594 (patch) | |
tree | ed259f348905247d2905672c7dc57f6a52c4511e | |
parent | 66f53f5022afe16f34387261e607b2da42bf8f2e (diff) |
[form_handler] Remove Plugin
Not compatible with 1.4 anymore
-rw-r--r-- | form_handler/__init__.py | 1 | ||||
-rw-r--r-- | form_handler/gtk/form.py | 72 | ||||
-rw-r--r-- | form_handler/gtk/util.py | 23 | ||||
-rw-r--r-- | form_handler/plugin.py | 97 |
4 files changed, 0 insertions, 193 deletions
diff --git a/form_handler/__init__.py b/form_handler/__init__.py deleted file mode 100644 index 8876e6e..0000000 --- a/form_handler/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from form_handler.plugin import FormHandlerPlugin
\ No newline at end of file diff --git a/form_handler/gtk/form.py b/form_handler/gtk/form.py deleted file mode 100644 index bc5e1a3..0000000 --- a/form_handler/gtk/form.py +++ /dev/null @@ -1,72 +0,0 @@ -# Copyright (C) 2018 Philipp Hörist <philipp AT hoerist.com> -# -# This file is part of Form Handler. -# -# Form Handler is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published -# by the Free Software Foundation; version 3 only. -# -# Form Handler is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Form Handler. If not, see <http://www.gnu.org/licenses/>. - -import nbxmpp -from nbxmpp.modules.dataforms import extend_form - -from gi.repository import Gtk - -from gajim.common import app -from gajim.common.structs import OutgoingMessage - -from gajim.gui.dataform import DataFormWidget - -from gajim.plugins.plugins_i18n import _ - - -class FormDialog(Gtk.ApplicationWindow): - def __init__(self, data): - Gtk.ApplicationWindow.__init__(self, title=_('Data Form')) - self.set_transient_for(app.window) - self.set_default_size(600, 400) - - self._account = data['account'] - self._client = app.get_client(self._account) - self._jid = data['jid'] - - self._form_widget = DataFormWidget( - extend_form(node=nbxmpp.Node(node=data['form']))) - box = Gtk.Box(orientation='vertical', spacing=12) - box.add(self._form_widget) - - button = Gtk.Button(label=data['submit-text']) - button.connect('clicked', self._on_send_clicked) - button.set_halign(Gtk.Align.END) - box.add(button) - - self.add(box) - self.show_all() - - def _on_send_clicked(self, _button): - form = self._form_widget.get_submit_form() - - contact = self._client.get_module('Contacts').get_contact(self._jid) - - message = OutgoingMessage(account=self._account, - contact=contact, - message=_('Form sent'), - type_='chat', - nodes=[form]) - - message.is_loggable = False - - app.connections[self._account].send_message(message) - - control = app.window.get_control(self._account, self._jid) - if control is None: - return - control.add_info_message(_('Form has successfully been sent')) - self.destroy() diff --git a/form_handler/gtk/util.py b/form_handler/gtk/util.py deleted file mode 100644 index 51420c5..0000000 --- a/form_handler/gtk/util.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (C) 2018 Philipp Hörist <philipp AT hoerist.com> -# -# This file is part of Form Handler. -# -# Form Handler is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published -# by the Free Software Foundation; version 3 only. -# -# Form Handler is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Form Handler. If not, see <http://www.gnu.org/licenses/>. - -from gi.repository import Gtk - - -def get_button(label, data, callback): - button = Gtk.Button(label=label) - button.connect('clicked', callback, data) - return button diff --git a/form_handler/plugin.py b/form_handler/plugin.py deleted file mode 100644 index a7094c8..0000000 --- a/form_handler/plugin.py +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright (C) 2018 Philipp Hörist <philipp AT hoerist.com> -# -# This file is part of Form Handler. -# -# Form Handler is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published -# by the Free Software Foundation; version 3 only. -# -# Form Handler is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Form Handler. If not, see <http://www.gnu.org/licenses/>. - -import logging - -from nbxmpp.modules.dataforms import extend_form -from nbxmpp.namespaces import Namespace - -from gajim.common import ged - -from gajim.plugins import GajimPlugin -from gajim.plugins.plugins_i18n import _ - -from form_handler.gtk.util import get_button -from form_handler.gtk.form import FormDialog - -log = logging.getLogger('gajim.p.form_handler') - - -class FormHandlerPlugin(GajimPlugin): - def init(self): - self.description = _('Lets the user display and answer forms attached ' - 'to messages.') - self.config_dialog = None - - self.events_handlers = { - 'message-received': (ged.CORE, self._on_message_received), - } - - self.gui_extension_points = { - 'print_real_text': (self._print_text, None), - } - - def _on_message_received(self, event): - form = event.stanza.getTag('x', namespace=Namespace.DATA) - if form is None: - return - - if form.getAttr('type') != 'form': - return - - data = self._parse_form(form) - - data['form'] = str(form) - data['jid'] = event.jid - - event.additional_data['form_handler'] = data - - @staticmethod - def _parse_form(form): - dataform = extend_form(node=form) - result = {} - try: - result['submit-text'] = dataform['submit-button-text'].value - except KeyError: - result['submit-text'] = _('Submit') - - try: - result['open-text'] = dataform['open-button-text'].value - except KeyError: - result['open-text'] = _('Open') - - return result - - def _print_text(self, tv, _real_text, _text_tags, _graphics, - iter_, additional_data): - if 'form_handler' not in additional_data: - return - - data = additional_data['form_handler'] - data['account'] = tv.account - - button = get_button(data['open-text'], data, self._show_form) - - buffer_ = tv.tv.get_buffer() - anchor = buffer_.create_child_anchor(iter_) - anchor.plaintext = '' - - button.show_all() - tv.tv.add_child_at_anchor(button, anchor) - - @staticmethod - def _show_form(_button, data): - FormDialog(data) |