mirror of https://github.com/GNOME/gimp.git
app: factor out the "Apply GEGL Operation" functionality from GimpGeglTool
to a new GimpOperationTool, make GimpGeglTool its subclass and leave only the selection of the operation in GimpGeglTool.
This commit is contained in:
parent
726d3c980c
commit
98ccc9512c
|
@ -118,6 +118,8 @@ libapptools_a_sources = \
|
||||||
gimpiscissorstool.h \
|
gimpiscissorstool.h \
|
||||||
gimplevelstool.c \
|
gimplevelstool.c \
|
||||||
gimplevelstool.h \
|
gimplevelstool.h \
|
||||||
|
gimpoperationtool.c \
|
||||||
|
gimpoperationtool.h \
|
||||||
gimpmagnifyoptions.c \
|
gimpmagnifyoptions.c \
|
||||||
gimpmagnifyoptions.h \
|
gimpmagnifyoptions.h \
|
||||||
gimpmagnifytool.c \
|
gimpmagnifytool.c \
|
||||||
|
|
|
@ -29,19 +29,9 @@
|
||||||
|
|
||||||
#include "tools-types.h"
|
#include "tools-types.h"
|
||||||
|
|
||||||
#include "gegl/gimp-gegl-config-proxy.h"
|
|
||||||
|
|
||||||
#include "core/gimpdrawable.h"
|
|
||||||
#include "core/gimperror.h"
|
|
||||||
#include "core/gimpimage.h"
|
|
||||||
#include "core/gimpimagemap.h"
|
|
||||||
#include "core/gimpparamspecs-duplicate.h"
|
|
||||||
|
|
||||||
#include "widgets/gimphelp-ids.h"
|
#include "widgets/gimphelp-ids.h"
|
||||||
#include "widgets/gimppropwidgets.h"
|
#include "widgets/gimppropwidgets.h"
|
||||||
|
|
||||||
#include "display/gimpdisplay.h"
|
|
||||||
|
|
||||||
#include "gimpgegltool.h"
|
#include "gimpgegltool.h"
|
||||||
#include "gimpimagemapoptions.h"
|
#include "gimpimagemapoptions.h"
|
||||||
|
|
||||||
|
@ -59,27 +49,13 @@ enum
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
|
|
||||||
static void gimp_gegl_tool_finalize (GObject *object);
|
static void gimp_gegl_tool_dialog (GimpImageMapTool *im_tool);
|
||||||
|
|
||||||
static gboolean gimp_gegl_tool_initialize (GimpTool *tool,
|
static void gimp_gegl_tool_operation_changed (GtkWidget *widget,
|
||||||
GimpDisplay *display,
|
GimpGeglTool *tool);
|
||||||
GError **error);
|
|
||||||
|
|
||||||
static GeglNode * gimp_gegl_tool_get_operation (GimpImageMapTool *im_tool,
|
|
||||||
GObject **config);
|
|
||||||
static void gimp_gegl_tool_map (GimpImageMapTool *im_tool);
|
|
||||||
static void gimp_gegl_tool_dialog (GimpImageMapTool *im_tool);
|
|
||||||
static void gimp_gegl_tool_reset (GimpImageMapTool *im_tool);
|
|
||||||
|
|
||||||
static void gimp_gegl_tool_config_notify (GObject *object,
|
|
||||||
GParamSpec *pspec,
|
|
||||||
GimpGeglTool *tool);
|
|
||||||
|
|
||||||
static void gimp_gegl_tool_operation_changed (GtkWidget *widget,
|
|
||||||
GimpGeglTool *tool);
|
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (GimpGeglTool, gimp_gegl_tool, GIMP_TYPE_IMAGE_MAP_TOOL)
|
G_DEFINE_TYPE (GimpGeglTool, gimp_gegl_tool, GIMP_TYPE_OPERATION_TOOL)
|
||||||
|
|
||||||
#define parent_class gimp_gegl_tool_parent_class
|
#define parent_class gimp_gegl_tool_parent_class
|
||||||
|
|
||||||
|
@ -103,20 +79,11 @@ gimp_gegl_tool_register (GimpToolRegisterCallback callback,
|
||||||
static void
|
static void
|
||||||
gimp_gegl_tool_class_init (GimpGeglToolClass *klass)
|
gimp_gegl_tool_class_init (GimpGeglToolClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
||||||
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
||||||
GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
|
GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
|
||||||
|
|
||||||
object_class->finalize = gimp_gegl_tool_finalize;
|
im_tool_class->dialog_desc = _("GEGL Operation");
|
||||||
|
|
||||||
tool_class->initialize = gimp_gegl_tool_initialize;
|
im_tool_class->dialog = gimp_gegl_tool_dialog;
|
||||||
|
|
||||||
im_tool_class->dialog_desc = _("GEGL Operation");
|
|
||||||
|
|
||||||
im_tool_class->get_operation = gimp_gegl_tool_get_operation;
|
|
||||||
im_tool_class->map = gimp_gegl_tool_map;
|
|
||||||
im_tool_class->dialog = gimp_gegl_tool_dialog;
|
|
||||||
im_tool_class->reset = gimp_gegl_tool_reset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -124,60 +91,6 @@ gimp_gegl_tool_init (GimpGeglTool *tool)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_gegl_tool_finalize (GObject *object)
|
|
||||||
{
|
|
||||||
GimpGeglTool *tool = GIMP_GEGL_TOOL (object);
|
|
||||||
|
|
||||||
if (tool->operation)
|
|
||||||
{
|
|
||||||
g_free (tool->operation);
|
|
||||||
tool->operation = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tool->config)
|
|
||||||
{
|
|
||||||
g_object_unref (tool->config);
|
|
||||||
tool->config = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gimp_gegl_tool_initialize (GimpTool *tool,
|
|
||||||
GimpDisplay *display,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
GimpGeglTool *g_tool = GIMP_GEGL_TOOL (tool);
|
|
||||||
GimpImage *image = gimp_display_get_image (display);
|
|
||||||
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
|
||||||
|
|
||||||
if (! drawable)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (g_tool->config)
|
|
||||||
gimp_config_reset (GIMP_CONFIG (g_tool->config));
|
|
||||||
|
|
||||||
return GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GeglNode *
|
|
||||||
gimp_gegl_tool_get_operation (GimpImageMapTool *im_tool,
|
|
||||||
GObject **config)
|
|
||||||
{
|
|
||||||
return g_object_new (GEGL_TYPE_NODE, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_gegl_tool_map (GimpImageMapTool *image_map_tool)
|
|
||||||
{
|
|
||||||
GimpGeglTool *tool = GIMP_GEGL_TOOL (image_map_tool);
|
|
||||||
|
|
||||||
if (tool->config)
|
|
||||||
gimp_gegl_config_proxy_sync (tool->config, image_map_tool->operation);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gimp_gegl_tool_operation_blacklisted (const gchar *name,
|
gimp_gegl_tool_operation_blacklisted (const gchar *name,
|
||||||
const gchar *categories_str)
|
const gchar *categories_str)
|
||||||
|
@ -306,21 +219,25 @@ gimp_get_geglopclasses (void)
|
||||||
static void
|
static void
|
||||||
gimp_gegl_tool_dialog (GimpImageMapTool *image_map_tool)
|
gimp_gegl_tool_dialog (GimpImageMapTool *image_map_tool)
|
||||||
{
|
{
|
||||||
GimpGeglTool *tool = GIMP_GEGL_TOOL (image_map_tool);
|
GimpGeglTool *tool = GIMP_GEGL_TOOL (image_map_tool);
|
||||||
GtkListStore *store;
|
GimpOperationTool *o_tool = GIMP_OPERATION_TOOL (image_map_tool);
|
||||||
GtkCellRenderer *cell;
|
GtkListStore *store;
|
||||||
GtkWidget *main_vbox;
|
GtkCellRenderer *cell;
|
||||||
GtkWidget *hbox;
|
GtkWidget *main_vbox;
|
||||||
GtkWidget *label;
|
GtkWidget *hbox;
|
||||||
GtkWidget *combo;
|
GtkWidget *label;
|
||||||
GList *opclasses;
|
GtkWidget *combo;
|
||||||
GList *iter;
|
GList *opclasses;
|
||||||
|
GList *iter;
|
||||||
|
|
||||||
|
GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->dialog (image_map_tool);
|
||||||
|
|
||||||
main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool);
|
main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool);
|
||||||
|
|
||||||
/* The operation combo box */
|
/* The operation combo box */
|
||||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||||
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
|
||||||
|
gtk_box_reorder_child (GTK_BOX (main_vbox), hbox, 0);
|
||||||
gtk_widget_show (hbox);
|
gtk_widget_show (hbox);
|
||||||
|
|
||||||
label = gtk_label_new_with_mnemonic (_("_Operation:"));
|
label = gtk_label_new_with_mnemonic (_("_Operation:"));
|
||||||
|
@ -382,35 +299,15 @@ gimp_gegl_tool_dialog (GimpImageMapTool *image_map_tool)
|
||||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
|
||||||
|
|
||||||
/* The options vbox */
|
/* The options vbox */
|
||||||
tool->options_frame = gimp_frame_new (_("Operation Settings"));
|
o_tool->options_table =
|
||||||
gtk_box_pack_start (GTK_BOX (main_vbox), tool->options_frame,
|
gtk_label_new (_("Select an operation from the list above"));
|
||||||
FALSE, FALSE, 0);
|
gimp_label_set_attributes (GTK_LABEL (o_tool->options_table),
|
||||||
gtk_widget_show (tool->options_frame);
|
|
||||||
|
|
||||||
tool->options_table = gtk_label_new (_("Select an operation from the list above"));
|
|
||||||
gimp_label_set_attributes (GTK_LABEL (tool->options_table),
|
|
||||||
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
|
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
|
||||||
-1);
|
-1);
|
||||||
gtk_misc_set_padding (GTK_MISC (tool->options_table), 0, 4);
|
gtk_misc_set_padding (GTK_MISC (o_tool->options_table), 0, 4);
|
||||||
gtk_container_add (GTK_CONTAINER (tool->options_frame), tool->options_table);
|
gtk_container_add (GTK_CONTAINER (o_tool->options_frame),
|
||||||
gtk_widget_show (tool->options_table);
|
o_tool->options_table);
|
||||||
}
|
gtk_widget_show (o_tool->options_table);
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_gegl_tool_reset (GimpImageMapTool *image_map_tool)
|
|
||||||
{
|
|
||||||
GimpGeglTool *tool = GIMP_GEGL_TOOL (image_map_tool);
|
|
||||||
|
|
||||||
if (tool->config)
|
|
||||||
gimp_config_reset (GIMP_CONFIG (tool->config));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_gegl_tool_config_notify (GObject *object,
|
|
||||||
GParamSpec *pspec,
|
|
||||||
GimpGeglTool *tool)
|
|
||||||
{
|
|
||||||
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -419,66 +316,21 @@ gimp_gegl_tool_operation_changed (GtkWidget *widget,
|
||||||
{
|
{
|
||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
gchar *operation;
|
||||||
|
|
||||||
if (! gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
|
if (! gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
|
model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
|
||||||
|
|
||||||
if (tool->operation)
|
|
||||||
{
|
|
||||||
g_free (tool->operation);
|
|
||||||
tool->operation = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tool->config)
|
|
||||||
{
|
|
||||||
g_object_unref (tool->config);
|
|
||||||
tool->config = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_tree_model_get (model, &iter,
|
gtk_tree_model_get (model, &iter,
|
||||||
COLUMN_NAME, &tool->operation,
|
COLUMN_NAME, &operation,
|
||||||
-1);
|
-1);
|
||||||
|
|
||||||
if (! tool->operation)
|
if (operation)
|
||||||
return;
|
|
||||||
|
|
||||||
if (GIMP_IMAGE_MAP_TOOL (tool)->image_map)
|
|
||||||
{
|
{
|
||||||
gimp_image_map_clear (GIMP_IMAGE_MAP_TOOL (tool)->image_map);
|
gimp_operation_tool_set_operation (GIMP_OPERATION_TOOL (tool),
|
||||||
g_object_unref (GIMP_IMAGE_MAP_TOOL (tool)->image_map);
|
operation);
|
||||||
GIMP_IMAGE_MAP_TOOL (tool)->image_map = NULL;
|
g_free (operation);
|
||||||
}
|
}
|
||||||
|
|
||||||
gegl_node_set (GIMP_IMAGE_MAP_TOOL (tool)->operation,
|
|
||||||
"operation", tool->operation,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
gimp_image_map_tool_create_map (GIMP_IMAGE_MAP_TOOL (tool));
|
|
||||||
|
|
||||||
tool->config = gimp_gegl_get_config_proxy (tool->operation);
|
|
||||||
|
|
||||||
if (tool->options_table)
|
|
||||||
{
|
|
||||||
gtk_widget_destroy (tool->options_table);
|
|
||||||
tool->options_table = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tool->config)
|
|
||||||
{
|
|
||||||
g_signal_connect_object (tool->config, "notify",
|
|
||||||
G_CALLBACK (gimp_gegl_tool_config_notify),
|
|
||||||
G_OBJECT (tool), 0);
|
|
||||||
|
|
||||||
tool->options_table =
|
|
||||||
gimp_prop_table_new (G_OBJECT (tool->config),
|
|
||||||
G_TYPE_FROM_INSTANCE (tool->config),
|
|
||||||
GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (tool)));
|
|
||||||
gtk_container_add (GTK_CONTAINER (tool->options_frame),
|
|
||||||
tool->options_table);
|
|
||||||
gtk_widget_show (tool->options_table);
|
|
||||||
}
|
|
||||||
|
|
||||||
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#define __GIMP_GEGL_TOOL_H__
|
#define __GIMP_GEGL_TOOL_H__
|
||||||
|
|
||||||
|
|
||||||
#include "gimpimagemaptool.h"
|
#include "gimpoperationtool.h"
|
||||||
|
|
||||||
|
|
||||||
#define GIMP_TYPE_GEGL_TOOL (gimp_gegl_tool_get_type ())
|
#define GIMP_TYPE_GEGL_TOOL (gimp_gegl_tool_get_type ())
|
||||||
|
@ -35,20 +35,15 @@ typedef struct _GimpGeglToolClass GimpGeglToolClass;
|
||||||
|
|
||||||
struct _GimpGeglTool
|
struct _GimpGeglTool
|
||||||
{
|
{
|
||||||
GimpImageMapTool parent_instance;
|
GimpOperationTool parent_instance;
|
||||||
|
|
||||||
gchar *operation;
|
|
||||||
GimpObject *config;
|
|
||||||
|
|
||||||
/* dialog */
|
/* dialog */
|
||||||
GtkWidget *operation_combo;
|
GtkWidget *operation_combo;
|
||||||
GtkWidget *options_frame;
|
|
||||||
GtkWidget *options_table;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GimpGeglToolClass
|
struct _GimpGeglToolClass
|
||||||
{
|
{
|
||||||
GimpImageMapToolClass parent_class;
|
GimpOperationToolClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,267 @@
|
||||||
|
/* GIMP - The GNU Image Manipulation Program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <gegl.h>
|
||||||
|
#include <gegl-plugin.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "libgimpcolor/gimpcolor.h"
|
||||||
|
#include "libgimpconfig/gimpconfig.h"
|
||||||
|
#include "libgimpwidgets/gimpwidgets.h"
|
||||||
|
|
||||||
|
#include "tools-types.h"
|
||||||
|
|
||||||
|
#include "gegl/gimp-gegl-config-proxy.h"
|
||||||
|
|
||||||
|
#include "core/gimpdrawable.h"
|
||||||
|
#include "core/gimperror.h"
|
||||||
|
#include "core/gimpimage.h"
|
||||||
|
#include "core/gimpimagemap.h"
|
||||||
|
#include "core/gimpparamspecs-duplicate.h"
|
||||||
|
|
||||||
|
#include "widgets/gimphelp-ids.h"
|
||||||
|
#include "widgets/gimppropwidgets.h"
|
||||||
|
|
||||||
|
#include "display/gimpdisplay.h"
|
||||||
|
|
||||||
|
#include "gimpoperationtool.h"
|
||||||
|
#include "gimpimagemapoptions.h"
|
||||||
|
|
||||||
|
#include "gimp-intl.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* local function prototypes */
|
||||||
|
|
||||||
|
static void gimp_operation_tool_finalize (GObject *object);
|
||||||
|
|
||||||
|
static gboolean gimp_operation_tool_initialize (GimpTool *tool,
|
||||||
|
GimpDisplay *display,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
static GeglNode * gimp_operation_tool_get_operation (GimpImageMapTool *im_tool,
|
||||||
|
GObject **config);
|
||||||
|
static void gimp_operation_tool_map (GimpImageMapTool *im_tool);
|
||||||
|
static void gimp_operation_tool_dialog (GimpImageMapTool *im_tool);
|
||||||
|
static void gimp_operation_tool_reset (GimpImageMapTool *im_tool);
|
||||||
|
|
||||||
|
static void gimp_operation_tool_config_notify (GObject *object,
|
||||||
|
GParamSpec *pspec,
|
||||||
|
GimpOperationTool *tool);
|
||||||
|
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GimpOperationTool, gimp_operation_tool,
|
||||||
|
GIMP_TYPE_IMAGE_MAP_TOOL)
|
||||||
|
|
||||||
|
#define parent_class gimp_operation_tool_parent_class
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
void
|
||||||
|
gimp_operation_tool_register (GimpToolRegisterCallback callback,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
(* callback) (GIMP_TYPE_OPERATION_TOOL,
|
||||||
|
GIMP_TYPE_IMAGE_MAP_OPTIONS, NULL,
|
||||||
|
0,
|
||||||
|
"gimp-operation-tool",
|
||||||
|
_("GEGL Operation"),
|
||||||
|
_("Operation Tool: Use an arbitrary GEGL operation"),
|
||||||
|
N_("_GEGL Operation..."), NULL,
|
||||||
|
NULL, GIMP_HELP_TOOL_OPERATION,
|
||||||
|
GIMP_STOCK_GEGL,
|
||||||
|
data);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_operation_tool_class_init (GimpOperationToolClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
||||||
|
GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->finalize = gimp_operation_tool_finalize;
|
||||||
|
|
||||||
|
tool_class->initialize = gimp_operation_tool_initialize;
|
||||||
|
|
||||||
|
im_tool_class->dialog_desc = _("GEGL Operation");
|
||||||
|
|
||||||
|
im_tool_class->get_operation = gimp_operation_tool_get_operation;
|
||||||
|
im_tool_class->map = gimp_operation_tool_map;
|
||||||
|
im_tool_class->dialog = gimp_operation_tool_dialog;
|
||||||
|
im_tool_class->reset = gimp_operation_tool_reset;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_operation_tool_init (GimpOperationTool *tool)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_operation_tool_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GimpOperationTool *tool = GIMP_OPERATION_TOOL (object);
|
||||||
|
|
||||||
|
if (tool->operation)
|
||||||
|
{
|
||||||
|
g_free (tool->operation);
|
||||||
|
tool->operation = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tool->config)
|
||||||
|
{
|
||||||
|
g_object_unref (tool->config);
|
||||||
|
tool->config = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gimp_operation_tool_initialize (GimpTool *tool,
|
||||||
|
GimpDisplay *display,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
GimpOperationTool *o_tool = GIMP_OPERATION_TOOL (tool);
|
||||||
|
GimpImage *image = gimp_display_get_image (display);
|
||||||
|
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
||||||
|
|
||||||
|
if (! drawable)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (o_tool->config)
|
||||||
|
gimp_config_reset (GIMP_CONFIG (o_tool->config));
|
||||||
|
|
||||||
|
return GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GeglNode *
|
||||||
|
gimp_operation_tool_get_operation (GimpImageMapTool *im_tool,
|
||||||
|
GObject **config)
|
||||||
|
{
|
||||||
|
return g_object_new (GEGL_TYPE_NODE, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_operation_tool_map (GimpImageMapTool *image_map_tool)
|
||||||
|
{
|
||||||
|
GimpOperationTool *tool = GIMP_OPERATION_TOOL (image_map_tool);
|
||||||
|
|
||||||
|
if (tool->config)
|
||||||
|
gimp_gegl_config_proxy_sync (tool->config, image_map_tool->operation);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************/
|
||||||
|
/* Operation dialog */
|
||||||
|
/*****************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_operation_tool_dialog (GimpImageMapTool *image_map_tool)
|
||||||
|
{
|
||||||
|
GimpOperationTool *tool = GIMP_OPERATION_TOOL (image_map_tool);
|
||||||
|
GtkWidget *main_vbox;
|
||||||
|
|
||||||
|
main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool);
|
||||||
|
|
||||||
|
/* The options vbox */
|
||||||
|
tool->options_frame = gimp_frame_new (_("Operation Settings"));
|
||||||
|
gtk_box_pack_start (GTK_BOX (main_vbox), tool->options_frame,
|
||||||
|
FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (tool->options_frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_operation_tool_reset (GimpImageMapTool *image_map_tool)
|
||||||
|
{
|
||||||
|
GimpOperationTool *tool = GIMP_OPERATION_TOOL (image_map_tool);
|
||||||
|
|
||||||
|
if (tool->config)
|
||||||
|
gimp_config_reset (GIMP_CONFIG (tool->config));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_operation_tool_config_notify (GObject *object,
|
||||||
|
GParamSpec *pspec,
|
||||||
|
GimpOperationTool *tool)
|
||||||
|
{
|
||||||
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_operation_tool_set_operation (GimpOperationTool *tool,
|
||||||
|
const gchar *operation)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GIMP_IS_OPERATION_TOOL (tool));
|
||||||
|
g_return_if_fail (operation != NULL);
|
||||||
|
|
||||||
|
if (tool->operation)
|
||||||
|
{
|
||||||
|
g_free (tool->operation);
|
||||||
|
tool->operation = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tool->config)
|
||||||
|
{
|
||||||
|
g_object_unref (tool->config);
|
||||||
|
tool->config = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
tool->operation = g_strdup (operation);
|
||||||
|
|
||||||
|
if (GIMP_IMAGE_MAP_TOOL (tool)->image_map)
|
||||||
|
{
|
||||||
|
gimp_image_map_clear (GIMP_IMAGE_MAP_TOOL (tool)->image_map);
|
||||||
|
g_object_unref (GIMP_IMAGE_MAP_TOOL (tool)->image_map);
|
||||||
|
GIMP_IMAGE_MAP_TOOL (tool)->image_map = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
gegl_node_set (GIMP_IMAGE_MAP_TOOL (tool)->operation,
|
||||||
|
"operation", tool->operation,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
gimp_image_map_tool_create_map (GIMP_IMAGE_MAP_TOOL (tool));
|
||||||
|
|
||||||
|
tool->config = gimp_gegl_get_config_proxy (tool->operation);
|
||||||
|
|
||||||
|
if (tool->options_table)
|
||||||
|
{
|
||||||
|
gtk_widget_destroy (tool->options_table);
|
||||||
|
tool->options_table = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tool->config)
|
||||||
|
{
|
||||||
|
g_signal_connect_object (tool->config, "notify",
|
||||||
|
G_CALLBACK (gimp_operation_tool_config_notify),
|
||||||
|
G_OBJECT (tool), 0);
|
||||||
|
|
||||||
|
tool->options_table =
|
||||||
|
gimp_prop_table_new (G_OBJECT (tool->config),
|
||||||
|
G_TYPE_FROM_INSTANCE (tool->config),
|
||||||
|
GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (tool)));
|
||||||
|
gtk_container_add (GTK_CONTAINER (tool->options_frame),
|
||||||
|
tool->options_table);
|
||||||
|
gtk_widget_show (tool->options_table);
|
||||||
|
}
|
||||||
|
|
||||||
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
/* GIMP - The GNU Image Manipulation Program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GIMP_OPERATION_TOOL_H__
|
||||||
|
#define __GIMP_OPERATION_TOOL_H__
|
||||||
|
|
||||||
|
|
||||||
|
#include "gimpimagemaptool.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define GIMP_TYPE_OPERATION_TOOL (gimp_operation_tool_get_type ())
|
||||||
|
#define GIMP_OPERATION_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_TOOL, GimpOperationTool))
|
||||||
|
#define GIMP_OPERATION_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_TOOL, GimpOperationToolClass))
|
||||||
|
#define GIMP_IS_OPERATION_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_TOOL))
|
||||||
|
#define GIMP_IS_OPERATION_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_TOOL))
|
||||||
|
#define GIMP_OPERATION_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_TOOL, GimpOperationToolClass))
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _GimpOperationTool GimpOperationTool;
|
||||||
|
typedef struct _GimpOperationToolClass GimpOperationToolClass;
|
||||||
|
|
||||||
|
struct _GimpOperationTool
|
||||||
|
{
|
||||||
|
GimpImageMapTool parent_instance;
|
||||||
|
|
||||||
|
gchar *operation;
|
||||||
|
GimpObject *config;
|
||||||
|
|
||||||
|
/* dialog */
|
||||||
|
GtkWidget *options_frame;
|
||||||
|
GtkWidget *options_table;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GimpOperationToolClass
|
||||||
|
{
|
||||||
|
GimpImageMapToolClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
void gimp_operation_tool_register (GimpToolRegisterCallback callback,
|
||||||
|
gpointer data);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
GType gimp_operation_tool_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
void gimp_operation_tool_set_operation (GimpOperationTool *tool,
|
||||||
|
const gchar *operation);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __GIMP_OPERATION_TOOL_H__ */
|
Loading…
Reference in New Issue