Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2009-08-03 17:23:52 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2009-08-03 17:23:52 (GMT)
commitc3ef4356f1d9178c185f6ca33a2767a985e754a1 (patch)
tree5fb4a733ee821c4584fee333a09b0a3b780a021d /extensions
parentb8ae254856d9884b3765361a82c300fd9117af0f (diff)
Change scope for class members
Diffstat (limited to 'extensions')
-rw-r--r--extensions/cpsection/updater/backends/aslo.py1
-rwxr-xr-xextensions/cpsection/updater/model.py24
-rw-r--r--extensions/cpsection/updater/view.py201
3 files changed, 114 insertions, 112 deletions
diff --git a/extensions/cpsection/updater/backends/aslo.py b/extensions/cpsection/updater/backends/aslo.py
index 69cd47c..dad0698 100644
--- a/extensions/cpsection/updater/backends/aslo.py
+++ b/extensions/cpsection/updater/backends/aslo.py
@@ -96,6 +96,7 @@ def parse_url(url):
The `urlopen_args` can be any keyword arguments accepted by
`bitfrost.util.urlrange.urlopen`."""
+ logging.debug('Update uri=%s' % url)
response = urllib2.urlopen(url)
return parse_aslo(response.read())
diff --git a/extensions/cpsection/updater/model.py b/extensions/cpsection/updater/model.py
index 97c0024..d5e2350 100755
--- a/extensions/cpsection/updater/model.py
+++ b/extensions/cpsection/updater/model.py
@@ -71,9 +71,9 @@ class UpdateList(gtk.ListStore):
self._cancel = False
self._is_valid = True
- self.registry = bundleregistry.get_registry()
- self.steps_count = 0
- self.steps_total = 0
+ self._registry = bundleregistry.get_registry()
+ self._steps_count = 0
+ self._steps_total = 0
self._progress_cb = None
def refresh_list(self, progress_callback=lambda n, extra: None,
@@ -83,12 +83,12 @@ class UpdateList(gtk.ListStore):
self._progress_cb(None, _('Looking for local actvities...'))
self.clear()
- self.steps_total = len([i for i in self.registry])
- self.steps_count = 0
+ self._steps_total = len([i for i in self._registry])
+ self._steps_count = 0
row_map = {}
- for bundle in self.registry:
+ for bundle in self._registry:
self._make_progress(_('Checking %s...') % bundle.get_name())
if self._cancel:
@@ -100,13 +100,13 @@ class UpdateList(gtk.ListStore):
row[BUNDLE] = bundle
row[BUNDLE_ID] = bundle.get_bundle_id()
- if self.refresh_row(row):
+ if self._refresh_row(row):
row_map[row[BUNDLE_ID]] = self.get_path(self.append(row))
def cancel(self):
self._cancel = True
- def refresh_row(self, row):
+ def _refresh_row(self, row):
logging.debug('Looking for %s' % row[BUNDLE].get_name())
try:
@@ -141,8 +141,8 @@ class UpdateList(gtk.ListStore):
def install_updates(self, progress_cb=(lambda n, row: None)):
self._cancel = False
self._progress_cb = progress_cb
- self.steps_total = len([0 for row in self if row[UPDATE_SELECTED]]) * 2
- self.steps_count = 0
+ self._steps_total = len([0 for row in self if row[UPDATE_SELECTED]]) * 2
+ self._steps_count = 0
installed = 0
@@ -192,8 +192,8 @@ class UpdateList(gtk.ListStore):
def _make_progress(self, msg=None): #FIXME needs better name
"""Helper function to do progress update."""
- self.steps_count += 1
- self._progress_cb(float(self.steps_count)/self.steps_total, msg)
+ self._steps_count += 1
+ self._progress_cb(float(self._steps_count)/self._steps_total, msg)
def _sum_rows(self, row_func):
"""Sum the values returned by row_func called on all non-header
diff --git a/extensions/cpsection/updater/view.py b/extensions/cpsection/updater/view.py
index a62fd53..0b5062e 100644
--- a/extensions/cpsection/updater/view.py
+++ b/extensions/cpsection/updater/view.py
@@ -37,10 +37,10 @@ class ActivityUpdater(SectionView):
self.set_border_width(style.DEFAULT_SPACING * 2)
# top label #
- self.top_label = gtk.Label()
- self.top_label.set_line_wrap(True)
- self.top_label.set_justify(gtk.JUSTIFY_LEFT)
- self.top_label.set_property('xalign', 0)
+ self._top_label = gtk.Label()
+ self._top_label.set_line_wrap(True)
+ self._top_label.set_justify(gtk.JUSTIFY_LEFT)
+ self._top_label.set_property('xalign', 0)
# bottom label #
bottom_label = gtk.Label()
@@ -52,7 +52,7 @@ class ActivityUpdater(SectionView):
'vulnerabilities, and provide new features.'))
# main canvas #
- self.pack_start(self.top_label, expand=False)
+ self.pack_start(self._top_label, expand=False)
self.pack_start(gtk.HSeparator(), expand=False)
self.pack_start(bottom_label, expand=False)
@@ -71,7 +71,7 @@ class ActivityUpdater(SectionView):
# refresh #
def refresh_cb(self, widget, event):
- self.top_label.set_markup('<big>%s</big>' % \
+ self._top_label.set_markup('<big>%s</big>' % \
_('Checking for updates...'))
self.progress_pane.switch_to_check_progress()
self.bundle_list.freeze_notify()
@@ -82,7 +82,7 @@ class ActivityUpdater(SectionView):
gobject.idle_add(self._refresh_done_cb)
def _refresh_progress_cb(self, n, extra=None):
- gobject.idle_add(self._progress_cb, n, extra)
+ gobject.idle_add(self._progress, n, extra)
# refresh done #
def _refresh_done_cb(self):
@@ -97,12 +97,12 @@ class ActivityUpdater(SectionView):
"You can install %s updates", avail) \
% avail
self.bundle_pane.switch()
- self.top_label.set_markup('<big>%s</big>' % _e(header))
+ self._top_label.set_markup('<big>%s</big>' % _e(header))
self.bundle_pane.refresh_update_size()
def install_clicked_cb(self, widget, event, data=None):
"""Invoked when the 'ok' button is clicked."""
- self.top_label.set_markup('<big>%s</big>' %
+ self._top_label.set_markup('<big>%s</big>' %
_('Installing updates...'))
self.progress_pane.switch_to_download_progress()
self.bundle_list.freeze_notify()
@@ -110,18 +110,18 @@ class ActivityUpdater(SectionView):
def _do_install(self): #@inhibit_suspend
installed = self.bundle_list.install_updates(self._refresh_progress_cb)
- gobject.idle_add(self._install_done_cb, installed)
+ gobject.idle_add(self._install_done, installed)
- def _install_done_cb(self, installed):
+ def _install_done(self, installed):
self.bundle_list.thaw_notify()
header = ngettext("%s update was installed",
"%s updates were installed", installed) \
% installed
- self.top_label.set_markup('<big>%s</big>' % _e(header))
+ self._top_label.set_markup('<big>%s</big>' % _e(header))
self.progress_pane.update(0)
self.progress_pane.switch_to_complete_message()
- def _progress_cb(self, n, extra=None, icon=None):
+ def _progress(self, n, extra=None, icon=None):
"""Invoked in main thread during a refresh operation."""
self.progress_pane.update(n, extra, icon)
@@ -135,13 +135,13 @@ class BundlePane(gtk.VBox):
def __init__(self, update_activity):
gtk.VBox.__init__(self)
- self.updater_activity = update_activity
+ self._updater_activity = update_activity
self.set_spacing(style.DEFAULT_PADDING)
# activity list #
vpaned = gtk.VPaned()
- self.bundles = BundleListView(update_activity, self)
- vpaned.pack1(self.bundles, resize=True, shrink=False)
+ bundles = BundleListView(update_activity, self)
+ vpaned.pack1(bundles, resize=True, shrink=False)
self.pack_start(vpaned, expand=True)
# Install/refresh buttons #
@@ -149,37 +149,37 @@ class BundlePane(gtk.VBox):
button_box.set_spacing(style.DEFAULT_SPACING)
hbox = gtk.HBox()
hbox.pack_end(button_box, expand=False)
- self.size_label = gtk.Label()
- self.size_label.set_property('xalign', 0)
- self.size_label.set_justify(gtk.JUSTIFY_LEFT)
- hbox.pack_start(self.size_label, expand=True)
+ self._size_label = gtk.Label()
+ self._size_label.set_property('xalign', 0)
+ self._size_label.set_justify(gtk.JUSTIFY_LEFT)
+ hbox.pack_start(self._size_label, expand=True)
self.pack_end(hbox, expand=False)
- self.check_button = gtk.Button(stock=gtk.STOCK_REFRESH)
- self.check_button.connect('clicked', update_activity.refresh_cb, self)
- button_box.pack_start(self.check_button, expand=False)
+ check_button = gtk.Button(stock=gtk.STOCK_REFRESH)
+ check_button.connect('clicked', update_activity.refresh_cb, self)
+ button_box.pack_start(check_button, expand=False)
- self.install_button = _make_button(_("Install selected"),
+ self._install_button = _make_button(_("Install selected"),
name='emblem-downloads')
- self.install_button.connect('clicked',
+ self._install_button.connect('clicked',
update_activity.install_clicked_cb, self)
- button_box.pack_start(self.install_button, expand=False)
+ button_box.pack_start(self._install_button, expand=False)
def is_valid_cb(bundle_list, __):
- self.install_button.set_sensitive(bundle_list.is_valid())
+ self._install_button.set_sensitive(bundle_list.is_valid())
update_activity.bundle_list.connect('notify::is-valid', is_valid_cb)
def refresh_update_size(self):
"""Update the 'download size' label."""
- bundle_list = self.updater_activity.bundle_list
+ bundle_list = self._updater_activity.bundle_list
size = bundle_list.updates_size()
- self.size_label.set_markup(_('Download size: %s') %
+ self._size_label.set_markup(_('Download size: %s') %
model._humanize_size(size))
- self.install_button.set_sensitive(bundle_list.updates_selected()!=0)
+ self._install_button.set_sensitive(bundle_list.updates_selected()!=0)
def switch(self):
"""Make the bundle list visible and the progress pane invisible."""
for widget, v in [(self, True),
- (self.updater_activity.progress_pane, False)]:# ,
+ (self._updater_activity.progress_pane, False)]:# ,
#(self.activity_updater.expander, False)]:
widget.set_property('visible', v)
@@ -187,18 +187,18 @@ class BundleListView(gtk.ScrolledWindow):
"""List view at the top, showing activities, versions, and sizes."""
def __init__(self, update_activity, bundle_pane):
gtk.ScrolledWindow.__init__(self)
- self.update_activity = update_activity
- self.bundle_pane = bundle_pane
+ self._update_activity = update_activity
+ self._bundle_pane = bundle_pane
# create TreeView using a filtered treestore
- self.treeview = gtk.TreeView(self.update_activity.bundle_list)
+ self._treeview = gtk.TreeView(self._update_activity.bundle_list)
# toggle cell renderers #
crbool = gtk.CellRendererToggle()
crbool.set_property('activatable', True)
crbool.set_property('xpad', style.DEFAULT_PADDING)
crbool.set_property('indicator_size', style.zoom(26))
- crbool.connect('toggled', self.toggled_cb)
+ crbool.connect('toggled', self.__toggled_cb)
# icon cell renderers #
cricon = gtk.CellRendererPixbuf()
@@ -218,16 +218,16 @@ class BundleListView(gtk.ScrolledWindow):
return view_func
hide_func = view_func_maker('visible')
insens_func = view_func_maker('sensitive')
- self.column_install = gtk.TreeViewColumn('Install', crbool)
- self.column_install.add_attribute(crbool, 'active',
+ column_install = gtk.TreeViewColumn('Install', crbool)
+ column_install.add_attribute(crbool, 'active',
model.UPDATE_SELECTED)
- self.column_install.set_cell_data_func(crbool, hide_func)
- self.column = gtk.TreeViewColumn('Name')
- self.column.pack_start(cricon, expand=False)
- self.column.pack_start(crtext, expand=True)
- self.column.add_attribute(cricon, 'pixbuf', model.ICON)
- self.column.set_resizable(True)
- self.column.set_cell_data_func(cricon, hide_func)
+ column_install.set_cell_data_func(crbool, hide_func)
+ column = gtk.TreeViewColumn('Name')
+ column.pack_start(cricon, expand=False)
+ column.pack_start(crtext, expand=True)
+ column.add_attribute(cricon, 'pixbuf', model.ICON)
+ column.set_resizable(True)
+ column.set_cell_data_func(cricon, hide_func)
def markup_func(cell_layout, renderer, m, it):
s = '<b>%s</b>' % _e(m.get_value(it, model.NAME))
if m.get_value(it, model.IS_HEADER):
@@ -237,34 +237,35 @@ class BundleListView(gtk.ScrolledWindow):
s += '\n<small>%s</small>' % _e(desc)
renderer.set_property('markup', s)
insens_func(cell_layout, renderer, m, it)
- self.column.set_cell_data_func(crtext, markup_func)
+ column.set_cell_data_func(crtext, markup_func)
# add tvcolumn to treeview
- self.treeview.append_column(self.column_install)
- self.treeview.append_column(self.column)
+ self._treeview.append_column(column_install)
+ self._treeview.append_column(column)
- self.treeview.set_reorderable(False)
- self.treeview.set_enable_search(False)
- self.treeview.set_headers_visible(False)
- self.treeview.set_rules_hint(True)
- self.treeview.connect('button-press-event', self.show_context_menu)
+ self._treeview.set_reorderable(False)
+ self._treeview.set_enable_search(False)
+ self._treeview.set_headers_visible(False)
+ self._treeview.set_rules_hint(True)
+ self._treeview.connect('button-press-event',
+ self.__button_press_event_cb)
def is_valid_cb(activity_list, __):
- self.treeview.set_sensitive(
- self.update_activity.bundle_list.is_valid())
- self.update_activity.bundle_list.connect('notify::is-valid',
+ self._treeview.set_sensitive(
+ self._update_activity.bundle_list.is_valid())
+ self._update_activity.bundle_list.connect('notify::is-valid',
is_valid_cb)
- is_valid_cb(self.update_activity.bundle_list, None)
+ is_valid_cb(self._update_activity.bundle_list, None)
- self.add_with_viewport(self.treeview)
+ self.add_with_viewport(self._treeview)
self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
- def toggled_cb(self, crbool, path):
- row = self.treeview.props.model[path]
+ def __toggled_cb(self, crbool, path):
+ row = self._treeview.props.model[path]
row[model.UPDATE_SELECTED] = not row[model.UPDATE_SELECTED]
- self.bundle_pane.refresh_update_size()
+ self._bundle_pane.refresh_update_size()
- def show_context_menu(self, widget, event):
+ def __button_press_event_cb(self, widget, event):
"""
Show a context menu if a right click was performed on an update entry
"""
@@ -275,13 +276,13 @@ class BundleListView(gtk.ScrolledWindow):
item = gtk.MenuItem(_("_Uncheck All"))
item.connect("activate", self.__check_activate_cb, False)
- if self.update_activity.bundle_list.updates_available() == 0:
+ if self._update_activity.bundle_list.updates_available() == 0:
item.set_property("sensitive", False)
menu.add(item)
item = gtk.MenuItem(_("_Check All"))
item.connect("activate", self.__check_activate_cb, True)
- if self.update_activity.bundle_list.updates_available() == 0:
+ if self._update_activity.bundle_list.updates_available() == 0:
item.set_property("sensitive", False)
menu.add(item)
@@ -289,43 +290,43 @@ class BundleListView(gtk.ScrolledWindow):
menu.show_all()
def __check_activate_cb(self, sender, state):
- for i in self.update_activity.bundle_list:
+ for i in self._update_activity.bundle_list:
i[model.UPDATE_SELECTED] = state
- self.bundle_pane.refresh_update_size()
+ self._bundle_pane.refresh_update_size()
class ProgressPane(gtk.VBox):
"""Container which replaces the `ActivityPane` during refresh or
install."""
def __init__(self, update_activity):
- self.update_activity = update_activity
+ self._update_activity = update_activity
gtk.VBox.__init__(self)
self.set_spacing(style.DEFAULT_PADDING)
self.set_border_width(style.DEFAULT_SPACING * 2)
- self.progress = gtk.ProgressBar()
- self.label = gtk.Label()
- self.label.set_line_wrap(True)
- self.label.set_property('xalign', 0.5)
- self.label.modify_fg(gtk.STATE_NORMAL,
+ self._progress = gtk.ProgressBar()
+ self._label = gtk.Label()
+ self._label.set_line_wrap(True)
+ self._label.set_property('xalign', 0.5)
+ self._label.modify_fg(gtk.STATE_NORMAL,
style.COLOR_BUTTON_GREY.get_gdk_color())
- self.icon = gtk.Image()
- self.icon.set_property('height-request', style.STANDARD_ICON_SIZE)
+ self._icon = gtk.Image()
+ self._icon.set_property('height-request', style.STANDARD_ICON_SIZE)
# make an HBox to center the various buttons.
hbox = gtk.HBox()
- self.cancel_button = gtk.Button(stock=gtk.STOCK_CANCEL)
- self.refresh_button = gtk.Button(stock=gtk.STOCK_REFRESH)
- self.try_again_button = _make_button(_('Try again'),
+ self._cancel_button = gtk.Button(stock=gtk.STOCK_CANCEL)
+ self._refresh_button = gtk.Button(stock=gtk.STOCK_REFRESH)
+ self._try_again_button = _make_button(_('Try again'),
stock=gtk.STOCK_REFRESH)
- for widget, cb in [(self.cancel_button, update_activity.cancel_cb),
- (self.refresh_button, update_activity.refresh_cb),
- (self.try_again_button, update_activity.refresh_cb)]:
+ for widget, cb in [(self._cancel_button, update_activity.cancel_cb),
+ (self._refresh_button, update_activity.refresh_cb),
+ (self._try_again_button, update_activity.refresh_cb)]:
widget.connect('clicked', cb, update_activity)
hbox.pack_start(widget, expand=True, fill=False)
- self.pack_start(self.icon)
- self.pack_start(self.progress)
- self.pack_start(self.label)
+ self.pack_start(self._icon)
+ self.pack_start(self._progress)
+ self.pack_start(self._label)
self.pack_start(hbox)
def update(self, n, extra=None, icon=None):
@@ -334,45 +335,45 @@ class ProgressPane(gtk.VBox):
in `extra` or an icon in `icon`."""
if n is None:
- self.progress.pulse()
+ self._progress.pulse()
else:
- self.progress.set_fraction(n)
+ self._progress.set_fraction(n)
extra = _e(extra) if extra is not None else ''
- self.label.set_markup(extra)
- self.icon.set_property('visible', icon is not None)
+ self._label.set_markup(extra)
+ self._icon.set_property('visible', icon is not None)
if icon is not None:
- self.icon.set_from_pixbuf(icon)
+ self._icon.set_from_pixbuf(icon)
def switch_to_check_progress(self):
self._switch(show_cancel=True, show_bar=True)
- self.label.set_markup(_('Checking for updates...'))
+ self._label.set_markup(_('Checking for updates...'))
def switch_to_download_progress(self):
self._switch(show_cancel=True, show_bar=True)
- self.label.set_markup(_('Starting download...'))
+ self._label.set_markup(_('Starting download...'))
def switch_to_complete_message(self):
self._switch(show_cancel=False, show_bar=False)
- self.label.set_markup('')
+ self._label.set_markup('')
def cancelling(self):
- self.cancel_button.set_sensitive(False)
- self.label.set_markup(_('Cancelling...'))
+ self._cancel_button.set_sensitive(False)
+ self._label.set_markup(_('Cancelling...'))
def _switch(self, show_cancel, show_bar, show_try_again=False):
"""Make the progress pane visible and the activity pane invisible."""
- self.update_activity.bundle_pane.set_property('visible', False)
+ self._update_activity.bundle_pane.set_property('visible', False)
self.set_property('visible', True)
- for widget, v in [(self.progress, show_bar),
- (self.cancel_button, show_cancel),
- (self.refresh_button,
+ for widget, v in [(self._progress, show_bar),
+ (self._cancel_button, show_cancel),
+ (self._refresh_button,
not show_cancel and not show_try_again),
- (self.try_again_button, show_try_again),
- #(self.update_activity.expander, False)
+ (self._try_again_button, show_try_again),
+ #(self._update_activity.expander, False)
]:
widget.set_property('visible', v)
- self.cancel_button.set_sensitive(True)
- #self.update_activity.expander.set_expanded(False)
+ self._cancel_button.set_sensitive(True)
+ #self._update_activity.expander.set_expanded(False)
def _make_button(label_text, stock=None, name=None):
"""Convenience function to make labelled buttons with images."""