package ugtk2;
use diagnostics;
use strict;
use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK @icon_paths $wm_icon $grab $border); #- leave it on one line, for automatic removal of the line at package creation
use locale;
@ISA = qw(Exporter);
%EXPORT_TAGS = (
wrappers => [ qw(gtkadd gtkadd_widget gtkappend gtkappend_page gtkappenditems gtkcombo_setpopdown_strings gtkdestroy
gtkentry gtkflush gtkhide gtkmodify_font gtkmove gtkpack gtkpack2 gtkpack2_
gtkpack2__ gtkpack_ gtkpack__ gtkpowerpack gtkput gtkradio gtkresize gtkroot
gtkset_active gtkset_border_width gtkset_editable gtkset_justify gtkset_alignment gtkset_layout gtkset_line_wrap
gtkset_markup gtkset_modal gtkset_mousecursor gtkset_mousecursor_normal gtkset_mousecursor_wait gtkset_name
gtkset_property gtkset_relief gtkset_selectable gtkset_sensitive gtkset_shadow_type gtkset_size_request
gtkset_text gtkset_tip gtkset_visibility gtksetstyle gtkshow gtksignal_connect gtksize gtktext_append
gtktext_insert ) ],
helpers => [ qw(add2notebook add_icon_path escape_text_for_TextView_markup_format gtkcolor gtkcreate_img
gtkcreate_pixbuf gtkfontinfo gtkset_background gtktreeview_children set_back_pixmap
get_default_step_items set_default_step_items
string_size string_width) ],
create => [ qw(create_adjustment create_box_with_title create_dialog create_factory_menu create_factory_popup_menu
create_hbox create_hpaned create_menu create_notebook create_okcancel create_packtable
create_scrolled_window create_vbox create_vpaned _create_dialog gtkcreate_frame) ],
ask => [ qw(ask_browse_tree_info ask_browse_tree_info_given_widgets ask_dir ask_from_entry ask_okcancel ask_warn
ask_yesorno) ],
dialogs => [ qw(err_dialog info_dialog warn_dialog) ],
);
$EXPORT_TAGS{all} = [ map { @$_ } values %EXPORT_TAGS ];
@EXPORT_OK = map { @$_ } values %EXPORT_TAGS;
use c;
use log;
use common;
use mygtk2 qw(gtknew); #- do not import gtkadd which conflicts with ugtk2 version
use Gtk2;
$border = 5;
sub wm_icon() { $wm_icon || $::Wizard_pix_up || "wiz_default_up.png" }
# -=-=---=-=---=-=---=-=---=-=---=-=---=-=---=-=---=-=---=-=---=-=---=-=---
# wrappers
#
# Functional-style wrappers to existing Gtk functions; allows to program in
# a more functional way, and especially, first, to avoid using temp
# variables, and second, to "see" directly in the code the user interface
# you're building.
sub gtkdestroy { mygtk2::may_destroy($_[0]) }
sub gtkflush() { mygtk2::flush() }
sub gtkhide { $_[0]->hide; $_[0] }
sub gtkmove { $_[0]->window->move($_[1], $_[2]); $_[0] }
sub gtkpack { gtkpowerpack(1, 1, @_) }
sub gtkpack_ { gtkpowerpack('arg', 1, @_) }
sub gtkpack__ { gtkpowerpack(0, 1, @_) }
sub gtkpack2 { gtkpowerpack(1, 0, @_) }
sub gtkpack2_ { gtkpowerpack('arg', 0, @_) }
sub gtkpack2__ { gtkpowerpack(0, 0, @_) }
sub gtkput { $_[0]->put(gtkshow($_[1]), $_[2], $_[3]); $_[0] }
sub gtkresize { $_[0]->window->resize($_[1], $_[2]); $_[0] }
sub gtkset_active { $_[0]->set_active($_[1]); $_[0] }
sub gtkset_border_width { $_[0]->set_border_width($_[1]); $_[0] }
sub gtkset_editable { $_[0]->set_editable($_[1]); $_[0] }
sub gtkset_selectable { $_[0]->set_selectable($_[1]); $_[0] }
sub gtkset_justify { $_[0]->set_justify($_[1]); $_[0] }
sub gtkset_alignment { $_[0]->set_alignment($_[1], $_[2]); $_[0] }
sub gtkset_layout { $_[0]->set_layout($_[1]); $_[0] }
sub gtkset_modal { $_[0]->set_modal($_[1]); $_[0] }
sub gtkset_mousecursor_normal { gtkset_mousecursor('left-ptr', @_) }
sub gtkset_mousecursor_wait { gtkset_mousecursor('watch', @_) }
sub gtkset_relief { $_[0]->set_relief($_[1]); $_[0] }
sub gtkset_sensitive { $_[0]->set_sensitive($_[1]); $_[0] }
sub gtkset_visibility { $_[0]->set_visibility($_[1]); $_[0] }
sub gtkset_tip { $_[0]->set_tip($_[1], $_[2]) if $_[2]; $_[1] }
sub gtkset_shadow_type { $_[0]->set_shadow_type($_[1]); $_[0] }
sub gtkset_style { $_[0]->set_style($_[1]); $_[0] }
sub gtkset_size_request { $_[0]->set_size_request($_[1], $_[2]); $_[0] }
sub gtkshow { $_[0]->show; $_[0] }
sub gtksize { $_[0]->size($_[1], $_[2]); $_[0] }
sub gtkset_markup { $_[0]->set_markup($_[1]); $_[0] }
sub gtkset_line_wrap { $_[0]->set_line_wrap($_[1]); $_[0] }
sub gtkadd {
my $w = shift;
foreach my $l (@_) {
ref $l or $l = gtknew('WrappedLabel', text => $l);
$w->add(gtkshow($l));
}
$w;
}
sub gtkadd_widget {
my $sg = shift;
map {
my $l = $_;
ref $l or $l = gtknew('WrappedLabel', text => $l);
$sg->add_widget($l);
$l;
} @_;
}
sub gtkappend {
my $w = shift;
foreach my $l (@_) {
ref $l or $l = gtknew('WrappedLabel', text => $l);
$w->append(gtkshow($l));
}
$w;
}
sub gtkappenditems {
my $w = shift;
$_->show foreach @_;
$w->append_items(@_);
$w;
}
|