|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Tomboy 0.10 Planning Meeting Tomorrow @ 13:00 PSTEveryone's invited to attend the Tomboy Planning Meeting tomorrow:
Who: Everyone who'd like to participate Where: #tomboy on irc.gnome.org When: Tuesday, 25 September 2007, 13:00 PST What: http://live.gnome.org/Tomboy/DevMeetingZeroPointTen _______________________________________________ Tomboy-list mailing list Tomboy-list@... http://lists.beatniksoftware.com/listinfo.cgi/tomboy-list-beatniksoftware.com |
|
|
Re: Tomboy 0.10 Planning Meeting Tomorrow @ 13:00 PSTHey Boyd,
You said during the meeting you tried to get checkboxes for todo items working. I was thinking about giving it a try as well. Just don't want to run into the same problems again. I guess you used child anchors of the TextView widget? Could you describe your problems or maybe send me your code? Thanks, Max Am Montag, den 24.09.2007, 08:41 -0600 schrieb Boyd Timothy: > Everyone's invited to attend the Tomboy Planning Meeting tomorrow: > > Who: Everyone who'd like to participate > Where: #tomboy on irc.gnome.org > When: Tuesday, 25 September 2007, 13:00 PST > What: http://live.gnome.org/Tomboy/DevMeetingZeroPointTen > _______________________________________________ > Tomboy-list mailing list > Tomboy-list@... > http://lists.beatniksoftware.com/listinfo.cgi/tomboy-list-beatniksoftware.com _______________________________________________ Tomboy-list mailing list Tomboy-list@... http://lists.beatniksoftware.com/listinfo.cgi/tomboy-list-beatniksoftware.com |
|
|
Re: Tomboy 0.10 Planning Meeting Tomorrow @ 13:00 PSTWell, I don't know that I saved any of that code anywhere. Basically,
here are some of the issues I ran into: 1. Modifying the TextBuffer during a TextBuffer.InsertText event (i.e., to add a checkbox) can be very tricky. The problem happens if there are other listeners for this event which follow. If you change the TextIter at all during this process, it can cause some real problems for the following event listeners. Supposedly, you're supposed to be able to correct the TextIter before exiting your event handler, but I haven't figure out the right calls to do that in C#. 2. The calls to insert at Widget into a ChildAnchor come from the TextView (the UI). During the event handler, you're not dealing with the UI at all and strictly the TextBuffer. I wasn't able to figure out how to get a Widget (like a CheckButton) to get inserted during the event handler. 3. Another option was trying to use a Gdk.Pixbuf. TextBuffer allows you to insert a Gdk.Pixbuf at a TextIter. This is how Tomboy's Bugzilla Addin works (see the bugzilla addin code for details). I tried going down this route as well, but there are problems doing it this way too: a) you now have to match the theme with a properly drawn checkbox, b) you have to figure out how to capture mouse button clicks so the user can mark the checkbox, c) you've got to figure out how to change the empty box to a box with a check when the user clicks the box. 4. To complicate things even a bit more, since we need unique IDs/Uris to each separate tasks, you can't just use a standard TextTag to mark the todo text as a todo. You have to use anonymous TextTags (I believe the Gtk C API discusses this). So, you have to set up your own data structures to keep track of the TextTags and TextIters. You can't just use the TextTagTable or other methods available from the TextBuffer to deal with the TextTags. In any case, if you'd like to take a stab at it, that would be awesome! Maybe I was trying to use the TextBuffer completely wrong? Perhaps you're a Gtk TextView/TextBuffer expert? If not, maybe your luck will be better than mine and that would ROCK! -Boyd On 9/26/07, Max Wiehle <wiehle@...> wrote: > Hey Boyd, > > You said during the meeting you tried to get checkboxes for todo items > working. I was thinking about giving it a try as well. Just don't want > to run into the same problems again. > I guess you used child anchors of the TextView widget? > > Could you describe your problems or maybe send me your code? > > Thanks, > Max > > Am Montag, den 24.09.2007, 08:41 -0600 schrieb Boyd Timothy: > > Everyone's invited to attend the Tomboy Planning Meeting tomorrow: > > > > Who: Everyone who'd like to participate > > Where: #tomboy on irc.gnome.org > > When: Tuesday, 25 September 2007, 13:00 PST > > What: http://live.gnome.org/Tomboy/DevMeetingZeroPointTen > > _______________________________________________ > > Tomboy-list mailing list > > Tomboy-list@... > > http://lists.beatniksoftware.com/listinfo.cgi/tomboy-list-beatniksoftware.com > > Tomboy-list mailing list Tomboy-list@... http://lists.beatniksoftware.com/listinfo.cgi/tomboy-list-beatniksoftware.com |
|
|
checkboxes for todosHi,
I just had a very quick try at this. It's not even a proof of concept. So don't expect any magic or anything. I just tried to get a checkbox printed at the beginning of the line since i am not familiar with neither tomboy nor gtk or TextView details. I did not care about where in the addin this would go either. I just hacked it right into the core of tomboy. I attached a patch that won't do anything usefull but convert [] at the beginning of a line in checkboxes. They don't get stored either. Am Mittwoch, denf 26.09.2007, 09:00 -0600 schrieb Boyd Timothy: > Well, I don't know that I saved any of that code anywhere. Basically, > here are some of the issues I ran into: > > 1. Modifying the TextBuffer during a TextBuffer.InsertText event > (i.e., to add a checkbox) can be very tricky. The problem happens if > there are other listeners for this event which follow. If you change > the TextIter at all during this process, it can cause some real > problems for the following event listeners. Supposedly, you're > supposed to be able to correct the TextIter before exiting your event > handler, but I haven't figure out the right calls to do that in C#. would fit into Addins though but the Latex Addin seems to take a similar approach. > 2. The calls to insert at Widget into a ChildAnchor come from the > TextView (the UI). During the event handler, you're not dealing with > the UI at all and strictly the TextBuffer. I wasn't able to figure > out how to get a Widget (like a CheckButton) to get inserted during > the event handler. I tried this by just adding the anchor and then triggering an event that gets handled in the UI and adds the actual widget. > 3. Another option was trying to use a Gdk.Pixbuf. TextBuffer allows > you to insert a Gdk.Pixbuf at a TextIter. This is how Tomboy's > Bugzilla Addin works (see the bugzilla addin code for details). I > tried going down this route as well, but there are problems doing it > this way too: a) you now have to match the theme with a properly drawn > checkbox, b) you have to figure out how to capture mouse button clicks > so the user can mark the checkbox, c) you've got to figure out how to > change the empty box to a box with a check when the user clicks the > box. I'd prefer a way to insert widgets since that might proof useful later on. > 4. To complicate things even a bit more, since we need unique IDs/Uris > to each separate tasks, you can't just use a standard TextTag to mark > the todo text as a todo. You have to use anonymous TextTags (I > believe the Gtk C API discusses this). So, you have to set up your > own data structures to keep track of the TextTags and TextIters. You > can't just use the TextTagTable or other methods available from the > TextBuffer to deal with the TextTags. That's what was puzzling me in the end. What data structures to use, How to "store the checkbox" and do the parsing etc. > In any case, if you'd like to take a stab at it, that would be > awesome! Maybe I was trying to use the TextBuffer completely wrong? > Perhaps you're a Gtk TextView/TextBuffer expert? If not, maybe your > luck will be better than mine and that would ROCK! As might be quite obvious i am not an expert at all ;) Might keep trying my luck though. Max > -Boyd > > On 9/26/07, Max Wiehle <wiehle@...> wrote: > > Hey Boyd, > > > > You said during the meeting you tried to get checkboxes for todo items > > working. I was thinking about giving it a try as well. Just don't want > > to run into the same problems again. > > I guess you used child anchors of the TextView widget? > > > > Could you describe your problems or maybe send me your code? > > > > Thanks, > > Max > > > > Am Montag, den 24.09.2007, 08:41 -0600 schrieb Boyd Timothy: > > > Everyone's invited to attend the Tomboy Planning Meeting tomorrow: > > > > > > Who: Everyone who'd like to participate > > > Where: #tomboy on irc.gnome.org > > > When: Tuesday, 25 September 2007, 13:00 PST > > > What: http://live.gnome.org/Tomboy/DevMeetingZeroPointTen > > > _______________________________________________ > > > Tomboy-list mailing list > > > Tomboy-list@... > > > http://lists.beatniksoftware.com/listinfo.cgi/tomboy-list-beatniksoftware.com > > > > [checkbox.patch] Index: Tomboy/NoteBuffer.cs =================================================================== --- Tomboy/NoteBuffer.cs (Revision 1575) +++ Tomboy/NoteBuffer.cs (Arbeitskopie) @@ -57,7 +57,9 @@ public event ChangeDepthHandler ChangeTextDepth; public event NewBulletHandler NewBulletInserted; + public event AnchorForCheckboxHandler AnchorForCheckboxInserted; + public void ToggleActiveTag (string tag_name) { Logger.Log ("ToggleTag called for '{0}'", tag_name); @@ -361,7 +363,44 @@ return true; } - + // replace "[]" with checkboxes... + else if (iter.Char.Equals ("[")) { + Gtk.TextIter start = GetIterAtLineOffset (iter.Line, 0); + Gtk.TextIter end = GetIterAtLineOffset (iter.Line, 1); + + // Remove the ']' character + if (end.Char != "]") + return false; + + end.ForwardChar(); + + // Set the direction of the bullet to be the same as + // the first character after the '*' or '-' + Pango.Direction direction = Pango.Direction.Ltr; + if (end.Char.Length > 0) + direction = Pango.Global.UnicharDirection (end.Char[0]); + + Delete (ref start, ref end); + + iter = GetIterAtMark (insert_mark); + int offset = iter.Offset; + iter.LineOffset = 0; + + Undoer.FreezeUndo (); + Gtk.TextChildAnchor anchor = this.CreateChildAnchor (ref iter); + Undoer.ThawUndo (); + + AnchorForCheckboxInserted (this, + new AnchorForCheckboxEventArgs (anchor, offset, 0, direction)); + + iter.LineOffset = offset; + + iter = GetIterAtMark (insert_mark); + Insert (ref iter, "\n"); + iter.LineOffset = 0; + + return true; + } return false; } @@ -1018,6 +1057,35 @@ public delegate void NewBulletHandler (object o, InsertBulletEventArgs args); + public class AnchorForCheckboxEventArgs : EventArgs + { + Gtk.TextChildAnchor anchor; + int offset; + int line; + int depth; + Pango.Direction direction; + + public Gtk.TextChildAnchor Anchor { get {return anchor; } } + + public int Offset { get {return offset; } } + + public int Line { get {return line; } } + + public int Depth { get {return depth; } } + + public Pango.Direction Direction { get {return direction; } } + + public AnchorForCheckboxEventArgs (Gtk.TextChildAnchor anchor, int offset, int depth, Pango.Direction direction) + { + this.anchor = anchor; + this.offset = offset; + this.depth = depth; + this.direction = direction; + } + } + + public delegate void AnchorForCheckboxHandler (object o, AnchorForCheckboxEventArgs args); + public class NoteBufferArchiver { public static string Serialize (Gtk.TextBuffer buffer) Index: Tomboy/Note.cs =================================================================== --- Tomboy/Note.cs (Revision 1575) +++ Tomboy/Note.cs (Arbeitskopie) @@ -412,6 +412,13 @@ DebugSave ("BufferInsertSetMark queueing save"); QueueSave (false); } + + void BufferAddCheckbox (object sender, AnchorForCheckboxEventArgs args) + { + Gtk.Widget checkbox = new Gtk.CheckButton (); + window.Editor.AddChildAtAnchor (checkbox, args.Anchor); + checkbox.Show (); + } // // Window events. Queue a save when the window location/size has changed, and set @@ -771,6 +778,7 @@ buffer.TagApplied += BufferTagApplied; buffer.TagRemoved += BufferTagRemoved; buffer.MarkSet += BufferInsertMarkSet; + buffer.AnchorForCheckboxInserted += BufferAddCheckbox; } return buffer; } _______________________________________________ Tomboy-list mailing list Tomboy-list@... http://lists.beatniksoftware.com/listinfo.cgi/tomboy-list-beatniksoftware.com |
|
|
Re: checkboxes for todosThis is something that interests me. No time to hack right now, but
attached is an updated version of Max's patch that applies in latest git master. Also attached is a screenshot of how it looks right now, so you can see that some hackery is still need to make it look decent. If anyone is interested in working on this, that would rock. Sandy On Wed, Sep 26, 2007 at 1:25 PM, Max Wiehle <wiehle@...> wrote: > Hi, > > I just had a very quick try at this. It's not even a proof of concept. > So don't expect any magic or anything. I just tried to get a checkbox > printed at the beginning of the line since i am not familiar with > neither tomboy nor gtk or TextView details. > > I did not care about where in the addin this would go either. I just > hacked it right into the core of tomboy. > > I attached a patch that won't do anything usefull but convert [] at the > beginning of a line in checkboxes. They don't get stored either. > > Am Mittwoch, denf 26.09.2007, 09:00 -0600 schrieb Boyd Timothy: >> Well, I don't know that I saved any of that code anywhere. Basically, >> here are some of the issues I ran into: >> >> 1. Modifying the TextBuffer during a TextBuffer.InsertText event >> (i.e., to add a checkbox) can be very tricky. The problem happens if >> there are other listeners for this event which follow. If you change >> the TextIter at all during this process, it can cause some real >> problems for the following event listeners. Supposedly, you're >> supposed to be able to correct the TextIter before exiting your event >> handler, but I haven't figure out the right calls to do that in C#. > I think reformating the line after finishing it, just the way > bulletlists do migth reduce some of that trouble. I don't know how this > would fit into Addins though but the Latex Addin seems to take a similar > approach. > >> 2. The calls to insert at Widget into a ChildAnchor come from the >> TextView (the UI). During the event handler, you're not dealing with >> the UI at all and strictly the TextBuffer. I wasn't able to figure >> out how to get a Widget (like a CheckButton) to get inserted during >> the event handler. > I tried this by just adding the anchor and then triggering an event that > gets handled in the UI and adds the actual widget. > >> 3. Another option was trying to use a Gdk.Pixbuf. TextBuffer allows >> you to insert a Gdk.Pixbuf at a TextIter. This is how Tomboy's >> Bugzilla Addin works (see the bugzilla addin code for details). I >> tried going down this route as well, but there are problems doing it >> this way too: a) you now have to match the theme with a properly drawn >> checkbox, b) you have to figure out how to capture mouse button clicks >> so the user can mark the checkbox, c) you've got to figure out how to >> change the empty box to a box with a check when the user clicks the >> box. > I'd prefer a way to insert widgets since that might proof useful later > on. > >> 4. To complicate things even a bit more, since we need unique IDs/Uris >> to each separate tasks, you can't just use a standard TextTag to mark >> the todo text as a todo. You have to use anonymous TextTags (I >> believe the Gtk C API discusses this). So, you have to set up your >> own data structures to keep track of the TextTags and TextIters. You >> can't just use the TextTagTable or other methods available from the >> TextBuffer to deal with the TextTags. > That's what was puzzling me in the end. What data structures to use, How > to "store the checkbox" and do the parsing etc. > >> In any case, if you'd like to take a stab at it, that would be >> awesome! Maybe I was trying to use the TextBuffer completely wrong? >> Perhaps you're a Gtk TextView/TextBuffer expert? If not, maybe your >> luck will be better than mine and that would ROCK! > As might be quite obvious i am not an expert at all ;) Might keep trying > my luck though. > > Max > >> -Boyd >> >> On 9/26/07, Max Wiehle <wiehle@...> wrote: >> > Hey Boyd, >> > >> > You said during the meeting you tried to get checkboxes for todo items >> > working. I was thinking about giving it a try as well. Just don't want >> > to run into the same problems again. >> > I guess you used child anchors of the TextView widget? >> > >> > Could you describe your problems or maybe send me your code? >> > >> > Thanks, >> > Max >> > >> > Am Montag, den 24.09.2007, 08:41 -0600 schrieb Boyd Timothy: >> > > Everyone's invited to attend the Tomboy Planning Meeting tomorrow: >> > > >> > > Who: Everyone who'd like to participate >> > > Where: #tomboy on irc.gnome.org >> > > When: Tuesday, 25 September 2007, 13:00 PST >> > > What: http://live.gnome.org/Tomboy/DevMeetingZeroPointTen >> > > _______________________________________________ >> > > Tomboy-list mailing list >> > > Tomboy-list@... >> > > http://lists.beatniksoftware.com/listinfo.cgi/tomboy-list-beatniksoftware.com >> > >> > > > _______________________________________________ > Tomboy-list mailing list > Tomboy-list@... > http://lists.beatniksoftware.com/listinfo.cgi/tomboy-list-beatniksoftware.com > > [checkbox2.patch] diff --git a/Tomboy/Note.cs b/Tomboy/Note.cs index 117d9cb..a916700 100644 --- a/Tomboy/Note.cs +++ b/Tomboy/Note.cs @@ -408,6 +408,13 @@ namespace Tomboy return "note://tomboy/" + Path.GetFileNameWithoutExtension (filepath); } + + void BufferAddCheckbox (object sender, AnchorForCheckboxEventArgs args) + { + Gtk.Widget checkbox = new Gtk.CheckButton (); + window.Editor.AddChildAtAnchor (checkbox, args.Anchor); + checkbox.Show (); + } public override int GetHashCode () { @@ -982,6 +989,7 @@ namespace Tomboy buffer.TagApplied += BufferTagApplied; buffer.TagRemoved += BufferTagRemoved; buffer.MarkSet += BufferInsertMarkSet; + buffer.AnchorForCheckboxInserted += BufferAddCheckbox; } return buffer; } diff --git a/Tomboy/NoteBuffer.cs b/Tomboy/NoteBuffer.cs index 938ae57..fe305ee 100644 --- a/Tomboy/NoteBuffer.cs +++ b/Tomboy/NoteBuffer.cs @@ -76,7 +76,9 @@ namespace Tomboy public event ChangeDepthHandler ChangeTextDepth; public event NewBulletHandler NewBulletInserted; + public event AnchorForCheckboxHandler AnchorForCheckboxInserted; + public void ToggleActiveTag (string tag_name) { Logger.Log ("ToggleTag called for '{0}'", tag_name); @@ -411,6 +413,44 @@ namespace Tomboy return true; } + // replace "[]" with checkboxes... + else if (iter.Char.Equals ("[")) { + Gtk.TextIter start = GetIterAtLineOffset (iter.Line, 0); + Gtk.TextIter end = GetIterAtLineOffset (iter.Line, 1); + + // Remove the ']' character + if (end.Char != "]") + return false; + + end.ForwardChar(); + + // Set the direction of the bullet to be the same as + // the first character after the '*' or '-' + Pango.Direction direction = Pango.Direction.Ltr; + if (end.Char.Length > 0) + direction = Pango.Global.UnicharDirection (end.Char[0]); + + Delete (ref start, ref end); + + iter = GetIterAtMark (insert_mark); + int offset = iter.Offset; + iter.LineOffset = 0; + + Undoer.FreezeUndo (); + Gtk.TextChildAnchor anchor = this.CreateChildAnchor (ref iter); + Undoer.ThawUndo (); + + AnchorForCheckboxInserted (this, + new AnchorForCheckboxEventArgs (anchor, offset, 0, direction)); + + iter.LineOffset = offset; + + iter = GetIterAtMark (insert_mark); + Insert (ref iter, "\n"); + iter.LineOffset = 0; + + return true; + } return false; } @@ -1124,6 +1164,35 @@ namespace Tomboy public delegate void NewBulletHandler (object o, InsertBulletEventArgs args); + public class AnchorForCheckboxEventArgs : EventArgs + { + Gtk.TextChildAnchor anchor; + int offset; + int line; + int depth; + Pango.Direction direction; + + public Gtk.TextChildAnchor Anchor { get {return anchor; } } + + public int Offset { get {return offset; } } + + public int Line { get {return line; } } + + public int Depth { get {return depth; } } + + public Pango.Direction Direction { get {return direction; } } + + public AnchorForCheckboxEventArgs (Gtk.TextChildAnchor anchor, int offset, int depth, Pango.Direction direction) + { + this.anchor = anchor; + this.offset = offset; + this.depth = depth; + this.direction = direction; + } + } + + public delegate void AnchorForCheckboxHandler (object o, AnchorForCheckboxEventArgs args); + public class NoteBufferArchiver { public static string Serialize (Gtk.TextBuffer buffer) _______________________________________________ Tomboy-list mailing list Tomboy-list@... http://lists.beatniksoftware.com/listinfo.cgi/tomboy-list-beatniksoftware.com |
| Free embeddable forum powered by Nabble | Forum Help |