Move History Sync Dialog into gtk module

This commit is contained in:
Philipp Hörist 2018-07-15 02:04:03 +02:00 committed by Philipp Hörist
parent ebbe06d587
commit dd664643bd
3 changed files with 38 additions and 21 deletions

View File

@ -27,7 +27,7 @@ from gajim import accounts_window
import gajim.plugins.gui
from gajim import history_window
from gajim import disco
from gajim.history_sync import HistorySyncAssistant
from gajim.gtk.history_sync import HistorySyncAssistant
from gajim.server_info import ServerInfoDialog
from gajim.gtk.mam_preferences import MamPreferences

View File

@ -1,17 +1,14 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2017 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, either version 3 of the License, or
# (at your option) any later version.
# 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
# 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
@ -25,8 +22,8 @@ from gi.repository import Gtk, GLib
from gajim.common import app
from gajim.common import ged
from gajim.gtkgui_helpers import get_icon_pixmap
from gajim.common.const import ArchiveState
from gajim.gtk.util import load_icon
log = logging.getLogger('gajim.c.message_archiving')
@ -40,7 +37,7 @@ class Pages(IntEnum):
class HistorySyncAssistant(Gtk.Assistant):
def __init__(self, account, parent):
Gtk.Assistant.__init__(self)
self.set_title(_('Synchronise History'))
# self.set_title(_('Synchronise History'))
self.set_resizable(False)
self.set_default_size(300, -1)
self.set_name('HistorySyncAssistant')
@ -103,10 +100,6 @@ class HistorySyncAssistant(Gtk.Assistant):
self.set_current_page(Pages.SUMMARY)
self.summary.nothing_to_do()
# if self.con.mam_query_ids:
# self.set_current_page(Pages.SUMMARY)
# self.summary.query_already_running()
self.show_all()
def hide_buttons(self):
@ -162,11 +155,13 @@ class HistorySyncAssistant(Gtk.Assistant):
self.set_current_page(Pages.SUMMARY)
self.summary.finished()
def _nec_mam_message_received(self, obj):
if obj.conn.name != self.account:
def _nec_mam_message_received(self, event):
if event.conn.name != self.account:
return
if obj.result.getAttr('queryid') != self.query_id:
result = event.stanza.getTag('result')
queryid = result.getAttr('queryid')
if queryid != self.query_id:
return
log.debug('received message')
@ -236,9 +231,8 @@ class DownloadHistoryPage(Gtk.Box):
self.count = 0
self.received = 0
pix = get_icon_pixmap('folder-download-symbolic', size=64)
image = Gtk.Image()
image.set_from_pixbuf(pix)
surface = load_icon('folder-download-symbolic', self, size=64)
image = Gtk.Image.new_from_surface(surface)
self.progress = Gtk.ProgressBar()
self.progress.set_show_text(True)
@ -304,7 +298,7 @@ class TimeOption(Gtk.Label):
super().__init__(label=label)
self.date = months
if months:
self.date = timedelta(days=30*months)
self.date = timedelta(days=30 * months)
def get_delta(self):
return self.date

View File

@ -14,13 +14,36 @@
import os
import sys
import logging
from gi.repository import Gtk
from gi.repository import GLib
import xml.etree.ElementTree as ET
from gajim.common import i18n
from gajim.common import configpaths
_icon_theme = Gtk.IconTheme.get_default()
_icon_theme.append_search_path(configpaths.get('ICONS'))
log = logging.getLogger('gajim.gtk.util')
def load_icon(icon_name, widget, size=16,
flags=Gtk.IconLookupFlags.FORCE_SIZE):
scale = widget.get_scale_factor()
if not scale:
log.warning('Could not determine scale factor')
scale = 1
try:
iconinfo = _icon_theme.lookup_icon_for_scale(
icon_name, size, scale, flags)
return iconinfo.load_surface(None)
except GLib.GError as e:
log.error('Unable to load icon %s: %s', icon_name, str(e))
def get_builder(file_name, widget=None):
file_path = os.path.join(configpaths.get('GUI'), file_name)