Appendix B. Glade Examples

Example 1

A simple example that shows a single warning window is shown below.

The XML file generated by glade that contains this layout is below.

<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">

<glade-interface>
<requires lib="gnome"/>

<widget class="GtkDialog" id="MainWindow">
  <property name="border_width">6</property>
  <property name="visible">True</property>
  <property name="title" translatable="yes">Useless Program</property>
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  <property name="window_position">GTK_WIN_POS_NONE</property>
  <property name="modal">False</property>
  <property name="resizable">False</property>
  <property name="destroy_with_parent">False</property>
  <property name="has_separator">False</property>
  <signal name="delete_event" handler="gtk_main_quit" last_modification_time="Mon, 15 Mar 2004 23:13:27 GMT"/>

  <child internal-child="vbox">
    <widget class="GtkVBox" id="dialog-vbox">
      <property name="visible">True</property>
      <property name="homogeneous">False</property>
      <property name="spacing">12</property>

      <child internal-child="action_area">
	<widget class="GtkHButtonBox" id="dialog-action_area">
	  <property name="visible">True</property>
	  <property name="layout_style">GTK_BUTTONBOX_END</property>

	  <child>
	    <widget class="GtkButton" id="OKButton">
	      <property name="visible">True</property>
	      <property name="can_default">True</property>
	      <property name="can_focus">True</property>
	      <property name="label">gtk-ok</property>
	      <property name="use_stock">True</property>
	      <property name="relief">GTK_RELIEF_NORMAL</property>
	      <property name="response_id">-5</property>
	      <signal name="clicked" handler="ok_button_clicked" last_modification_time="Mon, 15 Mar 2004 23:14:00 GMT"/>
	    </widget>
	  </child>
	</widget>
	<packing>
	  <property name="padding">0</property>
	  <property name="expand">False</property>
	  <property name="fill">True</property>
	  <property name="pack_type">GTK_PACK_END</property>
	</packing>
      </child>

      <child>
	<widget class="GtkHBox" id="InfoBox">
	  <property name="border_width">6</property>
	  <property name="visible">True</property>
	  <property name="homogeneous">False</property>
	  <property name="spacing">12</property>

	  <child>
	    <widget class="GtkImage" id="InfoImage">
	      <property name="visible">True</property>
	      <property name="stock">gtk-dialog-warning</property>
	      <property name="icon_size">6</property>
	      <property name="xalign">0.5</property>
	      <property name="yalign">0</property>
	      <property name="xpad">0</property>
	      <property name="ypad">0</property>
	    </widget>
	    <packing>
	      <property name="padding">0</property>
	      <property name="expand">False</property>
	      <property name="fill">False</property>
	    </packing>
	  </child>

	  <child>
	    <widget class="GtkLabel" id="InfoLabel">
	      <property name="visible">True</property>
	      <property name="label" translatable="yes">&lt;span weight=&quot;bold&quot; size=&quot;larger&quot;&gt;This program does nothing useful&lt;/span&gt;

No code has yet been added to this program to do anything other than display this short warning.  This program will now close.</property>
	      <property name="use_underline">False</property>
	      <property name="use_markup">True</property>
	      <property name="justify">GTK_JUSTIFY_LEFT</property>
	      <property name="wrap">True</property>
	      <property name="selectable">False</property>
	      <property name="xalign">0.5</property>
	      <property name="yalign">0.5</property>
	      <property name="xpad">0</property>
	      <property name="ypad">0</property>
	    </widget>
	    <packing>
	      <property name="padding">0</property>
	      <property name="expand">False</property>
	      <property name="fill">False</property>
	    </packing>
	  </child>
	</widget>
	<packing>
	  <property name="padding">0</property>
	  <property name="expand">False</property>
	  <property name="fill">False</property>
	</packing>
      </child>
    </widget>
  </child>
</widget>

</glade-interface>

Example 2

A simple example that shows the usage of a progress bar is shown below.

The XML file generated by glade that contains this layout is below.

<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">

<glade-interface>
<requires lib="gnome"/>

<widget class="GtkWindow" id="WasteTimeWindow">
  <property name="border_width">12</property>
  <property name="visible">True</property>
  <property name="title" translatable="yes">Wasting your time</property>
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  <property name="window_position">GTK_WIN_POS_NONE</property>
  <property name="modal">False</property>
  <property name="resizable">True</property>
  <property name="destroy_with_parent">False</property>
  <signal name="delete_event" handler="inform_user_of_time_wasted" last_modification_time="Thu, 18 Mar 2004 03:07:48 GMT"/>

  <child>
    <widget class="GtkVBox" id="TheProgressStuffies">
      <property name="visible">True</property>
      <property name="homogeneous">False</property>
      <property name="spacing">12</property>

      <child>
	<widget class="GtkProgressBar" id="Progress Bar">
	  <property name="visible">True</property>
	  <property name="orientation">GTK_PROGRESS_LEFT_TO_RIGHT</property>
	  <property name="fraction">0</property>
	  <property name="pulse_step">0.1</property>
	  <property name="text" translatable="yes"></property>
	</widget>
	<packing>
	  <property name="padding">0</property>
	  <property name="expand">False</property>
	  <property name="fill">False</property>
	</packing>
      </child>

      <child>
	<widget class="GtkLabel" id="ProgressInfo">
	  <property name="visible">True</property>
	  <property name="label" translatable="yes">Please wait while your time is wasted...</property>
	  <property name="use_underline">False</property>
	  <property name="use_markup">False</property>
	  <property name="justify">GTK_JUSTIFY_LEFT</property>
	  <property name="wrap">False</property>
	  <property name="selectable">False</property>
	  <property name="xalign">0.5</property>
	  <property name="yalign">0.5</property>
	  <property name="xpad">0</property>
	  <property name="ypad">0</property>
	</widget>
	<packing>
	  <property name="padding">0</property>
	  <property name="expand">False</property>
	  <property name="fill">False</property>
	</packing>
      </child>
    </widget>
  </child>
</widget>

</glade-interface>

Example 3

A simple example that shows toggle buttons is shown below.

The XML file generated by glade that contains this layout is below.

<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">

<glade-interface>
<requires lib="gnome"/>

<widget class="GtkWindow" id="OptionWindow">
  <property name="visible">True</property>
  <property name="title" translatable="yes">Here's some choices</property>
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  <property name="window_position">GTK_WIN_POS_NONE</property>
  <property name="modal">False</property>
  <property name="resizable">True</property>
  <property name="destroy_with_parent">False</property>
  <signal name="delete_event" handler="delete_handler" object="OohTellMe" last_modification_time="Thu, 18 Mar 2004 16:37:26 GMT"/>

  <child>
    <widget class="GtkVBox" id="AllTheOptions">
      <property name="border_width">12</property>
      <property name="visible">True</property>
      <property name="homogeneous">False</property>
      <property name="spacing">0</property>

      <child>
	<widget class="GtkCheckButton" id="SensitivityCheckButton">
	  <property name="visible">True</property>
	  <property name="can_focus">True</property>
	  <property name="label" translatable="yes">_Make other option sensitive</property>
	  <property name="use_underline">True</property>
	  <property name="relief">GTK_RELIEF_NORMAL</property>
	  <property name="active">False</property>
	  <property name="inconsistent">False</property>
	  <property name="draw_indicator">True</property>
	  <signal name="toggled" handler="sensitivity_toggled" object="OohTellMe" last_modification_time="Thu, 18 Mar 2004 15:02:15 GMT"/>
	</widget>
	<packing>
	  <property name="padding">0</property>
	  <property name="expand">False</property>
	  <property name="fill">False</property>
	</packing>
      </child>

      <child>
	<widget class="GtkHBox" id="TheSubOptionStuff">
	  <property name="visible">True</property>
	  <property name="homogeneous">False</property>
	  <property name="spacing">0</property>

	  <child>
	    <widget class="GtkLabel" id="SpacerLabel">
	      <property name="visible">True</property>
	      <property name="label" translatable="yes"></property>
	      <property name="use_underline">False</property>
	      <property name="use_markup">False</property>
	      <property name="justify">GTK_JUSTIFY_LEFT</property>
	      <property name="wrap">False</property>
	      <property name="selectable">False</property>
	      <property name="xalign">0.5</property>
	      <property name="yalign">0.5</property>
	      <property name="xpad">0</property>
	      <property name="ypad">0</property>
	    </widget>
	    <packing>
	      <property name="padding">9</property>
	      <property name="expand">False</property>
	      <property name="fill">False</property>
	    </packing>
	  </child>

	  <child>
	    <widget class="GtkCheckButton" id="OohTellMe">
	      <property name="visible">True</property>
	      <property name="sensitive">False</property>
	      <property name="can_focus">True</property>
	      <property name="label" translatable="yes">_Tell me what this button does</property>
	      <property name="use_underline">True</property>
	      <property name="relief">GTK_RELIEF_NORMAL</property>
	      <property name="active">False</property>
	      <property name="inconsistent">False</property>
	      <property name="draw_indicator">True</property>
	    </widget>
	    <packing>
	      <property name="padding">0</property>
	      <property name="expand">False</property>
	      <property name="fill">False</property>
	    </packing>
	  </child>
	</widget>
	<packing>
	  <property name="padding">0</property>
	  <property name="expand">False</property>
	  <property name="fill">False</property>
	</packing>
      </child>

      <child>
	<widget class="GtkHSeparator" id="hseparator1">
	  <property name="visible">True</property>
	</widget>
	<packing>
	  <property name="padding">12</property>
	  <property name="expand">False</property>
	  <property name="fill">False</property>
	</packing>
      </child>

      <child>
	<widget class="GtkHButtonBox" id="hbuttonbox1">
	  <property name="visible">True</property>
	  <property name="layout_style">GTK_BUTTONBOX_END</property>
	  <property name="spacing">0</property>

	  <child>
	    <widget class="GtkButton" id="QuitButton">
	      <property name="visible">True</property>
	      <property name="can_default">True</property>
	      <property name="can_focus">True</property>
	      <property name="label">gtk-quit</property>
	      <property name="use_stock">True</property>
	      <property name="relief">GTK_RELIEF_NORMAL</property>
	      <signal name="clicked" handler="quit_handler" object="OohTellMe" last_modification_time="Thu, 18 Mar 2004 16:37:36 GMT"/>
	    </widget>
	  </child>
	</widget>
	<packing>
	  <property name="padding">0</property>
	  <property name="expand">False</property>
	  <property name="fill">False</property>
	</packing>
      </child>
    </widget>
  </child>
</widget>

</glade-interface>

Example 4

An example that has a preferences window with three tabs and an alternate window that can come up when the user exits is shown below.

The XML file generated by glade that contains these layouts is below.

<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">

<glade-interface>
<requires lib="gnome"/>

<widget class="GtkWindow" id="MainWindow">
  <property name="visible">True</property>
  <property name="title" translatable="yes">Preferences</property>
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  <property name="window_position">GTK_WIN_POS_NONE</property>
  <property name="modal">False</property>
  <property name="resizable">True</property>
  <property name="destroy_with_parent">False</property>

  <child>
    <widget class="GtkVBox" id="AllDaGoodies">
      <property name="border_width">6</property>
      <property name="visible">True</property>
      <property name="homogeneous">False</property>
      <property name="spacing">0</property>

      <child>
	<widget class="GtkNotebook" id="Preferences">
	  <property name="visible">True</property>
	  <property name="can_focus">True</property>
	  <property name="show_tabs">True</property>
	  <property name="show_border">True</property>
	  <property name="tab_pos">GTK_POS_TOP</property>
	  <property name="scrollable">False</property>
	  <property name="enable_popup">False</property>

	  <child>
	    <widget class="GtkVBox" id="LocationOptions">
	      <property name="border_width">6</property>
	      <property name="visible">True</property>
	      <property name="homogeneous">False</property>
	      <property name="spacing">0</property>

	      <child>
		<widget class="GtkRadioButton" id="Here">
		  <property name="visible">True</property>
		  <property name="can_focus">True</property>
		  <property name="label" translatable="yes">_Here</property>
		  <property name="use_underline">True</property>
		  <property name="relief">GTK_RELIEF_NORMAL</property>
		  <property name="active">False</property>
		  <property name="inconsistent">False</property>
		  <property name="draw_indicator">True</property>
		</widget>
		<packing>
		  <property name="padding">0</property>
		  <property name="expand">False</property>
		  <property name="fill">False</property>
		</packing>
	      </child>

	      <child>
		<widget class="GtkRadioButton" id="There">
		  <property name="visible">True</property>
		  <property name="can_focus">True</property>
		  <property name="label" translatable="yes">_There</property>
		  <property name="use_underline">True</property>
		  <property name="relief">GTK_RELIEF_NORMAL</property>
		  <property name="active">False</property>
		  <property name="inconsistent">False</property>
		  <property name="draw_indicator">True</property>
		  <property name="group">Here</property>
		</widget>
		<packing>
		  <property name="padding">0</property>
		  <property name="expand">False</property>
		  <property name="fill">False</property>
		</packing>
	      </child>
	    </widget>
	    <packing>
	      <property name="tab_expand">False</property>
	      <property name="tab_fill">True</property>
	    </packing>
	  </child>

	  <child>
	    <widget class="GtkLabel" id="LocationLabel">
	      <property name="visible">True</property>
	      <property name="label" translatable="yes">Location</property>
	      <property name="use_underline">False</property>
	      <property name="use_markup">False</property>
	      <property name="justify">GTK_JUSTIFY_LEFT</property>
	      <property name="wrap">False</property>
	      <property name="selectable">False</property>
	      <property name="xalign">0.5</property>
	      <property name="yalign">0.5</property>
	      <property name="xpad">0</property>
	      <property name="ypad">0</property>
	    </widget>
	    <packing>
	      <property name="type">tab</property>
	    </packing>
	  </child>

	  <child>
	    <widget class="GtkColorSelection" id="ColorSelection">
	      <property name="border_width">6</property>
	      <property name="visible">True</property>
	      <property name="has_opacity_control">True</property>
	      <property name="has_palette">False</property>
	    </widget>
	    <packing>
	      <property name="tab_expand">False</property>
	      <property name="tab_fill">True</property>
	    </packing>
	  </child>

	  <child>
	    <widget class="GtkLabel" id="ColorLabel">
	      <property name="visible">True</property>
	      <property name="label" translatable="yes">Color</property>
	      <property name="use_underline">False</property>
	      <property name="use_markup">False</property>
	      <property name="justify">GTK_JUSTIFY_LEFT</property>
	      <property name="wrap">False</property>
	      <property name="selectable">False</property>
	      <property name="xalign">0.5</property>
	      <property name="yalign">0.5</property>
	      <property name="xpad">0</property>
	      <property name="ypad">0</property>
	    </widget>
	    <packing>
	      <property name="type">tab</property>
	    </packing>
	  </child>

	  <child>
	    <widget class="GtkFontSelection" id="FontSelection">
	      <property name="border_width">6</property>
	      <property name="visible">True</property>
	      <property name="preview_text" translatable="yes">abcdefghijk ABCDEFGHIJK</property>
	    </widget>
	    <packing>
	      <property name="tab_expand">False</property>
	      <property name="tab_fill">True</property>
	    </packing>
	  </child>

	  <child>
	    <widget class="GtkLabel" id="FontLabel">
	      <property name="visible">True</property>
	      <property name="label" translatable="yes">Font</property>
	      <property name="use_underline">False</property>
	      <property name="use_markup">False</property>
	      <property name="justify">GTK_JUSTIFY_LEFT</property>
	      <property name="wrap">False</property>
	      <property name="selectable">False</property>
	      <property name="xalign">0.5</property>
	      <property name="yalign">0.5</property>
	      <property name="xpad">0</property>
	      <property name="ypad">0</property>
	    </widget>
	    <packing>
	      <property name="type">tab</property>
	    </packing>
	  </child>
	</widget>
	<packing>
	  <property name="padding">0</property>
	  <property name="expand">True</property>
	  <property name="fill">True</property>
	</packing>
      </child>

      <child>
	<widget class="GtkVBox" id="TheGlobalButtonArea">
	  <property name="visible">True</property>
	  <property name="homogeneous">False</property>
	  <property name="spacing">0</property>

	  <child>
	    <widget class="GtkHSeparator" id="hseparator1">
	      <property name="visible">True</property>
	    </widget>
	    <packing>
	      <property name="padding">0</property>
	      <property name="expand">False</property>
	      <property name="fill">False</property>
	    </packing>
	  </child>

	  <child>
	    <widget class="GtkHButtonBox" id="hbuttonbox2">
	      <property name="visible">True</property>
	      <property name="layout_style">GTK_BUTTONBOX_END</property>
	      <property name="spacing">0</property>

	      <child>
		<widget class="GtkButton" id="QuitButton">
		  <property name="visible">True</property>
		  <property name="can_default">True</property>
		  <property name="can_focus">True</property>
		  <property name="label">gtk-quit</property>
		  <property name="use_stock">True</property>
		  <property name="relief">GTK_RELIEF_NORMAL</property>
		</widget>
	      </child>
	    </widget>
	    <packing>
	      <property name="padding">0</property>
	      <property name="expand">False</property>
	      <property name="fill">False</property>
	    </packing>
	  </child>
	</widget>
	<packing>
	  <property name="padding">0</property>
	  <property name="expand">False</property>
	  <property name="fill">False</property>
	</packing>
      </child>
    </widget>
  </child>
</widget>

<widget class="GtkDialog" id="ConfirmClose">
  <property name="border_width">6</property>
  <property name="visible">True</property>
  <property name="title" translatable="yes"></property>
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  <property name="window_position">GTK_WIN_POS_NONE</property>
  <property name="modal">True</property>
  <property name="resizable">False</property>
  <property name="destroy_with_parent">False</property>
  <property name="has_separator">False</property>

  <child internal-child="vbox">
    <widget class="GtkVBox" id="dialog-vbox">
      <property name="visible">True</property>
      <property name="homogeneous">False</property>
      <property name="spacing">12</property>

      <child internal-child="action_area">
	<widget class="GtkHButtonBox" id="dialog-action_area">
	  <property name="visible">True</property>
	  <property name="layout_style">GTK_BUTTONBOX_END</property>

	  <child>
	    <widget class="GtkButton" id="CancelButton">
	      <property name="visible">True</property>
	      <property name="can_default">True</property>
	      <property name="can_focus">True</property>
	      <property name="label">gtk-cancel</property>
	      <property name="use_stock">True</property>
	      <property name="relief">GTK_RELIEF_NORMAL</property>
	      <property name="response_id">-6</property>
	      <signal name="clicked" handler="ok_button_clicked" last_modification_time="Mon, 15 Mar 2004 23:14:00 GMT"/>
	    </widget>
	  </child>

	  <child>
	    <widget class="GtkButton" id="ExitButton">
	      <property name="visible">True</property>
	      <property name="can_default">True</property>
	      <property name="can_focus">True</property>
	      <property name="label" translatable="yes">E_xit anyway</property>
	      <property name="use_underline">True</property>
	      <property name="relief">GTK_RELIEF_NORMAL</property>
	      <property name="response_id">-7</property>
	    </widget>
	  </child>
	</widget>
	<packing>
	  <property name="padding">0</property>
	  <property name="expand">False</property>
	  <property name="fill">True</property>
	  <property name="pack_type">GTK_PACK_END</property>
	</packing>
      </child>

      <child>
	<widget class="GtkHBox" id="InfoBox">
	  <property name="border_width">6</property>
	  <property name="visible">True</property>
	  <property name="homogeneous">False</property>
	  <property name="spacing">12</property>

	  <child>
	    <widget class="GtkImage" id="InfoImage">
	      <property name="visible">True</property>
	      <property name="stock">gtk-dialog-warning</property>
	      <property name="icon_size">6</property>
	      <property name="xalign">0.5</property>
	      <property name="yalign">0</property>
	      <property name="xpad">0</property>
	      <property name="ypad">0</property>
	    </widget>
	    <packing>
	      <property name="padding">0</property>
	      <property name="expand">False</property>
	      <property name="fill">False</property>
	    </packing>
	  </child>

	  <child>
	    <widget class="GtkLabel" id="InfoLabel">
	      <property name="visible">True</property>
	      <property name="label" translatable="yes">&lt;span weight=&quot;bold&quot; size=&quot;larger&quot;&gt;Exit from this fantastorific application?&lt;/span&gt;

Exiting from this program will lose all customizations you have made to &lt;span size=&quot;larger&quot;&gt;There&lt;/span&gt;.  It will also make you sad because you know that using this program was the highlight of your day.</property>
	      <property name="use_underline">False</property>
	      <property name="use_markup">True</property>
	      <property name="justify">GTK_JUSTIFY_LEFT</property>
	      <property name="wrap">True</property>
	      <property name="selectable">False</property>
	      <property name="xalign">0.5</property>
	      <property name="yalign">0.5</property>
	      <property name="xpad">0</property>
	      <property name="ypad">0</property>
	    </widget>
	    <packing>
	      <property name="padding">0</property>
	      <property name="expand">False</property>
	      <property name="fill">False</property>
	    </packing>
	  </child>
	</widget>
	<packing>
	  <property name="padding">0</property>
	  <property name="expand">False</property>
	  <property name="fill">False</property>
	</packing>
      </child>
    </widget>
  </child>
</widget>

</glade-interface>