Re: GTK question


Subject: Re: GTK question
sterwill@abisource.com
Date: Wed Feb 16 2000 - 01:17:58 CST


sam th wrote:
> In implementing the Word Count dialog, I obviously need to display some
> numbers that are going to be stored as integers. I am currently looking
> at the GTK tutorial, and I am unable to find someplace that tells me how
> to display an integer the same way I would use a label to display a
> string. I suspect that the answer to this is fairly obvious, but I have
> yet to find it. Thanks in advance

To GTK, it's all just a gchar string. If you need to display an integer in a
label, convert it to a string with a printf-like function. Something
like the following will get you a label with the number in it.

        UT_uint32 nWordCount; // this is the integer value from
                                // some XP word counting process in
                                // AbiWord, it has a value like 2033

        char string[128]; // enough to store a very large number

        g_snprintf(string, 128, "%d", nWordCount);

        GtkWidget * numberLabel = gtk_label_new(string);
        UT_ASSERT(numberLabel);

        gtk_widget_show(numberLabel);

        /* code follows to stick numberLabel in the dialog, etc. */

-- 
Shaw Terwilliger



This archive was generated by hypermail 2b25 : Wed Feb 16 2000 - 01:17:59 CST