I anticipated this question :) Here's what I'm trying to do ...
I've got an abstract 'window' class that handles loading windows from a builder file, and attaching some convenience functions and stuff. I want to save the state of various things in a SQLite database. For example, GtkPaned positions are causing me issues on different resolutions and DPIs. So I'd like to be able to do: foreach my $item ( $window->{builder}->get_objects() ) { if ( ref $item eq "Gtk3::Paned" ) { my $name = $item->get_name; my $state_name = $class . ':' . $name . ':position'; my $state = $globals->{config_manager}->simpleGet( $state_name ); # simpleGet fetches from a SQLite key/value pair config db $item->set_position( $state ); } } ... on startup. I'd of course have signals on the 'notify' signal of each Gtk3::Paned to save the state each time it's altered ( with some work-arounds for initial state ). This code would similarly have to know the name of each item, so it could write it to the SQLite DB. I've done this all manually for a couple of widgets ( ie by having special code per widget ), but being able to do it generically as above would be a far better solution. Thoughts? Dan On Tue, Nov 17, 2015 at 4:57 AM, Emmanuele Bassi <eba...@gmail.com> wrote: > Hi; > > On 16 November 2015 at 02:26, Daniel Kasak <d.j.kasak...@gmail.com> wrote: >> Greetings all. >> >> I'd like to get a list of object names from a GtkBuilder object ( I'm >> using Perl ). I know about >> https://developer.gnome.org/gtk3/stable/GtkBuilder.html#gtk-builder-get-objects >> - which returns a list of objects, but I really need the names. Is it >> possible? > > The question would be "why do you think you need the names from the > XML, considering you wrote the XML definitions in the first place" — > i.e. since you're the author, you're supposed to already know those > names, not figure them out programmatically. > > In practice, you could load up the XML yourself and figure those names > out using the XML::Parser or XML::LibXML modules in Perl; but the > question betrays some confusion as to what GtkBuilder UI definition > files are, and how they are used, so it's probably better for you to > answer the question: what is it that you're trying to achieve? > > Ciao, > Emmanuele. > > -- > https://www.bassi.io > [@] ebassi [@gmail.com] _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list