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.