app, libgimp, pdb: new gimp_display_present() PDB call.

This commit is contained in:
Jehan 2021-04-30 03:39:23 +02:00
parent aba721ae68
commit 7eaa4f1ca9
9 changed files with 138 additions and 3 deletions

View File

@ -186,6 +186,17 @@ gimp_display_get_by_id (Gimp *gimp,
return NULL;
}
gboolean
gimp_display_present (GimpDisplay *display)
{
g_return_val_if_fail (GIMP_IS_DISPLAY (display), FALSE);
if (GIMP_DISPLAY_GET_CLASS (display)->present)
return GIMP_DISPLAY_GET_CLASS (display)->present (display);
return FALSE;
}
Gimp *
gimp_display_get_gimp (GimpDisplay *display)
{

View File

@ -46,6 +46,8 @@ struct _GimpDisplay
struct _GimpDisplayClass
{
GimpObjectClass parent_class;
gboolean (* present) (GimpDisplay *display);
};
@ -55,6 +57,8 @@ gint gimp_display_get_id (GimpDisplay *display);
GimpDisplay * gimp_display_get_by_id (Gimp *gimp,
gint id);
gboolean gimp_display_present (GimpDisplay *display);
Gimp * gimp_display_get_gimp (GimpDisplay *display);

View File

@ -93,6 +93,8 @@ static void gimp_display_get_property (GObject *object
GValue *value,
GParamSpec *pspec);
static gboolean gimp_display_impl_present (GimpDisplay *display);
static GimpProgress * gimp_display_progress_start (GimpProgress *progress,
gboolean cancellable,
const gchar *message);
@ -132,11 +134,14 @@ G_DEFINE_TYPE_WITH_CODE (GimpDisplayImpl, gimp_display_impl, GIMP_TYPE_DISPLAY,
static void
gimp_display_impl_class_init (GimpDisplayImplClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpDisplayClass *display_class = GIMP_DISPLAY_CLASS (klass);
object_class->set_property = gimp_display_set_property;
object_class->get_property = gimp_display_get_property;
display_class->present = gimp_display_impl_present;
g_object_class_install_property (object_class, PROP_IMAGE,
g_param_spec_object ("image",
NULL, NULL,
@ -208,6 +213,14 @@ gimp_display_get_property (GObject *object,
}
}
static gboolean
gimp_display_impl_present (GimpDisplay *display)
{
gimp_display_shell_present (gimp_display_get_shell (display));
return TRUE;
}
static GimpProgress *
gimp_display_progress_start (GimpProgress *progress,
gboolean cancellable,

View File

@ -160,6 +160,28 @@ display_get_window_handle_invoker (GimpProcedure *procedure,
return return_vals;
}
static GimpValueArray *
display_present_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDisplay *display;
display = g_value_get_object (gimp_value_array_index (args, 0));
if (success)
{
gimp_display_present (display);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
displays_flush_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -323,6 +345,29 @@ register_display_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-display-present
*/
procedure = gimp_procedure_new (display_present_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-display-present");
gimp_procedure_set_static_help (procedure,
"Present the specified display.",
"This procedure presents the specified display at the top of the display stack.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Jehan",
"Jehan",
"2021");
gimp_procedure_add_argument (procedure,
gimp_param_spec_display ("display",
"display",
"The display to present",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-displays-flush
*/

View File

@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 758 procedures registered total */
/* 759 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)

View File

@ -184,6 +184,7 @@ EXPORTS
gimp_display_is_valid
gimp_display_name
gimp_display_new
gimp_display_present
gimp_displays_flush
gimp_displays_reconnect
gimp_dodgeburn

View File

@ -187,6 +187,42 @@ gimp_display_get_window_handle (GimpDisplay *display)
return window;
}
/**
* gimp_display_present:
* @display: The display to present.
*
* Present the specified display.
*
* This procedure presents the specified display at the top of the
* display stack.
*
* Returns: TRUE on success.
*
* Since: 3.0
**/
gboolean
gimp_display_present (GimpDisplay *display)
{
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_DISPLAY, display,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-display-present",
args);
gimp_value_array_unref (args);
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
gimp_value_array_unref (return_vals);
return success;
}
/**
* gimp_displays_flush:
*

View File

@ -36,6 +36,7 @@ gboolean gimp_display_id_is_valid (gint display_id);
GimpDisplay* gimp_display_new (GimpImage *image);
gboolean gimp_display_delete (GimpDisplay *display);
gint gimp_display_get_window_handle (GimpDisplay *display);
gboolean gimp_display_present (GimpDisplay *display);
gboolean gimp_displays_flush (void);
gboolean gimp_displays_reconnect (GimpImage *old_image,
GimpImage *new_image);

View File

@ -117,6 +117,29 @@ CODE
);
}
sub display_present {
$blurb = 'Present the specified display.';
$help = <<'HELP';
This procedure presents the specified display at the top of the display stack.
HELP
&jehan_pdb_misc('2021', '3.0');
@inargs = (
{ name => 'display', type => 'display',
desc => 'The display to present' }
);
%invoke = (
code => <<'CODE'
{
gimp_display_present (display);
}
CODE
);
}
sub display_get_window_handle {
$blurb = 'Get a handle to the native window for an image display.';
@ -217,7 +240,8 @@ CODE
display_new
display_delete
display_get_window_handle
displays_flush
display_present
displays_flush
displays_reconnect);
%exports = (app => [@procs], lib => [@procs]);