Changes

Jump to: navigation, search

Addons development

3,677 bytes added, 23:44, 6 November 2022
m
Announce the addon
# [[#List_and_document_your_addon_on_the_wiki|Document your addon]] and publish it to the addon list
# [[#List_your_addon_in_the_Gramps_Plugin_Manager|Register your addon with the Plugin Manager]]
# [[Contact#Mailing_listsAnnounce_the_addon|Announce it on the Gramps mailing listForum]] - Let users know it exist and how to use it.
# [[#Support_it_through_issue_tracker|Support it through the issue tracker]]
# [[#Maintain_the_code_as_Gramps_continues_to_evolve|Maintain the code]] as Gramps continues to evolve
== Develop your addon ==
The [http://github.com/gramps-project/addons-source addons-source] repository holds the source code for the addons with branches holding the version for different gramps. If you are working on an addon for gramps for the current Gramps {{man version}} public release, be sure to use the maintenance/gramps51 git branch, as the default is master branch for the developmental pre-release. (Currently gramps 5.2, which is not the typical target for addons.)  Example commands are shown below referring to the public release rather than the master branch. The developers are currently merging changes to the most recent maintenance branch into master as necessary, so you don't have to do anything for that unless you are in a hurry.  The [http://github.com/gramps-project/addons-source addons-source] git repository has the following structure, with the code for each addon in its own folder:
* /addons-source
** ...
The [http://github.com/gramps-project/addons addons] git repository holds built versions of the addons for each release of Gramps, and has the following structure:
* /addons
*** /listings
The '''addon-source''' repository holds the source code for the addons with branches holding the version for different gramps. If you are working on an addon for gramps for the current Gramps {{man version}} public release, be sure to use the gramps51 git branch, as the default is master branch for the developmental pre-release. (Currently gramps 5.2, which is not the typical target for addons.)
 
Example commands are shown below referring to the public release rather than the master branch.
 
The developers are currently merging changes to the most recent maintenance branch into master as necessary, so you don't have to do anything for that unless you are in a hurry.
=== Get a local copy of Gramps and its addons ===
# Get an https://github.com/join account if you don't already have one.
# Request GIT write access for the https://github.com/gramps-project/addons-source project by emailing the [[Contact#Mailing_lists|gramps-devel mailing list]]
See also [[Brief_introduction_to_Git|git introduction]] for instructions on installing git and getting basic settings configured. Also [https://help.github.com/articles/generating-an-ssh-key/ Connecting to GitHub with SSH] will help with setting up credentials for GitHub.
To fully build and advertise a new addon will require local copies of the three repositories, the 'addons-source', 'addons' and the main Gramps source 'gramps'.
This wiki assumes that the all three git repositories local locations are all to be put into the users' home same base directory and named with the repository names. The three directories '''must''' be named as shown, and in the same base directory in order for the make.py script commands to work properlyas shown. From the base directory, however they don't have run the following commands to be located directory in the users home directorycreate a copy of each repositoryFrom your home directoryIf you want to use SSH;
git clone [email protected]:gramps-project/addons-source.git addons-source
git clone [email protected]:gramps-project/gramps.git gramps
or if you do not have want to use a Github accountweb url:
git clone https://github.com/gramps-project/addons-source.git addons-source
git clone https://github.com/gramps-project/gramps.git gramps
This will create a copy of the addons-source tree in your home directory at "~/addons-source", and the other trees at their respective locations as well. To switch to a local copy of the gramps51 maintenance branch:
cd addons-source
git checkout -b gramps52 origin/master
=== Other pre-requisites prerequisites ===
{{man warn|These instructions, the make.py script etc.|are designed to operate in a Linux environment. {{man menu|They won't work on Windows without modifications.}}}}
* Gramps uses Python version 3.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.
Create your NewProjectName.py and NewProjectName.gpr.py files.
Follow the development API for your tool, [[Report-writing_tutorial|report]], view, or [[Gramplets]]. Place all of your associated .py, .glade, etc. files in this directory. For general information on Gramps development see [[Portal:Developers]] and [[Writing a plugin|Writing a Plugin]] specifically.
=== Test your addon as you develop ===
{{man warn|{{bug|10436}} Symlinks to folders in gramps plugin dir are not scanned}}
To test your addon as you develop it is suggested that you insert copy your NewProjectName plugin into your Gramps user plugin directory with a link to from your addon development directory, like so: prior to testing. cd ~/Or just edit in the Gramps user plugin directory until it is ready to publish, then copy back to your addon development directory.gramps/gramps51/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.
_("Remaining names | rest")
Where "rest" is the English string that we want to present and "Remaining names" is a hint for translators.
 
==== Commands to compile translations ====
 
To build and compile translations for all projects to their download/Addon.addon.tgz files:
 
: <code>python3 make.py gramps51 build all</code>
 
To compile translations for all projects :
 
: <code>python3 make.py gramps51 compile all</code>
== Create a Gramps Plugin Registration file ==
Each report category has a set of standards and interface. The categories CATEGORY_TEXT and CATEGORY_DRAW use the Document interface of Gramps. See also [[Report API]] for a draft view on this.
The application programming interface or API for reports is treated at [[Report-writing_tutorial]]. For general information on Gramps development see [[Portal:Developers]] and [[Writing a plugin|Writing a Plugin]] specifically.
=== General plugins ===
<span id=internationalization>
 
== List the Prerequistes your addon depends on ==
 
''In your gpr file, you can have a line like:
 
<code>depends_on = ["libwebconnect"]</code>
 
which is a list of id's from other gpr files. This example will ensure that [[Addon:Web_Connect_Pack#Prerequisites|libwebconnect]] is loaded before your addon. If it can't be found, or you have a cycle, then your addons won't be loaded.
 
example code used in the Addon:Web_Connect_Pack that references libwebconnect Prerequistes [https://github.com/gramps-project/addons-source/blob/1304b65a7d758bfe17339c26260473ac3e9c4061/RUWebConnectPack/RUWebPack.gpr.py#L17 RUWebPack.gpr.py#L17 ]
 
This means that common Prerequistes can be shared between addons and that code sits in its own gpr/addon file.
 
<!--
 
[] for addon prerequistes have a look at converting them to use "depends_on = " like in the following addons
https://github.com/gramps-project/addons-source/search?utf8=%E2%9C%93&q=depends_on&type=
https://github.com/gramps-project/gramps/search?utf8=%E2%9C%93&q=depends_on&type=
 
which can be a comma separated list for multiple dependencies/prerequisites (so that addons that share prerequisites import the same library?) (maybe move spell check into an addon etc? tip of the day... possibilities...)
 
depends_on = ["libwebconnect"]
 
mentioned in the following
https://sourceforge.net/p/gramps/mailman/message/27070037/
''In your gpr file, you can have a line like:
 
depends_on = ["libwebconnect"]
 
which is a list of id's from other gpr files. This example will ensure
that libwebconnect is loaded before your plugin. If it can't be found,
or you have a cycle, then your plugin won't be loaded.
 
If it is a common function, perhaps libhtml is the right place to put
it, and you can put a depends_on on that.
 
-Doug''
 
 
example output is on terminal only:
 
Cannot resolve the following plugin dependencies:
Plugin 'UK Web Connect Pack' requires: ['libwebconnect']
 
[](feature) For plugins/addons if prerequisites not available display a page stating why/what is missing that includes the addon description and a url to the support page.
 
[] Gramps CLI info "gramps -v" needs a section that list third-party addons with version numbers and if prerequisites have been met.
 
[]update the Addon:Prerequisites Checker Gramplet to test for your Prerequisites.
 
-->
 
== Get translators to translate your addon into multiple languages ==
</span>
If you [[#Localization|designed for localization]], the addon will begin supporting a single language. Make your add-on addon inviting for volunteers to translate it into their native language.
* Initialize and update the <code>template.pot</code> for your addon:
: <code>cd ~/addons-source</code>
: <code>./make.py gramps51 build NewProjectName</code> or
: <code>./make.py gramps52 build NewProjectName</code> for the master branch.
 
Note that the
This will automatically include the following files in your build:
</pre>
{{man note|Note:|Running the command '''<code>make.py xxx build''' </code> will increment the third number in your dotted version number of all addons in the <code>*.gpr.py </code> file. Consider this number to be a "build number".}}
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.
git add gramps52/download/NewProjectName.addon.tgz
git commit -m " Added new plugin: NewProjectName"</pre>
 
== List your addon in the Gramps Plugin Manager==
==== Example addon template ====
Examine the listing for other addons and refer to the [[Plugin Addon list legend]] for details of on the meaning of each columns.
<pre>
|- <!-- Copy this section and list your Addon -->
</pre>
== Miscellaneous commands Announce the addon == To build Join the [[Contact#Forum|Gramps Forum]] and announce it to the users with general information on why you created and compile translations for all projects how to their download/Addon.addon.tgz files: : <code>python3 make.py gramps51 build all</code> To compile translations for all projects : : <code>python3 makeuse it.py gramps51 compile all</code>
== Support it through issue tracker ==
== Maintain the code as Gramps continues to evolve ==
{{man tip|When submitting an update the patch part of the version number MAJOR.MINOR.PATCH is updated during the addon build process e.g. 1.1.3 to 1.1.4|You can find this step in [https://github.com/gramps-project/addons-source/blob/master/make.py#L125 addons-source/make.py].[https://gramps.discourse.group/t/should-addons-pr-include-version-number-update/2591]}} Remember that Gramps addons exist for many reasons and there are manyGramps developers that do support addons in various ways (translations,triage, keeping in sync with master, download infrastructure, etc).
Some reasons why the addons exist; they provide:
* A place for controversial plugins that will never be accepted into core, but are loved by many users (eg, Data Entry Gramplet).
* A place for experimental components to live.
 
== Example code adding common enhancements ==
* Copy all the Gramplet's output to a system clipboard via context pop-up menu : Enhancement request {{bug|11573}}, [https://github.com/gramps-project/gramps/pull/1014/commits/72012e13b4ca15caca4b7f36fdb9702c1fd470fd example pull]
* add a custom [[Gramps_Glossary#viewmode|View Mode]] toolbar icon via the <code>.gpr.py</code> : [https://github.com/gramps-project/gramps/pull/1017 Pull 1017 Discussion], [https://github.com/gramps-project/gramps/pull/1017/commits/76e41d546d6ec519dd78fbe07f663135b5c79351 example Pull]
= Resources =
* [[Brief_introduction_to_Git|Git introduction]]
* [[Getting started with Gramps development]]
* [[Portal:Developers]]
* [https://gramps-project.org/docs/gen/gen_plug.html?highlight=include_in_listing#module-gramps.gen.plug._pluginreg Registration Module]
;Gramps Addons site for Gramps 4.2 and newer
1,969
edits

Navigation menu