Gtk2-Ex-DBITableFilter
view release on metacpan or search on metacpan
lib/Gtk2/Ex/DBITableFilter/FilterWidget.pm view on Meta::CPAN
my $col = $slist->get_column($columnnumber);
my $title = $col->get_title;
my $label = Gtk2::Label->new ($title);
my $labelbox = _add_arrow($label);
$col->set_widget ($labelbox);
$labelbox->show_all;
my $button = $col->get_widget; # not a button
do {
$button = $button->get_parent;
} until ($button->isa ('Gtk2::Button'));
my $popupwindow = Gtk2::Ex::PopupWindow->new($labelbox);
my $frame = Gtk2::Frame->new;
my $entry = Gtk2::Entry->new;
$entry->signal_connect( 'changed' =>
sub {
my $pattern_string;
if ($entry->get_text) {
$pattern_string = '\'%'.$entry->get_text.'%\'';
} else {
$pattern_string = undef;
}
$parent->{params}->{columnfilter}->{$columnnumber} = $pattern_string;
}
);
$frame->add($entry);
$frame->set_size_request(0, 0);
$popupwindow->{window}->add($frame);
$button->signal_connect ('button-release-event' =>
sub {
my ($self, $event) = @_;
$popupwindow->show;
}
);
}
sub add_choice {
my ($self, $columnnumber, $list) = @_;
my $parent = $self->{parent};
my $slist = $parent->{slist};
$slist->set_headers_clickable(TRUE);
my $col = $slist->get_column($columnnumber);
lib/Gtk2/Ex/DBITableFilter/FilterWidget.pm view on Meta::CPAN
sub add_date_filter {
my ($self, $columnnumber, $preselected) = @_;
my ($command1, $date1, $joiner1, $command2, $date2) = ('', '', '', '', '');
($command1, $date1, $joiner1, $command2, $date2) = @$preselected if $preselected;
#print "$date1, $command1, $joiner1, $date2, $command2\n";
my $parent = $self->{parent};
my $button = $self->_get_column_header_button($columnnumber);
my $popupwindow = Gtk2::Ex::PopupWindow->new($button);
$popupwindow->set_move_with_parent(TRUE);
my $choices = ['before', 'after'];
my $joiner = [ '', 'and', 'or'];
my $datelabel1 = Gtk2::Label->new;
my $datelabelbox1 = _calendar_popup($datelabel1, $date1);
my $combobox1 = Gtk2::ComboBox->new_text;
$combobox1->append_text($choices->[0]);
$combobox1->append_text($choices->[1]);
my $index1 = 1;
if ($command1) {
my $i = 0;
$index1 = { map { $_ => $i++ } @$choices }->{$command1};
}
$combobox1->set_active($index1);
my $datelabel2 = Gtk2::Label->new;
my $datelabelbox2 = _calendar_popup($datelabel2, $date2);
my $combobox2 = Gtk2::ComboBox->new_text;
$combobox2->append_text($choices->[0]);
$combobox2->append_text($choices->[1]);
my $index2 = 0;
if ($command1) {
my $i = 0;
$index2 = { map { $_ => $i++ } @$choices }->{$command2};
}
$combobox2->set_active($index2);
lib/Gtk2/Ex/DBITableFilter/FilterWidget.pm view on Meta::CPAN
$table->attach($datelabelbox1,1,2,0,1, 'expand', 'expand', 0, 0);
$table->attach($and_or_combobox,2,3,0,1, 'expand', 'expand', 0, 0);
$table->attach($combobox2,0,1,1,2, 'expand', 'expand', 0, 0);
$table->attach($datelabelbox2,1,2,1,2, 'expand', 'expand', 0, 0);
my $apply = Gtk2::Button->new_from_stock('gtk-apply');
$parent->{params}->{columnfilter}->{$columnnumber} = &$refreshparams if $preselected;
$apply->signal_connect ('button-release-event' =>
sub {
$parent->{params}->{columnfilter}->{$columnnumber}
= &$refreshparams;
$popupwindow->hide;
}
);
my $clear = Gtk2::Button->new_from_stock('gtk-clear');
$clear->signal_connect ('button-release-event' =>
sub {
$parent->{params}->{columnfilter}->{$columnnumber} = undef;
$and_or_combobox->set_active(0);
$datelabel1->set_text('none');
$popupwindow->hide;
}
);
my $hbox = Gtk2::HBox->new (TRUE, 0);
$hbox->pack_start ($apply, TRUE, TRUE, 0);
$hbox->pack_start ($clear, TRUE, TRUE, 0);
my $vbox = Gtk2::VBox->new (FALSE, 0);
$vbox->pack_start ($table, TRUE, TRUE, 0);
$vbox->pack_start ($hbox, FALSE, FALSE, 0);
$popupwindow->{window}->add($vbox);
$button->signal_connect ('button-release-event' =>
sub {
my ($self, $event) = @_;
$popupwindow->show;
unless ($and_or_combobox->get_active()) {
$combobox2->hide;
$datelabelbox2->hide;
}
}
);
}
sub process_dates {
my ($self, $fieldname, $list) = @_;
lib/Gtk2/Ex/DBITableFilter/FilterWidget.pm view on Meta::CPAN
my $labelbox = _add_arrow($label);
$col->set_widget ($labelbox);
$labelbox->show_all;
my $button = $col->get_widget; # not a button
do {
$button = $button->get_parent;
} until ($button->isa ('Gtk2::Button'));
return $button;
}
sub _calendar_popup {
my ($datelabel, $datestr) = @_;
my $datelabelbox = _add_button_press(_add_arrow($datelabel));
my $datepopup = Gtk2::Ex::PopupWindow->new($datelabelbox);
my $date = Gtk2::Calendar->new;
if ($datestr) {
my ($year, $mon, $day) = split '-', $datestr;
$date->select_month($mon-1, $year);
$date->select_day($day);
$datelabel->set_text("$year-$mon-$day");
}
my $apply = Gtk2::Button->new_from_stock('gtk-apply');
my $vbox = Gtk2::VBox->new (FALSE, 0);
$vbox->pack_start ($date, FALSE, FALSE, 0);
$vbox->pack_start ($apply, FALSE, FALSE, 0);
$apply->signal_connect ('button-release-event' =>
sub {
my ($year, $mon, $day) = $date->get_date();
$datelabel->set_text("$year-$mon-$day");
$datepopup->hide;
}
);
$datepopup->{window}->add($vbox);
$datelabelbox->signal_connect ('button-release-event' =>
sub {
$datepopup->show;
}
);
return $datelabelbox;
}
sub month {
return [
'January',
'February',
'March',
( run in 0.853 second using v1.01-cache-2.11-cpan-364913b4093 )