glib r7044 - in trunk: . docs/reference/gio gio
- From: rburton svn gnome org
- To: svn-commits-list gnome org
- Subject: glib r7044 - in trunk: . docs/reference/gio gio
- Date: Mon, 16 Jun 2008 08:49:08 +0000 (UTC)
Author: rburton
Date: Mon Jun 16 08:49:08 2008
New Revision: 7044
URL: http://svn.gnome.org/viewvc/glib?rev=7044&view=rev
Log:
2008-06-16 Ross Burton <ross burtonini com>
Bug 536252 â GFileEnumerator should allow access to the containing
GFile
* gio/gfileenumerator.c:
* gio/gfileenumerator.h:
* gio/gfile.h:
Add g_file_enumerator_get_container() and a container writeable
construct-only property. Also shuffle around typedefs to make it
compile.
* gio/glocalfileenumerator.c:
* gio/glocalfileenumerator.h:
* gio/glocalfile.c:
Instead of a string filename take a GFile in the constructor and
use it to set the container property.
* gio/gio.symbols:
* docs/reference/gio/gio-sections.txt:
Update with new API.
Modified:
trunk/ChangeLog
trunk/docs/reference/gio/gio-sections.txt
trunk/gio/gfile.h
trunk/gio/gfileenumerator.c
trunk/gio/gfileenumerator.h
trunk/gio/gio.symbols
trunk/gio/glocalfile.c
trunk/gio/glocalfileenumerator.c
trunk/gio/glocalfileenumerator.h
Modified: trunk/docs/reference/gio/gio-sections.txt
==============================================================================
--- trunk/docs/reference/gio/gio-sections.txt (original)
+++ trunk/docs/reference/gio/gio-sections.txt Mon Jun 16 08:49:08 2008
@@ -146,6 +146,7 @@
g_file_enumerator_is_closed
g_file_enumerator_has_pending
g_file_enumerator_set_pending
+g_file_enumerator_get_container
<SUBSECTION Standard>
GFileEnumeratorClass
G_FILE_ENUMERATOR
Modified: trunk/gio/gfile.h
==============================================================================
--- trunk/gio/gfile.h (original)
+++ trunk/gio/gfile.h Mon Jun 16 08:49:08 2008
@@ -124,6 +124,7 @@
G_FILE_MONITOR_WATCH_MOUNTS = (1<<0)
} GFileMonitorFlags;
+#if 0
/**
* GFile:
*
@@ -132,6 +133,7 @@
* necessarily represent files or directories that currently exist.
**/
typedef struct _GFile GFile; /* Dummy typedef */
+#endif
typedef struct _GFileIface GFileIface;
typedef struct _GFileMonitor GFileMonitor;
Modified: trunk/gio/gfileenumerator.c
==============================================================================
--- trunk/gio/gfileenumerator.c (original)
+++ trunk/gio/gfileenumerator.c Mon Jun 16 08:49:08 2008
@@ -56,12 +56,18 @@
struct _GFileEnumeratorPrivate {
/* TODO: Should be public for subclasses? */
+ GFile *container;
guint closed : 1;
guint pending : 1;
GAsyncReadyCallback outstanding_callback;
GError *outstanding_error;
};
+enum {
+ PROP_0,
+ PROP_CONTAINER
+};
+
static void g_file_enumerator_real_next_files_async (GFileEnumerator *enumerator,
int num_files,
int io_priority,
@@ -81,6 +87,42 @@
GError **error);
static void
+g_file_enumerator_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GFileEnumerator *enumerator;
+
+ enumerator = G_FILE_ENUMERATOR (object);
+
+ switch (property_id) {
+ case PROP_CONTAINER:
+ enumerator->priv->container = g_value_dup_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+g_file_enumerator_dispose (GObject *object)
+{
+ GFileEnumerator *enumerator;
+
+ enumerator = G_FILE_ENUMERATOR (object);
+
+ if (enumerator->priv->container) {
+ g_object_unref (enumerator->priv->container);
+ enumerator->priv->container = NULL;
+ }
+
+ if (G_OBJECT_CLASS (g_file_enumerator_parent_class)->dispose)
+ (*G_OBJECT_CLASS (g_file_enumerator_parent_class)->dispose) (object);
+}
+
+static void
g_file_enumerator_finalize (GObject *object)
{
GFileEnumerator *enumerator;
@@ -101,12 +143,23 @@
g_type_class_add_private (klass, sizeof (GFileEnumeratorPrivate));
+ gobject_class->set_property = g_file_enumerator_set_property;
+ gobject_class->dispose = g_file_enumerator_dispose;
gobject_class->finalize = g_file_enumerator_finalize;
klass->next_files_async = g_file_enumerator_real_next_files_async;
klass->next_files_finish = g_file_enumerator_real_next_files_finish;
klass->close_async = g_file_enumerator_real_close_async;
klass->close_finish = g_file_enumerator_real_close_finish;
+
+ g_object_class_install_property
+ (gobject_class, PROP_CONTAINER,
+ g_param_spec_object ("container", P_("Container"),
+ P_("The container that is being enumerated"),
+ G_TYPE_FILE,
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
}
static void
@@ -526,6 +579,24 @@
enumerator->priv->pending = pending;
}
+/**
+ * g_file_enumerator_get_container:
+ * @enumerator: a #GFileEnumerator
+ *
+ * Get the #GFile container which is being enumerated.
+ *
+ * Returns: the #GFile which is being enumerated.
+ *
+ * Since: 2.18.
+ */
+GFile *
+g_file_enumerator_get_container (GFileEnumerator *enumerator)
+{
+ g_return_val_if_fail (G_IS_FILE_ENUMERATOR (enumerator), NULL);
+
+ return enumerator->priv->container;
+}
+
typedef struct {
int num_files;
GList *files;
Modified: trunk/gio/gfileenumerator.h
==============================================================================
--- trunk/gio/gfileenumerator.h (original)
+++ trunk/gio/gfileenumerator.h Mon Jun 16 08:49:08 2008
@@ -53,6 +53,17 @@
typedef struct _GFileEnumeratorClass GFileEnumeratorClass;
typedef struct _GFileEnumeratorPrivate GFileEnumeratorPrivate;
+/* Nasty */
+GType g_file_get_type (void) G_GNUC_CONST;
+#define G_TYPE_FILE (g_file_get_type ())
+/**
+ * GFile:
+ *
+ * A handle to an object implementing the #GFileIface interface.
+ * Generally stores a location within the file system. Handles do not
+ * necessarily represent files or directories that currently exist.
+ **/
+typedef struct _GFile GFile; /* Dummy typedef */
struct _GFileEnumerator
{
@@ -133,6 +144,7 @@
gboolean g_file_enumerator_has_pending (GFileEnumerator *enumerator);
void g_file_enumerator_set_pending (GFileEnumerator *enumerator,
gboolean pending);
+GFile * g_file_enumerator_get_container (GFileEnumerator *enumerator);
G_END_DECLS
Modified: trunk/gio/gio.symbols
==============================================================================
--- trunk/gio/gio.symbols (original)
+++ trunk/gio/gio.symbols Mon Jun 16 08:49:08 2008
@@ -323,6 +323,7 @@
g_file_enumerator_is_closed
g_file_enumerator_has_pending
g_file_enumerator_set_pending
+g_file_enumerator_get_container
#endif
#endif
Modified: trunk/gio/glocalfile.c
==============================================================================
--- trunk/gio/glocalfile.c (original)
+++ trunk/gio/glocalfile.c Mon Jun 16 08:49:08 2008
@@ -578,7 +578,7 @@
GError **error)
{
GLocalFile *local = G_LOCAL_FILE (file);
- return _g_local_file_enumerator_new (local->filename,
+ return _g_local_file_enumerator_new (local,
attributes, flags,
cancellable, error);
}
Modified: trunk/gio/glocalfileenumerator.c
==============================================================================
--- trunk/gio/glocalfileenumerator.c (original)
+++ trunk/gio/glocalfileenumerator.c Mon Jun 16 08:49:08 2008
@@ -25,6 +25,7 @@
#include <glib.h>
#include <glocalfileenumerator.h>
#include <glocalfileinfo.h>
+#include <glocalfile.h>
#include <string.h>
#include <stdlib.h>
#include "glibintl.h"
@@ -187,13 +188,16 @@
#endif
GFileEnumerator *
-_g_local_file_enumerator_new (const char *filename,
+_g_local_file_enumerator_new (GLocalFile *file,
const char *attributes,
GFileQueryInfoFlags flags,
GCancellable *cancellable,
GError **error)
{
GLocalFileEnumerator *local;
+ char *filename;
+
+ filename = g_file_get_path (G_FILE (file));
#ifdef USE_GDIR
GError *dir_error;
@@ -208,6 +212,7 @@
convert_file_to_io_error (error, dir_error);
g_error_free (dir_error);
}
+ g_free (filename);
return NULL;
}
#else
@@ -222,15 +227,18 @@
g_set_error (error, G_IO_ERROR,
g_io_error_from_errno (errsv),
"%s", g_strerror (errsv));
+ g_free (filename);
return NULL;
}
#endif
- local = g_object_new (G_TYPE_LOCAL_FILE_ENUMERATOR, NULL);
+ local = g_object_new (G_TYPE_LOCAL_FILE_ENUMERATOR,
+ "container", file,
+ NULL);
local->dir = dir;
- local->filename = g_strdup (filename);
+ local->filename = filename;
local->matcher = g_file_attribute_matcher_new (attributes);
local->flags = flags;
Modified: trunk/gio/glocalfileenumerator.h
==============================================================================
--- trunk/gio/glocalfileenumerator.h (original)
+++ trunk/gio/glocalfileenumerator.h Mon Jun 16 08:49:08 2008
@@ -26,6 +26,7 @@
#include <gfileenumerator.h>
#include <gfileinfo.h>
#include <gfile.h>
+#include <glocalfile.h>
G_BEGIN_DECLS
@@ -49,7 +50,7 @@
GType _g_local_file_enumerator_get_type (void) G_GNUC_CONST;
-GFileEnumerator *_g_local_file_enumerator_new (const char *filename,
+GFileEnumerator *_g_local_file_enumerator_new (GLocalFile *file,
const char *attributes,
GFileQueryInfoFlags flags,
GCancellable *cancellable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]