【GTK3.0】背景设置

由于GTK 3.0将许多GTK 2.0的API都丢弃,转到GTK 3.0下编译后有些不适应,所以感觉能在GTK 3.0下调试成功这个Demo还是很成功的。

源码

#include <gtk/gtk.h>

   int main( int argc, char *argv[])
   {
               GtkWidget *window;
               GtkWidget *layout;
               GtkWidget *image;
               GtkWidget *button;

               gtk_init(&argc, &argv);

               window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
               gtk_window_set_default_size(GTK_WINDOW(window), 290, 200);
               gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);

               layout = gtk_layout_new(NULL, NULL);
               gtk_container_add(GTK_CONTAINER (window), layout);
               gtk_widget_show(layout);

               image = gtk_image_new_from_file("bg.jpg");
               gtk_layout_put(GTK_LAYOUT(layout), image, 0, 0);

               button = gtk_button_new_with_label("Button");
               gtk_layout_put(GTK_LAYOUT(layout), button, 20, 50);
               gtk_widget_set_size_request(button, 80, 35);

               g_signal_connect_swapped(G_OBJECT(window), "destroy",G_CALLBACK(gtk_main_quit), NULL);

               gtk_widget_show_all(window);

               gtk_main();

               return 0;
}


你可能感兴趣的:(image,layout,null,callback,button,gtk)