| 1 | # not really working ??? | ||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | # Copyright 2008, 2009, 2010 Kevin Ryde | ||
| 6 | |||
| 7 | # This file is part of Chart. | ||
| 8 | # | ||
| 9 | # Chart is free software; you can redistribute it and/or | ||
| 10 | # modify it under the terms of the GNU General Public License as published | ||
| 11 | # by the Free Software Foundation; either version 3, or (at your option) any | ||
| 12 | # later version. | ||
| 13 | # | ||
| 14 | # Chart is distributed in the hope that it will be useful, but | ||
| 15 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
| 16 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| 17 | # for more details. | ||
| 18 | # | ||
| 19 | # You should have received a copy of the GNU General Public License along | ||
| 20 | # with Chart. If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | |||
| 22 | package App::Chart::Gtk2::Ex::CellRendererButton; | ||
| 23 | use 5.006; | ||
| 24 | use strict; | ||
| 25 | use warnings; | ||
| 26 | use Gtk2; | ||
| 27 | |||
| 28 | # uncomment this to run the ### lines | ||
| 29 | #use Smart::Comments; | ||
| 30 | |||
| 31 | use Glib::Object::Subclass | ||
| 32 | 'Gtk2::CellRendererText', | ||
| 33 | signals => { editing_started => \&_do_editing_started, | ||
| 34 | clicked => { param_types => ['Glib::String'], | ||
| 35 | return_type => undef }, | ||
| 36 | }; | ||
| 37 | |||
| 38 | |||
| 39 | sub INIT_INSTANCE { | ||
| 40 | my ($self) = @_; | ||
| 41 | $self->set (editable => 1); | ||
| 42 | } | ||
| 43 | |||
| 44 | # gtk_cell_renderer_start_editing() | ||
| 45 | # | ||
| 46 | sub START_EDITING { | ||
| 47 | my ($self, $event, $view, $pathstr, $back_rect, $cell_rect, $flags) = @_; | ||
| 48 | ### CellRendererButton START_EDITING: $pathstr | ||
| 49 | $self->{'pathstr'} = $pathstr; | ||
| 50 | return undef; | ||
| 51 | } | ||
| 52 | |||
| 53 | sub _do_editing_started { | ||
| 54 | my ($self, $editable, $pathstr) = @_; | ||
| 55 | ### CellRendererButton editing_started | ||
| 56 | $self->signal_chain_from_overridden ($editable, $pathstr); | ||
| 57 | $self->stop_editing (1); | ||
| 58 | $self->signal_emit ('clicked', $self->{'pathstr'}); | ||
| 59 | } | ||
| 60 | |||
| 61 | 1; | ||
| 62 | __END__ | ||
| 63 | |||
| 64 | =for stopwords renderer DateSpinner CellRendererButton Eg | ||
| 65 | |||
| 66 | =head1 NAME | ||
| 67 | |||
| 68 | App::Chart::Gtk2::Ex::CellRendererButton -- date cell renderer with DateSpinner for editing | ||
| 69 | |||
| 70 | =for test_synopsis my ($treeviewcolumn) | ||
| 71 | |||
| 72 | =head1 SYNOPSIS | ||
| 73 | |||
| 74 | use App::Chart::Gtk2::Ex::CellRendererButton; | ||
| 75 | my $renderer = App::Chart::Gtk2::Ex::CellRendererButton->new; | ||
| 76 | |||
| 77 | $treeviewcolumn->pack_start ($renderer, 0); | ||
| 78 | $treeviewcolumn->add_attribute ($renderer, text => 0); | ||
| 79 | |||
| 80 | $renderer->signal_connect (clicked => sub { some_code() }); | ||
| 81 | |||
| 82 | =head1 WIDGET HIERARCHY | ||
| 83 | |||
| 84 | C<App::Chart::Gtk2::Ex::CellRendererButton> is a subclass of | ||
| 85 | C<Gtk2::CellRendererText>. | ||
| 86 | |||
| 87 | Gtk2::Object | ||
| 88 | Gtk2::CellRenderer | ||
| 89 | Gtk2::CellRendererText | ||
| 90 | App::Chart::Gtk2::Ex::CellRendererButton | ||
| 91 | |||
| 92 | =head1 DESCRIPTION | ||
| 93 | |||
| 94 | C<CellRendererButton> ... | ||
| 95 | |||
| 96 | =head1 FUNCTIONS | ||
| 97 | |||
| 98 | =over 4 | ||
| 99 | |||
| 100 | =item C<< $renderer = App::Chart::Gtk2::Ex::CellRendererButton->new (key=>value,...) >> | ||
| 101 | |||
| 102 | Create and return a new CellRendererButton object. Optional key/value pairs | ||
| 103 | set initial properties as per C<< Glib::Object->new >>. Eg. | ||
| 104 | |||
| 105 | my $renderer = App::Chart::Gtk2::Ex::CellRendererButton->new; | ||
| 106 | |||
| 107 | =back | ||
| 108 | |||
| 109 | =head1 SEE ALSO | ||
| 110 | |||
| 111 | L<Gtk2::CellRenderer> | ||
| 112 | |||
| 113 | =cut |