1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
3
nautilus-monitor.c: file and directory change monitoring for nautilus
5
Copyright (C) 2000, 2001 Eazel, Inc.
7
This program is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public License as
9
published by the Free Software Foundation; either version 2 of the
10
License, or (at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
General Public License for more details.
17
You should have received a copy of the GNU General Public
18
License along with this program; if not, write to the
19
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
Boston, MA 02111-1307, USA.
22
Authors: Seth Nickell <seth@eazel.com>
23
Darin Adler <darin@bentspoon.com>
24
Alex Graveley <alex@ximian.com>
28
#include "gof-monitor.h"
29
//#include "nautilus-file-changes-queue.h"
30
//#include "nautilus-file-utilities.h"
36
GFileMonitor *monitor;
40
dir_changed (GFileMonitor* monitor,
43
GFileMonitorEvent event_type,
48
uri = g_file_get_uri (child);
51
to_uri = g_file_get_uri (other_file);
56
case G_FILE_MONITOR_EVENT_CHANGED:
59
case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
60
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
61
//nautilus_file_changes_queue_file_changed (child);
62
printf ("file changed %s\n", uri);
64
case G_FILE_MONITOR_EVENT_DELETED:
65
//nautilus_file_changes_queue_file_removed (child);
66
printf ("file deleted %s\n", uri);
68
case G_FILE_MONITOR_EVENT_CREATED:
69
//nautilus_file_changes_queue_file_added (child);
70
printf ("file added %s\n", uri);
73
case G_FILE_MONITOR_EVENT_PRE_UNMOUNT:
74
/* TODO: Do something */
76
case G_FILE_MONITOR_EVENT_UNMOUNTED:
77
/* TODO: Do something */
86
gof_monitor_directory (GFile *location)
88
GFileMonitor *dir_monitor;
91
dir_monitor = g_file_monitor_directory (location, G_FILE_MONITOR_WATCH_MOUNTS, NULL, NULL);
92
/* TODO: implement GCancellable * */
93
//dir_monitor = g_file_monitor_directory (location, G_FILE_MONITOR_SEND_MOVED, NULL, NULL);
94
ret = g_new0 (GOFMonitor, 1);
95
ret->monitor = dir_monitor;
98
g_signal_connect (ret->monitor, "changed", (GCallback)dir_changed, ret);
105
gof_monitor_cancel (GOFMonitor *monitor)
107
if (monitor->monitor != NULL) {
108
g_signal_handlers_disconnect_by_func (monitor->monitor, dir_changed, monitor);
109
g_file_monitor_cancel (monitor->monitor);
110
g_object_unref (monitor->monitor);