2008-02-05 07:32:45 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2008-02-05 07:32:45 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2008-02-05 07:32:45 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-02-05 07:32:45 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-02-05 21:20:11 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2008-02-05 07:32:45 +08:00
|
|
|
#include <gegl.h>
|
2008-04-26 19:49:25 +08:00
|
|
|
#include <gegl-plugin.h>
|
2008-02-05 07:32:45 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2008-02-05 21:20:11 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2008-02-05 07:32:45 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "tools-types.h"
|
|
|
|
|
2010-02-18 03:45:20 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2008-02-05 21:20:11 +08:00
|
|
|
#include "widgets/gimppropwidgets.h"
|
|
|
|
|
2012-05-01 05:49:09 +08:00
|
|
|
#include "gimpcoloroptions.h"
|
2008-02-05 07:32:45 +08:00
|
|
|
#include "gimpgegltool.h"
|
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
2008-10-21 19:34:00 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
COLUMN_NAME,
|
|
|
|
COLUMN_LABEL,
|
2014-05-07 21:30:38 +08:00
|
|
|
COLUMN_ICON_NAME,
|
2008-11-17 04:17:43 +08:00
|
|
|
N_COLUMNS
|
2008-10-21 19:34:00 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-02-05 07:32:45 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2012-03-27 02:59:49 +08:00
|
|
|
static void gimp_gegl_tool_dialog (GimpImageMapTool *im_tool);
|
2008-02-05 07:32:45 +08:00
|
|
|
|
2012-03-27 02:59:49 +08:00
|
|
|
static void gimp_gegl_tool_operation_changed (GtkWidget *widget,
|
|
|
|
GimpGeglTool *tool);
|
2008-02-05 07:32:45 +08:00
|
|
|
|
|
|
|
|
2012-03-27 02:59:49 +08:00
|
|
|
G_DEFINE_TYPE (GimpGeglTool, gimp_gegl_tool, GIMP_TYPE_OPERATION_TOOL)
|
2008-02-05 07:32:45 +08:00
|
|
|
|
|
|
|
#define parent_class gimp_gegl_tool_parent_class
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_gegl_tool_register (GimpToolRegisterCallback callback,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
(* callback) (GIMP_TYPE_GEGL_TOOL,
|
2012-05-01 05:49:09 +08:00
|
|
|
GIMP_TYPE_COLOR_OPTIONS,
|
|
|
|
gimp_color_options_gui,
|
2008-02-05 07:32:45 +08:00
|
|
|
0,
|
|
|
|
"gimp-gegl-tool",
|
|
|
|
_("GEGL Operation"),
|
2008-02-06 03:12:22 +08:00
|
|
|
_("GEGL Tool: Use an arbitrary GEGL operation"),
|
2008-02-05 07:32:45 +08:00
|
|
|
N_("_GEGL Operation..."), NULL,
|
2010-02-18 01:41:04 +08:00
|
|
|
NULL, GIMP_HELP_TOOL_GEGL,
|
2008-02-05 08:38:08 +08:00
|
|
|
GIMP_STOCK_GEGL,
|
2008-02-05 07:32:45 +08:00
|
|
|
data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_gegl_tool_class_init (GimpGeglToolClass *klass)
|
|
|
|
{
|
|
|
|
GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
|
|
|
|
|
2012-03-27 02:59:49 +08:00
|
|
|
im_tool_class->dialog_desc = _("GEGL Operation");
|
2008-02-05 07:32:45 +08:00
|
|
|
|
2012-03-27 02:59:49 +08:00
|
|
|
im_tool_class->dialog = gimp_gegl_tool_dialog;
|
2008-02-05 07:32:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_gegl_tool_init (GimpGeglTool *tool)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-09-06 01:11:48 +08:00
|
|
|
static gboolean
|
2010-03-18 07:39:46 +08:00
|
|
|
gimp_gegl_tool_operation_blacklisted (const gchar *name,
|
|
|
|
const gchar *categories_str)
|
2008-09-06 01:11:48 +08:00
|
|
|
{
|
2010-03-18 07:39:46 +08:00
|
|
|
static const gchar * const category_blacklist[] =
|
|
|
|
{
|
|
|
|
"compositors",
|
|
|
|
"core",
|
|
|
|
"debug",
|
2013-12-04 01:43:00 +08:00
|
|
|
"display",
|
2010-03-18 07:39:46 +08:00
|
|
|
"hidden",
|
|
|
|
"input",
|
|
|
|
"output",
|
|
|
|
"programming",
|
|
|
|
"transform",
|
|
|
|
"video"
|
|
|
|
};
|
|
|
|
static const gchar * const name_blacklist[] =
|
2008-09-06 01:37:17 +08:00
|
|
|
{
|
2013-06-01 04:54:46 +08:00
|
|
|
/* these ops are already added to the menus via
|
2014-01-02 02:07:48 +08:00
|
|
|
* filters-actions or drawable-actions
|
2013-06-01 04:54:46 +08:00
|
|
|
*/
|
2013-07-19 04:53:06 +08:00
|
|
|
"gegl:alien-map",
|
2013-08-04 04:46:45 +08:00
|
|
|
"gegl:antialias",
|
2014-04-14 02:58:25 +08:00
|
|
|
"gegl:apply-lens",
|
2013-09-04 06:15:45 +08:00
|
|
|
"gegl:bump-map",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:c2g",
|
|
|
|
"gegl:cartoon",
|
2014-05-19 07:31:55 +08:00
|
|
|
"gegl:cell-noise",
|
2013-08-04 05:30:00 +08:00
|
|
|
"gegl:channel-mixer",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:checkerboard",
|
|
|
|
"gegl:color",
|
2014-11-11 05:23:54 +08:00
|
|
|
"gegl:color-exchange",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:color-reduction",
|
2014-06-20 07:14:21 +08:00
|
|
|
"gegl:color-rotate",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:color-temperature",
|
|
|
|
"gegl:color-to-alpha",
|
2014-05-29 08:36:59 +08:00
|
|
|
"gegl:convolution-matrix",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:cubism",
|
|
|
|
"gegl:deinterlace",
|
|
|
|
"gegl:difference-of-gaussians",
|
2014-08-04 03:34:32 +08:00
|
|
|
"gegl:distance-transform",
|
2013-06-01 07:13:22 +08:00
|
|
|
"gegl:dropshadow",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:edge-laplace",
|
|
|
|
"gegl:edge-sobel",
|
|
|
|
"gegl:emboss",
|
|
|
|
"gegl:exposure",
|
|
|
|
"gegl:fractal-trace",
|
|
|
|
"gegl:gaussian-blur",
|
2013-06-01 07:20:30 +08:00
|
|
|
"gegl:grid",
|
2013-06-24 06:45:04 +08:00
|
|
|
"gegl:invert-linear",
|
|
|
|
"gegl:invert-gamma",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:lens-distortion",
|
2014-06-27 18:02:16 +08:00
|
|
|
"gegl:mirrors",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:mono-mixer",
|
2013-09-22 00:58:44 +08:00
|
|
|
"gegl:mosaic",
|
2013-06-03 06:20:42 +08:00
|
|
|
"gegl:motion-blur-circular",
|
|
|
|
"gegl:motion-blur-linear",
|
|
|
|
"gegl:motion-blur-zoom",
|
2013-06-04 06:54:12 +08:00
|
|
|
"gegl:noise-cie-lch",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:noise-hsv",
|
|
|
|
"gegl:noise-hurl",
|
|
|
|
"gegl:noise-pick",
|
2014-05-05 07:57:33 +08:00
|
|
|
"gegl:noise-reduction",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:noise-rgb",
|
|
|
|
"gegl:noise-slur",
|
2014-11-23 03:45:15 +08:00
|
|
|
"gegl:noise-solid",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:noise-spread",
|
2014-10-12 02:32:31 +08:00
|
|
|
"gegl:oilify",
|
2014-05-17 07:23:24 +08:00
|
|
|
"gegl:panorama-projection",
|
2014-05-17 07:17:30 +08:00
|
|
|
"gegl:perlin-noise",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:photocopy",
|
|
|
|
"gegl:pixelize",
|
2013-08-27 14:14:51 +08:00
|
|
|
"gegl:plasma",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:polar-coordinates",
|
|
|
|
"gegl:red-eye-removal",
|
|
|
|
"gegl:ripple",
|
2014-05-17 07:17:30 +08:00
|
|
|
"gegl:simplex-noise",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:shift",
|
2014-11-22 03:49:15 +08:00
|
|
|
"gegl:sinus",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:softglow",
|
2013-11-16 01:58:52 +08:00
|
|
|
"gegl:stretch-contrast",
|
2013-11-16 23:30:04 +08:00
|
|
|
"gegl:stretch-contrast-hsv",
|
2014-11-19 03:01:09 +08:00
|
|
|
"gegl:supernova",
|
2014-01-02 02:07:48 +08:00
|
|
|
"gegl:texturize-canvas",
|
2014-05-17 03:59:30 +08:00
|
|
|
"gegl:tile-glass",
|
2013-07-28 23:53:41 +08:00
|
|
|
"gegl:tile-seamless",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:unsharp-mask",
|
|
|
|
"gegl:value-invert",
|
2014-11-13 05:20:11 +08:00
|
|
|
"gegl:video-degradation",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:vignette",
|
2013-06-01 21:13:40 +08:00
|
|
|
"gegl:waves",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:whirl-pinch",
|
2013-12-01 19:55:44 +08:00
|
|
|
"gegl:wind",
|
2013-06-01 04:54:46 +08:00
|
|
|
|
|
|
|
/* these ops are blacklisted for other reasons */
|
2013-06-04 06:54:12 +08:00
|
|
|
"gegl:contrast-curve",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:convert-format", /* pointless */
|
2012-05-02 01:41:32 +08:00
|
|
|
"gegl:fill-path",
|
2014-06-20 07:14:21 +08:00
|
|
|
"gegl:gray", /* we use gimp's op */
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:hstack", /* pointless */
|
|
|
|
"gegl:introspect", /* pointless */
|
|
|
|
"gegl:layer", /* we use gimp's ops */
|
|
|
|
"gegl:matting-global", /* used in the foreground select tool */
|
|
|
|
"gegl:opacity", /* poinless */
|
2012-05-02 01:41:32 +08:00
|
|
|
"gegl:path",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:posterize", /* we use gimp's op */
|
|
|
|
"gegl:seamless-clone", /* used in the seamless clone tool */
|
|
|
|
"gegl:text", /* we use gimp's text rendering */
|
|
|
|
"gegl:threshold", /* we use gimp's op */
|
|
|
|
"gegl:tile", /* pointless */
|
2013-03-27 08:35:49 +08:00
|
|
|
"gegl:vector-stroke",
|
2008-09-06 01:37:17 +08:00
|
|
|
};
|
2011-04-04 14:19:12 +08:00
|
|
|
|
|
|
|
gchar **categories;
|
|
|
|
gint i;
|
2008-09-06 01:11:48 +08:00
|
|
|
|
2010-03-18 07:39:46 +08:00
|
|
|
/* Operations with no name are abstract base classes */
|
2011-04-04 14:19:12 +08:00
|
|
|
if (! name)
|
2010-03-18 07:39:46 +08:00
|
|
|
return TRUE;
|
|
|
|
|
2012-05-06 02:49:27 +08:00
|
|
|
if (g_str_has_prefix (name, "gimp"))
|
|
|
|
return TRUE;
|
|
|
|
|
2010-03-18 07:39:46 +08:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (name_blacklist); i++)
|
2008-09-06 01:11:48 +08:00
|
|
|
{
|
2012-05-06 02:49:27 +08:00
|
|
|
if (! strcmp (name, name_blacklist[i]))
|
2008-09-06 01:11:48 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-04-04 14:19:12 +08:00
|
|
|
if (! categories_str)
|
2010-03-18 07:39:46 +08:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
categories = g_strsplit (categories_str, ":", 0);
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (category_blacklist); i++)
|
|
|
|
{
|
|
|
|
gint j;
|
2011-04-04 14:19:12 +08:00
|
|
|
|
2010-03-18 07:39:46 +08:00
|
|
|
for (j = 0; categories[j]; j++)
|
2011-04-04 14:19:12 +08:00
|
|
|
if (! strcmp (categories[j], category_blacklist[i]))
|
2010-03-18 07:39:46 +08:00
|
|
|
{
|
|
|
|
g_strfreev (categories);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_strfreev (categories);
|
2011-04-04 14:19:12 +08:00
|
|
|
|
2008-09-06 01:11:48 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Builds a GList of the class structures of all subtypes of type.
|
2008-04-26 19:49:25 +08:00
|
|
|
*/
|
|
|
|
static GList *
|
|
|
|
gimp_get_subtype_classes (GType type,
|
|
|
|
GList *classes)
|
|
|
|
{
|
2008-09-06 01:11:48 +08:00
|
|
|
GeglOperationClass *klass;
|
|
|
|
GType *ops;
|
2012-03-30 02:37:40 +08:00
|
|
|
const gchar *categories;
|
2008-09-06 01:11:48 +08:00
|
|
|
guint n_ops;
|
|
|
|
gint i;
|
2008-04-26 19:49:25 +08:00
|
|
|
|
2008-09-06 01:11:48 +08:00
|
|
|
if (! type)
|
2008-04-26 19:49:25 +08:00
|
|
|
return classes;
|
|
|
|
|
2008-09-06 01:11:48 +08:00
|
|
|
klass = GEGL_OPERATION_CLASS (g_type_class_ref (type));
|
2008-04-26 20:12:26 +08:00
|
|
|
ops = g_type_children (type, &n_ops);
|
2008-04-26 19:49:25 +08:00
|
|
|
|
2012-03-30 02:37:40 +08:00
|
|
|
categories = gegl_operation_class_get_key (klass, "categories");
|
|
|
|
|
|
|
|
if (! gimp_gegl_tool_operation_blacklisted (klass->name, categories))
|
2010-03-18 07:39:46 +08:00
|
|
|
classes = g_list_prepend (classes, klass);
|
2008-04-26 19:49:25 +08:00
|
|
|
|
2008-04-26 20:12:26 +08:00
|
|
|
for (i = 0; i < n_ops; i++)
|
|
|
|
classes = gimp_get_subtype_classes (ops[i], classes);
|
2008-04-26 19:49:25 +08:00
|
|
|
|
|
|
|
if (ops)
|
|
|
|
g_free (ops);
|
2008-04-26 20:12:26 +08:00
|
|
|
|
2008-04-26 19:49:25 +08:00
|
|
|
return classes;
|
|
|
|
}
|
|
|
|
|
2008-04-26 20:12:26 +08:00
|
|
|
static gint
|
|
|
|
gimp_gegl_tool_compare_operation_names (GeglOperationClass *a,
|
|
|
|
GeglOperationClass *b)
|
2008-04-26 19:49:25 +08:00
|
|
|
{
|
2014-06-10 09:11:54 +08:00
|
|
|
const gchar *name_a = gegl_operation_class_get_key (a, "title");
|
|
|
|
const gchar *name_b = gegl_operation_class_get_key (b, "title");
|
|
|
|
|
|
|
|
if (! name_a) name_a = a->name;
|
|
|
|
if (! name_b) name_b = b->name;
|
|
|
|
|
|
|
|
return strcmp (name_a, name_b);
|
2008-04-26 19:49:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static GList *
|
|
|
|
gimp_get_geglopclasses (void)
|
|
|
|
{
|
2008-04-26 20:12:26 +08:00
|
|
|
GList *opclasses;
|
2008-04-26 19:49:25 +08:00
|
|
|
|
|
|
|
opclasses = gimp_get_subtype_classes (GEGL_TYPE_OPERATION, NULL);
|
2008-04-26 20:12:26 +08:00
|
|
|
|
|
|
|
opclasses = g_list_sort (opclasses,
|
|
|
|
(GCompareFunc)
|
|
|
|
gimp_gegl_tool_compare_operation_names);
|
2008-04-26 19:49:25 +08:00
|
|
|
|
|
|
|
return opclasses;
|
|
|
|
}
|
|
|
|
|
2008-02-05 07:32:45 +08:00
|
|
|
|
|
|
|
/*****************/
|
|
|
|
/* Gegl dialog */
|
|
|
|
/*****************/
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_gegl_tool_dialog (GimpImageMapTool *image_map_tool)
|
|
|
|
{
|
2012-03-27 02:59:49 +08:00
|
|
|
GimpGeglTool *tool = GIMP_GEGL_TOOL (image_map_tool);
|
|
|
|
GimpOperationTool *o_tool = GIMP_OPERATION_TOOL (image_map_tool);
|
|
|
|
GtkListStore *store;
|
|
|
|
GtkCellRenderer *cell;
|
|
|
|
GtkWidget *main_vbox;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *combo;
|
|
|
|
GList *opclasses;
|
|
|
|
GList *iter;
|
|
|
|
|
|
|
|
GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->dialog (image_map_tool);
|
2008-02-05 07:32:45 +08:00
|
|
|
|
2008-06-29 21:54:01 +08:00
|
|
|
main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool);
|
2008-06-03 18:51:04 +08:00
|
|
|
|
2008-02-05 07:32:45 +08:00
|
|
|
/* The operation combo box */
|
2011-09-30 17:29:11 +08:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
2008-06-03 18:51:04 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
|
2012-03-27 02:59:49 +08:00
|
|
|
gtk_box_reorder_child (GTK_BOX (main_vbox), hbox, 0);
|
2008-02-05 07:32:45 +08:00
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2008-11-17 04:17:43 +08:00
|
|
|
store = gtk_list_store_new (N_COLUMNS,
|
2011-07-25 21:20:53 +08:00
|
|
|
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
|
2008-02-05 07:32:45 +08:00
|
|
|
|
2008-04-26 19:49:25 +08:00
|
|
|
opclasses = gimp_get_geglopclasses ();
|
2008-04-26 20:12:26 +08:00
|
|
|
|
2008-10-21 19:34:00 +08:00
|
|
|
for (iter = opclasses; iter; iter = iter->next)
|
2008-04-26 19:49:25 +08:00
|
|
|
{
|
2014-06-10 09:11:54 +08:00
|
|
|
GeglOperationClass *opclass = GEGL_OPERATION_CLASS (iter->data);
|
|
|
|
const gchar *icon_name = NULL;
|
|
|
|
const gchar *op_name = opclass->name;
|
|
|
|
const gchar *title;
|
|
|
|
gchar *label;
|
2008-04-26 20:12:26 +08:00
|
|
|
|
2010-03-18 07:39:46 +08:00
|
|
|
if (g_str_has_prefix (opclass->name, "gegl:"))
|
2014-06-10 09:11:54 +08:00
|
|
|
icon_name = GIMP_STOCK_GEGL;
|
|
|
|
|
|
|
|
if (g_str_has_prefix (op_name, "gegl:"))
|
|
|
|
op_name += strlen ("gegl:");
|
|
|
|
|
|
|
|
title = gegl_operation_class_get_key (opclass, "title");
|
|
|
|
|
|
|
|
if (title)
|
|
|
|
label = g_strdup_printf ("%s (%s)", title, op_name);
|
2010-03-18 07:39:46 +08:00
|
|
|
else
|
2014-06-10 09:11:54 +08:00
|
|
|
label = g_strdup (op_name);
|
2010-03-18 07:39:46 +08:00
|
|
|
|
|
|
|
gtk_list_store_insert_with_values (store, NULL, -1,
|
2014-05-07 21:30:38 +08:00
|
|
|
COLUMN_NAME, opclass->name,
|
|
|
|
COLUMN_LABEL, label,
|
|
|
|
COLUMN_ICON_NAME, icon_name,
|
2010-03-18 07:39:46 +08:00
|
|
|
-1);
|
2014-06-10 09:11:54 +08:00
|
|
|
|
|
|
|
g_free (label);
|
2008-04-26 20:12:26 +08:00
|
|
|
}
|
|
|
|
|
2008-04-26 19:49:25 +08:00
|
|
|
g_list_free (opclasses);
|
2008-02-05 07:32:45 +08:00
|
|
|
|
|
|
|
combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
|
2008-10-21 19:34:00 +08:00
|
|
|
g_object_unref (store);
|
2008-02-05 07:32:45 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (combo);
|
|
|
|
|
2008-10-21 19:34:00 +08:00
|
|
|
cell = gtk_cell_renderer_pixbuf_new ();
|
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, FALSE);
|
|
|
|
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), cell,
|
2014-05-07 21:30:38 +08:00
|
|
|
"icon-name", COLUMN_ICON_NAME);
|
2008-10-21 19:34:00 +08:00
|
|
|
|
|
|
|
cell = gtk_cell_renderer_text_new ();
|
2014-06-10 09:11:54 +08:00
|
|
|
g_object_set (cell,
|
|
|
|
"ellipsize", PANGO_ELLIPSIZE_MIDDLE,
|
|
|
|
NULL);
|
2008-10-21 19:34:00 +08:00
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
|
|
|
|
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), cell,
|
|
|
|
"text", COLUMN_LABEL);
|
2008-02-05 07:32:45 +08:00
|
|
|
|
|
|
|
g_signal_connect (combo, "changed",
|
|
|
|
G_CALLBACK (gimp_gegl_tool_operation_changed),
|
|
|
|
tool);
|
|
|
|
|
|
|
|
tool->operation_combo = combo;
|
|
|
|
|
2013-05-20 23:42:32 +08:00
|
|
|
tool->description_label = gtk_label_new ("");
|
|
|
|
gtk_label_set_line_wrap (GTK_LABEL (tool->description_label), TRUE);
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (tool->description_label), 0.0, 0.0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), tool->description_label,
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
gtk_box_reorder_child (GTK_BOX (main_vbox), tool->description_label, 1);
|
|
|
|
|
2008-02-05 07:32:45 +08:00
|
|
|
/* The options vbox */
|
2014-05-27 08:11:51 +08:00
|
|
|
o_tool->options_gui =
|
2012-03-27 02:59:49 +08:00
|
|
|
gtk_label_new (_("Select an operation from the list above"));
|
2014-05-27 08:11:51 +08:00
|
|
|
gimp_label_set_attributes (GTK_LABEL (o_tool->options_gui),
|
2008-02-18 23:31:23 +08:00
|
|
|
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
|
|
|
|
-1);
|
2014-05-27 08:11:51 +08:00
|
|
|
gtk_misc_set_padding (GTK_MISC (o_tool->options_gui), 0, 4);
|
2012-04-01 00:58:13 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (o_tool->options_box),
|
2014-05-27 08:11:51 +08:00
|
|
|
o_tool->options_gui);
|
|
|
|
gtk_widget_show (o_tool->options_gui);
|
2008-02-05 07:32:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_gegl_tool_operation_changed (GtkWidget *widget,
|
|
|
|
GimpGeglTool *tool)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
2012-03-27 02:59:49 +08:00
|
|
|
gchar *operation;
|
2008-02-05 07:32:45 +08:00
|
|
|
|
|
|
|
if (! gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
|
|
|
|
return;
|
|
|
|
|
|
|
|
model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, &iter,
|
2012-03-27 02:59:49 +08:00
|
|
|
COLUMN_NAME, &operation,
|
2008-02-05 07:32:45 +08:00
|
|
|
-1);
|
|
|
|
|
2012-03-27 02:59:49 +08:00
|
|
|
if (operation)
|
2008-02-05 21:54:25 +08:00
|
|
|
{
|
2013-05-20 23:42:32 +08:00
|
|
|
const gchar *description;
|
|
|
|
|
|
|
|
description = gegl_operation_get_key (operation, "description");
|
|
|
|
|
|
|
|
if (description)
|
|
|
|
{
|
|
|
|
gtk_label_set_text (GTK_LABEL (tool->description_label), description);
|
|
|
|
gtk_widget_show (tool->description_label);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_widget_hide (tool->description_label);
|
|
|
|
}
|
|
|
|
|
2012-03-27 02:59:49 +08:00
|
|
|
gimp_operation_tool_set_operation (GIMP_OPERATION_TOOL (tool),
|
2014-05-23 05:29:59 +08:00
|
|
|
operation, NULL, NULL);
|
2012-03-27 02:59:49 +08:00
|
|
|
g_free (operation);
|
2008-02-05 21:54:25 +08:00
|
|
|
}
|
2008-02-05 07:32:45 +08:00
|
|
|
}
|