Tanya 183 : Contoh Penggunaan GtkComboBoxEntry

Tanya :
Bisa berikan contoh penggunaan GtkComboBoxEntry ?
Jawab :
Berikut kode yang diambil dari forum GTK+

[sourcecode language=”cpp”][/sourcecode]
#include <gtk/gtk.h>
void entry_activated_cb(GtkEntry *entry, gpointer user_data)
g_print("Text in entry is ‘%s’\n", gtk_entry_get_text(entry));
gint main(gint argc, gchar **argv)
GtkWidget *win;
GtkWidget *entry;
const gchar *items[] = {
"Hello again!",
gint i;
gtk_init(&argc, &argv);
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(win, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
/* Memasukkan teks ke Combo Box */
entry = gtk_combo_box_entry_new_text();
for(i = 0; items[i] != NULL; i++)
gtk_combo_box_append_text(GTK_COMBO_BOX(entry), items[i]);
gtk_container_add(GTK_CONTAINER(win), entry);
/* We can now access the GtkEntry portion by using GTK_BIN(entry)->child */
g_signal_connect(gtk_bin_get_child(GTK_BIN(entry)), "activate", G_CALLBACK(entry_activated_cb), NULL);
return 0;
Demikian. Semoga manfaat (rezaervani@gmail.com)

Be the first to comment

Leave a Reply

Your email address will not be published.