Merge lp:~elachuni/software-center/pep8-test-part9 into lp:software-center
- pep8-test-part9
- Merge into trunk
Proposed by
Anthony Lenton
Status: | Merged |
---|---|
Merged at revision: | 2851 |
Proposed branch: | lp:~elachuni/software-center/pep8-test-part9 |
Merge into: | lp:software-center |
Diff against target: |
1071 lines (+199/-178) 5 files modified
softwarecenter/ui/gtk3/views/appview.py (+25/-32) softwarecenter/ui/gtk3/views/catview_gtk.py (+83/-72) softwarecenter/ui/gtk3/views/pkgnamesview.py (+8/-7) softwarecenter/ui/gtk3/views/purchaseview.py (+80/-66) test/test_pep8.py (+3/-1) |
To merge this branch: | bzr merge lp:~elachuni/software-center/pep8-test-part9 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Kiwinote | Approve | ||
Review via email: mp+97453@code.launchpad.net |
Commit message
Description of the change
Most of the files in softwarecenter.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'softwarecenter/ui/gtk3/views/appview.py' | |||
2 | --- softwarecenter/ui/gtk3/views/appview.py 2012-03-08 15:13:30 +0000 | |||
3 | +++ softwarecenter/ui/gtk3/views/appview.py 2012-03-14 16:41:35 +0000 | |||
4 | @@ -29,7 +29,8 @@ | |||
5 | 29 | from softwarecenter.ui.gtk3.models.appstore2 import AppPropertiesHelper | 29 | from softwarecenter.ui.gtk3.models.appstore2 import AppPropertiesHelper |
6 | 30 | from softwarecenter.utils import ExecutionTime | 30 | from softwarecenter.utils import ExecutionTime |
7 | 31 | 31 | ||
9 | 32 | LOG=logging.getLogger(__name__) | 32 | LOG = logging.getLogger(__name__) |
10 | 33 | |||
11 | 33 | 34 | ||
12 | 34 | class AppView(Gtk.VBox): | 35 | class AppView(Gtk.VBox): |
13 | 35 | 36 | ||
14 | @@ -38,16 +39,16 @@ | |||
15 | 38 | None, | 39 | None, |
16 | 39 | (GObject.TYPE_PYOBJECT, ), | 40 | (GObject.TYPE_PYOBJECT, ), |
17 | 40 | ), | 41 | ), |
26 | 41 | "application-activated" : (GObject.SignalFlags.RUN_LAST, | 42 | "application-activated": (GObject.SignalFlags.RUN_LAST, |
27 | 42 | None, | 43 | None, |
28 | 43 | (GObject.TYPE_PYOBJECT, ), | 44 | (GObject.TYPE_PYOBJECT, ), |
29 | 44 | ), | 45 | ), |
30 | 45 | "application-selected" : (GObject.SignalFlags.RUN_LAST, | 46 | "application-selected": (GObject.SignalFlags.RUN_LAST, |
31 | 46 | None, | 47 | None, |
32 | 47 | (GObject.TYPE_PYOBJECT, ), | 48 | (GObject.TYPE_PYOBJECT, ), |
33 | 48 | ), | 49 | ), |
34 | 49 | } | 50 | } |
36 | 50 | 51 | ||
37 | 51 | (INSTALLED_MODE, AVAILABLE_MODE, DIFF_MODE) = range(3) | 52 | (INSTALLED_MODE, AVAILABLE_MODE, DIFF_MODE) = range(3) |
38 | 52 | 53 | ||
39 | 53 | _SORT_METHOD_INDEX = (SortMethods.BY_ALPHABET, | 54 | _SORT_METHOD_INDEX = (SortMethods.BY_ALPHABET, |
40 | @@ -97,14 +98,13 @@ | |||
41 | 97 | self._handler = self.sort_methods_combobox.connect( | 98 | self._handler = self.sort_methods_combobox.connect( |
42 | 98 | "changed", | 99 | "changed", |
43 | 99 | self.on_sort_method_changed) | 100 | self.on_sort_method_changed) |
44 | 100 | return | ||
45 | 101 | 101 | ||
46 | 102 | #~ def on_draw(self, w, cr): | 102 | #~ def on_draw(self, w, cr): |
47 | 103 | #~ cr.set_source_rgb(1,1,1) | 103 | #~ cr.set_source_rgb(1,1,1) |
48 | 104 | #~ cr.paint() | 104 | #~ cr.paint() |
49 | 105 | 105 | ||
50 | 106 | def _append_appcount(self, appcount, mode=AVAILABLE_MODE): | 106 | def _append_appcount(self, appcount, mode=AVAILABLE_MODE): |
52 | 107 | #~ | 107 | #~ |
53 | 108 | #~ if mode == self.INSTALLED_MODE: | 108 | #~ if mode == self.INSTALLED_MODE: |
54 | 109 | #~ text = gettext.ngettext("%(amount)s item installed", | 109 | #~ text = gettext.ngettext("%(amount)s item installed", |
55 | 110 | #~ "%(amount)s items installed", | 110 | #~ "%(amount)s items installed", |
56 | @@ -112,12 +112,12 @@ | |||
57 | 112 | #~ elif mode == self.DIFF_MODE: | 112 | #~ elif mode == self.DIFF_MODE: |
58 | 113 | #~ text = gettext.ngettext("%(amount)s item", | 113 | #~ text = gettext.ngettext("%(amount)s item", |
59 | 114 | #~ "%(amount)s items", | 114 | #~ "%(amount)s items", |
61 | 115 | #~ appcount) % { 'amount' : appcount, } | 115 | #~ appcount) % { 'amount' : appcount, } |
62 | 116 | #~ else: | 116 | #~ else: |
63 | 117 | #~ text = gettext.ngettext("%(amount)s item available", | 117 | #~ text = gettext.ngettext("%(amount)s item available", |
64 | 118 | #~ "%(amount)s items available", | 118 | #~ "%(amount)s items available", |
65 | 119 | #~ appcount) % { 'amount' : appcount, } | 119 | #~ appcount) % { 'amount' : appcount, } |
67 | 120 | #~ | 120 | #~ |
68 | 121 | #~ if not self.appcount: | 121 | #~ if not self.appcount: |
69 | 122 | #~ self.appcount = Gtk.Label() | 122 | #~ self.appcount = Gtk.Label() |
70 | 123 | #~ self.appcount.set_alignment(0.5, 0.5) | 123 | #~ self.appcount.set_alignment(0.5, 0.5) |
71 | @@ -127,13 +127,12 @@ | |||
72 | 127 | #~ self.vbox.pack_start(self.appcount, False, False, 0) | 127 | #~ self.vbox.pack_start(self.appcount, False, False, 0) |
73 | 128 | #~ self.appcount.set_text(text) | 128 | #~ self.appcount.set_text(text) |
74 | 129 | #~ self.appcount.show() | 129 | #~ self.appcount.show() |
76 | 130 | return | 130 | pass |
77 | 131 | 131 | ||
78 | 132 | def on_sort_method_changed(self, *args): | 132 | def on_sort_method_changed(self, *args): |
79 | 133 | self.user_defined_sort_method = True | 133 | self.user_defined_sort_method = True |
80 | 134 | self.vadj = 0.0 | 134 | self.vadj = 0.0 |
81 | 135 | self.emit("sort-method-changed", self.sort_methods_combobox) | 135 | self.emit("sort-method-changed", self.sort_methods_combobox) |
82 | 136 | return | ||
83 | 137 | 136 | ||
84 | 138 | def _get_sort_methods_combobox(self): | 137 | def _get_sort_methods_combobox(self): |
85 | 139 | combo = Gtk.ComboBoxText.new() | 138 | combo = Gtk.ComboBoxText.new() |
86 | @@ -151,25 +150,21 @@ | |||
87 | 151 | if self._get_combo_children() == 4: | 150 | if self._get_combo_children() == 4: |
88 | 152 | return | 151 | return |
89 | 153 | self.sort_methods_combobox.append_text(_("By Relevance")) | 152 | self.sort_methods_combobox.append_text(_("By Relevance")) |
90 | 154 | return | ||
91 | 155 | 153 | ||
92 | 156 | def _use_combobox_without_sort_by_search_ranking(self): | 154 | def _use_combobox_without_sort_by_search_ranking(self): |
93 | 157 | if self._get_combo_children() == 3: | 155 | if self._get_combo_children() == 3: |
94 | 158 | return | 156 | return |
95 | 159 | self.sort_methods_combobox.remove(self._SORT_BY_SEARCH_RANKING) | 157 | self.sort_methods_combobox.remove(self._SORT_BY_SEARCH_RANKING) |
96 | 160 | self.set_sort_method_with_no_signal(self._SORT_BY_TOP_RATED) | 158 | self.set_sort_method_with_no_signal(self._SORT_BY_TOP_RATED) |
97 | 161 | return | ||
98 | 162 | 159 | ||
99 | 163 | def set_sort_method_with_no_signal(self, sort_method): | 160 | def set_sort_method_with_no_signal(self, sort_method): |
100 | 164 | combo = self.sort_methods_combobox | 161 | combo = self.sort_methods_combobox |
101 | 165 | combo.handler_block(self._handler) | 162 | combo.handler_block(self._handler) |
102 | 166 | combo.set_active(sort_method) | 163 | combo.set_active(sort_method) |
103 | 167 | combo.handler_unblock(self._handler) | 164 | combo.handler_unblock(self._handler) |
104 | 168 | return | ||
105 | 169 | 165 | ||
106 | 170 | def set_allow_user_sorting(self, do_allow): | 166 | def set_allow_user_sorting(self, do_allow): |
107 | 171 | self.sort_methods_combobox.set_visible(do_allow) | 167 | self.sort_methods_combobox.set_visible(do_allow) |
108 | 172 | return | ||
109 | 173 | 168 | ||
110 | 174 | def set_header_labels(self, first_line, second_line): | 169 | def set_header_labels(self, first_line, second_line): |
111 | 175 | if second_line: | 170 | if second_line: |
112 | @@ -180,7 +175,6 @@ | |||
113 | 180 | 175 | ||
114 | 181 | def set_model(self, model): | 176 | def set_model(self, model): |
115 | 182 | self.tree_view.set_model(model) | 177 | self.tree_view.set_model(model) |
116 | 183 | return | ||
117 | 184 | 178 | ||
118 | 185 | def display_matches(self, matches, is_search=False): | 179 | def display_matches(self, matches, is_search=False): |
119 | 186 | # FIXME: installedpane handles display of the trees intimately, | 180 | # FIXME: installedpane handles display of the trees intimately, |
120 | @@ -210,7 +204,6 @@ | |||
121 | 210 | 204 | ||
122 | 211 | self.tree_view_scroll.get_vadjustment().set_lower(self.vadj) | 205 | self.tree_view_scroll.get_vadjustment().set_lower(self.vadj) |
123 | 212 | self.tree_view_scroll.get_vadjustment().set_value(self.vadj) | 206 | self.tree_view_scroll.get_vadjustment().set_value(self.vadj) |
124 | 213 | return | ||
125 | 214 | 207 | ||
126 | 215 | def clear_model(self): | 208 | def clear_model(self): |
127 | 216 | return self.tree_view.clear_model() | 209 | return self.tree_view.clear_model() |
128 | @@ -218,7 +211,7 @@ | |||
129 | 218 | def get_sort_mode(self): | 211 | def get_sort_mode(self): |
130 | 219 | active_index = self.sort_methods_combobox.get_active() | 212 | active_index = self.sort_methods_combobox.get_active() |
131 | 220 | return self._SORT_METHOD_INDEX[active_index] | 213 | return self._SORT_METHOD_INDEX[active_index] |
133 | 221 | 214 | ||
134 | 222 | def get_app_icon_details(self): | 215 | def get_app_icon_details(self): |
135 | 223 | """ helper for unity dbus support to provide details about the | 216 | """ helper for unity dbus support to provide details about the |
136 | 224 | application icon as it is displayed on-screen | 217 | application icon as it is displayed on-screen |
137 | @@ -239,7 +232,7 @@ | |||
138 | 239 | else: | 232 | else: |
139 | 240 | icon_size = pb.get_height() | 233 | icon_size = pb.get_height() |
140 | 241 | return icon_size | 234 | return icon_size |
142 | 242 | 235 | ||
143 | 243 | def _get_app_icon_xy_position_on_screen(self): | 236 | def _get_app_icon_xy_position_on_screen(self): |
144 | 244 | """ helper for unity dbus support to get the x,y position of | 237 | """ helper for unity dbus support to get the x,y position of |
145 | 245 | the application icon as it is displayed on-screen | 238 | the application icon as it is displayed on-screen |
146 | @@ -251,16 +244,14 @@ | |||
147 | 251 | # get toplevel window position | 244 | # get toplevel window position |
148 | 252 | (px, py) = parent.get_position() | 245 | (px, py) = parent.get_position() |
149 | 253 | # and return the coordinate values | 246 | # and return the coordinate values |
155 | 254 | return (px+self.tree_view.selected_row_renderer.icon_x_offset, | 247 | return (px + self.tree_view.selected_row_renderer.icon_x_offset, |
156 | 255 | py+self.tree_view.selected_row_renderer.icon_y_offset) | 248 | py + self.tree_view.selected_row_renderer.icon_y_offset) |
152 | 256 | |||
153 | 257 | |||
154 | 258 | |||
157 | 259 | 249 | ||
158 | 260 | 250 | ||
159 | 261 | # ----------------------------------------------- testcode | 251 | # ----------------------------------------------- testcode |
160 | 262 | from softwarecenter.enums import NonAppVisibility | 252 | from softwarecenter.enums import NonAppVisibility |
161 | 263 | 253 | ||
162 | 254 | |||
163 | 264 | def get_query_from_search_entry(search_term): | 255 | def get_query_from_search_entry(search_term): |
164 | 265 | import xapian | 256 | import xapian |
165 | 266 | if not search_term: | 257 | if not search_term: |
166 | @@ -269,6 +260,7 @@ | |||
167 | 269 | user_query = parser.parse_query(search_term) | 260 | user_query = parser.parse_query(search_term) |
168 | 270 | return user_query | 261 | return user_query |
169 | 271 | 262 | ||
170 | 263 | |||
171 | 272 | def on_entry_changed(widget, data): | 264 | def on_entry_changed(widget, data): |
172 | 273 | 265 | ||
173 | 274 | def _work(): | 266 | def _work(): |
174 | @@ -278,8 +270,8 @@ | |||
175 | 278 | with ExecutionTime("total time"): | 270 | with ExecutionTime("total time"): |
176 | 279 | with ExecutionTime("enquire.set_query()"): | 271 | with ExecutionTime("enquire.set_query()"): |
177 | 280 | enquirer.set_query(get_query_from_search_entry(new_text), | 272 | enquirer.set_query(get_query_from_search_entry(new_text), |
180 | 281 | limit=100*1000, | 273 | limit=100 * 1000, |
181 | 282 | nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE) | 274 | nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE) |
182 | 283 | 275 | ||
183 | 284 | store = view.tree_view.get_model() | 276 | store = view.tree_view.get_model() |
184 | 285 | with ExecutionTime("store.clear()"): | 277 | with ExecutionTime("store.clear()"): |
185 | @@ -293,10 +285,11 @@ | |||
186 | 293 | Gtk.main_iteration() | 285 | Gtk.main_iteration() |
187 | 294 | return | 286 | return |
188 | 295 | 287 | ||
190 | 296 | if widget.stamp: | 288 | if widget.stamp: |
191 | 297 | GObject.source_remove(widget.stamp) | 289 | GObject.source_remove(widget.stamp) |
192 | 298 | widget.stamp = GObject.timeout_add(250, _work) | 290 | widget.stamp = GObject.timeout_add(250, _work) |
193 | 299 | 291 | ||
194 | 292 | |||
195 | 300 | def get_test_window(): | 293 | def get_test_window(): |
196 | 301 | import softwarecenter.log | 294 | import softwarecenter.log |
197 | 302 | softwarecenter.log.root.setLevel(level=logging.DEBUG) | 295 | softwarecenter.log.root.setLevel(level=logging.DEBUG) |
198 | 303 | 296 | ||
199 | === modified file 'softwarecenter/ui/gtk3/views/catview_gtk.py' | |||
200 | --- softwarecenter/ui/gtk3/views/catview_gtk.py 2012-03-08 09:13:23 +0000 | |||
201 | +++ softwarecenter/ui/gtk3/views/catview_gtk.py 2012-03-14 16:41:35 +0000 | |||
202 | @@ -55,31 +55,33 @@ | |||
203 | 55 | from softwarecenter.backend.scagent import SoftwareCenterAgent | 55 | from softwarecenter.backend.scagent import SoftwareCenterAgent |
204 | 56 | from softwarecenter.backend.reviews import get_review_loader | 56 | from softwarecenter.backend.reviews import get_review_loader |
205 | 57 | 57 | ||
207 | 58 | LOG=logging.getLogger(__name__) | 58 | LOG = logging.getLogger(__name__) |
208 | 59 | 59 | ||
209 | 60 | 60 | ||
210 | 61 | _asset_cache = {} | 61 | _asset_cache = {} |
211 | 62 | |||
212 | 63 | |||
213 | 62 | class CategoriesViewGtk(Viewport, CategoriesParser): | 64 | class CategoriesViewGtk(Viewport, CategoriesParser): |
214 | 63 | 65 | ||
215 | 64 | __gsignals__ = { | 66 | __gsignals__ = { |
222 | 65 | "category-selected" : (GObject.SignalFlags.RUN_LAST, | 67 | "category-selected": (GObject.SignalFlags.RUN_LAST, |
223 | 66 | None, | 68 | None, |
224 | 67 | (GObject.TYPE_PYOBJECT, ), | 69 | (GObject.TYPE_PYOBJECT, ), |
225 | 68 | ), | 70 | ), |
226 | 69 | 71 | ||
227 | 70 | "application-selected" : (GObject.SignalFlags.RUN_LAST, | 72 | "application-selected": (GObject.SignalFlags.RUN_LAST, |
228 | 73 | None, | ||
229 | 74 | (GObject.TYPE_PYOBJECT, ), | ||
230 | 75 | ), | ||
231 | 76 | |||
232 | 77 | "application-activated": (GObject.SignalFlags.RUN_LAST, | ||
233 | 71 | None, | 78 | None, |
234 | 72 | (GObject.TYPE_PYOBJECT, ), | 79 | (GObject.TYPE_PYOBJECT, ), |
235 | 73 | ), | 80 | ), |
236 | 74 | 81 | ||
245 | 75 | "application-activated" : (GObject.SignalFlags.RUN_LAST, | 82 | "show-category-applist": (GObject.SignalFlags.RUN_LAST, |
246 | 76 | None, | 83 | None, |
247 | 77 | (GObject.TYPE_PYOBJECT, ), | 84 | (),) |
240 | 78 | ), | ||
241 | 79 | |||
242 | 80 | "show-category-applist" : (GObject.SignalFlags.RUN_LAST, | ||
243 | 81 | None, | ||
244 | 82 | (),) | ||
248 | 83 | } | 85 | } |
249 | 84 | 86 | ||
250 | 85 | SPACING = PADDING = 3 | 87 | SPACING = PADDING = 3 |
251 | @@ -88,17 +90,17 @@ | |||
252 | 88 | STIPPLE = os.path.join(softwarecenter.paths.datadir, | 90 | STIPPLE = os.path.join(softwarecenter.paths.datadir, |
253 | 89 | "ui/gtk3/art/stipple.png") | 91 | "ui/gtk3/art/stipple.png") |
254 | 90 | 92 | ||
256 | 91 | def __init__(self, | 93 | def __init__(self, |
257 | 92 | datadir, | 94 | datadir, |
259 | 93 | desktopdir, | 95 | desktopdir, |
260 | 94 | cache, | 96 | cache, |
261 | 95 | db, | 97 | db, |
262 | 96 | icons, | 98 | icons, |
264 | 97 | apps_filter=None, # FIXME: kill this, its not needed anymore? | 99 | apps_filter=None, # FIXME: kill this, its not needed anymore? |
265 | 98 | apps_limit=0): | 100 | apps_limit=0): |
266 | 99 | 101 | ||
267 | 100 | """ init the widget, takes | 102 | """ init the widget, takes |
269 | 101 | 103 | ||
270 | 102 | datadir - the base directory of the app-store data | 104 | datadir - the base directory of the app-store data |
271 | 103 | desktopdir - the dir where the applications.menu file can be found | 105 | desktopdir - the dir where the applications.menu file can be found |
272 | 104 | db - a Database object | 106 | db - a Database object |
273 | @@ -172,7 +174,8 @@ | |||
274 | 172 | 174 | ||
275 | 173 | def _cache_art_assets(self): | 175 | def _cache_art_assets(self): |
276 | 174 | global _asset_cache | 176 | global _asset_cache |
278 | 175 | if _asset_cache: return _asset_cache | 177 | if _asset_cache: |
279 | 178 | return _asset_cache | ||
280 | 176 | assets = _asset_cache | 179 | assets = _asset_cache |
281 | 177 | # cache the bg pattern | 180 | # cache the bg pattern |
282 | 178 | surf = cairo.ImageSurface.create_from_png(self.STIPPLE) | 181 | surf = cairo.ImageSurface.create_from_png(self.STIPPLE) |
283 | @@ -189,7 +192,6 @@ | |||
284 | 189 | return False | 192 | return False |
285 | 190 | 193 | ||
286 | 191 | GObject.timeout_add(50, timeout_emit) | 194 | GObject.timeout_add(50, timeout_emit) |
287 | 192 | return | ||
288 | 193 | 195 | ||
289 | 194 | def on_category_clicked(self, btn, cat): | 196 | def on_category_clicked(self, btn, cat): |
290 | 195 | """emit the category-selected signal when a category was clicked""" | 197 | """emit the category-selected signal when a category was clicked""" |
291 | @@ -198,7 +200,6 @@ | |||
292 | 198 | return False | 200 | return False |
293 | 199 | 201 | ||
294 | 200 | GObject.timeout_add(50, timeout_emit) | 202 | GObject.timeout_add(50, timeout_emit) |
295 | 201 | return | ||
296 | 202 | 203 | ||
297 | 203 | def build(self, desktopdir): | 204 | def build(self, desktopdir): |
298 | 204 | pass | 205 | pass |
299 | @@ -206,14 +207,14 @@ | |||
300 | 206 | def do_draw(self, cr): | 207 | def do_draw(self, cr): |
301 | 207 | cr.set_source(_asset_cache["stipple"]) | 208 | cr.set_source(_asset_cache["stipple"]) |
302 | 208 | cr.paint_with_alpha(0.5) | 209 | cr.paint_with_alpha(0.5) |
305 | 209 | for child in self: self.propagate_draw(child, cr) | 210 | for child in self: |
306 | 210 | return | 211 | self.propagate_draw(child, cr) |
307 | 211 | 212 | ||
308 | 212 | def set_section(self, section): | 213 | def set_section(self, section): |
309 | 213 | self.section = section | 214 | self.section = section |
310 | 214 | 215 | ||
311 | 215 | def refresh_apps(self): | 216 | def refresh_apps(self): |
313 | 216 | raise NotImplemented | 217 | raise NotImplementedError |
314 | 217 | 218 | ||
315 | 218 | 219 | ||
316 | 219 | class LobbyViewGtk(CategoriesViewGtk): | 220 | class LobbyViewGtk(CategoriesViewGtk): |
317 | @@ -251,7 +252,8 @@ | |||
318 | 251 | 252 | ||
319 | 252 | self.top_hbox = Gtk.HBox(spacing=StockEms.SMALL) | 253 | self.top_hbox = Gtk.HBox(spacing=StockEms.SMALL) |
320 | 253 | top_hbox_alignment = Gtk.Alignment() | 254 | top_hbox_alignment = Gtk.Alignment() |
322 | 254 | top_hbox_alignment.set_padding(0, 0, StockEms.MEDIUM-2, StockEms.MEDIUM-2) | 255 | top_hbox_alignment.set_padding(0, 0, StockEms.MEDIUM - 2, |
323 | 256 | StockEms.MEDIUM - 2) | ||
324 | 255 | top_hbox_alignment.add(self.top_hbox) | 257 | top_hbox_alignment.add(self.top_hbox) |
325 | 256 | self.vbox.pack_start(top_hbox_alignment, False, False, 0) | 258 | self.vbox.pack_start(top_hbox_alignment, False, False, 0) |
326 | 257 | 259 | ||
327 | @@ -271,33 +273,33 @@ | |||
328 | 271 | 273 | ||
329 | 272 | #~ def _append_top_of_the_pops(self): | 274 | #~ def _append_top_of_the_pops(self): |
330 | 273 | #~ self.totp_hbox = Gtk.HBox(spacing=self.SPACING) | 275 | #~ self.totp_hbox = Gtk.HBox(spacing=self.SPACING) |
332 | 274 | #~ | 276 | #~ |
333 | 275 | #~ alignment = Gtk.Alignment() | 277 | #~ alignment = Gtk.Alignment() |
334 | 276 | #~ alignment.set_padding(0, 0, self.PADDING, self.PADDING) | 278 | #~ alignment.set_padding(0, 0, self.PADDING, self.PADDING) |
335 | 277 | #~ alignment.add(self.totp_hbox) | 279 | #~ alignment.add(self.totp_hbox) |
337 | 278 | #~ | 280 | #~ |
338 | 279 | #~ frame = FramedHeaderBox() | 281 | #~ frame = FramedHeaderBox() |
339 | 280 | #~ frame.header_implements_more_button() | 282 | #~ frame.header_implements_more_button() |
340 | 281 | #~ frame.set_header_label(_("Most Popular")) | 283 | #~ frame.set_header_label(_("Most Popular")) |
342 | 282 | #~ | 284 | #~ |
343 | 283 | #~ label = Gtk.Label.new("Soda pop!!!") | 285 | #~ label = Gtk.Label.new("Soda pop!!!") |
344 | 284 | #~ label.set_name("placeholder") | 286 | #~ label.set_name("placeholder") |
345 | 285 | #~ label.set_size_request(-1, 200) | 287 | #~ label.set_size_request(-1, 200) |
347 | 286 | #~ | 288 | #~ |
348 | 287 | #~ frame.add(label) | 289 | #~ frame.add(label) |
349 | 288 | #~ self.totp_hbox.add(frame) | 290 | #~ self.totp_hbox.add(frame) |
351 | 289 | #~ | 291 | #~ |
352 | 290 | #~ frame = FramedHeaderBox() | 292 | #~ frame = FramedHeaderBox() |
353 | 291 | #~ frame.header_implements_more_button() | 293 | #~ frame.header_implements_more_button() |
354 | 292 | #~ frame.set_header_label(_("Top Rated")) | 294 | #~ frame.set_header_label(_("Top Rated")) |
356 | 293 | #~ | 295 | #~ |
357 | 294 | #~ label = Gtk.Label.new("Demos ftw(?)") | 296 | #~ label = Gtk.Label.new("Demos ftw(?)") |
358 | 295 | #~ label.set_name("placeholder") | 297 | #~ label.set_name("placeholder") |
359 | 296 | #~ label.set_size_request(-1, 200) | 298 | #~ label.set_size_request(-1, 200) |
361 | 297 | #~ | 299 | #~ |
362 | 298 | #~ frame.add(label) | 300 | #~ frame.add(label) |
363 | 299 | #~ self.totp_hbox.add(frame) | 301 | #~ self.totp_hbox.add(frame) |
365 | 300 | #~ | 302 | #~ |
366 | 301 | #~ self.vbox.pack_start(alignment, False, False, 0) | 303 | #~ self.vbox.pack_start(alignment, False, False, 0) |
367 | 302 | #~ return | 304 | #~ return |
368 | 303 | 305 | ||
369 | @@ -306,17 +308,17 @@ | |||
370 | 306 | #~ frame.set_header_expand(False) | 308 | #~ frame.set_header_expand(False) |
371 | 307 | #~ frame.set_header_position(HeaderPosition.LEFT) | 309 | #~ frame.set_header_position(HeaderPosition.LEFT) |
372 | 308 | #~ frame.set_header_label(_("Latest Demo Videos")) | 310 | #~ frame.set_header_label(_("Latest Demo Videos")) |
374 | 309 | #~ | 311 | #~ |
375 | 310 | #~ label = Gtk.Label.new("Videos go here") | 312 | #~ label = Gtk.Label.new("Videos go here") |
376 | 311 | #~ label.set_name("placeholder") | 313 | #~ label.set_name("placeholder") |
377 | 312 | #~ label.set_size_request(-1, 200) | 314 | #~ label.set_size_request(-1, 200) |
379 | 313 | #~ | 315 | #~ |
380 | 314 | #~ frame.add(label) | 316 | #~ frame.add(label) |
382 | 315 | #~ | 317 | #~ |
383 | 316 | #~ alignment = Gtk.Alignment() | 318 | #~ alignment = Gtk.Alignment() |
384 | 317 | #~ alignment.set_padding(0, 0, self.PADDING, self.PADDING) | 319 | #~ alignment.set_padding(0, 0, self.PADDING, self.PADDING) |
385 | 318 | #~ alignment.add(frame) | 320 | #~ alignment.add(frame) |
387 | 319 | #~ | 321 | #~ |
388 | 320 | #~ self.vbox.pack_start(alignment, False, False, 0) | 322 | #~ self.vbox.pack_start(alignment, False, False, 0) |
389 | 321 | #~ return | 323 | #~ return |
390 | 322 | 324 | ||
391 | @@ -343,18 +345,19 @@ | |||
392 | 343 | # query using the agent | 345 | # query using the agent |
393 | 344 | scagent = SoftwareCenterAgent() | 346 | scagent = SoftwareCenterAgent() |
394 | 345 | scagent.connect( | 347 | scagent.connect( |
396 | 346 | "exhibits", lambda sca,l: exhibit_banner.set_exhibits(l)) | 348 | "exhibits", lambda sca, l: exhibit_banner.set_exhibits(l)) |
397 | 347 | scagent.query_exhibits() | 349 | scagent.query_exhibits() |
398 | 348 | 350 | ||
399 | 349 | a = Gtk.Alignment() | 351 | a = Gtk.Alignment() |
401 | 350 | a.set_padding(0,StockEms.SMALL,0,0) | 352 | a.set_padding(0, StockEms.SMALL, 0, 0) |
402 | 351 | a.add(exhibit_banner) | 353 | a.add(exhibit_banner) |
403 | 352 | 354 | ||
404 | 353 | self.vbox.pack_start(a, False, False, 0) | 355 | self.vbox.pack_start(a, False, False, 0) |
405 | 354 | return | 356 | return |
406 | 355 | 357 | ||
407 | 356 | def _append_departments(self): | 358 | def _append_departments(self): |
409 | 357 | # set the departments section to use the label markup we have just defined | 359 | # set the departments section to use the label markup we have just |
410 | 360 | # defined | ||
411 | 358 | cat_vbox = FramedBox(Gtk.Orientation.VERTICAL) | 361 | cat_vbox = FramedBox(Gtk.Orientation.VERTICAL) |
412 | 359 | self.top_hbox.pack_start(cat_vbox, False, False, 0) | 362 | self.top_hbox.pack_start(cat_vbox, False, False, 0) |
413 | 360 | 363 | ||
414 | @@ -363,7 +366,8 @@ | |||
415 | 363 | 366 | ||
416 | 364 | mrkup = "<small>%s</small>" | 367 | mrkup = "<small>%s</small>" |
417 | 365 | for cat in sorted_cats: | 368 | for cat in sorted_cats: |
419 | 366 | if 'carousel-only' in cat.flags: continue | 369 | if 'carousel-only' in cat.flags: |
420 | 370 | continue | ||
421 | 367 | category_name = mrkup % GObject.markup_escape_text(cat.name) | 371 | category_name = mrkup % GObject.markup_escape_text(cat.name) |
422 | 368 | label = LabelTile(category_name, None) | 372 | label = LabelTile(category_name, None) |
423 | 369 | label.label.set_margin_left(StockEms.SMALL) | 373 | label.label.set_margin_left(StockEms.SMALL) |
424 | @@ -400,8 +404,8 @@ | |||
425 | 400 | # only display the 'More' LinkButton if we have top_rated content | 404 | # only display the 'More' LinkButton if we have top_rated content |
426 | 401 | if top_rated_cat is not None: | 405 | if top_rated_cat is not None: |
427 | 402 | self.top_rated_frame.header_implements_more_button() | 406 | self.top_rated_frame.header_implements_more_button() |
430 | 403 | self.top_rated_frame.more.connect('clicked', | 407 | self.top_rated_frame.more.connect('clicked', |
431 | 404 | self.on_category_clicked, top_rated_cat) | 408 | self.on_category_clicked, top_rated_cat) |
432 | 405 | return | 409 | return |
433 | 406 | 410 | ||
434 | 407 | def _update_whats_new_content(self): | 411 | def _update_whats_new_content(self): |
435 | @@ -409,7 +413,7 @@ | |||
436 | 409 | self.whats_new.remove_all() | 413 | self.whats_new.remove_all() |
437 | 410 | # get top_rated category and docs | 414 | # get top_rated category and docs |
438 | 411 | whats_new_cat = get_category_by_name( | 415 | whats_new_cat = get_category_by_name( |
440 | 412 | self.categories, u"What\u2019s New") # untranslated name | 416 | self.categories, u"What\u2019s New") # untranslated name |
441 | 413 | if whats_new_cat: | 417 | if whats_new_cat: |
442 | 414 | docs = whats_new_cat.get_documents(self.db) | 418 | docs = whats_new_cat.get_documents(self.db) |
443 | 415 | self._add_tiles_to_flowgrid(docs, self.whats_new, 8) | 419 | self._add_tiles_to_flowgrid(docs, self.whats_new, 8) |
444 | @@ -428,33 +432,33 @@ | |||
445 | 428 | self.right_column.pack_start(self.whats_new_frame, True, True, 0) | 432 | self.right_column.pack_start(self.whats_new_frame, True, True, 0) |
446 | 429 | self.whats_new_frame.header_implements_more_button() | 433 | self.whats_new_frame.header_implements_more_button() |
447 | 430 | self.whats_new_frame.more.connect( | 434 | self.whats_new_frame.more.connect( |
451 | 431 | 'clicked', self.on_category_clicked, whats_new_cat) | 435 | 'clicked', self.on_category_clicked, whats_new_cat) |
452 | 432 | return | 436 | |
450 | 433 | |||
453 | 434 | def _update_recommended_for_you_content(self): | 437 | def _update_recommended_for_you_content(self): |
454 | 435 | if (self.recommended_for_you_panel and | 438 | if (self.recommended_for_you_panel and |
455 | 436 | self.recommended_for_you_panel.get_parent()): | 439 | self.recommended_for_you_panel.get_parent()): |
456 | 437 | self.bottom_hbox.remove(self.recommended_for_you_panel) | 440 | self.bottom_hbox.remove(self.recommended_for_you_panel) |
457 | 438 | self.recommended_for_you_panel = RecommendationsPanelLobby(self) | 441 | self.recommended_for_you_panel = RecommendationsPanelLobby(self) |
459 | 439 | self.bottom_hbox.pack_start(self.recommended_for_you_panel, | 442 | self.bottom_hbox.pack_start(self.recommended_for_you_panel, |
460 | 440 | True, True, 0) | 443 | True, True, 0) |
462 | 441 | 444 | ||
463 | 442 | def _append_recommended_for_you(self): | 445 | def _append_recommended_for_you(self): |
464 | 443 | # TODO: This space will initially contain an opt-in screen, and this | 446 | # TODO: This space will initially contain an opt-in screen, and this |
465 | 444 | # will update to the tile view of recommended apps when ready | 447 | # will update to the tile view of recommended apps when ready |
466 | 445 | # see https://wiki.ubuntu.com/SoftwareCenter#Home_screen | 448 | # see https://wiki.ubuntu.com/SoftwareCenter#Home_screen |
467 | 446 | self.bottom_hbox = Gtk.HBox(spacing=StockEms.SMALL) | 449 | self.bottom_hbox = Gtk.HBox(spacing=StockEms.SMALL) |
468 | 447 | bottom_hbox_alignment = Gtk.Alignment() | 450 | bottom_hbox_alignment = Gtk.Alignment() |
470 | 448 | bottom_hbox_alignment.set_padding(0, 0, StockEms.MEDIUM-2, StockEms.MEDIUM-2) | 451 | bottom_hbox_alignment.set_padding(0, 0, StockEms.MEDIUM - 2, |
471 | 452 | StockEms.MEDIUM - 2) | ||
472 | 449 | bottom_hbox_alignment.add(self.bottom_hbox) | 453 | bottom_hbox_alignment.add(self.bottom_hbox) |
473 | 450 | self.vbox.pack_start(bottom_hbox_alignment, False, False, 0) | 454 | self.vbox.pack_start(bottom_hbox_alignment, False, False, 0) |
475 | 451 | 455 | ||
476 | 452 | # TODO: During development, place the "Recommended for You" panel | 456 | # TODO: During development, place the "Recommended for You" panel |
477 | 453 | # at the bottom, but swap this with the Top Rated panel once | 457 | # at the bottom, but swap this with the Top Rated panel once |
478 | 454 | # the recommended for you pieces are done and deployed | 458 | # the recommended for you pieces are done and deployed |
479 | 455 | # see https://wiki.ubuntu.com/SoftwareCenter#Home_screen | 459 | # see https://wiki.ubuntu.com/SoftwareCenter#Home_screen |
480 | 456 | self.recommended_for_you_panel = RecommendationsPanelLobby(self) | 460 | self.recommended_for_you_panel = RecommendationsPanelLobby(self) |
482 | 457 | self.bottom_hbox.pack_start(self.recommended_for_you_panel, | 461 | self.bottom_hbox.pack_start(self.recommended_for_you_panel, |
483 | 458 | True, True, 0) | 462 | True, True, 0) |
484 | 459 | 463 | ||
485 | 460 | def _update_appcount(self): | 464 | def _update_appcount(self): |
486 | @@ -468,7 +472,7 @@ | |||
487 | 468 | 472 | ||
488 | 469 | length = enq.get_estimated_matches_count(query) | 473 | length = enq.get_estimated_matches_count(query) |
489 | 470 | text = gettext.ngettext("%(amount)s item", "%(amount)s items", length | 474 | text = gettext.ngettext("%(amount)s item", "%(amount)s items", length |
491 | 471 | ) % { 'amount' : length, } | 475 | ) % {'amount': length} |
492 | 472 | self.appcount.set_text(text) | 476 | self.appcount.set_text(text) |
493 | 473 | 477 | ||
494 | 474 | def _append_appcount(self): | 478 | def _append_appcount(self): |
495 | @@ -499,7 +503,7 @@ | |||
496 | 499 | self._update_appcount() | 503 | self._update_appcount() |
497 | 500 | return | 504 | return |
498 | 501 | 505 | ||
500 | 502 | # stubs for the time being, we may reuse them if we get dynamic content | 506 | # stubs for the time being, we may reuse them if we get dynamic content |
501 | 503 | # again | 507 | # again |
502 | 504 | def stop_carousels(self): | 508 | def stop_carousels(self): |
503 | 505 | pass | 509 | pass |
504 | @@ -507,6 +511,7 @@ | |||
505 | 507 | def start_carousels(self): | 511 | def start_carousels(self): |
506 | 508 | pass | 512 | pass |
507 | 509 | 513 | ||
508 | 514 | |||
509 | 510 | class SubCategoryViewGtk(CategoriesViewGtk): | 515 | class SubCategoryViewGtk(CategoriesViewGtk): |
510 | 511 | 516 | ||
511 | 512 | def __init__(self, datadir, desktopdir, cache, db, icons, | 517 | def __init__(self, datadir, desktopdir, cache, db, icons, |
512 | @@ -529,8 +534,8 @@ | |||
513 | 529 | self.appcount = None | 534 | self.appcount = None |
514 | 530 | 535 | ||
515 | 531 | # widgetry | 536 | # widgetry |
518 | 532 | self.vbox.set_margin_left(StockEms.MEDIUM-2) | 537 | self.vbox.set_margin_left(StockEms.MEDIUM - 2) |
519 | 533 | self.vbox.set_margin_right(StockEms.MEDIUM-2) | 538 | self.vbox.set_margin_right(StockEms.MEDIUM - 2) |
520 | 534 | self.vbox.set_margin_top(StockEms.MEDIUM) | 539 | self.vbox.set_margin_top(StockEms.MEDIUM) |
521 | 535 | return | 540 | return |
522 | 536 | 541 | ||
523 | @@ -544,15 +549,17 @@ | |||
524 | 544 | nonblocking_load=False) | 549 | nonblocking_load=False) |
525 | 545 | return self.enquire.get_documents() | 550 | return self.enquire.get_documents() |
526 | 546 | 551 | ||
528 | 547 | @wait_for_apt_cache_ready # be consistent with new apps | 552 | @wait_for_apt_cache_ready # be consistent with new apps |
529 | 548 | def _update_sub_top_rated_content(self, category): | 553 | def _update_sub_top_rated_content(self, category): |
530 | 549 | self.top_rated.remove_all() | 554 | self.top_rated.remove_all() |
531 | 550 | # FIXME: should this be m = "%s %s" % (_(gettext text), header text) ?? | 555 | # FIXME: should this be m = "%s %s" % (_(gettext text), header text) ?? |
534 | 551 | # TRANSLATORS: %s is a category name, like Internet or Development Tools | 556 | # TRANSLATORS: %s is a category name, like Internet or Development |
535 | 552 | m = _('Top Rated %(category)s') % { 'category' : GObject.markup_escape_text(self.header)} | 557 | # Tools |
536 | 558 | m = _('Top Rated %(category)s') % { | ||
537 | 559 | 'category': GObject.markup_escape_text(self.header)} | ||
538 | 553 | self.top_rated_frame.set_header_label(m) | 560 | self.top_rated_frame.set_header_label(m) |
539 | 554 | docs = self._get_sub_top_rated_content(category) | 561 | docs = self._get_sub_top_rated_content(category) |
541 | 555 | self._add_tiles_to_flowgrid(docs, self.top_rated, | 562 | self._add_tiles_to_flowgrid(docs, self.top_rated, |
542 | 556 | TOP_RATED_CAROUSEL_LIMIT) | 563 | TOP_RATED_CAROUSEL_LIMIT) |
543 | 557 | return | 564 | return |
544 | 558 | 565 | ||
545 | @@ -570,7 +577,8 @@ | |||
546 | 570 | 577 | ||
547 | 571 | # set the subcat header | 578 | # set the subcat header |
548 | 572 | m = "<b><big>%s</big></b>" | 579 | m = "<b><big>%s</big></b>" |
550 | 573 | self.subcat_label.set_markup(m % GObject.markup_escape_text(self.header)) | 580 | self.subcat_label.set_markup(m % GObject.markup_escape_text( |
551 | 581 | self.header)) | ||
552 | 574 | 582 | ||
553 | 575 | # sort Category.name's alphabetically | 583 | # sort Category.name's alphabetically |
554 | 576 | sorted_cats = categories_sorted_by_name(self.categories) | 584 | sorted_cats = categories_sorted_by_name(self.categories) |
555 | @@ -580,14 +588,14 @@ | |||
556 | 580 | # add the subcategory if and only if it is non-empty | 588 | # add the subcategory if and only if it is non-empty |
557 | 581 | enquire.set_query(cat.query) | 589 | enquire.set_query(cat.query) |
558 | 582 | 590 | ||
560 | 583 | if len(enquire.get_mset(0,1)): | 591 | if len(enquire.get_mset(0, 1)): |
561 | 584 | tile = CategoryTile(cat.name, cat.iconname) | 592 | tile = CategoryTile(cat.name, cat.iconname) |
562 | 585 | tile.connect('clicked', self.on_category_clicked, cat) | 593 | tile.connect('clicked', self.on_category_clicked, cat) |
563 | 586 | self.departments.add_child(tile) | 594 | self.departments.add_child(tile) |
564 | 587 | 595 | ||
565 | 588 | # partialy work around a (quite rare) corner case | 596 | # partialy work around a (quite rare) corner case |
566 | 589 | if num_items == 0: | 597 | if num_items == 0: |
568 | 590 | enquire.set_query(xapian.Query(xapian.Query.OP_AND, | 598 | enquire.set_query(xapian.Query(xapian.Query.OP_AND, |
569 | 591 | category.query, | 599 | category.query, |
570 | 592 | xapian.Query("ATapplication"))) | 600 | xapian.Query("ATapplication"))) |
571 | 593 | # assuming that we only want apps is not always correct ^^^ | 601 | # assuming that we only want apps is not always correct ^^^ |
572 | @@ -595,7 +603,8 @@ | |||
573 | 595 | num_items = tmp_matches.get_matches_estimated() | 603 | num_items = tmp_matches.get_matches_estimated() |
574 | 596 | 604 | ||
575 | 597 | # append an additional button to show all of the items in the category | 605 | # append an additional button to show all of the items in the category |
577 | 598 | all_cat = Category("All", _("All"), "category-show-all", category.query) | 606 | all_cat = Category("All", _("All"), "category-show-all", |
578 | 607 | category.query) | ||
579 | 599 | name = GObject.markup_escape_text('%s %s' % (_("All"), num_items)) | 608 | name = GObject.markup_escape_text('%s %s' % (_("All"), num_items)) |
580 | 600 | tile = CategoryTile(name, "category-show-all") | 609 | tile = CategoryTile(name, "category-show-all") |
581 | 601 | tile.connect('clicked', self.on_category_clicked, all_cat) | 610 | tile.connect('clicked', self.on_category_clicked, all_cat) |
582 | @@ -622,7 +631,7 @@ | |||
583 | 622 | def _update_appcount(self, appcount): | 631 | def _update_appcount(self, appcount): |
584 | 623 | text = gettext.ngettext("%(amount)s item available", | 632 | text = gettext.ngettext("%(amount)s item available", |
585 | 624 | "%(amount)s items available", | 633 | "%(amount)s items available", |
587 | 625 | appcount) % { 'amount' : appcount, } | 634 | appcount) % {'amount': appcount} |
588 | 626 | self.appcount.set_text(text) | 635 | self.appcount.set_text(text) |
589 | 627 | return | 636 | return |
590 | 628 | 637 | ||
591 | @@ -660,7 +669,8 @@ | |||
592 | 660 | self.header = root_category.name | 669 | self.header = root_category.name |
593 | 661 | self.categories = root_category.subcategories | 670 | self.categories = root_category.subcategories |
594 | 662 | 671 | ||
596 | 663 | if not self._built: self._build_subcat_view() | 672 | if not self._built: |
597 | 673 | self._build_subcat_view() | ||
598 | 664 | self._update_subcat_view(root_category, num_items) | 674 | self._update_subcat_view(root_category, num_items) |
599 | 665 | 675 | ||
600 | 666 | GObject.idle_add(self.queue_draw) | 676 | GObject.idle_add(self.queue_draw) |
601 | @@ -673,7 +683,8 @@ | |||
602 | 673 | return | 683 | return |
603 | 674 | self._supported_only = supported_only | 684 | self._supported_only = supported_only |
604 | 675 | 685 | ||
606 | 676 | if not self._built: self._build_subcat_view() | 686 | if not self._built: |
607 | 687 | self._build_subcat_view() | ||
608 | 677 | self._update_subcat_view(self.current_category) | 688 | self._update_subcat_view(self.current_category) |
609 | 678 | GObject.idle_add(self.queue_draw) | 689 | GObject.idle_add(self.queue_draw) |
610 | 679 | return | 690 | return |
611 | @@ -683,6 +694,7 @@ | |||
612 | 683 | #self.set_subcategory(self.root_category) | 694 | #self.set_subcategory(self.root_category) |
613 | 684 | #return | 695 | #return |
614 | 685 | 696 | ||
615 | 697 | |||
616 | 686 | def get_test_window_catview(): | 698 | def get_test_window_catview(): |
617 | 687 | 699 | ||
618 | 688 | def on_category_selected(view, cat): | 700 | def on_category_selected(view, cat): |
619 | @@ -740,11 +752,12 @@ | |||
620 | 740 | n.append_page(scroll, Gtk.Label(label="Subcats")) | 752 | n.append_page(scroll, Gtk.Label(label="Subcats")) |
621 | 741 | 753 | ||
622 | 742 | win.add(n) | 754 | win.add(n) |
624 | 743 | win.set_size_request(800,800) | 755 | win.set_size_request(800, 800) |
625 | 744 | win.show_all() | 756 | win.show_all() |
626 | 745 | win.connect('destroy', Gtk.main_quit) | 757 | win.connect('destroy', Gtk.main_quit) |
627 | 746 | return win | 758 | return win |
629 | 747 | 759 | ||
630 | 760 | |||
631 | 748 | def get_test_catview(): | 761 | def get_test_catview(): |
632 | 749 | 762 | ||
633 | 750 | def on_category_selected(view, cat): | 763 | def on_category_selected(view, cat): |
634 | @@ -784,5 +797,3 @@ | |||
635 | 784 | 797 | ||
636 | 785 | # run it | 798 | # run it |
637 | 786 | Gtk.main() | 799 | Gtk.main() |
638 | 787 | |||
639 | 788 | |||
640 | 789 | 800 | ||
641 | === modified file 'softwarecenter/ui/gtk3/views/pkgnamesview.py' | |||
642 | --- softwarecenter/ui/gtk3/views/pkgnamesview.py 2011-08-08 07:45:20 +0000 | |||
643 | +++ softwarecenter/ui/gtk3/views/pkgnamesview.py 2012-03-14 16:41:35 +0000 | |||
644 | @@ -27,6 +27,7 @@ | |||
645 | 27 | 27 | ||
646 | 28 | LOG = logging.getLogger(__name__) | 28 | LOG = logging.getLogger(__name__) |
647 | 29 | 29 | ||
648 | 30 | |||
649 | 30 | class PackageNamesView(Gtk.TreeView): | 31 | class PackageNamesView(Gtk.TreeView): |
650 | 31 | """ A simple widget that presents a list of packages, with | 32 | """ A simple widget that presents a list of packages, with |
651 | 32 | associated icons, in a treeview. Note the for current | 33 | associated icons, in a treeview. Note the for current |
652 | @@ -52,7 +53,7 @@ | |||
653 | 52 | continue | 53 | continue |
654 | 53 | s = "%s \n<small>%s</small>" % ( | 54 | s = "%s \n<small>%s</small>" % ( |
655 | 54 | cache[pkgname].installed.summary.capitalize(), pkgname) | 55 | cache[pkgname].installed.summary.capitalize(), pkgname) |
657 | 55 | 56 | ||
658 | 56 | app_details = Application("", pkgname).get_details(db) | 57 | app_details = Application("", pkgname).get_details(db) |
659 | 57 | proposed_icon = app_details.icon | 58 | proposed_icon = app_details.icon |
660 | 58 | if not proposed_icon or not icons.has_icon(proposed_icon): | 59 | if not proposed_icon or not icons.has_icon(proposed_icon): |
661 | @@ -65,11 +66,11 @@ | |||
662 | 65 | LOG.warn("cant set icon for '%s' " % pkgname) | 66 | LOG.warn("cant set icon for '%s' " % pkgname) |
663 | 66 | pb = icons.load_icon(Icons.MISSING_APP, | 67 | pb = icons.load_icon(Icons.MISSING_APP, |
664 | 67 | icon_size, | 68 | icon_size, |
667 | 68 | Gtk.IconLookupFlags.GENERIC_FALLBACK) | 69 | Gtk.IconLookupFlags.GENERIC_FALLBACK) |
668 | 69 | pb = pb.scale_simple(icon_size, | 70 | pb = pb.scale_simple(icon_size, |
669 | 70 | icon_size, GdkPixbuf.InterpType.BILINEAR) | 71 | icon_size, GdkPixbuf.InterpType.BILINEAR) |
670 | 71 | model.append([pb, s]) | 72 | model.append([pb, s]) |
672 | 72 | 73 | ||
673 | 73 | # finally, we don't allow selection, it's just a simple display list | 74 | # finally, we don't allow selection, it's just a simple display list |
674 | 74 | tree_selection = self.get_selection() | 75 | tree_selection = self.get_selection() |
675 | 75 | tree_selection.set_mode(Gtk.SelectionMode.NONE) | 76 | tree_selection.set_mode(Gtk.SelectionMode.NONE) |
676 | @@ -87,19 +88,19 @@ | |||
677 | 87 | db = StoreDatabase(pathname, cache) | 88 | db = StoreDatabase(pathname, cache) |
678 | 88 | db.open() | 89 | db.open() |
679 | 89 | 90 | ||
681 | 90 | import softwarecenter.paths | 91 | import softwarecenter.paths |
682 | 91 | datadir = softwarecenter.paths.datadir | 92 | datadir = softwarecenter.paths.datadir |
683 | 92 | 93 | ||
684 | 93 | from softwarecenter.ui.gtk3.utils import get_sc_icon_theme | 94 | from softwarecenter.ui.gtk3.utils import get_sc_icon_theme |
685 | 94 | icons = get_sc_icon_theme(datadir) | 95 | icons = get_sc_icon_theme(datadir) |
687 | 95 | 96 | ||
688 | 96 | pkgs = ["apt", "software-center"] | 97 | pkgs = ["apt", "software-center"] |
689 | 97 | view = PackageNamesView("header", cache, pkgs, icons, 32, db) | 98 | view = PackageNamesView("header", cache, pkgs, icons, 32, db) |
690 | 98 | view.show() | 99 | view.show() |
691 | 99 | 100 | ||
692 | 100 | win = Gtk.Window() | 101 | win = Gtk.Window() |
693 | 101 | win.add(view) | 102 | win.add(view) |
695 | 102 | win.set_size_request(600,400) | 103 | win.set_size_request(600, 400) |
696 | 103 | win.show() | 104 | win.show() |
697 | 104 | win.connect('destroy', Gtk.main_quit) | 105 | win.connect('destroy', Gtk.main_quit) |
698 | 105 | return win | 106 | return win |
699 | 106 | 107 | ||
700 | === modified file 'softwarecenter/ui/gtk3/views/purchaseview.py' | |||
701 | --- softwarecenter/ui/gtk3/views/purchaseview.py 2012-02-09 10:34:40 +0000 | |||
702 | +++ softwarecenter/ui/gtk3/views/purchaseview.py 2012-03-14 16:41:35 +0000 | |||
703 | @@ -36,12 +36,13 @@ | |||
704 | 36 | 36 | ||
705 | 37 | LOG = logging.getLogger(__name__) | 37 | LOG = logging.getLogger(__name__) |
706 | 38 | 38 | ||
707 | 39 | |||
708 | 39 | class LocaleAwareWebView(webkit.WebView): | 40 | class LocaleAwareWebView(webkit.WebView): |
710 | 40 | 41 | ||
711 | 41 | def __init__(self): | 42 | def __init__(self): |
712 | 42 | # actual webkit init | 43 | # actual webkit init |
713 | 43 | webkit.WebView.__init__(self) | 44 | webkit.WebView.__init__(self) |
715 | 44 | self.connect("resource-request-starting", | 45 | self.connect("resource-request-starting", |
716 | 45 | self._on_resource_request_starting) | 46 | self._on_resource_request_starting) |
717 | 46 | 47 | ||
718 | 47 | def _on_resource_request_starting(self, view, frame, res, req, resp): | 48 | def _on_resource_request_starting(self, view, frame, res, req, resp): |
719 | @@ -69,12 +70,13 @@ | |||
720 | 69 | self._add_progress_ui() | 70 | self._add_progress_ui() |
721 | 70 | # create main webkitview | 71 | # create main webkitview |
722 | 71 | self.scroll = Gtk.ScrolledWindow() | 72 | self.scroll = Gtk.ScrolledWindow() |
724 | 72 | self.scroll.set_policy(Gtk.PolicyType.AUTOMATIC, | 73 | self.scroll.set_policy(Gtk.PolicyType.AUTOMATIC, |
725 | 73 | Gtk.PolicyType.AUTOMATIC) | 74 | Gtk.PolicyType.AUTOMATIC) |
726 | 74 | self.pack_start(self.scroll, True, True, 0) | 75 | self.pack_start(self.scroll, True, True, 0) |
727 | 75 | # embed the webkit view in a scrolled window | 76 | # embed the webkit view in a scrolled window |
728 | 76 | self.scroll.add(self.webkit) | 77 | self.scroll.add(self.webkit) |
729 | 77 | self.show_all() | 78 | self.show_all() |
730 | 79 | |||
731 | 78 | def _add_progress_ui(self): | 80 | def _add_progress_ui(self): |
732 | 79 | # create toolbar box | 81 | # create toolbar box |
733 | 80 | self.header = Gtk.HBox() | 82 | self.header = Gtk.HBox() |
734 | @@ -94,7 +96,9 @@ | |||
735 | 94 | self.pack_start(self.frame, False, False, 6) | 96 | self.pack_start(self.frame, False, False, 6) |
736 | 95 | # connect the webkit stuff | 97 | # connect the webkit stuff |
737 | 96 | self.webkit.connect("notify::uri", self._on_uri_changed) | 98 | self.webkit.connect("notify::uri", self._on_uri_changed) |
739 | 97 | self.webkit.connect("notify::load-status", self._on_load_status_changed) | 99 | self.webkit.connect("notify::load-status", |
740 | 100 | self._on_load_status_changed) | ||
741 | 101 | |||
742 | 98 | def _on_uri_changed(self, view, pspec): | 102 | def _on_uri_changed(self, view, pspec): |
743 | 99 | prop = pspec.name | 103 | prop = pspec.name |
744 | 100 | uri = view.get_property(prop) | 104 | uri = view.get_property(prop) |
745 | @@ -108,6 +112,7 @@ | |||
746 | 108 | self.url.set_text("%s://%s" % (scheme, netloc)) | 112 | self.url.set_text("%s://%s" % (scheme, netloc)) |
747 | 109 | # start spinner when the uri changes | 113 | # start spinner when the uri changes |
748 | 110 | #self.spinner.start() | 114 | #self.spinner.start() |
749 | 115 | |||
750 | 111 | def _on_load_status_changed(self, view, pspec): | 116 | def _on_load_status_changed(self, view, pspec): |
751 | 112 | prop = pspec.name | 117 | prop = pspec.name |
752 | 113 | status = view.get_property(prop) | 118 | status = view.get_property(prop) |
753 | @@ -119,14 +124,13 @@ | |||
754 | 119 | status == webkit.LoadStatus.FAILED): | 124 | status == webkit.LoadStatus.FAILED): |
755 | 120 | self.spinner.stop() | 125 | self.spinner.stop() |
756 | 121 | self.spinner.hide() | 126 | self.spinner.hide() |
757 | 122 | |||
758 | 123 | 127 | ||
759 | 124 | 128 | ||
760 | 125 | class PurchaseView(Gtk.VBox): | 129 | class PurchaseView(Gtk.VBox): |
765 | 126 | """ | 130 | """ |
766 | 127 | View that displays the webkit-based UI for purchasing an item. | 131 | View that displays the webkit-based UI for purchasing an item. |
767 | 128 | """ | 132 | """ |
768 | 129 | 133 | ||
769 | 130 | LOADING_HTML = """ | 134 | LOADING_HTML = """ |
770 | 131 | <html> | 135 | <html> |
771 | 132 | <head> | 136 | <head> |
772 | @@ -151,7 +155,8 @@ | |||
773 | 151 | vertical-align: middle; | 155 | vertical-align: middle; |
774 | 152 | } | 156 | } |
775 | 153 | h1 { | 157 | h1 { |
777 | 154 | background: url(file:///usr/share/software-center/images/spinner.gif) top center no-repeat; | 158 | background: url(file:///usr/share/software-center/images/spinner.gif) top \ |
778 | 159 | center no-repeat; | ||
779 | 155 | padding-top: 48px; /* leaves room for the spinner above */ | 160 | padding-top: 48px; /* leaves room for the spinner above */ |
780 | 156 | font-size: 100%%; | 161 | font-size: 100%%; |
781 | 157 | font-weight: normal; | 162 | font-weight: normal; |
782 | @@ -164,19 +169,19 @@ | |||
783 | 164 | """ % _("Connecting to payment service...") | 169 | """ % _("Connecting to payment service...") |
784 | 165 | 170 | ||
785 | 166 | __gsignals__ = { | 171 | __gsignals__ = { |
799 | 167 | 'purchase-succeeded' : (GObject.SignalFlags.RUN_LAST, | 172 | 'purchase-succeeded': (GObject.SignalFlags.RUN_LAST, |
800 | 168 | None, | 173 | None, |
801 | 169 | ()), | 174 | ()), |
802 | 170 | 'purchase-failed' : (GObject.SignalFlags.RUN_LAST, | 175 | 'purchase-failed': (GObject.SignalFlags.RUN_LAST, |
803 | 171 | None, | 176 | None, |
804 | 172 | ()), | 177 | ()), |
805 | 173 | 'purchase-cancelled-by-user' : (GObject.SignalFlags.RUN_LAST, | 178 | 'purchase-cancelled-by-user': (GObject.SignalFlags.RUN_LAST, |
806 | 174 | None, | 179 | None, |
807 | 175 | ()), | 180 | ()), |
808 | 176 | 'purchase-needs-spinner' : (GObject.SignalFlags.RUN_LAST, | 181 | 'purchase-needs-spinner': (GObject.SignalFlags.RUN_LAST, |
809 | 177 | None, | 182 | None, |
810 | 178 | (bool, )), | 183 | (bool, )), |
811 | 179 | 184 | ||
812 | 180 | } | 185 | } |
813 | 181 | 186 | ||
814 | 182 | def __init__(self): | 187 | def __init__(self): |
815 | @@ -188,7 +193,8 @@ | |||
816 | 188 | def init_view(self): | 193 | def init_view(self): |
817 | 189 | if self.wk is None: | 194 | if self.wk is None: |
818 | 190 | self.wk = ScrolledWebkitWindow() | 195 | self.wk = ScrolledWebkitWindow() |
820 | 191 | #self.wk.webkit.connect("new-window-policy-decision-requested", self._on_new_window) | 196 | #self.wk.webkit.connect("new-window-policy-decision-requested", |
821 | 197 | # self._on_new_window) | ||
822 | 192 | self.wk.webkit.connect("create-web-view", self._on_create_web_view) | 198 | self.wk.webkit.connect("create-web-view", self._on_create_web_view) |
823 | 193 | self.wk.webkit.connect("close-web-view", self._on_close_web_view) | 199 | self.wk.webkit.connect("close-web-view", self._on_close_web_view) |
824 | 194 | self.wk.webkit.connect("console-message", self._on_console_message) | 200 | self.wk.webkit.connect("console-message", self._on_console_message) |
825 | @@ -196,15 +202,17 @@ | |||
826 | 196 | # a possible way to do IPC (script or title change) | 202 | # a possible way to do IPC (script or title change) |
827 | 197 | self.wk.webkit.connect("script-alert", self._on_script_alert) | 203 | self.wk.webkit.connect("script-alert", self._on_script_alert) |
828 | 198 | self.wk.webkit.connect("title-changed", self._on_title_changed) | 204 | self.wk.webkit.connect("title-changed", self._on_title_changed) |
832 | 199 | self.wk.webkit.connect("notify::load-status", self._on_load_status_changed) | 205 | self.wk.webkit.connect("notify::load-status", |
833 | 200 | # unblock signal handlers if needed when showing the purchase webkit view in | 206 | self._on_load_status_changed) |
834 | 201 | # case they were blocked after a previous purchase was completed or canceled | 207 | # unblock signal handlers if needed when showing the purchase webkit |
835 | 208 | # view in case they were blocked after a previous purchase was | ||
836 | 209 | # completed or canceled | ||
837 | 202 | self._unblock_wk_handlers() | 210 | self._unblock_wk_handlers() |
838 | 203 | 211 | ||
839 | 204 | def initiate_purchase(self, app, iconname, url=None, html=None): | 212 | def initiate_purchase(self, app, iconname, url=None, html=None): |
840 | 205 | """ | 213 | """ |
841 | 206 | initiates the purchase workflow inside the embedded webkit window | 214 | initiates the purchase workflow inside the embedded webkit window |
843 | 207 | for the item specified | 215 | for the item specified |
844 | 208 | """ | 216 | """ |
845 | 209 | self.init_view() | 217 | self.init_view() |
846 | 210 | self.app = app | 218 | self.app = app |
847 | @@ -223,7 +231,7 @@ | |||
848 | 223 | # only for debugging | 231 | # only for debugging |
849 | 224 | if os.environ.get("SOFTWARE_CENTER_DEBUG_BUY"): | 232 | if os.environ.get("SOFTWARE_CENTER_DEBUG_BUY"): |
850 | 225 | GObject.timeout_add_seconds(1, _generate_events, self) | 233 | GObject.timeout_add_seconds(1, _generate_events, self) |
852 | 226 | 234 | ||
853 | 227 | def _on_new_window(self, view, frame, request, action, policy): | 235 | def _on_new_window(self, view, frame, request, action, policy): |
854 | 228 | LOG.debug("_on_new_window") | 236 | LOG.debug("_on_new_window") |
855 | 229 | import subprocess | 237 | import subprocess |
856 | @@ -234,7 +242,7 @@ | |||
857 | 234 | win = view.get_data("win") | 242 | win = view.get_data("win") |
858 | 235 | win.destroy() | 243 | win.destroy() |
859 | 236 | return True | 244 | return True |
861 | 237 | 245 | ||
862 | 238 | def _on_create_web_view(self, view, frame): | 246 | def _on_create_web_view(self, view, frame): |
863 | 239 | win = Gtk.Window() | 247 | win = Gtk.Window() |
864 | 240 | win.set_size_request(400, 400) | 248 | win.set_size_request(400, 400) |
865 | @@ -261,7 +269,8 @@ | |||
866 | 261 | pass | 269 | pass |
867 | 262 | for k in ["token_key", "token_secret", "consumer_secret"]: | 270 | for k in ["token_key", "token_secret", "consumer_secret"]: |
868 | 263 | if k in message: | 271 | if k in message: |
870 | 264 | LOG.debug("skipping console message that contains sensitive data") | 272 | LOG.debug( |
871 | 273 | "skipping console message that contains sensitive data") | ||
872 | 265 | return True | 274 | return True |
873 | 266 | LOG.debug("_on_console_message '%s'" % message) | 275 | LOG.debug("_on_console_message '%s'" % message) |
874 | 267 | return False | 276 | return False |
875 | @@ -312,7 +321,8 @@ | |||
876 | 312 | return | 321 | return |
877 | 313 | # this is what the agent implements | 322 | # this is what the agent implements |
878 | 314 | elif "failures" in res: | 323 | elif "failures" in res: |
880 | 315 | LOG.error("the server returned a error: '%s'" % res["failures"]) | 324 | LOG.error("the server returned a error: '%s'" % |
881 | 325 | res["failures"]) | ||
882 | 316 | # show a generic error, the "failures" string we get from the | 326 | # show a generic error, the "failures" string we get from the |
883 | 317 | # server is way too technical to show, but we do log it | 327 | # server is way too technical to show, but we do log it |
884 | 318 | self.emit("purchase-failed") | 328 | self.emit("purchase-failed") |
885 | @@ -329,9 +339,9 @@ | |||
886 | 329 | # add repo and key | 339 | # add repo and key |
887 | 330 | backend = get_install_backend() | 340 | backend = get_install_backend() |
888 | 331 | backend.add_repo_add_key_and_install_app( | 341 | backend.add_repo_add_key_and_install_app( |
890 | 332 | deb_line, signing_key_id, self.app, self.iconname, | 342 | deb_line, signing_key_id, self.app, self.iconname, |
891 | 333 | license_key, license_key_path, json.dumps(self._oauth_token)) | 343 | license_key, license_key_path, json.dumps(self._oauth_token)) |
893 | 334 | 344 | ||
894 | 335 | def _block_wk_handlers(self): | 345 | def _block_wk_handlers(self): |
895 | 336 | # we need to block webkit signal handlers when we hide the | 346 | # we need to block webkit signal handlers when we hide the |
896 | 337 | # purchase webkit view, this prevents e.g. handling of signals on | 347 | # purchase webkit view, this prevents e.g. handling of signals on |
897 | @@ -341,14 +351,15 @@ | |||
898 | 341 | self.wk.webkit.handler_block_by_func(self._on_title_changed) | 351 | self.wk.webkit.handler_block_by_func(self._on_title_changed) |
899 | 342 | self.wk.webkit.handler_block_by_func(self._on_load_status_changed) | 352 | self.wk.webkit.handler_block_by_func(self._on_load_status_changed) |
900 | 343 | self._wk_handlers_blocked = True | 353 | self._wk_handlers_blocked = True |
902 | 344 | 354 | ||
903 | 345 | def _unblock_wk_handlers(self): | 355 | def _unblock_wk_handlers(self): |
904 | 346 | if self._wk_handlers_blocked: | 356 | if self._wk_handlers_blocked: |
905 | 347 | self.wk.webkit.handler_unblock_by_func(self._on_script_alert) | 357 | self.wk.webkit.handler_unblock_by_func(self._on_script_alert) |
906 | 348 | self.wk.webkit.handler_unblock_by_func(self._on_title_changed) | 358 | self.wk.webkit.handler_unblock_by_func(self._on_title_changed) |
908 | 349 | self.wk.webkit.handler_unblock_by_func(self._on_load_status_changed) | 359 | self.wk.webkit.handler_unblock_by_func( |
909 | 360 | self._on_load_status_changed) | ||
910 | 350 | self._wk_handlers_blocked = False | 361 | self._wk_handlers_blocked = False |
912 | 351 | 362 | ||
913 | 352 | 363 | ||
914 | 353 | # just used for testing -------------------------------------------- | 364 | # just used for testing -------------------------------------------- |
915 | 354 | DUMMY_HTML = """ | 365 | DUMMY_HTML = """ |
916 | @@ -361,11 +372,11 @@ | |||
917 | 361 | <body> | 372 | <body> |
918 | 362 | <script type="text/javascript"> | 373 | <script type="text/javascript"> |
919 | 363 | function changeTitle(title) { document.title = title; } | 374 | function changeTitle(title) { document.title = title; } |
925 | 364 | function success() { changeTitle('{ "successful" : true, \ | 375 | function success() { changeTitle('{"successful": true, "deb_line": \ |
926 | 365 | "deb_line" : "deb https://user:pass@private-ppa.launchpad.net/mvo/ubuntu lucid main", \ | 376 | "deb https://user:pass@private-ppa.launchpad.net/mvo/ubuntu lucid main", \ |
927 | 366 | "package_name" : "2vcard", \ | 377 | "package_name": "2vcard", \ |
928 | 367 | "application_name" : "The 2vcard app", \ | 378 | "application_name": "The 2vcard app", \ |
929 | 368 | "signing_key_id" : "1024R/0EB12F05"\ | 379 | "signing_key_id": "1024R/0EB12F05"\ |
930 | 369 | }') } | 380 | }') } |
931 | 370 | function cancel() { changeTitle('{ "successful" : false }') } | 381 | function cancel() { changeTitle('{ "successful" : false }') } |
932 | 371 | </script> | 382 | </script> |
933 | @@ -375,11 +386,11 @@ | |||
934 | 375 | <p> | 386 | <p> |
935 | 376 | <input type="entry"> | 387 | <input type="entry"> |
936 | 377 | </p> | 388 | </p> |
938 | 378 | <input type="button" name="test_button2" | 389 | <input type="button" name="test_button2" |
939 | 379 | value="Cancel" | 390 | value="Cancel" |
940 | 380 | onclick='cancel()' | 391 | onclick='cancel()' |
941 | 381 | /> | 392 | /> |
943 | 382 | <input type="button" name="test_button" | 393 | <input type="button" name="test_button" |
944 | 383 | value="Buy now" | 394 | value="Buy now" |
945 | 384 | onclick='success()' | 395 | onclick='success()' |
946 | 385 | /> | 396 | /> |
947 | @@ -387,30 +398,31 @@ | |||
948 | 387 | </html> | 398 | </html> |
949 | 388 | """ | 399 | """ |
950 | 389 | 400 | ||
951 | 401 | |||
952 | 390 | # synthetic key event generation | 402 | # synthetic key event generation |
953 | 391 | def _send_keys(view, s): | 403 | def _send_keys(view, s): |
954 | 392 | print("_send_keys %s" % s) | 404 | print("_send_keys %s" % s) |
963 | 393 | MAPPING = { '@' : 'at', | 405 | MAPPING = {'@': 'at', |
964 | 394 | '.' : 'period', | 406 | '.': 'period', |
965 | 395 | '\t' : 'Tab', | 407 | '\t': 'Tab', |
966 | 396 | '\n' : 'Return', | 408 | '\n': 'Return', |
967 | 397 | '?' : 'question', | 409 | '?': 'question', |
968 | 398 | '\a' : 'Down', # fake | 410 | '\a': 'Down', # fake |
969 | 399 | ' ' : 'space', | 411 | ' ': 'space', |
970 | 400 | '\v' : 'Page_Down', # fake | 412 | '\v': 'Page_Down', # fake |
971 | 401 | } | 413 | } |
973 | 402 | 414 | ||
974 | 403 | for key in s: | 415 | for key in s: |
975 | 404 | event = Gdk.Event(Gdk.KEY_PRESS) | 416 | event = Gdk.Event(Gdk.KEY_PRESS) |
976 | 405 | event.window = view.window | 417 | event.window = view.window |
977 | 406 | if key.isdigit(): | 418 | if key.isdigit(): |
979 | 407 | key = "_"+key | 419 | key = "_" + key |
980 | 408 | if hasattr(Gdk, key): | 420 | if hasattr(Gdk, key): |
981 | 409 | event.keyval = getattr(Gdk, key) | 421 | event.keyval = getattr(Gdk, key) |
982 | 410 | else: | 422 | else: |
983 | 411 | event.keyval = getattr(Gdk, MAPPING[key]) | 423 | event.keyval = getattr(Gdk, MAPPING[key]) |
984 | 412 | Gtk.main_do_event(event) | 424 | Gtk.main_do_event(event) |
986 | 413 | 425 | ||
987 | 414 | 426 | ||
988 | 415 | # \a means down key - its a just a fake to get it working | 427 | # \a means down key - its a just a fake to get it working |
989 | 416 | LOGIN = os.environ.get("SOFTWARE_CENTER_LOGIN") or "michael.vogt@ubuntu.com" | 428 | LOGIN = os.environ.get("SOFTWARE_CENTER_LOGIN") or "michael.vogt@ubuntu.com" |
990 | @@ -419,12 +431,14 @@ | |||
991 | 419 | PAYMENT_DETAILS = "\tstreet1\tstreet2\tcity\tstate\t1234\t\a\t\a\a\t"\ | 431 | PAYMENT_DETAILS = "\tstreet1\tstreet2\tcity\tstate\t1234\t\a\t\a\a\t"\ |
992 | 420 | "ACCEPTED\t4111111111111111\t1234\t\a\t\a\a\t\t\t \v" | 432 | "ACCEPTED\t4111111111111111\t1234\t\a\t\a\a\t\t\t \v" |
993 | 421 | # state-name, window title, keys | 433 | # state-name, window title, keys |
999 | 422 | STATES = [ ('login', 'Log in', LOGIN+"\t"), | 434 | STATES = [('login', 'Log in', LOGIN + "\t"), |
1000 | 423 | ('confirm-sso', 'Authenticate to', '\n'), | 435 | ('confirm-sso', 'Authenticate to', '\n'), |
1001 | 424 | ('enter-payment', 'Confirm Payment Details', PAYMENT_DETAILS), | 436 | ('enter-payment', 'Confirm Payment Details', PAYMENT_DETAILS), |
1002 | 425 | ('confirm-payment', 'title-the-same-as-before', '\t\n'), | 437 | ('confirm-payment', 'title-the-same-as-before', '\t\n'), |
1003 | 426 | ('end-state', 'no-title', ''), | 438 | ('end-state', 'no-title', ''), |
1004 | 427 | ] | 439 | ] |
1005 | 440 | |||
1006 | 441 | |||
1007 | 428 | def _generate_events(view): | 442 | def _generate_events(view): |
1008 | 429 | global STATES | 443 | global STATES |
1009 | 430 | 444 | ||
1010 | @@ -440,19 +454,20 @@ | |||
1011 | 440 | 454 | ||
1012 | 441 | return True | 455 | return True |
1013 | 442 | 456 | ||
1015 | 443 | # # for debugging only | 457 | # # for debugging only |
1016 | 444 | # def _on_key_press(dialog, event): | 458 | # def _on_key_press(dialog, event): |
1017 | 445 | # print event, event.keyval | 459 | # print event, event.keyval |
1018 | 446 | 460 | ||
1019 | 461 | |||
1020 | 447 | def get_test_window_purchaseview(): | 462 | def get_test_window_purchaseview(): |
1021 | 448 | #url = "http://www.animiertegifs.de/java-scripts/alertbox.php" | 463 | #url = "http://www.animiertegifs.de/java-scripts/alertbox.php" |
1022 | 449 | url = "http://www.ubuntu.cohtml=DUMMY_m" | 464 | url = "http://www.ubuntu.cohtml=DUMMY_m" |
1023 | 450 | #d = PurchaseDialog(app=None, url="http://spiegel.de") | 465 | #d = PurchaseDialog(app=None, url="http://spiegel.de") |
1024 | 451 | from softwarecenter.enums import BUY_SOMETHING_HOST | 466 | from softwarecenter.enums import BUY_SOMETHING_HOST |
1026 | 452 | url = BUY_SOMETHING_HOST+"/subscriptions/en/ubuntu/maverick/+new/?%s" % ( | 467 | url = BUY_SOMETHING_HOST + "/subscriptions/en/ubuntu/maverick/+new/?%s" % ( |
1027 | 453 | urllib.urlencode({ | 468 | urllib.urlencode({ |
1030 | 454 | 'archive_id' : "mvo/private-test", | 469 | 'archive_id': "mvo/private-test", |
1031 | 455 | 'arch' : "i386", | 470 | 'arch': "i386", |
1032 | 456 | })) | 471 | })) |
1033 | 457 | # use cmdline if available | 472 | # use cmdline if available |
1034 | 458 | if len(sys.argv) > 1: | 473 | if len(sys.argv) > 1: |
1035 | @@ -460,7 +475,7 @@ | |||
1036 | 460 | # useful for debugging | 475 | # useful for debugging |
1037 | 461 | #d.connect("key-press-event", _on_key_press) | 476 | #d.connect("key-press-event", _on_key_press) |
1038 | 462 | #GObject.timeout_add_seconds(1, _generate_events, d) | 477 | #GObject.timeout_add_seconds(1, _generate_events, d) |
1040 | 463 | 478 | ||
1041 | 464 | widget = PurchaseView() | 479 | widget = PurchaseView() |
1042 | 465 | widget.initiate_purchase(app=None, iconname=None, url=url) | 480 | widget.initiate_purchase(app=None, iconname=None, url=url) |
1043 | 466 | #widget.initiate_purchase(app=None, iconname=None, html=DUMMY_HTML) | 481 | #widget.initiate_purchase(app=None, iconname=None, html=DUMMY_HTML) |
1044 | @@ -477,4 +492,3 @@ | |||
1045 | 477 | if __name__ == "__main__": | 492 | if __name__ == "__main__": |
1046 | 478 | win = get_test_window_purchaseview() | 493 | win = get_test_window_purchaseview() |
1047 | 479 | Gtk.main() | 494 | Gtk.main() |
1048 | 480 | |||
1049 | 481 | 495 | ||
1050 | === modified file 'test/test_pep8.py' | |||
1051 | --- test/test_pep8.py 2012-03-13 17:13:27 +0000 | |||
1052 | +++ test/test_pep8.py 2012-03-14 16:41:35 +0000 | |||
1053 | @@ -8,15 +8,17 @@ | |||
1054 | 8 | 8 | ||
1055 | 9 | # Only test these two packages for now: | 9 | # Only test these two packages for now: |
1056 | 10 | import softwarecenter.db.pkginfo_impl | 10 | import softwarecenter.db.pkginfo_impl |
1057 | 11 | import softwarecenter.ui.gtk3.views | ||
1058 | 11 | import softwarecenter.ui.gtk3.widgets | 12 | import softwarecenter.ui.gtk3.widgets |
1059 | 12 | import softwarecenter.ui.qml | 13 | import softwarecenter.ui.qml |
1060 | 13 | 14 | ||
1061 | 14 | class PackagePep8TestCase(unittest.TestCase): | 15 | class PackagePep8TestCase(unittest.TestCase): |
1062 | 15 | maxDiff = None | 16 | maxDiff = None |
1063 | 16 | packages = [softwarecenter.ui.qml, | 17 | packages = [softwarecenter.ui.qml, |
1064 | 18 | softwarecenter.ui.gtk3.views, | ||
1065 | 17 | softwarecenter.ui.gtk3.widgets, | 19 | softwarecenter.ui.gtk3.widgets, |
1066 | 18 | softwarecenter.db.pkginfo_impl] | 20 | softwarecenter.db.pkginfo_impl] |
1068 | 19 | exclude = [] | 21 | exclude = ['appdetailsview.py'] |
1069 | 20 | 22 | ||
1070 | 21 | def message(self, text): | 23 | def message(self, text): |
1071 | 22 | self.errors.append(text) | 24 | self.errors.append(text) |
thanks a lot for this! looks good