I created a gtkcombobox with items. I wish pre-select an item in a list but o've got warnings (and i dont understand why) when i use the gtkcomboboxsetactive function.
Here is my code
<pre class="code prettyprint lang-d">```
void code_block()
#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;
}
Here is the warning / errors that i have. I dont understand why i cant cast in GTKCOMBOBOX
<pre class="code prettyprint lang-d">```
void code_block()
(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
How can i fix it ?
Thank's