core, pdb, xcf: Only load explicitly set filter names
We always save the filter name in XCFs, even if the user did not intentionally set it. This means that "default" names like Gaussian Blur are not translated when saved and loaded in XCFs. This patch adds a new property, "custom-name", to GimpDrawableFilter. It is FALSE by default, and only set to TRUE if the user provides a custom filter name (currently only possible in the public filter API). Based off this value, we either use the saved filter name or get it from the operation when saving and loading a filter from the XCF.
This commit is contained in:
@ -66,6 +66,7 @@ enum
|
||||
PROP_ID,
|
||||
PROP_DRAWABLE,
|
||||
PROP_MASK,
|
||||
PROP_CUSTOM_NAME,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
@ -81,6 +82,7 @@ struct _GimpDrawableFilter
|
||||
GeglNode *operation;
|
||||
|
||||
gboolean has_input;
|
||||
gboolean has_custom_name;
|
||||
|
||||
gboolean clip;
|
||||
GimpFilterRegion region;
|
||||
@ -204,6 +206,12 @@ gimp_drawable_filter_class_init (GimpDrawableFilterClass *klass)
|
||||
GIMP_TYPE_DRAWABLE,
|
||||
GIMP_PARAM_READWRITE);
|
||||
|
||||
drawable_filter_props[PROP_CUSTOM_NAME] = g_param_spec_boolean ("custom-name",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_READWRITE);
|
||||
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, drawable_filter_props);
|
||||
}
|
||||
|
||||
@ -255,6 +263,10 @@ gimp_drawable_filter_set_property (GObject *object,
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_CUSTOM_NAME:
|
||||
filter->has_custom_name = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
@ -277,6 +289,9 @@ gimp_drawable_filter_get_property (GObject *object,
|
||||
case PROP_MASK:
|
||||
g_value_set_object (value, gimp_drawable_filter_get_mask (filter));
|
||||
break;
|
||||
case PROP_CUSTOM_NAME:
|
||||
g_value_set_boolean (value, filter->has_custom_name);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
@ -324,26 +339,32 @@ gimp_drawable_filter_new (GimpDrawable *drawable,
|
||||
GimpDrawableFilter *filter;
|
||||
GimpImage *image;
|
||||
GeglNode *node;
|
||||
GeglOperation *op;
|
||||
GeglOperationClass *opclass;
|
||||
gboolean custom_name = TRUE;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
||||
g_return_val_if_fail (GEGL_IS_NODE (operation), NULL);
|
||||
g_return_val_if_fail (gegl_node_has_pad (operation, "output"), NULL);
|
||||
|
||||
op = gegl_node_get_gegl_operation (operation);
|
||||
opclass = GEGL_OPERATION_GET_CLASS (op);
|
||||
|
||||
if (undo_desc == NULL || strlen (undo_desc) == 0)
|
||||
{
|
||||
GeglOperation *op;
|
||||
GeglOperationClass *opclass;
|
||||
|
||||
op = gegl_node_get_gegl_operation (operation);
|
||||
opclass = GEGL_OPERATION_GET_CLASS (op);
|
||||
undo_desc = gegl_operation_class_get_key (opclass, "title");
|
||||
undo_desc = gegl_operation_class_get_key (opclass, "title");
|
||||
custom_name = FALSE;
|
||||
}
|
||||
|
||||
if (! g_strcmp0 (undo_desc, gegl_operation_class_get_key (opclass, "title")))
|
||||
custom_name = FALSE;
|
||||
|
||||
filter = g_object_new (GIMP_TYPE_DRAWABLE_FILTER,
|
||||
"name", undo_desc,
|
||||
"icon-name", icon_name,
|
||||
"drawable", drawable,
|
||||
"mask", NULL,
|
||||
"name", undo_desc,
|
||||
"icon-name", icon_name,
|
||||
"custom-name", custom_name,
|
||||
"drawable", drawable,
|
||||
"mask", NULL,
|
||||
NULL);
|
||||
|
||||
filter->operation = g_object_ref (operation);
|
||||
|
@ -2128,6 +2128,7 @@ xcf_save_effect (XcfInfo *info,
|
||||
{
|
||||
gchar *name;
|
||||
gchar *icon;
|
||||
gboolean has_custom_name;
|
||||
GimpDrawableFilter *filter_drawable;
|
||||
GeglNode *node;
|
||||
gchar *operation;
|
||||
@ -2144,12 +2145,22 @@ xcf_save_effect (XcfInfo *info,
|
||||
NULL);
|
||||
|
||||
g_object_get (filter,
|
||||
"name", &name,
|
||||
"icon-name", &icon,
|
||||
"name", &name,
|
||||
"icon-name", &icon,
|
||||
"custom-name", &has_custom_name,
|
||||
NULL);
|
||||
|
||||
/* Write out effect name */
|
||||
xcf_write_string_check_error (info, (gchar **) &name, 1, ;);
|
||||
if (has_custom_name)
|
||||
{
|
||||
xcf_write_string_check_error (info, (gchar **) &name, 1, ;);
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *empty = NULL;
|
||||
|
||||
xcf_write_string_check_error (info, (gchar **) &empty, 1, ;);
|
||||
}
|
||||
g_free (name);
|
||||
|
||||
/* Write out effect icon */
|
||||
|
Reference in New Issue
Block a user