[gtkada] pack_end

Frode Tennebø frode at tennebo.com
Mon Apr 1 02:18:58 CEST 2002


I want to design an interface where the user can add/remove/clear a 
composit widget using glade. However I stumbeled into a problem. 
Consider the folowing test.glade:

<?xml version="1.0"?>
<GTK-Interface>

<project>
  <name>Test</name>
  <program_name>test</program_name>
  <directory></directory>
  <source_directory>src</source_directory>
  <pixmaps_directory>pixmaps</pixmaps_directory>
  <language>Ada 95</language>
  <gnome_support>False</gnome_support>
  <gettext_support>True</gettext_support>
</project>

<widget>
  <class>GtkWindow</class>
  <name>window1</name>
  <width>200</width>
  <height>0</height>
  <title>window1</title>
  <type>GTK_WINDOW_TOPLEVEL</type>
  <position>GTK_WIN_POS_NONE</position>
  <modal>False</modal>
  <allow_shrink>False</allow_shrink>
  <allow_grow>True</allow_grow>
  <auto_shrink>False</auto_shrink>

  <widget>
    <class>GtkHBox</class>
    <name>hbox1</name>
    <homogeneous>False</homogeneous>
    <spacing>0</spacing>

    <widget>
      <class>GtkButton</class>
      <name>button1</name>
      <can_focus>True</can_focus>
      <label>More</label>
      <relief>GTK_RELIEF_NORMAL</relief>
      <child>
        <padding>0</padding>
        <expand>False</expand>
        <fill>False</fill>
      </child>
    </widget>

    <widget>
      <class>GtkButton</class>
      <name>button2</name>
      <can_focus>True</can_focus>
      <label>Fewer</label>
      <relief>GTK_RELIEF_NORMAL</relief>
      <child>
        <padding>0</padding>
        <expand>False</expand>
        <fill>False</fill>
      </child>
    </widget>

    <widget>
      <class>GtkButton</class>
      <name>button3</name>
      <can_focus>True</can_focus>
      <label>Clear</label>
      <relief>GTK_RELIEF_NORMAL</relief>
      <child>
        <padding>0</padding>
        <expand>False</expand>
        <fill>False</fill>
        <pack>GTK_PACK_END</pack>
      </child>
    </widget>
  </widget>
</widget>

</GTK-Interface>

If you open this in glade it will (hopefully) look like I want it to. 
Two pusbuttons groups to the left (more/fewer) and a single (clear) to 
the far right (note the <pack> for the last pushbuttpon).

Now, generate the code and run the binary. It produces a window with 
the three PBs compressed together. Inspecting the code I found that the 
last PB is:
  Add (Window1.Hbox1, Window1.Button3);

I changed this to:
   Pack_End (Window1.Hbox1, Window1.Button3, False, False, 0);

And now it looks like it does in Glade (well, I also had to figure out 
to set the width to a fixed (large enough) size). Is this suppose to be 
like this? I'm using Glade 0.6.4 and GtkAda 1.2.12.

 -Frode





More information about the gtkada mailing list