1SourceView(3) User Contributed Perl Documentation SourceView(3)
2
3
4
6 Gtk2::SourceView - Perl wrappers for the GtkSourceView widget
7
9 use Gtk2 '-init';
10 use Gtk2::SourceView;
11
12 $lm = Gtk2::SourceView::LanguagesManager->new;
13 $lang = $lm->get_language_from_mime_type("application/x-perl");
14 if ($lang)
15 {
16 $sb = Gtk2::SourceView::Buffer->new_with_language($lang);
17 $sb->set_highlight(1);
18 }
19 else
20 {
21 $sb = Gtk2::SourceView::Buffer->new(undef);
22 $sb->set_highlight(0);
23 }
24
25 # loading a file should be atomically undoable.
26 $sb->begin_not_undoable_action();
27 open INFILE, "program.pl" or die "Unable to open program.pl";
28 while (<INFILE>)
29 {
30 $sb->insert($sb->get_end_iter(), $_);
31 }
32 $sb->end_not_undoable_action();
33
34 # Gtk2::SourceView::Buffer inherits from Gtk2::TextBuffer.
35 $sb->set_modified(0);
36 $sb->place_cursor($sb->get_start_iter());
37
38 $win = Gtk2::Window->new('toplevel');
39 $sw = Gtk2::ScrolledWindow->new;
40 $sw->set_policy('automatic', 'automatic');
41 $win->add($sw);
42
43 # Gtk2::SourceView::View inherits from Gtk2::TextView.
44 $view = Gtk2::SourceView::View->new_with_buffer($sb);
45 $sw->add($view);
46 $view->show;
47 $win->show_all;
48
49 Gtk2->main;
50
51 0;
52
54 Perl bindings to the 1.x series of the GtkSourceView widget libraries.
55
57 Perl bindings to the 1.x series of the GtkSourceView widget libraries.
58 This module allows you to write Perl applications that utilize the
59 GtkSourceView library for source editing and printing.
60
61 To discuss gtk2-perl, ask questions and flame/praise the authors, join
62 gtk-perl-list@gnome.org at lists.gnome.org.
63
65 perl(1), Glib(3pm), Gtk2(3pm), Gnome2::Print(3pm).
66
68 Emmanuele Bassi <emmanuele.bassi@iol.it> muppet <scott at asofyet dot
69 org> Torsten Schoenfeld <kaffeetisch at gmx dot de>
70
71 gtk2-perl created by the gtk2-perl team: http://gtk2-perl.sf.net
72
74 Copyright 2004-2005 by Emmanuele Bassi (see the file AUTHORS)
75
76 This library is free software; you can redistribute it and/or modify it
77 under the terms of the GNU Library General Public License as published
78 by the Free Software Foundation; either version 2 of the License, or
79 (at your option) any later version.
80
81 This library is distributed in the hope that it will be useful, but
82 WITHOUT ANY WARRANTY; without even the implied warranty of
83 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
84 Library General Public License for more details.
85
86 You should have received a copy of the GNU Library General Public
87 License along with this library; if not, write to the Free Software
88 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307
89 USA.
90
91
92
93perl v5.12.3 2005-09-27 SourceView(3)