diff --git a/src/gen/plug/utils.py b/src/gen/plug/utils.py
index 87eeaa6dd..21419b3d0 100644
--- a/src/gen/plug/utils.py
+++ b/src/gen/plug/utils.py
@@ -187,7 +187,7 @@ class Zipfile(object):
"""
return os.path.split(name)[1]
-def load_addon_file(path, callback=None, register_plugin=None):
+def load_addon_file(path, callback=None):
"""
Load an addon from a particular path (from URL or file system).
"""
@@ -278,15 +278,8 @@ def load_addon_file(path, callback=None, register_plugin=None):
gpr_files = set([os.path.split(os.path.join(const.USER_PLUGINS, name))[0]
for name in good_gpr])
for gpr_file in gpr_files:
- # Convert gpr_file to unicode otherwise the callback will not
- # work with non ASCII characters in filenames in Windows.
- # But don't use converted filenames
- # in the call to self.__pmgr.reg_plugins
- # as that will break in reg_plugins.
u_gpr_file = unicode(gpr_file, sys.getfilesystemencoding())
if callback:
callback(" " + (_("Registered '%s'") % u_gpr_file) + "\n")
- if register_plugin:
- register_plugin(gpr_file)
file_obj.close()
diff --git a/src/glade/updateaddons.glade b/src/glade/updateaddons.glade
index 31b73797f..1093c081e 100644
--- a/src/glade/updateaddons.glade
+++ b/src/glade/updateaddons.glade
@@ -6,8 +6,8 @@
+
+ False
+ 1
+
+
+
+
+ True
+ True
+ automatic
+ automatic
-
+
True
True
- automatic
- automatic
-
-
- True
- True
-
-
-
- end
- 1
-
- 1
+ end
+ 2
@@ -99,7 +111,7 @@
start
- gtk-cancel
+ gtk-close
True
True
True
@@ -114,11 +126,11 @@
- gtk-apply
+ Install Selected _Addons
True
True
True
- True
+ True
False
diff --git a/src/gui/plug/_windows.py b/src/gui/plug/_windows.py
index 0add06253..6158ca09e 100644
--- a/src/gui/plug/_windows.py
+++ b/src/gui/plug/_windows.py
@@ -75,7 +75,8 @@ class PluginStatus(ManagedWindow.ManagedWindow):
AVAILABLE = '%s'\
% _('Visible')
- def __init__(self, uistate, track=[]):
+ def __init__(self, dbstate, uistate, track=[]):
+ self.dbstate = dbstate
self.__uistate = uistate
self.title = _("Plugin Manager")
ManagedWindow.ManagedWindow.__init__(self, uistate, track,
@@ -379,8 +380,8 @@ class PluginStatus(ManagedWindow.ManagedWindow):
pm.step()
(help_name, name, ptype, image, desc, use, rating, contact,
download, url) = row
- load_addon_file(url, callback=pm.append_message,
- register_plugin=self.__pmgr.reg_plugins)
+ load_addon_file(url, callback=pm.append_message)
+ self.uistate.viewmanager.do_reg_plugins(self.dbstate, self.uistate)
pm.message_area_ok.set_sensitive(True)
self.__rebuild_load_list()
self.__rebuild_reg_list()
@@ -402,7 +403,8 @@ class PluginStatus(ManagedWindow.ManagedWindow):
Get an addon from the wiki or file system and install it.
"""
path = self.install_addon_path.get_text()
- load_addon_file(path, callback, self.__pmgr.reg_plugins)
+ load_addon_file(path, callback)
+ self.uistate.viewmanager.do_reg_plugins(self.dbstate, self.uistate)
self.__rebuild_load_list()
self.__rebuild_reg_list()
diff --git a/src/gui/viewmanager.py b/src/gui/viewmanager.py
index 2e250f718..45f8f11b2 100644
--- a/src/gui/viewmanager.py
+++ b/src/gui/viewmanager.py
@@ -38,6 +38,7 @@ import os
import time
import datetime
from gen.ggettext import gettext as _
+from gen.ggettext import ngettext
from cStringIO import StringIO
from collections import defaultdict
@@ -327,7 +328,9 @@ class ViewManager(CLIManager):
break
addon_update_list = []
if fp and fp.getcode() == 200:
- for line in fp:
+ lines = list(fp.readlines())
+ count = 0
+ for line in lines:
try:
plugin_dict = safe_eval(line)
except:
@@ -356,11 +359,19 @@ class ViewManager(CLIManager):
plugin_dict))
config.set("behavior.last-check-for-updates",
datetime.date.today().strftime("%Y/%m/%d"))
+ count += 1
if fp:
fp.close()
LOG.debug("Done checking!")
if addon_update_list:
self.update_addons(addon_update_list)
+ elif force:
+ from QuestionDialog import OkDialog
+ OkDialog(_("There are no available addons of this type"),
+ _("Checked for '%s'") %
+ _("' and '").join(config.get('behavior.check-for-update-types')),
+ self.window)
+
def update_addons(self, addon_update_list):
from glade import Glade
@@ -423,9 +434,39 @@ class ViewManager(CLIManager):
"""
Process all of the selected addons.
"""
+ from QuestionDialog import OkDialog
+ from gui.widgets.progressdialog import LongOpStatus
+ self.update_dialog.hide()
+ longop = LongOpStatus(
+ _("Downloading and installing selected addons..."),
+ len(self.list.model), 1, # total, increment-by
+ can_cancel=True)
+ pm = ProgressMonitor(GtkProgressDialog,
+ ("Title", self.window, gtk.DIALOG_MODAL))
+ pm.add_op(longop)
+ count = 0
for row in self.list.model: # treemodelrow
- if row[0]: # toggle
+ if longop.should_cancel():
+ break
+ elif row[0]: # toggle on
load_addon_file(row[4], callback=LOG.debug)
+ count += 1
+ longop.heartbeat()
+ pm._get_dlg()._process_events()
+ if not longop.was_cancelled():
+ longop.end()
+ if count:
+ self.do_reg_plugins(self.dbstate, self.uistate)
+ OkDialog(_("Done downloading and installing addons"),
+ "%s %s" % (ngettext("%d addon was installed.",
+ "%d addons were installed.",
+ count) % count,
+ _("You need to restart Gramps to see new views.")),
+ self.window)
+ else:
+ OkDialog(_("Done downloading and installing addons"),
+ _("No addons were installed."),
+ self.window)
self.update_dialog.destroy()
def _errordialog(title, errormessage):
@@ -944,7 +985,7 @@ class ViewManager(CLIManager):
Display plugin status dialog
"""
try:
- PluginWindows.PluginStatus(self.uistate, [])
+ PluginWindows.PluginStatus(self.dbstate, self.uistate, [])
except Errors.WindowActiveError:
pass