RE: Newbie question



I think this is better:

        gtk_entry_append_text(myentry,"1");

done!


-----Original Message-----
From: gtk-app-devel-list-admin gnome org
[mailto:gtk-app-devel-list-admin gnome org] On Behalf Of
martyn 2 russell bt com
Sent: Tuesday, October 14, 2003 2:04 PM
To: gtk-app-devel-list gnome org
Subject: RE: Newbie question


it means that `msg' was declared as `const [something] * msg;'
and now that you are assigning something to it, the compiler must
discard `const'.

Or the other way around.
gtk_entry_get_text returns const char *, and msg is probably char *.
either declare const char *msg, or cast it 
msg = (char *) gtk_entry_get_text...

Thats a bad idea IMO.

This means:

a) you may potentially free it
b) the compiler will not warn you if you try to free it
c) your app is likely to go tits up when you free it.


You should simply use:

        G_CONST_RETURN gchar *str = NULL;

        str = gtk_entry_get_text(myentry);
        
        <use str somewhere>

I would suggest:


        G_CONST_RETURN gchar *entry_text = NULL;
        gchar *value = NULL;

        entry_text = gtk_entry_get_text(GTK_ENTRY(entry));

        value = g_strdup_printf("%s1", entry_text);
        gtk_entry_set_text(GTK_ENTRY(entry), value);

        g_free(value);  



Regards,
Martyn
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]