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

Proposed by Anthony Lenton
Status: Merged
Merged at revision: 2854
Proposed branch: lp:~elachuni/software-center/pep8-test-part11
Merge into: lp:software-center
Prerequisite: lp:~elachuni/software-center/pep8-test-part10
Diff against target: 1071 lines (+162/-148)
8 files modified
softwarecenter/ui/gtk3/panes/pendingpane.py (+7/-6)
softwarecenter/ui/gtk3/panes/softwarepane.py (+37/-41)
softwarecenter/ui/gtk3/panes/unused__channelpane.py (+33/-30)
softwarecenter/ui/gtk3/panes/viewswitcher.py (+17/-17)
softwarecenter/ui/gtk3/session/appmanager.py (+25/-18)
softwarecenter/ui/gtk3/session/navhistory.py (+17/-16)
softwarecenter/ui/gtk3/session/viewmanager.py (+20/-19)
test/test_pep8.py (+6/-1)
To merge this branch: bzr merge lp:~elachuni/software-center/pep8-test-part11
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+97547@code.launchpad.net

Description of the change

Made all files from softwarecenter.ui.gtk3.session and a few from softwarecenter.ui.gtk3.panes pass the pep8 test.

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

Thanks, 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/panes/pendingpane.py'
--- softwarecenter/ui/gtk3/panes/pendingpane.py 2011-10-06 02:53:27 +0000
+++ softwarecenter/ui/gtk3/panes/pendingpane.py 2012-03-15 00:20:29 +0000
@@ -30,7 +30,7 @@
3030
3131
32class PendingPane(Gtk.ScrolledWindow, BasePane):32class PendingPane(Gtk.ScrolledWindow, BasePane):
33 33
34 CANCEL_XPAD = StockEms.MEDIUM34 CANCEL_XPAD = StockEms.MEDIUM
35 CANCEL_YPAD = StockEms.MEDIUM35 CANCEL_YPAD = StockEms.MEDIUM
3636
@@ -64,14 +64,14 @@
64 tp.set_property("xpad", self.CANCEL_XPAD)64 tp.set_property("xpad", self.CANCEL_XPAD)
65 tp.set_property("ypad", self.CANCEL_YPAD)65 tp.set_property("ypad", self.CANCEL_YPAD)
66 tp.set_property("text", "")66 tp.set_property("text", "")
67 column = Gtk.TreeViewColumn("Progress", tp, 67 column = Gtk.TreeViewColumn("Progress", tp,
68 value=PendingStore.COL_PROGRESS,68 value=PendingStore.COL_PROGRESS,
69 pulse=PendingStore.COL_PULSE)69 pulse=PendingStore.COL_PULSE)
70 column.set_min_width(200)70 column.set_min_width(200)
71 self.tv.append_column(column)71 self.tv.append_column(column)
72 # cancel icon72 # cancel icon
73 tpix = Gtk.CellRendererPixbuf()73 tpix = Gtk.CellRendererPixbuf()
74 column = Gtk.TreeViewColumn("Cancel", tpix, 74 column = Gtk.TreeViewColumn("Cancel", tpix,
75 stock_id=PendingStore.COL_CANCEL)75 stock_id=PendingStore.COL_CANCEL)
76 self.tv.append_column(column)76 self.tv.append_column(column)
77 # fake columns that eats the extra space at the end77 # fake columns that eats the extra space at the end
@@ -81,7 +81,7 @@
81 # add it81 # add it
82 store = PendingStore(icons)82 store = PendingStore(icons)
83 self.tv.set_model(store)83 self.tv.set_model(store)
84 84
85 def _on_button_pressed(self, widget, event):85 def _on_button_pressed(self, widget, event):
86 """button press handler to capture clicks on the cancel button"""86 """button press handler to capture clicks on the cancel button"""
87 #print "_on_clicked: ", event87 #print "_on_clicked: ", event
@@ -100,7 +100,7 @@
100 # not cancelable (no icon)100 # not cancelable (no icon)
101 model = self.tv.get_model()101 model = self.tv.get_model()
102 if model[path][PendingStore.COL_CANCEL] == "":102 if model[path][PendingStore.COL_CANCEL] == "":
103 return 103 return
104 # get tid104 # get tid
105 tid = model[path][PendingStore.COL_TID]105 tid = model[path][PendingStore.COL_TID]
106 trans = model._transactions_watcher.get_transaction(tid)106 trans = model._transactions_watcher.get_transaction(tid)
@@ -125,6 +125,7 @@
125 def get_callback_for_page(self, page_id, view_state):125 def get_callback_for_page(self, page_id, view_state):
126 return None126 return None
127127
128
128def get_test_window():129def get_test_window():
129130
130 from softwarecenter.testutils import get_test_gtk3_icon_cache131 from softwarecenter.testutils import get_test_gtk3_icon_cache
@@ -139,7 +140,7 @@
139 win = Gtk.Window()140 win = Gtk.Window()
140 win.add(scroll)141 win.add(scroll)
141 view.grab_focus()142 view.grab_focus()
142 win.set_size_request(500,200)143 win.set_size_request(500, 200)
143 win.show_all()144 win.show_all()
144 win.connect("destroy", Gtk.main_quit)145 win.connect("destroy", Gtk.main_quit)
145146
146147
=== modified file 'softwarecenter/ui/gtk3/panes/softwarepane.py'
--- softwarecenter/ui/gtk3/panes/softwarepane.py 2012-02-28 13:51:20 +0000
+++ softwarecenter/ui/gtk3/panes/softwarepane.py 2012-03-15 00:20:29 +0000
@@ -78,15 +78,16 @@
78 self.filter = None78 self.filter = None
79 self.previous_purchases_query = None79 self.previous_purchases_query = None
80 self.vadjustment = 0.080 self.vadjustment = 0.0
81 return
8281
83 def __setattr__(self, name, val):82 def __setattr__(self, name, val):
84 attrs = self._attrs83 attrs = self._attrs
85 if name not in attrs:84 if name not in attrs:
86 raise AttributeError("The attr name \"%s\" is not permitted" % name)85 raise AttributeError("The attr name \"%s\" is not permitted" %
86 name)
87 Gtk.main_quit()87 Gtk.main_quit()
88 if not isinstance(val, attrs[name]):88 if not isinstance(val, attrs[name]):
89 msg = "Attribute %s expects %s, got %s" % (name, attrs[name], type(val))89 msg = "Attribute %s expects %s, got %s" % (name, attrs[name],
90 type(val))
90 raise TypeError(msg)91 raise TypeError(msg)
91 Gtk.main_quit()92 Gtk.main_quit()
92 return object.__setattr__(self, name, val)93 return object.__setattr__(self, name, val)
@@ -124,7 +125,7 @@
124 self.limit = 0125 self.limit = 0
125 #~ self.filter = None126 #~ self.filter = None
126 self.vadjustment = 0.0127 self.vadjustment = 0.0
127 return128
128129
129class SoftwarePane(Gtk.VBox, BasePane):130class SoftwarePane(Gtk.VBox, BasePane):
130 """ Common base class for AvailablePane and InstalledPane"""131 """ Common base class for AvailablePane and InstalledPane"""
@@ -136,10 +137,10 @@
136 SPINNER = 2137 SPINNER = 2
137138
138 __gsignals__ = {139 __gsignals__ = {
139 "app-list-changed" : (GObject.SignalFlags.RUN_LAST,140 "app-list-changed": (GObject.SignalFlags.RUN_LAST,
140 None, 141 None,
141 (int,),142 (int,),
142 ),143 ),
143 }144 }
144 PADDING = 6145 PADDING = 6
145146
@@ -148,7 +149,7 @@
148 Gtk.VBox.__init__(self)149 Gtk.VBox.__init__(self)
149 BasePane.__init__(self)150 BasePane.__init__(self)
150151
151 # other classes we need 152 # other classes we need
152 self.enquirer = AppEnquire(cache, db)153 self.enquirer = AppEnquire(cache, db)
153 self._query_complete_handler = self.enquirer.connect(154 self._query_complete_handler = self.enquirer.connect(
154 "query-complete", self.on_query_complete)155 "query-complete", self.on_query_complete)
@@ -189,7 +190,7 @@
189190
190 # cursor191 # cursor
191 self.busy_cursor = Gdk.Cursor.new(Gdk.CursorType.WATCH)192 self.busy_cursor = Gdk.Cursor.new(Gdk.CursorType.WATCH)
192 193
193 # views to be created in init_view194 # views to be created in init_view
194 self.app_view = None195 self.app_view = None
195 self.app_details_view = None196 self.app_details_view = None
@@ -200,7 +201,7 @@
200 SoftwarePane. Note that this method is intended to be called by201 SoftwarePane. Note that this method is intended to be called by
201 the subclass itself at the start of its own init_view() implementation.202 the subclass itself at the start of its own init_view() implementation.
202 """203 """
203 # common UI elements (applist and appdetails) 204 # common UI elements (applist and appdetails)
204 # its the job of the Child class to put it into a good location205 # its the job of the Child class to put it into a good location
205 # list206 # list
206 self.box_app_list = Gtk.VBox()207 self.box_app_list = Gtk.VBox()
@@ -211,23 +212,24 @@
211212
212 self.app_view = AppView(self.db, self.cache,213 self.app_view = AppView(self.db, self.cache,
213 self.icons, self.show_ratings)214 self.icons, self.show_ratings)
214 self.app_view.connect("sort-method-changed", self.on_app_view_sort_method_changed)215 self.app_view.connect("sort-method-changed",
216 self.on_app_view_sort_method_changed)
215217
216 self.init_atk_name(self.app_view, "app_view")218 self.init_atk_name(self.app_view, "app_view")
217 self.box_app_list.pack_start(self.app_view, True, True, 0)219 self.box_app_list.pack_start(self.app_view, True, True, 0)
218 self.app_view.connect("application-selected", 220 self.app_view.connect("application-selected",
219 self.on_application_selected)221 self.on_application_selected)
220 self.app_view.connect("application-activated", 222 self.app_view.connect("application-activated",
221 self.on_application_activated)223 self.on_application_activated)
222 224
223 # details225 # details
224 self.scroll_details = Gtk.ScrolledWindow()226 self.scroll_details = Gtk.ScrolledWindow()
225 self.scroll_details.set_policy(Gtk.PolicyType.AUTOMATIC, 227 self.scroll_details.set_policy(Gtk.PolicyType.AUTOMATIC,
226 Gtk.PolicyType.AUTOMATIC)228 Gtk.PolicyType.AUTOMATIC)
227 self.app_details_view = AppDetailsView(self.db, 229 self.app_details_view = AppDetailsView(self.db,
228 self.distro,230 self.distro,
229 self.icons, 231 self.icons,
230 self.cache, 232 self.cache,
231 self.datadir)233 self.datadir)
232 self.app_details_view.connect(234 self.app_details_view.connect(
233 "different-application-selected", self.on_application_activated)235 "different-application-selected", self.on_application_activated)
@@ -246,7 +248,7 @@
246 """ init the atk name for a given gtk widget based on parent-pane248 """ init the atk name for a given gtk widget based on parent-pane
247 and variable name (used for the mago tests)249 and variable name (used for the mago tests)
248 """250 """
249 name = self.__class__.__name__ + "." + name251 name = self.__class__.__name__ + "." + name
250 Atk.Object.set_name(widget.get_accessible(), name)252 Atk.Object.set_name(widget.get_accessible(), name)
251253
252 def on_cache_ready(self, cache):254 def on_cache_ready(self, cache):
@@ -254,7 +256,7 @@
254 LOG.debug("on_cache_ready")256 LOG.debug("on_cache_ready")
255 # it only makes sense to refresh if there is something to257 # it only makes sense to refresh if there is something to
256 # refresh, otherwise we create a bunch of (not yet needed)258 # refresh, otherwise we create a bunch of (not yet needed)
257 # AppStore objects on startup when the cache sends its 259 # AppStore objects on startup when the cache sends its
258 # initial "cache-ready" signal260 # initial "cache-ready" signal
259 model = self.app_view.tree_view.get_model()261 model = self.app_view.tree_view.get_model()
260 if model is None:262 if model is None:
@@ -270,7 +272,8 @@
270 self.state.application = app272 self.state.application = app
271273
272 vm = get_viewmanager()274 vm = get_viewmanager()
273 vm.display_page(self, SoftwarePane.Pages.DETAILS, self.state, self.display_details_page)275 vm.display_page(self, SoftwarePane.Pages.DETAILS, self.state,
276 self.display_details_page)
274277
275 def show_app(self, app):278 def show_app(self, app):
276 self.on_application_activated(None, app)279 self.on_application_activated(None, app)
@@ -288,7 +291,6 @@
288 self.app_view.display_matches(enquirer.matches,291 self.app_view.display_matches(enquirer.matches,
289 self._is_in_search_mode())292 self._is_in_search_mode())
290 self.hide_appview_spinner()293 self.hide_appview_spinner()
291 return
292294
293 def on_app_view_sort_method_changed(self, app_view, combo):295 def on_app_view_sort_method_changed(self, app_view, combo):
294 if app_view.get_sort_mode() == self.enquirer.sortmode:296 if app_view.get_sort_mode() == self.enquirer.sortmode:
@@ -298,7 +300,6 @@
298 app_view.clear_model()300 app_view.clear_model()
299 query = self.get_query()301 query = self.get_query()
300 self._refresh_apps_with_apt_cache(query)302 self._refresh_apps_with_apt_cache(query)
301 return
302303
303 def _is_in_search_mode(self):304 def _is_in_search_mode(self):
304 return (self.state.search_term and305 return (self.state.search_term and
@@ -311,7 +312,7 @@
311 if not self.state.search_term:312 if not self.state.search_term:
312 self.action_bar.clear()313 self.action_bar.clear()
313 self.spinner_notebook.show_spinner()314 self.spinner_notebook.show_spinner()
314 315
315 def hide_appview_spinner(self):316 def hide_appview_spinner(self):
316 """ hide the spinner and display the appview in the panel """317 """ hide the spinner and display the appview in the panel """
317 LOG.debug("hide_appview_spinner")318 LOG.debug("hide_appview_spinner")
@@ -320,11 +321,9 @@
320 def set_section(self, section):321 def set_section(self, section):
321 self.section = section322 self.section = section
322 self.app_details_view.set_section(section)323 self.app_details_view.set_section(section)
323 return
324324
325 def section_sync(self):325 def section_sync(self):
326 self.app_details_view.set_section(self.section)326 self.app_details_view.set_section(self.section)
327 return
328327
329 def on_app_list_changed(self, pane, length):328 def on_app_list_changed(self, pane, length):
330 """internal helper that keeps the the action bar up-to-date by329 """internal helper that keeps the the action bar up-to-date by
@@ -333,12 +332,10 @@
333332
334 self.show_nonapps_if_required(len(self.enquirer.matches))333 self.show_nonapps_if_required(len(self.enquirer.matches))
335 self.search_aid.update_search_help(self.state)334 self.search_aid.update_search_help(self.state)
336 return
337335
338 def hide_nonapps(self):336 def hide_nonapps(self):
339 """ hide non-applications control in the action bar """337 """ hide non-applications control in the action bar """
340 self.action_bar.unset_label()338 self.action_bar.unset_label()
341 return
342339
343 def show_nonapps_if_required(self, length):340 def show_nonapps_if_required(self, length):
344 """341 """
@@ -360,7 +357,7 @@
360 return357 return
361358
362 LOG.debug("nonapps_visible value=%s (always visible: %s)" % (359 LOG.debug("nonapps_visible value=%s (always visible: %s)" % (
363 self.nonapps_visible, 360 self.nonapps_visible,
364 self.nonapps_visible == NonAppVisibility.ALWAYS_VISIBLE))361 self.nonapps_visible == NonAppVisibility.ALWAYS_VISIBLE))
365362
366 self.action_bar.unset_label()363 self.action_bar.unset_label()
@@ -370,13 +367,13 @@
370 # In most/all languages you will want the whole string as a link367 # In most/all languages you will want the whole string as a link
371 label = gettext.ngettext("_Hide %(amount)i technical item_",368 label = gettext.ngettext("_Hide %(amount)i technical item_",
372 "_Hide %(amount)i technical items_",369 "_Hide %(amount)i technical items_",
373 n_pkgs) % { 'amount': n_pkgs, }370 n_pkgs) % {'amount': n_pkgs}
374 self.action_bar.set_label(371 self.action_bar.set_label(
375 label, link_result=self._hide_nonapp_pkgs) 372 label, link_result=self._hide_nonapp_pkgs)
376 else:373 else:
377 label = gettext.ngettext("_Show %(amount)i technical item_",374 label = gettext.ngettext("_Show %(amount)i technical item_",
378 "_Show %(amount)i technical items_",375 "_Show %(amount)i technical items_",
379 n_pkgs) % { 'amount': n_pkgs, }376 n_pkgs) % {'amount': n_pkgs}
380 self.action_bar.set_label(377 self.action_bar.set_label(
381 label, link_result=self._show_nonapp_pkgs)378 label, link_result=self._show_nonapp_pkgs)
382379
@@ -388,7 +385,7 @@
388 self.unset_current_category()385 self.unset_current_category()
389 self.refresh_apps()386 self.refresh_apps()
390 elif uri.startswith("search-parent:"):387 elif uri.startswith("search-parent:"):
391 self.apps_subcategory = None;388 self.apps_subcategory = None
392 self.refresh_apps()389 self.refresh_apps()
393 elif uri.startswith("search-unsupported:"):390 elif uri.startswith("search-unsupported:"):
394 self.apps_filter.set_supported_only(False)391 self.apps_filter.set_supported_only(False)
@@ -424,7 +421,7 @@
424 return channel_query421 return channel_query
425 # ... otherwise show all422 # ... otherwise show all
426 return xapian.Query("")423 return xapian.Query("")
427 424
428 def refresh_apps(self, query=None):425 def refresh_apps(self, query=None):
429 """refresh the applist and update the navigation bar """426 """refresh the applist and update the navigation bar """
430 LOG.debug("refresh_apps")427 LOG.debug("refresh_apps")
@@ -461,7 +458,6 @@
461 exact=self.is_custom_list(),458 exact=self.is_custom_list(),
462 nonapps_visible=self.nonapps_visible,459 nonapps_visible=self.nonapps_visible,
463 filter=self.state.filter)460 filter=self.state.filter)
464 return
465461
466 def display_details_page(self, page, view_state):462 def display_details_page(self, page, view_state):
467 self.app_details_view.show_app(view_state.application)463 self.app_details_view.show_app(view_state.application)
@@ -486,11 +482,11 @@
486 def get_sort_mode(self):482 def get_sort_mode(self):
487 # if the category sets a custom sort order, that wins, this483 # if the category sets a custom sort order, that wins, this
488 # is required for top-rated and whats-new484 # is required for top-rated and whats-new
489 if (self.state.category and 485 if (self.state.category and
490 self.state.category.sortmode != SortMethods.BY_ALPHABET):486 self.state.category.sortmode != SortMethods.BY_ALPHABET):
491 return self.state.category.sortmode487 return self.state.category.sortmode
492 # searches are always by ranking unless the user decided differently488 # searches are always by ranking unless the user decided differently
493 if (self._is_in_search_mode() and 489 if (self._is_in_search_mode() and
494 not self.app_view.user_defined_sort_method):490 not self.app_view.user_defined_sort_method):
495 return SortMethods.BY_SEARCH_RANKING491 return SortMethods.BY_SEARCH_RANKING
496 # use the appview combo492 # use the appview combo
@@ -520,15 +516,15 @@
520 def is_category_view_showing(self):516 def is_category_view_showing(self):
521 " stub implementation "517 " stub implementation "
522 pass518 pass
523 519
524 def is_applist_view_showing(self):520 def is_applist_view_showing(self):
525 " stub implementation "521 " stub implementation "
526 pass522 pass
527 523
528 def is_app_details_view_showing(self):524 def is_app_details_view_showing(self):
529 " stub implementation "525 " stub implementation "
530 pass526 pass
531 527
532 def get_current_app(self):528 def get_current_app(self):
533 " stub implementation "529 " stub implementation "
534 pass530 pass
535531
=== modified file 'softwarecenter/ui/gtk3/panes/unused__channelpane.py'
--- softwarecenter/ui/gtk3/panes/unused__channelpane.py 2011-08-10 07:35:53 +0000
+++ softwarecenter/ui/gtk3/panes/unused__channelpane.py 2012-03-15 00:20:29 +0000
@@ -37,6 +37,7 @@
3737
38LOG = logging.getLogger(__name__)38LOG = logging.getLogger(__name__)
3939
40
40class ChannelPane(SoftwarePane):41class ChannelPane(SoftwarePane):
41 """Widget that represents the channel pane for display of42 """Widget that represents the channel pane for display of
42 individual channels (PPAs, partner repositories, etc.)43 individual channels (PPAs, partner repositories, etc.)
@@ -47,10 +48,10 @@
47 (PAGE_APPLIST,48 (PAGE_APPLIST,
48 PAGE_APP_DETAILS,49 PAGE_APP_DETAILS,
49 PAGE_APP_PURCHASE) = range(3)50 PAGE_APP_PURCHASE) = range(3)
50 51
51 __gsignals__ = {'channel-pane-created':(GObject.SignalFlags.RUN_FIRST,52 __gsignals__ = {'channel-pane-created': (GObject.SignalFlags.RUN_FIRST,
52 None,53 None,
53 ())}54 ())}
5455
55 def __init__(self, cache, db, distro, icons, datadir):56 def __init__(self, cache, db, distro, icons, datadir):
56 # parent57 # parent
@@ -66,11 +67,14 @@
66 def init_view(self):67 def init_view(self):
67 if not self.view_initialized:68 if not self.view_initialized:
68 SoftwarePane.init_view(self)69 SoftwarePane.init_view(self)
69 self.notebook.append_page(self.box_app_list, Gtk.Label(label="channel"))70 self.notebook.append_page(self.box_app_list,
71 Gtk.Label(label="channel"))
70 # details72 # details
71 self.notebook.append_page(self.scroll_details, Gtk.Label(label="details"))73 self.notebook.append_page(self.scroll_details,
74 Gtk.Label(label="details"))
72 # purchase view75 # purchase view
73 self.notebook.append_page(self.purchase_view, Gtk.Label(label="purchase"))76 self.notebook.append_page(self.purchase_view,
77 Gtk.Label(label="purchase"))
74 # now we are initialized78 # now we are initialized
75 self.emit("channel-pane-created")79 self.emit("channel-pane-created")
76 self.show_all()80 self.show_all()
@@ -82,7 +86,7 @@
82 self.navigation_bar.remove_ids(NavButtons.PURCHASE)86 self.navigation_bar.remove_ids(NavButtons.PURCHASE)
83 self.notebook.set_current_page(self.PAGE_APPLIST)87 self.notebook.set_current_page(self.PAGE_APPLIST)
84 self.searchentry.show()88 self.searchentry.show()
85 89
86 def _clear_search(self):90 def _clear_search(self):
87 # remove the details and clear the search91 # remove the details and clear the search
88 self.searchentry.clear()92 self.searchentry.clear()
@@ -109,7 +113,7 @@
109 dialog.set_title("")113 dialog.set_title("")
110 dialog.set_markup("<big><b>%s</b></big>" % _("Add channel"))114 dialog.set_markup("<big><b>%s</b></big>" % _("Add channel"))
111 dialog.format_secondary_text(_("The selected channel is not yet "115 dialog.format_secondary_text(_("The selected channel is not yet "
112 "added. Do you want to add it now?"))116 "added. Do you want to add it now?"))
113 dialog.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,117 dialog.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
114 Gtk.STOCK_ADD, Gtk.ResponseType.YES)118 Gtk.STOCK_ADD, Gtk.ResponseType.YES)
115 res = dialog.run()119 res = dialog.run()
@@ -130,7 +134,7 @@
130 self.apps_filter.set_installed_only(True)134 self.apps_filter.set_installed_only(True)
131 # switch to applist, this will clear searches too135 # switch to applist, this will clear searches too
132 self.display_list()136 self.display_list()
133 137
134 def on_search_terms_changed(self, searchentry, terms):138 def on_search_terms_changed(self, searchentry, terms):
135 """callback when the search entry widget changes"""139 """callback when the search entry widget changes"""
136 LOG.debug("on_search_terms_changed: '%s'" % terms)140 LOG.debug("on_search_terms_changed: '%s'" % terms)
@@ -139,7 +143,7 @@
139 self._clear_search()143 self._clear_search()
140 self.refresh_apps()144 self.refresh_apps()
141 self.notebook.set_current_page(self.PAGE_APPLIST)145 self.notebook.set_current_page(self.PAGE_APPLIST)
142 146
143 def on_db_reopen(self, db):147 def on_db_reopen(self, db):
144 LOG.debug("got db-reopen signal")148 LOG.debug("got db-reopen signal")
145 self.refresh_apps()149 self.refresh_apps()
@@ -154,7 +158,7 @@
154 if not button.get_active():158 if not button.get_active():
155 return159 return
156 self.display_list()160 self.display_list()
157 161
158 def display_list(self):162 def display_list(self):
159 self._clear_search()163 self._clear_search()
160 self._show_channel_overview()164 self._show_channel_overview()
@@ -168,7 +172,7 @@
168 if not button.get_active():172 if not button.get_active():
169 return173 return
170 self.display_details()174 self.display_details()
171 175
172 def display_details(self):176 def display_details(self):
173 self.navigation_bar.remove_ids(NavButtons.PURCHASE)177 self.navigation_bar.remove_ids(NavButtons.PURCHASE)
174 self.notebook.set_current_page(self.PAGE_APP_DETAILS)178 self.notebook.set_current_page(self.PAGE_APP_DETAILS)
@@ -176,20 +180,21 @@
176 self.action_bar.clear()180 self.action_bar.clear()
177 # we want to re-enable the buy button if this is an app for purchase181 # we want to re-enable the buy button if this is an app for purchase
178 # FIXME: hacky, find a better approach182 # FIXME: hacky, find a better approach
179 if self.app_details_view.pkg_statusbar.button.get_label() == _(u'Buy\u2026'):183 button = self.app_details_view.pkg_statusbar.button
180 self.app_details_view.pkg_statusbar.button.set_sensitive(True)184 if button.get_label() == _(u'Buy\u2026'):
181 185 button.set_sensitive(True)
186
182 def on_navigation_purchase(self, button, part):187 def on_navigation_purchase(self, button, part):
183 """callback when the navigation button with id 'purchase' is clicked"""188 """callback when the navigation button with id 'purchase' is clicked"""
184 if not button.get_active():189 if not button.get_active():
185 return190 return
186 self.display_purchase()191 self.display_purchase()
187 192
188 def display_purchase(self):193 def display_purchase(self):
189 self.notebook.set_current_page(self.PAGE_APP_PURCHASE)194 self.notebook.set_current_page(self.PAGE_APP_PURCHASE)
190 self.searchentry.hide()195 self.searchentry.hide()
191 self.action_bar.clear()196 self.action_bar.clear()
192 197
193 def on_application_selected(self, appview, app):198 def on_application_selected(self, appview, app):
194 """callback when an app is selected"""199 """callback when an app is selected"""
195 LOG.debug("on_application_selected: '%s'" % app)200 LOG.debug("on_application_selected: '%s'" % app)
@@ -204,7 +209,7 @@
204 length = len(self.app_view.get_model())209 length = len(self.app_view.get_model())
205 self.emit("app-list-changed", length)210 self.emit("app-list-changed", length)
206 self.searchentry.show()211 self.searchentry.show()
207 212
208 def get_status_text(self):213 def get_status_text(self):
209 """return user readable status text suitable for a status bar"""214 """return user readable status text suitable for a status bar"""
210 # no status text in the details page215 # no status text in the details page
@@ -219,34 +224,34 @@
219 if len(self.searchentry.get_text()) > 0:224 if len(self.searchentry.get_text()) > 0:
220 return gettext.ngettext("%(amount)s matching item",225 return gettext.ngettext("%(amount)s matching item",
221 "%(amount)s matching items",226 "%(amount)s matching items",
222 length) % { 'amount' : length, }227 length) % {'amount': length}
223 else:228 else:
224 return gettext.ngettext("%(amount)s item installed",229 return gettext.ngettext("%(amount)s item installed",
225 "%(amount)s items installed",230 "%(amount)s items installed",
226 length) % { 'amount' : length, }231 length) % {'amount': length}
227 else:232 else:
228 if len(self.searchentry.get_text()) > 0:233 if len(self.searchentry.get_text()) > 0:
229 return gettext.ngettext("%(amount)s matching item",234 return gettext.ngettext("%(amount)s matching item",
230 "%(amount)s matching items",235 "%(amount)s matching items",
231 length) % { 'amount' : length, }236 length) % {'amount': length}
232 else:237 else:
233 return gettext.ngettext("%(amount)s item available",238 return gettext.ngettext("%(amount)s item available",
234 "%(amount)s items available",239 "%(amount)s items available",
235 length) % { 'amount' : length, }240 length) % {'amount': length}
236 241
237 def get_current_app(self):242 def get_current_app(self):
238 """return the current active application object applicable243 """return the current active application object applicable
239 to the context"""244 to the context"""
240 return self.current_appview_selection245 return self.current_appview_selection
241 246
242 def is_category_view_showing(self):247 def is_category_view_showing(self):
243 # there is no category view in the channel pane248 # there is no category view in the channel pane
244 return False249 return False
245 250
246 def is_applist_view_showing(self):251 def is_applist_view_showing(self):
247 """Return True if we are in the applist view """252 """Return True if we are in the applist view """
248 return self.notebook.get_current_page() == self.PAGE_APPLIST253 return self.notebook.get_current_page() == self.PAGE_APPLIST
249 254
250 def is_app_details_view_showing(self):255 def is_app_details_view_showing(self):
251 """Return True if we are in the app_details view """256 """Return True if we are in the app_details view """
252 return self.notebook.get_current_page() == self.PAGE_APP_DETAILS257 return self.notebook.get_current_page() == self.PAGE_APP_DETAILS
@@ -288,14 +293,13 @@
288 db.open()293 db.open()
289 except xapian.DatabaseCorruptError as e:294 except xapian.DatabaseCorruptError as e:
290 logging.exception("xapian open failed")295 logging.exception("xapian open failed")
291 dialogs.error(None, 296 dialogs.error(None,
292 _("Sorry, can not open the software database"),297 _("Sorry, can not open the software database"),
293 _("Please re-install the 'software-center' "298 _("Please re-install the 'software-center' "
294 "package."))299 "package."))
295 # FIXME: force rebuild by providing a dbus service for this300 # FIXME: force rebuild by providing a dbus service for this
296 sys.exit(1)301 sys.exit(1)
297302
298
299 import softwarecenter.distro303 import softwarecenter.distro
300 distro = softwarecenter.distro.get_distro()304 distro = softwarecenter.distro.get_distro()
301305
@@ -310,4 +314,3 @@
310 win.connect("destroy", Gtk.main_quit)314 win.connect("destroy", Gtk.main_quit)
311315
312 Gtk.main()316 Gtk.main()
313
314317
=== modified file 'softwarecenter/ui/gtk3/panes/viewswitcher.py'
--- softwarecenter/ui/gtk3/panes/viewswitcher.py 2012-02-20 15:59:17 +0000
+++ softwarecenter/ui/gtk3/panes/viewswitcher.py 2012-03-15 00:20:29 +0000
@@ -38,6 +38,8 @@
3838
3939
40_last_button = None40_last_button = None
41
42
41class ViewSwitcher(Gtk.Box):43class ViewSwitcher(Gtk.Box):
4244
43 ICON_SIZE = Gtk.IconSize.LARGE_TOOLBAR45 ICON_SIZE = Gtk.IconSize.LARGE_TOOLBAR
@@ -45,6 +47,7 @@
45 def __init__(self, view_manager, datadir, db, cache, icons):47 def __init__(self, view_manager, datadir, db, cache, icons):
46 # boring stuff48 # boring stuff
47 self.view_manager = view_manager49 self.view_manager = view_manager
50
48 def on_view_changed(widget, view_id):51 def on_view_changed(widget, view_id):
49 self.view_buttons[view_id].set_active(True)52 self.view_buttons[view_id].set_active(True)
50 self.view_manager.connect('view-changed', on_view_changed)53 self.view_manager.connect('view-changed', on_view_changed)
@@ -70,7 +73,6 @@
70 self._prev_item = None # track the previous active menu-item73 self._prev_item = None # track the previous active menu-item
71 self._handlers = []74 self._handlers = []
7275
73
74 # order is important here!76 # order is important here!
75 # first, the availablepane items77 # first, the availablepane items
76 icon = SymbolicIcon("available")78 icon = SymbolicIcon("available")
@@ -112,13 +114,14 @@
112 else:114 else:
113 self.stop_icon_animation()115 self.stop_icon_animation()
114 pending_btn = self.view_buttons[ViewPages.PENDING]116 pending_btn = self.view_buttons[ViewPages.PENDING]
115 from softwarecenter.ui.gtk3.session.viewmanager import get_viewmanager117 from softwarecenter.ui.gtk3.session.viewmanager import (
118 get_viewmanager,
119 )
116 vm = get_viewmanager()120 vm = get_viewmanager()
117 if vm.get_active_view() == 'view-page-pending':121 if vm.get_active_view() == 'view-page-pending':
118 vm.nav_back()122 vm.nav_back()
119 vm.clear_forward_history()123 vm.clear_forward_history()
120 pending_btn.set_visible(False)124 pending_btn.set_visible(False)
121 return
122125
123 def start_icon_animation(self):126 def start_icon_animation(self):
124 # the pending button ProgressImage is special, see:127 # the pending button ProgressImage is special, see:
@@ -135,9 +138,8 @@
135 image.set_transaction_count(count)138 image.set_transaction_count(count)
136139
137 def on_transaction_finished(self, backend, result):140 def on_transaction_finished(self, backend, result):
138 if result.success: 141 if result.success:
139 self.on_channels_changed()142 self.on_channels_changed()
140 return
141143
142 def on_section_sel_clicked(self, button, event, view_id):144 def on_section_sel_clicked(self, button, event, view_id):
143 # mvo: this check causes bug LP: #828675145 # mvo: this check causes bug LP: #828675
@@ -166,7 +168,6 @@
166168
167 self._prev_view = view_id169 self._prev_view = view_id
168 GObject.idle_add(config_view)170 GObject.idle_add(config_view)
169 return
170171
171 def on_get_available_channels(self, popup):172 def on_get_available_channels(self, popup):
172 return self.build_channel_list(popup, ViewPages.AVAILABLE)173 return self.build_channel_list(popup, ViewPages.AVAILABLE)
@@ -179,7 +180,6 @@
179 # setting popup to None will cause a rebuild of the popup180 # setting popup to None will cause a rebuild of the popup
180 # menu the next time the selector is clicked181 # menu the next time the selector is clicked
181 sel.popup = None182 sel.popup = None
182 return
183183
184 def append_section(self, view_id, label, icon):184 def append_section(self, view_id, label, icon):
185 btn = SectionSelector(label, icon, self.ICON_SIZE)185 btn = SectionSelector(label, icon, self.ICON_SIZE)
@@ -196,7 +196,8 @@
196 # to the group, toggled & clicked gets emitted... causing196 # to the group, toggled & clicked gets emitted... causing
197 # all panes to fully initialise on USC startup, which is197 # all panes to fully initialise on USC startup, which is
198 # undesirable!198 # undesirable!
199 btn.connect("button-release-event", self.on_section_sel_clicked, view_id)199 btn.connect("button-release-event", self.on_section_sel_clicked,
200 view_id)
200 return btn201 return btn
201202
202 def append_channel_selector(self, section_btn, view_id, build_func):203 def append_channel_selector(self, section_btn, view_id, build_func):
@@ -206,7 +207,8 @@
206 self.pack_start(sel, False, False, 0)207 self.pack_start(sel, False, False, 0)
207 return sel208 return sel
208209
209 def append_section_with_channel_sel(self, view_id, label, icon, build_func):210 def append_section_with_channel_sel(self, view_id, label, icon,
211 build_func):
210 btn = self.append_section(view_id, label, icon)212 btn = self.append_section(view_id, label, icon)
211 btn.draw_hint_has_channel_selector = True213 btn.draw_hint_has_channel_selector = True
212 sel = self.append_channel_selector(btn, view_id, build_func)214 sel = self.append_channel_selector(btn, view_id, build_func)
@@ -227,15 +229,16 @@
227 for i, channel in enumerate(channels):229 for i, channel in enumerate(channels):
228 # only calling it with a explicit new() makes it a really230 # only calling it with a explicit new() makes it a really
229 # empty one, otherwise the following error is raised:231 # empty one, otherwise the following error is raised:
230 # """Attempting to add a widget with type GtkBox to a 232 # """Attempting to add a widget with type GtkBox to a
231 # GtkCheckMenuItem, but as a GtkBin subclass a233 # GtkCheckMenuItem, but as a GtkBin subclass a
232 # GtkCheckMenuItem can only contain one widget at a time; 234 # GtkCheckMenuItem can only contain one widget at a time;
233 # it already contains a widget of type GtkAccelLabel """235 # it already contains a widget of type GtkAccelLabel """
234236
235 item = Gtk.MenuItem.new()237 item = Gtk.MenuItem.new()
236238
237 label = Gtk.Label.new(channel.display_name)239 label = Gtk.Label.new(channel.display_name)
238 image = Gtk.Image.new_from_icon_name(channel.icon, Gtk.IconSize.MENU)240 image = Gtk.Image.new_from_icon_name(channel.icon,
241 Gtk.IconSize.MENU)
239242
240 box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, StockEms.SMALL)243 box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, StockEms.SMALL)
241 box.pack_start(image, False, False, 0)244 box.pack_start(image, False, False, 0)
@@ -252,8 +255,7 @@
252 view_id255 view_id
253 )256 )
254 )257 )
255 popup.attach(item, 0, 1, i, i+1)258 popup.attach(item, 0, 1, i, i + 1)
256 return
257259
258 def on_channel_selected(self, item, event, channel, view_id):260 def on_channel_selected(self, item, event, channel, view_id):
259 vm = self.view_manager261 vm = self.view_manager
@@ -279,7 +281,6 @@
279 return False281 return False
280282
281 GObject.idle_add(config_view)283 GObject.idle_add(config_view)
282 return
283284
284285
285def get_test_window_viewswitcher():286def get_test_window_viewswitcher():
@@ -305,7 +306,7 @@
305 scroll.add_with_viewport(view)306 scroll.add_with_viewport(view)
306307
307 win.add(box)308 win.add(box)
308 win.set_size_request(400,200)309 win.set_size_request(400, 200)
309 win.connect("destroy", Gtk.main_quit)310 win.connect("destroy", Gtk.main_quit)
310 win.show_all()311 win.show_all()
311 return win312 return win
@@ -317,5 +318,4 @@
317 softwarecenter.paths.datadir = "./data"318 softwarecenter.paths.datadir = "./data"
318 win = get_test_window_viewswitcher()319 win = get_test_window_viewswitcher()
319320
320
321 Gtk.main()321 Gtk.main()
322322
=== modified file 'softwarecenter/ui/gtk3/session/appmanager.py'
--- softwarecenter/ui/gtk3/session/appmanager.py 2012-02-07 16:56:40 +0000
+++ softwarecenter/ui/gtk3/session/appmanager.py 2012-03-15 00:20:29 +0000
@@ -31,10 +31,14 @@
31from softwarecenter.distro import get_current_arch, get_distro31from softwarecenter.distro import get_current_arch, get_distro
32from softwarecenter.i18n import get_language32from softwarecenter.i18n import get_language
33from softwarecenter.ui.gtk3.dialogs import dependency_dialogs33from softwarecenter.ui.gtk3.dialogs import dependency_dialogs
34from softwarecenter.backend.transactionswatcher import TransactionFinishedResult34from softwarecenter.backend.transactionswatcher import (
35 TransactionFinishedResult,
36)
35import softwarecenter.paths37import softwarecenter.paths
3638
37_appmanager = None # the global AppManager instance39_appmanager = None # the global AppManager instance
40
41
38def get_appmanager():42def get_appmanager():
39 """ get a existing appmanager instance (or None if none is created yet) """43 """ get a existing appmanager instance (or None if none is created yet) """
40 return _appmanager44 return _appmanager
@@ -43,10 +47,10 @@
43class ApplicationManager(GObject.GObject):47class ApplicationManager(GObject.GObject):
4448
45 __gsignals__ = {49 __gsignals__ = {
46 "purchase-requested" : (GObject.SignalFlags.RUN_LAST,50 "purchase-requested": (GObject.SignalFlags.RUN_LAST,
47 None,51 None,
48 (GObject.TYPE_PYOBJECT, str, str,)52 (GObject.TYPE_PYOBJECT, str, str,)
49 ),53 ),
50 }54 }
5155
52 def __init__(self, db, backend, icons):56 def __init__(self, db, backend, icons):
@@ -72,25 +76,26 @@
72 if action is "remove", must check if other dependencies have to be76 if action is "remove", must check if other dependencies have to be
73 removed as well and show a dialog in that case77 removed as well and show a dialog in that case
74 """78 """
75 #~ LOG.debug("on_application_action_requested: '%s' %s" % (app, action))79 #~ LOG.debug("on_application_action_requested: '%s' %s"
80 #~ % (app, action))
76 appdetails = app.get_details(self.db)81 appdetails = app.get_details(self.db)
77 if action == AppActions.REMOVE:82 if action == AppActions.REMOVE:
78 if not dependency_dialogs.confirm_remove(83 if not dependency_dialogs.confirm_remove(
79 None, self.datadir, app, self.db, self.icons):84 None, self.datadir, app, self.db, self.icons):
80 # craft an instance of TransactionFinishedResult to send with the85 # craft an instance of TransactionFinishedResult to send
81 # transaction-stopped signal86 # with the transaction-stopped signal
82 result = TransactionFinishedResult(None, False)87 result = TransactionFinishedResult(None, False)
83 result.pkgname = app.pkgname88 result.pkgname = app.pkgname
84 self.backend.emit("transaction-stopped", result)89 self.backend.emit("transaction-stopped", result)
85 return90 return
86 elif action == AppActions.INSTALL:91 elif action == AppActions.INSTALL:
87 # If we are installing a package, check for dependencies that will 92 # If we are installing a package, check for dependencies that will
88 # also be removed and show a dialog for confirmation93 # also be removed and show a dialog for confirmation
89 # generic removal text (fixing LP bug #554319)94 # generic removal text (fixing LP bug #554319)
90 if not dependency_dialogs.confirm_install(95 if not dependency_dialogs.confirm_install(
91 None, self.datadir, app, self.db, self.icons):96 None, self.datadir, app, self.db, self.icons):
92 # craft an instance of TransactionFinishedResult to send with the97 # craft an instance of TransactionFinishedResult to send
93 # transaction-stopped signal98 # with the transaction-stopped signal
94 result = TransactionFinishedResult(None, False)99 result = TransactionFinishedResult(None, False)
95 result.pkgname = app.pkgname100 result.pkgname = app.pkgname
96 self.backend.emit("transaction-stopped", result)101 self.backend.emit("transaction-stopped", result)
@@ -100,8 +105,9 @@
100 if (action == AppActions.UPGRADE and app.request and105 if (action == AppActions.UPGRADE and app.request and
101 isinstance(app, DebFileApplication)):106 isinstance(app, DebFileApplication)):
102 action = AppActions.INSTALL107 action = AppActions.INSTALL
103 108
104 # action_func is one of: "install", "remove", "upgrade", "apply_changes"109 # action_func is one of:
110 # "install", "remove", "upgrade", "apply_changes"
105 action_func = getattr(self.backend, action)111 action_func = getattr(self.backend, action)
106 if action == AppActions.INSTALL:112 if action == AppActions.INSTALL:
107 # the package.deb path name is in the request113 # the package.deb path name is in the request
@@ -117,7 +123,8 @@
117 addons_install=addons_install,123 addons_install=addons_install,
118 addons_remove=addons_remove)124 addons_remove=addons_remove)
119 #~ else:125 #~ else:
120 #~ LOG.error("Not a valid action in AptdaemonBackend: '%s'" % action)126 #~ LOG.error("Not a valid action in AptdaemonBackend: '%s'" %
127 #~ action)
121128
122 # public interface129 # public interface
123 def reload(self):130 def reload(self):
@@ -149,10 +156,10 @@
149 lang = get_language()156 lang = get_language()
150 appdetails = app.get_details(self.db)157 appdetails = app.get_details(self.db)
151 url = self.distro.PURCHASE_APP_URL % (158 url = self.distro.PURCHASE_APP_URL % (
152 lang, self.distro.get_codename(), urlencode(159 lang, self.distro.get_codename(), urlencode({
153 {'archive_id' : appdetails.ppaname, 160 'archive_id': appdetails.ppaname,
154 'arch' : get_current_arch(),}161 'arch': get_current_arch()
155 )162 })
156 )163 )
157 self.emit("purchase-requested", app, appdetails.icon, url)164 self.emit("purchase-requested", app, appdetails.icon, url)
158165
159166
=== modified file 'softwarecenter/ui/gtk3/session/navhistory.py'
--- softwarecenter/ui/gtk3/session/navhistory.py 2011-10-22 00:13:32 +0000
+++ softwarecenter/ui/gtk3/session/navhistory.py 2012-03-15 00:20:29 +0000
@@ -20,7 +20,8 @@
2020
21import logging21import logging
2222
23LOG=logging.getLogger(__name__)23LOG = logging.getLogger(__name__)
24
2425
25class NavigationHistory(object):26class NavigationHistory(object):
26 """27 """
@@ -34,7 +35,6 @@
34 self.in_replay_history_mode = False35 self.in_replay_history_mode = False
35 self._nav_back_set_sensitive(False)36 self._nav_back_set_sensitive(False)
36 self._nav_forward_set_sensitive(False)37 self._nav_forward_set_sensitive(False)
37 return
3838
39 def append(self, nav_item):39 def append(self, nav_item):
40 """40 """
@@ -81,7 +81,7 @@
81 if self.back_forward.left.has_focus():81 if self.back_forward.left.has_focus():
82 self.back_forward.right.grab_focus()82 self.back_forward.right.grab_focus()
83 self._nav_back_set_sensitive(False)83 self._nav_back_set_sensitive(False)
84 84
85 def clear_forward_history(self):85 def clear_forward_history(self):
86 """86 """
87 clear the forward history and set the corresponding forward87 clear the forward history and set the corresponding forward
@@ -100,7 +100,7 @@
100 self.stack.reset()100 self.stack.reset()
101 self._nav_back_set_sensitive(False)101 self._nav_back_set_sensitive(False)
102 self._nav_forward_set_sensitive(False)102 self._nav_forward_set_sensitive(False)
103 103
104 def _nav_back_set_sensitive(self, is_sensitive):104 def _nav_back_set_sensitive(self, is_sensitive):
105 self.back_forward.left.set_sensitive(is_sensitive)105 self.back_forward.left.set_sensitive(is_sensitive)
106 #~ self.navhistory_back_action.set_sensitive(is_sensitive)106 #~ self.navhistory_back_action.set_sensitive(is_sensitive)
@@ -121,7 +121,6 @@
121 self.page = page121 self.page = page
122 self.view_state = view_state122 self.view_state = view_state
123 self.callback = callback123 self.callback = callback
124 return
125124
126 def __str__(self):125 def __str__(self):
127 facet = self.pane.pane_name.replace(' ', '')[:6]126 facet = self.pane.pane_name.replace(' ', '')[:6]
@@ -154,7 +153,7 @@
154 self.stack = []153 self.stack = []
155 self.cursor = 0154 self.cursor = 0
156155
157 if not options or not options.display_navlog: 156 if not options or not options.display_navlog:
158 return157 return
159158
160 import softwarecenter.ui.gtk3.widgets.navlog as navlog159 import softwarecenter.ui.gtk3.widgets.navlog as navlog
@@ -186,7 +185,8 @@
186 last = self[-1]185 last = self[-1]
187 last_vs = last.view_state186 last_vs = last.view_state
188 item_vs = item.view_state187 item_vs = item.view_state
189 # FIXME: This is getting messy, this stuff should be cleaned up somehow...188 # FIXME: This is getting messy, this stuff should be cleaned up
189 # somehow...
190 # hacky: special case, check for subsequent searches190 # hacky: special case, check for subsequent searches
191 # if subsequent search, update previous item_vs.search_term191 # if subsequent search, update previous item_vs.search_term
192 # to current.192 # to current.
@@ -212,11 +212,12 @@
212 if len(self) == 1:212 if len(self) == 1:
213 self.history._nav_back_set_sensitive(False)213 self.history._nav_back_set_sensitive(False)
214 self.history._nav_forward_set_sensitive(False)214 self.history._nav_forward_set_sensitive(False)
215 LOG.debug("also remove 'spurious' list navigation item (Bug #854047)")215 LOG.debug("also remove 'spurious' list navigation item "
216 "(Bug #854047)")
216 return False217 return False
217218
218 elif (item.page != AvailablePane.Pages.LIST and219 elif (item.page != AvailablePane.Pages.LIST and
219 last.page == AvailablePane.Pages.LIST and 220 last.page == AvailablePane.Pages.LIST and
220 not item_vs.search_term and last_vs.search_term):221 not item_vs.search_term and last_vs.search_term):
221 LOG.debug("search has been cleared. ignoring history item")222 LOG.debug("search has been cleared. ignoring history item")
222 if len(self) > 1:223 if len(self) > 1:
@@ -224,7 +225,8 @@
224 if len(self) == 1:225 if len(self) == 1:
225 self.history._nav_back_set_sensitive(False)226 self.history._nav_back_set_sensitive(False)
226 self.history._nav_forward_set_sensitive(False)227 self.history._nav_forward_set_sensitive(False)
227 LOG.debug("also remove 'spurious' list navigation item (Bug #854047)")228 LOG.debug("also remove 'spurious' list navigation item "
229 "(Bug #854047)")
228 return False230 return False
229231
230 if item.__str__() == last.__str__():232 if item.__str__() == last.__str__():
@@ -234,19 +236,18 @@
234236
235 def append(self, item):237 def append(self, item):
236 if not self._isok(item):238 if not self._isok(item):
237 self.cursor = len(self.stack)-1239 self.cursor = len(self.stack) - 1
238 LOG.debug('A:%s' % repr(self))240 LOG.debug('A:%s' % repr(self))
239 #~ print ('A:%s' % repr(self))241 #~ print ('A:%s' % repr(self))
240 return242 return
241 if len(self.stack) + 1 > self.max_length:243 if len(self.stack) + 1 > self.max_length:
242 self.stack.pop(1)244 self.stack.pop(1)
243 self.stack.append(item)245 self.stack.append(item)
244 self.cursor = len(self.stack)-1246 self.cursor = len(self.stack) - 1
245 LOG.debug('A:%s' % repr(self))247 LOG.debug('A:%s' % repr(self))
246 #~ print ('A:%s' % repr(self))248 #~ print ('A:%s' % repr(self))
247 if hasattr(self, "navlog"):249 if hasattr(self, "navlog"):
248 self.navlog.log.notify_append(item)250 self.navlog.log.notify_append(item)
249 return
250251
251 def step_back(self):252 def step_back(self):
252 did_step = False253 did_step = False
@@ -263,11 +264,11 @@
263264
264 def step_forward(self):265 def step_forward(self):
265 did_step = False266 did_step = False
266 if self.cursor < len(self.stack)-1:267 if self.cursor < len(self.stack) - 1:
267 self.cursor += 1268 self.cursor += 1
268 did_step = True269 did_step = True
269 else:270 else:
270 self.cursor = len(self.stack)-1271 self.cursor = len(self.stack) - 1
271 LOG.debug('B:%s' % repr(self))272 LOG.debug('B:%s' % repr(self))
272 #~ print ('B:%s' % repr(self))273 #~ print ('B:%s' % repr(self))
273 if hasattr(self, "navlog") and did_step:274 if hasattr(self, "navlog") and did_step:
@@ -280,7 +281,7 @@
280 self.navlog.log.notify_clear_forward_items()281 self.navlog.log.notify_clear_forward_items()
281282
282 def at_end(self):283 def at_end(self):
283 return self.cursor == len(self.stack)-1284 return self.cursor == len(self.stack) - 1
284285
285 def at_start(self):286 def at_start(self):
286 return self.cursor == 0287 return self.cursor == 0
287288
=== modified file 'softwarecenter/ui/gtk3/session/viewmanager.py'
--- softwarecenter/ui/gtk3/session/viewmanager.py 2012-02-16 14:14:01 +0000
+++ softwarecenter/ui/gtk3/session/viewmanager.py 2012-03-15 00:20:29 +0000
@@ -22,17 +22,21 @@
22from softwarecenter.ui.gtk3.widgets.backforward import BackForwardButton22from softwarecenter.ui.gtk3.widgets.backforward import BackForwardButton
23from softwarecenter.ui.gtk3.widgets.searchentry import SearchEntry23from softwarecenter.ui.gtk3.widgets.searchentry import SearchEntry
2424
25_viewmanager = None # the global Viewmanager instance25
26_viewmanager = None # the global Viewmanager instance
27
28
26def get_viewmanager():29def get_viewmanager():
27 return _viewmanager30 return _viewmanager
2831
32
29class ViewManager(GObject.GObject):33class ViewManager(GObject.GObject):
3034
31 __gsignals__ = {35 __gsignals__ = {
32 "view-changed" : (GObject.SignalFlags.RUN_LAST,36 "view-changed": (GObject.SignalFlags.RUN_LAST,
33 None,37 None,
34 (GObject.TYPE_PYOBJECT, ),38 (GObject.TYPE_PYOBJECT, ),
35 ),39 ),
36 }40 }
3741
38 def __init__(self, notebook_view, options=None):42 def __init__(self, notebook_view, options=None):
@@ -69,30 +73,27 @@
69 pane = self.get_current_view_widget()73 pane = self.get_current_view_widget()
70 if hasattr(pane, "on_search_terms_changed"):74 if hasattr(pane, "on_search_terms_changed"):
71 pane.on_search_terms_changed(widget, new_text)75 pane.on_search_terms_changed(widget, new_text)
72 return
7376
74 def on_nav_back_clicked(self, widget):77 def on_nav_back_clicked(self, widget):
75 pane = self.get_current_view_widget()78 pane = self.get_current_view_widget()
76 if hasattr(pane, "on_nav_back_clicked"):79 if hasattr(pane, "on_nav_back_clicked"):
77 pane.on_nav_back_clicked(widget)80 pane.on_nav_back_clicked(widget)
78 return
7981
80 def on_nav_forward_clicked(self, widget):82 def on_nav_forward_clicked(self, widget):
81 pane = self.get_current_view_widget()83 pane = self.get_current_view_widget()
82 if hasattr(pane, "on_nav_forward_clicked"):84 if hasattr(pane, "on_nav_forward_clicked"):
83 pane.on_nav_forward_clicked(widget)85 pane.on_nav_forward_clicked(widget)
84 return86
85
86 def on_search_entry_key_press_event(self, widget, event):87 def on_search_entry_key_press_event(self, widget, event):
87 88
88 pane = self.get_current_view_widget()89 pane = self.get_current_view_widget()
89 if hasattr(pane, "on_search_entry_key_press_event"):90 if hasattr(pane, "on_search_entry_key_press_event"):
90 pane.on_search_entry_key_press_event(event)91 pane.on_search_entry_key_press_event(event)
91 return
9292
93 def register(self, pane, view_id):93 def register(self, pane, view_id):
94 page_id = self.notebook_view.append_page(94 page_id = self.notebook_view.append_page(
95 pane, Gtk.Label.new("View %s" % view_id)) # label is for debugging only95 pane,
96 Gtk.Label.new("View %s" % view_id)) # label is for debugging only
96 self.all_views[view_id] = page_id97 self.all_views[view_id] = page_id
97 self.view_to_pane[view_id] = pane98 self.view_to_pane[view_id] = pane
9899
@@ -115,7 +116,7 @@
115116
116 def set_active_view(self, view_id):117 def set_active_view(self, view_id):
117 # no views yet118 # no views yet
118 if not self.all_views: 119 if not self.all_views:
119 return120 return
120 # if the view switches, ensure that the global spinner is hidden121 # if the view switches, ensure that the global spinner is hidden
121 self.spinner.hide()122 self.spinner.hide()
@@ -135,7 +136,7 @@
135 view_widget.state.search_term):136 view_widget.state.search_term):
136 self.search_entry.set_text_with_no_signal(137 self.search_entry.set_text_with_no_signal(
137 view_widget.state.search_term)138 view_widget.state.search_term)
138 139
139# callback = view_widget.get_callback_for_page(view_page,140# callback = view_widget.get_callback_for_page(view_page,
140# view_state)141# view_state)
141142
@@ -157,7 +158,7 @@
157158
158 def get_notebook_page_from_view_id(self, view_id):159 def get_notebook_page_from_view_id(self, view_id):
159 return self.all_views[view_id]160 return self.all_views[view_id]
160 161
161 def get_view_widget(self, view_id):162 def get_view_widget(self, view_id):
162 return self.view_to_pane.get(view_id, None)163 return self.view_to_pane.get(view_id, None)
163164
@@ -194,8 +195,9 @@
194 if self.get_current_view_widget() != pane:195 if self.get_current_view_widget() != pane:
195 view_id = None196 view_id = None
196 for view_id, widget in self.view_to_pane.items():197 for view_id, widget in self.view_to_pane.items():
197 if widget == pane: break198 if widget == pane:
198 199 break
200
199 self.set_active_view(view_id)201 self.set_active_view(view_id)
200202
201 if (not pane.searchentry or203 if (not pane.searchentry or
@@ -209,14 +211,13 @@
209 else:211 else:
210 self.search_entry.show()212 self.search_entry.show()
211 self.spinner.hide()213 self.spinner.hide()
212 return
213214
214 def nav_back(self):215 def nav_back(self):
215 self.navhistory.nav_back()216 self.navhistory.nav_back()
216217
217 def nav_forward(self):218 def nav_forward(self):
218 self.navhistory.nav_forward()219 self.navhistory.nav_forward()
219 220
220 def clear_forward_history(self):221 def clear_forward_history(self):
221 self.navhistory.clear_forward_history()222 self.navhistory.clear_forward_history()
222223
223224
=== modified file 'test/test_pep8.py'
--- test/test_pep8.py 2012-03-15 00:20:29 +0000
+++ test/test_pep8.py 2012-03-15 00:20:29 +0000
@@ -8,6 +8,8 @@
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.panes
12import softwarecenter.ui.gtk3.session
11import softwarecenter.ui.gtk3.views13import softwarecenter.ui.gtk3.views
12import softwarecenter.ui.gtk3.widgets14import softwarecenter.ui.gtk3.widgets
13import softwarecenter.ui.qml15import softwarecenter.ui.qml
@@ -15,10 +17,13 @@
15class PackagePep8TestCase(unittest.TestCase):17class PackagePep8TestCase(unittest.TestCase):
16 maxDiff = None18 maxDiff = None
17 packages = [softwarecenter.ui.qml,19 packages = [softwarecenter.ui.qml,
20 softwarecenter.ui.gtk3.panes,
21 softwarecenter.ui.gtk3.session,
18 softwarecenter.ui.gtk3.views,22 softwarecenter.ui.gtk3.views,
19 softwarecenter.ui.gtk3.widgets,23 softwarecenter.ui.gtk3.widgets,
20 softwarecenter.db.pkginfo_impl]24 softwarecenter.db.pkginfo_impl]
21 exclude = []25 exclude = ['availablepane.py', 'basepane.py', 'globalpane.py',
26 'historypane.py', 'installedpane.py']
2227
23 def message(self, text):28 def message(self, text):
24 self.errors.append(text)29 self.errors.append(text)