[gimp] Added a function to export the Pango markup of a text layer



commit 3f66808584d2252d278718f2e422bae558c8a034
Author: Barak Itkin <lightningismyname gmail com>
Date:   Tue May 18 00:29:27 2010 +0300

    Added a function to export the Pango markup of a text layer
    
    This is required for the PDF export plugin.

 app/pdb/internal-procs.c        |    2 +-
 app/pdb/text-layer-cmds.c       |   68 +++++++++++++++++++++++++++++++++++++++
 libgimp/gimp.def                |    1 +
 libgimp/gimptextlayer_pdb.c     |   36 ++++++++++++++++++++
 libgimp/gimptextlayer_pdb.h     |    1 +
 tools/pdbgen/pdb/text_layer.pdb |   47 ++++++++++++++++++++++++++-
 6 files changed, 153 insertions(+), 2 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 554e83a..cbe9a72 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 601 procedures registered total */
+/* 602 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)
diff --git a/app/pdb/text-layer-cmds.c b/app/pdb/text-layer-cmds.c
index 2981c1f..a59b6e3 100644
--- a/app/pdb/text-layer-cmds.c
+++ b/app/pdb/text-layer-cmds.c
@@ -174,6 +174,44 @@ text_layer_set_text_invoker (GimpProcedure      *procedure,
 }
 
 static GValueArray *
+text_layer_get_markup_invoker (GimpProcedure      *procedure,
+                               Gimp               *gimp,
+                               GimpContext        *context,
+                               GimpProgress       *progress,
+                               const GValueArray  *args,
+                               GError            **error)
+{
+  gboolean success = TRUE;
+  GValueArray *return_vals;
+  GimpLayer *layer;
+  gchar *markup = NULL;
+
+  layer = gimp_value_get_layer (&args->values[0], gimp);
+
+  if (success)
+    {
+      if (gimp_pdb_layer_is_text_layer (layer, FALSE, error))
+        {
+          g_object_get (gimp_text_layer_get_text (GIMP_TEXT_LAYER (layer)),
+                        "markup", &markup,
+                        NULL);
+        }
+      else
+        {
+          success = FALSE;
+        }
+    }
+
+  return_vals = gimp_procedure_get_return_values (procedure, success,
+                                                  error ? *error : NULL);
+
+  if (success)
+    g_value_take_string (&return_vals->values[1], markup);
+
+  return return_vals;
+}
+
+static GValueArray *
 text_layer_get_font_invoker (GimpProcedure      *procedure,
                              Gimp               *gimp,
                              GimpContext        *context,
@@ -1281,6 +1319,36 @@ register_text_layer_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-text-layer-get-markup
+   */
+  procedure = gimp_procedure_new (text_layer_get_markup_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-text-layer-get-markup");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-text-layer-get-markup",
+                                     "Get the markup from a text layer as string.",
+                                     "This procedure returns the markup of the styles from a text layer. The markup will be in the form of Pango's markup - See http://www.pango.org/ for more information about Pango and its markup. Note: Setting the markup of a text layer using Pango's markup is not supported for now.",
+                                     "Barak Itkin <lightningismyname gmail com>",
+                                     "Barak Itkin",
+                                     "2010",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_layer_id ("layer",
+                                                         "layer",
+                                                         "The text layer",
+                                                         pdb->gimp, FALSE,
+                                                         GIMP_PARAM_READWRITE));
+  gimp_procedure_add_return_value (procedure,
+                                   gimp_param_spec_string ("markup",
+                                                           "markup",
+                                                           "The markup which represents the style of the specified text layer.",
+                                                           FALSE, FALSE, FALSE,
+                                                           NULL,
+                                                           GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-text-layer-get-font
    */
   procedure = gimp_procedure_new (text_layer_get_font_invoker);
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index a526416..050cc5d 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -635,6 +635,7 @@ EXPORTS
 	gimp_text_layer_get_language
 	gimp_text_layer_get_letter_spacing
 	gimp_text_layer_get_line_spacing
+	gimp_text_layer_get_markup
 	gimp_text_layer_get_text
 	gimp_text_layer_new
 	gimp_text_layer_resize
diff --git a/libgimp/gimptextlayer_pdb.c b/libgimp/gimptextlayer_pdb.c
index 0be3df8..68297a7 100644
--- a/libgimp/gimptextlayer_pdb.c
+++ b/libgimp/gimptextlayer_pdb.c
@@ -143,6 +143,42 @@ gimp_text_layer_set_text (gint32       layer_ID,
 }
 
 /**
+ * gimp_text_layer_get_markup:
+ * @layer_ID: The text layer.
+ *
+ * Get the markup from a text layer as string.
+ *
+ * This procedure returns the markup of the styles from a text layer.
+ * The markup will be in the form of Pango's markup - See
+ * http://www.pango.org/ for more information about Pango and its
+ * markup. Note: Setting the markup of a text layer using Pango's
+ * markup is not supported for now.
+ *
+ * Returns: The markup which represents the style of the specified text layer.
+ *
+ * Since: GIMP 2.8
+ */
+gchar *
+gimp_text_layer_get_markup (gint32 layer_ID)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gchar *markup = NULL;
+
+  return_vals = gimp_run_procedure ("gimp-text-layer-get-markup",
+                                    &nreturn_vals,
+                                    GIMP_PDB_LAYER, layer_ID,
+                                    GIMP_PDB_END);
+
+  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
+    markup = g_strdup (return_vals[1].data.d_string);
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return markup;
+}
+
+/**
  * gimp_text_layer_get_font:
  * @layer_ID: The text layer.
  *
diff --git a/libgimp/gimptextlayer_pdb.h b/libgimp/gimptextlayer_pdb.h
index 1e3dfb3..bb07df9 100644
--- a/libgimp/gimptextlayer_pdb.h
+++ b/libgimp/gimptextlayer_pdb.h
@@ -36,6 +36,7 @@ gint32                gimp_text_layer_new                (gint32
 gchar*                gimp_text_layer_get_text           (gint32                 layer_ID);
 gboolean              gimp_text_layer_set_text           (gint32                 layer_ID,
                                                           const gchar           *text);
+gchar*                gimp_text_layer_get_markup         (gint32                 layer_ID);
 gchar*                gimp_text_layer_get_font           (gint32                 layer_ID);
 gboolean              gimp_text_layer_set_font           (gint32                 layer_ID,
                                                           const gchar           *font);
diff --git a/tools/pdbgen/pdb/text_layer.pdb b/tools/pdbgen/pdb/text_layer.pdb
index 90523ac..fe3e8e4 100644
--- a/tools/pdbgen/pdb/text_layer.pdb
+++ b/tools/pdbgen/pdb/text_layer.pdb
@@ -152,6 +152,50 @@ CODE
     );
 }
 
+sub text_layer_get_markup {
+    $blurb = 'Get the markup from a text layer as string.';
+
+    $help = <<'HELP';
+This procedure returns the markup of the styles from a text layer.
+The markup will be in the form of Pango's markup - See
+http://www.pango.org/ for more information about Pango and its markup.
+Note: Setting the markup of a text layer using Pango's markup is not
+supported for now.
+HELP
+
+    $author = 'Barak Itkin <lightningismyname gmail com>';
+    $copyright = 'Barak Itkin';
+    $date = '2010';
+    $since = '2.8';
+
+    @inargs = (
+        { name => 'layer', type => 'layer',
+          desc => 'The text layer' }
+    );
+
+    @outargs = (
+        { name => 'markup', type => 'string',
+          desc => 'The markup which represents the style of the specified text layer.' }
+    );
+    
+    %invoke = (
+        code => <<'CODE'
+{
+  if (gimp_pdb_layer_is_text_layer (layer, FALSE, error))
+    {
+      g_object_get (gimp_text_layer_get_text (GIMP_TEXT_LAYER (layer)),
+                    "markup", &markup,
+                    NULL);
+    }
+  else
+    {
+      success = FALSE;
+    }
+}
+CODE
+    );
+}
+
 sub text_layer_get_font {
     $blurb = 'Get the font from a text layer as string.';
 
@@ -1164,6 +1208,7 @@ CODE
 @procs = qw(text_layer_new
             text_layer_get_text
             text_layer_set_text
+            text_layer_get_markup
             text_layer_get_font
             text_layer_set_font
             text_layer_get_font_size
@@ -1188,7 +1233,7 @@ CODE
             text_layer_set_line_spacing
             text_layer_get_letter_spacing
             text_layer_set_letter_spacing
-	    text_layer_resize
+            text_layer_resize
             text_layer_get_hinting
             text_layer_set_hinting
 );



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]