5 from dialog
import Dialog
6 from policy
import policy
7 from impl_list
import ImplementationList
10 _dialogs
= {} # Interface -> Properties
18 class Properties(Dialog
):
22 def __init__(self
, interface
):
24 self
.interface
= interface
25 self
.set_title('Interface ' + interface
.get_name())
26 self
.set_default_size(gtk
.gdk
.screen_width() / 2,
27 gtk
.gdk
.screen_height() / 3)
29 vbox
= gtk
.VBox(False, 4)
30 vbox
.set_border_width(4)
31 self
.vbox
.pack_start(vbox
, True, True, 0)
33 self
.add_button(gtk
.STOCK_HELP
, gtk
.RESPONSE_HELP
)
34 self
.add_button(gtk
.STOCK_REFRESH
, 1)
35 self
.add_button(gtk
.STOCK_CLOSE
, gtk
.RESPONSE_CANCEL
)
36 self
.set_default_response(gtk
.RESPONSE_CANCEL
)
38 def response(dialog
, resp
):
39 if resp
== gtk
.RESPONSE_CANCEL
:
42 policy
.begin_iface_download(interface
)
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)
62 iter = buffer.get_start_iter()
63 buffer.insert_with_tags(iter,
64 '%s (%s)' % (interface
.get_name(), interface
.summary
), heading_style
)
66 buffer.insert(iter, '\nFull name: %s\n\n' % interface
.uri
)
68 buffer.insert_with_tags(iter, 'Description\n', heading_style
)
70 description
.set_size_request(-1, 100)
72 buffer.insert(iter, interface
.description
or "-")
74 self
.use_list
= ImplementationList(interface
)
75 vbox
.pack_start(self
.use_list
, True, True, 0)
76 self
.use_list
.set_policy(gtk
.POLICY_AUTOMATIC
, gtk
.POLICY_ALWAYS
)
78 hbox
= gtk
.HBox(False, 2)
79 vbox
.pack_start(hbox
, False, True, 0)
81 stability
= gtk
.combo_box_new_text()
82 stability
.append_text('Use default setting')
83 stability
.set_active(0)
84 for i
, x
in enumerate((stable
, testing
, developer
)):
85 stability
.append_text(str(x
).capitalize())
86 if x
is interface
.stability_policy
:
87 stability
.set_active(i
+ 1)
88 hbox
.pack_start(gtk
.Label('Preferred stability:'), False, True, 0)
89 hbox
.pack_start(stability
, False, True, 0)
90 def set_stability_policy(combo
):
91 i
= stability
.get_active()
95 name
= stability
.get_model()[i
][0].lower()
96 new_stability
= stability_levels
[name
]
97 interface
.set_stability_policy(new_stability
)
98 writer
.save_interface(interface
)
100 stability
.connect('changed', set_stability_policy
)
105 self
.connect('destroy', lambda s
: policy
.watchers
.remove(self
.update_list
))
106 policy
.watchers
.append(self
.update_list
)
108 def update_list(self
):
109 impls
= policy
.get_ranked_implementations(self
.interface
)
110 self
.use_list
.set_items(impls
)
113 assert isinstance(interface
, Interface
)
114 if interface
in _dialogs
:
115 _dialogs
[interface
].destroy()
116 _dialogs
[interface
] = Properties(interface
)
117 _dialogs
[interface
].show()
119 properties_help
= help_box
.HelpBox("Injector Properties Help",
120 ('Interface properties', """
121 This window displays information about an interface. At the top is the interface's \
122 short name, unique ID, summary and long description. The unique ID is also the \
123 location which is used to update the information."""),
125 ('Implementations', """
126 The main part of the window is a list of all known implementations of the interface. \
127 The columns have the following meanings:
129 Version gives the version number. High-numbered versions are considered to be \
130 better than low-numbered ones.
132 Stability is 'stable' if the implementation is believed to be stable, 'buggy' if \
133 it is known to contain serious bugs, and 'testing' if its stability is not yet \
134 known. This information is normally supplied and updated by the author of the \
135 software, but you can override their rating (overridden values are shown in upper-case). \
136 You can also use the special level 'preferred'.
138 C(ached) indicates whether the implementation is already stored on your computer. \
139 In off-line mode, only cached implementations are considered for use.
141 Arch indicates what kind of computer system the implementation is for, or 'any' \
142 if it works with all types of system.
144 Location is the path that will be used for the implementation when the program is run.
147 The implementations are listed in the injector's currently preferred order (the one \
148 at the top will actually be used). Usable implementations all come before unusable \
151 Unusable ones are those for incompatible \
152 architectures, those marked as 'buggy', versions explicitly marked as incompatible with \
153 another interface you are using and, in off-line mode, uncached implementations. Unusable \
154 implementations are shown crossed out.
156 For the usable implementations, the order is as follows:
158 - Preferred implementations come first.
160 - Then, if network use is set to 'Minimal', cached implementations come before \
163 - Then, implementations at or above the selected stability level come before all others.
165 - Then, higher-numbered versions come before low-numbered ones.
167 - Then cached come before non-cached (for 'Full' network use mode).