Blob Blame History Raw
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Widget Adaptor Definitions: Glade User Interface Designer Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="Glade User Interface Designer Reference Manual">
<link rel="up" href="catalog.html" title="Part I. Adding your custom widgets">
<link rel="prev" href="catalogintro.html" title="Introducing the Glade Catalog">
<link rel="next" href="properties.html" title="Property Class Definitions">
<meta name="generator" content="GTK-Doc V1.28 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="catalog.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="catalogintro.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="properties.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="widgetclasses"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle">Widget Adaptor Definitions</span></h2>
<p>Widget Classes — 
Adding support for custom widgets 
    </p>
</td>
<td class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="id-1.2.3.3"></a><h2>Forward</h2>
<p>
Widget support in Glade is provided by the <a class="link" href="gladeui-glade-widget-adaptor.html#GladeWidgetAdaptor"><span class="type">GladeWidgetAdaptor</span></a> object, each
`glade-widget-class' definition in the catalog will result in the creation
of an adaptor, which inherits the funcionality of the adaptor created for its
parent, or the closest adaptor available in the ancestry. Adaptor methods can
be overridden by functions in the plugin by specifying them in the catalog.
There is also a wealth of options you can use in the `glade-widget-class' without
writing code.
    </p>
<p>
A typical basic example of a widget class definition is as follows:
      </p>
<pre class="programlisting">
&lt;glade-widget-class name="FooFrobnicator" generic-name="frobnicator" title="Frobnicator"/&gt;</pre>
<p>
    </p>
<p>
Here is the complete example of the form of the `glade-widget-class' definition:
      </p>
<pre class="programlisting">
&lt;glade-widget-class name="FooFrobnicator" generic-name="frobnicator" title="Frobnicator"/&gt;
  &lt;post-create-function&gt;foo_frobnicator_plugin_post_create&lt;/post-create-function&gt;

  ... widget class support functions go here

  &lt;properties&gt;
    &lt;property id="frobnicated" default="False"/&gt;

    ... property definitions go here
  &lt;/properties&gt;

  &lt;signals&gt;
    &lt;signal id="frobnicate" since="1.0"/&gt;

    ... signal definitions go here
  &lt;/signals&gt;

  &lt;packing-properties&gt;
    ... child packing property definitions go here
  &lt;/packing-properties&gt;

  &lt;actions&gt;
    &lt;action id="launch_editor" name="Edit Frob" stock="gtk-edit"/&gt;

    ... context menu action definitions go here
  &lt;/actions&gt;

  &lt;packing-actions&gt;
    ... context menu action definitions for child objects go here
  &lt;/packing-actions&gt;

  &lt;packing-defaults&gt;
    &lt;parent-class name="GtkVBox"&gt;
      &lt;child-property id="expand" default="false"/&gt;
    &lt;/parent-class&gt;

    ... packing default definitions go here
  &lt;/packing-defaults&gt;
&lt;/glade-widget-class&gt;</pre>
<p>
    </p>
</div>
<div class="refsect1">
<a name="id-1.2.3.4"></a><h2>Widget Class Properties</h2>
<p>
The following are all properies of the `glade-widget-class' tag
    </p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">name</span></p></td>
<td><p>
The class name of the widget; unless the 'get-type-function' property is present, 
this will essentially be used to instantiate the actual class by deriving 
'gtk_label_get_type' from 'GtkLabel' and searching for 'gtk_label_get_type' in the 
support library.
          </p></td>
</tr>
<tr>
<td><p><span class="term">since</span></p></td>
<td><p>
A 'major.minor' formed version describing the version of the owning catalog in which this 
object class was introduced; example: <code class="literal">since="1.0"</code>.
          </p></td>
</tr>
<tr>
<td><p><span class="term">deprecated</span></p></td>
<td><p>
A boolean property depicting that this widget is currently deprecated.
          </p></td>
</tr>
<tr>
<td><p><span class="term">builder-unsupported</span></p></td>
<td><p>
A boolean property depicting that this widget is not supported by <a href="/usr/share/gtk-doc/html/gtk3/GtkBuilder.html#GtkBuilder-struct"><span class="type">GtkBuilder</span></a>.
          </p></td>
</tr>
<tr>
<td><p><span class="term">get-type-function</span></p></td>
<td><p>
Used to explicitly specify the name of the function used to get the type of the widget.  
It is optional, but if it is not present, the 'name' property will be used to guess the
name of the function, a process that could lead to unexpected results.
          </p></td>
</tr>
<tr>
<td><p><span class="term">generic-name</span></p></td>
<td><p>
Used to generate a default name for instances of the
widget in the UI editor. It is also used in conjunction with the 'icon-prefix'
to form an icon name for the widget.
          </p></td>
</tr>
<tr>
<td><p><span class="term">icon-name</span></p></td>
<td><p>
Used to explicitly set an icon name for this widget.
These icon names are looked up in the current icon theme to retrieve an icon for
the widget.
          </p></td>
</tr>
<tr>
<td><p><span class="term">title</span></p></td>
<td><p>
Used to display the name of the class in the palette and widget 
tree and will be translated before use in the interface.
          </p></td>
</tr>
<tr>
<td><p><span class="term">parent</span></p></td>
<td><p>
Use this to specify the name of the parent your widget derives from, you
can use this option instead of loading a real widget type (this allows you
to fake derive and still add properties and run your catalog independantly
of any plugins or libraries).
          </p></td>
</tr>
<tr>
<td><p><span class="term">toplevel</span></p></td>
<td><p>
Used to know whether this widget class is toplevel or not
in Glade context. This property will be inherited from the adaptors parent.
          </p></td>
</tr>
<tr>
<td><p><span class="term">fixed</span></p></td>
<td><p>
Used to mark a <span class="type">GladeWidgetClass</span> for free form placement capacities
to be handled with a <span class="type">GladeFixed</span>. This property will be inherited from the adaptors parent.
          </p></td>
</tr>
<tr>
<td><p><span class="term">use-placeholders</span></p></td>
<td><p>
Used to inform the core about adaptors that implement
<a href="/usr/share/gtk-doc/html/gtk3/GtkContainer.html#GtkContainer-struct"><span class="type">GtkContainer</span></a> editing, and whether or not they use <a class="link" href="GladePlaceholder.html" title="GladePlaceholder"><span class="type">GladePlaceholder</span></a>. This property will 
be inherited from the adaptors parent.
          </p></td>
</tr>
<tr>
<td><p><span class="term">default-width</span></p></td>
<td><p>
The default width to load a <a href="/usr/share/gtk-doc/html/gtk3/GtkWindow.html#GtkWindow-struct"><span class="type">GtkWindow</span></a> derived widget in the <a class="link" href="GladeDesignView.html" title="GladeDesignView"><span class="type">GladeDesignView</span></a>.
This property will be inherited from the adaptors parent.
          </p></td>
</tr>
<tr>
<td><p><span class="term">default-height</span></p></td>
<td><p>
The default height to load a <a href="/usr/share/gtk-doc/html/gtk3/GtkWindow.html#GtkWindow-struct"><span class="type">GtkWindow</span></a> derived widget in the <a class="link" href="GladeDesignView.html" title="GladeDesignView"><span class="type">GladeDesignView</span></a>.
This property will be inherited from the adaptors parent.
          </p></td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="id-1.2.3.5"></a><h2>Adapter Methods</h2>
<p>
The following are all child tags of the `glade-widget-class' tag
    </p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">constructor-function</span></p></td>
<td><p>
Used to override the actual <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject-struct"><span class="type">GObject</span></a> constructor of the said <a class="link" href="gladeui-glade-widget-adaptor.html#GladeWidgetAdaptor"><span class="type">GladeWidgetAdaptor</span></a>
          </p></td>
</tr>
<tr>
<td><p><span class="term">post-create-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladePostCreateFunc" title="GladePostCreateFunc ()"><span class="type">GladePostCreateFunc</span></a> support function that gets called whenever a widget of the said class is instantiated.
          </p></td>
</tr>
<tr>
<td><p><span class="term">deep-post-create-function</span></p></td>
<td><p>
Same as `post-create-function' except in that you must always chain up
to the super class definition as a rule.
          </p></td>
</tr>
<tr>
<td><p><span class="term">get-property-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladeGetPropertyFunc" title="GladeGetPropertyFunc ()"><span class="type">GladeGetPropertyFunc</span></a> to get values of properties on an instance in the
runtime.
          </p></td>
</tr>
<tr>
<td><p><span class="term">set-property-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladeSetPropertyFunc" title="GladeSetPropertyFunc ()"><span class="type">GladeSetPropertyFunc</span></a> to set values of properties on an instance in the
runtime.
          </p></td>
</tr>
<tr>
<td><p><span class="term">verify-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladeVerifyPropertyFunc" title="GladeVerifyPropertyFunc ()"><span class="type">GladeVerifyPropertyFunc</span></a> to set values of properties on an instance in the
runtime.
          </p></td>
</tr>
<tr>
<td><p><span class="term">add-child-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladeAddChildFunc" title="GladeAddChildFunc ()"><span class="type">GladeAddChildFunc</span></a> to add children to instances in the runtime.
          </p></td>
</tr>
<tr>
<td><p><span class="term">remove-child-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladeRemoveChildFunc" title="GladeRemoveChildFunc ()"><span class="type">GladeRemoveChildFunc</span></a> to remove children from instances in the runtime.
          </p></td>
</tr>
<tr>
<td><p><span class="term">replace-child-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladeReplaceChildFunc" title="GladeReplaceChildFunc ()"><span class="type">GladeReplaceChildFunc</span></a> to replace children inside instances in the runtime.
          </p></td>
</tr>
<tr>
<td><p><span class="term">get-children-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladeGetChildrenFunc" title="GladeGetChildrenFunc ()"><span class="type">GladeGetChildrenFunc</span></a> to get a list of children inside instances in the runtime.
          </p></td>
</tr>
<tr>
<td><p><span class="term">child-get-property-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladeChildGetPropertyFunc" title="GladeChildGetPropertyFunc ()"><span class="type">GladeChildGetPropertyFunc</span></a> to get packing properties from instances in the runtime.
          </p></td>
</tr>
<tr>
<td><p><span class="term">child-set-property-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladeChildSetPropertyFunc" title="GladeChildSetPropertyFunc ()"><span class="type">GladeChildSetPropertyFunc</span></a> to set packing properties on instances in the runtime.
          </p></td>
</tr>
<tr>
<td><p><span class="term">child-verify-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladeChildVerifyPropertyFunc" title="GladeChildVerifyPropertyFunc ()"><span class="type">GladeChildVerifyPropertyFunc</span></a> to verify packing properties on instances in the runtime.
          </p></td>
</tr>
<tr>
<td><p><span class="term">get-internal-child-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladeGetInternalFunc" title="GladeGetInternalFunc ()"><span class="type">GladeGetInternalFunc</span></a> to retrieve an internal child of a composite object in the runtime.
          </p></td>
</tr>
<tr>
<td><p><span class="term">action-activate-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladeActionActivateFunc" title="GladeActionActivateFunc ()"><span class="type">GladeActionActivateFunc</span></a> to run a routine for a plugin defined <a class="link" href="GladeWidgetAction.html" title="GladeWidgetAction"><span class="type">GladeWidgetAction</span></a>.
          </p></td>
</tr>
<tr>
<td><p><span class="term">child-action-activate-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladeChildActionActivateFunc" title="GladeChildActionActivateFunc ()"><span class="type">GladeChildActionActivateFunc</span></a> to run a routine for a plugin defined packing <a class="link" href="GladeWidgetAction.html" title="GladeWidgetAction"><span class="type">GladeWidgetAction</span></a>.
          </p></td>
</tr>
<tr>
<td><p><span class="term">read-widget-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladeReadWidgetFunc" title="GladeReadWidgetFunc ()"><span class="type">GladeReadWidgetFunc</span></a> to load a widget from the xml.
          </p></td>
</tr>
<tr>
<td><p><span class="term">write-widget-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladeWriteWidgetFunc" title="GladeWriteWidgetFunc ()"><span class="type">GladeWriteWidgetFunc</span></a> to write a widget from the xml.
          </p></td>
</tr>
<tr>
<td><p><span class="term">read-child-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladeReadWidgetFunc" title="GladeReadWidgetFunc ()"><span class="type">GladeReadWidgetFunc</span></a> to read a child to the xml.
          </p></td>
</tr>
<tr>
<td><p><span class="term">write-child-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladeWriteWidgetFunc" title="GladeWriteWidgetFunc ()"><span class="type">GladeWriteWidgetFunc</span></a> to write a child to the xml.
          </p></td>
</tr>
<tr>
<td><p><span class="term">create-editor-property-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladeCreateEPropFunc" title="GladeCreateEPropFunc ()"><span class="type">GladeCreateEPropFunc</span></a> to create widgets to be used in Glade's property editor.
          </p></td>
</tr>
<tr>
<td><p><span class="term">string-from-value-function</span></p></td>
<td><p>
A <a class="link" href="gladeui-glade-widget-adaptor.html#GladeStringFromValueFunc" title="GladeStringFromValueFunc ()"><span class="type">GladeStringFromValueFunc</span></a> to create a string from a <a href="/usr/share/gtk-doc/html/gobject/gobject-Generic-values.html#GValue"><span class="type">GValue</span></a>, these strings must
be unique and comparable for undo/redo to work properly.
          </p></td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="id-1.2.3.6"></a><h2>Action Definitions</h2>
<p>
Actions are added under the `actions' and `packing-actions' tags, actions can also
be nested so as to allow grouping in context menus, example:
      </p>
<pre class="programlisting">
...

&lt;action id="manage_frobs" name="Manage Frobs"&gt;
  &lt;action id="add_frob" name="Add" stock="gtk-add"/&gt;
  &lt;action id="remove_frob" name="Remove" stock="gtk-remove"/&gt;
&lt;/action&gt;

...</pre>
<p>
    </p>
<p>
Here are the meanings of the `action' tag's properties:
    </p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">id</span></p></td>
<td><p>
The string identifier for this action, the action_path argument to your <a class="link" href="gladeui-glade-widget-adaptor.html#GladeActionActivateFunc" title="GladeActionActivateFunc ()"><span class="type">GladeActionActivateFunc</span></a>
will be a combination if this id and any parents, for the above example: 
<code class="literal">"manage_frobs/add_frob"</code>.
          </p></td>
</tr>
<tr>
<td><p><span class="term">name</span></p></td>
<td><p>
A string to be displayed in the UI for this action.
          </p></td>
</tr>
<tr>
<td><p><span class="term">stock</span></p></td>
<td><p>
An optional Gtk stock icon to represent this action.
          </p></td>
</tr>
<tr>
<td><p><span class="term">important</span></p></td>
<td><p>
A boolean option to add emphasis to this action; currently actions marked as `important' 
are added to the toolbar.
          </p></td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="id-1.2.3.7"></a><h2>Packing Defaults</h2>
<p>
Default values can be specified for packing properties on your widget when added
to a said type of parent, as the example shows above; use the `parent-class' to 
specify what parent (or derivative of that parent) you are targetting and fill
in any `child-property' tags you need for that parent using `id' property to 
specify the property name and the `default' property for the value.
    </p>
</div>
<div class="refsect1">
<a name="id-1.2.3.8"></a><h2>Signals</h2>
<p>
The signal elements are currently only needed for versioning support, use
the `signal' child tag as described above and set signal `id' to be supported
since version `since'. Signals are initialized to be supported since the
introducing <a class="link" href="gladeui-glade-widget-adaptor.html#GladeWidgetAdaptor"><span class="type">GladeWidgetAdaptor</span></a> was supported.
    </p>
</div>
<div class="refsect1">
<a name="id-1.2.3.9"></a><h2>Icons</h2>
<p>
The Glade palette and other components use icons to represent the various widget classes. 
It is a good idea to provide icons for your widget classes, as this
enhances the user interface.
    </p>
<p>
Glade uses the GTK+ GtkIconTheme facility to provide icons for widget classes. Any icon
available in the current icon theme can be used as an icon for a widget class.
    </p>
<p>
By default, an icon name of the format "widget-CATALOG_NAME-GENERIC_NAME"
is assigned to every widget class. CATALOG_NAME is the value of catalog name attribute, 
and GENERIC_NAME is the value of an widget class's generic name attribute.
    </p>
<p>
To explicity set an icon name for a widget class, the "icon-name" attribute of the
"glade-widget-class" element can be specified. This will override the default icon 
name assigned to the widget class.
    </p>
<p>
Icon files can be installed under any system icon theme folder.
    </p>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.28</div>
</body>
</html>