<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">

<refentry id="class-gladexml">
  <refnamediv>
    <refname>gtk.glade.XML</refname>
    <refpurpose>Allows dynamic loading of user interfaces
                from XML descriptions.</refpurpose>
  </refnamediv>

  <refsect1>
    <title>Synopsis</title>

     <classsynopsis language="python">
       <ooclass><classname>gtk.glade.XML</classname></ooclass>
       <ooclass><classname><link
linkend="class-gobject">gobject.GObject</link></classname></ooclass>
       <constructorsynopsis language="python">
         <methodname><link 
linkend="constructor-gladexml">gtk.glade.XML</link></methodname>
         <methodparam><parameter role="keyword">fname</parameter></methodparam>
         <methodparam><parameter role="keyword">root</parameter><initializer><literal>None</literal></initializer></methodparam>
         <methodparam><parameter role="keyword">domain</parameter><initializer><literal>""</literal></initializer></methodparam>
         <methodparam><parameter role="keyword">typedict</parameter><initializer><literal>{}</literal></initializer></methodparam>  </constructorsynopsis>
       <methodsynopsis language="python">
         <methodname><link linkend="method-gladexml--signal-connect">signal_connect</link></methodname>
         <methodparam><parameter>handler_name</parameter></methodparam>
         <methodparam><parameter>func</parameter></methodparam>
       </methodsynopsis><methodsynopsis language="python">
         <methodname><link linkend="method-gladexml--signal-autoconnect">signal_autoconnect</link></methodname>
         <methodparam><parameter role="keyword">dict</parameter></methodparam>
       </methodsynopsis><methodsynopsis language="python">
         <methodname><link linkend="method-gladexml--get-widget">get_widget</link></methodname>
         <methodparam><parameter role="keyword">name</parameter></methodparam>
       </methodsynopsis><methodsynopsis language="python">
         <methodname><link linkend="method-gladexml--get-widget-prefix">get_widget_prefix</link></methodname>
         <methodparam><parameter role="keyword">name</parameter></methodparam>
       </methodsynopsis><methodsynopsis language="python">
         <methodname><link linkend="method-gladexml--relative-file">relative_file</link></methodname>
         <methodparam><parameter role="keyword">filename</parameter></methodparam>
       </methodsynopsis>
     </classsynopsis>

<programlisting>
<emphasis role="bold">Functions</emphasis>

<methodsynopsis language="python">
  <methodname><link linkend="function-glade--xml-new-from-buffer">gtk.glade.xml_new_from_buffer</link></methodname>
    <methodparam><parameter role="keyword">buffer</parameter></methodparam>
    <methodparam><parameter role="keyword">size</parameter></methodparam>
    <methodparam><parameter role="keyword">root</parameter><initializer><literal>""</literal></initializer></methodparam>
    <methodparam><parameter role="keyword">domain</parameter><initializer><literal>""</literal></initializer></methodparam>
    <methodparam><parameter role="keyword">typedict</parameter><initializer><literal>{}</literal></initializer></methodparam>
  </methodsynopsis><methodsynopsis language="python">
    <methodname><link linkend="function-glade--get-widget-name">gtk.glade.get_widget_name</link></methodname>
    <methodparam><parameter role="keyword">widget</parameter></methodparam>
  </methodsynopsis><methodsynopsis language="python">
    <methodname><link linkend="function-glade--get-widget-tree">gtk.glade.get_widget_tree</link></methodname>
    <methodparam><parameter role="keyword">widget</parameter></methodparam>
  </methodsynopsis><methodsynopsis language="python">
    <methodname><link linkend="function-glade--set-custom-handler">gtk.glade.set_custom_handler</link></methodname>
    <methodparam><parameter>handler</parameter></methodparam>
    <methodparam><parameter>user_data</parameter></methodparam>
  </methodsynopsis><methodsynopsis language="python">
    <methodname><link linkend="function-glade--bindtextdomain">gtk.glade.bindtextdomain</link></methodname>
    <methodparam><parameter role="keyword">domainname</parameter></methodparam>
    <methodparam><parameter role="keyword">dirname</parameter><initializer><literal>""</literal></initializer></methodparam>
  </methodsynopsis><methodsynopsis language="python">
    <methodname><link linkend="function-glade--textdomain">gtk.glade.textdomain</link></methodname>
    <methodparam><parameter role="keyword">domainname</parameter><initializer><literal>""</literal></initializer></methodparam>
  </methodsynopsis><methodsynopsis language="python">
    <methodname><link linkend="function-glade--set-custom-widget-callbacks">gtk.glade.set_custom_widget_callbacks</link></methodname>
    <methodparam><parameter role="keyword">dict</parameter></methodparam>
  </methodsynopsis></programlisting>
</refsect1>

  <refsect1>
    <title>Ancestry</title>

    <synopsis>+-- <link linkend="class-gobject">gobject.GObject</link>
      +-- <link linkend="class-gladexml">gtk.glade.XML</link>
    </synopsis>

  </refsect1>

  <refsect1 id="signal-prototypes-gladexml">
    <title>gtk.glade.XML Signal Prototypes</title>

    <para><link linkend="signal-prototypes-gobject">gobject.GObject Signal Prototypes</link></para>
</refsect1>

  <refsect1>
    <title>Description</title>

      <para>This object represents an `instantiation' of an XML interface
description.  When one of these objects is created, the XML file is read,
and the interface is created. The <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link> object
then provides an interface for accessing the widgets in the interface by the
names assigned to them inside the XML description.</para>

      <para>The <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link> object
can also be used to connect handlers to the named signals in the
description.  Libglade also provides an interface by which it can look up
the signal handler names in the program's symbol table and automatically
connect as many handlers up as it can that way.</para>

  </refsect1>

  <refsect1 id="constructor-gladexml">
    <title>Constructor</title>

    <programlisting><constructorsynopsis language="python">
        <methodname>gtk.glade.XML</methodname>
        <methodparam><parameter role="keyword">fname</parameter></methodparam>
        <methodparam><parameter role="keyword">root</parameter><initializer><literal>None</literal></initializer></methodparam>
        <methodparam><parameter role="keyword">domain</parameter><initializer><literal>""</literal></initializer></methodparam>
        <methodparam><parameter role="keyword">typedict</parameter><initializer><literal>{}</literal></initializer></methodparam>
      </constructorsynopsis></programlisting>

    <variablelist>
      <varlistentry>
	<term><parameter role="keyword">fname</parameter>&nbsp;:</term>
	<listitem><simpara>the XML file name</simpara></listitem>
      </varlistentry>
      <varlistentry>
	<term><parameter role="keyword">root</parameter>&nbsp;:</term>
	<listitem><simpara>the widget node in <parameter>fname</parameter> to
start building from (or <literal>None</literal>)</simpara></listitem>
      </varlistentry>
      <varlistentry>
	<term><parameter role="keyword">domain</parameter>&nbsp;:</term>
	<listitem><simpara>the translation domain for the XML file (or
<literal>""</literal> for default)</simpara></listitem>
      </varlistentry>
      <varlistentry>
	<term><parameter role="keyword">typedict</parameter>&nbsp;:</term>
	<listitem><simpara>A dictionary used to lookup types (or
<literal>{}</literal> for default)</simpara></listitem>
      </varlistentry>
      <varlistentry>
	<term><emphasis>Returns</emphasis>&nbsp;:</term>
	<listitem>
          <simpara>a new <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link>
object</simpara>
        </listitem>
      </varlistentry>
    </variablelist>

    <para>Creates a new <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link> object
(and the corresponding widgets) from the XML file specified by
<parameter>fname</parameter>. Optionally it will only build the interface
from the widget node specified by <parameter>root</parameter> (if it is not
<literal>None</literal>).  This feature is useful if you only want to build
say a toolbar or menu from the XML file, but not the window it is embedded
in. Note also that the XML parse tree is cached to speed up creating another
<link linkend="class-gladexml"><classname>gtk.glade.XML</classname></link>
object for the same file.</para>

  </refsect1>

  <refsect1>
    <title>Methods</title>

    <refsect2 id="method-gladexml--signal-connect">
      <title>gtk.glade.XML.signal_connect</title>

      <programlisting><methodsynopsis language="python">
          <methodname>signal_connect</methodname>
	  <methodparam><parameter>handler_name</parameter></methodparam>
	  <methodparam><parameter>func</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter>handler_name</parameter>&nbsp;:</term>
	  <listitem><simpara>the signal handler name</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>func</parameter>&nbsp;:</term>
	  <listitem><simpara>the signal handler function</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>In the glade interface descriptions, signal handlers are
specified for widgets by name. The <methodname>signal_connect</methodname>()
method allows you to connect a callback specified by
<parameter>func</parameter> to all signals in the <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link> file
with the signal handler name specified by
<parameter>handler_name</parameter>.</para>

    </refsect2>

    <refsect2 id="method-gladexml--signal-autoconnect">
      <title>gtk.glade.XML.signal_autoconnect</title>

      <programlisting><methodsynopsis language="python">
          <methodname>signal_autoconnect</methodname>
	  <methodparam><parameter role="keyword">dict</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">dict</parameter>&nbsp;:</term>
	  <listitem><simpara>a mapping or an instance</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>signal_autoconnect</methodname>() method is a
variation of the <link
linkend="method-gladexml--signal-connect">gtk.glade.XML.signal_connect</link>
method. It uses Python's introspective features to look at the keys (if
<parameter>dict</parameter> is a mapping) or attributes (if
<parameter>dict</parameter> is an instance) and tries to match them with the
signal handler names given in the interface description. The callbacks
referenced by each matched key or attribute are connected to their matching
signals. The argument is called <literal>dict</literal> due to compatibility
reasons since originally only the mapping interface was supported. The
instance variant was introduced in PyGTK 2.0.</para>

    </refsect2>

    <refsect2 id="method-gladexml--get-widget">
      <title>gtk.glade.XML.get_widget</title>

      <programlisting><methodsynopsis language="python">
          <methodname>get_widget</methodname>
	  <methodparam><parameter role="keyword">name</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">name</parameter>&nbsp;:</term>
	  <listitem><simpara>the name of the widget</simpara></listitem>
	</varlistentry>
        <varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem>
            <simpara>the widget matching the name or
<literal>None</literal></simpara>
          </listitem>
        </varlistentry>
      </variablelist>

      <para>The <methodname>get_widget</methodname>() method returns a
reference to the <link
linkend="class-gtkwidget"><classname>gtk.Widget</classname></link> specified
by <parameter>name</parameter> in the interface
description. <literal>None</literal> is returned, if
<parameter>name</parameter> doesn't specify a widget in the
interface.</para>

    </refsect2>

    <refsect2 id="method-gladexml--get-widget-prefix">
      <title>gtk.glade.XML.get_widget_prefix</title>

      <programlisting><methodsynopsis language="python">
          <methodname>get_widget_prefix</methodname>
	  <methodparam><parameter role="keyword">name</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">name</parameter>&nbsp;:</term>
	  <listitem><simpara>the prefix the widget names or
<literal>""</literal> for all widgets</simpara></listitem>
	</varlistentry>
        <varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem>
            <simpara>A list of widgets that match <parameter>name</parameter>
as the start of their name or <literal>None</literal></simpara>
          </listitem>
        </varlistentry>
      </variablelist>

      <para>The <methodname>get_widget_prefix</methodname>() method returns
a list of interface <link
linkend="class-gtkwidget"><classname>gtk.Widget</classname></link> objects
that have names prefixed by
<parameter>name</parameter>. <literal>None</literal> is returned if no
interface widget names match the prefix <parameter>name</parameter>.</para>

    </refsect2>

    <refsect2 id="method-gladexml--relative-file">
      <title>gtk.glade.XML.relative_file</title>

      <programlisting><methodsynopsis language="python">
          <methodname>relative_file</methodname>
	  <methodparam><parameter role="keyword">filename</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">filename</parameter>&nbsp;:</term>
	  <listitem><simpara>a relative file pathname</simpara></listitem>
	</varlistentry>
        <varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem>
            <simpara>the absolute file pathname</simpara>
          </listitem>
        </varlistentry>
      </variablelist>

      <para>The <methodname>relative_file</methodname>() method resolves the
relative pathname specified by <parameter>filename</parameter>, using the
directory of the XML file as a base. If <parameter>filename</parameter>
contains an absolute pathname, then the original file name is
returned.</para>

    </refsect2>

  </refsect1>

  <refsect1>
    <title>Functions</title>

    <refsect2 id="function-glade--xml-new-from-buffer">
      <title>gtk.glade.xml_new_from_buffer</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>gtk.image_new_from_buffer</methodname>
          <methodparam><parameter role="keyword">buffer</parameter></methodparam>
          <methodparam><parameter role="keyword">size</parameter></methodparam>
          <methodparam><parameter role="keyword">root</parameter><initializer><literal>""</literal></initializer></methodparam>
          <methodparam><parameter role="keyword">domain</parameter><initializer><literal>""</literal></initializer></methodparam>
          <methodparam><parameter role="keyword">typedict</parameter><initializer><literal>{}</literal></initializer></methodparam>
	</methodsynopsis></programlisting>

      <variablelist>
        <varlistentry>
  	  <term><parameter role="keyword">buffer</parameter>&nbsp;:</term>
  	  <listitem><simpara>the string containing the XML buffer</simpara></listitem>
        </varlistentry>
        <varlistentry>
  	  <term><parameter role="keyword">size</parameter>&nbsp;:</term>
  	  <listitem><simpara>size of the string</simpara></listitem>
        </varlistentry>
        <varlistentry>
  	  <term><parameter role="keyword">root</parameter>&nbsp;:</term>
  	  <listitem><simpara>the widget node in fname to start building from
(or <literal>""</literal>)</simpara></listitem>
        </varlistentry>
        <varlistentry>
  	  <term><parameter role="keyword">domain</parameter>&nbsp;:</term>
  	  <listitem><simpara>the translation domain for the XML file (or
<literal>""</literal> for default)</simpara></listitem>
        </varlistentry>
        <varlistentry>
  	  <term><parameter role="keyword">typedict</parameter>&nbsp;:</term>
  	  <listitem><simpara>A dictionary used to lookup types (or
<literal>{}</literal> for default)</simpara></listitem>
        </varlistentry>
        <varlistentry>
  	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
  	  <listitem>
            <simpara>a new <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link>
 object.</simpara>
          </listitem>
        </varlistentry>
      </variablelist>
  
      <para>The <function>gtk.glade.xml_new_from_buffer</function>()
function creates a new <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link> object
(and the corresponding widgets) from the string specified by
<parameter>buffer</parameter>. Optionally it will only build the interface
from the widget node specified by <parameter>root</parameter> (if it is not
<literal>""</literal>).  This feature is useful if you only want to build
say a toolbar or menu from the XML document, but not the window it is
embedded in.</para>

    </refsect2>

    <refsect2 id="function-glade--get-widget-name">
      <title>gtk.glade.get_widget_name</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>gtk.glade.get_widget_name</methodname>
          <methodparam><parameter role="keyword">widget</parameter></methodparam>
	</methodsynopsis></programlisting>

      <variablelist>
        <varlistentry>
  	  <term><parameter role="keyword">widget</parameter>&nbsp;:</term>
  	  <listitem><simpara>a <link
linkend="class-gtkwidget"><classname>gtk.Widget</classname></link></simpara></listitem>
        </varlistentry>
        <varlistentry>
  	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
  	  <listitem>
            <simpara>the name of the widget</simpara>
          </listitem>
        </varlistentry>
      </variablelist>
  
      <para>The <function>gtk.glade.get_widget_name</function>() function
returns the name of the <link
linkend="class-gtkwidget"><classname>gtk.Widget</classname></link> specified
by <parameter>widget</parameter> that was generated by a <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link>
object.</para>

    </refsect2>

    <refsect2 id="function-glade--get-widget-tree">
      <title>gtk.glade.get_widget_tree</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>gtk.glade.get_widget_tree</methodname>
          <methodparam><parameter role="keyword">widget</parameter></methodparam>
	</methodsynopsis></programlisting>

      <variablelist>
        <varlistentry>
  	  <term><parameter role="keyword">widget</parameter>&nbsp;:</term>
  	  <listitem><simpara>a <link
linkend="class-gtkwidget"><classname>gtk.Widget</classname></link></simpara></listitem>
        </varlistentry>
        <varlistentry>
  	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
  	  <listitem>
            <simpara>the <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link>
object that built <parameter>widget</parameter></simpara>
          </listitem>
        </varlistentry>
      </variablelist>
  
      <para>This <function>gtk.glade.get_widget_tree</function>() function
is used to get the <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link> object
that built the <link
linkend="class-gtkwidget"><classname>gtk.Widget</classname></link> specified
by <parameter>widget</parameter>.</para>

    </refsect2>
    
<refsect2 id="function-glade--set-custom-handler">
  <title>gtk.glade.set_custom_handler</title>

  <programlisting><methodsynopsis language="python">
	  <methodname>gtk.glade.set_custom_handler</methodname>
      <methodparam><parameter role="keyword">handler</parameter></methodparam>
      <methodparam><parameter role="keyword">user_data</parameter></methodparam>
  	</methodsynopsis></programlisting>

    <variablelist>
      <varlistentry>
    	  <term><parameter role="keyword">handler</parameter>&nbsp;:</term>
  	    <listitem><simpara>the custom widget handler.</simpara></listitem>
      </varlistentry>
      <varlistentry>
    	  <term><parameter role="keyword">user_data</parameter>&nbsp;:</term>
  	    <listitem><simpara>user data passed to the custom handler.</simpara></listitem>
      </varlistentry>
    </variablelist>
  
  <para>This <function>gtk.glade.set_custom_handler</function>() function 
    allows you to override the default behaviour when a Custom widget is found in an interface.
  </para>
</refsect2>

<refsect2 id="function-glade--bindtextdomain">
  <title>gtk.glade.bindtextdomain</title>

  <programlisting><methodsynopsis language="python">
	  <methodname>gtk.glade.bindtextdomain</methodname>
      <methodparam><parameter role="keyword">domainname</parameter></methodparam>
      <methodparam><parameter role="keyword">dirname</parameter></methodparam>
  	</methodsynopsis></programlisting>

    <variablelist>
      <varlistentry>
    	  <term><parameter role="keyword">domainname</parameter>&nbsp;:</term>
  	    <listitem><simpara>the name of the application.</simpara></listitem>
      </varlistentry>
      <varlistentry>
    	  <term><parameter role="keyword">dirname</parameter>&nbsp;:</term>
  	    <listitem><simpara>the directory where to find locales.</simpara></listitem>
      </varlistentry>
      <varlistentry>
    	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
    	  <listitem><simpara>the value of <parameter>dirname</parameter></simpara></listitem>
      </varlistentry>
    </variablelist>
  
  <para>This <function>gtk.glade.bindtextdomain</function>() function allows you to use internationalisation with glade.
  </para>
</refsect2>

<refsect2 id="function-glade--textdomain">
  <title>gtk.glade.textdomain</title>

  <programlisting><methodsynopsis language="python">
	  <methodname>gtk.glade.textdomain</methodname>
      <methodparam><parameter role="keyword">domainname</parameter></methodparam>
  	</methodsynopsis></programlisting>

    <variablelist>
      <varlistentry>
    	  <term><parameter role="keyword">domainname</parameter>&nbsp;:</term>
  	    <listitem><simpara>the name of the application.</simpara></listitem>
      </varlistentry>
      <varlistentry>
    	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
    	  <listitem><simpara>the value of <parameter>domainname</parameter></simpara></listitem>
      </varlistentry>
    </variablelist>
  
  <para>This <function>gtk.glade.textdomain</function>() function allows you to use internationalisation with glade.
  </para>
</refsect2>

<refsect2 id="function-glade--set-custom-widget-callbacks">
  <title>gtk.glade.set_custom_widget_callbacks</title>

  <programlisting><methodsynopsis language="python">
	  <methodname>gtk.glade.set_custom_widget_callbacks</methodname>
      <methodparam><parameter role="keyword">dict</parameter></methodparam>
  	</methodsynopsis></programlisting>

    <variablelist>
      <varlistentry>
    	  <term><parameter role="keyword">dict</parameter>&nbsp;:</term>
  	    <listitem><simpara>a dictionary of function names.</simpara></listitem>
      </varlistentry>
    </variablelist>
  
  <para>This <function>gtk.glade.set_custom_widget_callbacks</function>() function 
  takes a dictionary of function names->functions, for an example see 
  <ulink url="http://www.async.com.br/faq/pygtk/index.py">PyGTK FAQ 22.7</ulink>
  for an example.
  </para>
</refsect2>
</refsect1>
</refentry>
