Commit c5b88702 authored by Ell's avatar Ell

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.
parent 92cd4d46
......@@ -17,6 +17,7 @@
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "actions-types.h"
......
......@@ -17,6 +17,7 @@
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "actions-types.h"
......
......@@ -17,6 +17,7 @@
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "actions-types.h"
......
......@@ -22,6 +22,7 @@
#include "stdlib.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "gdk/gdkkeysyms.h"
......
......@@ -20,6 +20,7 @@
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
......
......@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
......
......@@ -17,6 +17,7 @@
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "menus-types.h"
......
......@@ -17,6 +17,7 @@
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "menus-types.h"
......
......@@ -19,6 +19,7 @@
#include <string.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include "menus-types.h"
......
......@@ -17,6 +17,7 @@
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
......
......@@ -17,6 +17,7 @@
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "menus-types.h"
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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,
......
......@@ -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),
......
......@@ -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__ */
......@@ -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
......
......@@ -17,6 +17,7 @@
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "tools-types.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment