[glib/wip/gdesktopappinfo: 3/13] inotify: stop using constructor()
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/gdesktopappinfo: 3/13] inotify: stop using constructor()
- Date: Thu, 1 Aug 2013 09:05:36 +0000 (UTC)
commit b2966bc6cfe82c8ef427e1633a3605c61bb0f4d7
Author: Ryan Lortie <desrt desrt ca>
Date: Thu Jul 25 13:48:50 2013 -0400
inotify: stop using constructor()
and start using the new start() vcall on the local monitor classes.
I only port inotify because I am uncomfortable making changes to the
other monitor backends without having a way of testing them.
gio/inotify/ginotifydirectorymonitor.c | 36 +++++-------------
gio/inotify/ginotifyfilemonitor.c | 62 +++++++++----------------------
2 files changed, 28 insertions(+), 70 deletions(-)
---
diff --git a/gio/inotify/ginotifydirectorymonitor.c b/gio/inotify/ginotifydirectorymonitor.c
index 89c818c..7b7fd0f 100644
--- a/gio/inotify/ginotifydirectorymonitor.c
+++ b/gio/inotify/ginotifydirectorymonitor.c
@@ -59,55 +59,39 @@ g_inotify_directory_monitor_finalize (GObject *object)
inotify_monitor->sub = NULL;
}
- if (G_OBJECT_CLASS (g_inotify_directory_monitor_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_inotify_directory_monitor_parent_class)->finalize) (object);
+ G_OBJECT_CLASS (g_inotify_directory_monitor_parent_class)->finalize (object);
}
-static GObject *
-g_inotify_directory_monitor_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+static void
+g_inotify_directory_monitor_start (GLocalDirectoryMonitor *local_monitor)
{
- GObject *obj;
- GInotifyDirectoryMonitorClass *klass;
- GObjectClass *parent_class;
- GInotifyDirectoryMonitor *inotify_monitor;
+ GInotifyDirectoryMonitor *inotify_monitor = G_INOTIFY_DIRECTORY_MONITOR (local_monitor);
const gchar *dirname = NULL;
inotify_sub *sub = NULL;
gboolean ret_ih_startup; /* return value of _ih_startup, for asserting */
gboolean pair_moves;
-
- klass = G_INOTIFY_DIRECTORY_MONITOR_CLASS (g_type_class_peek (G_TYPE_INOTIFY_DIRECTORY_MONITOR));
- parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
- obj = parent_class->constructor (type,
- n_construct_properties,
- construct_properties);
-
- inotify_monitor = G_INOTIFY_DIRECTORY_MONITOR (obj);
- dirname = G_LOCAL_DIRECTORY_MONITOR (obj)->dirname;
+ dirname = local_monitor->dirname;
g_assert (dirname != NULL);
- /* Will never fail as is_supported() should be called before instanciating
+ /* Will never fail as is_supported() should be called before instantiating
* anyway */
/* assert on return value */
ret_ih_startup = _ih_startup();
g_assert (ret_ih_startup);
- pair_moves = G_LOCAL_DIRECTORY_MONITOR (obj)->flags & G_FILE_MONITOR_SEND_MOVED;
+ pair_moves = local_monitor->flags & G_FILE_MONITOR_SEND_MOVED;
sub = _ih_sub_new (dirname, NULL, pair_moves, FALSE, inotify_monitor);
/* FIXME: what to do about errors here? we can't return NULL or another
* kind of error and an assertion is probably too hard */
g_assert (sub != NULL);
-
+
/* _ih_sub_add allways returns TRUE, see gio/inotify/inotify-helper.c line 109
* g_assert (_ih_sub_add (sub)); */
_ih_sub_add(sub);
inotify_monitor->sub = sub;
-
- return obj;
}
static gboolean
@@ -122,13 +106,13 @@ g_inotify_directory_monitor_class_init (GInotifyDirectoryMonitorClass* klass)
GObjectClass* gobject_class = G_OBJECT_CLASS (klass);
GFileMonitorClass *directory_monitor_class = G_FILE_MONITOR_CLASS (klass);
GLocalDirectoryMonitorClass *local_directory_monitor_class = G_LOCAL_DIRECTORY_MONITOR_CLASS (klass);
-
+
gobject_class->finalize = g_inotify_directory_monitor_finalize;
- gobject_class->constructor = g_inotify_directory_monitor_constructor;
directory_monitor_class->cancel = g_inotify_directory_monitor_cancel;
local_directory_monitor_class->mount_notify = TRUE;
local_directory_monitor_class->is_supported = g_inotify_directory_monitor_is_supported;
+ local_directory_monitor_class->start = g_inotify_directory_monitor_start;
}
static void
diff --git a/gio/inotify/ginotifyfilemonitor.c b/gio/inotify/ginotifyfilemonitor.c
index 5d300bb..ca30139 100644
--- a/gio/inotify/ginotifyfilemonitor.c
+++ b/gio/inotify/ginotifyfilemonitor.c
@@ -62,67 +62,43 @@ g_inotify_file_monitor_finalize (GObject *object)
inotify_monitor->sub = NULL;
}
- if (inotify_monitor->filename)
- {
- g_free (inotify_monitor->filename);
- inotify_monitor->filename = NULL;
- }
-
- if (inotify_monitor->dirname)
- {
- g_free (inotify_monitor->dirname);
- inotify_monitor->dirname = NULL;
- }
+ g_free (inotify_monitor->filename);
+ g_free (inotify_monitor->dirname);
- if (G_OBJECT_CLASS (g_inotify_file_monitor_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_inotify_file_monitor_parent_class)->finalize) (object);
+ G_OBJECT_CLASS (g_inotify_file_monitor_parent_class)->finalize (object);
}
-static GObject *
-g_inotify_file_monitor_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+static void
+g_inotify_file_monitor_start (GLocalFileMonitor *local_monitor)
{
- GObject *obj;
- GInotifyFileMonitorClass *klass;
- GObjectClass *parent_class;
- GInotifyFileMonitor *inotify_monitor;
+ GInotifyFileMonitor *inotify_monitor = G_INOTIFY_FILE_MONITOR (local_monitor);
const gchar *filename = NULL;
gboolean watch_hardlinks;
inotify_sub *sub = NULL;
gboolean pair_moves;
- gboolean ret_ih_startup; /* return value of _ih_startup, for asserting */
-
- klass = G_INOTIFY_FILE_MONITOR_CLASS (g_type_class_peek (G_TYPE_INOTIFY_FILE_MONITOR));
- parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
- obj = parent_class->constructor (type,
- n_construct_properties,
- construct_properties);
-
- inotify_monitor = G_INOTIFY_FILE_MONITOR (obj);
-
- filename = G_LOCAL_FILE_MONITOR (obj)->filename;
+ gboolean ret_ih_startup; /* return value of _ih_startup, for asserting */
+ filename = local_monitor->filename;
g_assert (filename != NULL);
inotify_monitor->filename = g_path_get_basename (filename);
inotify_monitor->dirname = g_path_get_dirname (filename);
- /* Will never fail as is_supported() should be called before instanciating
+ /* Will never fail as is_supported() should be called before instantiating
* anyway */
/* assert on return value */
ret_ih_startup = _ih_startup();
g_assert (ret_ih_startup);
- pair_moves = G_LOCAL_FILE_MONITOR (obj)->flags & G_FILE_MONITOR_SEND_MOVED;
- watch_hardlinks = G_LOCAL_FILE_MONITOR (obj)->flags & G_FILE_MONITOR_WATCH_HARD_LINKS;
+ pair_moves = local_monitor->flags & G_FILE_MONITOR_SEND_MOVED;
+ watch_hardlinks = local_monitor->flags & G_FILE_MONITOR_WATCH_HARD_LINKS;
sub = _ih_sub_new (inotify_monitor->dirname,
- inotify_monitor->filename,
- pair_moves,
- watch_hardlinks,
- inotify_monitor);
-
+ inotify_monitor->filename,
+ pair_moves,
+ watch_hardlinks,
+ inotify_monitor);
+
/* FIXME: what to do about errors here? we can't return NULL or another
* kind of error and an assertion is probably too hard */
g_assert (sub != NULL);
@@ -132,8 +108,6 @@ g_inotify_file_monitor_constructor (GType type,
_ih_sub_add (sub);
inotify_monitor->sub = sub;
-
- return obj;
}
static gboolean
@@ -148,12 +122,12 @@ g_inotify_file_monitor_class_init (GInotifyFileMonitorClass* klass)
GObjectClass* gobject_class = G_OBJECT_CLASS (klass);
GFileMonitorClass *file_monitor_class = G_FILE_MONITOR_CLASS (klass);
GLocalFileMonitorClass *local_file_monitor_class = G_LOCAL_FILE_MONITOR_CLASS (klass);
-
+
gobject_class->finalize = g_inotify_file_monitor_finalize;
- gobject_class->constructor = g_inotify_file_monitor_constructor;
file_monitor_class->cancel = g_inotify_file_monitor_cancel;
local_file_monitor_class->is_supported = g_inotify_file_monitor_is_supported;
+ local_file_monitor_class->start = g_inotify_file_monitor_start;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]