[gimp] app, libgimp, pdb: new gimp_display_present() PDB call.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app, libgimp, pdb: new gimp_display_present() PDB call.
- Date: Fri, 30 Apr 2021 01:54:15 +0000 (UTC)
commit 7eaa4f1ca98f5a95bf3dc521482674baf1915bc8
Author: Jehan <jehan girinstud io>
Date: Fri Apr 30 03:39:23 2021 +0200
app, libgimp, pdb: new gimp_display_present() PDB call.
app/core/gimpdisplay.c | 11 +++++++++++
app/core/gimpdisplay.h | 4 ++++
app/display/gimpdisplay.c | 15 ++++++++++++++-
app/pdb/display-cmds.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
app/pdb/internal-procs.c | 2 +-
libgimp/gimp.def | 1 +
libgimp/gimpdisplay_pdb.c | 36 ++++++++++++++++++++++++++++++++++++
libgimp/gimpdisplay_pdb.h | 1 +
pdb/groups/display.pdb | 26 +++++++++++++++++++++++++-
9 files changed, 138 insertions(+), 3 deletions(-)
---
diff --git a/app/core/gimpdisplay.c b/app/core/gimpdisplay.c
index a8aba94ba3..8f8da42a2c 100644
--- a/app/core/gimpdisplay.c
+++ b/app/core/gimpdisplay.c
@@ -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)
{
diff --git a/app/core/gimpdisplay.h b/app/core/gimpdisplay.h
index 2ea00c80d4..e40d8d65eb 100644
--- a/app/core/gimpdisplay.h
+++ b/app/core/gimpdisplay.h
@@ -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);
diff --git a/app/display/gimpdisplay.c b/app/display/gimpdisplay.c
index 6a504ca847..1712999546 100644
--- a/app/display/gimpdisplay.c
+++ b/app/display/gimpdisplay.c
@@ -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,
diff --git a/app/pdb/display-cmds.c b/app/pdb/display-cmds.c
index 2762cdd6e8..c943ca7186 100644
--- a/app/pdb/display-cmds.c
+++ b/app/pdb/display-cmds.c
@@ -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
*/
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 13594d3f3e..25446a4097 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
#include "internal-procs.h"
-/* 758 procedures registered total */
+/* 759 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index b8bf490214..8e5c2cced8 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -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
diff --git a/libgimp/gimpdisplay_pdb.c b/libgimp/gimpdisplay_pdb.c
index cdafecac2b..ed736909ef 100644
--- a/libgimp/gimpdisplay_pdb.c
+++ b/libgimp/gimpdisplay_pdb.c
@@ -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:
*
diff --git a/libgimp/gimpdisplay_pdb.h b/libgimp/gimpdisplay_pdb.h
index de389fbce0..48394dec96 100644
--- a/libgimp/gimpdisplay_pdb.h
+++ b/libgimp/gimpdisplay_pdb.h
@@ -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);
diff --git a/pdb/groups/display.pdb b/pdb/groups/display.pdb
index 4ca4042ec1..1b3a35604c 100644
--- a/pdb/groups/display.pdb
+++ b/pdb/groups/display.pdb
@@ -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]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]