Jeffrey Ray Hallock > Gtk2-Ex-CellRendererWrappedText-0.2 > Gtk2::Ex::CellRendererWrappedText

Download:
Gtk2-Ex-CellRendererWrappedText-0.2.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.2   Source  

NAME ^

Gtk2::Ex::CellRendererWrappedText - Widget for displaying and editing multi-line text entries in a TreeView

SYNOPSIS ^

 use Gtk2::Ex::CellRendererWrappedText;
 
 $treeview->new( $model );
 
 $cell = Gtk2::CellRender

 $cell = Gtk2::Ex::CellRendererWrappedText->new;
 
 $cell->set( editable => 1 );
 
 $cell->set( wrap_mode => 'word' );
 
 $cell->set( wrap_width => 400 );
 
 $cell->signal_connect (edited => sub {
                my ($cell, $text_path, $new_text, $model) = @_;
                my $path = Gtk2::TreePath->new_from_string ($text_path);
                my $iter = $model->get_iter ($path);
                $model->set ($iter, 1, $new_text);
        }, $model);

 $column = Gtk2::TreeViewColumn->new_with_attributes( 'Wrapped', $cell, text => 1 );
 
 $column->set_resizable( 1 );
 
 $view->append_column ($column);

WIDGET HIERARCHY ^

Glib::Object
+-- Glib::InitiallyUnowned
....+-- Gtk2::Object
........+-- Gtk2::CellRenderer
............+-- Gtk2::CellRendererText
................+ Gtk2::Ex::CellRendererWrappedText

DESCRIPTION ^

Gtk2::Ex::CellRendererWrappedText is a Gtk2::CellRendererText that automatically updates the wrap-width of the of the renderer when it is resized so that it always expands or shrinks to the avaialble area.

This module also handles editing of strings that span multiple lines by using a TextView instead of an Entry as CellRendererText does.

Pressing <Esc> whil in edit mode cancels the edit. Pressing <Enter> moves to the next line. Pressing <Ctrl+Enter> or focusing out of the renderer finishes editing and emits the 'edited' signal.

BUGS & CAVEATS ^

Using this module produces this warning:

    GLib-GObject-CRITICAL **: Object class Gtk2__Ex__CellRendererWrappedText__TextView
    doesn't implement property 'editing-canceled' from interface 'GtkCellEditable' at ...

This is only a warning, and a known issue with Gtk+ and the Gtk2-Perl bindings that will not affect behaviour of the widget.

See this post for more information:

http://old.nabble.com/Having-issues-porting-a-CellRenderer---CellEditable-to-Gtk3-td34129064.html

AUTHOR ^

Jeffrey Ray Hallock <jeffrey.hallock at gmail dot com>

Some code adapted from Muppet's customrenderer.pl script included in the Gtk2 examples directory.

COPYRIGHT & LICENSE ^

Copyright (c) 2010-2012 Jeffrey Ray Hallock.

    This is free software, licensed under:

    The Artistic License 2.0 (GPL Compatible)
syntax highlighting: