Added preferred as a user-selectable stability level. Always comes first.
[zeroinstall.git] / properties.py
blobb7895f26d1b2b4bcd21fcb835c236dad96e31335
1 from model import *
2 import gtk
4 import help_box
5 from dialog import Dialog
6 from policy import policy
7 from impl_list import ImplementationList
9 _dialogs = {} # Interface -> Properties
11 class Properties(Dialog):
12 interface = None
13 use_list = None
15 def __init__(self, interface):
16 Dialog.__init__(self)
17 self.interface = interface
18 self.set_title('Interface ' + interface.get_name())
19 self.set_default_size(gtk.gdk.screen_width() / 2,
20 gtk.gdk.screen_height() / 3)
22 vbox = gtk.VBox(False, 4)
23 vbox.set_border_width(4)
24 self.vbox.pack_start(vbox, True, True, 0)
26 self.add_button(gtk.STOCK_HELP, gtk.RESPONSE_HELP)
27 self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CANCEL)
28 self.set_default_response(gtk.RESPONSE_CANCEL)
30 label = gtk.Label('%s: %s' % (interface.get_name(),
31 interface.summary))
32 vbox.pack_start(label, False, True, 0)
34 vbox.pack_start(gtk.Label('(%s)' % interface.uri),
35 False, True, 0)
37 def response(dialog, resp):
38 if resp == gtk.RESPONSE_CANCEL:
39 self.destroy()
40 elif resp == gtk.RESPONSE_HELP:
41 properties_help.display()
42 self.connect('response', response)
44 frame = gtk.Frame()
45 frame.set_shadow_type(gtk.SHADOW_IN)
46 vbox.pack_start(frame, False, True, 0)
47 description = gtk.Label(interface.description)
48 description.set_line_wrap(True)
49 frame.add(description)
51 self.use_list = ImplementationList(interface)
52 vbox.pack_start(self.use_list, True, True, 0)
53 self.use_list.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
55 hbox = gtk.HBox(False, 2)
56 vbox.pack_start(hbox, False, True, 0)
58 stability = gtk.combo_box_new_text()
59 stability.append_text('Use default setting')
60 stability.append_text('Stable')
61 stability.append_text('Testing')
62 stability.append_text('Developer')
63 stability.set_active(0)
64 hbox.pack_start(gtk.Label('Preferred stability:'), False, True, 0)
65 hbox.pack_start(stability, False, True, 0)
66 def set_stability_policy(combo):
67 i = stability.get_active()
68 if i == 0:
69 new_stability = None
70 else:
71 name = stability.get_model()[i][0].lower()
72 new_stability = stability_levels[name]
73 interface.set_stability_policy(new_stability)
74 policy.recalculate()
75 stability.connect('changed', set_stability_policy)
77 self.update_list()
78 vbox.show_all()
80 self.connect('destroy', lambda s: policy.watchers.remove(self.update_list))
81 policy.watchers.append(self.update_list)
83 def update_list(self):
84 impls = policy.get_ranked_implementations(self.interface)
85 self.use_list.set_items(impls)
87 def edit(interface):
88 assert isinstance(interface, Interface)
89 if interface in _dialogs:
90 _dialogs[interface].destroy()
91 _dialogs[interface] = Properties(interface)
92 _dialogs[interface].show()
94 properties_help = help_box.HelpBox("Injector Properties Help",
95 ('Interface properties', """
96 This window displays information about an interface. At the top is the interface's \
97 short name, unique ID, summary and long description. The unique ID is also the \
98 location which is used to update the information."""),
100 ('Implementations', """
101 The main part of the window is a list of all known implementations of the interface. \
102 The columns have the following meanings:
104 Version gives the version number. High-numbered versions are considered to be \
105 better than low-numbered ones.
107 Stability is 'stable' if the implementation is believed to be stable, 'buggy' if \
108 it is known to contain serious bugs, and 'testing' if its stability is not yet \
109 known. This information is normally supplied and updated by the author of the \
110 software, but you can override their rating. Overridden values are shown in
111 upper-case, and you can also set it to the special level 'PREFERRED'.
113 C(ached) indicates whether the implementation is already stored on your computer. \
114 In off-line mode, only cached implementations are considered for use.
116 Arch indicates what kind of computer system the implementation is for, or 'any' \
117 if it works with all types of system.
119 Location is the path that will be used for the implementation when the program is run.
120 """),
121 ('Sort order', """
122 The implementations are listed in the injector's currently preferred order (the one \
123 at the top will actually be used). Usable implementations all come before unusable \
124 ones.
126 Unusable ones are those marked as 'avoid', those for incompatible \
127 architectures, those marked as 'buggy', versions explicitly marked as incompatible with \
128 another interface you are using and, in off-line mode, uncached implementations. Unusable \
129 implementations are shown shaded.
131 For the usable implementations, the order is as follows:
133 - If network use is set to 'Minimal', cached implementations come before \
134 non-cached.
136 - Then, implementations at or above the selected stability level come before all others.
138 - Then, higher-numbered versions come before low-numbered ones.
140 - Then cached come before non-cached (for 'Full' network use mode).
141 """))