Gtk2-Ex-Datasheet-DBI
view release on metacpan or search on metacpan
- harmless anyway because we only support automatic renderer selection for MySQL currently
Updated documentation & cleaned up POD somewhat
Version 1.0, ( not released )
Added dump_on_error flag to dump SQL on a DBI error
Converted more 0s to FALSEs
Version 0.9, released 16-Sep-2005
Add some logic to MOFO::CellRendererDate so that popup calendar gets placed completely on-screen
Added MOFO::CellRendererTime and use when a Time column is encountered
Dialog question asking user whether to apply if window is closed with unapplied changes to recordset
Add missing code to process sql_order_by
Renamed readonly flag to read_only ( for consistency ) and hide status column when read_only
Version 0.8, released 15-Aug-2005
Refresh dynamic combos when a toggle that they depend on is edited
Automatically choose a renderer type based on the database field type of each field ( can be overriden )
Automatically choose a default value for each column based on the database field definition ( can be overriden )
lib/Gtk2/Ex/Datasheet/DBI.pm view on Meta::CPAN
}
sub INIT_INSTANCE {
my ( $cell ) = @_;
my $popup = Gtk2::Window->new ('popup');
my $vbox = Gtk2::VBox->new( 0, 0 );
my $calendar = Gtk2::Calendar->new();
$calendar->modify_font( Gtk2::Pango::FontDescription->from_string( "Arial " . $cell->get( "font" ) ) );
my $hbox = Gtk2::HBox->new( 0, 0 );
my $today = Gtk2::Button->new('Today');
my $none = Gtk2::Button->new('None');
$cell -> {_arrow} = Gtk2::Arrow->new( "down", "none" );
# We can't just provide the callbacks now because they might need access to
# cell-specific variables. And we can't just connect the signals in
lib/Gtk2/Ex/Datasheet/DBI.pm view on Meta::CPAN
$today->signal_connect( clicked => sub {
$cell->{ _today_clicked_callback }->( @_ )
if ( exists( $cell->{ _today_clicked_callback } ) );
} );
$none->signal_connect( clicked => sub {
$cell->{ _none_clicked_callback }->( @_ )
if ( exists( $cell->{ _none_clicked_callback } ) );
} );
$calendar->signal_connect( day_selected_double_click => sub {
$cell->{ _day_selected_double_click_callback }->( @_ )
if ( exists( $cell->{ _day_selected_double_click_callback } ) );
} );
$calendar->signal_connect( month_changed => sub {
$cell->{ _month_changed }->( @_ )
if ( exists( $cell->{ _month_changed } ) );
} );
$hbox->pack_start( $today, 1, 1, 0 );
$hbox->pack_start( $none, 1, 1, 0 );
$vbox->pack_start( $calendar, 1, 1, 0 );
$vbox->pack_start( $hbox, 0, 0, 0 );
# Find out if the click happended outside of our window. If so, hide it.
# Largely copied from Planner (the former MrProject).
# Implement via Gtk2::get_event_widget?
$popup->signal_connect( button_press_event => sub {
my ( $popup, $event ) = @_;
if ( $event->button() == 1 ) {
lib/Gtk2/Ex/Datasheet/DBI.pm view on Meta::CPAN
return 1;
}
}
return 0;
} );
$popup->add( $vbox );
$cell->{ _popup } = $popup;
$cell->{ _calendar } = $calendar;
}
sub START_EDITING {
my ( $cell, $event, $view, $path, $background_area, $cell_area, $flags ) = @_;
my $popup = $cell -> { _popup };
my $calendar = $cell->{ _calendar };
# Specify the callbacks. Will be called by the signal handlers set up in
# INIT_INSTANCE.
$cell->{ _today_clicked_callback } = sub {
my ($button) = @_;
my ($year, $month, $day) = $cell -> get_today();
$cell->signal_emit( edited=>$path, join( "-", $cell->add_padding( $year, $month, $day ) ) );
$cell->hide_popup();
lib/Gtk2/Ex/Datasheet/DBI.pm view on Meta::CPAN
my ( $button ) = @_;
$cell->signal_emit( edited=>$path, "" );
$cell->hide_popup();
};
$cell->{ _day_selected_double_click_callback } = sub {
my ( $calendar ) = @_;
my ( $year, $month, $day ) = $calendar->get_date();
$cell->signal_emit( edited => $path, join( "-", $cell -> add_padding( $year, ++$month, $day ) ) );
$cell->hide_popup();
};
$cell->{ _month_changed } = sub {
my ( $calendar ) = @_;
my ( $selected_year, $selected_month ) = $calendar->get_date();
my ( $current_year, $current_month, $current_day ) = $cell->get_today();
if ( $selected_year == $current_year && ++$selected_month == $current_month ) {
$calendar->mark_day( $current_day );
}
else {
$calendar->unmark_day( $current_day );
}
};
my ( $year, $month, $day ) = $cell->get_date();
$calendar->select_month( $month - 1, $year );
$calendar->select_day( $day );
# Necessary to get the correct allocation of the popup.
$popup->move( -500, -500 );
$popup->show_all();
# Figure out where to put the popup - ie don't put it offscreen,
# as it's not movable ( by the user )
my $screen_height = $popup->get_screen->get_height;
my $requisition = $popup->size_request();
my $popup_width = $requisition->width;
( run in 1.017 second using v1.01-cache-2.11-cpan-5dc5da66d9d )