| View previous topic :: View next topic |
| Author |
Message |
syn
Joined: 12 May 2006 Posts: 46 Location: Hamburg
|
Posted: Tue Aug 29, 2006 7:01 pm Post subject: Treeview - Activate row |
|
|
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
|
Posted: Wed Aug 30, 2006 6:58 am Post subject: |
|
|
| 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
|
Posted: Wed Aug 30, 2006 12:18 pm Post subject: |
|
|
| But how to set them? |
|
| Back to top |
|
 |
cweiske
Joined: 08 Dec 2005 Posts: 454 Location: Leipzig/Germany
|
Posted: Wed Aug 30, 2006 12:24 pm Post subject: |
|
|
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
|
Posted: Wed Aug 30, 2006 5:09 pm Post subject: |
|
|
Hm, i think, in the documentation i use at home (no internet connection availeable ), these select_* methods arenīt documentated... 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
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
|
|
| Back to top |
|
 |
syn
Joined: 12 May 2006 Posts: 46 Location: Hamburg
|
Posted: Thu Aug 31, 2006 12:06 pm Post subject: |
|
|
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
|
Posted: Thu Aug 31, 2006 12:11 pm Post subject: |
|
|
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 |
|
 |
|