Re: [gtk-list] Re: Bug fix or feature addition?
- From: Lars Hamann <lars gtk org>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: Bug fix or feature addition?
- Date: Mon, 30 Aug 1999 00:58:03 +0200
On Sat, Aug 28, 1999 at 04:55:41AM -0600, Brad Pepers wrote:
> Another question (there are always more!) is how to easily change the
> is_leaf status on a node. Right now it looks like I've got to call
> gtk_ctree_get_node_info with a whole wack of pointers to things and
> then call gtk_ctree_set_node_info with all the same data. Wouldn't
> it be nicer and easier just to have some routines to change things
> like the is_leaf status?
No, there is no other way to do it. Maybe it would be nicer to have
such functions, but I think ctree does already have too much...
> Plus I can't seem to get the text part right.
> I declare a char* variable called text, pass a pointer to this to the
> get_node_info routine and then pass text itself to set_node_info.
> Doing this turns the text of the node to garbage so what do I do? Do
> I have to regenerate the text for the node just to change the is_leaf
> status?
>
[...]
> Here is basically the code I have that works for setting the is_leaf
> but turns the text to garbage:
It's even a bit more troublesome. The returned text is only a pointer
to the node text, not a copy. If you try to feed that pointer into
set_node_info, ctree will free text first and then tries to copy it.
So you have to generate your own copy of text :
>
> static void
> insert_in(GtkMenuItem *menuitem, ScreenInfo *info)
> {
> GtkCTreeNode *node;
> char *text;
> guint8 spacing;
> GdkPixmap *p_closed;
> GdkPixmap *m_closed;
> GdkPixmap *p_opened;
> GdkPixmap *m_opened;
> gboolean is_leaf;
>
> /* If parent is a leaf, change it */
> node = id_to_node(info, info->acct.gl_id);
> gtk_ctree_get_node_info(GTK_CTREE(info->list), node, &text,
> &spacing,
> &p_closed, &m_closed, &p_opened, &m_opened,
> &is_leaf, NULL);
> if (is_leaf) {
char *ctext;
ctext = g_strdup (text);
> gtk_ctree_set_node_info(GTK_CTREE(info->list), node, text, spacing,
> p_closed, m_closed, p_opened, m_opened,
> FALSE, TRUE);
g_free (ctext);
> }
> }
bye,
Lars
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]