Complete and Minimal Example of gtk_combo_box_new_text failure??
- From: Olivier <Olivier Ramare univ-lille1 fr>
- To: gtk-app-devel-list gnome org
- Subject: Complete and Minimal Example of gtk_combo_box_new_text failure??
- Date: Sat, 30 Apr 2005 14:01:09 +0200
Dear all,
Below is a program that goes to Segmentation fault when any
string in the combo_box is selected.
Any help would be appreciated!
Best,
Amities,
Olivier
---------------------------------------------------------------
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <gtk/gtk.h>
void my_gtk_widget_destroy(GtkWidget *widget)
{
gtk_widget_destroy(widget);
gtk_main_quit();
}
void selecter(GtkComboBox *combo)
{
char *name;
if ((name = gtk_combo_box_get_active_text (combo)) == NULL){
printf("What are we doing in here ???");
} else {
printf("Ok %s \n", name);};
}
int main(int argc, char *argv[])
{
GtkWidget *window, *my_combo_box;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window), "destroy",
G_CALLBACK(my_gtk_widget_destroy), NULL);
my_combo_box = gtk_combo_box_new_text();
gtk_combo_box_append_text(GTK_COMBO_BOX(my_combo_box), "Oui");
gtk_combo_box_append_text(GTK_COMBO_BOX(my_combo_box), "Non");
/*gtk_combo_box_set_active(GTK_COMBO_BOX (my_combo_box),0);*/
g_signal_connect (G_OBJECT(my_combo_box), "changed",
G_CALLBACK (selecter), NULL);
gtk_container_add(GTK_CONTAINER(window), my_combo_box);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
/*
gcc -Wall -pedantic essai.c -o essai.o -lm `pkg-config --cflags --libs gtk+-2.0`
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]