Exemplo n.º 1
0
	def __init__(self, driver, interface, iface_name, compile, show_versions = False):
		self.driver = driver

		widgets = Template('interface_properties')

		self.interface = interface

		window = widgets.get_widget('interface_properties')
		self.window = window
		window.set_title(_('Properties for %s') % iface_name)
		window.set_default_size(-1, gtk.gdk.screen_height() / 3)

		self.compile_button = widgets.get_widget('compile')
		self.compile_button.connect('clicked', lambda b: compile(interface))
		window.set_default_response(gtk.RESPONSE_CANCEL)

		def response(dialog, resp):
			if resp == gtk.RESPONSE_CANCEL:
				window.destroy()
			elif resp == gtk.RESPONSE_HELP:
				properties_help.display()
		window.connect('response', response)

		notebook = widgets.get_widget('interface_notebook')
		assert notebook

		self.feeds = Feeds(driver.config, interface, widgets)

		stability = widgets.get_widget('preferred_stability')

		self.stability = stability
		stability.connect('changed', lambda *args: self.ignore_stability_change or self.set_stability_policy())

		self.use_list = ImplementationList(driver, interface, widgets)

		self.feeds.tv.grab_focus()

		window.connect('destroy', lambda s: driver.watchers.remove(self.update))
		driver.watchers.append(self.update)
		self.update()

		if show_versions:
			notebook.next_page()
Exemplo n.º 2
0
	def __init__(self, config, notify_cb = None):
		if notify_cb is None:
			notify_cb = lambda: None

		def connect_toggle(widget_name, setting_name):
			widget = widgets.get_widget(widget_name)
			widget.set_active(getattr(config, setting_name))
			def toggle(w, config = config, setting_name = setting_name):
				setattr(config, setting_name, w.get_active())
				config.save_globals()
				notify_cb()
			widget.connect('toggled', toggle)

		widgets = Template('preferences_box')

		self.window = widgets.get_widget('preferences_box')
		self.window.connect('destroy', lambda w: self.destroyed())

		# (attribute to avoid: free variable 'network' referenced before assignment in enclosing scope)
		self.network = widgets.get_widget('network_use')
		self.network.set_active(list(network_levels).index(config.network_use))

		def set_network_use(combo):
			config.network_use = network_levels[self.network.get_active()]
			config.save_globals()
			notify_cb()
		self.network.connect('changed', set_network_use)

		# Freshness
		times = [x.time for x in freshness_levels]
		if config.freshness not in times:
			freshness_levels.append(Freshness(config.freshness,
							  '%d seconds' % config.freshness))
			times.append(config.freshness)
		freshness = widgets.get_widget('freshness')
		freshness_model = freshness.get_model()
		for level in freshness_levels:
			i = freshness_model.append()
			freshness_model.set_value(i, 0, str(level))
		freshness.set_active(times.index(config.freshness))
		def set_freshness(combo, freshness = freshness): # (pygtk bug?)
			config.freshness = freshness_levels[freshness.get_active()].time
			config.save_globals()
			notify_cb()
		freshness.connect('changed', set_freshness)

		connect_toggle('help_test', 'help_with_testing')

		# Keys
		keys_view = widgets.get_widget('trusted_keys')
		KeyList(keys_view)
		connect_toggle('auto_approve', 'auto_approve_keys')

		# Responses
		self.window.set_default_response(gtk.RESPONSE_CLOSE)
		self.window.get_default_widget().grab_focus()

		def response(dialog, resp):
			if resp in (gtk.RESPONSE_CLOSE, gtk.RESPONSE_DELETE_EVENT):
				self.window.destroy()
			elif resp == gtk.RESPONSE_HELP:
				gui_help.display()
		self.window.connect('response', response)

		self.window.set_default_size(-1, gtk.gdk.screen_height() / 3)