5 from dialog
import Dialog
7 from impl_list
import ImplementationList
11 _dialogs
= {} # Interface -> Properties
19 class Properties(Dialog
):
23 def __init__(self
, interface
):
25 self
.interface
= interface
26 self
.set_title('Interface ' + interface
.get_name())
27 self
.set_default_size(gtk
.gdk
.screen_width() / 2,
28 gtk
.gdk
.screen_height() / 3)
30 vbox
= gtk
.VBox(False, 4)
31 vbox
.set_border_width(4)
32 self
.vbox
.pack_start(vbox
, True, True, 0)
34 self
.add_button(gtk
.STOCK_HELP
, gtk
.RESPONSE_HELP
)
35 #self.add_button(gtk.STOCK_REFRESH, 1)
36 self
.add_button(gtk
.STOCK_CLOSE
, gtk
.RESPONSE_CANCEL
)
37 self
.set_default_response(gtk
.RESPONSE_CANCEL
)
39 def response(dialog
, resp
):
40 if resp
== gtk
.RESPONSE_CANCEL
:
43 # policy.begin_iface_download(interface, True)
44 elif resp
== gtk
.RESPONSE_HELP
:
45 properties_help
.display()
46 self
.connect('response', response
)
48 swin
= gtk
.ScrolledWindow(None, None)
49 swin
.set_shadow_type(gtk
.SHADOW_IN
)
50 swin
.set_policy(gtk
.POLICY_AUTOMATIC
, gtk
.POLICY_ALWAYS
)
51 vbox
.pack_start(swin
, False, True, 0)
52 description
= gtk
.TextView()
53 description
.set_left_margin(4)
54 description
.set_right_margin(4)
55 description
.set_wrap_mode(gtk
.WRAP_WORD
)
56 description
.set_editable(False)
57 description
.set_cursor_visible(False)
60 buffer = description
.get_buffer()
61 heading_style
= buffer.create_tag(underline
= True, scale
= 1.2)
64 buffer.delete(buffer.get_start_iter(), buffer.get_end_iter())
66 iter = buffer.get_start_iter()
68 buffer.insert_with_tags(iter,
69 '%s (%s)' % (interface
.get_name(), interface
.summary
), heading_style
)
71 buffer.insert(iter, '\nFull name: %s' % interface
.uri
)
73 # (converts to local time)
74 if interface
.last_modified
:
75 buffer.insert(iter, '\nLast upstream change: %s' % time
.ctime(interface
.last_modified
))
77 if interface
.last_checked
:
78 buffer.insert(iter, '\nLast checked: %s' % time
.ctime(interface
.last_checked
))
80 buffer.insert_with_tags(iter, '\n\nDescription\n', heading_style
)
82 buffer.insert(iter, interface
.description
or "-")
85 description
.set_size_request(-1, 100)
87 self
.use_list
= ImplementationList(interface
)
88 vbox
.pack_start(self
.use_list
, True, True, 0)
89 self
.use_list
.set_policy(gtk
.POLICY_AUTOMATIC
, gtk
.POLICY_ALWAYS
)
91 hbox
= gtk
.HBox(False, 2)
92 vbox
.pack_start(hbox
, False, True, 0)
94 stability
= gtk
.combo_box_new_text()
95 stability
.append_text('Use default setting')
96 stability
.set_active(0)
97 for i
, x
in enumerate((stable
, testing
, developer
)):
98 stability
.append_text(str(x
).capitalize())
99 if x
is interface
.stability_policy
:
100 stability
.set_active(i
+ 1)
101 hbox
.pack_start(gtk
.Label('Preferred stability:'), False, True, 0)
102 hbox
.pack_start(stability
, False, True, 0)
103 def set_stability_policy(combo
):
104 i
= stability
.get_active()
108 name
= stability
.get_model()[i
][0].lower()
109 new_stability
= stability_levels
[name
]
110 interface
.set_stability_policy(new_stability
)
111 writer
.save_interface(interface
)
113 stability
.connect('changed', set_stability_policy
)
121 self
.connect('destroy', lambda s
: policy
.watchers
.remove(updated
))
122 policy
.watchers
.append(updated
)
124 def update_list(self
):
125 impls
= policy
.get_ranked_implementations(self
.interface
)
126 self
.use_list
.set_items(impls
)
129 assert isinstance(interface
, Interface
)
130 if interface
in _dialogs
:
131 _dialogs
[interface
].destroy()
132 _dialogs
[interface
] = Properties(interface
)
133 _dialogs
[interface
].show()
135 properties_help
= help_box
.HelpBox("Injector Properties Help",
136 ('Interface properties', """
137 This window displays information about an interface. At the top is the interface's \
138 short name, unique ID, summary and long description. The unique ID is also the \
139 location which is used to update the information."""),
141 ('Implementations', """
142 The main part of the window is a list of all known implementations of the interface. \
143 The columns have the following meanings:
145 Version gives the version number. High-numbered versions are considered to be \
146 better than low-numbered ones.
148 Stability is 'stable' if the implementation is believed to be stable, 'buggy' if \
149 it is known to contain serious bugs, and 'testing' if its stability is not yet \
150 known. This information is normally supplied and updated by the author of the \
151 software, but you can override their rating (overridden values are shown in upper-case). \
152 You can also use the special level 'preferred'.
154 C(ached) indicates whether the implementation is already stored on your computer. \
155 In off-line mode, only cached implementations are considered for use.
157 Arch indicates what kind of computer system the implementation is for, or 'any' \
158 if it works with all types of system.
160 Location is the path that will be used for the implementation when the program is run.
163 The implementations are listed in the injector's currently preferred order (the one \
164 at the top will actually be used). Usable implementations all come before unusable \
167 Unusable ones are those for incompatible \
168 architectures, those marked as 'buggy', versions explicitly marked as incompatible with \
169 another interface you are using and, in off-line mode, uncached implementations. Unusable \
170 implementations are shown crossed out.
172 For the usable implementations, the order is as follows:
174 - Preferred implementations come first.
176 - Then, if network use is set to 'Minimal', cached implementations come before \
179 - Then, implementations at or above the selected stability level come before all others.
181 - Then, higher-numbered versions come before low-numbered ones.
183 - Then cached come before non-cached (for 'Full' network use mode).