[Gtk-sharp-list] patch for gnome binding
Martin Willemoes Hansen
mwh@sysrq.dk
Mon, 12 Jul 2004 15:43:37 +0200
--=-mjtDFAiKRjVW1mUsYsQE
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
man, 2004-07-12 kl. 14:48 skrev Mike Kestner:
> On Mon, 2004-07-12 at 07:22, Mike Kestner wrote:
> > On Mon, 2004-07-12 at 03:55, Martin Willemoes Hansen wrote:
> >
> > > I made a little fix for the gnome-binding of gtk#, what do you think? Is
> > > it ok to commit?
> >
> > No, this is not the correct way to provide a subclassable ctor now. It
> > would be best to let the generator generate this ctor on its own now,
> > since there are no parameters to map.
>
> Okay, I see there isn't a void ctor for this. There is no need to have
> a disable_void_ctor attr on the class, as the generator doesn't generate
> that by default any more. So that can be removed.
>
> The new manual implementation should use CreateNativeObject to
> instantiate objects for subclasses:
>
> {
> if (GetType () != typeof (PrintJob)) {
> CreateNativeObject (new string [0], new GLib.Value [0]);
> return;
> }
>
> Raw = gnome_print_job_new (PrintConfig.Default().Handle);
> }
>
> The problem with that is there is currently no way to set a PrintConfig
> on a PrintJob, which should be done in the CreateNative branch. So in
> order to do this properly, you probably need to also add some glue to
> set the config field on the Job.
>
> Using the GType ctor, as you did in your patch, would require that all
> subclasses define a GType property. Even with that, the fact that you
> were still using gnome_print_job_new would mean that the type of the
> native object would always be Gnome.PrintJob, and not the subclassed
> type, which could cause problems with the object wrapping mechanism if
> the GC ever gets involved.
Okay, here is a quick try to implement the suggestions you mentioned,
what do you think?
Happy hacking!
--
Martin Willemoes Hansen
--=-mjtDFAiKRjVW1mUsYsQE
Content-Disposition: attachment; filename=gnome.diff
Content-Type: text/x-patch; name=gnome.diff; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Index: ChangeLog
===================================================================
RCS file: /cvs/public/gtk-sharp/ChangeLog,v
retrieving revision 1.877
diff -u -r1.877 ChangeLog
--- ChangeLog 9 Jul 2004 15:28:51 -0000 1.877
+++ ChangeLog 12 Jul 2004 12:45:19 -0000
@@ -1,3 +1,14 @@
+2004-07-12 Martin Willemoes Hansen <mwh@sysrq.dk>
+
+ * gnome/Gnome.metadata: Fixed typo i to 1
+ Hide GetConfig
+ Remove unnessesary disabledefaultconstructor
+ * gnome/PrintJob.custom: Removed ctor which was not inheritable
+ Added Gnome.PrintConfig Set and Get property
+ Added new inheritable ctor
+ * gnome/glue/printjob.c: Added glue code for PrintConfig set property
+
+
2004-07-09 Mike Kestner <mkestner@ximian.com>
* gdk/Gdk.metadata : mark gc param of Drawable.DrawPixbuf null_ok.
Index: gnome/Gnome.metadata
===================================================================
RCS file: /cvs/public/gtk-sharp/gnome/Gnome.metadata,v
retrieving revision 1.16
diff -u -r1.16 Gnome.metadata
--- gnome/Gnome.metadata 19 Jun 2004 14:46:11 -0000 1.16
+++ gnome/Gnome.metadata 12 Jul 2004 12:45:19 -0000
@@ -88,7 +88,7 @@
<attr path="/api/namespace/object[@cname='GnomeIconEntry']/method[@name='PickDialog']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GnomeIconList']/method[@cname='gnome_icon_list_construct']/*/*[@type='GtkAdjustment*']" name="null_ok">1</attr>
<attr path="/api/namespace/object[@cname='GnomeIconList']/constructor[@cname='gnome_icon_list_new']" name="hidden">1</attr>
- <attr path="/api/namespace/object[@cname='GnomeIconList']/method[@name='GetSelection']" name="hidden">i</attr>
+ <attr path="/api/namespace/object[@cname='GnomeIconList']/method[@name='GetSelection']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GnomeIconList']/method[@name='SetHadjustment']/*/*[@type='GtkAdjustment*']" name="null_ok">1</attr>
<attr path="/api/namespace/object[@cname='GnomeIconList']/method[@name='SetVadjustment']/*/*[@type='GtkAdjustment*']" name="null_ok">1</attr>
<attr path="/api/namespace/object[@cname='GnomeIconList']/signal[@name='FocusIcon']" name="name">IconFocused</attr>
@@ -101,7 +101,7 @@
<attr path="/api/namespace/object[@cname='GnomePrintDialog']/method/*/*[@type='const-guchar*']" name="type">const-gchar*</attr>
<attr path="/api/namespace/object[@cname='GnomePrintDialog']/constructor[@cname='gnome_print_dialog_new']/*/*[@type='const-guchar*']" name="type">const-gchar*</attr>
<attr path="/api/namespace/object[@cname='GnomePrintDialog']/constructor[@cname='gnome_print_dialog_new']/*/*[@name='flags']" name="type">GnomePrintDialogFlags</attr>
- <attr path="/api/namespace/object[@cname='GnomePrintJob']" name="disabledefaultconstructor">1</attr>
+ <attr path="/api/namespace/object[@cname='GnomePrintJob']/method[@name='GetConfig']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GnomePrintJobPreview']/constructor/*/*[@type='const-guchar*']" name="type">const-gchar*</attr>
<attr path="/api/namespace/object[@cname='GnomePrintMeta']/method/*/*[@name='filename']" name="type">const-gchar*</attr>
<attr path="/api/namespace/object[@cname='GnomePrintPdf']" name="parent">GObject</attr>
Index: gnome/PrintJob.custom
===================================================================
RCS file: /cvs/public/gtk-sharp/gnome/PrintJob.custom,v
retrieving revision 1.3
diff -u -r1.3 PrintJob.custom
--- gnome/PrintJob.custom 25 Jun 2004 18:42:18 -0000 1.3
+++ gnome/PrintJob.custom 12 Jul 2004 12:45:19 -0000
@@ -3,7 +3,7 @@
//
// Author: Martin Willemoes Hansen <mwh@sysrq.dk>
//
-// Copyright (C) 2003 Martin Willemoes Hansen
+// Copyright (C) 2003 2004 Martin Willemoes Hansen
//
// This code is inserted after the automatically generated code.
//
@@ -22,8 +22,37 @@
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
-
+[DllImport("gnomeprint-2-2")]
+static extern IntPtr gnome_print_job_get_config (IntPtr raw);
+
+[DllImport("gnomesharpglue")]
+extern static void gnome_print_job_set_print_config (IntPtr job, IntPtr config);
+
+public Gnome.PrintConfig Config {
+ get {
+ IntPtr raw_ret = gnome_print_job_get_config(Handle);
+ Gnome.PrintConfig ret;
+ if (raw_ret == IntPtr.Zero)
+ ret = null;
+ else
+ ret = (Gnome.PrintConfig) GLib.Object.GetObject(raw_ret);
+ return ret;
+ }
+
+ set {
+ gnome_print_job_set_print_config (Handle, value.Handle);
+ }
+}
+
public PrintJob() : base (IntPtr.Zero)
{
+ if (GetType () != typeof (PrintJob)) {
+ CreateNativeObject (new string [0], new GLib.Value [0]);
+ Config = PrintConfig.Default();
+ return;
+ }
+
Raw = gnome_print_job_new (PrintConfig.Default().Handle);
}
+
+
Index: gnome/glue/printjob.c
===================================================================
RCS file: gnome/glue/printjob.c
diff -N gnome/glue/printjob.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnome/glue/printjob.c 12 Jul 2004 12:45:19 -0000
@@ -0,0 +1,30 @@
+/* printjob.c : Glue for accessing fields in a GnomePrintJob
+ *
+ * Author: Martin Willemoes Hansen (mwh@sysrq.dk)
+ *
+ * Copyright (C) 2004 Martin Willemoes Hansen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the Lesser GNU General
+ * Public License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <libgnomecanvas/gnome-canvas.h>
+
+void gnomesharp_print_job_set_print_config (GnomePrintConfig *);
+
+void
+gnomesharp_print_job_set_print_config (GnomePrintConfig * config)
+{
+ config->config = config;
+}
--=-mjtDFAiKRjVW1mUsYsQE--