Re: An automatic signal stub function generator
- From: Chas Owens <alas widomaker com>
- To: Ross McFarland <rwmcfa1 neces com>
- Cc: Gtk-Perl-List <gtk-perl-list gnome org>
- Subject: Re: An automatic signal stub function generator
- Date: Fri, 26 Sep 2003 17:42:03 -0400 (EDT)
Quoting Ross McFarland <rwmcfa1 neces com>:
true, forgot about the fact that the view is separate from the model.
it would be an acceptable/workable feature to have a SimpleList populate
an existing treeview, but it would be more appropriate for it to be
something like
Gtk2::SimpleList->new( tree_view => $treeview );
-rm
Dn't forget the custom widget placeholder in glade (1 and 2). You can use the
custom widget in the Glade tool and specify the arguments the custom_handler()
will recieve. You can then set the custom_handler() with
Gtk2::GladeXML->set_custom_handler()
I did this as part of my "put everything in one file" project. It was simple to
add the XML to the end of the Perl script, read it in with <DATA>, and pass the
resulting string to Gtk2::GladeXML->new_from_memory(), but the pixmaps were
harder to deal with (the Glade tool wanted a path not the pixmap info). So I
made all of the pixmaps custom widgets with "create_pixmap" as the
creation_function and put the xpm data in the XML file as the first string
argument. Well, that is what I did at first and had some problems with creating
the Gtk::ToggleButton the pixmap was in the right size, so I wound up doing this
instead, but the principle is the same.
The following code is from gnome-sql-editor version 5.2 available at
gsqleditor.sf.net.
<snip>
sub create_togglebutton_many_sql {
my $toggle = Gtk::ToggleButton->new;
my $vbox = Gtk::VBox->new(0, 0);
my $pixmap = create_pixmap(@_);
my $label = Gtk::Label->new('Statements');
$toggle->set_active(1);
$toggle->add($vbox);
$vbox->add($pixmap);
$vbox->add($label);
$toggle->show_all;
return $toggle;
}
sub create_pixmap {
my ($app, $pixmap_string) = @_;
my @xpm_data = split /\n/, $pixmap_string;
my $window = $app->get_widget('app');
$window->show;
my $style = $window->get_style()->bg( 'normal' );
my ( $pixmap, $mask ) = Gtk::Gdk::Pixmap->create_from_xpm_d(
$window->window,
$style,
@xpm_data
);
return Gtk::Pixmap->new($pixmap, $mask);
}
sub custom_handler {
my ($glade_obj, $funcname, $widget, $str1, $str2, $int1, $int2) = @_;
return eval "$funcname(\$glade_obj, '$str1', '$str2', $int1, $int2)";
}
</snip>
<snip>
<widget>
<class>Custom</class>
<name>togglebutton_many_sql</name>
<width>80</width>
<height>48</height>
<creation_function>create_togglebutton_many_sql</creation_function>
<string1>24 24 2 1
. c None
# c #000000
........................
........................
........................
......##....#####.......
..######..#########.....
..######.###..######....
....######......####....
.....####........###....
.....###.........####...
.....###.........####...
.....###.........####...
.....###.........####...
.....###.........####...
.....###.........####...
.....###.........####...
.....###.........####...
.....###.........####...
.....###.........####...
.....###.........####...
.....###.........####...
..#########......######.
..#########.......#####.
........................
........................</string1>
<int1>0</int1>
<int2>0</int2>
<last_modification_time>Tue, 18 Jun 2002 16:44:19 GMT</last_modification_time>
</widget>
</snip>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]