Bonjour à tous,
Mon problème est assez similaire à celui de Yugioh, posté un peu plus en dessous.
Néanmoins, même si le thread m'avait bien aidé, je n'obtiens pas tout à fait ce que je voudrais.
Je m'explique : j'ai une struct avec un champ char* que je voudrais passer en paramètre du callback. Quand je veux récupérer cette valeur dans ma fonction, j'obtiens un nombre et non une chaine de caractères. Après pas mal d'essais, je me trouve un peu démuni devant la situation.

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
 
#include <stdlib.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
 
typedef struct _GtkEntry GtkEntry;
typedef struct s_str *t_str;
 
struct s_str
{
  char *str;
};
 
int main(int argc, char **argv)
{
	GtkWidget *pWindow, *todoBox, *toolBox, *container, *entry[10], *label, *pToolbar, *new, *save, *open, *create;
	int s = 0;
 
	t_str newstr = malloc(sizeof(struct s_str));
	newstr->str = "Hello";
 
	void newfield(GtkWidget *widget, gpointer data)
	{
		t_str test = (t_str)data;
		entry[s]= gtk_entry_new ();
		gtk_entry_set_text (GTK_ENTRY (entry[s]), g_strdup_printf("%d", test->str)); // M'affiche un nombre et non "Hello"
		gtk_container_add (GTK_CONTAINER (todoBox), entry[s]);
		s++;
		gtk_widget_show_all(pWindow);
	}
 
	gtk_init(&argc,&argv);
	// Fenetre principale
	pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(pWindow), "Test");
	gtk_window_set_default_size(GTK_WINDOW(pWindow), 400, 600);
	g_signal_connect(G_OBJECT(pWindow), "destroy", G_CALLBACK(gtk_main_quit), NULL);
 
	container = gtk_vbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(pWindow), container);
 
	//Création de la toolbar
	toolBox = gtk_hbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(container), toolBox);
	pToolbar = gtk_toolbar_new();
	gtk_box_pack_start(GTK_BOX(toolBox), pToolbar, FALSE, FALSE, 0);
	gtk_toolbar_set_style(GTK_TOOLBAR(pToolbar), GTK_TOOLBAR_ICONS);
 
	// box des champs
	todoBox = gtk_vbox_new(TRUE, 1);
	gtk_container_add(GTK_CONTAINER(container), todoBox);
 
	create = gtk_toolbar_insert_stock(GTK_TOOLBAR(pToolbar),
		GTK_STOCK_NEW, "New", NULL, NULL, NULL, -1);
 
	g_signal_connect (G_OBJECT(create), "clicked", G_CALLBACK (newfield), &newstr);
 
	gtk_widget_show_all(pWindow);
 
	gtk_main();
 
	return EXIT_SUCCESS;
}
En espérant que quelqu'un puisse m'aider. Merci d'avance !