[Gtk-sharp-list] GTK# App with multiple windows, where doesApplication.Init() and Application.Run() go?

Nigel Benns nigel_benns@rogers.com
Thu, 31 Mar 2005 12:47:52 -0500 (EST)


------=_20050331124752_88372
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

I have it :)

I found it googling once.

> Come to think of it.... I did that using xslt once and it worked quite
> nice.
> Perhaps I'll find it somewhere on one of my backups.
> I didn't think anybody would be interested .....
>
> -----Oorspronkelijk bericht-----
> Van: gtk-sharp-list-admin@lists.ximian.com
> [mailto:gtk-sharp-list-admin@lists.ximian.com] Namens Rafael Teixeira
> Verzonden: woensdag 30 maart 2005 19:30
> Aan: Vincent Arnoux
> CC: gtk-sharp-list@lists.ximian.com
> Onderwerp: Re: [Gtk-sharp-list] GTK# App with multiple windows, where
> doesApplication.Init() and Application.Run() go?
>
> AFAIK, No!!!
>
> As a quick first try, someone could cook up a xslt transform to make
> just that...
>
> A better solution would involve CodeDom to generate the source for any
> registered language as is currently done in System.Web for ASP.NET
> pages.
>
> Both depend on building driving utilities for them to complete the
> needed information such as classname and namespace, and also possibly
> to deal with inheritance and custom widgets.
>
> HIH,
>
>
> On Wed, 30 Mar 2005 14:52:26 +0200, Vincent Arnoux
> <vincent.arnoux@rfo.atmel.com> wrote:
>> Hi,
>> A quick question (I am afraid I won't like the answer): does an
>> application to transform a Glade XML file into Gtk# code exist ?
>>
>> Vincent
>>
>>
>> _______________________________________________
>> Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>>
>
>
> --
> Rafael "Monoman" Teixeira
> ---------------------------------------
> I'm trying to become a "Rosh Gadol" before my own eyes.
> See http://www.joelonsoftware.com/items/2004/12/06.html for enlightment.
> It hurts!
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.308 / Virus Database: 266.8.3 - Release Date: 25/03/2005
>
>
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.308 / Virus Database: 266.8.3 - Release Date: 25/03/2005
>
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>

------=_20050331124752_88372
Content-Type: text/xml; name="glade2cs.xsl"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="glade2cs.xsl"

<?xml version='1.0'?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--

GLADEC#Sheet v1.0.0.0, Copyright Timothy Parez (c) 2003
A xsl stylesheet to generate C# code from glade files.

This program is free software
You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation
Either version 2 of the License, or (at your option) any later version.
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 General Public License for more details.


TODO: Add support for gnome widgets


 -->
<xsl:template match="/">
 <b>// GladeApp.cs</b><br/><br/>
 <table border="0">
  <tr>
   <td width="70px"></td>
   <td width="70px"></td>
   <td width="70px"></td>
   <td width="270px"></td>
   <td width="270px"></td>
  </tr>

  <tr>
   <td colspan="5">namespace GladeApp</td>
  </tr>
  
  <tr>
   <td colspan="5">{</td>
  </tr>
  
  <tr>
  <td></td>
  <td colspan="4">using System;</td>
  </tr>
  
  <tr>
  <td></td>
  <td colspan="4">using Gtk;</td>
  </tr>

  <!-- No Support for Gnome Widgets yet
  <tr>
  <td></td>
  <td colspan="4">using Gnome;</td>
  </tr>
  -->

  <tr>
  <td></td>
  <td colspan="4">using Glade;</td>
  </tr>
  
  <tr>
  <td></td>
  <td colspan="4">using GtkSharp;</td>
  </tr>
  
  <tr>
  <td></td>
  <td colspan="4"><br/>public class MyApplication<br/>{</td>
  </tr>
  
  <tr>
  <td/>
  <td/>
  <td colspan="3">static void Main()</td>
  </tr>
  
  <tr>
  <td/>
  <td/>
  <td colspan="3">{</td>
  </tr>

  <tr>
  <td/>
  <td/>
  <td/>
  <td colspan="2">MyApplication MyApp = new MyApplication();               
  </td>
  </tr>

  <tr>
  <td/>
  <td/>
  <td colspan="3">}</td>
  </tr>  
  
  <tr>
  <td colspan="5"><br/></td>
  </tr>  
  
  <!-- Constructor -->
  
  <tr>
  <td/>
  <td/>
  <td colspan="3">public MyApplication()</td>
  </tr>
  
  <tr>
  <td/>
  <td/>
  <td colspan="3">{</td>
  </tr>

  <tr>
  <td/>
  <td/>
  <td/>
  <td colspan="2">Application.Init();<br/><br/>
  <xsl:for-each select="//widget[@class='GtkWindow']">
  <xsl:value-of select="@id"/><xsl:text> </xsl:text>window<xsl:number/><xsl:text> </xsl:text>=<xsl:text> </xsl:text>new<xsl:text> </xsl:text><xsl:value-of select="@id"/>();<br/><br/>
  </xsl:for-each>
  Application.Run();                  
  </td>
  </tr>
  
  <tr>
  <td/>
  <td/>
  <td colspan="3">}</td>
  </tr>
  
  <tr>  
  <td></td>
  <td colspan="4">}</td>
  </tr>
  
  <tr>
  <td colspan="4">}</td>
  </tr>
  
 </table>
 <br/>
 <hr/>
 <br/>

 <!-- The GTK windows -->
 <xsl:for-each select="//widget[@class='GtkWindow']">
 <b>// <xsl:value-of select="@id"/>.cs</b><br/>
 <table border="0">
  <tr>
   <td width="70px"></td>
   <td width="70px"></td>
   <td width="70px"></td>
   <td width="270px"></td>
   <td width="270px"></td>
  </tr>

  <tr>
   <td colspan="5">namespace GladeApp</td>
  </tr>

  <tr>
   <td colspan="5">{</td>
  </tr>

  <tr>
  <td></td>
  <td colspan="4">using System;</td>
  </tr>

  <tr>
  <td></td>
  <td colspan="4">using Gtk;</td>
  </tr>

  <!-- No support for Gnome Widgets yet
  <tr>
  <td></td>
  <td colspan="4">using Gnome;</td>
  </tr>
  -->

  <tr>
  <td></td>
  <td colspan="4">using Glade;</td>
  </tr>

  <tr>
  <td></td>
  <td colspan="4">using GtkSharp;</td>
  </tr>

  <tr>
  <td></td>
  <td colspan="4"><br/>public class <xsl:value-of select="@id"/><br/>{</td>
  </tr>

  <tr>
   <td></td>
   <td></td>
   <td colspan="3">
    <xsl:variable name="test-value" select="substring(@class,4,string-length(@class) - 3)"/>
    [Glade.Widget]<br/>
    <xsl:if test="$test-value='Window'">
		Window<xsl:text> </xsl:text>Inner<xsl:value-of select="@id"/>;
    </xsl:if>
    <xsl:if test="not($test-value='Window')">
   		<xsl:value-of select="$test-value"/><xsl:text> </xsl:text><xsl:value-of select="@id"/>;
    </xsl:if>
    <br/><xsl:apply-templates select="child"/>
   </td>
  </tr>

  <!-- Constructor -->
  <tr>
  <td></td>
  <td></td>
  <td colspan="3"><br/>public <xsl:value-of select="@id"/>()<br/>{</td>
  </tr>

  <tr>
  <td></td>
  <td></td>
  <td></td>
  <td colspan="2">

  Glade.XML gxml<xsl:number/> = new Glade.XML("gladeapp.glade","<xsl:value-of select="@id"/>",null);<br/>
  gxml<xsl:number/>.Autoconnect(this);

  </td>
  </tr>

  <tr>
  <td></td>
  <td></td>
  <td colspan="3">}</td>
  </tr>

  <tr>
  <td></td>
  <td></td>
  <td colspan="3"><xsl:apply-templates select=".//signal"/></td>
  </tr>

  <tr>
  <td></td>
  <td colspan="3">}</td>
  </tr>

  <tr>
  <td colspan="4">}</td>
  </tr>
</table>

  <br/>
  <hr/>
  <br/>
 </xsl:for-each>
</xsl:template>

<xsl:template match="child"><xsl:apply-templates select="widget"/></xsl:template>

<xsl:template match="widget"><br/>
		[Glade.Widget]<br/>
                <xsl:value-of select="substring(@class,4,string-length(@class) - 3)"/><xsl:text> </xsl:text><xsl:value-of select="@id"/>;<br/>
		<xsl:apply-templates select="child"/>
</xsl:template>

<xsl:template match="signal">
		<br/>public void <xsl:value-of select="@handler"/>(System.Object obj, EventArgs e)<br/>
		{<br/><br/>
		}<br/>
</xsl:template> 

</xsl:stylesheet>
------=_20050331124752_88372--