|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
[PATCH] Fix custom CellRenderer creationHi,
While I was working on creating a custom cell renderer for a project of mine, I found that once I tried to override the Render method, and simply call the base one, the program would crash with an error in the native code. The attached patch makes custom CellRenderer behave, although it might be a bit hackish: the other functions that use "ref Gtk.Rectangle" for the native call also have it in the managed interface, but since I didn't want to change the interface (which I'm pretty sure would be a bad thing™) I kept the ref only in the subsequent call. It *should* be fine since the rectangles shouldn't be modified as far as I can see. I'm also attaching a simple testcase, if you're interested in seeing what the problem is. I also have another problem here: how do I make sure the Windows gtk# also have this applied? Should I rebuild it myself, or using the .dll file built on (Gentoo) Linux with that patch should be enough? Thanks, -- Diego Elio Pettenò — “Flameeyes” http://blog.flameeyes.eu/ If you found a .asc file in this mail and know not what it is, it's a GnuPG digital signature: http://www.gnupg.org/ [gtk-sharp-2.12.9-cellrenderer.patch] Index: gtk-sharp-2.12.9/gtk/CellRenderer.custom =================================================================== --- gtk-sharp-2.12.9.orig/gtk/CellRenderer.custom +++ gtk-sharp-2.12.9/gtk/CellRenderer.custom @@ -80,7 +80,7 @@ } [DllImport("gtksharpglue-2")] - static extern void gtksharp_cellrenderer_base_render (IntPtr handle, IntPtr window, IntPtr widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, Gtk.CellRendererState flags); + static extern void gtksharp_cellrenderer_base_render (IntPtr handle, IntPtr window, IntPtr widget, ref Gdk.Rectangle background_area, ref Gdk.Rectangle cell_area, ref Gdk.Rectangle expose_area, Gtk.CellRendererState flags); [DllImport("gtksharpglue-2")] static extern void gtksharp_cellrenderer_override_render (IntPtr gtype, RenderDelegate cb); @@ -112,15 +112,15 @@ [GLib.DefaultSignalHandler (Type=typeof(Gtk.CellRenderer), ConnectionMethod="OverrideRender")] protected virtual void Render (Gdk.Drawable window, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, Gtk.CellRendererState flags) { - gtksharp_cellrenderer_base_render (Handle, window.Handle, widget.Handle, background_area, cell_area, expose_area, flags); + gtksharp_cellrenderer_base_render (Handle, window.Handle, widget.Handle, ref background_area, ref cell_area, ref expose_area, flags); } [DllImport("gtksharpglue-2")] - static extern void gtksharp_cellrenderer_invoke_render (IntPtr gtype, IntPtr handle, IntPtr window, IntPtr widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, Gtk.CellRendererState flags); + static extern void gtksharp_cellrenderer_invoke_render (IntPtr gtype, IntPtr handle, IntPtr window, IntPtr widget, ref Gdk.Rectangle background_area, ref Gdk.Rectangle cell_area, ref Gdk.Rectangle expose_area, Gtk.CellRendererState flags); internal static void InternalRender (GLib.GType gtype, Gtk.CellRenderer cell, Gdk.Drawable window, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, Gtk.CellRendererState flags) { - gtksharp_cellrenderer_invoke_render (gtype.Val, cell.Handle, window.Handle, widget.Handle, background_area, cell_area, expose_area, flags); + gtksharp_cellrenderer_invoke_render (gtype.Val, cell.Handle, window.Handle, widget.Handle, ref background_area, ref cell_area, ref expose_area, flags); } [DllImport("gtksharpglue-2")] [MainWindow.cs] using System; using Gtk; public partial class MainWindow: Gtk.Window { public class CellRendererString : CellRendererText { [GLib.Property("object")] public object Object { get; set; } public override void GetSize (Gtk.Widget widget, ref Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height) { Text = Object.ToString(); base.GetSize (widget, ref cell_area, out x_offset, out y_offset, out width, out height); } protected override void Render (Gdk.Drawable window, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, Gtk.CellRendererState flags) { Text = Object.ToString(); base.Render (window, widget, background_area, cell_area, expose_area, flags); } } public MainWindow (): base (Gtk.WindowType.Toplevel) { Build (); ListStore ls = new ListStore(typeof(object)); treeview1.Model = ls; treeview1.AppendColumn("Test", new CellRendererString(), "object", 0); ls.AppendValues(DateTime.Now); ls.AppendValues(System.Guid.NewGuid()); } protected void OnDeleteEvent (object sender, DeleteEventArgs a) { Application.Quit (); a.RetVal = true; } } _______________________________________________ Gtk-sharp-list maillist - Gtk-sharp-list@... http://lists.ximian.com/mailman/listinfo/gtk-sharp-list |
|
|
Re: [PATCH] Fix custom CellRenderer creationI'm looking forward to learning the answer to this as well, but I have a feeling is simply involves writing text on a Drawable area. SpoodyGoon Diego Elio “Flameeyes” Pettenò wrote: Hi, While I was working on creating a custom cell renderer for a project of mine, I found that once I tried to override the Render method, and simply call the base one, the program would crash with an error in the native code. The attached patch makes custom CellRenderer behave, although it might be a bit hackish: the other functions that use "ref Gtk.Rectangle" for the native call also have it in the managed interface, but since I didn't want to change the interface (which I'm pretty sure would be a bad thing™) I kept the ref only in the subsequent call. It *should* be fine since the rectangles shouldn't be modified as far as I can see. I'm also attaching a simple testcase, if you're interested in seeing what the problem is. I also have another problem here: how do I make sure the Windows gtk# also have this applied? Should I rebuild it myself, or using the .dll file built on (Gentoo) Linux with that patch should be enough? Thanks, --
Andy
York
(aka Spoody Goon)
Please
Note:
Proper
Email Forwarding Use BCC
_______________________________________________ Gtk-sharp-list maillist - Gtk-sharp-list@... http://lists.ximian.com/mailman/listinfo/gtk-sharp-list |
|
|
Re: [PATCH] Fix custom CellRenderer creationDiego Elio “Flameeyes” Pettenò wrote:
> Hi, > > While I was working on creating a custom cell renderer for a project of > mine, I found that once I tried to override the Render method, and > simply call the base one, the program would crash with an error in the > native code. > > The attached patch makes custom CellRenderer behave, although it might > be a bit hackish: the other functions that use "ref Gtk.Rectangle" for > the native call also have it in the managed interface, but since I > didn't want to change the interface (which I'm pretty sure would be a > bad thing™) I kept the ref only in the subsequent call. It *should* be > fine since the rectangles shouldn't be modified as far as I can see. > trunk/2.90 is correct). Thank you very much for the fix and the test case. > I also have another problem here: how do I make sure the Windows gtk# > also have this applied? Should I rebuild it myself, or using the .dll > file built on (Gentoo) Linux with that patch should be enough? > You can use the Linux dll if you fix the calling convention by using the gapi-cdecl-insert script in the Gtk# 2.12 repo (or just wait for 2.12.10). Christian _______________________________________________ Gtk-sharp-list maillist - Gtk-sharp-list@... http://lists.ximian.com/mailman/listinfo/gtk-sharp-list |
| Free embeddable forum powered by Nabble | Forum Help |