=== modified file 'softwarecenter/ui/gtk3/panes/availablepane.py'
--- softwarecenter/ui/gtk3/panes/availablepane.py 2012-03-06 22:10:15 +0000
+++ softwarecenter/ui/gtk3/panes/availablepane.py 2012-03-15 01:02:25 +0000
@@ -53,6 +53,7 @@
LOG = logging.getLogger(__name__)
+
class AvailablePane(SoftwarePane):
"""Widget that represents the available panel in software-center
It contains a search entry and navigation buttons
@@ -60,10 +61,10 @@
class Pages():
# page names, useful for debugging
- NAMES = ('lobby',
+ NAMES = ('lobby',
'subcategory',
'list',
- 'details',
+ 'details',
'purchase',
)
# actual page id's
@@ -75,17 +76,17 @@
# the default page
HOME = LOBBY
- __gsignals__ = {'available-pane-created':(GObject.SignalFlags.RUN_FIRST,
- None,
- ())}
+ __gsignals__ = {'available-pane-created': (GObject.SignalFlags.RUN_FIRST,
+ None,
+ ())}
- def __init__(self,
+ def __init__(self,
cache,
- db,
- distro,
- icons,
- datadir,
- navhistory_back_action,
+ db,
+ distro,
+ icons,
+ datadir,
+ navhistory_back_action,
navhistory_forward_action):
# parent
SoftwarePane.__init__(self, cache, db, distro, icons, datadir)
@@ -100,21 +101,21 @@
self.current_app_by_category = {}
self.current_app_by_subcategory = {}
self.pane_name = _("Get Software")
-
+
# views to be created in init_view
self.cat_view = None
self.subcategories_view = None
-
+
# integrate with the Unity launcher
self.unity_launcher = UnityLauncher()
-
+
# flag to indicate whether applications should be added to the
# unity launcher when installed (this value is initialized by
# the config load in app.py)
self.add_to_launcher_enabled = True
def init_view(self):
- if self.view_initialized:
+ if self.view_initialized:
return
self.show_appview_spinner()
@@ -134,21 +135,26 @@
#~ self.app_view._append_appcount(appcount)
#~ liststore.connect('appcount-changed', on_appcount_changed)
self.app_view.set_model(liststore)
- liststore.connect(
- "needs-refresh", lambda helper, pkgname: self.app_view.queue_draw())
+ liststore.connect("needs-refresh",
+ lambda helper, pkgname: self.app_view.queue_draw())
# purchase view
self.purchase_view = PurchaseView()
app_manager = get_appmanager()
- app_manager.connect("purchase-requested", self.on_purchase_requested)
- self.purchase_view.connect("purchase-succeeded", self.on_purchase_succeeded)
- self.purchase_view.connect("purchase-failed", self.on_purchase_failed)
- self.purchase_view.connect("purchase-cancelled-by-user", self.on_purchase_cancelled_by_user)
- self.purchase_view.connect("purchase-needs-spinner", self.on_purchase_needs_spinner)
+ app_manager.connect("purchase-requested",
+ self.on_purchase_requested)
+ self.purchase_view.connect("purchase-succeeded",
+ self.on_purchase_succeeded)
+ self.purchase_view.connect("purchase-failed",
+ self.on_purchase_failed)
+ self.purchase_view.connect("purchase-cancelled-by-user",
+ self.on_purchase_cancelled_by_user)
+ self.purchase_view.connect("purchase-needs-spinner",
+ self.on_purchase_needs_spinner)
# categories, appview and details into the notebook in the bottom
self.scroll_categories = Gtk.ScrolledWindow()
- self.scroll_categories.set_policy(Gtk.PolicyType.AUTOMATIC,
+ self.scroll_categories.set_policy(Gtk.PolicyType.AUTOMATIC,
Gtk.PolicyType.AUTOMATIC)
self.cat_view = LobbyViewGtk(self.datadir, APP_INSTALL_PATH,
self.cache,
@@ -156,16 +162,17 @@
self.icons,
self.apps_filter)
self.scroll_categories.add(self.cat_view)
- self.notebook.append_page(self.scroll_categories, Gtk.Label(label="categories"))
+ self.notebook.append_page(self.scroll_categories,
+ Gtk.Label(label="categories"))
# sub-categories view
self.subcategories_view = SubCategoryViewGtk(self.datadir,
- APP_INSTALL_PATH,
- self.cache,
- self.db,
- self.icons,
- self.apps_filter,
- root_category=self.cat_view.categories[0])
+ APP_INSTALL_PATH,
+ self.cache,
+ self.db,
+ self.icons,
+ self.apps_filter,
+ root_category=self.cat_view.categories[0])
self.subcategories_view.connect(
"category-selected", self.on_subcategory_activated)
self.subcategories_view.connect(
@@ -196,15 +203,19 @@
"application-activated", self.on_application_activated)
# details
- self.notebook.append_page(self.scroll_details, Gtk.Label(label=NavButtons.DETAILS))
+ self.notebook.append_page(self.scroll_details,
+ Gtk.Label(label=NavButtons.DETAILS))
# purchase view
- self.notebook.append_page(self.purchase_view, Gtk.Label(label=NavButtons.PURCHASE))
+ self.notebook.append_page(self.purchase_view,
+ Gtk.Label(label=NavButtons.PURCHASE))
# install backend
- self.backend.connect("transactions-changed", self._on_transactions_changed)
- self.backend.connect("transaction-started", self.on_transaction_started)
-
+ self.backend.connect("transactions-changed",
+ self._on_transactions_changed)
+ self.backend.connect("transaction-started",
+ self.on_transaction_started)
+
# now we are initialized
self.searchentry.set_sensitive(True)
self.emit("available-pane-created")
@@ -230,7 +241,6 @@
vm.display_page(
self, AvailablePane.Pages.PURCHASE, self.state,
self.display_purchase)
- return
def on_purchase_needs_spinner(self, appmanager, active):
vm = get_viewmanager()
@@ -239,14 +249,14 @@
def on_purchase_succeeded(self, widget):
# switch to the details page to display the transaction is in progress
self._return_to_appdetails_view()
-
+
def on_purchase_failed(self, widget):
self._return_to_appdetails_view()
dialogs.error(None,
_("Failure in the purchase process."),
_("Sorry, something went wrong. Your payment "
"has been cancelled."))
-
+
def on_purchase_cancelled_by_user(self, widget):
self._return_to_appdetails_view()
@@ -307,15 +317,16 @@
#~ def _show_hide_subcategories(self, show_category_applist=False):
#~ # check if have subcategories and are not in a subcategory
#~ # view - if so, show it
- #~ if (self.notebook.get_current_page() == AvailablePane.Pages.LOBBY or
- #~ self.notebook.get_current_page() == AvailablePane.Pages.DETAILS):
+ #~ current_page = self.notebook.get_current_page()
+ #~ if (current_page == AvailablePane.Pages.LOBBY or
+ #~ current_page == AvailablePane.Pages.DETAILS):
#~ return
#~ if (not show_category_applist and
#~ self.state.category and
#~ self.state.category.subcategories and
#~ not (self.state.search_term or self.state.subcategory)):
#~ self.subcategories_view.set_subcategory(self.state.category,
- #~ num_items=len(self.app_view.get_model()))
+ #~ num_items=len(self.app_view.get_model()))
#~ self.notebook.set_current_page(AvailablePane.Pages.SUBCATEGORY)
#~ else:
#~ self.notebook.set_current_page(AvailablePane.Pages.LIST)
@@ -326,7 +337,8 @@
return None
else:
if self.state.subcategory:
- return self.current_app_by_subcategory.get(self.state.subcategory)
+ return self.current_app_by_subcategory.get(
+ self.state.subcategory)
else:
return self.current_app_by_category.get(self.state.category)
@@ -336,11 +348,10 @@
return self.state.subcategory
elif self.state.category:
return self.state.category
- return None
def unset_current_category(self):
- """ unset the current showing category, but keep e.g. the current
- search
+ """ unset the current showing category, but keep e.g. the current
+ search
"""
self.state.category = None
@@ -352,14 +363,14 @@
"""
if self._is_custom_list_search(self.state.search_term):
self._update_action_bar()
-
- def on_transaction_started(self, backend, pkgname, appname, trans_id,
+
+ def on_transaction_started(self, backend, pkgname, appname, trans_id,
trans_type):
self._add_application_to_unity_launcher(
backend, pkgname, appname, trans_id, trans_type)
- def _add_application_to_unity_launcher(self, backend, pkgname,
- appname, trans_id,
+ def _add_application_to_unity_launcher(self, backend, pkgname,
+ appname, trans_id,
trans_type):
if not self.add_to_launcher_enabled:
return
@@ -370,7 +381,7 @@
# we only care about installs
if not trans_type == TransactionTypes.INSTALL:
return
-
+
app = Application(pkgname=pkgname, appname=appname)
appdetails = app.get_details(self.db)
# we only add items to the launcher that have a desktop file
@@ -385,9 +396,11 @@
# now gather up the unity launcher info items and send the app to the
# launcher service
- launcher_info = self._get_unity_launcher_info(app, appdetails, trans_id)
- self.unity_launcher.send_application_to_launcher(pkgname, launcher_info)
-
+ launcher_info = self._get_unity_launcher_info(app, appdetails,
+ trans_id)
+ self.unity_launcher.send_application_to_launcher(pkgname,
+ launcher_info)
+
def _get_unity_launcher_info(self, app, appdetails, trans_id):
(icon_size, icon_x, icon_y) = (
self._get_onscreen_icon_details_for_launcher_service(app))
@@ -426,10 +439,10 @@
self._update_action_bar_buttons()
def _update_action_bar_buttons(self):
- '''
- update buttons in the action bar to implement the custom package lists feature,
- see https://wiki.ubuntu.com/SoftwareCenter#Custom%20package%20lists
- '''
+ """Update buttons in the action bar to implement the custom package
+ lists feature, see
+ https://wiki.ubuntu.com/SoftwareCenter#Custom%20package%20lists
+ """
if self._is_custom_list_search(self.state.search_term):
installable = []
for doc in self.enquirer.get_documents():
@@ -439,9 +452,10 @@
not len(self.backend.pending_transactions) > 0):
app = Application(pkgname=pkgname)
installable.append(app)
- button_text = gettext.ngettext("Install %(amount)s Item",
- "Install %(amount)s Items",
- len(installable)) % { 'amount': len(installable), }
+ button_text = gettext.ngettext(
+ "Install %(amount)s Item",
+ "Install %(amount)s Items",
+ len(installable)) % {'amount': len(installable)}
button = self.action_bar.get_button(ActionButtons.INSTALL)
if button and installable:
# Install all already offered. Update offer.
@@ -457,7 +471,7 @@
else:
# Ensure button is removed.
self.action_bar.remove_button(ActionButtons.INSTALL)
-
+
def _install_current_appstore(self):
'''
Function that installs all applications displayed in the pane.
@@ -478,17 +492,17 @@
self.backend.install_multiple(pkgnames, appnames, iconnames)
def set_state(self, nav_item):
- return
+ pass
def _clear_search(self):
self.searchentry.clear_with_no_signal()
self.apps_limit = 0
self.apps_search_term = ""
-
+
def _is_custom_list_search(self, search_term):
- return (search_term and
+ return (search_term and
',' in search_term)
-
+
# callbacks
def on_cache_ready(self, cache):
""" refresh the application list when the cache is re-opened """
@@ -502,7 +516,7 @@
LOG.debug("on_search_terms_changed: %s" % new_text)
self.state.search_term = new_text
-
+
# do not hide technical items for a custom list search
if self._is_custom_list_search(self.state.search_term):
self.nonapps_visible = NonAppVisibility.ALWAYS_VISIBLE
@@ -527,7 +541,7 @@
self.display_app_view_page)
return False
- elif (self.state.category and
+ elif (self.state.category and
self.state.category.subcategories and not new_text):
vm.display_page(self,
AvailablePane.Pages.SUBCATEGORY,
@@ -632,13 +646,12 @@
SoftwarePane.display_details_page(self, page, view_state)
self.cat_view.stop_carousels()
return True
-
+
def display_purchase(self, page, view_state):
self.notebook.set_current_page(AvailablePane.Pages.PURCHASE)
self.action_bar.clear()
self.cat_view.stop_carousels()
- return
-
+
def display_previous_purchases(self, page, view_state):
self.nonapps_visible = NonAppVisibility.ALWAYS_VISIBLE
self.app_view.set_header_labels(_("Previous Purchases"), None)
@@ -648,7 +661,6 @@
self.refresh_apps(query=self.previous_purchases_query)
self.action_bar.clear()
self.cat_view.stop_carousels()
- return
def on_subcategory_activated(self, subcat_view, category):
LOG.debug("on_subcategory_activated: %s %s" % (
@@ -713,13 +725,14 @@
""" Return True if we are in the category page or if we display a
sub-category page
"""
- return (self.notebook.get_current_page() == AvailablePane.Pages.LOBBY or \
- self.notebook.get_current_page() == AvailablePane.Pages.SUBCATEGORY)
+ current_page = self.notebook.get_current_page()
+ return (current_page == AvailablePane.Pages.LOBBY or
+ current_page == AvailablePane.Pages.SUBCATEGORY)
def is_applist_view_showing(self):
"""Return True if we are in the applist view """
return self.notebook.get_current_page() == AvailablePane.Pages.LIST
-
+
def is_app_details_view_showing(self):
"""Return True if we are in the app_details view """
return self.notebook.get_current_page() == AvailablePane.Pages.DETAILS
@@ -739,12 +752,14 @@
if not self.state.filter:
self.state.filter = AppFilter(self.db, self.cache)
- if category and category.flags and 'available-only' in category.flags:
+ if (category and category.flags and
+ 'available-only' in category.flags):
self.state.filter.set_available_only(True)
else:
self.state.filter.set_available_only(False)
- if category and category.flags and 'not-installed-only' in category.flags:
+ if (category and category.flags and
+ 'not-installed-only' in category.flags):
self.state.filter.set_not_installed_only(True)
else:
self.state.filter.set_not_installed_only(False)
@@ -769,7 +784,7 @@
)
# needed because available pane will try to get it
vm = get_test_gtk3_viewmanager()
- vm # make pyflakes happy
+ vm # make pyflakes happy
db = get_test_db()
cache = get_test_pkg_info()
datadir = get_test_datadir()
@@ -780,17 +795,20 @@
from softwarecenter.ui.gtk3.session.appmanager import ApplicationManager
ApplicationManager(db, backend, icons)
- navhistory_back_action = Gtk.Action("navhistory_back_action", "Back", "Back", None)
- navhistory_forward_action = Gtk.Action("navhistory_forward_action", "Forward", "Forward", None)
+ navhistory_back_action = Gtk.Action("navhistory_back_action", "Back",
+ "Back", None)
+ navhistory_forward_action = Gtk.Action("navhistory_forward_action",
+ "Forward", "Forward", None)
- w = AvailablePane(cache, db, 'Ubuntu', icons, datadir, navhistory_back_action, navhistory_forward_action)
+ w = AvailablePane(cache, db, 'Ubuntu', icons, datadir,
+ navhistory_back_action, navhistory_forward_action)
w.init_view()
w.show()
win = Gtk.Window()
win.connect("destroy", Gtk.main_quit)
win.add(w)
- win.set_size_request(800,600)
+ win.set_size_request(800, 600)
win.show_all()
# this is used later in tests
@@ -801,4 +819,3 @@
if __name__ == "__main__":
win = get_test_window()
Gtk.main()
-
=== modified file 'softwarecenter/ui/gtk3/panes/basepane.py'
--- softwarecenter/ui/gtk3/panes/basepane.py 2011-08-18 17:42:33 +0000
+++ softwarecenter/ui/gtk3/panes/basepane.py 2012-03-15 01:02:25 +0000
@@ -18,8 +18,8 @@
class BasePane(object):
- """ Base for all the View widgets that can be registered in a
- ViewManager
+ """ Base for all the View widgets that can be registered in a
+ ViewManager
"""
def __init__(self):
@@ -31,16 +31,16 @@
def is_category_view_showing(self):
return False
-
+
def is_applist_view_showing(self):
return False
-
+
def is_app_details_view_showing(self):
return False
def get_current_app(self):
- return None
-
+ pass
+
def init_view(self):
"""
A callback that is made at the time the pane is selected in the
@@ -50,5 +50,3 @@
is to optimize startup time performance.
"""
pass
-
-
=== modified file 'softwarecenter/ui/gtk3/panes/globalpane.py'
--- softwarecenter/ui/gtk3/panes/globalpane.py 2012-02-16 11:23:52 +0000
+++ softwarecenter/ui/gtk3/panes/globalpane.py 2012-03-15 01:02:25 +0000
@@ -4,12 +4,12 @@
from softwarecenter.ui.gtk3.session.viewmanager import get_viewmanager
from softwarecenter.ui.gtk3.panes.viewswitcher import ViewSwitcher
+
def _widget_set_margins(widget, top=0, bottom=0, left=0, right=0):
widget.set_margin_top(top)
widget.set_margin_bottom(bottom)
widget.set_margin_left(left)
widget.set_margin_right(right)
- return
class GlobalPane(Gtk.Toolbar):
@@ -20,10 +20,12 @@
context.add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
# add nav history back/forward buttons...
- # note: this is hacky, would be much nicer to make the custom self/right
- # buttons in BackForwardButton to be Gtk.Activatable/Gtk.Widgets, then wire in the
- # actions using e.g. self.navhistory_back_action.connect_proxy(self.back_forward.left),
- # but couldn't seem to get this to work..so just wire things up directly
+ # note: this is hacky, would be much nicer to make the custom
+ # self/right buttons in BackForwardButton to be
+ # Gtk.Activatable/Gtk.Widgets, then wire in the actions using e.g.
+ # self.navhistory_back_action.connect_proxy(self.back_forward.left),
+ # but couldn't seem to get this to work..so just wire things up
+ # directly
vm = get_viewmanager()
self.back_forward = vm.get_global_backforward()
self.back_forward.set_vexpand(False)
@@ -31,14 +33,17 @@
if self.get_direction() != Gtk.TextDirection.RTL:
_widget_set_margins(self.back_forward,
- left=StockEms.MEDIUM, right=StockEms.MEDIUM+2)
+ left=StockEms.MEDIUM,
+ right=StockEms.MEDIUM + 2)
else:
_widget_set_margins(self.back_forward,
- right=StockEms.MEDIUM, left=StockEms.MEDIUM+2)
+ right=StockEms.MEDIUM,
+ left=StockEms.MEDIUM + 2)
self._insert_as_tool_item(self.back_forward, 0)
# this is what actually draws the All Software, Installed etc buttons
- self.view_switcher = ViewSwitcher(view_manager, datadir, db, cache, icons)
+ self.view_switcher = ViewSwitcher(view_manager, datadir, db, cache,
+ icons)
self._insert_as_tool_item(self.view_switcher, 1)
item = Gtk.ToolItem()
@@ -58,7 +63,6 @@
_widget_set_margins(self.searchentry, right=StockEms.MEDIUM)
else:
_widget_set_margins(self.searchentry, left=StockEms.MEDIUM)
- return
def _insert_as_tool_item(self, widget, pos):
item = Gtk.ToolItem()
@@ -84,7 +88,7 @@
p = GlobalPane(vm, datadir, db, cache, icons)
win = Gtk.Window()
- win.set_size_request(400,200)
+ win.set_size_request(400, 200)
win.set_data("pane", p)
win.connect("destroy", Gtk.main_quit)
win.add(p)
@@ -94,5 +98,5 @@
if __name__ == "__main__":
win = get_test_window()
-
+
Gtk.main()
=== modified file 'softwarecenter/ui/gtk3/panes/historypane.py'
--- softwarecenter/ui/gtk3/panes/historypane.py 2012-03-01 11:32:37 +0000
+++ softwarecenter/ui/gtk3/panes/historypane.py 2012-03-15 01:02:25 +0000
@@ -31,16 +31,17 @@
from softwarecenter.ui.gtk3.session.viewmanager import get_viewmanager
from softwarepane import DisplayState
+
class HistoryPane(Gtk.VBox, BasePane):
__gsignals__ = {
- "app-list-changed" : (GObject.SignalFlags.RUN_LAST,
- None,
- (int, ),
- ),
- "history-pane-created" : (GObject.SignalFlags.RUN_FIRST,
- None,
- ()),
+ "app-list-changed": (GObject.SignalFlags.RUN_LAST,
+ None,
+ (int, ),
+ ),
+ "history-pane-created": (GObject.SignalFlags.RUN_FIRST,
+ None,
+ ()),
}
(COL_WHEN, COL_ACTION, COL_PKG) = range(3)
@@ -50,7 +51,7 @@
ICON_SIZE = 32
PADDING = 6
-
+
# pages for the spinner notebook
(PAGE_HISTORY_VIEW,
PAGE_SPINNER) = range(2)
@@ -84,12 +85,14 @@
self.toolbar.set_style(Gtk.ToolbarStyle.TEXT)
self.pack_start(self.toolbar, False, True, 0)
- all_action = Gtk.RadioAction('filter_all', _('All Changes'), None, None, self.ALL)
+ all_action = Gtk.RadioAction('filter_all', _('All Changes'), None,
+ None, self.ALL)
all_action.connect('changed', self.change_filter)
all_button = all_action.create_tool_item()
self.toolbar.insert(all_button, 0)
- installs_action = Gtk.RadioAction('filter_installs', _('Installations'), None, None, self.INSTALLED)
+ installs_action = Gtk.RadioAction('filter_installs',
+ _('Installations'), None, None, self.INSTALLED)
installs_action.join_group(all_action)
installs_button = installs_action.create_tool_item()
self.toolbar.insert(installs_button, 1)
@@ -118,11 +121,11 @@
Gtk.PolicyType.AUTOMATIC)
self.history_view.show()
self.history_view.add(self.view)
-
+
# make a spinner to display while history is loading
self.spinner_notebook = SpinnerNotebook(
self.history_view, _('Loading history'))
-
+
self.pack_start(self.spinner_notebook, True, True, 0)
self.store = Gtk.TreeStore(*self.COL_TYPES)
@@ -132,7 +135,7 @@
self.view.set_model(self.store_filter)
all_action.set_active(True)
self.last = None
-
+
# to save (a lot of) time at startup we load history later, only when
# it is selected to be viewed
self.history = None
@@ -145,14 +148,14 @@
self.cell_text = Gtk.CellRendererText()
self.column.pack_start(self.cell_text, True)
self.column.set_cell_data_func(self.cell_text, self.render_cell_text)
-
+
# busy cursor
self.busy_cursor = Gdk.Cursor.new(Gdk.CursorType.WATCH)
def init_view(self):
if self.history == None:
- # if the history is not yet initialized we have to load and parse it
- # show a spinner while we do that
+ # if the history is not yet initialized we have to load and parse
+ # it show a spinner while we do that
self.realize()
window = self.get_window()
window.set_cursor(self.busy_cursor)
@@ -171,9 +174,8 @@
cr.set_source_rgba(color.red, color.green, color.blue, 0.5)
cr.set_line_width(1)
cr.move_to(0.5, a.height - 0.5)
- cr.rel_line_to(a.width-1, 0)
+ cr.rel_line_to(a.width - 1, 0)
cr.stroke()
- return
def _get_emblems(self, icons):
from softwarecenter.enums import USE_PACKAGEKIT_BACKEND
@@ -189,7 +191,6 @@
for i, emblem in enumerate(emblem_names):
pb = icons.load_icon(emblem, self.ICON_SIZE, 0)
self._emblems[i + 1] = pb
- return
def _set_actions_sensitive(self, sensitive):
for action in self._actions_list:
@@ -198,11 +199,12 @@
def _reset_icon_cache(self, theme=None):
self._app_icon_cache.clear()
try:
- missing = self.icons.load_icon(Icons.MISSING_APP, self.ICON_SIZE, 0)
+ missing = self.icons.load_icon(Icons.MISSING_APP, self.ICON_SIZE,
+ 0)
except GObject.GError:
missing = None
self._app_icon_cache[Icons.MISSING_APP] = missing
-
+
def load_and_parse_history(self):
from softwarecenter.db.history import get_pkg_history
self.history = get_pkg_history()
@@ -234,7 +236,7 @@
date = when.date()
day = self.store.append(None, (date, self.ALL, None))
last_row = None
- actions = {self.INSTALLED: trans.install,
+ actions = {self.INSTALLED: trans.install,
self.REMOVED: trans.remove,
self.UPGRADED: trans.upgrade,
}
@@ -247,11 +249,11 @@
def get_current_page(self):
# single page views can return None here
- return None
+ pass
def get_callback_for_page(self, page, state):
# single page views can return None here
- return None
+ pass
def on_search_terms_changed(self, entry, terms):
self.update_view()
@@ -277,20 +279,20 @@
# Compute the number of visible changes
# don't do this atm - the spec doesn't mention that the history pane
- # should have a status text and it gives us a noticable performance gain
- # if we don't calculate this
+ # should have a status text and it gives us a noticable performance
+ # gain if we don't calculate this
# self.visible_changes = 0
# day = self.store_filter.get_iter_first()
# while day is not None:
# self.visible_changes += self.store_filter.iter_n_children(day)
# day = self.store_filter.iter_next(day)
-
+
# Expand the most recent day
day = self.store.get_iter_first()
if day is not None:
- path = self.store.get_path(day)
- self.view.expand_row(path, False)
- self.view.scroll_to_cell(path)
+ path = self.store.get_path(day)
+ self.view.expand_row(path, False)
+ self.view.scroll_to_cell(path)
# self.emit('app-list-changed', self.visible_changes)
@@ -327,7 +329,6 @@
action = store.get_value(iter, self.COL_ACTION)
cell.set_property('pixbuf', self._emblems[action])
-
#~ icon_name = Icons.MISSING_APP
#~ for m in self.db.xapiandb.postlist("AP" + pkg):
#~ doc = self.db.xapiandb.get_document(m.docid)
@@ -339,11 +340,11 @@
#~ icon = self._app_icon_cache[icon_name]
#~ else:
#~ try:
- #~ icon = self.icons.load_icon(icon_name, self.ICON_SIZE, 0)
+ #~ icon = self.icons.load_icon(icon_name, self.ICON_SIZE,
+ #~ 0)
#~ except GObject.GError:
#~ icon = self._app_icon_cache[Icons.MISSING_APP]
#~ self._app_icon_cache[icon_name] = icon
-
def render_cell_text(self, column, cell, store, iter, user_data):
when = store.get_value(iter, self.COL_WHEN)
@@ -352,15 +353,20 @@
pkg = store.get_value(iter, self.COL_PKG)
subs = {'pkgname': pkg,
'color': '#8A8A8A',
- # Translators : time displayed in history, display hours (0-12), minutes and AM/PM. %H should be used instead of %I to display hours 0-24
+ # Translators : time displayed in history, display hours
+ # (0-12), minutes and AM/PM. %H should be used instead
+ # of %I to display hours 0-24
'time': when.time().strftime(_('%I:%M %p')),
}
if action == self.INSTALLED:
- text = _('%(pkgname)s installed %(time)s') % subs
+ text = _('%(pkgname)s '
+ 'installed %(time)s') % subs
elif action == self.REMOVED:
- text = _('%(pkgname)s removed %(time)s') % subs
+ text = _('%(pkgname)s '
+ 'removed %(time)s') % subs
elif action == self.UPGRADED:
- text = _('%(pkgname)s updated %(time)s') % subs
+ text = _('%(pkgname)s '
+ 'updated %(time)s') % subs
elif isinstance(when, datetime.date):
today = datetime.date.today()
monday = today - datetime.timedelta(days=today.weekday())
@@ -388,7 +394,7 @@
)
# needed because available pane will try to get it
vm = get_test_gtk3_viewmanager()
- vm # make pyflakes happy
+ vm # make pyflakes happy
db = get_test_db()
cache = get_test_pkg_info()
icons = get_test_gtk3_icon_cache()
@@ -409,4 +415,3 @@
if __name__ == '__main__':
win = get_test_window()
Gtk.main()
-
=== modified file 'softwarecenter/ui/gtk3/panes/installedpane.py'
--- softwarecenter/ui/gtk3/panes/installedpane.py 2012-03-08 14:08:27 +0000
+++ softwarecenter/ui/gtk3/panes/installedpane.py 2012-03-15 01:02:25 +0000
@@ -45,7 +45,8 @@
from softwarecenter.db.appfilter import AppFilter
from softwarecenter.paths import APP_INSTALL_PATH
-LOG=logging.getLogger(__name__)
+LOG = logging.getLogger(__name__)
+
def interrupt_build_and_wait(f):
""" decorator that ensures that a build of the categorised installed apps
@@ -79,19 +80,20 @@
DETAILS) = range(2)
# the default page
HOME = LIST
-
+
# pages for the installed view spinner notebook
(PAGE_SPINNER,
PAGE_INSTALLED) = range(2)
- __gsignals__ = {'installed-pane-created':(GObject.SignalFlags.RUN_FIRST,
- None,
- ())}
+ __gsignals__ = {'installed-pane-created': (GObject.SignalFlags.RUN_FIRST,
+ None,
+ ())}
def __init__(self, cache, db, distro, icons, datadir):
# parent
- SoftwarePane.__init__(self, cache, db, distro, icons, datadir, show_ratings=False)
+ SoftwarePane.__init__(self, cache, db, distro, icons, datadir,
+ show_ratings=False)
CategoriesParser.__init__(self, db)
self.current_appview_selection = None
@@ -111,36 +113,42 @@
self._halt_build = False
self.nonapps_visible = NonAppVisibility.NEVER_VISIBLE
-
+
self.visible_docids = None
self.visible_cats = {}
-
+
self.installed_spinner_notebook = None
def init_view(self):
- if self.view_initialized:
+ if self.view_initialized:
return
SoftwarePane.init_view(self)
-
- # show a busy cursor and display the main spinner while we build the view
+
+ # show a busy cursor and display the main spinner while we build the
+ # view
window = self.get_window()
if window:
window.set_cursor(self.busy_cursor)
self.show_appview_spinner()
-
+
self.oneconf_viewpickler = OneConfViews(self.icons)
- self.oneconf_viewpickler.register_computer(None, _("This computer (%s)") % platform.node())
+ self.oneconf_viewpickler.register_computer(None,
+ _("This computer (%s)") % platform.node())
self.oneconf_viewpickler.select_first()
- self.oneconf_viewpickler.connect('computer-changed', self._selected_computer_changed)
- self.oneconf_viewpickler.connect('current-inventory-refreshed', self._current_inventory_need_refresh)
-
+ self.oneconf_viewpickler.connect('computer-changed',
+ self._selected_computer_changed)
+ self.oneconf_viewpickler.connect('current-inventory-refreshed',
+ self._current_inventory_need_refresh)
+
# Start OneConf
self.oneconf_handler = get_oneconf_handler(self.oneconf_viewpickler)
if self.oneconf_handler:
- self.oneconf_handler.connect('show-oneconf-changed', self._show_oneconf_changed)
- self.oneconf_handler.connect('last-time-sync-changed', self._last_time_sync_oneconf_changed)
-
+ self.oneconf_handler.connect('show-oneconf-changed',
+ self._show_oneconf_changed)
+ self.oneconf_handler.connect('last-time-sync-changed',
+ self._last_time_sync_oneconf_changed)
+
# OneConf pane
self.computerpane = Gtk.Paned.new(Gtk.Orientation.HORIZONTAL)
self.oneconfcontrol = Gtk.Box()
@@ -154,14 +162,18 @@
scroll.set_shadow_type(Gtk.ShadowType.IN)
scroll.add(self.oneconf_viewpickler)
self.oneconfcontrol.pack_start(scroll, True, True, 0)
-
+
oneconftoolbar = Gtk.Box()
oneconftoolbar.set_orientation(Gtk.Orientation.HORIZONTAL)
oneconfpropertymenu = Gtk.Menu()
- self.oneconfproperty = MenuButton(oneconfpropertymenu, Gtk.Image.new_from_stock(Gtk.STOCK_PROPERTIES, Gtk.IconSize.BUTTON))
+ self.oneconfproperty = MenuButton(oneconfpropertymenu,
+ Gtk.Image.new_from_stock(Gtk.STOCK_PROPERTIES,
+ Gtk.IconSize.BUTTON))
self.stopsync_label = _(u"Stop Syncing “%s”")
- stop_oneconf_share_menuitem = Gtk.MenuItem(label=self.stopsync_label % platform.node())
- stop_oneconf_share_menuitem.connect("activate", self._on_stop_oneconf_hostshare_clicked)
+ stop_oneconf_share_menuitem = Gtk.MenuItem(
+ label=self.stopsync_label % platform.node())
+ stop_oneconf_share_menuitem.connect("activate",
+ self._on_stop_oneconf_hostshare_clicked)
stop_oneconf_share_menuitem.show()
oneconfpropertymenu.append(stop_oneconf_share_menuitem)
self.oneconfcontrol.pack_start(oneconftoolbar, False, False, 1)
@@ -173,7 +185,8 @@
self.notebook.append_page(self.box_app_list, Gtk.Label(label="list"))
# details
- self.notebook.append_page(self.scroll_details, Gtk.Label(label="details"))
+ self.notebook.append_page(self.scroll_details,
+ Gtk.Label(label="details"))
# initial refresh
self.state.search_term = ""
@@ -184,25 +197,26 @@
self.treefilter.set_visible_func(self._row_visibility_func,
AppTreeStore.COL_ROW_DATA)
self.app_view.set_model(self.treefilter)
- self.app_view.tree_view.connect("row-collapsed", self._on_row_collapsed)
+ self.app_view.tree_view.connect("row-collapsed",
+ self._on_row_collapsed)
self._all_cats = self.parse_applications_menu(APP_INSTALL_PATH)
self._all_cats = categories_sorted_by_name(self._all_cats)
-
+
# we do not support the search aid feature in the installedview
self.box_app_list.remove(self.search_aid)
# remove here
- self.box_app_list.remove(self.app_view)
+ self.box_app_list.remove(self.app_view)
# create a local spinner notebook for the installed view
self.installed_spinner_notebook = SpinnerNotebook(self.app_view)
-
+
self.computerpane.pack2(self.installed_spinner_notebook, True, True)
self.show_installed_view_spinner()
-
+
self.show_all()
-
+
# initialize view to hide the oneconf computer selector
self.oneconf_viewpickler.select_first()
self.oneconfcontrol.hide()
@@ -214,15 +228,15 @@
# now we are initialized
self.emit("installed-pane-created")
-
+
self.view_initialized = True
return False
-
+
def show_installed_view_spinner(self):
""" display the local spinner for the installed view panel """
if self.installed_spinner_notebook:
self.installed_spinner_notebook.show_spinner()
-
+
def hide_installed_view_spinner(self):
""" hide the local spinner for the installed view panel """
if self.installed_spinner_notebook:
@@ -236,15 +250,17 @@
self.current_hostname = hostname
menuitem = self.oneconfproperty.get_menu().get_children()[0]
if self.current_hostid:
- (self.oneconf_additional_pkg, self.oneconf_missing_pkg) = self.oneconf_handler.oneconf.diff(self.current_hostid, '')
+ diff = self.oneconf_handler.oneconf.diff(self.current_hostid, '')
+ self.oneconf_additional_pkg, self.oneconf_missing_pkg = diff
stopsync_hostname = self.current_hostname
# FIXME for P: oneconf views don't support search
- if self.state.search_term:
+ if self.state.search_term:
self._search()
else:
stopsync_hostname = platform.node()
self.searchentry.show()
- menuitem.set_label(self.stopsync_label % stopsync_hostname.encode('utf-8'))
+ menuitem.set_label(self.stopsync_label %
+ stopsync_hostname.encode('utf-8'))
self.refresh_apps()
def _last_time_sync_oneconf_changed(self, oneconf_handler, msg):
@@ -266,14 +282,15 @@
if self.current_hostid:
self.oneconf_viewpickler.remove_computer(self.current_hostid)
self.oneconf_viewpickler.select_first()
-
+
def _current_inventory_need_refresh(self, oneconfviews):
if self.current_hostid:
- (self.oneconf_additional_pkg, self.oneconf_missing_pkg) = self.oneconf_handler.oneconf.diff(self.current_hostid, '')
+ diff = self.oneconf_handler.oneconf.diff(self.current_hostid, '')
+ self.oneconf_additional_pkg, self.oneconf_missing_pkg = diff
self.refresh_apps()
def _on_row_collapsed(self, view, it, path):
- return
+ pass
def _row_visibility_func(self, model, it, col):
row = model.get_value(it, col)
@@ -285,16 +302,18 @@
elif isinstance(row, CategoryRowReference):
return row.untranslated_name in self.visible_cats.keys()
- elif row is None: return False
+ elif row is None:
+ return False
return row.get_docid() in self.visible_docids
def _use_category(self, cat):
# System cat is large and slow to search, filter it in default mode
- if ('carousel-only' in cat.flags or
+ if ('carousel-only' in cat.flags or
((self.nonapps_visible == NonAppVisibility.NEVER_VISIBLE)
- and cat.untranslated_name == 'System')): return False
+ and cat.untranslated_name == 'System')):
+ return False
return True
@@ -306,14 +325,14 @@
#~ @interrupt_build_and_wait
def _build_categorised_installedview(self):
LOG.debug('Rebuilding categorised installedview...')
-
+
# display the busy cursor and a local spinner while we build the view
window = self.get_window()
if window:
window.set_cursor(self.busy_cursor)
self.show_installed_view_spinner()
-
- model = self.base_model # base model not treefilter
+
+ model = self.base_model # base model not treefilter
model.clear()
def profiled_rebuild_categorised_view():
@@ -323,28 +342,30 @@
def rebuild_categorised_view():
self.cat_docid_map = {}
enq = self.enquirer
-
+
i = 0
-
+
while Gtk.events_pending():
Gtk.main_iteration()
xfilter = AppFilter(self.db, self.cache)
xfilter.set_installed_only(True)
-
+
for cat in self._all_cats:
# for each category do category query and append as a new
# node to tree_view
- if not self._use_category(cat): continue
+ if not self._use_category(cat):
+ continue
query = self.get_query_for_cat(cat)
- LOG.debug("xfilter.installed_only: %s" % xfilter.installed_only)
+ LOG.debug("xfilter.installed_only: %s" %
+ xfilter.installed_only)
enq.set_query(query,
sortmode=SortMethods.BY_ALPHABET,
nonapps_visible=self.nonapps_visible,
filter=xfilter,
nonblocking_load=False,
- persistent_duplicate_filter=(i>0))
-
+ persistent_duplicate_filter=(i > 0))
+
L = len(enq.matches)
if L:
i += L
@@ -352,13 +373,13 @@
self.cat_docid_map[cat.untranslated_name] = \
set([doc.get_docid() for doc in docs])
model.set_category_documents(cat, docs)
-
+
while Gtk.events_pending():
Gtk.main_iteration()
# check for uncategorised pkgs
if self.state.channel:
- self._run_channel_enquirer(persistent_duplicate_filter=(i>0))
+ self._run_channel_enquirer(persistent_duplicate_filter=(i > 0))
L = len(enq.matches)
if L:
# some foo for channels
@@ -369,7 +390,8 @@
channel_name = self.state.channel.display_name
docs = enq.get_documents()
tag = channel_name or 'Uncategorized'
- self.cat_docid_map[tag] = set([doc.get_docid() for doc in docs])
+ self.cat_docid_map[tag] = set(
+ [doc.get_docid() for doc in docs])
model.set_nocategory_documents(docs, untranslated_name=tag,
display_name=channel_name)
i += L
@@ -382,14 +404,15 @@
# cache the installed app count
self.installed_count = i
- self.app_view._append_appcount(self.installed_count, mode=AppView.INSTALLED_MODE)
-
+ self.app_view._append_appcount(self.installed_count,
+ mode=AppView.INSTALLED_MODE)
+
# hide the local spinner
self.hide_installed_view_spinner()
-
+
if window:
window.set_cursor(None)
-
+
# reapply search if needed
if self.state.search_term:
self._do_search(self.state.search_term)
@@ -398,18 +421,17 @@
return
GObject.idle_add(profiled_rebuild_categorised_view)
- return
-
+
def _build_oneconfview(self):
LOG.debug('Rebuilding oneconfview for %s...' % self.current_hostid)
-
+
# display the busy cursor and the local spinner while we build the view
window = self.get_window()
if window:
window.set_cursor(self.busy_cursor)
self.show_installed_view_spinner()
-
- model = self.base_model # base model not treefilter
+
+ model = self.base_model # base model not treefilter
model.clear()
def profiled_rebuild_oneconfview():
@@ -417,10 +439,10 @@
rebuild_oneconfview()
def rebuild_oneconfview():
-
+
# FIXME for P: hide the search entry
self.searchentry.hide()
-
+
self.cat_docid_map = {}
enq = self.enquirer
query = xapian.Query("")
@@ -430,30 +452,33 @@
self.state.channel.query)
i = 0
-
+
# First search: missing apps only
xfilter = AppFilter(self.db, self.cache)
xfilter.set_restricted_list(self.oneconf_additional_pkg)
xfilter.set_not_installed_only(True)
-
+
enq.set_query(query,
sortmode=SortMethods.BY_ALPHABET,
nonapps_visible=self.nonapps_visible,
filter=xfilter,
- nonblocking_load=True, # we don't block this one for better oneconf responsiveness
- persistent_duplicate_filter=(i>0))
+ nonblocking_load=True, # we don't block this one for
+ # better oneconf responsiveness
+ persistent_duplicate_filter=(i > 0))
L = len(enq.matches)
if L:
- cat_title = utf8(ngettext(u'%(amount)s item on “%(machine)s” not on this computer',
- u'%(amount)s items on “%(machine)s” not on this computer',
- L)) % { 'amount' : L, 'machine': utf8(self.current_hostname)}
+ cat_title = utf8(ngettext(
+ u'%(amount)s item on “%(machine)s” not on this computer',
+ u'%(amount)s items on “%(machine)s” not on this computer',
+ L)) % {'amount': L, 'machine': utf8(self.current_hostname)}
i += L
docs = enq.get_documents()
- self.cat_docid_map["missingpkg"] = set([doc.get_docid() for doc in docs])
- model.set_nocategory_documents(docs, untranslated_name="additionalpkg",
- display_name=cat_title)
+ self.cat_docid_map["missingpkg"] = set(
+ [doc.get_docid() for doc in docs])
+ model.set_nocategory_documents(docs,
+ untranslated_name="additionalpkg", display_name=cat_title)
# Second search: additional apps
xfilter.set_restricted_list(self.oneconf_missing_pkg)
@@ -464,18 +489,20 @@
nonapps_visible=self.nonapps_visible,
filter=xfilter,
nonblocking_load=False,
- persistent_duplicate_filter=(i>0))
+ persistent_duplicate_filter=(i > 0))
L = len(enq.matches)
if L:
- cat_title = utf8(ngettext(u'%(amount)s item on this computer not on “%(machine)s”',
- '%(amount)s items on this computer not on “%(machine)s”',
- L)) % { 'amount' : L, 'machine': utf8(self.current_hostname)}
+ cat_title = utf8(ngettext(
+ u'%(amount)s item on this computer not on “%(machine)s”',
+ '%(amount)s items on this computer not on “%(machine)s”',
+ L)) % {'amount': L, 'machine': utf8(self.current_hostname)}
i += L
docs = enq.get_documents()
- self.cat_docid_map["additionalpkg"] = set([doc.get_docid() for doc in docs])
- model.set_nocategory_documents(docs, untranslated_name="additionalpkg",
- display_name=cat_title)
+ self.cat_docid_map["additionalpkg"] = set(
+ [doc.get_docid() for doc in docs])
+ model.set_nocategory_documents(docs,
+ untranslated_name="additionalpkg", display_name=cat_title)
if i:
self.app_view.tree_view.set_cursor(Gtk.TreePath(),
@@ -485,31 +512,30 @@
# cache the installed app count
self.installed_count = i
- self.app_view._append_appcount(self.installed_count, mode=AppView.DIFF_MODE)
-
+ self.app_view._append_appcount(self.installed_count,
+ mode=AppView.DIFF_MODE)
+
# hide the local spinner
self.hide_installed_view_spinner()
-
+
if window:
window.set_cursor(None)
-
+
self.emit("app-list-changed", i)
return
GObject.idle_add(profiled_rebuild_oneconfview)
- return
def _check_expand(self):
it = self.treefilter.get_iter_first()
while it:
path = self.treefilter.get_path(it)
- if self.state.search_term:# or path in self._user_expanded_paths:
+ if self.state.search_term: # or path in self._user_expanded_paths:
self.app_view.tree_view.expand_row(path, False)
else:
self.app_view.tree_view.collapse_row(path)
it = self.treefilter.iter_next(it)
- return
def _do_search(self, terms):
self.state.search_term = terms
@@ -519,7 +545,7 @@
nonapps_visible=self.nonapps_visible,
filter=xfilter,
nonblocking_load=True)
-
+
self.visible_docids = self.enquirer.get_docids()
self.visible_cats = self._get_vis_cats(self.visible_docids)
self.treefilter.refilter()
@@ -551,7 +577,6 @@
self.emit("app-list-changed", 0)
elif self.state.search_term != terms:
self._do_search(terms)
- return
def get_query(self):
# search terms
@@ -575,7 +600,6 @@
self._build_oneconfview()
else:
self._build_categorised_installedview()
- return
def _clear_search(self):
# remove the details and clear the search
@@ -589,7 +613,6 @@
self.state.search_term = terms
self.notebook.set_current_page(InstalledPane.Pages.LIST)
self.hide_installed_view_spinner()
- return
def _get_vis_cats(self, visids):
vis_cats = {}
@@ -626,7 +649,7 @@
def display_overview_page(self, page, view_state):
LOG.debug("view_state: %s" % view_state)
if self.current_hostid:
- # FIXME for P: oneconf views don't support search
+ # FIXME for P: oneconf views don't support search
# this one ensure that even when switching between pane, we
# don't have the search item
if self.state.search_term:
@@ -643,16 +666,16 @@
"""return the current active application object applicable
to the context"""
return self.current_appview_selection
-
+
def is_category_view_showing(self):
# there is no category view in the installed pane
return False
-
+
def is_applist_view_showing(self):
"""Return True if we are in the applist view """
return (self.notebook.get_current_page() ==
InstalledPane.Pages.LIST)
-
+
def is_app_details_view_showing(self):
"""Return True if we are in the app_details view """
return self.notebook.get_current_page() == InstalledPane.Pages.DETAILS
@@ -667,7 +690,7 @@
)
# needed because available pane will try to get it
vm = get_test_gtk3_viewmanager()
- vm # make pyflakes happy
+ vm # make pyflakes happy
db = get_test_db()
cache = get_test_pkg_info()
datadir = get_test_datadir()
@@ -696,4 +719,3 @@
if __name__ == "__main__":
win = get_test_window()
Gtk.main()
-
=== modified file 'test/test_pep8.py'
--- test/test_pep8.py 2012-03-15 01:02:25 +0000
+++ test/test_pep8.py 2012-03-15 01:02:25 +0000
@@ -22,8 +22,7 @@
softwarecenter.ui.gtk3.views,
softwarecenter.ui.gtk3.widgets,
softwarecenter.db.pkginfo_impl]
- exclude = ['availablepane.py', 'basepane.py', 'globalpane.py',
- 'historypane.py', 'installedpane.py']
+ exclude = []
def message(self, text):
self.errors.append(text)