~jshholland/ubuntu/lucid/aptdaemon/fix-beginn

« back to all changes in this revision

Viewing changes to aptdaemon/gtkwidgets.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2010-01-04 12:59:14 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20100104125914-7q5k7uxv3142tbiw
Tags: 0.11+bzr322-0ubuntu1
* New git snapshot
* debian/patches/series:
  - add 01_unused_removal.patch to allow removal of no longer
    used dependencies on removal

Show diffs side-by-side

added added

removed removed

Lines of Context:
391
391
    Complete progress dialog for long taking aptdaemon transactions, which
392
392
    features a progress bar, cancel button, status icon and label
393
393
    """
 
394
 
 
395
    __gsignals__ = {"finished": (gobject.SIGNAL_RUN_FIRST,
 
396
                                 gobject.TYPE_NONE, ())}
 
397
 
394
398
    def __init__(self, transaction=None, parent=None, terminal=True,
395
399
                 debconf=True):
396
400
        gtk.Dialog.__init__(self, buttons=None, parent=parent)
436
440
        if transaction != None:
437
441
            self.set_transaction(transaction)
438
442
 
439
 
    def run(self, attach=False, close_on_finished=True, show_error=True):
 
443
    def run(self, attach=False, close_on_finished=True, show_error=True,
 
444
            reply_handler=None, error_handler=None):
440
445
        """Run the transaction and show the progress in the dialog.
441
446
 
442
447
        Keyword arguments:
446
451
                  transaction is complete
447
452
        show_error -- show a dialog with the error message
448
453
        """
 
454
        def reply():
 
455
            self.show_all()
 
456
            reply_handler()
 
457
        if reply_handler:
 
458
            _reply_handler=reply
 
459
        else:
 
460
            _reply_handler=None
449
461
        parent = self.get_transient_for()
450
462
        self._signals.append(self._transaction.connect("finished",
451
463
                                                       self._on_finished,
452
464
                                                       close_on_finished,
453
465
                                                       show_error))
454
466
        if attach:
455
 
            self._transaction.attach(error_handler=self._on_error,
456
 
                                     reply_handler=self._on_run)
 
467
            self._transaction.attach(error_handler=error_handler,
 
468
                                     reply_handler=_reply_handler)
457
469
        else:
458
 
            self._transaction.run(error_handler=self._on_error,
459
 
                                  reply_handler=self._on_run)
460
 
 
461
 
    def _on_error(self, error):
462
 
        """Stop the "emulated" loop of the progress dialog."""
463
 
        if error.get_dbus_name() != \
464
 
           "org.freedesktop.PolicyKit.Error.NotAuthorized":
465
 
            raise error
466
 
 
467
 
    def _on_run(self):
468
 
        """Show the dialog."""
469
 
        self.show_all()
 
470
            self._transaction.run(error_handler=error_handler,
 
471
                                  reply_handler=_reply_handler)
 
472
        if not reply_handler:
 
473
            self.show_all()
470
474
 
471
475
    def _on_role_changed(self, transaction, role_enum):
472
476
        """Show the role of the transaction in the dialog interface"""
532
536
            err_dia = AptErrorDialog(self._transaction.error, self)
533
537
            err_dia.run()
534
538
            err_dia.hide()
 
539
        self.emit("finished")
535
540
 
536
541
 
537
542
class _ExpandableDialog(gtk.Dialog):