From d9d19a345050f9de940c9f808b0634137b3790cf Mon Sep 17 00:00:00 2001 From: John Luke Date: Thu, 24 Mar 2005 04:32:49 +0000 Subject: [PATCH] fix DemoHyperText small sizing change for DemoExpander svn path=/trunk/gtk-sharp/; revision=42185 --- sample/GtkDemo/DemoExpander.cs | 9 +++++++-- sample/GtkDemo/DemoHyperText.cs | 18 +++++++++++------- sample/GtkDemo/TODO | 6 +++--- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/sample/GtkDemo/DemoExpander.cs b/sample/GtkDemo/DemoExpander.cs index dded1b861..4f7b8e9f7 100644 --- a/sample/GtkDemo/DemoExpander.cs +++ b/sample/GtkDemo/DemoExpander.cs @@ -14,12 +14,17 @@ namespace GtkDemo { public DemoExpander () : base ("Demo Expander", null, DialogFlags.DestroyWithParent) { + this.Resizable = false; this.BorderWidth = 10; - this.VBox.PackStart (new Label ("Expander demo. Click on the triangle for details."), false, true, 3); + VBox vbox = new VBox (false, 5); + this.VBox.PackStart (vbox, true, true, 0); + vbox.BorderWidth = 5; + vbox.PackStart (new Label ("Expander demo. Click on the triangle for details."), false, false, 0); + // Create the expander Expander expander = new Expander ("Details"); expander.Add (new Label ("Details can be shown or hidden.")); - this.VBox.PackStart (expander, false, true, 3); + vbox.PackStart (expander, false, false, 0); this.AddButton (Stock.Close, ResponseType.Close); diff --git a/sample/GtkDemo/DemoHyperText.cs b/sample/GtkDemo/DemoHyperText.cs index 80d859d60..20bcddd38 100644 --- a/sample/GtkDemo/DemoHyperText.cs +++ b/sample/GtkDemo/DemoHyperText.cs @@ -20,6 +20,8 @@ namespace GtkDemo [Demo ("Hyper Text", "DemoHyperText.cs", "Text Widget")] public class DemoHyperText : Gtk.Window { + // FIXME: useless counter + int uid = 0; bool hoveringOverLink = false; Gdk.Cursor handCursor, regularCursor; @@ -64,12 +66,11 @@ namespace GtkDemo // as a link. void InsertLink (TextBuffer buffer, ref TextIter iter, string text, int page) { - TextTag tag = new TextTag ("link"); + TextTag tag = new TextTag ("link" + uid++); tag.Foreground = "blue"; tag.Underline = Pango.Underline.Single; tag.PersistentData.Add ("page", page); buffer.TagTable.Add (tag); - buffer.InsertWithTags (ref iter, text, tag); } @@ -101,8 +102,12 @@ namespace GtkDemo } else if (page == 3) { - TextTag tag = new TextTag ("bold"); - tag.Weight = Pango.Weight.Bold; + TextTag tag = buffer.TagTable.Lookup ("bold"); + if (tag == null) { + tag = new TextTag ("bold"); + tag.Weight = Pango.Weight.Bold; + buffer.TagTable.Add (tag); + } buffer.InsertWithTags (ref iter, "hypertext:\n", tag); buffer.Insert (ref iter, "machine-readable text that is not sequential but is organized" + @@ -127,7 +132,6 @@ namespace GtkDemo // Looks at all tags covering the position (x, y) in the text view, // and if one of them is a link, change the cursor to the "hands" cursor // typically used by web browsers. - void SetCursorIfAppropriate (TextView view, int x, int y) { bool hovering = false; @@ -135,8 +139,7 @@ namespace GtkDemo foreach (TextTag tag in iter.Tags) { - int page = (int) tag.PersistentData ["page"]; - if (page != 0) { + if (tag.PersistentData ["page"] != null && ((int) tag.PersistentData ["page"]) != 0) { hovering = true; break; } @@ -152,6 +155,7 @@ namespace GtkDemo } } + [GLib.ConnectBefore] void OnButtonRelease (object sender, ButtonReleaseEventArgs a) { if (a.Event.Button != 1) diff --git a/sample/GtkDemo/TODO b/sample/GtkDemo/TODO index a87b2779b..667166ccd 100644 --- a/sample/GtkDemo/TODO +++ b/sample/GtkDemo/TODO @@ -11,10 +11,10 @@ DemoStockBrowser - remove duplication in ListStore, and use DataFunc's DemoHyperText - - finish + - link tags are recreated too much and never removed Future ------ -IconView -RotatedText +IconView - gtk 2.6 +RotatedText - pango 1.6