1 /* make and manage dialogs ... subclass off this for dialog boxes
2  */
3 
4 /*
5 
6     Copyright (C) 1991-2003 The National Gallery
7 
8     This program is free software; you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation; either version 2 of the License, or
11     (at your option) any later version.
12 
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17 
18     You should have received a copy of the GNU General Public License along
19     with this program; if not, write to the Free Software Foundation, Inc.,
20     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21 
22  */
23 
24 /*
25 
26     These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
27 
28 */
29 
30 #ifndef IDIALOG_H
31 #define IDIALOG_H
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif /* __cplusplus */
36 
37 #define TYPE_IDIALOG (idialog_get_type())
38 #define IDIALOG( obj ) (GTK_CHECK_CAST( (obj), TYPE_IDIALOG, iDialog ))
39 #define IDIALOG_CLASS( klass ) \
40 	(GTK_CHECK_CLASS_CAST( (klass), TYPE_IDIALOG, iDialogClass ))
41 #define IS_IDIALOG( obj ) (GTK_CHECK_TYPE( (obj), TYPE_IDIALOG ))
42 #define IS_IDIALOG_CLASS( klass ) \
43 	(GTK_CHECK_CLASS_TYPE( (klass), TYPE_IDIALOG ))
44 
45 typedef struct _iDialog iDialog;
46 
47 typedef void (*iDialogFreeFn)( iDialog *, void * );
48 
49 struct _iDialog {
50 	iWindow parent_object;
51 
52 	/* My instance vars.
53 	 */
54 	iObject *iobject;		/* Kill dialog if this obj goes */
55 	guint destroy_sid;		/* Signal id for obj destroy */
56 
57 	GtkWidget *work;		/* Our work area */
58 	GtkWidget *hb;
59 	GtkWidget *bb;
60 
61 	GSList *ok_l;			/* List of OKbutton as set by user */
62 	GSList *ok_disp_l;		/* List of OKbutton as displayed */
63 	GSList *ok_but_l;		/* List of OK GtkButton as displayed */
64 
65 	GtkWidget *but_cancel;
66 	GtkWidget *but_help;
67 	GtkWidget *tog_pin;		/* Optional pinup widget */
68 
69 	GtkEntry *entry;		/* Last entry we added as default */
70 
71 	/* Flags.
72 	 */
73 	gboolean modal;			/* Modal/non-modal */
74 	gboolean pinup;			/* Stay up on OK */
75 	gboolean nosep;			/* Suppress hseparator */
76 	gboolean button_focus;		/* TRUE to focus buttons */
77 
78 	/* Name of help tag ... if set, make a help button and link to display
79 	 * of this.
80 	 */
81 	char *help_tag;
82 
83 	/* What we label the cancel button as (if any). Usually
84 	 * GTK_STOCK_CANCEL, but instant-apply dialogs should change this to
85 	 * GTK_STOCK_CLOSE.
86 	 */
87 	const char *cancel_text;
88 
89 	/* Per-instance build function.
90 	 */
91 	iWindowBuildFn build;
92 	void *build_a, *build_b, *build_c;
93 
94 	/* Our callbacks.
95 	 */
96 	iWindowFn cancel_cb;
97 	iWindowFn popdown_cb;
98 	iDialogFreeFn destroy_cb;	/* Called from _destroy() */
99 	void *client;			/* Client data for callbacks */
100 
101 	void *arg;			/* Misc thing provided to client */
102 
103 	/* Notify our parent when we finish.
104 	 */
105 	iWindowNotifyFn nfn;
106 	void *sys;
107 };
108 
109 typedef struct _iDialogClass {
110 	iWindowClass parent_class;
111 
112 	/* Our methods.
113 	 */
114 } iDialogClass;
115 
116 void idialog_free_client( iDialog *idlg, void *client );
117 
118 void idialog_set_ok_button_state( iDialog *idlg, gboolean state );
119 
120 GtkType idialog_get_type( void );
121 GtkWidget *idialog_new( void );
122 
123 void idialog_set_iobject( iDialog *idlg, iObject *iobject );
124 void idialog_set_modal( iDialog *, gboolean );
125 void idialog_set_pinup( iDialog *idlg, gboolean pinup );
126 void idialog_set_nosep( iDialog *, gboolean );
127 void idialog_set_button_focus( iDialog *idlg, gboolean button_focus );
128 void idialog_set_help_tag( iDialog *, const char *help_tag );
129 void idialog_set_callbacks( iDialog *,
130 	iWindowFn cancel_cb, iWindowFn popdown_cb,
131 	iDialogFreeFn destroy_cb, void *client );
132 void idialog_add_ok( iDialog *, iWindowFn done_cb, const char *fmt, ... )
133 	__attribute__((format(printf, 3, 4)));
134 void idialog_set_notify( iDialog *, iWindowNotifyFn, void * );
135 void idialog_set_build( iDialog *, iWindowBuildFn, void *, void *, void * );
136 void idialog_set_cancel_text( iDialog *, const char *cancel_text );
137 void idialog_set_default_entry( iDialog *idlg, GtkEntry *entry );
138 void idialog_init_entry( iDialog *idlg, GtkWidget *entry,
139 	const char *tip, const char *fmt, ... )
140 	__attribute__((format(printf, 4, 5)));
141 
142 void idialog_done_trigger( iDialog *idlg, int pos );
143 
144 #ifdef __cplusplus
145 }
146 #endif /* __cplusplus */
147 
148 #endif /* IDIALOG_H */
149