the proper way to do inheritance

Following is an example of how I currently fo inheritance.  Is this the "right"
way?  I remember there being some discussion earlier on changes to how Gtk2-Perl
was doing inheritance, but it referenced things I am not doing (like the type
system).  I have had no problems with this style, but I am wondering if there is
a better/more robust way of doing OO with Gtk2-Perl.

package GnomeSQLEditor::Editor;

        use strict;

        use Gtk2;
        use Gnome2;

        use base 'Gtk2::Notebook';

        sub new {
                my ($class, $text) = @_;
                my $self           = $class->SUPER::new(@_);
                $self->{sql}       = Gtk2::TextView->new;
                $self->{status}    = Gtk2::TextView->new;
                $self->{dirty}     = 0;
                my $pane      = Gtk2::VPaned->new;
                my $sw_sql    = Gtk2::ScrolledWindow->new;
                my $sw_status = Gtk2::ScrolledWindow->new;

                $self->append_page($pane, Gtk2::Label->new("Editor"));
                $pane->pack1($sw_sql, 1, 0);
                $pane->pack2($sw_status, 1, 1);

                $self->set_tab_pos('bottom'); #FIXME: this should be an option

                                "Monospace 12" #FIXME: should be an option

                my $buffer = $self->{sql}->get_buffer;
                        sub { $self->{dirty} = 1 }

                return bless $self, $class;

        sub is_dirty { $_[0]->{'dirty'} }

        sub get_text {
                my $self   = shift;
                my $buffer = $self->{'sql'}->get_buffer;
                $buffer->get_text($buffer->get_bounds, 0);

        sub execute {...}
        sub open    {...}
        sub close   {...}
        sub save    {...}
        sub save_as {...}

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