Changes

Jump to: navigation, search

Addons development

214 bytes added, 11:11, 17 November 2016
m
print() # for python3
=== Other pre-requisites ===
* Gramps uses Python version 3.4 2 or higher. You must have at least that version installed. If you have installed Gramps 4.2 or higher on your Linux system already, then a sufficient version of Python will be present. If you have more than one version of Python installed, then you must use the correct version for these scripts. On some systems, both Python 2.x and 3.x are installed. It is possible that the normal invocation of <code>python</code> starts up Python 2.x, and that to start up Python 3.x requires invoking with <code>python3</code> or <code>python3.4</code> etc. You can test the version by <code>python –version</code> or <code>python3 –version</code>. If this is so, replace any usage of 'python' in the examples below with the appropriate invocation.
* The make.py used in construction of the addons requires that the LANGUAGE environment variable be set to 'en_US.UTF-8'.
* The make.py used in construction of the addons requires that the GRAMPSPATH environment variable be set to your path to the Gramps source tree.
cd ~/.gramps/gramps42/plugins
ln -s ~/ addons-source/NewProjectName NewProjectName
Your installed Gramps will search this folder (and subdirectories) for .gpr.py files, and add them to the plugin list.
To commit your changes so that others can see your addon source.
# * Remove the files that should not be added to GitHub:
: <code>./make.py gramps42 clean NewProjectName</code>
# * Add the project to the repository:: <precode>git add NewProjectName</pre><br /code>* Commit it with an appropriate message: <precode>git commit -m "A message describing what this addon is"</precode>
Before committing additional edits to your addon, you should:
# <pre>git pull --rebase</pre> # * to make sure that outside changes do not affect your commit# : <precode>git statuspull --rebase</precode> # * only the files you changed should be in this list# : <code>git status</code>* Commit it with an appropriate message: <precode>git commit -m "A message describing the changes"</precode>
If you have been given 'push' rights to GitHub 'gramps-project/addons-source', and when you are sure you are done and want to publish to the repository:
# <pre>git pull --rebase</pre> # * to make sure that outside changes do not affect your commit# : <code>git pull --rebase</code>: <precode>git push origin gramps42</precode>
Also you may want to [[Addons_development#Package_your_addon |Package your addon]] so it can be downloaded via the plugin manager.
Runs when plugin is registered.
"""
print ("Hello World!")
</pre>
def filters(namespace):
print ("Ok...", plugin.category, namespace, uistate)
# return a Filter object here
return filters
* Initialize and update the template.pot for your addon:
** : <precode>cd ~/addons-source</code>: <code>./make.py gramps42 init NewProjectName</precode>
* You should edit the header of template.pot with your information, so it gets copied to individual language files.
* Initialize a language for your addon (say French, fr):
** : <precode>./make.py gramps42 init NewProjectName fr</precode>
* Update it from gramps and other addons:
** : <precode>./make.py gramps42 update NewProjectName fr</precode>
* Edit the translations file manually:
** : <precode>/NewProjectName/po/fr-local.po</precode>
* Compile the language:
** : <precode>./make.py gramps42 compile NewProjectName</precode>
* Add or update your local language file, and commit changes:
** : <precode>git add NewProjectName/po/fr-local.po<br /code>: <code>git commit NewProjectName/po/fr-local.po -m "Added fr po file"</precode>
* If you have been given 'push' rights to GitHub 'gramps-project/addons-source', then;
** : <precode>git push origin gramps42</precode>
== Package your addon ==
To create a downloadable package:
: <precode>./make.py gramps42 build NewProjectName</precode> or<br /> : <precode>./make.py gramps50 build NewProjectName</precode> for the master branch.
Note that the
This will leave your 'addons-source' with untracked changes according to git. You should delete the 'NewProjectName/locale' directory. The updated 'NewProjectName/NewProjectName.gpr.py ' is ready to add and commit the next time you make other changes.
: <code>rm –rf –v 'NewProjectName/locale'</code>
Then add the package to GitHub:
<pre>cd '~/addons'
git add gramps42/download/NewProjectName.addon.tgz
git commit -m "Added new plugin: NewProjectName"</pre>
or (for the master branch);
<pre>cd '~/addons'
git add gramps50/download/NewProjectName.addon.tgz
git commit -m " Added new plugin: NewProjectName"</pre>
To create a listing:
: <code>cd '~/gramps-addons' # </code> or wherever you have built your addon : <code>GRAMPSPATH=path/to/your/gramps/install ./make.py gramps42 listing NewProjectName</code>
or (for the master branch);
: <code>cd '~/gramps-addons' # </code> or wherever you have built your addon : <code>GRAMPSPATH=path/to/your/gramps/install ./make.py gramps50 listing NewProjectName</code>
That will create a series of files in the <tt>../listings/</tt> directory.
Then add the updated listing to GitHub:
<pre>cd '~/addons'
git add gramps42/listings/*
git commit -m "Added new plugin to listings: NewProjectName"</pre>
or (for the master branch);
<pre>cd '~/addons'
git add gramps50/listings/*
git commit -m " Added new plugin to listings: NewProjectName"</pre>
To build and compile translations for all projects to their download/Addon.addon.tgz files:
: <code>python3 make.py gramps42 build all</code>
To compile translations for all projects :
: <code>python3 make.py gramps42 compile all</code>
== Support it through issue tracker ==

Navigation menu