protected void OnActivated(object sender, EventArgs args)
        {
            if (notebook == null)
            {
                return;
            }

            // Look for the template note and create a new note
            Note templateNote = notebook.GetTemplateNote();
            Note note;

            NoteManager noteManager = Tomboy.DefaultNoteManager;

            note = noteManager.Create();
            if (templateNote != null)
            {
                // Use the body from the template note
                string xmlContent = templateNote.XmlContent.Replace(XmlEncoder.Encode(templateNote.Title),
                                                                    XmlEncoder.Encode(note.Title));
                xmlContent      = NoteManager.SanitizeXmlContent(xmlContent);
                note.XmlContent = xmlContent;
            }

            note.AddTag(notebook.Tag);
            note.Window.Show();
        }
Exemple #2
0
        /// <summary>
        /// Prompt the user and delete the notebok (if they say so).
        /// </summary>
        /// <param name="parent">
        /// A <see cref="Gtk.Window"/>
        /// </param>
        /// <param name="notebook">
        /// A <see cref="Notebook"/>
        /// </param>
        public static void PromptDeleteNotebook(Gtk.Window parent, Notebook notebook)
        {
            // Confirmation Dialog
            HIGMessageDialog dialog =
                new HIGMessageDialog(parent,
                                     Gtk.DialogFlags.Modal,
                                     Gtk.MessageType.Question,
                                     Gtk.ButtonsType.YesNo,
                                     Catalog.GetString("Really delete this notebook?"),
                                     Catalog.GetString(
                                         "The notes that belong to this notebook will not be " +
                                         "deleted, but they will no longer be associated with " +
                                         "this notebook.  This action cannot be undone."));

            dialog.DefaultResponse = Gtk.ResponseType.No;
            int response = dialog.Run();

            dialog.Destroy();
            if (response != (int)Gtk.ResponseType.Yes)
            {
                return;
            }

            DeleteNotebook(notebook);

            // Delete the template note
            Note templateNote = notebook.GetTemplateNote();

            if (templateNote != null)
            {
                NoteManager noteManager = Tomboy.DefaultNoteManager;
                noteManager.Delete(templateNote);
            }
        }
Exemple #3
0
        public static Notebook GetOrCreateNotebook(string notebookName)
        {
            if (notebookName == null)
            {
                throw new ArgumentNullException("NotebookManager.GetNotebook () called with a null name.");
            }

            Notebook notebook = GetNotebook(notebookName);

            if (notebook != null)
            {
                return(notebook);
            }

            Gtk.TreeIter iter = Gtk.TreeIter.Zero;
            lock (locker) {
                notebook = GetNotebook(notebookName);
                if (notebook != null)
                {
                    return(notebook);
                }

                try {
                    AddingNotebook = true;
                    notebook       = new Notebook(notebookName);
                } finally {
                    AddingNotebook = false;
                }
                iter = notebooks.Append();
                notebooks.SetValue(iter, 0, notebook);
                notebookMap [notebook.NormalizedName] = iter;

                // Create the template note so the system tag
                // that represents the notebook actually gets
                // saved to a note (and persisted after Tomboy
                // is shut down).
                Note templateNote = notebook.GetTemplateNote();

                // Make sure the template note has the notebook tag.
                // Since it's possible for the template note to already
                // exist, we need to make sure it gets tagged.
                templateNote.AddTag(notebook.Tag);
                if (NoteAddedToNotebook != null)
                {
                    NoteAddedToNotebook(templateNote, notebook);
                }
            }

            return(notebook);
        }
		/// <summary>
		/// Prompt the user and delete the notebok (if they say so).
		/// </summary>
		/// <param name="parent">
		/// A <see cref="Gtk.Window"/>
		/// </param>
		/// <param name="notebook">
		/// A <see cref="Notebook"/>
		/// </param>
		public static void PromptDeleteNotebook (Gtk.Window parent, Notebook notebook)
		{
			// Confirmation Dialog
			HIGMessageDialog dialog =
				new HIGMessageDialog (parent,
									  Gtk.DialogFlags.Modal,
									  Gtk.MessageType.Question,
									  Gtk.ButtonsType.YesNo,
									  Catalog.GetString ("Really delete this notebook?"),
									  Catalog.GetString (
									  	"The notes that belong to this notebook will not be " +
									  	"deleted, but they will no longer be associated with " +
									  	"this notebook.  This action cannot be undone."));
			dialog.DefaultResponse = Gtk.ResponseType.No;
			int response = dialog.Run ();
			dialog.Destroy ();
			if (response != (int) Gtk.ResponseType.Yes)
				return;
			
			// Grab the template note before removing all the notebook tags
			Note templateNote = notebook.GetTemplateNote ();
			
			DeleteNotebook (notebook);

			// Delete the template note
			if (templateNote != null) {
				NoteManager noteManager = Tomboy.DefaultNoteManager;
				noteManager.Delete (templateNote);
			}
		}
		public static Notebook GetOrCreateNotebook (string notebookName)
		{
			if (notebookName == null)
				throw new ArgumentNullException ("NotebookManager.GetNotebook () called with a null name.");
			
			Notebook notebook = GetNotebook (notebookName);
			if (notebook != null)
				return notebook;
			
			Gtk.TreeIter iter = Gtk.TreeIter.Zero;
			lock (locker) {
				notebook = GetNotebook (notebookName);
				if (notebook != null)
					return notebook;
				
				try {
					AddingNotebook = true;
					notebook = new Notebook (notebookName);
				} finally {
					AddingNotebook = false;
				}
				iter = notebooks.Append ();
				notebooks.SetValue (iter, 0, notebook);
				notebookMap [notebook.NormalizedName] = iter;
				
				// Create the template note so the system tag
				// that represents the notebook actually gets
				// saved to a note (and persisted after Tomboy
				// is shut down).
				Note templateNote = notebook.GetTemplateNote ();
				
				// Make sure the template note has the notebook tag.
				// Since it's possible for the template note to already
				// exist, we need to make sure it gets tagged.
				templateNote.AddTag (notebook.Tag);
				if (NoteAddedToNotebook != null)
					NoteAddedToNotebook (templateNote, notebook);
			}

			return notebook;
		}