[gimp/goat-invasion] app: add color pickers to all GEGL tool color properties
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion] app: add color pickers to all GEGL tool color properties
- Date: Mon, 30 Apr 2012 21:51:31 +0000 (UTC)
commit 4f79b8fcc687d6cc0f3390d7cb6991d61f043528
Author: Michael Natterer <mitch gimp org>
Date: Mon Apr 30 23:49:09 2012 +0200
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.
app/tools/gimpgegltool.c | 5 +++--
app/tools/gimpoperationtool.c | 27 ++++++++++++++++++++++++---
app/widgets/gimppropwidgets.c | 28 ++++++++++++++++++++++------
app/widgets/gimppropwidgets.h | 13 ++++++++++---
4 files changed, 59 insertions(+), 14 deletions(-)
---
diff --git a/app/tools/gimpgegltool.c b/app/tools/gimpgegltool.c
index 5a6d5cd..110cf7e 100644
--- a/app/tools/gimpgegltool.c
+++ b/app/tools/gimpgegltool.c
@@ -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"),
diff --git a/app/tools/gimpoperationtool.c b/app/tools/gimpoperationtool.c
index fcdff2f..c101112 100644
--- a/app/tools/gimpoperationtool.c
+++ b/app/tools/gimpoperationtool.c
@@ -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
@@ -269,6 +275,19 @@ gimp_operation_tool_get_settings_ui (GimpImageMapTool *image_map_tool,
}
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,
GimpOperationTool *tool)
@@ -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)
{
diff --git a/app/widgets/gimppropwidgets.c b/app/widgets/gimppropwidgets.c
index 1f6741f..ac0fe81 100644
--- a/app/widgets/gimppropwidgets.c
+++ b/app/widgets/gimppropwidgets.c
@@ -1415,9 +1415,11 @@ gimp_prop_icon_picker_notify (GObject *config,
/***********/
GtkWidget *
-gimp_prop_table_new (GObject *config,
- GType owner_type,
- GimpContext *context)
+gimp_prop_table_new (GObject *config,
+ GType owner_type,
+ 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
diff --git a/app/widgets/gimppropwidgets.h b/app/widgets/gimppropwidgets.h
index 168a210..bd1a3d8 100644
--- a/app/widgets/gimppropwidgets.h
+++ b/app/widgets/gimppropwidgets.h
@@ -101,9 +101,16 @@ GtkWidget * gimp_prop_icon_picker_new (GObject *config,
/* A view on all of an object's properties */
-GtkWidget * gimp_prop_table_new (GObject *config,
- GType owner_type,
- GimpContext *context);
+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,
+ GimpCreatePickerFunc create_picker_fnc,
+ gpointer picker_creator);
#endif /* __GIMP_APP_PROP_WIDGETS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]