Bonjour,

J'ai créer une liste déroulante avec 3 options. Je souhaiterais pré selectionner un élément de la liste mais j'obtiens un warning que je n'explique pas lors de l'utilisation de la fonction gtk_combo_box_set_active.
Voici mon code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
 
#include <stdlib.h>
#include <gtk/gtk.h>
 
 
 
int main(int argc,char **argv){
 
	// INITIALISATION DE GTK
	gtk_init(&argc, &argv);
 
 
	// VARIABLE
	GtkWidget *fenetre = NULL;
	GtkWidget *combo_format_message;
	GList *liste_format = NULL;
	GtkWidget *table = NULL;
 
 
	// FENETRE PRINCIPALE ET PARAMETRAGE
	fenetre = gtk_window_new(GTK_WINDOW_TOPLEVEL);				// on créer notre fenetre principale
	gtk_window_set_title(GTK_WINDOW(fenetre), "Calculatrice Crypto");	// titre
	gtk_window_set_default_size(GTK_WINDOW(fenetre), 500, 500);		// taille
	gtk_window_set_position(GTK_WINDOW(fenetre), GTK_WIN_POS_CENTER);	// position 
 
 
 
 
	// TABLE			
	table = gtk_table_new(5, 5, TRUE);
	gtk_container_add(GTK_CONTAINER(fenetre), table);		// add le container dans la fenetre
 
 
 
	// LISTE DEROULANTE (a compléter)
	liste_format = g_list_append(liste_format, "binaire"); 				
	liste_format = g_list_append(liste_format, "décimal"); 		
	liste_format = g_list_append(liste_format, "hexadécimal"); 
 
	combo_format_message = gtk_combo_new(); 								// cree une liste deroulante
	gtk_table_attach(GTK_TABLE(table), combo_format_message, 4, 5, 0, 1, GTK_EXPAND, GTK_EXPAND, 5, 5);
	gtk_combo_set_popdown_strings(GTK_COMBO(combo_format_message), liste_format) ; 				// met la liste dans la combo box
	gtk_combo_box_set_active(GTK_COMBO_BOX(combo_format_message), 0);						// élément pré-selectionné
	//gchar * p_text = gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo_format_message));
	//gchar *p_text = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combo_format_message))));
	//gchar *p_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX(combo_format_message));
	fflush(stdout);
 
 
 
 
 
	// FONCTION DE CALLBACK 
   	g_signal_connect(G_OBJECT(fenetre), "delete-event", G_CALLBACK(gtk_main_quit), NULL);
 
 
 
	// AUTRE
	gtk_widget_show_all(fenetre);				// affichage
	gtk_main();						// lancement de la boucle infinie
 
 
 
 
	return EXIT_SUCCESS;
}




Voilà les erreurs que j'obtiens. Je ne comprends pas pourquoi je n'ai pas le droit de cast en GTK_COMBO_BOX.


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
(test2:4341): GLib-GObject-WARNING **: invalid cast from 'GtkCombo' to 'GtkComboBox'
 
(test2:4341): Gtk-CRITICAL **: IA__gtk_combo_box_set_active: assertion 'GTK_IS_COMBO_BOX (combo_box)' failed
Comment rectifier celà ?

Cordialement