Add buttonboxes to makegdesc.
[doldaconnect.git] / common / makegdesc
index 0eaf7c7..3adbee2 100755 (executable)
@@ -1,5 +1,10 @@
 #!/usr/bin/perl
 
+use Getopt::Long;
+use IO::File;
+
+GetOptions(\%args, "h=s") || exit 1;
+
 $tempvar = 0;
 
 sub printwidgets
@@ -58,6 +63,16 @@ sub printwidgets
                print $widget->{"pad"} || "0";
                print ");\n";
            }
+       } elsif($widget->{"type"} =~ /([hv])btnbox/) {
+           print "${p}stack[$sl] = gtk_" . $1 . "button_box_new();\n";
+           if(defined($widget->{"layout"})) {
+               print "${p}gtk_button_box_set_layout(GTK_BUTTON_BOX(stack[$sl]), GTK_BUTTONBOX_" . $widget->{"layout"} . ");\n";
+           }
+           $pf = sub
+           {
+               my($widget, $p, $sl) = @_;
+               print "${p}gtk_container_add(GTK_CONTAINER(stack[" . ($sl - 1) . "]), stack[$sl]);\n";
+           }
        } elsif($widget->{"type"} eq "table") {
            print "${p}stack[$sl] = gtk_table_new(" . $widget->{"rows"} . ", " . $widget->{"cols"};
            print ", " . (($widget->{"homo"} eq "TRUE")?"TRUE":"FALSE");
@@ -114,6 +129,9 @@ sub printwidgets
            $widget->{"stock"} || die("Can't have image without stock\n");
            $widget->{"size"} || die("Can't have image without size\n");
            print "${p}stack[$sl] = gtk_image_new_from_stock(GTK_STOCK_" . $widget->{"stock"} . ", GTK_ICON_SIZE_" . $widget->{"size"} . ");\n";
+       } elsif($widget->{"type"} eq "xpmimg") {
+           $widget->{"data"} || die("Can't have XPM image without data\n");
+           print "${p}stack[$sl] = gtk_image_new_from_pixbuf(gdk_pixbuf_new_from_xpm_data((const char **)" . $widget->{"data"} . "));\n";
        } elsif($widget->{"type"} eq "lbl") {
            $widget->{"label"} || $widget->{"markup"} || die("Can't have label without label\n");
            if($widget->{"label"}) {
@@ -423,6 +441,20 @@ sub printwidgets
     }
 }
 
+sub printheader
+{
+    my($widget, $handle);
+    $handle = $_[1];
+    foreach $widget (@{$_[0]})
+    {
+       if($widget->{"var"})
+       {
+           $handle->print("extern GtkWidget *" . $options{"prefix"} . $widget->{"name"} .";\n");
+       }
+       printheader($widget->{"subwidgets"}, $handle) if($widget->{"subwidgets"});
+    }
+}
+
 sub printvars
 {
     my($widget);
@@ -488,6 +520,14 @@ while(<>)
     }
 }
 
+if($args{"h"})
+{
+    $hfile = IO::File->new($args{"h"}, "w") || die;
+    $hfile->print("GtkWidget *create_" . $options{"prefix"} . "wnd(void);\n");
+    printheader $rootwidgets, $hfile;
+    $hfile->close();
+}
+
 printvars $rootwidgets;
 print "\n";
 print "GtkWidget *create_" . $options{"prefix"} . "wnd(void)\n";