view release on metacpan or search on metacpan
- lines midpoint option
- fixes for bignum paths and values
Version 87, December 2011
- more stuff
Version 86, December 2011
- foreground/background for 2-value sequences
Version 85, December 2011
- fix for values combobox tooltip
Version 84, December 2011
- use NumSeq characteristic(increasing) etc
Version 83, December 2011
- colours shades for fractional values
Version 82, November 2011
- more stuff
debian/control view on Meta::CPAN
Section: utils
Priority: optional
Build-Depends: cdbs, debhelper (>= 5)
Maintainer: Kevin Ryde <user42@zip.com.au>
Standards-Version: 3.9.4
Homepage: http://user42.tuxfamily.org/math-image/index.html
Bugs: mailto:user42@zip.com.au
Package: math-image
Architecture: all
Depends: libmath-basecnv-perl, libclone-pp-perl, libcompress-zlib-perl | perl (>= 5.10), libconstant-defer-perl, libfile-homedir-perl, libgeometry-affinetransform-perl (>= 1.3), libglib-perl (>= 1:1.220), libglib-ex-objectbits-perl (>= 12), libglib-e...
Recommends: libmath-numseq-perl (>= 65), libmath-numseq-alpha-perl (>= 2), libmath-planepath-perl (>= 107), libmath-planepath-toothpick-perl (>= 10), libgtk2-ex-xor-perl, libmath-aronson-perl (>= 6), libmath-symbolic-perl (>= 0.605) | libmath-express...
Suggests: libimage-base-svg-perl (>= 3)
Description: Display some mathematical images
This program draws images like the Ulam spiral of prime numbers. It
can show them in a Gtk GUI or write PNG and other file formats.
devel/entry-text-index.pl view on Meta::CPAN
# require Glib::Ex::ConnectProperties;
# Glib::Ex::ConnectProperties->new
# ([$toolitem, 'sensitive'],
# [$button, 'active']);
# $button->show;
# $vbox->pack_start ($button, 0, 0, 0);
# }
# {
# my $button = Gtk2::CheckButton->new_with_label ('Child Sensitive');
# Glib::Ex::ConnectProperties->new
# ([$combobox, 'sensitive'],
# [$button, 'active']);
# $button->show;
# $vbox->pack_start ($button, 0, 0, 0);
# }
$entry->set_text ("ab123cd");
$toplevel->show_all;
Gtk2->main;
exit 0;
devel/lib/App/MathImage/Gtk1/Main.pm view on Meta::CPAN
$spin->signal_connect
(changed => sub {
my ($spin) = @_;
my $self = $spin->get_ancestor(__PACKAGE__) || return;
$self->{'draw'}->set (scale => $spin->get_value_as_int);
});
# # hide for LinesLevel
# Glib::Ex::ConnectProperties->new
# ([$values_combobox,'active-nick'],
# [$toolitem,'visible',
# write_only => 1,
# func_in => sub { $_[0] ne 'LinesLevel' }]);
}
{
my $combo = $self->{'figure_combo'} = Gtk::Combo->new;
App::MathImage::Gtk1::Ex::ComboBits::mouse_wheel($combo);
$combo->set_popdown_strings (App::MathImage::Generator->figure_choices);
$toolbar->append_widget ($combo,
devel/lib/App/MathImage/Gtk1/Main.pm view on Meta::CPAN
$combo->entry->signal_connect
(changed => sub {
my ($entry) = @_;
### figure combo changed: @_
my $self = $entry->get_ancestor(__PACKAGE__) || return;
$self->{'draw'}->set (figure => $entry->get_text);
});
# Glib::Ex::ConnectProperties->new
# ([$draw,'figure'],
# [$combobox,'active-nick']);
}
$vbox->pack_start ($draw, 1,1,0);
{
my $statusbar = $self->{'statusbar'} = Gtk::Statusbar->new;
$vbox->pack_end ($statusbar, 0,0,0);
}
_update_oeis($self);
devel/lib/App/MathImage/Gtk1/Main.pm view on Meta::CPAN
($quadbutton ? [$quadbutton,'visible'] : ()));
}
$table->show_all;
{
my $action = $actiongroup->get_action ('Toolbar');
Glib::Ex::ConnectProperties->new ([$toolbar,'visible'],
[$action,'active']);
}
my $path_combobox;
{
my $toolitem = Gtk::Ex::ToolItem::ComboEnum->new
(overflow_mnemonic => __('_Path'));
set_property_maybe
($toolitem, # tooltip-text new in 2.12
tooltip_text => __('The path for where to place values in the plane.'));
$toolitem->show;
$toolbar->insert ($toolitem, $toolpos++);
$path_combobox = $self->{'path_combobox'} = $toolitem->get_child;
set_property_maybe ($path_combobox,
# tearoff-title new in 2.10
tearoff_title => __('Math-Image: Path'));
Glib::Ex::ConnectProperties->new ([$draw,'path'],
[$toolitem,'active-nick']);
my $path_params = $self->{'path_params'}
= App::MathImage::Gtk1::Params->new (toolbar => $toolbar,
after_toolitem => $toolitem);
devel/lib/App/MathImage/Gtk1/Main.pm view on Meta::CPAN
### path_params values to draw...
Glib::Ex::ConnectProperties->new ([$path_params,'parameter-values'],
[$draw,'path-parameters']);
}
{
my $separator = Gtk::SeparatorToolItem->new;
$separator->show;
$toolbar->insert ($separator, $toolpos++);
}
my $values_combobox;
{
my $toolitem = $self->{'values_toolitem'}
= Gtk::Ex::ToolItem::ComboEnum->new
(overflow_mnemonic => __('_Values'));
$toolitem->show;
$toolbar->insert ($toolitem, $toolpos++);
$values_combobox = $self->{'values_combobox'} = $toolitem->get_child;
set_property_maybe ($values_combobox, # tearoff-title new in 2.10
tearoff_title => __('Math-Image: Values'));
$values_combobox->signal_connect
('notify::active-nick' => \&_do_values_changed);
Glib::Ex::ConnectProperties->new ([$draw,'values'],
[$values_combobox,'active-nick']);
### values combobox initial: $values_combobox->get('active-nick')
require App::MathImage::Gtk1::Params;
my $values_params = $self->{'values_params'}
= App::MathImage::Gtk1::Params->new (toolbar => $toolbar,
after_toolitem => $toolitem);
### values_params values to parameter_info_array...
Glib::Ex::ConnectProperties->new
([$draw,'values'],
[$values_params,'parameter-info-array',
devel/lib/App/MathImage/Gtk1/Main.pm view on Meta::CPAN
}
{
my $toolitem = Gtk::Ex::ToolItem::ComboEnum->new
(enum_type => 'App::MathImage::Gtk::Drawing::Filters',
overflow_mnemonic => __('Filter'));
set_property_maybe ($toolitem, # tooltip-text new in 2.12
tooltip_text => __('Filter the values to only odd, or even, or primes, etc.'));
$toolitem->show;
$toolbar->insert ($toolitem, $toolpos++);
my $combobox = $toolitem->get_child;
set_property_maybe ($combobox,
tearoff_title => __('Math-Image: Filter'));
Glib::Ex::ConnectProperties->new
([$draw,'filter'],
[$combobox,'active-nick']);
}
}
# 'destroy' class closure
sub _do_destroy {
my ($self) = @_;
### Main FINALIZE_INSTANCE(), break circular refs...
delete $self->{'actiongroup'};
devel/lib/App/MathImage/Gtk1/Main.pm view on Meta::CPAN
return shift->signal_chain_from_overridden(@_);
}
sub _update_values_tooltip {
my ($self) = @_;
### _update_values_tooltip()...
{
my $tooltip = __('The values to display.');
my $toolitem = $self->{'values_toolitem'};
my $values_combobox = $self->{'values_combobox'} || return;
my $enum_type = $values_combobox->get('enum_type');
my $values = $values_combobox->get('active-nick');
# my $desc = Glib::Ex::EnumBits::to_description($enum_type, $values)
my $values_seq;
if (($values_seq = $self->{'draw'}->gen_object->values_seq)
&& (my $desc = $values_seq->description)) {
my $name = Glib::Ex::EnumBits::to_display ($enum_type, $values);
$tooltip .= "\n\n"
. __x('Current setting: {name}', name => $name)
. "\n"
. $desc;
devel/lib/App/MathImage/Gtk2/Ex/Menu/ForComboBox.pm view on Meta::CPAN
# uncomment this to run the ### lines
#use Smart::Comments;
our $VERSION = 110;
use Glib::Object::Subclass
'Gtk2::Ex::MenuView',
signals => { 'item-create-or-update' => \&_do_item_create_or_update,
},
properties => [ Glib::ParamSpec->object
('combobox',
'Combo box object',
'Blurb.',
'Gtk2::ComboBox',
Glib::G_PARAM_READWRITE),
Glib::ParamSpec->string
('active-nick',
'Active nick',
'The selected enum value, as its nick.',
(eval {Glib->VERSION(1.240);1}
devel/lib/App/MathImage/Gtk2/Ex/Menu/ForComboBox.pm view on Meta::CPAN
# sub INIT_INSTANCE {
# my ($self) = @_;
# }
sub SET_PROPERTY {
my ($self, $pspec, $newval) = @_;
my $pname = $pspec->get_name;
$self->{$pname} = $newval;
### Enum SET_PROPERTY: $pname, $newval
if ($pname eq 'combobox') {
my $combobox = $newval;
Scalar::Util::weaken (my $weak_self = $self);
$self->{'combobox_ids'} = $combobox && Glib::Ex::SignalIds->new
($combobox,
$combobox->signal_connect (notify => \&_do_combobox_notify, \$weak_self));
_update_model($self);
}
}
sub _do_item_create_or_update {
my ($self, $item, $model, $path, $iter) = @_;
my $combobox = $self->{'combobox'};
if (! $item) {
$item = Gtk2::CheckMenuItem->new;
$item->set_draw_as_radio (1);
my $cellview = Gtk2::CellView->new;
foreach my $renderer ($combobox->get_cells) {
$cellview->pack_start ($renderer, 1);
$cellview->set_cell_data_func ($renderer, \&_do_cell_data);
}
$item->add ($cellview);
}
my $cellview = $item->get_child;
$cellview->set_model ($combobox->get_model);
$cellview->set_displayed_row ($path);
return $item;
}
sub _do_cell_data {
my ($self, $renderer, $model, $iter) = @_;
}
sub _do_combobox_notify {
my ($combobox, $pspec, $ref_weak_self) = @_;
my $self = $$ref_weak_self || return;
my $pname = $pspec->get_name;
if ($pname eq 'model') {
_update_model($self);
} elsif ($pname eq 'active') {
_update_active($self);
}
}
sub _update_model {
my ($self) = @_;
my $combobox = $self->{'combobox'};
my $model = $combobox && $combobox->get_model;
$self->set (model => $model);
_update_active ($self);
}
sub _update_active {
my ($self) = @_;
my $combobox = $self->{'combobox'};
my $model = $combobox && $combobox->get_model;
if (my $active_item = delete $self->{'active_item'}) {
$active_item->set_active (0);
}
if (my $iter = $combobox->get_active_iter) {
my $path = $model->get_path ($iter);
my $item = $self->item_at_path ($path);
$item->set_active (1);
Scalar::Util::weaken ($self->{'active_item'} = $item);
}
}
1;
__END__
# =for stopwords Math-Image enum ParamSpec pspec Enum Ryde
#
# =head1 NAME
#
# App::MathImage::Gtk2::Ex::Menu::ForComboBox -- menu of entries from a combobox
#
# =head1 SYNOPSIS
#
# use App::MathImage::Gtk2::Ex::Menu::ForComboBox;
# my $menu = App::MathImage::Gtk2::Ex::Menu::ForComboBox->new
# (combobox => $my_combobox);
#
# =head1 WIDGET HIERARCHY
#
# C<App::MathImage::Gtk2::Ex::Menu::ForComboBox> is a subclass of C<Gtk2::Menu>,
#
# Gtk2::Widget
# Gtk2::Container
# Gtk2::MenuShell
# Gtk2::Menu
# App::MathImage::Gtk2::Ex::Menu::ForComboBox
devel/lib/App/MathImage/Gtk2/Ex/Menu/ForComboBox.pm view on Meta::CPAN
# =head1 FUNCTIONS
#
# =over 4
#
# =item C<< $menu = App::MathImage::Gtk2::Ex::Menu::ForComboBox->new (key=>value,...) >>
#
# Create and return a new C<ForComboBox> menu object. Optional key/value pairs
# set initial properties per C<< Glib::Object->new >>.
#
# my $menu = App::MathImage::Gtk2::Ex::Menu::ForComboBox->new
# (combobox => $my_combobox);
#
# =back
#
# =head1 PROPERTIES
#
# =over 4
#
# =item C<combobox> (C<Gtk2::ComboBox> object, default C<undef>)
#
# =back
#
# =head1 SEE ALSO
#
# L<Gtk2::Menu>,
# L<Gtk2::ComboBox>,
#
# =head1 HOME PAGE
#
devel/menu-forcombo.pl view on Meta::CPAN
my $toplevel = Gtk2::Window->new('toplevel');
$toplevel->signal_connect (destroy => sub { Gtk2->main_quit });
my $vbox = Gtk2::VBox->new;
$toplevel->add ($vbox);
my $menubar = Gtk2::MenuBar->new;
$vbox->pack_start ($menubar, 0,0,0);
my $combobox = Gtk2::Ex::ComboBox::Enum->new (enum_type => 'My::Test1');
$combobox->signal_connect ('notify::active-nick' => sub {
my ($menu) = @_;
print "$progname: active-nick now ",$menu->get('active-nick')||'[undef]',"\n";
});
$vbox->pack_start ($combobox, 0,0,0);
my $item = Gtk2::MenuItem->new_with_label ('Menu');
$menubar->add ($item);
my $menu = App::MathImage::Gtk2::Ex::Menu::ForComboBox->new
(combobox => $combobox);
$item->set_submenu ($menu);
my $tearoff = Gtk2::TearoffMenuItem->new;
$menu->prepend($tearoff);
{
my $button = Gtk2::Button->new_with_label ('set active undef');
$button->signal_connect (clicked => sub {
$combobox->set (active_nick => undef);
});
$vbox->pack_start ($button, 0, 0, 0);
}
$toplevel->show_all;
Gtk2->main;
exit 0;
devel/run-savetype.pl view on Meta::CPAN
use warnings;
use Gtk2::Ex::ComboBox::PixbufType;
use Gtk2 '-init';
use FindBin;
my $progname = $FindBin::Script;
if (0) {
my @properties = Glib::Object::list_properties('Gtk2::ComboBox');
require Data::Dumper;
print Data::Dumper->new([\@properties],['combobox properties'])->Dump;
exit 0;
}
if (0) {
my @properties = Glib::Object::list_properties('Gtk2::Ex::ComboBox::PixbufType');
require Data::Dumper;
print Data::Dumper->new([\@properties],['savetype properties'])->Dump;
exit 0;
}
devel/tool-combotext.pl view on Meta::CPAN
$toolbar->show;
$vbox->pack_start ($toolbar, 0,0,0);
{
my $toolitem = Gtk2::ToolButton->new(undef,'ZZZZZZ');
$toolitem->show;
$toolbar->insert($toolitem, -1);
}
my $combobox = Gtk2::ComboBox->new_text;
$combobox->append_text ('One');
$combobox->append_text ('Two');
$combobox->append_text ('Three');
$combobox->set (tooltip_text => 'ComboBox tooltip',
add_tearoffs => 1);
$combobox->show;
$combobox->signal_connect
(notify => sub {
my ($combobox, $pspec) = @_;
print "$progname: combobox notify ",$pspec->get_name,"\n";
});
$combobox->signal_connect
(changed => sub {
my ($combobox) = @_;
my $iter = $combobox->get_active_iter;
my $path = $iter ? $combobox->get_model->get_path($iter) : Gtk2::TreePath->new;
print "$progname: combobox changed active: ",$path->to_string,"\n";
});
my $toolitem = App::MathImage::Gtk2::Ex::ToolItem::ComboText->new
(child => $combobox,
overflow_mnemonic => '_Foo',
visible => 1,
tooltip_text => 'Tooltip on toolitem');
$toolitem->show;
$toolitem->signal_connect
(notify => sub {
my ($toolitem, $pspec) = @_;
print "$progname: toolitem notify ",$pspec->get_name,"\n";
});
$toolbar->insert($toolitem,-1);
devel/tool-combotext.pl view on Meta::CPAN
require Glib::Ex::ConnectProperties;
Glib::Ex::ConnectProperties->new
([$toolitem, 'sensitive'],
[$button, 'active']);
$button->show;
$vbox->pack_start ($button, 0, 0, 0);
}
{
my $button = Gtk2::CheckButton->new_with_label ('Child Sensitive');
Glib::Ex::ConnectProperties->new
([$combobox, 'sensitive'],
[$button, 'active']);
$button->show;
$vbox->pack_start ($button, 0, 0, 0);
}
$toplevel->show;
Gtk2->main;
exit 0;
lib/App/MathImage/Gtk2/Drawing/Values.pm view on Meta::CPAN
use App::MathImage::Generator;
# uncomment this to run the ### lines
#use Smart::Comments;
our $VERSION = 110;
our $TEXTDOMAIN = 'App-MathImage';
Glib::Type->register_enum ('App::MathImage::Gtk2::Drawing::Values',
App::MathImage::Generator->values_choices);
# Don't load up all classes for the combobox ...
# sub EnumBits_to_display {
# my ($class, $nick) = @_;
# require App::MathImage::Generator;
# return App::MathImage::Generator->values_class($nick)->name;
# }
sub EnumBits_to_description {
my ($class, $nick) = @_;
require App::MathImage::Generator;
return App::MathImage::Generator->values_class($nick)->description;
lib/App/MathImage/Gtk2/Ex/ToolItem/ComboText.pm view on Meta::CPAN
$menuitem->get_child->set_text (_mnemonic_text ($self));
}
}
}
sub _do_add_or_remove {
my ($self, $child) = @_;
### ComboText _do_add_or_remove()...
$self->signal_chain_from_overridden ($child);
my $combobox = $self->get_child;
Scalar::Util::weaken (my $weak_self = $self);
$self->{'combobox_ids'} = $combobox && Glib::Ex::SignalIds->new
($combobox,
$combobox->signal_connect (notify => \&_do_combobox_notify,
\$weak_self),
$combobox->signal_connect (changed => \&_do_combobox_changed_active,
\$weak_self));
if ($combobox) {
if (my $menuview = $self->{'menuview'}) {
$menuview->set (model => $combobox->get_model,
sensitive => $combobox->get_sensitive);
_do_combobox_changed_active ($combobox, \$self);
}
}
$self->rebuild_menu;
_update_tearoff ($self);
}
sub _do_combobox_notify {
my ($combobox, $pspec, $ref_weak_self) = @_;
my $self = $$ref_weak_self || return;
my $menuview = $self->{'menuview'} || return;
my $pname = $pspec->get_name;
if ($pname eq 'model') {
$menuview->set (model => $combobox->get_model);
_do_combobox_changed_active ($combobox, $ref_weak_self);
} elsif ($pname eq 'sensitive') {
$menuview->set (model => $combobox->get_sensitive);
} elsif ($pname eq 'add_tearoffs') {
_update_tearoff ($self);
}
}
sub _do_combobox_changed_active {
my ($combobox, $ref_weak_self) = @_;
my $self = $$ref_weak_self || return;
my $menuview = $self->{'menuview'} || return;
$menuview->set_active_iter ($combobox && $combobox->get_active_iter);
}
sub _do_create_menu_proxy {
my ($self) = @_;
### ComboText _do_create_menu_proxy()...
$self->{'menuitem'} ||= do {
### create new menuitem...
my $menuitem = Gtk2::MenuItem->new_with_mnemonic (_mnemonic_text($self));
$menuitem->set (sensitive => $self->get('sensitive'));
if ($self->find_property('tooltip_text')) { # new in Gtk 2.12
$menuitem->set (tooltip_text => $self->get('tooltip_text'));
}
require App::MathImage::Gtk2::Ex::ToolItem::ComboText::MenuView;
my $combobox = $self->get_child;
my $menuview = $self->{'menuview'}
= App::MathImage::Gtk2::Ex::ToolItem::ComboText::MenuView->new
(model => $combobox && $combobox->get_model);
Scalar::Util::weaken ($menuview->{'toolitem'} = $self);
_update_tearoff ($self);
$menuitem->set_submenu ($menuview);
$menuitem
};
### proxy: "$self->{'menuitem'}"
### menuview: "$self->{'menuview'}"
### return: defined($self->get_child)
$self->set_proxy_menu_item (__PACKAGE__, $self->{'menuitem'});
return defined($self->get_child); # show when have combobox
}
sub _mnemonic_text {
my ($self) = @_;
my $str = $self->{'overflow_mnemonic'};
if (defined $str) {
return $str;
} elsif (my $child_widget = $self->{'child_widget'}) {
return Gtk2::Ex::MenuBits::mnemonic_escape ($child_widget->get_name);
} else {
return '';
}
}
sub _update_tearoff {
my ($self) = @_;
if (my $menuview = $self->{'menuview'}) {
my $combobox = $self->get_child;
_menu_want_tearoff ($menuview, $combobox && $combobox->get('add_tearoffs'));
}
}
sub _menu_want_tearoff {
my ($menu, $want_tearoff) = @_;
if ($want_tearoff) {
unless (List::Util::first
{$_->isa('Gtk2::TearoffMenuItem')}
$menu->get_children) {
### add new TearoffMenuItem...
$menu->prepend (Gtk2::TearoffMenuItem->new);
lib/App/MathImage/Gtk2/Ex/ToolItem/ComboText/MenuView.pm view on Meta::CPAN
### ComboText MenuView _do_item_create_or_update(): "path=".$path->to_string
my $str = $model->get ($iter, 0);
if ($item) {
$item->get_child->set_text ($str);
} else {
$item = App::MathImage::Gtk2::Ex::ToolItem::ComboText::MenuItem->new_with_label ($str);
}
return $item;
}
# from combobox change
sub set_active_iter {
my ($self, $iter) = @_;
### ComboText-MenuView set_active_iter()...
my $model;
my $path = $iter
&& ($model = $self->get('model'))
&& $model->get_path($iter);
$self->set_active_path($path);
}
lib/App/MathImage/Gtk2/Ex/ToolItem/ComboText/MenuView.pm view on Meta::CPAN
# $self->_current_item_at_path($path)
$self->set_active_item ($self->item_at_path ($path));
}
# from item activate
sub set_active_item {
my ($self, $item) = @_;
### ComboText-MenuView set_active_item(): defined $item && $item->get_child->get_text
### old item: defined $self->{'active_item'} && $self->{'active_item'}->get_child->get_text
# watch out for recurse from combobox 'changed' handler
my $old_item = $self->{'active_item'};
if (($old_item||0) == ($item||0)) {
### unchanged: ($old_item||0).'', ($item||0).''
return;
}
Scalar::Util::weaken ($self->{'active_item'} = $item);
if ($old_item) {
$old_item->set_active (0);
}
if ($item) {
$item->set_active (1);
}
if (my $toolitem = $self->{'toolitem'}) {
if (my $combobox = $toolitem->get_child) {
Gtk2::Ex::ComboBoxBits::set_active_path
($combobox, $item && $self->item_get_path($item));
}
}
}
1;
__END__
lib/App/MathImage/Gtk2/Main.pm view on Meta::CPAN
$pointerposition->signal_connect
(message_string => \&_statusbar_pointerposition_message);
}
# {
# my $action = $actiongroup->get_action ('Toolbar');
# Glib::Ex::ConnectProperties->new ([$toolbar,'visible'],
# [$action,'active']);
# }
my $toolpos = -999;
my $path_combobox;
{
my $toolitem = Gtk2::Ex::ToolItem::ComboEnum->new
(enum_type => 'App::MathImage::Gtk2::Drawing::Path',
overflow_mnemonic => __('_Path'));
set_property_maybe
($toolitem, # tooltip-text new in 2.12
tooltip_text => __('The path for where to place values in the plane.'));
$toolitem->show;
$toolbar->insert ($toolitem, $toolpos++);
$path_combobox = $self->{'path_combobox'} = $toolitem->get_child;
set_property_maybe ($path_combobox,
# tearoff-title new in 2.10
tearoff_title => __('Math-Image: Path'));
Glib::Ex::ConnectProperties->new ([$draw,'path'],
[$toolitem,'active-nick']);
my $path_params = $self->{'path_params'}
= App::MathImage::Gtk2::Params->new (toolbar => $toolbar,
after_toolitem => $toolitem);
lib/App/MathImage/Gtk2/Main.pm view on Meta::CPAN
### path_params values to draw...
Glib::Ex::ConnectProperties->new ([$path_params,'parameter-values'],
[$draw,'path-parameters']);
}
{
my $separator = Gtk2::SeparatorToolItem->new;
$separator->show;
$toolbar->insert ($separator, $toolpos++);
}
my $values_combobox;
{
my $toolitem = $self->{'values_toolitem'}
= Gtk2::Ex::ToolItem::ComboEnum->new
(enum_type => 'App::MathImage::Gtk2::Drawing::Values',
overflow_mnemonic => __('_Values'));
$toolitem->show;
$toolbar->insert ($toolitem, $toolpos++);
$values_combobox = $self->{'values_combobox'} = $toolitem->get_child;
set_property_maybe ($values_combobox, # tearoff-title new in 2.10
tearoff_title => __('Math-Image: Values'));
Glib::Ex::ConnectProperties->new ([$draw,'values'],
[$values_combobox,'active-nick']);
### values combobox initial: $values_combobox->get('active-nick')
require App::MathImage::Gtk2::Params;
my $values_params = $self->{'values_params'}
= App::MathImage::Gtk2::Params->new (toolbar => $toolbar,
after_toolitem => $toolitem);
### values_params values to parameter_info_array...
Glib::Ex::ConnectProperties->new
([$draw,'values'],
[$values_params,'parameter-info-array',
lib/App/MathImage/Gtk2/Main.pm view on Meta::CPAN
}
{
my $toolitem = Gtk2::Ex::ToolItem::ComboEnum->new
(enum_type => 'App::MathImage::Gtk2::Drawing::Filters',
overflow_mnemonic => __('Filter'));
set_property_maybe ($toolitem, # tooltip-text new in 2.12
tooltip_text => __('Filter the values to only odd, or even, or primes, etc.'));
$toolitem->show;
$toolbar->insert ($toolitem, $toolpos++);
my $combobox = $toolitem->get_child;
set_property_maybe ($combobox,
tearoff_title => __('Math-Image: Filter'));
Glib::Ex::ConnectProperties->new
([$draw,'filter'],
[$combobox,'active-nick']);
}
{
my $toolitem = Gtk2::Ex::ToolItem::OverflowToDialog->new
(overflow_mnemonic => __('_Scale'));
$toolbar->insert ($toolitem, $toolpos++);
my $hbox = Gtk2::HBox->new;
set_property_maybe ($toolitem,
# tooltip-text new in 2.12
tooltip_text => __('How many pixels per square.'));
lib/App/MathImage/Gtk2/Main.pm view on Meta::CPAN
0); # page_size
Glib::Ex::ConnectProperties->new ([$draw,'scale'],
[$adj,'value']);
my $spin = Gtk2::SpinButton->new ($adj, 10, 0);
$spin->set_width_chars(3);
$hbox->pack_start ($spin, 0,0,0);
$toolitem->show_all;
# hide for LinesLevel
Glib::Ex::ConnectProperties->new
([$values_combobox,'active-nick'],
[$toolitem,'visible',
write_only => 1,
func_in => sub { $_[0] ne 'LinesLevel' }]);
}
{
my $toolitem = Gtk2::Ex::ToolItem::ComboEnum->new
(enum_type => 'App::MathImage::Gtk2::Drawing::FigureType',
overflow_mnemonic => __('_Figure'));
set_property_maybe ($toolitem,
tooltip_text => __('The figure to draw at each position.'));
$toolitem->show;
$toolbar->insert ($toolitem, $toolpos++);
my $combobox = $toolitem->get_child;
set_property_maybe ($combobox, # tearoff-title new in 2.10
tearoff_title => __('Math-Image: Figure'));
Glib::Ex::ConnectProperties->new
([$draw,'figure'],
[$combobox,'active-nick']);
}
Gtk2::Ex::ActionTooltips::group_tooltips_to_menuitems ($actiongroup);
if (my $action = $actiongroup->get_action ('OeisBrowse')) {
Gtk2::Ex::ActionTooltips::action_tooltips_to_menuitems_dynamic ($action);
}
}
# 'destroy' class closure
sub _do_destroy {
lib/App/MathImage/Gtk2/Main.pm view on Meta::CPAN
return shift->signal_chain_from_overridden(@_);
}
sub _update_values_tooltip {
my ($self) = @_;
### _update_values_tooltip() ...
{
my $tooltip = __('The values to display.');
my $toolitem = $self->{'values_toolitem'};
my $values_combobox = $self->{'values_combobox'} || return;
my $enum_type = $values_combobox->get('enum_type');
my $values = $values_combobox->get('active-nick');
my $gen_object = $self->{'draw'}->gen_object;
if (my $values_seq = $gen_object->values_seq_maybe) {
{
my $name = Glib::Ex::EnumBits::to_display ($enum_type, $values);
$tooltip .= "\n\n" . __x('Current setting: {name}', name => $name);
}
if (my $desc = $values_seq->description) {
$tooltip .= "\n" . $desc;
}
lib/App/MathImage/Gtk2/OeisEntry.pm view on Meta::CPAN
#
# Math-Image is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with Math-Image. If not, see <http://www.gnu.org/licenses/>.
# go to no extension when combobox nothing selected ...
package App::MathImage::Gtk2::OeisEntry;
use 5.008;
use strict;
use warnings;
use Gtk2 1.220; # for Gtk2::EVENT_PROPAGATE()
use POSIX ();
use Module::Load;
use List::Util 'max';
lib/App/MathImage/Gtk2/Params/Enum.pm view on Meta::CPAN
} else {
my $name = $newval->{'name'};
my $display = ($newval->{'display'} || $name);
$self->set (enum_type => _pinfo_to_enum_type($newval),
overflow_mnemonic =>
Gtk2::Ex::MenuBits::mnemonic_escape($display));
if (! defined ($self->get('parameter-value'))) {
$self->set (parameter_value => $newval->{'default'});
}
my $combobox = $self->get_child;
set_property_maybe ($combobox, # tearoff-title new in 2.10
tearoff_title => __('Math-Image:').' '.$display);
}
}
sub _pinfo_to_enum_type {
my ($pinfo) = @_;
my $key = $pinfo->{'share_key'} || $pinfo->{'name'};
my $enum_type = "App::MathImage::Gtk2::Params::Enum::$key";
if (! eval { Glib::Type->list_values ($enum_type); 1 }) {
my $choices = $pinfo->{'choices'} || [];
lib/App/MathImage/Gtk2/PodDialog.pm view on Meta::CPAN
$self->set_title ($title);
}
# connect to self instead of a class handler since as of Gtk2-Perl 1.200 a
# Gtk2::Dialog class handler for 'response' is called with response IDs as
# numbers, not enum strings like 'accept'
$self->signal_connect (response => \&_do_response);
my $vbox = $self->vbox;
my $combobox = $self->{'combobox'} = Gtk2::ComboBox->new_text;
$combobox->append_text ($FindBin::Script);
foreach my $name (App::MathImage::Generator->path_choices) {
$combobox->append_text ($name);
}
foreach my $name (App::MathImage::Generator->values_choices) {
$combobox->append_text ($name);
}
if (defined (Module::Util::find_installed('Math::Aronson'))) {
$combobox->append_text ('Math::Aronson');
}
$combobox->append_text ('Math::Symbolic');
$combobox->append_text ('Math::Expression::Evaluator');
$combobox->set_active (0);
$combobox->signal_connect (changed => \&_do_combo_changed);
my $action_hbox = $self->get_action_area;
$action_hbox->pack_start ($combobox, 0,0,0);
$self->add_buttons ('gtk-close' => 'cancel');
my $scrolled = Gtk2::ScrolledWindow->new;
$scrolled->set_policy ('never', 'always');
$vbox->pack_start ($scrolled, 1,1,0);
my $viewer = $self->{'viewer'} = Gtk2::Ex::PodViewer->new;
$viewer->signal_connect (link_clicked => \&_do_viewer_link_clicked);
$scrolled->add ($viewer);
lib/App/MathImage/Gtk2/PodDialog.pm view on Meta::CPAN
Glib::Idle->add (\&_do_idle, \$weak_self,
Gtk2::GTK_PRIORITY_RESIZE() + 10); # low priority
# Glib::Timeout->add (3000, \&_do_idle, \$weak_self,
# Gtk2::GTK_PRIORITY_RESIZE() + 10);
}
sub GET_PROPERTY {
my ($self, $pspec) = @_;
my $pname = $pspec->get_name;
if ($pname eq 'pod') {
return $self->{'combobox'}->get_active_text;
} else {
return $self->{$pname};
}
}
sub SET_PROPERTY {
my ($self, $pspec, $newval) = @_;
my $pname = $pspec->get_name;
if ($pname eq 'pod') {
if (! defined $newval) {
$newval = $pspec->get_default_value;
}
return Gtk2::Ex::ComboBoxBits::set_active_text
($self->{'combobox'}, $newval);
} else {
$self->{$pname} = $newval;
}
}
sub _do_idle {
my ($ref_weak_self) = @_;
if (my $self = $$ref_weak_self) {
_do_combo_changed ($self->{'combobox'});
delete $self->{'cursor'};
}
return Glib::SOURCE_REMOVE; # once only
}
sub _do_response {
my ($self, $response) = @_;
if ($response eq 'cancel') {
# "Close" button gives GTK_RESPONSE_CANCEL.
# Emit 'close' same as a keyboard Esc to close, and that signal defaults
# to raising 'delete-event', which in turn defaults to a destroy
$self->signal_emit ('close');
}
}
sub _do_combo_changed {
my ($combobox) = @_;
my $self = $combobox->get_ancestor(__PACKAGE__) || return;
my $filename;
my $name = $combobox->get_active_text;
if ($combobox->get_active == 0) {
$filename = "$FindBin::Bin/$name";
} elsif ($name) {
$name =~ s/-/::/g;
if ($name =~ /::/) {
$filename = Module::Util::find_installed ($name);
} else {
if (my $module = App::MathImage::Generator->path_choice_to_class($name)
|| App::MathImage::Generator->values_choice_to_class($name)) {
$filename = Module::Util::find_installed ($module);
}
lib/App/MathImage/Gtk2/SaveDialog.pm view on Meta::CPAN
#
# Math-Image is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with Math-Image. If not, see <http://www.gnu.org/licenses/>.
# go to no extension when combobox nothing selected ...
package App::MathImage::Gtk2::SaveDialog;
use 5.008;
use strict;
use warnings;
use Text::Capitalize;
use File::Spec;
use List::Util;
use Gtk2;
lib/App/MathImage/Gtk2/SaveDialog.pm view on Meta::CPAN
$dialog->signal_connect (response => \&_message_dialog_response);
$dialog->present;
}
}
sub _message_dialog_response {
my ($dialog) = @_;
$dialog->destroy;
}
# type combobox 'active' signal handler
sub _combo_notify_active {
my ($combo) = @_;
my $self = $combo->get_ancestor(__PACKAGE__);
my $type = $combo->get('active-type');
my $info = ($type && Gtk2::Ex::PixbufBits::type_to_format($type)) || return;
_change_extension ($self,
$self->{'old_extensions'} || [],
$info->{'extensions'});
$self->{'old_extensions'} = $info->{'extensions'};
lib/App/MathImage/Prima/Main.pm view on Meta::CPAN
pack => { side => 'left' },
hint => __('Choose a random path, values, scale, etc.
Click repeatedly to see interesting things.'),
onClick => sub {
my ($button) = @_;
$self->{'draw'}->gen_options (App::MathImage::Generator->random_options);
_update($self);
},
);
my $combobox_height = do {
my $combo = Prima::ComboBox->create;
my $height = $combo->editHeight;
$combo->destroy;
$height
};
my $path_combo = $self->{'path_combo'}
= $toolbar->insert ('ComboBox',
pack => { side => 'left',
fill => 'none',
expand => 0 },
hint => __('The path for where to place values in the plane.'),
style => cs::DropDown,
# override dodgy height when style set
height => $combobox_height,
items => [ map { $_ } App::MathImage::Generator->path_choices ],
onChange => sub {
my ($combo) = @_;
### Main path_combo onChange
my $path = $combo->text;
$self->{'draw'}->gen_options (path => $path);
_update ($self);
},
);
$self->{'values_combo'}
= $toolbar->insert ('ComboBox',
pack => { side => 'left',
fill => 'none',
expand => 0 },
style => cs::DropDown,
# override dodgy height when style set
height => $combobox_height,
hint => __('The values to display.'),
items => [ map { $_ } App::MathImage::Generator->values_choices ],
onChange => sub {
my ($combo) = @_;
### Main values combo onChange
my $values = $combo->text;
$self->{'draw'}->gen_options (values => $values);
_update ($self);
},
);