IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C Discussion :

Problèmes de création d'une boite de dialogue avec gnome_message_box_new


Sujet :

C

  1. #1
    Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2003
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2003
    Messages : 13
    Points : 3
    Points
    3
    Par défaut Problèmes de création d'une boite de dialogue avec gnome_message_box_new
    Bonjour,

    J'ai déniché un tutoriel pour la programmation Gnome avec Glade sur
    http://eddy.writelinux.com/fr/part2/

    La création de l'interface avec Glade ne pose pas de problèmes.

    Après, je modifie pas-à-pas avec un éditeur de texte le fichier
    callbacks.c . Tout va bien jusque la ligne suivante :

    msgBox = gnome_message_box_new
    (message,GNOME_MESSAGE_BOX_INFO,GNOME_STOCK_BUTTON_OK,NULL);

    Quand je fais un make, il me dit :

    callbacks.c: In function ‘on_FConvertir_Bouton_clicked’:
    callbacks.c:65: error: ‘GNOME_MESSAGE_BOX_INFO’ undeclared (first use in
    this function)
    callbacks.c:65: error: (Each undeclared identifier is reported only once
    callbacks.c:65: error: for each function it appears in.)
    callbacks.c:65: error: ‘GNOME_STOCK_BUTTON_OK’ undeclared (first use in
    this function)
    callbacks.c:65: warning: assignment makes pointer from integer without a
    cast
    make: *** [callbacks.o] Erreur 1

    Le tutoriel ne parle pas de déclarer quoi que ce soit. Où est l'erreur?

    J'utilise Gnome 2 et Gtk 2.

    Si quelqu'un peut m'aider, ça me ferais plaisir.

    Merci d'avance.

  2. #2
    Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2003
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2003
    Messages : 13
    Points : 3
    Points
    3
    Par défaut
    Je pense qu'il va être plus simple de vous montrer tout le code du fichier callbacks.c :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    #ifdef HAVE_CONFIG_H
    #  include <config.h>
    #endif
     
    #include <gtk/gtk.h>
     
    #include "callbacks.h"
    #include "interface.h"
    #include "support.h"
     
     
     
    void
    on_Info_Bouton_clicked                 (GtkButton       *button,
                                            gpointer         user_data)
    {
     
    }
     
     
    void
    on_button1_clicked                     (GtkButton       *button,
                                            gpointer         user_data)
    {
     
    gtk_widget_show(create_aboutdialog1());
     
    }
     
     
    void
    on_Quitter_Bouton_clicked              (GtkButton       *button,
                                            gpointer         user_data)
    {
     
    gtk_main_quit();
     
    }
     
     
    void
    on_FConvertir_Bouton_clicked           (GtkButton       *button,
                                            gpointer         user_data)
    {
     
    // Notre boite de messagee
    GtkWidget *msgBox;
     
    // Valeur retournée par gnome_dialog_run_and_close
    gint returnVal;   
     
    // La vaeur retournée par g_strdup_printf devant etre passé à gnome_message_box_new
    gchar* message;
     
    // Résupération de la valeur Fahrenheit du widget de saisie de texte
    GtkWidget * fValue = lookup_widget(GTK_WIDGET(button), "F_saisie");
     
    // Conversion du texte récupéré en double
    gdouble fahrenheit = g_strtod(gtk_entry_get_text(GTK_ENTRY(fValue)),NULL);
     
    // Construction de la chaine finale qui sera passé à gnome_message_box_new
    message = g_strdup_printf("Le résultat est: %.2f degrés celsius.",( (5.0 / 9.0) * (fahrenheit - 32 ) )) ;
     
    // Création de notre boite de message
    msgBox = gnome_message_box_new (message,GNOME_MESSAGE_BOX_INFO,GNOME_STOCK_BUTTON_OK,NULL);
     
    // Affichage de la boite de message
    returnVal = gnome_dialog_run_and_close (GNOME_DIALOG (msgBox));
     
    // Libération de la mémoire alloué par g_strdup_printf
    g_free (message);
     
    }
     
     
    void
    on_CConvertir_Bouton_clicked           (GtkButton       *button,
                                            gpointer         user_data)
    {
     
     
    }
     
     
    void
    on_window_destroy                      (GtkObject       *object,
                                            gpointer         user_data)
    {
     
    gtk_main_quit();
     
    }

  3. #3
    Expert éminent sénior
    Avatar de Skyounet
    Homme Profil pro
    Software Engineer
    Inscrit en
    Mars 2005
    Messages
    6 380
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2005
    Messages : 6 380
    Points : 13 380
    Points
    13 380
    Par défaut


    A utiliser GTK, autant utiliser GTK jusqu'au bout.

    http://developer.gnome.org/doc/API/2...ageDialog.html

  4. #4
    Rédacteur
    Avatar de Franck.H
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2004
    Messages
    6 951
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Service public

    Informations forums :
    Inscription : Janvier 2004
    Messages : 6 951
    Points : 12 462
    Points
    12 462
    Par défaut
    Une chose de paraît bizarre ... tu veux utiliser des fonctions et constantes de GNOME mais je ne vois pas dans ton code de choses du style:

  5. #5
    Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2003
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2003
    Messages : 13
    Points : 3
    Points
    3
    Par défaut
    Bonjour,

    Effectivement, le tuto n'en parle pas. Je débute et je tatonne.

    Quand j'ajoute le #include <gnome.h>, il me dit que le fichier n'existe pas.

    Je suis sur Ubuntu 6.10 64 bit, et j'ai déjà rencontrer des petits problèmes. Genre Codeblocks qui ne fonctionne pas ou Anjuta qui débloque.

    Le gnome.h est contenu dans quel paquet?

    Merci d'avance.

  6. #6
    Rédacteur
    Avatar de Franck.H
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2004
    Messages
    6 951
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Service public

    Informations forums :
    Inscription : Janvier 2004
    Messages : 6 951
    Points : 12 462
    Points
    12 462
    Par défaut
    Citation Envoyé par Korak
    Bonjour,

    Effectivement, le tuto n'en parle pas. Je débute et je tatonne.

    Quand j'ajoute le #include <gnome.h>, il me dit que le fichier n'existe pas.

    Je suis sur Ubuntu 6.10 64 bit, et j'ai déjà rencontrer des petits problèmes. Genre Codeblocks qui ne fonctionne pas ou Anjuta qui débloque.

    Le gnome.h est contenu dans quel paquet?

    Merci d'avance.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    sudo apt-get install libgnome2-dev

  7. #7
    Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2003
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2003
    Messages : 13
    Points : 3
    Points
    3
    Par défaut
    J'ai fais une recherche sur mon système. J'ai un libgnome.h dans /usr/include/libgnome-2.0/libgnome et un gnome.h dans /usr/include/libgnomeui-2.0

    Donc, je suppose que tout est installé. Faut-il que je réinstalle?

  8. #8
    Rédacteur
    Avatar de Franck.H
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2004
    Messages
    6 951
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Service public

    Informations forums :
    Inscription : Janvier 2004
    Messages : 6 951
    Points : 12 462
    Points
    12 462
    Par défaut
    Citation Envoyé par Korak
    J'ai fais une recherche sur mon système. J'ai un libgnome.h dans /usr/include/libgnome-2.0/libgnome et un gnome.h dans /usr/include/libgnomeui-2.0

    Donc, je suppose que tout est installé. Faut-il que je réinstalle?
    Non, apparement tu as ce qu'il faut. Il te suffit d'inclure le header gnome.h c'est tout. Si en plus tu utilises Glade et que tu as fait un prjet Gnome et non pas GTK+ tu possède les Makefile qui vont bien donc il ne devrait pas y avoir de soucis particuliers.

  9. #9
    Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2003
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2003
    Messages : 13
    Points : 3
    Points
    3
    Par défaut
    J'ai comparé les sources avec celles du 1er programme proposé par le tuto.

    Le #include <gnome.h> est repris dans 4 fichiers :

    callbacks.c
    interface.c
    main.c
    support.c

    De plus, dans le fichier interface.c il y a aussi #include <bonobo.h>

    J'ai ajouté ces lignes dans mon nouveau code et ça ne va toujours pas.

    Voici le résultat de make :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    be@ubuntu:~/Projets/Convertemp/src$ make
    gcc -DHAVE_CONFIG_H -I. -I. -I.. -DPACKAGE_DATA_DIR=\""/usr/local/share"\"      -DPACKAGE_LOCALE_DIR=\""/usr/local/share/locale"\"   -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include      -g -O2 -c main.c
    main.c:12:19: error: gnome.h: Aucun fichier ou répertoire de ce type
    make: *** [main.o] Erreur 1
    be@ubuntu:~/Projets/Convertemp/src$

  10. #10
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 379
    Points : 41 573
    Points
    41 573
    Par défaut
    Rajoute -I/usr/include/libgnomeui-2.0 à ta ligne de commande.

  11. #11
    Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2003
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2003
    Messages : 13
    Points : 3
    Points
    3
    Par défaut
    Même chose, pas de changement.

  12. #12
    Expert confirmé
    Avatar de Thierry Chappuis
    Homme Profil pro
    Enseignant Chercheur
    Inscrit en
    Mai 2005
    Messages
    3 499
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Suisse

    Informations professionnelles :
    Activité : Enseignant Chercheur
    Secteur : Industrie Pharmaceutique

    Informations forums :
    Inscription : Mai 2005
    Messages : 3 499
    Points : 5 360
    Points
    5 360
    Par défaut
    et avec:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    gcc -c -o tonprog.o tonprog.c `pkg-config --cflags libgnomeui-2.0`
    gcc -o tonprog tonprog.o `pkg-config --libs libgnomeui-2.0`
    où tonprog est à remplacer par les noms de fichier adéquats. Cela règle-t'il tes problèmes de compilation?

    Thierry

  13. #13
    Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2003
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2003
    Messages : 13
    Points : 3
    Points
    3
    Par défaut
    Voici le résultat :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    be@ubuntu:~/Projets/Convertemp/src$ gcc -c -o callbacks.o callbacks.c `pkg-config --cflags libgnomeui-2.0`
    be@ubuntu:~/Projets/Convertemp/src$ gcc -o callbacks callbacks.o `pkg-config --libs libgnomeui-2.0`
    /usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../lib64/crt1.o: In function `_start':
    (.text+0x20): référence indéfinie vers « main »
    callbacks.o: In function `on_button1_clicked':
    callbacks.c:(.text+0x1f): référence indéfinie vers « create_aboutdialog1 »
    callbacks.o: In function `on_FConvertir_Bouton_clicked':
    callbacks.c:(.text+0x6e): référence indéfinie vers « lookup_widget »
    collect2: ld returned 1 exit status
    be@ubuntu:~/Projets/Convertemp/src$
    Et avec les 3 autres fichiers .c , qu'est-ce que je fais?

  14. #14
    Expert confirmé
    Avatar de Thierry Chappuis
    Homme Profil pro
    Enseignant Chercheur
    Inscrit en
    Mai 2005
    Messages
    3 499
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Suisse

    Informations professionnelles :
    Activité : Enseignant Chercheur
    Secteur : Industrie Pharmaceutique

    Informations forums :
    Inscription : Mai 2005
    Messages : 3 499
    Points : 5 360
    Points
    5 360
    Par défaut
    Je ne pense que ton fichier callbacks.c ne contienne de fonction main.

    la commande
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    gcc -c -o callbacks.o callbacks.c `pkg-config --cflags libgnomeui-2.0 `
    seule te retourne-t'elle des erreurs?

    Thierry

  15. #15
    Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2003
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2003
    Messages : 13
    Points : 3
    Points
    3
    Par défaut
    Non, aucun message.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    be@ubuntu:~/Projets/Convertemp/src$ gcc -c -o callbacks.o callbacks.c `pkg-config --cflags libgnomeui-2.0 `
    be@ubuntu:~/Projets/Convertemp/src$

  16. #16
    Expert confirmé
    Avatar de Thierry Chappuis
    Homme Profil pro
    Enseignant Chercheur
    Inscrit en
    Mai 2005
    Messages
    3 499
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Suisse

    Informations professionnelles :
    Activité : Enseignant Chercheur
    Secteur : Industrie Pharmaceutique

    Informations forums :
    Inscription : Mai 2005
    Messages : 3 499
    Points : 5 360
    Points
    5 360
    Par défaut
    et puis avec

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    gcc -c -o callbacks.o callbacks.c `pkg-config --cflags libgnomeui-2.0 `
     
    gcc -c -o fichier2.o fichier2.c `pkg-config --cflags libgnomeui-2.0 `
     
    gcc -c -o fichier3.o fichier3.c `pkg-config --cflags libgnomeui-2.0 `
     
     
    gcc -o programme callbacks.o fichier2.o fichier3.o `pkg-config --libs libgnomeui-2.0 `
    Dis-nous quelles commandes engendrent des erreurs et poste les messages du compilateur le cas échéant.

    Thierry

  17. #17
    Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2003
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2003
    Messages : 13
    Points : 3
    Points
    3
    Par défaut
    voilà ce que ça donne :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
     
    be@ubuntu:~/Projets/Convertemp/src$ gcc -c -o callbacks.o callbacks.c `pkg-config --cflags libgnomeui-2.0 `
    be@ubuntu:~/Projets/Convertemp/src$ gcc -c -o interface.o interface.c `pkg-config --cflags libgnomeui-2.0 `
    interface.c: In function ‘create_aboutdialog1’:
    interface.c:165: error: ‘VERSION’ undeclared (first use in this function)
    interface.c:165: error: (Each undeclared identifier is reported only once
    interface.c:165: error: for each function it appears in.)
    be@ubuntu:~/Projets/Convertemp/src$ gcc -c -o main.o main.c `pkg-config --cflags libgnomeui-2.0 `
    main.c: In function ‘main’:
    main.c:31: error: ‘PACKAGE_DATA_DIR’ undeclared (first use in this function)
    main.c:31: error: (Each undeclared identifier is reported only once
    main.c:31: error: for each function it appears in.)
    main.c:31: error: expected ‘)’ before string constant
    be@ubuntu:~/Projets/Convertemp/src$ gcc -c -o support.o support.c `pkg-config --cflags libgnomeui-2.0 `
    be@ubuntu:~/Projets/Convertemp/src$ gcc -o convertemp callbacks.o interface.o main.o support.o `pkg-config --libs libgnomeui-2.0 `
    be@ubuntu:~/Projets/Convertemp/src$
    Donc, si je comprend bien, ça pose un problème au niveau des fichiers interface et main.

  18. #18
    Expert confirmé
    Avatar de Thierry Chappuis
    Homme Profil pro
    Enseignant Chercheur
    Inscrit en
    Mai 2005
    Messages
    3 499
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Suisse

    Informations professionnelles :
    Activité : Enseignant Chercheur
    Secteur : Industrie Pharmaceutique

    Informations forums :
    Inscription : Mai 2005
    Messages : 3 499
    Points : 5 360
    Points
    5 360
    Par défaut
    Les problèmes semblent se situer dans tes fichiers main.c et interface.c avec les macros VERSION et PACKAGE_DATA_DIR qui ne sont pas définies.

    D'où viennent ces macros? As-tu posté le code de ces deux fixhiers? Je ne l'ai pas vu, mais peut-être ai-je passé ton post trop vite.

    Thierry

  19. #19
    Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2003
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2003
    Messages : 13
    Points : 3
    Points
    3
    Par défaut
    Non, j'ajoute le code de tous mes fichiers.

    Le fichier callbacks.c

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    #ifdef HAVE_CONFIG_H
    #  include <config.h>
    #endif
     
    #include <gtk/gtk.h>
     
    #include <gnome.h>
     
    #include "callbacks.h"
    #include "interface.h"
    #include "support.h"
     
     
     
    void
    on_Info_Bouton_clicked                 (GtkButton       *button,
                                            gpointer         user_data)
    {
     
    }
     
     
    void
    on_button1_clicked                     (GtkButton       *button,
                                            gpointer         user_data)
    {
     
    gtk_widget_show(create_aboutdialog1());
     
    }
     
     
    void
    on_Quitter_Bouton_clicked              (GtkButton       *button,
                                            gpointer         user_data)
    {
     
    gtk_main_quit();
     
    }
     
     
    void
    on_FConvertir_Bouton_clicked           (GtkButton       *button,
                                            gpointer         user_data)
    {
     
    // Notre boite de messagee
    GtkWidget *msgBox;
     
    // Valeur retournée par gnome_dialog_run_and_close
    gint returnVal;   
     
    // La vaeur retournée par g_strdup_printf devant etre passé à gnome_message_box_new
    gchar* message;
     
    // Résupération de la valeur Fahrenheit du widget de saisie de texte
    GtkWidget * fValue = lookup_widget(GTK_WIDGET(button), "F_saisie");
     
    // Conversion du texte récupéré en double
    gdouble fahrenheit = g_strtod(gtk_entry_get_text(GTK_ENTRY(fValue)),NULL);
     
    // Construction de la chaine finale qui sera passé à gnome_message_box_new
    message = g_strdup_printf("Le résultat est: %.2f degrés celsius.",( (5.0 / 9.0) * (fahrenheit - 32 ) )) ;
     
    // Création de notre boite de message
    msgBox = gnome_message_box_new (message,GNOME_MESSAGE_BOX_INFO,GNOME_STOCK_BUTTON_OK,NULL);
     
    // Affichage de la boite de message
    returnVal = gnome_dialog_run_and_close (GNOME_DIALOG (msgBox));
     
    // Libération de la mémoire alloué par g_strdup_printf
    g_free (message);
     
    }
     
     
    void
    on_CConvertir_Bouton_clicked           (GtkButton       *button,
                                            gpointer         user_data)
    {
     
     
    }
    Le fichier interface.c

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
     
    /*
     * DO NOT EDIT THIS FILE - it is generated by Glade.
     */
     
    #ifdef HAVE_CONFIG_H
    #  include <config.h>
    #endif
     
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <unistd.h>
    #include <string.h>
    #include <stdio.h>
     
    #include <gdk/gdkkeysyms.h>
    #include <gtk/gtk.h>
     
    #include "callbacks.h"
    #include "interface.h"
    #include "support.h"
     
    #define GLADE_HOOKUP_OBJECT(component,widget,name) \
      g_object_set_data_full (G_OBJECT (component), name, \
        gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
     
    #define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
      g_object_set_data (G_OBJECT (component), name, widget)
     
    GtkWidget*
    create_window (void)
    {
      GtkWidget *window;
      GtkWidget *fixed1;
      GtkWidget *F_Saisie;
      GtkWidget *C_Saisie;
      GtkWidget *hseparator1;
      GtkWidget *label1;
      GtkWidget *label2;
      GtkWidget *Info_Bouton;
      GtkWidget *CConvertir_Bouton;
      GtkWidget *Quitter_Bouton;
      GtkWidget *APropos_Bouton;
      GtkWidget *FConvertir_Bouton;
      GtkTooltips *tooltips;
     
      tooltips = gtk_tooltips_new ();
     
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_title (GTK_WINDOW (window), _("window"));
      gtk_window_set_default_size (GTK_WINDOW (window), 500, 400);
      gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
     
      fixed1 = gtk_fixed_new ();
      gtk_widget_show (fixed1);
      gtk_container_add (GTK_CONTAINER (window), fixed1);
     
      F_Saisie = gtk_entry_new ();
      gtk_widget_show (F_Saisie);
      gtk_fixed_put (GTK_FIXED (fixed1), F_Saisie, 112, 16);
      gtk_widget_set_size_request (F_Saisie, 160, 27);
      gtk_tooltips_set_tip (tooltips, F_Saisie, _("Valeur Fahrenheit \303\240 convertir en Celsius"), NULL);
      gtk_entry_set_invisible_char (GTK_ENTRY (F_Saisie), 9679);
     
      C_Saisie = gtk_entry_new ();
      gtk_widget_show (C_Saisie);
      gtk_fixed_put (GTK_FIXED (fixed1), C_Saisie, 112, 56);
      gtk_widget_set_size_request (C_Saisie, 160, 27);
      gtk_tooltips_set_tip (tooltips, C_Saisie, _("Valeur Celsius \303\240 convertir en Fahrenheit"), NULL);
      gtk_entry_set_invisible_char (GTK_ENTRY (C_Saisie), 9679);
     
      hseparator1 = gtk_hseparator_new ();
      gtk_widget_show (hseparator1);
      gtk_fixed_put (GTK_FIXED (fixed1), hseparator1, 0, 96);
      gtk_widget_set_size_request (hseparator1, 496, 16);
     
      label1 = gtk_label_new (_("Fahrenheit"));
      gtk_widget_show (label1);
      gtk_fixed_put (GTK_FIXED (fixed1), label1, 16, 24);
      gtk_widget_set_size_request (label1, 80, 16);
     
      label2 = gtk_label_new (_("Celsius"));
      gtk_widget_show (label2);
      gtk_fixed_put (GTK_FIXED (fixed1), label2, 16, 64);
      gtk_widget_set_size_request (label2, 56, 16);
     
      Info_Bouton = gtk_button_new_with_mnemonic (_("Info"));
      gtk_widget_show (Info_Bouton);
      gtk_fixed_put (GTK_FIXED (fixed1), Info_Bouton, 16, 128);
      gtk_widget_set_size_request (Info_Bouton, 62, 29);
      gtk_tooltips_set_tip (tooltips, Info_Bouton, _("Information sur la formule"), NULL);
     
      CConvertir_Bouton = gtk_button_new_with_mnemonic (_("Convertir"));
      gtk_widget_show (CConvertir_Bouton);
      gtk_fixed_put (GTK_FIXED (fixed1), CConvertir_Bouton, 296, 56);
      gtk_widget_set_size_request (CConvertir_Bouton, 72, 29);
      gtk_tooltips_set_tip (tooltips, CConvertir_Bouton, _("Convertit la valeur Celsius"), NULL);
     
      Quitter_Bouton = gtk_button_new_with_mnemonic (_("Quitter"));
      gtk_widget_show (Quitter_Bouton);
      gtk_fixed_put (GTK_FIXED (fixed1), Quitter_Bouton, 304, 128);
      gtk_widget_set_size_request (Quitter_Bouton, 62, 29);
      gtk_tooltips_set_tip (tooltips, Quitter_Bouton, _("Quitter l'application"), NULL);
     
      APropos_Bouton = gtk_button_new_with_mnemonic (_("A propos"));
      gtk_widget_show (APropos_Bouton);
      gtk_fixed_put (GTK_FIXED (fixed1), APropos_Bouton, 160, 128);
      gtk_widget_set_size_request (APropos_Bouton, 80, 29);
      gtk_tooltips_set_tip (tooltips, APropos_Bouton, _("Information \303\240 propos de cette application"), NULL);
     
      FConvertir_Bouton = gtk_button_new_with_mnemonic (_("Convertir"));
      gtk_widget_show (FConvertir_Bouton);
      gtk_fixed_put (GTK_FIXED (fixed1), FConvertir_Bouton, 296, 16);
      gtk_widget_set_size_request (FConvertir_Bouton, 72, 29);
      gtk_tooltips_set_tip (tooltips, FConvertir_Bouton, _("Convertit la valeur Fahrenheit"), NULL);
     
      g_signal_connect ((gpointer) window, "destroy",
                        G_CALLBACK (on_window_destroy),
                        NULL);
      g_signal_connect ((gpointer) Info_Bouton, "clicked",
                        G_CALLBACK (on_Info_Bouton_clicked),
                        NULL);
      g_signal_connect ((gpointer) CConvertir_Bouton, "clicked",
                        G_CALLBACK (on_CConvertir_Bouton_clicked),
                        NULL);
      g_signal_connect ((gpointer) Quitter_Bouton, "clicked",
                        G_CALLBACK (on_Quitter_Bouton_clicked),
                        NULL);
      g_signal_connect ((gpointer) APropos_Bouton, "clicked",
                        G_CALLBACK (on_button1_clicked),
                        NULL);
      g_signal_connect ((gpointer) FConvertir_Bouton, "clicked",
                        G_CALLBACK (on_FConvertir_Bouton_clicked),
                        NULL);
     
      /* Store pointers to all widgets, for use by lookup_widget(). */
      GLADE_HOOKUP_OBJECT_NO_REF (window, window, "window");
      GLADE_HOOKUP_OBJECT (window, fixed1, "fixed1");
      GLADE_HOOKUP_OBJECT (window, F_Saisie, "F_Saisie");
      GLADE_HOOKUP_OBJECT (window, C_Saisie, "C_Saisie");
      GLADE_HOOKUP_OBJECT (window, hseparator1, "hseparator1");
      GLADE_HOOKUP_OBJECT (window, label1, "label1");
      GLADE_HOOKUP_OBJECT (window, label2, "label2");
      GLADE_HOOKUP_OBJECT (window, Info_Bouton, "Info_Bouton");
      GLADE_HOOKUP_OBJECT (window, CConvertir_Bouton, "CConvertir_Bouton");
      GLADE_HOOKUP_OBJECT (window, Quitter_Bouton, "Quitter_Bouton");
      GLADE_HOOKUP_OBJECT (window, APropos_Bouton, "APropos_Bouton");
      GLADE_HOOKUP_OBJECT (window, FConvertir_Bouton, "FConvertir_Bouton");
      GLADE_HOOKUP_OBJECT_NO_REF (window, tooltips, "tooltips");
     
      return window;
    }
     
    GtkWidget*
    create_aboutdialog1 (void)
    {
      GtkWidget *aboutdialog1;
      const gchar *authors[] = {
        "Benoit Colige",
        NULL
      };
      /* TRANSLATORS: Replace this string with your names, one name per line. */
      gchar *translators = _("translator-credits");
     
      aboutdialog1 = gtk_about_dialog_new ();
      gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (aboutdialog1), VERSION);
      gtk_about_dialog_set_name (GTK_ABOUT_DIALOG (aboutdialog1), _("Convertemp"));
      gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG (aboutdialog1), _("Ce petit utilitaire sert \303\240 effectuer des convertions de temp\303\251ratures entre Fahrenheit et Celsius."));
      gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG (aboutdialog1), authors);
      gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG (aboutdialog1), translators);
     
      /* Store pointers to all widgets, for use by lookup_widget(). */
      GLADE_HOOKUP_OBJECT_NO_REF (aboutdialog1, aboutdialog1, "aboutdialog1");
     
      return aboutdialog1;
    }
    Le fichier main.c

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    /*
     * Initial main.c file generated by Glade. Edit as required.
     * Glade will not overwrite this file.
     */
     
    #ifdef HAVE_CONFIG_H
    #  include <config.h>
    #endif
     
    #include <gtk/gtk.h>
     
    #include <gnome.h>
     
    #include "interface.h"
    #include "support.h"
     
    int
    main (int argc, char *argv[])
    {
      GtkWidget *window;
     
    #ifdef ENABLE_NLS
      bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
      bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
      textdomain (GETTEXT_PACKAGE);
    #endif
     
      gtk_set_locale ();
      gtk_init (&argc, &argv);
     
      add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
     
      /*
       * The following code was added by Glade to create one of each component
       * (except popup menus), just so that you see something after building
       * the project. Delete any components that you don't want shown initially.
       */
      window = create_window ();
      gtk_widget_show (window);
     
      gtk_main ();
      return 0;
    }
    Le fichier support.c

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
     
    /*
     * DO NOT EDIT THIS FILE - it is generated by Glade.
     */
     
    #ifdef HAVE_CONFIG_H
    #  include <config.h>
    #endif
     
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <unistd.h>
    #include <string.h>
    #include <stdio.h>
     
    #include <gtk/gtk.h>
     
    #include "support.h"
     
    GtkWidget*
    lookup_widget                          (GtkWidget       *widget,
                                            const gchar     *widget_name)
    {
      GtkWidget *parent, *found_widget;
     
      for (;;)
        {
          if (GTK_IS_MENU (widget))
            parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
          else
            parent = widget->parent;
          if (!parent)
            parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
          if (parent == NULL)
            break;
          widget = parent;
        }
     
      found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
                                                     widget_name);
      if (!found_widget)
        g_warning ("Widget not found: %s", widget_name);
      return found_widget;
    }
     
    static GList *pixmaps_directories = NULL;
     
    /* Use this function to set the directory containing installed pixmaps. */
    void
    add_pixmap_directory                   (const gchar     *directory)
    {
      pixmaps_directories = g_list_prepend (pixmaps_directories,
                                            g_strdup (directory));
    }
     
    /* This is an internally used function to find pixmap files. */
    static gchar*
    find_pixmap_file                       (const gchar     *filename)
    {
      GList *elem;
     
      /* We step through each of the pixmaps directory to find it. */
      elem = pixmaps_directories;
      while (elem)
        {
          gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
                                             G_DIR_SEPARATOR_S, filename);
          if (g_file_test (pathname, G_FILE_TEST_EXISTS))
            return pathname;
          g_free (pathname);
          elem = elem->next;
        }
      return NULL;
    }
     
    /* This is an internally used function to create pixmaps. */
    GtkWidget*
    create_pixmap                          (GtkWidget       *widget,
                                            const gchar     *filename)
    {
      gchar *pathname = NULL;
      GtkWidget *pixmap;
     
      if (!filename || !filename[0])
          return gtk_image_new ();
     
      pathname = find_pixmap_file (filename);
     
      if (!pathname)
        {
          g_warning (_("Couldn't find pixmap file: %s"), filename);
          return gtk_image_new ();
        }
     
      pixmap = gtk_image_new_from_file (pathname);
      g_free (pathname);
      return pixmap;
    }
     
    /* This is an internally used function to create pixmaps. */
    GdkPixbuf*
    create_pixbuf                          (const gchar     *filename)
    {
      gchar *pathname = NULL;
      GdkPixbuf *pixbuf;
      GError *error = NULL;
     
      if (!filename || !filename[0])
          return NULL;
     
      pathname = find_pixmap_file (filename);
     
      if (!pathname)
        {
          g_warning (_("Couldn't find pixmap file: %s"), filename);
          return NULL;
        }
     
      pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
      if (!pixbuf)
        {
          fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
                   pathname, error->message);
          g_error_free (error);
        }
      g_free (pathname);
      return pixbuf;
    }
     
    /* This is used to set ATK action descriptions. */
    void
    glade_set_atk_action_description       (AtkAction       *action,
                                            const gchar     *action_name,
                                            const gchar     *description)
    {
      gint n_actions, i;
     
      n_actions = atk_action_get_n_actions (action);
      for (i = 0; i < n_actions; i++)
        {
          if (!strcmp (atk_action_get_name (action, i), action_name))
            atk_action_set_description (action, i, description);
        }
    }
    Voilà, je ne sais vraiment pas ce qu'il se passe.

    Merci de vos réponses.

Discussions similaires

  1. Réponses: 5
    Dernier message: 28/07/2009, 21h38
  2. Création d'une boite de dialogue
    Par sako31 dans le forum MATLAB
    Réponses: 7
    Dernier message: 07/11/2007, 15h35
  3. Réponses: 5
    Dernier message: 22/06/2007, 14h55
  4. Réponses: 1
    Dernier message: 06/01/2007, 15h22
  5. Création d'une boite de dialogue type MessageBox
    Par kurkaine dans le forum C++Builder
    Réponses: 8
    Dernier message: 25/10/2006, 11h45

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo