Compile .gtkh header files from .desc files.
[doldaconnect.git] / common / makegdesc
index 0eaf7c7..32271fb 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
@@ -423,6 +428,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 +507,13 @@ while(<>)
     }
 }
 
+if($args{"h"})
+{
+    $hfile = IO::File->new($args{"h"}, "w") || die;
+    printheader $rootwidgets, $hfile;
+    $hfile->close();
+}
+
 printvars $rootwidgets;
 print "\n";
 print "GtkWidget *create_" . $options{"prefix"} . "wnd(void)\n";