1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright (C) 2006-2007 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: Alexander Larsson <alexl@redhat.com>
25 #include "gioenumtypes.h"
26 #include "glocalfilemonitor.h"
27 #include "giomodule-priv.h"
41 G_DEFINE_ABSTRACT_TYPE (GLocalFileMonitor, g_local_file_monitor, G_TYPE_FILE_MONITOR)
44 g_local_file_monitor_init (GLocalFileMonitor* local_monitor)
49 g_local_file_monitor_set_property (GObject *object,
54 GLocalFileMonitor *local_monitor = G_LOCAL_FILE_MONITOR (object);
59 local_monitor->filename = g_value_dup_string (value);
63 local_monitor->flags = g_value_get_flags (value);
67 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
73 g_local_file_monitor_start (GLocalFileMonitor *local_monitor)
75 GLocalFileMonitorClass *class;
77 class = G_LOCAL_FILE_MONITOR_GET_CLASS (local_monitor);
80 class->start (local_monitor);
84 g_local_file_monitor_finalize (GObject *object)
86 GLocalFileMonitor *local_monitor = G_LOCAL_FILE_MONITOR (object);
88 g_free (local_monitor->filename);
90 G_OBJECT_CLASS (g_local_file_monitor_parent_class)->finalize (object);
93 static void g_local_file_monitor_class_init (GLocalFileMonitorClass *klass)
95 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
97 gobject_class->set_property = g_local_file_monitor_set_property;
98 gobject_class->finalize = g_local_file_monitor_finalize;
100 g_object_class_install_property (gobject_class,
102 g_param_spec_string ("filename",
104 P_("File name to monitor"),
106 G_PARAM_CONSTRUCT_ONLY|
108 G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
110 g_object_class_install_property (gobject_class,
112 g_param_spec_flags ("flags",
115 G_TYPE_FILE_MONITOR_FLAGS,
117 G_PARAM_CONSTRUCT_ONLY|
119 G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
123 _g_local_file_monitor_new (const char *pathname,
124 GFileMonitorFlags flags,
125 GMainContext *context,
126 gboolean is_remote_fs,
130 GFileMonitor *monitor = NULL;
131 GType type = G_TYPE_INVALID;
134 type = _g_io_module_get_default_type (G_NFS_FILE_MONITOR_EXTENSION_POINT_NAME,
135 "GIO_USE_FILE_MONITOR",
136 G_STRUCT_OFFSET (GLocalFileMonitorClass, is_supported));
138 if (type == G_TYPE_INVALID)
139 type = _g_io_module_get_default_type (G_LOCAL_FILE_MONITOR_EXTENSION_POINT_NAME,
140 "GIO_USE_FILE_MONITOR",
141 G_STRUCT_OFFSET (GLocalFileMonitorClass, is_supported));
143 if (type != G_TYPE_INVALID)
144 monitor = G_FILE_MONITOR (g_object_new (type, "filename", pathname, "flags", flags, "context", context, NULL));
146 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
147 _("Unable to find default local file monitor type"));
149 if (monitor && do_start)
150 g_local_file_monitor_start (G_LOCAL_FILE_MONITOR (monitor));