Gtk2-SourceView2-0.10/0000755000175000017500000000000011400555301014576 5ustar emmanuelemmanuelGtk2-SourceView2-0.10/COPYING0000644000175000017500000004325411374060746015657 0ustar emmanuelemmanuel GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. Gtk2-SourceView2-0.10/MANIFEST.SKIP0000644000175000017500000000024011374060746016506 0ustar emmanuelemmanuel^build/ ^Makefile$ ^Makefile[.]old$ ^xs/.*[.][co]$ ^blib/ ^pm_to_blib$ ^[.]git ^SourceView2[.]bs$ ^Gtk2-SourceView2-.+\.tar\.gz$ ^perl-Gtk2-SourceView2[.]doap$ Gtk2-SourceView2-0.10/lib/0000755000175000017500000000000011400555300015343 5ustar emmanuelemmanuelGtk2-SourceView2-0.10/lib/Gtk2/0000755000175000017500000000000011400555300016152 5ustar emmanuelemmanuelGtk2-SourceView2-0.10/lib/Gtk2/SourceView2.pm0000644000175000017500000000402711377543344020712 0ustar emmanuelemmanuelpackage Gtk2::SourceView2; =head1 NAME Gtk2::SourceView2 - Enhanced source code editor widget =head1 SYNOPSIS use Glib qw(TRUE FALSE); use Gtk2 '-init'; use Gtk2::SourceView2; my $window = Gtk2::Window->new(); my $view = Gtk2::SourceView2->new(); $window->add($view); $window->set_size_request(480, 120); $window->show_all(); $window->signal_connect(delete_event => sub { Gtk2->main_quit(); return TRUE; }); Gtk2->main(); =head1 DESCRIPTION Gtk2::SourceView2 is the Perl binding for the C library gtksourceview-2.0. This is the same widget that's used by gedit, MonoDevelop, Anjuta and several other projects. This widget extends the standard GTK+ framework for multiline text editing with support for configurable syntax highlighting, unlimited undo/redo, UTF-8 compliant caseless searching, printing and other features typical of a source code editor. For more information about gtksourceview-2.0 see: L. =head1 AUTHORS Emmanuel Rodriguez Epotyl@cpan.orgE. =head1 COPYRIGHT AND LICENSE Copyright (c) 2009-2010 by Emmanuel Rodriguez (see the file AUTHORS) This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version; or the Artistic License, version 2.0. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details; or the Artistic License. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA. =cut use warnings; use strict; use base 'DynaLoader'; use Gtk2; our $VERSION = '0.10'; sub dl_load_flags { $^O eq 'darwin' ? 0x00 : 0x01 } __PACKAGE__->bootstrap($VERSION); 1; Gtk2-SourceView2-0.10/Changes0000644000175000017500000000205311400555113016072 0ustar emmanuelemmanuelRevision history for Gtk2::SourceView2. 0.10 Sun May 30 23:35:52 CEST 2010 Unit tests now work with Test::Simple 0.95_02. Unit test compatible with gtksourceview 2.10.2 (view most be in a parent). 0.09 Tue Apr 27 20:11:56 CEST 2010 Fix the license in Makefile.PL. 0.08 Mon Apr 26 22:11:27 CEST 2010 License change to GPL2 and Artistic. Remove the dependency to File::Slurp in the example. 0.07 Fri Mar 19 21:12:08 CET 2010 Issue 2 - configure requires missing test failure. 0.06 Fri Jan 29 12:56:44 CET 2010 Issue 1 - test failure non-English locale (reopen). 0.05 Sat Nov 21 08:56:04 CET 2009 Issue 1 - test failure non-English locale. 0.04 Sat Nov 14 19:42:51 CET 2009 Fix a warning in the examples when pasting text with the keyboard. 0.03 Sun Nov 8 14:23:48 CET 2009 More complete example. Remove a TODO. 0.02 Sat Oct 31 09:22:17 CET 2009 Add the bindings for Gtk2::SourceView2::Iter. LanguageManager->guess_language() last argument is optional. Fix a typo in the module's documentation. 0.01 Thu Oct 29 21:33:41 CET 2009 First release. Gtk2-SourceView2-0.10/META.yml0000644000175000017500000000130511400555301016046 0ustar emmanuelemmanuel--- #YAML:1.0 name: Gtk2-SourceView2 version: 0.10 abstract: Enhanced source code editor widget author: - Emmanuel Rodriguez license: perl, gpl distribution_type: module configure_requires: ExtUtils::Depends: 0 ExtUtils::PkgConfig: 0 Glib::MakeHelper: 0 Gtk2::CodeGen: 0 build_requires: ExtUtils::MakeMaker: 0 requires: Gtk2: 1.160 no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.55_02 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 repository: http://github.com/potyl/gtk2-sourceview2 Gtk2-SourceView2-0.10/README0000644000175000017500000000335011374060746015475 0ustar emmanuelemmanuelGtk2::SourceView2 ================= Perl bindings for the C library "libgtksourceview2" that extends the standard GTK+ framework for multiline text editing with support for configurable syntax highlighting, unlimited undo/redo, UTF-8 compliant caseless searching, printing and other features typical of a source code editor. For more information about libgtksourceview2 refer to the library's web site: http://projects.gnome.org/gtksourceview/ INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test make install SUPPORT AND DOCUMENTATION After installing you can find documentation for this module with the perldoc command. perldoc Gtk2::SourceView2 Also feel free to take a look at the examples in the folder "examples/" and to play around with them. For any kind of help or support, simply send a mail to the gtk-perl mailing list (gtk-perl-list@gnome.org) or join us in the IRC channel #gtk-perl on irc.gnome.org. COPYRIGHT AND LICENCE Copyright (C) 2009 Emmanuel Rodriguez This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version; or the Artistic License, version 2.0. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA. Gtk2-SourceView2-0.10/maps0000644000175000017500000000240011374060746015473 0ustar emmanuelemmanuelGTK_TYPE_SOURCE_VIEW GtkSourceView GObject Gtk2::SourceView2::View GTK_TYPE_SOURCE_SEARCH_FLAGS GtkSourceSearchFlags GFlags Gtk2::SourceView2::SearchFlags GTK_TYPE_SOURCE_SMART_HOME_END_TYPE GtkSourceSmartHomeEndType GEnum Gtk2::SourceView2::SmartHomeEndType GTK_TYPE_SOURCE_DRAW_SPACES_FLAGS GtkSourceDrawSpacesFlags GFlags Gtk2::SourceView2::DrawSpacesFlags GTK_TYPE_SOURCE_BUFFER GtkSourceBuffer GObject Gtk2::SourceView2::Buffer GTK_TYPE_SOURCE_LANGUAGE GtkSourceLanguage GObject Gtk2::SourceView2::Language GTK_TYPE_SOURCE_STYLE_SCHEME GtkSourceStyleScheme GObject Gtk2::SourceView2::StyleScheme GTK_TYPE_SOURCE_MARK GtkSourceMark GObject Gtk2::SourceView2::Mark GTK_TYPE_SOURCE_LANGUAGE_MANAGER GtkSourceLanguageManager GObject Gtk2::SourceView2::LanguageManager GTK_TYPE_SOURCE_STYLE GtkSourceStyle GObject Gtk2::SourceView2::Style GTK_TYPE_SOURCE_STYLE_SCHEME_MANAGER GtkSourceStyleSchemeManager GObject Gtk2::SourceView2::StyleSchemeManager GTK_TYPE_SOURCE_PRINT_COMPOSITOR GtkSourcePrintCompositor GObject Gtk2::SourceView2::PrintCompositor Gtk2-SourceView2-0.10/Makefile.PL0000644000175000017500000000503411374060746016570 0ustar emmanuelemmanueluse strict; use warnings; use ExtUtils::MakeMaker; use Cwd; use File::Spec; use Gtk2::CodeGen; use Glib::MakeHelper; use ExtUtils::Depends; use ExtUtils::PkgConfig; my $DEPENDS; my @XS_FILES = (); exit main(); sub main { # Create the build folder used by the code generation utilities mkdir 'build', 0777; my @typemaps = (); my @deps = ('Glib'); my %pkgconfig; # Find gtksourceview 2.0 eval { %pkgconfig = ExtUtils::PkgConfig->find("gtksourceview-2.0"); push @XS_FILES, ; push @typemaps, 'maps'; push @deps, 'Gtk2'; }; if (my $error = $@) { warn "FAIL: ", $error; return; } $DEPENDS = ExtUtils::Depends->new('Gtk2::SourceView2', @deps); $DEPENDS->add_pm( File::Spec->catfile('lib', 'Gtk2', 'SourceView2.pm'), File::Spec->catfile('$(INST_LIBDIR)', 'SourceView2.pm'), ); # Code generation Gtk2::CodeGen->parse_maps('gtk2-sourceview2', input => [ @typemaps ]); Gtk2::CodeGen->write_boot( ignore => qr/^Gtk2::SourceView2$/, xs_files => [ @XS_FILES ], ); $DEPENDS->set_inc($pkgconfig{cflags} . ' -I./build'); $DEPENDS->set_libs($pkgconfig{libs}); $DEPENDS->add_xs(@XS_FILES); $DEPENDS->add_typemaps( File::Spec->catfile(cwd(), 'build', 'gtk2-sourceview2.typemap'), ); $DEPENDS->install( File::Spec->catfile('build', 'gtk2-sourceview2-autogen.h'), 'gtk2-sourceview2-perl.h', ); $DEPENDS->save_config(File::Spec->catfile('build', 'IFiles.pm')); # Create the Makefile WriteMakefile( AUTHOR => 'Emmanuel Rodriguez ', NAME => 'Gtk2::SourceView2', VERSION_FROM => File::Spec->catfile('lib', 'Gtk2', 'SourceView2.pm'), ABSTRACT_FROM => File::Spec->catfile('lib', 'Gtk2', 'SourceView2.pm'), LICENSE => 'perl, gpl', PREREQ_PM => { 'Gtk2' => '1.160', }, CONFIGURE_REQUIRES => { 'Gtk2::CodeGen' => 0, 'Glib::MakeHelper' => 0, 'ExtUtils::Depends' => 0, 'ExtUtils::PkgConfig' => 0, }, PREREQ_FATAL => 1, XSPROTOARG => '-noprototypes', MAN3PODS => { Glib::MakeHelper->do_pod_files(@XS_FILES), }, META_MERGE => { repository => 'http://github.com/potyl/gtk2-sourceview2', }, $DEPENDS->get_makefile_vars(), # Remove the build folder when doing "make clean" clean => { FILES => 'build', }, ); return 0; } sub MY::postamble { my $postamble = Glib::MakeHelper->postamble_clean(); $postamble .= Glib::MakeHelper->postamble_docs_full( DEPENDS => $DEPENDS, XS_FILES => [ @XS_FILES ], COPYRIGHT => 'Copyright (C) 2009 by Emmanuel Rodriguez' ); return $postamble; } Gtk2-SourceView2-0.10/t/0000755000175000017500000000000011400555300015040 5ustar emmanuelemmanuelGtk2-SourceView2-0.10/t/GtkSourceIter.t0000644000175000017500000000634211374060746020003 0ustar emmanuelemmanuel#!/usr/bin/perl use strict; use warnings; use Gtk2::TestHelper tests => 24; use FindBin; use lib "$FindBin::Bin"; use my_helper; use Test::Builder; use Glib qw(TRUE FALSE); use Gtk2::SourceView2; exit tests(); sub tests { test_search(); return 0; } sub test_search { my $buffer = get_buffer(); my @results; my $start = $buffer->get_start_iter; # Forward search from the start @results = Gtk2::SourceView2::Iter->forward_search($start, "Atreus", [ 'text-only' ]); is_text_at( [ @results ], { start_line => 4, start_offset => 43, end_line => 4, end_offset => 49, }, "Forward search" ); # Forward search from the start for a non existing word @results = Gtk2::SourceView2::Iter->forward_search($start, "Homer", [ 'text-only' ]); is_text_at( [ @results ], undef, "Forward search not found" ); # Multi line @results = Gtk2::SourceView2::Iter->forward_search( $start, "a\nprey to Dogs", [ 'text-only', 'case-insensitive' ] ); is_text_at( [ @results ], { start_line => 2, start_offset => 61, end_line => 3, end_offset => 12, }, "Forward search multi-line" ); my $end = $buffer->get_end_iter; # Look backwards for a word that's not there @results = Gtk2::SourceView2::Iter->backward_search($end, "Homer", [ 'text-only' ]); is_text_at( [ @results ], undef, "Backward search not found" ); # Look backwards for a word @results = Gtk2::SourceView2::Iter->backward_search($end, "Achilles", [ ]); is_text_at( [ @results ], { start_line => 5, start_offset => 10, end_line => 5, end_offset => 18, }, "Backward search for Achilles" ); # Look forwards for the same word as before @results = Gtk2::SourceView2::Iter->forward_search($start, "Achilles", [ ]); is_text_at( [ @results ], { start_line => 0, start_offset => 30, end_line => 0, end_offset => 38, }, "Forward search for Achilles" ); } sub is_text_at { my ($iters, $positions, $message) = @_; my ($start, $end) = @{ $iters }; my $tester = Test::Builder->new(); if ($start && $positions) { $tester->is_num($start->get_line, $positions->{start_line}, "$message (start line)"); $tester->is_num($start->get_line_offset, $positions->{start_offset}, "$message (start offset)"); } else { $tester->ok(! defined $start, "Start line for undef"); $tester->ok(! defined $positions, "Start offset for undef"); } if ($end && $positions) { $tester->is_num($end->get_line, $positions->{end_line}, "$message (end line)"); $tester->is_num($end->get_line_offset, $positions->{end_offset}, "$message (end offset)"); } else { $tester->ok(! defined $end, "$message (end line for undef)"); $tester->ok(! defined $positions, "$message (end offset for undef)"); } } sub get_buffer { my $buffer = Gtk2::SourceView2::Buffer->new(undef); $buffer->set_text(<<'__ILLIAD__'); Sing, O goddess, the anger of Achilles son of Peleus, that brought countless ills upon the Achaeans. Many a brave soul did it send hurrying down to Hades, and many a hero did it yield a prey to dogs and vultures, for so were the counsels of Jove fulfilled from the day on which the son of Atreus, king of men, and great Achilles, first fell out with one another. __ILLIAD__ return $buffer; } Gtk2-SourceView2-0.10/t/GtkSourceStyle.t0000644000175000017500000000111011374060746020164 0ustar emmanuelemmanuel#!/usr/bin/perl use strict; use warnings; use Gtk2::TestHelper tests => 2; use FindBin; use lib "$FindBin::Bin"; use my_helper; use Glib qw(TRUE FALSE); use Gtk2::SourceView2; exit tests(); sub tests { test_properties(); return 0; } sub test_properties { my $manager = Gtk2::SourceView2::StyleSchemeManager->get_default(); my ($id) = $manager->get_scheme_ids(); my $scheme = $manager->get_scheme($id); my $style = $scheme->get_style('def:comment'); isa_ok($style, 'Gtk2::SourceView2::Style'); my $copy = $style->copy(); isa_ok($copy, 'Gtk2::SourceView2::Style'); } Gtk2-SourceView2-0.10/t/GtkSourceLanguageManager.t0000644000175000017500000000404611374060746022115 0ustar emmanuelemmanuel#!/usr/bin/perl use strict; use warnings; use Gtk2::TestHelper tests => 17; use FindBin; use lib "$FindBin::Bin"; use my_helper; use Glib qw(TRUE FALSE); use Gtk2::SourceView2; exit tests(); sub tests { test_constructors(); test_properties(); return 0; } sub test_constructors { my $lm; $lm = Gtk2::SourceView2::LanguageManager->new(); isa_ok($lm, 'Gtk2::SourceView2::LanguageManager'); $lm = Gtk2::SourceView2::LanguageManager->get_default(); isa_ok($lm, 'Gtk2::SourceView2::LanguageManager'); } sub test_properties { my $lm = Gtk2::SourceView2::LanguageManager->get_default(); ok(scalar($lm->get_language_ids), "get_language_ids"); # Get language my $language = $lm->get_language('perl'); isa_ok($language, 'Gtk2::SourceView2::Language'); is($language->get_id, 'perl', "Got perl"); $language = $lm->get_language('emo-perl'); is($language, undef, "No such language emo-perl"); # Guess language $language = $lm->guess_language("$FindBin::Bin/my_helper.pm", undef); isa_ok($language, 'Gtk2::SourceView2::Language'); is($language->get_id, 'perl', "Got perl"); $language = $lm->guess_language("sample.c"); isa_ok($language, 'Gtk2::SourceView2::Language'); is($language->get_id, 'c', "Got C"); $language = $lm->guess_language(undef, 'text/x-c'); isa_ok($language, 'Gtk2::SourceView2::Language'); is($language->get_id, 'c', "Got c"); # Take a new LanguageManager an destroy it's search path $lm = Gtk2::SourceView2::LanguageManager->new(); my @path = $lm->get_search_path; ok(scalar(@path) > 0, "original search path has values"); # Clear the search path $lm->set_search_path(); is_deeply( [ $lm->get_search_path ], [ ], "set_search_path() clear" ); $lm->set_search_path('a'); is_deeply( [ $lm->get_search_path ], [ 'a' ], "set_search_path(a)" ); $lm->set_search_path('a', 'b'); is_deeply( [ $lm->get_search_path ], [ 'a', 'b' ], "set_search_path(a, b)" ); # Reset the search path $lm->set_search_path(undef); is_deeply( [ $lm->get_search_path ], [ @path ], "set_search_path(undef) reset" ); } Gtk2-SourceView2-0.10/t/GtkSourceMark.t0000644000175000017500000000353511374060746017773 0ustar emmanuelemmanuel#!/usr/bin/perl use strict; use warnings; use Gtk2::TestHelper tests => 16; use FindBin; use lib "$FindBin::Bin"; use my_helper; use Glib qw(TRUE FALSE); use Gtk2::SourceView2; exit tests(); sub tests { test_constructor(); test_properties(); return 0; } sub test_constructor { my $mark; $mark = Gtk2::SourceView2::Mark->new(undef, 'test'); isa_ok($mark, 'Gtk2::SourceView2::Mark'); $mark = Gtk2::SourceView2::Mark->new('named', 'test'); isa_ok($mark, 'Gtk2::SourceView2::Mark'); } sub test_properties { my $mark = Gtk2::SourceView2::Mark->new(undef, 'test'); is($mark->next(undef), undef, "no next from a mark without buffer"); is($mark->next('test'), undef, "no next('test') from a mark without buffer"); is($mark->next('test2'), undef, "no next('test2') from a mark without buffer"); is($mark->prev(undef), undef, "no prev from a mark without buffer"); is($mark->prev('test'), undef, "no prev('test') from a mark without buffer"); is($mark->prev('test2'), undef, "no prev('test2') from a mark without buffer"); is($mark->get_category, 'test', "get_category"); my $buffer = Gtk2::SourceView2::Buffer->new(undef); $buffer->set_text("Jumps over a green sheep"); my $iter1 = $buffer->get_iter_at_offset(6); my $iter2 = $buffer->get_iter_at_offset(12); my $iter3 = $buffer->get_iter_at_offset(18); my $mark1 = $buffer->create_source_mark('m1', 'word', $iter1); my $mark2 = $buffer->create_source_mark('m2', 'mark', $iter2); my $mark3 = $buffer->create_source_mark('m3', 'word', $iter3); is($mark1->get_category, 'word', "get_category"); is($mark2->get_category, 'mark', "get_category"); is($mark3->get_category, 'word', "get_category"); is($mark1->next(undef), $mark2, "next(undef)"); is($mark1->next('word'), $mark3, "next('word')"); is($mark3->prev(undef), $mark2, "prev(undef)"); is($mark3->prev('word'), $mark1, "prev('word')"); } Gtk2-SourceView2-0.10/t/GtkSourceBuffer.t0000644000175000017500000000766511374060746020322 0ustar emmanuelemmanuel#!/usr/bin/perl use strict; use warnings; use Gtk2::TestHelper tests => 25; use FindBin; use lib "$FindBin::Bin"; use my_helper; use Glib qw(TRUE FALSE); use Gtk2::SourceView2; exit tests(); sub tests { test_constructors(); test_properties(); return 0; } sub test_constructors { my $buffer; $buffer = Gtk2::SourceView2::Buffer->new(undef); isa_ok($buffer, 'Gtk2::SourceView2::Buffer'); my $table = Gtk2::TextTagTable->new(); $buffer = Gtk2::SourceView2::Buffer->new($table); isa_ok($buffer, 'Gtk2::SourceView2::Buffer'); my $lm = Gtk2::SourceView2::LanguageManager->get_default(); my $language = $lm->get_language('perl'); $buffer = Gtk2::SourceView2::Buffer->new_with_language($language); isa_ok($buffer, 'Gtk2::SourceView2::Buffer'); } sub test_properties { my $buffer = Gtk2::SourceView2::Buffer->new(undef); $buffer->set_text("The lazy grey fox"); is_buffer_text($buffer, "The lazy grey fox", "text 1"); is_boolean_ok($buffer, 'highlight_syntax'); is_boolean_ok($buffer, 'highlight_matching_brackets'); is_int_ok($buffer, 'max_undo_levels', 40, 60); my $language = Gtk2::SourceView2::LanguageManager->get_default->get_language('perl'); $buffer->set_language($language); is($buffer->get_language, $language, "set_language"); $buffer->set_language(undef); is($buffer->get_language, undef, "set_language(undef)"); my $scheme = Gtk2::SourceView2::StyleSchemeManager->get_default->get_scheme('classic'); $buffer->set_style_scheme($scheme); is($buffer->get_style_scheme, $scheme, "set_style_scheme"); ok($buffer->can_undo, "can_undo"); $buffer->undo(); is_buffer_text($buffer, "", "text undo"); ok($buffer->can_redo, "can_redo"); $buffer->redo(); is_buffer_text($buffer, "The lazy grey fox", "redo"); # Undoable action $buffer->begin_not_undoable_action(); $buffer->set_text("Jumps over a green sheep"); $buffer->end_not_undoable_action(); is_buffer_text($buffer, "Jumps over a green sheep", "undoable action"); ok(! $buffer->can_undo, "can't undo after an undoable action "); # Mark my $iter1 = $buffer->get_iter_at_offset(6); my $iter2 = $buffer->get_iter_at_offset(12); my $iter3 = $buffer->get_iter_at_offset(18); my $mark1 = $buffer->create_source_mark('word1', 'marks', $iter1); isa_ok($mark1, 'Gtk2::SourceView2::Mark'); my $mark2 = $buffer->create_source_mark('word2', 'mark2', $iter2); my $mark3 = $buffer->create_source_mark(undef, 'mark3', $iter3); my $iter = $buffer->get_start_iter; is($iter->get_offset, 0, "iter at offset 0"); # Move forward $buffer->forward_iter_to_source_mark($iter, 'mark2'); is($iter->get_offset, $iter2->get_offset, "iter at offset of iter2"); $buffer->forward_iter_to_source_mark($iter, undef); is($iter->get_offset, $iter3->get_offset, "iter at offset of iter3"); # Move backward $buffer->backward_iter_to_source_mark($iter, 'mark2'); is($iter->get_offset, $iter2->get_offset, "iter at offset of iter2"); $buffer->backward_iter_to_source_mark($iter, undef); is($iter->get_offset, $iter1->get_offset, "iter at offset of iter1"); # Get marks at (iter, line) my $mark_twice = $buffer->create_source_mark('bugs', 'duplicate', $iter2); my @marks = $buffer->get_source_marks_at_iter($iter2, undef); is_deeply( [ sort @marks ], [ sort $mark2, $mark_twice], "get_source_marks_at_iter" ); @marks = $buffer->get_source_marks_at_line(0, undef); is_deeply( [ sort @marks ], [ sort $mark1, $mark2, $mark3, $mark_twice ], "get_source_marks_at_line" ); $buffer->remove_source_marks($buffer->get_start_iter, $buffer->get_end_iter, undef); @marks = $buffer->get_source_marks_at_line(0, undef); is_deeply(\@marks, [], "remove_source_marks"); $buffer->ensure_highlight($buffer->get_start_iter, $buffer->get_end_iter); } sub is_buffer_text { my ($buffer, $wanted, $message) = @_; my $start = $buffer->get_start_iter; my $end = $buffer->get_end_iter; my $text = $buffer->get_text($start, $end, TRUE); my $tester = Test::Builder->new(); $tester->is_eq($text, $wanted, $message); } Gtk2-SourceView2-0.10/t/GtkSourceStyleScheme.t0000644000175000017500000000155311374060746021324 0ustar emmanuelemmanuel#!/usr/bin/perl use strict; use warnings; use Gtk2::TestHelper tests => 8; use FindBin; use lib "$FindBin::Bin"; use my_helper; use Glib qw(TRUE FALSE); use Gtk2::SourceView2; exit tests(); sub tests { test_properties(); return 0; } sub test_properties { my $manager = Gtk2::SourceView2::StyleSchemeManager->get_default(); my $scheme = $manager->get_scheme('classic'); isa_ok($scheme, 'Gtk2::SourceView2::StyleScheme'); is($scheme->get_id, 'classic', "get_id"); ok($scheme->get_name, "get_name"); ok($scheme->get_description, "get_description"); ok($scheme->get_filename =~ m(/classic\.xml), "get_filename"); is_deeply( [ $scheme->get_authors ], [ 'GtkSourceView team' ], "get_id" ); isa_ok($scheme->get_style('def:comment'), 'Gtk2::SourceView2::Style', "get_style"); is($scheme->get_style('do-no-exist'), undef, "get_style, doesn't exist"); } Gtk2-SourceView2-0.10/t/GtkSourceView.t0000644000175000017500000000421011400554641017772 0ustar emmanuelemmanuel#!/usr/bin/perl use strict; use warnings; use Gtk2::TestHelper tests => 18; use FindBin; use lib "$FindBin::Bin"; use my_helper; use Glib qw(TRUE FALSE); use Gtk2::SourceView2; exit tests(); sub tests { test_constructors(); test_properties(); return 0; } sub test_constructors { my $parent = Gtk2::HBox->new(); my $view = Gtk2::SourceView2::View->new(); $parent->add($view); isa_ok($view, 'Gtk2::SourceView2::View'); my $buffer = Gtk2::SourceView2::Buffer->new(undef); $view = Gtk2::SourceView2::View->new_with_buffer($buffer); $parent->add($view); isa_ok($view, 'Gtk2::SourceView2::View'); } sub test_properties { my $parent = Gtk2::HBox->new(); my $view = Gtk2::SourceView2::View->new(); $parent->add($view); is_int_ok($view, 'tab_width', 4, 6); is_int_ok($view, 'indent_width', 4, 6); is_int_ok($view, 'right_margin_position', 4, 6); is_boolean_ok($view, 'show_line_numbers'); is_boolean_ok($view, 'auto_indent'); is_boolean_ok($view, 'insert_spaces_instead_of_tabs'); is_boolean_ok($view, 'indent_on_tab'); is_boolean_ok($view, 'highlight_current_line'); is_boolean_ok($view, 'show_right_margin'); is_boolean_ok($view, 'show_line_marks'); is_enum_ok($view, 'smart_home_end', 'before', 'after'); # Draw spaces $view->set_draw_spaces(['space', 'tab']); # Test::Simple 0.95 no longer stringifies its arguments before comparing is('' . $view->get_draw_spaces, '[ space tab ]', "draw_spaces"); # Mark category (pixbuf, priority, background) my $pixbuf = Gtk2::Gdk::Pixbuf->new("rgb", FALSE, 8, 10, 10); $view->set_mark_category_pixbuf(test => $pixbuf); is( $view->get_mark_category_pixbuf('test'), $pixbuf, "mark_category_pixbuf" ); $view->set_mark_category_pixbuf(test => undef); is( $view->get_mark_category_pixbuf('test'), undef, "mark_category_pixbuf undef" ); $view->set_mark_category_priority(test => 15); is( $view->get_mark_category_priority('test'), 15, "mark_category_priority" ); my $color = Gtk2::Gdk::Color->new(65535, 0, 0); $view->set_mark_category_background(test => $color); is( $view->get_mark_category_background('test')->pixel, $color->pixel, "mark_category_background" ); } Gtk2-SourceView2-0.10/t/GtkSourceLanguage.t0000644000175000017500000000222611374060746020620 0ustar emmanuelemmanuel#!/usr/bin/perl use strict; use warnings; use Gtk2::TestHelper tests => 12; use FindBin; use lib "$FindBin::Bin"; use my_helper; use Glib qw(TRUE FALSE); use Gtk2::SourceView2; exit tests(); sub tests { test_properties(); return 0; } sub test_properties { my $lm = Gtk2::SourceView2::LanguageManager->get_default(); isa_ok($lm, 'Gtk2::SourceView2::LanguageManager'); my $language = $lm->get_language('perl'); isa_ok($language, 'Gtk2::SourceView2::Language'); is($language->get_id, 'perl', "get_id"); is($language->get_name, 'Perl', "get_name"); ok($language->get_section, "get_section"); is($language->get_hidden, FALSE, "get_hidden"); is($language->get_metadata('line-comment-start'), '#', "get_metadata"); is($language->get_metadata('doest-no-exist'), undef, "get_metadata undef"); is($language->get_style_name('perl:pod'), 'POD', "get_style_name"); is_deeply( [ sort $language->get_mime_types ], [ sort ('text/x-perl', 'application/x-perl') ], "get_mime_types" ); is_deeply( [ sort $language->get_globs ], [ sort ('*.pl', '*.pm', '*.al', '*.perl') ], "get_globs" ); ok(scalar($language->get_style_ids), "get_style_ids"); } Gtk2-SourceView2-0.10/t/my_helper.pm0000644000175000017500000000230011374060746017374 0ustar emmanuelemmanuel#!/usr/bin/perl use strict; use warnings; use Test::Builder; # # Check if an enum property can be set # sub is_enum_ok { # In Perl enums are like strings! return is_string_ok(@_); } # # Check if an string property can be set # sub is_string_ok { my ($view, $property, $val1, $val2) = @_; my $get = "get_$property"; my $set = "set_$property"; my $value = $view->$get(); my ($new_value) = ($value eq $val1 ? $val2 : $val1); $view->$set($new_value); my $tester = Test::Builder->new(); $tester->is_eq($view->$get(), $new_value, $property); } # # Check if an int property can be set # sub is_int_ok { my ($view, $property, $val1, $val2) = @_; my $get = "get_$property"; my $set = "set_$property"; my $value = $view->$get(); my ($new_value) = ($value == $val1 ? $val2 : $val1); $view->$set($new_value); my $tester = Test::Builder->new(); $tester->is_num($view->$get(), $new_value, $property); } # # Check if a boolean property can be set # sub is_boolean_ok { my ($view, $property) = @_; my $get = "get_$property"; my $set = "set_$property"; my $value = $view->$get(); $view->$set(! $value); my $tester = Test::Builder->new(); $tester->is_eq($view->$get(), ! $value, $property); } 1; Gtk2-SourceView2-0.10/t/GtkSourcePrintCompositor.t0000644000175000017500000000453011400553633022240 0ustar emmanuelemmanuel#!/usr/bin/perl use strict; use warnings; use Gtk2::TestHelper tests => 20; use FindBin; use lib "$FindBin::Bin"; use my_helper; use Glib qw(TRUE FALSE); use Gtk2::SourceView2; exit tests(); sub tests { test_constructors(); test_properties(); return 0; } sub test_constructors { my $print; $print = Gtk2::SourceView2::PrintCompositor->new( Gtk2::SourceView2::Buffer->new(undef) ); isa_ok($print, 'Gtk2::SourceView2::PrintCompositor'); my $window = Gtk2::Window->new(); my $view = Gtk2::SourceView2::View->new(); $window->add($view); $print = Gtk2::SourceView2::PrintCompositor->new_from_view($view); isa_ok($print, 'Gtk2::SourceView2::PrintCompositor'); } sub test_properties { my $print = Gtk2::SourceView2::PrintCompositor->new( Gtk2::SourceView2::Buffer->new(undef) ); isa_ok($print, 'Gtk2::SourceView2::PrintCompositor'); isa_ok($print->get_buffer, 'Gtk2::SourceView2::Buffer'); is_int_ok($print, 'tab_width', 4, 6); is_enum_ok($print, 'wrap_mode', 'word', 'char'); is_boolean_ok($print, 'highlight_syntax'); is_int_ok($print, 'print_line_numbers', 5, 10); is_string_ok($print, 'body_font_name', "Sans 10", "Sans 12"); is_string_ok($print, 'line_numbers_font_name', "Sans 10", "Sans 12"); is_string_ok($print, 'header_font_name', "Sans 10", "Sans 12"); is_string_ok($print, 'footer_font_name', "Sans 10", "Sans 12"); is_unit_ok($print, 'top_margin', 10, 20, 'mm'); is_unit_ok($print, 'bottom_margin', 10, 20, 'inch'); is_unit_ok($print, 'left_margin', 10, 20, 'points'); is_unit_ok($print, 'right_margin', 10, 20, 'mm'); is_boolean_ok($print, 'print_header'); is_boolean_ok($print, 'print_footer'); is($print->get_n_pages, -1, "get_n_pages"); is($print->get_pagination_progress, 0, "get_pagination_progress"); # Can't be tested but at least we try them $print->set_header_format(TRUE, "hello", "world", "!"); $print->set_header_format(TRUE, undef, undef, undef); $print->set_footer_format(TRUE, "perl", "gtk2", "sourceview"); $print->set_footer_format(TRUE, undef, undef, undef); } sub is_unit_ok { my ($view, $property, $val1, $val2, $unit) = @_; my $get = "get_$property"; my $set = "set_$property"; my $value = $view->$get($unit); my ($new_value) = ($value eq $val1 ? $val2 : $val1); $view->$set($new_value, $unit); my $tester = Test::Builder->new(); $tester->is_eq($view->$get($unit), $new_value, $property); } Gtk2-SourceView2-0.10/t/GtkSourceStyleSchemeManager.t0000644000175000017500000000317311374060746022617 0ustar emmanuelemmanuel#!/usr/bin/perl use strict; use warnings; use Gtk2::TestHelper tests => 10; use FindBin; use lib "$FindBin::Bin"; use my_helper; use Glib qw(TRUE FALSE); use Gtk2::SourceView2; exit tests(); sub tests { test_constructors(); test_properties(); return 0; } sub test_constructors { my $manager; $manager = Gtk2::SourceView2::StyleSchemeManager->new(); isa_ok($manager, 'Gtk2::SourceView2::StyleSchemeManager'); $manager = Gtk2::SourceView2::StyleSchemeManager->get_default(); isa_ok($manager, 'Gtk2::SourceView2::StyleSchemeManager'); } sub test_properties { my $manager = Gtk2::SourceView2::StyleSchemeManager->get_default(); ok(scalar($manager->get_scheme_ids), "get_scheme_ids"); my @path = $manager->get_search_path; ok(scalar(@path), "get_search_path"); my ($scheme_id) = $manager->get_scheme_ids; my $scheme = $manager->get_scheme($scheme_id); isa_ok($scheme, 'Gtk2::SourceView2::StyleScheme'); # Clear the search path $manager->set_search_path(); is_deeply( [ $manager->get_search_path ], [ ], "set_search_path() clear" ); $manager->set_search_path('a', 'b'); is_deeply( [ $manager->get_search_path ], [ 'a', 'b' ], "set_search_path(a, b)" ); $manager->append_search_path('c'); is_deeply( [ $manager->get_search_path ], [ 'a', 'b', 'c' ], "append_search_path(c)" ); $manager->prepend_search_path('0'); is_deeply( [ $manager->get_search_path ], [ 0, 'a', 'b', 'c' ], "prepend_search_path(0)" ); # Reset the search path $manager->set_search_path(undef); is_deeply( [ $manager->get_search_path ], [ @path ], "set_search_path(undef) reset" ); $manager->force_rescan(); } Gtk2-SourceView2-0.10/gtk2-sourceview2-perl.h0000644000175000017500000000334211374060746021051 0ustar emmanuelemmanuel#ifndef _SOURCEVIEW2_PERL_H_ #define _SOURCEVIEW2_PERL_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include "gtk2-sourceview2-autogen.h" /** * Returns a gchar** in the stack. */ #define sourceview2perl_return_strv(func, free) \ do {\ gchar **list = (gchar **) func; \ if (list == NULL) { \ XSRETURN_EMPTY; \ } \ else { \ size_t i = 0; \ for (; list[i] != NULL ; ++i) { \ SV *sv = newSVGChar(list[i]); \ XPUSHs(sv_2mortal(sv)); \ } \ } \ if (free) g_strfreev(list); \ } while (FALSE) /** * Generic function that acts as a setter for a property that's a string list. * This is the case for functions that accept a list of paths (strings). */ #define sourceview2perl_generic_set_dirs(func, arg) \ do {\ gchar **dirs = NULL; \ size_t count = items - 1; \ size_t i = 0; \ \ if (count > 0) { \ if (count == 1 && !SvOK(ST(1))) { \ /* Reset the values to the original list */ \ dirs = NULL; \ } \ else { \ dirs = g_new0(gchar *, items); \ for (i = 0; i < count; ++i) { \ dirs[i] = SvGChar(ST(i + 1)); \ } \ } \ } \ else { \ /* Clear the current list */ \ dirs = g_new0(gchar *, 1); \ dirs[1] = NULL; \ } \ \ func(arg, dirs); \ g_free(dirs); \ } while (FALSE) #endif /* _SOURCEVIEW2_PERL_H_ */ Gtk2-SourceView2-0.10/xs/0000755000175000017500000000000011400555300015227 5ustar emmanuelemmanuelGtk2-SourceView2-0.10/xs/GtkSourceMark.xs0000644000175000017500000000254211374060746020346 0ustar emmanuelemmanuel/* * Copyright (c) 2009-2010 by Emmanuel Rodriguez (see the file AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version; or the * Artistic License, version 2.0. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details; or the Artistic License. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307 USA. */ #include "gtk2-sourceview2-perl.h" MODULE = Gtk2::SourceView2::Mark PACKAGE = Gtk2::SourceView2::Mark PREFIX = gtk_source_mark_ GtkSourceMark* gtk_source_mark_new (class, const gchar_ornull *name, const gchar *category) C_ARGS: name, category const gchar* gtk_source_mark_get_category (GtkSourceMark *mark) GtkSourceMark_ornull* gtk_source_mark_next (GtkSourceMark *mark, const gchar_ornull *category) GtkSourceMark_ornull* gtk_source_mark_prev (GtkSourceMark *mark, const gchar_ornull *category) Gtk2-SourceView2-0.10/xs/GtkSourcePrintCompositor.xs0000644000175000017500000001206711374060746022632 0ustar emmanuelemmanuel/* * Copyright (c) 2009-2010 by Emmanuel Rodriguez (see the file AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version; or the * Artistic License, version 2.0. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details; or the Artistic License. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307 USA. */ #include "gtk2-sourceview2-perl.h" MODULE = Gtk2::SourceView2::PrintCompositor PACKAGE = Gtk2::SourceView2::PrintCompositor PREFIX = gtk_source_print_compositor_ GtkSourcePrintCompositor* gtk_source_print_compositor_new (class, GtkSourceBuffer *buffer) C_ARGS: buffer GtkSourcePrintCompositor* gtk_source_print_compositor_new_from_view (class, GtkSourceView *view) C_ARGS: view GtkSourceBuffer* gtk_source_print_compositor_get_buffer (GtkSourcePrintCompositor *compositor) void gtk_source_print_compositor_set_tab_width (GtkSourcePrintCompositor *compositor, guint width) guint gtk_source_print_compositor_get_tab_width (GtkSourcePrintCompositor *compositor) void gtk_source_print_compositor_set_wrap_mode (GtkSourcePrintCompositor *compositor, GtkWrapMode wrap_mode) GtkWrapMode gtk_source_print_compositor_get_wrap_mode (GtkSourcePrintCompositor *compositor) void gtk_source_print_compositor_set_highlight_syntax (GtkSourcePrintCompositor *compositor, gboolean highlight) gboolean gtk_source_print_compositor_get_highlight_syntax (GtkSourcePrintCompositor *compositor) void gtk_source_print_compositor_set_print_line_numbers (GtkSourcePrintCompositor *compositor, guint interval) guint gtk_source_print_compositor_get_print_line_numbers (GtkSourcePrintCompositor *compositor) void gtk_source_print_compositor_set_body_font_name (GtkSourcePrintCompositor *compositor, const gchar *font_name) gchar* gtk_source_print_compositor_get_body_font_name (GtkSourcePrintCompositor *compositor) void gtk_source_print_compositor_set_line_numbers_font_name (GtkSourcePrintCompositor *compositor, const gchar_ornull *font_name) gchar* gtk_source_print_compositor_get_line_numbers_font_name (GtkSourcePrintCompositor *compositor) void gtk_source_print_compositor_set_header_font_name (GtkSourcePrintCompositor *compositor, const gchar_ornull *font_name) gchar* gtk_source_print_compositor_get_header_font_name (GtkSourcePrintCompositor *compositor) void gtk_source_print_compositor_set_footer_font_name (GtkSourcePrintCompositor *compositor, const gchar_ornull *font_name) gchar* gtk_source_print_compositor_get_footer_font_name (GtkSourcePrintCompositor *compositor) gdouble gtk_source_print_compositor_get_top_margin (GtkSourcePrintCompositor *compositor, GtkUnit unit) void gtk_source_print_compositor_set_top_margin (GtkSourcePrintCompositor *compositor, gdouble margin, GtkUnit unit) gdouble gtk_source_print_compositor_get_bottom_margin (GtkSourcePrintCompositor *compositor, GtkUnit unit) void gtk_source_print_compositor_set_bottom_margin (GtkSourcePrintCompositor *compositor, gdouble margin, GtkUnit unit) gdouble gtk_source_print_compositor_get_left_margin (GtkSourcePrintCompositor *compositor, GtkUnit unit) void gtk_source_print_compositor_set_left_margin (GtkSourcePrintCompositor *compositor, gdouble margin, GtkUnit unit) gdouble gtk_source_print_compositor_get_right_margin (GtkSourcePrintCompositor *compositor, GtkUnit unit) void gtk_source_print_compositor_set_right_margin (GtkSourcePrintCompositor *compositor, gdouble margin, GtkUnit unit) void gtk_source_print_compositor_set_print_header (GtkSourcePrintCompositor *compositor, gboolean print) gboolean gtk_source_print_compositor_get_print_header (GtkSourcePrintCompositor *compositor) void gtk_source_print_compositor_set_print_footer (GtkSourcePrintCompositor *compositor, gboolean print) gboolean gtk_source_print_compositor_get_print_footer (GtkSourcePrintCompositor *compositor) void gtk_source_print_compositor_set_header_format (GtkSourcePrintCompositor *compositor, gboolean separator, const gchar_ornull *left, const gchar_ornull *center, const gchar_ornull *right) void gtk_source_print_compositor_set_footer_format (GtkSourcePrintCompositor *compositor, gboolean separator, const gchar_ornull *left, const gchar_ornull *center, const gchar_ornull *right) gint gtk_source_print_compositor_get_n_pages (GtkSourcePrintCompositor *compositor) gboolean gtk_source_print_compositor_paginate (GtkSourcePrintCompositor *compositor, GtkPrintContext *context) gdouble gtk_source_print_compositor_get_pagination_progress (GtkSourcePrintCompositor *compositor) void gtk_source_print_compositor_draw_page (GtkSourcePrintCompositor *compositor, GtkPrintContext *context, gint page_nr) Gtk2-SourceView2-0.10/xs/GtkSourceStyle.xs0000644000175000017500000000205311374060746020551 0ustar emmanuelemmanuel/* * Copyright (c) 2009-2010 by Emmanuel Rodriguez (see the file AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version; or the * Artistic License, version 2.0. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details; or the Artistic License. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307 USA. */ #include "gtk2-sourceview2-perl.h" MODULE = Gtk2::SourceView2::Style PACKAGE = Gtk2::SourceView2::Style PREFIX = gtk_source_style_ GtkSourceStyle* gtk_source_style_copy (GtkSourceStyle *style) Gtk2-SourceView2-0.10/xs/GtkSourceView.xs0000644000175000017500000000735511400002511020345 0ustar emmanuelemmanuel/* * Copyright (c) 2009-2010 by Emmanuel Rodriguez (see the file AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version; or the * Artistic License, version 2.0. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details; or the Artistic License. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307 USA. */ #include "gtk2-sourceview2-perl.h" MODULE = Gtk2::SourceView2::View PACKAGE = Gtk2::SourceView2::View PREFIX = gtk_source_view_ GtkWidget* gtk_source_view_new (class) C_ARGS: /* No args */ GtkWidget* gtk_source_view_new_with_buffer (class, GtkSourceBuffer *buffer) C_ARGS: buffer void gtk_source_view_set_show_line_numbers (GtkSourceView *view, gboolean show) gboolean gtk_source_view_get_show_line_numbers (GtkSourceView *view) void gtk_source_view_set_tab_width (GtkSourceView *view, guint width) guint gtk_source_view_get_tab_width (GtkSourceView *view) void gtk_source_view_set_indent_width (GtkSourceView *view, gint width) gint gtk_source_view_get_indent_width (GtkSourceView *view) void gtk_source_view_set_auto_indent (GtkSourceView *view, gboolean enable) gboolean gtk_source_view_get_auto_indent (GtkSourceView *view) void gtk_source_view_set_insert_spaces_instead_of_tabs (GtkSourceView *view, gboolean enable) gboolean gtk_source_view_get_insert_spaces_instead_of_tabs (GtkSourceView *view) void gtk_source_view_set_indent_on_tab (GtkSourceView *view, gboolean enable) gboolean gtk_source_view_get_indent_on_tab (GtkSourceView *view) void gtk_source_view_set_highlight_current_line (GtkSourceView *view, gboolean show) gboolean gtk_source_view_get_highlight_current_line (GtkSourceView *view) void gtk_source_view_set_show_right_margin (GtkSourceView *view, gboolean show) gboolean gtk_source_view_get_show_right_margin (GtkSourceView *view) void gtk_source_view_set_right_margin_position (GtkSourceView *view, guint pos) guint gtk_source_view_get_right_margin_position (GtkSourceView *view) void gtk_source_view_set_show_line_marks (GtkSourceView *view, gboolean show) gboolean gtk_source_view_get_show_line_marks (GtkSourceView *view) void gtk_source_view_set_mark_category_pixbuf (GtkSourceView *view, const gchar *category, GdkPixbuf_ornull *pixbuf) GdkPixbuf_ornull* gtk_source_view_get_mark_category_pixbuf (GtkSourceView *view, const gchar *category) void gtk_source_view_set_mark_category_background (GtkSourceView *view, const gchar *category, const GdkColor_ornull *color) GdkColor_copy* gtk_source_view_get_mark_category_background (GtkSourceView *view, const gchar *category) PREINIT: GdkColor color; CODE: gtk_source_view_get_mark_category_background(view, category, &color); RETVAL = &color; OUTPUT: RETVAL void gtk_source_view_set_mark_category_priority (GtkSourceView *view, const gchar *category, gint priority) gint gtk_source_view_get_mark_category_priority (GtkSourceView *view, const gchar *category) void gtk_source_view_set_smart_home_end (GtkSourceView *view, GtkSourceSmartHomeEndType smart_he) GtkSourceSmartHomeEndType gtk_source_view_get_smart_home_end (GtkSourceView *view) void gtk_source_view_set_draw_spaces (GtkSourceView *view, GtkSourceDrawSpacesFlags flags) GtkSourceDrawSpacesFlags gtk_source_view_get_draw_spaces (GtkSourceView *view) Gtk2-SourceView2-0.10/xs/GtkSourceStyleScheme.xs0000644000175000017500000000314611374060746021702 0ustar emmanuelemmanuel/* * Copyright (c) 2009-2010 by Emmanuel Rodriguez (see the file AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version; or the * Artistic License, version 2.0. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details; or the Artistic License. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307 USA. */ #include "gtk2-sourceview2-perl.h" MODULE = Gtk2::SourceView2::StyleScheme PACKAGE = Gtk2::SourceView2::StyleScheme PREFIX = gtk_source_style_scheme_ const gchar* gtk_source_style_scheme_get_id (GtkSourceStyleScheme *style) const gchar* gtk_source_style_scheme_get_name (GtkSourceStyleScheme *style) const gchar_ornull* gtk_source_style_scheme_get_description (GtkSourceStyleScheme *style) const gchar_ornull* gtk_source_style_scheme_get_filename (GtkSourceStyleScheme *style) GtkSourceStyle_ornull* gtk_source_style_scheme_get_style (GtkSourceStyleScheme *style, const gchar *style_id) void gtk_source_style_scheme_get_authors (GtkSourceStyleScheme *style) PPCODE: sourceview2perl_return_strv( gtk_source_style_scheme_get_authors(style), FALSE ); Gtk2-SourceView2-0.10/xs/GtkSourceViewBoot.xs0000644000175000017500000000202011374060746021201 0ustar emmanuelemmanuel/* * Copyright (c) 2009-2010 by Emmanuel Rodriguez (see the file AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version; or the * Artistic License, version 2.0. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details; or the Artistic License. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307 USA. */ #include "gtk2-sourceview2-perl.h" MODULE = Gtk2::SourceView2 PACKAGE = Gtk2::SourceView2 PREFIX = gtk_source_view_ BOOT: #include "register.xsh" #include "boot.xsh" Gtk2-SourceView2-0.10/xs/GtkSourceStyleSchemeManager.xs0000644000175000017500000000476711374060746023207 0ustar emmanuelemmanuel/* * Copyright (c) 2009-2010 by Emmanuel Rodriguez (see the file AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version; or the * Artistic License, version 2.0. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details; or the Artistic License. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307 USA. */ #include "gtk2-sourceview2-perl.h" MODULE = Gtk2::SourceView2::StyleSchemeManager PACKAGE = Gtk2::SourceView2::StyleSchemeManager PREFIX = gtk_source_style_scheme_manager_ GtkSourceStyleSchemeManager* gtk_source_style_scheme_manager_new (class) C_ARGS: /* No args */ GtkSourceStyleSchemeManager* gtk_source_style_scheme_manager_get_default (class) C_ARGS: /* No args */ =for apidoc Sets the list of directories where the manager looks for style scheme files. If no dirs are given (empty list) then the search path is cleared, if C is passed then the search path is reset to default. =cut void gtk_source_style_scheme_manager_set_search_path (GtkSourceStyleSchemeManager *manager, ...) CODE: sourceview2perl_generic_set_dirs( gtk_source_style_scheme_manager_set_search_path, manager ); void gtk_source_style_scheme_manager_append_search_path (GtkSourceStyleSchemeManager *manager, const gchar *path) void gtk_source_style_scheme_manager_prepend_search_path (GtkSourceStyleSchemeManager *manager, const gchar *path) void gtk_source_style_scheme_manager_force_rescan (GtkSourceStyleSchemeManager *manager) GtkSourceStyleScheme* gtk_source_style_scheme_manager_get_scheme (GtkSourceStyleSchemeManager *manager, const gchar *scheme_id) void gtk_source_style_scheme_manager_get_search_path (GtkSourceStyleSchemeManager *manager) PPCODE: sourceview2perl_return_strv( gtk_source_style_scheme_manager_get_search_path(manager), FALSE ); void gtk_source_style_scheme_manager_get_scheme_ids (GtkSourceStyleSchemeManager *manager) PPCODE: sourceview2perl_return_strv( gtk_source_style_scheme_manager_get_scheme_ids(manager), FALSE ); Gtk2-SourceView2-0.10/xs/GtkSourceLanguage.xs0000644000175000017500000000375011374060746021201 0ustar emmanuelemmanuel/* * Copyright (c) 2009-2010 by Emmanuel Rodriguez (see the file AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version; or the * Artistic License, version 2.0. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details; or the Artistic License. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307 USA. */ #include "gtk2-sourceview2-perl.h" MODULE = Gtk2::SourceView2::Language PACKAGE = Gtk2::SourceView2::Language PREFIX = gtk_source_language_ const gchar* gtk_source_language_get_id (GtkSourceLanguage *language) const gchar* gtk_source_language_get_name (GtkSourceLanguage *language) const gchar* gtk_source_language_get_section (GtkSourceLanguage *language) gboolean gtk_source_language_get_hidden (GtkSourceLanguage *language) const gchar_ornull* gtk_source_language_get_metadata (GtkSourceLanguage *language, const gchar *name) const gchar_ornull* gtk_source_language_get_style_name (GtkSourceLanguage *language, const char *style_id) void gtk_source_language_get_mime_types (GtkSourceLanguage *language) PPCODE: sourceview2perl_return_strv( gtk_source_language_get_mime_types(language), TRUE ); void gtk_source_language_get_globs (GtkSourceLanguage *language) PPCODE: sourceview2perl_return_strv( gtk_source_language_get_globs(language), TRUE ); void gtk_source_language_get_style_ids (GtkSourceLanguage *language) PPCODE: sourceview2perl_return_strv( gtk_source_language_get_style_ids(language), TRUE ); Gtk2-SourceView2-0.10/xs/GtkSourceIter.xs0000644000175000017500000000426411374060746020362 0ustar emmanuelemmanuel/* * Copyright (c) 2009-2010 by Emmanuel Rodriguez (see the file AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version; or the * Artistic License, version 2.0. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details; or the Artistic License. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307 USA. */ #include "gtk2-sourceview2-perl.h" MODULE = Gtk2::SourceView2::Iter PACKAGE = Gtk2::SourceView2::Iter PREFIX = gtk_source_iter_ =for apidoc backward_search =for signature (match_start, match_end) = Gtk2::SourceView2::Iter->backward_search ($iter, $str, $flags, $limit=NULL) =cut =for apidoc =for signature (match_start, match_end) = Gtk2::SourceView2::Iter->forward_search ($iter, $str, $flags, $limit=NULL) gtk_source_iter_forward_search (class, const GtkTextIter *iter, const gchar *str, GtkSourceSearchFlags flags, const GtkTextIter *limit = NULL) =cut void gtk_source_iter_forward_search (class, const GtkTextIter *iter, const gchar *str, GtkSourceSearchFlags flags) ALIAS: backward_search = 1 PREINIT: GtkTextIter match_start; GtkTextIter match_end; gboolean found = FALSE; gboolean (*searchfunc) (const GtkTextIter *iter, const gchar *str, GtkSourceSearchFlags flags, GtkTextIter *match_start, GtkTextIter *match_end, const GtkTextIter *limit); GtkTextIter *limit = NULL; PPCODE: searchfunc = (ix == 0 ? gtk_source_iter_forward_search : gtk_source_iter_backward_search); found = searchfunc(iter, str, flags, &match_start, &match_end, limit); if (! found) { XSRETURN_EMPTY; } EXTEND (SP, 2); PUSHs (sv_2mortal (newSVGtkTextIter_copy (&match_start))); PUSHs (sv_2mortal (newSVGtkTextIter_copy (&match_end))); Gtk2-SourceView2-0.10/xs/GtkSourceLanguageManager.xs0000644000175000017500000000475611374060746022503 0ustar emmanuelemmanuel/* * Copyright (c) 2009-2010 by Emmanuel Rodriguez (see the file AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version; or the * Artistic License, version 2.0. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details; or the Artistic License. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307 USA. */ #include "gtk2-sourceview2-perl.h" MODULE = Gtk2::SourceView2::LanguageManager PACKAGE = Gtk2::SourceView2::LanguageManager PREFIX = gtk_source_language_manager_ GtkSourceLanguageManager* gtk_source_language_manager_new (class) C_ARGS: /* no args */ GtkSourceLanguageManager* gtk_source_language_manager_get_default (class) C_ARGS: /* no args */ =for apidoc Sets the list of directories where the lm looks for language files. If no dirs are given (empty list) then the search path is cleared, if C is passed then the search path is reset to default. B: At the moment this function can be called only before the language files are loaded for the first time. In practice to set a custom search path for a Gtk2::SourceLanguageManager, you have to call this function right after creating it. =cut void gtk_source_language_manager_set_search_path (GtkSourceLanguageManager *lm, ...) CODE: sourceview2perl_generic_set_dirs( gtk_source_language_manager_set_search_path, lm ); void gtk_source_language_manager_get_search_path (GtkSourceLanguageManager *lm) PPCODE: sourceview2perl_return_strv( gtk_source_language_manager_get_search_path(lm), FALSE ); void gtk_source_language_manager_get_language_ids (GtkSourceLanguageManager *lm) PPCODE: sourceview2perl_return_strv( gtk_source_language_manager_get_language_ids(lm), FALSE ); GtkSourceLanguage_ornull* gtk_source_language_manager_get_language (GtkSourceLanguageManager *lm, const gchar *id) GtkSourceLanguage_ornull* gtk_source_language_manager_guess_language (GtkSourceLanguageManager *lm, const gchar_ornull *filename, const gchar_ornull *content_type = NULL) Gtk2-SourceView2-0.10/xs/GtkSourceBuffer.xs0000644000175000017500000001005611374060746020664 0ustar emmanuelemmanuel/* * Copyright (c) 2009-2010 by Emmanuel Rodriguez (see the file AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version; or the * Artistic License, version 2.0. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details; or the Artistic License. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307 USA. */ #include "gtk2-sourceview2-perl.h" /** * Returns a GSList in the stack and frees the input list. */ #define sourceview2perl_return_gslist(list) \ do {\ GSList *iter_ = (list); /* Iterator, doesn't need to be freed */ \ for (; iter_ != NULL ; iter_ = iter_->next) { \ GtkSourceMark *mark = GTK_SOURCE_MARK(iter_->data); \ SV *sv = newSVGtkSourceMark(mark); \ XPUSHs(sv_2mortal(sv)); \ } \ g_slist_free(list); \ } while (FALSE) MODULE = Gtk2::SourceView2::Buffer PACKAGE = Gtk2::SourceView2::Buffer PREFIX = gtk_source_buffer_ GtkSourceBuffer* gtk_source_buffer_new (class, GtkTextTagTable_ornull *table) C_ARGS: table GtkSourceBuffer* gtk_source_buffer_new_with_language (class, GtkSourceLanguage *language) C_ARGS: language gboolean gtk_source_buffer_get_highlight_syntax (GtkSourceBuffer *buffer) void gtk_source_buffer_set_highlight_syntax (GtkSourceBuffer *buffer, gboolean highlight) gboolean gtk_source_buffer_get_highlight_matching_brackets (GtkSourceBuffer *buffer) void gtk_source_buffer_set_highlight_matching_brackets (GtkSourceBuffer *buffer, gboolean highlight) gint gtk_source_buffer_get_max_undo_levels (GtkSourceBuffer *buffer) void gtk_source_buffer_set_max_undo_levels (GtkSourceBuffer *buffer, gint max_undo_levels) GtkSourceLanguage_ornull* gtk_source_buffer_get_language (GtkSourceBuffer *buffer) void gtk_source_buffer_set_language (GtkSourceBuffer *buffer, GtkSourceLanguage_ornull *language) gboolean gtk_source_buffer_can_undo (GtkSourceBuffer *buffer) gboolean gtk_source_buffer_can_redo (GtkSourceBuffer *buffer) GtkSourceStyleScheme_ornull* gtk_source_buffer_get_style_scheme (GtkSourceBuffer *buffer) void gtk_source_buffer_set_style_scheme (GtkSourceBuffer *buffer, GtkSourceStyleScheme *scheme) void gtk_source_buffer_ensure_highlight (GtkSourceBuffer *buffer, const GtkTextIter *start, const GtkTextIter *end) void gtk_source_buffer_undo (GtkSourceBuffer *buffer) void gtk_source_buffer_redo (GtkSourceBuffer *buffer) void gtk_source_buffer_begin_not_undoable_action (GtkSourceBuffer *buffer) void gtk_source_buffer_end_not_undoable_action (GtkSourceBuffer *buffer) GtkSourceMark* gtk_source_buffer_create_source_mark (GtkSourceBuffer *buffer, const gchar_ornull *name, const gchar *category, const GtkTextIter *where) gboolean gtk_source_buffer_forward_iter_to_source_mark (GtkSourceBuffer *buffer, GtkTextIter *iter, const gchar_ornull *category) gboolean gtk_source_buffer_backward_iter_to_source_mark (GtkSourceBuffer *buffer, GtkTextIter *iter, const gchar_ornull *category) void gtk_source_buffer_get_source_marks_at_iter (GtkSourceBuffer *buffer, GtkTextIter *iter, const gchar_ornull *category) PREINIT: GSList *list = NULL; PPCODE: list = gtk_source_buffer_get_source_marks_at_iter(buffer, iter, category); sourceview2perl_return_gslist(list); void gtk_source_buffer_get_source_marks_at_line (GtkSourceBuffer *buffer, gint line, const gchar_ornull *category) PREINIT: GSList *list = NULL; PPCODE: list = gtk_source_buffer_get_source_marks_at_line(buffer, line, category); sourceview2perl_return_gslist(list); void gtk_source_buffer_remove_source_marks (GtkSourceBuffer *buffer, const GtkTextIter *start, const GtkTextIter *end, const gchar_ornull *category) Gtk2-SourceView2-0.10/examples/0000755000175000017500000000000011400555300016413 5ustar emmanuelemmanuelGtk2-SourceView2-0.10/examples/perl-editor.pl0000755000175000017500000003103411374060746021221 0ustar emmanuelemmanuel#!/usr/bin/perl use strict; use warnings; use Glib qw(TRUE FALSE); use Gtk2 '-init'; use Gtk2::SourceView2; use Data::Dumper; use base 'Class::Accessor::Fast'; __PACKAGE__->mk_accessors(qw{ window sourceview buffer filename search_regexp search_case search_entry regexp highlighted }); my $NAME = 'Otec'; exit main() unless caller; sub main { my ($filename) = @ARGV ? @ARGV : (__FILE__); my $app = __PACKAGE__->new(); $app->build_gui(); $app->load_file($filename); Gtk2->main(); return 0; } sub build_gui { my $self = shift; my $window = Gtk2::Window->new(); $window->set_size_request(480, 360); $window->set_title($NAME); $self->window($window); my $vbox = Gtk2::VBox->new(FALSE, 0); $window->add($vbox); $vbox->pack_start($self->build_menu, FALSE, FALSE, 0); $vbox->pack_start($self->build_search_box, FALSE, FALSE, 0); my $scroll = Gtk2::ScrolledWindow->new(); $scroll->set_policy('automatic', 'automatic'); $scroll->set_shadow_type('in'); $vbox->pack_start($scroll, TRUE, TRUE, 0); my $buffer = $self->create_buffer(); my $sourceview = Gtk2::SourceView2::View->new_with_buffer($buffer); $sourceview->set_show_line_numbers(TRUE); $sourceview->set_tab_width(2); $sourceview->set_indent_on_tab(TRUE); $sourceview->set_highlight_current_line(TRUE); # $sourceview->set_draw_spaces(['tab', 'newline']); # # Fix Gtk2::TextView's annoying paste behaviour when pasting with the mouse # (middle button click). By default gtk will scroll the text view to the # original place where the cursor is. # $sourceview->signal_connect(button_press_event => sub { my ($view, $event) = @_; # We're only interested on middle mouse clicks (mouse-paste) return FALSE unless $event->button == 2; # Remember the position of the paste my (@coords) = $sourceview->window_to_buffer_coords('text', $event->x, $event->y); my ($iter) = $sourceview->get_iter_at_position(@coords); $self->{paste_mark} = $buffer->create_mark('paste', $iter, FALSE); return FALSE; }); # # If a paste is done through the middle click then place the cursor at the end # of the pasted text. # $buffer->signal_connect('paste-done' => sub { my $mark = delete $self->{paste_mark} or return; my $iter = $buffer->get_iter_at_mark($mark); $buffer->place_cursor($iter); $self->sourceview->scroll_to_mark( $mark, 0.0, FALSE, 0.0, 0.5 ); $buffer->delete_mark($mark); }); $scroll->add($sourceview); $self->sourceview($sourceview); $self->buffer($sourceview->get_buffer); $window->signal_connect(delete_event => sub { Gtk2->main_quit(); return TRUE; }); $window->show_all(); } sub build_search_box { my $self = shift; # Elements of the search box my $hbox = Gtk2::HBox->new(FALSE, 0); my $search_entry = Gtk2::Entry->new(); $search_entry->signal_connect(activate => sub {$self->do_search()}); $search_entry->signal_connect(icon_release => sub {$self->do_search()}); $self->search_entry($search_entry); my $search_regexp = Gtk2::CheckButton->new('RegExp'); $search_regexp->signal_connect(toggled => sub { $self->search_regexp($search_regexp->get_active); }); my $search_case = Gtk2::CheckButton->new('Case'); $search_case->signal_connect(toggled => sub { $self->search_case($search_case->get_active); }); my $search_icon = Gtk2::Button->new_from_stock('gtk-find'); $search_entry->set_icon_from_stock(primary => 'gtk-find'); $hbox->pack_start($search_entry, TRUE, TRUE , 0); $hbox->pack_start($search_regexp, FALSE, FALSE, 0); $hbox->pack_start($search_case, FALSE, FALSE, 0); return $hbox; } sub create_buffer { my $self = shift; my $tags = Gtk2::TextTagTable->new(); add_tag($tags, search => { background => 'yellow', }); add_tag($tags, goto_line => { 'paragraph-background' => 'orange', }); my $buffer = Gtk2::SourceView2::Buffer->new($tags); $buffer->signal_connect('notify::cursor-position' => sub { $self->clear_highlighted(); }); return $buffer; } sub add_tag { my ($tags, $name, $properties) = @_; my $tag = Gtk2::TextTag->new($name); $tag->set(%{ $properties }); $tags->add($tag); } sub detect_language { my $self = shift; my ($filename) = @_; # Guess the programming language of the file my $manager = Gtk2::SourceView2::LanguageManager->get_default; my $language = $manager->guess_language($filename); $self->buffer->set_language($language); } sub load_file { my $self = shift; my ($filename) = @_; my $buffer = $self->buffer; # Guess the programming language of the file $self->detect_language($filename); # Loading a file should not be undoable. my $content; do { open my $handle, $filename or die "Can't read file $filename because $!"; local $/; $content = <$handle>; close $handle; }; $buffer->begin_not_undoable_action(); $buffer->set_text($content); $buffer->end_not_undoable_action(); $buffer->set_modified(FALSE); $buffer->place_cursor($buffer->get_start_iter); $self->filename($filename); $self->window->set_title("$filename - $NAME"); } sub clear_highlighted { my $self = shift; my $highlighted = delete $self->{highlighted} or return; my $buffer = $self->buffer; my @iters; foreach my $mark (@{ $highlighted->{marks} }) { my $iter = $buffer->get_iter_at_mark($mark); push @iters, $iter; $buffer->delete_mark($mark); } $buffer->remove_tag_by_name($highlighted->{name}, @iters); } sub get_text { my $self = shift; my $buffer = $self->buffer; return $buffer->get_text($buffer->get_start_iter, $buffer->get_end_iter, FALSE); } sub do_search { my $self = shift; my $criteria = $self->search_entry->get_text; if ($criteria eq '') {return;} my $case = $self->search_case; my $buffer = $self->buffer; # Start the search at the last search result or from the current cursor's # position. As a fall back we also add the beginning of the document. Once we # have the start position we can erase the previous search results. my @start; if (my $highlighted = $self->highlighted) { # Search from the last match push @start, $buffer->get_iter_at_mark($highlighted->{marks}[1]); $self->clear_highlighted(); } else { # Search from the cursor push @start, $buffer->get_iter_at_offset( $buffer->get_property('cursor-position') ); } push @start, $buffer->get_start_iter; my @iters; if ($self->search_regexp) { # Gtk2::SourceView2 nor Gtk2::SourceView support regular expressions so we # have to do the search by hand! my $text = $self->get_text; my $regexp = $case ? qr/$criteria/m : qr/$criteria/im; foreach my $iter (@start) { # Tell Perl where to start the regexp lookup pos($text) = $iter->get_offset; if ($text =~ /($regexp)/g) { my $word = $1; my $pos = pos($text); @iters = ( $buffer->get_iter_at_offset($pos - length($word)), $buffer->get_iter_at_offset($pos), ); last; } } } else { # Use the builtin search mechanism my $flags = $case ? [ ] : [ 'case-insensitive' ]; foreach my $iter (@start) { @iters = Gtk2::SourceView2::Iter->forward_search($iter, $criteria, $flags); last if @iters; } } $self->show_highlighted(search => @iters) if @iters; } sub show_highlighted { my $self = shift; my ($tag_name, $start, $end) = @_; my $buffer = $self->buffer; # Highlight the region, remember it and scroll to it my $match_start = $buffer->create_mark('match-start', $start, TRUE); my $match_end = $buffer->create_mark('match-end', $end, FALSE); $buffer->apply_tag_by_name($tag_name, $start, $end); # We have a callback that listens to when the cursor is placed and we don't # want it to undo our work! So let's unhighlight the previous entry. delete $self->{highlighted}; $buffer->place_cursor($end); $self->sourceview->scroll_to_mark( $match_start, 0.2, FALSE, 0.0, 0.5 ); # Keep a reference to the markers once they have been added to the buffer. # Using them before can be catastrophic (segmenation fault). # $self->highlighted({ name => $tag_name, marks => [$match_start, $match_end], }); } sub do_file_new { my $self = shift; my $buffer = $self->buffer; # Set no language $buffer->set_language(undef); # Showing a blank editor should not be undoable. $buffer->begin_not_undoable_action(); $buffer->set_text(''); $buffer->end_not_undoable_action(); $buffer->set_modified(FALSE); $buffer->place_cursor($buffer->get_start_iter); $self->filename(''); $self->window->set_title("Untitled - $NAME"); } sub do_file_open { my $self = shift; my ($window, $action, $menu_item) = @_; my $dialog = Gtk2::FileSelection->new("Open file..."); $dialog->signal_connect(response => sub { my ($dialog, $response) = @_; if ($response eq 'ok') { my $file = $dialog->get_filename; return if -d $file; $self->load_file($file); } $dialog->destroy(); }); $dialog->show(); } sub do_show_about_dialog { my $self = shift; my $dialog = Gtk2::AboutDialog->new(); $dialog->set_authors("Emmanuel Rodriguez"); $dialog->set_comments("Gtk2::SourceView2 Demo"); $dialog->signal_connect(response => sub { my ($dialog, $response) = @_; $dialog->destroy(); }); $dialog->show(); } sub do_ask_goto_line { my $self = shift; my $dialog = Gtk2::Dialog->new_with_buttons( "Goto to line", $self->window, [ 'modal' ], 'gtk-cancel' => 'cancel', 'gtk-ok' => 'ok', ); my $hbox = Gtk2::HBox->new(FALSE, 0); $hbox->pack_start( Gtk2::Label->new("Line number: "), FALSE, FALSE, 0 ); my $entry = Gtk2::Entry->new(); $hbox->pack_start($entry, TRUE, TRUE, 0); $dialog->get_content_area->add($hbox); $dialog->show_all(); # Signal handlers $entry->signal_connect(activate => sub { if ($entry->get_text =~ /(\d+)/) { $dialog->response('ok'); } }); # Run the dialog my $response = $dialog->run(); $dialog->destroy(); return unless $response eq 'ok'; return unless my ($line) = ($entry->get_text =~ /(\d+)/); my $buffer = $self->buffer; my $start = $buffer->get_iter_at_line($line - 1); my $end = $start->copy; $end->forward_to_line_end; $self->clear_highlighted(); $self->show_highlighted(goto_line => $start, $end); } sub do_quit { my $self = shift; Gtk2->main_quit(); } sub do_save_as { my $self = shift; # If no file is associated with the editor then ask the user for a file where # to save the contents of the buffer. my $dialog = Gtk2::FileChooserDialog->new( "Save file", $self->window, 'save', 'gtk-cancel' => 'cancel', 'gtk-save' => 'ok', ); my $response = $dialog->run(); if ($response eq 'ok') { $self->filename($dialog->get_filename); $self->do_save(); } $dialog->destroy(); } sub do_save { my $self = shift; my $filename = $self->filename; # If there's no file then do a save as... if (! $filename) { $self->do_save_as(); return; } my $buffer = $self->buffer; open my $handle, '>:encoding(UTF-8)', $filename or die "Can't write to $filename: $!"; print $handle $self->get_text; close $handle; if (! $buffer->get_language) { $self->detect_language($filename); } } sub build_menu { my $self = shift; my $entries = [ # name, stock id, label [ "FileMenu", undef, "_File" ], [ "SearchMenu", undef, "_Search" ], [ "HelpMenu", undef, "_Help" ], # name, stock id, label, accelerator, tooltip, method [ "New", 'gtk-new', "_New", "N", "Create a new file", sub { $self->do_file_new(@_) } ], [ "Open", 'gtk-open', "_Open", "O", "Open a file", sub { $self->do_file_open(@_) } ], [ "Save", 'gtk-save', "_Save", "S", "Save current file", sub { $self->do_save(@_) } ], [ "SaveAs", 'gtk-save', "Save _As...", "S", "Save to a file", sub { $self->do_save_as(@_) } ], [ "Quit", 'gtk-quit', "_Quit", "Q", "Quit", sub { $self->do_quit() } ], [ "About", 'gtk-about', "_About", undef, "About", sub { $self->do_show_about_dialog(@_) } ], [ "GotoLine", undef, "Goto to _Line", "L", "Go to line", sub { $self->do_ask_goto_line(@_) } ], ]; my $actions = Gtk2::ActionGroup->new("Actions"); $actions->add_actions($entries, undef); my $ui = Gtk2::UIManager->new(); $ui->insert_action_group($actions, 0); $ui->add_ui_from_string(<<'__UI__'); __UI__ $self->window->add_accel_group($ui->get_accel_group); return $ui->get_widget('/MenuBar'); } Gtk2-SourceView2-0.10/MANIFEST0000644000175000017500000000133511400555301015731 0ustar emmanuelemmanuelChanges COPYING examples/perl-editor.pl gtk2-sourceview2-perl.h lib/Gtk2/SourceView2.pm Makefile.PL MANIFEST MANIFEST.SKIP README maps t/GtkSourceBuffer.t t/GtkSourceIter.t t/GtkSourceLanguage.t t/GtkSourceLanguageManager.t t/GtkSourceMark.t t/GtkSourcePrintCompositor.t t/GtkSourceStyle.t t/GtkSourceStyleScheme.t t/GtkSourceStyleSchemeManager.t t/GtkSourceView.t t/my_helper.pm xs/GtkSourceBuffer.xs xs/GtkSourceIter.xs xs/GtkSourceLanguage.xs xs/GtkSourceLanguageManager.xs xs/GtkSourceMark.xs xs/GtkSourcePrintCompositor.xs xs/GtkSourceStyle.xs xs/GtkSourceStyleScheme.xs xs/GtkSourceStyleSchemeManager.xs xs/GtkSourceView.xs xs/GtkSourceViewBoot.xs META.yml Module meta-data (added by MakeMaker)