Hi all, I just started using gtk sockets. Facing problem in using it. here i have given two case(case1 and case2). In case one its working fine, but in case two facing problem. Basically in the second case, the button click itself is not possible. I tried both in linux(slackware 12) and windows(xp sp2). what i observed is, always the socket which is created will be in the beginning of the window(means (0,0)). because of that in the second case i'm not able to plase button first and the socket next. Please help me. Is there any alternative way to do. (I want the second case should work). Case 1: /* sock.c */ #ifdef WIN32 #include <windows.h> #endif #include <gtk/gtk.h> void clicked(void) { #ifdef WIN32 MessageBox(NULL, "Clicked\n", "sock-test", MB_OK | MB_ICONINFORMATION); #else printf("Clicked\n"); #endif } int main() { GtkWidget *pWindow, *pSocket, *pBox, *pBtn; gtk_init(NULL, NULL); pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(GTK_OBJECT(pWindow), "destroy", G_CALLBACK(gtk_main_quit), (gpointer)pWindow); pBox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(pWindow), pBox); pSocket = gtk_socket_new(); gtk_widget_set_size_request(pSocket, 320, 240); gtk_box_pack_start(GTK_BOX(pBox), pSocket, 1,1,1); pBtn = gtk_button_new_with_label("Click"); g_signal_connect(GTK_OBJECT(pBtn), "clicked", G_CALLBACK(clicked), NULL); gtk_box_pack_start(GTK_BOX(pBox), pBtn, 1,1,1); gtk_widget_show_all(pWindow); gtk_main(); return 0; } This is working fine. Case 2: /* sock2.c */ #ifdef WIN32 #include <windows.h> #endif #include <gtk/gtk.h> void clicked(void) { #ifdef WIN32 MessageBox(NULL, "Clicked\n", "sock-test", MB_OK | MB_ICONINFORMATION); #else printf("Clicked\n"); #endif } int main() { GtkWidget *pWindow, *pSocket, *pBox, *pBtn; gtk_init(NULL, NULL); pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(GTK_OBJECT(pWindow), "destroy", G_CALLBACK(gtk_main_quit), (gpointer)pWindow); pBox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(pWindow), pBox); pSocket = gtk_socket_new(); gtk_widget_set_size_request(pSocket, 320, 240); gtk_box_pack_end(GTK_BOX(pBox), pSocket, 1,1,1); pBtn = gtk_button_new_with_label("Click"); g_signal_connect(GTK_OBJECT(pBtn), "clicked", G_CALLBACK(clicked), NULL); gtk_box_pack_end(GTK_BOX(pBox), pBtn, 1,1,1); gtk_widget_show_all(pWindow); gtk_main(); return 0; } OR /* sock2.c */ #ifdef WIN32 #include <windows.h> #endif #include <gtk/gtk.h> void clicked(void) { #ifdef WIN32 MessageBox(NULL, "Clicked\n", "sock-test", MB_OK | MB_ICONINFORMATION); #else printf("Clicked\n"); #endif } int main() { GtkWidget *pWindow, *pSocket, *pBox, *pBtn; gtk_init(NULL, NULL); pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(G_OBJECT(pWindow), "destroy", G_CALLBACK(gtk_main_quit), (gpointer)pWindow); pBox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(pWindow), pBox); pBtn = gtk_button_new_with_label("Click"); g_signal_connect(G_OBJECT(pBtn), "clicked", G_CALLBACK(clicked), NULL); gtk_box_pack_start(GTK_BOX(pBox), pBtn, 1,1,1); pSocket = gtk_socket_new(); gtk_widget_set_size_request(pSocket, 320, 240); gtk_box_pack_start(GTK_BOX(pBox), pSocket, 1,1,1); gtk_widget_show_all(pWindow); gtk_main(); return 0; } -- Thank You, Loh!tha R |
_______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list