gnope php gtk gui gnope.org  

Treeview - Activate row

 
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners
View previous topic :: View next topic  
Author Message
syn



Joined: 12 May 2006
Posts: 46
Location: Hamburg

PostPosted: Tue Aug 29, 2006 7:01 pm    Post subject: Treeview - Activate row Reply with quote

Hi,

in my tool, i have a treeview as primary navigation... if a user quits the programm, all settings are stored to an history file. Also the last visited point in the navigation.
If a user restarts the tool, all data are shown like the last time.

No problem at all... that works fine....

BUT...

How can i hilight the last selected navigation point in my primary navigation treeview. What kind of data have i to store in my history file (plaintext). For all other data, i store a eccident-string as index (eg. gba, snes, gen) here....

Please give me some demo-code, if possible....

Thank you and regards,
andreas
Back to top
cweiske



Joined: 08 Dec 2005
Posts: 454
Location: Leipzig/Germany

PostPosted: Wed Aug 30, 2006 6:58 am    Post subject: Reply with quote

Get the GtkTreeSelection object for the view, and get all selected rows (iters). Store their indices in your history file, and set them again when loading the program.
Back to top
syn



Joined: 12 May 2006
Posts: 46
Location: Hamburg

PostPosted: Wed Aug 30, 2006 12:18 pm    Post subject: Reply with quote

But how to set them?
Back to top
cweiske



Joined: 08 Dec 2005
Posts: 454
Location: Leipzig/Germany

PostPosted: Wed Aug 30, 2006 12:24 pm    Post subject: Reply with quote

Use the manual, or Dev_Inspector. It will show you that GtkTreeSelection has several select_* methods:
Code:

select_iter(GtkTreeIter $iter);
select_path($path);
select_range($start_path, $end_path);
Back to top
syn



Joined: 12 May 2006
Posts: 46
Location: Hamburg

PostPosted: Wed Aug 30, 2006 5:09 pm    Post subject: Reply with quote

Hm, i think, in the documentation i use at home (no internet connection availeable Sad), these select_* methods arenīt documentated... Smile Hope, this will help, but i think so.

Where can i get the latest download-version of the php-gtk2 documationation? Everytime i download the docu, i get the php-gtk1 docu Sad

I know, that you are one of the manual-writer .... thank you for the good job.
Is there a possibility, that there will be a php-gtk2 docu in extended chm like the php-docu found here: http://www.php.net/docs-echm.php

Regards,
andreas
Back to top
cweiske



Joined: 08 Dec 2005
Posts: 454
Location: Leipzig/Germany

PostPosted: Wed Aug 30, 2006 9:32 pm    Post subject: Reply with quote

There is a daily bzipped html version of the php-gtk2 manual at
http://php-gtk2.de/manual/

Many methods aren't documented yet, since there are over 3000 methods. You can see documentation coverage at
http://php-gtk2.de/manual/coverage.htm
Back to top
syn



Joined: 12 May 2006
Posts: 46
Location: Hamburg

PostPosted: Thu Aug 31, 2006 12:06 pm    Post subject: Reply with quote

Thank you for this link....

Ok, finaly i found the way but having some problems:



Code:

/**
* First try! Not running
*/

// SET
list($model, $iter) = $obj->get_selected();
if ($iter) {
    $this->ini->write_ecc_histroy_ini('nav_iter', base64_encode(serialize($iter)), false);
}
// GET
$treeview_nav_selection = $this->treeview1->get_selection();
if ($selected_iter = $this->ini->read_ecc_histroy_ini('nav_iter')) {
    $iter = (unserialize(base64_decode($selected_iter)));
    $treeview_nav_selection->select_iter($iter);
}

// RESULT
PHP Fatal error:  Internal object missing in GtkTreeIter wrapper in D:\emuControlCenter-DEVEL-SQLITE2\ecc-system\ecc.php on line 543
Fatal error: Internal object missing in GtkTreeIter wrapper in D:\emuControlCenter-DEVEL-SQLITE2\ecc-system\ecc.php on line 543

/**
* Second try! Works fine!
*/

// SET
$treeview_nav_selection = $this->treeview1->get_selection();
if ($selected_iter = $this->ini->read_ecc_histroy_ini('nav_iter')) {
    $treeview_nav_selection->select_path($selected_iter);
}
// GET
list($model, $iter) = $obj->get_selected();
if ($iter) {
    $path = $model->get_path($iter);
    $this->ini->write_ecc_histroy_ini('nav_iter', current($path), false);
}


Maybe you can say, why the first attemp is not running!

Regards,
andreas
Back to top
cweiske



Joined: 08 Dec 2005
Posts: 454
Location: Leipzig/Germany

PostPosted: Thu Aug 31, 2006 12:11 pm    Post subject: Reply with quote

Seems like a bug in php-gtk. The "internal object missing" usually comes when you derive your own class from a php-gtk class and don't call the parent constructor in your own constructor.

Unserializing iters doesn't work, and you shouldn't try to serialize them at all. Use the row position or so, since iters are temporary objects only.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Templates enhanced by DigiWiki. Hosting by Tradebit.