Re: Finding which window hierarchy I'm in



OK, I'll take a shot at this one as well; correct me if I don't understand you correctly.

Dan Lyke wrote:
Okay, one more stupid n00b "this is a Gtk+ and not a gtk2-perl"
question for the day (and yes, this time I have remembered to delete
the References headers... Sigh.):

My app is predicated on the idea that I'll have multiple views of the
same data, and the best way for that to happen seems to be with
multiple identical top level windows. My current solution to this is
to do something like:

    push @gladexml, Gtk2::GladeXML->new('something.glade');
    $gladexml[$#gladexml]->signal_autoconnect_from_package('main');

    # Connect various widgets to data sources, etc...

(This will happen in the File->New event or anywhere I want a new top
level window.) Then, also in package "main", I have a "get_widget"
function which builds a cached associative hash of widget object
references to other widget objects (source in footnote [1]), so that
when I need sibling widgets of the one that got the event, I can do
things like

    $imagewidget = main::get_widget($treewidget, 'image1');

If you're doing what I think you are, this is already implemented in the Glade module. Check the POD for 'get_widget' which you call like so:

my $gladexml = Gtk2::GladeXML->new('blah.glade');
$gladexml->get_widget('quit_button');


I guess this isn't too bad, as it isolates the duplicated global
information in one place, but I'll still need to clean this tree up
somehow when one of the top level windows is deleted, and it seems
like there has to be a better way to explore the hierarchy.

What's the better solution?

Dan




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]