libgimp: new gimp_procedure_dialog_get_preview_from_drawable() function.

This allows plug-in developers to create GimpPreviewDrawable widgets
with the procedure dialog API.
This commit is contained in:
Stanislav Grinkov 2024-02-03 18:03:32 +06:00
parent e9f24beb6b
commit 31b4e8122b
No known key found for this signature in database
GPG Key ID: F9FF16FBCBF58578
3 changed files with 46 additions and 0 deletions

View File

@ -1373,6 +1373,46 @@ gimp_procedure_dialog_get_size_entry (GimpProcedureDialog *dialog,
return widget;
}
/**
* gimp_procedure_dialog_get_drawable_preview:
* @dialog: the #GimpProcedureDialog.
* @preview_id: the ID of #GimpDrawablePreview.
* @drawable: the #GimpDrawable.
*
* Gets or creates a new #GimpDrawablePreview for @drawable.
* If a widget with the @preview_id has already been created for
* this procedure, it will be returned instead.
*
* The @preview_id ID can later be used together with property names
* to be packed in other containers or inside @dialog itself.
* Returns: (transfer none): the #GtkWidget representing @preview_id. The
* object belongs to @dialog and must not be
* freed.
*/
GtkWidget *
gimp_procedure_dialog_get_drawable_preview (GimpProcedureDialog *dialog,
const gchar *preview_id,
GimpDrawable *drawable)
{
GtkWidget *w = g_hash_table_lookup (dialog->priv->widgets, preview_id);
if (w != NULL)
{
g_warning ("%s: preview_from_drawable identifier '%s' was already configured.",
G_STRFUNC, preview_id);
return w;
}
w = gimp_drawable_preview_new_from_drawable (drawable);
g_hash_table_insert (dialog->priv->widgets, g_strdup (preview_id), w);
if (g_object_is_floating (w))
g_object_ref_sink (w);
return w;
}
/**
* gimp_procedure_dialog_get_label:
* @dialog: the #GimpProcedureDialog.

View File

@ -113,6 +113,11 @@ GtkWidget * gimp_procedure_dialog_get_file_chooser (GimpProcedureDialog *dialog
const gchar *property,
GtkFileChooserAction action);
GtkWidget * gimp_procedure_dialog_get_drawable_preview
(GimpProcedureDialog *dialog,
const gchar *preview_id,
GimpDrawable *drawable);
GtkWidget * gimp_procedure_dialog_fill_box (GimpProcedureDialog *dialog,
const gchar *container_id,
const gchar *first_property,

View File

@ -47,6 +47,7 @@ EXPORTS
gimp_procedure_dialog_fill_paned
gimp_procedure_dialog_fill_scrolled_window
gimp_procedure_dialog_get_color_widget
gimp_procedure_dialog_get_drawable_preview
gimp_procedure_dialog_get_file_chooser
gimp_procedure_dialog_get_int_combo
gimp_procedure_dialog_get_int_radio