Updated with upstream update
This commit is contained in:
@ -34,6 +34,8 @@
|
||||
#include "pdb-types.h"
|
||||
|
||||
#include "core/pika.h"
|
||||
#include "core/pikabrush.h"
|
||||
#include "core/pikacontainer.h"
|
||||
#include "core/pikadatafactory.h"
|
||||
#include "core/pikaparamspecs.h"
|
||||
|
||||
@ -53,20 +55,24 @@ brushes_popup_invoker (PikaProcedure *procedure,
|
||||
gboolean success = TRUE;
|
||||
const gchar *brush_callback;
|
||||
const gchar *popup_title;
|
||||
const gchar *initial_brush_name;
|
||||
PikaBrush *initial_brush;
|
||||
GBytes *parent_window;
|
||||
|
||||
brush_callback = g_value_get_string (pika_value_array_index (args, 0));
|
||||
popup_title = g_value_get_string (pika_value_array_index (args, 1));
|
||||
initial_brush_name = g_value_get_string (pika_value_array_index (args, 2));
|
||||
initial_brush = g_value_get_object (pika_value_array_index (args, 2));
|
||||
parent_window = g_value_get_boxed (pika_value_array_index (args, 3));
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (pika->no_interface ||
|
||||
PikaContainer *container = pika_data_factory_get_container (pika->brush_factory);
|
||||
|
||||
if (pika->no_interface ||
|
||||
! pika_pdb_lookup_procedure (pika->pdb, brush_callback) ||
|
||||
! pika_pdb_dialog_new (pika, context, progress,
|
||||
pika_data_factory_get_container (pika->brush_factory),
|
||||
popup_title, brush_callback, initial_brush_name,
|
||||
NULL))
|
||||
pika_container_get_children_type (container),
|
||||
parent_window, popup_title, brush_callback,
|
||||
PIKA_OBJECT (initial_brush), NULL))
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
@ -89,9 +95,12 @@ brushes_close_popup_invoker (PikaProcedure *procedure,
|
||||
|
||||
if (success)
|
||||
{
|
||||
PikaContainer *container = pika_data_factory_get_container (pika->brush_factory);
|
||||
|
||||
if (pika->no_interface ||
|
||||
! pika_pdb_lookup_procedure (pika->pdb, brush_callback) ||
|
||||
! pika_pdb_dialog_close (pika, pika_data_factory_get_container (pika->brush_factory),
|
||||
! pika_pdb_dialog_close (pika,
|
||||
pika_container_get_children_type (container),
|
||||
brush_callback))
|
||||
success = FALSE;
|
||||
}
|
||||
@ -110,18 +119,20 @@ brushes_set_popup_invoker (PikaProcedure *procedure,
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
const gchar *brush_callback;
|
||||
const gchar *brush_name;
|
||||
PikaBrush *brush;
|
||||
|
||||
brush_callback = g_value_get_string (pika_value_array_index (args, 0));
|
||||
brush_name = g_value_get_string (pika_value_array_index (args, 1));
|
||||
brush = g_value_get_object (pika_value_array_index (args, 1));
|
||||
|
||||
if (success)
|
||||
{
|
||||
PikaContainer *container = pika_data_factory_get_container (pika->brush_factory);
|
||||
|
||||
if (pika->no_interface ||
|
||||
! pika_pdb_lookup_procedure (pika->pdb, brush_callback) ||
|
||||
! pika_pdb_dialog_set (pika, pika_data_factory_get_container (pika->brush_factory),
|
||||
brush_callback, brush_name,
|
||||
NULL))
|
||||
! pika_pdb_dialog_set (pika,
|
||||
pika_container_get_children_type (container),
|
||||
brush_callback, PIKA_OBJECT (brush), NULL))
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
@ -163,12 +174,17 @@ register_brush_select_procs (PikaPDB *pdb)
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
pika_param_spec_string ("initial-brush-name",
|
||||
"initial brush name",
|
||||
"The name of the brush to set as the initial choice",
|
||||
FALSE, TRUE, FALSE,
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_param_spec_brush ("initial-brush",
|
||||
"initial brush",
|
||||
"The brush to set as the initial choice",
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
g_param_spec_boxed ("parent-window",
|
||||
"parent window",
|
||||
"An optional parent window handle for the popup to be set transient to",
|
||||
G_TYPE_BYTES,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
@ -218,12 +234,11 @@ register_brush_select_procs (PikaPDB *pdb)
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
pika_param_spec_string ("brush-name",
|
||||
"brush name",
|
||||
"The name of the brush to set as selected",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_param_spec_brush ("brush",
|
||||
"brush",
|
||||
"The brush to set as selected",
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
}
|
||||
|
@ -148,20 +148,20 @@ display_get_window_handle_invoker (PikaProcedure *procedure,
|
||||
gboolean success = TRUE;
|
||||
PikaValueArray *return_vals;
|
||||
PikaDisplay *display;
|
||||
gint window = 0;
|
||||
GBytes *handle = NULL;
|
||||
|
||||
display = g_value_get_object (pika_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
window = (gint32) pika_get_display_window_id (pika, display);
|
||||
handle = pika_get_display_window_id (pika, display);
|
||||
}
|
||||
|
||||
return_vals = pika_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_set_int (pika_value_array_index (return_vals, 1), window);
|
||||
g_value_take_boxed (pika_value_array_index (return_vals, 1), handle);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
@ -330,7 +330,8 @@ register_display_procs (PikaPDB *pdb)
|
||||
"pika-display-get-window-handle");
|
||||
pika_procedure_set_static_help (procedure,
|
||||
"Get a handle to the native window for an image display.",
|
||||
"This procedure returns a handle to the native window for a given image display. For example in the X backend of GDK, a native window handle is an Xlib XID. A value of 0 is returned for an invalid display or if this function is unimplemented for the windowing system that is being used.",
|
||||
"This procedure returns a handle to the native window for a given image display.\n"
|
||||
"It can be different types of data depending on the platform you are running on. For example in the X backend of GDK, a native window handle is an Xlib XID whereas on Wayland, it is a string handle. A value of NULL is returned for an invalid display or if this function is unimplemented for the windowing system that is being used.",
|
||||
NULL);
|
||||
pika_procedure_set_static_attribution (procedure,
|
||||
"Sven Neumann <sven@gimp.org>",
|
||||
@ -343,11 +344,11 @@ register_display_procs (PikaPDB *pdb)
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_return_value (procedure,
|
||||
g_param_spec_int ("window",
|
||||
"window",
|
||||
"The native window handle or 0",
|
||||
G_MININT32, G_MAXINT32, 0,
|
||||
PIKA_PARAM_READWRITE));
|
||||
g_param_spec_boxed ("handle",
|
||||
"handle",
|
||||
"The native window handle or NULL",
|
||||
G_TYPE_BYTES,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
|
@ -75,6 +75,57 @@ font_get_by_name_invoker (PikaProcedure *procedure,
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static PikaValueArray *
|
||||
fonts_get_by_name_invoker (PikaProcedure *procedure,
|
||||
Pika *pika,
|
||||
PikaContext *context,
|
||||
PikaProgress *progress,
|
||||
const PikaValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
PikaValueArray *return_vals;
|
||||
const gchar *name;
|
||||
gint num_fonts = 0;
|
||||
PikaFont **fonts = NULL;
|
||||
|
||||
name = g_value_get_string (pika_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
list = pika_pdb_get_resources (pika, PIKA_TYPE_FONT, name, PIKA_PDB_DATA_ACCESS_READ, error);
|
||||
|
||||
if (list == NULL)
|
||||
success = FALSE;
|
||||
|
||||
num_fonts = g_list_length (list);
|
||||
|
||||
if (num_fonts > 0)
|
||||
{
|
||||
gint i = 0;
|
||||
|
||||
fonts = g_new (PikaFont *, num_fonts);
|
||||
|
||||
for (GList *iter = list; i < num_fonts; i++, iter = g_list_next (iter))
|
||||
fonts[i] = g_object_ref (iter->data);
|
||||
}
|
||||
g_list_free (list);
|
||||
}
|
||||
|
||||
return_vals = pika_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
{
|
||||
g_value_set_int (pika_value_array_index (return_vals, 1), num_fonts);
|
||||
pika_value_take_object_array (pika_value_array_index (return_vals, 2), PIKA_TYPE_FONT, (GObject **) fonts, num_fonts);
|
||||
}
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
void
|
||||
register_font_procs (PikaPDB *pdb)
|
||||
{
|
||||
@ -87,8 +138,9 @@ register_font_procs (PikaPDB *pdb)
|
||||
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
||||
"pika-font-get-by-name");
|
||||
pika_procedure_set_static_help (procedure,
|
||||
"Returns the font with the given name.",
|
||||
"Returns the font with the given name.",
|
||||
"Returns a font with the given name.",
|
||||
"If several fonts are named identically, the one which is returned by this function should be considered random. This can be used when you know you won't have multiple fonts of this name or that you don't want to choose (non-interactive scripts, etc.).\n"
|
||||
"If you need more control, you should use 'pika-fonts-get-by-name' instead.",
|
||||
NULL);
|
||||
pika_procedure_set_static_attribution (procedure,
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
@ -109,4 +161,40 @@ register_font_procs (PikaPDB *pdb)
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* pika-fonts-get-by-name
|
||||
*/
|
||||
procedure = pika_procedure_new (fonts_get_by_name_invoker);
|
||||
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
||||
"pika-fonts-get-by-name");
|
||||
pika_procedure_set_static_help (procedure,
|
||||
"Returns the fonts with the given name.",
|
||||
"Returns the fonts with the given name. There may be more than one.",
|
||||
NULL);
|
||||
pika_procedure_set_static_attribution (procedure,
|
||||
"Jehan",
|
||||
"Jehan",
|
||||
"2023");
|
||||
pika_procedure_add_argument (procedure,
|
||||
pika_param_spec_string ("name",
|
||||
"name",
|
||||
"The name of the font",
|
||||
FALSE, FALSE, TRUE,
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_return_value (procedure,
|
||||
g_param_spec_int ("num-fonts",
|
||||
"num fonts",
|
||||
"The number of fonts with the given name",
|
||||
0, G_MAXINT32, 0,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_return_value (procedure,
|
||||
pika_param_spec_object_array ("fonts",
|
||||
"fonts",
|
||||
"The fonts with the given name",
|
||||
PIKA_TYPE_FONT,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
}
|
||||
|
@ -34,8 +34,10 @@
|
||||
#include "pdb-types.h"
|
||||
|
||||
#include "core/pika.h"
|
||||
#include "core/pikacontainer.h"
|
||||
#include "core/pikadatafactory.h"
|
||||
#include "core/pikaparamspecs.h"
|
||||
#include "text/pikafont.h"
|
||||
|
||||
#include "pikapdb.h"
|
||||
#include "pikaprocedure.h"
|
||||
@ -53,21 +55,25 @@ fonts_popup_invoker (PikaProcedure *procedure,
|
||||
gboolean success = TRUE;
|
||||
const gchar *font_callback;
|
||||
const gchar *popup_title;
|
||||
const gchar *initial_font_name;
|
||||
PikaFont *initial_font;
|
||||
GBytes *parent_window;
|
||||
|
||||
font_callback = g_value_get_string (pika_value_array_index (args, 0));
|
||||
popup_title = g_value_get_string (pika_value_array_index (args, 1));
|
||||
initial_font_name = g_value_get_string (pika_value_array_index (args, 2));
|
||||
initial_font = g_value_get_object (pika_value_array_index (args, 2));
|
||||
parent_window = g_value_get_boxed (pika_value_array_index (args, 3));
|
||||
|
||||
if (success)
|
||||
{
|
||||
PikaContainer *container = pika_data_factory_get_container (pika->font_factory);
|
||||
|
||||
if (pika->no_interface ||
|
||||
! pika_pdb_lookup_procedure (pika->pdb, font_callback) ||
|
||||
! pika_data_factory_data_wait (pika->font_factory) ||
|
||||
! pika_pdb_dialog_new (pika, context, progress,
|
||||
pika_data_factory_get_container (pika->font_factory),
|
||||
popup_title, font_callback, initial_font_name,
|
||||
NULL))
|
||||
pika_container_get_children_type (container),
|
||||
parent_window, popup_title, font_callback,
|
||||
PIKA_OBJECT (initial_font), NULL))
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
@ -90,10 +96,12 @@ fonts_close_popup_invoker (PikaProcedure *procedure,
|
||||
|
||||
if (success)
|
||||
{
|
||||
PikaContainer *container = pika_data_factory_get_container (pika->font_factory);
|
||||
|
||||
if (pika->no_interface ||
|
||||
! pika_pdb_lookup_procedure (pika->pdb, font_callback) ||
|
||||
! pika_pdb_dialog_close (pika,
|
||||
pika_data_factory_get_container (pika->font_factory),
|
||||
pika_container_get_children_type (container),
|
||||
font_callback))
|
||||
success = FALSE;
|
||||
}
|
||||
@ -112,20 +120,21 @@ fonts_set_popup_invoker (PikaProcedure *procedure,
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
const gchar *font_callback;
|
||||
const gchar *font_name;
|
||||
PikaFont *font;
|
||||
|
||||
font_callback = g_value_get_string (pika_value_array_index (args, 0));
|
||||
font_name = g_value_get_string (pika_value_array_index (args, 1));
|
||||
font = g_value_get_object (pika_value_array_index (args, 1));
|
||||
|
||||
if (success)
|
||||
{
|
||||
PikaContainer *container = pika_data_factory_get_container (pika->font_factory);
|
||||
|
||||
if (pika->no_interface ||
|
||||
! pika_pdb_lookup_procedure (pika->pdb, font_callback) ||
|
||||
! pika_data_factory_data_wait (pika->font_factory) ||
|
||||
! pika_pdb_dialog_set (pika,
|
||||
pika_data_factory_get_container (pika->font_factory),
|
||||
font_callback, font_name,
|
||||
NULL))
|
||||
pika_container_get_children_type (container),
|
||||
font_callback, PIKA_OBJECT (font), NULL))
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
@ -167,12 +176,17 @@ register_font_select_procs (PikaPDB *pdb)
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
pika_param_spec_string ("initial-font-name",
|
||||
"initial font name",
|
||||
"The name of the initial font choice.",
|
||||
FALSE, TRUE, FALSE,
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_param_spec_font ("initial-font",
|
||||
"initial font",
|
||||
"The name of the initial font choice.",
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
g_param_spec_boxed ("parent-window",
|
||||
"parent window",
|
||||
"An optional parent window handle for the popup to be set transient to",
|
||||
G_TYPE_BYTES,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
@ -222,12 +236,11 @@ register_font_select_procs (PikaPDB *pdb)
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
pika_param_spec_string ("font-name",
|
||||
"font name",
|
||||
"The name of the font to set as selected",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_param_spec_font ("font",
|
||||
"font",
|
||||
"The font to set as selected",
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
}
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "pdb-types.h"
|
||||
|
||||
#include "core/pika.h"
|
||||
#include "core/pikacontainer.h"
|
||||
#include "core/pikadatafactory.h"
|
||||
#include "core/pikagradient.h"
|
||||
#include "core/pikaparamspecs.h"
|
||||
@ -54,14 +55,18 @@ gradients_popup_invoker (PikaProcedure *procedure,
|
||||
gboolean success = TRUE;
|
||||
const gchar *gradient_callback;
|
||||
const gchar *popup_title;
|
||||
const gchar *initial_gradient_name;
|
||||
PikaGradient *initial_gradient;
|
||||
GBytes *parent_window;
|
||||
|
||||
gradient_callback = g_value_get_string (pika_value_array_index (args, 0));
|
||||
popup_title = g_value_get_string (pika_value_array_index (args, 1));
|
||||
initial_gradient_name = g_value_get_string (pika_value_array_index (args, 2));
|
||||
initial_gradient = g_value_get_object (pika_value_array_index (args, 2));
|
||||
parent_window = g_value_get_boxed (pika_value_array_index (args, 3));
|
||||
|
||||
if (success)
|
||||
{
|
||||
PikaContainer *container = pika_data_factory_get_container (pika->gradient_factory);
|
||||
|
||||
/* Formerly, this procedure had another parameter:
|
||||
* the sample size of the gradient's data passed in the changed callback.
|
||||
* Now the sample size is determined by core, and in the future,
|
||||
@ -71,9 +76,9 @@ gradients_popup_invoker (PikaProcedure *procedure,
|
||||
if (pika->no_interface ||
|
||||
! pika_pdb_lookup_procedure (pika->pdb, gradient_callback) ||
|
||||
! pika_pdb_dialog_new (pika, context, progress,
|
||||
pika_data_factory_get_container (pika->gradient_factory),
|
||||
popup_title, gradient_callback, initial_gradient_name,
|
||||
NULL))
|
||||
pika_container_get_children_type (container),
|
||||
parent_window, popup_title, gradient_callback,
|
||||
PIKA_OBJECT (initial_gradient), NULL))
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
@ -96,9 +101,12 @@ gradients_close_popup_invoker (PikaProcedure *procedure,
|
||||
|
||||
if (success)
|
||||
{
|
||||
PikaContainer *container = pika_data_factory_get_container (pika->gradient_factory);
|
||||
|
||||
if (pika->no_interface ||
|
||||
! pika_pdb_lookup_procedure (pika->pdb, gradient_callback) ||
|
||||
! pika_pdb_dialog_close (pika, pika_data_factory_get_container (pika->gradient_factory),
|
||||
! pika_pdb_dialog_close (pika,
|
||||
pika_container_get_children_type (container),
|
||||
gradient_callback))
|
||||
success = FALSE;
|
||||
}
|
||||
@ -117,18 +125,20 @@ gradients_set_popup_invoker (PikaProcedure *procedure,
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
const gchar *gradient_callback;
|
||||
const gchar *gradient_name;
|
||||
PikaGradient *gradient;
|
||||
|
||||
gradient_callback = g_value_get_string (pika_value_array_index (args, 0));
|
||||
gradient_name = g_value_get_string (pika_value_array_index (args, 1));
|
||||
gradient = g_value_get_object (pika_value_array_index (args, 1));
|
||||
|
||||
if (success)
|
||||
{
|
||||
PikaContainer *container = pika_data_factory_get_container (pika->gradient_factory);
|
||||
|
||||
if (pika->no_interface ||
|
||||
! pika_pdb_lookup_procedure (pika->pdb, gradient_callback) ||
|
||||
! pika_pdb_dialog_set (pika, pika_data_factory_get_container (pika->gradient_factory),
|
||||
gradient_callback, gradient_name,
|
||||
NULL))
|
||||
! pika_pdb_dialog_set (pika,
|
||||
pika_container_get_children_type (container),
|
||||
gradient_callback, PIKA_OBJECT (gradient), NULL))
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
@ -170,12 +180,17 @@ register_gradient_select_procs (PikaPDB *pdb)
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
pika_param_spec_string ("initial-gradient-name",
|
||||
"initial gradient name",
|
||||
"The name of the initial gradient choice",
|
||||
FALSE, TRUE, FALSE,
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_param_spec_gradient ("initial-gradient",
|
||||
"initial gradient",
|
||||
"The initial gradient choice",
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
g_param_spec_boxed ("parent-window",
|
||||
"parent window",
|
||||
"An optional parent window handle for the popup to be set transient to",
|
||||
G_TYPE_BYTES,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
@ -225,12 +240,11 @@ register_gradient_select_procs (PikaPDB *pdb)
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
pika_param_spec_string ("gradient-name",
|
||||
"gradient name",
|
||||
"The name of the gradient to set as selected",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_param_spec_gradient ("gradient",
|
||||
"gradient",
|
||||
"The gradient to set as selected",
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
}
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include "core/pikaimage.h"
|
||||
#include "core/pikaitem.h"
|
||||
#include "core/pikalayer.h"
|
||||
#include "core/pikapalette.h"
|
||||
#include "core/pikaparamspecs.h"
|
||||
#include "core/pikapickable.h"
|
||||
#include "core/pikaprogress.h"
|
||||
@ -1575,6 +1576,35 @@ image_set_colormap_invoker (PikaProcedure *procedure,
|
||||
error ? *error : NULL);
|
||||
}
|
||||
|
||||
static PikaValueArray *
|
||||
image_get_palette_invoker (PikaProcedure *procedure,
|
||||
Pika *pika,
|
||||
PikaContext *context,
|
||||
PikaProgress *progress,
|
||||
const PikaValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
PikaValueArray *return_vals;
|
||||
PikaImage *image;
|
||||
PikaPalette *colormap = NULL;
|
||||
|
||||
image = g_value_get_object (pika_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
colormap = pika_image_get_colormap_palette (image);
|
||||
}
|
||||
|
||||
return_vals = pika_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_set_object (pika_value_array_index (return_vals, 1), colormap);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static PikaValueArray *
|
||||
image_get_metadata_invoker (PikaProcedure *procedure,
|
||||
Pika *pika,
|
||||
@ -4356,6 +4386,35 @@ register_image_procs (PikaPDB *pdb)
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* pika-image-get-palette
|
||||
*/
|
||||
procedure = pika_procedure_new (image_get_palette_invoker);
|
||||
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
||||
"pika-image-get-palette");
|
||||
pika_procedure_set_static_help (procedure,
|
||||
"Returns the image's colormap",
|
||||
"This procedure returns the image's colormap as a PikaPalette. If the image is not in Indexed color mode, %NULL is returned.",
|
||||
NULL);
|
||||
pika_procedure_set_static_attribution (procedure,
|
||||
"Jehan",
|
||||
"Jehan",
|
||||
"2023");
|
||||
pika_procedure_add_argument (procedure,
|
||||
pika_param_spec_image ("image",
|
||||
"image",
|
||||
"The image",
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_return_value (procedure,
|
||||
pika_param_spec_palette ("colormap",
|
||||
"colormap",
|
||||
"The image's colormap.",
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* pika-image-get-metadata
|
||||
*/
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "internal-procs.h"
|
||||
|
||||
|
||||
/* 775 procedures registered total */
|
||||
/* 779 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (PikaPDB *pdb)
|
||||
@ -52,6 +52,7 @@ internal_procs_init (PikaPDB *pdb)
|
||||
register_drawable_procs (pdb);
|
||||
register_drawable_color_procs (pdb);
|
||||
register_drawable_edit_procs (pdb);
|
||||
register_drawable_select_procs (pdb);
|
||||
register_dynamics_procs (pdb);
|
||||
register_edit_procs (pdb);
|
||||
register_file_procs (pdb);
|
||||
|
@ -39,6 +39,7 @@ void register_display_procs (PikaPDB *pdb);
|
||||
void register_drawable_procs (PikaPDB *pdb);
|
||||
void register_drawable_color_procs (PikaPDB *pdb);
|
||||
void register_drawable_edit_procs (PikaPDB *pdb);
|
||||
void register_drawable_select_procs (PikaPDB *pdb);
|
||||
void register_dynamics_procs (PikaPDB *pdb);
|
||||
void register_edit_procs (PikaPDB *pdb);
|
||||
void register_file_procs (PikaPDB *pdb);
|
||||
|
@ -19,6 +19,7 @@ libappinternalprocs_sources = [
|
||||
'drawable-cmds.c',
|
||||
'drawable-color-cmds.c',
|
||||
'drawable-edit-cmds.c',
|
||||
'drawable-select-cmds.c',
|
||||
'dynamics-cmds.c',
|
||||
'edit-cmds.c',
|
||||
'file-cmds.c',
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "core/pika.h"
|
||||
#include "core/pikacontext.h"
|
||||
#include "core/pikadatafactory.h"
|
||||
#include "core/pikaimage-colormap.h"
|
||||
#include "core/pikapalette.h"
|
||||
#include "core/pikaparamspecs.h"
|
||||
|
||||
@ -308,9 +309,18 @@ palette_delete_entry_invoker (PikaProcedure *procedure,
|
||||
PikaPaletteEntry *entry = pika_palette_get_entry (palette, entry_num);
|
||||
|
||||
if (entry)
|
||||
pika_palette_delete_entry (palette, entry);
|
||||
{
|
||||
PikaImage *image = pika_data_get_image (PIKA_DATA (palette));
|
||||
|
||||
if (image != NULL)
|
||||
success = pika_image_delete_colormap_entry (image, entry_num, TRUE);
|
||||
else
|
||||
pika_palette_delete_entry (palette, entry);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
@ -376,7 +386,7 @@ palette_entry_set_color_invoker (PikaProcedure *procedure,
|
||||
if (success)
|
||||
{
|
||||
if (pika_data_is_writable (PIKA_DATA (palette)))
|
||||
success = pika_palette_set_entry_color (palette, entry_num, &color);
|
||||
success = pika_palette_set_entry_color (palette, entry_num, &color, TRUE);
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
@ -687,7 +697,8 @@ register_palette_procs (PikaPDB *pdb)
|
||||
"pika-palette-delete-entry");
|
||||
pika_procedure_set_static_help (procedure,
|
||||
"Deletes an entry from the palette.",
|
||||
"Deletes an entry from the palette. Returns an error if the index is out or range. Returns an error if the palette is not editable.",
|
||||
"This function will fail and return %FALSE if the index is out or range or if the palette is not editable.\n"
|
||||
"Additionally if the palette belongs to an indexed image, it will only be possible to delete palette colors not in use in the image.",
|
||||
NULL);
|
||||
pika_procedure_set_static_attribution (procedure,
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
|
@ -34,7 +34,9 @@
|
||||
#include "pdb-types.h"
|
||||
|
||||
#include "core/pika.h"
|
||||
#include "core/pikacontainer.h"
|
||||
#include "core/pikadatafactory.h"
|
||||
#include "core/pikapalette.h"
|
||||
#include "core/pikaparamspecs.h"
|
||||
|
||||
#include "pikapdb.h"
|
||||
@ -53,20 +55,24 @@ palettes_popup_invoker (PikaProcedure *procedure,
|
||||
gboolean success = TRUE;
|
||||
const gchar *palette_callback;
|
||||
const gchar *popup_title;
|
||||
const gchar *initial_palette_name;
|
||||
PikaPalette *initial_palette;
|
||||
GBytes *parent_window;
|
||||
|
||||
palette_callback = g_value_get_string (pika_value_array_index (args, 0));
|
||||
popup_title = g_value_get_string (pika_value_array_index (args, 1));
|
||||
initial_palette_name = g_value_get_string (pika_value_array_index (args, 2));
|
||||
initial_palette = g_value_get_object (pika_value_array_index (args, 2));
|
||||
parent_window = g_value_get_boxed (pika_value_array_index (args, 3));
|
||||
|
||||
if (success)
|
||||
{
|
||||
PikaContainer *container = pika_data_factory_get_container (pika->palette_factory);
|
||||
|
||||
if (pika->no_interface ||
|
||||
! pika_pdb_lookup_procedure (pika->pdb, palette_callback) ||
|
||||
! pika_pdb_dialog_new (pika, context, progress,
|
||||
pika_data_factory_get_container (pika->palette_factory),
|
||||
popup_title, palette_callback, initial_palette_name,
|
||||
NULL))
|
||||
pika_container_get_children_type (container),
|
||||
parent_window, popup_title, palette_callback,
|
||||
PIKA_OBJECT (initial_palette), NULL))
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
@ -89,9 +95,12 @@ palettes_close_popup_invoker (PikaProcedure *procedure,
|
||||
|
||||
if (success)
|
||||
{
|
||||
PikaContainer *container = pika_data_factory_get_container (pika->palette_factory);
|
||||
|
||||
if (pika->no_interface ||
|
||||
! pika_pdb_lookup_procedure (pika->pdb, palette_callback) ||
|
||||
! pika_pdb_dialog_close (pika, pika_data_factory_get_container (pika->palette_factory),
|
||||
! pika_pdb_dialog_close (pika,
|
||||
pika_container_get_children_type (container),
|
||||
palette_callback))
|
||||
success = FALSE;
|
||||
}
|
||||
@ -110,18 +119,20 @@ palettes_set_popup_invoker (PikaProcedure *procedure,
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
const gchar *palette_callback;
|
||||
const gchar *palette_name;
|
||||
PikaPalette *palette;
|
||||
|
||||
palette_callback = g_value_get_string (pika_value_array_index (args, 0));
|
||||
palette_name = g_value_get_string (pika_value_array_index (args, 1));
|
||||
palette = g_value_get_object (pika_value_array_index (args, 1));
|
||||
|
||||
if (success)
|
||||
{
|
||||
PikaContainer *container = pika_data_factory_get_container (pika->palette_factory);
|
||||
|
||||
if (pika->no_interface ||
|
||||
! pika_pdb_lookup_procedure (pika->pdb, palette_callback) ||
|
||||
! pika_pdb_dialog_set (pika, pika_data_factory_get_container (pika->palette_factory),
|
||||
palette_callback, palette_name,
|
||||
NULL))
|
||||
! pika_pdb_dialog_set (pika,
|
||||
pika_container_get_children_type (container),
|
||||
palette_callback, PIKA_OBJECT (palette), NULL))
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
@ -163,12 +174,17 @@ register_palette_select_procs (PikaPDB *pdb)
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
pika_param_spec_string ("initial-palette-name",
|
||||
"initial palette name",
|
||||
"The name of the palette to set as the initial choice.",
|
||||
FALSE, TRUE, FALSE,
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_param_spec_palette ("initial-palette",
|
||||
"initial palette",
|
||||
"The palette to set as the initial choice.",
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
g_param_spec_boxed ("parent-window",
|
||||
"parent window",
|
||||
"An optional parent window handle for the popup to be set transient to",
|
||||
G_TYPE_BYTES,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
@ -218,12 +234,11 @@ register_palette_select_procs (PikaPDB *pdb)
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
pika_param_spec_string ("palette-name",
|
||||
"palette name",
|
||||
"The name of the palette to set as selected",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_param_spec_palette ("palette",
|
||||
"palette",
|
||||
"The palette to set as selected",
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ register_pattern_procs (PikaPDB *pdb)
|
||||
"pika-pattern-get-pixels");
|
||||
pika_procedure_set_static_help (procedure,
|
||||
"Gets information about the pattern (including pixels).",
|
||||
"Gets information about the pattern: the pattern extents (width and height), its bpp, and its pixel data. The pixel data is an array in C or a list in some languages.",
|
||||
"Gets information about the pattern: the pattern extents (width and height), its bpp, and its pixel data.",
|
||||
NULL);
|
||||
pika_procedure_set_static_attribution (procedure,
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
|
@ -34,8 +34,10 @@
|
||||
#include "pdb-types.h"
|
||||
|
||||
#include "core/pika.h"
|
||||
#include "core/pikacontainer.h"
|
||||
#include "core/pikadatafactory.h"
|
||||
#include "core/pikaparamspecs.h"
|
||||
#include "core/pikapattern.h"
|
||||
|
||||
#include "pikapdb.h"
|
||||
#include "pikaprocedure.h"
|
||||
@ -53,20 +55,24 @@ patterns_popup_invoker (PikaProcedure *procedure,
|
||||
gboolean success = TRUE;
|
||||
const gchar *pattern_callback;
|
||||
const gchar *popup_title;
|
||||
const gchar *initial_pattern_name;
|
||||
PikaPattern *initial_pattern;
|
||||
GBytes *parent_window;
|
||||
|
||||
pattern_callback = g_value_get_string (pika_value_array_index (args, 0));
|
||||
popup_title = g_value_get_string (pika_value_array_index (args, 1));
|
||||
initial_pattern_name = g_value_get_string (pika_value_array_index (args, 2));
|
||||
initial_pattern = g_value_get_object (pika_value_array_index (args, 2));
|
||||
parent_window = g_value_get_boxed (pika_value_array_index (args, 3));
|
||||
|
||||
if (success)
|
||||
{
|
||||
PikaContainer *container = pika_data_factory_get_container (pika->pattern_factory);
|
||||
|
||||
if (pika->no_interface ||
|
||||
! pika_pdb_lookup_procedure (pika->pdb, pattern_callback) ||
|
||||
! pika_pdb_dialog_new (pika, context, progress,
|
||||
pika_data_factory_get_container (pika->pattern_factory),
|
||||
popup_title, pattern_callback, initial_pattern_name,
|
||||
NULL))
|
||||
pika_container_get_children_type (container),
|
||||
parent_window, popup_title, pattern_callback,
|
||||
PIKA_OBJECT (initial_pattern), NULL))
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
@ -89,9 +95,12 @@ patterns_close_popup_invoker (PikaProcedure *procedure,
|
||||
|
||||
if (success)
|
||||
{
|
||||
PikaContainer *container = pika_data_factory_get_container (pika->pattern_factory);
|
||||
|
||||
if (pika->no_interface ||
|
||||
! pika_pdb_lookup_procedure (pika->pdb, pattern_callback) ||
|
||||
! pika_pdb_dialog_close (pika, pika_data_factory_get_container (pika->pattern_factory),
|
||||
! pika_pdb_dialog_close (pika,
|
||||
pika_container_get_children_type (container),
|
||||
pattern_callback))
|
||||
success = FALSE;
|
||||
}
|
||||
@ -110,18 +119,20 @@ patterns_set_popup_invoker (PikaProcedure *procedure,
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
const gchar *pattern_callback;
|
||||
const gchar *pattern_name;
|
||||
PikaPattern *pattern;
|
||||
|
||||
pattern_callback = g_value_get_string (pika_value_array_index (args, 0));
|
||||
pattern_name = g_value_get_string (pika_value_array_index (args, 1));
|
||||
pattern = g_value_get_object (pika_value_array_index (args, 1));
|
||||
|
||||
if (success)
|
||||
{
|
||||
PikaContainer *container = pika_data_factory_get_container (pika->pattern_factory);
|
||||
|
||||
if (pika->no_interface ||
|
||||
! pika_pdb_lookup_procedure (pika->pdb, pattern_callback) ||
|
||||
! pika_pdb_dialog_set (pika, pika_data_factory_get_container (pika->pattern_factory),
|
||||
pattern_callback, pattern_name,
|
||||
NULL))
|
||||
! pika_pdb_dialog_set (pika,
|
||||
pika_container_get_children_type (container),
|
||||
pattern_callback, PIKA_OBJECT (pattern), NULL))
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
@ -163,12 +174,17 @@ register_pattern_select_procs (PikaPDB *pdb)
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
pika_param_spec_string ("initial-pattern-name",
|
||||
"initial pattern name",
|
||||
"The name of the pattern to set as the initial choice",
|
||||
FALSE, TRUE, FALSE,
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_param_spec_pattern ("initial-pattern",
|
||||
"initial pattern",
|
||||
"The pattern to set as the initial choice",
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
g_param_spec_boxed ("parent-window",
|
||||
"parent window",
|
||||
"An optional parent window handle for the popup to be set transient to",
|
||||
G_TYPE_BYTES,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
@ -218,12 +234,11 @@ register_pattern_select_procs (PikaPDB *pdb)
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
pika_param_spec_string ("pattern-name",
|
||||
"pattern name",
|
||||
"The name of the pattern to set as selected",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_param_spec_pattern ("pattern",
|
||||
"pattern",
|
||||
"The pattern to set as selected",
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
}
|
||||
|
@ -1167,47 +1167,6 @@ pdb_get_data_invoker (PikaProcedure *procedure,
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static PikaValueArray *
|
||||
pdb_get_data_size_invoker (PikaProcedure *procedure,
|
||||
Pika *pika,
|
||||
PikaContext *context,
|
||||
PikaProgress *progress,
|
||||
const PikaValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
PikaValueArray *return_vals;
|
||||
const gchar *identifier;
|
||||
gint bytes = 0;
|
||||
|
||||
identifier = g_value_get_string (pika_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (pika_is_canonical_identifier (identifier))
|
||||
{
|
||||
if (! pika_plug_in_manager_get_data (pika->plug_in_manager,
|
||||
identifier, &bytes))
|
||||
success = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
|
||||
_("Data label '%s' is not a canonical identifier"),
|
||||
identifier);
|
||||
success = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return_vals = pika_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_set_int (pika_value_array_index (return_vals, 1), bytes);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static PikaValueArray *
|
||||
pdb_set_data_invoker (PikaProcedure *procedure,
|
||||
Pika *pika,
|
||||
@ -2230,36 +2189,6 @@ register_pdb_procs (PikaPDB *pdb)
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* pika-pdb-get-data-size
|
||||
*/
|
||||
procedure = pika_procedure_new (pdb_get_data_size_invoker);
|
||||
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
||||
"pika-pdb-get-data-size");
|
||||
pika_procedure_set_static_help (procedure,
|
||||
"Returns size of data associated with the specified identifier.",
|
||||
"This procedure returns the size of any data which may have been associated with the specified identifier. If no data has been associated with the identifier, an error is returned.",
|
||||
NULL);
|
||||
pika_procedure_set_static_attribution (procedure,
|
||||
"Nick Lamb",
|
||||
"Nick Lamb",
|
||||
"1998");
|
||||
pika_procedure_add_argument (procedure,
|
||||
pika_param_spec_string ("identifier",
|
||||
"identifier",
|
||||
"The identifier associated with data",
|
||||
FALSE, FALSE, TRUE,
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_return_value (procedure,
|
||||
g_param_spec_int ("bytes",
|
||||
"bytes",
|
||||
"The number of bytes in the data",
|
||||
1, G_MAXINT32, 1,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* pika-pdb-set-data
|
||||
*/
|
||||
|
@ -105,6 +105,91 @@ pika_pdb_get_data_factory (Pika *pika,
|
||||
g_return_val_if_reached (NULL);
|
||||
}
|
||||
|
||||
GList *
|
||||
pika_pdb_get_resources (Pika *pika,
|
||||
GType data_type,
|
||||
const gchar *name,
|
||||
PikaPDBDataAccess access,
|
||||
GError **error)
|
||||
{
|
||||
GList *resources;
|
||||
PikaDataFactory *factory;
|
||||
PikaContainer *container;
|
||||
const gchar *label;
|
||||
|
||||
g_return_val_if_fail (PIKA_IS_PIKA (pika), NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
label = pika_pdb_get_data_label (data_type);
|
||||
|
||||
if (! name || ! strlen (name))
|
||||
{
|
||||
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
|
||||
/* TRANSLATOR: %s is a data label from the
|
||||
* PDB-error-data-label context.
|
||||
*/
|
||||
C_("PDB-error-message", "%s name cannot be empty"),
|
||||
g_type_name (data_type));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
factory = pika_pdb_get_data_factory (pika, data_type);
|
||||
g_return_val_if_fail (PIKA_IS_DATA_FACTORY (factory), NULL);
|
||||
|
||||
container = pika_data_factory_get_container (factory);
|
||||
resources = pika_container_get_children_by_name (container, name);
|
||||
|
||||
if (! resources && ! strcmp (name, "Standard"))
|
||||
{
|
||||
PikaData *resource;
|
||||
|
||||
resource = pika_data_factory_data_get_standard (factory, pika_get_user_context (pika));
|
||||
g_return_val_if_fail (resource != NULL, NULL);
|
||||
resources = g_list_prepend (NULL, resource);
|
||||
}
|
||||
|
||||
if (! resources)
|
||||
{
|
||||
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
|
||||
/* TRANSLATOR: the first %s is a data label from the
|
||||
* PDB-error-data-label context. The second %s is a data
|
||||
* name.
|
||||
*/
|
||||
C_("PDB-error-message", "%s '%s' not found"), label, name);
|
||||
}
|
||||
else if ((access & PIKA_PDB_DATA_ACCESS_WRITE) ||
|
||||
(access & PIKA_PDB_DATA_ACCESS_RENAME))
|
||||
{
|
||||
for (GList *iter = resources; iter; iter = iter->next)
|
||||
{
|
||||
if ((access & PIKA_PDB_DATA_ACCESS_WRITE) &&
|
||||
! pika_data_is_writable (PIKA_DATA (iter->data)))
|
||||
{
|
||||
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
|
||||
/* TRANSLATOR: the first %s is a data label from the
|
||||
* PDB-error-data-label context. The second %s is a data
|
||||
* name.
|
||||
*/
|
||||
C_("PDB-error-message", "%s '%s' is not editable"), label, name);
|
||||
return NULL;
|
||||
}
|
||||
else if ((access & PIKA_PDB_DATA_ACCESS_RENAME) &&
|
||||
! pika_viewable_is_name_editable (PIKA_VIEWABLE (iter->data)))
|
||||
{
|
||||
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
|
||||
/* TRANSLATOR: the first %s is a data label from the
|
||||
* PDB-error-data-label context. The second %s is a data
|
||||
* name.
|
||||
*/
|
||||
C_("PDB-error-message", "%s '%s' is not renamable"), label, name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resources;
|
||||
}
|
||||
|
||||
PikaResource *
|
||||
pika_pdb_get_resource (Pika *pika,
|
||||
GType data_type,
|
||||
|
@ -26,6 +26,11 @@
|
||||
PikaDataFactory * pika_pdb_get_data_factory (Pika *pika,
|
||||
GType data_type);
|
||||
|
||||
GList * pika_pdb_get_resources (Pika *pika,
|
||||
GType data_type,
|
||||
const gchar *name,
|
||||
PikaPDBDataAccess access,
|
||||
GError **error);
|
||||
PikaResource * pika_pdb_get_resource (Pika *pika,
|
||||
GType data_type,
|
||||
const gchar *name,
|
||||
|
@ -193,14 +193,14 @@ progress_get_window_handle_invoker (PikaProcedure *procedure,
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
PikaValueArray *return_vals;
|
||||
gint window = 0;
|
||||
GBytes *handle = NULL;
|
||||
|
||||
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
|
||||
|
||||
if (plug_in && plug_in->open)
|
||||
{
|
||||
if (! pika->no_interface)
|
||||
window = pika_plug_in_progress_get_window_id (plug_in);
|
||||
handle = pika_plug_in_progress_get_window_id (plug_in);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
@ -209,7 +209,7 @@ progress_get_window_handle_invoker (PikaProcedure *procedure,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_set_int (pika_value_array_index (return_vals, 1), window);
|
||||
g_value_take_boxed (pika_value_array_index (return_vals, 1), handle);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
@ -418,19 +418,20 @@ register_progress_procs (PikaPDB *pdb)
|
||||
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
||||
"pika-progress-get-window-handle");
|
||||
pika_procedure_set_static_help (procedure,
|
||||
"Returns the native window ID of the toplevel window this plug-in's progress is displayed in.",
|
||||
"This function returns the native window ID of the toplevel window this plug-in\'s progress is displayed in.",
|
||||
"Returns the native handle of the toplevel window this plug-in's progress is displayed in.",
|
||||
"This function returns the native handle allowing to identify the toplevel window this plug-in's progress is displayed in.\n"
|
||||
"This handle can be of various types (integer, string, etc.) depending on the platform you are running on which is why it returns a GBytes. There are usually no reasons to call this directly.",
|
||||
NULL);
|
||||
pika_procedure_set_static_attribution (procedure,
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
"Michael Natterer",
|
||||
"2004");
|
||||
pika_procedure_add_return_value (procedure,
|
||||
g_param_spec_int ("window",
|
||||
"window",
|
||||
"The progress bar's toplevel window",
|
||||
G_MININT32, G_MAXINT32, 0,
|
||||
PIKA_PARAM_READWRITE));
|
||||
g_param_spec_boxed ("handle",
|
||||
"handle",
|
||||
"The progress bar's toplevel window's handle",
|
||||
G_TYPE_BYTES,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
|
@ -67,14 +67,14 @@ text_layer_new_invoker (PikaProcedure *procedure,
|
||||
PikaValueArray *return_vals;
|
||||
PikaImage *image;
|
||||
const gchar *text;
|
||||
const gchar *fontname;
|
||||
PikaFont *font;
|
||||
gdouble size;
|
||||
PikaUnit unit;
|
||||
PikaTextLayer *layer = NULL;
|
||||
|
||||
image = g_value_get_object (pika_value_array_index (args, 0));
|
||||
text = g_value_get_string (pika_value_array_index (args, 1));
|
||||
fontname = g_value_get_string (pika_value_array_index (args, 2));
|
||||
font = g_value_get_object (pika_value_array_index (args, 2));
|
||||
size = g_value_get_double (pika_value_array_index (args, 3));
|
||||
unit = g_value_get_int (pika_value_array_index (args, 4));
|
||||
|
||||
@ -87,7 +87,7 @@ text_layer_new_invoker (PikaProcedure *procedure,
|
||||
|
||||
pika_text = g_object_new (PIKA_TYPE_TEXT,
|
||||
"text", text,
|
||||
"font", fontname,
|
||||
"font", font,
|
||||
"font-size", size,
|
||||
"font-size-unit", unit,
|
||||
"color", &color,
|
||||
@ -259,26 +259,26 @@ text_layer_get_font_invoker (PikaProcedure *procedure,
|
||||
gboolean success = TRUE;
|
||||
PikaValueArray *return_vals;
|
||||
PikaTextLayer *layer;
|
||||
gchar *font = NULL;
|
||||
PikaFont *font = NULL;
|
||||
|
||||
layer = g_value_get_object (pika_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
PikaFont *font_obj;
|
||||
|
||||
g_object_get (pika_text_layer_get_text (layer),
|
||||
"font", &font_obj,
|
||||
"font", &font,
|
||||
NULL);
|
||||
font = g_strdup (pika_font_get_lookup_name (font_obj));
|
||||
g_object_unref (font_obj);
|
||||
/* The PikaText keeps a reference. Therefore unref before returning the
|
||||
* pointer so that we don't leak a reference.
|
||||
*/
|
||||
g_object_unref (font);
|
||||
}
|
||||
|
||||
return_vals = pika_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_take_string (pika_value_array_index (return_vals, 1), font);
|
||||
g_value_set_object (pika_value_array_index (return_vals, 1), font);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
@ -293,10 +293,10 @@ text_layer_set_font_invoker (PikaProcedure *procedure,
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
PikaTextLayer *layer;
|
||||
const gchar *font;
|
||||
PikaFont *font;
|
||||
|
||||
layer = g_value_get_object (pika_value_array_index (args, 0));
|
||||
font = g_value_get_string (pika_value_array_index (args, 1));
|
||||
font = g_value_get_object (pika_value_array_index (args, 1));
|
||||
|
||||
if (success)
|
||||
{
|
||||
@ -1028,12 +1028,11 @@ register_text_layer_procs (PikaPDB *pdb)
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
pika_param_spec_string ("fontname",
|
||||
"fontname",
|
||||
"The name of the font",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_param_spec_font ("font",
|
||||
"font",
|
||||
"The font to write the text with",
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
g_param_spec_double ("size",
|
||||
"size",
|
||||
@ -1186,7 +1185,7 @@ register_text_layer_procs (PikaPDB *pdb)
|
||||
"pika-text-layer-get-font");
|
||||
pika_procedure_set_static_help (procedure,
|
||||
"Get the font from a text layer as string.",
|
||||
"This procedure returns the name of the font from a text layer.",
|
||||
"This procedure returns the font from a text layer.",
|
||||
NULL);
|
||||
pika_procedure_set_static_attribution (procedure,
|
||||
"Marcus Heese <heese@cip.ifi.lmu.de>",
|
||||
@ -1199,12 +1198,11 @@ register_text_layer_procs (PikaPDB *pdb)
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_return_value (procedure,
|
||||
pika_param_spec_string ("font",
|
||||
"font",
|
||||
"The font which is used in the specified text layer.",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_param_spec_font ("font",
|
||||
"font",
|
||||
"The font which is used in the specified text layer.",
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
@ -1229,12 +1227,11 @@ register_text_layer_procs (PikaPDB *pdb)
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
pika_param_spec_string ("font",
|
||||
"font",
|
||||
"The new font to use",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_param_spec_font ("font",
|
||||
"font",
|
||||
"The new font to use",
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "core/pikaimage.h"
|
||||
#include "core/pikalayer.h"
|
||||
#include "core/pikaparamspecs.h"
|
||||
#include "text/pikafont.h"
|
||||
#include "text/pikatext-compat.h"
|
||||
|
||||
#include "pikapdb.h"
|
||||
@ -48,12 +49,12 @@
|
||||
|
||||
|
||||
static PikaValueArray *
|
||||
text_fontname_invoker (PikaProcedure *procedure,
|
||||
Pika *pika,
|
||||
PikaContext *context,
|
||||
PikaProgress *progress,
|
||||
const PikaValueArray *args,
|
||||
GError **error)
|
||||
text_font_invoker (PikaProcedure *procedure,
|
||||
Pika *pika,
|
||||
PikaContext *context,
|
||||
PikaProgress *progress,
|
||||
const PikaValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
PikaValueArray *return_vals;
|
||||
@ -65,7 +66,7 @@ text_fontname_invoker (PikaProcedure *procedure,
|
||||
gint border;
|
||||
gboolean antialias;
|
||||
gdouble size;
|
||||
const gchar *fontname;
|
||||
PikaFont *font;
|
||||
PikaLayer *text_layer = NULL;
|
||||
|
||||
image = g_value_get_object (pika_value_array_index (args, 0));
|
||||
@ -76,7 +77,7 @@ text_fontname_invoker (PikaProcedure *procedure,
|
||||
border = g_value_get_int (pika_value_array_index (args, 5));
|
||||
antialias = g_value_get_boolean (pika_value_array_index (args, 6));
|
||||
size = g_value_get_double (pika_value_array_index (args, 7));
|
||||
fontname = g_value_get_string (pika_value_array_index (args, 9));
|
||||
font = g_value_get_object (pika_value_array_index (args, 8));
|
||||
|
||||
if (success)
|
||||
{
|
||||
@ -87,15 +88,9 @@ text_fontname_invoker (PikaProcedure *procedure,
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
gchar *real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size);
|
||||
|
||||
text_layer = text_render (image, drawable, context,
|
||||
x, y, real_fontname, text,
|
||||
border, antialias);
|
||||
|
||||
g_free (real_fontname);
|
||||
}
|
||||
text_layer = text_render (image, drawable, context,
|
||||
x, y, font, size, text,
|
||||
border, antialias);
|
||||
}
|
||||
|
||||
return_vals = pika_procedure_get_return_values (procedure, success,
|
||||
@ -108,18 +103,18 @@ text_fontname_invoker (PikaProcedure *procedure,
|
||||
}
|
||||
|
||||
static PikaValueArray *
|
||||
text_get_extents_fontname_invoker (PikaProcedure *procedure,
|
||||
Pika *pika,
|
||||
PikaContext *context,
|
||||
PikaProgress *progress,
|
||||
const PikaValueArray *args,
|
||||
GError **error)
|
||||
text_get_extents_font_invoker (PikaProcedure *procedure,
|
||||
Pika *pika,
|
||||
PikaContext *context,
|
||||
PikaProgress *progress,
|
||||
const PikaValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
PikaValueArray *return_vals;
|
||||
const gchar *text;
|
||||
gdouble size;
|
||||
const gchar *fontname;
|
||||
PikaFont *font;
|
||||
gint width = 0;
|
||||
gint height = 0;
|
||||
gint ascent = 0;
|
||||
@ -127,18 +122,14 @@ text_get_extents_fontname_invoker (PikaProcedure *procedure,
|
||||
|
||||
text = g_value_get_string (pika_value_array_index (args, 0));
|
||||
size = g_value_get_double (pika_value_array_index (args, 1));
|
||||
fontname = g_value_get_string (pika_value_array_index (args, 3));
|
||||
font = g_value_get_object (pika_value_array_index (args, 2));
|
||||
|
||||
if (success)
|
||||
{
|
||||
gchar *real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size);
|
||||
|
||||
success = text_get_extents (pika,
|
||||
real_fontname, text,
|
||||
font, size, text,
|
||||
&width, &height,
|
||||
&ascent, &descent);
|
||||
|
||||
g_free (real_fontname);
|
||||
}
|
||||
|
||||
return_vals = pika_procedure_get_return_values (procedure, success,
|
||||
@ -161,14 +152,15 @@ register_text_tool_procs (PikaPDB *pdb)
|
||||
PikaProcedure *procedure;
|
||||
|
||||
/*
|
||||
* pika-text-fontname
|
||||
* pika-text-font
|
||||
*/
|
||||
procedure = pika_procedure_new (text_fontname_invoker);
|
||||
procedure = pika_procedure_new (text_font_invoker);
|
||||
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
||||
"pika-text-fontname");
|
||||
"pika-text-font");
|
||||
pika_procedure_set_static_help (procedure,
|
||||
"Add text at the specified location as a floating selection or a new layer.",
|
||||
"This tool requires a fontname matching an installed PangoFT2 font. You can specify the fontsize in units of pixels or points, and the appropriate metric is specified using the size_type argument. The x and y parameters together control the placement of the new text by specifying the upper left corner of the text bounding box. If the specified drawable parameter is valid, the text will be created as a floating selection attached to the drawable. If the drawable parameter is not valid (%NULL), the text will appear as a new layer. Finally, a border can be specified around the final rendered text. The border is measured in pixels. Parameter size-type is not used and is currently ignored. If you need to display a font in points, divide the size in points by 72.0 and multiply it by the image's vertical resolution.",
|
||||
"The x and y parameters together control the placement of the new text by specifying the upper left corner of the text bounding box. If the specified drawable parameter is valid, the text will be created as a floating selection attached to the drawable. If the drawable parameter is not valid (%NULL), the text will appear as a new layer. Finally, a border can be specified around the final rendered text. The border is measured in pixels.\n"
|
||||
"The size is always in pixels. If you need to display a font in points, divide the size in points by 72.0 and multiply it by the image's vertical resolution.",
|
||||
NULL);
|
||||
pika_procedure_set_static_attribution (procedure,
|
||||
"Martin Edlman & Sven Neumann",
|
||||
@ -220,23 +212,15 @@ register_text_tool_procs (PikaPDB *pdb)
|
||||
pika_procedure_add_argument (procedure,
|
||||
g_param_spec_double ("size",
|
||||
"size",
|
||||
"The size of text in either pixels or points",
|
||||
"The size of text in pixels",
|
||||
0, G_MAXDOUBLE, 0,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
g_param_spec_enum ("size-type",
|
||||
"size type",
|
||||
"The units of specified size",
|
||||
PIKA_TYPE_SIZE_TYPE,
|
||||
PIKA_PIXELS,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
pika_param_spec_string ("fontname",
|
||||
"fontname",
|
||||
"The name of the font",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_param_spec_font ("font",
|
||||
"font",
|
||||
"The font",
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_return_value (procedure,
|
||||
pika_param_spec_layer ("text-layer",
|
||||
"text layer",
|
||||
@ -247,14 +231,16 @@ register_text_tool_procs (PikaPDB *pdb)
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* pika-text-get-extents-fontname
|
||||
* pika-text-get-extents-font
|
||||
*/
|
||||
procedure = pika_procedure_new (text_get_extents_fontname_invoker);
|
||||
procedure = pika_procedure_new (text_get_extents_font_invoker);
|
||||
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
||||
"pika-text-get-extents-fontname");
|
||||
"pika-text-get-extents-font");
|
||||
pika_procedure_set_static_help (procedure,
|
||||
"Get extents of the bounding box for the specified text.",
|
||||
"This tool returns the width and height of a bounding box for the specified text string with the specified font information. Ascent and descent for the specified font are returned as well. Parameter size-type is not used and is currently ignored. If you need to display a font in points, divide the size in points by 72.0 and multiply it by the vertical resolution of the image you are taking into account.",
|
||||
"This tool returns the width and height of a bounding box for the specified text rendered with the specified font information. Ascent and descent of the glyph extents are returned as well.\n"
|
||||
"The ascent is the distance from the baseline to the highest point of the character. This is positive if the glyph ascends above the baseline. The descent is the distance from the baseline to the lowest point of the character. This is positive if the glyph descends below the baseline.\n"
|
||||
"The size is always in pixels. If you need to set a font in points, divide the size in points by 72.0 and multiply it by the vertical resolution of the image you are taking into account.",
|
||||
NULL);
|
||||
pika_procedure_set_static_attribution (procedure,
|
||||
"Martin Edlman & Sven Neumann",
|
||||
@ -274,41 +260,33 @@ register_text_tool_procs (PikaPDB *pdb)
|
||||
0, G_MAXDOUBLE, 0,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
g_param_spec_enum ("size-type",
|
||||
"size type",
|
||||
"The units of specified size",
|
||||
PIKA_TYPE_SIZE_TYPE,
|
||||
PIKA_PIXELS,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_argument (procedure,
|
||||
pika_param_spec_string ("fontname",
|
||||
"fontname",
|
||||
"The name of the font",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_param_spec_font ("font",
|
||||
"font",
|
||||
"The name of the font",
|
||||
FALSE,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_return_value (procedure,
|
||||
g_param_spec_int ("width",
|
||||
"width",
|
||||
"The width of the specified font",
|
||||
"The width of the glyph extents",
|
||||
G_MININT32, G_MAXINT32, 0,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_return_value (procedure,
|
||||
g_param_spec_int ("height",
|
||||
"height",
|
||||
"The height of the specified font",
|
||||
"The height of the glyph extents",
|
||||
G_MININT32, G_MAXINT32, 0,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_return_value (procedure,
|
||||
g_param_spec_int ("ascent",
|
||||
"ascent",
|
||||
"The ascent of the specified font",
|
||||
"The ascent of the glyph extents",
|
||||
G_MININT32, G_MAXINT32, 0,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_procedure_add_return_value (procedure,
|
||||
g_param_spec_int ("descent",
|
||||
"descent",
|
||||
"The descent of the specified font",
|
||||
"The descent of the glyph extents",
|
||||
G_MININT32, G_MAXINT32, 0,
|
||||
PIKA_PARAM_READWRITE));
|
||||
pika_pdb_register_procedure (pdb, procedure);
|
||||
|
Reference in New Issue
Block a user