4 typedef GtkWidget *(*GDoDemoFunc) (GtkWidget *do_widget);
6 typedef struct _Demo Demo;
21 ($basename = $file) =~ s/\.c$//;
23 open INFO_FILE, $file or die "Cannot open '$file'\n";
25 $title =~ s@^\s*/\*\s*@@;
30 print "GtkWidget *do_$basename (GtkWidget *do_widget);\n";
32 push @demos, {"title" => $title, "file" => $file,
33 "func" => "do_$basename"};
36 # generate a list of 'parent names'
37 foreach $href (@demos) {
38 if ($href->{"title"} =~ m|^([-\w\s]+)/[-\w\s]+$|) {
43 if (defined @parents) {
44 foreach $foo (@parents) {
45 if ($foo eq $parent_name) {
55 push @parents, $parent_name;
57 $tmp = (defined @child_arrays)?($#child_arrays + 1):0;
58 push @child_arrays, "child$tmp";
60 push @demos, {"title" => $parent_name, "file" => "NULL",
65 if (defined @parents) {
67 for ($i = 0; $i <= $#parents; $i++) {
70 print "\nDemo ", $child_arrays[$i], "[] = {\n";
73 for ($j = 0; $j <= $#demos; $j++) {
76 if (!defined $demos[$j]) {
80 if ($demos[$j]{"title"} =~ m|^$parents[$i]/([-\w\s]+)$|) {
87 print qq ( { "$1", "$demos[$j]{file}", $demos[$j]{func}, NULL });
90 $demos[$j]{"title"} = "foo";
95 print qq ( { NULL } );
104 $a->{"title"} cmp $b->{"title"};
107 # sort the child arrays
108 if (defined @child_arrays) {
109 for ($i = 0; $i <= $#child_arrays; $i++) {
110 @foo_old = @{$child_arrays[$i]};
112 @{$child_arrays[$i]} = sort {
113 $a->{"title"} cmp $b->{"title"};
119 print "\nDemo testgtk_demos[] = {\n";
122 foreach $href (@demos) {
126 if ($href->{title} eq "foo") {
136 if (defined @parents) {
137 for ($i = 0; $i <= $#parents; $i++) {
138 if ($parents[$i] eq $href->{title}) {
140 if ($href->{file} eq 'NULL') {
141 print qq ( { "$href->{title}", NULL, $href->{func}, $child_arrays[$i] });
143 print qq ( { "$href->{title}", "$href->{file}", $href->{func}, $child_arrays[$i] });
156 print qq ( { "$href->{title}", "$href->{file}", $href->{func}, NULL });
160 print qq ( { NULL } );