Re: GtkCTree
| From: | Malk0 | Date: | Wed, 27 Oct 2004 16:07:36 +0000 |
| Subject: | Re: GtkCTree | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-5168@lists.php.net to get a copy of this message | ||
Hi,
generally GtkCtree are used with a single column, exactly as you do it.
the problem is with the data array you give to the insert_node method
of your gtkctree. Your $networks and $servers must have only one
element no more when calling this method you probably can solve this
by replacing this:
foreach($this->_parent->_networks as $network => $net) {
$networks[] = $network;
foreach($net['servers'] as $server) {
$servers[] =
$server['host'].":".$server['port'];
}
}
$parent = $tree->insert_node(null, null, $networks,
5, null, null, null, null, false, false);
$self = $tree->insert_node($parent, null, $servers,
5, null, null, null, null, false, false);
By this :
foreach($this->_parent->_networks as $network => $net) {
$parent = $tree->insert_node(null,null,array($network),5,null,null,null,null,false,false);
foreach($net['servers'] as $server) {
$self =
$tree->insert_node($parent,null,array($server['host'].":".$server['port']),5,null,null,null,null,false,false);
}
}
regards
nathan
On Wed, 27 Oct 2004 11:43:26 -0400, Joseph Crawford <codebowl@gmail.com> wrote:
> Guys i am trying to create a GtkCTree that will show a list of
> Networks/Servers for an IRC client.
>
> I have the networks and servers in an array however i cant seem to get
> the GtkCTree to work.
>
> what exactly is a column in a CTree? i keep getting errors like this
>
> Warning: insert_node(): the text array size (2) does not match the
> number of columns in the ctree (1) in
> /home/idle/PhpIRC/system/class/GUI.class.php on line 89
>
> here is the code i have so far.
>
> function serverList() {
>
> $w = &new GtkWindow();
> $w->set_usize('380', '240');
> $w->set_title("Networks");
> $w->connect("destroy", array('Actions',
> 'killwindow'), null);
>
> $scrolledwindow = &new GtkScrolledWindow();
> $scrolledwindow->set_policy(GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
>
> $tree = &new GtkCTree(1, 0);
> $networks = array();
> $servers = array();
> foreach($this->_parent->_networks as $network => $net) {
> $networks[] = $network;
>
> foreach($net['servers'] as $server) {
> $servers[] =
> $server['host'].":".$server['port'];
>
> }
> }
> $parent = $tree->insert_node(null, null, $networks, 5, null, null,
> null, null, false, false);
> $self = $tree->insert_node($parent, null, $servers, 5, null, null,
> null, null, false, false);
>
> $tree->show();
>
> $vbox = &new GtkVBox();
> $vbox->set_border_width(5);
> $vbox->set_usize(100, -1);
>
> $hbox = &new GtkHBox();
> $hbox->set_border_width(5);
>
> $scrolledwindow->add($tree);
> $scrolledwindow->set_usize(250, -1);
> $hbox->pack_start($scrolledwindow, false, false, 5);
>
> $hbox->pack_start($vbox, false, false, 5);
>
> $button = &new GtkButton("Connect");
> $button1 = &new GtkButton("Add");
> $button2 = &new GtkButton("Remove");
> $vbox->pack_start($button, false, false, 2);
> $vbox->pack_start($button1, false, false, 2);
> $vbox->pack_start($button2, false, false, 2);
>
> $w->add($hbox);
> $w->show_all();
>
> }
> --
> Joseph Crawford Jr.
> Codebowl Solutions
> codebowl@gmail.com
>
> For a GMail account
> contact me OFF-LIST
>
> --
> PHP-GTK General Mailing List (http://gtk.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
-- Malk0 --