Linux Headquarters

I've installed Linux… now what???

GtkVPaned – Vertical Split Container

Introduction
This example covers a container called the GtkVPaned widget. The GtkVPaned container is a split plane with top and bottom sections separated by a divider. By default, the divider can be dragged up or down to alter the size of the split.

Source Code

/*
*File name: vpane.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 *vpane;
GtkWidget *text1;
GtkWidget *text2;

gchar *buffer1 = “This is the top text pane.”;
gchar *buffer2 = “This is the lower text pane.”;

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

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

/*– Create the horizontal pane –*/
vpane = gtk_vpaned_new();

/*– Create two text areas –*/
text1 = gtk_text_new(NULL, NULL);
text2 = gtk_text_new(NULL, NULL);

/*– Set text areas to be editable –*/
gtk_text_set_editable(GTK_TEXT (text1), TRUE);
gtk_text_set_editable(GTK_TEXT (text2), TRUE);

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

/*– Add the top text area to the hpane –*/
gtk_paned_add1(GTK_PANED(vpane), text1);

/*– Add the lower text area to the hpane –*/
gtk_paned_add2(GTK_PANED(vpane), text2);

/*– Add the vpane to the window –*/
gtk_container_add(GTK_CONTAINER(window), vpane);

/*– Add some text to the window –*/
gtk_text_insert(GTK_TEXT(text1), NULL, NULL, NULL, buffer1, strlen(buffer1));
gtk_text_insert(GTK_TEXT(text2), NULL, NULL, NULL, buffer2, strlen(buffer2));

/*– Set window border to zero so that text area takes up the whole window –*/
gtk_container_border_width (GTK_CONTAINER (window), 0);

/*– Set the window to be 640 x 200 pixels –*/
gtk_window_set_default_size (GTK_WINDOW(window), 640, 200);

/*– Set the window title –*/
gtk_window_set_title(GTK_WINDOW (window), “A Vertical Panel”);

/*– Display the widgets –*/
gtk_widget_show(vpane);
gtk_widget_show(text1);
gtk_widget_show(text2);
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 vpane.c -o vpane `gtk-config –cflags` `gtk-config –libs`

Execute the Program
./vpane

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