4177: Needed usability improvements to addon update window

svn: r15757
This commit is contained in:
Doug Blank 2010-08-17 05:09:01 +00:00
parent fa09584578
commit d441154d3a
4 changed files with 82 additions and 34 deletions

View File

@ -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()

View File

@ -6,8 +6,8 @@
<object class="GtkDialog" id="dialog1">
<property name="border_width">5</property>
<property name="window_position">center</property>
<property name="default_width">500</property>
<property name="default_height">400</property>
<property name="default_width">700</property>
<property name="default_height">500</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">normal</property>
<property name="has_separator">False</property>
@ -31,6 +31,17 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="width_request">650</property>
<property name="visible">True</property>
<property name="label" translatable="yes">Gramps comes with a core set of plugins which provide all of the necessary features. However, you can extend this functionality with additional Addons. These addons provide reports, listings, views, gramplets, and more. Here you can select among the available extra addons, they will be retrieved from the internet off of the the Gramps website, and installed locally on your computer. If you close this dialog now, you can install addons later from the medu under Edit -&gt; Preferences.</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
@ -70,27 +81,28 @@
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<object class="GtkTreeView" id="list">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<child>
<object class="GtkTreeView" id="list">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
</child>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
<property name="pack_type">end</property>
<property name="position">2</property>
</packing>
</child>
<child internal-child="action_area">
@ -99,7 +111,7 @@
<property name="layout_style">start</property>
<child>
<object class="GtkButton" id="cancel">
<property name="label">gtk-cancel</property>
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -114,11 +126,11 @@
</child>
<child>
<object class="GtkButton" id="apply">
<property name="label">gtk-apply</property>
<property name="label">Install Selected _Addons</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>

View File

@ -75,7 +75,8 @@ class PluginStatus(ManagedWindow.ManagedWindow):
AVAILABLE = '<span weight="bold" color="blue">%s</span>'\
% _('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()

View File

@ -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