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 :

critical : gtk_adjustment_get_value lors de la destruction de la fenêtre


Sujet :

GTK+ avec C & C++

  1. #1
    Membre régulier
    Homme Profil pro
    Développeur Web en Loisir
    Inscrit en
    Janvier 2006
    Messages
    129
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Web en Loisir

    Informations forums :
    Inscription : Janvier 2006
    Messages : 129
    Points : 100
    Points
    100
    Par défaut critical : gtk_adjustment_get_value lors de la destruction de la fenêtre
    bonjour,

    J'ai crée une fenetre dans laquel j'insère une liste de valeur d'un tree view dans une scrolled window. Lorsque je clique sur une valeur, je voudrais détruire la fenêtre (pas par gtk_main_quit car c'est en fait une fenêtre secondaire pop_up).
    La fenêtre se détruit mais j'ai une erreur critique dans la console

    Gtk-CRITICAL **: gtk_adjustment_get_value: assertion 'GTK_IS_ADJUSTMENT (adjustment)' failed

    Pourtant, dans la doc j'ai lu que les adjustment se faisait tout seul si la scrolled window était initialisé avec NULL : gtk_scrolled_window_new(NULL, NULL).

    (ps : Le code de la gestion de la liste est issu du tuto gtk+ sur zetcode.com)


    Voici le code, j'ai indiqué dedans la ligne posant problème
    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
    #include <stdlib.h>
    #include <stdarg.h>
    // string.h nécessaire pour éviter warning implicit declaration of function strcmp
    #include <string.h>
    #include <stdbool.h>
    #include <math.h>
    #include <gtk/gtk.h>
     
    #ifndef M_PI
     #define M_PI 3.141592653
    #endif
     
    GtkWidget *pwindow_tools;
     
    enum
    {
      LIST_ITEM = 0,
      N_COLUMNS
    };
     
    static void init_list(GtkWidget *liste);
    static void add_to_list(GtkWidget *liste, const gint str);
    void on_changed(GtkWidget *widget, gpointer label);
    void close_wt(GtkWidget *button, gpointer data);
    int int_to_str(int value, char *buf, unsigned int len);
     
    /* -------------------------------------------------------
                     fonctions utilitaires int vers string
       -------------------------------------------------------*/
     
    int int_to_str(int value, char *buf, unsigned int len)
    {
    	unsigned result = 0;
     
    	if (!buf)
    		return -1;
     
    #define ADDCHAR(chr) \
    	if (result < len - 1) \
    	{ \
    		*buf++ = (chr); \
    		result++; \
    	}
     
    	int j = 0;
    	char int_to_str[16];
     
    	if (value < 0)
    		ADDCHAR('-');
     
    	char *ptr = int_to_str + sizeof(int_to_str) - 1;
    	do
    	{
    		int modulo = value % 10;
    		modulo = (modulo<0)?-modulo:modulo;
    		*ptr-- =  modulo + '0';
    		value /= 10;
    		j++;
    	} while (value);
     
    	for (; j > 0; j--)
    		ADDCHAR(int_to_str[sizeof(int_to_str) - j]);
     
    	*buf = '\0';
    	return 0;
    }
     
    static void init_list(GtkWidget *liste)
    {
      GtkCellRenderer *renderer;
      GtkTreeViewColumn *column;
      GtkListStore *store;
     
      renderer = gtk_cell_renderer_text_new();
      column = gtk_tree_view_column_new_with_attributes("List Items", renderer, "text", LIST_ITEM, NULL);
      /* centrer les éléments de la liste */
      g_object_set (renderer, "xalign", 0.5, NULL);
      gtk_tree_view_append_column(GTK_TREE_VIEW(liste), column);
      /* 1 colonne de type int*/
      store = gtk_list_store_new(1, G_TYPE_INT);
      gtk_tree_view_set_model(GTK_TREE_VIEW(liste), GTK_TREE_MODEL(store));
      g_object_unref(store);
    }
     
    static void add_to_list(GtkWidget *liste, const gint str)
    {
      GtkListStore *store;
      GtkTreeIter iter;
      store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(liste)));
      gtk_list_store_append(store, &iter);
      gtk_list_store_set(store, &iter, LIST_ITEM, str, -1);
    }
     
     
    void on_changed(GtkWidget *widget, gpointer data)
    {
      /* widget est un GtkTreeSelection */
      GtkTreeIter iter;
      GtkTreeModel *model;
      int value;
     
      if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(widget), &model, &iter)) {
        gtk_tree_model_get(model, &iter, LIST_ITEM, &value,  -1);
        g_print("value: %d", value);
        /* ligne liée à l'erreur */
        gtk_widget_destroy(GTK_WIDGET(pwindow_tools));
      }
    }
     
    void close_wt(GtkWidget *button, gpointer data) {
        gtk_main_quit();
    }
     
    /* -------------------------------------------------------
                            GTK Main
       -------------------------------------------------------*/
     
    int main (int argc, char *argv[]) {
     
        gtk_init (&argc, &argv);
     
        pwindow_tools = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_title(GTK_WINDOW(pwindow_tools), "Tool Box");
     
        GtkWidget *p_window_tools_notebook;
        GtkWidget *p_onglet2;
        GtkWidget *p_child;
        GtkWidget *liste, *label_liste;
        GtkTreeSelection *selection;
     
        /* --------  Création du Notebook ---------- */
     
        p_window_tools_notebook = gtk_notebook_new();
        gtk_widget_set_name( p_window_tools_notebook, "NoteBook");
     
        /* -------- CFL ---------- */
        liste = gtk_tree_view_new();
        gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(liste), FALSE);
        init_list(liste);
        int i;
     
        for (i=410; i>350; i=i-10) {
            add_to_list(liste, i);
        }
     
        selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(liste));
        g_signal_connect(selection, "changed", G_CALLBACK(on_changed), NULL);
     
        p_child = gtk_scrolled_window_new(NULL, NULL);
        gtk_widget_set_size_request(p_child,80, 100);
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(p_child), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
        gtk_container_add (GTK_CONTAINER (p_child), liste);
     
        p_onglet2 = gtk_label_new ("CFL");
        gtk_label_set_angle(GTK_LABEL(p_onglet2), 270);
        gtk_notebook_append_page (GTK_NOTEBOOK (p_window_tools_notebook), p_child, p_onglet2);
     
        gtk_notebook_set_tab_pos(GTK_NOTEBOOK(p_window_tools_notebook), GTK_POS_LEFT);
     
        gtk_container_add (GTK_CONTAINER (pwindow_tools), p_window_tools_notebook);
     
        gtk_widget_show_all(pwindow_tools);
     
      gtk_main ();
     
      return 0;
    }
    une idée ?

    Edit : simplification du code

  2. #2
    Membre régulier
    Homme Profil pro
    Développeur Web en Loisir
    Inscrit en
    Janvier 2006
    Messages
    129
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Web en Loisir

    Informations forums :
    Inscription : Janvier 2006
    Messages : 129
    Points : 100
    Points
    100
    Par défaut
    Indication :

    Après avoir effectué qq tests, je me suis aperçu que si j'enlevais le notebook, il n'y avait plus cette erreur.
    Donc ça vient du fait que le tree view soit à l'intérieur d'un notebook.

    D'ailleurs, sans le notebook la fonction on_changed est appelée à la création du tree view et la valeur selected est égale à la première valeur.(voir le g_print dans la console) Du coup le widget est détruit immédiatement, on a pas le temps de le voir à l'écran.
    Edit : Avec le notebook, cette fonction ne possède pas d'élément sélectionné.

    Code sans le notebook :
    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
    #include <stdlib.h>
    #include <stdarg.h>
    // string.h nécessaire pour éviter warning implicit declaration of function strcmp
    #include <string.h>
    #include <stdbool.h>
    #include <math.h>
    #include <gtk/gtk.h>
     
    #ifndef M_PI
     #define M_PI 3.141592653
    #endif
     
    GtkWidget *pwindow_tools;
     
    enum
    {
      LIST_ITEM = 0,
      N_COLUMNS
    };
     
    static void init_list(GtkWidget *liste);
    static void add_to_list(GtkWidget *liste, const gint str);
    void on_changed(GtkWidget *widget, gpointer label);
    void close_wt(GtkWidget *button, gpointer data);
    int int_to_str(int value, char *buf, unsigned int len);
     
    /* -------------------------------------------------------
                     fonctions utilitaires
       -------------------------------------------------------*/
     
    int int_to_str(int value, char *buf, unsigned int len)
    {
    	unsigned result = 0;
     
    	if (!buf)
    		return -1;
     
    #define ADDCHAR(chr) \
    	if (result < len - 1) \
    	{ \
    		*buf++ = (chr); \
    		result++; \
    	}
     
    	int j = 0;
    	char int_to_str[16];
     
    	if (value < 0)
    		ADDCHAR('-');
     
    	char *ptr = int_to_str + sizeof(int_to_str) - 1;
    	do
    	{
    		int modulo = value % 10;
    		modulo = (modulo<0)?-modulo:modulo;
    		*ptr-- =  modulo + '0';
    		value /= 10;
    		j++;
    	} while (value);
     
    	for (; j > 0; j--)
    		ADDCHAR(int_to_str[sizeof(int_to_str) - j]);
     
    	*buf = '\0';
    	return 0;
    }
     
    static void init_list(GtkWidget *liste)
    {
      GtkCellRenderer *renderer;
      GtkTreeViewColumn *column;
      GtkListStore *store;
     
      renderer = gtk_cell_renderer_text_new();
      column = gtk_tree_view_column_new_with_attributes("List Items", renderer, "text", LIST_ITEM, NULL);
      /* centrer les éléments de la liste */
      g_object_set (renderer, "xalign", 0.5, NULL);
      gtk_tree_view_append_column(GTK_TREE_VIEW(liste), column);
      /* 1 colonne de type int*/
      store = gtk_list_store_new(1, G_TYPE_INT);
      gtk_tree_view_set_model(GTK_TREE_VIEW(liste), GTK_TREE_MODEL(store));
      g_object_unref(store);
    }
     
    static void add_to_list(GtkWidget *liste, const gint str)
    {
      GtkListStore *store;
      GtkTreeIter iter;
      store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(liste)));
      gtk_list_store_append(store, &iter);
      gtk_list_store_set(store, &iter, LIST_ITEM, str, -1);
    }
     
     
    void on_changed(GtkWidget *widget, gpointer data)
    {
      /* widget est un GtkTreeSelection */
      GtkTreeIter iter;
      GtkTreeModel *model;
      int value;
     
      if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(widget), &model, &iter)) {
        gtk_tree_model_get(model, &iter, LIST_ITEM, &value,  -1);
        g_print("value: %d", value);
        /* ligne liée à l'erreur */
        gtk_widget_destroy(GTK_WIDGET(pwindow_tools));
      }
    }
     
    void close_wt(GtkWidget *button, gpointer data) {
        gtk_main_quit();
    }
     
    /* -------------------------------------------------------
                            GTK Main
       -------------------------------------------------------*/
     
    int main (int argc, char *argv[]) {
     
        gtk_init (&argc, &argv);
     
        pwindow_tools = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_title(GTK_WINDOW(pwindow_tools), "Tool Box");
     
        GtkWidget *p_window_tools_notebook;
        GtkWidget *p_onglet2;
        GtkWidget *p_child;
        GtkWidget *liste, *label_liste;
        GtkTreeSelection *selection;
     
        /* --------  Création du Notebook ---------- */
        /*
        p_window_tools_notebook = gtk_notebook_new();
        gtk_widget_set_name( p_window_tools_notebook, "NoteBook");
     
        /* -------- CFL ---------- */
        liste = gtk_tree_view_new();
        gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(liste), FALSE);
        init_list(liste);
        int i;
     
        for (i=410; i>350; i=i-10) {
            add_to_list(liste, i);
        }
     
        selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(liste));
        g_signal_connect(selection, "changed", G_CALLBACK(on_changed), NULL);
     
        p_child = gtk_scrolled_window_new(NULL, NULL);
        gtk_widget_set_size_request(p_child,80, 100);
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(p_child), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
        gtk_container_add (GTK_CONTAINER (p_child), liste);
        /*
        p_onglet2 = gtk_label_new ("CFL");
        gtk_label_set_angle(GTK_LABEL(p_onglet2), 270);
        gtk_notebook_append_page (GTK_NOTEBOOK (p_window_tools_notebook), p_child, p_onglet2);
     
        gtk_notebook_set_tab_pos(GTK_NOTEBOOK(p_window_tools_notebook), GTK_POS_LEFT);
        */
        gtk_container_add (GTK_CONTAINER (pwindow_tools), p_child);
     
        gtk_widget_show_all(pwindow_tools);
     
      gtk_main ();
     
      return 0;
    }
    ça avance mais là je cale...

  3. #3
    Membre régulier
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2006
    Messages
    90
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

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

    Informations forums :
    Inscription : Octobre 2006
    Messages : 90
    Points : 92
    Points
    92
    Par défaut
    Salut,

    Si j'ai bien survolé ton code :

    - Tu crées une fenêtre main;
    - Tu crées un notebook que tu ajoutes à ta fenêtre main
    - Tu crées une fenêtre fille dans laquelle tu ajoutes un treeview
    - Tu ajoutes cette fenêtre fille dans un nouvel onglet de notebook.

    Lorsque la sélection change, tu détruis la fenêtre main.

    As-tu essayé de procéder par étapes, sans détruire directement la fenêtre main ?
    i.e. détruire d'abord la fenêtre fille ou supprimer l'onglet ?

  4. #4
    Membre régulier
    Homme Profil pro
    Développeur Web en Loisir
    Inscrit en
    Janvier 2006
    Messages
    129
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Web en Loisir

    Informations forums :
    Inscription : Janvier 2006
    Messages : 129
    Points : 100
    Points
    100
    Par défaut
    salut,

    En fait je crée une fenêtre main. Depuis cette fenêtre, un clic sur un bouton déclenche l'ouverture de la fenêtre fille.
    Le code que j'ai mis (simplifié mais déclenchant le même pb) représente le code de la fenêtre fille.
    Cette fenêtre fille contient un notebook dans lequel j'insère dans un des onglets un tree view.
    Lorsque je clique sur le tree view pour sélectionner un élément, des choses diverses sont effectuées puis la fenêtre fille est détruite. C'est lors de cette destruction que j'ai le msg d'erreur.
    Si j'enlève le notebook, tout se passe bien.

    La différence entre les 2 cas :
    - avec notebook : erreur et pas de selected value initiale
    - sans notebook : ok la selected value = la première valeur de la liste du tree view


    ps : les codes sont compilables si tu veux tester

  5. #5
    Membre régulier
    Homme Profil pro
    Développeur Web en Loisir
    Inscrit en
    Janvier 2006
    Messages
    129
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Web en Loisir

    Informations forums :
    Inscription : Janvier 2006
    Messages : 129
    Points : 100
    Points
    100
    Par défaut pb cerné mais incomprehensible
    bonsoir,

    Après plusieurs autres tests, je m'aperçois que le pb ne vient pas spécialement du notebook.
    J'ai le même pb avec un gtk grid : voir code ci-dessous.
    Si j'enlève la grid et place le tree view (qui est dans une scroll window) directement dans la fenêtre, tout fonctionne.
    J'en déduis donc qu'il y a pb quand le tree view (et sa scroll window) est mis dans un container intermediaire ( comme un notebook ou une grid) qui est placé dans la fenêtre

    Comment faire pour résoudre cela ?

    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
    177
    178
    179
    180
    181
    182
    183
    #include <stdlib.h>
    #include <stdarg.h>
    #include <string.h>
    #include <stdbool.h>
    #include <math.h>
    #include <gtk/gtk.h>
     
    #ifndef M_PI
     #define M_PI 3.141592653
    #endif
     
    GtkWidget *pwindow_tools;
    GtkWidget *p_child;
     
    enum
    {
      LIST_ITEM = 0,
      N_COLUMNS
    };
     
    static void init_list(GtkWidget *liste);
    static void add_to_list(GtkWidget *liste, const gint str);
    void on_cflchanged(GtkWidget *widget, gpointer label);
    void close_wt(GtkWidget *button, gpointer data);
    int int_to_str(int value, char *buf, unsigned int len);
     
    /* -------------------------------------------------------
                     fonctions utilitaires
       -------------------------------------------------------*/
     
    int int_to_str(int value, char *buf, unsigned int len)
    {
    	unsigned result = 0;
     
    	if (!buf)
    		return -1;
     
    #define ADDCHAR(chr) \
    	if (result < len - 1) \
    	{ \
    		*buf++ = (chr); \
    		result++; \
    	}
     
    	int j = 0;
    	char int_to_str[16];
     
    	if (value < 0)
    		ADDCHAR('-');
     
    	char *ptr = int_to_str + sizeof(int_to_str) - 1;
    	do
    	{
    		int modulo = value % 10;
    		modulo = (modulo<0)?-modulo:modulo;
    		*ptr-- =  modulo + '0';
    		value /= 10;
    		j++;
    	} while (value);
     
    	for (; j > 0; j--)
    		ADDCHAR(int_to_str[sizeof(int_to_str) - j]);
     
    	*buf = '\0';
    	return 0;
    }
     
    static void init_list(GtkWidget *liste)
    {
      GtkCellRenderer *renderer;
      GtkTreeViewColumn *column;
      GtkListStore *store;
     
      renderer = gtk_cell_renderer_text_new();
      column = gtk_tree_view_column_new_with_attributes("List Items", renderer, "text", LIST_ITEM, NULL);
      /* centrer les ÈlÈments de la liste */
      g_object_set (renderer, "xalign", 0.5, NULL);
      gtk_tree_view_append_column(GTK_TREE_VIEW(liste), column);
      /* 1 colonne de type int*/
      store = gtk_list_store_new(1, G_TYPE_INT);
      gtk_tree_view_set_model(GTK_TREE_VIEW(liste), GTK_TREE_MODEL(store));
      g_object_unref(store);
    }
     
    static void add_to_list(GtkWidget *liste, const gint str)
    {
      GtkListStore *store;
      GtkTreeIter iter;
      store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(liste)));
      gtk_list_store_append(store, &iter);
      gtk_list_store_set(store, &iter, LIST_ITEM, str, -1);
    }
     
     
    void on_cflchanged(GtkWidget *widget, gpointer data)
    {
      /* widget est un GtkTreeSelection */
      GtkTreeIter iter;
      GtkTreeModel *model;
      int value;
     
      if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(widget), &model, &iter)) {
        gtk_tree_model_get(model, &iter, LIST_ITEM, &value,  -1);
        g_print("value: %d \n", value);
        /* remettre le destroy ci-dessous */
        gtk_widget_destroy(GTK_WIDGET(pwindow_tools));
      }
    }
     
    void close_wt(GtkWidget *button, gpointer data) {
        gtk_main_quit();
    }
     
    /* -------------------------------------------------------
                            GTK Main
       -------------------------------------------------------*/
     
    int main (int argc, char *argv[]) {
     
        gtk_init (&argc, &argv);
     
        /* ---------  crÈation FenÍtre pop-up ------------- */
     
        pwindow_tools = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     
        GtkWidget *pscrollwin;
        GtkWidget *p_window_tools_label1, *p_window_tools_label2;
        GtkWidget *p_window_tools_grid, *liste;
        GtkTreeSelection *selection;
     
        /* -------- CrÈation Grid 2x3 --------- */
        p_window_tools_grid = gtk_grid_new();
     
        /* -------- ligne 1 : Callsign + bouton close ---------- */
        GtkWidget *p_window_tools_close_button, *p_wt_close_im;
        p_window_tools_label1 = gtk_label_new("Avion");
     
        /* ------- Insertion Callsign dans GtkAlignment -------- */
        p_window_tools_close_button = gtk_button_new();
        p_wt_close_im = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
        gtk_container_add(GTK_CONTAINER (p_window_tools_close_button), p_wt_close_im);
        g_signal_connect(G_OBJECT(p_window_tools_close_button), "clicked", G_CALLBACK (close_wt), pwindow_tools);
     
        /* --------  Insertion ligne 1 dans grid --------- */
        gtk_grid_attach(GTK_GRID (p_window_tools_grid), p_window_tools_label1, 0, 0, 1, 1);
        gtk_grid_attach(GTK_GRID (p_window_tools_grid), p_window_tools_close_button, 1, 0, 1, 1);
     
        p_window_tools_label2 = gtk_label_new("CFL");
        gtk_grid_attach(GTK_GRID (p_window_tools_grid), p_window_tools_label2, 0, 1, 2, 1);
     
        /* --------  Ligne CFL ---------- */
     
            pscrollwin = gtk_scrolled_window_new(NULL, NULL);
            /* sans le size request, le widget a une hauteur de 0 pixel */
            gtk_widget_set_size_request(pscrollwin , 80, 100);
            gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(pscrollwin), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
     
            liste = gtk_tree_view_new();
            gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(liste), FALSE);
            init_list(liste);
            int i;
            for (i=490; i>410; i=i-20) {
                add_to_list(liste, i);
            }
            for (i=410; i>50; i=i-10) {
                add_to_list(liste, i);
            }
     
            gtk_container_add (GTK_CONTAINER(pscrollwin), GTK_WIDGET(liste));
            gtk_grid_attach(GTK_GRID (p_window_tools_grid), pscrollwin, 0, 2, 2, 1);
     
            selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(liste));
            gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
     
            gtk_container_add(GTK_CONTAINER(pwindow_tools), p_window_tools_grid);
            // gtk_container_add(GTK_CONTAINER(pwindow_tools), pscrollwin);
            gtk_widget_show_all(pwindow_tools);
            g_signal_connect(selection, "changed", G_CALLBACK(on_cflchanged), NULL);
     
      gtk_main ();
     
      return 0;
    }

  6. #6
    Membre régulier
    Homme Profil pro
    Développeur Web en Loisir
    Inscrit en
    Janvier 2006
    Messages
    129
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Web en Loisir

    Informations forums :
    Inscription : Janvier 2006
    Messages : 129
    Points : 100
    Points
    100
    Par défaut
    bonsoir,

    bon je crois que je vais remplacer gtk_widget_destroy par gtk_widget_hide et modifier le contenu de la fenêtre avant de la remontrer pour éviter l'erreur.

    bonne nuit

Discussions similaires

  1. [QThread] Problèmes lors de la destruction
    Par Anthares dans le forum Multithreading
    Réponses: 0
    Dernier message: 09/08/2012, 10h58
  2. [1.2] Problème lors de la destruction d'objet
    Par zithum dans le forum OpenSceneGraph
    Réponses: 3
    Dernier message: 18/05/2010, 11h54
  3. Plantage lors de la destruction d'une classe
    Par xwindoo dans le forum C++
    Réponses: 10
    Dernier message: 04/10/2006, 16h01
  4. Violation d'acces lors d'une destruction d'un composant
    Par Rayek dans le forum Composants VCL
    Réponses: 15
    Dernier message: 23/11/2005, 11h37
  5. Réponses: 2
    Dernier message: 17/08/2003, 20h07

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