Finding which window hierarchy I'm in
- From: Dan Lyke <danlyke flutterby com>
- To: "Gtk-Perl-List" <gtk-perl-list gnome org>
- Subject: Finding which window hierarchy I'm in
- Date: Sat, 20 Sep 2003 17:17:55 -0700
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');
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
[1]
package main;
my (@gladexml, %gladexml);
sub get_widget($$)
{
my ($widget, $name) = @_;
if (!defined($gladexml{$widget}))
{
my ($n, $gladexml);
$n = $widget->get_name();
foreach (@gladexml)
{
my ($w);
$w = $_->get_widget($n);
$gladexml = $_ if ($w eq $widget);
}
$gladexml{$widget} = [$gladexml, {}];
}
if (!defined($gladexml{$widget}->[1]->{$name}))
{
$gladexml{$widget}->[1]->{$name} =
$gladexml{$widget}->[0]->get_widget($name);
}
return $gladexml{$widget}->[1]->{$name};
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]