Accueil > > > EXEMPLE DE PLACEMENT DE WIDGETS
EXEMPLE DE PLACEMENT DE WIDGETS
Information sur la source
Description
Source
- #include "gtk/gtk.h"
-
- void
- delete_event (GtkWidget *widget, GdkEvent *event, gpointer *data)
- {
- gtk_main_quit ();
- }
-
- /* Construction d'une nouvelle hbox remplie de boutons. Les paramètres qui
- * nous intéressent sont passés à cette fonction.
- * On n'affiche pas la boîte, mais tout ce qu'elle contient. */
-
- GtkWidget *make_box (gint homogeneous, gint spacing,
- gint expand, gint fill, gint padding)
- {
- GtkWidget *box;
- GtkWidget *button;
- char padstr[80];
-
- /* Création d'une hbox avec les paramètres homogeneous et spacing
- * voulus. */
-
- box = gtk_hbox_new (homogeneous, spacing);
-
- /* Création d'une série de boutons configurés de façon appropriée */
-
- button = gtk_button_new_with_label ("gtk_box_pack");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- button = gtk_button_new_with_label ("(box,");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- button = gtk_button_new_with_label ("button,");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- /* Création d'un bouton portant un label dépendant de la valeur
- * du paramètre expand. */
-
- if (expand == TRUE)
- button = gtk_button_new_with_label ("TRUE,");
- else
- button = gtk_button_new_with_label ("FALSE,");
-
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- /* Même chose que ci-dessus mais sous forme abrégée. */
-
- button = gtk_button_new_with_label (fill ? "TRUE," : "FALSE,");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- /* Récupération du paramètre padding sous forme de chaîne. */
-
- sprintf (padstr, "%d);", padding);
-
- button = gtk_button_new_with_label (padstr);
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- return box;
- }
-
- int main (int argc, char *argv[])
- {
- GtkWidget *window;
- GtkWidget *button;
- GtkWidget *box1;
- GtkWidget *box2;
- GtkWidget *separator;
- GtkWidget *label;
- GtkWidget *quitbox;
- int which;
-
- /* Initialisation, à ne jamais oublier ! :) */
-
- gtk_init (&argc, &argv);
-
- if (argc != 2) {
- fprintf (stderr, "usage : %s num, où num vaut 1, 2, ou 3.\n", *argv);
-
- /* Nettoyage dans GTK et sortie avec un code d'erreur de 1 */
- gtk_exit (1);
- }
-
- which = atoi (argv[1]);
-
- /* Création de notre fenêtre. */
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-
- /* Il ne faut jamais oublier de connecter le signal "destroy" à la
- * fenêtre principale. C'est très important pour disposer d'un
- * comportement intuitif adéquat. */
-
- gtk_signal_connect (GTK_OBJECT (window), "delete_event",
- GTK_SIGNAL_FUNC (delete_event), NULL);
-
- gtk_container_border_width (GTK_CONTAINER (window), 10);
-
-
- /* Création d'une boîte verticale (vbox) pour y placer les boîtes
- * horizontales.
- * Ceci permet de placer les boîtes horizontales contenant les boutons
- * les unes au dessus des autres dans cette vbox. */
-
- box1 = gtk_vbox_new (FALSE, 0);
-
- /* L'exemple à afficher. Ils correspondent aux images ci-dessus. */
-
- switch (which) {
- case 1:
- /* Création d'un label. */
-
- label = gtk_label_new ("gtk_hbox_new (FALSE, 0);");
-
- /* Alignement du label à gauche. On précisera cette fonction ainsi
- * que les autres dans la section sur les attributs des widgets. */
-
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
-
- /* Placement du label dans la boîte verticale (vbox box1). Il ne
- * faut pas oublier que les widgets qui s'ajoutent à une vbox sont
- * placés les uns au dessus des autres. */
-
- gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0);
-
- /* Affichage du label */
-
- gtk_widget_show (label);
-
- /* On appelle notre fonction de construction de boîte :
- * homogeneous = FALSE, spacing = 0,
- * expand = FALSE, fill = FALSE, padding = 0 */
-
- box2 = make_box (FALSE, 0, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
- gtk_widget_show (box2);
-
- /* On appelle notre fonction de construction de boîte :
- * homogeneous = FALSE, spacing = 0,
- * expand = FALSE, fill = FALSE, padding = 0 */
-
- box2 = make_box (FALSE, 0, TRUE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
- gtk_widget_show (box2);
-
- /* Paramètres : homogeneous = FALSE, spacing = 0,
- * expand = TRUE, fill = TRUE, padding = 0 */
-
- box2 = make_box (FALSE, 0, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
- gtk_widget_show (box2);
-
- /* Création d'un séparateur, on verra cela plus tard, mais ils sont
- * simples à utiliser. */
-
- separator = gtk_hseparator_new ();
-
- /* Placement du séparateur dans la vbox. Ne pas oublier que tous les
- * widgets sont placés dans une vbox et qu'il seront placés
- * verticalement. */
-
- gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5);
- gtk_widget_show (separator);
-
- /* Création d'un nouveau label et affichage de celui-ci. */
-
- label = gtk_label_new ("gtk_hbox_new (TRUE, 0);");
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
- gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0);
- gtk_widget_show (label);
-
- /* Paramètres : homogeneous = TRUE, spacing = 0,
- * expand = TRUE, fill = FALSE, padding = 0 */
-
- box2 = make_box (TRUE, 0, TRUE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
- gtk_widget_show (box2);
-
- /* Paramètres : homogeneous = TRUE, spacing = 0,
- * expand = TRUE, fill = TRUE, padding = 0 */
-
- box2 = make_box (TRUE, 0, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
- gtk_widget_show (box2);
-
- /* Un autre séparateur */
-
- separator = gtk_hseparator_new ();
-
- /* Les 3 derniers paramètres de gtk_box_pack_start sont :
- * expand = FALSE, fill = TRUE, padding = 5. */
-
- gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5);
- gtk_widget_show (separator);
-
- break;
-
- case 2:
-
- /* Création d'un label, box1 est une vbox identique à
- * celle créée au début de main() */
-
- label = gtk_label_new ("gtk_hbox_new (FALSE, 10);");
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
- gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0);
- gtk_widget_show (label);
-
- /* Paramètres : homogeneous = FALSE, spacing = 10,
- * expand = TRUE, fill = FALSE, padding = 0 */
-
- box2 = make_box (FALSE, 10, TRUE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
- gtk_widget_show (box2);
-
- /* Paramètres : homogeneous = FALSE, spacing = 10,
- * expand = TRUE, fill = TRUE, padding = 0 */
-
- box2 = make_box (FALSE, 10, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
- gtk_widget_show (box2);
-
- separator = gtk_hseparator_new ();
-
- /* Les 3 derniers paramètres de gtk_box_pack_start sont :
- * expand = FALSE, fill = TRUE, padding = 5. */
-
- gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5);
- gtk_widget_show (separator);
-
- label = gtk_label_new ("gtk_hbox_new (FALSE, 0);");
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
- gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0);
- gtk_widget_show (label);
-
- /* Paramètres : homogeneous = FALSE, spacing = 0,
- * expand = TRUE, fill = FALSE, padding = 10 */
-
- box2 = make_box (FALSE, 0, TRUE, FALSE, 10);
- gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
- gtk_widget_show (box2);
-
- /* Paramètres : homogeneous = FALSE, spacing = 0,
- * expand = TRUE, fill = TRUE, padding = 10 */
-
- box2 = make_box (FALSE, 0, TRUE, TRUE, 10);
- gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
- gtk_widget_show (box2);
-
- separator = gtk_hseparator_new ();
-
- /* Les 3 derniers paramètres de gtk_box_pack_start sont :
- * expand = FALSE, fill = TRUE, padding = 5. */
-
- gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5);
- gtk_widget_show (separator);
- break;
-
- case 3:
-
- /* Ceci est une démonstration de la possibilité d'utiliser
- * gtk_box_pack_end() pour aligner les widgets à droite.
- * On crée d'abord une nouvelle boîte comme d'habitude. */
-
- box2 = make_box (FALSE, 0, FALSE, FALSE, 0);
-
- /* On crée le label qui sera mis à la fin. */
-
- label = gtk_label_new ("end");
-
- /* On le place en utilisant gtk_box_pack_end(), il est ainsi
- * mis à droite de la hbox créée par l'appel à make_box(). */
-
- gtk_box_pack_end (GTK_BOX (box2), label, FALSE, FALSE, 0);
-
- /* Affichage du label. */
-
- gtk_widget_show (label);
-
- /* Placement de box2 dans box1 (la vbox, vous vous rappelez ? :) */
-
- gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
- gtk_widget_show (box2);
-
- /* Séparateur pour le bas. */
-
- separator = gtk_hseparator_new ();
-
- /* Configuration du séparateur en 400x5 pixels.
- * La hbox que l'on a créée aura donc 400 pixels de large,
- * et le label "end" sera séparé des autres de la hbox.
- * Sinon, tous les widgets de la hbox seraient placés les plus
- * près possible les uns des autres. */
-
- gtk_widget_set_usize (separator, 400, 5);
-
- /* Placement du séparateur dans la vbox (box1)
- * créée au debut de main(). */
-
- gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5);
- gtk_widget_show (separator);
- }
-
- /* Création d'une nouvelle hbox.. vous pouvez en utiliser autant que
- * que vous en avez besoin ! */
-
- quitbox = gtk_hbox_new (FALSE, 0);
-
- /* Notre bouton pour quitter. */
-
- button = gtk_button_new_with_label ("Quit");
-
- /* Configuration du signal pour détruire la fenêtre. Ceci enverra le
- * signal "destroy" à la fenêtre. Ce signal sera à son tour capturé
- * par notre gestionnaire de signal défini plus haut. */
-
- gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
- GTK_SIGNAL_FUNC (gtk_widget_destroy),
- GTK_OBJECT (window));
-
- /* Placement du bouton dans la « quitbox ».
- * Les 3 derniers paramètres de gtk_box_pack_start sont :
- * expand = TRUE, fill = FALSE, padding = 0. */
-
- gtk_box_pack_start (GTK_BOX (quitbox), button, TRUE, FALSE, 0);
-
- /* Placement de la quitbox dans la vbox (box1) */
-
- gtk_box_pack_start (GTK_BOX (box1), quitbox, FALSE, FALSE, 0);
-
- /* Placement de la vbox (box1), qui contient maintenant tous nos
- * widgets, dans la fenêtre principale. */
-
- gtk_container_add (GTK_CONTAINER (window), box1);
-
- /* Affichage */
-
- gtk_widget_show (button);
- gtk_widget_show (quitbox);
-
- gtk_widget_show (box1);
-
- /* Affichage de la fenêtre en dernier */
-
- gtk_widget_show (window);
-
- /* Ne pas oublier notre fonction principale. */
-
- gtk_main ();
-
- /* Le contrôle revient ici lorsque gtk_main_quit() est appelée,
- * jusqu'à ce que gtk_exit() soitutilisée. */
-
- return 0;
- }
-
#include "gtk/gtk.h"
void
delete_event (GtkWidget *widget, GdkEvent *event, gpointer *data)
{
gtk_main_quit ();
}
/* Construction d'une nouvelle hbox remplie de boutons. Les paramètres qui
* nous intéressent sont passés à cette fonction.
* On n'affiche pas la boîte, mais tout ce qu'elle contient. */
GtkWidget *make_box (gint homogeneous, gint spacing,
gint expand, gint fill, gint padding)
{
GtkWidget *box;
GtkWidget *button;
char padstr[80];
/* Création d'une hbox avec les paramètres homogeneous et spacing
* voulus. */
box = gtk_hbox_new (homogeneous, spacing);
/* Création d'une série de boutons configurés de façon appropriée */
button = gtk_button_new_with_label ("gtk_box_pack");
gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
gtk_widget_show (button);
button = gtk_button_new_with_label ("(box,");
gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
gtk_widget_show (button);
button = gtk_button_new_with_label ("button,");
gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
gtk_widget_show (button);
/* Création d'un bouton portant un label dépendant de la valeur
* du paramètre expand. */
if (expand == TRUE)
button = gtk_button_new_with_label ("TRUE,");
else
button = gtk_button_new_with_label ("FALSE,");
gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
gtk_widget_show (button);
/* Même chose que ci-dessus mais sous forme abrégée. */
button = gtk_button_new_with_label (fill ? "TRUE," : "FALSE,");
gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
gtk_widget_show (button);
/* Récupération du paramètre padding sous forme de chaîne. */
sprintf (padstr, "%d);", padding);
button = gtk_button_new_with_label (padstr);
gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
gtk_widget_show (button);
return box;
}
int main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *button;
GtkWidget *box1;
GtkWidget *box2;
GtkWidget *separator;
GtkWidget *label;
GtkWidget *quitbox;
int which;
/* Initialisation, à ne jamais oublier ! :) */
gtk_init (&argc, &argv);
if (argc != 2) {
fprintf (stderr, "usage : %s num, où num vaut 1, 2, ou 3.\n", *argv);
/* Nettoyage dans GTK et sortie avec un code d'erreur de 1 */
gtk_exit (1);
}
which = atoi (argv[1]);
/* Création de notre fenêtre. */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
/* Il ne faut jamais oublier de connecter le signal "destroy" à la
* fenêtre principale. C'est très important pour disposer d'un
* comportement intuitif adéquat. */
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC (delete_event), NULL);
gtk_container_border_width (GTK_CONTAINER (window), 10);
/* Création d'une boîte verticale (vbox) pour y placer les boîtes
* horizontales.
* Ceci permet de placer les boîtes horizontales contenant les boutons
* les unes au dessus des autres dans cette vbox. */
box1 = gtk_vbox_new (FALSE, 0);
/* L'exemple à afficher. Ils correspondent aux images ci-dessus. */
switch (which) {
case 1:
/* Création d'un label. */
label = gtk_label_new ("gtk_hbox_new (FALSE, 0);");
/* Alignement du label à gauche. On précisera cette fonction ainsi
* que les autres dans la section sur les attributs des widgets. */
gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
/* Placement du label dans la boîte verticale (vbox box1). Il ne
* faut pas oublier que les widgets qui s'ajoutent à une vbox sont
* placés les uns au dessus des autres. */
gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0);
/* Affichage du label */
gtk_widget_show (label);
/* On appelle notre fonction de construction de boîte :
* homogeneous = FALSE, spacing = 0,
* expand = FALSE, fill = FALSE, padding = 0 */
box2 = make_box (FALSE, 0, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
gtk_widget_show (box2);
/* On appelle notre fonction de construction de boîte :
* homogeneous = FALSE, spacing = 0,
* expand = FALSE, fill = FALSE, padding = 0 */
box2 = make_box (FALSE, 0, TRUE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
gtk_widget_show (box2);
/* Paramètres : homogeneous = FALSE, spacing = 0,
* expand = TRUE, fill = TRUE, padding = 0 */
box2 = make_box (FALSE, 0, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
gtk_widget_show (box2);
/* Création d'un séparateur, on verra cela plus tard, mais ils sont
* simples à utiliser. */
separator = gtk_hseparator_new ();
/* Placement du séparateur dans la vbox. Ne pas oublier que tous les
* widgets sont placés dans une vbox et qu'il seront placés
* verticalement. */
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5);
gtk_widget_show (separator);
/* Création d'un nouveau label et affichage de celui-ci. */
label = gtk_label_new ("gtk_hbox_new (TRUE, 0);");
gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0);
gtk_widget_show (label);
/* Paramètres : homogeneous = TRUE, spacing = 0,
* expand = TRUE, fill = FALSE, padding = 0 */
box2 = make_box (TRUE, 0, TRUE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
gtk_widget_show (box2);
/* Paramètres : homogeneous = TRUE, spacing = 0,
* expand = TRUE, fill = TRUE, padding = 0 */
box2 = make_box (TRUE, 0, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
gtk_widget_show (box2);
/* Un autre séparateur */
separator = gtk_hseparator_new ();
/* Les 3 derniers paramètres de gtk_box_pack_start sont :
* expand = FALSE, fill = TRUE, padding = 5. */
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5);
gtk_widget_show (separator);
break;
case 2:
/* Création d'un label, box1 est une vbox identique à
* celle créée au début de main() */
label = gtk_label_new ("gtk_hbox_new (FALSE, 10);");
gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0);
gtk_widget_show (label);
/* Paramètres : homogeneous = FALSE, spacing = 10,
* expand = TRUE, fill = FALSE, padding = 0 */
box2 = make_box (FALSE, 10, TRUE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
gtk_widget_show (box2);
/* Paramètres : homogeneous = FALSE, spacing = 10,
* expand = TRUE, fill = TRUE, padding = 0 */
box2 = make_box (FALSE, 10, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
gtk_widget_show (box2);
separator = gtk_hseparator_new ();
/* Les 3 derniers paramètres de gtk_box_pack_start sont :
* expand = FALSE, fill = TRUE, padding = 5. */
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5);
gtk_widget_show (separator);
label = gtk_label_new ("gtk_hbox_new (FALSE, 0);");
gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0);
gtk_widget_show (label);
/* Paramètres : homogeneous = FALSE, spacing = 0,
* expand = TRUE, fill = FALSE, padding = 10 */
box2 = make_box (FALSE, 0, TRUE, FALSE, 10);
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
gtk_widget_show (box2);
/* Paramètres : homogeneous = FALSE, spacing = 0,
* expand = TRUE, fill = TRUE, padding = 10 */
box2 = make_box (FALSE, 0, TRUE, TRUE, 10);
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
gtk_widget_show (box2);
separator = gtk_hseparator_new ();
/* Les 3 derniers paramètres de gtk_box_pack_start sont :
* expand = FALSE, fill = TRUE, padding = 5. */
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5);
gtk_widget_show (separator);
break;
case 3:
/* Ceci est une démonstration de la possibilité d'utiliser
* gtk_box_pack_end() pour aligner les widgets à droite.
* On crée d'abord une nouvelle boîte comme d'habitude. */
box2 = make_box (FALSE, 0, FALSE, FALSE, 0);
/* On crée le label qui sera mis à la fin. */
label = gtk_label_new ("end");
/* On le place en utilisant gtk_box_pack_end(), il est ainsi
* mis à droite de la hbox créée par l'appel à make_box(). */
gtk_box_pack_end (GTK_BOX (box2), label, FALSE, FALSE, 0);
/* Affichage du label. */
gtk_widget_show (label);
/* Placement de box2 dans box1 (la vbox, vous vous rappelez ? :) */
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
gtk_widget_show (box2);
/* Séparateur pour le bas. */
separator = gtk_hseparator_new ();
/* Configuration du séparateur en 400x5 pixels.
* La hbox que l'on a créée aura donc 400 pixels de large,
* et le label "end" sera séparé des autres de la hbox.
* Sinon, tous les widgets de la hbox seraient placés les plus
* près possible les uns des autres. */
gtk_widget_set_usize (separator, 400, 5);
/* Placement du séparateur dans la vbox (box1)
* créée au debut de main(). */
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5);
gtk_widget_show (separator);
}
/* Création d'une nouvelle hbox.. vous pouvez en utiliser autant que
* que vous en avez besoin ! */
quitbox = gtk_hbox_new (FALSE, 0);
/* Notre bouton pour quitter. */
button = gtk_button_new_with_label ("Quit");
/* Configuration du signal pour détruire la fenêtre. Ceci enverra le
* signal "destroy" à la fenêtre. Ce signal sera à son tour capturé
* par notre gestionnaire de signal défini plus haut. */
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (gtk_widget_destroy),
GTK_OBJECT (window));
/* Placement du bouton dans la « quitbox ».
* Les 3 derniers paramètres de gtk_box_pack_start sont :
* expand = TRUE, fill = FALSE, padding = 0. */
gtk_box_pack_start (GTK_BOX (quitbox), button, TRUE, FALSE, 0);
/* Placement de la quitbox dans la vbox (box1) */
gtk_box_pack_start (GTK_BOX (box1), quitbox, FALSE, FALSE, 0);
/* Placement de la vbox (box1), qui contient maintenant tous nos
* widgets, dans la fenêtre principale. */
gtk_container_add (GTK_CONTAINER (window), box1);
/* Affichage */
gtk_widget_show (button);
gtk_widget_show (quitbox);
gtk_widget_show (box1);
/* Affichage de la fenêtre en dernier */
gtk_widget_show (window);
/* Ne pas oublier notre fonction principale. */
gtk_main ();
/* Le contrôle revient ici lorsque gtk_main_quit() est appelée,
* jusqu'à ce que gtk_exit() soitutilisée. */
return 0;
}
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
TECHDAYS PARIS 2012 : COMMENT SHAREPOINT A SAUVé MES TECHDAYSTECHDAYS PARIS 2012 : COMMENT SHAREPOINT A SAUVé MES TECHDAYS par ROMELARD Fabrice
Speakers : Lionel Limozin et Alain Marty La session commence par une découverte de SharePoint à travers la mise en place d'un environnement SharePoint pour la gestion des Sessions animées par BeWise. Le besoin est très ba...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice PERSPECTIVE 3.0 POUR SILVERLIGHT 5.0PERSPECTIVE 3.0 POUR SILVERLIGHT 5.0 par odewit
Je viens de publier la version 3.0 de Perspective pour Silverlight, qui regroupe un portage sous Silverlight 5.0 des fonctionnalités de Perspective 2.0, le framework 3D de haut-niveau introduit récemment et de nouveaux exemples de code. En voici la li...
Cliquez pour lire la suite de l'article par odewit TECHDAYS PARIS 2012 : TOP 10 DES BEST PRACTICES POUR SQL SERVERTECHDAYS PARIS 2012 : TOP 10 DES BEST PRACTICES POUR SQL SERVER par ROMELARD Fabrice
Speaker : Nadia Ben El Kadi Configuration machine La session commence par la toute première question à se poser lors de la mise en place d'environnement SQL Server, la configuration des machines : Type de mac...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : KINECT + OFFICE 365 UN BON GESTE POUR VOTRE SITECHDAYS PARIS 2012 : KINECT + OFFICE 365 UN BON GESTE POUR VOTRE SI par ROMELARD Fabrice
Speakers : Fabrice Barbin, Samuel Blanchard, Julien Lo Presti Titre Prometteur et attractif invitant à voir comment lier le composant ludique Kinect dans le cadre d'une structure IT classique, notamment au travers de la plat...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : PLEINIèRE DU PREMIER JOURTECHDAYS PARIS 2012 : PLEINIèRE DU PREMIER JOUR par ROMELARD Fabrice
KeyNotes du premier jour pour les développeurs. La session est principalement axée sur une des principales directions prise par Microsoft à travers tous ses nouveaux produits : Cloud privé ou public (Solution Azure) ...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Forum
C++ C++ par yesoun1
Cliquez pour lire la suite par yesoun1 OPNETOPNET par hth21
Cliquez pour lire la suite par hth21 RE : ARBRE BINAIRERE : ARBRE BINAIRE par pacotheking
Cliquez pour lire la suite par pacotheking
Logiciels
Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|