[gnome-builder] doc: add docs on embedding resources with Python
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] doc: add docs on embedding resources with Python
- Date: Thu, 7 Sep 2017 04:02:47 +0000 (UTC)
commit 5ed82c70058d4ac4d6a0c67ede45c6d446a47232
Author: Christian Hergert <chergert redhat com>
Date: Wed Sep 6 21:02:37 2017 -0700
doc: add docs on embedding resources with Python
doc/plugins/creating.rst | 30 ++++++++++++++++++++++++++++++
doc/plugins/running.rst | 3 +++
2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/doc/plugins/creating.rst b/doc/plugins/creating.rst
index 7809a27..cc7a317 100644
--- a/doc/plugins/creating.rst
+++ b/doc/plugins/creating.rst
@@ -72,4 +72,34 @@ Now if we close the window, we should see that our plugin was unloaded.
hello
goodbye
+.. _embedding_resources:
+
+Embedding Resources
+===================
+
+Sometimes plugins need to embed resources. Builder will automatically
+load a file that matches the name ``$module_name.gresource`` if it
+placed alongside the ``$module_name.plugin`` file.
+
+.. note:: If you are writing an extension in C or Vala, simply embed GResources as normal.
+
+.. code-block:: xml
+ :caption: First we need to create a my-plugin.gresource.xml file describing our resources
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <gresources>
+ <gresource prefix="/org/gnome/builder/plugins/my-plugin">
+ <file preprocess="xml-stripblanks" compressed="true">gtk/menus.ui</file>
+ </gresource>
+ </gresources>
+
+Next, compile the resources using ``glib-compile-resources``.
+
+.. code-block:: sh
+
+ glib-compile-resources --generate my-plugin.gresource my-plugin.gresource.xml
+
+Now you should have a file named ``my-plugin.gresource`` in the current directory.
+Ship this file along with your ``my-plugin.plugin`` and Python module.
+
Next, continue on to learn about other interfaces you can implement in Builder to extend it's features!
diff --git a/doc/plugins/running.rst b/doc/plugins/running.rst
index f51678c..e3c40f4 100644
--- a/doc/plugins/running.rst
+++ b/doc/plugins/running.rst
@@ -32,6 +32,9 @@ Let's take a look at a practical example using the Valgrind plugin.
</menu>
</interface>
+For more information on embedding resources with Python-based plugins,
+see :ref:`creating embedded GResources<embedding_resources>`.
+
Now register a run handler to handle the launch request.
.. code-block:: python3
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]