2016 ソフトウェア設計及び演習用の班Wiki
g01::背景遷移の基本形ソース
#include <gtk/gtk.h>
#include <stdlib.h>
GtkWidget *start(GtkWidget *);
GtkWidget *play(GtkWidget *);
GtkWidget *image;
static gboolean
cb_mouse_press(GtkWidget *widget,
GdkEventButton *event,
gpointer user_data)
{
gtk_main_quit();
}
int
main (int argc, char **argv)
{
gtk_init(&argc, &argv);
GtkWidget *window;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "たんいっち");
gtk_widget_set_size_request (window, 1200, 800);
gtk_widget_show_all(start(window));
gtk_main();
gtk_widget_destroy(image);
gtk_widget_show_all(play(window));
gtk_main();
return 0;
}
GtkWidget *start(GtkWidget *window)
{
image = gtk_image_new_from_file("start.jpg");
gtk_container_add(GTK_CONTAINER(window), image);
gtk_widget_add_events(window, GDK_BUTTON_PRESS_MASK);
g_signal_connect(G_OBJECT(window), "button-press-event",
G_CALLBACK(cb_mouse_press), image);
return window;
}
GtkWidget *play(GtkWidget *window)
{
image = gtk_image_new_from_file("rooma.jpg");
gtk_container_add(GTK_CONTAINER(window), image);
gtk_widget_add_events(window, GDK_BUTTON_PRESS_MASK);
g_signal_connect(G_OBJECT(window), "button-press-event",
G_CALLBACK(cb_mouse_press), image);
return window;
}
最終更新日:2016/06/03 23:50:07