From 87f4701dd6642840015a11c05d2f77a7689b87ce Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Fri, 15 Apr 2005 07:46:56 +0000 Subject: [PATCH] 2005-04-15 Chris Toshok * Makefile.am: add support for gtk glade files and resources. * DebugAttributes.cs: change the pixbuf object source to GtkVisualizers.PixbufObjectSource from VisualizerObjectSource. * gtk/PixbufVisualizer.cs (PixbufWindow): new class to wrap the glade UI. (PixbufVisualizer): read the data as written by our custom objectsource. (PixbufObjectSource): new class, since Pixbufs aren't serializable, we have to write the data ourselves. svn path=/trunk/monodevelop-visualizers/; revision=43023 --- ChangeLog | 14 +++ DebugAttributes.cs | 2 +- Makefile.am | 7 +- gecko/GeckoWindow.cs | 1 - gecko/geckovis.gladep | 8 -- gecko/geckovis.gladep.bak | 8 -- gtk/PixbufVisualizer.cs | 89 +++++++++++++++++-- .../geckovis.glade.bak => gtk/pixbufvis.glade | 37 +++++--- 8 files changed, 130 insertions(+), 36 deletions(-) delete mode 100644 gecko/geckovis.gladep delete mode 100644 gecko/geckovis.gladep.bak rename gecko/geckovis.glade.bak => gtk/pixbufvis.glade (68%) diff --git a/ChangeLog b/ChangeLog index e69de29..3d9e386 100644 --- a/ChangeLog +++ b/ChangeLog @@ -0,0 +1,14 @@ +2005-04-15 Chris Toshok + + * Makefile.am: add support for gtk glade files and resources. + + * DebugAttributes.cs: change the pixbuf object source to + GtkVisualizers.PixbufObjectSource from VisualizerObjectSource. + + * gtk/PixbufVisualizer.cs (PixbufWindow): new class to wrap the + glade UI. + (PixbufVisualizer): read the data as written by our custom + objectsource. + (PixbufObjectSource): new class, since Pixbufs aren't + serializable, we have to write the data ourselves. + diff --git a/DebugAttributes.cs b/DebugAttributes.cs index a6eb322..2277751 100644 --- a/DebugAttributes.cs +++ b/DebugAttributes.cs @@ -2,7 +2,7 @@ using System.Diagnostics; using MonoDevelop.DebuggerVisualizers; [assembly: DebuggerVisualizer (typeof (GtkVisualizers.PixbufVisualizer), - typeof (VisualizerObjectSource), + typeof (GtkVisualizers.PixbufObjectSource), Target = typeof (Gdk.Pixbuf), Description = "View Pixbuf")] [assembly: DebuggerVisualizer (typeof (CorlibVisualizers.StringVisualizer), diff --git a/Makefile.am b/Makefile.am index a50f051..747af6c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,9 +5,9 @@ GECKO_CSFILES=gecko/HTMLVisualizer.cs \ GECKO_FLAGS= -define:ENABLE_GECKO_VISUALIZERS -GLADE_FILES=gecko/geckovis.glade +GECKO_GLADE_FILES=gecko/geckovis.glade -RESOURCES= /resource:./gecko/geckovis.glade,geckovis.glade +GECKO_RESOURCES= /resource:./gecko/geckovis.glade,geckovis.glade endif CSFILES=AssemblyInfo.cs \ @@ -16,6 +16,9 @@ CSFILES=AssemblyInfo.cs \ gtk/PixbufVisualizer.cs \ $(GECKO_CSFILES) +GLADE_FILES=gtk/pixbufvis.glade $(GECKO_GLADE_FILES) +RESOURCES= /resource:./gtk/pixbufvis.glade,pixbufvis.glade $(GECKO_RESOURCES) + CSFLAGS=-g $(GECKO_FLAGS) noinst_DATA=DebuggerVisualizers.dll diff --git a/gecko/GeckoWindow.cs b/gecko/GeckoWindow.cs index 471533b..5d3ae83 100644 --- a/gecko/GeckoWindow.cs +++ b/gecko/GeckoWindow.cs @@ -43,7 +43,6 @@ namespace GeckoVisualizers public Widget CustomWidgetHandler (XML xml, string func_name, string name, string string1, string string2, int int1, int int2) { if (func_name.Equals ("CreateGeckoControl")) { - Console.WriteLine ("CreateGeckoControl"); return new Gecko.WebControl (); } diff --git a/gecko/geckovis.gladep b/gecko/geckovis.gladep deleted file mode 100644 index 1fb1124..0000000 --- a/gecko/geckovis.gladep +++ /dev/null @@ -1,8 +0,0 @@ - - - - - Geckovis - geckovis - FALSE - diff --git a/gecko/geckovis.gladep.bak b/gecko/geckovis.gladep.bak deleted file mode 100644 index 1fb1124..0000000 --- a/gecko/geckovis.gladep.bak +++ /dev/null @@ -1,8 +0,0 @@ - - - - - Geckovis - geckovis - FALSE - diff --git a/gtk/PixbufVisualizer.cs b/gtk/PixbufVisualizer.cs index e4fbb02..a22ecea 100644 --- a/gtk/PixbufVisualizer.cs +++ b/gtk/PixbufVisualizer.cs @@ -1,22 +1,99 @@ +using System; +using System.IO; +using System.Runtime.InteropServices; + using Gtk; using Gdk; +using Glade; + using MonoDevelop.DebuggerVisualizers; namespace GtkVisualizers { + class PixbufWindow + { + [Widget] Gtk.Dialog pixbuf_dialog; + [Widget] Gtk.Image pixbuf_image; + + public PixbufWindow (string title, Pixbuf pixbuf) + { + Glade.XML ui; + + ui = Glade.XML.FromAssembly ("pixbufvis.glade", "pixbuf_dialog", null); + ui.Autoconnect (this); + + pixbuf_dialog.Title = title; + pixbuf_image.Pixbuf = pixbuf; + } + + public void Show () + { + pixbuf_dialog.Run(); + pixbuf_dialog.Hide(); + } + + } + + // Debugger side class public class PixbufVisualizer : DialogDebuggerVisualizer { protected override void Show (IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider) { - Gtk.Window window = new Gtk.Window (Gtk.WindowType.Toplevel); - Gdk.Pixbuf pixbuf = (Gdk.Pixbuf) objectProvider.GetObject (); + Stream pixbuf_stream = objectProvider.GetData(); + BinaryReader reader = new BinaryReader (pixbuf_stream); - Widget image = new Gtk.Image(pixbuf); + bool has_alpha; + int bits_per_sample, width, height, rowstride; + Gdk.Pixbuf pixbuf; - window.Title = "Pixbuf Visualizer"; - window.Add (image); + has_alpha = reader.ReadBoolean (); + bits_per_sample = reader.ReadInt32 (); + width = reader.ReadInt32 (); + height = reader.ReadInt32 (); + rowstride = reader.ReadInt32 (); - window.ShowAll (); + int size = height * rowstride; + + byte[] pixbuf_data = new byte [size]; + + reader.Read (pixbuf_data, 0, size); + + pixbuf = new Pixbuf (Gdk.Colorspace.Rgb, has_alpha, bits_per_sample, width, height); + + Marshal.Copy (pixbuf_data, 0, pixbuf.Pixels, size); + + PixbufWindow win = new PixbufWindow ("Pixbuf Visualizer", pixbuf); + + win.Show (); + } + } + + // Debugee side class. This is necessary since Gdk.Pixbuf + // isn't serializable, a requirement for + // VisualizerObjectSource. + public class PixbufObjectSource : VisualizerObjectSource + { + void WriteBuf (Stream outgoingData, byte[] buf) + { + outgoingData.Write (buf, 0, buf.Length); + } + + public override void GetData (object target, Stream outgoingData) + { + Gdk.Pixbuf pixbuf = (Gdk.Pixbuf)target; + + WriteBuf (outgoingData, BitConverter.GetBytes (pixbuf.HasAlpha)); + WriteBuf (outgoingData, BitConverter.GetBytes (pixbuf.BitsPerSample)); + WriteBuf (outgoingData, BitConverter.GetBytes (pixbuf.Width)); + WriteBuf (outgoingData, BitConverter.GetBytes (pixbuf.Height)); + WriteBuf (outgoingData, BitConverter.GetBytes (pixbuf.Rowstride)); + + int size = pixbuf.Height * pixbuf.Rowstride; + + byte[] pixel_buf = new byte[size]; + Marshal.Copy (pixbuf.Pixels, pixel_buf, 0, size); + + WriteBuf (outgoingData, pixel_buf); } } } diff --git a/gecko/geckovis.glade.bak b/gtk/pixbufvis.glade similarity index 68% rename from gecko/geckovis.glade.bak rename to gtk/pixbufvis.glade index 4ea4003..2a6fb27 100644 --- a/gecko/geckovis.glade.bak +++ b/gtk/pixbufvis.glade @@ -3,15 +3,14 @@ - - 12 + True - gecko_dialog + dialog1 GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE True - 200 - 300 + 300 + 400 True False True @@ -55,12 +54,30 @@ - + True - CreateGeckoControl - 0 - 0 - Fri, 15 Apr 2005 01:01:08 GMT + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + GTK_SHADOW_IN + + + + True + 0.5 + 0.5 + 0 + 0 + + + + 0