Beispiel #1
0
        void OnNewNotebookMenuItem(object sender, EventArgs args)
        {
            List <Note> noteList = new List <Note> ();

            noteList.Add(Note);
            NotebookManager.PromptCreateNewNotebook(Note.Window, noteList);
        }
Beispiel #2
0
        public NotebookMenuItem(Note note, Notebook notebook) :
            base(notebook == null ? Catalog.GetString("No notebook") : notebook.Name)
        {
            this.note     = note;
            this.notebook = notebook;

            if (notebook == null)
            {
                // This is for the "No notebook" menu item

                // Check to see if the specified note belongs
                // to a notebook.  If so, don't activate the
                // radio button.
                if (NotebookManager.GetNotebookFromNote(note) == null)
                {
                    Active = true;
                }
            }
            else if (notebook.ContainsNote(note))
            {
                Active = true;
            }

            Activated += OnActivated;
        }
Beispiel #3
0
        public override void OnNoteOpened()
        {
            if (menu == null)
            {
                menu = new Gtk.Menu();
                menu.ShowAll();
            }

            if (toolButton == null)
            {
                InitializeToolButton();

                // Disable the notebook button if this note is a template note
                Tag templateTag = TagManager.GetOrCreateSystemTag(TagManager.TemplateNoteSystemTag);
                if (Note.ContainsTag(templateTag) == true)
                {
                    toolButton.Sensitive = false;

                    // Also prevent notebook templates from being deleted
                    if (NotebookManager.GetNotebookFromNote(Note) != null)
                    {
                        Note.Window.DeleteButton.Sensitive = false;
                    }
                }
            }
        }
Beispiel #4
0
        protected void OnActivated(object sender, EventArgs args)
        {
            if (note == null)
            {
                return;
            }

            NotebookManager.MoveNoteToNotebook(note, notebook);
        }
Beispiel #5
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_);
        }
Beispiel #6
0
 private void UpdateButtonSensitivity(bool isTemplate)
 {
     if (toolButton != null)
     {
         toolButton.Sensitive = !isTemplate;
     }
     if (Note.HasWindow)
     {
         Note.Window.DeleteButton.Sensitive = !isTemplate || NotebookManager.GetNotebookFromNote(Note) == null;
     }
 }
Beispiel #7
0
        /// <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);
        }
        private void OnTagRemoved(Note note, string normalizedTagName)
        {
            string megaPrefix =
                Tag.SYSTEM_TAG_PREFIX + Notebook.NotebookTagPrefix;

            if (normalizedTagName.StartsWith(megaPrefix) == false)
            {
                return;
            }

            string normalizedNotebookName =
                normalizedTagName.Substring(megaPrefix.Length);

            Notebook notebook =
                NotebookManager.GetNotebook(normalizedNotebookName);

            if (notebook == null)
            {
                return;
            }

            NotebookManager.FireNoteRemovedFromNoteBook(note, notebook);
        }
        /// <summary>
        /// Handle the addition of note tags through programmatic means,
        /// such as note sync or the dbus remote control.
        /// </summary>
        private void OnTagAdded(Note note, Tag tag)
        {
            if (NotebookManager.AddingNotebook)
            {
                return;
            }

            string megaPrefix =
                Tag.SYSTEM_TAG_PREFIX + Notebook.NotebookTagPrefix;

            if (tag.IsSystem == false ||
                tag.Name.StartsWith(megaPrefix) == false)
            {
                return;
            }

            string notebookName =
                tag.Name.Substring(megaPrefix.Length);

            Notebook notebook =
                NotebookManager.GetOrCreateNotebook(notebookName);

            NotebookManager.FireNoteAddedToNoteBook(note, notebook);
        }
Beispiel #10
0
        void UpdateNotebookButtonLabel()
        {
            Notebook currentNotebook = NotebookManager.GetNotebookFromNote(Note);

            UpdateNotebookButtonLabel(currentNotebook);
        }
 private void OnNewNotebookMenuItem(object sender, EventArgs args)
 {
     NotebookManager.PromptCreateNewNotebook(null);
 }