Gtk3-0.015/000755 001750 000024 00000000000 12251206043 012553 5ustar00brianstaff000000 000000 Gtk3-0.015/dist.ini000644 001750 000024 00000002571 12251206043 014224 0ustar00brianstaff000000 000000 name = Gtk3 version = 0.015 author = Torsten Schoenfeld license = LGPL_2_1 copyright_holder = Torsten Schoenfeld copyright_year = 2013 ; 'is_trial' comes from Zilla.pm; use this flag to change between 'stable' and ; 'testing'. DZil 4.300034 supports only 'stable' and 'testing', not ; 'unstable'; there's a note in Zilla.pm about this fact ;is_trial = 1 [GatherDir] [PruneCruft] [ManifestSkip] [MetaYAML] version = 2 [MetaJSON] [License] [MakeMaker] [Manifest] [PkgVersion] [Prereqs] Carp = 0 ; core Exporter = 0 ; core Cairo::GObject = 1.000 Glib::Object::Introspection = 0.016 Test::Simple = 0.96 ; for the fix for is() and objects with overloading [NextRelease] filename = NEWS format = Overview of changes in Gtk3 %v [%{yyyy-MM-dd}d]%n============================================== [Git::Check] changelog = NEWS [Git::Commit] changelog = NEWS commit_msg = Release v%v%n%n%c [Git::Tag] signed = 1 [Git::Push] [MetaResources] homepage = http://gtk2-perl.sourceforge.net bugtracker.web = http://rt.cpan.org/Public/Dist/Display.html?Name=Gtk3 bugtracker.mailto = bug-Gtk3 [at] rt.cpan.org repository.url = git://git.gnome.org/perl-Gtk3 repository.web = http://git.gnome.org/browse/perl-Gtk3 repository.type = git [TestRelease] [ConfirmRelease] [UploadToCPAN] [UploadToSFTP] site = frs.sourceforge.net directory = /home/pfs/project/g/gt/gtk2-perl/Gtk3 Gtk3-0.015/lib/000755 001750 000024 00000000000 12251206043 013321 5ustar00brianstaff000000 000000 Gtk3-0.015/LICENSE000644 001750 000024 00000060121 12251206043 013560 0ustar00brianstaff000000 000000 This software is Copyright (c) 2013 by Torsten Schoenfeld. This is free software, licensed under: The GNU Lesser General Public License, Version 2.1, February 1999 The GNU Lesser General Public License (LGPL) Version 2.1, February 1999 (The master copy of this license lives on the GNU website.) Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, 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 and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, 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 library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete 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 distribute a copy of this License along with the Library. 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 Library or any portion of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, 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 Library, 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 Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you 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. If distribution of 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 satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be 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. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library 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. 9. 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 Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library 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 with this License. 11. 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 Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library 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 Library. 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. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library 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. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser 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 Library 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 Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, 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 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. 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 LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Gtk3-0.015/Makefile.PL000644 001750 000024 00000002725 12251206043 014533 0ustar00brianstaff000000 000000 use strict; use warnings; use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( "ABSTRACT" => "Perl interface to the 3.x series of the gtk+ toolkit", "AUTHOR" => "Torsten Schoenfeld ", "BUILD_REQUIRES" => {}, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30" }, "DISTNAME" => "Gtk3", "EXE_FILES" => [], "LICENSE" => "lgpl", "NAME" => "Gtk3", "PREREQ_PM" => { "Cairo::GObject" => "1.000", "Carp" => 0, "Exporter" => 0, "Glib::Object::Introspection" => "0.016", "Test::Simple" => "0.96" }, "TEST_REQUIRES" => {}, "VERSION" => "0.015", "test" => { "TESTS" => "t/*.t" } ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { my $tr = delete $WriteMakefileArgs{TEST_REQUIRES}; my $br = $WriteMakefileArgs{BUILD_REQUIRES}; for my $mod ( keys %$tr ) { if ( exists $br->{$mod} ) { $br->{$mod} = $tr->{$mod} if $tr->{$mod} > $br->{$mod}; } else { $br->{$mod} = $tr->{$mod}; } } } unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) { my $br = delete $WriteMakefileArgs{BUILD_REQUIRES}; my $pp = $WriteMakefileArgs{PREREQ_PM}; for my $mod ( keys %$br ) { if ( exists $pp->{$mod} ) { $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod}; } else { $pp->{$mod} = $br->{$mod}; } } } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); Gtk3-0.015/MANIFEST000644 001750 000024 00000001021 12251206043 013676 0ustar00brianstaff000000 000000 LICENSE MANIFEST META.json META.yml Makefile.PL NEWS README dist.ini lib/Gtk3.pm perl-Gtk3.doap t/00-init.t t/floating-refs.t t/inc/setup.pl t/overrides.t t/signals.t t/vfuncs.t t/zz-GdkEvent.t t/zz-GtkActionGroup.t t/zz-GtkBuilder.t t/zz-GtkCellLayoutIface.t t/zz-GtkCellRendererIface.t t/zz-GtkContainer.t t/zz-GtkDialog.t t/zz-GtkImage.t t/zz-GtkInfoBar.t t/zz-GtkRadioAction.t t/zz-GtkRadioButton.t t/zz-GtkRadioMenuItem.t t/zz-GtkRadioToolButton.t t/zz-GtkRecentChooserDialog.t t/zz-GtkTextBuffer.t t/zz-GtkTreeModelIface.t Gtk3-0.015/META.json000644 001750 000024 00000002364 12251206043 014201 0ustar00brianstaff000000 000000 { "abstract" : "Perl interface to the 3.x series of the gtk+ toolkit", "author" : [ "Torsten Schoenfeld " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 4.300039, CPAN::Meta::Converter version 2.131560", "license" : [ "lgpl_2_1" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Gtk3", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.30" } }, "runtime" : { "requires" : { "Cairo::GObject" : "1.000", "Carp" : "0", "Exporter" : "0", "Glib::Object::Introspection" : "0.016", "Test::Simple" : "0.96" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-Gtk3 [at] rt.cpan.org", "web" : "http://rt.cpan.org/Public/Dist/Display.html?Name=Gtk3" }, "homepage" : "http://gtk2-perl.sourceforge.net", "repository" : { "type" : "git", "url" : "git://git.gnome.org/perl-Gtk3", "web" : "http://git.gnome.org/browse/perl-Gtk3" } }, "version" : "0.015" } Gtk3-0.015/META.yml000644 001750 000024 00000001562 12251206043 014030 0ustar00brianstaff000000 000000 --- abstract: 'Perl interface to the 3.x series of the gtk+ toolkit' author: - 'Torsten Schoenfeld ' dynamic_config: 0 generated_by: 'Dist::Zilla version 4.300039, CPAN::Meta::Converter version 2.131560' license: - lgpl_2_1 meta-spec: url: http://search.cpan.org/perldoc?CPAN::Meta::Spec version: 2 name: Gtk3 prereqs: configure: requires: ExtUtils::MakeMaker: 6.30 runtime: requires: Cairo::GObject: 1.000 Carp: 0 Exporter: 0 Glib::Object::Introspection: 0.016 Test::Simple: 0.96 release_status: stable resources: bugtracker: mailto: 'bug-Gtk3 [at] rt.cpan.org' web: http://rt.cpan.org/Public/Dist/Display.html?Name=Gtk3 homepage: http://gtk2-perl.sourceforge.net repository: type: git url: git://git.gnome.org/perl-Gtk3 web: http://git.gnome.org/browse/perl-Gtk3 version: 0.015 Gtk3-0.015/NEWS000644 001750 000024 00000011142 12251206043 013251 0ustar00brianstaff000000 000000 Overview of changes in Gtk3 0.015 [2013-12-08] ============================================== * Add overrides for Gtk3::RadioAction, Gtk3::RadioButton, Gtk3::RadioMenuItem and Gtk3::RadioToolButton. * Add an override for Gtk3::SizeGroup::get_widgets. * Add an override for Gtk3::Widget::render_icon. * Add an override for Pango::Layout::set_text. * Require Test::Simple >= 0.96. Overview of changes in Gtk3 0.014 [2013-10-18] ============================================== * dist.ini: document 'is_trial', sets 'testing' in metadata * dist.ini: Add MetaJSON, set MetaYAML version = 2 * dist.ini: Add [MetaResources] block with correct URLs; fixes RT#89118 Overview of changes in Gtk3 0.013 [2013-09-30] ============================================== * Add forgotten release notes. * Reenable UploadToCPAN Dist::Zilla plugin Overview of changes in Gtk3 0.012 [2013-09-30] ============================================== * Add overrides for Gtk3::Image. ∗ Fix partial misquoting in croak usage * Do not use 'defined' on an array (Spotted by Thierry Vignaud) * Add overrides for Gtk3::Image (Based on a patch by Dave M.) * Add two more tests for Gtk3::TextBuffer (Zach Morgan) Overview of changes in Gtk3 0.011 [2013-09-01] ============================================== * Add forgotten release notes. Overview of changes in Gtk3 0.010 [2013-09-01] ============================================== * Gtk3::HBox/Gtk3::VBox: use correct defaults in constructors. * Gtk3::TextBuffer::create_tag: handle all property pairs. * Fix a few test failures for older gtk+. Overview of changes in Gtk3 0.009 [2013-02-14] ============================================== * Add overrides for Gtk3::Container. * Add overrides for Gtk3::Dialog and Gtk3::InfoBar, including the conversion of predefined response IDs to nick names. * Add overrides for Gtk3::Editable. * Add overrides for Gtk3::FileChooserDialog. * Add overrides for Gtk3::RecentChooserDialog. * Add overrides for Gtk3::TextBuffer. * Add overrides for Gtk3::ListStore's and Gtk3::TreeStore's insert_with_values(). * Add more overrides for Gtk3::TreeView and friends. * Add overrides for various button constructors. * Add an override for Gtk3::main_level. * Add Gtk3::EVENT_PROPAGATE and Gtk3::EVENT_STOP. * In Gtk3::TreeModel::get, if no columns are specified, use all columns. * Test that no double-frees occur for custom Gtk3::Widget subclasses. * Add overrides for Gtk3::Gdk::Atom. * Add overrides for Gtk3::Gdk::RGBA. * Make Gtk3::Gdk::Pixbuf::save, save_to_buffer and save_to_callback usable. * Fix test failures on older versions of gtk+. Overview of changes in Gtk3 0.008 [2012-08-26] ============================================== * Add overrides for Gtk3::Gdk::Event. * Add overrides for some Gtk3::RadioMenuItem constructors. * Add overrides for Gtk3::CssProvider. * Add overrides for Gtk3::UIManager. * Always convert GdkRectangle objects to and from Cairo::RectangleInt. Overview of changes in Gtk3 0.007 [2012-07-05] ============================================== * Add overrides for Gtk3::ActionGroup. * Add an override for Gtk3::show_about_dialog. * Fix some test failures due to older dependencies. Overview of changes in Gtk3 0.006 [2012-06-04] ============================================== * Add overrides for Gtk3::MenuItem, CheckMenuItem and ImageMenuItem. * Require Glib 1.260 and Glib::Object::Introspection 0.009 for various improvements. Overview of changes in Gtk3 0.005 [2012-04-22] ============================================== * Require Cairo::GObject and load it automatically. * Add overrides for Gtk3::Builder and implement its connect_signals. * Add overrides for Gtk3::Menu::popup and popup_for_device. * Add some documentation about porting from Gtk2 to Gtk3. Overview of changes in Gtk3 0.004 [2012-03-18] ============================================== * Provide GdkPixbuf bindings under Gtk3::Gdk::Pixbuf. * Make Gtk3::[HV]Box::new provide default arg values. * Make Gtk3::Gdk::Window::new construct the mask automatically if none is given. * Clarify licensing terms. Overview of changes in Gtk3 0.003 [2012-01-14] ============================================== * API change: wrap gtk_stock_* as Gtk3::Stock::*. Also, make Gtk3::Stock::list_ids return a list and make Gtk3::Stock::lookup skip the sentinel boolean. * Correctly handle internal errors on perl < 5.14. This fixes a test failure. Overview of changes in Gtk3 0.002 [2011-12-09] ============================================== * Add more overrides for the tree objects. * Fix a test failure. (RT #72773) Overview of changes in Gtk3 0.001 [2011-10-14] ============================================== * Initial release. Gtk3-0.015/perl-Gtk3.doap000644 001750 000024 00000001437 12251206043 015175 0ustar00brianstaff000000 000000 Gtk3 Perl interface to the 3.x series of the Gimp Toolkit library Torsten Schönfeld tsch Gtk3-0.015/README000644 001750 000024 00000002042 12251206043 013431 0ustar00brianstaff000000 000000 Gtk3 ==== Perl bindings to the 3.x series of the gtk+ toolkit. This module allows you to write graphical user interfaces in a Perlish and object-oriented way, freeing you from the casting and memory management in C, yet remaining very close in spirit to original API. INSTALLATION ------------ To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES ------------ Gtk3 needs this C library: gtk+-3.0 >= 3.0.0 and these Perl modules: Glib::Object::Introspection >= 0.002 BUG REPORTS ----------- Please report bugs to the gnome-perl product in GNOME's Bugzilla: COPYRIGHT AND LICENSE --------------------- Copyright (C) 2005-2012 Torsten Schoenfeld This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. Gtk3-0.015/t/000755 001750 000024 00000000000 12251206043 013016 5ustar00brianstaff000000 000000 Gtk3-0.015/t/00-init.t000644 001750 000024 00000000653 12251206043 014367 0ustar00brianstaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; BEGIN { require Gtk3; } my $success = eval { Gtk3->import; 1 }; BAIL_OUT ("Cannot load Gtk3: $@") unless $success; plan tests => 1; SKIP: { @ARGV = qw(--help --name gtk2perl --urgs tree); skip 'Gtk3::init_check failed, probably unable to open DISPLAY', 1 unless Gtk3::init_check (); Gtk3::init (); is_deeply (\@ARGV, [qw(--help --urgs tree)]); } Gtk3-0.015/t/floating-refs.t000644 001750 000024 00000000602 12251206043 015741 0ustar00brianstaff000000 000000 #!/usr/bin/env perl BEGIN { require './t/inc/setup.pl' }; use strict; use warnings; use Scalar::Util qw/weaken/; plan tests => 2; SKIP: { my $button = Gtk3::Button->new_with_label ('Label'); weaken $button; is ($button, undef); } SKIP: { skip 'Window ref counting test', 1; # FIXME? my $window = Gtk3::Window->new ('toplevel'); weaken $window; is ($window, undef); } Gtk3-0.015/t/inc/000755 001750 000024 00000000000 12251206043 013567 5ustar00brianstaff000000 000000 Gtk3-0.015/t/overrides.t000644 001750 000024 00000051655 12251206043 015221 0ustar00brianstaff000000 000000 #!/usr/bin/env perl BEGIN { require './t/inc/setup.pl' }; use strict; use warnings; use utf8; use Encode; plan tests => 164; # Gtk3::CHECK_VERSION and check_version { my ($x, $y, $z) = (Gtk3::MAJOR_VERSION, Gtk3::MINOR_VERSION, Gtk3::MICRO_VERSION); ok (Gtk3::CHECK_VERSION ($x, $y, $z)); ok (Gtk3->CHECK_VERSION ($x, $y, $z)); ok (not defined Gtk3::check_version ($x, $y, $z)); ok (not defined Gtk3->check_version ($x, $y, $z)); $z++; ok (!Gtk3::CHECK_VERSION ($x, $y, $z)); ok (!Gtk3->CHECK_VERSION ($x, $y, $z)); ok (defined Gtk3::check_version ($x, $y, $z)); ok (defined Gtk3->check_version ($x, $y, $z)); } # Gtk3::Window::new and list_toplevels. This is at the top to avoid testing # against a polluted list of toplevels. { my $window1 = Gtk3::Window->new ('toplevel'); my $window2 = Gtk3::Window->new; is_deeply ([Gtk3::Window::list_toplevels ()], [$window1, $window2]); is (scalar Gtk3::Window::list_toplevels (), $window2); } # Gtk3::show_about_dialog { my %props = (program_name => 'Foo', version => '42', authors => [qw/me myself i/], license_type => 'lgpl-2-1'); Gtk3::show_about_dialog (undef, %props); Gtk3->show_about_dialog (undef, %props); Gtk3::show_about_dialog (Gtk3::Window->new, %props); Gtk3->show_about_dialog (Gtk3::Window->new, %props); ok (1); } # Gtk3::[HV]Box { foreach my $class (qw/HBox VBox/) { my $box = "Gtk3::$class"->new; ok (!$box->get_homogeneous); is ($box->get_spacing, 5); } } # Gtk3::Button::new { my $button = Gtk3::Button->new; ok (!defined ($button->get_label)); $button = Gtk3::Button->new ('_Test'); is ($button->get_label, '_Test'); } # Gtk3::CellLayout::get_cells { my $cell = Gtk3::TreeViewColumn->new; is_deeply([$cell->get_cells], []); my $one = Gtk3::CellRendererText->new; my $two = Gtk3::CellRendererText->new; $cell->pack_start($one, 0); $cell->pack_start($two, 1); is_deeply([$cell->get_cells], [$one, $two]); } # Gtk3::CheckButton::new { my $button = Gtk3::CheckButton->new; ok (!defined ($button->get_label)); $button = Gtk3::CheckButton->new ('_Test'); is ($button->get_label, '_Test'); } # Gtk3::ColorButton::new { my $button = Gtk3::ColorButton->new; is ($button->get_color->red, 0); my $color = Gtk3::Gdk::Color->new (red => 2**16-1, green => 0, blue => 0); $button = Gtk3::ColorButton->new ($color); is ($button->get_color->red, $color->red); } # Gtk3::CssProvider SKIP: { skip 'Gtk3::CssProvider; incorrect annotations', 2 unless Gtk3::CHECK_VERSION (3, 2, 0); my $css = "GtkButton {font: Cantarelll 10}"; my $expect = qr/Cantarelll/; my $p = Gtk3::CssProvider->new; $p->load_from_data ($css); like ($p->to_string, $expect); $p->load_from_data ([unpack 'C*', $css]); like ($p->to_string, $expect); } # Gtk3::Editable::insert_text { my $entry = Gtk3::Entry->new; my $orig_text = 'aeiou'; my $orig_text_chars = length ($orig_text); my $orig_text_bytes = length (Encode::encode_utf8 ($orig_text)); $entry->set_text ($orig_text); my ($new_text, $pos) = ('0123456789', $orig_text_chars); my $new_text_chars = length ($new_text); my $new_text_bytes = length (Encode::encode_utf8 ($new_text)); is ($entry->insert_text ($new_text, $pos), $pos + $new_text_chars); $pos = 0; is ($entry->insert_text ($new_text, $new_text_bytes, $pos), $pos + $new_text_chars); is ($entry->get_text, $new_text . $orig_text . $new_text); } # Gtk3::Editable::insert_text and length issues { my $entry = Gtk3::Entry->new; my ($text, $pos) = ('0123456789€', 0); is ($entry->insert_text ($text, $pos), $pos + length ($text)); is ($entry->get_text, $text); } # GtkEditable.insert-text signal SKIP: { skip 'GtkEditable.insert-text signal; need generic signal marshaller', 5 unless check_gi_version (1, 33, 10); my $entry = Gtk3::Entry->new; my $orig_text = 'äöü'; $entry->set_text ($orig_text); my ($my_text, $my_pos) = ('123', 2); $entry->signal_connect ('insert-text' => sub { my ($entry, $new_text, $new_text_bytes, $position, $data) = @_; is ($new_text, $my_text); is ($new_text_bytes, length (Encode::encode_utf8 ($my_text))); is ($position, $my_pos); # Disregard $position and move the text to the end. return length $entry->get_text; }); is ($entry->insert_text ($my_text, $my_pos), length ($orig_text) + length ($my_text)); is ($entry->get_text, $orig_text . $my_text); } # Gtk3::FileChooserDialog { my $parent = Gtk3::Window->new; my $dialog = Gtk3::FileChooserDialog->new ('some title', $parent, 'save', 'gtk-cancel' => 'cancel', 'gtk-ok' => 23); is ($dialog->get_title, 'some title'); is ($dialog->get_transient_for, $parent); is ($dialog->get_action, 'save'); } # Gtk3::FontButton::new { my $button = Gtk3::FontButton->new; # $button->get_font_name can be anything $button = Gtk3::FontButton->new ('Sans'); ok (defined $button->get_font_name); } # Gtk3::LinkButton::new { my ($host, $label) = ('http://localhost', 'Local'); my $button = Gtk3::LinkButton->new ($host); is ($button->get_label, $host); $button = Gtk3::LinkButton->new ($host, $label); is ($button->get_label, $label); } # Gtk3::ListStore::new, set and get, insert_with_values SKIP: { skip 'Gtk3::ListStore; tree model ctors not properly supported', 10 unless check_gi_version(1, 29, 17); my $model = Gtk3::ListStore->new ([qw/Glib::String Glib::Int/]); my $iter = $model->append; $model->set ($iter, [0, 1], ['Foo', 23]); is_deeply ([$model->get ($iter)], ['Foo', 23]); is_deeply ([$model->get ($iter, 0,1)], ['Foo', 23]); is (scalar $model->get ($iter, 0,1), 23); $iter = $model->append; $model->set ($iter, 0 => 'Bar', 1 => 42); is_deeply ([$model->get ($iter)], ['Bar', 42]); is_deeply ([$model->get ($iter, 0,1)], ['Bar', 42]); is (scalar $model->get ($iter, 0,1), 42); { local $@; eval { $model->set ($iter, 0) }; like ($@, qr/Usage/); } $iter = $model->insert_with_values (-1, [0, 1], ['FooFoo', 2323]); is_deeply ([$model->get ($iter)], ['FooFoo', 2323]); $iter = $model->insert_with_values (-1, 0 => 'BarBar', 1 => 4242); is_deeply ([$model->get ($iter)], ['BarBar', 4242]); { local $@; eval { $model->insert_with_values (-1, 0); }; like ($@, qr/Usage/); } } # Gtk3::Menu::popup and popup_for_device SKIP: { skip 'Gtk3::Menu; incorrect annotations', 2 unless Gtk3::CHECK_VERSION (3, 2, 0); { my $menu = Gtk3::Menu->new; my $position_callback = sub { my ($menu, $data) = @_; isa_ok ($menu, "Gtk3::Menu"); return @$data; }; $menu->popup (undef, undef, $position_callback, [50, 50], 1, 0); $menu->popup_for_device (undef, undef, undef, $position_callback, [50, 50, Glib::TRUE], 1, 0); } # Test this separately to ensure that specifying no callback does not lead to # an invalid invocation of the destroy notify func. { my $menu = Gtk3::Menu->new; $menu->popup (undef, undef, undef, undef, 1, 0); } } # Gtk2::MenuItem::new, Gtk2::CheckMenuItem::new, Gtk2::ImageMenuItem::new { foreach my $class (qw/Gtk3::MenuItem Gtk3::CheckMenuItem Gtk3::ImageMenuItem/) { my $item; $item = $class->new; isa_ok ($item, $class); ok (!$item->get_label); # might be '' or undef $item = $class->new ('_Test'); isa_ok ($item, $class); is ($item->get_label, '_Test'); $item = $class->new_with_mnemonic ('_Test'); isa_ok ($item, $class); is ($item->get_label, '_Test'); } } # Gtk3::SizeGroup { my $group = Gtk3::SizeGroup->new ("vertical"); my @widgets = $group->get_widgets; ok (!@widgets); my ($uno, $dos, $tres, $cuatro) = (Gtk3::Label->new ("Tinky-Winky"), Gtk3::Label->new ("Dipsy"), Gtk3::Label->new ("La La"), Gtk3::Label->new ("Po")); $group->add_widget ($uno); $group->add_widget ($dos); $group->add_widget ($tres); $group->add_widget ($cuatro); @widgets = $group->get_widgets; is (scalar @widgets, 4); } # Gtk3::Stock { ok (grep { $_ eq 'gtk-ok' } Gtk3::Stock::list_ids ()); my $item = Gtk3::Stock::lookup ('gtk-ok'); is ($item->{stock_id}, 'gtk-ok'); # Gtk3::Stock::add and add_static don't work yet Gtk3::Stock::set_translate_func ('perl-domain', sub {}, 42); } # Gtk3::ToggleButton::new { my $button = Gtk3::ToggleButton->new; ok (!defined ($button->get_label)); $button = Gtk3::ToggleButton->new ('_Test'); is ($button->get_label, '_Test'); } # Gtk3::TreeStore::new, set and get, insert_with_values SKIP: { skip 'Gtk3::TreeStore; tree model ctors not properly supported', 10 unless check_gi_version(1, 29, 17); my $model = Gtk3::TreeStore->new ([qw/Glib::String Glib::Int/]); my $iter = $model->append (undef); $model->set ($iter, [0, 1], ['Foo', 23]); is_deeply ([$model->get ($iter)], ['Foo', 23]); is_deeply ([$model->get ($iter, 0,1)], ['Foo', 23]); is (scalar $model->get ($iter, 0,1), 23); $iter = $model->append (undef); $model->set ($iter, 0 => 'Bar', 1 => 42); is_deeply ([$model->get ($iter)], ['Bar', 42]); is_deeply ([$model->get ($iter, 0,1)], ['Bar', 42]); is (scalar $model->get ($iter, 0,1), 42); { local $@; eval { $model->set ($iter, 0) }; like ($@, qr/Usage/); } $iter = $model->insert_with_values (undef, -1, [0, 1], ['FooFoo', 2323]); is_deeply ([$model->get ($iter)], ['FooFoo', 2323]); $iter = $model->insert_with_values (undef, -1, 0 => 'BarBar', 1 => 4242); is_deeply ([$model->get ($iter)], ['BarBar', 4242]); { local $@; eval { $model->insert_with_values (undef, -1, 0); }; like ($@, qr/Usage/); } } # Gtk3::TreePath::new, new_from_string, new_from_indices, get_indices { my $path = Gtk3::TreePath->new; isa_ok ($path, 'Gtk3::TreePath'); $path = Gtk3::TreePath->new ('1:2:3'); is_deeply ([$path->get_indices], [1, 2, 3]); $path = Gtk3::TreePath->new_from_string ('1:2:3'); is_deeply ([$path->get_indices], [1, 2, 3]); $path = Gtk3::TreePath->new_from_indices (1, 2, 3); is_deeply ([$path->get_indices], [1, 2, 3]); } # Gtk3::TreeModel::get_iter, get_iter_first, get_iter_from_string SKIP: { skip 'Gtk3::TreeModel; tree model ctors not properly supported', 6 unless check_gi_version(1, 29, 17); my $model = Gtk3::ListStore->new ('Glib::String'); my $path = Gtk3::TreePath->new_from_string ('0'); is ($model->get_iter ($path), undef); is ($model->get_iter_first, undef); is ($model->get_iter_from_string ('0'), undef); my $iter = $model->append; isa_ok ($model->get_iter ($path), 'Gtk3::TreeIter'); isa_ok ($model->get_iter_first, 'Gtk3::TreeIter'); isa_ok ($model->get_iter_from_string ('0'), 'Gtk3::TreeIter'); } # Gtk3::TreeModel::iter_children, iter_nth_child, iter_parent SKIP: { skip 'Gtk3::TreeModel; tree model ctors not properly supported', 6 unless check_gi_version(1, 29, 17); my $model = Gtk3::TreeStore->new ([qw/Glib::String/]); my $parent_iter = $model->append (undef); is ($model->iter_children ($parent_iter), undef); is ($model->iter_nth_child ($parent_iter, 0), undef); is ($model->iter_parent ($parent_iter), undef); my $child_iter = $model->append ($parent_iter); isa_ok ($model->iter_children ($parent_iter), 'Gtk3::TreeIter'); isa_ok ($model->iter_nth_child ($parent_iter, 0), 'Gtk3::TreeIter'); isa_ok ($model->iter_parent ($child_iter), 'Gtk3::TreeIter'); } # Gtk3::TreeModelFilter SKIP: { skip 'Gtk3::TreeFilter; tree model ctors not properly supported', 3 unless check_gi_version(1, 29, 17); my $child_model = Gtk3::TreeStore->new ([qw/Glib::String/]); my $child_iter = $child_model->append (undef); $child_model->set ($child_iter, 0 => 'Bla'); my $model = Gtk3::TreeModelFilter->new ($child_model); isa_ok ($model, 'Gtk3::TreeModelFilter'); my $iter = $model->convert_child_iter_to_iter ($child_iter); isa_ok ($iter, 'Gtk3::TreeIter'); is ($model->get ($iter, 0), 'Bla'); } # Gtk3::TreeModelSort SKIP: { skip 'Gtk3::TreeModelSort; tree model ctors not properly supported', 3 unless check_gi_version(1, 29, 17); my $child_model = Gtk3::TreeStore->new ([qw/Glib::String/]); my $child_iter = $child_model->append (undef); $child_model->set ($child_iter, 0 => 'Bla'); my $model = Gtk3::TreeModelSort->new_with_model ($child_model); isa_ok ($model, 'Gtk3::TreeModelSort'); my $iter = $model->convert_child_iter_to_iter ($child_iter); isa_ok ($iter, 'Gtk3::TreeIter'); is ($model->get ($iter, 0), 'Bla'); } # Gtk3::TreeSelection::get_selected SKIP: { skip 'Gtk3::TreeSelection; tree model ctors not properly supported', 3 unless check_gi_version(1, 29, 17); my $model = Gtk3::ListStore->new ('Glib::String'); my $view = Gtk3::TreeView->new ($model); my $selection = $view->get_selection; my $iter = $model->append; $selection->select_iter ($iter); my ($sel_model, $sel_iter) = $selection->get_selected; is ($sel_model, $model); isa_ok ($sel_iter, 'Gtk3::TreeIter'); $sel_iter = $selection->get_selected; isa_ok ($sel_iter, 'Gtk3::TreeIter'); } # Gtk3::TreeView::insert_column_with_attributes, get_dest_row_at_pos, # get_path_at_pos, get_tooltip_context, get_visible_range SKIP: { skip 'Gtk3::TreeView; tree model ctors not properly supported', 5 unless check_gi_version(1, 29, 17); my $model = Gtk3::ListStore->new ('Glib::String'); $model->insert_with_values (-1, 0 => 'Test string'); my $view = Gtk3::TreeView->new ($model); $view->insert_column_with_attributes (-1, 'String', Gtk3::CellRendererText->new, text => 0); my $column = $view->get_column (0); is ($column->get_title, 'String'); is_deeply ([$view->get_columns], [$column]); my $window = Gtk3::Window->new; $window->add ($view); $window->show_all; my @bin_pos = (0, 0); my @widget_pos = $view->convert_bin_window_to_widget_coords (@bin_pos); my @dest_stuff = $view->get_dest_row_at_pos (@widget_pos); is (@dest_stuff, 2); my @pos_stuff = $view->get_path_at_pos (@bin_pos); is (@pos_stuff, 4); my @tooltip_stuff = $view->get_tooltip_context (@widget_pos, Glib::TRUE); is (@tooltip_stuff, 5); # Nondeterministic: my @vis_paths = $view->get_visible_range; # is (@vis_paths, 2); # or sometimes 0 } # Gtk3::TreeViewColumn::new_with_attributes, set_attributes, cell_get_position SKIP: { skip 'Gtk3::TreeViewColumn; tree model ctors not properly supported', 2 unless check_gi_version(1, 29, 17); my $model = Gtk3::ListStore->new ('Glib::String'); $model->insert_with_values (-1, 0 => 'Test string'); my $renderer = Gtk3::CellRendererText->new; my $column = Gtk3::TreeViewColumn->new_with_attributes ( 'String', $renderer, text => 0); is ($column->get_title, 'String'); $column->set_attributes ($renderer, text => 0); my $view = Gtk3::TreeView->new ($model); $view->insert_column ($column, -1); my $window = Gtk3::Window->new; $window->add ($view); $window->show_all; my @cell_stuff = $column->cell_get_position ($renderer); is (@cell_stuff, 2); } # Gtk3::UIManager { my $ui_manager = Gtk3::UIManager->new; my $ui_info = <<__EOD__; __EOD__ ok ($ui_manager->add_ui_from_string ($ui_info) != 0); my $group_one = Gtk3::ActionGroup->new ("Barney"); my $group_two = Gtk3::ActionGroup->new ("Fred"); my @entries = ( [ "HelpMenu", undef, "_Help" ], [ "About", undef, "_About", "A", "About" ], [ "License", undef, "_License", "L", "License" ], ); $group_one->add_actions (\@entries, undef); $ui_manager->insert_action_group ($group_one, 0); $ui_manager->insert_action_group ($group_two, 1); is_deeply ([$ui_manager->get_action_groups], [$group_one, $group_two]); $ui_manager->ensure_update; my @menubars = $ui_manager->get_toplevels ("menubar"); is (@menubars, 2); isa_ok ($menubars[0], "Gtk3::MenuBar"); isa_ok ($menubars[1], "Gtk3::MenuBar"); } # Gtk3::Widget { my $widget = Gtk3::Label->new ("Test"); isa_ok ($widget->render_icon ("gtk-open", "menu", "detail"), "Gtk3::Gdk::Pixbuf"); } # Gtk3::Gdk::Atom SKIP: { skip 'atom stuff; missing annotations', 2 unless Gtk3::CHECK_VERSION(3, 2, 0); my $atom1 = Gtk3::Gdk::Atom::intern("CLIPBOARD", Glib::FALSE); my $atom2 = Gtk3::Gdk::Atom::intern("CLIPBOARD", Glib::FALSE); my $atom3 = Gtk3::Gdk::Atom::intern("PRIMARY", Glib::FALSE); ok ($atom1 == $atom2); ok ($atom1 != $atom3); } # Gtk3::Gdk::RGBA { my $rgba = Gtk3::Gdk::RGBA->new ({red => 0.0, green => 0.5, blue => 0.5, alpha => 0.5}); isa_ok ($rgba, 'Gtk3::Gdk::RGBA'); is ($rgba->red, 0.0); $rgba = Gtk3::Gdk::RGBA->new (red => 0.5, green => 0.0, blue => 0.5, alpha => 0.5); isa_ok ($rgba, 'Gtk3::Gdk::RGBA'); is ($rgba->green, 0.0); $rgba = Gtk3::Gdk::RGBA->new (0.5, 0.5, 0.0, 0.5); isa_ok ($rgba, 'Gtk3::Gdk::RGBA'); is ($rgba->blue, 0.0); $rgba = Gtk3::Gdk::RGBA::parse ('rgba(0.5, 0.5, 0.5, 0.0)'); isa_ok ($rgba, 'Gtk3::Gdk::RGBA'); is ($rgba->alpha, 0.0); ok ($rgba->parse ('rgba(0.5, 0.5, 0.5, 1.0)')); is ($rgba->alpha, 1.0); } # Gtk3::Gdk::Window::new SKIP: { # https://bugzilla.gnome.org/show_bug.cgi?id=670369 skip 'Gtk3::Gdk::Window::new; window attr type annotation missing', 3 unless Gtk3::CHECK_VERSION (3, 6, 0); my $window = Gtk3::Gdk::Window->new (undef, { window_type => 'toplevel', }); isa_ok ($window, 'Gtk3::Gdk::Window'); $window = Gtk3::Gdk::Window->new (undef, { window_type => 'toplevel', width => 100, height => 50, x => 100, y => 50, }, [qw/x y/]); isa_ok ($window, 'Gtk3::Gdk::Window'); $window = Gtk3::Gdk::Window->new (undef, { window_type => 'toplevel', width => 100, height => 50, x => 100, y => 50, }); isa_ok ($window, 'Gtk3::Gdk::Window'); } # Gtk3::Gdk::Pixbuf::get_formats { my @formats = Gtk3::Gdk::Pixbuf::get_formats; isa_ok ($formats[0], 'Gtk3::Gdk::PixbufFormat'); } # Gtk3::Gdk::Pixbuf::new_from_data SKIP: { skip 'Gtk3::Gdk::Pixbuf::new_from_data; incorrect annotations', 2; my ($width, $height) = (45, 89); my ($r, $g, $b) = (255, 0, 255); my $data = pack 'C*', (($r, $g, $b) x ($width*$height)); my $pixbuf = Gtk3::Gdk::Pixbuf->new_from_data ($data, 'rgb', Glib::FALSE, 8, $width, $height, $width*3); is ($pixbuf->get_byte_length, 3*$width*$height); is ($pixbuf->get_pixels, $data); } # Gtk3::Gdk::Pixbuf::save, save_to_buffer, save_to_callback SKIP: { skip 'pixbuf stuff; missing annotations', 19 unless Gtk3::Gdk::PIXBUF_MINOR >= 25; my ($width, $height) = (10, 5); my $pixbuf = Gtk3::Gdk::Pixbuf->new ('rgb', Glib::TRUE, 8, $width, $height); $pixbuf->fill (hex '0xFF000000'); my $expected_pixels = $pixbuf->get_pixels; my $filename = 'testsave.png'; END { unlink $filename if defined $filename; } eval { $pixbuf->save ($filename, 'png', 'key_arg_without_value_arg'); }; like ($@, qr/Usage/); my $mtime = scalar localtime; my $desc = 'Something really cool'; $pixbuf->save ($filename, 'png', 'tEXt::Thumb::MTime' => $mtime, 'tEXt::Description' => $desc); my $new_pixbuf = Gtk3::Gdk::Pixbuf->new_from_file ($filename); isa_ok ($new_pixbuf, 'Gtk3::Gdk::Pixbuf', 'new_from_file'); is ($new_pixbuf->get_option ('tEXt::Description'), $desc); is ($new_pixbuf->get_option ('tEXt::Thumb::MTime'), $mtime); is ($new_pixbuf->get_width, $width); is ($new_pixbuf->get_height, $height); is ($new_pixbuf->get_pixels, $expected_pixels); my $buffer = do { $pixbuf->save_to_buffer ('png', [qw/compression/], [9]); $pixbuf->save_to_buffer ('png', compression => 9); $pixbuf->save_to_buffer ('png'); }; ok (defined $buffer, 'save_to_buffer'); my $loader = Gtk3::Gdk::PixbufLoader->new; $loader->write ($buffer); $loader->close; $new_pixbuf = $loader->get_pixbuf; is ($new_pixbuf->get_width, $width); is ($new_pixbuf->get_height, $height); is ($new_pixbuf->get_pixels, $expected_pixels); my $callback_buffer = []; my $invocation_count = 0; ok ($pixbuf->save_to_callback (sub { my ($pixels, $length, $data) = @_; if (0 == $invocation_count++) { is ($length, scalar @$pixels); is ($pixels->[0], 137); is ($pixels->[7], 10); # PNG header is ($data, 'data'); } push @$callback_buffer, @$pixels; return Glib::TRUE, undef; }, 'data', 'png')); is_deeply ($callback_buffer, $buffer); skip 'Gtk3::Gdk::Pixbuf::save_to_callback; need error domain support', 2 unless check_gi_version (1, 29, 17); eval { $pixbuf->save_to_callback (sub { return Glib::FALSE, Gtk3::Gdk::PixbufError->new ('insufficient-memory', 'buzz'); }, undef, 'png'); }; my $error = $@; isa_ok ($error, 'Glib::Error'); is ($error->message, 'buzz'); } # Pango::Layout { my $label = Gtk3::Label->new ('Bla'); my $layout = $label->create_pango_layout ('Bla'); $layout->set_text('Bla bla.', 3); is ($layout->get_text, 'Bla'); $layout->set_text('Bla bla.'); is ($layout->get_text, 'Bla bla.'); } Gtk3-0.015/t/signals.t000644 001750 000024 00000001025 12251206043 014641 0ustar00brianstaff000000 000000 #!/usr/bin/env perl BEGIN { require './t/inc/setup.pl' }; use strict; use warnings; plan tests => 3; # Gtk3::Widget.size-allocate { my $window = Gtk3::Window->new; $window->show; my $alloc = {x => 10, y => 10, width => 100, height => 100}; my $data = [23, 42]; $window->signal_connect (size_allocate => sub { my ($cb_window, $cb_alloc, $cb_data) = @_; is ($cb_window, $window); is_deeply ($cb_alloc, $alloc); is_deeply ($cb_data, $data); }, $data); $window->signal_emit (size_allocate => $alloc); } Gtk3-0.015/t/vfuncs.t000644 001750 000024 00000001616 12251206043 014513 0ustar00brianstaff000000 000000 #!/usr/bin/env perl BEGIN { require './t/inc/setup.pl' }; use strict; use warnings; plan tests => 2; # Make sure that we can safely inherit from classes which have a "destroy" # vfunc. { my $label_destroy_called = 0; my $label_destroy_chain_called = 0; package MyLabel; use Glib::Object::Subclass Gtk3::Label:: ; # no DESTROY_VFUNC override package MyLabelDestroy; use Glib::Object::Subclass Gtk3::Label:: ; sub DESTROY_VFUNC { $label_destroy_called++; } package MyLabelDestroyChain; use Glib::Object::Subclass Gtk3::Label:: ; sub DESTROY_VFUNC { $label_destroy_chain_called++; $_[0]->SUPER::DESTROY_VFUNC (); } package main; { my $label = MyLabel->new; my $label_destroy = MyLabelDestroy->new; my $label_destroy_chan = MyLabelDestroyChain->new; } is ($label_destroy_called, 1); is ($label_destroy_chain_called, 1); } Gtk3-0.015/t/zz-GdkEvent.t000644 001750 000024 00000032363 12251206043 015362 0ustar00brianstaff000000 000000 #!/usr/bin/perl # Originally copied from Gtk2/t/GdkEvent.t. BEGIN { require './t/inc/setup.pl' } use strict; use warnings; plan tests => 142; sub fields_ok { my ($event, %fields_values) = @_; foreach my $field (keys %fields_values) { field_ok ($event, $field, $fields_values{$field}); } } sub field_ok { my ($event, $field, $value) = @_; $event->$field ($value); is ($event->$field, $value); } # Any ######################################################################### isa_ok (my $event = Gtk3::Gdk::Event->new ('enter-notify'), 'Gtk3::Gdk::Event', 'Gtk3::Gdk::Event->new any'); isa_ok ($event->copy, 'Gtk3::Gdk::Event'); is ($event->type, 'enter-notify'); my $window = Gtk3::Gdk::Window->new (undef, { width => 20, height => 20, window_type => 'toplevel' }); field_ok ($event, window => $window); field_ok ($event, window => undef); field_ok ($event, send_event => 23); my $screen = Gtk3::Gdk::Screen::get_default; $event->set_screen ($screen); is ($event->get_screen, $screen, '$event->get_screen'); my $device = Gtk3::Gdk::Display::get_default->list_devices->[0]; # FIXME? $event->set_device ($device); is ($event->get_device, $device, '$event->get_device'); $event->set_source_device ($device); is ($event->get_source_device, $device, '$event->get_source_device'); # Expose ####################################################################### isa_ok ($event = Gtk3::Gdk::Event->new ('expose'), 'Gtk3::Gdk::EventExpose', 'Gtk3::Gdk::Event->new expose'); field_ok ($event, count => 10); my $rect = {x => 0, y => 0, width => 100, height => 100}; # FIXME: [0, 0, 100, 100] $event->area ($rect); is_deeply ($event->area, $rect, '$expose_event->area'); my $region = Cairo::Region->create ($rect); $event->region ($region); isa_ok ($event->region, 'Cairo::Region', '$expose_event->region'); is_deeply ($event->region->get_rectangle (0), $rect); $event->region (undef); is ($event->region, undef, '$expose_event->region undef'); # Visibility ################################################################### isa_ok ($event = Gtk3::Gdk::Event->new ('visibility-notify'), 'Gtk3::Gdk::EventVisibility', 'Gtk3::Gdk::Event->new visibility'); field_ok ($event, state => 'partial'); # Motion ####################################################################### isa_ok ($event = Gtk3::Gdk::Event->new ('motion-notify'), 'Gtk3::Gdk::EventMotion', 'Gtk3::Gdk::Event->new motion'); fields_ok ($event, time => 42, x => 13, y => 14, x_root => 15, y_root => 16, state => [qw/shift-mask control-mask/], is_hint => 2); # FIXME: $event->axes not accessible currently field_ok ($event, device => $device); field_ok ($event, device => undef); is ($event->get_time, 42, '$event->get_time'); # FIXME: special case for get_time() # is (Gtk3::Gdk::Event::get_time (undef), 0, # "get_time with no event gets GDK_CURRENT_TIME, which is 0"); is ($event->get_state, [qw/shift-mask control-mask/], '$event->get_state'); is_deeply ([$event->get_coords], [13, 14], '$event->get_coords'); is_deeply ([$event->get_root_coords], [15, 16], '$event->get_root_coords'); is ($event->get_axis ("x"), 13); $event = Gtk3::Gdk::Event->new ('motion-notify'); $event->device ($device); $event->window ($window); SKIP: { skip 'request_motions; missing annotations', 0 unless Gtk3::CHECK_VERSION(3, 2, 0); $event->request_motions; } # Button ####################################################################### isa_ok ($event = Gtk3::Gdk::Event->new ('button-press'), 'Gtk3::Gdk::EventButton', 'Gtk3::Gdk::Event->new button'); fields_ok ($event, time => 42, x => 13, y => 14, x_root => 15, y_root => 16, state => [qw/shift-mask control-mask/], button => 2); # FIXME: $event->axes not accessible currently field_ok ($event, device => $device); field_ok ($event, device => undef); SKIP: { skip 'get_button&get_click_count; new in 3.2', 2 unless Gtk3::CHECK_VERSION(3, 2, 0); is ($event->get_button, 2); is ($event->get_click_count, 1); } # Scroll ####################################################################### isa_ok ($event = Gtk3::Gdk::Event->new ('scroll'), 'Gtk3::Gdk::EventScroll', 'Gtk3::Gdk::Event->new scroll'); fields_ok ($event, time => 42, x => 13, y => 14, x_root => 15, y_root => 16, state => [qw/shift-mask control-mask/], direction => 'down'); field_ok ($event, device => $device); field_ok ($event, device => undef); SKIP: { skip 'new 3.4 stuff', 2 unless Gtk3::CHECK_VERSION(3, 4, 0); $event->delta_x (17); $event->delta_y (18); is ($event->get_scroll_direction, 'down'); # skip 'direction&get_scroll_deltas; missing annotations', 1 unless Gtk3::CHECK_VERSION(3, 6, 0); $event->direction ('smooth'); is_deeply ([$event->get_scroll_deltas], [17, 18]); } # Key ########################################################################## isa_ok ($event = Gtk3::Gdk::Event->new ('key-press'), 'Gtk3::Gdk::EventKey', 'Gtk3::Gdk::Event->new key'); fields_ok ($event, time => 42, state => [qw/shift-mask control-mask/], keyval => 44, hardware_keycode => 10, group => 11, is_modifier => Glib::TRUE); SKIP: { skip 'keycode&keyval; new in 3.2', 2 unless Gtk3::CHECK_VERSION(3, 2, 0); is ($event->get_keycode, 10); is ($event->get_keyval, 44); } # Crossing ##################################################################### isa_ok ($event = Gtk3::Gdk::Event->new ('enter-notify'), 'Gtk3::Gdk::EventCrossing', 'Gtk3::Gdk::Event->new crossing'); fields_ok ($event, time => 42, x => 13, y => 14, x_root => 15, y_root => 16, mode => 'grab', detail => 'nonlinear', focus => Glib::TRUE, state => [qw/shift-mask control-mask/]); field_ok ($event, subwindow => $window); field_ok ($event, subwindow => undef); # Focus ######################################################################## isa_ok ($event = Gtk3::Gdk::Event->new ('focus-change'), 'Gtk3::Gdk::EventFocus', 'Gtk3::Gdk::Event->new focus'); fields_ok ($event, in => 10); # Configure #################################################################### isa_ok ($event = Gtk3::Gdk::Event->new ('configure'), 'Gtk3::Gdk::EventConfigure', 'Gtk3::Gdk::Event->new configure'); fields_ok ($event, x => 13, y => 14, width => 10, height => 10); # Property ##################################################################### isa_ok ($event = Gtk3::Gdk::Event->new ('property-notify'), 'Gtk3::Gdk::EventProperty', 'Gtk3::Gdk::Event->new property'); fields_ok ($event, time => 42); SKIP: { skip 'atom stuff; missing annotations', 3 unless Gtk3::CHECK_VERSION(3, 2, 0); my $atom = Gtk3::Gdk::Atom::intern ('foo', Glib::FALSE); $event->atom ($atom); isa_ok ($event->atom, 'Gtk3::Gdk::Atom', '$property_event->atom'); is ($event->atom->name, $atom->name, '$property_event->atom'); $event->atom (undef); is ($event->atom, undef); } SKIP: { # skip 'state accessor; missing annotations', 1 unless Gtk3::CHECK_VERSION (3, 6, 0); field_ok ($event, state => 'new-value'); } # Proximity #################################################################### isa_ok ($event = Gtk3::Gdk::Event->new ('proximity-in'), 'Gtk3::Gdk::EventProximity', 'Gtk3::Gdk::Event->new proximity'); fields_ok ($event, time => 42); field_ok ($event, device => $device); field_ok ($event, device => undef); # Setting ###################################################################### isa_ok ($event = Gtk3::Gdk::Event->new ('setting'), 'Gtk3::Gdk::EventSetting', 'Gtk3::Gdk::Event->new setting'); fields_ok ($event, action => 'new'); # FIXME: $event->name not accessible currently # WindowState ################################################################## isa_ok ($event = Gtk3::Gdk::Event->new ('window-state'), 'Gtk3::Gdk::EventWindowState', 'Gtk3::Gdk::Event->new windowstate'); fields_ok ($event, changed_mask => [qw/withdrawn above/], new_window_state => [qw/maximized sticky/]); # DND ########################################################################## isa_ok ($event = Gtk3::Gdk::Event->new ('drag-enter'), 'Gtk3::Gdk::EventDND', 'Gtk3::Gdk::Event->new dnd'); fields_ok ($event, time => 42, x_root => 15, y_root => 16); my $drag_context = Gtk3::Gdk::DragContext->new; field_ok ($event, context => $drag_context); field_ok ($event, context => undef); # Selection #################################################################### isa_ok ($event = Gtk3::Gdk::Event->new ('selection-clear'), 'Gtk3::Gdk::EventSelection', 'Gtk3::Gdk::Event->new selection'); fields_ok ($event, time => 42); SKIP: { skip 'atom stuff; missing annotations', 3 unless Gtk3::CHECK_VERSION(3, 2, 0); my $atom = Gtk3::Gdk::Atom::intern ('foo', Glib::FALSE); $event->property ($atom); is ($event->property->name, $atom->name); $event->selection ($atom); is ($event->selection->name, $atom->name); $event->target ($atom); is ($event->target->name, $atom->name); } field_ok ($event, requestor => $window); field_ok ($event, requestor => undef); # OwnerChange ################################################################## isa_ok ($event = Gtk3::Gdk::Event->new ("owner-change"), "Gtk3::Gdk::EventOwnerChange"); fields_ok ($event, reason => 'destroy', time => 42, selection_time => 42); field_ok ($event, owner => $window); field_ok ($event, owner => undef); SKIP: { skip 'atom stuff; missing annotations', 1 unless Gtk3::CHECK_VERSION(3, 2, 0); my $atom = Gtk3::Gdk::Atom::intern ('foo', Glib::FALSE); $event->selection ($atom); is ($event->selection->name, $atom->name); } # GrabBroken ################################################################## isa_ok ($event = Gtk3::Gdk::Event->new ("grab-broken"), "Gtk3::Gdk::EventGrabBroken"); fields_ok ($event, keyboard => Glib::TRUE, implicit => Glib::FALSE); field_ok ($event, grab_window => $window); field_ok ($event, grab_window => undef); # Touch ####################################################################### SKIP: { skip 'touch stuff; new in 3.4', 10 unless Gtk3::CHECK_VERSION(3, 4, 0); isa_ok ($event = Gtk3::Gdk::Event->new ("touch-begin"), "Gtk3::Gdk::EventTouch"); fields_ok ($event, time => 42, x => 13, y => 14, x_root => 15, y_root => 16, state => [qw/shift-mask control-mask/], emulating_pointer => Glib::TRUE); field_ok ($event, device => $device); field_ok ($event, device => undef); # FIXME: $event->axes not usable currently # FIXME: $event->sequence and get_event_sequence not usable currently } # Misc. ####################################################################### SKIP: { skip 'misc. stuff; missing annotations', 4 unless Gtk3::CHECK_VERSION(3, 2, 0); my $event = Gtk3::Gdk::Event->new ('button-press'); $event->put; ok (Gtk3::Gdk::events_pending); isa_ok (Gtk3::Gdk::Event::get (), 'Gtk3::Gdk::EventButton'); my $i_know_you = 0; Gtk3::Gdk::Event::handler_set (sub { return if $i_know_you++; my ($cb_event, $data) = @_; isa_ok ($cb_event, 'Gtk3::Gdk::EventButton'); # pass to gtk+ default handler Gtk3::main_do_event ($cb_event); }); $event->put; Gtk3::main_iteration while Gtk3::events_pending; # reset Gtk3::Gdk::Event::handler_set (undef); Gtk3::Gdk::set_show_events (Glib::FALSE); ok (!Gtk3::Gdk::get_show_events); } # Test that our custom event handling does not break callback marshalling due # to incorrect handling of the perl stack. { my $widget = Gtk3::Label->new ('Test'); $widget->signal_connect (key_press_event => sub { my ($cb_widget, $cb_event) = @_; is ($cb_widget, $widget); isa_ok ($cb_event, 'Gtk3::Gdk::EventKey'); is ($cb_event->keyval, 44); Glib::TRUE; }); my $event = Gtk3::Gdk::Event->new ('key-press'); $event->keyval (44); $widget->signal_emit (key_press_event => $event); } SKIP: { skip 'new 3.4 stuff', 1 unless Gtk3::CHECK_VERSION (3, 4, 0); my $event = Gtk3::Gdk::Event->new ('button-press'); $event->button (Gtk3::Gdk::BUTTON_SECONDARY ()); $event->window ($window); ok ($event->triggers_context_menu); } # FIXME: gdk_events_get_angle, gdk_events_get_center, gdk_events_get_distance # are misbound # { # my $event1 = Gtk3::Gdk::Event->new ('button-press'); # $event1->x (1); $event1->y (0); # my $event2 = Gtk3::Gdk::Event->new ('button-press'); # $event2->x (0); $event2->y (1); # warn join ', ', $event1->_get_angle ($event2); # warn join ', ', $event1->_get_center ($event2); # warn join ', ', $event1->_get_distance ($event2); # } __END__ Copyright (C) 2003-2012 by the gtk2-perl team (see the file AUTHORS for the full list). See LICENSE for more information. Gtk3-0.015/t/zz-GtkActionGroup.t000644 001750 000024 00000006641 12251206043 016553 0ustar00brianstaff000000 000000 #!/usr/bin/perl # Copied from Gtk2/t/GtkActionGroup.t BEGIN { require './t/inc/setup.pl' } use strict; use warnings; plan tests => 28; use Glib 'TRUE', 'FALSE'; my $action_group = Gtk3::ActionGroup->new ('Fred'); isa_ok ($action_group, 'Gtk3::ActionGroup'); is ($action_group->get_name, 'Fred'); $action_group->set_sensitive (1); is ($action_group->get_sensitive, 1); $action_group->set_visible (1); is ($action_group->get_visible, 1); my $action = Gtk3::Action->new ('Barney'); $action_group->add_action ($action); my @list = $action_group->list_actions; is (@list, 1); is ($list[0], $action); is ($action_group->get_action ('Barney'), $action); $action_group->remove_action ($action); @list = $action_group->list_actions; is (@list, 0); $action_group->add_action_with_accel ($action, undef); $action_group->remove_action ($action); $action_group->add_action_with_accel ($action, "a"); $action_group->remove_action ($action); my @action_entries = ( { name => 'open', stock_id => 'gtk-open', label => 'Open', accelerator => 'o', tooltip => 'Open something', callback => sub { ok (TRUE) }, }, { name => 'new', stock_id => 'gtk-new', }, { name => 'old', label => 'Old', }, [ 'close', 'gtk-close', 'Close', 'w', 'Close something', sub { ok (TRUE) } ], [ 'quit', 'gtk-quit', undef, 'q', ], [ 'sep', undef, 'blank', ], ); my @toggle_entries = ( [ "Bold", 'gtk-bold', "_Bold", # name, stock id, label "B", "Bold", # accelerator, tooltip \&activate_action, TRUE ], # is_active ); use constant COLOR_RED => 0; use constant COLOR_GREEN => 1; use constant COLOR_BLUE => 2; my @color_entries = ( # name, stock id, label, accelerator, tooltip, value [ "Red", undef, "_Red", "R", "Blood", COLOR_RED ], [ "Green", undef, "_Green", "G", "Grass", COLOR_GREEN ], [ "Blue", undef, "_Blue", "B", "Sky", COLOR_BLUE ], ); #$action_group->add_actions (\@action_entries, 42) $action_group->add_actions (\@action_entries); @list = $action_group->list_actions; is (@list, 6); $action_group->add_toggle_actions (\@toggle_entries, 42); #$action_group->add_toggle_actions (\@toggle_entries); @list = $action_group->list_actions; is (@list, 7); #$action_group->add_radio_actions (\@color_entries, COLOR_BLUE, \&on_change, 42); $action_group->add_radio_actions (\@color_entries, COLOR_GREEN, \&on_change); @list = $action_group->list_actions; is (@list, 10); $action_group->set_translation_domain("de_DE"); $action_group = Gtk3::ActionGroup->new ("Fred"); $action_group->set_translate_func(sub { my ($string, $data) = @_; is($string, "Urgs"); is($data, "bla"); return "Sgru"; }, "bla"); is($action_group->translate_string("Urgs"), "Sgru"); # as of 2.6.0 we have the ability to call the translation function # from add_*_actions like we're supposed to, so let's test that. # the following should result in 14 oks. $action_group->set_translate_func (sub { ok(TRUE, 'xlate'); reverse $_[0]; }); $action_group->add_actions (\@action_entries); $action_group->add_toggle_actions (\@toggle_entries, 42); $action_group->add_radio_actions (\@color_entries, COLOR_GREEN, \&on_change); __END__ Copyright (C) 2003-2005 by the gtk2-perl team (see the file AUTHORS for the full list). See LICENSE for more information. Gtk3-0.015/t/zz-GtkBuilder.t000644 001750 000024 00000012517 12251206043 015706 0ustar00brianstaff000000 000000 #!/usr/bin/perl # Copied from Gtk2/t/GtkBuilder.t BEGIN { require './t/inc/setup.pl' } use strict; use warnings; plan tests => 45; my $builder; my $ui = < 0 5 1 5 True adjustment1 EOD # --------------------------------------------------------------------------- # my $ui_file = 'tmp.ui'; open my $fh, '>', $ui_file or plan skip_all => 'unable to create ui file'; print $fh $ui; close $fh; $builder = Gtk3::Builder->new; isa_ok ($builder, 'Gtk3::Builder'); eval { $builder->add_from_file ('bla.ui'); }; like ($@, qr/bla\.ui/); eval { ok ($builder->add_from_file ($ui_file) > 0); }; is ($@, ''); isa_ok ($builder->get_object ('adjustment1'), 'Gtk3::Adjustment'); $builder->set_translation_domain (undef); is ($builder->get_translation_domain, undef); $builder->set_translation_domain ('de'); is ($builder->get_translation_domain, 'de'); { my $builder = Gtk3::Builder->new; eval { ok ($builder->add_objects_from_file ($ui_file, qw/adjustment1 spinbutton1/)); }; is ($@, ''); ok (defined $builder->get_object ('adjustment1') && defined $builder->get_object ('spinbutton1')); eval { $builder->add_objects_from_file ('bla.ui', qw/adjustment1 spinbutton1/); }; like ($@, qr/bla\.ui/); $builder = Gtk3::Builder->new; eval { ok ($builder->add_objects_from_string ($ui, qw/adjustment1 spinbutton1/)); }; is ($@, ''); ok (defined $builder->get_object ('adjustment1') && defined $builder->get_object ('spinbutton1')); eval { $builder->add_objects_from_string ('', qw/adjustment1 spinbutton1/); }; like ($@, qr/bla/); } unlink $ui_file; # --------------------------------------------------------------------------- # $builder = Gtk3::Builder->new; eval { $builder->add_from_string (''); }; like ($@, qr/bla/); eval { ok ($builder->add_from_string ($ui) > 0); }; is ($@, ''); my @objects = sort { ref $a cmp ref $b } $builder->get_objects; isa_ok ($objects[0], 'Gtk3::Adjustment'); isa_ok ($objects[1], 'Gtk3::SpinButton'); $builder->connect_signals_full(sub { my ($builder, $object, $signal_name, $handler_name, $connect_object, $flags, $data) = @_; if ($signal_name ne 'value-changed') { return; } isa_ok ($builder, 'Gtk3::Builder'); isa_ok ($object, 'Gtk3::SpinButton'); is ($signal_name, 'value-changed'); is ($handler_name, 'value_changed'); isa_ok ($connect_object, 'Gtk3::Adjustment'); ok ($flags == [ qw/after swapped/ ]); is ($data, 'data'); }, 'data'); # --------------------------------------------------------------------------- # package BuilderTestCaller; use Test::More; # for is(), isa_ok(), etc. use Glib qw/:constants/; sub value_changed { my ($spin, $data) = @_; isa_ok ($spin, 'Gtk3::SpinButton'); isa_ok ($data, 'Gtk3::Adjustment'); } sub wrapped { my ($spin, $data) = @_; isa_ok ($spin, 'Gtk3::SpinButton'); is ($data, '!alb'); } $builder = Gtk3::Builder->new; $builder->add_from_string ($ui); $builder->connect_signals ('!alb'); my $spin = $builder->get_object ('spinbutton1'); $spin->set_wrap (TRUE); $spin->spin ('step-forward', 1); # --------------------------------------------------------------------------- # package BuilderTest; use Test::More; # for is(), isa_ok(), etc. use Glib qw/:constants/; sub value_changed { my ($spin, $data) = @_; isa_ok ($spin, 'Gtk3::SpinButton'); isa_ok ($data, 'Gtk3::Adjustment'); } sub wrapped { my ($spin, $data) = @_; isa_ok ($spin, 'Gtk3::SpinButton'); is ($data, 'bla!'); } $builder = Gtk3::Builder->new; $builder->add_from_string ($ui); $builder->connect_signals ('bla!', 'BuilderTest'); $spin = $builder->get_object ('spinbutton1'); $spin->set_wrap (TRUE); $spin->spin ('step-forward', 1); # --------------------------------------------------------------------------- # package BuilderTestOO; use Test::More; # for is(), isa_ok(), etc. use Glib qw/:constants/; sub value_changed { my ($self, $spin, $data) = @_; is ($self->{answer}, 42); isa_ok ($spin, 'Gtk3::SpinButton'); isa_ok ($data, 'Gtk3::Adjustment'); } sub wrapped { my ($self, $spin, $data) = @_; is ($self->{answer}, 42); isa_ok ($spin, 'Gtk3::SpinButton'); is ($data, 'bla!'); } my $self = bless { answer => 42 }, 'BuilderTestOO'; $builder = Gtk3::Builder->new; $builder->add_from_string ($ui); $builder->connect_signals ('bla!', $self); $spin = $builder->get_object ('spinbutton1'); $spin->set_wrap (TRUE); $spin->spin ('step-forward', 1); # --------------------------------------------------------------------------- # $builder = Gtk3::Builder->new; $builder->add_from_string ($ui); $builder->connect_signals ('!alb', value_changed => \&BuilderTest::value_changed, wrapped => \&BuilderTestCaller::wrapped ); $spin = $builder->get_object ('spinbutton1'); $spin->set_wrap (TRUE); $spin->spin ('step-forward', 1); __END__ Copyright (C) 2007 by the gtk2-perl team Gtk3-0.015/t/zz-GtkCellLayoutIface.t000644 001750 000024 00000005114 12251206043 017320 0ustar00brianstaff000000 000000 #!/usr/bin/env perl BEGIN { require './t/inc/setup.pl' } use strict; use warnings; use Glib ':constants'; plan tests => 35; my $cell = Gtk3::CellRendererText->new (); my $layout = CustomCellLayout->new (); $layout->pack_start ($cell, TRUE); $layout->pack_end ($cell, FALSE); $layout->clear (); $layout->add_attribute ($cell, text => 42); $layout->clear_attributes ($cell); $layout->set_attributes ($cell, text => 42); $layout->reorder ($cell, 42); my @cells = $layout->get_cells (); is (scalar @cells, 2); isa_ok ($cells[0], 'Gtk3::CellRendererText'); isa_ok ($cells[1], 'Gtk3::CellRendererToggle'); SKIP: { skip 'tree model ctors not properly supported', 9 unless check_gi_version(1, 29, 17); my $callback = sub { my ($cb_layout, $cb_cell, $model, $iter, $data) = @_; is ($cb_layout, $layout); is ($cb_cell, $cell); isa_ok ($model, 'Gtk3::ListStore'); isa_ok ($iter, 'Gtk3::TreeIter'); is ($data, 'bla!'); }; $layout->set_cell_data_func ($cell, $callback, 'bla!'); $layout->set_cell_data_func ($cell, undef); } package CustomCellLayout; use strict; use warnings; use Glib ':constants'; use Test::More; use Glib::Object::Subclass Gtk3::Widget::, interfaces => [ Gtk3::CellLayout:: ], ; sub PACK_START { my ($self, $cell, $expand) = @_; isa_ok ($self, __PACKAGE__); isa_ok ($cell, 'Gtk3::CellRenderer'); is ($expand, TRUE); } sub PACK_END { my ($self, $cell, $expand) = @_; isa_ok ($self, __PACKAGE__); isa_ok ($cell, 'Gtk3::CellRenderer'); is ($expand, FALSE); } sub CLEAR { my ($self) = @_; isa_ok ($self, __PACKAGE__); } sub ADD_ATTRIBUTE { my ($self, $cell, $attribute, $column) = @_; isa_ok ($self, __PACKAGE__); isa_ok ($cell, 'Gtk3::CellRenderer'); is ($attribute, 'text'); is ($column, 42); } sub SET_CELL_DATA_FUNC { my ($self, $cell, $func, $data) = @_; isa_ok ($self, __PACKAGE__); isa_ok ($cell, 'Gtk3::CellRenderer'); if (defined $func) { my $model = Gtk3::ListStore->new (qw/Glib::String/); $func->($self, $cell, $model, $model->append (), $data); } } sub CLEAR_ATTRIBUTES { my ($self, $cell) = @_; isa_ok ($self, __PACKAGE__); isa_ok ($cell, 'Gtk3::CellRenderer'); } sub REORDER { my ($self, $cell, $position) = @_; isa_ok ($self, __PACKAGE__); isa_ok ($cell, 'Gtk3::CellRenderer'); is ($position, 42); } sub grow_the_stack { 0 .. 500 }; sub GET_CELLS { my ($self) = @_; isa_ok ($self, __PACKAGE__); $self->{cell_one} = Gtk3::CellRendererText->new; $self->{cell_two} = Gtk3::CellRendererToggle->new; my @list = grow_the_stack(); return [$self->{cell_one}, $self->{cell_two}]; } Gtk3-0.015/t/zz-GtkCellRendererIface.t000644 001750 000024 00000005520 12251206043 017612 0ustar00brianstaff000000 000000 #!/usr/bin/env perl BEGIN { require './t/inc/setup.pl' } use strict; use warnings; use Glib ':constants'; plan skip_all => 'tree model ctors not properly supported' unless check_gi_version(1, 29, 17); plan tests => 15; foreach my $package (qw/StandAlone InheritorC InheritorPerl/) { my ($cell, $view) = prepare_cell ($package); my ($min, $nat) = $cell->get_preferred_width ($view); ok (defined $min); ok (defined $nat); my $rect = { x => 5, y => 5, width => 10, height => 10 }; my $aligned_rect = $cell->get_aligned_area ($view, 'selected', $rect); ok (exists $aligned_rect->{x}); TODO: { local $SIG{__WARN__} = sub { warn $_[0] if -1 == index $_[0], 'Asked to hand out object' }; $cell->set (mode => 'editable'); $cell->set (editable => TRUE); my $event = Gtk3::Gdk::Event->new ("button-press"); my $editable = $cell->start_editing ($event, $view, "0", $rect, $rect, qw(selected)); isa_ok ($editable, "Gtk3::Entry"); local $TODO = 'ref-counting not quite right yet'; my $destroyed = FALSE; $editable->signal_connect (destroy => sub { $destroyed = TRUE }); undef $editable; ok ($destroyed, 'editable was destroyed'); } } sub prepare_cell { my ($package) = @_; my $model = Gtk3::ListStore->new ('Glib::String'); foreach (qw/foo fluffy flurble frob frobnitz ftang fire truck/) { my $iter = $model->append; $model->set ($iter, 0, $_); } my $view = Gtk3::TreeView->new ($model); my $cell = $package->new; my $column = Gtk3::TreeViewColumn->new_with_attributes ( 'stand-alone', $cell); $view->append_column ($column); return ($cell, $view); } { package StandAlone; use Glib::Object::Subclass Gtk3::CellRenderer::, properties => [ Glib::ParamSpec->boolean ( 'editable', 'editable', 'editable', Glib::FALSE, [qw/readable writable/], ), ], ; use Test::More; sub GET_PREFERRED_WIDTH { my ($cell, $widget) = @_; return (23, 42); } sub GET_ALIGNED_AREA { my ($cell, $widget, $flags, $cell_area) = @_; return $cell_area; } sub START_EDITING { my ($cell, $event, $widget, $path, $bg_area, $cell_area, $flags) = @_; return Gtk3::Entry->new; } } { package InheritorC; use Glib::Object::Subclass Gtk3::CellRendererText:: ; sub GET_PREFERRED_WIDTH { return shift->SUPER::GET_PREFERRED_WIDTH (@_); } sub GET_ALIGNED_AREA { return shift->SUPER::GET_ALIGNED_AREA (@_); } sub START_EDITING { return shift->SUPER::START_EDITING (@_); } } { package InheritorPerl; use Glib::Object::Subclass StandAlone:: ; sub GET_PREFERRED_WIDTH { return shift->SUPER::GET_PREFERRED_WIDTH (@_); } sub GET_ALIGNED_AREA { return shift->SUPER::GET_ALIGNED_AREA (@_); } sub START_EDITING { return shift->SUPER::START_EDITING (@_); } } Gtk3-0.015/t/zz-GtkContainer.t000644 001750 000024 00000013574 12251206043 016246 0ustar00brianstaff000000 000000 #!/usr/bin/perl -w # Originally copied from Gtk2/t/GtkDialog.t. BEGIN { require './t/inc/setup.pl' } use strict; use warnings; plan tests => 28; # we'll create some containers (windows and boxes are containers) and # mess around with some of the methods to make sure they do things. my $window = Gtk3::Window->new; my $vbox = Gtk3::VBox->new; is ($window->child_type, 'Gtk3::Widget', 'a window wants a widget'); # i think we'd know if $container->add didn't work $window->add ($vbox); ok (1, 'added a widget to the window'); $window->show_all; $window->set_focus_child($vbox); ok (1); is ($window->get_focus_child, $vbox); $window->set_focus_child (undef); is ($window->get_focus_child, undef); my $adjustment = Gtk3::Adjustment->new(0, 0, 100, 5, 10, 20); $window->set_focus_vadjustment($adjustment); is($window->get_focus_vadjustment, $adjustment); $window->set_focus_hadjustment($adjustment); is($window->get_focus_hadjustment, $adjustment); $window->resize_children; ok (1); $window->set_border_width(10); is($window->get_border_width, 10); # child_type returns undef when no more children may be added ok (!defined ($window->child_type), 'child_type returns undef when the container is full'); is ($window->get_child, $vbox, 'the window\'s child is set'); is ($vbox->child_type, 'Gtk3::Widget', 'a box wants a widget'); $vbox->pack_start (Gtk3::Label->new ("one"), 1, 1, 0); is ($vbox->child_type, 'Gtk3::Widget', 'a box is always hungry'); my $entry = Gtk3::Entry->new (); # let's dump in a few more quickly $vbox->pack_start (Gtk3::Button->new ("two"), 1, 1, 0); $vbox->pack_start (Gtk3::ToggleButton->new ("three"), 1, 1, 0); $vbox->pack_start (Gtk3::CheckButton->new ("four"), 1, 1, 0); $vbox->pack_start ($entry, 1, 1, 0); my @children = $vbox->get_children; is (scalar (@children), 5, 'we packed five children'); my @chain = $vbox->get_focus_chain; is (scalar (@chain), 0, 'we have not set a focus chain'); # set focus chain to focusable children in reverse order @chain = reverse map { $_->get_can_focus ? $_ : () } @children; $vbox->set_focus_chain (@chain); is_deeply ([$vbox->get_focus_chain], \@chain, 'focus chain took'); $vbox->unset_focus_chain; is_deeply ([$vbox->get_focus_chain], []); # togglebuttons suck. wipe them out... all of them. my $nremoved = 0; $vbox->foreach (sub { if ('Gtk3::ToggleButton' eq ref $_[0]) { $vbox->remove ($_[0]); $nremoved++; } }); is ($nremoved, 1, 'removed one toggle'); @children = $vbox->get_children; is (scalar (@children), 4, 'four children remain'); my $n_total = 0; $vbox->forall (sub { isa_ok ($_[0], Gtk3::Widget::); $n_total++; }); is ($n_total, 4, 'forall walks all children'); is ($vbox->get_resize_mode, 'parent'); $vbox->set_resize_mode ('queue'); is ($vbox->get_resize_mode, 'queue'); $vbox->check_resize; ok (1); $vbox->set_reallocate_redraws(1); ok (1); #------------------------------------------------------------------------------ # child_get() =for FIXME3 is_deeply ([$vbox->child_get ($entry, qw(expand fill pack-type padding position))], [1, 1, "start", 0, 4]); $vbox->child_set ($entry, expand => 0, position => 2); $vbox->child_set_property ($entry, fill => 0); is_deeply ([$vbox->child_get_property ($entry, qw(expand fill pack-type padding position))], [0, 0, "start", 0, 2]); my $label = Gtk3::Label->new ("Blub"); $vbox->add_with_properties ($label, pack_type => "end", position => 4); is_deeply ([$vbox->child_get ($label, qw(pack-type position))], ["end", 4]); $vbox->remove ($label); =cut #------------------------------------------------------------------------------ # find_child_property() =for FIXME3 is (Gtk3::Container->find_child_property('Gtk3-Perl-test-no-such-property'), undef, 'find_child_property() no such child property'); is (eval { Gtk3::Container::find_child_property('Not::A::Container::Class', 'propname'); 1 }, undef, 'find_child_property() Not::A::Container::Class croaks'); is (eval { Gtk3::Container::find_child_property('Gtk3::Widget', 'propname'); 1 }, undef, 'find_child_property() Gtk3::Widget croaks'); { my $pspec = Gtk3::Box->find_child_property('expand'); isa_ok ($pspec, 'Glib::Param::Boolean', 'find_child_property() "expand" is a boolean'); require Scalar::Util; Scalar::Util::weaken($pspec); is ($pspec, undef, 'find_child_property() destroyed when weakened'); } { my $hbox = Gtk3::HBox->new; my $pspec = $hbox->find_child_property('expand'); isa_ok ($pspec, 'Glib::Param::Boolean', 'find_child_property() object method "expand" is a boolean'); } =cut #------------------------------------------------------------------------------ # list_child_properties() =for FIXME3 # as of Gtk 2.20 the base Gtk3::Container class doesn't have any child # properties, but don't assume that, so don't ask anything of @pspecs, just # that list_child_properties() returns my @pspecs = Gtk3::Container->list_child_properties; is (eval { Gtk3::Container::list_child_properties('Not::A::Container::Class'); 1 }, undef, 'list_child_properties() Not::A::Container::Class croaks'); is (eval { Gtk3::Container::list_child_properties('Gtk3::Widget'); 1 }, undef, 'list_child_properties() Gtk3::Widget croaks'); { my @pspecs = Gtk3::Box->list_child_properties; cmp_ok (scalar(@pspecs), '>=', 2, 'list_child_properties() at least "expand" and "pack"'); require Scalar::Util; foreach (@pspecs) { Scalar::Util::weaken($_); } my $all_undef = 1; foreach (@pspecs) { if ($_) { $all_undef = 0; } } is ($all_undef, 1, 'list_child_properties() pspecs destroyed when weakened'); } { my $hbox = Gtk3::HBox->new; my @pspecs = $hbox->list_child_properties; cmp_ok (scalar(@pspecs), '>=', 2, 'list_child_properties() object method at least "expand" and "pack"'); } =cut __END__ Copyright (C) 2003-2012 by the gtk2-perl team (see the file AUTHORS for the full list). See LICENSE for more information. Gtk3-0.015/t/zz-GtkDialog.t000644 001750 000024 00000005371 12251206043 015517 0ustar00brianstaff000000 000000 #!/usr/bin/env perl # # Based on Gtk2/t/GtkDialog.t # BEGIN { require './t/inc/setup.pl' }; use strict; use warnings; plan tests => 15; my $win = Gtk3::Window->new ('toplevel'); # a constructor-made dialog, run my $d1 = Gtk3::Dialog->new ('Test Dialog', $win, [qw/destroy-with-parent/], 'gtk-cancel', 2, 'gtk-quit', 3); my $btn1 = $d1->add_button ('Another', 4); Glib::Idle->add (sub { $btn1->clicked; 0; }); is ($d1->run, 4); $d1->hide; # a hand-made dialog, run my $d2 = Gtk3::Dialog->new; $d2->add_button ('First Button', 0); my $btn2 = $d2->add_button ('gtk-ok', 1); $d2->add_buttons ('gtk-cancel', 2, 'gtk-quit', 3, 'Last Button', 4); $d2->add_action_widget (Gtk3::Button->new('Uhh'), 'help'); $d2->set_default_response ('cancel'); $d2->set_response_sensitive (4, Glib::TRUE); $d2->signal_connect (response => sub { is ($_[1], 1); 1; }); Glib::Idle->add (sub { $btn2->clicked; 0; }); is ($d2->run, 1); $d2->hide; # a constructor-made dialog, show my $d3 = Gtk3::Dialog->new_with_buttons ('Test Dialog', $win, [qw/destroy-with-parent/], 'gtk-ok', 22, 'gtk-quit', 33); my $btn3 = $d3->add_button('Another', 44); my $btn4 = $d3->add_button('Help', 'help'); $d3->set_response_sensitive ('help', Glib::TRUE); is ($d3->get_response_for_widget ($btn3), 44); is ($d3->get_response_for_widget ($btn4), 'help'); is ($d3->get_widget_for_response (44), $btn3); is ($d3->get_widget_for_response ('help'), $btn4); $d3->get_content_area->pack_start (Gtk3::Label->new ('This is just a test.'), 0, 0, 0); $d3->get_action_area->pack_start (Gtk3::Label->new ('<- Actions'), 0, 0, 0); $d3->signal_connect (response => sub { is ($_[1], 44); 1; }); $btn3->clicked; # make sure that known response types are converted to strings for the reponse # signal of Gtk3::Dialog and its ancestors SKIP: { skip 'Need generic signal marshaller', 4 unless check_gi_version (1, 33, 10); foreach my $package (qw/Gtk3::Dialog Gtk3::AboutDialog/) { my $d = $package->new; my $b = $d->add_button ('First Button', 'ok'); $d->signal_connect (response => sub { is ($_[1], 'ok', "$package response"); Gtk3::EVENT_STOP; }); Glib::Idle->add( sub { $b->clicked; Glib::SOURCE_REMOVE; }); is ($d->run, 'ok', "$package run"); $d->hide; } } { my $d = Gtk3::Dialog->new; $d->set_alternative_button_order (2, 3); $d->set_alternative_button_order (qw(ok cancel accept), 3); $d->set_alternative_button_order; my $screen = Gtk3::Gdk::Screen::get_default; ok (defined Gtk3::alternative_dialog_button_order ($screen)); ok (defined Gtk3::alternative_dialog_button_order (undef)); ok (defined Gtk3::alternative_dialog_button_order); } Gtk3-0.015/t/zz-GtkImage.t000644 001750 000024 00000012573 12251206043 015344 0ustar00brianstaff000000 000000 #!/usr/bin/perl # # Originally copied from Gtk2/t/GtkImage.t # BEGIN { require './t/inc/setup.pl' } use strict; use warnings; plan tests => 36; # borrowed from xsane-icons.c my @pixbuf_data = ( " 20 20 4 1", " none", ". c #000000", "+ c #208020", "a c #ffffff", " ", " ................. ", " .+++++++++++++++. ", " .+ . +. ", " .+ ... +. ", " .+ . . . +. ", " .+ . +. ", " .+ . +. ", " .+ . . . +. ", " .+ . . . +. ", " .+.............+. ", " .+ . . . +. ", " .+ . . . +. ", " .+ . +. ", " .+ . . . +. ", " .+ ... +. ", " .+ . +. ", " .+++++++++++++++. ", " ................. ", " ", ); my $pixbuf = Gtk3::Gdk::Pixbuf->new_from_xpm_data (@pixbuf_data); # Plain old new ################################################################ ok (my $img = Gtk3::Image->new, 'Gtk3::Image->new'); my @ret = $img->get_icon_set; is (scalar (@ret), 2); is ($ret[0], undef); ok (defined $ret[1]); # unpredictable is ($img->get_pixbuf, undef, 'get_pixbuf empty'); @ret = $img->get_stock (); is (scalar (@ret), 2); is ($ret[0], undef); ok (defined $ret[1]); # unpredictable is ($img->get_animation, undef, 'get_animation empty'); is ($img->get_storage_type, 'empty', 'get_storage_type empty'); # new from stock ############################################################### ok ($img = Gtk3::Image->new_from_stock ('gtk-cancel', 'menu'), 'Gtk3::Image->new_from_stock'); is ($img->get_storage_type, 'stock', 'new_from_stock get_storage_type'); is_deeply ([$img->get_stock ()], ['gtk-cancel', 'menu'], 'new_from_stock get_stock'); # new from icon set ############################################################ my $iconset = Gtk3::IconSet->new_from_pixbuf ($pixbuf); ok ($img = Gtk3::Image->new_from_icon_set ($iconset, 'small-toolbar'), 'Gtk3::Image->new_from_icon_set'); @ret = $img->get_icon_set; is (scalar (@ret), 2, 'new_from_icon_set get_icon_set num rets'); isa_ok ($ret[0], 'Gtk3::IconSet', 'new_from_icon_set get_icon_set icon_set'); is ($ret[1], 'small-toolbar', 'new_from_icon_set get_icon_set size'); # new from pixbuf ############################################################## ok ($img = Gtk3::Image->new_from_pixbuf ($pixbuf), 'Gtk3::Image->new_from_pixbuf'); isa_ok ($img->get_pixbuf, 'Gtk3::Gdk::Pixbuf', 'new_from_pixbuf get_pixbuf'); # set from stock ############################################################### $img->set_from_stock ('gtk-quit', 'dialog'); is ($img->get_storage_type, 'stock', 'set_from_stock get_storage_type'); is_deeply ([$img->get_stock ()], ['gtk-quit', 'dialog'], 'set_from_stock get_stock'); # set from icon set ############################################################ $img->set_from_icon_set ($iconset, 'small-toolbar'); @ret = $img->get_icon_set; is (scalar (@ret), 2, 'set_from_icon_set get_icon_set num rets'); isa_ok ($ret[0], 'Gtk3::IconSet', 'set_from_icon_set get_icon_set icon_set'); is ($ret[1], 'small-toolbar', 'set_from_icon_set get_icon_set size'); # set from pixbuf ############################################################## $img->set_from_pixbuf (undef); $img->set_from_pixbuf ($pixbuf); isa_ok ($img->get_pixbuf, 'Gtk3::Gdk::Pixbuf', 'set_from_pixbuf get_pixbuf'); # These require access to a file, so they may be skipped my $testfile = './gtk-demo/gnome-foot.png'; SKIP: { skip "unable to find test file, $testfile", 7 unless (-R $testfile); my $animation = Gtk3::Gdk::PixbufAnimation->new_from_file ($testfile); # new from file ############################################################## ok ($img = Gtk3::Image->new_from_file (''), 'Gtk3::Image->new_from_file undef'); ok ($img = Gtk3::Image->new_from_file ($testfile), 'Gtk3::Image->new_from_file'); isa_ok ($img->get_pixbuf, 'Gtk3::Gdk::Pixbuf', 'new_from_file get_pixbuf'); # new from animation ######################################################### ok ($img = Gtk3::Image->new_from_animation ($animation), 'Gtk3::Image->new_from_animation'); isa_ok ($img->get_animation, 'Gtk3::Gdk::PixbufAnimation', 'new_from_animation get_animationf'); # set from file ############################################################## $img->set_from_file (undef); $img->set_from_file ($testfile); isa_ok ($img->get_pixbuf, 'Gtk3::Gdk::Pixbuf', 'set_from_file get_pixbuf'); # set from animation ######################################################### $img->set_from_animation ($animation); isa_ok ($img->get_animation, 'Gtk3::Gdk::PixbufAnimation', 'set_from_animation get_animation'); } $img = Gtk3::Image->new_from_icon_name ('gtk-ok', 'button'); isa_ok ($img, 'Gtk3::Image', 'new_from_icon_name isa Gtk3::Image'); is_deeply ([$img->get_icon_name], ['gtk-ok', 'button'], 'deep get_icon_name'); $img->set_from_icon_name ('gtk-cancel', 'menu'); is_deeply ([$img->get_icon_name], ['gtk-cancel', 'menu'], 'get_icon_name from Gtk3::Image set_from_icon_name'); $img->set_pixel_size (23); is ($img->get_pixel_size, 23, 'Gtk3::Image get_pixel_size'); $img->clear; __END__ Copyright (C) 2003-2013 by the gtk2-perl team (see the file AUTHORS for the full list). See LICENSE for more information. Gtk3-0.015/t/zz-GtkInfoBar.t000644 001750 000024 00000003624 12251206043 015637 0ustar00brianstaff000000 000000 #!/usr/bin/perl # # Originally copied from Gtk2/t/GtkInfoBar.t # BEGIN { require './t/inc/setup.pl' } use strict; use warnings; plan tests => 15; ok (my $win = Gtk3::Window->new ('toplevel')); my $infobar = Gtk3::InfoBar->new; isa_ok ($infobar, 'Gtk3::InfoBar', 'new'); $win->add ($infobar); isa_ok ($infobar->get_action_area, 'Gtk3::Widget', 'get_action_area'); isa_ok ($infobar->get_content_area, 'Gtk3::Widget', 'get_content_area'); isa_ok ($infobar->add_button (test3 => 3), 'Gtk3::Widget', 'add_button'); is (button_count ($infobar), 1, 'add_button count'); $infobar->add_buttons (test4 => 4, test5 => 5); is (button_count ($infobar), 3, 'add_buttons'); my $button = Gtk3::Button->new ('action_widget'); $infobar->add_action_widget ($button, 6); is (button_count ($infobar), 4, 'add_action_widget'); my $infobar2 = Gtk3::InfoBar->new( 'gtk-ok' => 'ok', 'test2' => 2, ); isa_ok ($infobar2, 'Gtk3::InfoBar', 'new_with_buttons'); is (button_count ($infobar2), 2, 'new_with_buttons buttons count'); $infobar->set_response_sensitive (6, Glib::FALSE); is ($button->is_sensitive, Glib::FALSE, 'set_response_sensitive'); $infobar->set_message_type ('error'); is ($infobar->get_message_type, 'error', '[gs]et_message_type'); $infobar->set_default_response (4); ok (1, 'set_default_response'); SKIP: { skip 'Need generic signal marshaller', 2 unless check_gi_version (1, 33, 10); $infobar->signal_connect (response => sub { my ($infobar,$response) = @_; my $expected = $infobar->{expected_response}; ok ($response eq $expected, "response '$expected'"); 1; }); $infobar->response ($infobar->{expected_response} = 5); $infobar->response ($infobar->{expected_response} = 'ok'); } sub button_count { my @b = $_[0]->get_action_area->get_children; return scalar @b; } __END__ Copyright (C) 2003-2013 by the gtk2-perl team (see the file AUTHORS for the full list). See LICENSE for more information. Gtk3-0.015/t/zz-GtkRadioAction.t000644 001750 000024 00000002732 12251206043 016512 0ustar00brianstaff000000 000000 #!/usr/bin/perl # Based on Gtk2/t/GtkRadioAction.t BEGIN { require './t/inc/setup.pl' } use strict; use warnings; plan tests => 14; my @actions = (Gtk3::RadioAction->new ('one', undef, undef, undef, 0)); isa_ok ($actions[$#actions], 'Gtk3::RadioAction'); my $i = 1; foreach (qw(two three four five)) { push @actions, Gtk3::RadioAction->new ($_, undef, undef, undef, $i++); $actions[$#actions]->set (group => $actions[$#actions-1]); isa_ok ($actions[$#actions], 'Gtk3::RadioAction'); } my $group = $actions[0]->get_group; push @actions, Gtk3::RadioAction->new ('six', undef, undef, undef, 5); isa_ok ($actions[$#actions], 'Gtk3::RadioAction'); $actions[$#actions]->set_group ($group); { # get_group() no memory leaks in arrayref return and array items my $x = Gtk3::RadioAction->new ('x', undef, undef, undef, 0); my $y = Gtk3::RadioAction->new ('y', undef, undef, undef, 0); $y->set_group($x); my $aref = $x->get_group; is_deeply($aref, [$x,$y]); require Scalar::Util; Scalar::Util::weaken ($aref); is ($aref, undef, 'get_group() array destroyed by weakening'); Scalar::Util::weaken ($x); is ($x, undef, 'get_group() item x destroyed by weakening'); Scalar::Util::weaken ($y); is ($y, undef, 'get_group() item y destroyed by weakening'); } is ($actions[0]->get_current_value, 0); $actions[0]->set_current_value (3); is ($actions[0]->get_current_value, 3); $actions[3]->set_active (Glib::TRUE); ok (!$actions[0]->get_active); ok ($actions[3]->get_active); Gtk3-0.015/t/zz-GtkRadioButton.t000644 001750 000024 00000004106 12251206043 016545 0ustar00brianstaff000000 000000 #!/usr/bin/perl BEGIN { require './t/inc/setup.pl' } use strict; use warnings; plan tests => 11; { my $item_one = Gtk3::RadioButton -> new(); isa_ok($item_one, "Gtk3::RadioButton"); my $item_two = Gtk3::RadioButton -> new($item_one -> get_group()); isa_ok($item_two, "Gtk3::RadioButton"); my $item_three = Gtk3::RadioButton -> new_with_label([], "Bla"); isa_ok($item_three, "Gtk3::RadioButton"); my $item_four = Gtk3::RadioButton -> new_with_mnemonic([$item_one, $item_two], "_Bla"); isa_ok($item_four, "Gtk3::RadioButton"); $item_three -> set_group($item_one -> get_group()); is_deeply($item_one -> get_group(), [$item_one, $item_two, $item_three, $item_four]); my $item_five = Gtk3::RadioButton -> new_from_widget($item_one); isa_ok($item_five, "Gtk3::RadioButton"); my $item_six = Gtk3::RadioButton -> new_with_label_from_widget($item_two, "Bla"); isa_ok($item_six, "Gtk3::RadioButton"); my $item_seven = Gtk3::RadioButton -> new_with_mnemonic_from_widget($item_three, "_Bla"); isa_ok($item_seven, "Gtk3::RadioButton"); is_deeply($item_one -> get_group(), [$item_one, $item_two, $item_three, $item_four, $item_five, $item_six, $item_seven]); } { my $item_one = Gtk3::RadioButton -> new_from_widget(undef); my $item_two = Gtk3::RadioButton -> new($item_one); my $item_three = Gtk3::RadioButton -> new_with_label($item_one, "Bla"); my $item_four = Gtk3::RadioButton -> new_with_mnemonic($item_one, "_Bla"); is_deeply($item_one -> get_group(), [$item_one, $item_two, $item_three, $item_four]); my $item_five = Gtk3::RadioButton -> new_from_widget($item_one); my $item_six = Gtk3::RadioButton -> new_with_label_from_widget($item_two, "Bla"); my $item_seven = Gtk3::RadioButton -> new_with_mnemonic_from_widget($item_three, "_Bla"); is_deeply($item_seven -> get_group(), [$item_one, $item_two, $item_three, $item_four, $item_five, $item_six, $item_seven]); } __END__ Copyright (C) 2003-2012 by the gtk2-perl team (see the file AUTHORS for the full list). See LICENSE for more information. Gtk3-0.015/t/zz-GtkRadioMenuItem.t000644 001750 000024 00000004356 12251206043 017024 0ustar00brianstaff000000 000000 #!/usr/bin/perl # Based on Gtk2/t/GtkRadioMenuItem.t BEGIN { require './t/inc/setup.pl' } use strict; use warnings; plan tests => 12; { my $item_one = Gtk3::RadioMenuItem -> new(); isa_ok($item_one, "Gtk3::RadioMenuItem"); my $item_two = Gtk3::RadioMenuItem -> new($item_one -> get_group()); isa_ok($item_two, "Gtk3::RadioMenuItem"); my $item_three = Gtk3::RadioMenuItem -> new_with_label([], "Bla"); isa_ok($item_three, "Gtk3::RadioMenuItem"); my $item_four = Gtk3::RadioMenuItem -> new_with_mnemonic([$item_one, $item_two], "_Bla"); isa_ok($item_four, "Gtk3::RadioMenuItem"); is_deeply($item_one -> get_group(), [$item_one, $item_two, $item_four]); $item_three -> set_group($item_one -> get_group()); is_deeply($item_one -> get_group(), [$item_one, $item_two, $item_three, $item_four]); my $item_five = Gtk3::RadioMenuItem -> new_from_widget($item_one); isa_ok($item_five, "Gtk3::RadioMenuItem"); my $item_six = Gtk3::RadioMenuItem -> new_with_label_from_widget($item_two, "Bla"); isa_ok($item_six, "Gtk3::RadioMenuItem"); my $item_seven = Gtk3::RadioMenuItem -> new_with_mnemonic_from_widget($item_three, "_Bla"); isa_ok($item_seven, "Gtk3::RadioMenuItem"); is_deeply($item_one -> get_group(), [$item_one, $item_two, $item_three, $item_four, $item_five, $item_six, $item_seven]); } { my $item_one = Gtk3::RadioMenuItem -> new_from_widget(undef); my $item_two = Gtk3::RadioMenuItem -> new($item_one); my $item_three = Gtk3::RadioMenuItem -> new_with_label($item_one, "Bla"); my $item_four = Gtk3::RadioMenuItem -> new_with_mnemonic($item_one, "_Bla"); is_deeply($item_one -> get_group(), [$item_one, $item_two, $item_three, $item_four]); my $item_five = Gtk3::RadioMenuItem -> new_from_widget($item_one); my $item_six = Gtk3::RadioMenuItem -> new_with_label_from_widget($item_two, "Bla"); my $item_seven = Gtk3::RadioMenuItem -> new_with_mnemonic_from_widget($item_three, "_Bla"); is_deeply($item_seven -> get_group(), [$item_one, $item_two, $item_three, $item_four, $item_five, $item_six, $item_seven]); } __END__ Copyright (C) 2003-2012 by the gtk2-perl team (see the file AUTHORS for the full list). See LICENSE for more information. Gtk3-0.015/t/zz-GtkRadioToolButton.t000644 001750 000024 00000003070 12251206043 017402 0ustar00brianstaff000000 000000 #!/usr/bin/perl # Based on Gtk2/t/GtkRadioToolButton.t BEGIN { require './t/inc/setup.pl' } use strict; use warnings; plan tests => 12; my $item = Gtk3::RadioToolButton -> new(); isa_ok($item, "Gtk3::RadioToolButton"); my $item_two = Gtk3::RadioToolButton -> new(undef); isa_ok($item_two, "Gtk3::RadioToolButton"); my $item_three = Gtk3::RadioToolButton -> new([$item, $item_two]); isa_ok($item_three, "Gtk3::RadioToolButton"); $item_two = Gtk3::RadioToolButton -> new_from_stock(undef, "gtk-quit"); isa_ok($item_two, "Gtk3::RadioToolButton"); $item_three = Gtk3::RadioToolButton -> new_from_stock([$item, $item_two], "gtk-quit"); isa_ok($item_three, "Gtk3::RadioToolButton"); $item = Gtk3::RadioToolButton -> new_from_widget($item_two); isa_ok($item, "Gtk3::RadioToolButton"); $item = Gtk3::RadioToolButton -> new_with_stock_from_widget($item_two, "gtk-quit"); isa_ok($item, "Gtk3::RadioToolButton"); $item = Gtk3::RadioToolButton -> new(); $item -> set_group([$item_two, $item_three]); is_deeply($item -> get_group(), [$item_two, $item_three]); { # get_group() no memory leaks in arrayref return and array items my $x = Gtk3::RadioToolButton->new; my $y = Gtk3::RadioToolButton->new; $y->set_group ($x); my $aref = $x->get_group; is_deeply ($aref, [$x,$y]); require Scalar::Util; Scalar::Util::weaken ($aref); is ($aref, undef, 'get_group() array destroyed by weakening'); Scalar::Util::weaken ($x); is ($x, undef, 'get_group() item x destroyed by weakening'); Scalar::Util::weaken ($y); is ($y, undef, 'get_group() item y destroyed by weakening'); } Gtk3-0.015/t/zz-GtkRecentChooserDialog.t000644 001750 000024 00000003035 12251206043 020176 0ustar00brianstaff000000 000000 #!/usr/bin/perl # # Originally copied from Gtk2/t/GtkRecentChooserDialog.t # BEGIN { require './t/inc/setup.pl' } use strict; use warnings; plan tests => 14; my $window = Gtk3::Window->new; my $manager = Gtk3::RecentManager->new; my $chooser = Gtk3::RecentChooserDialog->new ('Test', $window); isa_ok ($chooser, 'Gtk3::RecentChooser'); isa_ok ($chooser, 'Gtk3::RecentChooserDialog'); $chooser = Gtk3::RecentChooserDialog->new ('Test', undef); isa_ok ($chooser, 'Gtk3::RecentChooser'); isa_ok ($chooser, 'Gtk3::RecentChooserDialog'); $chooser = Gtk3::RecentChooserDialog->new_for_manager ('Test', $window, $manager); isa_ok ($chooser, 'Gtk3::RecentChooser'); isa_ok ($chooser, 'Gtk3::RecentChooserDialog'); $chooser = Gtk3::RecentChooserDialog->new_for_manager ('Test', undef, $manager); isa_ok ($chooser, 'Gtk3::RecentChooser'); isa_ok ($chooser, 'Gtk3::RecentChooserDialog'); $chooser = Gtk3::RecentChooserDialog->new ('Test', $window, 'gtk-ok' => 'ok'); isa_ok ($chooser, 'Gtk3::RecentChooser'); isa_ok ($chooser, 'Gtk3::RecentChooserDialog'); my @buttons = $chooser->get_action_area->get_children; is (scalar @buttons, 1); $chooser = Gtk3::RecentChooserDialog->new_for_manager ('Test', $window, $manager, 'gtk-ok' => 'ok', 'gtk-cancel' => 'cancel'); isa_ok ($chooser, 'Gtk3::RecentChooser'); isa_ok ($chooser, 'Gtk3::RecentChooserDialog'); @buttons = $chooser->get_action_area->get_children; is (scalar @buttons, 2); __END__ Copyright (C) 2003-2012 by the gtk2-perl team (see the file AUTHORS for the full list). See LICENSE for more information. Gtk3-0.015/t/zz-GtkTextBuffer.t000644 001750 000024 00000012306 12251206043 016372 0ustar00brianstaff000000 000000 #!/usr/bin/perl # Originally copied from Gtk2/t/GtkTextBuffer.t. BEGIN { require './t/inc/setup.pl' } use strict; use warnings; use utf8; use Glib qw/TRUE FALSE/; plan tests => 44; my $table = Gtk3::TextTagTable -> new(); my $buffer = Gtk3::TextBuffer -> new($table); isa_ok($buffer, "Gtk3::TextBuffer"); is($buffer -> get_tag_table(), $table); $buffer = Gtk3::TextBuffer -> new(); isa_ok($buffer, "Gtk3::TextBuffer"); isa_ok($buffer -> get_start_iter(), "Gtk3::TextIter"); isa_ok($buffer -> get_end_iter(), "Gtk3::TextIter"); $buffer -> set_modified(FALSE); # Use one multi-byte character to test length handling. my $text = "Lore ipsem dolor‽ I think that is misspelled.\n"; my $start = sub { $buffer -> get_start_iter() }; my $end = sub { $buffer -> get_end_iter() }; my $bounds = sub { $buffer -> get_bounds() }; $buffer -> insert($start->(), $text); ok($buffer -> insert_interactive($start->(), $text, TRUE)); $buffer -> insert_at_cursor($text); ok($buffer -> insert_interactive_at_cursor($text, TRUE)); $buffer -> insert_range($end->(), $bounds->()); ok($buffer -> insert_range_interactive($end->(), $bounds->(), TRUE)); my @tags = ($buffer -> create_tag("bla", indent => 2), $buffer -> create_tag("blub", indent => 2)); $buffer -> create_tag("blaa", indent => 2); $buffer -> create_tag("bluub", indent => 2); $buffer -> insert_with_tags($start->(), $text, @tags); $buffer -> insert_with_tags_by_name($start->(), $text, "blaa", "bluub"); is($buffer -> get_text($bounds->(), TRUE), $text x 18); is($buffer -> get_line_count(), 18+1); is($buffer -> get_char_count(), 18 * length $text); ok($buffer -> get_modified()); isa_ok($buffer -> get_iter_at_line_offset(1, 10), "Gtk3::TextIter"); isa_ok($buffer -> get_iter_at_offset(100), "Gtk3::TextIter"); isa_ok($buffer -> get_iter_at_line(6), "Gtk3::TextIter"); isa_ok($buffer -> get_iter_at_line_index(3, 12), "Gtk3::TextIter"); my ($start_iter, $end_iter) = $buffer -> get_bounds(); isa_ok($start_iter, "Gtk3::TextIter"); isa_ok($end_iter, "Gtk3::TextIter"); $buffer -> set_text($text); is($buffer -> get_text($bounds->(), TRUE), $text); is($buffer -> get_slice($bounds->(), TRUE), $text); $buffer -> delete($bounds->()); ok($buffer -> delete_interactive($bounds->(), TRUE)); $buffer -> insert_pixbuf($start->(), Gtk3::Gdk::Pixbuf -> new("rgb", 0, 8, 10, 10)); my $anchor = Gtk3::TextChildAnchor -> new(); $buffer -> insert_child_anchor($start->(), $anchor); isa_ok($buffer -> get_iter_at_child_anchor($anchor), "Gtk3::TextIter"); isa_ok($buffer -> create_child_anchor($start->()), "Gtk3::TextChildAnchor"); my $mark = $buffer -> create_mark("bla", $start->(), TRUE); isa_ok($mark, "Gtk3::TextMark"); is($buffer -> get_mark("bla"), $mark); isa_ok($buffer -> get_iter_at_mark($mark), "Gtk3::TextIter"); $buffer -> move_mark($mark, $end->()); $buffer -> move_mark_by_name("bla", $start->()); $buffer -> delete_mark($mark); $mark = $buffer -> create_mark("bla", $start->(), TRUE); $buffer -> delete_mark_by_name("bla"); isa_ok($buffer -> get_insert(), "Gtk3::TextMark"); isa_ok($buffer -> get_selection_bound(), "Gtk3::TextMark"); $buffer -> place_cursor($end->()); ok(!$buffer -> delete_selection(TRUE, TRUE)); ok(!$buffer -> get_selection_bounds()); { $buffer -> select_range($bounds->()); } my $tag_one = $buffer -> create_tag("alb", indent => 2, justification => 'center'); isa_ok($tag_one, "Gtk3::TextTag"); is($tag_one->get ('indent'), 2); is($tag_one->get ('justification'), 'center'); $buffer -> apply_tag($tag_one, $bounds->()); $buffer -> apply_tag_by_name("alb", $bounds->()); my $tag_two = $buffer -> create_tag("bulb", indent => 2); my $tag_three = $buffer -> create_tag(undef, indent => 2); isa_ok($tag_two, "Gtk3::TextTag"); isa_ok($tag_three, "Gtk3::TextTag"); $buffer -> remove_tag($tag_one, $bounds->()); $buffer -> remove_tag_by_name("bulb", $bounds->()); $buffer -> remove_all_tags($bounds->()); SKIP: { skip 'clipboard stuff; missing annotations', 0 unless Gtk3::CHECK_VERSION (3, 2, 0); my $clipboard = Gtk3::Clipboard::get(Gtk3::Gdk::Atom::intern('clipboard', Glib::FALSE)); $buffer -> paste_clipboard($clipboard, $buffer -> get_end_iter(), TRUE); $buffer -> paste_clipboard($clipboard, undef, TRUE); $buffer -> copy_clipboard($clipboard); $buffer -> cut_clipboard($clipboard, TRUE); $buffer -> add_selection_clipboard($clipboard); $buffer -> remove_selection_clipboard($clipboard); } $buffer -> begin_user_action(); $buffer -> end_user_action(); { $buffer -> backspace($end->(), TRUE, TRUE); } { my $bool = $buffer -> get_has_selection(); ok (1); my $targetlist = $buffer -> get_copy_target_list(); isa_ok($targetlist, 'Gtk3::TargetList'); $targetlist = $buffer -> get_paste_target_list(); isa_ok($targetlist, 'Gtk3::TargetList'); isa_ok($buffer -> get('copy-target-list'), 'Gtk3::TargetList'); isa_ok($buffer -> get('paste-target-list'), 'Gtk3::TargetList'); } { my $mark = Gtk3::TextMark -> new('bla', TRUE); $buffer -> add_mark($mark, $end->()); } { my $buf = Gtk3::TextBuffer -> new(); $buf -> set_text('v年x最y'); my ($s,$e) = $buf -> get_bounds(); ok($s -> forward_find_char(sub{shift eq '年'})); is($s -> get_char, '年'); ok(not $e -> backward_find_char(sub{shift eq '%'}, undef, $s)); is($e -> get_char, '年'); } Gtk3-0.015/t/zz-GtkTreeModelIface.t000644 001750 000024 00000032736 12251206043 017135 0ustar00brianstaff000000 000000 #!/usr/bin/perl BEGIN { require './t/inc/setup.pl' } use strict; use warnings; use Glib ':constants'; plan tests => 171; { package CustomList; use strict; use warnings; use Glib qw(TRUE FALSE); use Test::More; use Glib::Object::Subclass Glib::Object::, interfaces => [ Gtk3::TreeModel::, Gtk3::TreeSortable:: ], ; # one-time init: my %ordmap; { my $i = 0; %ordmap = map { $_ => $i++ } qw( First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh Twelfth Thirteenth Fourteenth Fifteenth Sixteenth Seventeenth Eighteenth Nineteenth Twentieth ); } sub INIT_INSTANCE { my ($list) = @_; isa_ok ($list, "CustomList", "INIT_INSTANCE: list"); $list->{data} = []; foreach my $val (sort { $ordmap{$a} <=> $ordmap{$b} } keys %ordmap) { my $record = { pos => $ordmap{$val}, value => $val }; push @{$list->{data}}, $record; } $list->{stamp} = 23; $list->{sort_column_id} = -1; $list->{sort_order} = "ascending"; } sub FINALIZE_INSTANCE { my ($list) = @_; isa_ok ($list, "CustomList", "FINALIZE_INSTANCE: list"); } sub GET_FLAGS { my ($list) = @_; isa_ok ($list, "CustomList", "GET_FLAGS: list"); return [ qw/list-only iters-persist/ ]; } sub GET_N_COLUMNS { my ($list) = @_; isa_ok ($list, "CustomList", "GET_N_COLUMNS: list"); # we don't actually have 23 columns, just 1 -- but the point here is # to test that the marshaling actually puts through the correct # number, not just nonzero. return 23; } sub GET_COLUMN_TYPE { my ($list, $column) = @_; isa_ok ($list, "CustomList", "GET_COLUMN_TYPE: list"); is ($column, 1, "GET_COLUMN_TYPE: column correct"); return Glib::String:: } sub GET_ITER { my ($list, $path) = @_; isa_ok ($list, "CustomList", "GET_ITER: list"); isa_ok ($path, "Gtk3::TreePath", "GET_ITER: path"); my @indices = $path->get_indices; my $depth = $path->get_depth; ok ($depth == 1, "GET_ITER: depth OK"); my $n = $indices[0]; ok ($n < @{$list->{data}}, "GET_ITER: first path index OK"); ok ($n > 0, "GET_ITER: first path index OK"); my $record = $list->{data}[$n]; ok (defined ($record), "GET_ITER: record defined"); ok ($record->{pos} == $n, "GET_ITER: record has the correct index"); return (TRUE, Gtk3::TreeIter->new (stamp => $list->{stamp}, user_data => $record)); } sub GET_PATH { my ($list, $iter) = @_; isa_ok ($list, "CustomList", "GET_PATH: list"); ok ($iter->stamp == $list->{stamp}, "GET_PATH: stamps agree"); my $record = $iter->user_data; my $path = Gtk3::TreePath->new; $path->append_index ($record->{pos}); return $path; } sub GET_VALUE { my ($list, $iter, $column) = @_; isa_ok ($list, "CustomList"); ok ($iter->stamp == $list->{stamp}, "GET_VALUE: stamps agree"); is ($column, 1, "GET_VALUE: column correct"); my $record = $iter->user_data; ok (defined ($record), "GET_VALUE: record defined"); ok ($record->{pos} < @{$list->{data}}, "GET_VALUE: record within bounds"); return Glib::Object::Introspection::GValueWrapper->new ( Glib::String::, $record->{value}); } sub ITER_NEXT { my ($list, $iter) = @_; isa_ok ($list, "CustomList", "ITER_NEXT: list"); ok ($iter->stamp == $list->{stamp}, "ITER_NEXT: stamps agree"); my $record = $iter->user_data; ok (defined ($record), "ITER_NEXT: record defined"); # Is this the last record in the list? return FALSE if $record->{pos} >= @{ $list->{data} }; my $nextrecord = $list->{data}[$record->{pos} + 1]; ok (defined ($nextrecord), "ITER_NEXT: next record defined"); ok ($nextrecord->{pos} == ($record->{pos} + 1), "ITER_NEXT: next record's pos OK"); $iter->user_data ($nextrecord); return TRUE; } sub ITER_CHILDREN { my ($list, $iter) = @_; isa_ok ($list, "CustomList", "ITER_CHILDREN: list"); # this is a list, nodes have no children return (FALSE, undef) if $iter; # parent == NULL is a special case; we need to return the first top-level row # No rows => no first row return (FALSE, undef) unless @{ $list->{data} }; # Set iter to first item in list return (TRUE, Gtk3::TreeIter->new (stamp => $list->{stamp}, user_data => $list->{data}[0])); } sub ITER_HAS_CHILD { my ($list, $iter) = @_; isa_ok ($list, "CustomList", "ITER_HAS_CHILD: list"); ok ($iter->stamp == $list->{stamp}, "ITER_HAS_CHILD: stamps agree"); return 'asdf'; } sub ITER_N_CHILDREN { my ($list, $iter) = @_; isa_ok ($list, "CustomList", "ITER_N_CHILDREN: list"); # special case: if iter == NULL, return number of top-level rows return scalar @{$list->{data}} if ! $iter; return 0; # otherwise, this is easy again for a list } sub ITER_NTH_CHILD { my ($list, $iter, $n) = @_; isa_ok ($list, "CustomList", "ITER_NTH_CHILD: list"); # a list has only top-level rows return (FALSE, undef) if $iter; # special case: if parent == NULL, set iter to n-th top-level row ok ($n < @{$list->{data}}, "ITER_NTH_CHILD: n bounded correctly"); my $record = $list->{data}[$n]; ok (defined ($record), "ITER_NTH_CHILD: record defined"); ok ($record->{pos} == $n, "ITER_NTH_CHILD: record's pos correct"); return (TRUE, Gtk3::TreeIter->new (stamp => $list->{stamp}, user_data => $record)); } sub ITER_PARENT { my ($list, $iter) = @_; isa_ok ($list, "CustomList", "ITER_PARENT: list"); return (FALSE, undef); } sub REF_NODE { my ($list, $iter) = @_; isa_ok ($list, "CustomList", "REF_NODE: list"); ok ($iter->stamp == $list->{stamp}, "REF_NODE: stamps agree"); } sub UNREF_NODE { my ($list, $iter) = @_; isa_ok ($list, "CustomList", "UNREF_NODE: list"); ok ($iter->stamp == $list->{stamp}, "UNREF_NODE: stamps agree"); } sub set { my $list = shift; my $iter = shift; isa_ok ($list, "CustomList", "set: list"); isa_ok ($iter, "Gtk3::TreeIter", "set: iter"); my ($col, $value) = @_; ok ($col == 1, "set: col OK"); my $record = $iter->user_data; $record->{value} = $value; } sub get_iter_from_ordinal { my $list = shift; my $ord = shift; isa_ok ($list, "CustomList", "get_iter_from_ordinal: list"); my $n = $ordmap{$ord}; my $record = $list->{data}[$n]; ok (defined ($record), "get_iter_from_ordinal: record is valid"); my $iter = Gtk3::TreeIter->new (stamp => $list->{stamp}, user_data => $record); isa_ok ($iter, "Gtk3::TreeIter", "get_iter_from_ordinal: iter"); return $iter; } ############################################################################### sub GET_SORT_COLUMN_ID { my ($list) = @_; isa_ok ($list, "CustomList", "GET_SORT_COLUMN_ID: list"); my $id = $list->{sort_column_id}; my $order = $list->{sort_order}; return $id >= 0, $id, $order; } sub SET_SORT_COLUMN_ID { my ($list, $id, $order) = @_; isa_ok ($list, "CustomList", "SET_SORT_COLUMN_ID: list"); is ($id, 3, "SET_SORT_COLUMN_ID: id OK"); is ($order, "descending", "SET_SORT_COLUMN_ID: order OK"); $list->{sort_column_id} = $id; $list->{sort_order} = $order; } sub SET_SORT_FUNC { my ($list, $id, $func, $data) = @_; isa_ok ($list, "CustomList", "SET_SORT_FUNC: list"); ok ($id == 2 || $id == 3, "SET_SORT_FUNC: id OK"); ok (defined $func, "SET_SORT_FUNC: func OK"); ok (defined $data, "SET_SORT_FUNC: data OK"); $list->{sort_funcs}->[$id] = [$func, $data]; } sub SET_DEFAULT_SORT_FUNC { my ($list, $func, $data) = @_; isa_ok ($list, "CustomList", "SET_DEFAULT_SORT_FUNC: list"); ok (defined $func, "SET_SORT_FUNC: func OK"); ok (defined $data, "SET_DEFAULT_SORT_FUNC: data OK"); $list->{sort_func_default} = [$func, $data]; } sub HAS_DEFAULT_SORT_FUNC { my ($list) = @_; isa_ok ($list, "CustomList", "HAS_DEFAULT_SORT_FUNC: list"); return defined $list->{sort_func_default}; } sub sort { my ($list, $id) = @_; my $a = $list->get_iter_from_string (1); my $b = $list->get_iter_from_string (2); if (exists $list->{sort_funcs}->[$id]) { my $func = $list->{sort_funcs}->[$id]->[0]; my $data = $list->{sort_funcs}->[$id]->[1]; is ($func->($list, $a, $b, $data), -1); } else { my $func = $list->{sort_func_default}->[0]; my $data = $list->{sort_func_default}->[1]; is ($func->($list, $a, $b, $data), 1); } } } { my $model = CustomList->new; ok ($model->get_flags eq [qw/iters-persist list-only/]); is ($model->get_n_columns, 23, "get_n_columns reports the number correctly"); is ($model->get_column_type (1), Glib::String::); my $path = Gtk3::TreePath->new ("5"); my $iter; isa_ok ($iter = $model->get_iter ($path), "Gtk3::TreeIter"); isa_ok ($path = $model->get_path ($iter), "Gtk3::TreePath"); is_deeply ([$path->get_indices], [5]); is ($model->get_value ($iter, 1), "Sixth"); is ($model->get ($iter, 1), "Sixth"); $model->iter_next ($iter); isa_ok ($path = $model->get_path ($iter), "Gtk3::TreePath"); is_deeply ([$path->get_indices], [6]); isa_ok ($iter = $model->iter_children(undef), "Gtk3::TreeIter"); isa_ok ($path = $model->get_path ($iter), "Gtk3::TreePath"); is_deeply ([$path->get_indices], [0]); is ($model->iter_has_child ($iter), TRUE); is ($model->iter_n_children ($iter), 0); isa_ok ($iter = $model->iter_nth_child (undef, 7), "Gtk3::TreeIter"); isa_ok ($path = $model->get_path ($iter), "Gtk3::TreePath"); is_deeply ([$path->get_indices], [7]); ok (not defined ($model->iter_parent ($iter))); isa_ok ($iter = $model->get_iter_from_ordinal ('Twelfth'), "Gtk3::TreeIter"); isa_ok ($path = $model->get_path ($iter), "Gtk3::TreePath"); is_deeply ([$path->get_indices], [11]); $model->set($iter, 1, '12th'); is ($model->get($iter, 1), '12th'); $model->ref_node ($iter); $model->unref_node ($iter); SKIP: { skip 'rows_reordered is not usable currently', 8; my $signal_finished = 0; my $len = @{$model->{data}}; my @array = (0 .. $len-1); my $id = $model->signal_connect (rows_reordered => sub { my ($s_model, $path, $iter, $aref) = @_; is ($s_model, $model); isa_ok ($path, "Gtk3::TreePath"); my @indices = $path->get_indices; is_deeply (\@indices, []); is ($iter, undef); is_deeply ($aref, \@array); $signal_finished = 1; }); $model->rows_reordered (Gtk3::TreePath->new, undef, @array); ok ($signal_finished, 'rows-reordered signal ran'); $model->signal_handler_disconnect ($id); } my $sorter_two = sub { my ($list, $a, $b, $data) = @_; isa_ok ($list, "CustomList"); isa_ok ($a, "Gtk3::TreeIter"); isa_ok ($b, "Gtk3::TreeIter"); is ($data, "tada"); return -1; }; my $sorter_three = sub { my ($list, $a, $b, $data) = @_; isa_ok ($list, "CustomList"); isa_ok ($a, "Gtk3::TreeIter"); isa_ok ($b, "Gtk3::TreeIter"); is ($data, "data"); return -1; }; my $default_sorter = sub { my ($list, $a, $b, $data) = @_; isa_ok ($list, "CustomList"); isa_ok ($a, "Gtk3::TreeIter"); isa_ok ($b, "Gtk3::TreeIter"); is ($data, "atad"); return 1; }; $model->set_sort_column_id (3, "descending"); is_deeply ([$model->get_sort_column_id], [TRUE, 3, "descending"]); $model->set_sort_func (2, $sorter_two, "tada"); $model->set_sort_func (3, $sorter_three, "data"); $model->set_default_sort_func ($default_sorter, "atad"); ok ($model->has_default_sort_func); $model->sort(2); $model->sort(3); $model->sort(23); # This should result in a call to FINALIZE_INSTANCE $model = undef; } ############################################################################### { package StackTestModel; use strict; use warnings; use Glib qw/TRUE FALSE/; use Glib::Object::Subclass Glib::Object::, interfaces => [ Gtk3::TreeModel::, Gtk3::TreeSortable:: ]; our @ROW = (100,200,300,400,500,600,700,800,900,1000); sub grow_the_stack { 1 .. 500; }; sub GET_N_COLUMNS { my @list = grow_the_stack(); return scalar @ROW; } sub GET_COLUMN_TYPE { return 'Glib::String'; } sub GET_ITER { return (TRUE, Gtk3::TreeIter->new (stamp => 123)); } sub GET_VALUE { my ($self, $iter, $col) = @_; my @list = grow_the_stack(); return Glib::Object::Introspection::GValueWrapper->new ( 'Glib::String', $ROW[$col]); } sub GET_SORT_COLUMN_ID { my @list = grow_the_stack(); return TRUE, 3, 'ascending'; } } { my $model = StackTestModel->new; is_deeply ([ $model->get ($model->get_iter_first) ], [ @StackTestModel::ROW ], '$model->get ($iter) does not result in stack corruption'); is_deeply ([ $model->get ($model->get_iter_first, reverse 0 .. 9) ], [ reverse @StackTestModel::ROW ], '$model->get ($iter, @columns) does not result in stack corruption'); is_deeply ([ $model->get_sort_column_id ], [ TRUE, 3, 'ascending' ], '$model->get_sort_column_id does not result in stack corruption'); } Gtk3-0.015/t/inc/setup.pl000644 001750 000024 00000000371 12251206043 015265 0ustar00brianstaff000000 000000 use Test::More; use Gtk3; if (!Gtk3::init_check ()) { plan skip_all => 'Gtk3::init_check failed'; } sub check_gi_version { my ($x, $y, $z) = @_; return !system ('pkg-config', "--atleast-version=$x.$y.$z", 'gobject-introspection-1.0'); } 1; Gtk3-0.015/lib/Gtk3.pm000644 001750 000024 00000147652 12251206043 014506 0ustar00brianstaff000000 000000 package Gtk3; { $Gtk3::VERSION = '0.015'; } use strict; use warnings; use Carp qw/croak/; use Cairo::GObject; use Glib::Object::Introspection; use Exporter; our @ISA = qw(Exporter); my $_GTK_BASENAME = 'Gtk'; my $_GTK_VERSION = '3.0'; my $_GTK_PACKAGE = 'Gtk3'; my $_GDK_BASENAME = 'Gdk'; my $_GDK_VERSION = '3.0'; my $_GDK_PACKAGE = 'Gtk3::Gdk'; my $_GDK_PIXBUF_BASENAME = 'GdkPixbuf'; my $_GDK_PIXBUF_VERSION = '2.0'; my $_GDK_PIXBUF_PACKAGE = 'Gtk3::Gdk'; my $_PANGO_BASENAME = 'Pango'; my $_PANGO_VERSION = '1.0'; my $_PANGO_PACKAGE = 'Pango'; # - gtk customization ------------------------------------------------------- # my %_GTK_NAME_CORRECTIONS = ( 'Gtk3::stock_add' => 'Gtk3::Stock::add', 'Gtk3::stock_add_static' => 'Gtk3::Stock::add_static', 'Gtk3::stock_list_ids' => 'Gtk3::Stock::list_ids', 'Gtk3::stock_lookup' => 'Gtk3::Stock::lookup', 'Gtk3::stock_set_translate_func' => 'Gtk3::Stock::set_translate_func', ); my @_GTK_FLATTEN_ARRAY_REF_RETURN_FOR = qw/ Gtk3::ActionGroup::list_actions Gtk3::Builder::get_objects Gtk3::CellLayout::get_cells Gtk3::Container::get_children Gtk3::SizeGroup::get_widgets Gtk3::Stock::list_ids Gtk3::TreePath::get_indices Gtk3::TreeView::get_columns Gtk3::UIManager::get_action_groups Gtk3::UIManager::get_toplevels Gtk3::Window::list_toplevels /; my @_GTK_HANDLE_SENTINEL_BOOLEAN_FOR = qw/ Gtk3::Stock::lookup Gtk3::TextBuffer::get_selection_bounds Gtk3::TreeModel::get_iter Gtk3::TreeModel::get_iter_first Gtk3::TreeModel::get_iter_from_string Gtk3::TreeModel::iter_children Gtk3::TreeModel::iter_nth_child Gtk3::TreeModel::iter_parent Gtk3::TreeModelFilter::convert_child_iter_to_iter Gtk3::TreeModelSort::convert_child_iter_to_iter Gtk3::TreeSelection::get_selected Gtk3::TreeView::get_dest_row_at_pos Gtk3::TreeView::get_path_at_pos Gtk3::TreeView::get_tooltip_context Gtk3::TreeView::get_visible_range Gtk3::TreeViewColumn::cell_get_position /; my @_GTK_USE_GENERIC_SIGNAL_MARSHALLER_FOR = ( ['Gtk3::Editable', 'insert-text'], ['Gtk3::Dialog', 'response', \&Gtk3::Dialog::_gtk3_perl_response_converter], ['Gtk3::InfoBar', 'response', \&Gtk3::Dialog::_gtk3_perl_response_converter], ); # GtkResponseType: id <-> nick my $_GTK_RESPONSE_ID_TO_NICK = sub { my ($id) = @_; { local $@; my $nick = eval { Glib::Object::Introspection->convert_enum_to_sv ( 'Gtk3::ResponseType', $id) }; return $nick if defined $nick; } return $id; }; my $_GTK_RESPONSE_NICK_TO_ID = sub { my ($nick) = @_; { local $@; my $id = eval { Glib::Object::Introspection->convert_sv_to_enum ( 'Gtk3::ResponseType', $nick) }; return $id if defined $id; } return $nick; }; # Converter for GtkDialog's "response" signal. sub Gtk3::Dialog::_gtk3_perl_response_converter { my ($dialog, $id) = @_; return ($dialog, $_GTK_RESPONSE_ID_TO_NICK->($id)); } # GtkIconSize: id <-> nick my $_GTK_ICON_SIZE_ID_TO_NICK = sub { my ($id) = @_; { local $@; my $nick = eval { Glib::Object::Introspection->convert_enum_to_sv ( 'Gtk3::IconSize', $id) }; return $nick if defined $nick; } { my $nick = Gtk3::IconSize::get_name ($id); return $nick if defined $nick; } return $id; }; my $_GTK_ICON_SIZE_NICK_TO_ID = sub { my ($nick) = @_; { local $@; my $id = eval { Glib::Object::Introspection->convert_sv_to_enum ( 'Gtk3::IconSize', $nick) }; return $id if defined $id; } { my $id = Gtk3::IconSize::from_name ($nick); return $id if $id;# if it's not zero } return $nick; }; # - gdk customization ------------------------------------------------------- # my @_GDK_HANDLE_SENTINEL_BOOLEAN_FOR = qw/ Gtk3::Gdk::Event::get_axis Gtk3::Gdk::Event::get_button Gtk3::Gdk::Event::get_click_count Gtk3::Gdk::Event::get_coords Gtk3::Gdk::Event::get_keycode Gtk3::Gdk::Event::get_keyval Gtk3::Gdk::Event::get_scroll_direction Gtk3::Gdk::Event::get_scroll_deltas Gtk3::Gdk::Event::get_state Gtk3::Gdk::Event::get_root_coords /; my %_GDK_REBLESSERS = ( 'Gtk3::Gdk::Event' => \&Gtk3::Gdk::Event::_rebless, ); my %_GDK_EVENT_TYPE_TO_PACKAGE = ( 'expose' => 'Expose', 'motion-notify' => 'Motion', 'button-press' => 'Button', 'button-2press' => 'Button', 'button-3press' => 'Button', 'button-release' => 'Button', 'key-press' => 'Key', 'key-release' => 'Key', 'enter-notify' => 'Crossing', 'leave-notify' => 'Crossing', 'focus-change' => 'Focus', 'configure' => 'Configure', 'property-notify' => 'Property', 'selection-clear' => 'Selection', 'selection-request' => 'Selection', 'selection-notify' => 'Selection', 'proximity-in' => 'Proximity', 'proximity-out' => 'Proximity', 'drag-enter' => 'DND', 'drag-leave' => 'DND', 'drag-motion' => 'DND', 'drag-status' => 'DND', 'drop-start' => 'DND', 'drop-finished' => 'DND', 'client-event' => 'Client', 'visibility-notify' => 'Visibility', 'no-expose' => 'NoExpose', 'scroll' => 'Scroll', 'window-state' => 'WindowState', 'setting' => 'Setting', 'owner-change' => 'OwnerChange', 'grab-broken' => 'GrabBroken', 'damage' => 'Expose', # added in 3.4: 'touch-begin' => 'Touch', 'touch-update' => 'Touch', 'touch-end' => 'Touch', 'touch-cancel' => 'Touch', ); # Make all of the above sub-types inherit from Gtk3::Gdk::Event. { no strict qw(refs); my %seen; foreach (grep { !$seen{$_}++ } values %_GDK_EVENT_TYPE_TO_PACKAGE) { push @{'Gtk3::Gdk::Event' . $_ . '::ISA'}, 'Gtk3::Gdk::Event'; } } sub Gtk3::Gdk::Event::_rebless { my ($event) = @_; my $package = 'Gtk3::Gdk::Event'; if (exists $_GDK_EVENT_TYPE_TO_PACKAGE{$event->type}) { $package .= $_GDK_EVENT_TYPE_TO_PACKAGE{$event->type}; } return bless $event, $package; } # - gdk-pixbuf customization ------------------------------------------------ # my @_GDK_PIXBUF_FLATTEN_ARRAY_REF_RETURN_FOR = qw/ Gtk3::Gdk::Pixbuf::get_formats /; # - Wiring ------------------------------------------------------------------ # sub import { my $class = shift; Glib::Object::Introspection->setup ( basename => $_GTK_BASENAME, version => $_GTK_VERSION, package => $_GTK_PACKAGE, name_corrections => \%_GTK_NAME_CORRECTIONS, flatten_array_ref_return_for => \@_GTK_FLATTEN_ARRAY_REF_RETURN_FOR, handle_sentinel_boolean_for => \@_GTK_HANDLE_SENTINEL_BOOLEAN_FOR, use_generic_signal_marshaller_for => \@_GTK_USE_GENERIC_SIGNAL_MARSHALLER_FOR); Glib::Object::Introspection->setup ( basename => $_GDK_BASENAME, version => $_GDK_VERSION, package => $_GDK_PACKAGE, handle_sentinel_boolean_for => \@_GDK_HANDLE_SENTINEL_BOOLEAN_FOR, reblessers => \%_GDK_REBLESSERS); Glib::Object::Introspection->setup ( basename => $_GDK_PIXBUF_BASENAME, version => $_GDK_PIXBUF_VERSION, package => $_GDK_PIXBUF_PACKAGE, flatten_array_ref_return_for => \@_GDK_PIXBUF_FLATTEN_ARRAY_REF_RETURN_FOR); Glib::Object::Introspection->setup ( basename => $_PANGO_BASENAME, version => $_PANGO_VERSION, package => $_PANGO_PACKAGE); Glib::Object::Introspection->_register_boxed_synonym ( "cairo", "RectangleInt", "gdk_rectangle_get_type"); # FIXME: This uses an undocumented interface for overloading to avoid the # need for a package declaration. Gtk3::Gdk::Atom->overload::OVERLOAD ( '==' => sub { ${$_[0]} == ${$_[1]} }, '!=' => sub { ${$_[0]} != ${$_[1]} }, fallback => 1); my $init = 0; my @unknown_args = ($class); foreach (@_) { if (/^-?init$/) { $init = 1; } else { push @unknown_args, $_; } } if ($init) { Gtk3::init (); } # call into Exporter for the unrecognized arguments; handles exporting and # version checking Gtk3->export_to_level (1, @unknown_args); } # - Overrides --------------------------------------------------------------- # sub Gtk3::CHECK_VERSION { return not defined Gtk3::check_version(@_ == 4 ? @_[1..3] : @_); } sub Gtk3::check_version { Glib::Object::Introspection->invoke ($_GTK_BASENAME, undef, 'check_version', @_ == 4 ? @_[1..3] : @_); } # Names "STOP" and "PROPAGATE" here are per the GtkWidget event signal # descriptions. In some other flavours of signals the jargon is "handled" # instead of "stop". "Handled" matches g_signal_accumulator_true_handled(), # though that function doesn't rate a mention in the Gtk docs. There's # nothing fixed in the idea of "true means cease emission" (whether it's # called "stop" or "handled"). You can just as easily have false for cease # (the way the underlying GSignalAccumulator func in fact operates). The # upshot being don't want to attempt to be too universal with the names # here; "EVENT" is meant to hint at the context or signal flavour they're # for use with. sub Gtk3::EVENT_PROPAGATE() { !1 }; sub Gtk3::EVENT_STOP() { 1 }; sub Gtk3::init { my $rest = Glib::Object::Introspection->invoke ( $_GTK_BASENAME, undef, 'init', [$0, @ARGV]); @ARGV = @{$rest}[1 .. $#$rest]; # remove $0 return; } sub Gtk3::init_check { my ($success, $rest) = Glib::Object::Introspection->invoke ( $_GTK_BASENAME, undef, 'init_check', [$0, @ARGV]); @ARGV = @{$rest}[1 .. $#$rest]; # remove $0 return $success; } sub Gtk3::main { # Ignore any arguments passed in. Glib::Object::Introspection->invoke ($_GTK_BASENAME, undef, 'main'); } sub Gtk3::main_level { # Ignore any arguments passed in. return Glib::Object::Introspection->invoke ($_GTK_BASENAME, undef, 'main_level'); } sub Gtk3::main_quit { # Ignore any arguments passed in. Glib::Object::Introspection->invoke ($_GTK_BASENAME, undef, 'main_quit'); } { my $global_about_dialog = undef; my $about_dialog_key = '__gtk3_about_dialog'; sub Gtk3::show_about_dialog { # For backwards-compatibility, optionally accept and discard a class # argument. my $parent_or_class = shift; my $parent = defined $parent_or_class && $parent_or_class eq 'Gtk3' ? shift : $parent_or_class; my %props = @_; my $dialog = defined $parent ? $parent->{$about_dialog_key} : $global_about_dialog; if (!$dialog) { $dialog = Gtk3::AboutDialog->new; $dialog->signal_connect (delete_event => sub { $dialog->hide_on_delete }); $dialog->signal_connect (response => sub { $dialog->hide }); foreach my $prop (keys %props) { $dialog->set ($prop => $props{$prop}); } if ($parent) { $dialog->set_modal (Glib::TRUE); $dialog->set_transient_for ($parent); $dialog->set_destroy_with_parent (Glib::TRUE); $parent->{$about_dialog_key} = $dialog; } else { $global_about_dialog = $dialog; } } $dialog->present; } } sub Gtk3::ActionGroup::add_actions { my ($self, $entries, $user_data) = @_; croak 'actions must be a reference to an array of action entries' unless (ref($entries) eq 'ARRAY'); croak 'action array is empty' unless (@$entries); my $process = sub { my ($p) = @_; my ($name, $stock_id, $label, $accelerator, $tooltip, $callback); if (ref($p) eq 'ARRAY') { $name = $p->[0]; $stock_id = $p->[1]; $label = $p->[2]; $accelerator = $p->[3]; $tooltip = $p->[4]; $callback = $p->[5]; } elsif (ref($p) eq 'HASH') { $name = $p->{name}; $stock_id = $p->{stock_id}; $label = $p->{label}; $accelerator = $p->{accelerator}; $tooltip = $p->{tooltip}; $callback = $p->{callback}; } else { croak 'action entry must be a reference to a hash or an array'; } if (defined($label)) { $label = $self->translate_string($label); } if (defined($tooltip)) { $tooltip = $self->translate_string($tooltip); } my $action = Gtk3::Action->new ($name, $label, $tooltip, $stock_id); if ($callback) { $action->signal_connect ('activate', $callback, $user_data); } $self->add_action_with_accel ($action, $accelerator); }; for my $e (@$entries) { $process->($e); } } sub Gtk3::ActionGroup::add_toggle_actions { my ($self, $entries, $user_data) = @_; croak 'entries must be a reference to an array of toggle action entries' unless (ref($entries) eq 'ARRAY'); croak 'toggle action array is empty' unless (@$entries); my $process = sub { my ($p) = @_; my ($name, $stock_id, $label, $accelerator, $tooltip, $callback, $is_active); if (ref($p) eq 'ARRAY') { $name = $p->[0]; $stock_id = $p->[1]; $label = $p->[2]; $accelerator = $p->[3]; $tooltip = $p->[4]; $callback = $p->[5]; $is_active = $p->[6]; } elsif (ref($p) eq 'HASH') { $name = $p->{name}; $stock_id = $p->{stock_id}; $label = $p->{label}; $accelerator = $p->{accelerator}; $tooltip = $p->{tooltip}; $callback = $p->{callback}; $is_active = $p->{is_active}; } else { croak 'action entry must be a hash or an array'; } if (defined($label)) { $label = $self->translate_string($label); } if (defined($tooltip)) { $tooltip = $self->translate_string($tooltip); } my $action = Gtk3::ToggleAction->new ( $name, $label, $tooltip, $stock_id); $action->set_active ($is_active) if defined $is_active; if ($callback) { $action->signal_connect ('activate', $callback, $user_data); } $self->add_action_with_accel ($action, $accelerator); }; for my $e (@$entries) { $process->($e); } } sub Gtk3::ActionGroup::add_radio_actions { my ($self, $entries, $value, $on_change, $user_data) = @_; croak 'radio_action_entries must be a reference to ' . 'an array of action entries' unless (ref($entries) eq 'ARRAY'); croak 'radio action array is empty' unless (@$entries); my $first_action = undef; my $process = sub { my ($group, $p) = @_; my ($name, $stock_id, $label, $accelerator, $tooltip, $entry_value); if (ref($p) eq 'ARRAY') { $name = $p->[0]; $stock_id = $p->[1]; $label = $p->[2]; $accelerator = $p->[3]; $tooltip = $p->[4]; $entry_value = $p->[5]; } elsif (ref($p) eq 'HASH') { $name = $p->{name}; $stock_id = $p->{stock_id}; $label = $p->{label}; $accelerator = $p->{accelerator}; $tooltip = $p->{tooltip}; $entry_value = $p->{value}; } else { croak 'radio action entries neither hash nor array'; } if (defined($label)) { $label = $self->translate_string($label); } if (defined($tooltip)) { $tooltip = $self->translate_string($tooltip); } my $action = Gtk3::RadioAction->new ( $name, $label, $tooltip, $stock_id, $entry_value); $action->join_group($group); if ($value == $entry_value) { $action->set_active(Glib::TRUE); } $self->add_action_with_accel($action, $accelerator); return $action; }; for my $e (@$entries) { my $group = $process->($first_action, $e); if (!$first_action) { $first_action = $group; } } if ($first_action && $on_change) { $first_action->signal_connect ('changed', $on_change, $user_data); } } sub Gtk3::Builder::add_objects_from_file { my ($builder, $filename, @rest) = @_; my $ref = _rest_to_ref (\@rest); return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'Builder', 'add_objects_from_file', $builder, $filename, $ref); } sub Gtk3::Builder::add_objects_from_string { my ($builder, $string, @rest) = @_; my $ref = _rest_to_ref (\@rest); return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'Builder', 'add_objects_from_string', $builder, $string, -1, $ref); # wants length in bytes } sub Gtk3::Builder::add_from_string { my ($builder, $string) = @_; return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'Builder', 'add_from_string', $builder, $string, -1); # wants length in bytes } # Copied from Gtk2.pm sub Gtk3::Builder::connect_signals { my $builder = shift; my $user_data = shift; my $do_connect = sub { my ($object, $signal_name, $user_data, $connect_object, $flags, $handler) = @_; my $func = ($flags & 'after') ? 'signal_connect_after' : 'signal_connect'; # we get connect_object when we're supposed to call # signal_connect_object, which ensures that the data (an object) # lives as long as the signal is connected. the bindings take # care of that for us in all cases, so we only have signal_connect. # if we get a connect_object, just use that instead of user_data. $object->$func($signal_name => $handler, $connect_object || $user_data); }; # $builder->connect_signals ($user_data) # $builder->connect_signals ($user_data, $package) if ($#_ <= 0) { my $package = shift; $package = caller unless defined $package; $builder->connect_signals_full(sub { my ($builder, $object, $signal_name, $handler_name, $connect_object, $flags) = @_; no strict qw/refs/; my $handler = $handler_name; if (ref $package) { $handler = sub { $package->$handler_name(@_) }; } else { if ($package && $handler !~ /::/) { $handler = $package.'::'.$handler_name; } } $do_connect->($object, $signal_name, $user_data, $connect_object, $flags, $handler); }); } # $builder->connect_signals ($user_data, %handlers) else { my %handlers = @_; $builder->connect_signals_full(sub { my ($builder, $object, $signal_name, $handler_name, $connect_object, $flags) = @_; return unless exists $handlers{$handler_name}; $do_connect->($object, $signal_name, $user_data, $connect_object, $flags, $handlers{$handler_name}); }); } } { no strict 'refs'; my @button_classes = ([Button => 'new_with_mnemonic'], [CheckButton => 'new_with_mnemonic'], [ColorButton => 'new_with_color'], [FontButton => 'new_with_font'], [ToggleButton => 'new_with_mnemonic']); foreach my $button_pair (@button_classes) { my ($button_class, $button_ctor) = @$button_pair; *{'Gtk3::' . $button_class . '::new'} = sub { my ($class, $thing) = @_; if (defined $thing) { return $class->$button_ctor ($thing); } else { return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, $button_class, 'new', @_); } } } } sub Gtk3::CheckMenuItem::new { my ($class, $mnemonic) = @_; if (defined $mnemonic) { return $class->new_with_mnemonic ($mnemonic); } return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'CheckMenuItem', 'new', @_); } sub Gtk3::Container::get_focus_chain { my ($container) = @_; my ($is_set, $widgets) = Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'Container', 'get_focus_chain', $container); return () unless $is_set; return @$widgets; } sub Gtk3::Container::set_focus_chain { my ($container, @rest) = @_; return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'Container', 'set_focus_chain', $container, _rest_to_ref (\@rest)); } sub Gtk3::CssProvider::load_from_data { my ($self, $data) = @_; return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'CssProvider', 'load_from_data', $self, _unpack_unless_array_ref ($data)); } # Gtk3::Dialog / Gtk3::InfoBar methods due to overlap { no strict qw(refs); foreach my $dialog_package (qw/Dialog InfoBar/) { *{'Gtk3::' . $dialog_package . '::add_action_widget'} = sub { Glib::Object::Introspection->invoke ( $_GTK_BASENAME, $dialog_package, 'add_action_widget', $_[0], $_[1], $_GTK_RESPONSE_NICK_TO_ID->($_[2])); }; *{'Gtk3::' . $dialog_package . '::add_button'} = sub { Glib::Object::Introspection->invoke ( $_GTK_BASENAME, $dialog_package, 'add_button', $_[0], $_[1], $_GTK_RESPONSE_NICK_TO_ID->($_[2])); }; *{'Gtk3::' . $dialog_package . '::add_buttons'} = sub { my ($dialog, @rest) = @_; for (my $i = 0; $i < @rest; $i += 2) { $dialog->add_button ($rest[$i], $rest[$i+1]); } }; *{'Gtk3::' . $dialog_package . '::response'} = sub { return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, $dialog_package, 'response', $_[0], $_GTK_RESPONSE_NICK_TO_ID->($_[1])); }; *{'Gtk3::' . $dialog_package . '::set_default_response'} = sub { Glib::Object::Introspection->invoke ( $_GTK_BASENAME, $dialog_package, 'set_default_response', $_[0], $_GTK_RESPONSE_NICK_TO_ID->($_[1])); }; *{'Gtk3::' . $dialog_package . '::set_response_sensitive'} = sub { Glib::Object::Introspection->invoke ( $_GTK_BASENAME, $dialog_package, 'set_response_sensitive', $_[0], $_GTK_RESPONSE_NICK_TO_ID->($_[1]), $_[2]); }; } } sub Gtk3::Dialog::get_response_for_widget { my $id = Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'Dialog', 'get_response_for_widget', @_); return $_GTK_RESPONSE_ID_TO_NICK->($id); } sub Gtk3::Dialog::get_widget_for_response { return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'Dialog', 'get_widget_for_response', $_[0], $_GTK_RESPONSE_NICK_TO_ID->($_[1])); } sub Gtk3::Dialog::new { my ($class, $title, $parent, $flags, @rest) = @_; if (@_ == 1) { return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'Dialog', 'new', @_); } elsif ((@_ < 4) || (@rest % 2)){ croak ("Usage: Gtk3::Dialog->new ()\n" . " or Gtk3::Dialog->new (TITLE, PARENT, FLAGS, ...)\n" . " where ... is a series of button text and response id pairs"); } else { my $dialog = Gtk3::Dialog->new; defined $title and $dialog->set_title ($title); defined $parent and $dialog->set_transient_for ($parent); $flags & 'modal' and $dialog->set_modal (Glib::TRUE); $flags & 'destroy-with-parent' and $dialog->set_destroy_with_parent (Glib::TRUE); $dialog->add_buttons (@rest); return $dialog; } } sub Gtk3::Dialog::new_with_buttons { &Gtk3::Dialog::new; } sub Gtk3::Dialog::run { my $id = Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'Dialog', 'run', @_); return $_GTK_RESPONSE_ID_TO_NICK->($id); } sub Gtk3::Dialog::set_alternative_button_order { my ($dialog, @rest) = @_; return unless @rest; Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'Dialog', 'set_alternative_button_order_from_array', $dialog, [map { $_GTK_RESPONSE_NICK_TO_ID->($_) } @rest]); } sub Gtk3::Editable::insert_text { return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'Editable', 'insert_text', @_ == 4 ? @_ : (@_[0,1], -1, $_[2])); # wants length in bytes } sub Gtk3::FileChooserDialog::new { my ($class, $title, $parent, $action, @varargs) = @_; if (@varargs % 2) { croak 'Usage: Gtk2::FileChooserDialog->new' . ' (title, parent, action, backend, button-text =>' . " response-id, ...)\n"; } my $result = Glib::Object::new ( $class, title => $title, action => $action, ); if ($parent) { $result->set_transient_for ($parent); } for (my $i = 0; $i < @varargs; $i += 2) { $result->add_button ($varargs[$i], $varargs[$i+1]); } return $result; } sub Gtk3::HBox::new { my ($class, $homogeneous, $spacing) = @_; $homogeneous = 0 unless defined $homogeneous; $spacing = 5 unless defined $spacing; return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'HBox', 'new', $class, $homogeneous, $spacing); } # Gtk3::Image { no strict qw(refs); foreach my $ctor (qw/new_from_stock new_from_icon_set new_from_icon_name new_from_gicon/) { *{'Gtk3::Image::' . $ctor} = sub { my ($class, $thing, $size) = @_; return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'Image', $ctor, $class, $thing, $_GTK_ICON_SIZE_NICK_TO_ID->($size)); } } foreach my $getter (qw/get_stock get_icon_set get_icon_name get_gicon/) { *{'Gtk3::Image::' . $getter} = sub { my ($image) = @_; my ($thing, $size) = Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'Image', $getter, $image); return ($thing, $_GTK_ICON_SIZE_ID_TO_NICK->($size)); } } foreach my $setter (qw/set_from_stock set_from_icon_set set_from_icon_name set_from_gicon/) { *{'Gtk3::Image::' . $setter} = sub { my ($image, $thing, $size) = @_; Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'Image', $setter, $image, $thing, $_GTK_ICON_SIZE_NICK_TO_ID->($size)); } } } sub Gtk3::ImageMenuItem::new { my ($class, $mnemonic) = @_; if (defined $mnemonic) { return $class->new_with_mnemonic ($mnemonic); } return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'ImageMenuItem', 'new', @_); } sub Gtk3::InfoBar::new { my ($class, @buttons) = @_; if (@_ == 1) { return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'InfoBar', 'new', @_); } elsif (@buttons % 2) { croak "Usage: Gtk3::InfoBar->new_with_buttons (button-text => response_id, ...)\n"; } else { my $infobar = Gtk3::InfoBar->new; for (my $i = 0; $i < @buttons; $i += 2) { $infobar->add_button ($buttons[$i], $buttons[$i+1]); } return $infobar; } } sub Gtk3::InfoBar::new_with_buttons { &Gtk3::InfoBar::new; } sub Gtk3::LinkButton::new { my ($class, $uri, $label) = @_; if (defined $label) { return Gtk3::LinkButton->new_with_label ($uri, $label); } else { return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'LinkButton', 'new', @_); } } sub Gtk3::ListStore::new { return _common_tree_model_new ('ListStore', @_); } # Reroute 'get' to Gtk3::TreeModel instead of Glib::Object. sub Gtk3::ListStore::get { return Gtk3::TreeModel::get (@_); } sub Gtk3::ListStore::insert_with_values { my ($model, $position, @columns_and_values) = @_; my ($columns, $values) = _unpack_keys_and_values (\@columns_and_values); if (not defined $columns) { croak ("Usage: Gtk3::ListStore::insert_with_values (\$model, \$position, \\\@columns, \\\@values)\n", " -or-: Gtk3::ListStore::insert_with_values (\$model, \$position, \$column1 => \$value1, ...)"); } my @wrapped_values = (); foreach my $i (0..$#{$columns}) { my $column_type = $model->get_column_type ($columns->[$i]); push @wrapped_values, Glib::Object::Introspection::GValueWrapper->new ( $column_type, $values->[$i]); } return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'ListStore', 'insert_with_valuesv', # FIXME: missing rename-to annotation? $model, $position, $columns, \@wrapped_values); } sub Gtk3::ListStore::set { return _common_tree_model_set ('ListStore', @_); } sub Gtk3::Menu::popup { my $self = shift; $self->popup_for_device (undef, @_); } sub Gtk3::Menu::popup_for_device { my ($menu, $device, $parent_menu_shell, $parent_menu_item, $func, $data, $button, $activate_time) = @_; my $real_func = $func ? sub { my @stuff = eval { $func->(@_) }; if ($@) { warn "*** menu position callback ignoring error: $@"; } if (@stuff == 3) { return (@stuff); } elsif (@stuff == 2) { return (@stuff, Glib::FALSE); # provide a default for push_in } else { warn "*** menu position callback must return two integers " . "(x, y) or two integers and a boolean (x, y, push_in)"; return (0, 0, Glib::FALSE); } } : undef; return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'Menu', 'popup_for_device', $menu, $device, $parent_menu_shell, $parent_menu_item, $real_func, $data, $button, $activate_time); } sub Gtk3::MenuItem::new { my ($class, $mnemonic) = @_; if (defined $mnemonic) { return $class->new_with_mnemonic ($mnemonic); } return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'MenuItem', 'new', @_); } sub Gtk3::MessageDialog::new { my ($class, $parent, $flags, $type, $buttons, $format, @args) = @_; my $dialog = Glib::Object::new ($class, message_type => $type, buttons => $buttons); if (defined $format) { # sprintf can handle empty @args my $msg = sprintf $format, @args; $dialog->set (text => $msg); } if (defined $parent) { $dialog->set_transient_for ($parent); } if ($flags & 'modal') { $dialog->set_modal (Glib::TRUE); } if ($flags & 'destroy-with-parent') { $dialog->set_destroy_with_parent (Glib::TRUE); } return $dialog; } # Gtk3::RadioAction, Gtk3::RadioButton, Gtk3::RadioMenuItem and # Gtk3::RadioToolButton constructors. { no strict qw(refs); my $group_converter = sub { my ($ctor, $group_or_member, $package) = @_; local $@; # undef => [] if (!defined $group_or_member) { return ($ctor, []); } # [] => [] elsif (eval { $#$group_or_member == -1 }) { return ($ctor, []); } # [member1, ...] => member1 elsif (eval { $#$group_or_member >= 0 }) { my $member = $group_or_member->[0]; if (defined $member) { return ($ctor . '_from_widget', $member); } return ($ctor, []); } # member => member elsif (eval { $group_or_member->isa ('Gtk3::' . $package) }) { return ($ctor . '_from_widget', $group_or_member); } else { croak ('Unhandled group or member argument encountered'); } }; # Gtk3::RadioAction/Gtk3::RadioButton/Gtk3::RadioMenuItem/Gtk3::RadioToolButton foreach my $package (qw/RadioAction RadioButton RadioMenuItem RadioToolButton/) { *{'Gtk3::' . $package . '::set_group'} = sub { my ($button, $group) = @_; my $real_group = $group; if (eval { $#$group >= 0 }) { $real_group = $group->[0]; } $button->set (group => $real_group); }; } # Gtk3::RadioButton/Gtk3::RadioMenuItem foreach my $package (qw/RadioButton RadioMenuItem/) { foreach my $ctor (qw/new new_with_label new_with_mnemonic/) { # Avoid using the list-based API, as G:O:I does not support the memory # ownership semantics. Use the item-based API instead. *{'Gtk3::' . $package . '::' . $ctor} = sub { my ($class, $group_or_member, @rest) = @_; my ($real_ctor, $real_group_or_member) = $group_converter->($ctor, $group_or_member, $package); return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, $package, $real_ctor, $class, $real_group_or_member, @rest); }; # Work around . *{'Gtk3::' . $package . '::' . $ctor . '_from_widget'} = sub { my ($class, $member, @rest) = @_; my $real_ctor = $ctor; my $real_group_or_member = $member; if (!defined $member) { $real_group_or_member = []; } else { $real_ctor .= '_from_widget'; } return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, $package, $real_ctor, $class, $real_group_or_member, @rest); }; } } # GtkRadioToolButton foreach my $ctor (qw/new new_from_stock/) { # Avoid using the list-based API, as G:O:I does not support the memory # ownership semantics. Use the item-based API instead. *{'Gtk3::RadioToolButton::' . $ctor} = sub { my ($class, $group_or_member, @rest) = @_; my ($real_ctor, $real_group_or_member) = $group_converter->($ctor, $group_or_member, 'RadioToolButton'); $real_ctor =~ s/_from_stock_from_/_with_stock_from_/; # you gotta be kidding me... return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'RadioToolButton', $real_ctor, $class, $real_group_or_member, @rest); }; } } sub Gtk3::RecentChooserDialog::new { my ($class, $title, $parent, @buttons) = @_; my $dialog = Glib::Object::new ($class, title => $title); for (my $i = 0; $i < @buttons; $i += 2) { $dialog->add_button ($buttons[$i], $buttons[$i+1]); } if (defined $parent) { $dialog->set_transient_for ($parent); } return $dialog; } sub Gtk3::RecentChooserDialog::new_for_manager { my ($class, $title, $parent, $mgr, @buttons) = @_; my $dialog = Glib::Object::new ($class, title => $title, recent_manager => $mgr); for (my $i = 0; $i < @buttons; $i += 2) { $dialog->add_button ($buttons[$i], $buttons[$i+1]); } if (defined $parent) { $dialog->set_transient_for ($parent); } return $dialog; } sub Gtk3::TextBuffer::create_tag { my ($buffer, $tag_name, @rest) = @_; if (@rest % 2) { croak ('Usage: $buffer->create_tag ($tag_name, $property1 => $value1, ...'); } my $tag = Gtk3::TextTag->new ($tag_name); my $tag_table = $buffer->get_tag_table; $tag_table->add ($tag); for (my $i = 0 ; $i < @rest ; $i += 2) { $tag->set_property ($rest[$i], $rest[$i+1]); } return $tag; } sub Gtk3::TextBuffer::insert { return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'TextBuffer', 'insert', @_ == 4 ? @_ : (@_[0,1,2], -1)); # wants length in bytes } sub Gtk3::TextBuffer::insert_at_cursor { return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'TextBuffer', 'insert_at_cursor', @_ == 3 ? @_ : (@_[0,1], -1)); # wants length in bytes } sub Gtk3::TextBuffer::insert_interactive { return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'TextBuffer', 'insert_interactive', @_ == 5 ? @_ : (@_[0,1,2], -1, $_[3])); # wants length in bytes } sub Gtk3::TextBuffer::insert_interactive_at_cursor { return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'TextBuffer', 'insert_interactive_at_cursor', @_ == 4 ? @_ : (@_[0,1], -1, $_[2])); # wants length in bytes } sub Gtk3::TextBuffer::insert_with_tags { my ($buffer, $iter, $text, @tags) = @_; my $start_offset = $iter->get_offset; $buffer->insert ($iter, $text); my $start = $buffer->get_iter_at_offset ($start_offset); foreach my $tag (@tags) { $buffer->apply_tag ($tag, $start, $iter); } } sub Gtk3::TextBuffer::insert_with_tags_by_name { my ($buffer, $iter, $text, @tag_names) = @_; my $start_offset = $iter->get_offset; $buffer->insert ($iter, $text); my $tag_table = $buffer->get_tag_table; my $start = $buffer->get_iter_at_offset ($start_offset); foreach my $tag_name (@tag_names) { my $tag = $tag_table->lookup ($tag_name); if (!$tag) { warn "no tag with name $tag_name"; } else { $buffer->apply_tag ($tag, $start, $iter); } } } sub Gtk3::TextBuffer::set_text { return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'TextBuffer', 'set_text', @_ == 3 ? @_ : (@_[0,1], -1)); # wants length in bytes } sub Gtk3::TreeModel::get { my ($model, $iter, @columns) = @_; if (!@columns) { @columns = (0..($model->get_n_columns-1)); } my @values = map { $model->get_value ($iter, $_) } @columns; return @values[0..$#values]; } # Not needed anymore once # is fixed. sub Gtk3::TreeModelFilter::new { my ($class, $child_model, $root) = @_; Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'TreeModel', 'filter_new', $child_model, $root); } # Reroute 'get' to Gtk3::TreeModel instead of Glib::Object. sub Gtk3::TreeModelFilter::get { return Gtk3::TreeModel::get (@_); } # Not needed anymore once # is fixed. sub Gtk3::TreeModelSort::new_with_model { my ($class, $child_model) = @_; Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'TreeModel', 'sort_new_with_model', $child_model); } # Reroute 'get' to Gtk3::TreeModel instead of Glib::Object. sub Gtk3::TreeModelSort::get { return Gtk3::TreeModel::get (@_); } sub Gtk3::TreePath::new { my ($class, @args) = @_; my $method = (@args == 1) ? 'new_from_string' : 'new'; Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'TreePath', $method, @_); } sub Gtk3::TreePath::new_from_indices { my ($class, @indices) = @_; my $path = Gtk3::TreePath->new; foreach (@indices) { $path->append_index ($_); } return $path; } sub Gtk3::TreeStore::new { return _common_tree_model_new ('TreeStore', @_); } # Reroute 'get' to Gtk3::TreeModel instead of Glib::Object. sub Gtk3::TreeStore::get { return Gtk3::TreeModel::get (@_); } sub Gtk3::TreeStore::insert_with_values { my ($model, $parent, $position, @columns_and_values) = @_; my ($columns, $values) = _unpack_keys_and_values (\@columns_and_values); if (not defined $columns) { croak ("Usage: Gtk3::TreeStore::insert_with_values (\$model, \$parent, \$position, \\\@columns, \\\@values)\n", " -or-: Gtk3::TreeStore::insert_with_values (\$model, \$parent, \$position, \$column1 => \$value1, ...)"); } my @wrapped_values = (); foreach my $i (0..$#{$columns}) { my $column_type = $model->get_column_type ($columns->[$i]); push @wrapped_values, Glib::Object::Introspection::GValueWrapper->new ( $column_type, $values->[$i]); } return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'TreeStore', 'insert_with_values', $model, $parent, $position, $columns, \@wrapped_values); } sub Gtk3::TreeStore::set { return _common_tree_model_set ('TreeStore', @_); } sub Gtk3::TreeView::new { my ($class, @args) = @_; my $method = (@args == 1) ? 'new_with_model' : 'new'; Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'TreeView', $method, @_); } sub Gtk3::TreeView::insert_column_with_attributes { my ($tree_view, $position, $title, $cell, @rest) = @_; if (@rest % 2) { croak ('Usage: $tree_view->insert_column_with_attributes (position, title, cell_renderer, attr1 => col1, ...)'); } my $column = Gtk3::TreeViewColumn->new; my $n = $tree_view->insert_column ($column, $position); $column->set_title ($title); $column->pack_start ($cell, Glib::TRUE); for (my $i = 0; $i < @rest; $i += 2) { $column->add_attribute ($cell, $rest[$i], $rest[$i+1]); } return $n; } sub Gtk3::TreeViewColumn::new_with_attributes { my ($class, $title, $cell, @rest) = @_; if (@rest % 2) { croak ('Usage: Gtk3::TreeViewColumn->new_with_attributes (title, cell_renderer, attr1 => col1, ...)'); } my $object = $class->new; $object->set_title ($title); $object->pack_start ($cell, Glib::TRUE); for (my $i = 0; $i < @rest; $i += 2) { $object->add_attribute ($cell, $rest[$i], $rest[$i+1]); } return $object; } # Gtk3::TreeViewColumn::set_attributes and Gtk3::CellLayout::set_attributes { no strict 'refs'; foreach my $package (qw/TreeViewColumn CellLayout/) { *{'Gtk3::' . $package . '::set_attributes'} = sub { my ($object, $cell, @rest) = @_; if (@rest % 2) { croak ('Usage: $object->set_attributes (cell_renderer, attr1 => col1, ...)'); } $object->clear_attributes ($cell); for (my $i = 0; $i < @rest; $i += 2) { $object->add_attribute ($cell, $rest[$i], $rest[$i+1]); } } } } sub Gtk3::UIManager::add_ui_from_string { my ($manager, $string) = @_; return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'UIManager', 'add_ui_from_string', $manager, $string, -1); # wants length in bytes } sub Gtk3::VBox::new { my ($class, $homogeneous, $spacing) = @_; $homogeneous = 0 unless defined $homogeneous; $spacing = 5 unless defined $spacing; return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'VBox', 'new', $class, $homogeneous, $spacing); } sub Gtk3::Widget::render_icon { my ($widget, $stock_id, $size, $detail) = @_; Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'Widget', 'render_icon', $widget, $stock_id, $_GTK_ICON_SIZE_NICK_TO_ID->($size), $detail); } sub Gtk3::Window::new { my ($class, $type) = @_; $type = 'toplevel' unless defined $type; return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, 'Window', 'new', $class, $type); } # Gdk sub Gtk3::Gdk::RGBA::new { my ($class, @rest) = @_; # Handle Gtk3::Gdk::RGBA->new (r, g, b, a) specially. if (4 == @rest) { my %data; @data{qw/red green blue alpha/} = @rest; return Glib::Boxed::new ($class, \%data); } # Fall back to Glib::Boxed::new. return Glib::Boxed::new ($class, @rest); } sub Gtk3::Gdk::RGBA::parse { my $have_instance; { local $@; $have_instance = eval { $_[0]->isa ('Gtk3::Gdk::RGBA') }; } # This needs to be switched around if/when # is fixed. if ($have_instance) { return Glib::Object::Introspection->invoke ( $_GDK_BASENAME, 'RGBA', 'parse', @_); } else { my $instance = Gtk3::Gdk::RGBA->new; my $success = Glib::Object::Introspection->invoke ( $_GDK_BASENAME, 'RGBA', 'parse', $instance, @_); return $success ? $instance : undef; } } sub Gtk3::Gdk::Window::new { my ($class, $parent, $attr, $attr_mask) = @_; if (not defined $attr_mask) { $attr_mask = Gtk3::Gdk::WindowAttributesType->new ([]); if (exists $attr->{title}) { $attr_mask |= 'GDK_WA_TITLE' } if (exists $attr->{x}) { $attr_mask |= 'GDK_WA_X' } if (exists $attr->{y}) { $attr_mask |= 'GDK_WA_Y' } if (exists $attr->{cursor}) { $attr_mask |= 'GDK_WA_CURSOR' } if (exists $attr->{visual}) { $attr_mask |= 'GDK_WA_VISUAL' } if (exists $attr->{wmclass_name} && exists $attr->{wmclass_class}) { $attr_mask |= 'GDK_WA_WMCLASS' } if (exists $attr->{override_redirect}) { $attr_mask |= 'GDK_WA_NOREDIR' } if (exists $attr->{type_hint}) { $attr_mask |= 'GDK_WA_TYPE_HINT' } if (!Gtk3::CHECK_VERSION (3, 4, 4)) { # Before 3.4.4 or 3.5.6, the attribute mask parameter lacked proper # annotations, hence we numerify it here. FIXME: This breaks # encapsulation. $attr_mask = $$attr_mask; } } return Glib::Object::Introspection->invoke ( $_GDK_BASENAME, 'Window', 'new', $class, $parent, $attr, $attr_mask); } # GdkPixbuf sub Gtk3::Gdk::Pixbuf::get_pixels { my $pixel_aref = Glib::Object::Introspection->invoke ( $_GDK_PIXBUF_BASENAME, 'Pixbuf', 'get_pixels', @_); return pack 'C*', @{$pixel_aref}; } sub Gtk3::Gdk::Pixbuf::new_from_data { my ($class, $data, $colorspace, $has_alpha, $bits_per_sample, $width, $height, $rowstride) = @_; # FIXME: do we need to keep $real_data alive and then release it in a destroy # notify callback? my $real_data = _unpack_unless_array_ref ($data); return Glib::Object::Introspection->invoke ( $_GDK_PIXBUF_BASENAME, 'Pixbuf', 'new_from_data', $class, $real_data, $colorspace, $has_alpha, $bits_per_sample, $width, $height, $rowstride, undef, undef); } sub Gtk3::Gdk::Pixbuf::new_from_inline { my ($class, $data, $copy_pixels) = @_; $copy_pixels = Glib::TRUE unless defined $copy_pixels; return Glib::Object::Introspection->invoke ( $_GDK_PIXBUF_BASENAME, 'Pixbuf', 'new_from_inline', $class, _unpack_unless_array_ref ($data), $copy_pixels); } sub Gtk3::Gdk::Pixbuf::new_from_xpm_data { my ($class, @data) = @_; my $real_data; { local $@; $real_data = (@data == 1 && eval { @{$data[0]} }) ? $data[0] : \@data; } return Glib::Object::Introspection->invoke ( $_GDK_PIXBUF_BASENAME, 'Pixbuf', 'new_from_xpm_data', $class, $real_data); } # The next three subs might have to change when # is accepted. sub Gtk3::Gdk::Pixbuf::save { my ($pixbuf, $filename, $type, @rest) = @_; my ($keys, $values) = _unpack_keys_and_values (\@rest); if (not defined $keys) { croak ("Usage: \$pixbuf->save (\$filename, \$type, \\\@keys, \\\@values)\n", " -or-: \$pixbuf->save (\$filename, \$type, \$key1 => \$value1, ...)"); } Glib::Object::Introspection->invoke ( $_GDK_PIXBUF_BASENAME, 'Pixbuf', 'savev', $pixbuf, $filename, $type, $keys, $values); } sub Gtk3::Gdk::Pixbuf::save_to_buffer { my ($pixbuf, $type, @rest) = @_; my ($keys, $values) = _unpack_keys_and_values (\@rest); if (not defined $keys) { croak ("Usage: \$pixbuf->save_to_buffer (\$type, \\\@keys, \\\@values)\n", " -or-: \$pixbuf->save_to_buffer (\$type, \$key1 => \$value1, ...)"); } my (undef, $buffer) = Glib::Object::Introspection->invoke ( $_GDK_PIXBUF_BASENAME, 'Pixbuf', 'save_to_bufferv', $pixbuf, $type, $keys, $values); return $buffer; } sub Gtk3::Gdk::Pixbuf::save_to_callback { my ($pixbuf, $save_func, $user_data, $type, @rest) = @_; my ($keys, $values) = _unpack_keys_and_values (\@rest); if (not defined $keys) { croak ("Usage: \$pixbuf->save_to_callback (\$save_func, \$user_data, \$type, \\\@keys, \\\@values)\n", " -or-: \$pixbuf->save_to_callback (\$save_func, \$user_data, \$type, \$key1 => \$value1, ...)"); } Glib::Object::Introspection->invoke ( $_GDK_PIXBUF_BASENAME, 'Pixbuf', 'save_to_callbackv', $pixbuf, $save_func, $user_data, $type, $keys, $values); } # Pango sub Pango::Layout::set_text { return Glib::Object::Introspection->invoke ( $_PANGO_BASENAME, 'Layout', 'set_text', @_ == 3 ? @_ : (@_[0,1], -1)); # wants length in bytes } # - Helpers ----------------------------------------------------------------- # sub _common_tree_model_new { my ($package, $class, @types) = @_; my $real_types; { local $@; $real_types = (@types == 1 && eval { @{$types[0]} }) ? $types[0] : \@types; } return Glib::Object::Introspection->invoke ( $_GTK_BASENAME, $package, 'new', $class, $real_types); } sub _common_tree_model_set { my ($package, $model, $iter, @columns_and_values) = @_; my ($columns, $values) = _unpack_keys_and_values (\@columns_and_values); if (not defined $columns) { croak ("Usage: Gtk3::${package}::set (\$model, \$iter, \\\@columns, \\\@values)\n", " -or-: Gtk3::${package}::set (\$model, \$iter, \$column1 => \$value1, ...)"); } my @wrapped_values = (); foreach my $i (0..$#{$columns}) { my $column_type = $model->get_column_type ($columns->[$i]); push @wrapped_values, Glib::Object::Introspection::GValueWrapper->new ( $column_type, $values->[$i]); } Glib::Object::Introspection->invoke ( $_GTK_BASENAME, $package, 'set', $model, $iter, $columns, \@wrapped_values); } sub _unpack_keys_and_values { my ($keys_and_values) = @_; my (@keys, @values); my $have_array_refs; { local $@; $have_array_refs = @$keys_and_values == 2 && eval { @{$keys_and_values->[0]} }; } if ($have_array_refs) { @keys = @{$keys_and_values->[0]}; @values = @{$keys_and_values->[1]}; } elsif (@$keys_and_values % 2 == 0) { my %keys_to_vals = @$keys_and_values; @keys = keys %keys_to_vals; @values = values %keys_to_vals; } else { return (); } return (\@keys, \@values); } sub _unpack_unless_array_ref { my ($data) = @_; local $@; return eval { @{$data} } ? $data : [unpack 'C*', $data]; } sub _rest_to_ref { my ($rest) = @_; local $@; if (scalar @$rest == 1 && eval { defined $rest->[0]->[0] }) { return $rest->[0]; } else { return $rest; } } 1; __END__ # - Docs -------------------------------------------------------------------- # =head1 NAME Gtk3 - Perl interface to the 3.x series of the gtk+ toolkit =head1 SYNOPSIS use Gtk3 -init; my $window = Gtk3::Window->new ('toplevel'); my $button = Gtk3::Button->new ('Quit'); $button->signal_connect (clicked => sub { Gtk3::main_quit }); $window->add ($button); $window->show_all; Gtk3::main; =head1 ABSTRACT Perl bindings to the 3.x series of the gtk+ toolkit. This module allows you to write graphical user interfaces in a Perlish and object-oriented way, freeing you from the casting and memory management in C, yet remaining very close in spirit to original API. =head1 DESCRIPTION The Gtk3 module allows a Perl developer to use the gtk+ graphical user interface library. Find out more about gtk+ at L. The gtk+ reference manual is also a handy companion when writing Gtk3 programs in Perl: L. The Perl bindings follow the C API very closely, and the C reference documentation should be considered the canonical source. To discuss Gtk3 and ask questions join gtk-perl-list@gnome.org at L. Also have a look at the gtk2-perl website and sourceforge project page, L. =head2 Porting from Gtk2 to Gtk3 The majority of the API has not changed, so as a first approximation you can run C<< s/Gtk2/Gtk3/ >> on your application. A big exception to this rule is APIs that were deprecated in gtk+ 2.x -- these were all removed from gtk+ 3.0 and thus from L. The migration guide at L describes what to use instead. Apart from this, here is a list of some other incompatible differences between L and L: =over =item * The call syntax for class-static methods is now always C<< Gtk3::Stock::lookup >> instead of C<< Gtk3::Stock->lookup >>. =item * The %Gtk2::Gdk::Keysyms hash is gone; instead of C<< Gtk2::Gdk::Keysyms{XYZ} >>, use C<< Gtk3::Gdk::KEY_XYZ >>. =item * The Gtk2::Pango compatibility wrapper was not carried over; simply use the namespace "Pango" everywhere. It gets set up automatically when loading L. =item * The types Gtk3::Allocation and Gtk3::Gdk::Rectangle are now aliases for Cairo::RectangleInt, and as such they are represented as plain hashes with keys 'width', 'height', 'x' and 'y'. =item * Gtk3::Editable: Callbacks connected to the "insert-text" signal do not have as many options anymore as they had in Gtk2. Changes to arguments will not be propagated to the next signal handler, and only the updated position can and must be returned. =item * Gtk3::Menu: The position callback passed to popup() does not receive x and y parameters anymore. =item * Gtk3::RadioAction: The constructor now follows the C API. =item * Gtk3::TreeModel: iter_next() is now a method that is modifying the iter directly, instead of returning a new one. rows_reordered() and the "rows-reordered" signal are currently unusable. =item * Gtk3::TreeSelection: get_selected_rows() now returns two values: an array ref containing the selected paths, and the model. get_user_data() is not available currently. =item * Gtk3::TreeSortable: get_sort_column_id() has an additional boolean return value. =item * Gtk3::TreeStore, Gtk3::ListStore: reorder() is currently unusable. =item * Gtk3::Gdk::Atom: The constructor new() is not provided anymore, and the class function intern() must now be called as C<< Gtk3::Gdk::Atom::intern (name, only_if_exists) >>. =item * Implementations of Gtk3::TreeModel: Gtk3::TreeIter now has a constructor called new() expecting C<< key => value >> pairs; new_from_arrayref() does not exist anymore. To access the contents of Gtk3::TreeIter, use stamp(), user_data(), user_data2() and user_data3(); to_arrayref() does not exist anymore. GET_ITER(), ITER_CHILDREN(), ITER_NTH_CHILD() and ITER_PARENT() must return an additional boolean value. ITER_NEXT() must modify the iter and return a boolean rather than return a new iter. GET_VALUE() must return the value wrapped with C<< Glib::Object::Introspection::GValueWrapper->new >>. =item * Implementations of Gtk3::CellLayout: GET_CELLS() now needs to return an array ref instead of a list. =back Note also that Gtk3::CHECK_VERSION will always fail when passed 2.y.z, so if you have any existing version checks in your code, you will most likely need to remove them. =head1 SEE ALSO =over =item L =item L =back =head1 AUTHORS =encoding utf8 =over =item Torsten Schönfeld =back =head1 COPYRIGHT AND LICENSE Copyright (C) 2011-2013 by Torsten Schoenfeld This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. =cut