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

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
Reviewer Review Type Date Requested Status
Kiwinote Approve
Review via email: mp+97453@code.launchpad.net

Description of the change

Most of the files in softwarecenter.ui.gtk3.views now pass the pep8 test.

To post a comment you must log in.
Revision history for this message
Kiwinote (kiwinote) wrote :

thanks a lot for this! looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'softwarecenter/ui/gtk3/views/appview.py'
--- softwarecenter/ui/gtk3/views/appview.py 2012-03-08 15:13:30 +0000
+++ softwarecenter/ui/gtk3/views/appview.py 2012-03-14 16:41:35 +0000
@@ -29,7 +29,8 @@
29from softwarecenter.ui.gtk3.models.appstore2 import AppPropertiesHelper29from softwarecenter.ui.gtk3.models.appstore2 import AppPropertiesHelper
30from softwarecenter.utils import ExecutionTime30from softwarecenter.utils import ExecutionTime
3131
32LOG=logging.getLogger(__name__)32LOG = logging.getLogger(__name__)
33
3334
34class AppView(Gtk.VBox):35class AppView(Gtk.VBox):
3536
@@ -38,16 +39,16 @@
38 None,39 None,
39 (GObject.TYPE_PYOBJECT, ),40 (GObject.TYPE_PYOBJECT, ),
40 ),41 ),
41 "application-activated" : (GObject.SignalFlags.RUN_LAST,42 "application-activated": (GObject.SignalFlags.RUN_LAST,
42 None,43 None,
43 (GObject.TYPE_PYOBJECT, ),44 (GObject.TYPE_PYOBJECT, ),
44 ),45 ),
45 "application-selected" : (GObject.SignalFlags.RUN_LAST,46 "application-selected": (GObject.SignalFlags.RUN_LAST,
46 None,47 None,
47 (GObject.TYPE_PYOBJECT, ),48 (GObject.TYPE_PYOBJECT, ),
48 ),49 ),
49 }50 }
50 51
51 (INSTALLED_MODE, AVAILABLE_MODE, DIFF_MODE) = range(3)52 (INSTALLED_MODE, AVAILABLE_MODE, DIFF_MODE) = range(3)
5253
53 _SORT_METHOD_INDEX = (SortMethods.BY_ALPHABET,54 _SORT_METHOD_INDEX = (SortMethods.BY_ALPHABET,
@@ -97,14 +98,13 @@
97 self._handler = self.sort_methods_combobox.connect(98 self._handler = self.sort_methods_combobox.connect(
98 "changed",99 "changed",
99 self.on_sort_method_changed)100 self.on_sort_method_changed)
100 return
101101
102 #~ def on_draw(self, w, cr):102 #~ def on_draw(self, w, cr):
103 #~ cr.set_source_rgb(1,1,1)103 #~ cr.set_source_rgb(1,1,1)
104 #~ cr.paint()104 #~ cr.paint()
105105
106 def _append_appcount(self, appcount, mode=AVAILABLE_MODE):106 def _append_appcount(self, appcount, mode=AVAILABLE_MODE):
107#~ 107#~
108 #~ if mode == self.INSTALLED_MODE:108 #~ if mode == self.INSTALLED_MODE:
109 #~ text = gettext.ngettext("%(amount)s item installed",109 #~ text = gettext.ngettext("%(amount)s item installed",
110 #~ "%(amount)s items installed",110 #~ "%(amount)s items installed",
@@ -112,12 +112,12 @@
112 #~ elif mode == self.DIFF_MODE:112 #~ elif mode == self.DIFF_MODE:
113 #~ text = gettext.ngettext("%(amount)s item",113 #~ text = gettext.ngettext("%(amount)s item",
114 #~ "%(amount)s items",114 #~ "%(amount)s items",
115 #~ appcount) % { 'amount' : appcount, } 115 #~ appcount) % { 'amount' : appcount, }
116 #~ else:116 #~ else:
117 #~ text = gettext.ngettext("%(amount)s item available",117 #~ text = gettext.ngettext("%(amount)s item available",
118 #~ "%(amount)s items available",118 #~ "%(amount)s items available",
119 #~ appcount) % { 'amount' : appcount, }119 #~ appcount) % { 'amount' : appcount, }
120#~ 120#~
121 #~ if not self.appcount:121 #~ if not self.appcount:
122 #~ self.appcount = Gtk.Label()122 #~ self.appcount = Gtk.Label()
123 #~ self.appcount.set_alignment(0.5, 0.5)123 #~ self.appcount.set_alignment(0.5, 0.5)
@@ -127,13 +127,12 @@
127 #~ self.vbox.pack_start(self.appcount, False, False, 0)127 #~ self.vbox.pack_start(self.appcount, False, False, 0)
128 #~ self.appcount.set_text(text)128 #~ self.appcount.set_text(text)
129 #~ self.appcount.show()129 #~ self.appcount.show()
130 return130 pass
131131
132 def on_sort_method_changed(self, *args):132 def on_sort_method_changed(self, *args):
133 self.user_defined_sort_method = True133 self.user_defined_sort_method = True
134 self.vadj = 0.0134 self.vadj = 0.0
135 self.emit("sort-method-changed", self.sort_methods_combobox)135 self.emit("sort-method-changed", self.sort_methods_combobox)
136 return
137136
138 def _get_sort_methods_combobox(self):137 def _get_sort_methods_combobox(self):
139 combo = Gtk.ComboBoxText.new()138 combo = Gtk.ComboBoxText.new()
@@ -151,25 +150,21 @@
151 if self._get_combo_children() == 4:150 if self._get_combo_children() == 4:
152 return151 return
153 self.sort_methods_combobox.append_text(_("By Relevance"))152 self.sort_methods_combobox.append_text(_("By Relevance"))
154 return
155153
156 def _use_combobox_without_sort_by_search_ranking(self):154 def _use_combobox_without_sort_by_search_ranking(self):
157 if self._get_combo_children() == 3:155 if self._get_combo_children() == 3:
158 return156 return
159 self.sort_methods_combobox.remove(self._SORT_BY_SEARCH_RANKING)157 self.sort_methods_combobox.remove(self._SORT_BY_SEARCH_RANKING)
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)
161 return
162159
163 def set_sort_method_with_no_signal(self, sort_method):160 def set_sort_method_with_no_signal(self, sort_method):
164 combo = self.sort_methods_combobox161 combo = self.sort_methods_combobox
165 combo.handler_block(self._handler)162 combo.handler_block(self._handler)
166 combo.set_active(sort_method)163 combo.set_active(sort_method)
167 combo.handler_unblock(self._handler)164 combo.handler_unblock(self._handler)
168 return
169165
170 def set_allow_user_sorting(self, do_allow):166 def set_allow_user_sorting(self, do_allow):
171 self.sort_methods_combobox.set_visible(do_allow)167 self.sort_methods_combobox.set_visible(do_allow)
172 return
173168
174 def set_header_labels(self, first_line, second_line):169 def set_header_labels(self, first_line, second_line):
175 if second_line:170 if second_line:
@@ -180,7 +175,6 @@
180175
181 def set_model(self, model):176 def set_model(self, model):
182 self.tree_view.set_model(model)177 self.tree_view.set_model(model)
183 return
184178
185 def display_matches(self, matches, is_search=False):179 def display_matches(self, matches, is_search=False):
186 # FIXME: installedpane handles display of the trees intimately,180 # FIXME: installedpane handles display of the trees intimately,
@@ -210,7 +204,6 @@
210204
211 self.tree_view_scroll.get_vadjustment().set_lower(self.vadj)205 self.tree_view_scroll.get_vadjustment().set_lower(self.vadj)
212 self.tree_view_scroll.get_vadjustment().set_value(self.vadj)206 self.tree_view_scroll.get_vadjustment().set_value(self.vadj)
213 return
214207
215 def clear_model(self):208 def clear_model(self):
216 return self.tree_view.clear_model()209 return self.tree_view.clear_model()
@@ -218,7 +211,7 @@
218 def get_sort_mode(self):211 def get_sort_mode(self):
219 active_index = self.sort_methods_combobox.get_active()212 active_index = self.sort_methods_combobox.get_active()
220 return self._SORT_METHOD_INDEX[active_index]213 return self._SORT_METHOD_INDEX[active_index]
221 214
222 def get_app_icon_details(self):215 def get_app_icon_details(self):
223 """ helper for unity dbus support to provide details about the216 """ helper for unity dbus support to provide details about the
224 application icon as it is displayed on-screen217 application icon as it is displayed on-screen
@@ -239,7 +232,7 @@
239 else:232 else:
240 icon_size = pb.get_height()233 icon_size = pb.get_height()
241 return icon_size234 return icon_size
242 235
243 def _get_app_icon_xy_position_on_screen(self):236 def _get_app_icon_xy_position_on_screen(self):
244 """ helper for unity dbus support to get the x,y position of237 """ helper for unity dbus support to get the x,y position of
245 the application icon as it is displayed on-screen238 the application icon as it is displayed on-screen
@@ -251,16 +244,14 @@
251 # get toplevel window position244 # get toplevel window position
252 (px, py) = parent.get_position()245 (px, py) = parent.get_position()
253 # and return the coordinate values246 # and return the coordinate values
254 return (px+self.tree_view.selected_row_renderer.icon_x_offset,247 return (px + self.tree_view.selected_row_renderer.icon_x_offset,
255 py+self.tree_view.selected_row_renderer.icon_y_offset)248 py + self.tree_view.selected_row_renderer.icon_y_offset)
256
257
258
259249
260250
261# ----------------------------------------------- testcode251# ----------------------------------------------- testcode
262from softwarecenter.enums import NonAppVisibility252from softwarecenter.enums import NonAppVisibility
263253
254
264def get_query_from_search_entry(search_term):255def get_query_from_search_entry(search_term):
265 import xapian256 import xapian
266 if not search_term:257 if not search_term:
@@ -269,6 +260,7 @@
269 user_query = parser.parse_query(search_term)260 user_query = parser.parse_query(search_term)
270 return user_query261 return user_query
271262
263
272def on_entry_changed(widget, data):264def on_entry_changed(widget, data):
273265
274 def _work():266 def _work():
@@ -278,8 +270,8 @@
278 with ExecutionTime("total time"):270 with ExecutionTime("total time"):
279 with ExecutionTime("enquire.set_query()"):271 with ExecutionTime("enquire.set_query()"):
280 enquirer.set_query(get_query_from_search_entry(new_text),272 enquirer.set_query(get_query_from_search_entry(new_text),
281 limit=100*1000,273 limit=100 * 1000,
282 nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE)274 nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE)
283275
284 store = view.tree_view.get_model()276 store = view.tree_view.get_model()
285 with ExecutionTime("store.clear()"):277 with ExecutionTime("store.clear()"):
@@ -293,10 +285,11 @@
293 Gtk.main_iteration()285 Gtk.main_iteration()
294 return286 return
295287
296 if widget.stamp: 288 if widget.stamp:
297 GObject.source_remove(widget.stamp)289 GObject.source_remove(widget.stamp)
298 widget.stamp = GObject.timeout_add(250, _work)290 widget.stamp = GObject.timeout_add(250, _work)
299291
292
300def get_test_window():293def get_test_window():
301 import softwarecenter.log294 import softwarecenter.log
302 softwarecenter.log.root.setLevel(level=logging.DEBUG)295 softwarecenter.log.root.setLevel(level=logging.DEBUG)
303296
=== modified file 'softwarecenter/ui/gtk3/views/catview_gtk.py'
--- softwarecenter/ui/gtk3/views/catview_gtk.py 2012-03-08 09:13:23 +0000
+++ softwarecenter/ui/gtk3/views/catview_gtk.py 2012-03-14 16:41:35 +0000
@@ -55,31 +55,33 @@
55from softwarecenter.backend.scagent import SoftwareCenterAgent55from softwarecenter.backend.scagent import SoftwareCenterAgent
56from softwarecenter.backend.reviews import get_review_loader56from softwarecenter.backend.reviews import get_review_loader
5757
58LOG=logging.getLogger(__name__)58LOG = logging.getLogger(__name__)
5959
6060
61_asset_cache = {}61_asset_cache = {}
62
63
62class CategoriesViewGtk(Viewport, CategoriesParser):64class CategoriesViewGtk(Viewport, CategoriesParser):
6365
64 __gsignals__ = {66 __gsignals__ = {
65 "category-selected" : (GObject.SignalFlags.RUN_LAST,67 "category-selected": (GObject.SignalFlags.RUN_LAST,
66 None, 68 None,
67 (GObject.TYPE_PYOBJECT, ),69 (GObject.TYPE_PYOBJECT, ),
68 ),70 ),
69 71
70 "application-selected" : (GObject.SignalFlags.RUN_LAST,72 "application-selected": (GObject.SignalFlags.RUN_LAST,
73 None,
74 (GObject.TYPE_PYOBJECT, ),
75 ),
76
77 "application-activated": (GObject.SignalFlags.RUN_LAST,
71 None,78 None,
72 (GObject.TYPE_PYOBJECT, ),79 (GObject.TYPE_PYOBJECT, ),
73 ),80 ),
7481
75 "application-activated" : (GObject.SignalFlags.RUN_LAST,82 "show-category-applist": (GObject.SignalFlags.RUN_LAST,
76 None,83 None,
77 (GObject.TYPE_PYOBJECT, ),84 (),)
78 ),
79
80 "show-category-applist" : (GObject.SignalFlags.RUN_LAST,
81 None,
82 (),)
83 }85 }
8486
85 SPACING = PADDING = 387 SPACING = PADDING = 3
@@ -88,17 +90,17 @@
88 STIPPLE = os.path.join(softwarecenter.paths.datadir,90 STIPPLE = os.path.join(softwarecenter.paths.datadir,
89 "ui/gtk3/art/stipple.png")91 "ui/gtk3/art/stipple.png")
9092
91 def __init__(self, 93 def __init__(self,
92 datadir,94 datadir,
93 desktopdir, 95 desktopdir,
94 cache,96 cache,
95 db,97 db,
96 icons,98 icons,
97 apps_filter=None, # FIXME: kill this, its not needed anymore?99 apps_filter=None, # FIXME: kill this, its not needed anymore?
98 apps_limit=0):100 apps_limit=0):
99101
100 """ init the widget, takes102 """ init the widget, takes
101 103
102 datadir - the base directory of the app-store data104 datadir - the base directory of the app-store data
103 desktopdir - the dir where the applications.menu file can be found105 desktopdir - the dir where the applications.menu file can be found
104 db - a Database object106 db - a Database object
@@ -172,7 +174,8 @@
172174
173 def _cache_art_assets(self):175 def _cache_art_assets(self):
174 global _asset_cache176 global _asset_cache
175 if _asset_cache: return _asset_cache177 if _asset_cache:
178 return _asset_cache
176 assets = _asset_cache179 assets = _asset_cache
177 # cache the bg pattern180 # cache the bg pattern
178 surf = cairo.ImageSurface.create_from_png(self.STIPPLE)181 surf = cairo.ImageSurface.create_from_png(self.STIPPLE)
@@ -189,7 +192,6 @@
189 return False192 return False
190193
191 GObject.timeout_add(50, timeout_emit)194 GObject.timeout_add(50, timeout_emit)
192 return
193195
194 def on_category_clicked(self, btn, cat):196 def on_category_clicked(self, btn, cat):
195 """emit the category-selected signal when a category was clicked"""197 """emit the category-selected signal when a category was clicked"""
@@ -198,7 +200,6 @@
198 return False200 return False
199201
200 GObject.timeout_add(50, timeout_emit)202 GObject.timeout_add(50, timeout_emit)
201 return
202203
203 def build(self, desktopdir):204 def build(self, desktopdir):
204 pass205 pass
@@ -206,14 +207,14 @@
206 def do_draw(self, cr):207 def do_draw(self, cr):
207 cr.set_source(_asset_cache["stipple"])208 cr.set_source(_asset_cache["stipple"])
208 cr.paint_with_alpha(0.5)209 cr.paint_with_alpha(0.5)
209 for child in self: self.propagate_draw(child, cr)210 for child in self:
210 return211 self.propagate_draw(child, cr)
211212
212 def set_section(self, section):213 def set_section(self, section):
213 self.section = section214 self.section = section
214215
215 def refresh_apps(self):216 def refresh_apps(self):
216 raise NotImplemented217 raise NotImplementedError
217218
218219
219class LobbyViewGtk(CategoriesViewGtk):220class LobbyViewGtk(CategoriesViewGtk):
@@ -251,7 +252,8 @@
251252
252 self.top_hbox = Gtk.HBox(spacing=StockEms.SMALL)253 self.top_hbox = Gtk.HBox(spacing=StockEms.SMALL)
253 top_hbox_alignment = Gtk.Alignment()254 top_hbox_alignment = Gtk.Alignment()
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,
256 StockEms.MEDIUM - 2)
255 top_hbox_alignment.add(self.top_hbox)257 top_hbox_alignment.add(self.top_hbox)
256 self.vbox.pack_start(top_hbox_alignment, False, False, 0)258 self.vbox.pack_start(top_hbox_alignment, False, False, 0)
257259
@@ -271,33 +273,33 @@
271273
272 #~ def _append_top_of_the_pops(self):274 #~ def _append_top_of_the_pops(self):
273 #~ self.totp_hbox = Gtk.HBox(spacing=self.SPACING)275 #~ self.totp_hbox = Gtk.HBox(spacing=self.SPACING)
274#~ 276#~
275 #~ alignment = Gtk.Alignment()277 #~ alignment = Gtk.Alignment()
276 #~ alignment.set_padding(0, 0, self.PADDING, self.PADDING)278 #~ alignment.set_padding(0, 0, self.PADDING, self.PADDING)
277 #~ alignment.add(self.totp_hbox)279 #~ alignment.add(self.totp_hbox)
278#~ 280#~
279 #~ frame = FramedHeaderBox()281 #~ frame = FramedHeaderBox()
280 #~ frame.header_implements_more_button()282 #~ frame.header_implements_more_button()
281 #~ frame.set_header_label(_("Most Popular"))283 #~ frame.set_header_label(_("Most Popular"))
282#~ 284#~
283 #~ label = Gtk.Label.new("Soda pop!!!")285 #~ label = Gtk.Label.new("Soda pop!!!")
284 #~ label.set_name("placeholder")286 #~ label.set_name("placeholder")
285 #~ label.set_size_request(-1, 200)287 #~ label.set_size_request(-1, 200)
286#~ 288#~
287 #~ frame.add(label)289 #~ frame.add(label)
288 #~ self.totp_hbox.add(frame)290 #~ self.totp_hbox.add(frame)
289#~ 291#~
290 #~ frame = FramedHeaderBox()292 #~ frame = FramedHeaderBox()
291 #~ frame.header_implements_more_button()293 #~ frame.header_implements_more_button()
292 #~ frame.set_header_label(_("Top Rated"))294 #~ frame.set_header_label(_("Top Rated"))
293#~ 295#~
294 #~ label = Gtk.Label.new("Demos ftw(?)")296 #~ label = Gtk.Label.new("Demos ftw(?)")
295 #~ label.set_name("placeholder")297 #~ label.set_name("placeholder")
296 #~ label.set_size_request(-1, 200)298 #~ label.set_size_request(-1, 200)
297#~ 299#~
298 #~ frame.add(label)300 #~ frame.add(label)
299 #~ self.totp_hbox.add(frame)301 #~ self.totp_hbox.add(frame)
300#~ 302#~
301 #~ self.vbox.pack_start(alignment, False, False, 0)303 #~ self.vbox.pack_start(alignment, False, False, 0)
302 #~ return304 #~ return
303305
@@ -306,17 +308,17 @@
306 #~ frame.set_header_expand(False)308 #~ frame.set_header_expand(False)
307 #~ frame.set_header_position(HeaderPosition.LEFT)309 #~ frame.set_header_position(HeaderPosition.LEFT)
308 #~ frame.set_header_label(_("Latest Demo Videos"))310 #~ frame.set_header_label(_("Latest Demo Videos"))
309#~ 311#~
310 #~ label = Gtk.Label.new("Videos go here")312 #~ label = Gtk.Label.new("Videos go here")
311 #~ label.set_name("placeholder")313 #~ label.set_name("placeholder")
312 #~ label.set_size_request(-1, 200)314 #~ label.set_size_request(-1, 200)
313#~ 315#~
314 #~ frame.add(label)316 #~ frame.add(label)
315#~ 317#~
316 #~ alignment = Gtk.Alignment()318 #~ alignment = Gtk.Alignment()
317 #~ alignment.set_padding(0, 0, self.PADDING, self.PADDING)319 #~ alignment.set_padding(0, 0, self.PADDING, self.PADDING)
318 #~ alignment.add(frame)320 #~ alignment.add(frame)
319#~ 321#~
320 #~ self.vbox.pack_start(alignment, False, False, 0)322 #~ self.vbox.pack_start(alignment, False, False, 0)
321 #~ return323 #~ return
322324
@@ -343,18 +345,19 @@
343 # query using the agent345 # query using the agent
344 scagent = SoftwareCenterAgent()346 scagent = SoftwareCenterAgent()
345 scagent.connect(347 scagent.connect(
346 "exhibits", lambda sca,l: exhibit_banner.set_exhibits(l))348 "exhibits", lambda sca, l: exhibit_banner.set_exhibits(l))
347 scagent.query_exhibits()349 scagent.query_exhibits()
348350
349 a = Gtk.Alignment()351 a = Gtk.Alignment()
350 a.set_padding(0,StockEms.SMALL,0,0)352 a.set_padding(0, StockEms.SMALL, 0, 0)
351 a.add(exhibit_banner)353 a.add(exhibit_banner)
352354
353 self.vbox.pack_start(a, False, False, 0)355 self.vbox.pack_start(a, False, False, 0)
354 return356 return
355357
356 def _append_departments(self):358 def _append_departments(self):
357 # set the departments section to use the label markup we have just defined359 # set the departments section to use the label markup we have just
360 # defined
358 cat_vbox = FramedBox(Gtk.Orientation.VERTICAL)361 cat_vbox = FramedBox(Gtk.Orientation.VERTICAL)
359 self.top_hbox.pack_start(cat_vbox, False, False, 0)362 self.top_hbox.pack_start(cat_vbox, False, False, 0)
360363
@@ -363,7 +366,8 @@
363366
364 mrkup = "<small>%s</small>"367 mrkup = "<small>%s</small>"
365 for cat in sorted_cats:368 for cat in sorted_cats:
366 if 'carousel-only' in cat.flags: continue369 if 'carousel-only' in cat.flags:
370 continue
367 category_name = mrkup % GObject.markup_escape_text(cat.name)371 category_name = mrkup % GObject.markup_escape_text(cat.name)
368 label = LabelTile(category_name, None)372 label = LabelTile(category_name, None)
369 label.label.set_margin_left(StockEms.SMALL)373 label.label.set_margin_left(StockEms.SMALL)
@@ -400,8 +404,8 @@
400 # only display the 'More' LinkButton if we have top_rated content404 # only display the 'More' LinkButton if we have top_rated content
401 if top_rated_cat is not None:405 if top_rated_cat is not None:
402 self.top_rated_frame.header_implements_more_button()406 self.top_rated_frame.header_implements_more_button()
403 self.top_rated_frame.more.connect('clicked', 407 self.top_rated_frame.more.connect('clicked',
404 self.on_category_clicked, top_rated_cat) 408 self.on_category_clicked, top_rated_cat)
405 return409 return
406410
407 def _update_whats_new_content(self):411 def _update_whats_new_content(self):
@@ -409,7 +413,7 @@
409 self.whats_new.remove_all()413 self.whats_new.remove_all()
410 # get top_rated category and docs414 # get top_rated category and docs
411 whats_new_cat = get_category_by_name(415 whats_new_cat = get_category_by_name(
412 self.categories, u"What\u2019s New") # untranslated name416 self.categories, u"What\u2019s New") # untranslated name
413 if whats_new_cat:417 if whats_new_cat:
414 docs = whats_new_cat.get_documents(self.db)418 docs = whats_new_cat.get_documents(self.db)
415 self._add_tiles_to_flowgrid(docs, self.whats_new, 8)419 self._add_tiles_to_flowgrid(docs, self.whats_new, 8)
@@ -428,33 +432,33 @@
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)
429 self.whats_new_frame.header_implements_more_button()433 self.whats_new_frame.header_implements_more_button()
430 self.whats_new_frame.more.connect(434 self.whats_new_frame.more.connect(
431 'clicked', self.on_category_clicked, whats_new_cat) 435 'clicked', self.on_category_clicked, whats_new_cat)
432 return436
433
434 def _update_recommended_for_you_content(self):437 def _update_recommended_for_you_content(self):
435 if (self.recommended_for_you_panel and438 if (self.recommended_for_you_panel and
436 self.recommended_for_you_panel.get_parent()):439 self.recommended_for_you_panel.get_parent()):
437 self.bottom_hbox.remove(self.recommended_for_you_panel)440 self.bottom_hbox.remove(self.recommended_for_you_panel)
438 self.recommended_for_you_panel = RecommendationsPanelLobby(self)441 self.recommended_for_you_panel = RecommendationsPanelLobby(self)
439 self.bottom_hbox.pack_start(self.recommended_for_you_panel, 442 self.bottom_hbox.pack_start(self.recommended_for_you_panel,
440 True, True, 0)443 True, True, 0)
441 444
442 def _append_recommended_for_you(self):445 def _append_recommended_for_you(self):
443 # TODO: This space will initially contain an opt-in screen, and this446 # TODO: This space will initially contain an opt-in screen, and this
444 # will update to the tile view of recommended apps when ready447 # will update to the tile view of recommended apps when ready
445 # see https://wiki.ubuntu.com/SoftwareCenter#Home_screen448 # see https://wiki.ubuntu.com/SoftwareCenter#Home_screen
446 self.bottom_hbox = Gtk.HBox(spacing=StockEms.SMALL)449 self.bottom_hbox = Gtk.HBox(spacing=StockEms.SMALL)
447 bottom_hbox_alignment = Gtk.Alignment()450 bottom_hbox_alignment = Gtk.Alignment()
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,
452 StockEms.MEDIUM - 2)
449 bottom_hbox_alignment.add(self.bottom_hbox)453 bottom_hbox_alignment.add(self.bottom_hbox)
450 self.vbox.pack_start(bottom_hbox_alignment, False, False, 0)454 self.vbox.pack_start(bottom_hbox_alignment, False, False, 0)
451 455
452 # TODO: During development, place the "Recommended for You" panel456 # TODO: During development, place the "Recommended for You" panel
453 # at the bottom, but swap this with the Top Rated panel once457 # at the bottom, but swap this with the Top Rated panel once
454 # the recommended for you pieces are done and deployed458 # the recommended for you pieces are done and deployed
455 # see https://wiki.ubuntu.com/SoftwareCenter#Home_screen459 # see https://wiki.ubuntu.com/SoftwareCenter#Home_screen
456 self.recommended_for_you_panel = RecommendationsPanelLobby(self)460 self.recommended_for_you_panel = RecommendationsPanelLobby(self)
457 self.bottom_hbox.pack_start(self.recommended_for_you_panel, 461 self.bottom_hbox.pack_start(self.recommended_for_you_panel,
458 True, True, 0)462 True, True, 0)
459463
460 def _update_appcount(self):464 def _update_appcount(self):
@@ -468,7 +472,7 @@
468472
469 length = enq.get_estimated_matches_count(query)473 length = enq.get_estimated_matches_count(query)
470 text = gettext.ngettext("%(amount)s item", "%(amount)s items", length474 text = gettext.ngettext("%(amount)s item", "%(amount)s items", length
471 ) % { 'amount' : length, }475 ) % {'amount': length}
472 self.appcount.set_text(text)476 self.appcount.set_text(text)
473477
474 def _append_appcount(self):478 def _append_appcount(self):
@@ -499,7 +503,7 @@
499 self._update_appcount()503 self._update_appcount()
500 return504 return
501505
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
503 # again507 # again
504 def stop_carousels(self):508 def stop_carousels(self):
505 pass509 pass
@@ -507,6 +511,7 @@
507 def start_carousels(self):511 def start_carousels(self):
508 pass512 pass
509513
514
510class SubCategoryViewGtk(CategoriesViewGtk):515class SubCategoryViewGtk(CategoriesViewGtk):
511516
512 def __init__(self, datadir, desktopdir, cache, db, icons,517 def __init__(self, datadir, desktopdir, cache, db, icons,
@@ -529,8 +534,8 @@
529 self.appcount = None534 self.appcount = None
530535
531 # widgetry536 # widgetry
532 self.vbox.set_margin_left(StockEms.MEDIUM-2)537 self.vbox.set_margin_left(StockEms.MEDIUM - 2)
533 self.vbox.set_margin_right(StockEms.MEDIUM-2)538 self.vbox.set_margin_right(StockEms.MEDIUM - 2)
534 self.vbox.set_margin_top(StockEms.MEDIUM)539 self.vbox.set_margin_top(StockEms.MEDIUM)
535 return540 return
536541
@@ -544,15 +549,17 @@
544 nonblocking_load=False)549 nonblocking_load=False)
545 return self.enquire.get_documents()550 return self.enquire.get_documents()
546551
547 @wait_for_apt_cache_ready # be consistent with new apps552 @wait_for_apt_cache_ready # be consistent with new apps
548 def _update_sub_top_rated_content(self, category):553 def _update_sub_top_rated_content(self, category):
549 self.top_rated.remove_all()554 self.top_rated.remove_all()
550 # FIXME: should this be m = "%s %s" % (_(gettext text), header text) ??555 # FIXME: should this be m = "%s %s" % (_(gettext text), header text) ??
551 # TRANSLATORS: %s is a category name, like Internet or Development Tools556 # TRANSLATORS: %s is a category name, like Internet or Development
552 m = _('Top Rated %(category)s') % { 'category' : GObject.markup_escape_text(self.header)}557 # Tools
558 m = _('Top Rated %(category)s') % {
559 'category': GObject.markup_escape_text(self.header)}
553 self.top_rated_frame.set_header_label(m)560 self.top_rated_frame.set_header_label(m)
554 docs = self._get_sub_top_rated_content(category)561 docs = self._get_sub_top_rated_content(category)
555 self._add_tiles_to_flowgrid(docs, self.top_rated, 562 self._add_tiles_to_flowgrid(docs, self.top_rated,
556 TOP_RATED_CAROUSEL_LIMIT)563 TOP_RATED_CAROUSEL_LIMIT)
557 return564 return
558565
@@ -570,7 +577,8 @@
570577
571 # set the subcat header578 # set the subcat header
572 m = "<b><big>%s</big></b>"579 m = "<b><big>%s</big></b>"
573 self.subcat_label.set_markup(m % GObject.markup_escape_text(self.header))580 self.subcat_label.set_markup(m % GObject.markup_escape_text(
581 self.header))
574582
575 # sort Category.name's alphabetically583 # sort Category.name's alphabetically
576 sorted_cats = categories_sorted_by_name(self.categories)584 sorted_cats = categories_sorted_by_name(self.categories)
@@ -580,14 +588,14 @@
580 # add the subcategory if and only if it is non-empty588 # add the subcategory if and only if it is non-empty
581 enquire.set_query(cat.query)589 enquire.set_query(cat.query)
582590
583 if len(enquire.get_mset(0,1)):591 if len(enquire.get_mset(0, 1)):
584 tile = CategoryTile(cat.name, cat.iconname)592 tile = CategoryTile(cat.name, cat.iconname)
585 tile.connect('clicked', self.on_category_clicked, cat)593 tile.connect('clicked', self.on_category_clicked, cat)
586 self.departments.add_child(tile)594 self.departments.add_child(tile)
587595
588 # partialy work around a (quite rare) corner case596 # partialy work around a (quite rare) corner case
589 if num_items == 0:597 if num_items == 0:
590 enquire.set_query(xapian.Query(xapian.Query.OP_AND, 598 enquire.set_query(xapian.Query(xapian.Query.OP_AND,
591 category.query,599 category.query,
592 xapian.Query("ATapplication")))600 xapian.Query("ATapplication")))
593 # assuming that we only want apps is not always correct ^^^601 # assuming that we only want apps is not always correct ^^^
@@ -595,7 +603,8 @@
595 num_items = tmp_matches.get_matches_estimated()603 num_items = tmp_matches.get_matches_estimated()
596604
597 # append an additional button to show all of the items in the category605 # append an additional button to show all of the items in the category
598 all_cat = Category("All", _("All"), "category-show-all", category.query)606 all_cat = Category("All", _("All"), "category-show-all",
607 category.query)
599 name = GObject.markup_escape_text('%s %s' % (_("All"), num_items))608 name = GObject.markup_escape_text('%s %s' % (_("All"), num_items))
600 tile = CategoryTile(name, "category-show-all")609 tile = CategoryTile(name, "category-show-all")
601 tile.connect('clicked', self.on_category_clicked, all_cat)610 tile.connect('clicked', self.on_category_clicked, all_cat)
@@ -622,7 +631,7 @@
622 def _update_appcount(self, appcount):631 def _update_appcount(self, appcount):
623 text = gettext.ngettext("%(amount)s item available",632 text = gettext.ngettext("%(amount)s item available",
624 "%(amount)s items available",633 "%(amount)s items available",
625 appcount) % { 'amount' : appcount, }634 appcount) % {'amount': appcount}
626 self.appcount.set_text(text)635 self.appcount.set_text(text)
627 return636 return
628637
@@ -660,7 +669,8 @@
660 self.header = root_category.name669 self.header = root_category.name
661 self.categories = root_category.subcategories670 self.categories = root_category.subcategories
662671
663 if not self._built: self._build_subcat_view()672 if not self._built:
673 self._build_subcat_view()
664 self._update_subcat_view(root_category, num_items)674 self._update_subcat_view(root_category, num_items)
665675
666 GObject.idle_add(self.queue_draw)676 GObject.idle_add(self.queue_draw)
@@ -673,7 +683,8 @@
673 return683 return
674 self._supported_only = supported_only684 self._supported_only = supported_only
675685
676 if not self._built: self._build_subcat_view()686 if not self._built:
687 self._build_subcat_view()
677 self._update_subcat_view(self.current_category)688 self._update_subcat_view(self.current_category)
678 GObject.idle_add(self.queue_draw)689 GObject.idle_add(self.queue_draw)
679 return690 return
@@ -683,6 +694,7 @@
683 #self.set_subcategory(self.root_category)694 #self.set_subcategory(self.root_category)
684 #return695 #return
685696
697
686def get_test_window_catview():698def get_test_window_catview():
687699
688 def on_category_selected(view, cat):700 def on_category_selected(view, cat):
@@ -740,11 +752,12 @@
740 n.append_page(scroll, Gtk.Label(label="Subcats"))752 n.append_page(scroll, Gtk.Label(label="Subcats"))
741753
742 win.add(n)754 win.add(n)
743 win.set_size_request(800,800)755 win.set_size_request(800, 800)
744 win.show_all()756 win.show_all()
745 win.connect('destroy', Gtk.main_quit)757 win.connect('destroy', Gtk.main_quit)
746 return win758 return win
747 759
760
748def get_test_catview():761def get_test_catview():
749762
750 def on_category_selected(view, cat):763 def on_category_selected(view, cat):
@@ -784,5 +797,3 @@
784797
785 # run it798 # run it
786 Gtk.main()799 Gtk.main()
787
788
789800
=== modified file 'softwarecenter/ui/gtk3/views/pkgnamesview.py'
--- softwarecenter/ui/gtk3/views/pkgnamesview.py 2011-08-08 07:45:20 +0000
+++ softwarecenter/ui/gtk3/views/pkgnamesview.py 2012-03-14 16:41:35 +0000
@@ -27,6 +27,7 @@
2727
28LOG = logging.getLogger(__name__)28LOG = logging.getLogger(__name__)
2929
30
30class PackageNamesView(Gtk.TreeView):31class PackageNamesView(Gtk.TreeView):
31 """ A simple widget that presents a list of packages, with32 """ A simple widget that presents a list of packages, with
32 associated icons, in a treeview. Note the for current33 associated icons, in a treeview. Note the for current
@@ -52,7 +53,7 @@
52 continue53 continue
53 s = "%s \n<small>%s</small>" % (54 s = "%s \n<small>%s</small>" % (
54 cache[pkgname].installed.summary.capitalize(), pkgname)55 cache[pkgname].installed.summary.capitalize(), pkgname)
55 56
56 app_details = Application("", pkgname).get_details(db)57 app_details = Application("", pkgname).get_details(db)
57 proposed_icon = app_details.icon58 proposed_icon = app_details.icon
58 if not proposed_icon or not icons.has_icon(proposed_icon):59 if not proposed_icon or not icons.has_icon(proposed_icon):
@@ -65,11 +66,11 @@
65 LOG.warn("cant set icon for '%s' " % pkgname)66 LOG.warn("cant set icon for '%s' " % pkgname)
66 pb = icons.load_icon(Icons.MISSING_APP,67 pb = icons.load_icon(Icons.MISSING_APP,
67 icon_size,68 icon_size,
68 Gtk.IconLookupFlags.GENERIC_FALLBACK) 69 Gtk.IconLookupFlags.GENERIC_FALLBACK)
69 pb = pb.scale_simple(icon_size, 70 pb = pb.scale_simple(icon_size,
70 icon_size, GdkPixbuf.InterpType.BILINEAR)71 icon_size, GdkPixbuf.InterpType.BILINEAR)
71 model.append([pb, s])72 model.append([pb, s])
72 73
73 # finally, we don't allow selection, it's just a simple display list74 # finally, we don't allow selection, it's just a simple display list
74 tree_selection = self.get_selection()75 tree_selection = self.get_selection()
75 tree_selection.set_mode(Gtk.SelectionMode.NONE)76 tree_selection.set_mode(Gtk.SelectionMode.NONE)
@@ -87,19 +88,19 @@
87 db = StoreDatabase(pathname, cache)88 db = StoreDatabase(pathname, cache)
88 db.open()89 db.open()
8990
90 import softwarecenter.paths 91 import softwarecenter.paths
91 datadir = softwarecenter.paths.datadir92 datadir = softwarecenter.paths.datadir
9293
93 from softwarecenter.ui.gtk3.utils import get_sc_icon_theme94 from softwarecenter.ui.gtk3.utils import get_sc_icon_theme
94 icons = get_sc_icon_theme(datadir)95 icons = get_sc_icon_theme(datadir)
95 96
96 pkgs = ["apt", "software-center"]97 pkgs = ["apt", "software-center"]
97 view = PackageNamesView("header", cache, pkgs, icons, 32, db)98 view = PackageNamesView("header", cache, pkgs, icons, 32, db)
98 view.show()99 view.show()
99100
100 win = Gtk.Window()101 win = Gtk.Window()
101 win.add(view)102 win.add(view)
102 win.set_size_request(600,400)103 win.set_size_request(600, 400)
103 win.show()104 win.show()
104 win.connect('destroy', Gtk.main_quit)105 win.connect('destroy', Gtk.main_quit)
105 return win106 return win
106107
=== modified file 'softwarecenter/ui/gtk3/views/purchaseview.py'
--- softwarecenter/ui/gtk3/views/purchaseview.py 2012-02-09 10:34:40 +0000
+++ softwarecenter/ui/gtk3/views/purchaseview.py 2012-03-14 16:41:35 +0000
@@ -36,12 +36,13 @@
3636
37LOG = logging.getLogger(__name__)37LOG = logging.getLogger(__name__)
3838
39
39class LocaleAwareWebView(webkit.WebView):40class LocaleAwareWebView(webkit.WebView):
40 41
41 def __init__(self):42 def __init__(self):
42 # actual webkit init43 # actual webkit init
43 webkit.WebView.__init__(self)44 webkit.WebView.__init__(self)
44 self.connect("resource-request-starting", 45 self.connect("resource-request-starting",
45 self._on_resource_request_starting)46 self._on_resource_request_starting)
4647
47 def _on_resource_request_starting(self, view, frame, res, req, resp):48 def _on_resource_request_starting(self, view, frame, res, req, resp):
@@ -69,12 +70,13 @@
69 self._add_progress_ui()70 self._add_progress_ui()
70 # create main webkitview71 # create main webkitview
71 self.scroll = Gtk.ScrolledWindow()72 self.scroll = Gtk.ScrolledWindow()
72 self.scroll.set_policy(Gtk.PolicyType.AUTOMATIC, 73 self.scroll.set_policy(Gtk.PolicyType.AUTOMATIC,
73 Gtk.PolicyType.AUTOMATIC)74 Gtk.PolicyType.AUTOMATIC)
74 self.pack_start(self.scroll, True, True, 0)75 self.pack_start(self.scroll, True, True, 0)
75 # embed the webkit view in a scrolled window76 # embed the webkit view in a scrolled window
76 self.scroll.add(self.webkit)77 self.scroll.add(self.webkit)
77 self.show_all()78 self.show_all()
79
78 def _add_progress_ui(self):80 def _add_progress_ui(self):
79 # create toolbar box81 # create toolbar box
80 self.header = Gtk.HBox()82 self.header = Gtk.HBox()
@@ -94,7 +96,9 @@
94 self.pack_start(self.frame, False, False, 6)96 self.pack_start(self.frame, False, False, 6)
95 # connect the webkit stuff97 # connect the webkit stuff
96 self.webkit.connect("notify::uri", self._on_uri_changed)98 self.webkit.connect("notify::uri", self._on_uri_changed)
97 self.webkit.connect("notify::load-status", self._on_load_status_changed)99 self.webkit.connect("notify::load-status",
100 self._on_load_status_changed)
101
98 def _on_uri_changed(self, view, pspec):102 def _on_uri_changed(self, view, pspec):
99 prop = pspec.name103 prop = pspec.name
100 uri = view.get_property(prop)104 uri = view.get_property(prop)
@@ -108,6 +112,7 @@
108 self.url.set_text("%s://%s" % (scheme, netloc))112 self.url.set_text("%s://%s" % (scheme, netloc))
109 # start spinner when the uri changes113 # start spinner when the uri changes
110 #self.spinner.start()114 #self.spinner.start()
115
111 def _on_load_status_changed(self, view, pspec):116 def _on_load_status_changed(self, view, pspec):
112 prop = pspec.name117 prop = pspec.name
113 status = view.get_property(prop)118 status = view.get_property(prop)
@@ -119,14 +124,13 @@
119 status == webkit.LoadStatus.FAILED):124 status == webkit.LoadStatus.FAILED):
120 self.spinner.stop()125 self.spinner.stop()
121 self.spinner.hide()126 self.spinner.hide()
122
123127
124128
125class PurchaseView(Gtk.VBox):129class PurchaseView(Gtk.VBox):
126 """ 130 """
127 View that displays the webkit-based UI for purchasing an item. 131 View that displays the webkit-based UI for purchasing an item.
128 """132 """
129 133
130 LOADING_HTML = """134 LOADING_HTML = """
131<html>135<html>
132<head>136<head>
@@ -151,7 +155,8 @@
151 vertical-align: middle;155 vertical-align: middle;
152}156}
153h1 {157h1 {
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 \
159center no-repeat;
155 padding-top: 48px; /* leaves room for the spinner above */160 padding-top: 48px; /* leaves room for the spinner above */
156 font-size: 100%%;161 font-size: 100%%;
157 font-weight: normal;162 font-weight: normal;
@@ -164,19 +169,19 @@
164""" % _("Connecting to payment service...")169""" % _("Connecting to payment service...")
165170
166 __gsignals__ = {171 __gsignals__ = {
167 'purchase-succeeded' : (GObject.SignalFlags.RUN_LAST,172 'purchase-succeeded': (GObject.SignalFlags.RUN_LAST,
168 None,173 None,
169 ()),174 ()),
170 'purchase-failed' : (GObject.SignalFlags.RUN_LAST,175 'purchase-failed': (GObject.SignalFlags.RUN_LAST,
171 None,176 None,
172 ()),177 ()),
173 'purchase-cancelled-by-user' : (GObject.SignalFlags.RUN_LAST,178 'purchase-cancelled-by-user': (GObject.SignalFlags.RUN_LAST,
174 None,179 None,
175 ()),180 ()),
176 'purchase-needs-spinner' : (GObject.SignalFlags.RUN_LAST,181 'purchase-needs-spinner': (GObject.SignalFlags.RUN_LAST,
177 None,182 None,
178 (bool, )),183 (bool, )),
179 184
180 }185 }
181186
182 def __init__(self):187 def __init__(self):
@@ -188,7 +193,8 @@
188 def init_view(self):193 def init_view(self):
189 if self.wk is None:194 if self.wk is None:
190 self.wk = ScrolledWebkitWindow()195 self.wk = ScrolledWebkitWindow()
191 #self.wk.webkit.connect("new-window-policy-decision-requested", self._on_new_window)196 #self.wk.webkit.connect("new-window-policy-decision-requested",
197 # self._on_new_window)
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)
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)
194 self.wk.webkit.connect("console-message", self._on_console_message)200 self.wk.webkit.connect("console-message", self._on_console_message)
@@ -196,15 +202,17 @@
196 # a possible way to do IPC (script or title change)202 # a possible way to do IPC (script or title change)
197 self.wk.webkit.connect("script-alert", self._on_script_alert)203 self.wk.webkit.connect("script-alert", self._on_script_alert)
198 self.wk.webkit.connect("title-changed", self._on_title_changed)204 self.wk.webkit.connect("title-changed", self._on_title_changed)
199 self.wk.webkit.connect("notify::load-status", self._on_load_status_changed)205 self.wk.webkit.connect("notify::load-status",
200 # unblock signal handlers if needed when showing the purchase webkit view in206 self._on_load_status_changed)
201 # case they were blocked after a previous purchase was completed or canceled207 # unblock signal handlers if needed when showing the purchase webkit
208 # view in case they were blocked after a previous purchase was
209 # completed or canceled
202 self._unblock_wk_handlers()210 self._unblock_wk_handlers()
203211
204 def initiate_purchase(self, app, iconname, url=None, html=None):212 def initiate_purchase(self, app, iconname, url=None, html=None):
205 """213 """
206 initiates the purchase workflow inside the embedded webkit window214 initiates the purchase workflow inside the embedded webkit window
207 for the item specified 215 for the item specified
208 """216 """
209 self.init_view()217 self.init_view()
210 self.app = app218 self.app = app
@@ -223,7 +231,7 @@
223 # only for debugging231 # only for debugging
224 if os.environ.get("SOFTWARE_CENTER_DEBUG_BUY"):232 if os.environ.get("SOFTWARE_CENTER_DEBUG_BUY"):
225 GObject.timeout_add_seconds(1, _generate_events, self)233 GObject.timeout_add_seconds(1, _generate_events, self)
226 234
227 def _on_new_window(self, view, frame, request, action, policy):235 def _on_new_window(self, view, frame, request, action, policy):
228 LOG.debug("_on_new_window")236 LOG.debug("_on_new_window")
229 import subprocess237 import subprocess
@@ -234,7 +242,7 @@
234 win = view.get_data("win")242 win = view.get_data("win")
235 win.destroy()243 win.destroy()
236 return True244 return True
237 245
238 def _on_create_web_view(self, view, frame):246 def _on_create_web_view(self, view, frame):
239 win = Gtk.Window()247 win = Gtk.Window()
240 win.set_size_request(400, 400)248 win.set_size_request(400, 400)
@@ -261,7 +269,8 @@
261 pass269 pass
262 for k in ["token_key", "token_secret", "consumer_secret"]:270 for k in ["token_key", "token_secret", "consumer_secret"]:
263 if k in message:271 if k in message:
264 LOG.debug("skipping console message that contains sensitive data")272 LOG.debug(
273 "skipping console message that contains sensitive data")
265 return True274 return True
266 LOG.debug("_on_console_message '%s'" % message)275 LOG.debug("_on_console_message '%s'" % message)
267 return False276 return False
@@ -312,7 +321,8 @@
312 return321 return
313 # this is what the agent implements322 # this is what the agent implements
314 elif "failures" in res:323 elif "failures" in res:
315 LOG.error("the server returned a error: '%s'" % res["failures"])324 LOG.error("the server returned a error: '%s'" %
325 res["failures"])
316 # show a generic error, the "failures" string we get from the326 # show a generic error, the "failures" string we get from the
317 # server is way too technical to show, but we do log it327 # server is way too technical to show, but we do log it
318 self.emit("purchase-failed")328 self.emit("purchase-failed")
@@ -329,9 +339,9 @@
329 # add repo and key339 # add repo and key
330 backend = get_install_backend()340 backend = get_install_backend()
331 backend.add_repo_add_key_and_install_app(341 backend.add_repo_add_key_and_install_app(
332 deb_line, signing_key_id, self.app, self.iconname, 342 deb_line, signing_key_id, self.app, self.iconname,
333 license_key, license_key_path, json.dumps(self._oauth_token))343 license_key, license_key_path, json.dumps(self._oauth_token))
334 344
335 def _block_wk_handlers(self):345 def _block_wk_handlers(self):
336 # we need to block webkit signal handlers when we hide the346 # we need to block webkit signal handlers when we hide the
337 # purchase webkit view, this prevents e.g. handling of signals on347 # purchase webkit view, this prevents e.g. handling of signals on
@@ -341,14 +351,15 @@
341 self.wk.webkit.handler_block_by_func(self._on_title_changed)351 self.wk.webkit.handler_block_by_func(self._on_title_changed)
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)
343 self._wk_handlers_blocked = True353 self._wk_handlers_blocked = True
344 354
345 def _unblock_wk_handlers(self):355 def _unblock_wk_handlers(self):
346 if self._wk_handlers_blocked:356 if self._wk_handlers_blocked:
347 self.wk.webkit.handler_unblock_by_func(self._on_script_alert)357 self.wk.webkit.handler_unblock_by_func(self._on_script_alert)
348 self.wk.webkit.handler_unblock_by_func(self._on_title_changed)358 self.wk.webkit.handler_unblock_by_func(self._on_title_changed)
349 self.wk.webkit.handler_unblock_by_func(self._on_load_status_changed)359 self.wk.webkit.handler_unblock_by_func(
360 self._on_load_status_changed)
350 self._wk_handlers_blocked = False361 self._wk_handlers_blocked = False
351 362
352363
353# just used for testing --------------------------------------------364# just used for testing --------------------------------------------
354DUMMY_HTML = """365DUMMY_HTML = """
@@ -361,11 +372,11 @@
361<body>372<body>
362 <script type="text/javascript">373 <script type="text/javascript">
363 function changeTitle(title) { document.title = title; }374 function changeTitle(title) { document.title = title; }
364 function success() { changeTitle('{ "successful" : true, \375 function success() { changeTitle('{"successful": true, "deb_line": \
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", \
366 "package_name" : "2vcard", \377 "package_name": "2vcard", \
367 "application_name" : "The 2vcard app", \378 "application_name": "The 2vcard app", \
368 "signing_key_id" : "1024R/0EB12F05"\379 "signing_key_id": "1024R/0EB12F05"\
369 }') }380 }') }
370 function cancel() { changeTitle('{ "successful" : false }') }381 function cancel() { changeTitle('{ "successful" : false }') }
371 </script>382 </script>
@@ -375,11 +386,11 @@
375 <p>386 <p>
376 <input type="entry">387 <input type="entry">
377 </p>388 </p>
378 <input type="button" name="test_button2" 389 <input type="button" name="test_button2"
379 value="Cancel"390 value="Cancel"
380 onclick='cancel()'391 onclick='cancel()'
381 />392 />
382 <input type="button" name="test_button" 393 <input type="button" name="test_button"
383 value="Buy now"394 value="Buy now"
384 onclick='success()'395 onclick='success()'
385 />396 />
@@ -387,30 +398,31 @@
387</html>398</html>
388 """399 """
389400
401
390# synthetic key event generation402# synthetic key event generation
391def _send_keys(view, s):403def _send_keys(view, s):
392 print("_send_keys %s" % s)404 print("_send_keys %s" % s)
393 MAPPING = { '@' : 'at',405 MAPPING = {'@': 'at',
394 '.' : 'period',406 '.': 'period',
395 '\t' : 'Tab',407 '\t': 'Tab',
396 '\n' : 'Return',408 '\n': 'Return',
397 '?' : 'question',409 '?': 'question',
398 '\a' : 'Down', # fake 410 '\a': 'Down', # fake
399 ' ' : 'space',411 ' ': 'space',
400 '\v' : 'Page_Down', # fake412 '\v': 'Page_Down', # fake
401 }413 }
402 414
403 for key in s:415 for key in s:
404 event = Gdk.Event(Gdk.KEY_PRESS)416 event = Gdk.Event(Gdk.KEY_PRESS)
405 event.window = view.window417 event.window = view.window
406 if key.isdigit():418 if key.isdigit():
407 key = "_"+key419 key = "_" + key
408 if hasattr(Gdk, key):420 if hasattr(Gdk, key):
409 event.keyval = getattr(Gdk, key)421 event.keyval = getattr(Gdk, key)
410 else:422 else:
411 event.keyval = getattr(Gdk, MAPPING[key])423 event.keyval = getattr(Gdk, MAPPING[key])
412 Gtk.main_do_event(event)424 Gtk.main_do_event(event)
413 425
414426
415# \a means down key - its a just a fake to get it working427# \a means down key - its a just a fake to get it working
416LOGIN = os.environ.get("SOFTWARE_CENTER_LOGIN") or "michael.vogt@ubuntu.com"428LOGIN = os.environ.get("SOFTWARE_CENTER_LOGIN") or "michael.vogt@ubuntu.com"
@@ -419,12 +431,14 @@
419PAYMENT_DETAILS = "\tstreet1\tstreet2\tcity\tstate\t1234\t\a\t\a\a\t"\431PAYMENT_DETAILS = "\tstreet1\tstreet2\tcity\tstate\t1234\t\a\t\a\a\t"\
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"
421# state-name, window title, keys433# state-name, window title, keys
422STATES = [ ('login', 'Log in', LOGIN+"\t"),434STATES = [('login', 'Log in', LOGIN + "\t"),
423 ('confirm-sso', 'Authenticate to', '\n'),435 ('confirm-sso', 'Authenticate to', '\n'),
424 ('enter-payment', 'Confirm Payment Details', PAYMENT_DETAILS),436 ('enter-payment', 'Confirm Payment Details', PAYMENT_DETAILS),
425 ('confirm-payment', 'title-the-same-as-before', '\t\n'),437 ('confirm-payment', 'title-the-same-as-before', '\t\n'),
426 ('end-state', 'no-title', ''),438 ('end-state', 'no-title', ''),
427 ]439 ]
440
441
428def _generate_events(view):442def _generate_events(view):
429 global STATES443 global STATES
430444
@@ -440,19 +454,20 @@
440454
441 return True455 return True
442456
443# # for debugging only 457# # for debugging only
444# def _on_key_press(dialog, event):458# def _on_key_press(dialog, event):
445# print event, event.keyval459# print event, event.keyval
446460
461
447def get_test_window_purchaseview():462def get_test_window_purchaseview():
448 #url = "http://www.animiertegifs.de/java-scripts/alertbox.php"463 #url = "http://www.animiertegifs.de/java-scripts/alertbox.php"
449 url = "http://www.ubuntu.cohtml=DUMMY_m"464 url = "http://www.ubuntu.cohtml=DUMMY_m"
450 #d = PurchaseDialog(app=None, url="http://spiegel.de")465 #d = PurchaseDialog(app=None, url="http://spiegel.de")
451 from softwarecenter.enums import BUY_SOMETHING_HOST466 from softwarecenter.enums import BUY_SOMETHING_HOST
452 url = BUY_SOMETHING_HOST+"/subscriptions/en/ubuntu/maverick/+new/?%s" % ( 467 url = BUY_SOMETHING_HOST + "/subscriptions/en/ubuntu/maverick/+new/?%s" % (
453 urllib.urlencode({468 urllib.urlencode({
454 'archive_id' : "mvo/private-test", 469 'archive_id': "mvo/private-test",
455 'arch' : "i386",470 'arch': "i386",
456 }))471 }))
457 # use cmdline if available472 # use cmdline if available
458 if len(sys.argv) > 1:473 if len(sys.argv) > 1:
@@ -460,7 +475,7 @@
460 # useful for debugging475 # useful for debugging
461 #d.connect("key-press-event", _on_key_press)476 #d.connect("key-press-event", _on_key_press)
462 #GObject.timeout_add_seconds(1, _generate_events, d)477 #GObject.timeout_add_seconds(1, _generate_events, d)
463 478
464 widget = PurchaseView()479 widget = PurchaseView()
465 widget.initiate_purchase(app=None, iconname=None, url=url)480 widget.initiate_purchase(app=None, iconname=None, url=url)
466 #widget.initiate_purchase(app=None, iconname=None, html=DUMMY_HTML)481 #widget.initiate_purchase(app=None, iconname=None, html=DUMMY_HTML)
@@ -477,4 +492,3 @@
477if __name__ == "__main__":492if __name__ == "__main__":
478 win = get_test_window_purchaseview()493 win = get_test_window_purchaseview()
479 Gtk.main()494 Gtk.main()
480
481495
=== modified file 'test/test_pep8.py'
--- test/test_pep8.py 2012-03-13 17:13:27 +0000
+++ test/test_pep8.py 2012-03-14 16:41:35 +0000
@@ -8,15 +8,17 @@
88
9# Only test these two packages for now:9# Only test these two packages for now:
10import softwarecenter.db.pkginfo_impl10import softwarecenter.db.pkginfo_impl
11import softwarecenter.ui.gtk3.views
11import softwarecenter.ui.gtk3.widgets12import softwarecenter.ui.gtk3.widgets
12import softwarecenter.ui.qml13import softwarecenter.ui.qml
1314
14class PackagePep8TestCase(unittest.TestCase):15class PackagePep8TestCase(unittest.TestCase):
15 maxDiff = None16 maxDiff = None
16 packages = [softwarecenter.ui.qml,17 packages = [softwarecenter.ui.qml,
18 softwarecenter.ui.gtk3.views,
17 softwarecenter.ui.gtk3.widgets,19 softwarecenter.ui.gtk3.widgets,
18 softwarecenter.db.pkginfo_impl]20 softwarecenter.db.pkginfo_impl]
19 exclude = []21 exclude = ['appdetailsview.py']
2022
21 def message(self, text):23 def message(self, text):
22 self.errors.append(text)24 self.errors.append(text)