From 19e7e076dcbd4a69dae991d6fda911c873082491 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Tue, 16 Aug 2005 11:40:04 +0000 Subject: [PATCH] added utility function gimp_container_view_install_properties() to reduce 2005-08-16 Sven Neumann * app/widgets/gimpcontainerview.[ch]: added utility function gimp_container_view_install_properties() to reduce code duplication in classes implementing this interface. * app/widgets/gimpcontainerbox.c * app/widgets/gimpcontainercombobox.c * app/widgets/gimpcontainerentry.c: changed accordingly. --- ChangeLog | 10 ++++++++++ app/widgets/gimpcontainerbox.c | 16 +-------------- app/widgets/gimpcontainercombobox.c | 16 +-------------- app/widgets/gimpcontainerentry.c | 16 +-------------- app/widgets/gimpcontainerview.c | 31 +++++++++++++++++++++++++++++ app/widgets/gimpcontainerview.h | 24 ++++++++++++---------- 6 files changed, 57 insertions(+), 56 deletions(-) diff --git a/ChangeLog b/ChangeLog index 33c10e95e7..0db78afebd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-08-16 Sven Neumann + + * app/widgets/gimpcontainerview.[ch]: added utility function + gimp_container_view_install_properties() to reduce code duplication + in classes implementing this interface. + + * app/widgets/gimpcontainerbox.c + * app/widgets/gimpcontainercombobox.c + * app/widgets/gimpcontainerentry.c: changed accordingly. + 2005-08-16 Sven Neumann * configure.in diff --git a/app/widgets/gimpcontainerbox.c b/app/widgets/gimpcontainerbox.c index b326cdbe51..27d39ae2e5 100644 --- a/app/widgets/gimpcontainerbox.c +++ b/app/widgets/gimpcontainerbox.c @@ -112,21 +112,7 @@ gimp_container_box_class_init (GimpContainerBoxClass *klass) object_class->set_property = gimp_container_view_set_property; object_class->get_property = gimp_container_view_get_property; - g_object_class_override_property (object_class, - GIMP_CONTAINER_VIEW_PROP_CONTAINER, - "container"); - g_object_class_override_property (object_class, - GIMP_CONTAINER_VIEW_PROP_CONTEXT, - "context"); - g_object_class_override_property (object_class, - GIMP_CONTAINER_VIEW_PROP_REORDERABLE, - "reorderable"); - g_object_class_override_property (object_class, - GIMP_CONTAINER_VIEW_PROP_PREVIEW_SIZE, - "preview-size"); - g_object_class_override_property (object_class, - GIMP_CONTAINER_VIEW_PROP_PREVIEW_BORDER_WIDTH, - "preview-border-width"); + gimp_container_view_install_properties (object_class); } static void diff --git a/app/widgets/gimpcontainercombobox.c b/app/widgets/gimpcontainercombobox.c index ce3a8e87b0..3a9bca5fd4 100644 --- a/app/widgets/gimpcontainercombobox.c +++ b/app/widgets/gimpcontainercombobox.c @@ -127,21 +127,7 @@ gimp_container_combo_box_class_init (GimpContainerComboBoxClass *klass) object_class->set_property = gimp_container_view_set_property; object_class->get_property = gimp_container_view_get_property; - g_object_class_override_property (object_class, - GIMP_CONTAINER_VIEW_PROP_CONTAINER, - "container"); - g_object_class_override_property (object_class, - GIMP_CONTAINER_VIEW_PROP_CONTEXT, - "context"); - g_object_class_override_property (object_class, - GIMP_CONTAINER_VIEW_PROP_REORDERABLE, - "reorderable"); - g_object_class_override_property (object_class, - GIMP_CONTAINER_VIEW_PROP_PREVIEW_SIZE, - "preview-size"); - g_object_class_override_property (object_class, - GIMP_CONTAINER_VIEW_PROP_PREVIEW_BORDER_WIDTH, - "preview-border-width"); + gimp_container_view_install_properties (object_class); } static void diff --git a/app/widgets/gimpcontainerentry.c b/app/widgets/gimpcontainerentry.c index 29234b2980..c912e4366b 100644 --- a/app/widgets/gimpcontainerentry.c +++ b/app/widgets/gimpcontainerentry.c @@ -123,21 +123,7 @@ gimp_container_entry_class_init (GimpContainerEntryClass *klass) object_class->set_property = gimp_container_view_set_property; object_class->get_property = gimp_container_view_get_property; - g_object_class_override_property (object_class, - GIMP_CONTAINER_VIEW_PROP_CONTAINER, - "container"); - g_object_class_override_property (object_class, - GIMP_CONTAINER_VIEW_PROP_CONTEXT, - "context"); - g_object_class_override_property (object_class, - GIMP_CONTAINER_VIEW_PROP_REORDERABLE, - "reorderable"); - g_object_class_override_property (object_class, - GIMP_CONTAINER_VIEW_PROP_PREVIEW_SIZE, - "preview-size"); - g_object_class_override_property (object_class, - GIMP_CONTAINER_VIEW_PROP_PREVIEW_BORDER_WIDTH, - "preview-border-width"); + gimp_container_view_install_properties (object_class); } static void diff --git a/app/widgets/gimpcontainerview.c b/app/widgets/gimpcontainerview.c index fdd58a449f..dcf40a388f 100644 --- a/app/widgets/gimpcontainerview.c +++ b/app/widgets/gimpcontainerview.c @@ -291,6 +291,37 @@ gimp_container_view_get_private (GimpContainerView *view) return private; } +/** + * gimp_container_view_install_properties: + * @klass: the class structure for a type deriving from #GObject + * + * Installs the necessary properties for a class implementing + * #GimpContainerView. A #GimpContainerViewProp property is installed + * for each property, using the values from the #GimpContainerViewProp + * enumeration. The caller must make sure itself that the enumeration + * values don't collide with some other property values they + * are using (that's what %GIMP_CONTAINER_VIEW_PROP_LAST is good for). + **/ +void +gimp_container_view_install_properties (GObjectClass *klass) +{ + g_object_class_override_property (klass, + GIMP_CONTAINER_VIEW_PROP_CONTAINER, + "container"); + g_object_class_override_property (klass, + GIMP_CONTAINER_VIEW_PROP_CONTEXT, + "context"); + g_object_class_override_property (klass, + GIMP_CONTAINER_VIEW_PROP_REORDERABLE, + "reorderable"); + g_object_class_override_property (klass, + GIMP_CONTAINER_VIEW_PROP_PREVIEW_SIZE, + "preview-size"); + g_object_class_override_property (klass, + GIMP_CONTAINER_VIEW_PROP_PREVIEW_BORDER_WIDTH, + "preview-border-width"); +} + GimpContainer * gimp_container_view_get_container (GimpContainerView *view) { diff --git a/app/widgets/gimpcontainerview.h b/app/widgets/gimpcontainerview.h index 96f5e00c0a..36b8c7e302 100644 --- a/app/widgets/gimpcontainerview.h +++ b/app/widgets/gimpcontainerview.h @@ -23,15 +23,16 @@ #define __GIMP_CONTAINER_VIEW_H__ -enum +typedef enum { GIMP_CONTAINER_VIEW_PROP_0, GIMP_CONTAINER_VIEW_PROP_CONTAINER, GIMP_CONTAINER_VIEW_PROP_CONTEXT, GIMP_CONTAINER_VIEW_PROP_REORDERABLE, GIMP_CONTAINER_VIEW_PROP_PREVIEW_SIZE, - GIMP_CONTAINER_VIEW_PROP_PREVIEW_BORDER_WIDTH -}; + GIMP_CONTAINER_VIEW_PROP_PREVIEW_BORDER_WIDTH, + GIMP_CONTAINER_VIEW_PROP_LAST = GIMP_CONTAINER_VIEW_PROP_PREVIEW_BORDER_WIDTH +} GimpContainerViewProp; #define GIMP_TYPE_CONTAINER_VIEW (gimp_container_view_interface_get_type ()) @@ -131,14 +132,15 @@ void gimp_container_view_item_context (GimpContainerView *view, /* convenience functions */ -void gimp_container_view_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); -void gimp_container_view_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); +void gimp_container_view_install_properties (GObjectClass *klass); +void gimp_container_view_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +void gimp_container_view_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); #endif /* __GIMP_CONTAINER_VIEW_H__ */