gdbus-tool: simplify some logic
[platform/upstream/glib.git] / gio / fen / gfenfilemonitor.c
index 0a977de..185555b 100644 (file)
@@ -4,7 +4,8 @@
  * 
  * Copyright (C) 2006-2007 Red Hat, Inc.
  * Copyright (C) 2007 Sebastian Dröge.
- * Copyright (C) 2008 Sun Microsystem.
+ * Copyright (c) 2008, 2010 Oracle and/or its affiliates, Inc. All rights
+ * reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -17,9 +18,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  *
  * Authors: Alexander Larsson <alexl@redhat.com>
  *          John McCutchan <john@johnmccutchan.com> 
  *          Lin Ma <lin.ma@sun.com>
  */
 
-#include <config.h>
+#include "config.h"
 
 #include "gfenfilemonitor.h"
 #include <gio/giomodule.h>
 
 #include "fen-helper.h"
 
-#include "gioalias.h"
-
 struct _GFenFileMonitor
 {
     GLocalFileMonitor parent_instance;
-    fen_sub* sub;
+    gboolean enabled;
 };
 
 static gboolean g_fen_file_monitor_cancel (GFileMonitor* monitor);
@@ -54,12 +51,11 @@ G_DEFINE_TYPE_WITH_CODE (GFenFileMonitor, g_fen_file_monitor, G_TYPE_LOCAL_FILE_
 static void
 g_fen_file_monitor_finalize (GObject *object)
 {
-       GFenFileMonitor *self = G_FEN_FILE_MONITOR (object);
+    GFenFileMonitor *self = G_FEN_FILE_MONITOR (object);
     
-    if (self->sub) {
-        fen_remove (G_LOCAL_FILE_MONITOR (self)->filename, self->sub, FALSE);
-        fen_sub_delete (self->sub);
-        self->sub = NULL;
+    if (self->enabled) {
+        fen_remove (G_LOCAL_FILE_MONITOR (self)->filename, self, FALSE);
+        self->enabled = FALSE;
     }
     
     if (G_OBJECT_CLASS (g_fen_file_monitor_parent_class)->finalize)
@@ -96,10 +92,8 @@ g_fen_file_monitor_constructor (GType type,
     
     /* FIXME: what to do about errors here? we can't return NULL or another
      * kind of error and an assertion is probably too hard */
-    self->sub = fen_sub_new (self, FALSE);
-    g_assert (self->sub);
-    
-    fen_add (filename, self->sub, FALSE);
+    fen_add (filename, self, FALSE);
+    self->enabled = TRUE;
 
     return obj;
 }
@@ -107,7 +101,7 @@ g_fen_file_monitor_constructor (GType type,
 static gboolean
 g_fen_file_monitor_is_supported (void)
 {
-       return fen_init ();
+    return fen_init ();
 }
 
 static void
@@ -134,10 +128,9 @@ g_fen_file_monitor_cancel (GFileMonitor* monitor)
 {
     GFenFileMonitor *self = G_FEN_FILE_MONITOR (monitor);
     
-    if (self->sub) {
-        fen_remove (G_LOCAL_FILE_MONITOR (self)->filename, self->sub, FALSE);
-        fen_sub_delete (self->sub);
-        self->sub = NULL;
+    if (self->enabled) {
+        fen_remove (G_LOCAL_FILE_MONITOR (self)->filename, self, FALSE);
+        self->enabled = FALSE;
     }
     
     if (G_FILE_MONITOR_CLASS (g_fen_file_monitor_parent_class)->cancel)
@@ -145,4 +138,3 @@ g_fen_file_monitor_cancel (GFileMonitor* monitor)
 
     return TRUE;
 }
-