combo box problem



The following simple example of a gtk_combo_box compiles and works OK it the
select_cb() is empty.
The line marked gives a compiler error: undefined reference to
gtk_combo_box_get_active_text.  I am
befuddled!
sydney

#include <gtk/gtk.h>
#include <glib.h>

GtkWidget *window, *combo;

static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer
data)
{
   return FALSE;
}

static void destroy(GtkWidget *widget, gpointer data)
{
   gtk_main_quit();
}

static void select_cb(GtkWidget *widget, gpointer data)
{
   /* comment out following 2 lines and program compiles and works OK */
   gchar *str = gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo));  /*
compile error */
   g_print("active text: %s\n", str);
}

int main( int argc, char *argv[] )
{
   GtkWidget *button, *hbox;

   gtk_init (&argc, &argv);    /* init gtk */

   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_container_set_border_width(GTK_CONTAINER(window), 10);
   g_signal_connect(G_OBJECT(window), "delete_event",
G_CALLBACK(delete_event), NULL);
   g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL);

   hbox = gtk_hbox_new(TRUE, 20);
   gtk_container_add(GTK_CONTAINER(window), hbox);

   button = gtk_button_new_with_label("Select text");
   g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(select_cb),
NULL);
   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);

   combo = gtk_combo_box_new_text();
   gtk_box_pack_start(GTK_BOX(hbox), combo, FALSE, FALSE, 0);
   gtk_combo_box_insert_text(GTK_COMBO_BOX(combo), 0, "Astring");
   gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Bstring");
   gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Cstring");
   gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Dstring");
   gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Estring");
   gtk_combo_box_insert_text(GTK_COMBO_BOX(combo), 3, "xxxxx");

   gtk_widget_show_all(window);
   gtk_main();
   return 0;
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]