Dear Friends, Here is a minimal example of a program, where if i click the button, a pop up window appears. I am posting both the call back function and the main routine (table.c). I am facing 2 problem. 1) The problem is evry time I click the button "main", a new window appears(obviously). What I want to achive is, if the window is already present, it should not open again; rather it should focus that window. I believe, this can be achived by gtk_window_present(may be I am wrong). But I don't know how to use it.
2) In the callback function, I have C_1 and C_2. What I want to achive is C<sub>1</sub> etc via pango(or any other). I am not a C programmer. And this is my *first* GTK as well. So, I am posting both the code. I will be grateful if anybody take some time to suggest me how to get things done. Regards and Best, //########################### //# FILE TABLE.C //############################ #include <gtk/gtk.h> #include <stdio.h> #include <string.h> #include <gdk/gdk.h> GtkAccelGroup *menuGroup; GtkWidget *window1 ; GtkWidget *window; GtkWidget *button; GtkWidget *table; GtkWidget *vbox1 ; GtkWidget *menubar ; GtkWidget *helpmenu ; GtkWidget *helpmenu_menu ; GtkWidget *helphelp ; GtkWidget *helpabout ; #include "prop_label.c" int main( int argc, char *argv[] ) { GtkWidget *window; GtkWidget *button; GtkWidget *table; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "Main"); gtk_container_set_border_width (GTK_CONTAINER (window), 20); /* * MENU BAR */ vbox1 = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window1), vbox1); menubar = gtk_menu_bar_new (); gtk_box_pack_start (GTK_BOX (vbox1), menubar, FALSE, FALSE, 2); /* INITIALIZE THE TABLE */ table = gtk_table_new (1, 1, TRUE); gtk_box_pack_start (GTK_BOX (vbox1), table, FALSE, FALSE, 2); gtk_container_add (GTK_CONTAINER (window), vbox1); /* Color Scheme */ GdkColor colorBlue = { 0x0000, 3598, 57054, 61937 }; /* Create first button */ button = gtk_button_new_with_label ("main"); g_signal_connect (button, "clicked", G_CALLBACK (callback_it), (gpointer) "Call"); gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 1, 0, 1); gtk_widget_modify_bg( button, GTK_STATE_NORMAL, &colorBlue ); gtk_widget_show (button); gtk_widget_show (table); gtk_widget_show (window); gtk_widget_show_all (window); gtk_main (); return 0; } /*########################### # FILE PROP_LABEL.C ############################*/ #include <gtk/gtk.h> int callback_it( int argc, char *argv[] ) { static GtkWidget *window = NULL; GtkWidget *hbox; GtkWidget *vbox; GtkWidget *frame; GtkWidget *label; /* Initialise GTK */ gtk_init(&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "Callback"); vbox = gtk_vbox_new (FALSE, 0); hbox = gtk_hbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window), hbox); gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (window), 25); frame = gtk_frame_new ("C_1"); label = gtk_label_new ("1\n2\n3"); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_container_add (GTK_CONTAINER (frame), label); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); frame = gtk_frame_new ("C_2"); label = gtk_label_new ("1\n2\n3"); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_container_add (GTK_CONTAINER (frame), label); gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0); gtk_window_set_resizable(GTK_WINDOW (window), FALSE); gtk_widget_show_all (window); } _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list