Ejemplo n.º 1
0
        /// <summary>
        /// Finds all notes without a notebook tag and returns them in a list.
        /// </summary>
        public List <Note> ListUnfiledNotes()
        {
            List <Note> unfiled_notes = new List <Note> ();

            //Checks all notes
            foreach (Note note in Tomboy.DefaultNoteManager.Notes)
            {
                if (NotebookManager.GetNotebookFromNote(note) == null)
                {
                    unfiled_notes.Add(note);
                }
            }
            return(unfiled_notes);
        }
Ejemplo n.º 2
0
        public string GetNotebookForNote(string uri)
        {
            Note note = note_manager.FindByUri(uri);

            if (note == null)
            {
                return(string.Empty);
            }
            Notebook notebook = NotebookManager.GetNotebookFromNote(note);

            if (notebook == null)
            {
                return(string.Empty);
            }
            return(notebook.Name);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Determines the relative path between two exported files, can optionally be used
        /// by the subclass.
        /// </summary>
        /// <param name="title_from">
        /// The note we're finding the relative path from.
        /// </param>
        /// <param name="title_to">
        /// The title of the note we're finding the relative path to.
        /// </param>
        /// <returns>
        /// A <see cref="System.String"/>
        /// </returns>
        public string ResolveRelativePath(Note note_from, string title_to)
        {
            NoteManager manager    = Tomboy.DefaultNoteManager;
            Note        note_to    = manager.Find(title_to);
            string      title_from = SanitizeNoteTitle(note_from.Title);

            if (note_to != null)
            {
                title_to = SanitizeNoteTitle(note_to.Title);
                Logger.Debug("Found linked note '{0}', sanitized title: '{1}'", note_to.Title, title_to);
            }
            else
            {
                Logger.Error("Could not find note titled '{0}' to construct a link to it", title_to);
                return("");
            }

            if (exporting_single_notebook)
            {
                //If there is only one notebook being exported
                if (NotebookManager.GetNotebookFromNote(note_from) == NotebookManager.GetNotebookFromNote(note_to))
                {
                    return(title_to + "." + export_file_suffix);
                }
                else
                {
                    return("");
                }
            }
            else
            {
                //If all notebooks are available
                if (NotebookManager.GetNotebookFromNote(note_from) == NotebookManager.GetNotebookFromNote(note_to))
                {
                    //Both notes are in the same notebook
                    return(title_to + "." + export_file_suffix);
                }
                else
                {
                    //Unfiled notes are a special case because they're in the root directory and will
                    // throw an exception from the notebookmanager
                    string notebook_from;
                    string notebook_to;
                    try {
                        notebook_from = NotebookManager.GetNotebookFromNote(note_from).NormalizedName;
                    } catch (Exception ex) {
                        notebook_from = "___NotebookManager___UnfiledNotes__Notebook___";                         //TODO: Ugly!
                    }
                    try {
                        notebook_to = NotebookManager.GetNotebookFromNote(note_to).NormalizedName;
                    } catch (Exception ex) {
                        notebook_to = "___NotebookManager___UnfiledNotes__Notebook___";
                    }

                    if (notebook_to == "___NotebookManager___UnfiledNotes__Notebook___")
                    {
                        return(".." + System.IO.Path.DirectorySeparatorChar + title_to + "." + export_file_suffix);
                    }
                    else if (notebook_from == "___NotebookManager___UnfiledNotes__Notebook___")
                    {
                        return(SanitizePath(notebook_to) + System.IO.Path.DirectorySeparatorChar
                               + title_to + "." + export_file_suffix);
                    }
                    else
                    {
                        return(".." + System.IO.Path.DirectorySeparatorChar + SanitizePath(notebook_to)
                               + System.IO.Path.DirectorySeparatorChar + title_to + "." + export_file_suffix);
                    }
                }
            }
        }