Re: [gtk-list] Changing GTK list item label




On Wed, 25 Mar 1998, Tim Wilson wrote:
> Can anyone explain (or show example code) of how to change the label of
> a GTK list item
> created with gtk_list_item_new_with_label()?
> 

I tried to figure this out for trees the other night and ended up doing
this (ignore the "Menu" stuff): 

static void redo_tree_item(Menu * m)
{
  GtkWidget * ti = MENU_TREEITEM(m);
  GList * children;
  GtkWidget * label;

  children = gtk_container_children(GTK_CONTAINER(ti));

  if (children) {
    label = GTK_WIDGET(children->data);
    gtk_widget_destroy(label);
  }
  else {
    g_warning("Tree item has no child!");
  }

  if (MENU_NAME(m)) {
    label = gtk_label_new(MENU_NAME(m));
  }
  else {
    label = gtk_label_new("***You didn't name this!***");
  }
  
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_container_add(GTK_CONTAINER(ti), label);
  gtk_widget_show(label);
}

Maybe it would work for lists too. But there has to be a better way.

Havoc Pennington
http://pobox.com/~hp



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