[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: libglade with Gtk2 and Gnome2
- From: Chas Owens <alas widomaker com>
- To: Sylvain Daubert <sly_ ifrance com>
- Cc: gtk-perl-list gnome org
- Subject: Re: libglade with Gtk2 and Gnome2
- Date: Sat, 12 Apr 2003 09:26:28 -0400
On Sat, 2003-04-12 at 04:41, Sylvain Daubert wrote:
> Le Fri, 11 Apr 2003 15:19:32 -0400 (EDT)
> Chas Owens <alas widomaker com> a �it :
>
> > Has anyone written a wrapper for the new libglade? Gtk::GladeXML is why I fell
> > in love with the original gtk perl module, but I don't see anything like it in
> > the new modules.
> > _______________________________________________
> > gtk-perl-list mailing list
> > gtk-perl-list gnome org
> > http://mail.gnome.org/mailman/listinfo/gtk-perl-list
> > _____________________________________________________________________
> > Envie de discuter en "live" avec vos amis ? T�charger MSN Messenger
> > http://www.ifrance.com/_reloc/m la 1� messagerie instantan�de France
>
>
> Dermot Musgrove wrote GladePerl and he has begun writing Glade-Two-Perl. But last release is from last september...
>
> Sylvain
Glade-Two-Perl is not the same thing as Gtk::GladeXML. The former is a
Perl script that builds Perl code from the glade file. The later is a
Perl Module that takes XML (normally the glade file) and returns a
widget tree. The biggest difference is that the UI can be changed
without modifying the Perl code with Gtk::GladeXML. Gtk::GladeXML
doesn't have to build the whole glade file; you can specify a widget to
start building from. One of my programs allows you to add multiple
copies of a widget tree (an editor + other stuff) to a Gtk::Notebook.
With Glade-Two-Perl I would have to build that widget tree by hand since
it is dynamically generated, but with Gtk::GladeXML I can create a
placeholder window with the widget tree in it and then call
Gtk::GladeXML->new with the top level widget in that placeholder window.
#!/usr/bin/perl
use strict;
use Gtk;
use Gtk::GladeXML;
Gtk->init;
MainWindow->new;
Gtk->main;
BEGIN {
package MainWindow {
our $editor_count = 0;
sub new {
my $class = shift;
my $self;
$self = Gtk::GladeXML->new(
'example.glade',
'main_window'
);
$self->autoconnect('MainWindow');
return bless $class, $self;
}
sub new_tab {
my $thing = shift;
my $self;
if (ref $thing == "MainWindow") {
$self = $thing;
} else {
$self = $thing->get_widget_tree;
}
$self->AddEditor(Editor->new);
}
sub AddEditor {
my ($self, $editor, $text) = @_;
my $notebook = $self->get_widget('notebook');
$notebook->AppendPage(
$editor->get_widget('editor_vbox'),
Gtk::Label->new('Tab ' . $editor_count++)
);
$notebook->show_all;
}
package Editor;
sub new {
my $class = shift;
my $self = Gtk::GladeXML->new(
'example.glade',
'editor_vbox'
);
$self->autoconnect('Editor');
return bless $class, $self;
}
sub run {
}
sub stop {
}
sub refresh {
}
sub save {
}
sub open {
}
sub close {
}
}
--
Chas Owens <alas widomaker com>
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]