GNOME Bugzilla – Bug 639938
Command for inserting titles.
Last modified: 2011-07-29 20:11:53 UTC
Give Gnote a command that can be bound to a shortcut key that allows me to insert a short phrase of selected text, from within gnote or outside, and that replaces the note title with that selected phrase. Comment: I first saw this feature in a notes program I had way back in Dos Windows 3.1 days. This notes program was TSR. It is a feature I haven't seen elsewhere since. I found that sometimes the best note titles came from notes that one was writing or pasting into the note keeper. A phrase lifted from the first or second paragraph of an article was very often more mnenomic than any title contrived by me at the time of writtng. I often still select a phrase and insert it in the title -- but that is doubly annoying becasue the select and paste with the mouse isn't working in gnote and the additional step of deliting the old title is required. Not terribley onerus, but still, gnote should be quick and simple in my view. How it works is simple. No changes to the current title creation process need be made. One simply selects a phrase, pushes the short cut key combination, the selected phrase is stored to the clip board or a varible or whatever. The current title for the note is removed by a script and the new selected phrase is inserted in its place. Probably no more than an exchange of the contents of a variable.
Sounds interesting to me. I think it could work like this: when a certain short cut is pressed (or a button in toolbar), the title is replaced by the text selected elsewhere (the one, that can be pasted via mouse middle click). I think this should be implemented as addin.
Created attachment 191088 [details] replacetitle addin 1. It's my first patch, you'll probably discover mistakes. 2. It uses Ctrl+R - standing for "replace" . And gtk stock FIND_AND_REPLACE for the button. 3. The addin cannot use the Note::set_title method , because it does not edit the content. And I could not find a cool way. So this patch uses the Gtk::TextBuffer methods. 4. I had crachs when testing with French characters like "é". One line does now convert old title to Glib::ustring to avoid these. Apart from this, this seems to work here.
I built it using 0.7.4 , but i just tested using git (0.8.0) . One line from replacetitlenoteaddin.cpp has to be changed, GDK_R becomes GDK_KEY_R . Otherwise it seems ok.
Can you attach the patch, created using 'git format-patch'? Or set the proper mime-type, so that patch is viewable in bugzilla. Is Ctrl+T not possible for this? It would stand for "title", a bit more intuitive IMO. If you have changed anything in current Gnote code (excluding build system for your addin), I suggest to split it to a separate patch. Thanks for contribution and keep going!
Comment on attachment 191088 [details] replacetitle addin fix mimetype
The addin does not need Gnote code to be amended, excuding build system. Sorry my internet is limited these days but I may post a better format later. Unfortunately , Ctrl+T is currently used by Fixed Width Addin
Created attachment 192560 [details] [review] Same attachment at git format Hello, I played with git to attach the same thing with a better format. I hope it's the propper way.
Review of attachment 192560 [details] [review]: Copyright year should be 2011 only. Openning brace after `if' should be at the end of line, rather than on the new line. Why the BUFFER() macro? I think it would be better to use pointer to NoteBuffer instead. I'd suggest to try to replace title, like it's done when applying template (working with XML).
Created attachment 192763 [details] [review] Patch with set_note Thanks for your advices. I amended the copyright year, and discovered I was previously wrong, cause the set_title() method is working and checks title's uniqueness. Which I suppose to be cleaner.
Review of attachment 192763 [details] [review]: My apologies for the noise, I posted some wrong patch that you should ignore. Sorry.
Review of attachment 192763 [details] [review]: Few additional notes: 1. Fix copyright in header. 2. Use two spaces for indentation. I noticed one place in .cpp and one in .hpp, where tab is used. 3. I suggest to shrink title to "Replace title", leaving description as is (title() and description()).
Created attachment 192861 [details] [review] Replace Title with xml Hi, I fixed the copyright in header and made things simpler : get note content then replace the part of the string which is the title.
I have made some minot changes to the patch and improved it to not lose the cursor position when replacing. Nice work! I've also filled a bug 655600 for documenting this new add-in. This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.