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