diff --git a/src/gen/plug/_manager.py b/src/gen/plug/_manager.py
index 471156e76..3ebc83c81 100644
--- a/src/gen/plug/_manager.py
+++ b/src/gen/plug/_manager.py
@@ -127,6 +127,14 @@ class BasePluginManager(object):
for plugin in self.__pgr.filter_load_on_reg():
mod = self.load_plugin(plugin)
+ def is_loaded(self, pdata_id):
+ """
+ return True if plugin is already loaded
+ """
+ if pdata_id in self.__loaded_plugins:
+ return True
+ return False
+
def load_plugin(self, pdata):
"""
Load a PluginData object. This means import of the python module.
diff --git a/src/gen/plug/_pluginreg.py b/src/gen/plug/_pluginreg.py
index ba3335187..cd8d4d918 100644
--- a/src/gen/plug/_pluginreg.py
+++ b/src/gen/plug/_pluginreg.py
@@ -40,6 +40,7 @@ import traceback
#
#-------------------------------------------------------------------------
from const import VERSION as GRAMPSVERSION
+from const import IMAGE_DIR
from TransUtils import get_addon_translator
from gen.ggettext import gettext as _
@@ -168,6 +169,19 @@ class PluginData(object):
bool value, if True, the plugin is loaded on GRAMPS startup. Some
plugins. Only set this value if for testing you want the plugin to be
loaded immediately on startup. default=False
+ .. attribute: icons
+ New stock icons to register. A list of tuples (stock_id, icon_label),
+ eg:
+ [('gramps_myplugin', _('My Plugin')),
+ ('gramps_myplugin_open', _('Open Plugin')]
+ The icon directory must contain the directories scalable, 48x48, 22x22
+ and 16x16 with the icons, eg:
+ scalable/gramps_myplugin.svg
+ 48x48/gramps_myplugin.png
+ 22x22/gramps_myplugin.png
+ .. attribute: icondir
+ The directory to use for the icons. If icondir is not set or None, it
+ reverts to the plugindirectory itself.
Attributes for RELCALC plugins:
.. attribute:: relcalcclass
@@ -263,6 +277,9 @@ class PluginData(object):
"""
def __init__(self):
+ #read/write attribute
+ self.directory = None
+ #base attributes
self._id = None
self._name = None
self._version = None
@@ -276,6 +293,8 @@ class PluginData(object):
self._authors_email = []
self._supported = True
self._load_on_reg = False
+ self._icons = []
+ self._icondir = None
#derived var
self.mod_name = None
#RELCALC attr
@@ -412,14 +431,28 @@ class PluginData(object):
def _get_supported(self):
return self._supported
- def _get_load_on_reg(self):
- return self._load_on_reg
-
def _set_load_on_reg(self, load_on_reg):
if not isinstance(load_on_reg, bool):
raise ValueError, 'Plugin must have load_on_reg=True or False'
self._load_on_reg = load_on_reg
-
+
+ def _get_load_on_reg(self):
+ return self._load_on_reg
+
+ def _get_icons(self):
+ return self._icons
+
+ def _set_icons(self, icons):
+ if not isinstance(icons, list):
+ raise ValueError, 'Plugin must have icons as a list'
+ self._icons = icons
+
+ def _get_icondir(self):
+ return self._icondir
+
+ def _set_icondir(self, icondir):
+ self._icondir = icondir
+
id = property(_get_id, _set_id)
name = property(_get_name, _set_name)
description = property(_get_description, _set_description)
@@ -434,6 +467,8 @@ class PluginData(object):
authors_email = property(_get_authors_email, _set_authors_email)
supported = property(_get_supported, _set_supported)
load_on_reg = property(_get_load_on_reg, _set_load_on_reg)
+ icons = property(_get_icons, _set_icons)
+ icondir = property(_get_icondir, _set_icondir)
def statustext(self):
return STATUSTEXT[self.status]
@@ -740,6 +775,7 @@ class PluginData(object):
viewclass = property(_get_viewclass, _set_viewclass)
order = property(_get_order, _set_order)
+
def newplugin():
"""
@@ -821,6 +857,7 @@ def make_environment(**kwargs):
'GRAMPSVERSION': GRAMPSVERSION,
'START': START,
'END': END,
+ 'IMAGE_DIR': IMAGE_DIR
}
env.update(kwargs)
return env
@@ -902,6 +939,7 @@ class PluginRegister(object):
ind = lenpd-1
for plugin in self.__plugindata[lenpd:]:
ind += 1
+ plugin.directory = dir
if not plugin.status == STABLE and self.stable_only:
rmlist.append(ind)
continue
diff --git a/src/gui/grampsgui.py b/src/gui/grampsgui.py
index bbb9a25ee..a57a981b6 100644
--- a/src/gui/grampsgui.py
+++ b/src/gui/grampsgui.py
@@ -61,8 +61,8 @@ import gobject
from QuestionDialog import ErrorDialog
import config
import Utils
-import constfunc
-from gui.pluginmanager import GuiPluginManager
+from constfunc import win
+from gui.pluginmanager import GuiPluginManager, base_reg_stock_icons
from gen.plug import (START, END)
#-------------------------------------------------------------------------
@@ -71,6 +71,7 @@ from gen.plug import (START, END)
#
#-------------------------------------------------------------------------
+
def register_stock_icons ():
"""
Add the gramps names for its icons (eg gramps-person) to the GTK icon
@@ -78,7 +79,7 @@ def register_stock_icons ():
"""
#iconpath to the base image. The front of the list has highest priority
- if constfunc.win():
+ if win():
iconpaths = [
(os.path.join(const.IMAGE_DIR, '48x48'), '.png'),
(const.IMAGE_DIR, '.png'),
@@ -156,51 +157,7 @@ def register_stock_icons ():
('gramps-url', _('URL'), gtk.gdk.CONTROL_MASK, 0, ''),
]
- # Register our stock items
- gtk.stock_add (items+items_legacy)
-
- # Add our custom icon factory to the list of defaults
- factory = gtk.IconFactory ()
- factory.add_default ()
-
- for data in items+items_legacy:
- pixbuf = 0
- for (dirname, ext) in iconpaths:
- icon_file = os.path.expanduser(os.path.join(dirname, data[0]+ext))
- if os.path.isfile(icon_file):
- try:
- pixbuf = gtk.gdk.pixbuf_new_from_file (icon_file)
- break
- except:
- pass
-
- if not pixbuf :
- icon_file = os.path.join(const.IMAGE_DIR, 'gramps.png')
- pixbuf = gtk.gdk.pixbuf_new_from_file (icon_file)
-
- ## FIXME from gtk 2.17.3/2.15.2 change this to
- ## FIXME pixbuf = pixbuf.add_alpha(True, 255, 255, 255)
- pixbuf = pixbuf.add_alpha(True, chr(0xff), chr(0xff), chr(0xff))
- icon_set = gtk.IconSet (pixbuf)
- #add different sized icons, always png type!
- for size in extraiconsize :
- pixbuf = 0
- icon_file = os.path.expanduser(
- os.path.join(size[0], data[0]+'.png'))
- if os.path.isfile(icon_file):
- try:
- pixbuf = gtk.gdk.pixbuf_new_from_file (icon_file)
- except:
- pass
-
- if pixbuf :
- source = gtk.IconSource()
- source.set_size_wildcarded(False)
- source.set_size(size[1])
- source.set_pixbuf(pixbuf)
- icon_set.add_source(source)
-
- factory.add (data[0], icon_set)
+ base_reg_stock_icons(iconpaths, extraiconsize, items+items_legacy)
def _display_welcome_message():
"""
diff --git a/src/gui/pluginmanager.py b/src/gui/pluginmanager.py
index f15cf2261..2cb8ee9e1 100644
--- a/src/gui/pluginmanager.py
+++ b/src/gui/pluginmanager.py
@@ -34,7 +34,8 @@ importers, exporters, quick reports, and document generators.
# Standard Python modules
#
#-------------------------------------------------------------------------
-
+import os
+import gtk
#-------------------------------------------------------------------------
#
@@ -43,14 +44,75 @@ importers, exporters, quick reports, and document generators.
#-------------------------------------------------------------------------
import gen.utils
from gen.plug import BasePluginManager, PluginRegister
+from constfunc import win
import config
+import const
#-------------------------------------------------------------------------
#
-# Constants
+# Functions
#
#-------------------------------------------------------------------------
+def base_reg_stock_icons(iconpaths, extraiconsize, items):
+ """
+ Reusable base to register stock icons in Gramps
+ ..attribute iconpaths: list of main directory of the base icon, and
+ extension, eg:
+ [(os.path.join(const.IMAGE_DIR, 'scalable'), '.svg')]
+ ..attribute extraiconsize: list of dir with extra prepared icon sizes and
+ the gtk size to use them for, eg:
+ [(os.path.join(const.IMAGE_DIR, '22x22'), gtk.ICON_SIZE_LARGE_TOOLBAR)]
+ ..attribute items: list of icons to register, eg:
+ [('gramps-db', _('Family Trees'), gtk.gdk.CONTROL_MASK, 0, '')]
+ """
+
+ # Register our stock items
+ gtk.stock_add (items)
+
+ # Add our custom icon factory to the list of defaults
+ factory = gtk.IconFactory ()
+ factory.add_default ()
+
+ for data in items:
+ pixbuf = 0
+ for (dirname, ext) in iconpaths:
+ icon_file = os.path.expanduser(os.path.join(dirname, data[0]+ext))
+ if os.path.isfile(icon_file):
+ try:
+ pixbuf = gtk.gdk.pixbuf_new_from_file (icon_file)
+ break
+ except:
+ pass
+
+ if not pixbuf :
+ icon_file = os.path.join(const.IMAGE_DIR, 'gramps.png')
+ pixbuf = gtk.gdk.pixbuf_new_from_file (icon_file)
+
+ ## FIXME from gtk 2.17.3/2.15.2 change this to
+ ## FIXME pixbuf = pixbuf.add_alpha(True, 255, 255, 255)
+ pixbuf = pixbuf.add_alpha(True, chr(0xff), chr(0xff), chr(0xff))
+ icon_set = gtk.IconSet (pixbuf)
+ #add different sized icons, always png type!
+ for size in extraiconsize :
+ pixbuf = 0
+ icon_file = os.path.expanduser(
+ os.path.join(size[0], data[0]+'.png'))
+ if os.path.isfile(icon_file):
+ try:
+ pixbuf = gtk.gdk.pixbuf_new_from_file (icon_file)
+ except:
+ pass
+
+ if pixbuf :
+ source = gtk.IconSource()
+ source.set_size_wildcarded(False)
+ source.set_size(size[1])
+ source.set_pixbuf(pixbuf)
+ icon_set.add_source(source)
+
+ factory.add (data[0], icon_set)
+
#-------------------------------------------------------------------------
#
# GuiPluginManager
@@ -83,14 +145,70 @@ class GuiPluginManager(gen.utils.Callback):
self.basemgr = BasePluginManager.get_instance()
self.__hidden_plugins = set(config.get('plugin.hiddenplugins'))
self.__hidden_changed()
-
+
+ def load_plugin(self, pdata):
+ if not self.is_loaded(pdata.id):
+ #load stock icons before import, only gui needs this
+ if pdata.icons:
+ if pdata.icondir and os.path.isdir(pdata.icondir):
+ dir = pdata.icondir
+ else:
+ #use the plugin directory
+ dir = pdata.directory
+ self.load_icons(pdata.icons, dir)
+ return self.basemgr.load_plugin(pdata)
+
def reload_plugins(self):
self.basemgr.reload_plugins()
self.emit('plugins-reloaded')
def __getattr__(self, name):
return getattr(self.basemgr, name)
-
+
+ def load_icons(self, icons, dir):
+ """
+ Load icons in the iconfactory of gramps, so they can be used in the
+ plugin.
+
+ ..attribute icons:
+ New stock icons to register. A list of tuples (stock_id, icon_label),
+ eg:
+ [('gramps_myplugin', _('My Plugin')),
+ ('gramps_myplugin_open', _('Open Plugin'))]
+ The plugin directory must contain the directories scalable, 48x48, 22x22
+ and 16x16 with the icons, eg in dir we have:
+ scalable/gramps_myplugin.svg
+ 48x48/gramps_myplugin.png
+ 22x22/gramps_myplugin.png
+ ..attribute dir: directory from where to load the icons
+ """
+ if win():
+ iconpaths = [
+ (os.path.join(dir, '48x48'), '.png'),
+ (dir, '.png'),
+ ]
+ else :
+ iconpaths = [
+ (os.path.join(dir, 'scalable'), '.svg'),
+ (dir, '.svg'), (dir, '.png'),
+ ]
+
+ #sizes: menu=16, small_toolbar=18, large_toolbar=24,
+ # button=20, dnd=32, dialog=48
+ #add to the back of this list to overrule images set at beginning of list
+ extraiconsize = [
+ (os.path.join(dir, '22x22'), gtk.ICON_SIZE_LARGE_TOOLBAR),
+ (os.path.join(dir, '16x16'), gtk.ICON_SIZE_MENU),
+ (os.path.join(dir, '22x22'), gtk.ICON_SIZE_BUTTON),
+ ]
+
+ items = []
+ for stock_id, label in icons:
+ items.append((stock_id, label, gtk.gdk.CONTROL_MASK, 0, ''))
+
+ base_reg_stock_icons(iconpaths, extraiconsize, items)
+
+
def __hidden_changed(self, *args):
#if hidden changed, stored data must be emptied as it could contain
#something that now must be hidden
diff --git a/src/images/16x16/gramps-geo.png b/src/images/16x16/gramps-geo.png
index 1ab720324..6d98e1ab5 100644
Binary files a/src/images/16x16/gramps-geo.png and b/src/images/16x16/gramps-geo.png differ
diff --git a/src/images/22x22/Makefile.am b/src/images/22x22/Makefile.am
index cb749ad65..41c81e061 100644
--- a/src/images/22x22/Makefile.am
+++ b/src/images/22x22/Makefile.am
@@ -5,6 +5,14 @@ SUBDIRS =
pkgdatadir = $(datadir)/@PACKAGE@/images/22x22
dist_pkgdata_DATA = \
+ geo-fixed-zoom.png \
+ geo-free-zoom.png \
+ geo-place-add.png \
+ geo-place-link.png \
+ geo-show-event.png \
+ geo-show-family.png \
+ geo-show-person.png \
+ geo-show-place.png \
gramps-address.png \
gramps-attribute.png \
gramps-bookmark-delete.png \
diff --git a/src/images/22x22/geo-fixed-zoom.png b/src/images/22x22/geo-fixed-zoom.png
new file mode 100644
index 000000000..e4be82858
Binary files /dev/null and b/src/images/22x22/geo-fixed-zoom.png differ
diff --git a/src/images/22x22/geo-free-zoom.png b/src/images/22x22/geo-free-zoom.png
new file mode 100644
index 000000000..938ffa828
Binary files /dev/null and b/src/images/22x22/geo-free-zoom.png differ
diff --git a/src/images/22x22/geo-place-add.png b/src/images/22x22/geo-place-add.png
new file mode 100644
index 000000000..21ecb6100
Binary files /dev/null and b/src/images/22x22/geo-place-add.png differ
diff --git a/src/images/22x22/geo-place-link.png b/src/images/22x22/geo-place-link.png
new file mode 100644
index 000000000..d9f4d93c2
Binary files /dev/null and b/src/images/22x22/geo-place-link.png differ
diff --git a/src/images/22x22/geo-show-event.png b/src/images/22x22/geo-show-event.png
new file mode 100644
index 000000000..131c059be
Binary files /dev/null and b/src/images/22x22/geo-show-event.png differ
diff --git a/src/images/22x22/geo-show-family.png b/src/images/22x22/geo-show-family.png
new file mode 100644
index 000000000..e47e0d64f
Binary files /dev/null and b/src/images/22x22/geo-show-family.png differ
diff --git a/src/images/22x22/geo-show-person.png b/src/images/22x22/geo-show-person.png
new file mode 100644
index 000000000..a63ad86d6
Binary files /dev/null and b/src/images/22x22/geo-show-person.png differ
diff --git a/src/images/22x22/geo-show-place.png b/src/images/22x22/geo-show-place.png
new file mode 100644
index 000000000..844dc3e85
Binary files /dev/null and b/src/images/22x22/geo-show-place.png differ
diff --git a/src/images/22x22/gramps-geo.png b/src/images/22x22/gramps-geo.png
index 1a9292d49..c22ac5b73 100644
Binary files a/src/images/22x22/gramps-geo.png and b/src/images/22x22/gramps-geo.png differ
diff --git a/src/images/48x48/Makefile.am b/src/images/48x48/Makefile.am
index 60d075f8b..2c0da0cde 100644
--- a/src/images/48x48/Makefile.am
+++ b/src/images/48x48/Makefile.am
@@ -5,6 +5,14 @@ SUBDIRS =
pkgdatadir = $(datadir)/@PACKAGE@/images/48x48
dist_pkgdata_DATA = \
+ geo-fixed-zoom.png \
+ geo-free-zoom.png \
+ geo-place-add.png \
+ geo-place-link.png \
+ geo-show-event.png \
+ geo-show-family.png \
+ geo-show-person.png \
+ geo-show-place.png \
gramps-address.png \
gramps-attribute.png \
gramps-bookmark-delete.png \
diff --git a/src/images/48x48/geo-fixed-zoom.png b/src/images/48x48/geo-fixed-zoom.png
new file mode 100644
index 000000000..c3c2a40e1
Binary files /dev/null and b/src/images/48x48/geo-fixed-zoom.png differ
diff --git a/src/images/48x48/geo-free-zoom.png b/src/images/48x48/geo-free-zoom.png
new file mode 100644
index 000000000..889a44862
Binary files /dev/null and b/src/images/48x48/geo-free-zoom.png differ
diff --git a/src/images/48x48/geo-place-add.png b/src/images/48x48/geo-place-add.png
new file mode 100644
index 000000000..c2c0750a1
Binary files /dev/null and b/src/images/48x48/geo-place-add.png differ
diff --git a/src/images/48x48/geo-place-link.png b/src/images/48x48/geo-place-link.png
new file mode 100644
index 000000000..b88acfbc4
Binary files /dev/null and b/src/images/48x48/geo-place-link.png differ
diff --git a/src/images/48x48/geo-show-event.png b/src/images/48x48/geo-show-event.png
new file mode 100644
index 000000000..464818f7c
Binary files /dev/null and b/src/images/48x48/geo-show-event.png differ
diff --git a/src/images/48x48/geo-show-family.png b/src/images/48x48/geo-show-family.png
new file mode 100644
index 000000000..2ff66b141
Binary files /dev/null and b/src/images/48x48/geo-show-family.png differ
diff --git a/src/images/48x48/geo-show-person.png b/src/images/48x48/geo-show-person.png
new file mode 100644
index 000000000..f0fc0e588
Binary files /dev/null and b/src/images/48x48/geo-show-person.png differ
diff --git a/src/images/48x48/geo-show-place.png b/src/images/48x48/geo-show-place.png
new file mode 100644
index 000000000..bf3cc1731
Binary files /dev/null and b/src/images/48x48/geo-show-place.png differ
diff --git a/src/images/48x48/gramps-geo.png b/src/images/48x48/gramps-geo.png
index 2113b4c20..56ad65e56 100644
Binary files a/src/images/48x48/gramps-geo.png and b/src/images/48x48/gramps-geo.png differ
diff --git a/src/images/scalable/Makefile.am b/src/images/scalable/Makefile.am
index 9b953022b..027cd31ea 100644
--- a/src/images/scalable/Makefile.am
+++ b/src/images/scalable/Makefile.am
@@ -5,6 +5,15 @@ SUBDIRS =
pkgdatadir = $(datadir)/@PACKAGE@/images/scalable
dist_pkgdata_DATA = \
+geo-place-add.svg
+ geo-fixed-zoom.svg \
+ geo-free-zoom.svg \
+ geo-place-add.svg \
+ geo-place-link.svg \
+ geo-show-event.svg \
+ geo-show-family.svg \
+ geo-show-person.svg \
+ geo-show-place.svg \
gramps-address.svg \
gramps-attribute.svg \
gramps-bookmark-delete.svg \
diff --git a/src/images/scalable/geo-fixed-zoom.svg b/src/images/scalable/geo-fixed-zoom.svg
new file mode 100644
index 000000000..dea78fca7
--- /dev/null
+++ b/src/images/scalable/geo-fixed-zoom.svg
@@ -0,0 +1,1088 @@
+
+
+
+
diff --git a/src/images/scalable/geo-free-zoom.svg b/src/images/scalable/geo-free-zoom.svg
new file mode 100644
index 000000000..102dc0596
--- /dev/null
+++ b/src/images/scalable/geo-free-zoom.svg
@@ -0,0 +1,908 @@
+
+
+
+
diff --git a/src/images/scalable/geo-place-add.svg b/src/images/scalable/geo-place-add.svg
new file mode 100644
index 000000000..d58069a40
--- /dev/null
+++ b/src/images/scalable/geo-place-add.svg
@@ -0,0 +1,1058 @@
+
+
+
+
diff --git a/src/images/scalable/geo-place-link.svg b/src/images/scalable/geo-place-link.svg
new file mode 100644
index 000000000..bbf116223
--- /dev/null
+++ b/src/images/scalable/geo-place-link.svg
@@ -0,0 +1,1158 @@
+
+
+
+
diff --git a/src/images/scalable/geo-show-event.svg b/src/images/scalable/geo-show-event.svg
new file mode 100644
index 000000000..8a594883e
--- /dev/null
+++ b/src/images/scalable/geo-show-event.svg
@@ -0,0 +1,2885 @@
+
+
+
+
diff --git a/src/images/scalable/geo-show-family.svg b/src/images/scalable/geo-show-family.svg
new file mode 100644
index 000000000..4fb4fad59
--- /dev/null
+++ b/src/images/scalable/geo-show-family.svg
@@ -0,0 +1,2849 @@
+
+
+
+
diff --git a/src/images/scalable/geo-show-person.svg b/src/images/scalable/geo-show-person.svg
new file mode 100644
index 000000000..c4221b672
--- /dev/null
+++ b/src/images/scalable/geo-show-person.svg
@@ -0,0 +1,2957 @@
+
+
+
+
diff --git a/src/images/scalable/geo-show-place.svg b/src/images/scalable/geo-show-place.svg
new file mode 100644
index 000000000..ccc6beb67
--- /dev/null
+++ b/src/images/scalable/geo-show-place.svg
@@ -0,0 +1,2718 @@
+
+
+
+
diff --git a/src/images/scalable/gramps-geo.svg b/src/images/scalable/gramps-geo.svg
index 5fbad1cc1..639985fcc 100644
--- a/src/images/scalable/gramps-geo.svg
+++ b/src/images/scalable/gramps-geo.svg
@@ -1,5 +1,6 @@
+