Addon Update now shows lists by categories (eg, New Gramplets)
svn: r16238
This commit is contained in:
parent
2b43bf1046
commit
bb83e894ea
@ -213,11 +213,26 @@ ADDONS_URL = "http://gramps-addons.svn.sourceforge.net/viewvc/gramps-addons/trun
|
|||||||
# Local Functions
|
# Local Functions
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def update_rows(model, path, iter):
|
def update_rows(model, path, iter, user_data):
|
||||||
"""
|
"""
|
||||||
Update the rows of a model.
|
Update the rows of a model.
|
||||||
"""
|
"""
|
||||||
model.row_changed(path, iter)
|
#path: (8,) iter: <GtkTreeIter at 0xbfa89fa0>
|
||||||
|
#path: (8, 0) iter: <GtkTreeIter at 0xbfa89f60>
|
||||||
|
if len(path) == 2:
|
||||||
|
row = model[path]
|
||||||
|
row[0] = user_data
|
||||||
|
model.row_changed(path, iter)
|
||||||
|
|
||||||
|
def get_count(addon_update_list, category):
|
||||||
|
"""
|
||||||
|
Get the count of matching category items.
|
||||||
|
"""
|
||||||
|
count = 0
|
||||||
|
for (status,plugin_url,plugin_dict) in addon_update_list:
|
||||||
|
if plugin_dict["t"] == category and plugin_url:
|
||||||
|
count += 1
|
||||||
|
return count
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -387,7 +402,7 @@ class ViewManager(CLIManager):
|
|||||||
from QuestionDialog import OkDialog
|
from QuestionDialog import OkDialog
|
||||||
OkDialog(_("There are no available addons of this type"),
|
OkDialog(_("There are no available addons of this type"),
|
||||||
_("Checked for '%s'") %
|
_("Checked for '%s'") %
|
||||||
_("' and '").join(config.get('behavior.check-for-update-types')),
|
_("' and '").join(config.get('behavior.check-for-update-types')),
|
||||||
self.window)
|
self.window)
|
||||||
|
|
||||||
def update_addons(self, addon_update_list):
|
def update_addons(self, addon_update_list):
|
||||||
@ -410,22 +425,44 @@ class ViewManager(CLIManager):
|
|||||||
lambda obj: self.update_dialog.destroy())
|
lambda obj: self.update_dialog.destroy())
|
||||||
self.list = ListModel(glade.get_object("list"), [
|
self.list = ListModel(glade.get_object("list"), [
|
||||||
# name, click?, width, toggle
|
# name, click?, width, toggle
|
||||||
(_('Select'), NOSORT, 60, TOGGLE, True), # 0 selected?
|
{"name": _('Select'),
|
||||||
(_('Type'), 1, 120), # 1 new gramplet
|
"sort_id": NOSORT,
|
||||||
|
"width": 60,
|
||||||
|
"type": TOGGLE,
|
||||||
|
"visible_col": 6,
|
||||||
|
"editable": True}, # 0 selected?
|
||||||
|
(_('Type'), 1, 180), # 1 new gramplet
|
||||||
(_('Name'), 1, 200), # 2 name (version)
|
(_('Name'), 1, 200), # 2 name (version)
|
||||||
(_('Description'), 1, 200), # 3 description
|
(_('Description'), 1, 200), # 3 description
|
||||||
('', 1, 0), # 4 url
|
('', 1, 0), # 4 url
|
||||||
('', 1, 0), # 5 id
|
('', 1, 0), # 5 id
|
||||||
])
|
{"name": '', "type": TOGGLE}, # 6 visible? bool
|
||||||
|
], list_mode="tree")
|
||||||
pos = None
|
pos = None
|
||||||
|
addon_update_list.sort(key=lambda x: "%s %s" % (_(x[0]), x[2]["t"]))
|
||||||
|
last_category = None
|
||||||
for (status,plugin_url,plugin_dict) in addon_update_list:
|
for (status,plugin_url,plugin_dict) in addon_update_list:
|
||||||
iter = self.list.add([True,
|
count = get_count(addon_update_list, plugin_dict["t"])
|
||||||
|
category = "%s %s" % (_(status), ngettext(plugin_dict["t"],
|
||||||
|
plugin_dict["t"] + "s",
|
||||||
|
count))
|
||||||
|
if last_category != category:
|
||||||
|
last_category = category
|
||||||
|
node = self.list.add([False, # initially selected?
|
||||||
|
category,
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
False]) # checkbox visible?
|
||||||
|
iter = self.list.add([False, # initially selected?
|
||||||
"%s %s" % (_(status), plugin_dict["t"]),
|
"%s %s" % (_(status), plugin_dict["t"]),
|
||||||
"%s (%s)" % (plugin_dict["n"],
|
"%s (%s)" % (plugin_dict["n"],
|
||||||
plugin_dict["v"]),
|
plugin_dict["v"]),
|
||||||
plugin_dict["d"],
|
plugin_dict["d"],
|
||||||
plugin_url, plugin_dict["i"],
|
plugin_url,
|
||||||
])
|
plugin_dict["i"],
|
||||||
|
True], node=node)
|
||||||
if pos is None:
|
if pos is None:
|
||||||
pos = iter
|
pos = iter
|
||||||
if pos:
|
if pos:
|
||||||
@ -436,17 +473,15 @@ class ViewManager(CLIManager):
|
|||||||
"""
|
"""
|
||||||
Select all of the addons for download.
|
Select all of the addons for download.
|
||||||
"""
|
"""
|
||||||
for row in self.list.model: # treemodelrow
|
self.list.model.foreach(update_rows, True)
|
||||||
row[0] = True
|
self.list.tree.expand_all()
|
||||||
self.list.model.foreach(update_rows)
|
|
||||||
|
|
||||||
def select_none_clicked(self, widget):
|
def select_none_clicked(self, widget):
|
||||||
"""
|
"""
|
||||||
Select none of the addons for download.
|
Select none of the addons for download.
|
||||||
"""
|
"""
|
||||||
for row in self.list.model: # treemodelrow
|
self.list.model.foreach(update_rows, False)
|
||||||
row[0] = False
|
self.list.tree.expand_all()
|
||||||
self.list.model.foreach(update_rows)
|
|
||||||
|
|
||||||
def install_addons(self, obj):
|
def install_addons(self, obj):
|
||||||
"""
|
"""
|
||||||
@ -455,9 +490,15 @@ class ViewManager(CLIManager):
|
|||||||
from QuestionDialog import OkDialog
|
from QuestionDialog import OkDialog
|
||||||
from gui.widgets.progressdialog import LongOpStatus
|
from gui.widgets.progressdialog import LongOpStatus
|
||||||
self.update_dialog.hide()
|
self.update_dialog.hide()
|
||||||
|
iter = self.list.model.get_iter_first()
|
||||||
|
length = 0
|
||||||
|
while iter:
|
||||||
|
iter = self.list.model.iter_next(iter)
|
||||||
|
if iter:
|
||||||
|
length += self.list.model.iter_n_children(iter)
|
||||||
longop = LongOpStatus(
|
longop = LongOpStatus(
|
||||||
_("Downloading and installing selected addons..."),
|
_("Downloading and installing selected addons..."),
|
||||||
len(self.list.model), 1, # total, increment-by
|
length, 1, # total, increment-by
|
||||||
can_cancel=True)
|
can_cancel=True)
|
||||||
pm = ProgressMonitor(GtkProgressDialog,
|
pm = ProgressMonitor(GtkProgressDialog,
|
||||||
("Title", self.window, gtk.DIALOG_MODAL))
|
("Title", self.window, gtk.DIALOG_MODAL))
|
||||||
@ -466,17 +507,27 @@ class ViewManager(CLIManager):
|
|||||||
if not config.get('behavior.do-not-show-previously-seen-updates'):
|
if not config.get('behavior.do-not-show-previously-seen-updates'):
|
||||||
# reset list
|
# reset list
|
||||||
config.get('behavior.previously-seen-updates')[:] = []
|
config.get('behavior.previously-seen-updates')[:] = []
|
||||||
for row in self.list.model: # treemodelrow
|
iter = self.list.model.get_iter_first()
|
||||||
if longop.should_cancel():
|
while iter:
|
||||||
break
|
for rowcnt in range(self.list.model.iter_n_children(iter)):
|
||||||
elif row[0]: # toggle on
|
child = self.list.model.iter_nth_child(iter, rowcnt)
|
||||||
load_addon_file(row[4], callback=LOG.debug)
|
row = [self.list.model.get_value(child, 0),
|
||||||
count += 1
|
self.list.model.get_value(child, 1),
|
||||||
else: # add to list of previously seen, but not installed
|
self.list.model.get_value(child, 2),
|
||||||
if row[5] not in config.get('behavior.previously-seen-updates'):
|
self.list.model.get_value(child, 3),
|
||||||
config.get('behavior.previously-seen-updates').append(row[5])
|
self.list.model.get_value(child, 4),
|
||||||
longop.heartbeat()
|
self.list.model.get_value(child, 5),]
|
||||||
pm._get_dlg()._process_events()
|
if longop.should_cancel():
|
||||||
|
break
|
||||||
|
elif row[0]: # toggle on
|
||||||
|
load_addon_file(row[4], callback=LOG.debug)
|
||||||
|
count += 1
|
||||||
|
else: # add to list of previously seen, but not installed
|
||||||
|
if row[5] not in config.get('behavior.previously-seen-updates'):
|
||||||
|
config.get('behavior.previously-seen-updates').append(row[5])
|
||||||
|
longop.heartbeat()
|
||||||
|
pm._get_dlg()._process_events()
|
||||||
|
iter = self.list.model.iter_next(iter)
|
||||||
if not longop.was_cancelled():
|
if not longop.was_cancelled():
|
||||||
longop.end()
|
longop.end()
|
||||||
if count:
|
if count:
|
||||||
|
Loading…
Reference in New Issue
Block a user