mirror of https://github.com/GNOME/gimp.git
app/config/gimpconfig-deserialize.c removed redundant casts.
2004-07-08 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-deserialize.c * app/config/gimpconfig-serialize.c: removed redundant casts. * app/widgets/gimpsessioninfo.[ch]: added convenience functions to get and set aux-info based on object properties. * app/widgets/gimphistogrameditor.c: use the new functions to save a histogram's channel and scale in the sessionrc.
This commit is contained in:
parent
73b1182c80
commit
a4ac4de072
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2004-07-08 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/config/gimpconfig-deserialize.c
|
||||
* app/config/gimpconfig-serialize.c: removed redundant casts.
|
||||
|
||||
* app/widgets/gimpsessioninfo.[ch]: added convenience functions to
|
||||
get and set aux-info based on object properties.
|
||||
|
||||
* app/widgets/gimphistogrameditor.c: use the new functions to save
|
||||
a histogram's channel and scale in the sessionrc.
|
||||
|
||||
2004-07-07 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/widgets/gimpclipboard.c: sort the list of pixbuf formats so
|
||||
|
|
|
@ -516,10 +516,10 @@ gimp_config_deserialize_enum (GValue *value,
|
|||
case G_TOKEN_IDENTIFIER:
|
||||
g_scanner_get_next_token (scanner);
|
||||
|
||||
enum_value = g_enum_get_value_by_nick (G_ENUM_CLASS (enum_class),
|
||||
enum_value = g_enum_get_value_by_nick (enum_class,
|
||||
scanner->value.v_identifier);
|
||||
if (!enum_value)
|
||||
enum_value = g_enum_get_value_by_name (G_ENUM_CLASS (enum_class),
|
||||
enum_value = g_enum_get_value_by_name (enum_class,
|
||||
scanner->value.v_identifier);
|
||||
|
||||
if (!enum_value)
|
||||
|
|
|
@ -356,12 +356,9 @@ gimp_config_serialize_value (const GValue *value,
|
|||
|
||||
if (G_VALUE_HOLDS_ENUM (value))
|
||||
{
|
||||
GEnumClass *enum_class;
|
||||
GEnumValue *enum_value;
|
||||
|
||||
enum_class = g_type_class_peek (G_VALUE_TYPE (value));
|
||||
enum_value = g_enum_get_value (G_ENUM_CLASS (enum_class),
|
||||
g_value_get_enum (value));
|
||||
GEnumClass *enum_class = g_type_class_peek (G_VALUE_TYPE (value));
|
||||
GEnumValue *enum_value = g_enum_get_value (enum_class,
|
||||
g_value_get_enum (value));
|
||||
|
||||
if (enum_value && enum_value->value_nick)
|
||||
{
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "gimpdocked.h"
|
||||
#include "gimpenumcombobox.h"
|
||||
#include "gimpenumstore.h"
|
||||
#include "gimphelp-ids.h"
|
||||
|
@ -40,14 +41,18 @@
|
|||
#include "gimphistogrameditor.h"
|
||||
#include "gimphistogramview.h"
|
||||
#include "gimppropwidgets.h"
|
||||
#include "gimpsessioninfo.h"
|
||||
#include "gimpwidgets-utils.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
static void gimp_histogram_editor_class_init (GimpHistogramEditorClass *klass);
|
||||
static void gimp_histogram_editor_init (GimpHistogramEditor *editor);
|
||||
|
||||
static void gimp_histogram_editor_init (GimpHistogramEditor *editor);
|
||||
static void gimp_histogram_editor_docked_iface_init (GimpDockedInterface *docked_iface);
|
||||
static void gimp_histogram_editor_set_aux_info (GimpDocked *docked,
|
||||
GList *aux_info);
|
||||
static GList * gimp_histogram_editor_get_aux_info (GimpDocked *docked);
|
||||
static void gimp_histogram_editor_set_image (GimpImageEditor *editor,
|
||||
GimpImage *gimage);
|
||||
|
||||
|
@ -70,7 +75,8 @@ static void gimp_histogram_editor_menu_update (GimpHistogramEditor *editor);
|
|||
static void gimp_histogram_editor_info_update (GimpHistogramEditor *editor);
|
||||
|
||||
|
||||
static GimpImageEditorClass *parent_class = NULL;
|
||||
static GimpImageEditorClass *parent_class = NULL;
|
||||
static GimpDockedInterface *parent_docked_iface = NULL;
|
||||
|
||||
|
||||
GType
|
||||
|
@ -92,10 +98,18 @@ gimp_histogram_editor_get_type (void)
|
|||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_histogram_editor_init,
|
||||
};
|
||||
static const GInterfaceInfo docked_iface_info =
|
||||
{
|
||||
(GInterfaceInitFunc) gimp_histogram_editor_docked_iface_init,
|
||||
NULL, /* iface_finalize */
|
||||
NULL /* iface_data */
|
||||
};
|
||||
|
||||
editor_type = g_type_register_static (GIMP_TYPE_IMAGE_EDITOR,
|
||||
"GimpHistogramEditor",
|
||||
&editor_info, 0);
|
||||
g_type_add_interface_static (editor_type, GIMP_TYPE_DOCKED,
|
||||
&docked_iface_info);
|
||||
}
|
||||
|
||||
return editor_type;
|
||||
|
@ -212,6 +226,52 @@ gimp_histogram_editor_init (GimpHistogramEditor *editor)
|
|||
gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_histogram_editor_docked_iface_init (GimpDockedInterface *docked_iface)
|
||||
{
|
||||
parent_docked_iface = g_type_interface_peek_parent (docked_iface);
|
||||
|
||||
docked_iface->set_aux_info = gimp_histogram_editor_set_aux_info;
|
||||
docked_iface->get_aux_info = gimp_histogram_editor_get_aux_info;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_histogram_editor_set_aux_info (GimpDocked *docked,
|
||||
GList *aux_info)
|
||||
{
|
||||
GimpHistogramEditor *editor = GIMP_HISTOGRAM_EDITOR (docked);
|
||||
GimpHistogramView *view = GIMP_HISTOGRAM_BOX (editor->box)->view;
|
||||
|
||||
if (parent_docked_iface->set_aux_info)
|
||||
parent_docked_iface->set_aux_info (docked, aux_info);
|
||||
|
||||
gimp_session_info_aux_set_props (G_OBJECT (view), aux_info,
|
||||
"histogram-channel",
|
||||
"histogram-scale",
|
||||
NULL);
|
||||
}
|
||||
|
||||
#define AUX_INFO_channel "channel"
|
||||
|
||||
static GList *
|
||||
gimp_histogram_editor_get_aux_info (GimpDocked *docked)
|
||||
{
|
||||
GimpHistogramEditor *editor = GIMP_HISTOGRAM_EDITOR (docked);
|
||||
GimpHistogramView *view = GIMP_HISTOGRAM_BOX (editor->box)->view;
|
||||
GList *aux_info;
|
||||
|
||||
aux_info = gimp_session_info_aux_new_from_props (G_OBJECT (view),
|
||||
"histogram-channel",
|
||||
"histogram-scale",
|
||||
NULL);
|
||||
|
||||
if (parent_docked_iface->get_aux_info)
|
||||
return g_list_concat (parent_docked_iface->get_aux_info (docked),
|
||||
aux_info);
|
||||
else
|
||||
return aux_info;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_histogram_editor_set_image (GimpImageEditor *image_editor,
|
||||
GimpImage *gimage)
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "config/gimpconfig-serialize.h"
|
||||
#include "config/gimpconfigwriter.h"
|
||||
#include "config/gimpscanner.h"
|
||||
|
||||
|
@ -163,6 +164,139 @@ gimp_session_info_aux_free (GimpSessionInfoAux *aux)
|
|||
g_free (aux);
|
||||
}
|
||||
|
||||
GList *
|
||||
gimp_session_info_aux_new_from_props (GObject *object,
|
||||
...)
|
||||
{
|
||||
GList *list = NULL;
|
||||
const gchar *prop_name;
|
||||
va_list args;
|
||||
|
||||
g_return_val_if_fail (G_IS_OBJECT (object), NULL);
|
||||
|
||||
va_start (args, object);
|
||||
|
||||
for (prop_name = va_arg (args, const gchar *);
|
||||
prop_name;
|
||||
prop_name = va_arg (args, const gchar *))
|
||||
{
|
||||
GObjectClass *class = G_OBJECT_GET_CLASS (object);
|
||||
GParamSpec *pspec = g_object_class_find_property (class, prop_name);
|
||||
|
||||
if (pspec)
|
||||
{
|
||||
GString *str = g_string_new (NULL);
|
||||
GValue value = { 0, };
|
||||
|
||||
g_value_init (&value, pspec->value_type);
|
||||
g_object_get_property (object, pspec->name, &value);
|
||||
|
||||
if (gimp_config_serialize_value (&value, str, FALSE))
|
||||
list = g_list_prepend (list,
|
||||
gimp_session_info_aux_new (prop_name,
|
||||
str->str));
|
||||
g_value_unset (&value);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("%s: no property names '%s' for %s",
|
||||
G_STRFUNC,
|
||||
prop_name, G_OBJECT_CLASS_NAME (class));
|
||||
}
|
||||
}
|
||||
|
||||
va_end (args);
|
||||
|
||||
return g_list_reverse (list);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_aux_set_props (GObject *object,
|
||||
GList *auxs,
|
||||
...)
|
||||
{
|
||||
const gchar *prop_name;
|
||||
va_list args;
|
||||
|
||||
g_return_if_fail (G_IS_OBJECT (object));
|
||||
|
||||
va_start (args, auxs);
|
||||
|
||||
for (prop_name = va_arg (args, const gchar *);
|
||||
prop_name;
|
||||
prop_name = va_arg (args, const gchar *))
|
||||
{
|
||||
GList *list;
|
||||
|
||||
for (list = auxs; list; list = g_list_next (list))
|
||||
{
|
||||
GimpSessionInfoAux *aux = list->data;
|
||||
|
||||
if (strcmp (aux->name, prop_name) == 0)
|
||||
{
|
||||
GObjectClass *class = G_OBJECT_GET_CLASS (object);
|
||||
GParamSpec *pspec = g_object_class_find_property (class,
|
||||
prop_name);
|
||||
|
||||
if (pspec)
|
||||
{
|
||||
GValue value = { 0, };
|
||||
|
||||
g_value_init (&value, pspec->value_type);
|
||||
|
||||
if (G_VALUE_HOLDS_ENUM (&value))
|
||||
{
|
||||
GEnumClass *enum_class;
|
||||
GEnumValue *enum_value;
|
||||
|
||||
enum_class = g_type_class_peek (pspec->value_type);
|
||||
enum_value = g_enum_get_value_by_nick (enum_class,
|
||||
aux->value);
|
||||
|
||||
if (enum_value)
|
||||
{
|
||||
g_value_set_enum (&value, enum_value->value);
|
||||
g_object_set_property (object, pspec->name, &value);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("%s: unknown enum value in '%s' for %s",
|
||||
G_STRFUNC,
|
||||
prop_name, G_OBJECT_CLASS_NAME (class));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GValue str_value = { 0, };
|
||||
|
||||
g_value_init (&str_value, G_TYPE_STRING);
|
||||
g_value_set_static_string (&str_value, aux->value);
|
||||
|
||||
if (g_value_transform (&str_value, &value))
|
||||
g_object_set_property (object, pspec->name, &value);
|
||||
else
|
||||
g_warning ("%s: cannot convert property '%s' for %s",
|
||||
G_STRFUNC,
|
||||
prop_name, G_OBJECT_CLASS_NAME (class));
|
||||
|
||||
g_value_unset (&str_value);
|
||||
}
|
||||
|
||||
g_value_unset (&value);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("%s: no property names '%s' for %s",
|
||||
G_STRFUNC,
|
||||
prop_name, G_OBJECT_CLASS_NAME (class));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_save (GimpSessionInfo *info,
|
||||
const gchar *factory_name,
|
||||
|
@ -790,9 +924,7 @@ static GTokenType
|
|||
session_info_dock_deserialize (GScanner *scanner,
|
||||
GimpSessionInfo *info)
|
||||
{
|
||||
GTokenType token;
|
||||
|
||||
token = G_TOKEN_LEFT_PAREN;
|
||||
GTokenType token = G_TOKEN_LEFT_PAREN;
|
||||
|
||||
while (g_scanner_peek_next_token (scanner) == token)
|
||||
{
|
||||
|
@ -1003,9 +1135,7 @@ session_info_aux_deserialize (GScanner *scanner,
|
|||
GList **aux_list)
|
||||
{
|
||||
GimpSessionInfoAux *aux_info = NULL;
|
||||
GTokenType token;
|
||||
|
||||
token = G_TOKEN_LEFT_PAREN;
|
||||
GTokenType token = G_TOKEN_LEFT_PAREN;
|
||||
|
||||
while (g_scanner_peek_next_token (scanner) == token)
|
||||
{
|
||||
|
|
|
@ -82,6 +82,12 @@ GimpSessionInfoAux *
|
|||
const gchar *value);
|
||||
void gimp_session_info_aux_free (GimpSessionInfoAux *aux);
|
||||
|
||||
GList * gimp_session_info_aux_new_from_props (GObject *object,
|
||||
...);
|
||||
void gimp_session_info_aux_set_props (GObject *object,
|
||||
GList *aux,
|
||||
...);
|
||||
|
||||
void gimp_session_info_save (GimpSessionInfo *info,
|
||||
const gchar *factory_name,
|
||||
GimpConfigWriter *writer);
|
||||
|
|
|
@ -516,10 +516,10 @@ gimp_config_deserialize_enum (GValue *value,
|
|||
case G_TOKEN_IDENTIFIER:
|
||||
g_scanner_get_next_token (scanner);
|
||||
|
||||
enum_value = g_enum_get_value_by_nick (G_ENUM_CLASS (enum_class),
|
||||
enum_value = g_enum_get_value_by_nick (enum_class,
|
||||
scanner->value.v_identifier);
|
||||
if (!enum_value)
|
||||
enum_value = g_enum_get_value_by_name (G_ENUM_CLASS (enum_class),
|
||||
enum_value = g_enum_get_value_by_name (enum_class,
|
||||
scanner->value.v_identifier);
|
||||
|
||||
if (!enum_value)
|
||||
|
|
|
@ -356,12 +356,9 @@ gimp_config_serialize_value (const GValue *value,
|
|||
|
||||
if (G_VALUE_HOLDS_ENUM (value))
|
||||
{
|
||||
GEnumClass *enum_class;
|
||||
GEnumValue *enum_value;
|
||||
|
||||
enum_class = g_type_class_peek (G_VALUE_TYPE (value));
|
||||
enum_value = g_enum_get_value (G_ENUM_CLASS (enum_class),
|
||||
g_value_get_enum (value));
|
||||
GEnumClass *enum_class = g_type_class_peek (G_VALUE_TYPE (value));
|
||||
GEnumValue *enum_value = g_enum_get_value (enum_class,
|
||||
g_value_get_enum (value));
|
||||
|
||||
if (enum_value && enum_value->value_nick)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue