Commit 74ed71f5 authored by Daniel Brötzmann's avatar Daniel Brötzmann Committed by Philipp Hörist

Rework HTTPUpload dialog

parent 760b94f2
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.1 -->
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.14"/>
<requires lib="gtk+" version="3.20"/>
<object class="GtkBox" id="box">
<property name="width_request">300</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">18</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkAlignment" id="alignment1">
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">8</property>
<property name="bottom_padding">4</property>
<property name="left_padding">8</property>
<property name="right_padding">8</property>
<child>
<object class="GtkLabel" id="label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="variant" value="normal"/>
</attributes>
</object>
</child>
<property name="icon_name">document-send-symbolic</property>
<property name="icon_size">6</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -32,21 +23,14 @@
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment2">
<object class="GtkLabel" id="label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">4</property>
<property name="bottom_padding">4</property>
<property name="left_padding">8</property>
<property name="right_padding">8</property>
<child>
<object class="GtkProgressBar" id="progressbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pulse_step">0.10000000149</property>
<property name="show_text">True</property>
</object>
</child>
<property name="margin_top">6</property>
<property name="label">&lt;placeholder&gt;</property>
<style>
<class name="bold"/>
</style>
</object>
<packing>
<property name="expand">False</property>
......@@ -54,5 +38,52 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="progress_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">&lt;progress&gt;</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkProgressBar" id="progressbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">6</property>
<property name="pulse_step">0.10000000149</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton" id="cancel_upload_button">
<property name="label" translatable="yes">Cancel Upload</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="margin_top">6</property>
<signal name="clicked" handler="on_cancel_upload_button_clicked" swapped="no"/>
<style>
<class name="destructive-action"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
</interface>
......@@ -1727,21 +1727,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 = get_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)
......@@ -1749,20 +1746,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:
......@@ -1776,6 +1776,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)})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment