Re: numerical buttons labels cont'd URGENT
- From: Diego Zuccato <diego otello alma unibo it>
- To: gtk-list gnome org
- Subject: Re: numerical buttons labels cont'd URGENT
- Date: Fri, 29 Nov 2002 00:14:37 +0000
Pierre CHATEL wrote:
(sorry for the previous answer, but I had to send quickly... job
calling...)
> if i use char str[16], it says:
> warning: passing arg 2 of `gtk_label_get' from incompatible pointer type
That's right.
> so it seems gtk_label_get does not work with pre-declared strings...in
> fact i was thinking that gtk_label_get was allocating memory, writing
> into it, and returning to me the pointer to this freashly allocated
> string...wich is why i used char *str at first !
Nope. See the source (following...). It returns a pointer to the
INTERNAL string...
That's the source from 2.0.9...
/**
 * gtk_label_set_label:
 * @label: a #GtkLabel
 * @str: the new text to set for the label
 *
 * Sets the text of the label. The label is interpreted as
 * including embedded underlines and/or Pango markup depending
 * on the values of label->use_underline and label->use_markup.
 **/
void
gtk_label_set_label (GtkLabel    *label,
                     const gchar *str)
{
  guint last_keyval;
  g_return_if_fail (GTK_IS_LABEL (label));
  g_return_if_fail (str != NULL);
  last_keyval = label->mnemonic_keyval;
  gtk_label_set_label_internal (label, g_strdup (str));
  gtk_label_recalculate (label);
  if (last_keyval != label->mnemonic_keyval)
    gtk_label_setup_mnemonic (label, last_keyval);
}
/**
 * gtk_label_get_label:
 * @label: a #GtkLabel
 *
 * Fetches the text from a label widget including any embedded
 * underlines indicating mnemonics and Pango markup. (See
 * gtk_label_get_text ()).
 *
 * Return value: the text of the label widget. This string is
 *   owned by the widget and must not be modified or freed.
 **/
G_CONST_RETURN gchar *
gtk_label_get_label (GtkLabel *label)
{
  g_return_val_if_fail (GTK_IS_LABEL (label), NULL);
  return label->label;
}
So you should do a:
str=strdup(str);
just after getting it... Then it all should work.
BYtE,
 Diego.
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]