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"
|
|
|
|
|
2016-05-14 04:00:25 +08:00
|
|
|
#include "gimpfilteroptions.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 */
|
|
|
|
|
2016-05-10 06:08:36 +08:00
|
|
|
static void gimp_gegl_tool_dialog (GimpFilterTool *filter_tool);
|
2008-02-05 07:32:45 +08:00
|
|
|
|
2016-05-10 06:08:36 +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,
|
2016-05-14 04:00:25 +08:00
|
|
|
GIMP_TYPE_FILTER_OPTIONS,
|
2012-05-01 05:49:09 +08:00
|
|
|
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,
|
2017-03-05 23:01:59 +08:00
|
|
|
GIMP_ICON_GEGL,
|
2008-02-05 07:32:45 +08:00
|
|
|
data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_gegl_tool_class_init (GimpGeglToolClass *klass)
|
|
|
|
{
|
2016-05-10 06:08:36 +08:00
|
|
|
GimpFilterToolClass *filter_tool_class = GIMP_FILTER_TOOL_CLASS (klass);
|
2008-02-05 07:32:45 +08:00
|
|
|
|
2016-05-10 06:08:36 +08:00
|
|
|
filter_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",
|
2015-01-14 03:40:13 +08:00
|
|
|
"gegl:color-enhance",
|
2014-11-11 05:23:54 +08:00
|
|
|
"gegl:color-exchange",
|
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",
|
2017-02-03 00:43:27 +08:00
|
|
|
"gegl:component-extract",
|
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",
|
2015-01-21 05:45:33 +08:00
|
|
|
"gegl:diffraction-patterns",
|
2015-06-08 15:09:31 +08:00
|
|
|
"gegl:displace",
|
2014-08-04 03:34:32 +08:00
|
|
|
"gegl:distance-transform",
|
2016-12-27 01:55:08 +08:00
|
|
|
"gegl:dither",
|
2013-06-01 07:13:22 +08:00
|
|
|
"gegl:dropshadow",
|
2015-03-04 05:55:39 +08:00
|
|
|
"gegl:edge",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:edge-laplace",
|
2017-01-22 21:35:35 +08:00
|
|
|
"gegl:edge-neon",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:edge-sobel",
|
|
|
|
"gegl:emboss",
|
2014-12-16 06:42:57 +08:00
|
|
|
"gegl:engrave",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:exposure",
|
2017-02-03 03:42:58 +08:00
|
|
|
"gegl:fattal02",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:fractal-trace",
|
|
|
|
"gegl:gaussian-blur",
|
2015-11-26 18:20:44 +08:00
|
|
|
"gegl:gaussian-blur-selective",
|
2016-04-16 10:17:49 +08:00
|
|
|
"gegl:gegl",
|
2013-06-01 07:20:30 +08:00
|
|
|
"gegl:grid",
|
2016-01-25 07:54:05 +08:00
|
|
|
"gegl:high-pass",
|
2014-12-05 03:30:57 +08:00
|
|
|
"gegl:illusion",
|
2017-02-03 02:54:23 +08:00
|
|
|
"gegl:image-gradient",
|
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-12-31 18:12:53 +08:00
|
|
|
"gegl:lens-flare",
|
2017-02-03 03:42:58 +08:00
|
|
|
"gegl:mantiuk06",
|
2015-09-04 04:12:23 +08:00
|
|
|
"gegl:maze",
|
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",
|
2017-02-03 03:42:58 +08:00
|
|
|
"gegl:reinhard05",
|
2017-02-03 00:43:27 +08:00
|
|
|
"gegl:rgb-clip",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:ripple",
|
2016-01-25 07:33:53 +08:00
|
|
|
"gegl:saturation",
|
2015-11-23 04:32:36 +08:00
|
|
|
"gegl:sepia",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:shift",
|
2015-11-23 04:32:36 +08:00
|
|
|
"gegl:simplex-noise",
|
2014-11-22 03:49:15 +08:00
|
|
|
"gegl:sinus",
|
2017-02-03 00:43:27 +08:00
|
|
|
"gegl:slic",
|
2017-02-03 02:54:23 +08:00
|
|
|
"gegl:snn-mean",
|
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",
|
2017-02-03 03:42:58 +08:00
|
|
|
"gegl:stress",
|
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",
|
2015-04-30 23:59:49 +08:00
|
|
|
"gegl:tile-paper",
|
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",
|
2015-02-07 02:26:06 +08:00
|
|
|
"gegl:value-propagate",
|
2014-11-13 05:20:11 +08:00
|
|
|
"gegl:video-degradation",
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:vignette",
|
2017-02-03 00:43:27 +08:00
|
|
|
"gegl:waterpixels",
|
2017-01-23 09:33:59 +08:00
|
|
|
"gegl:wavelet-blur",
|
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 */
|
2017-02-03 02:54:23 +08:00
|
|
|
"gegl:ditto", /* 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 */
|
2015-05-02 12:38:09 +08:00
|
|
|
"gegl:lcms-from-profile", /* not usable here */
|
2015-05-02 12:09:17 +08:00
|
|
|
"gegl:linear-gradient", /* we use the blend tool */
|
2017-02-03 00:43:27 +08:00
|
|
|
"gegl:map-absolute", /* pointless */
|
|
|
|
"gegl:map-relative", /* pointless */
|
2013-06-01 04:54:46 +08:00
|
|
|
"gegl:matting-global", /* used in the foreground select tool */
|
2017-01-26 05:32:11 +08:00
|
|
|
"gegl:matting-levin", /* used in the foreground select tool */
|
2013-06-01 04:54:46 +08:00
|
|
|
"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 */
|
2015-05-02 12:09:17 +08:00
|
|
|
"gegl:radial-gradient", /* we use the blend tool */
|
2017-02-03 00:43:27 +08:00
|
|
|
"gegl:rectangle", /* pointless */
|
2013-06-01 04:54:46 +08:00
|
|
|
"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 */
|
2017-02-03 02:54:23 +08:00
|
|
|
"gegl:unpremul", /* 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
|
2016-05-10 06:08:36 +08:00
|
|
|
gimp_gegl_tool_dialog (GimpFilterTool *filter_tool)
|
2008-02-05 07:32:45 +08:00
|
|
|
{
|
2016-05-10 06:08:36 +08:00
|
|
|
GimpGeglTool *tool = GIMP_GEGL_TOOL (filter_tool);
|
|
|
|
GimpOperationTool *o_tool = GIMP_OPERATION_TOOL (filter_tool);
|
2012-03-27 02:59:49 +08:00
|
|
|
GtkListStore *store;
|
|
|
|
GtkCellRenderer *cell;
|
|
|
|
GtkWidget *main_vbox;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *combo;
|
|
|
|
GList *opclasses;
|
|
|
|
GList *iter;
|
|
|
|
|
2016-05-10 06:08:36 +08:00
|
|
|
GIMP_FILTER_TOOL_CLASS (parent_class)->dialog (filter_tool);
|
2008-02-05 07:32:45 +08:00
|
|
|
|
2016-05-10 06:08:36 +08:00
|
|
|
main_vbox = gimp_filter_tool_dialog_get_vbox (filter_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:"))
|
2017-03-05 23:01:59 +08:00
|
|
|
icon_name = GIMP_ICON_GEGL;
|
2014-06-10 09:11:54 +08:00
|
|
|
|
|
|
|
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);
|
2016-09-09 01:11:20 +08:00
|
|
|
gtk_label_set_xalign (GTK_LABEL (tool->description_label), 0.0);
|
2013-05-20 23:42:32 +08:00
|
|
|
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),
|
2016-01-18 03:08:25 +08:00
|
|
|
operation,
|
|
|
|
_("GEGL Operation"),
|
2016-01-23 04:22:36 +08:00
|
|
|
_("GEGL Operation"),
|
2016-01-18 03:08:25 +08:00
|
|
|
NULL,
|
2017-03-05 23:01:59 +08:00
|
|
|
GIMP_ICON_GEGL,
|
2016-01-18 03:08:25 +08:00
|
|
|
GIMP_HELP_TOOL_GEGL);
|
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
|
|
|
}
|