[omemo] Move ui files into gtk folder
This commit is contained in:
@@ -32,10 +32,10 @@ from urllib.parse import urlparse, urldefrag
|
|||||||
from io import BufferedWriter, FileIO, BytesIO
|
from io import BufferedWriter, FileIO, BytesIO
|
||||||
|
|
||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
from gajim import gtkgui_helpers
|
|
||||||
from gajim.common import app
|
from gajim.common import app
|
||||||
from gajim.common import configpaths
|
from gajim.common import configpaths
|
||||||
from gajim.dialogs import ErrorDialog, YesNoDialog
|
from gajim.gtk.dialogs import ErrorDialog, YesNoDialog
|
||||||
|
from omemo.gtk.progress import ProgressWindow
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
import certifi
|
import certifi
|
||||||
|
|
||||||
@@ -265,40 +265,6 @@ class Download:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class ProgressWindow:
|
|
||||||
def __init__(self, plugin, window, event):
|
|
||||||
self.plugin = plugin
|
|
||||||
self.event = event
|
|
||||||
self.xml = gtkgui_helpers.get_gtk_builder(
|
|
||||||
self.plugin.local_file_path('download_progress_dialog.ui'))
|
|
||||||
self.dialog = self.xml.get_object('progress_dialog')
|
|
||||||
self.dialog.set_transient_for(window)
|
|
||||||
self.label = self.xml.get_object('label')
|
|
||||||
self.progressbar = self.xml.get_object('progressbar')
|
|
||||||
self.progressbar.set_text("")
|
|
||||||
self.dialog.show_all()
|
|
||||||
self.xml.connect_signals(self)
|
|
||||||
self.seen = 0
|
|
||||||
|
|
||||||
def set_text(self, text):
|
|
||||||
self.label.set_markup('<big>%s</big>' % text)
|
|
||||||
return False
|
|
||||||
|
|
||||||
def update_progress(self, seen, total):
|
|
||||||
self.seen += seen
|
|
||||||
pct = (self.seen / float(total)) * 100.0
|
|
||||||
self.progressbar.set_fraction(self.seen / float(total))
|
|
||||||
self.progressbar.set_text(str(int(pct)) + "%")
|
|
||||||
return False
|
|
||||||
|
|
||||||
def close_dialog(self, *args):
|
|
||||||
self.dialog.destroy()
|
|
||||||
return False
|
|
||||||
|
|
||||||
def on_destroy(self, *args):
|
|
||||||
self.event.set()
|
|
||||||
|
|
||||||
|
|
||||||
class DownloadAbortedException(Exception):
|
class DownloadAbortedException(Exception):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return _('Download Aborted')
|
return _('Download Aborted')
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Copyright 2015 Bahtiar `kalkin-` Gadimov <bahtiar@gadimov.de>
|
Copyright 2015 Bahtiar `kalkin-` Gadimov <bahtiar@gadimov.de>
|
||||||
Copyright 2015 Daniel Gultsch <daniel@cgultsch.de>
|
Copyright 2015 Daniel Gultsch <daniel@cgultsch.de>
|
||||||
@@ -26,8 +24,12 @@ import os
|
|||||||
import textwrap
|
import textwrap
|
||||||
from enum import IntEnum, unique
|
from enum import IntEnum, unique
|
||||||
|
|
||||||
from gi.repository import Gtk, GdkPixbuf, Gdk
|
from gi.repository import GdkPixbuf
|
||||||
from axolotl.state.sessionrecord import SessionRecord
|
|
||||||
|
from gajim.common import app
|
||||||
|
from gajim.common import configpaths
|
||||||
|
from gajim.plugins.gui import GajimPluginConfigDialog
|
||||||
|
from gajim.plugins.helpers import get_builder
|
||||||
|
|
||||||
log = logging.getLogger('gajim.plugin_system.omemo')
|
log = logging.getLogger('gajim.plugin_system.omemo')
|
||||||
|
|
||||||
@@ -39,16 +41,6 @@ except ImportError as error:
|
|||||||
log.debug(error)
|
log.debug(error)
|
||||||
log.error('python-qrcode or dependencies of it are not available')
|
log.error('python-qrcode or dependencies of it are not available')
|
||||||
|
|
||||||
from gajim.common import app
|
|
||||||
from gajim.common import configpaths
|
|
||||||
from gajim.dialogs import YesNoDialog
|
|
||||||
from gajim.plugins.gui import GajimPluginConfigDialog
|
|
||||||
|
|
||||||
# Since Gajim 1.1.0 _() has to be imported
|
|
||||||
try:
|
|
||||||
from gajim.common.i18n import _
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
@unique
|
@unique
|
||||||
class State(IntEnum):
|
class State(IntEnum):
|
||||||
@@ -60,11 +52,11 @@ class State(IntEnum):
|
|||||||
class OMEMOConfigDialog(GajimPluginConfigDialog):
|
class OMEMOConfigDialog(GajimPluginConfigDialog):
|
||||||
def init(self):
|
def init(self):
|
||||||
# pylint: disable=attribute-defined-outside-init
|
# pylint: disable=attribute-defined-outside-init
|
||||||
self.GTK_BUILDER_FILE_PATH = \
|
path = self.plugin.local_file_path('gtk/config.ui')
|
||||||
self.plugin.local_file_path('config_dialog.ui')
|
self._ui = get_builder(path)
|
||||||
self.B = Gtk.Builder()
|
|
||||||
self.B.set_translation_domain('gajim_plugins')
|
image_path = self.plugin.local_file_path('omemo.png')
|
||||||
self.B.add_from_file(self.GTK_BUILDER_FILE_PATH)
|
self._ui.image.set_from_file(image_path)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.disabled_accounts = self.plugin.config['DISABLED_ACCOUNTS']
|
self.disabled_accounts = self.plugin.config['DISABLED_ACCOUNTS']
|
||||||
@@ -75,18 +67,18 @@ class OMEMOConfigDialog(GajimPluginConfigDialog):
|
|||||||
log.debug('Disabled Accounts:')
|
log.debug('Disabled Accounts:')
|
||||||
log.debug(self.disabled_accounts)
|
log.debug(self.disabled_accounts)
|
||||||
|
|
||||||
self.device_model = self.B.get_object('deviceid_store')
|
self.device_model = self._ui.get_object('deviceid_store')
|
||||||
|
|
||||||
self.disabled_acc_store = self.B.get_object('disabled_account_store')
|
self.disabled_acc_store = self._ui.get_object('disabled_account_store')
|
||||||
self.account_store = self.B.get_object('account_store')
|
self.account_store = self._ui.get_object('account_store')
|
||||||
|
|
||||||
self.active_acc_view = self.B.get_object('active_accounts_view')
|
self.active_acc_view = self._ui.get_object('active_accounts_view')
|
||||||
self.disabled_acc_view = self.B.get_object('disabled_accounts_view')
|
self.disabled_acc_view = self._ui.get_object('disabled_accounts_view')
|
||||||
|
|
||||||
box = self.get_content_area()
|
box = self.get_content_area()
|
||||||
box.pack_start(self.B.get_object('notebook1'), True, True, 0)
|
box.pack_start(self._ui.get_object('notebook1'), True, True, 0)
|
||||||
|
|
||||||
self.B.connect_signals(self)
|
self._ui.connect_signals(self)
|
||||||
|
|
||||||
self.plugin_active = False
|
self.plugin_active = False
|
||||||
|
|
||||||
@@ -119,10 +111,10 @@ class OMEMOConfigDialog(GajimPluginConfigDialog):
|
|||||||
if self.plugin_active is False:
|
if self.plugin_active is False:
|
||||||
return
|
return
|
||||||
if len(self.account_store) > 0:
|
if len(self.account_store) > 0:
|
||||||
self.B.get_object('account_combobox').set_active(0)
|
self._ui.get_object('account_combobox').set_active(0)
|
||||||
else:
|
else:
|
||||||
self.account_combobox_changed_cb(
|
self.account_combobox_changed_cb(
|
||||||
self.B.get_object('account_combobox'))
|
self._ui.get_object('account_combobox'))
|
||||||
|
|
||||||
def account_combobox_changed_cb(self, box, *args):
|
def account_combobox_changed_cb(self, box, *args):
|
||||||
self.update_context_list()
|
self.update_context_list()
|
||||||
@@ -177,7 +169,7 @@ class OMEMOConfigDialog(GajimPluginConfigDialog):
|
|||||||
self.update_account_combobox()
|
self.update_account_combobox()
|
||||||
|
|
||||||
def cleardevice_button_clicked_cb(self, button, *args):
|
def cleardevice_button_clicked_cb(self, button, *args):
|
||||||
active = self.B.get_object('account_combobox').get_active()
|
active = self._ui.get_object('account_combobox').get_active()
|
||||||
account = self.account_store[active][0]
|
account = self.account_store[active][0]
|
||||||
self.plugin.connections[account].clear_device_list()
|
self.plugin.connections[account].clear_device_list()
|
||||||
self.update_context_list()
|
self.update_context_list()
|
||||||
@@ -187,34 +179,34 @@ class OMEMOConfigDialog(GajimPluginConfigDialog):
|
|||||||
|
|
||||||
def update_context_list(self):
|
def update_context_list(self):
|
||||||
self.device_model.clear()
|
self.device_model.clear()
|
||||||
self.qrcode = self.B.get_object('qrcode')
|
self.qrcode = self._ui.get_object('qrcode')
|
||||||
self.qrinfo = self.B.get_object('qrinfo')
|
self.qrinfo = self._ui.get_object('qrinfo')
|
||||||
if len(self.account_store) == 0:
|
if len(self.account_store) == 0:
|
||||||
self.B.get_object('ID').set_markup('')
|
self._ui.get_object('ID').set_markup('')
|
||||||
self.B.get_object('fingerprint_label').set_markup('')
|
self._ui.get_object('fingerprint_label').set_markup('')
|
||||||
self.B.get_object('refresh').set_sensitive(False)
|
self._ui.get_object('refresh').set_sensitive(False)
|
||||||
self.B.get_object('cleardevice_button').set_sensitive(False)
|
self._ui.get_object('cleardevice_button').set_sensitive(False)
|
||||||
self.B.get_object('qrcode').clear()
|
self._ui.get_object('qrcode').clear()
|
||||||
return
|
return
|
||||||
active = self.B.get_object('account_combobox').get_active()
|
active = self._ui.get_object('account_combobox').get_active()
|
||||||
account = self.account_store[active][0]
|
account = self.account_store[active][0]
|
||||||
|
|
||||||
# Set buttons active
|
# Set buttons active
|
||||||
self.B.get_object('refresh').set_sensitive(True)
|
self._ui.get_object('refresh').set_sensitive(True)
|
||||||
if account == 'Local':
|
if account == 'Local':
|
||||||
self.B.get_object('cleardevice_button').set_sensitive(False)
|
self._ui.get_object('cleardevice_button').set_sensitive(False)
|
||||||
else:
|
else:
|
||||||
self.B.get_object('cleardevice_button').set_sensitive(True)
|
self._ui.get_object('cleardevice_button').set_sensitive(True)
|
||||||
|
|
||||||
# Set FPR Label and DeviceID
|
# Set FPR Label and DeviceID
|
||||||
state = self.plugin.get_omemo(account)
|
state = self.plugin.get_omemo(account)
|
||||||
deviceid = state.own_device_id
|
deviceid = state.own_device_id
|
||||||
self.B.get_object('ID').set_markup('<tt>%s</tt>' % deviceid)
|
self._ui.get_object('ID').set_markup('<tt>%s</tt>' % deviceid)
|
||||||
|
|
||||||
ownfpr = binascii.hexlify(state.store.getIdentityKeyPair()
|
ownfpr = binascii.hexlify(state.store.getIdentityKeyPair()
|
||||||
.getPublicKey().serialize()).decode('utf-8')
|
.getPublicKey().serialize()).decode('utf-8')
|
||||||
human_ownfpr = self.human_hash(ownfpr[2:])
|
human_ownfpr = self.human_hash(ownfpr[2:])
|
||||||
self.B.get_object('fingerprint_label').set_markup('<tt>%s</tt>'
|
self._ui.get_object('fingerprint_label').set_markup('<tt>%s</tt>'
|
||||||
% human_ownfpr)
|
% human_ownfpr)
|
||||||
|
|
||||||
# Set Device ID List
|
# Set Device ID List
|
||||||
@@ -229,12 +229,11 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage" id="image">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="tooltip_text">OMEMO</property>
|
<property name="tooltip_text">OMEMO</property>
|
||||||
<property name="valign">start</property>
|
<property name="valign">start</property>
|
||||||
<property name="pixbuf">omemo.png</property>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">0</property>
|
<property name="left_attach">0</property>
|
||||||
52
omemo/gtk/progress.py
Normal file
52
omemo/gtk/progress.py
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# Copyright (C) 2018 Philipp Hörist <philipp AT hoerist.com>
|
||||||
|
#
|
||||||
|
# This file is part of Gajim.
|
||||||
|
#
|
||||||
|
# Gajim 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.
|
||||||
|
#
|
||||||
|
# Gajim 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 Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from gajim.plugins.helpers import get_builder
|
||||||
|
|
||||||
|
|
||||||
|
class ProgressWindow:
|
||||||
|
def __init__(self, plugin, window, event):
|
||||||
|
self._plugin = plugin
|
||||||
|
self._event = event
|
||||||
|
|
||||||
|
path = self._plugin.local_file_path('gtk/progress.ui')
|
||||||
|
self._ui = get_builder(path)
|
||||||
|
self._ui.progress_dialog.set_transient_for(window)
|
||||||
|
self._ui.progressbar.set_text("")
|
||||||
|
self._ui.progress_dialog.show_all()
|
||||||
|
|
||||||
|
image_path = self._plugin.local_file_path('omemo.png')
|
||||||
|
self._ui.image.set_from_file(image_path)
|
||||||
|
self._ui.connect_signals(self)
|
||||||
|
self._seen = 0
|
||||||
|
|
||||||
|
def set_text(self, text):
|
||||||
|
self._ui.label.set_markup('<big>%s</big>' % text)
|
||||||
|
return False
|
||||||
|
|
||||||
|
def update_progress(self, seen, total):
|
||||||
|
self._seen += seen
|
||||||
|
pct = (self._seen / float(total)) * 100.0
|
||||||
|
self._ui.progressbar.set_fraction(self._seen / float(total))
|
||||||
|
self._ui.progressbar.set_text(str(int(pct)) + "%")
|
||||||
|
return False
|
||||||
|
|
||||||
|
def close_dialog(self, *args):
|
||||||
|
self._ui.progress_dialog.destroy()
|
||||||
|
return False
|
||||||
|
|
||||||
|
def on_destroy(self, *args):
|
||||||
|
self._event.set()
|
||||||
@@ -60,12 +60,11 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage" id="image">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="tooltip_text">OMEMO</property>
|
<property name="tooltip_text">OMEMO</property>
|
||||||
<property name="margin_right">6</property>
|
<property name="margin_right">6</property>
|
||||||
<property name="pixbuf">omemo.png</property>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@@ -38,6 +38,7 @@ from gajim.groupchat_control import GroupchatControl
|
|||||||
|
|
||||||
from omemo.xmpp import DevicelistPEP
|
from omemo.xmpp import DevicelistPEP
|
||||||
from omemo.gtk.key import KeyDialog
|
from omemo.gtk.key import KeyDialog
|
||||||
|
from omemo.gtk.config import OMEMOConfigDialog
|
||||||
|
|
||||||
CRYPTOGRAPHY_MISSING = 'You are missing Python-Cryptography'
|
CRYPTOGRAPHY_MISSING = 'You are missing Python-Cryptography'
|
||||||
AXOLOTL_MISSING = 'You are missing Python-Axolotl or use an outdated version'
|
AXOLOTL_MISSING = 'You are missing Python-Axolotl or use an outdated version'
|
||||||
@@ -69,7 +70,6 @@ except Exception as error:
|
|||||||
if not ERROR_MSG:
|
if not ERROR_MSG:
|
||||||
try:
|
try:
|
||||||
from omemo.omemo_connection import OMEMOConnection
|
from omemo.omemo_connection import OMEMOConnection
|
||||||
from omemo.ui import OMEMOConfigDialog
|
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
log.error(error)
|
log.error(error)
|
||||||
ERROR_MSG = 'Error: %s' % error
|
ERROR_MSG = 'Error: %s' % error
|
||||||
|
|||||||
Reference in New Issue
Block a user