1#!/usr/bin/perl -w
2
3# options-header.pl: generate options dialog boxes
4
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14
15# You should have received a copy of the GNU General Public License along
16# with this program; if not, write to the Free Software Foundation, Inc.,
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19# Author contact information:
20
21# E-mail: philip-fuse@shadowmagic.org.uk
22
23use strict;
24
25use Fuse;
26use Fuse::Dialog;
27
28die "No data file specified" unless @ARGV;
29
30my @dialogs = Fuse::Dialog::read( shift @ARGV );
31my $internal = 1;
32
33$internal = 0 if( @ARGV && shift( @ARGV ) eq 'public' );
34
35if( $internal ) {
36    print Fuse::GPL( 'options_internals.h: options dialog boxes',
37		 '2001-2002 Philip Kendall' );
38} else {
39    print Fuse::GPL( 'options.h: options dialog boxes public declarations',
40		 '2001-2002 Philip Kendall' );
41}
42
43print <<"CODE";
44
45/* This file is autogenerated from options.dat by options-header.pl.
46   Do not edit unless you know what you\'re doing! */
47
48CODE
49
50if( $internal ) {
51  print << "CODE";
52#ifndef FUSE_GTKOPTIONS_INTERNALS_H
53#define FUSE_GTKOPTIONS_INTERNALS_H
54
55#ifndef __GTK_H__
56#include <gtk/gtk.h>
57#endif
58
59CODE
60} else {
61  print << "CODE";
62#ifndef FUSE_OPTIONS_H
63#define FUSE_OPTIONS_H
64
65CODE
66}
67
68if( $internal ) {
69    foreach( @dialogs ) {
70
71	print << "CODE";
72void menu_options_$_->{name}( GtkWidget *widget, gpointer data );
73
74typedef struct menu_options_$_->{name}_t \{
75
76  GtkWidget *dialog;
77
78CODE
79
80	foreach my $widget ( @{ $_->{widgets} } ) {
81
82	    if( $widget->{type} eq "Checkbox" or
83		$widget->{type} eq "Combo" or
84		$widget->{type} eq "Entry"       ) {
85		print "  GtkWidget *$widget->{value};\n";
86	    } else {
87		die "Unknown type `$widget->{type}'";
88	    }
89
90	}
91
92	print "\n} menu_options_$_->{name}_t;\n\n"
93
94    }
95} else {
96
97    foreach( @dialogs ) {
98	foreach my $widget ( @{ $_->{widgets} } ) {
99	    if( $widget->{type} eq "Combo" ) {
100		print <<"CODE";
101int option_enumerate_$_->{name}_$widget->{value}( void );
102
103CODE
104	    }
105	}
106    }
107}
108
109if( $internal ) {
110    print << "CODE";
111#endif				/* #ifndef FUSE_GTKOPTIONS_ITERNALS_H */
112CODE
113} else {
114    print << "CODE";
115#endif				/* #ifndef FUSE_OPTIONS_H */
116CODE
117}
118