X-Git-Url: http://git.roojs.org/?p=gitlive;a=blobdiff_plain;f=Monitor.vala;h=1b5c4997864b2e2698c39414bef8ad4ad9ee5955;hp=9b3f41989f6dc1d49f2bcebf6e054931f153c605;hb=1ca3cefd12af4ec1e3cfa3469fbcfc1afc129723;hpb=79b628aef23a54509e78b1aead6480c721d13a4d diff --git a/Monitor.vala b/Monitor.vala index 9b3f4198..1b5c4997 100644 --- a/Monitor.vala +++ b/Monitor.vala @@ -68,7 +68,12 @@ public delegate void onEventHander (FileMonitor fm, File f_orig, File of_orig, F * */ -public class Monitor : Object +public abstract class gitMonitorBase : Object +{ + public abstract void monitor(string path, int depth = 0); +} + +public class Monitor : gitMonitorBase { @@ -136,10 +141,10 @@ public class Monitor : Object * * */ - public void monitor(string path, int depth = 0) + public override void monitor(string path, int depth = 0) { - stdout.printf("ADD: (%d): %s\n", depth, path); + //GLib.debug("ADD: (%d): %s\n", depth, path); //depth = typeof(depth) == 'number' ? depth *1 : 0; depth = depth > 0 ? depth *1 : 0; @@ -148,15 +153,14 @@ public class Monitor : Object //fn = fn || function (fm, f, of, event_type, uh) { // _this.onEvent(fm, f, of, event_type, uh); //} - - + var f = File.new_for_path(path); //var cancel = new Gio.Cancellable (); if (depth > 0) { try { - - var fm = f.monitor(FileMonitorFlags.SEND_MOVED + FileMonitorFlags.WATCH_MOVES,null); //Gio.FileMonitorFlags.SEND_MOVED + var fm = f.monitor(FileMonitorFlags.SEND_MOVED + FileMonitorFlags.WATCH_MOVES,null); + //var fm = f.monitor(FileMonitorFlags.WATCH_MOVES,null); fm.changed.connect( this.onEvent ); this.monitors.append_val(fm); @@ -325,19 +329,23 @@ public class Monitor : Object return; case FileMonitorEvent.MOVED: // eg. chmod/chatt + case FileMonitorEvent.MOVED_IN: // eg. chmod/chatt + case FileMonitorEvent.MOVED_OUT: // eg. chmod/chatt + case FileMonitorEvent.RENAMED: // eg. chmod/chatt - var of = this.realpath(of_orig); - var dest = new MonitorNamePathDir( - of.get_basename(), - of.get_path(), - Path.get_dirname(of.get_path()) - ); - + var of = this.realpath(of_orig); + var dest = new MonitorNamePathDir( + of.get_basename(), + of.get_path(), + Path.get_dirname(of.get_path()) + ); src.action = "moved"; dest.action = "moved"; this.onMoved(src,dest); return; + + default: stdout.printf("event type not handled %u", event_type); break;