parent
3312ca6c29
commit
b32b0f4411
2 changed files with 50 additions and 31 deletions
|
@ -2,13 +2,14 @@
|
||||||
<!-- Generated with glade 3.22.1 -->
|
<!-- Generated with glade 3.22.1 -->
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.20"/>
|
<requires lib="gtk+" version="3.20"/>
|
||||||
<object class="GtkBox" id="box">
|
<object class="GtkGrid" id="grid">
|
||||||
<property name="width_request">300</property>
|
<property name="width_request">300</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="border_width">18</property>
|
<property name="border_width">18</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="row_spacing">6</property>
|
||||||
<property name="spacing">6</property>
|
<property name="column_spacing">12</property>
|
||||||
|
<property name="column_homogeneous">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -17,40 +18,32 @@
|
||||||
<property name="icon_size">6</property>
|
<property name="icon_size">6</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="left_attach">0</property>
|
||||||
<property name="fill">True</property>
|
<property name="top_attach">0</property>
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="label">
|
<object class="GtkLabel" id="file_name_label">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="margin_top">6</property>
|
<property name="label"><file name></property>
|
||||||
<property name="label"><placeholder></property>
|
|
||||||
<style>
|
|
||||||
<class name="bold"/>
|
|
||||||
</style>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="left_attach">0</property>
|
||||||
<property name="fill">True</property>
|
<property name="top_attach">2</property>
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="progress_label">
|
<object class="GtkLabel" id="progress_label">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="label"><progress></property>
|
|
||||||
<style>
|
<style>
|
||||||
<class name="dim-label"/>
|
<class name="dim-label"/>
|
||||||
</style>
|
</style>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="left_attach">0</property>
|
||||||
<property name="fill">True</property>
|
<property name="top_attach">3</property>
|
||||||
<property name="position">2</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
@ -61,9 +54,8 @@
|
||||||
<property name="pulse_step">0.10000000149</property>
|
<property name="pulse_step">0.10000000149</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="left_attach">0</property>
|
||||||
<property name="fill">True</property>
|
<property name="top_attach">4</property>
|
||||||
<property name="position">3</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
@ -80,9 +72,23 @@
|
||||||
</style>
|
</style>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="left_attach">0</property>
|
||||||
<property name="fill">True</property>
|
<property name="top_attach">5</property>
|
||||||
<property name="position">4</property>
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="margin_top">6</property>
|
||||||
|
<property name="label"><placeholder></property>
|
||||||
|
<style>
|
||||||
|
<class name="bold"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
@ -32,6 +32,7 @@ from typing import Tuple # pylint: disable=unused-import
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
import logging
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
from gi.repository import Gdk
|
from gi.repository import Gdk
|
||||||
|
@ -1588,8 +1589,11 @@ class ProgressWindow(Gtk.ApplicationWindow):
|
||||||
self.event = file.event
|
self.event = file.event
|
||||||
self.file = file
|
self.file = file
|
||||||
self._ui = get_builder('httpupload_progress_dialog.ui')
|
self._ui = get_builder('httpupload_progress_dialog.ui')
|
||||||
|
file_name = os.path.basename(file.path)
|
||||||
|
self._ui.file_name_label.set_text(file_name)
|
||||||
|
self._start_time = time.time()
|
||||||
|
|
||||||
self.add(self._ui.box)
|
self.add(self._ui.grid)
|
||||||
|
|
||||||
self.pulse = GLib.timeout_add(100, self._pulse_progressbar)
|
self.pulse = GLib.timeout_add(100, self._pulse_progressbar)
|
||||||
self.show_all()
|
self.show_all()
|
||||||
|
@ -1602,12 +1606,13 @@ class ProgressWindow(Gtk.ApplicationWindow):
|
||||||
def _on_httpupload_progress(self, obj):
|
def _on_httpupload_progress(self, obj):
|
||||||
if self.file != obj.file:
|
if self.file != obj.file:
|
||||||
return
|
return
|
||||||
|
|
||||||
if obj.status == 'request':
|
if obj.status == 'request':
|
||||||
self._ui.label.set_text(_('Requesting HTTP Upload Slot…'))
|
self._ui.label.set_text(_('Requesting HTTP File Upload Slot…'))
|
||||||
elif obj.status == 'close':
|
elif obj.status == 'close':
|
||||||
self.destroy()
|
self.destroy()
|
||||||
elif obj.status == 'upload':
|
elif obj.status == 'upload':
|
||||||
self._ui.label.set_text(_('Uploading file via HTTP File Upload…'))
|
self._ui.label.set_text(_('Uploading via HTTP File Upload…'))
|
||||||
elif obj.status == 'update':
|
elif obj.status == 'update':
|
||||||
self.update_progress(obj.seen, obj.total)
|
self.update_progress(obj.seen, obj.total)
|
||||||
elif obj.status == 'encrypt':
|
elif obj.status == 'encrypt':
|
||||||
|
@ -1633,9 +1638,17 @@ class ProgressWindow(Gtk.ApplicationWindow):
|
||||||
if self.pulse:
|
if self.pulse:
|
||||||
GLib.source_remove(self.pulse)
|
GLib.source_remove(self.pulse)
|
||||||
self.pulse = None
|
self.pulse = None
|
||||||
self._ui.progressbar.set_fraction(float(seen) / total)
|
|
||||||
size_total = round(total / (1024 * 1024), 1)
|
size_total = round(total / (1024 * 1024), 1)
|
||||||
size_progress = round(seen / (1024 * 1024), 1)
|
size_progress = round(seen / (1024 * 1024), 1)
|
||||||
|
|
||||||
|
time_now = time.time()
|
||||||
|
mbytes_sec = round(size_progress / (time_now - self._start_time), 1)
|
||||||
|
|
||||||
|
self._ui.progressbar.set_fraction(float(seen) / total)
|
||||||
|
|
||||||
self._ui.progress_label.set_text(
|
self._ui.progress_label.set_text(
|
||||||
_('%(progress)s of %(total)s MiB sent') % \
|
_('%(progress)s of %(total)s MiB sent (%(speed)s MiB/s)') % \
|
||||||
{'progress': str(size_progress), 'total': str(size_total)})
|
{'progress': str(size_progress),
|
||||||
|
'total': str(size_total),
|
||||||
|
'speed': str(mbytes_sec)})
|
||||||
|
|
Loading…
Add table
Reference in a new issue