File: appDialogGtk.c

package info (click to toggle)
ted 2.16-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 13,944 kB
  • ctags: 20,273
  • sloc: ansic: 167,980; makefile: 12,518; sh: 263
file content (190 lines) | stat: -rw-r--r-- 4,391 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#   include	"appFrameConfig.h"

#   include	<stdlib.h>
#   include	<stdio.h>

#   include	"appFrame.h"
#   include	"appSystem.h"
#   include	<appGeoString.h>

#   ifdef USE_GTK

#   include	<gdk/gdkkeysyms.h>

#   include	<appDebugon.h>

/************************************************************************/
/*									*/
/*  Make a dialog with a vertical organisation.				*/
/*									*/
/************************************************************************/

void appMakeVerticalDialog(	AppDialog *		ad,
				APP_WIDGET *		pColumn,
				EditApplication *	ea,
				APP_CLOSE_CALLBACK_T	closeCallback,
				APP_DESTROY_CALLBACK_T	destroyCallback,
				void *			through,
				char *			widgetName )
    {
    APP_WIDGET		shell;
    APP_WIDGET		column;

#   if  GTK_MAJOR_VERSION < 2
    const gboolean	homogeneous= FALSE;
    const gint		spacing= COLUMN_SPACING_GTK;
#   endif

#   if GTK_MAJOR_VERSION < 2
    shell= gtk_window_new( GTK_WINDOW_DIALOG );
#   else
    shell= gtk_dialog_new();
#   endif

    gtk_window_set_position( GTK_WINDOW( shell ), GTK_WIN_POS_CENTER );

    if  ( closeCallback )
	{
	gtk_signal_connect( GTK_OBJECT( shell ),
					    "delete_event",
					    (GtkSignalFunc)closeCallback,
					    through );
	}

    if  ( destroyCallback )
	{
	gtk_signal_connect( GTK_OBJECT( shell ),
					    "destroy_event",
					    (GtkSignalFunc)destroyCallback,
					    through );
	}

    gtk_container_set_border_width( GTK_CONTAINER( shell ), WINDOW_BORDER_GTK );

#   if  GTK_MAJOR_VERSION < 2
    column= gtk_vbox_new( homogeneous, spacing );

    gtk_container_add( GTK_CONTAINER( shell ), column );

    gtk_widget_show( column );
#   else
    column= gtk_bin_get_child( GTK_BIN( shell ) );
#   endif

    ad->adAccelGroup= gtk_accel_group_new();
#   if GTK_MAJOR_VERSION < 2
    gtk_accel_group_attach( ad->adAccelGroup, GTK_OBJECT( shell ) );
#   else
    gtk_window_add_accel_group( GTK_WINDOW( shell ), ad->adAccelGroup );
#   endif

    ad->adTopWidget= shell; *pColumn= column;
    return;
    }

static void appGuiGtkDialogBreak(	GtkWidget *		w,
					GdkEvent *		event,
					void *			voidad )
    {
    AppDialog *		ad= (AppDialog *)voidad;

    ad->adCloseId= 0;

    gtk_main_quit();

    return;
    }

void appGuiRunDialog(			AppDialog *		ad,
					int			initial,
					EditApplication *	ea )
    {
    gtk_window_set_modal( GTK_WINDOW( ad->adTopWidget ), TRUE );

    ad->adResponse= initial;

    ad->adCloseId= gtk_signal_connect( GTK_OBJECT( ad->adTopWidget ),
					"delete_event",
					(GtkSignalFunc)appGuiGtkDialogBreak,
					(void *)ad );

    gtk_main();

    if  ( ad->adCloseId )
	{
	gtk_signal_disconnect( GTK_OBJECT( ad->adTopWidget ), ad->adCloseId );
	ad->adCloseId= 0;
	}

    gtk_window_set_modal( GTK_WINDOW( ad->adTopWidget ), FALSE );

    return;
    }

void appGuiBreakDialog(			AppDialog *		ad,
					int			response )
    {
    ad->adResponse= response;
    gtk_main_quit();
    }

void appGuiSetDefaultButtonForDialog(	AppDialog *		ad,
					APP_WIDGET		button )
    {
    unsigned int	keyMask= 0;
    unsigned int	keyCode= GDK_Return;

    gtk_widget_add_accelerator( button, "clicked", ad->adAccelGroup,
					keyCode, keyMask, GTK_ACCEL_VISIBLE );
    }

void appGuiSetCancelButtonForDialog(	AppDialog *		ad,
					APP_WIDGET		button )
    {
    unsigned int	keyMask= 0;
    unsigned int	keyCode= GDK_Escape;

    gtk_widget_add_accelerator( button, "clicked", ad->adAccelGroup,
					keyCode, keyMask, GTK_ACCEL_VISIBLE );
    }

void appGuiShowDialog(			AppDialog *		ad,
					APP_WIDGET		relative )
    {
    gint		x;
    gint		y;
    gint		wide;
    gint		high;

    if  ( relative )
	{
	gtk_window_set_transient_for(
		    GTK_WINDOW( ad->adTopWidget ), GTK_WINDOW( relative ) );

	gtk_window_set_position( GTK_WINDOW( ad->adTopWidget ),
							GTK_WIN_POS_NONE );

	gtk_widget_realize( ad->adTopWidget );

	gdk_window_get_position( relative->window, &x, &y );
	gdk_window_get_size( relative->window, &wide, &high );

	gdk_window_move( ad->adTopWidget->window, x+ wide/5, y+ high/ 5 );
	}
    else{
	gtk_window_set_position( GTK_WINDOW( ad->adTopWidget ),
							GTK_WIN_POS_CENTER );
	}

    gtk_widget_show( ad->adTopWidget );
    }

void appGuiHideDialog(			AppDialog *		ad )
    {
    gtk_widget_hide( ad->adTopWidget );

    gtk_window_set_transient_for(
			    GTK_WINDOW( ad->adTopWidget ), (GtkWindow *)0 );
    }

#   endif