int main (int argc, char **argv) { GtkWidget *window; gtk_init (&argc, &argv); if (!load_pixbufs ()) { g_message ("main(): Could not load all the pixbufs!"); exit (EXIT_FAILURE); } frame = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, back_width, back_height); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request (window, back_width, back_height); g_signal_connect (window, "destroy", G_CALLBACK (destroy_cb), NULL); da = gtk_drawing_area_new (); g_signal_connect (da, "draw", G_CALLBACK (draw_cb), NULL); gtk_container_add (GTK_CONTAINER (window), da); gtk_widget_add_tick_callback (da, on_tick, NULL, NULL); gtk_widget_show_all (window); gtk_main (); return 0; }
PP_Bool DidCreate(PP_Instance Instance, uint32_t argc, const char *argn[], const char *argv[]){ //printf("This is an instance!\n"); extern PP_Instance CurInstance; CurInstance = Instance; //----- GtkWidget *window; printf("Instance: %d", Instance); gtk_init (&argc, &argv); if (!load_pixbufs ()) { g_message ("main(): Could not load all the pixbufs!"); return PP_FALSE; } printf("After load_pixbufs\n"); frame = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, back_width, back_height); printf("After gdk_pixbuf_new\n"); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); printf("After gtk_widow_new\n"); gtk_widget_set_size_request (window, back_width, back_height); gtk_window_set_resizable (GTK_WINDOW (window), FALSE); g_signal_connect (window, "destroy", G_CALLBACK (destroy_cb), NULL); printf("After g_signal_connect destroy\n"); da = gtk_drawing_area_new (); g_signal_connect (da, "draw", G_CALLBACK (draw_cb), NULL); printf("After g_signal_connect draw\n"); gtk_container_add (GTK_CONTAINER (window), da); printf("After gtk_container_add\n"); timeout_id = gdk_threads_add_timeout (FRAME_DELAY, timeout, NULL); printf("After gdk_threads_add_timeout\n"); gtk_widget_show_all (window); gtk_main (); //----- return PP_TRUE; }
GtkWidget * do_pixbufs (GtkWidget *do_widget) { if (!window) { GError *error; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_screen (GTK_WINDOW (window), gtk_widget_get_screen (do_widget)); gtk_window_set_title (GTK_WINDOW (window), "Pixbufs"); gtk_window_set_resizable (GTK_WINDOW (window), FALSE); g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window); g_signal_connect (window, "destroy", G_CALLBACK (cleanup_callback), NULL); error = NULL; if (!load_pixbufs (&error)) { GtkWidget *dialog; dialog = gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Failed to load an image: %s", error->message); g_error_free (error); g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); gtk_widget_show (dialog); } else { gtk_widget_set_size_request (window, back_width, back_height); frame = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, back_width, back_height); da = gtk_drawing_area_new (); g_signal_connect (da, "expose-event", G_CALLBACK (expose_cb), NULL); gtk_container_add (GTK_CONTAINER (window), da); timeout_id = g_timeout_add (FRAME_DELAY, timeout, NULL); } } if (!gtk_widget_get_visible (window)) { gtk_widget_show_all (window); } else { gtk_widget_destroy (window); window = NULL; g_object_unref (frame); } return window; }