Commit 239b752c authored by klausstaedtler's avatar klausstaedtler

Icons: Some low hanging fruits of my attempt to redraw missing *svg's

parents e8590eb3 c381b975
......@@ -40,7 +40,7 @@
#include "core/gimpsettings.h"
#include "core/gimptoolinfo.h"
#include "gegl/gimp-gegl-config-proxy.h"
#include "gegl/gimp-gegl-config.h"
#include "display/gimpdisplay.h"
......@@ -253,11 +253,11 @@ gimp_gegl_procedure_execute_async (GimpProcedure *procedure,
GimpObject *settings;
GimpContainer *container;
settings = gimp_gegl_get_config_proxy (procedure->original_name,
gimp_viewable_get_icon_name (GIMP_VIEWABLE (procedure)),
GIMP_TYPE_SETTINGS);
settings = gimp_gegl_config_new (procedure->original_name,
gimp_viewable_get_icon_name (GIMP_VIEWABLE (procedure)),
GIMP_TYPE_SETTINGS);
container = gimp_gegl_get_config_container (G_TYPE_FROM_INSTANCE (settings));
container = gimp_gegl_config_get_container (G_TYPE_FROM_INSTANCE (settings));
g_object_unref (settings);
......@@ -272,7 +272,7 @@ gimp_gegl_procedure_execute_async (GimpProcedure *procedure,
node = gegl_node_new_child (NULL,
"operation", procedure->original_name,
NULL);
gimp_gegl_config_proxy_sync (settings, node);
gimp_gegl_config_sync_node (settings, node);
image = gimp_value_get_image (gimp_value_array_index (args, 1),
gimp);
......@@ -323,6 +323,7 @@ gimp_gegl_procedure_execute_async (GimpProcedure *procedure,
procedure->original_name,
gimp_procedure_get_label (procedure),
gimp_procedure_get_label (procedure),
gimp_procedure_get_label (procedure),
gimp_viewable_get_icon_name (GIMP_VIEWABLE (procedure)),
gimp_procedure_get_help_id (procedure));
......
......@@ -741,8 +741,9 @@ user_install_migrate_files (GimpUserInstall *install)
else if (g_file_test (source, G_FILE_TEST_IS_DIR))
{
/* skip these directories for all old versions */
if (strcmp (basename, "tmp") == 0 ||
strcmp (basename, "tool-options") == 0)
if (strcmp (basename, "tmp") == 0 ||
strcmp (basename, "tool-options") == 0 ||
strcmp (basename, "themes") == 0)
{
goto next_file;
}
......
......@@ -241,7 +241,10 @@ gimp_tool_gui_finalize (GObject *object)
**/
GimpToolGui *
gimp_tool_gui_new (GimpToolInfo *tool_info,
const gchar *title,
const gchar *description,
const gchar *icon_name,
const gchar *help_id,
GdkScreen *screen,
gint monitor,
gboolean overlay,
......@@ -258,11 +261,23 @@ gimp_tool_gui_new (GimpToolInfo *tool_info,
private = GET_PRIVATE (gui);
if (! title)
title = tool_info->blurb;
if (! description)
description = tool_info->blurb;
if (! icon_name)
icon_name = gimp_viewable_get_icon_name (GIMP_VIEWABLE (tool_info));
if (! help_id)
help_id = tool_info->help_id;
private->tool_info = g_object_ref (tool_info);
private->title = g_strdup (tool_info->blurb);
private->title = g_strdup (title);
private->description = g_strdup (description);
private->icon_name = g_strdup (gimp_viewable_get_icon_name (GIMP_VIEWABLE (tool_info)));
private->help_id = g_strdup (tool_info->help_id);
private->icon_name = g_strdup (icon_name);
private->help_id = g_strdup (help_id);
private->overlay = overlay;
va_start (args, overlay);
......
......@@ -53,7 +53,10 @@ struct _GimpToolGuiClass
GType gimp_tool_gui_get_type (void) G_GNUC_CONST;
GimpToolGui * gimp_tool_gui_new (GimpToolInfo *tool_info,
const gchar *title,
const gchar *description,
const gchar *icon_name,
const gchar *help_id,
GdkScreen *screen,
gint monitor,
gboolean overlay,
......
......@@ -25,8 +25,8 @@ libappgegl_a_sources = \
gimp-gegl.h \
gimp-gegl-apply-operation.c \
gimp-gegl-apply-operation.h \
gimp-gegl-config-proxy.c \
gimp-gegl-config-proxy.h \
gimp-gegl-config.c \
gimp-gegl-config.h \
gimp-gegl-loops.c \
gimp-gegl-loops.h \
gimp-gegl-mask.c \
......
......@@ -32,13 +32,37 @@
#include "core/gimpparamspecs-duplicate.h"
#include "core/gimpviewable.h"
#include "gimp-gegl-config-proxy.h"
#include "gimp-gegl-config.h"
#include "gimp-gegl-utils.h"
static GHashTable *config_types = NULL;
static GHashTable *config_containers = NULL;
static GHashTable *
gimp_gegl_config_get_type_table (void)
{
static GHashTable *config_types = NULL;
if (! config_types)
config_types = g_hash_table_new_full (g_str_hash,
g_str_equal,
(GDestroyNotify) g_free,
NULL);
return config_types;
}
static GHashTable *
gimp_gegl_config_get_container_table (void)
{
static GHashTable *config_containers = NULL;
if (! config_containers)
config_containers = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
NULL,
(GDestroyNotify) g_object_unref);
return config_containers;
}
static GValue *
gimp_gegl_config_value_new (GParamSpec *pspec)
......@@ -191,21 +215,37 @@ gimp_gegl_config_config_iface_init (GimpConfigInterface *iface)
iface->equal = gimp_gegl_config_equal;
}
/* public functions */
void
gimp_gegl_config_register (const gchar *operation,
GType config_type)
{
GHashTable *config_types;
g_return_if_fail (operation != NULL);
g_return_if_fail (g_type_is_a (config_type, GIMP_TYPE_OBJECT));
config_types = gimp_gegl_config_get_type_table ();
g_hash_table_insert (config_types,
g_strdup (operation),
(gpointer) config_type);
}
GimpObject *
gimp_gegl_get_config_proxy (const gchar *operation,
const gchar *icon_name,
GType parent_type)
gimp_gegl_config_new (const gchar *operation,
const gchar *icon_name,
GType parent_type)
{
GType config_type;
GHashTable *config_types;
GType config_type;
g_return_val_if_fail (operation != NULL, NULL);
g_return_val_if_fail (g_type_is_a (parent_type, GIMP_TYPE_OBJECT), NULL);
if (! config_types)
config_types = g_hash_table_new_full (g_str_hash,
g_str_equal,
(GDestroyNotify) g_free,
NULL);
config_types = gimp_gegl_config_get_type_table ();
config_type = (GType) g_hash_table_lookup (config_types, operation);
......@@ -269,17 +309,14 @@ gimp_gegl_get_config_proxy (const gchar *operation,
}
GimpContainer *
gimp_gegl_get_config_container (GType config_type)
gimp_gegl_config_get_container (GType config_type)
{
GHashTable *config_containers;
GimpContainer *container;
g_return_val_if_fail (g_type_is_a (config_type, GIMP_TYPE_OBJECT), NULL);
if (! config_containers)
config_containers = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
NULL,
(GDestroyNotify) g_object_unref);
config_containers = gimp_gegl_config_get_container_table ();
container = g_hash_table_lookup (config_containers, (gpointer) config_type);
......@@ -295,15 +332,15 @@ gimp_gegl_get_config_container (GType config_type)
}
void
gimp_gegl_config_proxy_sync (GimpObject *proxy,
GeglNode *node)
gimp_gegl_config_sync_node (GimpObject *config,
GeglNode *node)
{
GParamSpec **pspecs;
gchar *operation;
guint n_pspecs;
gint i;
g_return_if_fail (GIMP_IS_OBJECT (proxy));
g_return_if_fail (GIMP_IS_OBJECT (config));
g_return_if_fail (GEGL_IS_NODE (node));
gegl_node_get (node,
......@@ -315,10 +352,28 @@ gimp_gegl_config_proxy_sync (GimpObject *proxy,
pspecs = gegl_operation_list_properties (operation, &n_pspecs);
g_free (operation);
for (i = 0; i < n_pspecs; i++)
{
GParamSpec *pspec = pspecs[i];
/* if the operation has an object property of the config's
* type, set it and done
*/
if (G_IS_PARAM_SPEC_OBJECT (pspec) &&
pspec->value_type == G_TYPE_FROM_INSTANCE (config))
{
gegl_node_set (node,
pspec->name, config,
NULL);
g_free (pspecs);
return;
}
}
for (i = 0; i < n_pspecs; i++)
{
GParamSpec *gegl_pspec = pspecs[i];
GParamSpec *gimp_pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (proxy),
GParamSpec *gimp_pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (config),
gegl_pspec->name);
if (gimp_pspec)
......@@ -327,7 +382,7 @@ gimp_gegl_config_proxy_sync (GimpObject *proxy,
g_value_init (&value, gimp_pspec->value_type);
g_object_get_property (G_OBJECT (proxy), gimp_pspec->name,
g_object_get_property (G_OBJECT (config), gimp_pspec->name,
&value);
if (GEGL_IS_PARAM_SPEC_COLOR (gegl_pspec))
......
......@@ -15,17 +15,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_GEGL_CONFIG_PROXY_H__
#define __GIMP_GEGL_CONFIG_PROXY_H__
#ifndef __GIMP_GEGL_CONFIG_ARGH_H__
#define __GIMP_GEGL_CONFIG_ARGH_H__
GimpObject * gimp_gegl_get_config_proxy (const gchar *operation,
void gimp_gegl_config_register (const gchar *operation,
GType config_type);
GimpObject * gimp_gegl_config_new (const gchar *operation,
const gchar *icon_name,
GType parent_type);
GimpContainer * gimp_gegl_get_config_container (GType config_type);
GimpContainer * gimp_gegl_config_get_container (GType config_type);
void gimp_gegl_config_proxy_sync (GimpObject *proxy,
void gimp_gegl_config_sync_node (GimpObject *config,
GeglNode *node);
#endif /* __GIMP_GEGL_CONFIG_PROXY_H__ */
#endif /* __GIMP_GEGL_CONFIG_ARGH_H__ */
......@@ -37,8 +37,6 @@ libappoperations_generic_a_sources = \
gimphuesaturationconfig.h \
gimplevelsconfig.c \
gimplevelsconfig.h \
gimpthresholdconfig.c \
gimpthresholdconfig.h \
\
gimpoperationblend.c \
gimpoperationblend.h \
......
......@@ -19,13 +19,15 @@
#include "config.h"
#include <gio/gio.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
#include "operations-types.h"
#include "core/gimp.h"
#include "gegl/gimp-gegl-config.h"
#include "gimp-operations.h"
#include "gimpoperationblend.h"
......@@ -53,6 +55,13 @@
#include "gimpoperationposterize.h"
#include "gimpoperationthreshold.h"
#include "gimpbrightnesscontrastconfig.h"
#include "gimpcolorbalanceconfig.h"
#include "gimpcolorizeconfig.h"
#include "gimpcurvesconfig.h"
#include "gimphuesaturationconfig.h"
#include "gimplevelsconfig.h"
#include "gimpoperationpointlayermode.h"
#include "gimpoperationnormalmode.h"
#include "gimpoperationdissolvemode.h"
......@@ -145,4 +154,17 @@ gimp_operations_init (void)
g_type_class_ref (GIMP_TYPE_OPERATION_ERASE_MODE);
g_type_class_ref (GIMP_TYPE_OPERATION_REPLACE_MODE);
g_type_class_ref (GIMP_TYPE_OPERATION_ANTI_ERASE_MODE);
gimp_gegl_config_register ("gimp:brightness-contrast",
GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG);
gimp_gegl_config_register ("gimp:color-balance",
GIMP_TYPE_COLOR_BALANCE_CONFIG);
gimp_gegl_config_register ("gimp:colorize",
GIMP_TYPE_COLORIZE_CONFIG);
gimp_gegl_config_register ("gimp:curves",
GIMP_TYPE_CURVES_CONFIG);
gimp_gegl_config_register ("gimp:hue-saturation",
GIMP_TYPE_HUE_SATURATION_CONFIG);
gimp_gegl_config_register ("gimp:levels",
GIMP_TYPE_LEVELS_CONFIG);
}
......@@ -24,11 +24,31 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
#include "libgimpconfig/gimpconfig.h"
#include "operations-types.h"
#include "gimpoperationthreshold.h"
#include "gimpthresholdconfig.h"
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_LOW,
PROP_HIGH
};
static void gimp_operation_threshold_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_operation_threshold_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static gboolean gimp_operation_threshold_process (GeglOperation *operation,
void *in_buf,
......@@ -51,8 +71,10 @@ gimp_operation_threshold_class_init (GimpOperationThresholdClass *klass)
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
object_class->set_property = gimp_operation_point_filter_set_property;
object_class->get_property = gimp_operation_point_filter_get_property;
object_class->set_property = gimp_operation_threshold_set_property;
object_class->get_property = gimp_operation_threshold_get_property;
point_class->process = gimp_operation_threshold_process;
gegl_operation_class_set_keys (operation_class,
"name", "gimp:threshold",
......@@ -60,16 +82,19 @@ gimp_operation_threshold_class_init (GimpOperationThresholdClass *klass)
"description", "GIMP Threshold operation",
NULL);
point_class->process = gimp_operation_threshold_process;
g_object_class_install_property (object_class,
GIMP_OPERATION_POINT_FILTER_PROP_CONFIG,
g_param_spec_object ("config",
"Config",
"The config object",
GIMP_TYPE_THRESHOLD_CONFIG,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_LOW,
g_param_spec_double ("low",
_("Low threshold"),
NULL,
0.0, 1.0, 0.5,
GIMP_CONFIG_PARAM_FLAGS));
g_object_class_install_property (object_class, PROP_HIGH,
g_param_spec_double ("high",
_("High threshold"),
NULL,
0.0, 1.0, 1.0,
GIMP_CONFIG_PARAM_FLAGS));
}
static void
......@@ -77,7 +102,55 @@ gimp_operation_threshold_init (GimpOperationThreshold *self)
{
}
static gboolean
static void
gimp_operation_threshold_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpOperationThreshold *self = GIMP_OPERATION_THRESHOLD (object);
switch (property_id)
{
case PROP_LOW:
g_value_set_double (value, self->low);
break;
case PROP_HIGH:
g_value_set_double (value, self->high);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_operation_threshold_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpOperationThreshold *self = GIMP_OPERATION_THRESHOLD (object);
switch (property_id)
{
case PROP_LOW:
self->low = g_value_get_double (value);
break;
case PROP_HIGH:
self->high = g_value_get_double (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static gboolean
gimp_operation_threshold_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
......@@ -85,13 +158,9 @@ gimp_operation_threshold_process (GeglOperation *operation,
const GeglRectangle *roi,
gint level)
{
GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
GimpThresholdConfig *config = GIMP_THRESHOLD_CONFIG (point->config);
gfloat *src = in_buf;
gfloat *dest = out_buf;
if (! config)
return FALSE;
GimpOperationThreshold *threshold = GIMP_OPERATION_THRESHOLD (operation);
gfloat *src = in_buf;
gfloat *dest = out_buf;
while (samples--)
{
......@@ -100,7 +169,7 @@ gimp_operation_threshold_process (GeglOperation *operation,
value = MAX (src[RED], src[GREEN]);
value = MAX (value, src[BLUE]);
value = (value >= config->low && value <= config->high) ? 1.0 : 0.0;
value = (value >= threshold->low && value <= threshold->high) ? 1.0 : 0.0;
dest[RED] = value;
dest[GREEN] = value;
......
......@@ -39,6 +39,9 @@ typedef struct _GimpOperationThresholdClass GimpOperationThresholdClass;
struct _GimpOperationThreshold
{
GimpOperationPointFilter parent_instance;
gdouble low;
gdouble high;
};
struct _GimpOperationThresholdClass
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpthresholdconfig.c
* Copyright (C) 2007 Michael Natterer <mitch@gimp.org>
*
* 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 <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
#include "libgimpconfig/gimpconfig.h"
#include "operations-types.h"
#include "gimpthresholdconfig.h"
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_LOW,
PROP_HIGH
};
static void gimp_threshold_config_iface_init (GimpConfigInterface *iface);
static void gimp_threshold_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_threshold_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static gboolean gimp_threshold_config_equal (GimpConfig *a,
GimpConfig *b);
G_DEFINE_TYPE_WITH_CODE (GimpThresholdConfig, gimp_threshold_config,
GIMP_TYPE_SETTINGS,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
gimp_threshold_config_iface_init))
#define parent_class gimp_threshold_config_parent_class
static void
gimp_threshold_config_class_init (GimpThresholdConfigClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
object_class->set_property = gimp_threshold_config_set_property;
object_class->get_property = gimp_threshold_config_get_property;
viewable_class->default_icon_name = "gimp-tool-threshold";
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_LOW,
"low",
_("Low threshold"),
0.0, 1.0, 0.5, 0);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_HIGH,
"high",
_("High threshold"),
0.0, 1.0, 1.0, 0);
}
static void
gimp_threshold_config_iface_init (GimpConfigInterface *iface)
{
iface->equal = gimp_threshold_config_equal;
}
static void
gimp_threshold_config_init (GimpThresholdConfig *self)
{
}
static void
gimp_threshold_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpThresholdConfig *self = GIMP_THRESHOLD_CONFIG (object);
switch (property_id)
{
case PROP_LOW:
g_value_set_double (value, self->low);
break;
case PROP_HIGH:
g_value_set_double (value, self->high);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_threshold_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpThresholdConfig *self = GIMP_THRESHOLD_CONFIG (object);
switch (property_id)
{
case PROP_LOW:
self->low = g_value_get_double (value);
break;
case PROP_HIGH:
self->high = g_value_get_double (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static gboolean
gimp_threshold_config_equal (GimpConfig *a,
GimpConfig *b)
{
GimpThresholdConfig *config_a = GIMP_THRESHOLD_CONFIG (a);
GimpThresholdConfig *config_b = GIMP_THRESHOLD_CONFIG (b);
if (config_a->low != config_b->low ||
config_a->high != config_b->high)
{
return FALSE;
}
return TRUE;
}
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpthresholdconfig.h
* Copyright (C) 2007 Michael Natterer <mitch@gimp.org>
*
* 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_THRESHOLD_CONFIG_H__
#define __GIMP_THRESHOLD_CONFIG_H__
#include "core/gimpsettings.h"