Author: abrander
Date: 2009-10-15 18:08:04 +0200 (Thu, 15 Oct 2009)
New Revision: 2723
Modified:
trunk/librawstudio/rs-filter-param.c
trunk/librawstudio/rs-filter-param.h
trunk/librawstudio/rs-filter-response.c
trunk/librawstudio/rs-filter-response.h
Log:
Moved generic filter parameters from RSFilterResponse to RSFilterParam.
Modified: trunk/librawstudio/rs-filter-param.c
===================================================================
--- trunk/librawstudio/rs-filter-param.c 2009-10-15 15:50:30 UTC (rev
2722)
+++ trunk/librawstudio/rs-filter-param.c 2009-10-15 16:08:04 UTC (rev
2723)
@@ -5,6 +5,15 @@
static void
rs_filter_param_dispose(GObject *object)
{
+ RSFilterParam *filter_param = RS_FILTER_PARAM(object);
+
+ if (!filter_param->dispose_has_run)
+ {
+ filter_param->dispose_has_run = TRUE;
+
+ g_hash_table_destroy(filter_param->properties);
+ }
+
G_OBJECT_CLASS(rs_filter_param_parent_class)->dispose (object);
}
@@ -23,9 +32,38 @@
object_class->finalize = rs_filter_param_finalize;
}
+static inline GValue *
+new_value(GType type)
+{
+ GValue *value = g_slice_new0(GValue);
+ g_value_init(value, type);
+
+ return value;
+}
+
static void
+free_value(gpointer data)
+{
+ GValue *value = (GValue *) data;
+
+ g_value_unset(value);
+ g_slice_free(GValue, value);
+}
+
+static inline GValue *
+clone_value(const GValue *value)
+{
+ GType type = G_VALUE_TYPE(value);
+ GValue *ret = new_value(type);
+ g_value_copy(value, ret);
+
+ return ret;
+}
+
+static void
rs_filter_param_init(RSFilterParam *param)
{
+ param->properties = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, free_value);
}
RSFilterParam *
@@ -33,3 +71,104 @@
{
return g_object_new (RS_TYPE_FILTER_PARAM, NULL);
}
+
+void
+rs_filter_param_clone(RSFilterParam *destination, const RSFilterParam *source)
+{
+ g_assert(RS_IS_FILTER_PARAM(destination));
+ g_assert(RS_IS_FILTER_PARAM(source));
+
+ /* Clone the properties table */
+ GHashTableIter iter;
+ gpointer key, value;
+
+ g_hash_table_iter_init (&iter, source->properties);
+ while (g_hash_table_iter_next (&iter, &key, &value))
+ g_hash_table_insert(destination->properties, (gpointer)
g_strdup(key), clone_value(value));
+}
+
+static void
+rs_filter_param_set_gvalue(RSFilterParam *filter_param, const gchar *name,
GValue * value)
+{
+ g_assert(RS_IS_FILTER_PARAM(filter_param));
+ g_assert(name != NULL);
+ g_assert(name[0] != '\0');
+
+ g_hash_table_insert(filter_param->properties, (gpointer)
g_strdup(name), value);
+}
+
+static GValue *
+rs_filter_param_get_gvalue(const RSFilterParam *filter_param, const gchar
*name)
+{
+ g_assert(RS_IS_FILTER_PARAM(filter_param));
+
+ GValue *value = g_hash_table_lookup(filter_param->properties, name);
+
+ return value;
+}
+
+/**
+ * Set a string property
+ * @param filter_param A RSFilterParam
+ * @param name The name of the property
+ * @param str NULL-terminated string to set (will be copied)
+ */
+void
+rs_filter_param_set_string(RSFilterParam *filter_param, const gchar *name,
const gchar *str)
+{
+ GValue *val = new_value(G_TYPE_STRING);
+ g_value_set_string(val, str);
+
+ rs_filter_param_set_gvalue(filter_param, name, val);
+}
+
+/**
+ * Get a string property
+ * @param filter_param A RSFilterParam
+ * @param name The name of the property
+ * @param str A pointer to a string pointer where the value of the property
can be saved. Should not be freed
+ * @return TRUE if the property was found, FALSE otherwise
+ */
+gboolean
+rs_filter_param_get_string(const RSFilterParam *filter_param, const gchar
*name, const gchar ** const str)
+{
+ GValue *val = rs_filter_param_get_gvalue(filter_param, name);
+
+ if (val && G_VALUE_HOLDS_STRING(val))
+ *str = g_value_get_string(val);
+
+ return (val != NULL);
+}
+
+/**
+ * Set a float property
+ * @param filter_param A RSFilterParam
+ * @param name The name of the property
+ * @param value A value to store
+ */
+void
+rs_filter_param_set_float(RSFilterParam *filter_param, const gchar *name,
const gfloat value)
+{
+ GValue *val = new_value(G_TYPE_FLOAT);
+ g_value_set_float(val, value);
+
+ rs_filter_param_set_gvalue(filter_param, name, val);
+}
+
+/**
+ * Get a float property
+ * @param filter_param A RSFilterParam
+ * @param name The name of the property
+ * @param value A pointer to a gfloat where the value will be stored
+ * @return TRUE if the property was found, FALSE otherwise
+ */
+gboolean
+rs_filter_param_get_float(const RSFilterParam *filter_param, const gchar
*name, gfloat *value)
+{
+ GValue *val = rs_filter_param_get_gvalue(filter_param, name);
+
+ if (val && G_VALUE_HOLDS_FLOAT(val))
+ *value = g_value_get_float(val);
+
+ return (val != NULL);
+}
Modified: trunk/librawstudio/rs-filter-param.h
===================================================================
--- trunk/librawstudio/rs-filter-param.h 2009-10-15 15:50:30 UTC (rev
2722)
+++ trunk/librawstudio/rs-filter-param.h 2009-10-15 16:08:04 UTC (rev
2723)
@@ -14,6 +14,9 @@
typedef struct {
GObject parent;
+ gboolean dispose_has_run;
+
+ GHashTable *properties;
} RSFilterParam;
typedef struct {
@@ -24,6 +27,44 @@
RSFilterParam *rs_filter_param_new(void);
+void
+rs_filter_param_clone(RSFilterParam *destination, const RSFilterParam *source);
+
+/**
+ * Set a string property
+ * @param filter_param A RSFilterParam
+ * @param name The name of the property
+ * @param str NULL-terminated string to set (will be copied)
+ */
+void rs_filter_param_set_string(RSFilterParam *filter_param, const gchar
*name, const gchar *str);
+
+/**
+ * Get a string property
+ * @param filter_param A RSFilterParam
+ * @param name The name of the property
+ * @param str A pointer to a string pointer where the value of the property
can be saved. Should not be freed
+ * @return TRUE if the property was found, FALSE otherwise
+ */
+gboolean rs_filter_param_get_string(const RSFilterParam *filter_param, const
gchar *name, const gchar ** const str);
+
+/**
+ * Set a float property
+ * @param filter_param A RSFilterParam
+ * @param name The name of the property
+ * @param value A value to store
+ */
+void
+rs_filter_param_set_float(RSFilterParam *filter_param, const gchar *name,
const gfloat value);
+
+/**
+ * Get a float property
+ * @param filter_param A RSFilterParam
+ * @param name The name of the property
+ * @param value A pointer to a gfloat where the value will be stored
+ * @return TRUE if the property was found, FALSE otherwise
+ */
+gboolean rs_filter_param_get_float(const RSFilterParam *filter_param, const
gchar *name, gfloat *value);
+
G_END_DECLS
#endif /* RS_FILTER_PARAM_H */
Modified: trunk/librawstudio/rs-filter-response.c
===================================================================
--- trunk/librawstudio/rs-filter-response.c 2009-10-15 15:50:30 UTC (rev
2722)
+++ trunk/librawstudio/rs-filter-response.c 2009-10-15 16:08:04 UTC (rev
2723)
@@ -28,8 +28,6 @@
gboolean quick;
RS_IMAGE16 *image;
GdkPixbuf *image8;
-
- GHashTable *properties;
};
G_DEFINE_TYPE(RSFilterResponse, rs_filter_response, RS_TYPE_FILTER_PARAM)
@@ -48,8 +46,6 @@
if (filter_response->image8)
g_object_unref(filter_response->image8);
-
- g_hash_table_destroy(filter_response->properties);
}
G_OBJECT_CLASS (rs_filter_response_parent_class)->dispose (object);
@@ -70,42 +66,13 @@
object_class->finalize = rs_filter_response_finalize;
}
-static inline GValue *
-new_value(GType type)
-{
- GValue *value = g_slice_new0(GValue);
- g_value_init(value, type);
-
- return value;
-}
-
static void
-free_value(gpointer data)
-{
- GValue *value = (GValue *) data;
-
- g_value_unset(value);
- g_slice_free(GValue, value);
-}
-
-static inline GValue *
-clone_value(const GValue *value)
-{
- GType type = G_VALUE_TYPE(value);
- GValue *ret = new_value(type);
- g_value_copy(value, ret);
-
- return ret;
-}
-
-static void
rs_filter_response_init(RSFilterResponse *filter_response)
{
filter_response->roi_set = FALSE;
filter_response->quick = FALSE;
filter_response->image = NULL;
filter_response->image8 = NULL;
- filter_response->properties = g_hash_table_new_full(g_str_hash,
g_str_equal, g_free, free_value);
filter_response->dispose_has_run = FALSE;
}
@@ -135,13 +102,7 @@
new_filter_response->roi = filter_response->roi;
new_filter_response->quick = filter_response->quick;
- /* Clone the properties table */
- GHashTableIter iter;
- gpointer key, value;
-
- g_hash_table_iter_init (&iter, filter_response->properties);
- while (g_hash_table_iter_next (&iter, &key, &value))
- g_hash_table_insert(new_filter_response->properties,
(gpointer) g_strdup(key), clone_value(value));
+ rs_filter_param_clone(RS_FILTER_PARAM(new_filter_response),
RS_FILTER_PARAM(filter_response));
}
return new_filter_response;
@@ -314,89 +275,3 @@
return ret;
}
-
-static void
-rs_filter_response_set_gvalue(const RSFilterResponse *filter_response, const
gchar *name, GValue * value)
-{
- g_assert(RS_IS_FILTER_RESPONSE(filter_response));
- g_assert(name != NULL);
- g_assert(name[0] != '\0');
-
- g_hash_table_insert(filter_response->properties, (gpointer)
g_strdup(name), value);
-}
-
-static GValue *
-rs_filter_response_get_gvalue(const RSFilterResponse *filter_response, const
gchar *name)
-{
- g_assert(RS_IS_FILTER_RESPONSE(filter_response));
-
- GValue *value = g_hash_table_lookup(filter_response->properties, name);
-
- return value;
-}
-
-/**
- * Set a string property
- * @param filter_response A RSFilterResponse
- * @param name The name of the property
- * @param str NULL-terminated string to set (will be copied)
- */
-void
-rs_filter_response_set_string(const RSFilterResponse *filter_response, const
gchar *name, const gchar *str)
-{
- GValue *val = new_value(G_TYPE_STRING);
- g_value_set_string(val, str);
-
- rs_filter_response_set_gvalue(filter_response, name, val);
-}
-
-/**
- * Get a string property
- * @param filter_response A RSFilterResponse
- * @param name The name of the property
- * @param str A pointer to a string pointer where the value of the property
can be saved. Should not be freed
- * @return TRUE if the property was found, FALSE otherwise
- */
-gboolean
-rs_filter_response_get_string(const RSFilterResponse *filter_response, const
gchar *name, const gchar ** const str)
-{
- GValue *val = rs_filter_response_get_gvalue(filter_response, name);
-
- if (val && G_VALUE_HOLDS_STRING(val))
- *str = g_value_get_string(val);
-
- return (val != NULL);
-}
-
-/**
- * Set a float property
- * @param filter_response A RSFilterResponse
- * @param name The name of the property
- * @param value A value to store
- */
-void
-rs_filter_response_set_float(const RSFilterResponse *filter_response, const
gchar *name, const gfloat value)
-{
- GValue *val = new_value(G_TYPE_FLOAT);
- g_value_set_float(val, value);
-
- rs_filter_response_set_gvalue(filter_response, name, val);
-}
-
-/**
- * Get a float property
- * @param filter_response A RSFilterResponse
- * @param name The name of the property
- * @param value A pointer to a gfloat where the value will be stored
- * @return TRUE if the property was found, FALSE otherwise
- */
-gboolean
-rs_filter_response_get_float(const RSFilterResponse *filter_response, const
gchar *name, gfloat *value)
-{
- GValue *val = rs_filter_response_get_gvalue(filter_response, name);
-
- if (val && G_VALUE_HOLDS_FLOAT(val))
- *value = g_value_get_float(val);
-
- return (val != NULL);
-}
Modified: trunk/librawstudio/rs-filter-response.h
===================================================================
--- trunk/librawstudio/rs-filter-response.h 2009-10-15 15:50:30 UTC (rev
2722)
+++ trunk/librawstudio/rs-filter-response.h 2009-10-15 16:08:04 UTC (rev
2723)
@@ -130,41 +130,6 @@
*/
GdkPixbuf *rs_filter_response_get_image8(const RSFilterResponse
*filter_response);
-/**
- * Set a string property
- * @param filter_response A RSFilterResponse
- * @param name The name of the property
- * @param str NULL-terminated string to set (will be copied)
- */
-void rs_filter_response_set_string(const RSFilterResponse *filter_response,
const gchar *name, const gchar *str);
-
-/**
- * Get a string property
- * @param filter_response A RSFilterResponse
- * @param name The name of the property
- * @param str A pointer to a string pointer where the value of the property
can be saved. Should not be freed
- * @return TRUE if the property was found, FALSE otherwise
- */
-gboolean rs_filter_response_get_string(const RSFilterResponse
*filter_response, const gchar *name, const gchar ** const str);
-
-/**
- * Set a float property
- * @param filter_response A RSFilterResponse
- * @param name The name of the property
- * @param value A value to store
- */
-void
-rs_filter_response_set_float(const RSFilterResponse *filter_response, const
gchar *name, const gfloat value);
-
-/**
- * Get a float property
- * @param filter_response A RSFilterResponse
- * @param name The name of the property
- * @param value A pointer to a gfloat where the value will be stored
- * @return TRUE if the property was found, FALSE otherwise
- */
-gboolean rs_filter_response_get_float(const RSFilterResponse *filter_response,
const gchar *name, gfloat *value);
-
G_END_DECLS
#endif /* RS_FILTER_RESPONSE_H */
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit