Re: Serializing Gtk objects?
| From: | Alan Knowles | Date: | Tue, 28 May 2002 01:13:17 +0000 |
| Subject: | Re: Serializing Gtk objects? | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-2063@lists.php.net to get a copy of this message | ||
Any Ideas?
- Apart from your totally mad :)
Ok, looking at this, you probably want to look at glade storage.
- if you use glade to initialize/create the interface, it is unlikely that you application will need to (or even should) modify/change the state of the connected signals at runtime..
other than that you should be able to traverse the 'glade file you started with', and compare differences of the objects.. - like text content etc...
this may help...
http://docs.akbkhome.com/phpmole/classes/phpglade.html
just extend it to reparse the tree on exit, do some object property reading ->then write the xml...
regards
alan
Michael Dransfield wrote:
Has anyone experimented with serializing Gtk objects?
I have tried to do it but the object only seems to contain a integer key and value. I assume that this is some kind of internal gtk/php pointer.
It doesnt help that many properties can only be accessed via methods (e.g. get_text() for GtkEntry). I know this is the 'correct' OO way, but dont know why.
I have tried writing objects which extend normal Gtk objects which contain __sleep and __wakeup methods. The methods set a property to values which need to be saved (so far I can think of its text (labels, entrys etc), connected signals, data set, and size).
Returning the size and text is fairly easy, but as far as I can tell - there is no way to retrieve signals which have been connected (?)
To get the signals connected, I had to add a connect function to my new object - like this
class ExtendedGtkEntry extends GtkEntry {
var signal_array;
function extendedgtkentry(){
$this->signal_array = Array();
}
function connect($sig, $cb, $custom){
array_push($this->signal_array, Array($sig, $cb, $custom));
parent::connect($sig, $cb, $custom);
}
}
I would do the same for set_data etc... this makes the application cumbersome and means that every widget has to have an extension written for it, and any application needs to be written using these customised objects.
Can anyone think of any way that Gtk objects could be serialize()'d...
Saving as a glade xml file is another alternative, but carries the same problems.
Any ideas??? Anyone.....
Mike