[gimp] Issue #8744: refactor overdependence on gimpui.h
- From: Lloyd Konneker <lkonneker src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Issue #8744: refactor overdependence on gimpui.h
- Date: Sat, 15 Oct 2022 15:23:35 +0000 (UTC)
commit 7708c3fec3f0de5d984d65bb69077cf71ed4de33
Author: lloyd konneker <konnekerl gmail com>
Date: Sat Oct 15 10:10:21 2022 -0400
Issue #8744: refactor overdependence on gimpui.h
To reduce compiling due to changes in libgimpui.
plug-ins/script-fu/libscriptfu/script-fu-arg.c | 1 -
plug-ins/script-fu/libscriptfu/script-fu-command.c | 2 +-
.../script-fu/libscriptfu/script-fu-interface.c | 101 ++++++++++++++-------
plug-ins/script-fu/libscriptfu/script-fu-lib.c | 2 -
.../script-fu/libscriptfu/script-fu-proc-factory.c | 1 -
.../script-fu/libscriptfu/script-fu-register.c | 1 -
.../script-fu/libscriptfu/script-fu-run-func.c | 1 -
plug-ins/script-fu/libscriptfu/script-fu-script.c | 1 -
plug-ins/script-fu/libscriptfu/script-fu-scripts.c | 1 -
plug-ins/script-fu/libscriptfu/script-fu-types.h | 1 -
10 files changed, 68 insertions(+), 44 deletions(-)
---
diff --git a/plug-ins/script-fu/libscriptfu/script-fu-arg.c b/plug-ins/script-fu/libscriptfu/script-fu-arg.c
index b45e7108d4..afc1ffb9c9 100644
--- a/plug-ins/script-fu/libscriptfu/script-fu-arg.c
+++ b/plug-ins/script-fu/libscriptfu/script-fu-arg.c
@@ -20,7 +20,6 @@
#include <string.h>
#include <libgimp/gimp.h>
-#include <libgimp/gimpui.h>
#include "script-fu-types.h"
#include "script-fu-arg.h"
diff --git a/plug-ins/script-fu/libscriptfu/script-fu-command.c
b/plug-ins/script-fu/libscriptfu/script-fu-command.c
index 296e25d88a..923abc9838 100644
--- a/plug-ins/script-fu/libscriptfu/script-fu-command.c
+++ b/plug-ins/script-fu/libscriptfu/script-fu-command.c
@@ -17,7 +17,7 @@
#include "config.h"
-#include <libgimp/gimpui.h>
+#include <libgimp/gimp.h>
#include "script-fu-types.h" /* SFScript */
#include "script-fu-lib.h"
diff --git a/plug-ins/script-fu/libscriptfu/script-fu-interface.c
b/plug-ins/script-fu/libscriptfu/script-fu-interface.c
index 7f3e1e698b..4af4abab11 100644
--- a/plug-ins/script-fu/libscriptfu/script-fu-interface.c
+++ b/plug-ins/script-fu/libscriptfu/script-fu-interface.c
@@ -405,9 +405,12 @@ script_fu_interface (SFScript *script,
break;
case SF_ADJUSTMENT:
- switch (arg->default_value.sfa_adjustment.type)
- {
- case SF_SLIDER:
+ {
+ GtkAdjustment *adj_widget;
+
+ switch (arg->default_value.sfa_adjustment.type)
+ {
+ case SF_SLIDER:
{
GtkWidget *spinbutton;
@@ -420,38 +423,43 @@ script_fu_interface (SFScript *script,
arg->default_value.sfa_adjustment.step,
arg->default_value.sfa_adjustment.page);
spinbutton = gimp_label_spin_get_spin_button (GIMP_LABEL_SPIN (widget));
- arg->value.sfa_adjustment.adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON
(spinbutton));
+ adj_widget = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton));
gtk_entry_set_activates_default (GTK_ENTRY (spinbutton), TRUE);
}
- break;
-
- default:
- g_warning ("unexpected adjustment type: %d",
- arg->default_value.sfa_adjustment.type);
- /* fallthrough */
-
- case SF_SPINNER:
- left_align = TRUE;
- arg->value.sfa_adjustment.adj =
- gtk_adjustment_new (arg->value.sfa_adjustment.value,
- arg->default_value.sfa_adjustment.lower,
- arg->default_value.sfa_adjustment.upper,
- arg->default_value.sfa_adjustment.step,
- arg->default_value.sfa_adjustment.page,
- 0);
- widget = gimp_spin_button_new (arg->value.sfa_adjustment.adj,
- arg->default_value.sfa_adjustment.step,
- arg->default_value.sfa_adjustment.digits);
- gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (widget), TRUE);
- gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE);
- break;
- }
-
- g_signal_connect (arg->value.sfa_adjustment.adj,
- "value-changed",
- G_CALLBACK (gimp_double_adjustment_update),
- &arg->value.sfa_adjustment.value);
+ break;
+
+ default:
+ g_warning ("unexpected adjustment type: %d",
+ arg->default_value.sfa_adjustment.type);
+ /* fallthrough */
+
+ case SF_SPINNER:
+ left_align = TRUE;
+ adj_widget =
+ gtk_adjustment_new (arg->value.sfa_adjustment.value,
+ arg->default_value.sfa_adjustment.lower,
+ arg->default_value.sfa_adjustment.upper,
+ arg->default_value.sfa_adjustment.step,
+ arg->default_value.sfa_adjustment.page,
+ 0);
+ widget = gimp_spin_button_new (adj_widget,
+ arg->default_value.sfa_adjustment.step,
+ arg->default_value.sfa_adjustment.digits);
+ gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (widget), TRUE);
+ gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE);
+
+ break;
+ } /* end switch on adjustment type. */
+
+ /* Each case set adj_widget. */
+ g_assert (adj_widget != NULL);
+
+ g_signal_connect (adj_widget,
+ "value-changed",
+ G_CALLBACK (gimp_double_adjustment_update),
+ &arg->value.sfa_adjustment.value);
+ } /* end case SF_ADJUSTMENT */
break;
case SF_FILENAME:
@@ -952,8 +960,33 @@ script_fu_reset (SFScript *script)
break;
case SF_ADJUSTMENT:
- gtk_adjustment_set_value (value->sfa_adjustment.adj,
- value->sfa_adjustment.value);
+ {
+ /* Reset the widget's underlying GtkAdjustment.
+ * The widget knows its own GtkAdjustment.
+ * The widget is a GimpScaleEntry or a GimpSpinButton.
+ */
+ GtkAdjustment *adj_widget = NULL;
+
+ switch (script->args[i].default_value.sfa_adjustment.type)
+ {
+ case SF_SLIDER: /* GimpScaleEntry */
+ {
+ /* Widget knows its range which knows its adjustment. */
+ /* Unfortunately, gimp_scale_entry_get_range returns GtkWidget*, we must downcast.*/
+ GtkRange *range = GTK_RANGE (gimp_scale_entry_get_range (GIMP_SCALE_ENTRY (widget)));
+
+ adj_widget = gtk_range_get_adjustment (range);
+ }
+ break;
+
+ case SF_SPINNER: /* GimpSpinButton */
+ adj_widget = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
+ break;
+ }
+ g_assert (adj_widget != NULL);
+
+ gtk_adjustment_set_value (adj_widget, value->sfa_adjustment.value);
+ }
break;
case SF_FILENAME:
diff --git a/plug-ins/script-fu/libscriptfu/script-fu-lib.c b/plug-ins/script-fu/libscriptfu/script-fu-lib.c
index 235b2d35a7..d0081172cc 100644
--- a/plug-ins/script-fu/libscriptfu/script-fu-lib.c
+++ b/plug-ins/script-fu/libscriptfu/script-fu-lib.c
@@ -19,8 +19,6 @@
#include "config.h"
#include <libgimp/gimp.h>
-/* FIXME We only need gimpui because script-fu-types.h refers to GtkAdjustment. */
-#include <libgimp/gimpui.h>
#include "script-fu-lib.h"
diff --git a/plug-ins/script-fu/libscriptfu/script-fu-proc-factory.c
b/plug-ins/script-fu/libscriptfu/script-fu-proc-factory.c
index 614f837fe4..33a01be0a3 100644
--- a/plug-ins/script-fu/libscriptfu/script-fu-proc-factory.c
+++ b/plug-ins/script-fu/libscriptfu/script-fu-proc-factory.c
@@ -18,7 +18,6 @@
#include "config.h"
#include <glib.h>
#include <libgimp/gimp.h>
-#include <libgimp/gimpui.h>
#include "tinyscheme/scheme-private.h"
#include "script-fu-types.h"
diff --git a/plug-ins/script-fu/libscriptfu/script-fu-register.c
b/plug-ins/script-fu/libscriptfu/script-fu-register.c
index 42a2b5fc1f..ca4866e270 100644
--- a/plug-ins/script-fu/libscriptfu/script-fu-register.c
+++ b/plug-ins/script-fu/libscriptfu/script-fu-register.c
@@ -25,7 +25,6 @@
#endif
#include <libgimp/gimp.h>
-#include <libgimp/gimpui.h>
#include "tinyscheme/scheme-private.h"
diff --git a/plug-ins/script-fu/libscriptfu/script-fu-run-func.c
b/plug-ins/script-fu/libscriptfu/script-fu-run-func.c
index b2e6cbc02b..fd4ebfcd10 100644
--- a/plug-ins/script-fu/libscriptfu/script-fu-run-func.c
+++ b/plug-ins/script-fu/libscriptfu/script-fu-run-func.c
@@ -21,7 +21,6 @@
#include <glib.h>
#include <libgimp/gimp.h>
-#include <libgimp/gimpui.h>
#include "scheme-wrapper.h" /* type "pointer" */
diff --git a/plug-ins/script-fu/libscriptfu/script-fu-script.c
b/plug-ins/script-fu/libscriptfu/script-fu-script.c
index 97e956278d..4a4906089a 100644
--- a/plug-ins/script-fu/libscriptfu/script-fu-script.c
+++ b/plug-ins/script-fu/libscriptfu/script-fu-script.c
@@ -20,7 +20,6 @@
#include <string.h>
#include <libgimp/gimp.h>
-#include <libgimp/gimpui.h>
#include "tinyscheme/scheme-private.h"
diff --git a/plug-ins/script-fu/libscriptfu/script-fu-scripts.c
b/plug-ins/script-fu/libscriptfu/script-fu-scripts.c
index cbb54f3a48..d024c1c620 100644
--- a/plug-ins/script-fu/libscriptfu/script-fu-scripts.c
+++ b/plug-ins/script-fu/libscriptfu/script-fu-scripts.c
@@ -26,7 +26,6 @@
#endif
#include <libgimp/gimp.h>
-#include <libgimp/gimpui.h>
#include "tinyscheme/scheme-private.h"
diff --git a/plug-ins/script-fu/libscriptfu/script-fu-types.h
b/plug-ins/script-fu/libscriptfu/script-fu-types.h
index d74c5e6b40..7457ce6d62 100644
--- a/plug-ins/script-fu/libscriptfu/script-fu-types.h
+++ b/plug-ins/script-fu/libscriptfu/script-fu-types.h
@@ -24,7 +24,6 @@
typedef struct
{
- GtkAdjustment *adj;
gdouble value;
gdouble lower;
gdouble upper;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]