gui.py :  » Installer » Zero-Install » zeroinstall-injector-0.47 » zeroinstall » 0launch-gui » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Installer » Zero Install 
Zero Install » zeroinstall injector 0.47 » zeroinstall » 0launch gui » gui.py
# Copyright (C) 2009, Thomas Leonard
# See the README file for details, or visit http://0install.net.

import gobject

from zeroinstall.support import tasks
from zeroinstall.injector import handler,download

version = '0.47'

class GUIHandler(handler.Handler):
  dl_callbacks = None    # Download -> [ callback ]
  pulse = None
  mainwindow = None

  def _reset_counters(self):
    if not self.monitored_downloads:
      self.n_completed_downloads = 0
      self.total_bytes_downloaded = 0
    return False

  def abort_all_downloads(self):
    for dl in self.monitored_downloads.values():
      dl.abort()

  def downloads_changed(self):
    if self.monitored_downloads and self.pulse is None:
      def pulse():
        self.mainwindow.update_download_status()
        return True
      pulse()
      self.pulse = gobject.timeout_add(200, pulse)
    elif len(self.monitored_downloads) == 0:
      # Delay before resetting, in case we start a new download quickly
      gobject.timeout_add(500, self._reset_counters)

      # Stop animation
      if self.pulse:
        gobject.source_remove(self.pulse)
        self.pulse = None
        self.mainwindow.update_download_status()
  
  def impl_added_to_store(self, impl):
    self.mainwindow.update_download_status()

  @tasks.async
  def confirm_import_feed(self, pending, valid_sigs):
    if self.mainwindow.systray_icon:
      self.mainwindow.systray_icon.set_tooltip(_('Need to confirm a new GPG key'))
      self.mainwindow.systray_icon.set_blinking(True)

      # Wait for the user to click the icon, then continue
      yield self.mainwindow.systray_icon_blocker
      yield tasks.TimeoutBlocker(0.5, 'Delay')

    from zeroinstall.gtkui import trust_box
    box = trust_box.TrustBox(pending, valid_sigs, parent = self.mainwindow.window)
    box.show()
    yield box.closed

  def report_error(self, ex, tb = None):
    if isinstance(ex, download.DownloadAborted):
      return    # No need to tell the user about this, since they caused it
    self.mainwindow.report_exception(ex)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.