app: remove virtual function GimpToolOptions::reset()

and use GimpConfig::reset() instead.
This commit is contained in:
Michael Natterer 2015-12-29 12:47:04 +01:00
parent eec556f614
commit 2e40af5dcf
10 changed files with 122 additions and 83 deletions

View File

@ -175,7 +175,7 @@ tool_options_reset_cmd_callback (GtkAction *action,
GimpContext *context = gimp_get_user_context (gimp_editor_get_ui_manager (editor)->gimp);
GimpToolInfo *tool_info = gimp_context_get_tool (context);
gimp_tool_options_reset (tool_info->tool_options);
gimp_config_reset (GIMP_CONFIG (tool_info->tool_options));
}
void
@ -222,7 +222,7 @@ tool_options_reset_all_cmd_callback (GtkAction *action,
{
GimpToolInfo *tool_info = list->data;
gimp_tool_options_reset (tool_info->tool_options);
gimp_config_reset (GIMP_CONFIG (tool_info->tool_options));
}
}

View File

@ -53,8 +53,6 @@ static void gimp_tool_options_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void gimp_tool_options_real_reset (GimpToolOptions *tool_options);
static void gimp_tool_options_config_reset (GimpConfig *config);
static void gimp_tool_options_tool_notify (GimpToolOptions *options,
@ -77,8 +75,6 @@ gimp_tool_options_class_init (GimpToolOptionsClass *klass)
object_class->set_property = gimp_tool_options_set_property;
object_class->get_property = gimp_tool_options_get_property;
klass->reset = gimp_tool_options_real_reset;
g_object_class_override_property (object_class, PROP_TOOL, "tool");
g_object_class_install_property (object_class, PROP_TOOL_INFO,
@ -239,12 +235,6 @@ gimp_tool_options_get_property (GObject *object,
}
}
static void
gimp_tool_options_real_reset (GimpToolOptions *tool_options)
{
gimp_config_reset (GIMP_CONFIG (tool_options));
}
static void
gimp_tool_options_config_reset (GimpConfig *config)
{
@ -276,14 +266,6 @@ gimp_tool_options_tool_notify (GimpToolOptions *options,
/* public functions */
void
gimp_tool_options_reset (GimpToolOptions *tool_options)
{
g_return_if_fail (GIMP_IS_TOOL_OPTIONS (tool_options));
GIMP_TOOL_OPTIONS_GET_CLASS (tool_options)->reset (tool_options);
}
gboolean
gimp_tool_options_serialize (GimpToolOptions *tool_options,
GError **error)

View File

@ -42,15 +42,11 @@ struct _GimpToolOptions
struct _GimpToolOptionsClass
{
GimpContextClass parent_class;
void (* reset) (GimpToolOptions *tool_options);
};
GType gimp_tool_options_get_type (void) G_GNUC_CONST;
void gimp_tool_options_reset (GimpToolOptions *tool_options);
gboolean gimp_tool_options_serialize (GimpToolOptions *tool_options,
GError **error);
gboolean gimp_tool_options_deserialize (GimpToolOptions *tool_options,

View File

@ -57,7 +57,8 @@ static void gimp_mybrush_options_get_property (GObject *object,
static void gimp_mybrush_options_mybrush_changed (GimpContext *context,
GimpMybrush *brush);
static void gimp_mybrush_options_config_reset (GimpConfig *gimp_config);
static void gimp_mybrush_options_reset (GimpConfig *config);
G_DEFINE_TYPE_WITH_CODE (GimpMybrushOptions, gimp_mybrush_options,
GIMP_TYPE_PAINT_OPTIONS,
@ -66,6 +67,7 @@ G_DEFINE_TYPE_WITH_CODE (GimpMybrushOptions, gimp_mybrush_options,
static GimpConfigInterface *parent_config_iface = NULL;
static void
gimp_mybrush_options_class_init (GimpMybrushOptionsClass *klass)
{
@ -95,13 +97,12 @@ gimp_mybrush_options_class_init (GimpMybrushOptionsClass *klass)
GIMP_PARAM_STATIC_STRINGS);
}
static void
gimp_mybrush_options_config_iface_init (GimpConfigInterface *config_iface)
{
parent_config_iface = g_type_interface_peek_parent (config_iface);
config_iface->reset = gimp_mybrush_options_config_reset;
config_iface->reset = gimp_mybrush_options_reset;
}
static void
@ -181,11 +182,12 @@ gimp_mybrush_options_mybrush_changed (GimpContext *context,
}
static void
gimp_mybrush_options_config_reset (GimpConfig *gimp_config)
gimp_mybrush_options_reset (GimpConfig *config)
{
GimpContext *context = GIMP_CONTEXT (gimp_config);
GimpContext *context = GIMP_CONTEXT (config);
GimpMybrush *brush = gimp_context_get_mybrush (context);
parent_config_iface->reset (gimp_config);
parent_config_iface->reset (config);
gimp_mybrush_options_mybrush_changed (context, brush);
}
}

View File

@ -322,7 +322,7 @@ gimp_tools_restore (Gimp *gimp)
GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data);
/* get default values from prefs (see bug #120832) */
gimp_tool_options_reset (tool_info->tool_options);
gimp_config_reset (GIMP_CONFIG (tool_info->tool_options));
}
if (! gimp_contexts_load (gimp, &error))

View File

@ -55,6 +55,8 @@ enum
};
static void gimp_bucket_fill_options_config_iface_init (GimpConfigInterface *config_iface);
static void gimp_bucket_fill_options_set_property (GObject *object,
guint property_id,
const GValue *value,
@ -64,26 +66,27 @@ static void gimp_bucket_fill_options_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void gimp_bucket_fill_options_reset (GimpToolOptions *tool_options);
static void gimp_bucket_fill_options_reset (GimpConfig *config);
G_DEFINE_TYPE (GimpBucketFillOptions, gimp_bucket_fill_options,
GIMP_TYPE_PAINT_OPTIONS)
G_DEFINE_TYPE_WITH_CODE (GimpBucketFillOptions, gimp_bucket_fill_options,
GIMP_TYPE_PAINT_OPTIONS,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
gimp_bucket_fill_options_config_iface_init))
#define parent_class gimp_bucket_fill_options_parent_class
static GimpConfigInterface *parent_config_iface = NULL;
static void
gimp_bucket_fill_options_class_init (GimpBucketFillOptionsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolOptionsClass *options_class = GIMP_TOOL_OPTIONS_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gimp_bucket_fill_options_set_property;
object_class->get_property = gimp_bucket_fill_options_get_property;
options_class->reset = gimp_bucket_fill_options_reset;
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_FILL_MODE,
"fill-mode", NULL,
GIMP_TYPE_BUCKET_FILL_MODE,
@ -119,6 +122,14 @@ gimp_bucket_fill_options_class_init (GimpBucketFillOptionsClass *klass)
GIMP_PARAM_STATIC_STRINGS);
}
static void
gimp_bucket_fill_options_config_iface_init (GimpConfigInterface *config_iface)
{
parent_config_iface = g_type_interface_peek_parent (config_iface);
config_iface->reset = gimp_bucket_fill_options_reset;
}
static void
gimp_bucket_fill_options_init (GimpBucketFillOptions *options)
{
@ -195,18 +206,19 @@ gimp_bucket_fill_options_get_property (GObject *object,
}
static void
gimp_bucket_fill_options_reset (GimpToolOptions *tool_options)
gimp_bucket_fill_options_reset (GimpConfig *config)
{
GParamSpec *pspec;
GimpToolOptions *tool_options = GIMP_TOOL_OPTIONS (config);
GParamSpec *pspec;
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (tool_options),
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (config),
"threshold");
if (pspec)
G_PARAM_SPEC_DOUBLE (pspec)->default_value =
tool_options->tool_info->gimp->config->default_threshold;
GIMP_TOOL_OPTIONS_CLASS (parent_class)->reset (tool_options);
parent_config_iface->reset (config);
}
GtkWidget *

View File

@ -46,6 +46,8 @@ enum
};
static void gimp_magnify_options_config_iface_init (GimpConfigInterface *config_iface);
static void gimp_magnify_options_set_property (GObject *object,
guint property_id,
const GValue *value,
@ -55,26 +57,27 @@ static void gimp_magnify_options_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void gimp_magnify_options_reset (GimpToolOptions *tool_options);
static void gimp_magnify_options_reset (GimpConfig *config);
G_DEFINE_TYPE (GimpMagnifyOptions, gimp_magnify_options,
GIMP_TYPE_TOOL_OPTIONS)
G_DEFINE_TYPE_WITH_CODE (GimpMagnifyOptions, gimp_magnify_options,
GIMP_TYPE_TOOL_OPTIONS,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
gimp_magnify_options_config_iface_init))
#define parent_class gimp_magnify_options_parent_class
static GimpConfigInterface *parent_config_iface = NULL;
static void
gimp_magnify_options_class_init (GimpMagnifyOptionsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolOptionsClass *options_class = GIMP_TOOL_OPTIONS_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gimp_magnify_options_set_property;
object_class->get_property = gimp_magnify_options_get_property;
options_class->reset = gimp_magnify_options_reset;
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_AUTO_RESIZE,
"auto-resize",
_("Resize image window to accommodate "
@ -90,6 +93,14 @@ gimp_magnify_options_class_init (GimpMagnifyOptionsClass *klass)
GIMP_PARAM_STATIC_STRINGS);
}
static void
gimp_magnify_options_config_iface_init (GimpConfigInterface *config_iface)
{
parent_config_iface = g_type_interface_peek_parent (config_iface);
config_iface->reset = gimp_magnify_options_reset;
}
static void
gimp_magnify_options_init (GimpMagnifyOptions *options)
{
@ -142,18 +153,19 @@ gimp_magnify_options_get_property (GObject *object,
}
static void
gimp_magnify_options_reset (GimpToolOptions *tool_options)
gimp_magnify_options_reset (GimpConfig *config)
{
GParamSpec *pspec;
GimpToolOptions *tool_options = GIMP_TOOL_OPTIONS (config);
GParamSpec *pspec;
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (tool_options),
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (config),
"auto-resize");
if (pspec)
G_PARAM_SPEC_BOOLEAN (pspec)->default_value =
GIMP_DISPLAY_CONFIG (tool_options->tool_info->gimp->config)->resize_windows_on_zoom;
GIMP_TOOL_OPTIONS_CLASS (parent_class)->reset (tool_options);
parent_config_iface->reset (config);
}
GtkWidget *

View File

@ -50,6 +50,8 @@ enum
};
static void gimp_region_select_options_config_iface_init (GimpConfigInterface *config_iface);
static void gimp_region_select_options_set_property (GObject *object,
guint property_id,
const GValue *value,
@ -59,26 +61,27 @@ static void gimp_region_select_options_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void gimp_region_select_options_reset (GimpToolOptions *tool_options);
static void gimp_region_select_options_reset (GimpConfig *config);
G_DEFINE_TYPE (GimpRegionSelectOptions, gimp_region_select_options,
GIMP_TYPE_SELECTION_OPTIONS)
G_DEFINE_TYPE_WITH_CODE (GimpRegionSelectOptions, gimp_region_select_options,
GIMP_TYPE_SELECTION_OPTIONS,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
gimp_region_select_options_config_iface_init))
#define parent_class gimp_region_select_options_parent_class
static GimpConfigInterface *parent_config_iface = NULL;
static void
gimp_region_select_options_class_init (GimpRegionSelectOptionsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolOptionsClass *options_class = GIMP_TOOL_OPTIONS_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gimp_region_select_options_set_property;
object_class->get_property = gimp_region_select_options_get_property;
options_class->reset = gimp_region_select_options_reset;
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SELECT_TRANSPARENT,
"select-transparent",
_("Allow completely transparent regions "
@ -114,6 +117,14 @@ gimp_region_select_options_class_init (GimpRegionSelectOptionsClass *klass)
GIMP_PARAM_STATIC_STRINGS));
}
static void
gimp_region_select_options_config_iface_init (GimpConfigInterface *config_iface)
{
parent_config_iface = g_type_interface_peek_parent (config_iface);
config_iface->reset = gimp_region_select_options_reset;
}
static void
gimp_region_select_options_init (GimpRegionSelectOptions *options)
{
@ -192,18 +203,19 @@ gimp_region_select_options_get_property (GObject *object,
}
static void
gimp_region_select_options_reset (GimpToolOptions *tool_options)
gimp_region_select_options_reset (GimpConfig *config)
{
GParamSpec *pspec;
GimpToolOptions *tool_options = GIMP_TOOL_OPTIONS (config);
GParamSpec *pspec;
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (tool_options),
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (config),
"threshold");
if (pspec)
G_PARAM_SPEC_DOUBLE (pspec)->default_value =
tool_options->tool_info->gimp->config->default_threshold;
GIMP_TOOL_OPTIONS_CLASS (parent_class)->reset (tool_options);
parent_config_iface->reset (config);
}
GtkWidget *

View File

@ -72,6 +72,8 @@ enum
};
static void gimp_text_options_config_iface_init (GimpConfigInterface *config_iface);
static void gimp_text_options_finalize (GObject *object);
static void gimp_text_options_set_property (GObject *object,
guint property_id,
@ -82,7 +84,7 @@ static void gimp_text_options_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void gimp_text_options_reset (GimpToolOptions *tool_options);
static void gimp_text_options_reset (GimpConfig *config);
static void gimp_text_options_notify_font (GimpContext *context,
GParamSpec *pspec,
@ -100,24 +102,25 @@ static void gimp_text_options_notify_text_color (GimpText *text,
G_DEFINE_TYPE_WITH_CODE (GimpTextOptions, gimp_text_options,
GIMP_TYPE_TOOL_OPTIONS,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
gimp_text_options_config_iface_init)
G_IMPLEMENT_INTERFACE (GIMP_TYPE_RECTANGLE_OPTIONS,
NULL))
#define parent_class gimp_text_options_parent_class
static GimpConfigInterface *parent_config_iface = NULL;
static void
gimp_text_options_class_init (GimpTextOptionsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolOptionsClass *options_class = GIMP_TOOL_OPTIONS_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gimp_text_options_finalize;
object_class->set_property = gimp_text_options_set_property;
object_class->get_property = gimp_text_options_get_property;
options_class->reset = gimp_text_options_reset;
/* The 'highlight' property is defined here because we want different
* default values for the Crop, Text and the Rectangle Select tools.
*/
@ -214,6 +217,14 @@ gimp_text_options_class_init (GimpTextOptionsClass *klass)
gimp_rectangle_options_install_properties (object_class);
}
static void
gimp_text_options_config_iface_init (GimpConfigInterface *config_iface)
{
parent_config_iface = g_type_interface_peek_parent (config_iface);
config_iface->reset = gimp_text_options_reset;
}
static void
gimp_text_options_init (GimpTextOptions *options)
{
@ -358,9 +369,9 @@ gimp_text_options_set_property (GObject *object,
}
static void
gimp_text_options_reset (GimpToolOptions *tool_options)
gimp_text_options_reset (GimpConfig *config)
{
GObject *object = G_OBJECT (tool_options);
GObject *object = G_OBJECT (config);
/* implement reset() ourselves because the default impl would
* reset *all* properties, including all rectangle properties

View File

@ -67,6 +67,8 @@ enum
};
static void gimp_transform_options_config_iface_init (GimpConfigInterface *config_iface);
static void gimp_transform_options_set_property (GObject *object,
guint property_id,
const GValue *value,
@ -76,7 +78,7 @@ static void gimp_transform_options_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void gimp_transform_options_reset (GimpToolOptions *tool_options);
static void gimp_transform_options_reset (GimpConfig *config);
static gboolean gimp_transform_options_sync_grid (GBinding *binding,
const GValue *source_value,
@ -84,23 +86,24 @@ static gboolean gimp_transform_options_sync_grid (GBinding *binding,
gpointer user_data);
G_DEFINE_TYPE (GimpTransformOptions, gimp_transform_options,
GIMP_TYPE_TOOL_OPTIONS)
G_DEFINE_TYPE_WITH_CODE (GimpTransformOptions, gimp_transform_options,
GIMP_TYPE_TOOL_OPTIONS,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
gimp_transform_options_config_iface_init))
#define parent_class gimp_transform_options_parent_class
static GimpConfigInterface *parent_config_iface = NULL;
static void
gimp_transform_options_class_init (GimpTransformOptionsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolOptionsClass *options_class = GIMP_TOOL_OPTIONS_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gimp_transform_options_set_property;
object_class->get_property = gimp_transform_options_get_property;
options_class->reset = gimp_transform_options_reset;
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_TYPE,
"type", NULL,
GIMP_TYPE_TRANSFORM_TYPE,
@ -198,6 +201,14 @@ gimp_transform_options_class_init (GimpTransformOptionsClass *klass)
GIMP_PARAM_STATIC_STRINGS);
}
static void
gimp_transform_options_config_iface_init (GimpConfigInterface *config_iface)
{
parent_config_iface = g_type_interface_peek_parent (config_iface);
config_iface->reset = gimp_transform_options_reset;
}
static void
gimp_transform_options_init (GimpTransformOptions *options)
{
@ -344,18 +355,19 @@ gimp_transform_options_get_property (GObject *object,
}
static void
gimp_transform_options_reset (GimpToolOptions *tool_options)
gimp_transform_options_reset (GimpConfig *config)
{
GParamSpec *pspec;
GimpToolOptions *tool_options = GIMP_TOOL_OPTIONS (config);
GParamSpec *pspec;
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (tool_options),
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (config),
"interpolation");
if (pspec)
G_PARAM_SPEC_ENUM (pspec)->default_value =
tool_options->tool_info->gimp->config->interpolation_type;
GIMP_TOOL_OPTIONS_CLASS (parent_class)->reset (tool_options);
parent_config_iface->reset (config);
}
/**