#6 Gtk::CTreeNode

closed-fixed
ruby-gnome (11)
5
2002-06-12
2002-04-27
No

Hi,

the CTree does not work as expected, because the
identity of its subnodes (CTreeNode's) changes
permanently:

def testEquals(ctree, row)
gtknode1 = ctree.node_nth(row)
gtknode2 = ctree.node_nth(row)
assert(gtknode1 == gtknode2)
end

will raise an exception.

This is pretty uncomfortable, because the whole
model has to be mirrored, to know which item is meant
by a specific row.

The generated wrapper for CTreeNode's, should
implement the == operator to be able to work with
Hashes and Arrays.

Matthias

Discussion

  • Matthias veit

    Matthias veit - 2002-05-26

    Logged In: YES
    user_id=367980

    To help myself, I wrote a little patch that walk around the
    problem,
    not solving it. It clarifies the problem:

    file rbgtkctree.c line 38 ff:

    /* original:
    VALUE
    make_ctree_node(node)
    GtkCTreeNode* node;
    {
    if (!node) return Qnil;
    return Data_Wrap_Struct(gCTreeNode, 0, 0, node);
    }
    */

    // imitation:
    struct gtknode_to_ctreenode {
    GtkCTreeNode* node;
    VALUE ruby_node;
    };

    static struct gtknode_to_ctreenode all_ctree_nodes[1000];
    static int gtknode_to_ctreenode_count = 0;

    VALUE
    make_ctree_node(node)
    GtkCTreeNode* node;
    {
    int count =0;
    VALUE retval;

    //is nil?
    if (!node) return Qnil;
    //already generated?
    for (count=0; count < gtknode_to_ctreenode_count; count++) {
    if (all_ctree_nodes[count].node == node) {
    retval = all_ctree_nodes[count].ruby_node;
    break;
    }
    }
    //check
    if (gtknode_to_ctreenode_count == count) { //not found
    retval = Data_Wrap_Struct(gCTreeNode, 0, 0, node);
    //remember
    all_ctree_nodes[gtknode_to_ctreenode_count].node = node;

    all_ctree_nodes[gtknode_to_ctreenode_count].ruby_node = retval;
    gtknode_to_ctreenode_count++;
    }
    return retval;
    }

    Everything works fine, until 1000 ctreenode's are created.
    There must be a relation between identity of gtk's ctreenode
    ans ruby's ctreenode (perhaps there is a already generic
    solution
    for doing this??)

    Best regards
    Matthias

     
  • Masao Mutoh

    Masao Mutoh - 2002-06-12
    • assigned_to: klamath --> mutoh
    • status: open --> closed-fixed
     
  • Masao Mutoh

    Masao Mutoh - 2002-06-12

    Logged In: YES
    user_id=495147

    I implemented Gtk::CTreeNode#==(other). It is easier than
    yours though both patches are incomplete.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks