Ejemplo n.º 1
0
	def __init__(self, policy, widgets, download_only, select_only = False):
		self.policy = policy
		self.select_only = select_only

		def update_ok_state():
			self.window.set_response_sensitive(gtk.RESPONSE_OK, policy.solver.ready)
			if policy.solver.ready and self.window.get_focus() is None:
				run_button.grab_focus()
		policy.watchers.append(update_ok_state)

		self.window = widgets.get_widget('main')
		self.window.set_default_size(gtk.gdk.screen_width() * 2 / 5, 300)

		self.progress = widgets.get_widget('progress')
		self.progress_area = widgets.get_widget('progress_area')
		self.comment = widgets.get_widget('comment')

		widgets.get_widget('stop').connect('clicked', lambda b: policy.handler.abort_all_downloads())

		self.refresh_button = widgets.get_widget('refresh')

		# Tree view
		self.browser = InterfaceBrowser(policy, widgets)

		prefs = widgets.get_widget('preferences')
		self.window.action_area.set_child_secondary(prefs, True)

		# Glade won't let me add this to the template!
		if select_only:
			run_button = dialog.MixedButton(_("_Select"), gtk.STOCK_EXECUTE, button = gtk.ToggleButton())
		elif download_only:
			run_button = dialog.MixedButton(_("_Download"), gtk.STOCK_EXECUTE, button = gtk.ToggleButton())
		else:
			run_button = dialog.MixedButton(_("_Run"), gtk.STOCK_EXECUTE, button = gtk.ToggleButton())
		self.window.add_action_widget(run_button, gtk.RESPONSE_OK)
		run_button.show_all()
		run_button.set_flags(gtk.CAN_DEFAULT)
		self.run_button = run_button

		run_button.grab_focus()

		def response(dialog, resp):
			if resp in (gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT):
				self.window.destroy()
				sys.exit(1)
			elif resp == gtk.RESPONSE_OK:
				if self.cancel_download_and_run:
					self.cancel_download_and_run.trigger()
				if run_button.get_active():
					self.cancel_download_and_run = tasks.Blocker("cancel downloads")
					self.download_and_run(run_button, self.cancel_download_and_run)
			elif resp == gtk.RESPONSE_HELP:
				gui_help.display()
			elif resp == SHOW_PREFERENCES:
				import preferences
				preferences.show_preferences(policy.config, notify_cb = lambda: policy.solve_with_downloads())
		self.window.connect('response', response)
		self.window.realize()	# Make busy pointer work, even with --systray
Ejemplo n.º 2
0
    def confirm_install(self, message):
        yield self._switch_to_main_window(
            _('Need to confirm installation of distribution packages'))

        from zeroinstall.injector.download import DownloadAborted
        import dialog
        import gtk
        box = gtk.MessageDialog(self.mainwindow.window,
                                gtk.DIALOG_DESTROY_WITH_PARENT,
                                gtk.MESSAGE_QUESTION, gtk.BUTTONS_CANCEL,
                                str(message))
        box.set_position(gtk.WIN_POS_CENTER)

        install = dialog.MixedButton(_('Install'), gtk.STOCK_OK)
        install.set_can_default(True)
        box.add_action_widget(install, gtk.RESPONSE_OK)
        install.show_all()
        box.set_default_response(gtk.RESPONSE_OK)
        box.show()

        response = dialog.DialogResponse(box)
        yield response
        box.destroy()

        if response.response != gtk.RESPONSE_OK:
            raise DownloadAborted()