2002-05-14 23:57:40 +00:00
|
|
|
#!@PERL@ -w
|
2000-10-18 15:50:13 +00:00
|
|
|
|
|
|
|
print <<EOT;
|
2003-11-08 22:08:05 +00:00
|
|
|
typedef GtkWidget *(*GDoDemoFunc) (GtkWidget *do_widget);
|
2000-11-18 23:59:30 +00:00
|
|
|
|
2000-10-18 15:50:13 +00:00
|
|
|
typedef struct _Demo Demo;
|
|
|
|
|
|
|
|
struct _Demo
|
|
|
|
{
|
2012-05-13 17:51:15 +00:00
|
|
|
gchar *name;
|
2000-10-18 15:50:13 +00:00
|
|
|
gchar *title;
|
|
|
|
gchar *filename;
|
2000-11-18 23:59:30 +00:00
|
|
|
GDoDemoFunc func;
|
2001-10-02 18:54:05 +00:00
|
|
|
Demo *children;
|
2000-10-18 15:50:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
EOT
|
|
|
|
|
|
|
|
for $file (@ARGV) {
|
2001-10-02 18:54:05 +00:00
|
|
|
my %demo;
|
2000-10-18 15:50:13 +00:00
|
|
|
|
|
|
|
($basename = $file) =~ s/\.c$//;
|
|
|
|
|
|
|
|
open INFO_FILE, $file or die "Cannot open '$file'\n";
|
|
|
|
$title = <INFO_FILE>;
|
|
|
|
$title =~ s@^\s*/\*\s*@@;
|
|
|
|
$title =~ s@\s*$@@;
|
|
|
|
|
|
|
|
close INFO_FILE;
|
|
|
|
|
2003-11-08 22:08:05 +00:00
|
|
|
print "GtkWidget *do_$basename (GtkWidget *do_widget);\n";
|
2001-10-02 18:54:05 +00:00
|
|
|
|
2013-02-01 23:21:15 +00:00
|
|
|
push @demos, {"name" => $basename, "title" => $title, "file" => "$file",
|
2001-10-02 18:54:05 +00:00
|
|
|
"func" => "do_$basename"};
|
|
|
|
}
|
|
|
|
|
|
|
|
# generate a list of 'parent names'
|
|
|
|
foreach $href (@demos) {
|
2005-07-12 15:28:45 +00:00
|
|
|
if ($href->{"title"} =~ m|^([-\w\s]+)/[-\w\s]+$|) {
|
2001-10-02 18:54:05 +00:00
|
|
|
my $parent_name = $1;
|
|
|
|
my $do_next = 0;
|
|
|
|
|
|
|
|
# parent detected
|
|
|
|
if (defined @parents) {
|
|
|
|
foreach $foo (@parents) {
|
|
|
|
if ($foo eq $parent_name) {
|
|
|
|
$do_next = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($do_next) {
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
push @parents, $parent_name;
|
|
|
|
|
|
|
|
$tmp = (defined @child_arrays)?($#child_arrays + 1):0;
|
|
|
|
push @child_arrays, "child$tmp";
|
|
|
|
|
2012-05-13 17:51:15 +00:00
|
|
|
push @demos, {"name" => "NULL", "title" => $parent_name, "file" => "NULL",
|
2001-10-02 18:54:05 +00:00
|
|
|
"func" => "NULL"};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (defined @parents) {
|
|
|
|
$i = 0;
|
|
|
|
for ($i = 0; $i <= $#parents; $i++) {
|
|
|
|
$first = 1;
|
|
|
|
|
|
|
|
print "\nDemo ", $child_arrays[$i], "[] = {\n";
|
|
|
|
|
|
|
|
$j = 0;
|
|
|
|
for ($j = 0; $j <= $#demos; $j++) {
|
|
|
|
$href = $demos[$j];
|
|
|
|
|
|
|
|
if (!defined $demos[$j]) {
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2005-07-12 15:28:45 +00:00
|
|
|
if ($demos[$j]{"title"} =~ m|^$parents[$i]/([-\w\s]+)$|) {
|
2001-10-02 18:54:05 +00:00
|
|
|
if ($first) {
|
|
|
|
$first = 0;
|
|
|
|
} else {
|
|
|
|
print ",\n";
|
|
|
|
}
|
|
|
|
|
2012-05-13 17:51:15 +00:00
|
|
|
print qq ( { "$demos[$j]{name}", "$1", "$demos[$j]{file}", $demos[$j]{func}, NULL });
|
2001-10-02 18:54:05 +00:00
|
|
|
|
|
|
|
# hack ... ugly
|
|
|
|
$demos[$j]{"title"} = "foo";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print ",\n";
|
|
|
|
print qq ( { NULL } );
|
|
|
|
print "\n};\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# sort @demos
|
|
|
|
@demos_old = @demos;
|
|
|
|
|
|
|
|
@demos = sort {
|
|
|
|
$a->{"title"} cmp $b->{"title"};
|
|
|
|
} @demos_old;
|
|
|
|
|
|
|
|
# sort the child arrays
|
|
|
|
if (defined @child_arrays) {
|
|
|
|
for ($i = 0; $i <= $#child_arrays; $i++) {
|
|
|
|
@foo_old = @{$child_arrays[$i]};
|
|
|
|
|
|
|
|
@{$child_arrays[$i]} = sort {
|
|
|
|
$a->{"title"} cmp $b->{"title"};
|
|
|
|
} @foo_old;
|
|
|
|
}
|
2000-10-18 15:50:13 +00:00
|
|
|
}
|
|
|
|
|
2001-10-02 18:54:05 +00:00
|
|
|
# toplevel
|
2012-01-16 12:58:23 +00:00
|
|
|
print "\nDemo gtk_demos[] = {\n";
|
2001-10-02 18:54:05 +00:00
|
|
|
|
|
|
|
$first = 1;
|
|
|
|
foreach $href (@demos) {
|
|
|
|
$handled = 0;
|
|
|
|
|
|
|
|
# ugly evil hack
|
|
|
|
if ($href->{title} eq "foo") {
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($first) {
|
|
|
|
$first = 0;
|
|
|
|
} else {
|
|
|
|
print ", \n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (defined @parents) {
|
|
|
|
for ($i = 0; $i <= $#parents; $i++) {
|
|
|
|
if ($parents[$i] eq $href->{title}) {
|
|
|
|
|
|
|
|
if ($href->{file} eq 'NULL') {
|
2012-05-13 17:51:15 +00:00
|
|
|
print qq ( { NULL, "$href->{title}", NULL, $href->{func}, $child_arrays[$i] });
|
2001-10-02 18:54:05 +00:00
|
|
|
} else {
|
2012-05-13 17:51:15 +00:00
|
|
|
print qq ( { "$href->{name}", "$href->{title}", "$href->{file}", $href->{func}, $child_arrays[$i] });
|
2001-10-02 18:54:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$handled = 1;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($handled) {
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2012-05-13 17:51:15 +00:00
|
|
|
print qq ( { "$href->{name}", "$href->{title}", "$href->{file}", $href->{func}, NULL });
|
2001-10-02 18:54:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
print ",\n";
|
|
|
|
print qq ( { NULL } );
|
2000-10-18 15:50:13 +00:00
|
|
|
print "\n};\n";
|
2001-10-02 18:54:05 +00:00
|
|
|
|
|
|
|
exit 0;
|