hi. May i ask some help from you?

well here is the codes i m using now.

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

/*-- Declare gloabal variables for the file dialog box and the filename --*/
GtkWidget *file_selection_box;
gchar *filename;

/*-- This function allows the program to exit properly when the window is closed --*/
gint destroyapp (GtkWidget *widget, gpointer gdata)
g_print ("\nQuitting...\n");
return (FALSE);

void enter_callback( GtkWidget *widget,
GtkWidget *entry )
gchar *entry_text;
entry_text = gtk_entry_get_text(GTK_ENTRY(entry));
printf("Entry contents: %s\n", entry_text);

void entry_toggle_editable( GtkWidget *checkbutton,
GtkWidget *entry )

void entry_toggle_visibility( GtkWidget *checkbutton,
GtkWidget *entry )

void create()
GtkWidget *window;
GtkWidget *vbox, *hbox;
GtkWidget *entry;
GtkWidget *button;
GtkWidget *check;

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize( GTK_WIDGET (window), 200, 100);
gtk_window_set_title(GTK_WINDOW (window), "GTK Entry");
gtk_signal_connect(GTK_OBJECT (window), "delete_event",
(GtkSignalFunc) gtk_exit, NULL);

vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), vbox);
gtk_widget_show (vbox);

entry = gtk_entry_new_with_max_length (50);
gtk_signal_connect(GTK_OBJECT(entry), "activate",
gtk_entry_set_text (GTK_ENTRY (entry), "Enter IP address");
//gtk_entry_append_text (GTK_ENTRY (entry), " world");
gtk_entry_select_region (GTK_ENTRY (entry),
0, GTK_ENTRY(entry)->text_length);
gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0);
gtk_widget_show (entry);

hbox = gtk_hbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (vbox), hbox);
gtk_widget_show (hbox);

check = gtk_check_button_new_with_label("Editable");
gtk_box_pack_start (GTK_BOX (hbox), check, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT(check), "toggled",
GTK_SIGNAL_FUNC(entry_toggle_editable), entry);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(che ck), TRUE);
gtk_widget_show (check);

check = gtk_check_button_new_with_label("Visible");
gtk_box_pack_start (GTK_BOX (hbox), check, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT(check), "toggled",
GTK_SIGNAL_FUNC(entry_toggle_visibility), entry);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(che ck), TRUE);
gtk_widget_show (check);

button = gtk_button_new_with_label ("Close");
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
GTK_OBJECT (window));
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
gtk_widget_grab_default (button);
gtk_widget_show (button);


void store_filename(GtkFileSelection *file_selection, gpointer data)
/*-- Extract filename from the file selection dialog --*/
filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION (file_selection_box));

/*-- For the example, print the filename to the command line --*/
g_print (filename);

void create_file_selection(void)
/*-- Create the selector widget --*/
file_selection_box = gtk_file_selection_new("Please select a file for editing.");

/*-- Link the ok button to the store_filename function --*/
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION(file_selection_box)->ok_button), "clicked", GTK_SIGNAL_FUNC (store_filename), NULL);

/*-- Destroy the dialog box when the user clicks the ok_button --*/
gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION(file_selection_box)->ok_button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) file_selection_box);

/*-- Destroy the dialog box when the user clicks the cancel_button --*/
gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION(file_selection_box)->cancel_button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) file_selection_box);

/* Display the file dialog box */
gtk_widget_show (file_selection_box);

/* Create a Button Box with the specified parameters */
GtkWidget *create_bbox( gint horizontal,
char *title,
gint spacing,
gint child_w,
gint child_h,
gint layout )
GtkWidget *frame;
GtkWidget *bbox;
GtkWidget *button;

frame = gtk_frame_new (title);

if (horizontal)
bbox = gtk_hbutton_box_new ();
bbox = gtk_vbutton_box_new ();

gtk_container_set_border_width (GTK_CONTAINER (bbox), 5);
gtk_container_add (GTK_CONTAINER (frame), bbox);

/* Set the appearance of the Button Box */
gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), layout);
gtk_button_box_set_spacing (GTK_BUTTON_BOX (bbox), spacing);
gtk_button_box_set_child_size (GTK_BUTTON_BOX (bbox), child_w, child_h);

button = gtk_button_new_with_label ("Close");
gtk_container_add (GTK_CONTAINER (bbox), button);
gtk_signal_connect(GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (destroyapp), NULL);


void help()
GtkWidget *main_vbox;
GtkWidget *frame_horz;
gchar *markup_text;

GtkWidget *dialog, *label, *okay_button;
GtkWidget *vbox;
dialog = gtk_dialog_new();
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);

label = gtk_label_new("<span color=\"blue\">\t\t\t\tThis is a help box.\n The buttons are connected via VNCviewer to the IP address typed.\n \nFor more information, you may surf at www.realvnc.com. \n</span>");
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);

main_vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (main_vbox), vbox);

vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
gtk_container_add (GTK_CONTAINER (main_vbox), vbox);

gtk_box_pack_start (GTK_BOX (vbox),
create_bbox (TRUE, "Click this to close", 180, 85, 20, GTK_BUTTONBOX_SPREAD),
TRUE, TRUE, 0);//40 85 20
gtk_box_pack_start (GTK_BOX (main_vbox), frame_horz, TRUE, TRUE, 10);

g_print("Button was clicked");

static void help1(GtkWidget *widget, gpointer data)

int pid;
char data;
char buff[256];
int status;

pid = fork();
signal(SIGCHLD, (void *)waitchildren);
if (pid == 0)
//if (system("mozilla -mail") == -1)
if (execl("vncviewer", "vncviewer", "", NULL) != -1)

while (waitpid(pid, &status, WNOHANG) > -1)
if (errno != EINTR)

} else
char *temp_str;
sprintf(temp_str, " Error %d : %s \n",errno,strerror(errno));

int main (int argc, char *argv[])
/*-- Declare the GTK Widgets used in the program --*/
GtkWidget *window;
GtkWidget *menuFile;
GtkWidget *menuExit;
GtkWidget *menuHelp;
GtkWidget *menubar;
GtkWidget *menu;
GtkWidget *menuitem;
GtkWidget *vbox;
GtkWidget *handlebox;
GtkWidget *quitbox;
GtkWidget *scrolled_window;
GtkWidget *button, *button1;
GtkWidget *table;
char buffer[32];
int i, j;

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

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

/*-- Create the vbox --*/
vbox = gtk_vbox_new(FALSE, 0);

/*-- Create a text area --*/
//text = gtk_text_new(NULL, NULL);

/*-- Create the handlebox --*/
handlebox = gtk_handle_box_new();

/*-- Create the menu bar --*/
menubar = gtk_menu_bar_new();

/*-- Connect the window to the destroyapp function --*/
gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(destroyapp), NULL);

/*---------------- Create File menu items ------------------*/

menuFile = gtk_menu_item_new_with_label ("File");
gtk_menu_bar_append (GTK_MENU_BAR(menubar), menuFile);

/*-- Create File submenu --*/
menu = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuFile), menu);

/*-- Create New menu item under File submenu --*/
menuitem = gtk_menu_item_new_with_label ("New");
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_signal_connect(GTK_OBJECT (menuitem), "activate", GTK_SIGNAL_FUNC (create), NULL);
gtk_widget_show (menuitem);

/*-- Create Open menu item under File submenu --*/
menuitem = gtk_menu_item_new_with_label ("Open");
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_signal_connect(GTK_OBJECT (menuitem), "activate", GTK_SIGNAL_FUNC (create_file_selection), NULL);
gtk_widget_show (menuitem);

/*-- Create Exit menu item under File submenu --*/
menuitem = gtk_menu_item_new_with_label ("Exit");
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_signal_connect(GTK_OBJECT (menuitem), "activate", GTK_SIGNAL_FUNC (destroyapp), NULL);
gtk_widget_show (menuitem);
/*---------------- End File menu declarations ----------------*/

/*---------------- Create Edit menu items --------------------*/

menuExit = gtk_menu_item_new_with_label ("Exit");
gtk_menu_bar_append (GTK_MENU_BAR(menubar), menuExit);
gtk_signal_connect(GTK_OBJECT (menuExit), "activate", GTK_SIGNAL_FUNC (destroyapp), NULL);

/*---------------- Create Edit menu items --------------------*/

/*---------------- Start Help menu declarations ----------------*/
menuHelp = gtk_menu_item_new_with_label ("Help");
gtk_menu_bar_append (GTK_MENU_BAR(menubar), menuHelp);

/*-- Create Help submenu --*/
menu = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuHelp), menu);

/*-- Create About menu item under Help submenu --*/
menuitem = gtk_menu_item_new_with_label ("About");
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_signal_connect(GTK_OBJECT (menuitem), "activate", GTK_SIGNAL_FUNC (help), NULL);
gtk_widget_show (menuitem);
/*---------------- End Help menu declarations ----------------*/

/*-- Add the menubar to the handlebox --*/
gtk_container_add(GTK_CONTAINER(handlebox), menubar);

/*-- Pack the handlebox into the top of the vbox.
*-- You must use gtk_box_pack_start here instead of gtk_container_add
*-- or the menu will get larger as the window is enlarged
gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, TRUE, 0);

/*-- Add the text area to the window --*/
//gtk_container_add(GTK_CONTAINER(vbox), text);

/* create a new scrolled window. */
scrolled_window = gtk_scrolled_window_new (NULL, NULL);

gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 10);

/* the policy is one of GTK_POLICY AUTOMATIC, or GTK_POLICY_ALWAYS.
* GTK_POLICY_AUTOMATIC will automatically decide whether you need
* scrollbars, whereas GTK_POLICY_ALWAYS will always leave the scrollbars
* there. The first one is the horizontal scrollbar, the second,
* the vertical. */
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
/* The dialog window is created with a vbox packed into it. */
gtk_box_pack_start (GTK_BOX (GTK_DIALOG(window)->vbox), scrolled_window,
gtk_widget_show (scrolled_window);

/* create a table of 10 by 10 squares. */
table = gtk_table_new (10, 10, FALSE);

/* set the spacing to 10 on x and 10 on y */
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);

/* pack the table into the scrolled window */
gtk_scrolled_window_add_with_viewport (
GTK_SCROLLED_WINDOW (scrolled_window), table);
gtk_widget_show (table);

/* this simply creates a grid of toggle buttons on the table
* to demonstrate the scrolled window. */
for (i = 0; i < 5; i++)
for (j = 0; j < 5; j++) {
sprintf (buffer, "PC %d, %d\n", i, j);
button = gtk_toggle_button_new_with_label (buffer);
gtk_table_attach_defaults (GTK_TABLE (table), button,
i, i+1, j, j+1);
gtk_widget_show (button);

/*-- Add the scrolled window area to the window --*/
gtk_container_add(GTK_CONTAINER(vbox), scrolled_window);

/*-- Add the vbox to the main window --*/
gtk_container_add(GTK_CONTAINER(window), vbox);

/* Create another new hbox.. remember we can use as many as we need! */
quitbox = gtk_hbox_new (FALSE, 0);

/* Our quit button. */
button1 = gtk_button_new_with_label ("Quit");

/* Setup the signal to terminate the program when the button is clicked */
gtk_signal_connect_object (GTK_OBJECT (button1), "clicked",
GTK_SIGNAL_FUNC (destroyapp),
GTK_OBJECT (window));
/* Pack the button into the quitbox.
* The last 3 arguments to gtk_box_pack_start are:
* expand, fill, padding. */
gtk_box_pack_start (GTK_BOX (quitbox), button1, TRUE, FALSE, 0);
/* pack the quitbox into the vbox (box1) */
gtk_box_pack_start (GTK_BOX (vbox), quitbox, FALSE, FALSE, 0);

/* Pack the vbox (box1) which now contains all our widgets, into the
* main window. */
gtk_container_add (GTK_CONTAINER (window), vbox);

/* And show everything left */
// gtk_widget_show (button);
//gtk_widget_show (vbox);

// gtk_widget_show (box1);

/* This grabs this button to be the default button. Simply hitting
* the "Enter" key will cause this button to activate. */
gtk_widget_grab_default (button1);
//gtk_widget_show (button1);

/*-- 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 480 pixels --*/
gtk_window_set_default_size (GTK_WINDOW(window),640, 400);

/*-- Set the window title --*/
gtk_window_set_title(GTK_WINDOW (window), "File Dialog");

/*-- Display the widgets --*/
gtk_widget_show (button1);

/*-- Start the GTK event loop --*/

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

here are my questions:
i) is there a way to connect the "close" button when the user clicked at File/New with the buttons in the scrolled window?? what i intend to do is to display the ip address or jz the PC "no"(eg1,2,3) when the user had inserted a new ip. I could not think of a way to link both of the buttons.

I dun know the way of calling a function from a function. For instance in my case when the user click the ok button in the File/New... it will call another function to embed the ip address in the button to be passed to the scrolled window in main(). Got what i mean? is there a way to do so?? i m not using Glade btw...but i m using jz GTK+1.2.

ii) once i had clicked at the File/Open, i could not open any applications in the /home. Is there a way to do that?

ii)How do i enhance my program ie: colored buttons/ and additional pictures in it?

tq very much if u could help me or advice in solving my problems.