示例#1
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_);
        }
示例#2
0
		private static void AddRecentNotes (ICustomDestinationList custom_destinationd_list, NoteManager note_manager, uint slots)
		{
			IObjectCollection object_collection =
			    (IObjectCollection) Activator.CreateInstance (Type.GetTypeFromCLSID (CLSID.EnumerableObjectCollection));

			// Prevent template notes from appearing in the menu
			Tag template_tag = TagManager.GetOrCreateSystemTag (TagManager.TemplateNoteSystemTag);

			uint index = 0;
			foreach (Note note in note_manager.Notes) {
				if (note.IsSpecial)
					continue;

				// Skip template notes
				if (note.ContainsTag (template_tag))
					continue;

				string note_title = note.Title;
				if (note.IsNew) {
					note_title = String.Format (Catalog.GetString ("{0} (new)"), note_title);
				}

				IShellLink note_link = CreateShellLink (note_title, tomboy_path, "--open-note " + note.Uri,
				                                        System.IO.Path.Combine (icons_path, NoteIcon), -1);
				if (note_link != null)
					object_collection.AddObject (note_link);

				if (++index == slots - 1)
					break;
			}

			// Add Start Here note
			Note start_note = note_manager.FindByUri (NoteManager.StartNoteUri);
			if (start_note != null) {
				IShellLink start_note_link = CreateShellLink (start_note.Title, tomboy_path, "--open-note " +
				                                              NoteManager.StartNoteUri,
				                                              System.IO.Path.Combine (icons_path, NoteIcon), -1);
				if (start_note_link != null)
					object_collection.AddObject (start_note_link);
			}

			custom_destinationd_list.AppendCategory (Catalog.GetString ("Recent Notes"), (IObjectArray) object_collection);

			Marshal.ReleaseComObject (object_collection);
			object_collection = null;
		}