mail-archives/gtk-sharp-list/2004-February/003460.html

183 строки
5.7 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Gtk-sharp-list] Patch for TextBuffer
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:sayao%40brturbo.com">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK REL="Previous" HREF="003458.html">
<LINK REL="Next" HREF="003495.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Gtk-sharp-list] Patch for TextBuffer
</H1>
<B>Thiago Milczarek Sayão
</B>
<A HREF="mailto:sayao%40brturbo.com"
TITLE="[Gtk-sharp-list] Patch for TextBuffer">sayao@brturbo.com
</A><BR>
<I>Sat, 21 Feb 2004 17:03:17 -0300</I>
<P><UL>
<LI> Previous message: <A HREF="003458.html">[Gtk-sharp-list] Patch for TextBuffer
</A></li>
<LI> Next message: <A HREF="003495.html">[Gtk-sharp-list] Patch for TextBuffer
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#3460">[ date ]</a>
<a href="thread.html#3460">[ thread ]</a>
<a href="subject.html#3460">[ subject ]</a>
<a href="author.html#3460">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>--=-d+XnrUaMgXeMj4h7L2+m
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
On Sat, 2004-02-21 at 15:45, Mike Kestner wrote:
&gt;<i> On Sat, 2004-02-21 at 11:56, Thiago Milczarek Sayão wrote:
</I>&gt;<i> &gt; I did a patch some days ago that got commited. It was the InsertWithTags
</I>&gt;<i> &gt; patch. I didn't notice that the Insert function take 2 arguments, the
</I>&gt;<i> &gt; iter and the text, so i did the InsertWithTags function take just two
</I>&gt;<i> &gt; argument that is the text and the tags (i forgot the iter).
</I>&gt;<i>
</I>&gt;<i> Are you saying you submitted a patch that you didn't test? Please don't
</I>&gt;<i> ever do that. If a patch lands on this list, I'm assuming that it is
</I>&gt;<i> addressing a demonstrated problem, and that when the patch is applied,
</I>&gt;<i> the problem no longer exists.
</I>&gt;<i>
</I>I did test it. All patches i have sent work fine. I just did the
stupidity of making the wrong argument list to the function. It
addresses the problem of not having a gtk_text_buffer_insert_with_tags
() equivalent function.
&gt;<i> &gt; This patch corrects the InsertWithTags to take three arguments, the
</I>&gt;<i> &gt; iter, the text and the tags.
</I>&gt;<i>
</I>&gt;<i> Has it been tested?
</I>&gt;<i>
</I>
It was tested. The test i did is attached (run it inside the samples
dir). I've also tested on the gsirc (irc client).
&gt;<i> &gt; The second patch add alias to the functions Insert, InsertWithTags and
</I>&gt;<i> &gt; InsertPixbuf to automatically take EndIter as the iter argument. I don't
</I>&gt;<i> &gt; know if its a good idea, so i did a separated patch to let mkestner
</I>&gt;<i> &gt; decide :)
</I>&gt;<i>
</I>&gt;<i> Ditto.
</I>
Thanks,
Thiago.
--=-d+XnrUaMgXeMj4h7L2+m
Content-Disposition: attachment; filename=TestBuffer.cs
Content-Type: text/x-csharp; name=TestBuffer.cs; charset=UTF-8
Content-Transfer-Encoding: 7bit
using System;
using Gtk;
using Gdk;
class TestBuffer
{
TextView tv;
static void Main ()
{
new TestBuffer ();
}
TestBuffer ()
{
Application.Init ();
Gtk.Window win = new Gtk.Window (&quot;TextView Test&quot;);
win.SetDefaultSize (400, 300);
win.DeleteEvent += new DeleteEventHandler (OnWinDelete);
VBox vbox = new VBox (false, 0);
win.Add (vbox);
TextTagTable tt = new TextTagTable ();
TextTag t1 = new TextTag (null);
t1.Foreground = &quot;light blue&quot;;
TextTag t2 = new TextTag (null);
t2.Foreground = &quot;red&quot;;
TextTag t3 = new TextTag (null);
t3.Foreground = &quot;green&quot;;
TextTag t4 = new TextTag (null);
t4.Background = &quot;yellow&quot;;
tt.Add (t1);
tt.Add (t2);
tt.Add (t3);
tt.Add (t4);
TextBuffer buf = new TextBuffer (tt);
tv = new TextView ();
tv.Buffer = buf;
Gdk.Pixbuf pix = new Gdk.Pixbuf (&quot;pixmaps/gtk-sharp-logo.png&quot;);
buf.InsertPixbuf (pix);
buf.Insert (&quot;Text&quot;);
buf.InsertWithTags (&quot;RED&quot;, t2);
buf.InsertWithTags (&quot;RED FG YELLOW BG&quot;, t2, t4);
buf.InsertWithTags (buf.GetIterAtOffset (5), &quot;Green&quot;, t3);
buf.InsertWithTags (buf.GetIterAtOffset (20), &quot;Green&quot;, t3);
Gdk.Pixbuf pix2 = new Gdk.Pixbuf (&quot;pixmaps/gtk-sharp-logo.png&quot;);
buf.InsertPixbuf (pix2);
int offset = buf.EndIter.Offset;
buf.Insert (&quot;Text&quot;);
buf.InsertWithTags (&quot;RED&quot;, t2);
buf.InsertWithTags (&quot;RED FG YELLOW BG&quot;, t2, t4);
buf.InsertWithTags (buf.GetIterAtOffset (offset + 4), &quot;Green&quot;, t3);
buf.InsertWithTags (buf.GetIterAtOffset (offset + 19), &quot;Green&quot;, t3);
buf.Insert (&quot;\n&quot;);
buf.Insert (&quot;This text is at another line&quot;);
buf.InsertWithTags (&quot;\nThis text is red&quot;, t2);
buf.InsertWithTags (&quot;\nThis text is green&quot;, t3);
vbox.PackStart (tv, true, true, 0);
win.ShowAll ();
Application.Run ();
}
void OnWinDelete (object o, DeleteEventArgs args)
{
Application.Quit ();
}
}
--=-d+XnrUaMgXeMj4h7L2+m--
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI> Previous message: <A HREF="003458.html">[Gtk-sharp-list] Patch for TextBuffer
</A></li>
<LI> Next message: <A HREF="003495.html">[Gtk-sharp-list] Patch for TextBuffer
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#3460">[ date ]</a>
<a href="thread.html#3460">[ thread ]</a>
<a href="subject.html#3460">[ subject ]</a>
<a href="author.html#3460">[ author ]</a>
</LI>
</UL>
</body></html>