File: appOptionmenuGtk.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 (194 lines) | stat: -rw-r--r-- 4,226 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
191
192
193
194
#   include	"appFrameConfig.h"

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

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

#   ifdef USE_GTK

#   include	<appDebugon.h>

/************************************************************************/
/*									*/
/*  Used to get around Motif's ridiculous resize behavior. Probably	*/
/*  not needed for GTK.							*/
/*									*/
/************************************************************************/

void appOptionmenuRefreshWidth(	AppOptionmenu *		aom )
    { return;	}

void appMakeOptionmenuInColumn(		AppOptionmenu *	aom,
					APP_WIDGET	column )
    {
    APP_WIDGET	pulldown;
    APP_WIDGET	inplace;

    pulldown= gtk_menu_new();

    inplace= gtk_option_menu_new();

    gtk_box_pack_start( GTK_BOX( column ), inplace, FALSE, TRUE, 0 );

    gtk_widget_show( inplace );

    gtk_option_menu_set_menu( GTK_OPTION_MENU( inplace ), pulldown );

    aom->aomPulldown= pulldown; aom->aomInplace= inplace; return;
    }

void appMakeOptionmenuInRow(		AppOptionmenu *	aom,
					APP_WIDGET	row,
					int		column,
					int		colspan )
    {
    APP_WIDGET	pulldown;
    APP_WIDGET	inplace;

    pulldown= gtk_menu_new();

    inplace= gtk_option_menu_new();

    gtk_table_attach( GTK_TABLE( row ),
			inplace,
			column, column+ colspan,
			0, 1,
			GTK_FILL | GTK_EXPAND | GTK_SHRINK,
			GTK_FILL | GTK_EXPAND | GTK_SHRINK,
			ROW_XPADDING_GTK, ROW_YPADDING_GTK );

    gtk_widget_show( inplace );

    gtk_option_menu_set_menu( GTK_OPTION_MENU( inplace ), pulldown );

    aom->aomPulldown= pulldown; aom->aomInplace= inplace; return;
    }

/************************************************************************/
/*									*/
/*  Add an option to a pulldown.					*/
/*									*/
/************************************************************************/

APP_WIDGET appAddItemToOptionmenu(	AppOptionmenu *		aom,
					const char *		label,
					APP_OITEM_CALLBACK_T	callBack,
					void *			target )
    {
    APP_WIDGET	item;

    item= gtk_menu_item_new_with_label( label );

    gtk_menu_append( GTK_MENU( aom->aomPulldown ), item );

    gtk_widget_show( item );

    if  ( callBack )
	{
	gtk_signal_connect( GTK_OBJECT( item ), "activate",
					(GtkSignalFunc)callBack, target );
	}

    return item;
    }

/************************************************************************/
/*									*/
/*  Select a particular option in an option menu.			*/
/*									*/
/************************************************************************/

void appSetOptionmenu(	AppOptionmenu *	aom,
			int		num )
    {
    gtk_option_menu_set_history( GTK_OPTION_MENU( aom->aomInplace ), num );

    return;
    }

void appEmptyOptionmenu(	AppOptionmenu *		aom )
    {
    appEmptyParentWidget( aom->aomPulldown );
    }

void appGuiEnableOptionmenu(	AppOptionmenu *		aom,
				int			sensitive )
    {
    gtk_widget_set_sensitive( aom->aomInplace, sensitive != 0 );
    }

void appInitOptionmenu(		AppOptionmenu *		aom )
    {
    aom->aomPulldown= (APP_WIDGET)0;
    aom->aomInplace= (APP_WIDGET)0;
    }

static int appGuiGetOptionmenuFindItem(	int *		pIdx,
					GtkWidget *	w,
					GtkMenuItem *	it )
    {
    if  ( GTK_IS_CONTAINER( w ) )
	{
	GList *	glf;
	GList *	gl;

	gl= glf= gtk_container_children( GTK_CONTAINER( w ) );

	while( gl )
	    {
	    GtkWidget *	c= (GtkWidget *)gl->data;

	    if  ( GTK_IS_MENU_ITEM( c )		)
		{
		if  ( GTK_MENU_ITEM( c ) == it	)
		    { return *pIdx;	}

		(*pIdx)++;
		}
	    else{
		if  ( GTK_IS_CONTAINER( c ) )
		    {
		    int	rval= appGuiGetOptionmenuFindItem( pIdx, c, it );

		    if  ( rval >= 0 )
			{ return rval;	}
		    }
		}

	    gl= gl->next;
	    }

	if  ( glf )
	    { g_list_free( glf );	}
	}

    return -1;
    }

int appGuiGetOptionmenuItemIndexGtk(	AppOptionmenu *	aom,
					GtkMenuItem *	it )
    {
    int		idx= 0;

    return appGuiGetOptionmenuFindItem( &idx, aom->aomPulldown, it );
    }

void appOptionmenuItemSetVisibility(	APP_WIDGET	w,
					int		visible )
    {
    visible= ( visible != 0 );

    if  ( GTK_WIDGET_VISIBLE( w ) == visible )
	{ return;	}

    if  ( visible )
	{ gtk_widget_show( w );	}
    else{ gtk_widget_hide( w );	}

    return;
    }

#   endif