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, see <http://www.gnu.org/licenses/>.
18 * Author: Alexander Larsson <alexl@redhat.com>
23 #include "gioenumtypes.h"
24 #include "glocalfilemonitor.h"
25 #include "giomodule-priv.h"
39 G_DEFINE_ABSTRACT_TYPE (GLocalFileMonitor, g_local_file_monitor, G_TYPE_FILE_MONITOR)
42 g_local_file_monitor_init (GLocalFileMonitor* local_monitor)
47 g_local_file_monitor_set_property (GObject *object,
52 GLocalFileMonitor *local_monitor = G_LOCAL_FILE_MONITOR (object);
57 local_monitor->filename = g_value_dup_string (value);
61 local_monitor->flags = g_value_get_flags (value);
65 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
71 g_local_file_monitor_start (GLocalFileMonitor *local_monitor)
73 GLocalFileMonitorClass *class;
75 class = G_LOCAL_FILE_MONITOR_GET_CLASS (local_monitor);
78 class->start (local_monitor);
82 g_local_file_monitor_finalize (GObject *object)
84 GLocalFileMonitor *local_monitor = G_LOCAL_FILE_MONITOR (object);
86 g_free (local_monitor->filename);
88 G_OBJECT_CLASS (g_local_file_monitor_parent_class)->finalize (object);
91 static void g_local_file_monitor_class_init (GLocalFileMonitorClass *klass)
93 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
95 gobject_class->set_property = g_local_file_monitor_set_property;
96 gobject_class->finalize = g_local_file_monitor_finalize;
98 g_object_class_install_property (gobject_class,
100 g_param_spec_string ("filename",
102 P_("File name to monitor"),
104 G_PARAM_CONSTRUCT_ONLY|
106 G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
108 g_object_class_install_property (gobject_class,
110 g_param_spec_flags ("flags",
113 G_TYPE_FILE_MONITOR_FLAGS,
115 G_PARAM_CONSTRUCT_ONLY|
117 G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
121 _g_local_file_monitor_new (const char *pathname,
122 GFileMonitorFlags flags,
123 GMainContext *context,
124 gboolean is_remote_fs,
128 GFileMonitor *monitor = NULL;
129 GType type = G_TYPE_INVALID;
132 type = _g_io_module_get_default_type (G_NFS_FILE_MONITOR_EXTENSION_POINT_NAME,
133 "GIO_USE_FILE_MONITOR",
134 G_STRUCT_OFFSET (GLocalFileMonitorClass, is_supported));
136 if (type == G_TYPE_INVALID)
137 type = _g_io_module_get_default_type (G_LOCAL_FILE_MONITOR_EXTENSION_POINT_NAME,
138 "GIO_USE_FILE_MONITOR",
139 G_STRUCT_OFFSET (GLocalFileMonitorClass, is_supported));
141 if (type != G_TYPE_INVALID)
142 monitor = G_FILE_MONITOR (g_object_new (type, "filename", pathname, "flags", flags, "context", context, NULL));
144 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
145 _("Unable to find default local file monitor type"));
147 if (monitor && do_start)
148 g_local_file_monitor_start (G_LOCAL_FILE_MONITOR (monitor));