Added option of what addons to check (new, updated, or both)

svn: r15727
This commit is contained in:
Doug Blank 2010-08-13 21:44:21 +00:00
parent f3c614add6
commit 3551fe851a
3 changed files with 51 additions and 13 deletions

View File

@ -128,6 +128,7 @@ register('behavior.autoload', False)
register('behavior.avg-generation-gap', 20)
register('behavior.betawarn', False)
register('behavior.check-for-updates', 0)
register('behavior.check-for-update-types', ["update"])
register('behavior.last-check-for-updates', "1970/01/01")
register('behavior.database-path', os.path.join( const.HOME_DIR, 'grampsdb'))
register('behavior.date-about-range', 50)

View File

@ -970,8 +970,18 @@ class GrampsPreferences(ConfigureDialog):
self.old_format = the_list.get_value(the_iter, COL_FMT)
win = DisplayNameEditor(self.uistate, self.dbstate, self.track, self)
def check_for_type_changed(self, obj):
active = obj.get_active()
if active == 0: # update
config.set('behavior.check-for-update-types', ["update"])
elif active == 1: # update
config.set('behavior.check-for-update-types', ["new"])
elif active == 2: # update
config.set('behavior.check-for-update-types', ["update", "new"])
def check_for_updates_changed(self, obj):
config.set('behavior.check-for-updates', obj.get_active())
active = obj.get_active()
config.set('behavior.check-for-updates', active)
def date_format_changed(self, obj):
config.set('preferences.date-format', obj.get_active())
@ -1057,6 +1067,28 @@ class GrampsPreferences(ConfigureDialog):
table.attach(lwidget, 1, 2, 6, 7, yoptions=0)
table.attach(obox, 2, 4, 6, 7, yoptions=0)
self.whattype_box = gtk.combo_box_new_text()
formats = [_("Updated addons only"),
_("New addons only"),
_("New and updated addons"),]
map(self.whattype_box.append_text, formats)
whattype = config.get('behavior.check-for-update-types')
if "new" in whattype and "update" in whattype:
self.whattype_box.set_active(2)
elif "new" in whattype:
self.whattype_box.set_active(1)
elif "update" in whattype:
self.whattype_box.set_active(0)
self.whattype_box.connect('changed', self.check_for_type_changed)
lwidget = BasicLabel("%s: " % _('What to check'))
table.attach(lwidget, 1, 2, 7, 8, yoptions=0)
table.attach(self.whattype_box, 2, 3, 7, 8, yoptions=0)
button = gtk.Button(_("Check now"))
button.connect("clicked", lambda obj: \
self.uistate.viewmanager.check_for_updates(force=True))
table.attach(button, 3, 4, 7, 8, yoptions=0)
return _('General'), table
def add_database_panel(self, configdialog):

View File

@ -275,12 +275,15 @@ class ViewManager(CLIManager):
# Need to call after plugins have been registered
self.check_for_updates()
def check_for_updates(self):
def check_for_updates(self, force=False):
"""
"""
howoften = config.get("behavior.check-for-updates")
whattypes = config.get('behavior.check-for-update-types')
update = False
if howoften != 0: # update never if zero
if force:
update = True
elif howoften != 0: # update never if zero
y,m,d = map(int,
config.get("behavior.last-check-for-updates").split("/"))
days = (datetime.date.today() - datetime.date(y, m, d)).days
@ -333,20 +336,22 @@ class ViewManager(CLIManager):
if (version_str_to_tup(plugin_dict["v"], 3) >
version_str_to_tup(plugin.version, 3)):
LOG.debug(" Downloading '%s'..." % plugin_dict["z"])
addon_update_list.append(("update",
"%s/download/%s" %
(ADDONS_URL,
plugin_dict["z"]),
plugin_dict))
if "update" in whattypes:
addon_update_list.append(("update",
"%s/download/%s" %
(ADDONS_URL,
plugin_dict["z"]),
plugin_dict))
else:
LOG.debug(" '%s' is ok" % plugin_dict["n"])
else:
LOG.debug(" '%s' is not installed" % plugin_dict["n"])
#addon_update_list.append(("new",
# "%s/download/%s" %
# (ADDONS_URL,
# plugin_dict["z"]),
# plugin_dict))
if "new" in whattypes:
addon_update_list.append(("new",
"%s/download/%s" %
(ADDONS_URL,
plugin_dict["z"]),
plugin_dict))
config.set("behavior.last-check-for-updates",
datetime.date.today().strftime("%Y/%m/%d"))
if fp: