2 from iface_browser
import InterfaceBrowser
5 from dialog
import Dialog
6 from model
import stable
, testing
, network_levels
, SafeException
8 class MainWindow(Dialog
):
12 def __init__(self
, prog
, prog_args
):
14 self
.set_title('Dependency Injector')
15 self
.set_default_size(400, 300)
20 hbox
= gtk
.HBox(False, 2)
21 self
.vbox
.pack_start(hbox
, False, True, 0)
22 hbox
.set_border_width(4)
24 network
= gtk
.combo_box_new_text()
25 for level
in network_levels
:
26 network
.append_text(level
.capitalize())
27 network
.set_active(list(network_levels
).index(policy
.network_use
))
28 hbox
.pack_start(gtk
.Label('Network use:'), False, True, 0)
29 hbox
.pack_start(network
, True, True, 2)
30 def set_network_use(combo
):
31 policy
.network_use
= network_levels
[network
.get_active()]
34 network
.connect('changed', set_network_use
)
36 button
= gtk
.Button('Refresh all')
38 for x
in policy
.walk_interfaces():
39 policy
.begin_iface_download(x
, True)
40 button
.connect('clicked', refresh_all
)
41 hbox
.pack_start(button
, False, True, 2)
46 self
.browser
= InterfaceBrowser()
47 self
.vbox
.pack_start(self
.browser
, True, True, 0)
51 hbox
= gtk
.HBox(False, 2)
52 self
.vbox
.pack_start(hbox
, False, True, 0)
53 hbox
.set_border_width(4)
56 self
.browser
.edit_properties
.connect_proxy(button
)
57 hbox
.pack_start(button
, False, True, 0)
59 stable_toggle
= gtk
.CheckButton('Help test new versions')
60 hbox
.pack_start(stable_toggle
, False, True, 0)
61 tips
.set_tip(stable_toggle
,
62 "Try out new versions as soon as they are available, instead of "
63 "waiting for them to be marked as 'stable'. "
64 "This sets the default policy. Click on 'Interface Properties...' "
65 "to set the policy for an individual interface.")
66 stable_toggle
.set_active(policy
.help_with_testing
)
67 def toggle_stability(toggle
):
68 policy
.help_with_testing
= toggle
.get_active()
71 stable_toggle
.connect('toggled', toggle_stability
)
76 self
.progress
= gtk
.ProgressBar()
77 self
.vbox
.pack_start(self
.progress
, False, True, 0)
81 self
.add_button(gtk
.STOCK_HELP
, gtk
.RESPONSE_HELP
)
82 self
.add_button(gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
)
83 self
.add_button(gtk
.STOCK_EXECUTE
, gtk
.RESPONSE_OK
)
84 self
.set_default_response(gtk
.RESPONSE_OK
)
86 def response(dialog
, resp
):
87 if resp
== gtk
.RESPONSE_CANCEL
:
89 elif resp
== gtk
.RESPONSE_OK
:
92 run
.execute(policy
, prog
, prog_args
)
94 except SafeException
, ex
:
95 box
= gtk
.MessageDialog(self
, gtk
.DIALOG_MODAL
,
96 gtk
.MESSAGE_ERROR
, gtk
.BUTTONS_OK
,
100 elif resp
== gtk
.RESPONSE_HELP
:
102 self
.connect('response', response
)
104 gui_help
= help_box
.HelpBox("Injector Help",
106 A program is made up of many different components, typically written by different \
107 groups of people. Each component is available in multiple versions. The injector is \
108 used when starting a program. Its job is to decide which implementation of each required \
111 An interface describes what a component does. The injector starts with \
112 the interface for the program you want to run (like 'The Gimp') and chooses an \
113 implementation (like 'The Gimp 2.2.0'). However, this implementation \
114 will in turn depend on other interfaces, such as 'GTK' (which draws the menus \
115 and buttons). Thus, the injector must choose implementations of \
116 each dependancy (each of which may require further interfaces, and so on)."""),
118 ('List of interfaces', """
119 The main window displays all these interfaces, and the version of each chosen \
120 implementation. The top-most one represents the program you tried to run, and each direct \
121 child is a dependancy.
123 If you are happy with the choices shown, click on the Execute button to run the \
126 ('Choosing different versions', """
127 There are three ways to control which implementations are chosen. You can adjust the \
128 network policy and the overall stability policy, which affect all interfaces, or you \
129 can edit the policy of individual interfaces.
131 The 'Network use' option controls how the injector uses the network. If off-line, \
132 the network is not used at all. If 'Minimal' is selected then the injector will use \
133 the network if needed, but only if it has no choice. It will run an out-of-date \
134 version rather than download a newer one. If 'Full' is selected, the injector won't \
135 worry about how much it downloads, but will always pick the version it thinks is best.
137 The overall stability policy can either be to prefer stable versions, or to help test \
138 new versions. Choose whichever suits you. Since different programmers have different \
139 ideas of what 'stable' means, you may wish to override this on a per-interface basis \
142 To set the policy for an interface individually, select it and click on 'Interface \
143 Properties'. See that dialog's help text for more information."""))