Ejemplo n.º 1
0
    public Photo Create(string newPath, string origPath, uint roll_id, out Pixbuf thumbnail)
    {
        Photo photo;

        using (FSpot.ImageFile img = FSpot.ImageFile.Create(origPath)) {
            long   unix_time   = DbUtils.UnixTimeFromDateTime(img.Date);
            string description = img.Description != null?img.Description.Split('\0') [0] : String.Empty;

            uint id = (uint)Database.Execute(new DbCommand("INSERT INTO photos (time, " +
                                                           "directory_path, name, description, roll_id, default_version_id) " +
                                                           "VALUES (:time, :directory_path, :name, :description, " +
                                                           ":roll_id, :default_version_id)",
                                                           "time", unix_time,
                                                           "directory_path", System.IO.Path.GetDirectoryName(newPath),
                                                           "name", System.IO.Path.GetFileName(newPath),
                                                           "description", description,
                                                           "roll_id", roll_id,
                                                           "default_version_id", Photo.OriginalVersionId));

            photo = new Photo(id, unix_time, newPath);
            AddToCache(photo);
            photo.Loaded = true;

            thumbnail = GenerateThumbnail(UriList.PathToFileUri(newPath), img);
            EmitAdded(photo);
        }
        return(photo);
    }
        protected override void ProcessRequest(RequestItem request)
        {
            try {
                base.ProcessRequest(request);

                Gdk.Pixbuf image = request.result;
                if (image != null)
                {
                    Uri uri;
                    if (File.Exists(request.path))
                    {
                        uri = UriList.PathToFileUri(request.path);
                    }
                    else
                    {
                        uri = new Uri(request.path);
                    }

                    Save(image, uri);
                }

                System.Threading.Thread.Sleep(75);
            } catch (System.Exception e) {
                System.Console.WriteLine(e.ToString());
            }
        }
Ejemplo n.º 3
0
        public static void SetCopyFiles(this SelectionData selection_data, UriList uri_list)
        {
            var uris = (from p in uri_list select p.ToString()).ToArray();
            var data = Encoding.UTF8.GetBytes("copy\n" + string.Join("\n", uris));

            selection_data.Set(Atom.Intern("x-special/gnome-copied-files", true), 8, data, data.Length);
        }
        public static void Save(Gdk.Pixbuf image, Uri dest)
        {
            string uri = UriList.UriToStringEscaped(dest);

            System.DateTime mtime = DateTime.Now;

            // Use Gnome.Vfs
            try {
                Gnome.Vfs.FileInfo vfs = new Gnome.Vfs.FileInfo(uri);
                mtime = vfs.Mtime;

                PixbufUtils.SetOption(image, ThumbUri, uri);
                PixbufUtils.SetOption(image, ThumbMTime,
                                      ((uint)GLib.Marshaller.DateTimeTotime_t(mtime)).ToString());
            } catch (System.Exception e) {
                Console.WriteLine(e);
            }

            //System.Console.WriteLine ("saving uri \"{0}\" mtime \"{1}\"",
            //			  image.GetOption ("tEXt::Thumb::URI"),
            //			  image.GetOption ("tEXt::Thumb::MTime"));

            string large_path = ThumbnailPath(uri);

            try {
                ThumbnailCache.Default.RemoveThumbnailForPath(large_path);
            } finally {
                factory.SaveThumbnail(image, uri, mtime);
            }
        }
        void HandleDrops(int xx, int yy)
        {
            UriList uri_list = new UriList(uri_list_string);

            string [] cm_path_list = cm_path_string.Split('\n');

            uri_list_string = null;
            cm_path_string  = null;

            if (uri_list.Count != (cm_path_list.Length - 1))
            {
                Logger.Error("Error parsing drop input");
                return;
            }

            string cm_path_folderitem = cm_path_list[0];
            bool   first = true;

            for (int ii = 1; ii < cm_path_list.Length; ii++)
            {
                Uri    uri   = uri_list[ii - 1];
                string msgid = cm_path_list[ii];
                HandleDrop(xx, yy, first, uri, cm_path_folderitem, msgid);
                first = false;
            }
        }
Ejemplo n.º 6
0
 public void Viewbla(UriList list)
 {
     try {
         Register(new FSpot.SingleView(list).Window);
     } catch (System.Exception e) {
         System.Console.WriteLine(e.ToString());
         System.Console.WriteLine("no real valid path to view from {0}", list);
     }
 }
Ejemplo n.º 7
0
        public virtual void Enqueue(UriList uris)
        {
            CreateUserJob();

            foreach (string path in uris.LocalPaths)
            {
                base.Enqueue(path);
            }
        }
Ejemplo n.º 8
0
    public static void DeleteThumbnail(string path)
    {
        string uri = UriList.PathToFileUri(path).ToString();

        path = Thumbnail.PathForUri(uri, ThumbnailSize.Large);
        if (File.Exists(path))
        {
            File.Delete(path);
        }
    }
Ejemplo n.º 9
0
        private UriList MakeUris(StringList paths)
        {
            UriList newUris = new UriList();

            foreach (string s in paths)
            {
                newUris.Add(new Uri(s));
            }
            return(newUris);
        }
Ejemplo n.º 10
0
        protected override void OnDragDataReceived(Gdk.DragContext context,
                                                   int x, int y,
                                                   Gtk.SelectionData selectionData,
                                                   uint info, uint time_)
        {
            UriList uriList = new UriList(selectionData);

            if (uriList.Count == 0)
            {
                Gtk.Drag.Finish(context, false, false, time_);
                return;
            }

            Gtk.TreePath             path;
            Gtk.TreeViewDropPosition pos;
            if (GetDestRowAtPos(x, y, out path, out pos) == false)
            {
                Gtk.Drag.Finish(context, false, false, time_);
                return;
            }

            Gtk.TreeIter iter;
            if (Model.GetIter(out iter, path) == false)
            {
                Gtk.Drag.Finish(context, false, false, time_);
                return;
            }

            Notebook destNotebook = Model.GetValue(iter, 0) as Notebook;

            if (destNotebook is AllNotesNotebook)
            {
                Gtk.Drag.Finish(context, false, false, time_);
                return;
            }

            foreach (Uri uri in uriList)
            {
                Note note = noteManager.FindByUri(uri.ToString());
                if (note == null)
                {
                    continue;
                }

                Logger.Debug("Dropped into notebook: {0}", note.Title);

                // TODO: If we ever support selecting multiple notes,
                // we may want to double-check to see if there will be
                // any notes are already inside of a notebook.  Do we
                // want to prompt the user to confirm this choice?
                NotebookManager.MoveNoteToNotebook(note, destNotebook);
            }

            Gtk.Drag.Finish(context, true, false, time_);
        }
Ejemplo n.º 11
0
        static void Startup()
        {
            if (ApplicationContext.CommandLine.Contains("slideshow"))
            {
                App.Instance.Slideshow(null);
            }
            else if (ApplicationContext.CommandLine.Contains("shutdown"))
            {
                App.Instance.Shutdown();
            }
            else if (ApplicationContext.CommandLine.Contains("view"))
            {
                if (ApplicationContext.CommandLine.Files.Count == 0)
                {
                    Log.Error("f-spot: -view option takes at least one argument");
                    Environment.Exit(1);
                }

                var list = new UriList();

                foreach (var f in ApplicationContext.CommandLine.Files)
                {
                    list.AddUnknown(f);
                }

                if (list.Count == 0)
                {
                    ShowHelp();
                    Environment.Exit(1);
                }

                App.Instance.View(list);
            }
            else if (ApplicationContext.CommandLine.Contains("import"))
            {
                string dir = ApplicationContext.CommandLine ["import"];

                if (string.IsNullOrEmpty(dir))
                {
                    Log.Error("f-spot: -import option takes one argument");
                    Environment.Exit(1);
                }

                App.Instance.Import(dir);
            }
            else
            {
                App.Instance.Organize();
            }

            if (!App.Instance.IsRunning)
            {
                Gtk.Application.Run();
            }
        }
Ejemplo n.º 12
0
 protected bool GetValue(string name, out UriList value)
 {
     if (Key?.GetValue(name) is string[] v)
     {
         value = new UriList();
         value.AddRange(v.Select(entry => new Uri(entry)));
         return(true);
     }
     value = default;
     return(false);
 }
Ejemplo n.º 13
0
 public void Start()
 {
     isStop = false;
     while (!isStop && !IsComplete && UriList.Where((k, v) => !k.Value).Count() != 0)
     {
         var uri = UriList.Where((k, v) => !k.Value).FirstOrDefault().Key;
         UriList[uri] = true;
         var likesComplete = accountContainer.PutLikes(uri, TargetLogin, LikesCount - likesCountComplete);
         likesCountComplete += likesComplete;
         SleepWithStopFlag(1000 * 60 * 60 * 2);
     }
 }
Ejemplo n.º 14
0
        private void HandleApply(object sender, EventArgs args)
        {
            BrowsablePointer item   = view.Item;
            EditTarget       target = new EditTarget(item);

            try {
                using (ImageFile img = ImageFile.Create(item.Current.DefaultVersionUri)) {
                    Cairo.Format format = view.CompletePixbuf().HasAlpha ? Cairo.Format.Argb32 : Cairo.Format.Rgb24;

                    MemorySurface dest = new MemorySurface(format,
                                                           info.Bounds.Width,
                                                           info.Bounds.Height);

                    Context ctx = new Context(dest);
                    effect.OnExpose(ctx, info.Bounds);
                    ((IDisposable)ctx).Dispose();

                    string tmp = ImageFile.TempPath(item.Current.DefaultVersionUri.LocalPath);
                    using (Gdk.Pixbuf output = Widgets.CairoUtils.CreatePixbuf(dest)) {
                        using (System.IO.Stream stream = System.IO.File.OpenWrite(tmp)) {
                            img.Save(output, stream);
                        }
                    }

                    dest.Destroy();

                    // FIXME Not this again. I need to imlplement a real version of the transfer
                    // function that shows progress in the main window and allows for all the
                    // goodies we'll need.
                    Gnome.Vfs.Result result = Gnome.Vfs.Result.Ok;
                    result = Gnome.Vfs.Xfer.XferUri(new Gnome.Vfs.Uri(UriList.PathToFileUri(tmp).ToString()),
                                                    new Gnome.Vfs.Uri(target.Uri.ToString()),
                                                    Gnome.Vfs.XferOptions.Default,
                                                    Gnome.Vfs.XferErrorMode.Abort,
                                                    Gnome.Vfs.XferOverwriteMode.Replace,
                                                    delegate {
                        System.Console.Write(".");
                        return(1);
                    });

                    target.Commit();
                }
            } catch (System.Exception e) {
                System.Console.WriteLine(e);
                target.Delete();
                Dialog d = new EditExceptionDialog((Gtk.Window)view.Toplevel, e, view.Item.Current);
                d.Show();
                d.Run();
                d.Destroy();
            }
            Destroy();
        }
        public static bool ThumbnailIsValid(Gdk.Pixbuf thumbnail, System.Uri uri)
        {
            bool valid = false;

            try {
                Gnome.Vfs.FileInfo vfs   = new Gnome.Vfs.FileInfo(uri.ToString());
                DateTime           mtime = vfs.Mtime;
                valid = Gnome.Thumbnail.IsValid(thumbnail, UriList.UriToStringEscaped(uri), mtime);
            } catch (System.Exception e) {
                System.Console.WriteLine(e);
                valid = false;
            }

            return(valid);
        }
        private async void OnAddChannel(object obj)
        {
            await Task.Run(async() =>
            {
                string res = "";
                try
                {
                    res = InputUriChannel.Split('/').Last().Split('@').Last();
                }
                catch (Exception)
                {
                }

                try
                {
                    var id         = await _telegramLogic.JoinCannel(res);
                    _tLChannelFull = await _telegramLogic.GetFullInfoCannelsAsync();
                    _tLChannels    = await _telegramLogic.GetInfoChannelsAsync();

                    var tLChannelFullinfo = _tLChannelFull.Where(p => p.Id == id).FirstOrDefault();
                    var tLChannels        = _tLChannels.Where(p => p.Id == id).FirstOrDefault();


                    var channelsInfo = new ChannelsInfo()
                    {
                        SubscribersChannel = (int)tLChannelFullinfo.ParticipantsCount,
                        UriChannel         = tLChannels.Username,
                        NameChannel        = tLChannels.Title,
                        IdChannel          = tLChannels.Id,
                        AccessHashChannel  = (long)tLChannels.AccessHash,
                        FullUriCannel      = InputUriChannel
                    };

                    channelsInfo.AvatarChannel = tLChannelFullinfo.ChatPhoto is TLPhoto tLPhoto
                        ? DateTimeOffset.FromUnixTimeSeconds(tLPhoto.Date).DateTime
                        : new DateTime(2000, 1, 1);

                    InfoChannels.Add(_channelsService.Create(channelsInfo));
                    AddChannels addChannels = new AddChannels
                    {
                        UriChannel = InputUriChannel
                    };
                    UriList.Add(addChannels);
                }
                catch (Exception)
                { }
            });
        }
Ejemplo n.º 17
0
		protected override void OnDragDataReceived (Gdk.DragContext context,
													int x, int y,
													Gtk.SelectionData selectionData,
													uint info, uint time_)
		{
			UriList uriList = new UriList (selectionData);
			if (uriList.Count == 0) {
				Gtk.Drag.Finish (context, false, false, time_);
				return;
			}
			
			Gtk.TreePath path;
			Gtk.TreeViewDropPosition pos;
			if (GetDestRowAtPos (x, y, out path, out pos) == false) {
				Gtk.Drag.Finish (context, false, false, time_);
				return;
			}
			
			Gtk.TreeIter iter;
			if (Model.GetIter (out iter, path) == false) {
				Gtk.Drag.Finish (context, false, false, time_);
				return;
			}
			
			Notebook destNotebook = Model.GetValue (iter, 0) as Notebook;
			if (destNotebook is AllNotesNotebook) {
				Gtk.Drag.Finish (context, false, false, time_);
				return;
			}
			
			foreach (Uri uri in uriList) {
				Note note = noteManager.FindByUri (uri.ToString ());
				if (note == null)
					continue;
				
				Logger.Debug ("Dropped into notebook: {0}", note.Title);
				
				// TODO: If we ever support selecting multiple notes,
				// we may want to double-check to see if there will be
				// any notes are already inside of a notebook.  Do we
				// want to prompt the user to confirm this choice?
				NotebookManager.MoveNoteToNotebook (note, destNotebook);
			}

			Gtk.Drag.Finish (context, true, false, time_);
		}
            public void StringNames(string name)
            {
                string path       = CreateFile(name, 1024);
                string thumb_path = ThumbnailGenerator.ThumbnailPath(path);

                ThumbnailGenerator.Create(path);

                Assert.IsTrue(File.Exists(thumb_path), String.Format("Missing: {0} created from {1}", thumb_path, path));
                using (Gdk.Pixbuf thumb = new Gdk.Pixbuf(thumb_path)) {
                    Assert.IsNotNull(thumb);
                    Assert.AreEqual(thumb.GetOption(ThumbUri), UriList.PathToFileUriEscaped(path));
                    Assert.AreEqual(new Uri(thumb.GetOption(ThumbUri)), UriList.PathToFileUri(path));
                    Assert.IsTrue(ThumbnailGenerator.ThumbnailIsValid(thumb, UriList.PathToFileUri(path)));
                }

                File.Delete(path);
                File.Delete(thumb_path);
            }
Ejemplo n.º 19
0
        void DropEmailUriList(Gtk.DragDataReceivedArgs args)
        {
            string uri_string = Encoding.UTF8.GetString(args.SelectionData.Data);

            subject_list = new List <string>();

            UriList uri_list = new UriList(uri_string);

            foreach (Uri uri in uri_list)
            {
                Logger.Debug("Evolution: Dropped URI: {0}", uri.LocalPath);

                int mail_fd = Syscall.open(uri.LocalPath, OpenFlags.O_RDONLY);
                if (mail_fd == -1)
                {
                    continue;
                }

                GMime.Stream stream = new GMime.StreamFs(mail_fd);
                GMime.Parser parser = new GMime.Parser(stream);
                parser.ScanFrom = true;

                // Use GMime to read the RFC822 message bodies (in temp
                // files pointed to by a uri-list) in MBOX format, so we
                // can get subject/sender/date info.
                while (!parser.Eos())
                {
                    GMime.Message message = parser.ConstructMessage();
                    if (message == null)
                    {
                        break;
                    }

                    Logger.Debug("Evolution: Message Subject: {0}", message.Subject);
                    subject_list.Add(message.Subject);
                    message.Dispose();
                }
                ;

                parser.Dispose();
                stream.Close();
                stream.Dispose();
            }
        }
Ejemplo n.º 20
0
        void HandleDragDataReceived(object sender, DragDataReceivedArgs args)
        {
            if (args.Info == (uint)FSpot.DragDropTargets.TargetType.UriList ||
                args.Info == (uint)FSpot.DragDropTargets.TargetType.PlainText)
            {
                /*
                 * If the drop is coming from inside f-spot then we don't want to import
                 */
                if (Gtk.Drag.GetSourceWidget(args.Context) != null)
                {
                    return;
                }

                UriList list = args.SelectionData.GetUriListData();
                collection.LoadItems(list.ToArray());

                Gtk.Drag.Finish(args.Context, true, false, args.Time);
            }
        }
Ejemplo n.º 21
0
        public override object GetData(DeterministicRandom r)
        {
            if (needToAddFilesWithSearchPatterns)
            {
                UriList urisFromPathList = MakeUris(pathList);

                if (Uris == null)
                {
                    Uris = urisFromPathList;
                }
                else
                {
                    Uris.AddRange(MakeUris(pathList));
                }

                needToAddFilesWithSearchPatterns = false;
            }

            return(r.NextItem <Uri>(Uris));
        }
Ejemplo n.º 22
0
        public bool Convert(FilterRequest request)
        {
            //FIXME: make it works for uri (and use it in CDExport)
            int    i        = 1;
            string path     = destination.LocalPath;
            string filename = System.IO.Path.GetFileName(request.Source.LocalPath);
            string dest     = System.IO.Path.Combine(path, filename);

            while (System.IO.File.Exists(dest))
            {
                string numbered_name = String.Format("{0}-{1}{2}",
                                                     System.IO.Path.GetFileNameWithoutExtension(filename),
                                                     i++,
                                                     System.IO.Path.GetExtension(filename));
                dest = System.IO.Path.Combine(path, numbered_name);
            }

            System.IO.File.Copy(request.Current.LocalPath, dest);
            request.Current = UriList.PathToFileUri(dest);
            return(true);
        }
            public void BadNames(string name)
            {
                string path = CreateFile(name, 512);

                System.Uri uri = UriList.PathToFileUri(path);

                Gnome.ThumbnailFactory factory = new Gnome.ThumbnailFactory(Gnome.ThumbnailSize.Large);
                string escaped    = UriList.PathToFileUriEscaped(path);
                string large_path = Gnome.Thumbnail.PathForUri(escaped,
                                                               Gnome.ThumbnailSize.Large);

                using (Gdk.Pixbuf pixbuf = new Gdk.Pixbuf(uri.LocalPath)) {
                    factory.SaveThumbnail(pixbuf, escaped, System.DateTime.Now);

                    Assert.IsTrue(File.Exists(large_path), String.Format("Missing: {0} created from {1} as {2}", large_path, path, escaped));
                    Gdk.Pixbuf thumb = new Gdk.Pixbuf(large_path);
                    Assert.IsNotNull(thumb);
                }

                File.Delete(path);
                File.Delete(large_path);
            }
Ejemplo n.º 24
0
        void HandleDragDataReceived(object sender, DragDataReceivedArgs args)
        {
            switch (args.Info)
            {
            case 0:
            case 1:
                /*
                 * If the drop is coming from inside f-spot then we don't want to import
                 */
                if (Gtk.Drag.GetSourceWidget(args.Context) != null)
                {
                    return;
                }

                UriList list = new UriList(args.SelectionData);
                collection.LoadItems(list.ToArray());

                break;
            }

            Gtk.Drag.Finish(args.Context, true, false, args.Time);
        }
            public void UriNames(string name)
            {
                string path = CreateFile(name, 768);
                Uri    uri  = new Uri(Gnome.Vfs.Uri.GetUriFromLocalPath(path));

                string string_path = ThumbnailGenerator.ThumbnailPath(path);
                string thumb_path  = ThumbnailGenerator.ThumbnailPath(uri);

                Assert.AreEqual(thumb_path, string_path);

                ThumbnailGenerator.Create(uri);

                Assert.IsTrue(File.Exists(thumb_path), String.Format("Missing: {0} created from {1}", thumb_path, uri));
                using (Gdk.Pixbuf thumb = new Gdk.Pixbuf(thumb_path)) {
                    Assert.IsNotNull(thumb);
                    Assert.AreEqual(thumb.GetOption(ThumbUri), UriList.UriToStringEscaped(uri));
                    Assert.AreEqual(new Uri(thumb.GetOption(ThumbUri)), uri);
                    Assert.IsTrue(ThumbnailGenerator.ThumbnailIsValid(thumb, uri));
                }

                File.Delete(thumb_path);
                File.Delete(path);
            }
        public Uri TempUri(string extension)
        {
            string imgtemp;

            if (extension != null)
            {
                string temp = System.IO.Path.GetTempFileName();
                imgtemp = temp + "." + extension;
                System.IO.File.Move(temp, imgtemp);
            }
            else
            {
                imgtemp = System.IO.Path.GetTempFileName();
            }

            Uri uri = UriList.PathToFileUri(imgtemp);

            if (!temp_uris.Contains(uri))
            {
                temp_uris.Add(uri);
            }
            return(uri);
        }
Ejemplo n.º 27
0
		public SingleView (UriList list) : this (list.ToArray ())
		{
		}
Ejemplo n.º 28
0
 public void AddUri(string uri)
 {
     UriList.Add(uri, false);
 }
Ejemplo n.º 29
0
        static int Main(string [] args)
        {
            bool empty = false;
            List<string> uris = new List<string> ();
            Unix.SetProcessName (Defines.PACKAGE);

            // Options and Option parsing
            bool shutdown = false;
            bool view = false;
            bool slideshow = false;
            string import_uri = null;

            GLib.GType.Init ();
            Catalog.Init ("f-spot", Defines.LOCALE_DIR);

            FSpot.Global.PhotoDirectory = Preferences.Get<string> (Preferences.STORAGE_PATH);
            for (int i = 0; i < args.Length && !shutdown; i++) {
                switch (args [i]) {
                case "-h": case "-?": case "-help": case "--help": case "-usage":
                    Help ();
                    return 0;

                case "-shutdown": case "--shutdown":
                    Log.Information ("Shutting down existing F-Spot server...");
                    shutdown = true;
                    break;

                case "-b": case "-basedir": case "--basedir":
                    if (i+1 == args.Length || args[i+1].StartsWith ("-")) {
                        Log.Error ("f-spot: -basedir option takes one argument");
                        return 1;
                    }
                    FSpot.Global.BaseDirectory = args [++i];
                    Log.Information ("BaseDirectory is now {0}", FSpot.Global.BaseDirectory);
                    break;

                case "-p": case "-photodir": case "--photodir":
                    if (i+1 == args.Length || args[i+1].StartsWith ("-")) {
                        Log.Error ("f-spot: -photodir option takes one argument");
                        return 1;
                    }
                    FSpot.Global.PhotoDirectory = System.IO.Path.GetFullPath (args [++i]);
                    Log.Information ("PhotoDirectory is now {0}", FSpot.Global.PhotoDirectory);
                    break;

                case "-i": case "-import": case "--import":
                    if (i+1 == args.Length) {
                        Log.Error ("f-spot: -import option takes one argument");
                        return 1;
                    }
                    import_uri = args [++i];
                    break;

                case "-slideshow": case "--slideshow":
                    slideshow = true;
                    break;

                case "-v": case "-view": case "--view":
                    if (i+1 == args.Length || args[i+1].StartsWith ("-")) {
                        Log.Error ("f-spot: -view option takes (at least) one argument");
                        return 1;
                    }
                    view = true;
                    while (!(i+1 == args.Length) && !args[i+1].StartsWith ("-"))
                        uris.Add (args [++i]);
            //				if (!System.IO.Directory.Exists (args[i+1]) && !System.IO.File.Exists (args[i+1])) {
            //					Log.Error ("f-spot: -view argument must be an existing file or directory");
            //					return 1;
            //				}
                    break;

                case "-versions": case "--versions":
                    Versions ();
                    return 0;

                case "-V": case "-version": case "--version":
                    Version ();
                    return 0;

                case "--strace":
                    Log.Tracing = true;
                    break;

                case "--debug":
                    Log.Debugging = true;
                    // Debug GdkPixbuf critical warnings
                    GLib.LogFunc logFunc = new GLib.LogFunc (GLib.Log.PrintTraceLogFunction);
                    GLib.Log.SetLogHandler ("GdkPixbuf", GLib.LogLevelFlags.Critical, logFunc);

                    // Debug Gtk critical warnings
                    GLib.Log.SetLogHandler ("Gtk", GLib.LogLevelFlags.Critical, logFunc);

                    // Debug GLib critical warnings
                    GLib.Log.SetLogHandler ("GLib", GLib.LogLevelFlags.Critical, logFunc);

                    //Debug GLib-GObject critical warnings
                    GLib.Log.SetLogHandler ("GLib-GObject", GLib.LogLevelFlags.Critical, logFunc);

                    break;
                case "--uninstalled": case "--gdb": case "--valgrind": case "--sync":
                    break;
                default:
                    if (args [i].StartsWith ("--profile"))
                        break;
                    if (args [i].StartsWith ("--trace"))
                        break;
                    Log.Debug ("Unparsed argument >>{0}<<", args [i]);
                    break;
                }
            }

            // Validate command line options
            if ( (import_uri != null && (view || shutdown || slideshow)) ||
                 (view && (shutdown || slideshow)) ||
                 (shutdown && slideshow) ) {
                Log.Error ("Can't mix -import, -view, -shutdown or -slideshow");
                return 1;
            }

            //Initialize Mono.Addins
            uint timer = Log.InformationTimerStart ("Initializing Mono.Addins");
            AddinManager.Initialize (FSpot.Global.BaseDirectory);
            AddinManager.Registry.Update (null);
            SetupService setupService = new SetupService (AddinManager.Registry);
            string maj_version = String.Join (".", Defines.VERSION.Split ('.'), 0, 3);
            foreach (AddinRepository repo in setupService.Repositories.GetRepositories ())
                if (repo.Url.StartsWith ("http://addins.f-spot.org/") && !repo.Url.StartsWith ("http://addins.f-spot.org/" + maj_version)) {
                    Log.Information ("Unregistering {0}", repo.Url);
                    setupService.Repositories.RemoveRepository (repo.Url);
                }
            setupService.Repositories.RegisterRepository (null, "http://addins.f-spot.org/" + maj_version, false);
            Log.DebugTimerPrint (timer, "Mono.Addins Initialization took {0}");

            //Gtk initialization
            Gtk.Application.Init (Defines.PACKAGE, ref args);
            Gnome.Vfs.Vfs.Initialize ();

            // init web proxy globally
            Platform.WebProxy.Init ();

            if (File.Exists (Preferences.Get<string> (Preferences.GTK_RC))) {
                if (File.Exists (Path.Combine (Global.BaseDirectory, "gtkrc")))
                    Gtk.Rc.AddDefaultFile (Path.Combine (Global.BaseDirectory, "gtkrc"));

                Global.DefaultRcFiles = Gtk.Rc.DefaultFiles;
                Gtk.Rc.AddDefaultFile (Preferences.Get<string> (Preferences.GTK_RC));
                Gtk.Rc.ReparseAllForSettings (Gtk.Settings.Default, true);
            }

            try {
                Gtk.Window.DefaultIconList = new Gdk.Pixbuf [] {
                    GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 16, (Gtk.IconLookupFlags)0),
                    GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 22, (Gtk.IconLookupFlags)0),
                    GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 32, (Gtk.IconLookupFlags)0),
                    GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 48, (Gtk.IconLookupFlags)0)
                };
            } catch {}

            try {
                if (slideshow == true) {
                    App.Instance.Slideshow (null);
                } else if (shutdown) {
                    try {
                        App.Instance.Shutdown ();
                    } catch (System.Exception) { // trap errors
                    }
                    System.Environment.Exit (0);
                } else if (view) {
                    UriList list = new UriList ();
                    foreach (string s in uris)
                        list.AddUnknown (s);
                    if (list.Count == 0) {
                        Help ();
                        return 1;
                    }
                    App.Instance.View (list);
                } else if (import_uri != null) {
                    App.Instance.Import (import_uri);
                } else {
                    App.Instance.Organize ();
                }

                if (App.Instance.IsRunning)
                    return 0;
                Gtk.Application.Run ();
            } catch (System.Exception e) {
                Log.Exception (e);
                ExceptionDialog dlg = new ExceptionDialog(e);
                dlg.Run();
                dlg.Destroy();
                System.Environment.Exit(1);
            }
            return 0;
        }
Ejemplo n.º 30
0
		public void ImportUriList (UriList list, bool copy)
		{
			// Drag'n drop import.
			var controller = new ImportController (false);
			controller.StatusEvent += (evnt) => ThreadAssist.ProxyToMain (() => {
				if (evnt == ImportEvent.ImportFinished) {
					if (controller.PhotosImported > 0) {
						query.RollSet = new RollSet (Database.Rolls.GetRolls (1));
					}
				}
			});

			var source = new MultiFileImportSource (list.ToArray ());
			controller.ActiveSource = source;
			controller.CopyFiles = copy;
			controller.DuplicateDetect = true;
			controller.RecurseSubdirectories = true;
			controller.RemoveOriginals = false;

			var import_window = new ImportDialog (controller, Window);
			import_window.Show ();

			controller.StartImport ();
		}
Ejemplo n.º 31
0
        static int Main(string [] args)
        {
            bool          empty   = false;
            Program       program = null;
            ICore         control = null;
            List <string> uris    = new List <string> ();

            Unix.SetProcessName(Defines.PACKAGE);

            // Options and Option parsing
            bool   shutdown   = false;
            bool   view       = false;
            bool   slideshow  = false;
            string import_uri = null;

            program = new Program(Defines.PACKAGE,
                                  Defines.VERSION,
                                  Modules.UI, args);

            FSpot.Global.PhotoDirectory = Preferences.Get <string> (Preferences.STORAGE_PATH);

            for (int i = 0; i < args.Length && !shutdown; i++)
            {
                switch (args [i])
                {
                case "-h":
                case "-?":
                case "-help":
                case "--help":
                case "-usage":
                    Help();
                    return(0);

                case "-shutdown":
                case "--shutdown":
                    Log.Information("Shutting down existing F-Spot server...");
                    shutdown = true;
                    break;

                case "-b":
                case "-basedir":
                case "--basedir":
                    if (i + 1 == args.Length || args[i + 1].StartsWith("-"))
                    {
                        Log.Error("f-spot: -basedir option takes one argument");
                        return(1);
                    }
                    FSpot.Global.BaseDirectory = args [++i];
                    Log.InformationFormat("BaseDirectory is now {0}", FSpot.Global.BaseDirectory);
                    break;

                case "-p":
                case "-photodir":
                case "--photodir":
                    if (i + 1 == args.Length || args[i + 1].StartsWith("-"))
                    {
                        Log.Error("f-spot: -photodir option takes one argument");
                        return(1);
                    }
                    FSpot.Global.PhotoDirectory = System.IO.Path.GetFullPath(args [++i]);
                    Log.InformationFormat("PhotoDirectory is now {0}", FSpot.Global.PhotoDirectory);
                    break;

                case "-i":
                case "-import":
                case "--import":
                    if (i + 1 == args.Length)
                    {
                        Log.Error("f-spot: -import option takes one argument");
                        return(1);
                    }
                    import_uri = args [++i];
                    break;

                case "-slideshow":
                case "--slideshow":
                    slideshow = true;
                    break;

                case "-v":
                case "-view":
                case "--view":
                    if (i + 1 == args.Length || args[i + 1].StartsWith("-"))
                    {
                        Log.Error("f-spot: -view option takes (at least) one argument");
                        return(1);
                    }
                    view = true;
                    while (!(i + 1 == args.Length) && !args[i + 1].StartsWith("-"))
                    {
                        uris.Add(args [++i]);
                    }
//				if (!System.IO.Directory.Exists (args[i+1]) && !System.IO.File.Exists (args[i+1])) {
//					Log.Error ("f-spot: -view argument must be an existing file or directory");
//					return 1;
//				}
                    break;

                case "-versions":
                case "--versions":
                    Versions();
                    return(0);

                case "-V":
                case "-version":
                case "--version":
                    Version();
                    return(0);

                case "--debug":
                    Log.Debugging = true;
                    // Debug GdkPixbuf critical warnings
                    GLib.LogFunc logFunc = new GLib.LogFunc(GLib.Log.PrintTraceLogFunction);
                    GLib.Log.SetLogHandler("GdkPixbuf", GLib.LogLevelFlags.Critical, logFunc);

                    // Debug Gtk critical warnings
                    GLib.Log.SetLogHandler("Gtk", GLib.LogLevelFlags.Critical, logFunc);

                    break;

                case "--uninstalled":
                case "--gdb":
                    break;

                default:
                    if (args [i].StartsWith("--profile"))
                    {
                        break;
                    }
                    if (args [i].StartsWith("--trace"))
                    {
                        break;
                    }
                    Log.DebugFormat("Unparsed argument >>{0}<<", args [i]);
                    Help();
                    return(1);
                }
            }

            // Validate command line options
            if ((import_uri != null && (view || shutdown || slideshow)) ||
                (view && (shutdown || slideshow)) ||
                (shutdown && slideshow))
            {
                Log.Error("Can't mix -import, -view, -shutdown or -slideshow");
                return(1);
            }

            if (slideshow == true)
            {
                Catalog.Init("f-spot", Defines.LOCALE_DIR);

                Core core = new Core();
                core.ShowSlides(null);
                program.Run();
                Log.Debug("done");
                return(0);
            }

            try {
                uint timer = Log.InformationTimerStart("Initializing DBus");
                try {
                    NDesk.DBus.BusG.Init();
                } catch (Exception e) {
                    throw new ApplicationException("F-Spot cannot find the Dbus session bus.  Make sure dbus is configured properly or start a new session for f-spot using \"dbus-launch f-spot\"", e);
                }
                Log.DebugTimerPrint(timer, "DBusInitialization took {0}");
                uint ma_timer = Log.InformationTimerStart("Initializing Mono.Addins");
                AddinManager.Initialize(FSpot.Global.BaseDirectory);
                AddinManager.Registry.Update(null);
                SetupService setupService = new SetupService(AddinManager.Registry);
                string       maj_version  = String.Join(".", Defines.VERSION.Split('.'), 0, 3);
                foreach (AddinRepository repo in setupService.Repositories.GetRepositories())
                {
                    if (repo.Url.StartsWith("http://addins.f-spot.org/") && !repo.Url.StartsWith("http://addins.f-spot.org/" + maj_version))
                    {
                        Log.InformationFormat("Unregistering {0}", repo.Url);
                        setupService.Repositories.RemoveRepository(repo.Url);
                    }
                }
                setupService.Repositories.RegisterRepository(null, "http://addins.f-spot.org/" + maj_version, false);
                Log.DebugTimerPrint(ma_timer, "Mono.Addins Initialization took {0}");



                bool create      = true;
                int  retry_count = 0;
                while (control == null)
                {
                    try {
                        control = Core.FindInstance();
                        Log.InformationFormat("Found active FSpot server: {0}", control);
                        program = null;
                    } catch (System.Exception) {
                        if (!shutdown)
                        {
                            Log.Information("Starting new FSpot server");
                        }
                    }

                    Core core = null;
                    try {
                        if (control == null && create)
                        {
                            create = false;
                            Gnome.Vfs.Vfs.Initialize();

                            if (File.Exists(Preferences.Get <string> (Preferences.GTK_RC)))
                            {
#if GTK_2_12_2
                                if (!File.Exists(Path.Combine(Global.BaseDirectory, "gtkrc")))
                                {
                                    (File.Create(Path.Combine(Global.BaseDirectory, "gtkrc"))).Dispose();
                                }
                                Gtk.Rc.AddDefaultFile(Path.Combine(Global.BaseDirectory, "gtkrc"));
                                Global.DefaultRcFiles = Gtk.Rc.DefaultFiles;
#endif
                                Gtk.Rc.AddDefaultFile(Preferences.Get <string> (Preferences.GTK_RC));
                            }

                            Catalog.Init("f-spot", Defines.LOCALE_DIR);
                            try {
                                Gtk.Window.DefaultIconList = new Gdk.Pixbuf [] {
                                    GtkUtil.TryLoadIcon(FSpot.Global.IconTheme, "f-spot", 16, (Gtk.IconLookupFlags) 0),
                                    GtkUtil.TryLoadIcon(FSpot.Global.IconTheme, "f-spot", 22, (Gtk.IconLookupFlags) 0),
                                    GtkUtil.TryLoadIcon(FSpot.Global.IconTheme, "f-spot", 32, (Gtk.IconLookupFlags) 0),
                                    GtkUtil.TryLoadIcon(FSpot.Global.IconTheme, "f-spot", 48, (Gtk.IconLookupFlags) 0)
                                };
                            } catch {}

                            core = new Core(view);
                            core.RegisterServer();

                            empty   = view || Core.Database.Empty;
                            control = core;
                        }
                    } catch (System.Exception e) {
                        System.Console.WriteLine("XXXXX{1}{0}{1}XXXXX", e, Environment.NewLine);
                        control = null;

                        if (core != null)
                        {
                            core.UnregisterServer();
                        }

                        // if there is a problem with the DB, so is no way we can survive
                        if (e is DbException)
                        {
                            throw;
                        }
                    }
                    if (control == null)
                    {
                        Log.Warning("Can't get a connection to the dbus. Trying again...");
                        if (++retry_count > 5)
                        {
                            Log.Error("Sorry, couldn't start F-Spot");
                            return(1);
                        }
                    }
                }


                UriList list = new UriList();

                if (shutdown)
                {
                    try {
                        control.Shutdown();
                    } catch (System.Exception) {
                        // trap errors
                    }
                    System.Environment.Exit(0);
                }

                if (import_uri != null)
                {
                    control.Import(import_uri);
                }

                if (view)
                {
                    foreach (string s in uris)
                    {
                        list.AddUnknown(s);
                    }
                    if (list.Count == 0)
                    {
                        Help();
                        return(1);
                    }
                    control.View(list.ToString());
                }

                if (empty && import_uri == null && !view)
                {
                    control.Import(null);
                }

                if (import_uri != null || !view)
                {
                    control.Organize();
                    Gdk.Global.NotifyStartupComplete();
                    foreach (ServiceNode service in AddinManager.GetExtensionNodes("/FSpot/Services"))
                    {
                        service.Initialize();
                        service.Start();
                    }
                }

#if GSD_2_24
                Log.Information("Hack for gnome-settings-daemon engaged");
                int max_age, max_size;
                if (Preferences.TryGet <int> (Preferences.GSD_THUMBS_MAX_AGE, out max_age))
                {
                    if (max_age < 0)
                    {
                        Log.Debug("maximum_age check already disabled, good");
                    }
                    else if (max_age == 0)
                    {
                        Log.Warning("maximum_age is 0 (tin-hat mode), not overriding");
                    }
                    else if (max_age < 180)
                    {
                        Log.Debug("Setting maximum_age to a saner value");
                        Preferences.Set(Preferences.GSD_THUMBS_MAX_AGE, 180);
                    }
                }

                if (Preferences.TryGet <int> (Preferences.GSD_THUMBS_MAX_SIZE, out max_size))
                {
                    int count = Core.Database.Photos.Count("photos");
                    // average thumbs are taking 70K, so this will push the threshold
                    //if f-spot takes more than 70% of the thumbs space
                    int size = count / 10;
                    if (max_size < 0)
                    {
                        Log.Debug("maximum_size check already disabled, good");
                    }
                    else if (max_size == 0)
                    {
                        Log.Warning("maximum_size is 0 (tin-hat mode), not overriding");
                    }
                    else if (max_size < size)
                    {
                        Log.DebugFormat("Setting maximum_size to a saner value ({0}MB), according to your db size", size);
                        Preferences.Set(Preferences.GSD_THUMBS_MAX_SIZE, size);
                    }
                }
#endif
                if (program != null)
                {
                    program.Run();
                }

                Log.Information("exiting");
            } catch (System.Exception e) {
                Log.Exception(e);
                ExceptionDialog dlg = new ExceptionDialog(e);
                dlg.Run();
                dlg.Destroy();
                System.Environment.Exit(1);
            }
            return(0);
        }
Ejemplo n.º 32
0
		void HandleDragDataReceived (object sender, DragDataReceivedArgs args) 
		{
		
		switch (args.Info) {
		case 0:
		case 1:
			/* 
			 * If the drop is coming from inside f-spot then we don't want to import 
			 */
			if (Gtk.Drag.GetSourceWidget (args.Context) != null)
				return;

			UriList list = new UriList (args.SelectionData);
			collection.LoadItems (list.ToArray());

			break;
		}

		Gtk.Drag.Finish (args.Context, true, false, args.Time);
		}
Ejemplo n.º 33
0
        public static void Main(string [] args)
        {
            bool empty = false;
            Program program = null;
            ICore control = null;

            SetProcessName (Defines.PACKAGE);

            try {
            FSpotOptions options = new FSpotOptions ();
            options.ProcessArgs (args);

            if (!options.Validate ()) {
                options.DoHelp ();
                return;
            }

            if (options.basedir != null) {
                FSpot.Global.BaseDirectory = options.basedir;
                System.Console.WriteLine("BaseDirectory is now {0}", FSpot.Global.BaseDirectory);
            }

            if (options.photodir != null) {
                FSpot.Global.PhotoDirectory = System.IO.Path.GetFullPath(options.photodir);
                System.Console.WriteLine("PhotoDirectory is now {0}", FSpot.Global.PhotoDirectory);
            }

            if (options.slideshow) {
                Catalog.Init ("f-spot", Defines.LOCALE_DIR);

                program = new Program (Defines.PACKAGE,
                               Defines.VERSION,
                               Modules.UI, args);
                Core core = new Core ();
                core.ShowSlides (null);
                program.Run ();
                System.Console.WriteLine ("done");
                return;
            }

            try {
                NDesk.DBus.BusG.Init();
            } catch (Exception e) {
                throw new ApplicationException ("F-Spot cannot find the Dbus session bus.  Make sure dbus is configured properly or start a new session for f-spot using \"dbus-launch f-spot\"", e);
            }
            /*
             * FIXME we need to inialize gobject before making the dbus calls, we'll go
             * ahead and do it like this for now.
             */
            program = new Program (Defines.PACKAGE,
                           Defines.VERSION,
                           Modules.UI, args);

            Console.WriteLine ("Initializing Mono.Addins");
            Mono.Addins.AddinManager.Initialize (FSpot.Global.BaseDirectory);
            Mono.Addins.AddinManager.Registry.Update (null);

            bool create = true;
            while (control == null) {
                try {
                    control = Core.FindInstance ();
                    System.Console.WriteLine ("Found active FSpot server: {0}", control);
                    program = null;
                } catch (System.Exception) {
                    if (!options.shutdown)
                        System.Console.WriteLine ("Starting new FSpot server");
                }

                Core core = null;
                try {
                    if (control == null && create) {
                        create = false;
                        Gnome.Vfs.Vfs.Initialize ();
                        StockIcons.Initialize ();

                        Catalog.Init ("f-spot", Defines.LOCALE_DIR);
                        Gtk.Window.DefaultIconList = new Gdk.Pixbuf [] {PixbufUtils.LoadFromAssembly ("f-spot-16.png"),
                                                PixbufUtils.LoadFromAssembly ("f-spot-22.png"),
                                                PixbufUtils.LoadFromAssembly ("f-spot-32.png"),
                                                PixbufUtils.LoadFromAssembly ("f-spot-48.png")};
                        core = new Core (options.view);
                        core.RegisterServer ();

                        // FIXME: Error checking is non-existant here...

                        empty = options.view || Core.Database.Empty;
                        control = core;
                    }
                } catch (System.Exception e) {
                    System.Console.WriteLine ("XXXXX{1}{0}{1}XXXXX", e, Environment.NewLine);
                    control = null;

                    if (core != null)
                        core.UnregisterServer ();
                }
                if (control == null)
                    System.Console.WriteLine ("Can't get a connection to the dbus. Trying again...");
            }

            UriList list = new UriList ();

            if (options.shutdown) {
                try {
                    control.Shutdown ();
                } catch (System.Exception) {
                    // trap errors
                }
                System.Environment.Exit (0);
            }

            if (options.import != null) {
                control.Import (options.import);
            }

            if (options.view) {
                foreach (string s in options.Uris)
                    list.AddUnknown (s);
                if (list.Count > 0)
                    control.View (list.ToString ());
            }

            if (empty && options.import == null && !options.view)
                control.Import (null);

            if (options.import != null || !options.view) {
                control.Organize ();
                Gdk.Global.NotifyStartupComplete ();
            }

            if (program != null)
                program.Run ();

            System.Console.WriteLine ("exiting");
            } catch (System.Exception e) {
            Console.Error.WriteLine(e);
            Gtk.Application.Init();
            ExceptionDialog dlg = new ExceptionDialog(e);
            dlg.Run();
            dlg.Destroy();
            System.Environment.Exit(1);
            }
        }
        void HandleDrops(int xx, int yy)
        {
            UriList uri_list = new UriList(uri_list_string);
            string [] cm_path_list = cm_path_string.Split('\n');

            uri_list_string = null;
            cm_path_string = null;

            if(uri_list.Count != (cm_path_list.Length-1)) {
                Logger.Error("Error parsing drop input");
                return;
            }

            string cm_path_folderitem = cm_path_list[0];
            bool first = true;
            for(int ii = 1; ii < cm_path_list.Length; ii++) {
                Uri uri = uri_list[ii-1];
                string msgid = cm_path_list[ii];
                HandleDrop(xx, yy, first, uri, cm_path_folderitem, msgid);
                first = false;
            }
        }
Ejemplo n.º 35
0
		public void HandleCopy (object sender, EventArgs args)
		{
			Clipboard primary = Clipboard.Get (Atom.Intern ("PRIMARY", false));
			Clipboard clipboard = Clipboard.Get (Atom.Intern ("CLIPBOARD", false));

			if (Window.Focus is Editable) {
				(Window.Focus as Editable).CopyClipboard ();
				return;
			}

			TargetList targetList = new TargetList ();
			targetList.AddTextTargets ((uint)DragDropTargets.TargetType.PlainText);
			targetList.AddUriTargets ((uint)DragDropTargets.TargetType.UriList);
			targetList.Add (
				DragDropTargets.CopyFilesEntry.Target,
				(uint)DragDropTargets.CopyFilesEntry.Flags,
				(uint)DragDropTargets.CopyFilesEntry.Info);

			// use eager evaluation, because we want to copy the photos which are currently selected ...
			var uris = new UriList (from p in SelectedPhotos ()
			                                 select p.DefaultVersion.Uri);
			var paths = String.Join (" ",
				                     (from p in SelectedPhotos ()
				                                  select p.DefaultVersion.Uri.LocalPath).ToArray ()
			                     );

			clipboard.SetWithData ((TargetEntry[])targetList, delegate (Clipboard clip, SelectionData data, uint info) {

				if (info == (uint)DragDropTargets.TargetType.PlainText) {
					data.Text = paths;
					return;
				}

				if (info == (uint)DragDropTargets.TargetType.UriList) {
					data.SetUriListData (uris);
					return;
				}

				if (info == DragDropTargets.CopyFilesEntry.Info) {
					data.SetCopyFiles (uris);
					return;
				}

				Log.DebugFormat ("Unknown Selection Data Target (info: {0})", info);
			}, delegate {
			});

			primary.Text = paths;
		}
Ejemplo n.º 36
0
		public void Viewbla (UriList list)
		{
			try {
				Register (new FSpot.SingleView (list).Window);
			} catch (System.Exception e) {
				System.Console.WriteLine (e.ToString ());
				System.Console.WriteLine ("no real valid path to view from {0}", list);
			} 
		}
Ejemplo n.º 37
0
		//
		// DND Drop handling
		//
		protected override void OnDragDataReceived (Gdk.DragContext context,
		                int x,
		                int y,
		                Gtk.SelectionData selection_data,
		                uint info,
		                uint time)
		{
			bool has_url = false;

			foreach (Gdk.Atom target in context.ListTargets()) {
				if (target.Name == "text/uri-list" ||
				                target.Name == "_NETSCAPE_URL") {
					has_url = true;
					break;
				}
			}

			if (has_url) {
				UriList uri_list = new UriList (selection_data);
				bool more_than_one = false;

				// Place the cursor in the position where the uri was
				// dropped, adjusting x,y by the TextView's VisibleRect.
				Gdk.Rectangle rect = VisibleRect;
				int adjustedX = x + rect.X;
				int adjustedY = y + rect.Y;
				Gtk.TextIter cursor = GetIterAtLocation (adjustedX, adjustedY);
				Buffer.PlaceCursor (cursor);

				Gtk.TextTag link_tag = Buffer.TagTable.Lookup ("link:url");

				foreach (Uri uri in uri_list) {
					Logger.Debug ("Got Dropped URI: {0}", uri);
					string insert;
					if (uri.IsFile) {
						// URL-escape the path in case
						// there are spaces (bug #303902)
						insert = System.Uri.EscapeUriString (uri.LocalPath);
					} else {
						insert = uri.ToString ();
					}

					if (insert == null || insert.Trim () == String.Empty)
						continue;

					if (more_than_one) {
						cursor = Buffer.GetIterAtMark (Buffer.InsertMark);

						// FIXME: The space here is a hack
						// around a bug in the URL Regex which
						// matches across newlines.
						if (cursor.LineOffset == 0)
							Buffer.Insert (ref cursor, " \n");
						else
							Buffer.Insert (ref cursor, ", ");
					}

					Buffer.InsertWithTags (ref cursor, insert, link_tag);
					more_than_one = true;
				}

				Gtk.Drag.Finish (context, more_than_one, false, time);
			} else {
				base.OnDragDataReceived (context, x, y, selection_data, info, time);
			}
		}
Ejemplo n.º 38
0
Archivo: main.cs Proyecto: hbons/f-spot
        static void Startup()
        {
            if (ApplicationContext.CommandLine.Contains ("slideshow"))
                App.Instance.Slideshow (null);
            else if (ApplicationContext.CommandLine.Contains ("shutdown"))
                App.Instance.Shutdown ();
            else if (ApplicationContext.CommandLine.Contains ("view")) {
                if (ApplicationContext.CommandLine.Files.Count == 0) {
                    Log.Error ("f-spot: -view option takes at least one argument");
                    System.Environment.Exit (1);
                }

                var list = new UriList ();

                foreach (var f in ApplicationContext.CommandLine.Files)
                    list.AddUnknown (f);

                if (list.Count == 0) {
                    ShowHelp ();
                    System.Environment.Exit (1);
                }

                App.Instance.View (list);
            } else if (ApplicationContext.CommandLine.Contains ("import")) {
                string dir = ApplicationContext.CommandLine ["import"];

                if (string.IsNullOrEmpty (dir)) {
                    Log.Error ("f-spot: -import option takes one argument");
                    System.Environment.Exit (1);
                }

                App.Instance.Import (dir);
            } else
                App.Instance.Organize ();

            if (!App.Instance.IsRunning)
                Gtk.Application.Run ();
        }
Ejemplo n.º 39
0
 static public Gdk.Pixbuf ValidateThumbnail(string photo_path, Gdk.Pixbuf pixbuf)
 {
     System.Uri uri = UriList.PathToFileUri(photo_path);
     return(ValidateThumbnail(uri, pixbuf));
 }
        public static void SetUriListData(this SelectionData selection_data, UriList uri_list, Atom target)
        {
            Byte [] data = Encoding.UTF8.GetBytes (uri_list.ToString ());

            selection_data.Set (target, 8, data, data.Length);
        }
Ejemplo n.º 41
0
	static int Main (string [] args)
	{
		bool empty = false;
		Program program = null;
		ICore control = null;
		List<string> uris = new List<string> ();
		Unix.SetProcessName (Defines.PACKAGE);

		// Options and Option parsing
		bool shutdown = false;
		bool view = false;
		bool slideshow = false;
		string import_uri = null;
		
		program = new Program (Defines.PACKAGE, 
				       Defines.VERSION, 
				       Modules.UI, args);		
		
		FSpot.Global.PhotoDirectory = Preferences.Get<string> (Preferences.STORAGE_PATH);

		for (int i = 0; i < args.Length && !shutdown; i++) {
			switch (args [i]) {
			case "-h": case "-?": case "-help": case "--help": case "-usage":
				Help ();
				return 0;
			
			case "-shutdown": case "--shutdown":
				Log.Information ("Shutting down existing F-Spot server...");
				shutdown = true;
				break;

			case "-b": case "-basedir": case "--basedir":
				if (i+1 == args.Length || args[i+1].StartsWith ("-")) {
					Log.Error ("f-spot: -basedir option takes one argument");
					return 1;
				}
				FSpot.Global.BaseDirectory = args [++i];
				Log.InformationFormat ("BaseDirectory is now {0}", FSpot.Global.BaseDirectory);
				break;

			case "-p": case "-photodir": case "--photodir":
				if (i+1 == args.Length || args[i+1].StartsWith ("-")) {
					Log.Error ("f-spot: -photodir option takes one argument");
					return 1;
				}
				FSpot.Global.PhotoDirectory = System.IO.Path.GetFullPath (args [++i]);
				Log.InformationFormat ("PhotoDirectory is now {0}", FSpot.Global.PhotoDirectory);
				break;

			case "-i": case "-import": case "--import":
				if (i+1 == args.Length) {
					Log.Error ("f-spot: -import option takes one argument");
					return 1;
				}
				import_uri = args [++i];
				break;
			
			case "-slideshow": case "--slideshow":
				slideshow = true;
				break;

			case "-v": case "-view": case "--view":
				if (i+1 == args.Length || args[i+1].StartsWith ("-")) {
					Log.Error ("f-spot: -view option takes (at least) one argument");
					return 1;
				}
				view = true;
				while (!(i+1 == args.Length) && !args[i+1].StartsWith ("-"))
					uris.Add (args [++i]);
//				if (!System.IO.Directory.Exists (args[i+1]) && !System.IO.File.Exists (args[i+1])) {
//					Log.Error ("f-spot: -view argument must be an existing file or directory");
//					return 1;
//				}
				break;

			case "-versions": case "--versions":
				Versions ();
				return 0;
			
			case "-V": case "-version": case "--version":
				Version ();
				return 0;
			
			case "--debug":
				Log.Debugging = true;
				// Debug GdkPixbuf critical warnings
				GLib.LogFunc logFunc = new GLib.LogFunc (GLib.Log.PrintTraceLogFunction);
				GLib.Log.SetLogHandler ("GdkPixbuf", GLib.LogLevelFlags.Critical, logFunc);
		
				// Debug Gtk critical warnings
				GLib.Log.SetLogHandler ("Gtk", GLib.LogLevelFlags.Critical, logFunc);

				break;
			case "--uninstalled": case "--gdb":
				break;
			default:
				if (args [i].StartsWith ("--profile"))
					break;
				if (args [i].StartsWith ("--trace"))
					break;
				Log.DebugFormat ("Unparsed argument >>{0}<<", args [i]);
				Help ();
				return 1;
			}
		}

		// Validate command line options
		if ( (import_uri != null && (view || shutdown || slideshow)) || 
		     (view && (shutdown || slideshow)) ||
		     (shutdown && slideshow) ) {
			Log.Error ("Can't mix -import, -view, -shutdown or -slideshow");
			return 1;
		}

		if (slideshow == true) {
			Catalog.Init ("f-spot", Defines.LOCALE_DIR);
				
			Core core = new Core ();
			core.ShowSlides (null);
			program.Run ();
			Log.Debug ("done");
			return 0;
		}
		
		try {

			uint timer = Log.InformationTimerStart ("Initializing DBus");
			try {
				NDesk.DBus.BusG.Init();
			} catch (Exception e) {
				throw new ApplicationException ("F-Spot cannot find the Dbus session bus.  Make sure dbus is configured properly or start a new session for f-spot using \"dbus-launch f-spot\"", e);
			}
			Log.DebugTimerPrint (timer, "DBusInitialization took {0}");
			uint ma_timer = Log.InformationTimerStart ("Initializing Mono.Addins");
			AddinManager.Initialize (FSpot.Global.BaseDirectory);
			AddinManager.Registry.Update (null);
			SetupService setupService = new SetupService (AddinManager.Registry);
			string maj_version = String.Join (".", Defines.VERSION.Split ('.'), 0, 3);
			foreach (AddinRepository repo in setupService.Repositories.GetRepositories ())
				if (repo.Url.StartsWith ("http://addins.f-spot.org/") && !repo.Url.StartsWith ("http://addins.f-spot.org/" + maj_version)) {
					Log.InformationFormat ("Unregistering {0}", repo.Url);
					setupService.Repositories.RemoveRepository (repo.Url);
				}
			setupService.Repositories.RegisterRepository (null, "http://addins.f-spot.org/" + maj_version, false);
			Log.DebugTimerPrint (ma_timer, "Mono.Addins Initialization took {0}");
			
		

			bool create = true;
			int retry_count = 0;
			while (control == null) {
				try {
					control = Core.FindInstance ();
					Log.InformationFormat ("Found active FSpot server: {0}", control);
					program = null;
				} catch (System.Exception) { 
					if (!shutdown)
						Log.Information ("Starting new FSpot server");
				}
				
				Core core = null;
				try {
					if (control == null && create) {
						create = false;
						Gnome.Vfs.Vfs.Initialize ();

						if (File.Exists (Preferences.Get<string> (Preferences.GTK_RC))) {
#if GTK_2_12_2
							if (!File.Exists (Path.Combine (Global.BaseDirectory, "gtkrc")))
								(File.Create (Path.Combine (Global.BaseDirectory, "gtkrc"))).Dispose ();
							Gtk.Rc.AddDefaultFile (Path.Combine (Global.BaseDirectory, "gtkrc"));
							Global.DefaultRcFiles = Gtk.Rc.DefaultFiles;
#endif
							Gtk.Rc.AddDefaultFile (Preferences.Get<string> (Preferences.GTK_RC));
						}
						
						Catalog.Init ("f-spot", Defines.LOCALE_DIR);
						try {
							Gtk.Window.DefaultIconList = new Gdk.Pixbuf [] {
								GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 16, (Gtk.IconLookupFlags)0),
								GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 22, (Gtk.IconLookupFlags)0),
								GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 32, (Gtk.IconLookupFlags)0),
								GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 48, (Gtk.IconLookupFlags)0)
							};
						} catch {}

						core = new Core (view);
						core.RegisterServer ();

						empty = view || Core.Database.Empty;
						control = core;
					}
				} catch (System.Exception e) {
					System.Console.WriteLine ("XXXXX{1}{0}{1}XXXXX", e, Environment.NewLine);
					control = null;

					if (core != null)
						core.UnregisterServer ();

					// if there is a problem with the DB, so is no way we can survive
					if (e is DbException) {
						throw;
					}
				}
				if (control == null) {
					Log.Warning ("Can't get a connection to the dbus. Trying again...");
					if (++ retry_count > 5) {
						Log.Error ("Sorry, couldn't start F-Spot");
						return 1;
					}
				}
			}
			
			
			UriList list = new UriList ();

			if (shutdown) {
				try {
					control.Shutdown ();
				} catch (System.Exception) {
					// trap errors
				}
				System.Environment.Exit (0);
			}

			if (import_uri != null) {
				control.Import (import_uri);
			}

			if (view) {
				foreach (string s in uris)
					list.AddUnknown (s);
				if (list.Count == 0) {
					Help ();
					return 1;
				}
				control.View (list.ToString ());
			}
			
			if (empty && import_uri == null && !view)
				control.Import (null);
			
			if (import_uri != null || !view) {
				control.Organize ();
				Gdk.Global.NotifyStartupComplete ();
				foreach (ServiceNode service in AddinManager.GetExtensionNodes ("/FSpot/Services")) {
					service.Initialize ();
					service.Start ();
				}
			}			

#if GSD_2_24
			Log.Information ("Hack for gnome-settings-daemon engaged");
			int max_age, max_size;
			if (Preferences.TryGet<int> (Preferences.GSD_THUMBS_MAX_AGE, out max_age)) {
				if (max_age < 0)
					Log.Debug ("maximum_age check already disabled, good");
				else if (max_age == 0)
					Log.Warning ("maximum_age is 0 (tin-hat mode), not overriding");
				else if (max_age < 180) {
					Log.Debug ("Setting maximum_age to a saner value");
					Preferences.Set (Preferences.GSD_THUMBS_MAX_AGE, 180);
				}
			}

			if (Preferences.TryGet<int> (Preferences.GSD_THUMBS_MAX_SIZE, out max_size)) {
				int count = Core.Database.Photos.Count ("photos");
				// average thumbs are taking 70K, so this will push the threshold
				//if f-spot takes more than 70% of the thumbs space
				int size = count / 10;
				if (max_size < 0)
					Log.Debug ("maximum_size check already disabled, good");
				else if (max_size == 0)
					Log.Warning ("maximum_size is 0 (tin-hat mode), not overriding");
				else if (max_size < size) {
					Log.DebugFormat ("Setting maximum_size to a saner value ({0}MB), according to your db size", size);
					Preferences.Set (Preferences.GSD_THUMBS_MAX_SIZE, size);
				}
			}

#endif
			if (program != null)
				program.Run ();
			
			Log.Information ("exiting");
		} catch (System.Exception e) {
			Log.Exception (e);
			ExceptionDialog dlg = new ExceptionDialog(e);
			dlg.Run();
			dlg.Destroy();
			System.Environment.Exit(1);
		}
		return 0;
	}
 public FilterRequest(string path) : this(UriList.PathToFileUri(path))
 {
 }
Ejemplo n.º 43
0
	public void HandleTagSelectionDragDataReceived (object o, DragDataReceivedArgs args)
	{
		Tag [] tags = new Tag [1];

		//FIXME this is a lame api, we need to fix the drop behaviour of these things
		tags [0] = tag_selection_widget.TagAtPosition(args.X, args.Y);

		if (tags [0] == null)
			return;

		switch (args.Info) {
		case (uint)TargetType.PhotoList:
			db.BeginTransaction ();
			foreach (int num in SelectedIds ()) {
				AddTagExtended (num, tags);
			}
			db.CommitTransaction ();
			query_widget.PhotoTagsChanged (tags);
			break;
		case (uint)TargetType.UriList:
			UriList list = new UriList (args.SelectionData);
			
			db.BeginTransaction ();
			foreach (string path in list.ToLocalPaths ()) {
				Photo photo = db.Photos.GetByPath (path);
				
				// FIXME - at this point we should import the photo, and then continue
				if (photo == null)
					continue;
				
				// FIXME this should really follow the AddTagsExtended path too
				photo.AddTag (tags);
			}
			db.CommitTransaction ();
			InvalidateViews ();
			break;
		case (uint)TargetType.TagList:
			if (tag_selection_widget.TagHighlight.Length < 1)
				return;

			Tag child = tag_selection_widget.TagHighlight [0];
			Tag parent = tags[0];

			// FIXME with this reparenting via dnd, you cannot move a tag to root.
			if (child != parent && !child.IsAncestorOf(parent) && child.Category != parent && parent is Category)
			{
				child.Category = parent as Category;

				// Saving changes will automatically cause the TreeView to be updated
				db.Tags.Commit (child);
				
				args.RetVal = true;
			} else {
				args.RetVal = false;
			}

			break;
		}

	}
Ejemplo n.º 44
0
	void HandleTagSelectionDragDataGet (object sender, DragDataGetArgs args)
	{		
		UriList list = new UriList (SelectedPhotos ());

		switch (args.Info) {
		case (uint) TargetType.TagList:
			Byte [] data = Encoding.UTF8.GetBytes (list.ToString ());
			Atom [] targets = args.Context.Targets;
			
			args.SelectionData.Set (targets[0], 8, data, data.Length);
			break;
		}
	}
Ejemplo n.º 45
0
		// Pop up Start Here and insert dropped links, in the form:
		// Wednesday, December 8, 6:45 AM
		// http://luna/kwiki/index.cgi?AdelaideUniThoughts
		// http://www.beatniksoftware.com/blog/
		// And select the inserted text.
		//
		// FIXME: Make undoable, make sure our date-sizing tag never "bleeds".
		//
		void OnDragDataReceived (object sender, Gtk.DragDataReceivedArgs args)
		{
			UriList uri_list = new UriList (args.SelectionData);
			if (uri_list.Count == 0)
				return;

			StringBuilder insert_text = new StringBuilder ();
			bool more_than_one = false;

			foreach (Uri uri in uri_list) {
				if (more_than_one)
					insert_text.Append ("\n");

				if (uri.IsFile)
					insert_text.Append (uri.LocalPath);
				else
					insert_text.Append (uri.ToString ());

				more_than_one = true;
			}

			manager.GtkInvoke (() => {
				Note link_note = manager.FindByUri (NoteManager.StartNoteUri);
				if (link_note != null) {
					link_note.Window.Present ();
					PrependTimestampedText (link_note,
					                        DateTime.Now,
					                        insert_text.ToString ());
				}
			});
		}
Ejemplo n.º 46
0
        public void HandleDragDataReceived(object o, DragDataReceivedArgs args)
        {
            TreePath             path;
            TreeViewDropPosition position;

            if (!GetDestRowAtPos((int)args.X, (int)args.Y, out path, out position))
            {
                return;
            }

            Tag tag = path == null ? null : TagByPath(path);

            if (tag == null)
            {
                return;
            }

            if (args.Info == DragDropTargets.PhotoListEntry.Info)
            {
                database.BeginTransaction();

                Photo[] photos = args.SelectionData.GetPhotosData();

                foreach (Photo photo in photos)
                {
                    if (photo == null)
                    {
                        continue;
                    }

                    photo.AddTag(tag);
                    database.Photos.Commit(photo);

                    // FIXME: AddTagExtendes from Mainwindow.cs does some tag-icon handling.
                    // this should be done here or completely located to the Tag-class.
                }
                database.CommitTransaction();

                // FIXME: this needs to be done somewhere:
                //query_widget.PhotoTagsChanged (new Tag[] {tag});
                return;
            }

            if (args.Info == (uint)DragDropTargets.TargetType.UriList)
            {
                UriList list = args.SelectionData.GetUriListData();

                database.BeginTransaction();
                List <Photo> photos = new List <Photo> ();
                foreach (var photo_uri in list)
                {
                    Photo photo = database.Photos.GetByUri(photo_uri);

                    // FIXME - at this point we should import the photo, and then continue
                    if (photo == null)
                    {
                        continue;
                    }

                    // FIXME this should really follow the AddTagsExtended path too
                    photo.AddTag(new Tag[] { tag });
                    photos.Add(photo);
                }
                database.Photos.Commit(photos.ToArray());
                database.CommitTransaction();

                // FIXME: this need to be done
                //InvalidateViews (); // but it seems not to be needed. tags are updated through in IconView through PhotoChanged
                return;
            }

            if (args.Info == DragDropTargets.TagListEntry.Info)
            {
                Category parent;
                if (position == TreeViewDropPosition.Before || position == TreeViewDropPosition.After)
                {
                    parent = tag.Category;
                }
                else
                {
                    parent = tag as Category;
                }

                if (parent == null || TagHighlight.Length < 1)
                {
                    args.RetVal = false;
                    return;
                }

                int    moved_count      = 0;
                Tag [] highlighted_tags = TagHighlight;
                foreach (Tag child in TagHighlight)
                {
                    // FIXME with this reparenting via dnd, you cannot move a tag to root.
                    if (child != parent && child.Category != parent && !child.IsAncestorOf(parent))
                    {
                        child.Category = parent;

                        // Saving changes will automatically cause the TreeView to be updated
                        database.Tags.Commit(child);
                        moved_count++;
                    }
                }

                // Reselect the same tags
                TagHighlight = highlighted_tags;

                args.RetVal = moved_count > 0;
            }
        }
Ejemplo n.º 47
0
	public void HandleTagSelectionDragDataReceived (object o, DragDataReceivedArgs args)
	{
        TreePath path;
        TreeViewDropPosition position;
        if (!tag_selection_widget.GetDestRowAtPos((int)args.X, (int)args.Y, out path, out position))
            return;

        Tag tag = path == null ? null : tag_selection_widget.TagByPath (path);
		if (tag == null)
			return;

		switch (args.Info) {
		case (uint)TargetType.PhotoList:
			db.BeginTransaction ();
			AddTagExtended (SelectedIds (), new Tag[] {tag});
			db.CommitTransaction ();
			query_widget.PhotoTagsChanged (new Tag[] {tag});
			break;
		case (uint)TargetType.UriList:
			UriList list = new UriList (args.SelectionData);
			
			db.BeginTransaction ();
			List<Photo> photos = new List<Photo> ();
			foreach (Uri photo_uri in list) {
				Photo photo = db.Photos.GetByUri (photo_uri);
				
				// FIXME - at this point we should import the photo, and then continue
				if (photo == null)
					continue;
				
				// FIXME this should really follow the AddTagsExtended path too
				photo.AddTag (new Tag[] {tag});
				photos.Add (photo);
			}
			db.Photos.Commit (photos.ToArray ());
			db.CommitTransaction ();
			InvalidateViews ();
			break;
		case (uint)TargetType.TagList:
			Category parent;
            if (position == TreeViewDropPosition.Before || position == TreeViewDropPosition.After) {
                parent = tag.Category;
            } else {
                parent = tag as Category;
            }

			if (parent == null || tag_selection_widget.TagHighlight.Length < 1) {
                args.RetVal = false;
				return;
            }

            int moved_count = 0;
            Tag [] highlighted_tags = tag_selection_widget.TagHighlight;
			foreach (Tag child in tag_selection_widget.TagHighlight) {
                // FIXME with this reparenting via dnd, you cannot move a tag to root.
                if (child != parent && child.Category != parent && !child.IsAncestorOf(parent)) {
                    child.Category = parent as Category;

                    // Saving changes will automatically cause the TreeView to be updated
                    db.Tags.Commit (child);
                    moved_count++;
                }
            }

            // Reselect the same tags
            tag_selection_widget.TagHighlight = highlighted_tags;

            args.RetVal = moved_count > 0;
			break;
		}
	}
        public static void SetCopyFiles(this SelectionData selection_data, UriList uri_list)
        {
            var uris = (from p in uri_list select p.ToString ()).ToArray ();
            var data = Encoding.UTF8.GetBytes ("copy\n" + String.Join ("\n", uris));

            selection_data.Set (Atom.Intern ("x-special/gnome-copied-files", true), 8, data, data.Length);
        }
Ejemplo n.º 49
0
	void HandleIconViewDragDataGet (object sender, DragDataGetArgs args)
	{		
		switch (args.Info) {
		case (uint) TargetType.UriList:
		case (uint) TargetType.PhotoList:
			UriList list = new UriList (SelectedPhotos ());
			Byte [] data = Encoding.UTF8.GetBytes (list.ToString ());
			Atom [] targets = args.Context.Targets;
			args.SelectionData.Set (targets[0], 8, data, data.Length);
			break;
		case (uint) TargetType.RootWindow:
			HandleSetAsBackgroundCommand (null, null);
                        break;
		}
		       
	}
 public static void SetUriListData(this SelectionData selection_data, UriList uri_list)
 {
     selection_data.SetUriListData (uri_list, Atom.Intern ("text/uri-list", true));
 }
Ejemplo n.º 51
0
	public void ImportUriList (UriList list, bool copy) 
	{
		ImportCommand command = new ImportCommand (main_window);
		if (command.ImportFromPaths (db.Photos, list.ToLocalPaths (), copy) > 0) {
			query.RollSet = new RollSet (db.Rolls.GetRolls (1)[0]);
			UpdateQuery ();
		}
	}
Ejemplo n.º 52
0
		void DropEmailUriList (Gtk.DragDataReceivedArgs args)
		{
			string uri_string = Encoding.UTF8.GetString (args.SelectionData.Data);

			subject_list = new List<string>();

			UriList uri_list = new UriList (uri_string);
			foreach (Uri uri in uri_list) {
				Logger.Debug ("Evolution: Dropped URI: {0}", uri.LocalPath);

				int mail_fd = Syscall.open (uri.LocalPath, OpenFlags.O_RDONLY);
				if (mail_fd == -1)
					continue;

				GMime.Stream stream = new GMime.StreamFs (mail_fd);
				GMime.Parser parser = new GMime.Parser (stream);
				parser.ScanFrom = true;

				// Use GMime to read the RFC822 message bodies (in temp
				// files pointed to by a uri-list) in MBOX format, so we
				// can get subject/sender/date info.
				while (!parser.Eos()) {
					GMime.Message message = parser.ConstructMessage ();
					if (message == null)
						break;
					
					Logger.Debug ("Evolution: Message Subject: {0}", message.Subject);
					subject_list.Add (message.Subject);
					message.Dispose ();
				};

				parser.Dispose ();
				stream.Close ();
				stream.Dispose ();
			}
		}
Ejemplo n.º 53
0
	void HandleIconViewDragDataReceived (object sender, DragDataReceivedArgs args)
	{
	 	Widget source = Gtk.Drag.GetSourceWidget (args.Context);     
		
		switch (args.Info) {
		case (uint)TargetType.TagList:
			//
			// Translate the event args from viewport space to window space,
			// drag events use the viewport.  Owen sends his regrets.
			//
			int item = icon_view.CellAtPosition (args.X + (int) icon_view.Hadjustment.Value, 
							     args.Y + (int) icon_view.Vadjustment.Value);

			//Console.WriteLine ("Drop cell = {0} ({1},{2})", item, args.X, args.Y);
			if (item >= 0) {
				if (icon_view.Selection.Contains (item))
					AttachTags (tag_selection_widget.TagHighlight, SelectedIds());
				else 
					AttachTags (tag_selection_widget.TagHighlight, new int [] {item});
			}
			break;
		case (uint)TargetType.UriList:

			/* 
			 * If the drop is coming from inside f-spot then we don't want to import 
			 */
			if (source != null)
				return;

			UriList list = new UriList (args.SelectionData);
			ImportUriList (list, (args.Context.Action & Gdk.DragAction.Copy) != 0);
			break;
#if ENABLE_REPARENTING
		case (uint)TargetType.PhotoList:
			int p_item = icon_view.CellAtPosition (args.X + (int) icon_view.Hadjustment.Value, 
							     args.Y + (int) icon_view.Vadjustment.Value);

			if (p_item >= 0)
			{
				PhotoVersionCommands.Reparent cmd = new PhotoVersionCommands.Reparent ();
				
				cmd.Execute (db.Photos, SelectedPhotos(), query.Photos [p_item], GetToplevel (null));
				UpdateQuery ();
			}
	
			break;
#endif
		}

		Gtk.Drag.Finish (args.Context, true, false, args.Time);
	}