コード例 #1
0
ファイル: addbox.py プロジェクト: afb/0install
		def update_details_page():
			blocker = slave.invoke_master(['get-feed-metadata', uri.get_text()])
			yield blocker
			tasks.check(blocker)
			feed = blocker.result

			about.set_text('%s - %s' % (feed['name'], feed['summary']))
			icon_path = feed['icon-path']
			from zeroinstall.gtkui import icon
			icon_pixbuf = icon.load_icon(icon_path)
			if icon_pixbuf:
				icon_widget.set_from_pixbuf(icon_pixbuf)

			feed_category = feed['category']
			if feed_category:
				i = 0
				for row in categories:
					if row.lower() == feed_category.lower():
						category.set_active(i)
						break
					i += 1
			self.window.set_response_sensitive(_RESPONSE_PREV, True)

			nb.next_page()
			dialog_next.set_property('visible', False)
			dialog_ok.set_property('visible', True)
			dialog_ok.grab_focus()
コード例 #2
0
ファイル: impl_list.py プロジェクト: afb/0install
	def set(new):
		try:
			blocker = slave.invoke_master(["set-impl-stability", impl_details['from-feed'], impl_details['id'], new])
			yield blocker
			tasks.check(blocker)
			from zeroinstall.gui import main
			main.recalculate()
		except Exception:
			logger.warning("set", exc_info = True)
			raise
コード例 #3
0
ファイル: properties.py プロジェクト: afb/0install
	def set_stability_policy(self):
		try:
			i = self.stability.get_active()
			if i == 0:
				new_stability = None
			else:
				new_stability = ['stable', 'testing', 'developer'][i-1]
			blocker = slave.invoke_master(["set-stability-policy", self.interface.uri, new_stability])
			yield blocker
			tasks.check(blocker)
			from zeroinstall.gui import main
			main.recalculate()
		except Exception as ex:
			warning("set_stability_policy", exc_info = ex)
コード例 #4
0
ファイル: addbox.py プロジェクト: afb/0install
		def finish():
			from . import xdgutils
			blocker = slave.invoke_master(['get-feed-metadata', uri.get_text()])
			yield blocker
			tasks.check(blocker)
			feed = blocker.result

			try:
				icon_path = feed['icon-path']
				xdgutils.add_to_menu(feed, icon_path, categories[category.get_active()])
			except SafeException as ex:
				box = gtk.MessageDialog(self.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, str(ex))
				box.run()
				box.destroy()
			else:
				self.window.destroy()
コード例 #5
0
ファイル: preferences.py プロジェクト: afb/0install
		def remove_key(fingerprint, domain):
			fetcher = slave.invoke_master(["untrust-key", fingerprint, domain])
			yield fetcher
			tasks.check(fetcher)
			trust.trust_db.ensure_uptodate()
			update_keys()
コード例 #6
0
ファイル: iface_browser.py プロジェクト: afb/0install
	def compile(self, interface, autocompile = True):
		blocker = slave.invoke_master(["gui-compile", interface.uri, autocompile])
		yield blocker
		tasks.check(blocker)
		from zeroinstall.gui import main
		main.recalculate()
コード例 #7
0
ファイル: iface_browser.py プロジェクト: afb/0install
	def get_icon(self, iface_uri):
		"""Get an icon for this interface. If the icon is in the cache, use that.
		If not, start a download. If we already started a download (successful or
		not) do nothing. Returns None if no icon is currently available."""
		try:
			# Try the in-memory cache
			return self.cached_icon[iface_uri]
		except KeyError:
			# Try the on-disk cache

			iface = self.config.iface_cache.get_interface(iface_uri)
			iconpath = self.config.iface_cache.get_icon_path(iface)

			if iconpath:
				icon = load_icon(iconpath, ICON_SIZE, ICON_SIZE)
				# (if icon is None, cache the fact that we can't load it)
				self.cached_icon[iface.uri] = icon
			else:
				icon = None

			# Download a new icon if we don't have one, or if the
			# user did a 'Refresh'
			if iconpath is None or self.update_icons:
				if self.config.network_use == model.network_offline:
					fetcher = None
				else:
					fetcher = slave.invoke_master(["download-icon", iface.uri])
				if fetcher:
					if iface.uri not in self.cached_icon:
						self.cached_icon[iface.uri] = None	# Only try once

					@tasks.async
					def update_display():
						yield fetcher
						try:
							tasks.check(fetcher)
							# Try to insert new icon into the cache
							# If it fails, we'll be left with None in the cached_icon so
							# we don't try again.
							iconpath = self.config.iface_cache.get_icon_path(iface)
							if iconpath:
								self.cached_icon[iface.uri] = load_icon(iconpath, ICON_SIZE, ICON_SIZE)
								self.build_tree()
							else:
								pass #warning("Failed to download icon for '%s'", iface)
						except download.DownloadAborted as ex:
							info("Icon download aborted: %s", ex)
							# Don't report further; the user knows they cancelled
						except download.DownloadError as ex:
							warning("Icon download failed: %s", ex)
							# Not worth showing a dialog box for this
						except Exception as ex:
							import traceback
							traceback.print_exc()
							self.config.handler.report_error(ex)
					update_display()
				# elif fetcher is None: don't store anything in cached_icon

			# Note: if no icon is available for downloading,
			# more attempts are made later.
			# It can happen that no icon is yet available because
			# the interface was not downloaded yet, in which case
			# it's desireable to try again once the interface is available
			return icon

		return None
コード例 #8
0
ファイル: applistbox.py プロジェクト: afb/0install
	def action_help(self, uri):
		from zeroinstall.cmd import slave
		slave.invoke_master(['show-help', uri])