Merge lp:~elachuni/software-center/pep8-test-part5 into lp:software-center

Proposed by Anthony Lenton
Status: Merged
Merged at revision: 2840
Proposed branch: lp:~elachuni/software-center/pep8-test-part5
Merge into: lp:software-center
Diff against target: 1056 lines (+210/-190)
7 files modified
softwarecenter/ui/gtk3/widgets/exhibits.py (+82/-87)
softwarecenter/ui/gtk3/widgets/imagedialog.py (+7/-2)
softwarecenter/ui/gtk3/widgets/labels.py (+19/-13)
softwarecenter/ui/gtk3/widgets/menubutton.py (+30/-20)
softwarecenter/ui/gtk3/widgets/oneconfviews.py (+33/-27)
softwarecenter/ui/gtk3/widgets/recommendations.py (+38/-39)
test/test_pep8.py (+1/-2)
To merge this branch: bzr merge lp:~elachuni/software-center/pep8-test-part5
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+96758@code.launchpad.net

Description of the change

Made 6 more files in softwarecenter/ui/gtk3/widgets/ pass the pep8 test.

To post a comment you must log in.
Revision history for this message
Gary Lasker (gary-lasker) wrote :

Thank you, Anthony!!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'softwarecenter/ui/gtk3/widgets/exhibits.py'
--- softwarecenter/ui/gtk3/widgets/exhibits.py 2012-02-27 16:56:32 +0000
+++ softwarecenter/ui/gtk3/widgets/exhibits.py 2012-03-09 13:04:23 +0000
@@ -37,7 +37,7 @@
37from softwarecenter.ui.gtk3.utils import point_in37from softwarecenter.ui.gtk3.utils import point_in
38import softwarecenter.paths38import softwarecenter.paths
3939
40LOG=logging.getLogger(__name__)40LOG = logging.getLogger(__name__)
4141
42_asset_cache = {}42_asset_cache = {}
43_HAND = Gdk.Cursor.new(Gdk.CursorType.HAND2)43_HAND = Gdk.Cursor.new(Gdk.CursorType.HAND2)
@@ -75,34 +75,40 @@
75</body></html>75</body></html>
76"""76"""
7777
78
78class FeaturedExhibit(object):79class FeaturedExhibit(object):
7980
80 def __init__(self):81 def __init__(self):
81 self.id = 082 self.id = 0
82 self.package_names = "armagetronad,calibre,cheese,homebank,stellarium,gimp,inkscape,blender,audacity,gufw,frozen-bubble,fretsonfire,moovida,liferea,arista,gtg,freeciv-client-gtk,openshot,supertuxkart,tumiki-fighters,tuxpaint,webservice-office-zoho"83 self.package_names = ("armagetronad,calibre,cheese,homebank,"
84 "stellarium,gimp,inkscape,blender,audacity,gufw,frozen-bubble,"
85 "fretsonfire,moovida,liferea,arista,gtg,freeciv-client-gtk,"
86 "openshot,supertuxkart,tumiki-fighters,tuxpaint,"
87 "webservice-office-zoho")
83 self.title_translated = _("Our star apps")88 self.title_translated = _("Our star apps")
84 self.published = True89 self.published = True
85 self.banner_url = "file:%s" % (os.path.abspath(os.path.join(softwarecenter.paths.datadir, "default_banner/fallback.png")))90 self.banner_url = "file:%s" % (os.path.abspath(os.path.join(
86 self.html = EXHIBIT_HTML % { 91 softwarecenter.paths.datadir, "default_banner/fallback.png")))
87 'banner_url' : self.banner_url,92 self.html = EXHIBIT_HTML % {
88 'title' : _("Our star apps"),93 'banner_url': self.banner_url,
89 'subtitle' : _("Come and explore our favourites"),94 'title': _("Our star apps"),
90 }95 'subtitle': _("Come and explore our favourites"),
96 }
91 # we should extract this automatically from the html97 # we should extract this automatically from the html
92 #self.atk_name = _("Default Banner")98 #self.atk_name = _("Default Banner")
93 #self.atk_description = _("You see this banner because you have no cached banners")99 #self.atk_description = _("You see this banner because you have no "
100 # "cached banners")
94101
95102
96class _HtmlRenderer(Gtk.OffscreenWindow):103class _HtmlRenderer(Gtk.OffscreenWindow):
97104
98 __gsignals__ = {105 __gsignals__ = {
99 "render-finished" : (GObject.SignalFlags.RUN_LAST,106 "render-finished": (GObject.SignalFlags.RUN_LAST,
100 None, 107 None,
101 (),108 (),
102 )109 )
103 }110 }
104111
105
106 def __init__(self):112 def __init__(self):
107 Gtk.OffscreenWindow.__init__(self)113 Gtk.OffscreenWindow.__init__(self)
108 self.view = WebKit.WebView()114 self.view = WebKit.WebView()
@@ -120,11 +126,10 @@
120 self.on_download_error)126 self.on_download_error)
121 self.exhibit = None127 self.exhibit = None
122 self.view.connect("notify::load-status", self._on_load_status)128 self.view.connect("notify::load-status", self._on_load_status)
123 return
124129
125 def _on_load_status(self, view, prop):130 def _on_load_status(self, view, prop):
126 if view.get_property("load-status") == WebKit.LoadStatus.FINISHED:131 if view.get_property("load-status") == WebKit.LoadStatus.FINISHED:
127 # this needs to run with a timeout because otherwise the 132 # this needs to run with a timeout because otherwise the
128 # status is emited before the offscreen image is finihsed133 # status is emited before the offscreen image is finihsed
129 GObject.timeout_add(100, lambda: self.emit("render-finished"))134 GObject.timeout_add(100, lambda: self.emit("render-finished"))
130135
@@ -137,26 +142,25 @@
137 if hasattr(self.exhibit, "html") and self.exhibit.html:142 if hasattr(self.exhibit, "html") and self.exhibit.html:
138 html = self.exhibit.html143 html = self.exhibit.html
139 else:144 else:
140 html = EXHIBIT_HTML % { 'banner_url' : self.exhibit.banner_url,145 html = EXHIBIT_HTML % {
141 'title' : self.exhibit.title_translated,146 'banner_url': self.exhibit.banner_url,
142 'subtitle' : "",147 'title': self.exhibit.title_translated,
143 }148 'subtitle': "",
144 # replace the server side path with the local image name, this 149 }
150 # replace the server side path with the local image name, this
145 # assumes that the image always comes from the same server as151 # assumes that the image always comes from the same server as
146 # the html152 # the html
147 scheme, netloc, server_path, para, query, frag = urlparse(153 scheme, netloc, server_path, para, query, frag = urlparse(
148 self.exhibit.banner_url)154 self.exhibit.banner_url)
149 html = html.replace(server_path, image_name)155 html = html.replace(server_path, image_name)
150 self.view.load_string(html, "text/html", "UTF-8", 156 self.view.load_string(html, "text/html", "UTF-8",
151 "file:%s/" % cache_dir)157 "file:%s/" % cache_dir)
152 return
153158
154 def set_exhibit(self, exhibit):159 def set_exhibit(self, exhibit):
155 self.exhibit = exhibit160 self.exhibit = exhibit
156 self.loader.download_file(exhibit.banner_url, 161 self.loader.download_file(exhibit.banner_url,
157 use_cache=True,162 use_cache=True,
158 simple_quoting_for_webkit=True)163 simple_quoting_for_webkit=True)
159 return
160164
161165
162class ExhibitButton(Gtk.Button):166class ExhibitButton(Gtk.Button):
@@ -183,7 +187,6 @@
183 self._dropshadow = self.DROPSHADOW.scale_simple(187 self._dropshadow = self.DROPSHADOW.scale_simple(
184 a.width, a.width, GdkPixbuf.InterpType.BILINEAR)188 a.width, a.width, GdkPixbuf.InterpType.BILINEAR)
185 self._margin = int(float(a.width) / self.DROPSHADOW.get_width() * 15)189 self._margin = int(float(a.width) / self.DROPSHADOW.get_width() * 15)
186 return
187190
188 def do_draw(self, cr):191 def do_draw(self, cr):
189 a = self.get_allocation()192 a = self.get_allocation()
@@ -194,9 +197,9 @@
194 y = (a.height - ds_h) / 2197 y = (a.height - ds_h) / 2
195 Gdk.cairo_set_source_pixbuf(cr, self._dropshadow, 0, y)198 Gdk.cairo_set_source_pixbuf(cr, self._dropshadow, 0, y)
196 cr.paint()199 cr.paint()
197 Circle.layout(cr, self._margin, (a.height-ds_h)/2 + self._margin,200 Circle.layout(cr, self._margin, (a.height - ds_h) / 2 + self._margin,
198 a.width-2*self._margin,201 a.width - 2 * self._margin,
199 a.width-2*self._margin)202 a.width - 2 * self._margin)
200 if self.is_active:203 if self.is_active:
201 color = context.get_background_color(Gtk.StateFlags.SELECTED)204 color = context.get_background_color(Gtk.StateFlags.SELECTED)
202 else:205 else:
@@ -205,9 +208,8 @@
205 Gdk.cairo_set_source_rgba(cr, color)208 Gdk.cairo_set_source_rgba(cr, color)
206 cr.fill()209 cr.fill()
207210
208 for child in self: 211 for child in self:
209 self.propagate_draw(child, cr)212 self.propagate_draw(child, cr)
210 return
211213
212214
213class ExhibitArrowButton(ExhibitButton):215class ExhibitArrowButton(ExhibitButton):
@@ -215,24 +217,24 @@
215 def __init__(self, arrow_type, shadow_type=Gtk.ShadowType.IN):217 def __init__(self, arrow_type, shadow_type=Gtk.ShadowType.IN):
216 ExhibitButton.__init__(self)218 ExhibitButton.__init__(self)
217 a = Gtk.Alignment()219 a = Gtk.Alignment()
218 a.set_padding(1,1,1,1)220 a.set_padding(1, 1, 1, 1)
219 a.add(Gtk.Arrow.new(arrow_type, shadow_type)) 221 a.add(Gtk.Arrow.new(arrow_type, shadow_type))
220 self.add(a)222 self.add(a)
221 return
222223
223224
224class ExhibitBanner(Gtk.EventBox):225class ExhibitBanner(Gtk.EventBox):
225 # FIXME: sometimes despite set_exhibit being called the new exhibit isn't actually displayed226 # FIXME: sometimes despite set_exhibit being called the new exhibit isn't
227 # actually displayed
226228
227 __gsignals__ = {229 __gsignals__ = {
228 "show-exhibits-clicked" : (GObject.SignalFlags.RUN_LAST,230 "show-exhibits-clicked": (GObject.SignalFlags.RUN_LAST,
229 None, 231 None,
230 (GObject.TYPE_PYOBJECT,),232 (GObject.TYPE_PYOBJECT,),
231 )233 )
232 }234 }
233235
234 DROPSHADOW_HEIGHT = 11236 DROPSHADOW_HEIGHT = 11
235 MAX_HEIGHT = 200 # pixels237 MAX_HEIGHT = 200 # pixels
236 TIMEOUT_SECONDS = 10238 TIMEOUT_SECONDS = 10
237239
238 def __init__(self):240 def __init__(self):
@@ -274,8 +276,8 @@
274 self.pressed = False276 self.pressed = False
275277
276 self.alpha = 1.0278 self.alpha = 1.0
277 self.image = None 279 self.image = None
278 self.old_image = None 280 self.old_image = None
279 self.renderer = _HtmlRenderer()281 self.renderer = _HtmlRenderer()
280 self.renderer.connect("render-finished", self.on_banner_rendered)282 self.renderer.connect("render-finished", self.on_banner_rendered)
281283
@@ -295,9 +297,9 @@
295297
296 def _init_event_handling(self):298 def _init_event_handling(self):
297 self.set_can_focus(True)299 self.set_can_focus(True)
298 self.set_events(Gdk.EventMask.BUTTON_RELEASE_MASK|300 self.set_events(Gdk.EventMask.BUTTON_RELEASE_MASK |
299 Gdk.EventMask.BUTTON_PRESS_MASK|301 Gdk.EventMask.BUTTON_PRESS_MASK |
300 Gdk.EventMask.ENTER_NOTIFY_MASK|302 Gdk.EventMask.ENTER_NOTIFY_MASK |
301 Gdk.EventMask.LEAVE_NOTIFY_MASK)303 Gdk.EventMask.LEAVE_NOTIFY_MASK)
302 self.connect("enter-notify-event", self.on_enter_notify)304 self.connect("enter-notify-event", self.on_enter_notify)
303 self.connect("leave-notify-event", self.on_leave_notify)305 self.connect("leave-notify-event", self.on_leave_notify)
@@ -316,12 +318,10 @@
316318
317 def on_enter_notify(self, *args):319 def on_enter_notify(self, *args):
318 self._init_mouse_pointer()320 self._init_mouse_pointer()
319 return
320321
321 def on_leave_notify(self, *args):322 def on_leave_notify(self, *args):
322 window = self.get_window()323 window = self.get_window()
323 window.set_cursor(None)324 window.set_cursor(None)
324 return
325325
326 def on_button_release(self, widget, event):326 def on_button_release(self, widget, event):
327 if not point_in(self.get_allocation(),327 if not point_in(self.get_allocation(),
@@ -333,14 +333,11 @@
333 if exhibit.package_names and self.pressed:333 if exhibit.package_names and self.pressed:
334 self.emit("show-exhibits-clicked", exhibit)334 self.emit("show-exhibits-clicked", exhibit)
335 self.pressed = False335 self.pressed = False
336 return
337336
338 def on_button_press(self, widget, event):337 def on_button_press(self, widget, event):
339 if not point_in(self.get_allocation(),338 if point_in(self.get_allocation(),
340 int(event.x), int(event.y)):339 int(event.x), int(event.y)):
341 return340 self.pressed = True
342 self.pressed = True
343 return
344341
345 def on_key_press(self, widget, event):342 def on_key_press(self, widget, event):
346 # activate343 # activate
@@ -366,18 +363,15 @@
366 def on_next_clicked(self, *args):363 def on_next_clicked(self, *args):
367 self.next_exhibit()364 self.next_exhibit()
368 self.queue_next()365 self.queue_next()
369 return
370366
371 def on_previous_clicked(self, *args):367 def on_previous_clicked(self, *args):
372 self.previous()368 self.previous()
373 self.queue_next()369 self.queue_next()
374 return
375370
376 def cleanup_timeout(self):371 def cleanup_timeout(self):
377 if self._timeout > 0:372 if self._timeout > 0:
378 GObject.source_remove(self._timeout)373 GObject.source_remove(self._timeout)
379 self._timeout = 0374 self._timeout = 0
380 return
381375
382 def _render_exhibit_at_cursor(self):376 def _render_exhibit_at_cursor(self):
383 # init the mouse pointer377 # init the mouse pointer
@@ -402,7 +396,7 @@
402396
403 # next() is a special function in py3 so we call this next_exhibit397 # next() is a special function in py3 so we call this next_exhibit
404 def next_exhibit(self):398 def next_exhibit(self):
405 if len(self.exhibits)-1 == self.cursor:399 if len(self.exhibits) - 1 == self.cursor:
406 self.cursor = 0400 self.cursor = 0
407 else:401 else:
408 self.cursor += 1402 self.cursor += 1
@@ -411,7 +405,7 @@
411405
412 def previous(self):406 def previous(self):
413 if self.cursor == 0:407 if self.cursor == 0:
414 self.cursor = len(self.exhibits)-1408 self.cursor = len(self.exhibits) - 1
415 else:409 else:
416 self.cursor -= 1410 self.cursor -= 1
417 self._render_exhibit_at_cursor()411 self._render_exhibit_at_cursor()
@@ -433,7 +427,8 @@
433 return427 return
434428
435 from gi.repository import Atk429 from gi.repository import Atk
436 self.get_accessible().set_name(self.exhibits[self.cursor].title_translated)430 self.get_accessible().set_name(
431 self.exhibits[self.cursor].title_translated)
437 self.get_accessible().set_role(Atk.Role.PUSH_BUTTON)432 self.get_accessible().set_role(Atk.Role.PUSH_BUTTON)
438 self._fade_in()433 self._fade_in()
439 self.queue_next()434 self.queue_next()
@@ -455,12 +450,11 @@
455 return retval450 return retval
456451
457 GObject.timeout_add(50, fade_step)452 GObject.timeout_add(50, fade_step)
458 return
459453
460 def _cache_art_assets(self):454 def _cache_art_assets(self):
461 global _asset_cache455 global _asset_cache
462 assets = _asset_cache456 assets = _asset_cache
463 if assets: 457 if assets:
464 return assets458 return assets
465459
466 #~ surf = cairo.ImageSurface.create_from_png(self.NORTHERN_DROPSHADOW)460 #~ surf = cairo.ImageSurface.create_from_png(self.NORTHERN_DROPSHADOW)
@@ -490,7 +484,7 @@
490484
491 a = self.get_allocation()485 a = self.get_allocation()
492486
493 cr.set_source_rgb(1,1,1)487 cr.set_source_rgb(1, 1, 1)
494 cr.paint()488 cr.paint()
495489
496 # workaround a really odd bug in the offscreen window of the490 # workaround a really odd bug in the offscreen window of the
@@ -519,7 +513,7 @@
519 highlight = context.get_background_color(self.get_state_flags())513 highlight = context.get_background_color(self.get_state_flags())
520 context.restore()514 context.restore()
521515
522 rounded_rect(cr, 1, 1, a.width-2, a.height-3, 5)516 rounded_rect(cr, 1, 1, a.width - 2, a.height - 3, 5)
523 Gdk.cairo_set_source_rgba(cr, highlight)517 Gdk.cairo_set_source_rgba(cr, highlight)
524 cr.set_line_width(6)518 cr.set_line_width(6)
525 cr.stroke()519 cr.stroke()
@@ -531,26 +525,25 @@
531 #~ cr.paint()525 #~ cr.paint()
532 #~ cr.reset_clip()526 #~ cr.reset_clip()
533527
534 cr.rectangle(0, a.height-self.DROPSHADOW_HEIGHT,528 cr.rectangle(0, a.height - self.DROPSHADOW_HEIGHT,
535 a.width, self.DROPSHADOW_HEIGHT)529 a.width, self.DROPSHADOW_HEIGHT)
536 cr.clip()530 cr.clip()
537 cr.save()531 cr.save()
538 cr.translate(0, a.height-self.DROPSHADOW_HEIGHT)532 cr.translate(0, a.height - self.DROPSHADOW_HEIGHT)
539 cr.set_source(_asset_cache["s"])533 cr.set_source(_asset_cache["s"])
540 cr.paint()534 cr.paint()
541 cr.restore()535 cr.restore()
542536
543 cr.set_line_width(1)537 cr.set_line_width(1)
544 cr.move_to(-0.5, a.height-0.5)538 cr.move_to(-0.5, a.height - 0.5)
545 cr.rel_line_to(a.width+1, 0)539 cr.rel_line_to(a.width + 1, 0)
546 cr.set_source_rgba(1,1,1,0.75)540 cr.set_source_rgba(1, 1, 1, 0.75)
547 cr.stroke()541 cr.stroke()
548542
549 cr.restore()543 cr.restore()
550544
551 for child in self: 545 for child in self:
552 self.propagate_draw(child, cr)546 self.propagate_draw(child, cr)
553 return
554547
555 def _init_pause_handling_if_needed(self):548 def _init_pause_handling_if_needed(self):
556 # nothing todo if we have the toplevel already549 # nothing todo if we have the toplevel already
@@ -564,7 +557,7 @@
564 if not isinstance(w, Gtk.Window):557 if not isinstance(w, Gtk.Window):
565 return558 return
566 # connect to property changes for the toplevel focus559 # connect to property changes for the toplevel focus
567 w.connect("notify::has-toplevel-focus", 560 w.connect("notify::has-toplevel-focus",
568 self._on_main_window_is_active_changed)561 self._on_main_window_is_active_changed)
569 self._toplevel_window = w562 self._toplevel_window = w
570563
@@ -579,8 +572,7 @@
579 self.cleanup_timeout()572 self.cleanup_timeout()
580573
581 def set_exhibits(self, exhibits_list):574 def set_exhibits(self, exhibits_list):
582575 if not exhibits_list:
583 if not exhibits_list:
584 return576 return
585577
586 self.exhibits = exhibits_list578 self.exhibits = exhibits_list
@@ -600,13 +592,13 @@
600 self._dotsigs.append(592 self._dotsigs.append(
601 dot.connect("clicked",593 dot.connect("clicked",
602 self.on_paging_dot_clicked,594 self.on_paging_dot_clicked,
603 len(self.exhibits) - 1 - i) # index595 len(self.exhibits) - 1 - i) # index
604 )596 )
605 self.index_hbox.pack_end(dot, False, False, 0)597 self.index_hbox.pack_end(dot, False, False, 0)
606 self.index_hbox.show_all()598 self.index_hbox.show_all()
607599
608 self._render_exhibit_at_cursor()600 self._render_exhibit_at_cursor()
609 return601
610602
611def get_test_exhibits_window():603def get_test_exhibits_window():
612 from mock import Mock604 from mock import Mock
@@ -618,19 +610,22 @@
618610
619 exhibits_list = [FeaturedExhibit()]611 exhibits_list = [FeaturedExhibit()]
620 for (i, (title, url)) in enumerate([612 for (i, (title, url)) in enumerate([
621 ("1 some title", "https://wiki.ubuntu.com/Brand?action=AttachFile&do=get&target=orangeubuntulogo.png"),613 ("1 some title", "https://wiki.ubuntu.com/Brand?"
622 ("2 another title", "https://wiki.ubuntu.com/Brand?action=AttachFile&do=get&target=blackeubuntulogo.png"),614 "action=AttachFile&do=get&target=orangeubuntulogo.png"),
623 ("3 yet another title", "https://wiki.ubuntu.com/Brand?action=AttachFile&do=get&target=xubuntu.png"),615 ("2 another title", "https://wiki.ubuntu.com/Brand?"
624 ]):616 "action=AttachFile&do=get&target=blackeubuntulogo.png"),
625 exhibit = Mock()617 ("3 yet another title", "https://wiki.ubuntu.com/Brand?"
626 exhibit.id = i618 "action=AttachFile&do=get&target=xubuntu.png"),
627 exhibit.package_names = "apt,2vcard"619 ]):
628 exhibit.published = True620 exhibit = Mock()
629 exhibit.style = "some uri to html"621 exhibit.id = i
630 exhibit.title_translated = title622 exhibit.package_names = "apt,2vcard"
631 exhibit.banner_url = url623 exhibit.published = True
632 exhibit.html = None624 exhibit.style = "some uri to html"
633 exhibits_list.append(exhibit)625 exhibit.title_translated = title
626 exhibit.banner_url = url
627 exhibit.html = None
628 exhibits_list.append(exhibit)
634629
635 exhibit_banner.set_exhibits(exhibits_list)630 exhibit_banner.set_exhibits(exhibits_list)
636631
637632
=== modified file 'softwarecenter/ui/gtk3/widgets/imagedialog.py'
--- softwarecenter/ui/gtk3/widgets/imagedialog.py 2011-09-06 09:06:41 +0000
+++ softwarecenter/ui/gtk3/widgets/imagedialog.py 2012-03-09 13:04:23 +0000
@@ -22,12 +22,15 @@
2222
23ICON_EXCEPTIONS = ["gnome"]23ICON_EXCEPTIONS = ["gnome"]
2424
25
25class Url404Error(IOError):26class Url404Error(IOError):
26 pass27 pass
2728
29
28class Url403Error(IOError):30class Url403Error(IOError):
29 pass31 pass
3032
33
31class SimpleShowImageDialog(Gtk.Dialog):34class SimpleShowImageDialog(Gtk.Dialog):
32 """A dialog that shows a image """35 """A dialog that shows a image """
3336
@@ -61,7 +64,7 @@
61 self.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)64 self.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)
62 self.set_default_size(SimpleShowImageDialog.DEFAULT_WIDTH,65 self.set_default_size(SimpleShowImageDialog.DEFAULT_WIDTH,
63 SimpleShowImageDialog.DEFAULT_HEIGHT)66 SimpleShowImageDialog.DEFAULT_HEIGHT)
64 67
65 def run(self):68 def run(self):
66 # show all and run the real thing69 # show all and run the real thing
67 self.show_all()70 self.show_all()
@@ -71,5 +74,7 @@
71if __name__ == "__main__":74if __name__ == "__main__":
7275
73 # pixbuf76 # pixbuf
74 d = SimpleShowImageDialog("Synaptic Screenshot", GdkPixbuf.Pixbuf.new_from_file("/usr/share/software-center/images/arrows.png"))77 d = SimpleShowImageDialog("Synaptic Screenshot",
78 GdkPixbuf.Pixbuf.new_from_file(
79 "/usr/share/software-center/images/arrows.png"))
75 d.run()80 d.run()
7681
=== modified file 'softwarecenter/ui/gtk3/widgets/labels.py'
--- softwarecenter/ui/gtk3/widgets/labels.py 2012-01-26 22:11:41 +0000
+++ softwarecenter/ui/gtk3/widgets/labels.py 2012-03-09 13:04:23 +0000
@@ -21,26 +21,27 @@
2121
22from softwarecenter.hw import TAG_DESCRIPTION22from softwarecenter.hw import TAG_DESCRIPTION
2323
24
24class HardwareRequirementsLabel(Gtk.HBox):25class HardwareRequirementsLabel(Gtk.HBox):
25 """ contains a single HW requirement string and a image that shows if 26 """ contains a single HW requirement string and a image that shows if
26 the requirements are meet 27 the requirements are meet
27 """28 """
2829
29 SUPPORTED_SYM = {30 SUPPORTED_SYM = {
30 # TRANSLATORS: symbol for "hardware-supported"31 # TRANSLATORS: symbol for "hardware-supported"
31 'yes' : _(u'\u2713'),32 'yes': _(u'\u2713'),
32 # TRANSLATORS: symbol for hardware "not-supported"33 # TRANSLATORS: symbol for hardware "not-supported"
33 'no' : u'<span foreground="red">%s</span>' % _(u'\u2718'),34 'no': u'<span foreground="red">%s</span>' % _(u'\u2718'),
34 }35 }
3536
36 # TRANSLATORS: this is a substring that used to build the 37 # TRANSLATORS: this is a substring that used to build the
37 # "hardware-supported" string, where sym is38 # "hardware-supported" string, where sym is
38 # either a unicode checkmark or a cross39 # either a unicode checkmark or a cross
39 # and hardware is the short hardware description40 # and hardware is the short hardware description
40 # Note that this is the last substr, no trailing ","41 # Note that this is the last substr, no trailing ","
41 LABEL_LAST_ITEM = _("%(sym)s%(hardware)s")42 LABEL_LAST_ITEM = _("%(sym)s%(hardware)s")
4243
43 # TRANSLATORS: this is a substring that used to build the 44 # TRANSLATORS: this is a substring that used to build the
44 # "hardware-supported" string, where sym is45 # "hardware-supported" string, where sym is
45 # either a unicode checkmark or a cross46 # either a unicode checkmark or a cross
46 # and hardware is the short hardware description47 # and hardware is the short hardware description
@@ -53,27 +54,31 @@
53 self.result = None54 self.result = None
54 self.last_item = last_item55 self.last_item = last_item
55 self._build_ui()56 self._build_ui()
57
56 def _build_ui(self):58 def _build_ui(self):
57 self._label = Gtk.Label()59 self._label = Gtk.Label()
58 self._label.show()60 self._label.show()
59 self.pack_start(self._label, True, True, 0)61 self.pack_start(self._label, True, True, 0)
62
60 def get_label(self):63 def get_label(self):
61 # get the right symbol64 # get the right symbol
62 sym = self.SUPPORTED_SYM[self.result]65 sym = self.SUPPORTED_SYM[self.result]
63 # we add a trailing 66 # we add a trailing
64 if self.last_item:67 if self.last_item:
65 s = self.LABEL_LAST_ITEM68 s = self.LABEL_LAST_ITEM
66 else:69 else:
67 s= self.LABEL70 s = self.LABEL
68 return _(s) % {71 return _(s) % {
69 "sym" : sym,72 "sym": sym,
70 "hardware" : _(TAG_DESCRIPTION[self.tag]),73 "hardware": _(TAG_DESCRIPTION[self.tag]),
71 }74 }
75
72 def set_hardware_requirement(self, tag, result):76 def set_hardware_requirement(self, tag, result):
73 self.tag = tag77 self.tag = tag
74 self.result = result78 self.result = result
75 self._label.set_markup(self.get_label())79 self._label.set_markup(self.get_label())
7680
81
77class HardwareRequirementsBox(Gtk.HBox):82class HardwareRequirementsBox(Gtk.HBox):
78 """ A collection of HW requirement labels """83 """ A collection of HW requirement labels """
7984
@@ -107,9 +112,10 @@
107 win = Gtk.Window()112 win = Gtk.Window()
108 win.set_size_request(300, 200)113 win.set_size_request(300, 200)
109114
110 HW_TEST_RESULT = { 'hardware::gps' : 'yes',115 HW_TEST_RESULT = {
111 'hardware::video:opengl' : 'no',116 'hardware::gps': 'yes',
112 }117 'hardware::video:opengl': 'no',
118 }
113119
114 # add it120 # add it
115 hwbox = HardwareRequirementsBox()121 hwbox = HardwareRequirementsBox()
116122
=== modified file 'softwarecenter/ui/gtk3/widgets/menubutton.py'
--- softwarecenter/ui/gtk3/widgets/menubutton.py 2012-01-05 09:49:23 +0000
+++ softwarecenter/ui/gtk3/widgets/menubutton.py 2012-03-09 13:04:23 +0000
@@ -18,11 +18,12 @@
1818
19from gi.repository import Gtk19from gi.repository import Gtk
2020
21
21class MenuButton(Gtk.Button):22class MenuButton(Gtk.Button):
2223
23 def __init__(self, menu, icon=None, label=None):24 def __init__(self, menu, icon=None, label=None):
24 super(MenuButton, self).__init__()25 super(MenuButton, self).__init__()
25 26
26 box = Gtk.Box()27 box = Gtk.Box()
27 self.add(box)28 self.add(box)
2829
@@ -30,12 +31,12 @@
30 box.pack_start(icon, False, True, 1)31 box.pack_start(icon, False, True, 1)
31 if label:32 if label:
32 box.pack_start(Gtk.Label(label), True, True, 0)33 box.pack_start(Gtk.Label(label), True, True, 0)
33 34
34 arrow = Gtk.Arrow.new(Gtk.ArrowType.DOWN, Gtk.ShadowType.OUT)35 arrow = Gtk.Arrow.new(Gtk.ArrowType.DOWN, Gtk.ShadowType.OUT)
35 box.pack_start(arrow, False, False, 1)36 box.pack_start(arrow, False, False, 1)
3637
37 self.menu = menu38 self.menu = menu
38 39
39 self.connect("button-press-event", self.on_button_pressed, menu)40 self.connect("button-press-event", self.on_button_pressed, menu)
40 self.connect("clicked", self.on_keyboard_clicked, menu)41 self.connect("clicked", self.on_keyboard_clicked, menu)
4142
@@ -44,18 +45,21 @@
44 return self.menu45 return self.menu
4546
46 def on_button_pressed(self, button, event, menu):47 def on_button_pressed(self, button, event, menu):
47 menu.popup(None, None, self.menu_positionner, (button, event.x), event.button, event.time)48 menu.popup(None, None, self.menu_positionner, (button, event.x),
49 event.button, event.time)
4850
49 def on_keyboard_clicked(self, button, menu):51 def on_keyboard_clicked(self, button, menu):
50 menu.popup(None, None, self.menu_positionner, (button, None), 1, Gtk.get_current_event_time())52 menu.popup(None, None, self.menu_positionner, (button, None), 1,
53 Gtk.get_current_event_time())
5154
52 def menu_positionner(self, menu, (button, x_cursor_pos)):55 def menu_positionner(self, menu, (button, x_cursor_pos)):
53 (button_id, x, y) = button.get_window().get_origin()56 (button_id, x, y) = button.get_window().get_origin()
5457
55 # compute button position58 # compute button position
56 x_position = x + button.get_allocation().x59 x_position = x + button.get_allocation().x
57 y_position = y + button.get_allocation().y + button.get_allocated_height()60 y_position = (y + button.get_allocation().y +
58 61 button.get_allocated_height())
62
59 # if pressed by the mouse, center the X position to it63 # if pressed by the mouse, center the X position to it
60 if x_cursor_pos:64 if x_cursor_pos:
61 x_position += x_cursor_pos65 x_position += x_cursor_pos
@@ -63,19 +67,24 @@
6367
64 # computer current monitor height68 # computer current monitor height
65 current_screen = button.get_screen()69 current_screen = button.get_screen()
66 num_monitor = current_screen.get_monitor_at_point(x_position, y_position)70 num_monitor = current_screen.get_monitor_at_point(x_position,
71 y_position)
67 monitor_geo = current_screen.get_monitor_geometry(num_monitor)72 monitor_geo = current_screen.get_monitor_geometry(num_monitor)
68 73
69 # if the menu width is of the current monitor, shift is a little74 # if the menu width is of the current monitor, shift is a little
70 if x_position < monitor_geo.x:75 if x_position < monitor_geo.x:
71 x_position = monitor_geo.x76 x_position = monitor_geo.x
72 if x_position + menu.get_allocated_width() > monitor_geo.x + monitor_geo.width:77 if (x_position + menu.get_allocated_width() > monitor_geo.x +
73 x_position = monitor_geo.x + monitor_geo.width - menu.get_allocated_width()78 monitor_geo.width):
74 79 x_position = (monitor_geo.x + monitor_geo.width -
75 # if the menu height is too long for the monitor, put it above the widget80 menu.get_allocated_width())
81
82 # if the menu height is too long for the monitor, put it above the
83 # widget
76 if monitor_geo.height < y_position + menu.get_allocated_height():84 if monitor_geo.height < y_position + menu.get_allocated_height():
77 y_position = y_position - button.get_allocated_height() - menu.get_allocated_height()85 y_position = (y_position - button.get_allocated_height() -
78 86 menu.get_allocated_height())
87
79 return (x_position, y_position, True)88 return (x_position, y_position, True)
8089
8190
@@ -93,23 +102,24 @@
93 menuitem2.show()102 menuitem2.show()
94103
95 box1 = Gtk.Box()104 box1 = Gtk.Box()
96 box1.pack_start(Gtk.Label("something before to show we don't cheat"), True, True, 0)105 box1.pack_start(Gtk.Label("something before to show we don't cheat"),
106 True, True, 0)
97 win.add(box1)107 win.add(box1)
98108
99 box2 = Gtk.Box()109 box2 = Gtk.Box()
100 box2.set_orientation(Gtk.Orientation.VERTICAL) 110 box2.set_orientation(Gtk.Orientation.VERTICAL)
101 box1.pack_start(box2, True, True, 0)111 box1.pack_start(box2, True, True, 0)
102 box2.pack_start(Gtk.Label("first label with multiple line"), True, True, 0)112 box2.pack_start(Gtk.Label("first label with multiple line"), True, True, 0)
103 113
104 image = Gtk.Image.new_from_stock(Gtk.STOCK_PROPERTIES, Gtk.IconSize.BUTTON)114 image = Gtk.Image.new_from_stock(Gtk.STOCK_PROPERTIES, Gtk.IconSize.BUTTON)
105 label = "fooo"115 label = "fooo"
106 button_with_menu = MenuButton(menu, image, label)116 button_with_menu = MenuButton(menu, image, label)
107 box2.pack_start(button_with_menu, False, False, 1) 117 box2.pack_start(button_with_menu, False, False, 1)
108118
109 win.connect("destroy", lambda x: Gtk.main_quit())119 win.connect("destroy", lambda x: Gtk.main_quit())
110 win.show_all()120 win.show_all()
111121
112 settings = Gtk.Settings.get_default()122 settings = Gtk.Settings.get_default()
113 settings.set_property("gtk-button-images", True)123 settings.set_property("gtk-button-images", True)
114 124
115 Gtk.main()125 Gtk.main()
116126
=== modified file 'softwarecenter/ui/gtk3/widgets/oneconfviews.py'
--- softwarecenter/ui/gtk3/widgets/oneconfviews.py 2012-01-05 09:49:23 +0000
+++ softwarecenter/ui/gtk3/widgets/oneconfviews.py 2012-03-09 13:04:23 +0000
@@ -25,26 +25,28 @@
25class OneConfViews(Gtk.TreeView):25class OneConfViews(Gtk.TreeView):
2626
27 __gsignals__ = {27 __gsignals__ = {
28 "computer-changed" : (GObject.SIGNAL_RUN_LAST,28 "computer-changed": (GObject.SIGNAL_RUN_LAST,
29 GObject.TYPE_NONE, 29 GObject.TYPE_NONE,
30 (GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT),30 (GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT),
31 ),31 ),
32 "current-inventory-refreshed" : (GObject.SIGNAL_RUN_LAST,32 "current-inventory-refreshed": (GObject.SIGNAL_RUN_LAST,
33 GObject.TYPE_NONE,33 GObject.TYPE_NONE,
34 (),),34 (),
35 ),
35 }36 }
36 37
37 (COL_ICON, COL_HOSTID, COL_HOSTNAME) = range(3)38 (COL_ICON, COL_HOSTID, COL_HOSTNAME) = range(3)
3839
39 def __init__(self, icons):40 def __init__(self, icons):
40 super(OneConfViews, self).__init__()41 super(OneConfViews, self).__init__()
41 model = Gtk.ListStore(GdkPixbuf.Pixbuf, GObject.TYPE_STRING, GObject.TYPE_STRING)42 model = Gtk.ListStore(GdkPixbuf.Pixbuf, GObject.TYPE_STRING,
43 GObject.TYPE_STRING)
42 model.set_sort_column_id(self.COL_HOSTNAME, Gtk.SortType.ASCENDING)44 model.set_sort_column_id(self.COL_HOSTNAME, Gtk.SortType.ASCENDING)
43 model.set_sort_func(self.COL_HOSTNAME, self._sort_hosts)45 model.set_sort_func(self.COL_HOSTNAME, self._sort_hosts)
44 self.set_model(model)46 self.set_model(model)
45 self.set_headers_visible(False)47 self.set_headers_visible(False)
46 self.col = Gtk.TreeViewColumn('hostname')48 self.col = Gtk.TreeViewColumn('hostname')
47 49
48 hosticon_renderer = Gtk.CellRendererPixbuf()50 hosticon_renderer = Gtk.CellRendererPixbuf()
49 hostname_renderer = Gtk.CellRendererText()51 hostname_renderer = Gtk.CellRendererText()
50 self.col.pack_start(hosticon_renderer, False)52 self.col.pack_start(hosticon_renderer, False)
@@ -57,9 +59,9 @@
5759
58 # TODO: load the dynamic one (if present), later60 # TODO: load the dynamic one (if present), later
59 self.default_computer_icon = icons.load_icon("computer", 22, 0)61 self.default_computer_icon = icons.load_icon("computer", 22, 0)
60 62
61 self.connect("cursor-changed", self.on_cursor_changed)63 self.connect("cursor-changed", self.on_cursor_changed)
62 64
63 def register_computer(self, hostid, hostname):65 def register_computer(self, hostid, hostname):
64 '''Add a new computer to the model'''66 '''Add a new computer to the model'''
65 model = self.get_model()67 model = self.get_model()
@@ -73,17 +75,20 @@
73 model.append([self.default_computer_icon, hostid, hostname])75 model.append([self.default_computer_icon, hostid, hostname])
7476
75 def store_packagelist_changed(self, hostid):77 def store_packagelist_changed(self, hostid):
76 '''Emit a signal for refreshing the installedpane if current view is concerned'''78 '''Emit a signal for refreshing the installedpane if current view is
79 concerned
80 '''
77 if hostid == self.current_hostid:81 if hostid == self.current_hostid:
78 self.emit("current-inventory-refreshed")82 self.emit("current-inventory-refreshed")
79 83
80 def remove_computer(self, hostid):84 def remove_computer(self, hostid):
81 '''Remove a computer from the model'''85 '''Remove a computer from the model'''
82 model = self.get_model()86 model = self.get_model()
83 if not model:87 if not model:
84 return88 return
85 if hostid not in self.hostids:89 if hostid not in self.hostids:
86 LOG.warning("ask to remove a computer that isn't registered: %s" % hostid)90 LOG.warning("ask to remove a computer that isn't registered: %s" %
91 hostid)
87 return92 return
88 iter_id = model.get_iter_first()93 iter_id = model.get_iter_first()
89 while iter_id:94 while iter_id:
@@ -92,8 +97,7 @@
92 self.hostids.remove(hostid)97 self.hostids.remove(hostid)
93 break98 break
94 iter_id = model.iter_next(iter_id)99 iter_id = model.iter_next(iter_id)
95 100
96
97 def on_cursor_changed(self, widget):101 def on_cursor_changed(self, widget):
98102
99 (path, column) = self.get_cursor()103 (path, column) = self.get_cursor()
@@ -101,28 +105,30 @@
101 return105 return
102 model = self.get_model()106 model = self.get_model()
103 if not model:107 if not model:
104 return 108 return
105 hostid = model[path][self.COL_HOSTID]109 hostid = model[path][self.COL_HOSTID]
106 hostname = model[path][self.COL_HOSTNAME]110 hostname = model[path][self.COL_HOSTNAME]
107 if hostid != self.current_hostid:111 if hostid != self.current_hostid:
108 self.current_hostid = hostid112 self.current_hostid = hostid
109 self.emit("computer-changed", hostid, hostname)113 self.emit("computer-changed", hostid, hostname)
110 114
111 def select_first(self):115 def select_first(self):
112 '''Select first item'''116 '''Select first item'''
113 self.set_cursor(Gtk.TreePath.new_first(), None, False)117 self.set_cursor(Gtk.TreePath.new_first(), None, False)
114 118
115 def _sort_hosts(self, model, iter1, iter2, user_data):119 def _sort_hosts(self, model, iter1, iter2, user_data):
116 '''Sort hosts, with "this computer" (NONE HOSTID) as first'''120 '''Sort hosts, with "this computer" (NONE HOSTID) as first'''
117 if not self.get_model().get_value(iter1, self.COL_HOSTID):121 if not self.get_model().get_value(iter1, self.COL_HOSTID):
118 return -1122 return -1
119 if not self.get_model().get_value(iter2, self.COL_HOSTID):123 if not self.get_model().get_value(iter2, self.COL_HOSTID):
120 return 1 124 return 1
121 if self.get_model().get_value(iter1, self.COL_HOSTNAME) > self.get_model().get_value(iter2, self.COL_HOSTNAME):125 if (self.get_model().get_value(iter1, self.COL_HOSTNAME) >
126 self.get_model().get_value(iter2, self.COL_HOSTNAME)):
122 return 1127 return 1
123 else:128 else:
124 return -1129 return -1
125 130
131
126def get_test_window():132def get_test_window():
127133
128 w = OneConfViews(Gtk.IconTheme.get_default())134 w = OneConfViews(Gtk.IconTheme.get_default())
@@ -141,14 +147,14 @@
141 w.register_computer("CCCCC", "NameC")147 w.register_computer("CCCCC", "NameC")
142 w.register_computer("", "This computer should be first")148 w.register_computer("", "This computer should be first")
143 w.select_first()149 w.select_first()
144 150
145 GObject.timeout_add_seconds(5, w.register_computer, "EEEEE", "NameE")151 GObject.timeout_add_seconds(5, w.register_computer, "EEEEE", "NameE")
146 152
147 def print_selected_hostid(widget, hostid, hostname):153 def print_selected_hostid(widget, hostid, hostname):
148 print "%s selected for %s" % (hostid, hostname)154 print "%s selected for %s" % (hostid, hostname)
149 155
150 w.connect("computer-changed", print_selected_hostid)156 w.connect("computer-changed", print_selected_hostid)
151 157
152 w.remove_computer("DDDDD")158 w.remove_computer("DDDDD")
153 win.show_all()159 win.show_all()
154 return win160 return win
155161
=== modified file 'softwarecenter/ui/gtk3/widgets/recommendations.py'
--- softwarecenter/ui/gtk3/widgets/recommendations.py 2012-03-01 10:43:09 +0000
+++ softwarecenter/ui/gtk3/widgets/recommendations.py 2012-03-09 13:04:23 +0000
@@ -32,16 +32,17 @@
3232
33LOG = logging.getLogger(__name__)33LOG = logging.getLogger(__name__)
3434
35
35class RecommendationsPanel(FramedHeaderBox):36class RecommendationsPanel(FramedHeaderBox):
36 """37 """
37 Base class for widgets that display recommendations38 Base class for widgets that display recommendations
38 """39 """
3940
40 __gsignals__ = {41 __gsignals__ = {
41 "application-activated" : (GObject.SIGNAL_RUN_LAST,42 "application-activated": (GObject.SIGNAL_RUN_LAST,
42 GObject.TYPE_NONE, 43 GObject.TYPE_NONE,
43 (GObject.TYPE_PYOBJECT,),44 (GObject.TYPE_PYOBJECT,),
44 ),45 ),
45 }46 }
4647
47 def __init__(self, catview):48 def __init__(self, catview):
@@ -53,31 +54,32 @@
53 self.catview.connect(54 self.catview.connect(
54 "application-activated", self._on_application_activated)55 "application-activated", self._on_application_activated)
55 self.recommender_agent = RecommenderAgent()56 self.recommender_agent = RecommenderAgent()
57
56 def _on_application_activated(self, catview, app):58 def _on_application_activated(self, catview, app):
57 self.emit("application-activated", app)59 self.emit("application-activated", app)
5860
61
59class RecommendationsPanelLobby(RecommendationsPanel):62class RecommendationsPanelLobby(RecommendationsPanel):
60 """63 """
61 Panel for use in the lobby view that manages the recommendations experience,64 Panel for use in the lobby view that manages the recommendations
62 includes the initial opt-in screen and display of recommendations once they65 experience, includes the initial opt-in screen and display of
63 have been received from the recommender agent66 recommendations once they have been received from the recommender agent
64 """67 """
65
66 __gsignals__ = {68 __gsignals__ = {
67 "recommendations-opt-in" : (GObject.SIGNAL_RUN_LAST,69 "recommendations-opt-in": (GObject.SIGNAL_RUN_LAST,
68 GObject.TYPE_NONE, 70 GObject.TYPE_NONE,
69 (GObject.TYPE_STRING,),71 (GObject.TYPE_STRING,),
72 ),
73 "recommendations-opt-out": (GObject.SIGNAL_RUN_LAST,
74 GObject.TYPE_NONE,
75 (),
70 ),76 ),
71 "recommendations-opt-out" : (GObject.SIGNAL_RUN_LAST,
72 GObject.TYPE_NONE,
73 (),
74 ),
75 }77 }
76 78
77 def __init__(self, catview):79 def __init__(self, catview):
78 RecommendationsPanel.__init__(self, catview)80 RecommendationsPanel.__init__(self, catview)
79 self.set_header_label(_(u"Recommended for You"))81 self.set_header_label(_(u"Recommended for You"))
80 82
81 # if we already have a recommender UUID, then the user is already83 # if we already have a recommender UUID, then the user is already
82 # opted-in to the recommender service84 # opted-in to the recommender service
83 self.recommended_for_you_content = None85 self.recommended_for_you_content = None
@@ -85,14 +87,14 @@
85 self._update_recommended_for_you_content()87 self._update_recommended_for_you_content()
86 else:88 else:
87 self._show_opt_in_view()89 self._show_opt_in_view()
88 90
89 def _show_opt_in_view(self):91 def _show_opt_in_view(self):
90 # opt in box92 # opt in box
91 vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, StockEms.MEDIUM)93 vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, StockEms.MEDIUM)
92 vbox.set_border_width(StockEms.LARGE)94 vbox.set_border_width(StockEms.LARGE)
93 self.opt_in_vbox = vbox # for tests95 self.opt_in_vbox = vbox # for tests
94 self.recommended_for_you_content = vbox # hook it up to the rest96 self.recommended_for_you_content = vbox # hook it up to the rest
95 97
96 self.add(self.recommended_for_you_content)98 self.add(self.recommended_for_you_content)
9799
98 # opt in button100 # opt in button
@@ -111,7 +113,7 @@
111 label.set_alignment(0, 0.5)113 label.set_alignment(0, 0.5)
112 label.set_line_wrap(True)114 label.set_line_wrap(True)
113 vbox.pack_start(label, False, False, 0)115 vbox.pack_start(label, False, False, 0)
114 116
115 def _on_opt_in_button_clicked(self, button):117 def _on_opt_in_button_clicked(self, button):
116 # we upload the user profile here, and only after this is finished118 # we upload the user profile here, and only after this is finished
117 # do we fire the request for recommendations and finally display119 # do we fire the request for recommendations and finally display
@@ -119,11 +121,11 @@
119 # wants a progress bar, but we don't have access to real-time121 # wants a progress bar, but we don't have access to real-time
120 # progress info)122 # progress info)
121 self._upload_user_profile_and_get_recommendations()123 self._upload_user_profile_and_get_recommendations()
122 124
123 def _upload_user_profile_and_get_recommendations(self):125 def _upload_user_profile_and_get_recommendations(self):
124 # initiate upload of the user profile here126 # initiate upload of the user profile here
125 self._upload_user_profile()127 self._upload_user_profile()
126 128
127 def _upload_user_profile(self):129 def _upload_user_profile(self):
128 self.spinner_notebook.show_spinner(_("Submitting inventory…"))130 self.spinner_notebook.show_spinner(_("Submitting inventory…"))
129 self.recommender_agent.connect("submit-profile-finished",131 self.recommender_agent.connect("submit-profile-finished",
@@ -131,7 +133,7 @@
131 self.recommender_agent.connect("error",133 self.recommender_agent.connect("error",
132 self._on_profile_submitted_error)134 self._on_profile_submitted_error)
133 self.recommender_agent.post_submit_profile(self.catview.db)135 self.recommender_agent.post_submit_profile(self.catview.db)
134 136
135 def _on_profile_submitted(self, agent, profile, recommender_uuid):137 def _on_profile_submitted(self, agent, profile, recommender_uuid):
136 # after the user profile data has been uploaded, make the request138 # after the user profile data has been uploaded, make the request
137 # and load the the recommended_for_you content139 # and load the the recommended_for_you content
@@ -139,13 +141,13 @@
139 "submitted to the recommender agent")141 "submitted to the recommender agent")
140 self.emit("recommendations-opt-in", recommender_uuid)142 self.emit("recommendations-opt-in", recommender_uuid)
141 self._update_recommended_for_you_content()143 self._update_recommended_for_you_content()
142 144
143 def _on_profile_submitted_error(self, agent, msg):145 def _on_profile_submitted_error(self, agent, msg):
144 LOG.warn("Error while submitting the recommendations profile to the "146 LOG.warn("Error while submitting the recommendations profile to the "
145 "recommender agent: %s" % msg)147 "recommender agent: %s" % msg)
146 # TODO: handle this! display an error message in the panel148 # TODO: handle this! display an error message in the panel
147 self._hide_recommended_for_you_panel()149 self._hide_recommended_for_you_panel()
148 150
149 def _update_recommended_for_you_content(self):151 def _update_recommended_for_you_content(self):
150 # destroy the old content to ensure we don't see it twice152 # destroy the old content to ensure we don't see it twice
151 # (also removes the opt-in panel if it was there)153 # (also removes the opt-in panel if it was there)
@@ -163,7 +165,7 @@
163 self._on_recommended_for_you_agent_refresh)165 self._on_recommended_for_you_agent_refresh)
164 self.recommended_for_you_cat.connect('recommender-agent-error',166 self.recommended_for_you_cat.connect('recommender-agent-error',
165 self._on_recommender_agent_error)167 self._on_recommender_agent_error)
166 168
167 def _on_recommended_for_you_agent_refresh(self, cat):169 def _on_recommended_for_you_agent_refresh(self, cat):
168 docs = cat.get_documents(self.catview.db)170 docs = cat.get_documents(self.catview.db)
169 # display the recommendedations171 # display the recommendedations
@@ -179,8 +181,7 @@
179 # TODO: this test for zero docs is temporary and will not be181 # TODO: this test for zero docs is temporary and will not be
180 # needed once the recommendation agent is up and running182 # needed once the recommendation agent is up and running
181 self._hide_recommended_for_you_panel()183 self._hide_recommended_for_you_panel()
182 return184
183
184 def _on_recommender_agent_error(self, agent, msg):185 def _on_recommender_agent_error(self, agent, msg):
185 LOG.warn("Error while accessing the recommender agent for the "186 LOG.warn("Error while accessing the recommender agent for the "
186 "lobby recommendations: %s" % msg)187 "lobby recommendations: %s" % msg)
@@ -190,8 +191,8 @@
190 def _hide_recommended_for_you_panel(self):191 def _hide_recommended_for_you_panel(self):
191 # and hide the pane192 # and hide the pane
192 self.hide()193 self.hide()
193 194
194 195
195class RecommendationsPanelDetails(RecommendationsPanel):196class RecommendationsPanelDetails(RecommendationsPanel):
196 """197 """
197 Panel for use in the details view to display recommendations for a given198 Panel for use in the details view to display recommendations for a given
@@ -202,7 +203,7 @@
202 self.set_header_label(_(u"People Also Installed"))203 self.set_header_label(_(u"People Also Installed"))
203 self.app_recommendations_content = FlowableGrid()204 self.app_recommendations_content = FlowableGrid()
204 self.add(self.app_recommendations_content)205 self.add(self.app_recommendations_content)
205 206
206 def set_pkgname(self, pkgname):207 def set_pkgname(self, pkgname):
207 self.pkgname = pkgname208 self.pkgname = pkgname
208 self._update_app_recommendations_content()209 self._update_app_recommendations_content()
@@ -217,7 +218,7 @@
217 self._on_app_recommendations_agent_refresh)218 self._on_app_recommendations_agent_refresh)
218 self.app_recommendations_cat.connect('recommender-agent-error',219 self.app_recommendations_cat.connect('recommender-agent-error',
219 self._on_recommender_agent_error)220 self._on_recommender_agent_error)
220 221
221 def _on_app_recommendations_agent_refresh(self, cat):222 def _on_app_recommendations_agent_refresh(self, cat):
222 docs = cat.get_documents(self.catview.db)223 docs = cat.get_documents(self.catview.db)
223 # display the recommendations224 # display the recommendations
@@ -228,8 +229,7 @@
228 self.spinner_notebook.hide_spinner()229 self.spinner_notebook.hide_spinner()
229 else:230 else:
230 self._hide_app_recommendations_panel()231 self._hide_app_recommendations_panel()
231 return232
232
233 def _on_recommender_agent_error(self, agent, msg):233 def _on_recommender_agent_error(self, agent, msg):
234 LOG.warn("Error while accessing the recommender agent for the "234 LOG.warn("Error while accessing the recommender agent for the "
235 "details view recommendations: %s" % msg)235 "details view recommendations: %s" % msg)
@@ -239,7 +239,7 @@
239 def _hide_app_recommendations_panel(self):239 def _hide_app_recommendations_panel(self):
240 # and hide the pane240 # and hide the pane
241 self.hide()241 self.hide()
242 242
243243
244# test helpers244# test helpers
245def get_test_window():245def get_test_window():
@@ -247,7 +247,6 @@
247 softwarecenter.log.root.setLevel(level=logging.DEBUG)247 softwarecenter.log.root.setLevel(level=logging.DEBUG)
248 fmt = logging.Formatter("%(name)s - %(message)s", None)248 fmt = logging.Formatter("%(name)s - %(message)s", None)
249 softwarecenter.log.handler.setFormatter(fmt)249 softwarecenter.log.handler.setFormatter(fmt)
250
251250
252 # this is *way* to complicated we should *not* need a CatView251 # this is *way* to complicated we should *not* need a CatView
253 # here! see FIXME in RecommendationsPanel.__init__()252 # here! see FIXME in RecommendationsPanel.__init__()
@@ -259,7 +258,7 @@
259 icons = get_test_gtk3_icon_cache()258 icons = get_test_gtk3_icon_cache()
260 catview = CategoriesViewGtk(softwarecenter.paths.datadir,259 catview = CategoriesViewGtk(softwarecenter.paths.datadir,
261 softwarecenter.paths.APP_INSTALL_PATH,260 softwarecenter.paths.APP_INSTALL_PATH,
262 cache, 261 cache,
263 db,262 db,
264 icons)263 icons)
265264
@@ -271,9 +270,9 @@
271 win.set_data("rec_panel", view)270 win.set_data("rec_panel", view)
272 win.set_size_request(600, 200)271 win.set_size_request(600, 200)
273 win.show_all()272 win.show_all()
274 273
275 return win274 return win
276 275
277276
278if __name__ == "__main__":277if __name__ == "__main__":
279 win = get_test_window()278 win = get_test_window()
280279
=== modified file 'test/test_pep8.py'
--- test/test_pep8.py 2012-03-08 22:33:18 +0000
+++ test/test_pep8.py 2012-03-09 13:04:23 +0000
@@ -16,8 +16,7 @@
16 packages = [softwarecenter.ui.qml,16 packages = [softwarecenter.ui.qml,
17 softwarecenter.ui.gtk3.widgets,17 softwarecenter.ui.gtk3.widgets,
18 softwarecenter.db.pkginfo_impl]18 softwarecenter.db.pkginfo_impl]
19 exclude = ['recommendations.py', 'oneconfviews.py', 'menubutton.py',19 exclude = ['description.py',
20 'labels.py', 'imagedialog.py', 'exhibits.py', 'description.py',
21 'containers.py', 'cellrenderers.py', 'buttons.py', 'backforward.py',20 'containers.py', 'cellrenderers.py', 'buttons.py', 'backforward.py',
22 'apptreeview.py', 'animatedimage.py', 'actionbar.py']21 'apptreeview.py', 'animatedimage.py', 'actionbar.py']
2322