GdkPixbuf * ada_gdk_pixbuf_new_from_file (const char *filename, GError **error) { #ifdef GDK_WINDOWING_WIN32 return gdk_pixbuf_new_from_file_utf8 (filename, error); #else return gdk_pixbuf_new_from_file (filename, error); #endif }
int main(int argc, char *argv[]) { GtkWidget *box, *button, *poz, *reg_b, *frame; GtkStyle *style; GdkPixmap *bg; char buffer[buffsize]; if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) { fprintf(stderr, "WSAStartup() failed"); exit(1); } if ((sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) puts("socket() failed"); memset(&server, 0, sizeof(server)); /* Zero out structure */ server.sin_family = AF_INET; /* Internet address family */ server.sin_addr.s_addr = inet_addr("127.0.0.1"); /* Server IP address */ server.sin_port = htons(21); /* Server port */ if (connect(sock, (struct sockaddr *) &server, sizeof(server)) < 0) /* Establish the connection to the server */ puts("connect() failed"); gtk_init(&argc, &argv); //start GTK+ pixbuf = gdk_pixbuf_new_from_file_utf8("bgm.jpg", error); //read background gdk_pixbuf_render_pixmap_and_mask(pixbuf, &bg, NULL, 0); style = gtk_style_new(); style->bg_pixmap[0] = bg; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); //create window //gtk_window_set_default_size(GTK_WINDOW(window), 1280, 720); pixbuf = gdk_pixbuf_new_from_file_utf8("logo.gif", error); //read logo gtk_window_set_icon(GTK_WINDOW (window), pixbuf); //set logo gtk_container_set_border_width(GTK_CONTAINER (window), 10); //create close window event g_signal_connect(window, "delete-event", G_CALLBACK (delete_event), NULL); gtk_widget_set_style(GTK_WIDGET(window), GTK_STYLE(style)); //set background box = gtk_vbox_new(FALSE, 0); //the mess of positioning poz = gtk_hbox_new(FALSE, 0); logbox = gtk_vbox_new(FALSE, 0); gamebox = gtk_vbox_new(FALSE, 0); //positioning ends here //Setting up used Widgets -> buttons, input fields, ... //image = gtk_image_new_from_file_utf8("maemo.png"); pixbuf = gdk_pixbuf_new_from_file_at_scale_utf8("pic/0.jpg", 500, 500, TRUE, //read shown image error); image = gtk_image_new_from_pixbuf(pixbuf); //set image frame = gtk_frame_new(NULL); gtk_frame_set_shadow_type((GtkFrame *) frame, GTK_SHADOW_ETCHED_IN); gtk_container_add(GTK_CONTAINER (frame), image); gtk_container_add(GTK_CONTAINER (poz), frame); gtk_widget_show(frame); gtk_box_pack_start(GTK_BOX (poz), box, FALSE, FALSE, 10); //a bit of positioning gtk_box_pack_start(GTK_BOX (box), logbox, FALSE, FALSE, 10); gtk_box_pack_start(GTK_BOX (box), gamebox, FALSE, FALSE, 10); //end logname = gtk_entry_new(); gtk_box_pack_start(GTK_BOX (logbox), logname, FALSE, FALSE, 10); gtk_widget_show(logname); pass = gtk_entry_new(); gtk_box_pack_start(GTK_BOX (logbox), pass, FALSE, FALSE, 10); gtk_widget_show(pass); button = gtk_button_new_with_label("login"); g_signal_connect(button, "clicked", G_CALLBACK (login), (gpointer) NULL); gtk_box_pack_start(GTK_BOX (logbox), button, FALSE, FALSE, 10); gtk_widget_show(button); reg_b = gtk_button_new_with_label("Register"); g_signal_connect(reg_b, "clicked", G_CALLBACK (reg), (gpointer) "NULL"); gtk_box_pack_start(GTK_BOX (logbox), reg_b, FALSE, FALSE, 10); gtk_widget_show(reg_b); cbutton = gtk_button_new_with_label(buffer); g_signal_connect(cbutton, "clicked", G_CALLBACK (lan), (gpointer) buffer); gtk_box_pack_start(GTK_BOX (gamebox), cbutton, FALSE, FALSE, 10); button = gtk_button_new_with_label("picture"); g_signal_connect(button, "clicked", G_CALLBACK (set_image), "pic"); gtk_box_pack_start(GTK_BOX (gamebox), button, FALSE, FALSE, 10); stats = make_stats(); gtk_box_pack_start(GTK_BOX (gamebox), stats, FALSE, FALSE, 10); status = gtk_toggle_button_new_with_label("connected"); gtk_toggle_button_set_active((GtkToggleButton *) status, TRUE); g_signal_connect(status, "toggled", G_CALLBACK (clcon), (gpointer) NULL); gtk_box_pack_start(GTK_BOX (box), status, FALSE, FALSE, 10); gtk_container_add(GTK_CONTAINER (window), poz); //showing the parts of the window gtk_widget_show(status); gtk_widget_show(image); gtk_widget_show(logbox); gtk_widget_show(poz); gtk_widget_show(box); gtk_widget_show(window); gtk_main(); return EXIT_SUCCESS; }