ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / Examples / Linux / Navigation / Sources / ihm / ihm_config.c
1 #include <gtk/gtk.h>
2 #include <VP_Os/vp_os_malloc.h>
3 #include <VP_Os/vp_os_print.h>
4 #include <VP_Os/vp_os_signal.h>
5
6 #include <ardrone_api.h>
7 #include <config_keys.h>
8 #include <ardrone_tool/ardrone_tool_configuration.h>
9
10 #include "ihm_config.h"
11
12 ihm_config_widgets_t ihm_config = {0};
13
14
15 #undef ARDRONE_CONFIG_KEY_IMM
16 #undef ARDRONE_CONFIG_KEY_REF
17 #undef ARDRONE_CONFIG_KEY_STR
18 #include <config_keys.h>
19
20 /* Prototypes */
21         static void configuration_received_callback();
22         /* These prototypes must be present, to check at compile time that the callback functions have the right number of arguments */
23 //      ardrone_tool_configuration_callback send_custom_application_request_callback;
24 //      ardrone_tool_configuration_callback send_custom_user_request_callback;
25 //      ardrone_tool_configuration_callback send_custom_session_request_callback;
26         static void get_configuration_callback(GtkWidget *widget, gpointer data);
27         static void set_configuration_callback(GtkWidget *widget, gpointer data);
28
29 /*-------------------------------------------------------------------------------------------------------------*/
30
31         void send_custom_application_request_callback(bool_t res)  {    printf("Switched application config.\n");  }
32
33         void send_custom_application_request(GtkWidget *widget, gpointer data)
34         {
35                 const char * id;
36                 id = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget));
37
38                 if (configuration_check_config_id(id)==C_OK)
39                 {
40                         printf("Requesting application user configuration <%s>\n",id);
41                         ARDRONE_TOOL_CONFIGURATION_ADDEVENT(application_id, (char*)id, send_custom_application_request_callback);
42                         ARDRONE_TOOL_CONFIGURATION_GET(configuration_received_callback);
43                 }
44         }
45         void send_new_custom_application_request(GtkWidget *widget, gpointer data)
46         {
47                 const char * id;
48                 printf("reading from <%p>\n",ihm_config.new_custom_configs[CAT_APPLI].entry);
49
50                 id = gtk_entry_get_text(GTK_ENTRY(ihm_config.new_custom_configs[CAT_APPLI].entry));
51
52                 printf("Checking <%s>\n",id);
53                 if (configuration_check_config_id(id)==C_OK)
54                 {
55                         printf("Creating/requesting custom application configuration <%s>\n",id);
56                         ARDRONE_TOOL_CONFIGURATION_ADDEVENT(application_id, (char*)id, send_custom_application_request_callback);
57                         ARDRONE_TOOL_CONFIGURATION_GET(configuration_received_callback);
58                 }
59         }
60
61 /*-------------------------------------------------------------------------------------------------------------*/
62
63         void send_custom_user_request_callback(bool_t res)  { printf("Switched profile config.\n"); }
64
65         void send_custom_user_request(GtkWidget *widget, gpointer data)
66         {
67                 const char * id;
68                 id = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget));
69
70                 if (configuration_check_config_id(id)==C_OK)
71                 {
72                         printf("Requesting custom user configuration <%s>\n",id);
73                         ARDRONE_TOOL_CONFIGURATION_ADDEVENT(profile_id, (char*)id, send_custom_user_request_callback);
74                         ARDRONE_TOOL_CONFIGURATION_GET(configuration_received_callback);
75                 }
76         }
77         void send_new_custom_user_request(GtkWidget *widget, gpointer data)
78         {
79                 const char * id;
80                 id = gtk_entry_get_text(GTK_ENTRY(ihm_config.new_custom_configs[CAT_USER].entry));
81
82                 if (configuration_check_config_id(id)==C_OK)
83                 {
84                         printf("Creating/requesting custom user configuration <%s>\n",id);
85                         ARDRONE_TOOL_CONFIGURATION_ADDEVENT(profile_id, (char*)id, send_custom_application_request_callback);
86                         ARDRONE_TOOL_CONFIGURATION_GET(configuration_received_callback);
87                 }
88         }
89
90 /*-------------------------------------------------------------------------------------------------------------*/
91
92         void send_custom_session_request_callback(bool_t res)  { printf("Switched session config. acknowlegded by the drone.\n"); }
93
94         void send_custom_session_request(GtkWidget *widget, gpointer data)
95         {
96                 const char * id;
97                 id = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget));
98
99                 if (configuration_check_config_id(id)==C_OK)
100                 {
101                         printf("Requesting custom session <%s>\n",id);
102                         ARDRONE_TOOL_CONFIGURATION_ADDEVENT(session_id, (char*)id, send_custom_session_request_callback);
103                         ARDRONE_TOOL_CONFIGURATION_GET(configuration_received_callback);
104                 }
105         }
106         void send_new_custom_session_request(GtkWidget *widget, gpointer data)
107         {
108                 const char * id = gtk_entry_get_text(GTK_ENTRY(ihm_config.new_custom_configs[CAT_SESSION].entry));
109
110                 if (configuration_check_config_id(id)==C_OK)
111                 {
112                         printf("Creating/requesting custom session <%s>\n",id);
113                         ARDRONE_TOOL_CONFIGURATION_ADDEVENT(session_id, (char*)id, send_custom_application_request_callback);
114                         ARDRONE_TOOL_CONFIGURATION_GET(configuration_received_callback);
115                 }
116         }
117
118 /*-------------------------------------------------------------------------------------------------------------*/
119
120
121 static void custom_configurations_received_callback(bool_t res)
122 {
123         int i,j;
124
125         if (res==TRUE)
126         {
127                 PRINT("%s %s %i - Request success !\n",__FILE__,__FUNCTION__,__LINE__);
128
129                 gdk_threads_enter();
130
131                 for (i=1;i<NB_CONFIG_CATEGORIES;i++)
132                 {
133                         PRINT("Got %i ids for category %i\n",available_configurations[i].nb_configurations,i);
134
135                         if (available_configurations[i].nb_configurations==0)
136                         {
137                                 gtk_combo_box_remove_text (GTK_COMBO_BOX(ihm_config.custom_config_values[i].combo),0);
138                                 gtk_combo_box_insert_text(GTK_COMBO_BOX(ihm_config.custom_config_values[i].combo),0,"no custom config. detected");
139                         }
140                         else
141                         {
142                                 for (j=0;j<available_configurations[i].nb_configurations;j++)
143                                 {
144                                         gtk_combo_box_remove_text (GTK_COMBO_BOX(ihm_config.custom_config_values[i].combo),j);
145                                         gtk_combo_box_insert_text(GTK_COMBO_BOX(ihm_config.custom_config_values[i].combo),j,available_configurations[i].list[j].id);
146                                 }
147                         }
148                 }
149                 //gtk_widget_show_all(ihm_config.window);
150                 gdk_threads_leave();
151         }
152         else
153         {
154                 PRINT("%s %s %i - Request failure !\n",__FILE__,__FUNCTION__,__LINE__);
155         }
156 }
157
158
159 static void configuration_received_callback(bool_t res)
160 {
161
162         char labels[1024];
163         char values[1024];
164         int i,nb_values=0;
165
166         gdk_threads_enter();
167
168         PRINT("%s %s\n",__FILE__,__FUNCTION__);
169
170         GtkRcStyle *rc_style1,*rc_style2;
171         GdkColor color1,color2,white;
172
173           color1.red=40000;
174           color1.blue=40000;
175           color1.green=65535;
176           rc_style1=gtk_rc_style_new();
177          // rc_style1->bg[GTK_STATE_NORMAL]=color1;
178           rc_style1->base[GTK_STATE_NORMAL]=color1;
179          // rc_style1->color_flags[GTK_STATE_NORMAL]|=GTK_RC_BG;
180           rc_style1->color_flags[GTK_STATE_NORMAL]|=GTK_RC_BASE;
181
182           color2.red=0x8fff;
183           color2.blue=0x8fff;
184           color2.green=0x8fff;
185           white.red=0xffff;
186           white.blue=0xffff;
187           white.green=0xffff;
188
189           rc_style2=gtk_rc_style_new();
190           //rc_style2->bg[GTK_STATE_NORMAL]=color2;
191           rc_style2->base[GTK_STATE_NORMAL]=white;
192           //rc_style2->color_flags[GTK_STATE_NORMAL]|=GTK_RC_BG;
193           rc_style2->color_flags[GTK_STATE_NORMAL]|=GTK_RC_BASE;
194
195
196         if (!GTK_IS_WIDGET(ihm_config.config_values_frame)) //{ gtk_widget_destroy(ihm_config.config_values_frame); ihm_config.config_values_frame = NULL; }
197         {
198                 if (ihm_config.config_values!=NULL){    vp_os_free(ihm_config.config_values); ihm_config.config_values = NULL;  }
199
200                 ihm_config.config_values_frame = gtk_scrolled_window_new(NULL,NULL);
201                 gtk_box_pack_start(GTK_BOX(ihm_config.config_frame_vbox),ihm_config.config_values_frame,TRUE, TRUE, 0);
202                 ihm_config.config_values_hbox  = gtk_hbox_new(FALSE,0);
203                 ihm_config.config_values_vbox1 = gtk_vbox_new(FALSE,0);
204                 ihm_config.config_values_vbox2 = gtk_vbox_new(FALSE,0);
205                 gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW (ihm_config.config_values_frame),ihm_config.config_values_hbox);
206                 gtk_box_pack_start(GTK_BOX(ihm_config.config_values_hbox),ihm_config.config_values_vbox1,TRUE, TRUE, 0);
207                 gtk_box_pack_start(GTK_BOX(ihm_config.config_values_hbox),ihm_config.config_values_vbox2,TRUE, TRUE, 0);
208
209                 #define DISPLAY(KEY,NAME,C_TYPE,RW)\
210                         ihm_config.config_values = vp_os_realloc(ihm_config.config_values,(nb_values+1)*sizeof(ihm_config_value_t)); \
211                         sprintf(labels,"%s:%s",KEY,CFG_STRINGIFY(NAME)); \
212                         ihm_config.config_values[nb_values].label = gtk_label_new(labels); \
213                         ihm_config.config_values[nb_values].value = gtk_entry_new(); \
214                         ihm_config.config_values[nb_values].hbox = gtk_hbox_new(FALSE,0); \
215                         if ((RW)&K_WRITE) ihm_config.config_values[nb_values].send_button = gtk_button_new_with_label("send"); else ihm_config.config_values[nb_values].send_button=NULL; \
216                         gtk_box_pack_start(GTK_BOX(ihm_config.config_values_vbox1),ihm_config.config_values[nb_values].label,FALSE, FALSE, ((RW)&K_WRITE)?6:5);\
217                         gtk_box_pack_start(GTK_BOX(ihm_config.config_values_vbox2),ihm_config.config_values[nb_values].hbox,FALSE, FALSE, 0);\
218                         gtk_box_pack_start(GTK_BOX(ihm_config.config_values[nb_values].hbox),ihm_config.config_values[nb_values].value,TRUE, TRUE, 0);\
219                         gtk_widget_modify_style(GTK_WIDGET(ihm_config.config_values[nb_values].value),rc_style2); \
220                         if (ihm_config.config_values[nb_values].send_button)\
221                         {gtk_box_pack_start(GTK_BOX(ihm_config.config_values[nb_values].hbox),ihm_config.config_values[nb_values].send_button,FALSE, FALSE, 0);\
222                         gtk_signal_connect(GTK_OBJECT(ihm_config.config_values[nb_values].send_button), "clicked", G_CALLBACK(set_configuration_callback), NULL);}\
223                         nb_values++;
224
225                 #undef ARDRONE_CONFIG_KEY_IMM
226                 #undef ARDRONE_CONFIG_KEY_REF
227                 #undef ARDRONE_CONFIG_KEY_STR
228                 #define ARDRONE_CONFIG_KEY_IMM(KEY, NAME, INI_TYPE, C_TYPE, C_TYPE_PTR, RW, DEFAULT, CALLBACK) DISPLAY(KEY,NAME,C_TYPE,RW)
229                 #define ARDRONE_CONFIG_KEY_REF(KEY, NAME, INI_TYPE, C_TYPE, C_TYPE_PTR, RW, DEFAULT, CALLBACK) DISPLAY(KEY,NAME,C_TYPE,RW)
230                 #define ARDRONE_CONFIG_KEY_STR(KEY, NAME, INI_TYPE, C_TYPE, C_TYPE_PTR, RW, DEFAULT, CALLBACK) DISPLAY(KEY,NAME,C_TYPE,RW)
231                 #include <config_keys.h>
232         }
233
234         //sprintf(labels,"%s:%s",STRINGIFY(abc),STRINGIFY(def));
235         // sprintf(values,PRINTF_KEY(C_TYPE)),get_##NAME());
236         //gtk_entry_set_text( GTK_ENTRY(ihm_config.config_values[nb_values].value) , values );
237
238
239         //sprintf(values,PRINTF_KEY(uint32_t),123);
240
241         i=0;
242
243 #define CONFIGURATION_GETTER(x) ardrone_control_config.x
244
245 #define ARDRONE_CONFIG_KEY_IMM(KEY, NAME, INI_TYPE, C_TYPE, C_TYPE_PTR, RW, DEFAULT, CALLBACK) \
246                 if(strcmp("" #INI_TYPE, "INI_FLOAT") == 0)        { sprintf( values,"%f",(float)CONFIGURATION_GETTER(NAME)); } \
247                 else if(strcmp("" #INI_TYPE, "INI_INT") == 0) { sprintf( values,"%d",(int)CONFIGURATION_GETTER(NAME)); }  \
248                 else if(strcmp("" #INI_TYPE, "INI_BOOLEAN") == 0) { sprintf( values,"%s",(CONFIGURATION_GETTER(NAME)) ? "TRUE" : "FALSE"); }       \
249                 if (strcmp(gtk_entry_get_text(GTK_ENTRY(ihm_config.config_values[i].value)),values)!=0)         \
250                         gtk_widget_modify_style(GTK_WIDGET(ihm_config.config_values[i].value),rc_style1); \
251                         else gtk_widget_modify_style(GTK_WIDGET(ihm_config.config_values[i].value),rc_style2); \
252                 gtk_entry_set_text( GTK_ENTRY(ihm_config.config_values[i].value) , values );\
253                 i++;
254
255                 //PRINT(" Received parameter <%s:%s> with value <%f>\n",#KEY,#NAME,(float)CONFIGURATION_GETTER(NAME) );
256
257 #define ARDRONE_CONFIG_KEY_REF(KEY, NAME, INI_TYPE, C_TYPE, C_TYPE_PTR, RW, DEFAULT, CALLBACK)  \
258                 i++;
259
260 #define ARDRONE_CONFIG_KEY_STR(KEY, NAME, INI_TYPE, C_TYPE, C_TYPE_PTR, RW, DEFAULT, CALLBACK)  \
261                 if (strcmp(gtk_entry_get_text(GTK_ENTRY(ihm_config.config_values[i].value)),CONFIGURATION_GETTER(NAME))!=0) \
262                         gtk_widget_modify_style(GTK_WIDGET(ihm_config.config_values[i].value),rc_style1); \
263                         else gtk_widget_modify_style(GTK_WIDGET(ihm_config.config_values[i].value),rc_style2); \
264                 gtk_entry_set_text( GTK_ENTRY(ihm_config.config_values[i].value) , CONFIGURATION_GETTER(NAME) ); i++;
265
266 #include <config_keys.h>
267
268         ihm_config.nb_config_values = i;
269
270         gtk_widget_show_all(ihm_config.window);
271         gtk_rc_style_unref(rc_style1);
272         gtk_rc_style_unref(rc_style2);
273
274         gdk_threads_leave();
275 }
276
277
278 static void get_configuration_callback(GtkWidget *widget, gpointer data)
279 {
280         ARDRONE_TOOL_CONFIGURATION_GET(configuration_received_callback);
281 }
282
283 static void set_configuration_callback(GtkWidget *widget, gpointer data)
284 {
285         int i;
286         int config_index=-1;
287         char * textval;
288
289         //gdk_threads_enter();
290
291         printf("Nb config values : %i\n",ihm_config.nb_config_values);
292
293         for (i=0;i<ihm_config.nb_config_values;i++) { if (widget==ihm_config.config_values[i].send_button) config_index=i; }
294         if (config_index==-1) { return; }
295         GtkWidget * w = ihm_config.config_values[config_index].value;
296         textval = (char*)gtk_entry_get_text((GtkEntry*)w);
297
298         i=0;  // Index of the scanned configuration key
299
300 #define ARDRONE_CONFIG_KEY_INI_FLOAT(KEY, NAME, C_TYPE)                 \
301         if (i==config_index){                                           \
302           printf("Sending configuration <%s:%s> = <%s>\n",KEY,CFG_STRINGIFY(NAME),textval); \
303           float fval; sscanf (textval, "%f", &fval);                    \
304           ARDRONE_TOOL_CONFIGURATION_ADDEVENT (NAME, &fval, NULL);      \
305         }i++;
306 #define ARDRONE_CONFIG_KEY_INI_DOUBLE(KEY, NAME, C_TYPE)                \
307         if (i==config_index){                                           \
308           printf("Sending configuration <%s:%s> = <%s>\n",KEY,CFG_STRINGIFY(NAME),textval); \
309           float64_t dval; sscanf (textval, "%lf", &fdal);               \
310           ARDRONE_TOOL_CONFIGURATION_ADDEVENT (NAME, &dval, NULL);      \
311         }i++;
312 #define ARDRONE_CONFIG_KEY_INT_uint32_t(KEY, NAME)                      \
313         if (i==config_index){                                           \
314           printf("Sending configuration <%s:%s> = <%s>\n",KEY,CFG_STRINGIFY(NAME),textval); \
315           uint32_t ival; sscanf (textval, "%u", &ival);                  \
316           ARDRONE_TOOL_CONFIGURATION_ADDEVENT (NAME, &ival, NULL);      \
317         }i++;
318 #define ARDRONE_CONFIG_KEY_INT_int32_t(KEY, NAME)                      \
319         if (i==config_index){                                           \
320           printf("Sending configuration <%s:%s> = <%s>\n",KEY,CFG_STRINGIFY(NAME),textval); \
321           int32_t ival; sscanf (textval, "%d", &ival);                  \
322           ARDRONE_TOOL_CONFIGURATION_ADDEVENT (NAME, &ival, NULL);      \
323         }i++;
324 #define ARDRONE_CONFIG_KEY_INI_INT(KEY, NAME, C_TYPE)                   \
325         ARDRONE_CONFIG_KEY_INT_##C_TYPE(KEY, NAME)
326 #define ARDRONE_CONFIG_KEY_INI_BOOLEAN(KEY, NAME, C_TYPE)               \
327         if (i==config_index){                                           \
328           printf("Sending configuration <%s:%s> = <%s>\n",KEY,CFG_STRINGIFY(NAME),textval); \
329           bool_t bval = ((strcmp (textval, "TRUE")==0) ? TRUE : FALSE); \
330           ARDRONE_TOOL_CONFIGURATION_ADDEVENT (NAME, &bval, NULL);      \
331         }i++;          
332
333 #define ARDRONE_CONFIG_KEY_IMM(KEY, NAME, INI_TYPE, C_TYPE, C_TYPE_PTR, RW, DEFAULT, CALLBACK) \
334         ARDRONE_CONFIG_KEY_##INI_TYPE(KEY, NAME, C_TYPE);
335         /*        if(i==config_index){                                  \
336           printf("Sending configuration <%s:%s> = <%s>\n",KEY,CFG_STRINGIFY(NAME),textval); \
337           if     (strcmp("" #INI_TYPE, "INI_FLOAT") == 0) { float fval; sscanf( textval,"%f",&fval);    ARDRONE_TOOL_CONFIGURATION_ADDEVENT(NAME, (C_TYPE_PTR)&fval, NULL); } \
338           else if(strcmp("" #INI_TYPE, "INI_DOUBLE") == 0) { float64_t dval; sscanf( textval, "%lf", &dval);    ARDRONE_TOOL_CONFIGURATION_ADDEVENT(NAME, (C_TYPE_PTR)&dval, NULL); } \
339           else if(strcmp("" #INI_TYPE, "INI_INT") == 0) { int32_t ival = atoi(textval); ARDRONE_TOOL_CONFIGURATION_ADDEVENT(NAME, (C_TYPE_PTR)&ival, NULL); } \
340           else if(strcmp("" #INI_TYPE, "INI_BOOLEAN") == 0) { bool_t bval = ((strcmp(textval,"TRUE")==0) ? TRUE : FALSE); ARDRONE_TOOL_CONFIGURATION_ADDEVENT(NAME, (C_TYPE_PTR)&bval, NULL); } \
341           }i++;*/
342         
343 #define ARDRONE_CONFIG_KEY_REF(KEY, NAME, INI_TYPE, C_TYPE, C_TYPE_PTR, RW, DEFAULT, CALLBACK) i++;
344         
345 #define ARDRONE_CONFIG_KEY_STR(KEY, NAME, INI_TYPE, C_TYPE, C_TYPE_PTR, RW, DEFAULT, CALLBACK) \
346         if(i==config_index){                                            \
347           printf("Sending configuration <%s:%s> = <%s>\n",KEY,CFG_STRINGIFY(NAME),textval); \
348           ARDRONE_TOOL_CONFIGURATION_ADDEVENT(NAME, textval, NULL);     \
349         }i++;
350         
351 #include <config_keys.h>
352
353         //gdk_threads_leave();
354 }
355
356 static void get_custom_configurations_callback(GtkWidget *widget, gpointer data)
357 {
358         printf("%s %s %i\n",__FILE__,__FUNCTION__,__LINE__);
359         ARDRONE_TOOL_CUSTOM_CONFIGURATION_GET(custom_configurations_received_callback);
360         printf("%s %s %i\n",__FILE__,__FUNCTION__,__LINE__);
361 }
362
363
364
365 void ihm_config_create_window()
366 {
367         int i;
368
369         if (ihm_config.window!=NULL && GTK_IS_WIDGET(ihm_config.window)) { gtk_widget_show_all(ihm_config.window); return; }
370
371         vp_os_memset(&ihm_config,0,sizeof(ihm_config));
372
373         /* Main window */
374                 ihm_config.window = gtk_window_new( GTK_WINDOW_TOPLEVEL);
375
376         /* Split the window in two halves */
377                 ihm_config.panes = gtk_hbox_new(FALSE, 20);
378                 gtk_container_add( GTK_CONTAINER(ihm_config.window), ihm_config.panes);
379
380         /* Make two vertical frames next to each other*/
381                 ihm_config.config_frame = gtk_frame_new("Config");
382                 ihm_config.custom_config_frame = gtk_frame_new("Custom config.");
383                 gtk_box_pack_start(GTK_BOX(ihm_config.panes), ihm_config.config_frame ,TRUE, TRUE, 0);
384                 gtk_box_pack_start(GTK_BOX(ihm_config.panes), ihm_config.custom_config_frame ,TRUE, TRUE, 0);
385                 ihm_config.config_frame_vbox = gtk_vbox_new(FALSE,0);
386                 ihm_config.custom_config_frame_vbox = gtk_vbox_new(FALSE,0);
387                 gtk_container_add( GTK_CONTAINER(ihm_config.config_frame) , ihm_config.config_frame_vbox  );
388                 gtk_container_add( GTK_CONTAINER(ihm_config.custom_config_frame) , ihm_config.custom_config_frame_vbox );
389
390         /* Config frame */
391                 ihm_config.get_config_button = gtk_button_new_with_label("Get configuration");
392                 gtk_box_pack_start(GTK_BOX(ihm_config.config_frame_vbox),ihm_config.get_config_button,FALSE, FALSE, 0);
393                 gtk_signal_connect(GTK_OBJECT(ihm_config.get_config_button), "clicked", G_CALLBACK(get_configuration_callback), NULL);
394
395         /* Custom Configs frame */
396                 ihm_config.get_custom_configs_button = gtk_button_new_with_label("Get custom configurations list");
397                 gtk_signal_connect(GTK_OBJECT(ihm_config.get_custom_configs_button), "clicked", G_CALLBACK(get_custom_configurations_callback), NULL);
398
399                 ihm_config.custom_config_values[1].label = gtk_label_new("Application");
400                 ihm_config.custom_config_values[2].label = gtk_label_new("User profile");
401                 ihm_config.custom_config_values[3].label = gtk_label_new("Session");
402
403                 gtk_box_pack_start(GTK_BOX(ihm_config.custom_config_frame_vbox),ihm_config.get_custom_configs_button,FALSE, FALSE, 0);
404
405                 for (i=1;i<NB_CONFIG_CATEGORIES;i++)
406                 {
407                         ihm_config.custom_config_values[i].hbox = gtk_hbox_new(FALSE,0);
408                         ihm_config.custom_config_values[i].combo = gtk_combo_box_new_text();
409                         ihm_config.custom_config_values[i].raz_button = gtk_button_new_with_label("reset");
410                         gtk_box_pack_start(GTK_BOX(ihm_config.custom_config_values[i].hbox),ihm_config.custom_config_values[i].label,FALSE,FALSE,0);
411                         gtk_box_pack_start(GTK_BOX(ihm_config.custom_config_values[i].hbox),ihm_config.custom_config_values[i].combo,FALSE,FALSE,0);
412                         gtk_box_pack_start(GTK_BOX(ihm_config.custom_config_values[i].hbox),ihm_config.custom_config_values[i].raz_button,FALSE,FALSE,0);
413
414                         gtk_box_pack_start(GTK_BOX(ihm_config.custom_config_frame_vbox),ihm_config.custom_config_values[i].hbox,FALSE,FALSE,0);
415
416                         gtk_combo_box_insert_text(GTK_COMBO_BOX(ihm_config.custom_config_values[i].combo),0,"press button to retrieve list");
417                 }
418
419                 gtk_signal_connect(GTK_OBJECT(ihm_config.custom_config_values[1].combo), "changed", G_CALLBACK(send_custom_application_request),NULL);
420                 gtk_signal_connect(GTK_OBJECT(ihm_config.custom_config_values[2].combo), "changed", G_CALLBACK(send_custom_user_request),NULL);
421                 gtk_signal_connect(GTK_OBJECT(ihm_config.custom_config_values[3].combo), "changed", G_CALLBACK(send_custom_session_request),NULL);
422
423
424                 ihm_config.new_custom_configs[1].label = gtk_label_new("New application");
425                 ihm_config.new_custom_configs[2].label = gtk_label_new("New user profile");
426                 ihm_config.new_custom_configs[3].label = gtk_label_new("New session");
427
428                 for (i=1;i<NB_CONFIG_CATEGORIES;i++)
429                 {
430                         ihm_config.new_custom_configs[i].hbox = gtk_hbox_new(FALSE,0);
431                         ihm_config.new_custom_configs[i].entry = gtk_entry_new();
432                         ihm_config.new_custom_configs[i].send_button = gtk_button_new_with_label("send");
433                         gtk_box_pack_start(GTK_BOX(ihm_config.new_custom_configs[i].hbox),ihm_config.new_custom_configs[i].label,FALSE,FALSE,0);
434                         gtk_box_pack_start(GTK_BOX(ihm_config.new_custom_configs[i].hbox),ihm_config.new_custom_configs[i].entry,FALSE,FALSE,0);
435                         gtk_box_pack_start(GTK_BOX(ihm_config.new_custom_configs[i].hbox),ihm_config.new_custom_configs[i].send_button,FALSE,FALSE,0);
436
437                         gtk_box_pack_start(GTK_BOX(ihm_config.custom_config_frame_vbox),ihm_config.new_custom_configs[i].hbox,FALSE,FALSE,0);
438                 }
439
440                 gtk_signal_connect(GTK_OBJECT(ihm_config.new_custom_configs[1].send_button), "clicked", G_CALLBACK(send_new_custom_application_request),NULL);
441                 gtk_signal_connect(GTK_OBJECT(ihm_config.new_custom_configs[2].send_button), "clicked", G_CALLBACK(send_new_custom_user_request),NULL);
442                 gtk_signal_connect(GTK_OBJECT(ihm_config.new_custom_configs[3].send_button), "clicked", G_CALLBACK(send_new_custom_session_request),NULL);
443
444                 gtk_widget_show_all(ihm_config.window);
445 }