2005-04-15 Chris Toshok <toshok@ximian.com>

* 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
This commit is contained in:
Chris Toshok 2005-04-15 07:46:56 +00:00
Родитель c832d72ff1
Коммит 87f4701dd6
8 изменённых файлов: 130 добавлений и 36 удалений

Просмотреть файл

@ -0,0 +1,14 @@
2005-04-15 Chris Toshok <toshok@ximian.com>
* 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.

Просмотреть файл

@ -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),

Просмотреть файл

@ -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

Просмотреть файл

@ -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 ();
}

Просмотреть файл

@ -1,8 +0,0 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
<glade-project>
<name>Geckovis</name>
<program_name>geckovis</program_name>
<gnome_support>FALSE</gnome_support>
</glade-project>

Просмотреть файл

@ -1,8 +0,0 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
<glade-project>
<name>Geckovis</name>
<program_name>geckovis</program_name>
<gnome_support>FALSE</gnome_support>
</glade-project>

Просмотреть файл

@ -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);
}
}
}

Просмотреть файл

@ -3,15 +3,14 @@
<glade-interface>
<widget class="GtkDialog" id="gecko_dialog">
<property name="border_width">12</property>
<widget class="GtkDialog" id="pixbuf_dialog">
<property name="visible">True</property>
<property name="title" translatable="yes">gecko_dialog</property>
<property name="title" translatable="yes">dialog1</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">True</property>
<property name="default_width">200</property>
<property name="default_height">300</property>
<property name="default_width">300</property>
<property name="default_height">400</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
@ -55,12 +54,30 @@
</child>
<child>
<widget class="Custom" id="gecko_control">
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="creation_function">CreateGeckoControl</property>
<property name="int1">0</property>
<property name="int2">0</property>
<property name="last_modification_time">Fri, 15 Apr 2005 01:01:08 GMT</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkViewport" id="viewport1">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkImage" id="pixbuf_image">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>