[libgsf] GsfInput, GsfOutput: clean up a bit
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsf] GsfInput, GsfOutput: clean up a bit
- Date: Wed, 7 Dec 2011 16:14:12 +0000 (UTC)
commit 8caf3accd579d87045164c69c3ef07bdf0e44178
Author: Morten Welinder <terra gnome org>
Date: Wed Dec 7 11:07:08 2011 -0500
GsfInput, GsfOutput: clean up a bit
Notify ::name
Avoid G_OBJECT casts
ChangeLog | 12 ++++++++++++
NEWS | 1 +
configure.in | 4 ++--
gsf/gsf-input.c | 39 ++++++++++++++++++---------------------
gsf/gsf-output.c | 45 +++++++++++++++++++++++----------------------
5 files changed, 56 insertions(+), 45 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index df9143b..4dbaba6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2011-12-07 Morten Welinder <terra gnome org>
+
+ * configure.in: Require glib 2.16 for g_strcmp0.
+
+ * gsf/gsf-input.c (gsf_input_dispose): Rename from
+ gsf_input_finalize and hook up accordingly.
+ (gsf_input_set_name): Notify the property if changed.
+
+ * gsf/gsf-output.c (gsf_output_set_name): Notify the property if
+ changed.
+ (gsf_output_set_name_from_filename): Base of gsf_output_set_name.
+
2011-11-08 Morten Welinder <terra gnome org>
* gsf/gsf-input-gio.c (gsf_input_gio_read): Handle unexpected EOF
diff --git a/NEWS b/NEWS
index 1fa6fa3..cd36e24 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ Damien Lespiau:
Morten:
* Fix error messages on win32.
* Fix resource limiting in thumbnailer.
+ * Ensure GsfOutput::name and GsfInput::name notifications.
--------------------------------------------------------------------------
libgsf 1.14.21
diff --git a/configure.in b/configure.in
index 6d78f95..d4408c3 100644
--- a/configure.in
+++ b/configure.in
@@ -70,8 +70,8 @@ ifelse([
])
dnl Modules common to libgsf and libgsf-gnome
common_reqs="
- gobject-2.0 >= 2.6.0
- glib-2.0 >= 2.8.0
+ gobject-2.0 >= 2.16.0
+ glib-2.0 >= 2.16.0
"
dnl Modules required for libgsf
libgsf_reqs="
diff --git a/gsf/gsf-input.c b/gsf/gsf-input.c
index 2b28a7f..328d82b 100644
--- a/gsf/gsf-input.c
+++ b/gsf/gsf-input.c
@@ -88,17 +88,14 @@ gsf_input_get_property (GObject *object,
}
static void
-gsf_input_finalize (GObject *obj)
+gsf_input_dispose (GObject *obj)
{
GsfInput *input = GSF_INPUT (obj);
- g_free (input->name);
- input->name = NULL;
- if (input->container != NULL) {
- g_object_unref (G_OBJECT (input->container));
- input->container = NULL;
- }
- parent_class->finalize (obj);
+ gsf_input_set_container (input, NULL);
+ gsf_input_set_name (input, NULL);
+
+ parent_class->dispose (obj);
}
static void
@@ -117,7 +114,7 @@ gsf_input_class_init (GObjectClass *gobject_class)
{
parent_class = g_type_class_peek_parent (gobject_class);
- gobject_class->finalize = gsf_input_finalize;
+ gobject_class->dispose = gsf_input_dispose;
/* gobject_class->set_property = gsf_input_set_property; */
gobject_class->get_property = gsf_input_get_property;
@@ -224,11 +221,10 @@ gsf_input_dup (GsfInput *input, GError **err)
return NULL;
}
- if (input->name != NULL)
- gsf_input_set_name (dst, input->name);
+ gsf_input_set_name (dst, input->name);
dst->container = input->container;
if (dst->container != NULL)
- g_object_ref (G_OBJECT (dst->container));
+ g_object_ref (dst->container);
}
return dst;
}
@@ -398,13 +394,14 @@ gsf_input_seek (GsfInput *input, gsf_off_t offset, GSeekType whence)
gboolean
gsf_input_set_name (GsfInput *input, char const *name)
{
- char *buf;
-
g_return_val_if_fail (input != NULL, FALSE);
- buf = g_strdup (name);
- g_free (input->name);
- input->name = buf;
+ if (g_strcmp0 (name, input->name)) {
+ g_free (input->name);
+ input->name = g_strdup (name);
+ g_object_notify (G_OBJECT (input), "name");
+ }
+
return TRUE;
}
@@ -441,9 +438,9 @@ gsf_input_set_container (GsfInput *input, GsfInfile *container)
g_return_val_if_fail (input != NULL, FALSE);
if (container != NULL)
- g_object_ref (G_OBJECT (container));
+ g_object_ref (container);
if (input->container != NULL)
- g_object_unref (G_OBJECT (input->container));
+ g_object_unref (input->container);
input->container = container;
return TRUE;
}
@@ -588,7 +585,7 @@ gsf_input_uncompress (GsfInput *src)
if (memcmp (gzip_sig, data, sizeof (gzip_sig)) == 0) {
GsfInput *res = gsf_input_gzip_new (src, NULL);
if (res) {
- g_object_unref (G_OBJECT (src));
+ g_object_unref (src);
return gsf_input_uncompress (res);
}
}
@@ -602,7 +599,7 @@ gsf_input_uncompress (GsfInput *src)
if (memcmp (bzip_sig, data, strlen (bzip_sig)) == 0) {
GsfInput *res = gsf_input_memory_new_from_bzip (src, NULL);
if (res) {
- g_object_unref (G_OBJECT (src));
+ g_object_unref (src);
return gsf_input_uncompress (res);
}
}
diff --git a/gsf/gsf-output.c b/gsf/gsf-output.c
index 1550d1a..bda6fbf 100644
--- a/gsf/gsf-output.c
+++ b/gsf/gsf-output.c
@@ -88,19 +88,15 @@ gsf_output_dispose (GObject *obj)
gsf_output_close (output);
}
- g_free (output->name);
- output->name = NULL;
+ gsf_output_set_container (output, NULL);
+ gsf_output_set_name (output, NULL);
+
g_free (output->printf_buf);
output->printf_buf = NULL;
g_clear_error (&output->err);
- if (output->container != NULL) {
- g_object_unref (G_OBJECT (output->container));
- output->container = NULL;
- }
-
- G_OBJECT_CLASS (parent_class)->dispose (obj);
+ parent_class->dispose (obj);
}
static void
@@ -384,13 +380,14 @@ gsf_output_error (GsfOutput const *output)
gboolean
gsf_output_set_name (GsfOutput *output, char const *name)
{
- char *buf;
-
g_return_val_if_fail (GSF_IS_OUTPUT (output), FALSE);
- buf = g_strdup (name);
- g_free (output->name);
- output->name = buf;
+ if (g_strcmp0 (name, output->name)) {
+ g_free (output->name);
+ output->name = g_strdup (name);
+ g_object_notify (G_OBJECT (output), "name");
+ }
+
return TRUE;
}
@@ -407,13 +404,17 @@ gsf_output_set_name (GsfOutput *output, char const *name)
gboolean
gsf_output_set_name_from_filename (GsfOutput *output, char const *filename)
{
+ char *name;
+ gboolean res;
+
g_return_val_if_fail (GSF_IS_OUTPUT (output), FALSE);
- g_free (output->name);
- output->name = filename
+ name = filename
? g_filename_to_utf8 (filename, -1, NULL, NULL, NULL)
: NULL;
- return TRUE;
+ res = gsf_output_set_name (output, name);
+ g_free (name);
+ return res;
}
/**
@@ -432,9 +433,9 @@ gsf_output_set_container (GsfOutput *output, GsfOutfile *container)
g_return_val_if_fail (GSF_IS_OUTPUT (output), FALSE);
if (container != NULL)
- g_object_ref (G_OBJECT (container));
+ g_object_ref (container);
if (output->container != NULL)
- g_object_unref (G_OBJECT (output->container));
+ g_object_unref (output->container);
output->container = container;
return TRUE;
}
@@ -502,8 +503,8 @@ gsf_output_wrap (GObject *wrapper, GsfOutput *wrapee)
return FALSE;
}
- g_object_weak_ref (G_OBJECT (wrapper),
- (GWeakNotify) cb_output_unwrap, wrapee);
+ g_object_weak_ref (wrapper,
+ (GWeakNotify) cb_output_unwrap, wrapee);
wrapee->wrapped_by = wrapper;
return TRUE;
}
@@ -522,8 +523,8 @@ gsf_output_unwrap (GObject *wrapper, GsfOutput *wrapee)
g_return_val_if_fail (wrapee->wrapped_by == wrapper, FALSE);
wrapee->wrapped_by = NULL;
- g_object_weak_unref (G_OBJECT (wrapper),
- (GWeakNotify) cb_output_unwrap, wrapee);
+ g_object_weak_unref (wrapper,
+ (GWeakNotify) cb_output_unwrap, wrapee);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]