[gimp] app: allow specifying a callback function for propgui pickers
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: allow specifying a callback function for propgui pickers
- Date: Mon, 16 Oct 2017 16:39:29 +0000 (UTC)
commit c5b88702e6a9abbdb9bf93f1859ae65ac7acc3b2
Author: Ell <ell_se yahoo com>
Date: Mon Oct 16 11:38:28 2017 -0400
app: allow specifying a callback function for propgui pickers
Allow propgui constructors to specify an (optional) callback function
when creating pickers, to be called when a color/coordinate is picked,
similarly to controller callbacks.
Implement picker callback support in GimpFilterTool. When the active
picker has an associated callback function, call it instead of the
class's color_picked() function.
Add lots of "#include <gegl.h>" to .c files that miss it, which is
now necessary, since this commit adds a Babl* parameter in
propgui-types.h.
app/actions/cursor-info-commands.c | 1 +
app/actions/data-editor-commands.c | 1 +
app/actions/sample-points-commands.c | 1 +
app/display/gimpscalecombobox.c | 1 +
app/gui/session.c | 1 +
app/gui/themes.c | 1 +
app/menus/dockable-menu.c | 1 +
app/menus/filters-menu.c | 1 +
app/menus/image-menu.c | 1 +
app/menus/menus.c | 1 +
app/menus/window-menu.c | 1 +
app/propgui/gimppropgui-generic.c | 3 +-
app/propgui/gimppropgui.c | 3 +-
app/propgui/propgui-types.h | 11 ++++-
app/tools/gimpfiltertool.c | 38 ++++++++++++++--
app/tools/gimpfiltertool.h | 80 +++++++++++++++++----------------
app/tools/gimplevelstool.c | 3 +-
app/tools/gimptoolcontrol.c | 1 +
18 files changed, 102 insertions(+), 48 deletions(-)
---
diff --git a/app/actions/cursor-info-commands.c b/app/actions/cursor-info-commands.c
index 6ff2e82..c86d12f 100644
--- a/app/actions/cursor-info-commands.c
+++ b/app/actions/cursor-info-commands.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "actions-types.h"
diff --git a/app/actions/data-editor-commands.c b/app/actions/data-editor-commands.c
index da77e47..032084f 100644
--- a/app/actions/data-editor-commands.c
+++ b/app/actions/data-editor-commands.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "actions-types.h"
diff --git a/app/actions/sample-points-commands.c b/app/actions/sample-points-commands.c
index 9205880..45aa38c 100644
--- a/app/actions/sample-points-commands.c
+++ b/app/actions/sample-points-commands.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "actions-types.h"
diff --git a/app/display/gimpscalecombobox.c b/app/display/gimpscalecombobox.c
index 29e3158..07ec366 100644
--- a/app/display/gimpscalecombobox.c
+++ b/app/display/gimpscalecombobox.c
@@ -22,6 +22,7 @@
#include "stdlib.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "gdk/gdkkeysyms.h"
diff --git a/app/gui/session.c b/app/gui/session.c
index 59114a0..5e98079 100644
--- a/app/gui/session.c
+++ b/app/gui/session.c
@@ -20,6 +20,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
diff --git a/app/gui/themes.c b/app/gui/themes.c
index 7e8556b..db06605 100644
--- a/app/gui/themes.c
+++ b/app/gui/themes.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
diff --git a/app/menus/dockable-menu.c b/app/menus/dockable-menu.c
index b11bbe6..6de0eaf 100644
--- a/app/menus/dockable-menu.c
+++ b/app/menus/dockable-menu.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "menus-types.h"
diff --git a/app/menus/filters-menu.c b/app/menus/filters-menu.c
index fa4c822..974b1c8 100644
--- a/app/menus/filters-menu.c
+++ b/app/menus/filters-menu.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "menus-types.h"
diff --git a/app/menus/image-menu.c b/app/menus/image-menu.c
index 52b9152..ee34d0e 100644
--- a/app/menus/image-menu.c
+++ b/app/menus/image-menu.c
@@ -19,6 +19,7 @@
#include <string.h>
+#include <gegl.h>
#include <gtk/gtk.h>
#include "menus-types.h"
diff --git a/app/menus/menus.c b/app/menus/menus.c
index 6efa2e8..fff8b3c 100644
--- a/app/menus/menus.c
+++ b/app/menus/menus.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
diff --git a/app/menus/window-menu.c b/app/menus/window-menu.c
index 580c430..ccf237c 100644
--- a/app/menus/window-menu.c
+++ b/app/menus/window-menu.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "menus-types.h"
diff --git a/app/propgui/gimppropgui-generic.c b/app/propgui/gimppropgui-generic.c
index 2827815..3b73ee4 100644
--- a/app/propgui/gimppropgui-generic.c
+++ b/app/propgui/gimppropgui-generic.c
@@ -175,7 +175,8 @@ _gimp_prop_gui_new_generic (GObject *config,
pspec_name,
GIMP_ICON_CURSOR,
_("Pick coordinates from the image"),
- /* pick_abyss = */ TRUE);
+ /* pick_abyss = */ TRUE,
+ NULL, NULL);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
diff --git a/app/propgui/gimppropgui.c b/app/propgui/gimppropgui.c
index e3d28d2..d9ad874 100644
--- a/app/propgui/gimppropgui.c
+++ b/app/propgui/gimppropgui.c
@@ -365,7 +365,8 @@ gimp_prop_widget_new_from_pspec (GObject *config,
pspec->name,
GIMP_ICON_COLOR_PICKER_GRAY,
_("Pick color from the image"),
- /* pick_abyss = */ FALSE);
+ /* pick_abyss = */ FALSE,
+ NULL, NULL);
gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
gtk_widget_show (button);
}
diff --git a/app/propgui/propgui-types.h b/app/propgui/propgui-types.h
index 362db13..d95ff1a 100644
--- a/app/propgui/propgui-types.h
+++ b/app/propgui/propgui-types.h
@@ -75,6 +75,13 @@ typedef struct
/* function types */
+typedef void (* GimpPickerCallback) (gpointer data,
+ gpointer identifier,
+ gdouble x,
+ gdouble y,
+ const Babl *sample_format,
+ const GimpRGB *color);
+
typedef void (* GimpControllerLineCallback) (gpointer data,
GeglRectangle *area,
gdouble x1,
@@ -95,7 +102,9 @@ typedef GtkWidget * (* GimpCreatePickerFunc) (gpointer creator,
const gchar *property_name,
const gchar *icon_name,
const gchar *tooltip,
- gboolean pick_abyss);
+ gboolean pick_abyss,
+ GimpPickerCallback callback,
+ gpointer callback_data);
typedef GCallback (* GimpCreateControllerFunc) (gpointer creator,
GimpControllerType controller_type,
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index 9669a93..ecbd067 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -857,6 +857,28 @@ gimp_filter_tool_color_picked (GimpColorTool *color_tool,
{
GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (color_tool);
+ if (filter_tool->active_picker)
+ {
+ GimpPickerCallback callback;
+ gpointer callback_data;
+
+ callback = g_object_get_data (G_OBJECT (filter_tool->active_picker),
+ "picker-callback");
+ callback_data = g_object_get_data (G_OBJECT (filter_tool->active_picker),
+ "picker-callback-data");
+
+ if (callback)
+ {
+ callback (callback_data,
+ filter_tool->pick_identifier,
+ coords->x,
+ coords->y,
+ sample_format, color);
+
+ return;
+ }
+ }
+
GIMP_FILTER_TOOL_GET_CLASS (filter_tool)->color_picked (filter_tool,
filter_tool->pick_identifier,
coords->x,
@@ -1578,11 +1600,13 @@ gimp_filter_tool_color_picker_toggled (GtkWidget *widget,
}
GtkWidget *
-gimp_filter_tool_add_color_picker (GimpFilterTool *filter_tool,
- gpointer identifier,
- const gchar *icon_name,
- const gchar *tooltip,
- gboolean pick_abyss)
+gimp_filter_tool_add_color_picker (GimpFilterTool *filter_tool,
+ gpointer identifier,
+ const gchar *icon_name,
+ const gchar *tooltip,
+ gboolean pick_abyss,
+ GimpPickerCallback callback,
+ gpointer callback_data)
{
GtkWidget *button;
GtkWidget *image;
@@ -1606,6 +1630,10 @@ gimp_filter_tool_add_color_picker (GimpFilterTool *filter_tool,
"picker-identifier", identifier);
g_object_set_data (G_OBJECT (button),
"picker-pick-abyss", GINT_TO_POINTER (pick_abyss));
+ g_object_set_data (G_OBJECT (button),
+ "picker-callback", callback);
+ g_object_set_data (G_OBJECT (button),
+ "picker-callback-data", callback_data);
g_signal_connect (button, "toggled",
G_CALLBACK (gimp_filter_tool_color_picker_toggled),
diff --git a/app/tools/gimpfiltertool.h b/app/tools/gimpfiltertool.h
index 3a45476..a8f3842 100644
--- a/app/tools/gimpfiltertool.h
+++ b/app/tools/gimpfiltertool.h
@@ -99,45 +99,47 @@ struct _GimpFilterToolClass
GType gimp_filter_tool_get_type (void) G_GNUC_CONST;
-void gimp_filter_tool_get_operation (GimpFilterTool *filter_tool);
-
-void gimp_filter_tool_set_config (GimpFilterTool *filter_tool,
- GimpConfig *config);
-
-void gimp_filter_tool_edit_as (GimpFilterTool *filter_tool,
- const gchar *new_tool_id,
- GimpConfig *config);
-
-gboolean gimp_filter_tool_on_guide (GimpFilterTool *filter_tool,
- const GimpCoords *coords,
- GimpDisplay *display);
-
-GtkWidget * gimp_filter_tool_dialog_get_vbox (GimpFilterTool *filter_tool);
-
-void gimp_filter_tool_enable_color_picking (GimpFilterTool *filter_tool,
- gpointer identifier,
- gboolean pick_abyss);
-void gimp_filter_tool_disable_color_picking (GimpFilterTool *filter_tool);
-
-GtkWidget * gimp_filter_tool_add_color_picker (GimpFilterTool *filter_tool,
- gpointer identifier,
- const gchar *icon_name,
- const gchar *tooltip,
- gboolean pick_abyss);
-GCallback gimp_filter_tool_add_controller (GimpFilterTool *filter_tool,
- GimpControllerType controller_type,
- const gchar *status_title,
- GCallback callback,
- gpointer callback_data,
- gpointer *set_func_data);
-
-void gimp_filter_tool_set_widget (GimpFilterTool *filter_tool,
- GimpToolWidget *widget);
-
-gboolean gimp_filter_tool_get_drawable_area (GimpFilterTool *filter_tool,
- gint *drawable_offset_x,
- gint *drawable_offset_y,
- GeglRectangle *drawable_area);
+void gimp_filter_tool_get_operation (GimpFilterTool *filter_tool);
+
+void gimp_filter_tool_set_config (GimpFilterTool *filter_tool,
+ GimpConfig *config);
+
+void gimp_filter_tool_edit_as (GimpFilterTool *filter_tool,
+ const gchar *new_tool_id,
+ GimpConfig *config);
+
+gboolean gimp_filter_tool_on_guide (GimpFilterTool *filter_tool,
+ const GimpCoords *coords,
+ GimpDisplay *display);
+
+GtkWidget * gimp_filter_tool_dialog_get_vbox (GimpFilterTool *filter_tool);
+
+void gimp_filter_tool_enable_color_picking (GimpFilterTool *filter_tool,
+ gpointer identifier,
+ gboolean pick_abyss);
+void gimp_filter_tool_disable_color_picking (GimpFilterTool *filter_tool);
+
+GtkWidget * gimp_filter_tool_add_color_picker (GimpFilterTool *filter_tool,
+ gpointer identifier,
+ const gchar *icon_name,
+ const gchar *tooltip,
+ gboolean pick_abyss,
+ GimpPickerCallback callback,
+ gpointer callback_data);
+GCallback gimp_filter_tool_add_controller (GimpFilterTool *filter_tool,
+ GimpControllerType controller_type,
+ const gchar *status_title,
+ GCallback callback,
+ gpointer callback_data,
+ gpointer *set_func_data);
+
+void gimp_filter_tool_set_widget (GimpFilterTool *filter_tool,
+ GimpToolWidget *widget);
+
+gboolean gimp_filter_tool_get_drawable_area (GimpFilterTool *filter_tool,
+ gint *drawable_offset_x,
+ gint *drawable_offset_y,
+ GeglRectangle *drawable_area);
#endif /* __GIMP_FILTER_TOOL_H__ */
diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c
index cb8acca..e3bcb4a 100644
--- a/app/tools/gimplevelstool.c
+++ b/app/tools/gimplevelstool.c
@@ -289,7 +289,8 @@ gimp_levels_tool_color_picker_new (GimpLevelsTool *tool,
GUINT_TO_POINTER (value),
icon_name,
help,
- /* pick_abyss = */ FALSE);
+ /* pick_abyss = */ FALSE,
+ NULL, NULL);
}
static void
diff --git a/app/tools/gimptoolcontrol.c b/app/tools/gimptoolcontrol.c
index 8a3cdb6..a7d83ff 100644
--- a/app/tools/gimptoolcontrol.c
+++ b/app/tools/gimptoolcontrol.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "tools-types.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]