mirror of https://github.com/GNOME/gimp.git
Added a function to export the Pango markup of a text layer
This is required for the PDF export plugin.
This commit is contained in:
parent
bc54cbfd57
commit
3f66808584
|
@ -28,7 +28,7 @@
|
|||
#include "internal-procs.h"
|
||||
|
||||
|
||||
/* 601 procedures registered total */
|
||||
/* 602 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (GimpPDB *pdb)
|
||||
|
|
|
@ -173,6 +173,44 @@ text_layer_set_text_invoker (GimpProcedure *procedure,
|
|||
error ? *error : NULL);
|
||||
}
|
||||
|
||||
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,
|
||||
|
@ -1280,6 +1318,36 @@ register_text_layer_procs (GimpPDB *pdb)
|
|||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -142,6 +142,42 @@ gimp_text_layer_set_text (gint32 layer_ID,
|
|||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue