Re: Subclassing Gtk2::GladeXML



>> I was sub-classing Gtk2::GladeXML (I have a print dialog for a large

>> number of reports, each report has its own ‘options’ dialog it can

>> display which I have all in 1 glade file that I want to keep

>> separate from the rest of the program, and want to create some helper

>> functions that I want to access through the glade object.

>> 

>> The issue I ran into (and was able to “solve”) is that after sub-

>> classing Gtk2::GladeXML, I can’t say

>> 

>> $self->get_widget(‘winReports’);

>> 

>> I get an undefined value returned. However, if say it as so… it works

>> just fine.

>> 

>> &Gtk2::GladeXML::get_widget($self, 'winReports');

>> 

>> Is this a bug or is does this operate this way for a specific reason?

> 

>A minimal example that exhibits this problem would go a long way towards the answer.  The >immediate question i have is "are you writing the code in some odd way that causes the object to >be blessed incorrectly?"

 

Here is the beginning lines of the module.

 

package GTIMs::GUI::Dialog::Report;

use warnings;

use strict;

use Carp qw/carp cluck/;

 

use GTIMs;

use Glib qw(TRUE FALSE);

use Gtk2;

use Gtk2::GladeXML;

use Gtk2::Ex::DateEntry;

use base qw(Gtk2::GladeXML);

 

sub new {

    my $class = shift;

    my $self = bless Gtk2::GladeXML->new('lib/widgets/dlg_report.glade'), $class;

    $self->signal_autoconnect_from_package($class);

   

    $self->get_widget('winReports')->{GUI} = $self;

    $self->do_winReports_date_widgets_setup;

    $self->do_winReports_treeView_setup;

    $self->do_winReports_treeView_populate;

   

    return $self;

}

 

I can get away with this, and get the behavior that I want. The no warnings; use warnings; statements because I get a warning that get_widget has been redefined…

 

no warnings;

sub get_widget

{

    my ($self, $widget) = @_;

    &Gtk2::GladeXML::get_widget($self, $widget);

}

use warnings;

 

 

Im running windows 32, GTK+/Win32 Runtime Environment 2.8.20-1, ActiveState Perl 5.8.8 build 819. (The distribution from lostmind.de/gtk-perl/)



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