Linux Headquarters

I've installed Linux… now what???

GtkCombo – Combo Text List Widget

Introduction
This example produces a simple GTK combo pull-down list. It allows you to add default values to the list. In addition, the user is allowed to enter his/her own value.
Screenshot

Source Code

/*
*File name: hbox.c
*/

#include
#include

/*– This function allows the program to exit properly when the window is closed –*/
gint destroyapp (GtkWidget *widget, gpointer gdata)
{
g_print (“Quitting…\n”);
gtk_main_quit();
return (FALSE);
}
int main (int argc, char *argv[])
{

/*– Declare the GTK Widgets used in the program –*/
GtkWidget *window;
GtkWidget *combo;
GList *items = NULL;

/*–Initialize GTK–*/
gtk_init (&argc, &argv);

/*–Create the new window–*/
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

/*–Connect the window to the destroyapp function –*/
gtk_signal_connect(GTK_OBJECT(window), “delete_event”, GTK_SIGNAL_FUNC(destroyapp), NULL);

/*– Items to be added to combo widget–*/
items = g_list_append (items, “Banana”);
items = g_list_append (items, “Orange”);
items = g_list_append (items, “Peach”);
items = g_list_append (items, “Strawberry”);

/*–Create a new combo widget –*/
combo = gtk_combo_new();
/*– Set items in the popup list–*/
gtk_combo_set_popdown_strings (GTK_COMBO (combo), items);

/*— Add combo widget to window-*/
gtk_container_add(GTK_CONTAINER (window), combo);

/*– Add a border to the window to give the button a little room –*/
gtk_container_border_width (GTK_CONTAINER (window), 15);

/*– Display the widgets –*/
gtk_widget_show(combo);
gtk_widget_show(window);

/*– Start the GTK event loop–*/
gtk_main();

/*–Return 0 if exit is successful–*/
return 0;

}

Compile the Source Code
gcc -Wall -g combo.c -o combo `gtk-config –cflags` `gtk-config –libs`

Execute the Program
./combo

What is Related

Comments are closed.

Subscribe to email feed

  • RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Youtube

Dedicated Linux Serv

Linux is the popular system nowadays, offering all the benefits ...

StarOffice 5.1

Introduction StarOffice 5.1 is a complete office suite with a word ...

AxY FTP

Introduction AxY FTP, formerly known as wxFTP, is a graphical FTP ...

Adobe Acrobat PDF Re

Introduction Many of you are probably familar with Adobe Acrobat Reader ...

Macromedia Shockwave

Introduction Macromedia has developed a version of its popular Shockwave plugin ...

Twitter updates