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

GTK+ avec C & C++ Discussion :

GTK+ Un bouton dans un onglet


Sujet :

GTK+ avec C & C++

  1. #1
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2013
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2013
    Messages : 2
    Par défaut GTK+ Un bouton dans un onglet
    Bonjour,

    Ayant tout juste commencé GTK+, je me retrouve confronté au problème suivant:

    Comment puis-je rendre actif un bouton qui est dans un onglet?
    Je me suis basé sur ces excellents tutoriels: http://gtk.developpez.com/cours/gtk2/ et http://nicolasj.developpez.com/gtk/cours/.

    J'ai créé deux onglets, le premier contient deux boutons et je ne sais pas comment faire pour les rendre fonctionnels...

    Je met à disposition le code:

    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
    #include <stdlib.h>
    #include <gtk/gtk.h>
    #include "callback.h"
     
    int main(int argc, char **argv)
    {
        GtkWidget *pWindow;
        GtkWidget *pVBox;
        GtkWidget *pNotebook;
        GtkWidget *pButton;
        gint i;
        gint page_actuelle;
     
        // Creation onglets
        GtkWidget *pLabel;
        GtkWidget *p_buttons;
        GtkWidget *pTabLabel;
        GtkWidget *pChild;
        gchar *sLabel;
        gchar *sTabLabel;
     
     
        // Onglet 1
        GtkWidget *p_button_on;
        GtkWidget *p_button_off;
     
        gtk_init(&argc,&argv);
     
        pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_title(GTK_WINDOW(pWindow), "Interrupteur.exe");
        gtk_window_set_default_size(GTK_WINDOW(pWindow), 320, 200);
        g_signal_connect(G_OBJECT(pWindow), "delete-event", G_CALLBACK(quitter_fenetre), NULL);
     
        pVBox = gtk_vbox_new(FALSE, 0);
        gtk_container_add(GTK_CONTAINER(pWindow), pVBox);
     
        /* Creation du GtkNotebook */
        pNotebook = gtk_notebook_new();
        gtk_box_pack_start(GTK_BOX(pVBox), pNotebook, TRUE, TRUE, 0);
        gtk_notebook_set_tab_pos(GTK_NOTEBOOK(pNotebook), GTK_POS_TOP);
     
        // Creation des onglets
        sLabel = "A Completer";
     
        sTabLabel = "Allumer/Eteindre";
        p_buttons = gtk_hbox_new(FALSE, 0);
     
        p_button_on = gtk_button_new_with_label("Allumer");
        p_button_off = gtk_button_new_with_label("Eteindre");
     
        gtk_box_pack_start(GTK_BOX(p_buttons), p_button_on, FALSE, FALSE, 0);
        gtk_box_pack_start(GTK_BOX(p_buttons), p_button_off, FALSE, FALSE, 0);
        g_signal_connect (G_OBJECT (p_button_on), "clicked", G_CALLBACK (button_on), NULL);
     
            /* Creation des differents GtkLabel */
        pLabel = gtk_label_new(sLabel);
        pTabLabel = gtk_label_new(sTabLabel);
     
            /* Insertion de la page */
        gtk_notebook_append_page(GTK_NOTEBOOK(pNotebook), p_buttons, pTabLabel);
     
        g_free(sLabel);
        g_free(sTabLabel);
     
        page_actuelle = gtk_notebook_get_current_page(GTK_NOTEBOOK(pNotebook));
     
        g_signal_connect(G_OBJECT(p_button_on), "clicked", G_CALLBACK(button_on), NULL);
     
        sTabLabel = "Programmer sequence";
        // Faire 2eme onglet
        pLabel = gtk_label_new(sLabel);
        pTabLabel = gtk_label_new(sTabLabel);
     
            // Insertion de la page
        gtk_notebook_append_page(GTK_NOTEBOOK(pNotebook), pLabel, pTabLabel);
     
        g_free(sLabel);
        g_free(sTabLabel);
        // Fin Creation onglet
     
     
        pButton = gtk_button_new_with_label("Informations");
        gtk_box_pack_start(GTK_BOX(pVBox), pButton, FALSE, FALSE, 0);
     
        // Inefficace
        pChild = gtk_notebook_get_nth_page(pNotebook, page_actuelle);
     
        g_signal_connect(G_OBJECT(pButton), "clicked", G_CALLBACK(OnButton), pNotebook);
     
        gtk_widget_show_all(pWindow);
     
        gtk_main();
        return 0;
    }
    Je vous remercie d'avance.

  2. #2
    Membre averti Avatar de diesel83
    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Décembre 2014
    Messages
    57
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Décembre 2014
    Messages : 57
    Par défaut
    Ben..., tu déclares deux fonctions de callback (button_on et OnButton). Il faudrait peut être penser à les coder.

    Et il y a aussi la fonction quitter_fenetre.

    Jean-Marie

  3. #3
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2013
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2013
    Messages : 2
    Par défaut
    Et bien, je les ai codées dans un fichier callback.c d'ou le include "callback.h"
    Je me suis rendu compte que ce que je voulais n'était autre que des boîtes de dialogues...
    Excusez moi de mon post inutile, c'était la panique...

    Merci beaucoup

Discussions similaires

  1. [XL-2010] Ruban Excel: ajouter un bouton dans un onglet existant
    Par Eelectron dans le forum Excel
    Réponses: 0
    Dernier message: 10/06/2015, 22h22
  2. [XL-2003] Problème lié à la suppression de boutons dans un onglet masqué
    Par onobyone dans le forum Macros et VBA Excel
    Réponses: 8
    Dernier message: 16/09/2011, 18h25
  3. [AC-2007] Créer un contrôle Bouton dans un onglet
    Par jpg75014 dans le forum IHM
    Réponses: 8
    Dernier message: 30/11/2010, 12h12
  4. Problème de boutons dans des onglets
    Par nicolav dans le forum Macros et VBA Excel
    Réponses: 5
    Dernier message: 08/07/2009, 10h33
  5. Ajouter un bouton dans un onglet
    Par cocacola dans le forum GTK+ avec C & C++
    Réponses: 2
    Dernier message: 30/04/2007, 18h43

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