GNOME Bugzilla – Bug 601506
A new note created via notebook's list doesn't use the custom note template
Last modified: 2017-07-31 12:41:40 UTC
Created attachment 147458 [details] A new note created via notebook's list doesn't use the custom note template. OS: WinXP SP3 Gtk#: 2.12.9-2 Tomboy: 1.0.0, all standard add-ins activated Usecase: Creating a new note with custom template Problem: If creating a new note with right-click on a notebook (see screenshot), the custom defined template is going to be always ignored.
Notebooks have their own templates (see the Open Template Note) option. Are you suggesting that if a notebook does not have a template set, that it should use the main template? That could make sense.
> Are you suggesting that if a notebook does not have a template set, that it > should use the main template? That could make sense. That's what I meant: There's currently no fallback option. For 90% of my notebooks I am using my standard template (some kind of todo, fixme, etc.) Sorry for my rough description.
Right now, we're creating a new template note for the notebook. We could make it use the content of the main template--keeping a separate template for each notebook. This is a little annoying if you only want to update it in one place, but it allows you to give a notebook its own template down the line. I think I'm going to keep this behavior, because I don't want to refer directly to the main template. I know, it's cumbersome if you update your template, but here's to hoping you aren't doing that often. In the future, I think we need to retool the way template notes are done. Rather than associating a notebook with its template notes, we should have multiple template notes and be able to associate them with notebooks (by default). Or just choose _which_ template we want to use in any given notebook.
Created attachment 150950 [details] [review] Use default note template content for notebook templates If no notebook template exists, then we grab the content from the default template. However, if a template exists (even the default template), you're stuck copying and pasting from the default template. Anything more than this, and we'd really need to talk about what desirable behavior is. There's not much in the way of controlling how template notes are currently associated with notebooks. I think this is the nicest/safest way to do it. Though, I will freely agree, it isn't ideal--and not exactly what you wanted.
Review of attachment 150950 [details] [review]: ::: Tomboy/Notebooks/Notebook.cs @@ +112,3 @@ Note note = noteManager.Find (templateNoteTitle); if (note == null) { + Note default_note = Need to protect against a null return value here. The default template note is deletable. Maybe GetDefaultNoteTemplate should create it if it doesn't exist. @@ +116,3 @@ note = noteManager.Create (templateNoteTitle, + default_note.XmlContent); This doesn't work quite right, because the XmlContent includes the title, which isn't getting replaced properly by the Create method. This means the notebook template is getting the same title as the default template. This might best be fixed by fixing the Create method.
Created attachment 151255 [details] [review] New patch to fetch default note template content. I opted out of tinkering with NoteManager at all, actually. I killed GetDefaultNoteTemplate() in favor of using the pre-existing GetOrCreateNoteTemplate. I noticed the XmlContent.Raplace () trick that was happening in CreateNewNote(string title, string uid), and used that in Notebooks.cs instead. Now we shouldn't be getting a null object when getting the default note template, and the title is consistent within the XML.
Created attachment 151310 [details] [review] Address the issue in NoteManager Okay... So this time, I opted for addressing the issue in NoteManager. It's a much bigger change, but I think that it might be a step in the right direction. What do you think about teasing apart GetOrCreateNoteTemplate into retrieval and creation? There's repeated code peppered throughout all of this, and I tried to avoid adding more.
This fix will be trivial when bug #509147 is fixed. See patch attached to that bug.
This is mostly working in master now (1.7.4). The missing piece is the title of the notebook template. Currently it will use the default template.
The Tomboy team has moved from GNOME Bugzilla to GitHub for bug reports and feature requests: https://github.com/tomboy-notes/tomboy/issues/ Closing this report as NOTGNOME as part of Bugzilla Housekeeping (bug 781054) to keep tasks in one place. Please feel free to transfer this task to GitHub if this task is still valid in a recent Tomboy version. We are sorry for the inconvenience.