1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#include <stdlib.h>
#include <gtk/gtk.h>
int main(int argc, char **argv)
{
GtkWidget *p_window;
GtkWidget *p_button;
GtkWidget *p_image;
GtkWidget *layout;
/** Test avec gdk geometry **/
GdkGeometry windowProperties;
windowProperties.max_width = 850;
windowProperties.max_height = 400;
windowProperties.min_width = 849;
windowProperties.min_height = 399;
/* Initialisation de GTK+ */
gtk_init (&argc, &argv);
/** Creation de la fenetre **/
p_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT (p_window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
/** taille de la fenetre **/
gtk_window_set_default_size(GTK_WINDOW(p_window), 850, 400); // n' est pas suffisant
gtk_window_set_geometry_hints(GTK_WINDOW(p_window), NULL, &windowProperties, GDK_HINT_MAX_SIZE); //n'a aucun effet ??
gtk_window_set_geometry_hints(GTK_WINDOW(p_window), NULL, &windowProperties, GDK_HINT_MIN_SIZE);
gtk_window_set_resizable(GTK_WINDOW(p_window),FALSE);
/** Creation de l'imagebox et du layout **/
p_image = gtk_image_new_from_file ("./img.jpg");
layout = gtk_layout_new(NULL,NULL);
gtk_layout_put(GTK_LAYOUT(layout), p_image, 0, 0);
/** Creation du bouton **/
p_button = gtk_button_new_with_label ("Quit");
/**organisation du bouton**/
gtk_layout_put(GTK_LAYOUT(layout),p_button,720,350);
gtk_widget_set_size_request(p_button, 80, 35);
g_signal_connect (G_OBJECT (p_button), "clicked", G_CALLBACK(gtk_main_quit), NULL);
/**attachement de ma layout sur ma fennetre **/
gtk_container_add(GTK_CONTAINER (p_window),layout );
/** Affichage **/
gtk_widget_show_all (p_window);
gtk_main();
return EXIT_SUCCESS;
} |
Partager