[Gtk-sharp-list] Various enhancements to GnomePrint patch

Martin Willemoes Hansen mwh@sysrq.dk
Tue, 07 Oct 2003 13:43:53 +0200


--=-QhcTbwgr32LQ3i6ykb14
Content-Type: multipart/alternative; boundary="=-EQGs+Drjiyco9lT+Pjhg"


--=-EQGs+Drjiyco9lT+Pjhg
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Mon, 2003-10-06 at 22:35, Mike Kestner wrote: 

> Hi Martin,
> 
> On Mon, 2003-10-06 at 05:13, Martin Willemoes Hansen wrote:
> > Vups found one more bug, here is a new patch.
> 
> Thanks for the patch. 
> 
> A few comments.  Please try to include things in one diff.  You can have
> new files in the diff by doing a cvs add and using the -N option on your
> cvs diff command.


Thanks for letting me know, I will do it that way from now.


> Of course, lose the garbage gdk-api.xml change.

Sure


>        <method name="Get" cname="gnome_print_config_get">
> -        <return-type type="guchar*"/>
> +        <return-type type="const-gchar*"/>
> 
> Did you verify that the returned string here is not owned by the
> caller?  If you go marking stuff const that isn't const, it's going to
> leak.

Oh yes, im no C expert, but I would like to be. Here is the C function.

gnome-print-config.c
guchar *
gnome_print_config_get (GnomePrintConfig *config, const guchar *key)
{
        guchar *val;
                                                                                                  
        g_return_val_if_fail (config != NULL, NULL);
        g_return_val_if_fail (key != NULL, NULL);
        g_return_val_if_fail (*key != '\0', NULL);
                                                                                                  
        val = gpa_node_get_path_value (config->node, key);
                                                                                                  
        return val;
}

Can you or anyone else, explain me if its okay to use const gchar* as
return parameter?


> -          <parameter type="gint" name="flags"/>
> +          <parameter type="GnomePrintDialogFlags*" name="flags"/>
>          </parameters>
> 
> You really want that '*' there?  I don't know this api, but it would
> seem strange for a gint to actually be a pointer to an enumerated type.


Oh I thought it should be there to make the parser happy ;) I have
removed it.


Finally I have a new patch incorporating the changes mentioned above.





-- 
Martin Willemoes Hansen

--------------------------------------------------------
E-Mail	mwh@sysrq.dk	Website	mwh.sysrq.dk
IRC     MWH, freenode.net
--------------------------------------------------------               


--=-EQGs+Drjiyco9lT+Pjhg
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.0.9">
</HEAD>
<BODY>
On Mon, 2003-10-06 at 22:35, Mike Kestner wrote: 
<BLOCKQUOTE TYPE=CITE>
<PRE><FONT COLOR="#737373"><I>Hi Martin,

On Mon, 2003-10-06 at 05:13, Martin Willemoes Hansen wrote:
&gt; Vups found one more bug, here is a new patch.

Thanks for the patch. 

A few comments.  Please try to include things in one diff.  You can have
new files in the diff by doing a cvs add and using the -N option on your
cvs diff command.</I></FONT></PRE>
</BLOCKQUOTE>
<BR>
Thanks for letting me know, I will do it that way from now.<BR>
<BR>
<BLOCKQUOTE TYPE=CITE>
<PRE><FONT COLOR="#737373"><I>Of course, lose the garbage gdk-api.xml change.</I></FONT></PRE>
</BLOCKQUOTE>
Sure<BR>
<BR>
<BLOCKQUOTE TYPE=CITE>
<PRE><FONT COLOR="#737373"><I>       &lt;method name=&quot;Get&quot; cname=&quot;gnome_print_config_get&quot;&gt;
-        &lt;return-type type=&quot;guchar*&quot;/&gt;
+        &lt;return-type type=&quot;const-gchar*&quot;/&gt;

Did you verify that the returned string here is not owned by the
caller?  If you go marking stuff const that isn't const, it's going to
leak.</I></FONT></PRE>
</BLOCKQUOTE>
Oh yes, im no C expert, but I would like to be. Here is the C function.<BR>
<BR>
gnome-print-config.c<BR>
guchar *<BR>
gnome_print_config_get (GnomePrintConfig *config, const guchar *key)<BR>
{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; guchar *val;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp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YPE=CITE>
<PRE><FONT COLOR="#737373"><I>-          &lt;parameter type=&quot;gint&quot; name=&quot;flags&quot;/&gt;
+          &lt;parameter type=&quot;GnomePrintDialogFlags*&quot; name=&quot;flags&quot;/&gt;
         &lt;/parameters&gt;

You really want that '*' there?  I don't know this api, but it would
seem strange for a gint to actually be a pointer to an enumerated type.</I></FONT></PRE>
</BLOCKQUOTE>
<BR>
Oh I thought it should be there to make the parser happy ;) I have removed it.<BR>
<BR>
<BR>
Finally I have a new patch incorporating the changes mentioned above.
<PRE>

</PRE>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<PRE>-- 
Martin Willemoes Hansen

--------------------------------------------------------
E-Mail	mwh@sysrq.dk	Website	mwh.sysrq.dk
IRC     MWH, freenode.net
--------------------------------------------------------               
</PRE>
</TD>
</TR>
</TABLE>

</BODY>
</HTML>

--=-EQGs+Drjiyco9lT+Pjhg--

--=-QhcTbwgr32LQ3i6ykb14
Content-Disposition: attachment; filename=GnomePrintFixes.diff
Content-Type: text/x-patch; name=GnomePrintFixes.diff; charset=iso-8859-1
Content-Transfer-Encoding: 7bit

? GnomePrintFixes.diff
Index: ChangeLog
===================================================================
RCS file: /cvs/public/gtk-sharp/ChangeLog,v
retrieving revision 1.484
diff -u -r1.484 ChangeLog
--- ChangeLog	5 Oct 2003 00:37:24 -0000	1.484
+++ ChangeLog	7 Oct 2003 11:35:02 -0000
@@ -1,3 +1,12 @@
+2003-10-06  Martin Willemoes Hansen  <mwh@sysrq.dk>
+
+	* gnome/PrintJob.custom: Added default ctor.
+	* gnome/PrintDialog.custom: Added overloaded ctor with fewer parameters.
+	* sources/Gnome.metadata: Disabled default ctor for PrintJob,
+	  changed type from int to PrintDialogFlags for PrintDialog ctor and
+	  changed return type from byte to string for PrintConfig.Get.
+	* api/Makefile: Added gtkhtml-api.xml 
+
 2003-10-04  Mike Kestner  <mkestner@ximian.com>
 
 	* generator/CallbackGen.cs : remove CloseWriter call.
Index: api/gnome-api.xml
===================================================================
RCS file: /cvs/public/gtk-sharp/api/gnome-api.xml,v
retrieving revision 1.17
diff -u -r1.17 gnome-api.xml
--- api/gnome-api.xml	2 Oct 2003 15:48:36 -0000	1.17
+++ api/gnome-api.xml	7 Oct 2003 11:35:06 -0000
@@ -4937,7 +4937,7 @@
         </parameters>
       </method>
       <method name="Get" cname="gnome_print_config_get">
-        <return-type type="guchar*"/>
+        <return-type type="const-gchar*"/>
         <parameters>
           <parameter type="const-gchar*" name="key"/>
         </parameters>
@@ -5056,7 +5056,7 @@
         </parameters>
       </constructor>
     </object>
-    <object name="PrintJob" cname="GnomePrintJob" parent="GObject">
+    <object name="PrintJob" cname="GnomePrintJob" parent="GObject" disabledefaultconstructor="1">
       <method name="Close" cname="gnome_print_job_close">
         <return-type type="gint"/>
       </method>
@@ -6512,7 +6512,7 @@
         <parameters>
           <parameter type="GnomePrintJob*" name="gpj"/>
           <parameter type="const-gchar*" name="title"/>
-          <parameter type="gint" name="flags"/>
+          <parameter type="GnomePrintDialogFlags" name="flags"/>
         </parameters>
       </constructor>
       <method name="SetCopies" cname="gnome_print_dialog_set_copies">
Index: gnome/PrintDialog.custom
===================================================================
RCS file: gnome/PrintDialog.custom
diff -N gnome/PrintDialog.custom
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnome/PrintDialog.custom	7 Oct 2003 11:35:09 -0000
@@ -0,0 +1,12 @@
+//
+// PrintDialog.custom - customizations
+//
+// Author: Martin Willemoes Hansen <mwh@sysrq.dk>
+//
+// Copyright (C) 2003 Martin Willemoes Hansen
+//
+// This code is inserted after the automatically generated code.
+//
+	
+public PrintDialog (Gnome.PrintJob gpj, string title) 
+	: this (gpj, title, 0) {}
Index: gnome/PrintJob.custom
===================================================================
RCS file: gnome/PrintJob.custom
diff -N gnome/PrintJob.custom
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnome/PrintJob.custom	7 Oct 2003 11:35:09 -0000
@@ -0,0 +1,14 @@
+//
+// PrintJob.custom - customizations
+//
+// Author: Martin Willemoes Hansen <mwh@sysrq.dk>
+//
+// Copyright (C) 2003 Martin Willemoes Hansen
+//
+// This code is inserted after the automatically generated code.
+//
+	
+public PrintJob()
+{
+	Raw = gnome_print_job_new (PrintConfig.Default().Handle);
+}
Index: sources/Gnome.metadata
===================================================================
RCS file: /cvs/public/gtk-sharp/sources/Gnome.metadata,v
retrieving revision 1.12
diff -u -r1.12 Gnome.metadata
--- sources/Gnome.metadata	29 Sep 2003 11:05:30 -0000	1.12
+++ sources/Gnome.metadata	7 Oct 2003 11:35:09 -0000
@@ -319,6 +319,17 @@
   </data>
 </rule>
 
+<!-- disable default constructor -->
+<rule>
+  <class name="GnomePrintJob"/>
+  <data>
+    <attribute target="class">
+      <name>disabledefaultconstructor</name>
+      <value>1</value>
+    </attribute>
+  </data>
+</rule>
+
 <!-- misc -->
 <rule>
   <class name="GnomeAbout">
@@ -332,6 +343,18 @@
     </attribute>
  </data>
 </rule>
+<rule>
+  <class name="GnomePrintDialog">
+    <method>gnome_print_dialog_new</method>
+  </class>
+  <data>
+    <attribute target="params">
+      <filter level="name">flags</filter>
+      <name>type</name>
+      <value>GnomePrintDialogFlags</value>
+    </attribute>
+  </data>
+</rule>
 
 <!-- Use const-gchar* instead of const-guchar*, when the value is realy a string -->
 <rule>
@@ -494,6 +517,9 @@
     <method>GetPsName</method>
     <method>GetSample</method>
     <method>GetSpeciesName</method>
+  </class>
+  <class name="GnomePrintConfig">
+    <method>Get</method>
   </class>
   <data>
     <attribute target="return">

--=-QhcTbwgr32LQ3i6ykb14--