usb-creator-hackers team mailing list archive
-
usb-creator-hackers team
-
Mailing list archive
-
Message #00108
[Merge] lp:~evfool/usb-creator/unityprogress into lp:usb-creator
Robert Roth has proposed merging lp:~evfool/usb-creator/unityprogress into lp:usb-creator.
Requested reviews:
usb-creator hackers (usb-creator-hackers)
For more details, see:
https://code.launchpad.net/~evfool/usb-creator/unityprogress/+merge/65844
Added unity launcher API progressbar support to the installation progress. The progressbar is shown when the installation starts, is updated when the window progressbar is updated, and is hidden when the installation finishes or fails.
--
https://code.launchpad.net/~evfool/usb-creator/unityprogress/+merge/65844
Your team usb-creator hackers is requested to review the proposed merge of lp:~evfool/usb-creator/unityprogress into lp:usb-creator.
=== modified file 'usbcreator/frontends/gtk/frontend.py'
--- usbcreator/frontends/gtk/frontend.py 2011-05-19 16:58:02 +0000
+++ usbcreator/frontends/gtk/frontend.py 2011-06-24 22:56:01 +0000
@@ -25,6 +25,7 @@
from gi.repository import Gtk
from usbcreator.frontends.base import Frontend
+from usbcreator.frontends.gtk.unitysupport import UnitySupport
from usbcreator.misc import *
if 'USBCREATOR_LOCAL' in os.environ:
@@ -156,7 +157,8 @@
selection.connect('changed', self.selection_changed_target)
self.backend.detect_devices()
-
+ # FIXME: instead of passing parent we really should just send signals
+ self.unity = UnitySupport(parent=self)
self.update_loop = self.add_timeout(2000, self.backend.update_free)
Gdk.threads_enter()
try:
@@ -605,6 +607,7 @@
if source and target:
self.install_window.show()
self.window.hide()
+ self.unity.show_progress()
self.delete_timeout(self.update_loop)
try:
self.backend.install(source, target, persist,
@@ -621,6 +624,7 @@
if complete > 100:
complete = 100
self.progress_bar.set_fraction(complete / 100.0)
+ self.unity.set_progress(complete / 100.0)
if remaining and speed:
# TODO evand 2009-07-24: Could use a time formatting function
# like our human size function.
@@ -674,6 +678,7 @@
# FIXME: evand 2009-07-28: Do we need this?
self.warning_dialog.hide()
self.install_window.hide()
+ self.unity.show_progress(False)
if not message:
message = _('Installation failed.')
self.failed_dialog_label.set_text(message)
@@ -685,6 +690,7 @@
self.backend.unmount()
self.warning_dialog.hide()
self.install_window.hide()
+ self.unity.show_progress(False)
try:
import dbus
bus = dbus.SystemBus()
=== added file 'usbcreator/frontends/gtk/unitysupport.py'
--- usbcreator/frontends/gtk/unitysupport.py 1970-01-01 00:00:00 +0000
+++ usbcreator/frontends/gtk/unitysupport.py 2011-06-24 22:56:01 +0000
@@ -0,0 +1,57 @@
+# UnitySupport.py
+#
+# Copyright (c) 2011 Canonical
+#
+# Author: Robert Roth <robert.roth.off@xxxxxxxxx>
+# Bilal Akhtar <bilalakhtar@xxxxxxxxxx>
+#
+# This program 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 2 of the
+# License, or (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA
+
+import logging
+
+HAVE_UNITY_SUPPORT=False
+try:
+ from gi.repository import Unity
+ HAVE_UNITY_SUPPORT=True
+except ImportError as e:
+ logging.warn("can not import unity GI %s" % e)
+
+class IUnitySupport(object):
+ """ interface for unity support """
+ def __init__(self, parent): pass
+ def set_progress(self, progress): pass
+ def show_progress(self, show=True): pass
+
+class UnitySupportImpl(IUnitySupport):
+ """ implementation of unity support (if unity is available) """
+
+ def __init__(self, parent):
+ # create launcher and quicklist
+ usbcreator_launcher_entry = Unity.LauncherEntry.get_for_desktop_id(
+ "usb-creator-gtk.desktop")
+ self._unity = usbcreator_launcher_entry
+
+ def set_progress(self, progress):
+ self._unity.set_property("progress", progress)
+ def show_progress(self, show=True):
+ self._unity.set_property("progress_visible", show)
+
+# check what to export to the clients
+if HAVE_UNITY_SUPPORT:
+ UnitySupport = UnitySupportImpl
+else:
+ # we just provide the empty interface
+ UnitySupport = IUnitySupport