app: add color pickers to all GEGL tool color properties
The way to make gimp_prop_table_new() create tool pickers is disgusting, but works.
This commit is contained in:
@ -32,8 +32,8 @@
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
#include "widgets/gimppropwidgets.h"
|
||||
|
||||
#include "gimpcoloroptions.h"
|
||||
#include "gimpgegltool.h"
|
||||
#include "gimpimagemapoptions.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
@ -65,7 +65,8 @@ gimp_gegl_tool_register (GimpToolRegisterCallback callback,
|
||||
gpointer data)
|
||||
{
|
||||
(* callback) (GIMP_TYPE_GEGL_TOOL,
|
||||
GIMP_TYPE_IMAGE_MAP_OPTIONS, NULL,
|
||||
GIMP_TYPE_COLOR_OPTIONS,
|
||||
gimp_color_options_gui,
|
||||
0,
|
||||
"gimp-gegl-tool",
|
||||
_("GEGL Operation"),
|
||||
|
@ -45,8 +45,8 @@
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
|
||||
#include "gimpcoloroptions.h"
|
||||
#include "gimpoperationtool.h"
|
||||
#include "gimpimagemapoptions.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
@ -72,6 +72,10 @@ static GtkWidget * gimp_operation_tool_get_settings_ui (GimpImageMapTool *image
|
||||
const gchar *file_dialog_help_id,
|
||||
const gchar *default_folder,
|
||||
GtkWidget **settings_box);
|
||||
static void gimp_operation_tool_color_picked (GimpImageMapTool *im_tool,
|
||||
gpointer identifier,
|
||||
const Babl *sample_format,
|
||||
const GimpRGB *color);
|
||||
|
||||
static void gimp_operation_tool_config_notify (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
@ -89,7 +93,8 @@ gimp_operation_tool_register (GimpToolRegisterCallback callback,
|
||||
gpointer data)
|
||||
{
|
||||
(* callback) (GIMP_TYPE_OPERATION_TOOL,
|
||||
GIMP_TYPE_IMAGE_MAP_OPTIONS, NULL,
|
||||
GIMP_TYPE_COLOR_OPTIONS,
|
||||
gimp_color_options_gui,
|
||||
0,
|
||||
"gimp-operation-tool",
|
||||
_("GEGL Operation"),
|
||||
@ -118,6 +123,7 @@ gimp_operation_tool_class_init (GimpOperationToolClass *klass)
|
||||
im_tool_class->dialog = gimp_operation_tool_dialog;
|
||||
im_tool_class->reset = gimp_operation_tool_reset;
|
||||
im_tool_class->get_settings_ui = gimp_operation_tool_get_settings_ui;
|
||||
im_tool_class->color_picked = gimp_operation_tool_color_picked;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -268,6 +274,19 @@ gimp_operation_tool_get_settings_ui (GimpImageMapTool *image_map_tool,
|
||||
return widget;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_operation_tool_color_picked (GimpImageMapTool *im_tool,
|
||||
gpointer identifier,
|
||||
const Babl *sample_format,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
GimpOperationTool *tool = GIMP_OPERATION_TOOL (im_tool);
|
||||
|
||||
g_object_set (tool->config,
|
||||
identifier, color,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_operation_tool_config_notify (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
@ -340,7 +359,9 @@ gimp_operation_tool_set_operation (GimpOperationTool *tool,
|
||||
tool->options_table =
|
||||
gimp_prop_table_new (G_OBJECT (tool->config),
|
||||
G_TYPE_FROM_INSTANCE (tool->config),
|
||||
GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (tool)));
|
||||
GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (tool)),
|
||||
(GimpCreatePickerFunc) gimp_image_map_tool_add_color_picker,
|
||||
tool);
|
||||
|
||||
if (tool->options_box)
|
||||
{
|
||||
|
@ -1417,7 +1417,9 @@ gimp_prop_icon_picker_notify (GObject *config,
|
||||
GtkWidget *
|
||||
gimp_prop_table_new (GObject *config,
|
||||
GType owner_type,
|
||||
GimpContext *context)
|
||||
GimpContext *context,
|
||||
GimpCreatePickerFunc create_picker_func,
|
||||
gpointer picker_creator)
|
||||
{
|
||||
GtkWidget *table;
|
||||
GtkSizeGroup *size_group;
|
||||
@ -1507,12 +1509,26 @@ gimp_prop_table_new (GObject *config,
|
||||
}
|
||||
else if (GIMP_IS_PARAM_SPEC_RGB (pspec))
|
||||
{
|
||||
widget = gimp_prop_color_button_new (config, pspec->name,
|
||||
GtkWidget *button;
|
||||
|
||||
widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
||||
|
||||
button = gimp_prop_color_button_new (config, pspec->name,
|
||||
g_param_spec_get_nick (pspec),
|
||||
128, 24,
|
||||
GIMP_COLOR_AREA_SMALL_CHECKS);
|
||||
gimp_color_button_set_update (GIMP_COLOR_BUTTON (widget), TRUE);
|
||||
gimp_color_panel_set_context (GIMP_COLOR_PANEL (widget), context);
|
||||
gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE);
|
||||
gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), context);
|
||||
gtk_box_pack_start (GTK_BOX (widget), button, TRUE, TRUE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
button = create_picker_func (picker_creator,
|
||||
pspec->name,
|
||||
GIMP_STOCK_COLOR_PICKER_GRAY,
|
||||
_("Pick color from image"));
|
||||
gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
label = g_param_spec_get_nick (pspec);
|
||||
}
|
||||
else
|
||||
|
@ -101,9 +101,16 @@ GtkWidget * gimp_prop_icon_picker_new (GObject *config,
|
||||
|
||||
/* A view on all of an object's properties */
|
||||
|
||||
typedef GtkWidget * (* GimpCreatePickerFunc) (gpointer creator,
|
||||
const gchar *property_name,
|
||||
const gchar *stock_id,
|
||||
const gchar *help_id);
|
||||
|
||||
GtkWidget * gimp_prop_table_new (GObject *config,
|
||||
GType owner_type,
|
||||
GimpContext *context);
|
||||
GimpContext *context,
|
||||
GimpCreatePickerFunc create_picker_fnc,
|
||||
gpointer picker_creator);
|
||||
|
||||
|
||||
#endif /* __GIMP_APP_PROP_WIDGETS_H__ */
|
||||
|
Reference in New Issue
Block a user