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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
| #include <stdlib.h>
#include <gtk/gtk.h>
GtkWidget *pToolbar = NULL;
void Nouveau_Test(GtkWidget *widget, gpointer data);
/*Structure contenant comme champs :
>>Box : la pVBox contenue dans la fenetre principal
>>Label : le label qui sera mis à jour pendant le décompte
>>Bouton : le bouton qui sera dés/activé pendant le décompte
*/
struct _Structure
{
GtkWidget *Box;
GtkWidget *Label;
GtkWidget *Bouton;
};
typedef struct _Structure Structure;
void Nouveau_Test(GtkWidget* widget, gpointer data)
{
Structure *struc;
GtkWidget *Label;
/*Récupération de la structure par data*/
struc = (Structure*)data;
/* Creation des labels */
gtk_label_set_label(GTK_LABEL(struc->Label),"Vous etes sur le point de commencer un nouveau test.");
//structure->pLabel2=gtk_label_new("Une serie de 10 images va s'afficher. Vous aurez a chaque fois 5 secondes pour visualiser l'image avant de cliquer ou vous le desirez.");
/* Centrage des labels */
gtk_label_set_justify(GTK_LABEL(struc->Label), GTK_JUSTIFY_CENTER);
//gtk_label_set_justify(GTK_LABEL(structure->pLabel2), GTK_JUSTIFY_CENTER);
/* Ajout des labels à la fenetre */
gtk_box_pack_end(GTK_BOX(struc->Box), struc->Label, FALSE, FALSE, 0);
//gtk_box_pack_start(GTK_BOX(structure->Box), structure->pLabel2, FALSE, FALSE, 0);
gtk_widget_show_all(struc->Box);
}
int main(int argc, char **argv)
{
GtkWidget *pWindow;
GtkWidget *pLabel;
GtkWidget *Barre;
Structure *structure;
structure = g_malloc(sizeof(Structure));
gtk_init(&argc, &argv);
/* Creation de la fenetre */
pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(pWindow), "Test Avant Projet");
gtk_window_set_default_size(GTK_WINDOW(pWindow), 320, 200);
g_signal_connect(G_OBJECT(pWindow), "destroy", G_CALLBACK(gtk_main_quit), NULL);
/*Création de la pVBox*/
structure->Box = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(pWindow), structure->Box);
/*Création du label vide*/
structure->Label = gtk_label_new("");
gtk_box_pack_start(GTK_BOX(structure->Box), structure->Label, FALSE, FALSE, 0);
/* Creation de la barre d'outils */
Barre = gtk_toolbar_new();
gtk_box_pack_start(GTK_BOX(structure->Box), Barre, FALSE, FALSE, 0);
/* Creation a partir de stock */
gtk_toolbar_insert_stock(GTK_TOOLBAR(Barre),
GTK_STOCK_NEW,
"Commencer un nouveau test",
NULL,G_CALLBACK(Nouveau_Test),
(gpointer)structure,
-1);
gtk_toolbar_insert_stock(GTK_TOOLBAR(Barre),
GTK_STOCK_SAVE,
"Enregistrer",
NULL,
NULL,
NULL,
-1);
gtk_toolbar_insert_stock(GTK_TOOLBAR(Barre),
GTK_STOCK_QUIT,
"Fermer",
NULL,
G_CALLBACK(gtk_main_quit),
NULL,
-1);
/* Modification de la taille des icones */
gtk_toolbar_set_icon_size(GTK_TOOLBAR(Barre),GTK_ICON_SIZE_BUTTON);
/* Affichage uniquement des icones */
gtk_toolbar_set_style(GTK_TOOLBAR(Barre),GTK_TOOLBAR_ICONS);
gtk_widget_show_all(pWindow);
/* Libération de la mémoire */
g_free(structure);
gtk_main();
return EXIT_SUCCESS;
} |
Partager