protected void OnActivated(object sender, EventArgs args) { if (note == null) { return; } NotebookManager.MoveNoteToNotebook(note, notebook); }
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_); }
/// <summary> /// Prompt the user to create a new notebook and if successful, move /// the notes specified in the notesToAdd list into the new notebook. /// </summary> /// <param name="parent"> /// A <see cref="Gtk.Window"/> /// </param> /// <param name="notesToAdd"> /// A <see cref="List`1"/> of notes that should be added to the new /// notebook. /// </param> /// <returns> /// The newly created <see cref="Notebook"/> if successful or null /// if there was a problem. /// </returns> public static Notebook PromptCreateNewNotebook(Gtk.Window parent, List <Note> notesToAdd) { // Prompt the user for the name of a new notebook Notebooks.CreateNotebookDialog dialog = new Notebooks.CreateNotebookDialog(parent, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.NoSeparator); int response = dialog.Run(); string notebookName = dialog.NotebookName; dialog.Destroy(); if (response != (int)Gtk.ResponseType.Ok) { return(null); } Notebooks.Notebook notebook = GetOrCreateNotebook(notebookName); if (notebook == null) { Logger.Warn("Could not create notebook: {0}", notebookName); } else { Logger.Debug("Created the notebook: {0} ({1})", notebook.Name, notebook.NormalizedName); if (notesToAdd != null) { // Move all the specified notesToAdd into the new notebook foreach (Note note in notesToAdd) { NotebookManager.MoveNoteToNotebook(note, notebook); } } } return(notebook); }