1 /* Declarations supporting gtkutil.c
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 /* Look up an object's parent class dynamically.
31  */
32 #define PARENT_CLASS_DYNAMIC( OBJECT ) \
33 	(g_type_class_peek( \
34 		g_type_parent( \
35 			G_TYPE_FROM_INSTANCE( OBJECT ) ) ))
36 
37 /* Like G_CHECK_TYPE, but insist on an exact match.
38  */
39 #define TYPE_EXACT( OBJECT, TYPE ) \
40 	(G_TYPE_FROM_INSTANCE( OBJECT ) == (TYPE))
41 
42 #define DESTROY_GTK( X ) { \
43 	if( X ) { \
44 		gtk_object_destroy( GTK_OBJECT( X ) ); \
45 		(X) = NULL; \
46 	} \
47 }
48 
49 void adjustments_set_value( GtkAdjustment *hadj, GtkAdjustment *vadj,
50         float hval, float vval );
51 
52 void *object_destroy( void *obj );
53 void *null_g_free( void *obj );
54 const char *object_type_name( GtkObject *obj );
55 
56 void widget_visible( GtkWidget *widget, gboolean visible );
57 
58 /* Make widgets.
59  */
60 GtkWidget *build_button( const char *name, GtkSignalFunc cb, gpointer user );
61 void get_geo( GtkWidget *widget, const char *text, Rect *geo );
62 void set_fixed( GtkWidget *widget, int nchars );
63 GtkWidget *build_entry( int nchars );
64 
65 GtkWidget *menu_build( const char *name );
66 GtkWidget *menu_add_but( GtkWidget *menu,
67 	const char *name, GtkSignalFunc cb, void *user );
68 GtkWidget *menu_add_tog( GtkWidget *menu,
69 	const char *name, GtkSignalFunc cb, void *user );
70 GtkWidget *menu_add_sep( GtkWidget *menu );
71 GtkWidget *menu_add_pullright( GtkWidget *popup, const char *name );
72 
73 /* Popup menu handling.
74  */
75 typedef void (*PopupFunc)( GtkWidget *, GtkWidget *, void * );
76 #define POPUP_FUNC( fn ) ((PopupFunc) (fn))
77 
78 GtkWidget *popup_build( const char *name );
79 GtkWidget *popup_add_but( GtkWidget *, const char *, PopupFunc );
80 GtkWidget *popup_add_tog( GtkWidget *, const char *, PopupFunc );
81 GtkWidget *popup_add_pullright( GtkWidget *popup, const char *name );
82 void popup_show( GtkWidget *host, GdkEvent *ev );
83 void popup_link( GtkWidget *host, GtkWidget *popup, void *data );
84 guint popup_attach( GtkWidget *host, GtkWidget *popup, void *data );
85 void popup_detach( GtkWidget *host, guint sid );
86 
87 void set_tooltip( GtkWidget *wid, const char *fmt, ... )
88 	__attribute__((format(printf, 2, 3)));
89 void junk_tooltips( void );
90 
91 typedef void (*TooltipGenerateFn)( GtkWidget *, VipsBuf *, void *a, void *b );
92 void set_tooltip_generate( GtkWidget *widget,
93 	TooltipGenerateFn fn, void *a, void *b );
94 
95 /* Set/get a label/entry, printf style.
96  */
97 void set_gentryv( GtkWidget *edit, const char *fmt, va_list ap );
98 void set_gentry( GtkWidget *entry, const char *fmt, ... )
99 	__attribute__((format(printf, 2, 3)));
100 void set_glabel( GtkWidget *label, const char *fmt, ... )
101 	__attribute__((format(printf, 2, 3)));
102 void set_glabel1( GtkWidget *label, const char *fmt, ... )
103 	__attribute__((format(printf, 2, 3)));
104 void set_gcaption( GtkWidget *label, const char *fmt, ... )
105 	__attribute__((format(printf, 2, 3)));
106 gboolean get_geditable_string( GtkWidget *text, char *out, int sz );
107 gboolean get_geditable_name( GtkWidget *text, char *out, int sz );
108 gboolean get_geditable_filename( GtkWidget *text, char *out, int sz );
109 gboolean get_geditable_double( GtkWidget *text, double *out );
110 gboolean get_geditable_int( GtkWidget *text, int *n );
111 gboolean get_geditable_uint( GtkWidget *text, int *n );
112 gboolean get_geditable_pint( GtkWidget *text, int *n );
113 
114 /* Make widget groups.
115  */
116 GtkWidget *build_glabelframe2( GtkWidget *box, const char *label );
117 GtkWidget *build_glabeltext3( GtkWidget *box, const char *label );
118 GtkWidget *build_glabeltext4( GtkWidget *box, GtkSizeGroup *group,
119 	const char *label );
120 GtkWidget *build_gtoggle( GtkWidget *box, const char *caption );
121 GtkWidget *build_goption( GtkWidget *box, GtkSizeGroup *group,
122 	const char *name, const char *item_names[], int nitem,
123 	GtkSignalFunc fn, void *value );
124 
125 typedef gboolean (*FiledropFunc)( void *client, const char *file );
126 void filedrop_register( GtkWidget *widget, FiledropFunc fn, void *client );
127 
128 /* Tag our thumbnail drag-n-drops with these. Start up a bit to leave room for
129  * filedrop.
130  */
131 enum {
132 	TARGET_SYMBOL = 99
133 };
134 
135 void set_symbol_drag_type( GtkWidget *widget );
136 
137 void listen_add( GObject *gobject, GObject **zap,
138 	const char *name, GCallback gcallback );
139 
140 void widget_update_pointer( GtkWidget *widget, GdkEvent *ev );
141 
142 void *gobject_print( GObject *gobject );
143 
144 int get_dpi( void );
145 
146 GtkWidget *image_new_from_file( const char *name );
147 
148 void vfatal( GError **error );
149 
150 char *text_view_get_text( GtkTextView *text_view );
151 void text_view_set_text( GtkTextView *text_view,
152 	const char *text, gboolean editable );
153 void text_view_select_text( GtkTextView *text_view, int start, int end );
154 
155 typedef void (*DestroyFn)( GObject * );
156 void destroy_if_destroyed( GObject *child, GObject *parent,
157 	DestroyFn destroy_fn );
158 
159 void process_events( void );
160