diff --git a/gajim/data/gui/httpupload_progress_dialog.ui b/gajim/data/gui/httpupload_progress_dialog.ui index 2ee9d43b8..ce1c78969 100644 --- a/gajim/data/gui/httpupload_progress_dialog.ui +++ b/gajim/data/gui/httpupload_progress_dialog.ui @@ -1,29 +1,20 @@ - + - + + 300 True False + 18 vertical + 6 - + True False - 8 - 4 - 8 - 8 - - - True - False - - - - - - + document-send-symbolic + 6 False @@ -32,21 +23,14 @@ - + True False - 4 - 4 - 8 - 8 - - - True - False - 0.10000000149 - True - - + 6 + <placeholder> + False @@ -54,5 +38,52 @@ 1 + + + True + False + <progress> + + + + False + True + 2 + + + + + True + False + 6 + 0.10000000149 + + + False + True + 3 + + + + + Cancel Upload + True + True + True + center + 6 + + + + + False + True + 4 + + diff --git a/gajim/dialogs.py b/gajim/dialogs.py index bce1448fd..bd9ee693c 100644 --- a/gajim/dialogs.py +++ b/gajim/dialogs.py @@ -55,6 +55,7 @@ from gajim.common.exceptions import GajimGeneralException # Compat with Gajim 1.0.3 for plugins from gajim.gtk.dialogs import * from gajim.gtk.add_contact import AddNewContactWindow +from gajim.gtk.util import get_builder log = logging.getLogger('gajim.dialogs') @@ -1733,22 +1734,18 @@ class ProgressWindow(Gtk.ApplicationWindow): self.set_position(Gtk.WindowPosition.CENTER) self.set_show_menubar(False) self.set_title(_('File Transfer')) - self.set_default_size(250, -1) self.event = file.event self.file = file - self.xml = gtkgui_helpers.get_gtk_builder( - 'httpupload_progress_dialog.ui') + self._ui = get_builder('httpupload_progress_dialog.ui') - self.label = self.xml.get_object('label') - self.progressbar = self.xml.get_object('progressbar') - - self.add(self.xml.get_object('box')) + self.add(self._ui.box) self.pulse = GLib.timeout_add(100, self._pulse_progressbar) self.show_all() self.connect('destroy', self._on_destroy) + self._ui.connect_signals(self) app.ged.register_event_handler('httpupload-progress', ged.CORE, self._on_httpupload_progress) @@ -1756,20 +1753,23 @@ class ProgressWindow(Gtk.ApplicationWindow): if self.file != obj.file: return if obj.status == 'request': - self.label.set_text(_('Requesting HTTP Upload Slot…')) + self._ui.label.set_text(_('Requesting HTTP Upload Slot…')) elif obj.status == 'close': self.destroy() elif obj.status == 'upload': - self.label.set_text(_('Uploading file via HTTP File Upload…')) + self._ui.label.set_text(_('Uploading file via HTTP File Upload…')) elif obj.status == 'update': self.update_progress(obj.seen, obj.total) elif obj.status == 'encrypt': - self.label.set_text(_('Encrypting file…')) + self._ui.label.set_text(_('Encrypting file…')) def _pulse_progressbar(self): - self.progressbar.pulse() + self._ui.progressbar.pulse() return True + def on_cancel_upload_button_clicked(self, widget): + self.destroy() + def _on_destroy(self, *args): self.event.set() if self.pulse: @@ -1783,6 +1783,9 @@ class ProgressWindow(Gtk.ApplicationWindow): if self.pulse: GLib.source_remove(self.pulse) self.pulse = None - pct = (float(seen) / total) * 100.0 - self.progressbar.set_fraction(float(seen) / total) - self.progressbar.set_text(str(int(pct)) + "%") + self._ui.progressbar.set_fraction(float(seen) / total) + size_total = round(total / (1024 * 1024), 1) + size_progress = round(seen / (1024 * 1024), 1) + self._ui.progress_label.set_text( + _('%(progress)s of %(total)s MiB sent') % \ + {'progress': str(size_progress), 'total': str(size_total)})