Re: Tree problems




Bolliet Jerome <bolliet@in2p3.fr> writes:
BJ> I've tested and i can't repoduce these problems.
BJ> 
BJ> What's the system and the compiler ?

I see this on both my system at home (gtk 0.99.7 on Debian GNU/Linux
2.0, gcc 2.7.2.3, based on GNU libc 2.0.7pre1) and on the machines on
the MIT campus (SunOS 5.5, I think, gcc 2.7.1, using gtk no newer than 
0.99.3).

BJ> Have you piece of code where these problems are present.

(Stripped of Zephyr stuff)

struct zephyr_user
{
  char *name;
  GtkWidget *item;
  struct zephyr_group *group;
  struct zephyr_user *next;
};

static void do_update_user(struct zephyr_user *user)
{
  int numlocs;
  /* Perform Zephyr magic.  numlocs is zero if the user is not logged
   * in, nonzero if they are. */
  if (numlocs && !user->item)
    user_show(user);
  if (!numlocs && user->item)
    user_hide(user);
  do_update_user(user->next);
}

static void user_show(struct zephyr_user *user)
{
  if (!user->item)
  {
    user->item = gtk_tree_item_new_with_label(user->name);
    gtk_tree_append(GTK_TREE(user->group->tree), user->item);
    gtk_widget_show(user->item);
  }
}

static void user_hide(struct zephyr_user *user)
{
  GList *item_list;

  if (!user->item)
    return;

  gtk_widget_hide(user->item);
  /* gtk_tree_remove_item shows up in gtktree.h but doesn't seem
   * to actually exist :-(
   gtk_tree_remove_item(GTK_TREE(user->group->tree), user->item);
   * Code copied from gtktree.c (yes, a one-line wrapper would
   * fix this...)
   */
  item_list = g_list_alloc();
  item_list->data = user->item;
  gtk_tree_remove_items(GTK_TREE(user->group->tree), item_list);
  g_list_free(item_list);

  gtk_widget_destroy(user->item);
  user->item = NULL;
}


Looking at gtktree.h again suggests that I should change in particular 
user_hide to use gtk_container_remove instead of
gtk_tree_remove_items; I'll try this and see what happens.  I also
explicitly destroy my GtkTreeItems when I'm finished with them; does
the gtk reference-counting mechanism take care of this for me?

-- 
 _____________________________
/                             \  "The cat's been in the box for over
|          David Maze         |  20 years.  Nobody's feeding it.  The
|         dmaze@mit.edu       |            cat is dead."
| http://donut.mit.edu/dmaze/ |  -- Grant, on Schroedinger's Cat
\_____________________________/



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