diff --git a/lib/ruby-gtk2-2.0.2/AUTHORS b/lib/ruby-gtk2-2.0.2/AUTHORS new file mode 100644 index 0000000..4661444 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/AUTHORS @@ -0,0 +1,115 @@ +The Ruby-GNOME2 Project Team (in alphabetical order, M:Maintainer) +------------------------------------------------------------------------ +Chikara Takamatsu + Japanese Website, Website + +Guillaume Cottenceau + Ruby/GLib, Ruby/GTK, Website. + +Dario Linsky + German Website(M). + +Franz Burgmann + German Website, Website, Provides some binary packages. + +Hiroshi IGARASHI + rbbr, Technical advisor. + +Geoff Youngs + Ruby/GTK, Ruby/GdkPixbuf, Ruby/GtkSourceView, + Ruby/Pango, Ruby/GLib. Ruby-GNOME2 Icon, Website. + +Joachim Glauche + Releases(M), since 0.17.0 + +Joao Pedrosa + Portuguese-BR Website(M), Website, Ruby/GTK. + +Joshua Keith + Tutorial, Website, Ruby-GNOME2 Icon. + +Junichiro Kita + Ruby/GTK Tutorial(Japanese) (M) + +KATO Kazuyoshi + Ruby/GTK(mainly gtk-demo), Ruby/GdkPixbuf, Ruby/GLib, Ruby/Libart. + +Kouhei Sutou + Ruby/GnomePrint(M), Ruby/GnomePrintUI(M), Ruby/RSVG(M), Ruby/GdkPixbuf, + Ruby/GnomeCanvas, Ruby/GTK, Ruby/Libart, Ruby/Pango, Ruby/GtkGLExt, + Ruby/GLib. + +KUBO Takehiro + Ruby/GNOME, Ruby/GnomeCanvas, Ruby/Libart, Ruby/GTK, Ruby/GLib. + +Laurent Sansonetti + Ruby/GStreamer(M), Ruby/Libgda(M), Ruby/GtkSourceView(M), + Ruby/GLib, Ruby/GTK, French Website, Website, Tutorials. + +Malte Milatz + German Website. + +Martin Povolný + Ruby/GtkHtml2(M). Ruby/GTK, + +Masahiro Sakai + Ruby/GLib and almost of the important design + of Ruby-GNOME2. Porting to Win32 platform. + +Masao Mutoh + Chief maintainer. Ruby/ATK(M), Ruby/GTK(M), Ruby/GdkPixbuf(M), + Ruby/Libglade(M), Ruby/Pango(M), Ruby/PanelApplet(M), Ruby/rbbr(M), + Website(M), Others. Project management. + +Matthew Berg + Ruby/GTK TreeView Tutorial(M), Website, Ruby/GTK. + +Mirko Maischberger + Ruby/GtkMozEmbed(M), Ruby/GTK, Ruby/Pango, Ruby/GdkPixbuf, Ruby/GNOME, + Website. + +Nikolai :: lone-star :: Weibull + Ruby/GConf, Ruby/GnomeVFS(M), Ruby/GTK. + +Nobuyoshi Nakada + Technical advisor. + +OGASAWARA, Takeshi + Ruby/GTK. + +Pascal Terjan + Ruby/GLib, Ruby/GTK, Ruby/GtkSourceView, Ruby/Pango, Ruby/GnomeVFS, + Ruby/GConf. + +Sam Stephenson + Website. + +Sjoerd Simons + Ruby/GLib, Ruby/GTK. + +TAMURA.Kenichi + Ruby/GLib. + +Vincent Isambart + Ruby/GtkGLExt(M), Ruby/GnomeCanvas, Ruby/ATK, Ruby/Pango, Ruby/GLib, + Ruby/GTK, Ruby/GtkHtml2, Ruby/Libart, Ruby/Libglade, French Website, + Website. + +All members of Ruby-GNOME2 Mailing lists. +And many others who have contributed patches, reported bugs. Thanks! + +---------------------------------------- +Ruby-GNOME Maintainers. +(current) + Kouhei Sutou +(up to Ruby-GNOME2 ver. 0.16) + Masao Mutoh +(up to Ruby-GNOME ver. 0.27) + Neil Conway +(up to Ruby-GNOME ver. 0.25) + Hiroshi IGARASHI +(up to Ruby-GNOME ver. 0.18) + by Dai.K. + + +charset = UTF-8. diff --git a/lib/ruby-gtk2-2.0.2/COPYING.LIB b/lib/ruby-gtk2-2.0.2/COPYING.LIB new file mode 100644 index 0000000..b1e3f5a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/COPYING.LIB @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. + + GNU LESSER GENERAL PUBLIC LICENSE + 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 + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/lib/ruby-gtk2-2.0.2/NEWS b/lib/ruby-gtk2-2.0.2/NEWS new file mode 100644 index 0000000..153dabe --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/NEWS @@ -0,0 +1,3625 @@ +# -*- RD -*- + += NEWS + +== Ruby-GNOME2 2.0.2: 2013-05-26 + +Windows XP re-supportted release! + +=== Changes + +==== Ruby/GLib2 + + * Improvements + * Added rbgutil_key_equal() convenient function. + It is used for comparing key that may be String or Symbol. + +==== Ruby/Pango + + * Improvements + * [windows] Forced to disable uniscribe backend of HarfBuzz. + [ruby-list:49412] [Reported by Masafumi Yokoyama] + * Don't define Pango::CairoFcFontMap and Pango::CairoWin32FontMap + because they may cause crash on OS X. + [shocker-ja:1119] [Reported by znz] + * Updated samples. + [GitHub#164] [Patch by Kentaro Fukuchi] + * Fixes + * Fixed wrong index access in Pango::GlyphString#glyphs. + [ruby-gnome2-devel-ja] [Reported by Kentaro Fukuchi] + +=== Thanks + + * Kentaro Fukuchi + * Masafumi Yokoyama + * znz + +== Ruby-GNOME2 2.0.1: 2013-05-25 + +Ruby 1.8 support is dropped release! + +=== Changes + +==== All + + * Improvements + * Dropped Ruby 1.8 support. + * Updated bundled binaries versions for Windows. + +==== Ruby/Pango + + * Improvements + * Added Pango::CairoFontMap.set_default. + * Enabled fontconfig font on Windows. + * Defined Pango::CairoFcFontMap on init if it is available. + * Defined Pango::CairoWin32FontMap on init if it is available. + +==== Ruby/GTK3 + + * Improvements + * Added Gtk::Image#set_from_icon_set. + [GitHub#150] [Patch by Detlef Reichl] + * Added Gtk::Image#set_from_stock. + [GitHub#150] [Patch by Detlef Reichl] + * Added Gtk::Image#set_from_gicon. + [GitHub#150] [Patch by Detlef Reichl] + * Updated samples. + [GitHUb#151] [Patch by Detlef Reichl] + * Fixes + * Fixed a GC related crash bug. + [ruby-gnome2-devel-en] [Reported by Detlef Reichl] + +==== Ruby/GObjectIntrospection + + * Improvements + * Supported ownership transfer for some input argument types. + (Struct and Object) + * Supported "(out caller-allocates)" for boxed object. + [ruby-gnome2-devel-ja] [Reported by Kentaro Fukuchi] + * Supported gpointer in/out. + [ruby-gnome2-devel-ja] [Reported by NAKAJIMA Takashi] + * Fixes + * Fixed missing argument. + [GitHub#154] [Reported by Masafumi Yokoyama] + +==== RubyGStreamer + + * Improvements + * Supported methods that call callback + [ruby-gnome2-devel-ja] [Reported by NAKAJIMA Takashi] + * Updated samples. + [GitHub#156][GitHub#159][GitHub#160][GitHub#161] + [Patch by NAKAJIMA Takashi] + * Supported Gst::Bus#set_handler. + [ruby-gnome2-devel-ja] [Reported by NAKAJIMA Takashi] + * Supported Gst::Controller + [ruby-gnome2-devel-ja] [Suggested by NAKAJIMA Takashi] + * Stopped to require Gst.init. + * Fixes + * Fixed out of index access bug. + +==== Ruby/GooCanvas + + * Improvements + * Migrated to Ruby/GObjectIntrospection based bindings. + * Stopped to require Goo.init. + * Fixes + * Updated samples. + [GitHub#152][GitHub#153][GitHub#155][GitHub#157] + [Patch by Masafumi Yokoyama] + +==== Ruby/Clutter + + * Improvements + * Stopped to require Clutter.init. + * Fixes + * Fixed broken samples. + [ruby-gnome2-devel-ja] [Patch by Kentaro Fukuchi] + +==== Ruby/ClutterGtk + + * Improvements + * Stopped to require ClutterGtk.init. + +==== Ruby/ClutterGStreamer + + * Added. + +==== Ruby/WebKitGtk + + * Improvements + * Stopped to require WebKitGtk.init. + +==== Ruby/WebKitGtk2 + + * Improvements + * Stopped to require WebKitGtk2.init. + +=== Thanks + + * Detlef Reichl + * NAKAJIMA Takashi + * Masafumi Yokoyama + * Kentaro Fukuchi + +== Ruby-GNOME2 2.0.0: 2013-04-29 + +GObject Introspection based bindings on Windows support release! + +=== Changes + +==== NEWS + + * Fixes + * Fixed a typo. [Reported by Masafumi Yokoyama] + * FIxed a typo. [Reported by Toyo Abe] + +==== Ruby/GLib2 + + * Improvements + * Moved lib/gnome2-*.rb files to lib/gnome2/ directory. + * Supported GLib 2.34. [Reported by OBATA Akio] + +==== Ruby/GdkPixbuf2 + + * Fixes + * [windows] Fixed PNG can't be handled problem. + [ruby-gnoem2-devel-ja] [Reported by Masafumi Yokoyama] + +==== Ruby/GDK3 + + * Improvements + * [windows] Removed needless Greybird theme. + [ruby-gnome2-devel-en] [Reported by Regis d'Aubarede] + * Added Gdk::Window#create_cairo_context + [ruby-gnome2-devel-en] [Reported by Detlef Reichl] + +==== Ruby/GTK3 + + * Improvements + * Updated samples. + [GitHub #140][GitHub #141][GitHub #144] + [Patch by Simon Arnaud] + [GitHub #142][GitHub #143][GitHub #145][GitHub #146][GitHub #148] + [Patch by Detlef Reichl] + +==== Ruby/GObjectIntrospection + + * Improvements + * [windows] Supported! + +==== Ruby/GStreamer + + * Improvements + * Supported GStreamer 1.0! + * Migrated to GObject Introspection bindings! + * Dropped GStreamer 0.10 support. + +==== Ruby/Clutter + + * Improvements + * [windows] Supported! + +==== Ruby/ClutterGTK + + * Improvements + * [windows] Supported! + +=== Thanks + + * Masafumi Yokoyama + * Toyo Abe + * OBATA Akio + * Regis d'Aubarede + * Detlef Reichl + * Simon Arnaud + +== Ruby-GNOME2 1.2.6: 2013-04-02 + +Broken Ruby/Poppler fix release! + +=== Changes + +==== Ruby/GLib2 + + * Improvements + * Removed deprecated GLib::Completion. + * Removed deprecated g_source_get_current_time() use. + * [windows] Updated bundled GLib to 3.8.0. + * [windows] Updated bundled glib-networking to 3.8.0. + * [windows] Updated bundled GnuTLS to 3.1.10. + +==== Ruby/ATK + + * Improvements + * [windows] Updated bundled ATK to 2.8.0. + +==== Ruby/GdkPixbuf2 + + * Improvements + * [windows] Updated bundled gdk-pixbuf to 2.28.0. + +==== Ruby/Pango + + * Improvements + * [windows] Updated bundled Pango to 1.34.0. + +==== Ruby/GDK3 + + * Improvements + * [windows] Updated bundled GTK+ to 3.8.0. + +==== Ruby/Poppler + + * Fixes + * Fixed a bug that Poppler::Page#render is broken. + [SF.net#184] [Reported by HARUYAMA Seigo] + +==== Ruby/GooCanvas + + * Improvements + * Added a Ruby/GObjectIntrospection based sample. + [GitHub #139] [Patch by Masafumi Yokoyama] + +=== Thanks + + * Masafumi Yokoyama + * HARUYAMA Seigo + +== Ruby-GNOME2 1.2.5: 2013-03-28 + +Crash bug fix release! + +=== Changes + +==== All + + * Fixes + * Fixed crash bugs. + [GitHub #138] [Reported by Takuma Nakajima] + +=== Thanks + + * Takuma Nakajima + +== Ruby-GNOME2 1.2.4: 2013-03-24 + +Ruby/WebKitGtk2 addition release! + +=== Changes + +==== All + + * Improvements + * Start mswin64 support. (But it is not completed yet.) + [GitHub #135] [Patch by usa] + +==== Ruby/GLib2 + + * Improvements + * Reduce needless GBoxed object copy. + +==== Ruby/GdkPixbuf2 + + * Fixes + * Fix build error by a typo. + +==== Ruby/GtkSourceView2 + + * Improvements + * Support auto RPM install on CentOS 6. + +==== Ruby/GObjectIntrospection + + * Improvements + * Add method name to arguments validation failure message. + * Support specific version loading. + +==== Ruby/GTK3 + + * Improvements + * [windows] Add gschemas.compiled. + [ruby-talk:406026] [Reported by Regis d'Aubarede] + +==== Ruby/WebKitGtk2 + + * New! + [GitHub #136] [Patch by eumario] + +=== Thanks + + * usa + * Regis d'Aubarede + * eumario + +== Ruby-GNOME2 1.2.3: 2013-03-17 + +Clean up release! + +=== Changes + +==== Ruby/GTK2 + + * Remove needless signale handlers restore. + +==== Ruby/GTK3 + + * Remove needless signale handlers restore. + +== Ruby-GNOME2 1.2.2: 2013-03-11 + +Ruby 2.0.0 support release! + +=== Changes + +==== Ruby/GLib2 + + * Improvements + * Supported test on Ruby 2.0.0. + [GitHub #134] [Reported by mtasaka] + +==== Ruby/Poppler + + * Improvements + * Removed deprecated GDK support. + +==== Ruby/GDK3 + + * Improvements + * Supported Ruby 2.0.0. + [GitHub#129] [Reported by TOMITA Masahiro] + +==== Ruby/GObjectIntrospection + + * Improvements + * Supported not GType based flags. + * Supported not GType based enum. + * Supported custom callback function. + * Supported .h install. + * Supported .pc install. + * More Rubyish method names are used. + * Stopped to raise exception when there are two or more out + parameters. + * Added Loader.start_callback_dispatch_thread(). + * Supported arguments validation. + * Stopped to use array for just one return value. + * Supported Enumerator. + * Hide constructor methods. + +==== Ruby/GtkSourceView3 + + * Fixes + * Fixed wrong deb package name. + +==== Ruby/Clutter + + * Fixes + * Fixed wrong initialized check. + * Stopped to override Clutter.init unexpectedly. + +==== Ruby/ClutterGTK + + * Fixes + * Fixed wrong initialized check. + +==== Ruby/WebKitGTK + + * Fixes + * Fixed wrong initialized check. + +=== Thanks + + * Vincent Carmona + (for unreleased GObjectIntrospection based GStreamer bindings) + * TOMITA Masahiro + * NAKAJIMA Takashi + (for unreleased GObjectIntrospection based GStreamer bindings) + * mtasaka + +== Ruby-GNOME2 1.2.1: 2013-01-30 + +GTK+ 3 support on Mac OS X release! + +=== Changes + +==== Ruby/GLib2 + + * Improvements + * Supported custom sudo prompt on auto native package install. + [GitHub:126] [Suggested by Yorick Peterse] + * Started to support JRuby. (It is not completed yet.) + [GitHub:125] [Reported by vpereira] + * Accepted unsigned long int size GType. + * Removed DL support. + * Don't call deprecated g_type_init() for GLib >= 2.35.1. + +==== Ruby/GTK2 + + * Fixes + * Fixed a memory leak related Gtk::TreeIter. + [GitHub:128] [Patch by Toshiaki Asai] + +==== Ruby/GTK3 + + * Fixes + * Fixed a memory leak related Gtk::TreeIter. + [GitHub:128] [Patch by Toshiaki Asai] + * Fixed a crash bug caused by symbol conflict with Ruby/GDK3 on + Mac OS X. + [GitHub:127] [Reported by Sergio Campama] [Helped by Watson] + +==== Ruby/GDK3 + + * Improvements + * [windows] Bundled Greybird theme. + [Suggested by Regis d'Aubarede] + +==== Ruby/GooCanvas + + * Improvements + * Added Goo::Canvas#get_items_at [GitHub:124] [Patch by David Maciejak] + +==== Ruby/WebKitGTK + + * Added + +==== Ruby/GtkSourceView3 + + * Improvements + * Supported Windows. + +=== Thanks + + * David Maciejak + * Yorick Peterse + * vpereira + * Toshiaki Asai + * Sergio Campama + * Watson + * Regis d'Aubarede + +== Ruby-GNOME2 1.2.0: 2013-01-24 + +GTK+ 3 support release! + +=== Changes + +==== All + + * Added ruby-gtk3 package. Here is a list: + * Ruby/GLib2 + * Ruby/ATK + * Ruby/Pango + * Ruby/GdkPixbuf2 + * Ruby/GDK3 + * Ruby/GTK3 + +==== Ruby/GLib2 + + * Improvements + * Supported custom VALUE <-> GBoxed conversion + * Supported VALUE <-> GBoxed conversion by RVAL2GOBJ + * Added GLib::Source::REMOVE + * Added GLib::Source::CONTINUE + * Added rbgobj_make_boxed_raw() + * Added GLib::Value for internal use + * [windows] Updated to the latest GLib: 2.28.8-1 -> 2.34.3 + * Changes + * Removed deprecated GLib::Win32.get_package_installation_directory + * Removed deprecated GLib::Win32.get_package_installation_subdirectory + * Added user_data to RGConvertTable callbacks + * rbgobj_convert_define() copies passed RGConvertTable + * Removed deprecated G_DEF_FUNDAMENTAL. Use RG_DEF_CONVERSION instead + +==== Ruby/GIO2 + + * Improvements + * Installed headers + +==== Ruby/ATK + + * Improvements + * [windows] Updated to the latest ATK: 1.32.0 -> 2.6.0 + +==== Ruby/Pango + + * Improvements + * [windows] Updated to the latest Pango: 1.28.3 -> 1.32.6 + +==== Ruby/GdkPixbuf2 + + * Improvements + * [windows] Updated to the latest gdk-pixbuf: 2.24.0 -> 2.26.5 + +==== Ruby/GTK2 + + * Improvements + * Removed needless not copy flag from Allocation + * [windows] Updated to the latest GTK+ 2: 2.24.8 -> 2.24.14 + +==== Ruby/GDK3 + + * Improvements + * [windows] Supported: 3.6.4 + +==== Ruby/GTK3 + + * Improvements + * Removed needless not copy flag from Allocation + * [windows] Supported: 3.6.4 + +==== Ruby/GObjectIntrospection + + * Improvements + * Supported over loaded method + * Supported over loaded constructor + * Supported GBoxed object + * Supported char * + * Supported GInterface + * Supported CallableInfo + * Supported may be null + * Supported union object + * Supported not GBoxed struct + * Supported out parameter + * Supported C array + * Added "?" suffix to predicate method name + * Supported SourceFunc callback + * Supported GValue + * Added GObjectIntrospection::Loader.register_boxed_class_converter + * Supported inout parameter + * Supported binary data array + * Changes + * ArgInfo#[] -> ArgInfo#get_arg + +==== Ruby/CairoGObject + + * Added + +==== Ruby/Clutter + + * Added + +==== Ruby/ClutterGtk + + * Added + +== Ruby-GNOME2 1.1.9: 2012-12-29 + +This is a experimental GObjectIntrospection support release. + +=== Changes + +==== Ruby/GLib2 + + * Improvements + * Renamed G_DEF_CLASS4 to G_DEF_CLASS_WITH_PARENT. + G_DEF_CLASS4 is still usable but it is deprecated. + +==== Ruby/GObjectIntrospection + + * Added. It is still experimental. + +== Ruby-GNOME2 1.1.8: 2012-12-19 + +This is a bug fix release for Ruby 2.0.0. + +=== Changes + +==== All + + * Fixes + * Fixed a bug that *.so isn't installed with Ruby 2.0.0. + +== Ruby-GNOME2 1.1.7: 2012-12-10 + +This is a package for Windows fix release. + +=== Changes + +==== Ruby/GTK2 + + * Fixes + * Bundled GTK+ 2.24.8-1 instead of GTK+ 2.24.10-1. + [Reported by Mahoro Shimura] + +=== Thanks + + * Mahoro Shimura + +== Ruby-GNOME2 1.1.6: 2012-12-02 + +This is Ruby 2.0.0 support release! + +=== Changes + +==== All + + * Fixes + * Fixed install error on Ruby 2.0.0. + [ruby-gnome2-devel-en] Recent Ruby: 'depend' files must be changed + [Reported by Carlo E. Prelz] + +==== Ruby/GLib2 + + * Improvements + * Improved portability a bit. '$,' is used instead of rb_output_fs. + [GktHub:#117] [Reported by Marvin Gülker] + +==== Ruby/GIO2 + + * Fixes + * Fixed a crash bug on i386. [Reported by TAKATSU Tomonari] + +==== Ruby/GTK2 + + * Improvements + * Added Gtk::TreeModel#iter_root. [GitHub:121] [Patch by dmaciejak] + * Added Gtk::TreeModel#iter_next. [GitHub:121] [Patch by dmaciejak] + +==== Ruby/GdkPixbuf2 + + * Fixes + * Fixed build errors with old gdk-pixbuf. + +==== Ruby/Poppler + + * Improvements + * Added missing required Poppler version. + [Suggested by Grant Schoep] + [ruby-gnome2-devel-en] poppler, build fails, incorrect + required_pkg_config_package? + + * Fixes + * Fixed a wrong package name on Red Hat and Fedora. + [Reported by Grant Schoep] + [ruby-gnome2-devel-en] poppler, build fails, incorrect + required_pkg_config_package? + + * Changes + * Disabled auto Poppler install for Homebrew. It requires + --with-glib option but auto install with --with-glib option + isn't supported yet. + +==== Ruby/GooCanvas + + * Improvements + * Added Goo::Canvas#update. [GitHub:119] [Patch by dmaciejak] + * Added Goo::Canvas#request_update. [GitHub:119] [Patch by dmaciejak] + * Added Goo::Canvas#convert_from_pixels. [GitHub:123] [Patch by dmaciejak] + * Added Goo::Canvas#convert_to_pixels. [GitHub:123] [Patch by dmaciejak] + * Added Goo::Canvas#get_item_at. [GitHub:123] [Patch by dmaciejak] + * Added Goo::Canvas#bounds. [GitHub:123] [Patch by dmaciejak] + +==== Ruby/GStreamer + + * Improvements + * Don't pass -h and --help to GStreamer. + [GitHub:#118] [Reported by dmaciejak] + +=== Thanks + + * TAKATSU Tomonari + * dmaciejak + * Grant Schoep + * Carlo E. Prelz + * Marvin Gülker + +== Ruby-GNOME2 1.1.5: 2012-08-29 + +This is a network support improvement release! + +=== Changes + +==== Ruby/GLib2 + + * Improvements + * windows: Bundled glib-networking. + +==== Ruby/GIO2 + + * Improvements + * Added Gio::TlsCertificate. + * Added Gio::TlsCertificateFlags. + +==== Ruby/GTK2 + + * Improvements + * Added Gtk.show_uri. + + * Fixes + * Gtk::TreeStore#reorder: + Fixed wrong the number of reorder values check. + [SF.net#3561748] [Reported by Nounou] + +=== Thanks + + * Nounou + +== Ruby-GNOME2 1.1.4: 2012-07-21 + +This is a easy to install release! + +=== Changes + +==== All + + * Improvements + * Supported automatic required native packages install. + +==== Ruby/GLib2 + + * Improvements + * mkenums: Supported "/* < flags > */" tag. + * mkenums: Supported two or more upper case characters such as "IO". + * Before: GIOStatus -> g_iostatus + * After: GIOStatus -> g_io_status + * GIOCondition: Changed to GLib::Boxed object from integer. + * GLib::Source#attach doesn't require context. + + * Fixes + * Fixed wrong type conversion for GIOCondition. + +==== Ruby/GIO2 + + * Improvements + * Gio::Socket#create_source: Supported callback. + + * Fixes + * Fixed return values. + * Fixed wrong type conversions. + +==== Ruby/GTK2 + + * Improvements + * Re-supported GTK+ 2.10.0. [GitHub:115] [Patch by Grant Schoep] + + * Fixes + * Fixed a typo in test script. + [GitHub:109] [Reported by kimura wataru] + +==== Ruby/GStreamer + + * Fixes + * Fixed a test failure with GStreamer 0.10.36. + [GitHub:111] [Reported by mtasaka] + +=== Thanks + + * kimura wataru + * mtasaka + * Grant Schoep + +== Ruby-GNOME2 1.1.3: 2012-04-08 + +This is a bug fix release of 1.1.2. + +=== Changes + +==== Ruby/GLib2 + + * Improvements + * Added required Ruby version into gemspec. + * [GitHub#106] glib-mkenums.rb supported macro lines in header. + This change is required for building with GLib 2.31.20. + [Reported by mtasaka] + * [GitHub#107] Supported tests on PPC. + [Reported by mtasaka] + * Fixes + * Fixed handler_id type. + +==== Ruby/GTK2 + + * Improvements + * Added Gtk::TreeViewColumn#set_sort_column_id and + Gtk::TreeViewColumn#sort_column_id= for GTK+ < 2.18. + [ruby-gnome2-devel-en] Gtk::TreeViewColumn + [Reported by grant schoep] + * Added Gtk::InfoBar. + * Added Gtk::MessageType. + * Added Gtk::ResponseType. + * Fixes + * Fixed build failure with GTK+ < 2.12. + [ruby-gnome2-devel-en] compile problems gtk2, ruby-gnome2-all-1.1.2 + [Reported by grant schoep] + * Fixed require failure with GTK+ < 2.14. + [ruby-gnome2-devel-en] NameError: undefined method + `color_selection' for class `Gtk::ColorSelectionDialog' + [Reported by grant schoep] + +==== Ruby/Poppler + + * Improvements + * [GitHub#97] Added Poppler::Page#text_layout. + [Patch by Andrey Kutejko] + * [SF.net#3495948] Removed needless poppler-cairo check. + [Reported by Pino Toscano] + * Fixes + * [GitHub#96] Fixed valid state of child index iterator. + [Patch by Andrey Kutejko] + * [GitHub#97] Fixed parameter check of Poppler::Page#get_text. + [Patch by Andrey Kutejko] + +==== Ruby/VTE + + * Fixes + * Fixed build failure with VTE < 0.24. + +==== Ruby/GStreamer + + * Improvements + * Added Gst::Element#seek_simple. + * Fixes + * [GitHub#95] Fixed async test. + [Reported by mtasaka] + +=== Thanks + + * mtasaka + * grant schoep + * Andrey Kutejko + * Pino Toscano + +== Ruby-GNOME2 1.1.2: 2012-01-15 + +This is a bug fix release of 1.1.1. + +=== Changes + +==== Ruby/GLib2 + + * Fixes + * [GitHub#94] install missing header files. + [Reported by mtasaka] + +==== Ruby/Pango + + * Fixes + * [GitHub#94] install a missing header file. + [Reported by mtasaka] + +==== Ruby/GdkPixbuf2 + + * Fixes + * [GitHub#94] install missing header files. + [Reported by mtasaka] + +=== Thanks + + * mtasaka + +== Ruby-GNOME2 1.1.1: 2012-01-14 + +This is a bug fix release of 1.1.0. + +=== Changes + +==== Ruby/GLib2 + + * Fixes + * [ruby-list:48587] Re: [ANN] Ruby-GNOME2 1.1.0 + fix wrong parent class for GLib::IOChannelWin32Socket. + [Reported by ashbb] + +==== Ruby/GTK2 + + * Fixes + * Fixed a bug that Gtk::ActionGroup#add_radio_actions always fail. + +==== Ruby/GStreamer + + * Improvements + * [win32] Supported FLAC. + +=== Thanks + + * ashbb + +== Ruby-GNOME2 1.1.0: 2012-01-05 + +This is a source cleanup release. + +=== Changes + +==== Ruby/GLib2 + + * Improvements + * [GitHub#65] Supported GLib 2.31. [Reported by mtasaka] + * Supported comparing between GLib::Enum/GLib::Flags and Symbol. + * Fixes + * [GitHub#1] Fix GLib::Spawn regression. + [Patch by Geoff Youngs] + * Plugged memory leaks. + * Fixed a crash by GC on Ruby 1.9. + * Changes + * Remove optional Ruby-GetText-Package dependency. + +==== Ruby/GTK2 + + * Improvements + * [ruby-gnome2-devel-en] FileChooserDialog raising warnings on Windows: + Added hicolor-icon-theme into gem on Windows. + [Suggested by Nikolai Weibull] + * Fixes + * Fixed a crash by GC. + * Plugged memory leaks. + * Fixed Gdk::GC#colormap= uses wrong value. + * Fixed Gtk::TextBuffer#serialize uses wrong value. + +==== Ruby/Pango + + * Fixes + * Plugged memory leaks. + +==== Ruby/GdkPixbuf + + * Improvements + * Gdk::Pixbuf.new supports hash argument. + * Fixes + * Plugged memory leaks. + +==== Ruby/GStreamer + + * Improvements + * Supported Windows gem. + * Improved memory management. + * Fixes + * [GitHub#86] Gstreamer: test_caps test fails. [Reported by mtasaka] + * [GitHub#87] GStreamer: test_span test fails. [Reported by mtasaka] + * [GitHub#87] GStreamer: test_create_clock test fails. + [Reported by mtasaka] + * [GitHub#89] GStreamer: test_fraction_range_new test fails. + [Reported by mtasaka] + * [GitHub#91] GStreamer: test_state "sometimes" fails. + [Reported by mtasaka] + +==== Ruby/Poppler + + * Fixes + * Fixed a wrong conversion in Poppler::Document#find_dest. + [Reported by Chloé Desoutter] + +=== Thanks + + * Geoff Youngs + * mtasaka + * Chloé Desoutter + * Nikolai Weibull + +== Ruby-GNOME2 1.0.3: 2011-09-19 + +This is a bug fix release of 1.0.2. + +=== Changes + +==== Ruby/GLib2 + + * Fixes + * [#3411234] Supported RubyGems 1.8.6. + [Tobias Pfeiffer, Kouhei Sutou] + +=== Thanks + + * Tobias Pfeiffer + +== Ruby-GNOME2 1.0.2: 2011-09-18 + +This is a bug fix release of 1.0.1. + +=== Changes + +==== Ruby/GLib2 + + * Fixes + * [#3411204] Supported RubyGems 1.8.6. + [Tobias Pfeiffer, Kouhei Sutou] + +==== Ruby/GTK2 + + * Fixes + * Fixed the default theme on Windows. + [ashbb, Kouhei Sutou] + +=== Thanks + + * Tobias Pfeiffer + * ashbb + +== Ruby-GNOME2 1.0.1: 2011-09-18 + +This is a bug fix release of 1.0.0. + +=== Changes + +==== Ruby/GLib2 + + * Improvements + * GLib::IOChannel.open supports Windows. + [OBATA Akio, Kouhei Sutou] + * Added RVAL2STRV_FREE(), CSTRFILENAME2RVAL(), + RVAL2STRV, STRV2RVAL(), G_REPLACE_SET_PROPERTY(), + G_REPLACE_GET_PROPERTY() and G_REPLACE_ACTION(). + [Nikolai Weibull] + * Fixes + * GLib::IOChannelWin32Socket.new uses raw socket handle + not file descriptor. + [NAKAMURA Usaku, Kouhei Sutou] + +==== Ruby/GTK2 + + * Fixes + * [#3383158] removed non LANG=C characters to be + buildable on LANG=C environment. + [Antonio Terceiro, Kouhei Sutou] + * Fixed Gtk::FileFilter#add_custom crash. + [Jeff Moore, Kouhei Sutou] + * Fixed initialization order. + [ashbb, Kouhei Sutou] + +==== Ruby/GooCanvas + + * Improvements + * Supported binary bundled gem. + [HAYASHI Kentaro] + +==== Ruby/GtkSourceView2 + + * Fixes + * Fixed bundled binary directory path on Windows. + [HAYASHI Kentaro] + +==== Ruby/GtkMozEmbed + + * Deprecated. + +=== Thanks + + * Antonio Terceiro + * OBATA Akio + * NAKAMURA Usaku + * HAYASHI Kentaro + * Jeff Moore + * ashbb + * Nikolai Weibull + +== Ruby-GNOME2 1.0.0: 2011-07-13 + +This is the first major release!!! + +=== Changes + +==== Document + + * Fixes + * updated deprecated list in README. + [Michal Suchanek, Kouhei Sutou] + +==== Ruby/GLib2 + + * Improvements + * bind g_io_channel_win32_new_socket() as GLib::IOChannelWin32Socket. + [Kouhei Sutou] + + * Fixes + * [#3312572] added missing parentheses. + [Evan Phoenix] + +=== Thanks + + * Evan Phoenix + * Michal Suchanek + +== Ruby-GNOME2 0.90.9: 2011-06-11 + +NOTE: 0.90.x releases are for 1.0.0 major release. + +This is the last release of 0.90.x series. The next release +will be 1.0.0! + +=== Changes + +==== All + + * Fixes + * Fix a bug in version numbers. + [Grant Schoep, Vincent Carmona] + * Support 'bundle install' . + +==== Ruby/GLib2 + + * Improvements + * Support GLib::IOChannel.new(fd) and GLib::IOChannel#fd on Windows. + * GLib::IOChannel#write returns written byte not self. + [backward incompatible] + +==== Ruby/GTK2 + + * Fixes + * fix misc/bindings.rb sample (ruby 1.9). + [Vincent Carmona] + * [#3305589] fix Gtk::Window#add_accel_group misses + a reference to accel group. + [Piotr Korzuszek, Kouhei Sutou] + * Support cairo related samples in Ruby 1.9. + [Jon, Kouhei Sutou] + +==== Ruby/GStreamer + + * Improvements + * add Gst::Registry.update method. + [Vincent Carmona] + +==== Ruby/VTE + + * Fixes + * [#3199587] fix pc install. + [OBATA Akio, Kouhei Sutou] + +==== Ruby/Poppler + + * Fixes + * [#3292118] don't run needless tests. + [Mamoru Tasaka, Kouhei Sutou] + +==== Ruby/GtkSourceView2 + + * Improvements + * support Windows. + [S.Kitagawa] + +=== Thanks + + * OBATA Akio + * Grant Schoep + * Mamoru Tasaka + * Piotr Korzuszek + * S.Kitagawa + * Jon + +== Ruby-GNOME2 0.90.8: 2011-03-04 + +NOTE: 0.90.x releases are for 1.0.0 major release. + +A bug fix release of 0.90.7. + +=== Changes + +==== All + + * Fixes + * 'make distclean' does not removed pkg-config files. + +==== Ruby/GLib2 + + * Fixes + * fix non-gem rcairo detection. [#3178228] + [OBATA Akio, Kouhei Sutou] + +==== Ruby/Atk + + * Fixes + * fix 'make distclean' cleans needed a file. + [Vincent Carmona] + +==== Ruby/Pango + + * Fixes + * fix 'make distclean' cleans needed a file. + [Vincent Carmona] + +==== Ruby/GTK2 + + * Fixes + * fix require order. + [id:kenhys] + * [#3046538] fix crash by GC at exit. + [Vincent Carmona, Kouhei Sutou] + * gtk-demo samples with ruby 1.9 (excepted cairo ones). + [Vincent Carmona] + +==== Ruby/GooCanvas + + * Fixes + * fix pc install. [#3178294] + [OBATA Akio, Kouhei Sutou] + +==== Ruby/GStreamer + + * Improvements + * improve missing message. + [Vincent Carmona] + * add Gst::InstallPlugins. + [Vincent Carmona, Kouhei Sutou] + + * Fixes + * fix pc install. [#3178294] + [OBATA Akio, Kouhei Sutou] + * don't use rbgprivate.h. [#3188442] + [Mamoru Tasaka, Kouhei Sutou] + +==== Ruby/GtkMozEmbed + + * Fixes + * fix pc install. [#3178294] + [OBATA Akio, Kouhei Sutou] + +==== Ruby/GtkSourceView2 + + * Fixes + * fix pc install. [#3178294] + [OBATA Akio, Kouhei Sutou] + +=== Thanks + + * OBATA Akio + * Vincent Carmona + * id:kenhys + * Mamoru Tasaka + +== Ruby-GNOME2 0.90.7: 2011-02-02 + +NOTE: 0.90.x releases are for 1.0.0 major release. + +A package fix release of 0.90.6. + +=== Changes + +==== Ruby/GLib2 + + * Improvements + * force remove "-Wl,--no-undefined" linker option because + Ruby-GNOME2 packages doesn't support the option. + [Dobai-Pataky Bálint, Kouhei Sutou] + +==== Ruby/GTK2 + + * Improvements + * use "MS-Windows" GTK+ theme by default on Windows. + [ashbb, Kouhei Sutou] + +=== Thanks + + * ashbb + * Dobai-Pataky Bálint + +== Ruby-GNOME2 0.90.6: 2011-01-29 + +NOTE: 0.90.x releases are for 1.0.0 major release. + +Removed deprecated packages. All supported packages support +RubyGems. All supported packages except Ruby/VTE, +Ruby/GStreamer and Ruby/GtkMozEmbed support also Windows +binary bundled gem. + +=== Changes + +==== All + + * remove all deprecated packages. + [Masaaki Aoyagi] + * all supported packages support RubyGems. + [Masaaki Aoyagi] + +==== Ruby/GLib2 + + * Imrpovements + * add gnome2-raketask.rb that is a utility library to + define Rake tasks for Ruby-GNOME2 packages. + [Masaaki Aoyagi, Kouhei Sutou] + + * Fixes + * fix GType conversion. + [Kouhei Sutou] + * fix rcairo installed by RubyGems detection. + [Masaaki Aoyagi] + +==== Ruby/GIO2 + + * Improvements + * support GIO 2.26. + [Nikolai Weibull] + +==== Ruby/GStreamer + + * Improvements + * add Gst::MissingURISourceMessage. + [Vincent Carmona, Kouhei Sutou] + * support RubyGems. + [Masaaki Aoyagi] + +==== Ruby/Pango + + * Fixes + * rename Pango::LayoutIter#at_last_line! to + at_last_line? because at_last_line is a predicate + method. (at_last_line! still exists for backward compatibility.) + [mrkn, Kouhei Sutou] + +==== Ruby/GtkMozEmbed + + * Improvements + * support RubyGems. + [Masaaki Aoyagi] + * Fixes + * support "2.0b7" style module version. #3141244 + [reandr, Kouhei Sutou] + +==== Ruby/GooCanvas + + * Improvements + * support RubyGems. + [Masaaki Aoyagi] + +==== Ruby/GtkSourceView2 + + * Improvements + * support RubyGems. + [Masaaki Aoyagi] + +==== Ruby/VTE + + * Improvements + * support RubyGems. + [Masaaki Aoyagi] + +=== Thanks + + * Vincent Carmona + * mrkn + * reandr + * Nikolai Weibull + * Masaaki Aoyagi + +== Ruby-GNOME2 0.90.5: 2010-10-28 + +NOTE: 0.90.x releases are for 1.0.0 major release. + +A build system improvements release. + +=== Changes + +==== All + + * Improvements + * add --with-pkg-config-dir option to extconf.rb for *.pc. + +==== Ruby/GLib2 + + * Improvements + * glib-mkenums.rb can work with Ruby 1.9 on LANG=C. + [Kouhei Sutou] + + * Bug fixes + * fix pkg-config gem dependency. + [Kouhei Sutou] + +== Ruby-GNOME2 0.90.4: 2010-10-24 + +NOTE: 0.90.x releases are for 1.0.0 major release. + +A bug fix release of 0.90.3. + +=== Changes + +==== Ruby/GLib2 + + * Bug fixes + * add missing '*' for String type conversion. [#3093789] + [tmtms, Kouhei Sutou] + +==== Ruby/GIO2 + + * Bug fixes + * Remove needless cairo dependency. + [OBATA Akio, Kouhei Sutou] + +==== Ruby/Libglade2 + + * Improvements + * Don't install *.pc by default. + [OBATA Akio, Kouhei Sutou] + +=== Thanks + + * OBATA Akio + * tmtms + +== Ruby-GNOME2 0.90.3: 2010-10-23 + +NOTE: 0.90.x releases are for 1.0.0 major release. + + * Support String encoding in Ruby 1.9. + * RVAL2CSTR2 and CSTR2RVAL2 are deprecated. + * Ruby/GIO2 is imported as an experimental library. + +=== Changes + +==== All + + * Support String encoding. + [Guillaume Cottenceau, Neil Roberts, Kouhei Sutou] + * Don't install *.pc by default. Set pkgconfigdir make + varialbe like 'make pkgconfigdir=/usr/lib/pkgconfig'. + +==== Ruby/GLib2 + + * Improvements: + * declare argument types. + [Nobuyoshi Nakada, Kouhei Sutou] + +==== Ruby/GIO2 + + * Imported as an experimental library. + [Nikolai Weibull] + +==== Ruby/GTK2 + + * Improvements: + * keep backward compatibility around GDK key + symbols introduced at GTK+ 2.20. + "[ruby-gnome2-devel-en] Constants names change in Gdk::KeyVal" + [Vincent Carmona] + * move gdk-pixbuf and cairo related methods from Ruby/GdkPixbuf2. + "[ruby-gnome2-devel-en] gtk2 dependency to gdkpixbuf2" + [Andrea Dallera, Kouhei Sutou] + * Bug fixes: + * fix GType conversion in Gtk::ItemFactory.new on 64bit + platform. + [Grant McLean, Steve Wills, Kouhei Sutou] + +==== Ruby/GdkPixbuf2 + + * Improvements: + * move gdk-pixbuf and cairo related methods to Ruby/GTK2. + "[ruby-gnome2-devel-en] gtk2 dependency to gdkpixbuf2" + [Andrea Dallera, Kouhei Sutou] + * change .pc filename from ruby-gdkpixbuf2 to + ruby-gdk-pixbuf2. + +==== Ruby/RSVG2 + + * Bug fixes: + * add missing libcroco dependency on Windows. + [U.Nakamura, Kouhei Sutou] + +==== Ruby/Poppler + + * Improvements: + * support Popper 0.15.0. [#3079667] + [Mamoru Tasaka, Kouhei Sutou] + + * Bug fixes: + * add missing libjpeg dependency on Windows. + [U.Nakamura, Kouhei Sutou] + * fix installed Ruby/GLib2 gem can't be detected. + [kdmsnr, Kouhei Sutou] + +=== Thanks + + * U.Nakamura + * kdmsnr + * Mamoru Tasaka + * Guillaume Cottenceau + * Vincent Carmona + * Grant McLean + * Steve Wills + * Andrea Dallera + * Nobuyoshi Nakada + * Neil Roberts + +== Ruby-GNOME2 0.90.2: 2010-09-26 + +NOTE: 0.90.x releases are for 1.0.0 major release. + +A RubyGems package fix release. + +=== Changes + +==== All + + * fix path. + [kimura wataru, Kouhei Sutou] + +==== Ruby/GTK2 + + * Bug fixes: + * fix gtk2/base.rb is missing in gem. + [S.Kitagawa, Kouhei Sutou] + +==== Ruby/GIO2 + + * Bug fixes: + * fix a typo in .pc name. [#3075619] + [O01eg, Kouhei Sutou] + +==== Ruby/RSVG2 + + * Bug fixes: + * also check rb_cairo.h availability. [#3075617] + [O01eg, Kouhei Sutou] + +=== Thanks + + * S.Kitagawa + * O01eg + * kimura wataru + +== Ruby-GNOME2 0.90.1: 2010-09-23 + +NOTE: 0.90.x releases are for 1.0.0 major release. + +A install bug fix release of 0.90.0. + +=== Changes + +==== Ruby/ATK + + * Bug fixes: + * fix .pc install path. + [OBATA Akio, Kouhei Sutou] + +==== Ruby/GTK2 + + * Bug fixes: + * fix .pc install path. + [OBATA Akio, Kouhei Sutou] + +==== Ruby/Pango + + * Bug fixes: + * fix .pc install path. + [OBATA Akio, Kouhei Sutou] + +==== Ruby/Poppler + + * Bug fixes: + * fix .pc install path. + [OBATA Akio, Kouhei Sutou] + +==== Ruby/RSVG + + * Bug fixes: + * fix .pc install path. + [OBATA Akio, Kouhei Sutou] + +=== Thanks + + * OBATA Akio + +== Ruby-GNOME2 0.90.0: 2010-09-23 + +NOTE: 0.90.x releases are for 1.0.0 major release. + +RubyGems support! + +=== Changes + +==== Ruby/GTK2 + + * Bug fixes: + * [ruby-gnome2-devel-en] Gtk 2.20, Gtk::Builder and 'name' + add Gtk::Buildable#builder_name/set_builder_name. + [Simon Arnaud, Kouhei Sutou] + +=== Thanks + + * Simon Arnaud + +== Ruby-GNOME2 0.19.4: 2011-04-17 + +NOTE: 0.19.x releases are development series. + +This release has many bug fixes and some improvements. The +fixed bugs include a memory leak bug on GC. If your +application live long time, you should upgrade. + +=== Changes + +==== Ruby/GLib2 + + * Bug fixes: + * fixed type_register on Ruby 1.9. + [Simon Arnaud, Kouhei Sutou] + * fixed memory leak in GC. + [Kouhei Sutou] + +==== Ruby/GTK2 + + * Bug fixes: + * [#2865895] support GdkWindow's cursor property. + NOTE: GTK+ 2.18.0 is unsupported version. + [Guillaume Cottenceau, Mamoru Tasaka] + * Gtk::MenuItem.new accepts nil as a label. + [Kazuhiro NISHIYAMA, Kouhei Sutou] + * fixed wrong conversion in Gtk::TreePath#<=>. + [Takeuchi Yusuke, Kouhei Sutou] + * fix Gtk::RecentInfo#application_info's double free bug. + [Kouhei Sutou] + * Improvements: + * Gdk::Window#invalidate accepts nil as 'area' + argument. It means 'invalidates whole window'. + [Hiroyuki Ito] + * Gtk::Clipbord#request_text sets UTF-8 encoding in Ruby + 1.9. + [Rg Rg, Kouhei Sutou] + * add Gtk::TreePath#==. + [Takeuchi Yusuke, Kouhei Sutou] + +==== Ruby/Pango + + * Improvements: + * add Pango::Gravity. + [Hiroyuki Ito, Kouhei Sutou] + +==== Ruby/GdkPixbuf + + * add Gdk::Pixbuf#pixels=. + [Michal Suchanek] + +==== Ruby/GStreamer + + * Bug fixes: + * [#2920997] fix argument type. [Johan Kiviniemi] + * [#2924886] implement Gst::MessageTag#parse. [Vincent Carmona] + +==== Ruby/GtkMozEmbed + + * Bug Fixes: + * [#2924766] fix -Wl,-rpath syntax. [OBATA Akio] + * [#2925285] Gtk::MozEmbed#chrome_mask fails. + [tobi, Kouhei Sutou] + * support XULRunner 1.9.2. [OBATA Akio] + +=== Thanks + + * Guillaume Cottenceau + * Mamoru Tasaka + * Michal Suchanek + * Simon Arnaud + * Kazuhiro NISHIYAMA + * Johan Kiviniemi + * OBATA Akio + * Hiroyuki Ito + * Rg Rg + * Vincent Carmona + * tobi + * Takeuchi Yusuke + +== Ruby-GNOME2 0.19.3: 2009-09-24 + +NOTE: 0.19.x releases are development series. + +This release is a bug fix release of 0.19.2. + +=== Changes + +==== Ruby/GLib2 + + * Bug fix: + * really fix + 'empty $(vendorarchdir) related build problem on CentOS 5.3 x86_64.' + [Simon Arnaud, Kouhei Sutou] + +=== Thanks + + * Simon Arnaud + +== Ruby-GNOME2 0.19.2: 2009-09-23 + +NOTE: 0.19.x releases are development series. + +This release is a bug fix release of 0.19.1. + +=== Changes + +==== Ruby/GLib2 + + * Bug fixes: + * empty $(vendorarchdir) related build problem on CentOS 5.3 x86_64. + [Toshiyuki Suzumura, Kouhei Sutou] + * [#2862022] fix multi thread blocking with Ruby + 1.8.6-p368 or later and 1.8.7-p173 or later. + [Roy Wright, Andrea Dallera, Kouhei Sutou] + * [Debian #502262] work Ruby thread with GTK+. + [Johan Walles, Kouhei Sutou] + +==== Ruby/GTK2 + + * Bug fixes: + * [#2679744] fix a typo: + Gtk::Widget#set_scroll_adjustment -> + Gtk::Widget#set_scroll_adjustments. + [Kentaro Fukuchi, Kouhei Sutou] + +==== Ruby/GtkMozEmbed + + * Bug fixes: + * fix .pc detection. + [OBATA Akio, Kouhei Sutou] + +=== Thanks + + * OBATA Akio + * Toshiyuki Suzumura + * Roy Wright + * Andrea Dallera + * Johan Walles + * Kentaro Fukuchi + +== Ruby-GNOME2 0.19.1: 2009-07-26 + +NOTE: 0.19.x releases are development series. + +This release is a bug fix release of 0.19.0. + +=== Changes + +==== Ruby/GTK2 + + * use RUBYARCHDIR + [OBATA Akio] + * #2814953: install missing headers + [Mamoru Tasaka] + +==== Ruby/GLib2 + + * Bug fixes: + * avoid object allocation while GC + [OBATA Akio, Kouhei Sutou] + * use RUBYARCHDIR + [OBATA Akio] + * mkmf-gnome2.rb add "-I$(vendorarchdir)" to $CPPFLAGS. + [OBATA Akio, Kouhei Sutou] + +==== Ruby/ATK + + * use RUBYARCHDIR + [OBATA Akio] + +==== Ruby/Pango + + * use RUBYARCHDIR + [OBATA Akio] + * use gem version rcairo as fallback + [OBATA Akio] + +==== Ruby/Libart + + * use RUBYARCHDIR + [OBATA Akio] + +==== Ruby/GdkPixbuf + + * use gem version rcairo as fallback + [OBATA Akio] + +==== Ruby/GnomePrint + + * install rblibgnomeprintversion.h + [OBATA Akio, Kouhei Sutou] + +==== Ruby/GtkMozEmbeded + + * fix header generation error caused by missing file + [OBATA Akio] + +==== Ruby/VTE + + * support VTE 0.20 + [Kouhei Sutou] + +==== Ruby/PanelApplet + + * #2815036: re-support Ruby 1.8.6. + [Mamoru Tasaka, Kouhei Sutou] + +==== Ruby/Libglade2 + + * Debian#519786: fix GC related SEGV when a widget in + glade is removed by hand. + [Arnaud Cornet, Kouhei Sutou] + +=== Thanks + + * OBATA Akio + * Mamoru Tasaka + * Arnaud Cornet + +== Ruby-GNOME2 0.19.0: 2009-05-29 + +NOTE: 0.19.x releases are development series. + +This release supports new versions of panel-applet and xulrunner +and fixes various bugs including some GC issues + +=== Changes + +Ruby/GLib2: + * add 'const' to name argument of rbgerr_define_gerror() + [Nikolai Weibull, Kouhei Sutou] + * Bug fixes: + * #2420281: Failed to build + [troels knak-nielsen, Kouhei Sutou] + * #2493874: glib/rbglib_maincontext.c error in "RUBY_UBF_IO" + [boo, Kouhei Sutou] + * wrong priority conversion in GLib::Timeout.add and + GLib::Timeout.add_seconds. + [Nikolai Weibull] + * fixed limits of basic types + [Pascal Terjan] + +Ruby/GTK2: + * Bug fixes: + * fixed initialize function is deleted. + [kimura wataru, Kouhei Sutou] + * checked GTK_FILE_SYSTEM_ERROR availability. GTK+ 2.15.x + doesn't have it. + [Kouhei Sutou] + * fixed GC problems. + [Kouhei Sutou] + * #2195432: Gtk::RCStyle.set_color_flags wrong conversion + [Jesse van den Kieboom, Kouhei Sutou] + * #2318481: gtkselectiondata_set Drag and Drop API problem + [dave foster, Kouhei Sutou] + * #2420281: Failed to build + [troels knak-nielsen, Kouhei Sutou] + +Ruby/Pango: + * added Pango::Attribute#start_index= and Pango::Attribute#end_index=. + [Geoff Youngs, Kouhei Sutou] + +Ruby/Poppler: + * removed 0.6.x support. 0.8.0 or later is required. + [Kouhei Sutou] + +Ruby/RSVG2: + * fixed broken cairo integration. + [James Healy, Kouhei Sutou] + +Ruby/PanelApplet: + * #2466921: fixed build failure with libpanel-applet >= 2.25 + [Mamoru Tasaka, Kouhei Sutou] + * fixed incomplete install. + [Pascal Terjan, Kouhei Sutou] + +Ruby/GtkMozEmbed: + * supported XULRunner 1.9.0. + [Arnaud Cornet, Kouhei Sutou] + +Ruby/GNOME2: + * supported MinGW. + [id:luna_8bit, Kouhei Sutou] + +Ruby/Bonobo2: + * moved Bonobo.setup_x_error_handler to Ruby/BonoboUI2. + [id:luna_8bit, Kouhei Sutou] + +Ruby/BonoboUI2: + * moved Bonobo.setup_x_error_handler from Ruby/Bonobo2. + [id:luna_8bit, Kouhei Sutou] + +Ruby/GnomeVFS: + * format security error. + [Pascal Terjan] + +=== Thanks + + * kimura wataru + * Philipp Götzinger + * Andrew S. Townley + * Jesse van den Kieboom + * James Healy + * dave foster + * troels knak-nielsen + * boo + * Geoff Youngs + * Arnaud Cornet + * id:luna_8bit + +== Ruby-GNOME2 0.18.0: 2008-09-30 + +This release fixes some memory leak bugs and has new +experimental packages. + +=== Changes + +Ruby/GLib2: + * mkmf-gnome2.rb: add check_cairo. [Kouhei Sutou] + * fixed memory leaks. [Kouhei Sutou] + * [#2110165] Gdk::Pixbuf memory leak + * install glib-enum-types.h. [Andy Spencer] + * [#2106938] Install glib-enum-types.h + +Ruby/GTK2: + * add GTK+ 2.12 related bindings. [Guillaume Cottenceau] + * fixed initialize order. [Kouhei Sutou] + * [#2113491] Incorrect initialize order (compiling with mingw) + +Ruby/GooCanvas [NEW][EXPERIMENTAL]: + * added. [Kouhei Sutou] + +Ruby/Pango: + * fixed memory leaks. [Kouhei Sutou] + +Ruby/GtkSourceView2 [NEW][EXPERIMENTAL]: + * add. [yselkowitz] + +=== Thanks + + * OBATA Akio + * James Healy + * Ricky Zheng + * Guillaume Cottenceau + * Ricky Zheng + +== Ruby-GNOME2 0.17.0: 2008-09-07 + +=== Release notes + + * This Release supports Ruby 1.8.7 and has many bug fixes and + new bound functions. + +=== Main changes + +Ruby/GLib: + * [#2060606] Crash when removing ruby applet from gnome panel with 0.7rc1 + [Kouhei Sutou] + +Ruby/GTK: + * [#2025651] FTBFS with gtk+ 2.13.5 [Cesare Tirabassi, Kouhei Sutou] + * [#2043970] Segfaults on 64-bit Linux [Neil Roberts, Kouhei Sutou] + +Ruby/Pango: + * [#2043970] Pango::FontDescription#weight= seg fault [Kouhei Sutou] + +Many other changes, GC bugs, Segfault fixes. See +corresponding ChangeLog for detailed information on changes +and contributors. + +=== Thanks + +Special thanks for your contributions to: (list in no particular order) + + * Neil Roberts + * Cesare Tirabassi + * Arnaud Cornet + +== Ruby-GNOME2 0.17.0-rc1: 2008-06-06 + +=== Release notes + + * This Release Candidate seems to be pretty stable. Please give us + feedback if you encounter any problems. + * The win32 bindings will be released later and will be + considered as EXPERIMENTAL The changes marked with 2 + stars (**) may currently not work on win32 platforms. + +=== Main changes + +Ruby/GLib: + * Bound functions defined since 2.14 and 2.16. + * Improved main loop polling. ** + * Improved callback handling from non Ruby thread. ** + + This changes breaks API. Sjoerd, you need to call + rbgutil_start_callback_dispatch_thread() in your + GStreamer bindings. Sorry. + + * Supported convenience GEnum and GFlags notation. e.g.: + GLib::UTF8.normalize(utf8, GLib::NormalizeMode::NFD) + -> + GLib::UTF8.normalize(utf8, :nfd) + + key_file.load_from_data(data, + GLib::KeyFile::KEEP_COMMENTS | + GLib::KeyFile::KEEP_TRANSLATIONS) + -> + key_file.load_from_data(data, [:keep_contents, :keep_translations]) + + * Fixed locale dependent constant name computation. [#1901843] + [Kouhei Sutou] + +Ruby/GTK: + + * partially support new symbols in 2.12 + (Gtk::RecentAction, Gtk::TextBuffer, Gdk::Display, + Gtk::TreeViewColumn, Gtk::Stock, Gtk::Widget, + Gtk::ScaleButton, Gtk::TreeView, Gtk::VolumneButton, + Gtk::Tooptip and Gtk::TextMark only). + + * [#2025651] FTBFS with gtk+ 2.13.5 [Cesare Tirabassi, Kouhei Sutou] + + * [#2043970] Segfaults on 64-bit Linux [Neil Roberts, Kouhei Sutou] + +Ruby/GStreamer: + + * Worked with GStreamer >= 0.10.x but isn't completed yet. + +Ruby/Poppler: + + * Supported poppler-glib 0.6.x and 0.8.0. [Kouhei Sutou] + +Ruby-GNOME2: + * Ruby-GNOME2 can be built with ruby 1.9.0 but doesn't + work well without [ruby-dev:34104] patch. + + * Some extconf.rb improvements + +Many other changes, GC bugs, Segfault fixes. See +corresponding ChangeLog for detailed information on changes +and contributors. + +=== Thanks + +Special thanks for your contributions to: (list in no particular order) + * Kazuhiro NISHIYAMA + * Kouhei Sutou + * Kero van Gelder + * Masahiro Sakai + * Detlef Reichl + * Guillaume Cottenceau + * Masahiro Sakai + * Mikael Hallendal + * Carlo E. Prelz + * Sjoerd Simons + * Juergen Mangler + * Dirk von Schmieden + * Mathieu Blondel + * Joseph Method + * Masayuki Yamaguchi + +And also special thanks to all other contributors not listed +above! + +== Ruby-GNOME2 0.16.0: 2006-12-30 + +Ruby-GNOME2: + * Fixed serious bugs (depends on GC) + * Support GTK+-2.10 and the latest version of each libraries. + * Don't include Ruby/GStreamer and Ruby/Libgda. We cancel to + support Ruby/GStreamer and Ruby/Libgda. + * Cancel to support ruby-1.6.x and GTK+-2.4 or earlier. + +Ruby/GLib: + * Support GLib+-2.10 APIs. [Kouhei Sutou, Masao Mutoh] + * Fix segfaults related GC with signal handlers. [Guillaume Cottenceau, Kouhei Sutou] + * Add functions for Unicode Manipulation [Kouhei Sutou] + GLib::Unicode, GLib::UTF8, GLib::UTF16, GLib::UCS4, GLib::UniChar + * Add Key-value file parser [Masao Mutoh] + GLib::KeyFile + * Add Bookmark file parser [Masao Mutoh] + GLib::BookmarkFile + * Add Win32 compatibility functions [Masao Mutoh] + GLib::Win32 + * Add glib-mkenums.rb [Kouhei Sutou, Masao Mutoh] + * Other improvement and fix bugs.[Kouhei Sutou, Masao Mutoh] + +Ruby/ATK: + * Support ATK-1.12 APIs. [Masao Mutoh] + +Ruby/Pango: + * Support Pango-1.2, 1.4 APIs [Masao Mutoh] + * Fix some bugs. [Masao Mutoh] + +Ruby/GdkPixbuf: + * Move Cairo::Context#set_source_pixbuf from Ruby/GTK.[Kouhei Sutou] + You can use the methods unless X server. + +Ruby/GTK: + * Support GTK+-2.10. [Pascal Terjan, Kouhei Sutou, Masao Mutoh] + Gtk::PrintUnixDialog, Gtk::PageSetupUnixDialog, Gtk::Print*, Gtk::PageSet + Gtk::LinkButton, Gtk::Recent*, Gtk::Assistant, Gtk::StatusIcon + * Other improvement and fix bugs [Sjoerd Simons, Kouhei Sutou, Masao Mutoh] + +Ruby/GNOME: + * None. + +Ruby/GnomeCanvas: + * Fixed a bug and trivial improvement. [Masao Mutoh] + +Ruby/Libglade: + * Fixed some bugs and trivial improvement. [Kouhei Sutou, Masao Mutoh] + +Ruby/Libart: + * a trivial improvement. [Kouhei Sutou] + +Ruby/GConf: + * Sample code cleanup. [Masao Mutoh] + +Ruby/GnomeVFS: + * None. + +Ruby/GtkHtml2: + * None. + +Ruby/GtkGLExt: + * None. + +Ruby/PanelApplet: + * None. Deprecated (Use Gtk::StatusIcon in Ruby/GTK+) + +Ruby/GtkSourceView: + * Support gtksourceview-1.8. Some improvements. [Kouhei Sutou, Masao Mutoh] + +Ruby/GnomePrint: + * None. + +Ruby/GnomePrintUI: + * a trivial improvement. [Kouhei Sutou] + +Ruby/RSVG: + * Added a sample [Kouhei Sutou] + * Improved, fixed bugs [Kouhei Sutou] + +Ruby/GtkMozEmbed: + * a trivial improvement. [Masao Mutoh] + +Ruby/Poppler: + * Improved, fixed bugs [Kouhei Sutou] + +Ruby/VTE: + * None. + +Ruby/GStreamer: + * Canceled. + +Ruby/Libgda: + * Canceled. + +== Ruby-GNOME2-0.15.0: 2006-07-01 + +Ruby/GLib: + * Improve signal handlers with pthread ruby(--enable-pthread). [Sjoerd Simons] + * Added new fundamental object for other bindings. [Sjoerd Simons] + * GLib::Source#remove -> GLib::Soruce.remove [Kouhei Sutou] + * Added new macros (GLIST2ARYF, GLIST2ARY2F, GSLIST2ARYF, GLIST2ARY2F, + G_PROTECT_CALLBACK) [Masao Mutoh] + * Added GLib.win32_locale, GLib, win32_locale_filename_from_utf8 [Kouhei Sutou] + * Improve memory management [Kouhei Sutou, Sjoerd Simons, Masahiro Sakai, Masao Mutoh] + * Other improvement and fix bugs. + [Sjoerd Simons, Joao Pedrosa, Kouhei Sutou, Masahiro Sakai, Masao Mutoh] + +Ruby/ATK: + * Improved cygwin support. [Masao Mutoh] + * Fix a bug. [Masahiro Sakai] + +Ruby/Pango: + * Fix some bugs. [Laurent Sansonetti, Masao Mutoh] + * Added Pango::Layout#markup=, Pango::AttrAbsoluteSize [Masao Mutoh] + +Ruby/GdkPixbuf: + * Fix a bug. [NISHI Takao] + * Code cleanup [Masao Mutoh] + +Ruby/GTK: + * Improve signal handlers. [Masahiro Sakai] + * Added Gtk::Widget#set_widget, #set_requisition. [Daniel Chokola] + * Added Gtk::Dialog#get_response. [Masao Mutoh] + * Other improvement and fix bugs [Mario Steele, Tilman Sauerbeck, Geoff Youngs, + Masahiro Sakai, Kouhei Sutou, Masao Mutoh] + +Ruby/GNOME: + * Follow Ruby/GLib2 change(GRClosure). [Kouhei Sutou] + +Ruby/GnomeCanvas: + * Code cleanup [Kouhei Sutou, Masao Mutoh] + +Ruby/Libglade: + * Fixed some bugs and trivial improvement. [Masao Mutoh] + +Ruby/Libart: + * None. + +Ruby/GConf: + * Sample code cleanup. [Masao Mutoh] + +Ruby/GStreamer: + * Sample code cleanup. [Masao Mutoh] + +Ruby/GnomeVFS: + * Improved and fixed bugs. [Masahiro Sakai, Masao Mutoh] + +Ruby/GtkHtml2: + * Sample code cleanup. [Masao Mutoh] + +Ruby/GtkGLExt: + * Improved and fixed bugs. [Kouhei Sutou, Masao Mutoh] + +Ruby/Libgda: + * Fix build against 1.3.x branch (libgda-2.x). [Laurent Sansonetti] + +Ruby/PanelApplet: + * Fixed a bug [Patch #1431855] + +Ruby/GtkSourceView: + * Sample code cleanup. [Masao Mutoh] + +Ruby/GnomePrint: + * Added Gnome::Print::BINDING_VERSION. Code cleanup [Kouhei Sutou] + +Ruby/GnomePrintUI: + * Added Gnome::PrintUI::BINDING_VERSION. [Kouhei Sutou] + * Sample code cleanup. [Masao Mutoh] + +Ruby/RSVG: + * Added RSVG::BINDING_VERSION, RBRSVG_MAJOR_VERSION, + RBRSVG_MINOR_VERSION, RBRSVG_MICRO_VERSION. [Kouhei Sutou] + * Supported 2.14. + * Improved, fixed bugs [Kouhei Sutou, Masao Mutoh] + +Ruby/GtkMozEmbed: + * Improved, fixed bugs [Mirko Maischberger, Masao Mutoh] + +Ruby/Poppler [NEW] [EXPERIMENTAL]: + * Added [Kouhei Sutou] + +Ruby/VTE [NEW]: + * Added [Kouhei Sutou] + +== Ruby-GNOME2 0.14.1: 2005-11-06 + +Ruby/GLib: + * Fix memory leaks. [Masao Mutoh] + +Ruby/ATK: + * None. + +Ruby/Pango: + * Fix some bugs. [Masao Mutoh] + +Ruby/GdkPixbuf: + * None. + +Ruby/GTK: + * Improve memory management. [Masao Mutoh] + +Ruby/GNOME: + * None. + +Ruby/GnomeCanvas: + * None. + +Ruby/Libglade: + * None. + +Ruby/Libart: + * None. + +Ruby/GConf: + * None. + +Ruby/GStreamer: + * None. + +Ruby/GnomeVFS: + * None. + +Ruby/GtkHtml2: + * None. + +Ruby/GtkGLExt: + * None. + +Ruby/Libgda: + * None. + +Ruby/PanelApplet: + * None. + +Ruby/GtkSourceView: + * None. + +Ruby/GnomePrint: + * None. + +Ruby/GnomePrintUI: + * None. + +Ruby/RSVG: + * None. + +Ruby/GtkMozEmbed: + * None. + +== Ruby-GNOME2 0.14.0: 2005-10-16 + +Ruby/GLib: + * Fix segfault related on GC. [Masao Mutoh] + * Support Ruby-GetText-Pacakge(Include pseudo GetText module). [Masao Mutoh] + * Add and completed: [Masao Mutoh] + * Glib::Shell, GLib::Completion, GLib::Timer, + sample/shell.rb, completion.rb, timer.rb. + * Add some methods, improved, fixed bugs: [Pascal Terjan, Sven Herzberg, Masao Mutoh] + * GLib, GLib::Object, GLib::MetaInterface, GLib::Enum, + GLib::Flags, PKGConfig, extconf.rb, mkmf-gnome2.rb + +Ruby/ATK: + * Support ATK-1.10. [Masao Mutoh] + * Add Atk::BUILD_VERSION. [Masao Mutoh] + * Add some methods, improved, fixed bugs: [Masao Mutoh] + * Atk, Atk::Relation, Atk::RelationSet, + Atk::StreamableContent, Atk::Text::Attribute, + Atk::Util + * Add and completed: [Masao Mutoh] + * Atk::Util::KeyEventType + +Ruby/Pango: + * Support Pango-1.10 and cairo [Kouhei Sutou, Masao Mutoh] + * Add Pango::BUILD_VERSION. [Masao Mutoh] + * Add some methods, improved, fixed bugs: [Kouhei Sutou, Masao Mutoh] + * Pango, Pango::Layout, Pango::LayoutLine, + Pango::LayoutIter, Pango::Language, Pango::Font, + Pango::GlyphItem, Pango::GlyphString, Pango::Context, + Pango::Analysis, Pango::Item + * Add and completed: [Masao Mutoh] + * Pango::ScriptIter, Pango::Script, Pango::(.*)FontMap, Pango::(.*)Face, + Pango::(.*)Family, Pango::XFont, Pango::FT2Font, + sample/script.rb, break.rb, item.rb, layout.rb + * Add classes: [Kouhei Sutou, Masao Mutoh] + * Pango::Engine, Pango::EngineShape, Pango::EngineLang + Cairo::Context, Pango::CairoFcFont, Pango::CairoFont, Pango::CairoWin32Font, + Pango::CairoFontMap + * Rename class name: [Masao Mutoh] + * Pango::FontSet -> Pango::Fontset, Pango::FontSetSimple -> Pango::FontsetSimple. + +Ruby/GdkPixbuf: + * Support GTK+-2.8. [Guillaume Cottenceau] + * Add some methods, improved, fixed bugs: [Kouhei Sutou, Guillaume Cottenceau] + * Gdk::Pixbuf + * Add and completed: [Guillaume Cottenceau] + * Gdk::PixbufSimpleAnim, sample/simpleanim.rb + +Ruby/GTK: + * Support GTK+-2.8. [Guillaume Cottenceau, Masao Mutoh] + * Support cairo. [Kouhei Sutou, Masao Mutoh] + * Add Gtk::BUILD_VERSION. [Masao Mutoh] + * Add some methods, improve, fix bugs: [Guillaume Cottenceau, Masao Mutoh] + * Gdk, Gdk::Drawable, Gdk::Display, Gdk::Drawable, + Gdk::Cursor, Gdk::Window, Gdk::Screen, Gtk::Action, + Gtk::Dialog, Gtk::Drag, Gtk::EntryCompletion, + Gtk::FileChooser, Gtk::IconView, Gtk::Image, + Gtk::Menubar, Gtk::MenuShell, Gtk::ScrolledWindow, + Gtk::SizeGroup, Gtk::Stock, Gtk::TextBuffer, + Gtk::TextIter, Gtk::ToolButton, Gtk::TreeRowReference, + Gtk::TreeView, Gtk::TreeViewColumn, Gtk::Window, + sample/gtk-demo/*.rb + * Add: [Guillaume Cottenceau, Kouhei Sutou] + * Cairo::Context, Gdk::EventGrabBroken, + sample/gtk-demo/cairo_*.rb, sample/misc/rgtk+cairo.rb + + +Ruby/GNOME [Masao Mutoh]: + * Support libgnome/libgnomeui-2.12. + * Add Gnome::BUILD_VERSION. + * Add some methods, improve, fix bugs: + * Gnome, Gnome::Util, Gnome::URL, Gnome::Help, Gnome::App, Gnome::Client + * Add: Gnome::GConf, Gnome::Sound, Gnome::Trigger + * sample/gnome-trigger.rb, sample/gnome-sound.rb + +Ruby/GnomeCanvas: + * Support libgnomecanvas-2.12. [Pascal Terjan, Masao Mutoh] + * Add Gnome::Canvas::BUILD_VERSION. [Masao Mutoh] + * Add some methods, improve, fix bugs: [Kouhei Sutoh, Pascal Terjan, Masao Mutoh] + * Gnome::CanvasItem, Gnome::CanvasPathDef, Gnome::Canvas. + * Add: Gnome::CanvasBuf. [Masao Mutoh] + +Ruby/Libglade [Masao Mutoh]: + * Support libglade-2.12. + * Add GladeXML::BUILD_VERSION. + * Add some methods, improve, fix bugs: + bin/ruby-glade-create-template, sample/l10n_*.rb, GladeXML + +Ruby/Libart [Masao Mutoh]: + * Add Art::BUILD_VERSION. + * Add: Art::Uta. + +Ruby/GConf: + * Support Cygwin. [Yaakov Selkowitz] + * Add GConf::BUILD_VERSION. [Masao Mutoh] + +Ruby/GStreamer: + * Support on Ruby-1.9. [Laurent Sansonetti] + * Add Gst::BUILD_VERSION. [Masao Mutoh] + * Fix bugs, improve, add some methods: [Masao Mutoh] + * Gst::Element + +Ruby/GnomeVFS: + * Support Cygwin. [Yaakov Selkowitz] + * Add GnomeVFS::BUILD_VERSION. [Masao Mutoh] + * Fix bugs, improve, add some methods: [Masao Mutoh] + * GnomeVFS + +Ruby/GtkHtml2 [Masao Mutoh]: + * Add Gtk::HtmlContext::BUILD_VERSION. + +Ruby/GtkGLExt: + * Added Gtk::GL::BUILD_VERSION. [Masao Mutoh] + * Fix bugs, improve, add some methods: [Kouhei Sutou] + * Gdk::Pixmap + +Ruby/Libgda: + * Support Cygwin. [Yaakov Selkowitz] + * Add Gda::BUILD_VERSION. [Masao Mutoh] + +Ruby/PanelApplet [Masao Mutoh]: + * Add PanelApplet::BUILD_VERSION. + +Ruby/GtkSourceView [Masao Mutoh]: + * Support GtkSourcView-1.4. + * Add Gtk::SourceView::BUILD_VERSION. + * Fix bugs, Improve, Add some methods: + * Gtk::SourceView, Gtk::SourceBuffer, Gtk::SourceTag, Gtk::SourceTagStyleMask + * Add and completed: + * Gtk::SourceStyleScheme, Gtk::SourcePrintJob + +Ruby/GnomePrint [Kouhei Sutou]: + * Support libgnomeprint-2.12. + * Add Gnome::Print::BUILD_VERSION + * Fix bugs, Improve, Add some methods: + * Gnome::PrintContext + * Add: sample/gp-pac.rb + +Ruby/GnomePrintUI [Kouhei Sutou]: + * Support libgnomeprintui-2.12. + * Add: + * Gnome::PrintUI::BUILD_VERSION, Gnome::FontSelection, + Gnome::FontPreview, Gnome::FontDialog, + Gnome::PrintContentSelector + +Ruby/RSVG [Kouhei Sutou]: + * Support rsvg-2.12. + * Add RSVG::BUILD_VERSION + +Ruby/GtkMozEmbed [NEW]: + * Merged. [Mirko Maischberber] + * Add Gtk::MozEmbed::BUILD_VERSION [Masao Mutoh] + +== Ruby-GNOME2 0.13.0: 2005-07-31 + +Ruby/GLib: + * Fixed GCC 4.0 warnings [Masao Mutoh] + * Added and completed: [Masao Mutoh] + * GLib:PollFD, GLib::Source, GLib::MainLoop, GLib::IOChannel, + GLib::Idle, GLib::ChildWatch + * Added some methods, improved, fixed bugs: [Vincent Isambart, Masao Mutoh] + * PKGConfig, extconf.rb, + * Added: [Masao Mutoh] + * GLib::MainContext, sample/iochannel.rb, idle.rb, timeout.rb, + timeout2.rb, tests/test-iochannel.*, runner.rb, + +Ruby/ATK: + * None. + +Ruby/Pango: + * Fixed GCC 4.0 warnings [Masao Mutoh] + * Support x86_64 [Masao Mutoh] + * Pango::Layout + * Added some methods, improved, fixed bugs: [Mirko Maischberger, + Pascal Terjan, Masao Mutoh] + * sample/parse.rb, Pango::LayoutLine, Pango::Coverage, Pango::LayoutIter, + Pango::FontFamily, Pango::Attriterator + +Ruby/GdkPixbuf: + * Fixed GCC 4.0 warnings [Masao Mutoh] + * Fixed bugs, Improved: [Mirko Maischberger, Masao Mutoh] + * sample/*.rb + +Ruby/GTK: + * Support x86_64 [Kouhei Sutou, Masao Mutoh] + * Gdk::Atom, Gtk::ItemFactory, Gtk::Widget, Gtk::Drag, Gtk::SizeGroup + * Fixed GCC 4.0 warnings [Masao Mutoh] + * Fixed bugs, Improved, Added some methods: [Hiroyuki Ikezoe, KATO Kazuyoshi, + Pascal Terjan, Kouhei Sutou, Mirko Maischberger, Masao Mutoh] + * Gtk::ActionGroup, Gtk::IconTheme, Gtk::RC, Gtk::TreeModel, Gdk::TimeCoord, + Gdk::Window, Gtk::CellView, Gtk::ToolButton, Gtk::MenuToolButton, Gdk, + Gdk::Display, Gdk::GC, Gdk::PangoAttrEmbossed, Gdk::Drawable, Gtk::Window, + sample/gtk-demo/main.rb, sample/misc/*.rb, sample/testgtk/*.rb. + * Added: [KATO Kazuyoshi, Masao Mutoh] + * sample/gtk-demo/hypertext.rb, sample/misc/colorselection.rb + +Ruby/GNOME [Mirko Maischberger]: + * sh-bang (!#) normalization + * sample/test-gnome/*.rb + +Ruby/GnomeCanvas [Kouhei Sutou]: + * Support x86_64, Improved. [Kouhei Sutou] + * Gnome::CanvasPathDef + +Ruby/Libglade: + * None. + +Ruby/Libart: + * Added [Kouhei Sutou] + * Art::DRect, Art::IRect + * Fixed bugs, Improved, Added some methods: [Kouhei Sutou, Masao Mutoh] + * Art::Affine, Art::BPath. Art::Canvas + +Ruby/GConf: + * None. + +Ruby/GStreamer: + * Fixed GCC 4.0 warnings [Masao Mutoh] + * Added: [Laurent Sansonetti] + * Gst::XOverLay, sample/video-player.rb, + * Fixed bugs, Improved, Added some methods: + [Laurent Sansonetti] + * Gst::Caps, Gst::Pad, Gst::Element, Gst::TagSetter + +Ruby/GnomeVFS [Masao Mutoh]: + * Fixed bugs, Improved, Added some methods: + GnomeVFS::File + +Ruby/GtkHtml2: + * None. + +Ruby/GtkGLExt: + * None. + +Ruby/Libgda: + * None. + +Ruby/PanelApplet [Masao Mutoh]: + * Check libpanel-applet version(2.6 or later): + extconf.rb + +Ruby/GtkSourceView [Masao Mutoh]: + * None. + +Ruby/GnomePrint: + * Fixed GCC 4.0 warnings [Masao Mutoh] + * Fixed bugs, Improved, Added some methods. [Kouhei Sutou] + * Gnome::PrintContext, Gnome::PrintJob, Gnome::PrintConfig, + Gnome::PrintUnit, Gnome::PrintPaper, src/lib/gnomeprint2.rb, + sample/to_file.rb + +Ruby/GnomePrintUI: + * Fixed GCC 4.0 warnings [Masao Mutoh] + * Fixed bugs, Improved, Added some methods. [Kouhei Sutou] + * Gnome::PaperSelector, Gnome::PrintUnitSelector, Gnome::PrintPreview, + Gnome::PrintDialog, Gnome::PrintConfigDialog, sample/dialog.rb, + +Ruby/RSVG: + * Fixed GCC 4.0 warnings [Masao Mutoh] + * Fixed bugs, Improved, Added some methods. [Kouhei Sutou] + +== Ruby-GNOME2 0.12.0: 2005-03-06 + +Ruby/GLib: + * Support GLib-2.6.x. [Masao, Mutoh] + * Support MS VC++. [Masao, Mutoh] + * Fix bugs, Improved, Added some methods. [KATO Kazuyoshi, + Masao Mutoh] + * PKGConfig, rbgobj_lookup_class(). + * Added: [Masao, Mutoh] + * GLib::Threads, src/lib/pkg-config.rb, sample/spawn.rb. + +Ruby/ATK [Dafydd Harries, Vincent Isambart, Masao Mutoh]: + * Support MS VC++. + * Fix bugs, Improved, Added some methods. + * Follow Ruby/GLib changes. + +Ruby/Pango [Masao Mutoh]: + * Support Pango-1.8.x. + * Support MS VC++. + * Follow Ruby/GLib changes. + * Added and completed: + * Pango::Renderer, Pango::Matrix, Pango::AttrStrikethroughColor, + Pango::AttrUnderlineColor, Pango::GlyphItem + * Added some methods, improved, fixed bugs: [Matthew Berg] + * Pango::Context, Pango::AttList, Pango::Attribute, + Pango::Layout, Pango, Pango::AttrSize, Pango::LogAttr, + Pango::Item, Pango::Analysis, Pango::Font, + Pango::FontDescription, Pango::FontFace, + Pango::FontSet, Pango::AttrList, Pango::AttrIterator, + Pango::Rectangle, Pango::Layout, Pango::LayoutLine, + Pango::LayoutIter, Pango::GlyphInfo + * Added + * Pango::FcFont, Pango::XftFont, Pango::FontFcFontMap, + Pango::XftFontMap. + * Renamed, Moved + * Pango::FontFamily#list_faces -> #faces. + +Ruby/GdkPixbuf [leon breedt, Masao Mutoh]: + * Support GTK+-2.6.x. + * Follow Ruby/GLib changes. + * Fixed bugs, Improved, Added some methods for GTK+-2.6.x: + * Gdk::PixbufAnimationIter, Gdk::Pixbuf, + Gdk::PixbufLoader, Gdk::PixbufFormat + +Ruby/GTK: + * Support Ruby-1.9.x. + * Support Pango-1.8.x. + * Support GTK+-2.6.x. + * Support MS VC++. + * Follow Ruby/GLib changes. + * Improve to support gthread. + * Added and completed for GTK+-2.6.x: [Darren Willis, + * Gtk::CellRendererProgress, Gtk::ScrollStep, + Gtk::IconView, Gtk::CellRendererCombo, + Gtk::AboutDialog, Gdk::PangoRenderer, Gtk::CellView, + Gtk::MenuToolButton, Gtk::FileChooserButton, + Gdk::EventChange, Gdk::X11 + * Fixed bugs, Improved, Added some methods for GTK+-2.6.x: + [Mirko Maischberger, Joao Pedrosa, KATO Kazuyoshi, Masao Mutoh] + * Gtk, Gtk::CellLayout, Gtk::RadioToolButton, + Gtk::ToggleToolButton, Gtk::Stock, Gtk::Image, + Gtk::Label, Gtk::Progressbar, Gtk::EntryCompletion, + Gtk::TextBuffer, Gtk::FileFilter, Gtk::FileChooser, + Gtk::Menu, Gtk::CellRenderer, Gtk::TreeView, + Gtk::TextView, Gtk::TextBuffer, Gtk::Drag, + Gtk::ToolItem, Gtk::ActionGroup, Gtk::Action, + Gtk::ComboBox, Gtk::Combo, Gtk::IconTheme, + Gtk::SelectionData, Gtk::TargetList, Gtk::ListStore, + Gtk::Window, Gtk::ToggleAction, Gtk::MessageDialog, + Gdk::Region, Gdk::Window, Gtk::Clipboard, + Gtk::Settings, Gtk::TreeModel, Gtk::ModelFilter, + Gtk::TreeViewColumn, Gtk::Widget, Gdk::Pango, + Gdk::Display, Gdk::Drawable, Gtk::RadioAction, + Gdk::Screen, Gtk::TextBuffer, Gdk::Threads, + sample/gtk-demo/*.rb, sample/misc/threads.rb, + pangorenderer.rb + * Added: [KATO Kazuyoshi, Darren Willis, Masao, Mutoh] + * sample/misc/tree_progress.rb, misc_button.rb, + aboutdialog.rb, aboutdialog2.rb, + sample/gtk-demo/clipboard.rb, entry_completion.rb, + expander.rb, iconview.rb + +Ruby/GNOME [Masao Mutoh]: + * Follow Ruby/GLib changes. + +Ruby/GnomeCanvas [Masao Mutoh]: + * Follow Ruby/GLib changes. + +Ruby/Libglade [Masao Mutoh]: + * Follow Ruby/GLib changes. + * Support MS VC++. + * Improved. + +Ruby/Libart [KATO Kazuyoshi, Masao Mutoh]: + * Follow Ruby/GLib changes. + +Ruby/GConf [Masao Mutoh]: + * Follow Ruby/GLib changes. + * Fixed bugs, Improved. + * Deprecated: + * GConf::Client.new + +Ruby/GStreamer: + * Follow Ruby/GLib changes. [Masao Mutoh] + * Added and completed: [Jack Paul, Masao Mutoh, Laurent Sansonetti] + * Gst::TypeFindFactory, Gst::MediaInfoError, Gst::Tag, + Gst::RegistryPool, Gst::TagSetter + * Fixed bugs, Improved, Added some methods: + [Jack Paul, Max Nickel, Masao Mutoh, Laurent Sansonetti] + * Gst::Plugin, Gst::PluginFeature, Gst::Caps, Gst::Structure, + Gst::Xml, Gst::Thread, Gst::Scheduler, Gst::SchedulerFactory, + Gst::MediaInfo, + sample/gst-inspect.rb + +Ruby/GnomeVFS [Masao Mutoh]: + * Follow Ruby/GLib changes. + * Fixed bugs, Improved. + +Ruby/GtkHtml2 [Masao Mutoh]: + * Follow Ruby/GLib changes. + +Ruby/GtkGLExt [Masao Mutoh]: + * Follow Ruby/GLib changes. + +Ruby/Libgda: + * Support 1.1.99 + * Follow Ruby/GLib changes. [Masao Mutoh] + * Fixed bugs, Improved, Added some methods: [Laurent Sansonetti] + Gda::DataModel, Gda::Provider, Gda::Quarklist, Gda::Connection + * Renamed, Moved [Laurent Sansonetti] + * Gda::DataModel#editable? => #updatable? + * #editing? => changed? + * #begin_edit => #begin_update + * #cancel_edit => #cancel_update + * #end_edit => #end_update + +Ruby/PanelApplet [Neil Stevens, Masao Mutoh]: + * Follow Ruby/GLib changes. + * Added some methods + +Ruby/GtkSourceView [Masao Mutoh]: + * Follow Ruby/GLib changes. + * Added some methods + +Ruby/GnomePrint: + * Follow Ruby/GLib changes. [Masao Mutoh, Kouhei Sutou] + * Fixed bugs, Improved, Added some methods. [Kouhei Sutou] + +Ruby/GnomePrintUI: + * Follow Ruby/GLib changes. [Masao Mutoh, Kouhei Sutou] + * Fixed bugs, Improved, Added some methods. [Kouhei Sutou] + +Ruby/RSVG: + * Follow Ruby/GLib changes. [Masao Mutoh, Kouhei Sutou] + * Fixed bugs, Improved, Added some methods. [Kouhei Sutou] + +== Ruby-GNOME2 0.11.0: 2004-11-14 + +Ruby/GLib [Kouhei Sutou, Vincent Isambart, Masao Mutoh]: + * Fix bugs, Improved, Added some methods. + +Ruby/ATK [Vincent Isambart, Masao Mutoh]: + * Support ATK+-1.7.x. + * Fixed bugs, Improved, Added some methods. + +Ruby/Pango [Geoff Youngs, Vincent Isambart, Masao Mutoh]: + * Improved, Fix bugs. + +Ruby/GdkPixbuf [Geoff Youngs, Masao Mutoh]: + * Support GTK+-2.4.x. + * Fixed bugs, Improved, Added some methods. + +Ruby/GTK [Geoff Youngs, Vincent Isambart, Masao Mutoh]: + * Fixed bugs, Improved, Added some methods. + +Ruby/GNOME [Masao Mutoh]: + * Improved. + +Ruby/GnomeCanvas [Masao Mutoh]: + * Fixed bugs, Improved, Added some methods. + +Ruby/Libglade [Masao Mutoh]: + * Improved. + +Ruby/Libart [Vincent Isambart, Masao Mutoh]: + * Improved to support ruby-1.7.x or later. + * Changed: [Masao Mutoh] + * Art::Canvas::Color.new -> Art::Canvas.color. + * Art::Vpath::Dash -> Art::VpathDash. + +Ruby/GConf [Masao Mutoh]: + * Improved. + +Ruby/GStreamer [Masao Mutoh]: + * Improved. + +Ruby/GnomeVFS [Masao Mutoh]: + * Improved. + +Ruby/GtkHtml2 [Masao Mutoh]: + * Improved. + +Ruby/GtkGLExt [Vincent Isambart]: + * Improved. + +Ruby/Libgda: + * None. + +Ruby/PanelApplet: + * None. + +Ruby/GtkSourceView [Vincent Isambart, Masao Mutoh]: + * Fixed bugs. + +Ruby/GnomePrint [NEW]: + * Added. [Kouhei Sutou] + +Ruby/GnomePrintUI [NEW: Alpha release]: + * Added. [Kouhei Sutou] + +Ruby/RSVG [NEW: Alpha release]: + * Added. [Kouhei Sutou] + +== Ruby-GNOME2 0.10.1: 2004-08-16 + +Ruby/GdkPixbuf [Masao Mutoh]: + - Fix bugs. + +Ruby/GTK [Masao Mutoh]: + - Support GTK+-2.0.x again. + +Ruby/GtkSourceView [Masao Mutoh]: + - Fix bugs. + +== Ruby-GNOME2 0.10.0: 2004-08-09 + +Ruby/GLib [Masao Mutoh]: + * Added: [Kazuhiro NISHIYAMA, Masao, Mutoh] + * GLib::Spawn, sample/utils.rb, sample/type-register2.rb + * Added some methods, improved, fixed bugs: [Laurent Sansonetti, + Pascal Terjan, Masao Mutoh] + * GLib, GLib::Object, GLib::Log, glib2.rb, + +Ruby/ATK [Masao Mutoh]: + * None. + +Ruby/Pango [Masao Mutoh]: + * Fix bugs. + +Ruby/GdkPixbuf [Masao Mutoh]: + * Removed version information. + +Ruby/GTK: + * Support GTK+-2.4.x. + * Added: [Seiya Nishizawa, Masao, Mutoh] + * Gtk::ToolButton, Gtk::ToolItem, Gtk::ToggleToolButton, + Gtk::SeperatorToolItem, Gtk::ComboBox, Gtk::ComboBoxEntry, + Gtk::Expander, Gtk::ColorButton, Gtk::FontButton, Gtk::FileChooserWidget, + Gtk::FileChooser, Gtk::FileFilter, Gtk::FileChooserDialog, Gtk::Action, + Gtk::ToggleAction, Gtk::IconInfo, Gtk::IconTheme, Gtk::UIManager, + Gtk::RadioAction, Gtk::CellLayout, Gtk::ActionGroup, + sample/misc/entrycompletion.c, filechooser.rb, combobox.rb, expander.rb, + color_font_button.rb, uimanager.rb, uimanager2.rb, uimanager2.xml + * Improved, fixed bugs: [Geoff Youngs, Vincent Isambart, + Kazuhiro NISHIYAMA, Masao Mutoh] + * Gtk::Style, Gtk::Widget, Gtk::TextView, Gtk::Container, Gdk::EventClient, + Gtk::Dialog, Gtk::Entry, Gdk::Selection, Gtk::Drag, Gdk, Gdk::Atom, + Gtk::Editable, Gtk::Stock, Gtk::TextIter, Gtk::TextMark, Gtk::Style, + sample/misc/dialog2.rb, entry.rb, settings.rb, + * Renamed, Moved: [Masao Mutoh] + * Gtk::EventCrossing::CrossingMode to Gtk::EventCrossing::Mode, + Gdk::SettingAction to Gdk::EventSetting::Action + Gdk::Input.set_extension_events to Gdk::Device. + * Deperecated: [Masao Mutoh] + * Gtk::Combo, Gtk::OptionMenu since GTK+-2.4. + +Ruby/GNOME: + * None. + +Ruby/GnomeCanvas: + * None. + +Ruby/Libglade: + * Added: [Masao Mutoh] + * sample/l10n*, makemo.rb, sample/po/*. + * Added methods: [Masao Mutoh] + * GladeXML#get_tooltips. + * Improved, fixed bugs: [Masao Mutoh] + * GladeXML, bin/ruby-glade-create-template + +Ruby/Libart: + * None. + +Ruby/GConf: + * Added some methods, Improved, fixed bugs: [Giovanni Corriga, Pascal Terjan, + Kazuhiro NISHIYAMA, Masao Mutoh] + * GConf::Client + * Deprecated: [Masao Mutoh] + * GConf::Client.new. Use GConf::Client.default instead. + +Ruby/GStreamer: + * Requires GStreamer-0.8.x or later. + * Added: [Laurent Sansonetti] + * Gst::Clock, Gst::Scheduler + * Added methods, improved, Fixed bugs: [Laurent Sansonetti] + * Gst::Element, Gst::Bin, Gst::Caps, Gst::Structure, + * Removed: [Laurent Sansonetti] + * Gst::Autoplug, Gst::AutoplugFactory, Gst::Type, + Gst::TypeFactory, Gst::TypeFind + Gst.set_debug, + +Ruby/GnomeVFS: + * Fixed bugs: [Pascal Terjan, Giovanni Corriga, Masao Mutoh] + +Ruby/GtkHtml2: + * None. + +Ruby/GtkGLExt: + * Fixed bugs: [Vincent Isambart] + +Ruby/Libgda: + * Added methods, fixed bugs: [Laurent Sansonetti] + * Gda::Command, Gda::Connection + * Removed: [Laurent Sansonetti] + * Gda::Export + +Ruby/PanelApplet [NEW]: + * Added. [Jamis Buck, Masao Mutoh] + +Ruby/GtkSourceView [NEW]: + - Added. [Laurent Sansonetti] + += GNOME2 0.9.1: 2004-03-14 + +Ruby/GLib [Masao Mutoh]: + * Fix a compilation problem on MinGW. + +Ruby/ATK [Masao Mutoh]: + * Fix a compilation problem on MinGW. + * Improved extconf.rb + +Ruby/Pango [Masao Mutoh]: + * Improved extconf.rb + +Ruby/GTK [Masao Mutoh]: + * Fix a compilation problem on MinGW. + * Fix a bug of Gtk::Combo. + * Improved extconf.rb + +Ruby/GConf [Kazuhiro NISHIYAMA]: + * Fix bugs. + +Ruby/Libgda [Laurent Sansonetti]: + * Support libgda-1.0.3(stable branch). + += Ruby-GNOME2 0.9.0: 2004-03-07 + +Ruby/GLib: + * Improved, fixed bugs: [Kenichi Komiya, Vincent Isambart, Masao Mutoh] + * GLib::Object, GLib::Param::Flags, mkmf-gnome2.rb, sample/type-register.rb + * Added new macros: [Masao Mutoh] + * G_DEF_CLASS3() + +Ruby/ATK [NEW]: + * Added and compeleted: [Masao Mutoh] + * Atk::Action, Atk::Document, Atk::GObjectAccessible, Atk::NoOpObject, + Atk::NoOpObjectFactory, Atk::Value, Atk::Component, Atk::Image, + Atk::HyperText, Atk::HyperLink, Atk::EditableText, Atk::Implementor, + Atk::Object, Atk::Relation, Atk::Registry, Atk::ObjectFactory, + Atk::State, Atk::StateSet, Atk::EditableText, Atk::Table + * Added: [Masao Mutoh] + * Atk::Util, Atk::Component, Atk::Selection, Atk::Text + +Ruby/GdkPixbuf: + * None. + +Ruby/Pango: + * None. + +Ruby/GTK: + * Completed: [Masao Mutoh] + * Added and completed: [Masao Mutoh] + * Added: [Kenichi Komiya, Masao, Mutoh] + * Gtk::TextAppearance, sample/misc/bindings.rb, properties.rb, + style_property.rb, settings.rb + * Added some methods, improved, fixed bugs: [Kenichi Komiya, Masahiro Sakai, + Vincent Isambart, Dafydd Harries, Masao Mutoh] + * Gdk::Window, Gtk::SizeGroup, Gtk::Object, Gtk::BindingSet, + Gtk::TextTagTable, Gtk::TextTag, Gdk::Colormap, Gtk::TreeViewColumn, + Gtk::TextIter, Gtk::SpinButton, Gtk::Allocation, Gtk::TextView, + Gtk::TextBuffer, Gtk::Widget, Gtk::Container, Gtk::Setting, Gtk::TreePath, + Gtk::TreeIter, Gdk::Display, Gtk::TextAttributes, Gdk::Property, + Gdk::Keymap, Gdk::Pixmap, Gdk::Drawable, Gdk::Screen, Gdk::Event, + Gdk::EventExpose, Gdk::Selection, Gdk::GC, + sample/gtk-demo/main.rb, stock_browser.rb, list_store.rb, tree_store.rb, + sample/testgtk/notebook.rb, + sample/misc/label.rb, toolbar.rb, + extconf.rb + * Removed: [Masao Mutoh] + * Gtk::Object#activate_binding + * Use Gtk::Object#bindings_activate insted. + * Gtk::TextAttribute#copy + * Use GLib::Boxed#copy instead. + * Gdk::EventKey#string, #length. + * makedefconst.rb + * Deperecated: [Masao Mutoh] + * Gtk::TextBuffer#insert_with_tags, #insert_pixbuf, #insert_child_anchor. + They will be removed until 1.0.0. + Use Gtk::TextBuffer#insert instead. + +Ruby/GNOME: + * Fixed bugs: [Masao Mutoh] + * Gnome::Program + +Ruby/GnomeCanvas: + * Added: [Masao Mutoh] + * Gnome::CanvasShape, Gnome::CanvasRE, Gnome::CanvasClipgroup + * Fixed bugs: [Vincent Isambart, Masao Mutoh] + * extconf.rb, sample/canvas-curve.rb + +Ruby/Libglade: + * Added: [Masao Mutoh] + * sample/custom.[rb|glade] + * Added methods: [Archit Baweja, Masao Mutoh] + * GladeXML#widget_names, #filename, #[], #require, #provide + * Improved, fixed bugs: [Masao Mutoh] + * bin/ruby-glade-create-template + +Ruby/Libart: + * Improved: [Masao Mutoh] + * extconf.rb + +Ruby/GConf: + * None. + +Ruby/GStreamer: + * Added some methods, improved, fixed bugs: [Laurent Sansonetti] + * Gst, Gst::Bin, Gst::Pad, Gst::PadTemplate, Gst::Type, Gst::Element + sample/gst-inspect.rb, media-type2.rb + +Ruby/GnomeVFS: + * Added some methods, improved, fixed bugs: [Masahiro Sakai, Masao Mutoh] + * GnomeVFS::FileInfo, Gnome::VFS::File, GnomeVFS::ProtocolError, + GnomeVFS::NoMasterBrowserError + +Ruby/GtkHtml2: + * Added some methods, fixed bugs: [Vincent Isambart, Masao Mutoh] + * Gtk::HtmlView, Gtk::HtmlStream, extconf.rb + +Ruby/GtkGLExt: + * Added some methods, improved, fixed bugs: [Vincent Isambart, Masao Mutoh] + * Gdk::GLDrawable, sample/*.rb + +Ruby/Libgda: + * Added: [Laurent Sansonetti] + GeometricPoint, Gda::Money, Gdak::Time + * Added some methods, improved, fixed bugs: [Nikolai Weibull, Laurent Sansonetti] + * Gda::Error, Gda::ParameterList, Gda::Provider, Gda::DataSource, + Gda::Connection, Gda::Parameter, Gda::Command, Gda::Row, Gda::Value, + Gda::DataModel, Gda::ModelList, Gda::FieldAttributes + tests/*.rb, src/lib/libgda.rb + +== Ruby-GNOME2 0.8.1: 2003-11-23 + +Ruby/GTK: + * Fixed compilation problems for GTK+-2.0.x. [Masao Mutoh] + * Fixed some bugs. [Masahiro Sakai, Masao Mutoh] + * Added Gtk::Tree* methods for GTK+-2.2.x. [Matthew Berg] + +Ruby/GtkHtml2: + * Fixed compilation problems for libgtkhtml-2.4.1 [Masahiro Sakai] + +Ruby/Libgda: + * Fixed a bug [Laurent Sansonetti] + *Notice* Ruby/Libgda needs libgda-1.0.2(not released yet) or later. + +== Ruby-GNOME2 0.8.0: 2003-11-16 + +Ruby/GLib: + * Provide methods for creating GObject from ruby side. Now you can create + your own signals and properties: [Masahiro, Sakai] + * GLib::MetaInterface, GLib::Instantiatable, GLib::Signal + * Added some methods, improved and Fixed some bugs: + [Masahiro Sakai, Masao Mutoh] + * GLib::Closure, GLib, GLib::Instantiatable, GLib::Object, mkmf-gnome2.rb + * Added new macros: [Masao Mutoh] + * G_RENAME_NICK() + * Added: [Masahiro, Sakai] + * sample/type-register.rb, tests/*.rb + +Ruby/GdkPixbuf: + * Added some methods, improved and Fixed some bugs: + [KATO Kazuyoshi, Masao Mutoh] + * Gdk::Pixbuf + +Ruby/Pango: + * rbpango.h is installed with glib/gtk2 headers. + * Added new methods: [Masao Mutoh] + * Pango::Layout + * Added: [Masao Mutoh] + * PangoLogAttr, PangoAnalysis + +Ruby/GTK: + * Completed: [Masao Mutoh] + * Gdk::Geometry, Gdk::Event*, Gdk::Pixbuf, Gdk::Drawable, + Gdk::DragContext, Gdk::Selection, Gdk::RGB, Gdk::GC, Gdk::Atom, + Gdk::Image, Gdk::Colormap, Gdk::Keyval, Gdk::Screen, Gdk::Visual, + Gdk::Window, Gdk::Display, Gdk + * Added and completed: [Masao Mutoh] + * Gdk::Property, Gdk::Keymap, Gdk::TimeCoord, + * Added some methods, improved, fixed bugs: [Matthew Berg, + Martin Povolny, KATO Kazuyoshi, Laurent Sansonetti, Masahiro Sakai, + Masao Mutoh] + * Gtk::AccelGroup, Gtk::Accelmap, Gtk::Clipboard, Gtk::Notebook, + Gtk::Drag, Gtk::Menu, Gtk::Stock, Gtk::Style, Gtk::ListStore, + Gtk::TreeStore, Gtk::Widget, Gtk::TextBuffer, Gtk::TreePath, + Gtk::TreeRowReference + * Added: [KATO Kazuyoshi] + * sample/gtk-demo/changedisplay.rb, sample/gtk-demo/pixbufs.rb. + * Removed: [Masao Mutoh] + * Gtk::Clipboard#owner + * Gdk::Span + * Gdk::Region#eql?, #&, #-, #| + +Ruby/GNOME: + * Added some methods, improved, fixed bugs: [Masao Mutoh] + * Gnome::AppHelper, Gnome::DruidPageStandard + * Apply Enum/Flags. [Masao Mutoh] + +Ruby/GnomeCanvas: + * None. + +Ruby/Libglade: + * None. + +Ruby/Libart: + * None. + +Ruby/GConf: + * None. + +Ruby/GStreamer: + * Update maintainer's e-mail address [Laurent Sansonetti] + +Ruby/GnomeVFS: + * None. + +Ruby/GtkHtml2: + * Added and completed: [Masao Mutoh] + * Gtk::HtmlContext, Gtk::HtmlBoxTable, + Gtk::HtmlBoxTableRowGroup, + * Completed: [Masao Mutoh] + * Gtk::HtmlView + * Added: [Masao Mutoh] + * Gtk::HtmlBox, Gtk::HtmlBoxBlock, Gtk::HtmlBoxTableCaption, + Gtk::HtmlBoxText, Gtk::BoxRoot, Gtk::BoxForm, + Gtk::HtmlParser, Gtk::HtmlEmbedded, Gtk::HtmlBoxEmbedded + +Ruby/GtkGLExt: + * None. + +Ruby/Libgda [NEW]: + * Added and compeleted: [Laurent Sansonetti] + * Gda, Gda::Client, Gda::Command, Gda::Provider, + Gda::DataSource, Gda::Connection, Gda::DataModelArray, + Gda::DataModelHash, Gda::DataModelList, Gda::Error, + Gda::Export, Gda::FieldAttributes, Gda::Parameter, + Gda::ParameterList, Gda::QuarkList, Gda::Row, + Gda::Select, Gda::Table, Gda::Transaction + * Added + * Gda::DataModel + sample/*.rb, tests/*.rb + +== Ruby-GNOME2 0.7.0: 2003-09-07 + +The whole Ruby-GNOME2: + * Enum/Flags support. Enum/Flags constants are defined as classes. + [Masahiro Sakai, Vincent Isambart, Masao Mutoh] + * Improve extconf.rb. [Masao Mutoh] + If the libraries are not found, they're ignored. + And you can specify to target libraries. + +Ruby/GLib: + * Improved and Fixed some bugs. [Masahiro Sakai, Masao Mutoh] + * GLib::Type, GLib::Boxed, mkmf_gnome2.rb + * Added lib/glib2.rb and improve to support Win32 platform. + [TAMURA.KENICHI, Masahiro Sakai] + * Added new class: [Masahiro Sakai] + * GLib::Enum, GLib::Flags + * Added new macros: [Masahiro Sakai] + * RVAL2GENUM(), RVAL2GFLAGS(), GENUM2RVAL(), GFLAGS2RVAL(). + * Removed some methods. [Masahiro Sakai] + * GLib::Param#value_defaults? + * Define GLib::BINDING_VERSION + * Apply Enum/Flags. [Masahiro Sakai] + * Follow extconf.rb changes. [Masao Mutoh] + +Ruby/GdkPixbuf: + * Apply Enum/Flags. [Masahiro Sakai, Masao Mutoh] + * Follow extconf.rb changes. [Masao Mutoh] + +Ruby/Pango: + * Improved and Fixed some bugs: + [Vincent Isambart, Masahiro Sakai, Masao Mutoh] + * Pango::Font, sample/*.rb, extconf.rb + * Added new methods: [Masahiro Sakai] + * Pango::Language, Pango::FontMap, Pango::FontFamily, Pango::Context, + Pango::FontDescription, + * Apply Enum/Flags. [Masahiro Sakai, Masao Mutoh] + * Follow extconf.rb changes. [Masao Mutoh] + +Ruby/GTK: + * Follow Ruby/GLib changes. [Masahiro Sakai, Masao Mutoh] + * Added some methods, improved, fixed bugs: [Martin Povoln, + KATO Kazuyoshi, Masahiro Sakai, Masao Mutoh] + * Gdk::Atom, Gdk::Input, Gdk::DragContext, Gdk::Event, Gdk::GC, Gdk, + Gtk::Label, Gtk::TreeIter, Gtk::TreeView, Gtk::IconSize, + gdk-demo/*.rb, extconf.rb + * Added: [KATO Kazuyoshi] + * Gdk::DisplayManager, gtk-demo.rb + * Apply Enum/Flags. [Masahiro Sakai, Masao Mutoh] + * Follow extconf.rb changes. [Masao Mutoh] + +Ruby/GNOME: + * Follow extconf.rb changes. [Masao Mutoh] + * Fix bugs. [Masahiro Sakai] + +Ruby/GnomeCanvas: + * Follow extconf.rb changes. [Masao Mutoh] + * Improve extconf.rb. [Masahiro Sakai] + * Fix a sample. [Vincent Isambart] + +Ruby/Libglade: + * Add a 'after' parameter to GladeXML.connect. + It allows to connect signal_connect_after(). [Soila Jani] + * Fix bugs: [Masao Mutoh] + +Ruby/Libart: + * Follow extconf.rb changes. [Masao Mutoh] + +Ruby/GConf: + * Apply Enum/Flags. [Masao Mutoh] + * Follow extconf.rb changes. [Masao Mutoh] + +Ruby/GStreamer: + * Improved and Fixed some bugs. [Laurent Sansonetti] + * Gst, Gst::MediaInfo, Gst::Second, Gst::MediaType, sample/media-type.rb + * Added some methods: [Laurent Sansonetti] + * Gst::Bin, Gst::Registry, Gst::MediaInfoTrack + * Added: [Laurent Sansonetti] + * Gst::XML, Gst::ClockEntry, sample/xml-ogg-player.rb + * Win32 support. [Masahiro Sakai] + * Follow extconf.rb changes. [Masao Mutoh] + +Ruby/GnomeVFS: + * Follow extconf.rb changes. [Masao Mutoh] + +Ruby/GtkHtml2: + * Added: [Martin Povoln, Masao Mutoh] + * Gtk::HtmlStream, lib/gtkhtml2.rb + * Removed methods: [Martin Povoln] + * Gtk::HtmlView#set_html + * Follow extconf.rb changes. [Masao Mutoh] + +Ruby/GtkGLExt [NEW]: + * Added and completed. [Vincent Isambart] + * Gdk::GLConfig, Gdk::GLContext, Gdk::GLDrawable, Gdk::GLPixmap, + Gdk::GLWindow, Gdk::Window, Gdk::Pixmap, Gtk::GL, Gtk::Widget + * Added. [Vincent Isambart] + * Gdk::GL, sample/*.rb + * Follow extconf.rb changes. [Masao Mutoh] + * Win32 support. [Masahiro Sakai] + +== Ruby-GNOME2 0.6.0: 2003-08-09 + +Ruby/GLib: + * mkmf-gnome2.rb,rbglib.h, rbgobject.h, rbgutil.h are installed + to site-ruby directories. + The other libraries which depends on Ruby/GLib can compile + in any directotires. [Masahiro Sakai, Masao Mutoh] + * Support ruby-1.8.0 [Masao Mutoh] + * Added new macros: [Geoff Youngs, Masao Mutoh] + * CBOOL2RVAL/RVAL2CBOOL, G_DEF_CONSTANTS, G_RENAME_CONSTANT + * Improved and Fixed some bugs. [Masahiro Sakai] + * GLib::Object, GLib::Type, GLib::Closure, GLib::Signal, + * Added some methods: [Masahiro Sakai] + * GLib::Param, GLib::Param::*, GLib::Boxed, GLib::Signal, GLib::Pointer + * Removed some methods. [Masahiro Sakai] + * GLib::Param::*#default, #default_value + +Ruby/GdkPixbuf: + * Follow Ruby/GLib changes. [Masao Mutoh] + * Separate Gdk::Pixbuf#scale to #scale and #scale!, + #composite to #composite and #composite!. [Masao Mutoh] + +Ruby/Pango: + * Follow Ruby/GLib changes. [Masao Mutoh] + +Ruby/GTK: + * Follow Ruby/GLib changes. [Sakai, Masahiro, Masao Mutoh] + * rbgtk.h are installed to site-ruby directories. + The other libraries which depends on Ruby/GTK can compile + in any directotires. [Masao Mutoh] + * Completed: [Geoff Youngs, Masao Mutoh] + * Gtk::Clipboard, Gtk::Menu, Gtk::Notebook, Gtk::Socket, Gtk::Plug, + Gtk::FileSelection, Gtk::ListStore, Gtk::TreeStore, Gtk::TreeModel, + Gtk::TextView, Gtk::Notebook, Gtk::ColorSelection, Gtk::Style, + Gtk::ItemFactory, Gtk::Invisible, Gtk::TreeSortable, Gtk::TreeView, + Gtk::TreeSelection, Gtk::TreePath, Gtk::TreeViewColumn, Gtk::Drag, + Gtk::TextTag, Gtk module + * Added and completed. + * Gtk::TreeDragSource, Gtk::TreeDragDest, + * Added some methods, improved, fixed bugs: [Geoff Youngs, + Masahiro Sakai, Masao Mutoh] + * Gdk::Window, Gdk::Drawable, Gdk::EventProperty, Gdk module, + Gtk::Object, Gtk::Editable, Gtk::TreeModel, + Gtk module, Gtk::TextBuffer, Gtk::IMContext, Gtk::Menu + * Added: [Geoff Youngs, Masao Mutoh] + * Gtk::BingindSet, Gdk::Display, Gdk::Screen + * Removed: [Masao Mutoh] + * Gtk::Socket#xwindow, Gtk::Menu#set_path, + Gtk::Notebook#popup_disable/enable, Gtk::ItemFactory.add_foreign + Gtk::TreeSortable#sort_func=, Gtk::TreePath#to_s + +Ruby/GNOME: + * Follow Ruby/GLib changes. [Masao Mutoh] + * Add Gnome::PixmapEntry#set_preview. [Masao Mutoh] + +Ruby/GnomeCanvas: + * Follow Ruby/GLib changes. [Masao Mutoh] + +Ruby/Libglade: + * Follow Ruby/GLib changes. [Masao Mutoh] + +Ruby/Libart: + * Follow Ruby/GLib changes. [Masao Mutoh] + +Ruby/GConf: + * Fix a bug [744158] [Masao Mutoh] + +Ruby/GStreamer [NEW]: + * Merged with Ruby-GStreamer project. [Laurent Sansonetti] + * Version informations are also merged. + * Completed: [Laurent Sansonetti] + * Gst, Gst::Autoplug, Gst::Cpu, Gst::Format, + Gst::Object, Gst::PadTemplate, Gst::Pipeline, + Gst::PluginFeature, Gst::QueryType, + Gst::Type + * Added and completed. [Laurent Sansonetti] + * Gst::AutoplugFactory, Gst::EventMask, Gsk::EventSeek, + Gst::EventSegmentSeek, Gst::EventSize, Gst::Parse, + Gst::SystemClock, Gst::Thread,Gst::MediaInfo, + Gst::MediaInfoStream, Gst::MediaInfoTrack + * Added some methods, improved, fixed bugs: [Laurent Sansonetti] + * Gst::Caps, Gst::Clock, Gst::Plugin, Gst::Pad, Gst::Element, + * Added: [Nikolai :: lone-star :: Weibull, Laurent Sansonetti] + * sample/media-type.rb, gst-inspect.rb, mediap-type2.rb + +Ruby/GnomeVFS [NEW]: + * Initial release. [Nikolai :: lone-star :: Weibull] + * Completed: [Nikolai :: lone-star :: Weibull] + * GnomeVFS module, GnomeVFS::Directory, GnomeVFS::Monitor, + GnomeVFS::FileInfo, GnomeVFS::Error + * Added: [Nikolai :: lone-star :: Weibull] + * GnomeVFS::File, GnomeVFS::URI + +Ruby/GtkHtml2 [NEW]: + * Initial release. [Martin Povoln] + * Added: [Martin Povoln] + * Gtk::HtmlDocument, Gtk::HtmlView + +== Ruby-GNOME2 0.5.0: 2003-05-24 + +Ruby/GLib: + * Fixed warning for ruby-1.8.1. [Masao Mutoh] + * Fixed some bugs, Added methods and improved: [Masahiro Sakai] + * GLib::Object, GLib::ParamSpec, GLib::Signal, GLib::Type, + GLib::Instantiatable, GLib::MetaInterface, GLib::Param::String + * Added: [Geoff Youngs, Masao Mutoh] + +Ruby/GdkPixbuf: + * Fixed a bug. [Geoff Youngs] + +Ruby/Pango: + * Some constants were moved. [Masao Mutoh] + * Moved Pango::Attribute::UNDERLINE_* to Pango::AttrUnderline::*. + * Moved Pango::Attribute::SCALE_* to Pango::AttrScale::*. + +Ruby/GTK: + * Completed: [Masao Mutoh] + Gtk::AccelGroup, Gtk::Style, Gtk::Selection + * Added some methods, improved: [Stephen Lewis, Masahiro Sakai, Masao Mutoh] + * Gtk::TextBuffer, Gtk::TextIter, Gtk::TreeIter, Gtk::ListStore, + Gtk::TreeStore, Gtk, Gtk::HandleBox, Gtk::Frame, Gtk::Container, + Gtk::Table, Gdk::Input, Gtk::Widget, Gtk::Allocation, Gtk::RC, + Gtk::ItemFactory, Gtk::Toolbar, Gtk::Window, Gtk::CellEditable, + Gtk::Accessible, sample/misc/*.rb + * Added and completed. [Nikolai :: lone-star :: Weibull, Masao Mutoh] + * Gtk::RcStyle, Gtk::TargetList, Gtk::TreeSortable, Gtk::TreeModelSort, + Gtk::IMContext, Gtk::IMContextSimple, Gtk::IMMulticontext + * Added: [Masao Mutoh] + * Gtk::Settings + * Renamed some methods. [Masao Mutoh] + * Gtk::Table, Gtk::Widget + * Removed: [Masao Mutoh] + * Gtk::Object#user_data, #user_data=, #set_user_data. + Deprecated properties of Gtk::ProgressBar. + Gtk::Requisition. Use [width, height] instead. + Gtk::Widget#set_requisition, *_event, Gtk::Widget::NO_PARENT. + Gtk::SelectionData.remove_all. Use Gtk::Selection.remove_all instead. + +Ruby/GNOME: + * Cygwin support [Masahiro Sakai] + * sample/test-gnome/color-picker.rb: Follow Ruby/GTK changes.[Masao Mutoh] + +Ruby/GnomeCanvas: + * sample/canvas-primitives.rb: Follow Ruby/GTK changes.[Masao Mutoh] + +Ruby/Libglade: + * Fix a bug of bin/ruby-glade-create-template. [Masao Mutoh] + +Ruby/Libart: + * None + +Ruby/GConf: + - Added GConf::MetaInfo. [Nikolai :: lone-star :: Weibull] + - Fixed a bug [Masao Mutoh] + +== Ruby-GNOME2 0.4.0: 2003-03-23 + +The whole Ruby-GNOME2: + * Add mkmf-gnome2.rb for sub/optional libraries. [Masahiro Sakai] + +Ruby/GLib: + * Win32 platform support(Cygwin, Mingw32) [Masahiro Sakai] + * Support mkmf-gnome2.rb [Masahiro Sakai] + * Added some methods. [KUBO Takehiro, Masahiro Sakai] + * Fix some bugs and improvement. [Masahiro Sakai, Masao Mutoh] + +Ruby/GdkPixbuf: + * Win32 platform support(Cygwin, Mingw32) [Masahiro Sakai] + * Support mkmf-gnome2.rb [Masahiro Sakai] + * Fix some bugs and improvement. [Masahiro Sakai] + +Ruby/Pango: + * Win32 platform support(Cygwin, Mingw32) [Masahiro Sakai] + * Support mkmf-gnome2.rb [Masahiro Sakai] + * Added a method(Pango.pixels) [Masao Mutoh] + * Fix some bugs and improvement. [Masahiro Sakai] + +Ruby/GTK: + * Win32 platform support(Cygwin, Mingw32) [Masahiro Sakai] + * Support mkmf-gnome2.rb [Masahiro Sakai] + * Multi-threading support. [Masao Mutoh] + * Added some methods, improved: [Kazuo Saito, Geoff Youngs, + KATO Kazuyoshi, Masahiro Sakai, Masao Mutoh] + * Gtk::Toolbar, Gtk::ItemFactory, Gdk::Region, Gtk::AccelGroup, + Gtk::AccelMap, Gtk::TextIter, Gtk::TextTagTable, Gtk::TreeModel, + Gtk::TreeSelection, Gtk::Clipboard, Gtk::Box, Gdk::RGB, + Gtk::AccelGroupEntry, Gdk::Window, Gtk::SeparatorMenuItem, + Gtk::TreePath, Gtk::TreeView, Gtk::Combo, Gdk::Threads, + Gtk::TreeIter, Gdk::Event, Gtk::Drag, + * Added: [Kazuo Saito, KATO Kazuyoshi, Masao Mutoh] + * sample/gtk-demo/*.rb, sample/misc/threads.rb + * Removed: [Masao Mutoh] + * Gtk::Toolbar#insert_item/widget/element, + Gtk::Toolbar#prepend_item/widget/element, + Gtk::Toolbar#append_item/widget/element. + * Use Gtk::Toolbar#insert, prepend, append instead. + Gtk::Combo#list, button, popup, popwin, set_item_string, + +Ruby/GNOME: + * Support mkmf-gnome2.rb [Masahiro Sakai] + +Ruby/GnomeCanvas: + * Support mkmf-gnome2.rb [Masahiro Sakai] + +Ruby/Libglade: + * Support mkmf-gnome2.rb [Masahiro Sakai] + * Improved: [Masao Mutoh] + * bin/ruby-glade-create-template + +Ruby/Libart: + * Support mkmf-gnome2.rb [Masahiro Sakai] + * Fix some bugs and improvement. [Masahiro Sakai] + +Ruby/GConf: + * Support mkmf-gnome2.rb [Masahiro Sakai] + +Misc: + * Project website is moving from http://ruby-gnome2.sourceforge.net/ + to http://ruby-gnome2.sourceforge.jp/. + +== Ruby-GNOME2 0.3.0: 2003-02-09 + +Ruby/GLib: + * Miscellaneous bugfixes and some improvement internal. + [Masahiro Sakai, Masao Mutoh] + +Ruby/GTK: + * Miscellaneous bugfixes and some improvement internal. + [Masao Mutoh] + * Support GTK+-2.2.x. [KUBO Takehiro] + * DnD enhancement. [Geoff Youngs, Masao Mutoh] + * Require Ruby/Pango. [Masao Mutoh] + + * Completed: + * Gdk::Drawable, Gdk::Rectangle, Gdk::Region, Gtk::AccelGroup, + Gtk::Accelerator, Gtk::AccelGroupEntry, Gtk::AccelKey + * Added and completed: + * Gdk::Pango::Embossed, Gdk::Pango::Stipple, Gdk::Span + * Added some methods, improved: + * Gtk::Widget, Gtk::Calender, Gdk::GC, Gtk::Drag, Gtk::SelectionData, + Gtk::RadioMenuItem,Gdk::Pixmap + * Added: + * sample/misc/dnd.rb, dndtreeview.rb, dnd.rb + * Removed: + * Gtk::AccelGroup#connect_by_path(use Gtk::AccelGroup#connect instead). + +Ruby/GdkPixbuf: + * Added GdkPixbufLoader. [Geoff Youngs] + +Ruby/GNOME: + * None. + +Ruby/GnomeCanvas: + * Warning fixes for samples. [Masao Mutoh] + +Ruby/Libglade: + * Added a sample(sample/treview.[glade|rb]). [Masao Mutoh] + +Ruby/Libart: + * Added Art::Affine, Art::Bpath, Art::Canvas, Art::SVP, Art::Vpath [Tom Payne] + * Added samples(sample/rose.rb, testlibart2.rb). [Tom Payne] + +Ruby/GConf: + * None. + +Ruby/Pango(NEW): + * Initial release. [Geoff Youngs, Masao Mutoh] + + * Added and completed: + * Pango::Rectangle, Pango::FontDescription, Pango::FontMetrics, + Pango::FontFace, Pango::Fontset, Pango::FontsetSimple, + Pango::Attribute, Pango::AttrString, Pango::AttrLanguage, + Pango::AttrColor, Pango::AttrInt, Pango::AttrFloat, Pango::AttrBool + Pango::AttrFontDesc, Pango::AttrShape, Pango::AttrFamily, + Pango::AttrStyle, Pango::AttrVariant, Pango::AttrStretch, + Pango::AttrWeight, Pango::AttrSize, Pango::AttrForeground, + Pango::AttrBackground, Pango::AttrStrikethrough, Pango::AttrUnderline, + Pango::AttrScale, Pango::AttrRise, Pango::Color, Pango::Language, + Pango::AttrList, Pango::AttrIterator, Pango::TabArray + * Added: + * Pango::Context, Pango::Item, Pango::ClyphString, Pango::Font, + Pango::FontFamily, Pango::FontMap, Pango::Layout, Pango::LayoutIter, + Pango::LayoutLine, + sample/attribute.rb, gdk_layout.rb, label.rb, parse.rb. + +Misc + * Project website + http://ruby-gnome2.sourceforge.net/ + * Ruby/GTK Tutorial + http://ruby-gnome2.sourceforge.net/tut/toc.htm + * Ruby-GNOME2 reference manual(This project has just started). + http://rwiki.jin.gr.jp/cgi-bin/rw-cgi.rb?cmd=view;name=Ruby-GNOME2 + + +== Ruby-GNOME2 0.2: 2002-12-28 + +Ruby/GLib: + * Some bugfixes and some improvement internal. + +Ruby/GTK: + * Some bugfixes and some improvement internal. + * Require Ruby/GdkPixbuf. + * Completed: + * Gtk::TextIter, Gtk::Label, Gtk::Tooltips, Gtk::Viewport. + * Added and completed: + * Gtk::TextAttributes, Gtk::IconFactroy, Gtk::IconSet, + Gtk::IconSource, Gtk::IconSize, Gtk::Accelerator, + Gtk::AccelKey, Gtk::AccelGroupEntry, Gtk::SizeGroup, + * Added some methods, improved: + * Gtk module, Gtk::TextBuffer, Gtk::*MenuItem, Gtk::*Button, + Gtk::ItemFactory, Gtk::Widget, Gtk::TreeViewColumn, + Gtk::Notebook, Gtk::Image, Gtk::AccelLabel, Gtk::Invisible, + Gtk::Dialog, Gtk::TreePath, Gdk::Keyval + sample/misc/*button.rb, stock.rb + sample/testgtk/savedposition.rb + * Added: + * Gtk::Clipboard, Gtk::AccelGroup, Gtk::AccelMap + sample/misc/button2.rb, label.rb, dialog.rb, dialog2.rb, + treeview.rb + * Removed: + * Gdk::Bitmap(use Gdk::Pixmap(depth = 1) instead) + +Ruby/GdkPixbuf: + * Follow Ruby/GLib changes. + * Add Gdk::Pixdata. + +Ruby/GNOME: + * Follow Ruby/GLib changes. + * Fix problems which Ruby/GNOME can't work with Ruby/GdkPixbuf. + * Code cleanup. + * Remove Bonobo codes(Move to Ruby/Bonobo). + +Ruby/GnomeCanvas: + * Follow Ruby/GLib changes. + * Follow Ruby 1.8.0pre1, 1.6.8. + +Ruby/Libglade: + * Follow Ruby/GLib changes. + * Add bin/ruby-glade-create-template(Create .rb from .glade) + * Add sample/treeview* + * Improve the behavior to work when handlers aren't undefined not + to occur signal_proc.arity error. + +Ruby/Libart: + * Follow Ruby/GLib changes. + +Ruby/GConf: + * Follow Ruby/GLib changes. + +Misc: + * Project website: + http://ruby-gnome2.sourceforge.net/ + * Ruby/GTK Tutorial: + http://ruby-gnome2.sourceforge.net/tut/toc.htm + * Ruby-GNOME2 reference manual(This project has just started). + http://rwiki.jin.gr.jp/cgi-bin/rw-cgi.rb?cmd=view;name=Ruby-GNOME2 + +== Ruby-GNOME2 0.1: 2002-11-23 + +Initial release. + + * Ruby/GLib + * Ruby/GTK + * Ruby/GdkPixbuf + * Ruby/GNOME + * Ruby/GnomeCanvas + * Ruby/Libglade + * Ruby/Libart + * Ruby/GConf diff --git a/lib/ruby-gtk2-2.0.2/README b/lib/ruby-gtk2-2.0.2/README new file mode 100644 index 0000000..013a2be --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/README @@ -0,0 +1,206 @@ +# -*- RD -*- + += README + +== Ruby-GNOME2 -- Ruby bindings for GNOME-2.x + +This is a set of bindings for the GNOME-2.x and GNOME-3.x libraries to +use from Ruby 1.8.6, 1.8.7, 1.9.x and 2.0.0. + +== Release packages + +=== ruby-gtk2 + + * Ruby/GLib2: GLib 2.0.x or later + * Ruby/ATK: ATK 1.0.x or later + * Ruby/Pango: Pango 1.1.x or later + * Ruby/GdkPixbuf2: GTK+ 2.0.x or later + * Ruby/GTK2: GTK+ 2.0.x or later + * Ruby/GObjectIntrospection: GObject Introspection 1.32.1 or later + +=== ruby-gtk3 + + * ruby-gtk2 - Ruby/GTK2 + * Ruby/GDK3: GTK+ 3.4.2 or later + * Ruby/GTK3: GTK+ 3.4.2 or later + +=== ruby-gnome2-all + + * ruby-gtk2 + ruby-gtk3 - duplicated libraries + * Ruby/RSVG: librsvg 2.8.0 or later + * Ruby/Poppler: poppler-glib 0.8.0 or later + * Ruby/VTE VTE 0.12.1 or later + * Ruby/GtkSourceView2: GtkSourceView 2.0.0 or later + * Ruby/GIO2: GIO 2.16.x or later + * Ruby/CairoGObject: cairo-gobject 1.12.10 or later + * Ruby/Clutter: Clutter 1.12.0 or later + * Ruby/ClutterGTK: Clutter-GTK 1.2.0 or later + * Ruby/ClutterGStreamer:Clutter-GStreamer 2.0.0 or later + * Ruby/GtkSourceView3: GtkSourceView 3.4.2 or later + * Ruby/VTE3: VTE 0.32.2 or later + * Ruby/WebKitGTK: WebKitGTK+ 1.8.1 or later (for GTK+ 3) + * Ruby/WebKitGTK2: WebKitGTK+ 1.8.1 or later (for GTK+ 2) + * Ruby/GStreamer: GStreamer 1.0.0 or later + * Ruby/GooCanvas: GooCanvas 0.8.0 or later + +=== Experimental / Incomplete: + + * ... + +=== Deprecated + + * Ruby/PanelApplet: gnome-panel 2.6.0 or later (deprecated since 0.16.0) + * Ruby/GConf2: GConf 2.0.x or later + * Ruby/GNOME2: libgnome-2.0.x, libgnomeui-2.0.x or later + * Ruby/GnomeCanvas2: libgnomecanvas-2.0.x or later + * Ruby/GnomePrint: libgnomeprint-2.8.x or later + * Ruby/GnomePrintUI: libgnomeprintui-2.6.x or later + * Ruby/GnomeVFS: GnomeVFS 2.0.x or later + * Ruby/GtkHtml2: GtkHtml2 2.0.x or later + * Ruby/GtkGLExt: GtkGLExt 1.0.3 or later + * Ruby/Libart2: libart_lgpl 2.3.12 or later + * Ruby/GtkSourceView: GtkSourceView 1.0.1 or later + * Ruby/Libglade2: Libglade 2.0.x or later + * Ruby/GtkMozEmbed: GtkMozEmbed (Mozilla 1.7.x or FireFox-1.0.x or later) + +== Install + + % ruby extconf.rb + % make + % sudo make install + +To compile and install a particular sub-binding, you can add arguments: + + % ruby extconf.rb [subdir]... + e.g.) ruby extconf.rb glib2 pango atk gdk_pixbuf2 gtk2 + +Or you can compile each sub-binding: + + % cd + % ruby extconf.rb + % make + % sudo make install + +=== extconf.rb options + +: --ruby + ruby directory + +: --topsrcdir + top source directory + +: --topdir + top directory + +: --strict + if some libraries fail to compile/install, "make" + command returns 1(exit 1) + +=== Environment Variables + +: CAIRO_PATH + rcairo path (for Win32). + +=== Dependencies + +You should install a sub-binding with its dependencies. The +current dependencies are: + +: Ruby/GLib + none. + +: Ruby/ATK + depends on Ruby/GLib. + +: Ruby/Pango + depends on Ruby/GLib, rcairo(optional). + +: Ruby/GdkPixbuf + depends on Ruby/GLib. + +: Ruby/GTK + depends on Ruby/GLib, Ruby/ATK, Ruby/Pango, + Ruby/GdkPixbuf, rcairo(optional) + +: Ruby/RSVG + depends on Ruby/GLib, Ruby/GdkPixbuf2. + +: Ruby/Poppler + depends on Ruby/GLib, Ruby/GdkPixbuf(optional), rcairo(optional). + +: Ruby/VTE + depends on Ruby/GTK. + +: Ruby/GtkSourceView2 + depends on Ruby/GTK. + +: Ruby/GIO2 + depends on Ruby/GLib. + +=== Experimental + +: Ruby/GStreamer + depends on Ruby/GLib. + +: Ruby/GooCanvas + depends on Ruby/GTK. + +=== Deprecated + +: Ruby/PanelApplet + depends on Ruby/GTK (since libpanel-applet 2.25) or + Ruby/GNOME (before libpanel-applet 2.25). + +: Ruby/Libart + depends on Ruby/GLib(Use mkmf-gnome2.rb only). + +: Ruby/GConf + depends on Ruby/GLib. + +: Ruby/GNOME + depends on Ruby/GnomeCanvas. + +: Ruby/GnomeCanvas + depends on Ruby/GTK, Ruby/Libart. + +: Ruby/GnomeVFS + depends on Ruby/GLib. + +: Ruby/GnomePrint + depends on Ruby/GLib, Ruby/Pango, Ruby/Libart2. + +: Ruby/GnomePrintUI + depends on Ruby/GTK, Ruby/GnomePrint. + +: Ruby/GtkHtml2 + depends on Ruby/GTK. + +: Ruby/GtkGLExt + depends on Ruby/GTK, rbogl. + +: Ruby/GtkSourceView + depends on Ruby/GTK. + +: Ruby/Libglade + depends on Ruby/GTK, Ruby/GNOME(optional), REXML(optional). + +== Bugs + +Please report bugs either in our bug tracker +(()) + +or on the ruby-gnome2-devel-en / ruby-gnome2-devel-ja mailing list +(()) + +== Copying + +Copyright (c) 2002-2009 Ruby-GNOME2 Project Team + +This program is free software. +You can distribute/modify this program under the terms of +the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. + +== Project Website + +(()) + diff --git a/lib/ruby-gtk2-2.0.2/Rakefile b/lib/ruby-gtk2-2.0.2/Rakefile new file mode 100644 index 0000000..220b6ba --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/Rakefile @@ -0,0 +1,433 @@ +# -*- ruby -*- + +require "pathname" +require "tmpdir" +require "open-uri" + +repository_base_url = "https://ruby-gnome2.svn.sourceforge.net/svnroot/ruby-gnome2/ruby-gnome2" + +task :default => :test + +def version + @version ||= ENV["VERSION"] || guess_version +end + +def guess_version + versions = {} + File.open("glib2/ext/glib2/rbglib.h") do |rbglib_h| + rbglib_h.each_line do |line| + if /#define\s+RBGLIB_([A-Z]+)_VERSION\s+(\d+)/ =~ line + versions[$1.downcase] = $2.to_i + end + end + end + ["major", "minor", "micro"].collect {|type| versions[type]}.compact.join(".") +end + +def dist_dir(base_name, _version=nil) + _version ||= version + "#{base_name}-#{_version}" +end + +def archive_name(base_name, _version=nil) + dist_dir(base_name, _version) + ".tar.gz" +end + +@needless_paths = [".svn", ".test-result", ".gdb_history", "mkmf.log", + "*.o", "*.so", "pkg", "vendor", "tmp"] +def package(base_name, paths, needless_paths=nil) + _dist_dir = dist_dir(base_name) + + rm_rf(_dist_dir) + mkdir_p(_dist_dir) + cp_r(paths, _dist_dir, :preserve => true) + + needless_paths ||= @needless_paths + Dir.glob("#{_dist_dir}/**/{#{needless_paths.join(',')}}") do |needless_path| + rm_rf(needless_path) + end + sh("tar", "cvfz", archive_name(base_name), _dist_dir) +ensure + rm_rf(_dist_dir) if _dist_dir +end + +def download(url, local_path=nil) + local_path ||= File.basename(url) + open(url) do |remote_file| + File.open(local_path, "wb") do |local_file| + local_file.print(remote_file.read) + end + end + local_path +end + +def change_environment_variable(variables) + original_variables = {} + variables.each do |key, value| + next if ENV[key] + original_variables[key] = ENV[key] + ENV[key] = value + end + + begin + yield + ensure + original_variables.each do |key, value| + ENV[key] = value + end + end +end + +desc "configure all packages" +task :configure do + ruby("extconf.rb") +end + +file "Makefile" do + task(:configure).invoke +end + +desc "build all packages" +task :build => ["Makefile"] do + sh("make") +end + +desc "clean all packages" +task :clean do + sh("make", "clean") if File.exist?("Makefile") +end + +desc "more clean all packages" +task :distclean do + sh("make", "distclean") if File.exist?("Makefile") +end + +desc "run tests for all packages" +task :test => [:build] do + ruby("run-test.rb") +end + +gtk2_base_name = "ruby-gtk2" +gtk3_base_name = "ruby-gtk3" +gnome2_base_name = "ruby-gnome2-all" + +gtk2_packages = [ + "glib2", + "gobject-introspection", + "gio2", + "atk", + "pango", + "gdk_pixbuf2", + "gtk2", +] +gtk3_packages = gtk2_packages - ["gtk2"] + ["gdk3", "gtk3"] +gnome2_packages = gtk2_packages + gtk3_packages + [ + "goocanvas", + "gstreamer", + "gtksourceview2", + "poppler", + "rsvg2", + "vte", + "vte3", + "cairo-gobject", + "gtksourceview3", + "clutter", + "clutter-gtk", + "clutter-gstreamer", + "webkit-gtk", + "webkit-gtk2", +] +gnome2_packages = gnome2_packages.uniq + +namespace :dist do + base_files = ["AUTHORS", "COPYING.LIB", "NEWS", + "README", "Rakefile", + "exec_make.rb", "extconf.rb", "run-test.rb"] + desc "make Ruby/GTK2 package" + task :gtk2 do + package(gtk2_base_name, base_files + gtk2_packages) + end + + desc "make Ruby/GTK3 package" + task :gtk3 do + package(gtk3_base_name, base_files + gtk3_packages) + end + + desc "make Ruby/GNOME2 package" + task :gnome2 do + package(gnome2_base_name, base_files + gnome2_packages) + end + + ruby_versions = ["1.9.3-p392", "2.0.0-p0"] + namespace :test do + ruby_base_url = "ftp://ftp.ruby-lang.org/pub/ruby" + ruby_versions.each do |ruby_version| + base_dir = "tmp/dist-test-#{version}/#{ruby_version}" + directory base_dir + + prefix = Pathname.new(base_dir) + "local" + ruby_tar_bz2_base = "ruby-#{ruby_version}.tar.bz2" + file "#{base_dir}/#{ruby_tar_bz2_base}" => base_dir do + generation = ruby_version.scan(/\A\d\.\d/)[0] + ruby_tar_bz2_url = "#{ruby_base_url}/#{generation}/#{ruby_tar_bz2_base}" + Dir.chdir(base_dir) do + download(ruby_tar_bz2_url) + end + end + + ruby_path = "#{prefix}/bin/ruby" + expanded_ruby_path = File.expand_path(ruby_path) + file ruby_path => "#{base_dir}/#{ruby_tar_bz2_base}" do + expanded_prefix = prefix.expand_path + Dir.chdir(base_dir) do + sh("tar", "xvf", ruby_tar_bz2_base) + Dir.chdir(File.basename(ruby_tar_bz2_base, ".tar.bz2")) do + sh("./configure", "--prefix=#{expanded_prefix}") + sh("make", "-j8") + sh("make", "install-nodoc") + end + end + end + + rubygems_tgz_base = "rubygems-1.8.24.tgz" + rubygems_tgz = "#{base_dir}/#{rubygems_tgz_base}" + file rubygems_tgz => base_dir do + rubygems_url_base = "http://production.cf.rubygems.org/rubygems" + Dir.chdir(base_dir) do + download("#{rubygems_url_base}/#{rubygems_tgz_base}") + end + end + + gem_path = "#{prefix}/bin/gem" + expanded_gem_path = File.expand_path(gem_path) + file gem_path => [ruby_path, rubygems_tgz] do + Dir.chdir(base_dir) do + sh("tar", "xvf", rubygems_tgz_base) + Dir.chdir(File.basename(rubygems_tgz_base, ".tgz")) do + sh(expanded_ruby_path, "setup.rb") + end + end + end + + packages = { + "gtk2" => { + :archive_name => archive_name(gtk2_base_name), + :packages => gtk2_packages, + }, + "gtk3" => { + :archive_name => archive_name(gtk3_base_name), + :packages => gtk3_packages, + }, + "gnome2" => { + :archive_name => archive_name(gnome2_base_name), + :packages => gnome2_packages, + }, + } + namespace "ruby-#{ruby_version}" do + packages.each do |name, attributes| + namespace name do + tar_gz = File.expand_path(attributes[:archive_name]) + task :prepare => ["dist:#{name}", gem_path] do + Dir.chdir(base_dir) do + sh("tar", "xvf", tar_gz) + end + if /cairo/ !~ `#{expanded_gem_path} list cairo` + sh(expanded_gem_path, "install", "cairo") + end + end + + attributes[:packages].each do |sub_package_name| + task sub_package_name => :prepare do + Dir.chdir(base_dir) do + package_base_dir = File.basename(tar_gz, ".tar.gz") + rm_rf(sub_package_name) + sh("cp", "-a", + "#{package_base_dir}/#{sub_package_name}", sub_package_name) + Dir.chdir(sub_package_name) do + if File.exist?("extconf.rb") + sh(expanded_ruby_path, "extconf.rb") + sh("make", "-j8") + sh("make", "install") + end + end + rm_rf(sub_package_name) + end + end + end + end + end + + packages.each do |name, attributes| + test_tasks = attributes[:packages].collect do |sub_package_name| + "dist:test:ruby-#{ruby_version}:#{name}:#{sub_package_name}" + end + task name => test_tasks + end + end + + test_tasks = packages.collect do |name, attributes| + "dist:test:ruby-#{ruby_version}:#{name}" + end + task "ruby-#{ruby_version}" => test_tasks + end + end + + test_tasks = ruby_versions.collect do |ruby_version| + "dist:test:ruby-#{ruby_version}" + end + desc "run packages test" + task :test => test_tasks +end +desc "make all packages" +task :dist => ["dist:gtk2", "dist:gtk3", "dist:gnome2"] + +directory "misc" +file "misc/release.rb" => "misc" do |task| + release_rb = "https://raw.github.com/clear-code/cutter/master/misc/release.rb" + open(release_rb) do |remote_release_rb| + File.open(task.name, "w") do |local_release_rb| + local_release_rb.print(remote_release_rb.read) + end + end +end + +desc "release Ruby-GNOME2 packages" +task :release => ["misc/release.rb", :dist] do + sf_user_name = ENV["SF_USER"] || ENV["USER"] + project_id = "ruby-gnome2" + project_name = "Ruby-GNOME 2" + package_name = "ruby-gnome2" + release_name = "ruby-gnome2-#{version}" + package_base_names = [gtk2_base_name, gtk3_base_name, gnome2_base_name] + archive_names = package_base_names.collect do |base_name| + archive_name(base_name) + end + ruby("misc/release.rb", sf_user_name, project_id, project_name, + package_name, release_name, "README:1", "NEWS", + *archive_names) +end + +namespace :gem do + desc "build all gems" + task :build do + gnome2_packages.each do |package| + Dir.chdir(package) do + ruby("-S", "rake", "gem") + end + end + end + + desc "push all gems" + task :push do + gnome2_packages.each do |package| + ruby("-S", "gem", "push", + *Dir.glob(File.join(package, "pkg", "*-#{version}.gem"))) + end + end + + desc "install all gems" + task :install do + gnome2_packages.each do |package| + ruby("-S", "gem", "install", "--user-install", + *Dir.glob(File.join(package, "pkg", "*-#{version}.gem"))) + end + end + + desc "uninstall all gems" + task :uninstall do + gnome2_packages.each do |package| + ruby("-S", "gem", "uninstall", "--version", version, package) + end + end + + namespace :win32 do + win32_unsupported_packages = [ + "goocanvas", + "vte", + "vte3", + "webkit-gtk", + "webkit-gtk2", + ] + win32_gnome2_packages = gnome2_packages - win32_unsupported_packages + + namespace :build do + desc "build all Windows binaries" + task :vendor do + win32_gnome2_packages.each do |package| + Dir.chdir(package) do + ruby("-S", "rake", "native:build", "win32:build") + end + end + end + + desc "build all Windows bindings" + task :ext do + change_environment_variable("MAKE" => "make debugflags=") do + win32_gnome2_packages.each do |package| + Dir.chdir(package) do + tasks = [ + "cross", + "win32:builder:build:prepare:pkg_config", + "native", + "gem", + ] + ruby("-S", "rake", "RUBY_CC_VERSION=1.9.3:2.0.0", *tasks) + end + end + end + end + + desc "build GSettings schemas for all Windows binaries" + task :schema do + Dir.mktmpdir do |dir| + win32_gnome2_packages.each do |package| + gschema_xml_glob = File.join(package, "vendor", "local", "share", + "glib-2.0", "schemas", "*.gschema.xml") + Dir.glob(gschema_xml_glob).each do |schema| + cp(schema, dir) + end + end + sh("glib-compile-schemas", + "--targetdir", "glib2/vendor/local/share/glib-2.0/schemas", + dir) + end + end + end + + desc "build all Windows gems" + task :build => [ + "gem:win32:build:vendor", + "gem:win32:build:schema", + "gem:win32:build:ext", + ] + + desc "clean all Windows gems build" + task :clean do + win32_gnome2_packages.each do |package| + rm_rf(File.join(package, "tmp")) + end + end + + desc "download DLL for Windows all gems" + task :download do + win32_gnome2_packages.each do |package| + Dir.chdir(package) do + ruby("-S", "rake", "win32:download") + end + end + end + + desc "push all Windows gems" + task :push do + win32_gnome2_packages.each do |package| + ruby("-S", "gem", "push", + *Dir.glob(File.join(package, "pkg", "*-#{version}-x86-mingw32.gem"))) + end + end + end +end + +desc "tag the current release" +task :tag do + sh("git", "tag", "-a", version, "-m", "release #{version}!!!") +end diff --git a/lib/ruby-gtk2-2.0.2/atk/COPYING.LIB b/lib/ruby-gtk2-2.0.2/atk/COPYING.LIB new file mode 100644 index 0000000..b1e3f5a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/COPYING.LIB @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. + + GNU LESSER GENERAL PUBLIC LICENSE + 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 + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/lib/ruby-gtk2-2.0.2/atk/README b/lib/ruby-gtk2-2.0.2/atk/README new file mode 100644 index 0000000..035808f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/README @@ -0,0 +1,30 @@ +Ruby/ATK +=============== +Ruby/ATK is a Ruby binding of ATK-1.0.x or later. + +Requirements +------------ + Ruby: http://www.ruby-lang.org/ + GLib: http://www.gtk.org/ + ATK: http://developer.gnome.org/projects/gap + Ruby/GLib2: http://ruby-gnome2.sourceforge.net/ + +Install +------- + 0. install ruby-1.6.x or later, GLib, ATK, Ruby/GLib2. + 1. ruby extconf.rb + 2. make + 3. su + 4. make install + +Copying +------- + Copyright (c) 2003-2005 Ruby-GNOME2 Project Team + + This program is free software. + You can distribute/modify this program under the terms of + the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. + +Project Website +--------------- + http://ruby-gnome2.sourceforge.jp/ diff --git a/lib/ruby-gtk2-2.0.2/atk/Rakefile b/lib/ruby-gtk2-2.0.2/atk/Rakefile new file mode 100644 index 0000000..2a58ec7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/Rakefile @@ -0,0 +1,30 @@ +# -*- ruby -*- + +$LOAD_PATH.unshift("./../glib2/lib") +require "gnome2/rake/package-task" + +package_task = GNOME2::Rake::PackageTask.new do |package| + package.summary = "Ruby/ATK is a Ruby binding of ATK-1.0.x." + package.description = "Ruby/ATK is a Ruby binding of ATK-1.0.x." + package.dependency.gem.runtime = ["glib2"] + package.windows.packages = [] + package.windows.dependencies = [] + package.windows.build_dependencies = ["glib2", "gobject-introspection"] + package.external_packages = [ + { + :name => "atk", + :download_site => :gnome, + :label => "atk", + :version => "2.8.0", + :compression_method => "xz", + :windows => { + :configure_args => [ + "--enable-introspection", + ], + :build_concurrently => false, + }, + } + ] +end +package_task.define + diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/atk.def b/lib/ruby-gtk2-2.0.2/atk/ext/atk/atk.def new file mode 100644 index 0000000..d523068 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/atk.def @@ -0,0 +1,2 @@ +EXPORTS + Init_atk diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/depend b/lib/ruby-gtk2-2.0.2/atk/ext/atk/depend new file mode 100644 index 0000000..72cfba0 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/depend @@ -0,0 +1,11 @@ +install-so: install-headers +install-headers: + $(INSTALL_DATA) $(srcdir)/rbatk.h $(RUBYARCHDIR) + $(INSTALL_DATA) rbatkversion.h $(RUBYARCHDIR) + +install: install-pc +install-pc: + if test -n "$(pkgconfigdir)"; then \ + $(MAKEDIRS) $(pkgconfigdir); \ + $(INSTALL_DATA) ruby-atk.pc $(pkgconfigdir); \ + fi diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/extconf.rb b/lib/ruby-gtk2-2.0.2/atk/ext/atk/extconf.rb new file mode 100644 index 0000000..39d77dc --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/extconf.rb @@ -0,0 +1,81 @@ +=begin +extconf.rb for Ruby/Atk extention library +=end + +require 'pathname' + +base_dir = Pathname(__FILE__).dirname.parent.parent.expand_path +top_dir = base_dir.parent +top_build_dir = Pathname(".").parent.parent.parent.expand_path + +mkmf_gnome2_dir = top_dir + "glib2" + 'lib' +version_suffix = "" +unless mkmf_gnome2_dir.exist? + if /(-\d+\.\d+\.\d+)(?:\.\d+)?\z/ =~ base_dir.basename.to_s + version_suffix = $1 + mkmf_gnome2_dir = top_dir + "glib2#{version_suffix}" + 'lib' + end +end + +$LOAD_PATH.unshift(mkmf_gnome2_dir.to_s) + +module_name = "atk" +package_id = "atk" + +begin + require 'mkmf-gnome2' +rescue LoadError + require 'rubygems' + gem 'glib2' + require 'mkmf-gnome2' +end + +ruby_header = 'ruby.h' +have_func 'rb_errinfo', ruby_header + +["glib2"].each do |package| + directory = "#{package}#{version_suffix}" + build_dir = "#{directory}/tmp/#{RUBY_PLATFORM}/#{package}/#{RUBY_VERSION}" + add_depend_package(package, "#{directory}/ext/#{package}", + top_dir.to_s, + :top_build_dir => top_build_dir.to_s, + :target_build_dir => build_dir) +end + +setup_win32(module_name, base_dir) + +unless required_pkg_config_package(package_id, + :debian => "libatk1.0-dev", + :redhat => "atk-devel", + :homebrew => "atk", + :macports => "atk") + exit(false) +end + +atk_header = "atk/atk.h" +have_func('atk_action_get_localized_name', atk_header) +have_func('atk_hyperlink_is_inline', atk_header) +have_func('atk_object_add_relationship', atk_header) +have_func('atk_object_remove_relationship', atk_header) +have_func('atk_component_get_layer', atk_header) +have_func('atk_component_get_mdi_zorder', atk_header) +have_func('atk_hyperlink_is_selected_link', atk_header) +have_func('atk_text_get_bounded_ranges', atk_header) +have_func('atk_role_get_localized_name', atk_header) +have_func('atk_text_clip_type_get_type', atk_header) + +have_func('atk_text_free_ranges', atk_header) + +make_version_header("ATK", package_id, ".") + +create_pkg_config_file("Ruby/ATK", package_id) +$defs << " -DRUBY_ATK_COMPILATION" +create_makefile(module_name) + +pkg_config_dir = with_config("pkg-config-dir") +if pkg_config_dir.is_a?(String) + File.open("Makefile", "ab") do |makefile| + makefile.puts + makefile.puts("pkgconfigdir=#{pkg_config_dir}") + end +end diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatk.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatk.c new file mode 100644 index 0000000..f887b3a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatk.c @@ -0,0 +1,66 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE mAtk +VALUE mAtk; + +extern void Init_atk(void); + +void +Init_atk(void) +{ + RG_TARGET_NAMESPACE = rb_define_module("Atk"); + + rb_define_const(RG_TARGET_NAMESPACE, "BUILD_VERSION", + rb_ary_new3(3, + INT2FIX(ATK_MAJOR_VERSION), + INT2FIX(ATK_MINOR_VERSION), + INT2FIX(ATK_MICRO_VERSION))); + + Init_atk_action(RG_TARGET_NAMESPACE); + Init_atk_component(RG_TARGET_NAMESPACE); + Init_atk_document(RG_TARGET_NAMESPACE); + Init_atk_editabletext(RG_TARGET_NAMESPACE); + Init_atk_gobjectaccessible(RG_TARGET_NAMESPACE); + Init_atk_hyperlink(RG_TARGET_NAMESPACE); + Init_atk_hypertext(RG_TARGET_NAMESPACE); + Init_atk_image(RG_TARGET_NAMESPACE); + Init_atk_implementor(RG_TARGET_NAMESPACE); + Init_atk_noopobject(RG_TARGET_NAMESPACE); + Init_atk_noopobjectfactory(RG_TARGET_NAMESPACE); + Init_atk_object(RG_TARGET_NAMESPACE); + Init_atk_objectfactory(RG_TARGET_NAMESPACE); + Init_atk_registry(RG_TARGET_NAMESPACE); + Init_atk_relation(RG_TARGET_NAMESPACE); + Init_atk_relation_set(RG_TARGET_NAMESPACE); + Init_atk_selection(RG_TARGET_NAMESPACE); + Init_atk_state(RG_TARGET_NAMESPACE); + Init_atk_state_set(RG_TARGET_NAMESPACE); + Init_atk_streamable_content(RG_TARGET_NAMESPACE); + Init_atk_table(RG_TARGET_NAMESPACE); + Init_atk_text(RG_TARGET_NAMESPACE); + Init_atk_text_range(RG_TARGET_NAMESPACE); + Init_atk_text_rectangle(RG_TARGET_NAMESPACE); + Init_atk_util(RG_TARGET_NAMESPACE); + Init_atk_value(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatk.h b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatk.h new file mode 100644 index 0000000..85a56d1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatk.h @@ -0,0 +1,47 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003,2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "ruby.h" +#include +#include +#include +#include +#include "rbgobject.h" +#include "rbatkversion.h" +#include "rbatkconversions.h" + +#if defined(G_PLATFORM_WIN32) && !defined(RUBY_ATK_STATIC_COMPILATION) +# ifdef RUBY_ATK_COMPILATION +# define RUBY_ATK_VAR __declspec(dllexport) +# else +# define RUBY_ATK_VAR extern __declspec(dllimport) +# endif +#else +# define RUBY_ATK_VAR extern +#endif + +extern GType atk_text_rectangle_get_type(void); +extern GType atk_text_range_get_type(void); + +RUBY_ATK_VAR VALUE mAtk; + +#define ATK_TYPE_TEXT_RECTANGLE (atk_text_rectangle_get_type()) +#define ATK_TYPE_TEXT_RANGE (atk_text_range_get_type()) diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkaction.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkaction.c new file mode 100644 index 0000000..f11d9aa --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkaction.c @@ -0,0 +1,85 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE mAction +#define _SELF(s) (RVAL2ATKACTION(s)) + +static VALUE +rg_do_action(VALUE self, VALUE i) +{ + return CBOOL2RVAL(atk_action_do_action(_SELF(self), NUM2INT(i))); +} + +static VALUE +rg_n_actions(VALUE self) +{ + return INT2NUM(atk_action_get_n_actions(_SELF(self))); +} + +static VALUE +rg_get_description(VALUE self, VALUE i) +{ + return CSTR2RVAL(atk_action_get_description(_SELF(self), NUM2INT(i))); +} + +static VALUE +rg_get_name(VALUE self, VALUE i) +{ + return CSTR2RVAL(atk_action_get_name(_SELF(self), NUM2INT(i))); +} + +#ifdef HAVE_ATK_ACTION_GET_LOCALIZED_NAME +static VALUE +rg_get_localized_name(VALUE self, VALUE i) +{ + return CSTR2RVAL(atk_action_get_localized_name(_SELF(self), NUM2INT(i))); +} +#endif + +static VALUE +rg_get_keybinding(VALUE self, VALUE i) +{ + return CSTR2RVAL(atk_action_get_keybinding(_SELF(self), NUM2INT(i))); +} + +static VALUE +rg_set_description(VALUE self, VALUE i, VALUE desc) +{ + return CBOOL2RVAL(atk_action_set_description(_SELF(self), NUM2INT(i), RVAL2CSTR(desc))); +} + +void +Init_atk_action(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(ATK_TYPE_ACTION, "Action", mAtk); + + RG_DEF_METHOD(do_action, 1); + RG_DEF_METHOD(n_actions, 0); + RG_DEF_METHOD(get_description, 1); + RG_DEF_METHOD(get_name, 1); +#ifdef HAVE_ATK_ACTION_GET_LOCALIZED_NAME + RG_DEF_METHOD(get_localized_name, 1); +#endif + RG_DEF_METHOD(get_keybinding, 1); + RG_DEF_METHOD(set_description, 2); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkcomponent.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkcomponent.c new file mode 100644 index 0000000..2d28624 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkcomponent.c @@ -0,0 +1,179 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE mComponent +#define _SELF(s) (RVAL2ATKCOMPONENT(s)) + +/* +static void +focus_handler(AtkObject *aobj, gboolean bool) +{ + VALUE ret = rb_funcall((VALUE)func, id_call, 2, + GOBJ2RVAL(aobj), CBOOL2RVAL(bool)); +} +static VALUE +rg_add_focus_handler(VALUE self) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + return UINT2NUM(atk_component_add_focus_handler(_SELF(self), focus_handler)); +} +*/ + +static VALUE +rg_contains_p(VALUE self, VALUE x, VALUE y, VALUE coord_type) +{ + return CBOOL2RVAL(atk_component_contains(_SELF(self), + NUM2INT(x), NUM2INT(y), + RVAL2ATKCOORDTYPE(coord_type))); +} + +static VALUE +rg_get_extents(VALUE self, VALUE coord_type) +{ + gint x, y, width, height; + atk_component_get_extents(_SELF(self), &x, &y, &width, &height, + RVAL2ATKCOORDTYPE(coord_type)); + return rb_ary_new3(4, INT2NUM(x), INT2NUM(y), INT2NUM(width), INT2NUM(height)); +} + +#ifdef HAVE_ATK_COMPONENT_GET_LAYER +static VALUE +rg_layer(VALUE self) +{ + return ATKLAYER2RVAL(atk_component_get_layer(_SELF(self))); +} +#endif + +#ifdef HAVE_ATK_COMPONENT_GET_MDI_ZORDER +static VALUE +rg_mdi_zorder(VALUE self) +{ + return INT2NUM(atk_component_get_mdi_zorder(_SELF(self))); +} + +#endif +static VALUE +rg_position(VALUE self, VALUE coord_type) +{ + gint x, y; + atk_component_get_position(_SELF(self), &x, &y, + RVAL2ATKCOORDTYPE(coord_type)); + return rb_assoc_new(INT2NUM(x), INT2NUM(y)); +} + +static VALUE +rg_size(VALUE self) +{ + gint width, height; + atk_component_get_size(_SELF(self), &width, &height); + return rb_assoc_new(INT2NUM(width), INT2NUM(height)); +} + +static VALUE +rg_grab_focus(VALUE self) +{ + return CBOOL2RVAL(atk_component_grab_focus(_SELF(self))); +} + +static VALUE +rg_ref_accessible_at_point(VALUE self, VALUE x, VALUE y, VALUE coord_type) +{ + return GOBJ2RVAL(atk_component_ref_accessible_at_point( + _SELF(self), + NUM2INT(x), NUM2INT(y), + RVAL2ATKCOORDTYPE(coord_type))); +} + +static VALUE +rg_remove_focus_handler(VALUE self, VALUE handler_id) +{ + atk_component_remove_focus_handler(_SELF(self), NUM2UINT(handler_id)); + return self; +} + +static VALUE +rg_set_extents(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height, VALUE coord_type) +{ + gboolean ret = atk_component_set_extents(_SELF(self), + NUM2INT(x), NUM2INT(y), + NUM2INT(width), NUM2INT(height), + RVAL2ATKCOORDTYPE(coord_type)); + if (! ret) rb_raise(rb_eRuntimeError, "Can't set extents"); + return self; +} + +static VALUE +rg_set_position(VALUE self, VALUE x, VALUE y, VALUE coord_type) +{ + gboolean ret = atk_component_set_position(_SELF(self), + NUM2INT(x), NUM2INT(y), + RVAL2ATKCOORDTYPE(coord_type)); + if (! ret) rb_raise(rb_eRuntimeError, "Can't set the position"); + return self; +} + +static VALUE +rg_set_size(VALUE self, VALUE width, VALUE height) +{ + gboolean ret = atk_component_set_size(_SELF(self), + NUM2INT(width), NUM2INT(height)); + if (! ret) rb_raise(rb_eRuntimeError, "Can't set the size"); + return self; +} + +#if ATK_CHECK_VERSION(1,12,0) +static VALUE +rg_alpha(VALUE self) +{ + return rb_float_new(atk_component_get_alpha(_SELF(self))); +} +#endif + +void +Init_atk_component(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(ATK_TYPE_COMPONENT, "Component", mAtk); +/* + RG_DEF_METHOD(add_focus_handler, 0); +*/ + RG_DEF_METHOD_P(contains, 3); + RG_DEF_METHOD(get_extents, 1); +#ifdef HAVE_ATK_COMPONENT_GET_LAYER + RG_DEF_METHOD(layer, 0); +#endif +#ifdef HAVE_ATK_COMPONENT_GET_MDI_ZORDER + RG_DEF_METHOD(mdi_zorder, 0); +#endif + RG_DEF_METHOD(position, 1); + RG_DEF_METHOD(size, 0); + RG_DEF_METHOD(grab_focus, 0); + RG_DEF_METHOD(ref_accessible_at_point, 3); + RG_DEF_METHOD(remove_focus_handler, 1); + RG_DEF_METHOD(set_extents, 5); + RG_DEF_METHOD(set_position, 2); + RG_DEF_METHOD(set_size, 2); +#if ATK_CHECK_VERSION(1,12,0) + RG_DEF_METHOD(alpha, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkconversions.h b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkconversions.h new file mode 100644 index 0000000..f3599c2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkconversions.h @@ -0,0 +1,70 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __RBATKCONVERSIONS_H__ +#define __RBATKCONVERSIONS_H__ + +#define RVAL2ATKACTION(o) (ATK_ACTION(RVAL2GOBJ(o))) +#define RVAL2ATKCOMPONENT(o) (ATK_COMPONENT(RVAL2GOBJ(o))) +#define RVAL2ATKDOCUMENT(o) (ATK_DOCUMENT(RVAL2GOBJ(o))) +#define RVAL2ATKEDITABLETEXT(o) (ATK_EDITABLE_TEXT(RVAL2GOBJ(o))) +#define RVAL2ATKGOBJECTACCESSIBLE(o) (ATK_GOBJECT_ACCESSIBLE(RVAL2GOBJ(o))) +#define RVAL2ATKHYPERLINK(o) (ATK_HYPERLINK(RVAL2GOBJ(o))) +#define RVAL2ATKHYPERTEXT(o) (ATK_HYPERTEXT(RVAL2GOBJ(o))) +#define RVAL2ATKIMAGE(o) (ATK_IMAGE(RVAL2GOBJ(o))) +#define RVAL2ATKIMPLEMENTOR(o) (ATK_IMPLEMENTOR(RVAL2GOBJ(o))) +#define RVAL2ATKNOOPOBJECT(o) (ATK_NOOPOBJECT(RVAL2GOBJ(o))) +#define RVAL2ATKNOOPOBJECTFACTORY(o) (ATK_NO_OP_OBJECT_FACTORY(RVAL2GOBJ(o))) +#define RVAL2ATKOBJECT(o) (ATK_OBJECT(RVAL2GOBJ(o))) +#define RVAL2ATKOBJECTFACTORY(o) (ATK_OBJECT_FACTORY(RVAL2GOBJ(o))) +#define RVAL2ATKREGISTRY(o) (ATK_REGISTRY(RVAL2GOBJ(o))) +#define RVAL2ATKRELATION(o) (ATK_RELATION(RVAL2GOBJ(o))) +#define RVAL2ATKRELATIONSET(o) (ATK_RELATION_SET(RVAL2GOBJ(o))) +#define RVAL2ATKSELECTION(o) (ATK_SELECTION(RVAL2GOBJ(o))) +#define RVAL2ATKSTATE(o) (ATK_STATE(RVAL2GOBJ(o))) +#define RVAL2ATKSTATESET(o) (ATK_STATE_SET(RVAL2GOBJ(o))) +#define RVAL2ATKSTREAMABLECONTENT(o) (ATK_STREAMABLE_CONTENT(RVAL2GOBJ(o))) +#define RVAL2ATKTABLE(o) (ATK_TABLE(RVAL2GOBJ(o))) +#define RVAL2ATKTEXT(o) (ATK_TEXT(RVAL2GOBJ(o))) +#define RVAL2ATKVALUE(o) (ATK_VALUE(RVAL2GOBJ(o))) + +#define RVAL2ATKTEXTRANGE(o) ((AtkTextRange*)RVAL2BOXED(o, ATK_TYPE_TEXT_RANGE)) +#define ATKTEXTRANGE2RVAL(o) (BOXED2RVAL(o, ATK_TYPE_TEXT_RANGE)) +#define RVAL2ATKTEXTRECTANGLE(o) ((AtkTextRectangle*)RVAL2BOXED(o, ATK_TYPE_TEXT_RECTANGLE)) +#define ATKTEXTRECTANGLE2RVAL(o) (BOXED2RVAL(o, ATK_TYPE_TEXT_RECTANGLE)) + +#define RVAL2ATKCOORDTYPE(o) (RVAL2GENUM(o, ATK_TYPE_COORD_TYPE)) +#define ATKCOORDTYPE2RVAL(o) (GENUM2RVAL(o, ATK_TYPE_COORD_TYPE)) +#define RVAL2ATKLAYER(o) (RVAL2GENUM(o, ATK_TYPE_LAYER)) +#define ATKLAYER2RVAL(o) (GENUM2RVAL(o, ATK_TYPE_LAYER)) +#define RVAL2ATKRELATIONTYPE(o) (RVAL2GENUM(o, ATK_TYPE_RELATION_TYPE)) +#define ATKRELATIONTYPE2RVAL(o) (GENUM2RVAL(o, ATK_TYPE_RELATION_TYPE)) +#define RVAL2ATKROLE(o) (RVAL2GENUM(o, ATK_TYPE_ROLE)) +#define ATKROLE2RVAL(o) (GENUM2RVAL(o, ATK_TYPE_ROLE)) +#define RVAL2ATKSTATETYPE(o) (RVAL2GENUM(o, ATK_TYPE_STATE_TYPE)) +#define ATKSTATETYPE2RVAL(o) (GENUM2RVAL(o, ATK_TYPE_STATE_TYPE)) +#define RVAL2ATKTEXTATTRIBUTE(o) (RVAL2GENUM(o, ATK_TYPE_TEXT_ATTRIBUTE)) +#define ATKTEXTATTRIBUTE2RVAL(o) (GENUM2RVAL(o, ATK_TYPE_TEXT_ATTRIBUTE)) +#define RVAL2ATKTEXTBOUNDARY(o) (RVAL2GENUM(o, ATK_TYPE_TEXT_BOUNDARY)) +#define ATKTEXTBOUNDARY2RVAL(o) (GENUM2RVAL(o, ATK_TYPE_TEXT_BOUNDARY)) +#define RVAL2ATKTEXTCLIPTYPE(o) (RVAL2GENUM(o, ATK_TYPE_TEXT_CLIP_TYPE)) +#define ATKTEXTCLIPTYPE2RVAL(o) (GENUM2RVAL(o, ATK_TYPE_TEXT_CLIP_TYPE)) + +#endif /* __RBATKCONVERSIONS_H__ */ diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkdocument.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkdocument.c new file mode 100644 index 0000000..b8b31b9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkdocument.c @@ -0,0 +1,100 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE mDocument +#define _SELF(s) (RVAL2ATKDOCUMENT(s)) + +static VALUE +rg_document_type(VALUE self) +{ + return CSTR2RVAL(atk_document_get_document_type(_SELF(self))); +} + +/* +How can I implement this? +static VALUE +rg_document(VALUE self) +{ + return GOBJ2RVAL(atk_document_get_document(_SELF(self))); +} +*/ + +#if ATK_CHECK_VERSION(1,12,0) +static VALUE +rg_get_attribute_value(VALUE self, VALUE name) +{ + return CSTR2RVAL(atk_document_get_attribute_value(_SELF(self), + RVAL2CSTR(name))); +} + +static VALUE +rg_set_attribute_value(VALUE self, VALUE name, VALUE value) +{ + gboolean ret = atk_document_set_attribute_value(_SELF(self), + RVAL2CSTR(name), + RVAL2CSTR(value)); + + if (! ret) rb_raise(rb_eRuntimeError, "Can't set attribute value: %s, %s", + RVAL2CSTR(name), RVAL2CSTR(value)); + + return self; +} + +static VALUE +rg_attributes(VALUE self) +{ + AtkAttributeSet* list = atk_document_get_attributes(_SELF(self)); + VALUE ary = rb_ary_new(); + while (list) { + AtkAttribute* attr = list->data; + rb_ary_push(ary, rb_assoc_new(CSTR2RVAL(attr->name), CSTR2RVAL(attr->value))); + list = list->next; + } + return ary; +} + +static VALUE +rg_locale(VALUE self) +{ + return CSTR2RVAL(atk_document_get_locale(_SELF(self))); +} +#endif + +void +Init_atk_document(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(ATK_TYPE_DOCUMENT, "Document", mAtk); + + RG_DEF_METHOD(document_type, 0); +/* + RG_DEF_METHOD(document, 0); +*/ +#if ATK_CHECK_VERSION(1,12,0) + RG_DEF_METHOD(get_attribute_value, 1); + RG_DEF_ALIAS("[]", "get_attribute_value"); + RG_DEF_METHOD(set_attribute_value, 2); + RG_DEF_ALIAS("[]=", "set_attribute_value"); + RG_DEF_METHOD(attributes, 0); + RG_DEF_METHOD(locale, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkeditabletext.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkeditabletext.c new file mode 100644 index 0000000..9d50812 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkeditabletext.c @@ -0,0 +1,177 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE mEditableText +#define _SELF(s) (RVAL2ATKEDITABLETEXT(s)) + +struct rval2atkattributegslist_args { + VALUE ary; + long n; + GSList *result; +}; + +static VALUE +rbatk_rval2atkattributegslist_body(VALUE value) +{ + long i; + struct rval2atkattributegslist_args *args = (struct rval2atkattributegslist_args *)value; + + for (i = 0; i < args->n; i++) { + VALUE ary = rb_ary_to_ary(RARRAY_PTR(args->ary)[i]); + AtkAttribute *attribute; + + if (RARRAY_LEN(ary) != 2) + rb_raise(rb_eArgError, "attribute %ld should be an array of length 2", i); + + attribute = g_new(AtkAttribute, 1); + args->result = g_slist_append(args->result, attribute); + attribute->name = g_strdup(RVAL2CSTR(RARRAY_PTR(ary)[0])); + attribute->value = g_strdup(RVAL2CSTR(RARRAY_PTR(ary)[1])); + } + + return Qnil; +} + +static void +rbatk_atkattributegslist_free(GSList *list) +{ + GSList *p; + + for (p = list; p != NULL; p = g_slist_next(p)) { + AtkAttribute *attribute = (AtkAttribute *)p->data; + + g_free(attribute->value); + g_free(attribute->name); + g_free(attribute); + } + + g_slist_free(list); +} + +static G_GNUC_NORETURN VALUE +rbatk_rval2atkattributegslist_rescue(VALUE value) +{ + rbatk_atkattributegslist_free(((struct rval2atkattributegslist_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static GSList * +rbatk_rval2atkattributegslist(VALUE value) +{ + struct rval2atkattributegslist_args args; + + args.ary = rb_ary_to_ary(value); + args.n = RARRAY_LEN(args.ary); + args.result = NULL; + + rb_rescue(rbatk_rval2atkattributegslist_body, (VALUE)&args, + rbatk_rval2atkattributegslist_rescue, (VALUE)&args); + + return args.result; +} + +#define RVAL2ATKATTRIBUTEGSLIST(value) rbatk_rval2atkattributegslist(value) + +static VALUE +rg_set_run_attributes(VALUE self, + VALUE attributes, + VALUE rbstart_offset, + VALUE rbend_offset) +{ + AtkEditableText *editable; + gint start_offset, end_offset; + AtkAttributeSet *list; + gboolean result; + + if (NIL_P(attributes)) + return Qfalse; + + editable = _SELF(self); + start_offset = NUM2INT(rbstart_offset); + end_offset = NUM2INT(rbend_offset); + list = RVAL2ATKATTRIBUTEGSLIST(attributes); + result = atk_editable_text_set_run_attributes(editable, list, start_offset, end_offset); + rbatk_atkattributegslist_free(list); + + return CBOOL2RVAL(result); +} + +static VALUE +rg_set_text_contents(VALUE self, VALUE str) +{ + atk_editable_text_set_text_contents(_SELF(self), RVAL2CSTR(str)); + return self; +} + +static VALUE +rg_insert_text(VALUE self, VALUE str, VALUE position) +{ + gint pos = NUM2INT(position); + + StringValue(str); + atk_editable_text_insert_text(_SELF(self), RVAL2CSTR(str), RSTRING_LEN(str), &pos); + return INT2NUM(pos); +} + +static VALUE +rg_copy_text(VALUE self, VALUE start_pos, VALUE end_pos) +{ + atk_editable_text_copy_text(_SELF(self), NUM2INT(start_pos), NUM2INT(end_pos)); + return self; +} + +static VALUE +rg_cut_text(VALUE self, VALUE start_pos, VALUE end_pos) +{ + atk_editable_text_cut_text(_SELF(self), NUM2INT(start_pos), NUM2INT(end_pos)); + return self; +} + +static VALUE +rg_delete_text(VALUE self, VALUE start_pos, VALUE end_pos) +{ + atk_editable_text_delete_text(_SELF(self), NUM2INT(start_pos), NUM2INT(end_pos)); + return self; +} + +static VALUE +rg_paste_text(VALUE self, VALUE position) +{ + atk_editable_text_paste_text(_SELF(self), NUM2INT(position)); + return self; +} + +void +Init_atk_editabletext(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(ATK_TYPE_EDITABLE_TEXT, "EditableText", mAtk); + + RG_DEF_METHOD(set_run_attributes, 3); + RG_DEF_METHOD(set_text_contents, 1); + RG_DEF_METHOD(insert_text, 2); + RG_DEF_METHOD(copy_text, 2); + RG_DEF_METHOD(cut_text, 2); + RG_DEF_METHOD(delete_text, 2); + RG_DEF_METHOD(paste_text, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkgobjectaccessible.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkgobjectaccessible.c new file mode 100644 index 0000000..48874b6 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkgobjectaccessible.c @@ -0,0 +1,46 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE cGObjectAccessible +#define _SELF(s) (RVAL2ATKGOBJECTACCESSIBLE(s)) + +static VALUE +rg_s_for_object(G_GNUC_UNUSED VALUE self, VALUE obj) +{ + return GOBJ2RVAL(atk_gobject_accessible_for_object(RVAL2GOBJ(obj))); +} + +static VALUE +rg_object(VALUE self) +{ + return GOBJ2RVAL(atk_gobject_accessible_get_object(_SELF(self))); +} + +void +Init_atk_gobjectaccessible(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_GOBJECT_ACCESSIBLE, "GObjectAccessible", mAtk); + + RG_DEF_SMETHOD(for_object, 1); + RG_DEF_METHOD(object, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkhyperlink.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkhyperlink.c new file mode 100644 index 0000000..c1bd855 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkhyperlink.c @@ -0,0 +1,71 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003,2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE cHyperlink +#define _SELF(s) (RVAL2ATKHYPERLINK(s)) + +static VALUE +rg_get_uri(VALUE self, VALUE i) +{ + return CSTR2RVAL(atk_hyperlink_get_uri(_SELF(self), NUM2INT(i))); +} + +static VALUE +rg_get_object(VALUE self, VALUE i) +{ + return GOBJ2RVAL(atk_hyperlink_get_object(_SELF(self), NUM2INT(i))); +} + +static VALUE +rg_valid_p(VALUE self) +{ + return CBOOL2RVAL(atk_hyperlink_is_valid(_SELF(self))); +} + +#ifdef HAVE_ATK_HYPERLINK_IS_INLINE +static VALUE +rg_inline_p(VALUE self) +{ + return CBOOL2RVAL(atk_hyperlink_is_inline(_SELF(self))); +} +#endif + +static VALUE +rg_n_anchors(VALUE self) +{ + return INT2NUM(atk_hyperlink_get_n_anchors(_SELF(self))); +} + +void +Init_atk_hyperlink(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_HYPERLINK, "Hyperlink", mAtk); + + RG_DEF_METHOD(get_uri, 1); + RG_DEF_METHOD(get_object, 1); + RG_DEF_METHOD_P(valid, 0); +#ifdef HAVE_ATK_HYPERLINK_IS_INLINE + RG_DEF_METHOD_P(inline, 0); +#endif + RG_DEF_METHOD(n_anchors, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkhypertext.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkhypertext.c new file mode 100644 index 0000000..75c68b1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkhypertext.c @@ -0,0 +1,53 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE mHypertext +#define _SELF(s) (RVAL2ATKHYPERTEXT(s)) + +static VALUE +rg_get_link(VALUE self, VALUE link_index) +{ + return GOBJ2RVAL(atk_hypertext_get_link(_SELF(self), NUM2INT(link_index))); +} + +static VALUE +rg_n_links(VALUE self) +{ + return INT2NUM(atk_hypertext_get_n_links(_SELF(self))); +} + +static VALUE +rg_link_index(VALUE self, VALUE char_index) +{ + return INT2NUM(atk_hypertext_get_link_index(_SELF(self), NUM2INT(char_index))); +} + +void +Init_atk_hypertext(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(ATK_TYPE_HYPERTEXT, "Hypertext", mAtk); + + RG_DEF_METHOD(get_link, 1); + RG_DEF_METHOD(n_links, 0); + RG_DEF_METHOD(link_index, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkimage.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkimage.c new file mode 100644 index 0000000..505f50b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkimage.c @@ -0,0 +1,68 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE mImage +#define _SELF(s) (RVAL2ATKIMAGE(s)) + +static VALUE +rg_image_position(VALUE self, VALUE coord_type) +{ + gint x, y; + atk_image_get_image_position(_SELF(self), &x, &y, + RVAL2ATKCOORDTYPE(coord_type)); + return rb_assoc_new(INT2NUM(x), INT2NUM(y)); +} + +static VALUE +rg_image_description(VALUE self) +{ + return CSTR2RVAL(atk_image_get_image_description(_SELF(self))); +} + +static VALUE +rg_set_image_description(VALUE self, VALUE description) +{ + gboolean ret = atk_image_set_image_description(_SELF(self), + RVAL2CSTR(description)); + if (! ret) rb_raise(rb_eRuntimeError, "Can't set image description"); + return self; +} + +static VALUE +rg_image_size(VALUE self) +{ + gint width, height; + atk_image_get_image_size(_SELF(self), &width, &height); + return rb_assoc_new(INT2NUM(width), INT2NUM(height)); +} + +void +Init_atk_image(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(ATK_TYPE_IMAGE, "Image", mAtk); + + RG_DEF_METHOD(image_position, 1); + RG_DEF_METHOD(image_description, 0); + RG_DEF_METHOD(set_image_description, 1); + RG_DEF_METHOD(image_size, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkimplementor.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkimplementor.c new file mode 100644 index 0000000..ae7bd20 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkimplementor.c @@ -0,0 +1,38 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE mImplementor +#define _SELF(s) (RVAL2ATKIMPLEMENTOR(s)) + +static VALUE +rg_ref_accessible(VALUE self) +{ + return GOBJ2RVAL(atk_implementor_ref_accessible(_SELF(self))); +} + +void +Init_atk_implementor(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(ATK_TYPE_IMPLEMENTOR, "Implementor", mAtk); + RG_DEF_METHOD(ref_accessible, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatknoopobject.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatknoopobject.c new file mode 100644 index 0000000..9c78c26 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatknoopobject.c @@ -0,0 +1,40 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE cNoOpObject +#define _SELF(s) (RVAL2ATKNOOPOBJECT(s)) + +static VALUE +rg_initialize(VALUE self, VALUE gobj) +{ + G_INITIALIZE(self, atk_no_op_object_new(RVAL2GOBJ(gobj))); + return Qnil; +} + +void +Init_atk_noopobject(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_NO_OP_OBJECT, "NoOpObject", mAtk); + + RG_DEF_METHOD(initialize, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatknoopobjectfactory.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatknoopobjectfactory.c new file mode 100644 index 0000000..3020b20 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatknoopobjectfactory.c @@ -0,0 +1,40 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE cNoOpObjectFactory +#define _SELF(s) (RVAL2ATKNOOPOBJECTFACTORY(s)) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, atk_no_op_object_factory_new()); + return Qnil; +} + +void +Init_atk_noopobjectfactory(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_NO_OP_OBJECT_FACTORY, "NoOpObjectFactory", mAtk); + + RG_DEF_METHOD(initialize, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkobject.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkobject.c new file mode 100644 index 0000000..c8cd475 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkobject.c @@ -0,0 +1,153 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003,2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE cObject +#define _SELF(s) RVAL2ATKOBJECT(s) + +/* How can I implement this? Since 1.10 +AtkObject* atk_implementor_ref_accessible (AtkImplementor *implementor); +*/ + +/* Use properties accessible_* +G_CONST_RETURN gchar* atk_object_get_name (AtkObject *accessible); +G_CONST_RETURN gchar* atk_object_get_description + (AtkObject *accessible); +AtkObject* atk_object_get_parent (AtkObject *accessible); + (AtkObject *accessible); +*/ + +static VALUE +rg_n_accessible_children(VALUE self) +{ + return INT2NUM(atk_object_get_n_accessible_children(_SELF(self))); +} + +static VALUE +rg_ref_accessible_child(VALUE self, VALUE i) +{ + return GOBJ2RVAL(atk_object_ref_accessible_child(_SELF(self), NUM2INT(i))); +} + +static VALUE +rg_ref_relation_set(VALUE self) +{ + return GOBJ2RVAL(atk_object_ref_relation_set(_SELF(self))); +} + +/* Use properties accessible_* +AtkLayer atk_object_get_layer (AtkObject *accessible); +gint atk_object_get_mdi_zorder (AtkObject *accessible); +AtkRole atk_object_get_role (AtkObject *accessible); +*/ + +static VALUE +rg_ref_state_set(VALUE self) +{ + return GOBJ2RVAL(atk_object_ref_state_set(_SELF(self))); +} + +static VALUE +rg_index_in_parent(VALUE self) +{ + return INT2NUM(atk_object_get_index_in_parent(_SELF(self))); +} +/* Use properties accessible_* +void atk_object_set_name (AtkObject *accessible, + const gchar *name); +void atk_object_set_description (AtkObject *accessible, + const gchar *description); +void atk_object_set_parent (AtkObject *accessible, + AtkObject *parent); +void atk_object_set_role (AtkObject *accessible, + AtkRole role); +*/ + +/* +guint atk_object_connect_property_change_handler + (AtkObject *accessible, + AtkPropertyChangeHandler *handler); +void atk_object_remove_property_change_handler + (AtkObject *accessible, + guint handler_id); +*/ + +static VALUE +rg_notify_state_change(VALUE self, VALUE state, VALUE value) +{ + atk_object_notify_state_change(_SELF(self), + RVAL2ATKSTATETYPE(state), + RVAL2CBOOL(value)); + return self; +} + +/* I don't have a good idea to implement this method. Any idea? +void atk_object_initialize (AtkObject *accessible, + gpointer data); +*/ + +#ifdef HAVE_ATK_OBJECT_ADD_RELATIONSHIP +static VALUE +rg_add_relationship(VALUE self, VALUE relationship, VALUE target) +{ + return CBOOL2RVAL(atk_object_add_relationship( + _SELF(self), + RVAL2ATKRELATIONTYPE(relationship), + _SELF(target))); +} +#endif + +#ifdef HAVE_ATK_OBJECT_REMOVE_RELATIONSHIP +static VALUE +rg_remove_relationship(VALUE self, VALUE relationship, VALUE target) +{ + return CBOOL2RVAL(atk_object_remove_relationship( + _SELF(self), + RVAL2ATKRELATIONTYPE(relationship), + _SELF(target))); +} +#endif + +void +Init_atk_object(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_OBJECT, "Object", mAtk); + + RG_DEF_METHOD(n_accessible_children, 0); + RG_DEF_METHOD(ref_accessible_child, 1); + RG_DEF_METHOD(ref_relation_set, 0); + RG_DEF_METHOD(ref_state_set, 0); + RG_DEF_METHOD(index_in_parent, 0); + RG_DEF_METHOD(notify_state_change, 2); +#ifdef HAVE_ATK_OBJECT_ADD_RELATIONSHIP + RG_DEF_METHOD(add_relationship, 2); +#endif +#ifdef HAVE_ATK_OBJECT_REMOVE_RELATIONSHIP + RG_DEF_METHOD(remove_relationship, 2); +#endif + + Init_atk_object_role(RG_TARGET_NAMESPACE); + + /* AtkLayer */ + G_DEF_CLASS(ATK_TYPE_LAYER, "Layer", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, ATK_TYPE_LAYER, "ATK_"); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkobjectfactory.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkobjectfactory.c new file mode 100644 index 0000000..c0828dd --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkobjectfactory.c @@ -0,0 +1,53 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE cObjectFactory +#define _SELF(s) (RVAL2ATKOBJECTFACTORY(s)) + +static VALUE +rg_create_accessible(VALUE self, VALUE obj) +{ + return GOBJ2RVAL(atk_object_factory_create_accessible(_SELF(self), RVAL2GOBJ(obj))); +} + +static VALUE +rg_accessible_type(VALUE self) +{ + return GTYPE2CLASS(atk_object_factory_get_accessible_type(_SELF(self))); +} + +static VALUE +rg_invalidate(VALUE self) +{ + atk_object_factory_invalidate(_SELF(self)); + return self; +} + +void +Init_atk_objectfactory(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_OBJECT_FACTORY, "ObjectFactory", mAtk); + RG_DEF_METHOD(create_accessible, 0); + RG_DEF_METHOD(accessible_type, 0); + RG_DEF_METHOD(invalidate, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkobjectrole.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkobjectrole.c new file mode 100644 index 0000000..aa2f5fb --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkobjectrole.c @@ -0,0 +1,50 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003,2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE cRole + +static VALUE +rg_localized_name(G_GNUC_UNUSED VALUE self) +{ +#ifdef HAVE_ATK_ROLE_GET_LOCALIZED_NAME + return CSTR2RVAL(atk_role_get_localized_name(RVAL2ATKROLE(self))); +#else + rb_warning("not supported in this version of ATK."); + return Qnil; +#endif +} + +static VALUE +rg_s_for_name(G_GNUC_UNUSED VALUE self, VALUE name) +{ + return ATKROLE2RVAL(atk_role_for_name(RVAL2CSTR(name))); +} + +void +Init_atk_object_role(VALUE cObject) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_ROLE, "Role", cObject); + RG_DEF_METHOD(localized_name, 0); + RG_DEF_SMETHOD(for_name, 1); + G_DEF_CONSTANTS(cObject, ATK_TYPE_ROLE, "ATK_"); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkprivate.h b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkprivate.h new file mode 100644 index 0000000..33a6afe --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkprivate.h @@ -0,0 +1,48 @@ +#ifndef RB_ATK_PRIVATE_H +#define RB_ATK_PRIVATE_H + +#include "rbatk.h" + +#ifndef HAVE_RB_ERRINFO +# define rb_errinfo() (ruby_errinfo) +#endif + +#ifndef G_VALUE_INIT +# define G_VALUE_INIT { 0, { { 0 } } } +#endif + +G_BEGIN_DECLS + +G_GNUC_INTERNAL void Init_atk_action(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_component(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_document(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_editabletext(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_gobjectaccessible(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_hyperlink(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_hypertext(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_image(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_implementor(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_noopobject(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_noopobjectfactory(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_object(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_object_role(VALUE cObject); +G_GNUC_INTERNAL void Init_atk_objectfactory(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_registry(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_relation(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_relation_type(VALUE cRelation); +G_GNUC_INTERNAL void Init_atk_relation_set(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_selection(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_state(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_state_set(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_streamable_content(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_table(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_text(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_text_attribute(VALUE mText); +G_GNUC_INTERNAL void Init_atk_text_range(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_text_rectangle(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_util(VALUE mAtk); +G_GNUC_INTERNAL void Init_atk_value(VALUE mAtk); + +G_END_DECLS + +#endif /* RB_ATK_PRIVATE_H */ diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkregistry.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkregistry.c new file mode 100644 index 0000000..2e03235 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkregistry.c @@ -0,0 +1,63 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE cRegistry +#define _SELF(s) (RVAL2ATKREGISTRY(s)) + +static VALUE +rg_set_factory_type(VALUE self, VALUE type, VALUE factory_type) +{ + atk_registry_set_factory_type(_SELF(self), + CLASS2GTYPE(type), + CLASS2GTYPE(factory_type)); + return self; +} + +static VALUE +rg_get_factory_type(VALUE self, VALUE type) +{ + return GTYPE2CLASS(atk_registry_get_factory_type(_SELF(self), CLASS2GTYPE(type))); +} + +static VALUE +rg_get_factory(VALUE self, VALUE type) +{ + return GOBJ2RVAL(atk_registry_get_factory(_SELF(self), + CLASS2GTYPE(type))); +} + +static VALUE +rg_s_default_registry(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(atk_get_default_registry()); +} + +void +Init_atk_registry(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_REGISTRY, "Registry", mAtk); + RG_DEF_METHOD(set_factory_type, 2); + RG_DEF_METHOD(get_factory_type, 1); + RG_DEF_METHOD(get_factory, 1); + RG_DEF_SMETHOD(default_registry, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkrelation.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkrelation.c new file mode 100644 index 0000000..51e1974 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkrelation.c @@ -0,0 +1,102 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE cRelation +#define _SELF(s) (RVAL2ATKRELATION(s)) + +static VALUE +rg_s_type_register(G_GNUC_UNUSED VALUE self, VALUE name) +{ + return ATKRELATIONTYPE2RVAL(atk_relation_type_register(RVAL2CSTR(name))); +} + +struct rval2atkobjects_args { + VALUE ary; + long n; + AtkObject **result; +}; + +static VALUE +rval2atkobjects_body(VALUE value) +{ + long i; + struct rval2atkobjects_args *args = (struct rval2atkobjects_args *)value; + + for (i = 0; i < args->n; i++) + args->result[i] = RVAL2ATKOBJECT(RARRAY_PTR(args->ary)[i]); + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rval2atkobjects_rescue(VALUE value) +{ + g_free(((struct rval2atkobjects_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static VALUE +rg_initialize(VALUE self, VALUE targets, VALUE rbrelationship) +{ + AtkRelationType relationship = RVAL2ATKRELATIONTYPE(rbrelationship); + struct rval2atkobjects_args args; + AtkRelation *relation; + + args.ary = rb_ary_to_ary(targets); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(AtkObject *, args.n + 1); + + rb_rescue(rval2atkobjects_body, (VALUE)&args, + rval2atkobjects_rescue, (VALUE)&args); + + relation = atk_relation_new(args.result, args.n, relationship); + + g_free(args.result); + + G_INITIALIZE(self, relation); + + return Qnil; +} + +#if ATK_CHECK_VERSION(1,9,0) +static VALUE +rg_add_target(VALUE self, VALUE obj) +{ + atk_relation_add_target(_SELF(self), RVAL2ATKOBJECT(obj)); + return self; +} +#endif + +void +Init_atk_relation(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_RELATION, "Relation", mAtk); + RG_DEF_SMETHOD(type_register, 1); + RG_DEF_METHOD(initialize, 2); +#if ATK_CHECK_VERSION(1,9,0) + RG_DEF_METHOD(add_target, 1); +#endif + + Init_atk_relation_type(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkrelationset.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkrelationset.c new file mode 100644 index 0000000..55da840 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkrelationset.c @@ -0,0 +1,99 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE cRelationSet +#define _SELF(s) (RVAL2ATKRELATIONSET(s)) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, atk_relation_set_new()); + return Qnil; +} + +static VALUE +rg_contains_p(VALUE self, VALUE relationship) +{ + return CBOOL2RVAL(atk_relation_set_contains( + _SELF(self), + RVAL2ATKRELATIONTYPE(relationship))); +} + +static VALUE +rg_remove(VALUE self, VALUE relation) +{ + atk_relation_set_remove(_SELF(self), RVAL2ATKRELATION(relation)); + return self; +} + +static VALUE +rg_add(VALUE self, VALUE relation) +{ + atk_relation_set_add(_SELF(self), RVAL2ATKRELATION(relation)); + return self; +} + +static VALUE +rg_n_relations(VALUE self) +{ + return INT2NUM(atk_relation_set_get_n_relations(_SELF(self))); +} + +static VALUE +rg_get_relation(VALUE self, VALUE i) +{ + if (rb_obj_is_kind_of(i, GTYPE2CLASS(ATK_TYPE_RELATION_TYPE))){ + return GOBJ2RVAL(atk_relation_set_get_relation_by_type( + _SELF(self), + RVAL2ATKRELATIONTYPE(i))); + } else { + return GOBJ2RVAL(atk_relation_set_get_relation(_SELF(self), NUM2INT(i))); + } +} + +#if ATK_CHECK_VERSION(1,9,0) +static VALUE +rg_add_relation(VALUE self, VALUE relationship, VALUE obj) +{ + atk_relation_set_add_relation_by_type(_SELF(self), + RVAL2ATKRELATIONTYPE(relationship), + RVAL2ATKOBJECT(obj)); + return self; +} +#endif + +void +Init_atk_relation_set(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_RELATION_SET, "RelationSet", mAtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD_P(contains, 1); + RG_DEF_METHOD(remove, 1); + RG_DEF_METHOD(add, 1); + RG_DEF_METHOD(n_relations, 0); + RG_DEF_METHOD(get_relation, 1); +#if ATK_CHECK_VERSION(1,9,0) + RG_DEF_METHOD(add_relation, 2); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkrelationtype.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkrelationtype.c new file mode 100644 index 0000000..c5b9311 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkrelationtype.c @@ -0,0 +1,38 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE cType + +static VALUE +rg_s_for_name(G_GNUC_UNUSED VALUE self, VALUE name) +{ + return ATKRELATIONTYPE2RVAL(atk_relation_type_for_name(RVAL2CSTR(name))); +} + +void +Init_atk_relation_type(VALUE cRelation) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_RELATION_TYPE, "Type", cRelation); + RG_DEF_SMETHOD(for_name, 1); + G_DEF_CONSTANTS(cRelation, ATK_TYPE_RELATION_TYPE, "ATK_"); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkselection.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkselection.c new file mode 100644 index 0000000..e7923ae --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkselection.c @@ -0,0 +1,87 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE mSelection +#define _SELF(s) (RVAL2ATKSELECTION(s)) + +static VALUE +rg_add_selection(VALUE self, VALUE i) +{ + gboolean ret = atk_selection_add_selection(_SELF(self), NUM2INT(i)); + if (! ret) rb_raise(rb_eRuntimeError, "Can't add selection"); + return self; +} + +static VALUE +rg_clear_selection(VALUE self) +{ + gboolean ret = atk_selection_clear_selection(_SELF(self)); + if (! ret) rb_raise(rb_eRuntimeError, "Can't clear selection"); + return self; +} + +static VALUE +rg_ref_selection(VALUE self, VALUE i) +{ + return GOBJ2RVAL(atk_selection_ref_selection(_SELF(self), NUM2INT(i))); +} + +static VALUE +rg_selection_count(VALUE self) +{ + return INT2NUM(atk_selection_get_selection_count(_SELF(self))); +} + +static VALUE +rg_child_selected_p(VALUE self, VALUE i) +{ + return CBOOL2RVAL(atk_selection_is_child_selected(_SELF(self), NUM2INT(i))); +} + +static VALUE +rg_remove_selection(VALUE self, VALUE i) +{ + gboolean ret = atk_selection_remove_selection(_SELF(self), NUM2INT(i)); + if (! ret) rb_raise(rb_eRuntimeError, "Can't remove selection"); + return self; +} + +static VALUE +rg_select_all_selection(VALUE self) +{ + return CBOOL2RVAL(atk_selection_select_all_selection(_SELF(self))); +} + +void +Init_atk_selection(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(ATK_TYPE_SELECTION, "Selection", mAtk); + + RG_DEF_METHOD(add_selection, 1); + RG_DEF_METHOD(clear_selection, 0); + RG_DEF_METHOD(ref_selection, 1); + RG_DEF_METHOD(selection_count, 0); + RG_DEF_METHOD_P(child_selected, 1); + RG_DEF_METHOD(remove_selection, 1); + RG_DEF_METHOD(select_all_selection, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkstate.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkstate.c new file mode 100644 index 0000000..34e48e6 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkstate.c @@ -0,0 +1,51 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003,2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE cState +#define _SELF(s) (RVAL2ATKSTATE(s)) + +static VALUE +rg_s_type_register(G_GNUC_UNUSED VALUE self, VALUE name) +{ + return ATKSTATETYPE2RVAL(atk_state_type_register(RVAL2CSTR(name))); +} + +/* We don't need this. +G_CONST_RETURN gchar* atk_state_type_get_name + (AtkStateType type); +*/ + +static VALUE +rg_s_for_name(G_GNUC_UNUSED VALUE self, VALUE name) +{ + return ATKSTATETYPE2RVAL(atk_state_type_for_name(RVAL2CSTR(name))); +} + +void +Init_atk_state(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_STATE_TYPE, "State", mAtk); + RG_DEF_SMETHOD(type_register, 1); + RG_DEF_SMETHOD(for_name, 1); + G_DEF_CONSTANTS(mAtk, ATK_TYPE_STATE_TYPE, "ATK_"); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkstateset.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkstateset.c new file mode 100644 index 0000000..7c1289d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkstateset.c @@ -0,0 +1,180 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE cStateSet +#define _SELF(s) (RVAL2ATKSTATESET(s)) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, atk_state_set_new()); + return Qnil; +} + +static VALUE +rg_empty_p(VALUE self) +{ + return CBOOL2RVAL(atk_state_set_is_empty(_SELF(self))); +} + +static VALUE +rg_add_state(VALUE self, VALUE type) +{ + return CBOOL2RVAL(atk_state_set_add_state(_SELF(self), + RVAL2ATKSTATETYPE(type))); +} + +struct rval2atkstatetype_args { + VALUE ary; + long n; + AtkStateType *result; +}; + +static VALUE +rval2atkstatetype_body(VALUE value) +{ + long i; + struct rval2atkstatetype_args *args = (struct rval2atkstatetype_args *)value; + + for (i = 0; i < args->n; i++) + args->result[i] = RVAL2ATKSTATETYPE(RARRAY_PTR(args->ary)[i]); + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rval2atkstatetype_rescue(VALUE value) +{ + g_free(((struct rval2atkstatetype_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static AtkStateType * +rval2atkstatetype(VALUE value, long *n) +{ + struct rval2atkstatetype_args args; + + args.ary = rb_ary_to_ary(value); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(AtkStateType, args.n + 1); + + rb_rescue(rval2atkstatetype_body, (VALUE)&args, + rval2atkstatetype_rescue, (VALUE)&args); + + if (n != NULL) + *n = args.n; + + return args.result; +} + +#define RVAL2ATKSTATETYPES(value, n) rval2atkstatetype(value, n) + +static VALUE +rg_add_states(VALUE self, VALUE rbtypes) +{ + AtkStateSet *set = _SELF(self); + long n; + AtkStateType *types = RVAL2ATKSTATETYPES(rbtypes, &n); + + atk_state_set_add_states(set, types, n); + + g_free(types); + + return self; +} + +static VALUE +rg_clear_states(VALUE self) +{ + atk_state_set_clear_states(_SELF(self)); + return self; +} + +static VALUE +rg_contains_state(VALUE self, VALUE type) +{ + return CBOOL2RVAL(atk_state_set_contains_state(_SELF(self), + RVAL2ATKSTATETYPE(type))); +} + +static VALUE +rg_contains_states(VALUE self, VALUE rbtypes) +{ + AtkStateSet *set = _SELF(self); + long n; + AtkStateType *types = RVAL2ATKSTATETYPES(rbtypes, &n); + gboolean result; + + result = atk_state_set_contains_states(set, types, n); + + g_free(types); + + return CBOOL2RVAL(result); +} + +static VALUE +rg_remove_state(VALUE self, VALUE type) +{ + return CBOOL2RVAL(atk_state_set_remove_state(_SELF(self), + RVAL2ATKSTATETYPE(type))); +} + +static VALUE +rg_and(VALUE self, VALUE compare_set) +{ + return GOBJ2RVAL(atk_state_set_and_sets(_SELF(self), _SELF(compare_set))); +} + +static VALUE +rg_or(VALUE self, VALUE compare_set) +{ + return GOBJ2RVAL(atk_state_set_or_sets(_SELF(self), _SELF(compare_set))); +} + +static VALUE +rg_xor(VALUE self, VALUE compare_set) +{ + return GOBJ2RVAL(atk_state_set_xor_sets(_SELF(self), _SELF(compare_set))); +} + +void +Init_atk_state_set(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_STATE_SET, "StateSet", mAtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD_P(empty, 0); + RG_DEF_METHOD(add_state, 1); + RG_DEF_METHOD(add_states, 1); + RG_DEF_METHOD(clear_states, 0); + RG_DEF_METHOD(contains_state, 1); + RG_DEF_METHOD(contains_states, 1); + RG_DEF_METHOD(remove_state, 1); + RG_DEF_METHOD(and, 1); + RG_DEF_ALIAS("&", "and"); + RG_DEF_METHOD(or, 1); + RG_DEF_ALIAS("|", "or"); + RG_DEF_METHOD(xor, 1); + RG_DEF_ALIAS("^", "xor"); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkstreamablecontent.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkstreamablecontent.c new file mode 100644 index 0000000..44878ad --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkstreamablecontent.c @@ -0,0 +1,57 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE mStreamableContent +#define _SELF(s) (RVAL2ATKSTREAMABLECONTENT(s)) + +static VALUE +rg_n_mime_types(VALUE self) +{ + return INT2NUM(atk_streamable_content_get_n_mime_types(_SELF(self))); +} + +static VALUE +rg_mime_type(VALUE self, VALUE i) +{ + return CSTR2RVAL(atk_streamable_content_get_mime_type(_SELF(self), NUM2INT(i))); +} + +static VALUE +rg_get_stream(VALUE self, VALUE mime_type) +{ + GIOChannel* io = atk_streamable_content_get_stream(_SELF(self), RVAL2CSTR(mime_type)); + if (!io) + rb_raise(rb_eRuntimeError, "Couldn't get the stream."); + + return GIOCHANNEL2RVAL(io); +} + +void +Init_atk_streamable_content(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(ATK_TYPE_STREAMABLE_CONTENT, "StreamableContent", mAtk); + + RG_DEF_METHOD(n_mime_types, 0); + RG_DEF_METHOD(mime_type, 1); + RG_DEF_METHOD(get_stream, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatktable.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatktable.c new file mode 100644 index 0000000..b7a6cf8 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatktable.c @@ -0,0 +1,271 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003,2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE mTable +#define _SELF(s) (RVAL2ATKTABLE(s)) + +static VALUE +rg_ref_at(VALUE self, VALUE row, VALUE column) +{ + return GOBJ2RVAL(atk_table_ref_at(_SELF(self), NUM2INT(row), NUM2INT(column))); +} + +static VALUE +rg_get_index_at(VALUE self, VALUE row, VALUE column) +{ + return INT2NUM(atk_table_get_index_at(_SELF(self), NUM2INT(row), NUM2INT(column))); +} + +static VALUE +rg_get_column_at_index(VALUE self, VALUE index_) +{ + return INT2NUM(atk_table_get_column_at_index(_SELF(self), NUM2INT(index_))); +} + +static VALUE +rg_get_row_at_index(VALUE self, VALUE index_) +{ + return INT2NUM(atk_table_get_row_at_index(_SELF(self), NUM2INT(index_))); +} + +static VALUE +rg_n_columns(VALUE self) +{ + return INT2NUM(atk_table_get_n_columns(_SELF(self))); +} + +static VALUE +rg_n_rows(VALUE self) +{ + return INT2NUM(atk_table_get_n_rows(_SELF(self))); +} + +static VALUE +rg_get_column_extent_at(VALUE self, VALUE row, VALUE column) +{ + return INT2NUM(atk_table_get_column_extent_at(_SELF(self), NUM2INT(row), NUM2INT(column))); +} + +static VALUE +rg_get_row_extent_at(VALUE self, VALUE row, VALUE column) +{ + return INT2NUM(atk_table_get_row_extent_at(_SELF(self), NUM2INT(row), NUM2INT(column))); +} + +static VALUE +rg_caption(VALUE self) +{ + return GOBJ2RVAL(atk_table_get_caption(_SELF(self))); +} + +static VALUE +rg_get_column_description(VALUE self, VALUE column) +{ + return CSTR2RVAL(atk_table_get_column_description(_SELF(self), NUM2INT(column))); +} + +static VALUE +rg_get_row_description(VALUE self, VALUE row) +{ + return CSTR2RVAL(atk_table_get_row_description(_SELF(self), NUM2INT(row))); +} + +static VALUE +rg_get_column_header(VALUE self, VALUE column) +{ + return GOBJ2RVAL(atk_table_get_column_header(_SELF(self), NUM2INT(column))); +} + +static VALUE +rg_get_row_header(VALUE self, VALUE row) +{ + return GOBJ2RVAL(atk_table_get_row_header(_SELF(self), NUM2INT(row))); +} + +static VALUE +rg_summary(VALUE self) +{ + return GOBJ2RVAL(atk_table_get_summary(_SELF(self))); +} + +static VALUE +rg_set_caption(VALUE self, VALUE caption) +{ + atk_table_set_caption(_SELF(self), RVAL2ATKOBJECT(caption)); + return self; +} + +static VALUE +rg_set_row_description(VALUE self, VALUE row, VALUE description) +{ + atk_table_set_row_description(_SELF(self), NUM2INT(row), RVAL2CSTR(description)); + return self; +} + +static VALUE +rg_set_column_description(VALUE self, VALUE column, VALUE description) +{ + atk_table_set_column_description(_SELF(self), NUM2INT(column), RVAL2CSTR(description)); + return self; +} + +static VALUE +rg_set_row_header(VALUE self, VALUE row, VALUE header) +{ + atk_table_set_row_header(_SELF(self), NUM2INT(row), RVAL2ATKOBJECT(header)); + return self; +} + +static VALUE +rg_set_column_header(VALUE self, VALUE column, VALUE header) +{ + atk_table_set_column_header(_SELF(self), NUM2INT(column), RVAL2ATKOBJECT(header)); + return self; +} + +static VALUE +rg_set_summary(VALUE self, VALUE accessible) +{ + atk_table_set_summary(_SELF(self), RVAL2ATKOBJECT(accessible)); + return self; +} + +static VALUE +rg_selected_columns(VALUE self) +{ + gint ret; + gint* selected; + VALUE result = Qnil; + ret = atk_table_get_selected_columns(_SELF(self), &selected); + if (ret > 0){ + gint i; + result = rb_ary_new2(ret); + for (i = 0; i < ret; i++){ + rb_ary_push(result, INT2NUM(selected[i])); + } + } + return result; +} + +static VALUE +rg_selected_rows(VALUE self) +{ + gint ret; + gint* selected; + VALUE result = Qnil; + ret = atk_table_get_selected_rows(_SELF(self), &selected); + if (ret > 0){ + gint i; + result = rb_ary_new2(ret); + for (i = 0; i < ret; i++){ + rb_ary_push(result, INT2NUM(selected[i])); + } + } + return result; +} + +static VALUE +rg_column_selected_p(VALUE self, VALUE column) +{ + return CBOOL2RVAL(atk_table_is_column_selected(_SELF(self), NUM2INT(column))); +} + +static VALUE +rg_row_selected_p(VALUE self, VALUE row) +{ + return CBOOL2RVAL(atk_table_is_row_selected(_SELF(self), NUM2INT(row))); +} + +static VALUE +rg_selected_p(VALUE self, VALUE row, VALUE column) +{ + return CBOOL2RVAL(atk_table_is_selected(_SELF(self), NUM2INT(row), NUM2INT(column))); +} + +static VALUE +rg_add_column_selection(VALUE self, VALUE column) +{ + gboolean ret = atk_table_add_column_selection(_SELF(self), NUM2INT(column)); + if (! ret) rb_raise(rb_eRuntimeError, "not implement this interface"); + return self; +} + +static VALUE +rg_add_row_selection(VALUE self, VALUE row) +{ + gboolean ret = atk_table_add_row_selection(_SELF(self), NUM2INT(row)); + if (! ret) rb_raise(rb_eRuntimeError, "not implement this interface"); + return self; +} + +static VALUE +rg_remove_column_selection(VALUE self, VALUE column) +{ + gboolean ret = atk_table_remove_column_selection(_SELF(self), NUM2INT(column)); + if (! ret) rb_raise(rb_eRuntimeError, "not implement this interface"); + return self; +} + +static VALUE +rg_remove_row_selection(VALUE self, VALUE row) +{ + gboolean ret = atk_table_remove_row_selection(_SELF(self), NUM2INT(row)); + if (! ret) rb_raise(rb_eRuntimeError, "not implement this interface"); + return self; +} + +void +Init_atk_table(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(ATK_TYPE_TABLE, "Table", mAtk); + + RG_DEF_METHOD(ref_at, 2); + RG_DEF_METHOD(get_index_at, 2); + RG_DEF_METHOD(get_column_at_index, 1); + RG_DEF_METHOD(get_row_at_index, 1); + RG_DEF_METHOD(n_columns, 0); + RG_DEF_METHOD(n_rows, 0); + RG_DEF_METHOD(get_column_extent_at, 2); + RG_DEF_METHOD(get_row_extent_at, 2); + RG_DEF_METHOD(caption, 0); + RG_DEF_METHOD(get_column_description, 1); + RG_DEF_METHOD(get_row_description, 1); + RG_DEF_METHOD(get_column_header, 1); + RG_DEF_METHOD(get_row_header, 1); + RG_DEF_METHOD(summary, 0); + RG_DEF_METHOD(set_caption, 1); + RG_DEF_METHOD(set_row_description, 2); + RG_DEF_METHOD(set_column_description, 2); + RG_DEF_METHOD(set_row_header, 2); + RG_DEF_METHOD(set_column_header, 2); + RG_DEF_METHOD(set_summary, 1); + RG_DEF_METHOD(selected_columns, 0); + RG_DEF_METHOD(selected_rows, 0); + RG_DEF_METHOD_P(column_selected, 1); + RG_DEF_METHOD_P(row_selected, 1); + RG_DEF_METHOD_P(selected, 2); + RG_DEF_METHOD(add_column_selection, 1); + RG_DEF_METHOD(add_row_selection, 1); + RG_DEF_METHOD(remove_column_selection, 1); + RG_DEF_METHOD(remove_row_selection, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatktext.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatktext.c new file mode 100644 index 0000000..7a570e3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatktext.c @@ -0,0 +1,318 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE mText +#define _SELF(s) (RVAL2ATKTEXT(s)) + +static VALUE +rg_get_text(VALUE self, VALUE start_offset, VALUE end_offset) +{ + VALUE ret; + gchar* text = atk_text_get_text(_SELF(self), + NUM2INT(start_offset), + NUM2INT(end_offset)); + ret = CSTR2RVAL(text); + g_free(text); + return ret; +} + +static VALUE +rg_get_character_at_offset(VALUE self, VALUE offset) +{ + gchar buf[10]; + gint len = g_unichar_to_utf8(atk_text_get_character_at_offset + (_SELF(self), NUM2INT(offset)), buf); + buf[len] = '\0'; + return rb_str_new2(buf); +} + +static VALUE +rg_get_text_after_offset(VALUE self, VALUE offset, VALUE boundary_type) +{ + gchar* ret; + VALUE result; + gint start_offset, end_offset; + + ret = atk_text_get_text_after_offset(_SELF(self), NUM2INT(offset), + RVAL2ATKTEXTBOUNDARY(boundary_type), + &start_offset, &end_offset); + result = rb_ary_new3(3, CSTR2RVAL(ret), + INT2NUM(start_offset), INT2NUM(end_offset)); + g_free(ret); + + return result; +} + +static VALUE +rg_get_text_at_offset(VALUE self, VALUE offset, VALUE boundary_type) +{ + gchar* ret; + VALUE result; + gint start_offset, end_offset; + + ret = atk_text_get_text_at_offset(_SELF(self), NUM2INT(offset), + RVAL2ATKTEXTBOUNDARY(boundary_type), + &start_offset, &end_offset); + result = rb_ary_new3(3, CSTR2RVAL(ret), + INT2NUM(start_offset), INT2NUM(end_offset)); + g_free(ret); + + return result; +} + +static VALUE +rg_get_text_before_offset(VALUE self, VALUE offset, VALUE boundary_type) +{ + gchar* ret; + VALUE result; + gint start_offset, end_offset; + + ret = atk_text_get_text_before_offset(_SELF(self), NUM2INT(offset), + RVAL2ATKTEXTBOUNDARY(boundary_type), + &start_offset, &end_offset); + result = rb_ary_new3(3, CSTR2RVAL(ret), + INT2NUM(start_offset), INT2NUM(end_offset)); + g_free(ret); + + return result; +} + +static VALUE +rg_caret_offset(VALUE self) +{ + return INT2NUM(atk_text_get_caret_offset(_SELF(self))); +} + +static VALUE +rg_get_character_extents(VALUE self, VALUE offset, VALUE coords) +{ + gint x, y, width, height; + atk_text_get_character_extents(_SELF(self), NUM2INT(offset), + &x, &y, &width, &height, + RVAL2ATKCOORDTYPE(coords)); + return rb_ary_new3(4, INT2NUM(x), INT2NUM(y), INT2NUM(width), INT2NUM(height)); +} + +static VALUE +rg_get_run_attributes(VALUE self, VALUE offset) +{ + gint start_offset, end_offset; + AtkAttributeSet* list; + VALUE ary; + + list = atk_text_get_run_attributes(_SELF(self), NUM2INT(offset), + &start_offset, &end_offset); + + ary = rb_ary_new(); + + while (list) { + AtkAttribute* data = (AtkAttribute*)list->data; + rb_ary_push(ary, rb_assoc_new(CSTR2RVAL(data->name), + CSTR2RVAL(data->value))); + list = list->next; + } + atk_attribute_set_free(list); + return ary; +} + +static VALUE +rg_default_attributes(VALUE self) +{ + AtkAttributeSet* list; + VALUE ary; + + list = atk_text_get_default_attributes(_SELF(self)); + ary = rb_ary_new(); + + while (list) { + AtkAttribute* data = (AtkAttribute*)list->data; + rb_ary_push(ary, rb_assoc_new(CSTR2RVAL(data->name), + CSTR2RVAL(data->value))); + list = list->next; + } + atk_attribute_set_free(list); + return ary; +} + +static VALUE +rg_character_count(VALUE self) +{ + return INT2NUM(atk_text_get_character_count(_SELF(self))); +} + +static VALUE +rg_get_offset_at_point(VALUE self, VALUE x, VALUE y, VALUE coords) +{ + return INT2NUM(atk_text_get_offset_at_point(_SELF(self), + NUM2INT(x), NUM2INT(y), + RVAL2ATKCOORDTYPE(coords))); +} + +#ifdef HAVE_ATK_TEXT_GET_BOUNDED_RANGES +#ifdef HAVE_ATK_TEXT_CLIP_TYPE_GET_TYPE +static VALUE +rg_get_bounded_ranges(VALUE self, VALUE rect, VALUE coord_type, VALUE x_clip_type, VALUE y_clip_type) +{ + AtkTextRange** ranges; + int i = 0; + VALUE ary; + ranges = atk_text_get_bounded_ranges(_SELF(self), + RVAL2ATKTEXTRECTANGLE(rect), + RVAL2ATKCOORDTYPE(coord_type), + RVAL2ATKTEXTCLIPTYPE(x_clip_type), + RVAL2ATKTEXTCLIPTYPE(y_clip_type)); + ary = rb_ary_new(); + while(ranges[i]){ + rb_ary_push(ary, ATKTEXTRANGE2RVAL(ranges[i])); + i++; + } +#ifdef HAVE_ATK_TEXT_FREE_RANGES + atk_text_free_ranges(ranges); +#endif + return ary; +} +#endif + +static VALUE +rg_get_range_extents(VALUE self, VALUE start_offset, VALUE end_offset, VALUE coord_type) +{ + AtkTextRectangle rect; + atk_text_get_range_extents(_SELF(self), NUM2INT(start_offset), + NUM2INT(end_offset), + RVAL2ATKCOORDTYPE(coord_type), + &rect); + return ATKTEXTRECTANGLE2RVAL(&rect); +} + +/* Don't need this +void atk_text_free_ranges (AtkTextRange **ranges); +*/ +#endif + +static VALUE +rg_n_selections(VALUE self) +{ + return INT2NUM(atk_text_get_n_selections(_SELF(self))); +} + +static VALUE +rg_get_selection(VALUE self, VALUE selection_num) +{ + gint start_offset, end_offset; + VALUE ret; + gchar* text = atk_text_get_selection(_SELF(self), NUM2INT(selection_num), + &start_offset, &end_offset); + ret = CSTR2RVAL(text); + g_free(text); + + return ret; +} + +static VALUE +rg_add_selection(VALUE self, VALUE start_offset, VALUE end_offset) +{ + gboolean ret = atk_text_add_selection(_SELF(self), NUM2INT(start_offset), + NUM2INT(end_offset)); + if (! ret) rb_raise(rb_eRuntimeError, "Can't add selection"); + return self; +} + +static VALUE +rg_remove_selection(VALUE self, VALUE selection_num) +{ + gint num; + gboolean ret; + + num = NUM2INT(selection_num); + ret = atk_text_remove_selection(_SELF(self), num); + if (! ret) + rb_raise(rb_eRuntimeError, "Can't remove selection. num = %d", num); + return self; +} + +static VALUE +rg_set_selection(VALUE self, VALUE selection_num, VALUE start_offset, VALUE end_offset) +{ + gboolean ret = atk_text_set_selection(_SELF(self), NUM2INT(selection_num), + NUM2INT(start_offset), + NUM2INT(end_offset)); + if (! ret) rb_raise(rb_eRuntimeError, "Can't set selection"); + return self; +} + +static VALUE +rg_set_caret_offset(VALUE self, VALUE offset) +{ + gboolean ret = atk_text_set_caret_offset(_SELF(self), NUM2INT(offset)); + if (! ret) rb_raise(rb_eRuntimeError, "Can't set caret offset"); + return self; +} + +/* We don't need them. + void atk_attribute_set_free (AtkAttributeSet *attrib_set); +*/ + +void +Init_atk_text(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(ATK_TYPE_TEXT, "Text", mAtk); + + RG_DEF_METHOD(get_text, 2); + RG_DEF_METHOD(get_character_at_offset, 1); + RG_DEF_METHOD(get_text_after_offset, 2); + RG_DEF_METHOD(get_text_at_offset, 2); + RG_DEF_METHOD(get_text_before_offset, 2); + RG_DEF_METHOD(caret_offset, 0); + RG_DEF_METHOD(get_character_extents, 2); + RG_DEF_METHOD(get_run_attributes, 1); + RG_DEF_METHOD(default_attributes, 0); + RG_DEF_METHOD(character_count, 0); + RG_DEF_METHOD(get_offset_at_point, 3); +#ifdef HAVE_ATK_TEXT_GET_BOUNDED_RANGES +#ifdef HAVE_ATK_TEXT_CLIP_TYPE_GET_TYPE + RG_DEF_METHOD(get_bounded_ranges, 4); + RG_DEF_METHOD(get_range_extents, 3); +#endif +#endif + RG_DEF_METHOD(n_selections, 0); + RG_DEF_METHOD(get_selection, 1); + RG_DEF_METHOD(add_selection, 2); + RG_DEF_METHOD(remove_selection, 1); + RG_DEF_METHOD(set_selection, 3); + RG_DEF_METHOD(set_caret_offset, 1); + + /* AtkTextBoundary */ +#ifdef ATK_TYPE_TEXT_BOUNDARY + G_DEF_CLASS(ATK_TYPE_TEXT_BOUNDARY, "Boundary", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, ATK_TYPE_TEXT_BOUNDARY, "ATK_TEXT_"); +#endif + /* AtkTextClipType */ +#ifdef HAVE_ATK_TEXT_GET_BOUNDED_RANGES +#ifdef HAVE_ATK_TEXT_CLIP_TYPE_GET_TYPE + G_DEF_CLASS(ATK_TYPE_TEXT_CLIP_TYPE, "ClipType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, ATK_TYPE_TEXT_CLIP_TYPE, "ATK_TEXT_"); +#endif +#endif + + Init_atk_text_attribute(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatktextattribute.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatktextattribute.c new file mode 100644 index 0000000..69342f7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatktextattribute.c @@ -0,0 +1,54 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE cAttribute + +static VALUE +rg_s_type_register(G_GNUC_UNUSED VALUE self, VALUE name) +{ + return ATKTEXTATTRIBUTE2RVAL(atk_text_attribute_register(RVAL2CSTR(name))); +} + +static VALUE +rg_s_for_name(G_GNUC_UNUSED VALUE self, VALUE name) +{ + return ATKTEXTATTRIBUTE2RVAL(atk_text_attribute_for_name(RVAL2CSTR(name))); +} + +static VALUE +rg_get_value(VALUE self, VALUE index) +{ + return CSTR2RVAL(atk_text_attribute_get_value(RVAL2ATKTEXTATTRIBUTE(self), + NUM2INT(index))); +} + +void +Init_atk_text_attribute(VALUE mText) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_TEXT_ATTRIBUTE, "Attribute", mText); + G_DEF_CONSTANTS(mText, ATK_TYPE_TEXT_ATTRIBUTE, "ATK_TEXT_"); + + RG_DEF_SMETHOD(type_register, 1); + RG_DEF_SMETHOD(for_name, 1); + RG_DEF_METHOD(get_value, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatktextrange.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatktextrange.c new file mode 100644 index 0000000..ba6cada --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatktextrange.c @@ -0,0 +1,92 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * Copyright (C) 2002,2003 Masao Mutoh + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#ifdef HAVE_ATK_TEXT_GET_BOUNDED_RANGES +#define RG_TARGET_NAMESPACE cTextRange +#define _SELF(r) (RVAL2ATKTEXTRANGE(r)) + +/**********************************/ +static AtkTextRange* +atk_text_range_copy(const AtkTextRange* val) +{ + AtkTextRange* new_val; + g_return_val_if_fail (val != NULL, NULL); + new_val = g_new(AtkTextRange, 1); + *new_val = *val; + return new_val; +} + +GType +atk_text_range_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("AtkTextRange", + (GBoxedCopyFunc)atk_text_range_copy, + (GBoxedFreeFunc)g_free); + return our_type; +} +/**********************************/ +/* Struct accessors */ +static VALUE +rg_bounds(VALUE self) +{ + return ATKTEXTRECTANGLE2RVAL(&_SELF(self)->bounds); +} + +static VALUE +rg_start_offset(VALUE self) +{ + return INT2NUM(_SELF(self)->start_offset); +} + +static VALUE +rg_end_offset(VALUE self) +{ + return INT2NUM(_SELF(self)->end_offset); +} + +static VALUE +rg_content(VALUE self) +{ + return CSTR2RVAL(_SELF(self)->content); +} +#endif + +void +Init_atk_text_range(VALUE mAtk) +{ +#ifdef HAVE_ATK_TEXT_GET_BOUNDED_RANGES + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_TEXT_RANGE, "TextRange", mAtk); + + RG_DEF_METHOD(bounds, 0); + RG_DEF_METHOD(start_offset, 0); + RG_DEF_METHOD(end_offset, 0); + RG_DEF_METHOD(content, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatktextrectangle.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatktextrectangle.c new file mode 100644 index 0000000..d9ca475 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatktextrectangle.c @@ -0,0 +1,149 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * Copyright (C) 2002,2003 Masao Mutoh + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#ifdef HAVE_ATK_TEXT_GET_BOUNDED_RANGES +#define RG_TARGET_NAMESPACE cTextRectangle +#define _SELF(r) (RVAL2ATKTEXTRECTANGLE(r)) + +/**********************************/ +static AtkTextRectangle* +atk_text_rectangle_copy(const AtkTextRectangle* val) +{ + AtkTextRectangle* new_val; + g_return_val_if_fail (val != NULL, NULL); + new_val = g_new(AtkTextRectangle, 1); + *new_val = *val; + return new_val; +} + +GType +atk_text_rectangle_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("AtkTextRectangle", + (GBoxedCopyFunc)atk_text_rectangle_copy, + (GBoxedFreeFunc)g_free); + return our_type; +} +/**********************************/ + +static VALUE +rg_initialize(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height) +{ + AtkTextRectangle rectangle; + + rectangle.x = NUM2INT(x); + rectangle.y = NUM2INT(y); + rectangle.width = NUM2INT(width); + rectangle.height = NUM2INT(height); + + G_INITIALIZE(self, g_boxed_copy(ATK_TYPE_TEXT_RECTANGLE, &rectangle)); + return Qnil; +} + +/* Struct accessors */ +static VALUE +rg_x(VALUE self) +{ + return INT2NUM(_SELF(self)->x); +} + +static VALUE +rg_y(VALUE self) +{ + return INT2NUM(_SELF(self)->y); +} + +static VALUE +rg_width(VALUE self) +{ + return INT2NUM(_SELF(self)->width); +} + +static VALUE +rg_height(VALUE self) +{ + return INT2NUM(_SELF(self)->height); +} + +static VALUE +rg_set_x(VALUE self, VALUE x) +{ + _SELF(self)->x = NUM2INT(x); + return self; +} + +static VALUE +rg_set_y(VALUE self, VALUE y) +{ + _SELF(self)->y = NUM2INT(y); + return self; +} + +static VALUE +rg_set_width(VALUE self, VALUE width) +{ + _SELF(self)->width = NUM2INT(width); + return self; +} + +static VALUE +rg_set_height(VALUE self, VALUE height) +{ + _SELF(self)->height = NUM2INT(height); + return self; +} + +static VALUE +rg_to_a(VALUE self) +{ + AtkTextRectangle* a = _SELF(self); + return rb_ary_new3(4, INT2FIX(a->x), INT2FIX(a->y), + INT2FIX(a->width), INT2FIX(a->height)); +} +#endif + +void +Init_atk_text_rectangle(VALUE mAtk) +{ +#ifdef HAVE_ATK_TEXT_GET_BOUNDED_RANGES + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_TEXT_RECTANGLE, "TextRectangle", mAtk); + + RG_DEF_METHOD(initialize, 4); + RG_DEF_METHOD(x, 0); + RG_DEF_METHOD(y, 0); + RG_DEF_METHOD(width, 0); + RG_DEF_METHOD(height, 0); + RG_DEF_METHOD(set_x, 1); + RG_DEF_METHOD(set_y, 1); + RG_DEF_METHOD(set_width, 1); + RG_DEF_METHOD(set_height, 1); + RG_DEF_METHOD(to_a, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkutil.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkutil.c new file mode 100644 index 0000000..23fe7e6 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkutil.c @@ -0,0 +1,126 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE cUtil +static ID id_call; + +/* How can I implement them? +guint atk_add_focus_tracker (AtkEventListener focus_tracker); +void atk_remove_focus_tracker (guint tracker_id); +void atk_focus_tracker_init (AtkEventListenerInit add_function); +void (*AtkEventListener) (AtkObject*); +void (*AtkEventListenerInit) (void); +guint atk_add_global_event_listener (GSignalEmissionHook listener, + const gchar *event_type); +void atk_remove_global_event_listener + (guint listener_id); +*/ + +static VALUE +rg_s_focus_tracker_notify(VALUE self, VALUE obj) +{ + atk_focus_tracker_notify(RVAL2ATKOBJECT(obj)); + return self; +} + +static gint +key_snoop_func(AtkKeyEventStruct* event, gpointer func) +{ + VALUE ret = rb_funcall((VALUE)func, id_call, 7, + INT2NUM(event->type), UINT2NUM(event->state), + UINT2NUM(event->keyval), INT2NUM(event->length), + CSTR2RVAL(event->string), UINT2NUM(event->keycode), + UINT2NUM(event->timestamp)); + return NUM2INT(ret); +} + +static VALUE +rg_s_add_key_event_listener(VALUE self) +{ + guint ret; + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + ret = atk_add_key_event_listener((AtkKeySnoopFunc)key_snoop_func, (gpointer)func); + return UINT2NUM(ret); +} + +static VALUE +rg_s_remove_key_event_listener(VALUE self, VALUE id) +{ + atk_remove_key_event_listener(NUM2UINT(id)); + return self; +} + +static VALUE +rg_s_root(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(atk_get_root()); +} + +#if ATK_CHECK_VERSION(1,6,0) +static VALUE +rg_s_focus_object(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(atk_get_focus_object()); +} +#endif + +static VALUE +rg_s_toolkit_name(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(atk_get_toolkit_name()); +} + +static VALUE +rg_s_toolkit_version(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(atk_get_toolkit_version()); +} + +void +Init_atk_util(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_UTIL, "Util", mAtk); + + id_call = rb_intern("call"); + + RG_DEF_SMETHOD(focus_tracker_notify, 1); + RG_DEF_SMETHOD(add_key_event_listener, 0); + RG_DEF_SMETHOD(remove_key_event_listener, 1); + + RG_DEF_SMETHOD(root, 0); +#if ATK_CHECK_VERSION(1,6,0) + RG_DEF_SMETHOD(focus_object, 0); +#endif + RG_DEF_SMETHOD(toolkit_name, 0); + RG_DEF_SMETHOD(toolkit_version, 0); + + /* AtkCoordType */ + G_DEF_CLASS(ATK_TYPE_COORD_TYPE, "CoordType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, ATK_TYPE_COORD_TYPE, "ATK_"); + + /* AtkKeyEventType */ + G_DEF_CLASS(ATK_TYPE_KEY_EVENT_TYPE, "KeyEventType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, ATK_TYPE_KEY_EVENT_TYPE, "ATK_"); + +} diff --git a/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkvalue.c b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkvalue.c new file mode 100644 index 0000000..1730cf9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/ext/atk/rbatkvalue.c @@ -0,0 +1,78 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbatkprivate.h" + +#define RG_TARGET_NAMESPACE mValue +#define _SELF(s) (RVAL2ATKVALUE(s)) + +static VALUE +rg_current(VALUE self) +{ + GValue gval = G_VALUE_INIT; + atk_value_get_current_value(_SELF(self), &gval); + + return GVAL2RVAL(&gval); +} + +static VALUE +rg_max(VALUE self) +{ + GValue gval = G_VALUE_INIT; + atk_value_get_maximum_value(_SELF(self), &gval); + + return GVAL2RVAL(&gval); +} + +static VALUE +rg_min(VALUE self) +{ + GValue gval = G_VALUE_INIT; + atk_value_get_minimum_value(_SELF(self), &gval); + + return GVAL2RVAL(&gval); +} + +static VALUE +rg_set_current(VALUE self, VALUE value) +{ + GValue gval = G_VALUE_INIT; + g_value_init(&gval, RVAL2GTYPE(value)); + + rbgobj_rvalue_to_gvalue(value, &gval); + + if (! atk_value_set_current_value(_SELF(self), &gval)){ + rb_raise(rb_eRuntimeError, "Can't set the current value."); + } + + return self; +} + +void +Init_atk_value(VALUE mAtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(ATK_TYPE_VALUE, "Value", mAtk); + + RG_DEF_METHOD(current, 0); + RG_DEF_METHOD(max, 0); + RG_DEF_METHOD(min, 0); + RG_DEF_METHOD(set_current, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/atk/extconf.rb b/lib/ruby-gtk2-2.0.2/atk/extconf.rb new file mode 100644 index 0000000..fdfd8d0 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/extconf.rb @@ -0,0 +1,49 @@ +#!/usr/bin/env ruby + +require 'pathname' +require 'mkmf' +require 'rbconfig' +require 'fileutils' + +package = "atk" + +base_dir = Pathname(__FILE__).dirname.expand_path +ext_dir = base_dir + "ext" + package +mkmf_gnome2_dir = base_dir + 'lib' + +ruby = File.join(RbConfig::CONFIG['bindir'], + RbConfig::CONFIG['ruby_install_name'] + + RbConfig::CONFIG["EXEEXT"]) + +build_dir = Pathname("ext") + package +FileUtils.mkdir_p(build_dir.to_s) unless build_dir.exist? +extconf_rb_path = ext_dir + "extconf.rb" +system(ruby, "-C", build_dir.to_s, extconf_rb_path.to_s, *ARGV) || exit(false) + +create_makefile(package) +FileUtils.mv("Makefile", "Makefile.lib") + +File.open("Makefile", "w") do |makefile| + makefile.puts(<<-EOM) +all: + (cd ext/#{package} && $(MAKE)) + $(MAKE) -f Makefile.lib + +install: + (cd ext/#{package} && $(MAKE) install) + $(MAKE) -f Makefile.lib install + +site-install: + (cd ext/#{package} && $(MAKE) site-install) + $(MAKE) -f Makefile.lib site-install + +clean: + (cd ext/#{package} && $(MAKE) clean) + $(MAKE) -f Makefile.lib clean + +distclean: + (cd ext/#{package} && $(MAKE) distclean) + $(MAKE) -f Makefile.lib distclean + @rm -f Makefile.lib +EOM +end diff --git a/lib/ruby-gtk2-2.0.2/atk/lib/atk.rb b/lib/ruby-gtk2-2.0.2/atk/lib/atk.rb new file mode 100644 index 0000000..d03b24f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/lib/atk.rb @@ -0,0 +1,21 @@ +require 'glib2' + +base_dir = Pathname.new(__FILE__).dirname.dirname.expand_path +vendor_dir = base_dir + "vendor" + "local" +vendor_bin_dir = vendor_dir + "bin" +GLib.prepend_dll_path(vendor_bin_dir) +begin + major, minor, _ = RUBY_VERSION.split(/\./) + require "#{major}.#{minor}/atk.so" +rescue LoadError + require 'atk.so' +end + +if vendor_dir.exist? + begin + require "gobject-introspection" + vendor_girepository_dir = vendor_dir + "lib" + "girepository-1.0" + GObjectIntrospection.prepend_typelib_path(vendor_girepository_dir) + rescue LoadError + end +end diff --git a/lib/ruby-gtk2-2.0.2/atk/test/atk-test-utils.rb b/lib/ruby-gtk2-2.0.2/atk/test/atk-test-utils.rb new file mode 100644 index 0000000..aae01c7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/test/atk-test-utils.rb @@ -0,0 +1,21 @@ +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "test-unit" +require "test/unit/notify" + +module AtkTestUtils +end diff --git a/lib/ruby-gtk2-2.0.2/atk/test/run-test.rb b/lib/ruby-gtk2-2.0.2/atk/test/run-test.rb new file mode 100755 index 0000000..538e64a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/test/run-test.rb @@ -0,0 +1,45 @@ +#!/usr/bin/env ruby +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +ruby_gnome2_base = File.join(File.dirname(__FILE__), "..", "..") +ruby_gnome2_base = File.expand_path(ruby_gnome2_base) + +glib_base = File.join(ruby_gnome2_base, "glib2") +atk_base = File.join(ruby_gnome2_base, "atk") + +modules = [ + [glib_base, "glib2"], + [atk_base, "atk"] +] +modules.each do |target, module_name| + if system("which make > /dev/null") + `make -C #{target.dump} > /dev/null` or exit(false) + end + $LOAD_PATH.unshift(File.join(target, "ext", module_name)) + $LOAD_PATH.unshift(File.join(target, "lib")) +end + +$LOAD_PATH.unshift(File.join(glib_base, "test")) +require "glib-test-init" + +$LOAD_PATH.unshift(File.join(atk_base, "test")) +require "atk-test-utils" + +require "atk" + +exit Test::Unit::AutoRunner.run(true) diff --git a/lib/ruby-gtk2-2.0.2/atk/test/test-text-rectangle.rb b/lib/ruby-gtk2-2.0.2/atk/test/test-text-rectangle.rb new file mode 100644 index 0000000..816cc94 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/atk/test/test-text-rectangle.rb @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestAtkRectangle < Test::Unit::TestCase + include AtkTestUtils + + def test_width + rectangle = Atk::TextRectangle.new(0, 10, 20, 30) + assert_equal(20, rectangle.width) + end +end diff --git a/lib/ruby-gtk2-2.0.2/exec_make.rb b/lib/ruby-gtk2-2.0.2/exec_make.rb new file mode 100644 index 0000000..84550d7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/exec_make.rb @@ -0,0 +1,48 @@ +=begin + exec_make.rb is called by top-level Makefile. + + $Id: exec_make.rb,v 1.5 2005/01/31 10:34:33 mutoh Exp $ + + Copyright (C) 2003-2005 Ruby-GNOME2 Project Team +=end + +argv = ARGV +strict = false +if ARGV[0] == "--strict" || ARGV[0] == "-s" + strict = true + argv = ARGV[1..-1] +end + +SUBDIRS = argv[0].split(" ") +EXECUTE = argv[1..-1].join(' ') + +success = [] +failure = [] +SUBDIRS.each do |subdir| + Dir.chdir(subdir) + begin + ret = system(EXECUTE) + ensure + Dir.chdir("..") + end + + if ret + success << subdir + else + failure << subdir + end +end + +success << "NONE" if success.size == 0 +failure << "NONE" if failure.size == 0 + +puts "\n" +puts "-----" +puts "SUCCEEDED: #{success.join(' ')}" if success.size > 0 +puts "FAILED: #{failure.join(' ')}" if failure.size > 0 +puts "-----" +puts "Done." + +if strict && (failure.select { |x| x != "NONE" }.length > 0) + exit(1) +end diff --git a/lib/ruby-gtk2-2.0.2/extconf.rb b/lib/ruby-gtk2-2.0.2/extconf.rb new file mode 100644 index 0000000..abf3208 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/extconf.rb @@ -0,0 +1,144 @@ +=begin + top-level extconf.rb for Ruby-GNOME2 + + $Id: extconf.rb,v 1.17 2007/10/22 12:19:17 ktou Exp $ + + Copyright (C) 2003-2005 Ruby-GNOME2 Project Team +=end + +require 'English' +require 'mkmf' +require 'fileutils' +require 'pathname' + +priorlibs = [ + "glib2", + "gobject-introspection", + "gio2", + "gdk_pixbuf2", + "pango", + "atk", + "gtk2", + "gdk3", + "gtk3", +] + +# +# detect sub-directories +# +$ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['RUBY_INSTALL_NAME'] + RbConfig::CONFIG['EXEEXT']) +$ruby = arg_config("--ruby", $ruby) + +rm = "rm -f" +if /mswin/ =~ RUBY_PLATFORM + rm = "del" +end + + +$srcdir = File.dirname(__FILE__) +$topsrcdir = $configure_args["--topsrcdir"] ||= $srcdir +$topdir = $configure_args["--topdir"] ||= Dir.pwd +$strict = $configure_args["--strict"] ? "--strict" : "" + +$srcdir = File.expand_path($srcdir) +$topsrcdir = File.expand_path($topsrcdir) +$topdir = File.expand_path($topdir) + +subdirs = ARGV.select{|v| /^--/ !~ v} + +if subdirs.size == 0 + subdirs = Dir.glob($topsrcdir+"/*/extconf.rb") + subdirs.collect! do |subdir| + subdir[0..$topsrcdir.size] = "" + File.dirname(subdir) + end + priorlibs &= subdirs + subdirs -= priorlibs + subdirs = priorlibs + subdirs #Change the order +end + +# +# generate sub-directory Makefiles +# +target_modules = [] +ignore_modules = [] + +ruby, *ruby_args = Shellwords.shellwords($ruby) +if ARGV.grep(/\A--ruby=/) + extra_args = ["--ruby=#{$ruby}"] + ARGV.reject {|arg| /\A--ruby=/ =~ arg} +else + extra_args = ARGV.dup +end + +subdirs.each do |subdir| + STDERR.puts("#{$0}: Entering directory `#{subdir}'") + FileUtils.mkdir_p(subdir) + topdir = File.join(*([".."] * subdir.split(/\/+/).size)) + dir = $topsrcdir + dir = File.join(topdir, dir) unless Pathname.new(dir).absolute? + srcdir = File.join(dir, subdir) + args = ruby_args + ["-C", subdir, File.join(srcdir, "extconf.rb"), + "--topsrcdir=#{dir}", "--topdir=#{topdir}", + *extra_args] + ret = system(ruby, *args) + STDERR.puts("#{$0}: Leaving directory '#{subdir}'") + if ret + target_modules << subdir + else + ignore_modules << subdir + end +end +puts "\n-----" +unless target_modules.empty? + puts "Target libraries: #{target_modules.join(', ')}" +end +unless ignore_modules.empty? + puts "Ignored libraries: #{ignore_modules.join(', ')}" +end + +# +# generate top-level Makefile +# + +def run_make_in_sub_dir(sub_dir, target) + if /mswin/ =~ RUBY_PLATFORM + " $(COMMAND) '#{sub_dir}' $(MAKE) #{target}" + else + " (cd '#{sub_dir}' && $(MAKE) #{target})" + end +end + + +File.open("Makefile", "w") do |makefile| + makefile.print(<<-EOM) +TOPSRCDIR = #{$topsrcdir} +COMMAND = #{$ruby} #{$topsrcdir}/exec_make.rb #{$strict} +RM = #{rm} +EOM + + ["all", "install", "site-install", "clean", "distclean"].each do |target| + makefile.print(<<-EOM) +#{target}: +EOM + target_modules.each do |target_module| + sub_target = "#{target}-#{target_module}" + makefile.print(<<-EOM) +#{target}: #{sub_target} +#{sub_target}: + #{run_make_in_sub_dir(target_module, target)} + +EOM + end + end + + makefile.print(<<-EOM) +distclean: distclean-toplevel +distclean-toplevel: + $(RM) Makefile mkmf.log +EOM +end + +puts "-----" +puts "Done." + +$makefile_created = true diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/COPYING.LIB b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/COPYING.LIB new file mode 100644 index 0000000..b1e3f5a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/COPYING.LIB @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. + + GNU LESSER GENERAL PUBLIC LICENSE + 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 + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/README b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/README new file mode 100644 index 0000000..b7113e1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/README @@ -0,0 +1,29 @@ +Ruby/GdkPixbuf2 +=============== +Ruby/GdkPixbuf2 is a Ruby binding of GdkPixbuf-2.x. + +Requirements +------------ + Ruby: http://www.ruby-lang.org/ + GTK+: http://www.gtk.org/ + Ruby/GLib2, Ruby/GTK2: http://ruby-gnome2.sourceforge.net/ + +Install +------- + 0. install ruby-1.6.x or later, GTK+, Ruby/GLib2 and Ruby/GTK2. + 1. ruby extconf.rb + 2. make + 3. su + 4. make install + +Copying +------- + Copyright (c) 2002-2005 Ruby-GNOME2 Project Team + + This program is free software. + You can distribute/modify this program under the terms of + the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. + +Project Website +--------------- + http://ruby-gnome2.sourceforge.jp/ diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/Rakefile b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/Rakefile new file mode 100644 index 0000000..9c214e7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/Rakefile @@ -0,0 +1,32 @@ +# -*- ruby -*- + +$LOAD_PATH.unshift("./../glib2/lib") +require "gnome2/rake/package-task" + +package_task = GNOME2::Rake::PackageTask.new do |package| + package.summary = "Ruby/GdkPixbuf2 is a Ruby binding of GdkPixbuf-2.x." + package.description = "Ruby/GdkPixbuf2 is a Ruby binding of GdkPixbuf-2.x." + package.dependency.gem.runtime = ["glib2"] + package.windows.packages = [] + package.windows.dependencies = ["zlib", "libpng"] + package.windows.build_dependencies = [ + "glib2", + "gobject-introspection", + ] + package.external_packages = [ + { + :name => "gdk-pixbuf", + :download_site => :gnome, + :label => "gdk-pixbuf", + :version => "2.28.1", + :compression_method => "xz", + :windows => { + :configure_args => [ + "--with-included-loaders", + "--enable-introspection", + ], + }, + } + ] +end +package_task.define diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/depend b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/depend new file mode 100644 index 0000000..3fb2d1d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/depend @@ -0,0 +1,11 @@ +install-so: install-headers +install-headers: + $(INSTALL_DATA) $(srcdir)/rbgdk-pixbuf.h $(RUBYARCHDIR) + $(INSTALL_DATA) $(srcdir)/rbgdk-pixbuf2conversions.h $(RUBYARCHDIR) + +install: install-pc +install-pc: + if test -n "$(pkgconfigdir)"; then \ + $(MAKEDIRS) $(pkgconfigdir); \ + $(INSTALL_DATA) ruby-gdk-pixbuf2.pc $(pkgconfigdir); \ + fi diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/extconf.rb b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/extconf.rb new file mode 100644 index 0000000..dc6b08b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/extconf.rb @@ -0,0 +1,66 @@ +=begin +extconf.rb for Ruby/GdkPixbuf2 extention library +=end + +require 'pathname' + +base_dir = Pathname(__FILE__).dirname.parent.parent.expand_path +top_dir = base_dir.parent +top_build_dir = Pathname(".").parent.parent.parent.expand_path + +mkmf_gnome2_dir = top_dir + "glib2" + 'lib' +version_suffix = "" +unless mkmf_gnome2_dir.exist? + if /(-\d+\.\d+\.\d+)(?:\.\d+)?\z/ =~ base_dir.basename.to_s + version_suffix = $1 + mkmf_gnome2_dir = top_dir + "glib2#{version_suffix}" + 'lib' + end +end + +$LOAD_PATH.unshift(mkmf_gnome2_dir.to_s) + +module_name = "gdk_pixbuf2" +package_id = "gdk-pixbuf-2.0" + +begin + require 'mkmf-gnome2' +rescue LoadError + require 'rubygems' + gem 'glib2' + require 'mkmf-gnome2' +end + +["glib2"].each do |package| + directory = "#{package}#{version_suffix}" + build_dir = "#{directory}/tmp/#{RUBY_PLATFORM}/#{package}/#{RUBY_VERSION}" + add_depend_package(package, "#{directory}/ext/#{package}", + top_dir.to_s, + :top_build_dir => top_build_dir.to_s, + :target_build_dir => build_dir) +end + +setup_win32(module_name, base_dir) + +unless required_pkg_config_package(package_id, + :debian => "libgdk-pixbuf2.0-dev", + :redhat => "gtk2-devel", + :fedora => "gdk-pixbuf2-devel", + :homebrew => "gdk-pixbuf", + :macports => "gdk-pixbuf2") + exit(false) +end + +have_func("gdk_pixbuf_set_option", "gdk-pixbuf/gdk-pixbuf.h") do |src| + "#define GDK_PIXBUF_ENABLE_BACKEND\n#{src}" +end + +create_pkg_config_file("Ruby/GdkPixbuf2", package_id, nil, "ruby-gdk-pixbuf2.pc") +create_makefile(module_name) + +pkg_config_dir = with_config("pkg-config-dir") +if pkg_config_dir.is_a?(String) + File.open("Makefile", "ab") do |makefile| + makefile.puts + makefile.puts("pkgconfigdir=#{pkg_config_dir}") + end +end diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/gdk_pixbuf2.def b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/gdk_pixbuf2.def new file mode 100644 index 0000000..9d880ab --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/gdk_pixbuf2.def @@ -0,0 +1,2 @@ +EXPORTS + Init_gdk_pixbuf2 diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbuf-format.c b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbuf-format.c new file mode 100644 index 0000000..040fb83 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbuf-format.c @@ -0,0 +1,179 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgdk-pixbuf2private.h" +#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0) + +#ifdef HAVE_GDK_PIXBUF_GDK_PIXBUF_IO_H +#include +#endif + +#define RG_TARGET_NAMESPACE cPixbufFormat +#define _SELF(r) (RVAL2GDKPIXBUFFORMAT(r)) + +/**********************************/ +static GdkPixbufFormat* +format_copy(const GdkPixbufFormat* val) +{ + GdkPixbufFormat* new_val; + g_return_val_if_fail (val != NULL, NULL); + new_val = g_new(GdkPixbufFormat, 1); + *new_val = *val; + return new_val; +} + +GType +gdk_pixbuf_format_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("GdkPixbufFormat", + (GBoxedCopyFunc)format_copy, + (GBoxedFreeFunc)g_free); + return our_type; +} +/**********************************/ + +/* Move to rbgdk-pixbuf.c +gboolean gdk_pixbuf_set_option (GdkPixbuf *pixbuf, + const gchar *key, + const gchar *value); +GSList* gdk_pixbuf_get_formats (void); +*/ + +static VALUE +rg_name(VALUE self) +{ + return CSTR2RVAL_FREE(gdk_pixbuf_format_get_name(_SELF(self))); +} + +static VALUE +rg_description(VALUE self) +{ + return CSTR2RVAL_FREE(gdk_pixbuf_format_get_description(_SELF(self))); +} + +static VALUE +rg_mime_types(VALUE self) +{ + gint i = 0; + gchar** mime_types = gdk_pixbuf_format_get_mime_types(_SELF(self)); + VALUE array = rb_ary_new(); + while(mime_types[i]){ + rb_ary_push(array, CSTR2RVAL(mime_types[i])); + i++; + } + g_strfreev(mime_types); + return array; +} + +static VALUE +rg_extensions(VALUE self) +{ + gint i = 0; + gchar** extensions = gdk_pixbuf_format_get_extensions(_SELF(self)); + VALUE array = rb_ary_new(); + + while(extensions[i]){ + rb_ary_push(array, CSTR2RVAL(extensions[i])); + i++; + } + g_strfreev(extensions); + return array; +} + +static VALUE +rg_writable_p(VALUE self) +{ + return CBOOL2RVAL(gdk_pixbuf_format_is_writable(_SELF(self))); +} + +/* Structure */ +static VALUE +rg_domain(VALUE self) +{ + return CSTR2RVAL(_SELF(self)->domain); +} + +static VALUE +rg_signature(VALUE self) +{ + GdkPixbufModulePattern* signature = _SELF(self)->signature; + + VALUE array = rb_ary_new(); + int i = 0; + while(signature[i].prefix){ + rb_ary_push(array, rb_ary_new3(3, CSTR2RVAL((const char*)signature[i].prefix), + CSTR2RVAL((const char*)signature[i].mask), + INT2NUM(signature[i].relevance))); + i++; + } + return array; +} +#endif + +#if RBGDK_PIXBUF_CHECK_VERSION(2,6,0) +static VALUE +rg_scalable_p(VALUE self) +{ + return CBOOL2RVAL(gdk_pixbuf_format_is_scalable(_SELF(self))); +} +static VALUE +rg_disabled_p(VALUE self) +{ + return CBOOL2RVAL(gdk_pixbuf_format_is_disabled(_SELF(self))); +} +static VALUE +rg_set_disabled(VALUE self, VALUE disabled) +{ + gdk_pixbuf_format_set_disabled(_SELF(self), RVAL2CBOOL(disabled)); + return self; +} +static VALUE +rg_license(VALUE self) +{ + return CSTR2RVAL(gdk_pixbuf_format_get_license(_SELF(self))); +} +#endif + +void +Init_gdk_pixbuf_format(VALUE mGdk) +{ +#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_PIXBUF_FORMAT, "PixbufFormat", mGdk); + + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(description, 0); + RG_DEF_METHOD(mime_types, 0); + RG_DEF_METHOD(extensions, 0); + RG_DEF_METHOD_P(writable, 0); + RG_DEF_METHOD(domain, 0); + RG_DEF_METHOD(signature, 0); +#if RBGDK_PIXBUF_CHECK_VERSION(2,6,0) + RG_DEF_METHOD_P(scalable, 0); + RG_DEF_METHOD_P(disabled, 0); + RG_DEF_METHOD(set_disabled, 1); + RG_DEF_METHOD(license, 0); + +#endif +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbuf-loader.c b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbuf-loader.c new file mode 100644 index 0000000..5a21139 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbuf-loader.c @@ -0,0 +1,164 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * Copyright (C) 2003 Geoff Youngs + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgdk-pixbuf2private.h" + +#define RG_TARGET_NAMESPACE cPixbufLoader +#define _SELF(s) RVAL2GDKPIXBUFLOADER(s) + +/****************************************************/ +/* File opening */ +/* Image Data in Memory */ +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + GdkPixbufLoader* loader; + GError* error = NULL; + VALUE arg1, is_mime_type; + + rb_scan_args(argc, argv, "02", &arg1, &is_mime_type); + + if (NIL_P(arg1)) { + loader = gdk_pixbuf_loader_new(); + } else { + if (is_mime_type == Qtrue) { +#if RBGDK_PIXBUF_CHECK_VERSION(2,4,0) + loader = gdk_pixbuf_loader_new_with_mime_type(RVAL2CSTR(arg1), &error); +#else + rb_warning("Not supported GTK+-2.0/2.2."); + loader = gdk_pixbuf_loader_new(); +#endif + } else { + /* Default behavior */ + loader = gdk_pixbuf_loader_new_with_type(RVAL2CSTR(arg1), &error); + } + if(error) RAISE_GERROR(error); + } + + G_INITIALIZE(self, loader); + return Qnil; +} + +#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0) +static VALUE +rg_format(VALUE self) +{ + GdkPixbufFormat* format = gdk_pixbuf_loader_get_format(_SELF(self)); + return GDKPIXBUFFORMAT2RVAL(format); +} +#endif + +static VALUE +rg_write(VALUE self, VALUE data) +{ + GError *error = NULL; + + StringValue(data); + if (!gdk_pixbuf_loader_write(_SELF(self), + (const guchar *)RSTRING_PTR(data), + RSTRING_LEN(data), + &error)) + RAISE_GERROR(error); + + return Qtrue; +} + +static VALUE +rg_last_write(VALUE self, VALUE data) +{ + GError *error = NULL; + + StringValue(data); + if (!gdk_pixbuf_loader_write(_SELF(self), + (const guchar *)RSTRING_PTR(data), + RSTRING_LEN(data), + &error)) + RAISE_GERROR(error); + + if (!gdk_pixbuf_loader_close(_SELF(self), &error)) + RAISE_GERROR(error); + + return Qtrue; +} + +#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0) +static VALUE +rg_set_size(VALUE self, VALUE width, VALUE height) +{ + gdk_pixbuf_loader_set_size(_SELF(self), NUM2INT(width), NUM2INT(height)); + return self; +} +#endif + +static VALUE +rg_close(VALUE self) +{ + GError *error = NULL; + gboolean res; + + res = gdk_pixbuf_loader_close(_SELF(self), &error); + if(error) + RAISE_GERROR(error); + + return CBOOL2RVAL(res); +} + +/****************************************************/ +/* Creating image */ +static VALUE +rg_pixbuf(VALUE self) +{ + return GOBJ2RVAL(gdk_pixbuf_loader_get_pixbuf(_SELF(self))); +} + +/* Creating animation */ +static VALUE +rg_animation(VALUE self) +{ + return GOBJ2RVAL(gdk_pixbuf_loader_get_animation(_SELF(self))); +} + +void +Init_gdk_pixbuf_loader(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE; + /* initialize it */ + RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_PIXBUF_LOADER, "PixbufLoader", mGdk); + + /* + * File Loading, Image Data in Memory + */ + RG_DEF_METHOD(initialize, -1); + + rb_undef_method(RG_TARGET_NAMESPACE, "dup"); +#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(format, 0); +#endif + RG_DEF_METHOD(write, 1); + RG_DEF_METHOD(last_write, 1); +#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(set_size, 2); +#endif + RG_DEF_METHOD(close, 0); + RG_DEF_METHOD(pixbuf, 0); + RG_DEF_METHOD(animation, 0); +} \ No newline at end of file diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbuf.c b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbuf.c new file mode 100644 index 0000000..8148733 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbuf.c @@ -0,0 +1,737 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Masao Mutoh + * Copyright (C) 2000 Yasushi Shoji + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgdk-pixbuf2private.h" +#include + +#define RG_TARGET_NAMESPACE cPixbuf +#define _SELF(s) RVAL2GDKPIXBUF(s) + +#define NOMEM_ERROR(error) g_set_error(error,\ + GDK_PIXBUF_ERROR,\ + GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,\ + "Insufficient memory to load image file"); + +static ID id_pixdata; + +/****************************************************/ +/* The GdkPixbuf Structure */ +static int +pixels_size(GdkPixbuf *pixbuf) +{ + int height, width, rowstride, n_channels, bits_per_sample; + + height = gdk_pixbuf_get_height(pixbuf); + width = gdk_pixbuf_get_width(pixbuf); + rowstride = gdk_pixbuf_get_rowstride(pixbuf); + n_channels = gdk_pixbuf_get_n_channels(pixbuf); + bits_per_sample = gdk_pixbuf_get_bits_per_sample(pixbuf); + + return ((height - 1) * rowstride + + width * ((n_channels * bits_per_sample + 7) / 8)); +} + +static VALUE +get_pixels(VALUE self) +{ + GdkPixbuf *pixbuf = _SELF(self); + int size; + + size = pixels_size(pixbuf); + return rb_str_new((const char *)gdk_pixbuf_get_pixels(pixbuf), size); +} + +static VALUE +rg_operator_set_pixels(VALUE self, VALUE pixels) +{ + GdkPixbuf *pixbuf = _SELF(self); + int size; + int arg_size; + + size = pixels_size(pixbuf); + + StringValue(pixels); + arg_size = RSTRING_LEN(pixels); + if (arg_size != size) + rb_raise(rb_eRangeError, + "Pixels are %i bytes, %i bytes supplied.", + size, arg_size); + + /* The user currently cannot get a pointer to the actual + * pixels, the data is copied to a String. */ + memcpy(gdk_pixbuf_get_pixels(pixbuf), + RSTRING_PTR(pixels), MIN(RSTRING_LEN(pixels), size)); + + return pixels; +} + +static VALUE +rg_get_option(VALUE self, VALUE key) +{ + const gchar* ret = gdk_pixbuf_get_option(_SELF(self), RVAL2CSTR(key)); + return ret ? CSTR2RVAL(ret) : Qnil; +} + +/****************************************************/ +/* File opening */ +/* Image Data in Memory */ +static GdkPixbuf * +pixbuf_initialize_by_hash(VALUE self, VALUE arg, GError **error) +{ + GdkPixbuf *buf = NULL; + + VALUE rb_colorspace, rb_has_alpha, rb_bits_per_sample, rb_width, rb_height, + rb_data, rb_rowstride, rb_xpm, rb_inline, rb_copy_pixels, + rb_src_pixbuf, rb_src_x, rb_src_y, + rb_file, rb_scale_width, rb_scale_height, rb_preserve_aspect_ratio; + rbg_scan_options(arg, + "colorspace", &rb_colorspace, + "has_alpha", &rb_has_alpha, + "bits_per_sample", &rb_bits_per_sample, + "width", &rb_width, + "height", &rb_height, + "data", &rb_data, + "rowstride", &rb_rowstride, + "xpm", &rb_xpm, + "inline", &rb_inline, + "copy_pixels", &rb_copy_pixels, + "src_pixbuf", &rb_src_pixbuf, + "src_x", &rb_src_x, + "src_y", &rb_src_y, + "file", &rb_file, + "scale_width", &rb_scale_width, + "scale_height", &rb_scale_height, + "preserve_aspect_ratio", &rb_preserve_aspect_ratio, + NULL); + + if (!NIL_P(rb_data)) { + buf = gdk_pixbuf_new_from_data((const guchar*)RVAL2CSTR(rb_data), + NIL_P(rb_colorspace) ? GDK_COLORSPACE_RGB : RVAL2GDKCOLORSPACE(rb_colorspace), + RVAL2CBOOL(rb_has_alpha), + NIL_P(rb_bits_per_sample) ? 8 : NUM2INT(rb_bits_per_sample), + NUM2INT(rb_width), + NUM2INT(rb_height), + NUM2INT(rb_rowstride), + NULL, NULL); + if (buf == NULL) + NOMEM_ERROR(error); + // Save a reference to the string because the pixbuf doesn't copy it. + G_RELATIVE(self, rb_data); + } else if (!NIL_P(rb_xpm)) { + const gchar **data = RVAL2STRV(rb_xpm); + buf = gdk_pixbuf_new_from_xpm_data(data); + g_free(data); + if (buf == NULL) + NOMEM_ERROR(error); + } else if (!NIL_P(rb_inline)) { + /* TODO: Is this really up to the caller to decide? */ + long n; + guint8 *data = RVAL2GUINT8S(rb_inline, n); + buf = gdk_pixbuf_new_from_inline(n, data, RVAL2CBOOL(rb_copy_pixels), error); + /* need to manage the returned value */ + rb_ivar_set(self, id_pixdata, Data_Wrap_Struct(rb_cData, NULL, g_free, data)); + } else if (!NIL_P(rb_src_pixbuf)) { + buf = gdk_pixbuf_new_subpixbuf(_SELF(rb_src_pixbuf), + NUM2INT(rb_src_x), + NUM2INT(rb_src_y), + NUM2INT(rb_width), + NUM2INT(rb_height)); + if (buf == NULL) + NOMEM_ERROR(error); + } else if (!NIL_P(rb_file)) { + if (!NIL_P(rb_width)) { +#if RBGDK_PIXBUF_CHECK_VERSION(2,4,0) + buf = gdk_pixbuf_new_from_file_at_size(RVAL2CSTR(rb_file), + NUM2INT(rb_width), + NUM2INT(rb_height), + error); +#else + rb_warning("Sizing on load not supported in GTK+ < 2.4.0"); + buf = gdk_pixbuf_new_from_file(RVAL2CSTR(rb_file), error); +#endif + } else if (!NIL_P(rb_scale_width)) { +#if RBGDK_PIXBUF_CHECK_VERSION(2,6,0) + int width = NUM2INT(rb_scale_width); + int height = NUM2INT(rb_scale_height); +#if !RBGDK_PIXBUF_CHECK_VERSION(2,8,0) + if (width < 0 || height < 0) + rb_warning("For scaling on load, a negative value for width or height are not supported in GTK+ < 2.8.0"); +#endif + buf = gdk_pixbuf_new_from_file_at_scale(RVAL2CSTR(rb_file), + width, height, + NIL_P(rb_preserve_aspect_ratio) ? TRUE : RVAL2CBOOL(rb_preserve_aspect_ratio), + error); +#else + rb_warning("Scaling on load not supported in GTK+ < 2.6.0"); + buf = gdk_pixbuf_new_from_file(RVAL2CSTR(rb_file), error); +#endif + } else { + buf = gdk_pixbuf_new_from_file(RVAL2CSTR(rb_file), error); + } + } else { + buf = gdk_pixbuf_new(NIL_P(rb_colorspace) ? GDK_COLORSPACE_RGB : RVAL2GDKCOLORSPACE(rb_colorspace), + RVAL2CBOOL(rb_has_alpha), + NIL_P(rb_bits_per_sample) ? 8 : NUM2INT(rb_bits_per_sample), + NUM2INT(rb_width), + NUM2INT(rb_height)); + if (buf == NULL) + NOMEM_ERROR(error); + } + + return buf; +} + +/* TODO: make deprecated */ +static GdkPixbuf * +pixbuf_initialize(VALUE self, int argc, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5, VALUE arg6, VALUE arg7, GError **error) +{ + GdkPixbuf* buf; + + if (argc == 7){ + buf = gdk_pixbuf_new_from_data((const guchar*)RVAL2CSTR(arg1), + RVAL2GDKCOLORSPACE(arg2), + RVAL2CBOOL(arg3), NUM2INT(arg4), + NUM2INT(arg5), NUM2INT(arg6), + NUM2INT(arg7), NULL, NULL); + if (buf == NULL) NOMEM_ERROR(error); + // Save a reference to the string because the pixbuf doesn't copy it. + G_RELATIVE(self, arg1); + } else if (argc == 5){ + if (rb_obj_is_kind_of(arg1, GTYPE2CLASS(GDK_TYPE_PIXBUF))){ + buf = gdk_pixbuf_new_subpixbuf(_SELF(arg1), + NUM2INT(arg2), NUM2INT(arg3), + NUM2INT(arg4), NUM2INT(arg5)); + if (buf == NULL) NOMEM_ERROR(error); + } else if (rb_obj_is_kind_of(arg1, GTYPE2CLASS(GDK_TYPE_COLORSPACE))){ + buf = gdk_pixbuf_new(RVAL2GDKCOLORSPACE(arg1), + RVAL2CBOOL(arg2), NUM2INT(arg3), + NUM2INT(arg4), NUM2INT(arg5)); + if (buf == NULL) NOMEM_ERROR(error); + } else { + rb_raise(rb_eArgError, "Wrong type of 1st argument or wrong number of arguments"); + } + } else if (argc == 4) { +#if RBGDK_PIXBUF_CHECK_VERSION(2,6,0) + int width = NUM2INT(arg2); + int height = NUM2INT(arg3); +#if ! RBGDK_PIXBUF_CHECK_VERSION(2,8,0) + if (width < 0 || height < 0) + rb_warning("For scaling on load, a negative value for width or height are not supported in GTK+ < 2.8.0"); +#endif + buf = gdk_pixbuf_new_from_file_at_scale(RVAL2CSTR(arg1), + width, height, + RVAL2CBOOL(arg4), error); +#else + rb_warning("Scaling on load not supported in GTK+ < 2.6.0"); + buf = gdk_pixbuf_new_from_file(RVAL2CSTR(arg1), error); +#endif + } else if (argc == 3) { +#if RBGDK_PIXBUF_CHECK_VERSION(2,4,0) + buf = gdk_pixbuf_new_from_file_at_size(RVAL2CSTR(arg1), + NUM2INT(arg2), NUM2INT(arg3), error); +#else + rb_warning("Sizing on load not supported in GTK+ < 2.4.0"); + buf = gdk_pixbuf_new_from_file(RVAL2CSTR(arg1), error); +#endif + } else if (argc == 2) { + /* TODO: Is this really up to the caller to decide? */ + gboolean copy_pixels = RVAL2CBOOL(arg2); + long n; + guint8 *data = RVAL2GUINT8S(arg1, n); + buf = gdk_pixbuf_new_from_inline(n, data, copy_pixels, error); + /* need to manage the returned value */ + rb_ivar_set(self, id_pixdata, Data_Wrap_Struct(rb_cData, NULL, g_free, data)); + } else if (argc == 1){ + if (TYPE(arg1) == T_STRING) { + buf = gdk_pixbuf_new_from_file(RVAL2CSTR(arg1), error); + } else if (TYPE(arg1) == T_ARRAY) { + const gchar **data = RVAL2STRV(arg1); + buf = gdk_pixbuf_new_from_xpm_data(data); + g_free(data); + if (buf == NULL) + NOMEM_ERROR(error); + } else if (TYPE(arg1) == T_HASH) { + buf = pixbuf_initialize_by_hash(self, arg1, error); + } else { + rb_raise(rb_eArgError, "Wrong type of 1st argument or wrong number of arguments"); + } + } else { + rb_raise(rb_eArgError, "Wrong number of arguments"); + } + + return buf; +} + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE arg1, arg2, arg3, arg4, arg5, arg6, arg7; + GdkPixbuf *buf; + GError *error = NULL; + + rb_scan_args(argc, argv, "16", &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7); + buf = pixbuf_initialize(self, argc, arg1, arg2, arg3, arg4, arg5, arg6, arg7, &error); + if (buf == NULL) { + rb_gc(); + g_error_free(error); + error = NULL; + buf = pixbuf_initialize(self, argc, arg1, arg2, arg3, arg4, arg5, arg6, arg7, &error); + } + if (error || !buf) + RAISE_GERROR(error); + + G_INITIALIZE(self, buf); + return Qnil; +} + +static VALUE +rg_dup(VALUE self) +{ + VALUE ret; + GdkPixbuf* dest = gdk_pixbuf_copy(_SELF(self)); + if (dest == NULL) + return Qnil; + ret = GOBJ2RVAL(dest); + g_object_unref(dest); + return ret; +} + +#if RBGDK_PIXBUF_CHECK_VERSION(2,4,0) +static VALUE +rg_s_get_file_info(G_GNUC_UNUSED VALUE self, VALUE filename) +{ + gint width, height; + + GdkPixbufFormat* format = gdk_pixbuf_get_file_info(RVAL2CSTR(filename), + &width, &height); + return format ? rb_ary_new3(3, GDKPIXBUFFORMAT2RVAL(format), INT2NUM(width), INT2NUM(height)) : Qnil; +} + +#endif + +static VALUE +save_to(VALUE self, const gchar *filename, const gchar *type, VALUE options) +{ + VALUE result = self; + GError *error = NULL; + gchar **keys = NULL; + gchar **values = NULL; + + if (!NIL_P(options)) { + VALUE ary, key, value; + ID to_s; + gint len, i; + + Check_Type(options, T_HASH); + to_s = rb_intern("to_s"); + + ary = rb_funcall(options, rb_intern("to_a"), 0); + len = RARRAY_LEN(ary); + keys = ALLOCA_N(gchar *, len + 1); + values = ALLOCA_N(gchar *, len + 1); + for (i = 0; i < len; i++) { + key = RARRAY_PTR(RARRAY_PTR(ary)[i])[0]; + if (SYMBOL_P(key)) { + const char *const_key; + const_key = rb_id2name(SYM2ID(key)); + keys[i] = (gchar *)const_key; + } else { + keys[i] = (gchar *)RVAL2CSTR(key); + } + value = rb_funcall(RARRAY_PTR(RARRAY_PTR(ary)[i])[1], to_s, 0); + values[i] = (gchar *)RVAL2CSTR(value); + } + keys[len] = NULL; + values[len] = NULL; + } + + if (filename) { + gdk_pixbuf_savev(_SELF(self), filename, type, keys, values, &error); + } +#if RBGDK_PIXBUF_CHECK_VERSION(2,4,0) + else { + gchar *buffer; + gsize buffer_size; + if (gdk_pixbuf_save_to_bufferv(_SELF(self), &buffer, &buffer_size, + type, keys, values, &error)) + result = rb_str_new(buffer, buffer_size); + } +#endif + + if (error) + RAISE_GERROR(error); + + return result; +} + +/****************************************************/ +/* File saving */ +static VALUE +rg_save(int argc, VALUE *argv, VALUE self) +{ + VALUE filename, type, options; + + rb_scan_args(argc, argv, "21", &filename, &type, &options); + + return save_to(self, RVAL2CSTR(filename), RVAL2CSTR(type), options); +} + +#if RBGDK_PIXBUF_CHECK_VERSION(2,4,0) +/* XXX +gboolean gdk_pixbuf_save_to_callbackv (GdkPixbuf *pixbuf, + GdkPixbufSaveFunc save_func, + gpointer user_data, + const char *type, + char **option_keys, + char **option_values, + GError **error); +*/ + +static VALUE +rg_save_to_buffer(int argc, VALUE *argv, VALUE self) +{ + VALUE type, options; + + rb_scan_args(argc, argv, "11", &type, &options); + + return save_to(self, NULL, RVAL2CSTR(type), options); +} +#endif + +/****************************************************/ +/* Scaling */ +static VALUE +rg_scale(int argc, VALUE *argv, VALUE self) +{ + GdkPixbuf* dest; + VALUE dest_width, dest_height, interp_type, ret; + GdkInterpType type = GDK_INTERP_BILINEAR; + + rb_scan_args(argc, argv, "21", &dest_width, &dest_height, + &interp_type); + + if (!NIL_P(interp_type)) + type = RVAL2GDKINTERPTYPE(interp_type); + + dest = gdk_pixbuf_scale_simple(_SELF(self), + NUM2INT(dest_width), + NUM2INT(dest_height), + type); + if (dest == NULL) + return Qnil; + + ret = GOBJ2RVAL(dest); + g_object_unref(dest); + return ret; +} + +static VALUE +rg_scale_bang(int argc, VALUE *argv, VALUE self) +{ + GdkInterpType type = GDK_INTERP_BILINEAR; + + VALUE src, src_x, src_y, src_width, src_height; + VALUE offset_x, offset_y, scale_x, scale_y, interp_type; + + rb_scan_args(argc, argv, "91", &src, &src_x, &src_y, + &src_width, &src_height, &offset_x, &offset_y, + &scale_x, &scale_y, &interp_type); + + if (!NIL_P(interp_type)) + type = RVAL2GDKINTERPTYPE(interp_type); + + gdk_pixbuf_scale(_SELF(src), _SELF(self), + NUM2INT(src_x), NUM2INT(src_y), + NUM2INT(src_width), NUM2INT(src_height), + NUM2DBL(offset_x), NUM2DBL(offset_y), + NUM2DBL(scale_x), NUM2DBL(scale_y), type); + return self; +} + +static VALUE +rg_composite(VALUE self, VALUE dest_width, VALUE dest_height, VALUE interp_type, VALUE overall_alpha, VALUE check_size, VALUE color1, VALUE color2) +{ + GdkPixbuf* dest; + VALUE ret; + GdkInterpType type = GDK_INTERP_BILINEAR; + + if (!NIL_P(interp_type)) + type = RVAL2GDKINTERPTYPE(interp_type); + + dest = gdk_pixbuf_composite_color_simple( + _SELF(self), NUM2INT(dest_width), NUM2INT(dest_height), + type, NUM2INT(overall_alpha), NUM2INT(check_size), + NUM2UINT(color1), NUM2UINT(color2)); + + if (dest == NULL) + return Qnil; + + ret = GOBJ2RVAL(dest); + g_object_unref(dest); + return ret; +} + +static VALUE +rg_composite_bang(int argc, VALUE *argv, VALUE self) +{ + VALUE ret; + VALUE args[16]; + GdkInterpType interp_type = GDK_INTERP_BILINEAR; + + rb_scan_args(argc, argv, "97", + &args[0], &args[1], &args[2], &args[3], &args[4], + &args[5], &args[6], &args[7], &args[8], &args[9], + &args[10], &args[11], &args[12], &args[13], &args[14], + &args[15]); + + switch (argc) { + case 11: + if (!NIL_P(args[9])) + interp_type = RVAL2GDKINTERPTYPE(args[9]); + + gdk_pixbuf_composite(_SELF(args[0]), _SELF(self), + NUM2INT(args[1]), NUM2INT(args[2]), + NUM2INT(args[3]), NUM2INT(args[4]), + NUM2DBL(args[5]), NUM2DBL(args[6]), + NUM2DBL(args[7]), NUM2DBL(args[8]), + interp_type, NUM2INT(args[10])); + ret = self; + break; + case 16: + if (!NIL_P(args[9])) + interp_type = RVAL2GDKINTERPTYPE(args[9]); + + gdk_pixbuf_composite_color(_SELF(args[0]), _SELF(self), + NUM2INT(args[1]), NUM2INT(args[2]), + NUM2INT(args[3]), NUM2INT(args[4]), + NUM2DBL(args[5]), NUM2DBL(args[6]), + NUM2DBL(args[7]), NUM2DBL(args[8]), + interp_type, NUM2INT(args[10]), + NUM2INT(args[11]), NUM2INT(args[12]), + NUM2INT(args[13]), NUM2UINT(args[14]), + NUM2UINT(args[15])); + ret = self; + break; + default: + rb_raise(rb_eArgError, "Wrong number of arguments: %d", argc); + break; + } + return ret; +} + +#if RBGDK_PIXBUF_CHECK_VERSION(2,6,0) +static VALUE +rg_rotate(VALUE self, VALUE angle) +{ + VALUE ret; + GdkPixbuf* dest = gdk_pixbuf_rotate_simple(_SELF(self), RVAL2GDKPIXBUFROTATION(angle)); + if (dest == NULL) + return Qnil; + ret = GOBJ2RVAL(dest); + g_object_unref(dest); + return ret; +} + +static VALUE +rg_flip(VALUE self, VALUE horizontal) +{ + VALUE ret; + GdkPixbuf* dest = gdk_pixbuf_flip(_SELF(self), RVAL2CBOOL(horizontal)); + if (dest == NULL) + return Qnil; + ret = GOBJ2RVAL(dest); + g_object_unref(dest); + return ret; +} +#endif + +static VALUE +rg_add_alpha(VALUE self, VALUE substitute_color, VALUE r, VALUE g, VALUE b) +{ + VALUE ret; + GdkPixbuf* dest = gdk_pixbuf_add_alpha(_SELF(self), + RVAL2CBOOL(substitute_color), + FIX2INT(r), FIX2INT(g), FIX2INT(b)); + if (dest == NULL) + return Qnil; + ret = GOBJ2RVAL(dest); + g_object_unref(dest); + return ret; +} + +static VALUE +rg_copy_area(VALUE self, VALUE src_x, VALUE src_y, VALUE width, VALUE height, VALUE dest, VALUE dest_x, VALUE dest_y) +{ + gdk_pixbuf_copy_area(_SELF(self), NUM2INT(src_x), NUM2INT(src_y), + NUM2INT(width), NUM2INT(height), + _SELF(dest), NUM2INT(dest_x), NUM2INT(dest_y)); + return dest; +} + +static VALUE +rg_saturate_and_pixelate(VALUE self, VALUE staturation, VALUE pixelate) +{ + GdkPixbuf* dest = gdk_pixbuf_copy(_SELF(self)); + gdk_pixbuf_saturate_and_pixelate(_SELF(self), dest, + NUM2DBL(staturation), RVAL2CBOOL(pixelate)); + return GOBJ2RVAL(dest); +} + +static VALUE +rg_fill_bang(VALUE self, VALUE pixel) +{ + gdk_pixbuf_fill(_SELF(self), NUM2UINT(pixel)); + return self; +} + +/* From Module Interface */ +#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0) +static VALUE +rg_s_formats(G_GNUC_UNUSED VALUE self) +{ + return GSLIST2ARY2(gdk_pixbuf_get_formats(), GDK_TYPE_PIXBUF_FORMAT); +} + +#ifdef HAVE_GDK_PIXBUF_SET_OPTION +static VALUE +rg_set_option(VALUE self, VALUE key, VALUE value) +{ + return CBOOL2RVAL(gdk_pixbuf_set_option(_SELF(self), + RVAL2CSTR(key), RVAL2CSTR(value))); +} +#else +static VALUE +rg_set_option(G_GNUC_UNUSED VALUE self, G_GNUC_UNUSED VALUE key, G_GNUC_UNUSED VALUE value) +{ + rb_warning("not supported in this version of GTK+"); + return Qfalse; +} +#endif +#endif + +extern void Init_gdk_pixbuf2(void); + +void +Init_gdk_pixbuf2(void) +{ + VALUE mGdk = rb_define_module("Gdk"); + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_PIXBUF, "Pixbuf", mGdk); + + id_pixdata = rb_intern("pixdata"); + + /* + gdk_rgb_init();*/ /* initialize it anyway */ + + /* + * Initialization and Versions + */ +/* Removed. This crashes Ruby/GTK on Windows + GTK+-2.4.x. + Pointed out by Laurent. +#ifdef HAVE_GDK_PIXBUF_VERSION + rb_define_const(RG_TARGET_NAMESPACE, "VERSION", CSTR2RVAL(gdk_pixbuf_version)); +#endif +*/ + rb_define_const(RG_TARGET_NAMESPACE, "MAJOR", INT2FIX(GDK_PIXBUF_MAJOR)); + rb_define_const(RG_TARGET_NAMESPACE, "MINOR", INT2FIX(GDK_PIXBUF_MINOR)); + rb_define_const(RG_TARGET_NAMESPACE, "MICRO", INT2FIX(GDK_PIXBUF_MICRO)); + + /* + * The GdkPixbuf Structure + */ + G_REPLACE_GET_PROPERTY(RG_TARGET_NAMESPACE, "pixels", get_pixels, 0); + RG_DEF_METHOD_OPERATOR("pixels=", set_pixels, 1); + RG_DEF_METHOD(get_option, 1); + + /* GdkPixbufError */ + G_DEF_ERROR(GDK_PIXBUF_ERROR, "PixbufError", mGdk, rb_eRuntimeError, GDK_TYPE_PIXBUF_ERROR); + + /* GdkColorspace */ + G_DEF_CLASS(GDK_TYPE_COLORSPACE, "ColorSpace", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_COLORSPACE, "GDK_"); + + /* GdkPixbufAlphaMode */ + G_DEF_CLASS(GDK_TYPE_PIXBUF_ALPHA_MODE, "AlphaMode", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_PIXBUF_ALPHA_MODE, "GDK_PIXBUF_"); + + /* + * File Loading, Image Data in Memory + */ + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(dup, 0); +#if RBGDK_PIXBUF_CHECK_VERSION(2,4,0) + RG_DEF_SMETHOD(get_file_info, 1); +#endif + + /* + * File saving + */ + RG_DEF_METHOD(save, -1); +#if RBGDK_PIXBUF_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(save_to_buffer, -1); +#endif + + /* + * Scaling + */ + RG_DEF_METHOD(scale, -1); + RG_DEF_METHOD_BANG(scale, -1); + RG_DEF_METHOD(composite, 7); + RG_DEF_METHOD_BANG(composite, -1); +#if RBGDK_PIXBUF_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(rotate, 1); + RG_DEF_METHOD(flip, 1); +#endif + + /* GdkInterpType */ + G_DEF_CLASS(GDK_TYPE_INTERP_TYPE, "InterpType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_INTERP_TYPE, "GDK_"); + +#if RBGDK_PIXBUF_CHECK_VERSION(2,6,0) + /* GdkPixbufRotation */ + G_DEF_CLASS(GDK_TYPE_PIXBUF_ROTATION, "GdkPixbufRotation", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_PIXBUF_ROTATION, "GDK_PIXBUF_"); +#endif + /* + * Utilities + */ + RG_DEF_METHOD(add_alpha, 4); + RG_DEF_METHOD(copy_area, 7); + RG_DEF_METHOD(saturate_and_pixelate, 2); + RG_DEF_METHOD_BANG(fill, 1); + + /* + * Module Interface + */ +#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0) + RG_DEF_SMETHOD(formats, 0); + RG_DEF_METHOD(set_option, 2); +#endif + + Init_gdk_pixbuf_animation(mGdk); + Init_gdk_pixbuf_animation_iter(mGdk); +#if RBGDK_PIXBUF_CHECK_VERSION(2,8,0) + Init_gdk_pixbuf_simpleanim(mGdk); +#endif + Init_gdk_pixdata(mGdk); + Init_gdk_pixbuf_loader(mGdk); + Init_gdk_pixbuf_format(mGdk); +} diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbuf.h b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbuf.h new file mode 100644 index 0000000..8880d67 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbuf.h @@ -0,0 +1,41 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __RBGDK_PIXBUF_H__ +#define __RBGDK_PIXBUF_H__ + +#define GDK_PIXBUF_ENABLE_BACKEND +#include +#include +#include "rbgobject.h" +#include "rbgdk-pixbuf2conversions.h" + +extern GType gdk_pixbuf_format_get_type(void); + +#define RBGDK_PIXBUF_CHECK_VERSION(major,minor,micro) \ + (GDK_PIXBUF_MAJOR > (major) || \ + (GDK_PIXBUF_MAJOR == (major) && GDK_PIXBUF_MINOR > (minor)) || \ + (GDK_PIXBUF_MAJOR == (major) && GDK_PIXBUF_MINOR == (minor) && \ + GDK_PIXBUF_MICRO >= (micro))) + +#define GDK_TYPE_PIXBUF_FORMAT (gdk_pixbuf_format_get_type()) + +#endif /* __RBGDK_PIXBUF_H__ */ diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbuf2conversions.h b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbuf2conversions.h new file mode 100644 index 0000000..872f597 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbuf2conversions.h @@ -0,0 +1,42 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __RBGDK_PIXBUF2CONVERSIONS_H__ +#define __RBGDK_PIXBUF2CONVERSIONS_H__ + +#define RVAL2GDKPIXBUF(o) (GDK_PIXBUF(RVAL2GOBJ(o))) +#define RVAL2GDKPIXBUFANIMATION(o) (GDK_PIXBUF_ANIMATION(RVAL2GOBJ(o))) +#define RVAL2GDKPIXBUFANIMATIONITER(o) (GDK_PIXBUF_ANIMATION_ITER(RVAL2GOBJ(o))) +#define RVAL2GDKPIXBUFLOADER(o) (GDK_PIXBUF_LOADER(RVAL2GOBJ(o))) +#define RVAL2GDKPIXBUFSIMPLEANIM(o) (GDK_PIXBUF_SIMPLE_ANIM(RVAL2GOBJ(o))) + +#define RVAL2GDKPIXBUFFORMAT(o) ((GdkPixbufFormat*)RVAL2BOXED(o, GDK_TYPE_PIXBUF_FORMAT)) +#define GDKPIXBUFFORMAT2RVAL(o) (BOXED2RVAL(o, GDK_TYPE_PIXBUF_FORMAT)) +#define RVAL2GDKPIXDATA(o) ((GdkPixdata*)RVAL2BOXED(o, GDK_TYPE_PIXDATA)) +#define GDKPIXDATA2RVAL(o) (BOXED2RVAL(o, GDK_TYPE_PIXDATA)) + +#define RVAL2GDKCOLORSPACE(o) (RVAL2GENUM(o, GDK_TYPE_COLORSPACE)) +#define GDKCOLORSPACE2RVAL(o) (GENUM2RVAL(o, GDK_TYPE_COLORSPACE)) +#define RVAL2GDKINTERPTYPE(o) (RVAL2GENUM(o, GDK_TYPE_INTERP_TYPE)) +#define GDKINTERPTYPE2RVAL(o) (GENUM2RVAL(o, GDK_TYPE_INTERP_TYPE)) +#define RVAL2GDKPIXBUFROTATION(o) (RVAL2GENUM(o, GDK_TYPE_PIXBUF_ROTATION)) +#define GDKPIXBUFROTATION2RVAL(o) (GENUM2RVAL(o, GDK_TYPE_PIXBUF_ROTATION)) + +#endif /* __RBGDK_PIXBUF2CONVERSIONS_H__ */ diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbuf2private.h b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbuf2private.h new file mode 100644 index 0000000..428ae6e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbuf2private.h @@ -0,0 +1,35 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __RBGDK_PIXBUF2PRIVATE_H__ +#define __RBGDK_PIXBUF2PRIVATE_H__ + +#include "rbgdk-pixbuf.h" + +G_GNUC_INTERNAL void Init_gdk_pixbuf_animation(VALUE mGLib); +G_GNUC_INTERNAL void Init_gdk_pixbuf_animation_iter(VALUE mGLib); +G_GNUC_INTERNAL void Init_gdk_pixbuf_format(VALUE mGLib); +G_GNUC_INTERNAL void Init_gdk_pixbuf_loader(VALUE mGLib); +#if RBGDK_PIXBUF_CHECK_VERSION(2,8,0) +G_GNUC_INTERNAL void Init_gdk_pixbuf_simpleanim(VALUE mGLib); +#endif +G_GNUC_INTERNAL void Init_gdk_pixdata(VALUE mGLib); + +#endif /* __RBGDK_PIXBUF2PRIVATE_H__ */ diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbufanimation.c b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbufanimation.c new file mode 100644 index 0000000..63f2857 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbufanimation.c @@ -0,0 +1,93 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgdk-pixbuf2private.h" + +#define RG_TARGET_NAMESPACE cPixbufAnimation +#define _SELF(s) (RVAL2GDKPIXBUFANIMATION(s)) + +static VALUE +rg_initialize(VALUE self, VALUE filename) +{ + GdkPixbufAnimation* ret; + GError* error = NULL; + + ret = gdk_pixbuf_animation_new_from_file(RVAL2CSTR(filename), &error); + if (ret == NULL) + RAISE_GERROR(error); + + G_INITIALIZE(self, ret); + return Qnil; +} + +static VALUE +rg_width(VALUE self) +{ + return INT2NUM(gdk_pixbuf_animation_get_width(_SELF(self))); +} + +static VALUE +rg_height(VALUE self) +{ + return INT2NUM(gdk_pixbuf_animation_get_height(_SELF(self))); +} + +static VALUE +rg_get_iter(int argc, VALUE *argv, VALUE self) +{ + VALUE start_time_sec, start_time_usec; + GTimeVal start_time; + + rb_scan_args(argc, argv, "02", &start_time_sec, &start_time_usec); + + if (NIL_P(start_time_sec)) + return GOBJ2RVAL(gdk_pixbuf_animation_get_iter(_SELF(self), NULL)); + + start_time.tv_sec = NUM2LONG(start_time_sec); + start_time.tv_usec = NIL_P(start_time_usec) ? 0 : NUM2LONG(start_time_usec); + + return GOBJ2RVAL(gdk_pixbuf_animation_get_iter(_SELF(self), &start_time)); +} + +static VALUE +rg_static_image_p(VALUE self) +{ + return CBOOL2RVAL(gdk_pixbuf_animation_is_static_image(_SELF(self))); +} + +static VALUE +rg_static_image(VALUE self) +{ + return GOBJ2RVAL(gdk_pixbuf_animation_get_static_image(_SELF(self))); +} + +void +Init_gdk_pixbuf_animation(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_PIXBUF_ANIMATION, "PixbufAnimation", mGdk); + + RG_DEF_METHOD(initialize, 1); + RG_DEF_METHOD(width, 0); + RG_DEF_METHOD(height, 0); + RG_DEF_METHOD(get_iter, -1); + RG_DEF_METHOD_P(static_image, 0); + RG_DEF_METHOD(static_image, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbufanimationiter.c b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbufanimationiter.c new file mode 100644 index 0000000..71918d9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbufanimationiter.c @@ -0,0 +1,71 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgdk-pixbuf2private.h" + +#define RG_TARGET_NAMESPACE cPixbufAnimationIter +#define _SELF(i) (RVAL2GDKPIXBUFANIMATIONITER(i)) + +static VALUE +rg_advance(int argc, VALUE *argv, VALUE self) +{ + VALUE current_time_sec, current_time_usec; + GTimeVal current_time; + + rb_scan_args(argc, argv, "02", ¤t_time_sec, ¤t_time_usec); + + if (NIL_P(current_time_sec)) + return CBOOL2RVAL(gdk_pixbuf_animation_iter_advance(_SELF(self), NULL)); + + current_time.tv_sec = NUM2LONG(current_time_sec); + current_time.tv_usec = NIL_P(current_time_usec) ? 0 : NUM2LONG(current_time_usec); + + return CBOOL2RVAL(gdk_pixbuf_animation_iter_advance(_SELF(self), ¤t_time)); +} + +static VALUE +rg_delay_time(VALUE self) +{ + return INT2NUM(gdk_pixbuf_animation_iter_get_delay_time(_SELF(self))); +} + +static VALUE +rg_on_currently_loading_frame_p(VALUE self) +{ + return CBOOL2RVAL(gdk_pixbuf_animation_iter_on_currently_loading_frame(_SELF(self))); +} + +static VALUE +rg_pixbuf(VALUE self) +{ + return GOBJ2RVAL(gdk_pixbuf_animation_iter_get_pixbuf(_SELF(self))); +} + +void +Init_gdk_pixbuf_animation_iter(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_PIXBUF_ANIMATION_ITER, "PixbufAnimationIter", mGdk); + + RG_DEF_METHOD(advance, -1); + RG_DEF_METHOD(delay_time, 0); + RG_DEF_METHOD_P(on_currently_loading_frame, 0); + RG_DEF_METHOD(pixbuf, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbufsimpleanim.c b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbufsimpleanim.c new file mode 100644 index 0000000..0786ba7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixbufsimpleanim.c @@ -0,0 +1,53 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 the ruby-gnome2 project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgdk-pixbuf2private.h" + +#if RBGDK_PIXBUF_CHECK_VERSION(2,8,0) +#define RG_TARGET_NAMESPACE cPixbufSimpleAnim +#define _SELF(s) (RVAL2GDKPIXBUFSIMPLEANIM(s)) + +static VALUE +rg_initialize(VALUE self, VALUE width, VALUE height, VALUE rate) +{ + GdkPixbufSimpleAnim* ret = gdk_pixbuf_simple_anim_new(NUM2INT(width), NUM2INT(height), NUM2DBL(rate)); + G_INITIALIZE(self, ret); + return Qnil; +} + +static VALUE +rg_add_frame(VALUE self, VALUE pixbuf) +{ + gdk_pixbuf_simple_anim_add_frame(_SELF(self), RVAL2GDKPIXBUF(pixbuf)); + return self; +} +#endif + +void +Init_gdk_pixbuf_simpleanim(VALUE mGdk) +{ +#if RBGDK_PIXBUF_CHECK_VERSION(2,8,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_PIXBUF_SIMPLE_ANIM, "PixbufSimpleAnim", mGdk); + + RG_DEF_METHOD(initialize, 3); + RG_DEF_METHOD(add_frame, 1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixdata.c b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixdata.c new file mode 100644 index 0000000..8fd6023 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/ext/gdk_pixbuf2/rbgdk-pixdata.c @@ -0,0 +1,213 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgdk-pixbuf2private.h" + +#define GDK_TYPE_PIXDATA (gdk_pixdata_get_type()) +#define RG_TARGET_NAMESPACE cPixdata +#define _SELF(s) (RVAL2GDKPIXDATA(s)) + +static ID id_pixdata; + +/*****************************************/ +static GdkPixdata * +gdk_pixdata_copy(const GdkPixdata* src) +{ + GdkPixdata* data; + g_return_val_if_fail (src != NULL, NULL); + data = g_new(GdkPixdata, 1); + *data = *src; + return data; +} + +static GType +gdk_pixdata_get_type(void) +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static ("GdkPixdata", + (GBoxedCopyFunc)gdk_pixdata_copy, + (GBoxedFreeFunc)g_free); + return our_type; +} +/*****************************************/ +static VALUE +rg_s_from_pixbuf(G_GNUC_UNUSED VALUE self, VALUE pixbuf, VALUE use_rle) +{ + GdkPixdata pixdata; + gpointer rle_data = gdk_pixdata_from_pixbuf(&pixdata, RVAL2GDKPIXBUF(pixbuf), RVAL2CBOOL(use_rle)); + VALUE ret = GDKPIXDATA2RVAL(&pixdata); + if (use_rle){ + /* need to manage the returned value */ + rb_ivar_set(ret, id_pixdata, Data_Wrap_Struct(rb_cData, NULL, g_free, rle_data)); + } + return ret; +} + +static VALUE +rg_to_pixbuf(VALUE self, VALUE copy_pixels) +{ + GError* error = NULL; + GdkPixbuf* ret = gdk_pixbuf_from_pixdata(_SELF(self), RVAL2CBOOL(copy_pixels), &error); + if (error) + RAISE_GERROR(error); + return GOBJ2RVAL(ret); +} + +static VALUE +rg_serialize(VALUE self) +{ + guint stream_length; + guint i; + guint8* ret = gdk_pixdata_serialize(_SELF(self), &stream_length); + VALUE ary = rb_ary_new2(stream_length); + for (i = 0; i < stream_length; i++) { + rb_ary_push(ary, UINT2NUM(ret[i])); + } + return ary; +} + +static VALUE +rg_s_deserialize(VALUE self, VALUE rbstream) +{ + GdkPixdata pixdata; + long n; + guint8 *stream = RVAL2GUINT8S(rbstream, n); + GError *error = NULL; + + /* TODO: Should we really be creating a new array here? As far as I can + tell, the data is copied. */ + if (!gdk_pixdata_deserialize(&pixdata, n, stream, &error)) + RAISE_GERROR(error); + + /* need to manage the returned value */ + rb_ivar_set(self, id_pixdata, Data_Wrap_Struct(rb_cData, NULL, g_free, stream)); + + return GDKPIXDATA2RVAL(&pixdata); +} + +static VALUE +rg_to_csource(VALUE self, VALUE name, VALUE dump_type) +{ + GString* str = gdk_pixdata_to_csource(_SELF(self), RVAL2CSTR(name), FIX2INT(dump_type)); + VALUE ret = CSTR2RVAL(str->str); + g_string_free(str, TRUE); + return ret; +} + +/* GdkPixdata */ +static VALUE +rg_magic(VALUE self) +{ + return UINT2NUM(_SELF(self)->magic); +} + +static VALUE +rg_length(VALUE self) +{ + gint32 length = _SELF(self)->length; + + if(length > 0) + length -= GDK_PIXDATA_HEADER_LENGTH; + return INT2NUM(length); +} + +static VALUE +rg_pixdata_type(VALUE self) +{ + return UINT2NUM(_SELF(self)->pixdata_type); +} + +static VALUE +rg_rowstride(VALUE self) +{ + return INT2NUM(_SELF(self)->rowstride); +} + +static VALUE +rg_width(VALUE self) +{ + return INT2NUM(_SELF(self)->width); +} + +static VALUE +rg_height(VALUE self) +{ + return INT2NUM(_SELF(self)->height); +} + +static VALUE +rg_pixel_data(VALUE self) +{ + gint i; + guint8* ret = _SELF(self)->pixel_data; + gint32 length = _SELF(self)->length - GDK_PIXDATA_HEADER_LENGTH; + + VALUE ary = rb_ary_new2(length); + for (i = 0; i < length; i++) { + rb_ary_push(ary, UINT2NUM(ret[i])); + } + return ary; +} + +void +Init_gdk_pixdata(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_PIXDATA, "Pixdata", mGdk); + + id_pixdata = rb_intern("pixdata"); + + RG_DEF_SMETHOD(from_pixbuf, 2); + RG_DEF_SMETHOD(deserialize, 1); + RG_DEF_METHOD(to_pixbuf, 1); + RG_DEF_METHOD(serialize, 0); + RG_DEF_METHOD(to_csource, 2); + RG_DEF_METHOD(magic, 0); + RG_DEF_METHOD(length, 0); + RG_DEF_METHOD(pixdata_type, 0); + RG_DEF_METHOD(rowstride, 0); + RG_DEF_METHOD(width, 0); + RG_DEF_METHOD(height, 0); + RG_DEF_METHOD(pixel_data, 0); + + rb_define_const(RG_TARGET_NAMESPACE, "PIXBUF_MAGIC_NUMBER", INT2NUM(GDK_PIXBUF_MAGIC_NUMBER)); + rb_define_const(RG_TARGET_NAMESPACE, "HEADER_LENGTH", INT2NUM(GDK_PIXDATA_HEADER_LENGTH)); + + /* GdkPixdataType */ + rb_define_const(RG_TARGET_NAMESPACE, "COLOR_TYPE_RGB", INT2FIX(GDK_PIXDATA_COLOR_TYPE_RGB)); + rb_define_const(RG_TARGET_NAMESPACE, "COLOR_TYPE_RGBA", INT2FIX(GDK_PIXDATA_COLOR_TYPE_RGBA)); + rb_define_const(RG_TARGET_NAMESPACE, "COLOR_TYPE_MASK", INT2FIX(GDK_PIXDATA_COLOR_TYPE_MASK)); + rb_define_const(RG_TARGET_NAMESPACE, "SAMPLE_WIDTH_8", INT2FIX(GDK_PIXDATA_SAMPLE_WIDTH_8)); + rb_define_const(RG_TARGET_NAMESPACE, "SAMPLE_WIDTH_MASK", INT2FIX(GDK_PIXDATA_SAMPLE_WIDTH_MASK)); + rb_define_const(RG_TARGET_NAMESPACE, "ENCODING_RAW", INT2FIX(GDK_PIXDATA_ENCODING_RAW)); + rb_define_const(RG_TARGET_NAMESPACE, "ENCODING_RLE", INT2FIX(GDK_PIXDATA_ENCODING_RLE)); + rb_define_const(RG_TARGET_NAMESPACE, "ENCODING_MASK", INT2FIX(GDK_PIXDATA_ENCODING_MASK)); + + /* GdkPixdataDumpType */ + rb_define_const(RG_TARGET_NAMESPACE, "DUMP_PIXDATA_STREAM", INT2FIX(GDK_PIXDATA_DUMP_PIXDATA_STREAM)); + rb_define_const(RG_TARGET_NAMESPACE, "DUMP_PIXDATA_STRUCT", INT2FIX(GDK_PIXDATA_DUMP_PIXDATA_STRUCT)); + rb_define_const(RG_TARGET_NAMESPACE, "DUMP_MACROS", INT2FIX(GDK_PIXDATA_DUMP_MACROS)); + rb_define_const(RG_TARGET_NAMESPACE, "DUMP_GTYPES", INT2FIX(GDK_PIXDATA_DUMP_GTYPES)); + rb_define_const(RG_TARGET_NAMESPACE, "DUMP_CTYPES", INT2FIX(GDK_PIXDATA_DUMP_CTYPES)); + rb_define_const(RG_TARGET_NAMESPACE, "DUMP_STATIC", INT2FIX(GDK_PIXDATA_DUMP_STATIC)); + rb_define_const(RG_TARGET_NAMESPACE, "DUMP_CONST", INT2FIX(GDK_PIXDATA_DUMP_CONST)); + rb_define_const(RG_TARGET_NAMESPACE, "DUMP_RLE_DECODER", INT2FIX(GDK_PIXDATA_DUMP_RLE_DECODER)); +} diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/extconf.rb b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/extconf.rb new file mode 100644 index 0000000..37bac48 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/extconf.rb @@ -0,0 +1,49 @@ +#!/usr/bin/env ruby + +require 'pathname' +require 'mkmf' +require 'rbconfig' +require 'fileutils' + +package = "gdk_pixbuf2" + +base_dir = Pathname(__FILE__).dirname.expand_path +ext_dir = base_dir + "ext" + package +mkmf_gnome2_dir = base_dir + 'lib' + +ruby = File.join(RbConfig::CONFIG['bindir'], + RbConfig::CONFIG['ruby_install_name'] + + RbConfig::CONFIG["EXEEXT"]) + +build_dir = Pathname("ext") + package +FileUtils.mkdir_p(build_dir.to_s) unless build_dir.exist? +extconf_rb_path = ext_dir + "extconf.rb" +system(ruby, "-C", build_dir.to_s, extconf_rb_path.to_s, *ARGV) || exit(false) + +create_makefile(package) +FileUtils.mv("Makefile", "Makefile.lib") + +File.open("Makefile", "w") do |makefile| + makefile.puts(<<-EOM) +all: + (cd ext/#{package} && $(MAKE)) + $(MAKE) -f Makefile.lib + +install: + (cd ext/#{package} && $(MAKE) install) + $(MAKE) -f Makefile.lib install + +site-install: + (cd ext/#{package} && $(MAKE) site-install) + $(MAKE) -f Makefile.lib site-install + +clean: + (cd ext/#{package} && $(MAKE) clean) + $(MAKE) -f Makefile.lib clean + +distclean: + (cd ext/#{package} && $(MAKE) distclean) + $(MAKE) -f Makefile.lib distclean + @rm -f Makefile.lib +EOM +end diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/lib/gdk_pixbuf2.rb b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/lib/gdk_pixbuf2.rb new file mode 100644 index 0000000..5ec19c5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/lib/gdk_pixbuf2.rb @@ -0,0 +1,52 @@ +require 'glib2' + +base_dir = Pathname.new(__FILE__).dirname.dirname.expand_path +vendor_dir = base_dir + "vendor" + "local" +vendor_bin_dir = vendor_dir + "bin" +GLib.prepend_dll_path(vendor_bin_dir) +begin + major, minor, _ = RUBY_VERSION.split(/\./) + require "#{major}.#{minor}/gdk_pixbuf2.so" +rescue LoadError + require "gdk_pixbuf2.so" +end + +if vendor_dir.exist? + begin + require "gobject-introspection" + vendor_girepository_dir = vendor_dir + "lib" + "girepository-1.0" + GObjectIntrospection.prepend_typelib_path(vendor_girepository_dir) + rescue LoadError + end +end + +module Gdk + class PixbufLoader + def self.open(type = nil, mime_type = false) + loader = Gdk::PixbufLoader.new(type, mime_type) + if block_given? + begin + yield(loader) + ensure + loader.close + end + end + loader + end + end + class Pixbuf + LOG_DOMAIN = "GdkPixbuf" + + class << self + def cairo_available? + if Gdk.respond_to?(:cairo_available?) + Gdk.cairo_available? + else + false + end + end + end + end +end + +GLib::Log.set_log_domain(Gdk::Pixbuf::LOG_DOMAIN) diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/anim.rb b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/anim.rb new file mode 100644 index 0000000..f6be93d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/anim.rb @@ -0,0 +1,38 @@ +#!/usr/bin/env ruby +=begin + anim.rb - Ruby/GdkPixbuf sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: anim.rb,v 1.5 2006/06/17 14:38:08 mutoh Exp $ +=end + +require 'gtk2' + +w = Gtk::Window.new +w.signal_connect('delete-event') do + Gtk.main_quit +end + +box = Gtk::VBox.new +src = Gdk::PixbufAnimation.new("floppybuddy.gif") +box.pack_start(Gtk::Image.new(src)) +p src.width +p src.height +p src.static_image? + +static_image = src.static_image +box.pack_start(Gtk::Image.new(static_image)) + +iter = src.get_iter +p iter.advance +p iter.delay_time +p iter.on_currently_loading_frame? + +box.pack_start(Gtk::Image.new(iter.pixbuf)) + +w.add(box) +w.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/composite.rb b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/composite.rb new file mode 100644 index 0000000..77b45aa --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/composite.rb @@ -0,0 +1,45 @@ +#!/usr/bin/env ruby +=begin + composite.rb - Ruby/GdkPixbuf sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: composite.rb,v 1.6 2006/06/17 14:38:08 mutoh Exp $ +=end + +require 'gtk2' + +filename = ARGV[0] +unless filename + puts "ruby #{$0} filename" + exit(1) +end + +src = Gdk::Pixbuf.new(filename) + +vbox = Gtk::VBox.new + +dst = src.composite(100, 100, Gdk::Pixbuf::INTERP_HYPER, + 200, 32, 0xFF0000, 0x00FF00) +vbox.pack_start(Gtk::Image.new(dst)) + +dst = Gdk::Pixbuf.new(Gdk::Pixbuf::COLORSPACE_RGB, true, 8, 200, 200) +dst.composite!(src, 0, 0, 200, 200, 0, 0, 1.8, 1.8, + Gdk::Pixbuf::INTERP_HYPER, 200) +vbox.pack_start(Gtk::Image.new(dst)) + +dst = Gdk::Pixbuf.new(Gdk::Pixbuf::COLORSPACE_RGB, true, 8, 200, 200) +dst.composite!(src, 10, 10, 180, 180, 15, 15, 3, 2, + Gdk::Pixbuf::INTERP_BILINEAR, 200, 100, 100, 16, + 0x999999, 0xdddddd) +vbox.pack_start(Gtk::Image.new(dst)) + +window = Gtk::Window.new.add(vbox) +window.signal_connect('delete-event') do + Gtk.main_quit +end + +window.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/flip.rb b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/flip.rb new file mode 100644 index 0000000..2391452 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/flip.rb @@ -0,0 +1,47 @@ +#!/usr/bin/env ruby +=begin + flip.rb - Ruby/GdkPixbuf sample script. + + Copyright (c) 2005,2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: flip.rb,v 1.3 2006/06/17 14:38:08 mutoh Exp $ +=end + +require 'gtk2' + + +filename = ARGV[0] +unless filename + puts "ruby #{$0} filename" + exit(1) +end + +if str = Gtk.check_version(2, 6, 0) + puts "This sample requires GTK+ 2.6.0 or later" + puts str + exit +end + +vbox = Gtk::VBox.new + +src = Gdk::Pixbuf.new(filename) +vbox.add(Gtk::Image.new(src)) + +# Horizontal +dst = src.flip(true) +vbox.add(Gtk::Image.new(dst)) + +# Vertical +dst2 = src.flip(false) +vbox.add(Gtk::Image.new(dst2)) + +window = Gtk::Window.new +window.signal_connect('delete-event') do + Gtk.main_quit +end + +window.add(vbox).show_all + +Gtk.main + diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/floppybuddy.gif b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/floppybuddy.gif new file mode 100644 index 0000000..ac986c8 Binary files /dev/null and b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/floppybuddy.gif differ diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/format.rb b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/format.rb new file mode 100644 index 0000000..5a41141 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/format.rb @@ -0,0 +1,39 @@ +#!/usr/bin/env ruby +=begin + format.rb - Ruby/GdkPixbuf sample script. + + Copyright (c) 2004-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: format.rb,v 1.4 2006/06/17 14:38:08 mutoh Exp $ +=end + +require 'gtk2' + +if str = Gtk.check_version(2, 2, 0) + puts "This sample requires GTK+ 2.2.0 or later" + puts str + exit +end + +filename = ARGV[0] +unless filename + puts "ruby #{$0} filename" + exit(1) +end + +puts fileinfo = Gdk::Pixbuf.get_file_info(filename)[0] +puts "name = #{fileinfo.name}" +puts "description = #{fileinfo.description}" +puts "mime_types = #{fileinfo.mime_types.inspect}" +puts "extensions = #{fileinfo.extensions.inspect}" +puts "writable = #{fileinfo.writable?}" +puts "domain = #{fileinfo.domain}" +puts "signature = #{fileinfo.signature.inspect}" + +if Gtk.check_version?(2, 6, 0) + puts "Since 2.6 --- " + puts "scalable = #{fileinfo.scalable?}" + puts "disabled = #{fileinfo.disabled?}" + puts "license = #{fileinfo.license.inspect}" +end diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/gnome-foot.png b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/gnome-foot.png new file mode 100644 index 0000000..0476658 Binary files /dev/null and b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/gnome-foot.png differ diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/inline.rb b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/inline.rb new file mode 100644 index 0000000..24113a4 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/inline.rb @@ -0,0 +1,37 @@ +=begin + inline.rb - Ruby/GdkPixbuf sample script. + + Copyright (c) 2004-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: inline.rb,v 1.2 2006/06/17 14:38:08 mutoh Exp $ +=end + +require 'gtk2' + +pixbuf = Gdk::Pixbuf.new("gnome-foot.png") + +#pixbuf = Gdk::Pixbuf.new(ARGV[0]) + +# Create Gdk::Pixbuf from pixels(String). +pixbuf2 = Gdk::Pixbuf.new(pixbuf.pixels, Gdk::Pixbuf::COLORSPACE_RGB, + true, pixbuf.bits_per_sample, + pixbuf.width, pixbuf.height, + pixbuf.rowstride) + +# Create Gdk::Pixbuf from an array of numbers +# which created by Gdk::Pixdata#serialize. +pixdata = Gdk::Pixdata.from_pixbuf(pixbuf, false) +data = pixdata.serialize +pixbuf3 = Gdk::Pixbuf.new(data, false) + +# Create Gdk::Pixbuf from Gdk::Pixbuf. +pixbuf4 = Gdk::Pixbuf.new(pixbuf, 10, 10, 20, 20) + +vbox = Gtk::VBox.new +vbox.add(Gtk::Image.new(pixbuf)) +vbox.add(Gtk::Image.new(pixbuf2)) +vbox.add(Gtk::Image.new(pixbuf3)) +vbox.add(Gtk::Image.new(pixbuf4)) +Gtk::Window.new.add(vbox).show_all +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/loader.rb b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/loader.rb new file mode 100644 index 0000000..dcc797b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/loader.rb @@ -0,0 +1,20 @@ +#!/usr/bin/env ruby +=begin + loader.rb - Ruby/GdkPixbuf sample script. + + Copyright (c) 2003,2006: Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: loader.rb,v 1.3 2006/06/17 14:38:08 mutoh Exp $ +=end +require 'gtk2' + +loader = Gdk::PixbufLoader.new +File.open("gnome-foot.png","rb") { |f| + loader.last_write(f.read) +} +pixbuf = loader.pixbuf + +Gtk::Window.new.add(Gtk::Image.new(pixbuf)).show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/pixdata.rb b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/pixdata.rb new file mode 100644 index 0000000..70e26a0 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/pixdata.rb @@ -0,0 +1,39 @@ +=begin + pixdata.rb - Ruby/GdkPixbuf sample script. + + Copyright (c) 2004-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: pixdata.rb,v 1.2 2006/06/17 14:38:08 mutoh Exp $ +=end +require 'gtk2' + +r_xpm = [ + "10 10 3 1", + " c None", + ". c #FE0B0B", + "+ c #FFFFFF", + "+.......++", + "+.. ..+", + "+.. ..+", + "+.. ...+", + "+.......++", + "+.....++++", + "+..++..+++", + "+..++...++", + "+..+++...+", + "+..++++..+"] + +pixbuf = Gdk::Pixbuf.new(r_xpm) +pixdata = Gdk::Pixdata.from_pixbuf(pixbuf, false) + +#Serialize data +p data = pixdata.serialize + +#Deserialize data +pixdata = Gdk::Pixdata.deserialize(data) +pixbuf2 = pixdata.to_pixbuf(false) + +dst = pixbuf2.scale(300, 300, Gdk::Pixbuf::INTERP_HYPER) +Gtk::Window.new.add(Gtk::Image.new(dst)).show_all +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/rotate.rb b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/rotate.rb new file mode 100644 index 0000000..ea131e9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/rotate.rb @@ -0,0 +1,45 @@ +#!/usr/bin/env ruby +=begin + rotate.rb - Ruby/GdkPixbuf sample script. + + Copyright (c) 2005,2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: rotate.rb,v 1.3 2006/06/17 14:38:08 mutoh Exp $ +=end + +require 'gtk2' + + +filename = ARGV[0] +unless filename + puts "ruby #{$0} filename" + exit(1) +end + +if str = Gtk.check_version(2, 6, 0) + puts "This sample requires GTK+ 2.6.0 or later" + puts str + exit +end + +vbox = Gtk::VBox.new + +src = Gdk::Pixbuf.new(filename) +vbox.add(Gtk::Image.new(src)) + +dst = src.rotate(Gdk::Pixbuf::ROTATE_COUNTERCLOCKWISE) +vbox.add(Gtk::Image.new(dst)) + +dst2 = src.rotate(Gdk::Pixbuf::ROTATE_UPSIDEDOWN) +vbox.add(Gtk::Image.new(dst2)) + +window = Gtk::Window.new +window.signal_connect('delete-event') do + Gtk.main_quit +end + +window.add(vbox).show_all + +Gtk.main + diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/save.rb b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/save.rb new file mode 100644 index 0000000..7fd6f5c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/save.rb @@ -0,0 +1,25 @@ +#!/usr/bin/env ruby +=begin + save.rb - Ruby/GdkPixbuf sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: save.rb,v 1.5 2006/06/17 14:38:08 mutoh Exp $ +=end + +require 'gdk_pixbuf2' + +from = ARGV[0] +to = ARGV[1] +if ! from or ! to + puts "ruby #{$0} from_file to_file" + exit(1) +end + +src = Gdk::Pixbuf.new(from) + +dst = src.scale(300, 300, Gdk::Pixbuf::INTERP_HYPER) +# This doesn't work .... +#dst.save(to, "jpeg", {:quality => 100}) +dst.save(to, "png") diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/scale.rb b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/scale.rb new file mode 100644 index 0000000..4200ec7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/scale.rb @@ -0,0 +1,45 @@ +#!/usr/bin/env ruby +=begin + scale.rb - Ruby/GdkPixbuf sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: scale.rb,v 1.10 2006/06/17 14:38:08 mutoh Exp $ +=end + +require 'gtk2' + +filename = ARGV[0] +unless filename + puts "ruby #{$0} filename" + exit(1) +end + +vbox = Gtk::VBox.new + +src = Gdk::Pixbuf.new(filename) +vbox.add(Gtk::Image.new(src)) + +dst = src.scale(200, 200, Gdk::Pixbuf::INTERP_NEAREST) +dst.scale!(src, 60, 60, 90, 90, -50, 50, 6, 3) +vbox.add(Gtk::Image.new(dst)) + +dst2 = Gdk::Pixbuf.new(Gdk::Pixbuf::COLORSPACE_RGB, true, 8, 200, 200) +dst2.scale!(src, 0, 0, 100, 100, 0, 0, 1.5, 1.5) + +vbox.add(Gtk::Image.new(dst2)) + +dst3 = Gdk::Pixbuf.new(Gdk::Pixbuf::COLORSPACE_RGB, true, 8, 200, 200) +dst3.scale!(src, 0, 0, 200, 200, 0, 0, 5, 3, Gdk::Pixbuf::INTERP_HYPER) +vbox.add(Gtk::Image.new(dst3)) + +window = Gtk::Window.new +window.signal_connect('delete-event') do + Gtk.main_quit +end + +window.add(vbox).show_all + +Gtk.main + diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/simpleanim.rb b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/simpleanim.rb new file mode 100644 index 0000000..3f86911 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/simpleanim.rb @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby +=begin + simpleanim.rb - Ruby/GdkPixbuf sample script for Gdk::PixbufSimpleAnim. + + Inspired by http://mail.gnome.org/archives/gtk-perl-list/2005-September/msg00110.html + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: simpleanim.rb,v 1.2 2006/06/17 14:38:08 mutoh Exp $ +=end + +require 'gtk2' + +$stdout.sync = true + +simple_anim = Gdk::PixbufSimpleAnim.new(64, 64, 24) +store_pixels = [] + +print 'generating frames' +for red in 0 .. 126 + store_pixels << pixels = ([ 4*(63-red).abs, 0, 0 ] * (64*64)).pack('C*') + pixbuf = Gdk::Pixbuf.new(pixels, Gdk::Pixbuf::COLORSPACE_RGB, false, 8, 64, 64, 64*3) + simple_anim.add_frame(pixbuf) + print '.' +end +puts 'done' + +window = Gtk::Window.new +image = Gtk::Image.new(simple_anim) +window.add(image) +window.show_all +window.signal_connect('destroy') { Gtk.main_quit } +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/utils.rb b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/utils.rb new file mode 100644 index 0000000..4237740 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/utils.rb @@ -0,0 +1,44 @@ +#!/usr/bin/env ruby +=begin + utils.rb - Ruby/GdkPixbuf sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: utils.rb,v 1.4 2006/06/17 14:38:08 mutoh Exp $ +=end + +require 'gtk2' + +filename = ARGV[0] +unless filename + puts "ruby #{$0} filename" + exit(1) +end + +src = Gdk::Pixbuf.new(filename) + +vbox = Gtk::VBox.new + +dst = src.add_alpha(true, 0, 0, 0) +vbox.pack_start(Gtk::Image.new(dst)) + +dst = Gdk::Pixbuf.new(Gdk::Pixbuf::COLORSPACE_RGB, true, 8, + src.width + 20, src.height + 30) +src.copy_area(0, 0, src.width / 2, src.height / 2, dst, 10, 20) +vbox.pack_start(Gtk::Image.new(dst)) + +dst = src.saturate_and_pixelate(0.3, true) +vbox.pack_start(Gtk::Image.new(dst)) + +dst = src.fill!(0xff000099) #RGBA +vbox.pack_start(Gtk::Image.new(dst)) + +w = Gtk::Window.new.add(vbox) +w.signal_connect('delete-event') do + Gtk.main_quit +end + +w.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/xpm.rb b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/xpm.rb new file mode 100644 index 0000000..019db18 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gdk_pixbuf2/sample/xpm.rb @@ -0,0 +1,40 @@ +#!/usr/bin/env ruby +=begin + xpm.rb - Ruby/GdkPixbuf sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: xpm.rb,v 1.5 2006/06/17 14:38:08 mutoh Exp $ +=end + +require 'gtk2' + +r_xpm = [ + "10 10 3 1", + " c None", + ". c #FE0B0B", + "+ c #FFFFFF", + "+.......++", + "+.. ..+", + "+.. ..+", + "+.. ...+", + "+.......++", + "+.....++++", + "+..++..+++", + "+..++...++", + "+..+++...+", + "+..++++..+"] + +w = Gtk::Window.new +w.signal_connect('delete-event') do + Gtk.main_quit +end + +src = Gdk::Pixbuf.new(r_xpm) +dst = src.scale(300, 300, Gdk::Pixbuf::INTERP_HYPER) + +w.add(Gtk::Image.new(dst)) +w.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gio2/README b/lib/ruby-gtk2-2.0.2/gio2/README new file mode 100644 index 0000000..a477296 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/README @@ -0,0 +1,34 @@ +Ruby/GIO2 +========= + + +Ruby/GIO2 is a Ruby binding of gio-2.0.x. + +Requirements +------------ + + Ruby: http://www.ruby-lang.org/ + GIO: http://library.gnome.org/devel/gio/stable + +Install +------- + + 0. install Ruby and GLib. + 1. ruby extconf.rb + 2. make + 3. su + 4. make install + +Copying +------- + + Copyright (c) 2008-2010 Ruby-GNOME2 Project Team + + This program is free software. + You can distribute/modify this program under the terms of + the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. + +Project Website +--------------- + + http://ruby-gnome2.sourceforge.jp/ diff --git a/lib/ruby-gtk2-2.0.2/gio2/Rakefile b/lib/ruby-gtk2-2.0.2/gio2/Rakefile new file mode 100644 index 0000000..943b7a2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/Rakefile @@ -0,0 +1,14 @@ +# -*- ruby -*- + +$LOAD_PATH.unshift("./../glib2/lib") +require 'gnome2-raketask' + +package = GNOME2Package.new do |_package| + _package.summary = "Ruby/GIO2 is a Ruby binding of gio-2.x." + _package.description = "Ruby/GIO2 is a Ruby binding of gio-2.x." + _package.dependency.gem.runtime = ["glib2"] + _package.win32.packages = [] + _package.win32.dependencies = [] +end +package.define_tasks + diff --git a/lib/ruby-gtk2-2.0.2/gio2/TODO b/lib/ruby-gtk2-2.0.2/gio2/TODO new file mode 100644 index 0000000..6c30707 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/TODO @@ -0,0 +1,27 @@ +Unimplementable? +---------------- + +GIOExtension + +Other +----- + +When we use GOBJ2RVAL on properties of objects, should we call G_CHILD_ADD? + +g_unix_socket_address_new_abstract is deprecated + +Need to document GLib::Socket + +Glib::FileAttribute should be an object so that we can use | on them + +GLib::InputStream#read_all can read bytes /and/ return error at the same time + +GLib::OutputStream#write_all can write bytes /and/ return error at the same +time + +GConverterFlags + +Remove implementation of methods that only fetch or set properties (and thus +are automatically generated anyway) + +Update to 2.26 diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/depend b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/depend new file mode 100644 index 0000000..1a50898 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/depend @@ -0,0 +1,11 @@ +install-so: install-headers +install-headers: + $(INSTALL_DATA) $(srcdir)/rbgio2.h $(RUBYARCHDIR) + $(INSTALL_DATA) $(srcdir)/rbgio2conversions.h $(RUBYARCHDIR) + +install: install-pc +install-pc: + if test -n "$(pkgconfigdir)"; then \ + $(MAKEDIRS) $(pkgconfigdir); \ + $(INSTALL_DATA) ruby-gio2.pc $(pkgconfigdir); \ + fi diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/extconf.rb b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/extconf.rb new file mode 100644 index 0000000..83257ac --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/extconf.rb @@ -0,0 +1,67 @@ +=begin +extconf.rb for Ruby/GIO extention library +=end + +require 'pathname' + +base_dir = Pathname(__FILE__).dirname.parent.parent.expand_path +top_dir = base_dir.parent.expand_path +top_build_dir = Pathname(".").parent.parent.parent.expand_path + +mkmf_gnome2_dir = top_dir + "glib2" + 'lib' +version_suffix = "" +unless mkmf_gnome2_dir.exist? + if /(-\d+\.\d+\.\d+)(?:\.\d+)?\z/ =~ base_dir.basename.to_s + version_suffix = $1 + mkmf_gnome2_dir = top_dir + "glib2#{version_suffix}" + 'lib' + end +end + +$LOAD_PATH.unshift(mkmf_gnome2_dir.to_s) + +module_name = "gio2" +package_id = "gio-2.0" + +begin + require 'mkmf-gnome2' +rescue LoadError + require 'rubygems' + gem 'glib2' + require 'mkmf-gnome2' +end + +ruby_header = 'ruby.h' +have_func 'rb_exec_recursive', ruby_header +have_func 'rb_errinfo', ruby_header + +["glib2"].each do |package| + directory = "#{package}#{version_suffix}" + build_dir = "#{directory}/tmp/#{RUBY_PLATFORM}/#{package}/#{RUBY_VERSION}" + add_depend_package(package, "#{directory}/ext/#{package}", + top_dir.to_s, + :top_build_dir => top_build_dir.to_s, + :target_build_dir => build_dir) +end + +win32 = setup_win32(module_name, base_dir) + +defines = '-DRUBY_GIO2_COMPILATION' + +PKGConfig.have_package(package_id) or exit 1 +unless win32 + PKGConfig.have_package('gio-unix-2.0') and defines += ' -DHAVE_GIO_UNIX' +end +PKGConfig.have_package('gobject-2.0') or exit 1 + +create_pkg_config_file("Ruby/GIO2", package_id) + +$defs << defines +create_makefile(module_name) + +pkg_config_dir = with_config("pkg-config-dir") +if pkg_config_dir.is_a?(String) + File.open("Makefile", "ab") do |makefile| + makefile.puts + makefile.puts("pkgconfigdir=#{pkg_config_dir}") + end +end diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/gio2.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/gio2.c new file mode 100644 index 0000000..8f13891 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/gio2.c @@ -0,0 +1,31 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +void Init_gio2(void); + +void +Init_gio2(void) +{ + Init_util(); + Init_gio(); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/gio2.def b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/gio2.def new file mode 100644 index 0000000..52a12d1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/gio2.def @@ -0,0 +1,2 @@ +EXPORTS + Init_gio2 diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/gio2.h b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/gio2.h new file mode 100644 index 0000000..35e7c9c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/gio2.h @@ -0,0 +1,30 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __GIO2_H__ +#define __GIO2_H__ + +#ifdef __GNUC__ +#warning " has been deprecated. Use instead." +#endif + +#include "rbgio2.h" + +#endif /* __GIO2_H__ */ diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgio.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgio.c new file mode 100644 index 0000000..ab595ce --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgio.c @@ -0,0 +1,133 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mGio + +static VALUE +rg_s_has_unix_p(G_GNUC_UNUSED VALUE self) +{ +#ifdef HAVE_GIO_UNIX + return Qtrue; +#else + return Qfalse; +#endif +} + +void +Init_gio(void) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module("Gio"); + G_DEF_CLASS(G_TYPE_FILESYSTEM_PREVIEW_TYPE, "FilesystemPreviewType", RG_TARGET_NAMESPACE); + G_DEF_CLASS(G_TYPE_DATA_STREAM_BYTE_ORDER, "DataStreamByteOrder", RG_TARGET_NAMESPACE); + G_DEF_CLASS(G_TYPE_DATA_STREAM_NEWLINE_TYPE, "DataStreamNewlineType", RG_TARGET_NAMESPACE); + G_DEF_CLASS(G_TYPE_ASK_PASSWORD_FLAGS, "AskPasswordFlags", RG_TARGET_NAMESPACE); + G_DEF_CLASS(G_TYPE_PASSWORD_SAVE, "PasswordSave", RG_TARGET_NAMESPACE); + + RG_DEF_SMETHOD_P(has_unix, 0); + + Init_gappinfo(RG_TARGET_NAMESPACE); + Init_gapplaunchcontext(RG_TARGET_NAMESPACE); + Init_gasyncinitable(RG_TARGET_NAMESPACE); + Init_gasyncresult(RG_TARGET_NAMESPACE); + Init_gbufferedinputstream(RG_TARGET_NAMESPACE); + Init_gbufferedoutputstream(RG_TARGET_NAMESPACE); + Init_gcancellable(RG_TARGET_NAMESPACE); + Init_gcharsetconverter(RG_TARGET_NAMESPACE); + Init_gcontenttype(RG_TARGET_NAMESPACE); + Init_gconverter(RG_TARGET_NAMESPACE); + Init_gconverterinputstream(RG_TARGET_NAMESPACE); + Init_gconverteroutputstream(RG_TARGET_NAMESPACE); + Init_gdatainputstream(RG_TARGET_NAMESPACE); + Init_gdesktopappinfo(RG_TARGET_NAMESPACE); + Init_gdataoutputstream(RG_TARGET_NAMESPACE); + Init_gdrive(RG_TARGET_NAMESPACE); + Init_gemblem(RG_TARGET_NAMESPACE); + Init_gemblemedicon(RG_TARGET_NAMESPACE); + Init_gfile(RG_TARGET_NAMESPACE); + Init_gfileattribute(RG_TARGET_NAMESPACE); + Init_gfileattributeinfo(RG_TARGET_NAMESPACE); + Init_gfileattributematcher(RG_TARGET_NAMESPACE); + Init_gfiledescriptorbased(RG_TARGET_NAMESPACE); + Init_gfileenumerator(RG_TARGET_NAMESPACE); + Init_gfileicon(RG_TARGET_NAMESPACE); + Init_gfileinfo(RG_TARGET_NAMESPACE); + Init_gfileinputstream(RG_TARGET_NAMESPACE); + Init_gfileiostream(RG_TARGET_NAMESPACE); + Init_gfilemonitor(RG_TARGET_NAMESPACE); + Init_gfilenamecompleter(RG_TARGET_NAMESPACE); + Init_gfileoutputstream(RG_TARGET_NAMESPACE); + Init_gfilterinputstream(RG_TARGET_NAMESPACE); + Init_gfilteroutputstream(RG_TARGET_NAMESPACE); + Init_gicon(RG_TARGET_NAMESPACE); + Init_ginetaddress(RG_TARGET_NAMESPACE); + Init_ginetsocketaddress(RG_TARGET_NAMESPACE); + Init_ginitable(RG_TARGET_NAMESPACE); + Init_ginputstream(RG_TARGET_NAMESPACE); + Init_gioerror(RG_TARGET_NAMESPACE); + Init_giomodule(RG_TARGET_NAMESPACE); + Init_giomodules(RG_TARGET_NAMESPACE); + Init_gioscheduler(RG_TARGET_NAMESPACE); + Init_gioschedulerjob(RG_TARGET_NAMESPACE); + Init_giostream(RG_TARGET_NAMESPACE); + Init_gloadableicon(RG_TARGET_NAMESPACE); + Init_gmemoryinputstream(RG_TARGET_NAMESPACE); + Init_gmemoryoutputstream(RG_TARGET_NAMESPACE); + Init_gmount(RG_TARGET_NAMESPACE); + Init_gmountoperation(RG_TARGET_NAMESPACE); + Init_gnetworkaddress(RG_TARGET_NAMESPACE); + Init_gnetworkservice(RG_TARGET_NAMESPACE); + Init_goutputstream(RG_TARGET_NAMESPACE); + Init_gresolver(RG_TARGET_NAMESPACE); + Init_gseekable(RG_TARGET_NAMESPACE); + Init_gsimpleasyncresult(RG_TARGET_NAMESPACE); + Init_gsocket(RG_TARGET_NAMESPACE); + Init_gsocketaddress(RG_TARGET_NAMESPACE); + Init_gsocketclient(RG_TARGET_NAMESPACE); + Init_gsocketconnectable(RG_TARGET_NAMESPACE); + Init_gsocketaddressenumerator(RG_TARGET_NAMESPACE); + Init_gsocketconnection(RG_TARGET_NAMESPACE); + Init_gsocketconnectionfactory(RG_TARGET_NAMESPACE); + Init_gsocketcontrolmessage(RG_TARGET_NAMESPACE); + Init_gsocketlistener(RG_TARGET_NAMESPACE); + Init_gsocketservice(RG_TARGET_NAMESPACE); + Init_gsrvtarget(RG_TARGET_NAMESPACE); + Init_gtcpconnection(RG_TARGET_NAMESPACE); + Init_gthemedicon(RG_TARGET_NAMESPACE); + Init_gthreadedsocketservice(RG_TARGET_NAMESPACE); + Init_gtlscertificate(RG_TARGET_NAMESPACE); + Init_gunixconnection(RG_TARGET_NAMESPACE); + Init_gunixfdlist(RG_TARGET_NAMESPACE); + Init_gunixfdmessage(RG_TARGET_NAMESPACE); + Init_gunixinputstream(RG_TARGET_NAMESPACE); + Init_gunixmount(RG_TARGET_NAMESPACE); + Init_gunixmounts(RG_TARGET_NAMESPACE); + Init_gunixmountpoint(RG_TARGET_NAMESPACE); + Init_gunixmountpoints(RG_TARGET_NAMESPACE); + Init_gunixmountmonitor(RG_TARGET_NAMESPACE); + Init_gunixoutputstream(RG_TARGET_NAMESPACE); + Init_gunixsocketaddress(RG_TARGET_NAMESPACE); + Init_gvfs(RG_TARGET_NAMESPACE); + Init_gvolume(RG_TARGET_NAMESPACE); + Init_gvolumemonitor(RG_TARGET_NAMESPACE); + Init_gzlibcompressor(RG_TARGET_NAMESPACE); + Init_gzlibdecompressor(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgio2.h b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgio2.h new file mode 100644 index 0000000..1c31f2c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgio2.h @@ -0,0 +1,158 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __RBGIO2_H__ +#define __RBGIO2_H__ + +#include + +#include "rbgio2conversions.h" + +G_BEGIN_DECLS + +/* Block Handling */ +#define SAVE_BLOCK(block) G_STMT_START { \ + if (!NIL_P(block)) \ + G_CHILD_ADD(mGLib, (block)); \ +} G_STMT_END + +#define USE_BLOCK(data) \ + rbgio_child_remove_and_return(mGLib, (VALUE)(data)) + +#define USE_BLOCK_AND_SAVE(data) ((VALUE)data) + +#if !GLIB_CHECK_VERSION(2, 34, 0) +#define G_TYPE_FILE_ATTRIBUTE_MATCHER (g_file_attribute_matcher_get_type()) +GType g_file_attribute_matcher_get_type(void); + +#define G_TYPE_FILE_ATTRIBUTE_INFO_LIST (g_file_attribute_info_list_get_type()) +GType g_file_attribute_info_list_get_type(void); +#endif + +#define G_TYPE_FILE_ATTRIBUTE_INFO (g_file_attribute_info_get_type()) +GType g_file_attribute_info_get_type(void); + +/* Conversion Macros */ +#define RVAL2TYPE_WITH_DEFAULT(value, type, default_value) \ + (NIL_P(value) ? (default_value) : type(value)) + +#define RVAL2ATTRIBUTESDEFAULT(value) \ + RVAL2TYPE_WITH_DEFAULT((value), RVAL2CSTR, "standard::*") + +#define RVAL2GDRIVESTARTFLAGSDEFAULT(value) \ + RVAL2TYPE_WITH_DEFAULT((value), \ + RVAL2GDRIVESTARTFLAGS, \ + G_DRIVE_START_NONE) + +#define RVAL2GMOUNTMOUNTFLAGSDEFAULT(value) \ + RVAL2TYPE_WITH_DEFAULT((value), \ + RVAL2GMOUNTMOUNTFLAGS, \ + G_MOUNT_MOUNT_NONE) + +#define RVAL2GMOUNTUNMOUNTFLAGSDEFAULT(value) \ + RVAL2TYPE_WITH_DEFAULT((value), \ + RVAL2GMOUNTUNMOUNTFLAGS, \ + G_MOUNT_UNMOUNT_NONE) + +#define RVAL2GSOCKETPROTOCOLDEFAULT(value) \ + RVAL2TYPE_WITH_DEFAULT((value), \ + RVAL2GSOCKETPROTOCOL, \ + G_SOCKET_PROTOCOL_DEFAULT) + +#define GTIMEVAL2RVAL(value) rb_time_new((value)->tv_sec, (value)->tv_usec) + +#define RVAL2GZLIBCOMPRESSORFORMATDEFAULT(value) \ + RVAL2TYPE_WITH_DEFAULT((value), \ + RVAL2GZLIBCOMPRESSORFORMAT, \ + G_ZLIB_COMPRESSOR_FORMAT_ZLIB) + +#define RVAL2IOPRIORITYDEFAULT(value) \ + RVAL2TYPE_WITH_DEFAULT((value), NUM2INT, G_PRIORITY_DEFAULT) + +/* Integer Type Conversion Macros */ +#define FD2RVAL(value) INT2FIX(value) +#define RVAL2FD(value) FIX2INT(value) +#define RVAL2FDS(value, n) RVAL2GINTS(value, n) + +#define GINT2RVAL(value) INT2NUM(value) +#define RVAL2GINT(value) NUM2INT(value) + +#define GINT162RVAL(value) INT2FIX(value) +#define RVAL2GINT16(value) FIX2INT(value) + +#define GINT322RVAL(value) INT2NUM(value) +#define RVAL2GINT32(value) NUM2INT(value) + +#define GINT642RVAL(value) rbglib_int64_to_num(value) +#define RVAL2GINT64(value) rbglib_num_to_int64(value) + +#define GSIZE2RVAL(value) ULONG2NUM(value) +#define RVAL2GSIZE(value) NUM2ULONG(value) + +#define GLONG2RVAL(value) LONG2NUM(value) +#define RVAL2GLONG(value) NUM2LONG(value) + +#define GOFFSET2RVAL(value) rbglib_int64_to_num(value) +#define RVAL2GOFFSET(value) rbglib_num_to_int64(value) + +#define GSSIZE2RVAL(value) LONG2NUM(value) +#define RVAL2GSSIZE(value) NUM2LONG(value) + +/* TODO: Should we be zeroing out bits? */ +#define GUCHAR2RVAL(value) INT2FIX(value) +#define RVAL2GUCHAR(value) FIX2INT(value) + +#define GUINT2RVAL(value) UINT2NUM(value) +#define RVAL2GUINT(value) NUM2UINT(value) + +/* TODO: Should we be zeroing out bits? */ +#define GUINT162RVAL(value) INT2FIX(value) +#define RVAL2GUINT16(value) FIX2INT(value) + +#define GUINT322RVAL(value) UINT2NUM(value) +#define RVAL2GUINT32(value) NUM2UINT(value) + +#define GUINT642RVAL(value) rbglib_uint64_to_num(value) +#define RVAL2GUINT64(value) rbglib_num_to_uint64(value) + +#define GULONG2RVAL(value) ULONG2NUM(value) +#define RVAL2GULONG(value) NUM2ULONG(value) + +VALUE rbgio_define_domain_error(VALUE module, + const char *name, + GQuark domain, + const char *enum_name, + VALUE parent); +VALUE rbgio_define_error(VALUE module, + const char *name, + gint code, + VALUE domain_error); +NORETURN(void rbgio_raise_error(GError *error)); +GObject *rbgio_ginitable_new(GType type, VALUE parameters, VALUE cancellable); +void rbgio_gasyncinitable_new_async(GType type, + VALUE parameters, + VALUE io_priority, + VALUE cancellable, + VALUE block); + +G_END_DECLS + +#endif /* __RBGIO2_H__ */ diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgio2conversions.h b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgio2conversions.h new file mode 100644 index 0000000..5e067ac --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgio2conversions.h @@ -0,0 +1,154 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __RBGIO2CONVERSIONS_H__ +#define __RBGIO2CONVERSIONS_H__ + +#define RVAL2GAPPINFO(o) (G_APP_INFO(RVAL2GOBJ(o))) +#define RVAL2GAPPLAUNCHCONTEXT(o) (G_APP_LAUNCH_CONTEXT(RVAL2GOBJ(o))) +#define RVAL2GASYNCINITABLE(o) (G_ASYNC_INITABLE(RVAL2GOBJ(o))) +#define RVAL2GASYNCRESULT(o) (G_ASYNC_RESULT(RVAL2GOBJ(o))) +#define RVAL2GBUFFEREDINPUTSTREAM(o) (G_BUFFERED_INPUT_STREAM(RVAL2GOBJ(o))) +#define RVAL2GBUFFEREDOUTPUTSTREAM(o) (G_BUFFERED_OUTPUT_STREAM(RVAL2GOBJ(o))) +#define RVAL2GCANCELLABLE(o) (G_CANCELLABLE(RVAL2GOBJ(o))) +#define RVAL2GCHARSETCONVERTER(o) (G_CHARSET_CONVERTER(RVAL2GOBJ(o))) +#define RVAL2GCONVERTER(o) (G_CONVERTER(RVAL2GOBJ(o))) +#define RVAL2GCONVERTERINPUTSTREAM(o) (G_CONVERTER_INPUT_STREAM(RVAL2GOBJ(o))) +#define RVAL2GCONVERTEROUTPUTSTREAM(o) (G_CONVERTER_OUTPUT_STREAM(RVAL2GOBJ(o))) +#define RVAL2GDATAINPUTSTREAM(o) (G_DATA_INPUT_STREAM(RVAL2GOBJ(o))) +#define RVAL2GDATAOUTPUTSTREAM(o) (G_DATA_OUTPUT_STREAM(RVAL2GOBJ(o))) +#define RVAL2GDESKTOPAPPINFO(o) (G_DESKTOP_APP_INFO(RVAL2GOBJ(o))) +#define RVAL2GDRIVE(o) (G_DRIVE(RVAL2GOBJ(o))) +#define RVAL2GEMBLEM(o) (G_EMBLEM(RVAL2GOBJ(o))) +#define RVAL2GEMBLEMEDICON(o) (G_EMBLEMED_ICON(RVAL2GOBJ(o))) +#define RVAL2GFILE(o) (G_FILE(RVAL2GOBJ(o))) +#define RVAL2GFILEDESCRIPTORBASED(o) (G_FILE_DESCRIPTOR_BASED(RVAL2GOBJ(o))) +#define RVAL2GFILEENUMERATOR(o) (G_FILE_ENUMERATOR(RVAL2GOBJ(o))) +#define RVAL2GFILEICON(o) (G_FILE_ICON(RVAL2GOBJ(o))) +#define RVAL2GFILEINFO(o) (G_FILE_INFO(RVAL2GOBJ(o))) +#define RVAL2GFILEINPUTSTREAM(o) (G_FILE_INPUT_STREAM(RVAL2GOBJ(o))) +#define RVAL2GFILEIOSTREAM(o) (G_FILE_IO_STREAM(RVAL2GOBJ(o))) +#define RVAL2GFILEMONITOR(o) (G_FILE_MONITOR(RVAL2GOBJ(o))) +#define RVAL2GFILENAMECOMPLETER(o) (G_FILENAME_COMPLETER(RVAL2GOBJ(o))) +#define RVAL2GFILEOUTPUTSTREAM(o) (G_FILE_OUTPUT_STREAM(RVAL2GOBJ(o))) +#define RVAL2GICON(o) (G_ICON(RVAL2GOBJ(o))) +#define RVAL2GINETADDRESS(o) (G_INET_ADDRESS(RVAL2GOBJ(o))) +#define RVAL2GINITABLE(o) (G_INITABLE(RVAL2GOBJ(o))) +#define RVAL2GINPUTSTREAM(o) (G_INPUT_STREAM(RVAL2GOBJ(o))) +#define RVAL2GIOMODULE(o) (G_IO_MODULE(RVAL2GOBJ(o))) +#define RVAL2GIOSTREAM(o) (G_IO_STREAM(RVAL2GOBJ(o))) +#define RVAL2GLOADABLEICON(o) (G_LOADABLE_ICON(RVAL2GOBJ(o))) +#define RVAL2GMEMORYINPUTSTREAM(o) (G_MEMORY_INPUT_STREAM(RVAL2GOBJ(o))) +#define RVAL2GMOUNT(o) (G_MOUNT(RVAL2GOBJ(o))) +#define RVAL2GMOUNTOPERATION(o) (G_MOUNT_OPERATION(RVAL2GOBJ(o))) +#define RVAL2GNETWORKADDRESS(o) (G_NETWORK_ADDRESS(RVAL2GOBJ(o))) +#define RVAL2GNETWORKSERVICE(o) (G_NETWORK_SERVICE(RVAL2GOBJ(o))) +#define RVAL2GOUTPUTSTREAM(o) (G_OUTPUT_STREAM(RVAL2GOBJ(o))) +#define RVAL2GPERMISSION(o) (G_PERMISSION(RVAL2GOBJ(o))) +#define RVAL2GRESOLVER(o) (G_RESOLVER(RVAL2GOBJ(o))) +#define RVAL2GSEEKABLE(o) (G_SEEKABLE(RVAL2GOBJ(o))) +#define RVAL2GSIMPLEASYNCRESULT(o) (G_SIMPLE_ASYNC_RESULT(RVAL2GOBJ(o))) +#define RVAL2GSOCKET(o) (G_SOCKET(RVAL2GOBJ(o))) +#define RVAL2GSOCKETADDRESS(o) (G_SOCKET_ADDRESS(RVAL2GOBJ(o))) +#define RVAL2GSOCKETADDRESSENUMERATOR(o) (G_SOCKET_ADDRESS_ENUMERATOR(RVAL2GOBJ(o))) +#define RVAL2GSOCKETCLIENT(o) (G_SOCKET_CLIENT(RVAL2GOBJ(o))) +#define RVAL2GSOCKETCONNECTABLE(o) (G_SOCKET_CONNECTABLE(RVAL2GOBJ(o))) +#define RVAL2GSOCKETCONNECTION(o) (G_SOCKET_CONNECTION(RVAL2GOBJ(o))) +#define RVAL2GSOCKETCONTROLMESSAGE(o) (G_SOCKET_CONTROL_MESSAGE(RVAL2GOBJ(o))) +#define RVAL2GSOCKETLISTENER(o) (G_SOCKET_LISTENER(RVAL2GOBJ(o))) +#define RVAL2GSOCKETSERVICE(o) (G_SOCKET_SERVICE(RVAL2GOBJ(o))) +#define RVAL2GTHEMEDICON(o) (G_THEMED_ICON(RVAL2GOBJ(o))) +#define RVAL2GUNIXCONNECTION(o) (G_UNIX_CONNECTION(RVAL2GOBJ(o))) +#define RVAL2GUNIXFDLIST(o) (G_UNIX_FD_LIST(RVAL2GOBJ(o))) +#define RVAL2GUNIXFDMESSAGE(o) (G_UNIX_FD_MESSAGE(RVAL2GOBJ(o))) +#define RVAL2GUNIXINPUTSTREAM(o) (G_UNIX_INPUT_STREAM(RVAL2GOBJ(o))) +#define RVAL2GUNIXMOUNTMONITOR(o) (G_UNIX_MOUNT_MONITOR(RVAL2GOBJ(o))) +#define RVAL2GUNIXOUTPUTSTREAM(o) (G_UNIX_OUTPUT_STREAM(RVAL2GOBJ(o))) +#define RVAL2GUNIXSOCKETADDRESS(o) (G_UNIX_SOCKET_ADDRESS(RVAL2GOBJ(o))) +#define RVAL2GVFS(o) (G_VFS(RVAL2GOBJ(o))) +#define RVAL2GVOLUME(o) (G_VOLUME(RVAL2GOBJ(o))) +#define RVAL2GVOLUMEMONITOR(o) (G_VOLUME_MONITOR(RVAL2GOBJ(o))) +#define RVAL2GZLIBCOMPRESSOR(o) (G_ZLIB_COMPRESSOR(RVAL2GOBJ(o))) +#define RVAL2GZLIBDECOMPRESSOR(o) (G_ZLIB_DECOMPRESSOR(RVAL2GOBJ(o))) + +#define RVAL2GFILEATTRIBUTEINFO(o) ((GFileAttributeInfo*)RVAL2BOXED(o, G_TYPE_FILE_ATTRIBUTE_INFO)) +#define GFILEATTRIBUTEINFO2RVAL(o) (BOXED2RVAL(o, G_TYPE_FILE_ATTRIBUTE_INFO)) +#define RVAL2GFILEATTRIBUTEINFOLIST(o) ((GFileAttributeInfoList*)RVAL2BOXED(o, G_TYPE_FILE_ATTRIBUTE_INFO_LIST)) +#define GFILEATTRIBUTEINFOLIST2RVAL(o) (BOXED2RVAL(o, G_TYPE_FILE_ATTRIBUTE_INFO_LIST)) +#define RVAL2GFILEATTRIBUTEMATCHER(o) ((GFileAttributeMatcher*)RVAL2BOXED(o, G_TYPE_FILE_ATTRIBUTE_MATCHER)) +#define GFILEATTRIBUTEMATCHER2RVAL(o) (BOXED2RVAL(o, G_TYPE_FILE_ATTRIBUTE_MATCHER)) +#define RVAL2GSRVTARGET(o) ((GSrvTarget*)RVAL2BOXED(o, G_TYPE_SRV_TARGET)) +#define GSRVTARGET2RVAL(o) (BOXED2RVAL(o, G_TYPE_SRV_TARGET)) + +#define RVAL2GDATASTREAMBYTEORDER(o) (RVAL2GENUM(o, G_TYPE_DATA_STREAM_BYTE_ORDER)) +#define GDATASTREAMBYTEORDER2RVAL(o) (GENUM2RVAL(o, G_TYPE_DATA_STREAM_BYTE_ORDER)) +#define RVAL2GDATASTREAMNEWLINETYPE(o) (RVAL2GENUM(o, G_TYPE_DATA_STREAM_NEWLINE_TYPE)) +#define GDATASTREAMNEWLINETYPE2RVAL(o) (GENUM2RVAL(o, G_TYPE_DATA_STREAM_NEWLINE_TYPE)) +#define RVAL2GDRIVESTARTFLAGS(o) (RVAL2GENUM(o, G_TYPE_DRIVE_START_FLAGS)) +#define GDRIVESTARTFLAGS2RVAL(o) (GENUM2RVAL(o, G_TYPE_DRIVE_START_FLAGS)) +#define RVAL2GDRIVESTARTSTOPTYPE(o) (RVAL2GENUM(o, G_TYPE_DRIVE_START_STOP_TYPE)) +#define GDRIVESTARTSTOPTYPE2RVAL(o) (GENUM2RVAL(o, G_TYPE_DRIVE_START_STOP_TYPE)) +#define RVAL2GEMBLEMORIGIN(o) (RVAL2GENUM(o, G_TYPE_EMBLEM_ORIGIN)) +#define GEMBLEMORIGIN2RVAL(o) (GENUM2RVAL(o, G_TYPE_EMBLEM_ORIGIN)) +#define RVAL2GFILEATTRIBUTESTATUS(o) (RVAL2GENUM(o, G_TYPE_FILE_ATTRIBUTE_STATUS)) +#define GFILEATTRIBUTESTATUS2RVAL(o) (GENUM2RVAL(o, G_TYPE_FILE_ATTRIBUTE_STATUS)) +#define RVAL2GFILEATTRIBUTETYPE(o) (RVAL2GENUM(o, G_TYPE_FILE_ATTRIBUTE_TYPE)) +#define GFILEATTRIBUTETYPE2RVAL(o) (GENUM2RVAL(o, G_TYPE_FILE_ATTRIBUTE_TYPE)) +#define RVAL2GFILETYPE(o) (RVAL2GENUM(o, G_TYPE_FILE_TYPE)) +#define GFILETYPE2RVAL(o) (GENUM2RVAL(o, G_TYPE_FILE_TYPE)) +#define RVAL2GMOUNTMOUNTFLAGS(o) (RVAL2GENUM(o, G_TYPE_MOUNT_MOUNT_FLAGS)) +#define GMOUNTMOUNTFLAGS2RVAL(o) (GENUM2RVAL(o, G_TYPE_MOUNT_MOUNT_FLAGS)) +#define RVAL2GMOUNTOPERATIONRESULT(o) (RVAL2GENUM(o, G_TYPE_MOUNT_OPERATION_RESULT)) +#define GMOUNTOPERATIONRESULT2RVAL(o) (GENUM2RVAL(o, G_TYPE_MOUNT_OPERATION_RESULT)) +#define RVAL2GPASSWORDSAVE(o) (RVAL2GENUM(o, G_TYPE_PASSWORD_SAVE)) +#define GPASSWORDSAVE2RVAL(o) (GENUM2RVAL(o, G_TYPE_PASSWORD_SAVE)) +#define RVAL2GSOCKETFAMILY(o) (RVAL2GENUM(o, G_TYPE_SOCKET_FAMILY)) +#define GSOCKETFAMILY2RVAL(o) (GENUM2RVAL(o, G_TYPE_SOCKET_FAMILY)) +#define RVAL2GSOCKETPROTOCOL(o) (RVAL2GENUM(o, G_TYPE_SOCKET_PROTOCOL)) +#define GSOCKETPROTOCOL2RVAL(o) (GENUM2RVAL(o, G_TYPE_SOCKET_PROTOCOL)) +#define RVAL2GSOCKETTYPE(o) (RVAL2GENUM(o, G_TYPE_SOCKET_TYPE)) +#define GSOCKETTYPE2RVAL(o) (GENUM2RVAL(o, G_TYPE_SOCKET_TYPE)) + +#define RVAL2GAPPINFOCREATEFLAGS(o) (RVAL2GFLAGS(o, G_TYPE_APP_INFO_CREATE_FLAGS)) +#define GAPPINFOCREATEFLAGS2RVAL(o) (GFLAGS2RVAL(o, G_TYPE_APP_INFO_CREATE_FLAGS)) +#define RVAL2GAPPLICATIONFLAGS(o) (RVAL2GFLAGS(o, G_TYPE_APPLICATION_FLAGS)) +#define GAPPLICATIONFLAGS2RVAL(o) (GFLAGS2RVAL(o, G_TYPE_APPLICATION_FLAGS)) +#define RVAL2GCONVERTERFLAGS(o) (RVAL2GFLAGS(o, G_TYPE_CONVERTER_FLAGS)) +#define GCONVERTERFLAGS2RVAL(o) (GFLAGS2RVAL(o, G_TYPE_CONVERTER_FLAGS)) +#define RVAL2GCONVERTERRESULT(o) (RVAL2GFLAGS(o, G_TYPE_CONVERTER_RESULT)) +#define GCONVERTERRESULT2RVAL(o) (GFLAGS2RVAL(o, G_TYPE_CONVERTER_RESULT)) +#define RVAL2GFILEATTRIBUTEINFOFLAGS(o) (RVAL2GFLAGS(o, G_TYPE_FILE_ATTRIBUTE_INFO_FLAGS)) +#define GFILEATTRIBUTEINFOFLAGS2RVAL(o) (GFLAGS2RVAL(o, G_TYPE_FILE_ATTRIBUTE_INFO_FLAGS)) +#define RVAL2GFILECOPYFLAGS(o) (RVAL2GFLAGS(o, G_TYPE_FILE_COPY_FLAGS)) +#define GFILECOPYFLAGS2RVAL(o) (GFLAGS2RVAL(o, G_TYPE_FILE_COPY_FLAGS)) +#define RVAL2GFILECREATEFLAGS(o) (RVAL2GFLAGS(o, G_TYPE_FILE_CREATE_FLAGS)) +#define GFILECREATEFLAGS2RVAL(o) (GFLAGS2RVAL(o, G_TYPE_FILE_CREATE_FLAGS)) +#define RVAL2GFILEMONITORFLAGS(o) (RVAL2GFLAGS(o, G_TYPE_FILE_MONITOR_FLAGS)) +#define GFILEMONITORFLAGS2RVAL(o) (GFLAGS2RVAL(o, G_TYPE_FILE_MONITOR_FLAGS)) +#define RVAL2GFILEQUERYINFOFLAGS(o) (RVAL2GFLAGS(o, G_TYPE_FILE_QUERY_INFO_FLAGS)) +#define GFILEQUERYINFOFLAGS2RVAL(o) (GFLAGS2RVAL(o, G_TYPE_FILE_QUERY_INFO_FLAGS)) +#define RVAL2GMOUNTUNMOUNTFLAGS(o) (RVAL2GFLAGS(o, G_TYPE_MOUNT_UNMOUNT_FLAGS)) +#define GMOUNTUNMOUNTFLAGS2RVAL(o) (GFLAGS2RVAL(o, G_TYPE_MOUNT_UNMOUNT_FLAGS)) +#define RVAL2GOUTPUTSTREAMSPLICEFLAGS(o) (RVAL2GFLAGS(o, G_TYPE_OUTPUT_STREAM_SPLICE_FLAGS)) +#define GOUTPUTSTREAMSPLICEFLAGS2RVAL(o) (GFLAGS2RVAL(o, G_TYPE_OUTPUT_STREAM_SPLICE_FLAGS)) +#define RVAL2GZLIBCOMPRESSORFORMAT(o) (RVAL2GFLAGS(o, G_TYPE_ZLIB_COMPRESSOR_FORMAT)) +#define GZLIBCOMPRESSORFORMAT2RVAL(o) (GFLAGS2RVAL(o, G_TYPE_ZLIB_COMPRESSOR_FORMAT)) + +#endif /* __RBGIO2CONVERSIONS_H__ */ diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgio2private.h b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgio2private.h new file mode 100644 index 0000000..963ef9d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgio2private.h @@ -0,0 +1,148 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __RBGIO2PRIVATE_H__ +#define __RBGIO2PRIVATE_H__ + +#include + +#include +#include +#include "rbgio2.h" + +#define CSTR2RVAL_TAINTED(string, length) \ + rbgio_cstr_to_rval_tainted((string), (length)) +#define CSTR2RVAL_TAINTED_FREE(string, length) \ + rbgio_cstr_to_rval_tainted_free((string), (length)) + +#define GLIST2ARY_UNREF_FREE(list) rbgio_glist_to_ary_unref_free(list) + +#define GFDS2ARY(fds) rbgio_fds_to_ary(fds) +#define GFDS2ARY_FREE(fds) rbgio_fds_to_ary_free(fds) + +#define GFILEARY2GLIST(ary) rbgio_gfile_ary_to_glist(ary) +#define GFILEARY2GLIST_ACCEPT_NIL(ary) rbgio_gfile_ary_to_glist_accept_nil(ary) + +G_GNUC_INTERNAL VALUE rbgio_cstr_to_rval_tainted(const char *string, + gsize length); +G_GNUC_INTERNAL VALUE rbgio_cstr_to_rval_tainted_free(char *string, + gsize length); +G_GNUC_INTERNAL VALUE rbgio_glist_to_ary_unref_free(GList *list); +G_GNUC_INTERNAL VALUE rbgio_fds_to_ary(const gint *fds); +G_GNUC_INTERNAL VALUE rbgio_fds_to_ary_free(gint *fds); +G_GNUC_INTERNAL GList *rbgio_gfile_ary_to_glist(VALUE ary); +G_GNUC_INTERNAL GList *rbgio_gfile_ary_to_glist_accept_nil(VALUE ary); +G_GNUC_INTERNAL void rbgio_rval_to_gtimeval(VALUE value, GTimeVal *time); +G_GNUC_INTERNAL void rbgio_async_ready_callback(GObject *source, + GAsyncResult *result, + gpointer data); +G_GNUC_INTERNAL VALUE rbgio_child_remove_and_return(VALUE parent, VALUE child); + +G_GNUC_INTERNAL void Init_gio(void); +G_GNUC_INTERNAL void Init_gappinfo(VALUE mGio); +G_GNUC_INTERNAL void Init_gapplaunchcontext(VALUE mGio); +G_GNUC_INTERNAL void Init_gasyncinitable(VALUE mGio); +G_GNUC_INTERNAL void Init_gasyncresult(VALUE mGio); +G_GNUC_INTERNAL void Init_gbufferedinputstream(VALUE mGio); +G_GNUC_INTERNAL void Init_gbufferedoutputstream(VALUE mGio); +G_GNUC_INTERNAL void Init_gcancellable(VALUE mGio); +G_GNUC_INTERNAL void Init_gcharsetconverter(VALUE mGio); +G_GNUC_INTERNAL void Init_gcontenttype(VALUE mGio); +G_GNUC_INTERNAL void Init_gconverter(VALUE mGio); +G_GNUC_INTERNAL void Init_gconverterinputstream(VALUE mGio); +G_GNUC_INTERNAL void Init_gconverteroutputstream(VALUE mGio); +G_GNUC_INTERNAL void Init_gdatainputstream(VALUE mGio); +G_GNUC_INTERNAL void Init_gdataoutputstream(VALUE mGio); +G_GNUC_INTERNAL void Init_gdesktopappinfo(VALUE mGio); +G_GNUC_INTERNAL void Init_gdrive(VALUE mGio); +G_GNUC_INTERNAL void Init_gemblem(VALUE mGio); +G_GNUC_INTERNAL void Init_gemblemedicon(VALUE mGio); +G_GNUC_INTERNAL void Init_gfile(VALUE mGio); +G_GNUC_INTERNAL void Init_gfileattribute(VALUE mGio); +G_GNUC_INTERNAL void Init_gfileattributeinfo(VALUE mGio); +G_GNUC_INTERNAL void Init_fileattributeinfolist(VALUE mGio); +G_GNUC_INTERNAL void Init_gfileattributematcher(VALUE mGio); +G_GNUC_INTERNAL void Init_gfiledescriptorbased(VALUE mGio); +G_GNUC_INTERNAL void Init_gfileenumerator(VALUE mGio); +G_GNUC_INTERNAL void Init_gfileicon(VALUE mGio); +G_GNUC_INTERNAL void Init_gfileinfo(VALUE mGio); +G_GNUC_INTERNAL void Init_gfileinputstream(VALUE mGio); +G_GNUC_INTERNAL void Init_gfileiostream(VALUE mGio); +G_GNUC_INTERNAL void Init_gfilemonitor(VALUE mGio); +G_GNUC_INTERNAL void Init_gfilenamecompleter(VALUE mGio); +G_GNUC_INTERNAL void Init_gfileoutputstream(VALUE mGio); +G_GNUC_INTERNAL void Init_gfilterinputstream(VALUE mGio); +G_GNUC_INTERNAL void Init_gfilteroutputstream(VALUE mGio); +G_GNUC_INTERNAL void Init_gicon(VALUE mGio); +G_GNUC_INTERNAL void Init_ginetaddress(VALUE mGio); +G_GNUC_INTERNAL void Init_ginetsocketaddress(VALUE mGio); +G_GNUC_INTERNAL void Init_ginitable(VALUE mGio); +G_GNUC_INTERNAL void Init_ginputstream(VALUE mGio); +G_GNUC_INTERNAL void Init_gioerror(VALUE mGio); +G_GNUC_INTERNAL void Init_giomodule(VALUE mGio); +G_GNUC_INTERNAL void Init_giomodules(VALUE mGio); +G_GNUC_INTERNAL void Init_gioscheduler(VALUE mGio); +G_GNUC_INTERNAL void Init_gioschedulerjob(VALUE mGio); +G_GNUC_INTERNAL void Init_giostream(VALUE mGio); +G_GNUC_INTERNAL void Init_gloadableicon(VALUE mGio); +G_GNUC_INTERNAL void Init_gmemoryinputstream(VALUE mGio); +G_GNUC_INTERNAL void Init_gmemoryoutputstream(VALUE mGio); +G_GNUC_INTERNAL void Init_gmount(VALUE mGio); +G_GNUC_INTERNAL void Init_gmountoperation(VALUE mGio); +G_GNUC_INTERNAL void Init_gnetworkaddress(VALUE mGio); +G_GNUC_INTERNAL void Init_gnetworkservice(VALUE mGio); +G_GNUC_INTERNAL void Init_goutputstream(VALUE mGio); +G_GNUC_INTERNAL void Init_gresolver(VALUE mGio); +G_GNUC_INTERNAL void Init_gseekable(VALUE mGio); +G_GNUC_INTERNAL void Init_gsimpleasyncresult(VALUE mGio); +G_GNUC_INTERNAL void Init_gsocket(VALUE mGio); +G_GNUC_INTERNAL void Init_gsocketaddress(VALUE mGio); +G_GNUC_INTERNAL void Init_gsocketclient(VALUE mGio); +G_GNUC_INTERNAL void Init_gsocketconnectable(VALUE mGio); +G_GNUC_INTERNAL void Init_gsocketaddressenumerator(VALUE mGio); +G_GNUC_INTERNAL void Init_gsocketconnection(VALUE mGio); +G_GNUC_INTERNAL void Init_gsocketconnectionfactory(VALUE mGio); +G_GNUC_INTERNAL void Init_gsocketcontrolmessage(VALUE mGio); +G_GNUC_INTERNAL void Init_gsocketlistener(VALUE mGio); +G_GNUC_INTERNAL void Init_gsocketservice(VALUE mGio); +G_GNUC_INTERNAL void Init_gsrvtarget(VALUE mGio); +G_GNUC_INTERNAL void Init_gtcpconnection(VALUE mGio); +G_GNUC_INTERNAL void Init_gthreadedsocketservice(VALUE mGio); +G_GNUC_INTERNAL void Init_gthemedicon(VALUE mGio); +G_GNUC_INTERNAL void Init_gtlscertificate(VALUE mGio); +G_GNUC_INTERNAL void Init_gunixconnection(VALUE mGio); +G_GNUC_INTERNAL void Init_gunixfdlist(VALUE mGio); +G_GNUC_INTERNAL void Init_gunixfdmessage(VALUE mGio); +G_GNUC_INTERNAL void Init_gunixinputstream(VALUE mGio); +G_GNUC_INTERNAL void Init_gunixmount(VALUE mGio); +G_GNUC_INTERNAL void Init_gunixmounts(VALUE mGio); +G_GNUC_INTERNAL void Init_gunixmountpoint(VALUE mGio); +G_GNUC_INTERNAL void Init_gunixmountpoints(VALUE mGio); +G_GNUC_INTERNAL void Init_gunixmountmonitor(VALUE mGio); +G_GNUC_INTERNAL void Init_gunixoutputstream(VALUE mGio); +G_GNUC_INTERNAL void Init_gunixsocketaddress(VALUE mGio); +G_GNUC_INTERNAL void Init_gvfs(VALUE mGio); +G_GNUC_INTERNAL void Init_gvolume(VALUE mGio); +G_GNUC_INTERNAL void Init_gvolumemonitor(VALUE mGio); +G_GNUC_INTERNAL void Init_gzlibcompressor(VALUE mGio); +G_GNUC_INTERNAL void Init_gzlibdecompressor(VALUE mGio); +G_GNUC_INTERNAL void Init_util(void); + +#endif /* __RBGIO2PRIVATE_H__ */ diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioappinfo.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioappinfo.c new file mode 100644 index 0000000..27c35b3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioappinfo.c @@ -0,0 +1,317 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mAppInfo +#define _SELF(value) RVAL2GAPPINFO(value) + +#define RVAL2GAPPINFOCREATEFLAGSDEFAULT(value) \ + RVAL2TYPE_WITH_DEFAULT((value), \ + RVAL2GAPPINFOCREATEFLAGS, \ + G_APP_INFO_CREATE_NONE) + +static VALUE +rg_s_create_from_commandline(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE commandline, application_name, flags; + GError *error = NULL; + GAppInfo *info; + + rb_scan_args(argc, argv, "12", &commandline, &application_name, &flags); + info = g_app_info_create_from_commandline(RVAL2CSTR(commandline), + RVAL2CSTR_ACCEPT_NIL(application_name), + RVAL2GAPPINFOCREATEFLAGSDEFAULT(flags), + &error); + if (info == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(info); +} + +static VALUE +rg_s_reset_type_associations(VALUE self, VALUE content_type) +{ + g_app_info_reset_type_associations(RVAL2CSTR(content_type)); + + return self; +} + +static VALUE +rg_s_get_all_for_type(G_GNUC_UNUSED VALUE self, VALUE content_type) +{ + return GLIST2ARY_FREE(g_app_info_get_all_for_type(RVAL2CSTR(content_type))); +} + +static VALUE +rg_s_all(int argc, VALUE *argv, VALUE self) +{ + VALUE content_type; + + rb_scan_args(argc, argv, "01", &content_type); + if (!NIL_P(content_type)) + return rg_s_get_all_for_type(self, content_type); + + return GLIST2ARY_FREE(g_app_info_get_all()); +} + +static VALUE +rg_s_get_default_for_type(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE content_type, must_support_uris; + + rb_scan_args(argc, argv, "11", &content_type, &must_support_uris); + + return GOBJ2RVAL_UNREF(g_app_info_get_default_for_type(RVAL2CSTR(content_type), + RVAL2CBOOL(must_support_uris))); +} + +static VALUE +rg_s_get_default_for_uri_scheme(G_GNUC_UNUSED VALUE self, VALUE uri_scheme) +{ + return GOBJ2RVAL_UNREF(g_app_info_get_default_for_uri_scheme(RVAL2CSTR(uri_scheme))); +} + +static VALUE +rg_s_launch_default_for_uri(int argc, VALUE *argv, VALUE self) +{ + VALUE uri, launch_context; + GError *error; + + rb_scan_args(argc, argv, "11", &uri, &launch_context); + if (!g_app_info_launch_default_for_uri(RVAL2CSTR(uri), + RVAL2GAPPLAUNCHCONTEXT(launch_context), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_dup(VALUE self) +{ + return GOBJ2RVAL_UNREF(g_app_info_dup(_SELF(self))); +} + +static VALUE +rg_equal_p(VALUE self, VALUE other) +{ + return CBOOL2RVAL(g_app_info_equal(_SELF(self), _SELF(other))); +} + +static VALUE +rg_id(VALUE self) +{ + return CSTR2RVAL(g_app_info_get_id(_SELF(self))); +} + +static VALUE +rg_name(VALUE self) +{ + return CSTR2RVAL(g_app_info_get_name(_SELF(self))); +} + +static VALUE +rg_display_name(VALUE self) +{ + return CSTR2RVAL(g_app_info_get_display_name(_SELF(self))); +} + +static VALUE +rg_description(VALUE self) +{ + return CSTR2RVAL(g_app_info_get_description(_SELF(self))); +} + +static VALUE +rg_executable(VALUE self) +{ + return CSTR2RVAL(g_app_info_get_executable(_SELF(self))); +} + +static VALUE +rg_commandline(VALUE self) +{ + return CSTR2RVAL(g_app_info_get_commandline(_SELF(self))); +} + +static VALUE +rg_icon(VALUE self) +{ + return GOBJ2RVAL(g_app_info_get_icon(_SELF(self))); +} + +typedef gboolean (*LaunchMethod)(GAppInfo *, + GList *, + GAppLaunchContext *, + GError **); + +static VALUE +launch_method(LaunchMethod method, int argc, VALUE *argv, VALUE self) +{ + VALUE rbfiles, rblaunch_context; + GList *files; + GAppLaunchContext *launch_context; + GError *error = NULL; + gboolean launched; + + rb_scan_args(argc, argv, "02", &rbfiles, &rblaunch_context); + launch_context = RVAL2GAPPLAUNCHCONTEXT(rblaunch_context); + files = GFILEARY2GLIST_ACCEPT_NIL(rbfiles); + launched = method(_SELF(self), files, launch_context, &error); + g_list_free(files); + + if (!launched) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_launch(int argc, VALUE *argv, VALUE self) +{ + return launch_method(g_app_info_launch, argc, argv, self); +} + +static VALUE +rg_supports_files_p(VALUE self) +{ + return CBOOL2RVAL(g_app_info_supports_files(_SELF(self))); +} + +static VALUE +rg_supports_uris_p(VALUE self) +{ + return CBOOL2RVAL(g_app_info_supports_uris(_SELF(self))); +} + +static VALUE +rg_launch_uris(int argc, VALUE *argv, VALUE self) +{ + return launch_method(g_app_info_launch_uris, argc, argv, self); +} + +static VALUE +rg_should_show_p(VALUE self) +{ + return CBOOL2RVAL(g_app_info_should_show(_SELF(self))); +} + +static VALUE +rg_can_delete_p(VALUE self) +{ + return CBOOL2RVAL(g_app_info_can_delete(_SELF(self))); +} + +static VALUE +rg_delete(VALUE self) +{ + return CBOOL2RVAL(g_app_info_delete(_SELF(self))); +} + +static VALUE +rg_set_as_default_for_type(VALUE self, VALUE value) +{ + GError *error = NULL; + + if (!g_app_info_set_as_default_for_type(_SELF(self), RVAL2CSTR(value), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_set_as_default_for_extension(VALUE self, VALUE value) +{ + GError *error = NULL; + + if (!g_app_info_set_as_default_for_extension(_SELF(self), RVAL2CSTR(value), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_add_supports_type(VALUE self, VALUE value) +{ + GError *error = NULL; + + if (!g_app_info_add_supports_type(_SELF(self), RVAL2CSTR(value), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_remove_supports_type(VALUE self, VALUE value) +{ + GError *error = NULL; + + if (!g_app_info_remove_supports_type(_SELF(self), RVAL2CSTR(value), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_can_remove_supports_type_p(VALUE self) +{ + return CBOOL2RVAL(g_app_info_can_remove_supports_type(_SELF(self))); +} + +void +Init_gappinfo(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_APP_INFO, "AppInfo", mGio); + + G_DEF_CLASS(G_TYPE_APP_INFO_CREATE_FLAGS, "CreateFlags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_APP_INFO_CREATE_FLAGS, "G_APP_INFO_"); + + RG_DEF_SMETHOD(create_from_commandline, -1); + RG_DEF_SMETHOD(reset_type_associations, -1); + RG_DEF_SMETHOD(all, 0); + RG_DEF_SMETHOD(get_all_for_type, 1); + RG_DEF_SMETHOD(get_default_for_type, -1); + RG_DEF_SMETHOD(get_default_for_uri_scheme, 1); + RG_DEF_SMETHOD(launch_default_for_uri, 0); + + RG_DEF_METHOD(dup, 0); + RG_DEF_METHOD_P(equal, 1); + RG_DEF_METHOD(id, 0); + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(display_name, 0); + RG_DEF_METHOD(description, 0); + RG_DEF_METHOD(executable, 0); + RG_DEF_METHOD(commandline, 0); + RG_DEF_METHOD(icon, 0); + RG_DEF_METHOD(launch, -1); + RG_DEF_METHOD_P(supports_files, 0); + RG_DEF_METHOD_P(supports_uris, 0); + RG_DEF_METHOD(launch_uris, -1); + RG_DEF_METHOD_P(should_show, 0); + RG_DEF_METHOD_P(can_delete, 0); + RG_DEF_METHOD(delete, 0); + RG_DEF_METHOD(set_as_default_for_type, 1); + RG_DEF_METHOD(set_as_default_for_extension, 1); + RG_DEF_METHOD(add_supports_type, 1); + RG_DEF_METHOD_P(can_remove_supports_type, 1); + RG_DEF_METHOD(remove_supports_type, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioapplaunchcontext.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioapplaunchcontext.c new file mode 100644 index 0000000..bf3b25e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioapplaunchcontext.c @@ -0,0 +1,81 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cAppLaunchContext +#define _SELF(value) RVAL2GAPPLAUNCHCONTEXT(value) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, g_app_launch_context_new()); + + return Qnil; +} + +typedef char *(*GetMethod)(GAppLaunchContext *, GAppInfo *, GList *); + +static VALUE +get_value_by(GetMethod method, int argc, VALUE *argv, VALUE self) +{ + VALUE info, rbfiles; + GList *files; + char *value; + + rb_scan_args(argc, argv, "11", &info, &rbfiles); + files = GFILEARY2GLIST_ACCEPT_NIL(rbfiles); + value = method(_SELF(self), RVAL2GAPPINFO(info), files); + g_list_free(files); + + return CSTR2RVAL_FREE(value); +} + +static VALUE +rg_get_display(int argc, VALUE *argv, VALUE self) +{ + return get_value_by(g_app_launch_context_get_display, argc, argv, self); +} + +static VALUE +rg_get_startup_notify_id(int argc, VALUE *argv, VALUE self) +{ + return get_value_by(g_app_launch_context_get_startup_notify_id, argc, argv, self); +} + +static VALUE +rg_launch_failed(VALUE self, VALUE sn_id) +{ + g_app_launch_context_launch_failed(_SELF(self), RVAL2CSTR(sn_id)); + + return self; +} + +void +Init_gapplaunchcontext(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_APP_LAUNCH_CONTEXT, "AppLaunchContext", mGio); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(get_display, -1); + RG_DEF_METHOD(get_startup_notify_id, -1); + RG_DEF_METHOD(launch_failed, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioasyncinitable.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioasyncinitable.c new file mode 100644 index 0000000..0f1b7a7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioasyncinitable.c @@ -0,0 +1,246 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mAsyncInitable +#define _SELF(value) RVAL2GASYNCINITABLE(value) + +static VALUE +rg_init_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbio_priority, rbcancellable, block; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_async_initable_init_async(_SELF(self), + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_init_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + + if (!g_async_initable_init_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &error)) + rbgio_raise_error(error); + + return self; +} + +/* NOTE: We don't implement g_async_initable_new_async. */ + +/* NOTE: We don't implement g_async_initable_new_valist_async. */ + +struct rbgio_gasyncinitable_new_async_data { + GObjectClass *gclass; + int io_priority; + GCancellable *cancellable; + VALUE block; + VALUE rbparameters; + guint index; + guint n_parameters; + GParameter *parameters; +}; + +static VALUE +rbgio_gasyncinitiable_new_async_parameters_initialize(VALUE key_value, + struct rbgio_gasyncinitable_new_async_data *data) +{ + VALUE key, value; + GParamSpec *spec; + + if (data->index >= data->n_parameters) + rb_raise(rb_eArgError, + "too many parameters (%d >= %d)", + data->index, data->n_parameters); + + key = rb_ary_entry(key_value, 0); + value = rb_ary_entry(key_value, 1); + + data->parameters[data->index].name = SYMBOL_P(key) ? + rb_id2name(SYM2ID(key)) : + StringValuePtr(key); + spec = g_object_class_find_property(data->gclass, + data->parameters[data->index].name); + if (spec == NULL) + rb_raise(rb_eArgError, + "%s: no such property", + data->parameters[data->index].name); + g_value_init(&(data->parameters[data->index].value), + G_PARAM_SPEC_VALUE_TYPE(spec)); + rbgobj_rvalue_to_gvalue(value, &(data->parameters[data->index].value)); + + data->index++; + + return Qnil; +} + +static VALUE +rbgio_gasyncinitable_new_async_body(struct rbgio_gasyncinitable_new_async_data *data) +{ + rb_iterate(rb_each, + data->rbparameters, + rbgio_gasyncinitiable_new_async_parameters_initialize, + (VALUE)data); + + SAVE_BLOCK(data->block); + + g_async_initable_newv_async(G_TYPE_FROM_CLASS(data->gclass), + data->n_parameters, + data->parameters, + data->io_priority, + data->cancellable, + rbgio_async_ready_callback, + (gpointer)data->block); + + return Qnil; +} + +static VALUE +rbgio_gasyncinitable_new_async_ensure(struct rbgio_gasyncinitable_new_async_data *data) +{ + guint i; + + g_type_class_unref(data->gclass); + for (i = 0; i < data->n_parameters; i++) + if (G_IS_VALUE(&data->parameters[i].value)) + g_value_unset(&data->parameters[i].value); + + g_free(data->parameters); + + return Qnil; +} + +void +rbgio_gasyncinitable_new_async(GType type, + VALUE parameters, + VALUE io_priority, + VALUE cancellable, + VALUE block) +{ + static ID s_id_length; + struct rbgio_gasyncinitable_new_async_data data; + + if (s_id_length == 0) + s_id_length = rb_intern("length"); + + if (!g_type_is_a(type, G_TYPE_OBJECT)) + rb_raise(rb_eArgError, + "%s is not a descendant of GObject", + g_type_name(type)); + + if (NIL_P(parameters)) { + SAVE_BLOCK(block); + g_async_initable_newv_async(type, + 0, + NULL, + RVAL2IOPRIORITYDEFAULT(io_priority), + RVAL2GCANCELLABLE(cancellable), + rbgio_async_ready_callback, + (gpointer)block); + + return; + } else { + parameters = rb_convert_type(parameters, + T_HASH, + "Hash", + "to_hash"); + } + + data.gclass = G_OBJECT_CLASS(g_type_class_ref(type)); + data.io_priority = RVAL2IOPRIORITYDEFAULT(io_priority); + data.cancellable = RVAL2GCANCELLABLE(cancellable); + data.block = block; + data.rbparameters = parameters; + data.index = 0; + data.n_parameters = RVAL2GUINT(rb_funcall(parameters, s_id_length, 0)); + data.parameters = g_new(GParameter, data.n_parameters); + + rb_ensure(rbgio_gasyncinitable_new_async_body, (VALUE)&data, + rbgio_gasyncinitable_new_async_ensure, (VALUE)&data); + + return; +} + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + const RGObjClassInfo* info; + VALUE io_priority, cancellable, parameters, block; + + rb_scan_args(argc, argv, "03&", &io_priority, &cancellable, ¶meters, &block); + + info = CLASS2CINFO(self); + if (info->klass != self) + rb_raise(rb_eTypeError, + "%s: class not registered with GLib", + rb_class2name(self)); + + rbgio_gasyncinitable_new_async(info->gtype, + parameters, + io_priority, + cancellable, + block); + + return self; +} + +static VALUE +rg_initialize_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + GObject *object; + VALUE rbobject; + + object = g_async_initable_new_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &error); + if (object == NULL) + rbgio_raise_error(error); + + rbobject = GOBJ2RVAL(object); + g_object_unref(object); + + return rbobject; +} + +void +Init_gasyncinitable(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_ASYNC_INITABLE, "AsyncInitable", mGio); + + RG_DEF_METHOD(init_async, -1); + RG_DEF_METHOD(init_finish, 1); + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(initialize_finish, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioasyncresult.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioasyncresult.c new file mode 100644 index 0000000..627740d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioasyncresult.c @@ -0,0 +1,41 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mAsyncResult +#define _SELF(value) RVAL2GASYNCRESULT(value) + +/* NOTE: g_async_result_get_user_data isn't of any use from Ruby. */ + +static VALUE +rg_source_object(VALUE self) +{ + return GOBJ2RVAL_UNREF(g_async_result_get_source_object(_SELF(self))); +} + +void +Init_gasyncresult(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_ASYNC_RESULT, "AsyncResult", mGio); + + RG_DEF_METHOD(source_object, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiobufferedinputstream.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiobufferedinputstream.c new file mode 100644 index 0000000..08c962f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiobufferedinputstream.c @@ -0,0 +1,167 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cBufferedInputStream +#define _SELF(value) RVAL2GBUFFEREDINPUTSTREAM(value) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE rbbase_stream, size; + GInputStream *base_stream, *stream; + + rb_scan_args(argc, argv, "11", &rbbase_stream, &size); + base_stream = RVAL2GINPUTSTREAM(rbbase_stream); + + stream = NIL_P(size) ? + g_buffered_input_stream_new(base_stream) : + g_buffered_input_stream_new_sized(base_stream, RVAL2GSIZE(size)); + G_INITIALIZE(self, stream); + + return Qnil; +} + +static VALUE +rg_available(VALUE self) +{ + return GSIZE2RVAL(g_buffered_input_stream_get_available(_SELF(self))); +} + +static VALUE +rg_peek_buffer(VALUE self) +{ + gsize size; + const void *buffer; + + buffer = g_buffered_input_stream_peek_buffer(_SELF(self), &size); + + return CSTR2RVAL_TAINTED(buffer, size); +} + +static VALUE +rg_peek(VALUE self, VALUE rboffset, VALUE rbcount) +{ + gsize offset = RVAL2GSIZE(rboffset); + gsize count = RVAL2GSIZE(rbcount); + VALUE result = rb_str_new(NULL, count); + gsize bytes_peeked = g_buffered_input_stream_peek(_SELF(self), + RSTRING_PTR(result), + offset, + count); + + rb_str_set_len(result, bytes_peeked); + rb_str_resize(result, bytes_peeked); + OBJ_TAINT(result); + + return result; +} + +static VALUE +rg_fill(int argc, VALUE *argv, VALUE self) +{ + VALUE count, cancellable; + GError *error = NULL; + gsize bytes_read; + + rb_scan_args(argc, argv, "02", &count, &cancellable); + bytes_read = g_buffered_input_stream_fill(_SELF(self), + NIL_P(count) ? + -1 : + RVAL2GSSIZE(count), + RVAL2GCANCELLABLE(cancellable), + &error); + if (error != NULL) + rbgio_raise_error(error); + + return GSSIZE2RVAL(bytes_read); +} + +static VALUE +rg_fill_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbcount, rbio_priority, rbcancellable, block; + gssize count; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "03&", &rbcount, &rbio_priority, &rbcancellable, &block); + count = NIL_P(rbcount) ? -1 : RVAL2GSSIZE(rbcount); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_buffered_input_stream_fill_async(_SELF(self), + count, + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_fill_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + gsize bytes_read; + + bytes_read = g_buffered_input_stream_fill_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &error); + if (error != NULL) + rbgio_raise_error(error); + + return GSSIZE2RVAL(bytes_read); +} + +static VALUE +rg_read_byte(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + int byte; + + rb_scan_args(argc, argv, "01", &cancellable); + byte = g_buffered_input_stream_read_byte(_SELF(self), + RVAL2GCANCELLABLE(cancellable), + &error); + if (error != NULL) + rbgio_raise_error(error); + + return INT2FIX(byte); +} + +void +Init_gbufferedinputstream(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_BUFFERED_INPUT_STREAM, "BufferedInputStream", mGio); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(available, 0); + RG_DEF_METHOD(peek_buffer, 0); + RG_DEF_METHOD(peek, 2); + RG_DEF_METHOD(fill, -1); + RG_DEF_METHOD(fill_async, -1); + RG_DEF_METHOD(fill_finish, 1); + RG_DEF_METHOD(read_byte, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiobufferedoutputstream.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiobufferedoutputstream.c new file mode 100644 index 0000000..4713363 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiobufferedoutputstream.c @@ -0,0 +1,50 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cBufferedOutputStream +#define _SELF(value) RVAL2GBUFFEREDOUTPUTSTREAM(value) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE rbbase_stream, size; + GOutputStream *base_stream, *stream; + + rb_scan_args(argc, argv, "11", &rbbase_stream, &size); + base_stream = RVAL2GOUTPUTSTREAM(rbbase_stream); + + stream = NIL_P(size) ? + g_buffered_output_stream_new(base_stream) : + g_buffered_output_stream_new_sized(base_stream, RVAL2GSIZE(size)); + G_INITIALIZE(self, stream); + + return Qnil; +} + +void +Init_gbufferedoutputstream(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_BUFFERED_OUTPUT_STREAM, "BufferedOutputStream", mGio); + + RG_DEF_METHOD(initialize, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiocancellable.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiocancellable.c new file mode 100644 index 0000000..9ff7cee --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiocancellable.c @@ -0,0 +1,180 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cCancellable +#define _SELF(value) RVAL2GCANCELLABLE(value) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, g_cancellable_new()); + + return Qnil; +} + +static VALUE +rg_cancelled_p(VALUE self) +{ + return CBOOL2RVAL(g_cancellable_is_cancelled(_SELF(self))); +} + +static VALUE +rg_raise_error_if_cancelled(VALUE self) +{ + GError *error = NULL; + + if (g_cancellable_set_error_if_cancelled(_SELF(self), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_fd(VALUE self) +{ + return FD2RVAL(g_cancellable_get_fd(_SELF(self))); +} + +static VALUE +rg_make_pollfd(VALUE self) +{ + GCancellable *cancellable = _SELF(self); + GPollFD *gfd = g_new(GPollFD, 1); + + g_cancellable_make_pollfd(cancellable, gfd); + + return GPOLLFD2RVAL(gfd); +} + +G_GNUC_NORETURN static VALUE +rg_release_fd(VALUE self) +{ + /* TODO: How do we implement this? Maybe not at all? */ + self = self; + rb_raise(rb_eNotImpError, "release_fd has not been implemented yet"); +#if 0 + g_cancellable_release_fd(_SELF(self)); + + return self; +#endif +} + +static VALUE +rg_s_current(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(g_cancellable_get_current()); +} + +static VALUE +rg_pop_current(VALUE self) +{ + g_cancellable_pop_current(_SELF(self)); + + return self; +} + +static VALUE +rg_push_current(VALUE self) +{ + g_cancellable_push_current(_SELF(self)); + + return self; +} + +static VALUE +rg_reset(VALUE self) +{ + g_cancellable_reset(_SELF(self)); + + return self; +} + +static VALUE +cancellable_connect_callback_call(VALUE block) +{ + static ID s_id_call; + + if (s_id_call == 0) + s_id_call = rb_intern("call"); + + rb_funcall(block, s_id_call, 0); + + return Qnil; +} + +static void +cancellable_connect_callback(gpointer block) +{ + G_PROTECT_CALLBACK(cancellable_connect_callback_call, block); +} + +static VALUE +rg_connect(VALUE self) +{ + VALUE block; + + block = rb_block_proc(); + G_RELATIVE(self, block); + + return GULONG2RVAL(g_cancellable_connect(_SELF(self), + G_CALLBACK(cancellable_connect_callback), + (gpointer)block, + NULL)); +} + +static VALUE +rg_disconnect(VALUE self, VALUE handler_id) +{ + g_cancellable_disconnect(_SELF(self), RVAL2GULONG(handler_id)); + + return self; +} + +static VALUE +rg_cancel(VALUE self) +{ + g_cancellable_cancel(_SELF(self)); + + return self; +} + +void +Init_gcancellable(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_CANCELLABLE, "Cancellable", mGio); + + RG_DEF_SMETHOD(current, 0); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD_P(cancelled, 0); + RG_DEF_METHOD(raise_error_if_cancelled, 0); + RG_DEF_METHOD(fd, 0); + RG_DEF_METHOD(make_pollfd, 0); + RG_DEF_METHOD(release_fd, 0); + RG_DEF_METHOD(pop_current, 0); + RG_DEF_METHOD(push_current, 0); + RG_DEF_METHOD(reset, 0); + RG_DEF_METHOD(connect, 0); + RG_DEF_METHOD(disconnect, 1); + RG_DEF_METHOD(cancel, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiocharsetconverter.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiocharsetconverter.c new file mode 100644 index 0000000..194ecb7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiocharsetconverter.c @@ -0,0 +1,57 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cCharsetConverter +#define _SELF(value) RVAL2GCHARSETCONVERTER(value) + +static VALUE +rg_initialize(VALUE self, VALUE to, VALUE from) +{ + GError *error = NULL; + GCharsetConverter *converter; + + converter = g_charset_converter_new(RVAL2CSTR(to), + RVAL2CSTR(from), + &error); + if (converter == NULL) + rbgio_raise_error(error); + + G_INITIALIZE(self, converter); + + return Qnil; +} + +static VALUE +rg_num_fallbacks(VALUE self) +{ + return GUINT2RVAL(g_charset_converter_get_num_fallbacks(_SELF(self))); +} + +void +Init_gcharsetconverter(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_CHARSET_CONVERTER, "CharsetConverter", mGio); + + RG_DEF_METHOD(initialize, 2); + RG_DEF_METHOD(num_fallbacks, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiocontenttype.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiocontenttype.c new file mode 100644 index 0000000..be95546 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiocontenttype.c @@ -0,0 +1,131 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mContentType + +static VALUE +rg_s_equals_p(G_GNUC_UNUSED VALUE self, VALUE arg1, VALUE arg2) +{ + return CBOOL2RVAL(g_content_type_equals(RVAL2CSTR(arg1), RVAL2CSTR(arg2))); +} + +static VALUE +rg_s_is_a_p(G_GNUC_UNUSED VALUE self, VALUE arg1, VALUE arg2) +{ + return CBOOL2RVAL(g_content_type_is_a(RVAL2CSTR(arg1), RVAL2CSTR(arg2))); +} + +static VALUE +rg_s_unknown_p(G_GNUC_UNUSED VALUE type) +{ + return CBOOL2RVAL(g_content_type_is_unknown(RVAL2CSTR(type))); +} + +static VALUE +rg_s_get_description(G_GNUC_UNUSED VALUE type) +{ + return CSTR2RVAL_FREE(g_content_type_get_description(RVAL2CSTR(type))); +} + +static VALUE +rg_s_get_mime_type(G_GNUC_UNUSED VALUE type) +{ + return CSTR2RVAL_FREE(g_content_type_get_mime_type(RVAL2CSTR(type))); +} + +static VALUE +rg_s_get_icon(G_GNUC_UNUSED VALUE type) +{ + return GOBJ2RVAL_UNREF(g_content_type_get_icon(RVAL2CSTR(type))); +} + +static VALUE +rg_s_can_be_executable_p(G_GNUC_UNUSED VALUE type) +{ + return CBOOL2RVAL(g_content_type_can_be_executable(RVAL2CSTR(type))); +} + +static VALUE +rg_s_from_mime_type(G_GNUC_UNUSED VALUE type) +{ + return CSTR2RVAL(g_content_type_from_mime_type(RVAL2CSTR(type))); +} + +static VALUE +rg_s_guess(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE rbfilename, + rbdata; + const char *filename; + const guchar *data; + gboolean result_uncertain; + char *type; + + rb_scan_args(argc, argv, "02", &rbfilename, &rbdata); + + if (NIL_P(rbfilename) && NIL_P(rbdata)) + rb_raise(rb_eArgError, + "Either filename or data can be nil but not both"); + + filename = RVAL2CSTR_ACCEPT_NIL(rbfilename); + data = (guchar *)RVAL2CSTR_ACCEPT_NIL(rbdata); + + type = g_content_type_guess(filename, + data, + (gsize)((data != NULL) ? RSTRING_LEN(rbdata) : 0), + &result_uncertain); + + return rb_assoc_new(CSTR2RVAL_FREE(type), CBOOL2RVAL(result_uncertain)); +} + +static VALUE +rg_s_guess_for_tree(G_GNUC_UNUSED VALUE self, VALUE root) +{ + return STRV2RVAL_FREE(g_content_type_guess_for_tree(RVAL2GFILE(root))); +} + +static VALUE +rg_s_registered(G_GNUC_UNUSED VALUE self) +{ + return GLIST2ARY_STR_FREE(g_content_types_get_registered()); +} + +void +Init_gcontenttype(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGio, "ContentType"); + + /* TODO: Should wrap this in a class. */ + RG_DEF_SMETHOD_P(equals, 2); + /* TODO: This name isn't great. */ + RG_DEF_SMETHOD_P(is_a, 2); + RG_DEF_SMETHOD_P(unknown, 1); + RG_DEF_SMETHOD(get_description, 1); + RG_DEF_SMETHOD(get_mime_type, 1); + RG_DEF_SMETHOD(get_icon, 1); + RG_DEF_SMETHOD_P(can_be_executable, 1); + RG_DEF_SMETHOD(from_mime_type, 1); + RG_DEF_SMETHOD(guess, -1); + RG_DEF_SMETHOD(guess_for_tree, 1); + RG_DEF_SMETHOD(registered, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioconverter.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioconverter.c new file mode 100644 index 0000000..867d57f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioconverter.c @@ -0,0 +1,113 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mConverter +#define _SELF(value) RVAL2GCONVERTER(value) + +#define RVAL2GCONVERTERFLAGSDEFAULT(value) \ + RVAL2TYPE_WITH_DEFAULT((value), \ + RVAL2GCONVERTERFLAGS, \ + G_CONVERTER_NO_FLAGS) + +/* TODO: Look at gconverteroutputstream for implementing this. */ +/* TODO: Actually, is there any point in implementing this? */ +static VALUE +rg_convert(int argc, VALUE *argv, VALUE self) +{ + VALUE input, rbflags; + GConverter *converter; + gsize input_remaining, output_size, output_remaining, bytes_read, bytes_written; + GConverterFlags flags; + /* TODO: Use a Ruby string instead. */ + char *output_base, *output; + GError *error = NULL; + GConverterResult result; + + rb_scan_args(argc, argv, "11", &input, &rbflags); + converter = _SELF(self); + StringValue(input); + input_remaining = RSTRING_LEN(input); + flags = RVAL2GCONVERTERFLAGSDEFAULT(rbflags); + output_remaining = output_size = BUFSIZ; + output_base = output = ALLOCA_N(char, output_size); + do { + result = g_converter_convert(converter, + RSTRING_PTR(input), + input_remaining, + output, + output_remaining, + flags, + &bytes_read, + &bytes_written, + &error); + switch (result) { + case G_CONVERTER_ERROR: + switch (error->code) { + case G_IO_ERROR_NO_SPACE: + /* TODO: Expand the buffer? */ + break; + case G_IO_ERROR_PARTIAL_INPUT: + /* TODO: How do we request/tell the user that + * they need to provide more data? */ + break; + default: + break; + } + rbgio_raise_error(error); + break; + case G_CONVERTER_CONVERTED: + case G_CONVERTER_FLUSHED: + input_remaining -= bytes_read; + input += bytes_read; + output_remaining -= bytes_written; + output += bytes_written; + /* TODO: Do we need to do anything else? */ + break; + case G_CONVERTER_FINISHED: + /* TODO: Do we simply break, or do we need to consider + * something else? */ + break; + default: + break; + } + } while (input_remaining > 0); + + return CSTR2RVAL(output_base); +} + +static VALUE +rg_reset(VALUE self) +{ + g_converter_reset(_SELF(self)); + + return self; +} + +void +Init_gconverter(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_CONVERTER, "Converter", mGio); + + RG_DEF_METHOD(convert, -1); + RG_DEF_METHOD(reset, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioconverterinputstream.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioconverterinputstream.c new file mode 100644 index 0000000..790d105 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioconverterinputstream.c @@ -0,0 +1,43 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cConverterInputStream +#define _SELF(value) RVAL2GCONVERTERINPUTSTREAM(value) + +static VALUE +rg_initialize(VALUE self, VALUE base_stream, VALUE converter) +{ + G_INITIALIZE(self, + g_converter_input_stream_new(RVAL2GINPUTSTREAM(base_stream), + RVAL2GCONVERTER(converter))); + + return Qnil; +} + +void +Init_gconverterinputstream(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_CONVERTER_INPUT_STREAM, "ConverterInputStream", mGio); + + RG_DEF_METHOD(initialize, 2); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioconverteroutputstream.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioconverteroutputstream.c new file mode 100644 index 0000000..0bad3ef --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioconverteroutputstream.c @@ -0,0 +1,43 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cConverterOutputStream +#define _SELF(value) RVAL2GCONVERTEROUTPUTSTREAM(value) + +static VALUE +rg_initialize(VALUE self, VALUE base_stream, VALUE converter) +{ + G_INITIALIZE(self, + g_converter_output_stream_new(RVAL2GOUTPUTSTREAM(base_stream), + RVAL2GCONVERTER(converter))); + + return Qnil; +} + +void +Init_gconverteroutputstream(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_CONVERTER_OUTPUT_STREAM, "ConverterOutputStream", mGio); + + RG_DEF_METHOD(initialize, 2); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiodatainputstream.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiodatainputstream.c new file mode 100644 index 0000000..e08eb07 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiodatainputstream.c @@ -0,0 +1,309 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cDataInputStream +#define _SELF(value) RVAL2GDATAINPUTSTREAM(value) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE base_stream, byte_order, newline_type; + + rb_scan_args(argc, argv, "12", &base_stream, &byte_order, &newline_type); + + G_INITIALIZE(self, g_data_input_stream_new(RVAL2GINPUTSTREAM(base_stream))); + + if (!NIL_P(byte_order)) + g_data_input_stream_set_byte_order(_SELF(self), + RVAL2GDATASTREAMBYTEORDER(byte_order)); + + if (!NIL_P(newline_type)) + g_data_input_stream_set_newline_type(_SELF(self), + RVAL2GDATASTREAMNEWLINETYPE(newline_type)); + + return Qnil; +} + +static VALUE +rg_read_byte(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + guchar value; + + rb_scan_args(argc, argv, "01", &cancellable); + value = g_data_input_stream_read_byte(_SELF(self), + RVAL2GCANCELLABLE(cancellable), + &error); + if (error != NULL) + rbgio_raise_error(error); + + return GUCHAR2RVAL(value); +} + +static VALUE +rg_read_int16(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + gint16 value; + + rb_scan_args(argc, argv, "01", &cancellable); + value = g_data_input_stream_read_int16(_SELF(self), + RVAL2GCANCELLABLE(cancellable), + &error); + if (error != NULL) + rbgio_raise_error(error); + + return GINT162RVAL(value); +} + +static VALUE +rg_read_uint16(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + guint16 value; + + rb_scan_args(argc, argv, "01", &cancellable); + value = g_data_input_stream_read_uint16(_SELF(self), + RVAL2GCANCELLABLE(cancellable), + &error); + if (error != NULL) + rbgio_raise_error(error); + + return GUINT162RVAL(value); +} + +static VALUE +rg_read_int32(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + gint32 value; + + rb_scan_args(argc, argv, "01", &cancellable); + value = g_data_input_stream_read_int32(_SELF(self), + RVAL2GCANCELLABLE(cancellable), + &error); + if (error != NULL) + rbgio_raise_error(error); + + return GINT322RVAL(value); +} + +static VALUE +rg_read_uint32(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + guint32 value; + + rb_scan_args(argc, argv, "01", &cancellable); + value = g_data_input_stream_read_uint32(_SELF(self), + RVAL2GCANCELLABLE(cancellable), + &error); + if (error != NULL) + rbgio_raise_error(error); + + return GUINT322RVAL(value); +} + +static VALUE +rg_read_int64(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + gint64 value; + + rb_scan_args(argc, argv, "01", &cancellable); + value = g_data_input_stream_read_int64(_SELF(self), + RVAL2GCANCELLABLE(cancellable), + &error); + if (error != NULL) + rbgio_raise_error(error); + + return GINT642RVAL(value); +} + +static VALUE +rg_read_uint64(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + guint64 value; + + rb_scan_args(argc, argv, "01", &cancellable); + value = g_data_input_stream_read_uint64(_SELF(self), + RVAL2GCANCELLABLE(cancellable), + &error); + if (error != NULL) + rbgio_raise_error(error); + + return GUINT642RVAL(value); +} + +static VALUE +rg_read_line(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + gsize length; + GError *error; + char *line; + + rb_scan_args(argc, argv, "01", &cancellable); + line = g_data_input_stream_read_line(_SELF(self), + &length, + RVAL2GCANCELLABLE(cancellable), + &error); + if (error != NULL) + rbgio_raise_error(error); + + return CSTR2RVAL_TAINTED_FREE(line, length); +} + +static VALUE +rg_read_line_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbio_priority, rbcancellable, block; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_data_input_stream_read_line_async(_SELF(self), + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_read_line_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + gsize length; + char *line; + + line = g_data_input_stream_read_line_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &length, + &error); + if (error != NULL) + rbgio_raise_error(error); + + return CSTR2RVAL_TAINTED_FREE(line, length); +} + +#if GLIB_CHECK_VERSION(2, 26, 0) +static VALUE +rg_read_upto(int argc, VALUE *argv, VALUE self) +{ + VALUE rbstop_chars, cancellable; + const char *stop_chars; + gsize length; + GError *error; + char *string; + + rb_scan_args(argc, argv, "11", &rbstop_chars, &cancellable); + stop_chars = RVAL2CSTR(rbstop_chars); + string = g_data_input_stream_read_upto(_SELF(self), + stop_chars, + RSTRING_LEN(rbstop_chars), + &length, + RVAL2GCANCELLABLE(cancellable), + &error); + if (error != NULL) + rbgio_raise_error(error); + + return CSTR2RVAL_TAINTED_FREE(string, length); +} + +static VALUE +rg_read_upto_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbstop_chars, rbcancellable, rbio_priority, block; + const char *stop_chars; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "12&", &rbstop_chars, &rbio_priority, &rbcancellable, &block); + stop_chars = RVAL2CSTR(rbstop_chars); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_data_input_stream_read_upto_async(_SELF(self), + stop_chars, + RSTRING_LEN(rbstop_chars), + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_read_upto_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + gsize length; + char *string; + + string = g_data_input_stream_read_upto_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &length, + &error); + if (error != NULL) + rbgio_raise_error(error); + + return CSTR2RVAL_TAINTED_FREE(string, length); +} +#endif + +void +Init_gdatainputstream(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_DATA_INPUT_STREAM, "DataInputStream", mGio); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(read_byte, -1); + RG_DEF_METHOD(read_int16, -1); + RG_DEF_METHOD(read_uint16, -1); + RG_DEF_METHOD(read_int32, -1); + RG_DEF_METHOD(read_uint32, -1); + RG_DEF_METHOD(read_int64, -1); + RG_DEF_METHOD(read_uint64, -1); + RG_DEF_METHOD(read_line, -1); + RG_DEF_METHOD(read_line_async, -1); + RG_DEF_METHOD(read_line_finish, 1); +#if GLIB_CHECK_VERSION(2, 26, 0) + RG_DEF_METHOD(read_upto, -1); + RG_DEF_METHOD(read_upto_async, -1); + RG_DEF_METHOD(read_upto_finish, 1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiodataoutputstream.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiodataoutputstream.c new file mode 100644 index 0000000..7ed8463 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiodataoutputstream.c @@ -0,0 +1,186 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cDataOutputStream +#define _SELF(value) RVAL2GDATAOUTPUTSTREAM(value) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE base_stream, + byte_order; + + rb_scan_args(argc, argv, "11", &base_stream, &byte_order); + + G_INITIALIZE(self, g_data_output_stream_new(RVAL2GOUTPUTSTREAM(base_stream))); + + if (!NIL_P(byte_order)) + g_data_output_stream_set_byte_order(_SELF(self), + RVAL2GDATASTREAMBYTEORDER(byte_order)); + + return Qnil; +} + +static VALUE +rg_put_byte(int argc, VALUE *argv, VALUE self) +{ + VALUE value, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "11", &value, &cancellable); + if (!g_data_output_stream_put_byte(_SELF(self), + RVAL2GUCHAR(value), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_put_int16(int argc, VALUE *argv, VALUE self) +{ + VALUE value, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "11", &value, &cancellable); + if (!g_data_output_stream_put_int16(_SELF(self), + RVAL2GINT16(value), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_put_uint16(int argc, VALUE *argv, VALUE self) +{ + VALUE value, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "11", &value, &cancellable); + if (!g_data_output_stream_put_uint16(_SELF(self), + RVAL2GUINT16(value), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_put_int32(int argc, VALUE *argv, VALUE self) +{ + VALUE value, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "11", &value, &cancellable); + if (!g_data_output_stream_put_int32(_SELF(self), + RVAL2GINT32(value), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_put_uint32(int argc, VALUE *argv, VALUE self) +{ + VALUE value, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "11", &value, &cancellable); + if (!g_data_output_stream_put_uint32(_SELF(self), + RVAL2GINT32(value), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_put_int64(int argc, VALUE *argv, VALUE self) +{ + VALUE value, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "11", &value, &cancellable); + if (!g_data_output_stream_put_int64(_SELF(self), + RVAL2GINT64(value), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_put_uint64(int argc, VALUE *argv, VALUE self) +{ + VALUE value, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "11", &value, &cancellable); + if (!g_data_output_stream_put_uint64(_SELF(self), + RVAL2GUINT64(value), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_put_string(int argc, VALUE *argv, VALUE self) +{ + VALUE value, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "11", &value, &cancellable); + if (!g_data_output_stream_put_string(_SELF(self), + RVAL2CSTR(value), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +void +Init_gdataoutputstream(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_DATA_OUTPUT_STREAM, "DataOutputStream", mGio); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(put_byte, -1); + RG_DEF_METHOD(put_int16, -1); + RG_DEF_METHOD(put_uint16, -1); + RG_DEF_METHOD(put_int32, -1); + RG_DEF_METHOD(put_uint32, -1); + RG_DEF_METHOD(put_int64, -1); + RG_DEF_METHOD(put_uint64, -1); + RG_DEF_METHOD(put_string, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiodesktopappinfo.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiodesktopappinfo.c new file mode 100644 index 0000000..5899328 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiodesktopappinfo.c @@ -0,0 +1,87 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#ifdef HAVE_GIO_UNIX +#include + +#define RG_TARGET_NAMESPACE cDesktopAppInfo +#define _SELF(value) RVAL2GDESKTOPAPPINFO(value) + +static VALUE +rg_s_new_from_filename(G_GNUC_UNUSED VALUE self, VALUE filename) +{ + return GOBJ2RVAL_UNREF(g_desktop_app_info_new_from_filename(RVAL2CSTR(filename))); +} + +static VALUE +rg_s_new_from_keyfile(G_GNUC_UNUSED VALUE self, VALUE keyfile) +{ + return GOBJ2RVAL_UNREF(g_desktop_app_info_new_from_keyfile(RVAL2GKEYFILE(keyfile))); +} + +static VALUE +rg_initialize(VALUE self, VALUE desktop_id) +{ + G_INITIALIZE(self, g_desktop_app_info_new(RVAL2CSTR(desktop_id))); + + return Qnil; +} + +static VALUE +rg_filename(VALUE self) +{ + return CSTR2RVAL(g_desktop_app_info_get_filename(_SELF(self))); +} + +static VALUE +rg_hidden_p(VALUE self) +{ + return CBOOL2RVAL(g_desktop_app_info_get_is_hidden(_SELF(self))); +} + +static VALUE +rg_s_set_desktop_env(G_GNUC_UNUSED VALUE self, VALUE desktop_env) +{ + g_desktop_app_info_set_desktop_env(RVAL2CSTR(desktop_env)); + + return self; +} + +/* TODO: g_desktop_app_info_lookup_get_default_for_uri_scheme ()? */ +#endif + +void +Init_gdesktopappinfo(G_GNUC_UNUSED VALUE mGio) +{ +#ifdef HAVE_GIO_UNIX + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_DESKTOP_APP_INFO, "DesktopAppInfo", mGio); + + RG_DEF_SMETHOD(new_from_filename, 1); + RG_DEF_SMETHOD(new_from_keyfile, 1); + RG_DEF_SMETHOD(set_desktop_env, 1); + + RG_DEF_METHOD(initialize, 1); + RG_DEF_METHOD(filename, 0); + RG_DEF_METHOD_P(hidden, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiodrive.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiodrive.c new file mode 100644 index 0000000..d6e2c28 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiodrive.c @@ -0,0 +1,266 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mDrive +#define _SELF(value) RVAL2GDRIVE(value) + +static VALUE +rg_name(VALUE self) +{ + return CSTR2RVAL_FREE(g_drive_get_name(_SELF(self))); +} + +static VALUE +rg_icon(VALUE self) +{ + return GOBJ2RVAL_UNREF(g_drive_get_icon(_SELF(self))); +} + +static VALUE +rg_has_volumes_p(VALUE self) +{ + return CBOOL2RVAL(g_drive_has_volumes(_SELF(self))); +} + +static VALUE +rg_volumes(VALUE self) +{ + return GLIST2ARY_FREE(g_drive_get_volumes(_SELF(self))); +} + +static VALUE +rg_can_eject_p(VALUE self) +{ + return CBOOL2RVAL(g_drive_can_eject(_SELF(self))); +} + +static VALUE +rg_start_stop_type(VALUE self) +{ + return GDRIVESTARTSTOPTYPE2RVAL(g_drive_get_start_stop_type(_SELF(self))); +} + +static VALUE +rg_can_start_p(VALUE self) +{ + return CBOOL2RVAL(g_drive_can_start(_SELF(self))); +} + +static VALUE +rg_can_start_degraded_p(VALUE self) +{ + return CBOOL2RVAL(g_drive_can_start_degraded(_SELF(self))); +} + +static VALUE +rg_can_stop_p(VALUE self) +{ + return CBOOL2RVAL(g_drive_can_stop(_SELF(self))); +} + +static VALUE +rg_can_poll_for_media_p(VALUE self) +{ + return CBOOL2RVAL(g_drive_can_poll_for_media(_SELF(self))); +} + +static VALUE +rg_poll_for_media(int argc, VALUE *argv, VALUE self) +{ + VALUE rbcancellable, block; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "01&", &rbcancellable, &block); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + g_drive_poll_for_media(_SELF(self), + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +typedef gboolean (*BooleanFinishMethod)(GDrive *, GAsyncResult *, GError **); + +static VALUE +boolean_finish_method(BooleanFinishMethod method, VALUE self, VALUE result) +{ + GError *error = NULL; + + if (!method(_SELF(self), RVAL2GASYNCRESULT(result), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_poll_for_media_finish(VALUE self, VALUE result) +{ + return boolean_finish_method(g_drive_poll_for_media_finish, self, result); +} + +static VALUE +rg_has_media_p(VALUE self) +{ + return CBOOL2RVAL(g_drive_has_media(_SELF(self))); +} + +static VALUE +rg_media_check_automatic_p(VALUE self) +{ + return CBOOL2RVAL(g_drive_is_media_check_automatic(_SELF(self))); +} + +static VALUE +rg_media_removable_p(VALUE self) +{ + return CBOOL2RVAL(g_drive_is_media_removable(_SELF(self))); +} + +typedef void (*EjectStopMethod)(GDrive *, + GMountUnmountFlags, + GMountOperation *, + GCancellable *, + GAsyncReadyCallback, + gpointer); + +static VALUE +eject_stop_method(EjectStopMethod method, int argc, VALUE *argv, VALUE self) +{ + VALUE rbflags, rbmount_operation, rbcancellable, block; + GMountUnmountFlags flags; + GMountOperation *mount_operation; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "03&", &rbflags, &rbmount_operation, &rbcancellable, &block); + flags = RVAL2GMOUNTUNMOUNTFLAGSDEFAULT(rbflags); + mount_operation = RVAL2GMOUNTOPERATION(rbmount_operation); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + method(_SELF(self), + flags, + mount_operation, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_eject_with_operation(int argc, VALUE *argv, VALUE self) +{ + return eject_stop_method(g_drive_eject_with_operation, argc, argv, self); +} + +static VALUE +rg_eject_with_operation_finish(VALUE self, VALUE result) +{ + return boolean_finish_method(g_drive_eject_with_operation_finish, self, result); +} + +static VALUE +rg_start(int argc, VALUE *argv, VALUE self) +{ + VALUE rbflags, rbmount_operation, rbcancellable, block; + GDriveStartFlags flags; + GMountOperation *mount_operation; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "03", &rbflags, &rbmount_operation, &rbcancellable, &block); + flags = RVAL2GDRIVESTARTFLAGSDEFAULT(rbflags); + mount_operation = RVAL2GMOUNTOPERATION(rbmount_operation); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_drive_start(_SELF(self), flags, mount_operation, cancellable, + rbgio_async_ready_callback, (gpointer)block); + + return self; +} + +static VALUE +rg_start_finish(VALUE self, VALUE result) +{ + return boolean_finish_method(g_drive_start_finish, self, result); +} + +static VALUE +rg_stop(int argc, VALUE *argv, VALUE self) +{ + return eject_stop_method(g_drive_stop, argc, argv, self); +} + +static VALUE +rg_stop_finish(VALUE self, VALUE result) +{ + return boolean_finish_method(g_drive_stop_finish, self, result); +} + +static VALUE +rg_enumerate_identifiers(VALUE self) +{ + return STRV2RVAL_FREE(g_drive_enumerate_identifiers(_SELF(self))); +} + +static VALUE +rg_get_identifier(VALUE self, VALUE kind) +{ + return CSTR2RVAL_FREE(g_drive_get_identifier(_SELF(self), RVAL2CSTR(kind))); +} + +void +Init_gdrive(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_DRIVE, "Drive", mGio); + + G_DEF_CLASS(G_TYPE_DRIVE_START_FLAGS, "StartFlags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_DRIVE_START_FLAGS, "G_DRIVE_"); + + G_DEF_CLASS(G_TYPE_DRIVE_START_STOP_TYPE, "StartStopType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_DRIVE_START_STOP_TYPE, "G_DRIVE_"); + + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(icon, 0); + RG_DEF_METHOD_P(has_volumes, 0); + RG_DEF_METHOD(volumes, 0); + RG_DEF_METHOD_P(can_eject, 0); + RG_DEF_METHOD(start_stop_type, 0); + RG_DEF_METHOD_P(can_start, 0); + RG_DEF_METHOD_P(can_start_degraded, 0); + RG_DEF_METHOD_P(can_stop, 0); + RG_DEF_METHOD_P(can_poll_for_media, 0); + RG_DEF_METHOD(poll_for_media, -1); + RG_DEF_METHOD(poll_for_media_finish, 1); + RG_DEF_METHOD_P(has_media, 0); + RG_DEF_METHOD_P(media_check_automatic, 0); + RG_DEF_METHOD_P(media_removable, 0); + RG_DEF_METHOD(eject_with_operation, -1); + RG_DEF_METHOD(eject_with_operation_finish, 1); + RG_DEF_METHOD(start, -1); + RG_DEF_METHOD(start_finish, 1); + RG_DEF_METHOD(stop, -1); + RG_DEF_METHOD(stop_finish, 1); + RG_DEF_METHOD(enumerate_identifiers, -1); + RG_DEF_ALIAS("identifiers", "enumerate_identifiers"); + RG_DEF_METHOD(get_identifier, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioemblem.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioemblem.c new file mode 100644 index 0000000..3baa35b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioemblem.c @@ -0,0 +1,52 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cEmblem + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE rbicon, origin; + GIcon *icon; + GEmblem *emblem; + + rb_scan_args(argc, argv, "11", &rbicon, &origin); + icon = RVAL2GICON(rbicon); + emblem = NIL_P(origin) ? + g_emblem_new(icon) : + g_emblem_new_with_origin(icon, RVAL2GEMBLEMORIGIN(origin)); + G_INITIALIZE(self, emblem); + + return Qnil; +} + +void +Init_gemblem(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_EMBLEM, "Emblem", mGio); + + G_DEF_CLASS(G_TYPE_EMBLEM_ORIGIN, "Origin", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_EMBLEM_ORIGIN, "G_EMBLEM_"); + + RG_DEF_METHOD(initialize, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioemblemedicon.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioemblemedicon.c new file mode 100644 index 0000000..adb209c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioemblemedicon.c @@ -0,0 +1,65 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cEmblemedIcon +#define _SELF(value) RVAL2GEMBLEMEDICON(value) + +static VALUE +rg_initialize(VALUE self, VALUE icon, VALUE emblem) +{ + G_INITIALIZE(self, g_emblemed_icon_new(RVAL2GICON(icon), RVAL2GEMBLEM(emblem))); + + return Qnil; +} + +static VALUE +rg_icon(VALUE self) +{ + return GOBJ2RVAL(g_emblemed_icon_get_icon(_SELF(self))); +} + +static VALUE +rg_emblems(VALUE self) +{ + return GLIST2ARY_FREE(g_emblemed_icon_get_emblems(_SELF(self))); +} + +static VALUE +rg_add_emblem(VALUE self, VALUE emblem) +{ + g_emblemed_icon_add_emblem(_SELF(self), RVAL2GEMBLEM(emblem)); + + return self; +} + +void +Init_gemblemedicon(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_EMBLEMED_ICON, "EmblemedIcon", mGio); + + RG_DEF_METHOD(initialize, 2); + RG_DEF_METHOD(icon, 0); + RG_DEF_METHOD(emblems, 0); + RG_DEF_METHOD(add_emblem, 1); + RG_DEF_ALIAS("<<", "add_emblem"); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofile.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofile.c new file mode 100644 index 0000000..d3f0892 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofile.c @@ -0,0 +1,2045 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mFile +#define _SELF(value) RVAL2GFILE(value) + +#define RVAL2GFILECOPYFLAGSDEFAULT(value) \ + RVAL2TYPE_WITH_DEFAULT((value), RVAL2GFILECOPYFLAGS, G_FILE_COPY_NONE) + +#define RVAL2GFILECREATEFLAGSDEFAULT(value) \ + RVAL2TYPE_WITH_DEFAULT((value), \ + RVAL2GFILECREATEFLAGS, \ + G_FILE_CREATE_NONE) + +#define RVAL2GFILEMONITORFLAGSDEFAULT(value) \ + RVAL2TYPE_WITH_DEFAULT((value), \ + RVAL2GFILEMONITORFLAGS, \ + G_FILE_MONITOR_NONE) + +#define RVAL2GFILEQUERYINFOFLAGSDEFAULT(value) \ + RVAL2TYPE_WITH_DEFAULT((value), \ + RVAL2GFILEQUERYINFOFLAGS, \ + G_FILE_QUERY_INFO_NONE) + +#define RVAL2FSATTRIBUTESDEFAULT(value) \ + RVAL2TYPE_WITH_DEFAULT((value), RVAL2CSTR, "fs::*") + +static VALUE +rg_s_new_for_path(G_GNUC_UNUSED VALUE self, VALUE value) +{ + return GOBJ2RVAL_UNREF(g_file_new_for_path(RVAL2CSTR(value))); +} + +static VALUE +rg_s_new_for_uri(G_GNUC_UNUSED VALUE self, VALUE value) +{ + return GOBJ2RVAL_UNREF(g_file_new_for_uri(RVAL2CSTR(value))); +} + +static VALUE +rg_s_new_for_commandline_arg(G_GNUC_UNUSED VALUE self, VALUE value) +{ + return GOBJ2RVAL_UNREF(g_file_new_for_commandline_arg(RVAL2CSTR(value))); +} + +static VALUE +rg_s_parse_name(G_GNUC_UNUSED VALUE self, VALUE value) +{ + return GOBJ2RVAL_UNREF(g_file_parse_name(RVAL2CSTR(value))); +} + +static VALUE +rg_dup(VALUE self) +{ + return GOBJ2RVAL_UNREF(g_file_dup(_SELF(self))); +} + +static VALUE +rg_hash(VALUE self) +{ + return GUINT2RVAL(g_file_hash(_SELF(self))); +} + +static VALUE +rg_operator_file_equal(VALUE self, VALUE other) +{ + return CBOOL2RVAL(g_file_equal(_SELF(self), _SELF(other))); +} + +static VALUE +rg_basename(VALUE self) +{ + return CSTR2RVAL_FREE(g_file_get_basename(_SELF(self))); +} + +static VALUE +rg_path(VALUE self) +{ + return CSTR2RVAL_FREE(g_file_get_path(_SELF(self))); +} + +static VALUE +rg_uri(VALUE self) +{ + return CSTR2RVAL_FREE(g_file_get_uri(_SELF(self))); +} + +static VALUE +rg_parse_name(VALUE self) +{ + return CSTR2RVAL_FREE(g_file_get_parse_name(_SELF(self))); +} + +static VALUE +rg_parent(VALUE self) +{ + return GOBJ2RVAL_UNREF(g_file_get_parent(_SELF(self))); +} + +static VALUE +rg_has_parent_p(int argc, VALUE *argv, VALUE self) +{ + VALUE parent; + + rb_scan_args(argc, argv, "01", &parent); + return CBOOL2RVAL(g_file_has_parent(_SELF(self), RVAL2GFILE(parent))); +} + +static VALUE +rg_get_child(VALUE self, VALUE name) +{ + return GOBJ2RVAL_UNREF(g_file_get_child(_SELF(self), RVAL2CSTR(name))); +} + +static VALUE +rg_get_child_for_display_name(VALUE self, VALUE name) +{ + GError *error = NULL; + GFile *file = g_file_get_child_for_display_name(_SELF(self), + RVAL2CSTR(name), + &error); + if (file == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(file); +} + +static VALUE +rg_has_prefix_p(VALUE self, VALUE prefix) +{ + return CBOOL2RVAL(g_file_has_prefix(_SELF(self), _SELF(prefix))); +} + +static VALUE +rg_get_relative_path(VALUE self, VALUE other) +{ + return CSTR2RVAL_FREE(g_file_get_relative_path(_SELF(self), _SELF(other))); +} + +static VALUE +rg_resolve_relative_path(VALUE self, VALUE path) +{ + return GOBJ2RVAL_UNREF(g_file_resolve_relative_path(_SELF(self), RVAL2CSTR(path))); +} + +static VALUE +rg_native_p(VALUE self) +{ + return CBOOL2RVAL(g_file_is_native(_SELF(self))); +} + +static VALUE +rg_has_uri_scheme_p(VALUE self, VALUE scheme) +{ + return CBOOL2RVAL(g_file_has_uri_scheme(_SELF(self), RVAL2CSTR(scheme))); +} + +static VALUE +rg_uri_scheme(VALUE self) +{ + return CSTR2RVAL_FREE(g_file_get_uri_scheme(_SELF(self))); +} + +struct file_input_stream_close_data +{ + GCancellable *cancellable; + GFileInputStream *stream; +}; + +static VALUE +file_input_stream_close(VALUE data) +{ + struct file_input_stream_close_data *real; + GError *error = NULL; + + real = (struct file_input_stream_close_data *)data; + + if (!g_input_stream_close(G_INPUT_STREAM(real->stream), + real->cancellable, + &error)) + rbgio_raise_error(error); + + return Qnil; +} + +static VALUE +rg_read(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + struct file_input_stream_close_data data; + GError *error = NULL; + + rb_scan_args(argc, argv, "01", &cancellable); + data.cancellable = RVAL2GCANCELLABLE(cancellable); + data.stream = g_file_read(_SELF(self), data.cancellable, &error); + if (data.stream == NULL) + rbgio_raise_error(error); + + if (!rb_block_given_p()) + return GOBJ2RVAL_UNREF(data.stream); + + return rb_ensure(rb_yield, GOBJ2RVAL_UNREF(data.stream), + file_input_stream_close, (VALUE)&data); +} + +static VALUE +rg_read_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbio_priority, rbcancellable, block; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_file_read_async(_SELF(self), + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_read_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + GFileInputStream *stream; + + stream = g_file_read_finish(_SELF(self), RVAL2GASYNCRESULT(result), &error); + if (stream == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(stream); +} + +typedef GFileOutputStream *(*CreateMethod)(GFile *, + GFileCreateFlags, + GCancellable *, + GError **); + +struct file_output_stream_close_data +{ + GCancellable *cancellable; + GFileOutputStream *stream; +}; + +static VALUE +file_output_stream_close(VALUE data) +{ + struct file_output_stream_close_data *real; + GError *error = NULL; + + real = (struct file_output_stream_close_data *)data; + + if (!g_output_stream_close(G_OUTPUT_STREAM(real->stream), + real->cancellable, + &error)) + rbgio_raise_error(error); + + return Qnil; +} + +static VALUE +create_method(CreateMethod method, int argc, VALUE *argv, VALUE self) +{ + VALUE flags, cancellable; + struct file_output_stream_close_data data; + GError *error = NULL; + + rb_scan_args(argc, argv, "02", &flags, &cancellable); + data.cancellable = RVAL2GCANCELLABLE(cancellable); + data.stream = method(_SELF(self), + RVAL2GFILECREATEFLAGSDEFAULT(flags), + data.cancellable, + &error); + if (data.stream == NULL) + rbgio_raise_error(error); + + if (!rb_block_given_p()) + return GOBJ2RVAL_UNREF(data.stream); + + return rb_ensure(rb_yield, GOBJ2RVAL_UNREF(data.stream), + file_output_stream_close, (VALUE)&data); +} + +static VALUE +rg_append_to(int argc, VALUE *argv, VALUE self) +{ + return create_method(g_file_append_to, argc, argv, self); +} + +static VALUE +rg_create(int argc, VALUE *argv, VALUE self) +{ + return create_method(g_file_create, argc, argv, self); +} + +static VALUE +rg_replace(int argc, VALUE *argv, VALUE self) +{ + VALUE etag, make_backup, flags, cancellable; + struct file_output_stream_close_data data; + GError *error = NULL; + + rb_scan_args(argc, argv, "04", &etag, &make_backup, &flags, &cancellable); + data.cancellable = RVAL2GCANCELLABLE(cancellable); + data.stream = g_file_replace(_SELF(self), + RVAL2CSTR_ACCEPT_NIL(etag), + RVAL2CBOOL(make_backup), + RVAL2GFILECREATEFLAGSDEFAULT(flags), + data.cancellable, + &error); + if (data.stream == NULL) + rbgio_raise_error(error); + + if (!rb_block_given_p()) + return GOBJ2RVAL_UNREF(data.stream); + + return rb_ensure(rb_yield, GOBJ2RVAL_UNREF(data.stream), + file_output_stream_close, (VALUE)&data); +} + +typedef void (*CreateAsyncMethod)(GFile *, GFileCreateFlags, int, + GCancellable *, GAsyncReadyCallback, + gpointer); + +static VALUE +create_async_method(CreateAsyncMethod method, int argc, VALUE *argv, VALUE self) +{ + VALUE rbflags, rbio_priority, rbcancellable, block; + GFileCreateFlags flags; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "03&", &rbflags, &rbio_priority, &rbcancellable, &block); + flags = RVAL2GFILECREATEFLAGSDEFAULT(rbflags); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + method(_SELF(self), + flags, + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_append_to_async(int argc, VALUE *argv, VALUE self) +{ + return create_async_method(g_file_append_to_async, argc, argv, self); +} + +typedef GFileOutputStream *(*WriteFinishMethod)(GFile *, GAsyncResult *, GError **); + +static VALUE +write_finish_method(WriteFinishMethod method, VALUE self, VALUE result) +{ + GError *error = NULL; + GFileOutputStream *stream; + + stream = method(_SELF(self), RVAL2GASYNCRESULT(result), &error); + if (stream == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(stream); +} + +static VALUE +rg_append_to_finish(VALUE self, VALUE result) +{ + return write_finish_method(g_file_append_to_finish, self, result); +} + +static VALUE +rg_create_async(int argc, VALUE *argv, VALUE self) +{ + return create_async_method(g_file_create_async, argc, argv, self); +} + +static VALUE +rg_create_finish(VALUE self, VALUE result) +{ + return write_finish_method(g_file_create_finish, self, result); +} + +typedef void (*ReplaceAsyncMethod)(GFile *, + const char *, + gboolean, + GFileCreateFlags, + int, + GCancellable *, + GAsyncReadyCallback, + gpointer); + +static VALUE +replace_async_method(ReplaceAsyncMethod method, int argc, VALUE *argv, VALUE self) +{ + VALUE rbetag, rbmake_backup, rbflags, rbio_priority, rbcancellable, block; + const char *etag; + gboolean make_backup; + GFileCreateFlags flags; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "05&", &rbetag, &rbmake_backup, &rbflags, &rbio_priority, &rbcancellable, &block); + etag = RVAL2CSTR_ACCEPT_NIL(rbetag); + make_backup = RVAL2CBOOL(rbmake_backup); + flags = RVAL2GFILECREATEFLAGSDEFAULT(rbflags); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + method(_SELF(self), + etag, + make_backup, + flags, + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_replace_async(int argc, VALUE *argv, VALUE self) +{ + return replace_async_method(g_file_replace_async, argc, argv, self); +} + +static VALUE +rg_replace_finish(VALUE self, VALUE result) +{ + return write_finish_method(g_file_replace_finish, self, result); +} + +static VALUE +rg_query_info(int argc, VALUE *argv, VALUE self) +{ + VALUE attributes, flags, cancellable; + GError *error = NULL; + GFileInfo *info; + + rb_scan_args(argc, argv, "03", &attributes, &flags, &cancellable); + info = g_file_query_info(_SELF(self), + RVAL2ATTRIBUTESDEFAULT(attributes), + RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags), + RVAL2GCANCELLABLE(cancellable), + &error); + if (info == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(info); +} + +static VALUE +rg_query_info_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbattributes, rbflags, rbio_priority, rbcancellable, block; + const char *attributes; + GFileQueryInfoFlags flags; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "04&", &rbattributes, &rbflags, &rbio_priority, &rbcancellable, &block); + attributes = RVAL2ATTRIBUTESDEFAULT(rbattributes); + flags = RVAL2GFILEQUERYINFOFLAGSDEFAULT(rbflags); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_file_query_info_async(_SELF(self), + attributes, + flags, + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_query_info_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + + GFileInfo *info = g_file_query_info_finish(_SELF(self), RVAL2GASYNCRESULT(result), &error); + if (info == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(info); +} + +static VALUE +rg_query_exists_p(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + + rb_scan_args(argc, argv, "01", &cancellable); + + return CBOOL2RVAL(g_file_query_exists(_SELF(self), RVAL2GCANCELLABLE(cancellable))); +} + +static VALUE +rg_query_file_type(int argc, VALUE *argv, VALUE self) +{ + VALUE flags, cancellable; + + rb_scan_args(argc, argv, "02", &flags, &cancellable); + + return GFILETYPE2RVAL(g_file_query_file_type(_SELF(self), + RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags), + RVAL2GCANCELLABLE(cancellable))); +} + +static VALUE +rg_query_filesystem_info(int argc, VALUE *argv, VALUE self) +{ + VALUE attributes, cancellable; + GError *error = NULL; + GFileInfo *info; + + rb_scan_args(argc, argv, "02", &attributes, &cancellable); + info = g_file_query_filesystem_info(_SELF(self), + RVAL2FSATTRIBUTESDEFAULT(attributes), + RVAL2GCANCELLABLE(cancellable), + &error); + if (info == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(info); +} + +static VALUE +rg_query_filesystem_info_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbattributes, rbio_priority, rbcancellable, block; + const char *attributes; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "03&", &rbattributes, &rbio_priority, &rbcancellable, &block); + attributes = RVAL2FSATTRIBUTESDEFAULT(rbattributes); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_file_query_filesystem_info_async(_SELF(self), + attributes, + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_query_filesystem_info_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + GFileInfo *info; + + info = g_file_query_filesystem_info_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &error); + if (info == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(info); +} + +static VALUE +rg_query_default_handler(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + GAppInfo *info; + + rb_scan_args(argc, argv, "01", &cancellable); + info = g_file_query_default_handler(_SELF(self), + RVAL2GCANCELLABLE(cancellable), + &error); + if (info == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(info); +} + +static VALUE +rg_find_enclosing_mount(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + GMount *mount; + + rb_scan_args(argc, argv, "01", &cancellable); + mount = g_file_find_enclosing_mount(_SELF(self), + RVAL2GCANCELLABLE(cancellable), + &error); + if (mount == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(mount); +} + +static VALUE +rg_find_enclosing_mount_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbio_priority, rbcancellable, block; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_file_find_enclosing_mount_async(_SELF(self), + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_find_enclosing_mount_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + + GMount *mount = g_file_find_enclosing_mount_finish(_SELF(self), RVAL2GASYNCRESULT(result), &error); + if (mount == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(mount); +} + +struct file_enumerator_each_data +{ + GCancellable *cancellable; + GFileEnumerator *enumerator; +}; + +static VALUE +file_enumerator_each(VALUE data) +{ + struct file_enumerator_each_data *real; + GError *error = NULL; + + real = (struct file_enumerator_each_data *)data; + + while (TRUE) { + GFileInfo *info = g_file_enumerator_next_file(real->enumerator, + real->cancellable, + &error); + if (error != NULL) + rbgio_raise_error(error); + + if (info == NULL) + break; + + rb_yield(GOBJ2RVAL_UNREF(info)); + } + + return Qnil; +} + +static VALUE +file_enumerator_each_ensure(VALUE data) +{ + struct file_enumerator_each_data *real; + GError *error = NULL; + + real = (struct file_enumerator_each_data *)data; + + if (!g_file_enumerator_close(real->enumerator, + real->cancellable, + &error)) { + g_object_unref(real->enumerator); + rbgio_raise_error(error); + } + + g_object_unref(real->enumerator); + + return Qnil; +} + +static VALUE +rg_enumerate_children(int argc, VALUE *argv, VALUE self) +{ + VALUE attributes, flags, cancellable; + struct file_enumerator_each_data data; + GError *error = NULL; + + rb_scan_args(argc, argv, "03", &attributes, &flags, &cancellable); + data.cancellable = RVAL2GCANCELLABLE(cancellable); + data.enumerator = g_file_enumerate_children(_SELF(self), + RVAL2ATTRIBUTESDEFAULT(attributes), + RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags), + data.cancellable, + &error); + if (data.enumerator == NULL) + rbgio_raise_error(error); + + if (!rb_block_given_p()) + return GOBJ2RVAL_UNREF(data.enumerator); + + rb_ensure(file_enumerator_each, (VALUE)&data, + file_enumerator_each_ensure, (VALUE)&data); + + return self; +} + +static VALUE +rg_enumerate_children_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbattributes, rbflags, rbio_priority, rbcancellable, block; + const char *attributes; + GFileQueryInfoFlags flags; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "04&", &rbattributes, &rbflags, &rbio_priority, &rbcancellable, &block); + attributes = RVAL2ATTRIBUTESDEFAULT(rbattributes); + flags = RVAL2GFILEQUERYINFOFLAGSDEFAULT(rbflags); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_file_enumerate_children_async(_SELF(self), + attributes, + flags, + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_enumerate_children_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + GFileEnumerator *enumerator; + + enumerator = g_file_enumerate_children_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &error); + if (enumerator == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(enumerator); +} + +static VALUE +rg_set_display_name(int argc, VALUE *argv, VALUE self) +{ + VALUE display_name, cancellable; + GError *error = NULL; + GFile *file; + + rb_scan_args(argc, argv, "11", &display_name, &cancellable); + + file = g_file_set_display_name(_SELF(self), + RVAL2CSTR(display_name), + RVAL2GCANCELLABLE(cancellable), + &error); + if (file == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(file); +} + +static VALUE +rg_set_display_name_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbdisplay_name, rbio_priority, rbcancellable, block; + const char *display_name; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "03&", &rbdisplay_name, &rbio_priority, &rbcancellable, &block); + display_name = RVAL2CSTR(rbdisplay_name); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_file_set_display_name_async(_SELF(self), + display_name, + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_set_display_name_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + GFileInfo *info; + + info = g_file_query_filesystem_info_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &error); + if (info == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(info); +} + +typedef gboolean (*CancellableMethod)(GFile *, GCancellable *, GError **); + +static VALUE +cancellable_method(CancellableMethod method, int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "01", &cancellable); + if (!method(_SELF(self), RVAL2GCANCELLABLE(cancellable), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_delete(int argc, VALUE *argv, VALUE self) +{ + return cancellable_method(g_file_delete, argc, argv, self); +} + +static VALUE +rg_trash(int argc, VALUE *argv, VALUE self) +{ + return cancellable_method(g_file_trash, argc, argv, self); +} + +struct progress_callback_data +{ + goffset current_num_bytes; + goffset total_num_bytes; + gpointer data; +}; + +static VALUE +progress_callback_call(VALUE data) +{ + static ID s_id_call; + struct progress_callback_data *real; + VALUE block; + + if (s_id_call == 0) + s_id_call = rb_intern("call"); + + real = (struct progress_callback_data *)data; + block = USE_BLOCK_AND_SAVE(real->data); + if (!NIL_P(block)) + rb_funcall(block, s_id_call, 2, + GOFFSET2RVAL(real->current_num_bytes), + GOFFSET2RVAL(real->total_num_bytes)); + + return Qnil; +} + +static void +progress_callback(goffset current_num_bytes, goffset total_num_bytes, gpointer data) +{ + struct progress_callback_data real; + + real.current_num_bytes = current_num_bytes; + real.total_num_bytes = total_num_bytes; + real.data = data; + + G_PROTECT_CALLBACK(progress_callback_call, &real); +} + +typedef gboolean (*CopyMoveMethod)(GFile *, + GFile *, + GFileCopyFlags, + GCancellable *, + GFileProgressCallback, + gpointer, + GError **); + +static VALUE +copy_move_method(CopyMoveMethod method, int argc, VALUE *argv, VALUE self) +{ + VALUE rbdestination, rbflags, rbcancellable, block; + GFile *destination; + GFileCopyFlags flags; + GCancellable *cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "12&", &rbdestination, &rbflags, &rbcancellable, &block); + destination = _SELF(rbdestination); + flags = RVAL2GFILECOPYFLAGSDEFAULT(rbflags); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + if (!method(_SELF(self), + destination, + flags, + cancellable, + NIL_P(block) ? NULL : progress_callback, + (gpointer)block, + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_copy(int argc, VALUE *argv, VALUE self) +{ + return copy_move_method(g_file_copy, argc, argv, self); +} + +static VALUE +rg_copy_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbdestination, rbflags, rbio_priority, rbcancellable, block; + GFile *destination; + GFileCopyFlags flags; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "13&", &rbdestination, &rbflags, &rbio_priority, &rbcancellable, &block); + destination = _SELF(rbdestination); + flags = RVAL2GFILECOPYFLAGSDEFAULT(rbflags); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + /* NOTE: This requires the block to take a variable number of + * arguments. It will be two integer values for the progress part and + * a GLib::AsyncResult when done. */ + g_file_copy_async(_SELF(self), + destination, + flags, + io_priority, + cancellable, + NIL_P(block) ? NULL : progress_callback, + (gpointer)block, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +typedef gboolean (*BooleanFinishMethod)(GFile *, GAsyncResult *, GError **); + +static VALUE +boolean_finish_method(BooleanFinishMethod method, VALUE self, VALUE result) +{ + GError *error = NULL; + + if (!method(_SELF(self), RVAL2GASYNCRESULT(result), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_copy_finish(VALUE self, VALUE result) +{ + return boolean_finish_method(g_file_copy_finish, self, result); +} + +static VALUE +rg_move(int argc, VALUE *argv, VALUE self) +{ + return copy_move_method(g_file_move, argc, argv, self); +} + +static VALUE +rg_make_directory(int argc, VALUE *argv, VALUE self) +{ + return cancellable_method(g_file_make_directory, argc, argv, self); +} + +static VALUE +rg_make_directory_with_parents(int argc, VALUE *argv, VALUE self) +{ + return cancellable_method(g_file_make_directory_with_parents, argc, argv, self); +} + +static VALUE +rg_make_symbolic_link(int argc, VALUE *argv, VALUE self) +{ + VALUE symlink_value, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "11", &symlink_value, &cancellable); + if (!g_file_make_symbolic_link(_SELF(self), + RVAL2CSTR(symlink_value), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +typedef GFileAttributeInfoList *(*QueryAttributesMethod)(GFile *, + GCancellable *, + GError **); + +static VALUE +query_attributes_method(QueryAttributesMethod method, + int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + GFileAttributeInfoList *list; + + rb_scan_args(argc, argv, "01", &cancellable); + list = method(_SELF(self), RVAL2GCANCELLABLE(cancellable), &error); + if (list == NULL) + rbgio_raise_error(error); + + return GFILEATTRIBUTEINFOLIST2RVAL(list); +} + +static VALUE +rg_query_settable_attributes(int argc, VALUE *argv, VALUE self) +{ + return query_attributes_method(g_file_query_settable_attributes, + argc, argv, self); +} + +static VALUE +rg_query_writable_namespaces(int argc, VALUE *argv, VALUE self) +{ + return query_attributes_method(g_file_query_writable_namespaces, + argc, argv, self); +} + +static VALUE +rg_set_attribute(int argc, VALUE *argv, VALUE self) +{ + VALUE rbattribute, rbtype, rbvalue, rbflags, rbcancellable; + const char *attribute; + GFileAttributeType type; + gpointer value; + gboolean gboolean_value; + guint32 guint32_value; + gint32 gint32_value; + guint64 guint64_value; + gint64 gint64_value; + const char **stringv_value = NULL; + GFileQueryInfoFlags flags; + GCancellable *cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "32", &rbattribute, &rbtype, &rbvalue, &rbflags, &rbcancellable); + attribute = RVAL2CSTR(rbattribute); + type = RVAL2GFILEATTRIBUTETYPE(rbtype); + flags = RVAL2GFILEQUERYINFOFLAGSDEFAULT(rbflags); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + + switch (type) { + case G_FILE_ATTRIBUTE_TYPE_STRING: + case G_FILE_ATTRIBUTE_TYPE_BYTE_STRING: + value = (gpointer)RVAL2CSTR(rbvalue); + break; + case G_FILE_ATTRIBUTE_TYPE_BOOLEAN: + gboolean_value = RVAL2CBOOL(rbvalue); + value = &gboolean_value; + break; + case G_FILE_ATTRIBUTE_TYPE_UINT32: + guint32_value = RVAL2GUINT32(rbvalue); + value = &guint32_value; + break; + case G_FILE_ATTRIBUTE_TYPE_INT32: + gint32_value = RVAL2GINT32(rbvalue); + value = &gint32_value; + break; + case G_FILE_ATTRIBUTE_TYPE_UINT64: + guint64_value = RVAL2GUINT64(rbvalue); + value = &guint64_value; + break; + case G_FILE_ATTRIBUTE_TYPE_INT64: + gint64_value = RVAL2GINT64(rbvalue); + value = &gint64_value; + break; + case G_FILE_ATTRIBUTE_TYPE_OBJECT: + value = RVAL2GOBJ(rbvalue); + break; + case G_FILE_ATTRIBUTE_TYPE_STRINGV: + stringv_value = RVAL2STRV(rbvalue); + value = (gpointer)stringv_value; + break; + case G_FILE_ATTRIBUTE_TYPE_INVALID: + default: + rb_raise(rb_eArgError, "Unknown file attribute type: %d", type); + } + + g_file_set_attribute(_SELF(self), + attribute, + type, + value, + flags, + cancellable, + &error); + g_free(stringv_value); + if (error != NULL) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_set_attributes_from_info(int argc, VALUE *argv, VALUE self) +{ + VALUE info, flags, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "12", &info, &flags, &cancellable); + if (!g_file_set_attributes_from_info(_SELF(self), + RVAL2GFILEINFO(info), + RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_set_attributes_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbinfo, rbflags, rbio_priority, rbcancellable, block; + GFileInfo *info; + GFileQueryInfoFlags flags; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "13&", &rbinfo, &rbflags, &rbio_priority, &rbcancellable, &block); + info = RVAL2GFILEINFO(rbinfo); + flags = RVAL2GFILEQUERYINFOFLAGSDEFAULT(rbflags); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_file_set_attributes_async(_SELF(self), + info, + flags, + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_set_attributes_finish(VALUE self, VALUE result) +{ + GFileInfo *info; + GError *error = NULL; + + if (!g_file_set_attributes_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &info, + &error)) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(info); +} + +static VALUE +rg_set_attribute_string(int argc, VALUE *argv, VALUE self) +{ + VALUE attribute, value, flags, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "22", &attribute, &value, &flags, &cancellable); + if (!g_file_set_attribute_string(_SELF(self), + RVAL2CSTR(attribute), + RVAL2CSTR(value), + RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_set_attribute_byte_string(int argc, VALUE *argv, VALUE self) +{ + VALUE attribute, value, flags, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "22", &attribute, &value, &flags, &cancellable); + if (!g_file_set_attribute_byte_string(_SELF(self), + RVAL2CSTR(attribute), + RVAL2CSTR(value), + RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_set_attribute_uint32(int argc, VALUE *argv, VALUE self) +{ + VALUE attribute, value, flags, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "22", &attribute, &value, &flags, &cancellable); + if (!g_file_set_attribute_uint32(_SELF(self), + RVAL2CSTR(attribute), + RVAL2GUINT32(value), + RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_set_attribute_int32(int argc, VALUE *argv, VALUE self) +{ + VALUE attribute, value, flags, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "22", &attribute, &value, &flags, &cancellable); + if (!g_file_set_attribute_int32(_SELF(self), + RVAL2CSTR(attribute), + RVAL2GINT32(value), + RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_set_attribute_uint64(int argc, VALUE *argv, VALUE self) +{ + VALUE attribute, value, flags, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "22", &attribute, &value, &flags, &cancellable); + if (!g_file_set_attribute_uint64(_SELF(self), + RVAL2CSTR(attribute), + RVAL2GUINT64(value), + RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_set_attribute_int64(int argc, VALUE *argv, VALUE self) +{ + VALUE attribute, value, flags, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "22", &attribute, &value, &flags, &cancellable); + if (!g_file_set_attribute_int64(_SELF(self), + RVAL2CSTR(attribute), + RVAL2GINT64(value), + RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +typedef void (*MountMethod)(GFile *, + GMountMountFlags, + GMountOperation *, + GCancellable *, + GAsyncReadyCallback, + gpointer); + +static VALUE +mount_method(MountMethod method, int argc, VALUE *argv, VALUE self) +{ + VALUE rbflags, rbmount_operation, rbcancellable, block; + GMountMountFlags flags; + GMountOperation *mount_operation; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "03&", &rbflags, &rbmount_operation, &rbcancellable, &block); + flags = RVAL2GMOUNTMOUNTFLAGSDEFAULT(rbflags); + mount_operation = RVAL2GMOUNTOPERATION(rbmount_operation); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + method(_SELF(self), + flags, + mount_operation, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_mount_mountable(int argc, VALUE *argv, VALUE self) +{ + return mount_method(g_file_mount_mountable, argc, argv, self); +} + +static VALUE +rg_mount_mountable_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + GFile *file; + + file = g_file_mount_mountable_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &error); + if (file == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(file); +} + +typedef void (*UnmountEjectStopMountableMethod)(GFile *, + GMountUnmountFlags, + GMountOperation *, + GCancellable *, + GAsyncReadyCallback, + gpointer); + +static VALUE +unmount_eject_stop_mountable_method(UnmountEjectStopMountableMethod method, + int argc, VALUE *argv, VALUE self) +{ + VALUE rbflags, rbmount_operation, rbcancellable, block; + GMountUnmountFlags flags; + GMountOperation *mount_operation; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "03&", &rbflags, &rbmount_operation, &rbcancellable, &block); + flags = RVAL2GMOUNTUNMOUNTFLAGSDEFAULT(rbflags); + mount_operation = RVAL2GMOUNTOPERATION(rbmount_operation); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + method(_SELF(self), + flags, + mount_operation, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_unmount_mountable_with_operation(int argc, VALUE *argv, VALUE self) +{ + return unmount_eject_stop_mountable_method(g_file_unmount_mountable_with_operation, + argc, argv, self); +} + +static VALUE +rg_unmount_mountable_with_operation_finish(VALUE self, VALUE result) +{ + return boolean_finish_method(g_file_unmount_mountable_with_operation_finish, self, result); +} + +static VALUE +rg_eject_mountable_with_operation(int argc, VALUE *argv, VALUE self) +{ + return unmount_eject_stop_mountable_method(g_file_eject_mountable_with_operation, + argc, argv, self); +} + +static VALUE +rg_eject_mountable_with_operation_finish(VALUE self, VALUE result) +{ + return boolean_finish_method(g_file_eject_mountable_with_operation_finish, self, result); +} + +static VALUE +rg_start_mountable(int argc, VALUE *argv, VALUE self) +{ + VALUE rbflags, rbstart_operation, rbcancellable, block; + GDriveStartFlags flags; + GMountOperation *start_operation; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "03&", &rbflags, &rbstart_operation, &rbcancellable, &block); + flags = RVAL2GDRIVESTARTFLAGSDEFAULT(rbflags); + start_operation = RVAL2GMOUNTOPERATION(rbstart_operation); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_file_start_mountable(_SELF(self), + flags, + start_operation, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_start_mountable_finish(VALUE self, VALUE result) +{ + return boolean_finish_method(g_file_start_mountable_finish, self, result); +} + +static VALUE +rg_stop_mountable(int argc, VALUE *argv, VALUE self) +{ + return unmount_eject_stop_mountable_method(g_file_stop_mountable, + argc, argv, self); +} + +static VALUE +rg_stop_mountable_finish(VALUE self, VALUE result) +{ + return boolean_finish_method(g_file_stop_mountable_finish, self, result); +} + +typedef void (*CancellableAsyncMethod)(GFile *, + GCancellable *, + GAsyncReadyCallback, + gpointer); + +static VALUE +cancellable_async_method(CancellableAsyncMethod method, int argc, VALUE *argv, VALUE self) +{ + VALUE rbcancellable, block; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "01&", &rbcancellable, &block); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + method(_SELF(self), cancellable, rbgio_async_ready_callback, (gpointer)block); + + return self; +} + +static VALUE +rg_poll_mountable(int argc, VALUE *argv, VALUE self) +{ + return cancellable_async_method(g_file_poll_mountable, argc, argv, self); +} + +static VALUE +rg_poll_mountable_finish(VALUE self, VALUE result) +{ + return boolean_finish_method(g_file_poll_mountable_finish, self, result); +} + +static VALUE +rg_mount_enclosing_volume(int argc, VALUE *argv, VALUE self) +{ + return mount_method(g_file_mount_enclosing_volume, argc, argv, self); +} + +static VALUE +rg_mount_enclosing_volume_finish(VALUE self, VALUE result) +{ + return boolean_finish_method(g_file_mount_enclosing_volume_finish, self, result); +} + +typedef GFileMonitor *(*MonitorMethod)(GFile *, + GFileMonitorFlags, + GCancellable *, + GError **); + +static VALUE +monitor_method(MonitorMethod method, int argc, VALUE *argv, VALUE self) +{ + VALUE flags, cancellable; + GError *error = NULL; + GFileMonitor *monitor; + + rb_scan_args(argc, argv, "02", &flags, &cancellable); + monitor = method(_SELF(self), + RVAL2GFILEMONITORFLAGSDEFAULT(flags), + RVAL2GCANCELLABLE(cancellable), + &error); + if (monitor == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(monitor); +} + +static VALUE +rg_monitor_directory(int argc, VALUE *argv, VALUE self) +{ + return monitor_method(g_file_monitor_directory, argc, argv, self); +} + +static VALUE +rg_monitor_file(int argc, VALUE *argv, VALUE self) +{ + return monitor_method(g_file_monitor_file, argc, argv, self); +} + +static VALUE +rg_monitor(int argc, VALUE *argv, VALUE self) +{ + return monitor_method(g_file_monitor, argc, argv, self); +} + +static VALUE +rg_load_contents(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + char *contents; + gsize length; + char *etag_out; + GError *error = NULL; + + rb_scan_args(argc, argv, "01", &cancellable); + if (!g_file_load_contents(_SELF(self), + RVAL2GCANCELLABLE(cancellable), + &contents, + &length, + &etag_out, + &error)) + rbgio_raise_error(error); + + return rb_assoc_new(CSTR2RVAL_TAINTED_FREE(contents, length), + CSTR2RVAL_FREE(etag_out)); +} + +static VALUE +rg_load_contents_async(int argc, VALUE *argv, VALUE self) +{ + return cancellable_async_method(g_file_load_contents_async, argc, argv, self); +} + +static VALUE +rg_load_contents_finish(VALUE self, VALUE result) +{ + char *contents; + gsize length; + char *etag_out; + GError *error = NULL; + + if (!g_file_load_contents_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &contents, + &length, + &etag_out, + &error)) + rbgio_raise_error(error); + + return rb_assoc_new(CSTR2RVAL_TAINTED_FREE(contents, length), + CSTR2RVAL_FREE(etag_out)); +} + +struct load_partial_contents_async_read_more_callback_data +{ + const char *file_contents; + goffset file_size; + gpointer data; +}; + +static VALUE +load_partial_contents_async_read_more_callback_call(VALUE data) +{ + static ID s_id_call; + struct load_partial_contents_async_read_more_callback_data *real; + VALUE block; + + if (s_id_call == 0) + s_id_call = rb_intern("call"); + + real = (struct load_partial_contents_async_read_more_callback_data *)data; + block = USE_BLOCK_AND_SAVE(real->data); + if (NIL_P(block)) + return Qtrue; + + return rb_funcall(block, s_id_call, 1, + CSTR2RVAL_TAINTED(real->file_contents, + real->file_size)); +} + +static gboolean +load_partial_contents_async_read_more_callback(const char *file_contents, + goffset file_size, + gpointer data) +{ + struct load_partial_contents_async_read_more_callback_data real; + + real.file_contents = file_contents; + real.file_size = file_size; + real.data = data; + + return RVAL2CBOOL(G_PROTECT_CALLBACK(load_partial_contents_async_read_more_callback_call, + &real)); +} + +static VALUE +rg_load_partial_contents_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbcancellable, rbuse_read_more_callback, block; + GCancellable *cancellable; + gboolean use_read_more_callback; + + rb_scan_args(argc, argv, "02&", &rbcancellable, &rbuse_read_more_callback, &block); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + use_read_more_callback = RVAL2CBOOL(rbuse_read_more_callback); + SAVE_BLOCK(block); + /* TODO: Should we force a block if use_read_more_callback is true? */ + g_file_load_partial_contents_async(_SELF(self), + cancellable, + use_read_more_callback ? + load_partial_contents_async_read_more_callback : + NULL, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_load_partial_contents_finish(VALUE self, VALUE result) +{ + char *contents; + gsize length; + char *etag_out; + GError *error = NULL; + + if (!g_file_load_partial_contents_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &contents, + &length, + &etag_out, + &error)) + rbgio_raise_error(error); + + return rb_assoc_new(CSTR2RVAL_TAINTED_FREE(contents, length), + CSTR2RVAL_FREE(etag_out)); +} + +static VALUE +rg_replace_contents(int argc, VALUE *argv, VALUE self) +{ + VALUE rbcontents, etag, make_backup, flags, cancellable; + const char *contents; + char *new_etag; + GError *error = NULL; + + rb_scan_args(argc, argv, "14", &rbcontents, &etag, &make_backup, &flags, &cancellable); + contents = RVAL2CSTR(rbcontents); + if (!g_file_replace_contents(_SELF(self), + contents, + (gsize)RSTRING_LEN(rbcontents), + RVAL2CSTR_ACCEPT_NIL(etag), + RVAL2CBOOL(make_backup), + RVAL2GFILECREATEFLAGSDEFAULT(flags), + &new_etag, + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return CSTR2RVAL_FREE(new_etag); +} + +static VALUE +rg_replace_contents_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbcontents, rbetag, rbmake_backup, rbflags, rbcancellable, block; + const char *contents; + gsize length; + const char *etag; + gboolean make_backup; + GFileCreateFlags flags; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "14&", &rbcontents, &rbetag, &rbmake_backup, &rbflags, &rbcancellable, &block); + contents = RVAL2CSTR(rbcontents); + length = RSTRING_LEN(rbcontents); + etag = RVAL2CSTR_ACCEPT_NIL(rbetag); + make_backup = RVAL2CBOOL(rbmake_backup); + flags = RVAL2GFILECREATEFLAGSDEFAULT(rbflags); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_file_replace_contents_async(_SELF(self), + contents, + length, + etag, + make_backup, + flags, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_replace_contents_finish(VALUE self, VALUE result) +{ + char *new_etag; + GError *error = NULL; + + if (!g_file_replace_contents_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &new_etag, + &error)) + rbgio_raise_error(error); + + return CSTR2RVAL_FREE(new_etag); +} + +static VALUE +rg_copy_attributes(int argc, VALUE *argv, VALUE self) +{ + VALUE destination, flags, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "12", &destination, &flags, &cancellable); + if (!g_file_copy_attributes(_SELF(self), + _SELF(destination), + RVAL2GFILECOPYFLAGSDEFAULT(flags), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +struct file_io_stream_close_data +{ + GCancellable *cancellable; + GFileIOStream *stream; +}; + +static VALUE +file_io_stream_close(VALUE data) +{ + struct file_io_stream_close_data *real; + GError *error = NULL; + + real = (struct file_io_stream_close_data *)data; + + if (!g_io_stream_close(G_IO_STREAM(real->stream), + real->cancellable, + &error)) + rbgio_raise_error(error); + + return Qnil; +} + +static VALUE +rg_create_readwrite(int argc, VALUE *argv, VALUE self) +{ + VALUE flags, cancellable; + struct file_io_stream_close_data data; + GError *error = NULL; + + rb_scan_args(argc, argv, "02", &flags, &cancellable); + data.cancellable = RVAL2GCANCELLABLE(cancellable); + data.stream = g_file_create_readwrite(_SELF(self), + RVAL2GFILECREATEFLAGSDEFAULT(flags), + data.cancellable, + &error); + if (data.stream == NULL) + rbgio_raise_error(error); + + if (!rb_block_given_p()) + return GOBJ2RVAL_UNREF(data.stream); + + return rb_ensure(rb_yield, GOBJ2RVAL_UNREF(data.stream), + file_io_stream_close, (VALUE)&data); +} + +static VALUE +rg_create_readwrite_async(int argc, VALUE *argv, VALUE self) +{ + return create_async_method(g_file_create_readwrite_async, argc, argv, self); +} + +typedef GFileIOStream *(*ReadwriteFinishMethod)(GFile *, GAsyncResult *, GError **); + +static VALUE +readwrite_finish_method(ReadwriteFinishMethod method, VALUE self, VALUE result) +{ + GError *error = NULL; + + GFileIOStream *stream = method(_SELF(self), RVAL2GASYNCRESULT(result), &error); + if (stream == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(stream); +} + +static VALUE +rg_create_readwrite_finish(VALUE self, VALUE result) +{ + return readwrite_finish_method(g_file_create_readwrite_finish, self, result); +} + +static VALUE +rg_open_readwrite(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + struct file_io_stream_close_data data; + GError *error = NULL; + + rb_scan_args(argc, argv, "01", &cancellable); + data.cancellable = RVAL2GCANCELLABLE(cancellable); + data.stream = g_file_open_readwrite(_SELF(self), + data.cancellable, + &error); + if (data.stream == NULL) + rbgio_raise_error(error); + + if (!rb_block_given_p()) + return GOBJ2RVAL_UNREF(data.stream); + + return rb_ensure(rb_yield, GOBJ2RVAL_UNREF(data.stream), + file_io_stream_close, (VALUE)&data); +} + +static VALUE +rg_open_readwrite_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbio_priority, rbcancellable, block; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_file_open_readwrite_async(_SELF(self), io_priority, cancellable, + rbgio_async_ready_callback, (gpointer)block); + + return self; +} + +static VALUE +rg_open_readwrite_finish(VALUE self, VALUE result) +{ + return readwrite_finish_method(g_file_open_readwrite_finish, self, result); +} + +static VALUE +rg_replace_readwrite(int argc, VALUE *argv, VALUE self) +{ + VALUE etag, make_backup, flags, cancellable; + struct file_io_stream_close_data data; + GError *error = NULL; + + rb_scan_args(argc, argv, "04", &etag, &make_backup, &flags, &cancellable); + data.cancellable = RVAL2GCANCELLABLE(cancellable); + data.stream = g_file_replace_readwrite(_SELF(self), + RVAL2CSTR_ACCEPT_NIL(etag), + RVAL2CBOOL(make_backup), + RVAL2GFILECREATEFLAGSDEFAULT(flags), + data.cancellable, + &error); + if (data.stream == NULL) + rbgio_raise_error(error); + + if (!rb_block_given_p()) + return GOBJ2RVAL_UNREF(data.stream); + + return rb_ensure(rb_yield, GOBJ2RVAL_UNREF(data.stream), + file_io_stream_close, (VALUE)&data); +} + +static VALUE +rg_replace_readwrite_async(int argc, VALUE *argv, VALUE self) +{ + return replace_async_method(g_file_replace_readwrite_async, argc, argv, self); +} + +static VALUE +rg_replace_readwrite_finish(VALUE self, VALUE result) +{ + return readwrite_finish_method(g_file_replace_readwrite_finish, self, result); +} + +static VALUE +rg_supports_thread_contexts_p(VALUE self) +{ + return CBOOL2RVAL(g_file_supports_thread_contexts(_SELF(self))); +} + +void +Init_gfile(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_FILE, "File", mGio); + + G_DEF_CLASS(G_TYPE_FILE_QUERY_INFO_FLAGS, "QueryInfoFlags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_FILE_QUERY_INFO_FLAGS, "G_FILE_"); + + G_DEF_CLASS(G_TYPE_FILE_CREATE_FLAGS, "CreateFlags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_FILE_CREATE_FLAGS, "G_FILE_"); + + G_DEF_CLASS(G_TYPE_FILE_COPY_FLAGS, "CopyFlags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_FILE_COPY_FLAGS, "G_FILE_"); + + G_DEF_CLASS(G_TYPE_FILE_MONITOR_FLAGS, "MonitorFlags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_FILE_MONITOR_FLAGS, "G_FILE_"); + + G_DEF_CLASS(G_TYPE_FILE_TYPE, "Type", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_FILE_TYPE, "G_FILE_"); + + RG_DEF_SMETHOD(new_for_path, 1); + RG_DEF_SMETHOD(new_for_uri, 1); + RG_DEF_SMETHOD(new_for_commandline_arg, 1); + RG_DEF_SMETHOD(parse_name, 1); + + RG_DEF_METHOD(dup, 0); + RG_DEF_METHOD(hash, 0); + RG_DEF_METHOD_OPERATOR("==", file_equal, 1); + RG_DEF_METHOD(basename, 0); + RG_DEF_METHOD(path, 0); + RG_DEF_METHOD(uri, 0); + RG_DEF_METHOD(parse_name, 0); + RG_DEF_METHOD(parent, 0); + RG_DEF_METHOD_P(has_parent, -1); + RG_DEF_METHOD(get_child, 1); + RG_DEF_METHOD(get_child_for_display_name, 1); + RG_DEF_METHOD_P(has_prefix, 1); + RG_DEF_METHOD(get_relative_path, 1); + RG_DEF_METHOD(resolve_relative_path, 1); + RG_DEF_METHOD_P(native, 0); + RG_DEF_METHOD_P(has_uri_scheme, 1); + RG_DEF_METHOD(uri_scheme, 0); + RG_DEF_METHOD(read, -1); + RG_DEF_METHOD(read_async, -1); + RG_DEF_METHOD(read_finish, 1); + RG_DEF_METHOD(append_to, -1); + RG_DEF_METHOD(create, -1); + RG_DEF_METHOD(replace, -1); + RG_DEF_METHOD(append_to_async, -1); + RG_DEF_METHOD(append_to_finish, 1); + RG_DEF_METHOD(create_async, -1); + RG_DEF_METHOD(create_finish, 1); + RG_DEF_METHOD(replace_async, -1); + RG_DEF_METHOD(replace_finish, 1); + RG_DEF_METHOD(query_info, -1); + RG_DEF_METHOD(query_info_async, -1); + RG_DEF_METHOD(query_info_finish, 1); + RG_DEF_METHOD_P(query_exists, -1); + RG_DEF_ALIAS("exists?", "query_exists?"); + RG_DEF_METHOD(query_file_type, -1); + RG_DEF_METHOD(query_filesystem_info, -1); + RG_DEF_METHOD(query_filesystem_info_async, -1); + RG_DEF_METHOD(query_filesystem_info_finish, 1); + RG_DEF_METHOD(query_default_handler, -1); + RG_DEF_METHOD(find_enclosing_mount, -1); + RG_DEF_METHOD(find_enclosing_mount_async, -1); + RG_DEF_METHOD(find_enclosing_mount_finish, 1); + RG_DEF_METHOD(enumerate_children, -1); + RG_DEF_METHOD(enumerate_children_async, -1); + RG_DEF_METHOD(enumerate_children_finish, 1); + RG_DEF_METHOD(set_display_name, -1); + RG_DEF_METHOD(set_display_name_async, -1); + RG_DEF_METHOD(set_display_name_finish, 1); + RG_DEF_METHOD(delete, -1); + RG_DEF_METHOD(trash, -1); + RG_DEF_METHOD(copy, -1); + RG_DEF_METHOD(copy_async, -1); + RG_DEF_METHOD(copy_finish, 1); + RG_DEF_METHOD(move, -1); + RG_DEF_METHOD(make_directory, -1); + RG_DEF_METHOD(make_directory_with_parents, -1); + RG_DEF_METHOD(make_symbolic_link, -1); + RG_DEF_METHOD(query_settable_attributes, -1); + RG_DEF_METHOD(query_writable_namespaces, -1); + RG_DEF_METHOD(set_attribute, -1); + RG_DEF_METHOD(set_attributes_from_info, -1); + RG_DEF_METHOD(set_attributes_async, -1); + RG_DEF_METHOD(set_attributes_finish, 1); + RG_DEF_METHOD(set_attribute_string, -1); + RG_DEF_METHOD(set_attribute_byte_string, -1); + RG_DEF_METHOD(set_attribute_uint32, -1); + RG_DEF_METHOD(set_attribute_int32, -1); + RG_DEF_METHOD(set_attribute_uint64, -1); + RG_DEF_METHOD(set_attribute_int64, -1); + RG_DEF_METHOD(mount_mountable, -1); + RG_DEF_METHOD(mount_mountable_finish, 1); + RG_DEF_METHOD(unmount_mountable_with_operation, -1); + RG_DEF_METHOD(unmount_mountable_with_operation_finish, 1); + RG_DEF_METHOD(eject_mountable_with_operation, -1); + RG_DEF_METHOD(eject_mountable_with_operation_finish, 1); + RG_DEF_METHOD(start_mountable, -1); + RG_DEF_METHOD(start_mountable_finish, 1); + RG_DEF_METHOD(stop_mountable, -1); + RG_DEF_METHOD(stop_mountable_finish, 1); + RG_DEF_METHOD(poll_mountable, -1); + RG_DEF_METHOD(poll_mountable_finish, 1); + RG_DEF_METHOD(mount_enclosing_volume, -1); + RG_DEF_METHOD(mount_enclosing_volume_finish, 1); + RG_DEF_METHOD(monitor_directory, -1); + RG_DEF_METHOD(monitor_file, -1); + RG_DEF_METHOD(monitor, -1); + RG_DEF_METHOD(load_contents, -1); + RG_DEF_METHOD(load_contents_async, -1); + RG_DEF_METHOD(load_contents_finish, 1); + RG_DEF_METHOD(load_partial_contents_async, -1); + RG_DEF_METHOD(load_partial_contents_finish, 1); + RG_DEF_METHOD(replace_contents, -1); + RG_DEF_METHOD(replace_contents_async, -1); + RG_DEF_METHOD(replace_contents_finish, 1); + RG_DEF_METHOD(copy_attributes, -1); + RG_DEF_METHOD(create_readwrite, -1); + RG_DEF_METHOD(create_readwrite_async, -1); + RG_DEF_METHOD(create_readwrite_finish, 1); + RG_DEF_METHOD(open_readwrite, -1); + RG_DEF_METHOD(open_readwrite_async, -1); + RG_DEF_METHOD(open_readwrite_finish, 1); + RG_DEF_METHOD(replace_readwrite, -1); + RG_DEF_METHOD(replace_readwrite_async, -1); + RG_DEF_METHOD(replace_readwrite_finish, 1); + RG_DEF_METHOD_P(supports_thread_contexts, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileattribute.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileattribute.c new file mode 100644 index 0000000..6fac9b1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileattribute.c @@ -0,0 +1,114 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mFileAttribute + +void +Init_gfileattribute(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = rb_define_module_under(mGio, "FileAttribute"); + + rb_define_const(RG_TARGET_NAMESPACE, "STANDARD_TYPE", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_TYPE)); + rb_define_const(RG_TARGET_NAMESPACE, "STANDARD_IS_HIDDEN", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN)); + rb_define_const(RG_TARGET_NAMESPACE, "STANDARD_IS_BACKUP", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP)); + rb_define_const(RG_TARGET_NAMESPACE, "STANDARD_IS_SYMLINK", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK)); + rb_define_const(RG_TARGET_NAMESPACE, "STANDARD_IS_VIRTUAL", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL)); + rb_define_const(RG_TARGET_NAMESPACE, "STANDARD_NAME", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_NAME)); + rb_define_const(RG_TARGET_NAMESPACE, "STANDARD_DISPLAY_NAME", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME)); + rb_define_const(RG_TARGET_NAMESPACE, "STANDARD_EDIT_NAME", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME)); + rb_define_const(RG_TARGET_NAMESPACE, "STANDARD_COPY_NAME", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_COPY_NAME)); + rb_define_const(RG_TARGET_NAMESPACE, "STANDARD_DESCRIPTION", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION)); + rb_define_const(RG_TARGET_NAMESPACE, "STANDARD_ICON", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_ICON)); + rb_define_const(RG_TARGET_NAMESPACE, "STANDARD_CONTENT_TYPE", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE)); + rb_define_const(RG_TARGET_NAMESPACE, "STANDARD_FAST_CONTENT_TYPE", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE)); + rb_define_const(RG_TARGET_NAMESPACE, "STANDARD_SIZE", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_SIZE)); + rb_define_const(RG_TARGET_NAMESPACE, "STANDARD_ALLOCATED_SIZE", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE)); + rb_define_const(RG_TARGET_NAMESPACE, "STANDARD_SYMLINK_TARGET", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET)); + rb_define_const(RG_TARGET_NAMESPACE, "STANDARD_TARGET_URI", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_TARGET_URI)); + rb_define_const(RG_TARGET_NAMESPACE, "STANDARD_SORT_ORDER", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER)); + rb_define_const(RG_TARGET_NAMESPACE, "ETAG_VALUE", CSTR2RVAL(G_FILE_ATTRIBUTE_ETAG_VALUE)); + rb_define_const(RG_TARGET_NAMESPACE, "ID_FILE", CSTR2RVAL(G_FILE_ATTRIBUTE_ID_FILE)); + rb_define_const(RG_TARGET_NAMESPACE, "ID_FILESYSTEM", CSTR2RVAL(G_FILE_ATTRIBUTE_ID_FILESYSTEM)); + rb_define_const(RG_TARGET_NAMESPACE, "ACCESS_CAN_READ", CSTR2RVAL(G_FILE_ATTRIBUTE_ACCESS_CAN_READ)); + rb_define_const(RG_TARGET_NAMESPACE, "ACCESS_CAN_WRITE", CSTR2RVAL(G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE)); + rb_define_const(RG_TARGET_NAMESPACE, "ACCESS_CAN_EXECUTE", CSTR2RVAL(G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE)); + rb_define_const(RG_TARGET_NAMESPACE, "ACCESS_CAN_DELETE", CSTR2RVAL(G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE)); + rb_define_const(RG_TARGET_NAMESPACE, "ACCESS_CAN_TRASH", CSTR2RVAL(G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH)); + rb_define_const(RG_TARGET_NAMESPACE, "ACCESS_CAN_RENAME", CSTR2RVAL(G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME)); + rb_define_const(RG_TARGET_NAMESPACE, "MOUNTABLE_CAN_MOUNT", CSTR2RVAL(G_FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT)); + rb_define_const(RG_TARGET_NAMESPACE, "MOUNTABLE_CAN_UNMOUNT", CSTR2RVAL(G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT)); + rb_define_const(RG_TARGET_NAMESPACE, "MOUNTABLE_CAN_EJECT", CSTR2RVAL(G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT)); + rb_define_const(RG_TARGET_NAMESPACE, "MOUNTABLE_UNIX_DEVICE", CSTR2RVAL(G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE)); + rb_define_const(RG_TARGET_NAMESPACE, "MOUNTABLE_UNIX_DEVICE_FILE", CSTR2RVAL(G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE_FILE)); + rb_define_const(RG_TARGET_NAMESPACE, "MOUNTABLE_HAL_UDI", CSTR2RVAL(G_FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI)); + rb_define_const(RG_TARGET_NAMESPACE, "MOUNTABLE_CAN_POLL", CSTR2RVAL(G_FILE_ATTRIBUTE_MOUNTABLE_CAN_POLL)); + rb_define_const(RG_TARGET_NAMESPACE, "MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC", CSTR2RVAL(G_FILE_ATTRIBUTE_MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC)); + rb_define_const(RG_TARGET_NAMESPACE, "MOUNTABLE_CAN_START", CSTR2RVAL(G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START)); + rb_define_const(RG_TARGET_NAMESPACE, "MOUNTABLE_CAN_START_DEGRADED", CSTR2RVAL(G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START_DEGRADED)); + rb_define_const(RG_TARGET_NAMESPACE, "MOUNTABLE_CAN_STOP", CSTR2RVAL(G_FILE_ATTRIBUTE_MOUNTABLE_CAN_STOP)); + rb_define_const(RG_TARGET_NAMESPACE, "MOUNTABLE_START_STOP_TYPE", CSTR2RVAL(G_FILE_ATTRIBUTE_MOUNTABLE_START_STOP_TYPE)); + rb_define_const(RG_TARGET_NAMESPACE, "TIME_MODIFIED", CSTR2RVAL(G_FILE_ATTRIBUTE_TIME_MODIFIED)); + rb_define_const(RG_TARGET_NAMESPACE, "TIME_MODIFIED_USEC", CSTR2RVAL(G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC)); + rb_define_const(RG_TARGET_NAMESPACE, "TIME_ACCESS", CSTR2RVAL(G_FILE_ATTRIBUTE_TIME_ACCESS)); + rb_define_const(RG_TARGET_NAMESPACE, "TIME_ACCESS_USEC", CSTR2RVAL(G_FILE_ATTRIBUTE_TIME_ACCESS_USEC)); + rb_define_const(RG_TARGET_NAMESPACE, "TIME_CHANGED", CSTR2RVAL(G_FILE_ATTRIBUTE_TIME_CHANGED)); + rb_define_const(RG_TARGET_NAMESPACE, "TIME_CHANGED_USEC", CSTR2RVAL(G_FILE_ATTRIBUTE_TIME_CHANGED_USEC)); + rb_define_const(RG_TARGET_NAMESPACE, "TIME_CREATED", CSTR2RVAL(G_FILE_ATTRIBUTE_TIME_CREATED)); + rb_define_const(RG_TARGET_NAMESPACE, "TIME_CREATED_USEC", CSTR2RVAL(G_FILE_ATTRIBUTE_TIME_CREATED_USEC)); + rb_define_const(RG_TARGET_NAMESPACE, "UNIX_DEVICE", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_DEVICE)); + rb_define_const(RG_TARGET_NAMESPACE, "UNIX_INODE", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_INODE)); + rb_define_const(RG_TARGET_NAMESPACE, "UNIX_MODE", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_MODE)); + rb_define_const(RG_TARGET_NAMESPACE, "UNIX_NLINK", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_NLINK)); + rb_define_const(RG_TARGET_NAMESPACE, "UNIX_UID", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_UID)); + rb_define_const(RG_TARGET_NAMESPACE, "UNIX_GID", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_GID)); + rb_define_const(RG_TARGET_NAMESPACE, "UNIX_RDEV", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_RDEV)); + rb_define_const(RG_TARGET_NAMESPACE, "UNIX_BLOCK_SIZE", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_BLOCK_SIZE)); + rb_define_const(RG_TARGET_NAMESPACE, "UNIX_BLOCKS", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_BLOCKS)); + rb_define_const(RG_TARGET_NAMESPACE, "UNIX_IS_MOUNTPOINT", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT)); + rb_define_const(RG_TARGET_NAMESPACE, "DOS_IS_ARCHIVE", CSTR2RVAL(G_FILE_ATTRIBUTE_DOS_IS_ARCHIVE)); + rb_define_const(RG_TARGET_NAMESPACE, "DOS_IS_SYSTEM", CSTR2RVAL(G_FILE_ATTRIBUTE_DOS_IS_SYSTEM)); + rb_define_const(RG_TARGET_NAMESPACE, "OWNER_USER", CSTR2RVAL(G_FILE_ATTRIBUTE_OWNER_USER)); + rb_define_const(RG_TARGET_NAMESPACE, "OWNER_USER_REAL", CSTR2RVAL(G_FILE_ATTRIBUTE_OWNER_USER_REAL)); + rb_define_const(RG_TARGET_NAMESPACE, "OWNER_GROUP", CSTR2RVAL(G_FILE_ATTRIBUTE_OWNER_GROUP)); + rb_define_const(RG_TARGET_NAMESPACE, "THUMBNAIL_PATH", CSTR2RVAL(G_FILE_ATTRIBUTE_THUMBNAIL_PATH)); + rb_define_const(RG_TARGET_NAMESPACE, "THUMBNAILING_FAILED", CSTR2RVAL(G_FILE_ATTRIBUTE_THUMBNAILING_FAILED)); + rb_define_const(RG_TARGET_NAMESPACE, "PREVIEW_ICON", CSTR2RVAL(G_FILE_ATTRIBUTE_PREVIEW_ICON)); + rb_define_const(RG_TARGET_NAMESPACE, "FILESYSTEM_SIZE", CSTR2RVAL(G_FILE_ATTRIBUTE_FILESYSTEM_SIZE)); + rb_define_const(RG_TARGET_NAMESPACE, "FILESYSTEM_FREE", CSTR2RVAL(G_FILE_ATTRIBUTE_FILESYSTEM_FREE)); + rb_define_const(RG_TARGET_NAMESPACE, "FILESYSTEM_TYPE", CSTR2RVAL(G_FILE_ATTRIBUTE_FILESYSTEM_TYPE)); + rb_define_const(RG_TARGET_NAMESPACE, "FILESYSTEM_READONLY", CSTR2RVAL(G_FILE_ATTRIBUTE_FILESYSTEM_READONLY)); + rb_define_const(RG_TARGET_NAMESPACE, "FILESYSTEM_USE_PREVIEW", CSTR2RVAL(G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW)); + rb_define_const(RG_TARGET_NAMESPACE, "GVFS_BACKEND", CSTR2RVAL(G_FILE_ATTRIBUTE_GVFS_BACKEND)); + rb_define_const(RG_TARGET_NAMESPACE, "SELINUX_CONTEXT", CSTR2RVAL(G_FILE_ATTRIBUTE_SELINUX_CONTEXT)); + rb_define_const(RG_TARGET_NAMESPACE, "TRASH_ITEM_COUNT", CSTR2RVAL(G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT)); + rb_define_const(RG_TARGET_NAMESPACE, "TRASH_DELETION_DATE", CSTR2RVAL(G_FILE_ATTRIBUTE_TRASH_DELETION_DATE)); + rb_define_const(RG_TARGET_NAMESPACE, "TRASH_ORIG_PATH", CSTR2RVAL(G_FILE_ATTRIBUTE_TRASH_ORIG_PATH)); + + G_DEF_CLASS(G_TYPE_FILE_ATTRIBUTE_TYPE, "Type", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_FILE_ATTRIBUTE_TYPE, "G_FILE_ATTRIBUTE_"); + + G_DEF_CLASS(G_TYPE_FILE_ATTRIBUTE_STATUS, "Status", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_FILE_ATTRIBUTE_STATUS, "G_FILE_ATTRIBUTE_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileattributeinfo.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileattributeinfo.c new file mode 100644 index 0000000..0b7abe7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileattributeinfo.c @@ -0,0 +1,86 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cFileAttributeInfo + +static GFileAttributeInfo * +fileattributeinfo_copy(const GFileAttributeInfo *info) +{ + return (GFileAttributeInfo *)info; +} + +static void +fileattributeinfo_free(G_GNUC_UNUSED GFileAttributeInfo *info) +{ + return; +} + +GType +g_file_attribute_info_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static("GFileAttributeInfo", + (GBoxedCopyFunc)fileattributeinfo_copy, + (GBoxedFreeFunc)fileattributeinfo_free); + + return our_type; +} + +#define _SELF(value) RVAL2GFILEATTRIBUTEINFO(value) + +static VALUE +rg_name(VALUE self) +{ + return CSTR2RVAL(_SELF(self)->name); +} + +static VALUE +rg_type(VALUE self) +{ + return GFILEATTRIBUTETYPE2RVAL(_SELF(self)->type); +} + +static VALUE +rg_flags(VALUE self) +{ + return GFILEATTRIBUTEINFOFLAGS2RVAL(_SELF(self)->flags); +} + +void +Init_gfileattributeinfo(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_FILE_ATTRIBUTE_INFO, "FileAttributeInfo", mGio); + + G_DEF_CLASS(G_TYPE_FILE_ATTRIBUTE_INFO_FLAGS, "Flags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_FILE_ATTRIBUTE_INFO_FLAGS, "G_FILE_ATTRIBUTE_INFO_"); + + rbgobj_boxed_not_copy_obj(G_TYPE_FILE_ATTRIBUTE_INFO); + + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(type, 0); + RG_DEF_METHOD(flags, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileattributeinfolist.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileattributeinfolist.c new file mode 100644 index 0000000..c167a5f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileattributeinfolist.c @@ -0,0 +1,108 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cFileAttributeInfoList + +#define RVAL2GFILEATTRIBUTEINFOFLAGSDEFAULT(value) \ + RVAL2TYPE_WITH_DEFAULT((value), \ + RVAL2GFILEATTRIBUTEINFOFLAGS, \ + G_FILE_ATTRIBUTE_INFO_NONE) + +#if !GLIB_CHECK_VERSION(2, 34, 0) +GType +g_file_attribute_info_list_get_type(void) +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static("GFileAttributeInfoList", + (GBoxedCopyFunc)g_file_attribute_info_list_ref, + (GBoxedFreeFunc)g_file_attribute_info_list_unref); + return our_type; +} +#endif + +#define _SELF(value) RVAL2GFILEATTRIBUTEINFOLIST(value) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, g_file_attribute_info_list_new()); + + return Qnil; +} + +static VALUE +rg_dup(VALUE self) +{ + return GFILEATTRIBUTEINFOLIST2RVAL(g_file_attribute_info_list_dup(_SELF(self))); +} + +static VALUE +rg_lookup(VALUE self, VALUE name) +{ + /* TODO: How do we deal with the const? */ + return GFILEATTRIBUTEINFO2RVAL((GFileAttributeInfo *)g_file_attribute_info_list_lookup(_SELF(self), + RVAL2CSTR(name))); +} + +static VALUE +rg_add(int argc, VALUE *argv, VALUE self) +{ + VALUE name, type, flags; + + rb_scan_args(argc, argv, "21", &name, &type, &flags); + + g_file_attribute_info_list_add(_SELF(self), + RVAL2CSTR(name), + RVAL2GFILEATTRIBUTETYPE(type), + RVAL2GFILEATTRIBUTEINFOFLAGSDEFAULT(flags)); + + return self; +} + +static VALUE +rg_each(VALUE self) +{ + GFileAttributeInfoList *list = RVAL2GFILEATTRIBUTEINFOLIST(self); + int i; + + for (i = 0; i < list->n_infos; i++) + rb_yield(GFILEATTRIBUTEINFO2RVAL(&list->infos[i])); + + return self; +} + +void +Init_fileattributeinfolist(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_FILE_ATTRIBUTE_INFO_LIST, "FileAttributeInfoList", mGio); + + rb_include_module(RG_TARGET_NAMESPACE, rb_mEnumerable); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(dup, 0); + RG_DEF_METHOD(lookup, 1); + RG_DEF_ALIAS("[]", "lookup"); + RG_DEF_METHOD(add, 3); + RG_DEF_METHOD(each, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileattributematcher.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileattributematcher.c new file mode 100644 index 0000000..6b255f5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileattributematcher.c @@ -0,0 +1,95 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cFileAttributeMatcher + +#if !GLIB_CHECK_VERSION(2, 34, 0) +GType +g_file_attribute_matcher_get_type(void) +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static("GFileAttributeMatcher", + (GBoxedCopyFunc)g_file_attribute_matcher_ref, + (GBoxedFreeFunc)g_file_attribute_matcher_unref); + return our_type; +} +#endif + +#define _SELF(value) RVAL2GFILEATTRIBUTEMATCHER(value) + +static VALUE +rg_initialize(VALUE self, VALUE attributes) +{ + G_INITIALIZE(self, g_file_attribute_matcher_new(RVAL2CSTR(attributes))); + + return Qnil; +} + +static VALUE +rg_matches_p(VALUE self, VALUE attribute) +{ + return CBOOL2RVAL(g_file_attribute_matcher_matches(_SELF(self), RVAL2CSTR(attribute))); +} + +static VALUE +rg_matches_only_p(VALUE self, VALUE attribute) +{ + return CBOOL2RVAL(g_file_attribute_matcher_matches_only(_SELF(self), RVAL2CSTR(attribute))); +} + +static VALUE +rg_enumerate_namespace(VALUE self, VALUE ns) +{ + const char *match; + gboolean matches_all = g_file_attribute_matcher_enumerate_namespace(_SELF(self), + RVAL2CSTR(ns)); + if (!rb_block_given_p()) + return CBOOL2RVAL(matches_all); + + while ((match = g_file_attribute_matcher_enumerate_next(_SELF(self))) != NULL) + rb_yield(CSTR2RVAL(match)); + + return self; +} + +static VALUE +rg_enumerate_next(VALUE self) +{ + return CSTR2RVAL(g_file_attribute_matcher_enumerate_next(_SELF(self))); +} + +void +Init_gfileattributematcher(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_FILE_ATTRIBUTE_MATCHER, "FileAttributeMatcher", mGio); + + RG_DEF_METHOD(initialize, 1); + RG_DEF_METHOD_P(matches, 1); + /* TODO: Is this confusing when we have both #matches and + * #matches_only? What does #=~ call? */ + RG_DEF_ALIAS("=~", "matches?"); + RG_DEF_METHOD_P(matches_only, 1); + RG_DEF_METHOD(enumerate_namespace, 1); + RG_DEF_METHOD(enumerate_next, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofiledescriptorbased.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofiledescriptorbased.c new file mode 100644 index 0000000..3473563 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofiledescriptorbased.c @@ -0,0 +1,45 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#ifdef HAVE_GIO_UNIX +#include + +#define RG_TARGET_NAMESPACE mFileDescriptorBased +#define _SELF(value) RVAL2GFILEDESCRIPTORBASED(value) + +static VALUE +rg_fd(VALUE self) +{ + return FD2RVAL(g_file_descriptor_based_get_fd(_SELF(self))); +} +#endif + +void +Init_gfiledescriptorbased(G_GNUC_UNUSED VALUE mGio) +{ +#ifdef HAVE_GIO_UNIX + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_FILE_DESCRIPTOR_BASED, "FileDescriptorBased", mGio); + + RG_DEF_METHOD(fd, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileenumerator.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileenumerator.c new file mode 100644 index 0000000..bd23928 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileenumerator.c @@ -0,0 +1,166 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cFileEnumerator +#define _SELF(value) RVAL2GFILEENUMERATOR(value) + +static VALUE +rg_next_file(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + GFileInfo *info; + + rb_scan_args(argc, argv, "01", &cancellable); + info = g_file_enumerator_next_file(_SELF(self), + RVAL2GCANCELLABLE(cancellable), + &error); + if (error != NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(info); +} + +static VALUE +rg_close(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "01", &cancellable); + if (!g_file_enumerator_close(_SELF(self), RVAL2GCANCELLABLE(cancellable), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_next_files_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbnum_files, rbio_priority, rbcancellable, block; + int num_files; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "12&", &rbnum_files, &rbio_priority, &rbcancellable, &block); + num_files = NUM2INT(rbnum_files); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_file_enumerator_next_files_async(_SELF(self), + num_files, + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_next_files_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + GList *files = g_file_enumerator_next_files_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &error); + if (error != NULL) + rbgio_raise_error(error); + + return GLIST2ARY_FREE(files); +} + +static VALUE +rg_close_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbio_priority, rbcancellable, block; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_file_enumerator_close_async(_SELF(self), + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_close_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + if (!g_file_enumerator_close_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &error)) + rbgio_raise_error(error); + + return Qnil; +} + +static VALUE +rg_closed_p(VALUE self) +{ + return CBOOL2RVAL(g_file_enumerator_is_closed(_SELF(self))); +} + +static VALUE +rg_has_pending_p(VALUE self) +{ + return CBOOL2RVAL(g_file_enumerator_has_pending(_SELF(self))); +} + +static VALUE +rg_set_pending(VALUE self, VALUE pending) +{ + g_file_enumerator_set_pending(_SELF(self), RVAL2CBOOL(pending)); + + return self; +} + +static VALUE +rg_container(VALUE self) +{ + return GOBJ2RVAL(g_file_enumerator_get_container(_SELF(self))); +} + +void +Init_gfileenumerator(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_FILE_ENUMERATOR, "FileEnumerator", mGio); + + RG_DEF_METHOD(next_file, -1); + RG_DEF_METHOD(close, -1); + RG_DEF_METHOD(next_files_async, -1); + RG_DEF_METHOD(next_files_finish, 1); + RG_DEF_METHOD(close_async, -1); + RG_DEF_METHOD(close_finish, 1); + RG_DEF_METHOD_P(closed, 0); + RG_DEF_METHOD_P(has_pending, 0); + RG_DEF_METHOD(set_pending, 1); + RG_DEF_METHOD(container, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileicon.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileicon.c new file mode 100644 index 0000000..c97fa0f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileicon.c @@ -0,0 +1,41 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cFileIcon +#define _SELF(value) RVAL2GFILEICON(value) + +static VALUE +rg_initialize(VALUE self, VALUE file) +{ + G_INITIALIZE(self, g_file_icon_new(RVAL2GFILE(file))); + + return Qnil; +} + +void +Init_gfileicon(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_FILE_ICON, "FileIcon", mGio); + + RG_DEF_METHOD(initialize, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileinfo.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileinfo.c new file mode 100644 index 0000000..e31d9b7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileinfo.c @@ -0,0 +1,617 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cFileInfo +#define _SELF(value) RVAL2GFILEINFO(value) + +#define RVAL2FILEINFONAMESPACEDEFAULT(value) \ + RVAL2TYPE_WITH_DEFAULT((value), RVAL2CSTR, "*") + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, g_file_info_new()); + + return Qnil; +} + +static VALUE +rg_dup(VALUE self) +{ + return GOBJ2RVAL_UNREF(g_file_info_dup(_SELF(self))); +} + +static VALUE +rg_copy_into(VALUE self, VALUE other) +{ + g_file_info_copy_into(_SELF(self), _SELF(other)); + + return self; +} + +static VALUE +rg_has_attribute_p(VALUE self, VALUE attribute) +{ + return CBOOL2RVAL(g_file_info_has_attribute(_SELF(self), RVAL2CSTR(attribute))); +} + +static VALUE +rg_has_namespace_p(VALUE self, VALUE namespace) +{ + return CBOOL2RVAL(g_file_info_has_namespace(_SELF(self), RVAL2CSTR(namespace))); +} + +static VALUE +rg_set_attribute_status(VALUE self, VALUE attribute, VALUE status) +{ + return CBOOL2RVAL(g_file_info_set_attribute_status(_SELF(self), + RVAL2CSTR(attribute), + RVAL2GFILEATTRIBUTESTATUS(status))); +} + +static VALUE +rg_list_attributes(int argc, VALUE *argv, VALUE self) +{ + VALUE name_space; + + rb_scan_args(argc, argv, "01", &name_space); + + return STRV2RVAL_FREE(g_file_info_list_attributes(_SELF(self), + RVAL2FILEINFONAMESPACEDEFAULT(name_space))); +} + +static VALUE +rg_get_attribute_type(VALUE self, VALUE attribute) +{ + return GFILEATTRIBUTETYPE2RVAL(g_file_info_get_attribute_type(_SELF(self), RVAL2CSTR(attribute))); +} + +static VALUE +rg_remove_attribute(VALUE self, VALUE attribute) +{ + g_file_info_remove_attribute(_SELF(self), RVAL2CSTR(attribute)); + + return self; +} + +static VALUE +rg_get_attribute_as_string(VALUE self, VALUE attribute) +{ + return CSTR2RVAL_FREE(g_file_info_get_attribute_as_string(_SELF(self), RVAL2CSTR(attribute))); +} + +static VALUE +file_attribute_to_value(GFileAttributeType type, gpointer value) +{ + switch (type) { + case G_FILE_ATTRIBUTE_TYPE_STRING: + case G_FILE_ATTRIBUTE_TYPE_BYTE_STRING: + return CSTR2RVAL(value); + case G_FILE_ATTRIBUTE_TYPE_BOOLEAN: + return CBOOL2RVAL(*(gboolean *)value); + case G_FILE_ATTRIBUTE_TYPE_UINT32: + return GUINT322RVAL(*(guint32 *)value); + case G_FILE_ATTRIBUTE_TYPE_INT32: + return GINT322RVAL(*(gint32 *)value); + case G_FILE_ATTRIBUTE_TYPE_UINT64: + return GUINT642RVAL(*(guint64 *)value); + case G_FILE_ATTRIBUTE_TYPE_INT64: + return GINT642RVAL(*(gint64 *)value); + case G_FILE_ATTRIBUTE_TYPE_OBJECT: + return GOBJ2RVAL((GObject *)value); + case G_FILE_ATTRIBUTE_TYPE_STRINGV: + return STRV2RVAL_FREE((gchar **)value); + case G_FILE_ATTRIBUTE_TYPE_INVALID: + rb_raise(rb_eArgError, "invalid file attribute type"); + break; + default: + rb_raise(rb_eArgError, "unknown file attribute type"); + break; + } +} + +static VALUE +rg_get_attribute_data(VALUE self, VALUE attribute) +{ + GFileAttributeType type; + gpointer value; + GFileAttributeStatus status; + + if (!g_file_info_get_attribute_data(_SELF(self), + RVAL2CSTR(attribute), + &type, + &value, + &status)) + return Qnil; + + return rb_ary_new3(3, + GFILEATTRIBUTETYPE2RVAL(type), + file_attribute_to_value(type, value), + GFILEATTRIBUTESTATUS2RVAL(status)); +} + +static VALUE +rg_get_attribute_status(VALUE self, VALUE attribute) +{ + return GFILEATTRIBUTESTATUS2RVAL(g_file_info_get_attribute_status(_SELF(self), + RVAL2CSTR(attribute))); +} + +static VALUE +rg_get_attribute_string(VALUE self, VALUE attribute) +{ + return CSTR2RVAL(g_file_info_get_attribute_string(_SELF(self), + RVAL2CSTR(attribute))); +} + +static VALUE +rg_get_attribute_stringv(VALUE self, VALUE attribute) +{ + return STRV2RVAL((const gchar **)g_file_info_get_attribute_stringv(_SELF(self), + RVAL2CSTR(attribute))); +} + +static VALUE +rg_get_attribute_byte_string(VALUE self, VALUE attribute) +{ + return CSTR2RVAL(g_file_info_get_attribute_byte_string(_SELF(self), + RVAL2CSTR(attribute))); +} + +static VALUE +rg_get_attribute_boolean(VALUE self, VALUE attribute) +{ + return CBOOL2RVAL(g_file_info_get_attribute_boolean(_SELF(self), + RVAL2CSTR(attribute))); +} + +static VALUE +rg_get_attribute_uint32(VALUE self, VALUE attribute) +{ + return GUINT322RVAL(g_file_info_get_attribute_uint32(_SELF(self), + RVAL2CSTR(attribute))); +} + +static VALUE +rg_get_attribute_int32(VALUE self, VALUE attribute) +{ + return GINT322RVAL(g_file_info_get_attribute_int32(_SELF(self), + RVAL2CSTR(attribute))); +} + +static VALUE +rg_get_attribute_uint64(VALUE self, VALUE attribute) +{ + return GUINT642RVAL(g_file_info_get_attribute_uint64(_SELF(self), + RVAL2CSTR(attribute))); +} + +static VALUE +rg_get_attribute_int64(VALUE self, VALUE attribute) +{ + return GINT642RVAL(g_file_info_get_attribute_int64(_SELF(self), + RVAL2CSTR(attribute))); +} + +static VALUE +rg_get_attribute_object(VALUE self, VALUE attribute) +{ + return GOBJ2RVAL(g_file_info_get_attribute_object(_SELF(self), + RVAL2CSTR(attribute))); +} + +static VALUE +rg_get_attribute_value(VALUE self, VALUE attribute) +{ + GFileAttributeType type; + gpointer value; + GFileAttributeStatus status; + + if (!g_file_info_get_attribute_data(_SELF(self), + RVAL2CSTR(attribute), + &type, + &value, + &status)) + return Qnil; + + return file_attribute_to_value(type, value); +} + +static VALUE +rg_set_attribute_string(VALUE self, VALUE attribute, VALUE value) +{ + g_file_info_set_attribute_string(_SELF(self), + RVAL2CSTR(attribute), + RVAL2CSTR(value)); + + return self; +} + +static VALUE +rg_set_attribute_byte_string(VALUE self, VALUE attribute, VALUE value) +{ + g_file_info_set_attribute_byte_string(_SELF(self), + RVAL2CSTR(attribute), + RVAL2CSTR(value)); + + return self; +} + +static VALUE +rg_set_attribute_boolean(VALUE self, VALUE attribute, VALUE value) +{ + g_file_info_set_attribute_boolean(_SELF(self), + RVAL2CSTR(attribute), + RVAL2CBOOL(value)); + + return self; +} + +static VALUE +rg_set_attribute_uint32(VALUE self, VALUE attribute, VALUE value) +{ + g_file_info_set_attribute_uint32(_SELF(self), + RVAL2CSTR(attribute), + RVAL2GUINT32(value)); + + return self; +} + +static VALUE +rg_set_attribute_int32(VALUE self, VALUE attribute, VALUE value) +{ + g_file_info_set_attribute_int32(_SELF(self), + RVAL2CSTR(attribute), + RVAL2GINT32(value)); + + return self; +} + +static VALUE +rg_set_attribute_uint64(VALUE self, VALUE attribute, VALUE value) +{ + g_file_info_set_attribute_uint64(_SELF(self), + RVAL2CSTR(attribute), + RVAL2GUINT64(value)); + + return self; +} + +static VALUE +rg_set_attribute_int64(VALUE self, VALUE attribute, VALUE value) +{ + g_file_info_set_attribute_int64(_SELF(self), + RVAL2CSTR(attribute), + RVAL2GINT64(value)); + + return self; +} + +static VALUE +rg_set_attribute_object(VALUE self, VALUE attribute, VALUE value) +{ + g_file_info_set_attribute_object(_SELF(self), + RVAL2CSTR(attribute), + RVAL2GOBJ(value)); + + return self; +} + +static VALUE +rg_clear_status(VALUE self) +{ + g_file_info_clear_status(_SELF(self)); + + return self; +} + +static VALUE +rg_file_type(VALUE self) +{ + return GFILETYPE2RVAL(g_file_info_get_file_type(_SELF(self))); +} + +static VALUE +rg_hidden_p(VALUE self) +{ + return CBOOL2RVAL(g_file_info_get_is_hidden(_SELF(self))); +} + +static VALUE +rg_backup_p(VALUE self) +{ + return CBOOL2RVAL(g_file_info_get_is_backup(_SELF(self))); +} + +static VALUE +rg_symlink_p(VALUE self) +{ + return CBOOL2RVAL(g_file_info_get_is_symlink(_SELF(self))); +} + +static VALUE +rg_name(VALUE self) +{ + return CSTR2RVAL(g_file_info_get_name(_SELF(self))); +} + +static VALUE +rg_display_name(VALUE self) +{ + return CSTR2RVAL(g_file_info_get_display_name(_SELF(self))); +} + +static VALUE +rg_edit_name(VALUE self) +{ + return CSTR2RVAL(g_file_info_get_edit_name(_SELF(self))); +} + +static VALUE +rg_icon(VALUE self) +{ + return GOBJ2RVAL(g_file_info_get_icon(_SELF(self))); +} + +static VALUE +rg_content_type(VALUE self) +{ + return CSTR2RVAL(g_file_info_get_content_type(_SELF(self))); +} + +static VALUE +rg_size(VALUE self) +{ + return GOFFSET2RVAL(g_file_info_get_size(_SELF(self))); +} + +static VALUE +rg_modification_time(VALUE self) +{ + GTimeVal time; + + g_file_info_get_modification_time(_SELF(self), &time); + + return GTIMEVAL2RVAL(&time); +} + +static VALUE +rg_symlink_target(VALUE self) +{ + return CSTR2RVAL(g_file_info_get_symlink_target(_SELF(self))); +} + +static VALUE +rg_etag(VALUE self) +{ + return CSTR2RVAL(g_file_info_get_etag(_SELF(self))); +} + +static VALUE +rg_sort_order(VALUE self) +{ + return GINT322RVAL(g_file_info_get_sort_order(_SELF(self))); +} + +static VALUE +rg_set_attribute_mask(VALUE self, VALUE rbmask) +{ + gboolean should_unref; + GFileAttributeMatcher *mask; + + if (NIL_P(rbmask)) { + g_file_info_unset_attribute_mask(_SELF(self)); + return self; + } + + if (TYPE(rbmask) == T_STRING) { + mask = g_file_attribute_matcher_new(RVAL2CSTR(rbmask)); + should_unref = TRUE; + } else { + mask = RVAL2GFILEATTRIBUTEMATCHER(rbmask); + should_unref = FALSE; + } + + g_file_info_set_attribute_mask(_SELF(self), mask); + + if (should_unref) + g_file_attribute_matcher_unref(mask); + + return self; +} + +static VALUE +rg_unset_attribute_mask(VALUE self) +{ + g_file_info_unset_attribute_mask(_SELF(self)); + + return self; +} + +static VALUE +rg_set_file_type(VALUE self, VALUE value) +{ + g_file_info_set_file_type(_SELF(self), RVAL2GFILETYPE(value)); + + return self; +} + +static VALUE +rg_set_hidden(VALUE self, VALUE value) +{ + g_file_info_set_is_hidden(_SELF(self), RVAL2CBOOL(value)); + + return self; +} + +static VALUE +rg_set_symlink(VALUE self, VALUE value) +{ + g_file_info_set_is_symlink(_SELF(self), RVAL2CBOOL(value)); + + return self; +} + +static VALUE +rg_set_name(VALUE self, VALUE value) +{ + g_file_info_set_name(_SELF(self), RVAL2CSTR(value)); + + return self; +} + +static VALUE +rg_set_display_name(VALUE self, VALUE value) +{ + g_file_info_set_display_name(_SELF(self), RVAL2CSTR(value)); + + return self; +} + +static VALUE +rg_set_edit_name(VALUE self, VALUE value) +{ + g_file_info_set_edit_name(_SELF(self), RVAL2CSTR(value)); + + return self; +} + +static VALUE +rg_set_icon(VALUE self, VALUE value) +{ + g_file_info_set_icon(_SELF(self), RVAL2GICON(value)); + + return self; +} + +static VALUE +rg_set_content_type(VALUE self, VALUE value) +{ + g_file_info_set_content_type(_SELF(self), RVAL2CSTR(value)); + + return self; +} + +static VALUE +rg_set_size(VALUE self, VALUE value) +{ + g_file_info_set_size(_SELF(self), RVAL2GOFFSET(value)); + + return self; +} + +static VALUE +rg_set_modification_time(VALUE self, VALUE rbtime) +{ + GTimeVal time; + + rbgio_rval_to_gtimeval(rbtime, &time); + + g_file_info_set_modification_time(_SELF(self), &time); + + return self; +} + +static VALUE +rg_set_symlink_target(VALUE self, VALUE value) +{ + g_file_info_set_symlink_target(_SELF(self), RVAL2CSTR(value)); + + return self; +} + +static VALUE +rg_set_sort_order(VALUE self, VALUE value) +{ + g_file_info_set_sort_order(_SELF(self), RVAL2GINT32(value)); + + return self; +} + +void +Init_gfileinfo(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_FILE_INFO, "FileInfo", mGio); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(dup, 0); + RG_DEF_METHOD(copy_into, 1); + RG_DEF_METHOD_P(has_attribute, 1); + RG_DEF_METHOD_P(has_namespace, 1); + RG_DEF_METHOD(list_attributes, -1); + RG_DEF_ALIAS("attributes", "list_attributes"); + RG_DEF_METHOD(get_attribute_type, 1); + RG_DEF_METHOD(remove_attribute, 1); + RG_DEF_METHOD(get_attribute_as_string, 1); + RG_DEF_METHOD(get_attribute_data, 1); + RG_DEF_METHOD(get_attribute_status, 1); + RG_DEF_METHOD(get_attribute_string, 1); + RG_DEF_METHOD(get_attribute_stringv, 1); + RG_DEF_METHOD(get_attribute_byte_string, 1); + RG_DEF_METHOD(get_attribute_boolean, 1); + RG_DEF_METHOD(get_attribute_uint32, 1); + RG_DEF_METHOD(get_attribute_int32, 1); + RG_DEF_METHOD(get_attribute_uint64, 1); + RG_DEF_METHOD(get_attribute_int64, 1); + RG_DEF_METHOD(get_attribute_object, 1); + RG_DEF_METHOD(get_attribute_value, 1); + RG_DEF_ALIAS("[]", "get_attribute_value"); + RG_DEF_METHOD(set_attribute_status, 2); + RG_DEF_METHOD(set_attribute_string, 2); + RG_DEF_METHOD(set_attribute_byte_string, 2); + RG_DEF_METHOD(set_attribute_boolean, 2); + RG_DEF_METHOD(set_attribute_uint32, 2); + RG_DEF_METHOD(set_attribute_int32, 2); + RG_DEF_METHOD(set_attribute_uint64, 2); + RG_DEF_METHOD(set_attribute_int64, 2); + RG_DEF_METHOD(set_attribute_object, 2); + RG_DEF_METHOD(clear_status, 0); + RG_DEF_METHOD(file_type, 0); + RG_DEF_METHOD_P(hidden, 0); + RG_DEF_METHOD_P(backup, 0); + RG_DEF_METHOD_P(symlink, 0); + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(display_name, 0); + RG_DEF_METHOD(edit_name, 0); + RG_DEF_METHOD(icon, 0); + RG_DEF_METHOD(content_type, 0); + RG_DEF_METHOD(size, 0); + RG_DEF_METHOD(modification_time, 0); + RG_DEF_METHOD(symlink_target, 0); + RG_DEF_METHOD(etag, 0); + RG_DEF_METHOD(sort_order, 0); + RG_DEF_METHOD(set_attribute_mask, 1); + RG_DEF_METHOD(unset_attribute_mask, 0); + RG_DEF_METHOD(set_file_type, 1); + RG_DEF_METHOD(set_hidden, 1); + RG_DEF_METHOD(set_symlink, 1); + RG_DEF_METHOD(set_name, 1); + RG_DEF_METHOD(set_display_name, 1); + RG_DEF_METHOD(set_edit_name, 1); + RG_DEF_METHOD(set_icon, 1); + RG_DEF_METHOD(set_content_type, 1); + RG_DEF_METHOD(set_size, 1); + RG_DEF_METHOD(set_modification_time, 1); + RG_DEF_METHOD(set_symlink_target, 1); + RG_DEF_METHOD(set_sort_order, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileinputstream.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileinputstream.c new file mode 100644 index 0000000..b3ced55 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileinputstream.c @@ -0,0 +1,91 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cFileInputStream +#define _SELF(value) RVAL2GFILEINPUTSTREAM(value) + +static VALUE +rg_query_info(int argc, VALUE *argv, VALUE self) +{ + VALUE attributes, cancellable; + GError *error = NULL; + GFileInfo *info; + + rb_scan_args(argc, argv, "02", &attributes, &cancellable); + info = g_file_input_stream_query_info(_SELF(self), + RVAL2ATTRIBUTESDEFAULT(attributes), + RVAL2GCANCELLABLE(cancellable), + &error); + if (info == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(info); +} + +static VALUE +rg_query_info_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbattributes, rbio_priority, rbcancellable, block; + const char *attributes; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "03&", &rbattributes, &rbio_priority, &rbcancellable, &block); + attributes = RVAL2ATTRIBUTESDEFAULT(rbattributes); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_file_input_stream_query_info_async(_SELF(self), + attributes, + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_query_info_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + GFileInfo *info; + + info = g_file_input_stream_query_info_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &error); + if (info == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(info); +} + +void +Init_gfileinputstream(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_FILE_INPUT_STREAM, "FileInputStream", mGio); + + RG_DEF_METHOD(query_info, -1); + RG_DEF_METHOD(query_info_async, -1); + RG_DEF_METHOD(query_info_finish, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileiostream.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileiostream.c new file mode 100644 index 0000000..daf930c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileiostream.c @@ -0,0 +1,98 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cFileIOStream +#define _SELF(value) RVAL2GFILEIOSTREAM(value) + +static VALUE +rg_etag(VALUE self) +{ + return CSTR2RVAL(g_file_io_stream_get_etag(_SELF(self))); +} + +static VALUE +rg_query_info(int argc, VALUE *argv, VALUE self) +{ + VALUE attributes, cancellable; + GError *error = NULL; + GFileInfo *info; + + rb_scan_args(argc, argv, "02", &attributes, &cancellable); + info = g_file_io_stream_query_info(_SELF(self), + RVAL2ATTRIBUTESDEFAULT(attributes), + RVAL2GCANCELLABLE(cancellable), + &error); + if (info == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(info); +} + +static VALUE +rg_query_info_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbattributes, rbio_priority, rbcancellable, block; + const char *attributes; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "03&", &rbattributes, &rbio_priority, &rbcancellable, &block); + attributes = RVAL2ATTRIBUTESDEFAULT(rbattributes); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_file_io_stream_query_info_async(_SELF(self), + attributes, + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_query_info_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + GFileInfo *info; + + info = g_file_io_stream_query_info_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &error); + if (info == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(info); +} + +void +Init_gfileiostream(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_FILE_IO_STREAM, "FileIOStream", mGio); + + RG_DEF_METHOD(etag, 0); + RG_DEF_METHOD(query_info, -1); + RG_DEF_METHOD(query_info_async, -1); + RG_DEF_METHOD(query_info_finish, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofilemonitor.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofilemonitor.c new file mode 100644 index 0000000..a89c8a7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofilemonitor.c @@ -0,0 +1,46 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cFileMonitor +#define _SELF(value) RVAL2GFILEMONITOR(value) + +static VALUE +rg_cancel(VALUE self) +{ + return CBOOL2RVAL(g_file_monitor_cancel(_SELF(self))); +} + +void +Init_gfilemonitor(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_FILE_MONITOR, "FileMonitor", mGio); + + G_DEF_CLASS(G_TYPE_FILE_MONITOR_EVENT, "Event", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_FILE_MONITOR_EVENT, "G_FILE_MONITOR_"); + + G_DEF_CLASS(G_TYPE_FILE_MONITOR_FLAGS, "Flags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_FILE_MONITOR_FLAGS, "G_FILE_MONITOR_"); + + RG_DEF_METHOD(cancel, 0); + /* TODO: Do we need #emit_event? */ +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofilenamecompleter.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofilenamecompleter.c new file mode 100644 index 0000000..7f25413 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofilenamecompleter.c @@ -0,0 +1,73 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cFilenameCompleter +#define _SELF(value) RVAL2GFILENAMECOMPLETER(value) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE dirs_only; + GFilenameCompleter *completer; + + rb_scan_args(argc, argv, "01", &dirs_only); + completer = g_filename_completer_new(); + g_filename_completer_set_dirs_only(completer, RVAL2CBOOL(dirs_only)); + + G_INITIALIZE(self, completer); + + return Qnil; +} + +static VALUE +rg_get_completion_suffix(VALUE self, VALUE initial_text) +{ + return CSTR2RVAL_FREE(g_filename_completer_get_completion_suffix(_SELF(self), + RVAL2CSTR(initial_text))); +} + +static VALUE +rg_get_completions(VALUE self, VALUE initial_text) +{ + return STRV2RVAL_FREE(g_filename_completer_get_completions(_SELF(self), + RVAL2CSTR(initial_text))); +} + +static VALUE +rg_set_dirs_only(VALUE self, VALUE dirs_only) +{ + g_filename_completer_set_dirs_only(_SELF(self), RVAL2CBOOL(dirs_only)); + + return self; +} + +void +Init_gfilenamecompleter(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_FILENAME_COMPLETER, "FilenameCompleter", mGio); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(get_completion_suffix, 1); + RG_DEF_METHOD(get_completions, 1); + RG_DEF_METHOD(set_dirs_only, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileoutputstream.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileoutputstream.c new file mode 100644 index 0000000..e23c668 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofileoutputstream.c @@ -0,0 +1,98 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cFileOutputStream +#define _SELF(value) RVAL2GFILEOUTPUTSTREAM(value) + +static VALUE +rg_query_info(int argc, VALUE *argv, VALUE self) +{ + VALUE attributes, cancellable; + GError *error = NULL; + GFileInfo *info; + + rb_scan_args(argc, argv, "02", &attributes, &cancellable); + info = g_file_output_stream_query_info(_SELF(self), + RVAL2ATTRIBUTESDEFAULT(attributes), + RVAL2GCANCELLABLE(cancellable), + &error); + if (info == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(info); +} + +static VALUE +rg_query_info_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbattributes, rbio_priority, rbcancellable, block; + const char *attributes; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "03&", &rbattributes, &rbio_priority, &rbcancellable, &block); + attributes = RVAL2ATTRIBUTESDEFAULT(rbattributes); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_file_output_stream_query_info_async(_SELF(self), + attributes, + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_query_info_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + GFileInfo *info; + + info = g_file_output_stream_query_info_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &error); + if (info == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(info); +} + +static VALUE +rg_etag(VALUE self) +{ + return CSTR2RVAL(g_file_output_stream_get_etag(_SELF(self))); +} + +void +Init_gfileoutputstream(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_FILE_OUTPUT_STREAM, "FileOutputStream", mGio); + + RG_DEF_METHOD(query_info, -1); + RG_DEF_METHOD(query_info_async, -1); + RG_DEF_METHOD(query_info_finish, 1); + RG_DEF_METHOD(etag, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofilterinputstream.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofilterinputstream.c new file mode 100644 index 0000000..57cdc94 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofilterinputstream.c @@ -0,0 +1,28 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +void +Init_gfilterinputstream(VALUE mGio) +{ + (void)G_DEF_CLASS(G_TYPE_FILTER_INPUT_STREAM, "FilterInputStream", mGio); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofilteroutputstream.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofilteroutputstream.c new file mode 100644 index 0000000..9d378b1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiofilteroutputstream.c @@ -0,0 +1,28 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +void +Init_gfilteroutputstream(VALUE mGio) +{ + (void)G_DEF_CLASS(G_TYPE_FILTER_OUTPUT_STREAM, "FilterOutputStream", mGio); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioicon.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioicon.c new file mode 100644 index 0000000..1fc8e2d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioicon.c @@ -0,0 +1,69 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mIcon +#define _SELF(value) RVAL2GICON(value) + +static VALUE +rg_s_new_for_string(G_GNUC_UNUSED VALUE self, VALUE string) +{ + GError *error = NULL; + GIcon *icon; + + icon = g_icon_new_for_string(RVAL2CSTR(string), &error); + if (icon == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(icon); +} + +static VALUE +rg_hash(VALUE self) +{ + return GUINT2RVAL(g_icon_hash(_SELF(self))); +} + +static VALUE +rg_operator_icon_equal(VALUE self, VALUE other) +{ + return CBOOL2RVAL(g_icon_equal(_SELF(self), _SELF(other))); +} + +static VALUE +rg_to_string(VALUE self) +{ + return CSTR2RVAL_FREE(g_icon_to_string(_SELF(self))); +} + +void +Init_gicon(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_ICON, "Icon", mGio); + + RG_DEF_SMETHOD(new_for_string, 1); + + RG_DEF_METHOD(hash, 0); + RG_DEF_METHOD_OPERATOR("==", icon_equal, 1); + RG_DEF_METHOD(to_string, 0); + RG_DEF_ALIAS("to_s", "to_string"); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioinetaddress.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioinetaddress.c new file mode 100644 index 0000000..e2e7831 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioinetaddress.c @@ -0,0 +1,118 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mInetAddress +#define _SELF(value) RVAL2GINETADDRESS(value) + +static VALUE +rg_s_new_from_string(G_GNUC_UNUSED VALUE self, VALUE string) +{ + return GOBJ2RVAL_UNREF(g_inet_address_new_from_string(RVAL2CSTR(string))); +} + +/* TODO: Should this take an array instead? */ +static VALUE +rg_s_new_from_bytes(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE rbbytes, rbfamily; + guint8 *bytes; + GSocketFamily family; + + rb_scan_args(argc, argv, "11", &rbbytes, &rbfamily); + bytes = (guint8 *)RVAL2CSTR(rbbytes); + family = RVAL2GSOCKETFAMILY(rbfamily); + + /* TODO: Should check encoding. */ + /* TODO: We can't pass bytes as such, as it will be NULL-terminated. */ + /* TODO: Do we need to deal with G_SOCKET_FAMILY_UNIX? */ + switch (family) { + case G_SOCKET_FAMILY_IPV4: + if (RSTRING_LEN(rbbytes) != 4) + rb_raise(rb_eArgError, "string containing 4 bytes expected"); + break; + case G_SOCKET_FAMILY_IPV6: + if (RSTRING_LEN(rbbytes) != 16) + rb_raise(rb_eArgError, "string containing 16 bytes expected"); + break; + case G_SOCKET_FAMILY_INVALID: + case G_SOCKET_FAMILY_UNIX: + rb_raise(rb_eArgError, "invalid family: %d", family); + default: + rb_raise(rb_eArgError, "unknown family: %d", family); + break; + } + + return GOBJ2RVAL_UNREF(g_inet_address_new_from_bytes(bytes, family)); +} + +static VALUE +rg_s_new_any(G_GNUC_UNUSED VALUE self, VALUE family) +{ + return GOBJ2RVAL_UNREF(g_inet_address_new_any(RVAL2GSOCKETFAMILY(family))); +} + +static VALUE +rg_s_new_loopback(G_GNUC_UNUSED VALUE self, VALUE family) +{ + return GOBJ2RVAL_UNREF(g_inet_address_new_loopback(RVAL2GSOCKETFAMILY(family))); +} + +/* TODO: Return array of bytes instead? */ +static VALUE +rg_to_bytes(VALUE self) +{ + gsize size; + + size = g_inet_address_get_native_size(_SELF(self)); + return rb_str_new((const gchar *)g_inet_address_to_bytes(_SELF(self)), + size); +} + +static VALUE +rg_get_native_size(VALUE self) +{ + return GSIZE2RVAL(g_inet_address_get_native_size(_SELF(self))); +} + +static VALUE +rg_to_string(VALUE self) +{ + return CSTR2RVAL_FREE(g_inet_address_to_string(_SELF(self))); +} + +void +Init_ginetaddress(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_INET_ADDRESS, "InetAddress", mGio); + + RG_DEF_SMETHOD(new_from_string, 1); + RG_DEF_SMETHOD(new_from_bytes, -1); + RG_DEF_SMETHOD(new_any, 1); + RG_DEF_SMETHOD(new_loopback, 1); + + RG_DEF_METHOD(to_bytes, 0); + RG_DEF_METHOD(get_native_size, 0); + RG_DEF_METHOD(to_string, 0); + RG_DEF_ALIAS("to_str", "to_string"); + RG_DEF_ALIAS("to_s", "to_string"); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioinetsocketaddress.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioinetsocketaddress.c new file mode 100644 index 0000000..835d239 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioinetsocketaddress.c @@ -0,0 +1,41 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cInetSocketAddress + +static VALUE +rg_initialize(VALUE self, VALUE address, VALUE port) +{ + G_INITIALIZE(self, g_inet_socket_address_new(RVAL2GINETADDRESS(address), + RVAL2GUINT16(port))); + + return Qnil; +} + +void +Init_ginetsocketaddress(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_INET_SOCKET_ADDRESS, "InetSocketAddress", mGio); + + RG_DEF_METHOD(initialize, 2); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioinitable.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioinitable.c new file mode 100644 index 0000000..d9d5c59 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioinitable.c @@ -0,0 +1,199 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mInitable +#define _SELF(value) RVAL2GINITABLE(value) + +static VALUE +rg_init(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "01", &cancellable); + if (!g_initable_init(_SELF(self), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +struct rbgio_ginitable_new_data { + GObjectClass *gclass; + GCancellable *cancellable; + VALUE rbparameters; + guint index; + guint n_parameters; + GParameter *parameters; + GError *error; +}; + +static VALUE +rbgio_ginitiable_new_parameters_initialize(VALUE key_value, + struct rbgio_ginitable_new_data *data) +{ + VALUE key, value; + GParamSpec *spec; + + if (data->index >= data->n_parameters) + rb_raise(rb_eArgError, + "too many parameters (%d >= %d)", + data->index, data->n_parameters); + + key = rb_ary_entry(key_value, 0); + value = rb_ary_entry(key_value, 1); + + data->parameters[data->index].name = SYMBOL_P(key) ? + rb_id2name(SYM2ID(key)) : + StringValuePtr(key); + spec = g_object_class_find_property(data->gclass, + data->parameters[data->index].name); + if (spec == NULL) + rb_raise(rb_eArgError, + "%s: no such property", + data->parameters[data->index].name); + g_value_init(&(data->parameters[data->index].value), + G_PARAM_SPEC_VALUE_TYPE(spec)); + rbgobj_rvalue_to_gvalue(value, &(data->parameters[data->index].value)); + + data->index++; + + return Qnil; +} + +static VALUE +rbgio_ginitable_new_body(struct rbgio_ginitable_new_data *data) +{ + rb_iterate(rb_each, + data->rbparameters, + rbgio_ginitiable_new_parameters_initialize, + (VALUE)data); + + return (VALUE)g_initable_newv(G_TYPE_FROM_CLASS(data->gclass), + data->n_parameters, + data->parameters, + data->cancellable, + &data->error); +} + +static VALUE +rbgio_ginitable_new_ensure(struct rbgio_ginitable_new_data *data) +{ + guint i; + + g_type_class_unref(data->gclass); + for (i = 0; i < data->n_parameters; i++) + if (G_IS_VALUE(&data->parameters[i].value)) + g_value_unset(&data->parameters[i].value); + + g_free(data->parameters); + + return Qnil; +} + +GObject * +rbgio_ginitable_new(GType type, VALUE parameters, VALUE cancellable) +{ + static ID s_id_length; + GError *error = NULL; + GObject *object; + struct rbgio_ginitable_new_data data; + + if (s_id_length == 0) + s_id_length = rb_intern("length"); + + if (!g_type_is_a(type, G_TYPE_OBJECT)) + rb_raise(rb_eArgError, + "%s is not a descendant of GObject", + g_type_name(type)); + + if (NIL_P(parameters)) { + object = g_initable_newv(type, + 0, + NULL, + RVAL2GCANCELLABLE(cancellable), + &error); + if (object == NULL) + rbgio_raise_error(error); + + return object; + } else { + parameters = rb_convert_type(parameters, + T_HASH, + "Hash", + "to_hash"); + } + + data.gclass = G_OBJECT_CLASS(g_type_class_ref(type)); + data.cancellable = RVAL2GCANCELLABLE(cancellable); + data.rbparameters = parameters; + data.index = 0; + data.n_parameters = RVAL2GUINT(rb_funcall(parameters, s_id_length, 0)); + data.parameters = g_new(GParameter, data.n_parameters); + data.error = NULL; + + object = (GObject *)rb_ensure(rbgio_ginitable_new_body, (VALUE)&data, + rbgio_ginitable_new_ensure, (VALUE)&data); + if (object == NULL) + rbgio_raise_error(data.error); + + return object; +} + +/* NOTE: We don't implement g_initable_new. */ + +/* NOTE: We don't implement g_initable_new_valist. */ + +static VALUE +rg_s_new(int argc, VALUE *argv, VALUE self) +{ + const RGObjClassInfo* info; + VALUE cancellable, parameters; + GObject *object; + VALUE result; + + rb_scan_args(argc, argv, "02", &cancellable, ¶meters); + + info = CLASS2CINFO(self); + if (info->klass != self) + rb_raise(rb_eTypeError, + "%s: class not registered with GLib", + rb_class2name(self)); + + object = rbgio_ginitable_new(info->gtype, parameters, cancellable); + result = GOBJ2RVAL(object); + g_object_unref(object); + + return result; +} + +void +Init_ginitable(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_INITABLE, "Initable", mGio); + + RG_DEF_SMETHOD(new, -1); + + RG_DEF_METHOD(init, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioinputstream.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioinputstream.c new file mode 100644 index 0000000..b07f932 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioinputstream.c @@ -0,0 +1,341 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cInputStream +#define _SELF(value) RVAL2GINPUTSTREAM(value) + +static VALUE s_cReadAsyncResult; + +static VALUE +rg_read(int argc, VALUE *argv, VALUE self) +{ + VALUE rbcount, cancellable, result; + gsize count; + GError *error = NULL; + gssize bytes_read; + + rb_scan_args(argc, argv, "11", &rbcount, &cancellable); + count = RVAL2GSIZE(rbcount); + result = rb_str_new(NULL, count); + bytes_read = g_input_stream_read(_SELF(self), + RSTRING_PTR(result), + count, + RVAL2GCANCELLABLE(cancellable), + &error); + if (bytes_read == -1) + rbgio_raise_error(error); + + rb_str_set_len(result, bytes_read); + rb_str_resize(result, bytes_read); + OBJ_TAINT(result); + + return result; +} + +static VALUE +rg_read_all(int argc, VALUE *argv, VALUE self) +{ + VALUE rbcount, cancellable, result; + gsize count; + GError *error = NULL; + gsize bytes_read; + + rb_scan_args(argc, argv, "11", &rbcount, &cancellable); + count = RVAL2GSIZE(rbcount); + result = rb_str_new(NULL, count); + if (!g_input_stream_read_all(_SELF(self), + RSTRING_PTR(result), + count, + &bytes_read, + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + rb_str_set_len(result, bytes_read); + rb_str_resize(result, bytes_read); + OBJ_TAINT(result); + + return result; +} + +static VALUE +rg_skip(int argc, VALUE *argv, VALUE self) +{ + VALUE count, cancellable; + GError *error = NULL; + gssize bytes_skipped; + + rb_scan_args(argc, argv, "11", &count, &cancellable); + bytes_skipped = g_input_stream_skip(_SELF(self), + RVAL2GSIZE(count), + RVAL2GCANCELLABLE(cancellable), + &error); + if (bytes_skipped == -1) + rbgio_raise_error(error); + + return GSSIZE2RVAL(bytes_skipped); +} + +static VALUE +rg_close(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "01", &cancellable); + if (!g_input_stream_close(_SELF(self), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +struct read_async_result +{ + VALUE string; + GAsyncResult *result; +}; + +static void +read_async_result_mark(struct read_async_result *result) +{ + rb_gc_mark(result->string); +} + +struct read_async_callback_data +{ + GAsyncResult *result; + gpointer user_data; +}; + +static VALUE +read_async_callback_call(VALUE data) +{ + static ID s_id_call; + struct read_async_callback_data *real; + VALUE ary; + struct read_async_result *result; + + if (s_id_call == 0) + s_id_call = rb_intern("call"); + + real = (struct read_async_callback_data *)data; + + ary = (VALUE)real->user_data; + G_CHILD_REMOVE(mGLib, ary); + if (NIL_P(RARRAY_PTR(ary)[1])) + return Qnil; + + result = g_new(struct read_async_result, 1); + result->string = RARRAY_PTR(ary)[0]; + result->result = real->result; + + rb_funcall(RARRAY_PTR(ary)[1], s_id_call, 1, + Data_Wrap_Struct(s_cReadAsyncResult, + read_async_result_mark, + g_free, + result)); + + return Qnil; +} + +static void +read_async_callback(G_GNUC_UNUSED GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + struct read_async_callback_data real = { result, user_data }; + + G_PROTECT_CALLBACK(read_async_callback_call, &real); +} + +static VALUE +rg_read_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbcount, rbio_priority, rbcancellable, block, data; + gsize count; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "12&", &rbcount, &rbio_priority, &rbcancellable, &block); + count = RVAL2GSIZE(rbcount); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + data = rb_assoc_new(rb_str_new(NULL, count), block); + G_CHILD_ADD(mGLib, data); + g_input_stream_read_async(_SELF(self), + RSTRING_PTR(RARRAY_PTR(data)[0]), + count, + io_priority, + cancellable, + read_async_callback, + (gpointer)data); + + return self; +} + +static VALUE +rg_read_finish(VALUE self, VALUE rbresult) +{ + struct read_async_result *result; + GError *error = NULL; + gssize bytes_read; + + Data_Get_Struct(rbresult, struct read_async_result, result); + bytes_read = g_input_stream_read_finish(_SELF(self), + result->result, + &error); + if (bytes_read == -1) + rbgio_raise_error(error); + + rb_str_set_len(result->string, bytes_read); + rb_str_resize(result->string, bytes_read); + OBJ_TAINT(result->string); + + return result->string; +} + +static VALUE +rg_skip_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbcount, rbio_priority, rbcancellable, block; + gsize count; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "12&", &rbcount, &rbio_priority, &rbcancellable, &block); + count = RVAL2GSIZE(rbcount); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_input_stream_skip_async(_SELF(self), + count, + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_skip_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + gssize skipped_bytes; + + skipped_bytes = g_input_stream_skip_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &error); + if (skipped_bytes == -1) + rbgio_raise_error(error); + + return GSSIZE2RVAL(skipped_bytes); +} + +static VALUE +rg_close_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbio_priority, rbcancellable, block; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_input_stream_close_async(_SELF(self), + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_close_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + if (!g_input_stream_skip_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_closed_p(VALUE self) +{ + return CBOOL2RVAL(g_input_stream_is_closed(_SELF(self))); +} + +static VALUE +rg_has_pending_p(VALUE self) +{ + return CBOOL2RVAL(g_input_stream_has_pending(_SELF(self))); +} + +static VALUE +rg_set_pending(VALUE self) +{ + GError *error = NULL; + + if (!g_input_stream_set_pending(_SELF(self), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_clear_pending(VALUE self) +{ + g_input_stream_clear_pending(_SELF(self)); + + return self; +} + +void +Init_ginputstream(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_INPUT_STREAM, "InputStream", mGio); + + s_cReadAsyncResult = rb_define_class_under(RG_TARGET_NAMESPACE, "ReadAsyncResult", rb_cObject); + + RG_DEF_METHOD(read, -1); + RG_DEF_METHOD(read_all, -1); + RG_DEF_METHOD(skip, -1); + RG_DEF_METHOD(close, -1); + RG_DEF_METHOD(read_async, -1); + RG_DEF_METHOD(read_finish, 1); + RG_DEF_METHOD(skip_async, -1); + RG_DEF_METHOD(skip_finish, 1); + RG_DEF_METHOD(close_async, -1); + RG_DEF_METHOD(close_finish, 1); + RG_DEF_METHOD_P(closed, 0); + RG_DEF_METHOD_P(has_pending, 0); + RG_DEF_METHOD(set_pending, 0); + RG_DEF_METHOD(clear_pending, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioio.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioio.c new file mode 100644 index 0000000..2979504 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioio.c @@ -0,0 +1,73 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mIO + +/* NOTE: g_io_error_from_errno doesn't make sense from Ruby. */ + +void +Init_gioerror(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE, error; + + RG_TARGET_NAMESPACE = rb_define_module_under(mGio, "IO"); + + error = rbgio_define_domain_error(RG_TARGET_NAMESPACE, "Error", G_IO_ERROR, "GIOErrorEnum", rb_eIOError); + + rbgio_define_error(RG_TARGET_NAMESPACE, "FailedError", G_IO_ERROR_FAILED, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "NotFoundError", G_IO_ERROR_NOT_FOUND, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "ExistsError", G_IO_ERROR_EXISTS, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "IsDirectoryError", G_IO_ERROR_IS_DIRECTORY, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "NotDirectoryError", G_IO_ERROR_NOT_DIRECTORY, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "NotEmptyError", G_IO_ERROR_NOT_EMPTY, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "NotRegularFileError", G_IO_ERROR_NOT_REGULAR_FILE, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "NotSymbolicLinkError", G_IO_ERROR_NOT_SYMBOLIC_LINK, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "NotMountableFileError", G_IO_ERROR_NOT_MOUNTABLE_FILE, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "FilenameTooLongError", G_IO_ERROR_FILENAME_TOO_LONG, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "InvalidFilenameError", G_IO_ERROR_INVALID_FILENAME, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "TooManyLinksError", G_IO_ERROR_TOO_MANY_LINKS, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "NoSpaceError", G_IO_ERROR_NO_SPACE, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "InvalidArgumentError", G_IO_ERROR_INVALID_ARGUMENT, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "PermissionDeniedError", G_IO_ERROR_PERMISSION_DENIED, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "NotSupportedError", G_IO_ERROR_NOT_SUPPORTED, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "NotMountedError", G_IO_ERROR_NOT_MOUNTED, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "AlreadyMountedError", G_IO_ERROR_ALREADY_MOUNTED, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "ClosedError", G_IO_ERROR_CLOSED, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "CancelledError", G_IO_ERROR_CANCELLED, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "PendingError", G_IO_ERROR_PENDING, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "ReadOnlyError", G_IO_ERROR_READ_ONLY, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "CantCreateBackupError", G_IO_ERROR_CANT_CREATE_BACKUP, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "WrongEtagError", G_IO_ERROR_WRONG_ETAG, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "TimedOutError", G_IO_ERROR_TIMED_OUT, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "WouldRecurseError", G_IO_ERROR_WOULD_RECURSE, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "BusyError", G_IO_ERROR_BUSY, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "WouldBlockError", G_IO_ERROR_WOULD_BLOCK, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "HostNotFoundError", G_IO_ERROR_HOST_NOT_FOUND, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "WouldMergeError", G_IO_ERROR_WOULD_MERGE, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "FailedHandledError", G_IO_ERROR_FAILED_HANDLED, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "TooManyOpenFilesError", G_IO_ERROR_TOO_MANY_OPEN_FILES, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "NotInitializedError", G_IO_ERROR_NOT_INITIALIZED, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "AddressInUseError", G_IO_ERROR_ADDRESS_IN_USE, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "PartialInputError", G_IO_ERROR_PARTIAL_INPUT, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "InvalidDataError", G_IO_ERROR_INVALID_DATA, error); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioiomodule.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioiomodule.c new file mode 100644 index 0000000..b9a5adf --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioiomodule.c @@ -0,0 +1,45 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cIOModule +#define _SELF(value) RVAL2GIOMODULE(value) + +static VALUE +rg_initialize(VALUE self, VALUE filename) +{ + G_INITIALIZE(self, g_io_module_new(RVAL2CSTR(filename))); + + return Qnil; +} + +/* NOTE: No point in implementing g_io_module_query. */ + +void +Init_giomodule(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = G_DEF_CLASS(G_IO_TYPE_MODULE, "IOModule", mGio); + + RG_DEF_METHOD(initialize, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioiomodules.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioiomodules.c new file mode 100644 index 0000000..cee6e4d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioiomodules.c @@ -0,0 +1,47 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mIOModules + +static VALUE +rg_s_load_all_in_directory(G_GNUC_UNUSED VALUE self, VALUE dirname) +{ + return GLIST2ARY_FREE(g_io_modules_load_all_in_directory(RVAL2CSTR(dirname))); +} + +static VALUE +rg_s_scan_all_in_directory(VALUE self, VALUE dirname) +{ + g_io_modules_scan_all_in_directory(RVAL2CSTR(dirname)); + + return self; +} + +void +Init_giomodules(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGio, "IOModules"); + + RG_DEF_SMETHOD(load_all_in_directory, 1); + RG_DEF_SMETHOD(scan_all_in_directory, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioioscheduler.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioioscheduler.c new file mode 100644 index 0000000..fa2919e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioioscheduler.c @@ -0,0 +1,102 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mIOScheduler + +struct ioscheduler_job_callback_data +{ + GIOSchedulerJob *job; + GCancellable *cancellable; + gpointer data; +}; + +static VALUE +ioscheduler_job_callback_call(VALUE data) +{ + static VALUE s_id_call; + struct ioscheduler_job_callback_data *real; + + if (s_id_call == 0) + s_id_call = rb_intern("call"); + + real = (struct ioscheduler_job_callback_data *)data; + + /* TODO: Totally unsure if _UNREF is correct here or not. */ + return rb_funcall(USE_BLOCK_AND_SAVE(real->data), s_id_call, 2, + GOBJ2RVAL_UNREF(real->job), + GOBJ2RVAL_UNREF(real->cancellable)); +} + +static gboolean +ioscheduler_job_callback(GIOSchedulerJob *job, + GCancellable *cancellable, + gpointer data) +{ + struct ioscheduler_job_callback_data real = { job, cancellable, data }; + + return RVAL2CBOOL(G_PROTECT_CALLBACK(ioscheduler_job_callback_call, + &real)); +} + +static void +ioscheduler_job_callback_free(gpointer data) +{ + USE_BLOCK((VALUE)data); +} + +static VALUE +rg_s_push_job(int argc, VALUE *argv, VALUE self) +{ + VALUE rbio_priority, rbcancellable, block; + gint io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "02", &rbio_priority, &rbcancellable); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + block = rb_block_proc(); + SAVE_BLOCK(block); + g_io_scheduler_push_job(ioscheduler_job_callback, + (gpointer)block, + ioscheduler_job_callback_free, + io_priority, + cancellable); + + return self; +} + +static VALUE +rg_s_cancel_all_jobs(VALUE self) +{ + g_io_scheduler_cancel_all_jobs(); + + return self; +} + +void +Init_gioscheduler(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGio, "IOScheduler"); + RG_DEF_SMETHOD(push_job, -1); + RG_DEF_SMETHOD(cancel_all_jobs, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioioschedulerjob.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioioschedulerjob.c new file mode 100644 index 0000000..deee37a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioioschedulerjob.c @@ -0,0 +1,121 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define G_TYPE_IO_SCHEDULER_JOB (g_io_scheduler_job_get_type()) + +#define RVAL2GIOSCHEDULERJOB(object) \ + ((GIOSchedulerJob *)(RVAL2BOXED(object, G_TYPE_IO_SCHEDULER_JOB))) + +#define GIOSCHEDULERJOB2RVAL(object) \ + BOXED2RVAL(object, G_TYPE_IO_SCHEDULER_JOB) + +#define RG_TARGET_NAMESPACE cIOSchedulerJob +#define _SELF(value) RVAL2GIOSCHEDULERJOB(value) + +static GIOSchedulerJob * +ioschedulerjob_copy(const GIOSchedulerJob *job) +{ + return (GIOSchedulerJob *)job; +} + +static void +ioschedulerjob_free(G_GNUC_UNUSED GIOSchedulerJob *job) +{ + return; +} + +static GType +g_io_scheduler_job_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static("GIOSchedulerJob", + (GBoxedCopyFunc)ioschedulerjob_copy, + (GBoxedFreeFunc)ioschedulerjob_free); + + return our_type; +} + +static VALUE +ioscheduler_source_callback_call(VALUE data) +{ + static VALUE s_id_call; + + if (s_id_call == 0) + s_id_call = rb_intern("call"); + + return rb_funcall(USE_BLOCK_AND_SAVE(data), s_id_call, 0); +} + +static gboolean +ioscheduler_source_callback(gpointer data) +{ + return RVAL2CBOOL(G_PROTECT_CALLBACK(ioscheduler_source_callback_call, + data)); +} + +static void +ioscheduler_source_callback_free(gpointer data) +{ + USE_BLOCK(data); +} + +static VALUE +rg_send_to_mainloop(VALUE self) +{ + VALUE block; + + block = rb_block_proc(); + SAVE_BLOCK(block); + + return CBOOL2RVAL(g_io_scheduler_job_send_to_mainloop(_SELF(self), + ioscheduler_source_callback, + (gpointer)block, + ioscheduler_source_callback_free)); +} + +static VALUE +rg_send_to_mainloop_async(VALUE self) +{ + VALUE block; + + block = rb_block_proc(); + SAVE_BLOCK(block); + + g_io_scheduler_job_send_to_mainloop_async(_SELF(self), + ioscheduler_source_callback, + (gpointer)block, + ioscheduler_source_callback_free); + + return self; +} + +void +Init_gioschedulerjob(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_IO_SCHEDULER_JOB, "IOSchedulerJob", mGio); + + RG_DEF_METHOD(send_to_mainloop, 0); + RG_DEF_METHOD(send_to_mainloop_async, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioiostream.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioiostream.c new file mode 100644 index 0000000..0420f9e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioiostream.c @@ -0,0 +1,107 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cIOStream +#define _SELF(value) RVAL2GIOSTREAM(value) + +static VALUE +rg_close(VALUE self, VALUE cancellable) +{ + GError *error = NULL; + + if (!g_io_stream_close(_SELF(self), RVAL2GCANCELLABLE(cancellable), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_close_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbio_priority, rbcancellable, block; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "01&", &rbio_priority, &rbcancellable, &block); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_io_stream_close_async(_SELF(self), + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_close_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + + if (!g_io_stream_close_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_has_pending_p(VALUE self) +{ + return CBOOL2RVAL(g_io_stream_has_pending(_SELF(self))); +} + +static VALUE +rg_set_pending(VALUE self) +{ + GError *error = NULL; + + if (!g_io_stream_set_pending(_SELF(self), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_clear_pending(VALUE self) +{ + g_io_stream_clear_pending(_SELF(self)); + + return self; +} + +void +Init_giostream(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_IO_STREAM, "IOStream", mGio); + + RG_DEF_METHOD(close, 1); + RG_DEF_METHOD(close_async, -1); + RG_DEF_METHOD(close_finish, 1); + RG_DEF_METHOD_P(has_pending, 0); + RG_DEF_METHOD(set_pending, 0); + RG_DEF_METHOD(clear_pending, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioloadableicon.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioloadableicon.c new file mode 100644 index 0000000..89c97ff --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioloadableicon.c @@ -0,0 +1,92 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mLoadableIcon +#define _SELF(value) RVAL2GLOADABLEICON(value) + +static VALUE +rg_load(int argc, VALUE *argv, VALUE self) +{ + VALUE size, cancellable; + char *type; + GError *error = NULL; + GInputStream *stream; + + rb_scan_args(argc, argv, "11", &size, &cancellable); + stream = g_loadable_icon_load(_SELF(self), + NUM2INT(size), + &type, + RVAL2GCANCELLABLE(cancellable), + &error); + if (error != NULL) + rbgio_raise_error(error); + + return rb_assoc_new(GOBJ2RVAL_UNREF(stream), CSTR2RVAL_FREE(type)); +} + +static VALUE +rg_load_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbsize, rbcancellable, block; + int size; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "11&", &rbsize, &rbcancellable, &block); + size = NUM2INT(rbsize); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_loadable_icon_load_async(_SELF(self), + size, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_load_finish(VALUE self, VALUE result) +{ + char *type; + GError *error = NULL; + GInputStream *stream; + + stream = g_loadable_icon_load_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &type, + &error); + if (error != NULL) + rbgio_raise_error(error); + + return rb_assoc_new(GOBJ2RVAL_UNREF(stream), CSTR2RVAL_FREE(type)); +} + +void +Init_gloadableicon(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_LOADABLE_ICON, "LoadableIcon", mGio); + + RG_DEF_METHOD(load, -1); + RG_DEF_METHOD(load_async, -1); + RG_DEF_METHOD(load_finish, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiomemoryinputstream.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiomemoryinputstream.c new file mode 100644 index 0000000..4a70270 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiomemoryinputstream.c @@ -0,0 +1,67 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cMemoryInputStream +#define _SELF(value) RVAL2GMEMORYINPUTSTREAM(value) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE data; + + rb_scan_args(argc, argv, "01", &data); + if (NIL_P(data)) { + G_INITIALIZE(self, g_memory_input_stream_new()); + return Qnil; + } + + StringValue(data); + G_RELATIVE(self, data); + G_INITIALIZE(self, g_memory_input_stream_new_from_data(RSTRING_PTR(data), + RSTRING_LEN(data), + NULL)); + + return Qnil; +} + +static VALUE +rg_add_data(VALUE self, VALUE data) +{ + StringValue(data); + G_RELATIVE(self, data); + g_memory_input_stream_add_data(_SELF(self), + RSTRING_PTR(data), + RSTRING_LEN(data), + NULL); + + return self; +} + +void +Init_gmemoryinputstream(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_MEMORY_INPUT_STREAM, "MemoryInputStream", mGio); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(add_data, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiomemoryoutputstream.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiomemoryoutputstream.c new file mode 100644 index 0000000..b4fb75b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiomemoryoutputstream.c @@ -0,0 +1,44 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cMemoryOutputStream + +/* TODO: Take string argument? */ +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, g_memory_output_stream_new(NULL, + 0, + g_realloc, + g_free)); + + return Qnil; +} + +void +Init_gmemoryoutputstream(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_MEMORY_OUTPUT_STREAM, "MemoryOutputStream", mGio); + + RG_DEF_METHOD(initialize, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiomount.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiomount.c new file mode 100644 index 0000000..064a395 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiomount.c @@ -0,0 +1,286 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mMount +#define _SELF(value) RVAL2GMOUNT(value) + +static VALUE +rg_name(VALUE self) +{ + return CSTR2RVAL_FREE(g_mount_get_name(_SELF(self))); +} + +static VALUE +rg_uuid(VALUE self) +{ + return CSTR2RVAL_FREE(g_mount_get_uuid(_SELF(self))); +} + +static VALUE +rg_icon(VALUE self) +{ + return GOBJ2RVAL_UNREF(g_mount_get_icon(_SELF(self))); +} + +static VALUE +rg_drive(VALUE self) +{ + return GOBJ2RVAL_UNREF(g_mount_get_drive(_SELF(self))); +} + +static VALUE +rg_root(VALUE self) +{ + return GOBJ2RVAL_UNREF(g_mount_get_root(_SELF(self))); +} + +static VALUE +rg_volume(VALUE self) +{ + return GOBJ2RVAL_UNREF(g_mount_get_volume(_SELF(self))); +} + +static VALUE +rg_default_location(VALUE self) +{ + return GOBJ2RVAL_UNREF(g_mount_get_default_location(_SELF(self))); +} + +static VALUE +rg_can_unmount_p(VALUE self) +{ + return CBOOL2RVAL(g_mount_can_unmount(_SELF(self))); +} + +typedef void (*UnmountEjectMethod)(GMount *, + GMountUnmountFlags, + GMountOperation *, + GCancellable *, + GAsyncReadyCallback, + gpointer); + +static VALUE +unmount_eject_method(UnmountEjectMethod method, int argc, VALUE *argv, VALUE self) +{ + VALUE rbflags, rbmount_operation, rbcancellable, block; + GMountUnmountFlags flags; + GMountOperation *mount_operation; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "03&", &rbflags, &rbmount_operation, &rbcancellable, &block); + flags = RVAL2GMOUNTUNMOUNTFLAGSDEFAULT(rbflags); + mount_operation = RVAL2GMOUNTOPERATION(rbmount_operation); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + method(_SELF(self), + flags, + mount_operation, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_unmount_with_operation(int argc, VALUE *argv, VALUE self) +{ + return unmount_eject_method(g_mount_unmount_with_operation, argc, argv, self); +} + +typedef gboolean (*BooleanFinishMethod)(GMount *, + GAsyncResult *, + GError **); + +static VALUE +boolean_finish_method(BooleanFinishMethod method, VALUE self, VALUE result) +{ + GError *error = NULL; + + if (!method(_SELF(self), RVAL2GASYNCRESULT(result), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_unmount_with_operation_finish(VALUE self, VALUE result) +{ + return boolean_finish_method(g_mount_unmount_with_operation_finish, self, result); +} + +static VALUE +rg_remount(int argc, VALUE *argv, VALUE self) +{ + VALUE rbflags, rbmount_operation, rbcancellable, block; + GMountMountFlags flags; + GMountOperation *mount_operation; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "03&", &rbflags, &rbmount_operation, &rbcancellable, &block); + flags = RVAL2GMOUNTMOUNTFLAGSDEFAULT(rbflags); + mount_operation = RVAL2GMOUNTOPERATION(rbmount_operation); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_mount_remount(_SELF(self), + flags, + mount_operation, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_remount_finish(VALUE self, VALUE result) +{ + return boolean_finish_method(g_mount_remount_finish, self, result); +} + +static VALUE +rg_can_eject_p(VALUE self) +{ + return CBOOL2RVAL(g_mount_can_eject(_SELF(self))); +} + +static VALUE +rg_eject_with_operation(int argc, VALUE *argv, VALUE self) +{ + return unmount_eject_method(g_mount_eject_with_operation, argc, argv, self); +} + +static VALUE +rg_eject_with_operation_finish(VALUE self, VALUE result) +{ + return boolean_finish_method(g_mount_eject_with_operation_finish, self, result); +} + +static VALUE +rg_guess_content_type(int argc, VALUE *argv, VALUE self) +{ + VALUE rbforce_rescan, rbcancellable, block; + gboolean force_rescan; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "02&", &rbforce_rescan, &rbcancellable, &block); + force_rescan = RVAL2CBOOL(rbforce_rescan); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_mount_guess_content_type(_SELF(self), + force_rescan, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_guess_content_type_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + gchar **content_types; + + content_types = g_mount_guess_content_type_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &error); + if (content_types == NULL) + rbgio_raise_error(error); + + return STRV2RVAL_FREE(content_types); +} + +static VALUE +rg_guess_content_type_sync(int argc, VALUE *argv, VALUE self) +{ + VALUE force_rescan, cancellable; + GError *error = NULL; + gchar **content_types; + + rb_scan_args(argc, argv, "02", &force_rescan, &cancellable); + content_types = g_mount_guess_content_type_sync(_SELF(self), + RVAL2CBOOL(force_rescan), + RVAL2GCANCELLABLE(cancellable), + &error); + if (content_types == NULL) + rbgio_raise_error(error); + + return STRV2RVAL_FREE(content_types); +} + +static VALUE +rg_shadowed_p(VALUE self) +{ + return CBOOL2RVAL(g_mount_is_shadowed(_SELF(self))); +} + +static VALUE +rg_shadow(VALUE self) +{ + g_mount_shadow(_SELF(self)); + + return self; +} + +static VALUE +rg_unshadow(VALUE self) +{ + g_mount_unshadow(_SELF(self)); + + return self; +} + +void +Init_gmount(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_MOUNT, "Mount", mGio); + + G_DEF_CLASS(G_TYPE_MOUNT_MOUNT_FLAGS, "MountFlags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_MOUNT_MOUNT_FLAGS, "G_MOUNT_"); + + G_DEF_CLASS(G_TYPE_MOUNT_UNMOUNT_FLAGS, "UnmountFlags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_MOUNT_UNMOUNT_FLAGS, "G_MOUNT_"); + + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(uuid, 0); + RG_DEF_METHOD(icon, 0); + RG_DEF_METHOD(drive, 0); + RG_DEF_METHOD(root, 0); + RG_DEF_METHOD(volume, 0); + RG_DEF_METHOD(default_location, 0); + RG_DEF_METHOD_P(can_unmount, 0); + RG_DEF_METHOD(unmount_with_operation, -1); + RG_DEF_METHOD(unmount_with_operation_finish, 1); + RG_DEF_METHOD(remount, -1); + RG_DEF_METHOD(remount_finish, 1); + RG_DEF_METHOD_P(can_eject, 0); + RG_DEF_METHOD(eject_with_operation, -1); + RG_DEF_METHOD(eject_with_operation_finish, 1); + RG_DEF_METHOD(guess_content_type, -1); + RG_DEF_METHOD(guess_content_type_finish, 1); + RG_DEF_METHOD(guess_content_type_sync, -1); + RG_DEF_METHOD_P(shadowed, 0); + RG_DEF_METHOD(shadow, 0); + RG_DEF_METHOD(unshadow, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiomountoperation.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiomountoperation.c new file mode 100644 index 0000000..f4583a1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiomountoperation.c @@ -0,0 +1,53 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cMountOperation +#define _SELF(value) RVAL2GMOUNTOPERATION(value) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, g_mount_operation_new()); + + return Qnil; +} + +static VALUE +rg_reply(VALUE self, VALUE value) +{ + g_mount_operation_reply(_SELF(self), RVAL2GMOUNTOPERATIONRESULT(value)); + + return self; +} + +void +Init_gmountoperation(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_MOUNT_OPERATION, "MountOperation", mGio); + + G_DEF_CLASS(G_TYPE_MOUNT_OPERATION_RESULT, "Result", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_MOUNT_OPERATION_RESULT, "G_MOUNT_OPERATION_"); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(reply, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgionetworkaddress.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgionetworkaddress.c new file mode 100644 index 0000000..f305255 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgionetworkaddress.c @@ -0,0 +1,59 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cNetworkAddress +#define _SELF(value) RVAL2GNETWORKADDRESS(value) + +static VALUE +rg_initialize(VALUE self, VALUE hostname, VALUE port) +{ + G_INITIALIZE(self, g_network_address_new(RVAL2CSTR(hostname), + RVAL2GUINT16(port))); + + return Qnil; +} + +static VALUE +rg_s_parse(G_GNUC_UNUSED VALUE self, VALUE host_and_port, VALUE default_port) +{ + GError *error = NULL; + GSocketConnectable *connectable; + + connectable = g_network_address_parse(RVAL2CSTR(host_and_port), + RVAL2GUINT16(default_port), + &error); + if (connectable == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(connectable); +} + +void +Init_gnetworkaddress(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_NETWORK_ADDRESS, "NetworkAddress", mGio); + + RG_DEF_SMETHOD(parse, 2); + + RG_DEF_METHOD(initialize, 2); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgionetworkservice.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgionetworkservice.c new file mode 100644 index 0000000..025f196 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgionetworkservice.c @@ -0,0 +1,45 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cNetworkService +#define _SELF(value) RVAL2GNETWORKSERVICE(value) + +static VALUE +rg_initialize(VALUE self, VALUE service, VALUE protocol, VALUE domain) +{ + /* TODO: If these are infected, so should they be when returned. How + * do we deal with that? */ + G_INITIALIZE(self, g_network_service_new(RVAL2CSTR(service), + RVAL2CSTR(protocol), + RVAL2CSTR(domain))); + + return Qnil; +} + +void +Init_gnetworkservice(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_NETWORK_SERVICE, "NetworkService", mGio); + + RG_DEF_METHOD(initialize, 3); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiooutputstream.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiooutputstream.c new file mode 100644 index 0000000..f449e10 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiooutputstream.c @@ -0,0 +1,331 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cOutputStream +#define _SELF(value) RVAL2GOUTPUTSTREAM(value) + +#define RVAL2GOUTPUTSTREAMSPLICEFLAGSDEFAULT(value) \ + RVAL2TYPE_WITH_DEFAULT((value), \ + RVAL2GOUTPUTSTREAMSPLICEFLAGS, \ + G_OUTPUT_STREAM_SPLICE_NONE) + +static VALUE +rg_write(int argc, VALUE *argv, VALUE self) +{ + VALUE rbbuffer, cancellable; + const char *buffer; + GError *error = NULL; + gssize bytes_written; + + rb_scan_args(argc, argv, "11", &rbbuffer, &cancellable); + buffer = RVAL2CSTR(rbbuffer); + bytes_written = g_output_stream_write(_SELF(self), + buffer, + (gsize)RSTRING_LEN(rbbuffer), + RVAL2GCANCELLABLE(cancellable), + &error); + if (bytes_written == -1) + rbgio_raise_error(error); + + return GSSIZE2RVAL(bytes_written); +} + +static VALUE +rg_write_all(int argc, VALUE *argv, VALUE self) +{ + VALUE rbbuffer, cancellable; + const char *buffer; + gsize bytes_written; + GError *error = NULL; + + rb_scan_args(argc, argv, "11", &rbbuffer, &cancellable); + buffer = RVAL2CSTR(rbbuffer); + if (!g_output_stream_write_all(_SELF(self), + buffer, + (gsize)RSTRING_LEN(rbbuffer), + &bytes_written, + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return GSIZE2RVAL(bytes_written); +} + +static VALUE +rg_splice(int argc, VALUE *argv, VALUE self) +{ + VALUE source, flags, cancellable; + GError *error = NULL; + gssize bytes_spliced; + + rb_scan_args(argc, argv, "12", &source, &flags, &cancellable); + bytes_spliced = g_output_stream_splice(_SELF(self), + RVAL2GINPUTSTREAM(source), + RVAL2GOUTPUTSTREAMSPLICEFLAGSDEFAULT(flags), + RVAL2GCANCELLABLE(cancellable), + &error); + if (bytes_spliced == -1) + rbgio_raise_error(error); + + return GSSIZE2RVAL(bytes_spliced); +} + +typedef gboolean (*CancellableMethod)(GOutputStream *, GCancellable *, GError **); + +static VALUE +cancellable_method(CancellableMethod method, int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "01", &cancellable); + if (!method(_SELF(self), RVAL2GCANCELLABLE(cancellable), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_flush(int argc, VALUE *argv, VALUE self) +{ + return cancellable_method(g_output_stream_flush, argc, argv, self); +} + +static VALUE +rg_close(int argc, VALUE *argv, VALUE self) +{ + return cancellable_method(g_output_stream_close, argc, argv, self); +} + +/* TODO: Does it make sense to use buffer and count? We should probably + * provide a better wrapper that simply pumps out buffer while count hasn't + * been reached, calling the callback with the bytes written, then with the + * result. */ +static VALUE +rg_write_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbbuffer, rbcount, rbio_priority, rbcancellable, block; + const gchar *buffer; + gsize count; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "22&", &rbbuffer, &rbcount, &rbio_priority, &rbcancellable, &block); + buffer = RVAL2CSTR(rbbuffer); + count = RVAL2GSIZE(rbcount); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_output_stream_write_async(_SELF(self), + buffer, + count, + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +typedef gssize (*SSizeFinishMethod)(GOutputStream *, GAsyncResult *, GError **); + +static VALUE +ssize_finish_method(SSizeFinishMethod method, VALUE self, VALUE result) +{ + GError *error = NULL; + gssize bytes_read; + + bytes_read = method(_SELF(self), RVAL2GASYNCRESULT(result), &error); + if (error != NULL) + rbgio_raise_error(error); + + return GSSIZE2RVAL(bytes_read); +} + +static VALUE +rg_write_finish(VALUE self, VALUE result) +{ + return ssize_finish_method(g_output_stream_write_finish, self, result); +} + +static VALUE +rg_splice_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbsource, rbflags, rbio_priority, rbcancellable, block; + GInputStream *source; + GOutputStreamSpliceFlags flags; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "12&", &rbsource, &rbflags, &rbio_priority, &rbcancellable, &block); + source = RVAL2GINPUTSTREAM(rbsource); + flags = RVAL2GOUTPUTSTREAMSPLICEFLAGSDEFAULT(rbflags); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_output_stream_splice_async(_SELF(self), + source, + flags, + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_splice_finish(VALUE self, VALUE result) +{ + return ssize_finish_method(g_output_stream_splice_finish, self, result); +} + +static VALUE +rg_flush_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbio_priority, rbcancellable, block; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_output_stream_flush_async(_SELF(self), + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +typedef gboolean (*BooleanFinishMethod)(GOutputStream *, GAsyncResult *, GError **); + +static VALUE +boolean_finish_method(BooleanFinishMethod method, VALUE self, VALUE result) +{ + GError *error = NULL; + + if (!method(_SELF(self), RVAL2GASYNCRESULT(result), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_flush_finish(VALUE self, VALUE result) +{ + return boolean_finish_method(g_output_stream_flush_finish, self, result); +} + +static VALUE +rg_close_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbio_priority, rbcancellable, block; + int io_priority; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block); + io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_output_stream_close_async(_SELF(self), + io_priority, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_close_finish(VALUE self, VALUE result) +{ + return boolean_finish_method(g_output_stream_close_finish, self, result); +} + +static VALUE +rg_closing_p(VALUE self) +{ + return CBOOL2RVAL(g_output_stream_is_closing(_SELF(self))); +} + +static VALUE +rg_closed_p(VALUE self) +{ + return CBOOL2RVAL(g_output_stream_is_closed(_SELF(self))); +} + +static VALUE +rg_has_pending_p(VALUE self) +{ + return CBOOL2RVAL(g_output_stream_has_pending(_SELF(self))); +} + +static VALUE +rg_set_pending(VALUE self) +{ + GError *error = NULL; + + if (!g_output_stream_set_pending(_SELF(self), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_clear_pending(VALUE self) +{ + g_output_stream_clear_pending(_SELF(self)); + + return self; +} + +void +Init_goutputstream(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_OUTPUT_STREAM, "OutputStream", mGio); + + G_DEF_CLASS(G_TYPE_OUTPUT_STREAM_SPLICE_FLAGS, "SpliceFlags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_OUTPUT_STREAM_SPLICE_FLAGS, "G_OUTPUT_STREAM_"); + + RG_DEF_METHOD(write, -1); + RG_DEF_METHOD(write_all, -1); + RG_DEF_METHOD(splice, -1); + RG_DEF_METHOD(flush, -1); + RG_DEF_METHOD(close, -1); + RG_DEF_METHOD(write_async, -1); + RG_DEF_METHOD(write_finish, 1); + RG_DEF_METHOD(splice_async, -1); + RG_DEF_METHOD(splice_finish, 1); + RG_DEF_METHOD(flush_async, -1); + RG_DEF_METHOD(flush_finish, 1); + RG_DEF_METHOD(close_async, -1); + RG_DEF_METHOD(close_finish, 0); + RG_DEF_METHOD_P(closing, 0); + RG_DEF_METHOD_P(closed, 0); + RG_DEF_METHOD_P(has_pending, 0); + RG_DEF_METHOD(set_pending, 0); + RG_DEF_METHOD(clear_pending, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioresolver.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioresolver.c new file mode 100644 index 0000000..59114c0 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioresolver.c @@ -0,0 +1,230 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cResolver +#define _SELF(value) RVAL2GRESOLVER(value) + +static VALUE +rg_s_default(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL_UNREF(g_resolver_get_default()); +} + +static VALUE +rg_s_set_default(G_GNUC_UNUSED VALUE self, VALUE resolver) +{ + g_resolver_set_default(_SELF(resolver)); + + return self; +} + +static VALUE +rg_lookup_by_name(VALUE self, VALUE hostname, VALUE cancellable) +{ + GError *error = NULL; + GList *addresses; + + addresses = g_resolver_lookup_by_name(_SELF(self), + RVAL2CSTR(hostname), + RVAL2GCANCELLABLE(cancellable), + &error); + if (addresses == NULL) + rbgio_raise_error(error); + + return GLIST2ARY_UNREF_FREE(addresses); +} + +static VALUE +rg_lookup_by_name_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbhostname, rbcancellable, block; + const gchar *hostname; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "11&", &hostname, &rbcancellable, &block); + hostname = RVAL2CSTR(rbhostname); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_resolver_lookup_by_name_async(_SELF(self), + hostname, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_lookup_by_name_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + GList *addresses; + + addresses = g_resolver_lookup_by_name_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &error); + if (addresses == NULL) + rbgio_raise_error(error); + + return GLIST2ARY_UNREF_FREE(addresses); +} + +static VALUE +rg_lookup_by_address(int argc, VALUE *argv, VALUE self) +{ + VALUE address, cancellable; + GError *error = NULL; + gchar *hostname; + + rb_scan_args(argc, argv, "11", &address, &cancellable); + hostname = g_resolver_lookup_by_address(_SELF(self), + RVAL2GINETADDRESS(address), + RVAL2GCANCELLABLE(cancellable), + &error); + if (hostname == NULL) + rbgio_raise_error(error); + + return CSTR2RVAL_FREE(hostname); +} + +static VALUE +rg_lookup_by_address_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbaddress, rbcancellable, block; + GInetAddress *address; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "11&", &rbaddress, &rbcancellable, &block); + address = RVAL2GINETADDRESS(rbaddress); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_resolver_lookup_by_address_async(_SELF(self), + address, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_lookup_by_address_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + gchar *hostname; + + hostname = g_resolver_lookup_by_address_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &error); + if (hostname == NULL) + rbgio_raise_error(error); + + return CSTR2RVAL_FREE(hostname); +} + +static VALUE +rg_lookup_service(int argc, VALUE *argv, VALUE self) +{ + VALUE service, protocol, domain, cancellable; + GError *error = NULL; + GList *targets; + + rb_scan_args(argc, argv, "31", &service, &protocol, &domain, &cancellable); + targets = g_resolver_lookup_service(_SELF(self), + RVAL2CSTR(service), + RVAL2CSTR(protocol), + RVAL2CSTR(domain), + RVAL2GCANCELLABLE(cancellable), + &error); + if (targets == NULL) + rbgio_raise_error(error); + + return GLIST2ARY_UNREF_FREE(targets); +} + +static VALUE +rg_lookup_service_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbservice, rbprotocol, rbdomain, rbcancellable, block; + const gchar *service; + const gchar *protocol; + const gchar *domain; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "31&", &rbservice, &rbprotocol, &rbdomain, &rbcancellable, &block); + service = RVAL2CSTR(rbservice); + protocol = RVAL2CSTR(rbprotocol); + domain = RVAL2CSTR(rbdomain); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_resolver_lookup_service_async(_SELF(self), + service, + protocol, + domain, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_lookup_service_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + GList *targets; + + targets = g_resolver_lookup_service_finish(_SELF(self), RVAL2GASYNCRESULT(result), &error); + if (targets == NULL) + rbgio_raise_error(error); + + return GLIST2ARY_UNREF_FREE(targets); +} + +void +Init_gresolver(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE, error; + + RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_RESOLVER, "Resolver", mGio); + + RG_DEF_SMETHOD(default, 0); + RG_DEF_SMETHOD(set_default, 1); + + /* TODO: Taint result of these methods? */ + RG_DEF_METHOD(lookup_by_name, 2); + RG_DEF_METHOD(lookup_by_name_async, -1); + RG_DEF_METHOD(lookup_by_name_finish, 1); + RG_DEF_METHOD(lookup_by_address, -1); + RG_DEF_METHOD(lookup_by_address_async, -1); + RG_DEF_METHOD(lookup_by_address_finish, 1); + RG_DEF_METHOD(lookup_service, -1); + RG_DEF_METHOD(lookup_service_async, -1); + RG_DEF_METHOD(lookup_service_finish, 1); + + error = rbgio_define_domain_error(RG_TARGET_NAMESPACE, "Error", G_RESOLVER_ERROR, "GResolverErrorEnum", rb_eIOError); + + rbgio_define_error(RG_TARGET_NAMESPACE, "NotFoundError", G_RESOLVER_ERROR_NOT_FOUND, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "TemporaryFailureError", G_RESOLVER_ERROR_TEMPORARY_FAILURE, error); + rbgio_define_error(RG_TARGET_NAMESPACE, "InternalError", G_RESOLVER_ERROR_INTERNAL, error); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioseekable.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioseekable.c new file mode 100644 index 0000000..67c4b6d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgioseekable.c @@ -0,0 +1,91 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mSeekable +#define _SELF(value) RVAL2GSEEKABLE(value) + +#define RVAL2GSEEKTYPEDEFAULT(value) \ + RVAL2TYPE_WITH_DEFAULT((value), NUM2INT, G_SEEK_CUR) + +static VALUE +rg_tell(VALUE self) +{ + return GOFFSET2RVAL(g_seekable_tell(_SELF(self))); +} + +static VALUE +rg_can_seek_p(VALUE self) +{ + return CBOOL2RVAL(g_seekable_can_seek(_SELF(self))); +} + +static VALUE +rg_seek(int argc, VALUE *argv, VALUE self) +{ + VALUE offset, type, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "12", &offset, &type, &cancellable); + if (!g_seekable_seek(_SELF(self), + RVAL2GOFFSET(offset), + RVAL2GSEEKTYPEDEFAULT(type), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_can_truncate_p(VALUE self) +{ + return CBOOL2RVAL(g_seekable_can_truncate(_SELF(self))); +} + +static VALUE +rg_truncate(int argc, VALUE *argv, VALUE self) +{ + VALUE offset, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "11", &offset, &cancellable); + if (!g_seekable_truncate(_SELF(self), + RVAL2GOFFSET(offset), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +void +Init_gseekable(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_SEEKABLE, "Seekable", mGio); + + RG_DEF_METHOD(tell, 0); + RG_DEF_METHOD_P(can_seek, 0); + RG_DEF_METHOD(seek, -1); + RG_DEF_METHOD_P(can_truncate, 0); + RG_DEF_METHOD(truncate, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosimpleasyncresult.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosimpleasyncresult.c new file mode 100644 index 0000000..de64346 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosimpleasyncresult.c @@ -0,0 +1,152 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cSimpleAsyncResult +#define _SELF(value) RVAL2GSIMPLEASYNCRESULT(value) + +static VALUE +rg_initialize(VALUE self, VALUE object) +{ + VALUE block; + + /* TODO: I have absolutely no idea if this makes sense. Should we even + * be providing this method? */ + block = rb_block_proc(); + SAVE_BLOCK(block); + G_INITIALIZE(self, + g_simple_async_result_new(RVAL2GOBJ(object), + rbgio_async_ready_callback, + (gpointer)block, + (gpointer)block)); + + return Qnil; +} + +/* NOTE: Can't implement g_simple_async_result_new_error. */ + +/* NOTE: Can't implement g_simple_async_result_new_from_error. */ + +/* NOTE: Can't implement g_simple_async_result_set_op_res_gpointer. */ + +/* NOTE: Can't implement g_simple_async_result_get_op_res_gpointer. */ + +static VALUE +rg_set_op_res_gssize(VALUE self, VALUE op_res) +{ + g_simple_async_result_set_op_res_gssize(_SELF(self), + RVAL2GSSIZE(op_res)); + + return self; +} + +static VALUE +rg_op_res_gssize(VALUE self) +{ + return GSSIZE2RVAL(g_simple_async_result_get_op_res_gssize(_SELF(self))); +} + +static VALUE +rg_set_op_res_gboolean(VALUE self, VALUE op_res) +{ + g_simple_async_result_set_op_res_gboolean(_SELF(self), + RVAL2CBOOL(op_res)); + + return self; +} + +static VALUE +rg_op_res_gboolean(VALUE self) +{ + return CBOOL2RVAL(g_simple_async_result_get_op_res_gboolean(_SELF(self))); +} + +static VALUE +rg_source_tag(VALUE self) +{ + return (VALUE)g_simple_async_result_get_source_tag(_SELF(self)); +} + +static VALUE +rg_valid_p(VALUE self, VALUE source, VALUE source_tag) +{ + return CBOOL2RVAL(g_simple_async_result_is_valid(RVAL2GASYNCRESULT(self), + RVAL2GOBJ(source), + (gpointer)source_tag)); +} + +static VALUE +rg_set_handle_cancellation(VALUE self, VALUE handle_cancellation) +{ + g_simple_async_result_set_handle_cancellation(_SELF(self), + RVAL2CBOOL(handle_cancellation)); + + return self; +} + +static VALUE +rg_complete(VALUE self) +{ + g_simple_async_result_complete(_SELF(self)); + + return self; +} + +static VALUE +rg_complete_in_idle(VALUE self) +{ + g_simple_async_result_complete_in_idle(_SELF(self)); + + return self; +} + +/* TODO: Should we implement g_simple_async_result_run_in_thread? I'd say no, + * but I'm not sure. */ + +/* NOTE: Can't implement g_simple_async_result_set_from_error. */ + +/* NOTE: Can't implement g_simple_async_result_propagate_error. */ + +/* NOTE: Can't implement g_simple_async_result_set_error. */ + +/* NOTE: Can't implement g_simple_async_result_set_error_va. */ + +/* NOTE: Can't implement g_simple_async_result_report_error_in_idle. */ + +/* NOTE: Can't implement g_simple_async_result_report_gerror_in_idle. */ + +void +Init_gsimpleasyncresult(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_SIMPLE_ASYNC_RESULT, "SimpleAsyncResult", mGio); + + RG_DEF_METHOD(initialize, 1); + RG_DEF_METHOD(set_op_res_gssize, 1); + RG_DEF_METHOD(op_res_gssize, 0); + RG_DEF_METHOD(set_op_res_gboolean, 1); + RG_DEF_METHOD(op_res_gboolean, 0); + RG_DEF_METHOD(source_tag, 0); + RG_DEF_METHOD_P(valid, 2); + RG_DEF_METHOD(set_handle_cancellation, 1); + RG_DEF_METHOD(complete, 0); + RG_DEF_METHOD(complete_in_idle, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocket.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocket.c new file mode 100644 index 0000000..08063ec --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocket.c @@ -0,0 +1,390 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011-2012 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cSocket +#define _SELF(value) RVAL2GSOCKET(value) + +static ID id_call; + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE family, type, protocol; + GError *error = NULL; + GSocket *socket; + + rb_scan_args(argc, argv, "21", &family, &type, &protocol); + socket = g_socket_new(RVAL2GSOCKETFAMILY(family), + RVAL2GSOCKETTYPE(type), + RVAL2GSOCKETPROTOCOLDEFAULT(protocol), + &error); + if (socket == NULL) + rbgio_raise_error(error); + + G_INITIALIZE(self, socket); + + return Qnil; +} + +static VALUE +rg_s_new_from_fd(G_GNUC_UNUSED VALUE self, VALUE id) +{ + GError *error = NULL; + GSocket *socket; + + socket = g_socket_new_from_fd(RVAL2FD(id), &error); + if (socket == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(socket); +} + +static VALUE +rg_bind(VALUE self, VALUE address, VALUE allow_reuse) +{ + GError *error = NULL; + + if (!g_socket_bind(_SELF(self), + RVAL2GSOCKETADDRESS(address), + RVAL2CBOOL(allow_reuse), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_listen(VALUE self) +{ + GError *error = NULL; + + if (!g_socket_listen(_SELF(self), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_accept(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + GSocket *socket; + + rb_scan_args(argc, argv, "01", &cancellable); + socket = g_socket_accept(_SELF(self), + RVAL2GCANCELLABLE(cancellable), + &error); + if (socket == NULL) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_connect(int argc, VALUE *argv, VALUE self) +{ + VALUE address, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "11", &address, &cancellable); + if (!g_socket_connect(_SELF(self), + RVAL2GSOCKETADDRESS(address), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +/* TODO: This makes very little sense in Ruby. How do we deal with it? */ +static VALUE +rg_check_connect_result(VALUE self) +{ + GError *error = NULL; + + if (!g_socket_check_connect_result(_SELF(self), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_receive(int argc, VALUE *argv, VALUE self) +{ + VALUE rbbytes, cancellable, result; + GError *error = NULL; + gsize bytes; + gssize read; + + rb_scan_args(argc, argv, "11", &rbbytes, &cancellable); + bytes = RVAL2GSIZE(rbbytes); + result = rb_str_new(NULL, bytes); + read = g_socket_receive(_SELF(self), + RSTRING_PTR(result), + bytes, + RVAL2GCANCELLABLE(cancellable), + &error); + if (read == -1) + rbgio_raise_error(error); + + /* TODO: This is what Ruby does, but I can't figure out why one needs + * both. */ + rb_str_set_len(result, read); + rb_str_resize(result, read); + OBJ_TAINT(result); + + return result; +} + +static VALUE +rg_receive_from(int argc, VALUE *argv, VALUE self) +{ + VALUE rbbytes, cancellable, result; + GSocketAddress *address; + GError *error = NULL; + gsize bytes; + gssize read; + + rb_scan_args(argc, argv, "11", &rbbytes, &cancellable); + bytes = RVAL2GSIZE(rbbytes); + result = rb_str_new(NULL, bytes); + read = g_socket_receive_from(_SELF(self), + &address, + RSTRING_PTR(result), + bytes, + RVAL2GCANCELLABLE(cancellable), + &error); + if (read == -1) + rbgio_raise_error(error); + + rb_str_set_len(result, read); + rb_str_resize(result, read); + OBJ_TAINT(result); + + return rb_assoc_new(GOBJ2RVAL_UNREF(address), result); +} + +static VALUE +rg_send(int argc, VALUE *argv, VALUE self) +{ + VALUE buffer, cancellable; + GError *error = NULL; + gssize sent; + + rb_scan_args(argc, argv, "11", &buffer, &cancellable); + StringValue(buffer); + sent = g_socket_send(_SELF(self), + RSTRING_PTR(buffer), + RSTRING_LEN(buffer), + RVAL2GCANCELLABLE(cancellable), + &error); + if (sent == -1) + rbgio_raise_error(error); + + return GSSIZE2RVAL(sent); +} + +static VALUE +rg_send_to(int argc, VALUE *argv, VALUE self) +{ + VALUE address, buffer, cancellable; + GError *error = NULL; + gssize sent; + + rb_scan_args(argc, argv, "11", &address, &buffer, &cancellable); + StringValue(buffer); + sent = g_socket_send_to(_SELF(self), + RVAL2GSOCKETADDRESS(address), + RSTRING_PTR(buffer), + RSTRING_LEN(buffer), + RVAL2GCANCELLABLE(cancellable), + &error); + if (sent == -1) + rbgio_raise_error(error); + + return GSSIZE2RVAL(sent); +} + +static VALUE +rg_close(VALUE self) +{ + GError *error = NULL; + + if (!g_socket_close(_SELF(self), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_closed_p(VALUE self) +{ + return CBOOL2RVAL(g_socket_is_closed(_SELF(self))); +} + +static VALUE +rg_shutdown(VALUE self, VALUE shutdown_read, VALUE shutdown_write) +{ + GError *error = NULL; + + if (!g_socket_shutdown(_SELF(self), + RVAL2CBOOL(shutdown_read), + RVAL2CBOOL(shutdown_write), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_connected_p(VALUE self) +{ + return (g_socket_is_connected(_SELF(self))); +} + +static gboolean +source_func(GSocket *socket, GIOCondition condition, gpointer user_data) +{ + VALUE callback = (VALUE)user_data; + return RVAL2CBOOL(rb_funcall(callback, id_call, 2, + GOBJ2RVAL(socket), + GIOCONDITION2RVAL(condition))); +} + +static VALUE +rg_create_source(int argc, VALUE *argv, VALUE self) +{ + VALUE condition, cancellable, callback; + GSource *source; + + rb_scan_args(argc, argv, "11&", &condition, &cancellable, &callback); + + source = g_socket_create_source(_SELF(self), + RVAL2GIOCONDITION(condition), + RVAL2GCANCELLABLE(cancellable)); + G_RELATIVE(self, callback); + g_source_set_callback(source, + (GSourceFunc)source_func, + (gpointer)callback, + NULL); + return GSOURCE2RVAL(source); +} + +static VALUE +rg_condition_check(VALUE self, VALUE condition) +{ + return GIOCONDITION2RVAL(g_socket_condition_check(_SELF(self), + RVAL2GIOCONDITION(condition))); +} + +static VALUE +rg_condition_wait(int argc, VALUE *argv, VALUE self) +{ + VALUE condition, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "11", &condition, &cancellable); + if (!g_socket_condition_wait(_SELF(self), + RVAL2GIOCONDITION(condition), + RVAL2GCANCELLABLE(cancellable), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +socket_get_local_address(VALUE self) +{ + GError *error = NULL; + GSocketAddress *address; + + address = g_socket_get_local_address(_SELF(self), &error); + if (address == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(address); +} + +static VALUE +socket_get_remote_address(VALUE self) +{ + GError *error = NULL; + GSocketAddress *address; + + address = g_socket_get_remote_address(_SELF(self), &error); + if (address == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(address); +} + +static VALUE +rg_speaks_ipv4_p(VALUE self) +{ + return CBOOL2RVAL(g_socket_speaks_ipv4(_SELF(self))); +} + +void +Init_gsocket(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_SOCKET, "Socket", mGio); + + id_call = rb_intern("call"); + + G_DEF_CLASS(G_TYPE_SOCKET_FAMILY, "Family", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_SOCKET_FAMILY, "G_SOCKET_"); + + G_DEF_CLASS(G_TYPE_SOCKET_TYPE, "Type", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_SOCKET_TYPE, "G_SOCKET_"); + + G_DEF_CLASS(G_TYPE_SOCKET_PROTOCOL, "Protocol", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_SOCKET_PROTOCOL, "G_SOCKET_"); + + G_DEF_CLASS(G_TYPE_SOCKET_MSG_FLAGS, "MsgFlags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_SOCKET_MSG_FLAGS, "G_SOCKET_"); + + RG_DEF_SMETHOD(new_from_fd, 1); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(bind, 2); + RG_DEF_METHOD(listen, 0); + RG_DEF_METHOD(accept, -1); + RG_DEF_METHOD(connect, -1); + RG_DEF_METHOD(check_connect_result, 0); + RG_DEF_METHOD(receive, -1); + RG_DEF_METHOD(receive_from, -1); + RG_DEF_METHOD(send, -1); + RG_DEF_METHOD(send_to, -1); + RG_DEF_METHOD(close, 0); + RG_DEF_METHOD_P(closed, 0); + RG_DEF_METHOD(shutdown, 2); + RG_DEF_METHOD_P(connected, 0); + RG_DEF_METHOD(create_source, -1); + RG_DEF_METHOD(condition_check, 1); + RG_DEF_METHOD(condition_wait, -1); + G_REPLACE_GET_PROPERTY(RG_TARGET_NAMESPACE, "local_address", socket_get_local_address, 0); + G_REPLACE_GET_PROPERTY(RG_TARGET_NAMESPACE, "remote_address", socket_get_remote_address, 0); + RG_DEF_METHOD_P(speaks_ipv4, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketaddress.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketaddress.c new file mode 100644 index 0000000..a6b3b92 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketaddress.c @@ -0,0 +1,34 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +/* TODO: new_from_native? */ + +/* TODO: to_native? */ + +/* TODO: get_native_size? */ + +void +Init_gsocketaddress(VALUE mGio) +{ + (void)G_DEF_CLASS(G_TYPE_SOCKET_ADDRESS, "SocketAddress", mGio); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketaddressenumerator.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketaddressenumerator.c new file mode 100644 index 0000000..cf9d23e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketaddressenumerator.c @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cSocketAddressEnumerator +#define _SELF(value) RVAL2GSOCKETADDRESSENUMERATOR(value) + +static VALUE +rg_next(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + GSocketAddress *address; + + rb_scan_args(argc, argv, "01", &cancellable); + address = g_socket_address_enumerator_next(_SELF(self), + RVAL2GCANCELLABLE(cancellable), + &error); + if (error != NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL(address); +} + +static VALUE +rg_next_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbcancellable, block; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "01&", &rbcancellable, &block); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_socket_address_enumerator_next_async(_SELF(self), + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_next_finish(VALUE self, VALUE result) +{ + GError *error = NULL; + GSocketAddress *address; + + address = g_socket_address_enumerator_next_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &error); + if (address == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL(address); +} + +void +Init_gsocketaddressenumerator(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_SOCKET_ADDRESS_ENUMERATOR, "SocketAddressEnumerator", mGio); + + RG_DEF_METHOD(next, -1); + RG_DEF_METHOD(next_async, -1); + RG_DEF_METHOD(next_finish, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketclient.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketclient.c new file mode 100644 index 0000000..cc545f3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketclient.c @@ -0,0 +1,207 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cSocketClient +#define _SELF(value) RVAL2GSOCKETCLIENT(value) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, g_socket_client_new()); + + return Qnil; +} + +static VALUE +rg_connect(int argc, VALUE *argv, VALUE self) +{ + VALUE connectable, cancellable; + GError *error = NULL; + GSocketConnection *connection; + + rb_scan_args(argc, argv, "11", &connectable, &cancellable); + connection = g_socket_client_connect(_SELF(self), + RVAL2GSOCKETCONNECTABLE(connectable), + RVAL2GCANCELLABLE(cancellable), + &error); + if (connection == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(connection); +} + +static VALUE +rg_connect_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbconnectable, rbcancellable, block; + GCancellable *cancellable; + GSocketConnectable *connectable; + + rb_scan_args(argc, argv, "11&", &rbconnectable, &rbcancellable, &block); + connectable = RVAL2GSOCKETCONNECTABLE(rbconnectable); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_socket_client_connect_async(_SELF(self), + connectable, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +typedef GSocketConnection *(*ConnectionFinishMethod)(GSocketClient *, + GAsyncResult *, + GError **); + +static VALUE +connection_finish_method(ConnectionFinishMethod method, VALUE self, VALUE result) +{ + GError *error = NULL; + GSocketConnection *connection; + + connection = method(_SELF(self), RVAL2GASYNCRESULT(result), &error); + if (connection == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(connection); +} + +static VALUE +rg_connect_finish(VALUE self, VALUE result) +{ + return connection_finish_method(g_socket_client_connect_finish, self, result); +} + +static VALUE +rg_connect_to_host(int argc, VALUE *argv, VALUE self) +{ + VALUE host_and_port, default_port, cancellable; + GError *error = NULL; + GSocketConnection *connection; + + rb_scan_args(argc, argv, "21", &host_and_port, &default_port, &cancellable); + connection = g_socket_client_connect_to_host(_SELF(self), + RVAL2CSTR(host_and_port), + RVAL2GUINT16(default_port), + RVAL2GCANCELLABLE(cancellable), + &error); + if (connection == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(connection); +} + +static VALUE +rg_connect_to_host_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbhost_and_port, rbdefault_port, rbcancellable, block; + GCancellable *cancellable; + const gchar *host_and_port; + guint16 default_port; + + rb_scan_args(argc, argv, "21&", &rbhost_and_port, &rbdefault_port, &rbcancellable, &block); + host_and_port = RVAL2CSTR(rbhost_and_port); + default_port = RVAL2GUINT16(rbdefault_port); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_socket_client_connect_to_host_async(_SELF(self), + host_and_port, + default_port, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_connect_to_host_finish(VALUE self, VALUE result) +{ + return connection_finish_method(g_socket_client_connect_to_host_finish, self, result); +} + +static VALUE +rg_connect_to_service(int argc, VALUE *argv, VALUE self) +{ + VALUE domain, service, cancellable; + GError *error = NULL; + GSocketConnection *connection; + + rb_scan_args(argc, argv, "21", &domain, &service, &cancellable); + connection = g_socket_client_connect_to_service(_SELF(self), + RVAL2CSTR(domain), + RVAL2CSTR(service), + RVAL2GCANCELLABLE(cancellable), + &error); + if (connection == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(connection); +} + +static VALUE +rg_connect_to_service_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbdomain, rbservice, rbcancellable, block; + GCancellable *cancellable; + const gchar *domain; + const gchar *service; + + rb_scan_args(argc, argv, "21&", &domain, &service, &rbcancellable, &block); + domain = RVAL2CSTR(rbdomain); + service = RVAL2CSTR(rbservice); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_socket_client_connect_to_service_async(_SELF(self), + domain, + service, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_connect_to_service_finish(VALUE self, VALUE result) +{ + return connection_finish_method(g_socket_client_connect_to_service_finish, self, result); +} + +void +Init_gsocketclient(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_SOCKET_CLIENT, "SocketClient", mGio); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(connect, -1); + RG_DEF_METHOD(connect_async, -1); + RG_DEF_METHOD(connect_finish, 1); + RG_DEF_METHOD(connect_to_host, -1); + RG_DEF_METHOD(connect_to_host_async, -1); + RG_DEF_METHOD(connect_to_host_finish, 1); + RG_DEF_METHOD(connect_to_service, -1); + RG_DEF_METHOD(connect_to_service_async, -1); + RG_DEF_METHOD(connect_to_service_finish, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketconnectable.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketconnectable.c new file mode 100644 index 0000000..afb9ad4 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketconnectable.c @@ -0,0 +1,41 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mSocketConnectable +#define _SELF(value) RVAL2GSOCKETCONNECTABLE(value) + +static VALUE +rg_enumerate(VALUE self) +{ + return GOBJ2RVAL(g_socket_connectable_enumerate(_SELF(self))); +} + +void +Init_gsocketconnectable(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_SOCKET_CONNECTABLE, "SocketConnectable", mGio); + + RG_DEF_METHOD(enumerate, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketconnection.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketconnection.c new file mode 100644 index 0000000..a11e578 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketconnection.c @@ -0,0 +1,66 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cSocketConnection +#define _SELF(value) RVAL2GSOCKETCONNECTION(value) + +static VALUE +rg_local_address(VALUE self) +{ + GError *error = NULL; + GSocketAddress *address; + + address = g_socket_connection_get_local_address(_SELF(self), &error); + if (address == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(address); +} + +static VALUE +rg_remote_address(VALUE self) +{ + GError *error = NULL; + GSocketAddress *address; + + address = g_socket_connection_get_remote_address(_SELF(self), &error); + if (address == NULL) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(address); +} + +/* TODO: lookup_type */ + +/* TODO: register_type */ + +void +Init_gsocketconnection(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_SOCKET_CONNECTION, "SocketConnection", mGio); + + RG_DEF_METHOD(local_address, 0); + RG_DEF_METHOD(remote_address, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketconnectionfactory.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketconnectionfactory.c new file mode 100644 index 0000000..8a7be50 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketconnectionfactory.c @@ -0,0 +1,39 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mSocketConnectionFactory + +static VALUE +rg_s_create_connection(G_GNUC_UNUSED VALUE self, VALUE socket) +{ + return GOBJ2RVAL_UNREF(g_socket_connection_factory_create_connection(RVAL2GSOCKET(socket))); +} + +void +Init_gsocketconnectionfactory(VALUE mGio) +{ + /* TODO: Perhaps just move this to SocketConnection? */ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGio, "SocketConnectionFactory"); + + RG_DEF_SMETHOD(create_connection, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketcontrolmessage.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketcontrolmessage.c new file mode 100644 index 0000000..628a3ae --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketcontrolmessage.c @@ -0,0 +1,82 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cSocketControlMessage +#define _SELF(value) RVAL2GSOCKETCONTROLMESSAGE(value) + +static VALUE +rg_s_deserialize(G_GNUC_UNUSED VALUE self, VALUE level, VALUE type, VALUE data) +{ + StringValue(data); + return GOBJ2RVAL(g_socket_control_message_deserialize(FIX2INT(level), + FIX2INT(type), + RSTRING_LEN(data), + RSTRING_PTR(data))); +} + +static VALUE +rg_level(VALUE self) +{ + return INT2FIX(g_socket_control_message_get_level(_SELF(self))); +} + +static VALUE +rg_msg_type(VALUE self) +{ + return INT2FIX(g_socket_control_message_get_msg_type(_SELF(self))); +} + +static VALUE +rg_size(VALUE self) +{ + return GSIZE2RVAL(g_socket_control_message_get_size(_SELF(self))); +} + +static VALUE +rg_serialize(VALUE self) +{ + gsize size; + VALUE result; + + /* TODO: Is tainting really necessary? Where does the message come + * from? */ + size = g_socket_control_message_get_size(_SELF(self)); + result = rb_str_new(NULL, size); + g_socket_control_message_serialize(_SELF(self), RSTRING_PTR(result)); + OBJ_TAINT(result); + + return result; +} + +void +Init_gsocketcontrolmessage(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_SOCKET_CONTROL_MESSAGE, "SocketControlMessage", mGio); + + RG_DEF_SMETHOD(deserialize, 3); + + RG_DEF_METHOD(level, 0); + RG_DEF_METHOD(msg_type, 0); + RG_DEF_METHOD(size, 0); + RG_DEF_METHOD(serialize, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketlistener.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketlistener.c new file mode 100644 index 0000000..eb4474b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketlistener.c @@ -0,0 +1,246 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cSocketListener +#define _SELF(value) RVAL2GSOCKETLISTENER(value) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, g_socket_listener_new()); + + return Qnil; +} + +static VALUE +rg_add_socket(int argc, VALUE *argv, VALUE self) +{ + VALUE socket, source_object; + GError *error = NULL; + + rb_scan_args(argc, argv, "11", &socket, &source_object); + if (!g_socket_listener_add_socket(_SELF(self), RVAL2GSOCKET(socket), + RVAL2GOBJ(source_object), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_add_address(int argc, VALUE *argv, VALUE self) +{ + VALUE rbaddress, type, protocol, source_object; + GError *error = NULL; + GSocketAddress *address; + + rb_scan_args(argc, argv, "22", &rbaddress, &type, &protocol, &source_object); + if (!g_socket_listener_add_address(_SELF(self), + RVAL2GSOCKETADDRESS(rbaddress), + RVAL2GSOCKETTYPE(type), + RVAL2GSOCKETPROTOCOLDEFAULT(protocol), + RVAL2GOBJ(source_object), + &address, + &error)) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(address); +} + +static VALUE +rg_add_inet_port(int argc, VALUE *argv, VALUE self) +{ + VALUE port, source_object; + GError *error = NULL; + + rb_scan_args(argc, argv, "11", &port, &source_object); + if (!g_socket_listener_add_inet_port(_SELF(self), + RVAL2GUINT16(port), + RVAL2GOBJ(source_object), + &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_add_any_inet_port(int argc, VALUE *argv, VALUE self) +{ + VALUE source_object; + GError *error = NULL; + guint16 port; + + rb_scan_args(argc, argv, "01", &source_object); + port = g_socket_listener_add_any_inet_port(_SELF(self), + RVAL2GOBJ(source_object), + &error); + if (port == 0) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_accept(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GObject *source_object; + GError *error = NULL; + GSocketConnection *connection; + + rb_scan_args(argc, argv, "01", &cancellable); + connection = g_socket_listener_accept(_SELF(self), + &source_object, + RVAL2GCANCELLABLE(cancellable), + &error); + if (connection == NULL) + rbgio_raise_error(error); + + return rb_assoc_new(GOBJ2RVAL_UNREF(connection), + GOBJ2RVAL(source_object)); +} + +static VALUE +rg_accept_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbcancellable, block; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "01&", &rbcancellable, &block); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_socket_listener_accept_async(_SELF(self), + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_accept_finish(VALUE self, VALUE result) +{ + GObject *source_object; + GError *error = NULL; + GSocketConnection *connection; + + connection = g_socket_listener_accept_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &source_object, + &error); + if (connection == NULL) + rbgio_raise_error(error); + + return rb_assoc_new(GOBJ2RVAL_UNREF(connection), + GOBJ2RVAL(source_object)); +} + +static VALUE +rg_accept_socket(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GObject *source_object; + GError *error = NULL; + GSocket *socket; + + rb_scan_args(argc, argv, "01", &cancellable); + socket = g_socket_listener_accept_socket(_SELF(self), + &source_object, + RVAL2GCANCELLABLE(cancellable), + &error); + if (socket == NULL) + rbgio_raise_error(error); + + return rb_assoc_new(GOBJ2RVAL_UNREF(socket), + GOBJ2RVAL(source_object)); +} + +static VALUE +rg_accept_socket_async(int argc, VALUE *argv, VALUE self) +{ + VALUE rbcancellable, block; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "01&", &rbcancellable, &block); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_socket_listener_accept_socket_async(_SELF(self), + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_accept_socket_finish(VALUE self, VALUE result) +{ + GObject *source_object; + GError *error = NULL; + GSocket *socket; + + socket = g_socket_listener_accept_socket_finish(_SELF(self), + RVAL2GASYNCRESULT(result), + &source_object, + &error); + if (socket == NULL) + rbgio_raise_error(error); + + return rb_assoc_new(GOBJ2RVAL_UNREF(socket), + GOBJ2RVAL(source_object)); +} + +static VALUE +rg_close(VALUE self) +{ + g_socket_listener_close(_SELF(self)); + + return self; +} + +static VALUE +rg_set_backlog(VALUE self, VALUE listen_backlog) +{ + g_socket_listener_set_backlog(_SELF(self), FIX2INT(listen_backlog)); + + return self; +} + +void +Init_gsocketlistener(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_SOCKET_LISTENER, "SocketListener", mGio); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(add_socket, -1); + RG_DEF_METHOD(add_address, -1); + RG_DEF_METHOD(add_inet_port, -1); + RG_DEF_METHOD(add_any_inet_port, -1); + RG_DEF_METHOD(accept, -1); + RG_DEF_METHOD(accept_async, -1); + RG_DEF_METHOD(accept_finish, 1); + RG_DEF_METHOD(accept_socket, -1); + RG_DEF_METHOD(accept_socket_async, -1); + RG_DEF_METHOD(accept_socket_finish, 1); + RG_DEF_METHOD(close, 0); + RG_DEF_METHOD(set_backlog, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketservice.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketservice.c new file mode 100644 index 0000000..e460c25 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosocketservice.c @@ -0,0 +1,66 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cSocketService +#define _SELF(value) RVAL2GSOCKETSERVICE(value) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, g_socket_service_new()); + + return Qnil; +} + +static VALUE +rg_start(VALUE self) +{ + g_socket_service_start(_SELF(self)); + + return self; +} + +static VALUE +rg_stop(VALUE self) +{ + g_socket_service_stop(_SELF(self)); + + return self; +} + +static VALUE +rg_active_p(VALUE self) +{ + return CBOOL2RVAL(g_socket_service_is_active(_SELF(self))); +} + +void +Init_gsocketservice(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_SOCKET_SERVICE, "SocketService", mGio); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(start, 0); + RG_DEF_METHOD(stop, 0); + RG_DEF_METHOD_P(active, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosrvtarget.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosrvtarget.c new file mode 100644 index 0000000..628d998 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiosrvtarget.c @@ -0,0 +1,76 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cSrvTarget +#define _SELF(value) RVAL2GSRVTARGET(value) + +static VALUE +rg_initialize(VALUE self, VALUE hostname, VALUE port, VALUE priority, VALUE weight) +{ + /* TODO: Does this work with boxed? */ + /* TODO: hostname should be infected when returned. */ + G_INITIALIZE(self, g_srv_target_new(RVAL2CSTR(hostname), + RVAL2GUINT16(port), + RVAL2GUINT16(priority), + RVAL2GUINT16(weight))); + + return Qnil; +} + +static VALUE +rg_hostname(VALUE self) +{ + return CSTR2RVAL(g_srv_target_get_hostname(_SELF(self))); +} + +static VALUE +rg_port(VALUE self) +{ + return GUINT162RVAL(g_srv_target_get_port(_SELF(self))); +} + +static VALUE +rg_priority(VALUE self) +{ + return GUINT162RVAL(g_srv_target_get_priority(_SELF(self))); +} + +static VALUE +rg_weight(VALUE self) +{ + return GUINT162RVAL(g_srv_target_get_weight(_SELF(self))); +} + +/* TODO: srvtarget_list_sort */ + +void +Init_gsrvtarget(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_SRV_TARGET, "SrvTarget", mGio); + + RG_DEF_METHOD(initialize, 4); + RG_DEF_METHOD(hostname, 0); + RG_DEF_METHOD(port, 0); + RG_DEF_METHOD(priority, 0); + RG_DEF_METHOD(weight, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiotcpconnection.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiotcpconnection.c new file mode 100644 index 0000000..482b551 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiotcpconnection.c @@ -0,0 +1,28 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +void +Init_gtcpconnection(VALUE mGio) +{ + (void)G_DEF_CLASS(G_TYPE_TCP_CONNECTION, "TcpConnection", mGio); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiothemedicon.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiothemedicon.c new file mode 100644 index 0000000..69d2692 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiothemedicon.c @@ -0,0 +1,83 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mThemedIcon +#define _SELF(value) RVAL2GTHEMEDICON(value) + +/* TODO: Is this unnecessarily complicated? */ +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE iconnames, with_default_fallbacks; + GIcon *icon; + + rb_scan_args(argc, argv, "11", &iconnames, &with_default_fallbacks); + + if (TYPE(iconnames) != T_ARRAY) { + const char *iconname = RVAL2CSTR(iconnames); + + icon = RVAL2CBOOL(with_default_fallbacks) ? + g_themed_icon_new_with_default_fallbacks(iconname) : + g_themed_icon_new(iconname); + + G_INITIALIZE(self, icon); + + return Qnil; + } + + if (argc > 1) + rb_raise(rb_eArgError, + "only one argument allowed when first argument is an Array"); + + icon = g_themed_icon_new_from_names(RVAL2STRV_DUP(iconnames), -1); + + G_INITIALIZE(self, icon); + + return Qnil; +} + +static VALUE +rg_prepend_name(VALUE self, VALUE iconname) +{ + g_themed_icon_prepend_name(_SELF(self), RVAL2CSTR(iconname)); + + return self; +} + +static VALUE +rg_append_name(VALUE self, VALUE iconname) +{ + g_themed_icon_append_name(_SELF(self), RVAL2CSTR(iconname)); + + return self; +} + +void +Init_gthemedicon(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_THEMED_ICON, "ThemedIcon", mGio); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(prepend_name, 1); + RG_DEF_METHOD(append_name, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiothreadedsocketservice.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiothreadedsocketservice.c new file mode 100644 index 0000000..903bc5c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiothreadedsocketservice.c @@ -0,0 +1,43 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cThreadedSocketService + +static VALUE +rg_initialize(VALUE self, VALUE max_threads) +{ + G_INITIALIZE(self, + g_threaded_socket_service_new(RVAL2TYPE_WITH_DEFAULT(max_threads, + RVAL2GINT, + 10))); + + return Qnil; +} + +void +Init_gthreadedsocketservice(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_THREADED_SOCKET_SERVICE, "ThreadedSocketService", mGio); + + RG_DEF_METHOD(initialize, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiotlscertificate.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiotlscertificate.c new file mode 100644 index 0000000..4f1b37d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiotlscertificate.c @@ -0,0 +1,89 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cTlsCertificate +#define _SELF(value) RVAL2GOBJ(value) + +static VALUE +rg_initialize(VALUE self, VALUE data) +{ + GTlsCertificate *certificate; + GError *error = NULL; + + certificate = g_tls_certificate_new_from_pem(StringValuePtr(data), + RSTRING_LEN(data), + &error); + if (error) + rbgio_raise_error(error); + + G_INITIALIZE(self, certificate); + + return Qnil; +} + +static VALUE +rg_s_load(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE cert_file, key_file; + GError *error = NULL; + GTlsCertificate *certificate; + + rb_scan_args(argc, argv, "11", &cert_file, &key_file); + if (NIL_P(key_file)) { + certificate = g_tls_certificate_new_from_file(StringValuePtr(cert_file), + &error); + } else { + certificate = g_tls_certificate_new_from_files(StringValuePtr(cert_file), + StringValuePtr(key_file), + &error); + } + + if (error) + rbgio_raise_error(error); + + return GOBJ2RVAL_UNREF(certificate); +} + +static VALUE +rg_verify(VALUE self, VALUE identity, VALUE trusted_ca) +{ + GTlsCertificateFlags flags; + + flags = g_tls_certificate_verify(_SELF(self), + RVAL2GOBJ(identity), + RVAL2GOBJ(trusted_ca)); + return GFLAGS2RVAL(flags, G_TYPE_TLS_CERTIFICATE_FLAGS); +} + +void +Init_gtlscertificate(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_TLS_CERTIFICATE, + "TlsCertificate", mGio); + + G_DEF_CLASS(G_TYPE_TLS_CERTIFICATE_FLAGS, "TlsCertificateFlags", mGio); + + RG_DEF_SMETHOD(load, -1); + + RG_DEF_METHOD(initialize, 1); + RG_DEF_METHOD(verify, 2); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixconnection.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixconnection.c new file mode 100644 index 0000000..2e3683d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixconnection.c @@ -0,0 +1,71 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#ifdef HAVE_GIO_UNIX +#include + +#define RG_TARGET_NAMESPACE cUnixConnection +#define _SELF(value) RVAL2GUNIXCONNECTION(value) + +static VALUE +rg_receive_fd(int argc, VALUE *argv, VALUE self) +{ + VALUE cancellable; + GError *error = NULL; + gint fd; + + rb_scan_args(argc, argv, "01", &cancellable); + fd = g_unix_connection_receive_fd(_SELF(self), + RVAL2GCANCELLABLE(cancellable), + &error); + if (fd == -1) + rbgio_raise_error(error); + + return FD2RVAL(fd); +} + +static VALUE +rg_send_fd(int argc, VALUE *argv, VALUE self) +{ + VALUE fd, cancellable; + GError *error = NULL; + + rb_scan_args(argc, argv, "11", &fd, &cancellable); + if (!g_unix_connection_send_fd(_SELF(self), RVAL2FD(fd), + RVAL2GCANCELLABLE(cancellable), &error)) + rbgio_raise_error(error); + + return self; +} +#endif + +void +Init_gunixconnection(G_GNUC_UNUSED VALUE mGio) +{ +#ifdef HAVE_GIO_UNIX + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_UNIX_CONNECTION, "UnixConnection", mGio); + + RG_DEF_METHOD(receive_fd, -1); + RG_DEF_METHOD(send_fd, -1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixfdlist.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixfdlist.c new file mode 100644 index 0000000..1afd046 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixfdlist.c @@ -0,0 +1,115 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#ifdef HAVE_GIO_UNIX +#include + +#define RG_TARGET_NAMESPACE cUnixFDList +#define _SELF(value) RVAL2GUNIXFDLIST(value) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE rbfds; + long n; + gint *fds; + GUnixFDList *list; + + rb_scan_args(argc, argv, "0*", &rbfds); + fds = RVAL2FDS(rbfds, n); + if (n == 0) { + G_INITIALIZE(self, g_unix_fd_list_new()); + return Qnil; + } + + list = g_unix_fd_list_new_from_array(fds, n); + + g_free(fds); + + G_INITIALIZE(self, list); + + return Qnil; +} + +static VALUE +rg_length(VALUE self) +{ + return GINT2RVAL(g_unix_fd_list_get_length(_SELF(self))); +} + +static VALUE +rg_get(VALUE self, VALUE index) +{ + GError *error = NULL; + gint fd; + + fd = g_unix_fd_list_get(_SELF(self), RVAL2GINT(index), &error); + if (fd == -1) + rbgio_raise_error(error); + + /* TODO: This fd must be closed properly. How do we deal with that? */ + return FD2RVAL(fd); +} + +static VALUE +rg_peek_fds(VALUE self) +{ + return GFDS2ARY(g_unix_fd_list_peek_fds(_SELF(self), NULL)); +} + +static VALUE +rg_steal_fds(VALUE self) +{ + return GFDS2ARY_FREE(g_unix_fd_list_steal_fds(_SELF(self), NULL)); +} + +static VALUE +rg_append(VALUE self, VALUE fd) +{ + GError *error = NULL; + int index; + + index = g_unix_fd_list_append(_SELF(self), RVAL2FD(fd), &error); + if (index == -1) + rbgio_raise_error(error); + + return self; +} +#endif + +void +Init_gunixfdlist(G_GNUC_UNUSED VALUE mGio) +{ +#ifdef HAVE_GIO_UNIX + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_UNIX_FD_LIST, "UnixFDList", mGio); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(length, 0); + RG_DEF_METHOD(get, 1); + RG_DEF_ALIAS("[]", "get"); + RG_DEF_METHOD(peek_fds, 0); + RG_DEF_METHOD(steal_fds, 0); + RG_DEF_METHOD(append, 1); + RG_DEF_ALIAS("<<", "append"); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixfdmessage.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixfdmessage.c new file mode 100644 index 0000000..33adda2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixfdmessage.c @@ -0,0 +1,74 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#ifdef HAVE_GIO_UNIX +#include + +#define RG_TARGET_NAMESPACE cUnixFDMessage +#define _SELF(value) RVAL2GUNIXFDMESSAGE(value) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE fd_list; + GSocketControlMessage *message; + + rb_scan_args(argc, argv, "01", &fd_list); + message = NIL_P(fd_list) ? + g_unix_fd_message_new() : + g_unix_fd_message_new_with_fd_list(RVAL2GUNIXFDLIST(fd_list)); + G_INITIALIZE(self, message); + + return Qnil; +} + +static VALUE +rg_append_fd(VALUE self, VALUE fd) +{ + GError *error = NULL; + + if (!g_unix_fd_message_append_fd(_SELF(self), RVAL2FD(fd), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_steal_fds(VALUE self) +{ + return GFDS2ARY_FREE(g_unix_fd_message_steal_fds(_SELF(self), NULL)); +} +#endif + +void +Init_gunixfdmessage(G_GNUC_UNUSED VALUE mGio) +{ +#ifdef HAVE_GIO_UNIX + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_UNIX_FD_MESSAGE, "UnixFDMessage", mGio); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(append_fd, 1); + RG_DEF_ALIAS("<<", "append_fd"); + RG_DEF_METHOD(steal_fds, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixinputstream.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixinputstream.c new file mode 100644 index 0000000..3280732 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixinputstream.c @@ -0,0 +1,51 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#ifdef HAVE_GIO_UNIX +#include + +#define RG_TARGET_NAMESPACE cUnixInputStream +#define _SELF(value) RVAL2GUNIXINPUTSTREAM(value) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE fd, close_fd; + + rb_scan_args(argc, argv, "11", &fd, &close_fd); + G_INITIALIZE(self, g_unix_input_stream_new(RVAL2FD(fd), + RVAL2CBOOL(close_fd))); + + return Qnil; +} +#endif + +void +Init_gunixinputstream(G_GNUC_UNUSED VALUE mGio) +{ +#ifdef HAVE_GIO_UNIX + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_UNIX_INPUT_STREAM, "UnixInputStream", mGio); + + RG_DEF_METHOD(initialize, -1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixmount.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixmount.c new file mode 100644 index 0000000..54189f2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixmount.c @@ -0,0 +1,164 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#ifdef HAVE_GIO_UNIX +#include + +#define RG_TARGET_NAMESPACE cUnixMount + +static GUnixMountEntry * +unixmount_copy(const GUnixMountEntry *mount) +{ + return (GUnixMountEntry *)mount; +} + +static GType +g_unix_mount_entry_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static("GUnixMountEntry", + (GBoxedCopyFunc)unixmount_copy, + (GBoxedFreeFunc)g_unix_mount_free); + + return our_type; +} + +#define G_TYPE_UNIX_MOUNT_ENTRY (g_unix_mount_entry_get_type()) + +#define _SELF(value) \ + ((GUnixMountEntry *)(RVAL2BOXED((value), G_TYPE_UNIX_MOUNT_ENTRY))) + +#define GUNIXMOUNTENTRY2RVAL(value) BOXED2RVAL((value), G_TYPE_UNIX_MOUNT_ENTRY) + +static VALUE +rg_compare(VALUE self, VALUE other) +{ + return INT2FIX(g_unix_mount_compare(_SELF(self), _SELF(other))); +} + +static VALUE +rg_mount_path(VALUE self) +{ + return CSTR2RVAL(g_unix_mount_get_mount_path(_SELF(self))); +} + +static VALUE +rg_device_path(VALUE self) +{ + return CSTR2RVAL(g_unix_mount_get_device_path(_SELF(self))); +} + +static VALUE +rg_fs_type(VALUE self) +{ + return CSTR2RVAL(g_unix_mount_get_fs_type(_SELF(self))); +} + +static VALUE +rg_readonly_p(VALUE self) +{ + return CBOOL2RVAL(g_unix_mount_is_readonly(_SELF(self))); +} + +static VALUE +rg_system_internal_p(VALUE self) +{ + return CBOOL2RVAL(g_unix_mount_is_system_internal(_SELF(self))); +} + +static VALUE +rg_guess_icon(VALUE self) +{ + return GOBJ2RVAL_UNREF(g_unix_mount_guess_icon(_SELF(self))); +} + +static VALUE +rg_guess_name(VALUE self) +{ + return CSTR2RVAL_FREE(g_unix_mount_guess_name(_SELF(self))); +} + +static VALUE +rg_guess_can_eject_p(VALUE self) +{ + return CBOOL2RVAL(g_unix_mount_guess_can_eject(_SELF(self))); +} + +static VALUE +rg_guess_should_display_p(VALUE self) +{ + return CBOOL2RVAL(g_unix_mount_guess_should_display(_SELF(self))); +} + +static VALUE +rg_s_at(G_GNUC_UNUSED VALUE self, VALUE mount_path) +{ + guint64 time_read; + GUnixMountEntry *mount; + + mount = g_unix_mount_at(RVAL2CSTR(mount_path), &time_read); + + return rb_assoc_new(GUNIXMOUNTENTRY2RVAL(mount), + GUINT642RVAL(time_read)); +} + +static VALUE +rg_s_mount_path_system_internal_p(G_GNUC_UNUSED VALUE self, VALUE mount_path) +{ + return CBOOL2RVAL(g_unix_is_mount_path_system_internal(RVAL2CSTR(mount_path))); +} + +#endif + +void +Init_gunixmount(G_GNUC_UNUSED VALUE mGio) +{ +#ifdef HAVE_GIO_UNIX + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_UNIX_MOUNT_ENTRY, "UnixMount", mGio); + + rb_include_module(RG_TARGET_NAMESPACE, rb_mComparable); + + /* TODO: This doesn't follow the naming conventions, but it seems + * overkill to have GLib::Unix just for mount_path_system_internal?. */ + RG_DEF_SMETHOD_P(mount_path_system_internal, 1); + RG_DEF_SMETHOD(at, 1); + + rbgobj_boxed_not_copy_obj(G_TYPE_UNIX_MOUNT_ENTRY); + + RG_DEF_METHOD(compare, 1); + RG_DEF_ALIAS("<=>", "compare"); + RG_DEF_METHOD(mount_path, 0); + RG_DEF_METHOD(device_path, 0); + RG_DEF_METHOD(fs_type, 0); + RG_DEF_METHOD_P(readonly, 0); + RG_DEF_METHOD_P(system_internal, 0); + RG_DEF_METHOD(guess_icon, 0); + RG_DEF_METHOD(guess_name, 0); + RG_DEF_METHOD_P(guess_can_eject, 0); + RG_DEF_METHOD_P(guess_should_display, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixmountmonitor.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixmountmonitor.c new file mode 100644 index 0000000..f41be20 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixmountmonitor.c @@ -0,0 +1,65 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#ifdef HAVE_GIO_UNIX +#include + +#define RG_TARGET_NAMESPACE cUnixMountMonitor +#define _SELF(value) RVAL2GUNIXMOUNTMONITOR(value) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE limit_msec; + GUnixMountMonitor *monitor; + + rb_scan_args(argc, argv, "01", &limit_msec); + monitor = g_unix_mount_monitor_new(); + if (!NIL_P(limit_msec)) + g_unix_mount_monitor_set_rate_limit(monitor, + FIX2INT(limit_msec)); + G_INITIALIZE(self, monitor); + + return Qnil; +} + +static VALUE +rg_set_rate_limit(VALUE self, VALUE limit_msec) +{ + g_unix_mount_monitor_set_rate_limit(_SELF(self), FIX2INT(limit_msec)); + + return self; +} + +#endif + +void +Init_gunixmountmonitor(G_GNUC_UNUSED VALUE mGio) +{ +#ifdef HAVE_GIO_UNIX + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_UNIX_MOUNT_MONITOR, "UnixMountMonitor", mGio); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(set_rate_limit, 1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixmountpoint.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixmountpoint.c new file mode 100644 index 0000000..fa65b89 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixmountpoint.c @@ -0,0 +1,136 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#ifdef HAVE_GIO_UNIX +#include + +#define G_TYPE_UNIX_MOUNT_POINT (g_unix_mount_point_get_type()) + +#define RG_TARGET_NAMESPACE cUnixMountPoint +#define _SELF(value) \ + ((GUnixMountPoint *)(RVAL2BOXED((value), G_TYPE_UNIX_MOUNT_POINT))) + +static GUnixMountPoint * +unixmountpoint_copy(const GUnixMountPoint *mount_point) +{ + return (GUnixMountPoint *)mount_point; +} + +static GType +g_unix_mount_point_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static("GUnixMountPoint", + (GBoxedCopyFunc)unixmountpoint_copy, + (GBoxedFreeFunc)g_unix_mount_point_free); + + return our_type; +} + +static VALUE +rg_compare(VALUE self, VALUE other) +{ + return INT2FIX(g_unix_mount_point_compare(_SELF(self), _SELF(other))); +} + +static VALUE +rg_mount_path(VALUE self) +{ + return CSTR2RVAL(g_unix_mount_point_get_mount_path(_SELF(self))); +} + +static VALUE +rg_device_path(VALUE self) +{ + return CSTR2RVAL(g_unix_mount_point_get_device_path(_SELF(self))); +} + +static VALUE +rg_fs_type(VALUE self) +{ + return CSTR2RVAL(g_unix_mount_point_get_fs_type(_SELF(self))); +} + +static VALUE +rg_readonly_p(VALUE self) +{ + return CBOOL2RVAL(g_unix_mount_point_is_readonly(_SELF(self))); +} + +static VALUE +rg_user_mountable_p(VALUE self) +{ + return CBOOL2RVAL(g_unix_mount_point_is_user_mountable(_SELF(self))); +} + +static VALUE +rg_loopback_p(VALUE self) +{ + return CBOOL2RVAL(g_unix_mount_point_is_loopback(_SELF(self))); +} + +static VALUE +rg_guess_icon(VALUE self) +{ + return GOBJ2RVAL_UNREF(g_unix_mount_point_guess_icon(_SELF(self))); +} + +static VALUE +rg_guess_name(VALUE self) +{ + return CSTR2RVAL_FREE(g_unix_mount_point_guess_name(_SELF(self))); +} + +static VALUE +rg_guess_can_eject_p(VALUE self) +{ + return CBOOL2RVAL(g_unix_mount_point_guess_can_eject(_SELF(self))); +} + +#endif + +void +Init_gunixmountpoint(G_GNUC_UNUSED VALUE mGio) +{ +#ifdef HAVE_GIO_UNIX + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_UNIX_MOUNT_POINT, "UnixMountPoint", mGio); + + rb_include_module(RG_TARGET_NAMESPACE, rb_mComparable); + + rbgobj_boxed_not_copy_obj(G_TYPE_UNIX_MOUNT_POINT); + + RG_DEF_METHOD(compare, 1); + RG_DEF_ALIAS("<=>", "compare"); + RG_DEF_METHOD(mount_path, 0); + RG_DEF_METHOD(device_path, 0); + RG_DEF_METHOD(fs_type, 0); + RG_DEF_METHOD_P(readonly, 0); + RG_DEF_METHOD_P(user_mountable, 0); + RG_DEF_METHOD_P(loopback, 0); + RG_DEF_METHOD(guess_icon, 0); + RG_DEF_METHOD(guess_name, 0); + RG_DEF_METHOD_P(guess_can_eject, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixmountpoints.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixmountpoints.c new file mode 100644 index 0000000..368d1a0 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixmountpoints.c @@ -0,0 +1,58 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#ifdef HAVE_GIO_UNIX +#include + +#define RG_TARGET_NAMESPACE mUnixMountPoints + +static VALUE +rg_s_get(G_GNUC_UNUSED VALUE self) +{ + guint64 time_read; + GList *mount_points; + + mount_points = g_unix_mount_points_get(&time_read); + + return rb_assoc_new(GLIST2ARY_STR_FREE(mount_points), + GUINT642RVAL(time_read)); +} + +static VALUE +rg_s_changed_since_p(G_GNUC_UNUSED VALUE self, VALUE time_read) +{ + return CBOOL2RVAL(g_unix_mount_points_changed_since(RVAL2GUINT64(time_read))); +} + +#endif + +void +Init_gunixmountpoints(G_GNUC_UNUSED VALUE mGio) +{ +#ifdef HAVE_GIO_UNIX + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGio, "UnixMountPoints"); + + RG_DEF_SMETHOD(get, 0); + RG_DEF_SMETHOD_P(changed_since, 1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixmounts.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixmounts.c new file mode 100644 index 0000000..7205324 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixmounts.c @@ -0,0 +1,58 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#ifdef HAVE_GIO_UNIX +#include + +#define RG_TARGET_NAMESPACE mUnixMounts + +static VALUE +rg_s_get(G_GNUC_UNUSED VALUE self) +{ + guint64 time_read; + GList *mounts; + + mounts = g_unix_mounts_get(&time_read); + + return rb_assoc_new(GLIST2ARY_STR_FREE(mounts), + GUINT642RVAL(time_read)); +} + +static VALUE +rg_s_changed_since_p(G_GNUC_UNUSED VALUE self, VALUE time_read) +{ + return CBOOL2RVAL(g_unix_mounts_changed_since(RVAL2GUINT64(time_read))); +} + +#endif + +void +Init_gunixmounts(G_GNUC_UNUSED VALUE mGio) +{ +#ifdef HAVE_GIO_UNIX + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGio, "UnixMounts"); + + RG_DEF_SMETHOD(get, 0); + RG_DEF_SMETHOD_P(changed_since, 1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixoutputstream.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixoutputstream.c new file mode 100644 index 0000000..70d27cb --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixoutputstream.c @@ -0,0 +1,51 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#ifdef HAVE_GIO_UNIX +#include + +#define RG_TARGET_NAMESPACE cUnixOutputStream +#define _SELF(value) RVAL2GUNIXOUTPUTSTREAM(value) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE fd, close_fd; + + rb_scan_args(argc, argv, "11", &fd, &close_fd); + G_INITIALIZE(self, g_unix_output_stream_new(RVAL2FD(fd), + RVAL2CBOOL(close_fd))); + + return Qnil; +} +#endif + +void +Init_gunixoutputstream(G_GNUC_UNUSED VALUE mGio) +{ +#ifdef HAVE_GIO_UNIX + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_UNIX_OUTPUT_STREAM, "UnixOutputStream", mGio); + + RG_DEF_METHOD(initialize, -1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixsocketaddress.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixsocketaddress.c new file mode 100644 index 0000000..819c71b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiounixsocketaddress.c @@ -0,0 +1,69 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#ifdef HAVE_GIO_UNIX +#include + +#define RG_TARGET_NAMESPACE cUnixSocketAddress +#define _SELF(value) RVAL2GUNIXSOCKETADDRESS(value) + +static VALUE +rg_initialize(VALUE self, VALUE path) +{ + G_INITIALIZE(self, g_unix_socket_address_new(RVAL2CSTR(path))); + + return Qnil; +} + +static VALUE +rg_s_new_abstract(G_GNUC_UNUSED VALUE self, VALUE path) +{ + StringValue(path); + return GOBJ2RVAL_UNREF(g_unix_socket_address_new_abstract(RSTRING_PTR(path), + RSTRING_LEN(path))); +} + +static VALUE +rg_s_abstract_names_supported_p(G_GNUC_UNUSED VALUE self) +{ + return CBOOL2RVAL(g_unix_socket_address_abstract_names_supported()); +} +#endif + +void +Init_gunixsocketaddress(G_GNUC_UNUSED VALUE mGio) +{ +#ifdef HAVE_GIO_UNIX + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_UNIX_SOCKET_ADDRESS, "UnixSocketAddress", mGio); + +# if GLIB_CHECK_VERSION(2, 26, 0) + G_DEF_CLASS(G_TYPE_UNIX_SOCKET_ADDRESS_TYPE, "Type", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_UNIX_SOCKET_ADDRESS_TYPE, "G_UNIX_SOCKET_ADDRESS_"); +# endif + + RG_DEF_SMETHOD(new_abstract, 1); + RG_DEF_SMETHOD_P(abstract_names_supported, 0); + + RG_DEF_METHOD(initialize, 1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiovfs.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiovfs.c new file mode 100644 index 0000000..51fd6e8 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiovfs.c @@ -0,0 +1,84 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cVfs +#define _SELF(value) RVAL2GVFS(value) + +static VALUE +rg_file_for_path(VALUE self, VALUE path) +{ + return GOBJ2RVAL_UNREF(g_vfs_get_file_for_path(_SELF(self), RVAL2CSTR(path))); +} + +static VALUE +rg_file_for_uri(VALUE self, VALUE uri) +{ + return GOBJ2RVAL_UNREF(g_vfs_get_file_for_uri(_SELF(self), RVAL2CSTR(uri))); +} + +static VALUE +rg_parse_name(VALUE self, VALUE parse_name) +{ + return GOBJ2RVAL_UNREF(g_vfs_parse_name(_SELF(self), RVAL2CSTR(parse_name))); +} + +static VALUE +rg_s_default(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(g_vfs_get_default()); +} + +static VALUE +rg_s_local(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(g_vfs_get_local()); +} + +static VALUE +rg_active_p(VALUE self) +{ + return CBOOL2RVAL(g_vfs_is_active(_SELF(self))); +} + +static VALUE +rg_supported_uri_schemes(VALUE self) +{ + return STRV2RVAL((const gchar **)g_vfs_get_supported_uri_schemes(_SELF(self))); +} + +void +Init_gvfs(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_VFS, "Vfs", mGio); + + rb_define_const(RG_TARGET_NAMESPACE, "EXTENSION_POINT_NAME", CSTR2RVAL(G_VFS_EXTENSION_POINT_NAME)); + + RG_DEF_SMETHOD(default, 0); + RG_DEF_SMETHOD(local, 0); + + RG_DEF_METHOD(file_for_path, 1); + RG_DEF_METHOD(file_for_uri, 1); + RG_DEF_METHOD(parse_name, 1); + RG_DEF_METHOD_P(active, 0); + RG_DEF_METHOD(supported_uri_schemes, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiovolume.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiovolume.c new file mode 100644 index 0000000..347b702 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiovolume.c @@ -0,0 +1,193 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE mVolume +#define _SELF(value) RVAL2GVOLUME(value) + +static VALUE +rg_name(VALUE self) +{ + return CSTR2RVAL_FREE(g_volume_get_name(_SELF(self))); +} + +static VALUE +rg_uuid(VALUE self) +{ + return CSTR2RVAL_FREE(g_volume_get_uuid(_SELF(self))); +} + +static VALUE +rg_icon(VALUE self) +{ + return GOBJ2RVAL_UNREF(g_volume_get_icon(_SELF(self))); +} + +static VALUE +rg_drive(VALUE self) +{ + return GOBJ2RVAL_UNREF(g_volume_get_drive(_SELF(self))); +} + +static VALUE +rg_get_mount(VALUE self) +{ + return GOBJ2RVAL_UNREF(g_volume_get_mount(_SELF(self))); +} + +static VALUE +rg_can_mount_p(VALUE self) +{ + return CBOOL2RVAL(g_volume_can_mount(_SELF(self))); +} + +static VALUE +rg_should_automount_p(VALUE self) +{ + return CBOOL2RVAL(g_volume_should_automount(_SELF(self))); +} + +static VALUE +rg_activation_root(VALUE self) +{ + return GOBJ2RVAL_UNREF(g_volume_get_activation_root(_SELF(self))); +} + +static VALUE +rg_mount(int argc, VALUE *argv, VALUE self) +{ + VALUE rbflags, rbmount_operation, rbcancellable, block; + GMountMountFlags flags; + GMountOperation *mount_operation; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "03&", &rbflags, &rbmount_operation, &rbcancellable, &block); + flags = RVAL2GMOUNTMOUNTFLAGSDEFAULT(rbflags); + mount_operation = RVAL2GMOUNTOPERATION(rbmount_operation); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_volume_mount(_SELF(self), + flags, + mount_operation, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +typedef gboolean (*BooleanFinishMethod)(GVolume *, + GAsyncResult *, + GError **); + +static VALUE +boolean_finish_method(BooleanFinishMethod method, VALUE self, VALUE result) +{ + GError *error = NULL; + + if (!method(_SELF(self), RVAL2GASYNCRESULT(result), &error)) + rbgio_raise_error(error); + + return self; +} + +static VALUE +rg_mount_finish(VALUE self, VALUE result) +{ + return boolean_finish_method(g_volume_mount_finish, self, result); +} + +static VALUE +rg_can_eject_p(VALUE self) +{ + return CBOOL2RVAL(g_volume_can_eject(_SELF(self))); +} + +static VALUE +rg_eject_with_operation(int argc, VALUE *argv, VALUE self) +{ + VALUE rbflags, rbmount_operation, rbcancellable, block; + GMountUnmountFlags flags; + GMountOperation *mount_operation; + GCancellable *cancellable; + + rb_scan_args(argc, argv, "03&", &rbflags, &rbmount_operation, &rbcancellable, &block); + flags = RVAL2GMOUNTUNMOUNTFLAGSDEFAULT(rbflags); + mount_operation = RVAL2GMOUNTOPERATION(rbmount_operation); + cancellable = RVAL2GCANCELLABLE(rbcancellable); + SAVE_BLOCK(block); + g_volume_eject_with_operation(_SELF(self), + flags, + mount_operation, + cancellable, + rbgio_async_ready_callback, + (gpointer)block); + + return self; +} + +static VALUE +rg_eject_with_operation_finish(VALUE self, VALUE result) +{ + return boolean_finish_method(g_volume_eject_with_operation_finish, self, result); +} + +static VALUE +rg_enumerate_identifiers(VALUE self) +{ + return STRV2RVAL_FREE(g_volume_enumerate_identifiers(_SELF(self))); +} + +static VALUE +rg_get_identifier(VALUE self, VALUE kind) +{ + return CSTR2RVAL_FREE(g_volume_get_identifier(_SELF(self), RVAL2CSTR(kind))); +} + +void +Init_gvolume(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_VOLUME, "Volume", mGio); + + rb_define_const(RG_TARGET_NAMESPACE, "IDENTIFIER_KIND_HAL_UDI", CSTR2RVAL(G_VOLUME_IDENTIFIER_KIND_HAL_UDI)); + rb_define_const(RG_TARGET_NAMESPACE, "IDENTIFIER_KIND_LABEL", CSTR2RVAL(G_VOLUME_IDENTIFIER_KIND_LABEL)); + rb_define_const(RG_TARGET_NAMESPACE, "IDENTIFIER_KIND_NFS_MOUNT", CSTR2RVAL(G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT)); + rb_define_const(RG_TARGET_NAMESPACE, "IDENTIFIER_KIND_UNIX_DEVICE", CSTR2RVAL(G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE)); + rb_define_const(RG_TARGET_NAMESPACE, "IDENTIFIER_KIND_UUID", CSTR2RVAL(G_VOLUME_IDENTIFIER_KIND_UUID)); + + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(uuid, 0); + RG_DEF_METHOD(icon, 0); + RG_DEF_METHOD(drive, 0); + RG_DEF_METHOD(get_mount, 0); + RG_DEF_METHOD_P(can_mount, 0); + RG_DEF_METHOD_P(should_automount, 0); + RG_DEF_METHOD(activation_root, 0); + RG_DEF_METHOD(mount, -1); + RG_DEF_METHOD(mount_finish, 1); + RG_DEF_METHOD_P(can_eject, 0); + RG_DEF_METHOD(eject_with_operation, -1); + RG_DEF_METHOD(eject_with_operation_finish, 1); + RG_DEF_METHOD(enumerate_identifiers, -1); + RG_DEF_ALIAS("identifiers", "enumerate_identifiers"); + RG_DEF_METHOD(get_identifier, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiovolumemonitor.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiovolumemonitor.c new file mode 100644 index 0000000..2791011 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiovolumemonitor.c @@ -0,0 +1,77 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cVolumeMonitor +#define _SELF(value) RVAL2GVOLUMEMONITOR(value) + +static VALUE +rg_s_get(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL_UNREF(g_volume_monitor_get()); +} + +static VALUE +rg_connected_drives(VALUE self) +{ + return GLIST2ARY_FREE(g_volume_monitor_get_connected_drives(_SELF(self))); +} + +static VALUE +rg_volumes(VALUE self) +{ + return GLIST2ARY_FREE(g_volume_monitor_get_volumes(_SELF(self))); +} + +static VALUE +rg_mounts(VALUE self) +{ + return GLIST2ARY_FREE(g_volume_monitor_get_mounts(_SELF(self))); +} + +static VALUE +rg_get_mount_for_uuid(VALUE self, VALUE value) +{ + return GOBJ2RVAL_UNREF(g_volume_monitor_get_mount_for_uuid(_SELF(self), RVAL2CSTR(value))); +} + +static VALUE +rg_get_volume_for_uuid(VALUE self, VALUE value) +{ + return GOBJ2RVAL_UNREF(g_volume_monitor_get_volume_for_uuid(_SELF(self), RVAL2CSTR(value))); +} + +void +Init_gvolumemonitor(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_VOLUME_MONITOR, "VolumeMonitor", mGio); + + rb_define_const(RG_TARGET_NAMESPACE, "EXTENSION_POINT_NAME", CSTR2RVAL(G_VOLUME_MONITOR_EXTENSION_POINT_NAME)); + + RG_DEF_SMETHOD(get, 0); + + RG_DEF_METHOD(connected_drives, 0); + RG_DEF_METHOD(volumes, 0); + RG_DEF_METHOD(mounts, 0); + RG_DEF_METHOD(get_mount_for_uuid, 0); + RG_DEF_METHOD(get_volume_for_uuid, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiozlibcompressor.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiozlibcompressor.c new file mode 100644 index 0000000..038a9b3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiozlibcompressor.c @@ -0,0 +1,52 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cZlibCompressor +#define _SELF(value) RVAL2GZLIBCOMPRESSOR(value) + +#define RVAL2ZLIBCOMPRESSORLEVELDEFAULT(value) \ + RVAL2TYPE_WITH_DEFAULT((value), FIX2INT, -1) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE format, level; + + rb_scan_args(argc, argv, "02", &format, &level); + G_INITIALIZE(self, + g_zlib_compressor_new(RVAL2GZLIBCOMPRESSORFORMATDEFAULT(format), + RVAL2GZLIBCOMPRESSORFORMATDEFAULT(level))); + + return Qnil; +} + +void +Init_gzlibcompressor(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_ZLIB_COMPRESSOR, "ZlibCompressor", mGio); + + G_DEF_CLASS(G_TYPE_ZLIB_COMPRESSOR_FORMAT, "Format", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_ZLIB_COMPRESSOR_FORMAT, "G_ZLIB_"); + + RG_DEF_METHOD(initialize, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiozlibdecompressor.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiozlibdecompressor.c new file mode 100644 index 0000000..3e91efd --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/rbgiozlibdecompressor.c @@ -0,0 +1,45 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + +#define RG_TARGET_NAMESPACE cZlibDecompressor +#define _SELF(value) RVAL2GZLIBDECOMPRESSOR(value) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE format; + + rb_scan_args(argc, argv, "01", &format); + G_INITIALIZE(self, + g_zlib_decompressor_new(RVAL2GZLIBCOMPRESSORFORMATDEFAULT(format))); + + return Qnil; +} + +void +Init_gzlibdecompressor(VALUE mGio) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_ZLIB_DECOMPRESSOR, "ZlibDecompressor", mGio); + + RG_DEF_METHOD(initialize, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/util.c b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/util.c new file mode 100644 index 0000000..1f460de --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/ext/gio2/util.c @@ -0,0 +1,303 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgio2private.h" + + +#ifndef HAVE_RB_ERRINFO +# define rb_errinfo() (ruby_errinfo) +#endif + + +static ID s_id_enum_name; +static ID s_id_errors; + +static VALUE s_errors; + + +VALUE +rbgio_cstr_to_rval_tainted(const char *string, gsize length) +{ + VALUE result; + + if (string == NULL) + return Qnil; + + result = rb_str_new(string, length); + OBJ_TAINT(result); + + return result; +} + +struct rbgio_cstr_to_rval_tainted_free_data +{ + char *string; + gsize length; +}; + +static VALUE +rbgio_cstr_to_rval_tainted_free_body(VALUE data) +{ + struct rbgio_cstr_to_rval_tainted_free_data *real; + + real = (struct rbgio_cstr_to_rval_tainted_free_data *)data; + + return rbgio_cstr_to_rval_tainted(real->string, real->length); +} + +static VALUE +rbgio_cstr_to_rval_tainted_free_ensure(VALUE data) +{ + g_free(((struct rbgio_cstr_to_rval_tainted_free_data *)data)->string); + + return Qnil; +} + +VALUE +rbgio_cstr_to_rval_tainted_free(char *string, gsize length) +{ + struct rbgio_cstr_to_rval_tainted_free_data data = { string, length }; + + return rb_ensure(rbgio_cstr_to_rval_tainted_free_body, (VALUE)&data, + rbgio_cstr_to_rval_tainted_free_ensure, (VALUE)&data); +} + +VALUE +rbgio_glist_to_ary_unref_free(GList *list) +{ + VALUE ary; + GList *i; + + ary = rb_ary_new(); + for (i = list; i != NULL; i = i->next) + rb_ary_push(ary, GOBJ2RVAL_UNREF(i->data)); + g_list_free(list); + + return ary; +} + +VALUE +rbgio_fds_to_ary(const gint *fds) +{ + int i, n; + VALUE ary; + + for (i = n = 0; fds[i] != -1; i++) + n++; + + ary = rb_ary_new2(n); + for (i = 0; i < n; i++) + RARRAY_PTR(ary)[i] = FD2RVAL(fds[i]); + + return ary; +} + +static VALUE +rbgio_fds_to_ary_free_ensure(gint *fds) +{ + g_free(fds); + + return Qnil; +} + +VALUE +rbgio_fds_to_ary_free(gint *fds) +{ + return rb_ensure(rbgio_fds_to_ary, (VALUE)fds, + rbgio_fds_to_ary_free_ensure, (VALUE)fds); +} + +struct rbgio_gfile_ary_to_glist_args { + VALUE ary; + long n; + GList *result; +}; + +static VALUE +rbgio_gfile_ary_to_glist_body(VALUE value) +{ + long i; + struct rbgio_gfile_ary_to_glist_args *args = (struct rbgio_gfile_ary_to_glist_args *)value; + + for (i = 0; i < args->n; i++) + args->result = g_list_append(args->result, RVAL2GFILE(RARRAY_PTR(args->ary)[i])); + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbgio_gfile_ary_to_glist_rescue(VALUE value) +{ + g_list_free(((struct rbgio_gfile_ary_to_glist_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +GList * +rbgio_gfile_ary_to_glist(VALUE value) +{ + struct rbgio_gfile_ary_to_glist_args args; + + args.ary = rb_ary_to_ary(value); + args.n = RARRAY_LEN(args.ary); + args.result = NULL; + + rb_rescue(rbgio_gfile_ary_to_glist_body, (VALUE)&args, + rbgio_gfile_ary_to_glist_rescue, (VALUE)&args); + + return args.result; +} + +GList * +rbgio_gfile_ary_to_glist_accept_nil(VALUE ary) +{ + if (NIL_P(ary)) + return NULL; + + return rbgio_gfile_ary_to_glist(ary); +} + +void +rbgio_rval_to_gtimeval(VALUE value, GTimeVal *time) +{ + if (rb_respond_to(value, rb_intern("tv_sec"))) { + time->tv_sec = RVAL2GLONG(rb_funcall(value, rb_intern("tv_sec"), 0)); + time->tv_usec = rb_respond_to(value, rb_intern("tv_usec")) ? + RVAL2GLONG(rb_funcall(value, rb_intern("tv_usec"), 0)) : + 0; + } else if (rb_respond_to(value, rb_intern("to_ary"))) { + VALUE ary = rb_ary_to_ary(value); + if (RARRAY_LEN(ary) < 1 || RARRAY_LEN(ary) > 2) + rb_raise(rb_eArgError, "Array of length 1 or 2 expected"); + time->tv_sec = RVAL2GLONG(RARRAY_PTR(ary)[0]); + time->tv_usec = RARRAY_LEN(ary) > 1 ? RVAL2GLONG(RARRAY_PTR(ary)[1]) : 0; + } else { + time->tv_sec = RVAL2GLONG(value); + time->tv_usec = 0; + } +} + +struct async_ready_callback_data +{ + GAsyncResult *result; + gpointer data; +}; + +static VALUE +rbgio_async_ready_callback_call(VALUE data) +{ + static VALUE s_id_call; + struct async_ready_callback_data *real; + VALUE block; + + if (s_id_call == 0) + s_id_call = rb_intern("call"); + + real = (struct async_ready_callback_data *)data; + block = USE_BLOCK(real->data); + if (!NIL_P(block)) + rb_funcall(block, s_id_call, 1, GOBJ2RVAL_UNREF(real->result)); + + return Qnil; +} + +void +rbgio_async_ready_callback(G_GNUC_UNUSED GObject *source, + GAsyncResult *result, + gpointer data) +{ + struct async_ready_callback_data real = { result, data }; + + G_PROTECT_CALLBACK(rbgio_async_ready_callback_call, &real); +} + +VALUE +rbgio_child_remove_and_return(VALUE parent, VALUE child) +{ + G_CHILD_REMOVE(parent, child); + + return child; +} + +VALUE +rbgio_define_domain_error(VALUE module, + const char *name, + GQuark domain, + const char *enum_name, + VALUE parent) +{ + VALUE error; + + error = rb_define_class_under(module, name, parent); + rb_ivar_set(error, s_id_enum_name, CSTR2RVAL(enum_name)); + rb_ivar_set(error, s_id_errors, rb_hash_new()); + rb_hash_aset(s_errors, UINT2NUM(domain), error); + + return error; +} + +VALUE +rbgio_define_error(VALUE module, + const char *name, + gint code, + VALUE domain_error) +{ + VALUE error; + + error = rb_define_class_under(module, name, domain_error); + rb_hash_aset(rb_ivar_get(domain_error, s_id_errors), + INT2NUM(code), + error); + + return error; +} + +void +rbgio_raise_error(GError *error) +{ + VALUE domain_error, rberror; + + domain_error = rb_hash_aref(s_errors, UINT2NUM(error->domain)); + if (NIL_P(domain_error)) + RAISE_GERROR(error); + + rberror = rb_hash_aref(rb_ivar_get(domain_error, s_id_errors), + INT2NUM(error->code)); + if (NIL_P(rberror)) { + VALUE enum_name = rb_ivar_get(domain_error, s_id_enum_name); + + rb_raise(rb_eNotImpError, + "%s contains error codes that have not been implemented: %d", + RVAL2CSTR(enum_name), error->code); + } + + rb_raise(rberror, "%s", error->message); +} + +void +Init_util(void) +{ + s_id_enum_name = rb_intern("@enum_name"); + s_id_errors = rb_intern("@errors"); + + s_errors = rb_hash_new(); + rb_global_variable(&s_errors); +} diff --git a/lib/ruby-gtk2-2.0.2/gio2/extconf.rb b/lib/ruby-gtk2-2.0.2/gio2/extconf.rb new file mode 100644 index 0000000..a3d74f6 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/extconf.rb @@ -0,0 +1,49 @@ +#!/usr/bin/env ruby + +require 'pathname' +require 'mkmf' +require 'rbconfig' +require 'fileutils' + +package = "gio2" + +base_dir = Pathname(__FILE__).dirname.expand_path +ext_dir = base_dir + "ext" + package +mkmf_gnome2_dir = base_dir + 'lib' + +ruby = File.join(RbConfig::CONFIG['bindir'], + RbConfig::CONFIG['ruby_install_name'] + + RbConfig::CONFIG["EXEEXT"]) + +build_dir = Pathname("ext") + package +FileUtils.mkdir_p(build_dir.to_s) unless build_dir.exist? +extconf_rb_path = ext_dir + "extconf.rb" +system(ruby, "-C", build_dir.to_s, extconf_rb_path.to_s, *ARGV) || exit(false) + +create_makefile(package) +FileUtils.mv("Makefile", "Makefile.lib") + +File.open("Makefile", "w") do |makefile| + makefile.puts(<<-EOM) +all: + (cd ext/#{package} && $(MAKE)) + $(MAKE) -f Makefile.lib + +install: + (cd ext/#{package} && $(MAKE) install) + $(MAKE) -f Makefile.lib install + +site-install: + (cd ext/#{package} && $(MAKE) site-install) + $(MAKE) -f Makefile.lib site-install + +clean: + (cd ext/#{package} && $(MAKE) clean) + $(MAKE) -f Makefile.lib clean + +distclean: + (cd ext/#{package} && $(MAKE) distclean) + $(MAKE) -f Makefile.lib distclean + @rm -f Makefile.lib +EOM +end diff --git a/lib/ruby-gtk2-2.0.2/gio2/lib/gio2.rb b/lib/ruby-gtk2-2.0.2/gio2/lib/gio2.rb new file mode 100644 index 0000000..f915a5a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/lib/gio2.rb @@ -0,0 +1,161 @@ +require 'glib2' + +base_dir = Pathname.new(__FILE__).dirname.dirname.expand_path +vendor_dir = base_dir + "vendor" + "local" +vendor_bin_dir = vendor_dir + "bin" +GLib.prepend_dll_path(vendor_bin_dir) +begin + major, minor, _ = RUBY_VERSION.split(/\./) + require "#{major}.#{minor}/gio2.so" +rescue LoadError + require "gio2.so" +end + +require "gio2/deprecated" + +class Gio::DataInputStream + include Enumerable + + def each + while line = read_line + yield line + end + end + + alias each_line each + + def each_async(io_priority = GLib::PRIORITY_DEFAULT, cancellable = nil, &block) + each_async_loop io_priority, cancellable, block + self + end + + alias each_line_async each_async + +private + + def each_async_loop(io_priority, cancellable, block) + # TODO: Should we really pass in the object? I mean, how often is that + # useful? We can always get it with result.source_object as well. + read_line_async io_priority, cancellable do |result| + if line = read_line_finish(result) + block.call line + each_async_loop io_priority, cancellable, block + end + end + end + + # TODO: Add #each_byte? +end + +if Gio.const_defined? :DesktopAppInfo + class Gio::DesktopAppInfo + class << self + def desktop_env=(desktop_env) + set_desktop_env desktop_env + desktop_env + end + end + end +end + +module Gio::File + include Enumerable + + def eql?(other) + self === other and self == other + end + + alias each enumerate_children + + def each_async(num_files, attributes = nil, flags = nil, + io_priority = GLib::PRIORITY_DEFAULT, cancellable = nil, + &block) + enumerate_children_async attributes, flags, io_priority, cancellable do |result| + enumerate_children_finish(result).each_async num_files, io_priority, cancellable, &block + end + self + end +end + +class Gio::FileEnumerator + include Enumerable + + def each(cancellable = nil) + return self.enum_for unless block_given? + while file = next_file(cancellable) + yield file + end + close + self + end + + # TODO: Return Enumerator unless block_given? + def each_async(num_files, io_priority = GLib::PRIORITY_DEFAULT, cancellable = nil, &block) + each_async_loop num_files, io_priority, cancellable, block + end + +private + + def each_async_loop(num_files, io_priority, cancellable, block) + next_files_async num_files, io_priority, cancellable do |result| + files = next_files_finish(result) + files.each do |file| + block.call file + end + if files.length > 0 + each_async_loop num_files, io_priority, cancellable, block + else + close + end + end + end +end + +class Gio::FileInfo + def directory? + file_type == Gio::File::Type::DIRECTORY + end +end + +module Gio::Icon + def eql?(other) + self === other and self == other + end +end + +class Gio::InputStream + def pending=(pending) + pending ? set_pending : clear_pending + end +end + +class Gio::Resolver + class << self + def default=(default) + set_default default + default + end + end +end + +module Gio::SocketConnectable + include Enumerable + + def each(cancellable = nil) + enumerator = enumerate + while address = enumerator.next(cancellable) + yield address + end + end +end + +class Gio::UnixFDList + include Enumerable + + def each + i = 0 + while i < length + yield self[i] + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gio2/lib/gio2/deprecated.rb b/lib/ruby-gtk2-2.0.2/gio2/lib/gio2/deprecated.rb new file mode 100644 index 0000000..7e5ee48 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/lib/gio2/deprecated.rb @@ -0,0 +1,102 @@ +module GLib + extend GLib::Deprecatable + define_deprecated_const :AppInfo, 'Gio::AppInfo' + define_deprecated_const :AppLaunchContext, 'Gio::AppLaunchContext' + define_deprecated_const :AskPasswordFlags, 'Gio::AskPasswordFlags' + define_deprecated_const :AsyncInitable, 'Gio::AsyncInitable' + define_deprecated_const :AsyncResult, 'Gio::AsyncResult' + define_deprecated_const :BufferedInputStream, 'Gio::BufferedInputStream' + define_deprecated_const :BufferedOutputStream, 'Gio::BufferedOutputStream' + define_deprecated_const :Cancellable, 'Gio::Cancellable' + define_deprecated_const :CharsetConverter, 'Gio::CharsetConverter' + define_deprecated_const :ContentType, 'Gio::ContentType' + define_deprecated_const :Converter, 'Gio::Converter' + define_deprecated_const :ConverterInputStream, 'Gio::ConverterInputStream' + define_deprecated_const :ConverterOutputStream, 'Gio::ConverterOutputStream' + define_deprecated_const :DataInputStream, 'Gio::DataInputStream' + define_deprecated_const :DataOutputStream, 'Gio::DataOutputStream' + define_deprecated_const :DataStreamByteOrder, 'Gio::DataStreamByteOrder' + define_deprecated_const :DataStreamNewlineType, 'Gio::DataStreamNewlineType' + define_deprecated_const :DesktopAppInfo, 'Gio::DesktopAppInfo' + define_deprecated_const :Drive, 'Gio::Drive' + define_deprecated_const :Emblem, 'Gio::Emblem' + define_deprecated_const :EmblemedIcon, 'Gio::EmblemedIcon' + define_deprecated_const :File, 'Gio::File' + define_deprecated_const :FileAttribute, 'Gio::FileAttribute' + define_deprecated_const :FileAttributeInfo, 'Gio::FileAttributeInfo' + define_deprecated_const :FileAttributeMatcher, 'Gio::FileAttributeMatcher' + define_deprecated_const :FileDescriptorBased, 'Gio::FileDescriptorBased' + define_deprecated_const :FileEnumerator, 'Gio::FileEnumerator' + define_deprecated_const :FileIOStream, 'Gio::FileIOStream' + define_deprecated_const :FileIcon, 'Gio::FileIcon' + define_deprecated_const :FileInfo, 'Gio::FileInfo' + define_deprecated_const :FileInputStream, 'Gio::FileInputStream' + define_deprecated_const :FileMonitor, 'Gio::FileMonitor' + define_deprecated_const :FileOutputStream, 'Gio::FileOutputStream' + define_deprecated_const :FilenameCompleter, 'Gio::FilenameCompleter' + define_deprecated_const :FilesystemPreviewType, 'Gio::FilesystemPreviewType' + define_deprecated_const :FilterInputStream, 'Gio::FilterInputStream' + define_deprecated_const :FilterOutputStream, 'Gio::FilterOutputStream' + define_deprecated_const :IO, 'Gio::IO' + define_deprecated_const :IOModule, 'Gio::IOModule' + define_deprecated_const :IOModules, 'Gio::IOModules' + define_deprecated_const :IOScheduler, 'Gio::IOScheduler' + define_deprecated_const :IOSchedulerJob, 'Gio::IOSchedulerJob' + define_deprecated_const :IOStream, 'Gio::IOStream' + define_deprecated_const :Icon, 'Gio::Icon' + define_deprecated_const :InetAddress, 'Gio::InetAddress' + define_deprecated_const :InetSocketAddress, 'Gio::InetSocketAddress' + define_deprecated_const :Initable, 'Gio::Initable' + define_deprecated_const :InputStream, 'Gio::InputStream' + define_deprecated_const :LoadableIcon, 'Gio::LoadableIcon' + define_deprecated_const :MemoryInputStream, 'Gio::MemoryInputStream' + define_deprecated_const :MemoryOutputStream, 'Gio::MemoryOutputStream' + define_deprecated_const :Mount, 'Gio::Mount' + define_deprecated_const :MountOperation, 'Gio::MountOperation' + define_deprecated_const :NetworkAddress, 'Gio::NetworkAddress' + define_deprecated_const :NetworkService, 'Gio::NetworkService' + define_deprecated_const :OutputStream, 'Gio::OutputStream' + define_deprecated_const :PasswordSave, 'Gio::PasswordSave' + define_deprecated_const :Resolver, 'Gio::Resolver' + define_deprecated_const :Seekable, 'Gio::Seekable' + define_deprecated_const :SimpleAsyncResult, 'Gio::SimpleAsyncResult' + define_deprecated_const :Socket, 'Gio::Socket' + define_deprecated_const :SocketAddress, 'Gio::SocketAddress' + define_deprecated_const :SocketAddressEnumerator, 'Gio::SocketAddressEnumerator' + define_deprecated_const :SocketClient, 'Gio::SocketClient' + define_deprecated_const :SocketConnectable, 'Gio::SocketConnectable' + define_deprecated_const :SocketConnection, 'Gio::SocketConnection' + define_deprecated_const :SocketConnectionFactory, 'Gio::SocketConnectionFactory' + define_deprecated_const :SocketControlMessage, 'Gio::SocketControlMessage' + define_deprecated_const :SocketListener, 'Gio::SocketListener' + define_deprecated_const :SocketService, 'Gio::SocketService' + define_deprecated_const :SrvTarget, 'Gio::SrvTarget' + define_deprecated_const :TcpConnection, 'Gio::TcpConnection' + define_deprecated_const :ThemedIcon, 'Gio::ThemedIcon' + define_deprecated_const :ThreadedSocketService, 'Gio::ThreadedSocketService' + define_deprecated_const :UnixConnection, 'Gio::UnixConnection' + define_deprecated_const :UnixFDList, 'Gio::UnixFDList' + define_deprecated_const :UnixFDMessage, 'Gio::UnixFDMessage' + define_deprecated_const :UnixInputStream, 'Gio::UnixInputStream' + define_deprecated_const :UnixMount, 'Gio::UnixMount' + define_deprecated_const :UnixMountMonitor, 'Gio::UnixMountMonitor' + define_deprecated_const :UnixMountPoint, 'Gio::UnixMountPoint' + define_deprecated_const :UnixMountPoints, 'Gio::UnixMountPoints' + define_deprecated_const :UnixMounts, 'Gio::UnixMounts' + define_deprecated_const :UnixOutputStream, 'Gio::UnixOutputStream' + define_deprecated_const :UnixSocketAddress, 'Gio::UnixSocketAddress' + define_deprecated_const :Vfs, 'Gio::Vfs' + define_deprecated_const :Volume, 'Gio::Volume' + define_deprecated_const :VolumeMonitor, 'Gio::VolumeMonitor' + define_deprecated_const :ZlibCompressor, 'Gio::ZlibCompressor' + define_deprecated_const :ZlibDecompressor, 'Gio::ZlibDecompressor' + define_deprecated_enums 'Gio::FilesystemPreviewType', 'FILESYSTEM_PREVIEW_TYPE' + define_deprecated_enums 'Gio::DataStreamByteOrder', 'DATA_STREAM_BYTE_ORDER' + define_deprecated_enums 'Gio::DataStreamNewlineType', 'DATA_STREAM_NEWLINE_TYPE' + define_deprecated_flags 'Gio::AskPasswordFlags', 'ASK_PASSWORD' + define_deprecated_enums 'Gio::PasswordSave', 'PASSWORD_SAVE' + define_deprecated_singleton_method :gio_has_unix?, :warn => "Use 'Gio.has_unix?'." do |_self| + Gio.has_unix? + end +end + diff --git a/lib/ruby-gtk2-2.0.2/gio2/test/load-test.rb b/lib/ruby-gtk2-2.0.2/gio2/test/load-test.rb new file mode 100644 index 0000000..da2de32 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/test/load-test.rb @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- + +base = File.dirname(File.expand_path(__FILE__)) +root = File.dirname(File.dirname(base)) +['glib2', 'gio2'].each do |lib| + ['ext/%s' % lib, 'lib'].each do |sub| + $LOAD_PATH.unshift File.join(root, lib, sub) + end +end + +require 'gio2' +require File.join(root, 'glib2/test/glib-test-init') + +exit Test::Unit::AutoRunner.run(true, base) diff --git a/lib/ruby-gtk2-2.0.2/gio2/test/test_bufferedinputstream.rb b/lib/ruby-gtk2-2.0.2/gio2/test/test_bufferedinputstream.rb new file mode 100644 index 0000000..633f866 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/test/test_bufferedinputstream.rb @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- + diff --git a/lib/ruby-gtk2-2.0.2/gio2/test/test_charsetconverter.rb b/lib/ruby-gtk2-2.0.2/gio2/test/test_charsetconverter.rb new file mode 100644 index 0000000..633f866 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/test/test_charsetconverter.rb @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- + diff --git a/lib/ruby-gtk2-2.0.2/gio2/test/test_datainputstream.rb b/lib/ruby-gtk2-2.0.2/gio2/test/test_datainputstream.rb new file mode 100644 index 0000000..8297e24 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/test/test_datainputstream.rb @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- + +class TestDataInputStream < Test::Unit::TestCase + def test_byte_order_property + assert_equal GLib::DATA_STREAM_BYTE_ORDER_BIG_ENDIAN, GLib::DataInputStream.new(GLib::MemoryInputStream.new).byte_order + end +end diff --git a/lib/ruby-gtk2-2.0.2/gio2/test/test_fileenumerator.rb b/lib/ruby-gtk2-2.0.2/gio2/test/test_fileenumerator.rb new file mode 100644 index 0000000..adbf3ff --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/test/test_fileenumerator.rb @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- + +class TestFileEnumerator < Test::Unit::TestCase + def test_responds_to_properties + a = GLib::File.new_for_path('/').enumerate_children + assert a.respond_to?(:container) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gio2/test/test_filemonitor.rb b/lib/ruby-gtk2-2.0.2/gio2/test/test_filemonitor.rb new file mode 100644 index 0000000..633f866 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/test/test_filemonitor.rb @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- + diff --git a/lib/ruby-gtk2-2.0.2/gio2/test/test_inetaddress.rb b/lib/ruby-gtk2-2.0.2/gio2/test/test_inetaddress.rb new file mode 100644 index 0000000..a496645 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gio2/test/test_inetaddress.rb @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- + +class TestInetAddress < Test::Unit::TestCase + def test_responds_to_properties + a = GLib::InetAddress.new_any(GLib::Socket::FAMILY_IPV4) + assert a.respond_to?(:any?) + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/COPYING.LIB b/lib/ruby-gtk2-2.0.2/glib2/COPYING.LIB new file mode 100644 index 0000000..b1e3f5a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/COPYING.LIB @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. + + GNU LESSER GENERAL PUBLIC LICENSE + 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 + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/lib/ruby-gtk2-2.0.2/glib2/README b/lib/ruby-gtk2-2.0.2/glib2/README new file mode 100644 index 0000000..9364842 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/README @@ -0,0 +1,40 @@ +Ruby/GLib2 +========== +Ruby/GLib2 is a Ruby binding of GLib-2.x. + +Requirements +------------ + + Ruby >= 1.8.5: http://www.ruby-lang.org/ + pkg-config.rb: http://github.com/rcairo/pkg-config + GLib >= 2.x: http://www.gtk.org/ + +Install (RubyGems) +------------------ + + % sudo gem install glib2 + +Windows: + + > gem install glib2 --platform x86-mingw32 + +Install (traditional) +--------------------- + +Install ruby-1.8.5 or later, pkg-config.rb and GLib-2.x. + + % ruby extconf.rb + % make + % sudo make install + +Copying +------- + Copyright (c) 2002-2010 Ruby-GNOME2 Project Team + + This program is free software. + You can distribute/modify this program under the terms of + the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. + +Project Website +--------------- + http://ruby-gnome2.sourceforge.jp/ diff --git a/lib/ruby-gtk2-2.0.2/glib2/Rakefile b/lib/ruby-gtk2-2.0.2/glib2/Rakefile new file mode 100644 index 0000000..f0c5366 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/Rakefile @@ -0,0 +1,128 @@ +# -*- ruby -*- + +$LOAD_PATH.unshift("./lib") +require 'gnome2-raketask' + +include_dir = nil +glib2_include_dir = nil +libffi_lib_dir = nil + +package = GNOME2Package.new do |_package| + include_dir = (_package.windows.absolute_binary_dir + "include").to_s + glib2_include_dir = File.join(include_dir, "glib-2.0") + libffi_lib_dir = (_package.windows.absolute_binary_dir + "lib").to_s + + _package.summary = "Ruby/GLib2 is a Ruby binding of GLib-2.x." + _package.description = "Ruby/GLib2 is a Ruby binding of GLib-2.x." + _package.dependency.gem.runtime = [["pkg-config", ">= 0"]] + _package.dependency.gem.development = [["test-unit", ">= 2"]] + _package.win32.packages = [] + _package.win32.dependencies = ["zlib", "libffi", "gettext-runtime"] + _package.external_packages = [ + { + :name => "glib", + :download_site => :gnome, + :label => "GLib", + :version => "2.36.2", + :compression_method => "xz", + :windows => { + :configure_args => [ + "LIBFFI_CFLAGS=-I#{include_dir}", + "LIBFFI_LIBS=-L#{libffi_lib_dir} -lffi", + "--disable-modular-tests", + ], + :need_autoreconf => true, + }, + }, + { + :name => "gmp", + :download_base_url => "ftp://ftp.gmplib.org/pub/gmp-5.1.2", + :label => "GNU MP", + :version => "5.1.2", + :compression_method => "xz", + :windows => { + :configure_args => [ + "--disable-static", + "--enable-shared", + ], + }, + }, + { + :name => "nettle", + :download_base_url => "http://www.lysator.liu.se/~nisse/archive", + :label => "Nettle", + :version => "2.7", + :windows => { + :configure_args => [], + }, + }, + { + :name => "gnutls", + :download_base_url => "ftp://ftp.gnutls.org/gcrypt/gnutls/v3.1", + :label => "GnuTLS", + :version => "3.1.11", + :compression_method => "xz", + :windows => { + :configure_args => [ + "--with-libnettle-prefix=#{_package.win32.absolute_binary_dir}" + ], + :use_cc_environment_variable => false, + }, + }, + { + :name => "glib-networking", + :download_site => :gnome, + :label => "glib-networking", + :version => "2.36.2", + :compression_method => "xz", + :windows => { + :configure_args => [ + "--without-libproxy", + "--without-gnome-proxy", + "--without-ca-certificates", + ], + }, + }, + ] +end +package.define_tasks + +namespace :win32 do + namespace :libffi do + namespace :header do + desc "Move libffi headers to include/" + task :fix do + libffi_version = "libffi-3.0.6" + mv(Dir.glob(File.join(libffi_lib_dir, libffi_version, "include", "*.h")), + include_dir) + rm_rf(File.join(libffi_lib_dir, libffi_version)) + end + end + end + + namespace :downloader do + task :after => [ + "win32:libffi:header:fix", + ] + end + + namespace :gettext do + namespace :header do + desc "Copy gettext headers to include/glib-2.0/" + task :fix do + cp(File.join(include_dir, "libintl.h"), + glib2_include_dir) + end + end + end + + namespace :buildler do + namespace :build do + namespace :glib do + task :after => [ + "win32:gettext:header:fix", + ] + end + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/TODO b/lib/ruby-gtk2-2.0.2/glib2/TODO new file mode 100644 index 0000000..0e2f714 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/TODO @@ -0,0 +1,3 @@ +* GIO support +* inspect include readable properties. +* make log message handler set by Ruby/GLib removable. diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/depend b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/depend new file mode 100644 index 0000000..7d2e1c6 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/depend @@ -0,0 +1,18 @@ +install-so: install-headers +install-headers: + $(INSTALL_DATA) $(srcdir)/rbglib.h $(RUBYARCHDIR) + $(INSTALL_DATA) $(srcdir)/rbglibdeprecated.h $(RUBYARCHDIR) + $(INSTALL_DATA) $(srcdir)/rbglib2conversions.h $(RUBYARCHDIR) + $(INSTALL_DATA) $(srcdir)/rbgutil.h $(RUBYARCHDIR) + $(INSTALL_DATA) $(srcdir)/rbgutil_list.h $(RUBYARCHDIR) + $(INSTALL_DATA) $(srcdir)/rbgutildeprecated.h $(RUBYARCHDIR) + $(INSTALL_DATA) $(srcdir)/rbgobject.h $(RUBYARCHDIR) + $(INSTALL_DATA) $(srcdir)/rbgcompat.h $(RUBYARCHDIR) + $(INSTALL_DATA) glib-enum-types.h $(RUBYARCHDIR) + +install: install-pc +install-pc: + if test -n "$(pkgconfigdir)"; then \ + $(MAKEDIRS) $(pkgconfigdir); \ + $(INSTALL_DATA) ruby-glib2.pc $(pkgconfigdir); \ + fi diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/extconf.rb b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/extconf.rb new file mode 100644 index 0000000..730857a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/extconf.rb @@ -0,0 +1,78 @@ +=begin +extconf.rb for Ruby/GLib extention library +=end + +require 'pathname' + +base_dir = Pathname(__FILE__).dirname.parent.parent.expand_path +mkmf_gnome2_dir = base_dir + 'lib' + +$LOAD_PATH.unshift(mkmf_gnome2_dir.to_s) + +module_name = "glib2" +package_id = "gobject-2.0" + +require 'mkmf-gnome2' + +setup_win32(module_name, base_dir) + +unless required_pkg_config_package(package_id, + :debian => "libglib2.0-dev", + :redhat => "glib2-devel", + :homebrew => "glib", + :macports => "glib2") + exit(false) +end +PKGConfig.have_package('gthread-2.0') + +have_header("unistd.h") +have_header("io.h") + +glib_header = "glib.h" +have_func("g_spawn_close_pid", glib_header) +have_func("g_thread_init", glib_header) +have_func("g_main_depth", glib_header) +have_func("g_listenv", glib_header) + +ruby_header = "ruby.h" +have_func("rb_check_array_type", ruby_header) +have_func("rb_check_hash_type", ruby_header) +have_func("rb_exec_recursive", ruby_header) +have_func("rb_errinfo", ruby_header) +have_func("rb_sourcefile", ruby_header) +have_func("rb_sourceline", ruby_header) +have_func("ruby_set_current_source", ruby_header) +have_func("rb_thread_blocking_region", ruby_header) +have_func("ruby_native_thread_p", ruby_header) +have_func("rb_thread_call_with_gvl", ruby_header) +have_func("rb_str_new_cstr", ruby_header) +have_func("rb_gc_register_mark_object", ruby_header) + +have_var("curr_thread", [ruby_header, "node.h"]) +have_var("rb_curr_thread", [ruby_header, "node.h"]) + +create_pkg_config_file("Ruby/GLib2", package_id) + +enum_types_prefix = "glib-enum-types" +include_paths = PKGConfig.cflags_only_I("glib-2.0") +headers = include_paths.split.inject([]) do |result, path| + result + Dir.glob(File.join(path.sub(/^-I/, ""), "glib", "*.h")) +end.reject do |file| + /g(iochannel|main|scanner)\.h/ =~ file +end +include_paths = PKGConfig.cflags_only_I("gobject-2.0") +headers = include_paths.split.inject(headers) do |result, path| + result + Dir.glob(File.join(path.sub(/^-I/, ""), "gobject", "gsignal.h")) +end +glib_mkenums(enum_types_prefix, headers, "G_TYPE_", ["glib-object.h"]) + +$defs << "-DRUBY_GLIB2_COMPILATION" +create_makefile(module_name) + +pkg_config_dir = with_config("pkg-config-dir") +if pkg_config_dir.is_a?(String) + File.open("Makefile", "ab") do |makefile| + makefile.puts + makefile.puts("pkgconfigdir=#{pkg_config_dir}") + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/glib2.def b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/glib2.def new file mode 100644 index 0000000..3032e58 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/glib2.def @@ -0,0 +1,144 @@ +EXPORTS + Init_glib2 + mGLib DATA + rbgobj_cType DATA + rbgobj_id_children DATA + rbgobj_add_relative + rbgobj_invalidate_relatives + rbgobj_add_relative_removable + rbgobj_get_relative_removable + rbgobj_remove_relative + rbgobj_remove_relative_all + rbgobj_define_class + rbgobj_define_class_dynamic + rbgobj_register_mark_func + rbgobj_register_free_func + rbgobj_instance_from_ruby_object + rbgobj_ruby_object_from_instance + rbgobj_ruby_object_from_instance2 + rbgobj_ruby_object_from_instance_with_unref + rbgobj_get_ruby_object_from_gobject + rbgobj_create_object + rbgobj_gobject_new + rbgobj_gobject_initialize + rbgobj_boxed_create + rbgobj_boxed_get + rbgobj_boxed_get_default + rbgobj_boxed_not_copy_obj + rbgobj_boxed_unown + rbgobj_make_boxed + rbgobj_make_boxed_raw + rbgobj_make_boxed_default + rbgobj_add_abstract_but_create_instance_class + rbgobj_gtype_get + rbgobj_gtype_new + rbgobj_gvalue_to_rvalue + rbgobj_gvalue_to_rvalue_unset + rbgobj_rvalue_to_gvalue + rbgobj_initialize_gvalue + rbgobj_initialize_object + rbgobj_lookup_class + rbgobj_lookup_class_by_gtype + rbgobj_gtype_to_ruby_class + rbgobj_ptr2cptr + rbgobj_ptr_new + rbgobj_make_enum + rbgobj_get_enum + rbgobj_make_flags + rbgobj_get_flags + rbgobj_register_g2r_func + rbgobj_register_r2g_func + rbgobj_register_class + rbgobj_register_property_getter + rbgobj_register_property_setter + rbgobj_set_signal_func + rbgobj_get_signal_func + rbgobj_add_constants + rbgobj_constant_remap + rbgobj_signal_wrap + g_rclosure_new + g_rclosure_attach + g_rclosure_set_tag + rbgobj_ruby_value_get_type + g_value_get_ruby_value + g_value_set_ruby_value + g_key_file_get_type + rbg_rval_inspect + rbg_string_value_ptr + rbg_rval2cstr + rbg_rval2cstr_accept_nil + rbg_rval2cstr_accept_symbol + rbg_rval2cstr_accept_symbol_accept_nil + rbg_rval2glibid + rbg_cstr2rval + rbg_cstr2rval_len + rbg_cstr2rval_len_free + rbg_cstr2rval_with_encoding + rbg_cstr2rval_len_with_encoding + rbg_cstr2rval_free + rbg_cstr2rval_with_free + rbg_filename_to_ruby + rbg_filename_to_ruby_free + rbg_filename_from_ruby + rbg_filename_gslist_to_array_free + rbg_rval2strv + rbg_rval2strv_accept_nil + rbg_rval2strv_dup + rbg_rval2strv_dup_accept_nil + rbg_strv2rval + rbg_strv2rval_free + rbg_rval2gbooleans + rbg_rval2gints + rbg_rval2gint8s + rbg_rval2guint8s + rbg_rval2guint16s + rbg_rval2guint32s + rbg_rval2gdoubles + rbg_gints2rval + rbg_gints2rval_free + rbg_glist2rval + rbg_gslist2rval + rbg_glist2rval_with_type + rbg_gslist2rval_with_type + rbg_define_method + rbg_define_singleton_method + rbg_to_array + rbg_to_hash + rbg_check_array_type + rbg_check_hash_type + rbg_scan_options + rbgutil_id_module_eval DATA + rbgutil_def_setters + rbgutil_glist2ary + rbgutil_glist2ary_boxed + rbgutil_glist2ary_string + rbgutil_glist2ary_and_free + rbgutil_glist2ary_boxed_and_free + rbgutil_glist2ary_string_and_free + rbgutil_gslist2ary + rbgutil_gslist2ary_boxed + rbgutil_gslist2ary_and_free + rbgutil_gslist2ary_boxed_and_free + rbgutil_set_properties + rbgutil_glibid_r2g_func + rbgutil_sym_g2r_func + rbgutil_protect + rbgutil_invoke_callback + rbgutil_start_callback_dispatch_thread + rbgutil_stop_callback_dispatch_thread + rbgutil_string_set_utf8_encoding + rbgutil_key_equal + rbgerr_define_gerror + rbgerr_gerror2exception + rbgobj_convert_define + rbgobj_gc_mark_gvalue + rbgobj_gc_mark_instance + rbglib_num_to_uint64 + rbglib_uint64_to_num + rbglib_num_to_int64 + rbglib_int64_to_num + + g_source_get_type + g_connect_flags_get_type + g_poll_fd_get_type + g_signal_flags_get_type diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgcompat.h b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgcompat.h new file mode 100644 index 0000000..03de03c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgcompat.h @@ -0,0 +1,29 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2007 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __RBGCOMPAT_H__ +#define __RBGCOMPAT_H__ + +G_BEGIN_DECLS + +G_END_DECLS + +#endif diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib.c new file mode 100644 index 0000000..ef84d36 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib.c @@ -0,0 +1,1157 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include +#include "rbgprivate.h" +#include "rbglib.h" + +#define RG_TARGET_NAMESPACE mGLib + +static ID id_inspect; + +VALUE RG_TARGET_NAMESPACE; + +const gchar * +rbg_rval2cstr(VALUE *str) +{ + StringValue(*str); + +#ifdef HAVE_RUBY_ENCODING_H + if (rb_enc_get(*str) != rb_utf8_encoding()) + *str = rb_str_export_to_enc(*str, rb_utf8_encoding()); +#endif + + return RSTRING_PTR(*str); +} + +const gchar * +rbg_rval_inspect(VALUE object) +{ + VALUE inspected = rb_funcall(object, id_inspect, 0); + + return RVAL2CSTR(inspected); +} + +char * +rbg_string_value_ptr(volatile VALUE *ptr) +{ + return rb_string_value_ptr(ptr); +} + +const gchar * +rbg_rval2cstr_accept_nil(VALUE *str) +{ + return NIL_P(*str) ? NULL : RVAL2CSTR(*str); +} + +/* TODO: How do we deal with encodings? */ +const gchar * +rbg_rval2cstr_accept_symbol(volatile VALUE *value) +{ + if (!SYMBOL_P(*value)) + return rbg_rval2cstr((VALUE *)value); + + return rb_id2name(SYM2ID(*value)); +} + +const gchar * +rbg_rval2cstr_accept_symbol_accept_nil(volatile VALUE *value) +{ + return NIL_P(*value) ? NULL : rbg_rval2cstr_accept_symbol(value); +} + +const gchar * +rbg_rval2glibid(volatile VALUE *value, volatile VALUE *buf, gboolean accept_nil) +{ + gchar *id, *p; + + if (accept_nil && NIL_P(*value)) + return NULL; + + if (SYMBOL_P(*value)) { + *buf = rb_String(*value); + } else { + StringValue(*value); + *buf = rb_str_dup(*value); + } + RB_GC_GUARD(*buf); + + id = RSTRING_PTR(*buf); + for (p = id; *p; p++) + if (*p == '_') + *p = '-'; + + return id; +} + +VALUE +rbg_cstr2rval(const gchar *str) +{ + return str != NULL ? CSTR2RVAL_LEN(str, strlen(str)) : Qnil; +} + +VALUE +rbg_cstr2rval_len(const gchar *str, gsize len) +{ + if (str == NULL) + return Qnil; + +#ifdef HAVE_RUBY_ENCODING_H + return rb_external_str_new_with_enc(str, len, rb_utf8_encoding()); +#else + return rb_str_new(str, len); +#endif +} + +struct rbg_cstr2rval_len_free_args { + gchar *str; + gsize len; +}; + +static VALUE +rbg_cstr2rval_len_free_body(VALUE value) +{ + struct rbg_cstr2rval_len_free_args *args = (struct rbg_cstr2rval_len_free_args *)value; + + return CSTR2RVAL_LEN(args->str, args->len); +} + +static VALUE +rbg_cstr2rval_len_free_ensure(VALUE str) +{ + g_free((gchar *)str); + + return Qnil; +} + +VALUE +rbg_cstr2rval_len_free(gchar *str, gsize len) +{ + struct rbg_cstr2rval_len_free_args args = { str, len }; + + return str != NULL ? rb_ensure(rbg_cstr2rval_len_free_body, (VALUE)&args, + rbg_cstr2rval_len_free_ensure, (VALUE)str) : Qnil; +} + +VALUE +rbg_cstr2rval_with_encoding(const gchar *str, const gchar *encoding) +{ + return str != NULL ? CSTR2RVAL_LEN_ENC(str, strlen(str), encoding) : Qnil; +} + +#ifdef HAVE_RUBY_ENCODING_H +VALUE +rbg_cstr2rval_len_with_encoding(const gchar *str, gsize len, + const gchar *encoding) +{ + if (str == NULL) + return Qnil; + + return rb_external_str_new_with_enc(str, len, + encoding != NULL ? + rb_enc_find(encoding) : + rb_utf8_encoding()); +} +#else +VALUE +rbg_cstr2rval_len_with_encoding(const gchar *str, gsize len, + G_GNUC_UNUSED const gchar *encoding) +{ + if (str == NULL) + return Qnil; + + return rb_str_new(str, len); +} +#endif + +static VALUE +rbg_cstr2rval_free_body(VALUE str) +{ + return CSTR2RVAL((const gchar *)str); +} + +static VALUE +rbg_cstr2rval_free_ensure(VALUE str) +{ + g_free((gchar *)str); + + return Qnil; +} + +VALUE +rbg_cstr2rval_free(gchar *str) +{ + return str != NULL? rb_ensure(rbg_cstr2rval_free_body, (VALUE)str, + rbg_cstr2rval_free_ensure, (VALUE)str) : Qnil; +} + +/* just for backward compatibility. */ +VALUE +rbg_cstr2rval_with_free(gchar *str) +{ + return rbg_cstr2rval_free(str); +} + +#ifdef HAVE_RUBY_ENCODING_H +static rb_encoding *filename_encoding_if_not_utf8; +#endif + +#ifdef HAVE_RUBY_ENCODING_H +static VALUE +rbg_filename_to_ruby_body(VALUE filename) +{ + const gchar *filename_utf8 = (const gchar *)filename; + VALUE rb_filename; + + rb_filename = rb_external_str_new_with_enc(filename_utf8, + strlen(filename_utf8), + rb_utf8_encoding()); + + /* if needed, change encoding of Ruby String to filename encoding, so that + upcoming File operations will work properly */ + return filename_encoding_if_not_utf8 != NULL ? + rb_str_export_to_enc(rb_filename, filename_encoding_if_not_utf8) : + rb_filename; +} + +static VALUE +rbg_filename_to_ruby_ensure(VALUE filename) +{ + g_free((gchar *)filename); + + return Qnil; +} +#endif + +VALUE +rbg_filename_to_ruby(const gchar *filename) +{ +#ifdef HAVE_RUBY_ENCODING_H + gchar *filename_utf8; + gsize written; + GError *error = NULL; + + if (filename == NULL) + return Qnil; + + if (filename_encoding_if_not_utf8 == NULL) + return CSTR2RVAL(filename); + + filename_utf8 = g_filename_to_utf8(filename, -1, NULL, &written, &error); + if (error != NULL) + RAISE_GERROR(error); + + return rb_ensure(rbg_filename_to_ruby_body, (VALUE)filename_utf8, + rbg_filename_to_ruby_ensure, (VALUE)filename_utf8); +#else + return CSTR2RVAL(filename); +#endif +} + +VALUE +rbg_filename_to_ruby_free(gchar *filename) +{ +#ifdef HAVE_RUBY_ENCODING_H + gchar *filename_utf8; + gsize written; + + if (filename == NULL) + return Qnil; + + /* convert filename to UTF-8 if needed */ + if (filename_encoding_if_not_utf8 != NULL) { + GError *error = NULL; + + filename_utf8 = g_filename_to_utf8(filename, -1, NULL, &written, &error); + g_free(filename); + if (error != NULL) + RAISE_GERROR(error); + } else { + filename_utf8 = filename; + } + + return rb_ensure(rbg_filename_to_ruby_body, (VALUE)filename_utf8, + rbg_filename_to_ruby_ensure, (VALUE)filename_utf8); +#else + return CSTR2RVAL_FREE(filename); +#endif +} + +gchar * +rbg_filename_from_ruby(VALUE filename) +{ +#ifdef HAVE_RUBY_ENCODING_H + gchar *retval; + gsize written; + GError *error = NULL; + + /* if needed, change encoding of Ruby String to UTF-8 */ + StringValue(filename); + if (rb_enc_get(filename) != rb_utf8_encoding()) + filename = rb_str_export_to_enc(filename, rb_utf8_encoding()); + + /* convert it to filename encoding if needed */ + if (filename_encoding_if_not_utf8 == NULL) + return g_strdup(RSTRING_PTR(filename)); + + retval = g_filename_from_utf8(RSTRING_PTR(filename), -1, NULL, &written, &error); + if (error != NULL) + RAISE_GERROR(error); + + return retval; +#else + return g_strdup(RVAL2CSTR(filename)); +#endif +} + +struct rval2strv_args { + VALUE ary; + long n; + const gchar **result; +}; + +static VALUE +rbg_rval2strv_body(VALUE value) +{ + long i; + struct rval2strv_args *args = (struct rval2strv_args *)value; + + for (i = 0; i < args->n; i++) + args->result[i] = RVAL2CSTR(RARRAY_PTR(args->ary)[i]); + args->result[args->n] = NULL; + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbg_rval2strv_rescue(VALUE value) +{ + g_free(((struct rval2strv_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +const gchar ** +rbg_rval2strv(volatile VALUE *value, long *n) +{ + struct rval2strv_args args; + + args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value)); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(const gchar *, args.n + 1); + + rb_rescue(rbg_rval2strv_body, (VALUE)&args, + rbg_rval2strv_rescue, (VALUE)&args); + + if (n != NULL) + *n = args.n; + + return args.result; +} + +const gchar ** +rbg_rval2strv_accept_nil(volatile VALUE *value, long *n) +{ + if (!NIL_P(*value)) + return rbg_rval2strv(value, n); + + if (n != NULL) + *n = 0; + + return NULL; +} + +struct rval2strv_dup_args { + VALUE ary; + long n; + gchar **result; +}; + +static VALUE +rbg_rval2strv_dup_body(VALUE value) +{ + long i; + struct rval2strv_dup_args *args = (struct rval2strv_dup_args *)value; + + for (i = 0; i < args->n; i++) + args->result[i] = g_strdup(RVAL2CSTR(RARRAY_PTR(args->ary)[i])); + args->result[args->n] = NULL; + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbg_rval2strv_dup_rescue(VALUE value) +{ + g_free(((struct rval2strv_dup_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +gchar ** +rbg_rval2strv_dup(volatile VALUE *value, long *n) +{ + struct rval2strv_dup_args args; + + args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value)); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(gchar *, args.n + 1); + + rb_rescue(rbg_rval2strv_dup_body, (VALUE)&args, + rbg_rval2strv_dup_rescue, (VALUE)&args); + + if (n != NULL) + *n = args.n; + + return args.result; +} + +gchar ** +rbg_rval2strv_dup_accept_nil(volatile VALUE *value, long *n) +{ + if (!NIL_P(*value)) + rbg_rval2strv_dup(value, n); + + if (n != NULL) + *n = 0; + + return NULL; +} + +VALUE +rbg_strv2rval(const gchar **strings) +{ + VALUE ary; + const gchar **p; + + if (strings == NULL) + return Qnil; + + ary = rb_ary_new(); + for (p = strings; *p != NULL; p++) + rb_ary_push(ary, CSTR2RVAL(*p)); + + return ary; +} + +static VALUE +rbg_strv2rval_free_body(VALUE strings) +{ + return STRV2RVAL((const gchar **)strings); +} + +static VALUE +rbg_strv2rval_free_ensure(VALUE strings) +{ + g_strfreev((gchar **)strings); + + return Qnil; +} + +VALUE +rbg_strv2rval_free(gchar **strings) +{ + return rb_ensure(rbg_strv2rval_free_body, (VALUE)strings, + rbg_strv2rval_free_ensure, (VALUE)strings); +} + +struct rbg_rval2gbooleans_args { + VALUE ary; + long n; + gboolean *result; +}; + +static VALUE +rbg_rval2gbooleans_body(VALUE value) +{ + long i; + struct rbg_rval2gbooleans_args *args = (struct rbg_rval2gbooleans_args *)value; + + for (i = 0; i < args->n; i++) + args->result[i] = RVAL2CBOOL(RARRAY_PTR(args->ary)[i]); + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbg_rval2gbooleans_rescue(VALUE value) +{ + g_free(((struct rbg_rval2gbooleans_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +gboolean * +rbg_rval2gbooleans(volatile VALUE *value, long *n) +{ + struct rbg_rval2gbooleans_args args; + + args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value)); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(gboolean, args.n + 1); + + rb_rescue(rbg_rval2gbooleans_body, (VALUE)&args, + rbg_rval2gbooleans_rescue, (VALUE)&args); + + *n = args.n; + + return args.result; +} + +struct rbg_rval2gints_args { + VALUE ary; + long n; + gint *result; +}; + +static VALUE +rbg_rval2gints_body(VALUE value) +{ + long i; + struct rbg_rval2gints_args *args = (struct rbg_rval2gints_args *)value; + + for (i = 0; i < args->n; i++) + args->result[i] = NUM2INT(RARRAY_PTR(args->ary)[i]); + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbg_rval2gints_rescue(VALUE value) +{ + g_free(((struct rbg_rval2gints_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +gint * +rbg_rval2gints(volatile VALUE *value, long *n) +{ + struct rbg_rval2gints_args args; + + args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value)); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(gint, args.n + 1); + + rb_rescue(rbg_rval2gints_body, (VALUE)&args, + rbg_rval2gints_rescue, (VALUE)&args); + + *n = args.n; + + return args.result; +} + +struct rbg_rval2gint8s_args { + VALUE ary; + long n; + gint8 *result; +}; + +static VALUE +rbg_rval2gint8s_body(VALUE value) +{ + long i; + struct rbg_rval2gint8s_args *args = (struct rbg_rval2gint8s_args *)value; + + for (i = 0; i < args->n; i++) + args->result[i] = NUM2CHR(RARRAY_PTR(args->ary)[i]); + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbg_rval2gint8s_rescue(VALUE value) +{ + g_free(((struct rbg_rval2gint8s_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +gint8 * +rbg_rval2gint8s(volatile VALUE *value, long *n) +{ + struct rbg_rval2gint8s_args args; + + args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value)); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(gint8, args.n + 1); + + rb_rescue(rbg_rval2gint8s_body, (VALUE)&args, + rbg_rval2gint8s_rescue, (VALUE)&args); + + *n = args.n; + + return args.result; +} + +struct rbg_rval2guint8s_args { + VALUE ary; + long n; + guint8 *result; +}; + +static VALUE +rbg_rval2guint8s_body(VALUE value) +{ + long i; + struct rbg_rval2guint8s_args *args = (struct rbg_rval2guint8s_args *)value; + + for (i = 0; i < args->n; i++) + args->result[i] = NUM2UINT(RARRAY_PTR(args->ary)[i]); + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbg_rval2guint8s_rescue(VALUE value) +{ + g_free(((struct rbg_rval2guint8s_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +guint8 * +rbg_rval2guint8s(volatile VALUE *value, long *n) +{ + struct rbg_rval2guint8s_args args; + + args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value)); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(guint8, args.n + 1); + + rb_rescue(rbg_rval2guint8s_body, (VALUE)&args, + rbg_rval2guint8s_rescue, (VALUE)&args); + + *n = args.n; + + return args.result; +} + +struct rbg_rval2guint16s_args { + VALUE ary; + long n; + guint16 *result; +}; + +static VALUE +rbg_rval2guint16s_body(VALUE value) +{ + long i; + struct rbg_rval2guint16s_args *args = (struct rbg_rval2guint16s_args *)value; + + for (i = 0; i < args->n; i++) + args->result[i] = NUM2UINT(RARRAY_PTR(args->ary)[i]); + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbg_rval2guint16s_rescue(VALUE value) +{ + g_free(((struct rbg_rval2guint16s_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +guint16 * +rbg_rval2guint16s(volatile VALUE *value, long *n) +{ + struct rbg_rval2guint16s_args args; + + args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value)); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(guint16, args.n + 1); + + rb_rescue(rbg_rval2guint16s_body, (VALUE)&args, + rbg_rval2guint16s_rescue, (VALUE)&args); + + *n = args.n; + + return args.result; +} + +struct rbg_rval2guint32s_args { + VALUE ary; + long n; + guint32 *result; +}; + +static VALUE +rbg_rval2guint32s_body(VALUE value) +{ + long i; + struct rbg_rval2guint32s_args *args = (struct rbg_rval2guint32s_args *)value; + + for (i = 0; i < args->n; i++) + args->result[i] = NUM2UINT(RARRAY_PTR(args->ary)[i]); + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbg_rval2guint32s_rescue(VALUE value) +{ + g_free(((struct rbg_rval2guint32s_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +guint32 * +rbg_rval2guint32s(volatile VALUE *value, long *n) +{ + struct rbg_rval2guint32s_args args; + + args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value)); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(guint32, args.n + 1); + + rb_rescue(rbg_rval2guint32s_body, (VALUE)&args, + rbg_rval2guint32s_rescue, (VALUE)&args); + + *n = args.n; + + return args.result; +} + +struct rbg_rval2gdoubles_args { + VALUE ary; + long n; + gdouble *result; +}; + +static VALUE +rbg_rval2gdoubles_body(VALUE value) +{ + long i; + struct rbg_rval2gdoubles_args *args = (struct rbg_rval2gdoubles_args *)value; + + for (i = 0; i < args->n; i++) + args->result[i] = NUM2DBL(RARRAY_PTR(args->ary)[i]); + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbg_rval2gdoubles_rescue(VALUE value) +{ + g_free(((struct rbg_rval2gdoubles_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +gdouble * +rbg_rval2gdoubles(volatile VALUE *value, long *n) +{ + struct rbg_rval2gdoubles_args args; + + args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value)); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(gdouble, args.n + 1); + + rb_rescue(rbg_rval2gdoubles_body, (VALUE)&args, + rbg_rval2gdoubles_rescue, (VALUE)&args); + + *n = args.n; + + return args.result; +} + +VALUE +rbg_gints2rval(const gint *gints, long n) +{ + long i; + VALUE ary = rb_ary_new(); + + for (i = 0; i < n; i++) + rb_ary_push(ary, INT2NUM(gints[i])); + + return ary; +} + +struct rbg_gints2rval_free_args { + gint *gints; + long n; +}; + +static VALUE +rbg_gints2rval_free_body(VALUE value) +{ + struct rbg_gints2rval_free_args *args = (struct rbg_gints2rval_free_args *)value; + + return rbg_gints2rval(args->gints, args->n); +} + +static VALUE +rbg_gints2rval_free_ensure(VALUE value) +{ + g_free(((struct rbg_gints2rval_free_args *)value)->gints); + + return Qnil; +} + +VALUE +rbg_gints2rval_free(gint *gints, long n) +{ + struct rbg_gints2rval_free_args args = { gints, n }; + + return rb_ensure(rbg_gints2rval_free_body, (VALUE)&args, + rbg_gints2rval_free_ensure, (VALUE)&args); +} + +static const char * +rbg_inspect (VALUE object) +{ + VALUE inspected; + + inspected = rb_funcall(object, rb_intern("inspect"), 0); + return StringValueCStr(inspected); +} + +VALUE +rbg_to_array (VALUE object) +{ + return rb_convert_type(object, RUBY_T_ARRAY, "Array", "to_ary"); +} + +VALUE +rbg_to_hash (VALUE object) +{ + return rb_convert_type(object, RUBY_T_HASH, "Hash", "to_hash"); +} + +VALUE +rbg_check_array_type (VALUE object) +{ +#ifdef HAVE_RB_CHECK_ARRAY_TYPE + return rb_check_array_type(object); +#else + return rb_check_convert_type(object, RUBY_T_ARRAY, "Array", "to_ary"); +#endif +} + +VALUE +rbg_check_hash_type (VALUE object) +{ +#ifdef HAVE_RB_CHECK_HASH_TYPE + return rb_check_hash_type(object); +#else + return rb_check_convert_type(object, RUBY_T_HASH, "Hash", "to_hash"); +#endif +} + +void +rbg_scan_options (VALUE options, ...) +{ + VALUE original_options = options; + VALUE available_keys; + const char *key; + VALUE *value; + va_list args; + + options = rbg_check_hash_type(options); + if (NIL_P(options)) { + options = rb_hash_new(); + } else if (options == original_options) { + options = rb_funcall(options, rb_intern("dup"), 0); + } + + available_keys = rb_ary_new(); + va_start(args, options); + key = va_arg(args, const char *); + while (key) { + VALUE rb_key; + value = va_arg(args, VALUE *); + + rb_key = ID2SYM(rb_intern(key)); + rb_ary_push(available_keys, rb_key); + *value = rb_funcall(options, rb_intern("delete"), 1, rb_key); + + key = va_arg(args, const char *); + } + va_end(args); + + if (RVAL2CBOOL(rb_funcall(options, rb_intern("empty?"), 0))) + return; + + rb_raise(rb_eArgError, + "unexpected key(s) exist: %s: available keys: %s", + rbg_inspect(rb_funcall(options, rb_intern("keys"), 0)), + rbg_inspect(available_keys)); +} + +#if 0 +/* +2004-04-15 Commented out by Masao. + +These functions replace g_malloc/g_realloc/g_free of GLib. +When g_malloc is called and the memory area can not reserved, +rb_gc() will be called. It makes Ruby-GNOME2 uses memory efficiently. + +But rb_gc() does not work under multithread. +So they occur "cross-thread violation". +*/ + +static gpointer +my_malloc(gsize n_bytes) +{ + /* Should we rescue NoMemoryError? */ + return ruby_xmalloc(n_bytes); +} + +static gpointer +my_realloc(gpointer mem, gsize n_bytes) +{ + /* Should we rescue NoMemoryError? */ + return ruby_xrealloc(mem, n_bytes); +} + +static void +my_free(gpointer mem) +{ + return ruby_xfree(mem); +} + +static void +Init_mem() +{ + GMemVTable mem_table = { + my_malloc, + my_realloc, + my_free, + NULL, + NULL, + NULL, + }; + g_mem_set_vtable(&mem_table); +} +#endif + +static VALUE +rg_s_os_win32_p(G_GNUC_UNUSED VALUE self) +{ +#ifdef G_OS_WIN32 + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +rg_s_os_beos_p(G_GNUC_UNUSED VALUE self) +{ +#ifdef G_OS_BEOS + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +rg_s_os_unix_p(G_GNUC_UNUSED VALUE self) +{ +#ifdef G_OS_UNIX + return Qtrue; +#else + return Qfalse; +#endif +} + +extern void Init_glib2(void); + +void +Init_glib2(void) +{ +#ifdef HAVE_RUBY_ENCODING_H + const gchar **filename_charsets; +#endif + + id_inspect = rb_intern("inspect"); + + RG_TARGET_NAMESPACE = rb_define_module("GLib"); + + setlocale (LC_CTYPE, ""); +#ifdef LC_MESSAGES + setlocale (LC_MESSAGES, ""); +#endif + + /* Version Information */ + rb_define_const(RG_TARGET_NAMESPACE, "VERSION", + rb_ary_new3(3, + INT2FIX(glib_major_version), + INT2FIX(glib_minor_version), + INT2FIX(glib_micro_version))); + rb_define_const(RG_TARGET_NAMESPACE, "MAJOR_VERSION", INT2FIX(glib_major_version)); + rb_define_const(RG_TARGET_NAMESPACE, "MINOR_VERSION", INT2FIX(glib_minor_version)); + rb_define_const(RG_TARGET_NAMESPACE, "MICRO_VERSION", INT2FIX(glib_micro_version)); + rb_define_const(RG_TARGET_NAMESPACE, "INTERFACE_AGE", INT2FIX(glib_interface_age)); + rb_define_const(RG_TARGET_NAMESPACE, "BINARY_AGE", INT2FIX(glib_binary_age)); + + rb_define_const(RG_TARGET_NAMESPACE, "BINDING_VERSION", + rb_ary_new3(3, + INT2FIX(RBGLIB_MAJOR_VERSION), + INT2FIX(RBGLIB_MINOR_VERSION), + INT2FIX(RBGLIB_MICRO_VERSION))); + + rb_define_const(RG_TARGET_NAMESPACE, "BUILD_VERSION", + rb_ary_new3(3, + INT2FIX(GLIB_MAJOR_VERSION), + INT2FIX(GLIB_MINOR_VERSION), + INT2FIX(GLIB_MICRO_VERSION))); + + /* Limits of Basic Types */ + rb_define_const(RG_TARGET_NAMESPACE, "MININT", INT2FIX(G_MININT)); + rb_define_const(RG_TARGET_NAMESPACE, "MAXINT", INT2NUM(G_MAXINT)); + rb_define_const(RG_TARGET_NAMESPACE, "MAXUINT", UINT2NUM(G_MAXUINT)); + + rb_define_const(RG_TARGET_NAMESPACE, "MINSHORT", INT2FIX(G_MINSHORT)); + rb_define_const(RG_TARGET_NAMESPACE, "MAXSHORT", INT2FIX(G_MAXSHORT)); + rb_define_const(RG_TARGET_NAMESPACE, "MAXUSHORT", UINT2NUM(G_MAXUSHORT)); + + rb_define_const(RG_TARGET_NAMESPACE, "MINLONG", INT2FIX(G_MINLONG)); + rb_define_const(RG_TARGET_NAMESPACE, "MAXLONG", INT2NUM(G_MAXLONG)); + rb_define_const(RG_TARGET_NAMESPACE, "MAXULONG", UINT2NUM(G_MAXULONG)); + +#if GLIB_CHECK_VERSION(2,4,0) + rb_define_const(RG_TARGET_NAMESPACE, "MININT8", INT2FIX(G_MININT8)); + rb_define_const(RG_TARGET_NAMESPACE, "MAXINT8", INT2FIX(G_MAXINT8)); + rb_define_const(RG_TARGET_NAMESPACE, "MAXUINT8", UINT2NUM(G_MAXUINT8)); + + rb_define_const(RG_TARGET_NAMESPACE, "MININT16", INT2FIX(G_MININT16)); + rb_define_const(RG_TARGET_NAMESPACE, "MAXINT16", INT2FIX(G_MAXINT16)); + rb_define_const(RG_TARGET_NAMESPACE, "MAXUINT16", UINT2NUM(G_MAXUINT16)); + + rb_define_const(RG_TARGET_NAMESPACE, "MININT32", INT2FIX(G_MININT32)); + rb_define_const(RG_TARGET_NAMESPACE, "MAXINT32", INT2NUM(G_MAXINT32)); + rb_define_const(RG_TARGET_NAMESPACE, "MAXUINT32", UINT2NUM(G_MAXUINT32)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "MININT64", INT2FIX(G_MININT64)); + rb_define_const(RG_TARGET_NAMESPACE, "MAXINT64", LL2NUM(G_MAXINT64)); + rb_define_const(RG_TARGET_NAMESPACE, "MAXUINT64", ULL2NUM(G_MAXUINT64)); +#if GLIB_CHECK_VERSION(2,4,0) + rb_define_const(RG_TARGET_NAMESPACE, "MAXSIZE", UINT2NUM(G_MAXSIZE)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "MINFLOAT", INT2FIX(G_MINFLOAT)); + rb_define_const(RG_TARGET_NAMESPACE, "MAXFLOAT", DBL2NUM(G_MAXFLOAT)); + + rb_define_const(RG_TARGET_NAMESPACE, "MINDOUBLE", INT2FIX(G_MINDOUBLE)); + rb_define_const(RG_TARGET_NAMESPACE, "MAXDOUBLE", DBL2NUM(G_MAXDOUBLE)); + + /* Standard Macros */ + RG_DEF_SMETHOD_P(os_win32, 0); + RG_DEF_SMETHOD_P(os_beos, 0); + RG_DEF_SMETHOD_P(os_unix, 0); + + rb_define_const(RG_TARGET_NAMESPACE, "DIR_SEPARATOR", CSTR2RVAL(G_DIR_SEPARATOR_S)); + rb_define_const(RG_TARGET_NAMESPACE, "SEARCHPATH_SEPARATOR", CSTR2RVAL(G_SEARCHPATH_SEPARATOR_S)); + + /* discover and store glib filename encoding */ +#ifdef HAVE_RUBY_ENCODING_H + if (g_get_filename_charsets(&filename_charsets) + || filename_charsets == NULL + || filename_charsets[0] == NULL + || !strcmp(filename_charsets[0], "UTF-8") + || rb_enc_find(filename_charsets[0]) == rb_enc_find("ASCII-8BIT")) { + /* set to NULL, mean do not perform transcoding, either filename + encoding is unknown, UTF-8, or unsupported */ + filename_encoding_if_not_utf8 = NULL; + } else { + filename_encoding_if_not_utf8 = rb_enc_find(filename_charsets[0]); + } +#endif + +/* Don't implement them. +#define G_DIR_SEPARATOR_S +#define G_IS_DIR_SEPARATOR (c) +#define G_SEARCHPATH_SEPARATOR +#define TRUE +#define FALSE +#define NULL +#define MIN (a, b) +#define MAX (a, b) +#define ABS (a) +#define CLAMP (x, low, high) +#define G_STRUCT_MEMBER (member_type, struct_p, struct_offset) +#define G_STRUCT_MEMBER_P (struct_p, struct_offset) +#define G_STRUCT_OFFSET (struct_type, member) +#define G_MEM_ALIGN +#define G_CONST_RETURN +*/ + + /* Numerical Definitions */ +/* Don't implement them. +#define G_IEEE754_FLOAT_BIAS +#define G_IEEE754_DOUBLE_BIAS +union GFloatIEEE754; +union GDoubleIEEE754; +*/ + rb_define_const(RG_TARGET_NAMESPACE, "E", CSTR2RVAL(G_STRINGIFY(G_E))); + rb_define_const(RG_TARGET_NAMESPACE, "LN2", CSTR2RVAL(G_STRINGIFY(G_LN2))); + rb_define_const(RG_TARGET_NAMESPACE, "LN10", CSTR2RVAL(G_STRINGIFY(G_LN10))); + rb_define_const(RG_TARGET_NAMESPACE, "PI", CSTR2RVAL(G_STRINGIFY(G_PI))); + rb_define_const(RG_TARGET_NAMESPACE, "PI_2", CSTR2RVAL(G_STRINGIFY(G_PI_2))); + rb_define_const(RG_TARGET_NAMESPACE, "PI_4", CSTR2RVAL(G_STRINGIFY(G_PI_4))); + rb_define_const(RG_TARGET_NAMESPACE, "SQRT2", CSTR2RVAL(G_STRINGIFY(G_SQRT2))); + rb_define_const(RG_TARGET_NAMESPACE, "LOG_2_BASE_10", CSTR2RVAL(G_STRINGIFY(G_LOG_2_BASE_10))); + + /* From "The Main Event Loop" */ + rb_define_const(RG_TARGET_NAMESPACE, "PRIORITY_HIGH", INT2FIX(G_PRIORITY_HIGH)); + rb_define_const(RG_TARGET_NAMESPACE, "PRIORITY_DEFAULT", INT2FIX(G_PRIORITY_DEFAULT)); + rb_define_const(RG_TARGET_NAMESPACE, "PRIORITY_HIGH_IDLE", INT2FIX(G_PRIORITY_HIGH_IDLE)); + rb_define_const(RG_TARGET_NAMESPACE, "PRIORITY_DEFAULT_IDLE", INT2FIX(G_PRIORITY_DEFAULT_IDLE)); + rb_define_const(RG_TARGET_NAMESPACE, "PRIORITY_LOW", INT2FIX(G_PRIORITY_LOW)); + +/* Init_mem(); */ + Init_gutil(); + Init_gutil_callback(); + Init_glib_int64(); + Init_glib_error(); + Init_glib_threads(); + Init_glib_convert(); + Init_glib_messages(); + Init_glib_fileutils(); + Init_glib_i18n(); + Init_glib_win32(); + + Init_gobject(); + + /* Require GBoxed/GObject */ + Init_glib_utils(); + Init_glib_spawn(); + Init_glib_spawnerror(); + Init_glib_main_loop(); + Init_glib_source(); + Init_glib_main_context(); + Init_glib_poll_fd(); + Init_glib_io_constants(); + Init_glib_io_channel(); + Init_glib_io_channelerror(); + Init_glib_io_channel_win32_socket(); + Init_glib_shell(); + Init_glib_shellerror(); + Init_glib_timer(); + Init_glib_unicode(); + Init_glib_utf8(); + Init_glib_utf16(); + Init_glib_ucs4(); + Init_glib_unichar(); + Init_glib_keyfile(); + Init_glib_bookmark_file(); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib.h b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib.h new file mode 100644 index 0000000..195a25b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib.h @@ -0,0 +1,201 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011-2013 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Ruby-GNOME2 Project + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include +#include "ruby.h" + +#include "rbglibdeprecated.h" +#include "rbglib2conversions.h" + +#ifndef __RBGLIB_H__ +#define __RBGLIB_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define RBGLIB_MAJOR_VERSION 2 +#define RBGLIB_MINOR_VERSION 0 +#define RBGLIB_MICRO_VERSION 2 + +#ifndef RSTRING_PTR +# define RSTRING_PTR(s) (RSTRING(s)->ptr) +# define RSTRING_LEN(s) (RSTRING(s)->len) +#endif + +#ifndef RARRAY_PTR +# define RARRAY_PTR(s) (RARRAY(s)->ptr) +# define RARRAY_LEN(s) (RARRAY(s)->len) +#endif + +#ifndef DBL2NUM +# define DBL2NUM(v) (rb_float_new(v)) +#endif + +#if ! GLIB_CHECK_VERSION(2,4,0) +typedef int GPid; +#endif + +#ifndef G_SOURCE_REMOVE +# define G_SOURCE_REMOVE FALSE +#endif + +#ifndef G_SOURCE_CONTINUE +# define G_SOURCE_CONTINUE TRUE +#endif + +#define RBG_INSPECT(object) (rbg_rval_inspect(object)) + +#define RVAL2CSTR(v) (rbg_rval2cstr(&(v))) +#define RVAL2CSTR_ACCEPT_NIL(v) (rbg_rval2cstr_accept_nil(&(v))) +#define RVAL2CSTR2(v) (RVAL2CSTR_ACCEPT_NIL(v)) +#define RVAL2CSTR_ACCEPT_SYMBOL(v) (rbg_rval2cstr_accept_symbol(&(v))) +#define RVAL2CSTR_ACCEPT_SYMBOL_ACCEPT_NIL(v) (rbg_rval2cstr_accept_symbol_accept_nil(&(v))) +#define RVAL2GLIBID(v, buf) (rbg_rval2glibid(&(v), &(buf), FALSE)) +#define RVAL2GLIBID_ACCEPT_NIL(v, buf) (rbg_rval2glibid(&(v), &(buf), TRUE)) +#define CSTR2RVAL(s) (rbg_cstr2rval(s)) +#define CSTR2RVAL_LEN(s, l) (rbg_cstr2rval_len(s, l)) +#define CSTR2RVAL_LEN_FREE(s, l) (rbg_cstr2rval_len_free(s, l)) +#define CSTR2RVAL_ENC(s, e) (rbg_cstr2rval_with_encoding(s, e)) +#define CSTR2RVAL_LEN_ENC(s, l, e) (rbg_cstr2rval_len_with_encoding(s, l, e)) +#define CSTR2RVAL_FREE(s) (rbg_cstr2rval_free(s)) +#define CSTR2RVAL2(s) (CSTR2RVAL_FREE(s)) + +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +# define CSTR2RVAL_LEN_UCS4(s, l) (CSTR2RVAL_LEN_ENC(s, l, "UTF-32LE")) +# define CSTR2RVAL_LEN_UTF16(s, l) (CSTR2RVAL_LEN_ENC(s, l, "UTF-16LE")) +#else +# define CSTR2RVAL_LEN_UCS4(s, l) (CSTR2RVAL_LEN_ENC(s, l, "UTF-32BE")) +# define CSTR2RVAL_LEN_UTF16(s, l) (CSTR2RVAL_LEN_ENC(s, l, "UTF-16BE")) +#endif + +#define RVAL2CSTRFILENAME(v) (rbg_filename_from_ruby(v)) +#define CSTRFILENAME2RVAL(s) (rbg_filename_to_ruby(s)) +#define CSTRFILENAME2RVAL_FREE(s) (rbg_filename_to_ruby_free(s)) + +#define RVAL2STRS(ary, n) rbg_rval2strv(&(ary), &(n)) +#define RVAL2STRS_ACCEPT_NIL(ary, n) rbg_rval2strv_accept_nil(&(ary), &(n)) +#define RVAL2STRV(ary) rbg_rval2strv(&(ary), NULL) +#define RVAL2STRV_ACCEPT_NIL(ary) rbg_rval2strv_accept_nil(&(ary), NULL) +#define RVAL2STRS_DUP(ary, n) rbg_rval2strv_dup(&(ary), &(n)) +#define RVAL2STRS_DUP_ACCEPT_NIL(ary, n) rbg_rval2strv_dup_accept_nil(&(ary), &(n)) +#define RVAL2STRV_DUP(ary) rbg_rval2strv_dup(&(ary), NULL) +#define RVAL2STRV_DUP_ACCEPT_NIL(ary) rbg_rval2strv_dup_accept_nil(&(ary), NULL) + +#define STRV2RVAL(strings) rbg_strv2rval(strings) +#define STRV2RVAL_FREE(strings) rbg_strv2rval_free(strings) + +#define RVAL2GBOOLEANS(ary, n) rbg_rval2gbooleans(&(ary), &(n)) +#define RVAL2GINTS(ary, n) rbg_rval2gints(&(ary), &(n)) +#define RVAL2GINT8S(ary, n) rbg_rval2gint8s(&(ary), &(n)) +#define RVAL2GUINT8S(ary, n) rbg_rval2guint8s(&(ary), &(n)) +#define RVAL2GUINT16S(ary, n) rbg_rval2guint16s(&(ary), &(n)) +#define RVAL2GUINT32S(ary, n) rbg_rval2guint32s(&(ary), &(n)) +#define RVAL2GDOUBLES(ary, n) rbg_rval2gdoubles(&(ary), &(n)) + +#define GINTS2RVAL(ary, n) rbg_gints2rval(ary, n) +#define GINTS2RVAL_FREE(ary, n) rbg_gints2rval(ary, n) + +#define CBOOL2RVAL(b) ((b) ? Qtrue : Qfalse) +#define RVAL2CBOOL(b) (RTEST(b)) +#define GERROR2RVAL(error) (rbgerr_gerror2exception(error)) +#define RG_RAISE_ERROR(error) rb_exc_raise(GERROR2RVAL(error)) +#define RAISE_GERROR(error) RG_RAISE_ERROR(error) /* deprecated */ +#define G_DEF_ERROR(domain, name, module, parent, gtype) \ + rbgerr_define_gerror(domain, name, module, parent, gtype) +#define G_DEF_ERROR2(domain, name, module, parent) \ + rbgerr_define_gerror(domain, name, module, parent, Qnil) + +#if defined(G_PLATFORM_WIN32) && !defined(RUBY_GLIB2_STATIC_COMPILATION) +# ifdef RUBY_GLIB2_COMPILATION +# define RUBY_GLIB2_VAR __declspec(dllexport) +# else +# define RUBY_GLIB2_VAR extern __declspec(dllimport) +# endif +#else +# define RUBY_GLIB2_VAR extern +#endif + +RUBY_GLIB2_VAR VALUE mGLib; + +extern const gchar *rbg_rval_inspect(VALUE object); + +extern gchar* rbg_string_value_ptr(volatile VALUE* ptr); /* no longer used */ +extern const gchar *rbg_rval2cstr(VALUE *str); +extern const gchar *rbg_rval2cstr_accept_nil(VALUE *str); +extern const gchar *rbg_rval2cstr_accept_symbol(volatile VALUE *value); +extern const gchar *rbg_rval2cstr_accept_symbol_accept_nil(volatile VALUE *value); +extern const gchar *rbg_rval2glibid(volatile VALUE *value, volatile VALUE *buf, gboolean accept_nil); + +extern VALUE rbg_cstr2rval(const gchar* str); +extern VALUE rbg_cstr2rval_len(const gchar* str, gsize len); +extern VALUE rbg_cstr2rval_len_free(gchar *str, gsize len); +extern VALUE rbg_cstr2rval_with_encoding(const gchar* str, + const gchar *encoding); +extern VALUE rbg_cstr2rval_len_with_encoding(const gchar* str, gsize len, + const gchar *encoding); +extern VALUE rbg_cstr2rval_free(gchar *str); +/* just for backward compatibility. */ +extern VALUE rbg_cstr2rval_with_free(gchar *str); + +VALUE rbg_filename_to_ruby(const gchar *filename); +extern VALUE rbg_filename_to_ruby_free(gchar *filename); +extern gchar *rbg_filename_from_ruby(VALUE filename); + +const gchar **rbg_rval2strv(volatile VALUE *value, long *n); +const gchar **rbg_rval2strv_accept_nil(volatile VALUE *value, long *n); +gchar **rbg_rval2strv_dup(volatile VALUE *value, long *n); +gchar **rbg_rval2strv_dup_accept_nil(volatile VALUE *value, long *n); +VALUE rbg_strv2rval(const gchar **strings); +VALUE rbg_strv2rval_free(gchar **strings); + +gboolean *rbg_rval2gbooleans(volatile VALUE *value, long *n); +gint *rbg_rval2gints(volatile VALUE *value, long *n); +gint8 *rbg_rval2gint8s(volatile VALUE *value, long *n); +guint8 *rbg_rval2guint8s(volatile VALUE *value, long *n); +guint16 *rbg_rval2guint16s(volatile VALUE *value, long *n); +guint32 *rbg_rval2guint32s(volatile VALUE *value, long *n); +gdouble *rbg_rval2gdoubles(volatile VALUE *value, long *n); + +VALUE rbg_gints2rval(const gint *gints, long n); +VALUE rbg_gints2rval_free(gint *gints, long n); + +extern VALUE rbg_to_array(VALUE object); +extern VALUE rbg_to_hash(VALUE object); +extern VALUE rbg_check_array_type(VALUE object); +extern VALUE rbg_check_hash_type(VALUE object); +extern void rbg_scan_options(VALUE options, ...); + +/* rbgerror.h */ +extern VALUE rbgerr_gerror2exception(GError *error); +extern VALUE rbgerr_define_gerror(GQuark domain, const gchar* name, VALUE module, VALUE parent, VALUE gtype); + +extern VALUE rbglib_int64_to_num(guint64 val); +extern VALUE rbglib_uint64_to_num(guint64 val); +extern gint64 rbglib_num_to_int64(VALUE val); +extern guint64 rbglib_num_to_uint64(VALUE val); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __RBGLIB_H__ */ diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib2conversions.h b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib2conversions.h new file mode 100644 index 0000000..3922dec --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib2conversions.h @@ -0,0 +1,55 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __GLIB2CONVERSIONS_H__ +#define __GLIB2CONVERSIONS_H__ + +#define RVAL2GPARAMSPEC(o) (G_PARAM_SPEC(RVAL2GOBJ(o))) + +#define RVAL2GCLOSURE(o) ((GClosure*)RVAL2BOXED(o, G_TYPE_CLOSURE)) +#define GCLOSURE2RVAL(o) (BOXED2RVAL(o, G_TYPE_CLOSURE)) +#define RVAL2GIOCHANNEL(o) ((GIOChannel*)RVAL2BOXED(o, G_TYPE_IO_CHANNEL)) +#define GIOCHANNEL2RVAL(o) (BOXED2RVAL(o, G_TYPE_IO_CHANNEL)) +#define RVAL2GKEYFILE(o) ((GKeyFile*)RVAL2BOXED(o, G_TYPE_KEY_FILE)) +#define GKEYFILE2RVAL(o) (BOXED2RVAL(o, G_TYPE_KEY_FILE)) +#define RVAL2GMAINCONTEXT(o) ((GMainContext*)RVAL2BOXED(o, G_TYPE_MAIN_CONTEXT)) +#define GMAINCONTEXT2RVAL(o) (BOXED2RVAL(o, G_TYPE_MAIN_CONTEXT)) +#define RVAL2GMAINLOOP(o) ((GMainLoop*)RVAL2BOXED(o, G_TYPE_MAIN_LOOP)) +#define GMAINLOOP2RVAL(o) (BOXED2RVAL(o, G_TYPE_MAIN_LOOP)) +#define RVAL2GPOLLFD(o) ((GPollFD*)RVAL2BOXED(o, G_TYPE_POLL_FD)) +#define GPOLLFD2RVAL(o) (BOXED2RVAL(o, G_TYPE_POLL_FD)) +#define RVAL2GSOURCE(o) ((GSource*)RVAL2BOXED(o, G_TYPE_SOURCE)) +#define GSOURCE2RVAL(o) (BOXED2RVAL(o, G_TYPE_SOURCE)) +#define RVAL2GTIMER(o) ((GTimer*)RVAL2BOXED(o, G_TYPE_TIMER)) +#define GTIMER2RVAL(o) (BOXED2RVAL(o, G_TYPE_TIMER)) +#define RVAL2GVALUE(o) ((GValue*)RVAL2BOXED(o, G_TYPE_VALUE)) +#define GVALUE2RVAL(o) (BOXED2RVAL(o, G_TYPE_VALUE)) + +#define RVAL2GIOCONDITION(o) (RVAL2GFLAGS(o, G_TYPE_IO_CONDITION)) +#define GIOCONDITION2RVAL(o) (GFLAGS2RVAL(o, G_TYPE_IO_CONDITION)) +#define RVAL2GNORMALIZEMODE(o) (RVAL2GENUM(o, G_TYPE_NORMALIZE_MODE)) +#define GNORMALIZEMODE2RVAL(o) (GENUM2RVAL(o, G_TYPE_NORMALIZE_MODE)) + +#define RVAL2GCONNECTFLAGS(o) (RVAL2GFLAGS(o, G_TYPE_CONNECT_FLAGS)) +#define GCONNECTFLAGS2RVAL(o) (GFLAGS2RVAL(o, G_TYPE_CONNECT_FLAGS)) +#define RVAL2GKEYFILEFLAGS(o) (RVAL2GFLAGS(o, G_TYPE_KEY_FILE_FLAGS)) +#define GKEYFILEFLAGS2RVAL(o) (GFLAGS2RVAL(o, G_TYPE_KEY_FILE_FLAGS)) + +#endif /* __GLIB2CONVERSIONS_H__ */ diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_bookmarkfile.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_bookmarkfile.c new file mode 100644 index 0000000..70cca08 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_bookmarkfile.c @@ -0,0 +1,551 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#if GLIB_CHECK_VERSION(2,12,0) +/************************************************/ +static GBookmarkFile* +bookmarkfile_copy(const GBookmarkFile* file) +{ +/* + GBookmarkFile* new_file; + g_return_val_if_fail (file != NULL, NULL); + new_file = g_key_file_new(); + *new_file = (GBookmarkFile*)*file; + return new_file; +*/ + return (GBookmarkFile*)file; +} + +static GType +g_bookmark_file_get_type(void) +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static("GBookmarkFile", + (GBoxedCopyFunc)bookmarkfile_copy, + (GBoxedFreeFunc)g_bookmark_file_free); + return our_type; +} +/************************************************/ + +#define G_TYPE_BOOKMARK_FILE (g_bookmark_file_get_type()) + +#define RG_TARGET_NAMESPACE cBookmarkFile +#define _SELF(self) ((GBookmarkFile*)(RVAL2BOXED(self, G_TYPE_BOOKMARK_FILE))) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, g_bookmark_file_new()); + return Qnil; +} + +static VALUE +rg_load_from_file(VALUE self, VALUE rbfilename) +{ + gchar *filename = RVAL2CSTRFILENAME(rbfilename); + GError* error = NULL; + gboolean ret = g_bookmark_file_load_from_file(_SELF(self), filename, &error); + g_free(filename); + if (!ret) + RAISE_GERROR(error); + + return self; +} + +static VALUE +rg_load_from_data(VALUE self, VALUE data) +{ + GError *error = NULL; + + StringValue(data); + if (!g_bookmark_file_load_from_data(_SELF(self), + RSTRING_PTR(data), + RSTRING_LEN(data), + &error)) + RAISE_GERROR(error); + + return Qnil; +} + +static VALUE +rg_load_from_data_dirs(VALUE self, VALUE file) +{ + GError* error = NULL; + gboolean ret; + gchar* full_path; + + ret = g_bookmark_file_load_from_data_dirs(_SELF(self), + RVAL2CSTR(file), + &full_path, &error); + + if (! ret) RAISE_GERROR(error); + + return full_path ? CSTR2RVAL(full_path) : Qnil; +} + +static VALUE +rg_to_data(VALUE self) +{ + GError* error = NULL; + gchar* data = g_bookmark_file_to_data(_SELF(self), NULL, &error); + + if (error) RAISE_GERROR(error); + + return CSTR2RVAL_FREE(data); +} + +static VALUE +rg_to_file(VALUE self, VALUE rbfilename) +{ + gchar *filename = RVAL2CSTRFILENAME(rbfilename); + GError* error = NULL; + gboolean ret = g_bookmark_file_to_file(_SELF(self), filename, &error); + g_free(filename); + if (!ret) + RAISE_GERROR(error); + + return self; +} + +static VALUE +rg_has_item_p(VALUE self, VALUE uri) +{ + return CBOOL2RVAL(g_bookmark_file_has_item(_SELF(self), + RVAL2CSTR(uri))); +} + +static VALUE +rg_has_group_p(VALUE self, VALUE uri, VALUE group) +{ + GError* error = NULL; + return CBOOL2RVAL(g_bookmark_file_has_group(_SELF(self), + RVAL2CSTR(uri), + RVAL2CSTR(group), + &error)); +} + +static VALUE +rg_has_application_p(VALUE self, VALUE uri, VALUE name) +{ + GError* error = NULL; + return CBOOL2RVAL(g_bookmark_file_has_application(_SELF(self), + RVAL2CSTR(uri), + RVAL2CSTR(name), + &error)); +} + +static VALUE +rg_size(VALUE self) +{ + return INT2NUM(g_bookmark_file_get_size(_SELF(self))); +} + +static VALUE +rg_uris(VALUE self) +{ + return STRV2RVAL_FREE(g_bookmark_file_get_uris(_SELF(self), NULL)); +} + +static VALUE +rg_get_title(VALUE self, VALUE uri) +{ + GError *error = NULL; + gchar* ret = g_bookmark_file_get_title(_SELF(self), + RVAL2CSTR(uri), + &error); + if (error) RAISE_GERROR(error); + return CSTR2RVAL_FREE(ret); +} + +static VALUE +rg_get_description(VALUE self, VALUE uri) +{ + GError *error = NULL; + gchar* ret = g_bookmark_file_get_description(_SELF(self), + RVAL2CSTR(uri), + &error); + if (error) RAISE_GERROR(error); + return CSTR2RVAL_FREE(ret); +} + +static VALUE +rg_get_mime_type(VALUE self, VALUE uri) +{ + GError *error = NULL; + gchar* ret = g_bookmark_file_get_mime_type(_SELF(self), + RVAL2CSTR(uri), + &error); + if (error) RAISE_GERROR(error); + return CSTR2RVAL_FREE(ret); +} + +static VALUE +rg_private_p(VALUE self, VALUE uri) +{ + GError *error = NULL; + gboolean ret = g_bookmark_file_get_is_private(_SELF(self), + RVAL2CSTR(uri), + &error); + if (error) RAISE_GERROR(error); + return CBOOL2RVAL(ret); +} + +static VALUE +rg_get_icon(VALUE self, VALUE uri) +{ + gchar* href; + gchar* mime_type; + GError *error = NULL; + gboolean ret = g_bookmark_file_get_icon(_SELF(self), + RVAL2CSTR(uri), + &href, &mime_type, + &error); + if (!ret){ + if (error) RAISE_GERROR(error); + return Qnil; + } + return rb_assoc_new(CSTR2RVAL_FREE(href), CSTR2RVAL_FREE(mime_type)); +} + +static VALUE +rg_get_added(VALUE self, VALUE uri) +{ + GError *error = NULL; + time_t ret = g_bookmark_file_get_added(_SELF(self), + RVAL2CSTR(uri), + &error); + if (!ret) RAISE_GERROR(error); + + return rb_time_new(ret, 0); +} + +static VALUE +rg_get_modified(VALUE self, VALUE uri) +{ + GError *error = NULL; + time_t ret = g_bookmark_file_get_modified(_SELF(self), + RVAL2CSTR(uri), + &error); + if (!ret) RAISE_GERROR(error); + + return rb_time_new(ret, 0); +} + +static VALUE +rg_get_visited(VALUE self, VALUE uri) +{ + GError *error = NULL; + time_t ret = g_bookmark_file_get_visited(_SELF(self), + RVAL2CSTR(uri), + &error); + if (!ret) RAISE_GERROR(error); + + return rb_time_new(ret, 0); +} + +static VALUE +rg_get_groups(VALUE self, VALUE uri) +{ + gsize length; + VALUE ary; + gsize i; + GError* error = NULL; + gchar** ret = g_bookmark_file_get_groups(_SELF(self), + RVAL2CSTR(uri), + &length, &error); + if (error) RAISE_GERROR(error); + + ary = rb_ary_new(); + for(i = 0; i < length; i++){ + rb_ary_push(ary, CSTR2RVAL(ret[i])); + } + + g_strfreev(ret); + return ary; +} + +static VALUE +rg_get_applications(VALUE self, VALUE uri) +{ + gsize length; + VALUE ary; + gsize i; + GError* error = NULL; + gchar** ret = g_bookmark_file_get_applications(_SELF(self), + RVAL2CSTR(uri), + &length, &error); + if (error) RAISE_GERROR(error); + + ary = rb_ary_new(); + for(i = 0; i < length; i++){ + rb_ary_push(ary, CSTR2RVAL(ret[i])); + } + + g_strfreev(ret); + return ary; +} + +static VALUE +rg_get_app_info(VALUE self, VALUE uri, VALUE name) +{ + gchar* exec; + guint count; + time_t stamp; + GError* error = NULL; + + gboolean ret = g_bookmark_file_get_app_info(_SELF(self), + RVAL2CSTR(uri), + RVAL2CSTR(name), + &exec, &count, &stamp, &error); + if (!ret) RAISE_GERROR(error); + + return rb_ary_new3(3, CSTR2RVAL(exec), UINT2NUM(count), rb_time_new(stamp, 0)); +} + +static VALUE +rg_set_title(VALUE self, VALUE uri, VALUE title) +{ + g_bookmark_file_set_title(_SELF(self), + RVAL2CSTR(uri), + RVAL2CSTR(title)); + return self; +} + +static VALUE +rg_set_description(VALUE self, VALUE uri, VALUE description) +{ + g_bookmark_file_set_description(_SELF(self), + RVAL2CSTR(uri), + RVAL2CSTR(description)); + return self; +} + +static VALUE +rg_set_mime_type(VALUE self, VALUE uri, VALUE mime_type) +{ + g_bookmark_file_set_mime_type(_SELF(self), + RVAL2CSTR(uri), + RVAL2CSTR(mime_type)); + return self; +} + +static VALUE +rg_set_private(VALUE self, VALUE uri, VALUE is_private) +{ + g_bookmark_file_set_is_private(_SELF(self), + RVAL2CSTR(uri), + RVAL2CBOOL(is_private)); + return self; +} + +static VALUE +rg_set_icon(VALUE self, VALUE uri, VALUE href, VALUE mime_type) +{ + g_bookmark_file_set_icon(_SELF(self), + RVAL2CSTR(uri), + RVAL2CSTR(href), + RVAL2CSTR(mime_type)); + return self; +} + +static VALUE +rg_set_added(VALUE self, VALUE uri, VALUE time) +{ + g_bookmark_file_set_added(_SELF(self), + RVAL2CSTR(uri), + (time_t)NUM2LONG(rb_Integer(time))); + return self; +} + +static VALUE +rg_set_groups(VALUE self, VALUE rburi, VALUE rbgroups) +{ + GBookmarkFile *bookmark = _SELF(self); + const gchar *uri = RVAL2CSTR(rburi); + long n; + const gchar **groups = RVAL2STRS(rbgroups, n); + + g_bookmark_file_set_groups(bookmark, uri, groups, n); + + g_free(groups); + + return self; +} + +static VALUE +rg_set_modified(VALUE self, VALUE uri, VALUE time) +{ + g_bookmark_file_set_modified(_SELF(self), + RVAL2CSTR(uri), + (time_t)NUM2LONG(rb_Integer(time))); + return self; +} + +static VALUE +rg_set_visited(VALUE self, VALUE uri, VALUE time) +{ + g_bookmark_file_set_visited(_SELF(self), + RVAL2CSTR(uri), + (time_t)NUM2LONG(rb_Integer(time))); + return self; +} + +static VALUE +rg_set_app_info(VALUE self, VALUE uri, VALUE name, VALUE exec, VALUE count, VALUE stamp) +{ + GError* error = NULL; + gboolean ret = g_bookmark_file_set_app_info(_SELF(self), + RVAL2CSTR(uri), + RVAL2CSTR(name), + RVAL2CSTR(exec), + NUM2INT(count), + (time_t)NUM2LONG(rb_Integer(stamp)), + &error); + + if (! ret) RAISE_GERROR(error); + + return self; +} + +static VALUE +rg_add_group(VALUE self, VALUE uri, VALUE group) +{ + g_bookmark_file_add_group(_SELF(self), + RVAL2CSTR(uri), + RVAL2CSTR(group)); + return self; +} + +static VALUE +rg_add_application(VALUE self, VALUE uri, VALUE name, VALUE exec) +{ + g_bookmark_file_add_application(_SELF(self), + RVAL2CSTR(uri), + RVAL2CSTR(name), + RVAL2CSTR(exec)); + return self; +} + +static VALUE +rg_remove_group(VALUE self, VALUE uri, VALUE group) +{ + GError* error = NULL; + gboolean ret = g_bookmark_file_remove_group(_SELF(self), + RVAL2CSTR(uri), + RVAL2CSTR(group), + &error); + if (! ret) RAISE_GERROR(error); + + return self; +} + +static VALUE +rg_remove_application(VALUE self, VALUE uri, VALUE name) +{ + GError *error = NULL; + gboolean ret = g_bookmark_file_remove_application(_SELF(self), + RVAL2CSTR(uri), + RVAL2CSTR(name), + &error); + if (! ret) RAISE_GERROR(error); + + return self; +} + +static VALUE +rg_remove_item(VALUE self, VALUE uri) +{ + GError *error = NULL; + gboolean ret = g_bookmark_file_remove_item(_SELF(self), + RVAL2CSTR(uri), + &error); + if (! ret) RAISE_GERROR(error); + + return self; +} + +static VALUE +rg_move_item(VALUE self, VALUE old_uri, VALUE new_uri) +{ + GError *error = NULL; + gboolean ret = g_bookmark_file_move_item(_SELF(self), + RVAL2CSTR(old_uri), + RVAL2CSTR(new_uri), + &error); + if (! ret) RAISE_GERROR(error); + + return self; +} + +#endif + +void +Init_glib_bookmark_file(void) +{ +#if GLIB_CHECK_VERSION(2,12,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_BOOKMARK_FILE, "BookmarkFile", mGLib); + + G_DEF_ERROR(G_BOOKMARK_FILE_ERROR, "BookmarkFileError", mGLib, + rb_eRuntimeError, G_TYPE_BOOKMARK_FILE_ERROR); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(load_from_file, 1); + RG_DEF_METHOD(load_from_data, 1); + RG_DEF_METHOD(load_from_data_dirs, 1); + RG_DEF_METHOD(to_data, 0); + RG_DEF_METHOD(to_file, 1); + RG_DEF_METHOD_P(has_item, 1); + RG_DEF_METHOD_P(has_group, 2); + RG_DEF_METHOD_P(has_application, 2); + RG_DEF_METHOD(size, 0); + RG_DEF_METHOD(uris, 0); + RG_DEF_METHOD(get_title, 1); + RG_DEF_METHOD(get_description, 1); + RG_DEF_METHOD(get_mime_type, 1); + RG_DEF_METHOD_P(private, 1); + RG_DEF_METHOD(get_icon, 1); + RG_DEF_METHOD(get_added, 1); + RG_DEF_METHOD(get_modified, 1); + RG_DEF_METHOD(get_visited, 1); + RG_DEF_METHOD(get_groups, 1); + RG_DEF_METHOD(get_applications, 1); + RG_DEF_METHOD(get_app_info, 2); + RG_DEF_METHOD(set_title, 2); + RG_DEF_METHOD(set_description, 2); + RG_DEF_METHOD(set_mime_type, 2); + RG_DEF_METHOD(set_private, 2); + RG_DEF_METHOD(set_icon, 3); + RG_DEF_METHOD(set_added, 2); + RG_DEF_METHOD(set_groups, 2); + RG_DEF_METHOD(set_modified, 2); + RG_DEF_METHOD(set_visited, 2); + RG_DEF_METHOD(set_app_info, 5); + RG_DEF_METHOD(add_group, 2); + RG_DEF_METHOD(add_application, 3); + RG_DEF_METHOD(remove_group, 2); + RG_DEF_METHOD(remove_application, 2); + RG_DEF_METHOD(remove_item, 1); + RG_DEF_METHOD(move_item, 2); +#endif +} \ No newline at end of file diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_convert.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_convert.c new file mode 100644 index 0000000..478a32d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_convert.c @@ -0,0 +1,197 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2009 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 KUBO Takehiro + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" +#include "rbglib.h" + +#define RG_TARGET_NAMESPACE mGLib + +static VALUE +rg_s_convert(G_GNUC_UNUSED VALUE self, VALUE str, VALUE to, VALUE from) +{ + GError *err = NULL; + gchar* ret; + gsize written; + VALUE s = Qnil; + + StringValue(str); + ret = g_convert(RSTRING_PTR(str), RSTRING_LEN(str), + StringValuePtr(to), StringValuePtr(from), + NULL, &written, &err); + + if (err != NULL) + RAISE_GERROR(err); + s = rb_str_new(ret, written); + g_free(ret); + return s; +} + +static VALUE +rg_s_locale_to_utf8(G_GNUC_UNUSED VALUE self, VALUE str) +{ + GError *err = NULL; + VALUE s = Qnil; + gchar* ret; + gsize written; + + StringValue(str); + ret = g_locale_to_utf8(RSTRING_PTR(str), RSTRING_LEN(str), + NULL, &written, &err); + + if (err != NULL) + RAISE_GERROR(err); + s = rb_str_new(ret, written); + g_free(ret); + return s; +} + +static VALUE +rg_s_locale_from_utf8(G_GNUC_UNUSED VALUE self, VALUE str) +{ + GError *err = NULL; + VALUE s = Qnil; + gchar* ret; + gsize written; + + StringValue(str); + ret = g_locale_from_utf8(RSTRING_PTR(str), RSTRING_LEN(str), + NULL, &written, &err); + + if (err != NULL) + RAISE_GERROR(err); + s = rb_str_new(ret, written); + g_free(ret); + return s; +} + +static VALUE +rg_s_filename_to_utf8(G_GNUC_UNUSED VALUE self, VALUE str) +{ + GError *err = NULL; + VALUE s = Qnil; + gchar* ret; + gsize written; + + StringValue(str); + ret = g_filename_to_utf8(RSTRING_PTR(str), RSTRING_LEN(str), + NULL, &written, &err); + + if (err != NULL) + RAISE_GERROR(err); + s = rb_str_new(ret, written); + g_free(ret); + return s; +} + +static VALUE +rg_s_filename_from_utf8(G_GNUC_UNUSED VALUE self, VALUE str) +{ + GError *err = NULL; + VALUE s = Qnil; + gchar* ret; + gsize written; + + StringValue(str); + ret = g_filename_from_utf8(RSTRING_PTR(str), RSTRING_LEN(str), + NULL, &written, &err); + + if (err != NULL) + RAISE_GERROR(err); + s = rb_str_new(ret, written); + g_free(ret); + return s; +} + +static VALUE +rg_s_filename_to_uri(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE filename, hostname, s; + GError *err = NULL; + gchar* ret; + + rb_scan_args(argc, argv, "11", &filename, &hostname); + + ret = g_filename_to_uri(StringValuePtr(filename), + NIL_P(hostname) ? NULL : StringValuePtr(hostname), + &err); + + if (err) + RAISE_GERROR(err); + s = rb_str_new2(ret); + g_free(ret); + return s; +} + +static VALUE +rg_s_filename_from_uri(G_GNUC_UNUSED VALUE self, VALUE str) +{ + GError *err = NULL; + VALUE s; + gchar* filename; + char* hostname; + + filename = g_filename_from_uri(StringValuePtr(str), &hostname, &err); + + if (err) + RAISE_GERROR(err); + s = rb_ary_new3(2, rb_str_new2(filename), + hostname ? rb_str_new2(hostname) : Qnil); + g_free(filename); + g_free(hostname); + return s; +} + +static VALUE +rg_s_utf8_validate(G_GNUC_UNUSED VALUE self, VALUE str) +{ + rb_warning("GLib.utf8_validate is deprecated. Use GLib::UTF8.validate instead."); + StringValue(str); + return CBOOL2RVAL(g_utf8_validate(RSTRING_PTR(str), RSTRING_LEN(str), NULL)); +} + +void +Init_glib_convert(void) +{ + VALUE cCharError = G_DEF_ERROR2(G_CONVERT_ERROR, "ConvertError", RG_TARGET_NAMESPACE, rb_eIOError); + + rb_define_const(cCharError, "NO_CONVERSION", INT2NUM(G_CONVERT_ERROR_NO_CONVERSION)); + rb_define_const(cCharError, "ILLEGAL_SEQUENCE", INT2NUM(G_CONVERT_ERROR_ILLEGAL_SEQUENCE)); + rb_define_const(cCharError, "FAILED", INT2NUM(G_CONVERT_ERROR_FAILED)); + rb_define_const(cCharError, "PARTIAL_INPUT", INT2NUM(G_CONVERT_ERROR_PARTIAL_INPUT)); + rb_define_const(cCharError, "BAD_URI", INT2NUM(G_CONVERT_ERROR_BAD_URI)); + rb_define_const(cCharError, "NOT_ABSOLUTE_PATH", INT2NUM(G_CONVERT_ERROR_NOT_ABSOLUTE_PATH)); + + /* glib/gunicode.h */ + /* just for backward compatibility. + Use GLib::UTF8.validate instead. */ + RG_DEF_SMETHOD(utf8_validate, 1); + + /* glib/gconvert.h */ + RG_DEF_SMETHOD(convert, 3); + RG_DEF_SMETHOD(locale_to_utf8, 1); + RG_DEF_SMETHOD(locale_from_utf8, 1); + RG_DEF_SMETHOD(filename_to_utf8, 1); + RG_DEF_SMETHOD(filename_from_utf8, 1); + + RG_DEF_SMETHOD(filename_to_uri, -1); + RG_DEF_SMETHOD(filename_from_uri, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_error.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_error.c new file mode 100644 index 0000000..036a71c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_error.c @@ -0,0 +1,99 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" +#include + +static ID id_code; +static ID id_domain; +static VALUE gerror_table; +static VALUE generic_error; + +VALUE +rbgerr_gerror2exception(GError *error) +{ + VALUE exc = Qnil; + VALUE klass = Qnil; + + if (! error){ + return rb_exc_new2(rb_eRuntimeError, "GError parameter doesn't have a value."); + } + + klass = rb_hash_aref(gerror_table, UINT2NUM(error->domain)); + if (NIL_P(klass)) { + exc = rb_exc_new2(generic_error, error->message); + rb_ivar_set(exc, id_domain, CSTR2RVAL(g_quark_to_string(error->domain))); + rb_ivar_set(exc, id_code, INT2NUM(error->code)); + } else { + exc = rb_exc_new2(klass, error->message); + rb_ivar_set(exc, id_domain, CSTR2RVAL(g_quark_to_string(error->domain))); + rb_ivar_set(exc, id_code, INT2NUM(error->code)); + } + g_error_free(error); + return exc; +} + +VALUE +rbgerr_define_gerror(GQuark domain, const gchar *name, VALUE module, VALUE parent, VALUE gtype) +{ + VALUE klass = rb_define_class_under(module, name, parent); + rb_funcall(klass, rbgutil_id_module_eval, 1, CSTR2RVAL("def code; @code; end\n")); + rb_funcall(klass, rbgutil_id_module_eval, 1, CSTR2RVAL("def domain; @domain; end\n")); + + rb_hash_aset(gerror_table, UINT2NUM(domain), klass); + + if (! NIL_P(gtype)){ + GEnumClass* gclass = g_type_class_ref(gtype); + guint i; + + for (i = 0; i < gclass->n_values; i++) { + GEnumValue* entry = &(gclass->values[i]); + gchar* nick = g_strdup(entry->value_nick); + gchar* p; + + for (p = nick; *p; p++) { + if (*p == '-') + *p = '_'; + else + *p = g_ascii_toupper(*p); + } + rbgobj_define_const(klass, nick, INT2NUM(i)); + g_free(nick); + } + + g_type_class_unref(gclass); + } + + return klass; +} + +void +Init_glib_error(void) +{ + id_code = rb_intern("@code"); + id_domain = rb_intern("@domain"); + gerror_table = rb_hash_new(); + rb_global_variable(&gerror_table); + + generic_error = rb_define_class_under(mGLib, "Error", rb_eRuntimeError); + rb_funcall(generic_error, rbgutil_id_module_eval, 1, CSTR2RVAL("def code; @code; end\n")); + rb_funcall(generic_error, rbgutil_id_module_eval, 1, CSTR2RVAL("def domain; @domain; end\n")); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_fileutils.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_fileutils.c new file mode 100644 index 0000000..1b5c279 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_fileutils.c @@ -0,0 +1,94 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" +#include "rbglib.h" + +#define RG_TARGET_NAMESPACE cFileError + +/* Use Ruby standard libraries. +enum GFileTest; +GFileError g_file_error_from_errno (gint err_no); +gboolean g_file_get_contents (const gchar *filename, + gchar **contents, + gsize *length, + GError **error); +gboolean g_file_test (const gchar *filename, + GFileTest test); +gint g_mkstemp (gchar *tmpl); +gint g_file_open_tmp (const gchar *tmpl, + gchar **name_used, + GError **error); +gchar* g_file_read_link (const gchar *filename, + GError **error); + +struct GDir; +GDir* g_dir_open (const gchar *path, + guint flags, + GError **error); +G_CONST_RETURN gchar* g_dir_read_name (GDir *dir); +void g_dir_rewind (GDir *dir); +void g_dir_close (GDir *dir); +*/ + +#if GLIB_CHECK_VERSION(2, 16, 0) +static VALUE +rbglib_m_format_size_for_display(G_GNUC_UNUSED VALUE self, VALUE size) +{ + return CSTR2RVAL_FREE(g_format_size_for_display(NUM2INT(size))); +} +#endif + +void +Init_glib_fileutils(void) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_ERROR2(G_FILE_ERROR, "FileError", mGLib, rb_eIOError); + + rb_define_const(RG_TARGET_NAMESPACE, "EXIST", INT2NUM(G_FILE_ERROR_EXIST)); + rb_define_const(RG_TARGET_NAMESPACE, "ISDIR", INT2NUM(G_FILE_ERROR_ISDIR)); + rb_define_const(RG_TARGET_NAMESPACE, "ACCES", INT2NUM(G_FILE_ERROR_ACCES)); + rb_define_const(RG_TARGET_NAMESPACE, "NAMETOOLONG", INT2NUM(G_FILE_ERROR_NAMETOOLONG)); + rb_define_const(RG_TARGET_NAMESPACE, "NOENT", INT2NUM(G_FILE_ERROR_NOENT)); + rb_define_const(RG_TARGET_NAMESPACE, "NOTDIR", INT2NUM(G_FILE_ERROR_NOTDIR)); + rb_define_const(RG_TARGET_NAMESPACE, "NXIO", INT2NUM(G_FILE_ERROR_NXIO)); + rb_define_const(RG_TARGET_NAMESPACE, "NODEV", INT2NUM(G_FILE_ERROR_NODEV)); + rb_define_const(RG_TARGET_NAMESPACE, "ROFS", INT2NUM(G_FILE_ERROR_ROFS)); + rb_define_const(RG_TARGET_NAMESPACE, "TXTBSY", INT2NUM(G_FILE_ERROR_TXTBSY)); + rb_define_const(RG_TARGET_NAMESPACE, "FAULT", INT2NUM(G_FILE_ERROR_FAULT)); + rb_define_const(RG_TARGET_NAMESPACE, "LOOP", INT2NUM(G_FILE_ERROR_LOOP)); + rb_define_const(RG_TARGET_NAMESPACE, "NOSPC", INT2NUM(G_FILE_ERROR_NOSPC)); + rb_define_const(RG_TARGET_NAMESPACE, "NOMEM", INT2NUM(G_FILE_ERROR_NOMEM)); + rb_define_const(RG_TARGET_NAMESPACE, "MFILE", INT2NUM(G_FILE_ERROR_MFILE)); + rb_define_const(RG_TARGET_NAMESPACE, "NFILE", INT2NUM(G_FILE_ERROR_NFILE)); + rb_define_const(RG_TARGET_NAMESPACE, "BADF", INT2NUM(G_FILE_ERROR_BADF)); + rb_define_const(RG_TARGET_NAMESPACE, "INVAL", INT2NUM(G_FILE_ERROR_INVAL)); + rb_define_const(RG_TARGET_NAMESPACE, "PIPE", INT2NUM(G_FILE_ERROR_PIPE)); + rb_define_const(RG_TARGET_NAMESPACE, "AGAIN", INT2NUM(G_FILE_ERROR_AGAIN)); + rb_define_const(RG_TARGET_NAMESPACE, "INTR", INT2NUM(G_FILE_ERROR_INTR)); + rb_define_const(RG_TARGET_NAMESPACE, "IO", INT2NUM(G_FILE_ERROR_IO)); + rb_define_const(RG_TARGET_NAMESPACE, "PERM", INT2NUM(G_FILE_ERROR_PERM)); + rb_define_const(RG_TARGET_NAMESPACE, "FAILED", INT2NUM(G_FILE_ERROR_FAILED)); + +#if GLIB_CHECK_VERSION(2, 16, 0) + rbg_define_singleton_method(mGLib, "format_size_for_display", + rbglib_m_format_size_for_display, 1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_i18n.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_i18n.c new file mode 100644 index 0000000..bf598b8 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_i18n.c @@ -0,0 +1,44 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" +#include "rbglib.h" +#undef _ +#include + +#define RG_TARGET_NAMESPACE mGLib + +#if GLIB_CHECK_VERSION(2,6,0) +static VALUE +rg_s_language_names(G_GNUC_UNUSED VALUE self) +{ + return STRV2RVAL((const gchar **)g_get_language_names()); +} +#endif + +void +Init_glib_i18n(void) +{ + /* glib/gi18n.h */ +#if GLIB_CHECK_VERSION(2,6,0) + RG_DEF_SMETHOD(language_names, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_int64.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_int64.c new file mode 100644 index 0000000..820313c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_int64.c @@ -0,0 +1,165 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masahiro Sakai + * Copyright (C) 2002 Masahiro Sakai + * Kenichi Komiya + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +static ID id_and; +static ID id_rshift; +static ID id_lshift; +static ID id_lt; +static ID id_plus; +static ID id_uminus; +static ID id_abs; +static VALUE max_PRUint32; + +typedef guint64 PRUint64; +typedef gint64 PRInt64; + +#define LL_ZERO G_GINT64_CONSTANT(0) +#define LL_UI2L(lhs,rhs) ((lhs)=(rhs)) +#define LL_L2UI(lhs,rhs) ((lhs)=(guint32)(rhs)) +#define LL_SHL(lhs,v1,v2) ((lhs)=(v1)<<(v2)) +#define LL_SHR(lhs,v1,v2) ((lhs)=(v1)>>(v2)) +#define LL_ADD(lhs,v1,v2) ((lhs)=(v1)+(v2)) +#define LL_NEG(lhs,rhs) ((lhs)=-(rhs)) +#define LL_CMP(v1,op,v2) ((v1) op (v2)) + +/**********************************************************************/ +/* + following is ripped from rbXPCOM-0.0.3 + http://www.ruby-lang.org/en/raa-list.rhtml?name=rbXPCOM + Copyright (C) 2001 Kenichi Komiya +*/ + +static PRUint64 +RubyTo64BitInt(VALUE aRuby) +{ + VALUE bitMask = max_PRUint32; + VALUE lo = rb_funcall(aRuby, id_and, 1, bitMask); + VALUE hi = rb_funcall(aRuby, id_rshift, 1, INT2FIX(32)); + PRUint64 result, hi64, lo64; + LL_UI2L(hi64, NUM2UINT(hi)); + LL_UI2L(lo64, NUM2UINT(lo)); + LL_SHL(result, hi64, 32); + LL_ADD(result, result, lo64); + return result; +} + + +static inline PRUint64 +RubyToPRUint64(VALUE aRuby) +{ + return RubyTo64BitInt(aRuby); +} + + +static PRInt64 +RubyToPRInt64(VALUE aRuby) +{ + if(RVAL2CBOOL(rb_funcall(aRuby, id_lt, 1, INT2FIX(0)))) + { + VALUE absRuby = rb_funcall(aRuby, id_abs, 0); + PRInt64 result; + LL_NEG(result, RubyTo64BitInt(absRuby)); + return result; + } else + return (PRInt64)RubyTo64BitInt(aRuby); + +} + +static VALUE +RubyFrom64BitInt(PRUint64 aNative) +{ + PRUint64 lo64, hi64; + LL_L2UI(lo64, aNative); + LL_SHR(hi64, aNative, 32); + { + VALUE lo = UINT2NUM(lo64); + VALUE hi = UINT2NUM(hi64); + VALUE hiRuby = rb_funcall(hi, id_lshift, 1, INT2FIX(32)); + return rb_funcall(hiRuby, id_plus, 1, lo); + } +} + +static inline VALUE +PRUint64ToRuby(PRUint64 aNative) +{ + return RubyFrom64BitInt(aNative); +} + +static VALUE +PRInt64ToRuby(PRInt64 aNative) +{ + if(LL_CMP(aNative, <, LL_ZERO)) + { + PRUint64 abs64; + LL_NEG(abs64, aNative); + return rb_funcall(RubyFrom64BitInt(abs64), id_uminus, 0); + } + else + return RubyFrom64BitInt((PRUint64)aNative); +} + +/* end of ripping */ +/**********************************************************************/ + +VALUE +rbglib_int64_to_num(guint64 val) +{ + return PRInt64ToRuby(val); +} + +VALUE +rbglib_uint64_to_num(guint64 val) +{ + return PRUint64ToRuby(val); +} + +gint64 +rbglib_num_to_int64(VALUE val) +{ + return RubyToPRInt64(val); +} + +guint64 +rbglib_num_to_uint64(VALUE val) +{ + return RubyToPRUint64(val); +} + +/**********************************************************************/ + +void +Init_glib_int64(void) +{ + id_and = rb_intern("&"); + id_rshift = rb_intern(">>"); + id_lshift = rb_intern("<<"); + id_lt = rb_intern("<"); + id_plus = rb_intern("+"); + id_uminus = rb_intern("-@"); + id_abs = rb_intern("abs"); + + rb_global_variable(&max_PRUint32); + max_PRUint32 = UINT2NUM(0xffffffffL); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_io_constants.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_io_constants.c new file mode 100644 index 0000000..88e6fb4 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_io_constants.c @@ -0,0 +1,30 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011-2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +void +Init_glib_io_constants(void) +{ + VALUE RG_TARGET_NAMESPACE = mGLib; + + /* GIOCondition */ + G_DEF_CLASS(G_TYPE_IO_CONDITION, "IOCondition", RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_iochannel.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_iochannel.c new file mode 100644 index 0000000..869541e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_iochannel.c @@ -0,0 +1,824 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +static ID id_call; +static ID id_puts; +static ID id_unpack; + +static VALUE default_rs; + +#define RG_TARGET_NAMESPACE cIOChannel +#define _SELF(s) ((GIOChannel*)RVAL2BOXED(s, G_TYPE_IO_CHANNEL)) + +static void +ioc_error(GIOStatus status, GError *err) +{ + if (err != NULL) RAISE_GERROR(err); + + if (status == G_IO_STATUS_EOF){ + rb_raise(rb_eEOFError, "End of file reached"); + } else if (status == G_IO_STATUS_AGAIN){ + rb_raise(rb_eRuntimeError, "G_IO_STATUS_AGAIN"); + } else if (status == G_IO_STATUS_NORMAL){ + /* Do nothing */ + } else { + rb_raise(rb_eRuntimeError, "An error occured. status = %d\n", status); + } +} + +static VALUE +rg_initialize(gint argc, VALUE *argv, VALUE self) +{ + VALUE arg1, arg2; + + GIOChannel* io = NULL; + rb_secure(4); + rb_scan_args(argc, argv, "11", &arg1, &arg2); + + if (TYPE(arg1) != T_STRING){ + gint fd; + if (TYPE(arg1) == T_FIXNUM){ + fd = NUM2INT(arg1); + } else { + fd = NUM2INT(rb_funcall(arg1, rb_intern("to_i"), 0)); + } +#ifdef G_OS_UNIX + io = g_io_channel_unix_new(fd); +#elif defined(G_OS_WIN32) + io = g_io_channel_win32_new_fd(fd); +#else + rb_raise(rb_eRuntimeError, "GLib::IOChannel.new(fd) is supported on UNIX environment only"); +#endif + } else { + GError* err = NULL; + io = g_io_channel_new_file(RVAL2CSTR(arg1), + NIL_P(arg2) ? "r" : RVAL2CSTR(arg2), &err); + + if (err != NULL) RAISE_GERROR(err); + } + + G_INITIALIZE(self, io); + + return Qnil; +} + +static VALUE +ioc_close(VALUE self) +{ + GError* err = NULL; + GIOStatus status = g_io_channel_shutdown(_SELF(self), TRUE, &err); + + ioc_error(status, err); + return self; +} + +static VALUE +rg_s_open(gint argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE arg1, arg2; + VALUE rio; + GIOChannel* io = NULL; + + rb_scan_args(argc, argv, "11", &arg1, &arg2); + + if (TYPE(arg1) == T_FIXNUM){ +#ifdef G_OS_UNIX + io = g_io_channel_unix_new(NUM2INT(arg1)); +#elif defined(G_OS_WIN32) + io = g_io_channel_win32_new_fd(NUM2INT(arg1)); +#else + rb_raise(rb_eRuntimeError, + "GLib::IOChannel.new(fd) is supported on " + "UNIX and Windows environment only"); +#endif + } else { + GError* err = NULL; + io = g_io_channel_new_file(RVAL2CSTR(arg1), + NIL_P(arg2) ? "r" : RVAL2CSTR(arg2), &err); + + if (err != NULL) RAISE_GERROR(err); + } + + rio = BOXED2RVAL(io, G_TYPE_IO_CHANNEL); + + if (rb_block_given_p()) { + return rb_ensure(rb_yield, rio, ioc_close, rio); + } + return rio; +} + +static VALUE +rg_fileno(VALUE self) +{ +#ifdef G_OS_UNIX + return INT2NUM(g_io_channel_unix_get_fd(_SELF(self))); +#elif defined(G_OS_WIN32) + return INT2NUM(g_io_channel_win32_get_fd(_SELF(self))); +#else + rb_warn("GLib::IOChannel#fd is supported on " + "UNIX and Windows environment only."); + return Qnil; +#endif +} + +/* Don't need this +void g_io_channel_init (GIOChannel *channel); +*/ + +static VALUE +rg_read(gint argc, VALUE *argv, VALUE self) +{ + VALUE rbcount; + gsize count; + gchar *buffer; + gsize bytes_read; + GIOChannel *channel = _SELF(self); + GError *error = NULL; + GIOStatus status; + + rb_scan_args(argc, argv, "01", &rbcount); + + if (NIL_P(rbcount)) { + status = g_io_channel_read_to_end(channel, &buffer, &bytes_read, &error); + ioc_error(status, error); + + return buffer != NULL ? CSTR2RVAL_LEN_FREE(buffer, bytes_read) : CSTR2RVAL(""); + } + + count = NUM2UINT(rbcount); + + buffer = g_new(gchar, count); + memset(buffer, '\0', count); + + status = g_io_channel_read_chars(channel, buffer, count, &bytes_read, &error); + if (status == G_IO_STATUS_NORMAL) + return CSTR2RVAL_LEN_FREE(buffer, bytes_read); + else if (status == G_IO_STATUS_EOF) + return CSTR2RVAL(""); + + ioc_error(status, error); + + /* Not reached. */ + return Qnil; +} + +static VALUE +rg_readchar(VALUE self) +{ + gunichar thechar; + GError* err = NULL; + GIOStatus status = g_io_channel_read_unichar(_SELF(self), &thechar, &err); + + ioc_error(status, err); + + return UINT2NUM(thechar); +} + +static VALUE +rg_getc(VALUE self) +{ + gunichar thechar; + GError* err = NULL; + VALUE ret; + GIOStatus status = g_io_channel_read_unichar(_SELF(self), &thechar, &err); + + if (status == G_IO_STATUS_EOF){ + ret = Qnil; + } else { + ioc_error(status, err); + ret = UINT2NUM(thechar); + } + + return ret; +} + +static VALUE +rg_each_char(VALUE self) +{ + if (!rb_block_given_p()) { + rb_raise(rb_eArgError, "called without a block"); + } + + while (TRUE){ + gunichar thechar; + GError* err = NULL; + GIOStatus status = g_io_channel_read_unichar(_SELF(self), &thechar, &err); + if (status == G_IO_STATUS_EOF){ + break; + } else { + ioc_error(status, err); + rb_yield(UINT2NUM(thechar)); + } + } + return self; +} + +static VALUE +rg_readline(gint argc, VALUE *argv, VALUE self) +{ + gchar* str; + VALUE line_term, ret; + GIOStatus status; + GError* err = NULL; + + const gchar* old_line_term = NULL; + gint old_line_term_len; + + rb_scan_args(argc, argv, "01", &line_term); + + if (! NIL_P(line_term)){ + StringValue(line_term); + old_line_term = g_io_channel_get_line_term(_SELF(self), &old_line_term_len); + + g_io_channel_set_line_term(_SELF(self), RVAL2CSTR(line_term), + RSTRING_LEN(line_term)); + } + + status = g_io_channel_read_line(_SELF(self), &str, NULL, NULL, &err); + + if (! NIL_P(line_term)){ + g_io_channel_set_line_term(_SELF(self), old_line_term, old_line_term_len); + } + + ioc_error(status, err); + + ret = str ? CSTR2RVAL(str) : CSTR2RVAL(""); + g_free(str); + + return ret; +} + +static VALUE +rg_gets(gint argc, VALUE *argv, VALUE self) +{ + gchar* str; + VALUE line_term, ret; + GIOStatus status; + GError* err = NULL; + + const gchar* old_line_term = NULL; + gint old_line_term_len; + + rb_scan_args(argc, argv, "01", &line_term); + + if (! NIL_P(line_term)){ + StringValue(line_term); + + old_line_term = g_io_channel_get_line_term(_SELF(self), &old_line_term_len); + g_io_channel_set_line_term(_SELF(self), RVAL2CSTR(line_term), + RSTRING_LEN(line_term)); + } + + status = g_io_channel_read_line(_SELF(self), &str, NULL, NULL, &err); + + if (! NIL_P(line_term)){ + g_io_channel_set_line_term(_SELF(self), old_line_term, old_line_term_len); + } + + if (status == G_IO_STATUS_EOF){ + ret = Qnil; + } else { + ioc_error(status, err); + ret = str ? CSTR2RVAL(str) : CSTR2RVAL(""); + } + g_free(str); + + return ret; +} + +/* Internal use only */ +static VALUE +ioc_set_line_term(VALUE args) +{ + VALUE self = RARRAY_PTR(args)[0]; + VALUE doit = RARRAY_PTR(args)[1]; + VALUE line_term = RARRAY_PTR(args)[2]; + + if (doit == Qtrue){ + StringValue(line_term); + g_io_channel_set_line_term(_SELF(self), RVAL2CSTR(line_term), + RSTRING_LEN(line_term)); + } + return self; +} + +static VALUE +rg_each(gint argc, VALUE *argv, VALUE self) +{ + gchar* str; + VALUE line_term; + GIOStatus status; + GError* err = NULL; + GIOChannel *channel; + const gchar* old_line_term = NULL; + gint old_line_term_len; + + if (!rb_block_given_p()) { + rb_raise(rb_eArgError, "called without a block"); + } + + rb_scan_args(argc, argv, "01", &line_term); + + channel = _SELF(self); + if (!NIL_P(line_term)) { + StringValue(line_term); + + old_line_term = g_io_channel_get_line_term(channel, &old_line_term_len); + g_io_channel_set_line_term(channel, RVAL2CSTR(line_term), + RSTRING_LEN(line_term)); + } + + while (TRUE) { + status = g_io_channel_read_line(channel, &str, NULL, NULL, &err); + if (status == G_IO_STATUS_EOF) { + break; + } else { + VALUE rstr; + ioc_error(status, err); + if (str) { + rstr = CSTR2RVAL(str); + } else { + rstr = CSTR2RVAL(""); + } + g_free(str); + rb_ensure(rb_yield, rstr, ioc_set_line_term, + rb_ary_new3(3, self, + NIL_P(line_term) ? Qfalse : Qtrue, + CSTR2RVAL(old_line_term))); + } + } + return self; +} + +/* Don't need this. +GIOStatus g_io_channel_read_line_string (GIOChannel *channel, + GString *buffer, + gsize *terminator_pos, + GError **error); +*/ + +/* Use GLib::IOChannel#read instead. +static VALUE +ioc_read_to_end(VALUE self) +{ + gchar* str; + gsize length; + VALUE ret; + GError* err = NULL; + + GIOStatus status = g_io_channel_read_to_end(_SELF(self), &str, + &length, &err); + + ioc_error(status, err); + + ret = str ? rb_str_new(str, length) : CSTR2RVAL(""); + g_free(str); + + return ret; +} +*/ + +static VALUE +rg_write(VALUE self, VALUE buf) +{ + gssize count; + gsize bytes_written; + GIOStatus status; + GError* err = NULL; + + rb_secure(4); + buf = rb_obj_as_string(buf); + + StringValue(buf); + + count = RSTRING_LEN(buf); + + status = g_io_channel_write_chars(_SELF(self), RVAL2CSTR(buf), count, &bytes_written, &err); + + ioc_error(status, err); + return UINT2NUM(bytes_written); +} + +static VALUE +rg_putc(VALUE self, VALUE thechar) +{ + GError* err = NULL; + GIOStatus status; + gunichar unichar; + + rb_secure(4); + if (TYPE(thechar) == T_FIXNUM) { + unichar = NUM2UINT(thechar); + } else { + VALUE ary = rb_funcall(thechar, id_unpack, 1, CSTR2RVAL("U")); + unichar = NUM2UINT(RARRAY_PTR(ary)[0]); + } + + status = g_io_channel_write_unichar(_SELF(self), unichar, &err); + + ioc_error(status, err); + + return self; +} + +static VALUE +rg_flush(VALUE self) +{ + GError* err = NULL; + GIOStatus status = g_io_channel_flush(_SELF(self), &err); + ioc_error(status, err); + return self; +} + +static VALUE +rg_seek(gint argc, VALUE *argv, VALUE self) +{ + VALUE ofs, type; + GIOStatus status; + GError* err = NULL; + GSeekType gtype = G_SEEK_SET; + + rb_scan_args(argc, argv, "11", &ofs, &type); + + if (!NIL_P(type)) + gtype = NUM2INT(type); + + status = g_io_channel_seek_position(_SELF(self), NUM2INT(ofs), + gtype, &err); + ioc_error(status, err); + return self; +} + +static VALUE +rg_set_pos(VALUE self, VALUE pos) +{ + GError* err = NULL; + GIOStatus status = g_io_channel_seek_position(_SELF(self), NUM2INT(pos), + G_SEEK_SET, &err); + ioc_error(status, err); + return self; +} + +static VALUE +rg_close(gint argc, VALUE *argv, VALUE self) +{ + VALUE flush; + GError* err = NULL; + gboolean gflush = TRUE; + GIOStatus status; + + rb_scan_args(argc, argv, "01", &flush); + + if (!NIL_P(flush)){ + gflush = RVAL2CBOOL(flush); + } + + status = g_io_channel_shutdown(_SELF(self), gflush, &err); + ioc_error(status, err); + + return self; +} + +static VALUE +rg_create_watch(VALUE self, VALUE condition) +{ + return BOXED2RVAL(g_io_create_watch(_SELF(self), NUM2INT(condition)), + G_TYPE_SOURCE); +} + +static gboolean +io_func(GIOChannel *source, GIOCondition condition, gpointer func) +{ + return RVAL2CBOOL(rb_funcall((VALUE)func, id_call, 2, + BOXED2RVAL(source, G_TYPE_IO_CHANNEL), + INT2NUM(condition))); +} + +static VALUE +rg_add_watch(VALUE self, VALUE condition) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + return UINT2NUM(g_io_add_watch(_SELF(self), NUM2INT(condition), + (GIOFunc)io_func, (gpointer)func)); +} + +/* Don't need this +guint g_io_add_watch_full (GIOChannel *channel, + gint priority, + GIOCondition condition, + GIOFunc func, + gpointer user_data, + GDestroyNotify notify); +*/ + +static VALUE +rg_buffer_size(VALUE self) +{ + return UINT2NUM(g_io_channel_get_buffer_size(_SELF(self))); +} + +static VALUE +rg_set_buffer_size(VALUE self, VALUE buffer_size) +{ + g_io_channel_set_buffer_size(_SELF(self), NUM2UINT(buffer_size)); + return self; +} + +static VALUE +rg_buffer_condition(VALUE self) +{ + return INT2NUM(g_io_channel_get_buffer_condition(_SELF(self))); +} + +static VALUE +rg_flags(VALUE self) +{ + return INT2NUM(g_io_channel_get_flags(_SELF(self))); +} + +static VALUE +rg_set_flags(VALUE self, VALUE flags) +{ + GError* err = NULL; + GIOStatus status = g_io_channel_set_flags(_SELF(self), + NUM2INT(flags), &err); + ioc_error(status, err); + return self; +} + +/* Use them with GLib::IOChannel#gets, #readline, #readlines +static VALUE +ioc_get_line_term(VALUE self) +{ + gint length; + const gchar* ret = g_io_channel_get_line_term(_SELF(self), &length); + if (ret) { + if (length < 0) { + return CSTR2RVAL(ret); + } else { + return rb_str_new(ret, length); + } + } + return Qnil; +} + +static VALUE +ioc_set_line_term(VALUE self, VALUE line_term) +{ + StringValue(line_term); + g_io_channel_set_line_term(_SELF(self), RVAL2CSTR(line_term), + RSTRING_LEN(line_term)); + return self; +} +*/ + +static VALUE +rg_buffered(VALUE self) +{ + return CBOOL2RVAL(g_io_channel_get_buffered(_SELF(self))); +} + +static VALUE +rg_set_buffered(VALUE self, VALUE buffered) +{ + g_io_channel_set_buffered(_SELF(self), RVAL2CBOOL(buffered)); + return self; +} + +static VALUE +rg_encoding(VALUE self) +{ + return CSTR2RVAL(g_io_channel_get_encoding(_SELF(self))); +} + +static VALUE +rg_set_encoding(VALUE self, VALUE encoding) +{ + GError* err = NULL; + GIOStatus status; + + status = g_io_channel_set_encoding(_SELF(self), + RVAL2CSTR_ACCEPT_NIL(encoding), + &err); + ioc_error(status, err); + return self; +} + +/* Don't we need them ? +gboolean g_io_channel_get_close_on_unref (GIOChannel *channel); +void g_io_channel_set_close_on_unref (GIOChannel *channel, + gboolean do_close); +*/ + +/* Deprecated +GIOError g_io_channel_read (GIOChannel *channel, + gchar *buf, + gsize count, + gsize *bytes_read); +enum GIOError; +GIOError g_io_channel_write (GIOChannel *channel, + const gchar *buf, + gsize count, + gsize *bytes_written); +GIOError g_io_channel_seek (GIOChannel *channel, + gint64 offset, + GSeekType type); +void g_io_channel_close (GIOChannel *channel); +*/ + +/* + * Stolen some convenient methods from io.c + */ +static VALUE +rg_printf(int argc, VALUE *argv, VALUE self) +{ + rg_write(self, rb_f_sprintf(argc, argv)); + return Qnil; +} + +static VALUE +ioc_puts_ary(VALUE ary, VALUE out, int recur) +{ + VALUE tmp; + long i; + + for (i=0; i0) { + rg_write(out, output_field_separator); + } + switch (TYPE(argv[i])) { + case T_NIL: + rg_write(out, rb_str_new2("nil")); + break; + default: + rg_write(out, argv[i]); + break; + } + } + if (!NIL_P(output_field_separator)) { + rg_write(out, output_field_separator); + } + + return Qnil; +} + +void +Init_glib_io_channel(void) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_IO_CHANNEL, "IOChannel", mGLib); + + rb_include_module(RG_TARGET_NAMESPACE, rb_mEnumerable); + + id_call = rb_intern("call"); + id_puts = rb_intern("puts"); + id_unpack = rb_intern("unpack"); + + default_rs = rb_str_new_cstr("\n"); +#ifdef HAVE_RB_GC_REGISTER_MARK_OBJECT + rb_gc_register_mark_object(default_rs); +#else + rb_global_variable(&default_rs); +#endif + + RG_DEF_METHOD(initialize, -1); + RG_DEF_SMETHOD(open, -1); + RG_DEF_METHOD(fileno, 0); + RG_DEF_ALIAS("to_i", "fileno"); + RG_DEF_METHOD(read, -1); + RG_DEF_METHOD(readchar, 0); + RG_DEF_METHOD(getc, 0); + RG_DEF_METHOD(readline, -1); + RG_DEF_METHOD(gets, -1); + RG_DEF_METHOD(each, -1); + RG_DEF_ALIAS("each_line", "each"); + RG_DEF_METHOD(each_char, 0); + RG_DEF_METHOD(write, 1); + RG_DEF_METHOD(printf, -1); + RG_DEF_METHOD(print, -1); + RG_DEF_METHOD(puts, -1); + RG_DEF_METHOD(putc, 1); + RG_DEF_METHOD(flush, 0); + RG_DEF_METHOD(seek, -1); + RG_DEF_METHOD(set_pos, 1); + RG_DEF_METHOD(close, -1); + RG_DEF_METHOD(create_watch, 1); + RG_DEF_METHOD(add_watch, 1); + RG_DEF_METHOD(buffer_size, 0); + RG_DEF_METHOD(set_buffer_size, 1); + RG_DEF_METHOD(buffer_condition, 0); + RG_DEF_METHOD(flags, 0); + RG_DEF_METHOD(set_flags, 1); + RG_DEF_METHOD(buffered, 0); + RG_DEF_METHOD(set_buffered, 1); + RG_DEF_METHOD(encoding, 0); + RG_DEF_METHOD(set_encoding, 1); + + /* GSeekType */ + rb_define_const(RG_TARGET_NAMESPACE, "SEEK_CUR", INT2NUM(G_SEEK_CUR)); + rb_define_const(RG_TARGET_NAMESPACE, "SEEK_SET", INT2NUM(G_SEEK_SET)); + rb_define_const(RG_TARGET_NAMESPACE, "SEEK_END", INT2NUM(G_SEEK_END)); + + /* GIOStatus */ + rb_define_const(RG_TARGET_NAMESPACE, "STATUS_ERROR", INT2NUM(G_IO_STATUS_ERROR)); + rb_define_const(RG_TARGET_NAMESPACE, "STATUS_NORMAL", INT2NUM(G_IO_STATUS_NORMAL)); + rb_define_const(RG_TARGET_NAMESPACE, "STATUS_EOF", INT2NUM(G_IO_STATUS_EOF)); + rb_define_const(RG_TARGET_NAMESPACE, "STATUS_AGAIN", INT2NUM(G_IO_STATUS_AGAIN)); + + /* GIOCondition */ + /* Deprecated. Just for bacakward compatibility. Use + * GLib::IOCondition::* instead. */ + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_IO_CONDITION, "G_IO_"); + + /* GIOFlags */ + rb_define_const(RG_TARGET_NAMESPACE, "FLAG_APPEND", INT2NUM(G_IO_FLAG_APPEND)); + rb_define_const(RG_TARGET_NAMESPACE, "FLAG_NONBLOCK", INT2NUM(G_IO_FLAG_NONBLOCK)); + rb_define_const(RG_TARGET_NAMESPACE, "FLAG_READABLE", INT2NUM(G_IO_FLAG_IS_READABLE)); + rb_define_const(RG_TARGET_NAMESPACE, "FLAG_WRITEABLE", INT2NUM(G_IO_FLAG_IS_WRITEABLE)); + rb_define_const(RG_TARGET_NAMESPACE, "FLAG_IS_SEEKABLE", INT2NUM(G_IO_FLAG_IS_SEEKABLE)); + rb_define_const(RG_TARGET_NAMESPACE, "FLAG_MASK", INT2NUM(G_IO_FLAG_MASK)); + rb_define_const(RG_TARGET_NAMESPACE, "FLAG_GET_MASK", INT2NUM(G_IO_FLAG_GET_MASK)); + rb_define_const(RG_TARGET_NAMESPACE, "FLAG_SET_MASK", INT2NUM(G_IO_FLAG_SET_MASK)); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_iochannel_win32_socket.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_iochannel_win32_socket.c new file mode 100644 index 0000000..da28872 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_iochannel_win32_socket.c @@ -0,0 +1,56 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#ifdef G_OS_WIN32 + +#define RG_TARGET_NAMESPACE cIOChannelWin32Socket + +static VALUE +rg_initialize(VALUE self, VALUE socket) +{ + GIOChannel *io = NULL; + int fd; + + rb_secure(4); + /* TODO: support IO object */ + fd = NUM2INT(socket); + io = g_io_channel_win32_new_socket(rb_w32_get_osfhandle(fd)); + G_INITIALIZE(self, io); + + return Qnil; +} +#endif + +void +Init_glib_io_channel_win32_socket(void) +{ +#ifdef G_OS_WIN32 + /* GIOWin32Channel */ + VALUE RG_TARGET_NAMESPACE; + RG_TARGET_NAMESPACE = + rb_define_class_under(mGLib, + "IOChannelWin32Socket", + rb_const_get(mGLib, rb_intern("IOChannel"))); + RG_DEF_METHOD(initialize, 1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_iochannelerror.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_iochannelerror.c new file mode 100644 index 0000000..82fbedf --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_iochannelerror.c @@ -0,0 +1,49 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#define RG_TARGET_NAMESPACE cIOChannelError + +static VALUE +rg_s_from_errno(G_GNUC_UNUSED VALUE self, VALUE errno_) +{ + return INT2NUM(g_io_channel_error_from_errno(NUM2INT(errno_))); +} + +void +Init_glib_io_channelerror(void) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_ERROR2(G_IO_CHANNEL_ERROR, "IOChannelError", mGLib, rb_eIOError); + + /* GIOChannelError */ + RG_DEF_SMETHOD(from_errno, 1); + + rb_define_const(RG_TARGET_NAMESPACE, "FBIG", INT2NUM(G_IO_CHANNEL_ERROR_FBIG)); + rb_define_const(RG_TARGET_NAMESPACE, "INVAL", INT2NUM(G_IO_CHANNEL_ERROR_INVAL)); + rb_define_const(RG_TARGET_NAMESPACE, "IO", INT2NUM(G_IO_CHANNEL_ERROR_IO)); + rb_define_const(RG_TARGET_NAMESPACE, "ISDIR", INT2NUM(G_IO_CHANNEL_ERROR_ISDIR)); + rb_define_const(RG_TARGET_NAMESPACE, "NOSPC", INT2NUM(G_IO_CHANNEL_ERROR_NOSPC)); + rb_define_const(RG_TARGET_NAMESPACE, "NXIO", INT2NUM(G_IO_CHANNEL_ERROR_NXIO)); + rb_define_const(RG_TARGET_NAMESPACE, "OVERFLOW", INT2NUM(G_IO_CHANNEL_ERROR_OVERFLOW)); + rb_define_const(RG_TARGET_NAMESPACE, "PIPE", INT2NUM(G_IO_CHANNEL_ERROR_PIPE)); + rb_define_const(RG_TARGET_NAMESPACE, "FAILED", INT2NUM(G_IO_CHANNEL_ERROR_FAILED)); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_keyfile.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_keyfile.c new file mode 100644 index 0000000..d2346f9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_keyfile.c @@ -0,0 +1,775 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#if GLIB_CHECK_VERSION(2,6,0) +#if !GLIB_CHECK_VERSION(2,31,2) +/************************************************/ +static GKeyFile* +keyfile_copy(const GKeyFile* keyfile) +{ +// GKeyFile* new_keyfile; + g_return_val_if_fail (keyfile != NULL, NULL); +/* + new_keyfile = g_key_file_new(); + *new_keyfile = (GKeyFile*)*keyfile; + return new_keyfile; +*/ + return (GKeyFile*)keyfile; +} + +GType +g_key_file_get_type(void) +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static("GKeyFile", + (GBoxedCopyFunc)keyfile_copy, + (GBoxedFreeFunc)g_key_file_free); + return our_type; +} +/************************************************/ +#endif + +#define RG_TARGET_NAMESPACE cKeyFile +#define _SELF(self) ((GKeyFile*)(RVAL2BOXED(self, G_TYPE_KEY_FILE))) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, g_key_file_new()); + return Qnil; +} + +static VALUE +rg_set_list_separator(VALUE self, VALUE sep) +{ + g_key_file_set_list_separator(_SELF(self), NUM2INT(sep)); + return self; +} + +static VALUE +rg_load_from_file(int argc, VALUE *argv, VALUE self) +{ + VALUE file, flags; + GError* error = NULL; + gboolean ret; + GKeyFileFlags gflags = G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS; + + rb_scan_args(argc, argv, "11", &file, &flags); + + if (!NIL_P(flags)){ + gflags = RVAL2GFLAGS(flags, G_TYPE_KEY_FILE_FLAGS); + } + + ret = g_key_file_load_from_file(_SELF(self), + RVAL2CSTR(file), + gflags, &error); + + if (! ret) RAISE_GERROR(error); + + return self; +} + +static VALUE +rg_load_from_data(int argc, VALUE *argv, VALUE self) +{ + VALUE data, flags; + GError* error = NULL; + gboolean ret; + GKeyFileFlags gflags = G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS; + + rb_scan_args(argc, argv, "11", &data, &flags); + + if (!NIL_P(flags)){ + gflags = RVAL2GFLAGS(flags, G_TYPE_KEY_FILE_FLAGS); + } + StringValue(data); + + ret = g_key_file_load_from_data(_SELF(self), + (const gchar*)RVAL2CSTR(data), + (gsize)RSTRING_LEN(data), + gflags, &error); + + if (! ret) RAISE_GERROR(error); + + return self; +} + +static VALUE +rg_load_from_data_dirs(int argc, VALUE *argv, VALUE self) +{ + VALUE file, flags; + GError* error = NULL; + gboolean ret; + gchar* full_path; + GKeyFileFlags gflags = G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS; + + rb_scan_args(argc, argv, "11", &file, &flags); + + if (!NIL_P(flags)){ + gflags = RVAL2GFLAGS(flags, G_TYPE_KEY_FILE_FLAGS); + } + StringValue(file); + + ret = g_key_file_load_from_data_dirs(_SELF(self), + (const gchar*)RVAL2CSTR(file), + &full_path, + gflags, &error); + + if (! ret) RAISE_GERROR(error); + + return full_path ? CSTR2RVAL(full_path) : Qnil; +} + +#if GLIB_CHECK_VERSION(2, 14, 0) +static VALUE +rg_load_from_dirs(int argc, VALUE *argv, VALUE self) +{ + VALUE rb_file, rb_search_dirs, rb_flags; + GError* error = NULL; + gboolean success; + const gchar *file; + const gchar **search_dirs; + gchar* full_path; + GKeyFileFlags flags; + + rb_scan_args(argc, argv, "12", &rb_file, &rb_search_dirs, &rb_flags); + + file = RVAL2CSTR(rb_file); + search_dirs = RVAL2STRV_ACCEPT_NIL(rb_search_dirs); + flags = G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS; + if (!NIL_P(rb_flags)) + flags = RVAL2GFLAGS(rb_flags, G_TYPE_KEY_FILE_FLAGS); + + if (search_dirs != NULL) + success = g_key_file_load_from_dirs(_SELF(self), file, + search_dirs, + &full_path, flags, &error); + else + success = g_key_file_load_from_data_dirs(_SELF(self), file, + &full_path, flags, &error); + + g_free(search_dirs); + + if (!success) + RAISE_GERROR(error); + + return CSTR2RVAL(full_path); +} +#endif + +static VALUE +rg_to_data(VALUE self) +{ + GError* error = NULL; + gchar* data = g_key_file_to_data(_SELF(self), NULL, &error); + + if (error) RAISE_GERROR(error); + + return CSTR2RVAL_FREE(data); +} + +static VALUE +rg_start_group(VALUE self) +{ + return CSTR2RVAL(g_key_file_get_start_group(_SELF(self))); +} + +static VALUE +rg_groups(VALUE self) +{ + return STRV2RVAL_FREE(g_key_file_get_groups(_SELF(self), NULL)); +} + +static VALUE +rg_get_keys(VALUE self, VALUE group_name) +{ + GError *error = NULL; + gchar **keys = g_key_file_get_keys(_SELF(self), + RVAL2CSTR(group_name), + NULL, + &error); + if (error != NULL) + RAISE_GERROR(error); + + return STRV2RVAL_FREE(keys); +} + +static VALUE +rg_has_group_p(VALUE self, VALUE group_name) +{ + return CBOOL2RVAL(g_key_file_has_group(_SELF(self), + (const gchar*)RVAL2CSTR(group_name))); +} + +static VALUE +rg_has_key_p(VALUE self, VALUE group_name, VALUE key) +{ + GError* error = NULL; + gboolean ret = g_key_file_has_key(_SELF(self), + (const gchar*)RVAL2CSTR(group_name), + (const gchar*)RVAL2CSTR(key), + &error); + + if (error) RAISE_GERROR(error); + + return CBOOL2RVAL(ret); +} + +static VALUE +rg_get_value(VALUE self, VALUE group_name, VALUE key) +{ + GError* error = NULL; + gchar* ret = g_key_file_get_value(_SELF(self), + (const gchar*)RVAL2CSTR(group_name), + (const gchar*)RVAL2CSTR(key), + &error); + + if (error) RAISE_GERROR(error); + + return CSTR2RVAL_FREE(ret); +} + +static VALUE +rg_get_string(VALUE self, VALUE group_name, VALUE key) +{ + GError* error = NULL; + gchar* ret = g_key_file_get_string(_SELF(self), + (const gchar*)RVAL2CSTR(group_name), + (const gchar*)RVAL2CSTR(key), + &error); + + if (error) RAISE_GERROR(error); + + return CSTR2RVAL_FREE(ret); +} + +static VALUE +rg_get_locale_string(int argc, VALUE *argv, VALUE self) +{ + VALUE group_name, key, locale; + GError* error = NULL; + gchar* ret; + + rb_scan_args(argc, argv, "21", &group_name, &key, &locale); + + ret = g_key_file_get_locale_string(_SELF(self), + (const gchar*)RVAL2CSTR(group_name), + (const gchar*)RVAL2CSTR(key), + (const gchar*)RVAL2CSTR_ACCEPT_NIL(locale), + &error); + + if (error) RAISE_GERROR(error); + + return CSTR2RVAL_FREE(ret); +} + +static VALUE +rg_get_boolean(VALUE self, VALUE group_name, VALUE key) +{ + GError* error = NULL; + gboolean ret = g_key_file_get_boolean(_SELF(self), + (const gchar*)RVAL2CSTR(group_name), + (const gchar*)RVAL2CSTR(key), + &error); + + if (error) RAISE_GERROR(error); + + return CBOOL2RVAL(ret); +} + +static VALUE +rg_get_integer(VALUE self, VALUE group_name, VALUE key) +{ + GError* error = NULL; + gint ret = g_key_file_get_integer(_SELF(self), + (const gchar*)RVAL2CSTR(group_name), + (const gchar*)RVAL2CSTR(key), + &error); + + if (error) RAISE_GERROR(error); + + return INT2NUM(ret); +} + +#if GLIB_CHECK_VERSION(2,12,0) +static VALUE +rg_get_double(VALUE self, VALUE group_name, VALUE key) +{ + GError* error = NULL; + gdouble ret = g_key_file_get_double(_SELF(self), + (const gchar*)RVAL2CSTR(group_name), + (const gchar*)RVAL2CSTR(key), + &error); + + if (error) RAISE_GERROR(error); + + return rb_float_new(ret); +} +#endif + +static VALUE +rg_get_string_list(VALUE self, VALUE group_name, VALUE key) +{ + VALUE ary; + gsize i; + gsize length; + GError* error = NULL; + gchar** ret = g_key_file_get_string_list(_SELF(self), + (const gchar*)RVAL2CSTR(group_name), + (const gchar*)RVAL2CSTR(key), + &length, &error); + + if (error) RAISE_GERROR(error); + + ary = rb_ary_new(); + for(i = 0; i < length; i++){ + rb_ary_push(ary, CSTR2RVAL(ret[i])); + } + + g_strfreev(ret); + return ary; +} + +static VALUE +rg_get_locale_string_list(int argc, VALUE *argv, VALUE self) +{ + VALUE group_name, key, locale; + GError* error = NULL; + VALUE ary; + gsize i; + gsize length; + gchar** ret; + + rb_scan_args(argc, argv, "21", &group_name, &key, &locale); + + ret = g_key_file_get_locale_string_list(_SELF(self), + (const gchar*)RVAL2CSTR(group_name), + (const gchar*)RVAL2CSTR(key), + (const gchar*)RVAL2CSTR_ACCEPT_NIL(locale), + &length, &error); + + if (error) RAISE_GERROR(error); + + ary = rb_ary_new(); + for(i = 0; i < length; i++){ + rb_ary_push(ary, CSTR2RVAL(ret[i])); + } + + g_strfreev(ret); + return ary; +} + +static VALUE +rg_get_boolean_list(VALUE self, VALUE group_name, VALUE key) +{ + VALUE ary; + gsize i; + gsize length; + GError* error = NULL; + gboolean* ret = g_key_file_get_boolean_list(_SELF(self), + (const gchar*)RVAL2CSTR(group_name), + (const gchar*)RVAL2CSTR(key), + &length, &error); + + if (error) RAISE_GERROR(error); + + ary = rb_ary_new(); + for(i = 0; i < length; i++){ + rb_ary_push(ary, CBOOL2RVAL(ret[i])); + } + return ary; +} + +static VALUE +rg_get_integer_list(VALUE self, VALUE group_name, VALUE key) +{ + VALUE ary; + gsize i; + gsize length; + GError* error = NULL; + gint* ret = g_key_file_get_integer_list(_SELF(self), + (const gchar*)RVAL2CSTR(group_name), + (const gchar*)RVAL2CSTR(key), + &length, &error); + + if (error) RAISE_GERROR(error); + + ary = rb_ary_new(); + for(i = 0; i < length; i++){ + rb_ary_push(ary, INT2NUM(ret[i])); + } + return ary; +} + +#if GLIB_CHECK_VERSION(2,12,0) +static VALUE +rg_get_double_list(VALUE self, VALUE group_name, VALUE key) +{ + VALUE ary; + gsize i; + gsize length; + GError* error = NULL; + gdouble* ret = g_key_file_get_double_list(_SELF(self), + (const gchar*)RVAL2CSTR(group_name), + (const gchar*)RVAL2CSTR(key), + &length, &error); + + if (error) RAISE_GERROR(error); + + ary = rb_ary_new(); + for(i = 0; i < length; i++){ + rb_ary_push(ary, rb_float_new(ret[i])); + } + return ary; +} +#endif + +static VALUE +rg_get_comment(VALUE self, VALUE group_name, VALUE key) +{ + GError* error = NULL; + gchar* ret = g_key_file_get_comment(_SELF(self), + (const gchar*)RVAL2CSTR(group_name), + (const gchar*)RVAL2CSTR(key), + &error); + + if (error) RAISE_GERROR(error); + + return CSTR2RVAL_FREE(ret); +} + +static VALUE +rg_set_value(VALUE self, VALUE group_name, VALUE key, VALUE value) +{ + g_key_file_set_value(_SELF(self), (const gchar*)RVAL2CSTR(group_name), + (const gchar*)RVAL2CSTR(key), + (const gchar*)RVAL2CSTR(value)); + return self; +} + +static VALUE +rg_set_string(VALUE self, VALUE group_name, VALUE key, VALUE string) +{ + g_key_file_set_string(_SELF(self), (const gchar*)RVAL2CSTR(group_name), + (const gchar*)RVAL2CSTR(key), + (const gchar*)RVAL2CSTR(string)); + return self; +} + +static VALUE +rg_set_locale_string(VALUE self, VALUE group_name, VALUE key, VALUE locale, VALUE locale_string) +{ + g_key_file_set_locale_string(_SELF(self), (const gchar*)RVAL2CSTR(group_name), + (const gchar*)RVAL2CSTR(key), + (const gchar*)RVAL2CSTR(locale), + (const gchar*)RVAL2CSTR(locale_string)); + return self; +} + +static VALUE +rg_set_boolean(VALUE self, VALUE group_name, VALUE key, VALUE value) +{ + g_key_file_set_boolean(_SELF(self), (const gchar*)RVAL2CSTR(group_name), + (const gchar*)RVAL2CSTR(key), + RVAL2CBOOL(value)); + return self; +} + +static VALUE +rg_set_integer(VALUE self, VALUE group_name, VALUE key, VALUE value) +{ + g_key_file_set_integer(_SELF(self), (const gchar*)RVAL2CSTR(group_name), + (const gchar*)RVAL2CSTR(key), + NUM2INT(value)); + return self; +} + +#if GLIB_CHECK_VERSION(2,12,0) +static VALUE +rg_set_double(VALUE self, VALUE group_name, VALUE key, VALUE value) +{ + g_key_file_set_double(_SELF(self), (const gchar*)RVAL2CSTR(group_name), + (const gchar*)RVAL2CSTR(key), + NUM2DBL(value)); + return self; +} +#endif + +static VALUE +rg_set_string_list(VALUE self, VALUE rbgroup_name, VALUE rbkey, VALUE rblist) +{ + GKeyFile *key_file = _SELF(self); + const gchar *group_name = RVAL2CSTR(rbgroup_name); + const gchar *key = RVAL2CSTR(rbkey); + long n; + const gchar **list = RVAL2STRS(rblist, n); + + g_key_file_set_string_list(key_file, group_name, key, list, n); + + g_free(list); + + return self; +} + +static VALUE +rg_set_locale_string_list(VALUE self, VALUE rbgroup_name, VALUE rbkey, VALUE rblocale, VALUE rblist) +{ + GKeyFile *key_file = _SELF(self); + const gchar *group_name = RVAL2CSTR(rbgroup_name); + const gchar *key = RVAL2CSTR(rbkey); + const gchar *locale = RVAL2CSTR(rblocale); + long n; + const gchar **list = RVAL2STRS(rblist, n); + + g_key_file_set_locale_string_list(key_file, group_name, key, locale, list, n); + + g_free(list); + + return self; +} + +static VALUE +rg_set_boolean_list(VALUE self, VALUE rbgroup_name, VALUE rbkey, VALUE rblist) +{ + GKeyFile *key_file = _SELF(self); + const gchar *group_name = RVAL2CSTR(rbgroup_name); + const gchar *key = RVAL2CSTR(rbkey); + long n; + gboolean *list = RVAL2GBOOLEANS(rblist, n); + + g_key_file_set_boolean_list(key_file, group_name, key, list, n); + + g_free(list); + + return self; +} + +static VALUE +rg_set_integer_list(VALUE self, VALUE rbgroup_name, VALUE rbkey, VALUE rblist) +{ + GKeyFile *key_file = _SELF(self); + const gchar *group_name = RVAL2CSTR(rbgroup_name); + const gchar *key = RVAL2CSTR(rbkey); + long n; + gint *list = RVAL2GINTS(rblist, n); + + g_key_file_set_integer_list(key_file, group_name, key, list, n); + + g_free(list); + + return self; +} + +#if GLIB_CHECK_VERSION(2,12,0) +static VALUE +rg_set_double_list(VALUE self, VALUE rbgroup_name, VALUE rbkey, VALUE rblist) +{ + GKeyFile *key_file = _SELF(self); + const gchar *group_name = RVAL2CSTR(rbgroup_name); + const gchar *key = RVAL2CSTR(rbkey); + long n; + gdouble *list = RVAL2GDOUBLES(rblist, n); + + g_key_file_set_double_list(key_file, group_name, key, list, n); + + return self; +} +#endif + +static VALUE +rg_set_comment(VALUE self, VALUE group_name, VALUE key, VALUE comment) +{ + GError* error = NULL; + + g_key_file_set_comment(_SELF(self), + RVAL2CSTR(group_name), + RVAL2CSTR_ACCEPT_NIL(key), + RVAL2CSTR(comment), + &error); + if (error != NULL) + RAISE_GERROR(error); + + return self; +} + +static VALUE +rg_remove_group(VALUE self, VALUE group_name) +{ + GError* error = NULL; + + g_key_file_remove_group(_SELF(self), RVAL2CSTR(group_name), &error); + + if (error != NULL) + RAISE_GERROR(error); + + return self; +} + +static VALUE +rg_remove_key(VALUE self, VALUE group_name, VALUE key) +{ + GError* error = NULL; + + g_key_file_remove_key(_SELF(self), + RVAL2CSTR(group_name), + RVAL2CSTR(key), + &error); + + if (error != NULL) + RAISE_GERROR(error); + + return self; +} + +static VALUE +rg_remove_comment(VALUE self, VALUE group_name, VALUE key) +{ + GError* error = NULL; + + g_key_file_remove_comment(_SELF(self), + RVAL2CSTR(group_name), + RVAL2CSTR(key), + &error); + + if (error != NULL) + RAISE_GERROR(error); + + return self; +} +#endif + +void +Init_glib_keyfile(void) +{ +#if GLIB_CHECK_VERSION(2,6,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_KEY_FILE, "KeyFile", mGLib); + G_DEF_ERROR(G_KEY_FILE_ERROR, "KeyFileError", mGLib, + rb_eRuntimeError, G_TYPE_KEY_FILE_ERROR); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(set_list_separator, 1); + RG_DEF_METHOD(load_from_file, -1); + RG_DEF_METHOD(load_from_data, -1); + RG_DEF_METHOD(load_from_data_dirs, -1); +#if GLIB_CHECK_VERSION(2, 14, 0) + RG_DEF_METHOD(load_from_dirs, -1); +#endif + RG_DEF_METHOD(to_data, 0); + RG_DEF_METHOD(start_group, 0); + RG_DEF_METHOD(groups, 0); + RG_DEF_METHOD(get_keys, 1); + RG_DEF_METHOD_P(has_group, 1); + RG_DEF_METHOD_P(has_key, 2); + RG_DEF_METHOD(get_value, 2); + RG_DEF_METHOD(get_string, 2); + RG_DEF_METHOD(get_locale_string, -1); + RG_DEF_METHOD(get_boolean, 2); + RG_DEF_METHOD(get_integer, 2); +#if GLIB_CHECK_VERSION(2,12,0) + RG_DEF_METHOD(get_double, 2); +#endif + RG_DEF_METHOD(get_string_list, 2); + RG_DEF_METHOD(get_locale_string_list, -1); + RG_DEF_METHOD(get_boolean_list, 2); + RG_DEF_METHOD(get_integer_list, 2); +#if GLIB_CHECK_VERSION(2,12,0) + RG_DEF_METHOD(get_double_list, 2); +#endif + RG_DEF_METHOD(get_comment, 2); + RG_DEF_METHOD(set_value, 3); + RG_DEF_METHOD(set_string, 3); + RG_DEF_METHOD(set_locale_string, 4); + RG_DEF_METHOD(set_boolean, 3); + RG_DEF_METHOD(set_integer, 3); +#if GLIB_CHECK_VERSION(2,12,0) + RG_DEF_METHOD(set_double, 3); +#endif + RG_DEF_METHOD(set_string_list, 3); + RG_DEF_METHOD(set_locale_string_list, 4); + RG_DEF_METHOD(set_boolean_list, 3); + RG_DEF_METHOD(set_integer_list, 3); +#if GLIB_CHECK_VERSION(2,12,0) + RG_DEF_METHOD(set_double_list, 3); +#endif + RG_DEF_METHOD(set_comment, 3); + RG_DEF_METHOD(remove_group, 1); + RG_DEF_METHOD(remove_key, 2); + RG_DEF_METHOD(remove_comment, 2); + + /* GKeyFileFlags */ + G_DEF_CLASS(G_TYPE_KEY_FILE_FLAGS, "Flags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_KEY_FILE_FLAGS, "G_KEY_FILE_"); + +#if GLIB_CHECK_VERSION(2, 14, 0) + /* Defines for handling freedesktop.org Desktop files */ + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_GROUP", CSTR2RVAL(G_KEY_FILE_DESKTOP_GROUP)); + + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_KEY_TYPE", + CSTR2RVAL(G_KEY_FILE_DESKTOP_KEY_TYPE)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_KEY_VERSION", + CSTR2RVAL(G_KEY_FILE_DESKTOP_KEY_VERSION)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_KEY_NAME", + CSTR2RVAL(G_KEY_FILE_DESKTOP_KEY_NAME)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_KEY_GENERIC_NAME", + CSTR2RVAL(G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_KEY_NO_DISPLAY", + CSTR2RVAL(G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_KEY_COMMENT", + CSTR2RVAL(G_KEY_FILE_DESKTOP_KEY_COMMENT)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_KEY_ICON", + CSTR2RVAL(G_KEY_FILE_DESKTOP_KEY_ICON)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_KEY_HIDDEN", + CSTR2RVAL(G_KEY_FILE_DESKTOP_KEY_HIDDEN)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_KEY_ONLY_SHOW_IN", + CSTR2RVAL(G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_KEY_NOT_SHOW_IN", + CSTR2RVAL(G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_KEY_TRY_EXEC", + CSTR2RVAL(G_KEY_FILE_DESKTOP_KEY_TRY_EXEC)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_KEY_EXEC", + CSTR2RVAL(G_KEY_FILE_DESKTOP_KEY_EXEC)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_KEY_PATH", + CSTR2RVAL(G_KEY_FILE_DESKTOP_KEY_PATH)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_KEY_TERMINAL", + CSTR2RVAL(G_KEY_FILE_DESKTOP_KEY_TERMINAL)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_KEY_MIME_TYPE", + CSTR2RVAL(G_KEY_FILE_DESKTOP_KEY_MIME_TYPE)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_KEY_CATEGORIES", + CSTR2RVAL(G_KEY_FILE_DESKTOP_KEY_CATEGORIES)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_KEY_STARTUP_NOTIFY", + CSTR2RVAL(G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_KEY_STARTUP_WM_CLASS", + CSTR2RVAL(G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_KEY_URL", + CSTR2RVAL(G_KEY_FILE_DESKTOP_KEY_URL)); + + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_TYPE_APPLICATION", + CSTR2RVAL(G_KEY_FILE_DESKTOP_TYPE_APPLICATION)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_TYPE_LINK", + CSTR2RVAL(G_KEY_FILE_DESKTOP_TYPE_LINK)); + rb_define_const(RG_TARGET_NAMESPACE, "DESKTOP_TYPE_DIRECTORY", + CSTR2RVAL(G_KEY_FILE_DESKTOP_TYPE_DIRECTORY)); +#endif +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_maincontext.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_maincontext.c new file mode 100644 index 0000000..2697281 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_maincontext.c @@ -0,0 +1,925 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#ifndef HAVE_RB_THREAD_BLOCKING_REGION +# include +# include +# include +# include +# ifdef HAVE_CURR_THREAD +# define rb_curr_thread curr_thread +# endif +#endif + +GStaticPrivate rg_polling_key = G_STATIC_PRIVATE_INIT; + +/* +static ID id_poll_func; +*/ +static ID id_call; + +static VALUE mGLibSource; +static ID id__callbacks__; +static GHashTable *callbacks_table; + +typedef struct _callback_info_t +{ + VALUE callback; + guint id; +} callback_info_t; + +/*****************************************/ +static GPollFunc default_poll_func; + +#ifdef HAVE_RB_THREAD_BLOCKING_REGION + +/* just for ruby-1.9.0. */ +#if !defined(RUBY_UBF_IO) && defined(RB_UBF_DFL) +# define RUBY_UBF_IO RB_UBF_DFL +#endif + +typedef struct _PollInfo +{ + GPollFD *ufds; + guint nfsd; + gint timeout; + gint result; +} PollInfo; + +static VALUE +rg_poll_in_blocking(void *data) +{ + PollInfo *info = data; + + info->result = default_poll_func(info->ufds, info->nfsd, info->timeout); + + return Qnil; +} + +static gint +rg_poll(GPollFD *ufds, guint nfsd, gint timeout) +{ + PollInfo info; + + info.ufds = ufds; + info.nfsd = nfsd; + info.timeout = timeout; + info.result = 0; + + g_static_private_set(&rg_polling_key, GINT_TO_POINTER(TRUE), NULL); + rb_thread_blocking_region(rg_poll_in_blocking, &info, RUBY_UBF_IO, NULL); + g_static_private_set(&rg_polling_key, GINT_TO_POINTER(FALSE), NULL); + + return info.result; +} + +static VALUE +ruby_source_set_priority (G_GNUC_UNUSED VALUE self, G_GNUC_UNUSED VALUE priority) +{ + return Qnil; +} + +#else +static gint +rg_poll(GPollFD *ufds, guint nfsd, gint timeout) +{ + gint result; + + TRAP_BEG; + result = default_poll_func(ufds, nfsd, timeout); + TRAP_END; + + return result; +} +#endif + +static void +restore_poll_func(G_GNUC_UNUSED VALUE data) +{ + if (g_main_context_get_poll_func(NULL) == (GPollFunc)rg_poll) { + g_main_context_set_poll_func(NULL, default_poll_func); + } +} + +#ifndef HAVE_RB_THREAD_BLOCKING_REGION +static guint ruby_source_id = 0; + +/* from eval.c */ +#define WAIT_FD (1<<0) +#define WAIT_SELECT (1<<1) +#define WAIT_TIME (1<<2) +#define WAIT_JOIN (1<<3) +#define WAIT_PID (1<<4) + +#define DELAY_INFTY 1E30 + +#ifdef RUBY_RELEASE_YEAR +# define CHECK_RUBY_RELEASE_DATE(year, month, day) \ + (RUBY_RELEASE_YEAR >= (year) && \ + RUBY_RELEASE_MONTH >= (month) && \ + RUBY_RELEASE_DAY >= (day)) +#else +# define CHECK_RUBY_RELEASE_DATE(year, month, day) 0 +#endif + +static double +timeofday(void) +{ + struct timeval tv; +#if CHECK_RUBY_RELEASE_DATE(2009, 1, 7) +/* The following CLOCK_MONOTONIC change was introduced into + * Ruby 1.8.6 and 1.8.7 at 2009-01-07. + * + * 1.8.6: + * Wed Jan 7 10:06:12 2009 Nobuyoshi Nakada + * + * * eval.c (timeofday): use monotonic clock. based on a patch + * from zimbatm in [ruby-core:16627]. + * + * 1.8.7: + * Wed Jan 7 10:09:46 2009 Nobuyoshi Nakada + * + * * eval.c (timeofday): use monotonic clock. based on a patch + * from zimbatm in [ruby-core:16627]. + */ +# ifdef CLOCK_MONOTONIC + struct timespec tp; + + if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) { + return (double)tp.tv_sec + (double)tp.tv_nsec * 1e-9; + } +# endif +#endif + gettimeofday(&tv, NULL); + return (double)tv.tv_sec + (double)tv.tv_usec * 1e-6; +} + +/*****************************************/ +typedef struct _RGSource +{ + GSource source; + + GList *poll_fds; + GList *old_poll_fds; + gboolean ready; +} RGSource; + +static void +source_cleanup_poll_fds(GSource *source) +{ + RGSource *rg_source = (RGSource *)source; + GList *node; + + for (node = rg_source->old_poll_fds; node; node = g_list_next(node)) { + GPollFD *poll_fd = node->data; + + g_source_remove_poll(source, poll_fd); + g_slice_free(GPollFD, poll_fd); + } + g_list_free(rg_source->old_poll_fds); + rg_source->old_poll_fds = NULL; +} + +static inline void +source_prepare_add_poll_fd(GSource *source, gint fd, guchar events) +{ + GPollFD *poll_fd; + GList *node; + RGSource *rg_source = (RGSource *)source; + + for (node = rg_source->old_poll_fds; node; node = g_list_next(node)) { + poll_fd = node->data; + if (poll_fd->fd == fd && poll_fd->events == events) { + rg_source->old_poll_fds = + g_list_remove_link(rg_source->old_poll_fds, node); + rg_source->poll_fds = g_list_concat(rg_source->poll_fds, node); + return; + } + } + + poll_fd = g_slice_new0(GPollFD); + poll_fd->fd = fd; + poll_fd->events = events; + + g_source_add_poll(source, poll_fd); + rg_source->poll_fds = g_list_prepend(rg_source->poll_fds, poll_fd); +} + +static inline void +source_prepare_add_poll(GSource *source, rb_thread_t thread) +{ + if (thread->wait_for == WAIT_FD) { + /* The thread is blocked on thread->fd for read. */ + source_prepare_add_poll_fd(source, thread->fd, G_IO_IN); + return; + } + + if (thread->wait_for & WAIT_SELECT) { + /* thread->fd is the maximum fd of the fds in the various sets. Need to + * check the sets to see which fd's to wait for */ + int fd; + + for (fd = 0; fd < thread->fd; fd++) { + gushort events = 0; + + if (FD_ISSET(fd, &thread->readfds)) + events |= G_IO_IN; + if (FD_ISSET(fd, &thread->writefds)) + events |= G_IO_OUT; + if (FD_ISSET(fd, &thread->exceptfds)) + events |= G_IO_PRI | G_IO_ERR | G_IO_HUP; + + if (events != 0) + source_prepare_add_poll_fd(source, fd, events); + } + } +} + +static inline gboolean +source_prepare_setup_poll_fd(GSource *source, gint *timeout) +{ + RGSource *rg_source = (RGSource *)source; + rb_thread_t thread; + gdouble now; + + g_assert(rg_source->old_poll_fds == NULL); + rg_source->old_poll_fds = rg_source->poll_fds; + rg_source->poll_fds = NULL; + + now = timeofday(); + thread = rb_curr_thread; + do { + thread = thread->next; + + if ((thread->wait_for == 0 && thread->status == THREAD_RUNNABLE && + thread != rb_curr_thread) || + (thread->wait_for & WAIT_JOIN && + thread->join->status == THREAD_KILLED)) { + rg_source->poll_fds = g_list_concat(rg_source->poll_fds, + rg_source->old_poll_fds); + rg_source->old_poll_fds = NULL; + return TRUE; + } + + if (thread->wait_for & WAIT_TIME && thread->delay != DELAY_INFTY) { + gint delay; + + delay = (thread->delay - now) * 1000; + if (delay <= 0) { + rg_source->poll_fds = g_list_concat(rg_source->poll_fds, + rg_source->old_poll_fds); + rg_source->old_poll_fds = NULL; + return TRUE; + } + if (*timeout == -1 || delay < *timeout) + *timeout = delay; + } + + if (thread->wait_for == WAIT_FD || thread->wait_for & WAIT_SELECT) + source_prepare_add_poll(source, thread); + } while (thread != rb_curr_thread); + + source_cleanup_poll_fds(source); + + return FALSE; +} + +static gboolean +source_prepare(GSource *source, gint *timeout) +{ + RGSource *rg_source = (RGSource *)source; + + *timeout = -1; + rg_source->ready = source_prepare_setup_poll_fd(source, timeout); + + return rg_source->ready; +} + +static gboolean +source_check(GSource *source) +{ + RGSource *rg_source = (RGSource *)source; + GList *node; + + if (rg_source->ready) + return TRUE; + + for (node = rg_source->poll_fds; node; node = g_list_next(node)) { + GPollFD *poll_fd = node->data; + + if (poll_fd->revents) + return TRUE; + } + + return FALSE; +} + +static gboolean +source_dispatch(G_GNUC_UNUSED GSource *source, + G_GNUC_UNUSED GSourceFunc callback, + G_GNUC_UNUSED gpointer user_data) +{ + TRAP_BEG; + rb_thread_schedule(); + TRAP_END; + + return TRUE; +} + +static void +source_finalize(GSource *source) +{ + RGSource *rg_source = (RGSource *)source; + GList *node; + + for (node = rg_source->old_poll_fds; node; node = g_list_next(node)) { + GPollFD *poll_fd = node->data; + g_slice_free(GPollFD, poll_fd); + } + + for (node = rg_source->poll_fds; node; node = g_list_next(node)) { + GPollFD *poll_fd = node->data; + g_slice_free(GPollFD, poll_fd); + } + + g_list_free(rg_source->old_poll_fds); + rg_source->old_poll_fds = NULL; + + g_list_free(rg_source->poll_fds); + rg_source->poll_fds = NULL; +} + +static GSourceFuncs source_funcs = { + source_prepare, + source_check, + source_dispatch, + source_finalize, + NULL, + NULL +}; + +static GSource * +ruby_source_new(void) +{ + GSource *source; + RGSource *rg_source; + + source = g_source_new(&source_funcs, sizeof(RGSource)); + g_source_set_can_recurse(source, TRUE); + + rg_source = (RGSource *)source; + rg_source->poll_fds = NULL; + rg_source->old_poll_fds = NULL; + + return source; +} + +static VALUE +ruby_source_set_priority(G_GNUC_UNUSED VALUE self, VALUE priority) +{ + GSource *ruby_source = NULL; + + if (ruby_source_id != 0) + ruby_source = g_main_context_find_source_by_id(NULL, ruby_source_id); + + if (ruby_source) + g_source_set_priority(ruby_source, NUM2INT(priority)); + + return Qnil; +} +#endif + +static VALUE +source_remove(G_GNUC_UNUSED VALUE self, VALUE tag) +{ + VALUE callback; + callback = G_GET_RELATIVE(mGLibSource, id__callbacks__, tag); + G_REMOVE_RELATIVE(mGLibSource, id__callbacks__, tag); + g_hash_table_remove(callbacks_table, (gpointer)callback); + return CBOOL2RVAL(g_source_remove(NUM2UINT(tag))); +} + +#if GLIB_CHECK_VERSION(2,12,0) +static VALUE +source_current_source(G_GNUC_UNUSED VALUE self) +{ + return BOXED2RVAL(g_main_current_source, G_TYPE_SOURCE); +} +#endif + +static gboolean +invoke_source_func(gpointer data) +{ + callback_info_t *info = (callback_info_t *)data; + gboolean ret; + + ret = RVAL2CBOOL(rb_funcall(info->callback, id_call, 0)); + if (!ret) + G_REMOVE_RELATIVE(mGLibSource, id__callbacks__, UINT2NUM(info->id)); + return ret; +} + +/*****************************************/ +#if !GLIB_CHECK_VERSION(2,30,0) +GType +g_main_context_get_type(void) +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static ("GMainContext", + (GBoxedCopyFunc)g_main_context_ref, + (GBoxedFreeFunc)g_main_context_unref); + return our_type; +} +#endif +/*****************************************/ + +#define RG_TARGET_NAMESPACE cMainContext +#define _SELF(s) ((GMainContext*)RVAL2BOXED(s, G_TYPE_MAIN_CONTEXT)) + +static VALUE +rg_initialize(VALUE self) +{ + GMainContext *context; + + context = g_main_context_new(); + + g_main_context_set_poll_func(context, rg_poll); +#ifndef HAVE_RB_THREAD_BLOCKING_REGION + { + GSource *source; + source = ruby_source_new(); + g_source_attach(source, context); + g_source_unref(source); + } +#endif + + G_INITIALIZE(self, context); + return Qnil; +} + +static VALUE +rg_s_default(G_GNUC_UNUSED VALUE self) +{ + return BOXED2RVAL(g_main_context_default(), G_TYPE_MAIN_CONTEXT); +} + +static VALUE +rg_iteration(VALUE self, VALUE may_block) +{ + return CBOOL2RVAL(g_main_context_iteration(_SELF(self), RVAL2CBOOL(may_block))); +} + +static VALUE +rg_pending_p(VALUE self) +{ + return CBOOL2RVAL(g_main_context_pending(_SELF(self))); +} + +static VALUE +rg_find_source(VALUE self, VALUE source_id) +{ + GSource* src = g_main_context_find_source_by_id(_SELF(self), NUM2UINT(source_id)); + return BOXED2RVAL(src, G_TYPE_SOURCE); +} + +/* +GSource* g_main_context_find_source_by_user_data + (GMainContext *context, + gpointer user_data); +GSource* g_main_context_find_source_by_funcs_user_data + (GMainContext *context, + GSourceFuncs *funcs, + gpointer user_data); +*/ + +static VALUE +rg_wakeup(VALUE self) +{ + g_main_context_wakeup(_SELF(self)); + return self; +} + +static VALUE +rg_acquire(VALUE self) +{ + return CBOOL2RVAL(g_main_context_acquire(_SELF(self))); +} + +static VALUE +rg_release(VALUE self) +{ + g_main_context_release(_SELF(self)); + return self; +} + +#if GLIB_CHECK_VERSION(2,10,0) +static VALUE +rg_owner_p(VALUE self) +{ + return CBOOL2RVAL(g_main_context_is_owner(_SELF(self))); +} +#endif + +/* +gboolean g_main_context_wait (GMainContext *context, + GCond *cond, + GMutex *mutex); +*/ + +static VALUE +rg_prepare(VALUE self) +{ + gint priority; + gboolean ret = g_main_context_prepare(_SELF(self), &priority); + + return rb_assoc_new(CBOOL2RVAL(ret), INT2NUM(priority)); +} + +struct mc_query_body_args { + gint timeout_; + GPollFD *fds; + gint n_fds; +}; + +static VALUE +mc_query_body(VALUE value) +{ + struct mc_query_body_args *args = (struct mc_query_body_args *)value; + gint i; + VALUE ary = rb_ary_new(); + + for (i = 0; i < args->n_fds; i++) + rb_ary_push(ary, BOXED2RVAL(&args->fds[i], G_TYPE_POLL_FD)); + + return rb_assoc_new(INT2NUM(args->timeout_), ary); +} + +static VALUE +mc_query_ensure(VALUE value) +{ + g_free((GPollFD *)value); + + return Qnil; +} + +#define QUERY_DEFAULT_FDS 100 + +static VALUE +rg_query(VALUE self, VALUE rbmax_priority) +{ + GMainContext *context = _SELF(self); + gint max_priority = NUM2INT(rbmax_priority); + gint timeout_; + GPollFD *fds; + gint n_fds; + struct mc_query_body_args args; + + fds = g_new(GPollFD, QUERY_DEFAULT_FDS); + n_fds = g_main_context_query(context, max_priority, &timeout_, fds, QUERY_DEFAULT_FDS); + if (n_fds > QUERY_DEFAULT_FDS) { + g_free(fds); + fds = g_new(GPollFD, n_fds); + g_main_context_query(context, max_priority, &timeout_, fds, n_fds); + } + + args.timeout_ = timeout_; + args.fds = fds; + args.n_fds = n_fds; + return rb_ensure(mc_query_body, (VALUE)&args, + mc_query_ensure, (VALUE)fds); +} + +/* How can I implement this? +static VALUE +rg_check(VALUE self, VALUE max_priority) +{ + gint i, timeout_; + VALUE ary; + + GPollFD* fds; + gint ret, n_fds; + + fds = g_new (GPollFD, 10); + n_fds = g_main_context_query(_SELF(self), NUM2INT(max_priority), + &timeout_, fds, 10); + printf("n_fds = %d\n", n_fds); + + g_free(fds); + fds = g_new (GPollFD, n_fds); + + ret = g_main_context_check(_SELF(self), NUM2INT(max_priority), + fds, n_fds); + printf("ret = %d\n", ret); + ary = rb_ary_new(); + for (i = 0; i < ret; i++) + rb_ary_push(ary, BOXED2RVAL(&fds[i], G_TYPE_POLL_FD)); + + g_free(fds); + return ary; +} +*/ + +static VALUE +rg_dispatch(VALUE self) +{ + g_main_context_dispatch(_SELF(self)); + return self; +} + +/* How can I get "self" or something like it as key .... +static gint +poll_func(GPollFD *ufds, guint nfsd, gint timeout_) +{ + VALUE func = rb_ivar_get(self, id_poll_func); + if (NIL_P(func)) return -1; + + return INT2NUM(rb_funcall(func, 3, BOXED2RVAL(ufds, G_TYPE_POLL_FD), + UINT2NUM(nfsd), INT2NUM(timeout_))); +} + +static VALUE +rg_set_poll_func(VALUE self) +{ + rb_ivar_set(self, id_poll_func, rb_block_proc()); + g_main_context_set_poll_func(_SELF(self), (GPollFunc)poll_func); + + return self; +} +*/ + +/* +GPollFunc g_main_context_get_poll_func (GMainContext *context); +*/ + +static VALUE +rg_add_poll(VALUE self, VALUE fd, VALUE priority) +{ + g_main_context_add_poll(_SELF(self), RVAL2BOXED(fd, G_TYPE_POLL_FD), + NUM2INT(priority)); + return self; +} + +static VALUE +rg_remove_poll(VALUE self, VALUE fd) +{ + g_main_context_remove_poll(_SELF(self), RVAL2BOXED(fd, G_TYPE_POLL_FD)); + return self; +} + +#ifdef HAVE_G_MAIN_DEPTH +static VALUE +rg_s_depth(G_GNUC_UNUSED VALUE self) +{ + return INT2NUM(g_main_depth()); +} +#endif + +static VALUE +timeout_source_new(G_GNUC_UNUSED VALUE self, VALUE interval) +{ + return BOXED2RVAL(g_timeout_source_new(NUM2UINT(interval)), G_TYPE_SOURCE); +} +#if GLIB_CHECK_VERSION(2,14,0) +static VALUE +timeout_source_new_seconds(G_GNUC_UNUSED VALUE self, VALUE interval) +{ + return BOXED2RVAL(g_timeout_source_new_seconds(NUM2UINT(interval)), G_TYPE_SOURCE); +} +#endif + +static VALUE +timeout_add(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE interval, rb_priority, func, rb_id; + gint priority; + callback_info_t *info; + guint id; + + rb_scan_args(argc, argv, "11&", &interval, &rb_priority, &func); + + priority = NIL_P(rb_priority) ? G_PRIORITY_DEFAULT : NUM2INT(rb_priority); + info = ALLOC(callback_info_t); + info->callback = func; + id = g_timeout_add_full(priority, NUM2UINT(interval), + (GSourceFunc)invoke_source_func, + (gpointer)info, g_free); + info->id = id; + rb_id = UINT2NUM(id); + G_RELATIVE2(mGLibSource, func, id__callbacks__, rb_id); + g_hash_table_insert(callbacks_table, (gpointer)func, info); + return rb_id; +} + +#if GLIB_CHECK_VERSION(2,14,0) +static VALUE +timeout_add_seconds(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE interval, rb_priority, func, rb_id; + gint priority; + callback_info_t *info; + guint id; + + rb_scan_args(argc, argv, "11&", &interval, &rb_priority, &func); + + priority = NIL_P(rb_priority) ? G_PRIORITY_DEFAULT : NUM2INT(rb_priority); + info = ALLOC(callback_info_t); + info->callback = func; + id = g_timeout_add_seconds_full(priority, + NUM2UINT(interval), + (GSourceFunc)invoke_source_func, + (gpointer)info, + g_free); + info->id = id; + rb_id = UINT2NUM(id); + G_RELATIVE2(mGLibSource, func, id__callbacks__, rb_id); + g_hash_table_insert(callbacks_table, (gpointer)func, info); + return rb_id; +} +#endif + +static VALUE +idle_source_new(G_GNUC_UNUSED VALUE self) +{ + return BOXED2RVAL(g_idle_source_new(), G_TYPE_SOURCE); +} + +static VALUE +idle_add(gint argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE arg1, arg2, func, rb_id; + callback_info_t *info; + guint id; + gint priority = G_PRIORITY_DEFAULT_IDLE; + + rb_scan_args(argc, argv, "02", &arg1, &arg2); + + if (RVAL2CBOOL(rb_obj_is_kind_of(arg1, rb_cProc))) { + func = arg1; + } else if (RVAL2CBOOL(rb_obj_is_kind_of(arg1, rb_cInteger))) { + priority = NUM2INT(arg1); + func = rb_block_proc(); + } else { + func = rb_block_proc(); + } + + info = ALLOC(callback_info_t); + info->callback = func; + id = g_idle_add_full(priority, (GSourceFunc)invoke_source_func, + (gpointer)info, g_free); + info->id = id; + rb_id = UINT2NUM(id); + G_RELATIVE2(mGLibSource, func, id__callbacks__, rb_id); + g_hash_table_insert(callbacks_table, (gpointer)func, info); + return rb_id; +} + +static VALUE +idle_remove(G_GNUC_UNUSED VALUE self, VALUE func) +{ + callback_info_t *info; + + info = g_hash_table_lookup(callbacks_table, (gpointer)func); + G_REMOVE_RELATIVE(mGLibSource, id__callbacks__, UINT2NUM(info->id)); + g_hash_table_remove(callbacks_table, (gpointer)func); + return CBOOL2RVAL(g_idle_remove_by_data((gpointer)info)); +} + +#if GLIB_CHECK_VERSION(2,4,0) +static VALUE +child_watch_source_new(G_GNUC_UNUSED VALUE self, VALUE pid) +{ + return BOXED2RVAL(g_child_watch_source_new((GPid)NUM2INT(pid)), G_TYPE_SOURCE); +} + +static void +child_watch_func(GPid pid, gint status, gpointer func) +{ + rb_funcall((VALUE)func, id_call, 2, INT2NUM((long)pid), INT2NUM(status)); +} + +static VALUE +child_watch_add(VALUE self, VALUE pid) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + return UINT2NUM(g_child_watch_add((GPid)NUM2INT(pid), + (GChildWatchFunc)child_watch_func, (gpointer)func)); +} +#endif + +#ifndef HAVE_RB_THREAD_BLOCKING_REGION +static void +ruby_source_remove(G_GNUC_UNUSED VALUE data) +{ + if (ruby_source_id != 0) { + g_source_remove(ruby_source_id); + ruby_source_id = 0; + } +} +#endif + +void +Init_glib_main_context(void) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_MAIN_CONTEXT, "MainContext", mGLib); + + VALUE timeout = rb_define_module_under(mGLib, "Timeout"); + VALUE idle = rb_define_module_under(mGLib, "Idle"); +#if GLIB_CHECK_VERSION(2,4,0) + VALUE child_watch = rb_define_module_under(mGLib, "ChildWatch"); +#endif + + id_call = rb_intern("call"); + id__callbacks__ = rb_intern("__callbacks__"); + callbacks_table = g_hash_table_new(NULL, NULL); + + rbg_define_singleton_method(mGLib, "set_ruby_thread_priority", + ruby_source_set_priority, 1); + + mGLibSource = rb_const_get(mGLib, rb_intern("Source")); + rbg_define_singleton_method(mGLibSource, "remove", source_remove, 1); +#if GLIB_CHECK_VERSION(2,12,0) + rbg_define_singleton_method(mGLibSource, "current", source_current_source, 0); +#endif +/* + id_poll_func = rb_intern("__poll_func__"); +*/ + RG_DEF_METHOD(initialize, 0); + RG_DEF_SMETHOD(default, 0); + RG_DEF_METHOD(iteration, 1); + RG_DEF_METHOD_P(pending, 0); + RG_DEF_METHOD(find_source, 1); + RG_DEF_METHOD(wakeup, 0); + RG_DEF_METHOD(acquire, 0); + RG_DEF_METHOD(release, 0); +#if GLIB_CHECK_VERSION(2,10,0) + RG_DEF_METHOD_P(owner, 0); +#endif + RG_DEF_METHOD(prepare, 0); + RG_DEF_METHOD(query, 1); +/* + RG_DEF_METHOD(check, 1); +*/ + RG_DEF_METHOD(dispatch, 0); +/* + RG_DEF_METHOD(set_poll_func, 0); +*/ + RG_DEF_METHOD(add_poll, 2); + RG_DEF_METHOD(remove_poll, 1); +#ifdef HAVE_G_MAIN_DEPTH + RG_DEF_SMETHOD(depth, 0); +#endif + rbg_define_singleton_method(timeout, "source_new", timeout_source_new, 1); +#if GLIB_CHECK_VERSION(2,14,0) + rbg_define_singleton_method(timeout, "source_new_seconds", timeout_source_new_seconds, 1); +#endif + rbg_define_singleton_method(timeout, "add", timeout_add, -1); +#if GLIB_CHECK_VERSION(2,14,0) + rbg_define_singleton_method(timeout, "add_seconds", timeout_add_seconds, -1); +#endif + rbg_define_singleton_method(idle, "source_new", idle_source_new, 0); + rbg_define_singleton_method(idle, "add", idle_add, -1); + rbg_define_singleton_method(idle, "remove", idle_remove, 1); + +#if GLIB_CHECK_VERSION(2,4,0) + rbg_define_singleton_method(child_watch, "source_new", child_watch_source_new, 1); + rbg_define_singleton_method(child_watch, "add", child_watch_add, 1); +#endif + + default_poll_func = g_main_context_get_poll_func(NULL); + g_main_context_set_poll_func(NULL, rg_poll); + rb_set_end_proc(restore_poll_func, Qnil); + +#ifndef HAVE_RB_THREAD_BLOCKING_REGION + { + GSource *source; + + source = ruby_source_new(); + g_source_set_priority(source, G_PRIORITY_DEFAULT_IDLE); + ruby_source_id = g_source_attach(source, NULL); + g_source_unref(source); + rb_set_end_proc(ruby_source_remove, Qnil); + } +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_mainloop.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_mainloop.c new file mode 100644 index 0000000..bafba14 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_mainloop.c @@ -0,0 +1,96 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005,2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +/*****************************************/ +#if !GLIB_CHECK_VERSION(2,30,0) +GType +g_main_loop_get_type(void) +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static ("GMainLoop", + (GBoxedCopyFunc)g_main_loop_ref, + (GBoxedFreeFunc)g_main_loop_unref); + return our_type; +} +#endif +/*****************************************/ + +#define RG_TARGET_NAMESPACE cMainLoop +#define _SELF(s) ((GMainLoop*)RVAL2BOXED(s, G_TYPE_MAIN_LOOP)) + +/*****************************************/ + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE context, is_running; + GMainLoop *loop; + GMainContext *main_context = NULL; + + rb_scan_args(argc, argv, "02", &context, &is_running); + + if (!NIL_P(context)) + main_context = RVAL2BOXED(context, G_TYPE_MAIN_CONTEXT); + loop = g_main_loop_new(main_context, RVAL2CBOOL(is_running)); + G_INITIALIZE(self, loop); + return Qnil; +} + +static VALUE +rg_run(VALUE self) +{ + g_main_loop_run(_SELF(self)); + return self; +} + +static VALUE +rg_quit(VALUE self) +{ + g_main_loop_quit(_SELF(self)); + return Qnil; +} + +static VALUE +rg_running_p(VALUE self) +{ + return CBOOL2RVAL(g_main_loop_is_running(_SELF(self))); +} + +static VALUE +rg_context(VALUE self) +{ + return BOXED2RVAL(g_main_loop_get_context(_SELF(self)), G_TYPE_MAIN_CONTEXT); +} + +void +Init_glib_main_loop(void) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_MAIN_LOOP, "MainLoop", mGLib); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(run, 0); + RG_DEF_METHOD(quit, 0); + RG_DEF_METHOD_P(running, 0); + RG_DEF_METHOD(context, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_messages.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_messages.c new file mode 100644 index 0000000..f35813b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_messages.c @@ -0,0 +1,148 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#ifndef HAVE_RB_SOURCEFILE +#define rb_sourcefile() (ruby_sourcefile) +#endif + +#ifndef HAVE_RB_SOURCELINE +#define rb_sourceline() (ruby_sourceline) +#endif + +#define RG_TARGET_NAMESPACE mLog + +static VALUE rbglib_log_handler_procs; +static gboolean log_canceled; + +static const gchar * +logmessage(GLogLevelFlags level) +{ + if (level & G_LOG_LEVEL_ERROR){ + return "ERROR"; + } else if (level & G_LOG_LEVEL_CRITICAL){ + return "CRITICAL"; + } else if (level & G_LOG_LEVEL_WARNING){ + return "WARNING"; + } else if (level & G_LOG_LEVEL_MESSAGE){ + return "MESSAGE"; + } else if (level & G_LOG_LEVEL_INFO){ + return "INFO"; + } else if (level & G_LOG_LEVEL_DEBUG){ + return "DEBUG"; + } + return "UNKNOWN"; +} + +static void +rbglib_log_handler(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data) +{ + if (! log_canceled){ +#ifdef HAVE_RUBY_SET_CURRENT_SOURCE + ruby_set_current_source(); +#endif + g_printerr("%s: line %d\n", rb_sourcefile(), rb_sourceline()); + g_printerr(" %s-%s **:%s\n", log_domain, logmessage(log_level), message); + } else { + g_log_default_handler(log_domain, log_level, message, user_data); + } +} + +/* Use Internal only */ +static VALUE +rg_s_cancel_handler(G_GNUC_UNUSED VALUE self) +{ + log_canceled = TRUE; + return Qnil; +} + +static VALUE +rg_s_set_handler(VALUE self, VALUE domain, VALUE levels) +{ + guint handler_id = g_log_set_handler(RVAL2CSTR_ACCEPT_NIL(domain), + NUM2INT(levels), + (GLogFunc)rbglib_log_handler, (gpointer)self); + return UINT2NUM(handler_id); +} + +static VALUE +rg_s_remove_handler(VALUE self, VALUE domain, VALUE handler_id) +{ + g_log_remove_handler(RVAL2CSTR_ACCEPT_NIL(domain), + NUM2UINT(handler_id)); + G_REMOVE_RELATIVE(self, handler_id, rbglib_log_handler_procs); + return Qnil; +} + +static VALUE +rg_s_set_always_fatal(G_GNUC_UNUSED VALUE self, VALUE fatal_mask) +{ + return INT2NUM(g_log_set_always_fatal(NUM2INT(fatal_mask))); +} + +static VALUE +rg_s_set_fatal_mask(G_GNUC_UNUSED VALUE self, VALUE domain, VALUE fatal_mask) +{ + return INT2NUM(g_log_set_fatal_mask(RVAL2CSTR_ACCEPT_NIL(domain), + NUM2INT(fatal_mask))); +} + +static VALUE +rg_s_log(G_GNUC_UNUSED VALUE self, VALUE domain, VALUE level, VALUE str) +{ + g_log(RVAL2CSTR_ACCEPT_NIL(domain), NUM2INT(level), "%s", RVAL2CSTR(str)); + return Qnil; +} + +void +Init_glib_messages(void) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "Log"); + + log_canceled = FALSE; + + rb_global_variable(&rbglib_log_handler_procs); + rbglib_log_handler_procs = rb_hash_new(); + RG_DEF_SMETHOD(set_handler, 2); + RG_DEF_SMETHOD(remove_handler, 2); + RG_DEF_SMETHOD(cancel_handler, 0); + RG_DEF_SMETHOD(set_always_fatal, 1); + RG_DEF_SMETHOD(set_fatal_mask, 2); + RG_DEF_SMETHOD(log, 3); + + rb_define_const(RG_TARGET_NAMESPACE, "FATAL_MASK", INT2NUM(G_LOG_FATAL_MASK)); + rb_define_const(RG_TARGET_NAMESPACE, "LEVEL_USER_SHIFT", INT2NUM(G_LOG_LEVEL_USER_SHIFT)); + + /* GLogLevelFlags */ + rb_define_const(RG_TARGET_NAMESPACE, "FLAG_RECURSION", INT2NUM(G_LOG_FLAG_RECURSION)); + rb_define_const(RG_TARGET_NAMESPACE, "FLAG_FATAL", INT2NUM(G_LOG_FLAG_FATAL)); + rb_define_const(RG_TARGET_NAMESPACE, "LEVEL_ERROR", INT2NUM(G_LOG_LEVEL_ERROR)); + rb_define_const(RG_TARGET_NAMESPACE, "LEVEL_CRITICAL", INT2NUM(G_LOG_LEVEL_CRITICAL)); + rb_define_const(RG_TARGET_NAMESPACE, "LEVEL_WARNING", INT2NUM(G_LOG_LEVEL_WARNING)); + rb_define_const(RG_TARGET_NAMESPACE, "LEVEL_MESSAGE", INT2NUM(G_LOG_LEVEL_MESSAGE)); + rb_define_const(RG_TARGET_NAMESPACE, "LEVEL_INFO", INT2NUM(G_LOG_LEVEL_INFO)); + rb_define_const(RG_TARGET_NAMESPACE, "LEVEL_DEBUG", INT2NUM(G_LOG_LEVEL_DEBUG)); + rb_define_const(RG_TARGET_NAMESPACE, "LEVEL_MASK", INT2NUM(G_LOG_LEVEL_MASK)); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_pollfd.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_pollfd.c new file mode 100644 index 0000000..7ca1c71 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_pollfd.c @@ -0,0 +1,112 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +/*****************************************/ +static GPollFD* +pollfd_copy(const GPollFD* pollfd) +{ + GPollFD* new_pollfd; + g_return_val_if_fail (pollfd != NULL, NULL); + + new_pollfd = g_new(GPollFD, 1); + *new_pollfd = *pollfd; + return new_pollfd; +} + +GType +g_poll_fd_get_type(void) +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static ("GPollFD", + (GBoxedCopyFunc)pollfd_copy, + (GBoxedFreeFunc)g_free); + return our_type; +} +/*****************************************/ + +#define RG_TARGET_NAMESPACE cPollFD +#define _SELF(s) ((GPollFD*)RVAL2BOXED(s, G_TYPE_POLL_FD)) + +static VALUE +rg_initialize(VALUE self, VALUE fd, VALUE events, VALUE revents) +{ + GPollFD gfd; + gfd.fd = NUM2INT(fd); + gfd.events = NUM2INT(events); + gfd.revents = NUM2INT(revents); + + G_INITIALIZE(self, g_boxed_copy(G_TYPE_POLL_FD, &gfd)); + return Qnil; +} + +static VALUE +rg_set_fd(VALUE self, VALUE fd) +{ + _SELF(self)->fd = fd; + return self; +} +static VALUE +rg_fd(VALUE self) +{ + return INT2NUM(_SELF(self)->fd); +} + +static VALUE +rg_set_events(VALUE self, VALUE events) +{ + _SELF(self)->events = events; + return self; +} +static VALUE +rg_events(VALUE self) +{ + return INT2NUM(_SELF(self)->events); +} + +static VALUE +rg_set_revents(VALUE self, VALUE revents) +{ + _SELF(self)->revents = revents; + return self; +} +static VALUE +rg_revents(VALUE self) +{ + return INT2NUM(_SELF(self)->revents); +} + +void +Init_glib_poll_fd(void) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_POLL_FD, "PollFD", mGLib); + + RG_DEF_METHOD(initialize, 3); + + RG_DEF_METHOD(set_fd, 1); + RG_DEF_METHOD(fd, 0); + RG_DEF_METHOD(set_events, 1); + RG_DEF_METHOD(events, 0); + RG_DEF_METHOD(set_revents, 1); + RG_DEF_METHOD(revents, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_shell.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_shell.c new file mode 100644 index 0000000..7a38a55 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_shell.c @@ -0,0 +1,64 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#define RG_TARGET_NAMESPACE mShell + +static VALUE +rg_s_parse(G_GNUC_UNUSED VALUE self, VALUE command_line) +{ + gint argc; + gchar **argv; + GError *error = NULL; + + if (!g_shell_parse_argv(RVAL2CSTR(command_line), &argc, &argv, &error)) + RAISE_GERROR(error); + + return STRV2RVAL_FREE(argv); +} + +static VALUE +rg_s_quote(G_GNUC_UNUSED VALUE self, VALUE unquoted_string) +{ + return CSTR2RVAL_FREE(g_shell_quote(RVAL2CSTR(unquoted_string))); +} + +static VALUE +rg_s_unquote(G_GNUC_UNUSED VALUE self, VALUE quoted_string) +{ + GError *error = NULL; + gchar *str = g_shell_unquote(RVAL2CSTR(quoted_string), &error); + if (str == NULL) + RAISE_GERROR(error); + + return CSTR2RVAL_FREE(str); +} + +void +Init_glib_shell(void) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "Shell"); + + RG_DEF_SMETHOD(parse, 1); + RG_DEF_SMETHOD(quote, 1); + RG_DEF_SMETHOD(unquote, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_shellerror.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_shellerror.c new file mode 100644 index 0000000..e22a413 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_shellerror.c @@ -0,0 +1,34 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#define RG_TARGET_NAMESPACE cShellError + +void +Init_glib_shellerror(void) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_ERROR2(G_SHELL_ERROR, "ShellError", mGLib, rb_eRuntimeError); + + rb_define_const(RG_TARGET_NAMESPACE, "BAD_QUOTING", INT2FIX(G_SHELL_ERROR_BAD_QUOTING)); + rb_define_const(RG_TARGET_NAMESPACE, "EMPTY_STRING", INT2FIX(G_SHELL_ERROR_EMPTY_STRING)); + rb_define_const(RG_TARGET_NAMESPACE, "FAILED", INT2FIX(G_SHELL_ERROR_FAILED)); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_source.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_source.c new file mode 100644 index 0000000..c2e2e04 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_source.c @@ -0,0 +1,198 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011-2013 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +static ID id_call; + +/*****************************************/ +#if !GLIB_CHECK_VERSION(2,30,0) +static void +source_free(GSource *source) +{ + g_source_unref(source); + g_source_destroy(source); +} + +GType +g_source_get_type(void) +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static ("GSource", + (GBoxedCopyFunc)g_source_ref, + (GBoxedFreeFunc)source_free); + return our_type; +} +#endif +/*****************************************/ + +#define RG_TARGET_NAMESPACE cSource +#define _SELF(s) ((GSource*)RVAL2BOXED(s, G_TYPE_SOURCE)) + +/* +GSource* g_source_new (GSourceFuncs *source_funcs, + guint struct_size); +*/ + +static VALUE +rg_attach(int argc, VALUE *argv, VALUE self) +{ + VALUE context; + + rb_scan_args(argc, argv, "01", &context); + return UINT2NUM(g_source_attach(_SELF(self), + RVAL2BOXED(context, G_TYPE_MAIN_CONTEXT))); +} + +#if GLIB_CHECK_VERSION(2,12,0) +static VALUE +rg_destroyed_p(VALUE self) +{ + return CBOOL2RVAL(g_source_is_destroyed(_SELF(self))); +} +#endif + +static VALUE +rg_set_priority(VALUE self, VALUE priority) +{ + g_source_set_priority(_SELF(self), NUM2INT(priority)); + return self; +} + +static VALUE +rg_priority(VALUE self) +{ + return INT2NUM(g_source_get_priority(_SELF(self))); +} + +static VALUE +rg_set_can_recurse(VALUE self, VALUE can_recurse) +{ + g_source_set_can_recurse(_SELF(self), RVAL2CBOOL(can_recurse)); + return self; +} + +static VALUE +rg_can_recurse_p(VALUE self) +{ + return CBOOL2RVAL(g_source_get_can_recurse(_SELF(self))); +} + +static VALUE +rg_id(VALUE self) +{ + return UINT2NUM(g_source_get_id(_SELF(self))); +} + +static VALUE +rg_context(VALUE self) +{ + GMainContext* context = g_source_get_context(_SELF(self)); + return BOXED2RVAL(context, G_TYPE_MAIN_CONTEXT); +} + +static gboolean +source_func(gpointer func) +{ + return RVAL2CBOOL(rb_funcall((VALUE)func, id_call, 0)); +} + +static VALUE +rg_set_callback(VALUE self) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + g_source_set_callback(_SELF(self), + (GSourceFunc)source_func, + (gpointer)func, + (GDestroyNotify)NULL); + return self; +} + +/* +void g_source_set_callback_indirect (GSource *source, + gpointer callback_data, + GSourceCallbackFuncs *callback_funcs); +*/ + +static VALUE +rg_add_poll(VALUE self, VALUE fd) +{ + g_source_add_poll(_SELF(self), RVAL2BOXED(fd, G_TYPE_POLL_FD)); + return self; +} + +static VALUE +rg_remove_poll(VALUE self, VALUE fd) +{ + g_source_remove_poll(_SELF(self), RVAL2BOXED(fd, G_TYPE_POLL_FD)); + return self; +} + +#if GLIB_CHECK_VERSION(2, 28, 0) +static VALUE +rg_time(VALUE self) +{ + gint64 time; + time = g_source_get_time(_SELF(self)); + return LL2NUM(time); +} +#endif + +/* How can I implement them ? +gboolean g_source_remove_by_funcs_user_data + (GSourceFuncs *funcs, + gpointer user_data); +gboolean g_source_remove_by_user_data (gpointer user_data); +*/ + +void +Init_glib_source(void) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_SOURCE, "Source", mGLib); + + id_call = rb_intern("call"); + + rb_define_const(RG_TARGET_NAMESPACE, + "REMOVE", CBOOL2RVAL(G_SOURCE_REMOVE)); + rb_define_const(RG_TARGET_NAMESPACE, + "CONTINUE", CBOOL2RVAL(G_SOURCE_CONTINUE)); + + RG_DEF_METHOD(attach, -1); +#if GLIB_CHECK_VERSION(2,12,0) + RG_DEF_METHOD_P(destroyed, 0); +#endif + RG_DEF_METHOD(set_priority, 1); + RG_DEF_METHOD(priority, 0); + RG_DEF_METHOD(set_can_recurse, 1); + RG_DEF_METHOD_P(can_recurse, 0); + RG_DEF_METHOD(id, 0); + RG_DEF_METHOD(context, 0); + RG_DEF_METHOD(set_callback, 0); + RG_DEF_METHOD(add_poll, 1); + RG_DEF_METHOD(remove_poll, 1); +#if GLIB_CHECK_VERSION(2, 28, 0) + RG_DEF_METHOD(time, 0); +#endif + + /* GLib::Source.remove is moved to rbglib_maincontext.c */ +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_spawn.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_spawn.c new file mode 100644 index 0000000..1911780 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_spawn.c @@ -0,0 +1,245 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * Copyright (C) 2004 Kazuhiro NISHIYAMA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" +#include "rbglib.h" + +#define RG_TARGET_NAMESPACE mSpawn + +static ID id_call; +static ID id_new; + +static void +child_setup(gpointer func) +{ + if (! NIL_P(func)){ + rb_funcall((VALUE)func, id_call, 0); + } +} + +static VALUE +rg_s_async_with_pipes(VALUE self, VALUE working_directory, VALUE argv, VALUE envp, VALUE flags) +{ + GError *err = NULL; + gboolean ret; + GPid child_pid; + VALUE func = Qnil; + gchar **gargv; + gchar **genvp; + gint standard_input, standard_output, standard_error; + + if (rb_block_given_p()) { + func = rb_block_proc(); + G_RELATIVE(self, func); + } + + gargv = (gchar **)RVAL2STRV(argv); + genvp = (gchar **)RVAL2STRV_ACCEPT_NIL(envp); + ret = g_spawn_async_with_pipes(RVAL2CSTR_ACCEPT_NIL(working_directory), + gargv, genvp, NUM2INT(flags), + (GSpawnChildSetupFunc)child_setup, + (gpointer)func, + &child_pid, + &standard_input, &standard_output, + &standard_error, &err); + g_free(gargv); + g_free(genvp); + if (!ret) + RAISE_GERROR(err); + + return rb_ary_new3(4, INT2NUM((gint)child_pid), + rb_funcall(rb_cIO, id_new, 1, INT2NUM(standard_input)), + rb_funcall(rb_cIO, id_new, 1, INT2NUM(standard_output)), + rb_funcall(rb_cIO, id_new, 1, INT2NUM(standard_error))); +} + +static VALUE +rg_s_async(VALUE self, VALUE working_directory, VALUE argv, VALUE envp, VALUE flags) +{ + GError *err = NULL; + gboolean ret; + GPid child_pid; + VALUE func = Qnil; + gchar **gargv; + gchar **genvp; + + if (rb_block_given_p()) { + func = rb_block_proc(); + G_RELATIVE(self, func); + } + + gargv = (gchar **)RVAL2STRV(argv); + genvp = (gchar **)RVAL2STRV_ACCEPT_NIL(envp); + ret = g_spawn_async(RVAL2CSTR_ACCEPT_NIL(working_directory), + gargv, genvp, NUM2INT(flags), + (GSpawnChildSetupFunc)child_setup, (gpointer)func, + &child_pid, &err); + g_free(gargv); + g_free(genvp); + if (!ret) + RAISE_GERROR(err); + + return INT2NUM((int)child_pid); +} + +static VALUE +rg_s_sync(VALUE self, VALUE working_directory, VALUE argv, VALUE envp, VALUE flags) +{ + GError *err = NULL; + gboolean ret; + VALUE func = Qnil; + gchar** gargv; + gchar** genvp; + gchar *standard_output = NULL, *standard_error = NULL; + gint exit_status; + VALUE std_out, std_err; + + if (rb_block_given_p()) { + func = rb_block_proc(); + G_RELATIVE(self, func); + } + + gargv = (gchar **)RVAL2STRV(argv); + genvp = (gchar **)RVAL2STRV_ACCEPT_NIL(envp); + ret = g_spawn_sync(RVAL2CSTR_ACCEPT_NIL(working_directory), + gargv, genvp, NUM2INT(flags), + (GSpawnChildSetupFunc)child_setup, (gpointer)func, + &standard_output, &standard_error, + &exit_status, &err); + g_free(gargv); + g_free(genvp); + if (!ret) + RAISE_GERROR(err); + + if (standard_output) { + std_out = CSTR2RVAL(standard_output); + g_free(standard_output); + } else { + std_out = Qnil; + standard_output = NULL; + } + if (standard_error) { + std_err = CSTR2RVAL(standard_error); + g_free(standard_error); + standard_error = NULL; + } else { + std_err = Qnil; + } + + if (! ret) + RAISE_GERROR(err); + + return rb_ary_new3(3, std_out, std_err, INT2FIX(exit_status)); + +} + +static VALUE +rg_s_command_line_sync(G_GNUC_UNUSED VALUE self, VALUE str) +{ + GError *err = NULL; + const gchar *command_line; + gchar *standard_output = NULL, *standard_error = NULL; + gint exit_status; + VALUE std_out, std_err; + gboolean ret; + + command_line = RVAL2CSTR(str); + ret = g_spawn_command_line_sync(command_line, + &standard_output, + &standard_error, + &exit_status, + &err); + if (standard_output) { + std_out = CSTR2RVAL(standard_output); + g_free(standard_output); + } else { + std_out = Qnil; + standard_output = NULL; + } + if (standard_error) { + std_err = CSTR2RVAL(standard_error); + g_free(standard_error); + standard_error = NULL; + } else { + std_err = Qnil; + } + + if (! ret) + RAISE_GERROR(err); + + return rb_ary_new3(3, std_out, std_err, INT2FIX(exit_status)); +} + +static VALUE +rg_s_command_line_async(G_GNUC_UNUSED VALUE self, VALUE str) +{ + GError *err = NULL; + const gchar *command_line; + VALUE ret; + + command_line = StringValuePtr(str); + ret = CBOOL2RVAL(g_spawn_command_line_async(command_line, &err)); + if (err != NULL) + RAISE_GERROR(err); + + return ret; +} + +#ifdef HAVE_G_SPAWN_CLOSE_PID + +#define RVAL2GPID(value) ((GPid)NUM2INT(pid)) + +static VALUE +rg_s_close_pid(G_GNUC_UNUSED VALUE self, VALUE pid) +{ + g_spawn_close_pid(RVAL2GPID(pid)); + return Qnil; +} + +#endif + +void +Init_glib_spawn(void) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "Spawn"); + + id_call = rb_intern("call"); + id_new = rb_intern("new"); + + /* glib/gspawn.h */ + RG_DEF_SMETHOD(async_with_pipes, 4); + RG_DEF_SMETHOD(async, 4); + RG_DEF_SMETHOD(sync, 4); + RG_DEF_SMETHOD(command_line_sync, 1); + RG_DEF_SMETHOD(command_line_async, 1); +#ifdef HAVE_G_SPAWN_CLOSE_PID + RG_DEF_SMETHOD(close_pid, 1); +#endif + + rb_define_const(RG_TARGET_NAMESPACE, "LEAVE_DESCRIPTORS_OPEN", INT2NUM(G_SPAWN_LEAVE_DESCRIPTORS_OPEN)); + rb_define_const(RG_TARGET_NAMESPACE, "DO_NOT_REAP_CHILD", INT2NUM(G_SPAWN_DO_NOT_REAP_CHILD)); + rb_define_const(RG_TARGET_NAMESPACE, "SEARCH_PATH", INT2NUM(G_SPAWN_SEARCH_PATH)); + rb_define_const(RG_TARGET_NAMESPACE, "STDOUT_TO_DEV_NULL", INT2NUM(G_SPAWN_STDOUT_TO_DEV_NULL)); + rb_define_const(RG_TARGET_NAMESPACE, "STDERR_TO_DEV_NULL", INT2NUM(G_SPAWN_STDERR_TO_DEV_NULL)); + rb_define_const(RG_TARGET_NAMESPACE, "CHILD_INHERITS_STDIN", INT2NUM(G_SPAWN_CHILD_INHERITS_STDIN)); + rb_define_const(RG_TARGET_NAMESPACE, "FILE_AND_ARGV_ZERO", INT2NUM(G_SPAWN_FILE_AND_ARGV_ZERO)); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_spawnerror.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_spawnerror.c new file mode 100644 index 0000000..7eb31b5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_spawnerror.c @@ -0,0 +1,53 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * Copyright (C) 2004 Kazuhiro NISHIYAMA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" +#include "rbglib.h" + +#define RG_TARGET_NAMESPACE cSpawnError + +void +Init_glib_spawnerror(void) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_ERROR2(G_SPAWN_ERROR, "SpawnError", mGLib, rb_eIOError); + + rb_define_const(RG_TARGET_NAMESPACE, "FORK", INT2NUM(G_SPAWN_ERROR_FORK)); + rb_define_const(RG_TARGET_NAMESPACE, "READ", INT2NUM(G_SPAWN_ERROR_READ)); + rb_define_const(RG_TARGET_NAMESPACE, "CHDIR", INT2NUM(G_SPAWN_ERROR_CHDIR)); + rb_define_const(RG_TARGET_NAMESPACE, "EACCES", INT2NUM(G_SPAWN_ERROR_ACCES)); + rb_define_const(RG_TARGET_NAMESPACE, "EPERM", INT2NUM(G_SPAWN_ERROR_PERM)); + rb_define_const(RG_TARGET_NAMESPACE, "E2BIG", INT2NUM(G_SPAWN_ERROR_2BIG)); + rb_define_const(RG_TARGET_NAMESPACE, "ENOEXEC", INT2NUM(G_SPAWN_ERROR_NOEXEC)); + rb_define_const(RG_TARGET_NAMESPACE, "ENAMETOOLONG", INT2NUM(G_SPAWN_ERROR_NAMETOOLONG)); + rb_define_const(RG_TARGET_NAMESPACE, "ENOENT", INT2NUM(G_SPAWN_ERROR_NOENT)); + rb_define_const(RG_TARGET_NAMESPACE, "ENOMEM", INT2NUM(G_SPAWN_ERROR_NOMEM)); + rb_define_const(RG_TARGET_NAMESPACE, "ENOTDIR", INT2NUM(G_SPAWN_ERROR_NOTDIR)); + rb_define_const(RG_TARGET_NAMESPACE, "ELOOP", INT2NUM(G_SPAWN_ERROR_LOOP)); + rb_define_const(RG_TARGET_NAMESPACE, "ETXTBUSY", INT2NUM(G_SPAWN_ERROR_TXTBUSY)); + rb_define_const(RG_TARGET_NAMESPACE, "EIO", INT2NUM(G_SPAWN_ERROR_IO)); + rb_define_const(RG_TARGET_NAMESPACE, "ENFILE", INT2NUM(G_SPAWN_ERROR_NFILE)); + rb_define_const(RG_TARGET_NAMESPACE, "EMFILE", INT2NUM(G_SPAWN_ERROR_MFILE)); + rb_define_const(RG_TARGET_NAMESPACE, "EINVAL", INT2NUM(G_SPAWN_ERROR_INVAL)); + rb_define_const(RG_TARGET_NAMESPACE, "EISDIR", INT2NUM(G_SPAWN_ERROR_ISDIR)); + rb_define_const(RG_TARGET_NAMESPACE, "ELIBBAD", INT2NUM(G_SPAWN_ERROR_LIBBAD)); + rb_define_const(RG_TARGET_NAMESPACE, "FAILED", INT2NUM(G_SPAWN_ERROR_FAILED)); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_threads.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_threads.c new file mode 100644 index 0000000..c1c9773 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_threads.c @@ -0,0 +1,61 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#define RG_TARGET_NAMESPACE cThread + +static VALUE RG_TARGET_NAMESPACE; + +static VALUE +rg_s_init(VALUE self) +{ +#ifdef HAVE_G_THREAD_INIT +#ifdef G_THREADS_ENABLED + g_thread_init(NULL); +#endif +#endif + return self; +} + +static VALUE +rg_s_supported_p(G_GNUC_UNUSED VALUE self) +{ +#ifdef HAVE_G_THREAD_INIT +#ifdef G_THREADS_ENABLED + return CBOOL2RVAL(g_thread_supported()); +#else + return Qfalse; +#endif +#else + return Qfalse; +#endif + +} + +void +Init_glib_threads(void) +{ + RG_TARGET_NAMESPACE = rb_define_class_under(mGLib, "Thread", rb_cObject); + + RG_DEF_SMETHOD(init, 0); + RG_DEF_SMETHOD_P(supported, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_timer.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_timer.c new file mode 100644 index 0000000..7f8c6fb --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_timer.c @@ -0,0 +1,131 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#ifdef G_OS_WIN32 +#include +#endif + +/*****************************************/ + +/* This is stolen from gtimer.c of glib-2.6.2. */ +struct _GTimer +{ +#ifdef G_OS_WIN32 + DWORD start; + DWORD end; +#else /* !G_OS_WIN32 */ + struct timeval start; + struct timeval end; +#endif /* !G_OS_WIN32 */ + + guint active : 1; +}; + +static GTimer* +timer_copy(GTimer *timer) +{ + GTimer* new_timer; + g_return_val_if_fail (timer != NULL, NULL); + + new_timer = g_new(struct _GTimer, 1); + *new_timer = *timer; + return new_timer; +} + +static GType +g_timer_get_type(void) +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static ("GTimer", + (GBoxedCopyFunc)timer_copy, + (GBoxedFreeFunc)g_timer_destroy); + return our_type; +} +/*****************************************/ + +#define G_TYPE_TIMER (g_timer_get_type()) + +#define RG_TARGET_NAMESPACE cTimer +#define _SELF(s) ((GTimer*)RVAL2BOXED(s, G_TYPE_TIMER)) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, g_timer_new()); + return Qnil; +} + +static VALUE +rg_start(VALUE self) +{ + g_timer_start(_SELF(self)); + return self; +} + +static VALUE +rg_stop(VALUE self) +{ + g_timer_stop(_SELF(self)); + return self; +} + +#if GLIB_CHECK_VERSION(2,4,0) +static VALUE +rg_continue(VALUE self) +{ + g_timer_continue(_SELF(self)); + return self; +} +#endif + +static VALUE +rg_elapsed(VALUE self) +{ + gulong microseconds; + gdouble ret = g_timer_elapsed(_SELF(self), µseconds); + + return rb_assoc_new(rb_float_new(ret), ULONG2NUM(microseconds)); +} + +static VALUE +rg_reset(VALUE self) +{ + g_timer_reset(_SELF(self)); + return self; +} + +void +Init_glib_timer(void) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_TIMER, "Timer", mGLib); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(start, 0); + RG_DEF_METHOD(stop, 0); +#if GLIB_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(continue, 0); +#endif + RG_DEF_METHOD(elapsed, 0); + RG_DEF_METHOD(reset, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_ucs4.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_ucs4.c new file mode 100644 index 0000000..2f599d8 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_ucs4.c @@ -0,0 +1,79 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" +#include "rbglib.h" + +#define RG_TARGET_NAMESPACE mUCS4 + +static VALUE +rg_s_to_utf16(G_GNUC_UNUSED VALUE self, VALUE rb_ucs4) +{ + VALUE result; + gunichar *ucs4; + gunichar2 *utf16; + glong len, items_written; + GError *error = NULL; + + ucs4 = (gunichar *)StringValuePtr(rb_ucs4); + len = RSTRING_LEN(rb_ucs4) / sizeof(*ucs4); + + utf16 = g_ucs4_to_utf16(ucs4, len, NULL, &items_written, &error); + + if (error) + RAISE_GERROR(error); + + result = CSTR2RVAL_LEN_UTF16((char *)utf16, + items_written * sizeof(*utf16)); + g_free(utf16); + return result; +} + +static VALUE +rg_s_to_utf8(G_GNUC_UNUSED VALUE self, VALUE rb_ucs4) +{ + VALUE result; + gunichar *ucs4; + gchar *utf8; + glong len, items_written; + GError *error = NULL; + + ucs4 = (gunichar *)StringValuePtr(rb_ucs4); + len = RSTRING_LEN(rb_ucs4) / sizeof(*ucs4); + + utf8 = g_ucs4_to_utf8(ucs4, len, NULL, &items_written, &error); + + if (error) + RAISE_GERROR(error); + + result = CSTR2RVAL_LEN(utf8, items_written); + g_free(utf8); + return result; +} + +void +Init_glib_ucs4(void) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "UCS4"); + + RG_DEF_SMETHOD(to_utf16, 1); + RG_DEF_SMETHOD(to_utf8, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_unichar.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_unichar.c new file mode 100644 index 0000000..b400b76 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_unichar.c @@ -0,0 +1,209 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" +#include "rbglib.h" + +#define RG_TARGET_NAMESPACE mUniChar + +#define DEF_IS_UNICHAR(name) \ +static VALUE \ +rbglib_m_unichar_is ## name(G_GNUC_UNUSED VALUE self, VALUE unichar) \ +{ \ + return CBOOL2RVAL(g_unichar_is ## name(NUM2UINT(unichar))); \ +} + +DEF_IS_UNICHAR(alnum) +DEF_IS_UNICHAR(alpha) +DEF_IS_UNICHAR(cntrl) +DEF_IS_UNICHAR(digit) +DEF_IS_UNICHAR(graph) +DEF_IS_UNICHAR(lower) +DEF_IS_UNICHAR(print) +DEF_IS_UNICHAR(punct) +DEF_IS_UNICHAR(space) +DEF_IS_UNICHAR(upper) +DEF_IS_UNICHAR(xdigit) +DEF_IS_UNICHAR(title) +DEF_IS_UNICHAR(defined) +DEF_IS_UNICHAR(wide) +#if GLIB_CHECK_VERSION(2,12,0) +DEF_IS_UNICHAR(wide_cjk) +#endif + +#undef DEF_IS_UNICHAR + +static VALUE +rg_s_to_upper(G_GNUC_UNUSED VALUE self, VALUE unichar) +{ + return UINT2NUM(g_unichar_toupper(NUM2UINT(unichar))); +} + +static VALUE +rg_s_to_lower(G_GNUC_UNUSED VALUE self, VALUE unichar) +{ + return UINT2NUM(g_unichar_tolower(NUM2UINT(unichar))); +} + +static VALUE +rg_s_to_title(G_GNUC_UNUSED VALUE self, VALUE unichar) +{ + return UINT2NUM(g_unichar_totitle(NUM2UINT(unichar))); +} + +static VALUE +rg_s_digit_value(G_GNUC_UNUSED VALUE self, VALUE unichar) +{ + return INT2NUM(g_unichar_digit_value(NUM2UINT(unichar))); +} + +static VALUE +rg_s_xdigit_value(G_GNUC_UNUSED VALUE self, VALUE unichar) +{ + return INT2NUM(g_unichar_xdigit_value(NUM2UINT(unichar))); +} + +static VALUE +rg_s_type(G_GNUC_UNUSED VALUE self, VALUE unichar) +{ + return GENUM2RVAL(g_unichar_type(NUM2UINT(unichar)), + G_TYPE_UNICODE_TYPE); +} + +static VALUE +rg_s_break_type(G_GNUC_UNUSED VALUE self, VALUE unichar) +{ + return GENUM2RVAL(g_unichar_break_type(NUM2UINT(unichar)), + G_TYPE_UNICODE_BREAK_TYPE); +} + +#if GLIB_CHECK_VERSION(2,4,0) +static VALUE +rg_s_get_mirror_char(G_GNUC_UNUSED VALUE self, VALUE unichar) +{ + gunichar mirrored_char; + + if (g_unichar_get_mirror_char(NUM2UINT(unichar), &mirrored_char)) { + return UINT2NUM(mirrored_char); + } else { + return unichar; + } +} +#endif + +#if GLIB_CHECK_VERSION(2,14,0) +static VALUE +rg_s_combining_class(G_GNUC_UNUSED VALUE self, VALUE unichar) +{ + return INT2NUM(g_unichar_combining_class(NUM2UINT(unichar))); +} + +static VALUE +rg_s_get_script(G_GNUC_UNUSED VALUE self, VALUE unichar) +{ + return GENUM2RVAL(g_unichar_get_script(NUM2UINT(unichar)), + G_TYPE_UNICODE_SCRIPT); +} + +static VALUE +rg_s_mark_p(G_GNUC_UNUSED VALUE self, VALUE unichar) +{ + return CBOOL2RVAL(g_unichar_ismark(NUM2UINT(unichar))); +} + +static VALUE +rg_s_zero_width_p(G_GNUC_UNUSED VALUE self, VALUE unichar) +{ + return CBOOL2RVAL(g_unichar_iszerowidth(NUM2UINT(unichar))); +} +#endif + +static VALUE +rg_s_to_utf8(G_GNUC_UNUSED VALUE self, VALUE unichar) +{ + gchar utf8[6]; + gint len; + + len = g_unichar_to_utf8(NUM2UINT(unichar), utf8); + return CSTR2RVAL_LEN(utf8, len); +} + +void +Init_glib_unichar(void) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "UniChar"); + + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "alnum?", + rbglib_m_unichar_isalnum, 1); + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "alpha?", + rbglib_m_unichar_isalpha, 1); + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "cntrl?", + rbglib_m_unichar_iscntrl, 1); + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "digit?", + rbglib_m_unichar_isdigit, 1); + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "graph?", + rbglib_m_unichar_isgraph, 1); + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "lower?", + rbglib_m_unichar_islower, 1); + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "print?", + rbglib_m_unichar_isprint, 1); + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "punct?", + rbglib_m_unichar_ispunct, 1); + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "space?", + rbglib_m_unichar_isspace, 1); + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "upper?", + rbglib_m_unichar_isupper, 1); + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "xdigit?", + rbglib_m_unichar_isxdigit, 1); + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "title?", + rbglib_m_unichar_istitle, 1); + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "defined?", + rbglib_m_unichar_isdefined, 1); + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "wide?", + rbglib_m_unichar_iswide, 1); +#if GLIB_CHECK_VERSION(2,12,0) + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "wide_cjk?", + rbglib_m_unichar_iswide_cjk, 1); +#endif + + RG_DEF_SMETHOD(to_upper, 1); + RG_DEF_SMETHOD(to_lower, 1); + RG_DEF_SMETHOD(to_title, 1); + + RG_DEF_SMETHOD(digit_value, 1); + RG_DEF_SMETHOD(xdigit_value, 1); + + RG_DEF_SMETHOD(type, 1); + RG_DEF_SMETHOD(break_type, 1); + +#if GLIB_CHECK_VERSION(2,4,0) + RG_DEF_SMETHOD(get_mirror_char, 1); +#endif + +#if GLIB_CHECK_VERSION(2,14,0) + RG_DEF_SMETHOD(combining_class, 1); + RG_DEF_SMETHOD(get_script, 1); + RG_DEF_SMETHOD_P(mark, 1); + RG_DEF_SMETHOD_P(zero_width, 1); +#endif + + RG_DEF_SMETHOD(to_utf8, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_unicode.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_unicode.c new file mode 100644 index 0000000..826403c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_unicode.c @@ -0,0 +1,90 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" +#include "rbglib.h" + +#define RG_TARGET_NAMESPACE mUnicode + +static VALUE +rbglib_m_charset(G_GNUC_UNUSED VALUE self) +{ + const char *charset; + g_get_charset(&charset); + return CSTR2RVAL(charset); +} + +static VALUE +rg_s_canonical_ordering(G_GNUC_UNUSED VALUE self, VALUE rb_ucs4) +{ + VALUE normalized_ucs4; + gchar *original_str; + gunichar *ucs4; + gint len; + + original_str = StringValuePtr(rb_ucs4); + len = RSTRING_LEN(rb_ucs4); + ucs4 = g_memdup(original_str, len); + g_unicode_canonical_ordering(ucs4, len); + normalized_ucs4 = CSTR2RVAL_LEN_UCS4((const char *)ucs4, len); + g_free(ucs4); + return normalized_ucs4; +} + +static VALUE +rg_s_canonical_decomposition(G_GNUC_UNUSED VALUE self, VALUE unichar) +{ + VALUE normalized_ucs4; + gunichar *ucs4; + gsize len; + + ucs4 = g_unicode_canonical_decomposition(NUM2UINT(unichar), &len); + normalized_ucs4 = CSTR2RVAL_LEN_UCS4((const char *)ucs4, + len * sizeof(gunichar)); + g_free(ucs4); + return normalized_ucs4; +} + +void +Init_glib_unicode(void) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "Unicode"); + + /* GUnicodeType */ + G_DEF_CLASS(G_TYPE_UNICODE_TYPE, "Type", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_UNICODE_TYPE, "G_UNICODE_"); + /* GUnicodeBreakType */ + G_DEF_CLASS(G_TYPE_UNICODE_BREAK_TYPE, "BreakType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_UNICODE_BREAK_TYPE, "G_UNICODE_"); + +#if GLIB_CHECK_VERSION(2,14,0) + /* GUnicodeScript */ + G_DEF_CLASS(G_TYPE_UNICODE_SCRIPT, "Script", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_UNICODE_SCRIPT, "G_UNICODE_"); +#endif + + G_DEF_CLASS(G_TYPE_NORMALIZE_MODE, "NormalizeMode", mGLib); + + rbg_define_singleton_method(mGLib, "charset", rbglib_m_charset, 0); + + RG_DEF_SMETHOD(canonical_ordering, 1); + RG_DEF_SMETHOD(canonical_decomposition, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_utf16.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_utf16.c new file mode 100644 index 0000000..b36a89b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_utf16.c @@ -0,0 +1,78 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" +#include "rbglib.h" + +#define RG_TARGET_NAMESPACE mUTF16 + +static VALUE +rg_s_to_ucs4(G_GNUC_UNUSED VALUE self, VALUE rb_utf16) +{ + VALUE result; + gunichar *ucs4; + gunichar2 *utf16; + glong len, items_written; + GError *error = NULL; + + utf16 = (gunichar2 *)StringValueCStr(rb_utf16); + len = RSTRING_LEN(rb_utf16) / sizeof(*utf16); + + ucs4 = g_utf16_to_ucs4(utf16, len, NULL, &items_written, &error); + + if (error) + RAISE_GERROR(error); + + result = CSTR2RVAL_LEN_UCS4((char *)ucs4, items_written * sizeof(*ucs4)); + g_free(ucs4); + return result; +} + +static VALUE +rg_s_to_utf8(G_GNUC_UNUSED VALUE self, VALUE rb_utf16) +{ + VALUE result; + gchar *utf8; + gunichar2 *utf16; + glong len, items_written; + GError *error = NULL; + + utf16 = (gunichar2 *)StringValueCStr(rb_utf16); + len = RSTRING_LEN(rb_utf16) / sizeof(*utf16); + + utf8 = g_utf16_to_utf8(utf16, len, NULL, &items_written, &error); + + if (error) + RAISE_GERROR(error); + + result = CSTR2RVAL_LEN(utf8, items_written * sizeof(*utf8)); + g_free(utf8); + return result; +} + +void +Init_glib_utf16(void) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "UTF16"); + + RG_DEF_SMETHOD(to_ucs4, 1); + RG_DEF_SMETHOD(to_utf8, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_utf8.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_utf8.c new file mode 100644 index 0000000..af4ae69 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_utf8.c @@ -0,0 +1,259 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" +#include "rbglib.h" + +#define RG_TARGET_NAMESPACE mUTF8 + +static VALUE +rg_s_get_char(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE utf8, validate; + gunichar result; + + rb_scan_args(argc, argv, "11", &utf8, &validate); + + if (RVAL2CBOOL(validate)) { + StringValue(utf8); + result = g_utf8_get_char_validated(RSTRING_PTR(utf8), + RSTRING_LEN(utf8)); + if (result == (gunichar)-1) { + return INT2NUM(-1); + } else if (result == (gunichar)-2) { + return INT2NUM(-2); + } + } else { + result = g_utf8_get_char(StringValueCStr(utf8)); + } + + return UINT2NUM(result); +} + +static VALUE +rg_s_size(G_GNUC_UNUSED VALUE self, VALUE rb_utf8) +{ + gchar *utf8; + + utf8 = StringValueCStr(rb_utf8); + return INT2NUM(g_utf8_strlen(utf8, RSTRING_LEN(rb_utf8))); +} + +static VALUE +rg_s_reverse(G_GNUC_UNUSED VALUE self, VALUE rb_utf8) +{ + VALUE result; + gchar *utf8, *reversed_utf8; + + utf8 = StringValueCStr(rb_utf8); + reversed_utf8 = g_utf8_strreverse(utf8, RSTRING_LEN(rb_utf8)); + result = CSTR2RVAL(reversed_utf8); + g_free(reversed_utf8); + return result; +} + +static VALUE +rg_s_validate(G_GNUC_UNUSED VALUE self, VALUE str) +{ + StringValue(str); + return CBOOL2RVAL(g_utf8_validate(RSTRING_PTR(str), RSTRING_LEN(str), + NULL)); +} + +static VALUE +rg_s_upcase(G_GNUC_UNUSED VALUE self, VALUE rb_utf8) +{ + VALUE result; + gchar *utf8, *upcased_utf8; + + utf8 = StringValueCStr(rb_utf8); + upcased_utf8 = g_utf8_strup(utf8, RSTRING_LEN(rb_utf8)); + result = CSTR2RVAL(upcased_utf8); + g_free(upcased_utf8); + return result; +} + +static VALUE +rg_s_downcase(G_GNUC_UNUSED VALUE self, VALUE rb_utf8) +{ + VALUE result; + gchar *utf8, *downcased_utf8; + + utf8 = StringValueCStr(rb_utf8); + downcased_utf8 = g_utf8_strdown(utf8, RSTRING_LEN(rb_utf8)); + result = CSTR2RVAL(downcased_utf8); + g_free(downcased_utf8); + return result; +} + +static VALUE +rg_s_casefold(G_GNUC_UNUSED VALUE self, VALUE rb_utf8) +{ + VALUE result; + gchar *utf8, *casefolded_utf8; + + utf8 = StringValueCStr(rb_utf8); + casefolded_utf8 = g_utf8_casefold(utf8, RSTRING_LEN(rb_utf8)); + result = CSTR2RVAL(casefolded_utf8); + g_free(casefolded_utf8); + return result; +} + +static VALUE +rg_s_normalize(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE rb_utf8, rb_mode, result; + gchar *utf8, *normalized_utf8; + GNormalizeMode mode = G_NORMALIZE_DEFAULT; + + rb_scan_args(argc, argv, "11", &rb_utf8, &rb_mode); + + if (!NIL_P(rb_mode)) + mode = RVAL2GENUM(rb_mode, G_TYPE_NORMALIZE_MODE); + + utf8 = StringValueCStr(rb_utf8); + normalized_utf8 = g_utf8_normalize(utf8, RSTRING_LEN(rb_utf8), mode); + result = CSTR2RVAL(normalized_utf8); + g_free(normalized_utf8); + return result; +} + +static VALUE +rg_s_collate(G_GNUC_UNUSED VALUE self, VALUE utf8a, VALUE utf8b) +{ + return INT2NUM(g_utf8_collate(StringValueCStr(utf8a), + StringValueCStr(utf8b))); +} + +static VALUE +rg_s_collate_key(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE result, rb_utf8, for_filename; + gchar *key, *utf8; + gssize len; + + rb_scan_args(argc, argv, "11", &rb_utf8, &for_filename); + + utf8 = StringValueCStr(rb_utf8); + len = RSTRING_LEN(rb_utf8); +#if GLIB_CHECK_VERSION(2,8,0) + if (RVAL2CBOOL(for_filename)) + key = g_utf8_collate_key_for_filename(utf8, len); + else +#endif + key = g_utf8_collate_key(utf8, len); + + result = CSTR2RVAL(key); + g_free(key); + return result; +} + +static VALUE +rg_s_to_utf16(G_GNUC_UNUSED VALUE self, VALUE rb_utf8) +{ + VALUE result; + gchar *utf8; + gunichar2 *utf16; + glong len, items_written; + GError *error = NULL; + + utf8 = StringValueCStr(rb_utf8); + len = RSTRING_LEN(rb_utf8); + + utf16 = g_utf8_to_utf16(utf8, len, NULL, &items_written, &error); + + if (error) + RAISE_GERROR(error); + + result = CSTR2RVAL_LEN_UTF16((char *)utf16, + items_written * sizeof(*utf16)); + g_free(utf16); + return result; +} + +static VALUE +rg_s_to_ucs4(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE result, rb_utf8, is_fast; + gchar *utf8; + gunichar *ucs4; + glong len, items_written; + + rb_scan_args(argc, argv, "11", &rb_utf8, &is_fast); + + utf8 = StringValueCStr(rb_utf8); + len = RSTRING_LEN(rb_utf8); + + if (RVAL2CBOOL(is_fast)) { + ucs4 = g_utf8_to_ucs4_fast(utf8, len, &items_written); + } else { + GError *error = NULL; + ucs4 = g_utf8_to_ucs4(utf8, len, NULL, &items_written, &error); + + if (error) + RAISE_GERROR(error); + } + + result = CSTR2RVAL_LEN_UCS4((char *)ucs4, items_written * sizeof(*ucs4)); + g_free(ucs4); + return result; +} + +void +Init_glib_utf8(void) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "UTF8"); + + /* + Not implemented. + g_utf8_next_char + */ + RG_DEF_SMETHOD(get_char, -1); + /* + Not implemented. + g_utf8_offset_to_pointer + g_utf8_pointer_to_offset + g_utf8_prev_char + g_utf8_find_next_char + g_utf8_find_prev_char + g_utf8_prev_char + */ + RG_DEF_SMETHOD(size, 1); + /* + Not implemented. + g_utf8_strncpy + g_utf8_strrchr + */ + RG_DEF_SMETHOD(reverse, 1); + RG_DEF_SMETHOD(validate, 1); + + RG_DEF_SMETHOD(upcase, 1); + RG_DEF_SMETHOD(downcase, 1); + RG_DEF_SMETHOD(casefold, 1); + + RG_DEF_SMETHOD(normalize, -1); + + RG_DEF_SMETHOD(collate, 2); + RG_DEF_SMETHOD(collate_key, -1); + + RG_DEF_SMETHOD(to_utf16, 1); + RG_DEF_SMETHOD(to_ucs4, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_utils.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_utils.c new file mode 100644 index 0000000..45a36aa --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_utils.c @@ -0,0 +1,350 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Pascal Terjan + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#define RG_TARGET_NAMESPACE mGLib + +#if GLIB_CHECK_VERSION(2,2,0) +static VALUE +rg_s_application_name(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(g_get_application_name()); +} + +static VALUE +rg_s_set_application_name(VALUE self, VALUE application_name) +{ + g_set_prgname(RVAL2CSTR_ACCEPT_NIL(application_name)); + return self; +} +#endif + +static VALUE +rg_s_prgname(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(g_get_prgname()); +} + +static VALUE +rg_s_set_prgname(VALUE self, VALUE prgname) +{ + g_set_prgname(RVAL2CSTR_ACCEPT_NIL(prgname)); + return self; +} + +static VALUE +rg_s_getenv(G_GNUC_UNUSED VALUE self, VALUE variable) +{ + return CSTR2RVAL(g_getenv(RVAL2CSTR(variable))); +} + +#if GLIB_CHECK_VERSION(2,4,0) +static VALUE +rg_s_setenv(G_GNUC_UNUSED VALUE self, VALUE variable, VALUE value, VALUE overwrite) +{ + return CBOOL2RVAL(g_setenv(RVAL2CSTR(variable), + RVAL2CSTR_ACCEPT_NIL(value), + RVAL2CBOOL(overwrite))); +} + +static VALUE +rg_s_unsetenv(VALUE self, VALUE variable) +{ + g_unsetenv(RVAL2CSTR(variable)); + return self; +} +#endif + +#if GLIB_CHECK_VERSION(2,8,0) +#ifdef HAVE_G_LISTENV +static VALUE +rg_s_listenv(G_GNUC_UNUSED VALUE self) +{ + gchar** c_list; + gchar** c_var; + VALUE r_list = rb_ary_new(); + c_list = g_listenv(); + c_var = c_list; + while(*c_var) { + rb_ary_push(r_list, CSTR2RVAL(*(c_var++))); + } + g_strfreev(c_list); + return r_list; +} +#endif + +static VALUE +rg_s_host_name(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(g_get_host_name()); +} +#endif + +static VALUE +rg_s_user_name(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(g_get_user_name()); +} + +static VALUE +rg_s_real_name(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(g_get_real_name()); +} + +#if GLIB_CHECK_VERSION(2, 6, 0) +static VALUE +rg_s_user_cache_dir(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(g_get_user_cache_dir()); +} + +static VALUE +rg_s_user_data_dir(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(g_get_user_data_dir()); +} + +static VALUE +rg_s_user_config_dir(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(g_get_user_config_dir()); +} + +static VALUE +rg_s_system_data_dirs(G_GNUC_UNUSED VALUE self) +{ + return STRV2RVAL((const gchar **)g_get_system_data_dirs()); +} + +static VALUE +rg_s_system_config_dirs(G_GNUC_UNUSED VALUE self) +{ + return STRV2RVAL((const gchar **)g_get_system_config_dirs()); +} +#endif + +#if GLIB_CHECK_VERSION(2, 14, 0) +static VALUE +rg_s_get_user_special_dir(G_GNUC_UNUSED VALUE self, VALUE directory) +{ + return CSTR2RVAL(g_get_user_special_dir(RVAL2GENUM(directory, + G_TYPE_USER_DIRECTORY))); +} +#endif + +static VALUE +rg_s_home_dir(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(g_get_home_dir()); +} + +static VALUE +rg_s_tmp_dir(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(g_get_tmp_dir()); +} + +static VALUE +rg_s_current_dir(G_GNUC_UNUSED VALUE self) +{ + gchar* dir = g_get_current_dir(); + VALUE ret = CSTR2RVAL(dir); + g_free(dir); + return ret; +} + +static VALUE +rg_s_path_is_absolute_p(G_GNUC_UNUSED VALUE self, VALUE fname) +{ + return CBOOL2RVAL(g_path_is_absolute(RVAL2CSTR(fname))); +} + +static VALUE +rg_s_path_skip_root(G_GNUC_UNUSED VALUE self, VALUE fname) +{ + return CSTR2RVAL(g_path_skip_root(RVAL2CSTR(fname))); +} + +static VALUE +rg_s_path_get_basename(G_GNUC_UNUSED VALUE self, VALUE fname) +{ + return CSTR2RVAL(g_path_get_basename(RVAL2CSTR(fname))); +} + +static VALUE +rg_s_path_get_dirname(G_GNUC_UNUSED VALUE self, VALUE fname) +{ + return CSTR2RVAL(g_path_get_dirname(RVAL2CSTR(fname))); +} + +/* +Use File.join() +gchar* g_build_filename (const gchar *first_element, + ...); +gchar* g_build_filenamev (gchar **args); +gchar* g_build_path (const gchar *separator, + const gchar *first_element, + ...); +gchar* g_build_pathv (const gchar *separator, + gchar **args); +*/ + +static VALUE +rg_s_find_program_in_path(G_GNUC_UNUSED VALUE self, VALUE program) +{ + gchar* path = g_find_program_in_path(RVAL2CSTR(program)); + VALUE ret = CSTR2RVAL(path); + g_free(path); + return ret; +} + +static VALUE +rg_s_bit_nth_lsf(G_GNUC_UNUSED VALUE self, VALUE mask, VALUE nth_bit) +{ + return INT2NUM(g_bit_nth_lsf(NUM2ULONG(mask), NUM2INT(nth_bit))); +} + +static VALUE +rg_s_bit_nth_msf(G_GNUC_UNUSED VALUE self, VALUE mask, VALUE nth_bit) +{ + return INT2NUM(g_bit_nth_msf(NUM2ULONG(mask), NUM2INT(nth_bit))); +} + +static VALUE +rg_s_bit_storage(G_GNUC_UNUSED VALUE self, VALUE number) +{ + return UINT2NUM(g_bit_storage(NUM2ULONG(number))); +} + +static VALUE +rg_s_spaced_primes_closest(G_GNUC_UNUSED VALUE self, VALUE num) +{ + return UINT2NUM(g_spaced_primes_closest(NUM2UINT(num))); +} + +/* +Use at_exit of ruby instead. +void g_atexit (GVoidFunc func); +*/ + +static VALUE +rg_s_parse_debug_string(G_GNUC_UNUSED VALUE self, VALUE string, VALUE keys) +{ + gint i, nkeys; + VALUE ary; + GDebugKey* gkeys; + + Check_Type(keys, RUBY_T_HASH); + ary = rb_funcall(keys, rb_intern("to_a"), 0); + nkeys = RARRAY_LEN(ary); + gkeys = ALLOCA_N(GDebugKey, nkeys); + for (i = 0; i < nkeys; i++) { + gkeys[i].key = RVAL2CSTR(RARRAY_PTR(RARRAY_PTR(ary)[i])[0]); + gkeys[i].value = NUM2UINT(RARRAY_PTR(RARRAY_PTR(ary)[i])[1]); + } + + return UINT2NUM(g_parse_debug_string(RVAL2CSTR(string), gkeys, nkeys)); +} + +/* +void (*GVoidFunc) (void); +void (*GFreeFunc) (gpointer data); + +Don't need them. +void g_qsort_with_data (gconstpointer pbase, + gint total_elems, + gsize size, + GCompareDataFunc compare_func, + gpointer user_data); + +void g_nullify_pointer (gpointer *nullify_location); +*/ + +static VALUE +rg_s_check_version_p(G_GNUC_UNUSED VALUE self, VALUE major, VALUE minor, VALUE micro) +{ + return CBOOL2RVAL(glib_major_version > NUM2UINT(major) || + (glib_major_version == NUM2UINT(major) && + glib_minor_version > NUM2UINT(minor)) || + (glib_major_version == NUM2UINT(major) && + glib_minor_version == NUM2UINT(minor) && + glib_micro_version >= NUM2UINT(micro))); +} + +void +Init_glib_utils(void) +{ + /* glib/gutils.h */ +#if GLIB_CHECK_VERSION(2, 14, 0) + G_DEF_CLASS(G_TYPE_USER_DIRECTORY, "UserDirectory", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_USER_DIRECTORY, "G_"); +#endif + +#if GLIB_CHECK_VERSION(2,2,0) + RG_DEF_SMETHOD(application_name, 0); + RG_DEF_SMETHOD(set_application_name, 1); +#endif + RG_DEF_SMETHOD(prgname, 0); + RG_DEF_SMETHOD(set_prgname, 1); + RG_DEF_SMETHOD(getenv, 1); +#if GLIB_CHECK_VERSION(2,4,0) + RG_DEF_SMETHOD(setenv, 2); + RG_DEF_SMETHOD(unsetenv, 1); +#endif +#if GLIB_CHECK_VERSION(2,8,0) +#ifdef HAVE_G_LISTENV + RG_DEF_SMETHOD(listenv, 0); +#endif + RG_DEF_SMETHOD(host_name, 0); +#endif + RG_DEF_SMETHOD(user_name, 0); + RG_DEF_SMETHOD(real_name, 0); + +#if GLIB_CHECK_VERSION(2, 6, 0) + RG_DEF_SMETHOD(user_cache_dir, 0); + RG_DEF_SMETHOD(user_data_dir, 0); + RG_DEF_SMETHOD(user_config_dir, 0); + RG_DEF_SMETHOD(system_data_dirs, 0); + RG_DEF_SMETHOD(system_config_dirs, 0); +#endif +#if GLIB_CHECK_VERSION(2, 14, 0) + RG_DEF_SMETHOD(get_user_special_dir, 1); +#endif + RG_DEF_SMETHOD(home_dir, 0); + RG_DEF_SMETHOD(tmp_dir, 0); + RG_DEF_SMETHOD(current_dir, 0); + + RG_DEF_SMETHOD_P(path_is_absolute, 1); + RG_DEF_SMETHOD(path_skip_root, 1); + RG_DEF_SMETHOD(path_get_basename, 1); + RG_DEF_SMETHOD(path_get_dirname, 1); + RG_DEF_SMETHOD(find_program_in_path, 1); + RG_DEF_SMETHOD(bit_nth_lsf, 2); + RG_DEF_SMETHOD(bit_nth_msf, 2); + RG_DEF_SMETHOD(bit_storage, 1); + RG_DEF_SMETHOD(spaced_primes_closest, 1); + RG_DEF_SMETHOD(parse_debug_string, 2); + RG_DEF_SMETHOD_P(check_version, 3); + +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_win32.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_win32.c new file mode 100644 index 0000000..775b255 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglib_win32.c @@ -0,0 +1,119 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" +#include "rbglib.h" + +#ifdef G_OS_WIN32 + +#define RG_TARGET_NAMESPACE mWin32 + +static VALUE +rg_s_error_message(VALUE self, VALUE error) +{ + return CSTR2RVAL_FREE(g_win32_error_message(NUM2INT(error))); +} + +static VALUE +rg_s_locale(VALUE self) +{ + return CSTR2RVAL_FREE(g_win32_getlocale()); +} + +static VALUE +rbglib_m_win32_locale_deprecated(VALUE self) +{ + rb_warn("GLib.win32_locale() is deprecated. Use GLib::Win32.locale instead"); + return rg_s_locale(self); +} + +#if GLIB_CHECK_VERSION(2,6,0) +static VALUE +rg_s_version(VALUE self) +{ + return UINT2NUM(g_win32_get_windows_version()); +} +#endif + +#if GLIB_CHECK_VERSION(2,8,0) +static VALUE +rg_s_locale_filename_from_utf8(VALUE self, VALUE utf8_filename) +{ + return CSTR2RVAL_FREE(g_win32_locale_filename_from_utf8(RVAL2CSTR(utf8_filename))); +} + +static VALUE +rbglib_m_win32_locale_filename_from_utf8_deprecated(VALUE self, + VALUE utf8_filename) +{ + rb_warn("GLib.win32_locale_filename_from_utf8() is deprecated. Use GLib::Win32.locale_filename_from_utf8 instead"); + return rg_s_locale_filename_from_utf8(self, utf8_filename); +} + +#endif + +# if GLIB_CHECK_VERSION(2, 16, 0) +static VALUE +rg_s_get_package_installation_directory_of_module(int argc, + VALUE *argv, + VALUE self) +{ + VALUE rb_module; + gchar *directory; + gpointer hmodule; + + rb_scan_args(argc, argv, "01", &rb_module); + if (NIL_P(rb_module)) + hmodule = NULL; + else + hmodule = GINT_TO_POINTER(NUM2INT(rb_module)); + + directory = g_win32_get_package_installation_directory_of_module(hmodule); + return CSTR2RVAL_FREE(directory); +} +# endif +#endif + +void +Init_glib_win32(void) +{ +#ifdef G_OS_WIN32 + /* glib/gwin32.h */ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "Win32"); + + RG_DEF_SMETHOD(error_message, 1); + RG_DEF_SMETHOD(locale, 0); + RG_DEF_SMETHOD(version, 0); + /* Deprecated */ + rbg_define_singleton_method(mGLib, "win32_locale", rbglib_m_win32_locale_deprecated, 0); + +# if GLIB_CHECK_VERSION(2,8,0) + RG_DEF_SMETHOD(locale_filename_from_utf8, 1); + /* Deprecated */ + rbg_define_singleton_method(mGLib, "win32_locale_filename_from_utf8", + rbglib_m_win32_locale_filename_from_utf8_deprecated, 1); +# endif + +# if GLIB_CHECK_VERSION(2, 16, 0) + RG_DEF_SMETHOD(get_package_installation_directory_of_module, -1); +# endif +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglibdeprecated.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglibdeprecated.c new file mode 100644 index 0000000..8b2e198 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglibdeprecated.c @@ -0,0 +1,56 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +static VALUE +rbg_filename_gslist_to_array_free_body(VALUE list) +{ + VALUE ary = rb_ary_new(); + GSList *p; + + for (p = (GSList *)list; p != NULL; p = g_slist_next(p)) + rb_ary_push(ary, CSTRFILENAME2RVAL(p->data)); + + return ary; +} + +static VALUE +rbg_filename_gslist_to_array_free_ensure(VALUE val) +{ + GSList *list = (GSList *)val; + GSList *p; + + for (p = list; p != NULL; p = g_slist_next(p)) + g_free((gchar *)p->data); + + g_slist_free(list); + + return Qnil; +} + +VALUE +rbg_filename_gslist_to_array_free(GSList *list) +{ + return rb_ensure(rbg_filename_gslist_to_array_free_body, (VALUE)list, + rbg_filename_gslist_to_array_free_ensure, (VALUE)list); +} + diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglibdeprecated.h b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglibdeprecated.h new file mode 100644 index 0000000..2315002 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbglibdeprecated.h @@ -0,0 +1,34 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Ruby-GNOME2 Project + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __RBGLIBDEPRECATED_H__ +#define __RBGLIBDEPRECATED_H__ + +G_BEGIN_DECLS + +#define CSTRFILENAMEARRAY2RVAL_FREE(s) (rbg_filename_gslist_to_array_free(s)) + +extern VALUE rbg_filename_gslist_to_array_free(GSList *list); + +G_END_DECLS + +#endif /* __RBGLIBDEPRECATED_H__ */ diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_boxed.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_boxed.c new file mode 100644 index 0000000..7070d76 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_boxed.c @@ -0,0 +1,279 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011-2013 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#define RG_TARGET_NAMESPACE rbgobj_cBoxed + +VALUE RG_TARGET_NAMESPACE; + +static void +boxed_mark(boxed_holder *holder) +{ + const RGObjClassInfo *cinfo; + + cinfo = GTYPE2CINFO_NO_CREATE(holder->type); + if (cinfo && cinfo->mark) + cinfo->mark(holder->boxed); +} + +static void +boxed_free(boxed_holder *holder) +{ + const RGObjClassInfo *cinfo; + + cinfo = GTYPE2CINFO_NO_CREATE(holder->type); + if (cinfo && cinfo->free) + cinfo->free(holder->boxed); + + if (holder->own && holder->boxed) + g_boxed_free(holder->type, holder->boxed); + + free(holder); +} + +/**********************************************************************/ + +static VALUE +rbgobj_boxed_s_allocate(VALUE klass) +{ + const RGObjClassInfo *cinfo = rbgobj_lookup_class(klass); + boxed_holder *holder; + VALUE result; + + if (cinfo->gtype == G_TYPE_BOXED) + rb_raise(rb_eTypeError, "abstract class"); + + result = Data_Make_Struct(klass, boxed_holder, + boxed_mark, boxed_free, holder); + holder->type = cinfo->gtype; + holder->boxed = NULL; + holder->own = FALSE; + + return result; +} + +static G_GNUC_NORETURN VALUE +rg_initialize(VALUE self) +{ + rb_raise(rb_eTypeError, "can't initialize %s", + rb_class2name(CLASS_OF(self))); +} + +static VALUE +rg_inspect(VALUE self) +{ + boxed_holder *holder; + gchar *s; + VALUE result; + + Data_Get_Struct(self, boxed_holder, holder); + + s = g_strdup_printf("#<%s:%p ptr=%p own=%s>", + rb_class2name(CLASS_OF(self)), + (void *)self, + holder->boxed, + holder->own ? "true" : "false"); + + result = rb_str_new2(s); + g_free(s); + + return result; +} + +static VALUE +rg_initialize_copy(VALUE self, VALUE orig) +{ + boxed_holder *holder1; + boxed_holder *holder2; + + if (self == orig) return self; + + if (!rb_obj_is_instance_of(orig, rb_obj_class(self))) { + rb_raise(rb_eTypeError, "wrong argument class"); + } + + Data_Get_Struct(self, boxed_holder, holder1); + Data_Get_Struct(orig, boxed_holder, holder2); + + holder1->boxed = g_boxed_copy(holder2->type, holder2->boxed); + holder1->own = TRUE; + + if (!holder1->boxed) + rb_raise(rb_eRuntimeError, "g_boxed_copy() failed"); + + return self; +} + +/* deprecated */ +VALUE +rbgobj_boxed_create(VALUE klass) +{ + return rbgobj_boxed_s_allocate(klass); +} + +/**********************************************************************/ + +void +rbgobj_boxed_initialize(VALUE obj, gpointer boxed) +{ + boxed_holder *holder; + Data_Get_Struct(obj, boxed_holder, holder); + holder->boxed = boxed; + holder->own = TRUE; +} + +gpointer +rbgobj_boxed_get_default(VALUE obj, GType gtype) +{ + boxed_holder *holder; + + if (!RVAL2CBOOL(rb_obj_is_kind_of(obj, GTYPE2CLASS(gtype)))) + rb_raise(rb_eArgError, "invalid argument %s (expect %s)", + rb_class2name(CLASS_OF(obj)), + rb_class2name(GTYPE2CLASS(gtype))); + + Data_Get_Struct(obj, boxed_holder, holder); + if (!holder->boxed) + rb_raise(rb_eArgError, "uninitialize %s", rb_class2name(CLASS_OF(obj))); + + return holder->boxed; +} + +gpointer +rbgobj_boxed_get(VALUE obj, GType gtype) +{ + gpointer boxed = NULL; + + if (NIL_P(obj)) + return NULL; + + if (rbgobj_convert_robj2instance(gtype, obj, &boxed)) { + return boxed; + } + + return rbgobj_boxed_get_default(obj, gtype); +} + +VALUE +rbgobj_make_boxed_raw(gpointer p, GType gtype, VALUE klass, gint flags) +{ + VALUE result; + boxed_holder *holder; + + result = rbgobj_boxed_s_allocate(klass); + + Data_Get_Struct(result, boxed_holder, holder); + + if (flags & RBGOBJ_BOXED_NOT_COPY) { + holder->boxed = p; + holder->own = FALSE; + } else { + holder->boxed = g_boxed_copy(gtype, p); + holder->own = TRUE; + } + + return result; +} + +VALUE +rbgobj_make_boxed_default(gpointer p, GType gtype) +{ + const RGObjClassInfo *cinfo; + + cinfo = GTYPE2CINFO(gtype); + return rbgobj_make_boxed_raw(p, gtype, cinfo->klass, cinfo->flags); +} + +VALUE +rbgobj_make_boxed(gpointer p, GType gtype) +{ + VALUE result; + + if (!p) + return Qnil; + + if (rbgobj_convert_instance2robj(gtype, p, &result)) { + return result; + } + + return rbgobj_make_boxed_default(p, gtype); +} + +void +rbgobj_boxed_not_copy_obj(GType gtype) +{ + RGObjClassInfo *cinfo = (RGObjClassInfo *)GTYPE2CINFO(gtype); + cinfo->flags |= RBGOBJ_BOXED_NOT_COPY; +} + +void +rbgobj_boxed_unown(VALUE boxed) +{ + boxed_holder *holder; + + Data_Get_Struct(boxed, boxed_holder, holder); + + if (!holder->own) { + rb_raise(rb_eArgError, + "The boxed is already unowned: %p", + boxed); + } + + holder->own = FALSE; +} + +/**********************************************************************/ + +static VALUE +boxed_to_ruby(const GValue *from) +{ + gpointer boxed; + boxed = g_value_get_boxed(from); + return rbgobj_make_boxed(boxed, G_VALUE_TYPE(from)); +} + +static void +boxed_from_ruby(VALUE from, GValue *to) +{ + gpointer boxed; + boxed = rbgobj_boxed_get(from, G_VALUE_TYPE(to)); + g_value_set_boxed(to, boxed); +} + +/**********************************************************************/ + +void +Init_gobject_gboxed(void) +{ + RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_BOXED, "Boxed", mGLib); + + rbgobj_register_g2r_func(G_TYPE_BOXED, boxed_to_ruby); + rbgobj_register_r2g_func(G_TYPE_BOXED, boxed_from_ruby); + + rb_define_alloc_func(RG_TARGET_NAMESPACE, (VALUE(*)_((VALUE)))rbgobj_boxed_s_allocate); + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "gtype", generic_s_gtype, 0); + rbg_define_method(RG_TARGET_NAMESPACE, "gtype", generic_gtype, 0); + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(inspect, 0); + RG_DEF_METHOD(initialize_copy, 1); + RG_DEF_ALIAS("copy", "dup"); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_closure.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_closure.c new file mode 100644 index 0000000..b46cefe --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_closure.c @@ -0,0 +1,345 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011-2013 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Ruby-GNOME2 Project + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#define RG_TARGET_NAMESPACE cClosure + +static ID id_call, id_closures; +static gboolean rclosure_initialized = FALSE; + +#define TAG_SIZE 64 +typedef struct _GRClosure GRClosure; +struct _GRClosure +{ + GClosure closure; + VALUE callback; + VALUE extra_args; + VALUE rb_holder; + gint count; + GList *objects; + GValToRValSignalFunc g2r_func; + gchar tag[TAG_SIZE]; +}; + +static VALUE +rclosure_default_g2r_func(guint num, const GValue *values) +{ + guint i; + VALUE args = rb_ary_new2(num); + for (i = 0; i < num; i++) + rb_ary_store(args, i, GVAL2RVAL(&values[i])); + return args; +} + +struct marshal_arg +{ + GClosure* closure; + GValue* return_value; + guint n_param_values; + const GValue* param_values; + gpointer invocation_hint; + gpointer marshal_data; +}; + +static int +rclosure_alive_p(GRClosure *rclosure) +{ + return (rclosure->count > 0 && !NIL_P(rclosure->rb_holder)); +} + +static VALUE +rclosure_marshal_do(VALUE arg_) +{ + struct marshal_arg *arg; + GRClosure* rclosure; + GValue* return_value; + guint n_param_values; + const GValue* param_values; + /* gpointer invocation_hint;*/ + /* gpointer marshal_data; */ + + VALUE ret = Qnil; + VALUE args; + GValToRValSignalFunc func; + + arg = (struct marshal_arg*)arg_; + rclosure = (GRClosure *)(arg->closure); + return_value = arg->return_value; + n_param_values = arg->n_param_values; + param_values = arg->param_values; + /* invocation_hint = arg->invocation_hint; */ + /* marshal_data = arg->marshal_data; */ + + if (rclosure->g2r_func){ + func = (GValToRValSignalFunc)rclosure->g2r_func; + } else { + func = (GValToRValSignalFunc)rclosure_default_g2r_func; + } + args = (*func)(n_param_values, param_values); + + if (rclosure_alive_p(rclosure)) { + VALUE callback, extra_args; + callback = rclosure->callback; + extra_args = rclosure->extra_args; + + if (!NIL_P(extra_args)) { + args = rb_ary_concat(args, extra_args); + } + + ret = rb_apply(callback, id_call, args); + } else { + rb_warn("GRClosure invoking callback: already destroyed: %s", + rclosure->tag[0] ? rclosure->tag : "(anonymous)"); + } + + if (return_value && G_VALUE_TYPE(return_value)) + rbgobj_rvalue_to_gvalue(ret, return_value); + + return Qnil; +} + +static void +rclosure_marshal(GClosure* closure, + GValue* return_value, + guint n_param_values, + const GValue* param_values, + gpointer invocation_hint, + gpointer marshal_data) +{ + struct marshal_arg arg; + + if (!rclosure_initialized) { + g_closure_invalidate(closure); + return; + } + + arg.closure = closure; + arg.return_value = return_value; + arg.n_param_values = n_param_values; + arg.param_values = param_values; + arg.invocation_hint = invocation_hint; + arg.marshal_data = marshal_data; + + G_PROTECT_CALLBACK(rclosure_marshal_do, &arg); +} + +static void rclosure_weak_notify(gpointer data, GObject* where_the_object_was); + +static void +rclosure_unref(GRClosure *rclosure) +{ + rclosure->count--; + + if (!rclosure_alive_p(rclosure)) { + GList *next; + for (next = rclosure->objects; next; next = next->next) { + GObject *object = G_OBJECT(next->data); + g_object_weak_unref(object, rclosure_weak_notify, rclosure); + } + g_list_free(rclosure->objects); + rclosure->objects = NULL; + if (!NIL_P(rclosure->rb_holder)) { + DATA_PTR(rclosure->rb_holder) = NULL; + rclosure->rb_holder = Qnil; + } + } +} + +static void +rclosure_invalidate(G_GNUC_UNUSED gpointer data, GClosure *closure) +{ + GRClosure *rclosure = (GRClosure*)closure; + + if (rclosure->count > 0) { + GList *next; + + rclosure->count = 1; + for (next = rclosure->objects; next; next = next->next) { + GObject *object = G_OBJECT(next->data); + VALUE obj = rbgobj_ruby_object_from_instance2(object, FALSE); + if (!NIL_P(rclosure->rb_holder) && !NIL_P(obj)) + G_REMOVE_RELATIVE(obj, id_closures, rclosure->rb_holder); + } + + rclosure_unref(rclosure); + } +} + +static void +gr_closure_holder_mark(GRClosure *rclosure) +{ + if (!rclosure) + return; + + rb_gc_mark(rclosure->callback); + rb_gc_mark(rclosure->extra_args); +} + +static void +gr_closure_holder_free(GRClosure *rclosure) +{ + if (!rclosure) + return; + + if (rclosure->count > 0) { + rclosure->count = 1; + + /* No need to remove us from the relatives hash of our objects, as + * those aren't alive anymore anyway */ + rclosure_unref(rclosure); + } +} + +GClosure* +g_rclosure_new(VALUE callback_proc, VALUE extra_args, GValToRValSignalFunc g2r_func) +{ + GRClosure* closure; + + closure = (GRClosure*)g_closure_new_simple(sizeof(GRClosure), NULL); + + closure->count = 1; + closure->g2r_func = g2r_func; + closure->objects = NULL; + closure->callback = callback_proc; + closure->extra_args = extra_args; + closure->rb_holder = Data_Wrap_Struct(rb_cData, + gr_closure_holder_mark, + gr_closure_holder_free, + closure); + closure->tag[0] = '\0'; + + g_closure_set_marshal((GClosure*)closure, &rclosure_marshal); + g_closure_add_invalidate_notifier((GClosure*)closure, NULL, + &rclosure_invalidate); + + return (GClosure*)closure; +} + +static void +rclosure_weak_notify(gpointer data, GObject* where_the_object_was) +{ + GRClosure *rclosure = data; + if (rclosure_alive_p(rclosure)) { + rclosure->objects = + g_list_remove(rclosure->objects, where_the_object_was); + rclosure_unref(rclosure); + } +} + +void +g_rclosure_attach(GClosure *closure, VALUE object) +{ + static VALUE mGLibObject = (VALUE)NULL; + GRClosure *rclosure = (GRClosure *)closure; + + G_RELATIVE2(object, Qnil, id_closures, rclosure->rb_holder); + + if (!mGLibObject) { + mGLibObject = rb_const_get(mGLib, rb_intern("Object")); + } + if (rb_obj_is_kind_of(object, mGLibObject)) { + GObject *gobject; + gobject = RVAL2GOBJ(object); + rclosure->count++; + g_object_weak_ref(gobject, rclosure_weak_notify, rclosure); + rclosure->objects = g_list_prepend(rclosure->objects, gobject); + } +} + +void +g_rclosure_set_tag(GClosure *closure, const gchar *tag) +{ + GRClosure *rclosure = (GRClosure *)closure; + + if (tag) { + strncpy(rclosure->tag, tag, TAG_SIZE); + rclosure->tag[TAG_SIZE - 1] = '\0'; + } else { + rclosure->tag[0] = '\0'; + } +} + +static void +rclosure_end_proc(G_GNUC_UNUSED VALUE _) +{ + rclosure_initialized = FALSE; +} + +static void +init_rclosure(void) +{ + id_call = rb_intern("call"); + id_closures = rb_intern("closures"); + rclosure_initialized = TRUE; + rb_set_end_proc(rclosure_end_proc, Qnil); +} + +/**********************************************************************/ + +static VALUE +rg_initialize(VALUE self) +{ + GClosure* closure = g_rclosure_new(rb_block_proc(), Qnil, NULL); + G_INITIALIZE(self, closure); + g_closure_sink(closure); + return self; +} + +static VALUE +rg_in_marshal_p(VALUE self) +{ + GClosure* closure = RVAL2BOXED(self, G_TYPE_CLOSURE); + return CBOOL2RVAL(closure->in_marshal); +} + +static VALUE +rg_invalid_p(VALUE self) +{ + GClosure* closure = RVAL2BOXED(self, G_TYPE_CLOSURE); + return CBOOL2RVAL(closure->is_invalid); +} + +static VALUE +rg_invalidate(VALUE self) +{ + GClosure* closure = RVAL2BOXED(self, G_TYPE_CLOSURE); + g_closure_invalidate(closure); + return self; +} + +/**********************************************************************/ + +void +Init_gobject_gclosure(void) +{ + VALUE RG_TARGET_NAMESPACE; + + init_rclosure(); + + RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_CLOSURE, "Closure", mGLib); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD_P(in_marshal, 0); + RG_DEF_METHOD_P(invalid, 0); + RG_DEF_METHOD(invalidate, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_convert.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_convert.c new file mode 100644 index 0000000..da2ee2d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_convert.c @@ -0,0 +1,192 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011-2013 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Sjoerd Simons, Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgobject.h" +#include "rbgprivate.h" + +static GHashTable *tables, *class_to_g_type_map; + +static void +rg_convert_table_free(gpointer data) +{ + RGConvertTable *table = data; + + if (table->notify) { + table->notify(table->user_data); + } + g_free(table); +} + +void +Init_gobject_convert(void) +{ + /* TODO: unref the below tables on exit. */ + tables = g_hash_table_new_full(g_int_hash, g_int_equal, NULL, + rg_convert_table_free); + class_to_g_type_map = g_hash_table_new(g_int_hash, g_int_equal); +} + +void +rbgobj_convert_define(const RGConvertTable *table) +{ + RGConvertTable *copied_table; + copied_table = g_memdup(table, sizeof(RGConvertTable)); + g_hash_table_insert(tables, &(copied_table->type), copied_table); + if (copied_table->klass != Qfalse && !NIL_P(copied_table->klass)) { + g_hash_table_insert(class_to_g_type_map, + &(copied_table->klass), &(copied_table->type)); + } +} + +RGConvertTable * +rbgobj_convert_lookup(GType type) +{ + return g_hash_table_lookup(tables, &type); +} + +gboolean +rbgobj_convert_has_type(GType type) +{ + return rbgobj_convert_lookup(type) != NULL; +} + +gboolean +rbgobj_convert_get_superclass(GType type, VALUE *result) +{ + RGConvertTable *table; + + table = rbgobj_convert_lookup(type); + if (table && table->get_superclass) { + *result = table->get_superclass(table->user_data); + return TRUE; + } + + return FALSE; +} + +gboolean +rbgobj_convert_type_init_hook(GType type, VALUE klass) +{ + RGConvertTable *table; + + table = rbgobj_convert_lookup(type); + if (table && table->type_init_hook) { + table->type_init_hook(klass, table->user_data); + return TRUE; + } + + return FALSE; +} + +gboolean +rbgobj_convert_rvalue2gvalue(GType type, VALUE value, GValue *result) +{ + RGConvertTable *table; + + table = rbgobj_convert_lookup(type); + if (table && table->rvalue2gvalue) { + table->rvalue2gvalue(value, result, table->user_data); + return TRUE; + } + + return FALSE; +} + +gboolean +rbgobj_convert_gvalue2rvalue(GType type, const GValue *value, VALUE *result) +{ + RGConvertTable *table; + + table = rbgobj_convert_lookup(type); + if (table && table->gvalue2rvalue) { + *result = table->gvalue2rvalue(value, table->user_data); + return TRUE; + } + + return FALSE; +} + +GType +rbgobj_convert_rvalue2gtype(VALUE value) +{ + VALUE klass; + GType *result; + + klass = rb_class_of(value); + result = g_hash_table_lookup(class_to_g_type_map, &klass); + return result ? *result : 0; +} + +gboolean +rbgobj_convert_initialize(GType type, VALUE obj, gpointer cobj) +{ + RGConvertTable *table; + + table = rbgobj_convert_lookup(type); + if (table && table->initialize) { + table->initialize(obj, cobj, table->user_data); + return TRUE; + } + + return FALSE; +} + +gboolean +rbgobj_convert_robj2instance(GType type, VALUE obj, gpointer *result) +{ + RGConvertTable *table; + + table = rbgobj_convert_lookup(type); + if (table && table->robj2instance) { + *result = table->robj2instance(obj, table->user_data); + return TRUE; + } + + return FALSE; +} + +gboolean +rbgobj_convert_instance2robj(GType type, gpointer instance, VALUE *result) +{ + RGConvertTable *table; + + table = rbgobj_convert_lookup(type); + if (table && table->instance2robj) { + *result = table->instance2robj(instance, table->user_data); + return TRUE; + } + + return FALSE; +} + +gboolean +rbgobj_convert_unref(GType type, gpointer instance) +{ + RGConvertTable *table; + + table = rbgobj_convert_lookup(type); + if (table && table->unref) { + table->unref(instance, table->user_data); + return TRUE; + } + + return FALSE; +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_enumflags.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_enumflags.c new file mode 100644 index 0000000..3dd40ad --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_enumflags.c @@ -0,0 +1,109 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004-2006 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" +#include + +typedef struct { + char *original; + char *replacement; +} constant_map; + +static GSList *rbgobj_cmap = NULL; + +static gint +rbgobj_constant_find(constant_map *a, char *name) +{ + return strcmp(a->original, name); +} + +void +rbgobj_constant_remap(const char *original, const char *replacement) +{ + constant_map *map = g_new(constant_map,1); + + map->original = g_strdup(original); + map->replacement = g_strdup(replacement); + + rbgobj_cmap = g_slist_append(rbgobj_cmap, map); +} + +char * +rg_obj_constant_lookup(const char *name) +{ + GSList *p = rbgobj_cmap; + + p = g_slist_find_custom(rbgobj_cmap, name, + (GCompareFunc)rbgobj_constant_find); + if (p) { + char *replacement; + constant_map *map; + + map = (constant_map *)p->data; + rbgobj_cmap = g_slist_delete_link(rbgobj_cmap, p); + replacement = map->replacement; + + g_free(map->original); + g_free(map); + + return replacement; + } + + return NULL; +} + +void +rbgobj_define_const(VALUE mod, const char *name, + VALUE value) +{ + if (name[0] >= 'A' && name[0] <= 'Z') { + rb_define_const(mod, name, value); + } else { + char *new_name = rg_obj_constant_lookup(name); + + if (new_name) { + rb_define_const(mod, new_name, value); + g_free(new_name); + } else { + rb_warn("Invalid constant name '%s' - skipped", name); + } + } +} + +void +rbgobj_add_constants(VALUE mod, GType type, const gchar *strip_prefix) +{ + if (G_TYPE_IS_ENUM(type)) { + rg_enum_add_constants(mod, type, strip_prefix); + } else if (G_TYPE_IS_FLAGS(type)) { + rg_flags_add_constants(mod, type, strip_prefix); + } else { + g_warning("`%s' is not an enum/flags type", g_type_name(type)); + } +} + +void +Init_gobject_genumflags(void) +{ + Init_gobject_genums(); + Init_gobject_gflags(); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_enums.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_enums.c new file mode 100644 index 0000000..8f293c5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_enums.c @@ -0,0 +1,401 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004-2006 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" +#include + +#define RG_TARGET_NAMESPACE rbgobj_cEnum + +VALUE RG_TARGET_NAMESPACE; + +static ID id_new; +static ID id_to_s; + +/**********************************************************************/ + +static gchar * +nick_to_const_name(const gchar *nick) +{ + gchar *const_name; + gchar *p; + + if (!nick) + return NULL; + + const_name = g_strdup(nick); + for (p = const_name; *p; p++) { + if (*p == '-' || *p == ' ') + *p = '_'; + else + *p = g_ascii_toupper(*p); + } + return const_name; +} + +VALUE +rg_enum_resolve_value(VALUE klass, VALUE nick) +{ + VALUE value = Qnil; + gchar *const_nick; + ID const_nick_id; + + if (RVAL2CBOOL(rb_obj_is_kind_of(nick, klass))) + return nick; + + nick = rb_funcall(nick, id_to_s, 0); + const_nick = nick_to_const_name(RVAL2CSTR(nick)); + const_nick_id = rb_intern(const_nick); + if (rb_const_defined(klass, const_nick_id)) { + value = rb_const_get(klass, const_nick_id); + } + g_free(const_nick); + + return value; +} + +void +rg_enum_add_constants(VALUE mod, GType enum_type, const gchar *strip_prefix) +{ + GEnumClass *gclass; + guint i; + int prefix_len = strlen(strip_prefix); + + gclass = G_ENUM_CLASS(g_type_class_ref(enum_type)); + + for (i = 0; i < gclass->n_values; i++) { + const GEnumValue* value = &gclass->values[i]; + + if (strncmp(value->value_name, strip_prefix, prefix_len)) { + g_warning("\"%s\" doesn't have prefix \"%s\"", + value->value_name, strip_prefix); + } else { + const char* name = value->value_name + prefix_len; + rbgobj_define_const(mod, name, + rbgobj_make_enum(value->value, enum_type)); + } + } + + g_type_class_unref(gclass); +} + +/**********************************************************************/ + +typedef struct { + GEnumClass* gclass; + gint value; + GEnumValue* info; +} enum_holder; + +static void +enum_free(enum_holder* p) +{ + g_type_class_unref(p->gclass); + free(p); +} + +static enum_holder* +enum_get_holder(VALUE obj) +{ + enum_holder* p; + Data_Get_Struct(obj, enum_holder, p); + return p; +} + +static VALUE +make_enum(gint n, VALUE klass) +{ + return rb_funcall(klass, id_new, 1, INT2NUM(n)); +} + +VALUE +rbgobj_make_enum(gint n, GType gtype) +{ + return make_enum(n, GTYPE2CLASS(gtype)); +} + +gint +rbgobj_get_enum(VALUE obj, GType gtype) +{ + VALUE klass; + + if (!g_type_is_a(gtype, G_TYPE_ENUM)) + rb_raise(rb_eTypeError, "%s is not a %s: %s", + g_type_name(gtype), g_type_name(G_TYPE_ENUM), + RBG_INSPECT(obj)); + + /* for compatibility */ + if (rb_obj_is_kind_of(obj, rb_cInteger)) + obj = rbgobj_make_enum(NUM2INT(obj), gtype); + + klass = GTYPE2CLASS(gtype); + + if (!rb_obj_is_kind_of(obj, klass)) { + VALUE enum_value; + + enum_value = rg_enum_resolve_value(klass, obj); + if (!NIL_P(enum_value)) + obj = enum_value; + } + + if (rb_obj_is_kind_of(obj, klass)) + return enum_get_holder(obj)->value; + else + rb_raise(rb_eTypeError, "not a %s: %s", + rb_class2name(klass), RBG_INSPECT(obj)); +} + +/**********************************************************************/ + +void +rbgobj_init_enum_class(VALUE klass) +{ + GEnumClass* gclass = g_type_class_ref(CLASS2GTYPE(klass)); + guint i; + + for (i = 0; i < gclass->n_values; i++) { + GEnumValue* entry = &(gclass->values[i]); + gchar *const_nick_name; + + const_nick_name = nick_to_const_name(entry->value_nick); + +#if 0 + { + ID id = rb_intern(const_nick_name); + if (rb_is_const_id(id)) { + VALUE value; + + value = make_enum(entry->value, klass); + rb_define_const(klass, const_nick_name, value); + } + } +#else + { + if (const_nick_name) { + VALUE value; + + value = make_enum(entry->value, klass); + rbgobj_define_const(klass, const_nick_name, value); + } + } +#endif + + g_free(const_nick_name); + } + + g_type_class_unref(gclass); +} + +static VALUE +rg_s_range(VALUE self) +{ + GEnumClass* gclass = g_type_class_ref(CLASS2GTYPE(self)); + VALUE result = rb_range_new(INT2NUM(gclass->minimum), + INT2NUM(gclass->maximum), + FALSE); + g_type_class_unref(gclass); + return result; +} + +struct enum_s_values_body_args { + GEnumClass *gclass; + VALUE self; +}; + +static VALUE +enum_s_values_body(VALUE value) +{ + struct enum_s_values_body_args *args = (struct enum_s_values_body_args *)value; + VALUE result = rb_ary_new(); + guint i; + + for (i = 0; i < args->gclass->n_values; i++) + rb_ary_push(result, make_enum(args->gclass->values[i].value, args->self)); + + return result; +} + +static VALUE +enum_s_values_ensure(VALUE gclass) +{ + g_type_class_unref((GEnumClass *)gclass); + + return Qnil; +} + +static VALUE +rg_s_values(VALUE self) +{ + struct enum_s_values_body_args args = { + g_type_class_ref(CLASS2GTYPE(self)), + self + }; + + return rb_ensure(enum_s_values_body, (VALUE)&args, + enum_s_values_ensure, (VALUE)args.gclass); +} + +static VALUE +enum_s_allocate(VALUE self) +{ + GType gtype = CLASS2GTYPE(self); + + if (G_TYPE_IS_ABSTRACT(gtype)) { + rb_raise(rb_eTypeError, "abstract class"); + } else { + enum_holder* p; + VALUE result = Data_Make_Struct(self, enum_holder, NULL, enum_free, p); + p->gclass = g_type_class_ref(gtype); + p->info = NULL; + return result; + } +} + +static VALUE +rg_initialize(VALUE self, VALUE arg) +{ + enum_holder* p = enum_get_holder(self); + + if (rb_respond_to(arg, rb_intern("to_str"))) { + const char* str = StringValuePtr(arg); + p->info = g_enum_get_value_by_name(p->gclass, str); + if (! p->info) + p->info = g_enum_get_value_by_nick(p->gclass, str); + if (! p->info) + rb_raise(rb_eArgError, "invalid argument"); + } else { + p->value = NUM2INT(arg); + p->info = g_enum_get_value(p->gclass, p->value); + } + + return Qnil; +} + +static VALUE +rg_to_i(VALUE self) +{ + enum_holder* p = enum_get_holder(self); + return INT2NUM(p->value); +} + +static VALUE +rg_name(VALUE self) +{ + enum_holder* p = enum_get_holder(self); + return p->info ? rb_str_new2(p->info->value_name) : Qnil; +} + +static VALUE +rg_nick(VALUE self) +{ + enum_holder* p = enum_get_holder(self); + return p->info ? rb_str_new2(p->info->value_nick) : Qnil; +} + +static VALUE +rg_inspect(VALUE self) +{ + const char* cname = rb_class2name(CLASS_OF(self)); + enum_holder* p = enum_get_holder(self); + gchar* str; + VALUE result; + + if (p->info) + str = g_strdup_printf("#<%s %s>", + cname, p->info->value_nick); + else + str = g_strdup_printf("#<%s %d>", + cname, p->value); + result = rb_str_new2(str); + g_free(str); + + return result; +} + +static VALUE +rg_operator_enum_eqv(VALUE self, VALUE rhs) +{ + enum_holder* p = enum_get_holder(self); + GType gtype = G_TYPE_FROM_CLASS(p->gclass); + VALUE klass = GTYPE2CLASS(gtype); + + if (!rb_obj_is_kind_of(rhs, rb_cInteger)) { + rhs = rg_enum_resolve_value(klass, rhs); + if (CLASS_OF(rhs) != CLASS_OF(self)) + return Qnil; + } + return CBOOL2RVAL(rbgobj_get_enum(self, gtype) == rbgobj_get_enum(rhs, gtype)); +} + +static VALUE +rg_hash(VALUE self) +{ + enum_holder* p = enum_get_holder(self); + return UINT2NUM(p->value ^ G_TYPE_FROM_CLASS(p->gclass)); +} + +static VALUE +rg_coerce(VALUE self, VALUE other) +{ + enum_holder *holder; + GType gtype; + + if (!rb_obj_is_kind_of(other, rb_cInteger)) + rb_raise(rb_eTypeError, "can't coerce"); + + holder = enum_get_holder(self); + gtype = G_TYPE_FROM_CLASS(holder->gclass); + other = rbgobj_make_enum(NUM2INT(other), gtype); + return rb_ary_new3(2, other, self); +} + +/**********************************************************************/ + +void +Init_gobject_genums(void) +{ + id_new = rb_intern("new"); + id_to_s = rb_intern("to_s"); + + RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_ENUM, "Enum", mGLib); + + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "gtype", generic_s_gtype, 0); + rbg_define_method(RG_TARGET_NAMESPACE, "gtype", generic_gtype, 0); + + RG_DEF_SMETHOD(range, 0); + RG_DEF_SMETHOD(values, 0); + + rb_define_alloc_func(RG_TARGET_NAMESPACE, enum_s_allocate); + + RG_DEF_METHOD(initialize, 1); + RG_DEF_METHOD(to_i, 0); + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(nick, 0); + + RG_DEF_METHOD(inspect, 0); + RG_DEF_METHOD_OPERATOR("==", enum_eqv, 1); + RG_DEF_METHOD(hash, 0); + RG_DEF_ALIAS("eql?", "=="); + + /* for compatibility */ + RG_DEF_METHOD(coerce, 1); + RG_DEF_ALIAS("to_int", "to_i"); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_flags.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_flags.c new file mode 100644 index 0000000..dedc0f9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_flags.c @@ -0,0 +1,522 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004-2006 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" +#include + +#define RG_TARGET_NAMESPACE rbgobj_cFlags + +VALUE RG_TARGET_NAMESPACE; + +static ID id_new; +static ID id_module_eval; +static ID id_or; + +/**********************************************************************/ + +static VALUE +resolve_flags_value(VALUE klass, VALUE nick_or_nicks) +{ + int i, len; + VALUE flags_value; + + if (!RVAL2CBOOL(rb_obj_is_kind_of(nick_or_nicks, rb_cArray))) + return rg_enum_resolve_value(klass, nick_or_nicks); + + len = RARRAY_LEN(nick_or_nicks); + flags_value = rb_funcall(klass, id_new, 0); + for (i = 0; i < len; i++) { + VALUE value; + + value = rg_enum_resolve_value(klass, RARRAY_PTR(nick_or_nicks)[i]); + if (NIL_P(value)) + return Qnil; + + flags_value = rb_funcall(flags_value, id_or, 1, value); + } + + return flags_value; +} + +void +rg_flags_add_constants(VALUE mod, GType flags_type, const gchar *strip_prefix) +{ + GFlagsClass *gclass; + guint i; + int prefix_len = strlen(strip_prefix); + + gclass = G_FLAGS_CLASS(g_type_class_ref(flags_type)); + + for (i = 0; i < gclass->n_values; i++) { + const GFlagsValue* value = &gclass->values[i]; + + if (strncmp(value->value_name, strip_prefix, prefix_len)) { + g_warning("\"%s\" doesn't have prefix \"%s\"", + value->value_name, strip_prefix); + } else { + const char* name = value->value_name + prefix_len; + rbgobj_define_const(mod, name, + rbgobj_make_flags(value->value, flags_type)); + + } + } + + g_type_class_unref(gclass); +} + +/**********************************************************************/ + +typedef struct { + GFlagsClass* gclass; + guint value; + GFlagsValue* info; +} flags_holder; + +static void +flags_free(flags_holder* p) +{ + g_type_class_unref(p->gclass); + free(p); +} + +static flags_holder* +flags_get_holder(VALUE obj) +{ + flags_holder* p; + Data_Get_Struct(obj, flags_holder, p); + return p; +} + +static VALUE +make_flags(guint n, VALUE klass) +{ + return rb_funcall(klass, id_new, 1, UINT2NUM(n)); +} + +VALUE +rbgobj_make_flags(guint n, GType gtype) +{ + return make_flags(n, GTYPE2CLASS(gtype)); +} + +guint +rbgobj_get_flags(VALUE obj, GType gtype) +{ + VALUE klass; + + if (!g_type_is_a(gtype, G_TYPE_FLAGS)) + rb_raise(rb_eTypeError, "%s is not a %s", + g_type_name(gtype), g_type_name(G_TYPE_FLAGS)); + + /* for compatibility */ + if (rb_obj_is_kind_of(obj, rb_cInteger)) + obj = rbgobj_make_flags(NUM2UINT(obj), gtype); + + klass = GTYPE2CLASS(gtype); + + if (!rb_obj_is_kind_of(obj, klass)) { + VALUE flags_value = Qnil; + + flags_value = resolve_flags_value(klass, obj); + if (!NIL_P(flags_value)) + obj = flags_value; + } + + if (rb_obj_is_kind_of(obj, klass)) + return flags_get_holder(obj)->value; + else + rb_raise(rb_eTypeError, "not a %s: %s", + rb_class2name(klass), RBG_INSPECT(obj)); +} + +/**********************************************************************/ + +void +rbgobj_init_flags_class(VALUE klass) +{ + GFlagsClass* gclass = g_type_class_ref(CLASS2GTYPE(klass)); + GString* source = g_string_new(NULL); + guint i; + + for (i = 0; i < gclass->n_values; i++) { + GFlagsValue* entry = &(gclass->values[i]); + gchar* nick; + gchar* p; + gchar* replace_nick; + + replace_nick = rg_obj_constant_lookup(entry->value_nick); + if (replace_nick){ + nick = g_strdup(replace_nick); + } else { + nick = g_strdup(entry->value_nick); + } + + for (p = nick; *p; p++) + if (*p == '-' || *p == ' ') + *p = '_'; + else + *p = tolower(*p); + + g_string_append_printf( + source, + "def %s%s?; self >= self.class.new(%d); end\n", + g_ascii_isdigit(nick[0]) ? "_" : "", + nick, entry->value); + + for (p = nick; *p; p++) + *p = g_ascii_toupper(*p); + +#if 0 + { + ID id = rb_intern(nick); + if (rb_is_const_id(id)) { + rb_define_const(klass, nick, make_flags(entry->value, klass)); + } + } +#else + { + rbgobj_define_const(klass, nick, make_flags(entry->value, klass)); + } +#endif + + g_free(nick); + } + + rb_funcall(klass, id_module_eval, 1, rb_str_new2(source->str)); + g_string_free(source, TRUE); + + g_type_class_unref(gclass); +} + +static VALUE +rg_s_mask(VALUE klass) +{ + GFlagsClass* gclass = g_type_class_ref(CLASS2GTYPE(klass)); + VALUE result = UINT2NUM(gclass->mask); + g_type_class_unref(gclass); + return result; +} + +static VALUE +rg_s_values(VALUE klass) +{ + GFlagsClass *gclass; + VALUE result; + guint i; + + gclass = g_type_class_ref(CLASS2GTYPE(klass)); + result = rb_ary_new(); + for (i = 0; i < gclass->n_values; i++) { + GFlagsValue *p = &(gclass->values[i]); + rb_ary_push(result, make_flags(p->value, klass)); + } + g_type_class_unref(gclass); + + return result; +} + +static VALUE +flags_s_allocate(VALUE self) +{ + GType gtype = CLASS2GTYPE(self); + + if (G_TYPE_IS_ABSTRACT(gtype)) { + rb_raise(rb_eTypeError, "abstract class"); + } else { + flags_holder* p; + VALUE result = Data_Make_Struct(self, flags_holder, NULL, flags_free, p); + p->gclass = g_type_class_ref(gtype); + p->value = 0; + p->info = NULL; + return result; + } +} + +static VALUE +rg_initialize(int argc, VALUE* argv, VALUE self) +{ + flags_holder* p = flags_get_holder(self); + VALUE arg; + + rb_scan_args(argc, argv, "01", &arg); + + if (argc == 0) { + p->value = 0; + } else { + if (rb_respond_to(arg, rb_intern("to_str"))) { + const char* str = StringValuePtr(arg); + p->info = g_flags_get_value_by_name(p->gclass, str); + if (!p->info) + p->info = g_flags_get_value_by_nick(p->gclass, str); + if (!p->info) + rb_raise(rb_eArgError, "invalid argument"); + p->value = p->info->value; + } else { + p->value = NUM2UINT(arg); + } + } + + if (!p->info) { + guint i; + for (i = 0; i < p->gclass->n_values; i++){ + GFlagsValue* val = &(p->gclass->values[i]); + if (val->value == p->value){ + p->info = val; + break; + } + } + } + + return Qnil; +} + +static VALUE +rg_to_i(VALUE self) +{ + flags_holder* p = flags_get_holder(self); + return UINT2NUM(p->value); +} + +static VALUE +rg_name(VALUE self) +{ + flags_holder* p = flags_get_holder(self); + return p->info ? rb_str_new2(p->info->value_name) : Qnil; +} + +static VALUE +rg_nick(VALUE self) +{ + flags_holder* p = flags_get_holder(self); + return p->info ? rb_str_new2(p->info->value_nick) : Qnil; +} + +#define FLAGS_COMP_EQUAL 0 +#define FLAGS_COMP_GREATER 1 +#define FLAGS_COMP_LESS -1 +#define FLAGS_COMP_ELSE -2 +#define FLAGS_COMP_INCOMPARABLE -3 + +static gint +flags_compare(VALUE self, VALUE rhs) +{ + flags_holder* p = flags_get_holder(self); + GType gtype = G_TYPE_FROM_CLASS(p->gclass); + VALUE klass = GTYPE2CLASS(gtype); + guint rhs_val; + + if (!rb_obj_is_kind_of(rhs, rb_cInteger)) { + rhs = resolve_flags_value(klass, rhs); + if (CLASS_OF(rhs) != CLASS_OF(self)) + return FLAGS_COMP_INCOMPARABLE; + } + + rhs_val = rbgobj_get_flags(rhs, gtype); + + if (p->value == rhs_val) + return FLAGS_COMP_EQUAL; + else if ((p->value & rhs_val) == rhs_val) + return FLAGS_COMP_GREATER; + else if ((p->value & rhs_val) == p->value) + return FLAGS_COMP_LESS; + else + return FLAGS_COMP_ELSE; +} + +static VALUE +rg_operator_flags_compare(VALUE self, VALUE rhs) +{ + gint ret = flags_compare(self, rhs); + switch (ret) { + case FLAGS_COMP_EQUAL: + case FLAGS_COMP_GREATER: + case FLAGS_COMP_LESS: + return INT2FIX(ret); + default: + return Qnil; + } +} + +static VALUE +rg_operator_flags_eqv(VALUE self, VALUE rhs) +{ + gint ret = flags_compare(self, rhs); + if (ret == FLAGS_COMP_INCOMPARABLE) + return Qnil; + return CBOOL2RVAL(ret == FLAGS_COMP_EQUAL); +} + +static VALUE +rg_operator_flags_gt_eq(VALUE self, VALUE rhs) +{ + gint ret = flags_compare(self, rhs); + if (ret == FLAGS_COMP_INCOMPARABLE) + return Qnil; + return CBOOL2RVAL(ret == FLAGS_COMP_GREATER || ret == FLAGS_COMP_EQUAL); +} + +static VALUE +rg_operator_flags_lt_eq(VALUE self, VALUE rhs) +{ + gint ret = flags_compare(self, rhs); + if (ret == FLAGS_COMP_INCOMPARABLE) + return Qnil; + return CBOOL2RVAL(ret == FLAGS_COMP_LESS || ret == FLAGS_COMP_EQUAL); +} + +static VALUE +rg_operator_flags_gt(VALUE self, VALUE rhs) +{ + gint ret = flags_compare(self, rhs); + if (ret == FLAGS_COMP_INCOMPARABLE) + return Qnil; + return CBOOL2RVAL(ret == FLAGS_COMP_GREATER); +} + +static VALUE +rg_operator_flags_lt(VALUE self, VALUE rhs) +{ + gint ret = flags_compare(self, rhs); + if (ret == FLAGS_COMP_INCOMPARABLE) + return Qnil; + return CBOOL2RVAL(ret == FLAGS_COMP_LESS); +} + +static VALUE +rg_operator_flags_not(VALUE self, G_GNUC_UNUSED VALUE rhs) +{ + flags_holder* p = flags_get_holder(self); + return rbgobj_make_flags((~ p->value) & p->gclass->mask, + G_TYPE_FROM_CLASS(p->gclass)); +} + +#define LIFT_BINARY_OP(funcname, op) \ + static VALUE \ + funcname(VALUE self, VALUE rhs) \ + { \ + flags_holder* p = flags_get_holder(self); \ + GType gtype = G_TYPE_FROM_CLASS(p->gclass); \ + return rbgobj_make_flags(p->value op rbgobj_get_flags(rhs, gtype), \ + gtype); \ + } + +LIFT_BINARY_OP(flags_and, &) +LIFT_BINARY_OP(flags_or, |) +LIFT_BINARY_OP(flags_xor, ^) + +static VALUE +rg_operator_flags_minus(VALUE self, VALUE rhs) +{ + flags_holder* p = flags_get_holder(self); + GType gtype = G_TYPE_FROM_CLASS(p->gclass); + return rbgobj_make_flags(p->value & ~rbgobj_get_flags(rhs, gtype), + gtype); +} + +static VALUE +rg_empty_p(VALUE self) +{ + flags_holder* p = flags_get_holder(self); + return CBOOL2RVAL(p->value == 0); +} + +static VALUE +rg_hash(VALUE self) +{ + flags_holder* p = flags_get_holder(self); + return UINT2NUM(p->value ^ G_TYPE_FROM_CLASS(p->gclass)); +} + +static VALUE +rg_coerce(VALUE self, VALUE other) +{ + flags_holder *holder; + GType gtype; + + if (rb_obj_is_kind_of(other, rb_cInteger)) + rb_raise(rb_eTypeError, "can't coerce"); + + holder = flags_get_holder(self); + gtype = G_TYPE_FROM_CLASS(holder->gclass); + other = rbgobj_make_flags(NUM2UINT(other), gtype); + return rb_ary_new3(2, other, self); +} + +static VALUE +rg_nonzero_p(VALUE self) +{ + flags_holder* p = flags_get_holder(self); + return CBOOL2RVAL(p->value != 0); +} + +/**********************************************************************/ + +void +Init_gobject_gflags(void) +{ + id_module_eval = rb_intern("module_eval"); + id_new = rb_intern("new"); + id_or = rb_intern("|"); + + RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_FLAGS, "Flags", mGLib); + + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "gtype", generic_s_gtype, 0); + rbg_define_method(RG_TARGET_NAMESPACE, "gtype", generic_gtype, 0); + + RG_DEF_SMETHOD(mask, 0); + RG_DEF_SMETHOD(values, 0); + + rb_define_alloc_func(RG_TARGET_NAMESPACE, flags_s_allocate); + + RG_DEF_METHOD(initialize, -1); + + RG_DEF_METHOD(to_i, 0); + RG_DEF_ALIAS("to_int", "to_i"); + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(nick, 0); + + /* + rbg_define_method(RG_TARGET_NAMESPACE, "inspect", flags_inspect, 0); + */ + + RG_DEF_METHOD_OPERATOR("<=>", flags_compare, 1); + RG_DEF_METHOD_OPERATOR("==", flags_eqv, 1); + RG_DEF_METHOD_OPERATOR(">=", flags_gt_eq, 1); + RG_DEF_METHOD_OPERATOR("<=", flags_lt_eq, 1); + RG_DEF_METHOD_OPERATOR(">", flags_gt, 1); + RG_DEF_METHOD_OPERATOR("<", flags_lt, 1); + RG_DEF_METHOD_OPERATOR("~", flags_not, 0); + rbg_define_method(RG_TARGET_NAMESPACE, "&", flags_and, 1); + rbg_define_method(RG_TARGET_NAMESPACE, "|", flags_or, 1); + rbg_define_method(RG_TARGET_NAMESPACE, "^", flags_xor, 1); + RG_DEF_METHOD_OPERATOR("-", flags_minus, 1); + + RG_DEF_METHOD_P(empty, 0); + + RG_DEF_METHOD(hash, 0); + RG_DEF_ALIAS("eql?", "=="); + + /* for compatibility */ + RG_DEF_METHOD(coerce, 1); + RG_DEF_ALIAS("zero?", "empty?"); + RG_DEF_METHOD_P(nonzero, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_object.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_object.c new file mode 100644 index 0000000..2687a84 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_object.c @@ -0,0 +1,865 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2003 Masahiro Sakai + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#define RG_TARGET_NAMESPACE rbgobj_cObject + +VALUE RG_TARGET_NAMESPACE; +static VALUE eNoPropertyError; +static GQuark RUBY_GOBJECT_OBJ_KEY; + +/* deperecated */ +void +rbgobj_add_abstract_but_create_instance_class(G_GNUC_UNUSED GType gtype) +{ +} + +static void +weak_notify(gpointer data, G_GNUC_UNUSED GObject *where_the_object_was) +{ + gobj_holder *holder = data; + + rbgobj_instance_call_cinfo_free(holder->gobj); + rbgobj_invalidate_relatives(holder->self); + holder->destroyed = TRUE; + + g_object_unref(holder->gobj); + holder->gobj = NULL; +} + +static void +holder_mark(gobj_holder *holder) +{ + if (holder->gobj && !holder->destroyed) + rbgobj_instance_call_cinfo_mark(holder->gobj); +} + +static void +holder_free(gobj_holder *holder) +{ + if (holder->gobj) { + if (!holder->destroyed) { + g_object_set_qdata(holder->gobj, RUBY_GOBJECT_OBJ_KEY, NULL); + g_object_weak_unref(holder->gobj, (GWeakNotify)weak_notify, holder); + weak_notify(holder, holder->gobj); + } + holder->gobj = NULL; + } + xfree(holder); +} + +static VALUE +gobj_s_allocate(VALUE klass) +{ + gobj_holder* holder; + VALUE result; + + result = Data_Make_Struct(klass, gobj_holder, holder_mark, holder_free, holder); + holder->self = result; + holder->gobj = NULL; + holder->cinfo = NULL; + holder->destroyed = FALSE; + + return result; +} + +/* deprecated */ +VALUE +rbgobj_create_object(VALUE klass) +{ + return gobj_s_allocate(klass); +} + +void +rbgobj_gobject_initialize(VALUE obj, gpointer cobj) +{ + gobj_holder* holder = g_object_get_qdata((GObject*)cobj, RUBY_GOBJECT_OBJ_KEY); + if (holder) + rb_raise(rb_eRuntimeError, "ruby wrapper for this GObject* already exists."); + Data_Get_Struct(obj, gobj_holder, holder); + holder->cinfo = RVAL2CINFO(obj); + holder->gobj = (GObject*)cobj; + holder->destroyed = FALSE; + + g_object_set_qdata((GObject*)cobj, RUBY_GOBJECT_OBJ_KEY, (gpointer)holder); + g_object_weak_ref((GObject*)cobj, (GWeakNotify)weak_notify, holder); + { + GType t1 = G_TYPE_FROM_INSTANCE(cobj); + GType t2 = CLASS2GTYPE(CLASS_OF(obj)); + + if (t1 != t2) { + if (!g_type_is_a(t1, t2)) + rb_raise(rb_eTypeError, "%s is not subtype of %s", + g_type_name(t1), g_type_name(t2)); + } + } +} + +VALUE +rbgobj_get_ruby_object_from_gobject(GObject* gobj, gboolean alloc) +{ + gobj_holder *holder; + + holder = g_object_get_qdata(gobj, RUBY_GOBJECT_OBJ_KEY); + if (holder) { + return holder->self; + } else if (alloc) { + VALUE obj; + + obj = gobj_s_allocate(GTYPE2CLASS(G_OBJECT_TYPE(gobj))); + gobj = g_object_ref(gobj); + rbgobj_gobject_initialize(obj, (gpointer)gobj); + return obj; + } else { + return Qnil; + } +} + +GObject* +rbgobj_get_gobject(VALUE obj) +{ + gobj_holder* holder; + + if (!RVAL2CBOOL(rb_obj_is_kind_of(obj, GTYPE2CLASS(G_TYPE_OBJECT)))) + rb_raise(rb_eTypeError, "not a GLib::Object"); + + Data_Get_Struct(obj, gobj_holder, holder); + + if (holder->destroyed) + rb_raise(rb_eTypeError, "destroyed GLib::Object"); + if (!holder->gobj) + rb_raise(rb_eTypeError, "uninitialize GLib::Object"); + + return holder->gobj; +} + +static VALUE +dummy_init(int argc, VALUE *argv, VALUE self) +{ + GType gtype = CLASS2GTYPE(CLASS_OF(self)); + if (G_TYPE_IS_ABSTRACT(gtype)) + rb_raise(rb_eTypeError, "initializing abstract class"); + else + return rb_call_super(argc, argv); +} + +void +rbgobj_init_object_class(VALUE klass) +{ + rbgobj_define_property_accessors(klass); + if (G_TYPE_IS_ABSTRACT(CLASS2GTYPE(klass))) + rbg_define_method(klass, "initialize", dummy_init, -1); +} + +/**********************************************************************/ + +static gboolean +is_gtkobject(GObject *gobj) +{ + static GType gtype_gtkobject = G_TYPE_INVALID; + if (!gtype_gtkobject) + gtype_gtkobject = g_type_from_name("GtkObject"); + return gtype_gtkobject && g_type_is_a(G_OBJECT_TYPE(gobj), gtype_gtkobject); +} + +static void +gobj_mark(gpointer ptr) +{ + GObject* gobj = ptr; + guint n_properties; + GParamSpec** properties; + GValue gval = G_VALUE_INIT; + guint i; + + properties = g_object_class_list_properties(G_OBJECT_GET_CLASS(gobj), &n_properties); + + for (i = 0; i < n_properties; i++) { + GParamSpec* pspec = properties[i]; + GType value_type = G_PARAM_SPEC_VALUE_TYPE(pspec); + if (G_TYPE_FUNDAMENTAL(value_type) != G_TYPE_OBJECT) continue; + if (!(pspec->flags & G_PARAM_READABLE)) continue; + /* FIXME: exclude types that doesn't have identity. */ + + { + g_value_init(&gval, value_type); + g_object_get_property(gobj, pspec->name, &gval); + rbgobj_gc_mark_gvalue(&gval); + g_value_unset(&gval); + } + } + + g_free(properties); +} + +static VALUE +rg_s_new_bang(int argc, VALUE *argv, VALUE self) +{ + const RGObjClassInfo* cinfo = rbgobj_lookup_class(self); + VALUE params_hash; + GObject* gobj; + VALUE result; + + rb_scan_args(argc, argv, "01", ¶ms_hash); + + if (!NIL_P(params_hash)) + Check_Type(params_hash, RUBY_T_HASH); + + if (cinfo->klass != self) + rb_raise(rb_eTypeError, "%s isn't registered class", + rb_class2name(self)); + + gobj = rbgobj_gobject_new(cinfo->gtype, params_hash); + result = GOBJ2RVAL(gobj); + + // XXX: Ughhhhh + if (is_gtkobject(gobj)){ + // We can't call gtk_object_sink() here. + // But hopefully someone will call it in the future. + //gtk_object_sink(gobj); + } else { + g_object_unref(gobj); + } + + return result; +} + +struct param_setup_arg { + GObjectClass* gclass; + GParameter* params; + guint param_size; + VALUE params_hash; + guint index; +}; + +static VALUE +_params_setup(VALUE arg, struct param_setup_arg *param_setup_arg) +{ + guint index; + VALUE name, val; + GParamSpec* pspec; + + index = param_setup_arg->index; + if (index >= param_setup_arg->param_size) + rb_raise(rb_eArgError, "too many parameters"); + + name = rb_ary_entry(arg, 0); + val = rb_ary_entry(arg, 1); + + if (SYMBOL_P(name)) + param_setup_arg->params[index].name = rb_id2name(SYM2ID(name)); + else + param_setup_arg->params[index].name = StringValuePtr(name); + + pspec = g_object_class_find_property( + param_setup_arg->gclass, + param_setup_arg->params[index].name); + if (!pspec) + rb_raise(rb_eArgError, "No such property: %s", + param_setup_arg->params[index].name); + + g_value_init(&(param_setup_arg->params[index].value), + G_PARAM_SPEC_VALUE_TYPE(pspec)); + rbgobj_rvalue_to_gvalue(val, &(param_setup_arg->params[index].value)); + + param_setup_arg->index++; + + return Qnil; +} + +static VALUE +gobj_new_body(struct param_setup_arg* arg) +{ + rb_iterate(rb_each, (VALUE)arg->params_hash, _params_setup, (VALUE)arg); + return (VALUE)g_object_newv(G_TYPE_FROM_CLASS(arg->gclass), + arg->param_size, arg->params); +} + +static VALUE +gobj_new_ensure(struct param_setup_arg* arg) +{ + guint i; + g_type_class_unref(arg->gclass); + for (i = 0; i < arg->param_size; i++) { + if (G_IS_VALUE(&arg->params[i].value)) + g_value_unset(&arg->params[i].value); + } + return Qnil; +} + +GObject* +rbgobj_gobject_new(GType gtype, VALUE params_hash) +{ + GObject* result; + + if (!g_type_is_a(gtype, G_TYPE_OBJECT)) + rb_raise(rb_eArgError, + "type \"%s\" is not descendant of GObject", + g_type_name(gtype)); + + if (NIL_P(params_hash)) { + result = g_object_newv(gtype, 0, NULL); + } else { + size_t param_size; + struct param_setup_arg arg; + + param_size = NUM2INT(rb_funcall(params_hash, rb_intern("length"), 0)); + + arg.param_size = param_size; + arg.gclass = G_OBJECT_CLASS(g_type_class_ref(gtype)); + arg.params = ALLOCA_N(GParameter, param_size); + memset(arg.params, 0, sizeof(GParameter) * param_size); + arg.params_hash = params_hash; + arg.index = 0; + + result = (GObject*)rb_ensure(&gobj_new_body, (VALUE)&arg, + &gobj_new_ensure, (VALUE)&arg); + } + + if (!result) + rb_raise(rb_eRuntimeError, "g_object_newv failed"); + + return result; +} + +static VALUE +rg_s_install_property(int argc, VALUE* argv, VALUE self) +{ + const RGObjClassInfo* cinfo = rbgobj_lookup_class(self); + gpointer gclass; + GParamSpec* pspec; + VALUE pspec_obj, prop_id; + + if (cinfo->klass != self) + rb_raise(rb_eTypeError, "%s isn't registered class", + rb_class2name(self)); + + rb_scan_args(argc, argv, "11", &pspec_obj, &prop_id); + pspec = G_PARAM_SPEC(RVAL2GOBJ(pspec_obj)); + + gclass = g_type_class_ref(cinfo->gtype); + g_object_class_install_property(gclass, + NIL_P(prop_id) ? 1 : NUM2UINT(prop_id), + pspec); + g_type_class_unref(gclass); + + /* FIXME: define accessor methods */ + + return Qnil; +} + +static VALUE +gobj_s_property(VALUE self, VALUE property_name) +{ + GObjectClass* oclass; + const char* name; + GParamSpec* prop; + VALUE result; + + if (SYMBOL_P(property_name)) + name = rb_id2name(SYM2ID(property_name)); + else + name = StringValuePtr(property_name); + + oclass = g_type_class_ref(CLASS2GTYPE(self)); + + prop = g_object_class_find_property(oclass, name); + if (!prop){ + g_type_class_unref(oclass); + rb_raise(eNoPropertyError, "No such property: %s", name); + } + + result = GOBJ2RVAL(prop); + g_type_class_unref(oclass); + return result; +} + +static VALUE +gobj_s_properties(int argc, VALUE* argv, VALUE self) +{ + GObjectClass* oclass = g_type_class_ref(CLASS2GTYPE(self)); + guint n_properties; + GParamSpec** props; + VALUE inherited_too; + VALUE ary; + guint i; + + if (rb_scan_args(argc, argv, "01", &inherited_too) == 0) + inherited_too = Qtrue; + + props = g_object_class_list_properties(oclass, &n_properties); + + ary = rb_ary_new(); + for (i = 0; i < n_properties; i++){ + if (RVAL2CBOOL(inherited_too) + || GTYPE2CLASS(props[i]->owner_type) == self) + rb_ary_push(ary, rb_str_new2(props[i]->name)); + } + g_free(props); + g_type_class_unref(oclass); + return ary; +} + +static VALUE type_to_prop_setter_table; +static VALUE type_to_prop_getter_table; + +void +rbgobj_register_property_setter(GType gtype, const char *name, RValueToGValueFunc func) +{ + GObjectClass* oclass; + GParamSpec* pspec; + + VALUE table = rb_hash_aref(type_to_prop_setter_table, INT2FIX(gtype)); + if (NIL_P(table)){ + table = rb_hash_new(); + rb_hash_aset(type_to_prop_setter_table, INT2FIX(gtype), table); + } + + oclass = g_type_class_ref(gtype); + pspec = g_object_class_find_property(oclass, name); + + rb_hash_aset(table, CSTR2RVAL(g_param_spec_get_name(pspec)), + Data_Wrap_Struct(rb_cData, NULL, NULL, func)); + + g_type_class_unref(oclass); +} + +void +rbgobj_register_property_getter(GType gtype, const char *name, GValueToRValueFunc func) +{ + GObjectClass* oclass; + GParamSpec* pspec; + + VALUE table = rb_hash_aref(type_to_prop_getter_table, INT2FIX(gtype)); + if (NIL_P(table)){ + table = rb_hash_new(); + rb_hash_aset(type_to_prop_getter_table, INT2FIX(gtype), table); + } + + oclass = g_type_class_ref(gtype); + pspec = g_object_class_find_property(oclass, name); + + rb_hash_aset(table, CSTR2RVAL(g_param_spec_get_name(pspec)), + Data_Wrap_Struct(rb_cData, NULL, NULL, func)); + + g_type_class_unref(oclass); +} + +static VALUE +rg_set_property(VALUE self, VALUE prop_name, VALUE val) +{ + GParamSpec* pspec; + const char* name; + + if (SYMBOL_P(prop_name)) + name = rb_id2name(SYM2ID(prop_name)); + else + name = StringValuePtr(prop_name); + + pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(RVAL2GOBJ(self)), + name); + + if (!pspec) + rb_raise(eNoPropertyError, "No such property: %s", name); + else { + // FIXME: use rb_ensure to call g_value_unset() + RValueToGValueFunc setter = NULL; + GValue gval = G_VALUE_INIT; + + g_value_init(&gval, G_PARAM_SPEC_VALUE_TYPE(pspec)); + + { + VALUE table = rb_hash_aref(type_to_prop_setter_table, + INT2FIX(pspec->owner_type)); + if (!NIL_P(table)){ + VALUE obj = rb_hash_aref(table, CSTR2RVAL(g_param_spec_get_name(pspec))); + if (!NIL_P(obj)) + Data_Get_Struct(obj, void, setter); + } + } + if (setter) { + setter(val, &gval); + } else { + rbgobj_rvalue_to_gvalue(val, &gval); + } + + g_object_set_property(RVAL2GOBJ(self), name, &gval); + g_value_unset(&gval); + + G_CHILD_SET(self, rb_intern(name), val); + + return self; + } +} + +static VALUE +rg_get_property(VALUE self, VALUE prop_name) +{ + GParamSpec* pspec; + const char* name; + + if (SYMBOL_P(prop_name)) + name = rb_id2name(SYM2ID(prop_name)); + else + name = StringValuePtr(prop_name); + + pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(RVAL2GOBJ(self)), + name); + + if (!pspec) + rb_raise(eNoPropertyError, "No such property: %s", name); + else { + // FIXME: use rb_ensure to call g_value_unset() + GValueToRValueFunc getter = NULL; + GValue gval = G_VALUE_INIT; + VALUE ret; + + { + VALUE table = rb_hash_aref(type_to_prop_getter_table, + INT2FIX(pspec->owner_type)); + if (!NIL_P(table)){ + VALUE obj = rb_hash_aref(table, CSTR2RVAL(g_param_spec_get_name(pspec))); + if (!NIL_P(obj)) + Data_Get_Struct(obj, void, getter); + } + } + + g_value_init(&gval, G_PARAM_SPEC_VALUE_TYPE(pspec)); + g_object_get_property(RVAL2GOBJ(self), name, &gval); + + ret = getter ? getter(&gval) : GVAL2RVAL(&gval); + g_value_unset(&gval); + + G_CHILD_SET(self, rb_intern(name), ret); + + return ret; + } +} + +static VALUE rg_thaw_notify(VALUE self); + +static VALUE +rg_freeze_notify(VALUE self) +{ + g_object_freeze_notify(RVAL2GOBJ(self)); + if (rb_block_given_p()) { + return rb_ensure(rb_yield, self, rg_thaw_notify, self); + } + return self; +} + +static VALUE +rg_notify(VALUE self, VALUE property_name) +{ + g_object_notify(RVAL2GOBJ(self), StringValuePtr(property_name)); + return self; +} + +static VALUE +rg_thaw_notify(VALUE self) +{ + g_object_thaw_notify(RVAL2GOBJ(self)); + return self; +} + +static VALUE +rg_destroyed_p(VALUE self) +{ + gobj_holder* holder; + + if (!RVAL2CBOOL(rb_obj_is_kind_of(self, GTYPE2CLASS(G_TYPE_OBJECT)))) + rb_raise(rb_eTypeError, "not a GLib::Object"); + + Data_Get_Struct(self, gobj_holder, holder); + + return CBOOL2RVAL(holder->destroyed); +} + +static VALUE +rg_inspect(VALUE self) +{ + gobj_holder* holder; + const char *class_name; + char *s; + VALUE result; + + Data_Get_Struct(self, gobj_holder, holder); + + class_name = rb_class2name(CLASS_OF(self)); + if (!holder->destroyed) + s = g_strdup_printf("#<%s:%p ptr=%p>", class_name, (void *)self, + holder->gobj); + else + s = g_strdup_printf("#<%s:%p destroyed>", class_name, (void *)self); + + result = rb_str_new2(s); + g_free(s); + + return result; +} + +static VALUE +rg_type_name(VALUE self) +{ + return CSTR2RVAL(G_OBJECT_TYPE_NAME(RVAL2GOBJ(self))); +} + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE params_hash; + GObject* gobj; + + rb_scan_args(argc, argv, "01", ¶ms_hash); + + if (!NIL_P(params_hash)) + Check_Type(params_hash, RUBY_T_HASH); + + gobj = rbgobj_gobject_new(RVAL2GTYPE(self), params_hash); + + if (is_gtkobject(gobj)){ + gobj = g_object_ref(gobj); + // We can't call gtk_object_sink() here. + // But hopefully someone will call it in the future. + //gtk_object_sink(gobj); + } + + G_INITIALIZE(self, gobj); + return Qnil; +} + +static VALUE +gobj_ref_count(VALUE self) +{ + gobj_holder* holder; + Data_Get_Struct(self, gobj_holder, holder); + return INT2NUM(holder->gobj ? holder->gobj->ref_count : 0); +} + +/**********************************************************************/ + +static VALUE proc_mod_eval; +static GQuark q_ruby_setter; +static GQuark q_ruby_getter; + +// FIXME: use rb_protect +static void +get_prop_func(GObject* object, + G_GNUC_UNUSED guint property_id, + GValue* value, + GParamSpec* pspec) +{ + ID ruby_getter = (ID)g_param_spec_get_qdata(pspec, q_ruby_getter); + if (!ruby_getter) { + gchar* name = g_strdup(g_param_spec_get_name(pspec)); + gchar* p; + for (p = name; *p; p++) { + if (*p == '-') + *p = '_'; + } + ruby_getter = rb_intern(name); + g_param_spec_set_qdata(pspec, q_ruby_getter, (gpointer)ruby_getter); + g_free(name); + } + + { + VALUE ret = rb_funcall(GOBJ2RVAL(object), ruby_getter, 0); + rbgobj_rvalue_to_gvalue(ret, value); + } +} + +// FIXME: use rb_protect +static void +set_prop_func(GObject* object, + G_GNUC_UNUSED guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + ID ruby_setter = (ID)g_param_spec_get_qdata(pspec, q_ruby_setter); + if (!ruby_setter) { + gchar* name = g_strconcat(g_param_spec_get_name(pspec), "=", NULL); + gchar* p; + for (p = name; *p; p++) { + if (*p == '-') + *p = '_'; + } + ruby_setter = rb_intern(name); + g_param_spec_set_qdata(pspec, q_ruby_setter, (gpointer)ruby_setter); + g_free(name); + } + + rb_funcall(GOBJ2RVAL(object), ruby_setter, 1, GVAL2RVAL(value)); +} + +// FIXME: use rb_protect +static void +class_init_func(gpointer g_class_, G_GNUC_UNUSED gpointer class_data) +{ + GObjectClass* g_class = G_OBJECT_CLASS(g_class_); + + g_class->set_property = set_prop_func; + g_class->get_property = get_prop_func; + +#if 0 + VALUE class_init_proc = (VALUE)class_data; + rb_funcall(proc_mod_eval, rb_intern("call"), 2, + GTYPE2CLASS(G_TYPE_FROM_CLASS(g_class)), class_init_proc); +#endif +} + +static VALUE +rg_s_type_register(int argc, VALUE* argv, VALUE self) +{ + VALUE type_name, flags; + volatile VALUE class_init_proc = Qnil; + GType parent_type; + GTypeInfo* info; + + rb_scan_args(argc, argv, "03", &type_name, &info, &flags); + + { + const RGObjClassInfo* cinfo = rbgobj_lookup_class(self); + if (cinfo->klass == self) + rb_raise(rb_eTypeError, "already registered"); + } + + { + VALUE superclass = rb_funcall(self, rb_intern("superclass"), 0); + const RGObjClassInfo* cinfo = rbgobj_lookup_class(superclass); + if (cinfo->klass != superclass) + rb_raise(rb_eTypeError, "super class must be registered to GLib"); + parent_type = cinfo->gtype; + } + + if (NIL_P(type_name)) { + VALUE s = rb_funcall(self, rb_intern("name"), 0); + + if (strlen(StringValuePtr(s)) == 0) + rb_raise(rb_eTypeError, "can't determine type name"); + + type_name = rb_funcall( + rb_eval_string("lambda{|x| x.gsub(/::/,'') }"), + rb_intern("call"), 1, s); + } + + { + GTypeQuery query; + g_type_query(parent_type, &query); + + /* TODO: Why new? g_type_register_static() doesn’t retain a copy, so + * this should be allocated on the stack. */ + info = g_new0(GTypeInfo, 1); + info->class_size = query.class_size; + info->base_init = NULL; + info->base_finalize = NULL; + info->class_init = class_init_func; + info->class_finalize = NULL; + info->class_data = (gpointer)class_init_proc; + info->instance_size = query.instance_size; + info->n_preallocs = 0; + info->instance_init = NULL; + info->value_table = NULL; + } + + { + GType type = g_type_register_static(parent_type, + StringValuePtr(type_name), + info, + NIL_P(flags) ? 0 : NUM2INT(flags)); + G_RELATIVE(self, class_init_proc); + + rbgobj_register_class(self, type, TRUE, TRUE); + + { + RGObjClassInfo* cinfo = (RGObjClassInfo*)rbgobj_lookup_class(self); + cinfo->flags |= RBGOBJ_DEFINED_BY_RUBY; + } + + { + GType parent = g_type_parent(type); + const RGObjClassInfo* cinfo = GTYPE2CINFO(parent); + VALUE m = rb_define_module_under(self, RubyGObjectHookModule); + + if (! (cinfo->flags & RBGOBJ_DEFINED_BY_RUBY)) { + rbg_define_method(m, "initialize", rg_initialize, -1); + } + + rb_include_module(self, m); + } + + return Qnil; + } +} + +/**********************************************************************/ + +void +Init_gobject_gobject(void) +{ + RG_TARGET_NAMESPACE = G_DEF_CLASS_WITH_GC_FUNC(G_TYPE_OBJECT, "Object", mGLib, + gobj_mark, NULL); + +#ifdef G_TYPE_INITIALLY_UNOWNED + G_DEF_CLASS(G_TYPE_INITIALLY_UNOWNED, "InitiallyUnowned", mGLib); +#endif + + RUBY_GOBJECT_OBJ_KEY = g_quark_from_static_string("__ruby_gobject_object__"); + + rb_define_alloc_func(RG_TARGET_NAMESPACE, (VALUE(*)_((VALUE)))gobj_s_allocate); + RG_DEF_SMETHOD_BANG(new, -1); + + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "property", &gobj_s_property, 1); + rbg_define_singleton_method(RG_TARGET_NAMESPACE, "properties", &gobj_s_properties, -1); + RG_DEF_SMETHOD(install_property, -1); + q_ruby_getter = g_quark_from_static_string("__ruby_getter"); + q_ruby_setter = g_quark_from_static_string("__ruby_setter"); + + RG_DEF_METHOD(set_property, 2); + RG_DEF_METHOD(get_property, 1); + RG_DEF_METHOD(freeze_notify, 0); + rb_undef_method(RG_TARGET_NAMESPACE, "notify"); + RG_DEF_METHOD(notify, 1); + RG_DEF_METHOD(thaw_notify, 0); + RG_DEF_METHOD_P(destroyed, 0); + + RG_DEF_METHOD(initialize, -1); + rbg_define_method(RG_TARGET_NAMESPACE, "ref_count", gobj_ref_count, 0); /* for debugging */ + RG_DEF_METHOD(inspect, 0); + RG_DEF_METHOD(type_name, 0); + + eNoPropertyError = rb_define_class_under(mGLib, "NoPropertyError", + rb_eNameError); + + rb_global_variable(&type_to_prop_setter_table); + rb_global_variable(&type_to_prop_getter_table); + type_to_prop_setter_table = rb_hash_new(); + type_to_prop_getter_table = rb_hash_new(); + + /* subclass */ + RG_DEF_SMETHOD(type_register, -1); + + rb_global_variable(&proc_mod_eval); + proc_mod_eval = rb_eval_string("lambda{|obj,proc| obj.module_eval(&proc)}"); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_param.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_param.c new file mode 100644 index 0000000..c54d7c8 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_param.c @@ -0,0 +1,378 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#define RG_TARGET_NAMESPACE rbgobj_cParam + +VALUE RG_TARGET_NAMESPACE; +static GQuark qparamspec; + +static VALUE pspec_s_allocate(VALUE klass); + +typedef struct { + GParamSpec* instance; + const RGObjClassInfo* cinfo; +} pspec_holder; + +static void +pspec_mark(pspec_holder *holder) +{ + if (holder->instance) + rbgobj_instance_call_cinfo_mark(holder->instance); +} + +static void +pspec_free(pspec_holder *holder) +{ + if (holder->instance){ + rbgobj_instance_call_cinfo_free(holder->instance); + g_param_spec_set_qdata(holder->instance, qparamspec, NULL); + g_param_spec_unref(holder->instance); + } + free(holder); +} + +GParamSpec* +rbgobj_get_param_spec(VALUE obj) +{ + pspec_holder* holder; + Data_Get_Struct(obj, pspec_holder, holder); + return G_PARAM_SPEC(holder->instance); +} + +void +rbgobj_param_spec_initialize(VALUE self, GParamSpec *pspec) +{ + pspec_holder* holder; + Data_Get_Struct(self, pspec_holder, holder); + + pspec = g_param_spec_ref(pspec); + g_param_spec_sink(pspec); + + holder->instance = pspec; + holder->cinfo = GTYPE2CINFO(G_PARAM_SPEC_TYPE(pspec)); + g_param_spec_set_qdata(pspec, qparamspec, (gpointer)self); +} + +VALUE +rbgobj_get_ruby_object_from_param_spec(GParamSpec* pspec, gboolean alloc) +{ + gpointer data = g_param_spec_get_qdata(pspec, qparamspec); + if (data) + return (VALUE)data; + else if (alloc) { + VALUE result = pspec_s_allocate(GTYPE2CLASS(G_PARAM_SPEC_TYPE(pspec))); + rbgobj_param_spec_initialize(result, pspec); + return result; + } else + return Qnil; +} + +/**********************************************************************/ + +static VALUE +pspec_s_allocate(VALUE klass) +{ + const RGObjClassInfo* cinfo = rbgobj_lookup_class(klass); + if (G_TYPE_IS_ABSTRACT(cinfo->gtype)) + rb_raise(rb_eTypeError, "abstract class"); + + { + pspec_holder* holder; + VALUE result; + + result = Data_Make_Struct(klass, pspec_holder, pspec_mark, pspec_free, + holder); + holder->instance = NULL; + holder->cinfo = NULL; + + return result; + } +} + +static VALUE +rg_inspect(VALUE self) +{ + GParamSpec* pspec = rbgobj_get_param_spec(self); + VALUE v = rb_inspect(GTYPE2CLASS(pspec->owner_type)); + gchar* str = g_strdup_printf("#<%s: %s#%s>", + rb_class2name(CLASS_OF(self)), + StringValuePtr(v), + g_param_spec_get_name(pspec)); + VALUE result = rb_str_new2(str); + g_free(str); + return result; +} + +static VALUE +rg_name(VALUE self) +{ + return rb_str_new2(g_param_spec_get_name(rbgobj_get_param_spec(self))); +} + +static VALUE +rg_nick(VALUE self) +{ + const gchar* str = g_param_spec_get_nick(rbgobj_get_param_spec(self)); + return str ? rb_str_new2(str) : Qnil; +} + +static VALUE +rg_blurb(VALUE self) +{ + const gchar* str = g_param_spec_get_blurb(rbgobj_get_param_spec(self)); + return str ? rb_str_new2(str) : Qnil; +} + +static VALUE +rg_flags(VALUE self) +{ + return INT2NUM(rbgobj_get_param_spec(self)->flags); +} + +static VALUE +rg_value_type(VALUE self) +{ + return rbgobj_gtype_new(G_PARAM_SPEC_VALUE_TYPE(rbgobj_get_param_spec(self))); +} + +static VALUE +rg_owner_type(VALUE self) +{ + return rbgobj_gtype_new(rbgobj_get_param_spec(self)->owner_type); +} + +static VALUE +rg_owner(VALUE self) +{ + return GTYPE2CLASS(rbgobj_get_param_spec(self)->owner_type); +} + +static VALUE +rg_value_default(VALUE self) +{ + GValue tmp = G_VALUE_INIT; + VALUE result; + + g_value_init(&tmp, + G_PARAM_SPEC_VALUE_TYPE(rbgobj_get_param_spec(self))); + g_param_value_set_default(rbgobj_get_param_spec(self), &tmp); + result = rbgobj_gvalue_to_rvalue(&tmp); + g_value_unset(&tmp); + + return result; +} + +#if 0 +static VALUE +rg_value_defaults_p(VALUE self, VALUE val) +{ + GValue tmp = {0,}; + gboolean result; + + /* FIXME: use rb_ensure to ensure following g_value_unset() call*/ + g_value_init(&tmp, + G_PARAM_SPEC_VALUE_TYPE(rbgobj_get_param_spec(self))); + rbgobj_rvalue_to_gvalue(val, &tmp); + result = g_param_value_defaults(rbgobj_get_param_spec(self), &tmp); + g_value_unset(&tmp); + + return CBOOL2RVAL(result); +} +#endif + +struct validate_arg{ + GParamSpec* pspec; + GValue* value; + VALUE obj; +}; + +static VALUE +value_validate_body(struct validate_arg* arg) +{ + VALUE ret; + gboolean b; + + rbgobj_rvalue_to_gvalue(arg->obj, arg->value); + b = g_param_value_validate(arg->pspec, arg->value); + ret = rbgobj_gvalue_to_rvalue(arg->value); + return rb_ary_new3(2, CBOOL2RVAL(b), ret); +} + +static VALUE +value_validate_ensure(struct validate_arg* arg) +{ + g_value_unset(arg->value); + return Qnil; +} + +static VALUE +rg_value_validate(VALUE self, VALUE obj) +{ + struct validate_arg arg; + GValue value = G_VALUE_INIT; + + arg.pspec = rbgobj_get_param_spec(self); + arg.value = &value; + arg.obj = obj; + + g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(arg.pspec)); + + return rb_ensure(value_validate_body, (VALUE)&arg, + value_validate_ensure, (VALUE)&arg); +} + +static VALUE +rg_value_convert(int argc, VALUE* argv, VALUE self) +{ + GParamSpec* pspec = rbgobj_get_param_spec(self); + VALUE src, strict_validation; + VALUE src_type; + VALUE result = Qnil; + GValue src_value = G_VALUE_INIT; + GValue dest_value = G_VALUE_INIT; + gboolean b; + + rb_scan_args(argc, argv, "21", &src, &src_type, &strict_validation); + + /* FIXME: use rb_ensure to ensure following g_value_unset() call*/ + g_value_init(&src_value, rbgobj_gtype_get(src_type)); + g_value_init(&dest_value, G_PARAM_SPEC_VALUE_TYPE(pspec)); + + rbgobj_rvalue_to_gvalue(src, &src_value); + + b = g_param_value_convert(rbgobj_get_param_spec(self), + &src_value, &dest_value, + RVAL2CBOOL(strict_validation)); + + if (b) + result = rbgobj_gvalue_to_rvalue(&dest_value); + + g_value_unset(&src_value); + g_value_unset(&dest_value); + + if (b) + return result; + else + rb_raise(rb_eTypeError, "can't convert"); +} + +static VALUE +rg_value_compare(VALUE self, VALUE a, VALUE b) +{ + GParamSpec* pspec = rbgobj_get_param_spec(self); + GType type = G_PARAM_SPEC_VALUE_TYPE(pspec); + GValue v1 = G_VALUE_INIT; + GValue v2 = G_VALUE_INIT; + gint result; + + g_value_init(&v1, type); + g_value_init(&v2, type); + + /* FIXME: use rb_ensure to ensure following g_value_unset() call*/ + rbgobj_rvalue_to_gvalue(a, &v1); + rbgobj_rvalue_to_gvalue(b, &v2); + + result = g_param_values_cmp(pspec, &v1, &v2); + + g_value_unset(&v1); + g_value_unset(&v2); + + return INT2NUM(result); +} + +static VALUE +rg_ref_count(VALUE self) +{ + return INT2NUM(G_PARAM_SPEC(rbgobj_get_param_spec(self))->ref_count); +} + +#define param_is_flag(flag) \ + static VALUE \ + param_is_##flag(VALUE self) \ + { \ + GParamSpec* pspec = G_PARAM_SPEC(rbgobj_get_param_spec(self)); \ + return CBOOL2RVAL(pspec->flags & flag); \ + } + +param_is_flag(G_PARAM_READABLE) +param_is_flag(G_PARAM_WRITABLE) +param_is_flag(G_PARAM_CONSTRUCT) +param_is_flag(G_PARAM_CONSTRUCT_ONLY) +param_is_flag(G_PARAM_LAX_VALIDATION) +param_is_flag(G_PARAM_PRIVATE) +param_is_flag(G_PARAM_READWRITE) + +/**********************************************************************/ + +void +Init_gobject_gparam(void) +{ + qparamspec = g_quark_from_static_string("__ruby_gobject_param_spec__"); + RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_PARAM, "Param", mGLib); + + /* GParamFlags */ + rb_define_const(RG_TARGET_NAMESPACE, "READABLE", INT2FIX(G_PARAM_READABLE)); + rb_define_const(RG_TARGET_NAMESPACE, "WRITABLE", INT2FIX(G_PARAM_WRITABLE)); + rb_define_const(RG_TARGET_NAMESPACE, "CONSTRUCT", INT2FIX(G_PARAM_CONSTRUCT)); + rb_define_const(RG_TARGET_NAMESPACE, "CONSTRUCT_ONLY", INT2FIX(G_PARAM_CONSTRUCT_ONLY)); + rb_define_const(RG_TARGET_NAMESPACE, "LAX_VALIDATION", INT2FIX(G_PARAM_LAX_VALIDATION)); + rb_define_const(RG_TARGET_NAMESPACE, "PRIVATE", INT2FIX(G_PARAM_PRIVATE)); + rb_define_const(RG_TARGET_NAMESPACE, "READWRITE", INT2FIX(G_PARAM_READWRITE)); + rb_define_const(RG_TARGET_NAMESPACE, "MASK", INT2FIX(G_PARAM_MASK)); + rb_define_const(RG_TARGET_NAMESPACE, "USER_SHIFT", INT2FIX(G_PARAM_USER_SHIFT)); + + rb_define_alloc_func(RG_TARGET_NAMESPACE, pspec_s_allocate); + + RG_DEF_METHOD(inspect, 0); + + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(nick, 0); + RG_DEF_METHOD(blurb, 0); + + RG_DEF_METHOD(flags, 0); + RG_DEF_METHOD(value_type, 0); + RG_DEF_METHOD(owner_type, 0); + RG_DEF_METHOD(owner, 0); + + RG_DEF_METHOD(value_default, 0); + RG_DEF_ALIAS("default", "value_default"); + + // FIXME: better name +#if 0 + RG_DEF_METHOD_P(value_defaults, 1); +#endif + RG_DEF_METHOD(value_validate, 1); + RG_DEF_METHOD(value_convert, -1); + RG_DEF_METHOD(value_compare, 2); + + /* for debugging */ + RG_DEF_METHOD(ref_count, 0); + + rbg_define_method(RG_TARGET_NAMESPACE, "readable?", param_is_G_PARAM_READABLE, 0); + rbg_define_method(RG_TARGET_NAMESPACE, "writable?", param_is_G_PARAM_WRITABLE, 0); + rbg_define_method(RG_TARGET_NAMESPACE, "construct?", param_is_G_PARAM_CONSTRUCT, 0); + rbg_define_method(RG_TARGET_NAMESPACE, "construct_only?", param_is_G_PARAM_CONSTRUCT_ONLY, 0); + rbg_define_method(RG_TARGET_NAMESPACE, "lax_validation?", param_is_G_PARAM_LAX_VALIDATION, 0); + rbg_define_method(RG_TARGET_NAMESPACE, "private?", param_is_G_PARAM_PRIVATE, 0); + rbg_define_method(RG_TARGET_NAMESPACE, "readwrite?", param_is_G_PARAM_READWRITE, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_paramspecs.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_paramspecs.c new file mode 100644 index 0000000..140b585 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_paramspecs.c @@ -0,0 +1,311 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#define DEF_NUMERIC_PSPEC_METHODS_FUNC(pspec_type, typename, from_ruby, to_ruby, pspec_cast) \ +static VALUE \ +typename##_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb, \ + VALUE minimum, VALUE maximum, VALUE default_value, \ + VALUE flags) \ +{ \ + GParamSpec* pspec; \ + pspec = g_param_spec_##typename(StringValuePtr(name), \ + StringValuePtr(nick), \ + StringValuePtr(blurb), \ + from_ruby(minimum), \ + from_ruby(maximum), \ + from_ruby(default_value), \ + NUM2UINT(flags)); \ + rbgobj_param_spec_initialize(self, pspec); \ + return Qnil; \ +} \ + \ +static VALUE \ +typename##_minimum(VALUE self) \ +{ \ + return to_ruby(pspec_cast(RVAL2GOBJ(self))->minimum); \ +} \ + \ +static VALUE \ +typename##_maximum(VALUE self) \ +{ \ + return to_ruby(pspec_cast(RVAL2GOBJ(self))->maximum); \ +} \ + \ +static VALUE \ +typename##_range(VALUE self) \ +{ \ + pspec_type* pspec = pspec_cast(RVAL2GOBJ(self)); \ + return rb_range_new(pspec->minimum, pspec->maximum, 0); \ +} + +DEF_NUMERIC_PSPEC_METHODS_FUNC(GParamSpecChar, char, NUM2INT, INT2FIX, G_PARAM_SPEC_CHAR) +DEF_NUMERIC_PSPEC_METHODS_FUNC(GParamSpecUChar, uchar, NUM2UINT, INT2FIX, G_PARAM_SPEC_UCHAR) +DEF_NUMERIC_PSPEC_METHODS_FUNC(GParamSpecInt, int, NUM2INT, INT2NUM, G_PARAM_SPEC_INT) +DEF_NUMERIC_PSPEC_METHODS_FUNC(GParamSpecUInt, uint, NUM2UINT, UINT2NUM, G_PARAM_SPEC_UINT) +DEF_NUMERIC_PSPEC_METHODS_FUNC(GParamSpecLong, long, NUM2LONG, INT2NUM, G_PARAM_SPEC_LONG) +DEF_NUMERIC_PSPEC_METHODS_FUNC(GParamSpecULong, ulong, NUM2ULONG, UINT2NUM, G_PARAM_SPEC_ULONG) +DEF_NUMERIC_PSPEC_METHODS_FUNC(GParamSpecInt64, int64, rbglib_num_to_int64, rbglib_int64_to_num, G_PARAM_SPEC_INT64) +DEF_NUMERIC_PSPEC_METHODS_FUNC(GParamSpecUInt64, uint64, rbglib_num_to_uint64, rbglib_uint64_to_num, G_PARAM_SPEC_UINT64) +DEF_NUMERIC_PSPEC_METHODS_FUNC(GParamSpecFloat, float, NUM2DBL, rb_float_new, G_PARAM_SPEC_FLOAT) +DEF_NUMERIC_PSPEC_METHODS_FUNC(GParamSpecDouble, double, NUM2DBL, rb_float_new, G_PARAM_SPEC_DOUBLE) + +static VALUE +float_epsilon(VALUE self) +{ + return rb_float_new(G_PARAM_SPEC_FLOAT(RVAL2GOBJ(self))->epsilon); +} + +static VALUE +double_epsilon(VALUE self) +{ + return rb_float_new(G_PARAM_SPEC_DOUBLE(RVAL2GOBJ(self))->epsilon); +} + + +static VALUE +boolean_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb, + VALUE default_value, VALUE flags) +{ + GParamSpec* pspec; + pspec = g_param_spec_boolean(StringValuePtr(name), + StringValuePtr(nick), + StringValuePtr(blurb), + RVAL2CBOOL(default_value), + NUM2UINT(flags)); + rbgobj_param_spec_initialize(self, pspec); + return Qnil; +} + +static VALUE +unichar_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb, + VALUE default_value, VALUE flags) +{ + GParamSpec* pspec; + pspec = g_param_spec_unichar(StringValuePtr(name), + StringValuePtr(nick), + StringValuePtr(blurb), + NUM2UINT(default_value), + NUM2UINT(flags)); + rbgobj_param_spec_initialize(self, pspec); + return Qnil; +} + +static VALUE +enum_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb, + VALUE enum_type, VALUE default_value, VALUE flags) +{ + GParamSpec* pspec; + GType gtype = rbgobj_gtype_get(enum_type); + + pspec = g_param_spec_enum(StringValuePtr(name), + StringValuePtr(nick), + StringValuePtr(blurb), + gtype, + RVAL2GENUM(default_value, gtype), + NUM2UINT(flags)); + rbgobj_param_spec_initialize(self, pspec); + return Qnil; +} + +static VALUE +flags_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb, + VALUE flags_type, VALUE default_value, VALUE flags) +{ + GParamSpec* pspec; + GType gtype = rbgobj_gtype_get(flags_type); + + pspec = g_param_spec_flags(StringValuePtr(name), + StringValuePtr(nick), + StringValuePtr(blurb), + gtype, + RVAL2GFLAGS(default_value, gtype), + NUM2UINT(flags)); + rbgobj_param_spec_initialize(self, pspec); + return Qnil; +} + +static VALUE +string_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb, + VALUE default_value, VALUE flags) +{ + GParamSpec* pspec; + pspec = g_param_spec_string(StringValuePtr(name), + StringValuePtr(nick), + StringValuePtr(blurb), + NIL_P(default_value) ? NULL : StringValuePtr(default_value), + NUM2UINT(flags)); + rbgobj_param_spec_initialize(self, pspec); + return Qnil; +} + +static VALUE +param_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb, + VALUE param_type, VALUE flags) +{ + GParamSpec* pspec; + pspec = g_param_spec_param(StringValuePtr(name), + StringValuePtr(nick), + StringValuePtr(blurb), + rbgobj_gtype_get(param_type), + NUM2UINT(flags)); + rbgobj_param_spec_initialize(self, pspec); + return Qnil; +} + +static VALUE +boxed_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb, + VALUE boxed_type, VALUE flags) +{ + GParamSpec* pspec; + pspec = g_param_spec_boxed(StringValuePtr(name), + StringValuePtr(nick), + StringValuePtr(blurb), + rbgobj_gtype_get(boxed_type), + NUM2UINT(flags)); + rbgobj_param_spec_initialize(self, pspec); + return Qnil; +} + +static VALUE +pointer_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb, VALUE flags) +{ + GParamSpec* pspec; + pspec = g_param_spec_pointer(StringValuePtr(name), + StringValuePtr(nick), + StringValuePtr(blurb), + NUM2UINT(flags)); + rbgobj_param_spec_initialize(self, pspec); + return Qnil; +} + +static VALUE +value_array_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb, + VALUE element_spec, VALUE flags) +{ + GParamSpec* pspec; + pspec = g_param_spec_value_array(StringValuePtr(name), + StringValuePtr(nick), + StringValuePtr(blurb), + RVAL2GOBJ(element_spec), + NUM2UINT(flags)); + rbgobj_param_spec_initialize(self, pspec); + return Qnil; +} + +static VALUE +object_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb, + VALUE object_type, VALUE flags) +{ + GParamSpec* pspec; + pspec = g_param_spec_object(StringValuePtr(name), + StringValuePtr(nick), + StringValuePtr(blurb), + rbgobj_gtype_get(object_type), + NUM2UINT(flags)); + rbgobj_param_spec_initialize(self, pspec); + return Qnil; +} + +void +Init_gobject_gparamspecs(void) +{ + VALUE cParamSpec = GTYPE2CLASS(G_TYPE_PARAM); + VALUE c; + +#define DEF_NUMERIC_PSPEC_METHODS(c, typename) \ + G_STMT_START {\ + rbg_define_method(c, "initialize", typename##_initialize, 7); \ + rbg_define_method(c, "minimum", typename##_minimum, 0); \ + rbg_define_method(c, "maximum", typename##_maximum, 0); \ + rbg_define_method(c, "range", typename##_range, 0); \ + } G_STMT_END + +#if 0 + rbg_define_method(c, "default_value", typename##_default_value, 0); \ + rb_define_alias(c, "default", "default_value"); \ + +#endif + + c = G_DEF_CLASS(G_TYPE_PARAM_CHAR, "Char", cParamSpec); + DEF_NUMERIC_PSPEC_METHODS(c, char); + + c = G_DEF_CLASS(G_TYPE_PARAM_UCHAR, "UChar", cParamSpec); + DEF_NUMERIC_PSPEC_METHODS(c, uchar); + + c = G_DEF_CLASS(G_TYPE_PARAM_INT, "Int", cParamSpec); + DEF_NUMERIC_PSPEC_METHODS(c, int); + + c = G_DEF_CLASS(G_TYPE_PARAM_UINT, "UInt", cParamSpec); + DEF_NUMERIC_PSPEC_METHODS(c, uint); + + c = G_DEF_CLASS(G_TYPE_PARAM_LONG, "Long", cParamSpec); + DEF_NUMERIC_PSPEC_METHODS(c, long); + + c = G_DEF_CLASS(G_TYPE_PARAM_ULONG, "ULong", cParamSpec); + DEF_NUMERIC_PSPEC_METHODS(c, ulong); + + c = G_DEF_CLASS(G_TYPE_PARAM_INT64, "Int64", cParamSpec); + DEF_NUMERIC_PSPEC_METHODS(c, int64); + + c = G_DEF_CLASS(G_TYPE_PARAM_UINT64, "UInt64", cParamSpec); + DEF_NUMERIC_PSPEC_METHODS(c, uint64); + + c = G_DEF_CLASS(G_TYPE_PARAM_FLOAT, "Float", cParamSpec); + DEF_NUMERIC_PSPEC_METHODS(c, float); + rbg_define_method(c, "epsilon", float_epsilon, 0); + + c = G_DEF_CLASS(G_TYPE_PARAM_DOUBLE, "Double", cParamSpec); + DEF_NUMERIC_PSPEC_METHODS(c, double); + rbg_define_method(c, "epsilon", double_epsilon, 0); + + c = G_DEF_CLASS(G_TYPE_PARAM_BOOLEAN, "Boolean", cParamSpec); + rbg_define_method(c, "initialize", boolean_initialize, 5); + + c = G_DEF_CLASS(G_TYPE_PARAM_UNICHAR, "UniChar", cParamSpec); + rbg_define_method(c, "initialize", unichar_initialize, 5); + + c = G_DEF_CLASS(G_TYPE_PARAM_ENUM, "Enum", cParamSpec); + rbg_define_method(c, "initialize", enum_initialize, 6); + + c = G_DEF_CLASS(G_TYPE_PARAM_FLAGS, "Flags", cParamSpec); + rbg_define_method(c, "initialize", flags_initialize, 6); + + c = G_DEF_CLASS(G_TYPE_PARAM_STRING, "String", cParamSpec); + rbg_define_method(c, "initialize", string_initialize, 5); + + c = G_DEF_CLASS(G_TYPE_PARAM_PARAM, "Param", cParamSpec); + rbg_define_method(c, "initialize", param_initialize, 5); + + c = G_DEF_CLASS(G_TYPE_PARAM_BOXED, "Boxed", cParamSpec); + rbg_define_method(c, "initialize", boxed_initialize, 5); + + c = G_DEF_CLASS(G_TYPE_PARAM_POINTER, "Pointer", cParamSpec); + rbg_define_method(c, "initialize", pointer_initialize, 4); + + c = G_DEF_CLASS(G_TYPE_PARAM_VALUE_ARRAY, "ValueArray", cParamSpec); + rbg_define_method(c, "initialize", value_array_initialize, 5); + + c = G_DEF_CLASS(G_TYPE_PARAM_OBJECT, "Object", cParamSpec); + rbg_define_method(c, "initialize", object_initialize, 5); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_signal.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_signal.c new file mode 100644 index 0000000..76ba109 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_signal.c @@ -0,0 +1,978 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#define RG_TARGET_NAMESPACE cSignal + +static VALUE RG_TARGET_NAMESPACE; +VALUE rbgobj_signal_wrap(guint sig_id); + +#define default_handler_method_prefix "signal_do_" + +/**********************************************************************/ + +static VALUE signal_func_table; + +void +rbgobj_set_signal_func(VALUE klass, const gchar *sig_name, GValToRValSignalFunc func) +{ + VALUE obj = Data_Wrap_Struct(rb_cData, NULL, NULL, func); + guint signal_id = g_signal_lookup(sig_name, CLASS2GTYPE(klass)); + rb_hash_aset(signal_func_table, UINT2NUM(signal_id), obj); +} + +GValToRValSignalFunc +rbgobj_get_signal_func(guint signal_id) +{ + GValToRValSignalFunc func = NULL; + VALUE func_obj = rb_hash_aref(signal_func_table, UINT2NUM(signal_id)); + if (!NIL_P(func_obj)) + Data_Get_Struct(func_obj, void, func); + return func; +} + +/**********************************************************************/ + +static VALUE eNoSignalError; + +// FIXME: use rb_protect +static gboolean +accumulator_func(G_GNUC_UNUSED GSignalInvocationHint *ihint, + GValue *return_accu, + const GValue *handler_return, + gpointer data) +{ + VALUE proc = (VALUE)data; + VALUE val = GVAL2RVAL(return_accu); + VALUE new = GVAL2RVAL(handler_return); + VALUE hint = Qnil; // FIXME + VALUE tmp; + gboolean continue_emission = TRUE; + + tmp = rb_funcall(proc, rb_intern("call"), 3, hint, val, new); + /* FIXME */ + if (TYPE(tmp) == T_ARRAY) { + continue_emission = RVAL2CBOOL(rb_ary_entry(tmp, 0)); + val = rb_ary_entry(tmp, 1); + } else { + val = tmp; + } + rbgobj_rvalue_to_gvalue(val, return_accu); + + return continue_emission; +} + +struct rval2gtypes_args { + VALUE ary; + long n; + GType *result; +}; + +static VALUE +rbg_rval2gtypes_body(VALUE value) +{ + long i; + struct rval2gtypes_args *args = (struct rval2gtypes_args *)value; + + for (i = 0; i < args->n; i++) + args->result[i] = rbgobj_gtype_get(RARRAY_PTR(args->ary)[i]); + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbg_rval2gtypes_rescue(VALUE value) +{ + g_free(((struct rval2gtypes_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static GType * +rbg_rval2gtypes(volatile VALUE *value, long *n) +{ + struct rval2gtypes_args args; + + args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value)); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(GType, args.n + 1); + + rb_rescue(rbg_rval2gtypes_body, (VALUE)&args, + rbg_rval2gtypes_rescue, (VALUE)&args); + + if (n != NULL) + *n = args.n; + + return args.result; +} + +static GType * +rbg_rval2gtypes_accept_nil(volatile VALUE *value, long *n) +{ + if (!NIL_P(*value)) + return rbg_rval2gtypes(value, n); + + if (n != NULL) + *n = 0; + + return NULL; +} + +#define RVAL2GTYPES(value, n) rbg_rval2gtypes(&(value), &(n)) +#define RVAL2GTYPES_ACCEPT_NIL(value, n) rbg_rval2gtypes_accept_nil(&(value), &(n)) + +static VALUE +gobj_s_signal_new(int argc, VALUE* argv, VALUE self) +{ + const RGObjClassInfo *cinfo = rbgobj_lookup_class(self); + VALUE rbsignal_name, rbsignal_flags, accumulator, rbreturn_type, params; + const gchar *signal_name; + GSignalFlags signal_flags; + GClosure *class_closure; + GType return_type; + GType *param_types; + long n_params; + guint signal; + + rb_scan_args(argc, argv, "4*", + &rbsignal_name, &rbsignal_flags, &accumulator, &rbreturn_type, ¶ms); + + if (cinfo->klass != self) + rb_raise(rb_eTypeError, "not a registered class: %s", + rb_class2name(self)); + + if (SYMBOL_P(rbsignal_name)) + rbsignal_name = rb_str_new2(rb_id2name(SYM2ID(rbsignal_name))); + signal_name = RVAL2CSTR(rbsignal_name); + + signal_flags = NUM2INT(rbsignal_flags); + + { + VALUE factory; + VALUE proc; + ID method_id; + + method_id = rb_to_id(rb_str_concat(rb_str_new2(default_handler_method_prefix), rbsignal_name)); + + factory = rb_eval_string( + "lambda{|klass, id|\n" + " lambda{|instance,*args|\n" + " klass.instance_method(id).bind(instance).call(*args)\n" + " }\n" + "}\n"); + proc = rb_funcall(factory, rb_intern("call"), 2, self, ID2SYM(method_id)); + + class_closure = g_rclosure_new(proc, Qnil, NULL); + /* TODO: Should this be done even if something below it fails? */ + g_rclosure_attach(class_closure, self); + } + + return_type = rbgobj_gtype_get(rbreturn_type); + param_types = RVAL2GTYPES_ACCEPT_NIL(params, n_params); + + signal = g_signal_newv(signal_name, + cinfo->gtype, + signal_flags, + class_closure, + NIL_P(accumulator) ? NULL : accumulator_func, + NIL_P(accumulator) ? NULL : (gpointer)accumulator, + NULL, /* c_marshaller */ + return_type, + n_params, + param_types); + + g_free(param_types); + + if (!signal) + rb_raise(rb_eRuntimeError, "g_signal_newv failed"); + + if (!NIL_P(accumulator)) + G_RELATIVE(self, accumulator); /* FIXME */ + + return rbgobj_signal_wrap(signal); +} + +static void +_signal_list(VALUE result, GType gtype) +{ + guint n_ids, i; + guint* ids = g_signal_list_ids(gtype, &n_ids); + for (i = 0; i < n_ids; i++) + rb_ary_push(result, rb_str_new2(g_signal_name(ids[i]))); + g_free(ids); +} + +static VALUE +gobj_s_signals(int argc, VALUE* argv, VALUE self) +{ + GType gtype; + VALUE inherited_too, result; + + if (rb_scan_args(argc, argv, "01", &inherited_too) == 0) + inherited_too = Qtrue; + gtype = CLASS2GTYPE(self); + result = rb_ary_new(); + + if (RVAL2CBOOL(inherited_too)){ + guint n_interfaces, i; + GType* interfaces = g_type_interfaces(gtype, &n_interfaces); + for (i = 0; i < n_interfaces; i++) + _signal_list(result, interfaces[i]); + g_free(interfaces); + + for (; gtype; gtype = g_type_parent(gtype)) + _signal_list(result, gtype); + } else if (GTYPE2CLASS(gtype) == self) { + _signal_list(result, gtype); + } + + return result; +} + +static VALUE +gobj_s_signal(VALUE self, VALUE name) +{ + const char* sig_name; + guint sig_id; + + if (SYMBOL_P(name)) + sig_name = rb_id2name(SYM2ID(name)); + else + sig_name = StringValuePtr(name); + + sig_id = g_signal_lookup(sig_name, CLASS2GTYPE(self)); + if (!sig_id) + rb_raise(eNoSignalError, "no such signal: %s", sig_name); + + return rbgobj_signal_wrap(sig_id); +} + +static VALUE +gobj_sig_has_handler_pending(int argc, VALUE *argv, VALUE self) +{ + VALUE sig, may_be_blocked; + const char* sig_name; + guint signal_id; + GQuark detail; + + rb_scan_args(argc, argv, "11", &sig, &may_be_blocked); + + if (SYMBOL_P(sig)) + sig_name = rb_id2name(SYM2ID(sig)); + else + sig_name = StringValuePtr(sig); + + if (!g_signal_parse_name(sig_name, CLASS2GTYPE(CLASS_OF(self)), &signal_id, &detail, TRUE)) + rb_raise(eNoSignalError, "no such signal: %s", sig_name); + + return CBOOL2RVAL(g_signal_has_handler_pending(RVAL2GOBJ(self), + signal_id, detail, + RVAL2CBOOL(may_be_blocked))); +} + +static VALUE +gobj_sig_connect_impl(gboolean after, int argc, VALUE *argv, VALUE self) +{ + VALUE sig, rest; + gulong handler_id; + GClosure* rclosure; + const char* sig_name; + guint signal_id; + GQuark detail; + VALUE func; + GObject *g_object; + gchar *tag; + + rb_scan_args(argc, argv, "1*", &sig, &rest); + + if (NIL_P(rest)) rest = rb_ary_new(); + + if (SYMBOL_P(sig)) + sig_name = rb_id2name(SYM2ID(sig)); + else + sig_name = StringValuePtr(sig); + + if (!g_signal_parse_name(sig_name, CLASS2GTYPE(CLASS_OF(self)), &signal_id, &detail, TRUE)) + rb_raise(eNoSignalError, "no such signal: %s", sig_name); + + func = rb_block_proc(); + rclosure = g_rclosure_new(func, rest, + rbgobj_get_signal_func(signal_id)); + g_rclosure_attach((GClosure *)rclosure, self); + g_object = RVAL2GOBJ(self); + tag = g_strdup_printf("%s::%s", + G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(g_object)), + sig_name); + g_rclosure_set_tag((GClosure *)rclosure, tag); + g_free(tag); + handler_id = g_signal_connect_closure_by_id(g_object, signal_id, detail, + rclosure, after); + + return ULONG2NUM(handler_id); +} + +static VALUE +gobj_sig_connect(int argc, VALUE *argv, VALUE self) +{ + return gobj_sig_connect_impl(FALSE, argc, argv, self); +} + +static VALUE +gobj_sig_connect_after(int argc, VALUE *argv, VALUE self) +{ + return gobj_sig_connect_impl(TRUE, argc, argv, self); +} + +#if 0 +static VALUE +gobj_sig_get_invocation_hint(VALUE self) +{ + GSignalInvocationHint* hint; + hint = g_signal_get_invocation_hint(RVAL2GOBJ(self)); + return rb_ary_new3(3, + rbgobj_signal_wrap(hint->signal_id), + hint->detail ? rb_str_new2(g_quark_to_string(hint->detail)) : Qnil, + INT2NUM(hint->run_type)); +} +#endif + +struct emit_arg { + VALUE self; + VALUE args; + + GSignalQuery query; + GQuark detail; + GValueArray* instance_and_params; +}; + +static VALUE +emit_body(struct emit_arg* arg) +{ + GValue param = G_VALUE_INIT; + + g_value_init(¶m, G_TYPE_FROM_INSTANCE(RVAL2GOBJ(arg->self))); + rbgobj_rvalue_to_gvalue(arg->self, ¶m); + g_value_array_append(arg->instance_and_params, ¶m); + g_value_unset(¶m); + + { + guint i; + for (i = 0; i < arg->query.n_params; i++){ + GType gtype = arg->query.param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE; + + g_value_init(¶m, gtype); + + rbgobj_rvalue_to_gvalue(rb_ary_entry(arg->args, i), ¶m); + g_value_array_append(arg->instance_and_params, ¶m); + g_value_unset(¶m); + } + } + + { + gboolean use_ret = (arg->query.return_type != G_TYPE_NONE); + GValue return_value = G_VALUE_INIT; + + if (use_ret) + g_value_init(&return_value, + arg->query.return_type & ~G_SIGNAL_TYPE_STATIC_SCOPE); + + g_signal_emitv(arg->instance_and_params->values, + arg->query.signal_id, arg->detail, + (use_ret) ? &return_value : NULL); + + if (use_ret) { + VALUE ret = GVAL2RVAL(&return_value); + g_value_unset(&return_value); + return ret; + } else { + return Qnil; + } + } +} + +static VALUE +emit_ensure(struct emit_arg* arg) +{ + g_value_array_free(arg->instance_and_params); + return Qnil; +} + +static VALUE +gobj_sig_emit(int argc, VALUE *argv, VALUE self) +{ + VALUE sig; + const char* sig_name; + guint signal_id; + struct emit_arg arg; + + rb_scan_args(argc, argv, "1*", &sig, &arg.args); + + if (SYMBOL_P(sig)) + sig_name = rb_id2name(SYM2ID(sig)); + else + sig_name = StringValuePtr(sig); + + if (!g_signal_parse_name(sig_name, + CLASS2GTYPE(CLASS_OF(self)), + &signal_id, &arg.detail, FALSE)) + rb_raise(eNoSignalError, "invalid signal \"%s\"", sig_name); + + g_signal_query(signal_id, &arg.query); + + if (arg.query.n_params != (guint)RARRAY_LEN(arg.args)) + rb_raise(rb_eArgError, "wrong number of arguments(%ld for %d)", + RARRAY_LEN(arg.args) + 1, + arg.query.n_params + 1); + + arg.self = self; + arg.instance_and_params = g_value_array_new(1 + arg.query.n_params); + + return rb_ensure(emit_body, (VALUE)&arg, emit_ensure, (VALUE)&arg); +} + +static VALUE +gobj_sig_emit_stop(VALUE self, VALUE sig) +{ + gpointer instance = RVAL2GOBJ(self); + const char* sig_name; + guint signal_id; + GQuark detail; + + if (SYMBOL_P(sig)) + sig_name = rb_id2name(SYM2ID(sig)); + else + sig_name = StringValuePtr(sig); + + if (!g_signal_parse_name(sig_name, + CLASS2GTYPE(CLASS_OF(self)), + &signal_id, &detail, FALSE)) + rb_raise(eNoSignalError, "invalid signal \"%s\"", sig_name); + + g_signal_stop_emission(instance, signal_id, detail); + return self; +} + +static VALUE gobj_sig_handler_unblock(VALUE self, VALUE id); + +static VALUE +_sig_handler_block_ensure(VALUE arg) +{ + VALUE self = RARRAY_PTR(arg)[0]; + VALUE id = RARRAY_PTR(arg)[1]; + gobj_sig_handler_unblock(self, id); + return Qnil; +} + +static VALUE +gobj_sig_handler_block(VALUE self, VALUE id) +{ + g_signal_handler_block(RVAL2GOBJ(self), NUM2ULONG(id)); + if (rb_block_given_p()) + rb_ensure(rb_yield, self, _sig_handler_block_ensure, + rb_ary_new3(2, self, id)); + return self; +} + +static VALUE +gobj_sig_handler_unblock(VALUE self, VALUE id) +{ + g_signal_handler_unblock(RVAL2GOBJ(self), NUM2ULONG(id)); + return self; +} + +static VALUE +gobj_sig_handler_disconnect(VALUE self, VALUE id) +{ + g_signal_handler_disconnect(RVAL2GOBJ(self), NUM2ULONG(id)); + return self; +} + +static VALUE +gobj_sig_handler_is_connected(VALUE self, VALUE id) +{ + return CBOOL2RVAL(g_signal_handler_is_connected(RVAL2GOBJ(self), NUM2ULONG(id))); +} + +#if 0 +gulong g_signal_handler_find (gpointer instance, + GSignalMatchType mask, + guint signal_id, + GQuark detail, + GClosure *closure, + gpointer func, + gpointer data); +guint g_signal_handlers_block_matched (gpointer instance, + GSignalMatchType mask, + guint signal_id, + GQuark detail, + GClosure *closure, + gpointer func, + gpointer data); +guint g_signal_handlers_unblock_matched (gpointer instance, + GSignalMatchType mask, + guint signal_id, + GQuark detail, + GClosure *closure, + gpointer func, + gpointer data); +guint g_signal_handlers_disconnect_matched (gpointer instance, + GSignalMatchType mask, + guint signal_id, + GQuark detail, + GClosure *closure, + gpointer func, + gpointer data); +#endif + +static VALUE +chain_from_overridden_body(struct emit_arg* arg) +{ + g_value_init(arg->instance_and_params->values, + G_TYPE_FROM_INSTANCE(RVAL2GOBJ(arg->self))); + rbgobj_rvalue_to_gvalue(arg->self, arg->instance_and_params->values); + + { + GValue* params = arg->instance_and_params->values + 1; + guint i; + for (i = 0; i < arg->query.n_params; i++) { + GType gtype = arg->query.param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE; + g_value_init(params + i, gtype); + rbgobj_rvalue_to_gvalue(rb_ary_entry(arg->args, i), params + i); + } + } + + { + gboolean use_ret = (arg->query.return_type != G_TYPE_NONE); + GValue return_value = G_VALUE_INIT; + + if (use_ret) + g_value_init(&return_value, + arg->query.return_type & ~G_SIGNAL_TYPE_STATIC_SCOPE); + + g_signal_chain_from_overridden(arg->instance_and_params->values, + (use_ret) ? &return_value : NULL); + + if (use_ret) { + VALUE ret = GVAL2RVAL(&return_value); + g_value_unset(&return_value); + return ret; + } else { + return Qnil; + } + } +} + +static VALUE +gobj_sig_chain_from_overridden(int argc, VALUE *argv, VALUE self) +{ + struct emit_arg arg; + + { + GSignalInvocationHint* hint; + hint = g_signal_get_invocation_hint(RVAL2GOBJ(self)); + if (!hint) + rb_raise(rb_eRuntimeError, "can't get signal invocation hint"); + g_signal_query(hint->signal_id, &arg.query); + } + + if (arg.query.n_params != (guint)argc) + rb_raise(rb_eArgError, "wrong number of arguments(%d for %d)", + argc, arg.query.n_params); + + arg.self = self; + arg.args = rb_ary_new4(argc, argv); + arg.instance_and_params = g_value_array_new(1 + argc); + + return rb_ensure(chain_from_overridden_body, (VALUE)&arg, + emit_ensure, (VALUE)&arg); +} + +static VALUE +gobj_s_method_added(VALUE klass, VALUE id) +{ + const RGObjClassInfo* cinfo = rbgobj_lookup_class(klass); + const char* name = rb_id2name(SYM2ID(id)); + const int prefix_len = strlen(default_handler_method_prefix); + guint signal_id; + + if (cinfo->klass != klass) return Qnil; + if (strncmp(default_handler_method_prefix, name, prefix_len)) return Qnil; + + signal_id = g_signal_lookup(name + prefix_len, cinfo->gtype); + if (!signal_id) return Qnil; + + { + GSignalQuery query; + g_signal_query(signal_id, &query); + if (query.itype == cinfo->gtype) + return Qnil; + } + + { + VALUE f = rb_eval_string( + "lambda{|klass, id|\n" + " lambda{|instance,*args|\n" + " klass.instance_method(id).bind(instance).call(*args)\n" + " }\n" + "}\n"); + VALUE proc = rb_funcall(f, rb_intern("call"), 2, klass, id); + GClosure* rclosure = g_rclosure_new(proc, Qnil, + rbgobj_get_signal_func(signal_id)); + g_rclosure_attach((GClosure *)rclosure, klass); + g_signal_override_class_closure(signal_id, cinfo->gtype, rclosure); + } + + { + VALUE mod = rb_define_module_under(klass, RubyGObjectHookModule); + rb_include_module(klass, mod); + rbg_define_method(mod, name, gobj_sig_chain_from_overridden, -1); + } + + return Qnil; +} + +/**********************************************************************/ + +VALUE +rbgobj_signal_wrap(guint sig_id) +{ + VALUE result; + GSignalQuery* query; + + result = Data_Make_Struct(RG_TARGET_NAMESPACE, GSignalQuery, NULL, free, query); + g_signal_query(sig_id, query); + return result; +} + +static VALUE +rg_id(VALUE self) +{ + GSignalQuery* query; + Data_Get_Struct(self, GSignalQuery, query); + return UINT2NUM(query->signal_id); +} + +static VALUE +rg_name(VALUE self) +{ + GSignalQuery* query; + Data_Get_Struct(self, GSignalQuery, query); + return rb_str_new2(query->signal_name); +} + +static VALUE +rg_itype(VALUE self) +{ + GSignalQuery* query; + Data_Get_Struct(self, GSignalQuery, query); + return rbgobj_gtype_new(query->itype); +} + +static VALUE +rg_owner(VALUE self) +{ + GSignalQuery* query; + Data_Get_Struct(self, GSignalQuery, query); + return GTYPE2CLASS(query->itype); +} + +static VALUE +rg_return_type(VALUE self) +{ + GSignalQuery* query; + Data_Get_Struct(self, GSignalQuery, query); + return rbgobj_gtype_new(query->return_type); +} + +static VALUE +rg_flags(VALUE self) +{ + GSignalQuery* query; + Data_Get_Struct(self, GSignalQuery, query); + return UINT2NUM(query->signal_flags); +} + +static VALUE +rg_param_types(VALUE self) +{ + GSignalQuery* query; + VALUE result; + guint i; + Data_Get_Struct(self, GSignalQuery, query); + + result = rb_ary_new2(query->n_params); + for (i = 0; i < query->n_params; i++) + rb_ary_store(result, i, rbgobj_gtype_new(query->param_types[i])); + + return result; +} + +static VALUE +rg_inspect(VALUE self) +{ + GSignalQuery* query; + gchar* s; + VALUE result, v; + + Data_Get_Struct(self, GSignalQuery, query); + + v = rb_inspect(GTYPE2CLASS(query->itype)); + + s = g_strdup_printf("#<%s: %s#%s>", + rb_class2name(CLASS_OF(self)), + StringValuePtr(v), + query->signal_name); + result = rb_str_new2(s); + g_free(s); + + return result; +} + +#define query_is_flag(flag) \ + static VALUE \ + query_is_##flag(VALUE self) \ + { \ + GSignalQuery* query; \ + Data_Get_Struct(self, GSignalQuery, query); \ + return CBOOL2RVAL(query->signal_flags & flag); \ + } + +query_is_flag(G_SIGNAL_RUN_FIRST) +query_is_flag(G_SIGNAL_RUN_LAST) +query_is_flag(G_SIGNAL_RUN_CLEANUP) +query_is_flag(G_SIGNAL_NO_RECURSE) +query_is_flag(G_SIGNAL_DETAILED) +query_is_flag(G_SIGNAL_ACTION) +query_is_flag(G_SIGNAL_NO_HOOKS) + +static gboolean +hook_func(GSignalInvocationHint* ihint, + guint n_param_values, + const GValue* param_values, + gpointer data) +{ + GClosure* closure = data; + GValue ret_val =G_VALUE_INIT; + gboolean ret; + + g_value_init(&ret_val, G_TYPE_BOOLEAN); + g_closure_invoke(closure, &ret_val, n_param_values, param_values, ihint); + ret = g_value_get_boolean(&ret_val); + g_value_unset(&ret_val); + + return ret; +} + +static gulong +g_signal_add_emission_hook_closure (guint signal_id, + GQuark detail, + GClosure* closure) +{ + guint hook_id; + g_closure_ref(closure); + g_closure_sink(closure); + hook_id = g_signal_add_emission_hook(signal_id, detail, + &hook_func, closure, + (GDestroyNotify)&g_closure_unref); + return hook_id; +} + +static VALUE +rg_add_emission_hook(int argc, VALUE* argv, VALUE self) +{ + GSignalQuery* query; + VALUE proc; + guint hook_id; + GQuark detail = 0; + GClosure* closure; + + Data_Get_Struct(self, GSignalQuery, query); + + if (query->signal_flags & G_SIGNAL_DETAILED) { + VALUE detail_obj; + if (rb_scan_args(argc, argv, "01&", &detail_obj, &proc) == 1) { + if (SYMBOL_P(detail_obj)) + detail = g_quark_from_string(rb_id2name(SYM2ID(detail_obj))); + else + detail = g_quark_from_string(StringValuePtr(detail_obj)); + } + } else { + rb_scan_args(argc, argv, "00&", &proc); + } + + closure = g_rclosure_new(proc, Qnil, + rbgobj_get_signal_func(query->signal_id)); + g_rclosure_attach(closure, self); + hook_id = g_signal_add_emission_hook_closure(query->signal_id, detail, closure); + return ULONG2NUM(hook_id); +} + +static VALUE +rg_remove_emission_hook(VALUE self, VALUE hook_id) +{ + GSignalQuery* query; + Data_Get_Struct(self, GSignalQuery, query); + g_signal_remove_emission_hook(query->signal_id, NUM2ULONG(hook_id)); + return Qnil; +} + +/**********************************************************************/ + +void +rbgobj_define_action_methods(VALUE klass) +{ + GType gtype = CLASS2GTYPE(klass); + GString* source; + guint n_ids; + guint* ids; + guint i; + + if (gtype == G_TYPE_INTERFACE) + return; + + ids = g_signal_list_ids(gtype, &n_ids); + if (n_ids == 0) + return; + + source = g_string_new(NULL); + for (i = 0; i < n_ids; i++){ + GSignalQuery query; + g_signal_query(ids[i], &query); + + if (query.signal_flags & G_SIGNAL_ACTION) { + gchar* method_name = g_strdup(query.signal_name); + gchar* p; + GString* args; + guint j; + + for (p = method_name; *p; p++) + if (*p == '-') + *p = '_'; + + args = g_string_new(NULL); + for (j = 0; j < query.n_params; j++) + g_string_append_printf(args, ",x%d", j); + + g_string_append_printf( + source, + "def %s(%s)\n signal_emit('%s'%s)\nend\n", + method_name, + (query.n_params > 0) ? args->str + 1 : "", // Skip initial ',' + query.signal_name, + args->str); + + g_free(method_name); + g_string_free(args, TRUE); + } + } + + if (source->len > 0) + rb_funcall(klass, rb_intern("module_eval"), 1, rb_str_new2(source->str)); + g_string_free(source, TRUE); +} + +/**********************************************************************/ + +void +Init_gobject_gsignal(void) +{ + VALUE cSignalFlags, cSignalMatchType; + + RG_TARGET_NAMESPACE = rb_define_class_under(mGLib, "Signal", rb_cData); + + RG_DEF_METHOD(id, 0); + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(flags, 0); + RG_DEF_METHOD(itype, 0); + RG_DEF_METHOD(owner, 0); + RG_DEF_METHOD(return_type, 0); + RG_DEF_METHOD(param_types, 0); + RG_DEF_METHOD(inspect, 0); + + RG_DEF_METHOD(add_emission_hook, -1); + RG_DEF_METHOD(remove_emission_hook, 1); + + /* GSignalFlags */ + cSignalFlags = G_DEF_CLASS(G_TYPE_SIGNAL_FLAGS, "SignalFlags", mGLib); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_SIGNAL_FLAGS, "G_SIGNAL_"); + rb_define_const(cSignalFlags, "MASK", INT2NUM(G_SIGNAL_FLAGS_MASK)); + rb_define_const(RG_TARGET_NAMESPACE, "FLAGS_MASK", INT2NUM(G_SIGNAL_FLAGS_MASK)); + + rbg_define_method(RG_TARGET_NAMESPACE, "run_first?", query_is_G_SIGNAL_RUN_FIRST, 0); + rbg_define_method(RG_TARGET_NAMESPACE, "run_last?", query_is_G_SIGNAL_RUN_LAST, 0); + rbg_define_method(RG_TARGET_NAMESPACE, "run_cleanup?", query_is_G_SIGNAL_RUN_CLEANUP, 0); + rbg_define_method(RG_TARGET_NAMESPACE, "no_recurse?", query_is_G_SIGNAL_NO_RECURSE, 0); + rbg_define_method(RG_TARGET_NAMESPACE, "detailed?", query_is_G_SIGNAL_DETAILED, 0); + rbg_define_method(RG_TARGET_NAMESPACE, "action?", query_is_G_SIGNAL_ACTION, 0); + rbg_define_method(RG_TARGET_NAMESPACE, "no_hooks?", query_is_G_SIGNAL_NO_HOOKS, 0); + + /* GConnectFlags */ + G_DEF_CLASS(G_TYPE_CONNECT_FLAGS, "ConnectFlags", mGLib); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_CONNECT_FLAGS, "G_"); + + /* GSignalMatchType */ + cSignalMatchType = G_DEF_CLASS(G_TYPE_SIGNAL_MATCH_TYPE, + "SignalMatchType", mGLib); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_SIGNAL_MATCH_TYPE, "G_SIGNAL_"); + rb_define_const(cSignalMatchType, "MASK", INT2NUM(G_SIGNAL_MATCH_MASK)); + rb_define_const(RG_TARGET_NAMESPACE, "MATCH_MASK", INT2NUM(G_SIGNAL_MATCH_MASK)); + + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_STATIC_SCOPE", INT2FIX(G_SIGNAL_TYPE_STATIC_SCOPE)); + + eNoSignalError = rb_define_class_under(mGLib, "NoSignalError", rb_eNameError); + + signal_func_table = rb_hash_new(); + rb_global_variable(&signal_func_table); + + rbg_define_method(mMetaInterface, "signal_new", gobj_s_signal_new, -1); + rbg_define_method(mMetaInterface, "signals", gobj_s_signals, -1); + rbg_define_method(mMetaInterface, "signal", gobj_s_signal, 1); + + rbg_define_method(cInstantiatable, "signal_has_handler_pending?", + gobj_sig_has_handler_pending, -1); + rbg_define_method(cInstantiatable, "signal_connect", gobj_sig_connect, -1); + rbg_define_method(cInstantiatable, "signal_connect_after", + gobj_sig_connect_after, -1); + +#if 0 + rbg_define_method(cInstantiatable, "signal_invocation_hint", + gobj_sig_get_invocation_hint, 0); +#endif + + rbg_define_method(cInstantiatable, "signal_emit", + gobj_sig_emit, -1); + rbg_define_method(cInstantiatable, "signal_emit_stop", + gobj_sig_emit_stop, 1); + rbg_define_method(cInstantiatable, "signal_handler_block", + gobj_sig_handler_block, 1); + rbg_define_method(cInstantiatable, "signal_handler_unblock", + gobj_sig_handler_unblock, 1); + rbg_define_method(cInstantiatable, "signal_handler_disconnect", + gobj_sig_handler_disconnect, 1); + + rbg_define_method(cInstantiatable, "signal_handler_is_connected?", + gobj_sig_handler_is_connected, 1); + + rbg_define_singleton_method(cInstantiatable, "method_added", + gobj_s_method_added, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_strv.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_strv.c new file mode 100644 index 0000000..f3fdf86 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_strv.c @@ -0,0 +1,48 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#if GLIB_CHECK_VERSION(2,6,0) + +static VALUE +strv_to_ruby(const GValue *from) +{ + return STRV2RVAL((const gchar **)g_value_get_boxed(from)); +} + +static void +strv_from_ruby(VALUE from, GValue *to) +{ + const gchar **strings = RVAL2STRV(from); + g_value_set_boxed(to, strings); + g_free(strings); +} + +void +Init_gobject_gstrv(void) +{ + /* GStrv is treated as Array */ + rbgobj_register_g2r_func(G_TYPE_STRV, strv_to_ruby); + rbgobj_register_r2g_func(G_TYPE_STRV, strv_from_ruby); +} + +#endif diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_type.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_type.c new file mode 100644 index 0000000..e1674ba --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_type.c @@ -0,0 +1,841 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2002-2013 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#define RG_TARGET_NAMESPACE rbgobj_cType + +/**********************************************************************/ +/* Type Mapping */ + +static VALUE rb_cMutex; +static VALUE lookup_class_mutex; + +static ID id_new; +static ID id_superclass; +static ID id_lock; +static ID id_unlock; +static GHashTable *gtype_to_cinfo; +static VALUE klass_to_cinfo; + +static GHashTable* dynamic_gtype_list; +typedef struct { + const gchar* name; + VALUE module; + RGMarkFunc mark; + RGFreeFunc free; + int flags; /* RGObjClassFlag */ +} RGObjClassInfoDynamic; + +typedef struct { + VALUE parent; + GType gtype; + gboolean create_class; +} RGObjClassByGtypeData; + +static void +cinfo_mark(RGObjClassInfo* cinfo) +{ + rb_gc_mark(cinfo->klass); +} + +const RGObjClassInfo * +rbgobj_lookup_class(VALUE klass) +{ + VALUE data = rb_hash_aref(klass_to_cinfo, klass); + if (!NIL_P(data)){ + RGObjClassInfo* cinfo; + Data_Get_Struct(data, RGObjClassInfo, cinfo); + return cinfo; + } + + if (TYPE(klass) == T_CLASS) { + VALUE super; + if (FL_TEST(klass, FL_SINGLETON)) { + super = rb_class_real(klass); + } else { + super = rb_funcall(klass, id_superclass, 0); + } + return rbgobj_lookup_class(super); + } + + rb_raise(rb_eRuntimeError, "can't get gobject class information"); +} + +static const RGObjClassInfo *rbgobj_lookup_class_by_gtype_without_lock(GType gtype, + VALUE parent, + gboolean create_class); + +static VALUE +get_superclass(GType gtype) +{ + VALUE super_class; + + if (rbgobj_convert_get_superclass(gtype, &super_class)) + return super_class; + + switch (gtype) { + case G_TYPE_PARAM: + case G_TYPE_OBJECT: + return cInstantiatable; + case G_TYPE_BOXED: + return rb_cObject; + case G_TYPE_POINTER: + return rb_cData; + case G_TYPE_ENUM: + case G_TYPE_FLAGS: + return rb_cObject; + default: + { + GType parent_type; + + parent_type = g_type_parent(gtype); + if (parent_type == G_TYPE_INVALID) { + return cInstantiatable; + } else { + const RGObjClassInfo *cinfo_super; + cinfo_super = + rbgobj_lookup_class_by_gtype_without_lock(parent_type, + Qnil, + TRUE); + return cinfo_super->klass; + } + } + } +} + +static const RGObjClassInfo * +rbgobj_lookup_class_by_gtype_without_lock(GType gtype, VALUE parent, + gboolean create_class) +{ + GType fundamental_type; + RGObjClassInfo* cinfo; + RGObjClassInfoDynamic* cinfod; + void* gclass = NULL; + VALUE c; + + if (gtype == G_TYPE_INVALID) + return NULL; + + cinfo = g_hash_table_lookup(gtype_to_cinfo, GUINT_TO_POINTER(gtype)); + if (cinfo) + return cinfo; + + if (!create_class) + return NULL; + + c = Data_Make_Struct(rb_cData, RGObjClassInfo, cinfo_mark, NULL, cinfo); + cinfo->gtype = gtype; + cinfo->mark = NULL; + cinfo->free = NULL; + cinfo->flags = 0; + + fundamental_type = G_TYPE_FUNDAMENTAL(gtype); + switch (fundamental_type){ + case G_TYPE_POINTER: + case G_TYPE_BOXED: + case G_TYPE_PARAM: + case G_TYPE_OBJECT: + case G_TYPE_ENUM: + case G_TYPE_FLAGS: + if (NIL_P(parent)) parent = get_superclass(gtype); + cinfo->klass = rb_funcall(rb_cClass, id_new, 1, parent); + break; + + case G_TYPE_INTERFACE: + cinfo->klass = rb_module_new(); + break; + + default: + if (NIL_P(parent)) parent = get_superclass(gtype); + if (NIL_P(parent)) { + fprintf(stderr, + "%s: %s's fundamental type %s isn't supported\n", + "rbgobj_lookup_class_by_gtype", + g_type_name(gtype), + g_type_name(fundamental_type)); + return NULL; + } + cinfo->klass = rb_funcall(rb_cClass, id_new, 1, parent); + } + + cinfod = (RGObjClassInfoDynamic *)g_hash_table_lookup(dynamic_gtype_list, + g_type_name(gtype)); + if (cinfod){ + cinfo->mark = cinfod->mark; + cinfo->free = cinfod->free; + rb_define_const(cinfod->module, cinfod->name, cinfo->klass); + } + + rb_hash_aset(klass_to_cinfo, cinfo->klass, c); + g_hash_table_insert(gtype_to_cinfo, GUINT_TO_POINTER(gtype), cinfo); + + if (G_TYPE_IS_CLASSED(gtype)) + gclass = g_type_class_ref(gtype); + + if (G_TYPE_IS_INSTANTIATABLE(gtype) || G_TYPE_IS_INTERFACE(gtype)) + rbgobj_define_action_methods(cinfo->klass); + + if (G_TYPE_IS_INSTANTIATABLE(gtype)){ + GType* interfaces = NULL; + guint n_interfaces = 0; + guint i; + + interfaces = g_type_interfaces(gtype, &n_interfaces); + for (i = 0; i < n_interfaces; i++){ + const RGObjClassInfo *iface_cinfo; + iface_cinfo = + rbgobj_lookup_class_by_gtype_without_lock(interfaces[i], + Qnil, + TRUE); + rb_include_module(cinfo->klass, iface_cinfo->klass); + } + g_free(interfaces); + } + + if (!rbgobj_convert_type_init_hook(gtype, cinfo->klass)) { + switch (fundamental_type) { + case G_TYPE_OBJECT: + rbgobj_init_object_class(cinfo->klass); + break; + case G_TYPE_ENUM: + rbgobj_init_enum_class(cinfo->klass); + break; + case G_TYPE_FLAGS: + rbgobj_init_flags_class(cinfo->klass); + break; + case G_TYPE_INTERFACE: + rbgobj_init_interface(cinfo->klass); + break; + default: + rbgobj_convert_type_init_hook(fundamental_type, cinfo->klass); + break; + } + } + + if (gclass) + g_type_class_unref(gclass); + + return cinfo; +} + +static VALUE +rbgobj_lookup_class_by_gtype_body(VALUE data) +{ + RGObjClassByGtypeData *cdata = (RGObjClassByGtypeData *)data; + const RGObjClassInfo *cinfo; + + cinfo = rbgobj_lookup_class_by_gtype_without_lock(cdata->gtype, + cdata->parent, + cdata->create_class); + return (VALUE)cinfo; +} + +static VALUE +rbgobj_lookup_class_by_gtype_ensure(G_GNUC_UNUSED VALUE data) +{ + rb_funcall(lookup_class_mutex, id_unlock, 0); + return Qundef; +} + +const RGObjClassInfo * +rbgobj_lookup_class_by_gtype(GType gtype, VALUE parent) +{ + return rbgobj_lookup_class_by_gtype_full(gtype, parent, TRUE); +} + +const RGObjClassInfo * +rbgobj_lookup_class_by_gtype_full(GType gtype, VALUE parent, + gboolean create_class) +{ + RGObjClassByGtypeData data; + + data.gtype = gtype; + data.parent = parent; + data.create_class = create_class; + + if (create_class) { + rb_funcall(lookup_class_mutex, id_lock, 0); + return (RGObjClassInfo *)rb_ensure(rbgobj_lookup_class_by_gtype_body, + (VALUE)&data, + rbgobj_lookup_class_by_gtype_ensure, + (VALUE)&data); + } else { + return rbgobj_lookup_class_by_gtype_without_lock(gtype, parent, + create_class); + } +} + +VALUE +rbgobj_gtype_to_ruby_class(GType gtype) +{ + const RGObjClassInfo *cinfo; + + cinfo = GTYPE2CINFO(gtype); + return cinfo ? cinfo->klass : Qnil; +} + +VALUE +rbgobj_define_class(GType gtype, const gchar *name, VALUE module, + RGMarkFunc mark, RGFreeFunc free, VALUE parent) +{ + RGObjClassInfo* cinfo; + if (gtype == 0) + rb_bug("rbgobj_define_class: Invalid gtype [%s]\n", name); + + cinfo = (RGObjClassInfo*)rbgobj_lookup_class_by_gtype(gtype, parent); + cinfo->mark = mark; + cinfo->free = free; + rb_define_const(module, name, cinfo->klass); + return cinfo->klass; +} + +void +rbgobj_register_mark_func(GType gtype, RGMarkFunc mark) +{ + RGObjClassInfo *cinfo; + + cinfo = + (RGObjClassInfo *)rbgobj_lookup_class_by_gtype_full(gtype, Qnil, FALSE); + if (!cinfo) { + rb_raise(rb_eArgError, + "rbgobj_register_free_func(): no class is defined: <%s>", + g_type_name(gtype)); + } + cinfo->mark = mark; +} + +void +rbgobj_register_free_func(GType gtype, RGFreeFunc free) +{ + RGObjClassInfo *cinfo; + + cinfo = + (RGObjClassInfo *)rbgobj_lookup_class_by_gtype_full(gtype, Qnil, FALSE); + if (!cinfo) { + rb_raise(rb_eArgError, + "rbgobj_register_free_func(): no class is defined: <%s>", + g_type_name(gtype)); + } + cinfo->free = free; +} + +VALUE +rbgobj_define_class_dynamic(const gchar *gtype_name, const gchar *name, + VALUE module, RGMarkFunc mark, RGFreeFunc free) +{ + RGObjClassInfoDynamic* cinfo; + cinfo = (RGObjClassInfoDynamic*)g_new(RGObjClassInfoDynamic, 1); + cinfo->name = name; + cinfo->module = module; + cinfo->mark = mark; + cinfo->free = free; + g_hash_table_insert(dynamic_gtype_list, (void*)gtype_name, (void*)cinfo); + return Qnil; +} + +void +rbgobj_register_class(VALUE klass, + GType gtype, + gboolean klass2gtype, + gboolean gtype2klass) +{ + RGObjClassInfo* cinfo = NULL; + VALUE c = Qnil; + + if (klass2gtype) + c = Data_Make_Struct(rb_cData, RGObjClassInfo, cinfo_mark, NULL, cinfo); + if (gtype2klass && !cinfo) + cinfo = g_new(RGObjClassInfo, 1); + + if (cinfo) { + cinfo->klass = klass; + cinfo->gtype = gtype; + cinfo->mark = NULL; + cinfo->free = NULL; + cinfo->flags = 0; + } + + if (klass2gtype) + rb_hash_aset(klass_to_cinfo, cinfo->klass, c); + + if (gtype2klass) + g_hash_table_insert(gtype_to_cinfo, GUINT_TO_POINTER(gtype), cinfo); +} + +#define _register_fundamental_klass_to_gtype(klass, gtype) \ + rbgobj_register_class(klass, gtype, TRUE, FALSE) + +#define _register_fundamental_gtype_to_klass(gtype,klass) \ + rbgobj_register_class(klass, gtype, FALSE, TRUE) + +static void +init_typemap(void) +{ + id_new = rb_intern("new"); + id_superclass = rb_intern("superclass"); + + gtype_to_cinfo = g_hash_table_new(g_direct_hash, g_direct_equal); + rb_global_variable(&klass_to_cinfo); + klass_to_cinfo = rb_hash_new(); + + _register_fundamental_klass_to_gtype(rb_cFixnum, G_TYPE_LONG); + _register_fundamental_klass_to_gtype(rb_cFloat, G_TYPE_DOUBLE); + _register_fundamental_klass_to_gtype(rb_cInteger, G_TYPE_LONG); + _register_fundamental_klass_to_gtype(rb_cString, G_TYPE_STRING); + _register_fundamental_klass_to_gtype(rb_cSymbol, G_TYPE_STRING); + _register_fundamental_klass_to_gtype(Qnil, G_TYPE_NONE); + _register_fundamental_klass_to_gtype(rb_cNilClass, G_TYPE_NONE); + _register_fundamental_klass_to_gtype(rb_cTrueClass, G_TYPE_BOOLEAN); + _register_fundamental_klass_to_gtype(rb_cFalseClass, G_TYPE_BOOLEAN); + _register_fundamental_klass_to_gtype(Qtrue, G_TYPE_BOOLEAN); + _register_fundamental_klass_to_gtype(Qfalse, G_TYPE_BOOLEAN); + _register_fundamental_klass_to_gtype(rb_cObject, RBGOBJ_TYPE_RUBY_VALUE); + + _register_fundamental_gtype_to_klass(G_TYPE_UINT, rb_cInteger); + _register_fundamental_gtype_to_klass(G_TYPE_FLOAT, rb_cFloat); + _register_fundamental_gtype_to_klass(G_TYPE_DOUBLE, rb_cFloat); + _register_fundamental_gtype_to_klass(G_TYPE_INT64, rb_cInteger); + _register_fundamental_gtype_to_klass(G_TYPE_UINT64, rb_cInteger); + _register_fundamental_gtype_to_klass(G_TYPE_INT, rb_cInteger); + _register_fundamental_gtype_to_klass(G_TYPE_LONG, rb_cInteger); + _register_fundamental_gtype_to_klass(G_TYPE_CHAR, rb_cFixnum); + _register_fundamental_gtype_to_klass(G_TYPE_UCHAR, rb_cFixnum); + _register_fundamental_gtype_to_klass(G_TYPE_STRING, rb_cString); + _register_fundamental_gtype_to_klass(G_TYPE_ULONG, rb_cInteger); + _register_fundamental_gtype_to_klass(G_TYPE_NONE, rb_cNilClass); + _register_fundamental_gtype_to_klass(G_TYPE_BOOLEAN, rb_cTrueClass); +} + +/**********************************************************************/ +/* GLib::Type */ + +VALUE RG_TARGET_NAMESPACE; +static ID id_gtype; + +VALUE +rbgobj_gtype_new(GType gtype) +{ + VALUE result = rb_obj_alloc(RG_TARGET_NAMESPACE); + VALUE arg = ULONG2NUM(gtype); + rb_obj_call_init(result, 1, &arg); + return result; +} + +GType +rbgobj_gtype_get(VALUE self) +{ + if (RVAL2CBOOL(rb_obj_is_kind_of(self, RG_TARGET_NAMESPACE))) { + return NUM2ULONG(rb_ivar_get(self, id_gtype)); + } else { + return CLASS2GTYPE(self); + } + rb_raise(rb_eTypeError, "Not a GLib::Type"); +} + +static VALUE +rg_initialize(VALUE self, VALUE type) +{ + GType gtype; + + if (RVAL2CBOOL(rb_obj_is_kind_of(type, rb_cInteger))) { + gtype = NUM2ULONG(type); + if (!g_type_name(gtype)) + gtype = G_TYPE_INVALID; + } else { + gtype = g_type_from_name(StringValuePtr(type)); + } + + if (G_TYPE_INVALID == gtype) + rb_raise(rb_eArgError, "invalid type"); + + rb_ivar_set(self, id_gtype, ULONG2NUM(gtype)); + + return Qnil; +} + +static VALUE +rg_inspect(VALUE self) +{ + GType gtype = rbgobj_gtype_get(self); + gchar* str; + VALUE result; + + str = g_strdup_printf("GLib::Type[\"%s\"]", g_type_name(gtype)); + result = rb_str_new2(str); + g_free(str); + + return result; +} + +static VALUE +rg_operator_type_compare(VALUE self, VALUE other) +{ + if (!RVAL2CBOOL(rb_obj_is_kind_of(other, RG_TARGET_NAMESPACE))) + return Qnil; + else { + GType a = rbgobj_gtype_get(self); + GType b = rbgobj_gtype_get(other); + + if (a==b) + return INT2FIX(0); + else if (g_type_is_a(a,b)) + return INT2FIX(-1); + else if (g_type_is_a(b,a)) + return INT2FIX(1); + else + return Qnil; + } +} + +static VALUE +rg_operator_type_eq(VALUE self, VALUE other) +{ + if (!RVAL2CBOOL(rb_obj_is_kind_of(other, RG_TARGET_NAMESPACE))) + return Qnil; + else { + GType a = rbgobj_gtype_get(self); + GType b = rbgobj_gtype_get(other); + return CBOOL2RVAL(a == b); + } +} + +static VALUE +rg_operator_type_lt_eq(VALUE self, VALUE other) +{ + if (!RVAL2CBOOL(rb_obj_is_kind_of(other, RG_TARGET_NAMESPACE))) + return Qnil; + else { + GType a = rbgobj_gtype_get(self); + GType b = rbgobj_gtype_get(other); + return CBOOL2RVAL(g_type_is_a(a, b)); + } +} + +static VALUE +rg_operator_type_gt_eq(VALUE self, VALUE other) +{ + if (!RVAL2CBOOL(rb_obj_is_kind_of(other, RG_TARGET_NAMESPACE))) + return Qnil; + else { + GType a = rbgobj_gtype_get(self); + GType b = rbgobj_gtype_get(other); + return CBOOL2RVAL(g_type_is_a(b, a)); + } +} + +static VALUE +rg_operator_type_lt(VALUE self, VALUE other) +{ + if (!RVAL2CBOOL(rb_obj_is_kind_of(other, RG_TARGET_NAMESPACE))) + return Qnil; + else { + GType a = rbgobj_gtype_get(self); + GType b = rbgobj_gtype_get(other); + return CBOOL2RVAL(g_type_is_a(a, b) && a != b); + } +} + +static VALUE +rg_operator_type_gt(VALUE self, VALUE other) +{ + if (!RVAL2CBOOL(rb_obj_is_kind_of(other, RG_TARGET_NAMESPACE))) + return Qnil; + else { + GType a = rbgobj_gtype_get(self); + GType b = rbgobj_gtype_get(other); + return CBOOL2RVAL(g_type_is_a(b, a) && a != b); + } +} + +static VALUE +rg_hash(VALUE self) +{ + return rb_ivar_get(self, id_gtype); +} + +static VALUE +rg_to_class(VALUE self) +{ + return GTYPE2CLASS(rbgobj_gtype_get(self)); +} + +static VALUE +rg_fundamental(VALUE self) +{ + return rbgobj_gtype_new(G_TYPE_FUNDAMENTAL(rbgobj_gtype_get(self))); +} + +static VALUE +rg_fundamental_p(VALUE self) +{ + return CBOOL2RVAL(G_TYPE_IS_FUNDAMENTAL(rbgobj_gtype_get(self))); +} + +static VALUE +rg_derived_p(VALUE self) +{ + return CBOOL2RVAL(G_TYPE_IS_DERIVED(rbgobj_gtype_get(self))); +} + +static VALUE +rg_interface_p(VALUE self) +{ + return CBOOL2RVAL(G_TYPE_IS_INTERFACE(rbgobj_gtype_get(self))); +} + +static VALUE +rg_classed_p(VALUE self) +{ + return CBOOL2RVAL(G_TYPE_IS_CLASSED(rbgobj_gtype_get(self))); +} + +static VALUE +rg_instantiatable_p(VALUE self) +{ + return CBOOL2RVAL(G_TYPE_IS_INSTANTIATABLE(rbgobj_gtype_get(self))); +} + +static VALUE +rg_derivable_p(VALUE self) +{ + return CBOOL2RVAL(G_TYPE_IS_DERIVABLE(rbgobj_gtype_get(self))); +} + +static VALUE +rg_deep_derivable_p(VALUE self) +{ + return CBOOL2RVAL(G_TYPE_IS_DEEP_DERIVABLE(rbgobj_gtype_get(self))); +} + +static VALUE +rg_abstract_p(VALUE self) +{ + return CBOOL2RVAL(G_TYPE_IS_ABSTRACT(rbgobj_gtype_get(self))); +} + +static VALUE +rg_value_abstract_p(VALUE self) +{ + return CBOOL2RVAL(G_TYPE_IS_VALUE_ABSTRACT(rbgobj_gtype_get(self))); +} + +static VALUE +rg_value_type_p(VALUE self) +{ + return CBOOL2RVAL(G_TYPE_IS_VALUE_TYPE(rbgobj_gtype_get(self))); +} + +static VALUE +rg_has_value_table(VALUE self) +{ + return CBOOL2RVAL(G_TYPE_HAS_VALUE_TABLE(rbgobj_gtype_get(self))); +} + +static VALUE +rg_name(VALUE self) +{ + return rb_str_new2(g_type_name(rbgobj_gtype_get(self))); +} + +static VALUE +rg_parent(VALUE self) +{ + GType parent = g_type_parent(rbgobj_gtype_get(self)); + return parent ? rbgobj_gtype_new(parent) : Qnil; +} + +static VALUE +rg_depth(VALUE self) +{ + return UINT2NUM(g_type_depth(rbgobj_gtype_get(self))); +} + +static VALUE +rg_next_base(VALUE leaf_type, VALUE root_type) +{ + GType ret = g_type_next_base(rbgobj_gtype_get(leaf_type), + rbgobj_gtype_get(root_type)); + return ret ? rbgobj_gtype_new(ret) : Qnil; +} + +static VALUE +rg_type_is_a_p(VALUE self, VALUE is_a_type) +{ + return CBOOL2RVAL(g_type_is_a(rbgobj_gtype_get(self), rbgobj_gtype_get(is_a_type))); +} + +#if 0 +gpointer g_type_class_ref (GType type); +gpointer g_type_class_peek (GType type); +void g_type_class_unref (gpointer g_class); +gpointer g_type_class_peek_parent (gpointer g_class); +gpointer g_type_interface_peek (gpointer instance_class, + GType iface_type); +gpointer g_type_interface_peek_parent (gpointer g_iface); +#endif + +static VALUE +rg_children(VALUE self) +{ + guint n_children; + GType* types; + VALUE result; + guint i; + + types = g_type_children(rbgobj_gtype_get(self), &n_children); + result = rb_ary_new2(n_children); + for (i = 0; i < n_children; i++) + rb_ary_store(result, i, rbgobj_gtype_new(types[i])); + g_free(types); + + return result; +} + +static VALUE +rg_interfaces(VALUE self) +{ + guint n_interfaces; + GType* types; + VALUE result; + guint i; + + types = g_type_interfaces(rbgobj_gtype_get(self), &n_interfaces); + result = rb_ary_new2(n_interfaces); + for (i = 0; i < n_interfaces; i++) + rb_ary_store(result, i, rbgobj_gtype_new(types[i])); + g_free(types); + + return result; +} + +static VALUE +rg_class_size(VALUE self) +{ + GTypeQuery query; + g_type_query(rbgobj_gtype_get(self), &query); + return UINT2NUM(query.class_size); +} + +static VALUE +rg_instance_size(VALUE self) +{ + GTypeQuery query; + g_type_query(rbgobj_gtype_get(self), &query); + return UINT2NUM(query.instance_size); +} + +static inline void +_def_fundamental_type(VALUE ary, GType gtype, const char* name) +{ + VALUE c = rbgobj_gtype_new(gtype); + rb_define_const(RG_TARGET_NAMESPACE, name, c); + rb_ary_push(ary, c); +} + +/**********************************************************************/ + +void +Init_gobject_gtype(void) +{ +#if !GLIB_CHECK_VERSION(2, 35, 1) + g_type_init(); +#endif + + init_typemap(); + + /* type */ + rb_cMutex = rb_const_get(rb_cObject, rb_intern("Mutex")); + id_lock = rb_intern("lock"); + id_unlock = rb_intern("unlock"); + lookup_class_mutex = rb_funcall(rb_cMutex, id_new, 0); + rb_iv_set(mGLib, "lookup_class_mutex", lookup_class_mutex); + + dynamic_gtype_list = g_hash_table_new(g_str_hash, g_str_equal); + id_gtype = rb_intern("__gobject_gtype__"); + + RG_TARGET_NAMESPACE = rb_define_class_under(mGLib, "Type", rb_cObject); + + rb_define_alias(CLASS_OF(RG_TARGET_NAMESPACE), "[]", "new"); + RG_DEF_METHOD(initialize, 1); + RG_DEF_METHOD(inspect, 0); + RG_DEF_METHOD_OPERATOR("<=>", type_compare, 1); + RG_DEF_METHOD_OPERATOR("==", type_eq, 1); + RG_DEF_METHOD_OPERATOR("<=", type_lt_eq, 1); + RG_DEF_METHOD_OPERATOR(">=", type_gt_eq, 1); + RG_DEF_METHOD_OPERATOR("<", type_lt, 1); + RG_DEF_METHOD_OPERATOR(">", type_gt, 1); + RG_DEF_ALIAS("eql?", "=="); + RG_DEF_METHOD(hash, 0); + RG_DEF_ALIAS("to_i", "hash"); + RG_DEF_ALIAS("to_int", "hash"); + RG_DEF_METHOD(to_class, 0); + + RG_DEF_METHOD(fundamental, 0); + RG_DEF_METHOD_P(fundamental, 0); + RG_DEF_METHOD_P(derived, 0); + RG_DEF_METHOD_P(interface, 0); + RG_DEF_METHOD_P(classed, 0); + RG_DEF_METHOD_P(instantiatable, 0); + RG_DEF_METHOD_P(derivable, 0); + RG_DEF_METHOD_P(deep_derivable, 0); + RG_DEF_METHOD_P(abstract, 0); + RG_DEF_METHOD_P(value_abstract, 0); + RG_DEF_METHOD_P(value_type, 0); + RG_DEF_METHOD(has_value_table, 0); + + RG_DEF_METHOD(name, 0); + RG_DEF_ALIAS("to_s", "name"); + RG_DEF_METHOD(parent, 0); + RG_DEF_METHOD(depth, 0); + RG_DEF_METHOD(next_base, 1); + RG_DEF_METHOD_P(type_is_a, 1); + RG_DEF_METHOD(children, 0); + RG_DEF_METHOD(interfaces, 0); + RG_DEF_METHOD(class_size, 0); + RG_DEF_METHOD(instance_size, 0); + + { + VALUE ary = rb_ary_new(); + rb_define_const(RG_TARGET_NAMESPACE, "FUNDAMENTAL_MAX", INT2FIX(G_TYPE_FUNDAMENTAL_MAX)); + _def_fundamental_type(ary, G_TYPE_NONE, "NONE"); + _def_fundamental_type(ary, G_TYPE_INTERFACE, "INTERFACE"); + _def_fundamental_type(ary, G_TYPE_CHAR, "CHAR"); + _def_fundamental_type(ary, G_TYPE_UCHAR, "UCHAR"); + _def_fundamental_type(ary, G_TYPE_BOOLEAN, "BOOLEAN"); + _def_fundamental_type(ary, G_TYPE_INT, "INT"); + _def_fundamental_type(ary, G_TYPE_UINT, "UINT"); + _def_fundamental_type(ary, G_TYPE_LONG, "LONG"); + _def_fundamental_type(ary, G_TYPE_ULONG, "ULONG"); + _def_fundamental_type(ary, G_TYPE_INT64, "INT64"); + _def_fundamental_type(ary, G_TYPE_UINT64, "UINT64"); + _def_fundamental_type(ary, G_TYPE_ENUM, "ENUM"); + _def_fundamental_type(ary, G_TYPE_FLAGS, "FLAGS"); + _def_fundamental_type(ary, G_TYPE_FLOAT, "FLOAT"); + _def_fundamental_type(ary, G_TYPE_DOUBLE, "DOUBLE"); + _def_fundamental_type(ary, G_TYPE_STRING, "STRING"); + _def_fundamental_type(ary, G_TYPE_POINTER, "POINTER"); + _def_fundamental_type(ary, G_TYPE_BOXED, "BOXED"); + _def_fundamental_type(ary, G_TYPE_PARAM, "PARAM"); + _def_fundamental_type(ary, G_TYPE_OBJECT, "OBJECT"); + rb_define_const(RG_TARGET_NAMESPACE, "FUNDAMENTAL_TYPES", ary); /* FIXME: better name */ + } +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_typeinstance.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_typeinstance.c new file mode 100644 index 0000000..794f8bd --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_typeinstance.c @@ -0,0 +1,128 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#define RG_TARGET_NAMESPACE cInstantiatable + +VALUE RG_TARGET_NAMESPACE; + +typedef void (*ClassInfoCallbackFunc) (gpointer instance, + const RGObjClassInfo *class_info, + gpointer user_data); + +static G_GNUC_NORETURN VALUE +instantiatable_s_allocate(G_GNUC_UNUSED VALUE klass) +{ + rb_raise(rb_eTypeError, "abstract class"); +} + +static VALUE +rg_gtype(VALUE self) +{ + return rbgobj_gtype_new(G_TYPE_FROM_INSTANCE(rbgobj_instance_from_ruby_object(self))); +} + +static G_GNUC_NORETURN VALUE +rg_clone(VALUE self) +{ + rb_raise(rb_eTypeError, "can't clone %s", rb_class2name(CLASS_OF(self))); +} + +/**********************************************************************/ + +static void +each_cinfo(gpointer instance, ClassInfoCallbackFunc func, gpointer user_data) +{ + const GType gtype = G_TYPE_FROM_INSTANCE(instance); + GType* interfaces; + guint n_interfaces = 0; + + interfaces = g_type_interfaces(gtype, &n_interfaces); + { + guint i; + for (i = 0; i < n_interfaces; i++) { + const RGObjClassInfo *info; + + info = GTYPE2CINFO_NO_CREATE(interfaces[i]); + if (info) + func(instance, info, user_data); + } + } + g_free(interfaces); + + { + GType type; + for (type = gtype; type != G_TYPE_INVALID; type = g_type_parent(type)) { + const RGObjClassInfo *info; + + info = GTYPE2CINFO_NO_CREATE(type); + if (info) + func(instance, info, user_data); + } + } +} + +static void +call_cinfo_free(gpointer instance, const RGObjClassInfo *cinfo, G_GNUC_UNUSED gpointer user_data) +{ + if (cinfo->free) cinfo->free(instance); +} + +static void +call_cinfo_mark(gpointer instance, const RGObjClassInfo *cinfo, G_GNUC_UNUSED gpointer user_data) +{ + if (cinfo->mark) cinfo->mark(instance); +} + +void +rbgobj_instance_call_cinfo_mark(gpointer instance) +{ + each_cinfo(instance, call_cinfo_mark, NULL); +} + +void +rbgobj_instance_call_cinfo_free(gpointer instance) +{ + each_cinfo(instance, call_cinfo_free, NULL); +} + +void +rbgobj_gc_mark_instance(gpointer instance) +{ + VALUE obj = rbgobj_ruby_object_from_instance2(instance, FALSE); + rb_gc_mark(obj); +} + +/**********************************************************************/ + +void +Init_gobject_typeinstance(void) +{ + /* should be renamed to GLib::Instance? */ + RG_TARGET_NAMESPACE = rb_define_class_under(mGLib, "Instantiatable", rb_cObject); + rb_extend_object(RG_TARGET_NAMESPACE, mMetaInterface); + + rb_define_alloc_func(RG_TARGET_NAMESPACE, (VALUE(*)_((VALUE)))instantiatable_s_allocate); + RG_DEF_METHOD(gtype, 0); + RG_DEF_METHOD(clone, 0); +} \ No newline at end of file diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_typeinterface.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_typeinterface.c new file mode 100644 index 0000000..260d983 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_typeinterface.c @@ -0,0 +1,155 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#define RG_TARGET_NAMESPACE mMetaInterface + +VALUE rbgobj_mInterface; +VALUE RG_TARGET_NAMESPACE; + +static VALUE +rg_append_features(G_GNUC_UNUSED VALUE self, VALUE klass) +{ + if (!rb_obj_is_kind_of(klass, cInstantiatable)) + rb_raise(rb_eTypeError, "Not a subclass of GLib::Instantiatable"); + return rb_call_super(1, &klass); +} + +#if GLIB_CHECK_VERSION(2,4,0) + +static VALUE +rg_install_property(VALUE self, VALUE pspec_obj) +{ + const RGObjClassInfo* cinfo = rbgobj_lookup_class(self); + gpointer ginterface; + GParamSpec* pspec; + + if (cinfo->klass != self) + rb_raise(rb_eTypeError, "%s isn't registered class", rb_class2name(self)); + + pspec = G_PARAM_SPEC(RVAL2GOBJ(pspec_obj)); + ginterface = g_type_default_interface_ref(cinfo->gtype); + g_object_interface_install_property(ginterface, pspec); + g_type_default_interface_unref(ginterface); + + /* FIXME: define accessor methods */ + return Qnil; +} + +static VALUE +rg_property(VALUE self, VALUE property_name) +{ + gpointer ginterface; + const char* name; + GParamSpec* prop; + VALUE result; + GType gtype = CLASS2GTYPE(self); + + if (SYMBOL_P(property_name)) + name = rb_id2name(SYM2ID(property_name)); + else + name = StringValuePtr(property_name); + + if (!G_TYPE_IS_INTERFACE(gtype)) + rb_raise(rb_eTypeError, "%s isn't interface module", rb_class2name(self)); + /* XXX: g_type_default_interface_ref(G_TYPE_INTERFACE) causes SEGV. */ + if (gtype == G_TYPE_INTERFACE) { + rb_raise(rb_const_get(mGLib, rb_intern("NoPropertyError")), + "No such property: %s", name); + } + + ginterface = g_type_default_interface_ref(gtype); + prop = g_object_interface_find_property(ginterface, name); + if (!prop){ + g_type_default_interface_unref(ginterface); + rb_raise(rb_const_get(mGLib, rb_intern("NoPropertyError")), + "No such property: %s", name); + } + result = GOBJ2RVAL(prop); + g_type_default_interface_unref(ginterface); + + return result; +} + +static VALUE +rg_properties(int argc, VALUE* argv, VALUE self) +{ + guint n_properties; + GParamSpec** props; + VALUE inherited_too; + VALUE ary = rb_ary_new(); + guint i; + gpointer ginterface; + GType gtype = CLASS2GTYPE(self); + + if (rb_scan_args(argc, argv, "01", &inherited_too) == 0) + inherited_too = Qtrue; + + if (!G_TYPE_IS_INTERFACE(gtype)) + rb_raise(rb_eTypeError, "%s isn't interface module", rb_class2name(self)); + /* XXX: g_type_default_interface_ref(G_TYPE_INTERFACE) causes SEGV. */ + if (gtype == G_TYPE_INTERFACE) return ary; + + ginterface = g_type_default_interface_ref(gtype); + props = g_object_interface_list_properties(ginterface, &n_properties); + for (i = 0; i < n_properties; i++){ + if (RVAL2CBOOL(inherited_too) || GTYPE2CLASS(props[i]->owner_type) == self) + rb_ary_push(ary, rb_str_new2(props[i]->name)); + } + g_free(props); + g_type_default_interface_unref(ginterface); + + return ary; +} + +#endif + +void +rbgobj_init_interface(VALUE interf) +{ + static VALUE rb_mGLibInterface = Qnil; + + rb_extend_object(interf, RG_TARGET_NAMESPACE); + if (CLASS2GTYPE(interf) == G_TYPE_INTERFACE) { + rb_mGLibInterface = interf; + } else { + rb_extend_object(interf, rb_mGLibInterface); + rb_include_module(interf, rb_mGLibInterface); + rbgobj_define_property_accessors(interf); + } +} + +void +Init_gobject_typeinterface(void) +{ + RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "MetaInterface"); + rbg_define_method(RG_TARGET_NAMESPACE, "gtype", generic_s_gtype, 0); + RG_DEF_METHOD(append_features, 1); +#if GLIB_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(install_property, 1); + RG_DEF_METHOD(property, 1); + RG_DEF_METHOD(properties, -1); +#endif + + rbgobj_mInterface = G_DEF_INTERFACE(G_TYPE_INTERFACE, "Interface", mGLib); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_typemodule.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_typemodule.c new file mode 100644 index 0000000..b7a2be9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_typemodule.c @@ -0,0 +1,72 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#define RG_TARGET_NAMESPACE cTypeModule + +static VALUE +rg_use(VALUE self) +{ + return CBOOL2RVAL(g_type_module_use(G_TYPE_MODULE(RVAL2GOBJ(self)))); +} + +static VALUE +rg_unuse(VALUE self) +{ + g_type_module_unuse(G_TYPE_MODULE(RVAL2GOBJ(self))); + return self; +} + +static VALUE +rg_name(VALUE self) +{ + return rb_str_new2(G_TYPE_MODULE(RVAL2GOBJ(self))->name); +} + +static VALUE +rg_operator_set_name(VALUE self, VALUE name) +{ + g_type_module_set_name(G_TYPE_MODULE(RVAL2GOBJ(self)), StringValuePtr(name)); + return name; +} + +#if 0 +GType g_type_module_register_type (GTypeModule *module, + GType parent_type, + const gchar *type_name, + const GTypeInfo *type_info, + GTypeFlags flags); +void g_type_module_add_interface (GTypeModule *module, + GType instance_type, + GType interface_type, + const GInterfaceInfo *interface_info); +#endif + +void +Init_gobject_gtypemodule(void) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_TYPE_MODULE, "TypeModule", mGLib); + RG_DEF_METHOD(use, 0); + RG_DEF_METHOD(unuse, 0); + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD_OPERATOR("name=", set_name, 1); +} \ No newline at end of file diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_typeplugin.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_typeplugin.c new file mode 100644 index 0000000..6291bc1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_typeplugin.c @@ -0,0 +1,57 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#define RG_TARGET_NAMESPACE mTypePlugin + +static VALUE +rg_use(VALUE self) +{ + g_type_plugin_use(G_TYPE_PLUGIN(RVAL2GOBJ(self))); + return self; +} + +static VALUE +rg_unuse(VALUE self) +{ + g_type_plugin_unuse(G_TYPE_PLUGIN(RVAL2GOBJ(self))); + return self; +} + +#if 0 +void g_type_plugin_complete_type_info (GTypePlugin *plugin, + GType g_type, + GTypeInfo *info, + GTypeValueTable *value_table); +void g_type_plugin_complete_interface_info (GTypePlugin *plugin, + GType interface_type, + GType instance_type, + GInterfaceInfo *info); +#endif + +void +Init_gobject_gtypeplugin(void) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_TYPE_PLUGIN, "TypePlugin", mGLib); + RG_DEF_METHOD(use, 0); + RG_DEF_METHOD(unuse, 0); +} \ No newline at end of file diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_value.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_value.c new file mode 100644 index 0000000..af0a069 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_value.c @@ -0,0 +1,383 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +/**********************************************************************/ +#define RG_TARGET_NAMESPACE rbgobj_cValue +#define _SELF(self) RVAL2GVALUE(self) + +static ID id_to_s; +static GQuark qRValueToGValueFunc; +static GQuark qGValueToRValueFunc; + +void +rbgobj_register_r2g_func(GType gtype, RValueToGValueFunc func) +{ + g_type_set_qdata(gtype, qRValueToGValueFunc, func); +} + +void +rbgobj_register_g2r_func(GType gtype, GValueToRValueFunc func) +{ + g_type_set_qdata(gtype, qGValueToRValueFunc, func); +} + +/**********************************************************************/ + +VALUE +rbgobj_gvalue_to_rvalue(const GValue* value) +{ + GType type, fundamental_type; + VALUE rvalue; + + if (!value) + return Qnil; + + type = G_VALUE_TYPE(value); + if (rbgobj_convert_gvalue2rvalue(type, value, &rvalue)) + return rvalue; + + fundamental_type = G_TYPE_FUNDAMENTAL(type); + switch (fundamental_type) { + case G_TYPE_NONE: + return Qnil; + case G_TYPE_CHAR: + return CHR2FIX(g_value_get_char(value)); + case G_TYPE_UCHAR: + return INT2FIX(g_value_get_uchar(value)); + case G_TYPE_BOOLEAN: + return CBOOL2RVAL(g_value_get_boolean(value)); + case G_TYPE_INT: + return INT2NUM(g_value_get_int(value)); + case G_TYPE_UINT: + return UINT2NUM(g_value_get_uint(value)); + case G_TYPE_LONG: + return LONG2NUM(g_value_get_long(value)); + case G_TYPE_ULONG: + return ULONG2NUM(g_value_get_ulong(value)); + case G_TYPE_INT64: + return rbglib_int64_to_num(g_value_get_int64(value)); + case G_TYPE_UINT64: + return rbglib_uint64_to_num(g_value_get_uint64(value)); + case G_TYPE_FLOAT: + return rb_float_new(g_value_get_float(value)); + case G_TYPE_DOUBLE: + return rb_float_new(g_value_get_double(value)); + case G_TYPE_STRING: + return CSTR2RVAL(g_value_get_string(value)); + case G_TYPE_ENUM: + return rbgobj_make_enum(g_value_get_enum(value), type); + case G_TYPE_FLAGS: + return rbgobj_make_flags(g_value_get_flags(value), type); + case G_TYPE_OBJECT: + case G_TYPE_INTERFACE: + { + GObject* gobj = g_value_get_object(value); + return gobj ? GOBJ2RVAL(gobj) : Qnil; + } + case G_TYPE_PARAM: + { + GParamSpec* pspec = g_value_get_param(value); + return pspec ? rbgobj_ruby_object_from_instance(pspec) : Qnil; + } + case G_TYPE_POINTER: + { + gpointer ptr = g_value_get_pointer(value); + if (!ptr) + return Qnil; + else + return rbgobj_ptr_new(type, ptr); + } + + case G_TYPE_BOXED: + { + GType gtype; + for (gtype = type; + gtype != G_TYPE_INVALID; + gtype = g_type_parent(gtype)) + { + GValueToRValueFunc func = + g_type_get_qdata(gtype, qGValueToRValueFunc); + if (!func) + continue; + return func(value); + } + } + default: + if (!rbgobj_convert_gvalue2rvalue(fundamental_type, value, &rvalue)) { + GValueToRValueFunc func; + func = g_type_get_qdata(type, qGValueToRValueFunc); + if (!func) { + g_warning("rbgobj_gvalue_to_rvalue: unsupported type: %s\n", + g_type_name(type)); + } else { + rvalue = func(value); + } + } + return rvalue; + } +} + +static VALUE +rbgobj_gvalue_to_rvalue_unset_body(VALUE value) +{ + return GVAL2RVAL((GValue *)value); +} + +static VALUE +rbgobj_gvalue_to_rvalue_unset_ensure(VALUE value) +{ + g_value_unset((GValue *)value); + + return Qnil; +} + +VALUE +rbgobj_gvalue_to_rvalue_unset(GValue *value) +{ + return rb_ensure(rbgobj_gvalue_to_rvalue_unset_body, (VALUE)value, + rbgobj_gvalue_to_rvalue_unset_ensure, (VALUE)value); +} + +void +rbgobj_initialize_gvalue(GValue *result, VALUE value) +{ + GType type; + + type = rbgobj_convert_rvalue2gtype(value); + if (type == 0) { + switch (TYPE(value)) { + case T_NONE: + case T_NIL: + type = G_TYPE_NONE; + break; + case T_FLOAT: + type = G_TYPE_DOUBLE; + break; + case T_STRING: + case T_SYMBOL: + type = G_TYPE_STRING; + break; + case T_FIXNUM: + type = G_TYPE_INT; + break; + case T_BIGNUM: + type = G_TYPE_INT64; + break; + case T_TRUE: + case T_FALSE: + type = G_TYPE_BOOLEAN; + break; + default: + if (RVAL2CBOOL(rb_obj_is_kind_of(value, rbgobj_cEnum))) { + type = G_TYPE_ENUM; + } + else if (RVAL2CBOOL(rb_obj_is_kind_of(value, rbgobj_cFlags))) { + type = G_TYPE_FLAGS; + } + else if (RVAL2CBOOL(rb_obj_is_kind_of(value, rbgobj_cBoxed))) { + type = G_TYPE_BOXED; + } + else if (RVAL2CBOOL(rb_obj_is_kind_of(value, rbgobj_cParam))) { + type = G_TYPE_PARAM; + } + else if (RVAL2CBOOL(rb_obj_is_kind_of(value, rbgobj_cObject))) { + type = G_TYPE_OBJECT; + } + else if (RVAL2CBOOL(rb_obj_is_kind_of(value, rbgobj_mInterface))) { + /* should use rbgobj_mMetaInterface? */ + type = G_TYPE_INTERFACE; + } + else { + VALUE inspected_value; + inspected_value = rb_funcall(value, rb_intern("inspect"), 0); + rb_raise(rb_eArgError, + "unsupported value type: %s", + RSTRING_PTR(inspected_value)); + } + break; + } + } + + g_value_init(result, type); + rbgobj_rvalue_to_gvalue(value, result); +} + +void +rbgobj_rvalue_to_gvalue(VALUE val, GValue* result) +{ + GType type, fundamental_type; + + type = G_VALUE_TYPE(result); + if (rbgobj_convert_rvalue2gvalue(type, val, result)) + return; + + fundamental_type = G_TYPE_FUNDAMENTAL(type); + switch (fundamental_type) { + case G_TYPE_NONE: + return; + case G_TYPE_CHAR: + g_value_set_char(result, NUM2INT(val)); + return; + case G_TYPE_UCHAR: + g_value_set_uchar(result, NUM2UINT(val)); + return; + case G_TYPE_BOOLEAN: + g_value_set_boolean(result, RVAL2CBOOL(val)); + return; + case G_TYPE_INT: + g_value_set_int(result, NUM2INT(val)); + return; + case G_TYPE_UINT: + g_value_set_uint(result, NUM2UINT(val)); + return; + case G_TYPE_LONG: + g_value_set_long(result, NUM2LONG(val)); + return; + case G_TYPE_ULONG: + g_value_set_ulong(result, NUM2ULONG(val)); + return; + case G_TYPE_INT64: + g_value_set_int64(result, rbglib_num_to_int64(val)); + return; + case G_TYPE_UINT64: + g_value_set_uint64(result, rbglib_num_to_uint64(val)); + return; + case G_TYPE_ENUM: + g_value_set_enum(result, rbgobj_get_enum(val, G_VALUE_TYPE(result))); + return; + case G_TYPE_FLAGS: + g_value_set_flags(result, rbgobj_get_flags(val, G_VALUE_TYPE(result))); + return; + case G_TYPE_FLOAT: + g_value_set_float(result, NUM2DBL(val)); + return; + case G_TYPE_DOUBLE: + g_value_set_double(result, NUM2DBL(val)); + return; + case G_TYPE_STRING: + { + if (SYMBOL_P(val)) + val = rb_funcall(val, id_to_s, 0); + g_value_set_string(result, RVAL2CSTR_ACCEPT_NIL(val)); + return; + } + case G_TYPE_OBJECT: + case G_TYPE_INTERFACE: + g_value_set_object(result, NIL_P(val) ? NULL : RVAL2GOBJ(val)); + return; + case G_TYPE_PARAM: + g_value_set_param(result, NIL_P(val) ? NULL : RVAL2GOBJ(val)); + return; + case G_TYPE_POINTER: + g_value_set_pointer(result, NIL_P(val) ? NULL : rbgobj_ptr2cptr(val)); + return; + case G_TYPE_BOXED: + { + GType gtype; + for (gtype = type; + gtype != G_TYPE_INVALID; + gtype = g_type_parent(gtype)) + { + RValueToGValueFunc func = + g_type_get_qdata(gtype, qRValueToGValueFunc); + if (!func) + continue; + func(val, result); + return; + } + } + + default: + if (!rbgobj_convert_rvalue2gvalue(fundamental_type, val, result)) { + RValueToGValueFunc func = + g_type_get_qdata(type, qRValueToGValueFunc); + if (!func){ + g_warning("rbgobj_rvalue_to_gvalue: unsupported type: %s\n", + g_type_name(type)); + } else { + func(val, result); + } + } + } +} + +/**********************************************************************/ + +void +rbgobj_gc_mark_gvalue(GValue* value) +{ + GType gtype = G_VALUE_TYPE(value); + /* FIXME */ + if (G_TYPE_FUNDAMENTAL(gtype) == G_TYPE_OBJECT) + rbgobj_gc_mark_instance(g_value_get_object(value)); +} + +/**********************************************************************/ + +static VALUE +rg_initialize(VALUE self, VALUE rb_gtype, VALUE rb_value) +{ + GValue value = G_VALUE_INIT; + + g_value_init(&value, NUM2INT(rb_to_int(rb_gtype))); + rbgobj_rvalue_to_gvalue(rb_value, &value); + G_INITIALIZE(self, g_boxed_copy(G_TYPE_VALUE, &value)); + g_value_unset(&value); + + return Qnil; +} + +static VALUE +rg_type(VALUE self) +{ + GValue *value; + + value = _SELF(self); + + return rbgobj_gtype_new(value->g_type); +} + +static VALUE +rg_value(VALUE self) +{ + GValue *value; + + value = _SELF(self); + + return GVAL2RVAL(value); +} + +void +Init_gobject_gvalue(void) +{ + VALUE RG_TARGET_NAMESPACE; + + id_to_s = rb_intern("to_s"); + qRValueToGValueFunc = g_quark_from_static_string("__ruby_r2g_func__"); + qGValueToRValueFunc = g_quark_from_static_string("__ruby_g2r_func__"); + + RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_VALUE, "Value", mGLib); + RG_DEF_METHOD(initialize, 2); + RG_DEF_METHOD(type, 0); + RG_DEF_METHOD(value, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_valuearray.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_valuearray.c new file mode 100644 index 0000000..a6cfabc --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_valuearray.c @@ -0,0 +1,100 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Sjoerd Simons + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +static VALUE +value_array_to_ruby(const GValue *from) +{ + VALUE ary; + guint i; + + GValueArray *array = (GValueArray *)g_value_get_boxed(from); + if (array == NULL) + return Qnil; + + ary = rb_ary_new(); + for (i = 0; i < array->n_values; i++) + rb_ary_push(ary, GVAL2RVAL(g_value_array_get_nth(array, i))); + + return ary; +} + +struct value_array_from_ruby_args { + VALUE ary; + long n; + GValueArray *result; +}; + +static VALUE +value_array_from_ruby_body(VALUE value) +{ + long i; + struct value_array_from_ruby_args *args = (struct value_array_from_ruby_args *)value; + + for (i = 0; i < args->n; i++) { + GValue v = G_VALUE_INIT; + + g_value_init(&v, RVAL2GTYPE(RARRAY_PTR(args->ary)[i])); + rbgobj_rvalue_to_gvalue(RARRAY_PTR(args->ary)[i], &v); + + g_value_array_append(args->result, &v); + } + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +value_array_from_ruby_rescue(VALUE value) +{ + g_value_array_free(((struct value_array_from_ruby_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static void +value_array_from_ruby(const VALUE from, GValue *to) +{ + struct value_array_from_ruby_args args; + + if (NIL_P(from)) { + g_value_set_boxed(to, NULL); + + return; + } + + args.ary = rb_ary_to_ary(from); + args.n = RARRAY_LEN(args.ary); + args.result = g_value_array_new(args.n); + + rb_rescue(value_array_from_ruby_body, (VALUE)&args, + value_array_from_ruby_rescue, (VALUE)&args); + + g_value_set_boxed(to, args.result); +} + +void +Init_gobject_value_array(void) +{ + /* ValueArray is treated as Array */ + rbgobj_register_g2r_func(G_TYPE_VALUE_ARRAY, value_array_to_ruby); + rbgobj_register_r2g_func(G_TYPE_VALUE_ARRAY, value_array_from_ruby); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_valuetypes.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_valuetypes.c new file mode 100644 index 0000000..92db741 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobj_valuetypes.c @@ -0,0 +1,243 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" +#include "rbgobject.h" + + +VALUE +rbgobj_ptr_new(GType type, gpointer ptr) +{ + return Data_Wrap_Struct(GTYPE2CLASS(type), NULL, NULL, ptr); +} + +gpointer +rbgobj_ptr2cptr(VALUE ptr) +{ + gpointer dest; + if (rb_obj_is_kind_of(ptr, GTYPE2CLASS(G_TYPE_POINTER))){ + Data_Get_Struct(ptr, void, dest); + } else if (rb_obj_is_kind_of(ptr, rb_cObject)){ + dest = (gpointer)ptr; + } else{ + rb_raise(rb_eTypeError, "not a pointer object"); + } + return dest; +} + +static VALUE +ptr_s_gtype(VALUE klass) +{ + return rbgobj_gtype_new(rbgobj_lookup_class(klass)->gtype); +} + +static VALUE +ptr_gtype(VALUE self) +{ + return ptr_s_gtype(CLASS_OF(self)); +} + +static void +Init_gtype_pointer(void) +{ + VALUE cPtr = G_DEF_CLASS(G_TYPE_POINTER, "Pointer", mGLib); + rbg_define_singleton_method(cPtr, "gtype", ptr_s_gtype, 1); + rbg_define_method(cPtr, "gtype", ptr_gtype, 1); +} + +/**********************************************************************/ + +static GHashTable* boxed_ruby_value_table; +static VALUE boxed_ruby_value_table_wrapper; + +typedef struct { + VALUE obj; + guint ref_count; +} boxed_ruby_value_counter; + +static void +boxed_ruby_value_counter_mark(G_GNUC_UNUSED gpointer key, + gpointer value, + G_GNUC_UNUSED gpointer user_data) +{ + boxed_ruby_value_counter* counter = value; + if (counter->ref_count) + rb_gc_mark(counter->obj); +} + +static void +boxed_ruby_value_table_mark(GHashTable* table) +{ + g_hash_table_foreach(table, boxed_ruby_value_counter_mark, NULL); +} + +static VALUE +boxed_ruby_value_ref(VALUE val) +{ + if (!SPECIAL_CONST_P(val)){ + boxed_ruby_value_counter* counter; + + counter = g_hash_table_lookup(boxed_ruby_value_table, (gpointer)val); + + if (!counter){ + counter = g_new(boxed_ruby_value_counter, 1); + counter->obj = val; + counter->ref_count = 1; + g_hash_table_insert(boxed_ruby_value_table, (gpointer)val, + counter); + } else { + counter->ref_count += 1; + } + } + return val; +} + +static void +boxed_ruby_value_unref(VALUE val) +{ + if (!SPECIAL_CONST_P(val)){ + boxed_ruby_value_counter* counter; + + counter = g_hash_table_lookup(boxed_ruby_value_table, (gpointer)val); + counter->ref_count -= 1; + + if (!counter->ref_count) + g_hash_table_remove(boxed_ruby_value_table, (gpointer)val); + } +} + +struct transform_arg { + const GValue *src_value; + GValue *dest_value; +}; + +static VALUE +value_transform_ruby_any_impl(VALUE arg_) +{ + struct transform_arg* arg = (struct transform_arg*)arg_; + rbgobj_rvalue_to_gvalue(g_value_get_ruby_value(arg->src_value), + arg->dest_value); + return Qnil; +} + +static void +value_transform_ruby_any(const GValue *src_value, + GValue *dest_value) +{ + int state; + struct transform_arg arg; + arg.src_value = src_value; + arg.dest_value = dest_value; + rb_protect(&value_transform_ruby_any_impl, (VALUE)&arg, &state); +} + +static void +value_transform_any_ruby(const GValue *src_value, + GValue *dest_value) +{ + g_value_set_ruby_value(dest_value, GVAL2RVAL(src_value)); +} + +GType +rbgobj_ruby_value_get_type(void) +{ + static GType our_type = 0; + + if (!our_type){ + const GType table[] = { + G_TYPE_CHAR, + G_TYPE_UCHAR, + G_TYPE_BOOLEAN, + G_TYPE_INT, + G_TYPE_UINT, + G_TYPE_LONG, + G_TYPE_ULONG, + G_TYPE_INT64, + G_TYPE_UINT64, + G_TYPE_ENUM, + G_TYPE_FLAGS, + G_TYPE_FLOAT, + G_TYPE_DOUBLE, + G_TYPE_STRING, + G_TYPE_POINTER, + //G_TYPE_BOXED, + G_TYPE_PARAM, + G_TYPE_OBJECT, + }; + size_t i; + + our_type = g_boxed_type_register_static( + "VALUE", + (GBoxedCopyFunc)boxed_ruby_value_ref, + (GBoxedFreeFunc)boxed_ruby_value_unref); + + for (i = 0; i < sizeof(table)/sizeof(table[0]); i++){ + g_value_register_transform_func(table[i], our_type, + value_transform_any_ruby); + } + + g_value_register_transform_func(our_type, G_TYPE_BOOLEAN, + value_transform_ruby_any); + } + return our_type; +} + +VALUE +g_value_get_ruby_value(const GValue* value) +{ + return (VALUE)g_value_get_boxed(value); +} + +void +g_value_set_ruby_value(GValue* value, VALUE ruby) +{ + g_value_set_boxed(value, (gconstpointer)ruby); +} + +static void +ruby_value_r2g(VALUE from, GValue* to) +{ + g_value_set_ruby_value(to, from); +} + +static void +Init_boxed_ruby_value(void) +{ + boxed_ruby_value_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free); + + boxed_ruby_value_table_wrapper = + Data_Wrap_Struct(rb_cData, + boxed_ruby_value_table_mark, NULL, + boxed_ruby_value_table); + rb_global_variable(&boxed_ruby_value_table_wrapper); + + rbgobj_register_g2r_func(RBGOBJ_TYPE_RUBY_VALUE, g_value_get_ruby_value); + rbgobj_register_r2g_func(RBGOBJ_TYPE_RUBY_VALUE, ruby_value_r2g); +} + +/**********************************************************************/ + +void +Init_gobject_gvaluetypes(void) +{ + Init_gtype_pointer(); + Init_boxed_ruby_value(); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobject.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobject.c new file mode 100644 index 0000000..c1198a6 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobject.c @@ -0,0 +1,385 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003-2006 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "ruby.h" +#include "rbgprivate.h" +#include + +#include "rbgprivate.h" + +static ID id_relatives; +static ID id_delete; +static ID id_module_eval; + +ID rbgobj_id_children; + +/**********************************************************************/ + +void +rbgobj_initialize_object(VALUE obj, gpointer cobj) +{ + GType type; + GType parent_type; + + if (!cobj) + rb_raise(rb_eRuntimeError, "failed to initialize"); + + type = RVAL2GTYPE(obj); + + for (parent_type = type; + parent_type != G_TYPE_INVALID; + parent_type = g_type_parent(parent_type)) { + + if (rbgobj_convert_initialize(parent_type, obj, cobj)) + return; + } + + type = G_TYPE_FUNDAMENTAL(type); + switch (type){ + case G_TYPE_OBJECT: + rbgobj_gobject_initialize(obj, cobj); + break; + case G_TYPE_PARAM: + rbgobj_param_spec_initialize(obj, cobj); + break; + case G_TYPE_BOXED: + rbgobj_boxed_initialize(obj, cobj); + break; + default: + rbgobj_convert_initialize(type, obj, cobj); + break; + } +} + +gpointer +rbgobj_instance_from_ruby_object(VALUE obj) +{ + GType type; + GType fundamental_type; + + if (NIL_P(obj)) + return NULL; + + type = RVAL2GTYPE(obj); + if (rbgobj_convert_has_type(type)) { + gpointer instance; + if (rbgobj_convert_robj2instance(type, obj, &instance)) + return instance; + } + + fundamental_type = G_TYPE_FUNDAMENTAL(type); + switch (fundamental_type) { + case G_TYPE_OBJECT: + return rbgobj_get_gobject(obj); + case G_TYPE_BOXED: + return rbgobj_boxed_get(obj, type); + case G_TYPE_PARAM: + return rbgobj_get_param_spec(obj); + default: + { + gpointer instance; + if (!rbgobj_convert_robj2instance(fundamental_type, obj, &instance)) { + rb_raise(rb_eTypeError, "%s isn't supported", + rb_class2name(CLASS_OF(obj))); + } + return instance; + } + } +} + +VALUE +rbgobj_ruby_object_from_instance(gpointer instance) +{ + return rbgobj_ruby_object_from_instance2(instance, TRUE); +} + +VALUE +rbgobj_ruby_object_from_instance2(gpointer instance, gboolean alloc) +{ + VALUE object; + GType type; + + if (!instance) + return Qnil; + + type = G_TYPE_FROM_INSTANCE(instance); + if (alloc) { + GType parent_type; + for (parent_type = type; + parent_type != G_TYPE_INVALID; + parent_type = g_type_parent(parent_type)) { + if (rbgobj_convert_instance2robj(parent_type, instance, &object)) + return object; + } + } + + switch (G_TYPE_FUNDAMENTAL(type)) { + case G_TYPE_OBJECT: + return rbgobj_get_ruby_object_from_gobject(instance, alloc); + case G_TYPE_PARAM: + return rbgobj_get_ruby_object_from_param_spec(instance, alloc); + default: + if (alloc) { + rb_raise(rb_eTypeError, "%s isn't supported", g_type_name(type)); + } else { + return Qnil; + } + } +} + +VALUE +rbgobj_ruby_object_from_instance_with_unref(gpointer instance) +{ + VALUE result = rbgobj_ruby_object_from_instance(instance); + if (!NIL_P(result)) { + GType type; + + type = G_TYPE_FROM_INSTANCE(instance); + if (!rbgobj_convert_unref(type, instance)) { + type = G_TYPE_FUNDAMENTAL(type); + switch (type) { + case G_TYPE_OBJECT: + g_object_unref(instance); + break; + default: + rbgobj_convert_unref(type, instance); + break; + } + } + } + return result; +} + +/**********************************************************************/ + +void +rbgobj_add_relative(VALUE obj, VALUE relative) +{ + VALUE hash = Qnil; + + if (RVAL2CBOOL(rb_ivar_defined(obj, id_relatives))) + hash = rb_ivar_get(obj, id_relatives); + + if (NIL_P(hash) || TYPE(hash) != RUBY_T_HASH) { + hash = rb_hash_new(); + rb_ivar_set(obj, id_relatives, hash); + } + rb_hash_aset(hash, relative, Qnil); +} + +void +rbgobj_invalidate_relatives(VALUE obj) +{ + if (RVAL2CBOOL(rb_ivar_defined(obj, id_relatives))) + rb_ivar_set(obj, id_relatives, Qnil); + if (RVAL2CBOOL(rb_ivar_defined(obj, rbgobj_id_children))) + rb_ivar_set(obj, rbgobj_id_children, Qnil); +} + +void +rbgobj_add_relative_removable(VALUE obj, VALUE relative, ID obj_ivar_id, VALUE hash_key) +{ + VALUE hash = Qnil; + + if (RVAL2CBOOL(rb_ivar_defined(obj, obj_ivar_id))) + hash = rb_ivar_get(obj, obj_ivar_id); + + if (NIL_P(hash) || TYPE(hash) != RUBY_T_HASH) { + hash = rb_hash_new(); + rb_ivar_set(obj, obj_ivar_id, hash); + } + rb_hash_aset(hash, hash_key, relative); +} + +VALUE +rbgobj_get_relative_removable(VALUE obj, ID obj_ivar_id, VALUE hash_key) +{ + VALUE hash = Qnil; + + if (RVAL2CBOOL(rb_ivar_defined(obj, obj_ivar_id))) + hash = rb_ivar_get(obj, obj_ivar_id); + + if (NIL_P(hash) || TYPE(hash) != RUBY_T_HASH) { + return Qnil; + } + return rb_hash_aref(hash, hash_key); +} + +void +rbgobj_remove_relative(VALUE obj, ID obj_ivar_id, VALUE hash_key) +{ + VALUE hash = Qnil; + + if (RVAL2CBOOL(rb_ivar_defined(obj, obj_ivar_id))) + hash = rb_ivar_get(obj, obj_ivar_id); + + if (NIL_P(hash) || TYPE(hash) != RUBY_T_HASH) { + /* should not happen. */ + } else { + rb_funcall(hash, id_delete, 1, hash_key); + } +} + +void +rbgobj_remove_relative_all(VALUE obj, ID obj_ivar_id) +{ + rb_ivar_set(obj, obj_ivar_id, Qnil); +} + +/**********************************************************************/ + +static GHashTable* prop_exclude_list; + +#define IS_FLAG(bitmask, flag) (((bitmask) & (flag)) == (flag)) + +void +rbgobj_define_property_accessors(VALUE klass) +{ + GType gtype; + GParamSpec** pspecs = NULL; + guint i; + GString* source; + guint n_properties = 0; + gtype = CLASS2GTYPE(klass); + + if (G_TYPE_IS_INTERFACE(gtype)){ +#if GLIB_CHECK_VERSION(2,4,0) + gpointer iface = g_type_default_interface_ref(gtype); + pspecs = g_object_interface_list_properties(iface, &n_properties); + g_type_default_interface_unref(iface); +#endif + } else { + GObjectClass* oclass = G_OBJECT_CLASS(g_type_class_ref(gtype)); + pspecs = g_object_class_list_properties(oclass, &n_properties); + g_type_class_unref(oclass); + } + + if (n_properties == 0) + return; + + source = g_string_new(NULL); + for (i = 0; i < n_properties; i++){ + GParamSpec* pspec = pspecs[i]; + char* buf; + char* prop_name; + char* p; + + if (pspec->owner_type != gtype) + continue; + + buf = g_strdup(pspec->name); + for (p = buf; *p; p++) + if (*p == '-') + *p = '_'; + + if (!strncmp(buf, "is_", 3)) + prop_name = buf + 3; + else + prop_name = buf; + + if (g_hash_table_lookup(prop_exclude_list, prop_name)){ + g_free(buf); + continue; + } + + if (pspec->flags & G_PARAM_READABLE){ + g_string_append_printf( + source, + "def %s%s; get_property('%s'); end\n", + prop_name, + (G_PARAM_SPEC_VALUE_TYPE(pspec) == G_TYPE_BOOLEAN) ? "?" : "", + pspec->name); + } + + if (IS_FLAG(pspec->flags, G_PARAM_WRITABLE) && !IS_FLAG(pspec->flags, G_PARAM_CONSTRUCT_ONLY)){ + g_string_append_printf(source, + "def set_%s(val); set_property('%s', val); end\n", + prop_name, pspec->name); +#ifdef HAVE_NODE_ATTRASGN + g_string_append_printf(source, "alias %s= set_%s\n", + prop_name, prop_name); +#else + g_string_append_printf(source, + "def %s=(val); set_property('%s', val); val; end\n", + prop_name, pspec->name); +#endif + } + + g_free(buf); + } + + if (source->len > 0) + rb_funcall(klass, id_module_eval, 1, rb_str_new2(source->str)); + g_string_free(source, TRUE); +} + +/**********************************************************************/ + +void +Init_gobject(void) +{ + /* Not defined properties. They are already used as methods of Object */ + prop_exclude_list = g_hash_table_new(g_str_hash, g_str_equal); + g_hash_table_insert(prop_exclude_list, (gpointer)"class", (gpointer)"class"); + g_hash_table_insert(prop_exclude_list, (gpointer)"clone", (gpointer)"clone"); + g_hash_table_insert(prop_exclude_list, (gpointer)"dup", (gpointer)"dup"); + g_hash_table_insert(prop_exclude_list, (gpointer)"extend", (gpointer)"extend"); + g_hash_table_insert(prop_exclude_list, (gpointer)"freeze", (gpointer)"freeze"); + g_hash_table_insert(prop_exclude_list, (gpointer)"hash", (gpointer)"hash"); + g_hash_table_insert(prop_exclude_list, (gpointer)"method", (gpointer)"method"); + g_hash_table_insert(prop_exclude_list, (gpointer)"methods", (gpointer)"methods"); + g_hash_table_insert(prop_exclude_list, (gpointer)"object_id", (gpointer)"object_id"); + g_hash_table_insert(prop_exclude_list, (gpointer)"taint", (gpointer)"taint"); + g_hash_table_insert(prop_exclude_list, (gpointer)"untaint", (gpointer)"untaint"); + + /* IDs */ + id_relatives = rb_intern("__relatives__"); + id_delete = rb_intern("delete"); + id_module_eval = rb_intern("module_eval"); + + rbgobj_id_children = rb_intern("__stored_children__"); + + Init_gobject_convert(); + + Init_gobject_gtype(); + Init_gobject_typeinterface(); + Init_gobject_typeinstance(); + Init_gobject_gvalue(); + Init_gobject_gvaluetypes(); + Init_gobject_gboxed(); +#if GLIB_CHECK_VERSION(2,6,0) + Init_gobject_gstrv(); +#endif + Init_gobject_value_array(); + Init_gobject_genumflags(); + Init_gobject_gparam(); + Init_gobject_gparamspecs(); + Init_gobject_gclosure(); + Init_gobject_gobject(); + Init_gobject_gsignal(); + + Init_gobject_gtypeplugin(); + Init_gobject_gtypemodule(); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobject.h b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobject.h new file mode 100644 index 0000000..adecc4e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgobject.h @@ -0,0 +1,300 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003,2006 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __RBGOBJECT_H__ +#define __RBGOBJECT_H__ + +#include +#include "ruby.h" +#include "rbglib.h" +#include "rbgutil.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* macros */ + +#define G_INITIALIZE(obj, cobj)\ + (rbgobj_initialize_object(obj, (gpointer)cobj)) + +#define G_DEF_CLASS(gtype, name, module)\ + (rbgobj_define_class(gtype, name, module, 0, 0, Qnil)) +#define G_DEF_CLASS_WITH_GC_FUNC(gtype, name, module, mark, free) \ + (rbgobj_define_class(gtype, name, module, mark, free, Qnil)) +#define G_DEF_CLASS2(gtype, name, module, mark, free) \ + G_DEF_CLASS_WITH_GC_FUNC(gtype, name, module, mark, free) +#define G_DEF_CLASS3(gtype_name, name, module)\ + (rbgobj_define_class_dynamic(gtype_name, name, module, 0, 0)) +#define G_DEF_CLASS_WITH_PARENT(gtype, name, module, parent) \ + (rbgobj_define_class(gtype, name, module, 0, 0, parent)) +#define G_DEF_CLASS4(gtype, name, module, parent) \ + G_DEF_CLASS_WITH_PARENT(gtype, name, module, parent) + +#define G_DEF_INTERFACE(gtype, name, module)\ + (rbgobj_define_class(gtype, name, module, 0, 0, Qnil)) +#define G_DEF_INTERFACE2(gtype, name, module, mark, free)\ + (rbgobj_define_class(gtype, name, module, mark, free, Qnil)) + +#define RG_DEF_CONVERSION(table) (rbgobj_convert_define(table)) + +#define G_RELATIVE(obj, rel) (rbgobj_add_relative(obj, rel)) + +/* G_RELATIVE2 is useless now. Try G_CHILD_ADD/REMOVE first. */ +#define G_RELATIVE2(obj, rel, id, hash_key)\ + (rbgobj_add_relative_removable(obj, rel, id, hash_key)) +#define G_GET_RELATIVE(obj, id, hash_key)\ + (rbgobj_get_relative_removable(obj, id, hash_key)) +#define G_REMOVE_RELATIVE(obj, id, hash_key)\ + (rbgobj_remove_relative(obj, id, hash_key)) + +RUBY_GLIB2_VAR ID rbgobj_id_children; +#define G_CHILD_SET(self, id, child) (rb_ivar_set(self, id, child)) +#define G_CHILD_UNSET(self, id) (rb_ivar_set(self, id, Qnil)) + +/* G_CHILD_ADD is same as G_RELATIVE, but the macro name is more obviously + to use than G_RELATIVE, and also support "remove" operation with the key + which is the object itself. +*/ +#define G_CHILD_ADD(self, child) \ + (rbgobj_add_relative_removable(self, Qnil, rbgobj_id_children, child)) +#define G_CHILD_REMOVE(self, child) \ + (rbgobj_remove_relative(self, rbgobj_id_children, child)) +#define G_CHILD_REMOVE_ALL(self) \ + (rbgobj_remove_relative_all(self, rbgobj_id_children)) + +#define G_DEF_SIGNAL_FUNC(klass, sig_name, func)\ + (rbgobj_set_signal_func(klass, sig_name, func)) + +#define CLASS2CINFO(klass) (rbgobj_lookup_class(klass)) +#define GTYPE2CINFO(gtype) (rbgobj_lookup_class_by_gtype(gtype, Qnil)) +#define GTYPE2CINFO_NO_CREATE(gtype) (rbgobj_lookup_class_by_gtype_full(gtype, Qnil, FALSE)) +#define RVAL2CINFO(obj) (rbgobj_lookup_class(CLASS_OF(obj))) +#define GTYPE2CLASS(gtype) (rbgobj_gtype_to_ruby_class(gtype)) +#define CLASS2GTYPE(klass) (rbgobj_lookup_class(klass)->gtype) +#define RVAL2GTYPE(obj) (CLASS2GTYPE(CLASS_OF(obj))) + +#define RVAL2GOBJ(obj) (rbgobj_instance_from_ruby_object(obj)) +#define GOBJ2RVAL(gobj) (rbgobj_ruby_object_from_instance(gobj)) +#define GOBJ2RVAL_UNREF(gobj) (rbgobj_ruby_object_from_instance_with_unref(gobj)) +#define GOBJ2RVALU(gobj) GOBJ2RVAL_UNREF(gobj) +#define GVAL2RVAL(v) (rbgobj_gvalue_to_rvalue(v)) +#define GVAL2RVAL_UNSET(v) (rbgobj_gvalue_to_rvalue(v)) + +#define RVAL2BOXED(obj, gtype) (rbgobj_boxed_get(obj, gtype)) +#define BOXED2RVAL(cobj, gtype) (rbgobj_make_boxed(cobj, gtype)) + +#define RVAL2GENUM(obj, gtype) (rbgobj_get_enum(obj, gtype)) +#define RVAL2GFLAGS(obj, gtype) (rbgobj_get_flags(obj, gtype)) +#define GENUM2RVAL(n, gtype) (rbgobj_make_enum(n, gtype)) +#define GFLAGS2RVAL(n, gtype) (rbgobj_make_flags(n, gtype)) + +#define RVAL2GPTR(object) (rbgobj_ptr2cptr(object)) +#define GPTR2RVAL(ptr, gtype) (rbgobj_ptr_new(gtype, ptr)) + +#define G_DEF_CONSTANTS(mod, type, strip_prefix) \ + rbgobj_add_constants(mod, type, strip_prefix) +#define G_RENAME_CONSTANT(orig, alt) \ + rbgobj_constant_remap(orig, alt) +#define G_RENAME_NICK(orig, alt) \ + rbgobj_constant_remap(orig, alt) + +typedef enum +{ + RBGOBJ_ABSTRACT_BUT_CREATABLE = 1 << 0, /* deprecated */ + RBGOBJ_BOXED_NOT_COPY = 1 << 1, + RBGOBJ_DEFINED_BY_RUBY = 1 << 2, +} RGObjClassFlag; + +typedef void (*RGMarkFunc)(gpointer object); +typedef void (*RGFreeFunc)(gpointer object); + +typedef struct { + VALUE klass; + GType gtype; + RGMarkFunc mark; + RGFreeFunc free; + int flags; /* RGObjClassFlag */ +} RGObjClassInfo; + +/* rbgobject.c */ + +extern void rbgobj_initialize_object(VALUE obj, gpointer cobj); +extern gpointer rbgobj_instance_from_ruby_object(VALUE obj); +extern VALUE rbgobj_ruby_object_from_instance(gpointer instance); +extern VALUE rbgobj_ruby_object_from_instance2(gpointer instance, gboolean alloc); +extern VALUE rbgobj_ruby_object_from_instance_with_unref(gpointer instance); + +extern void rbgobj_add_relative(VALUE obj, VALUE relative); +extern void rbgobj_invalidate_relatives(VALUE obj); +extern void rbgobj_add_relative_removable(VALUE obj, VALUE relative, + ID obj_ivar_id, VALUE hash_key); +extern VALUE rbgobj_get_relative_removable(VALUE obj, ID obj_ivar_id, + VALUE hash_key); +extern void rbgobj_remove_relative(VALUE obj, ID obj_ivar_id, VALUE hash_key); +extern void rbgobj_remove_relative_all(VALUE obj, ID obj_ivar_id); + +extern GObject* rbgobj_gobject_new(GType type, VALUE params_hash); +extern VALUE rbgobj_create_object(VALUE klass); /* deprecated */ + +extern VALUE rbgobj_get_ruby_object_from_gobject(GObject* gobj, gboolean alloc); + +/* For Ruby/Gstreamer */ +extern void rbgobj_gobject_initialize(VALUE obj, gpointer cobj); + +/* deprecated */ +extern void rbgobj_add_abstract_but_create_instance_class(GType gtype); + +/* rbgobj_typeinstance.c */ +extern void rbgobj_gc_mark_instance(gpointer instance); + + +/* rbgobj_type.c */ +extern const RGObjClassInfo *rbgobj_lookup_class(VALUE klass); +extern const RGObjClassInfo *rbgobj_lookup_class_by_gtype(GType gtype, VALUE parent); +extern const RGObjClassInfo *rbgobj_lookup_class_by_gtype_full(GType gtype, + VALUE parent, + gboolean create_object); +extern VALUE rbgobj_gtype_to_ruby_class(GType gtype); +extern VALUE rbgobj_define_class(GType gtype, const gchar* name, VALUE module, + RGMarkFunc mark, RGFreeFunc free, VALUE parent); +extern VALUE rbgobj_define_class_dynamic(const gchar* gtype_name, + const gchar* name, VALUE module, + RGMarkFunc mark, RGFreeFunc free); +extern void rbgobj_register_class(VALUE klass, + GType gtype, + gboolean klass2gtype, + gboolean gtype2klass); +extern void rbgobj_register_mark_func(GType gtype, RGMarkFunc mark); +extern void rbgobj_register_free_func(GType gtype, RGFreeFunc free); +extern VALUE rbgobj_cType; +extern VALUE rbgobj_gtype_new(GType gtype); +extern GType rbgobj_gtype_get(VALUE obj); + +/* rbgobj_signal.c */ +typedef VALUE (*GValToRValSignalFunc)(guint num,const GValue* values); +extern void rbgobj_set_signal_func(VALUE klass, const gchar *sig_name, GValToRValSignalFunc func); +extern GValToRValSignalFunc rbgobj_get_signal_func(guint signal_id); +extern VALUE rbgobj_signal_wrap(guint sig_id); + + +/* rbgobj_closure.c */ +extern GClosure* g_rclosure_new(VALUE callback_proc, VALUE extra_args, + GValToRValSignalFunc func); +extern void g_rclosure_attach(GClosure *closure, VALUE object); +extern void g_rclosure_set_tag(GClosure *closure, const gchar *tag); + +/* rbgobj_value.c */ +extern VALUE rbgobj_gvalue_to_rvalue(const GValue* value); +extern VALUE rbgobj_gvalue_to_rvalue_unset(GValue *value); +extern void rbgobj_rvalue_to_gvalue(VALUE val, GValue* result); +extern void rbgobj_initialize_gvalue(GValue *result, VALUE value); + +typedef void (*RValueToGValueFunc)(VALUE from, GValue* to); +typedef VALUE (*GValueToRValueFunc)(const GValue* from); +extern void rbgobj_register_r2g_func(GType gtype, RValueToGValueFunc func); +extern void rbgobj_register_g2r_func(GType gtype, GValueToRValueFunc func); + +extern void rbgobj_gc_mark_gvalue(GValue* value); + +/* rbgobj_valuetypes.c */ +extern VALUE rbgobj_ptr_new(GType type, gpointer ptr); +extern gpointer rbgobj_ptr2cptr(VALUE ptr); + +#define RBGOBJ_TYPE_RUBY_VALUE (rbgobj_ruby_value_get_type()) +extern GType rbgobj_ruby_value_get_type(void); +extern VALUE g_value_get_ruby_value(const GValue* value); +extern void g_value_set_ruby_value(GValue* value, VALUE ruby); + +/* rbgobj_object.c */ +extern void rbgobj_register_property_setter(GType gtype, const char* prop_name, RValueToGValueFunc func); +extern void rbgobj_register_property_getter(GType gtype, const char* prop_name, GValueToRValueFunc func); + +/* rbgobj_boxed.c */ +extern VALUE rbgobj_boxed_create(VALUE klass); /* deprecated */ +extern gpointer rbgobj_boxed_get(VALUE obj, GType gtype); +extern gpointer rbgobj_boxed_get_default(VALUE obj, GType gtype); +extern VALUE rbgobj_make_boxed(gpointer data, GType gtype); +extern VALUE rbgobj_make_boxed_raw(gpointer p, GType gtype, + VALUE klass, gint flags); +extern VALUE rbgobj_make_boxed_default(gpointer data, GType gtype); +extern void rbgobj_boxed_not_copy_obj(GType gtype); +extern void rbgobj_boxed_unown(VALUE boxed); + +/* rbgobj_enums.c */ +extern void rbgobj_constant_remap(const char *original, const char *replacement); +extern void rbgobj_add_constants(VALUE mod, GType type, const gchar *strip_prefix); +extern VALUE rbgobj_make_enum(gint n, GType gtype); +extern gint rbgobj_get_enum(VALUE obj, GType gtype); +extern VALUE rbgobj_make_flags(guint n, GType gtype); +extern guint rbgobj_get_flags(VALUE obj, GType gtype); +extern void rbgobj_define_const(VALUE mod, const char *name, VALUE value); + + +/* rbglib_mainloop.c */ +#if !GLIB_CHECK_VERSION(2,30,0) + #define G_TYPE_MAIN_LOOP (g_main_loop_get_type()) + extern GType g_main_loop_get_type(void); +#endif + +/* rbglib_maincontext.c */ +#if !GLIB_CHECK_VERSION(2,30,0) + #define G_TYPE_MAIN_CONTEXT (g_main_context_get_type()) + #define G_TYPE_SOURCE (g_source_get_type()) + extern GType g_main_context_get_type(void); + extern GType g_source_get_type(void); +#endif + +#define G_TYPE_POLL_FD (g_poll_fd_get_type()) +extern GType g_poll_fd_get_type(void); + +/* rbglib_keyfile.c */ +#if !GLIB_CHECK_VERSION(2,31,2) + #define G_TYPE_KEY_FILE (g_key_file_get_type()) + extern GType g_key_file_get_type(void); +#endif + +/* rbgobj_convert.c */ +typedef struct { + GType type; + VALUE klass; + gpointer user_data; + GDestroyNotify notify; + VALUE (*get_superclass)(gpointer user_data); + void (*type_init_hook)(VALUE klass, gpointer user_data); + void (*rvalue2gvalue)(VALUE value, GValue *result, gpointer user_data); + VALUE (*gvalue2rvalue)(const GValue *value, gpointer user_data); + void (*initialize)(VALUE rb_instance, gpointer insntance, gpointer user_data); + gpointer (*robj2instance)(VALUE rb_instance, gpointer user_data); + VALUE (*instance2robj)(gpointer instance, gpointer user_data); + void (*unref)(gpointer instance, gpointer user_data); +} RGConvertTable; + +extern void rbgobj_convert_define(const RGConvertTable *table); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __RBGOBJECT_H__ */ + +#include "rbgcompat.h" diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgprivate.h b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgprivate.h new file mode 100644 index 0000000..3cda33c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgprivate.h @@ -0,0 +1,177 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011-2013 Ruby-GNOME2 Project Team + * Copyright (C) 2007 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __RBGPRIVATE_H__ +#define __RBGPRIVATE_H__ + +#include "rbgobject.h" +#include "glib-enum-types.h" + +#ifndef HAVE_RB_ERRINFO +# define rb_errinfo() (ruby_errinfo) +#endif + +#ifndef HAVE_RB_STR_NEW_CSTR +# define rb_str_new_cstr(c_string) rb_str_new2(c_string) +#endif + +#ifndef G_VALUE_INIT +# define G_VALUE_INIT { 0, { { 0 } } } +#endif + +G_BEGIN_DECLS + +typedef struct { + VALUE self; + GObject* gobj; + const RGObjClassInfo* cinfo; + gboolean destroyed; +} gobj_holder; + +typedef struct { + gpointer boxed; + gboolean own; + GType type; +} boxed_holder; + +#ifdef HAVE_RB_THREAD_BLOCKING_REGION +G_GNUC_INTERNAL extern GStaticPrivate rg_polling_key; +#endif + +extern VALUE rbgobj_cEnum; +extern VALUE rbgobj_cFlags; +extern VALUE rbgobj_cBoxed; +extern VALUE rbgobj_cParam; +extern VALUE rbgobj_mInterface; +extern VALUE rbgobj_cObject; + +extern VALUE rbgobj_cInstantiatable; +extern VALUE rbgobj_mMetaInterface; +#define cInstantiatable rbgobj_cInstantiatable +#define mMetaInterface rbgobj_mMetaInterface + +extern void rbgobj_define_property_accessors(VALUE klass); +extern void rbgobj_define_action_methods(VALUE klass); + +extern void rbgobj_param_spec_initialize(VALUE self, GParamSpec* pspec); +extern void rbgobj_boxed_initialize(VALUE obj, gpointer boxed); + +extern GParamSpec* rbgobj_get_param_spec(VALUE obj); +extern GObject* rbgobj_get_gobject(VALUE obj); + +extern VALUE rbgobj_get_ruby_object_from_param_spec(GParamSpec* pspec, gboolean alloc); + +extern void rbgobj_init_object_class(VALUE klass); +extern void rbgobj_init_flags_class(VALUE klass); +extern void rbgobj_init_enum_class(VALUE klass); +extern void rbgobj_init_interface(VALUE interf); + +/* FIXME: should have better name */ +extern void rbgobj_instance_call_cinfo_mark(gpointer instance); +extern void rbgobj_instance_call_cinfo_free(gpointer instance); + +VALUE rbgutil_generic_s_gtype(VALUE klass); +VALUE rbgutil_generic_gtype(VALUE self); +#define generic_s_gtype rbgutil_generic_s_gtype +#define generic_gtype rbgutil_generic_gtype + +extern gboolean rbgobj_convert_has_type(GType type); +extern RGConvertTable *rbgobj_convert_lookup(GType type); + +extern gboolean rbgobj_convert_get_superclass(GType type, VALUE *result); +extern gboolean rbgobj_convert_type_init_hook(GType type, VALUE klass); +extern gboolean rbgobj_convert_gvalue2rvalue(GType type, const GValue *value, + VALUE *result); +extern gboolean rbgobj_convert_rvalue2gvalue(GType type, VALUE val, + GValue *result); +extern GType rbgobj_convert_rvalue2gtype(VALUE val); +extern gboolean rbgobj_convert_initialize(GType type, VALUE obj, gpointer cobj); +extern gboolean rbgobj_convert_robj2instance(GType type, VALUE obj, + gpointer *result); +extern gboolean rbgobj_convert_instance2robj(GType type, gpointer instance, + VALUE *result); +extern gboolean rbgobj_convert_unref(GType type, gpointer instance); + +#define RubyGObjectHookModule "RubyGObjectHook__" + +G_GNUC_INTERNAL VALUE rg_enum_resolve_value(VALUE klass, VALUE nick); +G_GNUC_INTERNAL void rg_enum_add_constants(VALUE mod, GType enum_type, const gchar *strip_prefix); +G_GNUC_INTERNAL void rg_flags_add_constants(VALUE mod, GType flags_type, const gchar *strip_prefix); +G_GNUC_INTERNAL char *rg_obj_constant_lookup(const char *name); + +G_GNUC_INTERNAL void Init_gutil(void); +G_GNUC_INTERNAL void Init_gutil_callback(void); +G_GNUC_INTERNAL void Init_glib_int64(void); +G_GNUC_INTERNAL void Init_glib_error(void); +G_GNUC_INTERNAL void Init_glib_threads(void); +G_GNUC_INTERNAL void Init_glib_convert(void); +G_GNUC_INTERNAL void Init_glib_messages(void); +G_GNUC_INTERNAL void Init_glib_spawn(void); +G_GNUC_INTERNAL void Init_glib_spawnerror(void); +G_GNUC_INTERNAL void Init_glib_fileutils(void); +G_GNUC_INTERNAL void Init_glib_utils(void); +G_GNUC_INTERNAL void Init_glib_i18n(void); +G_GNUC_INTERNAL void Init_glib_win32(void); +G_GNUC_INTERNAL void Init_gobject(void); +G_GNUC_INTERNAL void Init_glib_main_loop(void); +G_GNUC_INTERNAL void Init_glib_main_context(void); +G_GNUC_INTERNAL void Init_glib_source(void); +G_GNUC_INTERNAL void Init_glib_poll_fd(void); +G_GNUC_INTERNAL void Init_glib_io_constants(void); +G_GNUC_INTERNAL void Init_glib_io_channel(void); +G_GNUC_INTERNAL void Init_glib_io_channelerror(void); +G_GNUC_INTERNAL void Init_glib_io_channel_win32_socket(void); +G_GNUC_INTERNAL void Init_glib_shell(void); +G_GNUC_INTERNAL void Init_glib_shellerror(void); +G_GNUC_INTERNAL void Init_glib_timer(void); +G_GNUC_INTERNAL void Init_glib_unicode(void); +G_GNUC_INTERNAL void Init_glib_utf8(void); +G_GNUC_INTERNAL void Init_glib_utf16(void); +G_GNUC_INTERNAL void Init_glib_ucs4(void); +G_GNUC_INTERNAL void Init_glib_unichar(void); +G_GNUC_INTERNAL void Init_glib_keyfile(void); +G_GNUC_INTERNAL void Init_glib_bookmark_file(void); + +G_GNUC_INTERNAL void Init_gobject_convert(void); +G_GNUC_INTERNAL void Init_gobject_gtype(void); +G_GNUC_INTERNAL void Init_gobject_typeinterface(void); +G_GNUC_INTERNAL void Init_gobject_typeinstance(void); +G_GNUC_INTERNAL void Init_gobject_gvalue(void); +G_GNUC_INTERNAL void Init_gobject_gvaluetypes(void); +G_GNUC_INTERNAL void Init_gobject_gboxed(void); +#if GLIB_CHECK_VERSION(2,6,0) +G_GNUC_INTERNAL void Init_gobject_gstrv(void); +#endif +G_GNUC_INTERNAL void Init_gobject_value_array(void); +G_GNUC_INTERNAL void Init_gobject_genumflags(void); +G_GNUC_INTERNAL void Init_gobject_genums(void); +G_GNUC_INTERNAL void Init_gobject_gflags(void); +G_GNUC_INTERNAL void Init_gobject_gparam(void); +G_GNUC_INTERNAL void Init_gobject_gparamspecs(void); +G_GNUC_INTERNAL void Init_gobject_gclosure(void); +G_GNUC_INTERNAL void Init_gobject_gobject(void); +G_GNUC_INTERNAL void Init_gobject_gsignal(void); +G_GNUC_INTERNAL void Init_gobject_gtypeplugin(void); +G_GNUC_INTERNAL void Init_gobject_gtypemodule(void); + +G_END_DECLS + +#endif diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutil.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutil.c new file mode 100644 index 0000000..705ad88 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutil.c @@ -0,0 +1,145 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011-2013 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +ID rbgutil_id_module_eval; + +static ID id_add_one_arg_setter; +static ID id_set_property; +static ID id_to_a; +static ID id_allocate; +static ID id_equal; + +void +rbg_define_method(VALUE klass, const char *name, VALUE (*func)(ANYARGS), int argc) +{ + rb_define_method(klass, name, func, argc); + if ((argc != 1) || strncmp(name, "set_", 4)) + return; + + name += 4; + rb_funcall(klass, rbgutil_id_module_eval, 1, + CSTR2RVAL_FREE(g_strdup_printf("def %s=(val); set_%s(val); val; end\n", + name, name))); +} + +void +rbg_define_singleton_method(VALUE obj, const char *name, VALUE (*func)(ANYARGS), int argc) +{ + rb_define_singleton_method(obj, name, func, argc); + if ((argc != 1) || strncmp(name, "set_", 4)) + return; + + name += 4; + rb_funcall(obj, rbgutil_id_module_eval, 1, + CSTR2RVAL_FREE(g_strdup_printf("def self.%s=(val); set_%s(val); val; end\n", + name, name))); +} + +void +rbgutil_set_properties(VALUE self, VALUE hash) +{ + int i; + VALUE ary; + GObject* obj; + + Check_Type(hash, RUBY_T_HASH); + ary = rb_funcall(hash, id_to_a, 0); + obj = RVAL2GOBJ(self); + + g_object_freeze_notify(obj); + for (i = 0; i < RARRAY_LEN(ary); i++) { + rb_funcall(self, id_set_property, 2, + RARRAY_PTR(RARRAY_PTR(ary)[i])[0], + RARRAY_PTR(RARRAY_PTR(ary)[i])[1]); + } + g_object_thaw_notify(obj); +} + +VALUE +rbgutil_def_setters(VALUE klass) +{ + return rb_funcall(mGLib, id_add_one_arg_setter, 1, klass); +} + +void +rbgutil_glibid_r2g_func(VALUE from, GValue* to) +{ + VALUE buffer; + g_value_set_string(to, RVAL2GLIBID(from, buffer)); +} + +VALUE +rbgutil_sym_g2r_func(const GValue *from) +{ + const gchar *str = g_value_get_string(from); + return str ? ID2SYM(rb_intern(str)) : Qnil; +} + +VALUE +rbgutil_generic_s_gtype(VALUE klass) +{ + return rbgobj_gtype_new(CLASS2GTYPE(klass)); +} + +VALUE +rbgutil_generic_gtype(VALUE self) +{ + return generic_s_gtype(CLASS_OF(self)); +} + +VALUE +rbgutil_string_set_utf8_encoding(VALUE string) +{ +#ifdef HAVE_RUBY_ENCODING_H + if (!NIL_P(string)) + rb_enc_associate(string, rb_utf8_encoding()); +#endif + return string; +} + +gboolean +rbgutil_key_equal(VALUE rb_key, const char *key) +{ + switch (TYPE(rb_key)) { + case RUBY_T_STRING: + return RVAL2CBOOL(rb_funcall(rb_key, id_equal, 1, rb_str_new_cstr(key))); + break; + case RUBY_T_SYMBOL: + return SYM2ID(rb_key) == rb_intern(key); + break; + default: + return FALSE; + break; + } +} + +void +Init_gutil(void) +{ + rbgutil_id_module_eval = rb_intern("module_eval"); + id_set_property = rb_intern("set_property"); + id_to_a = rb_intern("to_a"); + id_add_one_arg_setter = rb_intern("__add_one_arg_setter"); + id_allocate = rb_intern("allocate"); + id_equal = rb_intern("=="); +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutil.h b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutil.h new file mode 100644 index 0000000..4c15eed --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutil.h @@ -0,0 +1,110 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011-2013 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __RBGUTIL_H__ +#define __RBGUTIL_H__ + +#include +#include "ruby.h" +#ifdef HAVE_RUBY_ENCODING_H +# include +#endif +#include "rbglib.h" +#include "rbgutil_list.h" +#include "rbgutildeprecated.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define RG_DEF_MODFUNC(method, argc) \ + rb_define_module_function(RG_TARGET_NAMESPACE, #method, rg_m_ ## method, argc) +#define RG_DEF_MODFUNC_P(method, argc) \ + rb_define_module_function(RG_TARGET_NAMESPACE, #method"?", rg_m_ ## method ## _p, argc) +#define RG_DEF_MODFUNC_OPERATOR(ope, func, argc) \ + rb_define_module_function(RG_TARGET_NAMESPACE, ope, rg_m_operator_ ## func, argc) +#define RG_DEF_SMETHOD(method, argc) \ + rbg_define_singleton_method(RG_TARGET_NAMESPACE, #method, rg_s_ ## method, argc) +#define RG_DEF_SMETHOD_P(method, argc) \ + rb_define_singleton_method(RG_TARGET_NAMESPACE, #method"?", rg_s_ ## method ## _p, argc) +#define RG_DEF_SMETHOD_BANG(method, argc) \ + rb_define_singleton_method(RG_TARGET_NAMESPACE, #method"!", rg_s_ ## method ## _bang, argc) +#define RG_DEF_SMETHOD_OPERATOR(ope, func, argc) \ + rb_define_singleton_method(RG_TARGET_NAMESPACE, ope, rg_s_operator_ ## func, argc) +#define RG_DEF_METHOD(method, argc) \ + rbg_define_method(RG_TARGET_NAMESPACE, #method, rg_ ## method, argc) +#define RG_DEF_METHOD_P(method, argc) \ + rb_define_method(RG_TARGET_NAMESPACE, #method"?", rg_ ## method ## _p, argc) +#define RG_DEF_METHOD_BANG(method, argc) \ + rb_define_method(RG_TARGET_NAMESPACE, #method"!", rg_ ## method ## _bang, argc) +#define RG_DEF_METHOD_OPERATOR(ope, func, argc) \ + rb_define_method(RG_TARGET_NAMESPACE, ope, rg_operator_ ## func, argc) +#define RG_DEF_ATTR(attr, read, write, ex) \ + rb_attr(RG_TARGET_NAMESPACE, rb_intern(attr), read, write, ex) +#define RG_DEF_ALIAS(new, old) rb_define_alias(RG_TARGET_NAMESPACE, new, old) + +#define RG_REG_GLIBID_SETTER(name) \ + rbgobj_register_property_setter(CLASS2GTYPE(RG_TARGET_NAMESPACE), name, rbgutil_glibid_r2g_func) +#define RG_REG_SYMBOL_GETTER(name) \ + rbgobj_register_property_getter(CLASS2GTYPE(RG_TARGET_NAMESPACE), name, rbgutil_sym_g2r_func) + +#define G_REPLACE_SET_PROPERTY(klass, name, function, args) \ + rb_undef_method(klass, "set_" name); \ + rb_define_method(klass, "set_" name, function, args); \ + rb_undef_method(klass, name "="); \ + G_DEF_SETTER(klass, name) + +#define G_REPLACE_GET_PROPERTY(klass, name, function, args) \ + rb_undef_method(klass, name); \ + rb_define_method(klass, name, function, args) + +#define G_REPLACE_ACTION(klass, name, function, args) \ + rb_undef_method(klass, name); \ + rb_define_method(klass, name, function, args) + +#define G_SET_PROPERTIES(self, hash) (rbgutil_set_properties(self, hash)) +#define G_PROTECT_CALLBACK(func, data) (rbgutil_invoke_callback((VALUE(*)(VALUE))func, (VALUE)data)) + +#define RBG_STRING_SET_UTF8_ENCODING(string) \ + (rbgutil_string_set_utf8_encoding(string)) + +extern void rbg_define_method(VALUE klass, const char *name, VALUE (*func)(ANYARGS), int argc); +extern void rbg_define_singleton_method(VALUE obj, const char *name, VALUE (*func)(ANYARGS), int argc); +extern VALUE rbgutil_def_setters(VALUE klass); +extern void rbgutil_set_properties(VALUE self, VALUE hash); +extern VALUE rbgutil_protect(VALUE (*proc) (VALUE), VALUE data); +extern VALUE rbgutil_invoke_callback(VALUE (*func)(VALUE), VALUE arg); +extern void rbgutil_start_callback_dispatch_thread(void); +extern void rbgutil_stop_callback_dispatch_thread(void); + +extern VALUE rbgutil_string_set_utf8_encoding(VALUE string); +extern gboolean rbgutil_key_equal(VALUE rb_string, const char *key); + +/*< protected >*/ +RUBY_GLIB2_VAR ID rbgutil_id_module_eval; +extern void rbgutil_glibid_r2g_func(VALUE from, GValue* to); +extern VALUE rbgutil_sym_g2r_func(const GValue *from); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __RBGUTIL_H__ */ diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutil_callback.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutil_callback.c new file mode 100644 index 0000000..8f7ae42 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutil_callback.c @@ -0,0 +1,274 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2007 Ruby-GNOME2 Project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +#ifdef G_OS_WIN32 +# ifdef HAVE_IO_H +# include +# define pipe(phandles) _pipe(phandles, 128, _O_BINARY) +# endif +#else +# ifdef HAVE_UNISTD_H +# include +# endif +#endif +#include +#include + +#ifndef HAVE_RUBY_NATIVE_THREAD_P +# define ruby_native_thread_p() is_ruby_native_thread() +#endif + +static VALUE rbgutil_eGLibCallbackNotInitializedError; +static ID id_exit_application; + +/**********************************************************************/ + +VALUE +rbgutil_protect(VALUE (*func) (VALUE), VALUE data) +{ + int state = 0; + VALUE ret = rb_protect(func, data, &state); + VALUE e = rb_errinfo(); + if (state && !NIL_P(e)) + rb_funcall(mGLib, id_exit_application, 2, e, INT2NUM(EXIT_FAILURE)); + return ret; +} + +/**********************************************************************/ + +#ifdef HAVE_NATIVETHREAD + +typedef struct _CallbackRequest { + VALUE (*function)(VALUE); + VALUE argument; + VALUE result; + GMutex *done_mutex; + GCond *done_cond; +} CallbackRequest; + +static GMutex *callback_dispatch_thread_mutex = NULL; +static GAsyncQueue *callback_request_queue = NULL; +static ID id_callback_dispatch_thread; +static gint callback_pipe_fds[2] = {-1, -1}; + +#define CALLBACK_PIPE_READY_MESSAGE "R" +#define CALLBACK_PIPE_READY_MESSAGE_SIZE 1 + +static VALUE +exec_callback(VALUE data) +{ + CallbackRequest *request = (CallbackRequest *)data; + return request->function(request->argument); +} + +static VALUE +process_request(CallbackRequest *request) +{ + g_mutex_lock(request->done_mutex); + request->result = rbgutil_protect(exec_callback, (VALUE)request); + g_cond_signal(request->done_cond); + g_mutex_unlock(request->done_mutex); + + return Qnil; +} + +static VALUE +mainloop(void) +{ + for (;;) { + CallbackRequest *request; + gchar ready_message_buffer[CALLBACK_PIPE_READY_MESSAGE_SIZE]; + + rb_thread_wait_fd(callback_pipe_fds[0]); + if (read(callback_pipe_fds[0], ready_message_buffer, + CALLBACK_PIPE_READY_MESSAGE_SIZE + ) != CALLBACK_PIPE_READY_MESSAGE_SIZE || + strncmp(ready_message_buffer, + CALLBACK_PIPE_READY_MESSAGE, + CALLBACK_PIPE_READY_MESSAGE_SIZE) != 0) { + g_error("failed to read valid callback dispatcher message"); + continue; + } + request = g_async_queue_pop(callback_request_queue); + if (!request) + break; + + rb_thread_create(process_request, request); + } + + close(callback_pipe_fds[0]); + callback_pipe_fds[0] = -1; + close(callback_pipe_fds[1]); + callback_pipe_fds[1] = -1; + + return Qnil; +} + +static void +queue_callback_request(CallbackRequest *request) +{ + ssize_t written; + + g_async_queue_push(callback_request_queue, request); + written = write(callback_pipe_fds[1], + CALLBACK_PIPE_READY_MESSAGE, + CALLBACK_PIPE_READY_MESSAGE_SIZE); + if (written != CALLBACK_PIPE_READY_MESSAGE_SIZE) { + rb_warn("couldn't write all callback pipe ready message: " + "message-size: %d, written: %" G_GSSIZE_FORMAT, + CALLBACK_PIPE_READY_MESSAGE_SIZE, + written); + } +} + +static VALUE +invoke_callback_in_ruby_thread(VALUE (*func)(VALUE), VALUE arg) +{ + CallbackRequest request; + + g_mutex_lock(callback_dispatch_thread_mutex); + if (callback_pipe_fds[0] == -1) { + g_error("Please call rbgutil_start_callback_dispatch_thread() " + "to dispatch a callback from non-ruby thread before " + "callbacks are requested from non-ruby thread."); + g_mutex_unlock(callback_dispatch_thread_mutex); + return Qnil; + } + + request.function = func; + request.argument = arg; + request.result = Qnil; + request.done_mutex = g_mutex_new(); + request.done_cond = g_cond_new(); + + g_mutex_lock(request.done_mutex); + queue_callback_request(&request); + g_mutex_unlock(callback_dispatch_thread_mutex); + + g_cond_wait(request.done_cond, request.done_mutex); + g_mutex_unlock(request.done_mutex); + + g_cond_free(request.done_cond); + g_mutex_free(request.done_mutex); + + + return request.result; +} + +#ifdef HAVE_RB_THREAD_CALL_WITH_GVL +extern void *rb_thread_call_with_gvl(void *(*func)(void *), void *data1); + +static void * +invoke_callback_with_gvl(void *arg) +{ + CallbackRequest *req = (CallbackRequest*)arg; + return (void *)rbgutil_protect(req->function, req->argument); +} +#endif + +#endif + +/**********************************************************************/ + +VALUE +rbgutil_invoke_callback(VALUE (*func)(VALUE), VALUE arg) +{ +#ifdef HAVE_NATIVETHREAD + if (ruby_native_thread_p()) { +# ifdef HAVE_RB_THREAD_BLOCKING_REGION + if (!GPOINTER_TO_INT(g_static_private_get(&rg_polling_key))) { + return rbgutil_protect(func, arg); + } +# endif +# ifdef HAVE_RB_THREAD_CALL_WITH_GVL + { + CallbackRequest req; + req.function = func; + req.argument = arg; + return (VALUE)rb_thread_call_with_gvl(invoke_callback_with_gvl, &req); + } +# endif + } else { + return invoke_callback_in_ruby_thread(func, arg); + } +#endif + return rbgutil_protect(func, arg); +} + +/**********************************************************************/ + +void +rbgutil_start_callback_dispatch_thread(void) +{ +#ifdef HAVE_NATIVETHREAD + VALUE callback_dispatch_thread; + + g_mutex_lock(callback_dispatch_thread_mutex); + callback_dispatch_thread = rb_ivar_get(mGLib, id_callback_dispatch_thread); + if (NIL_P(callback_dispatch_thread)) { + if (pipe(callback_pipe_fds) == -1) + rb_sys_fail("pipe()"); + + callback_dispatch_thread = rb_thread_create(mainloop, NULL); + rb_ivar_set(mGLib, id_callback_dispatch_thread, + callback_dispatch_thread); + } + g_mutex_unlock(callback_dispatch_thread_mutex); +#endif +} + +void +rbgutil_stop_callback_dispatch_thread(void) +{ +#ifdef HAVE_NATIVETHREAD + VALUE callback_dispatch_thread; + + g_mutex_lock(callback_dispatch_thread_mutex); + callback_dispatch_thread = rb_ivar_get(mGLib, id_callback_dispatch_thread); + if (!NIL_P(callback_dispatch_thread)) { + queue_callback_request(NULL); + rb_ivar_set(mGLib, id_callback_dispatch_thread, Qnil); + } + g_mutex_unlock(callback_dispatch_thread_mutex); +#endif +} + +void +Init_gutil_callback(void) +{ + id_exit_application = rb_intern("exit_application"); + rbgutil_eGLibCallbackNotInitializedError = + rb_define_class_under(mGLib, "CallbackNotInitializedError", + rb_eRuntimeError); + +#ifdef HAVE_NATIVETHREAD + if (!g_thread_supported()) + g_thread_init(NULL); + + id_callback_dispatch_thread = rb_intern("callback_dispatch_thread"); + rb_ivar_set(mGLib, id_callback_dispatch_thread, Qnil); + + callback_request_queue = g_async_queue_new(); + callback_dispatch_thread_mutex = g_mutex_new(); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutil_list.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutil_list.c new file mode 100644 index 0000000..c82f887 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutil_list.c @@ -0,0 +1,173 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +struct list2rval_args { + gpointer list; + RBGRValueFunc conv; + GFreeFunc free_list; + GFreeFunc free_elem; +}; + +struct list2rval_with_type_args { + struct list2rval_args args; + RBGRValueFuncWithType conv_with_type; + GType gtype; +}; + +static VALUE +glist2rval_body(VALUE data) +{ + struct list2rval_args *args = (struct list2rval_args *)data; + RBGRValueFunc conv = args->conv; + GList *node; + VALUE ary; + + ary = rb_ary_new(); + if (conv) + for (node = args->list; node; node = g_list_next(node)) + rb_ary_push(ary, conv(node->data)); + + return ary; +} + +static VALUE +gslist2rval_body(VALUE data) +{ + struct list2rval_args *args = (struct list2rval_args *)data; + RBGRValueFunc conv = args->conv; + GSList *node; + VALUE ary; + + ary = rb_ary_new(); + if (conv) + for (node = args->list; node; node = g_slist_next(node)) + rb_ary_push(ary, conv(node->data)); + + return ary; +} + +static VALUE +glist2rval_with_type_body(VALUE data) +{ + struct list2rval_with_type_args *args_with_type = (struct list2rval_with_type_args *)data; + struct list2rval_args *args = (struct list2rval_args *)data; + RBGRValueFuncWithType conv = args_with_type->conv_with_type; + GType gtype = args_with_type->gtype; + GList *node; + VALUE ary; + + ary = rb_ary_new(); + if (conv) + for (node = args->list; node; node = g_list_next(node)) + rb_ary_push(ary, conv(node->data, gtype)); + + return ary; +} + +static VALUE +gslist2rval_with_type_body(VALUE data) +{ + struct list2rval_with_type_args *args_with_type = (struct list2rval_with_type_args *)data; + struct list2rval_args *args = (struct list2rval_args *)data; + RBGRValueFuncWithType conv = args_with_type->conv_with_type; + GType gtype = args_with_type->gtype; + GSList *node; + VALUE ary; + + ary = rb_ary_new(); + if (conv) + for (node = args->list; node; node = g_slist_next(node)) + rb_ary_push(ary, conv(node->data, gtype)); + + return ary; +} + +static VALUE +glist2rval_ensure(VALUE data) +{ + struct list2rval_args *args = (struct list2rval_args *)data; + GList *node; + + if (args->free_elem) + for (node = args->list; node; node = g_list_next(node)) + args->free_elem(node->data); + if (args->free_list) + args->free_list(args->list); + + return Qnil; +} + +static VALUE +gslist2rval_ensure(VALUE data) +{ + struct list2rval_args *args = (struct list2rval_args *)data; + GSList *node; + + if (args->free_elem) + for (node = args->list; node; node = g_slist_next(node)) + args->free_elem(node->data); + if (args->free_list) + args->free_list(args->list); + + return Qnil; +} + +VALUE +rbg_glist2rval(GList *const list, RBGRValueFunc conv, + GFreeFunc free_list, GFreeFunc free_elem) +{ + struct list2rval_args args = {list, conv, free_list, free_elem}; + + return rb_ensure(glist2rval_body, (VALUE)&args, + glist2rval_ensure, (VALUE)&args); +} + +VALUE +rbg_gslist2rval(GSList *const list, RBGRValueFunc conv, + GFreeFunc free_list, GFreeFunc free_elem) +{ + struct list2rval_args args = {list, conv, free_list, free_elem}; + + return rb_ensure(gslist2rval_body, (VALUE)&args, + gslist2rval_ensure, (VALUE)&args); +} + +VALUE +rbg_glist2rval_with_type(GList *const list, RBGRValueFuncWithType conv, GType gtype, + GFreeFunc free_list, GFreeFunc free_elem) +{ + struct list2rval_with_type_args args = {{list, NULL, free_list, free_elem}, conv, gtype}; + + return rb_ensure(glist2rval_with_type_body, (VALUE)&args, + glist2rval_ensure, (VALUE)&args); +} + +VALUE +rbg_gslist2rval_with_type(GSList *const list, RBGRValueFuncWithType conv, GType gtype, + GFreeFunc free_list, GFreeFunc free_elem) +{ + struct list2rval_with_type_args args = {{list, NULL, free_list, free_elem}, conv, gtype}; + + return rb_ensure(gslist2rval_with_type_body, (VALUE)&args, + gslist2rval_ensure, (VALUE)&args); +} + diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutil_list.h b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutil_list.h new file mode 100644 index 0000000..ac4a78b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutil_list.h @@ -0,0 +1,85 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __RBGUTIL_LIST_H__ +#define __RBGUTIL_LIST_H__ + +G_BEGIN_DECLS + +#define CSTRGLIST2RVAL(list) \ + CSTRGLIST2RVAL_FREE(list, NULL, NULL) +#define CSTRGLIST2RVAL_FREE(list, free_list, free_elem) \ + rbg_glist2rval(list, (RBGRValueFunc)rbg_cstr2rval, \ + (GFreeFunc)free_list, (GFreeFunc)free_elem) +#define CSTRGSLIST2RVAL(list) \ + CSTRGSLIST2RVAL_FREE(list, NULL, NULL) +#define CSTRGSLIST2RVAL_FREE(list, free_list, free_elem) \ + rbg_gslist2rval(list, (RBGRValueFunc)rbg_cstr2rval, \ + (GFreeFunc)free_list, (GFreeFunc)free_elem) + +#define FILENAMEGLIST2RVAL(list) \ + FILENAMEGLIST2RVAL_FREE(list, NULL, NULL) +#define FILENAMEGLIST2RVAL_FREE(list, free_list, free_elem) \ + rbg_glist2rval(list, (RBGRValueFunc)rbg_filename_to_ruby, \ + (GFreeFunc)free_list, (GFreeFunc)free_elem) +#define FILENAMEGSLIST2RVAL(list) \ + FILENAMEGSLIST2RVAL_FREE(list, NULL, NULL) +#define FILENAMEGSLIST2RVAL_FREE(list, free_list, free_elem) \ + rbg_gslist2rval(list, (RBGRValueFunc)rbg_filename_to_ruby, \ + (GFreeFunc)free_list, (GFreeFunc)free_elem) + +#define GOBJGLIST2RVAL(list) \ + GOBJGLIST2RVAL_FREE(list, NULL, NULL) +#define GOBJGLIST2RVAL_FREE(list, free_list, free_elem) \ + rbg_glist2rval(list, (RBGRValueFunc)rbgobj_ruby_object_from_instance, \ + (GFreeFunc)free_list, (GFreeFunc)free_elem) +#define GOBJGSLIST2RVAL(list) \ + GOBJGSLIST2RVAL_FREE(list, NULL, NULL) +#define GOBJGSLIST2RVAL_FREE(list, free_list, free_elem) \ + rbg_gslist2rval(list, (RBGRValueFunc)rbgobj_ruby_object_from_instance, \ + (GFreeFunc)free_list, (GFreeFunc)free_elem) + +#define BOXEDGLIST2RVAL(list, gtype) \ + BOXEDGLIST2RVAL_FREE(list, gtype, NULL, NULL) +#define BOXEDGLIST2RVAL_FREE(list, gtype, free_list, free_elem) \ + rbg_glist2rval_with_type(list, (RBGRValueFuncWithType)rbgobj_make_boxed, gtype, \ + (GFreeFunc)free_list, (GFreeFunc)free_elem) +#define BOXEDGSLIST2RVAL(list, gtype) \ + BOXEDGSLIST2RVAL_FREE(list, gtype, NULL, NULL) +#define BOXEDGSLIST2RVAL_FREE(list, gtype, free_list, free_elem) \ + rbg_gslist2rval_with_type(list, (RBGRValueFuncWithType)rbgobj_make_boxed, gtype, \ + (GFreeFunc)free_list, (GFreeFunc)free_elem) + +typedef VALUE (*RBGRValueFunc)(gpointer obj); +typedef VALUE (*RBGRValueFuncWithType)(gpointer obj, GType gtype); + +extern VALUE rbg_glist2rval(GList *const list, RBGRValueFunc conv, + GFreeFunc free_list, GFreeFunc free_elem); +extern VALUE rbg_gslist2rval(GSList *const list, RBGRValueFunc conv, + GFreeFunc free_list, GFreeFunc free_elem); +extern VALUE rbg_glist2rval_with_type(GList *const list, RBGRValueFuncWithType conv, GType gtype, + GFreeFunc free_list, GFreeFunc free_elem); +extern VALUE rbg_gslist2rval_with_type(GSList *const list, RBGRValueFuncWithType conv, GType gtype, + GFreeFunc free_list, GFreeFunc free_elem); + +G_END_DECLS + +#endif /* __RBGUTIL_LIST_H__ */ + diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutildeprecated.c b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutildeprecated.c new file mode 100644 index 0000000..b5d2f65 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutildeprecated.c @@ -0,0 +1,252 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbgprivate.h" + +VALUE +rbgutil_glist2ary(const GList *const list) +{ + VALUE ary; + const GList *i; + + ary = rb_ary_new(); + for (i = list; i != NULL; i = i->next) + rb_ary_push(ary, GOBJ2RVAL(i->data)); + + return ary; +} + +static VALUE +rbgutil_glist2ary_and_free_body(VALUE data) +{ + VALUE ary; + GList *i; + + ary = rb_ary_new(); + for (i = (GList *)data; i != NULL; i = i->next) + rb_ary_push(ary, GOBJ2RVAL(i->data)); + + return ary; +} + +static VALUE +rbgutil_glist2ary_and_free_ensure(VALUE data) +{ + g_list_free((GList *)data); + + return Qnil; +} + +VALUE +rbgutil_glist2ary_and_free(GList *const list) +{ + return rb_ensure(rbgutil_glist2ary_and_free_body, (VALUE)list, + rbgutil_glist2ary_and_free_ensure, (VALUE)list); +} + +VALUE +rbgutil_glist2ary_boxed(const GList *const list, GType gtype) +{ + VALUE ary; + const GList *i; + + ary = rb_ary_new(); + for (i = list; i != NULL; i = i->next) + rb_ary_push(ary, BOXED2RVAL(i->data, gtype)); + + return ary; +} + +struct rbgutil_glist2ary_boxed_and_free_data +{ + GList *const list; + GType gtype; +}; + +static VALUE +rbgutil_glist2ary_boxed_and_free_body(VALUE data) +{ + struct rbgutil_glist2ary_boxed_and_free_data *real; + VALUE ary; + GList *i; + + real = (struct rbgutil_glist2ary_boxed_and_free_data *)data; + ary = rb_ary_new(); + for (i = real->list; i != NULL; i = i->next) + rb_ary_push(ary, BOXED2RVAL(i->data, real->gtype)); + + return ary; +} + +static VALUE +rbgutil_glist2ary_boxed_and_free_ensure(VALUE data) +{ + g_list_free(((struct rbgutil_glist2ary_boxed_and_free_data *)data)->list); + + return Qnil; +} + +VALUE +rbgutil_glist2ary_boxed_and_free(GList *const list, GType gtype) +{ + struct rbgutil_glist2ary_boxed_and_free_data data = { list, gtype }; + + return rb_ensure(rbgutil_glist2ary_boxed_and_free_body, (VALUE)&data, + rbgutil_glist2ary_boxed_and_free_ensure, (VALUE)&data); +} + +VALUE +rbgutil_glist2ary_string(const GList *const list) +{ + VALUE ary; + const GList *i; + + ary = rb_ary_new(); + for (i = list; i != NULL; i = i->next) + rb_ary_push(ary, CSTR2RVAL(i->data)); + + return ary; +} + +static VALUE +rbgutil_glist2ary_string_and_free_body(VALUE data) +{ + VALUE ary; + GList *i; + + ary = rb_ary_new(); + for (i = (GList *)data; i != NULL; i = i->next) + rb_ary_push(ary, CSTR2RVAL(i->data)); + + return ary; +} + +static VALUE +rbgutil_glist2ary_string_and_free_ensure(VALUE data) +{ + GList *i; + + for (i = (GList *)data; i != NULL; i = i->next) + g_free(i->data); + g_list_free((GList *)data); + + return Qnil; +} + +VALUE +rbgutil_glist2ary_string_and_free(GList *const list) +{ + return rb_ensure(rbgutil_glist2ary_string_and_free_body, (VALUE)list, + rbgutil_glist2ary_string_and_free_ensure, (VALUE)list); +} + +VALUE +rbgutil_gslist2ary(const GSList *const list) +{ + VALUE ary; + const GSList *i; + + ary = rb_ary_new(); + for (i = list; i != NULL; i = i->next) + rb_ary_push(ary, GOBJ2RVAL(i->data)); + + return ary; +} + +static VALUE +rbgutil_gslist2ary_and_free_body(VALUE data) +{ + VALUE ary; + GSList *i; + + ary = rb_ary_new(); + for (i = (GSList *)data; i != NULL; i = i->next) + rb_ary_push(ary, GOBJ2RVAL(i->data)); + + return ary; +} + +static VALUE +rbgutil_gslist2ary_and_free_ensure(VALUE data) +{ + g_slist_free((GSList *)data); + + return Qnil; +} + +VALUE +rbgutil_gslist2ary_and_free(GSList *const list) +{ + return rb_ensure(rbgutil_gslist2ary_and_free_body, (VALUE)list, + rbgutil_gslist2ary_and_free_ensure, (VALUE)list); +} + +VALUE +rbgutil_gslist2ary_boxed(const GSList *const list, GType gtype) +{ + VALUE ary; + const GSList *i; + + ary = rb_ary_new(); + for (i = list; i != NULL; i = i->next) + rb_ary_push(ary, BOXED2RVAL(i->data, gtype)); + + return ary; +} + +struct rbgutil_gslist2ary_boxed_and_free_data +{ + GSList *const list; + GType gtype; +}; + +static VALUE +rbgutil_gslist2ary_boxed_and_free_body(VALUE data) +{ + struct rbgutil_gslist2ary_boxed_and_free_data *real; + VALUE ary; + GSList *i; + + real = (struct rbgutil_gslist2ary_boxed_and_free_data *)data; + ary = rb_ary_new(); + for (i = real->list; i != NULL; i = i->next) + rb_ary_push(ary, BOXED2RVAL(i->data, real->gtype)); + + return ary; +} + +static VALUE +rbgutil_gslist2ary_boxed_and_free_ensure(VALUE data) +{ + g_slist_free(((struct rbgutil_gslist2ary_boxed_and_free_data *)data)->list); + + return Qnil; +} + +VALUE +rbgutil_gslist2ary_boxed_and_free(GSList *const list, GType gtype) +{ + struct rbgutil_gslist2ary_boxed_and_free_data data = { list, gtype }; + + return rb_ensure(rbgutil_gslist2ary_boxed_and_free_body, (VALUE)&data, + rbgutil_gslist2ary_boxed_and_free_ensure, (VALUE)&data); +} + diff --git a/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutildeprecated.h b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutildeprecated.h new file mode 100644 index 0000000..10abfb0 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/ext/glib2/rbgutildeprecated.h @@ -0,0 +1,63 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __RBGUTILDEPRECATED_H__ +#define __RBGUTILDEPRECATED_H__ + +G_BEGIN_DECLS + +#define G_DEF_SETTER(klass, name) \ + rb_funcall(klass, rbgutil_id_module_eval, 1, rb_str_new2( \ + "def " name "=(val); set_" name "(val); val; end\n")) +#define G_DEF_SETTERS(klass) rbgutil_def_setters(klass) + +#define GLIST2ARY(list) (rbgutil_glist2ary(list)) +#define GLIST2ARY_FREE(list) (rbgutil_glist2ary_and_free(list)) +#define GLIST2ARYF(list) (GLIST2ARY_FREE(list)) +#define GLIST2ARY2(list, gtype) (rbgutil_glist2ary_boxed(list, gtype)) +#define GLIST2ARY2F(list, gtype) (rbgutil_glist2ary_boxed_and_free(list, gtype)) +#define GLIST2ARY_STR(list) (rbgutil_glist2ary_string(list)) +#define GLIST2ARY_STR_FREE(list) (rbgutil_glist2ary_string_and_free(list)) +#define GSLIST2ARY(list) (rbgutil_gslist2ary(list)) +#define GSLIST2ARY_FREE(list) (rbgutil_gslist2ary_and_free(list)) +#define GSLIST2ARYF(list) (GSLIST2ARY_FREE(list)) +#define GSLIST2ARY2(list, gtype) (rbgutil_gslist2ary_boxed(list, gtype)) +#define GSLIST2ARY2F(list, gtype) (rbgutil_gslist2ary_boxed_and_free(list, gtype)) + +#define G_SET_SYMBOL_PROPERTY(gtype, name) \ + rbgobj_register_property_getter(gtype, name, rbgutil_sym_g2r_func) + +#define G_BLOCK_PROC rb_block_proc + +extern VALUE rbgutil_glist2ary(const GList *list); +extern VALUE rbgutil_glist2ary_and_free(GList* list); +extern VALUE rbgutil_glist2ary_boxed(const GList *list, GType gtype); +extern VALUE rbgutil_glist2ary_boxed_and_free(GList *list, GType gtype); +extern VALUE rbgutil_glist2ary_string(const GList *list); +extern VALUE rbgutil_glist2ary_string_and_free(GList *list); +extern VALUE rbgutil_gslist2ary(const GSList *list); +extern VALUE rbgutil_gslist2ary_and_free(GSList *list); +extern VALUE rbgutil_gslist2ary_boxed(const GSList *list, GType gtype); +extern VALUE rbgutil_gslist2ary_boxed_and_free(GSList *list, GType gtype); + +G_END_DECLS + +#endif /* __RBGUTILDEPRECATED_H__ */ diff --git a/lib/ruby-gtk2-2.0.2/glib2/extconf.rb b/lib/ruby-gtk2-2.0.2/glib2/extconf.rb new file mode 100755 index 0000000..d0361bd --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/extconf.rb @@ -0,0 +1,49 @@ +#!/usr/bin/env ruby + +require 'pathname' +require 'mkmf' +require 'rbconfig' +require 'fileutils' + +package = "glib2" + +base_dir = Pathname(__FILE__).dirname.expand_path +ext_dir = base_dir + "ext" + package +mkmf_gnome2_dir = base_dir + 'lib' + +ruby = File.join(RbConfig::CONFIG['bindir'], + RbConfig::CONFIG['ruby_install_name'] + + RbConfig::CONFIG["EXEEXT"]) + +build_dir = Pathname("ext") + package +FileUtils.mkdir_p(build_dir.to_s) unless build_dir.exist? +extconf_rb_path = ext_dir + "extconf.rb" +system(ruby, "-C", build_dir.to_s, extconf_rb_path.to_s, *ARGV) || exit(false) + +create_makefile(package) +FileUtils.mv("Makefile", "Makefile.lib") + +File.open("Makefile", "w") do |makefile| + makefile.puts(<<-EOM) +all: + (cd ext/#{package} && $(MAKE)) + $(MAKE) -f Makefile.lib + +install: + (cd ext/#{package} && $(MAKE) install) + $(MAKE) -f Makefile.lib install + +site-install: + (cd ext/#{package} && $(MAKE) site-install) + $(MAKE) -f Makefile.lib site-install + +clean: + (cd ext/#{package} && $(MAKE) clean) + $(MAKE) -f Makefile.lib clean + +distclean: + (cd ext/#{package} && $(MAKE) distclean) + $(MAKE) -f Makefile.lib distclean + @rm -f Makefile.lib +EOM +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/lib/glib-mkenums.rb b/lib/ruby-gtk2-2.0.2/glib2/lib/glib-mkenums.rb new file mode 100644 index 0000000..9ff681f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/lib/glib-mkenums.rb @@ -0,0 +1,214 @@ +# +# glib-mkenums.rb +# +# C language enum description generation library like as glib-mkenums tool. +# +# Copyright(C) 2006-2013 Ruby-GNOME2 Project. +# +# This program is licenced under the same license of Ruby-GNOME2. +# + +module GLib + class EnumDefinition + attr_accessor :EnumName, :enum_name, :ENUM_NAME, :ENUM_SHORT + attr_accessor :type, :Type + attr_accessor :g_type_prefix, :prefix + + attr_reader :constants + + def initialize(name, const_lines, g_type_prefix, options={}) + @options = options || {} + @EnumName = name + @g_type_prefix = g_type_prefix + @constants = [] + @enum_name = to_snail_case(@EnumName) + @ENUM_NAME = @enum_name.upcase + @ENUM_SHORT = @ENUM_NAME.sub(/^#{@g_type_prefix.sub(/_TYPE.*$/, "")}/, "").sub(/^_/, "") + + parse_const_lines(const_lines) + end + + def parse_const_lines(const_lines) + if @options[:force_flags] or /<\*\/)?\s* + \{?\s*(.*?) + \}\s*(\w+);/mx) do |force_flags, constants, name| + enum_options = {} + enum_options[:force_flags] = !force_flags.nil? + force_flags_patterns = [(options[:force_flags] || [])].flatten + if force_flags_patterns.any? {|pattern| pattern === name} + enum_options[:force_flags] = true + end + enum = new(name, constants, g_type_prefix, enum_options) + enums << enum + end + enums + end + end + + class MkEnums + # Create target_filename.c and target_filename.h from files + # with g_type_prefix and include_files. + # * target_filename: the target file name. This creates #{target_filename.c} and #{target_filename.h}. + # * files: header files to parse + # * g_type_prefix: the gtype prefix such as GTK_TYPE_ + # * include_files: define #include lines into target_filename.c + def self.create(target_filename, files, g_type_prefix, include_files, + options) + puts "creating #{target_filename}.c" + mkenums = MkEnums.new(target_filename, files, g_type_prefix, include_files, + options) + + open("#{target_filename}.c", "w") do |out| + out.write(mkenums.create_c) + end + puts "creating #{target_filename}.h" + open("#{target_filename}.h", "w") do |out| + out.write(mkenums.create_h) + end + end + + # Initialize GLib::MkEnums + # + # * target_filename: the target file name. This creates #{target_filename.c} and #{target_filename.h}. + # * files: header files to parse + # * g_type_prefix: the gtype prefix such as GTK_TYPE_ + # * include_files: define #include lines into target_filename.c + def initialize(target_filename, files, g_type_prefix, include_files, options) + @target_filename = target_filename + @include_files = include_files + @targets = [] + files.each do |path| + data = "" + File.open(path) do |i| + data = i.read + end + @targets << [path, EnumDefinition.parse(data, g_type_prefix, options)] + end + end + + def create_enums(meth) # :nodoc: + ret = "" + @targets.each do |target| + if target[1].size > 0 + ret << %Q[\n\n/* enumerations from "#{target[0]}" */] + target[1].each{|enum| + ret << enum.__send__(meth) + } + end + end + ret + end + + # Create a C source as a String. + def create_c + ret = "\n/* Generated by glib-mkenums.rb ($Id$) */ \n\n" + ret << %Q[#include "#{@target_filename}.h"\n] + @include_files.each do |file| + ret << "#include <#{file}>\n" + end + ret << "\n" + ret << create_enums(:create_c) + ret << "\n\n/* Generated data ends here */\n\n" + ret + end + + # Create a C header as a String. + def create_h + header = "#{@target_filename}.h" + const = "__#{File.basename(header).upcase.gsub(/-|\./, '_')}__" + + ret = "\n/* Generated by glib-mkenums.rb ($Id$) */ \n\n" + ret << "#ifndef #{const}\n" + ret << "#define #{const}\n\n" + ret << "#include \n\n" + ret << "G_BEGIN_DECLS" + ret << create_enums(:create_h) + ret << "\n\nG_END_DECLS\n\n" + ret << "#endif /* #{const} */\n" + ret << "\n/* Generated data ends here */\n\n" + ret + end + end +end + diff --git a/lib/ruby-gtk2-2.0.2/glib2/lib/glib2.rb b/lib/ruby-gtk2-2.0.2/glib2/lib/glib2.rb new file mode 100644 index 0000000..56751b3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/lib/glib2.rb @@ -0,0 +1,227 @@ +# +# glib2.rb +# Copyright(C) 2005-2010 Ruby-GNOME2 Project. +# +# This program is licenced under the same license of Ruby-GNOME2. + +require 'pathname' +require 'English' +require 'thread' +require 'glib2/deprecatable' + +module GLib + module_function + def check_binding_version?(major, minor, micro) + BINDING_VERSION[0] > major || + (BINDING_VERSION[0] == major && + BINDING_VERSION[1] > minor) || + (BINDING_VERSION[0] == major && + BINDING_VERSION[1] == minor && + BINDING_VERSION[2] >= micro) + end + + def exit_application(exception, status) + msg = exception.message || exception.to_s + msg = exception.class.to_s if msg == "" + backtrace = exception.backtrace + $stderr.puts backtrace.shift + ": #{msg}" + backtrace.each do |v| + $stderr.puts "\t from #{v}" + end + exit(status) + end + + def __add_one_arg_setter(klass) + # for Instance methods. + method_names = klass.instance_methods(false) + method_names.each do |method_name| + next if /\Aset_/ !~ method_name + property_name = $POSTMATCH + next if klass.method_defined?("#{property_name}=") + next if klass.instance_method(method_name).arity != 1 + begin + klass.module_eval("def #{property_name}=(val); set_#{property_name}(val); val; end\n") + rescue SyntaxError + if $DEBUG + $stderr.puts "Couldn't create #{klass}\##{property_name}=(v)." + end + end + end + + # for Class methods/Module functions. + if klass.method(:methods).arity == -1 + method_names = klass.methods(false) + else + method_names = klass.methods + end + singleton_klass = (class << klass; self; end) + method_names.each do |method_name| + next if /\Aset_/ !~ method_name + property_name = $POSTMATCH + next if singleton_klass.method_defined?("#{property_name}=") + next if klass.method(method_name).arity != 1 + begin + klass.module_eval("def self.#{property_name}=(val); set_#{property_name}(val); val; end\n") + rescue SyntaxError + if $DEBUG + $stderr.puts "Couldn't create #{klass}.#{property_name}=(v)." + end + end + end + end + + def prepend_path_to_environment_variable(path, environment_name) + path = Pathname(path) unless path.is_a?(Pathname) + if path.exist? + separator = ::File::PATH_SEPARATOR + + paths = (ENV[environment_name] || '').split(/#{Regexp.escape(separator)}/) + dir = path.to_s + dir = dir.gsub(/\//, ::File::ALT_SEPARATOR) if ::File::ALT_SEPARATOR + unless paths.include?(dir) + paths = [dir] + paths + ENV[environment_name] = paths.join(separator) + end + end + end + + def prepend_dll_path(path) + prepend_path_to_environment_variable(path, "PATH") + end +end + + +base_dir = Pathname.new(__FILE__).dirname.dirname.expand_path +vendor_dir = base_dir + "vendor" + "local" +GLib.prepend_dll_path(vendor_dir + "bin") +begin + major, minor, _ = RUBY_VERSION.split(/\./) + require "#{major}.#{minor}/glib2.so" +rescue LoadError + require 'glib2.so' +end + +module GLib + + class Type + + def decendants + [self] + children.map{|t| t.decendants }.flatten + end + + def ancestors + # ([self] + interfaces + (parent ? parent.ancestors : [])).reverse.uniq.reverse + [self] + (parent ? parent.ancestors : []) + end + end + + + class Enum + def _dump(limit) + Marshal.dump(to_i, limit) + end + + def self._load(obj) + new(Marshal.load(obj)) + end + end + + + class Flags + def _dump(limit) + Marshal.dump(to_i, limit) + end + + def self._load(obj) + new(Marshal.load(obj)) + end + + # FIXME + def inspect + values = self.class.values + if values.find{|x| x == self } + body = nick + else + a = values.select{|x| self >= x } + a = a.reject{|x| a.find{|y| y > x } } + body = a.empty? ? '{}' : a.map{|x| x.nick }.join('|') + end + format('#<%s %s>', self.class.inspect, body) + end + end + + module Log + DOMAIN = "Ruby/GLib" + LEVELS = { + LEVEL_ERROR => "ERROR", + LEVEL_CRITICAL => "CRITICAL", + LEVEL_WARNING => "WARNING", + LEVEL_MESSAGE => "MESSAGE", + LEVEL_INFO => "INFO", + LEVEL_DEBUG => "DEBUG" + } + + module_function + def error(str) + log(DOMAIN, LEVEL_ERROR, caller(1)[0] << ": " << str) + end + def message(str) + log(DOMAIN, LEVEL_MESSAGE, caller(1)[0] << ": " << str) + end + def critical(str) + log(DOMAIN, LEVEL_CRITICAL, caller(1)[0] << ": " << str) + end + def warning(str) + log(DOMAIN, LEVEL_WARNING, caller(1)[0] << ": " << str) + end + + def set_log_domain(domain) + level = GLib::Log::LEVEL_MASK + if $DEBUG + level = 255 + elsif $VERBOSE + level = 127 + end + GLib::Log.set_handler(domain, level) + end + end + + if const_defined?(:UserDirectory) + class UserDirectory + constants.each do |name| + if /\ADIRECTORY_/ =~ name + const_set($POSTMATCH, const_get(name)) + end + end + end + end + + LOG_DOMAIN = "GLib" + + class Object + LOG_DOMAIN = "GLib-GObject" + end + + class Thread + LOG_DOMAIN = "GThread" + end + + module Module + LOG_DOMAIN = "GModule" + end +end + +GLib::Log.set_log_domain(nil) +GLib::Log.set_log_domain(GLib::LOG_DOMAIN) +GLib::Log.set_log_domain(GLib::Object::LOG_DOMAIN) +GLib::Log.set_log_domain(GLib::Thread::LOG_DOMAIN) +GLib::Log.set_log_domain(GLib::Module::LOG_DOMAIN) + +=begin +Don't we need this? +ObjectSpace.define_finalizer(GLib) { + GLib::Log.cancel_handler + puts "GLib::Log.cancel_handler was called." if $DEBUG +} +=end + diff --git a/lib/ruby-gtk2-2.0.2/glib2/lib/glib2/deprecatable.rb b/lib/ruby-gtk2-2.0.2/glib2/lib/glib2/deprecatable.rb new file mode 100644 index 0000000..7da4e61 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/lib/glib2/deprecatable.rb @@ -0,0 +1,149 @@ +module GLib + module Deprecatable + unless respond_to?(:define_singleton_method) + def define_singleton_method(name, &block) + singleton_class = class << self; self; end + singleton_class.__send__(:define_method, name, &block) + end + end + + @@deprecated_const = {} + def define_deprecated_const(deprecated_const, new_const = {}) + @@deprecated_const[self] ||= {} + @@deprecated_const[self][deprecated_const.to_sym] = new_const + end + + def define_deprecated_enums(enums, prefix = nil) + enums = module_eval(enums.to_s) rescue return + enums.constants.each do |const| + deprecated_const = prefix ? "#{prefix}_#{const}" : const + new_const = [enums, const].join('::') + define_deprecated_const(deprecated_const, new_const) + end + end + alias :define_deprecated_flags :define_deprecated_enums + + def define_deprecated_singleton_method(deprecated_method, new_method = {}, &block) + __define_deprecated_method__(:singleton, deprecated_method, new_method, &block) + end + + def define_deprecated_method(deprecated_method, new_method = {}, &block) + __define_deprecated_method__(:instance, deprecated_method, new_method, &block) + end + + def define_deprecated_method_by_hash_args(deprecated_method, old_args, new_args, req_argc = 0, &block) + klass = self + alias_name = "__deprecatable_#{deprecated_method}__" + alias_method alias_name, deprecated_method + private alias_name + + define_method(deprecated_method) do |*margs, &mblock| + if (margs.size == req_argc) || (margs.size == (req_argc + 1) && margs.last.is_a?(Hash)) + else + margs = block.call(self, *margs, &mblock) + msg = "#{caller[0]}: '#{klass}##{deprecated_method}(#{old_args})' style has been deprecated." + warn "#{msg} Use '#{klass}##{deprecated_method}(#{new_args})' style." + end + __send__(alias_name, *margs, &mblock) + end + end + + @@deprecated_signal = {} + def define_deprecated_signal(deprecated_signal, new_signal = {}) + @@deprecated_signal[self] ||= {} + @@deprecated_signal[self][deprecated_signal.to_s.gsub('_', '-').to_sym] = new_signal + end + + def self.extended(class_or_module) + GLib::Instantiatable.class_eval do + %w(signal_connect signal_connect_after).each do |connect_method| + alias_name = "__deprecatable_#{connect_method}__" + next if private_method_defined?(alias_name) + alias_method alias_name, connect_method + private alias_name + + define_method(connect_method) do |signal, *margs, &mblock| + signal = signal.to_s.gsub('_', '-').to_sym + signals = @@deprecated_signal[self] + if new_signal = (signals || {})[signal] + msg = "#{caller[0]}: '#{signal}' signal has been deprecated." + case new_signal + when String, Symbol + warn "#{msg} Use '#{new_signal}' signal." + signal = new_signal + when Hash + if new_signal[:raise] + raise DeprecatedError.new("#{msg} #{new_signal[:raise]}") + elsif new_signal[:warn] + warn "#{msg} #{new_signal[:warn]}" + else + warn "#{msg} Don't use this signal anymore." + end + return + end + end + __send__(alias_name, signal, *margs, &mblock) + end + end + end + end + + private + + def const_missing(deprecated_const) + if new_const = (@@deprecated_const[self] || {})[deprecated_const.to_sym] + msg = "#{caller[0]}: '#{[name, deprecated_const].join('::')}' has been deprecated." + case new_const + when String, Symbol + new_const_val = constant_get(new_const) + case new_const_val + when GLib::Enum, GLib::Flags + alt = " or ':#{new_const_val.nick.gsub('-', '_')}'" + end + warn "#{msg} Use '#{new_const}'#{alt}." + return const_set(deprecated_const, new_const_val) + when Hash + if new_const[:raise] + raise DeprecatedError.new("#{msg} #{new_const[:raise]}") + elsif new_const[:warn] + warn "#{msg} #{new_const[:warn]}" + else + warn "#{msg} Don't use this constant anymore." + end + return + end + end + raise NameError.new("uninitialized constant #{[self, deprecated_const].join('::')}") + end + + def constant_get(const) + const.split('::').inject(Object){|r, c| r.const_get(c)} + end + + def __define_deprecated_method__(type, deprecated_method, new_method = {}, &block) + def_method = type == :singleton ? :define_singleton_method : :define_method + sep = type == :singleton ? '.' : '#' + klass = self + + __send__(def_method, deprecated_method) do |*margs, &mblock| + msg = "#{caller[0]}: '#{klass}#{sep}#{deprecated_method}' has been deprecated." + case new_method + when String, Symbol + warn "#{msg} Use '#{klass}#{sep}#{new_method}'." + __send__(new_method, *margs, &mblock) + when Hash + if new_method[:raise] + raise DeprecatedError.new("#{msg} #{new_method[:raise]}") + elsif new_method[:warn] + warn "#{msg} #{new_method[:warn]}" + block.call(self, *margs, &mblock) if block + end + end + end + end + end + + class DeprecatedError < RuntimeError + end +end + diff --git a/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2-raketask.rb b/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2-raketask.rb new file mode 100644 index 0000000..8f01e8c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2-raketask.rb @@ -0,0 +1,8 @@ +# Copyright(C) 2013 Ruby-GNOME2 Project. +# +# This program is licenced under the same license of Ruby-GNOME2. + +# Just for backward compatibility. +require "gnome2/rake/package-task" + +GNOME2Package = GNOME2::Rake::PackageTask diff --git a/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/external-package.rb b/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/external-package.rb new file mode 100644 index 0000000..d4d8db4 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/external-package.rb @@ -0,0 +1,198 @@ +# -*- ruby -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +module GNOME2 + module Rake + class ExternalPackage < Struct.new(:name, + :label, + :version, + :download_site, + :download_base_url, + :compression_method, + :windows, + :native, + :patches, + :need_autogen, + :need_autoreconf, + :build_concurrently, + :bundled_packages) + def initialize(properties) + super() + properties.each do |key, value| + send("#{key}=", value) + end + end + + def compression_method + super || "gz" + end + + def base_name + "#{name}-#{version}" + end + + def archive_base_name + "#{base_name}.tar.#{compression_method}" + end + + def archive_url + "#{download_base_url}/#{archive_base_name}" + end + + def download_base_url + super || download_site_base_url + end + + def patches + super || [] + end + + def need_autogen? + need_autogen + end + + def need_autoreconf? + need_autoreconf + end + + def windows + super || WindowsConfiguration.new({}) + end + + def windows=(properties) + super(WindowsConfiguration.new(properties)) + end + + def native + super || NativeConfiguration.new({}) + end + + def native=(properties) + super(NativeConfiguration.new(properties)) + end + + def bundled_packages + super || [] + end + + private + def download_site_base_url + case download_site + when :gnome + base_url = "http://ftp.gnome.org/pub/gnome/sources" + release_series = version.gsub(/\A(\d+\.\d+).+\z/, '\1') + base_url << "/#{name}/#{release_series}" + else + base_url = nil + end + base_url + end + + class WindowsConfiguration < Struct.new(:build, + :include_paths, + :library_paths, + :configure_args, + :patches, + :need_autogen, + :need_autoreconf, + :build_concurrently, + :use_cc_environment_variable) + def initialize(properties) + super() + properties.each do |key, value| + send("#{key}=", value) + end + end + + def build? + build.nil? ? true : build + end + + def include_paths + super || [] + end + + def library_paths + super || [] + end + + def configure_args + super || [] + end + + def patches + super || [] + end + + def need_autogen? + need_autogen.nil? ? false : need_autogen + end + + def need_autoreconf? + need_autoreconf.nil? ? false : need_autoreconf + end + + def build_concurrently? + build_concurrently.nil? ? true : build_concurrently + end + + def use_cc_environment_variable? + use_cc_environment_variable.nil? ? true : use_cc_environment_variable + end + end + + class NativeConfiguration < Struct.new(:build, + :configure_args, + :patches, + :need_autogen, + :need_autoreconf, + :build_concurrently) + def initialize(properties) + super() + properties.each do |key, value| + send("#{key}=", value) + end + end + + def build? + build.nil? ? false : build + end + + def configure_args + super || [] + end + + def patches + super || [] + end + + def need_autogen? + need_autogen.nil? ? false : need_autogen + end + + def need_autoreconf? + need_autoreconf.nil? ? false : need_autoreconf + end + + def build_concurrently? + build_concurrently.nil? ? true : build_concurrently + end + end + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/native-binary-build-task.rb b/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/native-binary-build-task.rb new file mode 100644 index 0000000..f3d6240 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/native-binary-build-task.rb @@ -0,0 +1,108 @@ +# -*- ruby -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "rake" + +module GNOME2 + module Rake + class NativeBinaryBuildTask + include ::Rake::DSL + + def initialize(package) + @package = package + end + + def define + namespace :native do + namespace :builder do + task :before + define_build_tasks + build_tasks = build_packages.collect do |package| + "native:builder:build:#{package.name}" + end + task :build => build_tasks + task :after + end + + desc "Build binaries for build environment" + task :build => [ + "native:builder:before", + "native:builder:build", + "native:builder:after", + ] + end + end + + private + def define_build_tasks + namespace :build do + build_packages.each do |package| + download_task = "source:downloader:download:#{package.name}" + desc "Build #{package.label} and install it into #{dist_dir}." + task package.name => [download_task] do + package_tmp_dir = @package.tmp_dir + package.name + rm_rf(package_tmp_dir) + mkdir_p(package_tmp_dir) + + tar_full_path = @package.download_dir + package.archive_base_name + Dir.chdir(package_tmp_dir.to_s) do + sh("tar", "xf", tar_full_path.to_s) or exit(false) + end + + Dir.chdir((package_tmp_dir + package.base_name).to_s) do + package.native.patches.each do |patch| + sh("patch -p1 < #{@package.patches_dir}/#{patch}") + end + sh("./autogen.sh") if package.native.need_autogen? + sh("autoreconf --install") if package.native.need_autoreconf? + sh("./configure", + "PKG_CONFIG_PATH=#{pkg_config_path}", + "--prefix=#{dist_dir}", + *package.native.configure_args) or exit(false) + common_make_args = [] + common_make_args << "GLIB_COMPILE_SCHEMAS=glib-compile-schemas" + build_make_args = common_make_args.dup + install_make_args = common_make_args.dup + if package.native.build_concurrently? + make_n_jobs = ENV["MAKE_N_JOBS"] + build_make_args << "-j#{make_n_jobs}" if make_n_jobs + end + sh("nice", "make", *build_make_args) or exit(false) + sh("make", "install", *install_make_args) or exit(false) + end + end + end + end + end + + def build_packages + @package.external_packages.select do |package| + package.native.build? + end + end + + def dist_dir + @package.native.absolute_binary_dir + end + + def pkg_config_path + dist_dir + "lib/pkgconfig" + end + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/package-task.rb b/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/package-task.rb new file mode 100644 index 0000000..5c97bcd --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/package-task.rb @@ -0,0 +1,248 @@ +# coding: utf-8 + +# Copyright(C) 2011 Ruby-GNOME2 Project. +# +# This program is licenced under the same license of Ruby-GNOME2. + +require "find" +require "pathname" + +require "rubygems" +require "rubygems/package_task" +require "rake/extensiontask" +require "gnome2/rake/package" +require "gnome2/rake/external-package" +require "gnome2/rake/source-download-task" +require "gnome2/rake/native-binary-build-task" +require "gnome2/rake/win32-binary-download-task" +require "gnome2/rake/win32-binary-build-task" + +module GNOME2 + module Rake + class PackageTask + include ::Rake::DSL + + attr_accessor :name, :summary, :description, :author, :email, :homepage, :required_ruby_version, :post_install_message + attr_reader :root_dir + def initialize + initialize_variables + initialize_configurations + file, line, method = caller[1].scan(/^(.*):(\d+)(?::.*`(.*)')?\Z/).first + @package = Package.new(File.dirname(file)) + @packages = FileList["#{@package.root_dir.parent}/*"].map{|f| File.directory?(f) ? File.basename(f) : nil}.compact + @name = @package.name + @cross_compiling_hooks = [] + yield(self) if block_given? + end + + def cross_compiling(&block) + @cross_compiling_hooks << block + end + + def define + task :default => :build + define_spec + define_source_tasks + define_native_tasks + define_win32_tasks + define_package_tasks + end + + # Deprecated. Use #define instead. + def define_tasks + define + end + + def ruby_gnome2_package?(name) + @packages.include?(name) + end + + def dependency + @dependency_configuration + end + + def package + @package + end + + def windows + @package.windows + end + + # For backward compatibility + def win32 + windows + end + + def native + @package.native + end + + def version + ENV["VERSION"] || guess_version + end + + def guess_version + versions = {} + File.open("#{@package.glib2_root_dir}/ext/glib2/rbglib.h") do |rbglib_h| + rbglib_h.each_line do |line| + if /#define\s+RBGLIB_([A-Z]+)_VERSION\s+(\d+)/ =~ line + versions[$1.downcase] = $2.to_i + end + end + end + ["major", "minor", "micro"].collect {|type| versions[type]}.compact.join(".") + end + + def external_packages=(packages) + @package.external_packages = packages + end + + private + def initialize_variables + @summary = "" + @description = "" + @author = "The Ruby-GNOME2 Project Team" + @email = "ruby-gnome2-devel-en@lists.sourceforge.net" + @homepage = "http://ruby-gnome2.sourceforge.jp/" + @external_packages = [] + end + + def initialize_configurations + @dependency_configuration = DependencyConfiguration.new(self) + end + + def define_spec + @spec = Gem::Specification.new do |s| + s.name = @name + s.summary = @summary + s.description = @description + s.author = @author + s.email = @email + s.homepage = @homepage + s.version = version + extensions = FileList["ext/#{@name}/extconf.rb"] + extensions.existing! + s.extensions = extensions + s.require_paths = ["lib"] + files = FileList["ChangeLog", "README", + "Rakefile", "extconf.rb", + "lib/**/*.rb", + "{ext,sample,test,test-unit}/**/*"] + files.existing! + s.files = files + s.required_ruby_version = @required_ruby_version || ">= 1.8.5" + s.post_install_message = @post_install_message + @dependency_configuration.apply(s) + end + end + + def define_source_tasks + define_source_download_tasks + end + + def define_source_download_tasks + task = SourceDownloadTask.new(@package) + task.define + end + + def define_native_tasks + define_native_build_tasks + end + + def define_native_build_tasks + task = NativeBinaryBuildTask.new(@package) + task.define + end + + def define_win32_tasks + define_win32_extension_task + define_win32_download_task + define_win32_build_task + end + + def so_base_name + @name.gsub(/-/, "_") + end + + def define_win32_extension_task + ::Rake::ExtensionTask.new(so_base_name, @spec) do |ext| + ext.ext_dir = "ext/#{@name}" + ext.cross_compile = true + ext.cross_compiling do |spec| + if /mingw|mswin/ =~ spec.platform.to_s + win32_binary_dir = @package.windows.relative_binary_dir + win32_files = [] + if win32_binary_dir.exist? + Find.find(win32_binary_dir.to_s) do |file| + next if /\.zip\z/ =~ file + win32_files << file + end + end + spec.files += win32_files + end + @cross_compiling_hooks.each do |hook| + hook.call(spec) + end + end + end + + def define_win32_download_task + GNOME2Win32BinaryDownloadTask.new(@package) + end + + def define_win32_build_task + GNOME2Win32BinaryBuildTask.new(@package) + end + end + + def define_package_tasks + Gem::PackageTask.new(@spec) do |pkg| + end + end + + class DependencyConfiguration + attr_accessor :platform, :ruby + def initialize(package) + @package = package + @platform = Gem::Platform::RUBY + @gem_configuration = GemConfiguration.new(@package) + end + + def gem + @gem_configuration + end + + def apply(spec) + spec.platform = @platform + @gem_configuration.apply(spec) + end + + class GemConfiguration + attr_accessor :runtime, :development + def initialize(package) + @package = package + @runtime = [] + @development = [] + end + + def apply(spec) + @runtime.each do |dependency| + spec.add_runtime_dependency(*append_version(dependency)) + end + + @development.each do |dependency| + spec.add_development_dependency(*append_version(dependency)) + end + end + + def append_version(dependency) + name, *ver = dependency.is_a?(Array) ? dependency : [dependency] + ver << "= #{@package.version}" if @package.ruby_gnome2_package?(name) + [name, *ver] + end + end + end + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/package.rb b/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/package.rb new file mode 100644 index 0000000..9c94e61 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/package.rb @@ -0,0 +1,122 @@ +# -*- ruby -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "pathname" + +module GNOME2 + module Rake + class Package + attr_reader :name + attr_reader :root_dir + attr_reader :windows + attr_reader :native + attr_writer :external_packages + def initialize(root_dir) + @root_dir = Pathname.new(root_dir).expand_path + @name = @root_dir.basename.to_s + @windows = WindowsConfiguration.new + @native = NativeConfiguration.new + @external_packages = [] + end + + def project_root_dir + @root_dir.parent + end + + def glib2_root_dir + project_root_dir + "glib2" + end + + def tmp_dir + @root_dir + "tmp" + end + + def download_dir + tmp_dir + "download" + end + + def patches_dir + @root_dir + "patches" + end + + def external_packages + @external_packages.collect do |package| + ExternalPackage.new(package) + end + end + + class WindowsConfiguration < Struct.new(:packages, + :dependencies, + :build_dependencies, + :gobject_introspection_dependencies, + :build_packages, + :build_host) + + attr_reader :relative_binary_dir, :absolute_binary_dir + def initialize + super + @relative_binary_dir = Pathname.new("vendor/local") + @absolute_binary_dir = @relative_binary_dir.expand_path + end + + def packages + super || [] + end + + def dependencies + super || [] + end + + def build_dependencies + super || [] + end + + def gobject_introspection_dependencies + super || [] + end + + def build_packages + (super || []).collect do |package| + package = package.dup + package[:windows] = { + :include_paths => package.delete(:include_paths), + :library_paths => package.delete(:library_paths), + :configure_args => package.delete(:configure_args), + :patches => package.delete(:patches), + :need_autogen => package.delete(:need_autogen), + :need_autoreconf => package.delete(:need_autoreconf), + } + ExternalPackage.new(package) + end + end + + def build_host + super || "i686-w64-mingw32" + end + end + + class NativeConfiguration + attr_reader :relative_binary_dir, :absolute_binary_dir + def initialize + @relative_binary_dir = Pathname.new("tmp/native/local") + @absolute_binary_dir = @relative_binary_dir.expand_path + end + end + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/source-download-task.rb b/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/source-download-task.rb new file mode 100644 index 0000000..3d08881 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/source-download-task.rb @@ -0,0 +1,81 @@ +# -*- ruby -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "open-uri" +require "pathname" + +require "rake" + +module GNOME2 + module Rake + class SourceDownloadTask + include ::Rake::DSL + + def initialize(package) + @package = package + end + + def define + namespace :source do + namespace :downloader do + task :before + define_download_tasks + download_tasks = @package.external_packages.collect do |package| + "source:downloader:download:#{package.name}" + end + task :download => download_tasks + task :after + end + + desc "Dowanload sources" + task :download => [ + "source:downloader:before", + "source:downloader:download", + "source:downloader:after", + ] + end + end + + def define_download_tasks + namespace :download do + @package.external_packages.each do |package| + download_dir = @package.download_dir + tar_full_path = download_dir + package.archive_base_name + + task :before + task :after + desc "Download #{package.label} into #{download_dir}." + task package[:name] => [:before, tar_full_path.to_s, :after] + + directory_path = tar_full_path.dirname + directory directory_path.to_s + file tar_full_path.to_s => directory_path.to_s do + archive_url = package.archive_url + rake_output_message "Downloading... #{archive_url}" + open(archive_url) do |downloaded_tar| + tar_full_path.open("wb") do |tar_file| + tar_file.print(downloaded_tar.read) + end + end + end + end + end + end + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/win32-binary-build-task.rb b/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/win32-binary-build-task.rb new file mode 100644 index 0000000..1cfe08c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/win32-binary-build-task.rb @@ -0,0 +1,223 @@ +# Copyright(C) 2012 Ruby-GNOME2 Project. +# +# This program is licenced under the same license of Ruby-GNOME2. + +require "open-uri" +require "pathname" + +class GNOME2Win32BinaryBuildTask + include Rake::DSL + + def initialize(package) + @package = package + define + end + + private + def define + namespace :win32 do + namespace :builder do + task :before + define_build_tasks + build_tasks = build_packages.collect do |package| + "win32:builder:build:#{package.name}" + end + task :build => build_tasks + task :after + end + desc "Build Windows binaries" + task :build => ["win32:builder:before", + "win32:builder:build", + "win32:builder:after"] + end + end + + def define_build_tasks + namespace :build do + prepare_task_names = [] + namespace :prepare do + prepare_task_names << "pkg_config" + task :pkg_config do + depended_packages = @package.windows.build_dependencies + use_packages = [@package.name] + depended_packages + pkg_config_path = use_packages.collect do |package| + "../#{package}/#{@package.windows.relative_binary_dir}/lib/pkgconfig" + end + ENV["PKG_CONFIG_PATH"] = pkg_config_path.collect do |path| + File.expand_path(path) + end.join(":") + ENV["PKG_CONFIG_LIBDIR"] = rcairo_win32_pkgconfig_path + end + end + + full_prepare_task_names = prepare_task_names.collect do |name| + "win32:builder:build:prepare:#{name}" + end + task :prepare => full_prepare_task_names + + build_packages.each do |package| + namespace package.name do + task :before + download_task = "source:downloader:download:#{package.name}" + task :build => [:prepare, download_task] do + build_package_task_body(package) + end + task :after + end + + prefix = "win32:builder:build:#{package.name}" + desc "Build #{package.label} and install it into #{dist_dir}." + task package.name => [ + "#{prefix}:before", + "#{prefix}:build", + "#{prefix}:after", + ] + end + end + end + + def build_package_task_body(package) + package_tmp_dir = @package.tmp_dir + package.name + rm_rf(package_tmp_dir) + mkdir_p(package_tmp_dir) + + tar_full_path = @package.download_dir + package.archive_base_name + Dir.chdir(package_tmp_dir.to_s) do + sh("tar", "xf", tar_full_path.to_s) + end + + Dir.chdir((package_tmp_dir + package.base_name).to_s) do + package.windows.patches.each do |patch| + sh("patch -p1 < #{@package.patches_dir}/#{patch}") + end + sh("./autogen.sh") if package.windows.need_autogen? + sh("autoreconf --install") if package.windows.need_autoreconf? + cc_env = "CC=#{@package.windows.build_host}-gcc" + sh("./configure", + cc_env, + "CPPFLAGS=#{cppflags(package)}", + "LDFLAGS=#{ldflags(package)}", + "--prefix=#{dist_dir}", + "--host=#{@package.windows.build_host}", + *package.windows.configure_args) or exit(false) + common_make_args = [] + common_make_args << "GLIB_COMPILE_SCHEMAS=glib-compile-schemas" + if package.windows.use_cc_environment_variable? + common_make_args << cc_env + end + add_gobject_introspection_make_args(common_make_args) + build_make_args = common_make_args.dup + install_make_args = common_make_args.dup + if package.windows.build_concurrently? + make_n_jobs = ENV["MAKE_N_JOBS"] + build_make_args << "-j#{make_n_jobs}" if make_n_jobs + end + ENV["GREP_OPTIONS"] = "--text" + sh("nice", "make", *build_make_args) or exit(false) + sh("make", "install", *install_make_args) or exit(false) + + package_license_dir = license_dir + package.name + mkdir_p(package_license_dir) + package_license_files = ["AUTHORS", "COPYING", "COPYING.LIB"] + package_license_files = package_license_files.reject do |file| + not File.exist?(file) + end + cp(package_license_files, package_license_dir) + bundled_packages = package.bundled_packages + bundled_packages.each do |bundled_package| + bundled_package_license_dir = license_dir + bundled_package[:name] + mkdir_p(bundled_package_license_dir) + license_files = bundled_package[:license_files].collect do |file| + File.join(bundled_package[:path], file) + end + cp(license_files, bundled_package_license_dir) + end + end + end + + def build_packages + packages = @package.external_packages.select do |package| + package.windows.build? + end + # For backward compatibility + packages + @package.windows.build_packages + end + + def dist_dir + @package.windows.absolute_binary_dir + end + + def license_dir + dist_dir + "share" + "license" + end + + def glib2_include_path + "#{@package.glib2_root_dir}/vendor/local/include" + end + + def glib2_lib_path + "#{@package.glib2_root_dir}/vendor/local/lib" + end + + def rcairo_win32_dir + @package.project_root_dir.parent + "rcairo.win32" + end + + def rcairo_win32_pkgconfig_path + "#{rcairo_win32_dir}/vendor/local/lib/pkgconfig" + end + + def rcairo_win32_include_path + "#{rcairo_win32_dir}/vendor/local/include" + end + + def rcairo_win32_lib_path + "#{rcairo_win32_dir}/vendor/local/lib" + end + + def cppflags(package) + include_paths = package.windows.include_paths + if @package.windows.build_dependencies.include?("glib2") + include_paths += [glib2_include_path] + end + include_paths += [ + rcairo_win32_include_path, + dist_dir + 'include', + ] + cppflags = include_paths.collect do |path| + "-I#{path}" + end + cppflags.join(" ") + end + + def ldflags(package) + library_paths = package.windows.library_paths + if @package.windows.build_dependencies.include?("glib2") + library_paths += [glib2_lib_path] + end + library_paths += [ + rcairo_win32_lib_path, + dist_dir + 'lib', + ] + ldflags = library_paths.collect do |path| + "-L#{path}" + end + ldflags.join(" ") + end + + def add_gobject_introspection_make_args(common_make_args) + unless @package.windows.build_dependencies.include?("gobject-introspection") + return + end + + dependencies = [ + "gobject-introspection", + @package.name, + ] + dependencies += @package.windows.gobject_introspection_dependencies + data_dirs = dependencies.collect do |package| + "#{@package.project_root_dir}/#{package}/vendor/local/share" + end + common_make_args << "XDG_DATA_DIRS=#{data_dirs.join(File::PATH_SEPARATOR)}" + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/win32-binary-download-task.rb b/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/win32-binary-download-task.rb new file mode 100644 index 0000000..7509cd5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/lib/gnome2/rake/win32-binary-download-task.rb @@ -0,0 +1,175 @@ +# Copyright(C) 2010-2012 Ruby-GNOME2 Project. +# +# This program is licenced under the same license of Ruby-GNOME2. + +require 'open-uri' +require 'rubygems' +require 'mechanize' + +class GNOME2Win32BinaryDownloadTask + include Rake::DSL + + URL_BASE = "http://ftp.gnome.org/pub/gnome/binaries/win32" + def initialize(package) + @package = package + define + end + + private + def define + namespace :win32 do + namespace :downloader do + task :before + + download_tasks = [] + namespace :download do + directory dist_dir.to_s + task :prepare => [dist_dir.to_s] + + packages.each do |package| + desc "download #{package}" + task package => [:prepare] do + download_package(package) + end + download_tasks << package + end + + dependencies.each do |dependency| + name, version = dependency + desc "download #{name}" + task name => [:prepare] do + download_dependency(dependency) + end + download_tasks << name + end + end + + download_tasks = download_tasks.collect do |task| + "win32:downloader:download:#{task}" + end + desc "download Windows binaries into #{dist_dir}" + task :download => download_tasks + + task :after + end + desc "download Windows binaries" + task :download => ["win32:downloader:before", + "win32:downloader:download", + "win32:downloader:after"] + end + end + + def dist_dir + @package.windows.absolute_binary_dir + end + + def packages + @package.windows.packages + end + + def dependencies + @package.windows.dependencies + end + + def download_package(package) + version_page_url = "#{URL_BASE}/#{package}" + version_page = agent.get(version_page_url) + latest_version_link = version_page.links.sort_by do |link| + if /\A(\d+\.\d+)\/\z/ =~ link.href + $1.split(/\./).collect {|component| component.to_i} + else + [-1] + end + end.last + + escaped_package = Regexp.escape(package) + latest_version_page = latest_version_link.click + latest_version = latest_version_page.links.collect do |link| + case link.href + when /#{escaped_package}_([\d\.\-]+)_win32\.zip\z/, + /#{escaped_package}-([\d\.\-]+)-win32\.zip\z/, # old + /#{escaped_package}-([\d\.\-]+)\.zip\z/ # old + version = $1 + normalized_version = version.split(/[\.\-]/).collect do |component| + component.to_i + end + [normalized_version, version] + else + [[-1], nil] + end + end.sort_by do |normalized_version, version| + normalized_version + end.last[1] + + if latest_version.nil? + raise "can't find package: <#{package}>:<#{version_page_url}>" + end + escaped_latest_version = Regexp.escape(latest_version) + latest_version_page.links.each do |link| + case link.href + when /#{escaped_package}(?:-dev)?_#{escaped_latest_version}_win32\.zip\z/, + /#{escaped_package}(?:-dev)?-#{escaped_latest_version}-win32\.zip\z/, # old + /#{escaped_package}(?:-dev)?-#{escaped_latest_version}\.zip\z/ # old + click_zip_link(link) + end + end + end + + def download_dependency(dependency) + dependency_version = "any" + dependency_version_re = /[\d\.\-]+/ + if dependency.is_a?(Array) + dependency, dependency_version = dependency + dependency_version_re = /#{Regexp.escape(dependency_version)}/ + end + escaped_dependency = Regexp.escape(dependency) + dependencies_url = "#{URL_BASE}/dependencies" + dependencies_page = agent.get(dependencies_url) + latest_version = dependencies_page.links.collect do |link| + case link.href + when /\A#{escaped_dependency}_(#{dependency_version_re})_win32\.zip\z/ + version = $1 + [version.split(/[\.\-]/).collect {|component| component.to_i}, version] + else + [[-1], nil] + end + end.sort_by do |normalized_version, version| + normalized_version + end.last[1] + + if latest_version.nil? + message = "can't find dependency package: " + + "<#{dependency}>(#{dependency_version}):<#{dependencies_url}>" + raise message + end + escaped_latest_version = Regexp.escape(latest_version) + dependencies_page.links.each do |link| + case link.href + when /\A#{escaped_dependency}(?:-dev)?_#{escaped_latest_version}_win32\.zip\z/ + click_zip_link(link) + end + end + end + + private + def agent + @agent ||= Mechanize.new + end + + def click_zip_link(link) + zip = link.click + Dir.chdir(dist_dir) do + open(zip.filename, "wb") do |file| + file.print(zip.body) + end + system("unzip", "-o", zip.filename) + Dir.glob("lib/pkgconfig/*.pc") do |pc_path| + pc = File.read(pc_path) + pc = pc.gsub(/\Aprefix=.+$/) {"prefix=#{dist_dir}"} + File.open(pc_path, "w") do |pc_file| + pc_file.print(pc) + end + end + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/lib/mkmf-gnome2.rb b/lib/ruby-gtk2-2.0.2/glib2/lib/mkmf-gnome2.rb new file mode 100644 index 0000000..d9e97ca --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/lib/mkmf-gnome2.rb @@ -0,0 +1,566 @@ +# +# mkmf-gnome2.rb +# +# Extended mkmf for Ruby-GNOME2 and Ruby/GLib based libraries. +# +# Copyright(C) 2003-2011 Ruby-GNOME2 Project. +# +# This program is licenced under the same +# license of Ruby-GNOME2. +# + +require 'English' +require 'mkmf' +begin + require 'pkg-config' +rescue LoadError + require 'rubygems' + gem 'pkg-config' + require 'pkg-config' +end +require 'glib-mkenums' + +$CFLAGS += " #{ENV['CFLAGS']}" if ENV['CFLAGS'] + +def try_compiler_option(opt, &block) + checking_for "#{opt} option to compiler" do + $CFLAGS += " #{opt}" if try_compile '', opt, &block + end +end + +try_compiler_option '-Wall' +try_compiler_option '-Waggregate-return' +try_compiler_option '-Wcast-align' +# NOTE: Generates way too many false positives. +# try_compiler_option '-Wconversion' +try_compiler_option '-Wextra' +try_compiler_option '-Wformat=2' +try_compiler_option '-Winit-self' +# NOTE: This generates warnings for functions defined in ruby.h. +# try_compiler_option '-Winline' +try_compiler_option '-Wlarger-than-65500' +try_compiler_option '-Wmissing-declarations' +try_compiler_option '-Wmissing-format-attribute' +try_compiler_option '-Wmissing-include-dirs' +try_compiler_option '-Wmissing-noreturn' +try_compiler_option '-Wmissing-prototypes' +try_compiler_option '-Wnested-externs' +try_compiler_option '-Wold-style-definition' +try_compiler_option '-Wpacked' +try_compiler_option '-Wp,-D_FORTIFY_SOURCE=2' +try_compiler_option '-Wpointer-arith' +# NOTE: ruby.h and intern.h have too many of these. +# try_compiler_option '-Wredundant-decls' +# NOTE: Complains about index, for example. +# try_compiler_option '-Wshadow' +try_compiler_option '-Wswitch-default' +try_compiler_option '-Wswitch-enum' +try_compiler_option '-Wundef' +# NOTE: Incredible amounts of false positives. +#try_compiler_option '-Wunreachable-code' +try_compiler_option '-Wunsafe-loop-optimizations' +try_compiler_option '-Wwrite-strings' + +if /-Wl,--no-undefined/ =~ $LDFLAGS.to_s + $LDFLAGS.gsub!(/-Wl,--no-undefined/, '') +end + +include_path = nil +if ENV['GTK_BASEPATH'] and /cygwin/ !~ RUBY_PLATFORM + include_path = (ENV['GTK_BASEPATH'] + "\\INCLUDE").gsub("\\", "/") +# $hdrdir += " -I#{include_path} " + $CFLAGS += " -I#{include_path} " +end + +def setup_win32(target_name, base_dir=nil) + checking_for(checking_message("Win32 OS")) do + case RUBY_PLATFORM + when /cygwin|mingw|mswin/ + import_library_name = "libruby-#{target_name}.a" + $DLDFLAGS << " -Wl,--out-implib=#{import_library_name}" + $cleanfiles << import_library_name + base_dir ||= Pathname($0).dirname.parent.parent.expand_path + base_dir = Pathname(base_dir) if base_dir.is_a?(String) + binary_base_dir = base_dir + "vendor" + "local" + if binary_base_dir.exist? + $CFLAGS += " -I#{binary_base_dir}/include" + pkg_config_dir = binary_base_dir + "lib" + "pkgconfig" + PKGConfig.add_path(pkg_config_dir.to_s) + end + true + else + false + end + end +end + +def find_gem_spec(package) + begin + require 'rubygems' + if Gem::Specification.respond_to?(:find_by_name) + Gem::Specification.find_by_name(package) + else + Gem.source_index.find_name(package).last + end + rescue LoadError + nil + end +end + +#add_depend_package("glib2", "ext/glib2", "/...../ruby-gnome2") +def add_depend_package(target_name, target_srcdir, top_srcdir, options={}) + gem_spec = find_gem_spec(target_name) + if gem_spec + target_source_dir = File.join(gem_spec.full_gem_path, "ext/#{target_name}") + target_build_dir = target_source_dir + add_depend_package_path(target_name, + target_source_dir, + target_build_dir) + end + + [top_srcdir, + File.join(top_srcdir, target_name), + $configure_args['--topdir'], + File.join($configure_args['--topdir'], target_name)].each do |topdir| + topdir = File.expand_path(topdir) + target_source_dir_full_path = File.join(topdir, target_srcdir) + + top_build_dir = options[:top_build_dir] || topdir + target_build_dir = options[:target_build_dir] || target_srcdir + target_build_dir_full_path = File.join(top_build_dir, target_build_dir) + unless File.exist?(target_build_dir_full_path) + target_build_dir_full_path = File.join(top_build_dir, target_srcdir) + end + unless File.exist?(target_build_dir_full_path) + target_build_dir_full_path = File.join(topdir, target_build_dir) + end + unless File.exist?(target_build_dir_full_path) + target_build_dir_full_path = File.join(topdir, target_srcdir) + end + add_depend_package_path(target_name, + target_source_dir_full_path, + target_build_dir_full_path) + end +end + +def add_depend_package_path(target_name, target_source_dir, target_build_dir) + if File.exist?(target_source_dir) + $INCFLAGS = "-I#{target_source_dir} #{$INCFLAGS}" + end + + return unless File.exist?(target_build_dir) + if target_source_dir != target_build_dir + $INCFLAGS = "-I#{target_build_dir} #{$INCFLAGS}" + end + + case RUBY_PLATFORM + when /cygwin|mingw|mswin/ + library_base_name = "ruby-#{target_name.gsub(/-/, '_')}" + case RUBY_PLATFORM + when /cygwin|mingw/ + $LDFLAGS << " -L#{target_build_dir}" + $libs << " -l#{library_base_name}" + when /mswin/ + $DLDFLAGS << " /libpath:#{target_build_dir}" + $libs << " lib#{library_base_name}.lib" + end + target_base_dir = Pathname.new(target_source_dir).parent.parent + target_binary_base_dir = target_base_dir + "vendor" + "local" + if target_binary_base_dir.exist? + $INCFLAGS = "-I#{target_binary_base_dir}/include #{$INCFLAGS}" + target_pkg_config_dir = target_binary_base_dir + "lib" + "pkgconfig" + PKGConfig.add_path(target_pkg_config_dir.to_s) + end + end +end + +def add_distcleanfile(file) + $distcleanfiles ||= [] + $distcleanfiles << file +end + +def create_pkg_config_file(package_name, c_package, + version=nil, pc_file_name=nil) + pc_file_name ||= "#{package_name.downcase.sub(/\//, '-')}.pc" + version ||= ruby_gnome2_version || PKGConfig.modversion(c_package) + + puts "creating #{pc_file_name}" + + File.open(pc_file_name, 'w') do |pc_file| + if package_name.nil? + c_module_name = PKGConfig.name(c_package) + package_name = "Ruby/#{c_module_name}" if c_module_name + end + pc_file.puts("Name: #{package_name}") if package_name + + description = PKGConfig.description(c_package) + pc_file.puts("Description: Ruby bindings for #{description}") if description + pc_file.printf("Version: #{version}") + end + + add_distcleanfile(pc_file_name) +end + +def ruby_gnome2_version(glib_source_directory=nil) + glib_source_directory ||= File.join(File.dirname(__FILE__), "..", + "ext", "glib2") + rbglib_h = File.join(glib_source_directory, "rbglib.h") + return nil unless File.exist?(rbglib_h) + + version = nil + File.open(rbglib_h) do |h_file| + version_info = {} + h_file.each_line do |line| + case line + when /\A#define RBGLIB_(MAJOR|MINOR|MICRO)_VERSION\s+(\d+)/ + version_info[$1] = $2 + end + end + version_info = [version_info["MAJOR"], + version_info["MINOR"], + version_info["MICRO"]].compact + version = version_info.join(".") if version_info.size == 3 + end + + version +end + +def ensure_objs + return unless $objs.nil? + + source_dir = '$(srcdir)' + RbConfig.expand(source_dir) + + pattern = "*.{#{SRC_EXT.join(',')}}" + srcs = Dir[File.join(source_dir, pattern)] + srcs |= Dir[File.join(".", pattern)] + $objs = srcs.collect do |f| + File.basename(f, ".*") + ".o" + end.uniq +end + +def create_makefile_at_srcdir(pkg_name, srcdir, defs = nil) + base_dir = File.basename(Dir.pwd) + last_common_index = srcdir.rindex(base_dir) + if last_common_index + builddir = srcdir[(last_common_index + base_dir.size + 1)..-1] + end + builddir ||= "." + FileUtils.mkdir_p(builddir) + + Dir.chdir(builddir) do + yield if block_given? + + $defs << defs if defs + ensure_objs + create_makefile(pkg_name, srcdir) + end +end + +def run_make_in_sub_dirs_command(command, sub_dirs) + if /mswin/ =~ RUBY_PLATFORM + sub_dirs.collect do |dir| + <<-EOM.chmop + @cd #{dir} + @nmake -nologo DESTDIR=$(DESTDIR) #{command} + @cd .. + EOM + end.join("\n") + else + sub_dirs.collect do |dir| + "\t@cd #{dir}; $(MAKE) #{command}" + end.join("\n") + end +end + +def create_top_makefile(sub_dirs=["src"]) + File.open("Makefile", "w") do |makefile| + makefile.print(<<-EOM) +all: +#{run_make_in_sub_dirs_command("all", sub_dirs)} + +install: +#{run_make_in_sub_dirs_command("install", sub_dirs)} + +site-install: +#{run_make_in_sub_dirs_command("site-install", sub_dirs)} + +clean: +#{run_make_in_sub_dirs_command("clean", sub_dirs)} + EOM + + if /mswin/ =~ RUBY_PLATFORM + makefile.print(<<-EOM) + @if exist extconf.h del extconf.h + @if exist conftest.* del conftest.* + @if exist *.lib del *.lib + @if exist *~ del *~ + @if exist mkmf.log del mkmf.log + EOM + else + makefile.print(<<-EOM) + +distclean: clean +#{run_make_in_sub_dirs_command("distclean", sub_dirs)} + @rm -f Makefile extconf.h conftest.* + @rm -f core *~ mkmf.log + EOM + end + end +end + +# This is used for the library which doesn't support version info. +def make_version_header(app_name, pkgname, dir = "src") + version = PKGConfig.modversion(pkgname).split(/\./) + (0..2).each do |v| + version[v] = "0" unless version[v] + if /\A(\d+)/ =~ version[v] + number = $1 + tag = $POSTMATCH + unless tag.empty? + version[v] = number + version[3] = tag + end + end + end + filename = "rb#{app_name.downcase}version.h" + + puts "creating #{filename}" + + add_distcleanfile(filename) + + FileUtils.mkdir_p(dir) + out = File.open(File.join(dir, filename), "w") + + version_definitions = [] + ["MAJOR", "MINOR", "MICRO", "TAG"].each_with_index do |type, i| + _version = version[i] + next if _version.nil? + version_definitions << "#define #{app_name}_#{type}_VERSION (#{_version})" + end + out.print %Q[/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/************************************************ + + #{filename} - + + This file was generated by mkmf-gnome2.rb. + +************************************************/ + +#ifndef __RB#{app_name}_VERSION_H__ +#define __RB#{app_name}_VERSION_H__ + +#{version_definitions.join("\n")} + +#define #{app_name}_CHECK_VERSION(major,minor,micro) \\ + (#{app_name}_MAJOR_VERSION > (major) || \\ + (#{app_name}_MAJOR_VERSION == (major) && #{app_name}_MINOR_VERSION > (minor)) || \\ + (#{app_name}_MAJOR_VERSION == (major) && #{app_name}_MINOR_VERSION == (minor) && \\ + #{app_name}_MICRO_VERSION >= (micro))) + + +#endif /* __RB#{app_name}_VERSION_H__ */ +] + out.close +end + +def check_ruby_func + #Other options + ruby_header = "ruby.h" + have_func("rb_define_alloc_func", ruby_header) # for ruby-1.8 + have_func("rb_block_proc", ruby_header) # for ruby-1.8 + + STDOUT.print("checking for new allocation framework... ") # for ruby-1.7 + if Object.respond_to? :allocate + STDOUT.print "yes\n" + $defs << "-DHAVE_OBJECT_ALLOCATE" + else + STDOUT.print "no\n" + end + + STDOUT.print("checking for attribute assignment... ") # for ruby-1.7 + STDOUT.flush + if defined? try_compile and try_compile < 9 + mainloop.quit + false # the source is removed. + else + true # continue ... + end +} + +j = 0 +GLib::Idle.add { + j += 1 + p "timeout2-#{i}" + if j > 9 + mainloop.quit + false # the source is removed. + else + true # continue ... + end +} + +mainloop.run + +p "quit..." diff --git a/lib/ruby-gtk2-2.0.2/glib2/sample/iochannel.rb b/lib/ruby-gtk2-2.0.2/glib2/sample/iochannel.rb new file mode 100644 index 0000000..3a793b3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/sample/iochannel.rb @@ -0,0 +1,44 @@ +=begin + iochannel.rb - Sample for GLib::IOChannel. + + Copyright (C) 2005 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: iochannel.rb,v 1.3 2006/12/20 18:08:20 mutoh Exp $ +=end + +require 'glib2' + +path = ARGV[0] || __FILE__ + +GLib::IOChannel.open(path) {|io| + puts io.read +} + +stdout = GLib::IOChannel.new(path, "r") +stdout.add_watch(GLib::IOChannel::IN + ) {|io, condition| + puts "condition = #{condition}" + false +} + +context = GLib::MainContext.default +mainloop = GLib::MainLoop.new(context, true) + + +Thread.new{ + num = 0 + loop { + num += 1 + str = stdout.gets + puts "line #{num}: #{str}" + unless str + mainloop.quit + break + end + } +} + +mainloop.run + +stdout.close diff --git a/lib/ruby-gtk2-2.0.2/glib2/sample/keyfile.rb b/lib/ruby-gtk2-2.0.2/glib2/sample/keyfile.rb new file mode 100644 index 0000000..d87badf --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/sample/keyfile.rb @@ -0,0 +1,62 @@ +=begin + keyfile.rb - Sample for GLib::KeyFile + + Copyright (C) 2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: keyfile.rb,v 1.2 2006/12/23 17:43:03 mutoh Exp $ +=end + +require 'glib2' + +$KCODE = "U" + +# +# Create a GLib::KeyFile +# +kf = GLib::KeyFile.new +kf.set_value("Group 1", "value", "Hello World") +kf.set_comment("Group 1", nil, "This file is generated by keyfile.rb") +kf.set_string("Group 1", "string", "Hello World\nRuby-GNOME2") +kf.set_locale_string("Group 1", "locale_string", "ja", "こんにちわ世界") +kf.set_locale_string("Group 1", "locale_string", "en", "Hello World") +kf.set_boolean("Group 1", "boolean", true) +kf.set_integer("Group 1", "integer", 1) +kf.set_double("Group 1", "double", 1.0) +kf.set_string_list("Group 2", "string_list", ["foo", "bar"]) +kf.set_locale_string_list("Group 2", "locale_string_list", "ja", ["こんにちわ", "世界"]) +kf.set_locale_string_list("Group 2", "locale_string_list", "en", ["Hellow", "World"]) +kf.set_boolean_list("Group 2", "boolean_list", [true, false]) +kf.set_integer_list("Group 2", "integer_list", [1, 2, 3]) +kf.set_double_list("Group 2", "double_list", [1.2, 1.3, 1.45]) +kf.set_comment("Group 2", "string_list", "comment of string_list") + +# Save as "keyfile.ini" +File.open("keyfile.ini", "w") do |out| + out.write kf.to_data +end + +#kf.remove_comment("Group 2", "string_list") +#kf.remove_key("Group 2", "string_list") +#kf.remove_group("Group 2") + +# +# Load from "keyfile.ini" +# +kf2 = GLib::KeyFile.new +kf2.load_from_file("keyfile.ini") + +puts "Group 1: value = #{kf2.get_value("Group 1", "value")}" +puts "Group 1: string = #{kf2.get_string("Group 1", "string")}" +puts "Group 1: locale_string[ja] = #{kf2.get_locale_string("Group 1", "locale_string", "ja")}" +puts "Group 1: locale_string[en] = #{kf2.get_locale_string("Group 1", "locale_string", "en")}" +puts "Group 1: boolean = #{kf2.get_boolean("Group 1", "boolean")}" +puts "Group 1: integer = #{kf2.get_integer("Group 1", "integer")}" +puts "Group 1: double = #{kf2.get_double("Group 1", "double")}" +puts "Group 2: string_list = #{kf2.get_string_list("Group 2", "string_list").inspect}" +puts "Group 2: locale_string_list[ja] = #{kf2.get_locale_string_list("Group 2", "locale_string_list", "ja").inspect}" +puts "Group 2: locale_string_list[en] = #{kf2.get_locale_string_list("Group 2", "locale_string_list", "en").inspect}" +puts "Group 2: boolean_list = #{kf2.get_boolean_list("Group 2", "boolean_list").inspect}" +puts "Group 2: integer_list = #{kf2.get_integer_list("Group 2", "integer_list").inspect}" +puts "Group 2: double_list = #{kf2.get_double_list("Group 2", "double_list").inspect}" +puts "Group 2: comment = #{kf2.get_comment("Group 2", "string_list")}" diff --git a/lib/ruby-gtk2-2.0.2/glib2/sample/shell.rb b/lib/ruby-gtk2-2.0.2/glib2/sample/shell.rb new file mode 100644 index 0000000..9ec9b1b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/sample/shell.rb @@ -0,0 +1,36 @@ +=begin + shell.rb - Sample for GLib::Shell + + Copyright (C) 2005 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: shell.rb,v 1.1 2005/10/14 19:10:07 mutoh Exp $ +=end + +require 'glib2' + +cmd = "ls *.c *.o" + +p GLib::Shell.parse(cmd) + +puts quote = GLib::Shell.quote(cmd) +puts GLib::Shell.unquote(quote) + +puts "----" + +#Samples to catch an Exception +begin + GLib::Shell.parse('foooo "bar') +rescue GLib::ShellError => e + puts "domain = #{e.domain}" + puts "code = #{e.code}" + puts "message = #{e.message}" +end + +begin + GLib::Shell.unquote('foooo "bar') +rescue GLib::ShellError => e + puts "domain = #{e.domain}" + puts "code = #{e.code}" + puts "message = #{e.message}" +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/sample/spawn.rb b/lib/ruby-gtk2-2.0.2/glib2/sample/spawn.rb new file mode 100644 index 0000000..bec35f2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/sample/spawn.rb @@ -0,0 +1,25 @@ +=begin + spawn.rb - Sample for GLib::Spawn + + Copyright (C) 2005 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Date: 2005/10/14 19:10:07 $ + $Id: spawn.rb,v 1.3 2005/10/14 19:10:07 mutoh Exp $ +=end + +require 'glib2' + +p GLib::Spawn.command_line_sync("ls") + +puts "---" + +#Here is an example to catch GLib::SpawnError. +begin +p GLib::Spawn.command_line_sync("nonexist_app") +rescue => e + puts "class = #{e.class}" + puts "domain = #{e.domain}" + puts "code = #{e.code}" + puts "message = #{e.message}" +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/sample/timeout.rb b/lib/ruby-gtk2-2.0.2/glib2/sample/timeout.rb new file mode 100644 index 0000000..10abc43 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/sample/timeout.rb @@ -0,0 +1,28 @@ +=begin + timeout.rb - Sample for GLib::Timeout, GLib::MainLoop. + + Copyright (C) 2005 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: timeout.rb,v 1.2 2005/07/14 17:05:22 mutoh Exp $ +=end + +require 'glib2' + +mainloop = GLib::MainLoop.new(nil, true) + +i = 0 +GLib::Timeout.add(1000) { + i += 1 + p "timeout-#{i}" + if i > 9 + mainloop.quit + false # the source is removed. + else + true # continue ... + end +} + +mainloop.run + +p "quit..." diff --git a/lib/ruby-gtk2-2.0.2/glib2/sample/timeout2.rb b/lib/ruby-gtk2-2.0.2/glib2/sample/timeout2.rb new file mode 100644 index 0000000..85ec098 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/sample/timeout2.rb @@ -0,0 +1,35 @@ +=begin + timeout2.rb - Sample for GLib::Timeout, GLib::MainLoop. + + Copyright (C) 2005 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Date: 2005/03/13 15:43:32 $ + $Id: timeout2.rb,v 1.2 2005/03/13 15:43:32 mutoh Exp $ +=end + +require 'glib2' + +context = GLib::MainContext.new + +mainloop = GLib::MainLoop.new(context, true) + +source = GLib::Timeout.source_new(1000) + +i = 0 +source.set_callback { + i += 1 + p "timeout2-#{i}" + if i > 9 + mainloop.quit + false # the source is removed. + else + true # continue ... + end + +} +source.attach(context) + +mainloop.run + +p "quit..." diff --git a/lib/ruby-gtk2-2.0.2/glib2/sample/timer.rb b/lib/ruby-gtk2-2.0.2/glib2/sample/timer.rb new file mode 100644 index 0000000..b811690 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/sample/timer.rb @@ -0,0 +1,40 @@ +=begin + timer.rb - Sample for GLib::Timer + + Copyright (C) 2005 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: timer.rb,v 1.1 2005/10/14 19:48:41 mutoh Exp $ +=end + +require 'glib2' + +timer = GLib::Timer.new + +timer.start +puts "start (status = running) : #{timer.elapsed}" + +sleep(3) + +puts "after 3 sec (status = running) : #{timer.elapsed}" + +sleep(3) + +puts "after 3 sec (status = running) : #{timer.elapsed}" +timer.stop +puts "stop (status = stoped) : #{timer.elapsed}" + +sleep(3) +puts "after 3 sec (status = stoped) : #{timer.elapsed}" + +timer.continue +puts "continue (status = running) : #{timer.elapsed}" +sleep(3) +puts "after 3 sec (status = running) : #{timer.elapsed}" + +timer.reset +puts "reset (status = running) : #{timer.elapsed}" +sleep(3) +puts "after 3 sec (status = running) : #{timer.elapsed}" + + diff --git a/lib/ruby-gtk2-2.0.2/glib2/sample/type-register.rb b/lib/ruby-gtk2-2.0.2/glib2/sample/type-register.rb new file mode 100755 index 0000000..1896eb5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/sample/type-register.rb @@ -0,0 +1,103 @@ +=begin + type-register.rb - Sample for GLib::Object + + You also need Ruby/GTK. + + Copyright (C) 2004-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Date: 2006/06/17 14:31:22 $ + $Id: type-register.rb,v 1.9 2006/06/17 14:31:22 mutoh Exp $ +=end + +require 'gtk2' + +class MyButton < Gtk::Button + type_register + + def initialize(label = nil) + # XXX: + # When type_register() is used. + # super is equivalent to GLib::Object#initialize. + super("label" => label) + @fuga = 0 + end + + # override existing default handler of "clicked" signal. + def signal_do_clicked(*args) + puts "MyButton#signal_do_clicked enter" + #p caller + super + puts "MyButton#signal_do_clicked leave" + end + + # define new signal "hoge" + signal_new("hoge", # name + GLib::Signal::RUN_FIRST, # flags + nil, # accumulator (XXX: not supported yet) + nil, # return type (void == nil) + Integer, Integer # parameter types + ) + # define default handler of "hoge" signal + def signal_do_hoge(a, b) + puts "MyButton#signal_do_hoge enter" + #p caller + puts "MyButton#signal_do_hoge leave" + end + + # define new property "fuga" + install_property(GLib::Param::Int.new("fuga", # name + "Fuga", # nick + "fuga hoge", # blurb + 0, # min + 10000, # max + 0, # default + GLib::Param::READABLE | + GLib::Param::WRITABLE)) + # implementation of the property "fuga" + def fuga + puts "MyButton#fuga is called" + @fuga + end + def fuga=(arg) + puts "MyButton#fuga= is called" + @fuga = arg + notify("fuga") + end +end + +class MyButton2 < MyButton + type_register("MyButton2") + + # override default handler of "clicked" signal + def signal_do_clicked(*args) + puts "MyButton2#signal_do_clicked enter" + super(*args) + puts "MyButton2#signal_do_clicked leave" + end + + # override default handler of "hoge" signal + def signal_do_hoge(a, b) + puts "MyButton2#signal_do_hoge enter" + puts "a, b = #{a}, #{b}" + super + puts "MyButton2#signal_do_hoge leave" + end +end + +b = MyButton2.new("Hello") +p b +p b.label +p b.gtype +b.clicked +b.signal_emit("hoge", 1, 2) + +b.signal_connect("notify"){|obj, pspec| + puts "#{b} notify #{pspec}" +} + +p b.get_property("fuga") +b.set_property("fuga", 1) +p b.get_property("fuga") + +p MyButton2.ancestors diff --git a/lib/ruby-gtk2-2.0.2/glib2/sample/type-register2.rb b/lib/ruby-gtk2-2.0.2/glib2/sample/type-register2.rb new file mode 100755 index 0000000..02c5a7b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/sample/type-register2.rb @@ -0,0 +1,104 @@ +=begin + type-register2.rb - Sample for GLib::Object + + You also need Ruby/GTK. + + Copyright (C) 2004-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Date: 2006/06/17 14:31:22 $ + $Id: type-register2.rb,v 1.3 2006/06/17 14:31:22 mutoh Exp $ +=end + +require 'gtk2' + +class MyButton < Gtk::Button + type_register + + def initialize(label = nil) + # XXX: + # When type_register() is used. + # super is equivalent to GLib::Object#initialize. + super("label" => label) + @fuga = 0 + end + + # override existing default handler of "clicked" signal. + def signal_do_clicked(*args) + puts "MyButton#signal_do_clicked enter" + #p caller + super + puts "MyButton#signal_do_clicked leave" + end + + # define new signal "hoge" + signal_new("hoge", # name + GLib::Signal::RUN_FIRST, # flags + nil, # accumulator (XXX: not supported yet) + GLib::Type["void"], # return type + GLib::Type["gint"], GLib::Type["gint"] # parameter types + ) + # define default handler of "hoge" signal + def signal_do_hoge(a, b) + puts "MyButton#signal_do_hoge enter" + #p caller + puts "MyButton#signal_do_hoge leave" + end + + # define new property "fuga" + install_property(GLib::Param::Int.new("fuga", # name + "Fuga", # nick + "fuga hoge", # blurb + 0, # min + 10000, # max + 0, # default + GLib::Param::READABLE | + GLib::Param::WRITABLE)) + # implementation of the property "fuga" + def fuga + puts "MyButton#fuga is called" + @fuga + end + def fuga=(arg) + puts "MyButton#fuga= is called" + @fuga = arg + notify("fuga") + end +end + +class MyButton2 < MyButton + type_register("MyButton2") + + # override default handler of "clicked" signal + def signal_do_clicked(*args) + puts "MyButton2#signal_do_clicked enter" + super(*args) + puts "MyButton2#signal_do_clicked leave" + end + + # override default handler of "hoge" signal + def signal_do_hoge(a, b) + puts "MyButton2#signal_do_hoge enter" + puts "a, b = #{a}, #{b}" + #p caller + super + puts "MyButton2#signal_do_hoge leave" + end +end + +b = MyButton2.new("Hello") +p b +p b.label +p b.gtype +b.clicked +b.signal_emit("hoge", 1, 2) + +b.signal_connect("notify"){|obj, pspec| + puts "#{b} notify #{pspec}" +} + +p b.get_property("fuga") +b.set_property("fuga", 1) +p b.get_property("fuga") + +p MyButton2.ancestors diff --git a/lib/ruby-gtk2-2.0.2/glib2/sample/utils.rb b/lib/ruby-gtk2-2.0.2/glib2/sample/utils.rb new file mode 100644 index 0000000..c9ad4ca --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/sample/utils.rb @@ -0,0 +1,54 @@ +=begin + utils.rb - Sample for GLib module function produced by rbglib_utils.c + + Copyright (C) 2004 Masao Mutoh + This program is licenced under the same licence as Ruby-GNOME2. + + $Date: 2004/10/21 15:50:21 $ + $Id: utils.rb,v 1.2 2004/10/21 15:50:21 mutoh Exp $ +=end + +require 'glib2' + +if GLib.check_version?(2, 2, 0) + GLib.application_name = "application name" + puts "GLib.application_name = #{GLib.application_name}" +end + +GLib.prgname = "program name" +puts "GLib.prgname = #{GLib.prgname}" + +puts "GLib.getenv('HOME') = #{GLib.getenv('HOME')}" +if GLib.check_version?(2, 4, 0) + GLib.setenv("FOO", "foo") + puts "GLib.getenv('FOO') = #{GLib.getenv('FOO')}" + GLib.unsetenv("FOO") + puts "GLib.getenv('FOO') = #{GLib.getenv('FOO')}" +end + +puts "GLib.user_name = #{GLib.user_name}" +puts "GLib.real_name = #{GLib.real_name}" +puts "GLib.home_dir = #{GLib.home_dir}" +puts "GLib.tmp_dir = #{GLib.tmp_dir}" +puts "GLib.current_dir = #{GLib.current_dir}" +puts "GLib.path_is_absolute?('./') = #{GLib.path_is_absolute?("./")}" +puts "GLib.path_skip_root('/usr/local/bin/ruby') = #{GLib.path_skip_root('/usr/local/bin/ruby')}" +puts "GLib.path_get_basename(GLib.home_dir) = #{GLib.path_get_basename(GLib.home_dir)}" +puts "GLib.path_get_dirname(GLib.home_dir) = #{GLib.path_get_dirname(GLib.home_dir)}" +puts "GLib.find_program_in_path(GLib.prgname) = #{GLib.find_program_in_path(GLib.prgname)}" +puts "GLib.bit_nth_lsf(3, 1) = #{GLib.bit_nth_lsf(3, 1)}" +puts "GLib.bit_nth_msf(3, 1) = #{GLib.bit_nth_msf(3, 1)}" +puts "GLib.bit_storage(3) = #{GLib.bit_storage(3)}" +puts "GLib.spaced_primes_closest(10) = #{GLib.spaced_primes_closest(10)}" + +keys = { + "foo" => 1 << 0, + "bar" => 1 << 1, + "hoge" => 1 << 2, + "fuga" => 1 << 3 +} + +puts GLib.parse_debug_string("foo", keys) +puts GLib.parse_debug_string("bar", keys) +puts GLib.parse_debug_string("foo:bar:hoge", keys) +puts GLib.parse_debug_string("foo:bar:hoge:fuga", keys) diff --git a/lib/ruby-gtk2-2.0.2/glib2/test/glib-test-init.rb b/lib/ruby-gtk2-2.0.2/glib2/test/glib-test-init.rb new file mode 100644 index 0000000..193bc8b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/test/glib-test-init.rb @@ -0,0 +1,5 @@ +$VERBOSE = true + +require "rubygems" +gem 'test-unit' +require 'test/unit' diff --git a/lib/ruby-gtk2-2.0.2/glib2/test/glib-test-utils.rb b/lib/ruby-gtk2-2.0.2/glib2/test/glib-test-utils.rb new file mode 100644 index 0000000..06f03ee --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/test/glib-test-utils.rb @@ -0,0 +1,12 @@ +module GLibTestUtils + private + def only_glib_version(major, minor, micro) + unless GLib.check_version?(major, minor, micro) + omit("Require GLib >= #{major}.#{minor}.#{micro}") + end + end + + def only_win32 + omit("Only for Win32 platform") unless GLib.os_win32? + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/test/run-test.rb b/lib/ruby-gtk2-2.0.2/glib2/test/run-test.rb new file mode 100755 index 0000000..d4f7fd2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/test/run-test.rb @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby + +base = File.expand_path(File.join(File.dirname(__FILE__))) +top = File.expand_path(File.join(base, "..")) + +$LOAD_PATH.unshift(top) +require 'test/glib-test-init' + +if system("which make > /dev/null") + system("cd #{top.dump} && make > /dev/null") or exit(1) +end + +$LOAD_PATH.unshift(File.join(top, "ext", "glib2")) +$LOAD_PATH.unshift(File.join(top, "lib")) + +$LOAD_PATH.unshift(base) +require 'glib-test-utils' + +require 'glib2' + +exit Test::Unit::AutoRunner.run(true, base) diff --git a/lib/ruby-gtk2-2.0.2/glib2/test/test_enum.rb b/lib/ruby-gtk2-2.0.2/glib2/test/test_enum.rb new file mode 100644 index 0000000..78520ff --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/test/test_enum.rb @@ -0,0 +1,99 @@ +# -*- coding: utf-8 -*- +require 'test/unit' +require 'glib2' + +class TestEnum < Test::Unit::TestCase + def test_enum_by_symbol + original = [0x00c1].pack("U*") # A with acute + + assert_equal(GLib::UTF8.normalize(original, GLib::NormalizeMode::NFD), + GLib::UTF8.normalize(original, :nfd)) + assert_equal(GLib::UTF8.normalize(original, GLib::NormalizeMode::NFD), + GLib::UTF8.normalize(original, :NFD)) + + assert_raise(TypeError) do + GLib::UTF8.normalize(original, :unknown) + end + end + + def test_enum_by_string + original = [0x00c1].pack("U*") # A with acute + + assert_equal(GLib::UTF8.normalize(original, GLib::NormalizeMode::NFD), + GLib::UTF8.normalize(original, "nfd")) + assert_equal(GLib::UTF8.normalize(original, GLib::NormalizeMode::NFD), + GLib::UTF8.normalize(original, "NFD")) + + assert_raise(TypeError) do + GLib::UTF8.normalize(original, "unknown") + end + end + + def test_flags_simple + assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS, :keep_comments) + assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS, :KEEP_COMMENTS) + assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS, "keep_comments") + assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS, "KEEP_COMMENTS") + assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS, "keep COMMENTS") + + assert_raise(TypeError) do + assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS, :unknown) + end + + assert_raise(TypeError) do + assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS, "UNKNOWN") + end + end + + def test_flags_by_array + assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS | + GLib::KeyFile::KEEP_TRANSLATIONS, + [:keep_comments, :keep_translations]) + assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS | + GLib::KeyFile::KEEP_TRANSLATIONS, + [:keep_COMMENTS, "KEEP_TRANSLATIONS"]) + assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS | + GLib::KeyFile::KEEP_TRANSLATIONS, + ["keep_comments", "KEEP_translations"]) + assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS | + GLib::KeyFile::KEEP_TRANSLATIONS, + [:keep_comments, GLib::KeyFile::KEEP_TRANSLATIONS]) + + assert_raise(TypeError) do + assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS | + GLib::KeyFile::KEEP_TRANSLATIONS, + [:keep_comments, nil, :keep_translations]) + end + end + + def test_flags_or + assert_equal(GLib::KeyFile::KEEP_COMMENTS, + GLib::KeyFile::KEEP_COMMENTS | []) + assert_equal(GLib::KeyFile::KEEP_COMMENTS | + GLib::KeyFile::KEEP_TRANSLATIONS , + GLib::KeyFile::KEEP_COMMENTS | [:keep_translations]) + end + + private + def assert_key_file_load(flags, convenience_flags) + data = <<-EOD +[SECTION] +KEY=VALUE +# comment + +KEY[ja]=値 +EOD + + expected_key_file = GLib::KeyFile.new + expected_key_file.load_from_data(data, flags) + + actual_key_file = GLib::KeyFile.new + actual_key_file.load_from_data(data, convenience_flags) + + assert_equal(expected_key_file.get_value("SECTION", "KEY"), + actual_key_file.get_value("SECTION", "KEY")) + + assert_equal(expected_key_file.to_data, + actual_key_file.to_data) + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/test/test_file_utils.rb b/lib/ruby-gtk2-2.0.2/glib2/test/test_file_utils.rb new file mode 100644 index 0000000..1c65c8b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/test/test_file_utils.rb @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- + +class TestGLibFileUtils < Test::Unit::TestCase + include GLibTestUtils + + def test_format_size_for_display + only_glib_version(2, 16, 0) + + assert_equal("1.0 KB", GLib.format_size_for_display(1024)) + assert_equal("10.0 KB", GLib.format_size_for_display(1024 * 10)) + assert_equal("1.0 MB", GLib.format_size_for_display(1024 * 1024)) + assert_equal("1.5 MB", GLib.format_size_for_display(1024 * 1024 * 1.5)) + assert_equal("1.0 GB", GLib.format_size_for_display(1024 * 1024 * 1024)) + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/test/test_flags.rb b/lib/ruby-gtk2-2.0.2/glib2/test/test_flags.rb new file mode 100644 index 0000000..e4a5be2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/test/test_flags.rb @@ -0,0 +1,129 @@ +# -*- coding: utf-8 -*- + +require 'test/unit' +require 'glib2' + +class TestFlags < Test::Unit::TestCase + { + '<=>' => [ + [0b0000, 0.0, nil], + [0b0000, 0b0000, 0], + [0b0000, 0b0110, -1], + [0b0000, 0b1111, -1], + [0b0110, 0b0000, 1], + [0b0110, 0b0011, nil], + [0b0110, 0b0110, 0], + [0b0110, 0b0111, -1], + [0b0110, 0b1001, nil], + [0b0110, 0b1100, nil], + [0b0110, 0b1110, -1], + [0b0110, 0b1111, -1], + [0b1111, 0b0000, 1], + [0b1111, 0b0110, 1], + [0b1111, 0b1111, 0], + ], + '==' => [ + [0b0000, 0.0, nil], + [0b0000, 0b0000, true], + [0b0000, 0b0110, false], + [0b0000, 0b1111, false], + [0b0110, 0b0000, false], + [0b0110, 0b0011, false], + [0b0110, 0b0110, true], + [0b0110, 0b0111, false], + [0b0110, 0b1001, false], + [0b0110, 0b1100, false], + [0b0110, 0b1110, false], + [0b0110, 0b1111, false], + [0b1111, 0b0000, false], + [0b1111, 0b0110, false], + [0b1111, 0b1111, true], + ], + '>=' => [ + [0b0000, 0.0, nil], + [0b0000, 0b0000, true], + [0b0000, 0b0110, false], + [0b0000, 0b1111, false], + [0b0110, 0b0000, true], + [0b0110, 0b0011, false], + [0b0110, 0b0110, true], + [0b0110, 0b0111, false], + [0b0110, 0b1001, false], + [0b0110, 0b1100, false], + [0b0110, 0b1110, false], + [0b0110, 0b1111, false], + [0b1111, 0b0000, true], + [0b1111, 0b0110, true], + [0b1111, 0b1111, true], + ], + '<=' => [ + [0b0000, 0.0, nil], + [0b0000, 0b0000, true], + [0b0000, 0b0110, true], + [0b0000, 0b1111, true], + [0b0110, 0b0000, false], + [0b0110, 0b0011, false], + [0b0110, 0b0110, true], + [0b0110, 0b0111, true], + [0b0110, 0b1001, false], + [0b0110, 0b1100, false], + [0b0110, 0b1110, true], + [0b0110, 0b1111, true], + [0b1111, 0b0000, false], + [0b1111, 0b0110, false], + [0b1111, 0b1111, true], + ], + '>' => [ + [0b0000, 0.0, nil], + [0b0000, 0b0000, false], + [0b0000, 0b0110, false], + [0b0000, 0b1111, false], + [0b0110, 0b0000, true], + [0b0110, 0b0011, false], + [0b0110, 0b0110, false], + [0b0110, 0b0111, false], + [0b0110, 0b1001, false], + [0b0110, 0b1100, false], + [0b0110, 0b1110, false], + [0b0110, 0b1111, false], + [0b1111, 0b0000, true], + [0b1111, 0b0110, true], + [0b1111, 0b1111, false], + ], + '<' => [ + [0b0000, 0.0, nil], + [0b0000, 0b0000, false], + [0b0000, 0b0110, true], + [0b0000, 0b1111, true], + [0b0110, 0b0000, false], + [0b0110, 0b0011, false], + [0b0110, 0b0110, false], + [0b0110, 0b0111, true], + [0b0110, 0b1001, false], + [0b0110, 0b1100, false], + [0b0110, 0b1110, true], + [0b0110, 0b1111, true], + [0b1111, 0b0000, false], + [0b1111, 0b0110, false], + [0b1111, 0b1111, false], + ], + }.each do |operator, values| + values.each do |a, b, expected| + a_format = a.is_a?(Float) ? "%f" : "0b%04b" + b_format = b.is_a?(Float) ? "%f" : "0b%04b" + label_format = "#{a_format} %s #{b_format} == %s" + data((label_format % [a, operator, b, expected.inspect]), + { + :a => a, + :operator => operator, + :b => b, + :expected => expected, + }) + end + end + def test_flags_compare(data) + flags = GLib::KeyFile::Flags.new(data[:a]) + assert_equal(data[:expected], + flags.send(data[:operator], data[:b])) + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/test/test_glib2.rb b/lib/ruby-gtk2-2.0.2/glib2/test/test_glib2.rb new file mode 100755 index 0000000..42d23a4 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/test/test_glib2.rb @@ -0,0 +1,122 @@ +# coding: binary + +require 'test/unit' +require 'glib2' + +class TestGLib < Test::Unit::TestCase + + def test_version + assert_kind_of(Array, GLib::VERSION) + assert_equal(GLib::VERSION.length, 3) + assert(GLib::VERSION.all?{|i| i.is_a? Integer }) + + assert_kind_of(Integer, GLib::MAJOR_VERSION) + assert_kind_of(Integer, GLib::MINOR_VERSION) + assert_kind_of(Integer, GLib::MICRO_VERSION) + + assert_kind_of(Array, GLib::BINDING_VERSION) + assert_equal(GLib::BINDING_VERSION.length, 3) + assert(GLib::BINDING_VERSION.all?{|i| i.is_a? Integer }) + end + + def test_priority + assert_kind_of(Integer, GLib::PRIORITY_HIGH) + assert_kind_of(Integer, GLib::PRIORITY_DEFAULT) + assert_kind_of(Integer, GLib::PRIORITY_HIGH_IDLE) + assert_kind_of(Integer, GLib::PRIORITY_DEFAULT_IDLE) + assert_kind_of(Integer, GLib::PRIORITY_LOW) + end + + def test_int64 + end + + def test_convert + assert_kind_of(String, GLib.charset) + + sjis = "\202\261\202\361\202\311\202\277\202\315\220\242\212E" + euc = "\244\263\244\363\244\313\244\301\244\317\300\244\263\246" + utf8 = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257\344\270\226\347\225\214" + assert_equal(GLib.convert(sjis, "UTF-8", "SHIFT_JIS"), utf8) + assert_equal(GLib.convert(sjis, "EUC-JP", "SHIFT_JIS"), euc) + assert_equal(GLib.convert(sjis, "SHIFT_JIS", "SHIFT_JIS"), sjis) + assert_equal(GLib.convert(euc, "UTF-8", "EUC-JP"), utf8) + assert_equal(GLib.convert(euc, "EUC-JP", "EUC-JP"), euc) + assert_equal(GLib.convert(euc, "SHIFT_JIS", "EUC-JP"), sjis) + assert_equal(GLib.convert(utf8, "UTF-8", "UTF-8"), utf8) + assert_equal(GLib.convert(utf8, "EUC-JP", "UTF-8"), euc) + assert_equal(GLib.convert(utf8, "SHIFT_JIS", "UTF-8"), sjis) + + # rb_define_module_function(mGLib, "locale_to_utf8", rbglib_m_locale_to_utf8, 1); + # rb_define_module_function(mGLib, "locale_from_utf8", rbglib_m_locale_from_utf8, 1); + # rb_define_module_function(mGLib, "filename_to_utf8", rbglib_m_filename_to_utf8, 1); + # rb_define_module_function(mGLib, "filename_from_utf8", rbglib_m_filename_from_utf8, 1); + # + # rb_define_module_function(mGLib, "filename_to_uri", rbglib_m_filename_to_uri, -1); + # rb_define_module_function(mGLib, "filename_from_uri", rbglib_m_filename_from_uri, 1); + + end + + def test_messages + #rb_define_module_function(mGLog, "set_handler", rbglib_m_log_set_handler, 2); + #rb_define_module_function(mGLog, "remove_handler", rbglib_m_log_remove_handler, 2); + end + + def test_object + assert_raises(GLib::NoPropertyError) { + GLib::Object.property("foo") + } + + assert_raises(GLib::NoSignalError) { + GLib::Object.signal("foo") + } + end + + def test_interface_extend + assert_raises(TypeError){ + Object.__send__(:include, GLib::TypePlugin) + } + end + + def test_signal_has_handler_pending + obj = GLib::Object.new + signal_name = "notify" + + assert(!obj.signal_has_handler_pending?(signal_name)) + + h = obj.signal_connect(signal_name){} + assert(obj.signal_has_handler_pending?(signal_name)) + + obj.signal_handler_block(h) { + assert(obj.signal_has_handler_pending?(signal_name, true)) + assert(!obj.signal_has_handler_pending?(signal_name, false)) + } + assert(obj.signal_has_handler_pending?(signal_name, false)) + + obj.signal_handler_disconnect(h) + assert(!obj.signal_has_handler_pending?(signal_name)) + + obj = nil + end + + def test_signal_handler_disconnect_and_gc + obj = GLib::Object.new + klass = Class.new + 1000.times { + a = klass.new + id = obj.signal_connect("notify") { p a } + obj.signal_handler_disconnect(id) + } + GC.start + ary = [] + ObjectSpace.each_object(klass) { |a| ary.push(a) } + assert_operator(ary.size, :<, 1000) + end + + def test_gtype + assert_equal(GLib::Object.gtype, GLib::Type["GObject"]) + assert_equal(GLib::Interface.gtype, GLib::Type["GInterface"]) + + obj = GLib::Object.new + assert_equal(obj.gtype, GLib::Object.gtype) + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/test/test_iochannel.rb b/lib/ruby-gtk2-2.0.2/glib2/test/test_iochannel.rb new file mode 100755 index 0000000..03064b9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/test/test_iochannel.rb @@ -0,0 +1,275 @@ +# -*- coding: utf-8 -*- + +require 'test/unit' +require 'glib2' + +require 'tempfile' +require 'nkf' + +$KCODE = "U" unless defined?(:Encoding) + +class TestGIOChannel < Test::Unit::TestCase + def setup + @content = "aaa\nbbb\nccc\nあああ\n" + @sjis_content = NKF.nkf("-sW", @content) + + @file = Tempfile.new("glib2-content") + @file.open + @file.print(@content) + @file.close + + @sjis_file = Tempfile.new("glib2-sjis-content") + @sjis_file.open + @sjis_file.print(@sjis_content) + @sjis_file.close + end + + def test_open + write_test_file = Tempfile.new("glib2-write-test") + + io = GLib::IOChannel.open(@file.path) + io.close + + io = GLib::IOChannel.open(@file.path, "r") + assert_equal(@content, io.read) + io.close + + io = GLib::IOChannel.open(write_test_file.path, "w") + assert_raises(RuntimeError){ + assert_equal(@content, io.read) + } + io.close + + GLib::IOChannel.open(@file.path) do |_io| + assert_equal(@content, _io.read) + end + + GLib::IOChannel.open(@file.path, "r") do |_io| + assert_equal(@content, _io.read) + end + + GLib::IOChannel.open(write_test_file.path, "w") do |_io| + io = _io + assert_raises(RuntimeError) do + assert_equal(@content, io.read) + end + end + + assert_raises(GLib::IOChannelError) do + io.close + end + + assert_raises(GLib::FileError) do + GLib::IOChannel.new("foo") + end + end + + def test_getc + io = GLib::IOChannel.new(@file.path) + ["a", "b", "c", "あ"].each do |v| + 3.times do + assert_equal(v.unpack("U")[0], io.getc) + end + assert_equal("\n".unpack("U")[0], io.getc) + end + assert_equal(nil, io.getc) + io.close + end + + def test_each_char + text = @content.split(//u) + io = GLib::IOChannel.new(@file.path) + i = 0 + io.each_char {|ch| + assert_equal(text[i].unpack("U")[0], ch) + i += 1 + } + io.close + end + + def test_readchar + io = GLib::IOChannel.new(@file.path) + text = @content.split(//u) + text.each do |v| + assert_equal(v.unpack("U")[0], io.readchar) + end + assert_raises(EOFError) { + io.readchar + } + io.close + end + + def test_gets + io = GLib::IOChannel.new(@file.path) + assert_equal("aaa\n", io.gets) + assert_equal("bbb\n", io.gets) + assert_equal("ccc\n", io.gets) + assert_equal("あああ\n", io.gets) + assert_equal(nil, io.gets) + io.close + + io = GLib::IOChannel.new(@file.path) + assert_equal("aaa\nbbb\n", io.gets("bbb\n")) + assert_equal("ccc\nあああ\n", io.gets("bbb\n")) + assert_equal(nil, io.gets("bbb\n")) + io.close + end + + def test_readline + io = GLib::IOChannel.new(@file.path) + assert_equal("aaa\n", io.readline) + assert_equal("bbb\n", io.readline) + assert_equal("ccc\n", io.readline) + assert_equal("あああ\n", io.readline) + assert_raises(EOFError) { + io.readline + } + io.close + + io = GLib::IOChannel.new(@file.path) + assert_equal("aaa\nbbb\n", io.readline("bbb\n")) + assert_equal("ccc\nあああ\n", io.readline("bbb\n")) + assert_raises(EOFError) { + io.readline("bbb\n") + } + io.close + end + + def test_each_line + lines = ["aaa\n", "bbb\n", "ccc\n", "あああ\n"] + io = GLib::IOChannel.new(@file.path) + i = 0 + io.each {|line| + assert_equal(lines[i], line) + i += 1 + } + io.close + + io = GLib::IOChannel.new(@file.path) + assert_raises(RuntimeError) { + io.each {|line| + raise "test" + } + } + io.close + + io = GLib::IOChannel.new(@file.path) + i = 0 + io.each_line {|line| + assert_equal(lines[i], line) + i += 1 + } + io.close + + #Test for Enumerable + GLib::IOChannel.open(@file.path) do |_io| + io = _io + io.each_with_index do |line, _i| + assert_equal(lines[_i], line) + end + end + + assert_raises(ArgumentError) do + io.each + end + end + + def test_read + io = GLib::IOChannel.new(@file.path) + assert_equal(@content, io.read) + io.close + + io = GLib::IOChannel.new(@file.path) + assert_equal(@content, io.read(100)) + io.close + + io = GLib::IOChannel.new(@file.path) + assert_equal("aaa\nbbb\n", io.read(8)) + assert_equal("ccc\n", io.read(4)) + assert_equal("あああ\n", io.read(10)) + assert_equal("", io.read(10)) + assert_equal("", io.read(10)) + io.close + end + + def test_seek + text = @content + io = GLib::IOChannel.new(@file.path) + io.seek(5) + assert_equal(text.unpack("U*")[5], io.getc) + io.seek(6, GLib::IOChannel::SEEK_SET) + assert_equal(text.unpack("U*")[6], io.getc) + + io.seek(1, GLib::IOChannel::SEEK_CUR) + assert_equal(text.unpack("U*")[8], io.getc) + + io.pos = 0 + assert_equal(text.unpack("U*")[0], io.getc) + + io.set_pos(2) + assert_equal(text.unpack("U*")[2], io.getc) + + io.close + end + + def test_write + write_test_file = Tempfile.new("glib2-write-test") + + io = GLib::IOChannel.new(write_test_file.path, "w") + io.write("a\n") + io.write("あいう\n") + io.printf("a%sa\n", "a") + io.print("a", 100, "a\n") + io.puts("b", 200, "b") + io.putc("c") + io.putc("c".unpack("U")[0]) + io.putc("cc".unpack("U")[0]) + io.putc("あ".unpack("U")[0]) + io.putc("あ") + io.putc("あい") #Ignore 2nd char + io.putc("aあ") #Ignore 2nd char + io.close + + # check them + io = GLib::IOChannel.new(write_test_file.path, "r") + assert_equal("a\n", io.gets) + assert_equal("あいう\n", io.gets) + assert_equal("aaa\n", io.gets) + assert_equal("a100a\n", io.gets) + assert_equal("b\n", io.gets) + assert_equal("200\n", io.gets) + assert_equal("b\n", io.gets) + assert_equal("c".unpack("U")[0], io.getc) + assert_equal("c".unpack("U")[0], io.getc) + assert_equal("c".unpack("U")[0], io.getc) + assert_equal("あ".unpack("U")[0], io.getc) + assert_equal("あ".unpack("U")[0], io.getc) + assert_equal("あ".unpack("U")[0], io.getc) + assert_equal("a".unpack("U")[0], io.getc) + io.close + end + + def test_encoding + io = GLib::IOChannel.new(@file.path) + assert_equal("UTF-8", io.encoding) + io.encoding = "Shift_JIS" + assert_equal("Shift_JIS", io.encoding) + assert_raises(GLib::ConvertError) { + io.read + } + io.close + + io = GLib::IOChannel.new(@sjis_file.path) + io.encoding = "Shift_JIS" + assert_equal("Shift_JIS", io.encoding) + assert_equal(@content, io.read) + io.close + end + + def test_error + assert_raises(GLib::FileError) { + # No such file or directory + GLib::IOChannel.new("foo") + } + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/test/test_key_file.rb b/lib/ruby-gtk2-2.0.2/glib2/test/test_key_file.rb new file mode 100644 index 0000000..1bcf053 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/test/test_key_file.rb @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- + +require 'tempfile' + +class TestGLibKeyFile < Test::Unit::TestCase + include GLibTestUtils + + def test_load_from_dirs + only_glib_version(2, 14, 0) + + key_file = GLib::KeyFile.new + assert_raise(GLib::KeyFileError) do + key_file.load_from_dirs("non-existent") + end + + temp = Tempfile.new("key-file") + base_name = File.basename(temp.path) + search_dirs = [File.dirname(temp.path)] + assert_raise(GLib::KeyFileError) do + key_file.load_from_dirs("non-existent", search_dirs) + end + if GLib.check_version?(2, 31, 2) + assert_equal(temp.path, key_file.load_from_dirs(base_name, search_dirs)) + else + assert_raise(GLib::KeyFileError) do + key_file.load_from_dirs(base_name, search_dirs) + end + end + temp.puts(<<-EOK) +[General] +key = value +EOK + temp.close + assert_equal(temp.path, key_file.load_from_dirs(base_name, search_dirs)) + end + + def test_desktop_constants + only_glib_version(2, 14, 0) + assert_equal("Desktop Entry", GLib::KeyFile::DESKTOP_GROUP) + assert_equal("URL", GLib::KeyFile::DESKTOP_KEY_URL) + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/test/test_mkenums.rb b/lib/ruby-gtk2-2.0.2/glib2/test/test_mkenums.rb new file mode 100644 index 0000000..c7847e5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/test/test_mkenums.rb @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +require 'glib-mkenums' + +class TestGLibMkEnums < Test::Unit::TestCase + def test_parse_flags + source = <<-EOS + G_MARKUP_COLLECT_INVALID, + G_MARKUP_COLLECT_STRING, + G_MARKUP_COLLECT_STRDUP, + G_MARKUP_COLLECT_BOOLEAN, + G_MARKUP_COLLECT_TRISTATE, + + G_MARKUP_COLLECT_OPTIONAL = (1 << 16) +EOS + enum = GLib::EnumDefinition.new("GMarkupCollectType", source, 'G_TYPE_') + assert_equal([["G_MARKUP_COLLECT_INVALID", "invalid"], + ["G_MARKUP_COLLECT_STRING", "string"], + ["G_MARKUP_COLLECT_STRDUP", "strdup"], + ["G_MARKUP_COLLECT_BOOLEAN", "boolean"], + ["G_MARKUP_COLLECT_TRISTATE", "tristate"], + ["G_MARKUP_COLLECT_OPTIONAL", "optional"]], + enum.constants) + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/test/test_poll_fd.rb b/lib/ruby-gtk2-2.0.2/glib2/test/test_poll_fd.rb new file mode 100644 index 0000000..92b26c5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/test/test_poll_fd.rb @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestGLibPollFD < Test::Unit::TestCase + include GLibTestUtils + + def test_fd + poll_fd = GLib::PollFD.new(0, GLib::IOChannel::IN, 0) + assert_equal(0, poll_fd.fd) + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/test/test_signal.rb b/lib/ruby-gtk2-2.0.2/glib2/test/test_signal.rb new file mode 100644 index 0000000..01849fc --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/test/test_signal.rb @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- + +class TestSignal < Test::Unit::TestCase + def test_signal_flags + assert_const_defined(GLib, :SignalFlags) + assert_kind_of(GLib::SignalFlags, GLib::Signal::RUN_FIRST) + assert_equal(GLib::SignalFlags::MASK, GLib::Signal::FLAGS_MASK) + end + + def test_connect_flags + assert_const_defined(GLib, :ConnectFlags) + assert_kind_of(GLib::ConnectFlags, GLib::Signal::CONNECT_AFTER) + end + + def test_signal_match_type + assert_const_defined(GLib, :SignalMatchType) + assert_kind_of(GLib::SignalMatchType, GLib::Signal::MATCH_ID) + assert_equal(GLib::SignalMatchType::MASK, GLib::Signal::MATCH_MASK) + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/test/test_source.rb b/lib/ruby-gtk2-2.0.2/glib2/test/test_source.rb new file mode 100644 index 0000000..ee932db --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/test/test_source.rb @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestGLibSource < Test::Unit::TestCase + include GLibTestUtils + + def test_time + context = GLib::MainContext.default + source = GLib::Idle.source_new + source.attach(context) + time = source.time + assert_operator(0, :<, time) + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/test/test_spawn.rb b/lib/ruby-gtk2-2.0.2/glib2/test/test_spawn.rb new file mode 100644 index 0000000..17b5a37 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/test/test_spawn.rb @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +require 'rbconfig' + +class TestGLibSpawn < Test::Unit::TestCase + include GLibTestUtils + + def setup + end + + def teardown + end + + def test_async_keep_environment + if File.exist?('/bin/true') + assert_nothing_raised do + GLib::Spawn.async(Dir.pwd, ['/bin/true'], nil, 0) + end + end + end + + def test_async_clear_environment + if RbConfig.respond_to?(:ruby) + ruby = RbConfig.ruby + else + ruby = File.join(RbConfig::CONFIG['bindir'], + RbConfig::CONFIG['RUBY_INSTALL_NAME'] + + RbConfig::CONFIG['EXEEXT']) + end + pid = GLib::Spawn.async(Dir.pwd, [ruby, '-e', 'exit 1 unless ENV.empty?'], [], GLib::Spawn::DO_NOT_REAP_CHILD) + _, status = *Process.waitpid2(pid) + assert status.success? + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/test/test_timeout.rb b/lib/ruby-gtk2-2.0.2/glib2/test/test_timeout.rb new file mode 100644 index 0000000..f4f5f96 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/test/test_timeout.rb @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +class TestGLibTimeout < Test::Unit::TestCase + include GLibTestUtils + + def setup + @id = nil + end + + def teardown + GLib::Source.remove(@id) if @id + end + + def test_timeout_add_priority + priority = GLib::PRIORITY_HIGH + @id = GLib::Timeout.add(10, priority) + source = GLib::MainContext.default.find_source(@id) + assert_equal(priority, source.priority) + end + + def test_timeout_add_seconds_priority + only_glib_version(2, 14, 0) + priority = GLib::PRIORITY_HIGH + @id = GLib::Timeout.add_seconds(10, priority) + source = GLib::MainContext.default.find_source(@id) + assert_equal(priority, source.priority) + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/test/test_unicode.rb b/lib/ruby-gtk2-2.0.2/glib2/test/test_unicode.rb new file mode 100644 index 0000000..52ac0f7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/test/test_unicode.rb @@ -0,0 +1,394 @@ +# -*- coding: utf-8 -*- + +class TestGLibUnicode < Test::Unit::TestCase + include GLibTestUtils + + def test_gunicode_type + assert_nothing_raised do + GLib::Unicode::CONTROL + end + end + + def test_gunicode_break_type + assert_nothing_raised do + GLib::Unicode::BREAK_MANDATORY + end + end + + def test_unichar_alnum? + assert(GLib::UniChar.alnum?(unichar("a"))) + assert(GLib::UniChar.alnum?(unichar("1"))) + assert(!GLib::UniChar.alnum?(unichar("!"))) + end + + def test_unichar_alpha? + assert(GLib::UniChar.alpha?(unichar("a"))) + assert(GLib::UniChar.alpha?(unichar("A"))) + assert(!GLib::UniChar.alpha?(unichar("1"))) + end + + def test_unichar_cntrl? + assert(GLib::UniChar.cntrl?(unichar("\t"))) + assert(!GLib::UniChar.cntrl?(unichar("\h"))) + assert(!GLib::UniChar.cntrl?(unichar("a"))) + assert(!GLib::UniChar.cntrl?(unichar("1"))) + end + + def test_unichar_digit? + assert(GLib::UniChar.digit?(unichar("1"))) + assert(!GLib::UniChar.digit?(unichar("a"))) + end + + def test_unichar_graph? + assert(GLib::UniChar.graph?(unichar("a"))) + assert(!GLib::UniChar.graph?(unichar(" "))) + assert(!GLib::UniChar.graph?(unichar("\t"))) + end + + def test_unichar_lower? + assert(GLib::UniChar.lower?(unichar("a"))) + assert(!GLib::UniChar.lower?(unichar("A"))) + assert(!GLib::UniChar.lower?(unichar("1"))) + end + + def test_unichar_print? + assert(GLib::UniChar.print?(unichar("a"))) + assert(GLib::UniChar.print?(unichar(" "))) + assert(!GLib::UniChar.print?(unichar("\t"))) + end + + def test_unichar_punct? + assert(GLib::UniChar.punct?(unichar(","))) + assert(GLib::UniChar.punct?(unichar("."))) + assert(!GLib::UniChar.punct?(unichar("a"))) + assert(!GLib::UniChar.punct?(unichar("\t"))) + end + + def test_unichar_space? + assert(GLib::UniChar.space?(unichar(" "))) + assert(GLib::UniChar.space?(unichar("\t"))) + assert(GLib::UniChar.space?(unichar("\r"))) + assert(GLib::UniChar.space?(unichar("\n"))) + assert(!GLib::UniChar.space?(unichar("a"))) + end + + def test_unichar_upper? + assert(GLib::UniChar.upper?(unichar("A"))) + assert(!GLib::UniChar.upper?(unichar("a"))) + assert(!GLib::UniChar.upper?(unichar("1"))) + end + + def test_unichar_xdigit? + assert(GLib::UniChar.xdigit?(unichar("1"))) + assert(GLib::UniChar.xdigit?(unichar("a"))) + assert(GLib::UniChar.xdigit?(unichar("A"))) + assert(GLib::UniChar.xdigit?(unichar("F"))) + assert(!GLib::UniChar.xdigit?(unichar("X"))) + end + + def test_unichar_title? + end + + def test_unichar_defined? + end + + def test_unichar_wide? + assert(GLib::UniChar.wide?(unichar("あ"))) + assert(GLib::UniChar.wide?(unichar("A"))) + assert(!GLib::UniChar.wide?(unichar("a"))) + end + + def test_unichar_wide_cjk? + only_glib_version(2, 12, 0) + assert(GLib::UniChar.wide_cjk?(unichar("あ"))) + assert(GLib::UniChar.wide_cjk?(0xD55C)) # HANGUL SYLLABLE HAN + assert(!GLib::UniChar.wide_cjk?(unichar("a"))) + end + + def test_unichar_to_upper + assert_equal(unichar("A"), GLib::UniChar.to_upper(unichar("a"))) + assert_equal(unichar("A"), GLib::UniChar.to_upper(unichar("A"))) + assert_equal(unichar("*"), GLib::UniChar.to_title(unichar("*"))) + end + + def test_unichar_to_lower + assert_equal(unichar("a"), GLib::UniChar.to_lower(unichar("A"))) + assert_equal(unichar("a"), GLib::UniChar.to_lower(unichar("a"))) + assert_equal(unichar("*"), GLib::UniChar.to_title(unichar("*"))) + end + + def test_unichar_to_title + assert_equal(unichar("A"), GLib::UniChar.to_title(unichar("a"))) + assert_equal(unichar("A"), GLib::UniChar.to_title(unichar("A"))) + assert_equal(unichar("*"), GLib::UniChar.to_title(unichar("*"))) + end + + def test_unichar_digit_value + assert_equal(0, GLib::UniChar.digit_value(unichar("0"))) + assert_equal(9, GLib::UniChar.digit_value(unichar("9"))) + assert_equal(-1, GLib::UniChar.digit_value(unichar("a"))) + end + + def test_unichar_xdigit_value + assert_equal(0, GLib::UniChar.xdigit_value(unichar("0"))) + assert_equal(9, GLib::UniChar.xdigit_value(unichar("9"))) + assert_equal(10, GLib::UniChar.xdigit_value(unichar("a"))) + assert_equal(15, GLib::UniChar.xdigit_value(unichar("F"))) + assert_equal(-1, GLib::UniChar.xdigit_value(unichar("g"))) + end + + def test_unichar_type + assert_equal(GLib::Unicode::DECIMAL_NUMBER, + GLib::UniChar.type(unichar("0"))) + assert_equal(GLib::Unicode::LOWERCASE_LETTER, + GLib::UniChar.type(unichar("a"))) + assert_equal(GLib::Unicode::UPPERCASE_LETTER, + GLib::UniChar.type(unichar("A"))) + end + + def test_unichar_break_type + assert_equal(GLib::Unicode::BREAK_HYPHEN, + GLib::UniChar.break_type(unichar("-"))) + assert_equal(GLib::Unicode::BREAK_NUMERIC, + GLib::UniChar.break_type(unichar("0"))) + end + + def test_unicode_canonical_ordering + original = [unichar("a"), 0x0308, 0x0323, + unichar("e"), 0x0304, 0x0301, 0x0323].pack("U*") + expected = [unichar("a"), 0x0323, 0x0308, + unichar("e"), 0x0323, 0x0304, 0x0301].pack("U*") + assert_equal(utf8_to_utf32(expected), + GLib::Unicode.canonical_ordering(utf8_to_utf32(original))) + end + + def test_unicode_canonical_decomposition + a_with_acute = 0x00E1 + expected = [unichar("a"), 0x0301].pack("U*") + assert_equal(utf8_to_utf32(expected), + GLib::Unicode.canonical_decomposition(a_with_acute)) + + hiragana_ga = 0x304C + hiragana_ka = 0x304B + expected = [hiragana_ka, 0x3099].pack("U*") + assert_equal(utf8_to_utf32(expected), + GLib::Unicode.canonical_decomposition(hiragana_ga)) + end + + def test_unichar_get_mirror_char + assert_equal(unichar("("), GLib::UniChar.get_mirror_char(unichar(")"))) + assert_equal(unichar(")"), GLib::UniChar.get_mirror_char(unichar("("))) + assert_equal(unichar("x"), GLib::UniChar.get_mirror_char(unichar("x"))) + end + + def test_unichar_get_script + only_glib_version(2, 14, 0) + assert_equal(GLib::Unicode::SCRIPT_HIRAGANA, + GLib::UniChar.get_script(unichar("あ"))) + end + + def test_utf8_get_char + assert_equal(utf8_to_utf32("あ").unpack("L*")[0], + GLib::UTF8.get_char("あ")) + + assert_equal(utf8_to_utf32("あ").unpack("L*")[0], + GLib::UTF8.get_char("あ", true)) + partial_input = "あ".unpack("c*")[0..-2].pack("c*") + assert_equal(-2, GLib::UTF8.get_char(partial_input, true)) + invalid_input = "あ".unpack("c*")[2..-1].pack("c*") + assert_equal(-1, GLib::UTF8.get_char(invalid_input, true)) + end + + def test_utf8_size + assert_equal(1, GLib::UTF8.size("あ")) + assert_equal(2, GLib::UTF8.size("あい")) + end + + def test_utf8_reverse + assert_equal("おえういあ", GLib::UTF8.reverse("あいうえお")) + end + + def test_utf8_validate + assert(GLib::UTF8.validate("あ")) + assert(!GLib::UTF8.validate(binary("あ")[1..-1])) + end + + def test_utf8_upcase + assert_equal("ABCあいう", GLib::UTF8.upcase("aBcあいう")) + end + + def test_utf8_downcase + assert_equal("abcあいう", GLib::UTF8.downcase("aBcあいう")) + end + + def test_utf8_casefold + assert_equal(GLib::UTF8.casefold("AbCあいう"), + GLib::UTF8.casefold("aBcあいう")) + end + + def test_utf8_normalize + original = [0x00c1].pack("U*") # A with acute + + nfd = [0x0041, 0x0301].pack("U*") + assert_equal(nfd, + GLib::UTF8.normalize(original, GLib::NormalizeMode::NFD)) + + nfc = [0x00c1].pack("U*") + assert_equal(nfc, + GLib::UTF8.normalize(original, GLib::NormalizeMode::NFC)) + + nfkd = [0x0041, 0x0301].pack("U*") + assert_equal(nfkd, + GLib::UTF8.normalize(original, GLib::NormalizeMode::NFKD)) + + nfkc = [0x00c1].pack("U*") + assert_equal(nfkc, + GLib::UTF8.normalize(original, GLib::NormalizeMode::NFKC)) + end + + def test_utf8_collate + only_glib_version(2, 16, 0) + assert_operator(0, :>, GLib::UTF8.collate("あ", "い")) + assert_operator(0, :<, GLib::UTF8.collate("い", "あ")) + assert_equal(0, GLib::UTF8.collate("あ", "あ")) + end + + def test_utf8_collate_key + only_glib_version(2, 16, 0) + assert_operator(0, :>, + GLib::UTF8.collate_key("あ") <=> + GLib::UTF8.collate_key("い")) + assert_operator(0, :<, + GLib::UTF8.collate_key("い") <=> + GLib::UTF8.collate_key("あ")) + assert_equal(0, + GLib::UTF8.collate_key("あ") <=> + GLib::UTF8.collate_key("あ")) + end + + def test_utf8_collate_key_for_filename + assert_equal(["event.c", "event.h", "eventgenerator.c"], + ["event.c", "eventgenerator.c", "event.h"].sort_by do |f| + GLib::UTF8.collate_key(f, true) + end) + + assert_equal(["file1", "file5", "file10"], + ["file1", "file10", "file5"].sort_by do |f| + GLib::UTF8.collate_key(f, true) + end) + end + + def test_utf8_to_utf16 + assert_equal(utf8_to_utf16("あいうえお"), + GLib::UTF8.to_utf16("あいうえお")) + end + + def test_utf8_to_ucs4 + assert_equal(utf8_to_utf32("あいうえお"), + GLib::UTF8.to_ucs4("あいうえお")) + + assert_raise(GLib::ConvertError) do + GLib::UTF8.to_ucs4(binary("あいうえお")[1..-1]) + end + assert_nothing_raised do + GLib::UTF8.to_ucs4(binary("あいうえお")[1..-1], true) + end + end + + def test_utf16_to_ucs4 + assert_equal(utf8_to_utf32("あいうえお"), + GLib::UTF16.to_ucs4(utf8_to_utf16("あいうえお"))) + end + + def test_utf16_to_utf8 + assert_equal("あいうえお", + GLib::UTF16.to_utf8(utf8_to_utf16("あいうえお"))) + end + + + def test_ucs4_to_utf16 + assert_equal(utf8_to_utf16("あいうえお"), + GLib::UCS4.to_utf16(utf8_to_utf32("あいうえお"))) + + assert_raise(GLib::ConvertError) do + GLib::UCS4.to_utf16(binary(utf8_to_utf32("あいうえお"))[1..-1]) + end + end + + def test_ucs4_to_utf8 + assert_equal("あいうえお", + GLib::UCS4.to_utf8(utf8_to_utf32("あいうえお"))) + end + + def test_unichar_to_utf8 + assert_equal("あ", + GLib::UniChar.to_utf8(utf8_to_utf32("あ").unpack("L*")[0])) + end + + def test_unichar_combining_class + only_glib_version(2, 14, 0) + assert_equal(0, GLib::UniChar.combining_class(unichar("a"))) + assert_equal(230, GLib::UniChar.combining_class(unichar("́"))) + end + + def test_unichar_mark? + only_glib_version(2, 14, 0) + assert(!GLib::UniChar.mark?(unichar("a"))) + assert(!GLib::UniChar.mark?(0x200E)) # LEFT-TO-RIGHT MARK + assert(GLib::UniChar.mark?(0x1DC3)) # COMBINING SUSPENSION MARK + end + + def test_unichar_zero_width? + only_glib_version(2, 14, 0) + assert(!GLib::UniChar.zero_width?(unichar("a"))) + assert(GLib::UniChar.zero_width?(0x200B)) # ZERO WIDTH SPACE + end + + private + def unichar(char) + GLib::UTF8.get_char(char) + end + + def utf8_to_utf32(string) + if string.respond_to?(:encode) + if little_endian? + string.encode("UTF-32LE") + else + string.encode("UTF-32BE") + end + else + require_uconv + Uconv.u8tou4(string) + end + end + + def utf8_to_utf16(string) + if string.respond_to?(:encode) + if little_endian? + string.encode("UTF-16LE") + else + string.encode("UTF-16BE") + end + else + require_uconv + Uconv.u8tou16(string) + end + end + + def require_uconv + require 'uconv' + rescue LoadError + omit("Need uconv to run this test.") + end + + def binary(string) + if string.respond_to?(:force_encoding) + string.force_encoding("ascii-8bit") + end + string + end + + def little_endian? + [1].pack("v") == [1].pack("S") + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/test/test_utils.rb b/lib/ruby-gtk2-2.0.2/glib2/test/test_utils.rb new file mode 100644 index 0000000..fe4eba8 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/test/test_utils.rb @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- + +class TestGLibUtils < Test::Unit::TestCase + include GLibTestUtils + + def test_user_cache_dir + only_glib_version(2, 6, 0) + assert_kind_of(String, GLib.user_cache_dir) + end + + def test_user_data_dir + only_glib_version(2, 6, 0) + assert_kind_of(String, GLib.user_data_dir) + end + + def test_user_config_dir + only_glib_version(2, 6, 0) + assert_kind_of(String, GLib.user_config_dir) + end + + def test_system_data_dirs + only_glib_version(2, 6, 0) + assert_kind_of(Array, GLib.system_data_dirs) + end + + def test_system_config_dirs + only_glib_version(2, 6, 0) + assert_kind_of(Array, GLib.system_config_dirs) + end + + def test_get_user_special_dir + only_glib_version(2, 14, 0) + assert_nothing_raised do + GLib.get_user_special_dir(GLib::UserDirectory::DESKTOP) + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/test/test_value.rb b/lib/ruby-gtk2-2.0.2/glib2/test/test_value.rb new file mode 100644 index 0000000..dd23bbc --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/test/test_value.rb @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestGLibValue < Test::Unit::TestCase + include GLibTestUtils + + def test_type + value = GLib::Value.new(GLib::Type::UINT, 29) + assert_equal(GLib::Type::UINT, value.type) + end + + def test_value + value = GLib::Value.new(GLib::Type::UINT, 29) + assert_equal(29, value.value) + end +end diff --git a/lib/ruby-gtk2-2.0.2/glib2/test/test_win32.rb b/lib/ruby-gtk2-2.0.2/glib2/test/test_win32.rb new file mode 100644 index 0000000..0cc0fab --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/glib2/test/test_win32.rb @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- + +class TestGLibWin32 < Test::Unit::TestCase + include GLibTestUtils + + def test_get_package_install_directory_of_module + only_win32 + only_glib_version(2, 16, 0) + + assert_equal("FIXME", + GLib::Win32.get_package_installation_directory_of_module) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/COPYING.LIB b/lib/ruby-gtk2-2.0.2/gobject-introspection/COPYING.LIB new file mode 100644 index 0000000..4362b49 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/COPYING.LIB @@ -0,0 +1,502 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[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. + + GNU LESSER GENERAL PUBLIC LICENSE + 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 + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/README.md b/lib/ruby-gtk2-2.0.2/gobject-introspection/README.md new file mode 100644 index 0000000..52a3002 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/README.md @@ -0,0 +1,24 @@ +# Ruby/GObjectIntrospection + +Ruby/GObjectIntrospection is a Ruby binding of GObject Introspect. + +## Requirements + +* Ruby/GLib2 in + [Ruby-GNOME2](http://ruby-gnome2.sourceforge.jp/) +* [GObject Introspection](http://live.gnome.org/GObjectIntrospection) + +## Install + + gem install gobject-introspection + +## License + +Copyright (c) 2013 Ruby-GNOME2 Project Team + +This program is free software. You can distribute/modify this program +under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. + +## Project Website + +http://ruby-gnome2.sourceforge.jp/ diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/Rakefile b/lib/ruby-gtk2-2.0.2/gobject-introspection/Rakefile new file mode 100644 index 0000000..4a8d661 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/Rakefile @@ -0,0 +1,117 @@ +# -*- ruby -*- +# +# Copyright (C) 2012-2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +$LOAD_PATH.unshift("./../glib2/lib") +require "gnome2/rake/package-task" + +package_task = GNOME2::Rake::PackageTask.new do |package| + package.summary = "Ruby/GObjectIntrospection is a Ruby binding of GObjectIntrospection." + package.description = "Ruby/GObjectIntrospection is a Ruby binding of GObjectIntrospection." + package.dependency.gem.runtime = ["glib2"] + package.dependency.gem.development = [["test-unit", ">= 2"]] + package.windows.packages = [] + package.windows.dependencies = [] + package.windows.build_dependencies = ["glib2"] + package.external_packages = [ + { + :name => "glib", + :download_site => :gnome, + :label => "GLib", + :version => "2.36.2", + :compression_method => "xz", + :windows => { + :build => false, + }, + :native => { + :build => true, + :need_autoreconf => true, + }, + }, + { + :name => "gobject-introspection", + :download_site => :gnome, + :label => "gobject-introspection", + :version => "1.36.0", + :compression_method => "xz", + :windows => { + :configure_args => [ + "--with-g-ir-scanner=#{package.native.absolute_binary_dir}/bin/g-ir-scanner", + "--disable-tests", + ], + :patches => [ + "0001-Support-external-g-ir-scanner.patch", + ], + :need_autoreconf => true, + }, + :native => { + :build => true, + :patches => [ + # "cross-compilable-g-ir-scanner.diff", + ], + } + }, + ] +end +package_task.define + +namespace :native do + namespace :"gobject-introspection" do + desc "Make g-ir-scanner workable for Windows on non Windows" + task :cross do + g_ir_scanner_dir = package_task.native.absolute_binary_dir + g_ir_scanner_dir += "lib/gobject-introspection/giscanner" + Dir.chdir(g_ir_scanner_dir.to_s) do + patch = "#{package_task.package.patches_dir}/cross-g-ir-scanner.diff" + sh("patch -p2 < #{patch}") + end + end + end + + namespace :builder do + task :after => "native:gobject-introspection:cross" + end +end + +namespace :win32 do + namespace :"gobject-introspection" do + desc "Use native tools" + task :cross do + pkg_config_dir = package_task.windows.absolute_binary_dir + "lib/pkgconfig" + pc_path = pkg_config_dir + "gobject-introspection-1.0.pc" + original_pc = pc_path.read + new_pc = "" + new_pc << "native_prefix=#{package_task.native.absolute_binary_dir}\n" + new_pc << "native_bindir=${native_prefix}/bin\n" + original_pc.each_line do |line| + case line + when /\Ag_ir_(scanner|compiler)=/ + new_pc << line.gsub(/\${bindir}/, "${native_bindir}") + else + new_pc << line + end + end + pc_path.open("w") do |pc_file| + pc_file.write(new_pc) + end + end + end + + namespace :builder do + task :after => "win32:gobject-introspection:cross" + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/depend b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/depend new file mode 100644 index 0000000..30e05bc --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/depend @@ -0,0 +1,10 @@ +install-so: install-headers +install-headers: + $(INSTALL_DATA) $(srcdir)/rb-gobject-introspection.h $(RUBYARCHDIR) + +install: install-pc +install-pc: + if test -n "$(pkgconfigdir)"; then \ + $(MAKEDIRS) $(pkgconfigdir); \ + $(INSTALL_DATA) ruby-gobject-introspection.pc $(pkgconfigdir);\ + fi diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/extconf.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/extconf.rb new file mode 100755 index 0000000..a0b704d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/extconf.rb @@ -0,0 +1,94 @@ +#!/usr/bin/env ruby +# +# Copyright (C) 2012-2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "pathname" + +source_dir = Pathname(__FILE__).dirname +base_dir = source_dir.parent.parent.expand_path +top_dir = base_dir.parent.expand_path +top_build_dir = Pathname(".").parent.parent.parent.expand_path + +mkmf_gnome2_dir = top_dir + "glib2" + "lib" +version_suffix = "" +unless mkmf_gnome2_dir.exist? + if /(-\d+\.\d+\.\d+)(?:\.\d+)?\z/ =~ base_dir.basename.to_s + version_suffix = $1 + mkmf_gnome2_dir = top_dir + "glib2#{version_suffix}" + "lib" + end +end + +$LOAD_PATH.unshift(mkmf_gnome2_dir.to_s) + +module_name = "gobject_introspection" +package_id = "gobject-introspection-1.0" + +begin + require "mkmf-gnome2" +rescue LoadError + require "rubygems" + gem "glib2" + require "mkmf-gnome2" +end + +["glib2"].each do |package| + directory = "#{package}#{version_suffix}" + build_dir = "#{directory}/tmp/#{RUBY_PLATFORM}/#{package}/#{RUBY_VERSION}" + add_depend_package(package, "#{directory}/ext/#{package}", + top_dir.to_s, + :top_build_dir => top_build_dir.to_s, + :target_build_dir => build_dir) +end + +setup_win32(module_name, base_dir) + +unless required_pkg_config_package(package_id, + :debian => "libgirepository1.0-dev", + :fedora => "gobject-introspection-devel", + :homebrew => "gobject-introspection", + :macports => "gobject-introspection") + exit(false) +end + +make_version_header("GI", package_id, ".") + +gi_headers = ["girepository.h"] +have_func("g_interface_info_find_signal", gi_headers) + +enum_type_prefix = "gobject-introspection-enum-types" +include_paths = PKGConfig.cflags_only_I(package_id) +headers = include_paths.split.inject([]) do |result, path| + result + Dir.glob(File.join(path.sub(/^-I/, ""), "gi{repository,types}.h")) +end +glib_mkenums(enum_type_prefix, headers, "G_TYPE_", ["girepository.h"]) + +create_pkg_config_file("Ruby/GObjectIntrospection", + package_id, ruby_gnome2_version, + "ruby-gobject-introspection.pc") + +ensure_objs + +$defs << "-DRUBY_GOBJECT_INTROSPECTION_COMPILATION" +create_makefile(module_name) + +pkg_config_dir = with_config("pkg-config-dir") +if pkg_config_dir.is_a?(String) + File.open("Makefile", "ab") do |makefile| + makefile.puts + makefile.puts("pkgconfigdir=#{pkg_config_dir}") + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/gobject_introspection.def b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/gobject_introspection.def new file mode 100644 index 0000000..004bd9c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/gobject_introspection.def @@ -0,0 +1,5 @@ +EXPORTS + Init_gobject_introspection + + rb_gi_callback_data_free + rb_gi_callback_register_finder diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-arg-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-arg-info.c new file mode 100644 index 0000000..b77836f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-arg-info.c @@ -0,0 +1,151 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGIArgInfo +#define SELF(self) (RVAL2GI_ARG_INFO(self)) + +GType +gi_arg_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GIArgInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +static VALUE +rg_direction(VALUE self) +{ + GIArgInfo *info; + + info = SELF(self); + return GI_DIRECTION2RVAL(g_arg_info_get_direction(info)); +} + +static VALUE +rg_caller_allocates_p(VALUE self) +{ + GIArgInfo *info; + + info = SELF(self); + return CBOOL2RVAL(g_arg_info_is_caller_allocates(info)); +} + +static VALUE +rg_return_value_p(VALUE self) +{ + GIArgInfo *info; + + info = SELF(self); + return CBOOL2RVAL(g_arg_info_is_return_value(info)); +} + +static VALUE +rg_optional_p(VALUE self) +{ + GIArgInfo *info; + + info = SELF(self); + return CBOOL2RVAL(g_arg_info_is_optional(info)); +} + +static VALUE +rg_may_be_null_p(VALUE self) +{ + GIArgInfo *info; + + info = SELF(self); + return CBOOL2RVAL(g_arg_info_may_be_null(info)); +} + +static VALUE +rg_ownership_transfer(VALUE self) +{ + GIArgInfo *info; + + info = SELF(self); + return GI_TRANSFER2RVAL(g_arg_info_get_ownership_transfer(info)); +} + +static VALUE +rg_scope(VALUE self) +{ + GIArgInfo *info; + + info = SELF(self); + return GI_SCOPE_TYPE2RVAL(g_arg_info_get_scope(info)); +} + +static VALUE +rg_closure(VALUE self) +{ + GIArgInfo *info; + + info = SELF(self); + return INT2NUM(g_arg_info_get_closure(info)); +} + +static VALUE +rg_destroy(VALUE self) +{ + GIArgInfo *info; + + info = SELF(self); + return INT2NUM(g_arg_info_get_destroy(info)); +} + +static VALUE +rg_type(VALUE self) +{ + GIArgInfo *info; + + info = SELF(self); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_arg_info_get_type(info)); +} + +void +rb_gi_arg_info_init(VALUE rb_mGI, VALUE rb_cGIBaseInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_ARG_INFO, "ArgInfo", rb_mGI, + rb_cGIBaseInfo); + + RG_DEF_METHOD(direction, 0); + RG_DEF_METHOD_P(caller_allocates, 0); + RG_DEF_METHOD_P(return_value, 0); + RG_DEF_METHOD_P(optional, 0); + RG_DEF_METHOD_P(may_be_null, 0); + RG_DEF_METHOD(ownership_transfer, 0); + RG_DEF_METHOD(scope, 0); + RG_DEF_METHOD(closure, 0); + RG_DEF_METHOD(destroy, 0); + RG_DEF_METHOD(type, 0); + + G_DEF_CLASS(G_TYPE_I_DIRECTION, "Direction", rb_mGI); + G_DEF_CLASS(G_TYPE_I_SCOPE_TYPE, "ScopeType", rb_mGI); + G_DEF_CLASS(G_TYPE_I_TRANSFER, "Transfer", rb_mGI); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-argument.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-argument.c new file mode 100644 index 0000000..6644043 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-argument.c @@ -0,0 +1,1205 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012-2013 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +static VALUE rb_cGLibValue = Qnil; + +static void +array_c_to_ruby(const gchar **elements, GITypeInfo *type_info, VALUE rb_array) +{ + gint n_elements; + gboolean fixed_size_p; + gboolean zero_terminated_p; + + n_elements = g_type_info_get_array_length(type_info); + fixed_size_p = g_type_info_get_array_fixed_size(type_info); + zero_terminated_p = g_type_info_is_zero_terminated(type_info); + if (n_elements != -1) { + gint i; + for (i = 0; i < n_elements; i++) { + rb_ary_push(rb_array, CSTR2RVAL(elements[i])); + } + } else if (zero_terminated_p) { + for (; *elements; elements++) { + rb_ary_push(rb_array, CSTR2RVAL(*elements)); + } + } else { + rb_raise(rb_eNotImpError, + "TODO: GIArgument(array)[c] -> Ruby: " + "zero-terminated: %s " + "fixed-size: %s " + "length: %d", + zero_terminated_p ? "true" : "false", + fixed_size_p ? "true" : "false", + n_elements); + } +} + +static VALUE +array_to_ruby(gpointer array, GITypeInfo *type_info) +{ + VALUE rb_array; + GIArrayType array_type; + gint n_elements; + + array_type = g_type_info_get_array_type(type_info); + n_elements = g_type_info_get_array_length(type_info); + if (n_elements == -1) { + rb_array = rb_ary_new(); + } else { + rb_array = rb_ary_new2(n_elements); + } + switch (array_type) { + case GI_ARRAY_TYPE_C: + array_c_to_ruby(array, type_info, rb_array); + break; + case GI_ARRAY_TYPE_ARRAY: + rb_raise(rb_eNotImpError, "TODO: GIArgument(array)[array] -> Ruby"); + break; + case GI_ARRAY_TYPE_PTR_ARRAY: + rb_raise(rb_eNotImpError, "TODO: GIArgument(array)[ptr-array] -> Ruby"); + break; + case GI_ARRAY_TYPE_BYTE_ARRAY: + rb_raise(rb_eNotImpError, "TODO: GIArgument(array)[byte-array] -> Ruby"); + break; + default: + g_assert_not_reached(); + break; + } + + return rb_array; +} + +static VALUE +interface_to_ruby(GIArgument *argument, GITypeInfo *type_info) +{ + VALUE rb_interface; + GIBaseInfo *interface_info; + GIInfoType interface_type; + GType gtype; + + interface_info = g_type_info_get_interface(type_info); + interface_type = g_base_info_get_type(interface_info); + + gtype = g_registered_type_info_get_g_type(interface_info); + switch (interface_type) { + case GI_INFO_TYPE_INVALID: + rb_raise(rb_eNotImpError, + "TODO: GIArgument(interface)[invalid] -> Ruby"); + break; + case GI_INFO_TYPE_FUNCTION: + rb_raise(rb_eNotImpError, + "TODO: GIArgument(interface)[function] -> Ruby"); + break; + case GI_INFO_TYPE_CALLBACK: + rb_raise(rb_eNotImpError, + "TODO: GIArgument(interface)[callback] -> Ruby"); + break; + case GI_INFO_TYPE_STRUCT: + rb_interface = BOXED2RVAL(argument->v_pointer, gtype); + break; + case GI_INFO_TYPE_BOXED: + rb_raise(rb_eNotImpError, + "TODO: GIArgument(interface)[boxed] -> Ruby"); + break; + case GI_INFO_TYPE_ENUM: + if (gtype == G_TYPE_NONE) { + rb_interface = INT2NUM(argument->v_int32); + } else { + rb_interface = GENUM2RVAL(argument->v_int32, gtype); + } + break; + case GI_INFO_TYPE_FLAGS: + if (gtype == G_TYPE_NONE) { + rb_interface = INT2NUM(argument->v_int32); + } else { + rb_interface = GFLAGS2RVAL(argument->v_int32, gtype); + } + break; + case GI_INFO_TYPE_OBJECT: + rb_interface = GOBJ2RVAL(argument->v_pointer); + break; + case GI_INFO_TYPE_INTERFACE: + rb_interface = GOBJ2RVAL(argument->v_pointer); + break; + case GI_INFO_TYPE_CONSTANT: + rb_raise(rb_eNotImpError, + "TODO: GIArgument(interface)[constant] -> Ruby"); + break; + case GI_INFO_TYPE_INVALID_0: + g_assert_not_reached(); + break; + case GI_INFO_TYPE_UNION: + rb_interface = BOXED2RVAL(argument->v_pointer, gtype); + break; + case GI_INFO_TYPE_VALUE: + rb_raise(rb_eNotImpError, + "TODO: GIArgument(interface)[value] -> Ruby"); + break; + case GI_INFO_TYPE_SIGNAL: + rb_raise(rb_eNotImpError, + "TODO: GIArgument(interface)[signal] -> Ruby"); + break; + case GI_INFO_TYPE_VFUNC: + rb_raise(rb_eNotImpError, + "TODO: GIArgument(interface)[vfunc] -> Ruby"); + break; + case GI_INFO_TYPE_PROPERTY: + rb_raise(rb_eNotImpError, + "TODO: GIArgument(interface)[property] -> Ruby"); + break; + case GI_INFO_TYPE_FIELD: + rb_raise(rb_eNotImpError, + "TODO: GIArgument(interface)[field] -> Ruby"); + break; + case GI_INFO_TYPE_ARG: + rb_raise(rb_eNotImpError, + "TODO: GIArgument(interface)[arg] -> Ruby"); + break; + case GI_INFO_TYPE_TYPE: + rb_raise(rb_eNotImpError, + "TODO: GIArgument(interface)[type] -> Ruby"); + break; + case GI_INFO_TYPE_UNRESOLVED: + rb_raise(rb_eNotImpError, + "TODO: GIArgument(interface)[unresolved] -> Ruby"); + break; + default: + g_assert_not_reached(); + break; + } + + g_base_info_unref(interface_info); + + return rb_interface; +} + +VALUE +rb_gi_argument_to_ruby(GIArgument *argument, GITypeInfo *type_info) +{ + VALUE rb_argument = Qnil; + GITypeTag type_tag; + + type_tag = g_type_info_get_tag(type_info); + switch (type_tag) { + case GI_TYPE_TAG_VOID: + if (g_type_info_is_pointer(type_info)) { + rb_argument = ULONG2NUM(GPOINTER_TO_UINT(argument->v_pointer)); + } else { + rb_argument = Qnil; + } + break; + case GI_TYPE_TAG_BOOLEAN: + rb_argument = CBOOL2RVAL(argument->v_boolean); + break; + case GI_TYPE_TAG_INT8: + rb_argument = INT2NUM(argument->v_int8); + break; + case GI_TYPE_TAG_UINT8: + rb_argument = UINT2NUM(argument->v_uint8); + break; + case GI_TYPE_TAG_INT16: + rb_argument = INT2NUM(argument->v_int16); + break; + case GI_TYPE_TAG_UINT16: + rb_argument = UINT2NUM(argument->v_uint16); + break; + case GI_TYPE_TAG_INT32: + rb_argument = INT2NUM(argument->v_int32); + break; + case GI_TYPE_TAG_UINT32: + rb_argument = UINT2NUM(argument->v_uint32); + break; + case GI_TYPE_TAG_INT64: + rb_argument = LONG2NUM(argument->v_int64); + break; + case GI_TYPE_TAG_UINT64: + rb_argument = ULONG2NUM(argument->v_uint64); + break; + case GI_TYPE_TAG_FLOAT: + rb_argument = DBL2NUM(argument->v_float); + break; + case GI_TYPE_TAG_DOUBLE: + rb_argument = DBL2NUM(argument->v_double); + break; + case GI_TYPE_TAG_GTYPE: + rb_argument = rbgobj_gtype_new(argument->v_size); + break; + case GI_TYPE_TAG_UTF8: + rb_argument = CSTR2RVAL(argument->v_string); + break; + case GI_TYPE_TAG_FILENAME: + /* TODO: set encoding */ + rb_argument = CSTR2RVAL(argument->v_string); + break; + case GI_TYPE_TAG_ARRAY: + rb_argument = array_to_ruby(argument->v_pointer, type_info); + break; + case GI_TYPE_TAG_INTERFACE: + rb_argument = interface_to_ruby(argument, type_info); + break; + case GI_TYPE_TAG_GLIST: + case GI_TYPE_TAG_GSLIST: + case GI_TYPE_TAG_GHASH: + rb_raise(rb_eNotImpError, "TODO: GIArgument(unichar) -> Ruby"); + break; + case GI_TYPE_TAG_ERROR: + rb_argument = GERROR2RVAL(argument->v_pointer); + break; + case GI_TYPE_TAG_UNICHAR: + rb_raise(rb_eNotImpError, + "TODO: GIArgument(%s) -> Ruby", + g_type_tag_to_string(type_tag)); + break; + default: + g_assert_not_reached(); + break; + } + + return rb_argument; +} + +static void +rb_gi_out_argument_init_interface(GIArgument *argument, GIArgInfo *arg_info, + GITypeInfo *type_info) +{ + GIBaseInfo *interface_info; + GIInfoType interface_type; + + if (!g_arg_info_is_caller_allocates(arg_info)) { + argument->v_pointer = ALLOC(gpointer); + return; + } + + interface_info = g_type_info_get_interface(type_info); + interface_type = g_base_info_get_type(interface_info); + + switch (interface_type) { + case GI_INFO_TYPE_INVALID: + case GI_INFO_TYPE_FUNCTION: + case GI_INFO_TYPE_CALLBACK: + rb_raise(rb_eNotImpError, + "TODO: allocates GIArgument(interface)[%s] for output", + g_info_type_to_string(interface_type)); + break; + case GI_INFO_TYPE_STRUCT: + { + gsize struct_size; + + struct_size = g_struct_info_get_size(interface_info); + argument->v_pointer = xmalloc(struct_size); + memset(argument->v_pointer, 0, struct_size); + } + break; + case GI_INFO_TYPE_BOXED: + case GI_INFO_TYPE_ENUM: + case GI_INFO_TYPE_FLAGS: + case GI_INFO_TYPE_OBJECT: + case GI_INFO_TYPE_INTERFACE: + case GI_INFO_TYPE_CONSTANT: + case GI_INFO_TYPE_INVALID_0: + case GI_INFO_TYPE_UNION: + case GI_INFO_TYPE_VALUE: + case GI_INFO_TYPE_SIGNAL: + case GI_INFO_TYPE_VFUNC: + case GI_INFO_TYPE_PROPERTY: + case GI_INFO_TYPE_FIELD: + case GI_INFO_TYPE_ARG: + case GI_INFO_TYPE_TYPE: + case GI_INFO_TYPE_UNRESOLVED: + rb_raise(rb_eNotImpError, + "TODO: allocates GIArgument(interface)[%s] for output", + g_info_type_to_string(interface_type)); + break; + default: + g_assert_not_reached(); + break; + } + + g_base_info_unref(interface_info); +} + +void +rb_gi_out_argument_init(GIArgument *argument, GIArgInfo *arg_info) +{ + GITypeInfo type_info; + GITypeTag type_tag; + + memset(argument, 0, sizeof(GIArgument)); + + g_arg_info_load_type(arg_info, &type_info); + type_tag = g_type_info_get_tag(&type_info); + switch (type_tag) { + case GI_TYPE_TAG_VOID: + break; + case GI_TYPE_TAG_BOOLEAN: + argument->v_pointer = ALLOC(gboolean); + break; + case GI_TYPE_TAG_INT8: + argument->v_pointer = ALLOC(gint8); + break; + case GI_TYPE_TAG_UINT8: + argument->v_pointer = ALLOC(guint8); + break; + case GI_TYPE_TAG_INT16: + argument->v_pointer = ALLOC(gint16); + break; + case GI_TYPE_TAG_UINT16: + argument->v_pointer = ALLOC(guint16); + break; + case GI_TYPE_TAG_INT32: + argument->v_pointer = ALLOC(gint32); + break; + case GI_TYPE_TAG_UINT32: + argument->v_pointer = ALLOC(guint32); + break; + case GI_TYPE_TAG_INT64: + argument->v_pointer = ALLOC(gint64); + break; + case GI_TYPE_TAG_UINT64: + argument->v_pointer = ALLOC(guint64); + break; + case GI_TYPE_TAG_FLOAT: + argument->v_pointer = ALLOC(gfloat); + break; + case GI_TYPE_TAG_DOUBLE: + argument->v_pointer = ALLOC(gdouble); + break; + case GI_TYPE_TAG_GTYPE: + argument->v_pointer = ALLOC(GType); + break; + case GI_TYPE_TAG_UTF8: + case GI_TYPE_TAG_FILENAME: + argument->v_pointer = ALLOC(gchar *); + break; + case GI_TYPE_TAG_ARRAY: + argument->v_pointer = ALLOC(gpointer); + break; + case GI_TYPE_TAG_INTERFACE: + rb_gi_out_argument_init_interface(argument, arg_info, &type_info); + break; + case GI_TYPE_TAG_GLIST: + case GI_TYPE_TAG_GSLIST: + case GI_TYPE_TAG_GHASH: + argument->v_pointer = ALLOC(gpointer); + break; + case GI_TYPE_TAG_ERROR: + argument->v_pointer = ALLOC(GError *); + memset(argument->v_pointer, 0, sizeof(GError *)); + break; + case GI_TYPE_TAG_UNICHAR: + argument->v_pointer = ALLOC(gunichar); + break; + default: + g_assert_not_reached(); + break; + } +} + +VALUE +rb_gi_out_argument_to_ruby(GIArgument *argument, GIArgInfo *arg_info) +{ + GIArgument normalized_argument; + GITypeInfo type_info; + GITypeTag type_tag; + + memset(&normalized_argument, 0, sizeof(GIArgument)); + g_arg_info_load_type(arg_info, &type_info); + type_tag = g_type_info_get_tag(&type_info); + switch (type_tag) { + case GI_TYPE_TAG_VOID: + break; + case GI_TYPE_TAG_BOOLEAN: + normalized_argument.v_boolean = *((gboolean *)(argument->v_pointer)); + break; + case GI_TYPE_TAG_INT8: + normalized_argument.v_int8 = *((gint8 *)(argument->v_pointer)); + break; + case GI_TYPE_TAG_UINT8: + normalized_argument.v_uint8 = *((guint8 *)(argument->v_pointer)); + break; + case GI_TYPE_TAG_INT16: + normalized_argument.v_int16 = *((gint16 *)(argument->v_pointer)); + break; + case GI_TYPE_TAG_UINT16: + normalized_argument.v_uint16 = *((guint16 *)(argument->v_pointer)); + break; + case GI_TYPE_TAG_INT32: + normalized_argument.v_int32 = *((gint32 *)(argument->v_pointer)); + break; + case GI_TYPE_TAG_UINT32: + normalized_argument.v_uint32 = *((guint32 *)(argument->v_pointer)); + break; + case GI_TYPE_TAG_INT64: + normalized_argument.v_int64 = *((gint64 *)(argument->v_pointer)); + break; + case GI_TYPE_TAG_UINT64: + normalized_argument.v_uint64 = *((guint64 *)(argument->v_pointer)); + break; + case GI_TYPE_TAG_FLOAT: + normalized_argument.v_float = *((gfloat *)(argument->v_pointer)); + break; + case GI_TYPE_TAG_DOUBLE: + normalized_argument.v_double = *((gdouble *)(argument->v_pointer)); + break; + case GI_TYPE_TAG_GTYPE: + normalized_argument.v_size = *((GType *)(argument->v_pointer)); + break; + case GI_TYPE_TAG_UTF8: + case GI_TYPE_TAG_FILENAME: + normalized_argument.v_string = *((gchar **)(argument->v_pointer)); + break; + case GI_TYPE_TAG_ARRAY: + case GI_TYPE_TAG_INTERFACE: + case GI_TYPE_TAG_GLIST: + case GI_TYPE_TAG_GSLIST: + case GI_TYPE_TAG_GHASH: + if (g_arg_info_is_caller_allocates(arg_info)) { + normalized_argument.v_pointer = argument->v_pointer; + } else { + normalized_argument.v_pointer = *((gpointer *)(argument->v_pointer)); + } + break; + case GI_TYPE_TAG_ERROR: + normalized_argument.v_pointer = *((GError **)(argument->v_pointer)); + break; + case GI_TYPE_TAG_UNICHAR: + normalized_argument.v_uint32 = *((guint32 *)(argument->v_pointer)); + break; + default: + g_assert_not_reached(); + break; + } + + return rb_gi_argument_to_ruby(&normalized_argument, &type_info); +} + +void +rb_gi_out_argument_fin(GIArgument *argument, GIArgInfo *arg_info) +{ + GITypeInfo type_info; + + if (g_arg_info_get_direction(arg_info) != GI_DIRECTION_OUT) { + return; + } + + g_arg_info_load_type(arg_info, &type_info); + xfree(argument->v_pointer); +} + +VALUE +rb_gi_return_argument_to_ruby(GIArgument *argument, + GICallableInfo *callable_info) +{ + gboolean may_return_null; + GITypeInfo return_value_info; + + may_return_null = g_callable_info_may_return_null(callable_info); + if (may_return_null && !argument->v_pointer) { + return Qnil; + } + + g_callable_info_load_return_type(callable_info, &return_value_info); + return rb_gi_argument_to_ruby(argument, &return_value_info); +} + +static void +rb_gi_argument_from_ruby_array_c(GIArgument *argument, + G_GNUC_UNUSED GITypeInfo *type_info, + GITypeInfo *element_type_info, + VALUE rb_argument) +{ + GITypeTag element_type_tag; + + element_type_tag = g_type_info_get_tag(element_type_info); + switch (element_type_tag) { + case GI_TYPE_TAG_VOID: + case GI_TYPE_TAG_BOOLEAN: + rb_raise(rb_eNotImpError, + "TODO: Ruby -> GIArgument(array)[%s]", + g_type_tag_to_string(element_type_tag)); + break; + case GI_TYPE_TAG_INT8: + argument->v_pointer = StringValueCStr(rb_argument); + break; + case GI_TYPE_TAG_UINT8: + argument->v_pointer = RSTRING_PTR(rb_argument); + break; + case GI_TYPE_TAG_INT16: + case GI_TYPE_TAG_UINT16: + case GI_TYPE_TAG_INT32: + case GI_TYPE_TAG_UINT32: + case GI_TYPE_TAG_INT64: + case GI_TYPE_TAG_UINT64: + case GI_TYPE_TAG_FLOAT: + case GI_TYPE_TAG_DOUBLE: + case GI_TYPE_TAG_GTYPE: + rb_raise(rb_eNotImpError, + "TODO: Ruby -> GIArgument(array)[%s]", + g_type_tag_to_string(element_type_tag)); + break; + case GI_TYPE_TAG_UTF8: + case GI_TYPE_TAG_FILENAME: + argument->v_pointer = RVAL2STRV(rb_argument); + break; + case GI_TYPE_TAG_ARRAY: + case GI_TYPE_TAG_INTERFACE: + case GI_TYPE_TAG_GLIST: + case GI_TYPE_TAG_GSLIST: + case GI_TYPE_TAG_GHASH: + case GI_TYPE_TAG_ERROR: + case GI_TYPE_TAG_UNICHAR: + rb_raise(rb_eNotImpError, + "TODO: Ruby -> GIArgument(array)[%s]", + g_type_tag_to_string(element_type_tag)); + break; + default: + g_assert_not_reached(); + break; + } +} + +static void +rb_gi_argument_from_ruby_array(GIArgument *argument, GITypeInfo *type_info, + VALUE rb_argument) +{ + GIArrayType array_type; + GITypeInfo *element_type_info; + + array_type = g_type_info_get_array_type(type_info); + element_type_info = g_type_info_get_param_type(type_info, 0); + switch (array_type) { + case GI_ARRAY_TYPE_C: + rb_gi_argument_from_ruby_array_c(argument, + type_info, element_type_info, + rb_argument); + break; + case GI_ARRAY_TYPE_ARRAY: + case GI_ARRAY_TYPE_PTR_ARRAY: + case GI_ARRAY_TYPE_BYTE_ARRAY: + /* TODO */ + break; + default: + g_assert_not_reached(); + break; + } + g_base_info_unref(element_type_info); +} + +static void +rb_gi_argument_from_ruby_interface(GIArgument *argument, GITypeInfo *type_info, + VALUE rb_argument) +{ + GIBaseInfo *interface_info; + GIInfoType interface_type; + GType gtype; + + interface_info = g_type_info_get_interface(type_info); + interface_type = g_base_info_get_type(interface_info); + + gtype = g_registered_type_info_get_g_type(interface_info); + switch (interface_type) { + case GI_INFO_TYPE_INVALID: + case GI_INFO_TYPE_FUNCTION: + case GI_INFO_TYPE_CALLBACK: + rb_raise(rb_eNotImpError, + "TODO: Ruby -> GIArgument(interface)[%s]: <%s>", + g_info_type_to_string(interface_type), + g_base_info_get_name(interface_info)); + break; + case GI_INFO_TYPE_STRUCT: + if (gtype == G_TYPE_VALUE) { + GValue *gvalue; + gvalue = ALLOC(GValue); + memset(gvalue, 0, sizeof(GValue)); + if (rb_obj_is_kind_of(rb_argument, rb_cGLibValue)) { + GValue *source_gvalue; + source_gvalue = RVAL2BOXED(rb_argument, G_TYPE_VALUE); + g_value_init(gvalue, source_gvalue->g_type); + g_value_copy(source_gvalue, gvalue); + } else { + rbgobj_initialize_gvalue(gvalue, rb_argument); + } + argument->v_pointer = gvalue; + } else { + argument->v_pointer = RVAL2BOXED(rb_argument, gtype); + } + break; + case GI_INFO_TYPE_BOXED: + rb_raise(rb_eNotImpError, + "TODO: Ruby -> GIArgument(interface)[%s]: <%s>", + g_info_type_to_string(interface_type), + g_base_info_get_name(interface_info)); + break; + case GI_INFO_TYPE_ENUM: + if (gtype == G_TYPE_NONE) { + argument->v_int32 = NUM2INT(rb_argument); + } else { + argument->v_int32 = RVAL2GENUM(rb_argument, gtype); + } + break; + case GI_INFO_TYPE_FLAGS: + if (gtype == G_TYPE_NONE) { + argument->v_int32 = NUM2INT(rb_argument); + } else { + argument->v_int32 = RVAL2GFLAGS(rb_argument, gtype); + } + break; + case GI_INFO_TYPE_OBJECT: + case GI_INFO_TYPE_INTERFACE: + argument->v_pointer = RVAL2GOBJ(rb_argument); + break; + case GI_INFO_TYPE_CONSTANT: + rb_raise(rb_eNotImpError, + "TODO: Ruby -> GIArgument(interface)[%s]: <%s>", + g_info_type_to_string(interface_type), + g_base_info_get_name(interface_info)); + break; + case GI_INFO_TYPE_INVALID_0: + g_assert_not_reached(); + break; + case GI_INFO_TYPE_UNION: + case GI_INFO_TYPE_VALUE: + case GI_INFO_TYPE_SIGNAL: + case GI_INFO_TYPE_VFUNC: + case GI_INFO_TYPE_PROPERTY: + case GI_INFO_TYPE_FIELD: + case GI_INFO_TYPE_ARG: + case GI_INFO_TYPE_TYPE: + case GI_INFO_TYPE_UNRESOLVED: + default: + rb_raise(rb_eNotImpError, + "TODO: Ruby -> GIArgument(interface)[%s]: <%s>", + g_info_type_to_string(interface_type), + g_base_info_get_name(interface_info)); + break; + } + + g_base_info_unref(interface_info); +} + + +GIArgument * +rb_gi_value_argument_from_ruby(GIArgument *argument, GITypeInfo *type_info, + VALUE rb_argument) +{ + GITypeTag type_tag; + + memset(argument, 0, sizeof(GIArgument)); + + type_tag = g_type_info_get_tag(type_info); + switch (type_tag) { + case GI_TYPE_TAG_VOID: + if (g_type_info_is_pointer(type_info)) { + argument->v_pointer = GUINT_TO_POINTER(NUM2ULONG(rb_argument)); + } + break; + case GI_TYPE_TAG_BOOLEAN: + argument->v_boolean = RVAL2CBOOL(rb_argument); + break; + case GI_TYPE_TAG_INT8: + argument->v_int8 = NUM2INT(rb_argument); + break; + case GI_TYPE_TAG_UINT8: + argument->v_uint8 = NUM2UINT(rb_argument); + break; + case GI_TYPE_TAG_INT16: + argument->v_int16 = NUM2INT(rb_argument); + break; + case GI_TYPE_TAG_UINT16: + argument->v_uint16 = NUM2UINT(rb_argument); + break; + case GI_TYPE_TAG_INT32: + argument->v_int32 = NUM2INT(rb_argument); + break; + case GI_TYPE_TAG_UINT32: + argument->v_uint32 = NUM2UINT(rb_argument); + break; + case GI_TYPE_TAG_INT64: + argument->v_int64 = NUM2LONG(rb_argument); + break; + case GI_TYPE_TAG_UINT64: + argument->v_uint64 = NUM2ULONG(rb_argument); + break; + case GI_TYPE_TAG_FLOAT: + argument->v_float = NUM2DBL(rb_argument); + break; + case GI_TYPE_TAG_DOUBLE: + argument->v_double = NUM2DBL(rb_argument); + break; + case GI_TYPE_TAG_GTYPE: + /* TODO: support GLib::Type and String as GType name. */ + argument->v_size = NUM2ULONG(rb_argument); + break; + case GI_TYPE_TAG_UTF8: + /* TODO: support UTF-8 convert like rb_argument.encode("UTF-8"). */ + argument->v_string = (gchar *)RVAL2CSTR(rb_argument); + break; + case GI_TYPE_TAG_FILENAME: + argument->v_string = (gchar *)RVAL2CSTR(rb_argument); + break; + case GI_TYPE_TAG_ARRAY: + rb_gi_argument_from_ruby_array(argument, type_info, rb_argument); + break; + case GI_TYPE_TAG_INTERFACE: + rb_gi_argument_from_ruby_interface(argument, type_info, rb_argument); + break; + case GI_TYPE_TAG_GLIST: + case GI_TYPE_TAG_GSLIST: + case GI_TYPE_TAG_GHASH: + case GI_TYPE_TAG_ERROR: + case GI_TYPE_TAG_UNICHAR: + rb_raise(rb_eNotImpError, + "TODO: Ruby -> GIArgument(%s)", + g_type_tag_to_string(type_tag)); + break; + default: + g_assert_not_reached(); + break; + } + + return argument; +} + +static void +rb_gi_inout_argument_from_ruby(GIArgument *argument, + G_GNUC_UNUSED GIArgInfo *arg_info, + GITypeInfo *type_info, VALUE rb_argument) +{ + GIArgument in_argument; + GITypeTag type_tag; + + rb_gi_value_argument_from_ruby(&in_argument, type_info, rb_argument); + + type_tag = g_type_info_get_tag(type_info); + switch (type_tag) { + case GI_TYPE_TAG_VOID: + break; + case GI_TYPE_TAG_BOOLEAN: + argument->v_pointer = ALLOC(gboolean); + *((gboolean *)argument->v_pointer) = in_argument.v_boolean; + break; + case GI_TYPE_TAG_INT8: + argument->v_pointer = ALLOC(gint8); + *((gint8 *)argument->v_pointer) = in_argument.v_int8; + break; + case GI_TYPE_TAG_UINT8: + argument->v_pointer = ALLOC(guint8); + *((guint8 *)argument->v_pointer) = in_argument.v_uint8; + break; + case GI_TYPE_TAG_INT16: + argument->v_pointer = ALLOC(gint16); + *((gint16 *)argument->v_pointer) = in_argument.v_int16; + break; + case GI_TYPE_TAG_UINT16: + argument->v_pointer = ALLOC(guint16); + *((guint16 *)argument->v_pointer) = in_argument.v_uint16; + break; + case GI_TYPE_TAG_INT32: + argument->v_pointer = ALLOC(gint32); + *((gint32 *)argument->v_pointer) = in_argument.v_int32; + break; + case GI_TYPE_TAG_UINT32: + argument->v_pointer = ALLOC(guint32); + *((guint32 *)argument->v_pointer) = in_argument.v_uint32; + break; + case GI_TYPE_TAG_INT64: + argument->v_pointer = ALLOC(gint64); + *((gint64 *)argument->v_pointer) = in_argument.v_int64; + break; + case GI_TYPE_TAG_UINT64: + argument->v_pointer = ALLOC(guint64); + *((guint64 *)argument->v_pointer) = in_argument.v_uint64; + break; + case GI_TYPE_TAG_FLOAT: + argument->v_pointer = ALLOC(gfloat); + *((gfloat *)argument->v_pointer) = in_argument.v_float; + break; + case GI_TYPE_TAG_DOUBLE: + argument->v_pointer = ALLOC(gdouble); + *((gdouble *)argument->v_pointer) = in_argument.v_double; + break; + case GI_TYPE_TAG_GTYPE: + argument->v_pointer = ALLOC(gsize); + *((gsize *)argument->v_pointer) = in_argument.v_size; + break; + case GI_TYPE_TAG_UTF8: + case GI_TYPE_TAG_FILENAME: + argument->v_pointer = ALLOC(gchar *); + *((gchar **)argument->v_pointer) = in_argument.v_string; + break; + case GI_TYPE_TAG_ARRAY: + case GI_TYPE_TAG_INTERFACE: + case GI_TYPE_TAG_GLIST: + case GI_TYPE_TAG_GSLIST: + case GI_TYPE_TAG_GHASH: + argument->v_pointer = ALLOC(gpointer); + *((gpointer *)argument->v_pointer) = in_argument.v_pointer; + break; + case GI_TYPE_TAG_ERROR: + argument->v_pointer = ALLOC(GError *); + *((GError **)argument->v_pointer) = in_argument.v_pointer; + break; + case GI_TYPE_TAG_UNICHAR: + argument->v_pointer = ALLOC(gunichar); + *((gunichar *)argument->v_pointer) = in_argument.v_uint32; + break; + default: + g_assert_not_reached(); + break; + } +} + +static void +rb_gi_in_argument_transfer_interface(GIArgument *argument, + G_GNUC_UNUSED GITransfer transfer, + GITypeInfo *type_info, + G_GNUC_UNUSED VALUE rb_argument) +{ + GIBaseInfo *interface_info; + GIInfoType interface_type; + G_GNUC_UNUSED GType gtype; + + interface_info = g_type_info_get_interface(type_info); + interface_type = g_base_info_get_type(interface_info); + gtype = g_registered_type_info_get_g_type(interface_info); + g_base_info_unref(interface_info); + + switch (interface_type) { + case GI_INFO_TYPE_INVALID: + case GI_INFO_TYPE_FUNCTION: + case GI_INFO_TYPE_CALLBACK: + rb_raise(rb_eNotImpError, + "TODO: in transfer (interface) [%s]", + g_info_type_to_string(interface_type)); + break; + case GI_INFO_TYPE_STRUCT: + rbgobj_boxed_unown(rb_argument); + break; + case GI_INFO_TYPE_BOXED: + case GI_INFO_TYPE_ENUM: + case GI_INFO_TYPE_FLAGS: + rb_raise(rb_eNotImpError, + "TODO: in transfer (interface) [%s]", + g_info_type_to_string(interface_type)); + break; + case GI_INFO_TYPE_OBJECT: + g_object_ref(argument->v_pointer); + break; + case GI_INFO_TYPE_INTERFACE: + case GI_INFO_TYPE_CONSTANT: + rb_raise(rb_eNotImpError, + "TODO: in transfer (interface) [%s]", + g_info_type_to_string(interface_type)); + break; + case GI_INFO_TYPE_INVALID_0: + g_assert_not_reached(); + break; + case GI_INFO_TYPE_UNION: + case GI_INFO_TYPE_VALUE: + case GI_INFO_TYPE_SIGNAL: + case GI_INFO_TYPE_VFUNC: + case GI_INFO_TYPE_PROPERTY: + case GI_INFO_TYPE_FIELD: + case GI_INFO_TYPE_ARG: + case GI_INFO_TYPE_TYPE: + case GI_INFO_TYPE_UNRESOLVED: + rb_raise(rb_eNotImpError, + "TODO: in transfer (interface) [%s]", + g_info_type_to_string(interface_type)); + break; + default: + g_assert_not_reached(); + break; + } +} + +static void +rb_gi_in_argument_transfer(GIArgument *argument, GITransfer transfer, + GITypeInfo *type_info, VALUE rb_argument) +{ + GITypeTag type_tag; + + if (transfer == GI_TRANSFER_NOTHING) { + return; + } + + type_tag = g_type_info_get_tag(type_info); + switch (type_tag) { + case GI_TYPE_TAG_VOID: + case GI_TYPE_TAG_BOOLEAN: + case GI_TYPE_TAG_INT8: + case GI_TYPE_TAG_UINT8: + case GI_TYPE_TAG_INT16: + case GI_TYPE_TAG_UINT16: + case GI_TYPE_TAG_INT32: + case GI_TYPE_TAG_UINT32: + case GI_TYPE_TAG_INT64: + case GI_TYPE_TAG_UINT64: + case GI_TYPE_TAG_FLOAT: + case GI_TYPE_TAG_DOUBLE: + case GI_TYPE_TAG_GTYPE: + break; + case GI_TYPE_TAG_UTF8: + case GI_TYPE_TAG_FILENAME: + case GI_TYPE_TAG_ARRAY: + rb_raise(rb_eNotImpError, + "TODO: in transfer (%s)", + g_type_tag_to_string(type_tag)); + break; + case GI_TYPE_TAG_INTERFACE: + rb_gi_in_argument_transfer_interface(argument, transfer, + type_info, rb_argument); + break; + case GI_TYPE_TAG_GLIST: + case GI_TYPE_TAG_GSLIST: + case GI_TYPE_TAG_GHASH: + case GI_TYPE_TAG_ERROR: + case GI_TYPE_TAG_UNICHAR: + rb_raise(rb_eNotImpError, + "TODO: in transfer (%s)", + g_type_tag_to_string(type_tag)); + default: + g_assert_not_reached(); + break; + } +} + +GIArgument * +rb_gi_in_argument_from_ruby(GIArgument *argument, GIArgInfo *arg_info, + VALUE rb_argument) +{ + GITypeInfo type_info; + + if (g_arg_info_may_be_null(arg_info) && NIL_P(rb_argument)) { + memset(argument, 0, sizeof(GIArgument)); + return argument; + } + + g_arg_info_load_type(arg_info, &type_info); + if (g_arg_info_get_direction(arg_info) == GI_DIRECTION_INOUT) { + rb_gi_inout_argument_from_ruby(argument, arg_info, &type_info, + rb_argument); + } else { + rb_gi_value_argument_from_ruby(argument, &type_info, rb_argument); + rb_gi_in_argument_transfer(argument, + g_arg_info_get_ownership_transfer(arg_info), + &type_info, + rb_argument); + } + + return argument; +} + +static void +rb_gi_value_argument_free_array(GIArgument *argument, GITypeInfo *type_info) +{ + GIArrayType array_type; + + array_type = g_type_info_get_array_type(type_info); + switch (array_type) { + case GI_ARRAY_TYPE_C: + g_free(argument->v_pointer); + break; + case GI_ARRAY_TYPE_ARRAY: + case GI_ARRAY_TYPE_PTR_ARRAY: + case GI_ARRAY_TYPE_BYTE_ARRAY: + break; + default: + g_assert_not_reached(); + break; + } +} + +static void +rb_gi_value_argument_free_interface(GIArgument *argument, GITypeInfo *type_info) +{ + GIBaseInfo *interface_info; + GIInfoType interface_type; + + interface_info = g_type_info_get_interface(type_info); + interface_type = g_base_info_get_type(interface_info); + + if (interface_type == GI_INFO_TYPE_STRUCT) { + GType gtype; + gtype = g_registered_type_info_get_g_type(interface_info); + + if (gtype == G_TYPE_VALUE) { + GValue *gvalue = argument->v_pointer; + g_value_unset(gvalue); + xfree(argument->v_pointer); + } + } + + g_base_info_unref(interface_info); +} + +void +rb_gi_value_argument_free(GIArgument *argument, GITypeInfo *type_info) +{ + GITypeTag type_tag; + + type_tag = g_type_info_get_tag(type_info); + switch (type_tag) { + case GI_TYPE_TAG_VOID: + case GI_TYPE_TAG_BOOLEAN: + case GI_TYPE_TAG_INT8: + case GI_TYPE_TAG_UINT8: + case GI_TYPE_TAG_INT16: + case GI_TYPE_TAG_UINT16: + case GI_TYPE_TAG_INT32: + case GI_TYPE_TAG_UINT32: + case GI_TYPE_TAG_INT64: + case GI_TYPE_TAG_UINT64: + case GI_TYPE_TAG_FLOAT: + case GI_TYPE_TAG_DOUBLE: + case GI_TYPE_TAG_GTYPE: + case GI_TYPE_TAG_UTF8: + case GI_TYPE_TAG_FILENAME: + break; + case GI_TYPE_TAG_ARRAY: + rb_gi_value_argument_free_array(argument, type_info); + break; + case GI_TYPE_TAG_INTERFACE: + rb_gi_value_argument_free_interface(argument, type_info); + break; + case GI_TYPE_TAG_GLIST: + case GI_TYPE_TAG_GSLIST: + case GI_TYPE_TAG_GHASH: + case GI_TYPE_TAG_ERROR: + case GI_TYPE_TAG_UNICHAR: + break; + default: + g_assert_not_reached(); + break; + } +} + +static void +rb_gi_inout_argument_free(GIArgument *argument, GITypeInfo *type_info) +{ + GIArgument in_argument; + GITypeTag type_tag; + + memset(&in_argument, 0, sizeof(GIArgument)); + type_tag = g_type_info_get_tag(type_info); + switch (type_tag) { + case GI_TYPE_TAG_VOID: + break; + case GI_TYPE_TAG_BOOLEAN: + in_argument.v_boolean = *((gboolean *)(argument->v_pointer)); + break; + case GI_TYPE_TAG_INT8: + in_argument.v_int8 = *((gint8 *)(argument->v_pointer)); + break; + case GI_TYPE_TAG_UINT8: + /* TODO!!! */ + in_argument.v_uint8 = *((guint8 *)(argument->v_pointer)); + argument->v_pointer = ALLOC(guint8); + *((guint8 *)argument->v_pointer) = in_argument.v_uint8; + break; + case GI_TYPE_TAG_INT16: + in_argument.v_int16 = *((gint16 *)(argument->v_pointer)); + argument->v_pointer = ALLOC(gint16); + *((gint16 *)argument->v_pointer) = in_argument.v_int16; + break; + case GI_TYPE_TAG_UINT16: + in_argument.v_uint16 = *((guint16 *)(argument->v_pointer)); + argument->v_pointer = ALLOC(guint16); + *((guint16 *)argument->v_pointer) = in_argument.v_uint16; + break; + case GI_TYPE_TAG_INT32: + in_argument.v_int32 = *((gint32 *)(argument->v_pointer)); + argument->v_pointer = ALLOC(gint32); + *((gint32 *)argument->v_pointer) = in_argument.v_int32; + break; + case GI_TYPE_TAG_UINT32: + in_argument.v_uint32 = *((guint32 *)(argument->v_pointer)); + argument->v_pointer = ALLOC(guint32); + *((guint32 *)argument->v_pointer) = in_argument.v_uint32; + break; + case GI_TYPE_TAG_INT64: + in_argument.v_int64 = *((gint64 *)(argument->v_pointer)); + argument->v_pointer = ALLOC(gint64); + *((gint64 *)argument->v_pointer) = in_argument.v_int64; + break; + case GI_TYPE_TAG_UINT64: + in_argument.v_uint64 = *((guint64 *)(argument->v_pointer)); + argument->v_pointer = ALLOC(guint64); + *((guint64 *)argument->v_pointer) = in_argument.v_uint64; + break; + case GI_TYPE_TAG_FLOAT: + in_argument.v_float = *((gfloat *)(argument->v_pointer)); + argument->v_pointer = ALLOC(gfloat); + *((gfloat *)argument->v_pointer) = in_argument.v_float; + break; + case GI_TYPE_TAG_DOUBLE: + in_argument.v_double = *((gdouble *)(argument->v_pointer)); + argument->v_pointer = ALLOC(gdouble); + *((gdouble *)argument->v_pointer) = in_argument.v_double; + break; + case GI_TYPE_TAG_GTYPE: + in_argument.v_size = *((gsize *)(argument->v_pointer)); + break; + case GI_TYPE_TAG_UTF8: + case GI_TYPE_TAG_FILENAME: + in_argument.v_string = *((gchar **)(argument->v_pointer)); + break; + case GI_TYPE_TAG_ARRAY: + case GI_TYPE_TAG_INTERFACE: + case GI_TYPE_TAG_GLIST: + case GI_TYPE_TAG_GSLIST: + case GI_TYPE_TAG_GHASH: + in_argument.v_pointer = *((gpointer *)(argument->v_pointer)); + break; + case GI_TYPE_TAG_ERROR: + in_argument.v_pointer = *((GError **)(argument->v_pointer)); + break; + case GI_TYPE_TAG_UNICHAR: + in_argument.v_uint32 = *((gunichar *)(argument->v_pointer)); + break; + default: + g_assert_not_reached(); + break; + } + + rb_gi_value_argument_free(&in_argument, type_info); + xfree(argument->v_pointer); +} + +void +rb_gi_in_argument_free(GIArgument *argument, GIArgInfo *arg_info) +{ + GITypeInfo type_info; + + g_arg_info_load_type(arg_info, &type_info); + if (g_arg_info_get_direction(arg_info) == GI_DIRECTION_INOUT) { + rb_gi_inout_argument_free(argument, &type_info); + } else { + rb_gi_value_argument_free(argument, &type_info); + } +} + +void +rb_gi_argument_init(void) +{ + rb_cGLibValue = rb_const_get(mGLib, rb_intern("Value")); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-base-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-base-info.c new file mode 100644 index 0000000..361f925 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-base-info.c @@ -0,0 +1,218 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGIBaseInfo +#define SELF(self) RVAL2GI_BASE_INFO(self) + +VALUE +rb_gi_base_info_to_ruby(GIBaseInfo *info) +{ + GType g_type; + GIInfoType info_type; + + if (!info) { + return Qnil; + } + + info_type = g_base_info_get_type(info); + switch (info_type) { + case GI_INFO_TYPE_INVALID: + g_type = GI_TYPE_BASE_INFO; + break; + case GI_INFO_TYPE_FUNCTION: + { + GIFunctionInfoFlags flags; + + flags = g_function_info_get_flags((GIFunctionInfo *)info); + if (flags & GI_FUNCTION_IS_METHOD) { + g_type = GI_TYPE_METHOD_INFO; + } else if (flags & GI_FUNCTION_IS_CONSTRUCTOR) { + g_type = GI_TYPE_CONSTRUCTOR_INFO; + } else { + g_type = GI_TYPE_FUNCTION_INFO; + } + } + break; + case GI_INFO_TYPE_CALLBACK: + g_type = GI_TYPE_CALLBACK_INFO; + break; + case GI_INFO_TYPE_STRUCT: + g_type = GI_TYPE_STRUCT_INFO; + break; + case GI_INFO_TYPE_BOXED: + g_type = GI_TYPE_BOXED_INFO; + break; + case GI_INFO_TYPE_ENUM: + g_type = GI_TYPE_ENUM_INFO; + break; + case GI_INFO_TYPE_FLAGS: + g_type = GI_TYPE_FLAGS_INFO; + break; + case GI_INFO_TYPE_OBJECT: + g_type = GI_TYPE_OBJECT_INFO; + break; + case GI_INFO_TYPE_INTERFACE: + g_type = GI_TYPE_INTERFACE_INFO; + break; + case GI_INFO_TYPE_CONSTANT: + g_type = GI_TYPE_CONSTANT_INFO; + break; + case GI_INFO_TYPE_INVALID_0: + g_type = GI_TYPE_BASE_INFO; + break; + case GI_INFO_TYPE_UNION: + g_type = GI_TYPE_UNION_INFO; + break; + case GI_INFO_TYPE_VALUE: + g_type = GI_TYPE_VALUE_INFO; + break; + case GI_INFO_TYPE_SIGNAL: + g_type = GI_TYPE_SIGNAL_INFO; + break; + case GI_INFO_TYPE_VFUNC: + g_type = GI_TYPE_VFUNC_INFO; + break; + case GI_INFO_TYPE_PROPERTY: + g_type = GI_TYPE_PROPERTY_INFO; + break; + case GI_INFO_TYPE_FIELD: + g_type = GI_TYPE_FIELD_INFO; + break; + case GI_INFO_TYPE_ARG: + g_type = GI_TYPE_ARG_INFO; + break; + case GI_INFO_TYPE_TYPE: + g_type = GI_TYPE_TYPE_INFO; + break; + case GI_INFO_TYPE_UNRESOLVED: + g_type = GI_TYPE_UNRESOLVED_INFO; + break; + default: + g_type = GI_TYPE_BASE_INFO; + break; + } + + return BOXED2RVAL(info, g_type); +} + +VALUE +rb_gi_base_info_to_ruby_with_unref(GIBaseInfo *info) +{ + VALUE rb_info; + + rb_info = rb_gi_base_info_to_ruby(info); + if (!NIL_P(rb_info)) { + g_base_info_unref(info); + } + + return rb_info; +} + +GIBaseInfo * +rb_gi_base_info_from_ruby(VALUE rb_info) +{ + return RVAL2BOXED(rb_info, GI_TYPE_BASE_INFO); +} + +static VALUE +rg_type(VALUE self) +{ + GIBaseInfo *info; + + info = SELF(self); + return GI_INFO_TYPE2RVAL(g_base_info_get_type(info)); +} + +static VALUE +rg_name(VALUE self) +{ + GIBaseInfo *info; + + info = SELF(self); + return CSTR2RVAL(g_base_info_get_name(info)); +} + +static VALUE +rg_namespace(VALUE self) +{ + GIBaseInfo *info; + + info = SELF(self); + return CSTR2RVAL(g_base_info_get_namespace(info)); +} + +static VALUE +rg_operator_aref(VALUE self, VALUE name) +{ + GIBaseInfo *info; + + info = SELF(self); + return CSTR2RVAL(g_base_info_get_attribute(info, RVAL2CSTR(name))); +} + +static VALUE +rg_each(VALUE self) +{ + GIAttributeIter iter = {0, }; + GIBaseInfo *info; + gchar *name, *value; + + RETURN_ENUMERATOR(self, 0, NULL); + + info = SELF(self); + while (g_base_info_iterate_attributes(info, &iter, &name, &value)) { + VALUE rb_name, rb_value; + rb_name = CSTR2RVAL(name); + rb_value = CSTR2RVAL(value); + rb_yield(rb_ary_new3(2, rb_name, rb_value)); + } + + return Qnil; +} + +void +rb_gi_base_info_init(VALUE rb_mGI) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = G_DEF_CLASS(GI_TYPE_BASE_INFO, "BaseInfo", rb_mGI); + + rb_include_module(RG_TARGET_NAMESPACE, rb_mEnumerable); + + RG_DEF_METHOD(type, 0); + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(namespace, 0); + RG_DEF_METHOD_OPERATOR("[]", aref, 1); + RG_DEF_METHOD(each, 0); + + G_DEF_CLASS(G_TYPE_I_INFO_TYPE, "InfoType", rb_mGI); + + rb_gi_callable_info_init(rb_mGI, RG_TARGET_NAMESPACE); + rb_gi_registered_type_info_init(rb_mGI, RG_TARGET_NAMESPACE); + rb_gi_constant_info_init(rb_mGI, RG_TARGET_NAMESPACE); + rb_gi_value_info_init(rb_mGI, RG_TARGET_NAMESPACE); + rb_gi_property_info_init(rb_mGI, RG_TARGET_NAMESPACE); + rb_gi_field_info_init(rb_mGI, RG_TARGET_NAMESPACE); + rb_gi_arg_info_init(rb_mGI, RG_TARGET_NAMESPACE); + rb_gi_type_info_init(rb_mGI, RG_TARGET_NAMESPACE); + rb_gi_unresolved_info_init(rb_mGI, RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-boxed-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-boxed-info.c new file mode 100644 index 0000000..abb9256 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-boxed-info.c @@ -0,0 +1,48 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGIBoxedInfo +#define SELF(self) (RVAL2GI_BOXED_INFO(self)) + +GType +gi_boxed_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GIBoxedInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +void +rb_gi_boxed_info_init(VALUE rb_mGI, VALUE rb_cGIRegisteredTypeInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_BOXED_INFO, "BoxedInfo", rb_mGI, + rb_cGIRegisteredTypeInfo); + + (void)RG_TARGET_NAMESPACE; /* suppress a warning. */ +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-callable-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-callable-info.c new file mode 100644 index 0000000..e3a0cee --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-callable-info.c @@ -0,0 +1,104 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGICallableInfo +#define SELF(self) ((GICallableInfo *)(RVAL2GI_BASE_INFO(self))) + +GType +gi_callable_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GICallableInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +static VALUE +rg_return_type(VALUE self) +{ + GICallableInfo *info; + + info = SELF(self); + return GI_BASE_INFO2RVAL(g_callable_info_get_return_type(info)); +} + +static VALUE +rg_caller_owns(VALUE self) +{ + GICallableInfo *info; + + info = SELF(self); + return GI_TRANSFER2RVAL(g_callable_info_get_caller_owns(info)); +} + +static VALUE +rg_may_return_null_p(VALUE self) +{ + GICallableInfo *info; + + info = SELF(self); + return CBOOL2RVAL(g_callable_info_may_return_null(info)); +} + +static VALUE +rg_n_args(VALUE self) +{ + GICallableInfo *info; + + info = SELF(self); + return INT2NUM(g_callable_info_get_n_args(info)); +} + +static VALUE +rg_get_arg(VALUE self, VALUE rb_n) +{ + GICallableInfo *info; + gint n; + + info = SELF(self); + n = NUM2INT(rb_n); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_callable_info_get_arg(info, n)); +} + +void +rb_gi_callable_info_init(VALUE rb_mGI, VALUE rb_cGIBaseInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_CALLABLE_INFO, "CallableInfo", rb_mGI, + rb_cGIBaseInfo); + + RG_DEF_METHOD(return_type, 0); + RG_DEF_METHOD(caller_owns, 0); + RG_DEF_METHOD_P(may_return_null, 0); + RG_DEF_METHOD(n_args, 0); + RG_DEF_METHOD(get_arg, 1); + + rb_gi_function_info_init(rb_mGI, RG_TARGET_NAMESPACE); + rb_gi_callback_info_init(rb_mGI, RG_TARGET_NAMESPACE); + rb_gi_signal_info_init(rb_mGI, RG_TARGET_NAMESPACE); + rb_gi_vfunc_info_init(rb_mGI, RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-callback-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-callback-info.c new file mode 100644 index 0000000..b044bc9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-callback-info.c @@ -0,0 +1,48 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGICallbackInfo +#define SELF(self) RVAL2GI_BASE_INFO(self) + +GType +gi_callback_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GICallbackInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +void +rb_gi_callback_info_init(VALUE rb_mGI, VALUE rb_cGICallableInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_CALLBACK_INFO, "CallbackInfo", rb_mGI, + rb_cGICallableInfo); + + (void)RG_TARGET_NAMESPACE; /* suppress a warning. */ +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-constant-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-constant-info.c new file mode 100644 index 0000000..8c0c7c5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-constant-info.c @@ -0,0 +1,77 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGIConstantInfo +#define SELF(self) (RVAL2GI_CONSTANT_INFO(self)) + +GType +gi_constant_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GIConstantInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +static VALUE +rg_type(VALUE self) +{ + GIConstantInfo *info; + + info = SELF(self); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_constant_info_get_type(info)); +} + +static VALUE +rg_value(VALUE self) +{ + GIConstantInfo *info; + GIArgument value; + gint value_size; + GITypeInfo *type_info; + VALUE rb_value; + + info = SELF(self); + type_info = g_constant_info_get_type(info); + value_size = g_constant_info_get_value(info, &value); + rb_value = GI_ARGUMENT2RVAL(&value, type_info); + g_base_info_unref(type_info); + g_constant_info_free_value(info, &value); + + return rb_value; +} + +void +rb_gi_constant_info_init(VALUE rb_mGI, VALUE rb_cGIBaseInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_CONSTANT_INFO, "ConstantInfo", rb_mGI, + rb_cGIBaseInfo); + + RG_DEF_METHOD(type, 0); + RG_DEF_METHOD(value, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-constructor-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-constructor-info.c new file mode 100644 index 0000000..6e0d0e5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-constructor-info.c @@ -0,0 +1,128 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGIConstructorInfo +#define SELF(self) RVAL2GI_FUNCTION_INFO(self) + +GType +gi_constructor_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GIConstructorInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +static void +initialize_receiver(VALUE receiver, GITypeInfo *info, GIArgument *value) +{ + GIBaseInfo *interface_info; + GIInfoType interface_type; + + if (g_type_info_get_tag(info) != GI_TYPE_TAG_INTERFACE) { + rb_raise(rb_eRuntimeError, "TODO: returned value isn't interface"); + } + + interface_info = g_type_info_get_interface(info); + interface_type = g_base_info_get_type(interface_info); + g_base_info_unref(interface_info); + switch (interface_type) { + case GI_INFO_TYPE_OBJECT: + g_object_ref_sink(value->v_pointer); + G_INITIALIZE(receiver, value->v_pointer); + break; + case GI_INFO_TYPE_STRUCT: + G_INITIALIZE(receiver, value->v_pointer); + break; + case GI_INFO_TYPE_INVALID: + case GI_INFO_TYPE_FUNCTION: + case GI_INFO_TYPE_CALLBACK: + case GI_INFO_TYPE_BOXED: + case GI_INFO_TYPE_ENUM: + case GI_INFO_TYPE_FLAGS: + case GI_INFO_TYPE_INTERFACE: + case GI_INFO_TYPE_CONSTANT: + case GI_INFO_TYPE_INVALID_0: + case GI_INFO_TYPE_UNION: + case GI_INFO_TYPE_VALUE: + case GI_INFO_TYPE_SIGNAL: + case GI_INFO_TYPE_VFUNC: + case GI_INFO_TYPE_PROPERTY: + case GI_INFO_TYPE_FIELD: + case GI_INFO_TYPE_ARG: + case GI_INFO_TYPE_TYPE: + case GI_INFO_TYPE_UNRESOLVED: + default: + rb_raise(rb_eRuntimeError, + "TODO: returned value isn't object or struct"); + break; + } +} + +static VALUE +rg_invoke(VALUE self, VALUE rb_options) +{ + GIFunctionInfo *info; + GICallableInfo *callable_info; + VALUE receiver; + GIArgument return_value; + GITypeInfo return_value_info; + + info = SELF(self); + callable_info = (GICallableInfo *)info; + + rb_options = rbg_to_hash(rb_options); + receiver = rb_hash_delete(rb_options, ID2SYM(rb_intern("receiver"))); + if (NIL_P(receiver)) { + receiver = rb_hash_delete(rb_options, rb_str_new_cstr("receiver")); + } + if (NIL_P(receiver)) { + rb_raise(rb_eArgError, + "receiver is missing: %s", + RBG_INSPECT(rb_options)); + } + /* TODO: use rb_protect */ + rb_gi_function_info_invoke_raw(info, + rb_options, + &return_value); + + g_callable_info_load_return_type(callable_info, &return_value_info); + initialize_receiver(receiver, &return_value_info, &return_value); + + return receiver; +} + +void +rb_gi_constructor_info_init(VALUE rb_mGI, VALUE rb_cGIFunctionInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_CONSTRUCTOR_INFO, + "ConstructorInfo", rb_mGI, + rb_cGIFunctionInfo); + + RG_DEF_METHOD(invoke, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-conversions.h b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-conversions.h new file mode 100644 index 0000000..99a9f06 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-conversions.h @@ -0,0 +1,116 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012-2013 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef RB_GI_CONVERSIONS_H +#define RB_GI_CONVERSIONS_H + +#define RVAL2GI_REPOSITORY(rb_object) (G_IREPOSITORY(RVAL2GOBJ(rb_object))) +#define RVAL2GI_REPOSITORY_LOAD_FLAGS(rb_flags) \ + (RVAL2GFLAGS(rb_flags, G_TYPE_I_REPOSITORY_LOAD_FLAGS)) + +#define GI_BASE_INFO2RVAL(info) \ + (rb_gi_base_info_to_ruby((GIBaseInfo *)(info))) +#define GI_BASE_INFO2RVAL_WITH_UNREF(info) \ + (rb_gi_base_info_to_ruby_with_unref((GIBaseInfo *)(info))) +#define RVAL2GI_BASE_INFO(rb_object) (rb_gi_base_info_from_ruby(rb_object)) + +#define GI_ARGUMENT2RVAL(argument, type_info) \ + (rb_gi_argument_to_ruby((argument), (type_info))) +#define GI_OUT_ARGUMENT2RVAL(argument, arg_info) \ + (rb_gi_out_argument_to_ruby((argument), (arg_info))) +#define GI_RETURN_ARGUMENT2RVAL(argument, callable_info) \ + (rb_gi_return_argument_to_ruby((argument), (callable_info))) +#define RVAL2GI_VALUE_ARGUMENT(argument, type_info, rb_argument) \ + (rb_gi_value_argument_from_ruby((argument), (type_info), (rb_argument))) +#define RVAL2GI_IN_ARGUMENT(argument, arg_info, rb_argument) \ + (rb_gi_in_argument_from_ruby((argument), (arg_info), (rb_argument))) + + +#define RVAL2GI_REGISTERED_TYPE_INFO(rb_object) \ + ((GIRegisteredTypeInfo *)RVAL2GI_BASE_INFO(rb_object)) +#define RVAL2GI_FUNCTION_INFO(rb_object) \ + ((GIFunctionInfo *)RVAL2GI_BASE_INFO(rb_object)) +#define RVAL2GI_STRUCT_INFO(rb_object) \ + ((GIStructInfo *)RVAL2GI_BASE_INFO(rb_object)) +#define RVAL2GI_ENUM_INFO(rb_object) \ + ((GIEnumInfo *)RVAL2GI_BASE_INFO(rb_object)) +#define RVAL2GI_OBJECT_INFO(rb_object) \ + ((GIObjectInfo *)RVAL2GI_BASE_INFO(rb_object)) +#define RVAL2GI_INTERFACE_INFO(rb_object) \ + ((GIInterfaceInfo *)RVAL2GI_BASE_INFO(rb_object)) +#define RVAL2GI_CONSTANT_INFO(rb_object) \ + ((GIConstantInfo *)RVAL2GI_BASE_INFO(rb_object)) +#define RVAL2GI_UNION_INFO(rb_object) \ + ((GIUnionInfo *)RVAL2GI_BASE_INFO(rb_object)) +#define RVAL2GI_VALUE_INFO(rb_object) \ + ((GIValueInfo *)RVAL2GI_BASE_INFO(rb_object)) +#define RVAL2GI_ARG_INFO(rb_object) \ + ((GIArgInfo *)RVAL2GI_BASE_INFO(rb_object)) +#define RVAL2GI_FIELD_INFO(rb_object) \ + ((GIFieldInfo *)RVAL2GI_BASE_INFO(rb_object)) +#define RVAL2GI_TYPE_INFO(rb_object) \ + ((GITypeInfo *)RVAL2GI_BASE_INFO(rb_object)) + +#define GI_INFO_TYPE2RVAL(type) (GENUM2RVAL(type, G_TYPE_I_INFO_TYPE)) +#define GI_TRANSFER2RVAL(transfer) (GENUM2RVAL(transfer, G_TYPE_I_TRANSFER)) +#define GI_DIRECTION2RVAL(direction) (GENUM2RVAL(direction, G_TYPE_I_DIRECTION)) +#define GI_SCOPE_TYPE2RVAL(scope) (GENUM2RVAL(scope, G_TYPE_I_SCOPE_TYPE)) +#define RVAL2GI_TYPE_TAG(rb_tag) (RVAL2GENUM(rb_tag, G_TYPE_I_TYPE_TAG)) +#define GI_TYPE_TAG2RVAL(tag) (GENUM2RVAL(tag, G_TYPE_I_TYPE_TAG)) +#define GI_ARRAY_TYPE2RVAL(type) (rb_gi_array_type_to_ruby(type)) + +#define GI_FUNCTION_INFO_FLAGS2RVAL(tag) \ + (GFLAGS2RVAL(tag, G_TYPE_I_FUNCTION_INFO_FLAGS)) +#define GI_SIGNAL_FLAGS2RVAL(tag) \ + (GFLAGS2RVAL(tag, G_TYPE_SIGNAL_FLAGS)) +#define GI_VFUNC_INFO_FLAGS2RVAL(tag) \ + (GFLAGS2RVAL(tag, G_TYPE_IV_FUNC_INFO_FLAGS)) +#define GI_FIELD_INFO_FLAGS2RVAL(tag) \ + (GFLAGS2RVAL(tag, G_TYPE_I_FIELD_INFO_FLAGS)) + +VALUE rb_gi_base_info_to_ruby (GIBaseInfo *info); +VALUE rb_gi_base_info_to_ruby_with_unref(GIBaseInfo *info); +GIBaseInfo *rb_gi_base_info_from_ruby (VALUE rb_info); + +VALUE rb_gi_argument_to_ruby (GIArgument *argument, + GITypeInfo *type_info); +void rb_gi_out_argument_init (GIArgument *argument, + GIArgInfo *arg_info); +VALUE rb_gi_out_argument_to_ruby (GIArgument *argument, + GIArgInfo *arg_info); +void rb_gi_out_argument_fin (GIArgument *argument, + GIArgInfo *arg_info); +VALUE rb_gi_return_argument_to_ruby (GIArgument *argument, + GICallableInfo *callable_info); +GIArgument *rb_gi_value_argument_from_ruby (GIArgument *argument, + GITypeInfo *type_info, + VALUE rb_argument); +GIArgument *rb_gi_in_argument_from_ruby (GIArgument *argument, + GIArgInfo *arg_info, + VALUE rb_argument); +void rb_gi_value_argument_free (GIArgument *argument, + GITypeInfo *type_info); +void rb_gi_in_argument_free (GIArgument *argument, + GIArgInfo *arg_info); + +VALUE rb_gi_array_type_to_ruby (GIArrayType type); + +#endif + diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-enum-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-enum-info.c new file mode 100644 index 0000000..916f8d4 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-enum-info.c @@ -0,0 +1,145 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGIEnumInfo +#define SELF(self) (RVAL2GI_ENUM_INFO(self)) + +GType +gi_enum_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GIEnumInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +static VALUE +rg_n_values(VALUE self) +{ + GIEnumInfo *info; + + info = SELF(self); + return INT2NUM(g_enum_info_get_n_values(info)); +} + +static VALUE +rg_get_value(VALUE self, VALUE rb_n) +{ + GIEnumInfo *info; + gint n; + + info = SELF(self); + n = NUM2INT(rb_n); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_enum_info_get_value(info, n)); +} + +static VALUE +rg_values(VALUE self) +{ + GIEnumInfo *info; + gint i, n; + VALUE rb_values; + + info = SELF(self); + + rb_values = rb_ary_new(); + n = g_enum_info_get_n_values(info); + for (i = 0; i < n; i++) { + GIValueInfo *value_info; + value_info = g_enum_info_get_value(info, i); + rb_ary_push(rb_values, GI_BASE_INFO2RVAL_WITH_UNREF(value_info)); + } + + return rb_values; +} + +static VALUE +rg_n_methods(VALUE self) +{ + GIEnumInfo *info; + + info = SELF(self); + return INT2NUM(g_enum_info_get_n_methods(info)); +} + +static VALUE +rg_get_method(VALUE self, VALUE rb_n) +{ + GIEnumInfo *info; + gint n; + + info = SELF(self); + n = NUM2INT(rb_n); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_enum_info_get_method(info, n)); +} + +static VALUE +rg_methods(VALUE self) +{ + GIEnumInfo *info; + gint i, n; + VALUE rb_methods; + + info = SELF(self); + + rb_methods = rb_ary_new(); + n = g_enum_info_get_n_methods(info); + for (i = 0; i < n; i++) { + GIFunctionInfo *function_info; + function_info = g_enum_info_get_method(info, i); + rb_ary_push(rb_methods, GI_BASE_INFO2RVAL_WITH_UNREF(function_info)); + } + + return rb_methods; +} + +static VALUE +rg_storage_type(VALUE self) +{ + GIEnumInfo *info; + + info = SELF(self); + return GI_TYPE_TAG2RVAL(g_enum_info_get_storage_type(info)); +} + +void +rb_gi_enum_info_init(VALUE rb_mGI, VALUE rb_cGIRegisteredTypeInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_ENUM_INFO, "EnumInfo", rb_mGI, + rb_cGIRegisteredTypeInfo); + + RG_DEF_METHOD(n_values, 0); + RG_DEF_METHOD(get_value, 1); + RG_DEF_METHOD(values, 0); + RG_DEF_METHOD(n_methods, 0); + RG_DEF_METHOD(get_method, 1); + RG_DEF_METHOD(methods, 0); + RG_DEF_METHOD(storage_type, 0); + + rb_gi_flags_info_init(rb_mGI, RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-field-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-field-info.c new file mode 100644 index 0000000..ae7e43d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-field-info.c @@ -0,0 +1,153 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012-2013 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGIFieldInfo +#define SELF(self) (RVAL2GI_FIELD_INFO(self)) + +GType +gi_field_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GIFieldInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +static VALUE +rg_flags(VALUE self) +{ + GIFieldInfo *info; + + info = SELF(self); + return GI_FIELD_INFO_FLAGS2RVAL(g_field_info_get_flags(info)); +} + +static VALUE +rg_size(VALUE self) +{ + GIFieldInfo *info; + + info = SELF(self); + return INT2NUM(g_field_info_get_size(info)); +} + +static VALUE +rg_offset(VALUE self) +{ + GIFieldInfo *info; + + info = SELF(self); + return INT2NUM(g_field_info_get_offset(info)); +} + +static VALUE +rg_type(VALUE self) +{ + GIFieldInfo *info; + + info = SELF(self); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_field_info_get_type(info)); +} + +VALUE +rb_gi_field_info_get_field_raw(GIFieldInfo *info, gpointer memory) +{ + GIArgument argument; + GITypeInfo *type_info; + VALUE rb_field_value; + + if (!g_field_info_get_field(info, memory, &argument)) { + rb_raise(rb_eArgError, "failed to get field value"); + } + + type_info = g_field_info_get_type(info); + rb_field_value = GI_ARGUMENT2RVAL(&argument, type_info); + g_base_info_unref(type_info); + + return rb_field_value; +} + +void +rb_gi_field_info_set_field_raw(GIFieldInfo *info, gpointer memory, + VALUE rb_field_value) +{ + GIArgument field_value; + GITypeInfo *type_info; + gboolean succeeded; + + type_info = g_field_info_get_type(info); + RVAL2GI_VALUE_ARGUMENT(&field_value, type_info, rb_field_value); + + succeeded = g_field_info_set_field(info, memory, &field_value); + rb_gi_value_argument_free(&field_value, type_info); + g_base_info_unref(type_info); + + if (!succeeded) { + rb_raise(rb_eArgError, "failed to set field value"); + } +} + +static VALUE +rg_get_field(VALUE self, VALUE rb_memory) +{ + GIFieldInfo *info; + gpointer memory; + + info = SELF(self); + memory = GUINT_TO_POINTER(NUM2ULONG(rb_memory)); + return rb_gi_field_info_get_field_raw(info, memory); +} + +static VALUE +rg_set_field(VALUE self, VALUE rb_memory, VALUE rb_field_value) +{ + GIFieldInfo *info; + gpointer memory; + + info = SELF(self); + memory = GUINT_TO_POINTER(NUM2ULONG(rb_memory)); + rb_gi_field_info_set_field_raw(info, memory, rb_field_value); + + return Qnil; +} + +void +rb_gi_field_info_init(VALUE rb_mGI, VALUE rb_cGIBaseInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_FIELD_INFO, "FieldInfo", rb_mGI, + rb_cGIBaseInfo); + + RG_DEF_METHOD(flags, 0); + RG_DEF_METHOD(size, 0); + RG_DEF_METHOD(offset, 0); + RG_DEF_METHOD(type, 0); + RG_DEF_METHOD(get_field, 1); + RG_DEF_METHOD(set_field, 2); + + G_DEF_CLASS(G_TYPE_I_FIELD_INFO_FLAGS, "FieldInfoFlags", rb_mGI); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-flags-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-flags-info.c new file mode 100644 index 0000000..cb73942 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-flags-info.c @@ -0,0 +1,48 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGIFlagsInfo + +GType +gi_flags_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GIFlagsInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +void +rb_gi_flags_info_init(VALUE rb_mGI, VALUE rb_cGIEnumInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_FLAGS_INFO, "FlagsInfo", rb_mGI, + rb_cGIEnumInfo); + + /* Suppress a warning. */ + (void)RG_TARGET_NAMESPACE; +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-function-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-function-info.c new file mode 100644 index 0000000..507e66d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-function-info.c @@ -0,0 +1,764 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012-2013 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#ifdef HAVE_RUBY_THREAD_H +# include +# define RB_THREAD_CALL_WITHOUT_GVL_FUNC_RETURN_TYPE void * +# define RB_THREAD_CALL_WITHOUT_GVL_FUNC_RETURN_VALUE NULL +#else +# define rb_thread_call_without_gvl(func, func_data, ubf, ubf_data) \ + rb_thread_blocking_region(func, func_data, ubf, ubf_data) +# define RB_THREAD_CALL_WITHOUT_GVL_FUNC_RETURN_TYPE VALUE +# define RB_THREAD_CALL_WITHOUT_GVL_FUNC_RETURN_VALUE Qnil +#endif + +#define RG_TARGET_NAMESPACE rb_cGIFunctionInfo +#define SELF(self) RVAL2GI_FUNCTION_INFO(self) + +static VALUE RG_TARGET_NAMESPACE; +static VALUE rb_cGLibError; +static const char *callbacks_key = "gi_callbacks"; +static GPtrArray *callback_finders; + +GType +gi_function_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GIFunctionInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +static VALUE +rg_symbol(VALUE self) +{ + GIFunctionInfo *info; + + info = SELF(self); + return CSTR2RVAL(g_function_info_get_symbol(info)); +} + +static VALUE +rg_flags(VALUE self) +{ + GIFunctionInfo *info; + + info = SELF(self); + return GI_FUNCTION_INFO_FLAGS2RVAL(g_function_info_get_flags(info)); +} + +static VALUE +rg_property(VALUE self) +{ + GIFunctionInfo *info; + + info = SELF(self); + return GI_BASE_INFO2RVAL(g_function_info_get_property(info)); +} + +static VALUE +rg_vfunc(VALUE self) +{ + GIFunctionInfo *info; + + info = SELF(self); + return GI_BASE_INFO2RVAL(g_function_info_get_vfunc(info)); +} + +static void +allocate_arguments(GICallableInfo *info, + GArray *in_args, GArray *out_args, + GPtrArray *args_metadata) +{ + gint i, n_args; + gint rb_arg_index = 0; + + n_args = g_callable_info_get_n_args(info); + for (i = 0; i < n_args; i++) { + GIArgument argument; + RBGIArgMetadata *metadata; + GIArgInfo *arg_info; + GIDirection direction; + + memset(&argument, 0, sizeof(GIArgument)); + + metadata = ALLOC(RBGIArgMetadata); + arg_info = &(metadata->arg_info); + g_callable_info_load_arg(info, i, arg_info); + metadata->scope_type = g_arg_info_get_scope(arg_info); + metadata->direction = g_arg_info_get_direction(arg_info); + metadata->callback_p = (metadata->scope_type != GI_SCOPE_TYPE_INVALID); + metadata->closure_p = FALSE; + metadata->destroy_p = FALSE; + metadata->inout_argv_p = FALSE; + metadata->in_arg_index = -1; + metadata->closure_in_arg_index = -1; + metadata->destroy_in_arg_index = -1; + metadata->rb_arg_index = -1; + metadata->out_arg_index = -1; + metadata->inout_argc_arg_index = -1; + + direction = metadata->direction; + if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) { + metadata->in_arg_index = in_args->len; + g_array_append_val(in_args, argument); + metadata->rb_arg_index = rb_arg_index++; + } + if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) { + metadata->out_arg_index = out_args->len; + g_array_append_val(out_args, argument); + } + + g_ptr_array_add(args_metadata, metadata); + } +} + +static void +fill_metadata_inout_argv(GPtrArray *args_metadata) +{ + guint i; + gint inout_argc_arg_index = -1; + + for (i = 0; i < args_metadata->len; i++) { + RBGIArgMetadata *metadata; + GIArgInfo *arg_info; + const gchar *name; + + metadata = g_ptr_array_index(args_metadata, i); + if (metadata->direction != GI_DIRECTION_INOUT) { + continue; + } + arg_info = &(metadata->arg_info); + name = g_base_info_get_name(arg_info); + if (strcmp(name, "argc") == 0) { + inout_argc_arg_index = i; + } else if (strcmp(name, "argv") == 0) { + metadata->inout_argv_p = TRUE; + metadata->inout_argc_arg_index = inout_argc_arg_index; + } + } +} + +static void +fill_metadata_callback(GPtrArray *args_metadata) +{ + guint i; + + for (i = 0; i < args_metadata->len; i++) { + RBGIArgMetadata *metadata; + GIArgInfo *arg_info; + gint closure_index; + gint destroy_index; + + metadata = g_ptr_array_index(args_metadata, i); + if (!metadata->callback_p) { + continue; + } + + arg_info = &(metadata->arg_info); + closure_index = g_arg_info_get_closure(arg_info); + if (closure_index != -1) { + RBGIArgMetadata *closure_metadata; + closure_metadata = g_ptr_array_index(args_metadata, closure_index); + closure_metadata->closure_p = TRUE; + metadata->closure_in_arg_index = closure_metadata->in_arg_index; + closure_metadata->rb_arg_index = -1; + } + + destroy_index = g_arg_info_get_destroy(arg_info); + if (destroy_index != -1) { + RBGIArgMetadata *destroy_metadata; + destroy_metadata = g_ptr_array_index(args_metadata, destroy_index); + destroy_metadata->destroy_p = TRUE; + metadata->destroy_in_arg_index = destroy_metadata->in_arg_index; + destroy_metadata->rb_arg_index = -1; + } + } +} + +static void +fill_metadata(GPtrArray *args_metadata) +{ + fill_metadata_inout_argv(args_metadata); + fill_metadata_callback(args_metadata); +} + +static void +callback_data_guard_from_gc(RBGICallbackData *callback_data) +{ + VALUE rb_callbacks; + + rb_callbacks = rb_iv_get(RG_TARGET_NAMESPACE, callbacks_key); + callback_data->rb_gc_guard_key = rb_class_new_instance(0, NULL, rb_cObject); + rb_hash_aset(rb_callbacks, + callback_data->rb_gc_guard_key, + callback_data->rb_callback); +} + +static void +callback_data_unguard_from_gc(RBGICallbackData *callback_data) +{ + VALUE rb_callbacks; + + rb_callbacks = rb_iv_get(RG_TARGET_NAMESPACE, callbacks_key); + rb_hash_delete(rb_callbacks, callback_data->rb_gc_guard_key); +} + +void +rb_gi_callback_data_free(RBGICallbackData *callback_data) +{ + callback_data_unguard_from_gc(callback_data); + xfree(callback_data->metadata); + xfree(callback_data); +} + +static void +destroy_notify(gpointer data) +{ + RBGICallbackData *callback_data = data; + rb_gi_callback_data_free(callback_data); +} + +static gpointer +find_callback_function(GIArgInfo *info) +{ + guint i; + gpointer callback = NULL; + + for (i = 0; i < callback_finders->len; i++) { + RBGICallbackFinderFunc finder = g_ptr_array_index(callback_finders, i); + callback = finder(info); + if (callback) { + break; + } + } + + return callback; +} + +void +rb_gi_callback_register_finder(RBGICallbackFinderFunc finder) +{ + g_ptr_array_add(callback_finders, finder); +} + +static gboolean +source_func_p(GIArgInfo *info) +{ + GITypeInfo type_info; + GIBaseInfo *interface_info; + GICallableInfo *callback_info; + GITypeInfo return_type_info; + GIArgInfo first_arg_info; + GITypeInfo first_arg_type_info; + + g_arg_info_load_type(info, &type_info); + if (g_type_info_get_tag(&type_info) != GI_TYPE_TAG_INTERFACE) { + return FALSE; + } + + interface_info = g_type_info_get_interface(&type_info); + if (g_base_info_get_type(interface_info) != GI_INFO_TYPE_CALLBACK) { + g_base_info_unref(interface_info); + return FALSE; + } + + callback_info = (GICallableInfo *)interface_info; + g_callable_info_load_return_type(callback_info, &return_type_info); + if (g_type_info_get_tag(&return_type_info) != GI_TYPE_TAG_BOOLEAN) { + g_base_info_unref(interface_info); + return FALSE; + } + + if (g_callable_info_get_n_args(interface_info) != 1) { + g_base_info_unref(interface_info); + return FALSE; + } + + g_callable_info_load_arg(interface_info, 0, &first_arg_info); + g_arg_info_load_type(&first_arg_info, &first_arg_type_info); + if (g_type_info_get_tag(&first_arg_type_info) != GI_TYPE_TAG_VOID) { + g_base_info_unref(interface_info); + return FALSE; + } + + g_base_info_unref(interface_info); + return TRUE; +} + +static gboolean +source_func_callback(gpointer user_data) +{ + RBGICallbackData *callback_data = user_data; + VALUE rb_keep; + ID id_call; + + CONST_ID(id_call, "call"); + rb_keep = rb_funcall(callback_data->rb_callback, id_call, 0); + if (callback_data->metadata->scope_type == GI_SCOPE_TYPE_ASYNC) { + rb_gi_callback_data_free(callback_data); + } + return RVAL2CBOOL(rb_keep); +} + +static gpointer +source_func_callback_finder(GIArgInfo *arg_info) +{ + if (!source_func_p(arg_info)) { + return NULL; + } + return source_func_callback; +} + +static void +in_callback_argument_from_ruby(RBGIArgMetadata *metadata, GArray *in_args) +{ + gpointer callback; + GIArgInfo *arg_info; + GIArgument *callback_argument; + + arg_info = &(metadata->arg_info); + callback = find_callback_function(arg_info); + if (!callback) { + GITypeInfo type_info; + GIBaseInfo *interface_info; + VALUE rb_type_name; + g_arg_info_load_type(arg_info, &type_info); + interface_info = g_type_info_get_interface(&type_info); + rb_type_name = CSTR2RVAL(g_base_info_get_name(interface_info)); + g_base_info_unref(interface_info); + rb_raise(rb_eNotImpError, + "TODO: <%s>(%s) callback is not supported yet.", + RVAL2CSTR(rb_type_name), + g_base_info_get_name(arg_info)); + } + + callback_argument = &(g_array_index(in_args, + GIArgument, + metadata->in_arg_index)); + callback_argument->v_pointer = callback; + + if (metadata->closure_in_arg_index != -1) { + RBGICallbackData *callback_data; + GIArgument *closure_argument; + + callback_data = ALLOC(RBGICallbackData); + callback_data->metadata = metadata; + callback_data->rb_callback = rb_block_proc(); + callback_data_guard_from_gc(callback_data); + closure_argument = &(g_array_index(in_args, + GIArgument, + metadata->closure_in_arg_index)); + closure_argument->v_pointer = callback_data; + } + + if (metadata->destroy_in_arg_index != -1) { + GIArgument *destroy_argument; + destroy_argument = &(g_array_index(in_args, + GIArgument, + metadata->destroy_in_arg_index)); + destroy_argument->v_pointer = destroy_notify; + } +} + +static void +in_argument_from_ruby(RBGIArgMetadata *metadata, VALUE rb_arguments, + GArray *in_args) +{ + if (metadata->rb_arg_index == -1) { + return; + } + + if (metadata->callback_p) { + in_callback_argument_from_ruby(metadata, in_args); + } else { + GIArgument *argument; + VALUE rb_argument = Qnil; + + if (RARRAY_LEN(rb_arguments) > metadata->rb_arg_index) { + rb_argument = RARRAY_PTR(rb_arguments)[metadata->rb_arg_index]; + } + argument = &(g_array_index(in_args, GIArgument, metadata->in_arg_index)); + RVAL2GI_IN_ARGUMENT(argument, + &(metadata->arg_info), + rb_argument); + } +} + +static void +out_argument_from_ruby(RBGIArgMetadata *metadata, GArray *out_args) +{ + GIArgument *argument; + + argument = &(g_array_index(out_args, GIArgument, metadata->out_arg_index)); + rb_gi_out_argument_init(argument, &(metadata->arg_info)); +} + +static void +arg_metadata_free(gpointer data) +{ + RBGIArgMetadata *metadata = data; + if (metadata->scope_type == GI_SCOPE_TYPE_ASYNC || + metadata->scope_type == GI_SCOPE_TYPE_NOTIFIED) { + return; + } + xfree(metadata); +} + +static void +arguments_from_ruby(GICallableInfo *info, VALUE rb_arguments, + GArray *in_args, GArray *out_args, + GPtrArray *args_metadata) +{ + gint i, n_args; + + allocate_arguments(info, in_args, out_args, args_metadata); + fill_metadata(args_metadata); + + n_args = g_callable_info_get_n_args(info); + for (i = 0; i < n_args; i++) { + RBGIArgMetadata *metadata; + + metadata = g_ptr_array_index(args_metadata, i); + if (metadata->in_arg_index != -1) { + in_argument_from_ruby(metadata, rb_arguments, in_args); + } else { + out_argument_from_ruby(metadata, out_args); + } + } +} + +static VALUE +inout_argv_argument_to_ruby(GArray *in_args, RBGIArgMetadata *metadata) +{ + GIArgument *inout_argc_argument; + GIArgument *inout_argv_argument; + gint i, argc; + gchar **argv; + VALUE rb_argv_argument; + + inout_argc_argument = &g_array_index(in_args, GIArgument, + metadata->inout_argc_arg_index); + inout_argv_argument = &g_array_index(in_args, GIArgument, + metadata->in_arg_index); + argc = *((gint *)(inout_argc_argument->v_pointer)); + argv = *((gchar ***)(inout_argv_argument->v_pointer)); + rb_argv_argument = rb_ary_new2(argc); + for (i = 0; i < argc; i++) { + rb_ary_push(rb_argv_argument, CSTR2RVAL(argv[i])); + } + return rb_argv_argument; +} + +static VALUE +out_arguments_to_ruby(GICallableInfo *callable_info, + GArray *in_args, GArray *out_args, + GPtrArray *args_metadata) +{ + gint i, n_args; + VALUE rb_out_args; + + rb_out_args = rb_ary_new(); + n_args = g_callable_info_get_n_args(callable_info); + for (i = 0; i < n_args; i++) { + RBGIArgMetadata *metadata; + GIArgument *argument = NULL; + VALUE rb_argument; + + metadata = g_ptr_array_index(args_metadata, i); + switch (metadata->direction) { + case GI_DIRECTION_IN: + break; + case GI_DIRECTION_OUT: + argument = &g_array_index(out_args, GIArgument, + metadata->out_arg_index); + break; + case GI_DIRECTION_INOUT: + argument = &g_array_index(in_args, GIArgument, + metadata->in_arg_index); + break; + default: + g_assert_not_reached(); + break; + } + + if (!argument) { + continue; + } + + if (metadata->inout_argv_p) { + rb_argument = inout_argv_argument_to_ruby(in_args, metadata); + } else { + rb_argument = GI_OUT_ARGUMENT2RVAL(argument, &(metadata->arg_info)); + } + rb_ary_push(rb_out_args, rb_argument); + } + + if (RARRAY_LEN(rb_out_args) == 0) { + return Qnil; + } else { + return rb_out_args; + } +} + +static void +arguments_init(GArray **in_args, GArray **out_args, GPtrArray **args_metadata) +{ + *in_args = g_array_new(FALSE, FALSE, sizeof(GIArgument)); + *out_args = g_array_new(FALSE, FALSE, sizeof(GIArgument)); + *args_metadata = g_ptr_array_new_with_free_func(arg_metadata_free); +} + +static void +arguments_free(GArray *in_args, GArray *out_args, GPtrArray *args_metadata) +{ + guint i; + + for (i = 0; i < args_metadata->len; i++) { + RBGIArgMetadata *metadata; + gint in_arg_index; + + metadata = g_ptr_array_index(args_metadata, i); + if (metadata->direction == GI_DIRECTION_IN || + metadata->direction == GI_DIRECTION_INOUT) { + in_arg_index = metadata->in_arg_index; + if (in_arg_index != -1) { + GIArgument *argument; + argument = &(g_array_index(in_args, GIArgument, in_arg_index)); + rb_gi_in_argument_free(argument, &(metadata->arg_info)); + } + } else { + GIArgument *argument; + argument = &(g_array_index(out_args, GIArgument, + metadata->out_arg_index)); + rb_gi_out_argument_fin(argument, &(metadata->arg_info)); + } + } + + g_array_unref(in_args); + g_array_unref(out_args); + g_ptr_array_unref(args_metadata); +} + +typedef struct { + GIFunctionInfo *info; + GArray *in_args; + GArray *out_args; + GIArgument *return_value; + GError **error; + gboolean succeeded; +} InvokeData; + +static void +rb_gi_function_info_invoke_raw_call(InvokeData *data) +{ + data->succeeded = + g_function_info_invoke(data->info, + (GIArgument *)(data->in_args->data), + data->in_args->len, + (GIArgument *)(data->out_args->data), + data->out_args->len, + data->return_value, + data->error); +} + +static RB_THREAD_CALL_WITHOUT_GVL_FUNC_RETURN_TYPE +rb_gi_function_info_invoke_raw_call_without_gvl_body(void *user_data) +{ + InvokeData *data = (InvokeData *)user_data; + + rb_gi_function_info_invoke_raw_call(data); + + return RB_THREAD_CALL_WITHOUT_GVL_FUNC_RETURN_VALUE; +} + +static gboolean +gobject_based_p(GIBaseInfo *info) +{ + GIBaseInfo *container_info; + GIRegisteredTypeInfo *registered_type_info; + + container_info = g_base_info_get_container(info); + if (g_base_info_get_type(container_info) != GI_INFO_TYPE_STRUCT) { + return TRUE; + } + + registered_type_info = (GIRegisteredTypeInfo *)container_info; + if (g_registered_type_info_get_type_init(registered_type_info)) { + return TRUE; + } + + return FALSE; +} + +VALUE +rb_gi_function_info_invoke_raw(GIFunctionInfo *info, VALUE rb_options, + GIArgument *return_value) +{ + GICallableInfo *callable_info; + GIArgument receiver; + GArray *in_args, *out_args; + GPtrArray *args_metadata; + VALUE rb_out_args = Qnil; + gboolean succeeded; + GError *error = NULL; + gboolean unlock_gvl = FALSE; + VALUE rb_receiver, rb_arguments, rb_unlock_gvl; + + if (RB_TYPE_P(rb_options, RUBY_T_ARRAY)) { + rb_receiver = Qnil; + rb_arguments = rb_options; + rb_unlock_gvl = Qnil; + } else if (NIL_P(rb_options)) { + rb_receiver = Qnil; + rb_arguments = rb_ary_new(); + rb_unlock_gvl = Qnil; + } else { + rb_options = rbg_check_hash_type(rb_options); + rbg_scan_options(rb_options, + "receiver", &rb_receiver, + "arguments", &rb_arguments, + "unlock_gvl", &rb_unlock_gvl, + NULL); + } + + if (NIL_P(rb_receiver)) { + receiver.v_pointer = NULL; + } else { + if (gobject_based_p((GIBaseInfo *)info)) { + receiver.v_pointer = RVAL2GOBJ(rb_receiver); + } else { + receiver.v_pointer = DATA_PTR(rb_receiver); + } + } + rb_arguments = rbg_to_array(rb_arguments); + if (!NIL_P(rb_unlock_gvl) && RVAL2CBOOL(rb_unlock_gvl)) { + unlock_gvl = TRUE; + } + + callable_info = (GICallableInfo *)info; + arguments_init(&in_args, &out_args, &args_metadata); + if (receiver.v_pointer) { + g_array_append_val(in_args, receiver); + } + arguments_from_ruby(callable_info, rb_arguments, + in_args, out_args, args_metadata); + { + InvokeData data; + data.info = info; + data.in_args = in_args; + data.out_args = out_args; + data.return_value = return_value; + data.error = &error; + if (unlock_gvl) { + rb_thread_call_without_gvl( + rb_gi_function_info_invoke_raw_call_without_gvl_body, &data, + NULL, NULL); + } else { + rb_gi_function_info_invoke_raw_call(&data); + } + succeeded = data.succeeded; + } + + if (succeeded) { + rb_out_args = out_arguments_to_ruby(callable_info, + in_args, out_args, + args_metadata); + } + arguments_free(in_args, out_args, args_metadata); + if (!succeeded) { + RG_RAISE_ERROR(error); + } + + if (!NIL_P(rb_out_args) && RARRAY_LEN(rb_out_args) == 1) { + VALUE rb_out_arg; + rb_out_arg = RARRAY_PTR(rb_out_args)[0]; + if (rb_obj_is_kind_of(rb_out_arg, rb_cGLibError)) { + rb_exc_raise(rb_out_arg); + } + } + + return rb_out_args; +} + +static VALUE +rg_invoke(VALUE self, VALUE rb_options) +{ + GIFunctionInfo *info; + GICallableInfo *callable_info; + GIArgument return_value; + VALUE rb_out_args; + VALUE rb_return_value; + + info = SELF(self); + /* TODO: use rb_protect() */ + rb_out_args = rb_gi_function_info_invoke_raw(info, + rb_options, + &return_value); + + callable_info = (GICallableInfo *)info; + rb_return_value = GI_RETURN_ARGUMENT2RVAL(&return_value, callable_info); + + if (NIL_P(rb_out_args)) { + return rb_return_value; + } else { + GITypeInfo return_value_info; + g_callable_info_load_return_type(callable_info, &return_value_info); + if (g_type_info_get_tag(&return_value_info) != GI_TYPE_TAG_VOID) { + rb_ary_unshift(rb_out_args, rb_return_value); + } + if (RARRAY_LEN(rb_out_args) == 1) { + return RARRAY_PTR(rb_out_args)[0]; + } else { + return rb_out_args; + } + } +} + +void +rb_gi_function_info_init(VALUE rb_mGI, VALUE rb_cGICallableInfo) +{ + rb_cGLibError = rb_const_get(mGLib, rb_intern("Error")); + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_FUNCTION_INFO, "FunctionInfo", rb_mGI, + rb_cGICallableInfo); + + rb_iv_set(RG_TARGET_NAMESPACE, callbacks_key, rb_hash_new()); + + callback_finders = g_ptr_array_new(); + rb_gi_callback_register_finder(source_func_callback_finder); + + RG_DEF_METHOD(symbol, 0); + RG_DEF_METHOD(flags, 0); + RG_DEF_METHOD(property, 0); + RG_DEF_METHOD(vfunc, 0); + RG_DEF_METHOD(invoke, 1); + + G_DEF_CLASS(G_TYPE_I_FUNCTION_INFO_FLAGS, "FunctionInfoFlags", rb_mGI); + + rb_gi_method_info_init(rb_mGI, RG_TARGET_NAMESPACE); + rb_gi_constructor_info_init(rb_mGI, RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-interface-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-interface-info.c new file mode 100644 index 0000000..e7304f7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-interface-info.c @@ -0,0 +1,222 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGIInterfaceInfo +#define SELF(self) (RVAL2GI_INTERFACE_INFO(self)) + +GType +gi_interface_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GIInterfaceInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +static VALUE +rg_n_prerequisites(VALUE self) +{ + GIInterfaceInfo *info; + + info = SELF(self); + return INT2NUM(g_interface_info_get_n_prerequisites(info)); +} + +static VALUE +rg_get_prerequisite(VALUE self, VALUE rb_n) +{ + GIInterfaceInfo *info; + gint n; + + info = SELF(self); + n = NUM2INT(rb_n); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_interface_info_get_prerequisite(info, n)); +} + +static VALUE +rg_n_properties(VALUE self) +{ + GIInterfaceInfo *info; + + info = SELF(self); + return INT2NUM(g_interface_info_get_n_properties(info)); +} + +static VALUE +rg_get_property(VALUE self, VALUE rb_n) +{ + GIInterfaceInfo *info; + gint n; + + info = SELF(self); + n = NUM2INT(rb_n); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_interface_info_get_property(info, n)); +} + +static VALUE +rg_n_methods(VALUE self) +{ + GIInterfaceInfo *info; + + info = SELF(self); + return INT2NUM(g_interface_info_get_n_methods(info)); +} + +static VALUE +rg_get_method(VALUE self, VALUE rb_n_or_name) +{ + GIInterfaceInfo *info; + GIFunctionInfo *function_info; + + info = SELF(self); + if (RB_TYPE_P(rb_n_or_name, T_FIXNUM)) { + gint n; + n = NUM2INT(rb_n_or_name); + function_info = g_interface_info_get_method(info, n); + } else { + const char *name; + name = RVAL2CSTR(rb_n_or_name); + function_info = g_interface_info_find_method(info, name); + } + + return GI_BASE_INFO2RVAL_WITH_UNREF(function_info); +} + +static VALUE +rg_n_signals(VALUE self) +{ + GIInterfaceInfo *info; + + info = SELF(self); + return INT2NUM(g_interface_info_get_n_signals(info)); +} + +static VALUE +rg_get_signal(VALUE self, VALUE rb_n_or_name) +{ + GIInterfaceInfo *info; + GISignalInfo *signal_info; + + info = SELF(self); + if (RB_TYPE_P(rb_n_or_name, T_FIXNUM)) { + gint n; + n = NUM2INT(rb_n_or_name); + signal_info = g_interface_info_get_signal(info, n); + } else { +#ifdef HAVE_G_INTERFACE_INFO_FIND_SIGNAL + const char *name; + name = RVAL2CSTR(rb_n_or_name); + signal_info = g_interface_info_find_signal(info, name); +#else + rb_raise(rb_eArgError, + "g_interface_info_find_signal() is defined " + "since GObjectIntrospection 1.34"); +#endif + } + + return GI_BASE_INFO2RVAL_WITH_UNREF(signal_info); +} + +static VALUE +rg_n_vfuncs(VALUE self) +{ + GIInterfaceInfo *info; + + info = SELF(self); + return INT2NUM(g_interface_info_get_n_vfuncs(info)); +} + +static VALUE +rg_get_vfunc(VALUE self, VALUE rb_n_or_name) +{ + GIInterfaceInfo *info; + GIVFuncInfo *vfunc_info; + + info = SELF(self); + if (RB_TYPE_P(rb_n_or_name, T_FIXNUM)) { + gint n; + n = NUM2INT(rb_n_or_name); + vfunc_info = g_interface_info_get_vfunc(info, n); + } else { + const gchar *name; + name = RVAL2CSTR(rb_n_or_name); + vfunc_info = g_interface_info_find_vfunc(info, name); + } + + return GI_BASE_INFO2RVAL_WITH_UNREF(vfunc_info); +} + +static VALUE +rg_n_constants(VALUE self) +{ + GIInterfaceInfo *info; + + info = SELF(self); + return INT2NUM(g_interface_info_get_n_constants(info)); +} + +static VALUE +rg_get_constant(VALUE self, VALUE rb_n) +{ + GIInterfaceInfo *info; + gint n; + + info = SELF(self); + n = NUM2INT(rb_n); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_interface_info_get_constant(info, n)); +} + +static VALUE +rg_iface_struct(VALUE self) +{ + GIInterfaceInfo *info; + + info = SELF(self); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_interface_info_get_iface_struct(info)); +} + +void +rb_gi_interface_info_init(VALUE rb_mGI, VALUE rb_cGIRegisteredTypeInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_INTERFACE_INFO, "InterfaceInfo", rb_mGI, + rb_cGIRegisteredTypeInfo); + + RG_DEF_METHOD(n_prerequisites, 0); + RG_DEF_METHOD(get_prerequisite, 1); + RG_DEF_METHOD(n_properties, 0); + RG_DEF_METHOD(get_property, 1); + RG_DEF_METHOD(n_methods, 0); + RG_DEF_METHOD(get_method, 1); + RG_DEF_METHOD(n_signals, 0); + RG_DEF_METHOD(get_signal, 1); + RG_DEF_METHOD(n_vfuncs, 0); + RG_DEF_METHOD(get_vfunc, 1); + RG_DEF_METHOD(n_constants, 0); + RG_DEF_METHOD(get_constant, 1); + RG_DEF_METHOD(iface_struct, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-loader.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-loader.c new file mode 100644 index 0000000..a2fd53d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-loader.c @@ -0,0 +1,162 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012-2013 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGILoader + +static const gchar *boxed_class_converters_name = "@@boxed_class_converters"; + +static VALUE +rg_s_define_class(int argc, VALUE *argv, G_GNUC_UNUSED VALUE klass) +{ + VALUE rb_gtype, rb_name, rb_module; + VALUE rb_options, rb_parent; + GType gtype; + + rb_scan_args(argc, argv, "31", &rb_gtype, &rb_name, &rb_module, &rb_options); + rbg_scan_options(rb_options, + "parent", &rb_parent, + NULL); + + gtype = NUM2ULONG(rb_to_int(rb_gtype)); + return G_DEF_CLASS_WITH_PARENT(gtype, RVAL2CSTR(rb_name), + rb_module, rb_parent); +} + +static VALUE +rg_s_define_interface(G_GNUC_UNUSED VALUE klass, + VALUE rb_gtype, VALUE rb_name, VALUE rb_module) +{ + GType gtype; + + gtype = NUM2ULONG(rb_to_int(rb_gtype)); + return G_DEF_INTERFACE(gtype, RVAL2CSTR(rb_name), rb_module); +} + +static VALUE +struct_alloc(VALUE klass) +{ + VALUE rb_size; + + rb_size = rb_iv_get(klass, "@size"); + return Data_Wrap_Struct(klass, NULL, xfree, xmalloc(NUM2ULONG(rb_size))); +} + +static VALUE +rg_s_define_struct(int argc, VALUE *argv, G_GNUC_UNUSED VALUE klass) +{ + VALUE rb_size, rb_name, rb_module; + VALUE rb_options, rb_parent; + VALUE rb_class; + + rb_scan_args(argc, argv, "31", &rb_size, &rb_name, &rb_module, &rb_options); + rbg_scan_options(rb_options, + "parent", &rb_parent, + NULL); + + rb_size = rb_to_int(rb_size); + if (NIL_P(rb_parent)) { + rb_parent = rb_cObject; + } + rb_class = rb_define_class_under(rb_module, RVAL2CSTR(rb_name), rb_parent); + rb_iv_set(rb_class, "@size", rb_size); + rb_define_alloc_func(rb_class, struct_alloc); + return rb_class; +} + +typedef struct { + GType type; + VALUE rb_converters; + VALUE rb_converter; +} BoxedInstance2RObjData; + +static void +boxed_class_converter_free(gpointer user_data) +{ + BoxedInstance2RObjData *data = user_data; + rb_ary_delete(data->rb_converters, data->rb_converter); + g_free(data); +} + +static VALUE +boxed_instance2robj(gpointer instance, gpointer user_data) +{ + BoxedInstance2RObjData *data = user_data; + VALUE default_rb_instance; + VALUE klass; + gint flags = 0; + ID id_call; + + default_rb_instance = rbgobj_make_boxed_default(instance, data->type); + CONST_ID(id_call, "call"); + klass = rb_funcall(data->rb_converter, id_call, 1, default_rb_instance); + return rbgobj_make_boxed_raw(instance, data->type, klass, flags); +} + +static VALUE +rg_s_register_boxed_class_converter(VALUE klass, VALUE rb_gtype) +{ + RGConvertTable table; + BoxedInstance2RObjData *data; + ID id_to_i; + VALUE boxed_class_converters; + + memset(&table, 0, sizeof(RGConvertTable)); + CONST_ID(id_to_i, "to_i"); + table.type = NUM2UINT(rb_funcall(rb_gtype, id_to_i, 0)); + table.klass = Qnil; + table.instance2robj = boxed_instance2robj; + + data = g_new(BoxedInstance2RObjData, 1); + data->type = table.type; + data->rb_converter = rb_block_proc(); + boxed_class_converters = rb_cv_get(klass, boxed_class_converters_name); + rb_ary_push(boxed_class_converters, data->rb_converter); + table.user_data = data; + table.notify = boxed_class_converter_free; + + rbgobj_convert_define(&table); + + return Qnil; +} + +static VALUE +rg_s_start_callback_dispatch_thread(G_GNUC_UNUSED VALUE klass) +{ + rbgutil_start_callback_dispatch_thread(); + return Qnil; +} + +void +rb_gi_loader_init(VALUE rb_mGI) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = rb_define_class_under(rb_mGI, "Loader", rb_cObject); + + rb_cv_set(RG_TARGET_NAMESPACE, boxed_class_converters_name, rb_ary_new()); + + RG_DEF_SMETHOD(define_class, -1); + RG_DEF_SMETHOD(define_interface, 3); + RG_DEF_SMETHOD(define_struct, -1); + RG_DEF_SMETHOD(register_boxed_class_converter, 1); + RG_DEF_SMETHOD(start_callback_dispatch_thread, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-method-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-method-info.c new file mode 100644 index 0000000..7e80524 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-method-info.c @@ -0,0 +1,83 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012-2013 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGIMethodInfo +#define SELF(self) RVAL2GI_FUNCTION_INFO(self) + +GType +gi_method_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GIMethodInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +static VALUE +rg_invoke(VALUE self, VALUE rb_options) +{ + GIFunctionInfo *info; + GICallableInfo *callable_info; + GIArgument return_value; + VALUE rb_out_args; + VALUE rb_return_value; + + info = SELF(self); + + /* TODO: use rb_protect */ + rb_out_args = rb_gi_function_info_invoke_raw(info, + rb_options, + &return_value); + + callable_info = (GICallableInfo *)info; + rb_return_value = GI_RETURN_ARGUMENT2RVAL(&return_value, callable_info); + + if (NIL_P(rb_out_args)) { + return rb_return_value; + } else { + GITypeInfo return_value_info; + g_callable_info_load_return_type(callable_info, &return_value_info); + if (g_type_info_get_tag(&return_value_info) != GI_TYPE_TAG_VOID) { + rb_ary_unshift(rb_out_args, rb_return_value); + } + if (RARRAY_LEN(rb_out_args) == 1) { + return RARRAY_PTR(rb_out_args)[0]; + } else { + return rb_out_args; + } + } +} + +void +rb_gi_method_info_init(VALUE rb_mGI, VALUE rb_cGIFunctionInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_METHOD_INFO, "MethodInfo", rb_mGI, + rb_cGIFunctionInfo); + + RG_DEF_METHOD(invoke, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-object-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-object-info.c new file mode 100644 index 0000000..e1a8e61 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-object-info.c @@ -0,0 +1,345 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGIObjectInfo +#define SELF(self) (RVAL2GI_OBJECT_INFO(self)) + +GType +gi_object_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GIObjectInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +static VALUE +rg_type_name(VALUE self) +{ + GIObjectInfo *info; + + info = SELF(self); + return CSTR2RVAL(g_object_info_get_type_name(info)); +} + +static VALUE +rg_type_init(VALUE self) +{ + GIObjectInfo *info; + + info = SELF(self); + return CSTR2RVAL(g_object_info_get_type_init(info)); +} + +static VALUE +rg_abstract_p(VALUE self) +{ + GIObjectInfo *info; + + info = SELF(self); + return CBOOL2RVAL(g_object_info_get_abstract(info)); +} + +static VALUE +rg_fundamental_p(VALUE self) +{ + GIObjectInfo *info; + + info = SELF(self); + return CBOOL2RVAL(g_object_info_get_fundamental(info)); +} + +static VALUE +rg_parent(VALUE self) +{ + GIObjectInfo *info; + + info = SELF(self); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_object_info_get_parent(info)); +} + +static VALUE +rg_n_interfaces(VALUE self) +{ + GIObjectInfo *info; + + info = SELF(self); + return INT2NUM(g_object_info_get_n_interfaces(info)); +} + +static VALUE +rg_get_interface(VALUE self, VALUE rb_n) +{ + GIObjectInfo *info; + gint n; + + info = SELF(self); + n = NUM2INT(rb_n); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_object_info_get_interface(info, n)); +} + +static VALUE +rg_n_fields(VALUE self) +{ + GIObjectInfo *info; + + info = SELF(self); + return INT2NUM(g_object_info_get_n_fields(info)); +} + +static VALUE +rg_get_field(VALUE self, VALUE rb_n) +{ + GIObjectInfo *info; + gint n; + + info = SELF(self); + n = NUM2INT(rb_n); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_object_info_get_field(info, n)); +} + +static VALUE +rg_get_field_value(VALUE self, VALUE rb_object, VALUE rb_n) +{ + GIObjectInfo *info; + gint n; + GIFieldInfo *field_info; + VALUE rb_value; + + info = SELF(self); + n = NUM2INT(rb_n); + field_info = g_object_info_get_field(info, n); + rb_value = rb_gi_field_info_get_field_raw(field_info, RVAL2GOBJ(rb_object)); + g_base_info_unref(field_info); + + return rb_value; +} + +static VALUE +rg_set_field_value(VALUE self, VALUE rb_object, VALUE rb_n, VALUE rb_value) +{ + GIObjectInfo *info; + gint n; + GIFieldInfo *field_info; + + info = SELF(self); + n = NUM2INT(rb_n); + field_info = g_object_info_get_field(info, n); + rb_gi_field_info_set_field_raw(field_info, RVAL2GOBJ(rb_object), rb_value); + /* TODO: use rb_ensure() to unref field_info. */ + g_base_info_unref(field_info); + + return Qnil; +} + +static VALUE +rg_n_properties(VALUE self) +{ + GIObjectInfo *info; + + info = SELF(self); + return INT2NUM(g_object_info_get_n_properties(info)); +} + +static VALUE +rg_get_property(VALUE self, VALUE rb_n) +{ + GIObjectInfo *info; + gint n; + + info = SELF(self); + n = NUM2INT(rb_n); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_object_info_get_property(info, n)); +} + +static VALUE +rg_n_methods(VALUE self) +{ + GIObjectInfo *info; + + info = SELF(self); + return INT2NUM(g_object_info_get_n_methods(info)); +} + +static VALUE +rg_get_method(VALUE self, VALUE rb_n_or_name) +{ + GIObjectInfo *info; + GIFunctionInfo *function_info; + + info = SELF(self); + if (RB_TYPE_P(rb_n_or_name, T_FIXNUM)) { + gint n; + n = NUM2INT(rb_n_or_name); + function_info = g_object_info_get_method(info, n); + } else { + const gchar *name; + name = RVAL2CSTR(rb_n_or_name); + function_info = g_object_info_find_method(info, name); + } + + return GI_BASE_INFO2RVAL_WITH_UNREF(function_info); +} + +static VALUE +rg_n_signals(VALUE self) +{ + GIObjectInfo *info; + + info = SELF(self); + return INT2NUM(g_object_info_get_n_signals(info)); +} + +static VALUE +rg_get_signal(VALUE self, VALUE rb_n) +{ + GIObjectInfo *info; + gint n; + + info = SELF(self); + n = NUM2INT(rb_n); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_object_info_get_signal(info, n)); +} + +static VALUE +rg_n_vfuncs(VALUE self) +{ + GIObjectInfo *info; + + info = SELF(self); + return INT2NUM(g_object_info_get_n_vfuncs(info)); +} + +static VALUE +rg_get_vfunc(VALUE self, VALUE rb_n_or_name) +{ + GIObjectInfo *info; + GIVFuncInfo *vfunc_info; + + info = SELF(self); + if (RB_TYPE_P(rb_n_or_name, T_FIXNUM)) { + gint n; + n = NUM2INT(rb_n_or_name); + vfunc_info = g_object_info_get_vfunc(info, n); + } else { + const gchar *name; + name = RVAL2CSTR(rb_n_or_name); + vfunc_info = g_object_info_find_vfunc(info, name); + } + + return GI_BASE_INFO2RVAL_WITH_UNREF(vfunc_info); +} + +static VALUE +rg_n_constants(VALUE self) +{ + GIObjectInfo *info; + + info = SELF(self); + return INT2NUM(g_object_info_get_n_constants(info)); +} + +static VALUE +rg_get_constant(VALUE self, VALUE rb_n) +{ + GIObjectInfo *info; + gint n; + + info = SELF(self); + n = NUM2INT(rb_n); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_object_info_get_constant(info, n)); +} + +static VALUE +rg_unref_function(VALUE self) +{ + GIObjectInfo *info; + + info = SELF(self); + return CSTR2RVAL(g_object_info_get_unref_function(info)); +} + +static VALUE +rg_ref_function(VALUE self) +{ + GIObjectInfo *info; + + info = SELF(self); + return CSTR2RVAL(g_object_info_get_ref_function(info)); +} + +static VALUE +rg_set_value_function(VALUE self) +{ + GIObjectInfo *info; + + info = SELF(self); + return CSTR2RVAL(g_object_info_get_set_value_function(info)); +} + +static VALUE +rg_get_value_function(VALUE self) +{ + GIObjectInfo *info; + + info = SELF(self); + return CSTR2RVAL(g_object_info_get_get_value_function(info)); +} + +void +rb_gi_object_info_init(VALUE rb_mGI, VALUE rb_cGIRegisteredTypeInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_OBJECT_INFO, "ObjectInfo", rb_mGI, + rb_cGIRegisteredTypeInfo); + + RG_DEF_METHOD(type_name, 0); + RG_DEF_METHOD(type_init, 0); + RG_DEF_METHOD_P(abstract, 0); + RG_DEF_METHOD_P(fundamental, 0); + RG_DEF_METHOD(parent, 0); + RG_DEF_METHOD(n_interfaces, 0); + RG_DEF_METHOD(get_interface, 1); + RG_DEF_METHOD(n_fields, 0); + RG_DEF_METHOD(get_field, 1); + RG_DEF_METHOD(get_field_value, 2); + RG_DEF_METHOD(set_field_value, 3); + RG_DEF_METHOD(n_properties, 0); + RG_DEF_METHOD(get_property, 1); + RG_DEF_METHOD(n_methods, 0); + RG_DEF_METHOD(get_method, 1); + RG_DEF_METHOD(n_signals, 0); + RG_DEF_METHOD(get_signal, 1); + RG_DEF_METHOD(n_vfuncs, 0); + RG_DEF_METHOD(get_vfunc, 1); + RG_DEF_METHOD(n_constants, 0); + RG_DEF_METHOD(get_constant, 1); + RG_DEF_METHOD(unref_function, 0); + RG_DEF_METHOD(ref_function, 0); + RG_DEF_METHOD(set_value_function, 0); + RG_DEF_METHOD(get_value_function, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-private.h b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-private.h new file mode 100644 index 0000000..b8c2479 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-private.h @@ -0,0 +1,105 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012-2013 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef RB_GI_PRIVATE_H +#define RB_GI_PRIVATE_H + +#include +#include +#include + +#include +#include "gobject-introspection-enum-types.h" + +#include "rbgiversion.h" + +#include "rb-gi-types.h" +#include "rb-gi-conversions.h" + +#include "rb-gobject-introspection.h" + +#ifndef RB_TYPE_P +# define RB_TYPE_P(object, type) (TYPE(object) == type) +#endif + +extern void Init_gobject_introspection(void); + +void rb_gi_argument_init (void); + +void rb_gi_type_tag_init (VALUE rb_mGI); +void rb_gi_base_info_init (VALUE rb_mGI); +void rb_gi_callable_info_init (VALUE rb_mGI, + VALUE rb_cGIBaseInfo); +void rb_gi_function_info_init (VALUE rb_mGI, + VALUE rb_cGICallableInfo); +void rb_gi_method_info_init (VALUE rb_mGI, + VALUE rb_cGIFunctionInfo); +void rb_gi_constructor_info_init (VALUE rb_mGI, + VALUE rb_cGIFunctionInfo); +void rb_gi_callback_info_init (VALUE rb_mGI, + VALUE rb_cGICallableInfo); +void rb_gi_registered_type_info_init (VALUE rb_mGI, + VALUE rb_cGIBaseInfo); +void rb_gi_struct_info_init (VALUE rb_mGI, + VALUE rb_cGIRegisteredTypeInfo); +void rb_gi_boxed_info_init (VALUE rb_mGI, + VALUE rb_cGIRegisteredTypeInfo); +void rb_gi_enum_info_init (VALUE rb_mGI, + VALUE rb_cGIRegisteredTypeInfo); +void rb_gi_flags_info_init (VALUE rb_mGI, + VALUE rb_cGIEnumInfo); +void rb_gi_object_info_init (VALUE rb_mGI, + VALUE rb_cGIRegisteredTypeInfo); +void rb_gi_interface_info_init (VALUE rb_mGI, + VALUE rb_cGIRegisteredTypeInfo); +void rb_gi_constant_info_init (VALUE rb_mGI, + VALUE rb_cGIBaseInfo); +void rb_gi_union_info_init (VALUE rb_mGI, + VALUE rb_cGIRegisteredTypeInfo); +void rb_gi_value_info_init (VALUE rb_mGI, + VALUE rb_cGIBaseInfo); +void rb_gi_signal_info_init (VALUE rb_mGI, + VALUE rb_cGICallableInfo); +void rb_gi_vfunc_info_init (VALUE rb_mGI, + VALUE rb_cGICallableInfo); +void rb_gi_property_info_init (VALUE rb_mGI, + VALUE rb_cGIBaseInfo); +void rb_gi_field_info_init (VALUE rb_mGI, + VALUE rb_cGIBaseInfo); +void rb_gi_arg_info_init (VALUE rb_mGI, + VALUE rb_cGIBaseInfo); +void rb_gi_type_info_init (VALUE rb_mGI, + VALUE rb_cGIBaseInfo); +void rb_gi_unresolved_info_init (VALUE rb_mGI, + VALUE rb_cGIBaseInfo); +void rb_gi_repository_init (VALUE rb_mGI); +void rb_gi_loader_init (VALUE rb_mGI); + +VALUE rb_gi_function_info_invoke_raw (GIFunctionInfo *info, + VALUE rb_options, + GIArgument *return_value); + +VALUE rb_gi_field_info_get_field_raw (GIFieldInfo *info, + gpointer memory); +void rb_gi_field_info_set_field_raw (GIFieldInfo *info, + gpointer memory, + VALUE rb_field_value); + +#endif diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-property-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-property-info.c new file mode 100644 index 0000000..b20d1b2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-property-info.c @@ -0,0 +1,77 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGIPropertyInfo +#define SELF(self) RVAL2GI_BASE_INFO(self) + +GType +gi_property_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GIPropertyInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +static VALUE +rg_flags(VALUE self) +{ + GIPropertyInfo *info; + + info = SELF(self); + return INT2NUM(g_property_info_get_flags(info)); +} + +static VALUE +rg_type(VALUE self) +{ + GIPropertyInfo *info; + + info = SELF(self); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_property_info_get_type(info)); +} + +static VALUE +rg_ownership_transfer(VALUE self) +{ + GIPropertyInfo *info; + + info = SELF(self); + return GI_TRANSFER2RVAL(g_property_info_get_ownership_transfer(info)); +} + +void +rb_gi_property_info_init(VALUE rb_mGI, VALUE rb_cGICallableInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_PROPERTY_INFO, "PropertyInfo", rb_mGI, + rb_cGICallableInfo); + + RG_DEF_METHOD(flags, 0); + RG_DEF_METHOD(type, 0); + RG_DEF_METHOD(ownership_transfer, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-registered-type-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-registered-type-info.c new file mode 100644 index 0000000..c00087b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-registered-type-info.c @@ -0,0 +1,86 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGIRegisteredTypeInfo +#define SELF(self) (RVAL2GI_REGISTERED_TYPE_INFO(self)) + +GType +gi_registered_type_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GIRegisteredTypeInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +static VALUE +rg_type_name(VALUE self) +{ + GIRegisteredTypeInfo *info; + + info = SELF(self); + return CSTR2RVAL(g_registered_type_info_get_type_name(info)); +} + +static VALUE +rg_type_init(VALUE self) +{ + GIRegisteredTypeInfo *info; + + info = SELF(self); + return CSTR2RVAL(g_registered_type_info_get_type_init(info)); +} + +static VALUE +rg_gtype(VALUE self) +{ + GIRegisteredTypeInfo *info; + + info = SELF(self); + return rbgobj_gtype_new(g_registered_type_info_get_g_type(info)); +} + +void +rb_gi_registered_type_info_init(VALUE rb_mGI, VALUE rb_cGIBaseInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_REGISTERED_TYPE_INFO, + "RegisteredTypeInfo", + rb_mGI, + rb_cGIBaseInfo); + + RG_DEF_METHOD(type_name, 0); + RG_DEF_METHOD(type_init, 0); + RG_DEF_METHOD(gtype, 0); + + rb_gi_struct_info_init(rb_mGI, RG_TARGET_NAMESPACE); + rb_gi_boxed_info_init(rb_mGI, RG_TARGET_NAMESPACE); + rb_gi_enum_info_init(rb_mGI, RG_TARGET_NAMESPACE); + rb_gi_object_info_init(rb_mGI, RG_TARGET_NAMESPACE); + rb_gi_interface_info_init(rb_mGI, RG_TARGET_NAMESPACE); + rb_gi_union_info_init(rb_mGI, RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-repository.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-repository.c new file mode 100644 index 0000000..e9a9ed0 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-repository.c @@ -0,0 +1,164 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGIRepository +#define SELF(self) RVAL2GI_REPOSITORY(self) + +static VALUE +rg_s_default(G_GNUC_UNUSED VALUE klass) +{ + return GOBJ2RVAL(g_irepository_get_default()); +} + +static VALUE +rg_require(int argc, VALUE *argv, VALUE self) +{ + VALUE rb_namespace, rb_version, rb_flags; + const gchar *namespace_, *version; + GIRepositoryLoadFlags flags = 0; + GError *error = NULL; + + rb_scan_args(argc, argv, "12", &rb_namespace, &rb_version, &rb_flags); + + namespace_ = RVAL2CSTR(rb_namespace); + version = RVAL2CSTR_ACCEPT_NIL(rb_version); + if (!NIL_P(rb_flags)) { + flags = RVAL2GI_REPOSITORY_LOAD_FLAGS(rb_flags); + } + + g_irepository_require(SELF(self), namespace_, version, flags, &error); + if (error) { + RG_RAISE_ERROR(error); + } + + return Qnil; +} + +static VALUE +rg_get_dependencies(VALUE self, VALUE rb_namespace) +{ + GIRepository *repository; + const gchar *namespace_; + VALUE rb_dependencies; + gchar **dependencies; + gint i; + + repository = SELF(self); + namespace_ = RVAL2CSTR(rb_namespace); + dependencies = g_irepository_get_dependencies(repository, namespace_); + rb_dependencies = rb_ary_new(); + for (i = 0; dependencies[i]; i++) { + rb_ary_push(rb_dependencies, CSTR2RVAL(dependencies[i])); + } + g_strfreev(dependencies); + + return rb_dependencies; +} + +static VALUE +rg_loaded_namespaces(VALUE self) +{ + GIRepository *repository; + VALUE rb_namespaces; + gchar **namespaces; + gint i; + + repository = SELF(self); + namespaces = g_irepository_get_loaded_namespaces(repository); + rb_namespaces = rb_ary_new(); + for (i = 0; namespaces[i]; i++) { + rb_ary_push(rb_namespaces, CSTR2RVAL(namespaces[i])); + } + g_strfreev(namespaces); + + return rb_namespaces; +} + +static VALUE +rg_get_n_infos(VALUE self, VALUE rb_namespace) +{ + const gchar *namespace_; + gint n_infos; + + namespace_ = RVAL2CSTR(rb_namespace); + n_infos = g_irepository_get_n_infos(SELF(self), namespace_); + + return INT2NUM(n_infos); +} + +static VALUE +rg_get_info(VALUE self, VALUE rb_namespace, VALUE rb_n) +{ + GIRepository *repository; + const gchar *namespace_; + gint n; + GIBaseInfo *info; + + repository = SELF(self); + namespace_ = RVAL2CSTR(rb_namespace); + n = NUM2INT(rb_n); + info = g_irepository_get_info(repository, namespace_, n); + return GI_BASE_INFO2RVAL_WITH_UNREF(info); +} + +static VALUE +rg_find(int argc, VALUE *argv, VALUE self) +{ + GIBaseInfo *info; + + if (argc == 1) { + VALUE rb_gtype; + GType gtype; + rb_gtype = argv[0]; + gtype = NUM2UINT(rb_gtype); + info = g_irepository_find_by_gtype(SELF(self), gtype); + } else { + VALUE rb_namespace, rb_name; + const gchar *namespace_, *name; + + rb_scan_args(argc, argv, "2", &rb_namespace, &rb_name); + namespace_ = RVAL2CSTR(rb_namespace); + name = RVAL2CSTR(rb_name); + info = g_irepository_find_by_name(SELF(self), namespace_, name); + } + + return GI_BASE_INFO2RVAL(info); +} + +void +rb_gi_repository_init(VALUE rb_mGI) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_IREPOSITORY, "Repository", rb_mGI); + + RG_DEF_SMETHOD(default, 0); + RG_DEF_METHOD(require, -1); + RG_DEF_METHOD(get_dependencies, 1); + RG_DEF_METHOD(loaded_namespaces, 0); + RG_DEF_METHOD(get_n_infos, 1); + RG_DEF_METHOD(get_info, 2); + RG_DEF_METHOD(find, -1); + + G_DEF_CLASS(G_TYPE_I_REPOSITORY_LOAD_FLAGS, "RepositoryLoadFlags", rb_mGI); + G_DEF_CLASS(G_TYPE_I_REPOSITORY_ERROR, "RepositoryError", rb_mGI); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-signal-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-signal-info.c new file mode 100644 index 0000000..dcb67ad --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-signal-info.c @@ -0,0 +1,77 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGISignalInfo +#define SELF(self) RVAL2GI_BASE_INFO(self) + +GType +gi_signal_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GISignalInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +static VALUE +rg_flags(VALUE self) +{ + GISignalInfo *info; + + info = SELF(self); + return GI_SIGNAL_FLAGS2RVAL(g_signal_info_get_flags(info)); +} + +static VALUE +rg_class_closure(VALUE self) +{ + GISignalInfo *info; + + info = SELF(self); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_signal_info_get_class_closure(info)); +} + +static VALUE +rg_true_stops_emit_p(VALUE self) +{ + GISignalInfo *info; + + info = SELF(self); + return CBOOL2RVAL(g_signal_info_true_stops_emit(info)); +} + +void +rb_gi_signal_info_init(VALUE rb_mGI, VALUE rb_cGICallableInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_SIGNAL_INFO, "SignalInfo", rb_mGI, + rb_cGICallableInfo); + + RG_DEF_METHOD(flags, 0); + RG_DEF_METHOD(class_closure, 0); + RG_DEF_METHOD_P(true_stops_emit, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-struct-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-struct-info.c new file mode 100644 index 0000000..27b058f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-struct-info.c @@ -0,0 +1,190 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012-2013 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGIStructInfo +#define SELF(self) (RVAL2GI_STRUCT_INFO(self)) + +GType +gi_struct_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GIStructInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +static VALUE +rg_n_fields(VALUE self) +{ + GIStructInfo *info; + + info = SELF(self); + return INT2NUM(g_struct_info_get_n_fields(info)); +} + +static VALUE +rg_get_field(VALUE self, VALUE rb_n) +{ + GIStructInfo *info; + gint n; + + info = SELF(self); + n = NUM2INT(rb_n); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_struct_info_get_field(info, n)); +} + +static VALUE +rg_get_field_value(VALUE self, VALUE rb_struct, VALUE rb_n) +{ + GIStructInfo *info; + gint n; + GIFieldInfo *field_info; + VALUE rb_value; + gpointer instance; + + info = SELF(self); + n = NUM2INT(rb_n); + field_info = g_struct_info_get_field(info, n); + if (rb_respond_to(rb_struct, rb_intern("gtype"))) { + VALUE rb_gtype; + GType gtype; + rb_gtype = rb_funcall(rb_struct, rb_intern("gtype"), 0); + gtype = NUM2UINT(rb_funcall(rb_gtype, rb_intern("to_i"), 0)); + instance = RVAL2BOXED(rb_struct, gtype); + } else { + Data_Get_Struct(rb_struct, void, instance); + } + rb_value = rb_gi_field_info_get_field_raw(field_info, instance); + g_base_info_unref(field_info); + + return rb_value; +} + +static VALUE +rg_set_field_value(VALUE self, VALUE rb_struct, VALUE rb_n, VALUE rb_value) +{ + GIStructInfo *info; + gint n; + GIFieldInfo *field_info; + GType gtype; + + info = SELF(self); + n = NUM2INT(rb_n); + field_info = g_struct_info_get_field(info, n); + gtype = g_registered_type_info_get_g_type(info); + rb_gi_field_info_set_field_raw(field_info, + RVAL2BOXED(rb_struct, gtype), + rb_value); + /* TODO: use rb_ensure() to unref field_info. */ + g_base_info_unref(field_info); + + return Qnil; +} + +static VALUE +rg_n_methods(VALUE self) +{ + GIStructInfo *info; + + info = SELF(self); + return INT2NUM(g_struct_info_get_n_methods(info)); +} + +static VALUE +rg_get_method(VALUE self, VALUE rb_n_or_name) +{ + GIStructInfo *info; + GIFunctionInfo *function_info; + + info = SELF(self); + if (RB_TYPE_P(rb_n_or_name, RUBY_T_FIXNUM)) { + gint n; + n = NUM2INT(rb_n_or_name); + function_info = g_struct_info_get_method(info, n); + } else { + const gchar *name; + name = RVAL2CSTR(rb_n_or_name); + function_info = g_struct_info_find_method(info, name); + } + + return GI_BASE_INFO2RVAL_WITH_UNREF(function_info); +} + +static VALUE +rg_size(VALUE self) +{ + GIStructInfo *info; + + info = SELF(self); + return UINT2NUM(g_struct_info_get_size(info)); +} + +static VALUE +rg_alignment(VALUE self) +{ + GIStructInfo *info; + + info = SELF(self); + return UINT2NUM(g_struct_info_get_alignment(info)); +} + +static VALUE +rg_gtype_struct_p(VALUE self) +{ + GIStructInfo *info; + + info = SELF(self); + return CBOOL2RVAL(g_struct_info_is_gtype_struct(info)); +} + +static VALUE +rg_foreign_p(VALUE self) +{ + GIStructInfo *info; + + info = SELF(self); + return CBOOL2RVAL(g_struct_info_is_foreign(info)); +} + +void +rb_gi_struct_info_init(VALUE rb_mGI, VALUE rb_cGIRegisteredTypeInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_STRUCT_INFO, "StructInfo", rb_mGI, + rb_cGIRegisteredTypeInfo); + + RG_DEF_METHOD(n_fields, 0); + RG_DEF_METHOD(get_field, 1); + RG_DEF_METHOD(get_field_value, 2); + RG_DEF_METHOD(set_field_value, 3); + RG_DEF_METHOD(n_methods, 0); + RG_DEF_METHOD(get_method, 1); + RG_DEF_METHOD(size, 0); + RG_DEF_METHOD(alignment, 0); + RG_DEF_METHOD_P(gtype_struct, 0); + RG_DEF_METHOD_P(foreign, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-type-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-type-info.c new file mode 100644 index 0000000..596a705 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-type-info.c @@ -0,0 +1,143 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGITypeInfo +#define SELF(self) (RVAL2GI_TYPE_INFO(self)) + +GType +gi_type_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GITypeInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +VALUE +rb_gi_array_type_to_ruby(GIArrayType type) +{ + if (type == (GIArrayType)-1) { + return Qnil; + } else { + return GENUM2RVAL(type, G_TYPE_I_ARRAY_TYPE); + } +} + +static VALUE +rg_pointer_p(VALUE self) +{ + GITypeInfo *info; + + info = SELF(self); + return CBOOL2RVAL(g_type_info_is_pointer(info)); +} + +static VALUE +rg_tag(VALUE self) +{ + GITypeInfo *info; + + info = SELF(self); + return GI_TYPE_TAG2RVAL(g_type_info_get_tag(info)); +} + +static VALUE +rg_get_param_type(VALUE self, VALUE rb_n) +{ + GITypeInfo *info; + gint n; + + info = SELF(self); + n = NUM2INT(rb_n); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_type_info_get_param_type(info, n)); +} + +static VALUE +rg_interface(VALUE self) +{ + GITypeInfo *info; + + info = SELF(self); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_type_info_get_interface(info)); +} + +static VALUE +rg_array_length(VALUE self) +{ + GITypeInfo *info; + + info = SELF(self); + return INT2NUM(g_type_info_get_array_length(info)); +} + +static VALUE +rg_array_fixed_size(VALUE self) +{ + GITypeInfo *info; + + info = SELF(self); + return INT2NUM(g_type_info_get_array_fixed_size(info)); +} + +static VALUE +rg_zero_terminated_p(VALUE self) +{ + GITypeInfo *info; + + info = SELF(self); + return CBOOL2RVAL(g_type_info_is_zero_terminated(info)); +} + +static VALUE +rg_array_type(VALUE self) +{ + GITypeInfo *info; + + info = SELF(self); + return GI_ARRAY_TYPE2RVAL(g_type_info_get_array_type(info)); +} + +void +rb_gi_type_info_init(VALUE rb_mGI, VALUE rb_cGIBaseInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_TYPE_INFO, "TypeInfo", rb_mGI, + rb_cGIBaseInfo); + + RG_DEF_METHOD_P(pointer, 0); + RG_DEF_METHOD(tag, 0); + RG_DEF_METHOD(get_param_type, 1); + RG_DEF_METHOD(interface, 0); + RG_DEF_METHOD(array_length, 0); + RG_DEF_METHOD(array_fixed_size, 0); + RG_DEF_METHOD_P(zero_terminated, 0); + RG_DEF_METHOD(array_type, 0); + + rb_undef_method(RG_TARGET_NAMESPACE, "name"); + + G_DEF_CLASS(G_TYPE_I_ARRAY_TYPE, "ArrayType", rb_mGI); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-type-tag.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-type-tag.c new file mode 100644 index 0000000..dc82845 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-type-tag.c @@ -0,0 +1,43 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGITypeTag +#define SELF(self) (RVAL2GI_TYPE_TAG(self)) + +static VALUE +rg_to_s(VALUE self) +{ + GITypeTag tag; + + tag = SELF(self); + return CSTR2RVAL(g_type_tag_to_string(tag)); +} + +void +rb_gi_type_tag_init(VALUE rb_mGI) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_I_TYPE_TAG, "TypeTag", rb_mGI); + + RG_DEF_METHOD(to_s, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-types.h b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-types.h new file mode 100644 index 0000000..33a8f8e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-types.h @@ -0,0 +1,71 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef RB_GI_TYPES_H +#define RB_GI_TYPES_H + +#define GI_TYPE_CALLABLE_INFO (gi_callable_info_get_type()) +#define GI_TYPE_FUNCTION_INFO (gi_function_info_get_type()) +#define GI_TYPE_METHOD_INFO (gi_method_info_get_type()) +#define GI_TYPE_CONSTRUCTOR_INFO (gi_constructor_info_get_type()) +#define GI_TYPE_CALLBACK_INFO (gi_callback_info_get_type()) +#define GI_TYPE_REGISTERED_TYPE_INFO (gi_registered_type_info_get_type()) +#define GI_TYPE_STRUCT_INFO (gi_struct_info_get_type()) +#define GI_TYPE_BOXED_INFO (gi_boxed_info_get_type()) +#define GI_TYPE_ENUM_INFO (gi_enum_info_get_type()) +#define GI_TYPE_FLAGS_INFO (gi_flags_info_get_type()) +#define GI_TYPE_OBJECT_INFO (gi_object_info_get_type()) +#define GI_TYPE_INTERFACE_INFO (gi_interface_info_get_type()) +#define GI_TYPE_CONSTANT_INFO (gi_constant_info_get_type()) +#define GI_TYPE_UNION_INFO (gi_union_info_get_type()) +#define GI_TYPE_VALUE_INFO (gi_value_info_get_type()) +#define GI_TYPE_SIGNAL_INFO (gi_signal_info_get_type()) +#define GI_TYPE_VFUNC_INFO (gi_vfunc_info_get_type()) +#define GI_TYPE_PROPERTY_INFO (gi_property_info_get_type()) +#define GI_TYPE_FIELD_INFO (gi_field_info_get_type()) +#define GI_TYPE_ARG_INFO (gi_arg_info_get_type()) +#define GI_TYPE_TYPE_INFO (gi_type_info_get_type()) +#define GI_TYPE_UNRESOLVED_INFO (gi_unresolved_info_get_type()) + +GType gi_callable_info_get_type (void); +GType gi_function_info_get_type (void); +GType gi_method_info_get_type (void); +GType gi_constructor_info_get_type (void); +GType gi_callback_info_get_type (void); +GType gi_registered_type_info_get_type (void); +GType gi_struct_info_get_type (void); +GType gi_boxed_info_get_type (void); +GType gi_enum_info_get_type (void); +GType gi_flags_info_get_type (void); +GType gi_object_info_get_type (void); +GType gi_interface_info_get_type (void); +GType gi_constant_info_get_type (void); +GType gi_union_info_get_type (void); +GType gi_value_info_get_type (void); +GType gi_signal_info_get_type (void); +GType gi_vfunc_info_get_type (void); +GType gi_property_info_get_type (void); +GType gi_field_info_get_type (void); +GType gi_arg_info_get_type (void); +GType gi_type_info_get_type (void); +GType gi_unresolved_info_get_type (void); + + +#endif diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-union-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-union-info.c new file mode 100644 index 0000000..882706a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-union-info.c @@ -0,0 +1,206 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGIUnionInfo +#define SELF(self) (RVAL2GI_UNION_INFO(self)) + +GType +gi_union_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GIUnionInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +static VALUE +rg_n_fields(VALUE self) +{ + GIUnionInfo *info; + + info = SELF(self); + return INT2NUM(g_union_info_get_n_fields(info)); +} + +static VALUE +rg_get_field(VALUE self, VALUE rb_n) +{ + GIUnionInfo *info; + gint n; + + info = SELF(self); + n = NUM2INT(rb_n); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_union_info_get_field(info, n)); +} + +static VALUE +rg_get_field_value(VALUE self, VALUE rb_union, VALUE rb_n) +{ + GIUnionInfo *info; + gint n; + GIFieldInfo *field_info; + GType gtype; + VALUE rb_value; + + info = SELF(self); + n = NUM2INT(rb_n); + field_info = g_union_info_get_field(info, n); + gtype = g_registered_type_info_get_g_type(info); + rb_value = rb_gi_field_info_get_field_raw(field_info, + RVAL2BOXED(rb_union, gtype)); + g_base_info_unref(field_info); + + return rb_value; +} + +static VALUE +rg_set_field_value(VALUE self, VALUE rb_union, VALUE rb_n, VALUE rb_value) +{ + GIUnionInfo *info; + gint n; + GIFieldInfo *field_info; + GType gtype; + + info = SELF(self); + n = NUM2INT(rb_n); + field_info = g_union_info_get_field(info, n); + gtype = g_registered_type_info_get_g_type(info); + rb_gi_field_info_set_field_raw(field_info, + RVAL2BOXED(rb_union, gtype), + rb_value); + /* TODO: use rb_ensure() to unref field_info. */ + g_base_info_unref(field_info); + + return Qnil; +} + +static VALUE +rg_n_methods(VALUE self) +{ + GIUnionInfo *info; + + info = SELF(self); + return INT2NUM(g_union_info_get_n_methods(info)); +} + +static VALUE +rg_get_method(VALUE self, VALUE rb_n_or_name) +{ + GIUnionInfo *info; + GIFunctionInfo *function_info; + + info = SELF(self); + if (RB_TYPE_P(rb_n_or_name, T_FIXNUM)) { + gint n; + n = NUM2INT(rb_n_or_name); + function_info = g_union_info_get_method(info, n); + } else { + const gchar *name; + name = RVAL2CSTR(rb_n_or_name); + function_info = g_union_info_find_method(info, name); + } + + return GI_BASE_INFO2RVAL_WITH_UNREF(function_info); +} + +static VALUE +rg_discriminated_p(VALUE self) +{ + GIUnionInfo *info; + + info = SELF(self); + return CBOOL2RVAL(g_union_info_is_discriminated(info)); +} + +static VALUE +rg_discriminator_offset(VALUE self) +{ + GIUnionInfo *info; + + info = SELF(self); + return INT2NUM(g_union_info_get_discriminator_offset(info)); +} + +static VALUE +rg_discriminator_type(VALUE self) +{ + GIUnionInfo *info; + + info = SELF(self); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_union_info_get_discriminator_type(info)); +} + +static VALUE +rg_get_discriminator(VALUE self, VALUE rb_n) +{ + GIUnionInfo *info; + gint n; + + info = SELF(self); + n = NUM2INT(rb_n); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_union_info_get_discriminator(info, n)); +} + +static VALUE +rg_size(VALUE self) +{ + GIUnionInfo *info; + + info = SELF(self); + return ULONG2NUM(g_union_info_get_size(info)); +} + + +static VALUE +rg_alignment(VALUE self) +{ + GIUnionInfo *info; + + info = SELF(self); + return ULONG2NUM(g_union_info_get_alignment(info)); +} + +void +rb_gi_union_info_init(VALUE rb_mGI, VALUE rb_cGIRegisteredTypeInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_UNION_INFO, "UnionInfo", rb_mGI, + rb_cGIRegisteredTypeInfo); + + RG_DEF_METHOD(n_fields, 0); + RG_DEF_METHOD(get_field, 1); + RG_DEF_METHOD(get_field_value, 2); + RG_DEF_METHOD(set_field_value, 3); + RG_DEF_METHOD(n_methods, 0); + RG_DEF_METHOD(get_method, 1); + RG_DEF_METHOD_P(discriminated, 0); + RG_DEF_METHOD(discriminator_offset, 0); + RG_DEF_METHOD(discriminator_type, 0); + RG_DEF_METHOD(get_discriminator, 1); + RG_DEF_METHOD(size, 0); + RG_DEF_METHOD(alignment, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-unresolved-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-unresolved-info.c new file mode 100644 index 0000000..e2c3237 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-unresolved-info.c @@ -0,0 +1,48 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TUNRESOLVEDET_NAMESPACE rb_cGIUnresolvedInfo + +GType +gi_unresolved_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GIUnresolvedInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +void +rb_gi_unresolved_info_init(VALUE rb_mGI, VALUE rb_cGIBaseInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_UNRESOLVED_INFO, + "UnresolvedInfo", rb_mGI, + rb_cGIBaseInfo); + + (void)RG_TARGET_NAMESPACE; /* suppress a warning. */ +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-value-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-value-info.c new file mode 100644 index 0000000..9374845 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-value-info.c @@ -0,0 +1,57 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGIValueInfo +#define SELF(self) (RVAL2GI_VALUE_INFO(self)) + +GType +gi_value_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GIValueInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +static VALUE +rg_value(VALUE self) +{ + GIValueInfo *info; + + info = SELF(self); + return LONG2NUM(g_value_info_get_value(info)); +} + +void +rb_gi_value_info_init(VALUE rb_mGI, VALUE rb_cGIBaseInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_VALUE_INFO, "ValueInfo", rb_mGI, + rb_cGIBaseInfo); + + RG_DEF_METHOD(value, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-vfunc-info.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-vfunc-info.c new file mode 100644 index 0000000..a5718f1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gi-vfunc-info.c @@ -0,0 +1,91 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_cGIVFuncInfo +#define SELF(self) RVAL2GI_BASE_INFO(self) + +GType +gi_vfunc_info_get_type(void) +{ + static GType type = 0; + if (type == 0) { + type = g_boxed_type_register_static("GIVFuncInfo", + (GBoxedCopyFunc)g_base_info_ref, + (GBoxedFreeFunc)g_base_info_unref); + } + return type; +} + +static VALUE +rg_flags(VALUE self) +{ + GIVFuncInfo *info; + + info = SELF(self); + return GI_VFUNC_INFO_FLAGS2RVAL(g_vfunc_info_get_flags(info)); +} + +static VALUE +rg_offset(VALUE self) +{ + GIVFuncInfo *info; + + info = SELF(self); + return INT2NUM(g_vfunc_info_get_offset(info)); +} + +static VALUE +rg_signal(VALUE self) +{ + GIVFuncInfo *info; + + info = SELF(self); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_vfunc_info_get_signal(info)); +} + +static VALUE +rg_invoker(VALUE self) +{ + GIVFuncInfo *info; + + info = SELF(self); + return GI_BASE_INFO2RVAL_WITH_UNREF(g_vfunc_info_get_invoker(info)); +} + +void +rb_gi_vfunc_info_init(VALUE rb_mGI, VALUE rb_cGICallableInfo) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = + G_DEF_CLASS_WITH_PARENT(GI_TYPE_VFUNC_INFO, "VFuncInfo", rb_mGI, + rb_cGICallableInfo); + + rb_define_const(RG_TARGET_NAMESPACE, "UNKNOWN_OFFSET", INT2NUM(0xFFFF)); + + RG_DEF_METHOD(flags, 0); + RG_DEF_METHOD(offset, 0); + RG_DEF_METHOD(signal, 0); + RG_DEF_METHOD(invoker, 0); + + G_DEF_CLASS(G_TYPE_IV_FUNC_INFO_FLAGS, "VFuncInfoFlags", rb_mGI); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gobject-introspection.c b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gobject-introspection.c new file mode 100644 index 0000000..0db33a3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gobject-introspection.c @@ -0,0 +1,44 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012-2013 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rb-gi-private.h" + +#define RG_TARGET_NAMESPACE rb_mGObjectIntrospection + +void +Init_gobject_introspection(void) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = rb_define_module("GObjectIntrospection"); + + rb_define_const(RG_TARGET_NAMESPACE, "BUILD_VERSION", + rb_ary_new3(3, + INT2FIX(GI_MAJOR_VERSION), + INT2FIX(GI_MINOR_VERSION), + INT2FIX(GI_MICRO_VERSION))); + + rb_gi_argument_init(); + + rb_gi_type_tag_init(RG_TARGET_NAMESPACE); + rb_gi_base_info_init(RG_TARGET_NAMESPACE); + rb_gi_repository_init(RG_TARGET_NAMESPACE); + rb_gi_loader_init(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gobject-introspection.h b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gobject-introspection.h new file mode 100644 index 0000000..6c82317 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/ext/gobject-introspection/rb-gobject-introspection.h @@ -0,0 +1,57 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012-2013 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef RB_GOBJECT_INTROSPECTION_H +#define RB_GOBJECT_INTROSPECTION_H + +#include +#include + +#include + +typedef gpointer (*RBGICallbackFinderFunc)(GIArgInfo *info); + +typedef struct +{ + GIArgInfo arg_info; + GIScopeType scope_type; + GIDirection direction; + gboolean callback_p; + gboolean closure_p; + gboolean destroy_p; + gboolean inout_argv_p; + gint in_arg_index; + gint closure_in_arg_index; + gint destroy_in_arg_index; + gint rb_arg_index; + gint out_arg_index; + gint inout_argc_arg_index; +} RBGIArgMetadata; + +typedef struct { + RBGIArgMetadata *metadata; + VALUE rb_gc_guard_key; + VALUE rb_callback; +} RBGICallbackData; + +void rb_gi_callback_register_finder (RBGICallbackFinderFunc finder); +void rb_gi_callback_data_free (RBGICallbackData *callback_data); + +#endif diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/extconf.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/extconf.rb new file mode 100755 index 0000000..d8bc68e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/extconf.rb @@ -0,0 +1,71 @@ +#!/usr/bin/env ruby +# +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "pathname" +require "mkmf" +require "rbconfig" +require "fileutils" + +module_name = "gobject_introspection" +package = "gobject-introspection" + +base_dir = Pathname(__FILE__).dirname.expand_path +ext_dir = base_dir + "ext" + package +mkmf_gnome2_dir = base_dir + 'lib' + +if RbConfig.respond_to?(:ruby) + ruby = RbConfig.ruby +else + ruby = File.join(RbConfig::CONFIG['bindir'], + RbConfig::CONFIG['ruby_install_name'] + + RbConfig::CONFIG["EXEEXT"]) +end +build_dir = Pathname("ext") + package +FileUtils.mkdir_p(build_dir.to_s) unless build_dir.exist? +extconf_rb_path = ext_dir + "extconf.rb" +unless system(ruby, "-C", build_dir.to_s, extconf_rb_path.to_s, *ARGV) + exit(false) +end + +create_makefile(module_name) +FileUtils.mv("Makefile", "Makefile.lib") + +File.open("Makefile", "w") do |makefile| + makefile.puts(<<-EOM) +all: + (cd ext/#{package} && $(MAKE)) + $(MAKE) -f Makefile.lib + +install: + (cd ext/#{package} && $(MAKE) install) + $(MAKE) -f Makefile.lib install + +site-install: + (cd ext/#{package} && $(MAKE) site-install) + $(MAKE) -f Makefile.lib site-install + +clean: + (cd ext/#{package} && $(MAKE) clean) + $(MAKE) -f Makefile.lib clean + +distclean: + (cd ext/#{package} && $(MAKE) distclean) + $(MAKE) -f Makefile.lib distclean + @rm -f Makefile.lib +EOM +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection.rb new file mode 100644 index 0000000..3685b54 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection.rb @@ -0,0 +1,53 @@ +# Copyright (C) 2012-2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "glib2" + +module GObjectIntrospection + class << self + def prepend_typelib_path(path) + GLib.prepend_path_to_environment_variable(path, "GI_TYPELIB_PATH") + end + end +end + +base_dir = Pathname.new(__FILE__).dirname.dirname.expand_path +vendor_dir = base_dir + "vendor" + "local" +vendor_bin_dir = vendor_dir + "bin" +GLib.prepend_dll_path(vendor_bin_dir) +begin + major, minor, _ = RUBY_VERSION.split(/\./) + require "#{major}.#{minor}/gobject_introspection.so" +rescue LoadError + require "gobject_introspection.so" +end + +vendor_girepository_dir = vendor_dir + "lib" + "girepository-1.0" +GObjectIntrospection.prepend_typelib_path(vendor_girepository_dir) + +module GObjectIntrospection + LOG_DOMAIN = "GObjectIntrospection" +end +GLib::Log.set_log_domain(GObjectIntrospection::LOG_DOMAIN) + +require "gobject-introspection/repository" +require "gobject-introspection/callable-info" +require "gobject-introspection/object-info" +require "gobject-introspection/interface-info" +require "gobject-introspection/struct-info" +require "gobject-introspection/boxed-info" +require "gobject-introspection/union-info" +require "gobject-introspection/loader" diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/boxed-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/boxed-info.rb new file mode 100644 index 0000000..610f17f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/boxed-info.rb @@ -0,0 +1,28 @@ +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "gobject-introspection/collection-reader" + +module GObjectIntrospection + class BoxedInfo + extend CollectionReader + + alias_method :__methods__, :methods + + collection_reader("fields") + collection_reader("methods") + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/callable-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/callable-info.rb new file mode 100644 index 0000000..2456f90 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/callable-info.rb @@ -0,0 +1,91 @@ +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "gobject-introspection/collection-reader" + +module GObjectIntrospection + class CallableInfo + extend CollectionReader + + collection_reader("args") + + def in_args + callback_indexes = [] + closure_indexes = [] + destroy_indexes = [] + args.each_with_index do |arg, i| + next if arg.scope == ScopeType::INVALID + callback_indexes << i + closure_index = arg.closure + closure_indexes << closure_index if closure_index != -1 + destroy_index = arg.destroy + destroy_indexes << destroy_index if destroy_index != -1 + end + + args.find_all.with_index do |arg, i| + case arg.direction + when Direction::IN, Direction::INOUT + if callback_indexes.include?(i) + false + elsif closure_indexes.include?(i) + false + elsif destroy_indexes.include?(i) + false + else + true + end + else + false + end + end + end + + def required_in_args + in_args.reject do |arg| + arg.may_be_null? + end + end + + def n_in_args + in_args.size + end + + def n_required_in_args + required_in_args.size + end + + def require_callback? + args.any? do |arg| + arg.direction == Direction::IN and arg.scope != ScopeType::INVALID + end + end + + def out_args + args.find_all do |arg| + case arg.direction + when Direction::OUT, Direction::INOUT + true + else + false + end + end + end + + def n_out_args + out_args.size + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/collection-reader.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/collection-reader.rb new file mode 100644 index 0000000..d6b3b2c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/collection-reader.rb @@ -0,0 +1,34 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +module GObjectIntrospection + module CollectionReader + def collection_reader(name) + n_getter = "n_#{name}" + if name.end_with?("ies") + singular = name.sub(/ies\z/, "y") + else + singular = name.sub(/s\z/, "") + end + getter = "get_#{singular}" + define_method(name) do + send(n_getter).times.collect do |i| + send(getter, i) + end + end + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/interface-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/interface-info.rb new file mode 100644 index 0000000..4dddf39 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/interface-info.rb @@ -0,0 +1,32 @@ +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "gobject-introspection/collection-reader" + +module GObjectIntrospection + class InterfaceInfo + extend CollectionReader + + alias_method :__methods__, :methods + + collection_reader("prerequisites") + collection_reader("properties") + collection_reader("methods") + collection_reader("signals") + collection_reader("vfuncs") + collection_reader("constants") + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/loader.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/loader.rb new file mode 100644 index 0000000..7a7b6df --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/loader.rb @@ -0,0 +1,371 @@ +# Copyright (C) 2012-2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +module GObjectIntrospection + class Loader + class << self + def load(namespace, base_module, options={}) + loader = new(base_module) + loader.version = options[:version] + loader.load(namespace) + end + end + + attr_accessor :version + def initialize(base_module) + @base_module = base_module + @version = nil + end + + def load(namespace) + repository = Repository.default + repository.require(namespace, @version) + pre_load(repository, namespace) + repository.each(namespace) do |info| + load_info(info) + end + post_load(repository, namespace) + end + + private + def pre_load(repository, namespace) + end + + def post_load(repository, namespace) + end + + def load_info(info) + case info + when FunctionInfo + load_function_info(info) + when StructInfo + load_struct_info(info) + when BoxedInfo + load_boxed_info(info) + when FlagsInfo + load_flags_info(info) + when EnumInfo + load_enum_info(info) + when ObjectInfo + load_object_info(info) + when InterfaceInfo + load_interface_info(info) + when ConstantInfo + load_constant_info(info) + when UnionInfo + load_union_info(info) + end + end + + def load_function_info(info) + name = rubyish_method_name(info) + define_module_function(@base_module, name, info) + end + + def define_module_function(target_module, name, function_info) + unlock_gvl = should_unlock_gvl?(function_info, target_module) + validate = lambda do |arguments| + method_name = "#{target_module}\#.#{name}" + validate_arguments(function_info, method_name, arguments) + end + target_module.module_eval do + define_method(name) do |*arguments, &block| + validate.call(arguments, &block) + function_info.invoke({ + :arguments => arguments, + :unlock_gvl => unlock_gvl, + }, + &block) + end + module_function(name) + end + end + + def define_struct(info, options={}) + if info.gtype == GLib::Type::NONE + klass = self.class.define_struct(info.size, info.name, @base_module, + :parent => options[:parent]) + else + klass = self.class.define_class(info.gtype, info.name, @base_module, + :parent => options[:parent]) + end + load_fields(info, klass) + load_methods(info, klass) + end + + def load_struct_info(info) + return if info.gtype_struct? + + define_struct(info) + end + + def define_boxed(info) + klass = self.class.define_class(info.gtype, info.name, @base_module) + # TODO + # load_fields(info, klass) + # load_methods(info, klass) + end + + def load_boxed_info(info) + define_boxed(info) + end + + def load_enum_value(value_info, enum_module) + enum_module.const_set(value_info.name.upcase, value_info.value) + end + + def load_enum_info(info) + if info.gtype == GLib::Type::NONE + enum_module = Module.new + info.values.each do |value_info| + load_enum_value(value_info, enum_module) + end + @base_module.const_set(info.name, enum_module) + else + self.class.define_class(info.gtype, info.name, @base_module) + end + end + + def load_flag_value(value_info, flags_module) + flags_module.const_set(value_info.name.upcase, value_info.value) + end + + def load_flags_info(info) + if info.gtype == GLib::Type::NONE + flags_module = Module.new + info.values.each do |value_info| + load_flag_value(value_info, flags_module) + end + @base_module.const_set(info.name, flags_module) + else + self.class.define_class(info.gtype, info.name, @base_module) + end + end + + def load_object_info(info) + klass = self.class.define_class(info.gtype, info.name, @base_module) + load_fields(info, klass) + load_methods(info, klass) + end + + def load_fields(info, klass) + info.n_fields.times do |i| + field_info = info.get_field(i) + load_field(info, i, field_info, klass) + end + end + + def load_field(info, i, field_info, klass) + name = field_info.name + flags = field_info.flags + + if flags.readable? + klass.__send__(:define_method, name) do || + info.get_field_value(self, i) + end + end + + if flags.writable? + klass.__send__(:define_method, "#{name}=") do |value| + info.set_field_value(self, i, value) + end + end + end + + def load_methods(info, klass) + grouped_methods = info.methods.group_by do |method_info| + method_info.class + end + grouped_methods.each do |method_info_class, method_infos| + next if method_infos.empty? + case method_infos.first + when ConstructorInfo + load_constructor_infos(method_infos, klass) + when MethodInfo + load_method_infos(method_infos, klass) + when FunctionInfo + load_function_infos(method_infos, klass) + else + raise "TODO: #{method_info_class}" + end + end + end + + def load_constructor_infos(infos, klass) + return if infos.empty? + + validate = lambda do |info, method_name, arguments| + validate_arguments(info, "#{klass}\##{method_name}", arguments) + end + infos.each do |info| + name = "initialize_#{info.name}" + unlock_gvl = should_unlock_gvl?(info, klass) + klass.__send__(:define_method, name) do |*arguments, &block| + validate.call(info, name, arguments, &block) + info.invoke({ + :receiver => self, + :arguments => arguments, + :unlock_gvl => unlock_gvl, + }, + &block) + end + klass.__send__(:private, name) + end + + find_info = lambda do |arguments| + find_suitable_callable_info(infos, arguments) + end + klass.__send__(:define_method, "initialize") do |*arguments, &block| + info = find_info.call(arguments, &block) + __send__("initialize_#{info.name}", *arguments, &block) + end + end + + def validate_arguments(info, method_name, arguments) + n_in_args = info.n_in_args + n_required_in_args = info.n_required_in_args + return if (n_required_in_args..n_in_args).cover?(arguments.size) + + detail = "#{arguments.size} for " + if n_in_args == n_required_in_args + detail << "#{info.n_in_args}" + else + detail << "#{info.n_required_in_args}..#{info.n_in_args}" + end + message = "#{method_name}: wrong number of arguments (#{detail})" + raise ArgumentError, message + end + + def find_suitable_callable_info(infos, arguments) + min_n_args = nil + max_n_args = nil + infos.each do |info| + if arguments.size == info.n_in_args + return info + end + n_in_args = info.n_in_args + min_n_args = [min_n_args || n_in_args, n_in_args].min + max_n_args = [max_n_args || n_in_args, n_in_args].max + end + detail = "#{arguments.size} for #{min_n_args}" + if min_n_args < max_n_args + detail << "..#{max_n_args}" + end + raise ArgumentError, "wrong number of arguments (#{detail})" + end + + def rubyish_method_name(function_info) + name = function_info.name + return_type = function_info.return_type + if return_type.tag == GObjectIntrospection::TypeTag::BOOLEAN + case name + when /\A(?:is|get_is|get)_/ + "#{$POSTMATCH}?" + when /\A(?:has|use)_/ + "#{name}?" + else + name + end + elsif /\Aget_/ =~ name and function_info.n_in_args.zero? + $POSTMATCH + else + case name + when "to_string" + "to_s" + when "foreach" + "each" + else + name + end + end + end + + def should_unlock_gvl?(function_info, klass) + false + end + + def load_method_infos(infos, klass) + infos.each do |info| + method_name = rubyish_method_name(info) + load_method_info(info, klass, method_name) + if /\Aset_/ =~ method_name and info.n_args == 1 + klass.__send__(:alias_method, "#{$POSTMATCH}=", method_name) + end + end + end + + def load_method_info(info, klass, method_name) + unlock_gvl = should_unlock_gvl?(info, klass) + validate = lambda do |arguments| + validate_arguments(info, "#{klass}\##{method_name}", arguments) + end + klass.__send__(:define_method, method_name) do |*arguments, &block| + validate.call(arguments, &block) + if block.nil? and info.require_callback? + Enumerator.new(self, method_name, *arguments) + else + info.invoke({ + :receiver => self, + :arguments => arguments, + :unlock_gvl => unlock_gvl, + }, + &block) + end + end + end + + def load_function_infos(infos, klass) + infos.each do |info| + name = rubyish_method_name(info) + next if name == "new" + next if name == "alloc" + unlock_gvl = should_unlock_gvl?(info, klass) + validate = lambda do |arguments| + validate_arguments(info, "#{klass}.#{name}", arguments) + end + singleton_class = (class << klass; self; end) + singleton_class.__send__(:define_method, name) do |*arguments, &block| + validate.call(arguments, &block) + if block.nil? and info.require_callback? + Enumerator.new(self, name, *arguments) + else + info.invoke({ + :arguments => arguments, + :unlock_gvl => unlock_gvl, + }, + &block) + end + end + end + end + + def load_interface_info(info) + interface_module = + self.class.define_interface(info.gtype, info.name, @base_module) + load_methods(info, interface_module) + end + + def load_constant_info(info) + @base_module.const_set(info.name, info.value) + end + + def load_union_info(info) + klass = self.class.define_class(info.gtype, info.name, @base_module) + load_fields(info, klass) + load_methods(info, klass) + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/object-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/object-info.rb new file mode 100644 index 0000000..90cd8f1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/object-info.rb @@ -0,0 +1,33 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "gobject-introspection/collection-reader" + +module GObjectIntrospection + class ObjectInfo + extend CollectionReader + + alias_method :__methods__, :methods + + collection_reader("interfaces") + collection_reader("fields") + collection_reader("properties") + collection_reader("methods") + collection_reader("signals") + collection_reader("vfuncs") + collection_reader("constants") + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/repository.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/repository.rb new file mode 100644 index 0000000..97a6781 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/repository.rb @@ -0,0 +1,32 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +module GObjectIntrospection + class Repository + include Enumerable + + def each(*namespaces) + if namespaces.empty? + namespaces = loaded_namespaces + end + namespaces.each do |namespace| + get_n_infos(namespace).times do |i| + yield(get_info(namespace, i)) + end + end + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/struct-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/struct-info.rb new file mode 100644 index 0000000..e93e8aa --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/struct-info.rb @@ -0,0 +1,28 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "gobject-introspection/collection-reader" + +module GObjectIntrospection + class StructInfo + extend CollectionReader + + alias_method :__methods__, :methods + + collection_reader("fields") + collection_reader("methods") + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/union-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/union-info.rb new file mode 100644 index 0000000..f19ce08 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/lib/gobject-introspection/union-info.rb @@ -0,0 +1,28 @@ +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "gobject-introspection/collection-reader" + +module GObjectIntrospection + class UnionInfo + extend CollectionReader + + alias_method :__methods__, :methods + + collection_reader("fields") + collection_reader("methods") + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/patches/0001-Support-external-g-ir-scanner.patch b/lib/ruby-gtk2-2.0.2/gobject-introspection/patches/0001-Support-external-g-ir-scanner.patch new file mode 100644 index 0000000..f142bf2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/patches/0001-Support-external-g-ir-scanner.patch @@ -0,0 +1,365 @@ +From be397a8f143edc9808035f78c60159bb9aeedca2 Mon Sep 17 00:00:00 2001 +From: Kouhei Sutou +Date: Sun, 7 Apr 2013 18:51:45 +0900 +Subject: [PATCH] Support external g-ir-scanner + +With this change, you can build binaries for Windows on Debian +GNU/Linux. + +Run configure with the following options: + + % ./configure \ + --host=i686-w64-mingw32 \ + --with-g-ir-scanner=/usr/bin/g-ir-scanner \ + --disable-tests +--- + Makefile-gir.am | 29 +++++++++++++---------- + Makefile-giscanner.am | 6 +++++ + Makefile-tools.am | 15 +++++++++++- + Makefile.am | 5 +++- + common.mk | 9 ++++--- + configure.ac | 54 ++++++++++++++++++++++++++++++++---------- + tests/Makefile.am | 2 ++ + tests/offsets/Makefile.am | 6 +++++ + tests/repository/Makefile.am | 2 ++ + tests/scanner/Makefile.am | 4 ++++ + 10 files changed, 103 insertions(+), 29 deletions(-) + +diff --git a/Makefile-gir.am b/Makefile-gir.am +index 2b39e54..63b2f2b 100644 +--- a/Makefile-gir.am ++++ b/Makefile-gir.am +@@ -26,17 +26,17 @@ CLEANFILES += gir/cairo-1.0.gir + EXTRA_DIST += gir/cairo-1.0.gir.in + + # Doesn't seem to work to do gir/%.typelib =( +-gir/cairo-1.0.typelib: g-ir-compiler +-gir/DBus-1.0.typelib: g-ir-compiler +-gir/DBusGLib-1.0.typelib: g-ir-compiler +-gir/fontconfig-2.0.typelib: g-ir-compiler +-gir/freetype2-2.0.typelib: g-ir-compiler +-gir/GL-1.0.typelib: g-ir-compiler +-gir/libxml2-2.0.typelib: g-ir-compiler +-gir/xft-2.0.typelib: g-ir-compiler +-gir/xlib-2.0.typelib: g-ir-compiler +-gir/xfixes-4.0.typelib: g-ir-compiler +-gir/xrandr-1.3.typelib: g-ir-compiler ++gir/cairo-1.0.typelib: g-ir-compiler$(EXEEXT) ++gir/DBus-1.0.typelib: g-ir-compiler$(EXEEXT) ++gir/DBusGLib-1.0.typelib: g-ir-compiler$(EXEEXT) ++gir/fontconfig-2.0.typelib: g-ir-compiler$(EXEEXT) ++gir/freetype2-2.0.typelib: g-ir-compiler$(EXEEXT) ++gir/GL-1.0.typelib: g-ir-compiler$(EXEEXT) ++gir/libxml2-2.0.typelib: g-ir-compiler$(EXEEXT) ++gir/xft-2.0.typelib: g-ir-compiler$(EXEEXT) ++gir/xlib-2.0.typelib: g-ir-compiler$(EXEEXT) ++gir/xfixes-4.0.typelib: g-ir-compiler$(EXEEXT) ++gir/xrandr-1.3.typelib: g-ir-compiler$(EXEEXT) + + # glib with source (to enable documentation) + if WITH_GLIBSRC +@@ -89,7 +89,12 @@ endif + + BUILT_GIRSOURCES += GLib-2.0.gir + +-GLib-2.0.gir: g-ir-scanner g-ir-compiler$(EXEEXT) ++if BUILD_SCANNER ++G_IR_SCANNER_DEPENDENCY = g-ir-scanner ++else ++G_IR_SCANNER_DEPENDENCY = ++endif ++GLib-2.0.gir: $(G_IR_SCANNER_DEPENDENCY) g-ir-compiler$(EXEEXT) + + gir/DBusGLib-1.0.typelib: GObject-2.0.gir + +diff --git a/Makefile-giscanner.am b/Makefile-giscanner.am +index e8def0e..4c1d21e 100644 +--- a/Makefile-giscanner.am ++++ b/Makefile-giscanner.am +@@ -1,17 +1,21 @@ + ## Process this file with automake to produce Makefile.in + ++if BUILD_SCANNER + BUILT_SOURCES += \ + scannerparser.c \ + scannerparser.h \ + scannerlexer.c \ + scannerlexer.h ++endif + + AM_YFLAGS = -d -t + + # Why do I have to do this automake? + scannerlexer.h: scannerlexer.c + ++if BUILD_SCANNER + noinst_LTLIBRARIES += libgiscanner.la ++endif + + libgiscanner_la_SOURCES = \ + giscanner/sourcescanner.c \ +@@ -25,7 +29,9 @@ libgiscanner_la_CFLAGS = $(GOBJECT_CFLAGS) $(GIO_CFLAGS) + + # Python module + pkgpyexecdir = $(pkglibdir)/giscanner ++if BUILD_SCANNER + pkgpyexec_LTLIBRARIES = _giscanner.la ++endif + pkgpyexec_PYTHON = \ + giscanner/__init__.py \ + giscanner/annotationmain.py \ +diff --git a/Makefile-tools.am b/Makefile-tools.am +index 34d2a25..87c3a1f 100644 +--- a/Makefile-tools.am ++++ b/Makefile-tools.am +@@ -1,5 +1,8 @@ + bin_PROGRAMS += g-ir-compiler g-ir-generate ++ ++if BUILD_SCANNER + bin_SCRIPTS += g-ir-scanner g-ir-annotation-tool ++endif + + if BUILD_DOCTOOL + bin_SCRIPTS += g-ir-doc-tool +@@ -12,6 +15,7 @@ EXTRA_DIST += \ + + TOOL_SUBSTITUTIONS = sed -e s,@libdir\@,$(libdir), -e s,@datarootdir\@,$(datarootdir), -e s,@PYTHON\@,$(PYTHON), + ++if BUILD_SCANNER + g-ir-scanner: tools/g-ir-scanner.in _giscanner.la Makefile + $(AM_V_GEN) $(TOOL_SUBSTITUTIONS) $< > $@.tmp && mv $@.tmp $@ + @chmod a+x $@ +@@ -19,10 +23,13 @@ g-ir-scanner: tools/g-ir-scanner.in _giscanner.la Makefile + g-ir-annotation-tool: tools/g-ir-annotation-tool.in _giscanner.la Makefile + $(AM_V_GEN) $(TOOL_SUBSTITUTIONS) $< > $@.tmp && mv $@.tmp $@ + @chmod a+x $@ ++endif + ++if BUILD_DOCTOOL + g-ir-doc-tool: tools/g-ir-doc-tool.in _giscanner.la Makefile + $(AM_V_GEN) $(TOOL_SUBSTITUTIONS) $< > $@.tmp && mv $@.tmp $@ + @chmod a+x $@ ++endif + + g_ir_compiler_SOURCES = tools/compiler.c + g_ir_compiler_CPPFLAGS = -DGIREPO_DEFAULT_SEARCH_PATH="\"$(libdir)\"" \ +@@ -46,4 +53,10 @@ GCOVSOURCES = \ + $(g_ir_compiler_SOURCES) \ + $(g_ir_generate_SOURCES) + +-CLEANFILES += g-ir-scanner g-ir-annotation-tool g-ir-doc-tool ++if BUILD_SCANNER ++CLEANFILES += g-ir-scanner g-ir-annotation-tool ++endif ++ ++if BUILD_DOCTOOL ++CLEANFILES += g-ir-doc-tool ++endif +diff --git a/Makefile.am b/Makefile.am +index 736f3ad..08014bc 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -33,8 +33,11 @@ DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc + + man_MANS += \ + docs/g-ir-compiler.1 \ +- docs/g-ir-generate.1 \ ++ docs/g-ir-generate.1 ++if BUILD_SCANNER ++man_MANS += \ + docs/g-ir-scanner.1 ++endif + + pkgconfigdir = $(libdir)/pkgconfig + pkgconfig_DATA = gobject-introspection-1.0.pc gobject-introspection-no-export-1.0.pc +diff --git a/common.mk b/common.mk +index 28b73c7..15552fa 100644 +--- a/common.mk ++++ b/common.mk +@@ -9,11 +9,14 @@ + INTROSPECTION_SCANNER = \ + env PATH=.libs:$(PATH) \ + LPATH=.libs \ +- CC="$(CC)" \ ++ CC="$(CC)" ++if BUILD_SCANNER ++INTROSPECTION_SCANNER += \ + PYTHONPATH=$(top_builddir):$(top_srcdir) \ + UNINSTALLED_INTROSPECTION_SRCDIR=$(top_srcdir) \ +- UNINSTALLED_INTROSPECTION_BUILDDIR=$(top_builddir) \ +- $(top_builddir)/g-ir-scanner ++ UNINSTALLED_INTROSPECTION_BUILDDIR=$(top_builddir) ++endif ++INTROSPECTION_SCANNER += $(G_IR_SCANNER) + + INTROSPECTION_SCANNER_ARGS = \ + --verbose \ +diff --git a/configure.ac b/configure.ac +index 3537af1..604b164 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -246,19 +246,42 @@ AC_FUNC_STRTOD + AC_CHECK_FUNCS([memchr strchr strspn strstr strtol strtoull]) + AC_CHECK_FUNCS([backtrace backtrace_symbols]) + +-# Python +-AM_PATH_PYTHON([2.5]) +-case "$host" in +-*-*-mingw*) +- # Change backslashes to forward slashes in pyexecdir to avoid +- # quoting issues +- pyexecdir=`echo $pyexecdir | tr '\\\\' '/'` +- ;; ++AC_ARG_WITH(g_ir_scanner, ++ AS_HELP_STRING([--with-g-ir-scanner], ++ [Use existing g-ir-scanner instead of building. @<:@default=no@:>@]), ++ [], ++ [with_g_ir_scanner=no]) ++case "x${with_g_ir_scanner}" in ++xyes) ++ AC_PATH_PROG(G_IR_SCANNER, ++ [g-ir-scanner], ++ [AC_MSG_ERROR([g-ir-scanner not found.])]) ++ build_g_ir_scanner=no ++ ;; ++xno) ++ # Python ++ AM_PATH_PYTHON([2.5]) ++ case "$host" in ++ *-*-mingw*) ++ # Change backslashes to forward slashes in pyexecdir to avoid ++ # quoting issues ++ pyexecdir=`echo $pyexecdir | tr '\\\\' '/'` ++ ;; ++ esac ++ AM_CHECK_PYTHON_HEADERS(, AC_MSG_ERROR([Python headers not found])) ++ if test "x$os_win32" = "xyes"; then ++ AM_CHECK_PYTHON_LIBS(, AC_MSG_ERROR([Python libs not found. Windows requires Python modules to be explicitly linked to libpython.])) ++ fi ++ G_IR_SCANNER="\$(top_builddir)/g-ir-scanner" ++ build_g_ir_scanner=yes ++ ;; ++*) ++ G_IR_SCANNER="${with_g_ir_scanner}" ++ build_g_ir_scanner=no ++ ;; + esac +-AM_CHECK_PYTHON_HEADERS(, AC_MSG_ERROR([Python headers not found])) +-if test "x$os_win32" = "xyes"; then +- AM_CHECK_PYTHON_LIBS(, AC_MSG_ERROR([Python libs not found. Windows requires Python modules to be explicitly linked to libpython.])) +-fi ++AC_SUBST(G_IR_SCANNER) ++AM_CONDITIONAL(BUILD_SCANNER, test x${build_g_ir_scanner} = xyes) + + dnl Not enabled by default until 3.6 cycle when we can propose mako as + dnl an external dependency +@@ -310,6 +333,13 @@ fi + + AC_SUBST(EXTRA_LINK_FLAGS) + ++AC_ARG_ENABLE(tests, ++ [AS_HELP_STRING([--disable-tests], ++ [disable tests])], ++ [], ++ [enable_tests=yes]) ++AM_CONDITIONAL(ENABLE_TESTS, test x"$enable_tests" = xyes) ++ + AC_CONFIG_FILES([ + Makefile + m4/Makefile +diff --git a/tests/Makefile.am b/tests/Makefile.am +index b4985b9..5c9db00 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -16,7 +16,9 @@ tests_DATA = \ + gimarshallingtests.c \ + gimarshallingtests.h + ++if ENABLE_TESTS + check_LTLIBRARIES = libeverything-1.0.la libgimarshallingtests-1.0.la ++endif + + libeverything_1_0_la_SOURCES = everything.c + libgimarshallingtests_1_0_la_SOURCES = gimarshallingtests.c +diff --git a/tests/offsets/Makefile.am b/tests/offsets/Makefile.am +index 4f03830..053bd93 100644 +--- a/tests/offsets/Makefile.am ++++ b/tests/offsets/Makefile.am +@@ -11,7 +11,9 @@ check_PROGRAMS = + + ############################################################ + ++if ENABLE_TESTS + check_LTLIBRARIES += liboffsets.la ++endif + + liboffsets_la_SOURCES = \ + offsets.h \ +@@ -32,7 +34,9 @@ CLEANFILES += Offsets-1.0.gir Offsets-1.0.typelib + + ############################################################ + ++if ENABLE_TESTS + check_PROGRAMS += gitestoffsets ++endif + + nodist_gitestoffsets_SOURCES = gitestoffsets.c + gitestoffsets_CPPFLAGS = $(GIREPO_CFLAGS) -I$(top_srcdir)/girepository +@@ -42,8 +46,10 @@ gitestoffsets.c: gen-gitestoffsets offsets.h + $(AM_V_GEN) $(PYTHON) $(srcdir)/gen-gitestoffsets $(srcdir)/offsets.h > $@ || ( rm -f $@ && false ) + + EXTRA_DIST += gen-gitestoffsets ++if ENABLE_TESTS + BUILT_SOURCES += gitestoffsets.c + CLEANFILES += gitestoffsets.c ++endif + + ############################################################ + +diff --git a/tests/repository/Makefile.am b/tests/repository/Makefile.am +index 96afb89..0553a8b 100644 +--- a/tests/repository/Makefile.am ++++ b/tests/repository/Makefile.am +@@ -2,7 +2,9 @@ AM_CFLAGS = $(GOBJECT_CFLAGS) + AM_LDFLAGS = -module -avoid-version + LIBS = $(GOBJECT_LIBS) + ++if ENABLE_TESTS + check_PROGRAMS = gitestrepo gitestthrows gitypelibtest ++endif + + gitestrepo_SOURCES = $(srcdir)/gitestrepo.c + gitestrepo_CPPFLAGS = $(GIREPO_CFLAGS) -I$(top_srcdir)/girepository +diff --git a/tests/scanner/Makefile.am b/tests/scanner/Makefile.am +index 31487a6..65c02fa 100644 +--- a/tests/scanner/Makefile.am ++++ b/tests/scanner/Makefile.am +@@ -5,6 +5,7 @@ include $(top_srcdir)/Makefile.introspection + + INTROSPECTION_SCANNER_ARGS += --warn-all + ++if ENABLE_TESTS + check_LTLIBRARIES = \ + libsletter.la \ + libutility.la \ +@@ -13,6 +14,7 @@ check_LTLIBRARIES = \ + libregress.la \ + libwarnlib.la \ + $(NULL) ++endif + + AM_CPPFLAGS = -I$(top_srcdir)/girepository + AM_CFLAGS = $(GIO_CFLAGS) $(GOBJECT_CFLAGS) $(GTHREAD_CFLAGS) +@@ -126,7 +128,9 @@ GetType_1_0_gir_SCANNERFLAGS = --c-include="gettype.h" --identifier-prefix=GetTy + GIRS += GetType-1.0.gir + + if !OS_WIN32 ++if ENABLE_TESTS + check_PROGRAMS = barapp ++endif + + barapp_SOURCES = $(srcdir)/barapp.c $(srcdir)/barapp.h + barapp_LDADD = $(top_builddir)/libgirepository-1.0.la +-- +1.7.10.4 + diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/patches/cross-g-ir-scanner.diff b/lib/ruby-gtk2-2.0.2/gobject-introspection/patches/cross-g-ir-scanner.diff new file mode 100644 index 0000000..ccb97b6 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/patches/cross-g-ir-scanner.diff @@ -0,0 +1,36 @@ +diff --git a/giscanner/dumper.py b/giscanner/dumper.py +index d95ea6b..84a7afc 100644 +--- a/giscanner/dumper.py ++++ b/giscanner/dumper.py +@@ -157,8 +157,9 @@ class DumpCompiler(object): + else: + o_path = self._generate_tempfile(tmpdir, '.o') + ++ os.name = 'nt' + if os.name == 'nt': +- ext = 'exe' ++ ext = '.exe' + else: + ext = '' + +@@ -257,10 +258,7 @@ class DumpCompiler(object): + else: + args.extend(['-o', output]) + if libtool: +- if os.name == 'nt': +- args.append('-export-all-symbols') +- else: +- args.append('-export-dynamic') ++ args.append('-export-dynamic') + + cflags = os.environ.get('CFLAGS', '') + for cflag in cflags.split(): +@@ -354,6 +352,8 @@ class DumpCompiler(object): + if self._pkgconfig_msvc_flags == '': + if library.endswith(".la"): # explicitly specified libtool library + args.append(library) ++ elif library.startswith("lib") and library.endswith("-0"): ++ args.append('-l' + library[3:-2]) + else: + args.append('-l' + library) + diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/gobject-introspection-test-utils.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/gobject-introspection-test-utils.rb new file mode 100644 index 0000000..49ecfb3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/gobject-introspection-test-utils.rb @@ -0,0 +1,26 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "test-unit" +require "test/unit/notify" + +module GObjectIntrospectionTestUtils + def require_version(major, minor, micro) + if (GObjectIntrospection::BUILD_VERSION <=> [major, minor, micro]) < 0 + omit("require GObjectIntrospection #{major}.#{minor}.#{micro} or later.") + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/run-test.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/run-test.rb new file mode 100755 index 0000000..6ae0462 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/run-test.rb @@ -0,0 +1,45 @@ +#!/usr/bin/env ruby +# +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +ruby_gnome2_base = File.join(File.dirname(__FILE__), "..", "..") +ruby_gnome2_base = File.expand_path(ruby_gnome2_base) + +glib_base = File.join(ruby_gnome2_base, "glib2") +gobject_introspection_base = File.join(ruby_gnome2_base, "gobject-introspection") + +modules = [ + [glib_base, "glib2"], + [gobject_introspection_base, "gobject-introspection"] +] +modules.each do |target, module_name| + if system("which make > /dev/null") + `make -C #{target.dump} > /dev/null` or exit(false) + end + $LOAD_PATH.unshift(File.join(target, "ext", module_name)) + $LOAD_PATH.unshift(File.join(target, "lib")) +end + +$LOAD_PATH.unshift(File.join(glib_base, "test")) +require "glib-test-init" + +$LOAD_PATH.unshift(File.join(gobject_introspection_base, "test")) +require "gobject-introspection-test-utils" + +require "gobject-introspection" + +exit Test::Unit::AutoRunner.run(true) diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-arg-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-arg-info.rb new file mode 100644 index 0000000..3dcee00 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-arg-info.rb @@ -0,0 +1,68 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestArgInfo < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("GObject") + @callable_info = @repository.find("GObject", "signal_name") + @info = @callable_info.get_arg(0) + end + + def test_direction + assert_equal(GObjectIntrospection::Direction::IN, + @info.direction) + end + + def test_caller_allocate? + assert_false(@info.caller_allocates?) + end + + def test_return_value? + assert_false(@info.return_value?) + end + + def test_optional? + assert_false(@info.optional?) + end + + def test_may_be_null? + assert_false(@info.may_be_null?) + end + + def test_ownership_transfer + assert_equal(GObjectIntrospection::Transfer::NOTHING, + @info.ownership_transfer) + end + + def test_scope + assert_equal(GObjectIntrospection::ScopeType::INVALID, + @info.scope) + end + + def test_closure + assert_equal(-1, @info.closure) + end + + def test_destroy + assert_equal(-1, @info.destroy) + end + + def test_type + assert_kind_of(GObjectIntrospection::TypeInfo, + @info.type) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-base-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-base-info.rb new file mode 100644 index 0000000..1c6d7c5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-base-info.rb @@ -0,0 +1,31 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestBaseInfo < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("GObject") + @info = @repository.find("GObject", "Object") + end + + def test_name + assert_equal("Object", @info.name) + end + + def test_namespace + assert_equal("GObject", @info.namespace) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-boxed-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-boxed-info.rb new file mode 100644 index 0000000..08b7212 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-boxed-info.rb @@ -0,0 +1,21 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestBoxedInfo < Test::Unit::TestCase + def setup + # TODO: find BoxedInfo + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-callable-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-callable-info.rb new file mode 100644 index 0000000..a9c235f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-callable-info.rb @@ -0,0 +1,49 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestCallableInfo < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("GObject") + @info = @repository.find("GObject", "signal_name") + end + + def test_return_type + assert_kind_of(GObjectIntrospection::TypeInfo, + @info.return_type) + end + + def test_caller_owns + assert_equal(GObjectIntrospection::Transfer::NOTHING, + @info.caller_owns) + end + + def test_may_return_null? + assert_false(@info.may_return_null?) + end + + def test_n_args + assert_equal(1, @info.n_args) + end + + def test_get_arg + assert_equal("signal_id", @info.get_arg(0).name) + end + + def test_args + assert_equal(["signal_id"], @info.args.collect(&:name)) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-callback-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-callback-info.rb new file mode 100644 index 0000000..577ed48 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-callback-info.rb @@ -0,0 +1,29 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestCallbackInfo < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("Gio") + @info = @repository.find("Gio", "AsyncReadyCallback") + end + + def test_name + assert_equal(GObjectIntrospection::Transfer::NOTHING, + @info.caller_owns) + end +end + diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-constant-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-constant-info.rb new file mode 100644 index 0000000..0d1d878 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-constant-info.rb @@ -0,0 +1,24 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestConstantInfo < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("GObject") + # TODO: find ConstantInfo + # @info = @repository.find("GObject", "Object") + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-enum-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-enum-info.rb new file mode 100644 index 0000000..58641f5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-enum-info.rb @@ -0,0 +1,56 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestEnumInfo < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("Gio") + @info = @repository.find("Gio", "ResourceError") + end + + def test_n_values + assert_equal(2, @info.n_values) + end + + def test_value + assert_kind_of(GObjectIntrospection::ValueInfo, + @info.get_value(0)) + end + + def test_values + assert_equal([GObjectIntrospection::ValueInfo] * @info.n_values, + @info.values.collect(&:class)) + end + + def test_n_methods + assert_equal(1, @info.n_methods) + end + + def test_method + assert_kind_of(GObjectIntrospection::FunctionInfo, + @info.get_method(0)) + end + + def test_methods + assert_equal([GObjectIntrospection::FunctionInfo] * @info.n_methods, + @info.methods.collect(&:class)) + end + + def test_storage_type + assert_equal(GObjectIntrospection::TypeTag::UINT32, + @info.storage_type) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-field-type.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-field-type.rb new file mode 100644 index 0000000..70f4c0b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-field-type.rb @@ -0,0 +1,42 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestFieldInfo < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("Gio") + @object_info = @repository.find("Gio", "FileOutputStream") + @info = @object_info.get_field(0) + end + + def test_flags + assert_equal(GObjectIntrospection::FieldInfoFlags::READABLE, + @info.flags) + end + + def test_size + assert_equal(0, @info.size) + end + + def test_offset + assert_equal(0, @info.offset) + end + + def test_type + assert_kind_of(GObjectIntrospection::TypeInfo, + @info.type) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-flags-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-flags-info.rb new file mode 100644 index 0000000..107b00e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-flags-info.rb @@ -0,0 +1,27 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestFlagsInfo < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("GObject") + end + + def test_class + assert_kind_of(GObjectIntrospection::FlagsInfo, + @repository.find("GObject", "SignalFlags")) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-function-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-function-info.rb new file mode 100644 index 0000000..a93cadb --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-function-info.rb @@ -0,0 +1,37 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestFunctionInfo < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("GObject") + @info = @repository.find("GObject", "signal_name") + end + + def test_symbol + assert_equal("g_signal_name", @info.symbol) + end + + def test_flags + assert_equal(GObjectIntrospection::FunctionInfoFlags.new(0), + @info.flags) + end + + def test_invoke + assert_equal("notify", @info.invoke(1)) + end +end + diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-interface-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-interface-info.rb new file mode 100644 index 0000000..e724df3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-interface-info.rb @@ -0,0 +1,97 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestInterfaceInfo < Test::Unit::TestCase + include GObjectIntrospectionTestUtils + + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("Gio") + @info = @repository.find("Gio", "TlsServerConnection") + end + + def test_n_prerequisites + assert_equal(1, @info.n_prerequisites) + end + + def test_prerequisite + assert_kind_of(GObjectIntrospection::ObjectInfo, + @info.get_prerequisite(0)) + end + + def test_n_properties + assert_equal(1, @info.n_properties) + end + + def test_propertiy + assert_kind_of(GObjectIntrospection::PropertyInfo, + @info.get_property(0)) + end + + def test_n_methods + assert_equal(1, @info.n_methods) + end + + def test_get_method_n + assert_kind_of(GObjectIntrospection::FunctionInfo, + @info.get_method(0)) + end + + def test_get_method_name + assert_kind_of(GObjectIntrospection::FunctionInfo, + @info.get_method("new")) + end + + def test_n_signals + info = @repository.find("Gio", "Volume") + assert_equal(2, info.n_signals) + end + + def test_get_signal_n + info = @repository.find("Gio", "Volume") + assert_kind_of(GObjectIntrospection::SignalInfo, + info.get_signal(0)) + end + + def test_get_signal_name + require_version(1, 34, 0) + info = @repository.find("Gio", "Volume") + assert_kind_of(GObjectIntrospection::FunctionInfo, + info.get_signal("changed")) + end + + def test_n_vfuncs + info = @repository.find("Gio", "Volume") + assert_operator(0, :<, info.n_vfuncs) + end + + def test_get_vfunc_n + info = @repository.find("Gio", "Volume") + assert_kind_of(GObjectIntrospection::VFuncInfo, + info.get_vfunc(0)) + end + + def test_get_vfunc_name + info = @repository.find("Gio", "Volume") + assert_kind_of(GObjectIntrospection::VFuncInfo, + info.get_vfunc("can_eject")) + end + + def test_iface_struct + assert_kind_of(GObjectIntrospection::StructInfo, + @info.iface_struct) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-loader.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-loader.rb new file mode 100644 index 0000000..8793a89 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-loader.rb @@ -0,0 +1,30 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestLoaderInfo < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("Gio") + @info = @repository.find("Gio", "Application") + @sandbox = Module.new + end + + def test_define_class + gtype = @info.gtype + GObjectIntrospection::Loader.define_class(gtype, "Application", @sandbox) + assert_equal(gtype, @sandbox::Application.gtype) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-object-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-object-info.rb new file mode 100644 index 0000000..675e682 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-object-info.rb @@ -0,0 +1,131 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestObjectInfo < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("Gio") + @info = @repository.find("Gio", "FileOutputStream") + end + + def test_type_name + assert_equal("GFileOutputStream", @info.type_name) + end + + def test_type_init + assert_equal("g_file_output_stream_get_type", @info.type_init) + end + + def test_abstract? + assert_false(@info.abstract?) + end + + def test_fundamental? + assert_false(@info.fundamental?) + end + + def test_parent + assert_equal("OutputStream", @info.parent.name) + end + + def test_n_interfaces + assert_equal(1, @info.n_interfaces) + end + + def test_get_interface + assert_kind_of(GObjectIntrospection::InterfaceInfo, + @info.get_interface(0)) + end + + def test_n_fields + assert_equal(2, @info.n_fields) + end + + def test_get_field + assert_kind_of(GObjectIntrospection::FieldInfo, + @info.get_field(0)) + end + + def test_n_properties + info = @repository.find("Gio", "BufferedOutputStream") + assert_equal(2, info.n_properties) + end + + def test_get_property + info = @repository.find("Gio", "BufferedOutputStream") + assert_kind_of(GObjectIntrospection::PropertyInfo, + info.get_property(0)) + end + + def test_n_methods + assert_equal(4, @info.n_methods) + end + + def test_get_method_n + assert_kind_of(GObjectIntrospection::FunctionInfo, + @info.get_method(0)) + end + + def test_get_method_name + assert_kind_of(GObjectIntrospection::FunctionInfo, + @info.get_method("get_etag")) + end + + def test_n_signals + info = @repository.find("Gio", "Application") + assert_equal(5, info.n_signals) + end + + def test_get_signal + info = @repository.find("Gio", "Application") + assert_kind_of(GObjectIntrospection::SignalInfo, + info.get_signal(0)) + end + + def test_n_vfuncs + assert_equal(9, @info.n_vfuncs) + end + + def test_get_vfunc_n + assert_kind_of(GObjectIntrospection::VFuncInfo, + @info.get_vfunc(0)) + end + + def test_get_vfunc_name + assert_kind_of(GObjectIntrospection::VFuncInfo, + @info.get_vfunc("can_seek")) + end + + def test_n_constants + assert_equal(0, @info.n_constants) + end + + def test_unref_function + assert_nil(@info.unref_function) + end + + def test_ref_function + assert_nil(@info.ref_function) + end + + def test_set_value_function + assert_nil(@info.set_value_function) + end + + def test_get_value_function + assert_nil(@info.get_value_function) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-property-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-property-info.rb new file mode 100644 index 0000000..a723b83 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-property-info.rb @@ -0,0 +1,38 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestPropertyInfo < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("Gio") + @object_info = @repository.find("Gio", "Application") + @info = @object_info.get_property(0) + end + + def test_flags + assert_equal(GLib::Param::WRITABLE, @info.flags) + end + + def test_type + assert_kind_of(GObjectIntrospection::TypeInfo, + @info.type) + end + + def test_ownership_transfer + assert_equal(GObjectIntrospection::Transfer::NOTHING, + @info.ownership_transfer) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-registered-type-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-registered-type-info.rb new file mode 100644 index 0000000..f8184d9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-registered-type-info.rb @@ -0,0 +1,35 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestRegisteredTypeInfo < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("GObject") + @info = @repository.find("GObject", "TypePlugin") + end + + def test_type_name + assert_equal("GTypePlugin", @info.type_name) + end + + def test_type_init + assert_equal("g_type_plugin_get_type", @info.type_init) + end + + def test_gtype + assert_equal(GLib::Type.new("GTypePlugin"), @info.gtype) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-repository.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-repository.rb new file mode 100644 index 0000000..a180d64 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-repository.rb @@ -0,0 +1,59 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestRepository < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("GObject") + @repository.require("Gio") + end + + def test_get_n_infos + assert_kind_of(Integer, @repository.get_n_infos("GObject")) + end + + def test_get_info + assert_kind_of(GObjectIntrospection::BaseInfo, + @repository.get_info("GObject", 0)) + end + + def test_get_dependencies + assert_equal(["GLib-2.0", "GObject-2.0"].sort, + @repository.get_dependencies("Gio").sort) + end + + def test_loaded_namespaces + assert_equal(["GLib", "GObject", "Gio"].sort, + @repository.loaded_namespaces.sort) + end + + def test_enumerable + namespaces = @repository.collect do |info| + info.namespace + end + assert_equal(["GLib", "GObject", "Gio"].sort, namespaces.uniq.sort) + end + + def test_find_by_gtype + info = @repository.find(GLib::Object.gtype) + assert_equal("Object", info.name) + end + + def test_find_by_name + info = @repository.find("GObject", "Object") + assert_equal("Object", info.name) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-signal-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-signal-info.rb new file mode 100644 index 0000000..b2d608f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-signal-info.rb @@ -0,0 +1,37 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestSignalInfo < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("Gio") + @object_info = @repository.find("Gio", "Application") + @info = @object_info.get_signal(0) + end + + def test_flags + assert_equal(GLib::SignalFlags::RUN_CLEANUP, + @info.flags) + end + + def test_class_closure + assert_nil(@info.class_closure) + end + + def test_true_stops_emit? + assert_false(@info.true_stops_emit?) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-struct-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-struct-info.rb new file mode 100644 index 0000000..aef5578 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-struct-info.rb @@ -0,0 +1,57 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestStructInfo < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("GObject") + @info = @repository.find("GObject", "Value") + end + + def test_n_fields + assert_equal(2, @info.n_fields) + end + + def test_get_field + assert_kind_of(GObjectIntrospection::FieldInfo, + @info.get_field(0)) + end + + def test_n_methods + assert_equal(62, @info.n_methods) + end + + def test_get_method + assert_kind_of(GObjectIntrospection::FunctionInfo, + @info.get_method(0)) + end + + def test_size + assert_equal(24, @info.size) + end + + def test_alignment + assert_equal(8, @info.alignment) + end + + def test_gtype_struct? + assert_false(@info.gtype_struct?) + end + + def test_foreign? + assert_false(@info.foreign?) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-type-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-type-info.rb new file mode 100644 index 0000000..fa43f0b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-type-info.rb @@ -0,0 +1,62 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestTypeInfo < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("GObject") + @function_info = @repository.find("GObject", "signal_list_ids") + @info = @function_info.return_type + end + + def test_pointer? + assert_true(@info.pointer?) + end + + def test_tag + assert_kind_of(GObjectIntrospection::TypeTag, + @info.tag) + end + + def test_param_type + assert_kind_of(GObjectIntrospection::TypeInfo, + @info.get_param_type(0)) + end + + def test_interface + function_info = @repository.find("GObject", "type_class_ref") + info = function_info.return_type + assert_kind_of(GObjectIntrospection::StructInfo, + info.interface) + end + + def test_array_length + assert_equal(1, @info.array_length) + end + + def test_array_fixed_size + assert_equal(-1, @info.array_fixed_size) + end + + def test_zero_terminated? + assert_false(@info.zero_terminated?) + end + + def test_array_type + assert_equal(GObjectIntrospection::ArrayType::C, + @info.array_type) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-type-tag.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-type-tag.rb new file mode 100644 index 0000000..0c52e3b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-type-tag.rb @@ -0,0 +1,29 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestTypeTag < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("GObject") + @function_info = @repository.find("GObject", "signal_list_ids") + @type_info = @function_info.return_type + @tag = @type_info.tag + end + + def test_to_s + assert_equal("array", @tag.to_s) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-union-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-union-info.rb new file mode 100644 index 0000000..b611e76 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-union-info.rb @@ -0,0 +1,21 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestUnionInfo < Test::Unit::TestCase + def setup + # TODO: find UnionInfo + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-value-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-value-info.rb new file mode 100644 index 0000000..5b60310 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-value-info.rb @@ -0,0 +1,28 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestValueInfo < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("GObject") + @flags_info = @repository.find("GObject", "SignalFlags") + @info = @flags_info.get_value(0) + end + + def test_value + assert_equal(1, @info.value) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-vfunc-info.rb b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-vfunc-info.rb new file mode 100644 index 0000000..d492701 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gobject-introspection/test/test-vfunc-info.rb @@ -0,0 +1,42 @@ +# Copyright (C) 2012 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestVFuncInfo < Test::Unit::TestCase + def setup + @repository = GObjectIntrospection::Repository.default + @repository.require("Gio") + @object_info = @repository.find("Gio", "FileOutputStream") + @info = @object_info.get_vfunc(0) + end + + def test_flags + assert_equal(GObjectIntrospection::VFuncInfoFlags.new, + @info.flags) + end + + def test_offset + assert_equal(GObjectIntrospection::VFuncInfo::UNKNOWN_OFFSET, + @info.offset) + end + + def test_signal + assert_nil(@info.signal) + end + + def test_invoker + assert_nil(@info.invoker) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/COPYING.LIB b/lib/ruby-gtk2-2.0.2/gtk2/COPYING.LIB new file mode 100644 index 0000000..b1e3f5a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/COPYING.LIB @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. + + GNU LESSER GENERAL PUBLIC LICENSE + 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 + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/README b/lib/ruby-gtk2-2.0.2/gtk2/README new file mode 100644 index 0000000..b642772 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/README @@ -0,0 +1,33 @@ +Ruby/GTK2 +========= +Ruby/GTK2 is a Ruby binding of GTK+-2.0.x. + +Requirements +------------ + Ruby: http://www.ruby-lang.org/ + GTK+: http://www.gtk.org/ + Pango: http://www.pango.org/ + cairo/rcairo: http://cairographics.org/ (optional) + Ruby/GLib2, Ruby/ATK, Ruby/Pango: http://ruby-gnome2.sourceforge.net/ + +Install +------- + 0. install ruby-1.6.x or later, GTK+-2.0.x, Ruby/GLib2, Ruby/Pango + (and cairo/rcairo). + 1. ruby extconf.rb + (To use rcairo on Win32, set CAIRO_PATH as a environment variable first) + 2. make + 3. su + 4. make install + +Copying +------- + Copyright (c) 2002-2005 Ruby-GNOME2 Project Team + + This program is free software. + You can distribute/modify this program under the terms of + the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. + +Project Website +--------------- + http://ruby-gnome2.sourceforge.jp/ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/Rakefile b/lib/ruby-gtk2-2.0.2/gtk2/Rakefile new file mode 100644 index 0000000..adf45a9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/Rakefile @@ -0,0 +1,57 @@ +# -*- ruby -*- + +$LOAD_PATH.unshift("./../glib2/lib") +require 'gnome2-raketask' + +package = GNOME2Package.new do |_package| + _package.summary = "Ruby/GTK2 is a Ruby binding of GTK+-2.x." + _package.description = "Ruby/GTK2 is a Ruby binding of GTK+-2.x." + _package.dependency.gem.runtime = ["atk", "pango", "gdk_pixbuf2"] + _package.win32.packages = [] + _package.win32.dependencies = [] + _package.win32.build_dependencies = [ + "glib2", "atk", "pango", "gdk_pixbuf2", + ] + _package.external_packages = [ + { + :name => "gtk+", + :download_site => :gnome, + :label => "gtk+", + :version => "2.24.18", + :compression_method => "xz", + :windows => { + :configure_args => [], + :need_autoreconf => true, + :patches => [ + "gtk+-2.24.14-add-missing-exeext.diff", + ], + }, + }, + { + :name => "hicolor-icon-theme", + :download_base_url => "http://icon-theme.freedesktop.org/releases", + :label => "gtk-hi-color-icon-theme", + :version => "0.12", + :windows => { + :configure_args => [], + :build_concurrently => false, + } + }, + ] +end +package.define_tasks + +namespace :win32 do + desc "create default gtkrc" + task :gtkrc do + gtkrc_path = File.join("vendor", "local", "etc", "gtk-2.0", "gtkrc") + mkdir_p(File.dirname(gtkrc_path)) + File.open(gtkrc_path, "w") do |gtkrc| + gtkrc.puts('gtk-theme-name = "MS-Windows"') + end + end + + namespace :builder do + task :after => ["win32:gtkrc"] + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/depend b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/depend new file mode 100644 index 0000000..0b8572e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/depend @@ -0,0 +1,14 @@ +install-so: install-headers +install-headers: + $(INSTALL_DATA) $(srcdir)/rbgdk.h $(RUBYARCHDIR) + $(INSTALL_DATA) $(srcdir)/rbgdkconversions.h $(RUBYARCHDIR) + $(INSTALL_DATA) $(srcdir)/rbgtk.h $(RUBYARCHDIR) + $(INSTALL_DATA) $(srcdir)/rbgtkconversions.h $(RUBYARCHDIR) + $(INSTALL_DATA) $(srcdir)/rbgtkmacros.h $(RUBYARCHDIR) + +install: install-pc +install-pc: + if test -n "$(pkgconfigdir)"; then \ + $(MAKEDIRS) $(pkgconfigdir); \ + $(INSTALL_DATA) ruby-gtk2.pc $(pkgconfigdir); \ + fi diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/extconf.rb b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/extconf.rb new file mode 100644 index 0000000..f6ccd2c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/extconf.rb @@ -0,0 +1,139 @@ +=begin +extconf.rb for Ruby/GTK extention library +=end + +require 'pathname' + +source_dir = Pathname(__FILE__).dirname +base_dir = source_dir.parent.parent.expand_path +top_dir = base_dir.parent.expand_path +top_build_dir = Pathname(".").parent.parent.parent.expand_path + +mkmf_gnome2_dir = top_dir + "glib2" + 'lib' +version_suffix = "" +unless mkmf_gnome2_dir.exist? + if /(-\d+\.\d+\.\d+)(?:\.\d+)?\z/ =~ base_dir.basename.to_s + version_suffix = $1 + mkmf_gnome2_dir = top_dir + "glib2#{version_suffix}" + 'lib' + end +end + +$LOAD_PATH.unshift(mkmf_gnome2_dir.to_s) + +module_name = "gtk2" +package_id = "gtk+-2.0" + +begin + require 'mkmf-gnome2' +rescue LoadError + require 'rubygems' + gem 'glib2' + require 'mkmf-gnome2' +end + +have_func("rb_errinfo") + +["glib2", "atk", "pango", "gdk_pixbuf2"].each do |package| + directory = "#{package}#{version_suffix}" + build_dir = "#{directory}/tmp/#{RUBY_PLATFORM}/#{package}/#{RUBY_VERSION}" + add_depend_package(package, "#{directory}/ext/#{package}", + top_dir.to_s, + :top_build_dir => top_build_dir.to_s, + :target_build_dir => build_dir) +end + +rcairo_options = {} +rcairo_source_dir_names = ["rcairo"] +if /mingw|cygwin|mswin/ =~ RUBY_PLATFORM + rcairo_source_dir_names.unshift("rcairo.win32") +end +rcairo_source_dir_names.each do |rcairo_source_dir_name| + rcairo_source_dir = top_dir.parent.expand_path + rcairo_source_dir_name + if rcairo_source_dir.exist? + rcairo_options[:rcairo_source_dir] = rcairo_source_dir.to_s + break + end +end +check_cairo(rcairo_options) + +setup_win32(module_name, base_dir) + +unless required_pkg_config_package(package_id, + :debian => "libgtk2.0-dev", + :redhat => "gtk2-devel", + :homebrew => "gtk+", + :macports => "gtk2") + exit(false) +end + +have_header("st.h") +have_header("ruby/st.h") + +STDOUT.print("checking for target... ") +STDOUT.flush +target = PKGConfig.variable(package_id, "target") +$defs << "-DRUBY_GTK2_TARGET=\\\"#{target}\\\"" +STDOUT.print(target, "\n") + +gdk_include_path = nil +include_paths = $CFLAGS.gsub(/-D\w+/, '').split(/-I/) + ['/usr/include'] +include_paths.each do |path| + path.strip! + + if FileTest.exist?("#{path}/gdk/gdkkeysyms.h") + gdk_include_path = Pathname("#{path}/gdk") + break + end +end +raise "can't find gdkkeysyms.h" if gdk_include_path.nil? + +gtk_header = "gtk/gtk.h" +have_func('gtk_plug_get_type', gtk_header) +have_func('gtk_socket_get_type', gtk_header) +have_func('pango_render_part_get_type', gtk_header) +have_header('gtk/gtkfilesystem.h') do |src| + "#define GTK_FILE_SYSTEM_ENABLE_UNSUPPORTED\n#{src}" +end + +xlib_header = "X11/Xlib.h" +if target == "x11" and have_header('X11/Xlib.h') and have_library("X11") + have_func("XReadBitmapFileData", xlib_header) + have_func("XGetErrorText", xlib_header) +end + +if target != "win32" and PKGConfig.have_package('gtk+-unix-print-2.0') + $defs.push("-DHAVE_GTK_UNIX_PRINT") +end + +create_pkg_config_file("Ruby/GTK2", package_id, ruby_gnome2_version) + +rbgdkkeysyms_h_path = Pathname("rbgdkkeysyms.h") +gdkkeysyms_h_paths = [] +gdkkeysyms_h_paths << gdk_include_path + "gdkkeysyms.h" +gdkkeysyms_h_paths << gdk_include_path + "gdkkeysyms-compat.h" +rbgdkkeysyms_h_path.open("w") do |rbgdkkeysyms_h| + gdkkeysyms_h_paths.each do |path| + next unless path.exist? + path.each_line do |line| + if /^#define\s+(GDK_\w+)\s+\d+/ =~ line + define_line = "rb_define_const(mGdkKeyval, \"#{$1}\", INT2FIX(#{$1}));" + rbgdkkeysyms_h.puts(define_line) + end + end + end +end + +add_distcleanfile("rbgdkkeysyms.h") + +ensure_objs + +$defs << "-DRUBY_GTK2_COMPILATION" +create_makefile(module_name) + +pkg_config_dir = with_config("pkg-config-dir") +if pkg_config_dir.is_a?(String) + File.open("Makefile", "ab") do |makefile| + makefile.puts + makefile.puts("pkgconfigdir=#{pkg_config_dir}") + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/global.h b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/global.h new file mode 100644 index 0000000..d11d686 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/global.h @@ -0,0 +1,302 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef _RBGTK_GLOBAL_H +#define _RBGTK_GLOBAL_H + +#include "rbgtk.h" +#ifdef HAVE_RUBY_ST_H +# include +#else +# include +#endif + +#undef RG_DEF_METHOD +#define RG_DEF_METHOD(method, argc) \ + rb_define_method(RG_TARGET_NAMESPACE, #method, rg_ ## method, argc) +#undef RG_DEF_SMETHOD +#define RG_DEF_SMETHOD(method, argc) \ + rb_define_singleton_method(RG_TARGET_NAMESPACE, #method, rg_s_ ## method, argc) + +#ifndef HAVE_RB_ERRINFO +# define rb_errinfo() (ruby_errinfo) +#endif + +#ifndef G_VALUE_INIT +# define G_VALUE_INIT { 0, { { 0 } } } +#endif + +#if GTK_CHECK_VERSION(2,8,0) && defined(HAVE_RB_CAIRO_H) +# define CAIRO_AVAILABLE 1 +#else +# define CAIRO_AVAILABLE 0 +#endif + +extern ID id_relative_callbacks; +extern ID id_call; +extern VALUE treeiter_set_value_table; + +G_GNUC_INTERNAL void Init_gtk_gdk(void); +G_GNUC_INTERNAL void Init_gtk_gtk(void); +G_GNUC_INTERNAL void Init_gtk_gdk_atom(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_cairo(void); +G_GNUC_INTERNAL void Init_gtk_gdk_color(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_colormap(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_const(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_cursor(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_device(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_display(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_display_manager(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_dragcontext(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_event(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_geometry(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_image(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_input(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_keymap(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_keyval(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_pango(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_pangorenderer(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_pixbuf(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_pixmap(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_property(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_rectangle(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_region(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_rgb(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_screen(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_selection(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_threads(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_timecoord(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_visual(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_window(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_windowattr(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_x11(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_aboutdialog(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_accelerator(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_accel_group(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_accel_group_entry(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_accel_key(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_accel_label(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_accel_map(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_accessible(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_action(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_actiongroup(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_adjustment(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_alignment(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_allocation(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_arrow(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_aspect_frame(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_assistant(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_button_box(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_bin(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_bindings(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_border(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_box(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_buildable(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_builder(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_button(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_calendar(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_celleditable(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_celllayout(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_cellrenderer(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_cellrendereraccel(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_cellrenderercombo(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_cellrendererpixbuf(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_cellrendererprogress(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_cellrendererspin(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_cellrendererspinner(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_cellrenderertext(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_cellrenderertoggle(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_cellview(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_check_button(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_check_menu_item(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_clipboard(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_colorbutton(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_color_selection(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_color_selection_dialog(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_combo(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_combobox(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_comboboxentry(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_const(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_container(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_curve(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_dialog(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_drag(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_drawing_area(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_editable(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_entry(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_entry_completion(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_eventbox(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_expander(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_file_chooser(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_filesystemerror(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_filechooserbutton(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_file_chooser_dialog(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_file_chooser_widget(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_file_filter(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_file_selection(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_fixed(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_fontbutton(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_font_selection(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_font_selection_dialog(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_frame(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_gamma_curve(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_gdk_draw(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_gdk_gc(VALUE mGdk); +G_GNUC_INTERNAL void Init_gtk_handle_box(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_hbutton_box(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_hbox(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_hpaned(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_hruler(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_hscale(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_hscrollbar(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_hseparator(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_icon_factory(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_iconinfo(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_icon_set(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_icon_size(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_icon_source(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_icon_theme(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_iconview(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_image(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_image_menu_item(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_imcontext(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_imcontext_simple(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_im_multicontext(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_infobar(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_input_dialog(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_invisible(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_item(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_itemfactory(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_label(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_layout(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_link_button(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_list_store(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_menu(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_menu_bar(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_menu_item(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_menu_shell(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_menutoolbutton(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_message_dialog(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_misc(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_notebook(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_object(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_option_menu(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_page_setup(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_page_setup_unix_dialog(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_paned(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_paper_size(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_plug(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_print_context(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_printer(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_print_job(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_print_operation(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_print_operation_preview(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_print_settings(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_print_unix_dialog(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_progress(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_progress_bar(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_radio_action(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_radio_button(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_radio_menu_item(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_radiotoolbutton(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_range(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_rc(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_rcstyle(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_recentaction(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_recent_chooser(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_recent_chooser_dialog(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_recent_chooser_menu(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_recent_chooser_widget(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_recent_data(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_recent_filter(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_recent_filter_info(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_recent_info(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_recent_manager(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_ruler(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_scale(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_scalebutton(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_scrollbar(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_scrolled_window(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_selection(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_selectiondata(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_separator(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_separator_menu_item(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_separatortoolitem(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_settings(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_size_group(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_socket(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_spin_button(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_spinner(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_statusbar(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_status_icon(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_stock(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_style(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_table(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_target_list(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_tearoff_menu_item(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_text_appearance(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_text_attributes(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_textbuffer(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_textchild(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_textiter(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_textmark(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_texttag(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_text_tag_table(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_textview(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_toggle_action(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_toggle_button(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_toggletoolbutton(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_toolbar(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_toolbutton(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_toolitem(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_tooltip(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_tooltips(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_treedragdest(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_treedragsource(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_treeiter(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_treemodel(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_treemodelfilter(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_tmodelsort(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_treepath(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_treerowreference(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_treeselection(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_treesortable(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_tree_store(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_treeview(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_treeviewcolumn(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_uimanager(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_vbutton_box(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_vbox(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_viewport(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_volumebutton(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_vpaned(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_vruler(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_vscale(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_vscrollbar(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_vseparator(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_widget(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_window(VALUE mGtk); +G_GNUC_INTERNAL void Init_gtk_windowgroup(VALUE mGtk); + +#endif /* _RBGTK_GLOBAL_H */ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/gtk2.def b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/gtk2.def new file mode 100644 index 0000000..14b4a32 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/gtk2.def @@ -0,0 +1,29 @@ +EXPORTS + Init_gtk2 + mGdk DATA + rb_cGdkColor DATA + mGtk DATA + exec_callback + rbgdk_rval2gdkpoints + rbgdk_rval2gdkatoms + rbgdk_rval2gdkpixbufglist + gdk_atom_get_type + gdk_geometry_get_type + gdk_region_get_type + gdk_windowattr_get_type + get_gdkatom + get_gdkevent + gtk_accel_group_entry_get_type + gtk_accel_key_get_type + gtk_target_list_get_type + gtk_bindingset_get_type + make_gdkevent + rbgtk_atom2selectiondata + rbgtk_atom2selectiondata_free + rbgtk_rval2gtktargetentries + rbgtk_rval2gtktargetentries_accept_nil + rbgtk_get_target_entry + rbgtk_initialize_gtkobject + rbgtk_register_treeiter_set_value_func + gtk_text_appearance_get_type + rbgtk_dialog_add_buttons_internal diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/init.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/init.c new file mode 100644 index 0000000..93f07bc --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/init.c @@ -0,0 +1,284 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2001 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" +#include "gmodule.h" + +VALUE treeiter_set_value_table; + +extern void Init_gtk2(void); + +void +Init_gtk2(void) +{ + /* + * For Gtk::TreeModel, Gtk::TreeIter. + * They should be initialized on this timing. + */ + treeiter_set_value_table = rb_hash_new(); + rb_global_variable(&treeiter_set_value_table); + + Init_gtk_gdk(); + Init_gtk_gtk(); + + Init_gtk_gdk_atom(mGdk); + Init_gtk_gdk_cairo(); + Init_gtk_gdk_color(mGdk); + Init_gtk_gdk_colormap(mGdk); + Init_gtk_gdk_const(mGdk); + Init_gtk_gdk_cursor(mGdk); + Init_gtk_gdk_device(mGdk); + Init_gtk_gdk_display(mGdk); + Init_gtk_gdk_display_manager(mGdk); + Init_gtk_gdk_dragcontext(mGdk); + Init_gtk_gdk_event(mGdk); + Init_gtk_gdk_geometry(mGdk); + Init_gtk_gdk_image(mGdk); + Init_gtk_gdk_input(mGdk); + Init_gtk_gdk_keymap(mGdk); + Init_gtk_gdk_keyval(mGdk); + Init_gtk_gdk_pango(mGdk); + Init_gtk_gdk_pangorenderer(mGdk); + Init_gtk_gdk_pixbuf(mGdk); + Init_gtk_gdk_pixmap(mGdk); + Init_gtk_gdk_property(mGdk); + Init_gtk_gdk_rectangle(mGdk); + Init_gtk_gdk_region(mGdk); + Init_gtk_gdk_rgb(mGdk); + Init_gtk_gdk_screen(mGdk); + Init_gtk_gdk_selection(mGdk); + Init_gtk_gdk_threads(mGdk); + Init_gtk_gdk_timecoord(mGdk); + Init_gtk_gdk_visual(mGdk); + Init_gtk_gdk_window(mGdk); + Init_gtk_gdk_windowattr(mGdk); + Init_gtk_gdk_x11(mGdk); + Init_gtk_aboutdialog(mGtk); + Init_gtk_accelerator(mGtk); + Init_gtk_accel_group(mGtk); + Init_gtk_accel_group_entry(mGtk); + Init_gtk_accel_key(mGtk); + Init_gtk_accel_label(mGtk); + Init_gtk_accel_map(mGtk); + Init_gtk_accessible(mGtk); + Init_gtk_action(mGtk); + Init_gtk_actiongroup(mGtk); + Init_gtk_adjustment(mGtk); + Init_gtk_alignment(mGtk); + Init_gtk_allocation(mGtk); + Init_gtk_arrow(mGtk); + Init_gtk_aspect_frame(mGtk); + Init_gtk_assistant(mGtk); + Init_gtk_button_box(mGtk); + Init_gtk_bin(mGtk); + Init_gtk_bindings(mGtk); + Init_gtk_border(mGtk); + Init_gtk_box(mGtk); + Init_gtk_buildable(mGtk); + Init_gtk_builder(mGtk); + Init_gtk_button(mGtk); + Init_gtk_calendar(mGtk); + Init_gtk_celleditable(mGtk); + Init_gtk_celllayout(mGtk); + Init_gtk_cellrenderer(mGtk); + Init_gtk_cellrendereraccel(mGtk); + Init_gtk_cellrenderercombo(mGtk); + Init_gtk_cellrendererpixbuf(mGtk); + Init_gtk_cellrendererprogress(mGtk); + Init_gtk_cellrendererspin(mGtk); + Init_gtk_cellrendererspinner(mGtk); + Init_gtk_cellrenderertext(mGtk); + Init_gtk_cellrenderertoggle(mGtk); + Init_gtk_cellview(mGtk); + Init_gtk_check_button(mGtk); + Init_gtk_check_menu_item(mGtk); + Init_gtk_clipboard(mGtk); + Init_gtk_colorbutton(mGtk); + Init_gtk_color_selection(mGtk); + Init_gtk_color_selection_dialog(mGtk); + Init_gtk_combo(mGtk); + Init_gtk_combobox(mGtk); + Init_gtk_comboboxentry(mGtk); + Init_gtk_const(mGtk); + Init_gtk_container(mGtk); + Init_gtk_curve(mGtk); + Init_gtk_dialog(mGtk); + Init_gtk_drag(mGtk); + Init_gtk_drawing_area(mGtk); + Init_gtk_editable(mGtk); + Init_gtk_entry(mGtk); + Init_gtk_entry_completion(mGtk); + Init_gtk_eventbox(mGtk); + Init_gtk_expander(mGtk); + Init_gtk_file_chooser(mGtk); + Init_gtk_filesystemerror(mGtk); + Init_gtk_filechooserbutton(mGtk); + Init_gtk_file_chooser_dialog(mGtk); + Init_gtk_file_chooser_widget(mGtk); + Init_gtk_file_filter(mGtk); + Init_gtk_file_selection(mGtk); + Init_gtk_fixed(mGtk); + Init_gtk_fontbutton(mGtk); + Init_gtk_font_selection(mGtk); + Init_gtk_font_selection_dialog(mGtk); + Init_gtk_frame(mGtk); + Init_gtk_gamma_curve(mGtk); + Init_gtk_gdk_draw(mGdk); + Init_gtk_gdk_gc(mGdk); + Init_gtk_handle_box(mGtk); + Init_gtk_hbutton_box(mGtk); + Init_gtk_hbox(mGtk); + Init_gtk_hpaned(mGtk); + Init_gtk_hruler(mGtk); + Init_gtk_hscale(mGtk); + Init_gtk_hscrollbar(mGtk); + Init_gtk_hseparator(mGtk); + Init_gtk_icon_factory(mGtk); + Init_gtk_iconinfo(mGtk); + Init_gtk_icon_set(mGtk); + Init_gtk_icon_size(mGtk); + Init_gtk_icon_source(mGtk); + Init_gtk_icon_theme(mGtk); + Init_gtk_iconview(mGtk); + Init_gtk_image(mGtk); + Init_gtk_image_menu_item(mGtk); + Init_gtk_imcontext(mGtk); + Init_gtk_imcontext_simple(mGtk); + Init_gtk_im_multicontext(mGtk); + Init_gtk_infobar(mGtk); + Init_gtk_input_dialog(mGtk); + Init_gtk_invisible(mGtk); + Init_gtk_item(mGtk); + Init_gtk_itemfactory(mGtk); + Init_gtk_label(mGtk); + Init_gtk_layout(mGtk); + Init_gtk_link_button(mGtk); + Init_gtk_list_store(mGtk); + Init_gtk_menu(mGtk); + Init_gtk_menu_bar(mGtk); + Init_gtk_menu_item(mGtk); + Init_gtk_menu_shell(mGtk); + Init_gtk_menutoolbutton(mGtk); + Init_gtk_message_dialog(mGtk); + Init_gtk_misc(mGtk); + Init_gtk_notebook(mGtk); + Init_gtk_object(mGtk); + Init_gtk_option_menu(mGtk); + Init_gtk_page_setup(mGtk); + Init_gtk_page_setup_unix_dialog(mGtk); + Init_gtk_paned(mGtk); + Init_gtk_paper_size(mGtk); + Init_gtk_plug(mGtk); + Init_gtk_print_context(mGtk); + Init_gtk_printer(mGtk); + Init_gtk_print_job(mGtk); + Init_gtk_print_operation(mGtk); + Init_gtk_print_operation_preview(mGtk); + Init_gtk_print_settings(mGtk); + Init_gtk_print_unix_dialog(mGtk); + Init_gtk_progress(mGtk); + Init_gtk_progress_bar(mGtk); + Init_gtk_radio_action(mGtk); + Init_gtk_radio_button(mGtk); + Init_gtk_radio_menu_item(mGtk); + Init_gtk_radiotoolbutton(mGtk); + Init_gtk_range(mGtk); + Init_gtk_rc(mGtk); + Init_gtk_rcstyle(mGtk); + Init_gtk_recentaction(mGtk); + Init_gtk_recent_chooser(mGtk); + Init_gtk_recent_chooser_dialog(mGtk); + Init_gtk_recent_chooser_menu(mGtk); + Init_gtk_recent_chooser_widget(mGtk); + Init_gtk_recent_data(mGtk); + Init_gtk_recent_filter(mGtk); + Init_gtk_recent_filter_info(mGtk); + Init_gtk_recent_info(mGtk); + Init_gtk_recent_manager(mGtk); + Init_gtk_ruler(mGtk); + Init_gtk_scale(mGtk); + Init_gtk_scalebutton(mGtk); + Init_gtk_scrollbar(mGtk); + Init_gtk_scrolled_window(mGtk); + Init_gtk_selection(mGtk); + Init_gtk_selectiondata(mGtk); + Init_gtk_separator(mGtk); + Init_gtk_separator_menu_item(mGtk); + Init_gtk_separatortoolitem(mGtk); + Init_gtk_settings(mGtk); + Init_gtk_size_group(mGtk); + Init_gtk_socket(mGtk); + Init_gtk_spin_button(mGtk); + Init_gtk_spinner(mGtk); + Init_gtk_statusbar(mGtk); + Init_gtk_status_icon(mGtk); + Init_gtk_stock(mGtk); + Init_gtk_style(mGtk); + Init_gtk_table(mGtk); + Init_gtk_target_list(mGtk); + Init_gtk_tearoff_menu_item(mGtk); + Init_gtk_text_appearance(mGtk); + Init_gtk_text_attributes(mGtk); + Init_gtk_textbuffer(mGtk); + Init_gtk_textchild(mGtk); + Init_gtk_textiter(mGtk); + Init_gtk_textmark(mGtk); + Init_gtk_texttag(mGtk); + Init_gtk_text_tag_table(mGtk); + Init_gtk_textview(mGtk); + Init_gtk_toggle_action(mGtk); + Init_gtk_toggle_button(mGtk); + Init_gtk_toggletoolbutton(mGtk); + Init_gtk_toolbar(mGtk); + Init_gtk_toolbutton(mGtk); + Init_gtk_toolitem(mGtk); + Init_gtk_tooltip(mGtk); + Init_gtk_tooltips(mGtk); + Init_gtk_treedragdest(mGtk); + Init_gtk_treedragsource(mGtk); + Init_gtk_treeiter(mGtk); + Init_gtk_treemodel(mGtk); + Init_gtk_treemodelfilter(mGtk); + Init_gtk_tmodelsort(mGtk); + Init_gtk_treepath(mGtk); + Init_gtk_treerowreference(mGtk); + Init_gtk_treeselection(mGtk); + Init_gtk_treesortable(mGtk); + Init_gtk_tree_store(mGtk); + Init_gtk_treeview(mGtk); + Init_gtk_treeviewcolumn(mGtk); + Init_gtk_uimanager(mGtk); + Init_gtk_vbutton_box(mGtk); + Init_gtk_vbox(mGtk); + Init_gtk_viewport(mGtk); + Init_gtk_volumebutton(mGtk); + Init_gtk_vpaned(mGtk); + Init_gtk_vruler(mGtk); + Init_gtk_vscale(mGtk); + Init_gtk_vscrollbar(mGtk); + Init_gtk_vseparator(mGtk); + Init_gtk_widget(mGtk); + Init_gtk_window(mGtk); + Init_gtk_windowgroup(mGtk); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdk.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdk.c new file mode 100644 index 0000000..164b70e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdk.c @@ -0,0 +1,520 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE mGdk + +VALUE RG_TARGET_NAMESPACE; + +/* We don't need them. +void gdk_init (gint *argc, + gchar ***argv); +gboolean gdk_init_check (gint *argc, + gchar ***argv); +void gdk_parse_args (gint *argc, + gchar ***argv); +*/ + +struct rbgdk_rval2gdkpoints_args { + VALUE ary; + long n; + GdkPoint *result; +}; + +static VALUE +rbgdk_rval2gdkpoints_body(VALUE value) +{ + long i; + struct rbgdk_rval2gdkpoints_args *args = (struct rbgdk_rval2gdkpoints_args *)value; + + for (i = 0; i < args->n; i++) { + VALUE points = rb_ary_to_ary(RARRAY_PTR(args->ary)[i]); + + if (RARRAY_LEN(points) != 2) + rb_raise(rb_eArgError, "point %ld should be array of size 2", i); + + args->result[i].x = NUM2INT(RARRAY_PTR(points)[0]); + args->result[i].y = NUM2INT(RARRAY_PTR(points)[1]); + } + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbgdk_rval2gdkpoints_rescue(VALUE value) +{ + g_free(((struct rbgdk_rval2gdkpoints_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +GdkPoint * +rbgdk_rval2gdkpoints(VALUE value, long *n) +{ + struct rbgdk_rval2gdkpoints_args args; + + args.ary = rb_ary_to_ary(value); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(GdkPoint, args.n + 1); + + rb_rescue(rbgdk_rval2gdkpoints_body, (VALUE)&args, + rbgdk_rval2gdkpoints_rescue, (VALUE)&args); + + *n = args.n; + + return args.result; +} + +struct rbgdk_rval2gdkatoms_args { + VALUE ary; + long n; + GdkAtom *result; +}; + +static VALUE +rbgdk_rval2gdkatoms_body(VALUE value) +{ + long i; + struct rbgdk_rval2gdkatoms_args *args = (struct rbgdk_rval2gdkatoms_args *)value; + + for (i = 0; i < args->n; i++) + args->result[i] = RVAL2ATOM(RARRAY_PTR(args->ary)[i]); + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbgdk_rval2gdkatoms_rescue(VALUE value) +{ + g_free(((struct rbgdk_rval2gdkatoms_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +GdkAtom * +rbgdk_rval2gdkatoms(VALUE value, long *n) +{ + struct rbgdk_rval2gdkatoms_args args; + + args.ary = rb_ary_to_ary(value); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(GdkAtom, args.n + 1); + + rb_rescue(rbgdk_rval2gdkatoms_body, (VALUE)&args, + rbgdk_rval2gdkatoms_rescue, (VALUE)&args); + + *n = args.n; + + return args.result; +} + +struct rval2gdkpixbufglist_args { + VALUE ary; + long n; + GList *result; +}; + +static VALUE +rbgdk_rval2gdkpixbufglist_body(VALUE value) +{ + long i; + struct rval2gdkpixbufglist_args *args = (struct rval2gdkpixbufglist_args *)value; + + for (i = 0; i < args->n; i++) + args->result = g_list_append(args->result, GDK_PIXBUF(RVAL2GOBJ(RARRAY_PTR(args->ary)[i]))); + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbgdk_rval2gdkpixbufglist_rescue(VALUE value) +{ + g_list_free(((struct rval2gdkpixbufglist_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +GList * +rbgdk_rval2gdkpixbufglist(VALUE value) +{ + struct rval2gdkpixbufglist_args args; + + args.ary = rb_ary_to_ary(value); + args.n = RARRAY_LEN(args.ary); + args.result = NULL; + + rb_rescue(rbgdk_rval2gdkpixbufglist_body, (VALUE)&args, + rbgdk_rval2gdkpixbufglist_rescue, (VALUE)&args); + + return args.result; +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_m_display_arg_name(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(gdk_get_display_arg_name()); +} +#endif + +static VALUE +rg_m_set_locale(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(gdk_set_locale()); +} + +static VALUE +rg_m_set_sm_client_id(VALUE self, VALUE id) +{ + gdk_set_sm_client_id(NIL_P(id) ? NULL : RVAL2CSTR(id)); + return self; +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_m_notify_startup_complete(int argc, VALUE *argv, VALUE self) +{ + VALUE startup_id; + + rb_scan_args(argc, argv, "01", &startup_id); + + if (NIL_P(startup_id)) { + gdk_notify_startup_complete(); + } else { +#if GTK_CHECK_VERSION(2, 12, 0) + gdk_notify_startup_complete_with_id(RVAL2CSTR(startup_id)); +#else + rb_raise(rb_eNotImpError, + "GTK+ >= 2.12 is required to use " + "Gdk.notify_startup_complete with startup ID."); +#endif + } + return self; +} +#endif + +static VALUE +rg_m_program_class(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(gdk_get_program_class()); +} + +static VALUE +rg_m_set_program_class(VALUE self, VALUE program_class) +{ + gdk_set_program_class(RVAL2CSTR(program_class)); + return self; +} + +static VALUE +rg_m_display(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(gdk_get_display()); +} + +#ifdef HAVE_X11_XLIB_H +#ifdef HAVE_XGETERRORTEXT +#include +#include + +static VALUE rb_x_error; +static VALUE rb_x_io_error; + +static int +rbgdk_x_error(Display *display, XErrorEvent *error) +{ + gchar buf[64]; + + XGetErrorText(display, error->error_code, buf, 63); + + rb_funcall((VALUE)rb_x_error, id_call, 4, INT2NUM(error->serial), + INT2NUM(error->error_code), INT2NUM(error->request_code), + INT2NUM(error->minor_code)); + return 0; +} + +static int +rbgdk_x_io_error(Display *display) +{ + int errno_saved = errno; + const gchar* disp; + const gchar* error; + +#if GTK_CHECK_VERSION(2,2,0) + disp = display ? DisplayString(display) : gdk_get_display_arg_name(); +#else + disp = DisplayString(display); +#endif + if (! disp) + disp = "(none)"; + + error = g_strerror(errno_saved); + + rb_funcall((VALUE)rb_x_io_error, id_call, 3, CSTR2RVAL(disp), + INT2NUM(errno), CSTR2RVAL(error)); + return 0; +} +#endif +#endif + +static VALUE +rg_m_set_x_error_handler(VALUE self) +{ +#ifdef HAVE_XGETERRORTEXT + rb_x_error = rb_block_proc(); + G_RELATIVE(self, rb_x_error); + XSetErrorHandler(rbgdk_x_error); +#else + rb_warn("Not supported on this environment."); +#endif + return self; +} + +static VALUE +rg_m_set_x_io_error_handler(VALUE self) +{ +#ifdef HAVE_XGETERRORTEXT + rb_x_io_error = rb_block_proc(); + G_RELATIVE(self, rb_x_io_error); + XSetIOErrorHandler(rbgdk_x_io_error); +#else + rb_warn("Not supported on this environment."); +#endif + return self; +} + +static VALUE +rg_m_flush(VALUE self) +{ + gdk_flush(); + return self; +} + +static VALUE +rg_m_screen_width(G_GNUC_UNUSED VALUE self) +{ + return INT2NUM(gdk_screen_width()); +} + +static VALUE +rg_m_screen_width_mm(G_GNUC_UNUSED VALUE self) +{ + return INT2NUM(gdk_screen_width_mm()); +} + +static VALUE +rg_m_screen_height(G_GNUC_UNUSED VALUE self) +{ + return INT2NUM(gdk_screen_height()); +} + +static VALUE +rg_m_screen_height_mm(G_GNUC_UNUSED VALUE self) +{ + return INT2NUM(gdk_screen_height_mm()); +} + +static VALUE +rg_m_pointer_grab(G_GNUC_UNUSED VALUE self, VALUE win, VALUE owner_events, VALUE event_mask, VALUE confine_to, VALUE cursor, VALUE time) +{ + return GENUM2RVAL(gdk_pointer_grab(GDK_WINDOW(RVAL2GOBJ(win)), + RVAL2CBOOL(owner_events), + RVAL2GFLAGS(event_mask, GDK_TYPE_EVENT_MASK), + NIL_P(confine_to)?NULL:GDK_WINDOW(RVAL2GOBJ(confine_to)), + NIL_P(cursor)?NULL:(GdkCursor*)RVAL2BOXED(cursor, GDK_TYPE_CURSOR), + NUM2INT(time)), GDK_TYPE_GRAB_STATUS); +} + +static VALUE +rg_m_pointer_ungrab(VALUE self, VALUE time) +{ + gdk_pointer_ungrab(NUM2INT(time)); + return self; +} + +static VALUE +rg_m_keyboard_grab(G_GNUC_UNUSED VALUE self, VALUE win, VALUE owner_events, VALUE time) +{ + return GENUM2RVAL(gdk_keyboard_grab(GDK_WINDOW(RVAL2GOBJ(win)), + RVAL2CBOOL(owner_events), NUM2INT(time)), + GDK_TYPE_GRAB_STATUS); +} + +static VALUE +rg_m_keyboard_ungrab(VALUE self, VALUE time) +{ + gdk_keyboard_ungrab(NUM2INT(time)); + return self; +} + +static VALUE +rg_m_pointer_is_grabbed_p(G_GNUC_UNUSED VALUE self) +{ + return CBOOL2RVAL(gdk_pointer_is_grabbed()); +} + +static VALUE +rg_m_set_double_click_time(VALUE self, VALUE msec) +{ + gdk_set_double_click_time(NUM2UINT(msec)); + return self; +} + +static VALUE +rg_m_beep(VALUE self) +{ + gdk_beep(); + return self; +} + +static VALUE +rg_m_error_trap_push(VALUE self) +{ + gdk_error_trap_push(); + return self; +} + +static VALUE +rg_m_error_trap_pop(VALUE self) +{ + gdk_error_trap_pop(); + return self; +} + +static VALUE +rg_m_windowing_x11_p(G_GNUC_UNUSED VALUE self) +{ +#ifdef GDK_WINDOWING_X11 + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +rg_m_windowing_win32_p(G_GNUC_UNUSED VALUE self) +{ +#ifdef GDK_WINDOWING_WIN32 + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +rg_m_windowing_fb_p(G_GNUC_UNUSED VALUE self) +{ +#ifdef GDK_WINDOWING_FB + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +rg_m_windowing_quartz_p(G_GNUC_UNUSED VALUE self) +{ +#ifdef GDK_WINDOWING_QUARTZ + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +rg_m_windowing_directfb_p(G_GNUC_UNUSED VALUE self) +{ +#ifdef GDK_WINDOWING_DIRECTFB + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +rg_m_target(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(RUBY_GTK2_TARGET); +} + +static VALUE +rg_m_cairo_available_p(G_GNUC_UNUSED VALUE self) +{ +#if CAIRO_AVAILABLE + return Qtrue; +#else + return Qfalse; +#endif +} + +void +Init_gtk_gdk(void) +{ + RG_TARGET_NAMESPACE = rb_define_module("Gdk"); + +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_MODFUNC(display_arg_name, 0); +#endif + RG_DEF_MODFUNC(set_locale, 0); + RG_DEF_MODFUNC(set_sm_client_id, 1); +#if GTK_CHECK_VERSION(2, 2, 0) + RG_DEF_MODFUNC(notify_startup_complete, -1); +#endif + RG_DEF_MODFUNC(program_class, 0); + RG_DEF_MODFUNC(set_program_class, 1); + RG_DEF_MODFUNC(display, 0); + + RG_DEF_MODFUNC(set_x_error_handler, 0); + RG_DEF_MODFUNC(set_x_io_error_handler, 0); + RG_DEF_MODFUNC(screen_width, 0); + RG_DEF_MODFUNC(screen_width_mm, 0); + RG_DEF_MODFUNC(screen_height, 0); + RG_DEF_MODFUNC(screen_height_mm, 0); + RG_DEF_MODFUNC(beep, 0); + RG_DEF_MODFUNC(flush, 0); + RG_DEF_MODFUNC(set_double_click_time, 1); + RG_DEF_MODFUNC(pointer_grab, 6); + RG_DEF_MODFUNC(pointer_ungrab, 1); + RG_DEF_MODFUNC(keyboard_grab, 3); + RG_DEF_MODFUNC(keyboard_ungrab, 1); + RG_DEF_MODFUNC_P(pointer_is_grabbed, 0); + RG_DEF_MODFUNC(error_trap_push, 0); + RG_DEF_MODFUNC(error_trap_pop, 0); + RG_DEF_MODFUNC_P(windowing_x11, 0); + RG_DEF_MODFUNC_P(windowing_win32, 0); + RG_DEF_MODFUNC_P(windowing_fb, 0); + RG_DEF_MODFUNC_P(windowing_quartz, 0); + RG_DEF_MODFUNC_P(windowing_directfb, 0); + + RG_DEF_MODFUNC(target, 0); + + RG_DEF_MODFUNC_P(cairo_available, 0); + + /* GdkGrabStatus */ + G_DEF_CLASS(GDK_TYPE_GRAB_STATUS, "GrabStatus", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_GRAB_STATUS, "GDK_"); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} \ No newline at end of file diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdk.h b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdk.h new file mode 100644 index 0000000..6e8d7b2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdk.h @@ -0,0 +1,79 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __RB_GDK_H__ +#define __RB_GDK_H__ + +#include +#include +#include +#include + +#ifdef GDK_WINDOWING_X11 +# include +#endif +#ifdef GDK_WINDOWING_WIN32 +# include +#endif + +#define RVAL2GDKPOINTS(value, n) rbgdk_rval2gdkpoints(value, n) +#define RVAL2GDKATOMS(value, n) rbgdk_rval2gdkatoms(value, n) + +#define RVAL2GDKPIXBUFGLIST(value) rbgdk_rval2gdkpixbufglist(value) + +#define GDK_BITMAP(b) ((GdkBitmap*)GDK_PIXMAP(b)) + +#define GEV2RVAL(ev) (make_gdkevent(ev)) +#define RVAL2GEV(ev) (get_gdkevent(ev)) +#define RVAL2ATOM(atom) (get_gdkatom(atom)) +#define RVAL2GDKNATIVEWINDOW(value) ((GdkNativeWindow)NUM2UINT(value)) +/* TODO: Will UINT2NUM work for pointers on 64-bit Windows? */ +#define GDKNATIVEWINDOW2RVAL(value) UINT2NUM((guint32)value) + +#define GDK_TYPE_GEOMETRY (gdk_geometry_get_type()) +#define GDK_TYPE_REGION (gdk_region_get_type()) +#define GDK_TYPE_ATOM (gdk_atom_get_type()) +#define GDK_TYPE_WINDOW_ATTR (gdk_windowattr_get_type()) +#define GDK_TYPE_TIME_COORD (gdk_timecoord_get_type()) + +RUBY_GTK2_VAR VALUE mGdk; +RUBY_GTK2_VAR VALUE rb_cGdkColor; + +typedef struct { + GdkAtom atom; +} GdkAtomData; + +GdkPoint *rbgdk_rval2gdkpoints(VALUE value, long *n); +GdkAtom *rbgdk_rval2gdkatoms(VALUE value, long *n); + +GList *rbgdk_rval2gdkpixbufglist(VALUE value); + +extern GType gdk_windowattr_get_type(void); +extern GType gdk_atom_get_type(void); +extern GType gdk_geometry_get_type(void); +extern GType gdk_region_get_type(void); +extern GType gdk_timecoord_get_type(void); + +extern GdkAtom get_gdkatom(VALUE atom); +extern VALUE make_gdkevent(GdkEvent* event); +extern GdkEvent* get_gdkevent(VALUE event); + +#endif /* __RB_GDK_H__ */ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkatom.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkatom.c new file mode 100644 index 0000000..9ff24d1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkatom.c @@ -0,0 +1,124 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" +#include "rbgdk.h" + +#define RG_TARGET_NAMESPACE cAtom +#define _SELF(a) (((GdkAtomData*)RVAL2BOXED(a, GDK_TYPE_ATOM))->atom) + +/*****************************************/ +static GdkAtomData * +gdk_atom_copy(const GdkAtom atom) +{ + GdkAtomData* data; + data = g_new(GdkAtomData, 1); + data->atom = atom; + return data; +} + +GType +gdk_atom_get_type(void) +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static ("GdkAtomData", + (GBoxedCopyFunc)gdk_atom_copy, + (GBoxedFreeFunc)g_free); + return our_type; +} + +GdkAtom +get_gdkatom(VALUE atom) +{ + if (TYPE(atom) == T_STRING) + return gdk_atom_intern(RVAL2CSTR(atom), FALSE); + return ((GdkAtomData*)RVAL2BOXED(atom, GDK_TYPE_ATOM))->atom; +} +/*****************************************/ + +static VALUE +rg_s_intern(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE name; + VALUE exist; + + rb_scan_args(argc, argv, "11", &name, &exist); + + return BOXED2RVAL(gdk_atom_intern(RVAL2CSTR(name), RVAL2CBOOL(exist)), + GDK_TYPE_ATOM); +} + +/* We don't need them. +GdkAtom gdk_atom_intern_static_string(const gchar *atom_name); + */ + +static VALUE +rg_initialize(VALUE self, VALUE num) +{ + guint atom = FIX2INT(num); + if (atom == 0) { + /* This is a trick for passing 0(NULL) */ + G_INITIALIZE(self, GUINT_TO_POINTER(1)); + _SELF(self) = GUINT_TO_POINTER(GDK_NONE); + } else { + G_INITIALIZE(self, GUINT_TO_POINTER(atom)); + } + + return Qnil; +} + +static VALUE +rg_name(VALUE self) +{ + return CSTR2RVAL_FREE(gdk_atom_name(_SELF(self))); +} + +static VALUE +rg_to_i(VALUE self) +{ + return UINT2NUM(GPOINTER_TO_UINT(_SELF(self))); +} + +static VALUE +rg_operator_equal(VALUE self, VALUE other) +{ + return CBOOL2RVAL(_SELF(self) == _SELF(other)); +} + +void +Init_gtk_gdk_atom(VALUE mGdk) +{ + VALUE none; + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_ATOM, "Atom", mGdk); + + RG_DEF_SMETHOD(intern, -1); + + RG_DEF_METHOD(initialize, 1); + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(to_i, 0); + RG_DEF_METHOD_OPERATOR("==", equal, 1); + + /* This is a trick to define GDK_NONE as a BOXED object */ + none = BOXED2RVAL((gpointer)1, GDK_TYPE_ATOM); + rb_define_const(RG_TARGET_NAMESPACE, "NONE", none); + _SELF(none) = GDK_NONE; +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkcairo.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkcairo.c new file mode 100644 index 0000000..29eca06 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkcairo.c @@ -0,0 +1,97 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if CAIRO_AVAILABLE +#include +#include + +#define RG_TARGET_NAMESPACE rb_cCairo_Context +#define _SELF(self) RVAL2CRCONTEXT(self) + +static VALUE +rg_set_source_gdk_color(VALUE self, VALUE color) +{ + gdk_cairo_set_source_color(_SELF(self), RVAL2GDKCOLOR(color)); + rb_cairo_check_status(cairo_status(_SELF(self))); + return self; +} + +static VALUE +rg_set_source_pixbuf(int argc, VALUE *argv, VALUE self) +{ + VALUE pixbuf, pixbuf_x, pixbuf_y; + + rb_scan_args(argc, argv, "12", &pixbuf, &pixbuf_x, &pixbuf_y); + + gdk_cairo_set_source_pixbuf(_SELF(self), + GDK_PIXBUF(RVAL2GOBJ(pixbuf)), + NIL_P(pixbuf_x) ? 0 : NUM2DBL(pixbuf_x), + NIL_P(pixbuf_y) ? 0 : NUM2DBL(pixbuf_y)); + rb_cairo_check_status(cairo_status(_SELF(self))); + return self; +} + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_set_source_pixmap(VALUE self, VALUE pixmap, VALUE pixmap_x, VALUE pixmap_y) +{ + gdk_cairo_set_source_pixmap(_SELF(self), GDK_PIXMAP(RVAL2GOBJ(pixmap)), + NUM2DBL(pixmap_x), NUM2DBL(pixmap_y)); + rb_cairo_check_status(cairo_status(_SELF(self))); + return self; +} +#endif + +static VALUE +rg_gdk_rectangle(VALUE self, VALUE rectangle) +{ + gdk_cairo_rectangle(_SELF(self), + (GdkRectangle*)RVAL2BOXED(rectangle, GDK_TYPE_RECTANGLE)); + rb_cairo_check_status(cairo_status(_SELF(self))); + return self; +} + +static VALUE +rg_gdk_region(VALUE self, VALUE region) +{ + gdk_cairo_region(_SELF(self), (GdkRegion*)RVAL2BOXED(region, GDK_TYPE_REGION)); + rb_cairo_check_status(cairo_status(_SELF(self))); + return self; +} +#endif + +void +Init_gtk_gdk_cairo(void) +{ +#if CAIRO_AVAILABLE + RG_DEF_METHOD(set_source_gdk_color, 1); + RG_DEF_METHOD(set_source_pixbuf, -1); +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD(set_source_pixmap, 3); +#endif + RG_DEF_METHOD(gdk_rectangle, 1); + RG_DEF_METHOD(gdk_region, 1); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkcolor.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkcolor.c new file mode 100644 index 0000000..d0a3bd5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkcolor.c @@ -0,0 +1,146 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE rb_cGdkColor +#define _SELF(c) (RVAL2GDKCOLOR(c)) + +VALUE RG_TARGET_NAMESPACE = Qnil; + +static VALUE +rg_initialize(VALUE self, VALUE red, VALUE green, VALUE blue) +{ + GdkColor color; + + color.pixel = 0; + color.red = NUM2INT(red); + color.green = NUM2INT(green); + color.blue = NUM2INT(blue); + + G_INITIALIZE(self, g_boxed_copy(GDK_TYPE_COLOR, &color)); + + return Qnil; +} + +static VALUE +rg_s_parse(G_GNUC_UNUSED VALUE self, VALUE name) +{ + GdkColor c; + if (! gdk_color_parse(RVAL2CSTR(name), &c)) { + rb_raise(rb_eArgError, "can't parse color name `%s'", RVAL2CSTR(name)); + } + return BOXED2RVAL(&c, GDK_TYPE_COLOR); +} + +static VALUE +rg_pixel(VALUE self) +{ + return INT2NUM(_SELF(self)->pixel); +} + +static VALUE +rg_red(VALUE self) +{ + + return INT2FIX(_SELF(self)->red); +} + +static VALUE +rg_set_red(VALUE self, VALUE red) +{ + _SELF(self)->red = NUM2INT(red); + return self; +} + +static VALUE +rg_green(VALUE self) +{ + return INT2FIX(_SELF(self)->green); +} + +static VALUE +rg_set_green(VALUE self, VALUE green) +{ + _SELF(self)->green = NUM2INT(green); + return self; +} + +static VALUE +rg_blue(VALUE self) +{ + return INT2FIX(_SELF(self)->blue); +} + +static VALUE +rg_set_blue(VALUE self, VALUE blue) +{ + _SELF(self)->blue = NUM2INT(blue); + return self; +} + +static VALUE +rg_to_a(VALUE self) +{ + GdkColor *c = _SELF(self); + return rb_ary_new3(3, INT2FIX(c->red), + INT2FIX(c->green), INT2FIX(c->blue)); +} + +static VALUE +rg_operator_gdkcolor_equal(VALUE self, VALUE other) +{ + return CBOOL2RVAL(gdk_color_equal(_SELF(self), _SELF(other))); +} + +#if GTK_CHECK_VERSION(2, 12, 0) +static VALUE +rg_to_s(VALUE self) +{ + return CSTR2RVAL_FREE(gdk_color_to_string(_SELF(self))); +} +#endif + +void +Init_gtk_gdk_color(VALUE mGdk) +{ + RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_COLOR, "Color", mGdk); + + RG_DEF_SMETHOD(parse, 1); + RG_DEF_METHOD(initialize, 3); + RG_DEF_METHOD(pixel, 0); + RG_DEF_METHOD(red, 0); + RG_DEF_METHOD(set_red, 1); + RG_DEF_METHOD(green, 0); + RG_DEF_METHOD(set_green, 1); + RG_DEF_METHOD(blue, 0); + RG_DEF_METHOD(set_blue, 1); + RG_DEF_METHOD(to_a, 0); + RG_DEF_METHOD_OPERATOR("==", gdkcolor_equal, 1); +#if GTK_CHECK_VERSION(2, 12, 0) + RG_DEF_METHOD(to_s, 0); +#endif + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkcolormap.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkcolormap.c new file mode 100644 index 0000000..adaccb1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkcolormap.c @@ -0,0 +1,139 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cColormap +#define _SELF(self) (GDK_COLORMAP(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(VALUE self, VALUE visual, VALUE allocate) +{ + GdkColormap *cmap = gdk_colormap_new(GDK_VISUAL(RVAL2GOBJ(visual)), + RVAL2CBOOL(allocate)); + G_INITIALIZE(self, cmap); + return Qnil; +} + +static VALUE +rg_s_system(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(gdk_colormap_get_system()); +} + +/* Don't implement this. Because API is ugly + (especially treating of "success"). + Use Gdk::Colormap#alloc_color instead. +gint gdk_colormap_alloc_colors (GdkColormap *colormap, + GdkColor *colors, + gint ncolors, + gboolean writeable, + gboolean best_match, + gboolean *success); +*/ + +static VALUE +rg_alloc_color(VALUE self, VALUE color, VALUE writeable, VALUE best_match) +{ + gboolean result; + GdkColor *c = RVAL2GDKCOLOR(color); + result = gdk_colormap_alloc_color(_SELF(self), c, + RVAL2CBOOL(writeable), RVAL2CBOOL(best_match)); + return result ? INT2NUM(c->pixel) : Qnil; +} + +/* Don't implement Gdk::Colormap#free_colors. + Because it should be pair with Gdk::Colormap#alloc_colors */ +static VALUE +rg_free_color(VALUE self, VALUE color) +{ + gdk_colormap_free_colors(_SELF(self), RVAL2GDKCOLOR(color), 1); + return self; +} + +static VALUE +rg_query_color(VALUE self, VALUE pixel) +{ + GdkColor color; + gdk_colormap_query_color(_SELF(self), NUM2ULONG(pixel), &color); + return GDKCOLOR2RVAL(&color); +} + +static VALUE +rg_visual(VALUE self) +{ + return GOBJ2RVAL(gdk_colormap_get_visual(_SELF(self))); +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_screen(VALUE self) +{ + return GOBJ2RVAL(gdk_colormap_get_screen(_SELF(self))); +} +#endif + +static VALUE +rg_colors(VALUE self) +{ + GdkColormap *cmap; + GdkColor *colors; + GdkVisual *visual; + VALUE ary; + int i; + + cmap = _SELF(self); + colors = cmap->colors; + + visual = gdk_colormap_get_visual(cmap); + + if (visual->type == GDK_VISUAL_GRAYSCALE || + visual->type == GDK_VISUAL_PSEUDO_COLOR) { + ary = rb_ary_new2(cmap->size); + for (i = 0; i < cmap->size; i++) { + rb_ary_push(ary, BOXED2RVAL(colors, GDK_TYPE_COLOR)); + colors++; + } + return ary; + } else { + return Qnil; + } +} + +void +Init_gtk_gdk_colormap(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_COLORMAP, "Colormap", mGdk); + + RG_DEF_SMETHOD(system, 0); + RG_DEF_METHOD(initialize, 2); + RG_DEF_METHOD(alloc_color, 3); + RG_DEF_METHOD(free_color, 1); + RG_DEF_METHOD(query_color, 1); + RG_DEF_METHOD(visual, 0); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(screen, 0); +#endif + RG_DEF_METHOD(colors, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkconst.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkconst.c new file mode 100644 index 0000000..2a3745b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkconst.c @@ -0,0 +1,39 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +/* + * Gdk module constants + */ +void +Init_gtk_gdk_const(VALUE mGdk) +{ + /* GdkStatus */ + G_DEF_CLASS(GDK_TYPE_STATUS, "Status", mGdk); + G_DEF_CONSTANTS(mGdk, GDK_TYPE_STATUS, "GDK_"); + +} + + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkconversions.h b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkconversions.h new file mode 100644 index 0000000..eef97de --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkconversions.h @@ -0,0 +1,31 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __RB_GDK_CONVERSIONS_H__ +#define __RB_GDK_CONVERSIONS_H__ + +#include +#include + +#define RVAL2GDKCOLOR(color) ((GdkColor *)RVAL2BOXED(color, GDK_TYPE_COLOR)) +#define GDKCOLOR2RVAL(color) (BOXED2RVAL(color, GDK_TYPE_COLOR)) + +#endif /* __RB_GDK_CONVERSIONS_H__ */ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkcursor.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkcursor.c new file mode 100644 index 0000000..e164f53 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkcursor.c @@ -0,0 +1,120 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2001-2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cCursor + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + GdkCursor* cursor = NULL; + + if (argc == 1){ + VALUE type; + rb_scan_args(argc, argv, "10", &type); + cursor = gdk_cursor_new(RVAL2GENUM(type, GDK_TYPE_CURSOR_TYPE)); + } else if (argc == 2) { +#if GTK_CHECK_VERSION(2,2,0) + VALUE display, type_or_name; + rb_scan_args(argc, argv, "20", &display, &type_or_name); +#if GTK_CHECK_VERSION(2,8,0) + if (TYPE(type_or_name) == T_STRING) + cursor = gdk_cursor_new_from_name(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)), + RVAL2CSTR(type_or_name)); + else +#endif + cursor = gdk_cursor_new_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)), + RVAL2GENUM(type_or_name, GDK_TYPE_CURSOR_TYPE)); +#else + rb_raise(rb_eRuntimeError, "Gdk::Cursor.new(display, cursor_type) has been supported since GTK+-2.2."); +#endif + } else if (argc == 4) { +#if GTK_CHECK_VERSION(2,4,0) + VALUE display, pixbuf, x, y; + rb_scan_args(argc, argv, "40", &display, &pixbuf, &x, &y); + cursor = gdk_cursor_new_from_pixbuf(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)), + GDK_PIXBUF(RVAL2GOBJ(pixbuf)), + NUM2INT(x), NUM2INT(y)); +#else + rb_raise(rb_eRuntimeError, "Gdk::Cursor.new(pixbuf) has been supported since GTK+-2.4."); +#endif + } else if (argc == 6) { + VALUE pixmap, mask, fg, bg, x, y; + rb_scan_args(argc, argv, "60", &pixmap, &mask, &fg, &bg, &x, &y); + cursor = gdk_cursor_new_from_pixmap(GDK_PIXMAP(RVAL2GOBJ(pixmap)), + NIL_P(mask)?NULL:GDK_PIXMAP(RVAL2GOBJ(mask)), + RVAL2GDKCOLOR(fg), + RVAL2GDKCOLOR(bg), + NUM2INT(x), NUM2INT(y)); + } + G_INITIALIZE(self, cursor); + + return Qnil; +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_display(VALUE self) +{ + return GOBJ2RVAL(gdk_cursor_get_display((GdkCursor*)RVAL2BOXED(self, GDK_TYPE_CURSOR))); +} +#endif + +static VALUE +rg_pixmap_p(VALUE self) +{ + return CBOOL2RVAL(((GdkCursor*)RVAL2BOXED(self, GDK_TYPE_COLOR))->type == + GDK_CURSOR_IS_PIXMAP); +} + +static VALUE +rg_cursor_type(VALUE self) +{ + return GENUM2RVAL(((GdkCursor*)RVAL2BOXED(self, GDK_TYPE_CURSOR))->type, GDK_TYPE_CURSOR_TYPE); +} + +#if GTK_CHECK_VERSION(2,8,0) +static VALUE +rg_image(VALUE self) +{ + return GOBJ2RVAL(gdk_cursor_get_image((GdkCursor*)RVAL2BOXED(self, GDK_TYPE_CURSOR))); +} +#endif + +void +Init_gtk_gdk_cursor(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_CURSOR, "Cursor", mGdk); + + RG_DEF_METHOD(initialize, -1); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(display, 0); +#endif + RG_DEF_METHOD_P(pixmap, 0); + RG_DEF_METHOD(cursor_type, 0); +#if GTK_CHECK_VERSION(2,8,0) + RG_DEF_METHOD(image, 0); +#endif + + G_DEF_CLASS(GDK_TYPE_CURSOR_TYPE, "Type", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_CURSOR_TYPE, "GDK_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkdevice.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkdevice.c new file mode 100644 index 0000000..0cb9348 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkdevice.c @@ -0,0 +1,229 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003-2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cDevice +#define _SELF(self) (GDK_DEVICE(RVAL2GOBJ(self))) + +/* Methods */ +static VALUE +rg_s_list(G_GNUC_UNUSED VALUE self) +{ + /* Owned by GDK */ + return GLIST2ARY(gdk_devices_list()); +} + +static VALUE +rg_s_set_extension_events(G_GNUC_UNUSED VALUE self, VALUE window, VALUE mask, VALUE mode) +{ + gdk_input_set_extension_events(GDK_WINDOW(RVAL2GOBJ(window)), + NUM2INT(mask), FIX2INT(mode)); + return Qnil; +} + +static VALUE +rg_set_source(VALUE self, VALUE source) +{ + gdk_device_set_source(_SELF(self), RVAL2GENUM(source, GDK_TYPE_INPUT_SOURCE)); + return self; +} + +static VALUE +rg_set_mode(VALUE self, VALUE mode) +{ + return CBOOL2RVAL(gdk_device_set_mode(_SELF(self), RVAL2GENUM(mode, GDK_TYPE_INPUT_MODE))); +} + +static VALUE +rg_set_key(VALUE self, VALUE index, VALUE keyval, VALUE modifiers) +{ + gdk_device_set_key(_SELF(self), NUM2UINT(index), NUM2UINT(keyval), + RVAL2GFLAGS(modifiers, GDK_TYPE_MODIFIER_TYPE)); + return self; +} + +static VALUE +rg_set_axis_use(VALUE self, VALUE index, VALUE use) +{ + gdk_device_set_axis_use(_SELF(self), NUM2UINT(index), + RVAL2GENUM(use, GDK_TYPE_AXIS_USE)); + return self; +} + +static VALUE +rg_s_core_pointer(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(gdk_device_get_core_pointer()); +} + +static VALUE +rg_get_state(VALUE self, VALUE window) +{ + gdouble axes[2]; + GdkModifierType mask; + + gdk_device_get_state(_SELF(self), GDK_WINDOW(RVAL2GOBJ(window)), + axes, &mask); + return rb_ary_new3(3, rb_float_new(axes[0]), rb_float_new(axes[1]), + GFLAGS2RVAL(mask, GDK_TYPE_MODIFIER_TYPE)); +} + +static VALUE +rg_get_history(VALUE self, VALUE window, VALUE start, VALUE stop) +{ + gboolean ret; + GdkTimeCoord** events; + gint i, n_events; + VALUE ary = Qnil; + ret = gdk_device_get_history(_SELF(self), + GDK_WINDOW(RVAL2GOBJ(window)), + NUM2UINT(start), NUM2UINT(stop), + &events, &n_events); + if (ret){ + ary = rb_ary_new(); + for (i = 0; i < n_events; i++){ + rb_ary_push(ary, BOXED2RVAL(events, GDK_TYPE_TIME_COORD)); + } + gdk_device_free_history(events, n_events); + } + return ary; +} + +static VALUE +rg_get_axis(VALUE self, VALUE rbaxes, VALUE rbuse) +{ + GdkDevice *device = _SELF(self); + GdkAxisUse use = RVAL2GENUM(rbuse, GDK_TYPE_AXIS_USE); + long n; + gdouble *axes = RVAL2GDOUBLES(rbaxes, n); + gint device_n_axes = gdk_device_get_n_axes(device); + gdouble value; + gboolean found; + + if (n != device_n_axes) + rb_raise(rb_eArgError, + "unexpected number of axes: %ld != %d", + n, device_n_axes); + + found = gdk_device_get_axis(device, axes, use, &value); + + g_free(axes); + + return found ? DBL2NUM(value) : Qnil; +} + +/* Accessor */ +static VALUE +rg_name(VALUE self) +{ + return CSTR2RVAL(_SELF(self)->name); +} + +static VALUE +rg_source(VALUE self) +{ + return GENUM2RVAL(_SELF(self)->source, GDK_TYPE_INPUT_SOURCE); +} + +static VALUE +rg_mode(VALUE self) +{ + return GENUM2RVAL(_SELF(self)->mode, GDK_TYPE_INPUT_MODE); +} + +static VALUE +rg_has_cursor_p(VALUE self) +{ + return CBOOL2RVAL(_SELF(self)->has_cursor); +} + +static VALUE +rg_axes(VALUE self) +{ + gint i; + VALUE ary = rb_ary_new(); + GdkDeviceAxis* axes = _SELF(self)->axes; + + for (i = 0; i < _SELF(self)->num_axes; i++){ + rb_ary_push(ary, rb_ary_new3(3, GENUM2RVAL(axes[i].use, GDK_TYPE_AXIS_USE), + rb_float_new(axes[i].min), rb_float_new(axes[i].max))); + } + return ary; +} + +static VALUE +rg_keys(VALUE self) +{ + gint i; + VALUE ary = rb_ary_new(); + GdkDeviceKey* keys = _SELF(self)->keys; + + for (i = 0; i < _SELF(self)->num_keys; i++){ + rb_ary_push(ary, rb_ary_new3(2, UINT2NUM(keys[i].keyval), + GFLAGS2RVAL(keys[i].modifiers, GDK_TYPE_MODIFIER_TYPE))); + } + return ary; +} + +void +Init_gtk_gdk_device(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_DEVICE, "Device", mGdk); + + RG_DEF_SMETHOD(list, 0); + RG_DEF_SMETHOD(core_pointer, 0); + RG_DEF_SMETHOD(set_extension_events, 3); + + RG_DEF_METHOD(set_source, 1); + RG_DEF_METHOD(set_mode, 1); + RG_DEF_METHOD(set_key, 3); + RG_DEF_METHOD(set_axis_use, 2); + RG_DEF_METHOD(get_state, 1); + RG_DEF_METHOD(get_history, 3); + RG_DEF_METHOD(get_axis, 2); + + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(source, 0); + RG_DEF_METHOD(mode, 0); + RG_DEF_METHOD_P(has_cursor, 0); + RG_DEF_METHOD(axes, 0); + RG_DEF_METHOD(keys, 0); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + + /* GdkInputSource */ + G_DEF_CLASS(GDK_TYPE_INPUT_SOURCE, "InputSource", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_INPUT_SOURCE, "GDK_"); + + /* GdkInputMode */ + G_DEF_CLASS(GDK_TYPE_INPUT_MODE, "InputMode", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_INPUT_MODE, "GDK_"); + + /* GdkAxisUse */ + G_DEF_CLASS(GDK_TYPE_AXIS_USE, "AxisUse", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_AXIS_USE, "GDK_"); + + /* GdkExtensionMode */ + G_DEF_CLASS(GDK_TYPE_EXTENSION_MODE, "ExtensionMode", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_EXTENSION_MODE, "GDK_"); + +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkdisplay.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkdisplay.c new file mode 100644 index 0000000..c90b6d0 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkdisplay.c @@ -0,0 +1,591 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,2,0) + +#define RG_TARGET_NAMESPACE cDisplay +#define _SELF(i) GDK_DISPLAY_OBJECT(RVAL2GOBJ(i)) + +static VALUE +rg_close(VALUE self) +{ + gdk_display_close(_SELF(self)); + return self; +} + +static VALUE +rg_s_open(G_GNUC_UNUSED VALUE self, VALUE display_name) +{ + GdkDisplay* gdisplay = gdk_display_open(RVAL2CSTR(display_name)); + if (! gdisplay) { + rb_raise(rb_eRuntimeError, "The display `%s' could not be opened.", + RVAL2CSTR(display_name)); + } else { + VALUE display; + g_object_ref(gdisplay); + display = GOBJ2RVAL(gdisplay); + + if (rb_block_given_p()) { + rb_ensure(rb_yield, display, rg_close, display); + return Qnil; + } else { + return display; + } + } +} + +static VALUE +rg_s_default(G_GNUC_UNUSED VALUE self) +{ + GdkDisplay* gdisplay = gdk_display_get_default(); + if (! gdisplay) + rb_raise(rb_eRuntimeError, "No default display is found."); + + return GOBJ2RVAL(gdisplay); +} + +static VALUE +rg_name(VALUE self) +{ + return CSTR2RVAL(gdk_display_get_name(_SELF(self))); +} + +static VALUE +rg_n_screens(VALUE self) +{ + return INT2NUM(gdk_display_get_n_screens(_SELF(self))); +} + +static VALUE +rg_get_screen(VALUE self, VALUE num) +{ + return GOBJ2RVAL(gdk_display_get_screen(_SELF(self), NUM2INT(num))); +} + +static VALUE +rg_default_screen(VALUE self) +{ + return GOBJ2RVAL(gdk_display_get_default_screen(_SELF(self))); +} + +static VALUE +rg_pointer_ungrab(VALUE self, VALUE time) +{ + gdk_display_pointer_ungrab(_SELF(self), NUM2ULONG(time)); + return self; +} + +static VALUE +rg_keyboard_ungrab(VALUE self, VALUE time) +{ + gdk_display_keyboard_ungrab(_SELF(self), NUM2ULONG(time)); + return self; +} + +static VALUE +rg_pointer_grabbed_p(VALUE self) +{ + return CBOOL2RVAL(gdk_display_pointer_is_grabbed(_SELF(self))); +} + +static VALUE +rg_beep(VALUE self) +{ + gdk_display_beep(_SELF(self)); + return self; +} + +static VALUE +rg_sync(VALUE self) +{ + gdk_display_sync(_SELF(self)); + return self; +} + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_flush(VALUE self) +{ + gdk_display_flush(_SELF(self)); + return self; +} +#endif + +static VALUE +rg_devices(VALUE self) +{ + return rbgutil_glist2ary(gdk_display_list_devices(_SELF(self))); +} + +static VALUE +rg_event(VALUE self) +{ + return GEV2RVAL(gdk_display_get_event(_SELF(self))); +} + +static VALUE +rg_peek_event(VALUE self) +{ + return GEV2RVAL(gdk_display_peek_event(_SELF(self))); +} + +static VALUE +rg_put_event(VALUE self, VALUE event) +{ + gdk_display_put_event(_SELF(self), RVAL2GEV(event)); + return self; +} + +/* Don't implement this. +static GdkFilterReturn +filter_func(GdkXEvent xevent, GdkEvent event, gpointer func) +{ + return GENUM2RVAL(rb_funcall((VALUE)func, id_call, 2, + ????, GEV2RVAL(event)), + GDK_TYPE_FILTER_RETURN); +} + +static VALUE +gdkdisplay_add_client_message_filter(VALUE self, VALUE message_type) +{ + VALUE func = RB_BLOCK_PROC(); + G_RELATIVE(self, func); + gdk_display_add_client_message_filter(_SELF(self), RVAL2ATOM(message_type), + filter_func, func); + return self; +} +*/ + +static VALUE +rg_set_double_click_time(VALUE self, VALUE msec) +{ + gdk_display_set_double_click_time(_SELF(self), NUM2UINT(msec)); + return self; +} + +static VALUE +rg_double_click_time(VALUE self) +{ + return UINT2NUM(_SELF(self)->double_click_time); +} + +static VALUE +rg_button_click_time(VALUE self) +{ + return rb_ary_new3(2, + UINT2NUM(_SELF(self)->button_click_time[0]), + UINT2NUM(_SELF(self)->button_click_time[1])); +} + +static VALUE +rg_button_window(VALUE self) +{ + return rb_ary_new3(2, + GOBJ2RVAL(_SELF(self)->button_window[0]), + GOBJ2RVAL(_SELF(self)->button_window[1])); +} + +static VALUE +rg_button_number(VALUE self) +{ + return rb_ary_new3(2, + INT2NUM(_SELF(self)->button_number[0]), + INT2NUM(_SELF(self)->button_number[1])); +} + +static VALUE +rg_closed_p(VALUE self) +{ + return CBOOL2RVAL(_SELF(self)->closed); +} + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_button_x(VALUE self) +{ + return rb_ary_new3(2, + INT2NUM(_SELF(self)->button_x[0]), + INT2NUM(_SELF(self)->button_x[1])); +} + +static VALUE +rg_button_y(VALUE self) +{ + return rb_ary_new3(2, + INT2NUM(_SELF(self)->button_y[0]), + INT2NUM(_SELF(self)->button_y[1])); +} + +static VALUE +rg_set_double_click_distance(VALUE self, VALUE distance) +{ + gdk_display_set_double_click_distance(_SELF(self), NUM2UINT(distance)); + return self; +} + +static VALUE +rg_double_click_distance(VALUE self) +{ + return UINT2NUM(_SELF(self)->double_click_distance); +} +#endif + +static VALUE +rg_pointer(VALUE self) +{ + GdkScreen *screen; + int x,y; + GdkModifierType mask; + + gdk_display_get_pointer(_SELF(self), &screen, &x, &y, &mask); + + return rb_ary_new3(4, GOBJ2RVAL(screen), INT2NUM(x), INT2NUM(y), INT2NUM(mask)); +} +static VALUE +rg_window_at_pointer(VALUE self) +{ + GdkWindow *window; + int x,y; + + window = gdk_display_get_window_at_pointer(_SELF(self), &x, &y); + + return rb_ary_new3(3, GOBJ2RVAL(window), INT2NUM(x), INT2NUM(y)); +} + +/* Don't implement this. +GdkDisplayPointerHooks* gdk_display_set_pointer_hooks + (GdkDisplay *display, + const GdkDisplayPointerHooks *new_hooks); + */ + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_supports_cursor_color_p(VALUE self) +{ + return CBOOL2RVAL(gdk_display_supports_cursor_color(_SELF(self))); +} + +static VALUE +rg_supports_cursor_alpha_p(VALUE self) +{ + return CBOOL2RVAL(gdk_display_supports_cursor_alpha(_SELF(self))); +} + +static VALUE +rg_default_cursor_size(VALUE self) +{ + return UINT2NUM(gdk_display_get_default_cursor_size(_SELF(self))); +} + +static VALUE +rg_maximal_cursor_size(VALUE self) +{ + guint width, height; + gdk_display_get_maximal_cursor_size(_SELF(self), &width, &height); + return rb_assoc_new(UINT2NUM(width), UINT2NUM(height)); +} + +static VALUE +rg_default_group(VALUE self) +{ + return GOBJ2RVAL(gdk_display_get_default_group(_SELF(self))); +} +#endif + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_supports_selection_notification_p(VALUE self) +{ + return CBOOL2RVAL(gdk_display_supports_selection_notification(_SELF(self))); +} + +static VALUE +rg_request_selection_notification_p(VALUE self, VALUE selection) +{ + return CBOOL2RVAL(gdk_display_request_selection_notification(_SELF(self), + RVAL2ATOM(selection))); +} + +static VALUE +rg_supports_clipboard_persistence_p(VALUE self) +{ + return CBOOL2RVAL(gdk_display_supports_clipboard_persistence(_SELF(self))); +} + +static VALUE +rg_store_clipboard(VALUE self, VALUE rbclipboard_window, VALUE rbtime_, VALUE rbtargets) +{ + GdkDisplay *display = _SELF(self); + GdkWindow *clipboard_window = GDK_WINDOW(RVAL2GOBJ(rbclipboard_window)); + guint32 time_ = NUM2UINT(rbtime_); + long n; + GdkAtom *targets = RVAL2GDKATOMS(rbtargets, &n); + + gdk_display_store_clipboard(display, clipboard_window, time_, targets, n); + + g_free(targets); + + return self; +} +#endif + +static VALUE +rg_core_pointer(VALUE self) +{ + return GOBJ2RVAL(gdk_display_get_core_pointer(_SELF(self))); +} + +#if GTK_CHECK_VERSION(2,8,0) +static VALUE +rg_warp_pointer(VALUE self, VALUE screen, VALUE x, VALUE y) +{ + gdk_display_warp_pointer(_SELF(self), RVAL2GOBJ(screen), NUM2INT(x), NUM2INT(y)); + return self; +} +#endif + +#ifdef GDK_WINDOWING_X11 +static VALUE +rg_grab(VALUE self) +{ + gdk_x11_display_grab(_SELF(self)); + return self; +} +static VALUE +rg_ungrab(VALUE self) +{ + gdk_x11_display_ungrab(_SELF(self)); + return self; +} +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_register_standard_event_type(VALUE self, VALUE event_base, VALUE n_events) +{ + gdk_x11_register_standard_event_type(_SELF(self), + NUM2INT(event_base), NUM2INT(n_events)); + return self; +} +#endif +#if GTK_CHECK_VERSION(2,8,0) +static VALUE +rg_user_time(VALUE self) +{ + return UINT2NUM(gdk_x11_display_get_user_time(_SELF(self))); +} + +static VALUE +rg_set_cursor_theme(VALUE self, VALUE theme, VALUE size) +{ + gdk_x11_display_set_cursor_theme(_SELF(self), RVAL2CSTR(theme), NUM2INT(size)); + return self; +} +#endif + +# if GTK_CHECK_VERSION(2, 12, 0) +/* +*** need gdk_x11_display_broadcast_startup_messagev() *** + +typedef struct _StartupMessageParameterData { + gchar **parameters; + guint i; +} StartupMessageParameterData; + +static int +collect_parameter(VALUE key, VALUE value, VALUE data) +{ + StartupMessageParameterData *parameter_data; + parameter_data = (StartupMessageParameterData *)data; + + parameter_data->parameters[parameter_data->i] = RVAL2CSTR(key); + parameter_data->i++; + parameter_data->parameters[parameter_data->i] = RVAL2CSTR(value); + parameter_data->i++; + + return ST_CONTINUE; +} + +static VALUE +rg_broadcast_startup_message(int argc, VALUE *argv, VALUE self) +{ + VALUE rb_message_type, rb_parameters; + char *message_type; + guint n_parameters; + gchar **parameters; + + rb_scan_args(argc, argv, "11", &rb_message_type, &rb_parameters); + + message_type = RVAL2CSTR(rb_message_type); + if (NIL_P(rb_parameters)) { + n_parameters = 0; + parameters = NULL; + } + else { + StartupMessageParameterData data; + + Check_Type(rb_parameters, T_HASH); + n_parameters = NUM2UINT(rb_funcall(rb_parameters, rb_intern("size"), 0)); + parameters = ALLOCA_N(gchar *, n_parameters * 2); + data.i = 0; + data.parameters = parameters; + rb_hash_foreach(rb_parameters, collect_parameter, (VALUE)&data); + } + + gdk_x11_display_broadcast_startup_messagev(_SELF(self), + message_type, + n_parameters, + parameters); + + return self; +} +*/ + +static VALUE +rg_startup_notification_id(VALUE self) +{ + return CSTR2RVAL(gdk_x11_display_get_startup_notification_id(_SELF(self))); +} +# endif + +#endif +#endif + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_supports_shapes_p(VALUE self) +{ + return CBOOL2RVAL(gdk_display_supports_shapes(_SELF(self))); +} + +static VALUE +rg_supports_input_shapes_p(VALUE self) +{ + return CBOOL2RVAL(gdk_display_supports_input_shapes(_SELF(self))); +} +#endif + +#if GTK_CHECK_VERSION(2, 12, 0) +static VALUE +rg_supports_composite_p(VALUE self) +{ + return CBOOL2RVAL(gdk_display_supports_composite(_SELF(self))); +} + +static VALUE +rg_trigger_tooltip_query(VALUE self) +{ + gtk_tooltip_trigger_tooltip_query(_SELF(self)); + return self; +} +#endif + +void +Init_gtk_gdk_display(VALUE mGdk) +{ +#if GTK_CHECK_VERSION(2,2,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_DISPLAY, "Display", mGdk); + + RG_DEF_SMETHOD(open, 1); + RG_DEF_SMETHOD(default, 0); + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(n_screens, 0); + RG_DEF_METHOD(get_screen, 1); + RG_DEF_ALIAS("[]", "get_screen"); + RG_DEF_METHOD(default_screen, 0); + + RG_DEF_METHOD(pointer_ungrab, 1); + RG_DEF_METHOD(keyboard_ungrab, 1); + RG_DEF_METHOD_P(pointer_grabbed, 0); + + RG_DEF_METHOD(beep, 0); + RG_DEF_METHOD(sync, 0); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(flush, 0); +#endif + RG_DEF_METHOD(close, 0); + + RG_DEF_METHOD(devices, 0); + RG_DEF_METHOD(event, 0); + RG_DEF_METHOD(peek_event, 0); + RG_DEF_METHOD(put_event, 1); + RG_DEF_METHOD(set_double_click_time, 1); + RG_DEF_METHOD(double_click_time, 0); + RG_DEF_METHOD(button_click_time, 0); + RG_DEF_METHOD(button_window, 0); + RG_DEF_METHOD(button_number, 0); + RG_DEF_METHOD_P(closed, 0); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(button_x, 0); + RG_DEF_METHOD(button_y, 0); + RG_DEF_METHOD(set_double_click_distance, 1); + RG_DEF_METHOD(double_click_distance, 0); +#endif + RG_DEF_METHOD(pointer, 0); + RG_DEF_METHOD(window_at_pointer, 0); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD_P(supports_cursor_color, 0); + RG_DEF_METHOD_P(supports_cursor_alpha, 0); + RG_DEF_METHOD(default_cursor_size, 0); + RG_DEF_METHOD(maximal_cursor_size, 0); + RG_DEF_METHOD(default_group, 0); +#endif +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD_P(supports_selection_notification, 0); + RG_DEF_METHOD_P(request_selection_notification, 1); + RG_DEF_METHOD_P(supports_clipboard_persistence, 0); + RG_DEF_METHOD(store_clipboard, 3); +#endif + RG_DEF_METHOD(core_pointer, 0); +#if GTK_CHECK_VERSION(2,8,0) + RG_DEF_METHOD(warp_pointer, 3); +#endif + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +#ifdef GDK_WINDOWING_X11 + RG_DEF_METHOD(grab, 0); + RG_DEF_METHOD(ungrab, 0); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(register_standard_event_type, 2); +#endif +#if GTK_CHECK_VERSION(2,8,0) + RG_DEF_METHOD(user_time, 0); + RG_DEF_METHOD(set_cursor_theme, 2); +#endif +# if GTK_CHECK_VERSION(2, 12, 0) +/* + RG_DEF_METHOD(broadcast_startup_message, -1); +*/ + RG_DEF_METHOD(startup_notification_id, 0); +# endif + G_DEF_CLASS3("GdkDisplayX11", "DisplayX11", mGdk); +#endif +#endif + +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD_P(supports_shapes, 0); + RG_DEF_METHOD_P(supports_input_shapes, 0); +#endif +#if GTK_CHECK_VERSION(2, 12, 0) + RG_DEF_METHOD_P(supports_composite, 0); + RG_DEF_METHOD(trigger_tooltip_query, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkdisplaymanager.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkdisplaymanager.c new file mode 100644 index 0000000..1473699 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkdisplaymanager.c @@ -0,0 +1,59 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,2,0) + +#define RG_TARGET_NAMESPACE cDisplayManager +#define _SELF(obj) GDK_DISPLAY_MANAGER(RVAL2GOBJ(obj)) + +static VALUE +rg_s_get(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(gdk_display_manager_get()); +} + +static VALUE +rg_displays(VALUE self) +{ + return GSLIST2ARYF(gdk_display_manager_list_displays(_SELF(self))); +} + +/* Move to Gdk::Display. +static VALUE +gdkdisplaymanager_get_core_pointer(VALUE self) +{ + return GOBJ2RVAL(gdk_display_get_core_pointer(_SELF(self))); +} +*/ +#endif + +void +Init_gtk_gdk_display_manager(VALUE mGdk) +{ +#if GTK_CHECK_VERSION(2,2,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_DISPLAY_MANAGER, "DisplayManager", mGdk); + + RG_DEF_SMETHOD(get, 0); + RG_DEF_METHOD(displays, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkdragcontext.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkdragcontext.c new file mode 100644 index 0000000..6cbb970 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkdragcontext.c @@ -0,0 +1,304 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cDragContext +#define _SELF(self) (GDK_DRAG_CONTEXT(RVAL2GOBJ(self))) + +static VALUE +rg_protocol(VALUE self) +{ + return GENUM2RVAL(_SELF(self)->protocol, GDK_TYPE_DRAG_PROTOCOL); +} + +static VALUE +rg_source_p(VALUE self) +{ + return CBOOL2RVAL(_SELF(self)->is_source); +} + +static VALUE +rg_source_window(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->source_window); +} + +static VALUE +rg_dest_window(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->dest_window); +} + +static VALUE +rg_targets(VALUE self) +{ + GList *list = _SELF(self)->targets, *cur; + VALUE ary = rb_ary_new(); + + for (cur = list; cur != NULL; cur = cur->next) { + rb_ary_push(ary, BOXED2RVAL((GdkAtom)cur->data, GDK_TYPE_ATOM)); + } + return ary; +} + +static VALUE +rg_actions(VALUE self) +{ + return GFLAGS2RVAL(_SELF(self)->actions, GDK_TYPE_DRAG_ACTION); +} + +static VALUE +rg_suggested_action(VALUE self) +{ + return GFLAGS2RVAL(_SELF(self)->suggested_action, GDK_TYPE_DRAG_ACTION); +} + +static VALUE +rg_action(VALUE self) +{ + return GFLAGS2RVAL(_SELF(self)->action, GDK_TYPE_DRAG_ACTION); +} + +static VALUE +rg_start_time(VALUE self) +{ + return UINT2NUM(_SELF(self)->start_time); +} + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, gdk_drag_context_new()); + return Qnil; +} + +static VALUE +rg_s_get_protocol(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE xid; + GdkDragProtocol prot; + GdkNativeWindow ret; + + if (argc == 1) { + rb_scan_args(argc, argv, "10", &xid); + ret = gdk_drag_get_protocol(RVAL2GDKNATIVEWINDOW(xid), &prot); + } else { +#if GTK_CHECK_VERSION(2,2,0) + VALUE display; + rb_scan_args(argc, argv, "20", &display, &xid); + ret = gdk_drag_get_protocol_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)), + RVAL2GDKNATIVEWINDOW(xid), &prot); +#else + rb_warn("Not supported arguments for Gdk::Display in GTK+-2.0.x."); + ret = gdk_drag_get_protocol(NUM2UINT(xid), &prot); +#endif + } + + return rb_ary_new3(2, GENUM2RVAL(prot, GDK_TYPE_DRAG_PROTOCOL), GDKNATIVEWINDOW2RVAL(ret)); +} + +/* Instance Methods */ +static VALUE +rg_selection(VALUE self) +{ + return BOXED2RVAL(gdk_drag_get_selection(_SELF(self)), GDK_TYPE_ATOM); +} + +static VALUE +rg_drag_abort(VALUE self, VALUE time) +{ + gdk_drag_abort(_SELF(self), NUM2UINT(time)); + return self; +} + +static VALUE +rg_drop_reply(VALUE self, VALUE ok, VALUE time) +{ + gdk_drop_reply(_SELF(self), RVAL2CBOOL(ok), NUM2UINT(time)); + return self; +} + +static VALUE +rg_drag_drop(VALUE self, VALUE time) +{ + gdk_drag_drop(_SELF(self), NUM2UINT(time)); + return self; +} + +static VALUE +rg_find_window(int argc, VALUE *argv, VALUE self) +{ + VALUE drag_window, x_root, y_root; + GdkWindow *dest_window; + GdkDragProtocol prot; + + if (argc == 3) { + rb_scan_args(argc, argv, "30", &drag_window, &x_root, &y_root); + gdk_drag_find_window(_SELF(self), + GDK_WINDOW(RVAL2GOBJ(drag_window)), + NUM2INT(x_root), NUM2INT(y_root), + &dest_window, &prot); + } else { +#if GTK_CHECK_VERSION(2,2,0) + VALUE screen; + rb_scan_args(argc, argv, "40", &drag_window, &screen, &x_root, &y_root); + gdk_drag_find_window_for_screen(_SELF(self), + GDK_WINDOW(RVAL2GOBJ(drag_window)), + GDK_SCREEN(RVAL2GOBJ(screen)), + NUM2INT(x_root), NUM2INT(y_root), + &dest_window, &prot); +#else + rb_raise(rb_eArgError, "Wrong number of arguments: %d", argc); +#endif + } + + return rb_ary_new3(2, GOBJ2RVAL(dest_window), + GENUM2RVAL(prot, GDK_TYPE_DRAG_PROTOCOL)); +} + +struct rbgdk_rval2gdkatomglist_args { + VALUE ary; + long n; + GList *result; +}; + +static VALUE +rbgdk_rval2gdkatomglist_body(VALUE value) +{ + long i; + struct rbgdk_rval2gdkatomglist_args *args = (struct rbgdk_rval2gdkatomglist_args *)value; + + for (i = 0; i < args->n; i++) + args->result = g_list_append(args->result, GINT_TO_POINTER(RVAL2ATOM(RARRAY_PTR(args->ary)[i]))); + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbgdk_rval2gdkatomglist_rescue(VALUE value) +{ + g_free(((struct rbgdk_rval2gdkatomglist_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static GList * +rbgdk_rval2gdkatomglist(VALUE value) +{ + struct rbgdk_rval2gdkatomglist_args args; + + args.ary = rb_ary_to_ary(value); + args.n = RARRAY_LEN(args.ary); + args.result = NULL; + + rb_rescue(rbgdk_rval2gdkatomglist_body, (VALUE)&args, + rbgdk_rval2gdkatomglist_rescue, (VALUE)&args); + + return args.result; +} + +#define RVAL2GDKATOMGLIST(value) rbgdk_rval2gdkatomglist(value) + +static VALUE +rg_s_drag_begin(G_GNUC_UNUSED VALUE self, VALUE rbwindow, VALUE rbtargets) +{ + GdkWindow *window = GDK_WINDOW(RVAL2GOBJ(rbwindow)); + GList *targets = RVAL2GDKATOMGLIST(rbtargets); + GdkDragContext *result = gdk_drag_begin(window, targets); + + g_list_free(targets); + + return GOBJ2RVAL(result); +} + +static VALUE +rg_drag_motion(VALUE self, VALUE dest_window, VALUE protocol, VALUE x_root, VALUE y_root, VALUE suggested_action, VALUE possible_actions, VALUE time) +{ + gboolean ret = gdk_drag_motion(_SELF(self), + GDK_WINDOW(RVAL2GOBJ(dest_window)), + RVAL2GENUM(protocol, GDK_TYPE_DRAG_PROTOCOL), + NUM2INT(x_root), NUM2INT(y_root), + RVAL2GFLAGS(suggested_action, GDK_TYPE_DRAG_ACTION), + RVAL2GFLAGS(possible_actions, GDK_TYPE_DRAG_ACTION), + NUM2UINT(time)); + return CBOOL2RVAL(ret); +} + +static VALUE +rg_drop_finish(VALUE self, VALUE success, VALUE time) +{ + gdk_drop_finish(_SELF(self), RVAL2CBOOL(success), NUM2UINT(time)); + return self; +} + +static VALUE +rg_drag_status(VALUE self, VALUE action, VALUE time) +{ + gdk_drag_status(_SELF(self), + RVAL2GFLAGS(action, GDK_TYPE_DRAG_ACTION), NUM2UINT(time)); + return self; +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_drag_drop_succeeded_p(VALUE self) +{ + return CBOOL2RVAL(gdk_drag_drop_succeeded(_SELF(self))); +} +#endif + +void +Init_gtk_gdk_dragcontext(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_DRAG_CONTEXT, "DragContext", mGdk); + + RG_DEF_SMETHOD(get_protocol, -1); + RG_DEF_SMETHOD(drag_begin, 1); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(protocol, 0); + RG_DEF_METHOD_P(source, 0); + RG_DEF_METHOD(source_window, 0); + RG_DEF_METHOD(dest_window, 0); + RG_DEF_METHOD(targets, 0); + RG_DEF_METHOD(actions, 0); + RG_DEF_METHOD(suggested_action, 0); + RG_DEF_METHOD(action, 0); + RG_DEF_METHOD(start_time, 0); + + RG_DEF_METHOD(selection, 0); + RG_DEF_METHOD(drag_abort, 1); + RG_DEF_METHOD(drop_reply, 2); + RG_DEF_METHOD(drag_drop, 1); + RG_DEF_METHOD(find_window, 4); + RG_DEF_METHOD(drag_motion, 7); + RG_DEF_METHOD(drop_finish, 2); + RG_DEF_METHOD(drag_status, 2); +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD_P(drag_drop_succeeded, 0); +#endif + /* Constants */ + G_DEF_CLASS(GDK_TYPE_DRAG_PROTOCOL, "Protocol", RG_TARGET_NAMESPACE); + G_DEF_CLASS(GDK_TYPE_DRAG_ACTION, "Action", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_DRAG_PROTOCOL, "GDK_DRAG_"); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_DRAG_ACTION, "GDK_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkdraw.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkdraw.c new file mode 100644 index 0000000..61b5370 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkdraw.c @@ -0,0 +1,546 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" +#include "rbpango.h" +#ifdef GDK_WINDOWING_X11 +#include +#endif +#ifdef HAVE_RB_CAIRO_H +#include +#endif + +#define RG_TARGET_NAMESPACE cDrawable +#define _SELF(s) GDK_DRAWABLE(RVAL2GOBJ(s)) + +static VALUE +rg_visual(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)); +} + +static VALUE +rg_set_colormap(VALUE self, VALUE colormap) +{ + VALUE old_colormap; + + old_colormap = GOBJ2RVAL(gdk_drawable_get_colormap(_SELF(self))); + G_CHILD_REMOVE(self, old_colormap); + + G_CHILD_ADD(self, colormap); + gdk_drawable_set_colormap(_SELF(self), GDK_COLORMAP(RVAL2GOBJ(colormap))); + return self; +} + +static VALUE +rg_colormap(VALUE self) +{ + VALUE rb_colormap; + + rb_colormap = GOBJ2RVAL(gdk_drawable_get_colormap(_SELF(self))); + G_CHILD_ADD(self, rb_colormap); + return rb_colormap; +} + +static VALUE +rg_depth(VALUE self) +{ + return INT2NUM(gdk_drawable_get_depth(_SELF(self))); +} + +static VALUE +rg_size(VALUE self) +{ + gint width, height; + gdk_drawable_get_size(_SELF(self), &width, &height); + return rb_ary_new3(2, INT2NUM(width), INT2NUM(height)); +} + +static VALUE +rg_clip_region(VALUE self) +{ + return BOXED2RVAL(gdk_drawable_get_clip_region(_SELF(self)), GDK_TYPE_REGION); +} + +static VALUE +rg_visible_region(VALUE self) +{ + return BOXED2RVAL(gdk_drawable_get_visible_region(_SELF(self)), GDK_TYPE_REGION); +} + +static VALUE +rg_draw_point(VALUE self, VALUE gc, VALUE x, VALUE y) +{ + gdk_draw_point(_SELF(self), GDK_GC(RVAL2GOBJ(gc)), + NUM2INT(x), NUM2INT(y)); + return self; +} + +static VALUE +rg_draw_points(VALUE self, VALUE rbgc, VALUE rbpoints) +{ + GdkDrawable *drawable = _SELF(self); + GdkGC *gc = GDK_GC(RVAL2GOBJ(rbgc)); + long n; + GdkPoint *points = RVAL2GDKPOINTS(rbpoints, &n); + + gdk_draw_points(drawable, gc, points, n); + + g_free(points); + + return self; +} + +static VALUE +rg_draw_line(VALUE self, VALUE gc, VALUE x1, VALUE y1, VALUE x2, VALUE y2) +{ + gdk_draw_line(_SELF(self), GDK_GC(RVAL2GOBJ(gc)), + NUM2INT(x1), NUM2INT(y1), + NUM2INT(x2), NUM2INT(y2)); + return self; +} + +static VALUE +rg_draw_lines(VALUE self, VALUE rbgc, VALUE rbpoints) +{ + GdkDrawable *drawable = _SELF(self); + GdkGC *gc = GDK_GC(RVAL2GOBJ(rbgc)); + long n; + GdkPoint *points = RVAL2GDKPOINTS(rbpoints, &n); + + gdk_draw_lines(drawable, gc, points, n); + + g_free(points); + + return self; +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_draw_pixbuf(VALUE self, VALUE gc, VALUE pixbuf, VALUE src_x, VALUE src_y, VALUE dest_x, VALUE dest_y, VALUE width, VALUE height, VALUE dither, VALUE x_dither, VALUE y_dither) +{ + gdk_draw_pixbuf(_SELF(self), + GDK_GC(RVAL2GOBJ(gc)), + GDK_PIXBUF(RVAL2GOBJ(pixbuf)), + NUM2INT(src_x), NUM2INT(src_y), + NUM2INT(dest_x), NUM2INT(dest_y), + NUM2INT(width), NUM2INT(height), + RVAL2GENUM(dither, GDK_TYPE_RGB_DITHER), + NUM2INT(x_dither), NUM2INT(y_dither)); + return self; +} +#endif + +struct rbgdk_rval2gdksegments_args { + VALUE ary; + long n; + GdkSegment *result; +}; + +static VALUE +rbgdk_rval2gdksegments_body(VALUE value) +{ + long i; + struct rbgdk_rval2gdksegments_args *args = (struct rbgdk_rval2gdksegments_args *)value; + + for (i = 0; i < args->n; i++) { + VALUE segments = rb_ary_to_ary(RARRAY_PTR(args->ary)[i]); + + if (RARRAY_LEN(segments) != 2) + rb_raise(rb_eArgError, "segment %ld should be array of size 4", i); + + args->result[i].x1 = NUM2INT(RARRAY_PTR(segments)[0]); + args->result[i].y1 = NUM2INT(RARRAY_PTR(segments)[1]); + args->result[i].x2 = NUM2INT(RARRAY_PTR(segments)[2]); + args->result[i].y2 = NUM2INT(RARRAY_PTR(segments)[3]); + } + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbgdk_rval2gdksegments_rescue(VALUE value) +{ + g_free(((struct rbgdk_rval2gdksegments_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static GdkSegment * +rbgdk_rval2gdksegments(VALUE value, long *n) +{ + struct rbgdk_rval2gdksegments_args args; + + args.ary = rb_ary_to_ary(value); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(GdkSegment, args.n + 1); + + rb_rescue(rbgdk_rval2gdksegments_body, (VALUE)&args, + rbgdk_rval2gdksegments_rescue, (VALUE)&args); + + if (n != NULL) + *n = args.n; + + return args.result; +} + +#define RVAL2GDKSEGMENTS(value, n) rbgdk_rval2gdksegments(value, n) + +static VALUE +rg_draw_segments(VALUE self, VALUE rbgc, VALUE rbsegments) +{ + GdkDrawable *drawable = _SELF(self); + GdkGC *gc = GDK_GC(RVAL2GOBJ(rbgc)); + long n; + GdkSegment *segments = RVAL2GDKSEGMENTS(rbsegments, &n); + + gdk_draw_segments(drawable, gc, segments, n); + + g_free(segments); + + return self; +} + +static VALUE +rg_draw_rectangle(VALUE self, VALUE gc, VALUE filled, VALUE x, VALUE y, VALUE w, VALUE h) +{ + gdk_draw_rectangle(_SELF(self), GDK_GC(RVAL2GOBJ(gc)), + RVAL2CBOOL(filled), + NUM2INT(x), NUM2INT(y), + NUM2INT(w), NUM2INT(h)); + return self; +} + +static VALUE +rg_draw_arc(VALUE self, VALUE gc, VALUE filled, VALUE x, VALUE y, VALUE w, VALUE h, VALUE a1, VALUE a2) +{ + gdk_draw_arc(_SELF(self), GDK_GC(RVAL2GOBJ(gc)), + RVAL2CBOOL(filled), + NUM2INT(x), NUM2INT(y), + NUM2INT(w), NUM2INT(h), + NUM2INT(a1), NUM2INT(a2)); + return self; +} + +static VALUE +rg_draw_polygon(VALUE self, VALUE rbgc, VALUE rbfilled, VALUE rbpoints) +{ + GdkDrawable *drawable = _SELF(self); + GdkGC *gc = GDK_GC(RVAL2GOBJ(rbgc)); + gboolean filled = RVAL2CBOOL(rbfilled); + long n; + GdkPoint *points = RVAL2GDKPOINTS(rbpoints, &n); + + gdk_draw_polygon(drawable, gc, filled, points, n); + + g_free(points); + + return self; +} + +#if GTK_CHECK_VERSION(2,6,0) +/* + trapezoids = [[y1, x11, x21, y2, x12, x22], ...] + */ +struct rbgdk_rval2gdktrapezoids_args { + VALUE ary; + long n; + GdkTrapezoid *result; +}; + +static VALUE +rbgdk_rval2gdktrapezoids_body(VALUE value) +{ + long i; + struct rbgdk_rval2gdktrapezoids_args *args = (struct rbgdk_rval2gdktrapezoids_args *)value; + + for (i = 0; i < args->n; i++) { + VALUE trapezoids = rb_ary_to_ary(RARRAY_PTR(args->ary)[i]); + + if (RARRAY_LEN(trapezoids) != 6) + rb_raise(rb_eArgError, "trapezoid %ld should be array of size 6", i); + + args->result[i].y1 = NUM2DBL(RARRAY_PTR(trapezoids)[0]); + args->result[i].x11 = NUM2DBL(RARRAY_PTR(trapezoids)[1]); + args->result[i].x21 = NUM2DBL(RARRAY_PTR(trapezoids)[2]); + args->result[i].y2 = NUM2DBL(RARRAY_PTR(trapezoids)[3]); + args->result[i].x12 = NUM2DBL(RARRAY_PTR(trapezoids)[4]); + args->result[i].x22 = NUM2DBL(RARRAY_PTR(trapezoids)[5]); + } + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbgdk_rval2gdktrapezoids_rescue(VALUE value) +{ + g_free(((struct rbgdk_rval2gdktrapezoids_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static GdkTrapezoid * +rbgdk_rval2gdktrapezoids(VALUE value, long *n) +{ + struct rbgdk_rval2gdktrapezoids_args args; + + args.ary = rb_ary_to_ary(value); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(GdkTrapezoid, args.n + 1); + + rb_rescue(rbgdk_rval2gdktrapezoids_body, (VALUE)&args, + rbgdk_rval2gdktrapezoids_rescue, (VALUE)&args); + + if (n != NULL) + *n = args.n; + + return args.result; +} + +#define RVAL2GDKTRAPEZOIDS(value, n) rbgdk_rval2gdktrapezoids(value, n) + +static VALUE +rg_draw_trapezoids(VALUE self, VALUE rbgc, VALUE rbtrapezoids) +{ + GdkDrawable *drawable = _SELF(self); + GdkGC *gc = GDK_GC(RVAL2GOBJ(rbgc)); + long n; + GdkTrapezoid *trapezoids = RVAL2GDKTRAPEZOIDS(rbtrapezoids, &n); + + gdk_draw_trapezoids(drawable, gc, trapezoids, n); + + g_free(trapezoids); + + return self; +} +#endif + +static VALUE +rg_draw_glyphs(VALUE self, VALUE gc, VALUE font, VALUE x, VALUE y, VALUE glyphs) +{ + gdk_draw_glyphs(_SELF(self), GDK_GC(RVAL2GOBJ(gc)), PANGO_FONT(RVAL2GOBJ(font)), + NUM2INT(x), NUM2INT(y), + (PangoGlyphString*)(RVAL2BOXED(glyphs, PANGO_TYPE_GLYPH_STRING))); + return self; +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_draw_glyphs_transformed(VALUE self, VALUE gc, VALUE matrix, VALUE font, VALUE x, VALUE y, VALUE glyphs) +{ + gdk_draw_glyphs_transformed(_SELF(self), GDK_GC(RVAL2GOBJ(gc)), + NIL_P(matrix) ? (PangoMatrix*)NULL : (PangoMatrix*)(RVAL2BOXED(matrix, PANGO_TYPE_MATRIX)), + PANGO_FONT(RVAL2GOBJ(font)), + NUM2INT(x), NUM2INT(y), + (PangoGlyphString*)(RVAL2BOXED(glyphs, PANGO_TYPE_GLYPH_STRING))); + return self; +} +#endif + +static VALUE +rg_draw_layout_line(int argc, VALUE *argv, VALUE self) +{ + VALUE gc, x, y, line, fg, bg; + + rb_scan_args(argc, argv, "42", &gc, &x, &y, &line, &fg, &bg); + + gdk_draw_layout_line_with_colors(_SELF(self), GDK_GC(RVAL2GOBJ(gc)), + NUM2INT(x), NUM2INT(y), + (PangoLayoutLine*)RVAL2BOXED(line, PANGO_TYPE_LAYOUT_LINE), + RVAL2GDKCOLOR(fg), + RVAL2GDKCOLOR(bg)); + + return self; +} + +static VALUE +rg_draw_layout(int argc, VALUE *argv, VALUE self) +{ + VALUE gc, x, y, layout, fg, bg; + + rb_scan_args(argc, argv, "42", &gc, &x, &y, &layout, &fg, &bg); + + gdk_draw_layout_with_colors(_SELF(self), GDK_GC(RVAL2GOBJ(gc)), + NUM2INT(x), NUM2INT(y), PANGO_LAYOUT(RVAL2GOBJ(layout)), + RVAL2GDKCOLOR(fg), + RVAL2GDKCOLOR(bg)); + + return self; +} + +static VALUE +rg_draw_drawable(VALUE self, VALUE gc, VALUE src, VALUE xsrc, VALUE ysrc, VALUE xdst, VALUE ydst, VALUE w, VALUE h) +{ + gdk_draw_drawable(_SELF(self), GDK_GC(RVAL2GOBJ(gc)), _SELF(src), + NUM2INT(xsrc), NUM2INT(ysrc), + NUM2INT(xdst), NUM2INT(ydst), + NUM2INT(w), NUM2INT(h)); + return self; +} + +static VALUE +rg_draw_image(VALUE self, VALUE gc, VALUE image, VALUE xsrc, VALUE ysrc, VALUE xdst, VALUE ydst, VALUE w, VALUE h) +{ + gdk_draw_image(_SELF(self), GDK_GC(RVAL2GOBJ(gc)), + GDK_IMAGE(RVAL2GOBJ(image)), + NUM2INT(xsrc), NUM2INT(ysrc), + NUM2INT(xdst), NUM2INT(ydst), + NUM2INT(w), NUM2INT(h)); + return self; +} + +static VALUE +rg_get_image(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h) +{ + return GOBJ2RVAL(gdk_drawable_get_image(_SELF(self), + NUM2INT(x), NUM2INT(y), + NUM2INT(w), NUM2INT(h))); +} + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_copy_to_image(VALUE self, VALUE image, VALUE xsrc, VALUE ysrc, VALUE xdst, VALUE ydst, VALUE w, VALUE h) +{ + return GOBJ2RVAL(gdk_drawable_copy_to_image(_SELF(self), + GDK_IMAGE(RVAL2GOBJ(image)), + NUM2INT(xsrc), NUM2INT(ysrc), + NUM2INT(xdst), NUM2INT(ydst), + NUM2INT(w), NUM2INT(h))); +} +#endif + +#ifdef GDK_WINDOWING_X11 +static VALUE +rg_xid(VALUE self) +{ + return ULONG2NUM(GDK_DRAWABLE_XID(_SELF(self))); +} +#endif + +#ifdef GDK_WINDOWING_WIN32 +static VALUE +rg_handle(VALUE self) +{ + HGDIOBJ handle; + handle = gdk_win32_drawable_get_handle(_SELF(self)); + return ULONG2NUM(GPOINTER_TO_UINT(handle)); +} +#endif + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_display(VALUE self) +{ + return GOBJ2RVAL(gdk_drawable_get_display(_SELF(self))); +} + +static VALUE +rg_screen(VALUE self) +{ + return GOBJ2RVAL(gdk_drawable_get_screen(_SELF(self))); +} +#endif + +#if GTK_CHECK_VERSION(2,8,0) +# ifdef HAVE_RB_CAIRO_H +static VALUE +rg_create_cairo_context(VALUE self) +{ + VALUE rb_cr; + cairo_t *cr; + cr = gdk_cairo_create(_SELF(self)); + rb_cairo_check_status(cairo_status(cr)); + rb_cr = CRCONTEXT2RVAL(cr); + cairo_destroy (cr); + return rb_cr; +} +# endif +#endif + +void +Init_gtk_gdk_draw(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_DRAWABLE, "Drawable", mGdk); + + RG_DEF_METHOD(visual, 0); + RG_DEF_METHOD(set_colormap, 1); + RG_DEF_METHOD(colormap, 0); + RG_DEF_METHOD(depth, 0); + RG_DEF_METHOD(size, 0); + RG_DEF_METHOD(clip_region, 0); + RG_DEF_METHOD(visible_region, 0); + RG_DEF_METHOD(draw_point, 3); + RG_DEF_METHOD(draw_points, 2); + RG_DEF_METHOD(draw_line, 5); + RG_DEF_METHOD(draw_lines, 2); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(draw_pixbuf, 11); +#endif + RG_DEF_METHOD(draw_segments, 2); + RG_DEF_METHOD(draw_rectangle, 6); + RG_DEF_METHOD(draw_arc, 8); + RG_DEF_METHOD(draw_polygon, 3); +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(draw_trapezoids, 2); +#endif + RG_DEF_METHOD(draw_glyphs, 5); +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(draw_glyphs_transformed, 6); +#endif + RG_DEF_METHOD(draw_layout_line, -1); + RG_DEF_METHOD(draw_layout, -1); + RG_DEF_METHOD(draw_drawable, 8); + RG_DEF_METHOD(draw_image, 8); + RG_DEF_METHOD(get_image, 4); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(copy_to_image, 7); +#endif + +#ifdef GDK_WINDOWING_X11 + RG_DEF_METHOD(xid, 0); +#endif +#ifdef GDK_WINDOWING_WIN32 + RG_DEF_METHOD(handle, 0); +#endif +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(display, 0); + RG_DEF_METHOD(screen, 0); +#endif + +#if GTK_CHECK_VERSION(2,8,0) +# ifdef HAVE_RB_CAIRO_H + RG_DEF_METHOD(create_cairo_context, 0); +# endif +#endif + +#ifdef GDK_WINDOWING_X11 + G_DEF_CLASS3("GdkDrawableImplX11", "DrawableImplX11", mGdk); +#elif defined(GDK_WINDOWING_WIN32) + G_DEF_CLASS3("GdkDrawableImplWin32", "DrawableImplWin32", mGdk); +#elif defined(GDK_WINDOWING_FB) + G_DEF_CLASS3("GdkDrawableFB", "DrawableFB", mGdk); +#endif + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkevent.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkevent.c new file mode 100644 index 0000000..6a5d068 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkevent.c @@ -0,0 +1,981 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,8,0) +static VALUE gdkevents[36]; +#elif GTK_CHECK_VERSION(2,6,0) +static VALUE gdkevents[35]; +#else +static VALUE gdkevents[34]; +#endif + +/***********************************************/ + +VALUE +make_gdkevent(GdkEvent *ev) +{ + VALUE obj; + if (ev == NULL) return Qnil; + + obj = BOXED2RVAL(ev, GDK_TYPE_EVENT); + RBASIC(obj)->klass = gdkevents[ev->type]; /* hack */ + return obj; +} + +GdkEvent* +get_gdkevent(VALUE event) +{ + return NIL_P(event) ? NULL : RVAL2BOXED(event, GDK_TYPE_EVENT); +} + +/***********************************************/ +#define ATTR_STR(type, name)\ +static VALUE \ +gdkevent ## type ## _ ## name (VALUE self)\ +{\ + return CSTR2RVAL(get_gdkevent(self)->type.name);\ +}\ +static VALUE \ +gdkevent ## type ## _set_ ## name (VALUE self, VALUE val)\ +{\ + get_gdkevent(self)->type.name = (gchar *)RVAL2CSTR(val);\ + return self;\ +} + +#define ATTR_INT(type, name)\ +static VALUE \ +gdkevent ## type ## _ ## name (VALUE self)\ +{\ + return INT2NUM(get_gdkevent(self)->type.name);\ +}\ +static VALUE \ +gdkevent ## type ## _set_ ## name (VALUE self, VALUE val)\ +{\ + get_gdkevent(self)->type.name = NUM2INT(val);\ + return self;\ +} + +#define ATTR_UINT(type, name)\ +static VALUE \ +gdkevent ## type ## _ ## name (VALUE self)\ +{\ + return UINT2NUM(get_gdkevent(self)->type.name);\ +}\ +static VALUE \ +gdkevent ## type ## _set_ ## name (VALUE self, VALUE val)\ +{\ + get_gdkevent(self)->type.name = NUM2UINT(val);\ + return self;\ +} + +#define ATTR_GDKNATIVEWINDOW(type, name)\ +static VALUE \ +gdkevent ## type ## _ ## name (VALUE self)\ +{\ + return GDKNATIVEWINDOW2RVAL(get_gdkevent(self)->type.name);\ +}\ +static VALUE \ +gdkevent ## type ## _set_ ## name (VALUE self, VALUE val)\ +{\ + get_gdkevent(self)->type.name = RVAL2GDKNATIVEWINDOW(val);\ + return self;\ +} + +#define ATTR_FLOAT(type, name)\ +static VALUE \ +gdkevent ## type ## _ ## name (VALUE self)\ +{\ + return rb_float_new(get_gdkevent(self)->type.name);\ +}\ +static VALUE \ +gdkevent ## type ## _set_ ## name (VALUE self, VALUE val)\ +{\ + get_gdkevent(self)->type.name = NUM2DBL(val);\ + return self;\ +} + +#define ATTR_GOBJ(type, name)\ +static VALUE \ +gdkevent ## type ## _ ## name (VALUE self)\ +{\ + return GOBJ2RVAL(get_gdkevent(self)->type.name);\ +}\ +static VALUE \ +gdkevent ## type ## _set_ ## name (VALUE self, VALUE val)\ +{\ + GdkEvent *event;\ + event = get_gdkevent(self);\ + if (event->type.name)\ + g_object_unref(event->type.name);\ + event->type.name = RVAL2GOBJ(val);\ + if (event->type.name)\ + g_object_ref(event->type.name);\ + return self;\ +} + +#define ATTR_BOOL(type, name)\ +static VALUE \ +gdkevent ## type ## _ ## name (VALUE self)\ +{\ + return CBOOL2RVAL(get_gdkevent(self)->type.name);\ +}\ +static VALUE \ +gdkevent ## type ## _set_ ## name (VALUE self, VALUE val)\ +{\ + get_gdkevent(self)->type.name = RVAL2CBOOL(val);\ + return self;\ +} + +#define ATTR_ATOM(type, name)\ +static VALUE \ +gdkevent ## type ## _ ## name (VALUE self)\ +{\ + GdkAtom atom = get_gdkevent(self)->type.name;\ + return BOXED2RVAL(atom, GDK_TYPE_ATOM);\ +}\ +static VALUE \ +gdkevent ## type ## _set_ ## name (VALUE self, VALUE val)\ +{\ + get_gdkevent(self)->type.name = RVAL2ATOM(val);\ + return self;\ +} + +#define ATTR_FLAGS(type, name, gtype)\ +static VALUE \ +gdkevent ## type ## _ ## name (VALUE self)\ +{\ + return GFLAGS2RVAL(get_gdkevent(self)->type.name, gtype);\ +}\ +static VALUE \ +gdkevent ## type ## _set_ ## name (VALUE self, VALUE val)\ +{\ + get_gdkevent(self)->type.name = RVAL2GFLAGS(val, gtype);\ + return self;\ +} + +#define ATTR_ENUM(type, name, gtype)\ +static VALUE \ +gdkevent ## type ## _ ## name (VALUE self)\ +{\ + return GENUM2RVAL(get_gdkevent(self)->type.name, gtype);\ +}\ +static VALUE \ +gdkevent ## type ## _set_ ## name (VALUE self, VALUE val)\ +{\ + get_gdkevent(self)->type.name = RVAL2GENUM(val, gtype);\ + return self;\ +} + +#define ATTR_AXES(type, gdkklass) \ +static VALUE \ +gdkevent ##type ## _axes(VALUE self)\ +{\ + gdkklass type = get_gdkevent(self)->type;\ + return type.axes ? rb_ary_new3(2, \ + rb_float_new(type.axes[0]),\ + rb_float_new(type.axes[1])) : Qnil;\ +} \ +static VALUE \ +gdkevent ## type ## _set_axes(VALUE self, VALUE x, VALUE y)\ +{\ + gdkklass val = get_gdkevent(self)->type;\ + val.axes[0] = NUM2DBL(x);\ + val.axes[1] = NUM2DBL(y);\ + return self;\ +} + +#define DEFINE_ACCESSOR(event, type, name) \ + rb_define_method(event, G_STRINGIFY(name), gdkevent ## type ## _## name, 0);\ + rb_define_method(event, G_STRINGIFY(set_ ## name), gdkevent ## type ## _set_## name, 1); + + +/* initialize */ +#if GTK_CHECK_VERSION(2,2,0) +#define GDKEVENT_INIT(type, default_gtype) \ +static VALUE \ +gdkevent ## type ## _initialize(int argc, VALUE *argv, VALUE self)\ +{\ + VALUE type;\ + GdkEventType gtype;\ +\ + rb_scan_args(argc, argv, "01", &type);\ + if (NIL_P(type)){\ + gtype = default_gtype;\ + } else {\ + gtype = RVAL2GENUM(type, GDK_TYPE_EVENT_TYPE);\ + }\ +\ + G_INITIALIZE(self, gdk_event_new(gtype));\ + return Qnil;\ +} +#else +#define GDKEVENT_INIT(type, default_gtype) \ +static VALUE \ +gdkevent ## type ## _initialize(int argc, VALUE *argv, VALUE self)\ +{\ + rb_raise(rb_eRuntimeError, "Gdk::Event.new is not supported in this environment.");\ + return Qnil;\ +} +#endif + +#define DEFINE_INIT(event, type) \ + rb_define_method(event, "initialize", gdkevent ## type ## _initialize, -1); + +/***********************************************/ + +/* GdkEvent Singleton Methods */ +static VALUE +gdkevent_s_events_pending(G_GNUC_UNUSED VALUE self) +{ + return CBOOL2RVAL(gdk_events_pending()); +} + +static VALUE +gdkevent_s_peek(G_GNUC_UNUSED VALUE self) +{ + return make_gdkevent(gdk_event_peek()); +} + +static VALUE +gdkevent_s_get(G_GNUC_UNUSED VALUE self) +{ + return make_gdkevent(gdk_event_get()); +} + +static VALUE +gdkevent_s_get_graphics_expose(G_GNUC_UNUSED VALUE self, VALUE window) +{ + return make_gdkevent(gdk_event_get_graphics_expose(GDK_WINDOW(RVAL2GOBJ(window)))); +} + +/* GdkEvent */ +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +gdkevent_initialize(VALUE self, VALUE type) +{ + GdkEventType gtype = RVAL2GENUM(type, GDK_TYPE_EVENT_TYPE); + if (RBASIC(self)->klass != gdkevents[gtype]) + rb_raise(rb_eArgError, "Wrong event type for this class."); + + G_INITIALIZE(self, gdk_event_new(gtype)); + return Qnil; +} +#endif + +static VALUE +gdkevent_type(VALUE self) +{ + return GENUM2RVAL(get_gdkevent(self)->type, GDK_TYPE_EVENT_TYPE); +} + +static VALUE +gdkevent_put(VALUE self) +{ + gdk_event_put(get_gdkevent(self)); + return self; +} + +/* We don't need this. +gdk_event_get_time(); +gboolean gdk_event_get_state (GdkEvent *event, + GdkModifierType *state); +*/ + +static VALUE +gdkevent_get_axis(VALUE self, VALUE axis_use) +{ + gdouble value; + gboolean ret = gdk_event_get_axis(get_gdkevent(self), + RVAL2GENUM(axis_use, GDK_TYPE_AXIS_USE), &value); + return ret ? rb_float_new(value) : Qnil; +} + +static VALUE +gdkevent_get_coords(VALUE self) +{ + gdouble x_win, y_win; + gboolean ret = gdk_event_get_coords(get_gdkevent(self), &x_win, &y_win); + + return ret ? rb_ary_new3(2, rb_float_new(x_win), rb_float_new(y_win)) : Qnil; +} + +static VALUE +gdkevent_get_root_coords(VALUE self) +{ + gdouble x_root, y_root; + gboolean ret = gdk_event_get_root_coords(get_gdkevent(self), &x_root, &y_root); + + return ret ? rb_ary_new3(2, rb_float_new(x_root), rb_float_new(y_root)) : Qnil; +} + +static void +handler_func(GdkEvent *event, gpointer func) +{ + rb_funcall((VALUE)func, id_call, 1, make_gdkevent(event)); +} + +static VALUE +gdkevent_s_handler_set(VALUE self) +{ + volatile VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + + gdk_event_handler_set((GdkEventFunc)handler_func, (gpointer)func, NULL); + return self; +} + +static VALUE +gdkevent_s_get_show_events(G_GNUC_UNUSED VALUE self) +{ + return CBOOL2RVAL(gdk_get_show_events()); +} + +static VALUE +gdkevent_s_set_show_events(VALUE self, VALUE show_events) +{ + gdk_set_show_events(RVAL2CBOOL(show_events)); + return self; +} +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +gdkevent_set_screen(VALUE self, VALUE screen) +{ + gdk_event_set_screen(get_gdkevent(self), GDK_SCREEN(RVAL2GOBJ(screen))); + return self; +} + +static VALUE +gdkevent_screen(VALUE self) +{ + return GOBJ2RVAL(gdk_event_get_screen(get_gdkevent(self))); +} +#endif + +/* + type: String, Integer, Gdk::Color. + */ +static VALUE +gdkevent_s_setting_get(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE name, type; + GType gtype; + GValue val = G_VALUE_INIT; + gboolean ret; + VALUE value; + + rb_scan_args(argc, argv, "11", &name, &type); + if (NIL_P(type)) + gtype = G_TYPE_STRING; + else + gtype = CLASS2GTYPE(type); + + g_value_init(&val, gtype); + ret = gdk_setting_get(RVAL2CSTR(name), &val); + + value = ret ? GVAL2RVAL(&val) : Qnil; + g_value_unset(&val); + return value; +} + +/* GdkEventAny */ +ATTR_GOBJ(any, window); +ATTR_BOOL(any, send_event); + +/* GdkEventKey */ +ATTR_UINT(key, time); +ATTR_FLAGS(key, state, GDK_TYPE_MODIFIER_TYPE); +ATTR_INT(key, keyval); +ATTR_UINT(key, hardware_keycode); +ATTR_UINT(key, group); + +/* GdkEventButton */ +ATTR_UINT(button, time); +ATTR_FLOAT(button, x); +ATTR_FLOAT(button, y); +ATTR_AXES(button, GdkEventButton); +ATTR_INT(button, button); +ATTR_FLAGS(button, state, GDK_TYPE_MODIFIER_TYPE); +ATTR_GOBJ(button, device); +ATTR_FLOAT(button, x_root); +ATTR_FLOAT(button, y_root); + +/* GdkEventScroll */ +ATTR_UINT(scroll, time); +ATTR_FLOAT(scroll, x); +ATTR_FLOAT(scroll, y); +ATTR_FLAGS(scroll, state, GDK_TYPE_MODIFIER_TYPE); +ATTR_ENUM(scroll, direction, GDK_TYPE_SCROLL_DIRECTION); +ATTR_GOBJ(scroll, device); +ATTR_FLOAT(scroll, x_root); +ATTR_FLOAT(scroll, y_root); +GDKEVENT_INIT(scroll, GDK_SCROLL); + +/* GdkEventMotion */ +ATTR_UINT(motion, time); +ATTR_FLOAT(motion, x); +ATTR_FLOAT(motion, y); +ATTR_AXES(motion, GdkEventMotion); +ATTR_FLOAT(motion, x_root); +ATTR_FLOAT(motion, y_root); +ATTR_FLAGS(motion, state, GDK_TYPE_MODIFIER_TYPE); +ATTR_BOOL(motion, is_hint); +ATTR_GOBJ(motion, device); +GDKEVENT_INIT(motion, GDK_MOTION_NOTIFY); + +#if GTK_CHECK_VERSION(2, 12, 0) +static VALUE +gdkeventmotion_request_motions(VALUE self) +{ + gdk_event_request_motions(&(get_gdkevent(self)->motion)); + return self; +} +#endif + +/* GdkEventExpose */ +static VALUE +gdkeventexpose_area(VALUE self) +{ + return BOXED2RVAL(&get_gdkevent(self)->expose.area, GDK_TYPE_RECTANGLE); +} + +static VALUE +gdkeventexpose_set_area(VALUE self, VALUE rect) +{ + GdkRectangle* grect = (GdkRectangle*)RVAL2BOXED(rect, GDK_TYPE_RECTANGLE); + GdkEventExpose event = get_gdkevent(self)->expose; + event.area.x = grect->x; + event.area.y = grect->y; + event.area.width = grect->width; + event.area.height = grect->height; + return self; +} + +static VALUE +gdkeventexpose_region(VALUE self) +{ + return BOXED2RVAL(get_gdkevent(self)->expose.region, GDK_TYPE_REGION); +} +static VALUE +gdkeventexpose_set_region(VALUE self, VALUE region) +{ + get_gdkevent(self)->expose.region = RVAL2BOXED(region, GDK_TYPE_REGION); + return self; +} + +ATTR_INT(expose, count); +GDKEVENT_INIT(expose, GDK_EXPOSE); + +/* GdkEventVisibility */ +ATTR_ENUM(visibility, state, GDK_TYPE_VISIBILITY_STATE); +GDKEVENT_INIT(visibility, GDK_VISIBILITY_NOTIFY); + +/* GdkEventCrossing */ +ATTR_GOBJ(crossing, subwindow); +ATTR_UINT(crossing, time); +ATTR_INT(crossing, x); +ATTR_INT(crossing, y); +ATTR_FLOAT(crossing, x_root); +ATTR_FLOAT(crossing, y_root); +ATTR_ENUM(crossing, mode, GDK_TYPE_CROSSING_MODE); +ATTR_ENUM(crossing, detail, GDK_TYPE_NOTIFY_TYPE); +ATTR_BOOL(crossing, focus); +ATTR_FLAGS(crossing, state, GDK_TYPE_MODIFIER_TYPE); + +/* GdkEventFocus */ +ATTR_BOOL(focus_change, in); +GDKEVENT_INIT(focus_change, GDK_FOCUS_CHANGE); + +/* GdkEventConfigure */ +ATTR_INT(configure, x); +ATTR_INT(configure, y); +ATTR_INT(configure, width); +ATTR_INT(configure, height); +GDKEVENT_INIT(configure, GDK_CONFIGURE); + +/* GdkEventProperty */ +ATTR_ATOM(property, atom); +ATTR_UINT(property, time); +ATTR_ENUM(property, state, GDK_TYPE_PROPERTY_STATE); +GDKEVENT_INIT(property, GDK_PROPERTY_NOTIFY); + +/* GdkEventSelection */ +ATTR_ATOM(selection, selection); +ATTR_ATOM(selection, target); +ATTR_ATOM(selection, property); +ATTR_GDKNATIVEWINDOW(selection, requestor); +ATTR_INT(selection, time); + +/* GdkEventDND */ +ATTR_GOBJ(dnd, context); +ATTR_UINT(dnd, time); +ATTR_INT(dnd, x_root); +ATTR_INT(dnd, y_root); + +/* GdkEventProximity */ +ATTR_UINT(proximity, time); +ATTR_GOBJ(proximity, device); + +/* GdkEventClient */ +ATTR_ATOM(client, message_type); +GDKEVENT_INIT(client, GDK_CLIENT_EVENT); + +static VALUE +gdkeventclient_data_format(VALUE self) +{ + return INT2NUM(get_gdkevent(self)->client.data_format); +} + +static VALUE +gdkeventclient_data(VALUE self) +{ + int i; + VALUE ary = Qnil; + gushort format = get_gdkevent(self)->client.data_format; + + if (format == 8) { + ary = rb_ary_new2(20); + for (i = 0; i < 20; i++) + rb_ary_push(ary, INT2FIX(get_gdkevent(self)->client.data.b[i])); + } else if (format == 16) { + ary = rb_ary_new2(10); + for (i = 0; i<10; i++) + rb_ary_push(ary, INT2FIX(get_gdkevent(self)->client.data.s[i])); + } else if (format == 32){ + ary = rb_ary_new2(5); + for (i = 0; i < 5; i++) + rb_ary_push(ary, INT2NUM(get_gdkevent(self)->client.data.l[i])); + } else { + rb_warn("The format is not supported."); + } + return ary; +} + +static VALUE +gdkeventclient_send_client_message(int argc, VALUE *argv, VALUE self) +{ + VALUE xid, display; + rb_scan_args(argc, argv, "11", &xid, &display); + if (NIL_P(display)){ + return CBOOL2RVAL(gdk_event_send_client_message( + get_gdkevent(self), RVAL2GDKNATIVEWINDOW(xid))); + } else { +#if GTK_CHECK_VERSION(2,2,0) + return CBOOL2RVAL(gdk_event_send_client_message_for_display( + GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)), + get_gdkevent(self), + RVAL2GDKNATIVEWINDOW(xid))); +#else + rb_warn("this arguments number has been supported since 2.2"); + return Qfalse; +#endif + } +} + +static VALUE +gdkeventclient_send_clientmessage_toall(VALUE self) +{ + gdk_event_send_clientmessage_toall(get_gdkevent(self)); + return self; +} + +static GdkFilterReturn +filter_func(GdkXEvent *xevent, GdkEvent *event, gpointer func) +{ + VALUE ret = rb_funcall((VALUE)func, id_call, 2, LONG2NUM((glong)xevent), make_gdkevent(event)); + return RVAL2GENUM(ret, GDK_TYPE_FILTER_RETURN); +} + +static VALUE +gdkevent_s_add_client_message_filter(VALUE self, VALUE message_type) +{ + volatile VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gdk_add_client_message_filter(RVAL2ATOM(message_type), + (GdkFilterFunc)filter_func, (gpointer)func); + return self; +} + +/* GdkEventNoExpose */ +GDKEVENT_INIT(noexpose, GDK_NO_EXPOSE); + +/* GdkEventWindowState */ +ATTR_FLAGS(window_state, changed_mask, GDK_TYPE_WINDOW_STATE); +ATTR_FLAGS(window_state, new_window_state, GDK_TYPE_WINDOW_STATE); +GDKEVENT_INIT(window_state, GDK_WINDOW_STATE); + +/* GdkEventSetting */ +ATTR_ENUM(setting, action, GDK_TYPE_SETTING_ACTION); +ATTR_STR(setting, name); +GDKEVENT_INIT(setting, GDK_SETTING); + +/* GdkEventOwnerChange */ +#if GTK_CHECK_VERSION(2,6,0) +ATTR_GDKNATIVEWINDOW(owner_change, owner); +ATTR_ENUM(owner_change, reason, GDK_TYPE_OWNER_CHANGE); +ATTR_ATOM(owner_change, selection); +ATTR_UINT(owner_change, time); +ATTR_UINT(owner_change, selection_time); +GDKEVENT_INIT(owner_change, GDK_OWNER_CHANGE); +#endif + +/* GdkEventGrabBroken */ +#if GTK_CHECK_VERSION(2,8,0) +ATTR_BOOL(grab_broken, keyboard); +ATTR_BOOL(grab_broken, implicit); +ATTR_GOBJ(grab_broken, grab_window); +GDKEVENT_INIT(grab_broken, GDK_GRAB_BROKEN); +#endif + +/* MISC */ +static VALUE +gdkevent_g2r(const GValue *values) +{ + return make_gdkevent(g_value_get_boxed(&values[0])); +} + +void +Init_gtk_gdk_event(VALUE mGdk) +{ + VALUE ev; + VALUE gdkEvent; + VALUE gdkEventAny; + + gdkEvent = G_DEF_CLASS(GDK_TYPE_EVENT, "Event", mGdk); + gdkEventAny = rb_define_class_under(mGdk, "EventAny", gdkEvent); + + gdkevents[GDK_DELETE] = gdkEventAny; + gdkevents[GDK_DESTROY] = gdkEventAny; + gdkevents[GDK_EXPOSE] = rb_define_class_under(mGdk, "EventExpose", gdkEventAny); + gdkevents[GDK_MOTION_NOTIFY] = rb_define_class_under(mGdk, "EventMotion", gdkEventAny); + gdkevents[GDK_BUTTON_PRESS] = rb_define_class_under(mGdk, "EventButton", gdkEventAny); + gdkevents[GDK_2BUTTON_PRESS] = gdkevents[GDK_BUTTON_PRESS]; + gdkevents[GDK_3BUTTON_PRESS] = gdkevents[GDK_BUTTON_PRESS]; + gdkevents[GDK_BUTTON_RELEASE]= gdkevents[GDK_BUTTON_PRESS]; + gdkevents[GDK_KEY_PRESS] = rb_define_class_under(mGdk, "EventKey", gdkEventAny); + gdkevents[GDK_KEY_RELEASE] = gdkevents[GDK_KEY_PRESS]; + gdkevents[GDK_ENTER_NOTIFY] = rb_define_class_under(mGdk, "EventCrossing", gdkEventAny); + gdkevents[GDK_LEAVE_NOTIFY] = gdkevents[GDK_ENTER_NOTIFY]; + gdkevents[GDK_FOCUS_CHANGE] = rb_define_class_under(mGdk, "EventFocus", gdkEventAny); + gdkevents[GDK_CONFIGURE] = rb_define_class_under(mGdk, "EventConfigure", gdkEventAny); + gdkevents[GDK_MAP] = gdkEventAny; + gdkevents[GDK_UNMAP] = gdkEventAny; + gdkevents[GDK_PROPERTY_NOTIFY]= rb_define_class_under(mGdk, "EventProperty", gdkEventAny); + gdkevents[GDK_SELECTION_CLEAR]= rb_define_class_under(mGdk, "EventSelection", gdkEventAny); + gdkevents[GDK_SELECTION_REQUEST]= gdkevents[GDK_SELECTION_CLEAR]; + gdkevents[GDK_SELECTION_NOTIFY] = gdkevents[GDK_SELECTION_CLEAR]; + gdkevents[GDK_PROXIMITY_IN] = rb_define_class_under(mGdk, "EventProximity", gdkEventAny); + gdkevents[GDK_PROXIMITY_OUT] = gdkevents[GDK_PROXIMITY_IN]; + gdkevents[GDK_DRAG_ENTER] = rb_define_class_under(mGdk, "EventDND", gdkEventAny); + gdkevents[GDK_DRAG_LEAVE] = gdkevents[GDK_DRAG_ENTER]; + gdkevents[GDK_DRAG_MOTION] = gdkevents[GDK_DRAG_ENTER]; + gdkevents[GDK_DRAG_STATUS] = gdkevents[GDK_DRAG_ENTER]; + gdkevents[GDK_DROP_START] = gdkevents[GDK_DRAG_ENTER]; + gdkevents[GDK_DROP_FINISHED] = gdkevents[GDK_DRAG_ENTER]; + gdkevents[GDK_CLIENT_EVENT] = rb_define_class_under(mGdk, "EventClient", gdkEventAny); + gdkevents[GDK_VISIBILITY_NOTIFY] = rb_define_class_under(mGdk, "EventVisibility", gdkEventAny); + gdkevents[GDK_NO_EXPOSE] = rb_define_class_under(mGdk, "EventNoExpose", gdkEventAny); + gdkevents[GDK_SCROLL] = rb_define_class_under(mGdk, "EventScroll", gdkEventAny); + gdkevents[GDK_WINDOW_STATE] = rb_define_class_under(mGdk, "EventWindowState", gdkEventAny); + gdkevents[GDK_SETTING] = rb_define_class_under(mGdk, "EventSetting", gdkEventAny); +#if GTK_CHECK_VERSION(2,6,0) + gdkevents[GDK_OWNER_CHANGE] = rb_define_class_under(mGdk, "EventOwnerChange", gdkEventAny); +#endif +#if GTK_CHECK_VERSION(2,8,0) + gdkevents[GDK_GRAB_BROKEN] = rb_define_class_under(mGdk, "EventGrabBroken", gdkEventAny); +#endif + + /* GdkEvent */ +#if GTK_CHECK_VERSION(2,2,0) + rb_define_method(gdkEvent, "initialize", gdkevent_initialize, 1); +#endif + rb_define_method(gdkEvent, "event_type", gdkevent_type, 0); + + rb_define_singleton_method(gdkEvent, "events_pending?", gdkevent_s_events_pending, 0); + rb_define_singleton_method(gdkEvent, "peek", gdkevent_s_peek, 0); + rb_define_singleton_method(gdkEvent, "get", gdkevent_s_get, 0); + rb_define_method(gdkEvent, "put", gdkevent_put, 0); + rb_define_method(gdkEvent, "get_axis", gdkevent_get_axis, 1); + rb_define_method(gdkEvent, "coords", gdkevent_get_coords, 0); + rb_define_method(gdkEvent, "root_coords", gdkevent_get_root_coords, 0); + + rb_define_singleton_method(gdkEvent, "handler_set", gdkevent_s_handler_set, 0); + rb_define_singleton_method(gdkEvent, "show_events?", gdkevent_s_get_show_events, 0); + rb_define_singleton_method(gdkEvent, "set_show_events", gdkevent_s_set_show_events, 1); + rb_define_singleton_method(gdkEvent, "setting_get", gdkevent_s_setting_get, -1); + rb_define_singleton_method(gdkEvent, "add_client_message_filter", gdkevent_s_add_client_message_filter, 1); +#if GTK_CHECK_VERSION(2,2,0) + rb_define_method(gdkEvent, "screen", gdkevent_screen, 0); + rb_define_method(gdkEvent, "set_screen", gdkevent_set_screen, 1); +#endif + G_DEF_SETTERS(gdkEvent); + + /* GdkEventAny */ + DEFINE_ACCESSOR(gdkEventAny, any, window); + rb_define_method(gdkEventAny, "send_event?", gdkeventany_send_event, 0); + rb_define_method(gdkEventAny, "set_send_event", gdkeventany_set_send_event, 1); + G_DEF_SETTERS(gdkEventAny); + + /* GdkEventKey */ + ev = gdkevents[GDK_KEY_PRESS]; + DEFINE_ACCESSOR(ev, key, time); + DEFINE_ACCESSOR(ev, key, state); + DEFINE_ACCESSOR(ev, key, keyval); + DEFINE_ACCESSOR(ev, key, hardware_keycode); + DEFINE_ACCESSOR(ev, key, group); + G_DEF_SETTERS(ev); + + /* GdkEventButton */ + ev = gdkevents[GDK_BUTTON_PRESS]; + DEFINE_ACCESSOR(ev, button, time); + DEFINE_ACCESSOR(ev, button, x); + DEFINE_ACCESSOR(ev, button, y); + rb_define_method(ev, "axes", gdkeventbutton_axes, 0); + rb_define_method(ev, "set_axes", gdkeventbutton_set_axes, 2); + DEFINE_ACCESSOR(ev, button, state); + DEFINE_ACCESSOR(ev, button, button); + DEFINE_ACCESSOR(ev, button, device); + DEFINE_ACCESSOR(ev, button, x_root); + DEFINE_ACCESSOR(ev, button, y_root); + G_DEF_SETTERS(ev); + + /* GdkEventScroll */ + ev = gdkevents[GDK_SCROLL]; + DEFINE_ACCESSOR(ev, scroll, time); + DEFINE_ACCESSOR(ev, scroll, x); + DEFINE_ACCESSOR(ev, scroll, y); + DEFINE_ACCESSOR(ev, scroll, state); + DEFINE_ACCESSOR(ev, scroll, direction); + DEFINE_ACCESSOR(ev, scroll, device); + DEFINE_ACCESSOR(ev, scroll, x_root); + DEFINE_ACCESSOR(ev, scroll, y_root); + DEFINE_INIT(ev, scroll); + G_DEF_SETTERS(ev); + + /* GdkScrollDirection */ + G_DEF_CLASS(GDK_TYPE_SCROLL_DIRECTION, "Direction", ev); + G_DEF_CONSTANTS(ev, GDK_TYPE_SCROLL_DIRECTION, "GDK_SCROLL_"); + + /* GdkEventMotion */ + ev = gdkevents[GDK_MOTION_NOTIFY]; + DEFINE_ACCESSOR(ev, motion, time); + DEFINE_ACCESSOR(ev, motion, x); + DEFINE_ACCESSOR(ev, motion, y); + rb_define_method(ev, "axes", gdkeventmotion_axes, 0); + rb_define_method(ev, "set_axes", gdkeventmotion_set_axes, 1); + DEFINE_ACCESSOR(ev, motion, state); + rb_define_method(ev, "hint?", gdkeventmotion_is_hint, 0); + rb_define_method(ev, "set_hint", gdkeventmotion_set_is_hint, 1); + DEFINE_ACCESSOR(ev, motion, device); + DEFINE_ACCESSOR(ev, motion, x_root); + DEFINE_ACCESSOR(ev, motion, y_root); + DEFINE_INIT(ev, motion); +#if GTK_CHECK_VERSION(2, 12, 0) + rb_define_method(ev, "request", gdkeventmotion_request_motions, 0); +#endif + G_DEF_SETTERS(ev); + + /* GdkEventExpose */ + ev = gdkevents[GDK_EXPOSE]; + DEFINE_ACCESSOR(ev, expose, area); + DEFINE_ACCESSOR(ev, expose, region); + DEFINE_ACCESSOR(ev, expose, count); + DEFINE_INIT(ev, expose); + rb_define_singleton_method(ev, "get_graphics_expose", + gdkevent_s_get_graphics_expose, 1); + G_DEF_SETTERS(ev); + + /* GdkEventVisibility */ + ev = gdkevents[GDK_VISIBILITY_NOTIFY]; + DEFINE_ACCESSOR(ev, visibility, state); + DEFINE_INIT(ev, visibility); + G_DEF_SETTERS(ev); + + /* GdkVisibilityState */ + G_DEF_CLASS(GDK_TYPE_VISIBILITY_STATE, "State", ev); + G_DEF_CONSTANTS(ev, GDK_TYPE_VISIBILITY_STATE, "GDK_VISIBILITY_"); + + /* GdkEventCrossing */ + ev = gdkevents[GDK_ENTER_NOTIFY]; + DEFINE_ACCESSOR(ev, crossing, subwindow); + DEFINE_ACCESSOR(ev, crossing, time); + DEFINE_ACCESSOR(ev, crossing, x); + DEFINE_ACCESSOR(ev, crossing, y); + DEFINE_ACCESSOR(ev, crossing, x_root); + DEFINE_ACCESSOR(ev, crossing, y_root); + DEFINE_ACCESSOR(ev, crossing, mode); + DEFINE_ACCESSOR(ev, crossing, detail); + rb_define_method(ev, "focus?", gdkeventcrossing_focus, 0); + rb_define_method(ev, "set_focus", gdkeventcrossing_set_focus, 1); + DEFINE_ACCESSOR(ev, crossing, state); + G_DEF_SETTERS(ev); + + /* GdkCrossingMode */ + G_DEF_CLASS(GDK_TYPE_CROSSING_MODE, "Mode", ev); + G_DEF_CONSTANTS(ev, GDK_TYPE_CROSSING_MODE, "GDK_CROSSING_"); + /* GdkNotifyType */ + G_DEF_CLASS(GDK_TYPE_NOTIFY_TYPE, "NotifyType", ev); + G_DEF_CONSTANTS(ev, GDK_TYPE_NOTIFY_TYPE, "GDK_"); + + /* GdkEventFocus */ + ev = gdkevents[GDK_FOCUS_CHANGE]; + rb_define_method(ev, "in?", gdkeventfocus_change_in, 0); + rb_define_method(ev, "set_in", gdkeventfocus_change_set_in, 1); + DEFINE_INIT(ev, focus_change); + G_DEF_SETTERS(ev); + + /* GdkEventConfigure */ + ev = gdkevents[GDK_CONFIGURE]; + DEFINE_ACCESSOR(ev, configure, x); + DEFINE_ACCESSOR(ev, configure, y); + DEFINE_ACCESSOR(ev, configure, width); + DEFINE_ACCESSOR(ev, configure, height); + DEFINE_INIT(ev, configure); + G_DEF_SETTERS(ev); + + /* GdkEventProperty */ + ev = gdkevents[GDK_PROPERTY_NOTIFY]; + DEFINE_ACCESSOR(ev, property, atom); + DEFINE_ACCESSOR(ev, property, time); + DEFINE_ACCESSOR(ev, property, state); + DEFINE_INIT(ev, property); + G_DEF_SETTERS(ev); + + /* GdkPropertyState */ + G_DEF_CLASS(GDK_TYPE_PROPERTY_STATE, "State", ev); + G_DEF_CONSTANTS(ev, GDK_TYPE_PROPERTY_STATE, "GDK_"); + + /* GdkEventSelection */ + ev = gdkevents[GDK_SELECTION_CLEAR]; + DEFINE_ACCESSOR(ev, selection, selection); + DEFINE_ACCESSOR(ev, selection, target); + DEFINE_ACCESSOR(ev, selection, property); + DEFINE_ACCESSOR(ev, selection, requestor); + DEFINE_ACCESSOR(ev, selection, time); + G_DEF_SETTERS(ev); + + /* GdkEventDND */ + ev = gdkevents[GDK_DRAG_ENTER]; + DEFINE_ACCESSOR(ev, dnd, context); + DEFINE_ACCESSOR(ev, dnd, time); + DEFINE_ACCESSOR(ev, dnd, x_root); + DEFINE_ACCESSOR(ev, dnd, y_root); + G_DEF_SETTERS(ev); + + /* GdkEventProximity */ + ev = gdkevents[GDK_PROXIMITY_IN]; + DEFINE_ACCESSOR(ev, proximity, time); + DEFINE_ACCESSOR(ev, proximity, device); + G_DEF_SETTERS(ev); + + /* GdkEventClient */ + ev = gdkevents[GDK_CLIENT_EVENT]; + DEFINE_ACCESSOR(ev, client, message_type); + rb_define_method(ev, "data_format", gdkeventclient_data_format, 0); + rb_define_method(ev, "data", gdkeventclient_data, 0); + rb_define_method(ev, "send_client_message", + gdkeventclient_send_client_message, -1); + rb_define_method(ev, "send_clientmessage_toall", + gdkeventclient_send_clientmessage_toall, 0); + DEFINE_INIT(ev, client); + G_DEF_SETTERS(ev); + + /* GdkEventNoExpose */ + ev = gdkevents[GDK_NO_EXPOSE]; + DEFINE_INIT(ev, noexpose); + + /* GdkEventWindowState */ + ev = gdkevents[GDK_WINDOW_STATE]; + DEFINE_ACCESSOR(ev, window_state, changed_mask); + DEFINE_ACCESSOR(ev, window_state, new_window_state); + DEFINE_INIT(ev, window_state); + G_DEF_SETTERS(ev); + + /* GdkWindowState */ + G_DEF_CLASS(GDK_TYPE_WINDOW_STATE, "WindowState", ev); + G_DEF_CONSTANTS(ev, GDK_TYPE_WINDOW_STATE, "GDK_WINDOW_STATE_"); + + /* GdkEventSetting */ + ev = gdkevents[GDK_SETTING]; + DEFINE_ACCESSOR(ev, setting, action); + DEFINE_ACCESSOR(ev, setting, name); + DEFINE_INIT(ev, setting); + G_DEF_SETTERS(ev); + + /* GdkSettingAction */ + G_DEF_CLASS(GDK_TYPE_SETTING_ACTION, "Action", ev); + G_DEF_CONSTANTS(ev, GDK_TYPE_SETTING_ACTION, "GDK_SETTING_"); + +#if GTK_CHECK_VERSION(2,6,0) + /* GdkEventOwnerChange */ + ev = gdkevents[GDK_OWNER_CHANGE]; + DEFINE_ACCESSOR(ev, owner_change, owner); + DEFINE_ACCESSOR(ev, owner_change, reason); + DEFINE_ACCESSOR(ev, owner_change, selection); + DEFINE_ACCESSOR(ev, owner_change, time); + DEFINE_ACCESSOR(ev, owner_change, selection_time); + G_DEF_SETTERS(ev); + DEFINE_INIT(ev, owner_change); + + /* GdkOwnerChange */ + G_DEF_CLASS(GDK_TYPE_OWNER_CHANGE, "OwnerChange", ev); + G_DEF_CONSTANTS(ev, GDK_TYPE_OWNER_CHANGE, "GDK_OWNER_CHANGE_"); +#endif + +#if GTK_CHECK_VERSION(2,8,0) + /* GdkEventGrabBroken */ + ev = gdkevents[GDK_GRAB_BROKEN]; + rb_define_method(ev, "keyboard?", gdkeventgrab_broken_keyboard, 0); + rb_define_method(ev, "set_keyboard", gdkeventgrab_broken_set_keyboard, 1); + rb_define_method(ev, "implicit?", gdkeventgrab_broken_implicit, 0); + rb_define_method(ev, "set_implicit", gdkeventgrab_broken_set_implicit, 1); + DEFINE_ACCESSOR(ev, grab_broken, grab_window); + DEFINE_INIT(ev, grab_broken); + G_DEF_SETTERS(ev); +#endif + + rbgobj_register_g2r_func(GDK_TYPE_EVENT, &gdkevent_g2r); + + /* + * GdkEvent's Constants + */ + rb_define_const(gdkEvent, "CURRENT_TIME", INT2FIX(GDK_CURRENT_TIME)); + rb_define_const(gdkEvent, "PRIORITY_EVENTS", INT2FIX(GDK_PRIORITY_EVENTS)); + rb_define_const(gdkEvent, "PRIORITY_REDRAW", INT2FIX(GDK_PRIORITY_REDRAW)); + + /* GdkEventType */ + /* XXX */ + G_RENAME_CONSTANT("2BUTTON_PRESS","BUTTON2_PRESS"); + G_RENAME_CONSTANT("3BUTTON_PRESS","BUTTON3_PRESS"); + G_DEF_CLASS(GDK_TYPE_EVENT_TYPE, "Type", gdkEvent); + G_RENAME_CONSTANT("2BUTTON_PRESS","BUTTON2_PRESS"); + G_RENAME_CONSTANT("3BUTTON_PRESS","BUTTON3_PRESS"); + G_DEF_CONSTANTS(gdkEvent, GDK_TYPE_EVENT_TYPE, "GDK_"); + + /* GdkEventMask */ + G_DEF_CLASS(GDK_TYPE_EVENT_MASK, "Mask", gdkEvent); + G_DEF_CONSTANTS(gdkEvent, GDK_TYPE_EVENT_MASK, "GDK_"); + +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkgc.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkgc.c new file mode 100644 index 0000000..85f0181 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkgc.c @@ -0,0 +1,428 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * Copyright (C) 2001 Neil Conway + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cGC +#define _SELF(s) (GDK_GC(RVAL2GOBJ(s))) + +static VALUE RG_TARGET_NAMESPACE; +static VALUE gdkDrawable; + +static VALUE +rg_initialize(VALUE self, VALUE win) +{ + G_INITIALIZE(self, gdk_gc_new(GDK_DRAWABLE(RVAL2GOBJ(win)))); + return Qnil; +} + +/* we don't need them. +GdkGC* gdk_gc_new_with_values (GdkDrawable *drawable, + GdkGCValues *values, + GdkGCValuesMask values_mask); +void gdk_gc_set_values (GdkGC *gc, + GdkGCValues *values, + GdkGCValuesMask values_mask); +void gdk_gc_get_values (GdkGC *gc, + GdkGCValues *values); +*/ + +static VALUE +rg_set_foreground(VALUE self, VALUE color) +{ + gdk_gc_set_foreground(_SELF(self), RVAL2GDKCOLOR(color)); + return self; +} + +static VALUE +rg_set_background(VALUE self, VALUE color) +{ + gdk_gc_set_background(_SELF(self), RVAL2GDKCOLOR(color)); + return self; +} + +static VALUE +rg_set_rgb_fg_color(VALUE self, VALUE color) +{ + gdk_gc_set_rgb_fg_color(_SELF(self), RVAL2GDKCOLOR(color)); + return self; +} + +static VALUE +rg_set_rgb_bg_color(VALUE self, VALUE color) +{ + gdk_gc_set_rgb_bg_color(_SELF(self), RVAL2GDKCOLOR(color)); + return self; +} + +static VALUE +rg_set_function(VALUE self, VALUE func) +{ + GdkFunction f; + f = (GdkFunction)(RVAL2GENUM(func, GDK_TYPE_FUNCTION)); + if (f > GDK_SET) + rb_raise(rb_eArgError, "function out of range"); + + gdk_gc_set_function(_SELF(self), f); + return self; +} + +static VALUE +rg_set_fill(VALUE self, VALUE fill) +{ + gdk_gc_set_fill(_SELF(self), RVAL2GENUM(fill, GDK_TYPE_FILL)); + return self; +} + +static VALUE +rg_set_tile(VALUE self, VALUE tile) +{ + gdk_gc_set_tile(_SELF(self), GDK_PIXMAP(RVAL2GOBJ(tile))); + return self; +} + +static VALUE +rg_set_stipple(VALUE self, VALUE stipple) +{ + gdk_gc_set_stipple(_SELF(self), GDK_PIXMAP(RVAL2GOBJ(stipple))); + return self; +} + +static VALUE +rg_set_ts_origin(VALUE self, VALUE x, VALUE y) +{ + gdk_gc_set_ts_origin(_SELF(self), NUM2INT(x), NUM2INT(y)); + return self; +} + +static VALUE +rg_set_clip_origin(VALUE self, VALUE x, VALUE y) +{ + gdk_gc_set_clip_origin(_SELF(self), NUM2INT(x), NUM2INT(y)); + return self; +} + +static VALUE +rg_set_clip_mask(VALUE self, VALUE mask) +{ + gdk_gc_set_clip_mask(_SELF(self), GDK_BITMAP(RVAL2GOBJ(mask))); + return self; +} + +static VALUE +rg_set_clip_rectangle(VALUE self, VALUE rectangle) +{ + gdk_gc_set_clip_rectangle(_SELF(self), + (GdkRectangle*)RVAL2BOXED(rectangle, GDK_TYPE_RECTANGLE)); + return self; +} + +static VALUE +rg_set_clip_region(VALUE self, VALUE region) +{ + gdk_gc_set_clip_region(_SELF(self), + (GdkRegion*)RVAL2BOXED(region, GDK_TYPE_REGION)); + return self; +} + +static VALUE +rg_set_subwindow_mode(VALUE self, VALUE mode) +{ + gdk_gc_set_subwindow(_SELF(self), RVAL2GENUM(mode, GDK_TYPE_SUBWINDOW_MODE)); + return self; +} + +static VALUE +rg_set_exposures(VALUE self, VALUE exposures) +{ + gdk_gc_set_exposures(_SELF(self), RVAL2CBOOL(exposures)); + return self; +} + +static VALUE +rg_set_line_attributes(VALUE self, VALUE line_width, VALUE line_style, VALUE cap_style, VALUE join_style) +{ + gdk_gc_set_line_attributes(_SELF(self), NUM2INT(line_width), + RVAL2GENUM(line_style, GDK_TYPE_LINE_STYLE), + RVAL2GENUM(cap_style, GDK_TYPE_CAP_STYLE), + RVAL2GENUM(join_style, GDK_TYPE_JOIN_STYLE)); + return self; +} + +static VALUE +rg_set_dashes(VALUE self, VALUE rbdash_offset, VALUE rbdash_list) +{ + GdkGC *gc = _SELF(self); + gint dash_offset = NUM2INT(rbdash_offset); + long n; + gint8 *dash_list = RVAL2GINT8S(rbdash_list, n); + + gdk_gc_set_dashes(gc, dash_offset, dash_list, n); + + g_free(dash_list); + + return self; +} + +static VALUE +rg_copy(VALUE self, VALUE dst) +{ + if (RVAL2CBOOL(rb_obj_is_kind_of(dst, gdkDrawable))) { + VALUE args[1]; + args[0] = dst; + dst = rb_class_new_instance(1, args, RG_TARGET_NAMESPACE); + } + gdk_gc_copy(_SELF(dst), _SELF(self)); + return dst; +} + +static VALUE +rg_set_colormap(VALUE self, VALUE colormap) +{ + gdk_gc_set_colormap(_SELF(self), GDK_COLORMAP(RVAL2GOBJ(colormap))); + return self; +} + +static VALUE +rg_foreground(VALUE self) +{ + GdkGCValues val; + gdk_gc_get_values(_SELF(self), &val); + + return BOXED2RVAL(&val.foreground, GDK_TYPE_COLOR); +} + +static VALUE +rg_background(VALUE self) +{ + GdkGCValues val; + gdk_gc_get_values(_SELF(self), &val); + + return BOXED2RVAL(&val.background, GDK_TYPE_COLOR); +} + +static VALUE +rg_function(VALUE self) +{ + GdkGCValues val; + gdk_gc_get_values(_SELF(self), &val); + + return GENUM2RVAL(val.function, GDK_TYPE_FUNCTION); +} + +static VALUE +rg_fill(VALUE self) +{ + GdkGCValues val; + gdk_gc_get_values(_SELF(self), &val); + + return GENUM2RVAL(val.fill, GDK_TYPE_FILL); +} + +static VALUE +rg_tile(VALUE self) +{ + GdkGCValues val; + gdk_gc_get_values(_SELF(self), &val); + + return GOBJ2RVAL(val.tile); +} + +static VALUE +rg_stipple(VALUE self) +{ + GdkGCValues val; + gdk_gc_get_values(_SELF(self), &val); + + return GOBJ2RVAL(val.stipple); +} + +static VALUE +rg_ts_origin(VALUE self) +{ + GdkGCValues val; + gdk_gc_get_values(_SELF(self), &val); + + return rb_ary_new3(2, INT2NUM(val.ts_x_origin), + INT2NUM(val.ts_y_origin)); +} + +static VALUE +rg_clip_origin(VALUE self) +{ + GdkGCValues val; + gdk_gc_get_values(_SELF(self), &val); + + return rb_ary_new3(2, INT2NUM(val.clip_x_origin), + INT2NUM(val.clip_y_origin)); +} + +static VALUE +rg_clip_mask(VALUE self) +{ + GdkGCValues val; + gdk_gc_get_values(_SELF(self), &val); + + return GOBJ2RVAL(val.clip_mask); +} + +static VALUE +rg_subwindow_mode(VALUE self) +{ + GdkGCValues val; + gdk_gc_get_values(_SELF(self), &val); + + return GENUM2RVAL(val.subwindow_mode, GDK_TYPE_SUBWINDOW_MODE); +} + +static VALUE +rg_exposures_p(VALUE self) +{ + GdkGCValues val; + gdk_gc_get_values(_SELF(self), &val); + + return CBOOL2RVAL(val.graphics_exposures); +} + +static VALUE +rg_line_attributes(VALUE self) +{ + GdkGCValues val; + gdk_gc_get_values(_SELF(self), &val); + + return rb_ary_new3(4, INT2NUM(val.line_width), + GENUM2RVAL(val.line_style, GDK_TYPE_LINE_STYLE), + GENUM2RVAL(val.cap_style, GDK_TYPE_CAP_STYLE), + GENUM2RVAL(val.join_style, GDK_TYPE_JOIN_STYLE)); +} + +static VALUE +rg_colormap(VALUE self) +{ + return GOBJ2RVAL(gdk_gc_get_colormap(_SELF(self))); +} + +static VALUE +rg_offset(VALUE self, VALUE x, VALUE y) +{ + gdk_gc_offset(_SELF(self), NUM2INT(x), NUM2INT(y)); + return self; +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_screen(VALUE self) +{ + return GOBJ2RVAL(gdk_gc_get_screen(_SELF(self))); +} +#endif + +void +Init_gtk_gdk_gc(VALUE mGdk) +{ + RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_GC, "GC", mGdk); + gdkDrawable = rb_const_get(mGdk, rb_intern("Drawable")); + + rbgobj_add_abstract_but_create_instance_class(GDK_TYPE_GC); + + RG_DEF_METHOD(initialize, 1); + RG_DEF_METHOD(set_foreground, 1); + RG_DEF_METHOD(set_background, 1); + RG_DEF_METHOD(set_rgb_fg_color, 1); + RG_DEF_METHOD(set_rgb_bg_color, 1); + RG_DEF_METHOD(set_function, 1); + RG_DEF_METHOD(set_fill, 1); + RG_DEF_METHOD(set_tile, 1); + RG_DEF_METHOD(set_stipple, 1); + RG_DEF_METHOD(set_ts_origin, 2); + RG_DEF_METHOD(set_clip_origin, 2); + RG_DEF_METHOD(set_clip_mask, 1); + RG_DEF_METHOD(set_clip_rectangle, 1); + RG_DEF_METHOD(set_clip_region, 1); + RG_DEF_METHOD(set_subwindow_mode, 1); + RG_DEF_METHOD(set_exposures, 1); + RG_DEF_METHOD(set_line_attributes, 4); + RG_DEF_METHOD(set_dashes, 2); + RG_DEF_METHOD(copy, 1); + RG_DEF_METHOD(set_colormap, 1); + + RG_DEF_METHOD(foreground, 0); + RG_DEF_METHOD(background, 0); + RG_DEF_METHOD(function, 0); + RG_DEF_METHOD(fill, 0); + RG_DEF_METHOD(tile, 0); + RG_DEF_METHOD(stipple, 0); + RG_DEF_METHOD(ts_origin, 0); + RG_DEF_METHOD(clip_origin, 0); + RG_DEF_METHOD(clip_mask, 0); + RG_DEF_METHOD(subwindow_mode, 0); + RG_DEF_METHOD_P(exposures, 0); + RG_DEF_METHOD(line_attributes, 0); + + RG_DEF_METHOD(colormap, 0); + RG_DEF_METHOD(offset, 2); + +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(screen, 0); +#endif + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + + /* GdkGCValuesMask */ +/* Don't need them. + G_DEF_CLASS(GDK_TYPE_GC_VALUES_MASK, "ValuesMask", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_GC_VALUES_MASK, "GDK_GC_"); +*/ + + /* GdkFunction */ + G_DEF_CLASS(GDK_TYPE_FUNCTION, "Function", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_FUNCTION, "GDK_"); + + /* GdkFill */ + G_DEF_CLASS(GDK_TYPE_FILL, "Fill", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_FILL, "GDK_"); + + /* GdkSubwindowMode */ + G_DEF_CLASS(GDK_TYPE_SUBWINDOW_MODE, "SubWindowMode", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_SUBWINDOW_MODE, "GDK_"); + + /* GdkLineStyle */ + G_DEF_CLASS(GDK_TYPE_LINE_STYLE, "LineStyle", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_LINE_STYLE, "GDK_"); + + /* GdkCapStyle */ + G_DEF_CLASS(GDK_TYPE_CAP_STYLE, "CapStyle", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_CAP_STYLE, "GDK_"); + + /* GdkJoinStyle */ + G_DEF_CLASS(GDK_TYPE_JOIN_STYLE, "JoinStyle", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_JOIN_STYLE, "GDK_"); + +#ifdef GDK_WINDOWING_X11 + G_DEF_CLASS3("GdkGCX11", "GCX11", mGdk); +#elif defined(GDK_WINDOWING_WIN32) + G_DEF_CLASS3("GdkGCWin32", "GCWin32", mGdk); +#elif defined(GDK_WINDOWING_FB) + G_DEF_CLASS3("GdkGCFB", "GCFB", mGdk); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkgeometry.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkgeometry.c new file mode 100644 index 0000000..bba7be1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkgeometry.c @@ -0,0 +1,256 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +/*****************************************/ +static GdkGeometry* +geo_copy(const GdkGeometry* geo) +{ + GdkGeometry* new_geo; + g_return_val_if_fail (geo != NULL, NULL); + new_geo = g_new(GdkGeometry, 1); + *new_geo = *geo; + return new_geo; +} + +GType +gdk_geometry_get_type(void) +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static ("GdkGeometry", + (GBoxedCopyFunc)geo_copy, + (GBoxedFreeFunc)g_free); + return our_type; +} +/*****************************************/ + +#define RG_TARGET_NAMESPACE cGeometry +#define _SELF(g) ((GdkGeometry*)RVAL2BOXED(g, GDK_TYPE_GEOMETRY)) + +static VALUE +rg_initialize(VALUE self) +{ + GdkGeometry geometry; + memset(&geometry, 0, sizeof(GdkGeometry)); + G_INITIALIZE(self, g_boxed_copy(GDK_TYPE_GEOMETRY, &geometry)); + return Qnil; +} + +static VALUE +rg_set(VALUE self, VALUE min_width, VALUE min_height, VALUE max_width, VALUE max_height, VALUE base_width, VALUE base_height, VALUE width_inc, VALUE height_inc, VALUE min_aspect, VALUE max_aspect, VALUE gravity) +{ + GdkGeometry *geo = _SELF(self); + geo->min_width = NUM2INT(min_width); + geo->min_height = NUM2INT(min_height); + geo->max_width = NUM2INT(max_width); + geo->max_height = NUM2INT(max_height); + geo->base_width = NUM2INT(base_width); + geo->base_height = NUM2INT(base_height); + geo->width_inc = NUM2INT(width_inc); + geo->height_inc = NUM2INT(height_inc); + geo->min_aspect = NUM2DBL(min_aspect); + geo->max_aspect = NUM2DBL(max_aspect); + geo->win_gravity = RVAL2GENUM(gravity, GDK_TYPE_GRAVITY); + + return self; +} + +static VALUE +rg_min_width(VALUE self) +{ + return INT2NUM(_SELF(self)->min_width); +} + +static VALUE +rg_min_height(VALUE self) +{ + return INT2NUM(_SELF(self)->min_height); +} + +static VALUE +rg_max_width(VALUE self) +{ + return INT2NUM(_SELF(self)->max_width); +} + +static VALUE +rg_max_height(VALUE self) +{ + return INT2NUM(_SELF(self)->max_height); +} + +static VALUE +rg_base_width(VALUE self) +{ + return INT2NUM(_SELF(self)->base_width); +} + +static VALUE +rg_base_height(VALUE self) +{ + return INT2NUM(_SELF(self)->base_height); +} + +static VALUE +rg_width_inc(VALUE self) +{ + return INT2NUM(_SELF(self)->width_inc); +} + +static VALUE +rg_height_inc(VALUE self) +{ + return INT2NUM(_SELF(self)->height_inc); +} + +static VALUE +rg_min_aspect(VALUE self) +{ + return rb_float_new(_SELF(self)->min_aspect); +} + +static VALUE +rg_max_aspect(VALUE self) +{ + return rb_float_new(_SELF(self)->max_aspect); +} + +static VALUE +rg_win_gravity(VALUE self) +{ + return GENUM2RVAL(_SELF(self)->win_gravity, GDK_TYPE_GRAVITY); +} + +static VALUE +rg_set_min_width(VALUE self, VALUE min_width) +{ + _SELF(self)->min_width = NUM2INT(min_width); + return self; +} + +static VALUE +rg_set_min_height(VALUE self, VALUE min_height) +{ + _SELF(self)->min_height = NUM2INT(min_height); + return self; +} + +static VALUE +rg_set_max_width(VALUE self, VALUE max_width) +{ + _SELF(self)->max_width = NUM2INT(max_width); + return self; +} + +static VALUE +rg_set_max_height(VALUE self, VALUE max_height) +{ + _SELF(self)->max_height = NUM2INT(max_height); + return self; +} + +static VALUE +rg_set_base_width(VALUE self, VALUE base_width) +{ + _SELF(self)->base_width = NUM2INT(base_width); + return self; +} + +static VALUE +rg_set_base_height(VALUE self, VALUE base_height) +{ + _SELF(self)->base_height = NUM2INT(base_height); + return self; +} + +static VALUE +rg_set_width_inc(VALUE self, VALUE width_inc) +{ + _SELF(self)->width_inc = NUM2INT(width_inc); + return self; +} + +static VALUE +rg_set_height_inc(VALUE self, VALUE height_inc) +{ + _SELF(self)->height_inc = NUM2INT(height_inc); + return self; +} + +static VALUE +rg_set_min_aspect(VALUE self, VALUE min_aspect) +{ + _SELF(self)->min_aspect = NUM2DBL(min_aspect); + return self; +} + +static VALUE +rg_set_max_aspect(VALUE self, VALUE max_aspect) +{ + _SELF(self)->max_aspect = NUM2DBL(max_aspect); + return self; +} + +static VALUE +rg_set_win_gravity(VALUE self, VALUE gravity) +{ + _SELF(self)->win_gravity = RVAL2GENUM(gravity, GDK_TYPE_GRAVITY); + return self; +} + +void +Init_gtk_gdk_geometry(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_GEOMETRY, "Geometry", mGdk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(min_width, 0); + RG_DEF_METHOD(min_height, 0); + RG_DEF_METHOD(max_width, 0); + RG_DEF_METHOD(max_height, 0); + RG_DEF_METHOD(base_width, 0); + RG_DEF_METHOD(base_height, 0); + RG_DEF_METHOD(width_inc, 0); + RG_DEF_METHOD(height_inc, 0); + RG_DEF_METHOD(min_aspect, 0); + RG_DEF_METHOD(max_aspect, 0); + RG_DEF_METHOD(win_gravity, 0); + RG_DEF_METHOD(set, 11); + RG_DEF_METHOD(set_min_width, 1); + RG_DEF_METHOD(set_min_height, 1); + RG_DEF_METHOD(set_max_width, 1); + RG_DEF_METHOD(set_max_height, 1); + RG_DEF_METHOD(set_base_width, 1); + RG_DEF_METHOD(set_base_height, 1); + RG_DEF_METHOD(set_width_inc, 1); + RG_DEF_METHOD(set_height_inc, 1); + RG_DEF_METHOD(set_min_aspect, 1); + RG_DEF_METHOD(set_max_aspect, 1); + RG_DEF_METHOD(set_win_gravity, 1); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkimage.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkimage.c new file mode 100644 index 0000000..b10dcc0 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkimage.c @@ -0,0 +1,152 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cImage +#define _SELF(i) GDK_IMAGE(RVAL2GOBJ(i)) + +static VALUE +rg_initialize(VALUE self, VALUE type, VALUE visual, VALUE w, VALUE h) +{ + GdkImage* image = gdk_image_new((GdkImageType)RVAL2GENUM(type, GDK_TYPE_IMAGE_TYPE), + GDK_VISUAL(RVAL2GOBJ(visual)), + NUM2INT(w), NUM2INT(h)); + + if (image) + G_INITIALIZE(self, image); + else + rb_raise(rb_eArgError, "The image could not be created."); + + return Qnil; +} + +static VALUE +rg_colormap(VALUE self) +{ + return GOBJ2RVAL(gdk_image_get_colormap(_SELF(self))); +} + +static VALUE +rg_set_colormap(VALUE self, VALUE colormap) +{ + gdk_image_set_colormap(_SELF(self), RVAL2GOBJ(colormap)); + return self; +} + +static VALUE +rg_put_pixel(VALUE self, VALUE x, VALUE y, VALUE pix) +{ + gdk_image_put_pixel(_SELF(self), + NUM2INT(x), NUM2INT(y), NUM2INT(pix)); + return self; +} + +static VALUE +rg_get_pixel(VALUE self, VALUE x, VALUE y) +{ + return INT2NUM(gdk_image_get_pixel(_SELF(self), + NUM2INT(x), NUM2INT(y))); +} + +static VALUE +rg_image_type(VALUE self) +{ + return GENUM2RVAL((_SELF(self))->type, GDK_TYPE_IMAGE_TYPE); +} + +static VALUE +rg_visual(VALUE self) +{ + return GOBJ2RVAL((_SELF(self))->visual); +} + +static VALUE +rg_byte_order(VALUE self) +{ + return GENUM2RVAL((_SELF(self))->byte_order, GDK_TYPE_BYTE_ORDER); +} + +static VALUE +rg_bits_per_pixel(VALUE self) +{ + return INT2NUM((_SELF(self))->bits_per_pixel); +} + +static VALUE +rg_width(VALUE self) +{ + return INT2NUM((_SELF(self))->width); +} + +static VALUE +rg_height(VALUE self) +{ + return INT2NUM((_SELF(self))->height); +} + +static VALUE +rg_depth(VALUE self) +{ + return INT2NUM((_SELF(self))->depth); +} + +static VALUE +rg_bpp(VALUE self) +{ + return INT2NUM((_SELF(self))->bpp); +} + +static VALUE +rg_bpl(VALUE self) +{ + return INT2NUM((_SELF(self))->bpl); +} + +void +Init_gtk_gdk_image(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_IMAGE, "Image", mGdk); + + RG_DEF_METHOD(initialize, 4); + RG_DEF_METHOD(colormap, 0); + RG_DEF_METHOD(set_colormap, 1); + RG_DEF_METHOD(put_pixel, 3); + RG_DEF_METHOD(get_pixel, 2); + RG_DEF_METHOD(image_type, 0); + RG_DEF_METHOD(visual, 0); + RG_DEF_METHOD(byte_order, 0); + RG_DEF_METHOD(bits_per_pixel, 0); + RG_DEF_METHOD(width, 0); + RG_DEF_METHOD(height, 0); + RG_DEF_METHOD(depth, 0); + RG_DEF_METHOD(bpp, 0); + RG_DEF_METHOD(bpl, 0); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + + /* GdkImageType */ + G_DEF_CLASS(GDK_TYPE_IMAGE_TYPE, "Type", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_IMAGE_TYPE, "GDK_IMAGE_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkinput.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkinput.c new file mode 100644 index 0000000..b477dfe --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkinput.c @@ -0,0 +1,72 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE mInput + +static void +exec_input(gpointer data, G_GNUC_UNUSED gint source, GdkInputCondition condition) +{ + rb_funcall((VALUE)data, id_call, 1, + GFLAGS2RVAL(condition, GDK_TYPE_INPUT_CONDITION)); +} + +static VALUE +rg_m_add(VALUE self, VALUE filedescriptor, VALUE gdk_input_condition) +{ + VALUE id; + VALUE func; + + func = rb_block_proc(); + id = INT2FIX(gdk_input_add(NUM2INT(rb_funcall(filedescriptor, + rb_intern("to_i"), 0)), + RVAL2GFLAGS(gdk_input_condition, GDK_TYPE_INPUT_CONDITION), + (GdkInputFunction)exec_input, + (gpointer)func)); + G_RELATIVE2(self, func, id_relative_callbacks, id); + return id; +} + +static VALUE +rg_m_remove(VALUE self, VALUE id) +{ + gdk_input_remove(NUM2INT(id)); + G_REMOVE_RELATIVE(self, id_relative_callbacks, id); + return id; +} + +void +Init_gtk_gdk_input(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGdk, "Input"); + + RG_DEF_MODFUNC(add, 2); + RG_DEF_MODFUNC(remove, 1); + + /* GdkInputCondition */ + G_DEF_CLASS(GDK_TYPE_INPUT_CONDITION, "Condition", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_INPUT_CONDITION, "GDK_INPUT_"); + +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkkeymap.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkkeymap.c new file mode 100644 index 0000000..440928b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkkeymap.c @@ -0,0 +1,157 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003,2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cKeymap +#define _SELF(s) GDK_KEYMAP(RVAL2GOBJ(s)) + +static VALUE +rg_s_default(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(gdk_keymap_get_default()); +} +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_s_for_display(G_GNUC_UNUSED VALUE self, VALUE display) +{ + return GOBJ2RVAL(gdk_keymap_get_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)))); +} +#endif +static VALUE +rg_lookup_key(VALUE self, VALUE keycode, VALUE group, VALUE level) +{ + GdkKeymapKey key; + + key.keycode = NUM2UINT(keycode); + key.group = NUM2INT(group); + key.level = NUM2INT(level); + + return INT2NUM(gdk_keymap_lookup_key(_SELF(self), &key)); +} + +static VALUE +rg_translate_keyboard_state(VALUE self, VALUE hardware_keycode, VALUE state, VALUE group) +{ + guint keyval; + gint effective_group, level; + GdkModifierType consumed_modifiers; + gboolean ret; + + ret = gdk_keymap_translate_keyboard_state(_SELF(self), + NUM2UINT(hardware_keycode), + RVAL2GFLAGS(state, GDK_TYPE_MODIFIER_TYPE), + NUM2INT(group), + &keyval, &effective_group, + &level, &consumed_modifiers); + return ret ? rb_ary_new3(4, UINT2NUM(keyval), INT2NUM(effective_group), + INT2NUM(level), + GFLAGS2RVAL(consumed_modifiers, GDK_TYPE_MODIFIER_TYPE)) : Qnil; +} + +static VALUE +rg_get_entries_for_keyval(VALUE self, VALUE keyval) +{ + GdkKeymapKey* keys; + gint n_keys; + gboolean ret; + ret = gdk_keymap_get_entries_for_keyval(_SELF(self), + NUM2UINT(keyval), &keys, &n_keys); + + if (ret){ + VALUE key; + VALUE ary = rb_ary_new(); + gint i; + for (i = 0; i < n_keys; i++){ + key = rb_ary_new3(3, UINT2NUM(keys[i].keycode), INT2NUM(keys[i].group), + INT2NUM(keys[i].level)); + rb_ary_push(ary, key); + } + g_free(keys); + return ary; + } else { + return Qnil; + } +} + +static VALUE +rg_get_entries_for_keycode(VALUE self, VALUE hardware_keycode) +{ + GdkKeymapKey* keys; + guint* keyvals; + gint n_entries; + gboolean ret = gdk_keymap_get_entries_for_keycode(_SELF(self), + NUM2UINT(hardware_keycode), + &keys, &keyvals, &n_entries); + if (ret){ + VALUE key; + VALUE ary = rb_ary_new(); + gint i; + for (i = 0; i < n_entries; i++){ + key = rb_ary_new3(4, UINT2NUM(keys[i].keycode), INT2NUM(keys[i].group), + INT2NUM(keys[i].level), UINT2NUM(keyvals[i])); + rb_ary_push(ary, key); + } + g_free(keys); + g_free(keyvals); + return ary; + } else { + return Qnil; + } +} + +static VALUE +rg_direction(VALUE self) +{ + return GENUM2RVAL(gdk_keymap_get_direction(_SELF(self)), PANGO_TYPE_DIRECTION); +} + +#if GTK_CHECK_VERSION(2, 12, 0) +static VALUE +rg_have_bidi_layouts_p(VALUE self) +{ + return CBOOL2RVAL(gdk_keymap_have_bidi_layouts(_SELF(self))); +} +#endif + +void +Init_gtk_gdk_keymap(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_KEYMAP, "Keymap", mGdk); + + RG_DEF_SMETHOD(default, 0); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_SMETHOD(for_display, 0); +#endif + RG_DEF_METHOD(lookup_key, 3); + RG_DEF_METHOD(translate_keyboard_state, 3); + RG_DEF_METHOD(get_entries_for_keyval, 1); + RG_DEF_METHOD(get_entries_for_keycode, 1); + RG_DEF_METHOD(direction, 0); +#if GTK_CHECK_VERSION(2, 12, 0) + RG_DEF_METHOD_P(have_bidi_layouts, 0); +#endif + +#ifdef GDK_WINDOWING_X11 + G_DEF_CLASS3("GdkKeymapX11", "KeymapX11", mGdk); +#endif + +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkkeyval.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkkeyval.c new file mode 100644 index 0000000..e909929 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkkeyval.c @@ -0,0 +1,108 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" +#include + +#define RG_TARGET_NAMESPACE mGdkKeyval + +static VALUE +rg_m_to_name(G_GNUC_UNUSED VALUE self, VALUE keyval) +{ + gchar* name = gdk_keyval_name(NUM2UINT(keyval)); + return name ? CSTR2RVAL(name) : Qnil; +} + +static VALUE +rg_m_from_name(G_GNUC_UNUSED VALUE self, VALUE keyval_name) +{ + return UINT2NUM(gdk_keyval_from_name(RVAL2CSTR(keyval_name))); +} + +static VALUE +rg_m_upper_p(G_GNUC_UNUSED VALUE self, VALUE keyval) +{ + return CBOOL2RVAL(gdk_keyval_is_upper(NUM2UINT(keyval))); +} + +static VALUE +rg_m_lower_p(G_GNUC_UNUSED VALUE self, VALUE keyval) +{ + return CBOOL2RVAL(gdk_keyval_is_lower(NUM2UINT(keyval))); +} + +static VALUE +rg_m_convert_case(G_GNUC_UNUSED VALUE self, VALUE symbol) +{ + guint upper, lower; + gdk_keyval_convert_case(NUM2UINT(symbol), &lower, &upper); + return rb_ary_new3(2, UINT2NUM(lower), UINT2NUM(upper)); +} + +static VALUE +rg_m_to_upper(G_GNUC_UNUSED VALUE self, VALUE keyval) +{ + return INT2NUM(gdk_keyval_to_upper(NUM2UINT(keyval))); +} + +static VALUE +rg_m_to_lower(G_GNUC_UNUSED VALUE self, VALUE keyval) +{ + return INT2NUM(gdk_keyval_to_lower(NUM2UINT(keyval))); +} + +static VALUE +rg_m_to_unicode(G_GNUC_UNUSED VALUE self, VALUE keyval) +{ + return UINT2NUM(gdk_keyval_to_unicode(NUM2UINT(keyval))); +} + +static VALUE +rg_m_from_unicode(G_GNUC_UNUSED VALUE self, VALUE wc) +{ + VALUE unicode; + if (TYPE(wc) == T_STRING) { + unicode = NUM2UINT(rb_funcall(wc, rb_intern("[]"), 1, INT2FIX(0))); + } else { + unicode = NUM2UINT(wc); + } + return UINT2NUM(gdk_unicode_to_keyval(unicode)); +} + +void +Init_gtk_gdk_keyval(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGdk, "Keyval"); + RG_DEF_MODFUNC(to_name, 1); + RG_DEF_MODFUNC(from_name, 1); + RG_DEF_MODFUNC_P(upper, 1); + RG_DEF_MODFUNC_P(lower, 1); + RG_DEF_MODFUNC(convert_case, 1); + RG_DEF_MODFUNC(to_upper, 1); + RG_DEF_MODFUNC(to_lower, 1); + RG_DEF_MODFUNC(to_unicode, 1); + RG_DEF_MODFUNC(from_unicode, 1); + +#include "rbgdkkeysyms.h" +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkpango.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkpango.c new file mode 100644 index 0000000..2967189 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkpango.c @@ -0,0 +1,188 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003,2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" +#include "rbpango.h" + +#define RG_TARGET_NAMESPACE mPango + +static VALUE +rg_m_context(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE screen, ret; + rb_scan_args(argc, argv, "01", &screen); + if (NIL_P(screen)){ + ret = GOBJ2RVAL(gdk_pango_context_get()); + } else { +#if GTK_CHECK_VERSION(2,2,0) + ret = GOBJ2RVAL(gdk_pango_context_get_for_screen(GDK_SCREEN(RVAL2GOBJ(screen)))); +#else + rb_warn("Gdk::Pango.context_get: Not supported arguments in GTK+-2.0.x."); + ret = GOBJ2RVAL(gdk_pango_context_get()); +#endif + } + return ret; +} + +static VALUE +gdkpango_context_set_colormap(VALUE self, VALUE colormap) +{ + gdk_pango_context_set_colormap(PANGO_CONTEXT(RVAL2GOBJ(self)), + GDK_COLORMAP(RVAL2GOBJ(colormap))); + return self; +} + +static VALUE +gdkpango_attr_embossed_initialize(VALUE self, VALUE embossed) +{ + DATA_PTR(self) = gdk_pango_attr_embossed_new(RVAL2CBOOL(embossed)); + return Qnil; +} + +static VALUE +gdkpango_attr_embossed_value(VALUE self) +{ + return CBOOL2RVAL(((GdkPangoAttrEmbossed*)RVAL2ATTR(self))->embossed); +} + +static VALUE +gdkpango_attr_stipple_initialize(VALUE self, VALUE stipple) +{ + DATA_PTR(self) = gdk_pango_attr_stipple_new(GDK_BITMAP(RVAL2GOBJ(stipple))); + return Qnil; +} + +static VALUE +gdkpango_attr_stipple_value(VALUE self) +{ + return GOBJ2RVAL(((GdkPangoAttrStipple*)RVAL2ATTR(self))->stipple); +} + +static VALUE +gdkpango_layout_get_clip_region(VALUE self, VALUE rbx_origin, VALUE rby_origin, VALUE rbindex_ranges) +{ + PangoLayout *layout = PANGO_LAYOUT(RVAL2GOBJ(self)); + gint x_origin = NUM2INT(rbx_origin); + gint y_origin = NUM2INT(rby_origin); + long n; + gint *index_ranges = RVAL2GINTS(rbindex_ranges, n); + GdkRegion *result; + + if (n % 2 != 0) { + g_free(index_ranges); + + rb_raise(rb_eArgError, + "an even number of byte indexes must be given"); + } + + result = gdk_pango_layout_get_clip_region(layout, x_origin, y_origin, index_ranges, n / 2); + + g_free(index_ranges); + + return BOXED2RVAL(result, GDK_TYPE_REGION); +} + +static VALUE +gdkpango_layout_line_get_clip_region(VALUE self, VALUE rbx_origin, VALUE rby_origin, VALUE rbindex_ranges) +{ + PangoLayoutLine *line = (PangoLayoutLine *)RVAL2BOXED(self, PANGO_TYPE_LAYOUT_LINE); + gint x_origin = NUM2INT(rbx_origin); + gint y_origin = NUM2INT(rby_origin); + long n; + gint *index_ranges = RVAL2GINTS(rbindex_ranges, n); + GdkRegion *result; + + if (n % 2 != 0) { + g_free(index_ranges); + + rb_raise(rb_eArgError, + "an even number of byte indexes must be given"); + } + + result = gdk_pango_layout_line_get_clip_region(line, x_origin, y_origin, index_ranges, n / 2); + + g_free(index_ranges); + + return BOXED2RVAL(result, GDK_TYPE_REGION); +} + +#if GTK_CHECK_VERSION(2, 12, 0) +static VALUE +gdkpango_attr_emboss_color_initialize(VALUE self, VALUE color) +{ + DATA_PTR(self) = gdk_pango_attr_emboss_color_new(RVAL2GDKCOLOR(color)); + return Qnil; +} + +static VALUE +gdkpango_attr_emboss_color_value(VALUE self) +{ + return BOXED2RVAL(&(((GdkPangoAttrEmbossColor *)RVAL2ATTR(self))->color), + PANGO_TYPE_COLOR); +} +#endif + +void +Init_gtk_gdk_pango(VALUE mGdk) +{ + VALUE klass; + PangoAttribute* tmpattr; + GdkColor color; + + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGdk, "Pango"); + VALUE context = GTYPE2CLASS(PANGO_TYPE_CONTEXT); + VALUE layout = GTYPE2CLASS(PANGO_TYPE_LAYOUT); + VALUE layoutline = GTYPE2CLASS(PANGO_TYPE_LAYOUT_LINE); + VALUE pattr = ATTRTYPE2CLASS(CSTR2RVAL("Attribute")); + VALUE pattrbool = ATTRTYPE2CLASS(CSTR2RVAL("AttrBool")); + VALUE pattr_color = ATTRTYPE2CLASS(CSTR2RVAL("AttrColor")); + + RG_DEF_MODFUNC(context, -1); + + rb_define_method(context, "set_colormap", gdkpango_context_set_colormap, 1); + G_DEF_SETTER(context, "colormap"); + rb_define_method(layout, "get_clip_region", gdkpango_layout_get_clip_region, 3); + rb_define_method(layoutline, "get_clip_region", gdkpango_layout_line_get_clip_region, 3); + + klass = rb_define_class_under(mGdk, "PangoAttrEmbossed", pattrbool); + rb_define_method(klass, "initialize", gdkpango_attr_embossed_initialize, 1); + tmpattr = gdk_pango_attr_embossed_new(TRUE); + rb_define_method(klass, "value", gdkpango_attr_embossed_value, 0); + RBPANGO_ADD_ATTRIBUTE(tmpattr->klass->type, klass); + pango_attribute_destroy(tmpattr); + + klass = rb_define_class_under(mGdk, "PangoAttrStipple", pattr); + rb_define_method(klass, "initialize", gdkpango_attr_stipple_initialize, 1); + rb_define_method(klass, "value", gdkpango_attr_stipple_value, 0); + tmpattr = gdk_pango_attr_stipple_new(NULL); + RBPANGO_ADD_ATTRIBUTE(tmpattr->klass->type, klass); + pango_attribute_destroy(tmpattr); + +#if GTK_CHECK_VERSION(2, 12, 0) + klass = rb_define_class_under(mGdk, "PangoAttrEmbossColor", pattr_color); + rb_define_method(klass, "initialize", + gdkpango_attr_emboss_color_initialize, 1); + rb_define_method(klass, "value", gdkpango_attr_emboss_color_value, 0); + tmpattr = gdk_pango_attr_emboss_color_new(&color); + RBPANGO_ADD_ATTRIBUTE(tmpattr->klass->type, klass); + pango_attribute_destroy(tmpattr); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkpangorenderer.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkpangorenderer.c new file mode 100644 index 0000000..6dc90e8 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkpangorenderer.c @@ -0,0 +1,149 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011-2012 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,6,0) + +#define RG_TARGET_NAMESPACE cPangoRenderer +#define _SELF(s) (GDK_PANGO_RENDERER(RVAL2GOBJ(s))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE screen; + GdkScreen* gscreen; + + rb_scan_args(argc, argv, "01", &screen); + + if (NIL_P(screen)){ + gscreen = gdk_screen_get_default(); + } else { + gscreen = GDK_SCREEN(RVAL2GOBJ(screen)); + } + + G_INITIALIZE(self, gdk_pango_renderer_new(gscreen)); + + return Qnil; +} + +static VALUE +rg_s_get_default(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE screen; + GdkScreen* gscreen; + + rb_scan_args(argc, argv, "01", &screen); + + if (NIL_P(screen)){ + gscreen = gdk_screen_get_default(); + } else { + gscreen = GDK_SCREEN(RVAL2GOBJ(screen)); + } + return GOBJ2RVAL(gdk_pango_renderer_get_default(gscreen)); +} + +static VALUE +rg_s_default(G_GNUC_UNUSED VALUE self) +{ + GdkScreen* gscreen = gdk_screen_get_default(); + return GOBJ2RVAL(gdk_pango_renderer_get_default(gscreen)); +} + +static VALUE +rg_set_drawable(VALUE self, VALUE drawable) +{ + gdk_pango_renderer_set_drawable(_SELF(self), + GDK_DRAWABLE(RVAL2GOBJ(drawable))); + return self; +} + +static VALUE +rg_set_gc(VALUE self, VALUE gc) +{ + gdk_pango_renderer_set_gc(_SELF(self), + NIL_P(gc) ? NULL : GDK_GC(RVAL2GOBJ(gc))); + return self; +} + +#ifdef HAVE_PANGO_RENDER_PART_GET_TYPE +static VALUE +rg_set_stipple(VALUE self, VALUE part, VALUE stipple) +{ + gdk_pango_renderer_set_stipple(_SELF(self), RVAL2GENUM(part, PANGO_TYPE_RENDER_PART), + NIL_P(stipple) ? NULL : GDK_BITMAP(RVAL2GOBJ(stipple))); + + return self; +} +#else +static VALUE +rg_set_stipple(G_GNUC_UNUSED VALUE self, + G_GNUC_UNUSED VALUE part, + G_GNUC_UNUSED VALUE stipple) +{ + rb_warning("Gdk::PangoRender#set_tipple is not supported (Require pango-1.8.1 or later"); + + return self; +} +#endif + +#ifdef HAVE_PANGO_RENDER_PART_GET_TYPE +static VALUE +rg_set_override_color(VALUE self, VALUE part, VALUE color) +{ + gdk_pango_renderer_set_override_color(_SELF(self), + RVAL2GENUM(part, PANGO_TYPE_RENDER_PART), + RVAL2GDKCOLOR(color)); + + return self; +} +#else +static VALUE +rg_set_override_color(G_GNUC_UNUSED VALUE self, + G_GNUC_UNUSED VALUE part, + G_GNUC_UNUSED VALUE color) +{ + rb_warning("Gdk::PangoRender#set_override_color is not supported (Require pango-1.8.1 or later"); + + return self; +} +#endif + +#endif + +void +Init_gtk_gdk_pangorenderer(VALUE mGdk) +{ +#if GTK_CHECK_VERSION(2,6,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_PANGO_RENDERER, "PangoRenderer", mGdk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(set_drawable, 1); + RG_DEF_METHOD(set_gc, 1); + RG_DEF_METHOD(set_stipple, 2); + RG_DEF_METHOD(set_override_color, 2); + + RG_DEF_SMETHOD(get_default, -1); + RG_DEF_SMETHOD(default, 0); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkpixbuf.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkpixbuf.c new file mode 100644 index 0000000..92fb711 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkpixbuf.c @@ -0,0 +1,174 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cPixbuf +#define _SELF(s) GDK_PIXBUF(RVAL2GOBJ(s)) + +static VALUE +rg_render_threshold_alpha(VALUE self, VALUE bitmap, VALUE src_x, VALUE src_y, VALUE dest_x, VALUE dest_y, VALUE width, VALUE height, VALUE alpha_threshold) +{ + gdk_pixbuf_render_threshold_alpha(_SELF(self), GDK_BITMAP(RVAL2GOBJ(bitmap)), + NUM2INT(src_x), NUM2INT(src_y), + NUM2INT(dest_x), NUM2INT(dest_y), + NUM2INT(width), NUM2INT(height), + NUM2INT(alpha_threshold)); + return self; +} + +static VALUE +rg_render_to_drawable(int argc, VALUE *argv, VALUE self) +{ + VALUE gc, src_x, src_y, dest_x, dest_y, width, height, + dither, x_dither, y_dither; + +#if GTK_CHECK_VERSION(2,2,0) + rb_warn("Gdk::Pixbuf#render_to_drawable is obsolete. Use Gdk::Drawable#draw_pixbuf instead."); +#endif + + rb_scan_args(argc, argv, "73", &gc, &src_x, &src_y, &dest_x, &dest_y, + &width, &height, &dither, &x_dither, &y_dither); + + if (NIL_P(gc)) + rb_raise(rb_eArgError, "arguments 1 must be non nil"); + if (NIL_P(src_x)) + rb_raise(rb_eArgError, "arguments 2 must be non nil"); + if (NIL_P(src_y)) + rb_raise(rb_eArgError, "arguments 3 must be non nil"); + if (NIL_P(dest_x)) + rb_raise(rb_eArgError, "arguments 4 must be non nil"); + if (NIL_P(dest_y)) + rb_raise(rb_eArgError, "arguments 5 must be non nil"); + if (NIL_P(width)) + rb_raise(rb_eArgError, "arguments 6 must be non nil"); + if (NIL_P(height)) + rb_raise(rb_eArgError, "arguments 7 must be non nil"); + + gdk_pixbuf_render_to_drawable(_SELF(self), + GDK_DRAWABLE(RVAL2GOBJ(self)), + GDK_GC(RVAL2GOBJ(gc)), + NUM2INT(src_x), NUM2INT(src_y), + NUM2INT(dest_x), NUM2INT(dest_y), + NUM2INT(width), NUM2INT(height), + NIL_P(dither) ? GDK_RGB_DITHER_NONE : RVAL2GENUM(dither, GDK_TYPE_RGB_DITHER), + NIL_P(x_dither) ? 0 : NUM2INT(x_dither), + NIL_P(y_dither) ? 0 : NUM2INT(y_dither)); + return self; +} + +static VALUE +rg_render_pixmap_and_mask(int argc, VALUE *argv, VALUE self) +{ + VALUE colormap_or_alpha, alpha; + GdkPixmap *pixmap; + GdkBitmap *mask; + + rb_scan_args(argc, argv, "11", &colormap_or_alpha, &alpha); + + if (rb_obj_is_kind_of(colormap_or_alpha, GTYPE2CLASS(GDK_TYPE_COLORMAP))){ + gdk_pixbuf_render_pixmap_and_mask_for_colormap(_SELF(self), + RVAL2GOBJ(colormap_or_alpha), + &pixmap, + &mask, + NIL_P(alpha)?0:NUM2INT(alpha)); + } else { + gdk_pixbuf_render_pixmap_and_mask(_SELF(self), + &pixmap, + &mask, + NIL_P(colormap_or_alpha)? + 0:NUM2INT(colormap_or_alpha)); + } + + return rb_ary_new3(2, + pixmap ? GOBJ2RVAL(pixmap) : Qnil, + mask ? GOBJ2RVAL(mask) : Qnil); +} + +static VALUE +rg_s_from_drawable(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE cmap, src, src_x, src_y, width, height, dest, dest_x, dest_y; + GdkPixbuf* buf; + + rb_scan_args(argc, argv, "63", &cmap, &src, &src_x, &src_y, &width, &height, + &dest, &dest_x, &dest_y); + + buf = gdk_pixbuf_get_from_drawable(GDK_PIXBUF(RVAL2GOBJ(dest)), + GDK_DRAWABLE(RVAL2GOBJ(src)), + GDK_COLORMAP(RVAL2GOBJ(cmap)), + NUM2INT(src_x), NUM2INT(src_y), + NIL_P(dest_x) ? 0 : NUM2INT(dest_x), + NIL_P(dest_y) ? 0 : NUM2INT(dest_y), + NUM2INT(width), NUM2INT(height)); + if (NIL_P(dest)) { + if (buf) { + return GOBJ2RVALU(buf); + } else { + return Qnil; + } + } else { + return dest; + } +} + +static VALUE +rg_s_from_image(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE cmap, src, src_x, src_y, width, height, dest, dest_x, dest_y; + GdkPixbuf* buf; + + rb_scan_args(argc, argv, "63", &cmap, &src, &src_x, &src_y, &width, &height, + &dest, &dest_x, &dest_y); + + buf = gdk_pixbuf_get_from_image(GDK_PIXBUF(RVAL2GOBJ(dest)), + GDK_IMAGE(RVAL2GOBJ(src)), + GDK_COLORMAP(RVAL2GOBJ(cmap)), + NUM2INT(src_x), NUM2INT(src_y), + NIL_P(dest_x) ? 0 : NUM2INT(dest_x), + NIL_P(dest_y) ? 0 : NUM2INT(dest_y), + NUM2INT(width), NUM2INT(height)); + if (NIL_P(dest)) { + if (buf) { + return GOBJ2RVAL(buf); + } else { + return Qnil; + } + } else { + return dest; + } +} + +void +Init_gtk_gdk_pixbuf(VALUE mGdk) +{ + /* + * This defines Gdk::Pixbuf methods of GDK side. + */ + VALUE RG_TARGET_NAMESPACE = GTYPE2CLASS(GDK_TYPE_PIXBUF); + + RG_DEF_METHOD(render_threshold_alpha, 8); + RG_DEF_METHOD(render_to_drawable, -1); + RG_DEF_METHOD(render_pixmap_and_mask, -1); + + RG_DEF_SMETHOD(from_drawable, -1); + RG_DEF_SMETHOD(from_image, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkpixmap.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkpixmap.c new file mode 100644 index 0000000..1adaa79 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkpixmap.c @@ -0,0 +1,251 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" +#ifdef HAVE_XREADBITMAPFILEDATA +#include +#endif /* HAVE_XREADBITMAPFILEDATA */ + +#define RG_TARGET_NAMESPACE cPixmap + +static VALUE +rg_initialize(VALUE self, VALUE win, VALUE w, VALUE h, VALUE depth) +{ + G_INITIALIZE(self, gdk_pixmap_new(GDK_WINDOW(RVAL2GOBJ(win)), + NUM2INT(w), NUM2INT(h), + NUM2INT(depth))); + return Qnil; +} + +static VALUE +rg_s_create_from_data(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE win, data, w, h, depth, fg, bg, ret; + + rb_scan_args(argc, argv, "43", &win, &data, &w, &h, &depth, &fg, &bg); + + StringValue(data); + if (NIL_P(depth)){ + ret = GOBJ2RVAL(gdk_bitmap_create_from_data(NIL_P(win) ? NULL : GDK_WINDOW(RVAL2GOBJ(win)), + RVAL2CSTR(data), NUM2INT(w), NUM2INT(h))); + } else { + ret = GOBJ2RVAL(gdk_pixmap_create_from_data(NIL_P(win) ? NULL : GDK_WINDOW(RVAL2GOBJ(win)), + RVAL2CSTR(data), NUM2INT(w), NUM2INT(h), + NUM2INT(depth), + RVAL2GDKCOLOR(fg), + RVAL2GDKCOLOR(bg))); + } + return ret; +} + +static VALUE +rg_s_create_from_xpm(G_GNUC_UNUSED VALUE self, VALUE win, VALUE color, VALUE fname) +{ + GdkPixmap *result; + GdkBitmap *mask; + + result = gdk_pixmap_create_from_xpm(GDK_WINDOW(RVAL2GOBJ(win)), + &mask, + RVAL2GDKCOLOR(color), + RVAL2CSTR(fname)); + if (result == NULL) + rb_raise(rb_eArgError, "Pixmap not created from %s", RVAL2CSTR(fname)); + + return rb_assoc_new(GOBJ2RVAL(result), GOBJ2RVAL(mask)); +} + +static VALUE +rg_s_create_from_xpm_d(G_GNUC_UNUSED VALUE self, VALUE win, VALUE tcolor, VALUE data) +{ + GdkPixmap *result; + GdkBitmap *mask; + const gchar **buf = RVAL2STRV(data); + + result = gdk_pixmap_create_from_xpm_d(GDK_WINDOW(RVAL2GOBJ(win)), + &mask, + RVAL2GDKCOLOR(tcolor), + (gchar **)buf); + + g_free(buf); + + return rb_assoc_new(GOBJ2RVAL(result), GOBJ2RVAL(mask)); +} + +static VALUE +rg_s_colormap_create_from_xpm(G_GNUC_UNUSED VALUE self, VALUE win, VALUE colormap, VALUE tcolor, VALUE fname) +{ + GdkPixmap *result; + GdkBitmap *mask; + + result = gdk_pixmap_colormap_create_from_xpm(NIL_P(win) ? NULL : GDK_WINDOW(RVAL2GOBJ(win)), + GDK_COLORMAP(RVAL2GOBJ(colormap)), + &mask, + RVAL2GDKCOLOR(tcolor), + RVAL2CSTR(fname)); + if (result == NULL) + rb_raise(rb_eArgError, "Pixmap not created from %s", RVAL2CSTR(fname)); + + return rb_assoc_new(GOBJ2RVAL(result), GOBJ2RVAL(mask)); +} + +static VALUE +rg_s_colormap_create_from_xpm_d(G_GNUC_UNUSED VALUE self, VALUE win, VALUE colormap, VALUE tcolor, VALUE data) +{ + GdkPixmap *result; + GdkBitmap *mask; + const gchar **buf = RVAL2STRV(data); + + result = gdk_pixmap_colormap_create_from_xpm_d(NIL_P(win) ? NULL : GDK_WINDOW(RVAL2GOBJ(win)), + GDK_COLORMAP(RVAL2GOBJ(colormap)), + &mask, + RVAL2GDKCOLOR(tcolor), + (gchar **)buf); + + return rb_assoc_new(GOBJ2RVAL(result), GOBJ2RVAL(mask)); +} + +#ifdef HAVE_XREADBITMAPFILEDATA +static VALUE +rg_s_create_from_xbm(VALUE self, VALUE win, VALUE fname) +{ + GdkBitmap *new; + unsigned char *data; + unsigned int width, height; + int x, y; + + StringValue(fname); + if (XReadBitmapFileData(RVAL2CSTR(fname), &width, &height, &data, &x, &y)) + rb_raise(rb_eArgError, "Bitmap not created from %s", RVAL2CSTR(fname)); + + new = gdk_bitmap_create_from_data(GDK_WINDOW(RVAL2GOBJ(win)), + (const gchar*)data, width, height); + XFree(data); + return GOBJ2RVAL(new); +} +#endif /* HAVE_XREADBITMAPFILEDATA */ + +/* From X Window System Interaction */ +/* + Gdk::Window.foreign_new(anid) + Gdk::Window.foreign_new(display, anid) # Since GTK+-2.2 + Gdk::Window.foreign_new(screen, anid, width, height, depth) # Since GTK+-2.10 + */ + +static VALUE +rg_s_foreign_new(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE arg[5]; + GdkPixmap* win = NULL; + + rb_scan_args(argc, argv, "14", &arg[0], &arg[1], &arg[2], &arg[3], &arg[4]); + + switch(argc) + { + case 1: + win = gdk_pixmap_foreign_new(RVAL2GDKNATIVEWINDOW(arg[0])); + break; + case 2: +#if GTK_CHECK_VERSION(2,2,0) + win = gdk_pixmap_foreign_new_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(arg[0])), + RVAL2GDKNATIVEWINDOW(arg[1])); +#else + win = gdk_pixmap_foreign_new(RVAL2GDKNATIVEWINDOW(arg[1])); + rb_warn("Not supported. Use GTK+-2.2.0 or later."); +#endif + break; + case 5: +#if GTK_CHECK_VERSION(2,10,0) + win = gdk_pixmap_foreign_new_for_screen(GDK_SCREEN(RVAL2GOBJ(arg[0])), + RVAL2GDKNATIVEWINDOW(arg[1]), /* anid */ + NUM2INT(arg[2]), /* width */ + NUM2INT(arg[3]), /* height */ + NUM2INT(arg[4])); /* depth */ +#else + win = gdk_pixmap_foreign_new(NUM2UINT(arg[1])); + rb_warn("Not supported. GTK+-2.10.0 or later."); +#endif + break; + default: + break; + } + return win ? GOBJ2RVAL(win) : Qnil; +} + +static VALUE +rg_s_lookup(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE arg[2]; + GdkPixmap* win = NULL; + + rb_scan_args(argc, argv, "11", &arg[0], &arg[1]); + + switch(argc) + { + case 1: + win = gdk_pixmap_lookup(RVAL2GDKNATIVEWINDOW(arg[0])); + break; + case 2: +#if GTK_CHECK_VERSION(2,2,0) + win = gdk_pixmap_lookup_for_display(RVAL2GOBJ(arg[0]), RVAL2GDKNATIVEWINDOW(arg[1])); +#else + win = gdk_pixmap_lookup(RVAL2GDKNATIVEWINDOW(arg[1])); + rb_warn("Not supported in GTK+-2.0.x."); +#endif + break; + default: + break; + } + if (win == NULL) + return Qnil; + else { + return GOBJ2RVAL(win); + } +} + +void +Init_gtk_gdk_pixmap(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_PIXMAP, "Pixmap", mGdk); + + RG_DEF_METHOD(initialize, 4); + RG_DEF_SMETHOD(create_from_data, -1); + RG_DEF_SMETHOD(create_from_xpm, 3); + RG_DEF_SMETHOD(create_from_xpm_d, 3); + RG_DEF_SMETHOD(colormap_create_from_xpm, 4); + RG_DEF_SMETHOD(colormap_create_from_xpm_d, 4); +#ifdef HAVE_XREADBITMAPFILEDATA + RG_DEF_SMETHOD(create_from_xbm, 2); +#endif /* HAVE_XREADBITMAPFILEDATA */ +#ifdef GDK_WINDOWING_X11 + G_DEF_CLASS3("GdkPixmapImplX11", "PixmapImplX11", mGdk); +#elif defined(GDK_WINDOWING_WIN32) + G_DEF_CLASS3("GdkPixmapImplWin32", "PixmapImplWin32", mGdk); +#elif defined(GDK_WINDOWING_FB) + G_DEF_CLASS3("GdkPixmapFB", "PixmapFB", mGdk); +#endif + + RG_DEF_SMETHOD(foreign_new, -1); + RG_DEF_SMETHOD(lookup, -1); + +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkproperty.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkproperty.c new file mode 100644 index 0000000..52ad019 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkproperty.c @@ -0,0 +1,329 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE mProperty + +static VALUE +rg_m_text_property_to_text_list(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + gint num, i; + gchar** list; + VALUE ret = Qnil; + + if (argc == 3) { + VALUE encoding, format, text; + rb_scan_args(argc, argv, "30", &encoding, &format, &text); + StringValue(text); + + num = gdk_text_property_to_text_list(RVAL2ATOM(encoding), + NUM2INT(format), + (const guchar*)RVAL2CSTR(text), + RSTRING_LEN(text), &list); + } else { +#if GTK_CHECK_VERSION(2,2,0) + VALUE display, encoding, format, text; + rb_scan_args(argc, argv, "40", &display, &encoding, &format, &text); + StringValue(text); + + num = gdk_text_property_to_text_list_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)), + RVAL2ATOM(encoding), + NUM2INT(format), + (const guchar*)RVAL2CSTR(text), + RSTRING_LEN(text), + &list); +#else + VALUE encoding, format, text; + rb_scan_args(argc, argv, "30", &encoding, &format, &text); + rb_warn("Gdk::Property.text_property_to_text_list: Not supported arguments in GTK+-2.0.x."); + num = gdk_text_property_to_text_list(RVAL2ATOM(encoding), + NUM2INT(format), + (const guchar*)RVAL2CSTR(text), + RSTRING_LEN(text), &list); +#endif + } + + ret = rb_ary_new2(num); + for (i =0; i < num; i++){ + rb_ary_push(ret, CSTR2RVAL(list[i])); + } + gdk_free_text_list(list); + return ret; +} + +static VALUE +rg_m_text_property_to_utf8_list(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + gint num, i; + gchar** list; + VALUE ret = Qnil; + + if (argc == 3) { + VALUE encoding, format, text; + rb_scan_args(argc, argv, "30", &encoding, &format, &text); + StringValue(text); + + num = gdk_text_property_to_utf8_list(RVAL2ATOM(encoding), + NUM2INT(format), + (const guchar*)RVAL2CSTR(text), + RSTRING_LEN(text), &list); + } else { +#if GTK_CHECK_VERSION(2,2,0) + VALUE display, encoding, format, text; + rb_scan_args(argc, argv, "40", &display, &encoding, &format, &text); + StringValue(text); + + num = gdk_text_property_to_utf8_list_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)), + RVAL2ATOM(encoding), + NUM2INT(format), + (const guchar*)RVAL2CSTR(text), + RSTRING_LEN(text), + &list); +#else + VALUE encoding, format, text; + rb_scan_args(argc, argv, "30", &encoding, &format, &text); + StringValue(text); + + rb_warn("Gdk::Property.text_property_to_utf8_list: Not supported arguments in GTK+-2.0.x."); + num = gdk_text_property_to_utf8_list(RVAL2ATOM(encoding), + NUM2INT(format), + (const guchar*)RVAL2CSTR(text), + RSTRING_LEN(text), &list); +#endif + } + + ret = rb_ary_new2(num); + for (i =0; i < num; i++){ + rb_ary_push(ret, CSTR2RVAL(list[i])); + } + g_strfreev(list); + return ret; +} + +static VALUE +rg_m_string_to_compound_text(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + gint num; + GdkAtom encoding; + gint format; + guchar *ctext; + gint length; + + if (argc == 1) { + VALUE str; + rb_scan_args(argc, argv, "10", &str); + num = gdk_string_to_compound_text(RVAL2CSTR(str), + &encoding, &format, + &ctext, &length); + } else { +#if GTK_CHECK_VERSION(2,2,0) + VALUE display, str; + + rb_scan_args(argc, argv, "20", &display, &str); + num = gdk_string_to_compound_text_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)), + RVAL2CSTR(str), + &encoding, &format, + &ctext, &length); +#else + VALUE str; + rb_scan_args(argc, argv, "10", &str); + rb_warn("Gdk::Property.string_to_compound_text: Not supported arguments in GTK+-2.0.x."); + num = gdk_string_to_compound_text(RVAL2CSTR(str), + &encoding, &format, + &ctext, &length); +#endif + } + + if (num == 0){ + VALUE ret = CSTR2RVAL((const char*)ctext); + gdk_free_compound_text(ctext); + return rb_ary_new3(3, BOXED2RVAL(encoding, GDK_TYPE_ATOM), + INT2NUM(format), ret); + } else { + rb_raise(rb_eRuntimeError, "failed to converts a string %d\n", num); + } + return Qnil; +} + +static VALUE +rg_m_utf8_to_string_target(G_GNUC_UNUSED VALUE self, VALUE str) +{ + return CSTR2RVAL((const char*)gdk_utf8_to_string_target(RVAL2CSTR(str))); +} + +static VALUE +rg_m_utf8_to_compound_text(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + GdkAtom encoding; + gint format; + guchar *ctext; + gint length; + gint ret; + + if (argc == 1) { + VALUE str; + rb_scan_args(argc, argv, "10", &str); + + ret = gdk_utf8_to_compound_text(RVAL2CSTR(str), + &encoding, &format, + &ctext, &length); + } else { +#if GTK_CHECK_VERSION(2,2,0) + VALUE display, str; + + rb_scan_args(argc, argv, "20", &display, &str); + ret = gdk_utf8_to_compound_text_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)), + RVAL2CSTR(str), + &encoding, &format, + &ctext, &length); +#else + VALUE str; + rb_scan_args(argc, argv, "10", &str); + + rb_warn("Gdk::Property.utf8_to_compound_text: Not supported arguments in GTK+-2.0.x."); + ret = gdk_utf8_to_compound_text(RVAL2CSTR(str), + &encoding, &format, + &ctext, &length); +#endif + } + + if (ret){ + VALUE val = CSTR2RVAL((const char*)ctext); + gdk_free_compound_text(ctext); + return rb_ary_new3(3, BOXED2RVAL(encoding, GDK_TYPE_ATOM), + INT2NUM(format), val); + } else { + rb_raise(rb_eRuntimeError, "failed to converts a string %d\n", ret); + } + return Qnil; +} + +static VALUE +rg_m_change(int argc, VALUE *argv, VALUE self) +{ + int fmt, len; + void* dat; + GdkAtom ntype; + VALUE win, property, type, size= Qnil, mode, src; + + if(6 == argc) + rb_scan_args(argc, argv, "60", &win, &property, &type, &size, &mode, &src); + else + rb_scan_args(argc, argv, "50", &win, &property, &type, &mode, &src); + + rbgtk_atom2selectiondata(type, size, src, &ntype, &dat, &fmt, &len); + + gdk_property_change(GDK_WINDOW(RVAL2GOBJ(win)), RVAL2ATOM(property), + ntype, fmt, RVAL2GENUM(mode, GDK_TYPE_PROP_MODE), dat, len); + + rbgtk_atom2selectiondata_free(ntype, dat); + + return self; +} + +static VALUE +rg_m_get(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + /* for argument processing */ + GdkAtom rtype; + gint rfmt, rlen; + guchar* rdat; + VALUE win, property, type, offset=INT2FIX(0), length=INT2FIX(9999), delete; + + /* for inner processing */ + gint i; + size_t j; + VALUE ret = 0; + + if(6 == argc) + rb_scan_args(argc, argv, "60", &win, &property, &type, &offset, &length, &delete); + else + rb_scan_args(argc, argv, "40", &win, &property, &type, &delete); + + if(gdk_property_get(GDK_WINDOW(RVAL2GOBJ(win)), RVAL2ATOM(property), RVAL2ATOM(type), + NUM2INT(offset), NUM2INT(length), + RVAL2CBOOL(delete), &rtype, &rfmt, &rlen, &rdat) == FALSE){ + return Qnil; + } + + switch(rfmt){ + case 8: + default: + ret = RBG_STRING_SET_UTF8_ENCODING(rb_str_new((const char*)rdat, rlen)); + break; + + case 16: + ret = rb_ary_new(); + + for( i = 0; i < rlen; i++){ + rb_ary_push(ret, rb_Integer(((unsigned short*)rdat)[i])); + } + break; + + case 32: + ret = rb_ary_new(); + + if(rtype != GDK_SELECTION_TYPE_ATOM){ + for(j = 0; j < (rlen/sizeof(unsigned long)); j++){ + rb_ary_push(ret, INT2FIX(((unsigned long*)rdat)[j])); + } + } else { + for(j = 0; j < (rlen/sizeof(unsigned long)); j++){ + rb_ary_push(ret, BOXED2RVAL((GdkAtom)((unsigned long*)rdat)[j], GDK_TYPE_ATOM)); + } + } + break; + } + + return rb_ary_new3(3, BOXED2RVAL(rtype, GDK_TYPE_ATOM), + ret, INT2NUM(rlen)); +} + +static VALUE +rg_m_delete(VALUE self, VALUE win, VALUE property) +{ + gdk_property_delete(GDK_WINDOW(RVAL2GOBJ(win)), RVAL2ATOM(property)); + return self; +} + +void +Init_gtk_gdk_property(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGdk, "Property"); + + RG_DEF_MODFUNC(text_property_to_text_list, -1); + RG_DEF_MODFUNC(text_property_to_utf8_list, -1); + RG_DEF_MODFUNC(string_to_compound_text, -1); + RG_DEF_MODFUNC(utf8_to_string_target, 1); + RG_DEF_MODFUNC(utf8_to_compound_text, -1); + RG_DEF_MODFUNC(change, -1); + RG_DEF_MODFUNC(get, -1); + RG_DEF_MODFUNC(delete, 2); + + /* GdkPropMode from GdkProperties */ + G_DEF_CLASS(GDK_TYPE_PROP_MODE, "PropMode", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_PROP_MODE, "GDK_PROP_"); + +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkrectangle.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkrectangle.c new file mode 100644 index 0000000..ed9e627 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkrectangle.c @@ -0,0 +1,142 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cRectangle +#define _SELF(r) ((GdkRectangle*)RVAL2BOXED(r, GDK_TYPE_RECTANGLE)) + +static VALUE +rg_initialize(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height) +{ + GdkRectangle rectangle; + + rectangle.x = NUM2INT(x); + rectangle.y = NUM2INT(y); + rectangle.width = NUM2INT(width); + rectangle.height = NUM2INT(height); + + G_INITIALIZE(self, g_boxed_copy(GDK_TYPE_RECTANGLE, &rectangle)); + return Qnil; +} + +static VALUE +rg_intersect(VALUE self, VALUE other) +{ + GdkRectangle dest; + gboolean ret = gdk_rectangle_intersect(_SELF(self), _SELF(other), &dest); + return ret ? BOXED2RVAL(&dest, GDK_TYPE_RECTANGLE) : Qnil; +} + +static VALUE +rg_union(VALUE self, VALUE other) +{ + GdkRectangle dest; + gdk_rectangle_union(_SELF(self), _SELF(other), &dest); + return BOXED2RVAL(&dest, GDK_TYPE_RECTANGLE); +} + +/* Struct accessors */ +static VALUE +rg_x(VALUE self) +{ + return INT2NUM(_SELF(self)->x); +} + +static VALUE +rg_y(VALUE self) +{ + return INT2NUM(_SELF(self)->y); +} + +static VALUE +rg_width(VALUE self) +{ + return INT2NUM(_SELF(self)->width); +} + +static VALUE +rg_height(VALUE self) +{ + return INT2NUM(_SELF(self)->height); +} + +static VALUE +rg_set_x(VALUE self, VALUE x) +{ + _SELF(self)->x = NUM2INT(x); + return self; +} + +static VALUE +rg_set_y(VALUE self, VALUE y) +{ + _SELF(self)->y = NUM2INT(y); + return self; +} + +static VALUE +rg_set_width(VALUE self, VALUE width) +{ + _SELF(self)->width = NUM2INT(width); + return self; +} + +static VALUE +rg_set_height(VALUE self, VALUE height) +{ + _SELF(self)->height = NUM2INT(height); + return self; +} + +static VALUE +rg_to_a(VALUE self) +{ + GdkRectangle* a = _SELF(self); + return rb_ary_new3(4, INT2FIX(a->x), INT2FIX(a->y), + INT2FIX(a->width), INT2FIX(a->height)); +} + +void +Init_gtk_gdk_rectangle(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_RECTANGLE, "Rectangle", mGdk); + + RG_DEF_METHOD(initialize, 4); + RG_DEF_METHOD(intersect, 1); + RG_DEF_ALIAS("&", "intersect"); + RG_DEF_METHOD(union, 1); + RG_DEF_ALIAS("|", "union"); + RG_DEF_METHOD(x, 0); + RG_DEF_METHOD(y, 0); + RG_DEF_METHOD(width, 0); + RG_DEF_METHOD(height, 0); + RG_DEF_METHOD(set_x, 1); + RG_DEF_METHOD(set_y, 1); + RG_DEF_METHOD(set_width, 1); + RG_DEF_METHOD(set_height, 1); + RG_DEF_METHOD(to_a, 0); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkregion.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkregion.c new file mode 100644 index 0000000..ce733d2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkregion.c @@ -0,0 +1,289 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cRegion +#define _SELF(r) ((GdkRegion*)RVAL2BOXED(r, GDK_TYPE_REGION)) + +/**********************************/ +GType +gdk_region_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("GdkRegion", + (GBoxedCopyFunc)gdk_region_copy, + (GBoxedFreeFunc)gdk_region_destroy); + return our_type; +} +/**********************************/ +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE points_or_rectangle, rbfill_rule; + GdkRegion *region; + + rb_scan_args(argc, argv, "02", &points_or_rectangle, &rbfill_rule); + if (NIL_P(points_or_rectangle)) { + region = gdk_region_new(); + } else if (TYPE(points_or_rectangle) == T_ARRAY) { + GdkFillRule fill_rule = RVAL2GENUM(rbfill_rule, GDK_TYPE_FILL_RULE); + long n; + GdkPoint *points = RVAL2GDKPOINTS(points_or_rectangle, &n); + + region = gdk_region_polygon(points, n, fill_rule); + + g_free(points); + } else if (RVAL2GTYPE(points_or_rectangle) == GDK_TYPE_RECTANGLE) { + region = gdk_region_rectangle((GdkRectangle*)RVAL2BOXED(points_or_rectangle, + GDK_TYPE_RECTANGLE)); + } else { + rb_raise(rb_eArgError, + "invalid argument %s (expect array of Gdk::Point or Gdk::Rectangle, nil)", + rb_class2name(CLASS_OF(points_or_rectangle))); + } + + G_INITIALIZE(self, region); + + return Qnil; +} + +static VALUE +rg_rectangles(VALUE self) +{ + GdkRectangle* rectangles; + gint n_rect, i; + VALUE ary; + + gdk_region_get_rectangles(_SELF(self), &rectangles, &n_rect); + ary = rb_ary_new2(n_rect); + for (i = 0; i < n_rect; i++) { + rb_ary_push(ary, BOXED2RVAL(&rectangles[i], GDK_TYPE_RECTANGLE)); + } + g_free(rectangles); + return ary; +} + +static void +gdkregion_span_func(GdkSpan *span, gpointer func) +{ + rb_funcall((VALUE)func, id_call, 3, + INT2NUM(span->x), INT2NUM(span->y), INT2NUM(span->width)); +} + +struct rbgdk_rval2gdkspans_args { + VALUE ary; + long n; + GdkSpan *result; +}; + +static VALUE +rbgdk_rval2gdkspans_body(VALUE value) +{ + long i; + struct rbgdk_rval2gdkspans_args *args = (struct rbgdk_rval2gdkspans_args *)value; + + for (i = 0; i < args->n; i++) { + VALUE points = rb_ary_to_ary(RARRAY_PTR(args->ary)[i]); + + if (RARRAY_LEN(points) != 2) + rb_raise(rb_eArgError, "point %ld should be array of size 3", i); + + args->result[i].x = NUM2INT(RARRAY_PTR(points)[0]); + args->result[i].y = NUM2INT(RARRAY_PTR(points)[1]); + args->result[i].width = NUM2INT(RARRAY_PTR(points)[1]); + } + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbgdk_rval2gdkspans_rescue(VALUE value) +{ + g_free(((struct rbgdk_rval2gdkspans_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static GdkSpan * +rbgdk_rval2gdkspans(VALUE value, long *n) +{ + struct rbgdk_rval2gdkspans_args args; + + args.ary = rb_ary_to_ary(value); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(GdkSpan, args.n + 1); + + rb_rescue(rbgdk_rval2gdkspans_body, (VALUE)&args, + rbgdk_rval2gdkspans_rescue, (VALUE)&args); + + if (n != NULL) + *n = args.n; + + return args.result; +} + +#define RVAL2GDKSPANS(value, n) rbgdk_rval2gdkspans(value, n) + +static VALUE +rg_spans_intersect_each(VALUE self, VALUE rbspans, VALUE rbsorted) +{ + GdkRegion *region = _SELF(self); + gboolean sorted = RVAL2CBOOL(rbsorted); + VALUE func = rb_block_proc(); + long n; + GdkSpan *spans; + + G_RELATIVE(self, func); + + spans = RVAL2GDKSPANS(rbspans, &n); + + gdk_region_spans_intersect_foreach(region, + spans, + n, + sorted, + (GdkSpanFunc)gdkregion_span_func, + (gpointer)func); + + g_free(spans); + + return self; +} + +static VALUE +rg_clipbox(VALUE self) +{ + GdkRectangle rect; + gdk_region_get_clipbox(_SELF(self), &rect); + return BOXED2RVAL(&rect, GDK_TYPE_RECTANGLE); +} + +static VALUE +rg_empty_p(VALUE self) +{ + return CBOOL2RVAL(gdk_region_empty(_SELF(self))); +} + +static VALUE +rg_operator_equal(VALUE self, VALUE obj) +{ + if (!rb_obj_is_instance_of(obj, GTYPE2CLASS(GDK_TYPE_REGION))) { + return Qnil; + } + return CBOOL2RVAL(gdk_region_equal(_SELF(self), _SELF(obj))); +} + +static VALUE +rg_point_in_p(VALUE self, VALUE x, VALUE y) +{ + return CBOOL2RVAL(gdk_region_point_in(_SELF(self), NUM2INT(x), + NUM2INT(y))); +} + +static VALUE +rg_rect_in(VALUE self, VALUE rect) +{ + return GENUM2RVAL(gdk_region_rect_in( + _SELF(self), + (GdkRectangle*)RVAL2BOXED(rect, GDK_TYPE_RECTANGLE)), + GDK_TYPE_OVERLAP_TYPE); +} + +static VALUE +rg_offset(VALUE self, VALUE dx, VALUE dy) +{ + gdk_region_offset(_SELF(self), NUM2INT(dx), NUM2INT(dy)); + return self; +} + +static VALUE +rg_shrink(VALUE self, VALUE dx, VALUE dy) +{ + gdk_region_shrink(_SELF(self), NUM2INT(dx), NUM2INT(dy)); + return self; +} + +static VALUE +rg_intersect(VALUE self, VALUE region) +{ + gdk_region_intersect(_SELF(self), _SELF(region)); + return self; +} + +static VALUE +rg_union(VALUE self, VALUE other) +{ + if (RVAL2GTYPE(other) == GDK_TYPE_RECTANGLE){ + gdk_region_union_with_rect(_SELF(self), + (GdkRectangle*)RVAL2BOXED(other, GDK_TYPE_RECTANGLE)); + } else { + gdk_region_union(_SELF(self), _SELF(other)); + } + return self; +} + +static VALUE +rg_subtract(VALUE self, VALUE region) +{ + gdk_region_subtract(_SELF(self), _SELF(region)); + return self; +} + +static VALUE +rg_xor(VALUE self, VALUE region) +{ + gdk_region_xor(_SELF(self), _SELF(region)); + return self; +} + +void +Init_gtk_gdk_region(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_REGION, "Region", mGdk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(rectangles, 0); + RG_DEF_METHOD(spans_intersect_each, 2); + RG_DEF_METHOD(clipbox, 0); + RG_DEF_METHOD_P(empty, 0); + RG_DEF_METHOD_OPERATOR("==", equal, 1); + RG_DEF_METHOD_P(point_in, 2); + RG_DEF_METHOD(rect_in, 1); + RG_DEF_METHOD(offset, 2); + RG_DEF_METHOD(shrink, 2); + RG_DEF_METHOD(intersect, 1); + RG_DEF_METHOD(union, 1); + RG_DEF_METHOD(subtract, 1); + RG_DEF_METHOD(xor, 1); + + /* GdkOverlapType */ + G_DEF_CLASS(GDK_TYPE_OVERLAP_TYPE, "OverlapType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_OVERLAP_TYPE, "GDK_"); + + /* GdkFillRule */ + G_DEF_CLASS(GDK_TYPE_FILL_RULE, "FillRule", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_FILL_RULE, "GDK_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkrgb.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkrgb.c new file mode 100644 index 0000000..8dccd81 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkrgb.c @@ -0,0 +1,198 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE mRGB +#define RVAL2DRAW(s) GDK_DRAWABLE(RVAL2GOBJ(s)) + +static VALUE +rg_m_draw_rgb_image(int argc, VALUE *argv, VALUE self) +{ + VALUE win, gc, x, y, w, h, dither, buf, rowstride, xdith, ydith; + + rb_scan_args(argc, argv, "92", &win, &gc, &x, &y, &w, &h, &dither, + &buf, &rowstride, &xdith, &ydith); + + if (argc == 9){ + gdk_draw_rgb_image(RVAL2DRAW(win), GDK_GC(RVAL2GOBJ(gc)), + NUM2INT(x), NUM2INT(y), + NUM2INT(w), NUM2INT(h), + RVAL2GENUM(dither, GDK_TYPE_RGB_DITHER), + (guchar*)RVAL2CSTR(buf), + NUM2INT(rowstride)); + } else { + gdk_draw_rgb_image_dithalign(RVAL2DRAW(win), GDK_GC(RVAL2GOBJ(gc)), + NUM2INT(x), NUM2INT(y), + NUM2INT(w), NUM2INT(h), + RVAL2GENUM(dither, GDK_TYPE_RGB_DITHER), + (guchar*)RVAL2CSTR(buf), + NUM2INT(rowstride), + NUM2INT(xdith), NUM2INT(ydith)); + } + + return self; +} + +static VALUE +rg_m_draw_indexed_image(VALUE self, VALUE win, VALUE rbgc, VALUE rbx, VALUE rby, + VALUE rbwidth, VALUE rbheight, VALUE rbdither, + VALUE rbbuf, VALUE rbrowstride, VALUE rbcolors) +{ + GdkDrawable *drawable = RVAL2DRAW(win); + GdkGC *gc = GDK_GC(RVAL2GOBJ(rbgc)); + gint x = NUM2INT(rbx); + gint y = NUM2INT(rby); + gint width = NUM2INT(rbwidth); + gint height = NUM2INT(rbheight); + GdkRgbDither dither = RVAL2GENUM(rbdither, GDK_TYPE_RGB_DITHER); + const guchar *buf = (const guchar *)RVAL2CSTR(rbbuf); + gint rowstride = NUM2INT(rbrowstride); + long n; + guint32 *colors = RVAL2GUINT32S(rbcolors, n); + GdkRgbCmap *cmap; + + if (n < 0 || n > 255) { + g_free(colors); + + rb_raise(rb_eArgError, "colors: out of range (0 - 255)"); + } + + cmap = gdk_rgb_cmap_new(colors, n); + + g_free(colors); + + gdk_draw_indexed_image(drawable, gc, x, y, width, height, dither, buf, rowstride, cmap); + + gdk_rgb_cmap_free(cmap); + + return self; +} + +static VALUE +rg_m_draw_gray_image(VALUE self, VALUE win, VALUE gc, VALUE x, VALUE y, VALUE w, VALUE h, VALUE dither, VALUE buf, VALUE rowstride) +{ + gdk_draw_gray_image(RVAL2DRAW(win), GDK_GC(RVAL2GOBJ(gc)), + NUM2INT(x), NUM2INT(y), + NUM2INT(w), NUM2INT(h), + RVAL2GENUM(dither, GDK_TYPE_RGB_DITHER), + (guchar*)RVAL2CSTR(buf), + NUM2INT(rowstride)); + return self; +} + +static VALUE +rg_m_draw_rgb_32_image(int argc, VALUE *argv, VALUE self) +{ + VALUE win, gc, x, y, w, h, dither, buf, rowstride, xdith, ydith; + + rb_scan_args(argc, argv, "92", &win, &gc, &x, &y, &w, &h, &dither, + &buf, &rowstride, &xdith, &ydith); + + if (argc == 9){ + gdk_draw_rgb_32_image(RVAL2DRAW(win), GDK_GC(RVAL2GOBJ(gc)), + NUM2INT(x), NUM2INT(y), + NUM2INT(w), NUM2INT(h), + RVAL2GENUM(dither, GDK_TYPE_RGB_DITHER), + (guchar*)RVAL2CSTR(buf), + NUM2INT(rowstride)); + } else { + gdk_draw_rgb_32_image_dithalign(RVAL2DRAW(win), GDK_GC(RVAL2GOBJ(gc)), + NUM2INT(x), NUM2INT(y), + NUM2INT(w), NUM2INT(h), + RVAL2GENUM(dither, GDK_TYPE_RGB_DITHER), + (guchar*)RVAL2CSTR(buf), + NUM2INT(rowstride), NUM2INT(xdith), NUM2INT(ydith)); + } + return self; +} + +static VALUE +rg_m_find_color(VALUE self, VALUE colormap, VALUE color) +{ + gdk_rgb_find_color(GDK_COLORMAP(RVAL2GOBJ(colormap)), + RVAL2GDKCOLOR(color)); + return self; +} + +static VALUE +rg_m_set_install(VALUE self, VALUE install) +{ + gdk_rgb_set_install(RVAL2CBOOL(install)); + return self; +} + +static VALUE +rg_m_set_min_colors(VALUE self, VALUE min_colors) +{ + gdk_rgb_set_min_colors(NUM2INT(min_colors)); + return self; +} + +static VALUE +rg_m_visual(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(gdk_rgb_get_visual()); +} + +static VALUE +rg_m_colormap(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(gdk_rgb_get_colormap()); +} + +static VALUE +rg_m_ditherable_p(G_GNUC_UNUSED VALUE self) +{ + return CBOOL2RVAL(gdk_rgb_ditherable()); +} + +static VALUE +rg_m_set_verbose(VALUE self, VALUE verbose) +{ + gdk_rgb_set_verbose(RVAL2CBOOL(verbose)); + return self; +} + +void +Init_gtk_gdk_rgb(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGdk, "RGB"); + + RG_DEF_MODFUNC(draw_rgb_image, -1); + RG_DEF_MODFUNC(draw_indexed_image, 10); + RG_DEF_MODFUNC(draw_gray_image, 9); + RG_DEF_MODFUNC(draw_rgb_32_image, -1); + RG_DEF_MODFUNC(find_color, 2); + RG_DEF_MODFUNC(set_install, 1); + RG_DEF_MODFUNC(set_min_colors, 0); + RG_DEF_MODFUNC(visual, 0); + RG_DEF_MODFUNC(colormap, 0); + RG_DEF_MODFUNC_P(ditherable, 0); + RG_DEF_MODFUNC(set_verbose, 1); + + /* GdkRgbDither */ + G_DEF_CLASS(GDK_TYPE_RGB_DITHER, "Dither", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_RGB_DITHER, "GDK_RGB_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkscreen.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkscreen.c new file mode 100644 index 0000000..5c56182 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkscreen.c @@ -0,0 +1,444 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003-2006 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Geoff Youngs + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" +#ifdef HAVE_RB_CAIRO_H +#include +#endif + +#if GTK_CHECK_VERSION(2,2,0) + +#define RG_TARGET_NAMESPACE cScreen +#define _SELF(i) GDK_SCREEN(RVAL2GOBJ(i)) + +static ID id_new; + +static VALUE +rg_s_default(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(gdk_screen_get_default()); +} + +static VALUE +rg_default_colormap(VALUE self) +{ + return GOBJ2RVAL(gdk_screen_get_default_colormap(_SELF(self))); +} + +static VALUE +rg_set_default_colormap(VALUE self, VALUE colormap) +{ + gdk_screen_set_default_colormap(_SELF(self), + GDK_COLORMAP(RVAL2GOBJ(colormap))); + return self; +} + +static VALUE +rg_system_colormap(VALUE self) +{ + return GOBJ2RVAL(gdk_screen_get_system_colormap(_SELF(self))); +} + +static VALUE +rg_system_visual(VALUE self) +{ + return GOBJ2RVAL(gdk_screen_get_system_visual(_SELF(self))); +} + +static VALUE +rg_rgb_colormap(VALUE self) +{ + return GOBJ2RVAL(gdk_screen_get_rgb_colormap(_SELF(self))); +} + +static VALUE +rg_rgb_visual(VALUE self) +{ + return GOBJ2RVAL(gdk_screen_get_rgb_visual(_SELF(self))); +} + +#if GTK_CHECK_VERSION(2,8,0) +static VALUE +rg_rgba_colormap(VALUE self) +{ + return GOBJ2RVAL(gdk_screen_get_rgba_colormap(_SELF(self))); +} + +static VALUE +rg_rgba_visual(VALUE self) +{ + return GOBJ2RVAL(gdk_screen_get_rgba_visual(_SELF(self))); +} +#endif + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_composited_p(VALUE self) +{ + return CBOOL2RVAL(gdk_screen_is_composited(_SELF(self))); +} +#endif + +static VALUE +rg_root_window(VALUE self) +{ + return GOBJ2RVAL(gdk_screen_get_root_window(_SELF(self))); +} + +static VALUE +rg_display(VALUE self) +{ + return GOBJ2RVAL(gdk_screen_get_display(_SELF(self))); +} + +static VALUE +rg_number(VALUE self) +{ + return INT2NUM(gdk_screen_get_number(_SELF(self))); +} +static VALUE +rg_width(VALUE self) +{ + return INT2NUM(gdk_screen_get_width(_SELF(self))); +} +static VALUE +rg_height(VALUE self) +{ + return INT2NUM(gdk_screen_get_height(_SELF(self))); +} +static VALUE +rg_width_mm(VALUE self) +{ + return INT2NUM(gdk_screen_get_width_mm(_SELF(self))); +} +static VALUE +rg_height_mm(VALUE self) +{ + return INT2NUM(gdk_screen_get_height_mm(_SELF(self))); +} + +static VALUE +rg_visuals(VALUE self) +{ + return GLIST2ARYF(gdk_screen_list_visuals(_SELF(self))); +} + +static VALUE +rg_toplevel_windows(VALUE self) +{ + return GLIST2ARYF(gdk_screen_get_toplevel_windows(_SELF(self))); +} + +static VALUE +rg_display_name(VALUE self) +{ + gchar* name = gdk_screen_make_display_name(_SELF(self)); + VALUE ret = CSTR2RVAL(name); + g_free(name); + return ret; +} + +static VALUE +rg_n_monitors(VALUE self) +{ + return INT2NUM(gdk_screen_get_n_monitors(_SELF(self))); +} + +static VALUE +rg_monitor_geometry(VALUE self, VALUE num) +{ + GdkRectangle rect; + gdk_screen_get_monitor_geometry(_SELF(self), NUM2INT(num), &rect); + return BOXED2RVAL(&rect, GDK_TYPE_RECTANGLE); +} + +static VALUE +rg_get_monitor(int argc, VALUE *argv, VALUE self) +{ + VALUE arg1, arg2; + VALUE ret; + + rb_scan_args(argc, argv, "11", &arg1, &arg2); + if (argc == 2){ + ret = INT2NUM(gdk_screen_get_monitor_at_point(_SELF(self), + NUM2INT(arg1), NUM2INT(arg2))); + } else if (argc == 1){ + ret = INT2NUM(gdk_screen_get_monitor_at_window(_SELF(self), + GDK_WINDOW(RVAL2GOBJ(arg1)))); + } else { + rb_raise(rb_eArgError, "Wrong number of arguments: %d", argc); + } + return ret; +} + +static VALUE +rg_broadcast_client_message(VALUE self, VALUE event) +{ + gdk_screen_broadcast_client_message(_SELF(self), RVAL2GEV(event)); + return self; +} + +/* + type: String, Integer, Gdk::Color. + */ +static VALUE +rg_get_setting(int argc, VALUE *argv, VALUE self) +{ + VALUE name, type; + GType gtype; + GValue val = G_VALUE_INIT; + gboolean ret; + VALUE value; + + rb_scan_args(argc, argv, "11", &name, &type); + if (NIL_P(type)) + gtype = G_TYPE_STRING; + else + gtype = CLASS2GTYPE(type); + + g_value_init(&val, gtype); + ret = gdk_screen_get_setting(_SELF(self), RVAL2CSTR(name), &val); + value = ret ? GVAL2RVAL(&val) : Qnil; + g_value_unset(&val); + return value; +} + +#if GTK_CHECK_VERSION(2,10,0) +#ifdef HAVE_RB_CAIRO_H +static VALUE +gdkscreen_get_font_options(VALUE self) +{ + return CRFONTOPTIONS2RVAL((cairo_font_options_t *)gdk_screen_get_font_options(_SELF(self))); +} + +static VALUE +gdkscreen_set_font_options(VALUE self, VALUE options) +{ + gdk_screen_set_font_options(_SELF(self), + (const cairo_font_options_t *)RVAL2CRFONTOPTIONS(options)); + return self; +} +#endif + +static VALUE +rg_active_window(VALUE self) +{ + return GOBJ2RVAL(gdk_screen_get_active_window(_SELF(self))); +} + +static VALUE +rg_window_stack(VALUE self) +{ + GList* list = gdk_screen_get_window_stack(_SELF(self)); + VALUE ary = rb_ary_new(); + while (list) { + rb_ary_push(ary, GOBJ2RVAL(list->data)); + g_object_unref(list->data); + list = list->next; + } + g_list_free(list); + return ary; +} +#endif + +#if GTK_CHECK_VERSION(2,4,0) +static void +child_setup(gpointer func) +{ + if (! NIL_P(func)){ + rb_funcall((VALUE)func, id_call, 0); + } +} + +static VALUE +rg_spawn_on_screen(VALUE self, VALUE working_directory, VALUE argv, VALUE envp, VALUE flags) +{ + GError *err = NULL; + gboolean ret; + gint child_pid; + VALUE func = Qnil; + gchar **gargv; + gchar **genvp; + + if (rb_block_given_p()) { + func = rb_block_proc(); + G_RELATIVE(self, func); + } + + gargv = (gchar **)RVAL2STRV(argv); + genvp = (gchar **)RVAL2STRV_ACCEPT_NIL(envp); + ret = gdk_spawn_on_screen(_SELF(self), + NIL_P(working_directory) ? NULL : RVAL2CSTR(working_directory), + gargv, genvp, NUM2INT(flags), + (GSpawnChildSetupFunc)child_setup, (gpointer)func, + &child_pid, &err); + g_free(gargv); + g_free(genvp); + if (!ret) + RAISE_GERROR(err); + + return INT2NUM(child_pid); +} + +static VALUE +rg_spawn_on_screen_with_pipes(VALUE self, VALUE working_directory, VALUE argv, VALUE envp, VALUE flags) +{ + GError *err = NULL; + gboolean ret; + gint child_pid; + VALUE func = Qnil; + gchar **gargv; + gchar **genvp; + gint standard_input, standard_output, standard_error; + + if (rb_block_given_p()) { + func = rb_block_proc(); + G_RELATIVE(self, func); + } + + gargv = (gchar **)RVAL2STRV(argv); + genvp = (gchar **)RVAL2STRV_ACCEPT_NIL(envp); + ret = gdk_spawn_on_screen_with_pipes(_SELF(self), + NIL_P(working_directory) ? NULL : RVAL2CSTR(working_directory), + gargv, genvp, NUM2INT(flags), + (GSpawnChildSetupFunc)child_setup, (gpointer)func, + &child_pid, + &standard_input, &standard_output, + &standard_error, &err); + g_free(gargv); + g_free(genvp); + if (!ret) + RAISE_GERROR(err); + + return rb_ary_new3(4, INT2NUM(child_pid), + rb_funcall(rb_cIO, id_new, 1, INT2NUM(standard_input)), + rb_funcall(rb_cIO, id_new, 1, INT2NUM(standard_output)), + rb_funcall(rb_cIO, id_new, 1, INT2NUM(standard_error))); +} + +static VALUE +rg_spawn_command_line_on_screen(G_GNUC_UNUSED VALUE self, VALUE command_line) +{ + GError *err = NULL; + VALUE ret; + + ret = CBOOL2RVAL(g_spawn_command_line_async(RVAL2CSTR(command_line), &err)); + if (!ret) RAISE_GERROR(err); + + return ret; +} +#endif + +/* From X Window System Interaction */ +#ifdef GDK_WINDOWING_X11 +#include +static VALUE +rg_xnumber(VALUE self) +{ + return INT2NUM(GDK_SCREEN_XNUMBER(_SELF(self))); +} +static VALUE +rg_supports_net_wm_hint_p(VALUE self, VALUE property) +{ + return CBOOL2RVAL(gdk_x11_screen_supports_net_wm_hint(_SELF(self), + RVAL2ATOM(property))); +} + +static VALUE +rg_window_manager_name(VALUE self) +{ + return CSTR2RVAL(gdk_x11_screen_get_window_manager_name(_SELF(self))); +} +static VALUE +rg_screen_number(VALUE self) +{ + return INT2NUM(gdk_x11_screen_get_screen_number(_SELF(self))); +} +#endif + +#endif + +void +Init_gtk_gdk_screen(VALUE mGdk) +{ +#if GTK_CHECK_VERSION(2,2,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_SCREEN, "Screen", mGdk); + + id_new = rb_intern("new"); + + RG_DEF_SMETHOD(default, 0); + RG_DEF_METHOD(default_colormap, 0); + RG_DEF_METHOD(set_default_colormap, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "default_colormap"); + RG_DEF_METHOD(system_colormap, 0); + RG_DEF_METHOD(system_visual, 0); + RG_DEF_METHOD(rgb_colormap, 0); + RG_DEF_METHOD(rgb_visual, 0); +#if GTK_CHECK_VERSION(2,8,0) + RG_DEF_METHOD(rgba_colormap, 0); + RG_DEF_METHOD(rgba_visual, 0); +#endif +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD_P(composited, 0); +#endif + RG_DEF_METHOD(root_window, 0); + RG_DEF_METHOD(display, 0); + RG_DEF_METHOD(number, 0); + RG_DEF_METHOD(width, 0); + RG_DEF_METHOD(height, 0); + RG_DEF_METHOD(width_mm, 0); + RG_DEF_METHOD(height_mm, 0); + RG_DEF_METHOD(visuals, 0); + RG_DEF_METHOD(toplevel_windows, 0); + RG_DEF_METHOD(display_name, 0); + RG_DEF_METHOD(n_monitors, 0); + RG_DEF_METHOD(monitor_geometry, 1); + RG_DEF_METHOD(get_monitor, -1); + RG_DEF_METHOD(broadcast_client_message, 1); + RG_DEF_METHOD(get_setting, -1); +#if GTK_CHECK_VERSION(2,10,0) +#ifdef HAVE_RB_CAIRO_H + G_REPLACE_GET_PROPERTY(RG_TARGET_NAMESPACE, "font_options", gdkscreen_get_font_options, 0); + G_REPLACE_SET_PROPERTY(RG_TARGET_NAMESPACE, "font_options", gdkscreen_set_font_options, 1); +#endif + RG_DEF_METHOD(active_window, 0); + RG_DEF_METHOD(window_stack, 0); +#endif + +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(spawn_on_screen, 4); + RG_DEF_METHOD(spawn_on_screen_with_pipes, 4); + RG_DEF_METHOD(spawn_command_line_on_screen, 1); +#endif + +#ifdef GDK_WINDOWING_X11 + RG_DEF_METHOD(xnumber, 0); + RG_DEF_METHOD_P(supports_net_wm_hint, 0); + RG_DEF_METHOD(window_manager_name, 0); + RG_DEF_METHOD(screen_number, 0); +#endif + +#ifdef GDK_WINDOWING_X11 + G_DEF_CLASS3("GdkScreenX11", "ScreenX11", mGdk); +#endif +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkselection.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkselection.c new file mode 100644 index 0000000..cbfe99c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkselection.c @@ -0,0 +1,160 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE mSelection +#define GATOM2RVAL(g) (BOXED2RVAL(g, GDK_TYPE_ATOM)) + +static VALUE +rg_m_owner_set(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE owner, selection, time, send_event; + int ret; + + if (argc == 4){ + rb_scan_args(argc, argv, "40", &owner, &selection, &time, &send_event); + ret = gdk_selection_owner_set(GDK_WINDOW(RVAL2GOBJ(owner)), + RVAL2ATOM(selection), + NUM2UINT(time), RVAL2CBOOL(send_event)); + } else { +#if GTK_CHECK_VERSION(2,2,0) + VALUE display = Qnil; + rb_scan_args(argc, argv, "50", &display, &owner, &selection, &time, &send_event); + ret = gdk_selection_owner_set_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)), + GDK_WINDOW(RVAL2GOBJ(owner)), + RVAL2ATOM(selection), + NUM2UINT(time), RVAL2CBOOL(send_event)); +#else + rb_raise(rb_eArgError, "Wrong number of arguments: %d", argc); +#endif + + } + return CBOOL2RVAL(ret); +} + +static VALUE +rg_m_owner_get(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE selection; + + if (argc == 1) { + rb_scan_args(argc, argv, "10", &selection); + return GOBJ2RVAL(gdk_selection_owner_get(RVAL2ATOM(selection))); + } else { +#if GTK_CHECK_VERSION(2,2,0) + VALUE display = Qnil; + rb_scan_args(argc, argv, "20", &display, &selection); + return GOBJ2RVAL(gdk_selection_owner_get_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)), + RVAL2ATOM(selection))); +#else + rb_raise(rb_eArgError, "Wrong number of arguments: %d", argc); +#endif + } +} + +static VALUE +rg_m_convert(VALUE self, VALUE requestor, VALUE selection, VALUE target, VALUE time) +{ + gdk_selection_convert(GDK_WINDOW(RVAL2GOBJ(requestor)), + RVAL2ATOM(selection), + RVAL2ATOM(target), NUM2INT(time)); + return self; +} + +static VALUE +rg_m_property_get(G_GNUC_UNUSED VALUE self, VALUE requestor) +{ + guchar *data; + GdkAtom prop_type; + gint prop_format; + VALUE ary; + + gdk_selection_property_get(GDK_WINDOW(RVAL2GOBJ(requestor)), &data, + &prop_type, &prop_format); + + ary = rb_ary_new3(3, CSTR2RVAL((const char*)data), GATOM2RVAL(prop_type), + INT2NUM(prop_format)); + g_free(data); + return ary; +} + +static VALUE +rg_m_send_notify(int argc, VALUE *argv, VALUE self) +{ + VALUE requestor, selection, target, property, time; + + if (argc == 5) { + rb_scan_args(argc, argv, "50", &requestor, &selection, &target, &property, &time); + gdk_selection_send_notify(RVAL2GDKNATIVEWINDOW(requestor), RVAL2ATOM(selection), + RVAL2ATOM(target), + NIL_P(property) ? GDK_NONE : RVAL2ATOM(property), + NUM2INT(time)); + } else { +#if GTK_CHECK_VERSION(2,2,0) + VALUE display = Qnil; + rb_scan_args(argc, argv, "60", &display, &requestor, &selection, &target, &property, &time); + gdk_selection_send_notify_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)), + RVAL2GDKNATIVEWINDOW(requestor), RVAL2ATOM(selection), + RVAL2ATOM(target), + NIL_P(property) ? GDK_NONE : RVAL2ATOM(property), + NUM2INT(time)); +#else + rb_raise(rb_eArgError, "Wrong number of arguments: %d", argc); +#endif + } + return self; +} + +void +Init_gtk_gdk_selection(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGdk, "Selection"); + + RG_DEF_MODFUNC(owner_set, -1); + RG_DEF_MODFUNC(owner_get, -1); + RG_DEF_MODFUNC(convert, 4); + RG_DEF_MODFUNC(property_get, 1); + RG_DEF_MODFUNC(send_notify, -1); + + /* Constants */ + rb_define_const(RG_TARGET_NAMESPACE, "PRIMARY", GATOM2RVAL(GDK_SELECTION_PRIMARY)); + rb_define_const(RG_TARGET_NAMESPACE, "SECONDARY", GATOM2RVAL(GDK_SELECTION_SECONDARY)); + rb_define_const(RG_TARGET_NAMESPACE, "CLIPBOARD", GATOM2RVAL(GDK_SELECTION_CLIPBOARD)); + + /* GdkSelectionType */ + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_ATOM", GATOM2RVAL(GDK_SELECTION_TYPE_ATOM)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_BITMAP", GATOM2RVAL(GDK_SELECTION_TYPE_BITMAP)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_COLORMAP", GATOM2RVAL(GDK_SELECTION_TYPE_COLORMAP)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_DRAWABLE", GATOM2RVAL(GDK_SELECTION_TYPE_DRAWABLE)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_INTEGER", GATOM2RVAL(GDK_SELECTION_TYPE_INTEGER)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_PIXMAP", GATOM2RVAL(GDK_SELECTION_TYPE_PIXMAP)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_WINDOW", GATOM2RVAL(GDK_SELECTION_TYPE_WINDOW)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_STRING", GATOM2RVAL(GDK_SELECTION_TYPE_STRING)); + + /* GdkTarget */ + rb_define_const(RG_TARGET_NAMESPACE, "TARGET_BITMAP", GATOM2RVAL(GDK_TARGET_BITMAP)); + rb_define_const(RG_TARGET_NAMESPACE, "TARGET_COLORMAP", GATOM2RVAL(GDK_TARGET_COLORMAP)); + rb_define_const(RG_TARGET_NAMESPACE, "TARGET_DRAWABLE", GATOM2RVAL(GDK_TARGET_DRAWABLE)); + rb_define_const(RG_TARGET_NAMESPACE, "TARGET_PIXMAP", GATOM2RVAL(GDK_TARGET_PIXMAP)); + rb_define_const(RG_TARGET_NAMESPACE, "TARGET_STRING", GATOM2RVAL(GDK_TARGET_STRING)); + +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkthreads.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkthreads.c new file mode 100644 index 0000000..bce4b5a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkthreads.c @@ -0,0 +1,77 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#ifdef G_THREADS_ENABLED + +#define RG_TARGET_NAMESPACE mThreads + +static VALUE +rg_m_init(VALUE self) +{ +#ifndef GDK_WINDOWING_WIN32 + if (!g_thread_supported()){ + g_thread_init(NULL); + } + gdk_threads_init(); +#endif + return self; +} + +static VALUE +rg_m_enter(VALUE self) +{ + gdk_threads_enter(); + return self; +} + +static VALUE +rg_m_leave(VALUE self) +{ + gdk_threads_leave(); + return self; +} + +static VALUE +rg_m_synchronize(G_GNUC_UNUSED VALUE self) +{ + VALUE func = rb_block_proc(); + gdk_threads_enter(); + func = rb_block_proc(); + rb_funcall(func, id_call, 0); + gdk_threads_leave(); + return Qnil; +} +#endif + +void +Init_gtk_gdk_threads(VALUE mGdk) +{ +#ifdef G_THREADS_ENABLED + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGdk, "Threads"); + + RG_DEF_MODFUNC(init, 0); + RG_DEF_MODFUNC(enter, 0); + RG_DEF_MODFUNC(leave, 0); + RG_DEF_MODFUNC(synchronize, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdktimecoord.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdktimecoord.c new file mode 100644 index 0000000..b568dac --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdktimecoord.c @@ -0,0 +1,135 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTimeCoord +#define _SELF(s) ((GdkTimeCoord*)RVAL2BOXED(s, GDK_TYPE_TIME_COORD)) + +/**********************************/ +static GdkTimeCoord* +timecoord_copy(const GdkTimeCoord* val) +{ + GdkTimeCoord* new_val; + g_return_val_if_fail (val != NULL, NULL); + new_val = g_new(GdkTimeCoord, 1); + *new_val = *val; + return new_val; +} + +GType +gdk_timecoord_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("GdkTimeCoord", + (GBoxedCopyFunc)timecoord_copy, + (GBoxedFreeFunc)g_free); + return our_type; +} +/**********************************/ + +static VALUE +rg_initialize(VALUE self, VALUE rbtime, VALUE rbaxes) +{ + guint32 time = NUM2UINT(rbtime); + long n; + gdouble *axes = RVAL2GDOUBLES(rbaxes, n); + GdkTimeCoord *coord; + + if (n > GDK_MAX_TIMECOORD_AXES) { + g_free(axes); + + rb_raise(rb_eArgError, + "axes out of range: %ld (0..%d)", + n, GDK_MAX_TIMECOORD_AXES); + } + + coord = g_new(GdkTimeCoord, 1); + coord->time = time; + MEMCPY(coord->axes, axes, gdouble, n); + + g_free(axes); + + G_INITIALIZE(self, coord); + + return Qnil; +} + +static VALUE +rg_time(VALUE self) +{ + return UINT2NUM(_SELF(self)->time); +} + +static VALUE +rg_set_time(VALUE self, VALUE time) +{ + _SELF(self)->time = NUM2UINT(time); + return self; +} + +static VALUE +rg_axes(VALUE self) +{ + VALUE ary = rb_ary_new(); + int i; + for (i = 0; i < GDK_MAX_TIMECOORD_AXES; i++){ + rb_ary_push(ary, rb_float_new(_SELF(self)->axes[i])); + } + return ary; +} + +static VALUE +rg_set_axes(VALUE self, VALUE rbaxes) +{ + GdkTimeCoord *coord = _SELF(self); + VALUE axes = rb_ary_to_ary(rbaxes); + long i; + long n = RARRAY_LEN(axes); + + if (n < 0 || n > GDK_MAX_TIMECOORD_AXES) + rb_raise(rb_eArgError, + "axes out of range: %ld (0..%d)", + n, GDK_MAX_TIMECOORD_AXES); + + for (i = 0; i < n; i++) + coord->axes[i] = NUM2DBL(RARRAY_PTR(axes)[i]); + + return self; +} + +void +Init_gtk_gdk_timecoord(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_TIME_COORD, "TimeCoord", mGdk); + + RG_DEF_METHOD(initialize, 2); + RG_DEF_METHOD(time, 0); + RG_DEF_METHOD(set_time, 1); + RG_DEF_METHOD(axes, 0); + RG_DEF_METHOD(set_axes, 1); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + + rb_define_const(RG_TARGET_NAMESPACE, "MAX_AXES", INT2NUM(GDK_MAX_TIMECOORD_AXES)); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkvisual.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkvisual.c new file mode 100644 index 0000000..95b8989 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkvisual.c @@ -0,0 +1,256 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Masao Mutoh + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cVisual +#define _SELF(self) (GDK_VISUAL(RVAL2GOBJ(self))) + +static VALUE +rg_s_query_depths(G_GNUC_UNUSED VALUE self) +{ + gint *depth; + gint count; + VALUE ary; + int i; + + gdk_query_depths(&depth, &count); + ary = rb_ary_new2(count); + for (i = 0; i < count; i++) { + rb_ary_push(ary, INT2NUM((depth)[i])); + } + return ary; +} + +static VALUE +rg_s_query_visual_types(G_GNUC_UNUSED VALUE self) +{ + GdkVisualType *visual_types; + gint count; + VALUE ary; + int i; + + gdk_query_visual_types(&visual_types, &count); + ary = rb_ary_new2(count); + for (i = 0; i < count; i++) { + rb_ary_push(ary, GENUM2RVAL((visual_types)[i], GDK_TYPE_VISUAL_TYPE)); + } + return ary; +} + +static VALUE +rg_s_visuals(G_GNUC_UNUSED VALUE self) +{ + GList *list = gdk_list_visuals(), *cur; + VALUE ary = rb_ary_new(); + + for (cur = list; cur != NULL; cur = cur->next) { + rb_ary_push(ary, GOBJ2RVAL((GdkVisual *)cur->data)); + } + g_list_free(list); + return ary; +} + +static VALUE +rg_s_best_depth(G_GNUC_UNUSED VALUE self) +{ + return INT2NUM(gdk_visual_get_best_depth()); +} + +static VALUE +rg_s_best_type(G_GNUC_UNUSED VALUE self) +{ + return INT2NUM(gdk_visual_get_best_type()); +} + +static VALUE +rg_s_system(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(gdk_visual_get_system()); +} + +static VALUE +rg_s_best(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(gdk_visual_get_best()); +} + +static VALUE +rg_s_best_with_depth(G_GNUC_UNUSED VALUE self, VALUE depth) +{ + return GOBJ2RVAL(gdk_visual_get_best_with_depth(NUM2INT(depth))); +} + +static VALUE +rg_s_best_with_type(G_GNUC_UNUSED VALUE self, VALUE type) +{ + return GOBJ2RVAL(gdk_visual_get_best_with_depth( + (GdkVisualType)GENUM2RVAL(type, GDK_TYPE_VISUAL_TYPE))); +} + +static VALUE +rg_s_best_with_both(G_GNUC_UNUSED VALUE self, VALUE depth, VALUE type) +{ + return GOBJ2RVAL(gdk_visual_get_best_with_both( + NUM2INT(depth), + (GdkVisualType)RVAL2GENUM(type, GDK_TYPE_VISUAL_TYPE))); +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_screen(VALUE self) +{ + return GOBJ2RVAL(gdk_visual_get_screen(_SELF(self))); +} +#endif + +/* Structure accessors */ +static VALUE +rg_visual_type(VALUE self) +{ + return GENUM2RVAL(_SELF(self)->type, GDK_TYPE_VISUAL_TYPE); +} + +static VALUE +rg_depth(VALUE self) +{ + return INT2FIX(_SELF(self)->depth); +} + +static VALUE +rg_byte_order(VALUE self) +{ + return GENUM2RVAL(_SELF(self)->byte_order, GDK_TYPE_BYTE_ORDER); +} + +static VALUE +rg_colormap_size(VALUE self) +{ + return INT2FIX(_SELF(self)->colormap_size); +} + +static VALUE +rg_bits_per_rgb(VALUE self) +{ + return INT2FIX(_SELF(self)->bits_per_rgb); +} + +static VALUE +rg_red_mask(VALUE self) +{ + return INT2FIX(_SELF(self)->red_mask); +} + +static VALUE +rg_red_shift(VALUE self) +{ + return INT2FIX(_SELF(self)->red_shift); +} + +static VALUE +rg_red_prec(VALUE self) +{ + return INT2FIX(_SELF(self)->red_prec); +} + +static VALUE +rg_green_mask(VALUE self) +{ + return INT2FIX(_SELF(self)->green_mask); +} + +static VALUE +rg_green_shift(VALUE self) +{ + return INT2FIX(_SELF(self)->green_shift); +} + +static VALUE +rg_green_prec(VALUE self) +{ + return INT2FIX(_SELF(self)->green_prec); +} + +static VALUE +rg_blue_mask(VALUE self) +{ + return INT2FIX(_SELF(self)->blue_mask); +} + +static VALUE +rg_blue_shift(VALUE self) +{ + return INT2FIX(_SELF(self)->blue_shift); +} + +static VALUE +rg_blue_prec(VALUE self) +{ + return INT2FIX(_SELF(self)->blue_prec); +} + +void +Init_gtk_gdk_visual(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_VISUAL, "Visual", mGdk); + + /* class methods */ + RG_DEF_SMETHOD(query_depths, 0); + RG_DEF_SMETHOD(query_visual_types, 0); + RG_DEF_SMETHOD(visuals, 0); + RG_DEF_SMETHOD(best_depth, 0); + RG_DEF_SMETHOD(best_type, 0); + RG_DEF_SMETHOD(system, 0); + RG_DEF_SMETHOD(best, 0); + RG_DEF_SMETHOD(best_with_depth, 1); + RG_DEF_SMETHOD(best_with_type, 1); + RG_DEF_SMETHOD(best_with_both, 2); + + /* instance methods */ +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(screen, 0); +#endif + RG_DEF_METHOD(visual_type, 0); + RG_DEF_METHOD(depth, 0); + RG_DEF_METHOD(byte_order, 0); + RG_DEF_METHOD(colormap_size, 0); + RG_DEF_METHOD(bits_per_rgb, 0); + RG_DEF_METHOD(red_mask, 0); + RG_DEF_METHOD(red_shift, 0); + RG_DEF_METHOD(red_prec, 0); + RG_DEF_METHOD(green_mask, 0); + RG_DEF_METHOD(green_shift, 0); + RG_DEF_METHOD(green_prec, 0); + RG_DEF_METHOD(blue_mask, 0); + RG_DEF_METHOD(blue_shift, 0); + RG_DEF_METHOD(blue_prec, 0); + + /* GdkVisualType */ + G_DEF_CLASS(GDK_TYPE_VISUAL_TYPE, "Type", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_VISUAL_TYPE, "GDK_VISUAL_"); + + /* GdkByteOrder */ + G_DEF_CLASS(GDK_TYPE_BYTE_ORDER, "ByteOrder", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_BYTE_ORDER, "GDK_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkwindow.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkwindow.c new file mode 100644 index 0000000..d764599 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkwindow.c @@ -0,0 +1,1178 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cWindow +#define _SELF(s) GDK_WINDOW(RVAL2GOBJ(s)) + +static VALUE +rg_initialize(VALUE self, VALUE parent, VALUE attributes, VALUE attributes_mask) +{ + GdkWindow* win; + win = gdk_window_new(NIL_P(parent) ? NULL : _SELF(parent), + (GdkWindowAttr*)RVAL2BOXED(attributes, + GDK_TYPE_WINDOW_ATTR), + RVAL2GFLAGS(attributes_mask, + GDK_TYPE_WINDOW_ATTRIBUTES_TYPE)); + G_INITIALIZE(self, win); + + return Qnil; +} + +static VALUE +rg_destroy(VALUE self) +{ + gdk_window_destroy(_SELF(self)); + return Qnil; +} + +static VALUE +rg_window_type(VALUE self) +{ + return GENUM2RVAL(gdk_window_get_window_type(_SELF(self)), GDK_TYPE_WINDOW_TYPE); +} + +static VALUE +rg_s_at_pointer(G_GNUC_UNUSED VALUE self) +{ + gint x, y; + GdkWindow* win = gdk_window_at_pointer(&x, &y); + return rb_ary_new3(3, GOBJ2RVAL(win), INT2FIX(x), INT2FIX(y)); +} + +static VALUE +rg_show(VALUE self) +{ + gdk_window_show(_SELF(self)); + return self; +} + +static VALUE +rg_show_unraised(VALUE self) +{ + gdk_window_show_unraised(_SELF(self)); + return self; +} + +static VALUE +rg_hide(VALUE self) +{ + gdk_window_hide(_SELF(self)); + return Qnil; +} + +static VALUE +rg_visible_p(VALUE self) +{ + return CBOOL2RVAL(gdk_window_is_visible(_SELF(self))); +} + +static VALUE +rg_viewable_p(VALUE self) +{ + return CBOOL2RVAL(gdk_window_is_viewable(_SELF(self))); +} + +static VALUE +rg_state(VALUE self) +{ + return GENUM2RVAL(gdk_window_get_state(_SELF(self)), GDK_TYPE_WINDOW_STATE); +} + +static VALUE +rg_withdraw(VALUE self) +{ + gdk_window_withdraw(_SELF(self)); + return Qnil; +} + +static VALUE +rg_iconify(VALUE self) +{ + gdk_window_iconify(_SELF(self)); + return self; +} + +static VALUE +rg_deiconify(VALUE self) +{ + gdk_window_deiconify(_SELF(self)); + return self; +} + +static VALUE +rg_stick(VALUE self) +{ + gdk_window_stick(_SELF(self)); + return self; +} + +static VALUE +rg_unstick(VALUE self) +{ + gdk_window_unstick(_SELF(self)); + return self; +} + +static VALUE +rg_maximize(VALUE self) +{ + gdk_window_maximize(_SELF(self)); + return self; +} + +static VALUE +rg_unmaximize(VALUE self) +{ + gdk_window_unmaximize(_SELF(self)); + return self; +} +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_fullscreen(VALUE self) +{ + gdk_window_fullscreen(_SELF(self)); + return self; +} + +static VALUE +rg_unfullscreen(VALUE self) +{ + gdk_window_unfullscreen(_SELF(self)); + return self; +} +#endif +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_set_keep_above(VALUE self, VALUE setting) +{ + gdk_window_set_keep_above(_SELF(self), RVAL2CBOOL(setting)); + return self; +} + +static VALUE +rg_set_keep_below(VALUE self, VALUE setting) +{ + gdk_window_set_keep_below(_SELF(self), RVAL2CBOOL(setting)); + return self; +} +#endif + +static VALUE +rg_move(VALUE self, VALUE x, VALUE y) +{ + gdk_window_move(_SELF(self), NUM2INT(x), NUM2INT(y)); + return self; +} + +static VALUE +rg_resize(VALUE self, VALUE w, VALUE h) +{ + gdk_window_resize(_SELF(self), NUM2INT(w), NUM2INT(h)); + return self; +} + +static VALUE +rg_move_resize(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h) +{ + gdk_window_move_resize(_SELF(self), NUM2INT(x), NUM2INT(y), NUM2INT(w), NUM2INT(h)); + return self; +} + +static VALUE +rg_scroll(VALUE self, VALUE dx, VALUE dy) +{ + gdk_window_scroll(_SELF(self), NUM2INT(dx), NUM2INT(dy)); + return self; +} + +#if GTK_CHECK_VERSION(2,8,0) +static VALUE +rg_move_region(VALUE self, VALUE region, VALUE dx, VALUE dy) +{ + gdk_window_move_region(_SELF(self), + (GdkRegion*)RVAL2BOXED(region, GDK_TYPE_REGION), + NUM2INT(dx), + NUM2INT(dy)); + return self; +} +#endif + +static VALUE +rg_reparent(VALUE self, VALUE new_parent, VALUE x, VALUE y) +{ + gdk_window_reparent(_SELF(self), _SELF(new_parent), NUM2INT(x), NUM2INT(y)); + return self; +} + +static VALUE +rg_clear(VALUE self) +{ + gdk_window_clear(_SELF(self)); + return self; +} + +static VALUE +rg_clear_area(int argc, VALUE *argv, VALUE self) +{ + VALUE gen_expose, x, y, w, h; + rb_scan_args(argc, argv, "41", &x, &y, &w, &h, &gen_expose); + + if (! NIL_P(gen_expose) && RVAL2CBOOL(gen_expose)){ + gdk_window_clear_area_e(_SELF(self), + NUM2INT(x), NUM2INT(y), NUM2INT(w), NUM2INT(h)); + } else { + gdk_window_clear_area(_SELF(self), + NUM2INT(x), NUM2INT(y), NUM2INT(w), NUM2INT(h)); + } + return self; +} + +static VALUE +rg_raise(VALUE self) +{ + gdk_window_raise(_SELF(self)); + return self; +} + +static VALUE +rg_lower(VALUE self) +{ + gdk_window_lower(_SELF(self)); + return self; +} + +static VALUE +rg_focus(VALUE self, VALUE timestamp) +{ + gdk_window_focus(_SELF(self), NUM2UINT(timestamp)); + return self; +} + +static VALUE +rg_register_dnd(VALUE self) +{ + gdk_window_register_dnd(_SELF(self)); + return self; +} + +static VALUE +rg_begin_resize_drag(VALUE self, VALUE edge, VALUE button, VALUE root_x, VALUE root_y, VALUE timestamp) +{ + gdk_window_begin_resize_drag(_SELF(self), + RVAL2GENUM(edge, GDK_TYPE_WINDOW_EDGE), + NUM2INT(button), + NUM2INT(root_x), NUM2INT(root_y), + NUM2UINT(timestamp)); + return self; +} + +static VALUE +rg_begin_move_drag(VALUE self, VALUE button, VALUE root_x, VALUE root_y, VALUE timestamp) +{ + gdk_window_begin_move_drag(_SELF(self), NUM2INT(button), + NUM2INT(root_x), NUM2INT(root_y), + NUM2UINT(timestamp)); + return self; +} + +static VALUE +rg_s_constrain_size(G_GNUC_UNUSED VALUE self, VALUE geometry, VALUE flags, VALUE w, VALUE h) +{ + gint new_width, new_height; + gdk_window_constrain_size((GdkGeometry*)RVAL2BOXED(geometry, GDK_TYPE_GEOMETRY), + RVAL2GFLAGS(flags, GDK_TYPE_WINDOW_HINTS), + NUM2INT(w), NUM2INT(h), &new_width, &new_height); + return rb_assoc_new(INT2NUM(new_width), INT2NUM(new_height)); +} + +#if GTK_CHECK_VERSION(2, 12, 0) +static VALUE +rg_beep(VALUE self) +{ + gdk_window_beep(_SELF(self)); + return self; +} +#endif + +static VALUE +rg_begin_paint(VALUE self, VALUE area) +{ + if (rb_obj_is_kind_of(area, GTYPE2CLASS(GDK_TYPE_RECTANGLE))){ + gdk_window_begin_paint_rect(_SELF(self), + (GdkRectangle*)RVAL2BOXED(area, GDK_TYPE_RECTANGLE)); + } else { + gdk_window_begin_paint_region(_SELF(self), + (GdkRegion*)RVAL2BOXED(area, GDK_TYPE_REGION)); + } + return self; +} + +static VALUE +rg_end_paint(VALUE self) +{ + gdk_window_end_paint(_SELF(self)); + return self; +} + +static VALUE +rg_invalidate(VALUE self, VALUE area, VALUE invalidate_children) +{ + if (rb_obj_is_kind_of(area, GTYPE2CLASS(GDK_TYPE_REGION))){ + gdk_window_invalidate_region(_SELF(self), + RVAL2BOXED(area, GDK_TYPE_REGION), + RVAL2CBOOL(invalidate_children)); + } else { + gdk_window_invalidate_rect(_SELF(self), + RVAL2BOXED(area, GDK_TYPE_RECTANGLE), + RVAL2CBOOL(invalidate_children)); + } + return self; +} + +static gboolean +invalidate_child_func_wrap(GdkWindow *window, VALUE func) +{ + VALUE result = rb_funcall(func, id_call, 1, GOBJ2RVAL(window)); + return RVAL2CBOOL(result); +} + +typedef gboolean (*ChildFunc) (GdkWindow*, gpointer); + +static VALUE +rg_invalidate_maybe_recurse(VALUE self, VALUE region) +{ + VALUE func = (VALUE)NULL; + if (rb_block_given_p()){ + func = rb_block_proc(); + G_RELATIVE(self, func); + } + gdk_window_invalidate_maybe_recurse(_SELF(self), + RVAL2BOXED(region, GDK_TYPE_REGION), + (ChildFunc)invalidate_child_func_wrap, + (gpointer)func); + return self; +} + +static VALUE +rg_update_area(VALUE self) +{ + GdkRegion* ret = gdk_window_get_update_area(_SELF(self)); + return BOXED2RVAL(ret, GDK_TYPE_REGION); +} + +static VALUE +rg_freeze_updates(VALUE self) +{ + gdk_window_freeze_updates(_SELF(self)); + return self; +} + +static VALUE +rg_thaw_updates(VALUE self) +{ + gdk_window_thaw_updates(_SELF(self)); + return self; +} + +static VALUE +rg_s_process_all_updates(VALUE self) +{ + gdk_window_process_all_updates(); + return self; +} + +static VALUE +rg_process_updates(VALUE self, VALUE update_children) +{ + gdk_window_process_updates(_SELF(self), RVAL2CBOOL(update_children)); + return self; +} + +static VALUE +rg_s_set_debug_updates(VALUE self, VALUE setting) +{ + gdk_window_set_debug_updates(RVAL2CBOOL(setting)); + return self; +} + +static VALUE +rg_internal_paint_info(VALUE self) +{ + GdkDrawable* real_drawable; + gint x_offset, y_offset; + + gdk_window_get_internal_paint_info(_SELF(self), &real_drawable, + &x_offset, &y_offset); + return rb_ary_new3(3, GOBJ2RVAL(real_drawable), + INT2NUM(x_offset), INT2NUM(y_offset)); +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_configure_finished(VALUE self) +{ + gdk_window_configure_finished(_SELF(self)); + return self; +} + +static VALUE +rg_enable_synchronized_configure(VALUE self) +{ + gdk_window_enable_synchronized_configure(_SELF(self)); + + if (rb_block_given_p()) { + rb_ensure(rb_yield, self, rg_configure_finished, self); + } + return self; +} +#endif + +static VALUE +rg_set_user_data(VALUE self, VALUE user_data) +{ + gdk_window_set_user_data(_SELF(self), (gpointer)RVAL2GOBJ(user_data)); + return self; +} + +static VALUE +rg_set_override_redirect(VALUE self, VALUE override_redirect) +{ + gdk_window_set_override_redirect(_SELF(self), + RVAL2CBOOL(override_redirect)); + return self; +} + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_set_accept_focus(VALUE self, VALUE accept_focus) +{ + gdk_window_set_accept_focus(_SELF(self), RVAL2CBOOL(accept_focus)); + return self; +} +#endif + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_set_focus_on_map(VALUE self, VALUE focus_on_map) +{ + gdk_window_set_focus_on_map(_SELF(self), RVAL2CBOOL(focus_on_map)); + return self; +} +#endif + +/* GdkXEvent is not implemented. + void gdk_window_add_filter (GdkWindow *window, + GdkFilterFunc function, + gpointer data); + void gdk_window_remove_filter (GdkWindow *window, + GdkFilterFunc function, + gpointer data); + GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent, + GdkEvent *event, + gpointer data); +*/ + +static VALUE +rg_shape_combine_mask(VALUE self, VALUE shape_mask, VALUE offset_x, VALUE offset_y) +{ + gdk_window_shape_combine_mask(_SELF(self), + GDK_BITMAP(RVAL2GOBJ(shape_mask)), + NUM2INT(offset_x), NUM2INT(offset_y)); + return self; +} + +static VALUE +rg_shape_combine_region(VALUE self, VALUE shape_region, VALUE offset_x, VALUE offset_y) +{ + gdk_window_shape_combine_region(_SELF(self), + NIL_P(shape_region) ? NULL : (GdkRegion*)RVAL2BOXED(shape_region, GDK_TYPE_REGION), + INT2NUM(offset_x), INT2NUM(offset_y)); + return self; +} + +static VALUE +rg_set_child_shapes(VALUE self) +{ + gdk_window_set_child_shapes(_SELF(self)); + return self; +} + +static VALUE +rg_merge_child_shapes(VALUE self) +{ + gdk_window_merge_child_shapes(_SELF(self)); + return self; +} + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_input_shape_combine_mask(VALUE self, VALUE mask, VALUE x, VALUE y) +{ + gdk_window_input_shape_combine_mask(_SELF(self), + GDK_BITMAP(RVAL2GOBJ(mask)), + NUM2INT(x), NUM2INT(y)); + return self; +} + +static VALUE +rg_input_shape_combine_region(VALUE self, VALUE shape_region, VALUE offset_x, VALUE offset_y) +{ + gdk_window_input_shape_combine_region(_SELF(self), + (GdkRegion*)RVAL2BOXED(shape_region, GDK_TYPE_REGION), + NUM2INT(offset_x), + NUM2INT(offset_y)); + return self; +} + +static VALUE +rg_set_child_input_shapes(VALUE self) +{ + gdk_window_set_child_input_shapes(_SELF(self)); + return self; +} + +static VALUE +rg_merge_child_input_shapes(VALUE self) +{ + gdk_window_merge_child_input_shapes(_SELF(self)); + return self; +} + +#endif + +static VALUE +rg_set_static_gravities(VALUE self, VALUE use_static) +{ + gboolean ret = gdk_window_set_static_gravities(_SELF(self), + RVAL2CBOOL(use_static)); + if (! ret) + rb_raise(rb_eRuntimeError, "couldn't turn on static gravity"); + + return self; +} + +static VALUE +rg_set_title(VALUE self, VALUE title) +{ + gdk_window_set_title(_SELF(self),RVAL2CSTR(title)); + return self; +} + +static VALUE +rg_set_background(VALUE self, VALUE color) +{ + gdk_window_set_background(_SELF(self), RVAL2GDKCOLOR(color)); + return self; +} + +static VALUE +rg_set_back_pixmap(VALUE self, VALUE pixmap, VALUE parent_relative) +{ + gdk_window_set_back_pixmap(_SELF(self), + GDK_PIXMAP(RVAL2GOBJ(pixmap)), + RVAL2CBOOL(parent_relative)); + return self; +} + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_set_cursor(VALUE self, VALUE cursor) +{ + gdk_window_set_cursor(_SELF(self), + RVAL2BOXED(cursor, GDK_TYPE_CURSOR)); + return self; +} +#endif + +static VALUE +rg_user_data(VALUE self) +{ + GObject *data = NULL; + gdk_window_get_user_data(_SELF(self), (gpointer)&data); + return GOBJ2RVAL(data); +} + +static VALUE +rg_geometry(VALUE self) +{ + gint x, y, w, h, d; + gdk_window_get_geometry(_SELF(self), &x, &y, &w, &h, &d); + return rb_ary_new3(5, INT2NUM(x), INT2NUM(y), + INT2NUM(w), INT2NUM(h), INT2NUM(d)); +} + +static VALUE +rg_set_geometry_hints(VALUE self, VALUE geometry, VALUE geom_mask) +{ + gdk_window_set_geometry_hints(_SELF(self), + NIL_P(geometry) ? (GdkGeometry*)NULL : (GdkGeometry*)RVAL2BOXED(geometry, GDK_TYPE_GEOMETRY), + RVAL2GFLAGS(geom_mask, GDK_TYPE_WINDOW_HINTS)); + return self; +} + +static VALUE +rg_set_icon_list(VALUE self, VALUE rbpixbufs) +{ + GdkWindow *window = _SELF(self); + GList *pixbufs = RVAL2GDKPIXBUFGLIST(rbpixbufs); + + gdk_window_set_icon_list(window, pixbufs); + + g_list_free(pixbufs); + + return self; +} + +static VALUE +rg_set_modal_hint(VALUE self, VALUE modal) +{ + gdk_window_set_modal_hint(_SELF(self), RVAL2CBOOL(modal)); + return self; +} + +static VALUE +rg_set_type_hint(VALUE self, VALUE hint) +{ + gdk_window_set_type_hint(_SELF(self), RVAL2GENUM(hint, GDK_TYPE_WINDOW_TYPE_HINT)); + return self; +} + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_type_hint(VALUE self) +{ + return GENUM2RVAL(gdk_window_get_type_hint(_SELF(self)), GDK_TYPE_WINDOW_TYPE_HINT); +} +#endif + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_set_skip_taskbar_hint(VALUE self, VALUE hint) +{ + gdk_window_set_skip_taskbar_hint(_SELF(self), RVAL2CBOOL(hint)); + return self; +} + +static VALUE +rg_set_skip_pager_hint(VALUE self, VALUE hint) +{ + gdk_window_set_skip_pager_hint(_SELF(self), RVAL2CBOOL(hint)); + return self; +} +#endif + +#if GTK_CHECK_VERSION(2,8,0) +static VALUE +rg_set_urgency_hint(VALUE self, VALUE hint) +{ + gdk_window_set_urgency_hint(_SELF(self), RVAL2CBOOL(hint)); + return self; +} +#endif + +static VALUE +rg_position(VALUE self) +{ + gint x, y; + gdk_window_get_position(_SELF(self), &x, &y); + return rb_assoc_new(INT2NUM(x), INT2NUM(y)); +} + +static VALUE +rg_root_origin(VALUE self) +{ + int x, y; + gdk_window_get_root_origin(_SELF(self), &x, &y); + return rb_assoc_new(INT2FIX(x), INT2FIX(y)); +} + +static VALUE +rg_frame_extents(VALUE self) +{ + GdkRectangle rect; + gdk_window_get_frame_extents(_SELF(self), &rect); + return BOXED2RVAL(&rect, GDK_TYPE_RECTANGLE); +} + +static VALUE +rg_origin(VALUE self) +{ + gint x, y; + gdk_window_get_origin(_SELF(self), &x, &y); + return rb_assoc_new(INT2NUM(x), INT2NUM(y)); +} + +static VALUE +rg_pointer(VALUE self) +{ + gint x, y; + GdkModifierType state; + GdkWindow* ret = gdk_window_get_pointer(_SELF(self), &x, &y, &state); + return rb_ary_new3(4, GOBJ2RVAL(ret), INT2NUM(x), INT2NUM(y), GFLAGS2RVAL(state, GDK_TYPE_MODIFIER_TYPE)); +} + +static VALUE +rg_parent(VALUE self) +{ + return GOBJ2RVAL(gdk_window_get_parent(_SELF(self))); +} + +static VALUE +rg_toplevel(VALUE self) +{ + return GOBJ2RVAL(gdk_window_get_toplevel(_SELF(self))); +} + +static VALUE +rg_children(VALUE self) +{ + /* Don't use gdk_window_get_children() here */ + GList* list = gdk_window_peek_children(_SELF(self)); + VALUE ary = rb_ary_new(); + while (list) { + rb_ary_push(ary, GOBJ2RVAL(list->data)); + list = list->next; + } + return ary; +} + +static VALUE +rg_events(VALUE self) +{ + return GFLAGS2RVAL(gdk_window_get_events(_SELF(self)), GDK_TYPE_EVENT_MASK); +} + +static VALUE +rg_set_events(VALUE self, VALUE mask) +{ + gdk_window_set_events(_SELF(self), RVAL2GFLAGS(mask, GDK_TYPE_EVENT_MASK)); + return self; +} + +static VALUE +rg_set_icon(VALUE self, VALUE icon, VALUE pixmap, VALUE mask) +{ + gdk_window_set_icon(_SELF(self), NIL_P(icon) ? NULL :_SELF(icon), + NIL_P(pixmap) ? NULL : GDK_PIXMAP(RVAL2GOBJ(pixmap)), + NIL_P(mask) ? NULL : GDK_BITMAP(RVAL2GOBJ(mask))); + return self; +} + +static VALUE +rg_set_icon_name(VALUE self, VALUE name) +{ + gdk_window_set_icon_name(_SELF(self), RVAL2CSTR(name)); + return self; +} + +static VALUE +rg_set_transient_for(VALUE self, VALUE parent) +{ + gdk_window_set_transient_for(_SELF(self), _SELF(parent)); + return self; +} + +static VALUE +rg_set_role(VALUE self, VALUE role) +{ + gdk_window_set_role(_SELF(self), RVAL2CSTR(role)); + return self; +} + +static VALUE +rg_set_group(VALUE self, VALUE leader) +{ + gdk_window_set_group(_SELF(self), _SELF(leader)); + return self; +} + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_group(VALUE self) +{ + return GOBJ2RVAL(gdk_window_get_group(_SELF(self))); +} +#endif + +static VALUE +rg_set_decorations(VALUE self, VALUE decor) +{ + gdk_window_set_decorations(_SELF(self), RVAL2GFLAGS(decor, GDK_TYPE_WM_DECORATION)); + return self; +} + +static VALUE +rg_decorations(VALUE self) +{ + GdkWMDecoration decorations; + gboolean ret = gdk_window_get_decorations(_SELF(self), &decorations); + return ret ? GFLAGS2RVAL(decorations, GDK_TYPE_WM_DECORATION) : Qnil; +} + +static VALUE +rg_set_functions(VALUE self, VALUE func) +{ + gdk_window_set_functions(_SELF(self), RVAL2GFLAGS(func, GDK_TYPE_WM_FUNCTION)); + return self; +} + +#if GTK_CHECK_VERSION(2, 12, 0) +static VALUE +rg_set_composited(VALUE self, VALUE composited) +{ + gdk_window_set_composited(_SELF(self), RVAL2CBOOL(composited)); + return self; +} + +static VALUE +rg_set_opacity(VALUE self, VALUE opacity) +{ + gdk_window_set_opacity(_SELF(self), NUM2DBL(opacity)); + return self; +} + +static VALUE +rg_set_startup_id(VALUE self, VALUE startup_id) +{ + gdk_window_set_startup_id(_SELF(self), RVAL2CSTR_ACCEPT_NIL(startup_id)); + return self; +} +#endif + +static VALUE +rg_s_toplevels(G_GNUC_UNUSED VALUE self) +{ + return GLIST2ARYF(gdk_window_get_toplevels()); +} + +static VALUE +rg_s_default_root_window(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(gdk_get_default_root_window()); +} + +/* Would you need this? +GdkPointerHooks* gdk_set_pointer_hooks (const GdkPointerHooks *new_hooks); +*/ + +/* From X Window System Interaction */ +static VALUE +rg_s_foreign_new(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE arg[2]; + GdkWindow * win = NULL; + + rb_scan_args(argc, argv, "11", &arg[0], &arg[1]); + + switch(argc) + { + case 1: + win = gdk_window_foreign_new(RVAL2GDKNATIVEWINDOW(arg[0])); + break; + case 2: +#if GTK_CHECK_VERSION(2,2,0) + win = gdk_window_foreign_new_for_display(RVAL2GOBJ(arg[0]), + RVAL2GDKNATIVEWINDOW(arg[1])); +#else + win = gdk_window_foreign_new(NUM2UINT(arg[1])); + rb_warn("Not supported in GTK+-2.0.x."); +#endif + break; + default: + break; + } + if (win == NULL) + return Qnil; + else { + return GOBJ2RVAL(win); + } +} + +static VALUE +rg_s_lookup(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE arg[2]; + GdkWindow * win = NULL; + + rb_scan_args(argc, argv, "11", &arg[0], &arg[1]); + + switch(argc) + { + case 1: + win = gdk_window_lookup(RVAL2GDKNATIVEWINDOW(arg[0])); + break; + case 2: +#if GTK_CHECK_VERSION(2,2,0) + win = gdk_window_lookup_for_display(RVAL2GOBJ(arg[0]), RVAL2GDKNATIVEWINDOW(arg[1])); +#else + win = gdk_window_lookup(NUM2UINT(arg[1])); + rb_warn("Not supported in GTK+-2.0.x."); +#endif + break; + default: + break; + } + if (win == NULL) + return Qnil; + else { + return GOBJ2RVAL(win); + } +} + +#ifdef GDK_WINDOWING_X11 +static VALUE +rg_server_time(VALUE self) +{ + return UINT2NUM(gdk_x11_get_server_time(_SELF(self))); +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_set_user_time(VALUE self, VALUE time) +{ + gdk_x11_window_set_user_time(_SELF(self), NUM2UINT(time)); + return Qnil; +} +#endif + +#if GTK_CHECK_VERSION(2,8,0) +static VALUE +rg_move_to_current_desktop(VALUE self) +{ + gdk_x11_window_move_to_current_desktop(_SELF(self)); + return self; +} +#endif + +#endif + +void +Init_gtk_gdk_window(VALUE mGdk) +{ + GObjectClass *g_class; + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_WINDOW, "Window", mGdk); + + g_class = g_type_class_peek(GDK_TYPE_WINDOW); + + RG_DEF_METHOD(initialize, 3); + RG_DEF_METHOD(destroy, 0); + RG_DEF_METHOD(window_type, 0); + RG_DEF_SMETHOD(at_pointer, 0); + RG_DEF_SMETHOD(constrain_size, 4); + RG_DEF_SMETHOD(process_all_updates, 0); + RG_DEF_SMETHOD(set_debug_updates, 1); + RG_DEF_METHOD(show, 0); + RG_DEF_METHOD(show_unraised, 0); + RG_DEF_METHOD(hide, 0); + RG_DEF_METHOD_P(visible, 0); + RG_DEF_METHOD_P(viewable, 0); + RG_DEF_METHOD(withdraw, 0); + RG_DEF_METHOD(state, 0); + RG_DEF_METHOD(iconify, 0); + RG_DEF_METHOD(deiconify, 0); + RG_DEF_METHOD(stick, 0); + RG_DEF_METHOD(unstick, 0); + RG_DEF_METHOD(maximize, 0); + RG_DEF_METHOD(unmaximize, 0); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(fullscreen, 0); + RG_DEF_METHOD(unfullscreen, 0); +#endif +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(set_keep_above, 1); + RG_DEF_METHOD(set_keep_below, 1); +#endif + RG_DEF_METHOD(move, 2); + RG_DEF_METHOD(resize, 2); + RG_DEF_METHOD(move_resize, 4); + RG_DEF_METHOD(scroll, 2); +#if GTK_CHECK_VERSION(2,8,0) + RG_DEF_METHOD(move_region, 3); +#endif + RG_DEF_METHOD(reparent, 3); + RG_DEF_METHOD(clear, 0); + RG_DEF_METHOD(clear_area, -1); + RG_DEF_METHOD(raise, 0); + RG_DEF_METHOD(lower, 0); + RG_DEF_METHOD(focus, 1); + RG_DEF_METHOD(register_dnd, 0); +#if GTK_CHECK_VERSION(2, 12, 0) + RG_DEF_METHOD(beep, 0); +#endif + RG_DEF_METHOD(begin_resize_drag, 5); + RG_DEF_METHOD(begin_move_drag, 4); + RG_DEF_METHOD(begin_paint, 1); + RG_DEF_METHOD(end_paint, 0); + RG_DEF_METHOD(invalidate, 2); + RG_DEF_METHOD(invalidate_maybe_recurse, 1); + RG_DEF_METHOD(update_area, 0); + RG_DEF_METHOD(freeze_updates, 0); + RG_DEF_METHOD(thaw_updates, 0); + RG_DEF_METHOD(process_updates, 1); + RG_DEF_METHOD(internal_paint_info, 0); +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(configure_finished, 0); + RG_DEF_METHOD(enable_synchronized_configure, 0); +#endif + RG_DEF_METHOD(set_user_data, 1); + RG_DEF_METHOD(set_override_redirect, 1); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(set_accept_focus, 1); +#endif +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(set_focus_on_map, 1); +#endif + RG_DEF_METHOD(shape_combine_mask, 3); + RG_DEF_METHOD(shape_combine_region, 3); + RG_DEF_METHOD(set_child_shapes, 0); + RG_DEF_METHOD(merge_child_shapes, 0); +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD(input_shape_combine_mask, 3); + RG_DEF_METHOD(input_shape_combine_region, 3); + RG_DEF_METHOD(set_child_input_shapes, 0); + RG_DEF_METHOD(merge_child_input_shapes, 0); +#endif + RG_DEF_METHOD(set_static_gravities, 1); + RG_DEF_METHOD(set_title, 1); + RG_DEF_METHOD(set_background, 1); + RG_DEF_METHOD(set_back_pixmap, 2); +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD(set_cursor, 1); +#endif + RG_DEF_METHOD(user_data, 0); + RG_DEF_METHOD(geometry, 0); + RG_DEF_METHOD(set_geometry_hints, 2); + RG_DEF_METHOD(set_icon_list, 1); + RG_DEF_METHOD(set_modal_hint, 1); + RG_DEF_METHOD(set_type_hint, 1); +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD(type_hint, 0); +#endif + +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(set_skip_taskbar_hint, 1); + RG_DEF_METHOD(set_skip_pager_hint, 1); +#endif +#if GTK_CHECK_VERSION(2,8,0) + RG_DEF_METHOD(set_urgency_hint, 1); +#endif + RG_DEF_METHOD(position, 0); + RG_DEF_METHOD(root_origin, 0); + RG_DEF_METHOD(frame_extents, 0); + RG_DEF_METHOD(origin, 0); + RG_DEF_METHOD(pointer, 0); + RG_DEF_METHOD(parent, 0); + RG_DEF_METHOD(toplevel, 0); + RG_DEF_SMETHOD(default_root_window, 0); + RG_DEF_METHOD(children, 0); + RG_DEF_METHOD(events, 0); + RG_DEF_METHOD(set_events, 1); + RG_DEF_METHOD(set_icon, 3); + RG_DEF_METHOD(set_icon_name, 1); + RG_DEF_METHOD(set_transient_for, 1); + RG_DEF_METHOD(set_role, 1); + RG_DEF_METHOD(set_group, 1); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(group, 0); +#endif + RG_DEF_METHOD(set_decorations, 1); + RG_DEF_METHOD(decorations, 0); + RG_DEF_METHOD(set_functions, 1); +#if GTK_CHECK_VERSION(2, 12, 0) + RG_DEF_METHOD(set_composited, 1); + RG_DEF_METHOD(set_opacity, 1); + RG_DEF_METHOD(set_startup_id, 1); +#endif + RG_DEF_SMETHOD(toplevels, 0); + + RG_DEF_SMETHOD(foreign_new, -1); + RG_DEF_SMETHOD(lookup, -1); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + + /* GdkWindowType */ + G_DEF_CLASS(GDK_TYPE_WINDOW_TYPE, "Type", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_WINDOW_TYPE, "GDK_WINDOW_"); + + /* GdkWindowClass */ + G_DEF_CLASS(GDK_TYPE_WINDOW_CLASS, "Class", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_WINDOW_CLASS, "GDK_"); + + /* GdkWindowHints */ + G_DEF_CLASS(GDK_TYPE_WINDOW_HINTS, "Hints", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_WINDOW_HINTS, "GDK_"); + + /* GdkGravity */ + G_DEF_CLASS(GDK_TYPE_GRAVITY, "Gravity", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_GRAVITY, "GDK_"); + + /* GdkWindowEdge */ + G_DEF_CLASS(GDK_TYPE_WINDOW_EDGE, "Edge", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_WINDOW_EDGE, "GDK_WINDOW_"); + + /* GdkWindowTypeHint */ + G_DEF_CLASS(GDK_TYPE_WINDOW_TYPE_HINT, "TypeHint", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_WINDOW_TYPE_HINT, "GDK_WINDOW_"); + + /* GdkWindowAttibutesType */ + G_DEF_CLASS(GDK_TYPE_WINDOW_ATTRIBUTES_TYPE, "AttributesType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_WINDOW_ATTRIBUTES_TYPE, "GDK_"); + + /* GdkFilterReturn */ + G_DEF_CLASS(GDK_TYPE_FILTER_RETURN, "FilterReturn", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_FILTER_RETURN, "GDK_"); + + /* GdkModifierType */ + G_DEF_CLASS(GDK_TYPE_MODIFIER_TYPE, "ModifierType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_MODIFIER_TYPE, "GDK_"); + + /* GdkWMDecoration */ + G_DEF_CLASS(GDK_TYPE_WM_DECORATION, "WMDecoration", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_WM_DECORATION, "GDK_"); + + /* GdkWMFunction */ + G_DEF_CLASS(GDK_TYPE_WM_FUNCTION, "WMFunction", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_WM_FUNCTION, "GDK_"); + + rb_define_const(RG_TARGET_NAMESPACE, "PARENT_RELATIVE", INT2FIX(GDK_PARENT_RELATIVE)); + +#ifdef GDK_WINDOWING_X11 + RG_DEF_METHOD(server_time, 0); + +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(set_user_time, 1); +#endif +#if GTK_CHECK_VERSION(2,8,0) + RG_DEF_METHOD(move_to_current_desktop, 0); +#endif + + G_DEF_CLASS3("GdkWindowImplX11", "WindowImplX11", mGdk); +#elif defined(GDK_WINDOWING_WIN32) + G_DEF_CLASS3("GdkWindowImplWin32", "WindowImplWin32", mGdk); +#elif defined(GDK_WINDOWING_FB) + G_DEF_CLASS3("GdkWindowFB", "WindowFB", mGdk); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkwindowattr.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkwindowattr.c new file mode 100644 index 0000000..93fd411 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkwindowattr.c @@ -0,0 +1,208 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +/*****************************************/ +static GdkWindowAttr* +attr_copy(const GdkWindowAttr* win) +{ + GdkWindowAttr* new_win; + g_return_val_if_fail (win != NULL, NULL); + new_win = g_new(GdkWindowAttr, 1); + *new_win = *win; + return new_win; +} + +GType +gdk_windowattr_get_type(void) +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static ("GdkWindowAttr", + (GBoxedCopyFunc)attr_copy, + (GBoxedFreeFunc)g_free); + return our_type; +} +/*****************************************/ + +#define RG_TARGET_NAMESPACE cWindowAttr +#define _SELF(w) ((GdkWindowAttr*)RVAL2BOXED(w, GDK_TYPE_WINDOW_ATTR)) + +static VALUE +rg_initialize(VALUE self, VALUE width, VALUE height, VALUE wclass, + VALUE window_type) +{ + GdkWindowAttr attribute; + attribute.width = NUM2INT(width); + attribute.height = NUM2INT(height); + attribute.wclass = RVAL2GENUM(wclass, GDK_TYPE_WINDOW_CLASS); + attribute.window_type = RVAL2GENUM(window_type, GDK_TYPE_WINDOW_TYPE); + G_INITIALIZE(self, g_boxed_copy(GDK_TYPE_WINDOW_ATTR, &attribute)); + return Qnil; +} + +#define ATTR_STR(name)\ +static VALUE \ +attr_get_ ## name (VALUE self)\ +{\ + return CSTR2RVAL(_SELF(self)->name);\ +}\ +static VALUE \ +attr_set_ ## name (VALUE self, VALUE val)\ +{\ + _SELF(self)->name = (gchar *)RVAL2CSTR(val);\ + return self;\ +} + +#define ATTR_INT(name)\ +static VALUE \ +attr_get_ ## name (VALUE self)\ +{\ + return INT2NUM(_SELF(self)->name);\ +}\ +static VALUE \ +attr_set_ ## name (VALUE self, VALUE val)\ +{\ + _SELF(self)->name = NUM2INT(val);\ + return self;\ +} + +ATTR_STR(title); +ATTR_INT(event_mask); +ATTR_INT(x); +ATTR_INT(y); +ATTR_INT(width); +ATTR_INT(height); + +static VALUE +rg_wclass(VALUE self) +{ + return GENUM2RVAL(_SELF(self)->wclass, GDK_TYPE_WINDOW_CLASS); +} +static VALUE +rg_set_wclass(VALUE self, VALUE val) +{ + _SELF(self)->wclass = RVAL2GENUM(val, GDK_TYPE_WINDOW_CLASS); + return self; +} + +static VALUE +rg_visual(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->visual); +} +static VALUE +rg_set_visual(VALUE self, VALUE val) +{ + _SELF(self)->visual = GDK_VISUAL(RVAL2GOBJ(val)); + return self; +} + +static VALUE +rg_colormap(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->colormap); +} +static VALUE +rg_set_colormap(VALUE self, VALUE val) +{ + _SELF(self)->colormap = GDK_COLORMAP(RVAL2GOBJ(val)); + return self; +} + +static VALUE +rg_window_type(VALUE self) +{ + return GENUM2RVAL(_SELF(self)->window_type, GDK_TYPE_WINDOW_TYPE); +} +static VALUE +rg_set_window_type(VALUE self, VALUE val) +{ + _SELF(self)->window_type = RVAL2GENUM(val, GDK_TYPE_WINDOW_TYPE); + return self; +} + +static VALUE +rg_cursor(VALUE self) +{ + return BOXED2RVAL(_SELF(self)->cursor, GDK_TYPE_CURSOR); +} +static VALUE +rg_set_cursor(VALUE self, VALUE val) +{ + _SELF(self)->cursor = (GdkCursor*)(RVAL2BOXED(val, GDK_TYPE_CURSOR)); + return self; +} + +ATTR_STR(wmclass_name); +ATTR_STR(wmclass_class); + +static VALUE +rg_override_redirect(VALUE self) +{ + return CBOOL2RVAL(_SELF(self)->override_redirect); +} +static VALUE +rg_set_override_redirect(VALUE self, VALUE val) +{ + _SELF(self)->override_redirect = RVAL2CBOOL(val); + return self; +} + +void +Init_gtk_gdk_windowattr(VALUE mGdk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_WINDOW_ATTR, "WindowAttr", mGdk); + + RG_DEF_METHOD(initialize, 4); + rb_define_method(RG_TARGET_NAMESPACE, "title", attr_get_title, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_title", attr_set_title, 1); + rb_define_method(RG_TARGET_NAMESPACE, "event_mask", attr_get_event_mask, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_event_mask", attr_set_event_mask, 1); + rb_define_method(RG_TARGET_NAMESPACE, "x", attr_get_x, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_x", attr_set_x, 1); + rb_define_method(RG_TARGET_NAMESPACE, "y", attr_get_y, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_y", attr_set_y, 1); + rb_define_method(RG_TARGET_NAMESPACE, "width", attr_get_width, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_width", attr_set_width, 1); + rb_define_method(RG_TARGET_NAMESPACE, "height", attr_get_height, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_height", attr_set_height, 1); + RG_DEF_METHOD(wclass, 0); + RG_DEF_METHOD(set_wclass, 1); + RG_DEF_METHOD(visual, 0); + RG_DEF_METHOD(set_visual, 1); + RG_DEF_METHOD(colormap, 0); + RG_DEF_METHOD(set_colormap, 1); + RG_DEF_METHOD(window_type, 0); + RG_DEF_METHOD(set_window_type, 1); + RG_DEF_METHOD(cursor, 0); + RG_DEF_METHOD(set_cursor, 1); + rb_define_method(RG_TARGET_NAMESPACE, "wmclass_name", attr_get_wmclass_name, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_wmclass_name", attr_set_wmclass_name, 1); + rb_define_method(RG_TARGET_NAMESPACE, "wmclass_class", attr_get_wmclass_class, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_wmclass_class", attr_set_wmclass_class, 1); + RG_DEF_METHOD(override_redirect, 0); + RG_DEF_METHOD(set_override_redirect, 1); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkx11.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkx11.c new file mode 100644 index 0000000..3b2afdf --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgdkx11.c @@ -0,0 +1,262 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" +#ifdef GDK_WINDOWING_X11 + +#define RG_TARGET_NAMESPACE mX11 + +/* Can't implement +#define GDK_ROOT_WINDOW () +*/ +/* Deprecated. +#define GDK_ROOT_PARENT () +*/ +/* Can't implement +#define GDK_DISPLAY () +#define GDK_WINDOW_XDISPLAY (win) +*/ +/* Use Gdk::Drawable#xid +#define GDK_WINDOW_XID (win) +*/ +/* Same as GDK_WINDOW_* +#define GDK_PIXMAP_XDISPLAY (pix) +#define GDK_PIXMAP_XID (pix) +#define GDK_DISPLAY_XDISPLAY (display) +#define GDK_DRAWABLE_XDISPLAY (win) +#define GDK_DRAWABLE_XID (win) +*/ +/* Can't implement +#define GDK_IMAGE_XDISPLAY (image) +#define GDK_IMAGE_XIMAGE (image) +#define GDK_GC_XDISPLAY (gc) +#define GDK_COLORMAP_XDISPLAY (cmap) +#define GDK_COLORMAP_XCOLORMAP (cmap) +#define GDK_SCREEN_XDISPLAY (screen) +*/ +/* Implement at Gdk::Screen +#define GDK_SCREEN_XNUMBER (screen) +*/ +/* Can't implement +#define GDK_SCREEN_XSCREEN (screen) +#define GDK_VISUAL_XVISUAL (vis) +*/ +/* Deprecated. +#define GDK_FONT_XDISPLAY (font) +#define GDK_FONT_XFONT (font) +*/ +/* Can't implement. +#define GDK_CURSOR_XCURSOR (cursor) +#define GDK_CURSOR_XDISPLAY (cursor) +#define GDK_GC_XGC (gc) +#define GDK_GC_GET_XGC (gc) +*/ +/* Don't need this. +#define GDK_WINDOW_XWINDOW +*/ +/* Can't implement. +GdkVisual* gdkx_visual_get (VisualID xvisualid); +GdkColormap* gdkx_colormap_get (Colormap xcolormap); +*/ +/* Implement at Gdk::Pixmap. +GdkPixmap* gdk_pixmap_foreign_new (GdkNativeWindow anid); +GdkPixmap* gdk_pixmap_foreign_new_for_display + (GdkDisplay *display, + GdkNativeWindow anid); +*/ +/* Implement at Gdk::Window. +GdkWindow* gdk_window_foreign_new (GdkNativeWindow anid); +GdkWindow* gdk_window_foreign_new_for_display + (GdkDisplay *display, + GdkNativeWindow anid); +*/ + +static VALUE +rg_m_xid_table_lookup(int argc, VALUE *argv, VALUE self) +{ + VALUE arg[2]; + GdkPixmap* win = NULL; + + rb_scan_args(argc, argv, "11", &arg[0], &arg[1]); + + switch(argc) + { + case 1: + win = gdk_xid_table_lookup(NUM2UINT(arg[0])); + break; + case 2: +#if GTK_CHECK_VERSION(2,2,0) + win = gdk_xid_table_lookup_for_display(RVAL2GOBJ(arg[0]), NUM2UINT(arg[1])); +#else + win = gdk_xid_table_lookup(NUM2UINT(arg[1])); + rb_warn("Not supported in GTK+-2.0.x."); +#endif + break; + } + if (win == NULL) + return Qnil; + else { + return GOBJ2RVAL(win); + } +} + +/* Implement at Gdk::Window +GdkWindow* gdk_window_lookup (GdkNativeWindow anid); +GdkWindow* gdk_window_lookup_for_display (GdkDisplay *display, + GdkNativeWindow anid); +*/ +/* Implement at Gdk::Pixmap +GdkPixmap* gdk_pixmap_lookup (GdkNativeWindow anid); +GdkPixmap* gdk_pixmap_lookup_for_display (GdkDisplay *display, + GdkNativeWindow anid); +*/ +/* Deprecated. +#define gdk_font_lookup (xid) +#define gdk_font_lookup_for_display (display, xid) +*/ +/* Can't implement. +GdkDisplay* gdk_x11_lookup_xdisplay (Display *xdisplay); +*/ +/* Implement at Gdk::Window +guint32 gdk_x11_get_server_time (GdkWindow *window); +*/ + +static VALUE +rg_m_net_wm_supports_p(VALUE self, VALUE property) +{ + return CBOOL2RVAL(gdk_net_wm_supports(RVAL2ATOM(property))); +} + +/* Implement at Gdk::Screen +gboolean gdk_x11_screen_supports_net_wm_hint + (GdkScreen *screen, + GdkAtom property); +const char* gdk_x11_screen_get_window_manager_name + (GdkScreen *screen); +*/ +/* Can't implement +GdkVisual* gdk_x11_screen_lookup_visual (GdkScreen *screen, + VisualID xvisualid); +GdkColormap* gdk_x11_colormap_foreign_new (GdkVisual *visual, + Colormap xcolormap); +Colormap gdk_x11_colormap_get_xcolormap (GdkColormap *colormap); +Display* gdk_x11_colormap_get_xdisplay (GdkColormap *colormap); +Cursor gdk_x11_cursor_get_xcursor (GdkCursor *cursor); +Display* gdk_x11_cursor_get_xdisplay (GdkCursor *cursor); +Display* gdk_x11_display_get_xdisplay (GdkDisplay *display); +*/ + +/* Implement at Gdk::Display +void gdk_x11_display_grab (GdkDisplay *display); +void gdk_x11_display_ungrab (GdkDisplay *display); +void gdk_x11_register_standard_event_type + (GdkDisplay *display, + gint event_base, + gint n_events); +*/ +/* Can't implement +Display* gdk_x11_drawable_get_xdisplay (GdkDrawable *drawable); +*/ +/* Use Gdk::Drawable#xid instead +XID gdk_x11_drawable_get_xid (GdkDrawable *drawable); +*/ +/* Deprecated +G_CONST_RETURN char* gdk_x11_font_get_name (GdkFont *font); +Display* gdk_x11_font_get_xdisplay (GdkFont *font); +gpointer gdk_x11_font_get_xfont (GdkFont *font); +*/ +/* Can't implement +Display* gdk_x11_gc_get_xdisplay (GdkGC *gc); +GC gdk_x11_gc_get_xgc (GdkGC *gc); +Window gdk_x11_get_default_root_xwindow + (void); +*/ + +static VALUE +rg_m_default_screen(VALUE self) +{ + return INT2NUM(gdk_x11_get_default_screen()); +} +/* Can't implement +Display* gdk_x11_get_default_xdisplay (void); +*/ + +static VALUE +rg_m_grab_server(VALUE self) +{ + gdk_x11_grab_server(); + return Qnil; +} +/* Can't implement +Display* gdk_x11_image_get_xdisplay (GdkImage *image); +XImage* gdk_x11_image_get_ximage (GdkImage *image); +*/ +/* Implement at Gdk::Screen. +int gdk_x11_screen_get_screen_number + (GdkScreen *screen); +*/ +/* Can't impelement +Screen* gdk_x11_screen_get_xscreen (GdkScreen *screen); +*/ + +static VALUE +rg_m_ungrab_server(VALUE self) +{ + gdk_x11_ungrab_server(); + return Qnil; +} +/* Can't implement +Visual* gdk_x11_visual_get_xvisual (GdkVisual *visual); + +Atom gdk_x11_atom_to_xatom (GdkAtom atom); +Atom gdk_x11_atom_to_xatom_for_display + (GdkDisplay *display, + GdkAtom atom); +GdkAtom gdk_x11_xatom_to_atom (Atom xatom); +GdkAtom gdk_x11_xatom_to_atom_for_display + (GdkDisplay *display, + Atom xatom); +Atom gdk_x11_get_xatom_by_name (const gchar *atom_name); +Atom gdk_x11_get_xatom_by_name_for_display + (GdkDisplay *display, + const gchar *atom_name); +G_CONST_RETURN gchar* gdk_x11_get_xatom_name + (Atom xatom); +G_CONST_RETURN gchar* gdk_x11_get_xatom_name_for_display + (GdkDisplay *display, + Atom xatom); +*/ +#endif +void +Init_gtk_gdk_x11(VALUE mGdk) +{ +#ifdef GDK_WINDOWING_X11 + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGdk, "X11"); + + RG_DEF_MODFUNC(xid_table_lookup, -1); + RG_DEF_MODFUNC_P(net_wm_supports, 1); + + RG_DEF_MODFUNC(default_screen, 0); + RG_DEF_MODFUNC(grab_server, 0); + + RG_DEF_MODFUNC(ungrab_server, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtk.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtk.c new file mode 100644 index 0000000..64424b0 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtk.c @@ -0,0 +1,577 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2001 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" +#ifdef HAVE_SYS_TIME_H +# include +#endif +#include + +#define RG_TARGET_NAMESPACE mGtk + +VALUE RG_TARGET_NAMESPACE; + +static VALUE rbgtk_eGtkInitError; + +ID id_relative_callbacks; +ID id_call; +static ID id__windows__; +static ID id__quit_callbacks__, id__timeout_callbacks__; +static ID id__idle_callbacks__, id__snooper_callbacks__; + +typedef struct _callback_info_t +{ + VALUE callback; + ID key; + guint id; +} callback_info_t; + +static void +remove_from_windows(G_GNUC_UNUSED GtkWidget *window, VALUE obj) +{ + VALUE klass, windows; + + klass = rb_obj_class(obj); + windows = rb_ivar_get(klass, id__windows__); + if (!NIL_P(windows)) { + rb_hash_delete(windows, obj); + } +} + +void +rbgtk_initialize_gtkobject(VALUE obj, GtkObject *gtkobj) +{ + gtkobj = g_object_ref(gtkobj); + gtk_object_sink(gtkobj); + G_INITIALIZE(obj, gtkobj); + + if (GTK_IS_WINDOW(gtkobj) || GTK_IS_MENU_SHELL(gtkobj)) { + VALUE klass; + klass = rb_obj_class(obj); + if (rb_ivar_defined(klass, id__windows__) == Qfalse) { + rb_ivar_set(klass, id__windows__, rb_hash_new()); + } + rb_hash_aset(rb_ivar_get(klass, id__windows__), obj, Qnil); + g_signal_connect_after(gtkobj, "destroy", + G_CALLBACK(remove_from_windows), + (gpointer)obj); + } +} + +void +exec_callback(GtkWidget *widget, gpointer proc) +{ + rb_funcall((VALUE)proc, id_call, 1, GOBJ2RVAL(widget)); +} + +/* + * Gtk module + */ + +/* We can't use rbgtk_poll() on native Win32. + Because GPollFD doesn't have file descriptor but HANDLE. */ +#define USE_POLL_FUNC + +static VALUE +rg_m_events_pending_p(G_GNUC_UNUSED VALUE self) +{ + return CBOOL2RVAL(gtk_events_pending()); +} + +static VALUE +gtk_m_function_body(VALUE data) +{ + callback_info_t *info = (callback_info_t *)data; + VALUE ret = rb_funcall(info->callback, id_call, 0); + + if (info->key && !ret) + G_REMOVE_RELATIVE(RG_TARGET_NAMESPACE, info->key, UINT2NUM(info->id)); + return ret; +} + +static gboolean +gtk_m_function(gpointer data) +{ + return RVAL2CBOOL(G_PROTECT_CALLBACK(gtk_m_function_body, data)); +} + +static VALUE +gtk_m_function2_body(gpointer proc) +{ + rb_funcall((VALUE)proc, id_call, 0); + return Qnil; +} + +static void +gtk_m_function2(gpointer proc) +{ + G_PROTECT_CALLBACK(gtk_m_function2_body, proc); +} + +static VALUE +rg_m_set_locale(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(gtk_set_locale()); +} + +static VALUE +rg_m_disable_setlocale(G_GNUC_UNUSED VALUE self) +{ + gtk_disable_setlocale(); + return Qnil; +} + +static VALUE +rg_m_default_language(G_GNUC_UNUSED VALUE self) +{ + return BOXED2RVAL(gtk_get_default_language(), PANGO_TYPE_LANGUAGE); +} + +typedef void (*SignalFunc) (int); + +static gboolean _initialized = FALSE; + +static VALUE +rg_m_init(int argc, VALUE *argv, VALUE self) +{ + gint i, gargc; + VALUE argary; + char** gargv; + VALUE progname; + + if (_initialized) + return self; + else + _initialized = TRUE; + + rb_scan_args(argc, argv, "01", &argary); + + if (NIL_P(argary)){ + argary = rb_const_get(rb_cObject, rb_intern("ARGV")); + gargc = RARRAY_LEN(argary); + } else { + Check_Type(argary, T_ARRAY); + gargc = RARRAY_LEN(argary); + } + + gargv = ALLOCA_N(char *, gargc + 1); + progname = rb_gv_get("$0"); + gargv[0] = (char *)RVAL2CSTR(progname); + + for (i = 0; i < gargc; i++) + if (TYPE(RARRAY_PTR(argary)[i]) == T_STRING) + gargv[i+1] = (char *)RVAL2CSTR(RARRAY_PTR(argary)[i]); + else + gargv[i+1] = (char *)""; + gargc++; + + { + gboolean is_initialized; + + is_initialized = gtk_init_check(&gargc, &gargv); + if (! is_initialized) { + const char *display_name_arg = gdk_get_display_arg_name(); + display_name_arg = display_name_arg ? display_name_arg : g_getenv("DISPLAY"); + rb_raise(rbgtk_eGtkInitError, "Cannot open display: %s", + display_name_arg ? display_name_arg : " "); + } + + setlocale(LC_NUMERIC, "C"); + } + + return self; +} + +/* We don't need them. +gtk_init() +gtk_exit() +*/ + +static VALUE +rg_m_main(G_GNUC_UNUSED VALUE self) +{ + gtk_main(); + return Qnil; +} + +static VALUE +rg_m_main_level(G_GNUC_UNUSED VALUE self) +{ + return INT2FIX(gtk_main_level()); +} + +static VALUE +rg_m_main_quit(G_GNUC_UNUSED VALUE self) +{ + gtk_main_quit(); + return Qnil; +} + +static VALUE +rg_m_main_iteration(G_GNUC_UNUSED VALUE self) +{ + return CBOOL2RVAL(gtk_main_iteration()); +} + +static VALUE +rg_m_main_iteration_do(G_GNUC_UNUSED VALUE self, VALUE blocking) +{ + return CBOOL2RVAL(gtk_main_iteration_do(RVAL2CBOOL(blocking))); +} + +static VALUE +rg_m_main_do_event(G_GNUC_UNUSED VALUE self, VALUE event) +{ + gtk_main_do_event(RVAL2GEV(event)); + return event; +} + +/* We don't need them. +gtk_true() +gtk_false() +*/ + +static VALUE +rg_m_grab_add(G_GNUC_UNUSED VALUE self, VALUE widget) +{ + gtk_grab_add(GTK_WIDGET(RVAL2GOBJ(widget))); + return Qnil; +} + +static VALUE +rg_m_current(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(gtk_grab_get_current()); +} + +static VALUE +rg_m_grab_remove(G_GNUC_UNUSED VALUE self, VALUE widget) +{ + gtk_grab_remove(GTK_WIDGET(RVAL2GOBJ(widget))); + return Qnil; +} + +static VALUE +rg_m_init_add(VALUE self) +{ + volatile VALUE func = rb_block_proc(); + + gtk_init_add((GtkFunction)gtk_m_function2, (gpointer)func); + G_RELATIVE(self, func); + return Qnil; +} + +static VALUE +rg_m_quit_add(VALUE self, VALUE main_level) +{ + volatile VALUE func = rb_block_proc(); + VALUE rb_id; + callback_info_t *info; + guint id; + + info = ALLOC(callback_info_t); + info->callback = func; + info->key = id_relative_callbacks; + id = gtk_quit_add_full(NUM2UINT(main_level), (GtkFunction)gtk_m_function, + NULL, (gpointer)info, g_free); + info->id = id; + rb_id = UINT2NUM(id); + G_RELATIVE2(self, func, id__quit_callbacks__, rb_id); + return rb_id; +} + +static VALUE +rg_m_quit_remove(VALUE self, VALUE quit_handler_id) +{ + gtk_quit_remove(NUM2UINT(quit_handler_id)); + G_REMOVE_RELATIVE(self, id__quit_callbacks__, quit_handler_id); + return quit_handler_id; +} + +/* We don't need this. +gtk_quit_add_full () +gtk_quit_add_destroy() +gtk_quit_remove_by_data() +gtk_timeout_add_full() +*/ + +static VALUE +rg_m_timeout_add(VALUE self, VALUE interval) +{ + VALUE func, rb_id; + callback_info_t *info; + guint id; + + func = rb_block_proc(); + info = ALLOC(callback_info_t); + info->callback = func; + info->key = id__timeout_callbacks__; + id = gtk_timeout_add_full(NUM2UINT(interval), (GtkFunction)gtk_m_function, + NULL, (gpointer)info, g_free); + info->id = id; + rb_id = UINT2NUM(id); + G_RELATIVE2(self, func, id__timeout_callbacks__, rb_id); + return rb_id; +} + +static VALUE +rg_m_timeout_remove(VALUE self, VALUE id) +{ + gtk_timeout_remove(NUM2UINT(id)); + G_REMOVE_RELATIVE(self, id__timeout_callbacks__, id); + return Qnil; +} + +static VALUE +rg_m_idle_add(VALUE self) +{ + VALUE func, rb_id; + callback_info_t *info; + guint id; + + func = rb_block_proc(); + info = ALLOC(callback_info_t); + info->callback = func; + info->key = id__idle_callbacks__; + id = gtk_idle_add_full(G_PRIORITY_DEFAULT_IDLE, + (GtkFunction)gtk_m_function, NULL, + (gpointer)info, g_free); + info->id = id; + rb_id = UINT2NUM(id); + G_RELATIVE2(self, func, id__idle_callbacks__, rb_id); + return rb_id; +} + +static VALUE +rg_m_idle_add_priority(VALUE self, VALUE priority) +{ + VALUE func, rb_id; + callback_info_t *info; + guint id; + + func = rb_block_proc(); + info = ALLOC(callback_info_t); + info->callback = func; + info->key = id__idle_callbacks__; + id = gtk_idle_add_full(NUM2INT(priority), (GtkFunction)gtk_m_function, + NULL, (gpointer)info, g_free); + info->id = id; + rb_id = UINT2NUM(id); + G_RELATIVE2(self, func, id__idle_callbacks__, rb_id); + return rb_id; +} + +static VALUE +rg_m_idle_remove(VALUE self, VALUE id) +{ + gtk_idle_remove(NUM2UINT(id)); + G_REMOVE_RELATIVE(self, id__idle_callbacks__, id); + return Qnil; +} + +/* We don't need this. +gtk_idle_remove_by_data() +gtk_idle_add_full() + +Use Gdk::Input.add, remove +gtk_input_add_full() +gtk_input_remove() +*/ + +static gint +gtk_m_key_snoop_func(GtkWidget *grab_widget, GdkEventKey *event, gpointer func) +{ + VALUE ret = rb_funcall((VALUE)func, id_call, 2, + GOBJ2RVAL(grab_widget), + GEV2RVAL((GdkEvent*)event)); + return RVAL2CBOOL(ret); +} + +static VALUE +rg_m_key_snooper_install(VALUE self) +{ + VALUE func = rb_block_proc(); + VALUE id = INT2FIX(gtk_key_snooper_install( + (GtkKeySnoopFunc)gtk_m_key_snoop_func, + (gpointer)func)); + G_RELATIVE2(self, func, id__snooper_callbacks__, id); + return id; +} + +static VALUE +rg_m_key_snooper_remove(VALUE self, VALUE id) +{ + gtk_key_snooper_remove(NUM2UINT(id)); + G_REMOVE_RELATIVE(self, id__snooper_callbacks__, id); + return Qnil; +} + +static VALUE +rg_m_current_event(G_GNUC_UNUSED VALUE self) +{ + return GEV2RVAL(gtk_get_current_event()); +} + +static VALUE +rg_m_current_event_time(G_GNUC_UNUSED VALUE self) +{ + return INT2NUM(gtk_get_current_event_time()); +} + +static VALUE +rg_m_current_event_state(G_GNUC_UNUSED VALUE self) +{ + GdkModifierType state; + gboolean ret = gtk_get_current_event_state(&state); + return ret ? GFLAGS2RVAL(state, GDK_TYPE_MODIFIER_TYPE) : Qnil; +} + +static VALUE +rg_m_get_event_widget(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE event; + rb_scan_args(argc, argv, "01", &event); + + return GOBJ2RVAL(gtk_get_event_widget(NIL_P(event) ? NULL :RVAL2GEV(event))); +} + +static VALUE +rg_m_propagate_event(G_GNUC_UNUSED VALUE self, VALUE widget, VALUE event) +{ + gtk_propagate_event(GTK_WIDGET(RVAL2GOBJ(widget)), RVAL2GEV(event)); + return Qnil; +} + +/* From Version Information */ +static VALUE +rg_m_check_version(G_GNUC_UNUSED VALUE self, VALUE major, VALUE minor, VALUE micro) +{ + const gchar *ret; + ret = gtk_check_version(FIX2INT(major), FIX2INT(minor), FIX2INT(micro)); + return ret ? CSTR2RVAL(ret) : Qnil; +} + +static VALUE +rg_m_check_version_p(G_GNUC_UNUSED VALUE self, VALUE major, VALUE minor, VALUE micro) +{ + const gchar *ret; + ret = gtk_check_version(FIX2INT(major), FIX2INT(minor), FIX2INT(micro)); + return CBOOL2RVAL(ret == NULL); +} + +#if GTK_CHECK_VERSION(2,14,0) +static VALUE +rg_m_show_uri(G_GNUC_UNUSED VALUE self, VALUE rb_uri_or_options) +{ + VALUE rb_screen = Qnil; + VALUE rb_uri = Qnil; + VALUE rb_timestamp = Qnil; + GdkScreen *screen = NULL; + const gchar *uri = NULL; + guint32 timestamp = GDK_CURRENT_TIME; + GError *error = NULL; + + if (TYPE(rb_uri_or_options) == T_HASH) { + rbg_scan_options(rb_uri_or_options, + "screen", &rb_screen, + "uri", &rb_uri, + "timestamp", &rb_timestamp, + NULL); + } else { + rb_uri = rb_uri_or_options; + } + + screen = RVAL2GOBJ(rb_screen); + uri = StringValueCStr(rb_uri); + if (!NIL_P(rb_timestamp)) { + timestamp = NUM2UINT(rb_timestamp); + } + + if (!gtk_show_uri(screen, uri, timestamp, &error)) { + RAISE_GERROR(error); + } + + return self; +} +#endif + +/* + * Init + */ +void +Init_gtk_gtk(void) +{ + id_call = rb_intern("call"); + id__windows__ = rb_intern("__windows__"); + id__quit_callbacks__ = rb_intern("__quit_callbacks__"); + id__timeout_callbacks__ = rb_intern("__timeout_callbacks__"); + id__idle_callbacks__ = rb_intern("__idle_callbacks__"); + id__snooper_callbacks__ = rb_intern("__snooper_callbacks__"); + + RG_TARGET_NAMESPACE = rb_define_module("Gtk"); + rb_ivar_set(RG_TARGET_NAMESPACE, id_relative_callbacks, Qnil); + + rbgtk_eGtkInitError = rb_define_class_under(RG_TARGET_NAMESPACE, "InitError", + rb_eRuntimeError); + + RG_DEF_MODFUNC_P(events_pending, 0); + + RG_DEF_MODFUNC(set_locale, 0); + RG_DEF_MODFUNC(disable_setlocale, 0); + RG_DEF_MODFUNC(default_language, 0); + RG_DEF_MODFUNC(init, -1); + RG_DEF_MODFUNC(main, 0); + RG_DEF_MODFUNC(main_level, 0); + RG_DEF_MODFUNC(main_quit, 0); + RG_DEF_MODFUNC(main_iteration, 0); + RG_DEF_MODFUNC(main_iteration_do, 1); + RG_DEF_MODFUNC(main_do_event, 1); + RG_DEF_MODFUNC(grab_add, 1); + RG_DEF_MODFUNC(current, 0); + RG_DEF_MODFUNC(grab_remove, 1); + RG_DEF_MODFUNC(init_add, 0); + RG_DEF_MODFUNC(quit_add, 1); + RG_DEF_MODFUNC(quit_remove, 1); + + RG_DEF_MODFUNC(timeout_add, 1); + RG_DEF_MODFUNC(timeout_remove, 1); + RG_DEF_MODFUNC(idle_add, 0); + RG_DEF_MODFUNC(idle_add_priority, 1); + RG_DEF_MODFUNC(idle_remove, 1); + RG_DEF_MODFUNC(key_snooper_install, 0); + RG_DEF_MODFUNC(key_snooper_remove, 1); + RG_DEF_MODFUNC(current_event, 0); + RG_DEF_MODFUNC(current_event_time, 0); + RG_DEF_MODFUNC(current_event_state, 0); + RG_DEF_MODFUNC(get_event_widget, -1); + RG_DEF_MODFUNC(propagate_event, 2); + RG_DEF_MODFUNC(check_version, 3); + RG_DEF_MODFUNC_P(check_version, 3); + +#if GTK_CHECK_VERSION(2,14,0) + RG_DEF_MODFUNC(show_uri, 1); +#endif + + rb_define_const(RG_TARGET_NAMESPACE, "PRIORITY_RESIZE", INT2FIX(GTK_PRIORITY_RESIZE)); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtk.h b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtk.h new file mode 100644 index 0000000..cda67c6 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtk.h @@ -0,0 +1,132 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003-2006 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef _RBGTK_H +#define _RBGTK_H + +#include +#include +#include +#include +#include + +#include + +#define RubyGtkContainerHookModule "RubyGtkContainerHook__" + +#define RBGTK_INITIALIZE(obj,gtkobj)\ + (rbgtk_initialize_gtkobject(obj, GTK_OBJECT(gtkobj))) + +#define GTK_TYPE_ALLOCATION (gtk_allocation_get_type()) +#define GTK_TYPE_ACCEL_KEY (gtk_accel_key_get_type()) +#define GTK_TYPE_ACCEL_GROUP_ENTRY (gtk_accel_group_entry_get_type()) +#define GTK_TYPE_BINDING_SET (gtk_bindingset_get_type()) +#define GTK_TYPE_TEXT_APPEARANCE (gtk_text_appearance_get_type()) +#define GTK_TYPE_RECENT_FILTER_INFO (gtk_recent_filter_info_get_type()) +#define GTK_TYPE_RECENT_DATA (gtk_recent_data_get_type()) +#ifndef GTK_TYPE_TARGET_LIST +extern GType gtk_target_list_get_type(); +#define GTK_TYPE_TARGET_LIST (gtk_target_list_get_type()) +#endif + +RUBY_GTK2_VAR VALUE mGtk; + +/* + * for gtk2.0/gtk2.2 + */ +#ifndef GTK_TYPE_CLIPBOARD +#define GTK_TYPE_CLIPBOARD (rbgtk_clipboard_get_type()) +#define RVAL2CLIPBOARD(obj) (rbgtk_get_clipboard(obj)) +#define CLIPBOARD2RVAL(val) (rbgtk_make_clipboard(val)) +extern GType rbgtk_clipboard_get_type(); +extern GtkClipboard* rbgtk_get_clipboard(VALUE obj); +extern VALUE rbgtk_make_clipboard(GtkClipboard* gobj); +#else +#define RVAL2CLIPBOARD(obj) (GTK_CLIPBOARD(RVAL2GOBJ(obj))) +#define CLIPBOARD2RVAL(val) (GOBJ2RVAL(val)) +#endif + +#ifndef GTK_TYPE_TREE_ROW_REFERENCE +#define GTK_TYPE_TREE_ROW_REFERENCE (rbgtk_tree_row_reference_get_type()) +#define RVAL2TREEROWREFERENCE(obj) (rbgtk_get_tree_row_reference(obj)) +extern GType rbgtk_tree_row_reference_get_type(); +extern GtkTreeRowReference* rbgtk_get_tree_row_reference(VALUE obj); +#else +#define RVAL2TREEROWREFERENCE(obj) ((GtkTreeRowReference*)(RVAL2BOXED(obj, GTK_TYPE_TREE_ROW_REFERENCE))) +#endif + + +/* + * for gtk + */ +extern void rbgtk_initialize_gtkobject(VALUE obj, GtkObject *gtkobj); +extern void exec_callback(GtkWidget *widget, gpointer proc); +extern GType gtk_allocation_get_type(void); +extern GType gtk_accel_key_get_type(void); +extern GType gtk_accel_group_entry_get_type(void); +extern GType gtk_bindingset_get_type(void); +extern GType gtk_text_appearance_get_type(void); +extern GType gtk_recent_filter_info_get_type(void); +extern GType gtk_recent_data_get_type(void); + +/* + * Gtk::TreeIter callback + */ +typedef void (*rbgtkiter_set_value_func)(void *model, GtkTreeIter *iter, + gint column, GValue *value); +extern void rbgtk_register_treeiter_set_value_func(GType, rbgtkiter_set_value_func); + +/* + * Gtk::SelectionData + */ +extern void rbgtk_atom2selectiondata(VALUE type, VALUE size, VALUE src, GdkAtom* gtype, + void** data, gint* format, gint* length); +extern void rbgtk_atom2selectiondata_free(GdkAtom gtype, void* data); + +/* + * Gtk::Drag + */ +#define RVAL2GTKTARGETENTRIES(value, n) rbgtk_rval2gtktargetentries(value, n) +extern GtkTargetEntry *rbgtk_rval2gtktargetentries(VALUE value, long *n); +#define RVAL2GTKTARGETENTRIES_ACCEPT_NIL(value, n) rbgtk_rval2gtktargetentries_accept_nil(value, n) +GtkTargetEntry *rbgtk_rval2gtktargetentries_accept_nil(VALUE value, long *n); +/* Only for backwards compatibility. */ +GtkTargetEntry *rbgtk_get_target_entry(VALUE targets); + +/* + * Gtk::Container + */ +extern void rbgtkcontainer_register_child_property_setter(GType gtype, + const char* prop_name, + RValueToGValueFunc func); +extern void rbgtkcontainer_register_child_property_getter(GType gtype, + const char* prop_name, + GValueToRValueFunc func); + +/* + * Dialog + */ +extern VALUE rbgtk_dialog_add_buttons_internal(VALUE self, VALUE button_ary); + +#endif /* _RBGTK_H */ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaboutdialog.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaboutdialog.c new file mode 100644 index 0000000..6f98977 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaboutdialog.c @@ -0,0 +1,141 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,6,0) + +#define RG_TARGET_NAMESPACE cAboutDialog +#define _SELF(self) (GTK_ABOUT_DIALOG(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_about_dialog_new()); + return Qnil; +} + +static void +activate_link_func(GtkAboutDialog *about, const gchar *link, gpointer func) +{ + rb_funcall((VALUE)func, id_call, 2, GOBJ2RVAL(about), CSTR2RVAL(link)); +} + +static VALUE +rg_s_set_email_hook(VALUE self) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_about_dialog_set_email_hook((GtkAboutDialogActivateLinkFunc)activate_link_func, (gpointer)func, (GDestroyNotify)NULL); + return self; +} + +static VALUE +rg_s_set_url_hook(VALUE self) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_about_dialog_set_url_hook((GtkAboutDialogActivateLinkFunc)activate_link_func, (gpointer)func, (GDestroyNotify)NULL); + return self; +} + +typedef struct { + const char *name; + gpointer value; +} prop_data; + +#define ABOUT_PROP_NUM (15) + +static VALUE +rg_s_show(VALUE self, VALUE parent, VALUE props) +{ + int i; + VALUE ary; + prop_data pd[ABOUT_PROP_NUM]; + + Check_Type(props, T_HASH); + + ary = rb_funcall(props, rb_intern("to_a"), 0); + + if (RARRAY_LEN(ary) > ABOUT_PROP_NUM) + rb_raise(rb_eArgError, "Too many args."); + + for (i = 0; i < ABOUT_PROP_NUM; i++){ + pd[i].name = (const char*)NULL; + pd[i].value = (gpointer)NULL; + } + for (i = 0; i < RARRAY_LEN(ary); i++){ + if (TYPE(RARRAY_PTR(RARRAY_PTR(ary)[i])[0]) == T_SYMBOL){ + pd[i].name = rb_id2name(SYM2ID(RARRAY_PTR(RARRAY_PTR(ary)[i])[0])); + } else { + pd[i].name = RVAL2CSTR(RARRAY_PTR(RARRAY_PTR(ary)[i])[0]); + } + if (strncmp(pd[i].name, "artists", strlen("artists")) == 0|| + strncmp(pd[i].name, "authors", strlen("authors")) == 0|| + strncmp(pd[i].name, "documenters", strlen("documenters")) == 0){ + GValue gval = G_VALUE_INIT; + g_value_init(&gval, G_TYPE_STRV); + rbgobj_rvalue_to_gvalue(RARRAY_PTR(RARRAY_PTR(ary)[i])[1], &gval); + + pd[i].value = g_boxed_copy(G_TYPE_STRV, g_value_get_boxed(&gval)); + } else if (strncmp(pd[i].name, "logo", strlen("logo")) == 0 && + strlen(pd[i].name) == strlen("logo")){ + pd[i].value = g_object_ref(RVAL2GOBJ(RARRAY_PTR(RARRAY_PTR(ary)[i])[1])); + } else if (strncmp(pd[i].name, "wrap_license", strlen("wrap_license")) == 0){ + pd[i].value = GINT_TO_POINTER(RVAL2CBOOL(RARRAY_PTR(ary)[i])); + } else { + pd[i].value = g_strdup(RVAL2CSTR(RARRAY_PTR(RARRAY_PTR(ary)[i])[1])); + } + } + + gtk_show_about_dialog(GTK_WINDOW(RVAL2GOBJ(parent)), + pd[0].name, pd[0].value, + pd[1].name, pd[1].value, + pd[2].name, pd[2].value, + pd[3].name, pd[3].value, + pd[4].name, pd[4].value, + pd[5].name, pd[5].value, + pd[6].name, pd[6].value, + pd[7].name, pd[7].value, + pd[8].name, pd[8].value, + pd[9].name, pd[9].value, + pd[10].name, pd[10].value, + pd[11].name, pd[11].value, + pd[12].name, pd[12].value, + pd[13].name, pd[13].value, + pd[14].name, pd[14].value, + NULL); + return self; +} +#endif + +void +Init_gtk_aboutdialog(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,6,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ABOUT_DIALOG, "AboutDialog", mGtk); + RG_DEF_METHOD(initialize, 0); + + RG_DEF_SMETHOD(set_email_hook, 0); + RG_DEF_SMETHOD(set_url_hook, 0); + RG_DEF_SMETHOD(show, 2); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaccelerator.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaccelerator.c new file mode 100644 index 0000000..bbcd73f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaccelerator.c @@ -0,0 +1,85 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE mAccelerator + +#define RVAL2MOD(mods) RVAL2GFLAGS(mods, GDK_TYPE_MODIFIER_TYPE) + +static VALUE +rg_s_valid(G_GNUC_UNUSED VALUE self, VALUE keyval, VALUE modifiers) +{ + return CBOOL2RVAL(gtk_accelerator_valid(NUM2UINT(keyval), RVAL2MOD(modifiers))); +} + +static VALUE +rg_s_parse(G_GNUC_UNUSED VALUE self, VALUE accelerator) +{ + guint key; + GdkModifierType mods; + gtk_accelerator_parse(RVAL2CSTR(accelerator), &key, &mods); + return rb_ary_new3(2, UINT2NUM(key), GFLAGS2RVAL(mods, GDK_TYPE_MODIFIER_TYPE)); +} + +static VALUE +rg_s_to_name(G_GNUC_UNUSED VALUE self, VALUE key, VALUE mods) +{ + return CSTR2RVAL(gtk_accelerator_name(NUM2UINT(key), RVAL2MOD(mods))); +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_s_get_label(G_GNUC_UNUSED VALUE self, VALUE key, VALUE mods) +{ + return CSTR2RVAL(gtk_accelerator_get_label(NUM2UINT(key), RVAL2MOD(mods))); +} +#endif + +static VALUE +rg_s_set_default_mod_mask(VALUE self, VALUE default_mod_mask) +{ + gtk_accelerator_set_default_mod_mask(RVAL2MOD(default_mod_mask)); + return self; +} + +static VALUE +rg_s_default_mod_mask(G_GNUC_UNUSED VALUE self) +{ + return GFLAGS2RVAL(gtk_accelerator_get_default_mod_mask(), GDK_TYPE_MODIFIER_TYPE); +} + +void +Init_gtk_accelerator(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGtk, "Accelerator"); + + RG_DEF_SMETHOD(valid, 2); + RG_DEF_SMETHOD(parse, 1); + /* name is reserved by Ruby */ + RG_DEF_SMETHOD(to_name, 2); +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_SMETHOD(get_label, 2); +#endif + RG_DEF_SMETHOD(set_default_mod_mask, 1); + RG_DEF_SMETHOD(default_mod_mask, 0); + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaccelgroup.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaccelgroup.c new file mode 100644 index 0000000..1a540b8 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaccelgroup.c @@ -0,0 +1,208 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cAccelGroup +#define _SELF(w) GTK_ACCEL_GROUP(RVAL2GOBJ(w)) +#define RVAL2MOD(mods) (NIL_P(mods) ? 0 : RVAL2GFLAGS(mods, GDK_TYPE_MODIFIER_TYPE)) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, gtk_accel_group_new()); + return Qnil; +} + +static VALUE +rg_connect(int argc, VALUE *argv, VALUE self) +{ + VALUE key, mods, flags, path, closure; + GClosure *rclosure; + + if (argc > 2){ + rb_scan_args(argc, argv, "31", &key, &mods, &flags, &closure); + if (NIL_P(closure)){ + rclosure = g_rclosure_new(rb_block_proc(), Qnil, NULL); + } else { + rclosure = (GClosure*)RVAL2BOXED(closure, G_TYPE_CLOSURE); + } + g_rclosure_attach(rclosure, self); + gtk_accel_group_connect(_SELF(self), NUM2UINT(key), + RVAL2MOD(mods), + RVAL2GFLAGS(flags, GTK_TYPE_ACCEL_FLAGS), + rclosure); + } else { + rb_scan_args(argc, argv, "11", &path, &closure); + if (NIL_P(closure)){ + rclosure = g_rclosure_new(rb_block_proc(), Qnil, NULL); + } else { + rclosure = (GClosure*)RVAL2BOXED(closure, G_TYPE_CLOSURE); + } + g_rclosure_attach(rclosure, self); + gtk_accel_group_connect_by_path(_SELF(self), RVAL2CSTR(path), rclosure); + } + return self; +} + +static VALUE +rg_disconnect_key(VALUE self, VALUE key, VALUE mods) +{ + return CBOOL2RVAL(gtk_accel_group_disconnect_key(_SELF(self), NUM2UINT(key), + RVAL2MOD(mods))); +} + +static VALUE +rg_query(VALUE self, VALUE key, VALUE mods) +{ + GtkAccelGroupEntry *entries; + guint n_entries; + guint cnt; + VALUE result; + + entries = gtk_accel_group_query(_SELF(self), NUM2UINT(key), + RVAL2MOD(mods), &n_entries); + if(n_entries == 0){ + return Qnil; + } + else{ + result = rb_ary_new2(n_entries); + for(cnt=0; cntkey, GTK_TYPE_ACCEL_KEY); +} + +static VALUE +rg_closure(VALUE self) +{ + return BOXED2RVAL(_SELF(self)->closure, G_TYPE_CLOSURE); +} + +static VALUE +rg_accel_path(VALUE self) +{ + const gchar *quark_str = g_quark_to_string(_SELF(self)->accel_path_quark); + return quark_str ? CSTR2RVAL(quark_str) : Qnil; +} + +void +Init_gtk_accel_group_entry(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ACCEL_GROUP_ENTRY, "AccelGroupEntry", mGtk); + + RG_DEF_METHOD(initialize, 0); + + RG_DEF_METHOD(accel_key, 0); + RG_DEF_METHOD(closure, 0); + RG_DEF_METHOD(accel_path, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaccelkey.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaccelkey.c new file mode 100644 index 0000000..145a0d8 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaccelkey.c @@ -0,0 +1,122 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 OGASAWARA, Takeshi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cAccelKey +#define _SELF(s) ((GtkAccelKey*)RVAL2BOXED(s, GTK_TYPE_ACCEL_KEY)) +#define GTK_TYPE_ACCEL_KEY (gtk_accel_key_get_type()) + +static GtkAccelKey * +accel_key_copy(const GtkAccelKey *key) +{ + GtkAccelKey *new_key; + g_return_val_if_fail (key != NULL, NULL); + new_key = g_new(GtkAccelKey, 1); + *new_key = *key; + return new_key; +} + +GType +gtk_accel_key_get_type(void) +{ + static GType our_type = 0; + if(our_type == 0) + our_type = g_boxed_type_register_static("GtkAccelKey", + (GBoxedCopyFunc)accel_key_copy, + (GBoxedFreeFunc)g_free); + return our_type; +} + +/* +struct _GtkAccelKey +{ + guint accel_key; + GdkModifierType accel_mods; + guint accel_flags : 16; +}; +*/ + +static VALUE +rg_initialize(VALUE self) +{ + GtkAccelKey key; + memset(&key, 0, sizeof(GtkAccelKey)); + G_INITIALIZE(self, g_boxed_copy(GTK_TYPE_ACCEL_KEY, &key)); + return Qnil; +} + +static VALUE +rg_key(VALUE self) +{ + return UINT2NUM(_SELF(self)->accel_key); +} + +static VALUE +rg_mods(VALUE self) +{ + return GFLAGS2RVAL(_SELF(self)->accel_mods, GDK_TYPE_MODIFIER_TYPE); +} + +static VALUE +rg_flags(VALUE self) +{ + return INT2FIX(_SELF(self)->accel_flags); +} + +static VALUE +rg_set_key(VALUE self, VALUE key) +{ + _SELF(self)->accel_key = NUM2UINT(key); + return self; +} + +static VALUE +rg_set_mods(VALUE self, VALUE mods) +{ + _SELF(self)->accel_mods = RVAL2GFLAGS(mods, GDK_TYPE_MODIFIER_TYPE); + return self; +} + +static VALUE +rg_set_flags(VALUE self, VALUE flags) +{ + _SELF(self)->accel_flags = FIX2INT(flags); + return self; +} + +void +Init_gtk_accel_key(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ACCEL_KEY, "AccelKey", mGtk); + + RG_DEF_METHOD(initialize, 0); + + RG_DEF_METHOD(key, 0); + RG_DEF_METHOD(mods, 0); + RG_DEF_METHOD(flags, 0); + + RG_DEF_METHOD(set_key, 1); + RG_DEF_METHOD(set_mods, 1); + RG_DEF_METHOD(set_flags, 1); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaccellabel.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaccellabel.c new file mode 100644 index 0000000..d16e88e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaccellabel.c @@ -0,0 +1,55 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 2001 Neil Conway + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cAccelLabel + +static VALUE +rg_initialize(VALUE self, VALUE string) +{ + RBGTK_INITIALIZE(self, gtk_accel_label_new(RVAL2CSTR(string))); + return Qnil; +} + +static VALUE +rg_accel_width(VALUE self) +{ + return INT2NUM(gtk_accel_label_get_accel_width(GTK_ACCEL_LABEL(RVAL2GOBJ(self)))); +} + +static VALUE +rg_refetch(VALUE self) +{ + gtk_accel_label_refetch(GTK_ACCEL_LABEL(RVAL2GOBJ(self))); + return Qfalse; // always returns false +} + +void +Init_gtk_accel_label(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ACCEL_LABEL, "AccelLabel", mGtk); + + RG_DEF_METHOD(initialize, 1); + RG_DEF_METHOD(accel_width, 0); + RG_DEF_METHOD(refetch, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaccelmap.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaccelmap.c new file mode 100644 index 0000000..2ee74fb --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaccelmap.c @@ -0,0 +1,159 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 OGASAWARA, Takeshi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cAccelMap + +#define RVAL2MOD(mods) (NIL_P(mods) ? 0 : RVAL2GFLAGS(mods, GDK_TYPE_MODIFIER_TYPE)) + +static VALUE +rg_s_add_entry(VALUE self, VALUE path, VALUE key, VALUE mods) +{ + gtk_accel_map_add_entry(RVAL2CSTR(path), NUM2UINT(key), RVAL2MOD(mods)); + return self; +} + +static VALUE +rg_s_lookup_entry(VALUE self, VALUE path) +{ + GtkAccelKey key; + if(gtk_accel_map_lookup_entry(RVAL2CSTR(path), &key)) + return BOXED2RVAL(&key, GTK_TYPE_ACCEL_KEY); + else + return self; +} + +static VALUE +rg_s_change_entry(G_GNUC_UNUSED VALUE self, VALUE path, VALUE key, VALUE mods, VALUE replace) +{ + return CBOOL2RVAL(gtk_accel_map_change_entry(RVAL2CSTR(path), NUM2UINT(key), + RVAL2MOD(mods), RVAL2CBOOL(replace))); +} + +static VALUE +rg_s_load(VALUE self, VALUE filename) +{ + gtk_accel_map_load(RVAL2CSTR(filename)); + return self; +} + +static VALUE +rg_s_save(VALUE self, VALUE filename) +{ + gtk_accel_map_save(RVAL2CSTR(filename)); + return self; +} + +static VALUE +rg_s_add_filter(VALUE self, VALUE pattern) +{ + gtk_accel_map_add_filter(RVAL2CSTR(pattern)); + return self; +} + +static void +accel_map_foreach_func(gpointer func, const gchar *path, guint key, GdkModifierType mods, gboolean changed) +{ + rb_funcall((VALUE)func, id_call, 4, + CSTR2RVAL(path), UINT2NUM(key), GFLAGS2RVAL(mods, GDK_TYPE_MODIFIER_TYPE), + CBOOL2RVAL(changed)); +} + +static VALUE +rg_s_each(VALUE self) +{ + volatile VALUE func = rb_block_proc(); + gtk_accel_map_foreach((gpointer)func, + (GtkAccelMapForeach)accel_map_foreach_func); + return self; +} + +static VALUE +rg_s_each_unfilterd(VALUE self) +{ + volatile VALUE func = rb_block_proc(); + gtk_accel_map_foreach_unfiltered((gpointer)func, + (GtkAccelMapForeach)accel_map_foreach_func); + return self; +} + +/* +void gtk_accel_map_load_scanner (GScanner *scanner); +*/ + +/* We don't need them. +void gtk_accel_map_load_fd (gint fd); +void gtk_accel_map_save_fd (gint fd); +*/ + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_s_get(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(gtk_accel_map_get()); +} + +static VALUE +rg_s_lock_path(VALUE self, VALUE accel_path) +{ + gtk_accel_map_lock_path(RVAL2CSTR(accel_path)); + return self; +} + +static VALUE +rg_s_unlock_path(VALUE self, VALUE accel_path) +{ + gtk_accel_map_unlock_path(RVAL2CSTR(accel_path)); + return self; +} +#endif + +void +Init_gtk_accel_map(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ACCEL_MAP, "AccelMap", mGtk); + + RG_DEF_SMETHOD(add_entry, 3); + RG_DEF_SMETHOD(lookup_entry, 1); + RG_DEF_SMETHOD(change_entry, 4); + RG_DEF_SMETHOD(load, 1); + RG_DEF_SMETHOD(save, 1); + RG_DEF_SMETHOD(add_filter, 1); + RG_DEF_SMETHOD(each, 0); + RG_DEF_SMETHOD(each_unfilterd, 0); + RG_DEF_SMETHOD(get, 0); + RG_DEF_SMETHOD(lock_path, 1); + RG_DEF_SMETHOD(unlock_path, 1); +#else + VALUE mAccelMap = rb_define_module_under(mGtk, "AccelMap"); + + rb_define_module_function(mAccelMap, "add_entry", rg_s_add_entry, 3); + rb_define_module_function(mAccelMap, "lookup_entry", rg_s_lookup_entry, 1); + rb_define_module_function(mAccelMap, "change_entry", rg_s_change_entry, 4); + rb_define_module_function(mAccelMap, "load", rg_s_load, 1); + rb_define_module_function(mAccelMap, "save", rg_s_save, 1); + rb_define_module_function(mAccelMap, "add_filter", rg_s_add_filter, 1); + rb_define_module_function(mAccelMap, "each", rg_s_each, 0); + rb_define_module_function(mAccelMap, "each_unfilterd", rg_s_each_unfilterd, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaccessible.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaccessible.c new file mode 100644 index 0000000..090c28b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaccessible.c @@ -0,0 +1,39 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cAccessible + +static VALUE +rg_connect_widget_destroyed(VALUE self) +{ + gtk_accessible_connect_widget_destroyed(GTK_ACCESSIBLE(RVAL2GOBJ(self))); + return self; +} + +void +Init_gtk_accessible(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ACCESSIBLE, "Accessible", mGtk); + + RG_DEF_METHOD(connect_widget_destroyed, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaction.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaction.c new file mode 100644 index 0000000..76f367e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaction.c @@ -0,0 +1,237 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004-2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cAction +#define _SELF(self) (GTK_ACTION(RVAL2GOBJ(self))) +#define RVAL2WIDGET(w) (GTK_WIDGET(RVAL2GOBJ(w))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE name, label, tooltip, stock_id; + const gchar *stock = NULL; + + rb_scan_args(argc, argv, "22", &name, &label, &tooltip, &stock_id); + + if (TYPE(stock_id) == T_SYMBOL) { + stock = rb_id2name(SYM2ID(stock_id)); + } else if (TYPE(stock_id) == T_STRING){ + stock = RVAL2CSTR(stock_id); + } + + G_INITIALIZE(self, gtk_action_new(RVAL2CSTR(name), RVAL2CSTR(label), + NIL_P(tooltip) ? NULL : RVAL2CSTR(tooltip), + stock)); + return Qnil; +} + +static VALUE +rg_is_sensitive_p(VALUE self) +{ + return CBOOL2RVAL(gtk_action_is_sensitive(_SELF(self))); +} + +static VALUE +rg_is_visible_p(VALUE self) +{ + return CBOOL2RVAL(gtk_action_is_visible(_SELF(self))); +} + +static VALUE +rg_activate(VALUE self) +{ + gtk_action_activate(_SELF(self)); + return self; +} + +static VALUE +rg_create_icon(VALUE self, VALUE icon_size) +{ + return GOBJ2RVAL(gtk_action_create_icon(_SELF(self), + RVAL2GENUM(icon_size, GTK_TYPE_ICON_SIZE))); +} + +static VALUE +rg_create_menu_item(VALUE self) +{ + return GOBJ2RVAL(gtk_action_create_menu_item(_SELF(self))); +} + +#if GTK_CHECK_VERSION(2, 12, 0) +static VALUE +rg_create_menu(VALUE self) +{ + return GOBJ2RVAL(gtk_action_create_menu(_SELF(self))); +} +#endif + +static VALUE +rg_create_tool_item(VALUE self) +{ + return GOBJ2RVAL(gtk_action_create_tool_item(_SELF(self))); +} + +static VALUE +rg_connect_proxy(VALUE self, VALUE proxy) +{ + gtk_action_connect_proxy(_SELF(self), RVAL2WIDGET(proxy)); + return self; +} + +static VALUE +rg_disconnect_proxy(VALUE self, VALUE proxy) +{ + gtk_action_disconnect_proxy(_SELF(self), RVAL2WIDGET(proxy)); + return self; +} + +static VALUE +rg_proxies(VALUE self) +{ + /* Owned by GTK+ */ + return GSLIST2ARY(gtk_action_get_proxies(_SELF(self))); +} + +static VALUE +rg_connect_accelerator(VALUE self) +{ + gtk_action_connect_accelerator(_SELF(self)); + return self; +} + +static VALUE +rg_disconnect_accelerator(VALUE self) +{ + gtk_action_disconnect_accelerator(_SELF(self)); + return self; +} + +static VALUE +rg_block_activate_from(VALUE self, VALUE proxy) +{ + gtk_action_block_activate_from(_SELF(self), RVAL2WIDGET(proxy)); + return self; +} + +static VALUE +rg_unblock_activate_from(VALUE self, VALUE proxy) +{ + gtk_action_unblock_activate_from(_SELF(self), RVAL2WIDGET(proxy)); + return self; +} + +static VALUE +rg_set_accel_path(VALUE self, VALUE accel_path) +{ + gtk_action_set_accel_path(_SELF(self), RVAL2CSTR(accel_path)); + return self; +} + +static VALUE +rg_set_accel_group(VALUE self, VALUE accel_group) +{ + gtk_action_set_accel_group(_SELF(self), RVAL2GOBJ(accel_group)); + return self; +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_accel_path(VALUE self) +{ + return CSTR2RVAL(gtk_action_get_accel_path(_SELF(self))); +} +#endif + +#if GTK_CHECK_VERSION(2,8,0) +static VALUE +rg_accel_closure(VALUE self) +{ + return BOXED2RVAL(gtk_action_get_accel_closure(_SELF(self)), G_TYPE_CLOSURE); +} +#endif + +static void +action_mark(void *p) +{ + GtkAction *action; + GSList *node; + + action = GTK_ACTION(p); + for (node = gtk_action_get_proxies(action); + node; + node = g_slist_next(node)) { + GtkWidget *proxy = node->data; + rbgobj_gc_mark_instance(proxy); + } +} +#endif + +void +Init_gtk_action(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = G_DEF_CLASS_WITH_GC_FUNC(GTK_TYPE_ACTION, "Action", mGtk, + action_mark, NULL); + + RG_DEF_METHOD(initialize, -1); + /* (NOTICE) Gtk::Action#is_sensitive?, #is_visible are special. + Because there are also Gtk::Action#sensitive?, #visible? as property + accessors. + Gtk::Action#is_sensitive?, #is_visible? check its associated + action group. + Gtk::Action#sensitive?, #visible? returns the value of the properties. + */ + RG_DEF_METHOD_P(is_sensitive, 0); + RG_DEF_METHOD_P(is_visible, 0); + RG_DEF_METHOD(activate, 0); + RG_DEF_METHOD(create_icon, 1); + RG_DEF_METHOD(create_menu_item, 0); +#if GTK_CHECK_VERSION(2, 12, 0) + RG_DEF_METHOD(create_menu, 0); +#endif + RG_DEF_METHOD(create_tool_item, 0); + RG_DEF_METHOD(connect_proxy, 1); + RG_DEF_METHOD(disconnect_proxy, 1); + RG_DEF_METHOD(proxies, 0); + RG_DEF_METHOD(connect_accelerator, 0); + RG_DEF_METHOD(disconnect_accelerator, 0); + RG_DEF_METHOD(block_activate_from, 1); + RG_DEF_METHOD(unblock_activate_from, 1); + RG_DEF_METHOD(set_accel_path, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "accel_path"); + RG_DEF_METHOD(set_accel_group, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "accel_group"); + +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(accel_path, 0); +#endif + +#if GTK_CHECK_VERSION(2,8,0) + RG_DEF_METHOD(accel_closure, 0); +#endif +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkactiongroup.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkactiongroup.c new file mode 100644 index 0000000..86528cc --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkactiongroup.c @@ -0,0 +1,477 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004-2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +static ID id_action_procs; +static ID id_toggle_action_procs; + +#define RG_TARGET_NAMESPACE cActionGroup +#define _SELF(self) (GTK_ACTION_GROUP(RVAL2GOBJ(self))) +#define RVAL2WIDGET(w) (GTK_WIDGET(RVAL2GOBJ(w))) + +static VALUE +rg_initialize(VALUE self, VALUE name) +{ + G_INITIALIZE(self, gtk_action_group_new(RVAL2CSTR(name))); + return Qnil; +} + +static VALUE +rg_get_action(VALUE self, VALUE action_name) +{ + return GOBJ2RVAL(gtk_action_group_get_action(_SELF(self), RVAL2CSTR(action_name))); +} + +static VALUE +rg_actions(VALUE self) +{ + return GLIST2ARYF(gtk_action_group_list_actions(_SELF(self))); +} + +static VALUE +rg_add_action(int argc, VALUE *argv, VALUE self) +{ + VALUE action, accelerator; + + rb_scan_args(argc, argv, "11", &action, &accelerator); + + gtk_action_group_add_action_with_accel(_SELF(self), + GTK_ACTION(RVAL2GOBJ(action)), + NIL_P(accelerator) ? NULL : RVAL2CSTR(accelerator)); + G_CHILD_ADD(self, action); + + return self; +} + +static VALUE +rg_remove_action(VALUE self, VALUE action) +{ + gtk_action_group_remove_action(_SELF(self), GTK_ACTION(RVAL2GOBJ(action))); + G_CHILD_REMOVE(self, action); + return self; +} + +static void +activate_action(GtkAction *action, VALUE self) +{ + VALUE proc = rb_hash_aref(rb_ivar_get(self, id_action_procs), + CSTR2RVAL(gtk_action_get_name(action))); + + if (!NIL_P(proc)) + rb_funcall(proc, id_call, 2, self, GOBJ2RVAL(action)); +} + +struct rbg_rval2gtkactionentries_args { + VALUE ary; + long n; + GtkActionEntry *result; + VALUE procs; +}; + +static VALUE +rbg_rval2gtkactionentries_body(VALUE value) +{ + long i; + struct rbg_rval2gtkactionentries_args *args = (struct rbg_rval2gtkactionentries_args *)value; + + for (i = 0; i < args->n; i++) { + VALUE entry; + long n; + + RARRAY_PTR(args->ary)[i] = rb_ary_dup(rb_ary_to_ary(RARRAY_PTR(args->ary)[i])); + entry = RARRAY_PTR(args->ary)[i]; + n = RARRAY_LEN(entry); + + args->result[i].callback = G_CALLBACK(activate_action); + + if (n < 1 || n > 6) + rb_raise(rb_eArgError, "entry does not contain right number of entries %ld (1..6)", n); + + args->result[i].name = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[0]); + + switch (n) { + case 6: + /* TODO: Call #to_proc on entry 5? */ + rb_hash_aset(args->procs, RARRAY_PTR(entry)[0], RARRAY_PTR(entry)[5]); + case 5: + args->result[i].tooltip = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[4]); + case 4: + args->result[i].accelerator = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[3]); + case 3: + args->result[i].label = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[2]); + case 2: + args->result[i].stock_id = RVAL2CSTR_ACCEPT_SYMBOL_ACCEPT_NIL(RARRAY_PTR(entry)[1]); + break; + default: + break; + } + } + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbg_rval2gtkactionentries_rescue(VALUE value) +{ + g_free(((struct rbg_rval2gtkactionentries_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static GtkActionEntry * +rbg_rval2gtkactionentries(volatile VALUE *value, long *n, VALUE procs) +{ + struct rbg_rval2gtkactionentries_args args; + + args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value)); + args.n = RARRAY_LEN(args.ary); + args.result = g_new0(GtkActionEntry, args.n + 1); + args.procs = procs; + + rb_rescue(rbg_rval2gtkactionentries_body, (VALUE)&args, + rbg_rval2gtkactionentries_rescue, (VALUE)&args); + + *n = args.n; + + return args.result; +} + +#define RVAL2GTKACTIONENTRIES(value, n, procs) rbg_rval2gtkactionentries(&(value), &(n), procs) + +static VALUE +rg_add_actions(VALUE self, VALUE rbentries) +{ + GtkActionGroup *group = _SELF(self); + VALUE action_procs = rb_ivar_defined(self, id_action_procs) == Qtrue ? + rb_ivar_get(self, id_action_procs) : + rb_hash_new(); + long n; + GtkActionEntry *entries = RVAL2GTKACTIONENTRIES(rbentries, n, action_procs); + + rb_ivar_set(self, id_action_procs, action_procs); + + gtk_action_group_add_actions(group, entries, n, (gpointer)self); + + g_free(entries); + + return self; +} + +static void +activate_toggle_action(GtkAction *action, VALUE self) +{ + VALUE proc = rb_hash_aref(rb_ivar_get(self, id_toggle_action_procs), + CSTR2RVAL(gtk_action_get_name(action))); + + if (!NIL_P(proc)) + rb_funcall(proc, id_call, 2, self, GOBJ2RVAL(action)); +} + +struct rbg_rval2gtktoggleactionentries_args { + VALUE ary; + long n; + GtkToggleActionEntry *result; + VALUE procs; +}; + +static VALUE +rbg_rval2gtktoggleactionentries_body(VALUE value) +{ + long i; + struct rbg_rval2gtktoggleactionentries_args *args = (struct rbg_rval2gtktoggleactionentries_args *)value; + + for (i = 0; i < args->n; i++) { + VALUE entry; + long n; + + RARRAY_PTR(args->ary)[i] = rb_ary_dup(rb_ary_to_ary(RARRAY_PTR(args->ary)[i])); + entry = RARRAY_PTR(args->ary)[i]; + n = RARRAY_LEN(entry); + + args->result[i].callback = G_CALLBACK(activate_toggle_action); + + if (n < 1 || n > 7) + rb_raise(rb_eArgError, "entry does not contain right number of entries %ld (1..7)", n); + + args->result[i].name = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[0]); + + switch (n) { + case 7: + args->result[i].is_active = RVAL2CBOOL(RARRAY_PTR(entry)[6]); + case 6: + /* TODO: Call #to_proc on entry 5? */ + rb_hash_aset(args->procs, RARRAY_PTR(entry)[0], RARRAY_PTR(entry)[5]); + case 5: + args->result[i].tooltip = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[4]); + case 4: + args->result[i].accelerator = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[3]); + case 3: + args->result[i].label = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[2]); + case 2: + args->result[i].stock_id = RVAL2CSTR_ACCEPT_SYMBOL_ACCEPT_NIL(RARRAY_PTR(entry)[1]); + break; + default: + break; + } + } + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbg_rval2gtktoggleactionentries_rescue(VALUE value) +{ + g_free(((struct rbg_rval2gtktoggleactionentries_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static GtkToggleActionEntry * +rbg_rval2gtktoggleactionentries(volatile VALUE *value, long *n, VALUE procs) +{ + struct rbg_rval2gtktoggleactionentries_args args; + + args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value)); + args.n = RARRAY_LEN(args.ary); + args.result = g_new0(GtkToggleActionEntry, args.n + 1); + args.procs = procs; + + rb_rescue(rbg_rval2gtktoggleactionentries_body, (VALUE)&args, + rbg_rval2gtktoggleactionentries_rescue, (VALUE)&args); + + *n = args.n; + + return args.result; +} + +#define RVAL2GTKTOGGLEACTIONENTRIES(value, n, procs) rbg_rval2gtktoggleactionentries(&(value), &(n), procs) + +static VALUE +rg_add_toggle_actions(VALUE self, VALUE rbentries) +{ + GtkActionGroup *group = _SELF(self); + VALUE toggle_action_procs = rb_ivar_defined(self, id_toggle_action_procs) == Qtrue ? + rb_ivar_get(self, id_toggle_action_procs) : + rb_hash_new(); + long n; + GtkToggleActionEntry *entries = RVAL2GTKTOGGLEACTIONENTRIES(rbentries, n, toggle_action_procs); + + rb_ivar_set(self, id_toggle_action_procs, toggle_action_procs); + + gtk_action_group_add_toggle_actions(group, entries, n, (gpointer)self); + + g_free(entries); + + return self; +} + +static void +activate_radio_action(GtkAction *action, GtkRadioAction *current, VALUE proc) +{ + if (!NIL_P(proc)) + rb_funcall(proc, id_call, 2, GOBJ2RVAL(action), GOBJ2RVAL(current)); +} + +struct rbg_rval2gtkradioactionentries_args { + VALUE ary; + long n; + GtkRadioActionEntry *result; +}; + +static VALUE +rbg_rval2gtkradioactionentries_body(VALUE value) +{ + long i; + struct rbg_rval2gtkradioactionentries_args *args = (struct rbg_rval2gtkradioactionentries_args *)value; + + for (i = 0; i < args->n; i++) { + VALUE entry; + long n; + + RARRAY_PTR(args->ary)[i] = rb_ary_dup(rb_ary_to_ary(RARRAY_PTR(args->ary)[i])); + entry = RARRAY_PTR(args->ary)[i]; + n = RARRAY_LEN(entry); + + switch (n) { + case 6: + args->result[i].value = NUM2INT(RARRAY_PTR(entry)[5]); + case 5: + args->result[i].tooltip = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[4]); + case 4: + args->result[i].accelerator = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[3]); + case 3: + args->result[i].label = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[2]); + case 2: + args->result[i].stock_id = RVAL2CSTR_ACCEPT_SYMBOL_ACCEPT_NIL(RARRAY_PTR(entry)[1]); + case 1: + args->result[i].name = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[0]); + break; + default: + rb_raise(rb_eArgError, "entry does not contain right number of entries %ld (1..6)", n); + break; + } + } + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbg_rval2gtkradioactionentries_rescue(VALUE value) +{ + g_free(((struct rbg_rval2gtkradioactionentries_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static GtkRadioActionEntry * +rbg_rval2gtkradioactionentries(volatile VALUE *value, long *n) +{ + struct rbg_rval2gtkradioactionentries_args args; + + args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value)); + args.n = RARRAY_LEN(args.ary); + args.result = g_new0(GtkRadioActionEntry, args.n + 1); + + rb_rescue(rbg_rval2gtkradioactionentries_body, (VALUE)&args, + rbg_rval2gtkradioactionentries_rescue, (VALUE)&args); + + *n = args.n; + + return args.result; +} + +#define RVAL2GTKRADIOACTIONENTRIES(value, n) rbg_rval2gtkradioactionentries(&(value), &(n)) + +static VALUE +rg_add_radio_actions(int argc, VALUE *argv, VALUE self) +{ + GtkActionGroup *group = _SELF(self); + VALUE rbentries, rbvalue, proc; + long n; + GtkRadioActionEntry *entries; + gint value; + + rb_scan_args(argc, argv, "12", &rbentries, &rbvalue, &proc); + + value = NIL_P(rbvalue) ? -1 : NUM2INT(rbvalue); + + if (NIL_P(proc) && rb_block_given_p()) { + proc = rb_block_proc(); + /* TODO: How do we remove this proc when all the radio actions passed + * have been removed? */ + G_RELATIVE(self, proc); + } + + entries = RVAL2GTKRADIOACTIONENTRIES(rbentries, n); + + gtk_action_group_add_radio_actions(group, + entries, + n, + value, + G_CALLBACK(activate_radio_action), + (gpointer)proc); + + g_free(entries); + + return self; +} + +static gchar * +translate_func(const gchar *path, gpointer func) +{ + VALUE ret = rb_funcall((VALUE)func, id_call, 1, CSTR2RVAL(path)); + return (gchar *)RVAL2CSTR(ret); +} + +static VALUE +rg_set_translate_func(VALUE self) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_action_group_set_translate_func(_SELF(self), + (GtkTranslateFunc)translate_func, + (gpointer)func, NULL); + return self; +} + +static VALUE +rg_set_translation_domain(VALUE self, VALUE domain) +{ + gtk_action_group_set_translation_domain(_SELF(self), + NIL_P(domain) ? (const gchar*)NULL : RVAL2CSTR(domain)); + return self; +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_translate_string(VALUE self, VALUE str) +{ + return CSTR2RVAL(gtk_action_group_translate_string(_SELF(self), RVAL2CSTR(str))); +} +#endif + +static void +action_group_mark(void *p) +{ + GtkActionGroup *group; + GList *actions, *node; + + group = GTK_ACTION_GROUP(p); + actions = gtk_action_group_list_actions(group); + for (node = actions; node; node = g_list_next(node)) { + GtkWidget *action = node->data; + rbgobj_gc_mark_instance(action); + } + g_list_free(actions); +} +#endif + +void +Init_gtk_actiongroup(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = G_DEF_CLASS_WITH_GC_FUNC(GTK_TYPE_ACTION_GROUP, "ActionGroup", + mGtk, action_group_mark, NULL); + + id_action_procs = rb_intern("@action_procs"); + id_toggle_action_procs = rb_intern("@toggle_action_procs"); + + RG_DEF_METHOD(initialize, 1); + RG_DEF_METHOD(get_action, 1); + RG_DEF_METHOD(actions, 0); + RG_DEF_METHOD(add_action, -1); + RG_DEF_METHOD(remove_action, 1); + RG_DEF_METHOD(add_actions, 1); + RG_DEF_METHOD(add_toggle_actions, 1); + RG_DEF_METHOD(add_radio_actions, -1); + RG_DEF_METHOD(set_translate_func, 0); + RG_DEF_METHOD(set_translation_domain, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "translation_domain"); +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(translate_string, 1); +#endif +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkadjustment.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkadjustment.c new file mode 100644 index 0000000..5b88899 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkadjustment.c @@ -0,0 +1,72 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cAdjustment +#define _SELF(self) (GTK_ADJUSTMENT(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(VALUE self, VALUE value, VALUE lower, VALUE upper, VALUE step_inc, VALUE page_inc, VALUE page_size) +{ + RBGTK_INITIALIZE(self, gtk_adjustment_new(NUM2DBL(value), + NUM2DBL(lower), + NUM2DBL(upper), + NUM2DBL(step_inc), + NUM2DBL(page_inc), + NUM2DBL(page_size))); + return Qnil; +} + +static VALUE +rg_clamp_page(VALUE self, VALUE lower, VALUE upper) +{ + gtk_adjustment_clamp_page(_SELF(self), NUM2DBL(lower), NUM2DBL(upper)); + return self; +} + +static VALUE +rg_changed(VALUE self) +{ + gtk_adjustment_changed(_SELF(self)); + return self; +} + +static VALUE +rg_value_changed(VALUE self) +{ + gtk_adjustment_value_changed(_SELF(self)); + return self; +} + +void +Init_gtk_adjustment(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ADJUSTMENT, "Adjustment", mGtk); + + RG_DEF_METHOD(initialize, 6); + RG_DEF_METHOD(clamp_page, 2); + RG_DEF_METHOD(changed, 0); + RG_DEF_METHOD(value_changed, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkalignment.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkalignment.c new file mode 100644 index 0000000..334d34d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkalignment.c @@ -0,0 +1,79 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cAlignment + +static VALUE +rg_initialize(VALUE self, VALUE xalign, VALUE yalign, VALUE xscale, VALUE yscale) +{ + RBGTK_INITIALIZE(self, gtk_alignment_new(NUM2DBL(xalign), + NUM2DBL(yalign), + NUM2DBL(xscale), + NUM2DBL(yscale))); + return Qnil; +} + +static VALUE +rg_set(VALUE self, VALUE xalign, VALUE yalign, VALUE xscale, VALUE yscale) +{ + gtk_alignment_set(GTK_ALIGNMENT(RVAL2GOBJ(self)), + NUM2DBL(xalign), NUM2DBL(yalign), + NUM2DBL(xscale), NUM2DBL(yscale)); + return self; +} +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_padding(VALUE self) +{ + guint top, bottom, left, right; + gtk_alignment_get_padding(GTK_ALIGNMENT(RVAL2GOBJ(self)), + &top, &bottom, &left, &right); + return rb_ary_new3(4, UINT2NUM(top), UINT2NUM(bottom), + UINT2NUM(left), UINT2NUM(right)); +} +static VALUE +rg_set_padding(VALUE self, VALUE top, VALUE bottom, VALUE left, VALUE right) +{ + gtk_alignment_set_padding(GTK_ALIGNMENT(RVAL2GOBJ(self)), + NUM2UINT(top), NUM2UINT(bottom), + NUM2UINT(left), NUM2UINT(right)); + return self; +} +#endif + +void +Init_gtk_alignment(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ALIGNMENT, "Alignment", mGtk); + + RG_DEF_METHOD(initialize, 4); + RG_DEF_METHOD(set, 4); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(padding, 0); + RG_DEF_METHOD(set_padding, 4); +#endif + +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkallocation.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkallocation.c new file mode 100644 index 0000000..2c554d5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkallocation.c @@ -0,0 +1,168 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +static GtkAllocation * +gtk_allocation_copy(const GtkAllocation *alloc) +{ + GtkAllocation *result = g_new (GtkAllocation, 1); + *result = *alloc; + + return result; +} + +GType +gtk_allocation_get_type(void) +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static ("GtkAllocation", + (GBoxedCopyFunc)gtk_allocation_copy, + (GBoxedFreeFunc)g_free); + return our_type; +} + +#define RG_TARGET_NAMESPACE cAllocation +#define _SELF(r) ((GtkAllocation*)RVAL2BOXED(r, GTK_TYPE_ALLOCATION)) + +static VALUE +rg_initialize(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height) +{ + GtkAllocation allocation; + + allocation.x = NUM2INT(x); + allocation.y = NUM2INT(y); + allocation.width = NUM2INT(width); + allocation.height = NUM2INT(height); + + G_INITIALIZE(self, g_boxed_copy(GTK_TYPE_ALLOCATION, &allocation)); + return Qnil; +} + +static VALUE +rg_intersect(VALUE self, VALUE other) +{ + GtkAllocation dest; + gboolean ret = gdk_rectangle_intersect(_SELF(self), _SELF(other), &dest); + return ret ? BOXED2RVAL(&dest, GTK_TYPE_ALLOCATION) : Qnil; +} + +static VALUE +rg_union(VALUE self, VALUE other) +{ + GtkAllocation dest; + gdk_rectangle_union(_SELF(self), _SELF(other), &dest); + return BOXED2RVAL(&dest, GTK_TYPE_ALLOCATION); +} + +/* Struct accessors */ +static VALUE +rg_x(VALUE self) +{ + return INT2NUM(_SELF(self)->x); +} + +static VALUE +rg_y(VALUE self) +{ + return INT2NUM(_SELF(self)->y); +} + +static VALUE +rg_width(VALUE self) +{ + return INT2NUM(_SELF(self)->width); +} + +static VALUE +rg_height(VALUE self) +{ + return INT2NUM(_SELF(self)->height); +} + +static VALUE +rg_set_x(VALUE self, VALUE x) +{ + _SELF(self)->x = NUM2INT(x); + return self; +} + +static VALUE +rg_set_y(VALUE self, VALUE y) +{ + _SELF(self)->y = NUM2INT(y); + return self; +} + +static VALUE +rg_set_width(VALUE self, VALUE width) +{ + _SELF(self)->width = NUM2INT(width); + return self; +} + +static VALUE +rg_set_height(VALUE self, VALUE height) +{ + _SELF(self)->height = NUM2INT(height); + return self; +} + +static VALUE +rg_to_a(VALUE self) +{ + GtkAllocation* a = _SELF(self); + return rb_ary_new3(4, INT2FIX(a->x), INT2FIX(a->y), + INT2FIX(a->width), INT2FIX(a->height)); +} + +static VALUE +rg_to_rect(VALUE self) +{ + return BOXED2RVAL(_SELF(self), GDK_TYPE_RECTANGLE); +} + +void +Init_gtk_allocation(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ALLOCATION, "Allocation", mGtk); + + RG_DEF_METHOD(initialize, 4); + RG_DEF_METHOD(intersect, 1); + RG_DEF_ALIAS("&", "intersect"); + RG_DEF_METHOD(union, 1); + RG_DEF_ALIAS("|", "union"); + RG_DEF_METHOD(x, 0); + RG_DEF_METHOD(y, 0); + RG_DEF_METHOD(width, 0); + RG_DEF_METHOD(height, 0); + RG_DEF_METHOD(set_x, 1); + RG_DEF_METHOD(set_y, 1); + RG_DEF_METHOD(set_width, 1); + RG_DEF_METHOD(set_height, 1); + RG_DEF_METHOD(to_a, 0); + RG_DEF_METHOD(to_rect, 0); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkarrow.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkarrow.c new file mode 100644 index 0000000..ee67f73 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkarrow.c @@ -0,0 +1,57 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cArrow + +static VALUE +rg_initialize(VALUE self, VALUE arrow_t, VALUE shadow_t) +{ + RBGTK_INITIALIZE(self, gtk_arrow_new(RVAL2GENUM(arrow_t, GTK_TYPE_ARROW_TYPE), + RVAL2GENUM(shadow_t, GTK_TYPE_SHADOW_TYPE))); + return Qnil; +} + +static VALUE +rg_set(VALUE self, VALUE arrow_t, VALUE shadow_t) +{ + gtk_arrow_set(GTK_ARROW(RVAL2GOBJ(self)), + RVAL2GENUM(arrow_t, GTK_TYPE_ARROW_TYPE), + RVAL2GENUM(shadow_t, GTK_TYPE_SHADOW_TYPE)); + return self; +} + +void +Init_gtk_arrow(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ARROW, "Arrow", mGtk); + + RG_DEF_METHOD(initialize, 2); + RG_DEF_METHOD(set, 2); + + /* GtkArrowType (from General constants) */ + G_DEF_CLASS(GTK_TYPE_ARROW_TYPE, "Type", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_ARROW_TYPE, "GTK_ARROW_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaspectframe.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaspectframe.c new file mode 100644 index 0000000..f90da64 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkaspectframe.c @@ -0,0 +1,56 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cAspectFrame + +static VALUE +rg_initialize(VALUE self, VALUE label, VALUE xalign, VALUE yalign, VALUE ratio, VALUE obey_child) +{ + RBGTK_INITIALIZE(self, gtk_aspect_frame_new(NIL_P(label)?NULL:RVAL2CSTR(label), + NUM2DBL(xalign), + NUM2DBL(yalign), + NUM2DBL(ratio), + RVAL2CBOOL(obey_child))); + return Qnil; +} + +static VALUE +rg_set(VALUE self, VALUE xalign, VALUE yalign, VALUE ratio, VALUE obey_child) +{ + gtk_aspect_frame_set(GTK_ASPECT_FRAME(RVAL2GOBJ(self)), + NUM2DBL(xalign), NUM2DBL(yalign), + NUM2DBL(ratio), RVAL2CBOOL(obey_child)); + return self; +} + +void +Init_gtk_aspect_frame(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ASPECT_FRAME, "AspectFrame", mGtk); + + RG_DEF_METHOD(initialize, 5); + RG_DEF_METHOD(set, 4); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkassistant.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkassistant.c new file mode 100644 index 0000000..a8028bc --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkassistant.c @@ -0,0 +1,226 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +#define RG_TARGET_NAMESPACE cAssistant +#define _SELF(s) (GTK_ASSISTANT(RVAL2GOBJ(s))) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_assistant_new()); + return Qnil; +} + +static VALUE +rg_current_page(VALUE self) +{ + return INT2NUM(gtk_assistant_get_current_page(_SELF(self))); +} + +static VALUE +rg_set_current_page(VALUE self, VALUE page_num) +{ + gtk_assistant_set_current_page(_SELF(self), NUM2INT(page_num)); + return self; +} + +static VALUE +rg_n_pages(VALUE self) +{ + return INT2NUM(gtk_assistant_get_n_pages(_SELF(self))); +} + +static VALUE +rg_get_nth_page(VALUE self, VALUE page_num) +{ + return GOBJ2RVAL(gtk_assistant_get_nth_page(_SELF(self), NUM2INT(page_num))); +} + +static VALUE +rg_prepend_page(VALUE self, VALUE page) +{ + return INT2NUM(gtk_assistant_prepend_page(_SELF(self), GTK_WIDGET(RVAL2GOBJ(page)))); +} + +static VALUE +rg_append_page(VALUE self, VALUE page) +{ + return INT2NUM(gtk_assistant_append_page(_SELF(self), GTK_WIDGET(RVAL2GOBJ(page)))); +} + +static VALUE +rg_insert_page(VALUE self, VALUE page, VALUE position) +{ + return INT2NUM(gtk_assistant_insert_page(_SELF(self), GTK_WIDGET(RVAL2GOBJ(page)), NUM2INT(position))); +} + +static gint +ass_page_func(gint current_page, gpointer func) +{ + return NUM2INT(rb_funcall((VALUE)func, id_call, 1, INT2NUM(current_page))); +} + +static VALUE +rg_set_forward_page_func(VALUE self) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_assistant_set_forward_page_func(_SELF(self), (GtkAssistantPageFunc)ass_page_func, (gpointer)func, NULL); + return self; +} + +static VALUE +rg_set_page_type(VALUE self, VALUE page, VALUE type) +{ + gtk_assistant_set_page_type(_SELF(self), GTK_WIDGET(RVAL2GOBJ(page)), RVAL2GENUM(type, GTK_TYPE_ASSISTANT_PAGE_TYPE)); + return self; +} + +static VALUE +rg_get_page_type(VALUE self, VALUE page) +{ + return GENUM2RVAL(gtk_assistant_get_page_type(_SELF(self), GTK_WIDGET(RVAL2GOBJ(page))), GTK_TYPE_ASSISTANT_PAGE_TYPE); +} + +static VALUE +rg_set_page_title(VALUE self, VALUE page, VALUE title) +{ + gtk_assistant_set_page_title(_SELF(self), GTK_WIDGET(RVAL2GOBJ(page)), RVAL2CSTR(title)); + return self; +} + +static VALUE +rg_get_page_title(VALUE self, VALUE page) +{ + return CSTR2RVAL(gtk_assistant_get_page_title(_SELF(self), GTK_WIDGET(RVAL2GOBJ(page)))); +} + +static VALUE +rg_set_page_header_image(VALUE self, VALUE page, VALUE header_image) +{ + gtk_assistant_set_page_header_image(_SELF(self), GTK_WIDGET(RVAL2GOBJ(page)), GDK_PIXBUF(RVAL2GOBJ(header_image))); + return self; +} + +static VALUE +rg_get_page_header_image(VALUE self, VALUE page) +{ + return GOBJ2RVAL(gtk_assistant_get_page_header_image(_SELF(self), GTK_WIDGET(RVAL2GOBJ(page)))); +} + +static VALUE +rg_set_page_side_image(VALUE self, VALUE page, VALUE side_image) +{ + gtk_assistant_set_page_side_image(_SELF(self), GTK_WIDGET(RVAL2GOBJ(page)), GDK_PIXBUF(RVAL2GOBJ(side_image))); + return self; +} + +static VALUE +rg_get_page_side_image(VALUE self, VALUE page) +{ + return GOBJ2RVAL(gtk_assistant_get_page_side_image(_SELF(self), GTK_WIDGET(RVAL2GOBJ(page)))); +} + +static VALUE +rg_set_page_complete(VALUE self, VALUE page, VALUE complete) +{ + gtk_assistant_set_page_complete(_SELF(self), GTK_WIDGET(RVAL2GOBJ(page)), RVAL2CBOOL(complete)); + return self; +} + +static VALUE +rg_get_page_complete(VALUE self, VALUE page) +{ + return CBOOL2RVAL(gtk_assistant_get_page_complete(_SELF(self), GTK_WIDGET(RVAL2GOBJ(page)))); +} + +static VALUE +rg_add_action_widget(VALUE self, VALUE child) +{ + gtk_assistant_add_action_widget(_SELF(self), GTK_WIDGET(RVAL2GOBJ(child))); + return self; +} + +static VALUE +rg_remove_action_widget(VALUE self, VALUE child) +{ + gtk_assistant_remove_action_widget(_SELF(self), GTK_WIDGET(RVAL2GOBJ(child))); + return self; +} + +static VALUE +rg_update_buttons_state(VALUE self) +{ + gtk_assistant_update_buttons_state(_SELF(self)); + return self; +} + +static VALUE +rg_commit(VALUE self) +{ + gtk_assistant_commit(_SELF(self)); + + return self; +} + +#endif + +void +Init_gtk_assistant(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ASSISTANT, "Assistant", mGtk); + RG_DEF_METHOD(initialize, 0); + + RG_DEF_METHOD(current_page, 0); + RG_DEF_METHOD(set_current_page, 1); + RG_DEF_METHOD(n_pages, 0); + RG_DEF_METHOD(get_nth_page, 1); + RG_DEF_METHOD(prepend_page, 1); + RG_DEF_METHOD(append_page, 1); + RG_DEF_METHOD(insert_page, 2); + RG_DEF_METHOD(set_forward_page_func, 0); + RG_DEF_METHOD(set_page_type, 2); + RG_DEF_METHOD(get_page_type, 1); + RG_DEF_METHOD(set_page_title, 2); + RG_DEF_METHOD(get_page_title, 1); + RG_DEF_METHOD(set_page_header_image, 2); + RG_DEF_METHOD(get_page_header_image, 1); + RG_DEF_METHOD(set_page_side_image, 2); + RG_DEF_METHOD(get_page_side_image, 1); + RG_DEF_METHOD(set_page_complete, 2); + RG_DEF_METHOD(get_page_complete, 1); + RG_DEF_METHOD(add_action_widget, 1); + RG_DEF_METHOD(remove_action_widget, 1); + RG_DEF_METHOD(update_buttons_state, 0); + RG_DEF_METHOD(commit, 0); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + + /* GtkAssistantPageType */ + G_DEF_CLASS(GTK_TYPE_ASSISTANT_PAGE_TYPE, "PageType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_ASSISTANT_PAGE_TYPE, "GTK_ASSISTANT_"); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbbox.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbbox.c new file mode 100644 index 0000000..7e73063 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbbox.c @@ -0,0 +1,57 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cButtonBox + +static VALUE +rg_set_child_secondary(VALUE self, VALUE child, VALUE is_secondary) +{ + gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(RVAL2GOBJ(self)), + GTK_WIDGET(RVAL2GOBJ(child)), + RVAL2CBOOL(is_secondary)); + return self; +} +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_get_child_secondary(VALUE self, VALUE child) +{ + return CBOOL2RVAL(gtk_button_box_get_child_secondary(GTK_BUTTON_BOX(RVAL2GOBJ(self)), + GTK_WIDGET(RVAL2GOBJ(child)))); +} +#endif + +void +Init_gtk_button_box(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_BUTTON_BOX, "ButtonBox", mGtk); + RG_DEF_METHOD(set_child_secondary, 2); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(get_child_secondary, 1); +#endif + /* GtkButtonBoxStyle(General constants) */ + G_DEF_CLASS(GTK_TYPE_BUTTON_BOX_STYLE, "Style", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_BUTTON_BOX_STYLE, "GTK_BUTTONBOX_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbin.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbin.c new file mode 100644 index 0000000..6273c70 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbin.c @@ -0,0 +1,42 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cBin + +static VALUE +rg_child(VALUE self) +{ + GtkWidget *child = gtk_bin_get_child(RVAL2GOBJ(self)); + return child ? GOBJ2RVAL(child) : Qnil; +} + +void +Init_gtk_bin(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_BIN, "Bin", mGtk); + + RG_DEF_METHOD(child, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbindingset.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbindingset.c new file mode 100644 index 0000000..a62a784 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbindingset.c @@ -0,0 +1,189 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +/* + NOTE: + - gtk_bindings_activate() is mapped to + Gtk::Object#bindings_activate. + + - gtk_binding_set_by_class() is mapped to + Gtk::Object.binding_set + */ + +#include "global.h" + +#define RVAL2MOD(mods) RVAL2GFLAGS(mods, GDK_TYPE_MODIFIER_TYPE) + +/*****************************************/ +static GtkBindingSet* +gtk_bindingset_copy(const GtkBindingSet* bin) +{ + /* GtkBindingSet should not be copied */ + return (GtkBindingSet*)bin; +} + +static void +gtk_bindingset_free(G_GNUC_UNUSED GtkBindingSet* bin) +{ + /* GtkBindingSet should not be freed */ +} + +GType +gtk_bindingset_get_type(void) +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static ("GtkBindingSet", + (GBoxedCopyFunc)gtk_bindingset_copy, + (GBoxedFreeFunc)gtk_bindingset_free); + return our_type; +} +/*****************************************/ + +#define RG_TARGET_NAMESPACE cBindingSet +#define _SELF(s) (GtkBindingSet*)(RVAL2BOXED(s, GTK_TYPE_BINDING_SET)) + +static VALUE +rg_initialize(VALUE self, VALUE set_name) +{ + G_INITIALIZE(self, gtk_binding_set_new(RVAL2CSTR(set_name))); + return Qnil; +} + +static VALUE +rg_s_find(G_GNUC_UNUSED VALUE self, VALUE set_name) +{ + return BOXED2RVAL(gtk_binding_set_find(RVAL2CSTR(set_name)), + GTK_TYPE_BINDING_SET); +} + +static VALUE +rg_activate(VALUE self, VALUE keyval, VALUE modifiers, VALUE object) +{ + return CBOOL2RVAL(gtk_binding_set_activate(_SELF(self), NUM2UINT(keyval), + RVAL2MOD(modifiers), + GTK_OBJECT(RVAL2GOBJ(object)))); +} + +static VALUE +rg_entry_clear(VALUE self, VALUE keyval, VALUE modifiers) +{ + gtk_binding_entry_clear(_SELF(self), NUM2UINT(keyval), + RVAL2MOD(modifiers)); + return self; +} + +static VALUE +rg_add_signal(int argc, VALUE *argv, VALUE self) +{ + VALUE keyval, modifiers, signame, rest; + long i; + VALUE param; + GSList *slist, *free_slist; + + slist = NULL; + + rb_scan_args(argc, argv, "3*", &keyval, &modifiers, &signame, &rest); + + for (i = 0; i < RARRAY_LEN(rest); i++) { + GtkBindingArg *arg; + + arg = g_new0 (GtkBindingArg, 1); + slist = g_slist_prepend (slist, arg); + + param = RARRAY_PTR(rest)[i]; + if (TYPE(param) == T_FLOAT) { + arg->arg_type = G_TYPE_DOUBLE; + arg->d.double_data = NUM2DBL(param); + } else if (rb_respond_to (param, rb_intern("to_int"))) { + arg->arg_type = G_TYPE_LONG; + arg->d.long_data = NUM2LONG(param); + } else if (param == Qfalse) { + arg->arg_type = G_TYPE_LONG; + arg->d.long_data = 0; + } else if (param == Qtrue) { + arg->arg_type = G_TYPE_LONG; + arg->d.long_data = 1; + } else if (rb_respond_to (param, rb_intern("to_str"))) { + arg->arg_type = G_TYPE_STRING; + arg->d.string_data = (gchar *)RVAL2CSTR(param); + } else { + rb_raise(rb_eTypeError, + "can not convert %s into String, Numeric, " + "GLib::Enum/GLib::Flags or true/false", + rb_class2name(CLASS_OF(param))); + + } + } + slist = g_slist_reverse (slist); + gtk_binding_entry_add_signall (_SELF(self), NUM2UINT(keyval), RVAL2MOD(modifiers), + RVAL2CSTR(signame), slist); + free_slist = slist; + while (slist) { + g_free (slist->data); + slist = slist->next; + } + g_slist_free (free_slist); + + return self; +} + +static VALUE +rg_add_path(VALUE self, VALUE path_type, VALUE path_pattern, VALUE priority) +{ + gtk_binding_set_add_path(_SELF(self), RVAL2GENUM(path_type, GTK_TYPE_PATH_TYPE), + RVAL2CSTR(path_pattern), + RVAL2GENUM(priority, GTK_TYPE_PATH_PRIORITY_TYPE)); + return self; +} + +static VALUE +rg_entry_remove(VALUE self, VALUE keyval, VALUE modifiers) +{ + gtk_binding_entry_remove(_SELF(self), NUM2UINT(keyval), RVAL2MOD(modifiers)); + return self; +} + +#if GTK_CHECK_VERSION(2,12,0) +static VALUE +rg_entry_skip(VALUE self, VALUE keyval, VALUE modifiers) +{ + gtk_binding_entry_skip(_SELF(self), NUM2UINT(keyval), RVAL2MOD(modifiers)); + return self; +} +#endif + +void +Init_gtk_bindings(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_BINDING_SET, "BindingSet", mGtk); + RG_DEF_METHOD(initialize, 1); + RG_DEF_SMETHOD(find, 1); + RG_DEF_METHOD(activate, 3); + RG_DEF_METHOD(entry_clear, 2); + RG_DEF_METHOD(add_signal, -1); + RG_DEF_ALIAS("entry_add_signal", "add_signal"); + RG_DEF_METHOD(add_path, 3); + RG_DEF_METHOD(entry_remove, 2); +#if GTK_CHECK_VERSION(2,12,0) + RG_DEF_METHOD(entry_skip, 2); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkborder.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkborder.c new file mode 100644 index 0000000..4cd4d96 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkborder.c @@ -0,0 +1,87 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cBorder +#define _SELF(self) ((GtkBorder*)RVAL2BOXED(self, GTK_TYPE_BORDER)) + +#define ATTR_INT(name)\ +static VALUE \ +border_int_ ## name (VALUE self)\ +{\ + return INT2NUM(_SELF(self)->name);\ +}\ +static VALUE \ +border_int_set_ ## name (VALUE self, VALUE val)\ +{\ + _SELF(self)->name = NUM2INT(val); \ + return self;\ +} + +ATTR_INT(left); +ATTR_INT(right); +ATTR_INT(top); +ATTR_INT(bottom); + +#define DEFINE_ACCESSOR(gt, type, name) \ + rb_define_method(gt, G_STRINGIFY(name), border_ ## type ## _## name, 0);\ + rb_define_method(gt, G_STRINGIFY(set_ ## name), border_ ## type ## _set_## name, 1); + +static VALUE +rg_initialize(VALUE self, VALUE left, VALUE right, VALUE top, VALUE bottom) +{ + GtkBorder border; + border.left = NUM2INT(left); + border.right = NUM2INT(right); + border.top = NUM2INT(top); + border.bottom = NUM2INT(bottom); + + G_INITIALIZE(self, g_boxed_copy(GTK_TYPE_BORDER, &border)); + return Qnil; +} + +static VALUE +rg_to_a(VALUE self) +{ + GtkBorder* border = _SELF(self); + return rb_ary_new3(4, INT2NUM(border->left), INT2NUM(border->right), + INT2NUM(border->top), INT2NUM(border->bottom)); +} + +void +Init_gtk_border(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_BORDER, "Border", mGtk); + + RG_DEF_METHOD(initialize, 4); + RG_DEF_METHOD(to_a, 0); + + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, int, left); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, int, right); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, int, top); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, int, bottom); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbox.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbox.c new file mode 100644 index 0000000..8663bc1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbox.c @@ -0,0 +1,138 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cBox +#define _SELF(self) (GTK_BOX(RVAL2GOBJ(self))) +#define RVAL2WIDGET(w) (GTK_WIDGET(RVAL2GOBJ(w))) + +static void +box_pack_start_or_end(int argc, VALUE *argv, VALUE self, int start) +{ + VALUE arg0, arg1, arg2, arg3; + gint expand, fill, padding; + GtkWidget *widget, *child; + + expand = fill = Qtrue; padding = 0; + switch (rb_scan_args(argc, argv, "13", &arg0, &arg1, &arg2, &arg3)) { + case 4: + padding = NUM2INT(arg3); + case 3: + fill = RVAL2CBOOL(arg2); + case 2: + expand = RVAL2CBOOL(arg1); + default: + child = GTK_WIDGET(RVAL2GOBJ(arg0)); + G_CHILD_ADD(self, arg0); + break; + } + widget = GTK_WIDGET(RVAL2GOBJ(self)); + + if (start) + gtk_box_pack_start(_SELF(self), child, expand, fill, padding); + else + gtk_box_pack_end(_SELF(self), child, expand, fill, padding); +} + +static VALUE +rg_pack_start(int argc, VALUE *argv, VALUE self) +{ + box_pack_start_or_end(argc, argv, self, 1); + return self; +} + +static VALUE +rg_pack_end(int argc, VALUE *argv, VALUE self) +{ + box_pack_start_or_end(argc, argv, self, 0); + return self; +} + +static VALUE +rg_pack_start_defaults(VALUE self, VALUE widget) +{ + gtk_box_pack_start_defaults(_SELF(self), RVAL2WIDGET(widget)); + return self; +} + +static VALUE +rg_pack_end_defaults(VALUE self, VALUE widget) +{ + gtk_box_pack_end_defaults(_SELF(self), RVAL2WIDGET(widget)); + return self; +} + +static VALUE +rg_reorder_child(VALUE self, VALUE child, VALUE pos) +{ + gtk_box_reorder_child(_SELF(self), + RVAL2WIDGET(child), NUM2INT(pos)); + return self; +} + +static VALUE +rg_query_child_packing(VALUE self, VALUE child) +{ + gboolean expand, fill; + guint padding; + GtkPackType pack_type; + VALUE ary; + + gtk_box_query_child_packing(_SELF(self), + RVAL2WIDGET(child), + &expand, &fill, &padding, &pack_type); + + ary = rb_ary_new2(4); + rb_ary_push(ary, expand == FALSE ? Qfalse : Qtrue); + rb_ary_push(ary, fill == FALSE ? Qfalse : Qtrue); + rb_ary_push(ary, INT2NUM(padding)); + rb_ary_push(ary, GENUM2RVAL(pack_type, GTK_TYPE_PACK_TYPE)); + + return ary; +} + +static VALUE +rg_set_child_packing(VALUE self, VALUE child, VALUE expand, VALUE fill, VALUE padding, VALUE pack_type) +{ + gtk_box_set_child_packing(_SELF(self), + RVAL2WIDGET(child), + RVAL2CBOOL(expand), RVAL2CBOOL(fill), + NUM2UINT(padding), RVAL2GENUM(pack_type, GTK_TYPE_PACK_TYPE)); + return self; +} + +void +Init_gtk_box(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_BOX, "Box", mGtk); + + RG_DEF_METHOD(pack_start, -1); + RG_DEF_METHOD(pack_end, -1); + RG_DEF_METHOD(pack_start_defaults, 1); + RG_DEF_METHOD(pack_end_defaults, 1); + RG_DEF_METHOD(reorder_child, 2); + RG_DEF_METHOD(query_child_packing, 1); + RG_DEF_METHOD(set_child_packing, 5); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbuildable.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbuildable.c new file mode 100644 index 0000000..9f97042 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbuildable.c @@ -0,0 +1,127 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2, 12, 0) + +#define RG_TARGET_NAMESPACE cBuildable +#define _SELF(self) (GTK_BUILDABLE(RVAL2GOBJ(self))) +#define RVAL2BUILDER(obj) (GTK_BUILDER(RVAL2GOBJ(obj))) + +static VALUE +rg_builder_name(VALUE self) +{ + return CSTR2RVAL(gtk_buildable_get_name(_SELF(self))); +} + +static VALUE +rg_set_builder_name(VALUE self, VALUE name) +{ + gtk_buildable_set_name(_SELF(self), RVAL2CSTR(name)); + return self; +} + +static VALUE +rg_add_child(int argc, VALUE *argv, VALUE self) +{ + VALUE builder, child, type; + + rb_scan_args(argc, argv, "21", &builder, &child, &type); + gtk_buildable_add_child(_SELF(self), RVAL2BUILDER(builder), RVAL2GOBJ(child), + RVAL2CSTR_ACCEPT_NIL(type)); + return self; +} + +static VALUE +rg_set_buildable_property(VALUE self, VALUE rb_builder, + VALUE rb_name, VALUE rb_value) +{ + GtkBuilder *builder; + const gchar *name; + GValue value = G_VALUE_INIT; + + builder = RVAL2BUILDER(rb_builder); + name = RVAL2CSTR(rb_name); + rbgobj_initialize_gvalue(&value, rb_value); + gtk_buildable_set_buildable_property(_SELF(self), builder, name, &value); + + return self; +} + +static VALUE +rg_construct_child(VALUE self, VALUE builder, VALUE name) +{ + return GOBJ2RVAL(gtk_buildable_construct_child(_SELF(self), + RVAL2BUILDER(builder), + RVAL2CSTR(name))); +} + +/* + customized buildable is not supported yet. + +gboolean gtk_buildable_custom_tag_start (GtkBuildable *buildable, + GtkBuilder *builder, + GObject *child, + const gchar *tagname, + GMarkupParser *parser, + gpointer *data); +void gtk_buildable_custom_tag_end (GtkBuildable *buildable, + GtkBuilder *builder, + GObject *child, + const gchar *tagname, + gpointer *data); +void gtk_buildable_custom_finished (GtkBuildable *buildable, + GtkBuilder *builder, + GObject *child, + const gchar *tagname, + gpointer data); +void gtk_buildable_parser_finished (GtkBuildable *buildable, + GtkBuilder *builder); +*/ + +static VALUE +rg_get_internal_child(VALUE self, VALUE builder, VALUE child_name) +{ + return GOBJ2RVAL(gtk_buildable_get_internal_child(_SELF(self), + RVAL2BUILDER(builder), + RVAL2CSTR(child_name))); +} +#endif + +void +Init_gtk_buildable(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2, 12, 0) + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_BUILDABLE, "Buildable", mGtk); + + RG_DEF_METHOD(builder_name, 0); + RG_DEF_METHOD(set_builder_name, 1); + RG_DEF_METHOD(add_child, -1); + RG_DEF_METHOD(set_buildable_property, 3); + RG_DEF_METHOD(construct_child, 2); + RG_DEF_METHOD(get_internal_child, 2); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbuilder.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbuilder.c new file mode 100644 index 0000000..30772e6 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbuilder.c @@ -0,0 +1,170 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" +#include /* From Ruby/GLib2 */ + +#if GTK_CHECK_VERSION(2, 12, 0) + +#define RG_TARGET_NAMESPACE cBuilder +#define _SELF(self) (GTK_BUILDER(RVAL2GOBJ(self))) + +static ID id___connect_signals__; + +static void +builder_mark(gpointer object) +{ + GtkBuilder *builder = object; + GSList *objects; + + objects = gtk_builder_get_objects(builder); + g_slist_foreach(objects, (GFunc)rbgobj_gc_mark_instance, NULL); + g_slist_free(objects); +} + +static VALUE +rg_initialize(VALUE self) +{ + GtkBuilder *builder; + + builder = gtk_builder_new(); + G_INITIALIZE(self, builder); + + return Qnil; +} + +static VALUE +rg_add_from_file(VALUE self, VALUE filename) +{ + GError *error = NULL; + + if (gtk_builder_add_from_file(_SELF(self), + RVAL2CSTR(filename), + &error) == 0) + RAISE_GERROR(error); + + return self; +} + +static VALUE +rg_add_from_string(VALUE self, VALUE string) +{ + GError *error = NULL; + + StringValue(string); + if (gtk_builder_add_from_string(_SELF(self), + RSTRING_PTR(string), + RSTRING_LEN(string), + &error) == 0) + RAISE_GERROR(error); + + return self; +} + +static VALUE +rg_add(VALUE self, VALUE filename_or_xml) +{ + const char xml_detect_re_str[] = "(?:\\A<|[\\r\\n])"; + VALUE xml_detect_re; + + xml_detect_re = rb_reg_new(xml_detect_re_str, strlen(xml_detect_re_str), 0); + if (NIL_P(rb_reg_match(xml_detect_re, filename_or_xml))) + return rg_add_from_file(self, filename_or_xml); + else + return rg_add_from_string(self, filename_or_xml); +} + +static VALUE +rg_get_object(VALUE self, VALUE name) +{ + return GOBJ2RVAL(gtk_builder_get_object(_SELF(self), RVAL2CSTR(name))); +} + +static VALUE +rg_objects(VALUE self) +{ + return GSLIST2ARY_FREE(gtk_builder_get_objects(_SELF(self))); +} + +static void +connect_signals(GtkBuilder *builder, GObject *object, const gchar *signal_name, + const gchar *handler_name, GObject *connect_object, + GConnectFlags flags, gpointer user_data) +{ + VALUE signal_connector = (VALUE)user_data; + + rb_funcall(GOBJ2RVAL(builder), id___connect_signals__, 6, + signal_connector, GOBJ2RVAL(object), CSTR2RVAL(signal_name), + CSTR2RVAL(handler_name), GOBJ2RVAL(connect_object), + GFLAGS2RVAL(flags, G_TYPE_CONNECT_FLAGS)); +} + +static VALUE +rg_connect_signals(VALUE self) +{ + VALUE signal_connector; + + signal_connector = rb_block_proc(); + G_CHILD_ADD(self, signal_connector); + gtk_builder_connect_signals_full(_SELF(self), connect_signals, + (gpointer)signal_connector); + G_CHILD_REMOVE(self, signal_connector); + + return self; +} + +static VALUE +rg_get_type(VALUE self, VALUE name) +{ + return GTYPE2CLASS(gtk_builder_get_type_from_name(_SELF(self), + RVAL2CSTR(name))); +} +#endif + +void +Init_gtk_builder(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2, 12, 0) + VALUE RG_TARGET_NAMESPACE; + + id___connect_signals__ = rb_intern("__connect_signals__"); + + RG_TARGET_NAMESPACE = G_DEF_CLASS_WITH_GC_FUNC(GTK_TYPE_BUILDER, "Builder", mGtk, + builder_mark, NULL); + + G_DEF_CLASS(GTK_TYPE_BUILDER_ERROR, "BuilderError", mGtk); + + RG_DEF_METHOD(initialize, 0); + + RG_DEF_METHOD(add_from_file, 1); + RG_DEF_METHOD(add_from_string, 1); + RG_DEF_METHOD(add, 1); + RG_DEF_ALIAS("<<", "add"); + + RG_DEF_METHOD(get_object, 1); + RG_DEF_ALIAS("[]", "get_object"); + RG_DEF_METHOD(objects, 0); + + RG_DEF_METHOD(connect_signals, 0); + + RG_DEF_METHOD(get_type, 1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbutton.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbutton.c new file mode 100644 index 0000000..a57ae7a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkbutton.c @@ -0,0 +1,119 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cButton +#define _SELF(self) (GTK_BUTTON(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE label, use_underline; + GtkWidget *widget = NULL; + + if (rb_scan_args(argc, argv, "02", &label, &use_underline) > 0) { + if (TYPE(label) == T_STRING){ + if (NIL_P(use_underline) || RVAL2CBOOL(use_underline)){ + widget = gtk_button_new_with_mnemonic(RVAL2CSTR(label)); + } else { + widget = gtk_button_new_with_label(RVAL2CSTR(label)); + } + } else if (TYPE(label) == T_SYMBOL){ + widget = gtk_button_new_from_stock(rb_id2name(SYM2ID(label))); + } else { + rb_raise(rb_eArgError, "invalid argument %s (expect Symbol(Gtk::Stock constants) or String)", + rb_class2name(CLASS_OF(label))); + } + } else { + widget = gtk_button_new(); + } + + RBGTK_INITIALIZE(self, widget); + return Qnil; +} + +static VALUE +rg_pressed(VALUE self) +{ + gtk_button_pressed(GTK_BUTTON(RVAL2GOBJ(self))); + return self; +} + +static VALUE +rg_released(VALUE self) +{ + gtk_button_released(_SELF(self)); + return self; +} + +static VALUE +rg_enter(VALUE self) +{ + gtk_button_enter(_SELF(self)); + return self; +} + +static VALUE +rg_leave(VALUE self) +{ + gtk_button_leave(_SELF(self)); + return self; +} + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_set_alignment(VALUE self, VALUE xalign, VALUE yalign) +{ + gtk_button_set_alignment(_SELF(self), NUM2DBL(xalign), NUM2DBL(yalign)); + return self; +} + +static VALUE +rg_alignment(VALUE self) +{ + gfloat xalign, yalign; + gtk_button_get_alignment(_SELF(self), &xalign, &yalign); + + return rb_assoc_new(rb_float_new(xalign), rb_float_new(yalign)); +} +#endif + +void +Init_gtk_button(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_BUTTON, "Button", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(pressed, 0); + RG_DEF_METHOD(released, 0); + RG_DEF_METHOD(enter, 0); + RG_DEF_METHOD(leave, 0); + +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(set_alignment, 2); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "alignment"); + RG_DEF_METHOD(alignment, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcalendar.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcalendar.c new file mode 100644 index 0000000..f9b0666 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcalendar.c @@ -0,0 +1,157 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cCalendar +#define _SELF(self) (GTK_CALENDAR(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_calendar_new()); + return Qnil; +} + +static VALUE +rg_select_month(VALUE self, VALUE month, VALUE year) +{ + gint ret = gtk_calendar_select_month(_SELF(self), + NUM2INT(month)-1, + NUM2INT(year)); + return INT2FIX(ret); +} + +static VALUE +rg_select_day(VALUE self, VALUE day) +{ + gtk_calendar_select_day(_SELF(self), NUM2INT(day)); + return self; +} + +static VALUE +rg_mark_day(VALUE self, VALUE day) +{ + gtk_calendar_mark_day(_SELF(self), NUM2INT(day)); + return self; +} + +static VALUE +rg_unmark_day(VALUE self, VALUE day) +{ + gtk_calendar_unmark_day(_SELF(self), NUM2INT(day)); + return self; +} + +static VALUE +rg_clear_marks(VALUE self) +{ + gtk_calendar_clear_marks(_SELF(self)); + return self; +} + +static VALUE +rg_date(VALUE self) +{ + VALUE ret; + guint year, month, day; + + gtk_calendar_get_date(_SELF(self), &year, &month, &day); + ret = rb_ary_new(); + rb_ary_push(ret, INT2FIX(year)); + rb_ary_push(ret, INT2FIX(month+1)); + rb_ary_push(ret, INT2FIX(day)); + return ret; +} + +static VALUE +rg_freeze(VALUE self) +{ + gtk_calendar_freeze(_SELF(self)); + return self; +} + +static VALUE +rg_thaw(VALUE self) +{ + gtk_calendar_thaw(_SELF(self)); + return self; +} + +static VALUE +rg_display_options(int argc, VALUE *argv, VALUE self) +{ + VALUE flags; + rb_scan_args(argc, argv, "01", &flags); + + if (NIL_P(flags)){ +#if GTK_CHECK_VERSION(2,4,0) + return GFLAGS2RVAL(gtk_calendar_get_display_options(_SELF(self)), + GTK_TYPE_CALENDAR_DISPLAY_OPTIONS); +#else + rb_warn("Gtk::Calendar#display_options has supported since GTK+-2.4."); +#endif + } else { + /* This is for backward compatibility. */ + rb_warning("Gtk::Calendar#display_options(flags) has been deprecated. Use Gtk::Calendar#set_display_options(flags)."); + gtk_calendar_display_options(_SELF(self), + RVAL2GFLAGS(flags, GTK_TYPE_CALENDAR_DISPLAY_OPTIONS)); + } + return self; +} + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_set_display_options(VALUE self, VALUE flags) +{ + gtk_calendar_set_display_options(_SELF(self), + RVAL2GFLAGS(flags, + GTK_TYPE_CALENDAR_DISPLAY_OPTIONS)); + return self; +} +#endif + +void +Init_gtk_calendar(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_CALENDAR, "Calendar", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(select_month, 2); + RG_DEF_METHOD(select_day, 1); + RG_DEF_METHOD(mark_day, 1); + RG_DEF_METHOD(unmark_day, 1); + RG_DEF_METHOD(clear_marks, 0); + RG_DEF_METHOD(date, 0); + RG_DEF_METHOD(freeze, 0); + RG_DEF_METHOD(thaw, 0); + RG_DEF_METHOD(display_options, -1); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(set_display_options, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "display_options"); +#endif + + G_DEF_CLASS(GTK_TYPE_CALENDAR_DISPLAY_OPTIONS, "DisplayOptions", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_CALENDAR_DISPLAY_OPTIONS, "GTK_CALENDAR_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcelleditable.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcelleditable.c new file mode 100644 index 0000000..7710ed1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcelleditable.c @@ -0,0 +1,57 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE mCellEditable +#define _SELF(s) (GTK_CELL_EDITABLE(RVAL2GOBJ(s))) + +static VALUE +rg_start_editing(VALUE self, VALUE event) +{ + gtk_cell_editable_start_editing(_SELF(self), + NIL_P(event) ? NULL : RVAL2GEV(event)); + return self; +} + +static VALUE +rg_editing_done(VALUE self) +{ + gtk_cell_editable_editing_done(_SELF(self)); + return self; +} + +static VALUE +rg_remove_widget(VALUE self) +{ + gtk_cell_editable_remove_widget(_SELF(self)); + return self; +} + +void +Init_gtk_celleditable(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(GTK_TYPE_CELL_EDITABLE, "CellEditable", mGtk); + + RG_DEF_METHOD(start_editing, 1); + RG_DEF_METHOD(editing_done, 0); + RG_DEF_METHOD(remove_widget, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcelllayout.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcelllayout.c new file mode 100644 index 0000000..49e715d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcelllayout.c @@ -0,0 +1,142 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE mCellLayout +#define _SELF(s) (GTK_CELL_LAYOUT(RVAL2GOBJ(s))) +#define RVAL2RENDERER(s) (GTK_CELL_RENDERER(RVAL2GOBJ(s))) + +static VALUE +rg_pack_start(VALUE self, VALUE cell, VALUE expand) +{ + gtk_cell_layout_pack_start(_SELF(self), RVAL2RENDERER(cell), + RVAL2CBOOL(expand)); + return self; +} + +static VALUE +rg_pack_end(VALUE self, VALUE cell, VALUE expand) +{ + gtk_cell_layout_pack_end(_SELF(self), RVAL2RENDERER(cell), + RVAL2CBOOL(expand)); + return self; +} + +static VALUE +rg_reorder(VALUE self, VALUE cell, VALUE position) +{ + gtk_cell_layout_reorder(_SELF(self), RVAL2RENDERER(cell), + NUM2INT(position)); + return self; +} + +static VALUE +rg_clear(VALUE self) +{ + gtk_cell_layout_clear(_SELF(self)); + return self; +} + +static VALUE +rg_add_attribute(VALUE self, VALUE cell, VALUE attribute, VALUE column) +{ + const gchar *name; + + if (SYMBOL_P(attribute)) { + name = rb_id2name(SYM2ID(attribute)); + } else { + name = RVAL2CSTR(attribute); + } + + gtk_cell_layout_add_attribute(_SELF(self), RVAL2RENDERER(cell), + name, NUM2INT(column)); + return self; +} + +static void +layout_data_func(GtkCellLayout *layout, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer func) +{ + iter->user_data3 = tree_model; + rb_funcall((VALUE)func, id_call, 4, GOBJ2RVAL(layout), GOBJ2RVAL(cell), + GOBJ2RVAL(tree_model), GTKTREEITER2RVAL(iter)); +} + +static VALUE +rg_set_cell_data_func(VALUE self, VALUE cell) +{ + if (rb_block_given_p()) { + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_cell_layout_set_cell_data_func(_SELF(self), RVAL2RENDERER(cell), + (GtkCellLayoutDataFunc)layout_data_func, + (gpointer)func, NULL); + } else { + gtk_cell_layout_set_cell_data_func(_SELF(self), RVAL2RENDERER(cell), + NULL, (gpointer)NULL, NULL); + } + return self; +} + +static VALUE +rg_clear_attributes(VALUE self, VALUE cell) +{ + gtk_cell_layout_clear_attributes(_SELF(self), RVAL2RENDERER(cell)); + return self; +} + +static VALUE +rg_set_attributes(VALUE self, VALUE cell, VALUE attrs) +{ + gint i; + VALUE ary; + Check_Type(attrs, T_HASH); + + rg_clear_attributes(self, cell); + + ary = rb_funcall(attrs, rb_intern("to_a"), 0); + for (i = 0; i < RARRAY_LEN(ary); i++){ + rg_add_attribute(self, cell, + RARRAY_PTR(RARRAY_PTR(ary)[i])[0], + RARRAY_PTR(RARRAY_PTR(ary)[i])[1]); + } + return self; +} +#endif + +void +Init_gtk_celllayout(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(GTK_TYPE_CELL_LAYOUT, "CellLayout", mGtk); + + RG_DEF_METHOD(pack_start, 2); + RG_DEF_METHOD(pack_end, 2); + RG_DEF_METHOD(reorder, 2); + RG_DEF_METHOD(clear, 0); + RG_DEF_METHOD(add_attribute, 3); + RG_DEF_METHOD(set_cell_data_func, 1); + RG_DEF_METHOD(clear_attributes, 1); + RG_DEF_METHOD(set_attributes, 2); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrenderer.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrenderer.c new file mode 100644 index 0000000..a3c1400 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrenderer.c @@ -0,0 +1,139 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cCellRenderer +#define _SELF(s) (GTK_CELL_RENDERER(RVAL2GOBJ(s))) +#define RVAL2RECT(r) ((GdkRectangle*)RVAL2BOXED(r, GDK_TYPE_RECTANGLE)) +#define RECT2RVAL(r) (BOXED2RVAL(r, GDK_TYPE_RECTANGLE)) + +static VALUE +rg_get_size(VALUE self, VALUE widget, VALUE cell_area) +{ + GdkRectangle ret; + + gtk_cell_renderer_get_size(_SELF(self), GTK_WIDGET(RVAL2GOBJ(widget)), + RVAL2RECT(cell_area), + &ret.x, &ret.y, &ret.width, &ret.height); + return RECT2RVAL(&ret); +} + +static VALUE +rg_render(VALUE self, VALUE window, VALUE widget, VALUE background_area, VALUE cell_area, VALUE expose_area, VALUE flags) +{ + gtk_cell_renderer_render(_SELF(self), GDK_WINDOW(RVAL2GOBJ(window)), + GTK_WIDGET(RVAL2GOBJ(widget)), + RVAL2RECT(background_area), + RVAL2RECT(cell_area), + RVAL2RECT(expose_area), + RVAL2GFLAGS(flags, GTK_TYPE_CELL_RENDERER_STATE)); + return self; +} + +static VALUE +rg_activate(VALUE self, VALUE event, VALUE widget, VALUE path, VALUE background_area, VALUE cell_area, VALUE flags) +{ + gboolean ret = + gtk_cell_renderer_activate(_SELF(self), (GdkEvent*)RVAL2GEV(event), + GTK_WIDGET(RVAL2GOBJ(widget)), + RVAL2CSTR(path), RVAL2RECT(background_area), + RVAL2RECT(cell_area), + RVAL2GFLAGS(flags, GTK_TYPE_CELL_RENDERER_STATE)); + return CBOOL2RVAL(ret); +} + +static VALUE +rg_start_editing(VALUE self, VALUE event, VALUE widget, VALUE path, VALUE background_area, VALUE cell_area, VALUE flags) +{ + GtkCellEditable* edit = + gtk_cell_renderer_start_editing(_SELF(self), (GdkEvent*)RVAL2GEV(event), + GTK_WIDGET(RVAL2GOBJ(widget)), + RVAL2CSTR(path), RVAL2RECT(background_area), + RVAL2RECT(cell_area), + RVAL2GFLAGS(flags, GTK_TYPE_CELL_RENDERER_STATE)); + return edit ? GOBJ2RVAL(edit) : Qnil; +} + +#if GTK_CHECK_VERSION(2,4,0) +#ifndef GTK_DISABLE_DEPRECATED +static VALUE +rg_editing_canceled(VALUE self) +{ + gtk_cell_renderer_editing_canceled(_SELF(self)); + return self; +} +#endif +#endif + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_stop_editing(VALUE self, VALUE canceled) +{ + gtk_cell_renderer_stop_editing(_SELF(self), RVAL2CBOOL(canceled)); + return self; +} +#endif + +static VALUE +rg_fixed_size(VALUE self) +{ + int width, height; + gtk_cell_renderer_get_fixed_size(_SELF(self), &width, &height); + return rb_ary_new3(2, INT2NUM(width), INT2NUM(height)); +} + +static VALUE +rg_set_fixed_size(VALUE self, VALUE width, VALUE height) +{ + gtk_cell_renderer_set_fixed_size(_SELF(self), NUM2INT(width), + NUM2INT(height)); + return self; +} + +void +Init_gtk_cellrenderer(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_CELL_RENDERER, "CellRenderer", mGtk); + + RG_DEF_METHOD(get_size, 2); + RG_DEF_METHOD(render, 6); + RG_DEF_METHOD(activate, 6); + RG_DEF_METHOD(start_editing, 6); +#if GTK_CHECK_VERSION(2,4,0) +#ifndef GTK_DISABLE_DEPRECATED + RG_DEF_METHOD(editing_canceled, 0); +#endif +#endif +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(stop_editing, 1); +#endif + RG_DEF_METHOD(fixed_size, 0); + RG_DEF_METHOD(set_fixed_size, 2); + + /* GtkCellRendererState */ + G_DEF_CLASS(GTK_TYPE_CELL_RENDERER_STATE, "State", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_CELL_RENDERER_STATE, "GTK_CELL_RENDERER_"); + + /* GtkCellRendererMode */ + G_DEF_CLASS(GTK_TYPE_CELL_RENDERER_MODE, "Mode", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_CELL_RENDERER_MODE, "GTK_CELL_RENDERER_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrendereraccel.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrendereraccel.c new file mode 100644 index 0000000..c368cb0 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrendereraccel.c @@ -0,0 +1,49 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Ruby-GNOME2 Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +#define RG_TARGET_NAMESPACE cCellRendererAccel +#define _SELF(s) (GTK_CELL_RENDERER_ACCEL(RVAL2GOBJ(s))) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_cell_renderer_accel_new()); + return Qnil; +} + +#endif + +void +Init_gtk_cellrendereraccel(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_CELL_RENDERER_ACCEL, "CellRendererAccel", mGtk); + RG_DEF_METHOD(initialize, 0); + + /* GtkCellRendererAccelMode */ + G_DEF_CLASS(GTK_TYPE_CELL_RENDERER_ACCEL_MODE, "Mode", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_CELL_RENDERER_ACCEL_MODE, "GTK_CELL_RENDERER_ACCEL_"); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrenderercombo.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrenderercombo.c new file mode 100644 index 0000000..a04e3c9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrenderercombo.c @@ -0,0 +1,44 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,6,0) + +#define RG_TARGET_NAMESPACE cCellRendererCombo + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_cell_renderer_combo_new()); + return Qnil; +} + +#endif + +void +Init_gtk_cellrenderercombo(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,6,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_CELL_RENDERER_COMBO, "CellRendererCombo", mGtk); + RG_DEF_METHOD(initialize, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrendererpixbuf.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrendererpixbuf.c new file mode 100644 index 0000000..528ad05 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrendererpixbuf.c @@ -0,0 +1,39 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cCellRendererPixbuf +#define _SELF(s) (GTK_CELL_RENDERER_PIXBUF(RVAL2GOBJ(s))) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_cell_renderer_pixbuf_new()); + return Qnil; +} + +void +Init_gtk_cellrendererpixbuf(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_CELL_RENDERER_PIXBUF, "CellRendererPixbuf", mGtk); + RG_DEF_METHOD(initialize, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrendererprogress.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrendererprogress.c new file mode 100644 index 0000000..c4481fb --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrendererprogress.c @@ -0,0 +1,44 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Darren Willis + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,6,0) + +#define RG_TARGET_NAMESPACE cCellRendererProgress + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_cell_renderer_progress_new()); + return Qnil; +} + +#endif + +void +Init_gtk_cellrendererprogress(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,6,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_CELL_RENDERER_PROGRESS, "CellRendererProgress", mGtk); + RG_DEF_METHOD(initialize, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrendererspin.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrendererspin.c new file mode 100644 index 0000000..f26de87 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrendererspin.c @@ -0,0 +1,45 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Ruby-GNOME2 Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +#define RG_TARGET_NAMESPACE cCellRendererSpin +#define _SELF(s) (GTK_CELL_RENDERER_SPIN(RVAL2GOBJ(s))) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_cell_renderer_spin_new()); + return Qnil; +} + +#endif + +void +Init_gtk_cellrendererspin(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_CELL_RENDERER_SPIN, "CellRendererSpin", mGtk); + RG_DEF_METHOD(initialize, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrendererspinner.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrendererspinner.c new file mode 100644 index 0000000..c800778 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrendererspinner.c @@ -0,0 +1,44 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,20,0) + +#define RG_TARGET_NAMESPACE cCellRendererSpinner +#define _SELF(s) (GTK_CELL_RENDERER_SPINNER(RVAL2GOBJ(s))) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_cell_renderer_spinner_new()); + return Qnil; +} + +#endif + +void +Init_gtk_cellrendererspinner(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,20,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_CELL_RENDERER_SPINNER, "CellRendererSpinner", mGtk); + RG_DEF_METHOD(initialize, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrenderertext.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrenderertext.c new file mode 100644 index 0000000..4dec8a9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrenderertext.c @@ -0,0 +1,49 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cCellRendererText +#define _SELF(s) (GTK_CELL_RENDERER_TEXT(RVAL2GOBJ(s))) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_cell_renderer_text_new()); + return Qnil; +} + +static VALUE +rg_set_fixed_height_from_font(VALUE self, VALUE number_of_rows) +{ + gtk_cell_renderer_text_set_fixed_height_from_font(_SELF(self), NUM2INT(number_of_rows)); + return self; +} + +void +Init_gtk_cellrenderertext(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_CELL_RENDERER_TEXT, "CellRendererText", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(set_fixed_height_from_font, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "fixed_height_from_font"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrenderertoggle.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrenderertoggle.c new file mode 100644 index 0000000..3e05dfb --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellrenderertoggle.c @@ -0,0 +1,39 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cCellRendererToggle +#define _SELF(s) (GTK_CELL_RENDERER_TOGGLE(RVAL2GOBJ(s))) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_cell_renderer_toggle_new()); + return Qnil; +} + +void +Init_gtk_cellrenderertoggle(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_CELL_RENDERER_TOGGLE, "CellRendererToggle", mGtk); + RG_DEF_METHOD(initialize, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellview.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellview.c new file mode 100644 index 0000000..6b6f5b5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcellview.c @@ -0,0 +1,122 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005,2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,6,0) + +#define RG_TARGET_NAMESPACE cCellView +#define _SELF(self) (GTK_CELL_VIEW(RVAL2GOBJ(self))) + +static ID id_model; +static ID id_text; + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE text; + VALUE with_markup = Qnil; + GtkWidget *widget = NULL; + + rb_scan_args(argc, argv, "02", &text, &with_markup); + + if (NIL_P(text)) { + widget = gtk_cell_view_new(); + } else { + G_CHILD_SET(self, id_text, text); + if (TYPE(text) == T_STRING){ + if (NIL_P(with_markup) || RVAL2CBOOL(with_markup)){ + widget = gtk_cell_view_new_with_markup(RVAL2CSTR(text)); + } else { + widget = gtk_cell_view_new_with_text(RVAL2CSTR(text)); + } + } else if (rb_obj_is_kind_of(text, GTYPE2CLASS(GDK_TYPE_PIXBUF))){ + widget = gtk_cell_view_new_with_pixbuf(GDK_PIXBUF(RVAL2GOBJ(text))); + } else { + rb_raise(rb_eArgError, + "invalid argument %s (expect String or Gdk::Pixbuf)", + rb_class2name(CLASS_OF(text))); + } + } + + RBGTK_INITIALIZE(self, widget); + + return Qnil; +} + +static VALUE +rg_set_displayed_row(VALUE self, VALUE path) +{ + gtk_cell_view_set_displayed_row(_SELF(self), + NIL_P(path) ? (GtkTreePath*)NULL : + RVAL2GTKTREEPATH(path)); + return self; +} + +static VALUE +rg_displayed_row(VALUE self) +{ + return GTKTREEPATH2RVAL(gtk_cell_view_get_displayed_row(_SELF(self))); +} + +static VALUE +rg_get_size_of_row(VALUE self, VALUE path) +{ + GtkRequisition req; + gboolean ret = gtk_cell_view_get_size_of_row(_SELF(self), + RVAL2GTKTREEPATH(path), + &req); + if (! ret) + rb_raise(rb_eRuntimeError, "Can't get the value"); + + return rb_ary_assoc(INT2NUM(req.width), INT2NUM(req.height)); +} + +/* Use Gtk::CellView#background_gdk(Gdk::Color) instead. +void gtk_cell_view_set_background_color + (GtkCellView *cell_view, + const GdkColor *color); +*/ + +static VALUE +rg_cell_renderers(VALUE self) +{ + return GLIST2ARYF(gtk_cell_view_get_cell_renderers(_SELF(self))); +} +#endif + +void +Init_gtk_cellview(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,6,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_CELL_VIEW, "CellView", mGtk); + + id_model = rb_intern("model"); + id_text = rb_intern("text"); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(set_displayed_row, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "displayed_row"); + RG_DEF_METHOD(displayed_row, 0); + RG_DEF_METHOD(get_size_of_row, 1); + RG_DEF_METHOD(cell_renderers, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcheckbutton.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcheckbutton.c new file mode 100644 index 0000000..f236099 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcheckbutton.c @@ -0,0 +1,64 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cCheckButton + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE label, use_underline; + GtkWidget *widget; + + if (rb_scan_args(argc, argv, "02", &label, &use_underline) > 0) { + if (TYPE(label) == T_STRING){ + if (NIL_P(use_underline) || RVAL2CBOOL(use_underline)){ + widget = gtk_check_button_new_with_mnemonic(RVAL2CSTR(label)); + } else { + widget = gtk_check_button_new_with_label(RVAL2CSTR(label)); + } + } else if (TYPE(label) == T_SYMBOL){ + widget = gtk_check_button_new_with_label(rb_id2name(SYM2ID(label))); + gtk_button_set_use_stock(GTK_BUTTON(widget), TRUE); + } else { + rb_raise(rb_eArgError, "invalid argument %s (expect Symbol(Gtk::Stock constants) or String)", + rb_class2name(CLASS_OF(label))); + } + } + else { + widget = gtk_check_button_new(); + } + + RBGTK_INITIALIZE(self, widget); + return Qnil; +} + +void +Init_gtk_check_button(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_CHECK_BUTTON, "CheckButton", mGtk); + + RG_DEF_METHOD(initialize, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcheckmenuitem.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcheckmenuitem.c new file mode 100644 index 0000000..0148848 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcheckmenuitem.c @@ -0,0 +1,64 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cCheckMenuItem + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE label, use_underline; + GtkWidget *widget = NULL; + + if (rb_scan_args(argc, argv, "02", &label, &use_underline) > 0) { + if (NIL_P(use_underline) || RVAL2CBOOL(use_underline)){ + widget = gtk_check_menu_item_new_with_mnemonic(RVAL2CSTR(label)); + } else { + widget = gtk_check_menu_item_new_with_label(RVAL2CSTR(label)); + } + } + else { + widget = gtk_check_menu_item_new(); + } + + RBGTK_INITIALIZE(self, widget); + return Qnil; +} + +static VALUE +rg_toggled(VALUE self) +{ + gtk_check_menu_item_toggled(GTK_CHECK_MENU_ITEM(RVAL2GOBJ(self))); + return self; +} + +void +Init_gtk_check_menu_item(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_CHECK_MENU_ITEM, "CheckMenuItem", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(toggled, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkclipboard.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkclipboard.c new file mode 100644 index 0000000..ddf448b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkclipboard.c @@ -0,0 +1,473 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004,2006 Ruby-GNOME2 Project + * Copyright (C) 2002,2003 OGASAWARA, Takeshi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cClipboard +#define _SELF(s) RVAL2CLIPBOARD(s) + +#ifndef GTK_TYPE_CLIPBOARD +static GtkClipboard* +clipboard_copy(const GtkClipboard *clipboard) +{ + /* I don't know how to copy this object ... */ + return (GtkClipboard*)clipboard; +} + +GType +rbgtk_clipboard_get_type() +{ + static GType our_type = 0; + if(our_type == 0) + our_type = g_boxed_type_register_static("GtkClipboard", + (GBoxedCopyFunc)clipboard_copy, + (GBoxedFreeFunc)g_free); + return our_type; +} + +GtkClipboard* +rbgtk_get_clipboard(VALUE obj) +{ + return GTK_CLIPBOARD(RVAL2GOBJ(obj)); +} + +VALUE +rbgtk_make_clipboard(GtkClipboard *gobj) +{ + return GOBJ2RVAL(gobj); +} +#endif + +static VALUE +rg_s_get(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + GtkClipboard *clipboard; + + if (argc == 1){ + VALUE selection; + rb_scan_args(argc, argv, "10", &selection); + clipboard = gtk_clipboard_get(RVAL2ATOM(selection)); + } else { +#if GTK_CHECK_VERSION(2,2,0) + VALUE display, selection; + rb_scan_args(argc, argv, "20", &display, &selection); + clipboard = gtk_clipboard_get_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)), + RVAL2ATOM(selection)); +#else + rb_raise(rb_eArgError, "Wrong number of arguments: %d", argc); +#endif + } + return CLIPBOARD2RVAL(clipboard); +} + +static VALUE +rg_display(VALUE self) +{ +#if GTK_CHECK_VERSION(2,2,0) + return GOBJ2RVAL(gtk_clipboard_get_display(_SELF(self))); +#else + return Qnil; +#endif +} + +static void +clipboard_get_func(GtkClipboard *clipboard, GtkSelectionData *selection_data, G_GNUC_UNUSED guint info, gpointer func) +{ + rb_funcall((VALUE)func, id_call, 2, CLIPBOARD2RVAL(clipboard), + BOXED2RVAL(selection_data, GTK_TYPE_SELECTION_DATA)); +} + +struct clipboard_set_args { + VALUE self; + VALUE targets; + VALUE func; +}; + +static VALUE +clipboard_set_body(VALUE value) +{ + struct clipboard_set_args *args = (struct clipboard_set_args *)value; + GtkClipboard *clipboard = _SELF(args->self); + long n; + GtkTargetEntry *targets = RVAL2GTKTARGETENTRIES(args->targets, &n); + gboolean result = gtk_clipboard_set_with_data(clipboard, + targets, + n, + (GtkClipboardGetFunc)clipboard_get_func, + (GtkClipboardClearFunc)NULL, + (gpointer)args->func); + + g_free(targets); + + return CBOOL2RVAL(result); +} + +static G_GNUC_NORETURN VALUE +clipboard_set_rescue(VALUE value) +{ + struct clipboard_set_args *args = (struct clipboard_set_args *)value; + + G_CHILD_REMOVE(args->self, args->func); + + rb_exc_raise(rb_errinfo()); +} + +static VALUE +rg_set(VALUE self, VALUE targets) +{ + struct clipboard_set_args args = { self, targets, rb_block_proc() }; + + G_CHILD_ADD(self, args.func); + + return rb_rescue(clipboard_set_body, (VALUE)&args, + clipboard_set_rescue, (VALUE)&args); +} + +/* +Do not implement this. Use Gtk::Clipboard#set_with_data instead. +gboolean gtk_clipboard_set_with_owner (GtkClipboard *clipboard, + const GtkTargetEntry *targets, + guint n_targets, + GtkClipboardGetFunc get_func, + GtkClipboardClearFunc clear_func, + GObject *owner); + +static VALUE +rg_owner(VALUE self) +{ + GObject *gobj; + gobj = gtk_clipboard_get_owner(_SELF(self)); + return gobj ? GOBJ2RVAL(gobj) : Qnil; +} +*/ + +static VALUE +rg_clear(VALUE self) +{ + gtk_clipboard_clear(_SELF(self)); + return self; +} + +static VALUE +rg_set_text(VALUE self, VALUE text) +{ + StringValue(text); + gtk_clipboard_set_text(_SELF(self), RVAL2CSTR(text), RSTRING_LEN(text)); + return self; +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_set_image(VALUE self, VALUE pixbuf) +{ + gtk_clipboard_set_image(_SELF(self), GDK_PIXBUF(RVAL2GOBJ(pixbuf))); + return self; +} +#endif + +static void +clipboard_received_func(GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer func) +{ + rb_funcall((VALUE)func, id_call, 2, CLIPBOARD2RVAL(clipboard), + BOXED2RVAL(selection_data, GTK_TYPE_SELECTION_DATA)); +} + +static VALUE +rg_request_contents(VALUE self, VALUE target) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_clipboard_request_contents(_SELF(self), RVAL2ATOM(target), + (GtkClipboardReceivedFunc)clipboard_received_func, + (gpointer)func); + return self; +} + +static void +clipboard_text_received_func(GtkClipboard *clipboard, const gchar *text, + gpointer func) +{ + VALUE vtext = Qnil; + if (text) { + vtext = CSTR2RVAL(text); + } + + rb_funcall((VALUE)func, id_call, 2, CLIPBOARD2RVAL(clipboard), vtext); +} + +static VALUE +rg_request_text(VALUE self) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_clipboard_request_text(_SELF(self), + (GtkClipboardTextReceivedFunc)clipboard_text_received_func, + (gpointer)func); + return self; +} + +#if GTK_CHECK_VERSION(2,6,0) +static void +clipboard_image_received_func(GtkClipboard *clipboard, GdkPixbuf *pixbuf, gpointer func) +{ + rb_funcall((VALUE)func, id_call, 2, CLIPBOARD2RVAL(clipboard), + GOBJ2RVAL(pixbuf)); +} + +static VALUE +rg_request_image(VALUE self) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_clipboard_request_image(_SELF(self), + (GtkClipboardImageReceivedFunc)clipboard_image_received_func, + (gpointer)func); + return self; +} +#endif + +#if GTK_CHECK_VERSION(2,4,0) +static void +clipboard_target_received_func(GtkClipboard *clipboard, GdkAtom *atoms, gint n_atoms, gpointer func) +{ + gint i; + VALUE ary = rb_ary_new(); + for (i = 0; i < n_atoms; i++){ + rb_ary_push(ary, BOXED2RVAL(atoms[i], GDK_TYPE_ATOM)); + } + + rb_funcall((VALUE)func, id_call, 2, CLIPBOARD2RVAL(clipboard), ary); +} + +static VALUE +rg_request_targets(VALUE self) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + + gtk_clipboard_request_targets(_SELF(self), + (GtkClipboardTargetsReceivedFunc)clipboard_target_received_func, + (gpointer)func); + return self; +} +#endif + +#if GTK_CHECK_VERSION(2,10,0) +static void +clipboard_rich_text_received_func(GtkClipboard *clipboard, GdkAtom format, const guint8 *text, gsize length, gpointer func) +{ + rb_funcall((VALUE)func, id_call, 3, CLIPBOARD2RVAL(clipboard), + BOXED2RVAL(format, GDK_TYPE_ATOM), rb_str_new((char*)text, length)); +} + +static VALUE +rg_request_rich_text(VALUE self, VALUE buffer) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + + gtk_clipboard_request_rich_text(_SELF(self), GTK_TEXT_BUFFER(RVAL2GOBJ(buffer)), + (GtkClipboardRichTextReceivedFunc)clipboard_rich_text_received_func, + (gpointer)func); + return self; +} +#endif + +static VALUE +rg_wait_for_contents(VALUE self, VALUE target) +{ + return BOXED2RVAL(gtk_clipboard_wait_for_contents( + _SELF(self), + RVAL2ATOM(target)), + GTK_TYPE_SELECTION_DATA); +} + +static VALUE +rg_wait_for_text(VALUE self) +{ + gchar *str; + str = gtk_clipboard_wait_for_text(_SELF(self)); + return str ? CSTR2RVAL(str) : Qnil; +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_wait_for_image(VALUE self) +{ + GdkPixbuf* pixbuf = gtk_clipboard_wait_for_image(_SELF(self)); + return GOBJ2RVAL(pixbuf); +} +#endif + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_wait_for_rich_text(VALUE self, VALUE buffer) +{ + GdkAtom format; + gsize length; + guint8* data = gtk_clipboard_wait_for_rich_text(_SELF(self), + GTK_TEXT_BUFFER(RVAL2GOBJ(buffer)), + &format, &length); + if (data){ + VALUE str = rb_str_new((char*)data, length); + g_free(data); + return rb_assoc_new(str, BOXED2RVAL(format, GDK_TYPE_ATOM)); + } else { + return rb_assoc_new(Qnil, BOXED2RVAL(format, GDK_TYPE_ATOM)); + } + +} +#endif + +static VALUE +rg_wait_is_text_available_p(VALUE self) +{ + return CBOOL2RVAL(gtk_clipboard_wait_is_text_available(_SELF(self))); +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_wait_is_image_available_p(VALUE self) +{ + return CBOOL2RVAL(gtk_clipboard_wait_is_image_available(_SELF(self))); +} +#endif + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_wait_is_rich_text_available_p(VALUE self, VALUE buffer) +{ + return CBOOL2RVAL(gtk_clipboard_wait_is_rich_text_available(_SELF(self), GTK_TEXT_BUFFER(RVAL2GOBJ(buffer)))); +} +#endif + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_wait_for_targets(VALUE self) +{ + gint i; + VALUE ary = Qnil; + GdkAtom* targets; + gint n_targets = 0; + gboolean ret = gtk_clipboard_wait_for_targets(_SELF(self), &targets, &n_targets); + + if (ret){ + ary = rb_ary_new(); + for (i = 0; i < n_targets; i++){ + if ((GdkAtom)targets == (GdkAtom)GDK_NONE){ + rb_ary_push(ary, rb_eval_string("Gdk::Atom::NONE")); + } + else + rb_ary_push(ary, BOXED2RVAL(targets, GDK_TYPE_ATOM)); + targets++; + } + /* How can I this ? + g_free(&o_targets); + */ + } + return ary; +} +#endif + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_wait_is_target_available_p(VALUE self, VALUE target) +{ + return CBOOL2RVAL(gtk_clipboard_wait_is_target_available(_SELF(self), RVAL2ATOM(target))); +} + +static VALUE +rg_set_can_store(VALUE self, VALUE rbtargets) +{ + GtkClipboard *clipboard = _SELF(self); + long n = 0; + GtkTargetEntry *targets = RVAL2GTKTARGETENTRIES_ACCEPT_NIL(rbtargets, &n); + + gtk_clipboard_set_can_store(clipboard, targets, n); + + g_free(targets); + + return self; +} + +static VALUE +rg_store(VALUE self) +{ + gtk_clipboard_store(_SELF(self)); + + return self; +} +#endif + +void +Init_gtk_clipboard(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_CLIPBOARD, "Clipboard", mGtk); + + RG_DEF_SMETHOD(get, -1); + RG_DEF_METHOD(display, 0); + RG_DEF_METHOD(set, 1); +/* + RG_DEF_METHOD(owner, 0); +*/ + RG_DEF_METHOD(clear, 0); + RG_DEF_METHOD(set_text, 1); +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(set_image, 1); +#endif + RG_DEF_METHOD(request_contents, 1); + RG_DEF_METHOD(request_text, 0); +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(request_image, 0); +#endif +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(request_targets, 0); +#endif +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD(request_rich_text, 1); +#endif + RG_DEF_METHOD(wait_for_contents, 1); + RG_DEF_METHOD(wait_for_text, 0); +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(wait_for_image, 0); +#endif +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD(wait_for_rich_text, 1); +#endif + RG_DEF_METHOD_P(wait_is_text_available, 0); +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD_P(wait_is_image_available, 0); +#endif +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD_P(wait_is_rich_text_available, 1); +#endif +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(wait_for_targets, 0); +#endif +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD_P(wait_is_target_available, 1); + RG_DEF_METHOD(set_can_store, 1); + RG_DEF_METHOD(store, 0); +#endif + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcolorbutton.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcolorbutton.c new file mode 100644 index 0000000..efb9ac4 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcolorbutton.c @@ -0,0 +1,55 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cColorButton + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE color; + GtkWidget* widget; + + rb_scan_args(argc, argv, "01", &color); + + if (NIL_P(color)){ + widget = gtk_color_button_new(); + } else { + widget = gtk_color_button_new_with_color(RVAL2GDKCOLOR(color)); + } + + RBGTK_INITIALIZE(self, widget); + return Qnil; +} + +#endif + +void +Init_gtk_colorbutton(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_COLOR_BUTTON, "ColorButton", mGtk); + RG_DEF_METHOD(initialize, -1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcolorsel.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcolorsel.c new file mode 100644 index 0000000..3ed95ef --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcolorsel.c @@ -0,0 +1,215 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cColorSelection +#define _SELF(s) (GTK_COLOR_SELECTION(RVAL2GOBJ(self))) + +static VALUE RG_TARGET_NAMESPACE; + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_color_selection_new()); + return Qnil; +} + +static VALUE +rg_previous_alpha(VALUE self) +{ + return INT2NUM(gtk_color_selection_get_previous_alpha(_SELF(self))); +} + +static VALUE +rg_set_previous_alpha(VALUE self, VALUE alpha) +{ + gtk_color_selection_set_previous_alpha(_SELF(self), NUM2INT(alpha)); + return self; +} + +static VALUE +rg_set_previous_color(VALUE self, VALUE color) +{ + gtk_color_selection_set_previous_color(_SELF(self), RVAL2GDKCOLOR(color)); + return self; +} + +static VALUE +rg_previous_color(VALUE self) +{ + GdkColor color; + gtk_color_selection_get_previous_color(_SELF(self), &color); + return GDKCOLOR2RVAL(&color); +} + +static VALUE +rg_adjusting_p(VALUE self) +{ + return CBOOL2RVAL(gtk_color_selection_is_adjusting(_SELF(self))); +} + +static VALUE +rg_s_palette_from_string(G_GNUC_UNUSED VALUE self, VALUE str) +{ + GdkColor* gcolors; + gint i, n_colors; + VALUE ary = Qnil; + gboolean ret = gtk_color_selection_palette_from_string(RVAL2CSTR(str), + &gcolors, &n_colors); + + if (ret) { + ary = rb_ary_new(); + for (i = 0; i < n_colors; i++) { + rb_ary_push(ary, GDKCOLOR2RVAL(&gcolors[i])); + } + } + + return ary; +} + +struct rbgdk_rval2gdkcolors_args { + VALUE ary; + long n; + GdkColor *result; +}; + +static VALUE +rbgdk_rval2gdkcolors_body(VALUE value) +{ + long i; + struct rbgdk_rval2gdkcolors_args *args = (struct rbgdk_rval2gdkcolors_args *)value; + + for (i = 0; i < args->n; i++) + args->result[i] = *RVAL2GDKCOLOR(RARRAY_PTR(args->ary)[i]); + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbgdk_rval2gdkcolors_rescue(VALUE value) +{ + g_free(((struct rbgdk_rval2gdkcolors_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static GdkColor * +rbgdk_rval2gdkcolors(VALUE value, long *n) +{ + struct rbgdk_rval2gdkcolors_args args; + + args.ary = rb_ary_to_ary(value); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(GdkColor, args.n + 1); + + rb_rescue(rbgdk_rval2gdkcolors_body, (VALUE)&args, + rbgdk_rval2gdkcolors_rescue, (VALUE)&args); + + if (n != NULL) + *n = args.n; + + return args.result; +} + +#define RVAL2GDKCOLORS(value, n) rbgdk_rval2gdkcolors(value, n) + +static VALUE +rg_s_palette_to_string(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE rbcolors; + long n; + GdkColor *colors; + gchar *palette; + + if (argc > 1) + rb_scan_args(argc, argv, "*", &rbcolors); + else + rb_scan_args(argc, argv, "10", &rbcolors); + + colors = RVAL2GDKCOLORS(rbcolors, &n); + + palette = gtk_color_selection_palette_to_string(colors, n); + + g_free(colors); + + return CSTR2RVAL_FREE(palette); +} + +#if GTK_CHECK_VERSION(2,2,0) +static void +screen_func(GdkScreen *screen, const GdkColor *colors, gint n_colors) +{ + int i; + VALUE func = rb_cvar_get(RG_TARGET_NAMESPACE, rb_intern("__palette_proc__")); + VALUE ary = rb_ary_new(); + for (i = 0; i < n_colors; i++){ + ary = rb_ary_push(ary, GDKCOLOR2RVAL((GdkColor *)&colors[i])); + } + if (! NIL_P(func)) + rb_funcall(func, id_call, 2, GOBJ2RVAL(screen), ary); +} + +static VALUE +rg_s_set_change_palette_hook(VALUE self) +{ + VALUE func = rb_block_proc(); + + rb_cv_set(RG_TARGET_NAMESPACE, "__palette_proc__", func); + gtk_color_selection_set_change_palette_with_screen_hook( + (GtkColorSelectionChangePaletteWithScreenFunc)screen_func); + return self; +} +#endif + +/* Don't implement them. +GtkColorSelectionChangePaletteFunc gtk_color_selection_set_change_palette_hook + (GtkColorSelectionChangePaletteFunc func); +void (*GtkColorSelectionChangePaletteWithScreenFunc) + (GdkScreen *screen, + const GdkColor *colors, + gint n_colors); +*/ + +void +Init_gtk_color_selection(VALUE mGtk) +{ + RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_COLOR_SELECTION, "ColorSelection", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(previous_alpha, 0); + RG_DEF_METHOD(set_previous_alpha, 1); + RG_DEF_METHOD(set_previous_color, 1); + RG_DEF_METHOD(previous_color, 0); + RG_DEF_METHOD_P(adjusting, 0); + + RG_DEF_SMETHOD(palette_to_string, -1); + RG_DEF_SMETHOD(palette_from_string, 1); + +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_SMETHOD(set_change_palette_hook, 0); +#endif + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcolorselectiondialog.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcolorselectiondialog.c new file mode 100644 index 0000000..d10121c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcolorselectiondialog.c @@ -0,0 +1,50 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cColorSelectionDialog +#define _SELF(s) (GTK_COLOR_SELECTION_DIALOG(RVAL2GOBJ(s))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE title; + rb_scan_args(argc, argv, "01", &title); + RBGTK_INITIALIZE(self, gtk_color_selection_dialog_new(NIL_P(title) ? NULL : RVAL2CSTR(title))); + return Qnil; +} + +void +Init_gtk_color_selection_dialog(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_COLOR_SELECTION_DIALOG, + "ColorSelectionDialog", mGtk); + + RG_DEF_METHOD(initialize, -1); +#if GTK_CHECK_VERSION(2, 14, 0) + /* NOTE: Backward compatibility */ + RG_DEF_ALIAS("colorsel", "color_selection"); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcombo.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcombo.c new file mode 100644 index 0000000..702994a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcombo.c @@ -0,0 +1,119 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#ifndef GTK_DISABLE_DEPRECATED /* Since 2.4 */ + +#define RG_TARGET_NAMESPACE cCombo + +static VALUE +rg_set_popdown_strings(VALUE self, VALUE ary) +{ + int i; + GList *glist = NULL; + + Check_Type(ary, T_ARRAY); + for (i=0; ientry); +} +#endif + +void +Init_gtk_combo(VALUE mGtk) +{ +#ifndef GTK_DISABLE_DEPRECATED /* Since 2.4 */ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_COMBO, "Combo", mGtk); + + RG_DEF_METHOD(initialize, -1); + G_REPLACE_SET_PROPERTY(RG_TARGET_NAMESPACE, "value_in_list", combo_set_val_in_list, 2); + RG_DEF_METHOD(set_use_arrows, 1); + RG_DEF_METHOD(set_use_arrows_always, 1); + RG_DEF_METHOD(set_popdown_strings, 1); + RG_DEF_METHOD(disable_activate, 0); + + RG_DEF_METHOD(entry, 0); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcombobox.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcombobox.c new file mode 100644 index 0000000..71bda6f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcombobox.c @@ -0,0 +1,163 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cComboBox +#define _SELF(self) (GTK_COMBO_BOX(RVAL2GOBJ(self))) +#define RVAL2WIDGET(w) (GTK_WIDGET(RVAL2GOBJ(w))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE model_or_false; + GtkWidget* widget; + + rb_scan_args(argc, argv, "01", &model_or_false); + + if (rb_obj_is_kind_of(model_or_false, GTYPE2CLASS(GTK_TYPE_TREE_MODEL))){ + widget = gtk_combo_box_new_with_model(GTK_TREE_MODEL(RVAL2GOBJ(model_or_false))); + } else if (NIL_P(model_or_false) || TYPE(model_or_false) == T_TRUE){ + widget = gtk_combo_box_new_text(); + } else if (TYPE(model_or_false) == T_FALSE){ + widget = gtk_combo_box_new(); + } else { + rb_raise(rb_eArgError, "invalid 2nd argument %s (except true/false or Gtk::TreeModel)", + rb_class2name(CLASS_OF(model_or_false))); + } + + RBGTK_INITIALIZE(self, widget); + return Qnil; +} + +static VALUE +rg_active_iter(VALUE self) +{ + GtkTreeIter iter; + VALUE val = Qnil; + gboolean ret = gtk_combo_box_get_active_iter(_SELF(self), &iter); + if (ret){ + iter.user_data3 = (gpointer)gtk_combo_box_get_model(_SELF(self)); + val = BOXED2RVAL(&iter, GTK_TYPE_TREE_ITER); + } + return val; +} + +static VALUE +rg_set_active_iter(VALUE self, VALUE iter) +{ + gtk_combo_box_set_active_iter(_SELF(self), RVAL2GTKTREEITER(iter)); + return self; +} + +static VALUE +rg_append_text(VALUE self, VALUE text) +{ + gtk_combo_box_append_text(_SELF(self), RVAL2CSTR(text)); + return self; +} + +static VALUE +rg_insert_text(VALUE self, VALUE position, VALUE text) +{ + gtk_combo_box_insert_text(_SELF(self), NUM2INT(position), RVAL2CSTR(text)); + return self; +} + +static VALUE +rg_prepend_text(VALUE self, VALUE text) +{ + gtk_combo_box_prepend_text(_SELF(self), RVAL2CSTR(text)); + return self; +} + +static VALUE +rg_remove_text(VALUE self, VALUE position) +{ + gtk_combo_box_remove_text(_SELF(self), NUM2INT(position)); + return self; +} + +#if GTK_CHECK_VERSION(2,6,0) + +static VALUE +rg_active_text(VALUE self) +{ + return CSTR2RVAL_FREE(gtk_combo_box_get_active_text(_SELF(self))); +} + +static VALUE +rg_popup_accessible(VALUE self) +{ + return GOBJ2RVAL(gtk_combo_box_get_popup_accessible(_SELF(self))); +} + +/* How can I implement this? +GtkTreeViewRowSeparatorFunc gtk_combo_box_get_row_separator_func + (GtkComboBox *combo_box); +*/ + +static gboolean +row_separator_func(GtkTreeModel *model, GtkTreeIter *iter, gpointer *func) +{ + iter->user_data3 = model; + return RVAL2CBOOL(rb_funcall((VALUE)func, id_call, 2, GOBJ2RVAL(model), + GTKTREEITER2RVAL(iter))); +} + +static VALUE +rg_set_row_separator_func(VALUE self) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_combo_box_set_row_separator_func(_SELF(self), + (GtkTreeViewRowSeparatorFunc)row_separator_func, + (gpointer)func, NULL); + return self; +} + +#endif +#endif + +void +Init_gtk_combobox(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_COMBO_BOX, "ComboBox", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(active_iter, 0); + RG_DEF_METHOD(set_active_iter, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "active_iter"); + RG_DEF_METHOD(append_text, 1); + RG_DEF_METHOD(insert_text, 2); + RG_DEF_METHOD(prepend_text, 1); + RG_DEF_METHOD(remove_text, 1); + +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(active_text, 0); + RG_DEF_METHOD(popup_accessible, 0); + RG_DEF_METHOD(set_row_separator_func, 0); +#endif +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcomboboxentry.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcomboboxentry.c new file mode 100644 index 0000000..918d890 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcomboboxentry.c @@ -0,0 +1,62 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cComboBoxEntry + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE model_or_false, text_column; + GtkWidget* widget; + + rb_scan_args(argc, argv, "02", &model_or_false, &text_column); + + if (rb_obj_is_kind_of(model_or_false, GTYPE2CLASS(GTK_TYPE_TREE_MODEL))){ + widget = gtk_combo_box_entry_new_with_model( + GTK_TREE_MODEL(RVAL2GOBJ(model_or_false)), + NUM2INT(text_column)); + } else if (NIL_P(model_or_false) || TYPE(model_or_false) == T_TRUE){ + widget = gtk_combo_box_entry_new_text(); + } else if (TYPE(model_or_false) == T_FALSE){ + widget = gtk_combo_box_entry_new(); + } else { + rb_raise(rb_eArgError, "invalid 2nd argument %s (except true/false or Gtk::TreeModel)", + rb_class2name(CLASS_OF(model_or_false))); + } + + RBGTK_INITIALIZE(self, widget); + return Qnil; +} + +#endif + +void +Init_gtk_comboboxentry(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_COMBO_BOX_ENTRY, "ComboBoxEntry", mGtk); + RG_DEF_METHOD(initialize, -1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkconst.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkconst.c new file mode 100644 index 0000000..ca06226 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkconst.c @@ -0,0 +1,181 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +/* + * constants + */ +void +Init_gtk_const(VALUE mGtk) +{ + /* + * version information + */ + rb_define_const(mGtk, "BINDING_VERSION", + rb_ary_new3(3, INT2FIX(RBGTK_MAJOR_VERSION), + INT2FIX(RBGTK_MINOR_VERSION), + INT2FIX(RBGTK_MICRO_VERSION))); + + rb_define_const(mGtk, "BUILD_VERSION", + rb_ary_new3(3, INT2FIX(GTK_MAJOR_VERSION), + INT2FIX(GTK_MINOR_VERSION), + INT2FIX(GTK_MICRO_VERSION))); + + rb_define_const(mGtk, "VERSION", + rb_ary_new3(3, INT2FIX(gtk_major_version), + INT2FIX(gtk_minor_version), + INT2FIX(gtk_micro_version))); + rb_define_const(mGtk, "MAJOR_VERSION", INT2FIX(gtk_major_version)); + rb_define_const(mGtk, "MINOR_VERSION", INT2FIX(gtk_minor_version)); + rb_define_const(mGtk, "MICRO_VERSION", INT2FIX(gtk_micro_version)); + rb_define_const(mGtk, "BINARY_AGE", INT2FIX(gtk_binary_age)); + rb_define_const(mGtk, "INTERFACE_AGE", INT2FIX(gtk_interface_age)); + + /* + * standard enumeration + */ + + /* GtkAccelFlags */ + G_DEF_CLASS(GTK_TYPE_ACCEL_FLAGS, "AccelFlags", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_ACCEL_FLAGS, "GTK_"); + + /* GtkAnchorType */ + G_DEF_CLASS(GTK_TYPE_ANCHOR_TYPE, "AnchorType", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_ANCHOR_TYPE, "GTK_"); + + /* GtkAttachOptions */ + G_DEF_CLASS(GTK_TYPE_ATTACH_OPTIONS, "AttachOptions", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_ATTACH_OPTIONS, "GTK_"); + + /* GtkCornerType */ + G_DEF_CLASS(GTK_TYPE_CORNER_TYPE, "CornerType", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_CORNER_TYPE, "GTK_"); + + /* GtkDeleteType */ + G_DEF_CLASS(GTK_TYPE_DELETE_TYPE, "DeleteType", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_DELETE_TYPE, "GTK_"); + + /* GtkDirectionType */ + G_DEF_CLASS(GTK_TYPE_DIRECTION_TYPE, "DirectionType", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_DIRECTION_TYPE, "GTK_"); + + /* GtkExpanderStyle */ + G_DEF_CLASS(GTK_TYPE_EXPANDER_STYLE, "ExpanderStyle", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_EXPANDER_STYLE, "GTK_"); + + /* GtkJustification */ + G_DEF_CLASS(GTK_TYPE_JUSTIFICATION, "Justification", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_JUSTIFICATION, "GTK_"); + + /* GtkMessageType */ + G_DEF_CLASS(GTK_TYPE_MESSAGE_TYPE, "MessageType", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_MESSAGE_TYPE, "GTK_MESSAGE_"); + + /* GtkMetricType */ + G_DEF_CLASS(GTK_TYPE_METRIC_TYPE, "MetricType", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_METRIC_TYPE, "GTK_"); + + /* GtkMovementStep */ + G_DEF_CLASS(GTK_TYPE_MOVEMENT_STEP, "MovementStep", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_MOVEMENT_STEP, "GTK_"); + + /* GtkOrientation */ + G_DEF_CLASS(GTK_TYPE_ORIENTATION, "Orientation", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_ORIENTATION, "GTK_"); + + /* GtkPackType */ + G_DEF_CLASS(GTK_TYPE_PACK_TYPE, "PackType", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_PACK_TYPE, "GTK_"); + + /* GtkPathPriorityType */ + G_DEF_CLASS(GTK_TYPE_PATH_PRIORITY_TYPE, "PathPriorityType", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_PATH_PRIORITY_TYPE, "GTK_"); + + /* GtkPathType */ + G_DEF_CLASS(GTK_TYPE_PATH_TYPE, "PathType", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_PATH_TYPE, "GTK_"); + + /* GtkPolicyType */ + G_DEF_CLASS(GTK_TYPE_POLICY_TYPE, "PolicyType", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_POLICY_TYPE, "GTK_"); + + /* GtkPositionType */ + G_DEF_CLASS(GTK_TYPE_POSITION_TYPE, "PositionType", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_POSITION_TYPE, "GTK_"); + + /* GtkReliefStyle */ + G_DEF_CLASS(GTK_TYPE_RELIEF_STYLE, "ReliefStyle", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_RELIEF_STYLE, "GTK_"); + + /* GtkResizeMode */ + G_DEF_CLASS(GTK_TYPE_RESIZE_MODE, "ResizeMode", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_RESIZE_MODE, "GTK_"); + + /* GtkResponseType */ + G_DEF_CLASS(GTK_TYPE_RESPONSE_TYPE, "ResponseType", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_RESPONSE_TYPE, "GTK_"); + + /* GtkScrollStep */ +#if GTK_CHECK_VERSION(2,4,0) + G_DEF_CLASS(GTK_TYPE_SCROLL_STEP, "ScrollStep", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_SCROLL_STEP, "GTK_"); +#endif + + /* GtkScrollType */ + G_DEF_CLASS(GTK_TYPE_SCROLL_TYPE, "ScrollType", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_SCROLL_TYPE, "GTK_"); + + /* GtkSelectionMode */ + G_DEF_CLASS(GTK_TYPE_SELECTION_MODE, "SelectionMode", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_SELECTION_MODE, "GTK_"); + + /* GtkShadowType */ + G_DEF_CLASS(GTK_TYPE_SHADOW_TYPE, "ShadowType", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_SHADOW_TYPE, "GTK_"); + + /* GtkStateType */ + G_DEF_CLASS(GTK_TYPE_STATE_TYPE, "StateType", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_STATE_TYPE, "GTK_"); + + /* GtkSubmenuDirection */ + G_DEF_CLASS(GTK_TYPE_SUBMENU_DIRECTION, "SubmenuDirection", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_SUBMENU_DIRECTION, "GTK_"); + + /* GtkSubmenuPlacement */ + G_DEF_CLASS(GTK_TYPE_SUBMENU_PLACEMENT, "SubmenuPlacement", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_SUBMENU_PLACEMENT, "GTK_"); + + /* GtkUpdateType */ + G_DEF_CLASS(GTK_TYPE_UPDATE_TYPE, "UpdateType", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_UPDATE_TYPE, "GTK_"); + + /* GtkVisibility */ + G_DEF_CLASS(GTK_TYPE_VISIBILITY, "Visibility", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_VISIBILITY, "GTK_"); + + /* GtkSortType */ + G_DEF_CLASS(GTK_TYPE_SORT_TYPE, "SortType", mGtk); + G_DEF_CONSTANTS(mGtk, GTK_TYPE_SORT_TYPE, "GTK_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcontainer.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcontainer.c new file mode 100644 index 0000000..41b8cff --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcontainer.c @@ -0,0 +1,783 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cContainer +#define _SELF(s) (GTK_CONTAINER(RVAL2GOBJ(self))) + +/* +We don't need this. +#define GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID(object, property_id, pspec) +*/ + +static VALUE type_to_prop_setter_table; +static VALUE type_to_prop_getter_table; + +static VALUE +rg_resize_container_p(VALUE self) +{ + return CBOOL2RVAL(GTK_IS_RESIZE_CONTAINER(_SELF(self))); +} + +static VALUE +rg_remove(VALUE self, VALUE other) +{ + G_CHILD_REMOVE(self, other); + gtk_container_remove(_SELF(self), GTK_WIDGET(RVAL2GOBJ(other))); + return self; +} + +static VALUE +rg_check_resize(VALUE self) +{ + gtk_container_check_resize(_SELF(self)); + return self; +} + +static VALUE +rg_each(int argc, VALUE *argv, VALUE self) +{ + VALUE callback; + + rb_scan_args(argc, argv, "01", &callback); + if (NIL_P(callback)) { + callback = rb_block_proc(); + } + gtk_container_foreach(_SELF(self), exec_callback, (gpointer)callback); + return self; +} + +static VALUE +rg_each_forall(int argc, VALUE *argv, VALUE self) +{ + VALUE callback; + + rb_scan_args(argc, argv, "01", &callback); + if (NIL_P(callback)) { + callback = rb_block_proc(); + } + gtk_container_forall(_SELF(self), exec_callback, (gpointer)callback); + return self; +} + +static VALUE +rg_children(VALUE self) +{ + return GLIST2ARYF(gtk_container_get_children(_SELF(self))); +} + +static VALUE +rg_set_reallocate_redraws(VALUE self, VALUE needs_redraws) +{ + gtk_container_set_reallocate_redraws(_SELF(self), RVAL2CBOOL(needs_redraws)); + return self; +} + +static VALUE +rg_set_focus_child(VALUE self, VALUE child) +{ + gtk_container_set_focus_child(_SELF(self), GTK_WIDGET(RVAL2GOBJ(child))); + return self; +} + +static VALUE +rg_set_focus_vadjustment(VALUE self, VALUE adjustment) +{ + gtk_container_set_focus_vadjustment(_SELF(self), + NIL_P(adjustment) ? NULL : GTK_ADJUSTMENT(RVAL2GOBJ(adjustment))); + return self; +} + +static VALUE +rg_set_focus_hadjustment(VALUE self, VALUE adjustment) +{ + gtk_container_set_focus_hadjustment(_SELF(self), + NIL_P(adjustment) ? NULL : GTK_ADJUSTMENT(RVAL2GOBJ(adjustment))); + return self; +} + +static VALUE +rg_focus_vadjustment(VALUE self) +{ + GtkAdjustment* adj = gtk_container_get_focus_vadjustment(_SELF(self)); + return adj ? GOBJ2RVAL(adj) : Qnil; +} + +static VALUE +rg_focus_hadjustment(VALUE self) +{ + GtkAdjustment* adj = gtk_container_get_focus_hadjustment(_SELF(self)); + return adj ? GOBJ2RVAL(adj) : Qnil; +} + +static VALUE +rg_resize_children(VALUE self) +{ + gtk_container_resize_children(_SELF(self)); + return self; +} + +static VALUE +rg_child_type(VALUE self) +{ + return GTYPE2CLASS(gtk_container_child_type(_SELF(self))); +} + +/* +void gtk_container_child_get (GtkContainer *container, + GtkWidget *child, + const gchar *first_prop_name, + ...); +void gtk_container_child_set (GtkContainer *container, + GtkWidget *child, + const gchar *first_prop_name, + ...); +*/ + +void +rbgtkcontainer_register_child_property_setter(GType gtype, const char *name, RValueToGValueFunc func) +{ + GObjectClass* oclass; + GParamSpec* pspec; + + VALUE table = rb_hash_aref(type_to_prop_setter_table, INT2FIX(gtype)); + if (NIL_P(table)){ + table = rb_hash_new(); + rb_hash_aset(type_to_prop_setter_table, INT2FIX(gtype), table); + } + + oclass = g_type_class_ref(gtype); + pspec = gtk_container_class_find_child_property(oclass, name); + + rb_hash_aset(table, rb_intern(g_param_spec_get_name(pspec)), + Data_Wrap_Struct(rb_cData, NULL, NULL, func)); + + g_type_class_unref(oclass); +} + +void +rbgtkcontainer_register_child_property_getter(GType gtype, const char *name, GValueToRValueFunc func) +{ + GObjectClass* oclass; + GParamSpec* pspec; + + VALUE table = rb_hash_aref(type_to_prop_getter_table, INT2FIX(gtype)); + if (NIL_P(table)){ + table = rb_hash_new(); + rb_hash_aset(type_to_prop_getter_table, INT2FIX(gtype), table); + } + + oclass = g_type_class_ref(gtype); + pspec = gtk_container_class_find_child_property(oclass, name); + + rb_hash_aset(table, rb_intern(g_param_spec_get_name(pspec)), + Data_Wrap_Struct(rb_cData, NULL, NULL, func)); +} + +static VALUE +rg_child_get_property(VALUE self, VALUE child, VALUE prop_name) +{ + GParamSpec* pspec; + const char* name; + + if (SYMBOL_P(prop_name)) { + name = rb_id2name(SYM2ID(prop_name)); + } else { + name = RVAL2CSTR(prop_name); + } + + pspec = gtk_container_class_find_child_property( + G_OBJECT_GET_CLASS(RVAL2GOBJ(self)), name); + + if (!pspec) + rb_raise(rb_eArgError, "No such property: %s", name); + else { + GValueToRValueFunc getter = NULL; + GValue gval = G_VALUE_INIT; + VALUE ret; + + { + VALUE table = rb_hash_aref(type_to_prop_getter_table, + INT2FIX(pspec->owner_type)); + if (!NIL_P(table)){ + VALUE obj = rb_hash_aref(table, rb_intern(g_param_spec_get_name(pspec))); + if (!NIL_P(obj)) + Data_Get_Struct(obj, void, getter); + } + } + g_value_init(&gval, G_PARAM_SPEC_VALUE_TYPE(pspec)); + gtk_container_child_get_property(GTK_CONTAINER(RVAL2GOBJ(self)), + GTK_WIDGET(RVAL2GOBJ(child)), + name , &gval); + ret = getter ? getter(&gval) : GVAL2RVAL(&gval); + + G_CHILD_ADD(child, ret); + + g_value_unset(&gval); + return ret; + } +} + +static VALUE +rg_child_set_property(VALUE self, VALUE child, VALUE prop_name, VALUE val) +{ + GParamSpec* pspec; + const char* name; + + if (SYMBOL_P(prop_name)) { + name = rb_id2name(SYM2ID(prop_name)); + } else { + name = RVAL2CSTR(prop_name); + } + + pspec = gtk_container_class_find_child_property( + G_OBJECT_GET_CLASS(RVAL2GOBJ(self)), name); + + if (!pspec) + rb_raise(rb_eArgError, "No such property: %s", name); + else { + RValueToGValueFunc setter = NULL; + GValue gval = G_VALUE_INIT; + g_value_init(&gval, G_PARAM_SPEC_VALUE_TYPE(pspec)); + + { + VALUE table = rb_hash_aref(type_to_prop_setter_table, + INT2FIX(pspec->owner_type)); + if (!NIL_P(table)){ + VALUE obj = rb_hash_aref(table, rb_intern(g_param_spec_get_name(pspec))); + if (!NIL_P(obj)) + Data_Get_Struct(obj, void, setter); + } + } + + if (setter) + setter(val, &gval); + else { + if (!NIL_P(val)) + rbgobj_rvalue_to_gvalue(val, &gval); + } + + G_CHILD_ADD(child, val); + + gtk_container_child_set_property(GTK_CONTAINER(RVAL2GOBJ(self)), + GTK_WIDGET(RVAL2GOBJ(child)), name, &gval); + + g_value_unset(&gval); + return self; + } +} + +static VALUE +rg_add(int argc, VALUE *argv, VALUE self) +{ + VALUE other, properties; + GtkWidget *child; + + rb_scan_args(argc, argv, "11", &other, &properties); + + child = GTK_WIDGET(RVAL2GOBJ(other)); + gtk_widget_freeze_child_notify(child); + gtk_container_add(_SELF(self), child); + + G_CHILD_ADD(self, other); + + if (child->parent && (! NIL_P(properties))){ + int i; + VALUE ary; + GObject* obj; + + Check_Type(properties, T_HASH); + ary = rb_funcall(properties, rb_intern("to_a"), 0); + obj = RVAL2GOBJ(self); + + for (i = 0; i < RARRAY_LEN(ary); i++) { + rg_child_set_property(self, other, + RARRAY_PTR(RARRAY_PTR(ary)[i])[0], + RARRAY_PTR(RARRAY_PTR(ary)[i])[1]); + } + } + gtk_widget_thaw_child_notify(child); + return self; +} + +/* +void gtk_container_child_get_valist (GtkContainer *container, + GtkWidget *child, + const gchar *first_property_name, + va_list var_args); +void gtk_container_child_set_valist (GtkContainer *container, + GtkWidget *child, + const gchar *first_property_name, + va_list var_args); +*/ + +static VALUE +rg_propagate_expose(VALUE self, VALUE child, VALUE event) +{ + gtk_container_propagate_expose(_SELF(self), GTK_WIDGET(RVAL2GOBJ(child)), + (GdkEventExpose *)RVAL2GEV(event)); + return self; +} + +static VALUE +rg_focus_chain(VALUE self) +{ + gboolean ret; + GList *glist = NULL; + ret = gtk_container_get_focus_chain(_SELF(self), &glist); + return GLIST2ARYF(glist); +} + +struct rval2gtkwidgetglist_args { + VALUE ary; + long n; + GList *result; +}; + +static VALUE +rbg_rval2gtkwidgetglist_body(VALUE value) +{ + long i; + struct rval2gtkwidgetglist_args *args = (struct rval2gtkwidgetglist_args *)value; + + for (i = 0; i < args->n; i++) + args->result = g_list_append(args->result, GTK_WIDGET(RVAL2GOBJ(RARRAY_PTR(args->ary)[i]))); + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbg_rval2gtkwidgetglist_rescue(VALUE value) +{ + g_list_free(((struct rval2gtkwidgetglist_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static GList * +rbg_rval2gtkwidgetglist(VALUE value) +{ + struct rval2gtkwidgetglist_args args; + + args.ary = rb_ary_to_ary(value); + args.n = RARRAY_LEN(args.ary); + args.result = NULL; + + rb_rescue(rbg_rval2gtkwidgetglist_body, (VALUE)&args, + rbg_rval2gtkwidgetglist_rescue, (VALUE)&args); + + return args.result; +} + +#define RVAL2GTKWIDGETGLIST(value) rbg_rval2gtkwidgetglist(value) + +static VALUE +rg_set_focus_chain(VALUE self, VALUE rbfocusable_widgets) +{ + GtkContainer *container = _SELF(self); + GList *focusable_widgets = RVAL2GTKWIDGETGLIST(rbfocusable_widgets); + + gtk_container_set_focus_chain(container, focusable_widgets); + + g_list_free(focusable_widgets); + + return self; +} + +static VALUE +rg_unset_focus_chain(VALUE self) +{ + gtk_container_unset_focus_chain(_SELF(self)); + return self; +} + +static VALUE +rg_s_child_property(VALUE self, VALUE property_name) +{ + GObjectClass* oclass; + const char* name; + GParamSpec* prop; + VALUE result; + + if (SYMBOL_P(property_name)) { + name = rb_id2name(SYM2ID(property_name)); + } else { + name = RVAL2CSTR(property_name); + } + + oclass = g_type_class_ref(CLASS2GTYPE(self)); + + prop = gtk_container_class_find_child_property(oclass, name); + if (!prop){ + g_type_class_unref(oclass); + rb_raise(rb_eNameError, "no such property: %s", name); + } + + result = GOBJ2RVAL(prop); + g_type_class_unref(oclass); + return result; +} + +static VALUE +rg_s_install_child_property(int argc, VALUE *argv, VALUE self) +{ + const RGObjClassInfo* cinfo = rbgobj_lookup_class(self); + GtkContainerClass* gclass; + VALUE spec, prop_id; + GParamSpec* pspec; + + rb_scan_args(argc, argv, "11", &spec, &prop_id); + + pspec = G_PARAM_SPEC(RVAL2GOBJ(spec)); + + if (cinfo->klass != self) + rb_raise(rb_eTypeError, "%s isn't registerd class", + rb_class2name(self)); + + gclass = GTK_CONTAINER_CLASS(g_type_class_ref(cinfo->gtype)); + gtk_container_class_install_child_property(gclass, + NIL_P(prop_id) ? 1 : NUM2UINT(prop_id), + pspec); + + return self; +} + +static VALUE +rg_s_child_properties(int argc, VALUE *argv, VALUE self) +{ + GObjectClass* oclass = g_type_class_ref(CLASS2GTYPE(self)); + guint n_properties; + GParamSpec** props; + VALUE inherited_too; + VALUE ary; + guint i; + + if (rb_scan_args(argc, argv, "01", &inherited_too) == 0) + inherited_too = Qtrue; + + props = gtk_container_class_list_child_properties(oclass, &n_properties); + + ary = rb_ary_new(); + for (i = 0; i < n_properties; i++){ + if (RVAL2CBOOL(inherited_too) + || GTYPE2CLASS(props[i]->owner_type) == self) + rb_ary_push(ary, CSTR2RVAL(props[i]->name)); + } + g_free(props); + g_type_class_unref(oclass); + return ary; +} + +/**********************************************************************/ + +static VALUE proc_mod_eval; +static GQuark q_ruby_setter; +static GQuark q_ruby_getter; + +static VALUE +cont_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE params_hash; + GObject* gobj; + + rb_scan_args(argc, argv, "01", ¶ms_hash); + + if (!NIL_P(params_hash)) + Check_Type(params_hash, T_HASH); + + gobj = rbgobj_gobject_new(RVAL2GTYPE(self), params_hash); + + RBGTK_INITIALIZE(self, gobj); + return Qnil; +} + +// FIXME: use rb_protect +static void +get_prop_func(GObject* object, + G_GNUC_UNUSED guint property_id, + GValue* value, + GParamSpec* pspec) +{ + ID ruby_getter = (ID)g_param_spec_get_qdata(pspec, q_ruby_getter); + if (!ruby_getter) { + gchar* name = g_strdup(g_param_spec_get_name(pspec)); + gchar* p; + for (p = name; *p; p++) { + if (*p == '-') + *p = '_'; + } + ruby_getter = rb_intern(name); + g_param_spec_set_qdata(pspec, q_ruby_getter, (gpointer)ruby_getter); + g_free(name); + } + + { + VALUE ret = rb_funcall(GOBJ2RVAL(object), ruby_getter, 0); + rbgobj_rvalue_to_gvalue(ret, value); + } +} + +// FIXME: use rb_protect +static void +set_prop_func(GObject* object, + G_GNUC_UNUSED guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + ID ruby_setter = (ID)g_param_spec_get_qdata(pspec, q_ruby_setter); + if (!ruby_setter) { + gchar* name = g_strconcat(g_param_spec_get_name(pspec), "=", NULL); + gchar* p; + for (p = name; *p; p++) { + if (*p == '-') + *p = '_'; + } + ruby_setter = rb_intern(name); + g_param_spec_set_qdata(pspec, q_ruby_setter, (gpointer)ruby_setter); + g_free(name); + } + + rb_funcall(GOBJ2RVAL(object), ruby_setter, 1, GVAL2RVAL(value)); +} + +// FIXME: use rb_protect +static void +get_child_prop_func(GtkContainer *container, + GtkWidget *child, + G_GNUC_UNUSED guint property_id, + GValue *value, + GParamSpec *pspec) +{ + ID ruby_getter = (ID)g_param_spec_get_qdata(pspec, q_ruby_getter); + if (!ruby_getter) { + gchar* name = g_strconcat("get_", g_param_spec_get_name(pspec), NULL); + gchar* p; + for (p = name; *p; p++) { + if (*p == '-') + *p = '_'; + } + ruby_getter = rb_intern(name); + g_param_spec_set_qdata(pspec, q_ruby_getter, (gpointer)ruby_getter); + g_free(name); + } + + { + VALUE ret = rb_funcall(GOBJ2RVAL(container), ruby_getter, 1, GOBJ2RVAL(child)); + rbgobj_rvalue_to_gvalue(ret, value); + } +} + +// FIXME: use rb_protect +static void +set_child_prop_func(GtkContainer *container, + GtkWidget *child, + G_GNUC_UNUSED guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + ID ruby_setter = (ID)g_param_spec_get_qdata(pspec, q_ruby_setter); + if (!ruby_setter) { + gchar* name = g_strconcat("set_", g_param_spec_get_name(pspec), NULL); + gchar* p; + for (p = name; *p; p++) { + if (*p == '-') + *p = '_'; + } + ruby_setter = rb_intern(name); + g_param_spec_set_qdata(pspec, q_ruby_setter, (gpointer)ruby_setter); + g_free(name); + } + + rb_funcall(GOBJ2RVAL(container), ruby_setter, 2, GOBJ2RVAL(child), GVAL2RVAL(value)); +} + +// FIXME: use rb_protect +static void +class_init_func(gpointer g_class, G_GNUC_UNUSED gpointer class_data) +{ + GObjectClass* g_class1 = G_OBJECT_CLASS(g_class); + GtkContainerClass* g_class2 = GTK_CONTAINER_CLASS(g_class); + + g_class1->set_property = set_prop_func; + g_class1->get_property = get_prop_func; + + g_class2->set_child_property = set_child_prop_func; + g_class2->get_child_property = get_child_prop_func; + +#if 0 + VALUE class_init_proc = (VALUE)class_data; + rb_funcall(proc_mod_eval, rb_intern("call"), 2, + GTYPE2CLASS(G_TYPE_FROM_CLASS(g_class)), class_init_proc); +#endif +} + +static VALUE +rg_s_type_register(int argc, VALUE* argv, VALUE self) +{ + VALUE type_name, flags; + volatile VALUE class_init_proc = Qnil; + GType parent_type; + GTypeInfo* info; + + rb_scan_args(argc, argv, "03", &type_name, &info, &flags); + + /* TODO: Replace this copy-paste job with the real thing in glib2. */ + { + const RGObjClassInfo* cinfo = rbgobj_lookup_class(self); + if (cinfo->klass == self) + rb_raise(rb_eTypeError, "already registered"); + } + + { + VALUE superclass = rb_funcall(self, rb_intern("superclass"), 0); + const RGObjClassInfo* cinfo = CLASS2CINFO(superclass); + if (cinfo->klass != superclass) + rb_raise(rb_eTypeError, "super class must be registered to GLib"); + parent_type = cinfo->gtype; + } + + if (NIL_P(type_name)){ + VALUE s = rb_funcall(self, rb_intern("name"), 0); + + if (strlen(StringValuePtr(s)) == 0) + rb_raise(rb_eTypeError, "can't determine type name"); + + type_name = rb_funcall( + rb_eval_string("lambda{|x| x.gsub(/::/,'') }"), + rb_intern("call"), 1, s); + } + + { + GTypeQuery query; + g_type_query(parent_type, &query); + + /* TODO: This should not require a new GTypeInfo, as GLib doesn't + * retain a copy. */ + info = g_new0(GTypeInfo, 1); + info->class_size = query.class_size; + info->base_init = NULL; + info->base_finalize = NULL; + info->class_init = class_init_func; + info->class_finalize = NULL; + info->class_data = (gpointer)class_init_proc; + info->instance_size = query.instance_size; + info->n_preallocs = 0; + info->instance_init = NULL; + info->value_table = NULL; + } + + { + GType type = g_type_register_static(parent_type, + StringValuePtr(type_name), + info, + NIL_P(flags) ? 0 : NUM2INT(flags)); + G_RELATIVE(self, class_init_proc); + + rbgobj_register_class(self, type, TRUE, TRUE); + + { + RGObjClassInfo* cinfo = (RGObjClassInfo*)rbgobj_lookup_class(self); + cinfo->flags |= RBGOBJ_DEFINED_BY_RUBY; + } + + { + GType parent = g_type_parent(type); + const RGObjClassInfo* cinfo = GTYPE2CINFO(parent); + VALUE m = rb_define_module_under(self, RubyGtkContainerHookModule); + + if (! (cinfo->flags & RBGOBJ_DEFINED_BY_RUBY)) { + rb_define_method(m, "initialize", cont_initialize, -1); + } + + rb_include_module(self, m); + } + + return Qnil; + } +} +/**********************************************************************/ + +static void +cont_mark_callback(GtkWidget *w, G_GNUC_UNUSED gpointer data) +{ + rbgobj_gc_mark_instance(w); +} + +static void +cont_mark(void* p) +{ + gtk_container_forall(GTK_CONTAINER(p), cont_mark_callback, NULL); +} + +/**********************************************************************/ + +void +Init_gtk_container(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = G_DEF_CLASS_WITH_GC_FUNC(GTK_TYPE_CONTAINER, "Container", + mGtk, cont_mark, NULL); + RG_DEF_METHOD_P(resize_container, 0); + RG_DEF_METHOD(add, -1); + RG_DEF_ALIAS("<<", "add"); + RG_DEF_METHOD(remove, 1); + RG_DEF_METHOD(check_resize, 0); + RG_DEF_METHOD(each, -1); + RG_DEF_METHOD(each_forall, -1); + RG_DEF_METHOD(children, 0); + RG_DEF_METHOD(set_reallocate_redraws, 1); + RG_DEF_METHOD(set_focus_child, 1); + RG_DEF_METHOD(set_focus_vadjustment, 1); + RG_DEF_METHOD(set_focus_hadjustment, 1); + RG_DEF_METHOD(focus_vadjustment, 0); + RG_DEF_METHOD(focus_hadjustment, 0); + RG_DEF_METHOD(resize_children, 0); + RG_DEF_METHOD(child_type, 0); + RG_DEF_METHOD(child_get_property, 2); + RG_DEF_METHOD(child_set_property, 3); + RG_DEF_METHOD(propagate_expose, 2); + RG_DEF_METHOD(focus_chain, 0); + RG_DEF_METHOD(set_focus_chain, 1); + RG_DEF_METHOD(unset_focus_chain, 0); + RG_DEF_SMETHOD(child_property, 1); + RG_DEF_SMETHOD(child_properties, -1); + RG_DEF_SMETHOD(install_child_property, -1); + + q_ruby_getter = g_quark_from_static_string("__ruby_getter"); + q_ruby_setter = g_quark_from_static_string("__ruby_setter"); + + RG_DEF_SMETHOD(type_register, -1); + + rb_global_variable(&proc_mod_eval); + proc_mod_eval = rb_eval_string("lambda{|obj,proc| obj.module_eval(&proc)}"); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + + rb_global_variable(&type_to_prop_setter_table); + rb_global_variable(&type_to_prop_getter_table); + type_to_prop_setter_table = rb_hash_new(); + type_to_prop_getter_table = rb_hash_new(); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkconversions.h b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkconversions.h new file mode 100644 index 0000000..e3b23b0 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkconversions.h @@ -0,0 +1,39 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef _RBGTKCONVERSIONS_H +#define _RBGTKCONVERSIONS_H + +#include +#include + +#include + +#define GTKTREEPATH2RVAL(t) (BOXED2RVAL(t, GTK_TYPE_TREE_PATH)) +#define RVAL2GTKTREEPATH(t) ((GtkTreePath *)RVAL2BOXED(t, GTK_TYPE_TREE_PATH)) +#define GTKTREEITER2RVAL(i) (BOXED2RVAL(i, GTK_TYPE_TREE_ITER)) +#define RVAL2GTKTREEITER(i) ((GtkTreeIter *)RVAL2BOXED(i, GTK_TYPE_TREE_ITER)) + +#define RVAL2GTKSTATETYPE(type) (RVAL2GENUM(type, GTK_TYPE_STATE_TYPE)) +#define GTKRCFLAGS2RVAL(flags) (GFLAGS2RVAL(flags, GTK_TYPE_RC_FLAGS)) +#define RVAL2GTKRCFLAGS(flags) (RVAL2GFLAGS(flags, GTK_TYPE_RC_FLAGS)) + +#endif /* _RBGTKCONVERSIONS_H */ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcurve.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcurve.c new file mode 100644 index 0000000..251edff --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkcurve.c @@ -0,0 +1,111 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cCurve + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_curve_new()); + return Qnil; +} + +static VALUE +rg_reset(VALUE self) +{ + gtk_curve_reset(GTK_CURVE(RVAL2GOBJ(self))); + return self; +} + +static VALUE +rg_set_gamma(VALUE self, VALUE gamma) +{ + gtk_curve_set_gamma(GTK_CURVE(RVAL2GOBJ(self)), NUM2DBL(gamma)); + return self; +} + +static VALUE +rg_set_range(VALUE self, VALUE min_x, VALUE max_x, VALUE min_y, VALUE max_y) +{ + gtk_curve_set_range(GTK_CURVE(RVAL2GOBJ(self)), + NUM2DBL(min_x), NUM2DBL(max_x), + NUM2DBL(min_y), NUM2DBL(max_y)); + return self; +} + +static VALUE +rg_set_vector(VALUE self, VALUE length, VALUE vector) +{ + gint len = NUM2INT(length); + gfloat *c_vec; + gint i; + + c_vec = ALLOCA_N(gfloat, len); + for (i = 0; i < len; i++) + c_vec[i] = NUM2DBL(RARRAY_PTR(vector)[i]); + + gtk_curve_set_vector(GTK_CURVE(RVAL2GOBJ(self)), len, c_vec); + + return self; +} + +static VALUE +rg_get_vector(VALUE self, VALUE length) +{ + gint len = NUM2INT(length); + gfloat *c_vec; + gint i; + VALUE vector = rb_ary_new2(len); + + c_vec = ALLOCA_N(gfloat, len); + gtk_curve_get_vector(GTK_CURVE(RVAL2GOBJ(self)), len, c_vec); + for (i = 0; i < len; i++) + rb_ary_push(vector, rb_float_new(c_vec[i])); + + return vector; +} + +void +Init_gtk_curve(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_CURVE, "Curve", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(reset, 0); + RG_DEF_METHOD(set_gamma, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "gamma"); + RG_DEF_METHOD(set_range, 4); + RG_DEF_METHOD(set_vector, 2); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "vector"); + /* NOTE: For backwards compatability. */ + RG_DEF_METHOD(get_vector, 1); + RG_DEF_ALIAS("vector", "get_vector"); + + /* GtkCurveType(from standard constants) */ + + G_DEF_CLASS(GTK_TYPE_CURVE_TYPE, "Type", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_CURVE_TYPE, "GTK_CURVE_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkdialog.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkdialog.c new file mode 100644 index 0000000..420432b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkdialog.c @@ -0,0 +1,259 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cDialog +#define _SELF(self) (GTK_DIALOG(RVAL2GOBJ(self))) + +static ID id_to_a; + +static VALUE +rg_add_button(VALUE self, VALUE button_text, VALUE response_id) +{ + const gchar *name; + if (SYMBOL_P(button_text)) { + name = rb_id2name(SYM2ID(button_text)); + } else { + name = RVAL2CSTR(button_text); + } + return GOBJ2RVAL(gtk_dialog_add_button(_SELF(self), name, + RVAL2GENUM(response_id, GTK_TYPE_RESPONSE_TYPE))); +} + +struct rbgtk_dialog_add_buttons_internal_args { + VALUE self; + VALUE buttons; +}; + +static VALUE +rbgtk_dialog_add_buttons_internal_body(VALUE value) +{ + struct rbgtk_dialog_add_buttons_internal_args *args = (struct rbgtk_dialog_add_buttons_internal_args *)value; + long i; + long n = RARRAY_LEN(args->buttons); + + for (i = 0; i < n; i++) { + VALUE button = rb_ary_to_ary(RARRAY_PTR(args->buttons)[i]); + + rg_add_button(args->self, RARRAY_PTR(button)[0], RARRAY_PTR(button)[1]); + } + + return args->self; +} + +static VALUE +rbgtk_dialog_add_buttons_internal_ensure(VALUE value) +{ + g_object_thaw_notify(RVAL2GOBJ(((struct rbgtk_dialog_add_buttons_internal_args *)value)->self)); + + return Qnil; +} + +VALUE +rbgtk_dialog_add_buttons_internal(VALUE self, VALUE buttons) +{ + struct rbgtk_dialog_add_buttons_internal_args args = { self, buttons }; + + if (NIL_P(RARRAY_PTR(buttons)[0])) + return self; + + g_object_freeze_notify(RVAL2GOBJ(self)); + + return rb_ensure(rbgtk_dialog_add_buttons_internal_body, (VALUE)&args, + rbgtk_dialog_add_buttons_internal_ensure, (VALUE)&args); +} + +static VALUE +rg_add_buttons(int argc, VALUE *argv, VALUE self) +{ + VALUE button_ary; + rb_scan_args(argc, argv, "*", &button_ary); + rbgtk_dialog_add_buttons_internal(self, button_ary); + return self; +} + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE title, parent, flags, button_ary; + rb_scan_args(argc, argv, "03*", &title, &parent, &flags, &button_ary); + + if (argc == 0){ + RBGTK_INITIALIZE(self, gtk_dialog_new()); + } else if (argc > 0){ + GtkDialog* dialog = GTK_DIALOG(g_object_new(GTK_TYPE_DIALOG, NULL)); + GtkDialogFlags gflags = NIL_P(flags) ? 0 : RVAL2GFLAGS(flags, GTK_TYPE_DIALOG_FLAGS); + if (! NIL_P(title)) + gtk_window_set_title(GTK_WINDOW(dialog), RVAL2CSTR(title)); + if (! NIL_P(parent)) + gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(RVAL2GOBJ(parent))); + + if (gflags & GTK_DIALOG_MODAL) + gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); + if (gflags & GTK_DIALOG_DESTROY_WITH_PARENT) + gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE); + if (gflags & GTK_DIALOG_NO_SEPARATOR) + gtk_dialog_set_has_separator(dialog, FALSE); + + RBGTK_INITIALIZE(self, dialog); + if (! NIL_P(button_ary)) + rbgtk_dialog_add_buttons_internal(self, button_ary); + } else { + rb_raise(rb_eArgError, "invalid argument number"); + } + return Qnil; +} + +static VALUE +rg_run(VALUE self) +{ + if (rb_block_given_p()){ + VALUE ret = INT2NUM(gtk_dialog_run(_SELF(self))); + rb_yield(ret); + return ret; + } else { + return INT2NUM(gtk_dialog_run(_SELF(self))); + } +} + +static VALUE +rg_response(VALUE self, VALUE response_id) +{ + gtk_dialog_response(_SELF(self), NUM2INT(response_id)); + return self; +} + +static VALUE +rg_add_action_widget(VALUE self, VALUE child, VALUE response_id) +{ + gtk_dialog_add_action_widget(_SELF(self), GTK_WIDGET(RVAL2GOBJ(child)), + NUM2INT(response_id)); + return self; +} + +static VALUE +rg_set_default_response(VALUE self, VALUE response_id) +{ + gtk_dialog_set_default_response(_SELF(self), NUM2INT(response_id)); + return self; +} + +static VALUE +rg_set_response_sensitive(VALUE self, VALUE response_id, VALUE setting) +{ + gtk_dialog_set_response_sensitive(_SELF(self), NUM2INT(response_id), RVAL2CBOOL(setting)); + return self; +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_s_alternative_dialog_button_order_p(G_GNUC_UNUSED VALUE self, VALUE screen) +{ + gboolean ret = gtk_alternative_dialog_button_order(NIL_P(screen) ? NULL : + GDK_SCREEN(RVAL2GOBJ(screen))); + return CBOOL2RVAL(ret); +} + +/* Use gtk_dialog_set_alternative_button_order_from_array() instead. +void gtk_dialog_set_alternative_button_order + (GtkDialog *dialog, + gint first_response_id, + ...); +*/ + +static VALUE +rg_set_alternative_button_order(VALUE self, VALUE rbnew_order) +{ + GtkDialog *dialog = _SELF(self); + long n; + gint *new_order = RVAL2GINTS(rbnew_order, n); + + gtk_dialog_set_alternative_button_order_from_array(dialog, n, new_order); + + g_free(new_order); + + return self; +} + +#endif + +static VALUE +rg_vbox(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->vbox); +} + +static VALUE +rg_action_area(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->action_area); +} + +#if GTK_CHECK_VERSION(2,8,0) +static VALUE +rg_get_response(VALUE self, VALUE widget) +{ + return INT2NUM(gtk_dialog_get_response_for_widget(_SELF(self), RVAL2GOBJ(widget))); +} +#endif + +void +Init_gtk_dialog(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_DIALOG, "Dialog", mGtk); + + id_to_a = rb_intern("to_a"); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(run, 0); + RG_DEF_METHOD(response, 1); + RG_DEF_METHOD(add_button, 2); + RG_DEF_METHOD(add_buttons, -1); + RG_DEF_METHOD(add_action_widget, 2); + RG_DEF_METHOD(set_default_response, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "default_response"); + +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_SMETHOD_P(alternative_dialog_button_order, 1); + RG_DEF_METHOD(set_alternative_button_order, 1); +#endif + + RG_DEF_METHOD(set_response_sensitive, 2); + RG_DEF_METHOD(vbox, 0); + RG_DEF_METHOD(action_area, 0); + +#if GTK_CHECK_VERSION(2,8,0) + RG_DEF_METHOD(get_response, 1); + RG_DEF_ALIAS("get_response_for_widget", "get_response"); +#endif + + /* GtkDialogFlags */ + G_DEF_CLASS(GTK_TYPE_DIALOG_FLAGS, "Flags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_DIALOG_FLAGS, "GTK_DIALOG_"); + + /* GtkResponseType */ + G_DEF_CLASS(GTK_TYPE_RESPONSE_TYPE, "ResponseType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_RESPONSE_TYPE, "GTK_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkdrag.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkdrag.c new file mode 100644 index 0000000..10b66f4 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkdrag.c @@ -0,0 +1,451 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE mDrag + +#define RVAL2DC(c) (GDK_DRAG_CONTEXT(RVAL2GOBJ(c))) +#define RVAL2WIDGET(w) (GTK_WIDGET(RVAL2GOBJ(w))) + +struct rbgtk_rval2gtktargetentries_args { + VALUE ary; + long n; + GtkTargetEntry *result; +}; + +static VALUE +rbgtk_rval2gtktargetentries_body(VALUE value) +{ + long i; + struct rbgtk_rval2gtktargetentries_args *args = (struct rbgtk_rval2gtktargetentries_args *)value; + + for (i = 0; i < args->n; i++) { + VALUE entry = rb_ary_to_ary(RARRAY_PTR(args->ary)[i]); + VALUE flags = RARRAY_PTR(entry)[1]; + VALUE info = RARRAY_PTR(entry)[2]; + + args->result[i].target = (gchar *)RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[0]); + args->result[i].flags = NIL_P(flags) ? 0 : RVAL2GFLAGS(flags, GTK_TYPE_TARGET_FLAGS); + args->result[i].info = NIL_P(info) ? 0 : NUM2INT(info); + } + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbgtk_rval2gtktargetentries_rescue(VALUE value) +{ + g_free(((struct rbgtk_rval2gtktargetentries_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +GtkTargetEntry * +rbgtk_rval2gtktargetentries(VALUE value, long *n) +{ + struct rbgtk_rval2gtktargetentries_args args; + + args.ary = rb_ary_to_ary(value); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(GtkTargetEntry, args.n + 1); + + rb_rescue(rbgtk_rval2gtktargetentries_body, (VALUE)&args, + rbgtk_rval2gtktargetentries_rescue, (VALUE)&args); + + *n = args.n; + + return args.result; +} + +GtkTargetEntry * +rbgtk_rval2gtktargetentries_accept_nil(VALUE value, long *n) +{ + if (!NIL_P(value)) + return rbgtk_rval2gtktargetentries(value, n); + + *n = 0; + + return NULL; +} + +GtkTargetEntry * +rbgtk_get_target_entry(VALUE targets) +{ + long n; + + return RVAL2GTKTARGETENTRIES(targets, &n); +} + +static VALUE +rg_m_dest_set(VALUE self, VALUE rbwidget, VALUE rbflags, VALUE rbtargets, VALUE rbactions) +{ + GtkWidget *widget = RVAL2WIDGET(rbwidget); + GtkDestDefaults flags = RVAL2GFLAGS(rbflags, GTK_TYPE_DEST_DEFAULTS); + GdkDragAction actions = RVAL2GFLAGS(rbactions, GDK_TYPE_DRAG_ACTION); + long n; + GtkTargetEntry *targets = RVAL2GTKTARGETENTRIES_ACCEPT_NIL(rbtargets, &n); + + gtk_drag_dest_set(widget, flags, targets, n, actions); + + g_free(targets); + + return self; +} + +static VALUE +rg_m_dest_set_proxy(VALUE self, VALUE widget, VALUE proxy_window, VALUE protocol, VALUE use_coordinates) +{ + gtk_drag_dest_set_proxy(RVAL2WIDGET(widget), + GDK_WINDOW(RVAL2GOBJ(proxy_window)), + RVAL2GENUM(protocol, GDK_TYPE_DRAG_PROTOCOL), + RVAL2CBOOL(use_coordinates)); + return self; +} + +static VALUE +rg_m_dest_unset(VALUE self, VALUE widget) +{ + gtk_drag_dest_unset(RVAL2WIDGET(widget)); + return self; +} + +static VALUE +rg_m_dest_find_target(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE widget, context, target_list; + GdkAtom ret; + rb_scan_args(argc, argv, "21", &widget, &context, &target_list); + + ret = gtk_drag_dest_find_target( + RVAL2WIDGET(widget), RVAL2DC(context), + NIL_P(target_list) ? NULL : RVAL2BOXED(target_list, GTK_TYPE_TARGET_LIST)); + + return BOXED2RVAL(ret, GDK_TYPE_ATOM); +} + +static VALUE +rg_m_dest_get_target_list(G_GNUC_UNUSED VALUE self, VALUE widget) +{ + GtkTargetList* list = gtk_drag_dest_get_target_list(RVAL2WIDGET(widget)); + return BOXED2RVAL(list, GTK_TYPE_TARGET_LIST); +} + +static VALUE +rg_m_dest_set_target_list(VALUE self, VALUE widget, VALUE target_list) +{ + gtk_drag_dest_set_target_list( + RVAL2WIDGET(widget), + NIL_P(target_list) ? NULL : RVAL2BOXED(target_list, GTK_TYPE_TARGET_LIST)); + + return self; +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_m_dest_add_text_targets(VALUE self, VALUE widget) +{ + gtk_drag_dest_add_text_targets(RVAL2WIDGET(widget)); + return self; +} +static VALUE +rg_m_dest_add_image_targets(VALUE self, VALUE widget) +{ + gtk_drag_dest_add_image_targets(RVAL2WIDGET(widget)); + return self; +} +static VALUE +rg_m_dest_add_uri_targets(VALUE self, VALUE widget) +{ + gtk_drag_dest_add_uri_targets(RVAL2WIDGET(widget)); + return self; +} +#endif + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_m_dest_set_track_motion(VALUE self, VALUE widget, VALUE track_motion) +{ + gtk_drag_dest_set_track_motion(RVAL2WIDGET(widget), RVAL2CBOOL(track_motion)); + return self; +} + +static VALUE +rg_m_dest_get_track_motion(G_GNUC_UNUSED VALUE self, VALUE widget) +{ + return CBOOL2RVAL(gtk_drag_dest_get_track_motion(RVAL2WIDGET(widget))); +} +#endif + +static VALUE +rg_m_finish(VALUE self, VALUE context, VALUE success, VALUE del, VALUE time) +{ + gtk_drag_finish(RVAL2DC(context), RVAL2CBOOL(success), + RVAL2CBOOL(del), NUM2UINT(time)); + return self; +} + +static VALUE +rg_m_get_data(VALUE self, VALUE widget, VALUE context, VALUE target, VALUE time) +{ + gtk_drag_get_data(RVAL2WIDGET(widget), RVAL2DC(context), RVAL2ATOM(target), + NUM2UINT(time)); + return self; +} + +static VALUE +rg_m_get_source_widget(G_GNUC_UNUSED VALUE self, VALUE context) +{ + return GOBJ2RVAL(gtk_drag_get_source_widget(RVAL2DC(context))); +} + +static VALUE +rg_m_highlight(VALUE self, VALUE widget) +{ + gtk_drag_highlight(RVAL2WIDGET(widget)); + return self; +} + +static VALUE +rg_m_unhighlight(VALUE self, VALUE widget) +{ + gtk_drag_unhighlight(RVAL2WIDGET(widget)); + return self; +} + +static VALUE +rg_m_begin(G_GNUC_UNUSED VALUE self, VALUE widget, VALUE target_list, VALUE actions, VALUE button, VALUE event) +{ + return GOBJ2RVAL(gtk_drag_begin(RVAL2WIDGET(widget), + RVAL2BOXED(target_list, GTK_TYPE_TARGET_LIST), + RVAL2GFLAGS(actions, GDK_TYPE_DRAG_ACTION), + NUM2INT(button), + RVAL2GEV(event))); +} + +static VALUE +rg_m_set_icon(int argc, VALUE *argv, VALUE self) +{ + VALUE context, obj, pixmap = Qnil, mask = Qnil, hot_x, hot_y; + + if (argc == 6) { + rb_scan_args(argc, argv, "60", &context, &obj, &pixmap, &mask, &hot_x, &hot_y); + gtk_drag_set_icon_pixmap(RVAL2DC(context), + GDK_COLORMAP(RVAL2GOBJ(obj)), + GDK_PIXMAP(RVAL2GOBJ(pixmap)), + GDK_BITMAP(RVAL2GOBJ(mask)), + NUM2INT(hot_x), NUM2INT(hot_y)); + } else { + rb_scan_args(argc, argv, "40", &context, &obj, &hot_x, &hot_y); + + if (TYPE(obj) == T_SYMBOL){ + gtk_drag_set_icon_stock(RVAL2DC(context), rb_id2name(SYM2ID(obj)), + NUM2INT(hot_x), NUM2INT(hot_y)); + } else if (rb_obj_is_kind_of(obj, GTYPE2CLASS(GTK_TYPE_WIDGET))){ + gtk_drag_set_icon_widget(RVAL2DC(context), RVAL2WIDGET(obj), + NUM2INT(hot_x), NUM2INT(hot_y)); + } else if (rb_obj_is_kind_of(obj, GTYPE2CLASS(GDK_TYPE_PIXBUF))){ + gtk_drag_set_icon_pixbuf(RVAL2DC(context), + GDK_PIXBUF(RVAL2GOBJ(obj)), + NUM2INT(hot_x), NUM2INT(hot_y)); + } else { + rb_raise(rb_eArgError, "invalid argument %s", rb_class2name(CLASS_OF(obj))); + } + } + return self; +} + +#if GTK_CHECK_VERSION(2,8,0) +static VALUE +rg_m_set_icon_name(VALUE self, VALUE context, VALUE name, VALUE hot_x, VALUE hot_y) +{ + gtk_drag_set_icon_name(RVAL2DC(context), RVAL2CSTR(name), NUM2INT(hot_x), NUM2INT(hot_y)); + return self; +} +#endif + +static VALUE +rg_m_set_icon_default(VALUE self, VALUE context) +{ + gtk_drag_set_icon_default(RVAL2DC(context)); + return self; +} + +static VALUE +rg_m_threshold_p(G_GNUC_UNUSED VALUE self, VALUE widget, VALUE start_x, VALUE start_y, VALUE current_x, VALUE current_y) +{ + return CBOOL2RVAL(gtk_drag_check_threshold(RVAL2WIDGET(widget), + NUM2INT(start_x), NUM2INT(start_y), + NUM2INT(current_x), NUM2INT(current_y))); +} + +static VALUE +rg_m_source_set(VALUE self, VALUE rbwidget, VALUE rbstart_button_mask, VALUE rbtargets, VALUE rbactions) +{ + GtkWidget *widget = RVAL2WIDGET(rbwidget); + GdkModifierType start_button_mask = RVAL2GFLAGS(rbstart_button_mask, GDK_TYPE_MODIFIER_TYPE); + GdkDragAction actions = RVAL2GFLAGS(rbactions, GDK_TYPE_DRAG_ACTION); + long n; + GtkTargetEntry *targets = RVAL2GTKTARGETENTRIES(rbtargets, &n); + + gtk_drag_source_set(widget, start_button_mask, targets, n, actions); + + g_free(targets); + + return self; +} + +static VALUE +rg_m_source_set_icon(int argc, VALUE *argv, VALUE self) +{ + VALUE widget, obj, pixmap = Qnil, mask = Qnil; + + rb_scan_args(argc, argv, "22", &widget, &obj, &pixmap, &mask); + if (argc == 4){ + gtk_drag_source_set_icon(RVAL2WIDGET(widget), GDK_COLORMAP(RVAL2GOBJ(obj)), + GDK_PIXMAP(RVAL2GOBJ(pixmap)), + GDK_BITMAP(RVAL2GOBJ(mask))); + } else if (argc == 2){ + if (TYPE(obj) == T_SYMBOL){ + gtk_drag_source_set_icon_stock(RVAL2WIDGET(widget), rb_id2name(SYM2ID(obj))); + } else { + gtk_drag_source_set_icon_pixbuf(RVAL2WIDGET(widget), GDK_PIXBUF(RVAL2GOBJ(obj))); + } + } else { + rb_raise(rb_eArgError, "need 2 or 4 arguments"); + } + return self; +} + +#if GTK_CHECK_VERSION(2,8,0) +static VALUE +rg_m_source_set_icon_name(VALUE self, VALUE widget, VALUE icon_name) +{ + gtk_drag_source_set_icon_name(RVAL2WIDGET(widget), RVAL2CSTR(icon_name)); + return self; +} +#endif + +static VALUE +rg_m_source_unset(VALUE self, VALUE widget) +{ + gtk_drag_source_unset(RVAL2WIDGET(widget)); + return self; +} + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_m_source_set_target_list(VALUE self, VALUE widget, VALUE targetlist) +{ + GtkTargetList* tlist = NULL; + if (! NIL_P(targetlist)) + tlist = (GtkTargetList*)RVAL2BOXED(targetlist, GTK_TYPE_TARGET_LIST); + + gtk_drag_source_set_target_list(RVAL2WIDGET(widget),tlist); + return self; +} + +static VALUE +rg_m_source_get_target_list(G_GNUC_UNUSED VALUE self, VALUE widget) +{ + GtkTargetList* ret = gtk_drag_source_get_target_list(RVAL2WIDGET(widget)); + return NIL_P(ret) ? Qnil : BOXED2RVAL(ret, GTK_TYPE_TARGET_LIST); +} +#endif + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_m_source_add_text_targets(VALUE self, VALUE widget) +{ + gtk_drag_source_add_text_targets(RVAL2WIDGET(widget)); + return self; +} +static VALUE +rg_m_source_add_image_targets(VALUE self, VALUE widget) +{ + gtk_drag_source_add_image_targets(RVAL2WIDGET(widget)); + return self; +} +static VALUE +rg_m_source_add_uri_targets(VALUE self, VALUE widget) +{ + gtk_drag_source_add_uri_targets(RVAL2WIDGET(widget)); + return self; +} +#endif + +void +Init_gtk_drag(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGtk, "Drag"); + + RG_DEF_MODFUNC(dest_set, 4); + RG_DEF_MODFUNC(dest_set_proxy, 4); + RG_DEF_MODFUNC(dest_unset, 1); + RG_DEF_MODFUNC(dest_find_target, -1); + RG_DEF_MODFUNC(dest_get_target_list, 1); + RG_DEF_MODFUNC(dest_set_target_list, 2); +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_MODFUNC(dest_add_text_targets, 1); + RG_DEF_MODFUNC(dest_add_image_targets, 1); + RG_DEF_MODFUNC(dest_add_uri_targets, 1); +#endif +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_MODFUNC(dest_set_track_motion, 2); + RG_DEF_MODFUNC(dest_get_track_motion, 1); +#endif + RG_DEF_MODFUNC(finish, 4); + RG_DEF_MODFUNC(get_data, 4); + RG_DEF_MODFUNC(get_source_widget, 1); + RG_DEF_MODFUNC(highlight, 1); + RG_DEF_MODFUNC(unhighlight, 1); + RG_DEF_MODFUNC(begin, 5); + RG_DEF_MODFUNC_P(threshold, 5); + RG_DEF_MODFUNC(set_icon, -1); +#if GTK_CHECK_VERSION(2,8,0) + RG_DEF_MODFUNC(set_icon_name, 4); +#endif + RG_DEF_MODFUNC(set_icon_default, 1); + RG_DEF_MODFUNC(source_set, 4); + RG_DEF_MODFUNC(source_set_icon, -1); +#if GTK_CHECK_VERSION(2,8,0) + RG_DEF_MODFUNC(source_set_icon_name, 2); +#endif + RG_DEF_MODFUNC(source_unset, 1); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_MODFUNC(source_set_target_list, 2); + RG_DEF_MODFUNC(source_get_target_list, 1); +#endif +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_MODFUNC(source_add_text_targets, 1); + RG_DEF_MODFUNC(source_add_image_targets, 1); + RG_DEF_MODFUNC(source_add_uri_targets, 1); +#endif + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + + /* GtkDestDefaults */ + G_DEF_CLASS(GTK_TYPE_DEST_DEFAULTS, "DestDefaults", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_DEST_DEFAULTS, "GTK_"); + + /* GtkTargetFlags */ + G_DEF_CLASS(GTK_TYPE_TARGET_FLAGS, "TargetFlags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_TARGET_FLAGS, "GTK_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkdrawingarea.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkdrawingarea.c new file mode 100644 index 0000000..a1e3f42 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkdrawingarea.c @@ -0,0 +1,42 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cDrawingArea + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_drawing_area_new()); + return Qnil; +} + +void +Init_gtk_drawing_area(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_DRAWING_AREA, "DrawingArea", mGtk); + + RG_DEF_METHOD(initialize, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkeditable.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkeditable.c new file mode 100644 index 0000000..c1950bf --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkeditable.c @@ -0,0 +1,151 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE mEditable + +static VALUE +rg_select_region(VALUE self, VALUE start, VALUE end) +{ + gtk_editable_select_region(GTK_EDITABLE(RVAL2GOBJ(self)), + NUM2INT(start), NUM2INT(end)); + return self; +} + +static VALUE +rg_selection_bounds(VALUE self) +{ + gint start, end; + gboolean ret; + ret = gtk_editable_get_selection_bounds(GTK_EDITABLE(RVAL2GOBJ(self)), + &start, &end); + return ret ? rb_ary_new3(2, INT2NUM(start), INT2NUM(end)) : Qnil; +} + +static VALUE +rg_insert_text(VALUE self, VALUE new_text, VALUE pos) +{ + gint p = NUM2INT(pos); + + StringValue(new_text); + gtk_editable_insert_text(GTK_EDITABLE(RVAL2GOBJ(self)), + RSTRING_PTR(new_text), + RSTRING_LEN(new_text), + &p); + return INT2NUM(p); +} + +static VALUE +rg_delete_text(VALUE self, VALUE start, VALUE end) +{ + gtk_editable_delete_text(GTK_EDITABLE(RVAL2GOBJ(self)), + NUM2INT(start), NUM2INT(end)); + return self; +} + +static VALUE +rg_get_chars(VALUE self, VALUE start, VALUE end) +{ + return CSTR2RVAL_FREE( + gtk_editable_get_chars(GTK_EDITABLE(RVAL2GOBJ(self)), /* check s */ + NUM2INT(start), NUM2INT(end))); /* check start,end */ +} + +static VALUE +rg_delete_selection(VALUE self) +{ + gtk_editable_delete_selection(GTK_EDITABLE(RVAL2GOBJ(self))); + return self; +} + +static VALUE +rg_position(VALUE self) +{ + return INT2NUM(gtk_editable_get_position(GTK_EDITABLE(RVAL2GOBJ(self)))); +} + +static VALUE +rg_set_position(VALUE self, VALUE position) +{ + gtk_editable_set_position(GTK_EDITABLE(RVAL2GOBJ(self)), + NUM2INT(position)); + return self; +} + +static VALUE +rg_set_editable(VALUE self, VALUE editable) +{ + gtk_editable_set_editable(GTK_EDITABLE(RVAL2GOBJ(self)), RVAL2CBOOL(editable)); + return self; +} + +static VALUE +rg_editable_p(VALUE self) +{ + return CBOOL2RVAL(gtk_editable_get_editable(GTK_EDITABLE(RVAL2GOBJ(self)))); +} + +static VALUE +rg_cut_clipboard(VALUE self) +{ + gtk_editable_cut_clipboard(GTK_EDITABLE(RVAL2GOBJ(self))); + return self; +} + +static VALUE +rg_copy_clipboard(VALUE self) +{ + gtk_editable_copy_clipboard(GTK_EDITABLE(RVAL2GOBJ(self))); + return self; +} + +static VALUE +rg_paste_clipboard(VALUE self) +{ + gtk_editable_paste_clipboard(GTK_EDITABLE(RVAL2GOBJ(self))); + return self; +} + +void +Init_gtk_editable(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(GTK_TYPE_EDITABLE, "Editable", mGtk); + + RG_DEF_METHOD(select_region, 2); + RG_DEF_METHOD(selection_bounds, 0); + RG_DEF_METHOD(insert_text, 2); + RG_DEF_METHOD(delete_text, 2); + RG_DEF_METHOD(get_chars, 2); + RG_DEF_METHOD(delete_selection, 0); + RG_DEF_METHOD(position, 0); + RG_DEF_METHOD(set_position, 1); + RG_DEF_METHOD(set_editable, 1); + RG_DEF_METHOD_P(editable, 0); + RG_DEF_METHOD(copy_clipboard, 0); + RG_DEF_METHOD(cut_clipboard, 0); + RG_DEF_METHOD(paste_clipboard, 0); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkentry.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkentry.c new file mode 100644 index 0000000..4d2b129 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkentry.c @@ -0,0 +1,117 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cEntry +#define _SELF(self) (GTK_ENTRY(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_entry_new()); + return Qnil; +} + +static VALUE +rg_layout(VALUE self) +{ + return GOBJ2RVAL(gtk_entry_get_layout(_SELF(self))); +} + +static VALUE +rg_layout_offsets(VALUE self) +{ + int x, y; + gtk_entry_get_layout_offsets(_SELF(self), &x, &y); + return rb_ary_new3(2, INT2NUM(x), INT2NUM(y)); +} + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_set_completion(VALUE self, VALUE completion) +{ + gtk_entry_set_completion(_SELF(self), GTK_ENTRY_COMPLETION(RVAL2GOBJ(completion))); + + G_CHILD_SET(self, rb_intern("completion"), completion); + + return self; +} + +static VALUE +rg_completion(VALUE self) +{ + return GOBJ2RVAL(gtk_entry_get_completion(_SELF(self))); +} +#endif + +static VALUE +rg_layout_index_to_text_index(VALUE self, VALUE layout_index) +{ + return INT2NUM(gtk_entry_layout_index_to_text_index(_SELF(self), NUM2INT(layout_index))); +} + +static VALUE +rg_text_index_to_layout_index(VALUE self, VALUE text_index) +{ + return INT2NUM(gtk_entry_text_index_to_layout_index(_SELF(self), NUM2INT(text_index))); +} + +#if GTK_CHECK_VERSION(2, 12, 0) +static VALUE +rg_cursor_hadjustment(VALUE self) +{ + return GOBJ2RVAL(gtk_entry_get_cursor_hadjustment(_SELF(self))); +} + +static VALUE +rg_set_cursor_hadjustment(VALUE self, VALUE adjustment) +{ + gtk_entry_set_cursor_hadjustment(_SELF(self), RVAL2GOBJ(adjustment)); + return self; +} +#endif + +void +Init_gtk_entry(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ENTRY, "Entry", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(layout, 0); + RG_DEF_METHOD(layout_offsets, 0); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(set_completion, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "completion"); + RG_DEF_METHOD(completion, 0); +#endif + RG_DEF_METHOD(layout_index_to_text_index, 1); + RG_DEF_METHOD(text_index_to_layout_index, 1); + +#if GTK_CHECK_VERSION(2, 12, 0) + RG_DEF_METHOD(cursor_hadjustment, 0); + RG_DEF_METHOD(set_cursor_hadjustment, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "cursor_hadjustment"); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkentrycompletion.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkentrycompletion.c new file mode 100644 index 0000000..021e8bb --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkentrycompletion.c @@ -0,0 +1,138 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004,2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cEntryCompletion +#define _SELF(self) (GTK_ENTRY_COMPLETION(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, gtk_entry_completion_new()); + return Qnil; +} + +static VALUE +rg_entry(VALUE self) +{ + return GOBJ2RVAL(gtk_entry_completion_get_entry(_SELF(self))); +} + +static gboolean +entryc_match_func(GtkEntryCompletion *completion, const gchar *key, GtkTreeIter *iter, gpointer func) +{ + iter->user_data3 = gtk_entry_completion_get_model(completion); + return RVAL2CBOOL(rb_funcall((VALUE)func, id_call, 3, GOBJ2RVAL(completion), + CSTR2RVAL(key), GTKTREEITER2RVAL(iter))); +} + +static VALUE +rg_set_match_func(VALUE self) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_entry_completion_set_match_func(_SELF(self), + (GtkEntryCompletionMatchFunc)entryc_match_func, + (gpointer)func, NULL); + return self; +} + +static VALUE +rg_complete(VALUE self) +{ + gtk_entry_completion_complete(_SELF(self)); + return self; +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_insert_prefix(VALUE self) +{ + gtk_entry_completion_insert_prefix(_SELF(self)); + return self; +} +#endif + +static VALUE +rg_insert_action_text(VALUE self, VALUE index, VALUE text) +{ + gtk_entry_completion_insert_action_text(_SELF(self), NUM2INT(index), RVAL2CSTR(text)); + return self; +} + +static VALUE +rg_insert_action_markup(VALUE self, VALUE index, VALUE markup) +{ + gtk_entry_completion_insert_action_markup(_SELF(self), NUM2INT(index), RVAL2CSTR(markup)); + return self; +} + +static VALUE +rg_delete_action(VALUE self, VALUE index) +{ + gtk_entry_completion_delete_action(_SELF(self), NUM2INT(index)); + return self; +} + +static VALUE +entryc_set_text_column(VALUE self, VALUE column) +{ + gtk_entry_completion_set_text_column(_SELF(self), NUM2INT(column)); + return self; +} + +#if GTK_CHECK_VERSION(2, 12, 0) +static VALUE +rg_completion_prefix(VALUE self) +{ + return CSTR2RVAL(gtk_entry_completion_get_completion_prefix(_SELF(self))); +} +#endif + +#endif + +void +Init_gtk_entry_completion(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ENTRY_COMPLETION, "EntryCompletion", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(entry, 0); + RG_DEF_METHOD(set_match_func, 0); + RG_DEF_METHOD(complete, 0); +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(insert_prefix, 0); +#endif + RG_DEF_METHOD(insert_action_text, 2); + RG_DEF_METHOD(insert_action_markup, 2); + RG_DEF_METHOD(delete_action, 1); + + G_REPLACE_SET_PROPERTY(RG_TARGET_NAMESPACE, "text_column", entryc_set_text_column, 1); + +#if GTK_CHECK_VERSION(2, 12, 0) + RG_DEF_METHOD(completion_prefix, 0); +#endif +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkeventbox.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkeventbox.c new file mode 100644 index 0000000..d007516 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkeventbox.c @@ -0,0 +1,42 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cEventBox + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_event_box_new()); + return Qnil; +} + +void +Init_gtk_eventbox(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_EVENT_BOX, "EventBox", mGtk); + + RG_DEF_METHOD(initialize, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkexpander.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkexpander.c new file mode 100644 index 0000000..b283e08 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkexpander.c @@ -0,0 +1,55 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cExpander +#define _SELF(self) (GTK_EXPANDER(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE label, with_mnemonic; + GtkWidget* widget = NULL; + + rb_scan_args(argc, argv, "11", &label, &with_mnemonic); + if (NIL_P(with_mnemonic) || ! RVAL2CBOOL(with_mnemonic)){ + widget = gtk_expander_new(RVAL2CSTR(label)); + } else { + widget = gtk_expander_new_with_mnemonic(RVAL2CSTR(label)); + } + + RBGTK_INITIALIZE(self, widget); + return Qnil; +} + +#endif + +void +Init_gtk_expander(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_EXPANDER, "Expander", mGtk); + RG_DEF_METHOD(initialize, -1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilechooser.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilechooser.c new file mode 100644 index 0000000..e2b7724 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilechooser.c @@ -0,0 +1,321 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005,2006 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Seiya Nishizawa, Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE mFileChooser +#define _SELF(self) GTK_FILE_CHOOSER(RVAL2GOBJ(self)) + +#ifdef HAVE_GTK_GTKFILESYSTEM_H +/* For error handling */ +# define GTK_FILE_SYSTEM_ENABLE_UNSUPPORTED +# include +#endif + +static VALUE +gslist2ary_free(GSList* list) +{ + GSList* l; + VALUE ary = rb_ary_new(); + for (l = list; l != NULL; l = g_slist_next(l)) { + rb_ary_push(ary, CSTR2RVAL_FREE(l->data)); + } + g_slist_free(list); + return ary; +} + +static VALUE +rg_set_current_name(VALUE self, VALUE name) +{ + /* doc says the awaited string is UTF-8, so use RVAL2CSTR */ + gtk_file_chooser_set_current_name(_SELF(self), RVAL2CSTR(name)); + return self; +} + +static VALUE +rg_filename(VALUE self) +{ + return CSTRFILENAME2RVAL_FREE(gtk_file_chooser_get_filename(_SELF(self))); +} + +static VALUE +rg_set_filename(VALUE self, VALUE rbfilename) +{ + gchar *filename = RVAL2CSTRFILENAME(rbfilename); + gboolean ret = gtk_file_chooser_set_filename(_SELF(self), filename); + g_free(filename); + if (!ret) + rb_raise(rb_eRuntimeError, "Can't set filename"); + + return self; +} + +static VALUE +rg_select_filename(VALUE self, VALUE rbfilename) +{ + gchar *filename = RVAL2CSTRFILENAME(rbfilename); + gboolean ret = gtk_file_chooser_select_filename(_SELF(self), filename); + g_free(filename); + + return CBOOL2RVAL(ret); +} + +static VALUE +rg_unselect_filename(VALUE self, VALUE rbfilename) +{ + gchar *filename = RVAL2CSTRFILENAME(rbfilename); + gtk_file_chooser_unselect_filename(_SELF(self), filename); + g_free(filename); + + return self; +} + +static VALUE +rg_select_all(VALUE self) +{ + gtk_file_chooser_select_all(_SELF(self)); + return self; +} + +static VALUE +rg_unselect_all(VALUE self) +{ + gtk_file_chooser_unselect_all(_SELF(self)); + return self; +} + +static VALUE +rg_filenames(VALUE self) +{ + return CSTRFILENAMEARRAY2RVAL_FREE(gtk_file_chooser_get_filenames(_SELF(self))); +} + +static VALUE +rg_set_current_folder(VALUE self, VALUE filename) +{ + gboolean ret = gtk_file_chooser_set_current_folder(_SELF(self), RVAL2CSTR(filename)); + if (! ret) rb_raise(rb_eRuntimeError, "Can't set current folder"); + return self; +} + +static VALUE +rg_current_folder(VALUE self) +{ + return CSTR2RVAL_FREE(gtk_file_chooser_get_current_folder(_SELF(self))); +} + +static VALUE +rg_uri(VALUE self) +{ + return CSTR2RVAL_FREE(gtk_file_chooser_get_uri(_SELF(self))); +} + +static VALUE +rg_set_uri(VALUE self, VALUE uri) +{ + gboolean ret = gtk_file_chooser_set_uri(_SELF(self), RVAL2CSTR(uri)); + if (! ret) rb_raise(rb_eRuntimeError, "Can't set uri"); + return self; +} + +static VALUE +rg_select_uri(VALUE self, VALUE uri) +{ + return CBOOL2RVAL(gtk_file_chooser_select_uri(_SELF(self), RVAL2CSTR(uri))); +} + +static VALUE +rg_unselect_uri(VALUE self, VALUE uri) +{ + gtk_file_chooser_unselect_uri(_SELF(self), RVAL2CSTR(uri)); + return self; +} + +static VALUE +rg_uris(VALUE self) +{ + return gslist2ary_free(gtk_file_chooser_get_uris(_SELF(self))); +} + +static VALUE +rg_set_current_folder_uri(VALUE self, VALUE uri) +{ + gboolean ret = gtk_file_chooser_set_current_folder_uri(_SELF(self), RVAL2CSTR(uri)); + if (! ret) rb_raise(rb_eRuntimeError, "Can't set current folder uri"); + return self; +} + +static VALUE +rg_current_folder_uri(VALUE self) +{ + return CSTR2RVAL_FREE(gtk_file_chooser_get_current_folder_uri(_SELF(self))); +} + +static VALUE +rg_preview_filename(VALUE self) +{ + return CSTR2RVAL_FREE(gtk_file_chooser_get_preview_filename(_SELF(self))); +} + +static VALUE +rg_preview_uri(VALUE self) +{ + return CSTR2RVAL_FREE(gtk_file_chooser_get_preview_uri(_SELF(self))); +} + +static VALUE +rg_add_filter(VALUE self, VALUE filter) +{ + gtk_file_chooser_add_filter(_SELF(self), GTK_FILE_FILTER(RVAL2GOBJ(filter))); + return self; +} + +static VALUE +rg_remove_filter(VALUE self, VALUE filter) +{ + gtk_file_chooser_remove_filter(_SELF(self), GTK_FILE_FILTER(RVAL2GOBJ(filter))); + return self; +} + +static VALUE +rg_filters(VALUE self) +{ + return GSLIST2ARYF(gtk_file_chooser_list_filters(_SELF(self))); +} + +static VALUE +rg_add_shortcut_folder(VALUE self, VALUE rbfolder) +{ + gchar *folder = RVAL2CSTRFILENAME(rbfolder); + GError *error = NULL; + gboolean ret = gtk_file_chooser_add_shortcut_folder(_SELF(self), folder, &error); + g_free(folder); + if (!ret) + RAISE_GERROR(error); + + return self; +} + +static VALUE +rg_remove_shortcut_folder(VALUE self, VALUE rbfolder) +{ + gchar *folder = RVAL2CSTRFILENAME(rbfolder); + GError *error = NULL; + gboolean ret = gtk_file_chooser_remove_shortcut_folder(_SELF(self), folder, &error); + g_free(folder); + if (!ret) + RAISE_GERROR(error); + + return self; +} + +static VALUE +rg_shortcut_folders(VALUE self) +{ + return CSTRFILENAMEARRAY2RVAL_FREE(gtk_file_chooser_list_shortcut_folders(_SELF(self))); +} + +static VALUE +rg_add_shortcut_folder_uri(VALUE self, VALUE uri) +{ + GError *error = NULL; + if (! gtk_file_chooser_add_shortcut_folder_uri(_SELF(self), RVAL2CSTR(uri), &error)) + RAISE_GERROR(error); + return self; +} + +static VALUE +rg_remove_shortcut_folder_uri(VALUE self, VALUE uri) +{ + GError *error = NULL; + if (! gtk_file_chooser_remove_shortcut_folder_uri(_SELF(self), RVAL2CSTR(uri), &error)) + RAISE_GERROR(error); + return self; +} + +static VALUE +rg_shortcut_folder_uris(VALUE self) +{ + return gslist2ary_free(gtk_file_chooser_list_shortcut_folder_uris(_SELF(self))); +} +#endif + +void +Init_gtk_file_chooser(VALUE mGtk) +{ + +#if GTK_CHECK_VERSION(2,4,0) + + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(GTK_TYPE_FILE_CHOOSER, "FileChooser", mGtk); + + RG_DEF_METHOD(set_current_name, 1); + RG_DEF_METHOD(set_filename, 1); + RG_DEF_METHOD(filename, 0); + RG_DEF_METHOD(select_filename, 1); + RG_DEF_METHOD(unselect_filename, 1); + RG_DEF_METHOD(select_all, 0); + RG_DEF_METHOD(unselect_all, 0); + RG_DEF_METHOD(filenames, 0); + RG_DEF_METHOD(set_current_folder, 1); + RG_DEF_METHOD(current_folder, 0); + RG_DEF_METHOD(set_uri, 1); + RG_DEF_METHOD(uri, 0); + RG_DEF_METHOD(select_uri, 1); + RG_DEF_METHOD(unselect_uri, 1); + RG_DEF_METHOD(uris, 0); + RG_DEF_METHOD(set_current_folder_uri, 1); + RG_DEF_METHOD(current_folder_uri, 0); + RG_DEF_METHOD(preview_filename, 0); + RG_DEF_METHOD(preview_uri, 0); + RG_DEF_METHOD(add_filter, 1); + RG_DEF_METHOD(remove_filter, 1); + RG_DEF_METHOD(filters, 0); + RG_DEF_METHOD(add_shortcut_folder, 1); + RG_DEF_METHOD(remove_shortcut_folder, 1); + RG_DEF_METHOD(shortcut_folders, 0); + RG_DEF_METHOD(add_shortcut_folder_uri, 1); + RG_DEF_METHOD(remove_shortcut_folder_uri, 1); + + RG_DEF_METHOD(shortcut_folder_uris, 0); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + + /* GtkFileChooserAction */ + G_DEF_CLASS(GTK_TYPE_FILE_CHOOSER_ACTION, "Action", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_FILE_CHOOSER_ACTION, "GTK_FILE_CHOOSER_"); + + /* GtkFileChooserError */ + G_DEF_ERROR(GTK_FILE_CHOOSER_ERROR, "FileChooserError", mGtk, rb_eRuntimeError, + GTK_TYPE_FILE_CHOOSER_ERROR); + +#if GTK_CHECK_VERSION(2,8,0) + /* GtkFileChooserConfirmation */ + G_DEF_CLASS(GTK_TYPE_FILE_CHOOSER_CONFIRMATION, "Confirmation", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_FILE_CHOOSER_CONFIRMATION, "GTK_FILE_CHOOSER_"); +#endif + + G_DEF_CLASS3("GtkFileChooserEmbed", "FileChooserEmbed", mGtk); + +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilechooserbutton.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilechooserbutton.c new file mode 100644 index 0000000..7c9a3f3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilechooserbutton.c @@ -0,0 +1,63 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,6,0) + +#define RG_TARGET_NAMESPACE cFileChooserButton + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE title, action, backend; + GtkWidget* widget; + + rb_scan_args(argc, argv, "12", &title, &action, &backend); + + if (TYPE(title) == T_STRING) { + if (NIL_P(backend)){ + widget = gtk_file_chooser_button_new(RVAL2CSTR(title), + RVAL2GENUM(action, GTK_TYPE_FILE_CHOOSER_ACTION)); + } else { + widget = gtk_file_chooser_button_new_with_backend(RVAL2CSTR(title), + RVAL2GENUM(action, + GTK_TYPE_FILE_CHOOSER_ACTION), + RVAL2CSTR(backend)); + } + } else { + widget = gtk_file_chooser_button_new_with_dialog(GTK_WIDGET(RVAL2GOBJ(title))); + } + + RBGTK_INITIALIZE(self, widget); + return Qnil; +} + +#endif + +void +Init_gtk_filechooserbutton(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,6,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_FILE_CHOOSER_BUTTON, "FileChooserButton", mGtk); + RG_DEF_METHOD(initialize, -1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilechooserdialog.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilechooserdialog.c new file mode 100644 index 0000000..e30c60c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilechooserdialog.c @@ -0,0 +1,67 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Seiya Nishizawa, Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cFileChooserDialog +#define _SELF(self) GTK_FILE_CHOOSER_DIALOG(RVAL2GOBJ(self)) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE title, parent, action, back, button_ary; + GtkWidget* dialog; + const gchar *gtitle; + GtkWindow *gparent; + GtkFileChooserAction gaction; + const gchar *gback; + + rb_scan_args(argc, argv, "04*", &title, &parent, &action, &back, &button_ary); + gtitle = NIL_P(title) ? NULL : RVAL2CSTR(title); + gparent = NIL_P(parent) ? NULL : GTK_WINDOW(RVAL2GOBJ(parent)); + gaction = NIL_P(action) ? GTK_FILE_CHOOSER_ACTION_OPEN : RVAL2GENUM(action, GTK_TYPE_FILE_CHOOSER_ACTION); + gback = NIL_P(back) ? NULL : RVAL2CSTR(back); + dialog = gtk_file_chooser_dialog_new_with_backend(gtitle, + gparent, + gaction, + gback, + NULL, + NULL); + RBGTK_INITIALIZE(self, dialog); + rbgtk_dialog_add_buttons_internal(self, button_ary); + return Qnil; +} + +#endif + +void +Init_gtk_file_chooser_dialog(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_FILE_CHOOSER_DIALOG, "FileChooserDialog", mGtk); + + RG_DEF_METHOD(initialize, -1); + +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilechooserwidget.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilechooserwidget.c new file mode 100644 index 0000000..30e1bbf --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilechooserwidget.c @@ -0,0 +1,58 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Seiya Nishizawa, Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cFileChooserWidget + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE action, back; + GtkWidget* widget; + + rb_scan_args(argc, argv, "11", &action, &back); + + if (NIL_P(back)){ + widget = gtk_file_chooser_widget_new(RVAL2GENUM(action, GTK_TYPE_FILE_CHOOSER_ACTION)); + } else { + widget = gtk_file_chooser_widget_new_with_backend(RVAL2GENUM(action, GTK_TYPE_FILE_CHOOSER_ACTION), + RVAL2CSTR(back)); + } + + RBGTK_INITIALIZE(self, widget); + return Qnil; +} +#endif + +void +Init_gtk_file_chooser_widget(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_FILE_CHOOSER_WIDGET, "FileChooserWidget", mGtk); + + RG_DEF_METHOD(initialize, -1); + +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilefilter.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilefilter.c new file mode 100644 index 0000000..27d75de --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilefilter.c @@ -0,0 +1,142 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Seiya Nishizawa, Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cFileFilter +#define _SELF(self) GTK_FILE_FILTER(RVAL2GOBJ(self)) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_file_filter_new()); + return Qnil; +} + +static VALUE +rg_set_name(VALUE self, VALUE name) +{ + gtk_file_filter_set_name(_SELF(self), RVAL2CSTR(name)); + return self; +} + +static VALUE +rg_name(VALUE self) +{ + return CSTR2RVAL(gtk_file_filter_get_name(_SELF(self))); +} + +static VALUE +rg_add_mime_type(VALUE self, VALUE mime) +{ + gtk_file_filter_add_mime_type(_SELF(self), RVAL2CSTR(mime)); + return self; +} + +static VALUE +rg_add_pattern(VALUE self, VALUE pattern) +{ + gtk_file_filter_add_pattern(_SELF(self), RVAL2CSTR(pattern)); + return self; +} + +/* Should return true/false */ +static gboolean +filter_func(const GtkFileFilterInfo *info, gpointer func) +{ + return CBOOL2RVAL(rb_funcall((VALUE)func, + id_call, + 5, + GFLAGS2RVAL(info->contains, GTK_TYPE_FILE_FILTER_FLAGS), + CSTR2RVAL(info->filename), + CSTR2RVAL(info->uri), + CSTR2RVAL(info->display_name), + CSTR2RVAL(info->mime_type))); +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_add_pixbuf_formats(VALUE self) +{ + gtk_file_filter_add_pixbuf_formats(_SELF(self)); + return self; +} +#endif + +static VALUE +rg_add_custom(VALUE self, VALUE needed) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_file_filter_add_custom(_SELF(self), RVAL2GFLAGS(needed, GTK_TYPE_FILE_FILTER_FLAGS), + (GtkFileFilterFunc)filter_func, (gpointer)func, NULL); + return self; +} + +static VALUE +rg_needed(VALUE self) +{ + return GFLAGS2RVAL(gtk_file_filter_get_needed(_SELF(self)), GTK_TYPE_FILE_FILTER_FLAGS); +} + +static VALUE +rg_filter_p(VALUE self, VALUE contains, VALUE filename, VALUE uri, VALUE display_name, VALUE mime_type) +{ + GtkFileFilterInfo info; + info.contains = RVAL2GFLAGS(contains, GTK_TYPE_FILE_FILTER_FLAGS); + info.filename = RVAL2CSTR(filename); + info.uri = RVAL2CSTR(uri); + info.display_name = RVAL2CSTR(display_name); + info.mime_type = RVAL2CSTR(mime_type); + + return CBOOL2RVAL(gtk_file_filter_filter(_SELF(self), &info)); +} +#endif + +void +Init_gtk_file_filter(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_FILE_FILTER, "FileFilter", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(set_name, 1); + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(add_mime_type, 1); + RG_DEF_METHOD(add_pattern, 1); +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(add_pixbuf_formats, 0); +#endif + RG_DEF_METHOD(add_custom, 1); + RG_DEF_METHOD(needed, 0); + RG_DEF_METHOD_P(filter, 5); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + + G_DEF_CLASS(GTK_TYPE_FILE_FILTER_FLAGS, "Flags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_FILE_FILTER_FLAGS, "GTK_FILE_FILTER_"); + +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilesel.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilesel.c new file mode 100644 index 0000000..e177598 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilesel.c @@ -0,0 +1,150 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cFileSelection +#define _SELF(self) GTK_FILE_SELECTION(RVAL2GOBJ(self)) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE title; + rb_scan_args(argc, argv, "01", &title); + RBGTK_INITIALIZE(self, gtk_file_selection_new(NIL_P(title) ? NULL : RVAL2CSTR(title))); + return Qnil; +} + +static VALUE +rg_complete(VALUE self, VALUE pattern) +{ + gtk_file_selection_complete(_SELF(self), RVAL2CSTR(pattern)); + return self; +} + +static VALUE +rg_show_fileop_buttons(VALUE self) +{ + gtk_file_selection_show_fileop_buttons(_SELF(self)); + return Qnil; +} + +static VALUE +rg_hide_fileop_buttons(VALUE self) +{ + gtk_file_selection_hide_fileop_buttons(_SELF(self)); + return Qnil; +} + +static VALUE +rg_selections(VALUE self) +{ + gchar** ptr = gtk_file_selection_get_selections(_SELF(self)); + gchar** selections = ptr; + VALUE ary = rb_ary_new(); + while(*selections){ + rb_ary_push(ary, CSTR2RVAL(*selections)); + selections++; + } + if (ptr) + g_strfreev(ptr); + + return ary; +} + +static VALUE +rg_fileop_dialog(VALUE self) +{ + GtkWidget* widget = _SELF(self)->fileop_dialog; + return widget ? GOBJ2RVAL(widget) : Qnil; +} + +static VALUE +rg_dir_list(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->dir_list); +} + +static VALUE +rg_file_list(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->file_list); +} + +static VALUE +rg_ok_button(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->ok_button); +} + +static VALUE +rg_cancel_button(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->cancel_button); +} + +static VALUE +rg_history_pulldown(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->history_pulldown); +} + +static VALUE +rg_fileop_c_dir(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->fileop_c_dir); +} + +static VALUE +rg_fileop_del_file(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->fileop_del_file); +} + +static VALUE +rg_fileop_ren_file(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->fileop_ren_file); +} + +void +Init_gtk_file_selection(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_FILE_SELECTION, "FileSelection", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(complete, 1); + RG_DEF_METHOD(show_fileop_buttons, 0); + RG_DEF_METHOD(hide_fileop_buttons, 0); + RG_DEF_METHOD(selections, 0); + RG_DEF_METHOD(fileop_dialog, 0); + RG_DEF_METHOD(ok_button, 0); + RG_DEF_METHOD(cancel_button, 0); + RG_DEF_METHOD(dir_list, 0); + RG_DEF_METHOD(file_list, 0); + RG_DEF_METHOD(history_pulldown, 0); + RG_DEF_METHOD(fileop_c_dir, 0); + RG_DEF_METHOD(fileop_del_file, 0); + RG_DEF_METHOD(fileop_ren_file, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilesystemerror.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilesystemerror.c new file mode 100644 index 0000000..c058f1c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfilesystemerror.c @@ -0,0 +1,51 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005,2006 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Seiya Nishizawa, Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cFileSystemError + +void +Init_gtk_filesystemerror(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) +#ifdef GTK_FILE_SYSTEM_ERROR + VALUE RG_TARGET_NAMESPACE; + + /* GtkFileSystemError */ + RG_TARGET_NAMESPACE = G_DEF_ERROR2(GTK_FILE_SYSTEM_ERROR, "FileSystemError", + mGtk, rb_eRuntimeError); + rb_define_const(RG_TARGET_NAMESPACE, "NONEXISTENT", + INT2NUM(GTK_FILE_SYSTEM_ERROR_NONEXISTENT)); + rb_define_const(RG_TARGET_NAMESPACE, "NOT_FOLDER", + INT2NUM(GTK_FILE_SYSTEM_ERROR_NOT_FOLDER)); + rb_define_const(RG_TARGET_NAMESPACE, "INVALID_URI", + INT2NUM(GTK_FILE_SYSTEM_ERROR_INVALID_URI)); + rb_define_const(RG_TARGET_NAMESPACE, "BAD_FILENAME", + INT2NUM(GTK_FILE_SYSTEM_ERROR_BAD_FILENAME)); + rb_define_const(RG_TARGET_NAMESPACE, "FAILED", + INT2NUM(GTK_FILE_SYSTEM_ERROR_FAILED)); + rb_define_const(RG_TARGET_NAMESPACE, "ALREADY_EXSITS", + INT2NUM(GTK_FILE_SYSTEM_ERROR_ALREADY_EXISTS)); +#endif +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfixed.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfixed.c new file mode 100644 index 0000000..fc4f560 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfixed.c @@ -0,0 +1,78 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cFixed +#define _SELF(self) (GTK_FIXED(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_fixed_new()); + return Qnil; +} + +static VALUE +rg_put(VALUE self, VALUE win, VALUE x, VALUE y) +{ + gtk_fixed_put(_SELF(self), GTK_WIDGET(RVAL2GOBJ(win)), + NUM2INT(x), NUM2INT(y)); + return self; +} + +static VALUE +rg_move(VALUE self, VALUE win, VALUE x, VALUE y) +{ + gtk_fixed_move(_SELF(self), GTK_WIDGET(RVAL2GOBJ(win)), + NUM2INT(x), NUM2INT(y)); + return self; +} + +static VALUE +rg_has_window_p(VALUE self) +{ + return CBOOL2RVAL(gtk_fixed_get_has_window(_SELF(self))); +} + +static VALUE +rg_set_has_window(VALUE self, VALUE has_window) +{ + gtk_fixed_set_has_window(_SELF(self), RVAL2CBOOL(has_window)); + return self; +} + +void +Init_gtk_fixed(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_FIXED, "Fixed", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(put, 3); + RG_DEF_METHOD(move, 3); + RG_DEF_METHOD_P(has_window, 0); + RG_DEF_METHOD(set_has_window, 1); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfontbutton.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfontbutton.c new file mode 100644 index 0000000..b5f24c9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfontbutton.c @@ -0,0 +1,55 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cFontButton + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE fontname; + GtkWidget* widget; + + rb_scan_args(argc, argv, "01", &fontname); + + if (NIL_P(fontname)){ + widget = gtk_font_button_new(); + } else { + widget = gtk_font_button_new_with_font(RVAL2CSTR(fontname)); + } + + RBGTK_INITIALIZE(self, widget); + return Qnil; +} + +#endif + +void +Init_gtk_fontbutton(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_FONT_BUTTON, "FontButton", mGtk); + RG_DEF_METHOD(initialize, -1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfontselection.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfontselection.c new file mode 100644 index 0000000..ad55033 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfontselection.c @@ -0,0 +1,41 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 2001 Neil Conway + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cFontSelection + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_font_selection_new()); + return Qnil; +} + +void +Init_gtk_font_selection(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_FONT_SELECTION, "FontSelection", mGtk); + + RG_DEF_METHOD(initialize, 0); + rb_undef_method(RG_TARGET_NAMESPACE, "font"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfontselectiondialog.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfontselectiondialog.c new file mode 100644 index 0000000..dbb8251 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkfontselectiondialog.c @@ -0,0 +1,106 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 2001 Neil Conway + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cFontSelectionDialog +#define _SELF(self) (GTK_FONT_SELECTION_DIALOG(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE title; + rb_scan_args(argc, argv, "01", &title); + RBGTK_INITIALIZE(self, gtk_font_selection_dialog_new(NIL_P(title) ? NULL : RVAL2CSTR(title))); + return Qnil; +} + +static VALUE +rg_font_name(VALUE self) +{ + gchar* name = gtk_font_selection_dialog_get_font_name(_SELF(self)); + return name ? CSTR2RVAL(name) : Qnil; +} + +static VALUE +rg_set_font_name(VALUE self, VALUE fontname) +{ + return CBOOL2RVAL(gtk_font_selection_dialog_set_font_name(_SELF(self), + RVAL2CSTR(fontname))); +} + +static VALUE +rg_preview_text(VALUE self) +{ + const gchar* text = gtk_font_selection_dialog_get_preview_text(_SELF(self)); + return text ? CSTR2RVAL(text) : Qnil; +} + +static VALUE +rg_set_preview_text(VALUE self, VALUE text) +{ + gtk_font_selection_dialog_set_preview_text(_SELF(self), RVAL2CSTR(text)); + return self; +} + +static VALUE +rg_font_selection(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->fontsel); +} + +static VALUE +rg_ok_button(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->ok_button); +} + +static VALUE +rg_cancel_button(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->cancel_button); +} + +static VALUE +rg_apply_button(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->apply_button); +} + +void +Init_gtk_font_selection_dialog(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_FONT_SELECTION_DIALOG, + "FontSelectionDialog", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(font_name, 0); + RG_DEF_METHOD(set_font_name, 1); + RG_DEF_METHOD(preview_text, 0); + RG_DEF_METHOD(set_preview_text, 1); + RG_DEF_METHOD(font_selection, 0); + RG_DEF_METHOD(ok_button, 0); + RG_DEF_METHOD(cancel_button, 0); + RG_DEF_METHOD(apply_button, 0); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkframe.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkframe.c new file mode 100644 index 0000000..fd8ed35 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkframe.c @@ -0,0 +1,69 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cFrame + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE label; + rb_scan_args(argc, argv, "01", &label); + RBGTK_INITIALIZE(self, gtk_frame_new(NIL_P(label)?NULL:RVAL2CSTR(label))); + return Qnil; +} + +static VALUE +rg_set_label_align(VALUE self, VALUE xalign, VALUE yalign) +{ + gtk_frame_set_label_align(GTK_FRAME(RVAL2GOBJ(self)), + NUM2DBL(xalign), + NUM2DBL(yalign)); + + return self; +} + +static VALUE +rg_label_align(VALUE self) +{ + gfloat xalign, yalign; + gtk_frame_get_label_align(GTK_FRAME(RVAL2GOBJ(self)), + &xalign, &yalign); + + return rb_ary_new3(2, rb_float_new(xalign), rb_float_new(yalign)); +} + +void +Init_gtk_frame(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_FRAME, "Frame", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(set_label_align, 2); + RG_DEF_METHOD(label_align, 0); + rb_undef_method(RG_TARGET_NAMESPACE, "shadow"); + rb_undef_method(RG_TARGET_NAMESPACE, "shadow="); + rb_undef_method(RG_TARGET_NAMESPACE, "set_shadow"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkgamma.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkgamma.c new file mode 100644 index 0000000..990bbbc --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkgamma.c @@ -0,0 +1,56 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cGammaCurve + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_gamma_curve_new()); + return Qnil; +} + +static VALUE +rg_gamma(VALUE self) +{ + return rb_float_new(GTK_GAMMA_CURVE(RVAL2GOBJ(self))->gamma); +} + +static VALUE +rg_curve(VALUE self) +{ + return GOBJ2RVAL(GTK_GAMMA_CURVE(RVAL2GOBJ(self))->curve); +} + +void +Init_gtk_gamma_curve(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_GAMMA_CURVE, "GammaCurve", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(gamma, 0); + RG_DEF_METHOD(curve, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhandlebox.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhandlebox.c new file mode 100644 index 0000000..14056f2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhandlebox.c @@ -0,0 +1,45 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cHandleBox + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_handle_box_new()); + return Qnil; +} + +void +Init_gtk_handle_box(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_HANDLE_BOX, "HandleBox", mGtk); + + RG_DEF_METHOD(initialize, 0); + rb_undef_method(RG_TARGET_NAMESPACE, "shadow"); + rb_undef_method(RG_TARGET_NAMESPACE, "shadow="); + rb_undef_method(RG_TARGET_NAMESPACE, "set_shadow"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhbbox.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhbbox.c new file mode 100644 index 0000000..1b08079 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhbbox.c @@ -0,0 +1,42 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cHButtonBox + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_hbutton_box_new()); + return Qnil; +} + +void +Init_gtk_hbutton_box(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_HBUTTON_BOX, "HButtonBox", mGtk); + + RG_DEF_METHOD(initialize, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhbox.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhbox.c new file mode 100644 index 0000000..41df685 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhbox.c @@ -0,0 +1,47 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cHBox + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE homogeneous, spacing; + + rb_scan_args(argc, argv, "02", &homogeneous, &spacing); + + RBGTK_INITIALIZE(self, gtk_hbox_new(RVAL2CBOOL(homogeneous), + (NIL_P(spacing)?0:NUM2INT(spacing)))); + return Qnil; +} + +void +Init_gtk_hbox(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_HBOX, "HBox", mGtk); + + RG_DEF_METHOD(initialize, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhpaned.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhpaned.c new file mode 100644 index 0000000..b577ace --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhpaned.c @@ -0,0 +1,42 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cHPaned + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_hpaned_new()); + return Qnil; +} + +void +Init_gtk_hpaned(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_HPANED, "HPaned", mGtk); + + RG_DEF_METHOD(initialize, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhruler.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhruler.c new file mode 100644 index 0000000..b8b3d89 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhruler.c @@ -0,0 +1,42 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cHRuler + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_hruler_new()); + return Qnil; +} + +void +Init_gtk_hruler(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_HRULER, "HRuler", mGtk); + + RG_DEF_METHOD(initialize, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhscale.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhscale.c new file mode 100644 index 0000000..7482e68 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhscale.c @@ -0,0 +1,54 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cHScale + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE arg1, arg2, arg3; + GtkAdjustment *adj = NULL; + GtkWidget *widget; + + rb_scan_args(argc, argv, "03", &arg1, &arg2, &arg3); + + if (NIL_P(arg1) || RVAL2GTYPE(arg1) == GTK_TYPE_ADJUSTMENT){ + if (!NIL_P(arg1)) adj = GTK_ADJUSTMENT(RVAL2GOBJ(arg1)); + widget = gtk_hscale_new(adj); + } else { + widget = gtk_hscale_new_with_range(NUM2DBL(arg1), + NUM2DBL(arg2), NUM2DBL(arg3)); + } + RBGTK_INITIALIZE(self, widget); + return Qnil; +} + +void +Init_gtk_hscale(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_HSCALE, "HScale", mGtk); + RG_DEF_METHOD(initialize, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhscrollbar.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhscrollbar.c new file mode 100644 index 0000000..22d9681 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhscrollbar.c @@ -0,0 +1,47 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cHScrollbar + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE arg1; + GtkAdjustment *adj = NULL; + + rb_scan_args(argc, argv, "01", &arg1); + if (!NIL_P(arg1)) adj = GTK_ADJUSTMENT(RVAL2GOBJ(arg1)); + + RBGTK_INITIALIZE(self, gtk_hscrollbar_new(adj)); + return Qnil; +} + +void +Init_gtk_hscrollbar(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_HSCROLLBAR, "HScrollbar", mGtk); + RG_DEF_METHOD(initialize, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhseparator.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhseparator.c new file mode 100644 index 0000000..d792cde --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkhseparator.c @@ -0,0 +1,41 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cHSeparator + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_hseparator_new()); + return Qnil; +} + +void +Init_gtk_hseparator(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_HSEPARATOR, "HSeparator", mGtk); + RG_DEF_METHOD(initialize, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkiconfactory.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkiconfactory.c new file mode 100644 index 0000000..8701f50 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkiconfactory.c @@ -0,0 +1,86 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 OGASAWARA, Takeshi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cIconFactory +#define _SELF(s) (GTK_ICON_FACTORY(RVAL2GOBJ(s))) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, gtk_icon_factory_new()); + return Qnil; +} + +static VALUE +rg_add(VALUE self, VALUE id, VALUE icon_set) +{ + gtk_icon_factory_add(_SELF(self), RVAL2CSTR(id), + (GtkIconSet*)RVAL2BOXED(icon_set, GTK_TYPE_ICON_SET)); + return self; +} + +static VALUE +rg_add_default(VALUE self) +{ + gtk_icon_factory_add_default(_SELF(self)); + return self; +} + +static VALUE +rg_lookup(VALUE self, VALUE id) +{ + GtkIconSet *icon_set; + + icon_set = gtk_icon_factory_lookup(_SELF(self), RVAL2CSTR(id)); + return BOXED2RVAL(icon_set, GTK_TYPE_ICON_SET); +} + +static VALUE +rg_s_lookup_default(G_GNUC_UNUSED VALUE self, VALUE id) +{ + GtkIconSet *icon_set; + + icon_set = gtk_icon_factory_lookup_default(RVAL2CSTR(id)); + return BOXED2RVAL(icon_set, GTK_TYPE_ICON_SET); +} + +static VALUE +rg_remove_default(VALUE self) +{ + gtk_icon_factory_remove_default(_SELF(self)); + return self; +} + +void +Init_gtk_icon_factory(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ICON_FACTORY, "IconFactory", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(add, 2); + RG_DEF_METHOD(add_default, 0); + RG_DEF_METHOD(remove_default, 0); + RG_DEF_METHOD(lookup, 1); + + RG_DEF_SMETHOD(lookup_default, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkiconinfo.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkiconinfo.c new file mode 100644 index 0000000..2153b91 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkiconinfo.c @@ -0,0 +1,122 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cIconInfo +#define _SELF(i) ((GtkIconInfo*)RVAL2BOXED(i, GTK_TYPE_ICON_INFO)) + +static VALUE +rg_base_size(VALUE self) +{ + return INT2NUM(gtk_icon_info_get_base_size(_SELF(self))); +} + +static VALUE +rg_filename(VALUE self) +{ + return CSTR2RVAL(gtk_icon_info_get_filename(_SELF(self))); +} + +static VALUE +rg_builtin_pixbuf(VALUE self) +{ + return GOBJ2RVAL(gtk_icon_info_get_builtin_pixbuf(_SELF(self))); +} + +static VALUE +rg_load_icon(VALUE self) +{ + GError* error = NULL; + GdkPixbuf* pixbuf = gtk_icon_info_load_icon(_SELF(self), &error); + VALUE ret; + + if (error) RAISE_GERROR(error); + + ret = GOBJ2RVAL(pixbuf); + g_object_unref(pixbuf); + return ret; +} + +static VALUE +rg_set_raw_coordinates(VALUE self, VALUE raw_coordinates) +{ + gtk_icon_info_set_raw_coordinates(_SELF(self), RVAL2CBOOL(raw_coordinates)); + return self; +} + +static VALUE +rg_embedded_rect(VALUE self) +{ + GdkRectangle rectangle; + gboolean ret = gtk_icon_info_get_embedded_rect(_SELF(self), &rectangle); + + if (ret) + return BOXED2RVAL(&rectangle, GDK_TYPE_RECTANGLE); + else + return Qnil; +} + +static VALUE +rg_attach_points(VALUE self) +{ + GdkPoint* points; + gint n_points, i; + gboolean ret = gtk_icon_info_get_attach_points(_SELF(self), &points, &n_points); + VALUE ary = Qnil; + + if (ret){ + ary = rb_ary_new(); + for (i = 0; i < n_points; i++){ + rb_ary_push(ary, rb_assoc_new(INT2NUM(points[i].x), INT2NUM(points[i].y))); + } + g_free(points); + } + return ary; +} + +static VALUE +rg_display_name(VALUE self) +{ + return CSTR2RVAL(gtk_icon_info_get_display_name(_SELF(self))); +} +#endif + +void +Init_gtk_iconinfo(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ICON_INFO, "IconInfo", mGtk); + + RG_DEF_METHOD(base_size, 0); + RG_DEF_METHOD(filename, 0); + RG_DEF_METHOD(builtin_pixbuf, 0); + RG_DEF_METHOD(load_icon, 0); + RG_DEF_METHOD(set_raw_coordinates, 1); + RG_DEF_METHOD(embedded_rect, 0); + RG_DEF_METHOD(attach_points, 0); + RG_DEF_METHOD(display_name, 0); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkiconset.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkiconset.c new file mode 100644 index 0000000..bfab433 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkiconset.c @@ -0,0 +1,91 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 OGASAWARA, Takeshi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cIconSet +#define _SELF(s) ((GtkIconSet*)RVAL2BOXED(s, GTK_TYPE_ICON_SET)) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + GtkIconSet *icon_set; + VALUE pixbuf; + + rb_scan_args(argc, argv, "01", &pixbuf); + + if(NIL_P(pixbuf)) + icon_set = gtk_icon_set_new(); + else + icon_set = gtk_icon_set_new_from_pixbuf(RVAL2GOBJ(pixbuf)); + + G_INITIALIZE(self, icon_set); + return Qnil; +} + +static VALUE +rg_add_source(VALUE self, VALUE source) +{ + gtk_icon_set_add_source(_SELF(self), RVAL2BOXED(source, GTK_TYPE_ICON_SOURCE)); + return self; +} + +static VALUE +rg_sizes(VALUE self) +{ + GtkIconSize *sizes; + gint n_sizes; + VALUE result; + int n; + + gtk_icon_set_get_sizes(_SELF(self), &sizes, &n_sizes); + result = rb_ary_new(); + for(n=0; n 0) { + if (TYPE(label) == T_STRING){ + if (NIL_P(use_underline_or_accel_group) || RVAL2CBOOL(use_underline_or_accel_group)){ + widget = gtk_image_menu_item_new_with_mnemonic(RVAL2CSTR(label)); + } else { + widget = gtk_image_menu_item_new_with_label(RVAL2CSTR(label)); + } + } else if (TYPE(label) == T_SYMBOL){ + widget = gtk_image_menu_item_new_from_stock(rb_id2name(SYM2ID(label)), + NIL_P(use_underline_or_accel_group) ? NULL : + GTK_ACCEL_GROUP(RVAL2GOBJ(use_underline_or_accel_group))); + } else { + rb_raise(rb_eArgError, "invalid argument %s (expect Symbol(Gtk::Stock constants) or String)", + rb_class2name(CLASS_OF(label))); + } + } else { + widget = gtk_image_menu_item_new(); + } + + RBGTK_INITIALIZE(self, widget); + return Qnil; +} + +void +Init_gtk_image_menu_item(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_IMAGE_MENU_ITEM, "ImageMenuItem", mGtk); + + RG_DEF_METHOD(initialize, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkimcontext.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkimcontext.c new file mode 100644 index 0000000..b540c81 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkimcontext.c @@ -0,0 +1,135 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cIMContext +#define _SELF(self) (GTK_IM_CONTEXT(RVAL2GOBJ(self))) + +static VALUE +rg_set_client_window(VALUE self, VALUE gdkwindow) +{ + gtk_im_context_set_client_window(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow))); + return self; +} + +static VALUE +rg_preedit_string(VALUE self) +{ + gchar* str; + PangoAttrList* attrs; + gint cursor_pos; + + gtk_im_context_get_preedit_string(_SELF(self), &str, &attrs, &cursor_pos); + return rb_ary_new3(3, CSTR2RVAL(str), BOXED2RVAL(attrs, PANGO_TYPE_ATTR_LIST), + INT2NUM(cursor_pos)); +} + +static VALUE +rg_filter_keypress(VALUE self, VALUE event) +{ + return CBOOL2RVAL(gtk_im_context_filter_keypress(_SELF(self), (GdkEventKey*)RVAL2GEV(event))); +} + +static VALUE +rg_focus_in(VALUE self) +{ + gtk_im_context_focus_in(_SELF(self)); + return self; +} + +static VALUE +rg_focus_out(VALUE self) +{ + gtk_im_context_focus_out(_SELF(self)); + return self; +} + +static VALUE +rg_reset(VALUE self) +{ + gtk_im_context_reset(_SELF(self)); + return self; +} + +static VALUE +rg_set_cursor_location(VALUE self, VALUE area) +{ + gtk_im_context_set_cursor_location( + _SELF(self), + ((GdkRectangle*)RVAL2BOXED(area, GDK_TYPE_RECTANGLE))); + return self; +} + +static VALUE +rg_set_use_preedit(VALUE self, VALUE use_preedit) +{ + gtk_im_context_set_use_preedit(_SELF(self), RVAL2CBOOL(use_preedit)); + return self; +} + +static VALUE +rg_set_surrounding(VALUE self, VALUE text, VALUE cursor_index) +{ + StringValue(text); + gtk_im_context_set_surrounding(_SELF(self), + RSTRING_PTR(text), RSTRING_LEN(text), + NUM2INT(cursor_index)); + return self; +} + +static VALUE +rg_surrounding(VALUE self) +{ + gchar* text; + gint cursor_index; + gboolean result = gtk_im_context_get_surrounding(_SELF(self), + &text, &cursor_index); + return result ? rb_ary_new3(2, CSTR2RVAL(text), INT2NUM(cursor_index)) : Qnil; +} + +static VALUE +rg_delete_surrounding(VALUE self, VALUE offset, VALUE n_chars) +{ + return CBOOL2RVAL(gtk_im_context_delete_surrounding(_SELF(self), NUM2INT(offset), + NUM2INT(n_chars))); +} + +void +Init_gtk_imcontext(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_IM_CONTEXT, "IMContext", mGtk); + + RG_DEF_METHOD(set_client_window, 1); + RG_DEF_METHOD(preedit_string, 0); + /* Is it better to name as "filter_keypress?" ?*/ + RG_DEF_METHOD(filter_keypress, 1); + RG_DEF_METHOD(focus_in, 0); + RG_DEF_METHOD(focus_out, 0); + RG_DEF_METHOD(reset, 0); + RG_DEF_METHOD(set_cursor_location, 1); + RG_DEF_METHOD(set_use_preedit, 1); + RG_DEF_METHOD(set_surrounding, 2); + RG_DEF_METHOD(surrounding, 0); + RG_DEF_METHOD(delete_surrounding, 2); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkimcontextsimple.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkimcontextsimple.c new file mode 100644 index 0000000..928206e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkimcontextsimple.c @@ -0,0 +1,69 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cIMContextSimple +#define _SELF(self) (GTK_IM_CONTEXT_SIMPLE(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, gtk_im_context_simple_new()); + + return Qnil; +} + +/* TODO: Why are we taking a third argument? Shouldn't it be determined by the + * length of rbdata? */ +static VALUE +rg_add_table(VALUE self, VALUE rbdata, VALUE rbmax_seq_len, VALUE rbn_seqs) +{ + GtkIMContextSimple *context_simple = _SELF(self); + gint max_seq_len = NUM2INT(rbmax_seq_len); + gint n_seqs = NUM2INT(rbn_seqs); + long n; + guint16 *data; + + if (max_seq_len > GTK_MAX_COMPOSE_LEN) + rb_raise(rb_eArgError, + "max_seq_len cannot be greater than GTK_MAX_COMPOSE_LEN: %d > %d", + max_seq_len, GTK_MAX_COMPOSE_LEN); + + data = RVAL2GUINT16S(rbdata, n); + + gtk_im_context_simple_add_table(context_simple, data, max_seq_len, n_seqs); + + g_free(data); + + return self; +} + +void +Init_gtk_imcontext_simple(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_IM_CONTEXT_SIMPLE, "IMContextSimple", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(add_table, 3); + + rb_define_const(RG_TARGET_NAMESPACE, "MAX_COMPOSE_LEN", GTK_MAX_COMPOSE_LEN); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkimmulticontext.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkimmulticontext.c new file mode 100644 index 0000000..4d443da --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkimmulticontext.c @@ -0,0 +1,48 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cIMMulticontext +#define _SELF(self) (GTK_IM_MULTICONTEXT(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, gtk_im_multicontext_new()); + return Qnil; +} + +static VALUE +rg_append_menuitems(VALUE self, VALUE menushell) +{ + gtk_im_multicontext_append_menuitems(_SELF(self), RVAL2GOBJ(menushell)); + return self; +} + +void +Init_gtk_im_multicontext(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_IM_MULTICONTEXT, "IMMulticontext", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(append_menuitems, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkinfobar.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkinfobar.c new file mode 100644 index 0000000..7e5dfda --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkinfobar.c @@ -0,0 +1,147 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2012 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,18,0) +#define RG_TARGET_NAMESPACE cInfoBar +#define _SELF(self) (GTK_INFO_BAR(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + if (argc == 0){ + RBGTK_INITIALIZE(self, gtk_info_bar_new ()); + } else if (argc > 0){ + //TODO gtk_info_bar_new_with_buttons + rb_raise(rb_eArgError, "method does not yet supported adding buttons"); + } else { + rb_raise(rb_eArgError, "invalid argument number"); + } + return Qnil; +} + +static VALUE +rg_get_action_area(VALUE self) +{ + return GOBJ2RVAL(gtk_info_bar_get_action_area(_SELF(self))); +} + +static VALUE +rg_get_content_area(VALUE self) +{ + return GOBJ2RVAL(gtk_info_bar_get_content_area(_SELF(self))); +} + +static VALUE +rg_get_message_type(VALUE self) +{ + return GENUM2RVAL(gtk_info_bar_get_message_type(_SELF(self)), + GTK_TYPE_MESSAGE_TYPE); +} + +static VALUE +rg_set_message_type(VALUE self, VALUE type) +{ + gtk_info_bar_set_message_type(_SELF(self), + RVAL2GENUM(type, GTK_TYPE_MESSAGE_TYPE)); + return self; +} + +static VALUE +rg_set_default_response(VALUE self, VALUE response_id) +{ + gtk_info_bar_set_default_response(_SELF(self), + RVAL2GENUM(response_id, GTK_TYPE_RESPONSE_TYPE)); + return self; +} + +static VALUE +rg_add_action_widget(VALUE self, VALUE widget, VALUE response_id) +{ + gtk_info_bar_add_action_widget(_SELF(self), + GTK_WIDGET(RVAL2GOBJ(widget)), + RVAL2GENUM(response_id, GTK_TYPE_RESPONSE_TYPE)); + return self; +} + +static VALUE +rg_add_button(VALUE self, VALUE button_text, VALUE response_id) +{ + const gchar *name; + if (SYMBOL_P(button_text)) { + name = rb_id2name(SYM2ID(button_text)); + } else { + name = RVAL2CSTR(button_text); + } + return GOBJ2RVAL(gtk_info_bar_add_button(_SELF(self), name, + RVAL2GENUM(response_id, GTK_TYPE_RESPONSE_TYPE))); +} + +/* +static VALUE +rg_add_buttons(int argc, VALUE *argv, VALUE self) +{ +} +*/ + +static VALUE +rg_set_response_sensitive(VALUE self, VALUE response_id, VALUE sensitive) +{ + gtk_info_bar_set_response_sensitive(_SELF(self), + RVAL2GENUM(response_id, GTK_TYPE_RESPONSE_TYPE), + RVAL2CBOOL(sensitive)); + return self; +} + +static VALUE +rg_response(VALUE self, VALUE response_id) +{ + gtk_info_bar_response(_SELF(self), RVAL2GENUM(response_id, GTK_TYPE_RESPONSE_TYPE)); + return self; +} +#endif + +void +Init_gtk_infobar(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,18,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_INFO_BAR, "InfoBar", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(get_action_area, 0); + RG_DEF_ALIAS("action_area", "get_action_area"); + RG_DEF_METHOD(get_content_area, 0); + RG_DEF_ALIAS("content_area", "get_content_area"); + RG_DEF_METHOD(get_message_type, 0); + RG_DEF_ALIAS("message_type", "get_message_type"); + RG_DEF_METHOD(set_message_type, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "message_type"); + RG_DEF_METHOD(set_default_response, 1); + RG_DEF_METHOD(add_action_widget, 2); + RG_DEF_METHOD(add_button, 2); +/* + RG_DEF_METHOD(add_buttons, -1); +*/ + RG_DEF_METHOD(set_response_sensitive, 2); + RG_DEF_METHOD(response, 1); +#endif +} + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkinputdialog.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkinputdialog.c new file mode 100644 index 0000000..5f92b11 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkinputdialog.c @@ -0,0 +1,41 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cInputDialog + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_input_dialog_new()); + return Qnil; +} + +void +Init_gtk_input_dialog(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_INPUT_DIALOG, "InputDialog", mGtk); + RG_DEF_METHOD(initialize, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkinvisible.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkinvisible.c new file mode 100644 index 0000000..c3331f9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkinvisible.c @@ -0,0 +1,53 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 OGASAWARA, Takeshi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cInvisible +#define _SELF(s) GTK_INVISIBLE(RVAL2GOBJ(s)) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE screen; + + rb_scan_args(argc, argv, "01", &screen); + + if (argc == 0){ + RBGTK_INITIALIZE(self, gtk_invisible_new()); + } else { +#if GTK_CHECK_VERSION(2,2,0) + RBGTK_INITIALIZE(self, gtk_invisible_new_for_screen( + GDK_SCREEN(RVAL2GOBJ(screen)))); +#else + rb_raise(rb_eArgError, "GTK+-2.2 feature. GTK+-2.0.x doesn't support this."); +#endif + } + return Qnil; +} + +void +Init_gtk_invisible(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_INVISIBLE, "Invisible", mGtk); + + RG_DEF_METHOD(initialize, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkitem.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkitem.c new file mode 100644 index 0000000..6bd974c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkitem.c @@ -0,0 +1,60 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cItem + +/* + * Item + */ +static VALUE +rg_select(VALUE self) +{ + gtk_item_select(GTK_ITEM(RVAL2GOBJ(self))); + return self; +} + +static VALUE +rg_deselect(VALUE self) +{ + gtk_item_deselect(GTK_ITEM(RVAL2GOBJ(self))); + return self; +} + +static VALUE +rg_toggle(VALUE self) +{ + gtk_item_toggle(GTK_ITEM(RVAL2GOBJ(self))); + return self; +} + +void +Init_gtk_item(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ITEM, "Item", mGtk); + RG_DEF_METHOD(select, 0); + RG_DEF_METHOD(deselect, 0); + RG_DEF_METHOD(toggle, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkitemfactory.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkitemfactory.c new file mode 100644 index 0000000..681e56d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkitemfactory.c @@ -0,0 +1,299 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Hiroshi Igarashi, + * dellin, + * MUTOH Masao + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" +#include + +#define RG_TARGET_NAMESPACE cItemFactory +#define _SELF(self) (GTK_ITEM_FACTORY(RVAL2GOBJ(self))) +#define RVAL2WIDGET(w) (GTK_WIDGET(RVAL2GOBJ(w))) +#define RVAL2ACCEL(a) (GTK_ACCEL_GROUP(RVAL2GOBJ(a))) + +static VALUE action_table; +static guint action_id = 0; + +static VALUE +rg_initialize(VALUE self, VALUE type, VALUE path, VALUE accel) +{ + VALUE obj = rb_eval_string("eval('self', binding)"); + G_RELATIVE(obj, self); + RBGTK_INITIALIZE(self, gtk_item_factory_new(NUM2ULONG(type), RVAL2CSTR(path), + RVAL2ACCEL(accel))); + + return Qnil; +} + +static VALUE +rg_construct(int argc, VALUE *argv, VALUE self) +{ + VALUE type, path, accel; + GtkItemFactory* ifact = _SELF(self); + ifact->accel_group = NULL; + + rb_scan_args(argc, argv, "21", &type, &path, &accel); + gtk_item_factory_construct(ifact, FIX2INT(type), + RVAL2CSTR(path), RVAL2ACCEL(accel)); + return self; +} + +static VALUE +rg_s_from_widget(VALUE self, VALUE widget) +{ + VALUE obj = GOBJ2RVAL(gtk_item_factory_from_widget(RVAL2WIDGET(widget))); + G_RELATIVE(obj, self); + return obj; +} + +static VALUE +rg_s_path_from_widget(G_GNUC_UNUSED VALUE self, VALUE widget) +{ + return CSTR2RVAL(gtk_item_factory_path_from_widget(RVAL2WIDGET(widget))); +} + +static VALUE +rg_get_item(VALUE self, VALUE path) +{ + VALUE obj = Qnil; + GtkWidget* widget = gtk_item_factory_get_item(_SELF(self), RVAL2CSTR(path)); + if (widget){ + obj = GOBJ2RVAL(widget); + G_RELATIVE(obj, self); + } + return obj; +} + +static VALUE +rg_get_widget(VALUE self, VALUE path) +{ + VALUE obj = Qnil; + GtkWidget* widget = gtk_item_factory_get_widget(_SELF(self), RVAL2CSTR(path)); + if (widget){ + obj = GOBJ2RVAL(widget); + G_RELATIVE(obj, self); + } + return obj; +} + +/* We can't implement them because actions are always 1. +GtkWidget* gtk_item_factory_get_widget_by_action + (GtkItemFactory *ifactory, + guint action); +GtkWidget* gtk_item_factory_get_item_by_action + (GtkItemFactory *ifactory, + guint action); +*/ + +static int +menuitem_type_check(char *item_type) +{ + if (item_type == NULL || strcmp(item_type, "") == 0 + || (strcmp(item_type, "") == 0) + || (strcmp(item_type, "") == 0)) + return 0; + else + return -1; +} + +static void +items_exec_callback_wrap(G_GNUC_UNUSED VALUE callback_data, guint action_id, GtkWidget *widget) +{ + VALUE iter, data; + VALUE action = rb_hash_aref(action_table, UINT2NUM(action_id)); + + iter = RARRAY_PTR(action)[0]; + data = RARRAY_PTR(action)[1]; + if (!NIL_P(iter)) { + rb_funcall(iter, id_call, 2, data, GOBJ2RVAL(widget)); + } +} + +static void +create_factory_entry(GtkItemFactoryEntry *entry, VALUE self, VALUE path, VALUE item_type, VALUE accel, VALUE extdata, VALUE func, VALUE data) +{ + VALUE action; + + entry->path = (gchar *)(NIL_P(path) ? NULL : RVAL2CSTR(path)); + entry->item_type = (gchar *)(NIL_P(item_type) ? "" : RVAL2CSTR(item_type)); + entry->accelerator = (gchar *)(NIL_P(accel) ? NULL : RVAL2CSTR(accel)); + + if (menuitem_type_check(entry->item_type) == 0) { + entry->callback = NULL; + } else { + if (NIL_P(func)) { + entry->callback = NULL; + } else { + entry->callback = items_exec_callback_wrap; + } + } + action = rb_ary_new3(2, func, data); + G_RELATIVE(self, action); + rb_hash_aset(action_table, UINT2NUM(action_id), action); + entry->callback_action = action_id; + action_id++; + + if (NIL_P(extdata)){ + entry->extra_data = NULL; + } else if (TYPE(extdata) == T_STRING){ + entry->extra_data = RVAL2CSTR(extdata); + } else if (TYPE(extdata) == T_SYMBOL){ + entry->extra_data = rb_id2name(SYM2ID(extdata)); + } else if (RVAL2GTYPE(extdata) == GDK_TYPE_PIXBUF){ + GdkPixdata pixdata; + guint stream_length_p; + gdk_pixdata_from_pixbuf(&pixdata, GDK_PIXBUF(RVAL2GOBJ(extdata)), TRUE); + entry->extra_data = gdk_pixdata_serialize(&pixdata, &stream_length_p); + } else { + entry->extra_data = NULL; + } +} + +static VALUE +rg_create_item(int argc, VALUE *argv, VALUE self) +{ + VALUE path, type, accel, extdata, data, func; + GtkItemFactoryEntry *entry; + + rb_scan_args(argc, argv, "14", &path, &type, &accel, &extdata, &data); + + entry = ALLOC(GtkItemFactoryEntry); + func = rb_rescue((VALUE(*)())rb_block_proc, 0, NULL, 0); + + create_factory_entry(entry, self, path, type, accel, extdata, func, data); + + gtk_item_factory_create_item(_SELF(self), entry, (gpointer)self, 1); + g_free(entry); + return self; +} + +static VALUE +rg_create_items(VALUE self, VALUE ary) +{ + VALUE entry, path, accel, type, func, data, extdata; + GtkItemFactoryEntry *entries; + guint i, len, n_menu_entries; + + n_menu_entries = RARRAY_LEN(ary); + entries = ALLOC_N(GtkItemFactoryEntry, n_menu_entries); + + for (i = 0; i < n_menu_entries; i++) { + entry = RARRAY_PTR(ary)[i]; + len = RARRAY_LEN(entry); + Check_Type(entry, T_ARRAY); + path = RARRAY_PTR(entry)[0]; + type = ((len > 1) ? RARRAY_PTR(entry)[1] : Qnil); + accel = ((len > 2) ? RARRAY_PTR(entry)[2] : Qnil); + extdata = ((len > 3) ? RARRAY_PTR(entry)[3] : Qnil); + func = ((len > 4) ? RARRAY_PTR(entry)[4] : Qnil); + data = ((len > 5) ? RARRAY_PTR(entry)[5] : Qnil); + + create_factory_entry(&entries[i], self, path, type, accel, extdata, func, data); + } + + gtk_item_factory_create_items (_SELF(self), n_menu_entries, entries, NULL); + g_free(entries); + + return self; +} + +static VALUE +rg_delete_item(VALUE self, VALUE path) +{ + gtk_item_factory_delete_item(_SELF(self), RVAL2CSTR(path)); + return self; +} + +/* +Don't implement. Use Gtk::ItemFactory#delete_item instead. +void gtk_item_factory_delete_entry (GtkItemFactory *ifactory, + GtkItemFactoryEntry *entry); +void gtk_item_factory_delete_entries (GtkItemFactory *ifactory, + guint n_entries, + GtkItemFactoryEntry *entries); +*/ + +static VALUE +rg_popup(VALUE self, VALUE x, VALUE y, VALUE mouse_button, VALUE time) +{ + gtk_item_factory_popup(_SELF(self), NUM2UINT(x), NUM2UINT(y), NUM2UINT(mouse_button), + NUM2UINT(time)); + return self; +} +/* +Do we need these methods? +void gtk_item_factory_popup_with_data + (GtkItemFactory *ifactory, + gpointer popup_data, + GtkDestroyNotify destroy, + guint x, + guint y, + guint mouse_button, + guint32 time); + +gpointer gtk_item_factory_popup_data (GtkItemFactory *ifactory); +gpointer gtk_item_factory_popup_data_from_widget + (GtkWidget *widget); +void gtk_item_factory_set_translate_func + (GtkItemFactory *ifactory, + GtkTranslateFunc func, + gpointer data, + GtkDestroyNotify notify); +*/ + +void +Init_gtk_itemfactory(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ITEM_FACTORY, "ItemFactory", mGtk); + + RG_DEF_SMETHOD(from_widget, 1); + RG_DEF_SMETHOD(path_from_widget, 1); + + RG_DEF_METHOD(initialize, 3); + RG_DEF_METHOD(construct, -1); + RG_DEF_METHOD(get_item, 1); + RG_DEF_METHOD(get_widget, 1); + RG_DEF_METHOD(create_item, -1); + RG_DEF_METHOD(create_items, 1); + RG_DEF_METHOD(delete_item, 1); + RG_DEF_METHOD(popup, 4); + + /* Ruby/GTK Original constants */ + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_MENU_BAR", INT2FIX(GTK_TYPE_MENU_BAR)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_MENU", INT2FIX(GTK_TYPE_MENU)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_OPTION_MENU", INT2FIX(GTK_TYPE_OPTION_MENU)); + + rb_define_const(RG_TARGET_NAMESPACE, "TITLE", CSTR2RVAL("")); + rb_define_const(RG_TARGET_NAMESPACE, "ITEM", CSTR2RVAL("<Item>")); + rb_define_const(RG_TARGET_NAMESPACE, "CHECK_ITEM", CSTR2RVAL("<CheckItem>")); + rb_define_const(RG_TARGET_NAMESPACE, "TOGGLE_ITEM", CSTR2RVAL("<ToggleItem>")); + rb_define_const(RG_TARGET_NAMESPACE, "RADIO_ITEM", CSTR2RVAL("<RadioItem>")); + rb_define_const(RG_TARGET_NAMESPACE, "IMAGE_ITEM", CSTR2RVAL("<ImageItem>")); + rb_define_const(RG_TARGET_NAMESPACE, "STOCK_ITEM", CSTR2RVAL("<StockItem>")); + rb_define_const(RG_TARGET_NAMESPACE, "SEPARATOR", CSTR2RVAL("<Separator>")); + rb_define_const(RG_TARGET_NAMESPACE, "BRANCH", CSTR2RVAL("<Branch>")); + rb_define_const(RG_TARGET_NAMESPACE, "LAST_BRANCH", CSTR2RVAL("<LastBranch>")); + rb_define_const(RG_TARGET_NAMESPACE, "TEAROFF", CSTR2RVAL("<Tearoff>")); + + action_table = rb_hash_new(); + rb_global_variable(&action_table); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtklabel.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtklabel.c new file mode 100644 index 0000000..d331624 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtklabel.c @@ -0,0 +1,139 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cLabel +#define _SELF(s) (GTK_LABEL(RVAL2GOBJ(s))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE label, with_mnemonic; + GtkWidget* widget = NULL; + + rb_scan_args(argc, argv, "02", &label, &with_mnemonic); + if (NIL_P(with_mnemonic) || ! RVAL2CBOOL(with_mnemonic)){ + widget = gtk_label_new(NIL_P(label)?NULL:RVAL2CSTR(label)); + } else { + widget = gtk_label_new_with_mnemonic(NIL_P(label)?NULL:RVAL2CSTR(label)); + } + + RBGTK_INITIALIZE(self, widget); + return Qnil; +} + +static VALUE +rg_operator_label_set_text_only(VALUE self, VALUE text) +{ + gtk_label_set_text(_SELF(self), RVAL2CSTR(text)); + return text; +} + +static VALUE +rg_set_text(int argc, VALUE *argv, VALUE self) +{ + VALUE label, with_mnemonic; + + rb_scan_args(argc, argv, "02", &label, &with_mnemonic); + if (NIL_P(with_mnemonic) || ! RVAL2CBOOL(with_mnemonic)){ + gtk_label_set_text(_SELF(self), RVAL2CSTR(label)); + } else { + gtk_label_set_text_with_mnemonic(_SELF(self), RVAL2CSTR(label)); + } + return self; +} + +static VALUE +rg_operator_label_set_markup_only(VALUE self, VALUE text) +{ + gtk_label_set_markup(_SELF(self), RVAL2CSTR(text)); + return text; +} + +static VALUE +rg_set_markup(int argc, VALUE *argv, VALUE self) +{ + VALUE str, with_mnemonic; + rb_scan_args(argc, argv, "02", &str, &with_mnemonic); + + if (NIL_P(with_mnemonic) || ! RVAL2CBOOL(with_mnemonic)){ + gtk_label_set_markup(_SELF(self), RVAL2CSTR(str)); + } else { + gtk_label_set_markup_with_mnemonic(_SELF(self), RVAL2CSTR(str)); + } + return self; +} + +static VALUE +rg_layout_offsets(VALUE self) +{ + gint x, y; + gtk_label_get_layout_offsets(_SELF(self), &x, &y); + return rb_ary_new3(2, INT2NUM(x), INT2NUM(y)); +} + +static VALUE +rg_text(VALUE self) +{ + return CSTR2RVAL(gtk_label_get_text(_SELF(self))); +} + +static VALUE +rg_select_region(VALUE self, VALUE start_offset, VALUE end_offset) +{ + gtk_label_select_region(_SELF(self), NUM2INT(start_offset), NUM2INT(end_offset)); + return self; +} + +static VALUE +rg_layout(VALUE self) +{ + return GOBJ2RVAL(gtk_label_get_layout(_SELF(self))); +} + +static VALUE +rg_selection_bounds(VALUE self) +{ + gint start, end; + gboolean ret = gtk_label_get_selection_bounds(_SELF(self), &start, &end); + return ret ? rb_ary_new3(2, INT2NUM(start), INT2NUM(end)) : Qnil; +} + +void +Init_gtk_label(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_LABEL, "Label", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(text, 0); + RG_DEF_METHOD(set_text, -1); + RG_DEF_METHOD_OPERATOR("text=", label_set_text_only, 1); + RG_DEF_METHOD(set_markup, -1); + RG_DEF_METHOD_OPERATOR("markup=", label_set_markup_only, 1); + RG_DEF_METHOD(layout_offsets, 0); + RG_DEF_METHOD(select_region, 2); + RG_DEF_METHOD(layout, 0); + RG_DEF_METHOD(selection_bounds, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtklayout.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtklayout.c new file mode 100644 index 0000000..2b338d4 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtklayout.c @@ -0,0 +1,94 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cLayout +#define _SELF(self) (GTK_LAYOUT(RVAL2GOBJ(self))) +#define RVAL2ADJ(a) (GTK_ADJUSTMENT(RVAL2GOBJ(a))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE hadjustment, vadjustment; + GtkWidget* layout; + rb_scan_args(argc, argv, "02", &hadjustment, &vadjustment); + + layout = gtk_layout_new( + NIL_P(hadjustment) ? 0 : RVAL2ADJ(hadjustment), + NIL_P(vadjustment) ? 0 : RVAL2ADJ(vadjustment)); + + RBGTK_INITIALIZE(self, layout); + return Qnil; +} + +static VALUE +rg_put(VALUE self, VALUE widget, VALUE x, VALUE y) +{ + gtk_layout_put(_SELF(self), GTK_WIDGET(RVAL2GOBJ(widget)), + NUM2INT(x), NUM2INT(y)); + return self; +} + +static VALUE +rg_move(VALUE self, VALUE widget, VALUE x, VALUE y) +{ + gtk_layout_move(_SELF(self), GTK_WIDGET(RVAL2GOBJ(widget)), + NUM2INT(x), NUM2INT(y)); + return self; +} + +static VALUE +rg_set_size(VALUE self, VALUE width, VALUE height) +{ + gtk_layout_set_size(_SELF(self), NUM2UINT(width), NUM2UINT(height)); + return self; +} + +static VALUE +rg_size(VALUE self) +{ + guint width, height; + gtk_layout_get_size(_SELF(self), &width, &height); + return rb_ary_new3(2, INT2NUM(width), INT2NUM(height)); +} + +static VALUE +rg_bin_window(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->bin_window); +} + +void +Init_gtk_layout(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_LAYOUT, "Layout", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(put, 3); + RG_DEF_METHOD(move, 3); + RG_DEF_METHOD(set_size, 2); + RG_DEF_METHOD(size, 0); + RG_DEF_METHOD(bin_window, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtklinkbutton.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtklinkbutton.c new file mode 100644 index 0000000..12987fa --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtklinkbutton.c @@ -0,0 +1,70 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +#define RG_TARGET_NAMESPACE cLinkButton +#define _SELF(self) (GTK_LINK_BUTTON(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE uri, label; + GtkWidget *widget = NULL; + + rb_scan_args(argc, argv, "11", &uri, &label); + if (NIL_P(label)){ + widget = gtk_link_button_new(RVAL2CSTR(uri)); + } else { + widget = gtk_link_button_new_with_label(RVAL2CSTR(uri), RVAL2CSTR(label)); + } + RBGTK_INITIALIZE(self, widget); + return Qnil; +} + +static void +link_func(GtkLinkButton *button, const gchar *link, gpointer func) +{ + rb_funcall((VALUE)func, id_call, 2, GOBJ2RVAL(button), CSTR2RVAL(link)); +} + +static VALUE +rg_s_set_uri_hook(VALUE self) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_link_button_set_uri_hook((GtkLinkButtonUriFunc)link_func, (gpointer)func, (GDestroyNotify)NULL); + return self; +} +#endif + +void +Init_gtk_link_button(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_LINK_BUTTON, "LinkButton", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_SMETHOD(set_uri_hook, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkliststore.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkliststore.c new file mode 100644 index 0000000..25c6278 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkliststore.c @@ -0,0 +1,425 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cListStore +#define _SELF(s) (GTK_LIST_STORE(RVAL2GOBJ(s))) + +static ID id_to_a, id_size; + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + gint cnt; + GtkListStore* store; + GType* buf; + + if (argc == 0) rb_raise(rb_eArgError, "need more than 1 class type."); + + buf = ALLOCA_N(GType, argc); + for (cnt = 0; cnt < argc; cnt++) { + buf[cnt] = CLASS2GTYPE(argv[cnt]); + } + + store = gtk_list_store_newv(argc, buf); + + G_INITIALIZE(self, store); + + return Qnil; +} + +static VALUE +rg_set_column_types(int argc, VALUE *argv, VALUE self) +{ + gint cnt; + GType* buf; + + if (argc == 0) rb_raise(rb_eArgError, "need more than 1 class type."); + buf = ALLOCA_N(GType, argc); + for (cnt = 0; cnt < argc; cnt++) { + buf[cnt] = CLASS2GTYPE(argv[cnt]); + } + + gtk_list_store_set_column_types(_SELF(self), argc, buf); + + return self; +} + +static VALUE +rg_set_value(VALUE self, VALUE iter, VALUE column, VALUE value) +{ + GType gtype = gtk_tree_model_get_column_type(GTK_TREE_MODEL(RVAL2GOBJ(self)), NUM2INT(column)); + GValue gval = G_VALUE_INIT; + g_value_init(&gval, gtype); + + rbgobj_rvalue_to_gvalue(value, &gval); + + G_CHILD_ADD(iter, value); + + gtk_list_store_set_value(_SELF(self), RVAL2GTKTREEITER(iter), NUM2INT(column), &gval); + + g_value_unset(&gval); + return self; +} + +#if GTK_CHECK_VERSION(2, 12, 0) +typedef struct _ValuesInfo +{ + gint i; + VALUE iter; + GtkTreeModel *model; + gint *g_columns; + GValue *g_values; +} ValuesInfo; + +static int +collect_value(VALUE key, VALUE value, ValuesInfo *info) +{ + GType g_type; + gint column; + + column = NUM2INT(key); + info->g_columns[info->i] = column; + g_type = gtk_tree_model_get_column_type(info->model, column); + g_value_init(&(info->g_values[info->i]), g_type); + rbgobj_rvalue_to_gvalue(value, &(info->g_values[info->i])); + G_CHILD_ADD(info->iter, value); + info->i++; + + return ST_CONTINUE; +} + +static void +hash_to_values(VALUE hash, VALUE iter, GtkTreeModel *model, + gint *g_columns, GValue *g_values, G_GNUC_UNUSED gint length) +{ + ValuesInfo info; + + info.i = 0; + info.iter = iter; + info.model = model; + info.g_columns = g_columns; + info.g_values = g_values; + rb_hash_foreach(hash, collect_value, (VALUE)(&info)); +} + +static void +array_to_values(VALUE array, VALUE iter, GtkTreeModel *model, + gint *g_columns, GValue *g_values, gint length) +{ + gint i; + + for (i = 0; i < length; i++) { + GType g_type; + + g_columns[i] = i; + g_type = gtk_tree_model_get_column_type(model, i); + g_value_init(&g_values[i], g_type); + rbgobj_rvalue_to_gvalue(RARRAY_PTR(array)[i], &g_values[i]); + G_CHILD_ADD(iter, RARRAY_PTR(array)[i]); + } +} + +static VALUE +rg_set_values(VALUE self, VALUE iter, VALUE values) +{ + GValue *g_values; + GtkListStore *store; + GtkTreeModel *model; + gint *g_columns; + gint i, length; + + length = NUM2INT(rb_funcall(values, id_size, 0)); + if (length == 0) + return self; + + g_columns = ALLOCA_N(gint, length); + g_values = ALLOCA_N(GValue, length); + MEMZERO(g_values, GValue, length); + + store = _SELF(self); + model = GTK_TREE_MODEL(store); + if (RVAL2CBOOL(rb_obj_is_kind_of(values, rb_cHash))) { + hash_to_values(values, iter, model, g_columns, g_values, length); + } + else if (RVAL2CBOOL(rb_obj_is_kind_of(values, rb_cArray))) { + array_to_values(values, iter, model, g_columns, g_values, length); + } + else { + rb_raise(rb_eArgError, "must be array or hash of values"); + } + + gtk_list_store_set_valuesv(store, RVAL2GTKTREEITER(iter), + g_columns, g_values, length); + + for (i = 0; i < length; i++) + g_value_unset(&g_values[i]); + + return self; +} +#endif + +/* + void gtk_tree_store_set (GtkTreeStore *tree_store, + GtkTreeIter *iter, + ...); + + void gtk_tree_store_set_valist (GtkTreeStore *tree_store, + GtkTreeIter *iter, + va_list var_args); +*/ + +static VALUE +rg_remove(VALUE self, VALUE iter) +{ + G_CHILD_REMOVE(self, iter); +#if GTK_CHECK_VERSION(2,2,0) + return CBOOL2RVAL(gtk_list_store_remove(_SELF(self), RVAL2GTKTREEITER(iter))); +#else + gtk_list_store_remove(_SELF(self), RVAL2GTKTREEITER(iter)); + return Qtrue; +#endif +} + +struct lstore_insert_args { + GtkListStore *store; + GtkTreeIter iter; + gint position; + VALUE ary; + long i; + long n; + gint *columns; + GValue *values; +}; + +static VALUE +lstore_insert_body(VALUE value) +{ + struct lstore_insert_args *args = (struct lstore_insert_args *)value; + GtkTreeModel *model = GTK_TREE_MODEL(args->store); + + for (args->i = 0; args->i < args->n; args->i++) { + VALUE ary = rb_ary_to_ary(RARRAY_PTR(args->ary)[args->i]); + + args->columns[args->i] = NUM2INT(RARRAY_PTR(ary)[1]); + g_value_init(&args->values[args->i], + gtk_tree_model_get_column_type(model, args->columns[args->i])); + rbgobj_rvalue_to_gvalue(RARRAY_PTR(ary)[0], &args->values[args->i]); + } + + gtk_list_store_insert_with_valuesv(args->store, + &args->iter, + args->position, + args->columns, + args->values, + args->n); + + return Qnil; +} + +static VALUE +lstore_insert_ensure(VALUE value) +{ + long i; + struct lstore_insert_args *args = (struct lstore_insert_args *)value; + + for (i = 0; i < args->i; i++) + g_value_unset(&args->values[i]); + + g_free(args->values); + g_free(args->columns); + + return Qnil; +} + +/* + Gtk::ListStore#insert(pos, val1 => 0, val2 => 2, ... ) + */ +static VALUE +rg_insert(int argc, VALUE *argv, VALUE self) +{ + VALUE position, values, result; + struct lstore_insert_args args; + args.store = _SELF(self); + + rb_scan_args(argc, argv, "11", &position, &values); + args.position = NUM2INT(position); + + if (NIL_P(values)){ + gtk_list_store_insert(args.store, &args.iter, args.position); + } else { +#if GTK_CHECK_VERSION(2,6,0) + args.ary = rb_funcall(values, id_to_a, 0); + args.n = RARRAY_LEN(args.ary); + args.columns = g_new(gint, args.n); + args.values = g_new0(GValue, args.n); + + rb_ensure(lstore_insert_body, (VALUE)&args, + lstore_insert_ensure, (VALUE)&args); +#else + gtk_list_store_insert(args.store, &args.iter, args.position); + rb_warn("Ignored 2nd argument under this environment, as it has been supported since GTK+-2.6."); +#endif + } + + args.iter.user_data3 = args.store; + + result = GTKTREEITER2RVAL(&args.iter); + + return result; +} + +static VALUE +rg_insert_before(VALUE self, VALUE sibling) +{ + VALUE ret; + GtkTreeIter iter; + GtkListStore* model = _SELF(self); + gtk_list_store_insert_before(model, &iter, NIL_P(sibling) ? NULL : RVAL2GTKTREEITER(sibling)); + iter.user_data3 = model; + + ret = GTKTREEITER2RVAL(&iter); + return ret; +} + +static VALUE +rg_insert_after(VALUE self, VALUE sibling) +{ + VALUE ret; + GtkTreeIter iter; + GtkListStore* model = _SELF(self); + gtk_list_store_insert_after(model, &iter, NIL_P(sibling) ? NULL : RVAL2GTKTREEITER(sibling)); + iter.user_data3 = model; + + ret = GTKTREEITER2RVAL(&iter); + return ret; +} + +static VALUE +rg_prepend(VALUE self) +{ + VALUE ret; + GtkTreeIter iter; + GtkListStore* model = _SELF(self); + gtk_list_store_prepend(model, &iter); + iter.user_data3 = model; + + ret = GTKTREEITER2RVAL(&iter); + return ret; +} + +static VALUE +rg_append(VALUE self) +{ + VALUE ret; + GtkTreeIter iter; + GtkListStore* model = _SELF(self); + gtk_list_store_append(model, &iter); + iter.user_data3 = model; + + ret = GTKTREEITER2RVAL(&iter); + return ret; +} + +static VALUE +rg_clear(VALUE self) +{ + G_CHILD_REMOVE_ALL(self); + gtk_list_store_clear(_SELF(self)); + return self; +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_iter_is_valid_p(VALUE self, VALUE iter) +{ + return (NIL_P(iter)) ? Qfalse : + CBOOL2RVAL(gtk_list_store_iter_is_valid(_SELF(self), RVAL2GTKTREEITER(iter))); +} + +static VALUE +rg_reorder(VALUE self, VALUE rbnew_order) +{ + GtkListStore *store = _SELF(self); + long n; + gint *new_order = RVAL2GINTS(rbnew_order, n); + + gtk_list_store_reorder(store, new_order); + + g_free(new_order); + + return self; +} +static VALUE +rg_swap(VALUE self, VALUE iter1, VALUE iter2) +{ + gtk_list_store_swap(_SELF(self), RVAL2GTKTREEITER(iter1), RVAL2GTKTREEITER(iter2)); + return self; +} +static VALUE +rg_move_before(VALUE self, VALUE iter, VALUE position) +{ + gtk_list_store_move_before(_SELF(self), RVAL2GTKTREEITER(iter), + NIL_P(position) ? NULL : RVAL2GTKTREEITER(position)); + return self; +} +static VALUE +rg_move_after(VALUE self, VALUE iter, VALUE position) +{ + gtk_list_store_move_after(_SELF(self), RVAL2GTKTREEITER(iter), + NIL_P(position) ? NULL : RVAL2GTKTREEITER(position)); + return self; +} +#endif + +void +Init_gtk_list_store(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_LIST_STORE, "ListStore", mGtk); + + id_to_a = rb_intern("to_a"); + id_size = rb_intern("size"); + + rbgtk_register_treeiter_set_value_func(GTK_TYPE_LIST_STORE, + (rbgtkiter_set_value_func)>k_list_store_set_value); + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(set_column_types, -1); + RG_DEF_METHOD(set_value, 3); + RG_DEF_METHOD(remove, 1); + RG_DEF_METHOD(insert, -1); + RG_DEF_METHOD(insert_before, 1); + RG_DEF_METHOD(insert_after, 1); + RG_DEF_METHOD(prepend, 0); + RG_DEF_METHOD(append, 0); + RG_DEF_METHOD(clear, 0); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD_P(iter_is_valid, 1); + RG_DEF_METHOD(reorder, 1); + RG_DEF_METHOD(swap, 2); + RG_DEF_METHOD(move_before, 2); + RG_DEF_METHOD(move_after, 2); +#endif +#if GTK_CHECK_VERSION(2, 12, 0) + RG_DEF_METHOD(set_values, 2); +#endif + +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmacros.h b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmacros.h new file mode 100644 index 0000000..62140dd --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmacros.h @@ -0,0 +1,39 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2008 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __RB_GTK_MACROS_H__ +#define __RB_GTK_MACROS_H__ + +#define RBGTK_MAJOR_VERSION RBGLIB_MAJOR_VERSION +#define RBGTK_MINOR_VERSION RBGLIB_MINOR_VERSION +#define RBGTK_MICRO_VERSION RBGLIB_MICRO_VERSION + +#if defined(G_PLATFORM_WIN32) && !defined(RUBY_GTK2_STATIC_COMPILATION) +# ifdef RUBY_GTK2_COMPILATION +# define RUBY_GTK2_VAR __declspec(dllexport) +# else +# define RUBY_GTK2_VAR extern __declspec(dllimport) +# endif +#else +# define RUBY_GTK2_VAR extern +#endif + +#endif /* __RB_GTK_MACROS_H__ */ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmenu.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmenu.c new file mode 100644 index 0000000..1b64e91 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmenu.c @@ -0,0 +1,183 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cMenu +#define _SELF(self) (GTK_MENU(RVAL2GOBJ(self))) +#define RVAL2WIDGET(w) (GTK_WIDGET(RVAL2GOBJ(w))) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_menu_new()); + return Qnil; +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_set_screen(VALUE self, VALUE screen) +{ + gtk_menu_set_screen(_SELF(self), GDK_SCREEN(RVAL2GOBJ(screen))); + return self; +} +#endif + +static VALUE +rg_reorder_child(VALUE self, VALUE child, VALUE position) +{ + gtk_menu_reorder_child(_SELF(self), GTK_WIDGET(RVAL2GOBJ(child)), + NUM2INT(position)); + return self; +} + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_attach(VALUE self, VALUE child, VALUE left_attach, VALUE right_attach, VALUE top_attach, VALUE bottom_attach) +{ + gtk_menu_attach(_SELF(self), GTK_WIDGET(RVAL2GOBJ(child)), + NUM2UINT(left_attach), NUM2UINT(right_attach), + NUM2UINT(top_attach), NUM2UINT(bottom_attach)); + return self; +} +#endif + +static void +menu_pos_func(GtkMenu *menu, gint *px, gint *py, gboolean *push_in, gpointer data) +{ + VALUE arr = rb_funcall((VALUE)data, id_call, 4, GOBJ2RVAL(menu), + INT2FIX(*px), INT2FIX(*py), + CBOOL2RVAL(*push_in)); + + if (TYPE(arr) == T_ARRAY && (RARRAY_LEN(arr) == 2 || RARRAY_LEN(arr) == 3)){ + *px = NUM2INT(RARRAY_PTR(arr)[0]); + *py = NUM2INT(RARRAY_PTR(arr)[1]); + if (RARRAY_LEN(arr) == 3) + *push_in = RVAL2CBOOL(RARRAY_PTR(arr)[2]); + } else { + rb_raise(rb_eArgError, "block should return [x, y, push_in]"); + } +} + +/* the proc should return [x, y, push_in] */ +static VALUE +rg_popup(VALUE self, VALUE pshell, VALUE pitem, VALUE button, VALUE activate_time) +{ + GtkWidget *gpshell = NULL; + GtkWidget *gpitem = NULL; + GtkMenuPositionFunc pfunc = NULL; + gpointer data = NULL; + VALUE func; + + if (rb_block_given_p()) { + func = rb_block_proc(); + pfunc = (GtkMenuPositionFunc)menu_pos_func; + data = (gpointer)func; + G_RELATIVE(self, func); + } + if (!NIL_P(pshell)){ + gpshell = RVAL2WIDGET(pshell); + } + if (!NIL_P(pitem)) { + gpitem = RVAL2WIDGET(pitem); + } + + gtk_menu_popup(_SELF(self), gpshell, gpitem, + pfunc, data, NUM2UINT(button), + NUM2UINT(activate_time)); + return self; +} + +static VALUE +rg_popdown(VALUE self) +{ + gtk_menu_popdown(_SELF(self)); + return self; +} + +static VALUE +rg_reposition(VALUE self) +{ + gtk_menu_reposition(_SELF(self)); + return self; +} + +static VALUE menu_detacher; +static void +detach_func(GtkWidget *attach_widget, GtkMenu *menu) +{ + rb_funcall((VALUE)menu_detacher, id_call, 2, + GOBJ2RVAL(attach_widget), GOBJ2RVAL(menu)); +} + +static VALUE +rg_attach_to_widget(VALUE self, VALUE attach_widget) +{ + menu_detacher = rb_block_proc(); + G_RELATIVE(self, menu_detacher); + gtk_menu_attach_to_widget(_SELF(self), + GTK_WIDGET(RVAL2GOBJ(attach_widget)), + (GtkMenuDetachFunc)detach_func); + return self; +} + +static VALUE +rg_detach(VALUE self) +{ + gtk_menu_detach(_SELF(self)); + return self; +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_s_get_for_attach_widget(G_GNUC_UNUSED VALUE self, VALUE widget) +{ + /* Owned by GTK+ */ + return GLIST2ARY(gtk_menu_get_for_attach_widget(GTK_WIDGET(RVAL2GOBJ(widget)))); +} +#endif + +void +Init_gtk_menu(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_MENU, "Menu", mGtk); + + RG_DEF_METHOD(initialize, 0); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(set_screen, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "screen"); +#endif + RG_DEF_METHOD(reorder_child, 2); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(attach, 5); +#endif + RG_DEF_METHOD(popup, 4); + RG_DEF_METHOD(popdown, 0); + RG_DEF_METHOD(reposition, 0); + RG_DEF_METHOD(detach, 0); +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_SMETHOD(get_for_attach_widget, 1); +#endif + RG_DEF_METHOD(attach_to_widget, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmenubar.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmenubar.c new file mode 100644 index 0000000..9317b47 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmenubar.c @@ -0,0 +1,47 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cMenuBar + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_menu_bar_new()); + return Qnil; +} + +void +Init_gtk_menu_bar(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_MENU_BAR, "MenuBar", mGtk); + RG_DEF_METHOD(initialize, 0); + +#if GTK_CHECK_VERSION(2,8,0) + /* GtkPackDirection */ + G_DEF_CLASS(GTK_TYPE_PACK_DIRECTION, "PackDirection", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_PACK_DIRECTION, "GTK_"); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmenuitem.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmenuitem.c new file mode 100644 index 0000000..fe3c933 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmenuitem.c @@ -0,0 +1,111 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cMenuItem +#define _SELF(s) (GTK_MENU_ITEM(RVAL2GOBJ(s))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + const gchar *label = NULL; + VALUE rb_label, use_underline; + GtkWidget *widget = NULL; + + rb_scan_args(argc, argv, "02", &rb_label, &use_underline); + + if (!NIL_P(rb_label)) + label = RVAL2CSTR(rb_label); + if (label) { + if (NIL_P(use_underline) || RVAL2CBOOL(use_underline)) { + widget = gtk_menu_item_new_with_mnemonic(label); + } else { + widget = gtk_menu_item_new_with_label(label); + } + } else { + widget = gtk_menu_item_new(); + } + + RBGTK_INITIALIZE(self, widget); + return Qnil; +} + +static VALUE +mitem_set_submenu(VALUE self, VALUE child) +{ + GtkMenuItem *item; + GtkWidget *submenu; + + item = _SELF(self); + submenu = gtk_menu_item_get_submenu(item); + if (submenu) + G_CHILD_REMOVE(self, GOBJ2RVAL(submenu)); + + gtk_menu_item_set_submenu(item, GTK_WIDGET(RVAL2GOBJ(child))); + G_CHILD_ADD(self, child); + return self; +} + +static VALUE +rg_remove_submenu(VALUE self) +{ + GtkMenuItem *item; + GtkWidget *submenu; + + item = _SELF(self); + submenu = gtk_menu_item_get_submenu(item); + gtk_menu_item_remove_submenu(item); + if (submenu) + G_CHILD_REMOVE(self, GOBJ2RVAL(submenu)); + + return self; +} + +static VALUE +rg_toggle_size_request(VALUE self) +{ + gint requisition; + gtk_menu_item_toggle_size_request(_SELF(self), &requisition); + return INT2NUM(requisition); +} + +static VALUE +rg_toggle_size_allocate(VALUE self, VALUE allocation) +{ + gtk_menu_item_toggle_size_allocate(_SELF(self), NUM2INT(allocation)); + return self; +} + +void +Init_gtk_menu_item(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_MENU_ITEM, "MenuItem", mGtk); + + RG_DEF_METHOD(initialize, -1); + G_REPLACE_SET_PROPERTY(RG_TARGET_NAMESPACE, "submenu", mitem_set_submenu, 1); + RG_DEF_METHOD(remove_submenu, 0); + RG_DEF_METHOD(toggle_size_request, 0); + RG_DEF_METHOD(toggle_size_allocate, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmenushell.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmenushell.c new file mode 100644 index 0000000..31657f4 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmenushell.c @@ -0,0 +1,112 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cMenuShell +#define _SELF(self) (GTK_MENU_SHELL(RVAL2GOBJ(self))) +#define RVAL2WIDGET(w) (GTK_WIDGET(RVAL2GOBJ(w))) + +static VALUE +rg_append(VALUE self, VALUE child) +{ + gtk_menu_shell_append(_SELF(self),RVAL2WIDGET(child)); + G_CHILD_ADD(self, child); + return self; +} + +static VALUE +rg_prepend(VALUE self, VALUE child) +{ + gtk_menu_shell_prepend(_SELF(self), RVAL2WIDGET(child)); + G_CHILD_ADD(self, child); + return self; +} + +static VALUE +rg_insert(VALUE self, VALUE child, VALUE pos) +{ + gtk_menu_shell_insert(_SELF(self), RVAL2WIDGET(child), + NUM2INT(pos)); + G_CHILD_ADD(self, child); + return self; +} + +static VALUE +rg_deactivate(VALUE self) +{ + gtk_menu_shell_deactivate(_SELF(self)); + return self; +} + +static VALUE +rg_select_item(VALUE self, VALUE menu_item) +{ + gtk_menu_shell_select_item(_SELF(self), RVAL2WIDGET(menu_item)); + return self; +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_select_first(VALUE self, VALUE search_sensitive) +{ + gtk_menu_shell_select_first(_SELF(self), RVAL2CBOOL(search_sensitive)); + return self; +} +#endif + +static VALUE +rg_deselect(VALUE self) +{ + gtk_menu_shell_deselect(_SELF(self)); + return self; +} + +static VALUE +rg_activate_item(VALUE self, VALUE menu_item, VALUE force_deactivate) +{ + gtk_menu_shell_activate_item(_SELF(self), RVAL2WIDGET(menu_item), + RVAL2CBOOL(force_deactivate)); + return self; +} + +void +Init_gtk_menu_shell(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_MENU_SHELL, "MenuShell", mGtk); + + RG_DEF_METHOD(append, 1); + RG_DEF_METHOD(prepend, 1); + RG_DEF_METHOD(insert, 2); + RG_DEF_METHOD(deactivate, 0); + RG_DEF_METHOD(select_item, 1); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(select_first, 1); +#endif + RG_DEF_METHOD(deselect, 0); + RG_DEF_METHOD(activate_item, 2); + /* GtkMenuDirectionType */ + G_DEF_CLASS(GTK_TYPE_MENU_DIRECTION_TYPE, "DirectionType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_MENU_DIRECTION_TYPE, "GTK_MENU_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmenutoolbutton.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmenutoolbutton.c new file mode 100644 index 0000000..28eb10d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmenutoolbutton.c @@ -0,0 +1,79 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,6,0) + +#define RG_TARGET_NAMESPACE cMenuToolButton +#define _SELF(self) (GTK_MENU_TOOL_BUTTON(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + GtkToolItem* item; + + if (argc == 0){ + item = gtk_menu_tool_button_new((GtkWidget*)NULL, (const gchar*)NULL); + } else if (TYPE(argv[0]) == T_SYMBOL || TYPE(argv[0]) == T_STRING){ + VALUE stock_id; + rb_scan_args(argc, argv, "10", &stock_id); + + if (TYPE(stock_id) == T_SYMBOL){ + item = gtk_menu_tool_button_new_from_stock(rb_id2name(SYM2ID(stock_id))); + } else { + item = gtk_menu_tool_button_new_from_stock(RVAL2CSTR(stock_id)); + } + } else { + VALUE icon_widget, label; + rb_scan_args(argc, argv, "11", &icon_widget, &label); + + item = gtk_menu_tool_button_new(GTK_WIDGET(RVAL2GOBJ(icon_widget)), + NIL_P(label) ? (const gchar*)NULL : RVAL2CSTR(label)); + } + + RBGTK_INITIALIZE(self, item); + return Qnil; +} + +static VALUE +rg_set_arrow_tooltip(int argc, VALUE *argv, VALUE self) +{ + VALUE tooltips, tip_text, tip_private; + + rb_scan_args(argc, argv, "12", &tooltips, &tip_text, &tip_private); + gtk_menu_tool_button_set_arrow_tooltip(_SELF(self), GTK_TOOLTIPS(RVAL2GOBJ(self)), + NIL_P(tip_text) ? NULL : RVAL2CSTR(tip_text), + NIL_P(tip_private) ? NULL : RVAL2CSTR(tip_private)); + return self; +} +#endif + +void +Init_gtk_menutoolbutton(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,6,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_MENU_TOOL_BUTTON, "MenuToolButton", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(set_arrow_tooltip, -1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmessagedialog.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmessagedialog.c new file mode 100644 index 0000000..06134fa --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmessagedialog.c @@ -0,0 +1,93 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cMessageDialog +#define _SELF(s) (GTK_MESSAGE_DIALOG(RVAL2GOBJ(s))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE parent, flags, type, buttons, message; + GtkWidget* w; + + rb_scan_args(argc, argv, "41", &parent, &flags, &type, &buttons, &message); + + w = gtk_message_dialog_new(NIL_P(parent) ? NULL : GTK_WINDOW(RVAL2GOBJ(parent)), + RVAL2GFLAGS(flags, GTK_TYPE_DIALOG_FLAGS), + RVAL2GENUM(type, GTK_TYPE_MESSAGE_TYPE), + RVAL2GENUM(buttons, GTK_TYPE_BUTTONS_TYPE), + "%s", + NIL_P(message) ? "": RVAL2CSTR(message)); + RBGTK_INITIALIZE(self, w); + return Qnil; +} + +/* +Don't implement. Use Gtk::MessageDialog#set_markup. +GtkWidget* gtk_message_dialog_new_with_markup + (GtkWindow *parent, + GtkDialogFlags flags, + GtkMessageType type, + GtkButtonsType buttons, + const gchar *message_format, + ...); +*/ +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_set_markup(VALUE self, VALUE str) +{ + gtk_message_dialog_set_markup(_SELF(self), RVAL2CSTR(str)); + return self; +} +#endif + +/* Not needed in Ruby +void gtk_message_dialog_format_secondary_text + (GtkMessageDialog *message_dialog, + const gchar *message_format, + ...); +void gtk_message_dialog_format_secondary_markup + (GtkMessageDialog *message_dialog, + const gchar *message_format, + ...); +*/ + +void +Init_gtk_message_dialog(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_MESSAGE_DIALOG, "MessageDialog", mGtk); + + RG_DEF_METHOD(initialize, -1); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(set_markup, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "markup"); +#endif + + /* GtkMessageType */ + G_DEF_CLASS(GTK_TYPE_MESSAGE_TYPE, "Type", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_MESSAGE_TYPE, "GTK_MESSAGE_"); + + /* GtkButtonsType */ + G_DEF_CLASS(GTK_TYPE_BUTTONS_TYPE, "ButtonsType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_BUTTONS_TYPE, "GTK_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmisc.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmisc.c new file mode 100644 index 0000000..0df7824 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkmisc.c @@ -0,0 +1,70 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cMisc +#define _SELF(s) (GTK_MISC(RVAL2GOBJ(s))) + +static VALUE +rg_set_alignment(VALUE self, VALUE xalign, VALUE yalign) +{ + gtk_misc_set_alignment(_SELF(self), NUM2DBL(xalign), NUM2DBL(yalign)); + return self; +} + +static VALUE +rg_set_padding(VALUE self, VALUE xpad, VALUE ypad) +{ + gtk_misc_set_padding(_SELF(self), NUM2DBL(xpad), NUM2DBL(ypad)); + return self; +} + +static VALUE +rg_alignment(VALUE self) +{ + gfloat xalign, yalign; + gtk_misc_get_alignment(_SELF(self), &xalign, &yalign); + + return rb_ary_new3(2, rb_float_new(xalign), rb_float_new(yalign)); +} + +static VALUE +rg_padding(VALUE self) +{ + gint xpad, ypad; + gtk_misc_get_padding(_SELF(self), &xpad, &ypad); + + return rb_ary_new3(2, INT2NUM(xpad), INT2NUM(ypad)); +} +void +Init_gtk_misc(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_MISC, "Misc", mGtk); + + RG_DEF_METHOD(set_alignment, 2); + RG_DEF_METHOD(set_padding, 2); + RG_DEF_METHOD(alignment, 0); + RG_DEF_METHOD(padding, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtknotebook.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtknotebook.c new file mode 100644 index 0000000..8a1ef16 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtknotebook.c @@ -0,0 +1,421 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cNotebook +#define _SELF(self) GTK_NOTEBOOK(RVAL2GOBJ(self)) +#define RVAL2WIDGET(w) GTK_WIDGET(RVAL2GOBJ(w)) +#define GTK_TYPE_NOTEBOOK_PAGE (gtk_notebookpage_get_type()) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_notebook_new()); + return Qnil; +} + +static VALUE +rg_append_page(int argc, VALUE *argv, VALUE self) +{ + VALUE child, label; + + rb_scan_args(argc, argv, "11", &child, &label); + gtk_notebook_append_page(_SELF(self), + RVAL2WIDGET(child), + NIL_P(label) ? NULL : RVAL2WIDGET(label)); + G_CHILD_ADD(self, child); + + return self; +} + +static VALUE +rg_append_page_menu(int argc, VALUE *argv, VALUE self) +{ + VALUE child, tab_label, menu_label; + + rb_scan_args(argc, argv, "12", &child, &tab_label, &menu_label); + gtk_notebook_append_page_menu(_SELF(self), + RVAL2WIDGET(child), + RVAL2WIDGET(tab_label), + NIL_P(menu_label) ? NULL : + RVAL2WIDGET(menu_label)); + return self; +} + +static VALUE +rg_prepend_page(int argc, VALUE *argv, VALUE self) +{ + VALUE child, label; + + rb_scan_args(argc, argv, "11", &child, &label); + gtk_notebook_prepend_page(_SELF(self), + RVAL2WIDGET(child), + NIL_P(label) ? NULL : RVAL2WIDGET(label)); + return self; +} + +static VALUE +rg_prepend_page_menu(int argc, VALUE *argv, VALUE self) +{ + VALUE child, tab_label, menu_label; + + rb_scan_args(argc, argv, "12", &child, &tab_label, &menu_label); + gtk_notebook_prepend_page_menu(_SELF(self), + RVAL2WIDGET(child), + RVAL2WIDGET(tab_label), + NIL_P(menu_label) ? NULL : + RVAL2WIDGET(menu_label)); + return self; +} + +static VALUE +rg_insert_page(int argc, VALUE *argv, VALUE self) +{ + VALUE pos, child, label; + + rb_scan_args(argc, argv, "21", &pos, &child, &label); + gtk_notebook_insert_page(_SELF(self), + RVAL2WIDGET(child), + NIL_P(label) ? NULL : RVAL2WIDGET(label), + NUM2INT(pos)); + return self; +} + +static VALUE +rg_insert_page_menu(int argc, VALUE *argv, VALUE self) +{ + VALUE pos, child, tab_label, menu_label; + + rb_scan_args(argc, argv, "22", &pos, &child, &tab_label, &menu_label); + gtk_notebook_insert_page_menu(_SELF(self), + RVAL2WIDGET(child), + RVAL2WIDGET(tab_label), + RVAL2WIDGET(menu_label), + NUM2INT(pos)); + return self; +} + +static VALUE +rg_remove_page(VALUE self, VALUE pos) +{ + gtk_notebook_remove_page(_SELF(self), NUM2INT(pos)); + return self; +} + +static VALUE +rg_page_num(VALUE self, VALUE child) +{ + return INT2FIX(gtk_notebook_page_num(_SELF(self), + RVAL2WIDGET(child))); +} + +static VALUE +rg_next_page(VALUE self) +{ + gtk_notebook_next_page(_SELF(self)); + return self; +} + +static VALUE +rg_prev_page(VALUE self) +{ + gtk_notebook_prev_page(_SELF(self)); + return self; +} + +static VALUE +rg_reorder_child(VALUE self, VALUE child, VALUE pos) +{ + gtk_notebook_reorder_child(_SELF(self), RVAL2WIDGET(child), + NUM2INT(pos)); + return self; +} + +static VALUE +rg_get_menu_label(VALUE self, VALUE child) +{ + return GOBJ2RVAL(gtk_notebook_get_menu_label(_SELF(self), + RVAL2WIDGET(child))); +} + +static VALUE +rg_get_nth_page(VALUE self, VALUE page_num) +{ + GtkWidget *page = gtk_notebook_get_nth_page(_SELF(self), + NUM2INT(page_num)); + return page ? GOBJ2RVAL(page) : Qnil; +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_n_pages(VALUE self) +{ + return INT2NUM(gtk_notebook_get_n_pages(_SELF(self))); +} +#endif + +static VALUE +rg_get_tab_label(VALUE self, VALUE child) +{ + return GOBJ2RVAL(gtk_notebook_get_tab_label(_SELF(self), + RVAL2WIDGET(child))); +} + +static VALUE +rg_query_tab_label_packing(VALUE self, VALUE child) +{ + gboolean expand, fill; + GtkPackType pack_type; + VALUE ary; + + gtk_notebook_query_tab_label_packing(_SELF(self), + RVAL2WIDGET(child), + &expand, &fill, &pack_type); + ary = rb_ary_new2(3); + rb_ary_push(ary, CBOOL2RVAL(expand)); + rb_ary_push(ary, CBOOL2RVAL(fill)); + rb_ary_push(ary, GENUM2RVAL(pack_type, GTK_TYPE_PACK_TYPE)); + return ary; +} + +static VALUE +rg_set_menu_label(VALUE self, VALUE child, VALUE label) +{ + gtk_notebook_set_menu_label(_SELF(self), + RVAL2WIDGET(child), + NIL_P(label)?NULL:RVAL2WIDGET(label)); + return self; +} + +static VALUE +rg_set_menu_label_text(VALUE self, VALUE child, VALUE text) +{ + gtk_notebook_set_menu_label_text(_SELF(self), + RVAL2WIDGET(child), + RVAL2CSTR(text)); + return self; +} + +static VALUE +rg_set_tab_label(VALUE self, VALUE child, VALUE label) +{ + gtk_notebook_set_tab_label(_SELF(self), + RVAL2WIDGET(child), + NIL_P(label)?NULL:RVAL2WIDGET(label)); + return self; +} + +static VALUE +rg_set_tab_label_packing(VALUE self, VALUE child, VALUE expand, VALUE fill, VALUE pack_type) +{ + gtk_notebook_set_tab_label_packing(_SELF(self), + RVAL2WIDGET(child), + RVAL2CBOOL(expand), RVAL2CBOOL(fill), + RVAL2GENUM(pack_type, GTK_TYPE_PACK_TYPE)); + return self; +} + +static VALUE +rg_set_tab_label_text(VALUE self, VALUE child, VALUE text) +{ + gtk_notebook_set_tab_label_text(_SELF(self), + RVAL2WIDGET(child), + RVAL2CSTR(text)); + return self; +} + +static VALUE +rg_get_menu_label_text(VALUE self, VALUE child) +{ + return CSTR2RVAL(gtk_notebook_get_menu_label_text(_SELF(self), + RVAL2WIDGET(child))); +} + +static VALUE +rg_get_tab_label_text(VALUE self, VALUE child) +{ + return CSTR2RVAL(gtk_notebook_get_tab_label_text(_SELF(self), + RVAL2WIDGET(child))); +} + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_get_tab_reorderable(VALUE self, VALUE child) +{ + return CBOOL2RVAL(gtk_notebook_get_tab_reorderable(_SELF(self), + GTK_WIDGET(RVAL2GOBJ(child)))); +} +static VALUE +rg_set_tab_reorderable(VALUE self, VALUE child, VALUE reorderable) +{ + gtk_notebook_set_tab_reorderable(_SELF(self), GTK_WIDGET(RVAL2GOBJ(child)), + RVAL2CBOOL(reorderable)); + return self; +} + +static VALUE +rg_get_tab_detachable(VALUE self, VALUE child) +{ + return CBOOL2RVAL(gtk_notebook_get_tab_detachable(_SELF(self), + GTK_WIDGET(RVAL2GOBJ(child)))); +} +static VALUE +rg_set_tab_detachable(VALUE self, VALUE child, VALUE detachable) +{ + gtk_notebook_set_tab_detachable(_SELF(self), GTK_WIDGET(RVAL2GOBJ(child)), + RVAL2CBOOL(detachable)); + return self; +} + +static GtkNotebook* +creation_func(GtkNotebook *source, GtkWidget *page, gint x, gint y, gpointer func) +{ + VALUE ret; + ret = rb_funcall((VALUE)func, id_call, 4, GOBJ2RVAL(source), GOBJ2RVAL(page), + INT2NUM(x), INT2NUM(y)); + return NIL_P(ret) ? (GtkNotebook*)NULL : GTK_NOTEBOOK(RVAL2GOBJ(ret)); +} + +static VALUE +rg_s_set_window_creation_hook(VALUE self) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_notebook_set_window_creation_hook((GtkNotebookWindowCreationFunc)creation_func, + (gpointer)func, (GDestroyNotify)NULL); + return self; +} +#endif + +#if GTK_CHECK_VERSION(2,20,0) +static VALUE +rg_set_action_widget(VALUE self, VALUE widget, VALUE pack_type) +{ + gtk_notebook_set_action_widget(_SELF(self), + RVAL2WIDGET(widget), + RVAL2GENUM(pack_type, GTK_TYPE_PACK_TYPE)); + return self; +} + +static VALUE +rg_get_action_widget(VALUE self, VALUE pack_type) +{ + return GOBJ2RVAL(gtk_notebook_get_action_widget(_SELF(self), + RVAL2GENUM(pack_type, GTK_TYPE_PACK_TYPE))); +} +#endif + +/***********************************************/ +/* + * Gtk::NotebookPage + */ +typedef struct { + VALUE parent; + GtkNotebookPage *page; +} GtkNotebookPageData; + +static GtkNotebookPageData * +notebookpage_copy(const GtkNotebookPage *page) +{ + GtkNotebookPageData *data; + g_return_val_if_fail (page != NULL, NULL); + data = g_new(GtkNotebookPageData, 1); + data->page = (GtkNotebookPage *)page; + return data; +} + +static GType +gtk_notebookpage_get_type(void) +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static ("GtkNotebookPageData", + (GBoxedCopyFunc)notebookpage_copy, + (GBoxedFreeFunc)g_free); + return our_type; +} + +static VALUE +signal_g2r_func(G_GNUC_UNUSED guint num, const GValue *values) +{ + GtkNotebookPageData npp; + npp.parent = GVAL2RVAL(&values[0]); + npp.page = (GtkNotebookPage*)g_value_get_pointer(&values[1]); + return rb_ary_new3(3, GVAL2RVAL(&values[0]), BOXED2RVAL(&npp, GTK_TYPE_NOTEBOOK_PAGE), + GVAL2RVAL(&values[2])); +} + +/*****************************************/ + +void +Init_gtk_notebook(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_NOTEBOOK, "Notebook", mGtk); + G_DEF_CLASS(GTK_TYPE_NOTEBOOK_PAGE, "NotebookPage", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(append_page, -1); + RG_DEF_METHOD(append_page_menu, -1); + RG_DEF_METHOD(prepend_page, -1); + RG_DEF_METHOD(prepend_page_menu, -1); + RG_DEF_METHOD(insert_page, -1); + RG_DEF_METHOD(insert_page_menu, -1); + RG_DEF_METHOD(remove_page, 1); + RG_DEF_METHOD(page_num, 1); + RG_DEF_METHOD(next_page, 0); + RG_DEF_METHOD(prev_page, 0); + RG_DEF_METHOD(reorder_child, 2); + RG_DEF_METHOD(get_menu_label, 1); + RG_DEF_METHOD(get_nth_page, 1); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(n_pages, 0); +#endif + RG_DEF_METHOD(get_tab_label, 1); + RG_DEF_METHOD(query_tab_label_packing, 1); + RG_DEF_METHOD(set_menu_label, 2); + RG_DEF_METHOD(set_menu_label_text, 2); + RG_DEF_METHOD(set_tab_label, 2); + RG_DEF_METHOD(set_tab_label_packing, 4); + RG_DEF_METHOD(set_tab_label_text, 2); + RG_DEF_METHOD(get_menu_label_text, 1); + RG_DEF_METHOD(get_tab_label_text, 1); + +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD(get_tab_reorderable, 1); + RG_DEF_METHOD(set_tab_reorderable, 2); + RG_DEF_METHOD(get_tab_detachable, 1); + RG_DEF_METHOD(set_tab_detachable, 2); + RG_DEF_SMETHOD(set_window_creation_hook, 0); +#endif +#if GTK_CHECK_VERSION(2,20,0) + RG_DEF_METHOD(set_action_widget, 2); + RG_DEF_METHOD(get_action_widget, 1); +#endif + /* GtkNotebookTab */ + rb_define_const(RG_TARGET_NAMESPACE, "TAB_FIRST", GTK_NOTEBOOK_TAB_FIRST); + rb_define_const(RG_TARGET_NAMESPACE, "TAB_LAST", GTK_NOTEBOOK_TAB_LAST); + + G_DEF_SIGNAL_FUNC(RG_TARGET_NAMESPACE, "switch_page", (GValToRValSignalFunc)signal_g2r_func); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkobject.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkobject.c new file mode 100644 index 0000000..4ef0e08 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkobject.c @@ -0,0 +1,144 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cObject + +/* +We shouldn't implement it. +void gtk_object_sink (GtkObject *object); +#define GTK_OBJECT_FLOATING (obj) + +gtk_object_new is deprecated. Use g_object_new instead. +GtkObject* gtk_object_new (GtkType type, + const gchar *first_property_name, + ...); +*/ + +static VALUE +rg_type_name(VALUE self) +{ + return CSTR2RVAL(GTK_OBJECT_TYPE_NAME(RVAL2GOBJ(self))); +} + +static VALUE +rg_destroy(VALUE self) +{ + gtk_object_destroy(GTK_OBJECT(RVAL2GOBJ(self))); + return Qnil; +} + +static VALUE +rg_flags(VALUE self) +{ + /* _GtkObject.flags is int32 */ + return(INT2FIX(GTK_OBJECT_FLAGS(RVAL2GOBJ(self)))); +} + +static VALUE +rg_set_flags(VALUE self, VALUE flags) +{ + GTK_OBJECT_SET_FLAGS(RVAL2GOBJ(self), NUM2INT(flags)); + return self; +} + +static VALUE +rg_unset_flags(VALUE self, VALUE flags) +{ + GTK_OBJECT_UNSET_FLAGS(RVAL2GOBJ(self), NUM2INT(flags)); + return self; +} + +/* Move from Bindings */ +static VALUE +rg_bindings_activate(VALUE self, VALUE keyval, VALUE modifiers) +{ + return CBOOL2RVAL(gtk_bindings_activate(GTK_OBJECT(RVAL2GOBJ(self)), + NUM2UINT(keyval), + NUM2UINT(modifiers))); +} + +/* Move from Bindings */ +static VALUE +rg_s_binding_set(VALUE self) +{ + GType gtype; + gpointer gclass; + GtkBindingSet* binding_set; + + Check_Type(self, T_CLASS); + + gtype = CLASS2GTYPE(self); + + if (!G_TYPE_IS_CLASSED(gtype)) { + rb_raise(rb_eTypeError, "%s is not a classed GType", + rb_class2name(self)); + } + gclass = g_type_class_ref(gtype); + if (!gclass) { + rb_raise(rb_eRuntimeError, "couldn't get class reference"); + } + if (!GTK_IS_OBJECT_CLASS(gclass)) { + g_type_class_unref(gclass); + rb_raise(rb_eTypeError, "%s is not a Gtk Object class", + rb_class2name(self)); + } + + binding_set = gtk_binding_set_by_class(gclass); + if (!binding_set) { + g_type_class_unref(gclass); + rb_raise(rb_eRuntimeError, "couldn't get BindingSet from %s", + rb_class2name(self)); + } + g_type_class_unref(gclass); + + return BOXED2RVAL(binding_set, GTK_TYPE_BINDING_SET); +} + +void +Init_gtk_object(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_OBJECT, "Object", mGtk); + + RG_DEF_SMETHOD(binding_set, 0); + + RG_DEF_METHOD(type_name, 0); + RG_DEF_METHOD(flags, 0); + RG_DEF_METHOD(set_flags, 1); + RG_DEF_METHOD(unset_flags, 1); + RG_DEF_METHOD(destroy, 0); + RG_DEF_METHOD(bindings_activate, 2); + + /* GtkObjectFlags */ + G_DEF_CLASS(GTK_TYPE_OBJECT_FLAGS, "Flags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_OBJECT_FLAGS, "GTK_"); + + /* undef deprecated properties */ + rb_undef_method(RG_TARGET_NAMESPACE, "user_data"); + rb_undef_method(RG_TARGET_NAMESPACE, "user_data="); + rb_undef_method(RG_TARGET_NAMESPACE, "set_user_data"); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkoptionmenu.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkoptionmenu.c new file mode 100644 index 0000000..149394e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkoptionmenu.c @@ -0,0 +1,72 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#ifndef GTK_DISABLE_DEPRECATED /* Since 2.4 */ + +#define RG_TARGET_NAMESPACE cOptionMenu + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_option_menu_new()); + return Qnil; +} + +static VALUE +rg_remove_menu(VALUE self) +{ + gtk_option_menu_remove_menu(GTK_OPTION_MENU(RVAL2GOBJ(self))); + return self; +} + +static VALUE +rg_set_history(VALUE self, VALUE index) +{ + gtk_option_menu_set_history(GTK_OPTION_MENU(RVAL2GOBJ(self)), NUM2INT(index)); + return self; +} + +static VALUE +rg_history(VALUE self) +{ + return INT2NUM(gtk_option_menu_get_history(GTK_OPTION_MENU(RVAL2GOBJ(self)))); +} + +#endif + +void +Init_gtk_option_menu(VALUE mGtk) +{ +#ifndef GTK_DISABLE_DEPRECATED /* Since 2.4 */ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_OPTION_MENU, "OptionMenu", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(remove_menu, 0); + RG_DEF_METHOD(set_history, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "history"); + RG_DEF_METHOD(history, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkpagesetup.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkpagesetup.c new file mode 100644 index 0000000..f3b89f4 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkpagesetup.c @@ -0,0 +1,206 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +#define RG_TARGET_NAMESPACE cPageSetup +#define _SELF(s) (GTK_PAGE_SETUP(RVAL2GOBJ(s))) + +#define RVAL2SIZE(o) (RVAL2BOXED(o, GTK_TYPE_PAPER_SIZE)) +#define RVAL2UNIT(o) (RVAL2GENUM(o, GTK_TYPE_UNIT)) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, gtk_page_setup_new()); + return Qnil; +} + +static VALUE +rg_dup(VALUE self) +{ + return GOBJ2RVALU(gtk_page_setup_copy(_SELF(self))); +} + +static VALUE +rg_orientation(VALUE self) +{ + return GENUM2RVAL(gtk_page_setup_get_orientation(_SELF(self)), + GTK_TYPE_PAGE_ORIENTATION); +} + +static VALUE +rg_set_orientation(VALUE self, VALUE orientation) +{ + gtk_page_setup_set_orientation(_SELF(self), + RVAL2GENUM(orientation, GTK_TYPE_PAGE_ORIENTATION)); + return self; +} + +static VALUE +rg_paper_size(VALUE self) +{ + return BOXED2RVAL(gtk_page_setup_get_paper_size(_SELF(self)), GTK_TYPE_PAPER_SIZE); +} + +static VALUE +rg_set_paper_size(VALUE self, VALUE paper_size) +{ + gtk_page_setup_set_paper_size(_SELF(self), RVAL2SIZE(paper_size)); + return self; +} + +static VALUE +rg_get_top_margin(VALUE self, VALUE unit) +{ + return rb_float_new(gtk_page_setup_get_top_margin(_SELF(self), + RVAL2UNIT(unit))); +} + +static VALUE +rg_set_top_margin(VALUE self, VALUE margin, VALUE unit) +{ + gtk_page_setup_set_top_margin(_SELF(self), NUM2DBL(margin), + RVAL2UNIT(unit)); + return self; +} + +static VALUE +rg_get_bottom_margin(VALUE self, VALUE unit) +{ + return rb_float_new(gtk_page_setup_get_bottom_margin(_SELF(self), + RVAL2UNIT(unit))); +} + +static VALUE +rg_set_bottom_margin(VALUE self, VALUE margin, VALUE unit) +{ + gtk_page_setup_set_bottom_margin(_SELF(self), NUM2DBL(margin), + RVAL2UNIT(unit)); + return self; +} + +static VALUE +rg_get_left_margin(VALUE self, VALUE unit) +{ + return rb_float_new(gtk_page_setup_get_left_margin(_SELF(self), + RVAL2UNIT(unit))); +} + +static VALUE +rg_set_left_margin(VALUE self, VALUE margin, VALUE unit) +{ + gtk_page_setup_set_left_margin(_SELF(self), NUM2DBL(margin), + RVAL2UNIT(unit)); + return self; +} + +static VALUE +rg_get_right_margin(VALUE self, VALUE unit) +{ + return rb_float_new(gtk_page_setup_get_right_margin(_SELF(self), + RVAL2UNIT(unit))); +} + +static VALUE +rg_set_right_margin(VALUE self, VALUE margin, VALUE unit) +{ + gtk_page_setup_set_right_margin(_SELF(self), NUM2DBL(margin), + RVAL2UNIT(unit)); + return self; +} + +static VALUE +rg_set_paper_size_and_default_margins(VALUE self, VALUE size) +{ + gtk_page_setup_set_paper_size_and_default_margins(_SELF(self), + RVAL2SIZE(size)); + return self; +} + +/* These take orientation, but not margins into consideration */ +static VALUE +rg_get_paper_width(VALUE self, VALUE unit) +{ + return rb_float_new(gtk_page_setup_get_paper_width(_SELF(self), + RVAL2UNIT(unit))); +} + +static VALUE +rg_get_paper_height(VALUE self, VALUE unit) +{ + return rb_float_new(gtk_page_setup_get_paper_height(_SELF(self), + RVAL2UNIT(unit))); +} + +/* These take orientation, and margins into consideration */ +static VALUE +rg_get_page_width(VALUE self, VALUE unit) +{ + return rb_float_new(gtk_page_setup_get_page_width(_SELF(self), + RVAL2UNIT(unit))); +} + +static VALUE +rg_get_page_height(VALUE self, VALUE unit) +{ + return rb_float_new(gtk_page_setup_get_page_height(_SELF(self), + RVAL2UNIT(unit))); +} +#endif + +void +Init_gtk_page_setup(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_PAGE_SETUP, "PageSetup", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(dup, 0); + + RG_DEF_METHOD(orientation, 0); + RG_DEF_METHOD(set_orientation, 1); + RG_DEF_METHOD(paper_size, 0); + RG_DEF_METHOD(set_paper_size, 1); + RG_DEF_METHOD(get_top_margin, 1); + RG_DEF_METHOD(set_top_margin, 2); + RG_DEF_METHOD(get_bottom_margin, 1); + RG_DEF_METHOD(set_bottom_margin, 2); + RG_DEF_METHOD(get_left_margin, 1); + RG_DEF_METHOD(set_left_margin, 2); + RG_DEF_METHOD(get_right_margin, 1); + RG_DEF_METHOD(set_right_margin, 2); + + RG_DEF_METHOD(set_paper_size_and_default_margins, 1); + + /* These take orientation, but not margins into consideration */ + RG_DEF_METHOD(get_paper_width, 1); + RG_DEF_METHOD(get_paper_height, 1); + + /* These take orientation, and margins into consideration */ + RG_DEF_METHOD(get_page_width, 1); + RG_DEF_METHOD(get_page_height, 1); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkpagesetupunixdialog.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkpagesetupunixdialog.c new file mode 100644 index 0000000..132aa95 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkpagesetupunixdialog.c @@ -0,0 +1,87 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#ifdef HAVE_GTK_UNIX_PRINT +#include <gtk/gtkpagesetupunixdialog.h> + +#define RG_TARGET_NAMESPACE cPageSetupUnixDialog +#define _SELF(s) (GTK_PAGE_SETUP_UNIX_DIALOG(RVAL2GOBJ(s))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + GtkWidget *dialog; + VALUE title, parent; + + rb_scan_args(argc, argv, "02", &title, &parent); + dialog = gtk_page_setup_unix_dialog_new(RVAL2CSTR_ACCEPT_NIL(title), RVAL2GOBJ(parent)); + + RBGTK_INITIALIZE(self, dialog); + return Qnil; +} + +static VALUE +rg_set_page_setup(VALUE self, VALUE page_setup) +{ + gtk_page_setup_unix_dialog_set_page_setup(_SELF(self), + RVAL2GOBJ(page_setup)); + return self; +} + +static VALUE +rg_page_setup(VALUE self) +{ + return GOBJ2RVAL(gtk_page_setup_unix_dialog_get_page_setup(_SELF(self))); +} + +static VALUE +rg_set_print_settings(VALUE self, VALUE print_settings) +{ + gtk_page_setup_unix_dialog_set_print_settings(_SELF(self), + RVAL2GOBJ(print_settings)); + return Qnil; +} + +static VALUE +rg_print_settings(VALUE self) +{ + return GOBJ2RVAL(gtk_page_setup_unix_dialog_get_print_settings(_SELF(self))); +} +#endif + +void +Init_gtk_page_setup_unix_dialog(VALUE mGtk) +{ +#ifdef HAVE_GTK_UNIX_PRINT + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_PAGE_SETUP_UNIX_DIALOG, + "PageSetupUnixDialog", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(set_page_setup, 1); + RG_DEF_METHOD(page_setup, 0); + RG_DEF_METHOD(set_print_settings, 1); + RG_DEF_METHOD(print_settings, 0); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkpaned.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkpaned.c new file mode 100644 index 0000000..32b1fc6 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkpaned.c @@ -0,0 +1,114 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cPaned +#define _SELF(self) (GTK_PANED(RVAL2GOBJ(self))) +#define RVAL2WIDGET(w) (GTK_WIDGET(RVAL2GOBJ(w))) + +static VALUE +rg_add1(VALUE self, VALUE child) +{ + gtk_paned_add1(_SELF(self), RVAL2WIDGET(child)); + return self; +} + +static VALUE +rg_add2(VALUE self, VALUE child) +{ + gtk_paned_add2(_SELF(self), RVAL2WIDGET(child)); + return self; +} + +static VALUE +rg_pack1(VALUE self, VALUE child, VALUE resize, VALUE shrink) +{ + gtk_paned_pack1(_SELF(self), RVAL2WIDGET(child), + RVAL2CBOOL(resize), RVAL2CBOOL(shrink)); + return self; +} + +static VALUE +rg_pack2(VALUE self, VALUE child, VALUE resize, VALUE shrink) +{ + gtk_paned_pack2(_SELF(self), RVAL2WIDGET(child), + RVAL2CBOOL(resize), RVAL2CBOOL(shrink)); + return self; +} + +static VALUE +rg_child1(VALUE self) +{ + GtkWidget *child = _SELF(self)->child1; + return (child == NULL) ? Qnil : GOBJ2RVAL(child); +} + +static VALUE +rg_child2(VALUE self) +{ + GtkWidget *child = _SELF(self)->child2; + return (child == NULL) ? Qnil : GOBJ2RVAL(child); +} + +static VALUE +rg_child1_resize_p(VALUE self) +{ + return CBOOL2RVAL(_SELF(self)->child1_resize); +} + +static VALUE +rg_child1_shrink_p(VALUE self) +{ + return CBOOL2RVAL(_SELF(self)->child1_shrink); +} + +static VALUE +rg_child2_resize_p(VALUE self) +{ + return CBOOL2RVAL(_SELF(self)->child2_resize); +} + +static VALUE +rg_child2_shrink_p(VALUE self) +{ + return CBOOL2RVAL(_SELF(self)->child2_shrink); +} + +void +Init_gtk_paned(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_PANED, "Paned", mGtk); + + RG_DEF_METHOD(add1, 1); + RG_DEF_METHOD(add2, 1); + RG_DEF_METHOD(pack1, 3); + RG_DEF_METHOD(pack2, 3); + RG_DEF_METHOD(child1, 0); + RG_DEF_METHOD(child2, 0); + RG_DEF_METHOD_P(child1_resize, 0); + RG_DEF_METHOD_P(child1_shrink, 0); + RG_DEF_METHOD_P(child2_resize, 0); + RG_DEF_METHOD_P(child2_shrink, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkpapersize.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkpapersize.c new file mode 100644 index 0000000..69bb0f5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkpapersize.c @@ -0,0 +1,192 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +#define RG_TARGET_NAMESPACE cPaperSize +#define _SELF(s) (RVAL2BOXED(s, GTK_TYPE_PAPER_SIZE)) +#define SIZE2RVAL(o) (BOXED2RVAL(o, GTK_TYPE_PAPER_SIZE)) + +#define RVAL2UNIT(o) (RVAL2GENUM(o, GTK_TYPE_UNIT)) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + GtkPaperSize *size; + + if (argc <= 1) { + VALUE name; + rb_scan_args(argc, argv, "01", &name); + size = gtk_paper_size_new(RVAL2CSTR_ACCEPT_NIL(name)); + } else if (argc == 4) { + size = gtk_paper_size_new_from_ppd(RVAL2CSTR(argv[0]), + RVAL2CSTR(argv[1]), + NUM2DBL(argv[2]), + NUM2DBL(argv[3])); + } else if (argc == 5) { + size = gtk_paper_size_new_custom(RVAL2CSTR(argv[0]), + RVAL2CSTR(argv[1]), + NUM2DBL(argv[2]), + NUM2DBL(argv[3]), + RVAL2UNIT(argv[4])); + } else { + rb_raise(rb_eArgError, + "wrong number of arguments (%d for 0, 1, 4 or 5)", argc); + } + + G_INITIALIZE(self, size); + return Qnil; +} + +static VALUE +rg_operator_equal(VALUE self, VALUE other) +{ + return CBOOL2RVAL(RVAL2CBOOL(rb_equal(rb_obj_class(self), rb_obj_class(other))) && + gtk_paper_size_is_equal(_SELF(self), _SELF(other))); +} + +/* The width is always the shortest side, measure in mm */ +static VALUE +rg_name(VALUE self) +{ + return CSTR2RVAL(gtk_paper_size_get_name(_SELF(self))); +} + +static VALUE +rg_display_name(VALUE self) +{ + return CSTR2RVAL(gtk_paper_size_get_display_name(_SELF(self))); +} + +static VALUE +rg_ppd_name(VALUE self) +{ + return CSTR2RVAL(gtk_paper_size_get_ppd_name(_SELF(self))); +} + +static VALUE +rg_get_width(VALUE self, VALUE unit) +{ + return rb_float_new(gtk_paper_size_get_width(_SELF(self), RVAL2UNIT(unit))); +} + +static VALUE +rg_get_height(VALUE self, VALUE unit) +{ + return rb_float_new(gtk_paper_size_get_height(_SELF(self), RVAL2UNIT(unit))); +} + +static VALUE +rg_custom_p(VALUE self) +{ + return CBOOL2RVAL(gtk_paper_size_is_custom(_SELF(self))); +} + +/* Only for custom sizes: */ +static VALUE +rg_set_size(VALUE self, VALUE width, VALUE height, VALUE unit) +{ + gtk_paper_size_set_size(_SELF(self), NUM2DBL(width), NUM2DBL(height), + RVAL2UNIT(unit)); + return self; +} + +static VALUE +rg_get_default_top_margin(VALUE self, VALUE unit) +{ + return rb_float_new(gtk_paper_size_get_default_top_margin(_SELF(self), + RVAL2UNIT(unit))); +} + +static VALUE +rg_get_default_bottom_margin(VALUE self, VALUE unit) +{ + return rb_float_new(gtk_paper_size_get_default_bottom_margin(_SELF(self), + RVAL2UNIT(unit))); +} + +static VALUE +rg_get_default_left_margin(VALUE self, VALUE unit) +{ + return rb_float_new(gtk_paper_size_get_default_left_margin(_SELF(self), + RVAL2UNIT(unit))); +} + +static VALUE +rg_get_default_right_margin(VALUE self, VALUE unit) +{ + return rb_float_new(gtk_paper_size_get_default_right_margin(_SELF(self), + RVAL2UNIT(unit))); +} + +static VALUE +rg_s_default(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(gtk_paper_size_get_default()); +} +#endif + +void +Init_gtk_paper_size(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_PAPER_SIZE, "PaperSize", mGtk); + + RG_DEF_SMETHOD(default, 0); + + rb_define_const(RG_TARGET_NAMESPACE, "A3", CSTR2RVAL(GTK_PAPER_NAME_A3)); + rb_define_const(RG_TARGET_NAMESPACE, "A4", CSTR2RVAL(GTK_PAPER_NAME_A4)); + rb_define_const(RG_TARGET_NAMESPACE, "A5", CSTR2RVAL(GTK_PAPER_NAME_A5)); + rb_define_const(RG_TARGET_NAMESPACE, "B5", CSTR2RVAL(GTK_PAPER_NAME_B5)); + rb_define_const(RG_TARGET_NAMESPACE, "LETTER", CSTR2RVAL(GTK_PAPER_NAME_LETTER)); + rb_define_const(RG_TARGET_NAMESPACE, "EXECUTIVE", + CSTR2RVAL(GTK_PAPER_NAME_EXECUTIVE)); + rb_define_const(RG_TARGET_NAMESPACE, "LEGAL", CSTR2RVAL(GTK_PAPER_NAME_LEGAL)); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD_OPERATOR("==", equal, 1); + + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(display_name, 0); + RG_DEF_METHOD(ppd_name, 0); + + RG_DEF_METHOD(get_width, 1); + RG_DEF_METHOD(get_height, 1); + + RG_DEF_METHOD_P(custom, 0); + + RG_DEF_METHOD(set_size, 3); + + RG_DEF_METHOD(get_default_top_margin, 1); + RG_DEF_METHOD(get_default_bottom_margin, 1); + RG_DEF_METHOD(get_default_left_margin, 1); + RG_DEF_METHOD(get_default_right_margin, 1); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + + /* GtkUnit */ + G_DEF_CLASS(GTK_TYPE_UNIT, "Unit", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_UNIT, "GTK_"); + +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkplug.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkplug.c new file mode 100644 index 0000000..46cff23 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkplug.c @@ -0,0 +1,91 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 2002 Neil Conway + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#ifdef HAVE_GTK_PLUG_GET_TYPE + +#define RG_TARGET_NAMESPACE cPlug + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE socket_id; + GdkNativeWindow id; + + if (rb_scan_args(argc, argv, "01", &socket_id) == 0) + id = 0; + else { +#ifdef GDK_NATIVE_WINDOW_POINTER + id = GUINT_TO_POINTER(NUM2ULONG(socket_id)); +#else + id = NUM2UINT(socket_id); +#endif + } + + RBGTK_INITIALIZE(self, gtk_plug_new(id)); + return Qnil; +} + +/* +GtkWidget* gtk_plug_new_for_display (GdkDisplay *display, +GdkNativeWindow socket_id); +void gtk_plug_construct_for_display (GtkPlug *plug, +GdkDisplay *display, + GdkNativeWindow socket_id); +*/ + +static VALUE +rg_construct(VALUE self, VALUE socket_id) +{ +#ifdef GDK_NATIVE_WINDOW_POINTER + gtk_plug_construct(GTK_PLUG(RVAL2GOBJ(self)), GUINT_TO_POINTER(NUM2ULONG(socket_id))); +#else + gtk_plug_construct(GTK_PLUG(RVAL2GOBJ(self)), (guint32)NUM2UINT(socket_id)); +#endif + return self; +} + +static VALUE +rg_id(VALUE self) +{ + GdkNativeWindow id = gtk_plug_get_id(GTK_PLUG(RVAL2GOBJ(self))); +#ifdef GDK_NATIVE_WINDOW_POINTER + return UINT2NUM(GPOINTER_TO_UINT(id)); +#else + return UINT2NUM(id); +#endif +} + +#endif /* HAVE_GTK_PLUG_GET_TYPE */ + +void +Init_gtk_plug(VALUE mGtk) +{ +#ifdef HAVE_GTK_PLUG_GET_TYPE + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_PLUG, "Plug", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(construct, 1); + RG_DEF_METHOD(id, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprintcontext.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprintcontext.c new file mode 100644 index 0000000..1df0c17 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprintcontext.c @@ -0,0 +1,132 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +#define RG_TARGET_NAMESPACE cPrintContext +#define _SELF(s) (GTK_PRINT_CONTEXT(RVAL2GOBJ(s))) + +# ifdef HAVE_RB_CAIRO_H +#include <rb_cairo.h> + +/* Rendering */ +static VALUE +rg_cairo_context(VALUE self) +{ + return CRCONTEXT2RVAL(gtk_print_context_get_cairo_context(_SELF(self))); +} +# endif + +static VALUE +rg_page_setup(VALUE self) +{ + return GOBJ2RVAL(gtk_print_context_get_page_setup(_SELF(self))); +} + +static VALUE +rg_width(VALUE self) +{ + return rb_float_new(gtk_print_context_get_width(_SELF(self))); +} + +static VALUE +rg_height(VALUE self) +{ + return rb_float_new(gtk_print_context_get_height(_SELF(self))); +} + +static VALUE +rg_dpi_x(VALUE self) +{ + return rb_float_new(gtk_print_context_get_dpi_x(_SELF(self))); +} + +static VALUE +rg_dpi_y(VALUE self) +{ + return rb_float_new(gtk_print_context_get_dpi_y(_SELF(self))); +} + +/* Fonts */ +static VALUE +rg_pango_fontmap(VALUE self) +{ + return GOBJ2RVAL(gtk_print_context_get_pango_fontmap(_SELF(self))); +} + +static VALUE +rg_create_pango_context(VALUE self) +{ + return GOBJ2RVALU(gtk_print_context_create_pango_context(_SELF(self))); +} + +static VALUE +rg_create_pango_layout(VALUE self) +{ + return GOBJ2RVALU(gtk_print_context_create_pango_layout(_SELF(self))); +} + +/* Needed for preview implementations */ +# ifdef HAVE_RB_CAIRO_H +static VALUE +rg_set_cairo_context(VALUE self, VALUE cr, VALUE dpi_x, VALUE dpi_y) +{ + gtk_print_context_set_cairo_context(_SELF(self), + RVAL2CRCONTEXT(cr), + NUM2DBL(dpi_x), + NUM2DBL(dpi_y)); + return self; +} +# endif +#endif + +void +Init_gtk_print_context(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_PRINT_CONTEXT, + "PrintContext", mGtk); + + /* Rendering */ +# ifdef HAVE_RB_CAIRO_H + RG_DEF_METHOD(cairo_context, 0); +# endif + RG_DEF_METHOD(page_setup, 0); + RG_DEF_METHOD(width, 0); + RG_DEF_METHOD(height, 0); + RG_DEF_METHOD(dpi_x, 0); + RG_DEF_METHOD(dpi_y, 0); + + /* Fonts */ + RG_DEF_METHOD(pango_fontmap, 0); + RG_DEF_METHOD(create_pango_context, 0); + RG_DEF_METHOD(create_pango_layout, 0); + + /* Needed for preview implementations */ +# ifdef HAVE_RB_CAIRO_H + RG_DEF_METHOD(set_cairo_context, 3); +# endif + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprinter.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprinter.c new file mode 100644 index 0000000..31ebd8d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprinter.c @@ -0,0 +1,154 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#ifdef HAVE_GTK_UNIX_PRINT +#include <gtk/gtkprinter.h> + +#ifndef GTK_TYPE_PRINT_BACKEND +#define GTK_TYPE_PRINT_BACKEND (gtk_print_backend_get_type ()) +#define GTK_PRINT_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINT_BACKEND, GtkPrintBackend)) +GType gtk_print_backend_get_type (void) G_GNUC_CONST; +#endif + +#define RG_TARGET_NAMESPACE cPrinter +#define _SELF(s) (GTK_PRINTER(RVAL2GOBJ(s))) + +static VALUE +rg_initialize(VALUE self, VALUE name, VALUE backend, VALUE rb_virtual) +{ + GtkPrinter *printer; + + printer = gtk_printer_new(RVAL2CSTR(name), + GTK_PRINT_BACKEND(RVAL2GOBJ(backend)), + RVAL2CBOOL(rb_virtual)); + + G_INITIALIZE(self, printer); + return Qnil; +} + +static VALUE +rg_description(VALUE self) +{ + return CSTR2RVAL(gtk_printer_get_description(_SELF(self))); +} + +static VALUE +rg_active_p(VALUE self) +{ + return CBOOL2RVAL(gtk_printer_is_default(_SELF(self))); +} + +static VALUE +rg_default_p(VALUE self) +{ + return CBOOL2RVAL(gtk_printer_is_default(_SELF(self))); +} + +static VALUE +rg_operator_p_compare(VALUE self, VALUE other) +{ + if (rb_obj_is_kind_of(other, GTYPE2CLASS(GTK_TYPE_PRINTER))){ + return INT2NUM(gtk_printer_compare(_SELF(self), _SELF(other))); + } else { + rb_raise(rb_eTypeError, "%s isn't a kind of Gtk::Printer", rb_class2name(other)); + } +} + +struct callback_arg +{ + VALUE callback; + int argc; + VALUE *argv; +}; + +static VALUE +invoke_callback(VALUE data) +{ + struct callback_arg *arg = (struct callback_arg *)data; + + return rb_funcall2(arg->callback, id_call, arg->argc, arg->argv); +} + +static gboolean +each_printer(GtkPrinter *printer, gpointer data) +{ + VALUE result; + VALUE argv[1]; + struct callback_arg arg; + + argv[0] = GOBJ2RVAL(printer); + + arg.callback = (VALUE)data; + arg.argc = 1; + arg.argv = argv; + + result = G_PROTECT_CALLBACK(invoke_callback, &arg); + return NIL_P(rb_errinfo()) ? TRUE : RVAL2CBOOL(result); +} + +static void +remove_callback_reference(gpointer data) +{ + VALUE callback = (VALUE)data; + G_CHILD_REMOVE(mGtk, callback); +} + +static VALUE +rg_s_each(int argc, VALUE *argv, VALUE self) +{ + VALUE wait, block; + rb_scan_args(argc, argv, "01", &wait); + + block = rb_block_proc(); + G_CHILD_ADD(mGtk, block); + gtk_enumerate_printers(each_printer, (gpointer)block, + remove_callback_reference, RVAL2CBOOL(wait)); + + return self; +} +#endif + +void +Init_gtk_printer(VALUE mGtk) +{ +#ifdef HAVE_GTK_UNIX_PRINT + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_PRINTER, "Printer", mGtk); + rb_include_module(RG_TARGET_NAMESPACE, rb_mComparable); + + G_DEF_CLASS(GTK_TYPE_PRINT_BACKEND, "PrintBackend", mGtk); + + RG_DEF_SMETHOD(each, -1); + + RG_DEF_METHOD(initialize, 3); + RG_DEF_METHOD(description, 0); + RG_DEF_METHOD_P(active, 0); + RG_DEF_METHOD_P(default, 0); + RG_DEF_METHOD_OPERATOR("<=>", p_compare, 1); + + G_DEF_CLASS3("GtkPrintBackendCups", "PrintBackendCups", mGtk); + G_DEF_CLASS3("GtkPrintBackendFile", "PrintBackendFile", mGtk); + G_DEF_CLASS3("GtkPrintBackendLpr", "PrintBackendLpr", mGtk); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprintjob.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprintjob.c new file mode 100644 index 0000000..008fff7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprintjob.c @@ -0,0 +1,149 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#ifdef HAVE_GTK_UNIX_PRINT +#include <gtk/gtkprintjob.h> +#ifndef GTK_TYPE_PRINT_CAPABILITIES +# define GTK_TYPE_PRINT_CAPABILITIES (gtk_print_capabilities_get_type()) +#endif + +#ifdef HAVE_RB_CAIRO_H +# include <rb_cairo.h> +#endif + +#define RG_TARGET_NAMESPACE cPrintJob +#define _SELF(s) (GTK_PRINT_JOB(RVAL2GOBJ(s))) + +static VALUE RG_TARGET_NAMESPACE; + +static VALUE +rg_initialize(VALUE self, VALUE title, VALUE printer, + VALUE settings, VALUE page_setup) +{ + GtkPrintJob *job; + + job = gtk_print_job_new(RVAL2CSTR(title), + GTK_PRINTER(RVAL2GOBJ(printer)), + GTK_PRINT_SETTINGS(RVAL2GOBJ(settings)), + GTK_PAGE_SETUP(RVAL2GOBJ(page_setup))); + + G_INITIALIZE(self, job); + return Qnil; +} + +static VALUE +rg_status(VALUE self) +{ + return GENUM2RVAL(gtk_print_job_get_status(_SELF(self)), GTK_TYPE_PRINT_STATUS); +} + +static VALUE +rg_set_source_file(VALUE self, VALUE filename) +{ + GError *error = NULL; + gboolean result; + + result = gtk_print_job_set_source_file(_SELF(self), RVAL2CSTR(filename), + &error); + + if (!result) + RAISE_GERROR(error); + + return Qnil; +} + +#ifdef HAVE_RB_CAIRO_H +static VALUE +rg_surface(VALUE self) +{ + cairo_surface_t *surface; + GError *error = NULL; + + surface = gtk_print_job_get_surface(_SELF(self), &error); + if (error) + RAISE_GERROR(error); + return CRSURFACE2RVAL(surface); +} +#endif + +struct callback_arg +{ + VALUE callback; + VALUE job; + GError* error; +}; + +static VALUE +invoke_callback(VALUE data) +{ + struct callback_arg *arg = (struct callback_arg *)data; + + if (arg->error) RAISE_GERROR(arg->error); + rb_funcall(arg->callback, id_call, 1, arg->job); + return Qnil; +} +static void +complete_func(GtkPrintJob *job, gpointer data, GError *error) +{ + struct callback_arg arg; + + arg.callback = (VALUE)data; + arg.job = GOBJ2RVAL(job); + arg.error = error; + G_PROTECT_CALLBACK(invoke_callback, &arg); +} + +static void +remove_callback_reference(gpointer data) +{ + G_CHILD_REMOVE(RG_TARGET_NAMESPACE, (VALUE)data); +} + +static VALUE +rg_send(VALUE self) +{ + VALUE block = rb_block_proc(); + G_CHILD_ADD(RG_TARGET_NAMESPACE, block); + gtk_print_job_send(_SELF(self), complete_func, (gpointer)block, + remove_callback_reference); + return self; +} +#endif + +void +Init_gtk_print_job(VALUE mGtk) +{ +#ifdef HAVE_GTK_UNIX_PRINT + RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_PRINT_JOB, "PrintJob", mGtk); + G_DEF_CLASS(GTK_TYPE_PRINT_CAPABILITIES, "PrintCapabilities", mGtk); + + RG_DEF_METHOD(initialize, 4); + RG_DEF_METHOD(status, 0); + RG_DEF_METHOD(set_source_file, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "source_file"); +#ifdef HAVE_RB_CAIRO_H + RG_DEF_METHOD(surface, 0); +#endif + RG_DEF_METHOD(send, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprintoperation.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprintoperation.c new file mode 100644 index 0000000..d0b80c8 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprintoperation.c @@ -0,0 +1,161 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +#define RG_TARGET_NAMESPACE cPrintOperation +#define _SELF(s) (GTK_PRINT_OPERATION(RVAL2GOBJ(s))) + +static VALUE RG_TARGET_NAMESPACE; + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, gtk_print_operation_new()); + return Qnil; +} + +static VALUE +rg_run(int argc, VALUE *argv, VALUE self) +{ + VALUE action, parent, rb_result; + GtkPrintOperationResult result; + GError *error = NULL; + + rb_scan_args(argc, argv, "11", &action, &parent); + + result = gtk_print_operation_run(_SELF(self), + RVAL2GENUM(action, GTK_TYPE_PRINT_OPERATION_ACTION), + RVAL2GOBJ(parent), &error); + + rb_result = GENUM2RVAL(result, GTK_TYPE_PRINT_OPERATION_RESULT); + if (rb_block_given_p()) { + return rb_yield(rb_result); + } else { + if (result == GTK_PRINT_OPERATION_RESULT_ERROR) + RAISE_GERROR(error); + return rb_result; + } +} + +static VALUE +rg_error(VALUE self) +{ + GError *error = NULL; + gtk_print_operation_get_error(_SELF(self), &error); + return error ? rbgerr_gerror2exception(error) : Qnil; +} + +static VALUE +rg_finished_p(VALUE self) +{ + return CBOOL2RVAL(gtk_print_operation_is_finished(_SELF(self))); +} + +static VALUE +rg_cancel(VALUE self) +{ + gtk_print_operation_cancel(_SELF(self)); + return self; +} + +struct callback_arg +{ + VALUE callback; + VALUE page_setup; +}; + +static VALUE +invoke_callback(VALUE arg_) +{ + struct callback_arg *arg = (struct callback_arg *)arg_; + return rb_funcall(arg->callback, id_call, 1, arg->page_setup); +} + +static void +page_setup_done_cb(GtkPageSetup *page_setup, gpointer data) +{ + VALUE callback = (VALUE)data; + struct callback_arg arg; + + G_CHILD_UNSET(RG_TARGET_NAMESPACE, rb_intern("setup_done_cb")); + + arg.callback = callback; + arg.page_setup = GOBJ2RVAL(page_setup); + + G_PROTECT_CALLBACK(invoke_callback, &arg); +} + +static VALUE +rg_s_run_page_setup_dialog(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE parent, page_setup, settings; + rb_scan_args(argc, argv, "03", &parent, &page_setup, &settings); + + if (rb_block_given_p()) { + volatile VALUE func = rb_block_proc(); + G_CHILD_SET(RG_TARGET_NAMESPACE, rb_intern("setup_done_cb"), func); + gtk_print_run_page_setup_dialog_async(RVAL2GOBJ(parent), + RVAL2GOBJ(page_setup), + RVAL2GOBJ(settings), + page_setup_done_cb, + (gpointer)func); + return Qnil; + } else { + return GOBJ2RVALU(gtk_print_run_page_setup_dialog(RVAL2GOBJ(parent), + RVAL2GOBJ(page_setup), + RVAL2GOBJ(settings))); + } +} +#endif + +void +Init_gtk_print_operation(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_PRINT_OPERATION, "PrintOperation", mGtk); + + G_DEF_ERROR(GTK_PRINT_ERROR, "PrintError", mGtk, rb_eRuntimeError, + GTK_TYPE_PRINT_ERROR); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(run, -1); + RG_DEF_METHOD(error, 0); + RG_DEF_METHOD_P(finished, 0); + RG_DEF_METHOD(cancel, 0); + + RG_DEF_SMETHOD(run_page_setup_dialog, -1); + + /* GtkPrintStatus */ + G_DEF_CLASS(GTK_TYPE_PRINT_STATUS, "Status", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_PRINT_STATUS, "GTK_PRINT_"); + + /* GtkPrintOperationAction */ + G_DEF_CLASS(GTK_TYPE_PRINT_OPERATION_ACTION,"Action", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_PRINT_OPERATION_ACTION, "GTK_PRINT_OPERATION_"); + + /* GtkPrintOperationResult */ + G_DEF_CLASS(GTK_TYPE_PRINT_OPERATION_RESULT, "Result", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_PRINT_OPERATION_RESULT, "GTK_PRINT_OPERATION_"); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprintoperationpreview.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprintoperationpreview.c new file mode 100644 index 0000000..248c847 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprintoperationpreview.c @@ -0,0 +1,66 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +#define RG_TARGET_NAMESPACE cPrintOperationPreview +#define _SELF(s) (GTK_PRINT_OPERATION_PREVIEW(RVAL2GOBJ(s))) + +static VALUE +rg_render_page(VALUE self, VALUE page_number) +{ + gtk_print_operation_preview_render_page(_SELF(self), NUM2INT(page_number)); + return self; +} + +static VALUE +rg_end_preview(VALUE self) +{ + gtk_print_operation_preview_end_preview(_SELF(self)); + return self; +} + +static VALUE +rg_selected_p(VALUE self, VALUE page_number) +{ + gboolean selected; + selected = gtk_print_operation_preview_is_selected(_SELF(self), + NUM2INT(page_number)); + return CBOOL2RVAL(selected); +} +#endif + +void +Init_gtk_print_operation_preview(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_PRINT_OPERATION_PREVIEW, + "PrintOperationPreview", mGtk); + + RG_DEF_METHOD(render_page, 1); + RG_DEF_METHOD(end_preview, 0); + RG_DEF_METHOD_P(selected, 1); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprintsettings.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprintsettings.c new file mode 100644 index 0000000..662c17e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprintsettings.c @@ -0,0 +1,847 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +#define RG_TARGET_NAMESPACE cPrintSettings +#define _SELF(s) (GTK_PRINT_SETTINGS(RVAL2GOBJ(s))) + +#define RVAL2UNIT(o) (RVAL2GENUM(o, GTK_TYPE_UNIT)) + +static VALUE s_string, s_bool, s_double, s_length, s_int; + +#if GTK_CHECK_VERSION(2,12,0) +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE arg1, arg2; + GtkPrintSettings* settings = NULL; + GError *error = NULL; + rb_scan_args(argc, argv, "02", &arg1, &arg2); + if (NIL_P(arg1)){ + settings = gtk_print_settings_new(); + } else if (NIL_P(arg2)){ + settings = gtk_print_settings_new_from_file(RVAL2CSTR(arg1), &error); + if (!settings) { + RAISE_GERROR(error); + } + } else { + settings = gtk_print_settings_new_from_key_file((GKeyFile*)RVAL2BOXED(arg1, G_TYPE_KEY_FILE), + RVAL2CSTR(arg2), + &error); + if (!settings) { + RAISE_GERROR(error); + } + } + G_INITIALIZE(self, settings); + return Qnil; +} +#else +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, gtk_print_settings_new()); + return Qnil; +} +#endif + +static VALUE +rg_dup(VALUE self) +{ + return GOBJ2RVALU(gtk_print_settings_copy(_SELF(self))); +} + +static VALUE +rg_has_key_p(VALUE self, VALUE key) +{ + return CBOOL2RVAL(gtk_print_settings_has_key(_SELF(self), RVAL2CSTR(key))); +} + +static VALUE +ps_get(VALUE self, VALUE key) +{ + return CSTR2RVAL(gtk_print_settings_get(_SELF(self), RVAL2CSTR(key))); +} + +static VALUE +ps_set(VALUE self, VALUE key, VALUE value) +{ + gtk_print_settings_set(_SELF(self), RVAL2CSTR(key), RVAL2CSTR_ACCEPT_NIL(value)); + return self; +} + +static VALUE +rg_unset(VALUE self, VALUE key) +{ + gtk_print_settings_unset(_SELF(self), RVAL2CSTR(key)); + return self; +} + +static void +ps_foreach_cb(const gchar *key, const gchar *value, gpointer data) +{ + rb_funcall((VALUE)data, id_call, 2, CSTR2RVAL(key), CSTR2RVAL(value)); +} + +static VALUE +rg_each(VALUE self) +{ + gtk_print_settings_foreach(_SELF(self), ps_foreach_cb, + (gpointer)rb_block_proc()); + return self; +} + +static VALUE +rg_get_bool(VALUE self, VALUE key) +{ + return CBOOL2RVAL(gtk_print_settings_get_bool(_SELF(self), RVAL2CSTR(key))); +} + +static VALUE +ps_set_bool(VALUE self, VALUE key, VALUE value) +{ + gtk_print_settings_set_bool(_SELF(self), RVAL2CSTR(key), RVAL2CBOOL(value)); + return self; +} + +static VALUE +rg_get_double(int argc, VALUE *argv, VALUE self) +{ + VALUE key, default_value; + gdouble value; + + rb_scan_args(argc, argv, "11", &key, &default_value); + if (NIL_P(default_value)) + value = gtk_print_settings_get_double(_SELF(self), RVAL2CSTR(key)); + else + value = gtk_print_settings_get_double_with_default(_SELF(self), + RVAL2CSTR(key), + NUM2DBL(default_value)); + + return rb_float_new(value); +} + +static VALUE +ps_set_double(VALUE self, VALUE key, VALUE value) +{ + gtk_print_settings_set_double(_SELF(self), RVAL2CSTR(key), NUM2DBL(value)); + return self; +} + +static VALUE +rg_get_length(VALUE self, VALUE key, VALUE unit) +{ + return rb_float_new(gtk_print_settings_get_length(_SELF(self), + RVAL2CSTR(key), + RVAL2UNIT(unit))); +} + +static VALUE +ps_set_length(VALUE self, VALUE key, VALUE value, VALUE unit) +{ + gtk_print_settings_set_length(_SELF(self), RVAL2CSTR(key), + NUM2DBL(value), RVAL2UNIT(unit)); + return self; +} + +static VALUE +rg_get_int(int argc, VALUE *argv, VALUE self) +{ + VALUE key, default_value; + gint value; + + rb_scan_args(argc, argv, "11", &key, &default_value); + if (NIL_P(default_value)) + value = gtk_print_settings_get_int(_SELF(self), RVAL2CSTR(key)); + else + value = gtk_print_settings_get_int_with_default(_SELF(self), + RVAL2CSTR(key), + NUM2INT(default_value)); + + return INT2NUM(value); +} + +static VALUE +ps_set_int(VALUE self, VALUE key, VALUE value) +{ + gtk_print_settings_set_int(_SELF(self), RVAL2CSTR(key), NUM2INT(value)); + return self; +} + +static VALUE +rg_get(int argc, VALUE *argv, VALUE self) +{ + VALUE key, type, unit_or_default, result; + + rb_scan_args(argc, argv, "12", &key, &type, &unit_or_default); + + if (NIL_P(type) || (RVAL2CBOOL(rb_equal(type, s_string)))) { + result = ps_get(self, key); + } else if (RVAL2CBOOL(rb_equal(type, s_bool))) { + result = rg_get_bool(self, key); + } else if (RVAL2CBOOL(rb_equal(type, s_double))) { + VALUE double_argv[2]; + double_argv[0] = key; + double_argv[1] = unit_or_default; + result = rg_get_double(2, double_argv, self); + } else if (RVAL2CBOOL(rb_equal(type, s_length))) { + result = rg_get_length(self, key, unit_or_default); + } else if (RVAL2CBOOL(rb_equal(type, s_int))) { + VALUE int_argv[2]; + int_argv[0] = key; + int_argv[1] = unit_or_default; + result = rg_get_int(2, int_argv, self); + } else { + VALUE inspected_type; + inspected_type = rb_inspect(type); + rb_raise(rb_eArgError, + "%s must be nil, :string, :bool, :double, :length or :int", + RVAL2CSTR(inspected_type)); + } + + return result; +} + +static VALUE +rg_set(int argc, VALUE *argv, VALUE self) +{ + VALUE key, value, unit; + + rb_scan_args(argc, argv, "21", &key, &value, &unit); + + switch (TYPE(value)) { + case T_STRING: + ps_set(self, key, value); + break; + case T_TRUE: + case T_FALSE: + ps_set_bool(self, key, value); + break; + case T_FIXNUM: + ps_set_int(self, key, value); + break; + case T_FLOAT: + if (NIL_P(unit)) { + ps_set_double(self, key, value); + } else { + ps_set_length(self, key, value, unit); + } + break; + case T_NIL: + rg_unset(self, key); + break; + default: + { + VALUE inspected_value; + inspected_value = rb_inspect(value); + rb_raise(rb_eArgError, + "%s is invalid value", RVAL2CSTR(inspected_value)); + break; + } + } + + return self; +} + +static VALUE +rg_operator_ps_set_generic_indexer(int argc, VALUE *argv, VALUE self) +{ + if (argc == 3) { + VALUE swapped_argv[3]; + swapped_argv[0] = argv[0]; + swapped_argv[1] = argv[2]; + swapped_argv[2] = argv[1]; + rg_set(argc, swapped_argv, self); + } else if (argc == 2) { + rg_set(argc, argv, self); + } else { + rb_raise(rb_eArgError, + "wrong number of arguments (%d for 2 or 3)", argc); + } + + return argv[2]; +} + +/* Helpers: */ +static VALUE +rg_printer(VALUE self) +{ + return CSTR2RVAL(gtk_print_settings_get_printer(_SELF(self))); +} + +static VALUE +rg_set_printer(VALUE self, VALUE printer) +{ + gtk_print_settings_set_printer(_SELF(self), RVAL2CSTR_ACCEPT_NIL(printer)); + return self; +} + +static VALUE +rg_orientation(VALUE self) +{ + return GENUM2RVAL(gtk_print_settings_get_orientation(_SELF(self)), + GTK_TYPE_PAGE_ORIENTATION); +} + +static VALUE +rg_set_orientation(VALUE self, VALUE orientation) +{ + gtk_print_settings_set_orientation(_SELF(self), + RVAL2GENUM(orientation, GTK_TYPE_PAGE_ORIENTATION)); + return self; +} + +static VALUE +rg_paper_size(VALUE self) +{ + return GOBJ2RVAL(gtk_print_settings_get_paper_size(_SELF(self))); +} + +static VALUE +rg_set_paper_size(VALUE self, VALUE paper_size) +{ + gtk_print_settings_set_paper_size(_SELF(self), + RVAL2BOXED(paper_size, GTK_TYPE_PAPER_SIZE)); + return self; +} + +static VALUE +rg_paper_width(VALUE self, VALUE unit) +{ + return rb_float_new(gtk_print_settings_get_paper_width(_SELF(self), + RVAL2UNIT(unit))); +} + +static VALUE +rg_set_paper_width(VALUE self, VALUE paper_width, VALUE unit) +{ + gtk_print_settings_set_paper_width(_SELF(self), NUM2DBL(paper_width), + RVAL2UNIT(unit)); + return self; +} + +static VALUE +rg_paper_height(VALUE self, VALUE unit) +{ + return rb_float_new(gtk_print_settings_get_paper_height(_SELF(self), + RVAL2UNIT(unit))); +} + +static VALUE +rg_set_paper_height(VALUE self, VALUE paper_height, VALUE unit) +{ + gtk_print_settings_set_paper_height(_SELF(self), NUM2DBL(paper_height), + RVAL2UNIT(unit)); + return self; +} + +static VALUE +rg_use_color_p(VALUE self) +{ + return CBOOL2RVAL(gtk_print_settings_get_use_color(_SELF(self))); +} + +static VALUE +rg_set_use_color(VALUE self, VALUE use_color) +{ + gtk_print_settings_set_use_color(_SELF(self), RVAL2CBOOL(use_color)); + return self; +} + +static VALUE +rg_collate_p(VALUE self) +{ + return CBOOL2RVAL(gtk_print_settings_get_collate(_SELF(self))); +} + +static VALUE +rg_set_collate(VALUE self, VALUE collate) +{ + gtk_print_settings_set_collate(_SELF(self), RVAL2CBOOL(collate)); + return self; +} + +static VALUE +rg_reverse_p(VALUE self) +{ + return CBOOL2RVAL(gtk_print_settings_get_reverse(_SELF(self))); +} + +static VALUE +rg_set_reverse(VALUE self, VALUE reverse) +{ + gtk_print_settings_set_reverse(_SELF(self), RVAL2CBOOL(reverse)); + return self; +} + +static VALUE +rg_duplex(VALUE self) +{ + return GENUM2RVAL(gtk_print_settings_get_duplex(_SELF(self)), + GTK_TYPE_PRINT_DUPLEX); +} + +static VALUE +rg_set_duplex(VALUE self, VALUE duplex) +{ + gtk_print_settings_set_duplex(_SELF(self), + RVAL2GENUM(duplex, GTK_TYPE_PRINT_DUPLEX)); + return self; +} + +static VALUE +rg_quality(VALUE self) +{ + return GENUM2RVAL(gtk_print_settings_get_quality(_SELF(self)), + GTK_TYPE_PRINT_QUALITY); +} + +static VALUE +rg_set_quality(VALUE self, VALUE quality) +{ + gtk_print_settings_set_quality(_SELF(self), + RVAL2GENUM(quality, GTK_TYPE_PRINT_QUALITY)); + return self; +} + +static VALUE +rg_n_copies(VALUE self) +{ + return INT2NUM(gtk_print_settings_get_n_copies(_SELF(self))); +} + +static VALUE +rg_set_n_copies(VALUE self, VALUE n_copies) +{ + gtk_print_settings_set_n_copies(_SELF(self), NUM2INT(n_copies)); + return self; +} + +static VALUE +rg_number_up(VALUE self) +{ + return INT2NUM(gtk_print_settings_get_number_up(_SELF(self))); +} + +static VALUE +rg_set_number_up(VALUE self, VALUE number_up) +{ + gtk_print_settings_set_number_up(_SELF(self), NUM2INT(number_up)); + return self; +} + +static VALUE +rg_resolution(VALUE self) +{ + return INT2NUM(gtk_print_settings_get_resolution(_SELF(self))); +} + +static VALUE +rg_set_resolution(VALUE self, VALUE resolution) +{ + gtk_print_settings_set_resolution(_SELF(self), NUM2INT(resolution)); + return self; +} + +static VALUE +rg_scale(VALUE self) +{ + return rb_float_new(gtk_print_settings_get_scale(_SELF(self))); +} + +static VALUE +rg_set_scale(VALUE self, VALUE scale) +{ + gtk_print_settings_set_scale(_SELF(self), NUM2DBL(scale)); + return self; +} + +static VALUE +rg_print_pages(VALUE self) +{ + return GENUM2RVAL(gtk_print_settings_get_print_pages(_SELF(self)), + GTK_TYPE_PRINT_PAGES); +} + +static VALUE +rg_set_print_pages(VALUE self, VALUE print_pages) +{ + gtk_print_settings_set_print_pages(_SELF(self), RVAL2GENUM(print_pages, GTK_TYPE_PRINT_PAGES)); + return self; +} + +static VALUE +rg_page_ranges(VALUE self) +{ + VALUE rb_ranges; + GtkPageRange *ranges; + int i, num_ranges; + + ranges = gtk_print_settings_get_page_ranges(_SELF(self), &num_ranges); + + rb_ranges = rb_ary_new2(num_ranges); + for (i = 0; i < num_ranges; i++) { + rb_ary_push(rb_ranges, + rb_ary_new3(2, + INT2NUM(ranges[i].start), + INT2NUM(ranges[i].end))); + } + g_free(ranges); + return rb_ranges; +} + +struct rbgtk_rval2gtkpageranges_args { + VALUE ary; + long n; + GtkPageRange *result; +}; + +static VALUE +rbgtk_rval2gtkpageranges_body(VALUE value) +{ + long i; + struct rbgtk_rval2gtkpageranges_args *args = (struct rbgtk_rval2gtkpageranges_args *)value; + + for (i = 0; i < args->n; i++) { + VALUE ary = rb_ary_to_ary(RARRAY_PTR(args->ary)[i]); + + if (RARRAY_LEN(ary) != 2) + rb_raise(rb_eArgError, "range %ld should be array of size 2", i); + + args->result[i].start = NUM2INT(RARRAY_PTR(ary)[0]); + args->result[i].end = NUM2INT(RARRAY_PTR(ary)[1]); + } + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbgtk_rval2gtkpageranges_rescue(VALUE value) +{ + g_free(((struct rbgtk_rval2gtkpageranges_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static GtkPageRange * +rbgtk_rval2gtkpageranges(VALUE value, long *n) +{ + struct rbgtk_rval2gtkpageranges_args args; + + args.ary = rb_ary_to_ary(value); + args.n = RARRAY_LEN(args.ary); + args.result = g_new(GtkPageRange, args.n + 1); + + rb_rescue(rbgtk_rval2gtkpageranges_body, (VALUE)&args, + rbgtk_rval2gtkpageranges_rescue, (VALUE)&args); + + if (n != NULL) + *n = args.n; + + return args.result; +} + +#define RVAL2GTKPAGERANGES(value, n) rbgtk_rval2gtkpageranges(value, n) + +static VALUE +rg_set_page_ranges(VALUE self, VALUE rbpage_ranges) +{ + GtkPrintSettings *settings = _SELF(self); + long n; + GtkPageRange *page_ranges = RVAL2GTKPAGERANGES(rbpage_ranges, &n); + + gtk_print_settings_set_page_ranges(settings, page_ranges, n); + + g_free(page_ranges); + + return self; +} + +static VALUE +rg_page_set(VALUE self) +{ + return GENUM2RVAL(gtk_print_settings_get_page_set(_SELF(self)), + GTK_TYPE_PAGE_SET); +} + +static VALUE +rg_set_page_set(VALUE self, VALUE page_set) +{ + gtk_print_settings_set_page_set(_SELF(self), + RVAL2GENUM(page_set, GTK_TYPE_PAGE_SET)); + return self; +} + +static VALUE +rg_default_source(VALUE self) +{ + return CSTR2RVAL(gtk_print_settings_get_default_source(_SELF(self))); +} + +static VALUE +rg_set_default_source(VALUE self, VALUE default_source) +{ + gtk_print_settings_set_default_source(_SELF(self), + RVAL2CSTR_ACCEPT_NIL(default_source)); + return self; +} + +static VALUE +rg_media_type(VALUE self) +{ + return CSTR2RVAL(gtk_print_settings_get_media_type(_SELF(self))); +} + +static VALUE +rg_set_media_type(VALUE self, VALUE media_type) +{ + gtk_print_settings_set_media_type(_SELF(self), RVAL2CSTR_ACCEPT_NIL(media_type)); + return self; +} + +static VALUE +rg_dither(VALUE self) +{ + return CSTR2RVAL(gtk_print_settings_get_dither(_SELF(self))); +} + +static VALUE +rg_set_dither(VALUE self, VALUE dither) +{ + gtk_print_settings_set_dither(_SELF(self), RVAL2CSTR_ACCEPT_NIL(dither)); + return self; +} + +static VALUE +rg_finishings(VALUE self) +{ + return CSTR2RVAL(gtk_print_settings_get_finishings(_SELF(self))); +} + +static VALUE +rg_set_finishings(VALUE self, VALUE finishings) +{ + gtk_print_settings_set_finishings(_SELF(self), RVAL2CSTR_ACCEPT_NIL(finishings)); + return self; +} + +static VALUE +rg_output_bin(VALUE self) +{ + return CSTR2RVAL(gtk_print_settings_get_output_bin(_SELF(self))); +} + +static VALUE +rg_set_output_bin(VALUE self, VALUE output_bin) +{ + gtk_print_settings_set_output_bin(_SELF(self), RVAL2CSTR_ACCEPT_NIL(output_bin)); + return self; +} +#endif + +#if GTK_CHECK_VERSION(2,12,0) +static VALUE +rg_to_file(VALUE self, VALUE file_name) +{ + GError *error = NULL; + if (!gtk_print_settings_to_file(_SELF(self), RVAL2CSTR(file_name), &error)) { + RAISE_GERROR(error); + } + return self; +} +static VALUE +rg_to_key_file(int argc, VALUE *argv, VALUE self) +{ + VALUE key_file, group_name; + rb_scan_args(argc, argv, "11", &key_file, &group_name); + gtk_print_settings_to_key_file(_SELF(self), + (GKeyFile*)RVAL2BOXED(key_file, G_TYPE_KEY_FILE), + RVAL2CSTR_ACCEPT_NIL(group_name)); + return self; +} +#endif + +void +Init_gtk_print_settings(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + VALUE RG_TARGET_NAMESPACE; + + s_string = ID2SYM(rb_intern("string")); + s_bool = ID2SYM(rb_intern("bool")); + s_double = ID2SYM(rb_intern("double")); + s_length = ID2SYM(rb_intern("length")); + s_int = ID2SYM(rb_intern("int")); + + RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_PRINT_SETTINGS, + "PrintSettings", mGtk); + + rb_include_module(RG_TARGET_NAMESPACE, rb_mEnumerable); + +#if GTK_CHECK_VERSION(2,12,0) + RG_DEF_METHOD(initialize, -1); +#else + RG_DEF_METHOD(initialize, 0); +#endif + RG_DEF_METHOD(dup, 0); + RG_DEF_METHOD_P(has_key, 1); + + RG_DEF_METHOD(get, -1); + RG_DEF_ALIAS("[]", "get"); + RG_DEF_METHOD(get_bool, 1); + RG_DEF_METHOD(get_double, -1); + RG_DEF_METHOD(get_length, 2); + RG_DEF_METHOD(get_int, -1); + + RG_DEF_METHOD(set, -1); + RG_DEF_METHOD_OPERATOR("[]=", ps_set_generic_indexer, -1); + + RG_DEF_METHOD(unset, -1); + RG_DEF_ALIAS("delete", "unset"); + + RG_DEF_METHOD(each, 0); + + rb_define_const(RG_TARGET_NAMESPACE, "PRINTER", + CSTR2RVAL(GTK_PRINT_SETTINGS_PRINTER)); + rb_define_const(RG_TARGET_NAMESPACE, "ORIENTATION", + CSTR2RVAL(GTK_PRINT_SETTINGS_ORIENTATION)); + rb_define_const(RG_TARGET_NAMESPACE, "PAPER_FORMAT", + CSTR2RVAL(GTK_PRINT_SETTINGS_PAPER_FORMAT)); + rb_define_const(RG_TARGET_NAMESPACE, "PAPER_WIDTH", + CSTR2RVAL(GTK_PRINT_SETTINGS_PAPER_WIDTH)); + rb_define_const(RG_TARGET_NAMESPACE, "PAPER_HEIGHT", + CSTR2RVAL(GTK_PRINT_SETTINGS_PAPER_HEIGHT)); + rb_define_const(RG_TARGET_NAMESPACE, "N_COPIES", + CSTR2RVAL(GTK_PRINT_SETTINGS_N_COPIES)); + rb_define_const(RG_TARGET_NAMESPACE, "DEFAULT_SOURCE", + CSTR2RVAL(GTK_PRINT_SETTINGS_DEFAULT_SOURCE)); + rb_define_const(RG_TARGET_NAMESPACE, "QUALITY", + CSTR2RVAL(GTK_PRINT_SETTINGS_QUALITY)); + rb_define_const(RG_TARGET_NAMESPACE, "RESOLUTION", + CSTR2RVAL(GTK_PRINT_SETTINGS_RESOLUTION)); + rb_define_const(RG_TARGET_NAMESPACE, "USE_COLOR", + CSTR2RVAL(GTK_PRINT_SETTINGS_USE_COLOR)); + rb_define_const(RG_TARGET_NAMESPACE, "DUPLEX", + CSTR2RVAL(GTK_PRINT_SETTINGS_DUPLEX)); + rb_define_const(RG_TARGET_NAMESPACE, "COLLATE", + CSTR2RVAL(GTK_PRINT_SETTINGS_COLLATE)); + rb_define_const(RG_TARGET_NAMESPACE, "REVERSE", + CSTR2RVAL(GTK_PRINT_SETTINGS_REVERSE)); + rb_define_const(RG_TARGET_NAMESPACE, "MEDIA_TYPE", + CSTR2RVAL(GTK_PRINT_SETTINGS_MEDIA_TYPE)); + rb_define_const(RG_TARGET_NAMESPACE, "DITHER", + CSTR2RVAL(GTK_PRINT_SETTINGS_DITHER)); + rb_define_const(RG_TARGET_NAMESPACE, "SCALE", + CSTR2RVAL(GTK_PRINT_SETTINGS_SCALE)); + rb_define_const(RG_TARGET_NAMESPACE, "PRINT_PAGES", + CSTR2RVAL(GTK_PRINT_SETTINGS_PRINT_PAGES)); + rb_define_const(RG_TARGET_NAMESPACE, "PAGE_RANGES", + CSTR2RVAL(GTK_PRINT_SETTINGS_PAGE_RANGES)); + rb_define_const(RG_TARGET_NAMESPACE, "PAGE_SET", + CSTR2RVAL(GTK_PRINT_SETTINGS_PAGE_SET)); + rb_define_const(RG_TARGET_NAMESPACE, "FINISHINGS", + CSTR2RVAL(GTK_PRINT_SETTINGS_FINISHINGS)); + rb_define_const(RG_TARGET_NAMESPACE, "NUMBER_UP", + CSTR2RVAL(GTK_PRINT_SETTINGS_NUMBER_UP)); + rb_define_const(RG_TARGET_NAMESPACE, "OUTPUT_BIN", + CSTR2RVAL(GTK_PRINT_SETTINGS_OUTPUT_BIN)); + + rb_define_const(RG_TARGET_NAMESPACE, "OUTPUT_FILE_FORMAT", + CSTR2RVAL(GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT)); + rb_define_const(RG_TARGET_NAMESPACE, "OUTPUT_URI", + CSTR2RVAL(GTK_PRINT_SETTINGS_OUTPUT_URI)); + + rb_define_const(RG_TARGET_NAMESPACE, "WIN32_DRIVER_VERSION", + CSTR2RVAL(GTK_PRINT_SETTINGS_WIN32_DRIVER_VERSION)); + rb_define_const(RG_TARGET_NAMESPACE, "WIN32_DRIVER_EXTRA", + CSTR2RVAL(GTK_PRINT_SETTINGS_WIN32_DRIVER_EXTRA)); + + /* Helpers: */ + RG_DEF_METHOD(printer, 0); + RG_DEF_METHOD(set_printer, 1); + RG_DEF_METHOD(orientation, 0); + RG_DEF_METHOD(set_orientation, 1); + RG_DEF_METHOD(paper_size, 0); + RG_DEF_METHOD(set_paper_size, 1); + RG_DEF_METHOD(paper_width, 1); + RG_DEF_METHOD(set_paper_width, 2); + RG_DEF_METHOD(paper_height, 1); + RG_DEF_METHOD(set_paper_height, 2); + RG_DEF_METHOD_P(use_color, 0); + RG_DEF_METHOD(set_use_color, 1); + RG_DEF_METHOD_P(collate, 0); + RG_DEF_METHOD(set_collate, 1); + RG_DEF_METHOD_P(reverse, 0); + RG_DEF_METHOD(set_reverse, 1); + RG_DEF_METHOD(duplex, 0); + RG_DEF_METHOD(set_duplex, 1); + RG_DEF_METHOD(quality, 0); + RG_DEF_METHOD(set_quality, 1); + RG_DEF_METHOD(n_copies, 0); + RG_DEF_METHOD(set_n_copies, 1); + RG_DEF_METHOD(number_up, 0); + RG_DEF_METHOD(set_number_up, 1); + RG_DEF_METHOD(resolution, 0); + RG_DEF_METHOD(set_resolution, 1); + RG_DEF_METHOD(scale, 0); + RG_DEF_METHOD(set_scale, 1); + RG_DEF_METHOD(print_pages, 0); + RG_DEF_METHOD(set_print_pages, 1); + RG_DEF_METHOD(page_ranges, 0); + RG_DEF_METHOD(set_page_ranges, 1); + RG_DEF_METHOD(page_set, 0); + RG_DEF_METHOD(set_page_set, 1); + RG_DEF_METHOD(default_source, 0); + RG_DEF_METHOD(set_default_source, 1); + RG_DEF_METHOD(media_type, 0); + RG_DEF_METHOD(set_media_type, 1); + RG_DEF_METHOD(dither, 0); + RG_DEF_METHOD(set_dither, 1); + RG_DEF_METHOD(finishings, 0); + RG_DEF_METHOD(set_finishings, 1); + RG_DEF_METHOD(output_bin, 0); + RG_DEF_METHOD(set_output_bin, 1); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + + /* GtkPageOrientation */ + G_DEF_CLASS(GTK_TYPE_PAGE_ORIENTATION, "PageOrientation", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_PAGE_ORIENTATION, "GTK_PAGE_"); + /* GtkPrintDuplex */ + G_DEF_CLASS(GTK_TYPE_PRINT_DUPLEX, "PrintDuplex", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_PRINT_DUPLEX, "GTK_PRINT_"); + /* GtkPrintQuality */ + G_DEF_CLASS(GTK_TYPE_PRINT_QUALITY, "PrintQuality", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_PRINT_QUALITY, "GTK_PRINT_"); + /* GtkPrintPages */ + G_DEF_CLASS(GTK_TYPE_PRINT_PAGES, "PrintPages", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_PRINT_PAGES, "GTK_PRINT_"); + /* GtkPageSet */ + G_DEF_CLASS(GTK_TYPE_PAGE_SET, "PageSet", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_PAGE_SET, "GTK_"); +#endif +#if GTK_CHECK_VERSION(2,12,0) + RG_DEF_METHOD(to_file, 1); + RG_DEF_METHOD(to_key_file, -1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprintunixdialog.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprintunixdialog.c new file mode 100644 index 0000000..7ab6a2a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprintunixdialog.c @@ -0,0 +1,86 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#ifdef HAVE_GTK_UNIX_PRINT +#include <gtk/gtkprintunixdialog.h> + +#define RG_TARGET_NAMESPACE cPrintUnixDialog +#define _SELF(s) (GTK_PRINT_UNIX_DIALOG(RVAL2GOBJ(s))) +#ifndef GTK_TYPE_PRINT_CAPABILITIES +# define GTK_TYPE_PRINT_CAPABILITIES (gtk_print_capabilities_get_type()) +#endif + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + GtkWidget *dialog; + VALUE title, parent; + + rb_scan_args(argc, argv, "02", &title, &parent); + dialog = gtk_print_unix_dialog_new(NIL_P(title) ? NULL : RVAL2CSTR(title), + RVAL2GOBJ(parent)); + + RBGTK_INITIALIZE(self, dialog); + return Qnil; +} + +static VALUE +rg_add_custom_tab(VALUE self, VALUE child, VALUE tab_label) +{ + gtk_print_unix_dialog_add_custom_tab(_SELF(self), + RVAL2GOBJ(child), + RVAL2GOBJ(tab_label)); + return self; +} + +static VALUE +rg_set_manual_capability(VALUE self, VALUE rb_capabilities) +{ + GtkPrintCapabilities capabilities; + + capabilities = RVAL2GFLAGS(rb_capabilities, GTK_TYPE_PRINT_CAPABILITIES); + gtk_print_unix_dialog_set_manual_capabilities(_SELF(self), capabilities); + return self; +} +#endif + +void +Init_gtk_print_unix_dialog(VALUE mGtk) +{ +#ifdef HAVE_GTK_UNIX_PRINT + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_PRINT_UNIX_DIALOG, + "PrintUnixDialog", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(add_custom_tab, 2); + RG_DEF_METHOD(set_manual_capability, 1); + RG_DEF_ALIAS("settings", "print_settings"); + RG_DEF_ALIAS("set_settings", "set_print_settings"); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + + /* GtkPrintCapabilities */ + G_DEF_CLASS(GTK_TYPE_PRINT_CAPABILITIES, "Capabilities", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_PRINT_CAPABILITIES, "GTK_PRINT_"); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprogress.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprogress.c new file mode 100644 index 0000000..2e565e4 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprogress.c @@ -0,0 +1,31 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +void +Init_gtk_progress(VALUE mGtk) +{ + G_DEF_CLASS(GTK_TYPE_PROGRESS, "Progress", mGtk); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprogressbar.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprogressbar.c new file mode 100644 index 0000000..66ebc74 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkprogressbar.c @@ -0,0 +1,71 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cProgressBar + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_progress_bar_new()); + return Qnil; +} + +static VALUE +rg_pulse(VALUE self) +{ + gtk_progress_bar_pulse(GTK_PROGRESS_BAR(RVAL2GOBJ(self))); + return self; +} + +void +Init_gtk_progress_bar(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_PROGRESS_BAR, "ProgressBar", mGtk); + + /* GtkProgressBarOrientation */ + G_DEF_CLASS(GTK_TYPE_PROGRESS_BAR_ORIENTATION, "Orientation", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_PROGRESS_BAR_ORIENTATION, "GTK_PROGRESS_"); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(pulse, 0); + + /* undef deprecated properties */ + rb_undef_method(RG_TARGET_NAMESPACE, "adjustment"); + rb_undef_method(RG_TARGET_NAMESPACE, "adjustment="); + rb_undef_method(RG_TARGET_NAMESPACE, "set_adjustment"); + rb_undef_method(RG_TARGET_NAMESPACE, "bar_style"); + rb_undef_method(RG_TARGET_NAMESPACE, "bar_style="); + rb_undef_method(RG_TARGET_NAMESPACE, "set_bar_style"); + rb_undef_method(RG_TARGET_NAMESPACE, "discrete_blocks"); + rb_undef_method(RG_TARGET_NAMESPACE, "discrete_blocks="); + rb_undef_method(RG_TARGET_NAMESPACE, "set_discrete_blocks"); + rb_undef_method(RG_TARGET_NAMESPACE, "activity_blocks"); + rb_undef_method(RG_TARGET_NAMESPACE, "activity_blocks="); + rb_undef_method(RG_TARGET_NAMESPACE, "set_activity_blocks"); + rb_undef_method(RG_TARGET_NAMESPACE, "activity_step"); + rb_undef_method(RG_TARGET_NAMESPACE, "activity_step="); + rb_undef_method(RG_TARGET_NAMESPACE, "set_activity_step"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkradioaction.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkradioaction.c new file mode 100644 index 0000000..e06ca56 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkradioaction.c @@ -0,0 +1,138 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004-2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cRadioAction +#define _SELF(self) (GTK_RADIO_ACTION(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(VALUE self, VALUE name, VALUE label, VALUE tooltip, VALUE stock_id, VALUE value) +{ + const gchar *gstock = NULL; + + if (TYPE(stock_id) == T_STRING){ + gstock = RVAL2CSTR(stock_id); + } else if (TYPE(stock_id) == T_SYMBOL) { + gstock = rb_id2name(SYM2ID(stock_id)); + } + G_INITIALIZE(self, gtk_radio_action_new(RVAL2CSTR(name), + RVAL2CSTR(label), + NIL_P(tooltip) ? NULL : RVAL2CSTR(tooltip), + gstock, + NUM2INT(value))); + return Qnil; +} + +static VALUE +raction_get_group(VALUE self) +{ + /* Owned by GTK+ */ + return GSLIST2ARY(gtk_radio_action_get_group(_SELF(self))); +} + +struct rbgtk_rval2gtkradioactiongslist_args { + VALUE ary; + long n; + GSList *result; +}; + +static VALUE +rbgtk_rval2gtkradioactiongslist_body(VALUE value) +{ + long i; + struct rbgtk_rval2gtkradioactiongslist_args *args = (struct rbgtk_rval2gtkradioactiongslist_args *)value; + + for (i = 0; i < args->n; i++) + args->result = g_slist_append(args->result, GTK_RADIO_ACTION(RVAL2GOBJ(RARRAY_PTR(args->ary)[i]))); + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbgtk_rval2gtkradioactiongslist_rescue(VALUE value) +{ + g_slist_free(((struct rbgtk_rval2gtkradioactiongslist_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static GSList * +rbgtk_rval2gtkradioactiongslist(VALUE value) +{ + struct rbgtk_rval2gtkradioactiongslist_args args; + + args.ary = rb_ary_to_ary(value); + args.n = RARRAY_LEN(args.ary); + args.result = NULL; + + rb_rescue(rbgtk_rval2gtkradioactiongslist_body, (VALUE)&args, + rbgtk_rval2gtkradioactiongslist_rescue, (VALUE)&args); + + return args.result; +} + +#define RVAL2GTKRADIOACTIONGSLIST(value) rbgtk_rval2gtkradioactiongslist(value) + +static VALUE +raction_set_group(VALUE self, VALUE rbgroup) +{ + GtkRadioAction *action = _SELF(self); + + /* TODO: This might leak. Use gtk_radio_action_join_group() in 3.0. */ + if (TYPE(rbgroup) == T_ARRAY) + gtk_radio_action_set_group(action, RVAL2GTKRADIOACTIONGSLIST(rbgroup)); + else if (NIL_P(rbgroup)) + gtk_radio_action_set_group(action, NULL); + else + gtk_radio_action_set_group(action, + gtk_radio_action_get_group(GTK_RADIO_ACTION(RVAL2GOBJ(rbgroup)))); + + return self; +} + +#if ! GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_current_value(VALUE self) +{ + return INT2NUM(gtk_radio_action_get_current_value(_SELF(self))); +} +#endif + +#endif + +void +Init_gtk_radio_action(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_RADIO_ACTION, "RadioAction", mGtk); + + RG_DEF_METHOD(initialize, 5); +#if ! GTK_CHECK_VERSION(2,10,0) + /* Define as Property since 2.10 */ + RG_DEF_METHOD(current_value, 0); +#endif + G_REPLACE_GET_PROPERTY(RG_TARGET_NAMESPACE, "group", raction_get_group, 0); + G_REPLACE_SET_PROPERTY(RG_TARGET_NAMESPACE, "group", raction_set_group, 1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkradiobutton.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkradiobutton.c new file mode 100644 index 0000000..e75462e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkradiobutton.c @@ -0,0 +1,90 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cRadioButton + +static VALUE RG_TARGET_NAMESPACE; + +#define _GROUP(s) (NIL_P(s) ? NULL : GTK_RADIO_BUTTON(RVAL2GOBJ(s))) + +static GtkWidget* +create_button(VALUE group, VALUE label, VALUE use_underline) +{ + GtkWidget* widget = NULL; + + if (TYPE(label) == T_STRING){ + if (NIL_P(use_underline) || RVAL2CBOOL(use_underline)){ + widget = gtk_radio_button_new_with_mnemonic_from_widget(_GROUP(group), RVAL2CSTR(label)); + } else { + widget = gtk_radio_button_new_with_label_from_widget(_GROUP(group), RVAL2CSTR(label)); + } + } else if (TYPE(label) == T_SYMBOL){ + widget = gtk_radio_button_new_with_label_from_widget(_GROUP(group), rb_id2name(SYM2ID(label))); + gtk_button_set_use_stock(GTK_BUTTON(widget), TRUE); + } else if (NIL_P(label)){ + widget = gtk_radio_button_new_from_widget(_GROUP(group)); + } else { + rb_raise(rb_eArgError, "invalid argument %s (expect Symbol(Gtk::Stock constants) or String)", + rb_class2name(CLASS_OF(label))); + } + return widget; +} + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE group_or_label, label_or_use_underline, use_underline; + GtkWidget *widget; + + if (rb_scan_args(argc, argv, "03", &group_or_label, &label_or_use_underline, &use_underline) > 0) { + if (rb_obj_is_kind_of(group_or_label, RG_TARGET_NAMESPACE)){ + widget = create_button(group_or_label, label_or_use_underline, use_underline); + } else { + widget = create_button(Qnil, group_or_label, label_or_use_underline); + } + } else { + widget = gtk_radio_button_new(NULL); + } + + RBGTK_INITIALIZE(self, widget); + return Qnil; +} + +static VALUE +rg_group(VALUE self) +{ + /* Owned by GTK+ */ + return GSLIST2ARY(gtk_radio_button_get_group(GTK_RADIO_BUTTON(RVAL2GOBJ(self)))); +} + +void +Init_gtk_radio_button(VALUE mGtk) +{ + RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_RADIO_BUTTON, "RadioButton", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(group, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkradiomenuitem.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkradiomenuitem.c new file mode 100644 index 0000000..c89f790 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkradiomenuitem.c @@ -0,0 +1,148 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi, + * dellin + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cRadioMenuItem + +struct rbgtk_rval2gtkradiomenuitemgslist_args { + VALUE ary; + long n; + GSList *result; +}; + +static VALUE +rbgtk_rval2gtkradiomenuitemgslist_body(VALUE value) +{ + long i; + struct rbgtk_rval2gtkradiomenuitemgslist_args *args = (struct rbgtk_rval2gtkradiomenuitemgslist_args *)value; + + for (i = 0; i < args->n; i++) + args->result = g_slist_append(args->result, GTK_RADIO_MENU_ITEM(RVAL2GOBJ(RARRAY_PTR(args->ary)[i]))); + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbgtk_rval2gtkradiomenuitemgslist_rescue(VALUE value) +{ + g_slist_free(((struct rbgtk_rval2gtkradiomenuitemgslist_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static GSList * +rbgtk_rval2gtkradiomenuitemgslist(VALUE value) +{ + struct rbgtk_rval2gtkradiomenuitemgslist_args args; + + args.ary = rb_ary_to_ary(value); + args.n = RARRAY_LEN(args.ary); + args.result = NULL; + + rb_rescue(rbgtk_rval2gtkradiomenuitemgslist_body, (VALUE)&args, + rbgtk_rval2gtkradiomenuitemgslist_rescue, (VALUE)&args); + + return args.result; +} + +#define RVAL2GTKRADIOMENUITEMGSLIST(value) rbgtk_rval2gtkradiomenuitemgslist(value) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE arg1, arg2, arg3; + GtkWidget *widget; + GSList *list = NULL; + const gchar *label = NULL; + const gchar *mnemonic = NULL; + + if (rb_scan_args(argc, argv, "03", &arg1, &arg2, &arg3) > 0 && + TYPE(arg1) == T_STRING) { + if (NIL_P(arg2) || RVAL2CBOOL(arg2)) + mnemonic = RVAL2CSTR(arg1); + else + label = RVAL2CSTR(arg1); + } else { + if (!NIL_P(arg2)) { + if (NIL_P(arg3) || RVAL2CBOOL(arg3)) + mnemonic = RVAL2CSTR(arg2); + else + label = RVAL2CSTR(arg2); + } + + if (rb_obj_is_kind_of(arg1, GTYPE2CLASS(GTK_TYPE_RADIO_MENU_ITEM))) + list = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(RVAL2GOBJ(arg1))); + else if (TYPE(arg1) == T_ARRAY) + /* TODO: This might leak. */ + list = RVAL2GTKRADIOMENUITEMGSLIST(arg1); + else if (!NIL_P(arg1)) + rb_raise(rb_eArgError, "invalid argument %s (expect Array or Gtk::RadioMenuItem)", + rb_class2name(CLASS_OF(arg1))); + } + + if (label != NULL) + widget = gtk_radio_menu_item_new_with_label(list, label); + else if (mnemonic != NULL) + widget = gtk_radio_menu_item_new_with_mnemonic(list, mnemonic); + else + widget = gtk_radio_menu_item_new(list); + + RBGTK_INITIALIZE(self, widget); + + return Qnil; +} + +static VALUE +rmitem_get_group(VALUE self) +{ + /* Owened by GTK+ */ + return GSLIST2ARY(gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(RVAL2GOBJ(self)))); +} + +static VALUE +rmitem_set_group(VALUE self, VALUE grp_ary) +{ + GtkRadioMenuItem *rmitem2add, *rmitem_orig; + GSList *group; + + rmitem2add = GTK_RADIO_MENU_ITEM(RVAL2GOBJ(self)); + rmitem_orig = GTK_RADIO_MENU_ITEM(RVAL2GOBJ(rb_ary_entry(grp_ary, 0))); + group = gtk_radio_menu_item_group(rmitem_orig); + + gtk_radio_menu_item_set_group(rmitem2add, group); + + return GSLIST2ARY(gtk_radio_menu_item_get_group(rmitem2add)); +} + +void +Init_gtk_radio_menu_item(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_RADIO_MENU_ITEM, "RadioMenuItem", mGtk); + + RG_DEF_METHOD(initialize, -1); + G_REPLACE_GET_PROPERTY(RG_TARGET_NAMESPACE, "group", rmitem_get_group, 0); + G_REPLACE_SET_PROPERTY(RG_TARGET_NAMESPACE, "group", rmitem_set_group, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkradiotoolbutton.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkradiotoolbutton.c new file mode 100644 index 0000000..8c33211 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkradiotoolbutton.c @@ -0,0 +1,138 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004-2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cRadioToolButton +#define _SELF(self) (GTK_RADIO_TOOL_BUTTON(RVAL2GOBJ(self))) + +static VALUE RG_TARGET_NAMESPACE; + +struct rbgtk_rval2gtkradiotoolbuttongslist_args { + VALUE ary; + long n; + GSList *result; +}; + +static VALUE +rbgtk_rval2gtkradiotoolbuttongslist_body(VALUE value) +{ + long i; + struct rbgtk_rval2gtkradiotoolbuttongslist_args *args = (struct rbgtk_rval2gtkradiotoolbuttongslist_args *)value; + + for (i = 0; i < args->n; i++) + args->result = g_slist_append(args->result, GTK_RADIO_MENU_ITEM(RVAL2GOBJ(RARRAY_PTR(args->ary)[i]))); + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +rbgtk_rval2gtkradiotoolbuttongslist_rescue(VALUE value) +{ + g_slist_free(((struct rbgtk_rval2gtkradiotoolbuttongslist_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static GSList * +rbgtk_rval2gtkradiotoolbuttongslist(VALUE value) +{ + struct rbgtk_rval2gtkradiotoolbuttongslist_args args; + + args.ary = rb_ary_to_ary(value); + args.n = RARRAY_LEN(args.ary); + args.result = NULL; + + rb_rescue(rbgtk_rval2gtkradiotoolbuttongslist_body, (VALUE)&args, + rbgtk_rval2gtkradiotoolbuttongslist_rescue, (VALUE)&args); + + return args.result; +} + +#define RVAL2GTKRADIOTOOLBUTTONGSLIST(value) rbgtk_rval2gtkradiotoolbuttongslist(value) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE group_or_stock_id, rbstock_id; + GtkToolItem *widget; + + if (rb_scan_args(argc, argv, "02", &group_or_stock_id, &rbstock_id) > 0) { + GSList *group = NULL; + const gchar *stock_id = TYPE(rbstock_id) == T_SYMBOL ? + rb_id2name(SYM2ID(rbstock_id)) : + RVAL2CSTR_ACCEPT_NIL(rbstock_id); + + if (TYPE(group_or_stock_id) == T_ARRAY) + /* TODO: This has a potential for leaking. */ + group = RVAL2GTKRADIOTOOLBUTTONGSLIST(group_or_stock_id); + else if (rb_obj_is_kind_of(group_or_stock_id, RG_TARGET_NAMESPACE)) + group = gtk_radio_tool_button_get_group(_SELF(group_or_stock_id)); + + if (stock_id == NULL) + widget = gtk_radio_tool_button_new(group); + else + widget = gtk_radio_tool_button_new_from_stock(group, stock_id); + } else { + widget = gtk_radio_tool_button_new(NULL); + } + + RBGTK_INITIALIZE(self, widget); + + return Qnil; +} + +static VALUE +rbtn_get_group(VALUE self) +{ + /* Owned by GTK+ */ + return GSLIST2ARY(gtk_radio_tool_button_get_group(_SELF(self))); +} + +static VALUE +rbtn_set_group(VALUE self, VALUE rbgroup) +{ + GtkRadioToolButton *button = _SELF(self); + GSList *group = TYPE(rbgroup) == T_ARRAY ? + /* TODO: This might leak. */ + RVAL2GTKRADIOTOOLBUTTONGSLIST(rbgroup) : + gtk_radio_tool_button_get_group(_SELF(rbgroup)); + + gtk_radio_tool_button_set_group(button, group); + + return self; +} + +#endif + +void +Init_gtk_radiotoolbutton(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_RADIO_TOOL_BUTTON, "RadioToolButton", mGtk); + + RG_DEF_METHOD(initialize, -1); + G_REPLACE_GET_PROPERTY(RG_TARGET_NAMESPACE, "group", rbtn_get_group, 0); + G_REPLACE_SET_PROPERTY(RG_TARGET_NAMESPACE, "group", rbtn_set_group, 1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrange.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrange.c new file mode 100644 index 0000000..2d492f4 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrange.c @@ -0,0 +1,73 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cRange +#define _SELF(self) (GTK_RANGE(RVAL2GOBJ(self))) + +static VALUE +rg_value(VALUE self) +{ + return rb_float_new(gtk_range_get_value(_SELF(self))); +} + +static VALUE +rg_set_increments(VALUE self, VALUE step, VALUE page) +{ + gtk_range_set_increments(_SELF(self), NUM2DBL(step), NUM2DBL(page)); + return self; +} + +static VALUE +rg_set_range(VALUE self, VALUE min, VALUE max) +{ + gtk_range_set_range(_SELF(self), NUM2DBL(min), NUM2DBL(max)); + return self; +} + +static VALUE +rg_set_value(VALUE self, VALUE value) +{ + gtk_range_set_value(_SELF(self), NUM2DBL(value)); + return self; +} + +void +Init_gtk_range(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_RANGE, "Range", mGtk); + + RG_DEF_METHOD(value, 0); + RG_DEF_METHOD(set_increments, 2); + RG_DEF_METHOD(set_range, 2); + RG_DEF_METHOD(set_value, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "value"); + +#if GTK_CHECK_VERSION(2,10,0) + /* GtkSensitivityType */ + G_DEF_CLASS(GTK_TYPE_SENSITIVITY_TYPE, "SensitivityType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_SENSITIVITY_TYPE, "GTK_"); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrc.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrc.c new file mode 100644 index 0000000..8837fc7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrc.c @@ -0,0 +1,221 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE mRC + +/* +static VALUE +rc_scanner_new(VALUE self) +{ + return BOXED2RVAL(gtk_rc_scanner_new(), GTK_TYPE_GSCANNER); +} +*/ + +static VALUE +rg_m_get_style(G_GNUC_UNUSED VALUE self, VALUE widget) +{ + GtkStyle* style = gtk_rc_get_style(GTK_WIDGET(RVAL2GOBJ(widget))); + GType gtype = G_OBJECT_TYPE(style); + const gchar* name = G_OBJECT_TYPE_NAME(style); + if (! rb_const_defined_at(mGtk, rb_intern(name))){ + G_DEF_CLASS(gtype, (gchar*)name, mGtk); + } + return GOBJ2RVAL(gtk_rc_get_style(GTK_WIDGET(RVAL2GOBJ(widget)))); +} + +static VALUE +rg_m_get_style_by_paths(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE settings, widget_path, class_path, klass; + GtkStyle* style; + GType gtype; + const gchar* name; + + rb_scan_args(argc, argv, "13", &settings, &widget_path, &class_path, &klass); + + style = gtk_rc_get_style_by_paths(GTK_SETTINGS(RVAL2GOBJ(settings)), + NIL_P(widget_path) ? NULL : RVAL2CSTR(widget_path), + NIL_P(class_path) ? NULL : RVAL2CSTR(class_path), + NIL_P(klass) ? G_TYPE_NONE : CLASS2GTYPE(klass)); + + if (style){ + gtype = G_OBJECT_TYPE(style); + name = G_OBJECT_TYPE_NAME(style); + if (! rb_const_defined_at(mGtk, rb_intern(name))){ + G_DEF_CLASS(gtype, (gchar*)name, mGtk); + } + return GOBJ2RVAL(style); + } + return Qnil; +} + +static VALUE +rg_m_parse(G_GNUC_UNUSED VALUE self, VALUE filename) +{ + gtk_rc_parse(RVAL2CSTR(filename)); + return filename; +} + +static VALUE +rg_m_parse_string(G_GNUC_UNUSED VALUE self, VALUE rc_string) +{ + gtk_rc_parse_string(RVAL2CSTR(rc_string)); + return rc_string; +} + +static VALUE +rg_m_reparse_all(G_GNUC_UNUSED VALUE self) +{ + return CBOOL2RVAL(gtk_rc_reparse_all()); +} + +static VALUE +rg_m_reparse_all_for_settings(G_GNUC_UNUSED VALUE self, VALUE settings, VALUE force_load) +{ + return CBOOL2RVAL(gtk_rc_reparse_all_for_settings(GTK_SETTINGS(RVAL2GOBJ(settings)), + RVAL2CBOOL(force_load))); +} + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_m_reset_styles(G_GNUC_UNUSED VALUE self, VALUE settings) +{ + gtk_rc_reset_styles(GTK_SETTINGS(RVAL2GOBJ(settings))); + return settings; +} +#endif + +static VALUE +rg_m_add_default_file(G_GNUC_UNUSED VALUE self, VALUE filename) +{ + gtk_rc_add_default_file(RVAL2CSTR(filename)); + return filename; +} + +static VALUE +rg_m_default_files(G_GNUC_UNUSED VALUE self) +{ + gchar** files = gtk_rc_get_default_files(); + VALUE ary = rb_ary_new(); + while(*files){ + rb_ary_push(ary, CSTR2RVAL(*files)); + files++; + } + return ary; +} + +static VALUE +rg_m_set_default_files(G_GNUC_UNUSED VALUE self, VALUE rbfilenames) +{ + gchar **filenames = (gchar **)RVAL2STRV(rbfilenames); + + gtk_rc_set_default_files(filenames); + + g_free(filenames); + + return rbfilenames; +} +/* +guint gtk_rc_parse_color (GScanner *scanner, + GdkColor *color); +guint gtk_rc_parse_color_full (GScanner *scanner, + GtkRcStyle *style, + GdkColor *color); +guint gtk_rc_parse_state (GScanner *scanner, + GtkStateType *state); +guint gtk_rc_parse_priority (GScanner *scanner, + GtkPathPriorityType *priority); +*/ + +static VALUE +rg_m_find_module_in_path(G_GNUC_UNUSED VALUE self, VALUE module_file) +{ + return CSTR2RVAL_FREE(gtk_rc_find_module_in_path(RVAL2CSTR(module_file))); +} + +/* +gchar* gtk_rc_find_pixmap_in_path (GtkSettings *settings, + GScanner *scanner, + const gchar *pixmap_file); +*/ + +static VALUE +rg_m_module_dir(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL_FREE(gtk_rc_get_module_dir()); +} + +static VALUE +rg_m_im_module_path(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(gtk_rc_get_im_module_path()); +} + +static VALUE +rg_m_im_module_file(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL(gtk_rc_get_im_module_file()); +} + +static VALUE +rg_m_theme_dir(G_GNUC_UNUSED VALUE self) +{ + return CSTR2RVAL_FREE(gtk_rc_get_theme_dir()); +} + +void +Init_gtk_rc(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGtk, "RC"); + + RG_DEF_MODFUNC(get_style, 1); + RG_DEF_MODFUNC(get_style_by_paths, -1); + RG_DEF_MODFUNC(parse, 1); + RG_DEF_MODFUNC(parse_string, 1); + RG_DEF_MODFUNC(reparse_all, 0); + RG_DEF_MODFUNC(reparse_all_for_settings, 2); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_MODFUNC(reset_styles, 1); +#endif + RG_DEF_MODFUNC(add_default_file, 1); + RG_DEF_MODFUNC(default_files, 0); + RG_DEF_MODFUNC(set_default_files, 1); + RG_DEF_MODFUNC(find_module_in_path, 1); + RG_DEF_MODFUNC(module_dir, 0); + RG_DEF_MODFUNC(im_module_path, 0); + RG_DEF_MODFUNC(im_module_file, 0); + RG_DEF_MODFUNC(theme_dir, 0); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + + /* GtkRcFlags */ + G_DEF_CLASS(GTK_TYPE_RC_FLAGS, "Flags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_RC_FLAGS, "GTK_RC_"); + + /* GtkRcTokenType */ + G_DEF_CLASS(GTK_TYPE_RC_TOKEN_TYPE, "TokenType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_RC_TOKEN_TYPE, "GTK_RC_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrcstyle.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrcstyle.c new file mode 100644 index 0000000..a2a292f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrcstyle.c @@ -0,0 +1,182 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cRcStyle +#define _SELF(rc) (GTK_RC_STYLE(RVAL2GOBJ(rc))) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, gtk_rc_style_new()); + return Qnil; +} + +static VALUE +rg_name(VALUE self) +{ + return CSTR2RVAL(_SELF(self)->name); +} + +static VALUE +rg_set_name(VALUE self, VALUE name) +{ + _SELF(self)->name = g_strdup(RVAL2CSTR(name)); + return self; +} + +static VALUE +rg_bg_pixmap_name(VALUE self, VALUE idx) +{ + int i = NUM2INT(idx); + + if (i < 0 || 5 < i) + rb_raise(rb_eArgError, "state out of range"); + return CSTR2RVAL(_SELF(self)->bg_pixmap_name[i]); +} + +static VALUE +rg_set_bg_pixmap_name(VALUE self, VALUE idx, VALUE bg_pixmap_name) +{ + int i = NUM2INT(idx); + + if (i < 0 || 5 < i) + rb_raise(rb_eArgError, "state out of range"); + _SELF(self)->bg_pixmap_name[i] = g_strdup(RVAL2CSTR(bg_pixmap_name)); + return self; +} + +static VALUE +rg_font_desc(VALUE self) +{ + PangoFontDescription* desc = _SELF(self)->font_desc; + return BOXED2RVAL(desc, PANGO_TYPE_FONT_DESCRIPTION); +} + +static VALUE +rg_set_font_desc(VALUE self, VALUE font_desc) +{ + _SELF(self)->font_desc = (PangoFontDescription*)RVAL2BOXED(font_desc, PANGO_TYPE_FONT_DESCRIPTION); + return self; +} + +static VALUE +rg_color_flags(VALUE self, VALUE rb_state_type) +{ + GtkStateType state_type; + + state_type = RVAL2GTKSTATETYPE(rb_state_type); + return GTKRCFLAGS2RVAL(_SELF(self)->color_flags[state_type]); +} + +static VALUE +rg_set_color_flags(VALUE self, VALUE rb_state_type, VALUE flags) +{ + GtkStateType state_type; + + state_type = RVAL2GTKSTATETYPE(rb_state_type); + _SELF(self)->color_flags[state_type] = RVAL2GTKRCFLAGS(flags); + return self; +} + +#define DEFINE_STYLE_COLOR(type) \ +static VALUE \ +rcstyle_set_ ## type(VALUE self, VALUE idx, VALUE r, VALUE g, VALUE b) \ +{ \ + GdkColor *color; \ + int i = NUM2INT(idx); \ + \ + if (i < 0 || 5 < i) rb_raise(rb_eArgError, "state out of range"); \ + color = &(_SELF(self) -> type [i]); \ + color->red = NUM2INT(r); \ + color->green = NUM2INT(g); \ + color->blue = NUM2INT(b); \ + return self;\ +} \ +static VALUE \ +rcstyle_ ## type(VALUE self, VALUE idx) \ +{ \ + int i = NUM2INT(idx); \ + \ + if (i < 0 || 5 < i) rb_raise(rb_eArgError, "state out of range"); \ + return BOXED2RVAL(&_SELF(self)-> type [i], GDK_TYPE_COLOR); \ +} \ + +DEFINE_STYLE_COLOR(fg); +DEFINE_STYLE_COLOR(bg); +DEFINE_STYLE_COLOR(text); +DEFINE_STYLE_COLOR(base); + +static VALUE +rg_xthickness(VALUE self) +{ + return INT2NUM(_SELF(self)->xthickness); +} + +static VALUE +rg_set_xthickness(VALUE self, VALUE xthickness) +{ + _SELF(self)->xthickness = NUM2INT(xthickness); + return self; +} + +static VALUE +rg_ythickness(VALUE self) +{ + return INT2NUM(_SELF(self)->ythickness); +} + +static VALUE +rg_set_ythickness(VALUE self, VALUE ythickness) +{ + _SELF(self)->ythickness = NUM2INT(ythickness); + return self; +} + +void +Init_gtk_rcstyle(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_RC_STYLE, "RcStyle", mGtk); + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(color_flags, 1); + RG_DEF_METHOD(set_color_flags, 2); + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(set_name, 1); + RG_DEF_METHOD(bg_pixmap_name, 1); + RG_DEF_METHOD(set_bg_pixmap_name, 2); + RG_DEF_METHOD(font_desc, 0); + RG_DEF_METHOD(set_font_desc, 1); + rb_define_method(RG_TARGET_NAMESPACE, "fg", rcstyle_fg, 1); + rb_define_method(RG_TARGET_NAMESPACE, "bg", rcstyle_bg, 1); + rb_define_method(RG_TARGET_NAMESPACE, "text", rcstyle_text, 1); + rb_define_method(RG_TARGET_NAMESPACE, "base", rcstyle_base, 1); + rb_define_method(RG_TARGET_NAMESPACE, "set_fg", rcstyle_set_fg, 4); + rb_define_method(RG_TARGET_NAMESPACE, "set_bg", rcstyle_set_bg, 4); + rb_define_method(RG_TARGET_NAMESPACE, "set_text", rcstyle_set_text, 4); + rb_define_method(RG_TARGET_NAMESPACE, "set_base", rcstyle_set_base, 4); + RG_DEF_METHOD(xthickness, 0); + RG_DEF_METHOD(ythickness, 0); + RG_DEF_METHOD(set_xthickness, 1); + RG_DEF_METHOD(set_ythickness, 1); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentaction.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentaction.c new file mode 100644 index 0000000..fc4fccb --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentaction.c @@ -0,0 +1,60 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,12,0) + +#define RG_TARGET_NAMESPACE cRecentAction + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE name, label, tooltip, stock_id, manager; + rb_scan_args(argc, argv, "23", &name, &label, &tooltip, &stock_id, &manager); + if (NIL_P(manager)) { + G_INITIALIZE(self, gtk_recent_action_new(RVAL2CSTR(name), + RVAL2CSTR(label), + NIL_P(tooltip) ? NULL : RVAL2CSTR(tooltip), + NIL_P(stock_id) ? NULL : RVAL2CSTR(stock_id))); + } else { + G_INITIALIZE(self, gtk_recent_action_new_for_manager(RVAL2CSTR(name), + RVAL2CSTR(label), + NIL_P(tooltip) ? NULL : RVAL2CSTR(tooltip), + NIL_P(stock_id) ? NULL : RVAL2CSTR(stock_id), + GTK_RECENT_MANAGER(RVAL2GOBJ(manager)))); + } + return Qnil; +} + +#endif + +void +Init_gtk_recentaction(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,12,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_RECENT_ACTION, "RecentAction", mGtk); + RG_DEF_METHOD(initialize, -1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentchooser.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentchooser.c new file mode 100644 index 0000000..9f547d4 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentchooser.c @@ -0,0 +1,222 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +#define RG_TARGET_NAMESPACE cRecentChooser +#define _SELF(self) (GTK_RECENT_CHOOSER(RVAL2GOBJ(self))) + +static VALUE +rg_set_show_numbers(VALUE self, VALUE val) +{ + gtk_recent_chooser_set_show_numbers(_SELF(self), RVAL2CBOOL(val)); + return self; +} + +static VALUE +rg_show_numbers(VALUE self) +{ + return CBOOL2RVAL(gtk_recent_chooser_get_show_numbers(_SELF(self))); +} + +struct callback_arg +{ + VALUE callback; + VALUE a, b; +}; + +static VALUE +invoke_callback(VALUE data) +{ + struct callback_arg *arg = (struct callback_arg *)data; + return rb_funcall(arg->callback, id_call, 1, arg->a, arg->b); +} + +static void +remove_callback_reference(gpointer callback) +{ + G_CHILD_REMOVE(mGtk, (VALUE)callback); +} + +static gint +sort_func(GtkRecentInfo *a, GtkRecentInfo *b, gpointer func) +{ + struct callback_arg arg; + + arg.callback = (VALUE)func; + arg.a = BOXED2RVAL(a, GTK_TYPE_RECENT_INFO); + arg.b = BOXED2RVAL(b, GTK_TYPE_RECENT_INFO); + return NUM2INT(G_PROTECT_CALLBACK(invoke_callback, &arg)); +} + +static VALUE +rg_set_sort_func(VALUE self) +{ + VALUE func = rb_block_proc(); + G_CHILD_ADD(mGtk, func); + gtk_recent_chooser_set_sort_func(_SELF(self), (GtkRecentSortFunc)sort_func, + (gpointer)func, (GDestroyNotify)remove_callback_reference); + return self; +} + +static VALUE +rg_set_current_uri(VALUE self, VALUE uri) +{ + GError *error = NULL; + gboolean ret = gtk_recent_chooser_set_current_uri(_SELF(self), + RVAL2CSTR(uri), + &error); + if (! ret) RAISE_GERROR(error); + return self; +} + +static VALUE +rg_current_uri(VALUE self) +{ + return CSTR2RVAL(gtk_recent_chooser_get_current_uri(_SELF(self))); +} + +static VALUE +rg_current_item(VALUE self) +{ + return BOXED2RVAL(gtk_recent_chooser_get_current_item(_SELF(self)), + GTK_TYPE_RECENT_INFO); +} + +static VALUE +rg_select_uri(VALUE self, VALUE uri) +{ + GError *error = NULL; + gboolean ret = gtk_recent_chooser_select_uri(_SELF(self), + RVAL2CSTR(uri), + &error); + if (! ret) RAISE_GERROR(error); + return self; +} + +static VALUE +rg_unselect_uri(VALUE self, VALUE uri) +{ + gtk_recent_chooser_unselect_uri(_SELF(self), RVAL2CSTR(uri)); + return self; +} + +static VALUE +rg_select_all(VALUE self) +{ + gtk_recent_chooser_select_all(_SELF(self)); + return self; +} + +static VALUE +rg_unselect_all(VALUE self) +{ + gtk_recent_chooser_unselect_all(_SELF(self)); + return self; +} + +static VALUE +rg_items(VALUE self) +{ + GList* list = gtk_recent_chooser_get_items(_SELF(self)); + VALUE ary = rb_ary_new(); + while (list) { + rb_ary_push(ary, BOXED2RVAL(list->data, GTK_TYPE_RECENT_INFO)); + gtk_recent_info_unref(list->data); + list = list->next; + } + g_list_free(list); + return ary; +} + +static VALUE +rg_uris(VALUE self) +{ + gsize i; + gsize size; + gchar** uris = gtk_recent_chooser_get_uris(_SELF(self), &size); + VALUE ary = rb_ary_new(); + for (i = 0; i < size; i++){ + rb_ary_push(ary, CSTR2RVAL(uris[i])); + } + g_strfreev(uris); + return ary; +} + +static VALUE +rg_add_filter(VALUE self, VALUE filter) +{ + gtk_recent_chooser_add_filter(_SELF(self), + GTK_RECENT_FILTER(RVAL2GOBJ(filter))); + return self; +} + +static VALUE +rg_remove_filter(VALUE self, VALUE filter) +{ + gtk_recent_chooser_remove_filter(_SELF(self), + GTK_RECENT_FILTER(RVAL2GOBJ(filter))); + return self; +} + +static VALUE +rg_filters(VALUE self) +{ + return GSLIST2ARYF(gtk_recent_chooser_list_filters(_SELF(self))); +} +#endif + +void +Init_gtk_recent_chooser(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_RECENT_CHOOSER, "RecentChooser", mGtk); + + RG_DEF_METHOD(set_show_numbers, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "show_numbers"); + RG_DEF_METHOD(show_numbers, 0); + RG_DEF_METHOD(set_sort_func, 0); + RG_DEF_METHOD(set_current_uri, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "current_uri"); + RG_DEF_METHOD(current_uri, 0); + RG_DEF_METHOD(current_item, 0); + RG_DEF_METHOD(select_uri, 1); + RG_DEF_METHOD(unselect_uri, 1); + RG_DEF_METHOD(select_all, 0); + RG_DEF_METHOD(unselect_all, 0); + RG_DEF_METHOD(items, 0); + RG_DEF_METHOD(uris, 0); + RG_DEF_METHOD(add_filter, 1); + RG_DEF_METHOD(remove_filter, 1); + RG_DEF_METHOD(filters, 0); + + /* GtkRecentChooserError */ + G_DEF_ERROR(GTK_RECENT_CHOOSER_ERROR, "RecentChooserError", mGtk, rb_eRuntimeError, + GTK_TYPE_RECENT_CHOOSER_ERROR); + + /* GtkRecentSortType */ + G_DEF_CLASS(GTK_TYPE_RECENT_SORT_TYPE, "SortType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_RECENT_SORT_TYPE, "GTK_RECENT_"); +#endif + +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentchooserdialog.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentchooserdialog.c new file mode 100644 index 0000000..71b0fd8 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentchooserdialog.c @@ -0,0 +1,67 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +#define RG_TARGET_NAMESPACE cRecentChooserDialog +#define _SELF(self) (GTK_RECENT_CHOOSER_DIALOG(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE title, parent, button_ary; + GtkWidget* dialog; + if (rb_obj_is_kind_of(argv[2], GTYPE2CLASS(GTK_TYPE_RECENT_MANAGER))){ + VALUE manager; + rb_scan_args(argc, argv, "03*", &title, &parent, &manager, &button_ary); + + dialog = gtk_recent_chooser_dialog_new_for_manager((const gchar*)RVAL2CSTR_ACCEPT_NIL(title), + GTK_WINDOW(RVAL2GOBJ(parent)), + GTK_RECENT_MANAGER(RVAL2GOBJ(manager)), + (const gchar*)NULL, NULL); + } else { + rb_scan_args(argc, argv, "02*", &title, &parent, &button_ary); + + dialog = gtk_recent_chooser_dialog_new((const gchar*)RVAL2CSTR_ACCEPT_NIL(title), + GTK_WINDOW(RVAL2GOBJ(parent)), + (const gchar*)NULL, NULL); + } + + RBGTK_INITIALIZE(self, dialog); + + if (button_ary != Qnil){ + rbgtk_dialog_add_buttons_internal(self, button_ary); + } + return Qnil; +} +#endif + +void +Init_gtk_recent_chooser_dialog(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_RECENT_CHOOSER_DIALOG, "RecentChooserDialog", mGtk); + + RG_DEF_METHOD(initialize, -1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentchoosermenu.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentchoosermenu.c new file mode 100644 index 0000000..7725344 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentchoosermenu.c @@ -0,0 +1,56 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +#define RG_TARGET_NAMESPACE cRecentChooserMenu +#define _SELF(self) (GTK_RECENT_CHOOSER_MENU(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE manager; + GtkWidget* menu; + + rb_scan_args(argc, argv, "01", &manager); + + if (NIL_P(manager)){ + menu = gtk_recent_chooser_menu_new_for_manager(GTK_RECENT_MANAGER(RVAL2GOBJ(manager))); + } else { + menu = gtk_recent_chooser_menu_new(); + } + RBGTK_INITIALIZE(self, menu); + return Qnil; +} + +#endif + +void +Init_gtk_recent_chooser_menu(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_RECENT_CHOOSER_MENU, "RecentChooserMenu", mGtk); + + RG_DEF_METHOD(initialize, -1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentchooserwidget.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentchooserwidget.c new file mode 100644 index 0000000..2105bb8 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentchooserwidget.c @@ -0,0 +1,53 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +#define RG_TARGET_NAMESPACE cRecentChooserWidget +#define _SELF(self) (GTK_RECENT_CHOOSER_WIDGET(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE manager; + GtkWidget* widget; + rb_scan_args(argc, argv, "01", &manager); + if (NIL_P(manager)){ + widget = gtk_recent_chooser_widget_new_for_manager(GTK_RECENT_MANAGER(RVAL2GOBJ(manager))); + } else { + widget = gtk_recent_chooser_widget_new(); + } + RBGTK_INITIALIZE(self, widget); + return Qnil; +} +#endif + +void +Init_gtk_recent_chooser_widget(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_RECENT_CHOOSER_WIDGET, "RecentChooserWidget", mGtk); + + RG_DEF_METHOD(initialize, -1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentdata.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentdata.c new file mode 100644 index 0000000..491eac5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentdata.c @@ -0,0 +1,150 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +/*****************************************/ +static GtkRecentData* +rd_copy(const GtkRecentData* data) +{ + GtkRecentData* new_data; + g_return_val_if_fail (data != NULL, NULL); + new_data = g_new(GtkRecentData, 1); + *new_data = *data; + return new_data; +} + +static void +rd_free(GtkRecentData* boxed) +{ + if (boxed){ + g_free(boxed->groups); + g_free(boxed); + } +} + +GType +gtk_recent_data_get_type(void) +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static ("GtkRecentData", + (GBoxedCopyFunc)rd_copy, + (GBoxedFreeFunc)rd_free); + return our_type; +} +/*****************************************/ + +#define RG_TARGET_NAMESPACE cRecentData +#define _SELF(w) ((GtkRecentData*)RVAL2BOXED(w, GTK_TYPE_RECENT_DATA)) + +static VALUE +rg_initialize(VALUE self) +{ + GtkRecentData data; + memset(&data, 0, sizeof(GtkRecentData)); + G_INITIALIZE(self, g_boxed_copy(GTK_TYPE_RECENT_DATA, &data)); + return Qnil; +} + +#define RD_STR(name)\ +static VALUE \ +rd_get_ ## name (VALUE self)\ +{\ + return CSTR2RVAL(_SELF(self)->name);\ +}\ +static VALUE \ +rd_set_ ## name (VALUE self, VALUE val)\ +{\ + _SELF(self)->name = (gchar *)RVAL2CSTR(val);\ + return self;\ +} + +RD_STR(display_name); +RD_STR(description); +RD_STR(mime_type); +RD_STR(app_name); +RD_STR(app_exec); + +static VALUE +rg_groups(VALUE self) +{ + gchar** grps = _SELF(self)->groups; + VALUE ary = rb_ary_new(); + + gint i = 0; + while (grps[i]) { + rb_ary_push(ary, CSTR2RVAL((gchar*)grps[i])); + i++; + } + return ary; +} + +static VALUE +rg_set_groups(VALUE self, VALUE groups) +{ + _SELF(self)->groups = RVAL2STRV_DUP(groups); + + return self; +} + +static VALUE +rg_private_p(VALUE self) +{ + return CBOOL2RVAL(_SELF(self)->is_private); +} + +static VALUE +rg_set_private(VALUE self, VALUE is_private) +{ + _SELF(self)->is_private = RVAL2CBOOL(is_private); + return self; +} + +#endif + +void +Init_gtk_recent_data(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_RECENT_DATA, "RecentData", mGtk); + + RG_DEF_METHOD(initialize, 0); + rb_define_method(RG_TARGET_NAMESPACE, "display_name", rd_get_display_name, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_display_name", rd_set_display_name, 1); + rb_define_method(RG_TARGET_NAMESPACE, "description", rd_get_description, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_description", rd_set_description, 1); + rb_define_method(RG_TARGET_NAMESPACE, "mime_type", rd_get_mime_type, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_mime_type", rd_set_mime_type, 1); + rb_define_method(RG_TARGET_NAMESPACE, "app_name", rd_get_app_name, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_app_name", rd_set_app_name, 1); + rb_define_method(RG_TARGET_NAMESPACE, "app_exec", rd_get_app_exec, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_app_exec", rd_set_app_exec, 1); + RG_DEF_METHOD(groups, 0); + RG_DEF_METHOD(set_groups, 1); + RG_DEF_METHOD_P(private, 0); + RG_DEF_METHOD(set_private, 1); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentfilter.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentfilter.c new file mode 100644 index 0000000..8e75bbb --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentfilter.c @@ -0,0 +1,175 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +#define RG_TARGET_NAMESPACE cRecentFilter +#define _SELF(self) (GTK_RECENT_FILTER(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_recent_filter_new()); + return Qnil; +} + +static VALUE +rg_name(VALUE self) +{ + return CSTR2RVAL(gtk_recent_filter_get_name(_SELF(self))); +} + +static VALUE +rg_set_name(VALUE self, VALUE name) +{ + gtk_recent_filter_set_name(_SELF(self), RVAL2CSTR(name)); + return self; +} + +static VALUE +rg_add_mime_type(VALUE self, VALUE mime_type) +{ + gtk_recent_filter_add_mime_type(_SELF(self), RVAL2CSTR(mime_type)); + return self; +} + +static VALUE +rg_add_pattern(VALUE self, VALUE pattern) +{ + gtk_recent_filter_add_pattern(_SELF(self), RVAL2CSTR(pattern)); + return self; +} + +static VALUE +rg_add_pixbuf_formats(VALUE self) +{ + gtk_recent_filter_add_pixbuf_formats(_SELF(self)); + return self; +} + +static VALUE +rg_add_application(VALUE self, VALUE application) +{ + gtk_recent_filter_add_application(_SELF(self), RVAL2CSTR(application)); + return self; +} + +static VALUE +rg_add_group(VALUE self, VALUE group) +{ + gtk_recent_filter_add_group(_SELF(self), RVAL2CSTR(group)); + return self; +} + +static VALUE +rg_add_age(VALUE self, VALUE days) +{ + gtk_recent_filter_add_age(_SELF(self), NUM2INT(days)); + return self; +} + +struct callback_arg +{ + VALUE callback; + VALUE info; +}; + +static VALUE +invoke_callback(VALUE arg_) +{ + struct callback_arg *arg = (struct callback_arg *)arg_; + return rb_funcall(arg->callback, id_call, 1, arg->info); +} + +static gboolean +filter_func(const GtkRecentFilterInfo *info, gpointer func) +{ + VALUE result; + struct callback_arg arg; + + arg.callback = (VALUE)func; + arg.info = BOXED2RVAL((gpointer)info, GTK_TYPE_RECENT_FILTER_INFO); + + result = G_PROTECT_CALLBACK(invoke_callback, &arg); + return NIL_P(rb_errinfo()) ? TRUE : RVAL2CBOOL(result); +} + +static void +remove_callback_reference(gpointer data) +{ + G_CHILD_REMOVE(mGtk, (VALUE)data); +} + +static VALUE +rg_add_custom(VALUE self, VALUE needed) +{ + VALUE func = rb_block_proc(); + G_CHILD_ADD(mGtk, func); + + gtk_recent_filter_add_custom(_SELF(self), + RVAL2GFLAGS(needed, GTK_TYPE_RECENT_FILTER_FLAGS), + (GtkRecentFilterFunc)filter_func, + (gpointer)func, + (GDestroyNotify)remove_callback_reference); + return self; +} + +static VALUE +rg_needed(VALUE self) +{ + return GFLAGS2RVAL(gtk_recent_filter_get_needed(_SELF(self)), GTK_TYPE_RECENT_FILTER_FLAGS); +} + +static VALUE +rg_filter(VALUE self, VALUE filter_info) +{ + return CBOOL2RVAL(gtk_recent_filter_filter(_SELF(self), + (GtkRecentFilterInfo*)RVAL2BOXED(filter_info, GTK_TYPE_RECENT_FILTER_INFO))); +} +#endif + +void +Init_gtk_recent_filter(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_RECENT_FILTER, "RecentFilter", mGtk); + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(set_name, 1); + RG_DEF_METHOD(add_mime_type, 1); + RG_DEF_METHOD(add_pattern, 1); + RG_DEF_METHOD(add_pixbuf_formats, 0); + RG_DEF_METHOD(add_application, 1); + RG_DEF_METHOD(add_group, 1); + RG_DEF_METHOD(add_age, 1); + RG_DEF_METHOD(add_custom, 1); + RG_DEF_METHOD(needed, 0); + RG_DEF_METHOD(filter, 1); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + + /* GtkRecentFilterFlags */ + G_DEF_CLASS(GTK_TYPE_RECENT_FILTER_FLAGS, "Flags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_RECENT_FILTER_FLAGS, "GTK_RECENT_FILTER_"); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentfilterinfo.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentfilterinfo.c new file mode 100644 index 0000000..f71b6ba --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentfilterinfo.c @@ -0,0 +1,187 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +/*****************************************/ +static GtkRecentFilterInfo* +rf_copy(const GtkRecentFilterInfo* info) +{ + GtkRecentFilterInfo* new_info; + g_return_val_if_fail (info != NULL, NULL); + new_info = g_new(GtkRecentFilterInfo, 1); + *new_info = *info; + return new_info; +} + +static void +rf_free(GtkRecentFilterInfo* boxed) +{ + if (boxed) { + g_free(boxed->applications); + g_free(boxed->groups); + g_free(boxed); + } +} + +GType +gtk_recent_filter_info_get_type(void) +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static ("GtkRecentFilterInfo", + (GBoxedCopyFunc)rf_copy, + (GBoxedFreeFunc)rf_free); + return our_type; +} +/*****************************************/ + +#define RG_TARGET_NAMESPACE cRecentFilterInfo +#define _SELF(w) ((GtkRecentFilterInfo*)RVAL2BOXED(w, GTK_TYPE_RECENT_FILTER_INFO)) + +static VALUE +rg_initialize(VALUE self) +{ + GtkRecentFilterInfo finfo; + memset(&finfo, 0, sizeof(GtkRecentFilterInfo)); + G_INITIALIZE(self, g_boxed_copy(GTK_TYPE_RECENT_FILTER_INFO, &finfo)); + return Qnil; +} + +static VALUE +rg_contains(VALUE self) +{ + return GFLAGS2RVAL(_SELF(self)->contains, GTK_TYPE_RECENT_FILTER_FLAGS); +} + +static VALUE +rg_set_contains(VALUE self, VALUE contains) +{ + _SELF(self)->contains = RVAL2GFLAGS(contains, GTK_TYPE_RECENT_FILTER_FLAGS); + return self; +} + +#define FINFO_STR(name)\ +static VALUE \ +rf_get_ ## name (VALUE self)\ +{\ + return CSTR2RVAL(_SELF(self)->name);\ +}\ +static VALUE \ +rf_set_ ## name (VALUE self, VALUE val)\ +{\ + _SELF(self)->name = RVAL2CSTR(val);\ + return self;\ +} + +FINFO_STR(uri); +FINFO_STR(display_name); +FINFO_STR(mime_type); + +static VALUE +rg_applications(VALUE self) +{ + const gchar** apps = _SELF(self)->applications; + VALUE ary = rb_ary_new(); + + gint i = 0; + while (apps[i]) { + rb_ary_push(ary, CSTR2RVAL((gchar*)apps[i])); + i++; + } + return ary; +} + +static VALUE +rg_set_applications(VALUE self, VALUE applications) +{ + /* NOTE: This can't be right. What guarantees that the entries in + * applications will be around? It should be RVAL2STRV_DUP and use + * g_strfreev in free above. */ + _SELF(self)->applications = RVAL2STRV(applications); + + return self; +} + +static VALUE +rg_groups(VALUE self) +{ + const gchar** grps = _SELF(self)->groups; + VALUE ary = rb_ary_new(); + + gint i = 0; + while (grps[i]) { + rb_ary_push(ary, CSTR2RVAL((gchar*)grps[i])); + i++; + } + return ary; +} + +static VALUE +rg_set_groups(VALUE self, VALUE groups) +{ + _SELF(self)->groups = RVAL2STRV(groups); + + return self; +} + +static VALUE +rg_age(VALUE self) +{ + return INT2NUM(_SELF(self)->age); +} + +static VALUE +rg_set_age(VALUE self, VALUE age) +{ + _SELF(self)->age = NUM2INT(age); + return self; +} + +#endif + +void +Init_gtk_recent_filter_info(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_RECENT_FILTER_INFO, "RecentFilterInfo", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(contains, 0); + RG_DEF_METHOD(set_contains, 1); + rb_define_method(RG_TARGET_NAMESPACE, "uri", rf_get_uri, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_uri", rf_set_uri, 1); + rb_define_method(RG_TARGET_NAMESPACE, "display_name", rf_get_display_name, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_display_name", rf_set_display_name, 1); + rb_define_method(RG_TARGET_NAMESPACE, "mime_type", rf_get_mime_type, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_mime_type", rf_set_mime_type, 1); + RG_DEF_METHOD(applications, 0); + RG_DEF_METHOD(set_applications, 1); + RG_DEF_METHOD(groups, 0); + RG_DEF_METHOD(set_groups, 1); + RG_DEF_METHOD(age, 0); + RG_DEF_METHOD(set_age, 1); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentinfo.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentinfo.c new file mode 100644 index 0000000..9000b6d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentinfo.c @@ -0,0 +1,221 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +#define RG_TARGET_NAMESPACE cRecentInfo +#define _SELF(self) ((GtkRecentInfo*)RVAL2BOXED(self, GTK_TYPE_RECENT_INFO)) + +static VALUE +rg_uri(VALUE self) +{ + return CSTR2RVAL(gtk_recent_info_get_uri(_SELF(self))); +} + +static VALUE +rg_display_name(VALUE self) +{ + return CSTR2RVAL(gtk_recent_info_get_display_name(_SELF(self))); +} + +static VALUE +rg_description(VALUE self) +{ + return CSTR2RVAL(gtk_recent_info_get_description(_SELF(self))); +} + +static VALUE +rg_mime_type(VALUE self) +{ + return CSTR2RVAL(gtk_recent_info_get_mime_type(_SELF(self))); +} + +static VALUE +rg_added(VALUE self) +{ + time_t t = gtk_recent_info_get_added(_SELF(self)); + return rb_funcall(rb_cTime, rb_intern("at"), 1, INT2NUM(t)); +} + +static VALUE +rg_modified(VALUE self) +{ + time_t t = gtk_recent_info_get_modified(_SELF(self)); + return rb_funcall(rb_cTime, rb_intern("at"), 1, INT2NUM(t)); +} + +static VALUE +rg_visited(VALUE self) +{ + time_t t = gtk_recent_info_get_visited(_SELF(self)); + return rb_funcall(rb_cTime, rb_intern("at"), 1, INT2NUM(t)); +} + +static VALUE +rg_private_hint_p(VALUE self) +{ + return CBOOL2RVAL(gtk_recent_info_get_private_hint(_SELF(self))); +} + +static VALUE +rg_application_info(VALUE self, VALUE app_name) +{ + const gchar *app_exec; + guint count; + time_t t; + gboolean ret = gtk_recent_info_get_application_info(_SELF(self), + RVAL2CSTR(app_name), + &app_exec, + &count, + &t); + VALUE ary = rb_ary_new(); + if (ret){ + rb_ary_push(ary, CSTR2RVAL(app_exec)); + rb_ary_push(ary, UINT2NUM(count)); + rb_ary_push(ary, rb_funcall(rb_cTime, rb_intern("at"), 1, INT2NUM(t))); + } + return ary; +} + +static VALUE +rg_applications(VALUE self) +{ + gsize i; + gsize length; + gchar** str = gtk_recent_info_get_applications(_SELF(self), &length); + VALUE ary = rb_ary_new(); + for(i = 0; i < length; i++){ + rb_ary_push(ary, CSTR2RVAL(str[i])); + } + g_strfreev(str); + return ary; +} + +static VALUE +rg_last_application(VALUE self) +{ + return CSTR2RVAL(gtk_recent_info_last_application(_SELF(self))); +} + +static VALUE +rg_groups(VALUE self) +{ + gsize i; + gsize length; + gchar** str = gtk_recent_info_get_groups(_SELF(self), &length); + VALUE ary = rb_ary_new(); + for(i = 0; i < length; i++){ + rb_ary_push(ary, CSTR2RVAL(str[i])); + } + g_strfreev(str); + return ary; +} + +static VALUE +rg_has_group_p(VALUE self, VALUE group_name) +{ + return CBOOL2RVAL(gtk_recent_info_has_group(_SELF(self), + RVAL2CSTR(group_name))); +} + +static VALUE +rg_has_application_p(VALUE self, VALUE app_name) +{ + return CBOOL2RVAL(gtk_recent_info_has_application(_SELF(self), + RVAL2CSTR(app_name))); +} + +static VALUE +rg_get_icon(VALUE self, VALUE size) +{ + return GOBJ2RVAL(gtk_recent_info_get_icon(_SELF(self), NUM2INT(size))); +} + +static VALUE +rg_short_name(VALUE self) +{ + return CSTR2RVAL(gtk_recent_info_get_short_name(_SELF(self))); +} + +static VALUE +rg_uri_display(VALUE self) +{ + return CSTR2RVAL(gtk_recent_info_get_uri_display(_SELF(self))); +} + +static VALUE +rg_age(VALUE self) +{ + return INT2NUM(gtk_recent_info_get_age(_SELF(self))); +} + +static VALUE +rg_local_p(VALUE self) +{ + return CBOOL2RVAL(gtk_recent_info_is_local(_SELF(self))); +} + +static VALUE +rg_exist_p(VALUE self) +{ + return CBOOL2RVAL(gtk_recent_info_exists(_SELF(self))); +} + +static VALUE +rg_operator_ri_match(VALUE self, VALUE other) +{ + return CBOOL2RVAL(gtk_recent_info_match(_SELF(self), _SELF(other))); +} + +#endif + +void +Init_gtk_recent_info(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_RECENT_INFO, "RecentInfo", mGtk); + RG_DEF_METHOD(uri, 0); + RG_DEF_METHOD(display_name, 0); + RG_DEF_METHOD(description, 0); + RG_DEF_METHOD(mime_type, 0); + RG_DEF_METHOD(added, 0); + RG_DEF_METHOD(modified, 0); + RG_DEF_METHOD(visited, 0); + RG_DEF_METHOD_P(private_hint, 0); + RG_DEF_METHOD(application_info, 1); + RG_DEF_METHOD(applications, 0); + RG_DEF_METHOD(last_application, 0); + RG_DEF_METHOD(groups, 0); + RG_DEF_METHOD_P(has_group, 1); + RG_DEF_METHOD_P(has_application, 1); + RG_DEF_METHOD(get_icon, 1); + RG_DEF_METHOD(short_name, 0); + RG_DEF_METHOD(uri_display, 0); + RG_DEF_METHOD(age, 0); + RG_DEF_METHOD_P(local, 0); + RG_DEF_METHOD_P(exist, 0); + RG_DEF_METHOD_OPERATOR("==", ri_match, 1); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentmanager.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentmanager.c new file mode 100644 index 0000000..e0316cf --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkrecentmanager.c @@ -0,0 +1,154 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +#define RG_TARGET_NAMESPACE cRecentManager +#define _SELF(self) (GTK_RECENT_MANAGER(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, gtk_recent_manager_new()); + return Qnil; +} + +static VALUE +rg_s_default(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(gtk_recent_manager_get_default()); +} + +static VALUE +rg_s_get_for_screen(G_GNUC_UNUSED VALUE self, VALUE screen) +{ + return GOBJ2RVAL(gtk_recent_manager_get_for_screen(GDK_SCREEN(RVAL2GOBJ(screen)))); +} + +static VALUE +rg_set_screen(VALUE self, VALUE screen) +{ + gtk_recent_manager_set_screen(_SELF(self), GDK_SCREEN(RVAL2GOBJ(screen))); + return self; +} + +static VALUE +rg_add_item(int argc, VALUE *argv, VALUE self) +{ + VALUE uri, data; + gboolean ret; + rb_scan_args(argc, argv, "11", &uri, &data); + + if (NIL_P(data)){ + ret = gtk_recent_manager_add_item(_SELF(self), RVAL2CSTR(uri)); + if (! ret) rb_raise(rb_eRuntimeError, "Can't add the uri"); + } else { + ret = gtk_recent_manager_add_full(_SELF(self), + RVAL2CSTR(uri), + RVAL2BOXED(data, GTK_TYPE_RECENT_DATA)); + if (! ret) rb_raise(rb_eRuntimeError, "Can't add the uri or data"); + } + return self; +} + +static VALUE +rg_remove_item(VALUE self, VALUE uri) +{ + GError* error = NULL; + gboolean ret = gtk_recent_manager_remove_item(_SELF(self), RVAL2CSTR(uri), + &error); + if (! ret) RAISE_GERROR(error); + + return self; +} + +static VALUE +rg_lookup_item(VALUE self, VALUE uri) +{ + GError* error = NULL; + GtkRecentInfo* info = gtk_recent_manager_lookup_item(_SELF(self), RVAL2CSTR(uri), + &error); + if (error) RAISE_GERROR(error); + return BOXED2RVAL(info, GTK_TYPE_RECENT_INFO); +} + +static VALUE +rg_has_item_p(VALUE self, VALUE uri) +{ + return CBOOL2RVAL(gtk_recent_manager_has_item(_SELF(self), RVAL2CSTR(uri))); +} + +static VALUE +rg_move_item(VALUE self, VALUE uri, VALUE new_uri) +{ + GError* error = NULL; + gboolean ret = gtk_recent_manager_move_item(_SELF(self), + RVAL2CSTR(uri), + RVAL2CSTR(new_uri), + &error); + if (! ret) RAISE_GERROR(error); + return self; +} + +static VALUE +rg_items(VALUE self) +{ + return GLIST2ARY2F(gtk_recent_manager_get_items(_SELF(self)), GTK_TYPE_RECENT_INFO); +} + +static VALUE +rg_purge_items(VALUE self) +{ + GError* error = NULL; + gint ret = gtk_recent_manager_purge_items(_SELF(self), &error); + + if (error) RAISE_GERROR(error); + + return INT2NUM(ret); +} +#endif + +void +Init_gtk_recent_manager(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_RECENT_MANAGER, "RecentManager", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_SMETHOD(default, 0); + RG_DEF_SMETHOD(get_for_screen, 1); + RG_DEF_METHOD(set_screen, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "set_screen"); + RG_DEF_METHOD(add_item, -1); + RG_DEF_METHOD(remove_item, 1); + RG_DEF_METHOD(lookup_item, 1); + RG_DEF_METHOD_P(has_item, 1); + RG_DEF_METHOD(move_item, 2); + RG_DEF_METHOD(items, 0); + RG_DEF_METHOD(purge_items, 0); + + /* GtkRecentManagerError */ + G_DEF_ERROR(GTK_RECENT_MANAGER_ERROR, "RecentManagerError", mGtk, rb_eRuntimeError, + GTK_TYPE_RECENT_MANAGER_ERROR); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkruler.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkruler.c new file mode 100644 index 0000000..a007414 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkruler.c @@ -0,0 +1,71 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cRuler +#define _SELF(self) (GTK_RULER(RVAL2GOBJ(self))) + +static VALUE +rg_set_range(VALUE self, VALUE lower, VALUE upper, VALUE position, VALUE max_size) +{ + gtk_ruler_set_range(_SELF(self), NUM2DBL(lower), NUM2DBL(upper), + NUM2DBL(position), NUM2DBL(max_size)); + return self; +} + +static VALUE +rg_range(VALUE self) +{ + gdouble lower, upper, position, max_size; + gtk_ruler_get_range(_SELF(self), &lower, &upper, &position, &max_size); + return rb_ary_new3(4, rb_float_new(lower), rb_float_new(upper), + rb_float_new(position), rb_float_new(max_size)); +} + +static VALUE +rg_draw_ticks(VALUE self) +{ + gtk_ruler_draw_ticks(_SELF(self)); + return self; +} + +static VALUE +rg_draw_pos(VALUE self) +{ + gtk_ruler_draw_pos(_SELF(self)); + return self; +} + +void +Init_gtk_ruler(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_RULER, "Ruler", mGtk); + + RG_DEF_METHOD(set_range, 4); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "range"); + RG_DEF_METHOD(range, 0); + RG_DEF_METHOD(draw_ticks, 0); + RG_DEF_METHOD(draw_pos, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkscale.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkscale.c new file mode 100644 index 0000000..88ab7f3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkscale.c @@ -0,0 +1,56 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cScale +#define _SELF(self) (GTK_SCALE(RVAL2GOBJ(self))) + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_layout(VALUE self) +{ + return GOBJ2RVAL(gtk_scale_get_layout(_SELF(self))); +} + +static VALUE +rg_layout_offsets(VALUE self) +{ + gint x, y; + gtk_scale_get_layout_offsets(_SELF(self), &x, &y); + return rb_assoc_new(INT2NUM(x), INT2NUM(y)); +} +#endif + +void +Init_gtk_scale(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_SCALE, "Scale", mGtk); + RG_DEF_METHOD(layout, 0); + RG_DEF_METHOD(layout_offsets, 0); +#else + G_DEF_CLASS(GTK_TYPE_SCALE, "Scale", mGtk); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkscalebutton.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkscalebutton.c new file mode 100644 index 0000000..5c65a41 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkscalebutton.c @@ -0,0 +1,75 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,12,0) + +#define RG_TARGET_NAMESPACE cScaleButton +#define _SELF(s) (GTK_SCALE_BUTTON(RVAL2GOBJ(s))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE arg1, arg2, arg3, arg4, arg5; + GtkWidget *widget; + gdouble min = 0; + gdouble max = 100; + gdouble step = 2; + + rb_scan_args(argc, argv, "14", &arg1, &arg2, &arg3, &arg4, &arg5); + + if (!NIL_P(arg2)) + min = NUM2DBL(arg2); + + if (!NIL_P(arg3)) + max = NUM2DBL(arg3); + + if (!NIL_P(arg4)) + step = NUM2DBL(arg4); + + widget = gtk_scale_button_new(RVAL2GENUM(arg1, GTK_TYPE_ICON_SIZE), min, max, step, NULL); + RBGTK_INITIALIZE(self, widget); + + if (!NIL_P(arg5)) { + const gchar **icons = RVAL2STRV(arg5); + + gtk_scale_button_set_icons(_SELF(self), icons); + + g_free(icons); + } + + return Qnil; +} + +#endif + +void +Init_gtk_scalebutton(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,12,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_SCALE_BUTTON, "ScaleButton", mGtk); + RG_DEF_METHOD(initialize, -1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkscrollbar.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkscrollbar.c new file mode 100644 index 0000000..7109fe3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkscrollbar.c @@ -0,0 +1,31 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +void +Init_gtk_scrollbar(VALUE mGtk) +{ + G_DEF_CLASS(GTK_TYPE_SCROLLBAR, "Scrollbar", mGtk); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkscrolledwindow.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkscrolledwindow.c new file mode 100644 index 0000000..53c3c14 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkscrolledwindow.c @@ -0,0 +1,133 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cScrolledWindow +#define _SELF(self) (GTK_SCROLLED_WINDOW(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE arg1, arg2; + GtkAdjustment *h_adj = NULL; + GtkAdjustment *v_adj = NULL; + + rb_scan_args(argc, argv, "02", &arg1, &arg2); + + if (!NIL_P(arg1)) h_adj = GTK_ADJUSTMENT(RVAL2GOBJ(arg1)); + if (!NIL_P(arg2)) v_adj = GTK_ADJUSTMENT(RVAL2GOBJ(arg2)); + + RBGTK_INITIALIZE(self, gtk_scrolled_window_new(h_adj, v_adj)); + return Qnil; +} + +static VALUE +rg_set_policy(VALUE self, VALUE hpolicy, VALUE vpolicy) +{ + gtk_scrolled_window_set_policy(_SELF(self), + RVAL2GENUM(hpolicy, GTK_TYPE_POLICY_TYPE), + RVAL2GENUM(vpolicy, GTK_TYPE_POLICY_TYPE)); + return self; +} + +static VALUE +rg_policy(VALUE self) +{ + GtkPolicyType hpolicy, vpolicy; + + gtk_scrolled_window_get_policy(_SELF(self), &hpolicy, &vpolicy); + return rb_ary_new3(2, + GENUM2RVAL(hpolicy, GTK_TYPE_POLICY_TYPE), + GENUM2RVAL(vpolicy, GTK_TYPE_POLICY_TYPE)); +} + +static VALUE +rg_add_with_viewport(VALUE self, VALUE other) +{ + gtk_scrolled_window_add_with_viewport(_SELF(self), + GTK_WIDGET(RVAL2GOBJ(other))); + G_CHILD_ADD(self, other); + return self; +} + +#if GTK_CHECK_VERSION(2,8,0) +static VALUE +rg_hscrollbar(VALUE self) +{ + return GOBJ2RVAL(gtk_scrolled_window_get_hscrollbar(_SELF(self))); +} + +static VALUE +rg_vscrollbar(VALUE self) +{ + return GOBJ2RVAL(gtk_scrolled_window_get_vscrollbar(_SELF(self))); +} +#endif + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_set_placement(VALUE self, VALUE corner_type) +{ + gtk_scrolled_window_set_placement(_SELF(self), + RVAL2GENUM(corner_type, GTK_TYPE_CORNER_TYPE)); + return self; +} + +static VALUE +rg_unset_placement(VALUE self) +{ + gtk_scrolled_window_unset_placement(_SELF(self)); + return self; +} + +static VALUE +rg_placement(VALUE self) +{ + return GENUM2RVAL(gtk_scrolled_window_get_placement(_SELF(self)), + GTK_TYPE_CORNER_TYPE); +} +#endif + +void +Init_gtk_scrolled_window(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_SCROLLED_WINDOW, "ScrolledWindow", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(set_policy, 2); + RG_DEF_METHOD(policy, 0); + RG_DEF_METHOD(add_with_viewport, 1); +#if GTK_CHECK_VERSION(2,8,0) + RG_DEF_METHOD(hscrollbar, 0); + RG_DEF_METHOD(vscrollbar, 0); +#endif + +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD(unset_placement, 0); + RG_DEF_METHOD(placement, 0); + RG_DEF_METHOD(set_placement, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "placement"); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkselection.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkselection.c new file mode 100644 index 0000000..88786ce --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkselection.c @@ -0,0 +1,179 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE mSelection + +#define RVAL2WIDGET(w) (GTK_WIDGET(RVAL2GOBJ(w))) + +static VALUE +rg_m_owner_set(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + gboolean ret; + + if (argc == 3){ + VALUE widget, selection, time; + rb_scan_args(argc, argv, "30", &widget, &selection, &time); + ret = gtk_selection_owner_set(RVAL2WIDGET(widget), + RVAL2ATOM(selection), NUM2INT(time)); + } else { +#if GTK_CHECK_VERSION(2,2,0) + VALUE display, widget, selection, time; + rb_scan_args(argc, argv, "40", &display, &widget, &selection, &time); + ret = gtk_selection_owner_set_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)), + RVAL2WIDGET(widget), + RVAL2ATOM(selection), NUM2INT(time)); +#else + rb_raise(rb_eArgError, "Wrong number of arguments: %d", argc); +#endif + } + return CBOOL2RVAL(ret); +} + +static VALUE +rg_m_add_target(VALUE self, VALUE widget, VALUE selection, VALUE target, VALUE info) +{ + gtk_selection_add_target(RVAL2WIDGET(widget), RVAL2ATOM(selection), + RVAL2ATOM(target), NUM2INT(info)); + return self; +} + +static VALUE +rg_m_add_targets(VALUE self, VALUE rbwidget, VALUE rbselection, VALUE rbtargets) +{ + GtkWidget *widget = RVAL2WIDGET(rbwidget); + GdkAtom selection = RVAL2ATOM(rbselection); + long n; + GtkTargetEntry *targets = RVAL2GTKTARGETENTRIES(rbtargets, &n); + + gtk_selection_add_targets(widget, selection, targets, n); + + g_free(targets); + + return self; +} + +static VALUE +rg_m_clear_targets(VALUE self, VALUE widget, VALUE selection) +{ + gtk_selection_clear_targets(RVAL2WIDGET(widget), RVAL2ATOM(selection)); + return self; +} + +static VALUE +rg_m_convert(G_GNUC_UNUSED VALUE self, VALUE widget, VALUE selection, VALUE target, VALUE time) +{ + gboolean ret = gtk_selection_convert(RVAL2WIDGET(widget), + RVAL2ATOM(selection), RVAL2ATOM(target), + NUM2INT(time)); + return CBOOL2RVAL(ret); +} + +static VALUE +rg_m_remove_all(VALUE self, VALUE widget) +{ + gtk_selection_remove_all(RVAL2WIDGET(widget)); + return self; +} + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_m_include_image_p(G_GNUC_UNUSED VALUE self, VALUE rbtargets, VALUE rbwritable) +{ + gboolean writable = RVAL2CBOOL(rbwritable); + long n; + GdkAtom *targets = RVAL2GDKATOMS(rbtargets, &n); + gboolean result; + + result = gtk_targets_include_image(targets, n, writable); + + g_free(targets); + + return result; +} + +static VALUE +rg_m_include_text_p(G_GNUC_UNUSED VALUE self, VALUE rbtargets) +{ + long n; + GdkAtom *targets = RVAL2GDKATOMS(rbtargets, &n); + gboolean result; + + result = gtk_targets_include_text(targets, n); + + g_free(targets); + + return result; +} + +static VALUE +rg_m_include_uri_p(G_GNUC_UNUSED VALUE self, VALUE rbtargets) +{ + long n; + GdkAtom *targets = RVAL2GDKATOMS(rbtargets, &n); + gboolean result; + + result = gtk_targets_include_uri(targets, n); + + g_free(targets); + + return result; +} + +static VALUE +rg_m_include_rich_text_p(G_GNUC_UNUSED VALUE self, VALUE rbtargets, VALUE rbbuffer) +{ + GtkTextBuffer *buffer = GTK_TEXT_BUFFER(RVAL2GOBJ(rbbuffer)); + long n; + GdkAtom *targets = RVAL2GDKATOMS(rbtargets, &n); + gboolean result; + + result = gtk_targets_include_rich_text(targets, n, buffer); + + g_free(targets); + + return result; +} +#endif + +void +Init_gtk_selection(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGtk, "Selection"); + + RG_DEF_MODFUNC(owner_set, 3); + RG_DEF_MODFUNC(add_target, 4); + RG_DEF_MODFUNC(add_targets, 3); + RG_DEF_MODFUNC(clear_targets, 2); + RG_DEF_MODFUNC(convert, 4); + RG_DEF_MODFUNC(remove_all, 1); + +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_MODFUNC_P(include_image, 2); + RG_DEF_MODFUNC_P(include_text, 1); + RG_DEF_MODFUNC_P(include_uri, 1); + RG_DEF_MODFUNC_P(include_rich_text, 2); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkselectiondata.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkselectiondata.c new file mode 100644 index 0000000..5a7f9c3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkselectiondata.c @@ -0,0 +1,297 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cSelectionData +#define _SELF(d) ((GtkSelectionData*)RVAL2BOXED(d, GTK_TYPE_SELECTION_DATA)) + +static GdkAtom compound_text; + +/************************************************************************/ +void +rbgtk_atom2selectiondata(VALUE type, VALUE size, VALUE src, GdkAtom *gtype, + void **data, gint *format, gint *length) +{ + void* dat = NULL; + gint fmt, len; + GdkAtom ntype = RVAL2ATOM(type); + + if(ntype == GDK_SELECTION_TYPE_INTEGER){ + int *i; + i = ALLOC(int); + *i = NUM2INT(src); + dat = i; + fmt = sizeof(int) * 8; + len = 1; + } else if(ntype == GDK_SELECTION_TYPE_STRING) { + dat = (void *)RVAL2CSTR(src); + if (NIL_P(size)) { + fmt = sizeof(char) * 8; + len = RSTRING_LEN(src); + } else { + len = NUM2UINT(size); + fmt = (RSTRING_LEN(src) / len) * 8; + } + } else if(ntype == compound_text){ + guchar* str = (guchar*)dat; + gdk_string_to_compound_text(RVAL2CSTR(src), &ntype, &fmt, &str, &len); + } else if(type != Qnil && size != Qnil && src != Qnil) { + dat = (void *)RVAL2CSTR(src); + fmt = NUM2INT(size); + len = (RSTRING_LEN(src) * sizeof(char) / fmt); + } else { + rb_raise(rb_eArgError, "no supported type."); + } + + *gtype = ntype; + *data = dat; + *format = fmt; + *length = len; +} + +void +rbgtk_atom2selectiondata_free(GdkAtom type, void *dat) +{ + if (type == GDK_SELECTION_TYPE_INTEGER || + type == GDK_SELECTION_TYPE_ATOM) { + xfree(dat); + } else if(type == compound_text) { + gdk_free_compound_text(dat); + } +} +/************************************************************************/ + +static VALUE +rg_selection(VALUE self) +{ + GdkAtom selection = _SELF(self)->selection; + return BOXED2RVAL(&selection, GDK_TYPE_ATOM); +} + +static VALUE +rg_target(VALUE self) +{ + return BOXED2RVAL(_SELF(self)->target, GDK_TYPE_ATOM); +} + +static VALUE +rg_type(VALUE self) +{ + return BOXED2RVAL(_SELF(self)->type, GDK_TYPE_ATOM); +} + +static VALUE +rg_format(VALUE self) +{ + return INT2NUM(_SELF(self)->format); +} + +static VALUE +rg_data(VALUE self) +{ + return RBG_STRING_SET_UTF8_ENCODING(rb_str_new((const char*)_SELF(self)->data, + _SELF(self)->length)); +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_display(VALUE self) +{ + return BOXED2RVAL(_SELF(self)->display, GDK_TYPE_DISPLAY); +} +#endif + +/* Instance Methods */ +static VALUE +rg_set(int argc, VALUE *argv, VALUE self) +{ + void* dat; + VALUE type, src; + gint fmt, len; + GdkAtom ntype; + VALUE size = Qnil; + + if(3 == argc) + rb_scan_args(argc, argv, "30", &type, &size, &src); + else + rb_scan_args(argc, argv, "20", &type, &src); + + rbgtk_atom2selectiondata(type, size, src, &ntype, &dat, &fmt, &len); + + gtk_selection_data_set(_SELF(self), ntype, fmt, dat, len); + + rbgtk_atom2selectiondata_free(ntype, dat); + + return self; +} + +static VALUE +rg_set_text(VALUE self, VALUE str) +{ + StringValue(str); + + if (!gtk_selection_data_set_text(_SELF(self), RSTRING_PTR(str), RSTRING_LEN(str))) + rb_raise(rb_eRuntimeError, "the selection wasn't successfully set"); + + return self; +} + +static VALUE +rg_text(VALUE self) +{ + return CSTR2RVAL_FREE((gchar *)gtk_selection_data_get_text(_SELF(self))); +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_set_pixbuf(VALUE self, VALUE pixbuf) +{ + if (!gtk_selection_data_set_pixbuf(_SELF(self), GDK_PIXBUF(RVAL2GOBJ(pixbuf)))) + rb_raise(rb_eRuntimeError, "the selection wasn't successfully set"); + + return self; +} + +static VALUE +rg_pixbuf(VALUE self) +{ + return GOBJ2RVAL(gtk_selection_data_get_pixbuf(_SELF(self))); +} + +static VALUE +rg_set_uris(VALUE self, VALUE uris) +{ + gboolean ret; + gchar **guris; + + guris = (gchar **)RVAL2STRV(uris); + ret = gtk_selection_data_set_uris(_SELF(self), guris); + g_free(guris); + if (!ret) + rb_raise(rb_eRuntimeError, "the selection wasn't successfully."); + + return self; +} + +static VALUE +rg_uris(VALUE self) +{ + VALUE ary = rb_ary_new(); + gchar** uris = gtk_selection_data_get_uris(_SELF(self)); + + if (uris) { + gchar **uri = uris; + while (*uri) { + rb_ary_push(ary, CSTR2RVAL(*uri)); + uri++; + } + g_strfreev(uris); + } + return ary; +} +#endif + +static VALUE +rg_targets(VALUE self) +{ + GdkAtom* targets; + gint n_atoms; + VALUE result = Qnil; + gboolean ret = gtk_selection_data_get_targets(_SELF(self), + &targets, &n_atoms); + if (ret) { + int i; + result = rb_ary_new2(n_atoms); + for (i = 0; i < n_atoms; i++){ + rb_ary_push(result, BOXED2RVAL(targets[i], GDK_TYPE_ATOM)); + } + } + g_free(targets); + return result; +} +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_targets_include_image(VALUE self, VALUE writable) +{ + return CBOOL2RVAL(gtk_selection_data_targets_include_image(_SELF(self), RVAL2CBOOL(writable))); +} +#endif + +static VALUE +rg_targets_include_text(VALUE self) +{ + return CBOOL2RVAL(gtk_selection_data_targets_include_text(_SELF(self))); +} + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_targets_include_uri(VALUE self) +{ + return CBOOL2RVAL(gtk_selection_data_targets_include_uri(_SELF(self))); +} +static VALUE +rg_targets_include_rich_text(VALUE self, VALUE buffer) +{ + return CBOOL2RVAL(gtk_selection_data_targets_include_rich_text(_SELF(self), + GTK_TEXT_BUFFER(RVAL2GOBJ(buffer)))); +} +#endif + +void +Init_gtk_selectiondata(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_SELECTION_DATA, "SelectionData", mGtk); + + rbgobj_boxed_not_copy_obj(GTK_TYPE_SELECTION_DATA); + + compound_text = gdk_atom_intern("COMPOUND_TEXT", FALSE); + + RG_DEF_METHOD(selection, 0); + RG_DEF_METHOD(target, 0); + RG_DEF_METHOD(type, 0); + RG_DEF_METHOD(format, 0); + RG_DEF_METHOD(data, 0); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(display, 0); +#endif + + RG_DEF_METHOD(set, -1); + RG_DEF_METHOD(text, 0); + RG_DEF_METHOD(set_text, 1); + +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(pixbuf, 0); + RG_DEF_METHOD(set_pixbuf, 1); + RG_DEF_METHOD(uris, 0); + RG_DEF_METHOD(set_uris, 1); + RG_DEF_METHOD(targets_include_image, 1); +#endif + RG_DEF_METHOD(targets, 0); + RG_DEF_METHOD(targets_include_text, 0); +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD(targets_include_uri, 0); + RG_DEF_METHOD(targets_include_rich_text, 1); +#endif + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkseparator.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkseparator.c new file mode 100644 index 0000000..22aa8af --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkseparator.c @@ -0,0 +1,31 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +void +Init_gtk_separator(VALUE mGtk) +{ + G_DEF_CLASS(GTK_TYPE_SEPARATOR, "Separator", mGtk); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkseparatormenuitem.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkseparatormenuitem.c new file mode 100644 index 0000000..e6c0191 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkseparatormenuitem.c @@ -0,0 +1,39 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cSeparatorMenuItem + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_separator_menu_item_new()); + return Qnil; +} + +void +Init_gtk_separator_menu_item(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_SEPARATOR_MENU_ITEM, "SeparatorMenuItem", mGtk); + + RG_DEF_METHOD(initialize, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkseparatortoolitem.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkseparatortoolitem.c new file mode 100644 index 0000000..0535c55 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkseparatortoolitem.c @@ -0,0 +1,44 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cSeparatorToolItem + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_separator_tool_item_new()); + return Qnil; +} + +#endif + +void +Init_gtk_separatortoolitem(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_SEPARATOR_TOOL_ITEM, "SeparatorToolItem", mGtk); + RG_DEF_METHOD(initialize, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtksettings.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtksettings.c new file mode 100644 index 0000000..3efa473 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtksettings.c @@ -0,0 +1,233 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003,2004 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cSettings + +static VALUE prop_func_table; + +static VALUE +rg_s_default(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(gtk_settings_get_default()); +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_s_get_for_screen(G_GNUC_UNUSED VALUE self, VALUE screen) +{ + return GOBJ2RVAL(gtk_settings_get_for_screen(GDK_SCREEN(RVAL2GOBJ(screen)))); +} +#endif + +/* + * Gtk::Settings.install_property(...) do |spec, str| + * #parse str + * new_val = .... # parse value from string. + * new_val # return new_val or nil if you can't convert the value. + * end + */ +static gboolean +rc_property_parser(const GParamSpec *pspec, const GString *rc_string, GValue *property_value) +{ + VALUE spec = GOBJ2RVAL((gpointer)pspec); + VALUE func = rb_hash_aref(prop_func_table, spec); + VALUE ret = rb_funcall(func, id_call, 2, spec, CSTR2RVAL(rc_string->str)); + if (NIL_P(ret)) { + return FALSE; + } else if (RVAL2CBOOL(ret)){ + rbgobj_rvalue_to_gvalue(ret, property_value); + return TRUE; + } else { + rb_raise(rb_eArgError, "Gtk::Settings#install_property() block should return new value or nil"); + } +} + +static VALUE +rg_s_install_property(VALUE self, VALUE spec) +{ + GParamSpec* pspec = G_PARAM_SPEC(RVAL2GOBJ(spec)); + if (rb_block_given_p()){ + VALUE func = rb_block_proc(); + rb_hash_aset(prop_func_table, spec, func); + gtk_settings_install_property_parser(pspec, (GtkRcPropertyParser)rc_property_parser); + } else { + gtk_settings_install_property(pspec); + } + return self; +} + +static VALUE +settings_rc_property_parse(G_GNUC_UNUSED VALUE self, VALUE rbspec, VALUE rbstring, GtkRcPropertyParser parser) +{ + GParamSpec *spec = RVAL2GOBJ(rbspec); + GString *string = g_string_new(RVAL2CSTR(rbstring)); + GValue property = G_VALUE_INIT; + gboolean parsed; + + g_value_init(&property, spec->value_type); + + parsed = parser(spec, string, &property); + + g_string_free(string, TRUE); + + return parsed ? GVAL2RVAL_UNSET(&property) : Qnil; +} + +static VALUE +rg_s_rc_property_parse_color(VALUE self, VALUE rbspec, VALUE rbstring) +{ + return settings_rc_property_parse(self, rbspec, rbstring, gtk_rc_property_parse_color); +} + +static VALUE +rg_s_rc_property_parse_enum(VALUE self, VALUE rbspec, VALUE rbstring) +{ + return settings_rc_property_parse(self, rbspec, rbstring, gtk_rc_property_parse_enum); +} + +static VALUE +rg_s_rc_property_parse_flags(VALUE self, VALUE rbspec, VALUE rbstring) +{ + return settings_rc_property_parse(self, rbspec, rbstring, gtk_rc_property_parse_flags); +} + +static VALUE +rg_s_rc_property_parse_requisition(G_GNUC_UNUSED VALUE self, VALUE rbspec, VALUE rbstring) +{ + GParamSpec *spec = RVAL2GOBJ(rbspec); + GString *string = g_string_new(RVAL2CSTR(rbstring)); + GValue property = G_VALUE_INIT; + gboolean parsed; + GtkRequisition *requisition; + gint width; + gint height; + + g_value_init(&property, GTK_TYPE_REQUISITION); + + parsed = gtk_rc_property_parse_requisition(spec, string, &property); + + g_string_free(string, TRUE); + + if (!parsed) + return Qnil; + + requisition = g_value_get_boxed(&property); + width = requisition->width; + height = requisition->height; + + g_value_unset(&property); + + return rb_assoc_new(INT2NUM(width), INT2NUM(height)); +} + +static VALUE +settings_rc_property_parse_border_result(VALUE value) +{ + return BOXED2RVAL(g_value_get_boxed((GValue *)value), GTK_TYPE_BORDER); +} + +static VALUE +settings_rc_property_parse_border_ensure(VALUE value) +{ + g_value_unset((GValue *)value); + + return Qnil; +} + +static VALUE +rg_s_rc_property_parse_border(G_GNUC_UNUSED VALUE self, VALUE rbspec, VALUE rbstring) +{ + GParamSpec *spec = RVAL2GOBJ(rbspec); + GString *string = g_string_new(RVAL2CSTR(rbstring)); + GValue property = G_VALUE_INIT; + gboolean parsed; + + g_value_init(&property, GTK_TYPE_BORDER); + + parsed = gtk_rc_property_parse_border(spec, string, &property); + + g_string_free(string, TRUE); + + if (!parsed) + return Qnil; + + return rb_ensure(settings_rc_property_parse_border_result, (VALUE)&property, + settings_rc_property_parse_border_ensure, (VALUE)&property); +} + +static VALUE +rg_set_property_value(VALUE self, VALUE rbname, VALUE rbvalue, VALUE origin) +{ + GtkSettings *settings = GTK_SETTINGS(RVAL2GOBJ(self)); + GtkSettingsValue svalue = { (gchar *)RVAL2CSTR(origin), G_VALUE_INIT }; + const gchar *name = RVAL2CSTR(rbname); + g_value_init(&svalue.value, RVAL2GTYPE(rbvalue)); + rbgobj_rvalue_to_gvalue(rbvalue, &svalue.value); + + gtk_settings_set_property_value(settings, name, &svalue); + + g_value_unset(&svalue.value); + + return self; +} + +/* We don't need them, Use set_property_value() instead. +void gtk_settings_set_string_property + (GtkSettings *settings, + const gchar *name, + const gchar *v_string, + const gchar *origin); +void gtk_settings_set_long_property (GtkSettings *settings, + const gchar *name, + glong v_long, + const gchar *origin); +void gtk_settings_set_double_property + (GtkSettings *settings, + const gchar *name, + gdouble v_double, + const gchar *origin); +*/ + +void +Init_gtk_settings(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_SETTINGS, "Settings", mGtk); + + rb_global_variable(&prop_func_table); + prop_func_table = rb_hash_new(); + + RG_DEF_SMETHOD(default, 0); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_SMETHOD(get_for_screen, 1); +#endif + RG_DEF_SMETHOD(install_property, 1); + + RG_DEF_SMETHOD(rc_property_parse_color, 2); + RG_DEF_SMETHOD(rc_property_parse_enum, 2); + RG_DEF_SMETHOD(rc_property_parse_flags, 2); + RG_DEF_SMETHOD(rc_property_parse_requisition, 2); + RG_DEF_SMETHOD(rc_property_parse_border, 2); + + RG_DEF_METHOD(set_property_value, 3); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtksizegroup.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtksizegroup.c new file mode 100644 index 0000000..b46a425 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtksizegroup.c @@ -0,0 +1,73 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003-2005 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 OGASAWARA, Takeshi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cSizeGroup +#define _SELF(self) (GTK_SIZE_GROUP(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(VALUE self, VALUE mode) +{ + G_INITIALIZE(self, gtk_size_group_new(RVAL2GENUM(mode, GTK_TYPE_SIZE_GROUP_MODE))); + return Qnil; +} + +static VALUE +rg_add_widget(VALUE self, VALUE widget) +{ + gtk_size_group_add_widget(_SELF(self), GTK_WIDGET(RVAL2GOBJ(widget))); + return self; +} + +static VALUE +rg_remove_widget(VALUE self, VALUE widget) +{ + gtk_size_group_remove_widget(_SELF(self), GTK_WIDGET(RVAL2GOBJ(widget))); + return self; +} + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_widgets(VALUE self) +{ + return GSLIST2ARY(gtk_size_group_get_widgets(_SELF(self))); +} +#endif + +void +Init_gtk_size_group(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_SIZE_GROUP, "SizeGroup", mGtk); + + RG_DEF_METHOD(initialize, 1); + RG_DEF_METHOD(add_widget, 1); + RG_DEF_METHOD(remove_widget, 1); + +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD(widgets, 0); +#endif + + /* GtkSizeGroupMode */ + G_DEF_CLASS(GTK_TYPE_SIZE_GROUP_MODE, "Mode", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_SIZE_GROUP_MODE, "GTK_SIZE_GROUP_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtksocket.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtksocket.c new file mode 100644 index 0000000..7739eab --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtksocket.c @@ -0,0 +1,80 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 2002 Neil Conway + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#ifdef HAVE_GTK_SOCKET_GET_TYPE + +#define RG_TARGET_NAMESPACE cSocket +#define _SELF(self) GTK_SOCKET(RVAL2GOBJ(self)) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_socket_new()); + return Qnil; +} + +static VALUE +rg_add_id(VALUE self, VALUE wid) +{ + gtk_socket_add_id(_SELF(self), +#ifdef GDK_NATIVE_WINDOW_POINTER + GUINT_TO_POINTER(NUM2ULONG(wid)) +#else + (guint32)NUM2UINT(wid) +#endif + ); + return self; +} + +static VALUE +rg_plug_window(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->plug_window); +} + +static VALUE +rg_id(VALUE self) +{ + GdkNativeWindow id = gtk_socket_get_id(_SELF(self)); +#ifdef GDK_NATIVE_WINDOW_POINTER + return UINT2NUM(GPOINTER_TO_UINT(id)); +#else + return UINT2NUM(id); +#endif +} + +#endif /* HAVE_GTK_SOCKET_GET_TYPE */ + +void +Init_gtk_socket(VALUE mGtk) +{ +#ifdef HAVE_GTK_SOCKET_GET_TYPE + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_SOCKET, "Socket", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(plug_window, 0); + RG_DEF_METHOD(add_id, 1); + RG_DEF_METHOD(id, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkspinbutton.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkspinbutton.c new file mode 100644 index 0000000..c906953 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkspinbutton.c @@ -0,0 +1,137 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2004 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cSpinButton +#define _SELF(self) (GTK_SPIN_BUTTON(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE arg1, arg2, arg3; + GtkAdjustment *adj = NULL; + gfloat climb_rate; + gint digits; + GtkWidget *widget; + + rb_scan_args(argc, argv, "03", &arg1, &arg2, &arg3); + + if (NIL_P(arg1) || RVAL2GTYPE(arg1) == GTK_TYPE_ADJUSTMENT){ + if (!NIL_P(arg1)) adj = GTK_ADJUSTMENT(RVAL2GOBJ(arg1)); + climb_rate = (NIL_P(arg2))? 0.0: NUM2DBL(arg2); + digits = (NIL_P(arg3))? 0: NUM2UINT(arg3); + widget = gtk_spin_button_new(adj, climb_rate, digits); + } else { + widget = gtk_spin_button_new_with_range(NUM2DBL(arg1), + NUM2DBL(arg2), NUM2DBL(arg3)); + } + RBGTK_INITIALIZE(self, widget); + return Qnil; +} + +static VALUE +rg_configure(VALUE self, VALUE adj, VALUE climb_rate, VALUE digits) +{ + gtk_spin_button_configure(_SELF(self), GTK_ADJUSTMENT(RVAL2GOBJ(adj)), + NUM2DBL(climb_rate), NUM2UINT(digits)); + return self; +} + +static VALUE +rg_set_increments(VALUE self, VALUE step, VALUE page) +{ + gtk_spin_button_set_increments(_SELF(self), NUM2DBL(step), NUM2DBL(page)); + return self; +} + +static VALUE +rg_set_range(VALUE self, VALUE min, VALUE max) +{ + gtk_spin_button_set_range(_SELF(self), NUM2DBL(min), NUM2DBL(max)); + return self; +} + +static VALUE +rg_value_as_int(VALUE self) +{ + return INT2NUM(gtk_spin_button_get_value_as_int(_SELF(self))); +} + +static VALUE +rg_spin(VALUE self, VALUE direction, VALUE increment) +{ + gtk_spin_button_spin(_SELF(self), RVAL2GENUM(direction, GTK_TYPE_SPIN_TYPE), + NUM2DBL(increment)); + return self; +} + +static VALUE +rg_update(VALUE self) +{ + gtk_spin_button_update(_SELF(self)); + return self; +} + +static VALUE +rg_increments(VALUE self) +{ + gdouble step, page; + gtk_spin_button_get_increments(_SELF(self), &step, &page); + + return rb_ary_new3(2, rb_float_new(step), rb_float_new(page)); +} + +static VALUE +rg_range(VALUE self) +{ + gdouble min, max; + gtk_spin_button_get_range(_SELF(self), &min, &max); + + return rb_ary_new3(2, rb_float_new(min), rb_float_new(max)); +} + +void +Init_gtk_spin_button(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_SPIN_BUTTON, "SpinButton", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(configure, 3); + RG_DEF_METHOD(set_increments, 2); + RG_DEF_METHOD(set_range, 2); + RG_DEF_METHOD(value_as_int, 0); + RG_DEF_METHOD(spin, 2); + RG_DEF_METHOD(update, 0); + RG_DEF_METHOD(increments, 0); + RG_DEF_METHOD(range, 0); + + /* GtkSpinType */ + G_DEF_CLASS(GTK_TYPE_SPIN_TYPE, "Type", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_SPIN_TYPE, "GTK_SPIN_"); + + /* GtkSpinButtonUpdatePolicy */ + G_DEF_CLASS(GTK_TYPE_SPIN_BUTTON_UPDATE_POLICY, "UpdatePolicy", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_SPIN_BUTTON_UPDATE_POLICY, "GTK_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkspinner.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkspinner.c new file mode 100644 index 0000000..5718a9e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkspinner.c @@ -0,0 +1,61 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,20,0) + +#define RG_TARGET_NAMESPACE cSpinner +#define _SELF(s) (GTK_SPINNER(RVAL2GOBJ(s))) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_spinner_new()); + return Qnil; +} + +static VALUE +rg_start(VALUE self) +{ + gtk_spinner_start(_SELF(self)); + return self; +} + +static VALUE +rg_stop(VALUE self) +{ + gtk_spinner_stop(_SELF(self)); + return self; +} + +#endif + +void +Init_gtk_spinner(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,20,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_SPINNER, "Spinner", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(start, 0); + RG_DEF_METHOD(stop, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkstatusbar.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkstatusbar.c new file mode 100644 index 0000000..f99b5db --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkstatusbar.c @@ -0,0 +1,77 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cStatusbar +#define _SELF(self) (GTK_STATUSBAR(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_statusbar_new()); + return Qnil; +} + +static VALUE +rg_get_context_id(VALUE self, VALUE text) +{ + + return INT2FIX(gtk_statusbar_get_context_id(_SELF(self), + RVAL2CSTR(text))); +} + +static VALUE +rg_push(VALUE self, VALUE id, VALUE text) +{ + return INT2FIX(gtk_statusbar_push(_SELF(self), + NUM2INT(id), RVAL2CSTR(text))); +} + +static VALUE +rg_pop(VALUE self, VALUE id) +{ + gtk_statusbar_pop(_SELF(self), NUM2INT(id)); + return self; + +} + +static VALUE +rg_remove(VALUE self, VALUE cid, VALUE mid) +{ + gtk_statusbar_remove(_SELF(self), NUM2INT(cid), NUM2INT(mid)); + return self; +} + +void +Init_gtk_statusbar(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_STATUSBAR, "Statusbar", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(get_context_id, 1); + RG_DEF_METHOD(push, 2); + RG_DEF_METHOD(pop, 1); + RG_DEF_METHOD(remove, 2); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkstatusicon.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkstatusicon.c new file mode 100644 index 0000000..67f45b7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkstatusicon.c @@ -0,0 +1,95 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,10,0) + +#define RG_TARGET_NAMESPACE cStatusIcon +#define _SELF(w) (GTK_STATUS_ICON(RVAL2GOBJ(w))) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, gtk_status_icon_new()); + return Qnil; +} + +/* Don't implement this. Use Gtk::StatusIcon.new.set_foo(v) instead. +GtkStatusIcon* gtk_status_icon_new_from_pixbuf + (GdkPixbuf *pixbuf); +GtkStatusIcon* gtk_status_icon_new_from_file + (const gchar *filename); +GtkStatusIcon* gtk_status_icon_new_from_stock + (const gchar *stock_id); +GtkStatusIcon* gtk_status_icon_new_from_icon_name + (const gchar *icon_name); +*/ + +static VALUE +rg_set_tooltip(VALUE self, VALUE tooltip_text) +{ + gtk_status_icon_set_tooltip(_SELF(self), RVAL2CSTR(tooltip_text)); + return self; +} + +static VALUE +rg_position_menu(VALUE self, VALUE menu) +{ + gint x, y; + gboolean push_in; + + gtk_status_icon_position_menu(GTK_MENU(RVAL2GOBJ(menu)), &x, &y, &push_in, + (gpointer)(_SELF(self))); + return rb_ary_new3(3, INT2NUM(x), INT2NUM(y), CBOOL2RVAL(push_in)); +} + +static VALUE +rg_geometry(VALUE self) +{ + GdkScreen* screen; + GdkRectangle area; + GtkOrientation orientation; + gboolean ret = gtk_status_icon_get_geometry(_SELF(self), &screen, + &area, &orientation); + if (ret) { + return rb_ary_new3(3, GOBJ2RVAL(screen), + BOXED2RVAL(&area, GDK_TYPE_RECTANGLE), + GENUM2RVAL(orientation, GTK_TYPE_ORIENTATION)); + } else { + return rb_ary_new3(3, Qnil, Qnil, Qnil); + } +} +#endif + +void +Init_gtk_status_icon(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,10,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_STATUS_ICON, "StatusIcon", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(set_tooltip, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "tooltip"); + RG_DEF_METHOD(position_menu, 1); + RG_DEF_METHOD(geometry, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkstock.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkstock.c new file mode 100644 index 0000000..03963e3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkstock.c @@ -0,0 +1,268 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 KUBO Takehiro + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE mStock + +#define Check_Symbol(sym) do { \ + if (!SYMBOL_P(sym)) \ + rb_raise(rb_eArgError, "invalid argument %s (expect Symbol)", \ + rb_class2name(CLASS_OF(sym))); \ +} while (0) + +/* check whether sym is a Symbol or not in advance. */ +#define SYM2CSTR(sym) rb_id2name(SYM2ID(sym)) +#define CSTR2SYM(str) ID2SYM(rb_intern(str)) + +static VALUE +rg_s_add(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE stock_id, label, modifier, keyval, translation_domain; + GtkStockItem item; + + rb_scan_args(argc, argv, "23", &stock_id, &label, &modifier, &keyval, &translation_domain); + Check_Symbol(stock_id); + item.stock_id = (gchar *)SYM2CSTR(stock_id); + item.label = (gchar *)RVAL2CSTR(label); + item.modifier = NIL_P(modifier) ? 0 : NUM2UINT(modifier); + item.keyval = NIL_P(keyval) ? 0 : NUM2UINT(keyval); + item.translation_domain = NIL_P(translation_domain) ? NULL : (gchar *)RVAL2CSTR(translation_domain); + gtk_stock_add(&item, 1); + return Qnil; +} + +static VALUE +rg_s_lookup(G_GNUC_UNUSED VALUE self, VALUE stock_id) +{ + GtkStockItem item; + + Check_Symbol(stock_id); + if (gtk_stock_lookup(SYM2CSTR(stock_id), &item)) { + return rb_ary_new3(5, + CSTR2SYM(item.stock_id), + CSTR2RVAL(item.label), + UINT2NUM(item.modifier), + UINT2NUM(item.keyval), + CSTR2RVAL(item.translation_domain)); + } + rb_raise(rb_eArgError, "no such stock-id: %s", SYM2CSTR(stock_id)); +} + +static VALUE +rg_s_ids(G_GNUC_UNUSED VALUE self) +{ + GSList *ids = gtk_stock_list_ids(); + GSList *l; + VALUE ary = rb_ary_new(); + for (l = ids; l != NULL; l = g_slist_next(l)) { + rb_ary_push(ary, CSTR2SYM(l->data)); + g_free(l->data); + } + g_slist_free(ids); + return ary; +} + +#if GTK_CHECK_VERSION(2,8,0) +static gchar * +translate_func(const gchar *path, gpointer func) +{ + VALUE ret = rb_funcall((VALUE)func, id_call, 1, CSTR2RVAL(path)); + return (gchar *)RVAL2CSTR(ret); +} + +static VALUE +rg_s_set_translate_func(VALUE klass, VALUE domain) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(klass, func); + gtk_stock_set_translate_func(RVAL2CSTR(domain), + (GtkTranslateFunc)translate_func, + (gpointer)func, + NULL); + return Qnil; +} +#endif + +void +Init_gtk_stock(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGtk, "Stock"); + + rb_undef_method(RG_TARGET_NAMESPACE, "new"); + RG_DEF_SMETHOD(add, -1); + RG_DEF_SMETHOD(lookup, 1); + RG_DEF_SMETHOD(ids, 0); +#if GTK_CHECK_VERSION(2,8,0) + RG_DEF_SMETHOD(set_translate_func, 1); +#endif + + /* Stock IDs (not all are stock items; some are images only) */ +#if GTK_CHECK_VERSION(2,6,0) + rb_define_const(RG_TARGET_NAMESPACE, "ABOUT", CSTR2SYM(GTK_STOCK_ABOUT)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "ADD", CSTR2SYM(GTK_STOCK_ADD)); + rb_define_const(RG_TARGET_NAMESPACE, "APPLY", CSTR2SYM(GTK_STOCK_APPLY)); + rb_define_const(RG_TARGET_NAMESPACE, "BOLD", CSTR2SYM(GTK_STOCK_BOLD)); + rb_define_const(RG_TARGET_NAMESPACE, "CANCEL", CSTR2SYM(GTK_STOCK_CANCEL)); +#if GTK_CHECK_VERSION(2,16,0) + rb_define_const(RG_TARGET_NAMESPACE, "CAPS_LOCK_WARNING", CSTR2SYM(GTK_STOCK_CAPS_LOCK_WARNING)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "CDROM", CSTR2SYM(GTK_STOCK_CDROM)); + rb_define_const(RG_TARGET_NAMESPACE, "CLEAR", CSTR2SYM(GTK_STOCK_CLEAR)); + rb_define_const(RG_TARGET_NAMESPACE, "CLOSE", CSTR2SYM(GTK_STOCK_CLOSE)); +#if GTK_CHECK_VERSION(2,2,0) + rb_define_const(RG_TARGET_NAMESPACE, "COLOR_PICKER", CSTR2SYM(GTK_STOCK_COLOR_PICKER)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "CONVERT", CSTR2SYM(GTK_STOCK_CONVERT)); +#if GTK_CHECK_VERSION(2,6,0) + rb_define_const(RG_TARGET_NAMESPACE, "CONNECT", CSTR2SYM(GTK_STOCK_CONNECT)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "COPY", CSTR2SYM(GTK_STOCK_COPY)); + rb_define_const(RG_TARGET_NAMESPACE, "CUT", CSTR2SYM(GTK_STOCK_CUT)); + rb_define_const(RG_TARGET_NAMESPACE, "DELETE", CSTR2SYM(GTK_STOCK_DELETE)); +#if GTK_CHECK_VERSION(2,4,0) + rb_define_const(RG_TARGET_NAMESPACE, "DIALOG_AUTHENTICATION", CSTR2SYM(GTK_STOCK_DIALOG_AUTHENTICATION)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "DIALOG_ERROR", CSTR2SYM(GTK_STOCK_DIALOG_ERROR)); + rb_define_const(RG_TARGET_NAMESPACE, "DIALOG_INFO", CSTR2SYM(GTK_STOCK_DIALOG_INFO)); + rb_define_const(RG_TARGET_NAMESPACE, "DIALOG_QUESTION", CSTR2SYM(GTK_STOCK_DIALOG_QUESTION)); + rb_define_const(RG_TARGET_NAMESPACE, "DIALOG_WARNING", CSTR2SYM(GTK_STOCK_DIALOG_WARNING)); +#if GTK_CHECK_VERSION(2,6,0) + rb_define_const(RG_TARGET_NAMESPACE, "DIRECTORY", CSTR2SYM(GTK_STOCK_DIRECTORY)); +#endif +#if GTK_CHECK_VERSION(2,12,0) + rb_define_const(RG_TARGET_NAMESPACE, "DISCARD", CSTR2SYM(GTK_STOCK_DISCARD)); +#endif +#if GTK_CHECK_VERSION(2,6,0) + rb_define_const(RG_TARGET_NAMESPACE, "DISCONNECT", CSTR2SYM(GTK_STOCK_DISCONNECT)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "DND", CSTR2SYM(GTK_STOCK_DND)); + rb_define_const(RG_TARGET_NAMESPACE, "DND_MULTIPLE", CSTR2SYM(GTK_STOCK_DND_MULTIPLE)); +#if GTK_CHECK_VERSION(2,6,0) + rb_define_const(RG_TARGET_NAMESPACE, "EDIT", CSTR2SYM(GTK_STOCK_EDIT)); + rb_define_const(RG_TARGET_NAMESPACE, "FILE", CSTR2SYM(GTK_STOCK_FILE)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "EXECUTE", CSTR2SYM(GTK_STOCK_EXECUTE)); + rb_define_const(RG_TARGET_NAMESPACE, "FIND", CSTR2SYM(GTK_STOCK_FIND)); + rb_define_const(RG_TARGET_NAMESPACE, "FIND_AND_REPLACE", CSTR2SYM(GTK_STOCK_FIND_AND_REPLACE)); + rb_define_const(RG_TARGET_NAMESPACE, "FLOPPY", CSTR2SYM(GTK_STOCK_FLOPPY)); +#if GTK_CHECK_VERSION(2,8,0) + rb_define_const(RG_TARGET_NAMESPACE, "FULLSCREEN", CSTR2SYM(GTK_STOCK_FULLSCREEN)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "GOTO_BOTTOM", CSTR2SYM(GTK_STOCK_GOTO_BOTTOM)); + rb_define_const(RG_TARGET_NAMESPACE, "GOTO_FIRST", CSTR2SYM(GTK_STOCK_GOTO_FIRST)); + rb_define_const(RG_TARGET_NAMESPACE, "GOTO_LAST", CSTR2SYM(GTK_STOCK_GOTO_LAST)); + rb_define_const(RG_TARGET_NAMESPACE, "GOTO_TOP", CSTR2SYM(GTK_STOCK_GOTO_TOP)); + rb_define_const(RG_TARGET_NAMESPACE, "GO_BACK", CSTR2SYM(GTK_STOCK_GO_BACK)); + rb_define_const(RG_TARGET_NAMESPACE, "GO_DOWN", CSTR2SYM(GTK_STOCK_GO_DOWN)); + rb_define_const(RG_TARGET_NAMESPACE, "GO_FORWARD", CSTR2SYM(GTK_STOCK_GO_FORWARD)); + rb_define_const(RG_TARGET_NAMESPACE, "GO_UP", CSTR2SYM(GTK_STOCK_GO_UP)); +#if GTK_CHECK_VERSION(2,4,0) + rb_define_const(RG_TARGET_NAMESPACE, "HARDDISK", CSTR2SYM(GTK_STOCK_HARDDISK)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "HELP", CSTR2SYM(GTK_STOCK_HELP)); + rb_define_const(RG_TARGET_NAMESPACE, "HOME", CSTR2SYM(GTK_STOCK_HOME)); +#if GTK_CHECK_VERSION(2,4,0) + rb_define_const(RG_TARGET_NAMESPACE, "INDENT", CSTR2SYM(GTK_STOCK_INDENT)); +#endif +#if GTK_CHECK_VERSION(2,8,0) + rb_define_const(RG_TARGET_NAMESPACE, "INFO", CSTR2SYM(GTK_STOCK_INFO)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "INDEX", CSTR2SYM(GTK_STOCK_INDEX)); + rb_define_const(RG_TARGET_NAMESPACE, "ITALIC", CSTR2SYM(GTK_STOCK_ITALIC)); + rb_define_const(RG_TARGET_NAMESPACE, "JUMP_TO", CSTR2SYM(GTK_STOCK_JUMP_TO)); + rb_define_const(RG_TARGET_NAMESPACE, "JUSTIFY_CENTER", CSTR2SYM(GTK_STOCK_JUSTIFY_CENTER)); + rb_define_const(RG_TARGET_NAMESPACE, "JUSTIFY_FILL", CSTR2SYM(GTK_STOCK_JUSTIFY_FILL)); + rb_define_const(RG_TARGET_NAMESPACE, "JUSTIFY_LEFT", CSTR2SYM(GTK_STOCK_JUSTIFY_LEFT)); + rb_define_const(RG_TARGET_NAMESPACE, "JUSTIFY_RIGHT", CSTR2SYM(GTK_STOCK_JUSTIFY_RIGHT)); +#if GTK_CHECK_VERSION(2,8,0) + rb_define_const(RG_TARGET_NAMESPACE, "LEAVE_FULLSCREEN", CSTR2SYM(GTK_STOCK_LEAVE_FULLSCREEN)); +#endif +#if GTK_CHECK_VERSION(2,6,0) + rb_define_const(RG_TARGET_NAMESPACE, "MEDIA_FORWARD", CSTR2SYM(GTK_STOCK_MEDIA_FORWARD)); + rb_define_const(RG_TARGET_NAMESPACE, "MEDIA_NEXT", CSTR2SYM(GTK_STOCK_MEDIA_NEXT)); + rb_define_const(RG_TARGET_NAMESPACE, "MEDIA_PAUSE", CSTR2SYM(GTK_STOCK_MEDIA_PAUSE)); + rb_define_const(RG_TARGET_NAMESPACE, "MEDIA_PLAY", CSTR2SYM(GTK_STOCK_MEDIA_PLAY)); + rb_define_const(RG_TARGET_NAMESPACE, "MEDIA_PREVIOUS", CSTR2SYM(GTK_STOCK_MEDIA_PREVIOUS)); + rb_define_const(RG_TARGET_NAMESPACE, "MEDIA_RECORD", CSTR2SYM(GTK_STOCK_MEDIA_RECORD)); + rb_define_const(RG_TARGET_NAMESPACE, "MEDIA_REWIND", CSTR2SYM(GTK_STOCK_MEDIA_REWIND)); + rb_define_const(RG_TARGET_NAMESPACE, "MEDIA_STOP", CSTR2SYM(GTK_STOCK_MEDIA_STOP)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "MISSING_IMAGE", CSTR2SYM(GTK_STOCK_MISSING_IMAGE)); +#if GTK_CHECK_VERSION(2,4,0) + rb_define_const(RG_TARGET_NAMESPACE, "NETWORK", CSTR2SYM(GTK_STOCK_NETWORK)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "NEW", CSTR2SYM(GTK_STOCK_NEW)); + rb_define_const(RG_TARGET_NAMESPACE, "NO", CSTR2SYM(GTK_STOCK_NO)); + rb_define_const(RG_TARGET_NAMESPACE, "OK", CSTR2SYM(GTK_STOCK_OK)); + rb_define_const(RG_TARGET_NAMESPACE, "OPEN", CSTR2SYM(GTK_STOCK_OPEN)); +#if GTK_CHECK_VERSION(2,10,0) + rb_define_const(RG_TARGET_NAMESPACE, "ORIENTATION_LANDSCAPE", CSTR2SYM(GTK_STOCK_ORIENTATION_LANDSCAPE)); + rb_define_const(RG_TARGET_NAMESPACE, "ORIENTATION_PORTRAIT", CSTR2SYM(GTK_STOCK_ORIENTATION_PORTRAIT)); + rb_define_const(RG_TARGET_NAMESPACE, "ORIENTATION_REVERSE_LANDSCAPE", CSTR2SYM(GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE)); + rb_define_const(RG_TARGET_NAMESPACE, "ORIENTATION_REVERSE_PORTRAIT", CSTR2SYM(GTK_STOCK_ORIENTATION_REVERSE_PORTRAIT)); +#endif +#if GTK_CHECK_VERSION(2,14,0) + rb_define_const(RG_TARGET_NAMESPACE, "PAGE_SETUP", CSTR2SYM(GTK_STOCK_PAGE_SETUP)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "PASTE", CSTR2SYM(GTK_STOCK_PASTE)); + rb_define_const(RG_TARGET_NAMESPACE, "PREFERENCES", CSTR2SYM(GTK_STOCK_PREFERENCES)); + rb_define_const(RG_TARGET_NAMESPACE, "PRINT", CSTR2SYM(GTK_STOCK_PRINT)); +#if GTK_CHECK_VERSION(2,14,0) + rb_define_const(RG_TARGET_NAMESPACE, "PRINT_ERROR", CSTR2SYM(GTK_STOCK_PRINT_ERROR)); + rb_define_const(RG_TARGET_NAMESPACE, "PRINT_PAUSED", CSTR2SYM(GTK_STOCK_PRINT_PAUSED)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "PRINT_PREVIEW", CSTR2SYM(GTK_STOCK_PRINT_PREVIEW)); +#if GTK_CHECK_VERSION(2,14,0) + rb_define_const(RG_TARGET_NAMESPACE, "PRINT_REPORT", CSTR2SYM(GTK_STOCK_PRINT_REPORT)); + rb_define_const(RG_TARGET_NAMESPACE, "PRINT_WARNING", CSTR2SYM(GTK_STOCK_PRINT_WARNING)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "PROPERTIES", CSTR2SYM(GTK_STOCK_PROPERTIES)); + rb_define_const(RG_TARGET_NAMESPACE, "QUIT", CSTR2SYM(GTK_STOCK_QUIT)); + rb_define_const(RG_TARGET_NAMESPACE, "REDO", CSTR2SYM(GTK_STOCK_REDO)); + rb_define_const(RG_TARGET_NAMESPACE, "REFRESH", CSTR2SYM(GTK_STOCK_REFRESH)); + rb_define_const(RG_TARGET_NAMESPACE, "REMOVE", CSTR2SYM(GTK_STOCK_REMOVE)); + rb_define_const(RG_TARGET_NAMESPACE, "REVERT_TO_SAVED", CSTR2SYM(GTK_STOCK_REVERT_TO_SAVED)); + rb_define_const(RG_TARGET_NAMESPACE, "SAVE", CSTR2SYM(GTK_STOCK_SAVE)); + rb_define_const(RG_TARGET_NAMESPACE, "SAVE_AS", CSTR2SYM(GTK_STOCK_SAVE_AS)); +#if GTK_CHECK_VERSION(2,10,0) + rb_define_const(RG_TARGET_NAMESPACE, "SELECT_ALL", CSTR2SYM(GTK_STOCK_SELECT_ALL)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "SELECT_COLOR", CSTR2SYM(GTK_STOCK_SELECT_COLOR)); + rb_define_const(RG_TARGET_NAMESPACE, "SELECT_FONT", CSTR2SYM(GTK_STOCK_SELECT_FONT)); + rb_define_const(RG_TARGET_NAMESPACE, "SORT_ASCENDING", CSTR2SYM(GTK_STOCK_SORT_ASCENDING)); + rb_define_const(RG_TARGET_NAMESPACE, "SORT_DESCENDING", CSTR2SYM(GTK_STOCK_SORT_DESCENDING)); + rb_define_const(RG_TARGET_NAMESPACE, "SPELL_CHECK", CSTR2SYM(GTK_STOCK_SPELL_CHECK)); + rb_define_const(RG_TARGET_NAMESPACE, "STOP", CSTR2SYM(GTK_STOCK_STOP)); + rb_define_const(RG_TARGET_NAMESPACE, "STRIKETHROUGH", CSTR2SYM(GTK_STOCK_STRIKETHROUGH)); + rb_define_const(RG_TARGET_NAMESPACE, "UNDELETE", CSTR2SYM(GTK_STOCK_UNDELETE)); + rb_define_const(RG_TARGET_NAMESPACE, "UNDERLINE", CSTR2SYM(GTK_STOCK_UNDERLINE)); + rb_define_const(RG_TARGET_NAMESPACE, "UNDO", CSTR2SYM(GTK_STOCK_UNDO)); +#if GTK_CHECK_VERSION(2,4,0) + rb_define_const(RG_TARGET_NAMESPACE, "UNINDENT", CSTR2SYM(GTK_STOCK_UNINDENT)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "YES", CSTR2SYM(GTK_STOCK_YES)); + rb_define_const(RG_TARGET_NAMESPACE, "ZOOM_100", CSTR2SYM(GTK_STOCK_ZOOM_100)); + rb_define_const(RG_TARGET_NAMESPACE, "ZOOM_FIT", CSTR2SYM(GTK_STOCK_ZOOM_FIT)); + rb_define_const(RG_TARGET_NAMESPACE, "ZOOM_IN", CSTR2SYM(GTK_STOCK_ZOOM_IN)); + rb_define_const(RG_TARGET_NAMESPACE, "ZOOM_OUT", CSTR2SYM(GTK_STOCK_ZOOM_OUT)); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkstyle.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkstyle.c new file mode 100644 index 0000000..ba00369 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkstyle.c @@ -0,0 +1,650 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cStyle +#define _SELF(w) GTK_STYLE(RVAL2GOBJ(w)) +#define RVAL2REC(r) (NIL_P(r) ? NULL : (GdkRectangle*)RVAL2BOXED(r, GDK_TYPE_RECTANGLE)) +#define RVAL2ICONSOURCE(s) ((GtkIconSource*)RVAL2BOXED(s, GTK_TYPE_ICON_SOURCE)) +#define RVAL2STATE(s) (RVAL2GENUM(s, GTK_TYPE_STATE_TYPE)) +#define RVAL2SHADOW(s) (RVAL2GENUM(s, GTK_TYPE_SHADOW_TYPE)) +#define RVAL2ARROW(s) (RVAL2GENUM(s, GTK_TYPE_ARROW_TYPE)) +#define RVAL2GAP(s) (RVAL2GENUM(s, GTK_TYPE_POSITION_TYPE)) +#define RVAL2ORI(s) (RVAL2GENUM(s, GTK_TYPE_ORIENTATION)) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, gtk_style_new()); + return Qnil; +} + +static VALUE +rg_attached_p(VALUE self) +{ + return CBOOL2RVAL(GTK_STYLE_ATTACHED(_SELF(self))); +} + +static VALUE +rg_copy(VALUE self) +{ + return GOBJ2RVAL(gtk_style_copy(_SELF(self))); +} + +static VALUE +rg_attach(VALUE self, VALUE win) +{ + return GOBJ2RVAL(gtk_style_attach(_SELF(self), + GDK_WINDOW(RVAL2GOBJ(win)))); +} + +static VALUE +rg_detach(VALUE self) +{ + gtk_style_detach(_SELF(self)); + return self; +} + +static VALUE +rg_set_background(VALUE self, VALUE win, VALUE state_type) +{ + gtk_style_set_background(_SELF(self), GDK_WINDOW(RVAL2GOBJ(win)), + RVAL2STATE(state_type)); + return self; +} + +static VALUE +rg_apply_default_background(VALUE self, VALUE gdkwindow, VALUE set_bg, VALUE state_type, VALUE area, VALUE x, VALUE y, VALUE width, VALUE height) +{ + gtk_style_apply_default_background(_SELF(self), + GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2CBOOL(set_bg), RVAL2STATE(state_type), + RVAL2REC(area), + NUM2INT(x), NUM2INT(y), + NUM2INT(width), NUM2INT(height)); + return self; +} + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_lookup_color(VALUE self, VALUE color_name) +{ + GdkColor color; + if (gtk_style_lookup_color(_SELF(self), RVAL2CSTR(color_name), &color)){ + return GDKCOLOR2RVAL(&color); + } else { + return Qnil; + } +} +#endif + +static VALUE +rg_lookup_icon_set(VALUE self, VALUE stock_id) +{ + const gchar *id; + GtkIconSet *ret; + if (TYPE(stock_id) == T_STRING) { + id = RVAL2CSTR(stock_id); + } else { + id = rb_id2name(SYM2ID(stock_id)); + } + + ret = gtk_style_lookup_icon_set(_SELF(self), id); + return BOXED2RVAL(ret, GTK_TYPE_ICON_SET); +} + +static VALUE +rg_render_icon(VALUE self, VALUE source, VALUE direction, VALUE state, VALUE size, VALUE widget, VALUE detail) +{ + return GOBJ2RVAL(gtk_style_render_icon(_SELF(self), RVAL2ICONSOURCE(source), + RVAL2GENUM(direction, GTK_TYPE_TEXT_DIRECTION), + RVAL2STATE(state), + RVAL2GENUM(size, GTK_TYPE_ICON_SIZE), + GTK_WIDGET(RVAL2GOBJ(widget)), + RVAL2CSTR(detail))); +} + +static VALUE +rg_paint_arrow(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE shadow_type, VALUE area, VALUE widget, VALUE detail, VALUE arrow_type, VALUE fill, VALUE x, VALUE y, VALUE width, VALUE height) +{ + gtk_paint_arrow(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2STATE(state_type), RVAL2SHADOW(shadow_type), RVAL2REC(area), + GTK_WIDGET(RVAL2GOBJ(widget)), RVAL2CSTR(detail), + RVAL2ARROW(arrow_type), RVAL2CBOOL(fill), NUM2INT(x), NUM2INT(y), + NUM2INT(width), NUM2INT(height)); + return self; +} + +static VALUE +rg_paint_box(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE shadow_type, VALUE area, VALUE widget, VALUE detail, VALUE x, VALUE y, VALUE width, VALUE height) +{ + gtk_paint_box(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2STATE(state_type), RVAL2SHADOW(shadow_type), RVAL2REC(area), + GTK_WIDGET(RVAL2GOBJ(widget)), RVAL2CSTR(detail), + NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height)); + return self; +} + +static VALUE +rg_paint_box_gap(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE shadow_type, VALUE area, VALUE widget, VALUE detail, VALUE x, VALUE y, VALUE width, VALUE height, VALUE gap_side, VALUE gap_x, VALUE gap_width) +{ + gtk_paint_box_gap(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2STATE(state_type), RVAL2SHADOW(shadow_type), RVAL2REC(area), + GTK_WIDGET(RVAL2GOBJ(widget)), RVAL2CSTR(detail), + NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height), + RVAL2GAP(gap_side), NUM2INT(gap_x), NUM2INT(gap_width)); + return self; +} + +static VALUE +rg_paint_check(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE shadow_type, VALUE area, VALUE widget, VALUE detail, VALUE x, VALUE y, VALUE width, VALUE height) +{ + gtk_paint_check(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2STATE(state_type), RVAL2SHADOW(shadow_type), RVAL2REC(area), + GTK_WIDGET(RVAL2GOBJ(widget)), RVAL2CSTR(detail), + NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height)); + return self; +} + +static VALUE +rg_paint_diamond(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE shadow_type, VALUE area, VALUE widget, VALUE detail, VALUE x, VALUE y, VALUE width, VALUE height) +{ + gtk_paint_diamond(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2STATE(state_type), RVAL2SHADOW(shadow_type), RVAL2REC(area), + GTK_WIDGET(RVAL2GOBJ(widget)), RVAL2CSTR(detail), + NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height)); + return self; +} + +static VALUE +rg_paint_extension(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE shadow_type, VALUE area, VALUE widget, VALUE detail, VALUE x, VALUE y, VALUE width, VALUE height, VALUE gap_side) +{ + gtk_paint_extension(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2STATE(state_type), RVAL2SHADOW(shadow_type), RVAL2REC(area), + GTK_WIDGET(RVAL2GOBJ(widget)), RVAL2CSTR(detail), + NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height), + RVAL2GAP(gap_side)); + return self; +} + +static VALUE +rg_paint_flat_box(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE shadow_type, VALUE area, VALUE widget, VALUE detail, VALUE x, VALUE y, VALUE width, VALUE height) +{ + gtk_paint_flat_box(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2STATE(state_type), RVAL2SHADOW(shadow_type), RVAL2REC(area), + GTK_WIDGET(RVAL2GOBJ(widget)), RVAL2CSTR(detail), + NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height)); + return self; +} + +static VALUE +rg_paint_focus(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE area, VALUE widget, VALUE detail, VALUE x, VALUE y, VALUE width, VALUE height) +{ + gtk_paint_focus(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2STATE(state_type), RVAL2REC(area), + GTK_WIDGET(RVAL2GOBJ(widget)), RVAL2CSTR(detail), + NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height)); + return self; +} + +static VALUE +rg_paint_handle(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE shadow_type, VALUE area, VALUE widget, VALUE detail, VALUE x, VALUE y, VALUE width, VALUE height, VALUE orientation) +{ + gtk_paint_handle(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2STATE(state_type), RVAL2SHADOW(shadow_type), RVAL2REC(area), + GTK_WIDGET(RVAL2GOBJ(widget)), RVAL2CSTR(detail), + NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height), + RVAL2ORI(orientation)); + return self; +} + +static VALUE +rg_paint_hline(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE area, VALUE widget, VALUE detail, VALUE x1, VALUE x2, VALUE y) +{ + gtk_paint_hline(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2STATE(state_type), RVAL2REC(area), + GTK_WIDGET(RVAL2GOBJ(widget)), RVAL2CSTR(detail), + NUM2INT(x1), NUM2INT(x2), NUM2INT(y)); + return self; +} + +static VALUE +rg_paint_option(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE shadow_type, VALUE area, VALUE widget, VALUE detail, VALUE x, VALUE y, VALUE width, VALUE height) +{ + gtk_paint_option(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2STATE(state_type), RVAL2SHADOW(shadow_type), RVAL2REC(area), + GTK_WIDGET(RVAL2GOBJ(widget)), + NIL_P(detail) ? NULL : RVAL2CSTR(detail), + NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height)); + return self; +} + +static VALUE +rg_paint_polygon(VALUE self, VALUE rbwindow, VALUE rbstate_type, + VALUE rbshadow_type, VALUE rbarea, VALUE rbwidget, + VALUE rbdetail, VALUE rbpoints, VALUE rbfill) +{ + GtkStyle *style = _SELF(self); + GdkWindow *window = GDK_WINDOW(RVAL2GOBJ(rbwindow)); + GtkStateType state_type = RVAL2STATE(rbstate_type); + GtkShadowType shadow_type = RVAL2SHADOW(rbshadow_type); + GdkRectangle *area = RVAL2REC(rbarea); + GtkWidget *widget = GTK_WIDGET(RVAL2GOBJ(rbwidget)); + const gchar *detail = RVAL2CSTR_ACCEPT_NIL(rbdetail); + gboolean fill = RVAL2CBOOL(rbfill); + long n; + GdkPoint *points = RVAL2GDKPOINTS(rbpoints, &n); + + gtk_paint_polygon(style, window, state_type, shadow_type, area, widget, detail, points, n, fill); + + g_free(points); + + return self; +} + +static VALUE +rg_paint_shadow(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE shadow_type, VALUE area, VALUE widget, VALUE detail, VALUE x, VALUE y, VALUE width, VALUE height) +{ + gtk_paint_shadow(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2STATE(state_type), RVAL2SHADOW(shadow_type), RVAL2REC(area), + GTK_WIDGET(RVAL2GOBJ(widget)), + NIL_P(detail) ? NULL : RVAL2CSTR(detail), + NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height)); + return self; +} + +static VALUE +rg_paint_shadow_gap(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE shadow_type, VALUE area, VALUE widget, VALUE detail, VALUE x, VALUE y, VALUE width, VALUE height, VALUE gap_side, VALUE gap_x, VALUE gap_width) +{ + gtk_paint_shadow_gap(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2STATE(state_type), RVAL2SHADOW(shadow_type), RVAL2REC(area), + GTK_WIDGET(RVAL2GOBJ(widget)), + NIL_P(detail) ? NULL : RVAL2CSTR(detail), + NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height), + RVAL2GAP(gap_side), NUM2INT(gap_x), NUM2INT(gap_width)); + return self; +} + +static VALUE +rg_paint_slider(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE shadow_type, VALUE area, VALUE widget, VALUE detail, VALUE x, VALUE y, VALUE width, VALUE height, VALUE orientation) +{ + gtk_paint_slider(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2STATE(state_type), RVAL2SHADOW(shadow_type), RVAL2REC(area), + GTK_WIDGET(RVAL2GOBJ(widget)), + NIL_P(detail) ? NULL : RVAL2CSTR(detail), + NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height), + RVAL2ORI(orientation)); + return self; +} + +static VALUE +rg_paint_tab(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE shadow_type, VALUE area, VALUE widget, VALUE detail, VALUE x, VALUE y, VALUE width, VALUE height) +{ + gtk_paint_tab(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2STATE(state_type), RVAL2SHADOW(shadow_type), RVAL2REC(area), + GTK_WIDGET(RVAL2GOBJ(widget)), + NIL_P(detail) ? NULL : RVAL2CSTR(detail), + NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height)); + return self; +} + +static VALUE +rg_paint_vline(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE area, VALUE widget, VALUE detail, VALUE y1, VALUE y2, VALUE x) +{ + gtk_paint_vline(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2STATE(state_type), RVAL2REC(area), + GTK_WIDGET(RVAL2GOBJ(widget)), + NIL_P(detail) ? NULL : RVAL2CSTR(detail), + NUM2INT(y1), NUM2INT(y2), NUM2INT(x)); + return self; +} + +static VALUE +rg_paint_expander(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE area, VALUE widget, VALUE detail, VALUE x, VALUE y, VALUE expander_style) +{ + gtk_paint_expander(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2STATE(state_type), RVAL2REC(area), + GTK_WIDGET(RVAL2GOBJ(widget)), + NIL_P(detail) ? NULL : RVAL2CSTR(detail), + NUM2INT(x), NUM2INT(y), RVAL2GENUM(expander_style, GTK_TYPE_EXPANDER_STYLE)); + return self; +} + +static VALUE +rg_paint_layout(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE use_text, VALUE area, VALUE widget, VALUE detail, VALUE x, VALUE y, VALUE layout) +{ + gtk_paint_layout(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2STATE(state_type), RVAL2CBOOL(use_text), RVAL2REC(area), + GTK_WIDGET(RVAL2GOBJ(widget)), + NIL_P(detail) ? NULL : RVAL2CSTR(detail), + NUM2INT(x), NUM2INT(y), PANGO_LAYOUT(RVAL2GOBJ(layout))); + return self; +} + +static VALUE +rg_paint_resize_grip(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE area, VALUE widget, VALUE detail, VALUE edge, VALUE x, VALUE y, VALUE width, VALUE height) +{ + gtk_paint_resize_grip(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), + RVAL2STATE(state_type), RVAL2REC(area), + GTK_WIDGET(RVAL2GOBJ(widget)), + NIL_P(detail) ? NULL : RVAL2CSTR(detail), + RVAL2GENUM(edge, GDK_TYPE_WINDOW_EDGE), + NUM2INT(x), NUM2INT(y), + NUM2INT(width), NUM2INT(height)); + return self; +} +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_s_draw_insertion_cursor(VALUE self, VALUE widget, VALUE drawable, VALUE area, VALUE location, VALUE is_primary, VALUE direction, VALUE draw_arrow) +{ + gtk_draw_insertion_cursor(GTK_WIDGET(RVAL2GOBJ(widget)), + GDK_WINDOW(RVAL2GOBJ(drawable)), + RVAL2REC(area), RVAL2REC(location), + RVAL2CBOOL(is_primary), + RVAL2GENUM(direction, GTK_TYPE_TEXT_DIRECTION), + RVAL2CBOOL(draw_arrow)); + return self; +} +#endif + +#define DEFINE_STYLE_COLOR(type) \ +static VALUE \ +style_set_ ## type(VALUE self, VALUE idx, VALUE r, VALUE g, VALUE b) \ +{ \ + GdkColor *color; \ + int i = NUM2INT(idx); \ + \ + if (i < 0 || 5 < i) rb_raise(rb_eArgError, "state out of range"); \ + color = &(_SELF(self) -> type [i]); \ + color->red = NUM2INT(r); \ + color->green = NUM2INT(g); \ + color->blue = NUM2INT(b); \ + return self; \ +} \ +static VALUE \ +style_ ## type(VALUE self, VALUE idx) \ +{ \ + int i = NUM2INT(idx); \ + \ + if (i < 0 || 5 < i) rb_raise(rb_eArgError, "state out of range"); \ + return BOXED2RVAL(&_SELF(self)-> type [i], GDK_TYPE_COLOR); \ +} \ + +DEFINE_STYLE_COLOR(fg); +DEFINE_STYLE_COLOR(bg); +DEFINE_STYLE_COLOR(light); +DEFINE_STYLE_COLOR(dark); +DEFINE_STYLE_COLOR(mid); +DEFINE_STYLE_COLOR(text); +DEFINE_STYLE_COLOR(base); +DEFINE_STYLE_COLOR(text_aa); + +static VALUE +rg_black(VALUE self) +{ + return BOXED2RVAL(&_SELF(self)->black, GDK_TYPE_COLOR); +} + +static VALUE +rg_set_black(VALUE self, VALUE r, VALUE g, VALUE b) +{ + GdkColor* color = &(_SELF(self)->black); + color->red = NUM2INT(r); + color->green = NUM2INT(g); + color->blue = NUM2INT(b); + + return self; +} + +static VALUE +rg_white(VALUE self) +{ + return BOXED2RVAL(&_SELF(self)->white, GDK_TYPE_COLOR); +} + +static VALUE +rg_set_white(VALUE self, VALUE r, VALUE g, VALUE b) +{ + GdkColor* color = &(_SELF(self)->white); + color->red = NUM2INT(r); + color->green = NUM2INT(g); + color->blue = NUM2INT(b); + return self; +} + +static VALUE +rg_font_desc(VALUE self) +{ + PangoFontDescription* desc = _SELF(self)->font_desc; + return BOXED2RVAL(desc, PANGO_TYPE_FONT_DESCRIPTION); +} + +static VALUE +rg_set_font_desc(VALUE self, VALUE font_desc) +{ + GtkStyle *style = _SELF(self); + if (style->font_desc) + pango_font_description_free(style->font_desc); + style->font_desc = pango_font_description_copy((PangoFontDescription*)RVAL2BOXED(font_desc, PANGO_TYPE_FONT_DESCRIPTION)); + return self; +} + +static VALUE +rg_xthickness(VALUE self) +{ + return INT2NUM(_SELF(self)->xthickness); +} + +static VALUE +rg_set_xthickness(VALUE self, VALUE xthickness) +{ + _SELF(self)->xthickness = NUM2INT(xthickness); + return self; +} + +static VALUE +rg_ythickness(VALUE self) +{ + return INT2NUM(_SELF(self)->ythickness); +} + +static VALUE +rg_set_ythickness(VALUE self, VALUE ythickness) +{ + _SELF(self)->ythickness = NUM2INT(ythickness); + return self; +} + +#define DEFINE_STYLE_GC(type) \ +static VALUE \ +style_set_ ## type(VALUE self, VALUE idx, VALUE gc) \ +{ \ + int i = NUM2INT(idx); \ + \ + if (i < 0 || 5 < i) rb_raise(rb_eArgError, "state out of range"); \ + _SELF(self)-> type [i] = GDK_GC(RVAL2GOBJ(gc));\ + return self;\ +} \ +static VALUE \ +style_ ## type(VALUE self, VALUE idx) \ +{ \ + int i = NUM2INT(idx); \ + \ + if (i < 0 || 5 < i) rb_raise(rb_eArgError, "state out of range"); \ + return GOBJ2RVAL(_SELF(self)-> type [i]); \ +} \ + +DEFINE_STYLE_GC(fg_gc); +DEFINE_STYLE_GC(bg_gc); +DEFINE_STYLE_GC(light_gc); +DEFINE_STYLE_GC(dark_gc); +DEFINE_STYLE_GC(mid_gc); +DEFINE_STYLE_GC(text_gc); +DEFINE_STYLE_GC(base_gc); +DEFINE_STYLE_GC(text_aa_gc); + +static VALUE +rg_black_gc(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->black_gc); +} + +static VALUE +rg_set_black_gc(VALUE self, VALUE gc) +{ + _SELF(self)->black_gc = GDK_GC(RVAL2GOBJ(gc)); + return self; +} + +static VALUE +rg_white_gc(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->white_gc); +} + +static VALUE +rg_set_white_gc(VALUE self, VALUE gc) +{ + _SELF(self)->white_gc = GDK_GC(RVAL2GOBJ(gc)); + return self; +} + +static VALUE +rg_bg_pixmap(VALUE self, VALUE idx) +{ + int i = NUM2INT(idx); + + if (i < 0 || 5 < i) + rb_raise(rb_eArgError, "state out of range"); + return GOBJ2RVAL(_SELF(self)->bg_pixmap[i]); +} + +static VALUE +rg_set_bg_pixmap(VALUE self, VALUE idx, VALUE bg_pixmap) +{ + int i = NUM2INT(idx); + GdkPixmap* pixmap = RVAL2GOBJ(bg_pixmap); + g_object_ref(G_OBJECT(pixmap)); + if (i < 0 || 5 < i) + rb_raise(rb_eArgError, "state out of range"); + _SELF(self)->bg_pixmap[i] = pixmap; + return self; +} + +void +Init_gtk_style(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_STYLE, "Style", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD_P(attached, 0); + RG_DEF_METHOD(copy, 0); + RG_DEF_ALIAS("clone", "copy"); + RG_DEF_ALIAS("dup", "copy"); + RG_DEF_METHOD(attach, 1); + RG_DEF_METHOD(detach, 0); + RG_DEF_METHOD(set_background, 2); + RG_DEF_METHOD(apply_default_background, 8); +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD(lookup_color, 1); +#endif + RG_DEF_METHOD(lookup_icon_set, 1); + RG_DEF_METHOD(render_icon, 6); + RG_DEF_METHOD(paint_arrow, 12); + RG_DEF_METHOD(paint_box, 10); + RG_DEF_METHOD(paint_box_gap, 13); + RG_DEF_METHOD(paint_check, 10); + RG_DEF_METHOD(paint_diamond, 10); + RG_DEF_METHOD(paint_extension, 10); + RG_DEF_METHOD(paint_flat_box, 10); + RG_DEF_METHOD(paint_focus, 9); + RG_DEF_METHOD(paint_handle, 11); + RG_DEF_METHOD(paint_hline, 8); + RG_DEF_METHOD(paint_option, 10); + RG_DEF_METHOD(paint_polygon, 8); + RG_DEF_METHOD(paint_shadow, 10); + RG_DEF_METHOD(paint_shadow_gap, 13); + RG_DEF_METHOD(paint_slider, 11); + RG_DEF_METHOD(paint_tab, 10); + RG_DEF_METHOD(paint_vline, 9); + RG_DEF_METHOD(paint_expander, 8); + RG_DEF_METHOD(paint_layout, 9); + RG_DEF_METHOD(paint_resize_grip, 10); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_SMETHOD(draw_insertion_cursor, 7); +#endif + rb_define_method(RG_TARGET_NAMESPACE, "fg", style_fg, 1); + rb_define_method(RG_TARGET_NAMESPACE, "bg", style_bg, 1); + rb_define_method(RG_TARGET_NAMESPACE, "light", style_light, 1); + rb_define_method(RG_TARGET_NAMESPACE, "dark", style_dark, 1); + rb_define_method(RG_TARGET_NAMESPACE, "mid", style_mid, 1); + rb_define_method(RG_TARGET_NAMESPACE, "text", style_text, 1); + rb_define_method(RG_TARGET_NAMESPACE, "base", style_base, 1); + rb_define_method(RG_TARGET_NAMESPACE, "text_aa", style_text_aa, 1); + rb_define_method(RG_TARGET_NAMESPACE, "set_fg", style_set_fg, 4); + rb_define_method(RG_TARGET_NAMESPACE, "set_bg", style_set_bg, 4); + rb_define_method(RG_TARGET_NAMESPACE, "set_light", style_set_light, 4); + rb_define_method(RG_TARGET_NAMESPACE, "set_dark", style_set_dark, 4); + rb_define_method(RG_TARGET_NAMESPACE, "set_mid", style_set_mid, 4); + rb_define_method(RG_TARGET_NAMESPACE, "set_text", style_set_text, 4); + rb_define_method(RG_TARGET_NAMESPACE, "set_base", style_set_base, 4); + rb_define_method(RG_TARGET_NAMESPACE, "set_text_aa", style_set_text_aa, 4); + + RG_DEF_METHOD(black, 0); + RG_DEF_METHOD(set_black, 3); + RG_DEF_METHOD(white, 0); + RG_DEF_METHOD(set_white, 3); + RG_DEF_METHOD(font_desc, 0); + RG_DEF_METHOD(set_font_desc, 1); + RG_DEF_METHOD(xthickness, 0); + RG_DEF_METHOD(ythickness, 0); + RG_DEF_METHOD(set_xthickness, 1); + RG_DEF_METHOD(set_ythickness, 1); + + rb_define_method(RG_TARGET_NAMESPACE, "fg_gc", style_fg_gc, 1); + rb_define_method(RG_TARGET_NAMESPACE, "bg_gc", style_bg_gc, 1); + rb_define_method(RG_TARGET_NAMESPACE, "light_gc", style_light_gc, 1); + rb_define_method(RG_TARGET_NAMESPACE, "dark_gc", style_dark_gc, 1); + rb_define_method(RG_TARGET_NAMESPACE, "mid_gc", style_mid_gc, 1); + rb_define_method(RG_TARGET_NAMESPACE, "text_gc", style_text_gc, 1); + rb_define_method(RG_TARGET_NAMESPACE, "base_gc", style_base_gc, 1); + rb_define_method(RG_TARGET_NAMESPACE, "text_aa_gc", style_text_aa_gc, 1); + RG_DEF_METHOD(black_gc, 0); + RG_DEF_METHOD(white_gc, 0); + RG_DEF_METHOD(bg_pixmap, 1); + rb_define_method(RG_TARGET_NAMESPACE, "set_fg_gc", style_set_fg_gc, 2); + rb_define_method(RG_TARGET_NAMESPACE, "set_bg_gc", style_set_bg_gc, 2); + rb_define_method(RG_TARGET_NAMESPACE, "set_light_gc", style_set_light_gc, 2); + rb_define_method(RG_TARGET_NAMESPACE, "set_dark_gc", style_set_dark_gc, 2); + rb_define_method(RG_TARGET_NAMESPACE, "set_mid_gc", style_set_mid_gc, 2); + rb_define_method(RG_TARGET_NAMESPACE, "set_text_gc", style_set_text_gc, 2); + rb_define_method(RG_TARGET_NAMESPACE, "set_base_gc", style_set_base_gc, 2); + rb_define_method(RG_TARGET_NAMESPACE, "set_text_aa_gc", style_set_text_aa_gc, 2); + RG_DEF_METHOD(set_black_gc, 1); + RG_DEF_METHOD(set_white_gc, 1); + RG_DEF_METHOD(set_bg_pixmap, 2); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktable.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktable.c new file mode 100644 index 0000000..147ea97 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktable.c @@ -0,0 +1,177 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTable +#define _SELF(self) (GTK_TABLE(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE row, col, homogeneous; + + rb_scan_args(argc, argv, "21", &row, &col, &homogeneous); + RBGTK_INITIALIZE(self, gtk_table_new(NUM2INT(row), + NUM2INT(col), + RVAL2CBOOL(homogeneous))); + return Qnil; +} + +static VALUE +rg_resize(VALUE self, VALUE rows, VALUE columns) +{ + gtk_table_resize(_SELF(self), NUM2UINT(rows), NUM2UINT(columns)); + return self; +} + +static VALUE +rg_attach(int argc, VALUE *argv, VALUE self) +{ + VALUE child, left, right, top, bottom; + VALUE arg0, arg1, arg2, arg3; + gint xspc, yspc; + GtkAttachOptions xopt, yopt; + + xopt = yopt = GTK_EXPAND | GTK_FILL; + xspc = yspc = 0; + rb_scan_args(argc, argv, "54", + &child, &left, &right, &top, &bottom, + &arg0, &arg1, &arg2, &arg3); + if (!NIL_P(arg0)) xopt = RVAL2GFLAGS(arg0, GTK_TYPE_ATTACH_OPTIONS); + if (!NIL_P(arg1)) yopt = RVAL2GFLAGS(arg1, GTK_TYPE_ATTACH_OPTIONS); + if (!NIL_P(arg2)) xspc = NUM2INT(arg2); + if (!NIL_P(arg3)) yspc = NUM2INT(arg3); + + gtk_table_attach(_SELF(self), + GTK_WIDGET(RVAL2GOBJ(child)), + NUM2INT(left),NUM2INT(right), + NUM2INT(top),NUM2INT(bottom), + xopt, yopt, xspc, yspc); + + G_CHILD_ADD(self, child); + + return self; +} + +static VALUE +rg_attach_defaults(VALUE self, VALUE widget, VALUE left_attach, VALUE right_attach, VALUE top_attach, VALUE bottom_attach) +{ + gtk_table_attach_defaults(_SELF(self), GTK_WIDGET(RVAL2GOBJ(widget)), + NUM2UINT(left_attach), NUM2UINT(right_attach), + NUM2UINT(top_attach), NUM2UINT(bottom_attach)); + G_CHILD_ADD(self, widget); + return self; +} + +static VALUE +tbl_set_row_spacing(VALUE self, VALUE row, VALUE spc) +{ + gtk_table_set_row_spacing(_SELF(self), NUM2UINT(row), NUM2UINT(spc)); + return self; +} + +static VALUE +rg_get_row_spacing(VALUE self, VALUE row) +{ + return UINT2NUM(gtk_table_get_row_spacing(_SELF(self), NUM2UINT(row))); +} + +static VALUE +tbl_set_col_spacing(VALUE self, VALUE col, VALUE spc) +{ + gtk_table_set_col_spacing(_SELF(self), NUM2UINT(col), NUM2UINT(spc)); + return self; +} + +static VALUE +rg_get_column_spacing(VALUE self, VALUE col) +{ + return UINT2NUM(gtk_table_get_col_spacing(_SELF(self), NUM2UINT(col))); +} + +static VALUE +rg_set_row_spacings(VALUE self, VALUE spc) +{ + gtk_table_set_row_spacings(_SELF(self), NUM2UINT(spc)); + return self; +} + +static VALUE +rg_set_column_spacings(VALUE self, VALUE spc) +{ + gtk_table_set_col_spacings(_SELF(self), NUM2UINT(spc)); + return self; +} + +static VALUE +rg_row_spacings(VALUE self) +{ + return UINT2NUM(_SELF(self)->row_spacing); +} + +static VALUE +rg_column_spacings(VALUE self) +{ + return UINT2NUM(_SELF(self)->column_spacing); +} + +static VALUE +rg_default_row_spacing(VALUE self) +{ + return UINT2NUM(gtk_table_get_default_row_spacing(_SELF(self))); +} + +static VALUE +rg_default_column_spacing(VALUE self) +{ + return UINT2NUM(gtk_table_get_default_col_spacing(_SELF(self))); +} + +void +Init_gtk_table(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TABLE, "Table", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(resize, 2); + RG_DEF_METHOD(attach, -1); + RG_DEF_METHOD(attach_defaults, 5); + G_REPLACE_SET_PROPERTY(RG_TARGET_NAMESPACE, "row_spacing", tbl_set_row_spacing, 2); + rb_undef_method(RG_TARGET_NAMESPACE, "row_spacing="); + G_REPLACE_SET_PROPERTY(RG_TARGET_NAMESPACE, "column_spacing", tbl_set_col_spacing, 2); + rb_undef_method(RG_TARGET_NAMESPACE, "column_spacing="); + RG_DEF_METHOD(get_row_spacing, 1); + rb_undef_method(RG_TARGET_NAMESPACE, "row_spacing"); + RG_DEF_METHOD(get_column_spacing, 1); + rb_undef_method(RG_TARGET_NAMESPACE, "column_spacing"); + RG_DEF_METHOD(set_row_spacings, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "row_spacings"); + RG_DEF_METHOD(set_column_spacings, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "column_spacings"); + RG_DEF_METHOD(row_spacings, 0); + RG_DEF_METHOD(column_spacings, 0); + RG_DEF_METHOD(default_row_spacing, 0); + RG_DEF_METHOD(default_column_spacing, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktargetlist.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktargetlist.c new file mode 100644 index 0000000..9d7882a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktargetlist.c @@ -0,0 +1,159 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTargetList +#define _SELF(r) ((GtkTargetList*)RVAL2BOXED(r, GTK_TYPE_TARGET_LIST)) + +/**********************************/ +#if ! GTK_CHECK_VERSION(2,10,0) +static GtkTargetList* +rbgtk_target_list_copy(const GtkTargetList* list) +{ + GtkTargetList* new_list; + g_return_val_if_fail (list != NULL, NULL); + new_list = g_new(GtkTargetList, 1); + *new_list = *list; + return new_list; +} + +GType +gtk_target_list_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("GtkTargetList", + (GBoxedCopyFunc)rbgtk_target_list_copy, + (GBoxedFreeFunc)gtk_target_list_unref); + return our_type; +} +#endif +/**********************************/ + +static VALUE +rg_initialize(VALUE self, VALUE rbtargets) +{ + long n; + GtkTargetEntry *targets = RVAL2GTKTARGETENTRIES(rbtargets, &n); + GtkTargetList *list = gtk_target_list_new(targets, n); + + g_free(targets); + + G_INITIALIZE(self, list); + + return Qnil; +} + +static VALUE +rg_add(VALUE self, VALUE target, VALUE flags, VALUE info) +{ + gtk_target_list_add(_SELF(self), RVAL2ATOM(target), + FIX2UINT(flags), FIX2UINT(info)); + return self; +} + +static VALUE +rg_add_table(VALUE self, VALUE rbtargets) +{ + GtkTargetList *list = _SELF(self); + long n; + GtkTargetEntry *targets = RVAL2GTKTARGETENTRIES(rbtargets, &n); + + gtk_target_list_add_table(list, targets, n); + + g_free(targets); + + return self; +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_add_text_targets(VALUE self, VALUE info) +{ + gtk_target_list_add_text_targets(_SELF(self), NUM2UINT(info)); + return self; +} + +static VALUE +rg_add_image_targets(VALUE self, VALUE info, VALUE writable) +{ + gtk_target_list_add_image_targets(_SELF(self), NUM2UINT(info), RVAL2CBOOL(writable)); + return self; +} + +static VALUE +rg_add_uri_targets(VALUE self, VALUE info) +{ + gtk_target_list_add_uri_targets(_SELF(self), NUM2UINT(info)); + return self; +} +#endif + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_add_rich_text_targets(VALUE self, VALUE info, VALUE deserializable, VALUE buffer) +{ + gtk_target_list_add_rich_text_targets(_SELF(self), NUM2UINT(info), + RVAL2CBOOL(deserializable), + GTK_TEXT_BUFFER(RVAL2GOBJ(buffer))); + return self; +} +#endif + +static VALUE +rg_remove(VALUE self, VALUE target) +{ + gtk_target_list_remove(_SELF(self), RVAL2ATOM(target)); + return self; +} + +static VALUE +rg_find(VALUE self, VALUE target) +{ + guint info; + gboolean ret = gtk_target_list_find(_SELF(self), RVAL2ATOM(target), + &info); + return ret ? INT2NUM(info) : Qnil; +} + +void +Init_gtk_target_list(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TARGET_LIST, "TargetList", mGtk); + + rbgobj_boxed_not_copy_obj(GTK_TYPE_TARGET_LIST); + + RG_DEF_METHOD(initialize, 1); + RG_DEF_METHOD(add, 3); + RG_DEF_METHOD(add_table, 1); +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(add_text_targets, 1); + RG_DEF_METHOD(add_image_targets, 2); + RG_DEF_METHOD(add_uri_targets, 1); +#endif +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD(add_rich_text_targets, 3); +#endif + RG_DEF_METHOD(remove, 1); + RG_DEF_METHOD(find, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktearoffmenuitem.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktearoffmenuitem.c new file mode 100644 index 0000000..e471dea --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktearoffmenuitem.c @@ -0,0 +1,41 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTearoffMenuItem + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_tearoff_menu_item_new()); + return Qnil; +} + +void +Init_gtk_tearoff_menu_item(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TEAROFF_MENU_ITEM, "TearoffMenuItem", mGtk); + RG_DEF_METHOD(initialize, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextappearance.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextappearance.c new file mode 100644 index 0000000..267fa7b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextappearance.c @@ -0,0 +1,172 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +/*****************************************/ +static GtkTextAppearance* +app_copy(const GtkTextAppearance* app) +{ + GtkTextAppearance* new_app; + g_return_val_if_fail (app != NULL, NULL); + new_app = g_new(GtkTextAppearance, 1); + *new_app = *app; + return new_app; +} + +GType +gtk_text_appearance_get_type(void) +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static ("GtkTextAppearance", + (GBoxedCopyFunc)app_copy, + (GBoxedFreeFunc)g_free); + return our_type; +} +/*****************************************/ + +#define RG_TARGET_NAMESPACE cTextAppearance +#define _SELF(t) ((GtkTextAppearance*)RVAL2BOXED(t, GTK_TYPE_TEXT_APPEARANCE)) + +/***********************************************/ +#define ATTR_INT(name)\ +static VALUE \ +txt_app_int_ ## name (VALUE self)\ +{\ + return INT2NUM(_SELF(self)->name);\ +}\ +static VALUE \ +txt_app_int_set_ ## name (VALUE self, VALUE val)\ +{\ + _SELF(self)->name = NUM2INT(val); \ + return self;\ +} + +#define ATTR_BOOL(name)\ +static VALUE \ +txt_app_bool_ ## name (VALUE self)\ +{\ + return CBOOL2RVAL(_SELF(self)->name);\ +}\ +static VALUE \ +txt_app_bool_set_ ## name (VALUE self, VALUE val)\ +{\ + _SELF(self)->name = RVAL2CBOOL(val);\ + return self;\ +} + +#define ATTR_ENUM(name, gtype)\ +static VALUE \ +txt_app_enums_ ## name (VALUE self)\ +{\ + return GENUM2RVAL(_SELF(self)->name, gtype);\ +}\ +static VALUE \ +txt_app_enums_set_ ## name (VALUE self, VALUE val)\ +{\ + _SELF(self)->name = RVAL2GENUM(val, gtype);\ + return self;\ +} + +#define ATTR_GOBJ(name)\ +static VALUE \ +txt_app_gobj_ ## name (VALUE self)\ +{\ + VALUE val; \ + if (_SELF(self)->name == NULL) return Qnil;\ + val = GOBJ2RVAL(_SELF(self)->name); \ + G_CHILD_SET(self, rb_intern(G_STRINGIFY(name)), val);\ + return val; \ +}\ +static VALUE \ +txt_app_gobj_set_ ## name (VALUE self, VALUE val)\ +{\ + _SELF(self)->name = RVAL2GOBJ(val);\ + G_CHILD_SET(self, rb_intern(G_STRINGIFY(name)), val);\ + return self;\ +} + +#define ATTR_COLOR(name)\ +static VALUE \ +txt_app_color_ ## name (VALUE self)\ +{\ + VALUE val = BOXED2RVAL(&_SELF(self)->name, GDK_TYPE_COLOR);\ + G_CHILD_SET(self, rb_intern(G_STRINGIFY(name)), val);\ + return val;\ +}\ +static VALUE \ +txt_app_color_set_ ## name (VALUE self, VALUE val)\ +{\ + G_CHILD_SET(self, rb_intern(G_STRINGIFY(name)), val);\ + _SELF(self)->name = *RVAL2GDKCOLOR(val); \ + return self;\ +} + +#define DEFINE_ACCESSOR(gt, type, name) \ + rb_define_method(gt, G_STRINGIFY(name), txt_app_ ## type ## _## name, 0);\ + rb_define_method(gt, G_STRINGIFY(set_ ## name), txt_app_ ## type ## _set_## name, 1); +/***********************************************/ +ATTR_COLOR(bg_color); +ATTR_COLOR(fg_color); +ATTR_GOBJ(bg_stipple); +ATTR_GOBJ(fg_stipple); + +ATTR_INT(rise); +ATTR_ENUM(underline, PANGO_TYPE_UNDERLINE); +ATTR_BOOL(strikethrough); +ATTR_BOOL(draw_bg); +ATTR_BOOL(inside_selection); +ATTR_BOOL(is_text); + +static VALUE +rg_initialize(VALUE self) +{ + GtkTextAppearance* app = ALLOC(GtkTextAppearance); + memset(app, 0, sizeof(GtkTextAppearance)); + G_INITIALIZE(self, app); + return Qnil; +} + +void +Init_gtk_text_appearance(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TEXT_APPEARANCE, "TextAppearance", mGtk); + + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, color, bg_color); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, color, fg_color); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, gobj, bg_stipple); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, gobj, fg_stipple); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, int, rise); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, enums, underline); + + RG_DEF_METHOD(initialize, 0); + rb_define_method(RG_TARGET_NAMESPACE, "strikethrough?", txt_app_bool_strikethrough, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_strikethrough", txt_app_bool_set_strikethrough, 1); + rb_define_method(RG_TARGET_NAMESPACE, "draw_bg?", txt_app_bool_draw_bg, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_draw_bg", txt_app_bool_set_draw_bg, 1); + rb_define_method(RG_TARGET_NAMESPACE, "inside_selection?", txt_app_bool_inside_selection, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_inside_selection", txt_app_bool_set_inside_selection, 1); + rb_define_method(RG_TARGET_NAMESPACE, "text?", txt_app_bool_is_text, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_text", txt_app_bool_set_is_text, 1); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextattributes.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextattributes.c new file mode 100644 index 0000000..f85c40d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextattributes.c @@ -0,0 +1,203 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 OGASAWARA, Takeshi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTextAttributes +#define _SELF(s) ((GtkTextAttributes*)RVAL2BOXED(s, GTK_TYPE_TEXT_ATTRIBUTES)) + +/***********************************************/ +#define ATTR_INT(name)\ +static VALUE \ +txt_attr_int_ ## name (VALUE self)\ +{\ + return INT2NUM(_SELF(self)->name);\ +}\ +static VALUE \ +txt_attr_int_set_ ## name (VALUE self, VALUE val)\ +{\ + _SELF(self)->name = NUM2INT(val); \ + return self;\ +} + +#define ATTR_BOOL(name)\ +static VALUE \ +txt_attr_bool_ ## name (VALUE self)\ +{\ + return CBOOL2RVAL(_SELF(self)->name);\ +}\ +static VALUE \ +txt_attr_bool_set_ ## name (VALUE self, VALUE val)\ +{\ + _SELF(self)->name = RVAL2CBOOL(val);\ + return self;\ +} + +#define ATTR_FLAGS(name, gtype)\ +static VALUE \ +txt_attr_flags_ ## name (VALUE self)\ +{\ + return GFLAGS2RVAL(_SELF(self)->name, gtype);\ +}\ +static VALUE \ +txt_attr_flags_set_ ## name (VALUE self, VALUE val)\ +{\ + _SELF(self)->name = RVAL2GFLAGS(val, gtype);\ + return self;\ +} + +#define ATTR_ENUM(name, gtype)\ +static VALUE \ +txt_attr_enums_ ## name (VALUE self)\ +{\ + return GENUM2RVAL(_SELF(self)->name, gtype);\ +}\ +static VALUE \ +txt_attr_enums_set_ ## name (VALUE self, VALUE val)\ +{\ + _SELF(self)->name = RVAL2GENUM(val, gtype);\ + return self;\ +} + +#define ATTR_BOXED(name, gtype)\ +static VALUE \ +txt_attr_boxed_ ## name (VALUE self)\ +{\ + VALUE val; \ + if (_SELF(self)->name == NULL) return Qnil;\ + val = BOXED2RVAL(_SELF(self)->name, gtype);\ + G_CHILD_SET(self, rb_intern(G_STRINGIFY(name)), val);\ + return val;\ +}\ +static VALUE \ +txt_attr_boxed_set_ ## name (VALUE self, VALUE val)\ +{\ + G_CHILD_SET(self, rb_intern(G_STRINGIFY(name)), val);\ + _SELF(self)->name = RVAL2BOXED(val, gtype);\ + return self;\ +} + +#define DEFINE_ACCESSOR(gt, type, name) \ + rb_define_method(gt, G_STRINGIFY(name), txt_attr_ ## type ## _## name, 0);\ + rb_define_method(gt, G_STRINGIFY(set_ ## name), txt_attr_ ## type ## _set_## name, 1); + +/***********************************************/ +static VALUE +txt_attr_boxed_appearance(VALUE self) +{ + GtkTextAppearance app = _SELF(self)->appearance; + return BOXED2RVAL(&app, GTK_TYPE_TEXT_APPEARANCE); +} +static VALUE +txt_attr_boxed_set_appearance(VALUE self, VALUE val) +{ + GtkTextAppearance* app = (GtkTextAppearance*)RVAL2BOXED(val, GTK_TYPE_TEXT_APPEARANCE); + _SELF(self)->appearance = *app; + return self; +} + +ATTR_ENUM(justification, GTK_TYPE_JUSTIFICATION); +ATTR_ENUM(direction, GTK_TYPE_DIRECTION_TYPE); +ATTR_BOXED(font, PANGO_TYPE_FONT_DESCRIPTION); + +static VALUE +txt_attr_double_font_scale(VALUE self) +{ + return rb_float_new(_SELF(self)->font_scale); +} +static VALUE +txt_attr_double_set_font_scale(VALUE self, VALUE val) +{ + _SELF(self)->font_scale = NUM2DBL(val); + return self; +} + +ATTR_INT(left_margin); +ATTR_INT(indent); +ATTR_INT(right_margin); +ATTR_INT(pixels_above_lines); +ATTR_INT(pixels_below_lines); +ATTR_INT(pixels_inside_wrap); + +ATTR_BOXED(tabs, PANGO_TYPE_TAB_ARRAY); + +ATTR_ENUM(wrap_mode, GTK_TYPE_WRAP_MODE); +ATTR_BOXED(language, PANGO_TYPE_LANGUAGE); + +ATTR_BOOL(invisible); +ATTR_BOOL(bg_full_height); +ATTR_BOOL(editable); +ATTR_BOOL(realized); + +/***********************************************/ + +static VALUE +rg_initialize(VALUE self) +{ + GtkTextAttributes *attr; + + attr = gtk_text_attributes_new(); + G_INITIALIZE(self, attr); + return Qnil; +} + +static VALUE +rg_copy_values(VALUE self, VALUE dest) +{ + gtk_text_attributes_copy_values(_SELF(self), _SELF(dest)); + return self; +} + +void +Init_gtk_text_attributes(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TEXT_ATTRIBUTES, "TextAttributes", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(copy_values, 1); + + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, boxed, appearance); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, enums, justification); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, enums, direction); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, boxed, font); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, double, font_scale); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, int, left_margin); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, int, indent); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, int, right_margin); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, int, pixels_above_lines); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, int, pixels_below_lines); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, int, pixels_inside_wrap); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, boxed, tabs); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, enums, wrap_mode); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, boxed, language); + + rb_define_method(RG_TARGET_NAMESPACE, "invisible?", txt_attr_bool_invisible, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_invisible", txt_attr_bool_set_invisible, 1); + rb_define_method(RG_TARGET_NAMESPACE, "bg_full_height?", txt_attr_bool_bg_full_height, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_bg_full_height", txt_attr_bool_set_bg_full_height, 1); + rb_define_method(RG_TARGET_NAMESPACE, "editable?", txt_attr_bool_editable, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_editable", txt_attr_bool_set_editable, 1); + rb_define_method(RG_TARGET_NAMESPACE, "realized?", txt_attr_bool_realized, 0); + rb_define_method(RG_TARGET_NAMESPACE, "set_realized", txt_attr_bool_set_realized, 1); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextbuffer.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextbuffer.c new file mode 100644 index 0000000..e897688 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextbuffer.c @@ -0,0 +1,898 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTextBuffer +#define _SELF(s) (GTK_TEXT_BUFFER(RVAL2GOBJ(s))) +#define RVAL2ITR(i) (GtkTextIter*)RVAL2BOXED(i, GTK_TYPE_TEXT_ITER) +#define ITR2RVAL(i) (BOXED2RVAL(i, GTK_TYPE_TEXT_ITER)) +#define RVAL2MARK(m) (GTK_TEXT_MARK(RVAL2GOBJ(m))) +#define N_RVAL2CSTR(text) (NIL_P(text) ? NULL : RVAL2CSTR(text)) +#define RVAL2TAG(t) (GTK_TEXT_TAG(RVAL2GOBJ(t))) +#define RVAL2ANCHOR(a) (GTK_TEXT_CHILD_ANCHOR(RVAL2GOBJ(a))) +#define ATOM2RVAL(a) (BOXED2RVAL(a, GDK_TYPE_ATOM)) + +static ID id_tagtable; + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE table; + rb_scan_args(argc, argv, "01", &table); + if (NIL_P(table)) + G_INITIALIZE(self, gtk_text_buffer_new(NULL)); + else { + G_CHILD_SET(self, id_tagtable, table); + G_INITIALIZE(self, gtk_text_buffer_new(GTK_TEXT_TAG_TABLE(RVAL2GOBJ(table)))); + } + return Qnil; +} + +static VALUE +rg_line_count(VALUE self) +{ + return INT2NUM(gtk_text_buffer_get_line_count(_SELF(self))); +} + +static VALUE +rg_char_count(VALUE self) +{ + return INT2NUM(gtk_text_buffer_get_char_count(_SELF(self))); +} + +static VALUE +txt_set_text(VALUE self, VALUE text) +{ + StringValue(text); + gtk_text_buffer_set_text(_SELF(self), RSTRING_PTR(text), RSTRING_LEN(text)); + return self; +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_backspace(VALUE self, VALUE iter, VALUE interactive, VALUE default_editable) +{ + return CBOOL2RVAL(gtk_text_buffer_backspace(_SELF(self), RVAL2ITR(iter), + RVAL2CBOOL(interactive), + RVAL2CBOOL(default_editable))); +} +#endif + +static VALUE +rg_insert_at_cursor(VALUE self, VALUE text) +{ + StringValue(text); + gtk_text_buffer_insert_at_cursor(_SELF(self), RSTRING_PTR(text), RSTRING_LEN(text)); + return self; +} + +static VALUE +rg_insert_interactive(VALUE self, VALUE iter, VALUE text, VALUE editable) +{ + StringValue(text); + + return CBOOL2RVAL(gtk_text_buffer_insert_interactive(_SELF(self), + RVAL2ITR(iter), + RSTRING_PTR(text), + RSTRING_LEN(text), + RVAL2CBOOL(editable))); +} + +static VALUE +rg_insert_interactive_at_cursor(VALUE self, VALUE text, VALUE editable) +{ + StringValue(text); + + return CBOOL2RVAL(gtk_text_buffer_insert_interactive_at_cursor(_SELF(self), + RSTRING_PTR(text), + RSTRING_LEN(text), + RVAL2CBOOL(editable))); +} + +static VALUE +rg_insert_range(VALUE self, VALUE iter, VALUE start, VALUE end) +{ + gtk_text_buffer_insert_range(_SELF(self), RVAL2ITR(iter), + RVAL2ITR(start), RVAL2ITR(end)); + return self; +} + +static VALUE +rg_insert_range_interactive(VALUE self, VALUE iter, VALUE start, VALUE end, VALUE editable) +{ + return CBOOL2RVAL(gtk_text_buffer_insert_range_interactive(_SELF(self), + RVAL2ITR(iter), + RVAL2ITR(start), + RVAL2ITR(end), + RVAL2CBOOL(editable))); +} + +static VALUE +rg_delete(VALUE self, VALUE start, VALUE end) +{ + gtk_text_buffer_delete(GTK_TEXT_BUFFER(RVAL2GOBJ(self)), + RVAL2ITR(start), RVAL2ITR(end)); + return self; +} + +static VALUE +rg_delete_interactive(VALUE self, VALUE start, VALUE end, VALUE editable) +{ + return CBOOL2RVAL(gtk_text_buffer_delete_interactive(_SELF(self), + RVAL2ITR(start), + RVAL2ITR(end), + RVAL2CBOOL(editable))); +} + +static VALUE +rg_get_text(int argc, VALUE *argv, VALUE self) +{ + VALUE start, end, include_hidden_chars; + GtkTextIter start_iter, end_iter; + GtkTextBuffer* buffer = _SELF(self); + gchar* ret; + VALUE result; + + rb_scan_args(argc, argv, "03", &start, &end, &include_hidden_chars); + + if (NIL_P(start)) gtk_text_buffer_get_start_iter(buffer, &start_iter); + if (NIL_P(end)) gtk_text_buffer_get_end_iter(buffer, &end_iter); + if (NIL_P(include_hidden_chars)) include_hidden_chars = Qfalse; + + ret = gtk_text_buffer_get_text( + buffer, + NIL_P(start) ? &start_iter : RVAL2ITR(start), + NIL_P(end) ? &end_iter : RVAL2ITR(end), + RVAL2CBOOL(include_hidden_chars)); + result = CSTR2RVAL(ret); + g_free(ret); + + return result; +} + +static VALUE +txt_get_text_all(VALUE self) +{ + return rg_get_text(0, NULL, self); +} + +static VALUE +rg_get_slice(int argc, VALUE *argv, VALUE self) +{ + VALUE start, end, include_hidden_chars; + GtkTextIter start_iter, end_iter; + GtkTextBuffer* buffer = _SELF(self); + gchar* ret; + VALUE result; + + rb_scan_args(argc, argv, "03", &start, &end, &include_hidden_chars); + + if (NIL_P(start)) gtk_text_buffer_get_start_iter(buffer, &start_iter); + if (NIL_P(end)) gtk_text_buffer_get_end_iter(buffer, &end_iter); + if (NIL_P(include_hidden_chars)) include_hidden_chars = Qfalse; + + ret = gtk_text_buffer_get_slice( + buffer, + NIL_P(start) ? &start_iter : RVAL2ITR(start), + NIL_P(end) ? &end_iter : RVAL2ITR(end), + RVAL2CBOOL(include_hidden_chars)); + result = CSTR2RVAL(ret); + g_free(ret); + + return result; +} + +static VALUE +rg_slice(VALUE self) +{ + return rg_get_slice(0, NULL, self); +} + +static VALUE +rg_insert_pixbuf(VALUE self, VALUE iter, VALUE pixbuf) +{ + G_CHILD_ADD(self, iter); + G_CHILD_ADD(iter, pixbuf); + + if (RVAL2CBOOL(ruby_debug)) + rb_warning("Gtk::TextBuffer#insert_pixbuf is deprecated. Use Gtk::TextBuffer#insert instead."); + gtk_text_buffer_insert_pixbuf(_SELF(self), RVAL2ITR(iter), + GDK_PIXBUF(RVAL2GOBJ(pixbuf))); + return self; +} + +static VALUE +rg_insert_child_anchor(VALUE self, VALUE iter, VALUE anchor) +{ + G_CHILD_ADD(self, iter); + G_CHILD_ADD(iter, anchor); + if (RVAL2CBOOL(ruby_debug)) + rb_warning("Gtk::TextBuffer#insert_child_anchor is deprecated. Use Gtk::TextBuffer#insert instead."); + gtk_text_buffer_insert_child_anchor(_SELF(self), RVAL2ITR(iter), + GTK_TEXT_CHILD_ANCHOR(RVAL2GOBJ(anchor))); + return self; +} + +static VALUE +rg_create_child_anchor(VALUE self, VALUE iter) +{ + VALUE ret = GOBJ2RVAL(gtk_text_buffer_create_child_anchor(_SELF(self), RVAL2ITR(iter))); + G_CHILD_ADD(self, ret); + return ret; +} + +static VALUE +rg_create_mark(VALUE self, VALUE name, VALUE where, VALUE left_gravity) +{ + VALUE ret = GOBJ2RVAL(gtk_text_buffer_create_mark(_SELF(self), + NIL_P(name) ? NULL : RVAL2CSTR(name), + RVAL2ITR(where), + RVAL2CBOOL(left_gravity))); + G_CHILD_ADD(self, ret); + return ret; +} + +#if GTK_CHECK_VERSION(2,12,0) +static VALUE +rg_add_mark(VALUE self, VALUE mark, VALUE where) +{ + gtk_text_buffer_add_mark(_SELF(self), RVAL2MARK(mark), RVAL2ITR(where)); + return self; +} +#endif + +static VALUE +rg_delete_mark(VALUE self, VALUE mark) +{ + if (rb_obj_is_kind_of(mark, GTYPE2CLASS(GTK_TYPE_TEXT_MARK))){ + G_CHILD_REMOVE(self, mark); + gtk_text_buffer_delete_mark(_SELF(self), RVAL2MARK(mark)); + } else { + G_CHILD_REMOVE(self, GOBJ2RVAL(gtk_text_buffer_get_mark(_SELF(self), RVAL2CSTR(mark)))); + gtk_text_buffer_delete_mark_by_name(_SELF(self), RVAL2CSTR(mark)); + } + return self; +} + +static VALUE +rg_get_mark(VALUE self, VALUE name) +{ + return GOBJ2RVAL(gtk_text_buffer_get_mark(_SELF(self), RVAL2CSTR(name))); +} + +/* +static VALUE +rg_get_insert(VALUE self) +{ + return GOBJ2RVAL(gtk_text_buffer_get_insert(_SELF(self))); +} +*/ + +static VALUE +rg_selection_bound(VALUE self) +{ + return GOBJ2RVAL(gtk_text_buffer_get_selection_bound(_SELF(self))); +} + +static VALUE +rg_place_cursor(VALUE self, VALUE where) +{ + gtk_text_buffer_place_cursor(_SELF(self), RVAL2ITR(where)); + return self; +} + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_select_range(VALUE self, VALUE ins, VALUE bound) +{ + gtk_text_buffer_select_range(_SELF(self), RVAL2ITR(ins), RVAL2ITR(bound)); + return self; +} +#endif + +static VALUE +rg_get_iter_at_child_anchor(VALUE self, VALUE anchor) +{ + GtkTextIter iter; + gtk_text_buffer_get_iter_at_child_anchor(_SELF(self), &iter, RVAL2ANCHOR(anchor)); + return ITR2RVAL(&iter); +} + +static VALUE +rg_modified_p(VALUE self) +{ + return CBOOL2RVAL(gtk_text_buffer_get_modified(_SELF(self))); +} + +static VALUE +rg_set_modified(VALUE self, VALUE setting) +{ + gtk_text_buffer_set_modified(_SELF(self), RVAL2CBOOL(setting)); + return setting; +} + +static VALUE +rg_add_selection_clipboard(VALUE self, VALUE clipboard) +{ + G_CHILD_ADD(self, clipboard); + gtk_text_buffer_add_selection_clipboard(_SELF(self), RVAL2CLIPBOARD(clipboard)); + return self; +} + +static VALUE +rg_remove_selection_clipboard(VALUE self, VALUE clipboard) +{ + G_CHILD_REMOVE(self, clipboard); + gtk_text_buffer_remove_selection_clipboard(_SELF(self), RVAL2CLIPBOARD(clipboard)); + return self; +} + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_deserialize(VALUE self, VALUE content_buffer, VALUE format, VALUE iter, VALUE data) +{ + GError* error = NULL; + gboolean ret; + + StringValue(data); + ret = gtk_text_buffer_deserialize(_SELF(self), _SELF(content_buffer), + RVAL2ATOM(format), + RVAL2ITR(iter), + (const guint8*)RSTRING_PTR(data), + (gsize)RSTRING_LEN(data), + &error); + if (! ret) RAISE_GERROR(error); + return self; +} + +static VALUE +rg_deserialize_can_create_tags_p(VALUE self, VALUE format) +{ + return CBOOL2RVAL(gtk_text_buffer_deserialize_get_can_create_tags(_SELF(self), + RVAL2ATOM(format))); + +} + +static VALUE +rg_deserialize_set_can_create_tags(VALUE self, VALUE format, VALUE can_create_tags) +{ + gtk_text_buffer_deserialize_set_can_create_tags(_SELF(self), + RVAL2ATOM(format), + RVAL2CBOOL(can_create_tags)); + return self; +} + +static VALUE +rg_deserialize_formats(VALUE self) +{ + gint i; + gint n_formats; + GdkAtom* atoms = gtk_text_buffer_get_deserialize_formats(_SELF(self), &n_formats); + VALUE ary = rb_ary_new(); + + for (i = 0; i < n_formats; i++){ + rb_ary_push(ary, ATOM2RVAL(atoms[i])); + } + return ary; +} + +static VALUE +rg_serialize_formats(VALUE self) +{ + gint i; + gint n_formats; + GdkAtom* atoms = gtk_text_buffer_get_serialize_formats(_SELF(self), &n_formats); + VALUE ary = rb_ary_new(); + + for (i = 0; i < n_formats; i++){ + rb_ary_push(ary, ATOM2RVAL(atoms[i])); + } + return ary; +} + +struct callback_arg +{ + VALUE callback; + int argc; + VALUE *argv; +}; + +static VALUE +invoke_callback(VALUE data) +{ + struct callback_arg *arg = (struct callback_arg *)data; + + return rb_funcall2(arg->callback, id_call, arg->argc, arg->argv); +} + +static gboolean +deserialize_func(GtkTextBuffer *register_buffer, + GtkTextBuffer *content_buffer, + GtkTextIter *iter, + const guint8 *data, + gsize length, + gboolean create_tags, + gpointer func, + G_GNUC_UNUSED GError **error) +{ + VALUE result; + VALUE argv[5]; + struct callback_arg arg; + + argv[0] = GOBJ2RVAL(register_buffer); + argv[1] = GOBJ2RVAL(content_buffer); + argv[2] = ITR2RVAL(iter); + argv[3] = RBG_STRING_SET_UTF8_ENCODING(rb_str_new((char*)data, length)); + argv[4] = CBOOL2RVAL(create_tags); + + arg.callback = (VALUE)func; + arg.argc = 5; + arg.argv = argv; + + result = G_PROTECT_CALLBACK(invoke_callback, &arg); + return NIL_P(rb_errinfo()) ? RVAL2CBOOL(result) : FALSE; +} + +static void +remove_callback_reference(gpointer callback) +{ + G_CHILD_REMOVE(mGtk, (VALUE)callback); +} + +static VALUE +rg_register_deserialize_format(VALUE self, VALUE mime_type) +{ + VALUE block = rb_block_proc(); + GdkAtom atom; + G_CHILD_ADD(mGtk, block); + atom = gtk_text_buffer_register_deserialize_format(_SELF(self), + (const gchar*)RVAL2CSTR(mime_type), + (GtkTextBufferDeserializeFunc)deserialize_func, + (gpointer)block, + (GDestroyNotify)remove_callback_reference); + return ATOM2RVAL(atom); +} + +static VALUE +rg_register_deserialize_target(VALUE self, VALUE tagset_name) +{ + return ATOM2RVAL(gtk_text_buffer_register_deserialize_tagset(_SELF(self), + (const gchar*)(NIL_P(tagset_name) ? NULL : RVAL2CSTR(tagset_name)))); +} + +static guint8* +serialize_func(GtkTextBuffer *register_buffer, GtkTextBuffer *content_buffer, GtkTextIter *start, GtkTextIter *end, gsize *length, gpointer func) +{ + VALUE result; + VALUE argv[4]; + struct callback_arg arg; + + argv[0] = GOBJ2RVAL(register_buffer); + argv[1] = GOBJ2RVAL(content_buffer); + argv[2] = ITR2RVAL(start); + argv[3] = ITR2RVAL(end); + + arg.callback = (VALUE)func; + arg.argc = 4; + arg.argv = argv; + + /* This should return data as String */ + result = G_PROTECT_CALLBACK(invoke_callback, &arg); + StringValue(result); + *length = RSTRING_LEN(result); + return (guint8*)(NIL_P(rb_errinfo()) ? RSTRING_PTR(result) : NULL); +} + +static VALUE +rg_register_serialize_format(VALUE self, VALUE mime_type) +{ + VALUE block = rb_block_proc(); + GdkAtom atom; + G_CHILD_ADD(mGtk, block); + atom = gtk_text_buffer_register_serialize_format(_SELF(self), + (const gchar*)RVAL2CSTR(mime_type), + (GtkTextBufferSerializeFunc)serialize_func, + (gpointer)block, + (GDestroyNotify)remove_callback_reference); + return ATOM2RVAL(atom); +} + +static VALUE +rg_register_serialize_target(VALUE self, VALUE tagset_name) +{ + return ATOM2RVAL(gtk_text_buffer_register_serialize_tagset(_SELF(self), + NIL_P(tagset_name) ? NULL : RVAL2CSTR(tagset_name))); +} + +static VALUE +rg_serialize(VALUE self, VALUE content_buffer, VALUE format, VALUE start, VALUE end) +{ + gsize length; + guint8* ret = gtk_text_buffer_serialize(_SELF(self), _SELF(content_buffer), + RVAL2ATOM(format), + RVAL2ITR(start), RVAL2ITR(end), + &length); + return RBG_STRING_SET_UTF8_ENCODING(rb_str_new((char*)ret, length)); +} + +static VALUE +rg_unregister_deserialize_format(VALUE self, VALUE format) +{ + gtk_text_buffer_unregister_deserialize_format(_SELF(self), RVAL2ATOM(format)); + return self; +} + +static VALUE +rg_unregister_serialize_format(VALUE self, VALUE format) +{ + gtk_text_buffer_unregister_serialize_format(_SELF(self), RVAL2ATOM(format)); + return self; +} +#endif + +static VALUE +rg_cut_clipboard(VALUE self, VALUE clipboard, VALUE default_editable) +{ + G_CHILD_ADD(self, clipboard); + gtk_text_buffer_cut_clipboard(_SELF(self), RVAL2CLIPBOARD(clipboard), RVAL2CBOOL(default_editable)); + return self; +} + +static VALUE +rg_copy_clipboard(VALUE self, VALUE clipboard) +{ + G_CHILD_ADD(self, clipboard); + gtk_text_buffer_copy_clipboard(_SELF(self), RVAL2CLIPBOARD(clipboard)); + return self; +} + +static VALUE +rg_paste_clipboard(VALUE self, VALUE clipboard, VALUE location, VALUE default_editable) +{ + G_CHILD_ADD(self, clipboard); + gtk_text_buffer_paste_clipboard(_SELF(self), RVAL2CLIPBOARD(clipboard), + NIL_P(location) ? NULL : RVAL2ITR(location), + RVAL2CBOOL(default_editable)); + return self; +} + +static VALUE +rg_selection_bounds(VALUE self) +{ + GtkTextIter start, end; + + gboolean ret = gtk_text_buffer_get_selection_bounds(_SELF(self), &start, &end); + return rb_ary_new3(3, ITR2RVAL(&start), ITR2RVAL(&end), CBOOL2RVAL(ret)); +} + +static VALUE +rg_delete_selection(int argc, VALUE *argv, VALUE self) +{ + VALUE interactive, default_editable; + rb_scan_args(argc, argv, "20", &interactive, &default_editable); + return CBOOL2RVAL(gtk_text_buffer_delete_selection(_SELF(self), + RVAL2CBOOL(interactive), RVAL2CBOOL(default_editable))); +} + +static VALUE +rg_end_user_action(VALUE self) +{ + gtk_text_buffer_end_user_action(_SELF(self)); + return self; +} + +static VALUE +rg_begin_user_action(VALUE self) +{ + gtk_text_buffer_begin_user_action(_SELF(self)); + if (rb_block_given_p()) + rb_ensure(rb_yield, self, rg_end_user_action, self); + return self; +} + +static VALUE +rg_start_iter(VALUE self) +{ + GtkTextIter iter; + gtk_text_buffer_get_start_iter(_SELF(self), &iter); + return ITR2RVAL(&iter); +} + +static VALUE +rg_end_iter(VALUE self) +{ + GtkTextIter iter; + gtk_text_buffer_get_end_iter(_SELF(self), &iter); + return ITR2RVAL(&iter); +} + +static VALUE +rg_move_mark(VALUE self, VALUE mark, VALUE where) +{ + if (rb_obj_is_kind_of(mark, GTYPE2CLASS(GTK_TYPE_TEXT_MARK))) + gtk_text_buffer_move_mark(_SELF(self), RVAL2MARK(mark), RVAL2ITR(where)); + else + gtk_text_buffer_move_mark_by_name(_SELF(self), RVAL2CSTR(mark), RVAL2ITR(where)); + return self; +} + +static VALUE +rg_create_tag(VALUE self, VALUE tag_name, VALUE properties) +{ + GtkTextTag *tag; + VALUE ret; + + tag = gtk_text_tag_new(NIL_P(tag_name) ? (gchar*)NULL : RVAL2CSTR(tag_name)); + gtk_text_tag_table_add (gtk_text_buffer_get_tag_table(_SELF(self)), tag); + + G_SET_PROPERTIES(GOBJ2RVAL(tag), properties); + + ret = GOBJ2RVAL(tag); + + G_CHILD_ADD(self, ret); + + return ret; +} + +static VALUE +rg_insert(int argc, VALUE *argv, VALUE self) +{ + VALUE where, value, tags; + gint start_offset; + GtkTextIter start; + int i; + + rb_scan_args(argc, argv, "2*", &where, &value, &tags); + + G_CHILD_ADD(self, where); + G_CHILD_ADD(self, value); + if (rb_obj_is_kind_of(value, GTYPE2CLASS(GDK_TYPE_PIXBUF))){ + gtk_text_buffer_insert_pixbuf(_SELF(self), RVAL2ITR(where), + GDK_PIXBUF(RVAL2GOBJ(value))); + } else if (rb_obj_is_kind_of(value, GTYPE2CLASS(GTK_TYPE_TEXT_CHILD_ANCHOR))){ + gtk_text_buffer_insert_child_anchor(_SELF(self), RVAL2ITR(where), + GTK_TEXT_CHILD_ANCHOR(RVAL2GOBJ(value))); + } else { + start_offset = gtk_text_iter_get_offset(RVAL2ITR(where)); + StringValue(value); + gtk_text_buffer_insert(_SELF(self), RVAL2ITR(where), + RSTRING_PTR(value), RSTRING_LEN(value)); + + if (RARRAY_LEN(tags) == 0) + return self; + + /* TODO: Do we really want to do this before we know that everything + * below passed without any errors? */ + G_CHILD_ADD(self, tags); + + gtk_text_buffer_get_iter_at_offset(_SELF(self), &start, start_offset); + + for(i = 0; i < RARRAY_LEN(tags); i++) { + GtkTextTag *tag; + + if (rb_obj_is_kind_of(RARRAY_PTR(tags)[i], GTYPE2CLASS(GTK_TYPE_TEXT_TAG))) { + tag = RVAL2GOBJ(RARRAY_PTR(tags)[i]); + } else { + tag = gtk_text_tag_table_lookup(_SELF(self)->tag_table, + RVAL2CSTR(RARRAY_PTR(tags)[i])); + if (tag == NULL) { + g_warning ("%s: no tag with name '%s'!", + G_STRLOC, RVAL2CSTR(RARRAY_PTR(tags)[i])); + return self; + } + } + gtk_text_buffer_apply_tag(_SELF(self), tag, &start, RVAL2ITR(where)); + } + } + return self; +} + +static VALUE +rg_insert_with_tags(int argc, VALUE *argv, VALUE self) +{ + if (RVAL2CBOOL(ruby_debug)) + rb_warning("Gtk::TextBuffer#insert_with_tags is deprecated. Use Gtk::TextBuffer#insert instead."); + rg_insert(argc, argv, self); + return self; +} + +static VALUE +rg_apply_tag(VALUE self, VALUE tag, VALUE start, VALUE end) +{ + if (rb_obj_is_kind_of(tag, GTYPE2CLASS(GTK_TYPE_TEXT_TAG))) + gtk_text_buffer_apply_tag(_SELF(self), RVAL2TAG(tag), RVAL2ITR(start), RVAL2ITR(end)); + else + gtk_text_buffer_apply_tag_by_name(_SELF(self), RVAL2CSTR(tag), RVAL2ITR(start), RVAL2ITR(end)); + + return self; +} + +static VALUE +rg_remove_tag(VALUE self, VALUE tag, VALUE start, VALUE end) +{ + if (rb_obj_is_kind_of(tag, GTYPE2CLASS(GTK_TYPE_TEXT_TAG))) + gtk_text_buffer_remove_tag(_SELF(self), RVAL2TAG(tag), RVAL2ITR(start), RVAL2ITR(end)); + else + gtk_text_buffer_remove_tag_by_name(_SELF(self), RVAL2CSTR(tag), RVAL2ITR(start), RVAL2ITR(end)); + + return self; +} + +static VALUE +rg_remove_all_tags(VALUE self, VALUE start, VALUE end) +{ + gtk_text_buffer_remove_all_tags(_SELF(self), RVAL2ITR(start), RVAL2ITR(end)); + return self; +} + +static VALUE +rg_get_iter_at_line_offset(VALUE self, VALUE line_number, VALUE char_offset) +{ + GtkTextIter iter; + gtk_text_buffer_get_iter_at_line_offset(_SELF(self), &iter, NUM2INT(line_number), NUM2INT(char_offset)); + return ITR2RVAL(&iter); +} + +static VALUE +rg_get_iter_at_line_index(VALUE self, VALUE line_number, VALUE byte_index) +{ + GtkTextIter iter; + gtk_text_buffer_get_iter_at_line_index(_SELF(self), &iter, NUM2INT(line_number), NUM2INT(byte_index)); + return ITR2RVAL(&iter); +} + +static VALUE +rg_get_iter_at_offset(VALUE self, VALUE char_offset) +{ + GtkTextIter iter; + gtk_text_buffer_get_iter_at_offset(_SELF(self), &iter, NUM2INT(char_offset)); + return ITR2RVAL(&iter); +} + +static VALUE +rg_get_iter_at_line(VALUE self, VALUE line_number) +{ + GtkTextIter iter; + gtk_text_buffer_get_iter_at_line(_SELF(self), &iter, NUM2INT(line_number)); + return ITR2RVAL(&iter); +} + +static VALUE +rg_bounds(VALUE self) +{ + GtkTextIter start, end; + VALUE result; + + gtk_text_buffer_get_bounds(_SELF(self), &start, &end); + result = rb_ary_new(); + rb_ary_push(result, ITR2RVAL(&start)); + rb_ary_push(result, ITR2RVAL(&end)); + + return result; +} + +static VALUE +rg_get_iter_at_mark(VALUE self, VALUE mark) +{ + GtkTextIter iter; + gtk_text_buffer_get_iter_at_mark(_SELF(self), &iter, RVAL2MARK(mark)); + return ITR2RVAL(&iter); +} + +void +Init_gtk_textbuffer(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TEXT_BUFFER, "TextBuffer", mGtk); + + id_tagtable = rb_intern("tagtable"); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(line_count, 0); + RG_DEF_METHOD(char_count, 0); + + G_REPLACE_SET_PROPERTY(RG_TARGET_NAMESPACE, "text", txt_set_text, 1); + RG_DEF_METHOD(insert, -1); + RG_DEF_METHOD(insert_with_tags, -1); +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(backspace, 3); +#endif + RG_DEF_METHOD(insert_at_cursor, 1); + RG_DEF_METHOD(insert_interactive, 3); + RG_DEF_METHOD(insert_interactive_at_cursor, 2); + RG_DEF_METHOD(insert_range, 3); + RG_DEF_METHOD(insert_range_interactive, 4); + + RG_DEF_METHOD(delete, 2); + RG_DEF_METHOD(delete_interactive, 3); + + RG_DEF_METHOD(get_text, -1); + G_REPLACE_GET_PROPERTY(RG_TARGET_NAMESPACE, "text", txt_get_text_all, 0); + RG_DEF_METHOD(get_slice, -1); + RG_DEF_METHOD(slice, 0); + + RG_DEF_METHOD(insert_pixbuf, 2); + RG_DEF_METHOD(insert_child_anchor, 2); + RG_DEF_METHOD(create_child_anchor, 1); + + RG_DEF_METHOD(create_mark, 3); +#if GTK_CHECK_VERSION(2,12,0) + RG_DEF_METHOD(add_mark, 2); +#endif + RG_DEF_METHOD(delete_mark, 1); + + RG_DEF_METHOD(get_mark, 1); +/* Comment out because this method's name is very bad. + Use Gtk::TextBuffer#get_mark("insert") instead. + RG_DEF_METHOD(get_insert, 0); +*/ + RG_DEF_METHOD(selection_bound, 0); + RG_DEF_METHOD(place_cursor, 1); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(select_range, 2); +#endif + RG_DEF_METHOD_P(modified, 0); + RG_DEF_METHOD(set_modified, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "modified"); + + RG_DEF_METHOD(add_selection_clipboard, 1); + RG_DEF_METHOD(remove_selection_clipboard, 1); +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD(deserialize, 4); + RG_DEF_METHOD_P(deserialize_can_create_tags, 1); + RG_DEF_METHOD(deserialize_set_can_create_tags, 2); + RG_DEF_METHOD(deserialize_formats, 0); + RG_DEF_METHOD(serialize_formats, 0); + RG_DEF_METHOD(register_deserialize_format, 1); + RG_DEF_METHOD(register_deserialize_target, 1); + RG_DEF_METHOD(register_serialize_format, 1); + RG_DEF_METHOD(register_serialize_target, 1); + RG_DEF_METHOD(serialize, 4); + RG_DEF_METHOD(unregister_deserialize_format, 1); + RG_DEF_METHOD(unregister_serialize_format, 1); +#endif + RG_DEF_METHOD(cut_clipboard, 2); + RG_DEF_METHOD(copy_clipboard, 1); + RG_DEF_METHOD(paste_clipboard, 3); + + RG_DEF_METHOD(selection_bounds, 0); + RG_DEF_METHOD(delete_selection, -1); + + RG_DEF_METHOD(begin_user_action, 0); + RG_DEF_METHOD(end_user_action, 0); + + RG_DEF_METHOD(start_iter, 0); + RG_DEF_METHOD(end_iter, 0); + RG_DEF_METHOD(get_iter_at_line_offset, 2); + RG_DEF_METHOD(get_iter_at_line_index, 2); + RG_DEF_METHOD(get_iter_at_offset, 1); + RG_DEF_METHOD(get_iter_at_line, 1); + RG_DEF_METHOD(bounds, 0); + RG_DEF_METHOD(get_iter_at_mark, 1); + RG_DEF_METHOD(move_mark, 2); + RG_DEF_METHOD(get_iter_at_child_anchor, 1); + + RG_DEF_METHOD(create_tag, 2); + RG_DEF_METHOD(apply_tag, 3); + RG_DEF_METHOD(remove_tag, 3); + RG_DEF_METHOD(remove_all_tags, 2); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextchild.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextchild.c new file mode 100644 index 0000000..520cc56 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextchild.c @@ -0,0 +1,55 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * Copyright (C) 2002-2006 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTextChildAnchor +#define _SELF(self) GTK_TEXT_CHILD_ANCHOR(RVAL2GOBJ(self)) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_text_child_anchor_new()); + return Qnil; +} + +static VALUE +rg_widgets(VALUE self) +{ + return GLIST2ARYF(gtk_text_child_anchor_get_widgets(_SELF(self))); +} + +static VALUE +rg_deleted_p(VALUE self) +{ + return CBOOL2RVAL(gtk_text_child_anchor_get_deleted(_SELF(self))); +} + +void +Init_gtk_textchild(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TEXT_CHILD_ANCHOR, "TextChildAnchor", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(widgets, 0); + RG_DEF_METHOD_P(deleted, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextiter.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextiter.c new file mode 100644 index 0000000..9ec43fd --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextiter.c @@ -0,0 +1,514 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTextIter +#define _SELF(s) ((GtkTextIter*)RVAL2BOXED(s, GTK_TYPE_TEXT_ITER)) +#define RVAL2TAG(t) (GTK_TEXT_TAG(RVAL2GOBJ(t))) +#define ITR2RVAL(i) (BOXED2RVAL(i, GTK_TYPE_TEXT_ITER)) + +static gboolean is_compat_240; +static ID id_pixbuf; + +static VALUE +rg_buffer(VALUE self) +{ + return GOBJ2RVAL(gtk_text_iter_get_buffer(_SELF(self))); +} + +#define def_gint_getter(__name__) \ +static VALUE \ +get_##__name__(VALUE self) \ +{ \ + return INT2NUM(gtk_text_iter_get_##__name__(_SELF(self))); \ +} + +def_gint_getter(offset) +def_gint_getter(line) +def_gint_getter(line_offset) +def_gint_getter(line_index) +def_gint_getter(visible_line_offset) +def_gint_getter(visible_line_index) + +static VALUE +rg_char(VALUE self) +{ + gchar buf[10]; + gint len = g_unichar_to_utf8(gtk_text_iter_get_char(_SELF(self)), buf); + buf[len] = '\0'; + return CSTR2RVAL(buf); +} + +static VALUE +rg_get_slice(VALUE self, VALUE rhs) +{ + return CSTR2RVAL(gtk_text_iter_get_slice(_SELF(self), _SELF(rhs))); +} + +static VALUE +rg_get_text(VALUE self, VALUE rhs) +{ + return CSTR2RVAL(gtk_text_iter_get_text(_SELF(self), _SELF(rhs))); +} + +static VALUE +rg_get_visible_slice(VALUE self, VALUE rhs) +{ + return CSTR2RVAL(gtk_text_iter_get_visible_slice(_SELF(self), _SELF(rhs))); +} + +static VALUE +rg_get_visible_text(VALUE self, VALUE rhs) +{ + return CSTR2RVAL(gtk_text_iter_get_visible_text(_SELF(self), _SELF(rhs))); +} + +static VALUE +rg_pixbuf(VALUE self) +{ + GdkPixbuf* pixbuf = gtk_text_iter_get_pixbuf(_SELF(self)); + VALUE ret = Qnil; + if (pixbuf){ + ret = GOBJ2RVAL(pixbuf); + G_CHILD_SET(self, id_pixbuf, ret); + } + return ret; +} + +static VALUE +rg_marks(VALUE self) +{ + return GSLIST2ARYF(gtk_text_iter_get_marks(_SELF(self))); +} + +static VALUE +rg_toggled_tags(VALUE self, VALUE toggled_on) +{ + return GSLIST2ARYF(gtk_text_iter_get_toggled_tags(_SELF(self), RVAL2CBOOL(toggled_on))); +} + +static VALUE +rg_child_anchor(VALUE self) +{ + GtkTextChildAnchor* anchor = gtk_text_iter_get_child_anchor(_SELF(self)); + return anchor ? GOBJ2RVAL(anchor) : Qnil; +} + +static VALUE +rg_begins_tag_p(VALUE self, VALUE tag) +{ + return CBOOL2RVAL(gtk_text_iter_begins_tag(_SELF(self), RVAL2TAG(tag))); +} + +static VALUE +rg_ends_tag_p(VALUE self, VALUE tag) +{ + return CBOOL2RVAL(gtk_text_iter_ends_tag(_SELF(self), RVAL2TAG(tag))); +} + +static VALUE +rg_toggles_tag_p(VALUE self, VALUE tag) +{ + return CBOOL2RVAL(gtk_text_iter_toggles_tag(_SELF(self), RVAL2TAG(tag))); +} + +static VALUE +rg_has_tag_p(VALUE self, VALUE tag) +{ + return CBOOL2RVAL(gtk_text_iter_has_tag(_SELF(self), RVAL2TAG(tag))); +} + +static VALUE +rg_tags(VALUE self) +{ + return GSLIST2ARYF(gtk_text_iter_get_tags(_SELF(self))); +} + +static VALUE +rg_editable_p(VALUE self, VALUE default_setting) +{ + return CBOOL2RVAL(gtk_text_iter_editable(_SELF(self), RVAL2CBOOL(default_setting))); +} + +static VALUE +rg_can_insert_p(VALUE self, VALUE default_setting) +{ + return CBOOL2RVAL(gtk_text_iter_can_insert(_SELF(self), RVAL2CBOOL(default_setting))); +} + +#define def_predicate(__name__) \ +static VALUE \ +__name__(VALUE self) \ +{ \ + return CBOOL2RVAL(gtk_text_iter_##__name__(_SELF(self))); \ +} + +def_predicate(starts_word) +def_predicate(ends_word) +def_predicate(inside_word) +def_predicate(starts_sentence) +def_predicate(ends_sentence) +def_predicate(starts_line) +def_predicate(ends_line) +def_predicate(is_cursor_position) + +def_gint_getter(chars_in_line) +def_gint_getter(bytes_in_line) + +static VALUE +rg_attributes(VALUE self) +{ + GtkTextAttributes attr; + + if(gtk_text_iter_get_attributes(_SELF(self), &attr) == TRUE){ + return BOXED2RVAL(&attr, GTK_TYPE_TEXT_ATTRIBUTES); + } else { + return Qnil; + } +} + +static VALUE +rg_language(VALUE self) +{ + return CSTR2RVAL(pango_language_to_string(gtk_text_iter_get_language(_SELF(self)))); +} + +def_predicate(is_end) +def_predicate(is_start) + +#define def_move(__name__) \ +static VALUE \ +__name__(VALUE self) \ +{ \ + return CBOOL2RVAL(gtk_text_iter_##__name__(_SELF(self))); \ +} + +#define def_move_gint(__name__) \ +static VALUE \ +__name__(VALUE self, VALUE i) \ +{ \ + return CBOOL2RVAL(gtk_text_iter_##__name__(_SELF(self), NUM2INT(i))); \ +} + +def_move(forward_char) +def_move(backward_char) +def_move_gint(forward_chars) +def_move_gint(backward_chars) +def_move(forward_line) +def_move(backward_line) +def_move_gint(forward_lines) +def_move_gint(backward_lines) +def_move(forward_word_end) +def_move(backward_word_start) +def_move_gint(forward_word_ends) +def_move_gint(backward_word_starts) +def_move(forward_sentence_end) +def_move(backward_sentence_start) +def_move_gint(forward_sentence_ends) +def_move_gint(backward_sentence_starts) + +#if GTK_CHECK_VERSION(2,4,0) +def_move_gint(forward_visible_word_ends) +def_move_gint(backward_visible_word_starts) +def_move(forward_visible_word_end) +def_move(backward_visible_word_start) +def_move(forward_visible_cursor_position) +def_move(backward_visible_cursor_position) +def_move_gint(forward_visible_cursor_positions) +def_move_gint(backward_visible_cursor_positions) +#endif +#if GTK_CHECK_VERSION(2,8,0) +def_move(forward_visible_line) +def_move(backward_visible_line) +def_move_gint(forward_visible_lines) +def_move_gint(backward_visible_lines) +#endif +def_move(forward_cursor_position) +def_move(backward_cursor_position) +def_move_gint(forward_cursor_positions) +def_move_gint(backward_cursor_positions) +def_move(forward_to_line_end) + +static VALUE +rg_forward_to_end(VALUE self) +{ + gtk_text_iter_forward_to_end(_SELF(self)); + return self; +} + +#define def_gint_setter(__name__) \ +static VALUE \ +set_##__name__(VALUE self, VALUE val) \ +{ \ + gtk_text_iter_set_##__name__(_SELF(self), NUM2INT(val)); \ + return val; \ +} + +def_gint_setter(offset) +def_gint_setter(line) +def_gint_setter(line_offset) +def_gint_setter(line_index) + +def_gint_setter(visible_line_offset) +def_gint_setter(visible_line_index) + +static VALUE +rg_forward_to_tag_toggle(int argc, VALUE *argv, VALUE self) +{ + VALUE tag; + + rb_scan_args(argc, argv, "01", &tag); + return CBOOL2RVAL(gtk_text_iter_forward_to_tag_toggle(_SELF(self), + NIL_P(tag) ? NULL : RVAL2TAG(tag))); +} + +static VALUE +rg_backward_to_tag_toggle(int argc, VALUE *argv, VALUE self) +{ + VALUE tag; + + rb_scan_args(argc, argv, "01", &tag); + return CBOOL2RVAL(gtk_text_iter_backward_to_tag_toggle(_SELF(self), + NIL_P(tag) ? NULL : RVAL2TAG(tag))); +} + +static gboolean +char_predicate_func(guint32 ch, gpointer func) +{ + return RVAL2CBOOL(rb_funcall((VALUE)func, id_call, 1, UINT2NUM(ch))); +} + +static VALUE +rg_forward_find_char(int argc, VALUE *argv, VALUE self) +{ + VALUE limit; + volatile VALUE func = rb_block_proc(); + + rb_scan_args(argc, argv, "01", &limit); + return CBOOL2RVAL(gtk_text_iter_forward_find_char(_SELF(self), + (GtkTextCharPredicate)char_predicate_func, + (gpointer)func, + NIL_P(limit) ? NULL : _SELF(limit))); +} + +static VALUE +rg_backward_find_char(int argc, VALUE *argv, VALUE self) +{ + VALUE limit; + volatile VALUE func = rb_block_proc(); + + rb_scan_args(argc, argv, "01", &limit); + return CBOOL2RVAL(gtk_text_iter_backward_find_char(_SELF(self), + (GtkTextCharPredicate)char_predicate_func, + (gpointer)func, + NIL_P(limit) ? NULL : _SELF(limit))); +} + +static VALUE +rg_forward_search(int argc, VALUE *argv, VALUE self) +{ + GtkTextIter m_start, m_end; + VALUE str, flags, limit; + gboolean ret; + + rb_scan_args(argc, argv, "21", &str, &flags, &limit); + + if (is_compat_240){ + ret = gtk_text_iter_forward_search(_SELF(self), RVAL2CSTR(str), + RVAL2GFLAGS(flags, GTK_TYPE_TEXT_SEARCH_FLAGS), + &m_start, &m_end, + NIL_P(limit) ? NULL : _SELF(limit)); + } else { + ret = gtk_text_iter_forward_search(_SELF(self), RVAL2CSTR(str), + RVAL2GENUM(flags, GTK_TYPE_TEXT_SEARCH_FLAGS), + &m_start, &m_end, + NIL_P(limit) ? NULL : _SELF(limit)); + } + return ret ? rb_ary_new3(2, ITR2RVAL(&m_start), ITR2RVAL(&m_end)) : Qnil; +} + +static VALUE +rg_backward_search(int argc, VALUE *argv, VALUE self) +{ + GtkTextIter m_start, m_end; + VALUE str, flags, limit; + gboolean ret; + + rb_scan_args(argc, argv, "21", &str, &flags, &limit); + if (is_compat_240){ + ret = gtk_text_iter_backward_search(_SELF(self), RVAL2CSTR(str), + RVAL2GFLAGS(flags, GTK_TYPE_TEXT_SEARCH_FLAGS), + &m_start, &m_end, + NIL_P(limit) ? NULL : _SELF(limit)); + } else { + ret = gtk_text_iter_backward_search(_SELF(self), RVAL2CSTR(str), + RVAL2GENUM(flags, GTK_TYPE_TEXT_SEARCH_FLAGS), + &m_start, &m_end, + NIL_P(limit) ? NULL : _SELF(limit)); + } + return ret ? rb_ary_new3(2, ITR2RVAL(&m_start), ITR2RVAL(&m_end)) : Qnil; +} + +static VALUE +rg_operator_equal(VALUE self, VALUE other) +{ + return CBOOL2RVAL(gtk_text_iter_equal(_SELF(self), _SELF(other))); +} + +static VALUE +rg_operator_compare(VALUE self, VALUE rhs) +{ + return INT2NUM(gtk_text_iter_compare(_SELF(self), _SELF(rhs))); +} + +/* + The following methods don't have to be implimented. + Including Comparable module is enough. + +gboolean gtk_text_iter_in_range (const GtkTextIter *iter, + const GtkTextIter *start, + const GtkTextIter *end); +void gtk_text_iter_order (GtkTextIter *first, + GtkTextIter *second); +*/ + +void +Init_gtk_textiter(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TEXT_ITER, "TextIter", mGtk); + rb_include_module(RG_TARGET_NAMESPACE, rb_mComparable); + + is_compat_240 = gtk_check_version(2, 4, 0) ? FALSE : TRUE; + + id_pixbuf = rb_intern("pixbuf"); + + RG_DEF_METHOD(buffer, 0); + rb_define_method(RG_TARGET_NAMESPACE, "offset", get_offset, 0); + rb_define_method(RG_TARGET_NAMESPACE, "line", get_line, 0); + rb_define_method(RG_TARGET_NAMESPACE, "line_offset", get_line_offset, 0); + rb_define_method(RG_TARGET_NAMESPACE, "line_index", get_line_index, 0); + rb_define_method(RG_TARGET_NAMESPACE, "visible_line_offset", get_visible_line_offset, 0); + rb_define_method(RG_TARGET_NAMESPACE, "visible_line_index", get_visible_line_index, 0); + RG_DEF_METHOD(char, 0); + + RG_DEF_METHOD(get_slice, 1); + RG_DEF_METHOD(get_text, 1); + RG_DEF_METHOD(get_visible_slice, 1); + RG_DEF_METHOD(get_visible_text, 1); + + RG_DEF_METHOD(pixbuf, 0); + RG_DEF_METHOD(marks, 0); + RG_DEF_METHOD(child_anchor, 0); + + RG_DEF_METHOD(toggled_tags, 1); + RG_DEF_METHOD_P(begins_tag, 1); + RG_DEF_METHOD_P(ends_tag, 1); + RG_DEF_METHOD_P(toggles_tag, 1); + RG_DEF_METHOD_P(has_tag, 1); + RG_DEF_METHOD(tags, 0); + + RG_DEF_METHOD_P(editable, 1); + RG_DEF_METHOD_P(can_insert, 1); + + rb_define_method(RG_TARGET_NAMESPACE, "starts_word?", starts_word, 0); + rb_define_method(RG_TARGET_NAMESPACE, "ends_word?", ends_word, 0); + rb_define_method(RG_TARGET_NAMESPACE, "inside_word?", inside_word, 0); + rb_define_method(RG_TARGET_NAMESPACE, "starts_sentence?", starts_sentence, 0); + rb_define_method(RG_TARGET_NAMESPACE, "ends_sentence?", ends_sentence, 0); + rb_define_method(RG_TARGET_NAMESPACE, "starts_line?", starts_line, 0); + rb_define_method(RG_TARGET_NAMESPACE, "ends_line?", ends_line, 0); + rb_define_method(RG_TARGET_NAMESPACE, "cursor_position?", is_cursor_position, 0); + + rb_define_method(RG_TARGET_NAMESPACE, "chars_in_line", get_chars_in_line, 0); + rb_define_method(RG_TARGET_NAMESPACE, "bytes_in_line", get_bytes_in_line, 0); + + RG_DEF_METHOD(attributes, 0); + + RG_DEF_METHOD(language, 0); + rb_define_method(RG_TARGET_NAMESPACE, "end?", is_end, 0); + rb_define_method(RG_TARGET_NAMESPACE, "start?", is_start, 0); + + rb_define_method(RG_TARGET_NAMESPACE, "forward_char", forward_char, 0); + rb_define_method(RG_TARGET_NAMESPACE, "backward_char", backward_char, 0); + rb_define_method(RG_TARGET_NAMESPACE, "forward_chars", forward_chars, 1); + rb_define_method(RG_TARGET_NAMESPACE, "backward_chars", backward_chars, 1); + rb_define_method(RG_TARGET_NAMESPACE, "forward_line", forward_line, 0); + rb_define_method(RG_TARGET_NAMESPACE, "backward_line", backward_line, 0); + rb_define_method(RG_TARGET_NAMESPACE, "forward_lines", forward_lines, 1); + rb_define_method(RG_TARGET_NAMESPACE, "backward_lines", backward_lines, 1); + rb_define_method(RG_TARGET_NAMESPACE, "forward_word_end", forward_word_end, 0); + rb_define_method(RG_TARGET_NAMESPACE, "backward_word_start", backward_word_start, 0); + rb_define_method(RG_TARGET_NAMESPACE, "forward_word_ends", forward_word_ends, 1); + rb_define_method(RG_TARGET_NAMESPACE, "backward_word_starts", backward_word_starts, 1); + rb_define_method(RG_TARGET_NAMESPACE, "forward_sentence_end", forward_sentence_end, 0); + rb_define_method(RG_TARGET_NAMESPACE, "backward_sentence_start", backward_sentence_start, 0); + rb_define_method(RG_TARGET_NAMESPACE, "forward_sentence_ends", forward_sentence_ends, 1); + rb_define_method(RG_TARGET_NAMESPACE, "backward_sentence_starts", backward_sentence_starts, 1); + +#if GTK_CHECK_VERSION(2,4,0) + rb_define_method(RG_TARGET_NAMESPACE, "forward_visible_word_ends", forward_visible_word_ends, 1); + rb_define_method(RG_TARGET_NAMESPACE, "backward_visible_word_starts", backward_visible_word_starts, 1); + rb_define_method(RG_TARGET_NAMESPACE, "forward_visible_word_end", forward_visible_word_end, 0); + rb_define_method(RG_TARGET_NAMESPACE, "backword_visible_word_start", backward_visible_word_start, 0); + rb_define_method(RG_TARGET_NAMESPACE, "forward_visible_cursor_position", forward_visible_cursor_position, 0); + rb_define_method(RG_TARGET_NAMESPACE, "backward_visible_cursor_position", backward_visible_cursor_position, 0); + rb_define_method(RG_TARGET_NAMESPACE, "forward_visible_cursor_positions", forward_visible_cursor_positions, 1); + rb_define_method(RG_TARGET_NAMESPACE, "backward_visible_cursor_positions", backward_visible_cursor_positions, 1); +#endif +#if GTK_CHECK_VERSION(2,8,0) + rb_define_method(RG_TARGET_NAMESPACE, "forward_visible_line", forward_visible_line, 0); + rb_define_method(RG_TARGET_NAMESPACE, "backward_visible_line", backward_visible_line, 0); + rb_define_method(RG_TARGET_NAMESPACE, "forward_visible_lines", forward_visible_lines, 1); + rb_define_method(RG_TARGET_NAMESPACE, "backward_visible_lines", backward_visible_lines, 1); +#endif + rb_define_method(RG_TARGET_NAMESPACE, "forward_cursor_position", forward_cursor_position, 0); + rb_define_method(RG_TARGET_NAMESPACE, "backward_cursor_position", backward_cursor_position, 0); + rb_define_method(RG_TARGET_NAMESPACE, "forward_cursor_positions", forward_cursor_positions, 1); + rb_define_method(RG_TARGET_NAMESPACE, "backward_cursor_positions", backward_cursor_positions, 1); + RG_DEF_METHOD(forward_to_end, 0); + rb_define_method(RG_TARGET_NAMESPACE, "forward_to_line_end", forward_to_line_end, 0); + + rb_define_method(RG_TARGET_NAMESPACE, "set_offset", set_offset, 1); + rb_define_method(RG_TARGET_NAMESPACE, "set_line", set_line, 1); + rb_define_method(RG_TARGET_NAMESPACE, "set_line_offset", set_line_offset, 1); + rb_define_method(RG_TARGET_NAMESPACE, "set_line_index", set_line_index, 1); + + rb_define_method(RG_TARGET_NAMESPACE, "set_visible_line_offset", set_visible_line_offset, 1); + rb_define_method(RG_TARGET_NAMESPACE, "set_visible_line_index", set_visible_line_index, 1); + + RG_DEF_METHOD(forward_to_tag_toggle, -1); + RG_DEF_METHOD(backward_to_tag_toggle, -1); + RG_DEF_METHOD(forward_find_char, -1); + RG_DEF_METHOD(backward_find_char, -1); + RG_DEF_METHOD(forward_search, -1); + RG_DEF_METHOD(backward_search, -1); + + RG_DEF_METHOD_OPERATOR("==", equal, 1); + RG_DEF_METHOD_OPERATOR("<=>", compare, 1); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + + /* GtkTextSearchFlags */ + G_DEF_CLASS(GTK_TYPE_TEXT_SEARCH_FLAGS, "SearchFlags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_TEXT_SEARCH_FLAGS, "GTK_TEXT_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextmark.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextmark.c new file mode 100644 index 0000000..57a4b24 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextmark.c @@ -0,0 +1,76 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTextMark +#define _SELF(s) (GTK_TEXT_MARK(RVAL2GOBJ(s))) + +#if GTK_CHECK_VERSION(2,12,0) +static VALUE +rg_initialize(VALUE self, VALUE name, VALUE left_gravity) +{ + if (NIL_P(name)) + G_INITIALIZE(self, gtk_text_mark_new(NULL, RVAL2CBOOL(left_gravity))); + else + G_INITIALIZE(self, gtk_text_mark_new(RVAL2CSTR(name), RVAL2CBOOL(left_gravity))); + return Qnil; +} +#endif + +static VALUE +rg_set_visible(VALUE self, VALUE setting) +{ + gtk_text_mark_set_visible(_SELF(self), RVAL2CBOOL(setting)); + return setting; +} + +static VALUE +rg_visible_p(VALUE self) +{ + return CBOOL2RVAL(gtk_text_mark_get_visible(_SELF(self))); +} + +static VALUE +rg_deleted_p(VALUE self) +{ + return CBOOL2RVAL(gtk_text_mark_get_deleted(_SELF(self))); +} + +static VALUE +rg_buffer(VALUE self) +{ + return GOBJ2RVAL(gtk_text_mark_get_buffer(_SELF(self))); +} + +void +Init_gtk_textmark(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TEXT_MARK, "TextMark", mGtk); +#if GTK_CHECK_VERSION(2,12,0) + RG_DEF_METHOD(initialize, 2); +#endif + RG_DEF_METHOD(set_visible, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "visible"); + RG_DEF_METHOD_P(visible, 0); + RG_DEF_METHOD_P(deleted, 0); + RG_DEF_METHOD(buffer, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktexttag.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktexttag.c new file mode 100644 index 0000000..c04237b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktexttag.c @@ -0,0 +1,71 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masahiro Sakai + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTextTag + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE name; + rb_scan_args(argc, argv, "01", &name); + G_INITIALIZE(self, gtk_text_tag_new(NIL_P(name) ? NULL : RVAL2CSTR(name))); + return Qnil; +} + +static VALUE +rg_priority(VALUE self) +{ + return INT2NUM(gtk_text_tag_get_priority(GTK_TEXT_TAG(RVAL2GOBJ(self)))); +} + +static VALUE +rg_set_priority(VALUE self, VALUE priority) +{ + gtk_text_tag_set_priority(GTK_TEXT_TAG(RVAL2GOBJ(self)), NUM2INT(priority)); + return priority; +} + +static VALUE +rg_event(VALUE self, VALUE event_object, VALUE event, VALUE iter) +{ + gboolean ret = gtk_text_tag_event(GTK_TEXT_TAG(RVAL2GOBJ(self)), + RVAL2GOBJ(event_object), + RVAL2GEV(event), + (GtkTextIter*)RVAL2BOXED(iter, GTK_TYPE_TEXT_ITER)); + return CBOOL2RVAL(ret); +} + +void +Init_gtk_texttag(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TEXT_TAG, "TextTag", mGtk); + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(priority, 0); + RG_DEF_METHOD(set_priority, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "priority"); + RG_DEF_METHOD(event, 3); + + /* GtkWrapMode */ + G_DEF_CLASS(GTK_TYPE_WRAP_MODE, "WrapMode", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_WRAP_MODE, "GTK_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktexttagtable.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktexttagtable.c new file mode 100644 index 0000000..72bdca2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktexttagtable.c @@ -0,0 +1,97 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 OGASAWARA, Takeshi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTextTagTable +#define _SELF(self) (GTK_TEXT_TAG_TABLE(RVAL2GOBJ(self))) +#define RVAL2TAG(t) (GTK_TEXT_TAG(RVAL2GOBJ(t))) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, gtk_text_tag_table_new()); + return Qnil; +} + +static VALUE +rg_add(VALUE self, VALUE tag) +{ + G_CHILD_ADD(self, tag); + gtk_text_tag_table_add(_SELF(self), RVAL2TAG(tag)); + return self; +} + +static VALUE +rg_remove(VALUE self, VALUE tag) +{ + G_CHILD_REMOVE(self, tag); + gtk_text_tag_table_remove(_SELF(self), RVAL2TAG(tag)); + return self; +} + +static VALUE +rg_lookup(VALUE self, VALUE name) +{ + VALUE ret = Qnil; + GtkTextTag* tag = gtk_text_tag_table_lookup(_SELF(self), RVAL2CSTR(name)); + if (tag){ + ret = GOBJ2RVAL(tag); + G_CHILD_ADD(self, ret); + } + return ret; +} + +static gboolean +txt_tt_foreach_func(GtkTextTag *tag, gpointer func) +{ + return RVAL2CBOOL(rb_funcall((VALUE)func, id_call, 1, GOBJ2RVAL(tag))); +} + +static VALUE +rg_each(VALUE self) +{ + volatile VALUE func = rb_block_proc(); + gtk_text_tag_table_foreach(_SELF(self), + (GtkTextTagTableForeach)txt_tt_foreach_func, + (gpointer)func); + return self; +} + +static VALUE +rg_size(VALUE self) +{ + return INT2NUM(gtk_text_tag_table_get_size(_SELF(self))); +} + +void +Init_gtk_text_tag_table(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TEXT_TAG_TABLE, "TextTagTable", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(add, 1); + RG_DEF_METHOD(remove, 1); + RG_DEF_METHOD(lookup, 1); + RG_DEF_ALIAS("[]", "lookup"); + RG_DEF_METHOD(each, 0); + RG_DEF_METHOD(size, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextview.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextview.c new file mode 100644 index 0000000..2ff8ad9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktextview.c @@ -0,0 +1,330 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTextView +#define _SELF(self) (GTK_TEXT_VIEW(RVAL2GOBJ(self))) +#define RVAL2BUFFER(b) (GTK_TEXT_BUFFER(RVAL2GOBJ(b))) +#define RVAL2MARK(m) (GTK_TEXT_MARK(RVAL2GOBJ(m))) +#define RVAL2ITR(i) ((GtkTextIter*)(RVAL2BOXED(i, GTK_TYPE_TEXT_ITER))) +#define ITR2RVAL(i) (BOXED2RVAL(i, GTK_TYPE_TEXT_ITER)) + +static ID id_buffer; + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE buffer; + GtkWidget* widget; + rb_scan_args(argc, argv, "01", &buffer); + + if (NIL_P(buffer)) + widget = gtk_text_view_new(); + else { + G_CHILD_SET(self, id_buffer, buffer); + widget = gtk_text_view_new_with_buffer(RVAL2BUFFER(buffer)); + } + + RBGTK_INITIALIZE(self, widget); + return self; +} + +static VALUE +textview_set_buffer(VALUE self, VALUE buf) +{ + G_CHILD_SET(self, id_buffer, buf); + gtk_text_view_set_buffer(_SELF(self), + NIL_P(buf) ? NULL : RVAL2BUFFER(buf)); + return self; +} + +static VALUE +textview_get_buffer(VALUE self) +{ + VALUE buf = GOBJ2RVAL(gtk_text_view_get_buffer(_SELF(self))); + G_CHILD_SET(self, id_buffer, buf); + + return buf; +} + +static VALUE +rg_scroll_to_mark(VALUE self, VALUE mark, VALUE within_margin, VALUE use_align, VALUE xalign, VALUE yalign) +{ + gtk_text_view_scroll_to_mark(_SELF(self), RVAL2MARK(mark), + NUM2DBL(within_margin), RVAL2CBOOL(use_align), + NUM2DBL(xalign), NUM2DBL(yalign)); + return self; +} + +static VALUE +rg_scroll_to_iter(VALUE self, VALUE iter, VALUE within_margin, VALUE use_align, VALUE xalign, VALUE yalign) +{ + return CBOOL2RVAL(gtk_text_view_scroll_to_iter(_SELF(self), RVAL2ITR(iter), + NUM2DBL(within_margin), RVAL2CBOOL(use_align), + NUM2DBL(xalign), NUM2DBL(yalign))); +} + +static VALUE +rg_scroll_mark_onscreen(VALUE self, VALUE mark) +{ + gtk_text_view_scroll_mark_onscreen(_SELF(self), RVAL2MARK(mark)); + return self; +} + +static VALUE +rg_move_mark_onscreen(VALUE self, VALUE mark) +{ + return CBOOL2RVAL(gtk_text_view_move_mark_onscreen(_SELF(self), RVAL2MARK(mark))); +} + +static VALUE +rg_place_cursor_onscreen(VALUE self) +{ + return CBOOL2RVAL(gtk_text_view_place_cursor_onscreen(_SELF(self))); +} + +static VALUE +rg_visible_rect(VALUE self) +{ + GdkRectangle rect; + gtk_text_view_get_visible_rect(_SELF(self), &rect); + return BOXED2RVAL(&rect, GDK_TYPE_RECTANGLE); +} + +static VALUE +rg_get_iter_location(VALUE self, VALUE iter) +{ + GdkRectangle rect; + gtk_text_view_get_iter_location(_SELF(self), RVAL2ITR(iter), &rect); + return BOXED2RVAL(&rect, GDK_TYPE_RECTANGLE); +} + +static VALUE +rg_get_line_at_y(VALUE self, VALUE y) +{ + GtkTextIter target_iter; + gint line_top; + gtk_text_view_get_line_at_y(_SELF(self), &target_iter, NUM2INT(y), &line_top); + return rb_ary_new3(2, ITR2RVAL(&target_iter), INT2NUM(line_top)); +} + +static VALUE +rg_get_line_yrange(VALUE self, VALUE iter) +{ + int y, height; + gtk_text_view_get_line_yrange(_SELF(self), RVAL2ITR(iter), &y, &height); + + return rb_ary_new3(2, INT2NUM(y), INT2NUM(height)); +} + +static VALUE +rg_get_iter_at_location(VALUE self, VALUE x, VALUE y) +{ + GtkTextIter iter; + gtk_text_view_get_iter_at_location(_SELF(self), &iter, NUM2INT(x), NUM2INT(y)); + return ITR2RVAL(&iter); +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_get_iter_at_position(VALUE self, VALUE x, VALUE y) +{ + GtkTextIter iter; + gint trailing; + gtk_text_view_get_iter_at_position(_SELF(self), &iter, &trailing, NUM2INT(x), NUM2INT(y)); + return rb_assoc_new(ITR2RVAL(&iter), INT2NUM(trailing)); +} +#endif + +static VALUE +rg_buffer_to_window_coords(VALUE self, VALUE wintype, VALUE buffer_x, VALUE buffer_y) +{ + int window_x, window_y; + gtk_text_view_buffer_to_window_coords(_SELF(self), + RVAL2GENUM(wintype, GTK_TYPE_TEXT_WINDOW_TYPE), + NUM2INT(buffer_x), NUM2INT(buffer_y), + &window_x, &window_y); + return rb_ary_new3(2, INT2NUM(window_x), INT2NUM(window_y)); +} + +static VALUE +rg_window_to_buffer_coords(VALUE self, VALUE wintype, VALUE window_x, VALUE window_y) +{ + int buffer_x, buffer_y; + gtk_text_view_window_to_buffer_coords(_SELF(self), + RVAL2GENUM(wintype, GTK_TYPE_TEXT_WINDOW_TYPE), + NUM2INT(window_x), NUM2INT(window_y), + &buffer_x, &buffer_y); + return rb_ary_new3(2, INT2NUM(buffer_x), INT2NUM(buffer_y)); +} + +static VALUE +rg_get_window(VALUE self, VALUE wintype) +{ + GdkWindow* win = NULL; + win = gtk_text_view_get_window(_SELF(self), + RVAL2GENUM(wintype, GTK_TYPE_TEXT_WINDOW_TYPE)); + return win ? GOBJ2RVAL(win): Qnil; +} + +static VALUE +rg_get_window_type(VALUE self, VALUE gdkwin) +{ + return GENUM2RVAL(gtk_text_view_get_window_type(_SELF(self), RVAL2GOBJ(gdkwin)), + GTK_TYPE_TEXT_WINDOW_TYPE); +} + +static VALUE +rg_set_border_window_size(VALUE self, VALUE wintype, VALUE size) +{ + gtk_text_view_set_border_window_size(_SELF(self), + RVAL2GENUM(wintype, GTK_TYPE_TEXT_WINDOW_TYPE), + NUM2INT(size)); + return self; +} + +static VALUE +rg_get_border_window_size(VALUE self, VALUE wintype) +{ + return INT2NUM(gtk_text_view_get_border_window_size( + _SELF(self), + RVAL2GENUM(wintype, GTK_TYPE_TEXT_WINDOW_TYPE))); +} + +static VALUE +rg_forward_display_line(VALUE self, VALUE iter) +{ + return CBOOL2RVAL(gtk_text_view_forward_display_line(_SELF(self), RVAL2ITR(iter))); +} + +static VALUE +rg_backward_display_line(VALUE self, VALUE iter) +{ + return CBOOL2RVAL(gtk_text_view_backward_display_line(_SELF(self), RVAL2ITR(iter))); +} + +static VALUE +rg_forward_display_line_end(VALUE self, VALUE iter) +{ + return CBOOL2RVAL(gtk_text_view_forward_display_line_end(_SELF(self), RVAL2ITR(iter))); +} + +static VALUE +rg_backward_display_line_start(VALUE self, VALUE iter) +{ + return CBOOL2RVAL(gtk_text_view_backward_display_line_start(_SELF(self), RVAL2ITR(iter))); +} + +static VALUE +rg_starts_display_line(VALUE self, VALUE iter) +{ + return CBOOL2RVAL(gtk_text_view_starts_display_line(_SELF(self), RVAL2ITR(iter))); +} + +static VALUE +rg_move_visually(VALUE self, VALUE iter, VALUE count) +{ + return CBOOL2RVAL(gtk_text_view_move_visually(_SELF(self), RVAL2ITR(iter), NUM2INT(count))); +} + +static VALUE +rg_add_child_at_anchor(VALUE self, VALUE child, VALUE anchor) +{ + G_CHILD_ADD(self, child); + gtk_text_view_add_child_at_anchor(_SELF(self), GTK_WIDGET(RVAL2GOBJ(child)), + GTK_TEXT_CHILD_ANCHOR(RVAL2GOBJ(anchor))); + return self; +} + +static VALUE +rg_add_child_in_window(VALUE self, VALUE child, VALUE which_window, VALUE xpos, VALUE ypos) +{ + G_CHILD_ADD(self, child); + gtk_text_view_add_child_in_window(_SELF(self), GTK_WIDGET(RVAL2GOBJ(child)), + RVAL2GENUM(which_window, GTK_TYPE_TEXT_WINDOW_TYPE), + NUM2INT(xpos), NUM2INT(ypos)); + return self; +} + +static VALUE +rg_move_child(VALUE self, VALUE child, VALUE xpos, VALUE ypos) +{ + G_CHILD_ADD(self, child); + gtk_text_view_move_child(_SELF(self), GTK_WIDGET(RVAL2GOBJ(child)), + NUM2INT(xpos), NUM2INT(ypos)); + return self; +} + +static VALUE +rg_default_attributes(VALUE self) +{ + return BOXED2RVAL(gtk_text_view_get_default_attributes(_SELF(self)), + GTK_TYPE_TEXT_ATTRIBUTES); +} + +void +Init_gtk_textview(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TEXT_VIEW, "TextView", mGtk); + + id_buffer = rb_intern("buffer"); + + RG_DEF_METHOD(initialize, -1); + G_REPLACE_SET_PROPERTY(RG_TARGET_NAMESPACE, "buffer", textview_set_buffer, 1); + G_REPLACE_GET_PROPERTY(RG_TARGET_NAMESPACE, "buffer", textview_get_buffer, 0); + RG_DEF_METHOD(scroll_to_mark, 5); + RG_DEF_METHOD(scroll_to_iter, 5); + RG_DEF_METHOD(scroll_mark_onscreen, 1); + RG_DEF_METHOD(move_mark_onscreen, 1); + RG_DEF_METHOD(place_cursor_onscreen, 0); + RG_DEF_METHOD(visible_rect, 0); + RG_DEF_METHOD(get_iter_location, 1); + RG_DEF_METHOD(get_line_at_y, 1); + RG_DEF_METHOD(get_line_yrange, 1); + RG_DEF_METHOD(get_iter_at_location, 2); +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(get_iter_at_position, 2); +#endif + RG_DEF_METHOD(buffer_to_window_coords, 3); + RG_DEF_METHOD(window_to_buffer_coords, 3); + RG_DEF_METHOD(get_window, 1); + RG_DEF_METHOD(get_window_type, 1); + RG_DEF_METHOD(set_border_window_size, 2); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "border_window_size"); + RG_DEF_METHOD(get_border_window_size, 1); + RG_DEF_METHOD(forward_display_line, 1); + RG_DEF_METHOD(backward_display_line, 1); + RG_DEF_METHOD(forward_display_line_end, 1); + RG_DEF_METHOD(backward_display_line_start, 1); + RG_DEF_METHOD(starts_display_line, 1); + RG_DEF_METHOD(move_visually, 2); + RG_DEF_METHOD(add_child_at_anchor, 2); + RG_DEF_METHOD(add_child_in_window, 4); + RG_DEF_METHOD(move_child, 3); + RG_DEF_METHOD(default_attributes, 0); + + /* GtkTextWindowType */ + G_DEF_CLASS(GTK_TYPE_TEXT_WINDOW_TYPE, "WindowType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_TEXT_WINDOW_TYPE, "GTK_TEXT_"); + + rb_define_const(RG_TARGET_NAMESPACE, "PRIORITY_VALIDATE", INT2FIX(GTK_TEXT_VIEW_PRIORITY_VALIDATE)); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktoggleaction.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktoggleaction.c new file mode 100644 index 0000000..1ac14ee --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktoggleaction.c @@ -0,0 +1,66 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004,2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cToggleAction +#define _SELF(self) (GTK_TOGGLE_ACTION(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(VALUE self, VALUE name, VALUE label, VALUE tooltip, VALUE stock_id) +{ + const gchar *gstockid = NULL; + + if (TYPE(stock_id) == T_SYMBOL){ + gstockid = rb_id2name(SYM2ID(stock_id)); + } else if (TYPE(stock_id) == T_STRING){ + gstockid = RVAL2CSTR(stock_id); + } + + G_INITIALIZE(self, gtk_toggle_action_new(RVAL2CSTR(name), + RVAL2CSTR(label), + NIL_P(tooltip) ? NULL : RVAL2CSTR(tooltip), + gstockid)); + return Qnil; +} + +static VALUE +rg_toggled(VALUE self) +{ + gtk_toggle_action_toggled(_SELF(self)); + return self; +} + +#endif + +void +Init_gtk_toggle_action(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TOGGLE_ACTION, "ToggleAction", mGtk); + + RG_DEF_METHOD(initialize, 4); + RG_DEF_METHOD(toggled, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktogglebutton.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktogglebutton.c new file mode 100644 index 0000000..600b805 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktogglebutton.c @@ -0,0 +1,88 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cToggleButton + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE label, use_underline; + GtkWidget *widget; + + if (rb_scan_args(argc, argv, "02", &label, &use_underline) > 0) { + if (TYPE(label) == T_STRING){ + if (NIL_P(use_underline) || RVAL2CBOOL(use_underline)){ + widget = gtk_toggle_button_new_with_mnemonic(RVAL2CSTR(label)); + } else { + widget = gtk_toggle_button_new_with_label(RVAL2CSTR(label)); + } + } else if (TYPE(label) == T_SYMBOL){ + widget = gtk_toggle_button_new_with_label(rb_id2name(SYM2ID(label))); + gtk_button_set_use_stock(GTK_BUTTON(widget), TRUE); + } else { + rb_raise(rb_eArgError, "invalid argument %s (expect Symbol(Gtk::Stock constants) or String)", + rb_class2name(CLASS_OF(label))); + } + } else { + widget = gtk_toggle_button_new(); + } + + RBGTK_INITIALIZE(self, widget); + return Qnil; +} + +static VALUE +rg_set_mode(VALUE self, VALUE mode) +{ + gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(RVAL2GOBJ(self)), + RVAL2CBOOL(mode)); + return self; +} + +static VALUE +rg_mode_p(VALUE self) +{ + return CBOOL2RVAL(gtk_toggle_button_get_mode(GTK_TOGGLE_BUTTON(RVAL2GOBJ(self)))); +} + +static VALUE +rg_toggled(VALUE self) +{ + gtk_toggle_button_toggled(GTK_TOGGLE_BUTTON(RVAL2GOBJ(self))); + return self; +} + +void +Init_gtk_toggle_button(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TOGGLE_BUTTON, "ToggleButton", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(set_mode, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "mode"); + RG_DEF_METHOD_P(mode, 0); + RG_DEF_METHOD(toggled, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktoggletoolbutton.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktoggletoolbutton.c new file mode 100644 index 0000000..c38d23b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktoggletoolbutton.c @@ -0,0 +1,60 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cToggleToolButton +#define _SELF(self) (GTK_TOGGLE_TOOL_BUTTON(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE stock_id; + GtkToolItem* item; + + rb_scan_args(argc, argv, "01", &stock_id); + + if (NIL_P(stock_id)){ + item = gtk_toggle_tool_button_new(); + } else { + if (TYPE(stock_id) == T_SYMBOL){ + item = gtk_toggle_tool_button_new_from_stock(rb_id2name(SYM2ID(stock_id))); + } else { + item = gtk_toggle_tool_button_new_from_stock(RVAL2CSTR(stock_id)); + } + } + RBGTK_INITIALIZE(self, item); + return Qnil; +} + +#endif + +void +Init_gtk_toggletoolbutton(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TOGGLE_TOOL_BUTTON, "ToggleToolButton", mGtk); + + RG_DEF_METHOD(initialize, -1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktoolbar.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktoolbar.c new file mode 100644 index 0000000..434d8ef --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktoolbar.c @@ -0,0 +1,321 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cToolbar +#define _SELF(self) (GTK_TOOLBAR(RVAL2GOBJ(self))) +#define N_RVAL2CSTR(text) (NIL_P(text) ? NULL : RVAL2CSTR(text)) +#define N_RVAL2WIDGET(w) (NIL_P(w) ? NULL : GTK_WIDGET(RVAL2GOBJ(w))) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_toolbar_new()); + return Qnil; +} + +static VALUE +rg_append(int argc, VALUE *argv, VALUE self) +{ + GtkWidget* ret = NULL; + VALUE type = Qnil; + VALUE widget, stock_id, element_type, text, ttext, ptext, icon, func; + + if (argc > 0) type = argv[0]; + + if (NIL_P(type) || TYPE(type) == T_STRING){ + rb_scan_args(argc, argv, "05", &text, &ttext, &ptext, &icon, &func); + if (NIL_P(func)) func = rb_block_proc(); + G_RELATIVE(self, func); + + ret = gtk_toolbar_append_item(_SELF(self), N_RVAL2CSTR(text), + N_RVAL2CSTR(ttext), N_RVAL2CSTR(ptext), + N_RVAL2WIDGET(icon), + GTK_SIGNAL_FUNC(exec_callback), + (gpointer)func); + } else if (TYPE(type) == T_FIXNUM) { + rb_scan_args(argc, argv, "07", &element_type, &widget, &text, &ttext, &ptext, &icon, &func); + if (NIL_P(func)) func = rb_block_proc(); + G_RELATIVE(self, func); + + ret = gtk_toolbar_append_element(_SELF(self), + RVAL2GENUM(element_type, GTK_TYPE_TOOLBAR_CHILD_TYPE), + N_RVAL2WIDGET(widget), N_RVAL2CSTR(text), + N_RVAL2CSTR(ttext), N_RVAL2CSTR(ptext), + N_RVAL2WIDGET(icon), + GTK_SIGNAL_FUNC(exec_callback), + (gpointer)func); + if (RVAL2GENUM(element_type, GTK_TYPE_TOOLBAR_CHILD_TYPE) == GTK_TOOLBAR_CHILD_SPACE) + ret = NULL; + } else if (TYPE(type) == T_SYMBOL) { + rb_scan_args(argc, argv, "13", &stock_id, &ttext, &ptext, &func); + if (NIL_P(func)) func = rb_block_proc(); + G_RELATIVE(self, func); + + ret = gtk_toolbar_insert_stock(_SELF(self), rb_id2name(SYM2ID(stock_id)), + N_RVAL2CSTR(ttext), N_RVAL2CSTR(ptext), + GTK_SIGNAL_FUNC(exec_callback), + (gpointer)func, -1); + } else { + rb_scan_args(argc, argv, "12", &widget, &ttext, &ptext); + gtk_toolbar_append_widget(_SELF(self), GTK_WIDGET(RVAL2GOBJ(widget)), + N_RVAL2CSTR(ttext), N_RVAL2CSTR(ptext)); + return widget; + } + + return ret ? GOBJ2RVAL(ret) : Qnil; +} + +static VALUE +rg_prepend(int argc, VALUE *argv, VALUE self) +{ + GtkWidget* ret = NULL; + VALUE type = Qnil; + VALUE widget, stock_id, element_type, text, ttext, ptext, icon, func; + + if (argc > 0) type = argv[0]; + + if (NIL_P(type) || TYPE(type) == T_STRING){ + rb_scan_args(argc, argv, "05", &text, &ttext, &ptext, &icon, &func); + if (NIL_P(func)) func = rb_block_proc(); + G_RELATIVE(self, func); + + ret = gtk_toolbar_prepend_item(_SELF(self), N_RVAL2CSTR(text), + N_RVAL2CSTR(ttext), N_RVAL2CSTR(ptext), + N_RVAL2WIDGET(icon), + GTK_SIGNAL_FUNC(exec_callback), + (gpointer)func); + } else if (TYPE(type) == T_FIXNUM) { + rb_scan_args(argc, argv, "07", &element_type, &widget, &text, &ttext, &ptext, &icon, &func); + if (NIL_P(func)) func = rb_block_proc(); + G_RELATIVE(self, func); + + ret = gtk_toolbar_prepend_element(_SELF(self), RVAL2GENUM(element_type, GTK_TYPE_TOOLBAR_CHILD_TYPE), + N_RVAL2WIDGET(widget), N_RVAL2CSTR(text), + N_RVAL2CSTR(ttext), N_RVAL2CSTR(ptext), + N_RVAL2WIDGET(icon), + GTK_SIGNAL_FUNC(exec_callback), + (gpointer)func); + if (RVAL2GENUM(element_type, GTK_TYPE_TOOLBAR_CHILD_TYPE) == GTK_TOOLBAR_CHILD_SPACE) + ret = NULL; + } else if (TYPE(type) == T_SYMBOL) { + rb_scan_args(argc, argv, "13", &stock_id, &ttext, &ptext, &func); + if (NIL_P(func)) func = rb_block_proc(); + G_RELATIVE(self, func); + + ret = gtk_toolbar_insert_stock(_SELF(self), rb_id2name(SYM2ID(stock_id)), + N_RVAL2CSTR(ttext), N_RVAL2CSTR(ptext), + GTK_SIGNAL_FUNC(exec_callback), + (gpointer)func, 0); + } else { + rb_scan_args(argc, argv, "12", &widget, &ttext, &ptext); + gtk_toolbar_prepend_widget(_SELF(self), GTK_WIDGET(RVAL2GOBJ(widget)), + N_RVAL2CSTR(ttext), N_RVAL2CSTR(ptext)); + return widget; + } + + return ret ? GOBJ2RVAL(ret) : Qnil; +} + +static VALUE +rg_insert(int argc, VALUE *argv, VALUE self) +{ + GtkWidget* ret = NULL; + VALUE type = Qnil; + VALUE pos, widget, stock_id, element_type, text, ttext, ptext, icon, func; + + if (argc > 1) type = argv[1]; + + if (NIL_P(type) || TYPE(type) == T_STRING){ + rb_scan_args(argc, argv, "15", &pos, &text, &ttext, &ptext, &icon, &func); + if (NIL_P(func)) func = rb_block_proc(); + G_RELATIVE(self, func); + ret = gtk_toolbar_insert_item(_SELF(self),N_RVAL2CSTR(text), + N_RVAL2CSTR(ttext), N_RVAL2CSTR(ptext), + N_RVAL2WIDGET(icon), + GTK_SIGNAL_FUNC(exec_callback), + (gpointer)func, + NUM2INT(pos)); + } else if (TYPE(type) == T_FIXNUM) { + rb_scan_args(argc, argv, "17", &pos, &element_type, &widget, &text, &ttext, &ptext, &icon, &func); + if (NIL_P(func)) func = rb_block_proc(); + G_RELATIVE(self, func); + + ret = gtk_toolbar_insert_element(_SELF(self), + RVAL2GENUM(element_type, GTK_TYPE_TOOLBAR_CHILD_TYPE), + N_RVAL2WIDGET(widget), + N_RVAL2CSTR(text), N_RVAL2CSTR(ttext), + N_RVAL2CSTR(ptext), N_RVAL2WIDGET(icon), + GTK_SIGNAL_FUNC(exec_callback), + (gpointer)func, + NUM2INT(pos)); + if (RVAL2GENUM(element_type, GTK_TYPE_TOOLBAR_CHILD_TYPE) == GTK_TOOLBAR_CHILD_SPACE) + ret = NULL; + } else if (TYPE(type) == T_SYMBOL) { + rb_scan_args(argc, argv, "14", &pos, &stock_id, &ttext, &ptext, &func); + if (NIL_P(func)) func = rb_block_proc(); + G_RELATIVE(self, func); + + ret = gtk_toolbar_insert_stock(_SELF(self), rb_id2name(SYM2ID(stock_id)), + N_RVAL2CSTR(ttext), N_RVAL2CSTR(ptext), + GTK_SIGNAL_FUNC(exec_callback), + (gpointer)func, NUM2INT(pos)); +#if GTK_CHECK_VERSION(2,4,0) + } else if (rb_obj_is_kind_of(type, GTYPE2CLASS(GTK_TYPE_TOOL_ITEM))){ + rb_scan_args(argc, argv, "20", &pos, &widget); + gtk_toolbar_insert(_SELF(self), GTK_TOOL_ITEM(RVAL2GOBJ(widget)), + NUM2INT(pos)); + return widget; +#endif + } else { + rb_scan_args(argc, argv, "22", &pos, &widget, &ttext, &ptext); + gtk_toolbar_insert_widget(_SELF(self), GTK_WIDGET(RVAL2GOBJ(widget)), + N_RVAL2CSTR(ttext), N_RVAL2CSTR(ptext), + NUM2INT(pos)); + return widget; + } + + return ret ? GOBJ2RVAL(ret) : Qnil; +} + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_item_index(VALUE self, VALUE item) +{ + return INT2NUM(gtk_toolbar_get_item_index(_SELF(self), GTK_TOOL_ITEM(RVAL2GOBJ(item)))); +} + +static VALUE +rg_n_items(VALUE self) +{ + return INT2NUM(gtk_toolbar_get_n_items(_SELF(self))); +} + +static VALUE +rg_nth_item(VALUE self, VALUE n) +{ + return GOBJ2RVAL(gtk_toolbar_get_nth_item(_SELF(self), NUM2INT(n))); +} + +static VALUE +rg_drop_index(VALUE self, VALUE x, VALUE y) +{ + return INT2NUM(gtk_toolbar_get_drop_index(_SELF(self), NUM2INT(x), NUM2INT(y))); +} + +static VALUE +rg_set_drop_highlight_item(VALUE self, VALUE item, VALUE index) +{ + gtk_toolbar_set_drop_highlight_item(_SELF(self), + GTK_TOOL_ITEM(RVAL2GOBJ(item)), + NUM2INT(index)); + return self; +} + +static VALUE +rg_relief_style(VALUE self) +{ + return GENUM2RVAL(gtk_toolbar_get_relief_style(_SELF(self)), GTK_TYPE_RELIEF_STYLE); +} +#endif + +static VALUE +rg_append_space(VALUE self) +{ + gtk_toolbar_append_space(_SELF(self)); + return self; +} + +static VALUE +rg_prepend_space(VALUE self) +{ + gtk_toolbar_prepend_space(_SELF(self)); + return self; +} + +static VALUE +rg_insert_space(VALUE self, VALUE pos) +{ + gtk_toolbar_insert_space(_SELF(self), NUM2INT(pos)); + return self; +} + +static VALUE +rg_remove_space(VALUE self, VALUE position) +{ + gtk_toolbar_remove_space(_SELF(self), NUM2INT(position)); + return self; +} + +static VALUE +rg_unset_icon_size(VALUE self) +{ + gtk_toolbar_unset_icon_size(_SELF(self)); + return self; +} + +static VALUE +rg_unset_style(VALUE self) +{ + gtk_toolbar_unset_style(_SELF(self)); + return self; +} + +void +Init_gtk_toolbar(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TOOLBAR, "Toolbar", mGtk); + + RG_DEF_METHOD(initialize, 0); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(item_index, 1); + RG_DEF_METHOD(n_items, 0); + RG_DEF_METHOD(nth_item, 1); + RG_DEF_METHOD(drop_index, 2); + RG_DEF_METHOD(set_drop_highlight_item, 2); + RG_DEF_METHOD(relief_style, 0); +#endif + RG_DEF_METHOD(append, -1); + RG_DEF_METHOD(prepend, -1); + RG_DEF_METHOD(insert, -1); + RG_DEF_METHOD(append_space, 0); + RG_DEF_METHOD(prepend_space, 0); + RG_DEF_METHOD(insert_space, 1); + RG_DEF_METHOD(remove_space, 1); + RG_DEF_METHOD(unset_icon_size, 0); + RG_DEF_METHOD(unset_style, 0); + + /* GtkToolbarChildType */ + G_DEF_CLASS(GTK_TYPE_TOOLBAR_CHILD_TYPE, "ChildType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_TOOLBAR_CHILD_TYPE, "GTK_TOOLBAR_"); + + /* GtkToolbarSpaceStyle */ + G_DEF_CLASS(GTK_TYPE_TOOLBAR_SPACE_STYLE, "SpaceStyle", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_TOOLBAR_SPACE_STYLE, "GTK_TOOLBAR_"); + + /* GtkToolbarStyle(from Standard Constants) */ + G_DEF_CLASS(GTK_TYPE_TOOLBAR_STYLE, "Style", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_TOOLBAR_STYLE, "GTK_TOOLBAR_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktoolbutton.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktoolbutton.c new file mode 100644 index 0000000..b35899a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktoolbutton.c @@ -0,0 +1,59 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cToolButton +#define _SELF(self) (GTK_TOOL_BUTTON(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE obj, label; + GtkToolItem* item; + + rb_scan_args(argc, argv, "02", &obj, &label); + + if (TYPE(obj) == T_SYMBOL){ + item = gtk_tool_button_new_from_stock(rb_id2name(SYM2ID(obj))); + } else if (TYPE(obj) == T_STRING){ + item = gtk_tool_button_new_from_stock(RVAL2CSTR(obj)); + } else { + item = gtk_tool_button_new(GTK_WIDGET(RVAL2GOBJ(obj)), + NIL_P(label) ? NULL : RVAL2CSTR(label)); + } + RBGTK_INITIALIZE(self, item); + return Qnil; +} + +#endif + +void +Init_gtk_toolbutton(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TOOL_BUTTON, "ToolButton", mGtk); + + RG_DEF_METHOD(initialize, -1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktoolitem.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktoolitem.c new file mode 100644 index 0000000..fae38d7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktoolitem.c @@ -0,0 +1,166 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004,2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cToolItem +#define _SELF(self) (GTK_TOOL_ITEM(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_tool_item_new()); + return Qnil; +} + +static VALUE +rg_set_homogeneous(VALUE self, VALUE homogeneous) +{ + gtk_tool_item_set_homogeneous(_SELF(self), RVAL2CBOOL(homogeneous)); + return self; +} +static VALUE +rg_homogeneous_p(VALUE self) +{ + return CBOOL2RVAL(gtk_tool_item_get_homogeneous(_SELF(self))); +} + +static VALUE +rg_set_expand(VALUE self, VALUE expand) +{ + gtk_tool_item_set_expand(_SELF(self), RVAL2CBOOL(expand)); + return self; +} +static VALUE +rg_expand_p(VALUE self) +{ + return CBOOL2RVAL(gtk_tool_item_get_expand(_SELF(self))); +} + +static VALUE +rg_set_tooltip(int argc, VALUE *argv, VALUE self) +{ + VALUE tooltip, tip_text, tip_private; + + rb_scan_args(argc, argv, "21", &tooltip, &tip_text, &tip_private); + + gtk_tool_item_set_tooltip(_SELF(self), GTK_TOOLTIPS(RVAL2GOBJ(tooltip)), + RVAL2CSTR(tip_text), + NIL_P(tip_private) ? NULL : RVAL2CSTR(tip_private)); + return self; +} + +static VALUE +rg_set_use_drag_window(VALUE self, VALUE use_drag_window) +{ + gtk_tool_item_set_use_drag_window(_SELF(self), RVAL2CBOOL(use_drag_window)); + return self; +} +static VALUE +rg_use_drag_window_p(VALUE self) +{ + return CBOOL2RVAL(gtk_tool_item_get_use_drag_window(_SELF(self))); +} + +static VALUE +rg_icon_size(VALUE self) +{ + return GENUM2RVAL(gtk_tool_item_get_icon_size(_SELF(self)), GTK_TYPE_ICON_SIZE); +} + +static VALUE +rg_orientation(VALUE self) +{ + return GENUM2RVAL(gtk_tool_item_get_orientation(_SELF(self)), GTK_TYPE_ORIENTATION); +} + +static VALUE +rg_toolbar_style(VALUE self) +{ + return GENUM2RVAL(gtk_tool_item_get_toolbar_style(_SELF(self)), GTK_TYPE_TOOLBAR_STYLE); +} + +static VALUE +rg_relief_style(VALUE self) +{ + return GENUM2RVAL(gtk_tool_item_get_relief_style(_SELF(self)), GTK_TYPE_RELIEF_STYLE); +} + +static VALUE +rg_retrieve_proxy_menu_item(VALUE self) +{ + return GOBJ2RVAL(gtk_tool_item_retrieve_proxy_menu_item(_SELF(self))); +} + +static VALUE +rg_get_proxy_menu_item(VALUE self, VALUE menu_item_id) +{ + return GOBJ2RVAL(gtk_tool_item_get_proxy_menu_item(_SELF(self), RVAL2CSTR(menu_item_id))); +} + +static VALUE +rg_set_proxy_menu_item(VALUE self, VALUE menu_item_id, VALUE menu_item) +{ + gtk_tool_item_set_proxy_menu_item(_SELF(self), RVAL2CSTR(menu_item_id), + GTK_WIDGET(RVAL2GOBJ(menu_item))); + return self; +} + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_rebuild_menu(VALUE self) +{ + gtk_tool_item_rebuild_menu(_SELF(self)); + return self; +} +#endif +#endif + +void +Init_gtk_toolitem(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TOOL_ITEM, "ToolItem", mGtk); + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(set_homogeneous, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "homogenous"); + RG_DEF_METHOD_P(homogeneous, 0); + RG_DEF_METHOD(set_expand, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "expand"); + RG_DEF_METHOD_P(expand, 0); + RG_DEF_METHOD(set_tooltip, -1); + RG_DEF_METHOD(set_use_drag_window, 1); + G_DEF_SETTER(RG_TARGET_NAMESPACE, "use_drag_window"); + RG_DEF_METHOD_P(use_drag_window, 0); + RG_DEF_METHOD(icon_size, 0); + RG_DEF_METHOD(orientation, 0); + RG_DEF_METHOD(toolbar_style, 0); + RG_DEF_METHOD(relief_style, 0); + RG_DEF_METHOD(retrieve_proxy_menu_item, 0); + RG_DEF_METHOD(get_proxy_menu_item, 1); + RG_DEF_METHOD(set_proxy_menu_item, 2); +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(rebuild_menu, 0); +#endif +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktooltip.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktooltip.c new file mode 100644 index 0000000..ccbfe4e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktooltip.c @@ -0,0 +1,82 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,12,0) + +#define RG_TARGET_NAMESPACE cTooltip +/* GTK_TOOLTIP type-cast is private because it should be useless */ +#define _SELF(self) (RVAL2GOBJ(self)) + +static VALUE +rg_set_markup(VALUE self, VALUE markup) +{ + gtk_tooltip_set_markup(_SELF(self), RVAL2CSTR(markup)); + return self; +} + +static VALUE +rg_set_text(VALUE self, VALUE text) +{ + gtk_tooltip_set_text(_SELF(self), RVAL2CSTR(text)); + return self; +} + +static VALUE +rg_set_icon(VALUE self, VALUE icon) +{ + gtk_tooltip_set_icon(_SELF(self), GDK_PIXBUF(RVAL2GOBJ(icon))); + return self; +} + +static VALUE +rg_set_icon_from_stock(VALUE self, VALUE stock_id, VALUE size) +{ + gtk_tooltip_set_icon_from_stock(_SELF(self), rb_id2name(SYM2ID(stock_id)), RVAL2GENUM(size, GTK_TYPE_ICON_SIZE)); + return self; +} + +static VALUE +rg_set_custom(VALUE self, VALUE custom_widget) +{ + gtk_tooltip_set_custom(_SELF(self), GTK_WIDGET(RVAL2GOBJ(custom_widget))); + return self; +} + +#endif + +void +Init_gtk_tooltip(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,12,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TOOLTIP, "Tooltip", mGtk); + RG_DEF_METHOD(set_markup, 1); + RG_DEF_METHOD(set_text, 1); + RG_DEF_METHOD(set_icon, 1); + RG_DEF_METHOD(set_icon_from_stock, 2); + RG_DEF_METHOD(set_custom, 1); + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktooltips.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktooltips.c new file mode 100644 index 0000000..b6b35e3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktooltips.c @@ -0,0 +1,108 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Masao Mutoh + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTooltips +#define _SELF(self) (GTK_TOOLTIPS(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_tooltips_new()); + return Qnil; +} + +static VALUE +rg_enable(VALUE self) +{ + gtk_tooltips_enable(_SELF(self)); + return self; +} + +static VALUE +rg_disable(VALUE self) +{ + gtk_tooltips_disable(_SELF(self)); + return self; +} + +static VALUE +rg_set_tip(VALUE self, VALUE win, VALUE text, VALUE priv) +{ + gtk_tooltips_set_tip(_SELF(self), + GTK_WIDGET(RVAL2GOBJ(win)), + NIL_P(text)?NULL:RVAL2CSTR(text), + NIL_P(priv)?NULL:RVAL2CSTR(priv)); + + return self; +} + +static VALUE +rg_s_get_data(G_GNUC_UNUSED VALUE self, VALUE widget) +{ + GtkTooltipsData* data = gtk_tooltips_data_get(GTK_WIDGET(RVAL2GOBJ(widget))); + + return rb_ary_new3(3, GOBJ2RVAL(data->widget), CSTR2RVAL(data->tip_text), + CSTR2RVAL(data->tip_private)); +} + +static VALUE +rg_force_window(VALUE self) +{ + gtk_tooltips_force_window(_SELF(self)); + return self; +} + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_s_get_info(G_GNUC_UNUSED VALUE self, VALUE window) +{ + GtkTooltips* tooltips; + GtkWidget* current_widget; + gboolean ret = gtk_tooltips_get_info_from_tip_window(GTK_WINDOW(RVAL2GOBJ(window)), + &tooltips, + ¤t_widget); + if (ret) + return rb_assoc_new(GOBJ2RVAL(tooltips), GOBJ2RVAL(current_widget)); + else + return Qnil; +} +#endif + +void +Init_gtk_tooltips(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TOOLTIPS, "Tooltips", mGtk); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(set_tip, 3); + RG_DEF_METHOD(enable, 0); + RG_DEF_METHOD(disable, 0); + RG_DEF_METHOD(force_window, 0); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_SMETHOD(get_info, 1); +#endif + RG_DEF_SMETHOD(get_data, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreedragdest.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreedragdest.c new file mode 100644 index 0000000..c1bab8e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreedragdest.c @@ -0,0 +1,28 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +void +Init_gtk_treedragdest(VALUE mGtk) +{ + G_DEF_INTERFACE(GTK_TYPE_TREE_DRAG_DEST, "TreeDragDest", mGtk); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreedragsource.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreedragsource.c new file mode 100644 index 0000000..3ff984f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreedragsource.c @@ -0,0 +1,28 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +void +Init_gtk_treedragsource(VALUE mGtk) +{ + G_DEF_INTERFACE(GTK_TYPE_TREE_DRAG_SOURCE, "TreeDragSource", mGtk); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreeiter.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreeiter.c new file mode 100644 index 0000000..7200328 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreeiter.c @@ -0,0 +1,255 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTreeIter +#define _SELF(i) ((GtkTreeIter*)RVAL2BOXED(i, GTK_TYPE_TREE_ITER)) + +void +rbgtk_register_treeiter_set_value_func(GType gtype, rbgtkiter_set_value_func func) +{ + rb_hash_aset(treeiter_set_value_table, INT2NUM(gtype), + Data_Wrap_Struct(rb_cData, NULL, NULL, func)); +} + +static VALUE +rg_first_bang(VALUE self) +{ + GtkTreeIter* iter = _SELF(self); + GtkTreeModel* model = (GtkTreeModel*)iter->user_data3; + VALUE ret = CBOOL2RVAL(gtk_tree_model_get_iter_first(model, iter)); + iter->user_data3 = model; + return ret; +} + +static VALUE +rg_next_bang(VALUE self) +{ + GtkTreeIter* iter = _SELF(self); + GtkTreeModel* model = (GtkTreeModel*)iter->user_data3; + gboolean ret = gtk_tree_model_iter_next(model, iter); + if (! ret){ + gtk_tree_model_get_iter_first(model, iter); + } + iter->user_data3 = model; + + return CBOOL2RVAL(ret); +} + +static VALUE +rg_get_value(VALUE self, VALUE column) +{ + GValue value = G_VALUE_INIT; + GtkTreeIter* iter = _SELF(self); + GtkTreeModel* model = (GtkTreeModel*)iter->user_data3; + VALUE ret = Qnil; + + gtk_tree_model_get_value(model, iter, NUM2INT(column), &value); + if (G_VALUE_TYPE(&value) != G_TYPE_INVALID){ + ret = GVAL2RVAL(&value); + g_value_unset(&value); + } + return ret; +} + +static VALUE +rg_first_child(VALUE self) +{ + GtkTreeIter child; + GtkTreeIter* iter = _SELF(self); + GtkTreeModel* model = (GtkTreeModel*)iter->user_data3; + gboolean ret = gtk_tree_model_iter_children(model, &child, iter); + child.user_data3 = model; + return ret ? GTKTREEITER2RVAL(&child) : Qnil; +} + +static VALUE +rg_path(VALUE self) +{ + VALUE retval = Qnil; + GtkTreeIter* iter = _SELF(self); + GtkTreeModel* model = (GtkTreeModel*)iter->user_data3; + GtkTreePath* path = gtk_tree_model_get_path(model, iter); + retval= GTKTREEPATH2RVAL(path); + gtk_tree_path_free(path); + return retval; +} + +static VALUE +rg_has_child_p(VALUE self) +{ + GtkTreeIter* iter = _SELF(self); + GtkTreeModel* model = (GtkTreeModel*)iter->user_data3; + return CBOOL2RVAL(gtk_tree_model_iter_has_child(model, iter)); +} + +static VALUE +rg_n_children(VALUE self) +{ + GtkTreeIter* iter = _SELF(self); + GtkTreeModel* model = (GtkTreeModel*)iter->user_data3; + return INT2NUM(gtk_tree_model_iter_n_children(model, iter)); +} + +static VALUE +rg_nth_child(VALUE self, VALUE n) +{ + GtkTreeIter child; + GtkTreeIter* iter = _SELF(self); + GtkTreeModel* model = (GtkTreeModel*)iter->user_data3; + gboolean ret = gtk_tree_model_iter_nth_child(model, &child, iter, NUM2INT(n)); + child.user_data3 = model; + return ret ? GTKTREEITER2RVAL(&child) : Qnil; +} + +static VALUE +rg_parent(VALUE self) +{ + GtkTreeIter parent; + GtkTreeIter* iter = _SELF(self); + GtkTreeModel* model = (GtkTreeModel*)iter->user_data3; + gboolean ret = gtk_tree_model_iter_parent(model, &parent, iter); + parent.user_data3 = model; + return ret ? GTKTREEITER2RVAL(&parent) : Qnil; +} + +static VALUE +rg_set_value(VALUE self, VALUE column, VALUE value) +{ + GtkTreeIter* iter = _SELF(self); + GtkTreeModel* model = (GtkTreeModel*)iter->user_data3; + + VALUE obj = rb_hash_aref(treeiter_set_value_table, INT2NUM(G_TYPE_FROM_INSTANCE(model))); + rbgtkiter_set_value_func func; + GType gtype = gtk_tree_model_get_column_type(model, NUM2INT(column)); + GValue gval = G_VALUE_INIT; + + if (NIL_P(obj)) + rb_raise(rb_eTypeError, "Gtk::TreeModel is invalid."); + + Data_Get_Struct(obj, void, func); + + g_value_init(&gval, gtype); + rbgobj_rvalue_to_gvalue(value, &gval); + func(model, iter, NUM2INT(column), &gval); + g_value_unset(&gval); + + return self; +} + +static VALUE +rg_operator_treeiter_set_value_eql(VALUE self, VALUE column, VALUE value) +{ + rg_set_value(self, column, value); + return value; +} + +static VALUE +rg_operator_treeiter_eql(VALUE self, VALUE other) +{ + gint i, num1, num2; + GtkTreeIter* iter1 = _SELF(self); + GtkTreeIter* iter2; + GtkTreeModel* model1; + GtkTreeModel* model2; + GtkTreePath* path1; + GtkTreePath* path2; + + if (!rb_obj_is_kind_of(other, GTYPE2CLASS(GTK_TYPE_TREE_ITER))) + return Qfalse; + + iter2 = _SELF(other); + + model1 = (GtkTreeModel*)iter1->user_data3; + model2 = (GtkTreeModel*)iter2->user_data3; + if (model1 != model2) return Qfalse; + + num1 = gtk_tree_model_get_n_columns(model1); + num2 = gtk_tree_model_get_n_columns(model2); + if (num1 != num2) return Qfalse; + + path1 = gtk_tree_model_get_path(model1, iter1); + path2 = gtk_tree_model_get_path(model2, iter2); + if (gtk_tree_path_compare(path1, path2) != 0) { + gtk_tree_path_free(path1); + gtk_tree_path_free(path2); + return Qfalse; + } else { + gtk_tree_path_free(path1); + gtk_tree_path_free(path2); + } + + for (i = 0; i < num1; i++){ + GValue gval1 = G_VALUE_INIT; + GValue gval2 = G_VALUE_INIT; + VALUE ret1, ret2; + gtk_tree_model_get_value(model1, iter1, i, &gval1); + gtk_tree_model_get_value(model2, iter2, i, &gval2); + + ret1 = GVAL2RVAL(&gval1); + ret2 = GVAL2RVAL(&gval2); + g_value_unset(&gval1); + g_value_unset(&gval2); + if (rb_equal(ret1, ret2) == Qfalse) + return Qfalse; + } + return Qtrue; +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_to_str(VALUE self) +{ + GtkTreeIter* iter = _SELF(self); + GtkTreeModel* model = (GtkTreeModel*)iter->user_data3; + + gchar* s = gtk_tree_model_get_string_from_iter (model, iter); + VALUE result = CSTR2RVAL(s); + g_free(s); + return result; +} +#endif + +void +Init_gtk_treeiter(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TREE_ITER, "TreeIter", mGtk); + + RG_DEF_METHOD_BANG(first, 0); + RG_DEF_METHOD_BANG(next, 0); + RG_DEF_METHOD(get_value, 1); + RG_DEF_ALIAS("[]", "get_value"); + RG_DEF_METHOD(first_child, 0); + RG_DEF_METHOD(path, 0); + RG_DEF_METHOD_P(has_child, 0); + RG_DEF_METHOD(n_children, 0); + RG_DEF_METHOD(nth_child, 1); + RG_DEF_METHOD(parent, 0); + RG_DEF_METHOD(set_value, 2); + RG_DEF_METHOD_OPERATOR("[]=", treeiter_set_value_eql, 2); + RG_DEF_METHOD_OPERATOR("==", treeiter_eql, 1); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(to_str, 0); + RG_DEF_ALIAS("to_s", "to_str"); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreemodel.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreemodel.c new file mode 100644 index 0000000..de14253 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreemodel.c @@ -0,0 +1,282 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE mTreeModel +#define _SELF(s) (GTK_TREE_MODEL(RVAL2GOBJ(s))) + +static VALUE +rg_flags(VALUE self) +{ + return GFLAGS2RVAL(gtk_tree_model_get_flags(_SELF(self)), GTK_TYPE_TREE_MODEL_FLAGS); +} + +static VALUE +rg_n_columns(VALUE self) +{ + return INT2NUM(gtk_tree_model_get_n_columns(_SELF(self))); +} + +static VALUE +rg_get_column_type(VALUE self, VALUE index) +{ + return GTYPE2CLASS(gtk_tree_model_get_column_type(_SELF(self), + NUM2INT(index))); +} + +static VALUE +rg_iter_first(VALUE self) +{ + VALUE val = Qnil; + GtkTreeIter iter; + GtkTreeModel* model = _SELF(self); + gboolean ret = (gtk_tree_model_get_iter_first(model, &iter)); + iter.user_data3 = model; + + if (ret) { + val = GTKTREEITER2RVAL(&iter); + } + + return val; +} + +static VALUE +rg_iter_root(VALUE self) +{ + VALUE val = Qnil; + GtkTreeIter iter; + GtkTreeModel* model = _SELF(self); + gboolean ret = (gtk_tree_model_get_iter_root(model, &iter)); + iter.user_data3 = model; + + if (ret) { + val = GTKTREEITER2RVAL(&iter); + } + + return val; +} + +static VALUE +rg_iter_next(VALUE self, VALUE iter) +{ + VALUE val = Qnil; + gboolean ret = (gtk_tree_model_iter_next(_SELF(self), RVAL2GTKTREEITER(iter))); + + if (ret) { + val = GTKTREEITER2RVAL(&iter); + } + + return val; +} + +static VALUE +rg_get_iter(VALUE self, VALUE path) +{ + VALUE val = Qnil; + GtkTreeIter iter; + gboolean ret; + GtkTreeModel* model = _SELF(self); + + if (TYPE(path) == T_STRING){ + ret = gtk_tree_model_get_iter_from_string(model, &iter, + RVAL2CSTR(path)); + } else { + ret = gtk_tree_model_get_iter(model, &iter, + RVAL2GTKTREEPATH(path)); + } + iter.user_data3 = model; + + if (ret) { + val = GTKTREEITER2RVAL(&iter); + } + + return val; +} + +static VALUE +rg_get_value(VALUE self, VALUE iter, VALUE column) +{ + GValue value = G_VALUE_INIT; + VALUE ret = Qnil; + gtk_tree_model_get_value(_SELF(self), RVAL2GTKTREEITER(iter), NUM2INT(column), &value); + if (G_VALUE_TYPE(&value) != G_TYPE_INVALID){ + ret = GVAL2RVAL(&value); + g_value_unset(&value); + } + return ret; +} + +/* These methods may be neededless. +void gtk_tree_model_ref_node (GtkTreeModel *tree_model, + GtkTreeIter *iter); +void gtk_tree_model_unref_node (GtkTreeModel *tree_model, + GtkTreeIter *iter); +*/ + +/* XXXX +void gtk_tree_model_get_valist (GtkTreeModel *tree_model, + GtkTreeIter *iter, + va_list var_args); +*/ + +static gboolean +treemodel_foreach_func(GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + G_GNUC_UNUSED gpointer func) +{ + iter->user_data3 = model; + rb_yield(rb_ary_new3(3, GOBJ2RVAL(model), GTKTREEPATH2RVAL(path), GTKTREEITER2RVAL(iter))); + return FALSE; +} + +static VALUE +rg_each(VALUE self) +{ + gtk_tree_model_foreach(_SELF(self), + (GtkTreeModelForeachFunc)treemodel_foreach_func, + (gpointer)NULL); + return self; +} + +static VALUE +rg_row_changed(VALUE self, VALUE path, VALUE iter) +{ + gtk_tree_model_row_changed(_SELF(self), RVAL2GTKTREEPATH(path), RVAL2GTKTREEITER(iter)); + return self; +} + +static VALUE +rg_row_inserted(VALUE self, VALUE path, VALUE iter) +{ + gtk_tree_model_row_inserted(_SELF(self), RVAL2GTKTREEPATH(path), RVAL2GTKTREEITER(iter)); + return self; +} + +static VALUE +rg_row_has_child_toggled(VALUE self, VALUE path, VALUE iter) +{ + gtk_tree_model_row_has_child_toggled(_SELF(self), RVAL2GTKTREEPATH(path), RVAL2GTKTREEITER(iter)); + return self; +} + +static VALUE +rg_row_deleted(VALUE self, VALUE path) +{ + gtk_tree_model_row_deleted(_SELF(self), RVAL2GTKTREEPATH(path)); + return self; +} + +static VALUE +rg_rows_reordered(VALUE self, VALUE rbpath, VALUE rbiter, VALUE rbnew_order) +{ + GtkTreeModel *proxy = _SELF(self); + GtkTreePath *path = RVAL2GTKTREEPATH(rbpath); + GtkTreeIter *iter = RVAL2GTKTREEITER(rbiter); + gint columns = gtk_tree_model_get_n_columns(proxy); + long n; + gint *new_order = RVAL2GINTS(rbnew_order, n); + + if (n != columns) { + g_free(new_order); + + rb_raise(rb_eArgError, + "new order array must contain same number of elements as the number of columns in the store: %ld != %d", + n, columns); + } + + gtk_tree_model_rows_reordered(proxy, path, iter, new_order); + + g_free(new_order); + + return self; +} + +static VALUE +rg_iter_is_valid_p(G_GNUC_UNUSED VALUE self, G_GNUC_UNUSED VALUE iter) +{ + return Qtrue; +} + +static VALUE +signal_func(G_GNUC_UNUSED guint num, const GValue *values) +{ + GtkTreeModel* model = g_value_get_object(&values[0]); + GtkTreePath* path = g_value_get_boxed(&values[1]); + GtkTreeIter* iter = g_value_get_boxed(&values[2]); + iter->user_data3 = model; + + return rb_ary_new3(3, GOBJ2RVAL(model), GTKTREEPATH2RVAL(path), GTKTREEITER2RVAL(iter)); +} + +static VALUE +signal_rows_reordered_func(G_GNUC_UNUSED guint num, const GValue *values) +{ + GtkTreeModel* model = g_value_get_object(&values[0]); + GtkTreePath* path = g_value_get_boxed(&values[1]); + GtkTreeIter* iter = g_value_get_boxed(&values[2]); + gint* new_orders = (gint*)g_value_get_pointer(&values[3]); + gint len = gtk_tree_model_iter_n_children(model, iter); + VALUE orders = Qnil; + int i; + + iter->user_data3 = model; + + orders = rb_ary_new2(len); + for (i = 0; i < len; i++, new_orders++) { + rb_ary_push(orders, INT2NUM(*new_orders)); + } + return rb_ary_new3(4, GOBJ2RVAL(model), GTKTREEPATH2RVAL(path), GTKTREEITER2RVAL(iter), orders); +} + +void +Init_gtk_treemodel(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(GTK_TYPE_TREE_MODEL, "TreeModel", mGtk); + + RG_DEF_METHOD(flags, 0); + RG_DEF_METHOD(n_columns, 0); + RG_DEF_METHOD(get_column_type, 1); + RG_DEF_METHOD(iter_first, 0); + RG_DEF_METHOD(iter_root, 0); + RG_DEF_METHOD(iter_next, 1); + RG_DEF_METHOD(get_iter, 1); + RG_DEF_METHOD(get_value, 2); + RG_DEF_METHOD(each, 0); + RG_DEF_METHOD(row_changed, 2); + RG_DEF_METHOD(row_inserted, 2); + RG_DEF_METHOD(row_has_child_toggled, 2); + RG_DEF_METHOD(row_deleted, 1); + RG_DEF_METHOD(rows_reordered, 3); + RG_DEF_METHOD_P(iter_is_valid, 1); + + /* GtkTreeModelFlags */ + G_DEF_CLASS(GTK_TYPE_TREE_MODEL_FLAGS, "Flags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_TREE_MODEL_FLAGS, "GTK_TREE_MODEL_"); + + G_DEF_SIGNAL_FUNC(RG_TARGET_NAMESPACE, "row_changed", (GValToRValSignalFunc)signal_func); + G_DEF_SIGNAL_FUNC(RG_TARGET_NAMESPACE, "row_inserted", (GValToRValSignalFunc)signal_func); + G_DEF_SIGNAL_FUNC(RG_TARGET_NAMESPACE, "row_has_child_toggled", (GValToRValSignalFunc)signal_func); + G_DEF_SIGNAL_FUNC(RG_TARGET_NAMESPACE, "rows_reordered", (GValToRValSignalFunc)signal_rows_reordered_func); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreemodelfilter.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreemodelfilter.c new file mode 100644 index 0000000..ebb1266 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreemodelfilter.c @@ -0,0 +1,203 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004,2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cTreeModelFilter +#define _SELF(s) (GTK_TREE_MODEL_FILTER(RVAL2GOBJ(s))) + +static ID id_child_model; +static ID id_root; + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE child_model, root; + GtkTreeModel* widget; + + rb_scan_args(argc, argv, "11", &child_model, &root); + + G_CHILD_SET(self, id_child_model, child_model); + if (NIL_P(root)){ + widget = gtk_tree_model_filter_new(GTK_TREE_MODEL(RVAL2GOBJ(child_model)), + (GtkTreePath*)NULL); + } else { + G_CHILD_SET(self, id_root, root); + widget = gtk_tree_model_filter_new(GTK_TREE_MODEL(RVAL2GOBJ(child_model)), + (GtkTreePath*)RVAL2GTKTREEPATH(root)); + } + + G_INITIALIZE(self, widget); + return Qnil; +} + +static gboolean +visible_func(GtkTreeModel *model, GtkTreeIter *iter, gpointer func) +{ + VALUE ret; + + iter->user_data3 = model; + ret = rb_funcall((VALUE)func, id_call, 2, GOBJ2RVAL(model), GTKTREEITER2RVAL(iter)); + return RVAL2CBOOL(ret); +} + +static VALUE +rg_set_visible_func(VALUE self) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_tree_model_filter_set_visible_func(_SELF(self), + (GtkTreeModelFilterVisibleFunc)visible_func, + (gpointer)func, NULL); + return self; +} + +static void +modify_func(GtkTreeModel *model, GtkTreeIter *iter, GValue *value, gint column, gpointer func) +{ + VALUE ret; + iter->user_data3 = model; + ret = rb_funcall((VALUE)func, id_call, 3, GOBJ2RVAL(model), GTKTREEITER2RVAL(iter), + INT2NUM(column)); + rbgobj_rvalue_to_gvalue(ret, value); +} + +/* + * Should return value + * + * e.g. + * filter.set_modify_func(String) do |model, iter, column| + * "foo" + * end + */ +static VALUE +rg_set_modify_func(int argc, VALUE *argv, VALUE self) +{ + VALUE func = rb_block_proc(); + gint i; + GType* types; + + if (argc == 0) rb_raise(rb_eArgError, "need more than 1 class type."); + + types = ALLOCA_N(GType, argc); + + G_RELATIVE(self, func); + + for (i = 0; i < argc; i++){ + types[i] = CLASS2GTYPE(argv[i]); + } + gtk_tree_model_filter_set_modify_func(_SELF(self), + argc, types, + (GtkTreeModelFilterModifyFunc)modify_func, + (gpointer)func, NULL); + return self; +} + +static VALUE +rg_set_visible_column(VALUE self, VALUE column) +{ + gtk_tree_model_filter_set_visible_column(_SELF(self), NUM2INT(column)); + return self; +} + +static VALUE +rg_model(VALUE self) +{ + return GOBJ2RVAL(gtk_tree_model_filter_get_model(_SELF(self))); +} + +static VALUE +rg_convert_child_iter_to_iter(VALUE self, VALUE child_iter) +{ + GtkTreeIter filter_iter; + GtkTreeModelFilter* modelfilter = _SELF(self); + gtk_tree_model_filter_convert_child_iter_to_iter(modelfilter, &filter_iter, + RVAL2GTKTREEITER(child_iter)); + filter_iter.user_data3 = gtk_tree_model_filter_get_model(modelfilter); + return GTKTREEITER2RVAL(&filter_iter); +} + +static VALUE +rg_convert_iter_to_child_iter(VALUE self, VALUE filtered_iter) +{ + GtkTreeIter child_iter; + GtkTreeModelFilter* modelfilter = _SELF(self); + gtk_tree_model_filter_convert_iter_to_child_iter(modelfilter, &child_iter, + RVAL2GTKTREEITER(filtered_iter)); + child_iter.user_data3 = gtk_tree_model_filter_get_model(modelfilter); + return GTKTREEITER2RVAL(&child_iter); +} + +static VALUE +rg_convert_child_path_to_path(VALUE self, VALUE child_path) +{ + return GTKTREEPATH2RVAL(gtk_tree_model_filter_convert_child_path_to_path( + _SELF(self), + RVAL2GTKTREEPATH(child_path))); +} +static VALUE +rg_convert_path_to_child_path(VALUE self, VALUE filter_path) +{ + return GTKTREEPATH2RVAL(gtk_tree_model_filter_convert_path_to_child_path( + _SELF(self), + RVAL2GTKTREEPATH(filter_path))); +} + +static VALUE +rg_refilter(VALUE self) +{ + gtk_tree_model_filter_refilter(_SELF(self)); + return self; +} + +static VALUE +rg_clear_cache(VALUE self) +{ + gtk_tree_model_filter_clear_cache(_SELF(self)); + return self; +} +#endif + +void +Init_gtk_treemodelfilter(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TREE_MODEL_FILTER, "TreeModelFilter", mGtk); + + id_child_model = rb_intern("child_model"); + id_root = rb_intern("root"); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(set_visible_func, 0); + RG_DEF_METHOD(set_modify_func, -1); + RG_DEF_METHOD(set_visible_column, 1); + RG_DEF_METHOD(model, 0); + RG_DEF_METHOD(convert_child_iter_to_iter, 1); + RG_DEF_METHOD(convert_iter_to_child_iter, 1); + RG_DEF_METHOD(convert_child_path_to_path, 1); + RG_DEF_METHOD(convert_path_to_child_path, 1); + RG_DEF_METHOD(refilter, 0); + RG_DEF_METHOD(clear_cache, 0); + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreemodelsort.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreemodelsort.c new file mode 100644 index 0000000..bd7141c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreemodelsort.c @@ -0,0 +1,116 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTreeModelSort +#define _SELF(s) (GTK_TREE_MODEL_SORT(RVAL2GOBJ(s))) + +static ID id_model; + +static VALUE +rg_initialize(VALUE self, VALUE model) +{ + G_CHILD_SET(self, id_model, model); + G_INITIALIZE(self, + gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(RVAL2GOBJ(model)))); + return Qnil; +} + +static VALUE +rg_convert_child_path_to_path(VALUE self, VALUE child_path) +{ + return GTKTREEPATH2RVAL(gtk_tree_model_sort_convert_child_path_to_path( + _SELF(self), + RVAL2GTKTREEPATH(child_path))); +} + +static VALUE +rg_convert_child_iter_to_iter(VALUE self, VALUE child_iter) +{ + GtkTreeIter sort_iter; + GtkTreeModelSort* modelsort = _SELF(self); + gtk_tree_model_sort_convert_child_iter_to_iter(modelsort, &sort_iter, + RVAL2GTKTREEITER(child_iter)); + sort_iter.user_data3 = gtk_tree_model_sort_get_model(modelsort); + return GTKTREEITER2RVAL(&sort_iter); +} + +static VALUE +rg_convert_path_to_child_path(VALUE self, VALUE sorted_path) +{ + return GTKTREEPATH2RVAL(gtk_tree_model_sort_convert_path_to_child_path( + _SELF(self), + RVAL2GTKTREEPATH(sorted_path))); +} + +static VALUE +rg_convert_iter_to_child_iter(VALUE self, VALUE sorted_iter) +{ + GtkTreeIter child_iter; + GtkTreeModelSort* modelsort = _SELF(self); + gtk_tree_model_sort_convert_iter_to_child_iter(modelsort, &child_iter, + RVAL2GTKTREEITER(sorted_iter)); + child_iter.user_data3 = gtk_tree_model_sort_get_model(modelsort); + return GTKTREEITER2RVAL(&child_iter); +} + +static VALUE +rg_reset_default_sort_func(VALUE self) +{ + gtk_tree_model_sort_reset_default_sort_func(_SELF(self)); + return self; +} + +static VALUE +rg_clear_cache(VALUE self) +{ + gtk_tree_model_sort_clear_cache(_SELF(self)); + return self; +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_iter_is_valid_p(VALUE self, VALUE iter) +{ + return CBOOL2RVAL(gtk_tree_model_sort_iter_is_valid(_SELF(self), RVAL2GTKTREEITER(iter))); +} +#endif + +void +Init_gtk_tmodelsort(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TREE_MODEL_SORT, "TreeModelSort", mGtk); + + id_model = rb_intern("model"); + + RG_DEF_METHOD(initialize, 1); + RG_DEF_METHOD(convert_child_path_to_path, 1); + RG_DEF_METHOD(convert_child_iter_to_iter, 1); + RG_DEF_METHOD(convert_path_to_child_path, 1); + RG_DEF_METHOD(convert_iter_to_child_iter, 1); + RG_DEF_METHOD(reset_default_sort_func, 0); + RG_DEF_METHOD(clear_cache, 0); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD_P(iter_is_valid, 1); +#endif + +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreepath.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreepath.c new file mode 100644 index 0000000..55648f9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreepath.c @@ -0,0 +1,191 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Ruby-GNOME2 Project Team + * Copyright (C) 2003,2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTreePath +#define _SELF(s) ((GtkTreePath*)RVAL2BOXED(s, GTK_TYPE_TREE_PATH)) + +static ID id_equal; + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE path; + GtkTreePath* widget; + + if (argc == 1) { + path = argv[0]; + if (TYPE(path) == T_STRING){ + widget = gtk_tree_path_new_from_string(RVAL2CSTR(path)); + } else { + widget = gtk_tree_path_new(); + gtk_tree_path_append_index(widget, NUM2INT(path)); + } + if (widget == NULL) + rb_raise(rb_eArgError, "Invalid path %s was passed.", RVAL2CSTR(path)); + } else { + int i; + widget = gtk_tree_path_new(); + for (i = 0; i < argc; i++) + gtk_tree_path_append_index(widget, NUM2INT(argv[i])); + } + + G_INITIALIZE(self, widget); + return Qnil; +} + +static VALUE +rg_to_str(VALUE self) +{ + gchar* s = gtk_tree_path_to_string(_SELF(self)); + VALUE result = CSTR2RVAL(s); + g_free(s); + return result; +} + +/* Do we need this ? +GtkTreePath* gtk_tree_path_new_first (void); + +Deprecated +#define gtk_tree_path_new_root () +*/ + +static VALUE +rg_append_index(VALUE self, VALUE index) +{ + gtk_tree_path_append_index(_SELF(self), NUM2INT(index)); + return self; +} + +static VALUE +rg_prepend_index(VALUE self, VALUE index) +{ + gtk_tree_path_prepend_index(_SELF(self), NUM2INT(index)); + return self; +} + +static VALUE +rg_depth(VALUE self) +{ + return INT2NUM(gtk_tree_path_get_depth(_SELF(self))); +} + +static VALUE +rg_indices(VALUE self) +{ + VALUE ary; + gint i, length; + gint* indices; + + length = gtk_tree_path_get_depth(_SELF(self)); + indices = gtk_tree_path_get_indices(_SELF(self)); + + if (indices != NULL) { + ary = rb_ary_new2(length); + for (i = 0; i < length; i++) { + rb_ary_push(ary, INT2NUM(indices[i])); + } + + return ary; + } else { + return Qnil; + } +} + +static VALUE +rg_operator_treepath_compare(VALUE self, VALUE other) +{ + return INT2NUM(gtk_tree_path_compare(_SELF(self), _SELF(other))); +} + +static VALUE +rg_operator_treepath_equal(VALUE self, VALUE other) +{ + if (!RVAL2CBOOL(rb_funcall(CLASS_OF(self), id_equal, 1, CLASS_OF(other)))) { + return Qfalse; + } + + return CBOOL2RVAL(gtk_tree_path_compare(_SELF(self), _SELF(other)) == 0); +} + +static VALUE +rg_next_bang(VALUE self) +{ + gtk_tree_path_next(_SELF(self)); + return self; +} + +static VALUE +rg_prev_bang(VALUE self) +{ + return CBOOL2RVAL(gtk_tree_path_prev(_SELF(self))); +} + +static VALUE +rg_up_bang(VALUE self) +{ + return CBOOL2RVAL(gtk_tree_path_up(_SELF(self))); +} + +static VALUE +rg_down_bang(VALUE self) +{ + gtk_tree_path_down(_SELF(self)); + return Qtrue; +} + +static VALUE +rg_ancestor_p(VALUE self, VALUE descendant) +{ + return CBOOL2RVAL(gtk_tree_path_is_ancestor(_SELF(self), _SELF(descendant))); +} + +static VALUE +rg_descendant_p(VALUE self, VALUE ancestor) +{ + return CBOOL2RVAL(gtk_tree_path_is_descendant(_SELF(self), _SELF(ancestor))); +} + +void +Init_gtk_treepath(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TREE_PATH, "TreePath", mGtk); + + id_equal = rb_intern("=="); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(to_str, 0); + RG_DEF_ALIAS("to_s", "to_str"); + RG_DEF_METHOD(append_index, 1); + RG_DEF_METHOD(prepend_index, 1); + RG_DEF_METHOD(depth, 0); + RG_DEF_METHOD(indices, 0); + RG_DEF_METHOD_OPERATOR("<=>", treepath_compare, 1); + RG_DEF_METHOD_OPERATOR("==", treepath_equal, 1); + RG_DEF_METHOD_BANG(next, 0); + RG_DEF_METHOD_BANG(prev, 0); + RG_DEF_METHOD_BANG(up, 0); + RG_DEF_METHOD_BANG(down, 0); + RG_DEF_METHOD_P(ancestor, 1); + RG_DEF_METHOD_P(descendant, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreerowreference.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreerowreference.c new file mode 100644 index 0000000..355edcd --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreerowreference.c @@ -0,0 +1,175 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +/*****************************************/ + +#ifndef GTK_TYPE_TREE_ROW_REFERENCE +static GtkTreeRowReference* +treerowref_copy(const GtkTreeRowReference *ref) +{ + return (GtkTreeRowReference*)ref; +} + +GType +rbgtk_tree_row_reference_get_type() +{ + static GType our_type = 0; + if (our_type == 0) + our_type = g_boxed_type_register_static ("GtkTreeRowReference", + (GBoxedCopyFunc)treerowref_copy, + (GBoxedFreeFunc)gtk_tree_row_reference_free); + return our_type; +} + +GtkTreeRowReference * +rbgtk_get_tree_row_reference(VALUE obj) +{ + return (GtkTreeRowReference*)RVAL2BOXED(obj, GTK_TYPE_TREE_ROW_REFERENCE); +} +#endif + +/*****************************************/ + +#define RG_TARGET_NAMESPACE cTreeRowReference +#define _SELF(s) RVAL2TREEROWREFERENCE(s) + +/*****************************************/ + +static ID id_proxy; +static ID id_model; +static ID id_path; + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE proxy, model, path; + GtkTreeRowReference* ref; + + if (argc == 3){ + rb_scan_args(argc, argv, "3", &proxy, &model, &path); + G_CHILD_SET(self, id_proxy, proxy); + ref = gtk_tree_row_reference_new_proxy(RVAL2GOBJ(proxy), + GTK_TREE_MODEL(RVAL2GOBJ(model)), + RVAL2GTKTREEPATH(path)); + } else { + rb_scan_args(argc, argv, "2", &model, &path); + ref = gtk_tree_row_reference_new(GTK_TREE_MODEL(RVAL2GOBJ(model)), + RVAL2GTKTREEPATH(path)); + } + if (ref == NULL) + rb_raise(rb_eArgError, "Invalid arguments were passed."); + + G_CHILD_SET(self, id_model, model); + G_CHILD_SET(self, id_path, path); + + G_INITIALIZE(self, ref); + return Qnil; +} + +static VALUE +rg_path(VALUE self) +{ + VALUE ret = GTKTREEPATH2RVAL(gtk_tree_row_reference_get_path(_SELF(self))); + G_CHILD_SET(self, id_path, ret); + return ret; +} + +#if GTK_CHECK_VERSION(2,8,0) +static VALUE +rg_model(VALUE self) +{ + VALUE ret = GOBJ2RVAL(gtk_tree_row_reference_get_model(_SELF(self))); + G_CHILD_SET(self, id_model, ret); + return ret; +} +#endif + +static VALUE +rg_valid_p(VALUE self) +{ + return CBOOL2RVAL(gtk_tree_row_reference_valid(_SELF(self))); +} + +static VALUE +rg_s_inserted(VALUE self, VALUE proxy, VALUE path) +{ + gtk_tree_row_reference_inserted(RVAL2GOBJ(proxy), RVAL2GTKTREEPATH(path)); + return self; +} + +static VALUE +rg_s_deleted(VALUE self, VALUE proxy, VALUE path) +{ + gtk_tree_row_reference_deleted(RVAL2GOBJ(proxy), RVAL2GTKTREEPATH(path)); + return self; +} + +static VALUE +rg_s_reordered(VALUE self, VALUE rbproxy, VALUE rbpath, VALUE rbiter, VALUE rbnew_order) +{ + GObject *proxy = RVAL2GOBJ(rbproxy); + GtkTreePath *path = RVAL2GTKTREEPATH(rbpath); + GtkTreeIter *iter = RVAL2GTKTREEITER(rbiter); + /* TODO: How do we implement this check? + gint columns = gtk_tree_model_get_n_columns(proxy); + */ + long n; + gint *new_order = RVAL2GINTS(rbnew_order, n); + + /* + if (n != columns) { + g_free(new_order); + + rb_raise(rb_eArgError, + "new order array must contain same number of elements as the number of columns in the store: %ld != %d", + n, columns); + } + */ + + gtk_tree_row_reference_reordered(proxy, path, iter, new_order); + + g_free(new_order); + + return self; +} + +void +Init_gtk_treerowreference(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TREE_ROW_REFERENCE, "TreeRowReference", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(path, 0); +#if GTK_CHECK_VERSION(2,8,0) + RG_DEF_METHOD(model, 0); +#endif + RG_DEF_METHOD_P(valid, 0); + + RG_DEF_SMETHOD(inserted, 2); + RG_DEF_SMETHOD(deleted, 2); + RG_DEF_SMETHOD(reordered, 4); + + id_proxy = rb_intern("proxy"); + id_model = rb_intern("model"); + id_path = rb_intern("path"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreeselection.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreeselection.c new file mode 100644 index 0000000..ca42dbd --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreeselection.c @@ -0,0 +1,217 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTreeSelection +#define _SELF(s) (GTK_TREE_SELECTION(RVAL2GOBJ(s))) +#define RVAL2TREEMODEL(s) (GTK_TREE_MODEL(RVAL2GOBJ(s))) + +static VALUE +rg_set_mode(VALUE self, VALUE type) +{ + gtk_tree_selection_set_mode(_SELF(self), RVAL2GENUM(type, GTK_TYPE_SELECTION_MODE)); + return self; +} + +static VALUE +rg_mode(VALUE self) +{ + return GENUM2RVAL(gtk_tree_selection_get_mode(_SELF(self)), GTK_TYPE_SELECTION_MODE); +} + +static gboolean +selection_func(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, gpointer func) +{ + return RVAL2CBOOL(rb_funcall((VALUE)func, id_call, 4, + GOBJ2RVAL(selection), + GOBJ2RVAL(model), + GTKTREEPATH2RVAL(path), + CBOOL2RVAL(path_currently_selected))); +} + +static VALUE +rg_set_select_function(VALUE self) +{ + volatile VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_tree_selection_set_select_function(_SELF(self), + (GtkTreeSelectionFunc)selection_func, + (gpointer)func, NULL); + return self; +} + +/* We don't need this(?) +gpointer gtk_tree_selection_get_user_data +(GtkTreeSelection *selection); +*/ + +static VALUE +rg_tree_view(VALUE self) +{ + return GOBJ2RVAL(gtk_tree_selection_get_tree_view(_SELF(self))); +} + +static VALUE +rg_selected(VALUE self) +{ + GtkTreeIter iter; + GtkTreeModel* model; + gboolean ret = gtk_tree_selection_get_selected(_SELF(self), &model, &iter); + iter.user_data3 = model; + return ret ? GTKTREEITER2RVAL(&iter) : Qnil; +} + +static void +foreach_func(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) +{ + iter->user_data3 = model; + rb_funcall((VALUE)data, id_call, 3, GOBJ2RVAL(model), + GTKTREEPATH2RVAL(path), GTKTREEITER2RVAL(iter)); +} + +static VALUE +rg_selected_each(VALUE self) +{ + volatile VALUE func = rb_block_proc(); + gtk_tree_selection_selected_foreach(_SELF(self), + (GtkTreeSelectionForeachFunc)foreach_func, + (gpointer)func); + return self; +} + +static VALUE +rg_select_path(VALUE self, VALUE path) +{ + gtk_tree_selection_select_path(_SELF(self), RVAL2GTKTREEPATH(path)); + return self; +} + +static VALUE +rg_unselect_path(VALUE self, VALUE path) +{ + gtk_tree_selection_unselect_path(_SELF(self), RVAL2GTKTREEPATH(path)); + return self; +} + +static VALUE +rg_path_is_selected_p(VALUE self, VALUE path) +{ + return CBOOL2RVAL(gtk_tree_selection_path_is_selected(_SELF(self), RVAL2GTKTREEPATH(path))); +} + +static VALUE +rg_select_iter(VALUE self, VALUE iter) +{ + gtk_tree_selection_select_iter(_SELF(self), RVAL2GTKTREEITER(iter)); + return self; +} + +static VALUE +rg_unselect_iter(VALUE self, VALUE iter) +{ + gtk_tree_selection_unselect_iter(_SELF(self), RVAL2GTKTREEITER(iter)); + return self; +} + +static VALUE +rg_iter_is_selected_p(VALUE self, VALUE iter) +{ + return CBOOL2RVAL(gtk_tree_selection_iter_is_selected(_SELF(self), RVAL2GTKTREEITER(iter))); +} + +static VALUE +rg_select_all(VALUE self) +{ + gtk_tree_selection_select_all(_SELF(self)); + return self; +} + +static VALUE +rg_unselect_all(VALUE self) +{ + gtk_tree_selection_unselect_all(_SELF(self)); + return self; +} + +static VALUE +rg_select_range(VALUE self, VALUE start_path, VALUE end_path) +{ + gtk_tree_selection_select_range(_SELF(self), RVAL2GTKTREEPATH(start_path), + RVAL2GTKTREEPATH(end_path)); + return self; +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_selected_rows(VALUE self) +{ + GtkTreeModel* model; + GList* list = gtk_tree_selection_get_selected_rows(_SELF(self), &model); + VALUE ret = GLIST2ARY2(list, GTK_TYPE_TREE_PATH); + g_list_foreach(list, (GFunc)gtk_tree_path_free, (gpointer)NULL); + g_list_free(list); + return ret; +} + +static VALUE +rg_count_selected_rows(VALUE self) +{ + return INT2NUM(gtk_tree_selection_count_selected_rows(_SELF(self))); +} + +static VALUE +rg_unselect_range(VALUE self, VALUE start_path, VALUE end_path) +{ + gtk_tree_selection_unselect_range(_SELF(self), RVAL2GTKTREEPATH(start_path), + RVAL2GTKTREEPATH(end_path)); + return self; +} +#endif + +void +Init_gtk_treeselection(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TREE_SELECTION, "TreeSelection", mGtk); + + RG_DEF_METHOD(set_mode, 1); + RG_DEF_METHOD(mode, 0); + RG_DEF_METHOD(set_select_function, 0); + RG_DEF_METHOD(tree_view, 0); + RG_DEF_METHOD(selected, 0); + RG_DEF_METHOD(selected_each, 0); + RG_DEF_METHOD(select_path, 1); + RG_DEF_METHOD(unselect_path, 1); + RG_DEF_METHOD_P(path_is_selected, 1); + RG_DEF_METHOD(select_iter, 1); + RG_DEF_METHOD(unselect_iter, 1); + RG_DEF_METHOD_P(iter_is_selected, 1); + RG_DEF_METHOD(select_all, 0); + RG_DEF_METHOD(unselect_all, 0); + RG_DEF_METHOD(select_range, 2); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(selected_rows, 0); + RG_DEF_METHOD(count_selected_rows, 0); + RG_DEF_METHOD(unselect_range, 2); +#endif + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreesortable.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreesortable.c new file mode 100644 index 0000000..4291fca --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreesortable.c @@ -0,0 +1,123 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE mTreeSortable +#define _SELF(s) (GTK_TREE_SORTABLE(RVAL2GOBJ(s))) + +static VALUE +rg_sort_column_changed(VALUE self) +{ + gtk_tree_sortable_sort_column_changed(_SELF(self)); + return self; +} + +static VALUE +rg_sort_column_id(VALUE self) +{ + gint sort_column_id; + GtkSortType order; + + if (gtk_tree_sortable_get_sort_column_id(_SELF(self), &sort_column_id, + &order)) { + VALUE ary; + + ary = rb_ary_new2(2); + rb_ary_push(ary, INT2NUM(sort_column_id)); + rb_ary_push(ary, GENUM2RVAL(order, GTK_TYPE_SORT_TYPE)); + return ary; + } else { + return Qnil; /* XXX: or something else? exception? */ + } +} + +static VALUE +rg_set_sort_column_id(int argc, VALUE *argv, VALUE self) +{ + gint sort_column_id; + GtkSortType order; + + if (argc == 1 || argc == 2) { + sort_column_id = NUM2INT(argv[0]); + order = (argc == 2) ? RVAL2GENUM(argv[1], GTK_TYPE_SORT_TYPE) : GTK_SORT_ASCENDING; + } else { + rb_raise(rb_eArgError, "need 1 or 2 arguments."); + } + + gtk_tree_sortable_set_sort_column_id(_SELF(self), sort_column_id, + order); + return self; +} + +static gint +sort_func(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer func) +{ + a->user_data3 = model; + b->user_data3 = model; + return NUM2INT(rb_funcall((VALUE)func, id_call, 2, GTKTREEITER2RVAL(a), + GTKTREEITER2RVAL(b))); +} + +static VALUE +rg_set_sort_func(VALUE self, VALUE sort_column_id) +{ + volatile VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_tree_sortable_set_sort_func(_SELF(self), NUM2INT(sort_column_id), + (GtkTreeIterCompareFunc)sort_func, + (gpointer)func, NULL); + return self; +} + +static VALUE +rg_set_default_sort_func(VALUE self) +{ + volatile VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_tree_sortable_set_default_sort_func(_SELF(self), + (GtkTreeIterCompareFunc)sort_func, + (gpointer)func, NULL); + return self; +} + +static VALUE +rg_has_default_sort_func_p(VALUE self) +{ + return RVAL2CBOOL(gtk_tree_sortable_has_default_sort_func(_SELF(self))); +} + +void +Init_gtk_treesortable(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(GTK_TYPE_TREE_SORTABLE, "TreeSortable", mGtk); + + RG_DEF_METHOD(sort_column_changed, 0); + RG_DEF_METHOD(sort_column_id, 0); + RG_DEF_METHOD(set_sort_column_id, -1); + RG_DEF_METHOD(set_sort_func, 1); + RG_DEF_METHOD(set_default_sort_func, 0); + RG_DEF_METHOD_P(has_default_sort_func, 0); + + rb_define_const(RG_TARGET_NAMESPACE, "DEFAULT_SORT_COLUMN_ID", GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID); +} + +/* vim: set sts=4 sw=4 ts=8: */ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreestore.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreestore.c new file mode 100644 index 0000000..d0f0d7a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreestore.c @@ -0,0 +1,381 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011-2012 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTreeStore +#define _SELF(s) (GTK_TREE_STORE(RVAL2GOBJ(s))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + gint cnt; + GtkTreeStore* store; + GType* buf; + + if (argc == 0) rb_raise(rb_eArgError, "need more than 1 class type."); + + buf = ALLOCA_N(GType, argc); + for (cnt = 0; cnt < argc; cnt++) { + buf[cnt] = CLASS2GTYPE(argv[cnt]); + } + + store = gtk_tree_store_newv(argc, buf); + + G_INITIALIZE(self, store); + + return Qnil; +} + +static VALUE +rg_set_column_types(int argc, VALUE *argv, VALUE self) +{ + gint cnt; + GType* buf; + + if (argc == 0) rb_raise(rb_eArgError, "need more than 1 class type."); + buf = ALLOCA_N(GType, argc); + for (cnt = 0; cnt < argc; cnt++) { + buf[cnt] = CLASS2GTYPE(argv[cnt]); + } + + gtk_tree_store_set_column_types(_SELF(self), argc, buf); + + return self; +} + +static VALUE +rg_set_value(VALUE self, VALUE iter, VALUE column, VALUE value) +{ + GType gtype = gtk_tree_model_get_column_type(GTK_TREE_MODEL(RVAL2GOBJ(self)), NUM2INT(column)); + GValue gval = G_VALUE_INIT; + g_value_init(&gval, gtype); + + rbgobj_rvalue_to_gvalue(value, &gval); + + G_CHILD_ADD(self, iter); + G_CHILD_ADD(iter, value); + + gtk_tree_store_set_value(_SELF(self), RVAL2GTKTREEITER(iter), NUM2INT(column), &gval); + + g_value_unset(&gval); + return self; +} + +/* + void gtk_tree_store_set (GtkTreeStore *tree_store, + GtkTreeIter *iter, + ...); + + void gtk_tree_store_set_valist (GtkTreeStore *tree_store, + GtkTreeIter *iter, + va_list var_args); +*/ + +static VALUE +rg_remove(VALUE self, VALUE iter) +{ + G_CHILD_REMOVE(self, iter); +#if GTK_CHECK_VERSION(2,2,0) + return CBOOL2RVAL(gtk_tree_store_remove(_SELF(self), RVAL2GTKTREEITER(iter))); +#else + gtk_tree_store_remove(_SELF(self), RVAL2GTKTREEITER(iter)); + return Qtrue; +#endif +} + +static VALUE +rg_insert(int argc, VALUE *argv, VALUE self) +{ + VALUE parent, position, values, ret; + GtkTreeIter iter; + GtkTreeStore* model = _SELF(self); + + rb_scan_args(argc, argv, "21", &parent, &position, &values); + + if (NIL_P(values)){ + gtk_tree_store_insert(model, &iter, + NIL_P(parent) ? NULL : RVAL2GTKTREEITER(parent), + NUM2INT(position)); + iter.user_data3 = model; + ret = GTKTREEITER2RVAL(&iter); + G_CHILD_ADD(self, ret); + } else { +#if GTK_CHECK_VERSION(2,10,0) + gint *c_columns; + GValue *c_values; + long size, i; + + size = NUM2INT(rb_funcall(values, rb_intern("size"), 0)); + c_columns = ALLOCA_N(gint, size); + c_values = ALLOCA_N(GValue, size); + + if(TYPE(values)==T_ARRAY) { + for(i=0; i<size; i++) { + GType gtype; + GValue gval = G_VALUE_INIT; + + c_columns[i] = i; + gtype = gtk_tree_model_get_column_type(GTK_TREE_MODEL(RVAL2GOBJ(self)), + c_columns[i]); + + g_value_init(&gval, gtype); + rbgobj_rvalue_to_gvalue(rb_ary_shift(values), &gval); + c_values[i] = gval; + } + } else if(TYPE(values)==T_HASH) { + VALUE r_columns; + r_columns = rb_funcall(values, rb_intern("keys"), 0); + + for(i=0; i<size; i++) { + GType gtype; + GValue gval = G_VALUE_INIT; + + c_columns[i] = NUM2INT (rb_ary_entry(r_columns, i)); + gtype = gtk_tree_model_get_column_type(GTK_TREE_MODEL(RVAL2GOBJ(self)), + c_columns[i]); + + g_value_init(&gval, gtype); + rbgobj_rvalue_to_gvalue(rb_hash_aref(values, INT2NUM(c_columns[i])), &gval); + c_values[i] = gval; + } + } else { + rb_raise(rb_eArgError, "values must be of type Hash or Array"); + } + + gtk_tree_store_insert_with_valuesv(model, &iter, + NIL_P(parent) ? NULL : RVAL2GTKTREEITER(parent), + NUM2INT(position), + c_columns, + c_values, + size); + iter.user_data3 = model; + + ret = GTKTREEITER2RVAL(&iter); + G_CHILD_ADD(self, ret); + + for(i=0; i<size; i++) { + G_CHILD_ADD(ret, rbgobj_gvalue_to_rvalue(&(c_values[i]))); + g_value_unset(&(c_values[i])); + } +#else + rb_warn("Gtk::TreeStore#insert(parent, position, values) requires GTK+-2.10.0 or later"); + gtk_tree_store_insert(model, &iter, + NIL_P(parent) ? NULL : RVAL2GTKTREEITER(parent), + NUM2INT(position)); + iter.user_data3 = model; + ret = GTKTREEITER2RVAL(&iter); + G_CHILD_ADD(self, ret); +#endif + } + + return ret; +} + +static VALUE +rg_insert_before(VALUE self, VALUE parent, VALUE sibling) +{ + VALUE ret; + GtkTreeIter iter; + GtkTreeStore* model = _SELF(self); + gtk_tree_store_insert_before(model, &iter, + NIL_P(parent) ? NULL : RVAL2GTKTREEITER(parent), + NIL_P(sibling) ? NULL : RVAL2GTKTREEITER(sibling)); + iter.user_data3 = model; + ret = GTKTREEITER2RVAL(&iter); + G_CHILD_ADD(self, ret); + return ret; +} + +static VALUE +rg_insert_after(VALUE self, VALUE parent, VALUE sibling) +{ + VALUE ret; + GtkTreeIter iter; + GtkTreeStore* model = _SELF(self); + gtk_tree_store_insert_after(model, &iter, + NIL_P(parent) ? NULL : RVAL2GTKTREEITER(parent), + NIL_P(sibling) ? NULL : RVAL2GTKTREEITER(sibling)); + iter.user_data3 = model; + + ret = GTKTREEITER2RVAL(&iter); + G_CHILD_ADD(self, ret); + return ret; +} + +/* The 2 following functions where implemented as TreeStore#insert + which will use a Hash instead of pairs of parameters + +void gtk_tree_store_insert_with_values + (GtkTreeStore *tree_store, + GtkTreeIter *iter, + GtkTreeIter *parent, + gint position, + ...); + +void gtk_tree_store_insert_with_valuesv + (GtkTreeStore *tree_store, + GtkTreeIter *iter, + GtkTreeIter *parent, + gint position, + gint *columns, + GValue *values, + gint n_values); + +*/ + +static VALUE +rg_prepend(VALUE self, VALUE parent) +{ + VALUE ret; + GtkTreeIter iter; + GtkTreeStore* model = _SELF(self); + gtk_tree_store_prepend(model, &iter, + NIL_P(parent)?NULL:RVAL2GTKTREEITER(parent)); + iter.user_data3 = model; + + ret = GTKTREEITER2RVAL(&iter); + G_CHILD_ADD(self, ret); + return ret; +} + +static VALUE +rg_append(VALUE self, VALUE parent) +{ + VALUE ret; + GtkTreeIter iter; + GtkTreeStore* model = _SELF(self); + gtk_tree_store_append(model, &iter, + NIL_P(parent)?NULL:RVAL2GTKTREEITER(parent)); + iter.user_data3 = model; + + ret = GTKTREEITER2RVAL(&iter); + G_CHILD_ADD(self, ret); + return ret; +} + +static VALUE +rg_ancestor_p(VALUE self, VALUE iter, VALUE descendant) +{ + return gtk_tree_store_is_ancestor(_SELF(self), RVAL2GTKTREEITER(iter), + RVAL2GTKTREEITER(descendant)); +} + +static VALUE +rg_iter_depth(VALUE self, VALUE iter) +{ + return INT2NUM(gtk_tree_store_iter_depth(_SELF(self), RVAL2GTKTREEITER(iter))); +} + +static VALUE +rg_clear(VALUE self) +{ + G_CHILD_REMOVE_ALL(self); + gtk_tree_store_clear(_SELF(self)); + return self; +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_iter_is_valid_p(VALUE self, VALUE iter) +{ + return (NIL_P(iter)) ? Qfalse : + CBOOL2RVAL(gtk_tree_store_iter_is_valid(_SELF(self), RVAL2GTKTREEITER(iter))); +} + +static VALUE +rg_reorder(VALUE self, VALUE rbparent, VALUE rbnew_order) +{ + GtkTreeStore *store = _SELF(self); + GtkTreeIter *parent = RVAL2GTKTREEITER(rbparent); + gint n_children = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), + parent); + long n; + gint *new_order = RVAL2GINTS(rbnew_order, n); + + if (n != n_children) { + g_free(new_order); + + rb_raise(rb_eArgError, + "new order array must contain the same number of elements as the number of children in the parent: %ld != %d", + n, n_children); + } + + gtk_tree_store_reorder(store, parent, new_order); + + g_free(new_order); + + return self; +} + +static VALUE +rg_swap(VALUE self, VALUE iter1, VALUE iter2) +{ + gtk_tree_store_swap(_SELF(self), RVAL2GTKTREEITER(iter1), RVAL2GTKTREEITER(iter2)); + return self; +} + +static VALUE +rg_move_before(VALUE self, VALUE iter, VALUE position) +{ + gtk_tree_store_move_before(_SELF(self), RVAL2GTKTREEITER(iter), + NIL_P(position) ? NULL : RVAL2GTKTREEITER(position)); + return self; +} + +static VALUE +rg_move_after(VALUE self, VALUE iter, VALUE position) +{ + gtk_tree_store_move_after(_SELF(self), RVAL2GTKTREEITER(iter), + NIL_P(position) ? NULL : RVAL2GTKTREEITER(position)); + return self; +} +#endif + +void +Init_gtk_tree_store(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TREE_STORE, "TreeStore", mGtk); + + rbgtk_register_treeiter_set_value_func(GTK_TYPE_TREE_STORE, + (rbgtkiter_set_value_func)>k_tree_store_set_value); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(set_column_types, -1); + RG_DEF_METHOD(set_value, 3); + RG_DEF_METHOD(remove, 1); + RG_DEF_METHOD(insert, -1); + RG_DEF_METHOD(insert_before, 2); + RG_DEF_METHOD(insert_after, 2); + RG_DEF_METHOD(prepend, 1); + RG_DEF_METHOD(append, 1); + RG_DEF_METHOD_P(ancestor, 2); + RG_DEF_METHOD(iter_depth, 1); + RG_DEF_METHOD(clear, 0); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD_P(iter_is_valid, 1); + RG_DEF_METHOD(reorder, 2); + RG_DEF_METHOD(swap, 2); + RG_DEF_METHOD(move_before, 2); + RG_DEF_METHOD(move_after, 2); +#endif + +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreeview.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreeview.c new file mode 100644 index 0000000..9a5497f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreeview.c @@ -0,0 +1,770 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTreeView +#define _SELF(s) (GTK_TREE_VIEW(RVAL2GOBJ(s))) +#define TREEVIEW_COL(c) (GTK_TREE_VIEW_COLUMN(RVAL2GOBJ(c))) +#define RVAL2CELLRENDERER(c) (GTK_CELL_RENDERER(RVAL2GOBJ(c))) + +static ID id_model; +static ID id_selection; + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE model; + GtkWidget *widget; + + if (rb_scan_args(argc, argv, "01", &model) == 1) { + G_CHILD_SET(self, id_model, model); + widget = gtk_tree_view_new_with_model(GTK_TREE_MODEL(RVAL2GOBJ(model))); + } + else { + widget = gtk_tree_view_new(); + } + + RBGTK_INITIALIZE(self, widget); + return Qnil; +} + +static VALUE +rg_selection(VALUE self) +{ + VALUE ret = GOBJ2RVAL(gtk_tree_view_get_selection(_SELF(self))); + G_CHILD_SET(self, id_selection, ret); + return ret; +} + +static VALUE +rg_columns_autosize(VALUE self) +{ + gtk_tree_view_columns_autosize(_SELF(self)); + return self; +} + +static VALUE +rg_append_column(VALUE self, VALUE column) +{ + G_CHILD_ADD(self, column); + return INT2NUM(gtk_tree_view_append_column(_SELF(self), + TREEVIEW_COL(column))); +} + +static VALUE +rg_remove_column(VALUE self, VALUE column) +{ + G_CHILD_REMOVE(self, column); + return INT2NUM(gtk_tree_view_remove_column(_SELF(self), + TREEVIEW_COL(column))); +} + +static void +cell_data_func(GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer func) +{ + iter->user_data3 = model; + rb_funcall((VALUE)func, id_call, 4, GOBJ2RVAL(column), + GOBJ2RVAL(cell), GOBJ2RVAL(model), + GTKTREEITER2RVAL(iter)); +} + +static VALUE +rg_insert_column(int argc, VALUE *argv, VALUE self) +{ + VALUE args[4]; + + rb_scan_args(argc, argv, "22", /* NORMAL ATTRIBUTES DATA_FUNC */ + &args[0], /* column position position */ + &args[1], /* position title title */ + &args[2], /* renderer renderer */ + &args[3]); /* attributes */ + + if (argc == 2) { + G_CHILD_ADD(self, args[0]); + return INT2NUM(gtk_tree_view_insert_column(_SELF(self), + TREEVIEW_COL(args[0]), + NUM2INT(args[1]))); + } else if (argc == 3) { + int ret; + VALUE func = rb_block_proc(); + + G_RELATIVE(self, func); + ret = gtk_tree_view_insert_column_with_data_func(_SELF(self), + NUM2INT(args[0]), + RVAL2CSTR(args[1]), + RVAL2CELLRENDERER(args[2]), + (GtkTreeCellDataFunc)cell_data_func, + (gpointer)func, + NULL); + return INT2NUM(ret); + } else if (argc == 4) { + int i; + int col; + int ret; + const gchar *name; + VALUE ary; + GtkCellRenderer* renderer = RVAL2CELLRENDERER(args[2]); + + GtkTreeViewColumn* column = gtk_tree_view_column_new(); + + Check_Type(args[3], T_HASH); + + /* TODO: Should this really be done before we know that everything + * below worked without error? */ + G_CHILD_ADD(self, args[2]); + G_CHILD_ADD(self, args[3]); + + gtk_tree_view_column_set_title(column, RVAL2CSTR(args[1])); + gtk_tree_view_column_pack_start(column, renderer, TRUE); + + ret = gtk_tree_view_insert_column(_SELF(self), column, NUM2INT(args[0])); + ary = rb_funcall(args[3], rb_intern("to_a"), 0); + for (i = 0; i < RARRAY_LEN(ary); i++) { + VALUE val = RARRAY_PTR(RARRAY_PTR(ary)[i])[0]; + if (SYMBOL_P(val)) { + name = rb_id2name(SYM2ID(val)); + } else { + name = RVAL2CSTR(val); + } + col = NUM2INT(RARRAY_PTR(RARRAY_PTR(ary)[i])[1]); + gtk_tree_view_column_add_attribute(column, + renderer, + name, col); + } + return INT2NUM(ret); + } else { + rb_raise(rb_eArgError, "Wrong number of arguments: %d", argc); + } + + return Qnil; +} + +static VALUE +rg_get_column(VALUE self, VALUE num) +{ + return GOBJ2RVAL(gtk_tree_view_get_column(_SELF(self), NUM2INT(num))); +} + +static VALUE +rg_columns(VALUE self) +{ + return GLIST2ARYF(gtk_tree_view_get_columns(_SELF(self))); +} + +static VALUE +rg_move_column_after(VALUE self, VALUE column, VALUE base_column) +{ + gtk_tree_view_move_column_after(_SELF(self), TREEVIEW_COL(column), + NIL_P(base_column) ? NULL : TREEVIEW_COL(base_column)); + return self; +} + +static gboolean +column_drop_func(GtkTreeView *treeview, GtkTreeViewColumn *column, GtkTreeViewColumn *prev_column, GtkTreeViewColumn *next_column, gpointer func) +{ + return RVAL2CBOOL(rb_funcall((VALUE)func, id_call, 4, GOBJ2RVAL(treeview), + GOBJ2RVAL(column), GOBJ2RVAL(prev_column), + GOBJ2RVAL(next_column))); +} + +static VALUE +rg_set_column_drag_function(VALUE self) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_tree_view_set_column_drag_function(_SELF(self), + (GtkTreeViewColumnDropFunc)column_drop_func, + (gpointer)func, NULL); + return self; +} + +static VALUE +rg_scroll_to_point(VALUE self, VALUE x, VALUE y) +{ + gtk_tree_view_scroll_to_point(_SELF(self), NUM2INT(x), NUM2INT(y)); + return self; +} + +static VALUE +rg_scroll_to_cell(VALUE self, VALUE path, VALUE column, VALUE use_align, VALUE row_align, VALUE col_align) +{ + gtk_tree_view_scroll_to_cell(_SELF(self), + NIL_P(path) ? NULL : RVAL2GTKTREEPATH(path), + NIL_P(column) ? NULL : TREEVIEW_COL(column), + RVAL2CBOOL(use_align), + NUM2DBL(row_align), NUM2DBL(col_align)); + return self; +} + +static VALUE +rg_set_cursor(VALUE self, VALUE path, VALUE focus_column, VALUE start_editing) +{ + gtk_tree_view_set_cursor(_SELF(self), RVAL2GTKTREEPATH(path), + NIL_P(focus_column) ? NULL : TREEVIEW_COL(focus_column), + RVAL2CBOOL(start_editing)); + return self; +} + +static VALUE +rg_cursor(VALUE self) +{ + GtkTreePath* path; + GtkTreeViewColumn* focus_column; + + gtk_tree_view_get_cursor(_SELF(self), &path, &focus_column); + return rb_ary_new3(2, path ? GTKTREEPATH2RVAL(path) : Qnil, + GOBJ2RVAL(focus_column)); +} + +static VALUE +rg_expand_all(VALUE self) +{ + gtk_tree_view_expand_all(_SELF(self)); + return self; +} + +static VALUE +rg_collapse_all(VALUE self) +{ + gtk_tree_view_collapse_all(_SELF(self)); + return self; +} + +static VALUE +rg_expand_row(VALUE self, VALUE path, VALUE open_all) +{ + return CBOOL2RVAL(gtk_tree_view_expand_row(_SELF(self), + RVAL2GTKTREEPATH(path), + RVAL2CBOOL(open_all))); +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_expand_to_path(VALUE self, VALUE path) +{ + gtk_tree_view_expand_to_path(_SELF(self), RVAL2GTKTREEPATH(path)); + return self; +} +#endif + +static VALUE +rg_collapse_row(VALUE self, VALUE path) +{ + return CBOOL2RVAL(gtk_tree_view_collapse_row(_SELF(self), + RVAL2GTKTREEPATH(path))); +} + +static void +mapping_func(GtkTreeView *treeview, GtkTreePath *path, gpointer func) +{ + rb_funcall((VALUE)func, id_call, 2, GOBJ2RVAL(treeview), + GTKTREEPATH2RVAL(path)); +} + +static VALUE +rg_map_expanded_rows(VALUE self) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_tree_view_map_expanded_rows(_SELF(self), + (GtkTreeViewMappingFunc)mapping_func, + (gpointer)func); + return self; +} + +static VALUE +rg_row_expanded_p(VALUE self, VALUE path) +{ + return CBOOL2RVAL(gtk_tree_view_row_expanded(_SELF(self), + RVAL2GTKTREEPATH(path))); +} + +static VALUE +rg_get_path_at_pos(VALUE self, VALUE x, VALUE y) +{ + GtkTreePath* path; + GtkTreeViewColumn* column; + gint cell_x, cell_y; + gboolean ret; + + ret = gtk_tree_view_get_path_at_pos(_SELF(self), + NUM2INT(x), NUM2INT(y), + &path, &column, &cell_x, &cell_y); + return ret ? rb_ary_new3(4, + path ? GTKTREEPATH2RVAL(path) : Qnil, + column ? GOBJ2RVAL(column) : Qnil, + INT2NUM(cell_x), INT2NUM(cell_y)) : Qnil; +} + +static VALUE +rg_get_cell_area(VALUE self, VALUE path, VALUE column) +{ + GdkRectangle rect; + gtk_tree_view_get_cell_area(_SELF(self), + NIL_P(path) ? NULL : RVAL2GTKTREEPATH(path), + NIL_P(column) ? NULL : TREEVIEW_COL(column), + &rect); + return BOXED2RVAL(&rect, GDK_TYPE_RECTANGLE); +} + +static VALUE +rg_get_background_area(VALUE self, VALUE path, VALUE column) +{ + GdkRectangle rect; + gtk_tree_view_get_background_area(_SELF(self), + NIL_P(path) ? NULL : RVAL2GTKTREEPATH(path), + NIL_P(column) ? NULL : TREEVIEW_COL(column), + &rect); + return BOXED2RVAL(&rect, GDK_TYPE_RECTANGLE); +} + +static VALUE +rg_visible_rect(VALUE self) +{ + GdkRectangle rect; + gtk_tree_view_get_visible_rect(_SELF(self), &rect); + return BOXED2RVAL(&rect, GDK_TYPE_RECTANGLE); +} + +#if GTK_CHECK_VERSION(2,8,0) +static VALUE +rg_visible_range(VALUE self) +{ + GtkTreePath* start_path; + GtkTreePath* end_path; + + gboolean valid_paths = gtk_tree_view_get_visible_range(_SELF(self), &start_path, &end_path); + + return valid_paths ? rb_assoc_new(GTKTREEPATH2RVAL(start_path), + GTKTREEPATH2RVAL(end_path)) : Qnil; +} +#endif + +static VALUE +rg_bin_window(VALUE self) +{ + return GOBJ2RVAL(gtk_tree_view_get_bin_window(_SELF(self))); +} + +static VALUE +rg_widget_to_tree_coords(VALUE self, VALUE wx, VALUE wy) +{ + gint tx, ty; + gtk_tree_view_widget_to_tree_coords(_SELF(self), + NUM2INT(wx), NUM2INT(wy), + &tx, &ty); + return rb_ary_new3(2, INT2NUM(tx), INT2NUM(ty)); +} + +static VALUE +rg_tree_to_widget_coords(VALUE self, VALUE tx, VALUE ty) +{ + gint wx, wy; + gtk_tree_view_tree_to_widget_coords(_SELF(self), + NUM2INT(tx), NUM2INT(ty), + &wx, &wy); + return rb_ary_new3(2, INT2NUM(wx), INT2NUM(wy)); +} + +#if GTK_CHECK_VERSION(2,12,0) +static VALUE +rg_convert_bin_window_to_tree_coords(VALUE self, VALUE bx, VALUE by) +{ + gint tx, ty; + gtk_tree_view_convert_bin_window_to_tree_coords(_SELF(self), + NUM2INT(bx), NUM2INT(by), + &tx, &ty); + return rb_ary_new3(2, INT2NUM(tx), INT2NUM(ty)); +} +static VALUE +rg_convert_bin_window_to_widget_coords(VALUE self, VALUE bx, VALUE by) +{ + gint wx, wy; + gtk_tree_view_convert_bin_window_to_widget_coords(_SELF(self), + NUM2INT(bx), NUM2INT(by), + &wx, &wy); + return rb_ary_new3(2, INT2NUM(wx), INT2NUM(wy)); +} + +static VALUE +rg_convert_tree_to_bin_window_coords(VALUE self, VALUE tx, VALUE ty) +{ + gint bx, by; + gtk_tree_view_convert_tree_to_bin_window_coords(_SELF(self), + NUM2INT(tx), NUM2INT(ty), + &bx, &by); + return rb_ary_new3(2, INT2NUM(bx), INT2NUM(by)); +} +static VALUE +rg_convert_tree_to_widget_coords(VALUE self, VALUE tx, VALUE ty) +{ + gint wx, wy; + gtk_tree_view_convert_tree_to_widget_coords(_SELF(self), + NUM2INT(tx), NUM2INT(ty), + &wx, &wy); + return rb_ary_new3(2, INT2NUM(wx), INT2NUM(wy)); +} + +static VALUE +rg_convert_widget_to_bin_window_coords(VALUE self, VALUE wx, VALUE wy) +{ + gint bx, by; + gtk_tree_view_convert_widget_to_bin_window_coords(_SELF(self), + NUM2INT(wx), NUM2INT(wy), + &bx, &by); + return rb_ary_new3(2, INT2NUM(bx), INT2NUM(by)); +} +static VALUE +rg_convert_widget_to_tree_coords(VALUE self, VALUE wx, VALUE wy) +{ + gint tx, ty; + gtk_tree_view_convert_widget_to_tree_coords(_SELF(self), + NUM2INT(wx), NUM2INT(wy), + &tx, &ty); + return rb_ary_new3(2, INT2NUM(tx), INT2NUM(ty)); +} +#endif + +static VALUE +rg_enable_model_drag_dest(VALUE self, VALUE rbtargets, VALUE rbactions) +{ + GtkTreeView *view = _SELF(self); + GdkDragAction actions = RVAL2GFLAGS(rbactions, GDK_TYPE_DRAG_ACTION); + long n; + GtkTargetEntry *targets = RVAL2GTKTARGETENTRIES(rbtargets, &n); + + gtk_tree_view_enable_model_drag_dest(view, targets, n, actions); + + g_free(targets); + + return self; +} + +static VALUE +rg_enable_model_drag_source(VALUE self, VALUE rbstart_button_mask, VALUE rbtargets, VALUE rbactions) +{ + GtkTreeView *view = _SELF(self); + GdkModifierType start_button_mask = RVAL2GFLAGS(rbstart_button_mask, GDK_TYPE_MODIFIER_TYPE); + GdkDragAction actions = RVAL2GFLAGS(rbactions, GDK_TYPE_DRAG_ACTION); + long n; + GtkTargetEntry *targets = RVAL2GTKTARGETENTRIES_ACCEPT_NIL(rbtargets, &n); + + if (targets == NULL) + return self; + + gtk_tree_view_enable_model_drag_source(view, start_button_mask, targets, n, actions); + + g_free(targets); + + return self; +} + +static VALUE +rg_unset_rows_drag_source(VALUE self) +{ + gtk_tree_view_unset_rows_drag_source(_SELF(self)); + return self; +} + +static VALUE +rg_unset_rows_drag_dest(VALUE self) +{ + gtk_tree_view_unset_rows_drag_dest(_SELF(self)); + return self; +} + +static VALUE +rg_set_drag_dest_row(VALUE self, VALUE path, VALUE pos) +{ + gtk_tree_view_set_drag_dest_row(_SELF(self), + NIL_P(path)?NULL:RVAL2GTKTREEPATH(path), + RVAL2GENUM(pos, GTK_TYPE_TREE_VIEW_DROP_POSITION)); + return self; +} + +static VALUE +rg_drag_dest_row(VALUE self) +{ + GtkTreePath* path = NULL; + GtkTreeViewDropPosition pos; + gtk_tree_view_get_drag_dest_row(_SELF(self), &path, &pos); + return rb_ary_new3(2, path ? GTKTREEPATH2RVAL(path) : Qnil, + GENUM2RVAL(pos, GTK_TYPE_TREE_VIEW_DROP_POSITION)); +} + +static VALUE +rg_get_dest_row_at_pos(VALUE self, VALUE drag_x, VALUE drag_y) +{ + GtkTreePath* path; + GtkTreeViewDropPosition pos; + gboolean ret; + + ret = gtk_tree_view_get_dest_row_at_pos(_SELF(self), + NUM2INT(drag_x), NUM2INT(drag_y), + &path, &pos); + return ret ? rb_ary_new3(2, path ? GTKTREEPATH2RVAL(path) : Qnil, + GENUM2RVAL(pos, GTK_TYPE_TREE_VIEW_DROP_POSITION)) : Qnil; +} + +static VALUE +rg_create_row_drag_icon(VALUE self, VALUE path) +{ + return GOBJ2RVAL(gtk_tree_view_create_row_drag_icon(_SELF(self), + RVAL2GTKTREEPATH(path))); +} + +/* + We don't need this. + GtkTreeViewSearchEqualFunc gtk_tree_view_get_search_equal_func + (GtkTreeView *tree_view); +*/ + +static gboolean +search_equal_func(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer func) +{ + iter->user_data3 = model; + return RVAL2CBOOL(rb_funcall((VALUE)func, id_call, 4, + GOBJ2RVAL(model), INT2NUM(column), + CSTR2RVAL(key), GTKTREEITER2RVAL(iter))); +} + +static VALUE +rg_set_search_equal_func(VALUE self) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + gtk_tree_view_set_search_equal_func(_SELF(self), + (GtkTreeViewSearchEqualFunc)search_equal_func, + (gpointer)func, NULL); + return self; +} + +/* + * Optional Signals + */ +static VALUE +treeview_signal_func(G_GNUC_UNUSED guint num, const GValue *values) +{ + GtkTreeView* view = g_value_get_object(&values[0]); + GtkTreeIter* iter = g_value_get_boxed(&values[1]); + iter->user_data3 = gtk_tree_view_get_model(view); + + return rb_ary_new3(3, GOBJ2RVAL(view), GTKTREEITER2RVAL(iter), GVAL2RVAL(&values[2])); +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_set_cursor_on_cell(VALUE self, VALUE path, VALUE focus_column, VALUE focus_cell, VALUE start_editing) +{ + gtk_tree_view_set_cursor_on_cell(_SELF(self), RVAL2GTKTREEPATH(path), + NIL_P(focus_column) ? NULL : TREEVIEW_COL(focus_column), + NIL_P(focus_cell) ? NULL : GTK_CELL_RENDERER(RVAL2GOBJ(focus_cell)), + RVAL2CBOOL(start_editing)); + return self; +} +#endif + +/* How can I implement this? +GtkTreeViewRowSeparatorFunc gtk_tree_view_get_row_separator_func + (GtkTreeView *tree_view); +*/ + +#if GTK_CHECK_VERSION(2,6,0) +static gboolean +row_separator_func(GtkTreeModel *model, GtkTreeIter *iter, gpointer func) +{ + VALUE ret; + iter->user_data3 = model; + ret = rb_funcall((VALUE)func, id_call, 2, GOBJ2RVAL(model), + GTKTREEITER2RVAL(iter)); + return CBOOL2RVAL(ret); +} + +static VALUE +rg_set_row_separator_func(VALUE self) +{ + VALUE func = rb_block_proc(); + + G_RELATIVE(self, func); + gtk_tree_view_set_row_separator_func(_SELF(self), + row_separator_func, + (gpointer)func, + (GtkDestroyNotify)NULL); + return self; +} +#endif + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_search_entry(VALUE self) +{ + return GOBJ2RVAL(gtk_tree_view_get_search_entry(_SELF(self))); +} + +static VALUE +rg_set_search_entry(VALUE self, VALUE entry) +{ + gtk_tree_view_set_search_entry(_SELF(self), RVAL2GOBJ(entry)); + return self; +} + +/* Can't define this. +GtkTreeViewSearchPositionFunc gtk_tree_view_get_search_position_func + (GtkTreeView *tree_view); +*/ + +struct callback_arg +{ + VALUE callback; + VALUE tree_view; + VALUE search_dialog; +}; + +static VALUE +invoke_callback(VALUE data) +{ + struct callback_arg *arg = (struct callback_arg *)data; + rb_funcall(arg->callback, id_call, 2, arg->tree_view, arg->search_dialog); + return Qnil; +} + +static void +search_position_func(GtkTreeView *tree_view, GtkWidget *search_dialog, gpointer func) +{ + struct callback_arg arg; + + arg.callback = (VALUE)func; + arg.tree_view = GOBJ2RVAL(tree_view); + arg.search_dialog = GOBJ2RVAL(search_dialog); + G_PROTECT_CALLBACK(invoke_callback, &arg); +} + +static void +remove_callback_reference(gpointer data) +{ + G_CHILD_REMOVE(mGtk, (VALUE)data); +} + +static VALUE +rg_set_search_position_func(VALUE self) +{ + VALUE func = rb_block_proc(); + G_CHILD_ADD(mGtk, func); + gtk_tree_view_set_search_position_func(_SELF(self), + (GtkTreeViewSearchPositionFunc)search_position_func, + (gpointer)func, + (GDestroyNotify)remove_callback_reference); + return self; +} + +#endif + +void +Init_gtk_treeview(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TREE_VIEW, "TreeView", mGtk); + + id_selection = rb_intern("selection"); + id_model = rb_intern("model"); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(selection, 0); + RG_DEF_METHOD(columns_autosize, 0); + RG_DEF_METHOD(append_column, 1); + RG_DEF_METHOD(remove_column, 1); + RG_DEF_METHOD(insert_column, -1); + RG_DEF_METHOD(get_column, 1); + RG_DEF_METHOD(columns, 0); + RG_DEF_METHOD(move_column_after, 2); + RG_DEF_METHOD(set_column_drag_function, 0); + RG_DEF_METHOD(scroll_to_point, 2); + RG_DEF_METHOD(scroll_to_cell, 5); + RG_DEF_METHOD(set_cursor, 3); + RG_DEF_METHOD(cursor, 0); + RG_DEF_METHOD(expand_all, 0); + RG_DEF_METHOD(collapse_all, 0); + RG_DEF_METHOD(expand_row, 2); + RG_DEF_METHOD(collapse_row, 1); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(expand_to_path, 1); +#endif + RG_DEF_METHOD(map_expanded_rows, 0); + RG_DEF_METHOD_P(row_expanded, 1); + RG_DEF_METHOD(get_path_at_pos, 2); + RG_DEF_ALIAS("get_path", "get_path_at_pos"); + RG_DEF_METHOD(get_cell_area, 2); + RG_DEF_METHOD(get_background_area, 2); + RG_DEF_METHOD(visible_rect, 0); +#if GTK_CHECK_VERSION(2,8,0) + RG_DEF_METHOD(visible_range, 0); +#endif + + RG_DEF_METHOD(bin_window, 0); + RG_DEF_METHOD(widget_to_tree_coords, 2); + RG_DEF_METHOD(tree_to_widget_coords, 2); +#if GTK_CHECK_VERSION(2,12,0) + RG_DEF_METHOD(convert_bin_window_to_tree_coords, 2); + RG_DEF_METHOD(convert_bin_window_to_widget_coords, 2); + RG_DEF_METHOD(convert_tree_to_bin_window_coords, 2); + RG_DEF_METHOD(convert_tree_to_widget_coords, 2); + RG_DEF_METHOD(convert_widget_to_bin_window_coords, 2); + RG_DEF_METHOD(convert_widget_to_tree_coords, 2); +#endif + RG_DEF_METHOD(enable_model_drag_dest, 2); + RG_DEF_METHOD(enable_model_drag_source, 3); + RG_DEF_METHOD(unset_rows_drag_source, 0); + RG_DEF_METHOD(unset_rows_drag_dest, 0); + RG_DEF_METHOD(set_drag_dest_row, 2); + RG_DEF_METHOD(drag_dest_row, 0); + RG_DEF_METHOD(get_dest_row_at_pos, 2); + RG_DEF_ALIAS("get_dest_row", "get_dest_row_at_pos"); + RG_DEF_METHOD(create_row_drag_icon, 1); + RG_DEF_METHOD(set_search_equal_func, 0); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(set_cursor_on_cell, 4); +#endif + +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_METHOD(set_row_separator_func, 0); +#endif +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD(search_entry, 0); + RG_DEF_METHOD(set_search_entry, 1); + RG_DEF_METHOD(set_search_position_func, 0); +#endif + + /* Constants */ + G_DEF_CLASS(GTK_TYPE_TREE_VIEW_DROP_POSITION, "DropPosition", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_TREE_VIEW_DROP_POSITION, "GTK_TREE_VIEW_"); + +#if GTK_CHECK_VERSION(2,10,0) + /* GtkTreeViewGridLines */ + G_DEF_CLASS(GTK_TYPE_TREE_VIEW_GRID_LINES, "GridLines", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_TREE_VIEW_GRID_LINES, "GTK_TREE_VIEW_"); +#endif + + /* Option Signals */ + G_DEF_SIGNAL_FUNC(RG_TARGET_NAMESPACE, "row-collapsed", (GValToRValSignalFunc)treeview_signal_func); + G_DEF_SIGNAL_FUNC(RG_TARGET_NAMESPACE, "row-expanded", (GValToRValSignalFunc)treeview_signal_func); + G_DEF_SIGNAL_FUNC(RG_TARGET_NAMESPACE, "test-collapse-row", (GValToRValSignalFunc)treeview_signal_func); + G_DEF_SIGNAL_FUNC(RG_TARGET_NAMESPACE, "test-expand-row", (GValToRValSignalFunc)treeview_signal_func); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreeviewcolumn.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreeviewcolumn.c new file mode 100644 index 0000000..7ee4ab7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtktreeviewcolumn.c @@ -0,0 +1,299 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2004 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cTreeViewColumn +#define _SELF(s) (GTK_TREE_VIEW_COLUMN(RVAL2GOBJ(s))) +#define RVAL2CELLRENDERER(c) (GTK_CELL_RENDERER(RVAL2GOBJ(c))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + int i; + int col; + GtkTreeViewColumn *tvc; + GtkCellRenderer *renderer; + const gchar *name; + VALUE ary, val; + + tvc = gtk_tree_view_column_new(); + if (argc > 0){ + gtk_tree_view_column_set_title(tvc, RVAL2CSTR(argv[0])); + if (argc > 1) { + gtk_tree_view_column_pack_start(tvc, RVAL2CELLRENDERER(argv[1]), TRUE); + G_CHILD_ADD(self, argv[1]); + } + } + + RBGTK_INITIALIZE(self, tvc); + + if (argc == 3){ + ary = rb_funcall(argv[2], rb_intern("to_a"), 0); + renderer = RVAL2CELLRENDERER(argv[1]); + for (i = 0; i < RARRAY_LEN(ary); i++) { + val = RARRAY_PTR(RARRAY_PTR(ary)[i])[0]; + if (SYMBOL_P(val)) { + name = rb_id2name(SYM2ID(val)); + } else { + name = RVAL2CSTR(val); + } + col = NUM2INT(RARRAY_PTR(RARRAY_PTR(ary)[i])[1]); + gtk_tree_view_column_add_attribute(_SELF(self), renderer, name, col); + } + } + + return Qnil; +} + +static VALUE +rg_pack_start(VALUE self, VALUE cell, VALUE expand) +{ + G_CHILD_ADD(self, cell); + gtk_tree_view_column_pack_start(_SELF(self), RVAL2CELLRENDERER(cell), RVAL2CBOOL(expand)); + return self; +} + +static VALUE +rg_pack_end(VALUE self, VALUE cell, VALUE expand) +{ + G_CHILD_ADD(self, cell); + gtk_tree_view_column_pack_end(_SELF(self), RVAL2CELLRENDERER(cell), RVAL2CBOOL(expand)); + return self; +} + +static VALUE +rg_clear(VALUE self) +{ + G_CHILD_REMOVE_ALL(self); + gtk_tree_view_column_clear(_SELF(self)); + return self; +} + +static VALUE +rg_cell_renderers(VALUE self) +{ + return GLIST2ARYF(gtk_tree_view_column_get_cell_renderers(_SELF(self))); +} + +static VALUE +rg_add_attribute(VALUE self, VALUE cell, VALUE attribute, VALUE column) +{ + const gchar *name; + if (SYMBOL_P(attribute)) { + name = rb_id2name(SYM2ID(attribute)); + } else { + name = RVAL2CSTR(attribute); + } + gtk_tree_view_column_add_attribute(_SELF(self), RVAL2CELLRENDERER(cell), + name, NUM2INT(column)); + return self; +} + +static VALUE +rg_set_attributes(VALUE self, VALUE renderer, VALUE attributes) +{ + GtkTreeViewColumn *tvc; + GtkCellRenderer *grenderer; + const gchar *name; + int i, col; + VALUE ary, val; + + Check_Type(attributes, T_HASH); + + tvc = _SELF(self); + grenderer = RVAL2CELLRENDERER(renderer); + gtk_tree_view_column_clear_attributes(tvc, grenderer); + + ary = rb_funcall(attributes, rb_intern("to_a"), 0); + for (i = 0; i < RARRAY_LEN(ary); i++) { + val = RARRAY_PTR(RARRAY_PTR(ary)[i])[0]; + if (SYMBOL_P(val)) { + name = rb_id2name(SYM2ID(val)); + } else { + name = RVAL2CSTR(val); + } + col = NUM2INT(RARRAY_PTR(RARRAY_PTR(ary)[i])[1]); + gtk_tree_view_column_add_attribute(tvc, grenderer, name, col); + } + return self; +} + +static void +cell_data_func(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer func) +{ + iter->user_data3 = model; + rb_funcall((VALUE)func, id_call, 4, GOBJ2RVAL(tree_column), + GOBJ2RVAL(cell), GOBJ2RVAL(model), + GTKTREEITER2RVAL(iter)); +} + +static VALUE +rg_set_cell_data_func(VALUE self, VALUE renderer) +{ + volatile VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + G_RELATIVE(renderer, func); + gtk_tree_view_column_set_cell_data_func(_SELF(self), RVAL2CELLRENDERER(renderer), + (GtkTreeCellDataFunc)cell_data_func, (gpointer)func, NULL); + return self; +} + +static VALUE +rg_clear_attributes(VALUE self, VALUE cell) +{ + gtk_tree_view_column_clear_attributes(_SELF(self), RVAL2CELLRENDERER(cell)); + return self; +} + +static VALUE +rg_clicked(VALUE self) +{ + gtk_tree_view_column_clicked(_SELF(self)); + return self; +} + +static VALUE +rg_cell_set_cell_data(VALUE self, VALUE model, VALUE iter, VALUE is_expander, VALUE is_expanded) +{ + gtk_tree_view_column_cell_set_cell_data(_SELF(self), + GTK_TREE_MODEL(RVAL2GOBJ(model)), + RVAL2GTKTREEITER(iter), + RVAL2CBOOL(is_expander), + RVAL2CBOOL(is_expanded)); + return self; +} + +static VALUE +rg_cell_size(VALUE self) +{ + GdkRectangle cell_area; + gint x_offset, y_offset, width, height; + VALUE cell; + + /* Is this collect implement for cell_area ? */ + cell_area.x = -1; + cell_area.y = -1; + cell_area.width = -1; + cell_area.height = -1; + + gtk_tree_view_column_cell_get_size(_SELF(self), &cell_area, + &x_offset, &y_offset, + &width, &height); + if (cell_area.x == -1 || cell_area.y == -1 || + cell_area.width == -1 || cell_area.height == -1){ + cell = Qnil; + } else { + cell = BOXED2RVAL(&cell_area, GDK_TYPE_RECTANGLE); + } + return rb_ary_new3(5, cell, + x_offset ? INT2NUM(x_offset) : Qnil, + y_offset ? INT2NUM(y_offset) : Qnil, + width ? INT2NUM(width) : Qnil, + height ? INT2NUM(height) : Qnil); +} + +static VALUE +rg_cell_is_visible_p(VALUE self) +{ + return CBOOL2RVAL(gtk_tree_view_column_cell_is_visible(_SELF(self))); +} + +#if GTK_CHECK_VERSION(2,2,0) + +static VALUE +rg_focus_cell(VALUE self, VALUE renderer) +{ + gtk_tree_view_column_focus_cell(_SELF(self), RVAL2CELLRENDERER(renderer)); + + return self; +} + +#endif + +#if GTK_CHECK_VERSION(2,8,0) +static VALUE +rg_queue_resize(VALUE self) +{ + gtk_tree_view_column_queue_resize(_SELF(self)); + return self; +} +#endif + +#if GTK_CHECK_VERSION(2,12,0) +static VALUE +rg_tree_view(VALUE self) +{ + return GOBJ2RVAL(gtk_tree_view_column_get_tree_view(_SELF(self))); +} +#endif + +#if !GTK_CHECK_VERSION(2,18,0) +static VALUE +rg_sort_column_id(VALUE self) +{ + return INT2NUM(gtk_tree_view_column_get_sort_column_id(_SELF(self))); +} + +static VALUE +rg_set_sort_column_id(VALUE self, VALUE id) +{ + gtk_tree_view_column_set_sort_column_id(_SELF(self), NUM2INT(id)); + return self; +} +#endif + +void +Init_gtk_treeviewcolumn(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TREE_VIEW_COLUMN, "TreeViewColumn", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(pack_start, 2); + RG_DEF_METHOD(pack_end, 2); + RG_DEF_METHOD(clear, 0); + RG_DEF_METHOD(cell_renderers, 0); + RG_DEF_METHOD(add_attribute, 3); + RG_DEF_METHOD(set_attributes, 2); + RG_DEF_METHOD(set_cell_data_func, 1); + RG_DEF_METHOD(clear_attributes, 1); + RG_DEF_METHOD(clicked, 0); + RG_DEF_METHOD(cell_set_cell_data, 4); + RG_DEF_METHOD(cell_size, 0); + RG_DEF_METHOD_P(cell_is_visible, 0); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(focus_cell, 1); +#endif +#if GTK_CHECK_VERSION(2,8,0) + RG_DEF_METHOD(queue_resize, 0); +#endif +#if GTK_CHECK_VERSION(2,12,0) + RG_DEF_METHOD(tree_view, 0); +#endif +#if !GTK_CHECK_VERSION(2,18,0) + RG_DEF_METHOD(sort_column_id, 0); + RG_DEF_METHOD(set_sort_column_id, 1); + RG_DEF_ALIAS("sort_column_id=", "set_sort_column_id"); +#endif + /* GtkTreeViewColumnSizing */ + G_DEF_CLASS(GTK_TYPE_TREE_VIEW_COLUMN_SIZING, "Sizing", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_TREE_VIEW_COLUMN_SIZING, "GTK_TREE_VIEW_COLUMN_"); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkuimanager.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkuimanager.c new file mode 100644 index 0000000..6477e9b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkuimanager.c @@ -0,0 +1,195 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2004-2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,4,0) + +#define RG_TARGET_NAMESPACE cUIManager +#define _SELF(self) (GTK_UI_MANAGER(RVAL2GOBJ(self))) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, gtk_ui_manager_new()); + return Qnil; +} + +static VALUE +rg_insert_action_group(VALUE self, VALUE action_group, VALUE pos) +{ + gtk_ui_manager_insert_action_group(_SELF(self), RVAL2GOBJ(action_group), NUM2INT(pos)); + G_CHILD_ADD(self, action_group); + return self; +} + +static VALUE +rg_remove_action_group(VALUE self, VALUE action_group) +{ + gtk_ui_manager_remove_action_group(_SELF(self), RVAL2GOBJ(action_group)); + G_CHILD_REMOVE(self, action_group); + return self; +} + +static VALUE +rg_action_groups(VALUE self) +{ + /* Owned by GTK+ */ + return GLIST2ARY(gtk_ui_manager_get_action_groups(_SELF(self))); +} + +static VALUE +rg_accel_group(VALUE self) +{ + return GOBJ2RVAL(gtk_ui_manager_get_accel_group(_SELF(self))); +} + +static VALUE +rg_get_widget(VALUE self, VALUE path) +{ + GtkWidget* widget = gtk_ui_manager_get_widget(_SELF(self), RVAL2CSTR(path)); + if (! widget) + rb_raise(rb_eArgError, "no widget was found."); + + return GOBJ2RVAL(widget); +} + +static VALUE +rg_get_toplevels(VALUE self, VALUE types) +{ + return GSLIST2ARYF(gtk_ui_manager_get_toplevels(_SELF(self), + RVAL2GFLAGS(types, GTK_TYPE_UI_MANAGER_ITEM_TYPE))); +} + +static VALUE +rg_get_action(VALUE self, VALUE path) +{ + return GOBJ2RVAL(gtk_ui_manager_get_action(_SELF(self), RVAL2CSTR(path))); +} + +static VALUE +rg_add_ui(int argc, VALUE *argv, VALUE self) +{ + GError* error = NULL; + guint ret; + VALUE buffer; + + if (argc == 1) { + VALUE buffer_or_filename; + rb_scan_args(argc, argv, "10", &buffer_or_filename); + + StringValue(buffer_or_filename); + buffer = rb_funcall(buffer_or_filename, rb_intern("include?"), 1, CSTR2RVAL("<ui>")); + + if (RVAL2CBOOL(buffer)){ + StringValue(buffer_or_filename); + ret = gtk_ui_manager_add_ui_from_string(_SELF(self), + RSTRING_PTR(buffer_or_filename), + RSTRING_LEN(buffer_or_filename), + &error); + } else { + ret = gtk_ui_manager_add_ui_from_file(_SELF(self), RVAL2CSTR(buffer_or_filename), + &error); + } + } else { + VALUE merge_id, path, name, action, type, top; + + rb_scan_args(argc, argv, "60", &merge_id, &path, &name, &action, &type, &top); + + ret = NUM2UINT(merge_id); + gtk_ui_manager_add_ui(_SELF(self), ret, RVAL2CSTR(path), + RVAL2CSTR(name), RVAL2CSTR(action), + RVAL2GFLAGS(type, GTK_TYPE_UI_MANAGER_ITEM_TYPE), + RVAL2CBOOL(top)); + } + + if (ret == 0) RAISE_GERROR(error); + + return UINT2NUM(ret); +} + +static VALUE +rg_new_merge_id(VALUE self) +{ + return UINT2NUM(gtk_ui_manager_new_merge_id(_SELF(self))); +} + +static VALUE +rg_remove_ui(VALUE self, VALUE merge_id) +{ + gtk_ui_manager_remove_ui(_SELF(self), NUM2UINT(merge_id)); + return self; +} + +static VALUE +rg_ensure_update(VALUE self) +{ + gtk_ui_manager_ensure_update(_SELF(self)); + return self; +} + +static void +rbuimanager_mark(void *p) +{ + GtkUIManager *manager; + GList *node; + + manager = GTK_UI_MANAGER(p); + for (node = gtk_ui_manager_get_action_groups(manager); + node; + node = g_list_next(node)) { + GtkWidget *action_group = node->data; + rbgobj_gc_mark_instance(action_group); + } + + rbgobj_gc_mark_instance(gtk_ui_manager_get_accel_group(manager)); +} +#endif + +void +Init_gtk_uimanager(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,4,0) + VALUE RG_TARGET_NAMESPACE; + + RG_TARGET_NAMESPACE = G_DEF_CLASS_WITH_GC_FUNC(GTK_TYPE_UI_MANAGER, "UIManager", mGtk, + rbuimanager_mark, NULL); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(insert_action_group, 2); + RG_DEF_METHOD(remove_action_group, 1); + RG_DEF_METHOD(action_groups, 0); + RG_DEF_METHOD(accel_group, 0); + RG_DEF_METHOD(get_widget, 1); + RG_DEF_ALIAS("[]", "get_widget"); + RG_DEF_METHOD(get_toplevels, 1); + RG_DEF_METHOD(get_action, 1); + RG_DEF_METHOD(add_ui, -1); + RG_DEF_METHOD(new_merge_id, 0); + RG_DEF_METHOD(remove_ui, 1); + RG_DEF_METHOD(ensure_update, 0); + + /* GtkUIManagerItemType */ + G_DEF_CLASS(GTK_TYPE_UI_MANAGER_ITEM_TYPE, "ItemType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_UI_MANAGER_ITEM_TYPE, "GTK_UI_MANAGER_"); + +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvbbox.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvbbox.c new file mode 100644 index 0000000..30ede22 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvbbox.c @@ -0,0 +1,42 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cVButtonBox + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_vbutton_box_new()); + return Qnil; +} + +void +Init_gtk_vbutton_box(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_VBUTTON_BOX, "VButtonBox", mGtk); + + RG_DEF_METHOD(initialize, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvbox.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvbox.c new file mode 100644 index 0000000..d33f559 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvbox.c @@ -0,0 +1,47 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cVBox + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE homogeneous, spacing; + + rb_scan_args(argc, argv, "02", &homogeneous, &spacing); + + RBGTK_INITIALIZE(self, gtk_vbox_new(RVAL2CBOOL(homogeneous), + (NIL_P(spacing)?0:NUM2INT(spacing)))); + return Qnil; +} + +void +Init_gtk_vbox(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_VBOX, "VBox", mGtk); + + RG_DEF_METHOD(initialize, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkviewport.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkviewport.c new file mode 100644 index 0000000..3f6f060 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkviewport.c @@ -0,0 +1,44 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cViewport + +static VALUE +rg_initialize(VALUE self, VALUE hadj, VALUE vadj) +{ + GtkAdjustment *h_adj = GTK_ADJUSTMENT(RVAL2GOBJ(hadj)); + GtkAdjustment *v_adj = GTK_ADJUSTMENT(RVAL2GOBJ(vadj)); + + RBGTK_INITIALIZE(self, gtk_viewport_new(h_adj, v_adj)); + return Qnil; +} + +void +Init_gtk_viewport(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_VIEWPORT, "Viewport", mGtk); + RG_DEF_METHOD(initialize, 2); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvolumebutton.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvolumebutton.c new file mode 100644 index 0000000..349bfb3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvolumebutton.c @@ -0,0 +1,47 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#if GTK_CHECK_VERSION(2,12,0) + +#define RG_TARGET_NAMESPACE cVolumeButton + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_volume_button_new()); + return Qnil; +} + +#endif + +void +Init_gtk_volumebutton(VALUE mGtk) +{ +#if GTK_CHECK_VERSION(2,12,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_VOLUME_BUTTON, "VolumeButton", mGtk); + RG_DEF_METHOD(initialize, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvpaned.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvpaned.c new file mode 100644 index 0000000..d6d8804 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvpaned.c @@ -0,0 +1,42 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cVPaned + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_vpaned_new()); + return Qnil; +} + +void +Init_gtk_vpaned(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_VPANED, "VPaned", mGtk); + + RG_DEF_METHOD(initialize, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvruler.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvruler.c new file mode 100644 index 0000000..840bfd8 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvruler.c @@ -0,0 +1,41 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cVRuler + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_vruler_new()); + return Qnil; +} + +void +Init_gtk_vruler(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_VRULER, "VRuler", mGtk); + RG_DEF_METHOD(initialize, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvscale.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvscale.c new file mode 100644 index 0000000..396e4f7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvscale.c @@ -0,0 +1,54 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cVScale + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE arg1, arg2, arg3; + GtkAdjustment *adj = NULL; + GtkWidget *widget; + + rb_scan_args(argc, argv, "03", &arg1, &arg2, &arg3); + + if (NIL_P(arg1) || RVAL2GTYPE(arg1) == GTK_TYPE_ADJUSTMENT){ + if (!NIL_P(arg1)) adj = GTK_ADJUSTMENT(RVAL2GOBJ(arg1)); + widget = gtk_vscale_new(adj); + } else { + widget = gtk_vscale_new_with_range(NUM2DBL(arg1), + NUM2DBL(arg2), NUM2DBL(arg3)); + } + RBGTK_INITIALIZE(self, widget); + return Qnil; +} + +void +Init_gtk_vscale(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_VSCALE, "VScale", mGtk); + RG_DEF_METHOD(initialize, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvscrollbar.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvscrollbar.c new file mode 100644 index 0000000..3dd0581 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvscrollbar.c @@ -0,0 +1,47 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cVScrollbar + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE arg1; + GtkAdjustment *adj = NULL; + + rb_scan_args(argc, argv, "01", &arg1); + if (!NIL_P(arg1)) adj = GTK_ADJUSTMENT(RVAL2GOBJ(arg1)); + + RBGTK_INITIALIZE(self, gtk_vscrollbar_new(adj)); + return Qnil; +} + +void +Init_gtk_vscrollbar(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_VSCROLLBAR, "VScrollbar", mGtk); + RG_DEF_METHOD(initialize, -1); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvseparator.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvseparator.c new file mode 100644 index 0000000..a586817 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkvseparator.c @@ -0,0 +1,41 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cVSeparator + +static VALUE +rg_initialize(VALUE self) +{ + RBGTK_INITIALIZE(self, gtk_vseparator_new()); + return Qnil; +} + +void +Init_gtk_vseparator(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_VSEPARATOR, "VSeparator", mGtk); + RG_DEF_METHOD(initialize, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkwidget.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkwidget.c new file mode 100644 index 0000000..263beb0 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkwidget.c @@ -0,0 +1,1249 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cWidget +#define _SELF(self) (GTK_WIDGET(RVAL2GOBJ(self))) + +static VALUE style_prop_func_table; + +static VALUE +rg_flags(VALUE self) +{ + return GFLAGS2RVAL(GTK_WIDGET_FLAGS(_SELF(self)), GTK_TYPE_WIDGET_FLAGS); +} + +static VALUE +rg_set_flags(VALUE self, VALUE flag) +{ + GTK_WIDGET_SET_FLAGS(_SELF(self), RVAL2GFLAGS(flag, GTK_TYPE_WIDGET_FLAGS)); + return self; +} + +static VALUE +rg_unset_flags(VALUE self, VALUE flag) +{ + GTK_WIDGET_UNSET_FLAGS(_SELF(self), RVAL2GFLAGS(flag, GTK_TYPE_WIDGET_FLAGS)); + return self; +} + +static VALUE +rg_unparent(VALUE self) +{ + gtk_widget_unparent(_SELF(self)); + return self; +} + +static VALUE +rg_show(VALUE self) +{ + gtk_widget_show(_SELF(self)); + return self; +} + +static VALUE +rg_show_now(VALUE self) +{ + gtk_widget_show_now(_SELF(self)); + return self; +} + +static VALUE +rg_hide(VALUE self) +{ + gtk_widget_hide(_SELF(self)); + return self; +} + +static VALUE +rg_show_all(VALUE self) +{ + gtk_widget_show_all(_SELF(self)); + return self; +} + +static VALUE +rg_hide_all(VALUE self) +{ + gtk_widget_hide_all(_SELF(self)); + return self; +} + +static VALUE +rg_map(VALUE self) +{ + gtk_widget_map(_SELF(self)); + return self; +} + +static VALUE +rg_unmap(VALUE self) +{ + gtk_widget_unmap(_SELF(self)); + return self; +} + +static VALUE +rg_realize(VALUE self) +{ + gtk_widget_realize(_SELF(self)); + return self; +} + +static VALUE +rg_unrealize(VALUE self) +{ + gtk_widget_unrealize(_SELF(self)); + return self; +} + +static VALUE +rg_queue_draw(VALUE self) +{ + gtk_widget_queue_draw(_SELF(self)); + return self; +} + +static VALUE +rg_queue_resize(VALUE self) +{ + gtk_widget_queue_resize(_SELF(self)); + return self; +} + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_queue_resize_no_redraw(VALUE self) +{ + gtk_widget_queue_resize_no_redraw(_SELF(self)); + return self; +} +#endif + +/* Note this method is not + gtk_widget_get_size_request */ +static VALUE +rg_size_request(VALUE self) +{ + GtkRequisition req; + gtk_widget_size_request(_SELF(self), &req); + return rb_ary_new3(2, INT2NUM(req.width), INT2NUM(req.height)); +} + +static VALUE +rg_child_requisition(VALUE self) +{ + GtkRequisition req; + + gtk_widget_get_child_requisition(_SELF(self), &req); + return rb_ary_new3(2, INT2NUM(req.width), INT2NUM(req.height)); +} + +static VALUE +rg_size_allocate(VALUE self, VALUE alloc) +{ + gtk_widget_size_allocate(_SELF(self), (GtkAllocation*)RVAL2BOXED(alloc, GTK_TYPE_ALLOCATION)); + return self; +} + +static VALUE +rg_add_accelerator(VALUE self, VALUE sig, VALUE accel, VALUE key, VALUE mod, VALUE flag) +{ + gtk_widget_add_accelerator(_SELF(self), + RVAL2CSTR(sig), + GTK_ACCEL_GROUP(RVAL2GOBJ(accel)), + NUM2INT(key), + RVAL2GFLAGS(mod, GDK_TYPE_MODIFIER_TYPE), + RVAL2GFLAGS(flag, GTK_TYPE_ACCEL_FLAGS)); + return self; +} + +static VALUE +rg_remove_accelerator(VALUE self, VALUE accel, VALUE key, VALUE mod) +{ + return CBOOL2RVAL(gtk_widget_remove_accelerator(_SELF(self), + GTK_ACCEL_GROUP(RVAL2GOBJ(accel)), + NUM2INT(key), + RVAL2GFLAGS(mod, GDK_TYPE_MODIFIER_TYPE))); +} + +static VALUE +rg_set_accel_path(VALUE self, VALUE accel_path, VALUE accel_group) +{ + gtk_widget_set_accel_path(_SELF(self), RVAL2CSTR(accel_path), + GTK_ACCEL_GROUP(RVAL2GOBJ(accel_group))); + return self; +} + +static VALUE +rg_accel_closures(VALUE self) +{ + return GLIST2ARY2F(gtk_widget_list_accel_closures(_SELF(self)), G_TYPE_CLOSURE); +} + +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_can_activate_accel_p(VALUE self, VALUE signal_id) +{ + return CBOOL2RVAL(gtk_widget_can_activate_accel(_SELF(self), NUM2UINT(signal_id))); +} +#endif + +static VALUE +rg_event(VALUE self, VALUE event) +{ + return CBOOL2RVAL(gtk_widget_event(_SELF(self), RVAL2GEV(event))); +} + +static VALUE +rg_activate(VALUE self) +{ + return CBOOL2RVAL(gtk_widget_activate(_SELF(self))); +} + +static VALUE +rg_reparent(VALUE self, VALUE parent) +{ + gtk_widget_reparent(_SELF(self), _SELF(parent)); + return self; +} + +static VALUE +rg_intersect(VALUE self, VALUE area) +{ + GdkRectangle intersection; + gboolean ret = gtk_widget_intersect(_SELF(self), + (GdkRectangle*)RVAL2BOXED(area, GDK_TYPE_RECTANGLE), + &intersection); + return ret ? BOXED2RVAL(&intersection, GDK_TYPE_RECTANGLE) : Qnil; +} + +static VALUE +rg_grab_default(VALUE self) +{ + gtk_widget_grab_default(_SELF(self)); + return self; +} + +static VALUE +rg_set_state(VALUE self, VALUE state) +{ + gtk_widget_set_state(_SELF(self), RVAL2GTKSTATETYPE(state)); + return self; +} + +static VALUE +rg_set_parent_window(VALUE self, VALUE parent_window) +{ + gtk_widget_set_parent_window(_SELF(self), + GDK_WINDOW(RVAL2GOBJ(parent_window))); + return self; +} + +static VALUE +rg_parent_window(VALUE self) +{ + return GOBJ2RVAL(gtk_widget_get_parent_window(_SELF(self))); +} + +static VALUE +rg_add_events(VALUE self, VALUE events) +{ + gtk_widget_add_events(_SELF(self), NUM2INT(events)); + return self; +} + +static VALUE +rg_toplevel(VALUE self) +{ + return GOBJ2RVAL(gtk_widget_get_toplevel(_SELF(self))); +} + +static VALUE +rg_get_ancestor(VALUE self, VALUE klass) +{ + return GOBJ2RVAL(gtk_widget_get_ancestor(_SELF(self), CLASS2GTYPE(klass))); +} + +static VALUE +rg_colormap(VALUE self) +{ + return GOBJ2RVAL(gtk_widget_get_colormap(_SELF(self))); +} + +static VALUE +rg_set_colormap(VALUE self, VALUE colormap) +{ + gtk_widget_set_colormap(_SELF(self), GDK_COLORMAP(RVAL2GOBJ(colormap))); + return self; +} + +static VALUE +rg_visual(VALUE self) +{ + return GOBJ2RVAL(gtk_widget_get_visual(_SELF(self))); +} + +static VALUE +rg_pointer(VALUE self) +{ + int x, y; + + gtk_widget_get_pointer(_SELF(self), &x, &y); + return rb_assoc_new(INT2FIX(x), INT2FIX(y)); +} + +static VALUE +rg_ancestor_p(VALUE self, VALUE ancestor) +{ + return CBOOL2RVAL(gtk_widget_is_ancestor(_SELF(self), _SELF(ancestor))); +} + +static VALUE +rg_translate_coordinates(VALUE self, VALUE dest_widget, VALUE src_x, VALUE src_y) +{ + gint dest_x, dest_y; + gboolean ret; + VALUE result = Qnil; + ret = gtk_widget_translate_coordinates(_SELF(self), _SELF(dest_widget), + NUM2INT(src_x), NUM2INT(src_y), + &dest_x, &dest_y); + if (ret) + result = rb_ary_new3(2, INT2FIX(dest_x), INT2FIX(dest_y)); + + return result; +} + +static VALUE +rg_hide_on_delete(VALUE self) +{ + return CBOOL2RVAL(gtk_widget_hide_on_delete(_SELF(self))); +} + +static VALUE +rg_ensure_style(VALUE self) +{ + gtk_widget_ensure_style(_SELF(self)); + return self; +} + +static VALUE +rg_reset_rc_styles(VALUE self) +{ + gtk_widget_reset_rc_styles(_SELF(self)); + return self; +} + +static VALUE +rg_s_push_colormap(G_GNUC_UNUSED VALUE self, VALUE cmap) +{ + gtk_widget_push_colormap(GDK_COLORMAP(RVAL2GOBJ(cmap))); + return cmap; +} + +static VALUE +rg_s_pop_colormap(VALUE self) +{ + gtk_widget_pop_colormap(); + return self; +} + +static VALUE +rg_s_set_default_colormap(G_GNUC_UNUSED VALUE self, VALUE cmap) +{ + gtk_widget_set_default_colormap(GDK_COLORMAP(RVAL2GOBJ(cmap))); + return cmap; +} + +static VALUE +rg_s_default_style(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(gtk_widget_get_default_style()); +} + +static VALUE +rg_s_default_colormap(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(gtk_widget_get_default_colormap()); +} + +static VALUE +rg_s_default_visual(G_GNUC_UNUSED VALUE self) +{ + return GOBJ2RVAL(gtk_widget_get_default_visual()); +} + +static VALUE +rg_set_direction(VALUE self, VALUE dir) +{ + gtk_widget_set_direction(_SELF(self), RVAL2GENUM(dir, GTK_TYPE_TEXT_DIRECTION)); + return self; +} + +static VALUE +rg_direction(VALUE self) +{ + return GENUM2RVAL(gtk_widget_get_direction(_SELF(self)), GTK_TYPE_TEXT_DIRECTION); +} + +static VALUE +rg_s_set_default_direction(VALUE self, VALUE dir) +{ + gtk_widget_set_default_direction(RVAL2GENUM(dir, GTK_TYPE_TEXT_DIRECTION)); + return self; +} + +static VALUE +rg_s_default_direction(G_GNUC_UNUSED VALUE self) +{ + return GENUM2RVAL(gtk_widget_get_default_direction(), GTK_TYPE_TEXT_DIRECTION); +} + +static VALUE +rg_shape_combine_mask(VALUE self, VALUE shape_mask, VALUE offset_x, VALUE offset_y) +{ + gtk_widget_shape_combine_mask(_SELF(self), + GDK_BITMAP(RVAL2GOBJ(shape_mask)), + NUM2INT(offset_x), + NUM2INT(offset_y)); + return self; +} + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_input_shape_combine_mask(VALUE self, VALUE shape_mask, VALUE offset_x, VALUE offset_y) +{ + gtk_widget_input_shape_combine_mask(_SELF(self), + GDK_BITMAP(RVAL2GOBJ(shape_mask)), + NUM2INT(offset_x), + NUM2INT(offset_y)); + return self; +} +#endif + +static VALUE +rg_path(VALUE self) +{ + guint path_length; + gchar *path; + gchar *path_reversed; + VALUE str_path; + VALUE str_path_reversed; + + gtk_widget_path(_SELF(self), &path_length, &path, &path_reversed); + str_path = CSTR2RVAL(path); + str_path_reversed = CSTR2RVAL(path_reversed); + g_free(path); + g_free(path_reversed); + return rb_ary_new3(2, str_path, str_path_reversed); +} + +static VALUE +rg_class_path(VALUE self) +{ + guint path_length; + gchar *path; + gchar *path_reversed; + VALUE str_path; + VALUE str_path_reversed; + + gtk_widget_class_path(_SELF(self), &path_length, &path, &path_reversed); + str_path = CSTR2RVAL(path); + str_path_reversed = CSTR2RVAL(path_reversed); + g_free(path); + g_free(path_reversed); + return rb_ary_new3(2, str_path, str_path_reversed); +} + +static VALUE +rg_composite_name(VALUE self) +{ + return CSTR2RVAL(gtk_widget_get_composite_name(_SELF(self))); +} + +static VALUE +rg_modify_style(VALUE self, VALUE style) +{ + gtk_widget_modify_style(_SELF(self), + GTK_RC_STYLE(RVAL2GOBJ(style))); + return self; +} + +static VALUE +rg_modifier_style(VALUE self) +{ + return GOBJ2RVAL(gtk_widget_get_modifier_style(_SELF(self))); +} + +static VALUE +rg_modify_fg(VALUE self, VALUE state, VALUE color) +{ + gtk_widget_modify_fg(_SELF(self), RVAL2GTKSTATETYPE(state), + RVAL2GDKCOLOR(color)); + return self; +} + +static VALUE +rg_modify_bg(VALUE self, VALUE state, VALUE color) +{ + gtk_widget_modify_bg(_SELF(self), RVAL2GTKSTATETYPE(state), + RVAL2GDKCOLOR(color)); + return self; +} + +static VALUE +rg_modify_text(VALUE self, VALUE state, VALUE color) +{ + gtk_widget_modify_text(_SELF(self), RVAL2GTKSTATETYPE(state), + RVAL2GDKCOLOR(color)); + return self; +} + +static VALUE +rg_modify_base(VALUE self, VALUE state, VALUE color) +{ + gtk_widget_modify_base(_SELF(self), RVAL2GTKSTATETYPE(state), + RVAL2GDKCOLOR(color)); + return self; +} + +static VALUE +rg_modify_font(VALUE self, VALUE font_desc) +{ + gtk_widget_modify_font(_SELF(self), + (PangoFontDescription*)RVAL2BOXED(font_desc, PANGO_TYPE_FONT_DESCRIPTION)); + return self; +} + +#if GTK_CHECK_VERSION(2,12,0) +static VALUE +rg_modify_cursor(VALUE self, VALUE primary, VALUE seconday) +{ + gtk_widget_modify_cursor(_SELF(self), + RVAL2BOXED(primary, GDK_TYPE_COLOR), + RVAL2BOXED(seconday, GDK_TYPE_COLOR)); + return self; +} +#endif + +static VALUE +rg_create_pango_context(VALUE self) +{ + return GOBJ2RVALU(gtk_widget_create_pango_context(_SELF(self))); +} + +static VALUE +rg_pango_context(VALUE self) +{ + return GOBJ2RVAL(gtk_widget_get_pango_context(_SELF(self))); +} + +static VALUE +rg_create_pango_layout(int argc, VALUE *argv, VALUE self) +{ + VALUE text; + rb_scan_args(argc, argv, "01", &text); + return GOBJ2RVALU(gtk_widget_create_pango_layout(_SELF(self), RVAL2CSTR_ACCEPT_NIL(text))); +} + +static VALUE +rg_render_icon(int argc, VALUE *argv, VALUE self) +{ + VALUE stock_id, size, detail; + rb_scan_args(argc, argv, "21", &stock_id, &size, &detail); + return GOBJ2RVALU(gtk_widget_render_icon(_SELF(self), rb_id2name(SYM2ID(stock_id)), + RVAL2GENUM(size, GTK_TYPE_ICON_SIZE), + RVAL2CSTR_ACCEPT_NIL(detail))); +} + +static VALUE +rg_s_pop_composite_child(VALUE self) +{ + gtk_widget_pop_composite_child(); + return self; +} + +static VALUE +rg_s_push_composite_child(VALUE self) +{ + gtk_widget_push_composite_child(); + return self; +} + +static VALUE +rg_queue_draw_area(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height) +{ + gtk_widget_queue_draw_area(_SELF(self), NUM2INT(x), NUM2INT(y), + NUM2INT(width), NUM2INT(height)); + return self; +} + +static VALUE +rg_reset_shapes(VALUE self) +{ + gtk_widget_reset_shapes(_SELF(self)); + return self; +} + +static VALUE +rg_set_redraw_on_allocate(VALUE self, VALUE redraw_on_allocate) +{ + gtk_widget_set_redraw_on_allocate(_SELF(self), RVAL2CBOOL(redraw_on_allocate)); + return self; +} + +static VALUE +rg_set_composite_name(VALUE self, VALUE name) +{ + gtk_widget_set_composite_name(_SELF(self), RVAL2CSTR(name)); + return self; +} + +static VALUE +rg_set_scroll_adjustments(VALUE self, VALUE h, VALUE v) +{ + return CBOOL2RVAL(gtk_widget_set_scroll_adjustments(_SELF(self), + GTK_ADJUSTMENT(_SELF(h)), + GTK_ADJUSTMENT(_SELF(v)))); +} + +static VALUE +rg_mnemonic_activate(VALUE self, VALUE group_cycling) +{ + return CBOOL2RVAL(gtk_widget_mnemonic_activate(_SELF(self), RVAL2CBOOL(group_cycling))); +} + +/* + * Gtk::Widget.install_style_property(...) do |spec, str| + * #parse str + * new_val = .... # parse value from string. + * new_val # return new_val or nil if you can't convert the value. + * end + */ +static gboolean +rc_property_parser(const GParamSpec *pspec, const GString *rc_string, GValue *property_value) +{ + VALUE spec = GOBJ2RVAL((gpointer)pspec); + VALUE func = rb_hash_aref(style_prop_func_table, spec); + VALUE ret = rb_funcall(func, id_call, 2, spec, CSTR2RVAL(rc_string->str)); + if (NIL_P(ret)) { + return FALSE; + } else if (RVAL2CBOOL(ret)){ + rbgobj_rvalue_to_gvalue(ret, property_value); + return TRUE; + } else { + rb_raise(rb_eArgError, "Gtk::Widget#install_style_property() block should return new value or nil"); + } +} + +static VALUE +rg_s_install_style_property(VALUE self, VALUE spec) +{ + const RGObjClassInfo* cinfo = rbgobj_lookup_class(self); + GtkWidgetClass* gclass; + GParamSpec* pspec = G_PARAM_SPEC(RVAL2GOBJ(spec)); + + if (cinfo->klass != self) + rb_raise(rb_eTypeError, "%s isn't registered class", + rb_class2name(self)); + + gclass = (GtkWidgetClass *)g_type_class_ref(cinfo->gtype); + if (rb_block_given_p()){ + VALUE func = rb_block_proc(); + rb_hash_aset(style_prop_func_table, spec, func); + gtk_widget_class_install_style_property_parser(gclass, pspec, + (GtkRcPropertyParser)rc_property_parser); + } else { + gtk_widget_class_install_style_property(gclass, pspec); + } + return self; +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_s_style_property(VALUE self, VALUE property_name) +{ + GtkWidgetClass* oclass; + const char* name; + GParamSpec* prop; + VALUE result; + + if (SYMBOL_P(property_name)) { + name = rb_id2name(SYM2ID(property_name)); + } else { + name = RVAL2CSTR(property_name); + } + + oclass = (GtkWidgetClass*)g_type_class_ref(CLASS2GTYPE(self)); + + prop = gtk_widget_class_find_style_property(oclass, name); + if (!prop){ + g_type_class_unref(oclass); + rb_raise(rb_eval_string("GLib::NoPropertyError"), "no such property: %s", name); + } + + result = GOBJ2RVAL(prop); + g_type_class_unref(oclass); + return result; +} + +static VALUE +rg_s_style_properties(int argc, VALUE *argv, VALUE self) +{ + GtkWidgetClass* oclass = g_type_class_ref(CLASS2GTYPE(self)); + guint n_properties; + GParamSpec** props; + VALUE inherited_too; + VALUE ary; + guint i; + + if (rb_scan_args(argc, argv, "01", &inherited_too) == 0) + inherited_too = Qtrue; + + props = gtk_widget_class_list_style_properties(oclass, &n_properties); + + ary = rb_ary_new(); + for (i = 0; i < n_properties; i++){ + if (RVAL2CBOOL(inherited_too) + || GTYPE2CLASS(props[i]->owner_type) == self) + rb_ary_push(ary, CSTR2RVAL(props[i]->name)); + } + + g_free(props); + g_type_class_unref(oclass); + return ary; +} +#endif + +static VALUE +rg_region_intersect(VALUE self, VALUE region) +{ + return BOXED2RVAL(gtk_widget_region_intersect(_SELF(self), + (GdkRegion*)RVAL2BOXED(region, GDK_TYPE_REGION)), + GDK_TYPE_REGION); +} + +static VALUE +rg_send_expose(VALUE self, VALUE event) +{ + return INT2NUM(gtk_widget_send_expose(_SELF(self), RVAL2GEV(event))); +} + +/* They are needless method for ruby. +void gtk_widget_style_get (GtkWidget *widget, + const gchar *first_property_name, + ...); +void gtk_widget_style_get_valist (GtkWidget *widget, + const gchar *first_property_name, + va_list var_args); +*/ + +static VALUE +rg_style_get_property(VALUE self, VALUE prop_name) +{ + GParamSpec* pspec = NULL; + const char* name; + + if (SYMBOL_P(prop_name)) { + name = rb_id2name(SYM2ID(prop_name)); + } else { + name = RVAL2CSTR(prop_name); + } +#if GTK_CHECK_VERSION(2,2,0) + pspec = gtk_widget_class_find_style_property((GtkWidgetClass*)g_type_class_ref(RVAL2GTYPE(self)), name); +#endif + if (!pspec) + rb_raise(rb_eval_string("GLib::NoPropertyError"), "No such property: %s", name); + else { + // FIXME: use rb_ensure to call g_value_unset() + GValue gval = G_VALUE_INIT; + VALUE ret; + g_value_init(&gval, G_PARAM_SPEC_VALUE_TYPE(pspec)); + gtk_widget_style_get_property(GTK_WIDGET(RVAL2GOBJ(self)), name, &gval); + ret = GVAL2RVAL(&gval); + g_value_unset(&gval); + return ret; + } +} + +static VALUE +rg_accessible(VALUE self) +{ + return GOBJ2RVAL(gtk_widget_get_accessible(_SELF(self))); +} + +static VALUE +rg_child_focus(VALUE self, VALUE direction) +{ + return CBOOL2RVAL(gtk_widget_child_focus(_SELF(self), RVAL2GENUM(direction, GTK_TYPE_DIRECTION_TYPE))); +} + +#if GTK_CHECK_VERSION(2,12,0) +static VALUE +rg_error_bell(VALUE self) +{ + gtk_widget_error_bell(_SELF(self)); + return self; +} + +static VALUE +rg_keynav_failed(VALUE self, VALUE direction) +{ + return CBOOL2RVAL(gtk_widget_keynav_failed(_SELF(self), RVAL2GENUM(direction, GTK_TYPE_DIRECTION_TYPE))); +} +#endif + +static VALUE +rg_child_notify(VALUE self, VALUE child_property) +{ + gtk_widget_child_notify(_SELF(self), RVAL2CSTR(child_property)); + return self; +} + +static VALUE +rg_freeze_child_notify(VALUE self) +{ + gtk_widget_freeze_child_notify(_SELF(self)); + return self; +} + +static VALUE +rg_child_visible_p(VALUE self) +{ + return CBOOL2RVAL(gtk_widget_get_child_visible(_SELF(self))); +} + +static VALUE +rg_settings(VALUE self) +{ + return GOBJ2RVAL(gtk_widget_get_settings(_SELF(self))); +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_get_clipboard(VALUE self, VALUE selection) +{ + return CLIPBOARD2RVAL(gtk_widget_get_clipboard(_SELF(self), RVAL2ATOM(selection))); +} + +static VALUE +rg_display(VALUE self) +{ + return GOBJ2RVAL(gtk_widget_get_display(_SELF(self))); +} + +static VALUE +rg_root_window(VALUE self) +{ + return GOBJ2RVAL(gtk_widget_get_root_window(_SELF(self))); +} + +static VALUE +rg_screen(VALUE self) +{ + return GOBJ2RVAL(gtk_widget_get_screen(_SELF(self))); +} + +static VALUE +rg_has_screen_p(VALUE self) +{ + return CBOOL2RVAL(gtk_widget_has_screen(_SELF(self))); +} +#endif + +/* + Note this method is not gtk_widget_size_request() +*/ +static VALUE +rg_get_size_request(VALUE self) +{ + gint width, height; + gtk_widget_get_size_request(_SELF(self), &width, &height); + return rb_ary_new3(2, INT2NUM(width), INT2NUM(height)); +} + +static VALUE +rg_set_child_visible(VALUE self, VALUE is_visible) +{ + gtk_widget_set_child_visible(_SELF(self), RVAL2CBOOL(is_visible)); + return self; +} + +static VALUE +rg_set_size_request(VALUE self, VALUE width, VALUE height) +{ + gtk_widget_set_size_request(_SELF(self), NUM2INT(width), NUM2INT(height)); + return self; +} + +static VALUE +rg_thaw_child_notify(VALUE self) +{ + gtk_widget_thaw_child_notify(_SELF(self)); + return self; +} + +#if GTK_CHECK_VERSION(2,4,0) + +static VALUE +rg_mnemonic_labels(VALUE self) +{ + return GLIST2ARYF(gtk_widget_list_mnemonic_labels(_SELF(self))); +} + +static VALUE +rg_add_mnemonic_label(VALUE self, VALUE label) +{ + gtk_widget_add_mnemonic_label(_SELF(self), GTK_WIDGET(RVAL2GOBJ(label))); + return self; +} + +static VALUE +rg_remove_mnemonic_label(VALUE self, VALUE label) +{ + gtk_widget_remove_mnemonic_label(_SELF(self), GTK_WIDGET(RVAL2GOBJ(label))); + return self; +} +#endif + +#if GTK_CHECK_VERSION(2,12,0) +static VALUE +rg_set_tooltip_window(VALUE self, VALUE custom_window) +{ + gtk_widget_set_tooltip_window(_SELF(self), GTK_WINDOW(RVAL2GOBJ(custom_window))); + return self; +} + +static VALUE +rg_tooltip_window(VALUE self) +{ + return GOBJ2RVAL(gtk_widget_get_tooltip_window(_SELF(self))); +} + +static VALUE +rg_trigger_tooltip_query(VALUE self) +{ + gtk_widget_trigger_tooltip_query(_SELF(self)); + return self; +} + +#endif + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_action(VALUE self) +{ + return GOBJ2RVAL(gtk_widget_get_action(_SELF(self))); +} + +static VALUE +rg_composited_p(VALUE self) +{ + return CBOOL2RVAL(gtk_widget_is_composited(_SELF(self))); +} + +static VALUE +rg_window(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->window); +} +#endif + +static VALUE +rg_set_window(VALUE self, VALUE window) +{ +#if GTK_CHECK_VERSION(2,18,0) + gtk_widget_set_window(_SELF(self), GDK_WINDOW(RVAL2GOBJ(window))); +#else + _SELF(self)->window = RVAL2GOBJ(window); +#endif + return self; +} + +#define DEFINE_IS_WIDGET(STATE) \ +static VALUE \ +widget_ ## STATE (VALUE self) \ +{ \ + return( GTK_WIDGET_ ## STATE (_SELF(self))? Qtrue: Qfalse ); \ +} +DEFINE_IS_WIDGET(TOPLEVEL); +DEFINE_IS_WIDGET(NO_WINDOW); +DEFINE_IS_WIDGET(REALIZED); +DEFINE_IS_WIDGET(MAPPED); +/*DEFINE_IS_WIDGET(VISIBLE); VISIBLE is defined as property*/ +DEFINE_IS_WIDGET(DRAWABLE); +DEFINE_IS_WIDGET(PARENT_SENSITIVE); +DEFINE_IS_WIDGET(IS_SENSITIVE); +DEFINE_IS_WIDGET(HAS_GRAB); +DEFINE_IS_WIDGET(RC_STYLE); + +static VALUE +rg_allocation(VALUE self) +{ + return BOXED2RVAL(&(_SELF(self)->allocation), GTK_TYPE_ALLOCATION); +} + +static VALUE +rg_set_allocation(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h) +{ + GtkAllocation *a = &(_SELF(self)->allocation); + a->x = NUM2INT(x); + a->y = NUM2INT(y); + a->width = NUM2INT(w); + a->height = NUM2INT(h); + return self; +} + +static VALUE +rg_requisition(VALUE self) +{ + GtkRequisition req = _SELF(self)->requisition; + return rb_ary_new3(2, INT2NUM(req.width), INT2NUM(req.height)); +} + +static VALUE +rg_set_requisition(VALUE self, VALUE w, VALUE h) +{ + GtkRequisition *r = &(_SELF(self)->requisition); + r->width = NUM2INT(w); + r->height = NUM2INT(h); + return self; +} + +static VALUE +rg_state(VALUE self) +{ + return GENUM2RVAL(_SELF(self)->state, GTK_TYPE_STATE_TYPE); +} + +static VALUE +rg_saved_state(VALUE self) +{ + return GENUM2RVAL(_SELF(self)->saved_state, GTK_TYPE_STATE_TYPE); +} + +static VALUE +widget_signal_size_request(G_GNUC_UNUSED guint num, const GValue *values) +{ + GtkRequisition* req = (GtkRequisition*)g_value_get_boxed(&values[1]); + return rb_ary_new3(2, GVAL2RVAL(&values[0]), + rb_ary_new3(2, INT2NUM(req->width), INT2NUM(req->height))); +} +static VALUE +widget_signal_size_allocate(G_GNUC_UNUSED guint num, const GValue *values) +{ + GtkAllocation* alloc = (GtkAllocation*)g_value_get_boxed(&values[1]); + return rb_ary_new3(2, GVAL2RVAL(&values[0]), BOXED2RVAL(alloc, GTK_TYPE_ALLOCATION)); +} + +void +Init_gtk_widget(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_WIDGET, "Widget", mGtk); + + rb_global_variable(&style_prop_func_table); + style_prop_func_table = rb_hash_new(); + + /* + * instance methods + */ + RG_DEF_METHOD(flags, 0); + RG_DEF_METHOD(set_flags, 1); + RG_DEF_METHOD(unset_flags, 1); + RG_DEF_METHOD(unparent, 0); + RG_DEF_METHOD(show, 0); + RG_DEF_METHOD(show_now, 0); + RG_DEF_METHOD(hide, 0); + RG_DEF_METHOD(show_all, 0); + RG_DEF_METHOD(hide_all, 0); + RG_DEF_METHOD(map, 0); + RG_DEF_METHOD(unmap, 0); + RG_DEF_METHOD(realize, 0); + RG_DEF_METHOD(unrealize, 0); + RG_DEF_METHOD(queue_draw, 0); + RG_DEF_METHOD(queue_resize, 0); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(queue_resize_no_redraw, 0); +#endif + RG_DEF_METHOD(size_request, 0); + RG_DEF_METHOD(child_requisition, 0); + RG_DEF_METHOD(size_allocate, 1); + RG_DEF_METHOD(add_accelerator, 5); + RG_DEF_METHOD(remove_accelerator, 3); + RG_DEF_METHOD(set_accel_path, 2); + RG_DEF_METHOD(accel_closures, 0); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD_P(can_activate_accel, 1); +#endif + RG_DEF_METHOD(event, 1); + RG_DEF_METHOD(activate, 0); + RG_DEF_METHOD(reparent, 1); + RG_DEF_SMETHOD(install_style_property, 1); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_SMETHOD(style_property, 1); + RG_DEF_SMETHOD(style_properties, -1); +#endif + RG_DEF_METHOD(intersect, 1); + RG_DEF_METHOD(grab_default, 0); + RG_DEF_METHOD(set_state, 1); + RG_DEF_METHOD(set_parent_window, 1); + RG_DEF_METHOD(parent_window, 0); + RG_DEF_METHOD(add_events, 1); + RG_DEF_METHOD(toplevel, 0); + RG_DEF_METHOD(get_ancestor, 1); + RG_DEF_METHOD(colormap, 0); + RG_DEF_METHOD(set_colormap, 1); + RG_DEF_METHOD(visual, 0); + RG_DEF_METHOD(pointer, 0); + RG_DEF_METHOD_P(ancestor, 1); + RG_DEF_METHOD(translate_coordinates, 3); + RG_DEF_METHOD(hide_on_delete, 0); + RG_DEF_METHOD(ensure_style, 0); + RG_DEF_METHOD(reset_rc_styles, 0); + RG_DEF_METHOD(set_direction, 1); + RG_DEF_METHOD(direction, 0); + RG_DEF_METHOD(shape_combine_mask, 3); +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD(input_shape_combine_mask, 3); +#endif + RG_DEF_METHOD(path, 0); + RG_DEF_METHOD(class_path, 0); + RG_DEF_METHOD(composite_name, 0); + RG_DEF_METHOD(modify_style, 1); + RG_DEF_METHOD(modifier_style, 0); + RG_DEF_METHOD(modify_fg, 2); + RG_DEF_METHOD(modify_bg, 2); + RG_DEF_METHOD(modify_text, 2); + RG_DEF_METHOD(modify_base, 2); + RG_DEF_METHOD(modify_font, 1); +#if GTK_CHECK_VERSION(2,12,0) + RG_DEF_METHOD(modify_cursor, 2); +#endif + RG_DEF_METHOD(create_pango_context, 0); + RG_DEF_METHOD(pango_context, 0); + RG_DEF_METHOD(create_pango_layout, -1); + RG_DEF_METHOD(render_icon, -1); + RG_DEF_METHOD(queue_draw_area, 4); + RG_DEF_METHOD(reset_shapes, 0); + RG_DEF_METHOD(set_redraw_on_allocate, 1); + RG_DEF_METHOD(set_composite_name, 1); + RG_DEF_METHOD(set_scroll_adjustments, 2); + /* for backward compatibility. */ + RG_DEF_ALIAS("set_scroll_adjustment", "set_scroll_adjustments"); + RG_DEF_METHOD(mnemonic_activate, 1); + RG_DEF_METHOD(region_intersect, 1); + RG_DEF_METHOD(send_expose, 1); + RG_DEF_METHOD(style_get_property, 1); + RG_DEF_METHOD(accessible, 0); + RG_DEF_METHOD(child_focus, 1); +#if GTK_CHECK_VERSION(2,12,0) + RG_DEF_METHOD(error_bell, 0); + RG_DEF_METHOD(keynav_failed, 0); +#endif + RG_DEF_METHOD(child_notify, 1); + RG_DEF_METHOD(freeze_child_notify, 0); + RG_DEF_METHOD_P(child_visible, 0); + RG_DEF_METHOD(settings, 0); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(get_clipboard, 1); + RG_DEF_METHOD(display, 0); + RG_DEF_METHOD(root_window, 0); + RG_DEF_METHOD(screen, 0); + RG_DEF_METHOD_P(has_screen, 0); +#endif + RG_DEF_METHOD(set_child_visible, 1); + RG_DEF_METHOD(get_size_request, 0); + RG_DEF_METHOD(set_size_request, 2); + RG_DEF_METHOD(thaw_child_notify, 0); +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(mnemonic_labels, 0); + RG_DEF_METHOD(add_mnemonic_label, 1); + RG_DEF_METHOD(remove_mnemonic_label, 1); +#endif +#if GTK_CHECK_VERSION(2,12,0) + RG_DEF_METHOD(set_tooltip_window, 1); + RG_DEF_METHOD(tooltip_window, 0); + RG_DEF_METHOD(trigger_tooltip_query, 0); +#endif +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD(action, 0); + RG_DEF_METHOD_P(composited, 0); + RG_DEF_METHOD(window, 0); +#endif + RG_DEF_METHOD(set_window, 1); + RG_DEF_METHOD(allocation, 0); + RG_DEF_METHOD(set_allocation, 4); + RG_DEF_METHOD(requisition, 0); + RG_DEF_METHOD(set_requisition, 2); + RG_DEF_METHOD(state, 0); + RG_DEF_METHOD(saved_state, 0); + + rb_define_method(RG_TARGET_NAMESPACE, "toplevel?", widget_TOPLEVEL, 0); + rb_define_method(RG_TARGET_NAMESPACE, "no_window?", widget_NO_WINDOW, 0); + rb_define_method(RG_TARGET_NAMESPACE, "realized?", widget_REALIZED, 0); + rb_define_method(RG_TARGET_NAMESPACE, "mapped?", widget_MAPPED, 0); + rb_define_method(RG_TARGET_NAMESPACE, "drawable?", widget_DRAWABLE, 0); + rb_define_method(RG_TARGET_NAMESPACE, "parent_sensitive?", widget_PARENT_SENSITIVE, 0); + /* This method's name avoid to sensitive? of a property variables. */ + rb_define_method(RG_TARGET_NAMESPACE, "sensitive_with_parent?", widget_IS_SENSITIVE, 0); + rb_define_method(RG_TARGET_NAMESPACE, "has_grab?", widget_HAS_GRAB, 0); + rb_define_method(RG_TARGET_NAMESPACE, "rc_style?", widget_RC_STYLE, 0); + + /* + * singleton methods + */ + RG_DEF_SMETHOD(push_colormap, 1); + RG_DEF_SMETHOD(pop_colormap, 0); + RG_DEF_SMETHOD(set_default_colormap, 1); + RG_DEF_SMETHOD(default_style, 0); + RG_DEF_SMETHOD(default_colormap, 0); + RG_DEF_SMETHOD(default_visual, 0); + RG_DEF_SMETHOD(set_default_direction, 1); + RG_DEF_SMETHOD(default_direction, 0); + RG_DEF_SMETHOD(pop_composite_child, 0); + RG_DEF_SMETHOD(push_composite_child, 0); + + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + + /* + * constants + */ + /* GtkWidgetFlags */ + G_DEF_CLASS(GTK_TYPE_WIDGET_FLAGS, "Flags", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_WIDGET_FLAGS, "GTK_"); + + /* GtkWidgetHelpType */ + G_DEF_CLASS(GTK_TYPE_WIDGET_HELP_TYPE, "HelpType", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_WIDGET_HELP_TYPE, "GTK_WIDGET_"); + + /* GtkTextDirection */ + G_DEF_CLASS(GTK_TYPE_TEXT_DIRECTION, "TextDirection", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_TEXT_DIRECTION, "GTK_"); + + /* Special signals */ + G_DEF_SIGNAL_FUNC(RG_TARGET_NAMESPACE, "size-request", (GValToRValSignalFunc)widget_signal_size_request); + G_DEF_SIGNAL_FUNC(RG_TARGET_NAMESPACE, "size-allocate", (GValToRValSignalFunc)widget_signal_size_allocate); + +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkwindow.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkwindow.c new file mode 100644 index 0000000..fe71ddb --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkwindow.c @@ -0,0 +1,633 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2002-2011 Ruby-GNOME2 Project Team + * Copyright (C) 1998-2000 Yukihiro Matsumoto, + * Daisuke Kanda, + * Hiroshi Igarashi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cWindow +#define _SELF(s) (GTK_WINDOW(RVAL2GOBJ(s))) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE arg; + GtkWindowType tp = GTK_WINDOW_TOPLEVEL; + const gchar *title = NULL; + GtkWidget* window = NULL; + + if (rb_scan_args(argc, argv, "01", &arg) == 1) { + if (TYPE(arg) == T_STRING) { + StringValue(arg); + title = RVAL2CSTR(arg); + } else { + tp = RVAL2GENUM(arg, GTK_TYPE_WINDOW_TYPE); + } + } + window = gtk_window_new(tp); + + if (title != NULL) + gtk_window_set_title(GTK_WINDOW(window), title); + + RBGTK_INITIALIZE(self, window); + return Qnil; +} + +static VALUE +rg_set_wmclass(VALUE self, VALUE wmclass_name, VALUE wmclass_class) +{ + gtk_window_set_wmclass(_SELF(self), + NIL_P(wmclass_name)?NULL:RVAL2CSTR(wmclass_name), + NIL_P(wmclass_class)?NULL:RVAL2CSTR(wmclass_class)); + return self; +} + +static VALUE +rg_add_accel_group(VALUE self, VALUE accel) +{ + gtk_window_add_accel_group(_SELF(self), + GTK_ACCEL_GROUP(RVAL2GOBJ(accel))); + G_CHILD_ADD(self, accel); + return self; +} + +static VALUE +rg_remove_accel_group(VALUE self, VALUE accel) +{ + gtk_window_remove_accel_group(_SELF(self), + GTK_ACCEL_GROUP(RVAL2GOBJ(accel))); + G_CHILD_REMOVE(self, accel); + return self; +} + +static VALUE +gwin_activate_focus(VALUE self) +{ + return CBOOL2RVAL(gtk_window_activate_focus(_SELF(self))); +} + +static VALUE +gwin_activate_default(VALUE self) +{ + return CBOOL2RVAL(gtk_window_activate_default(_SELF(self))); +} + +static VALUE +rg_active_focus(VALUE self) +{ + rb_warning("Gtk::Window#active_focus is deprecated. Use Gtk::Window#activate_focus"); + gtk_window_activate_focus(_SELF(self)); + return self; +} + +static VALUE +rg_active_default(VALUE self) +{ + rb_warning("Gtk::Window#active_default is deprecated. Use Gtk::Window#activate_default"); + gtk_window_activate_default(_SELF(self)); + return self; +} + +static VALUE +rg_set_default_size(VALUE self, VALUE w, VALUE h) +{ + gtk_window_set_default_size(_SELF(self), + NUM2INT(w), NUM2INT(h)); + return self; +} + +static VALUE +rg_set_geometry_hints(VALUE self, VALUE geometry_widget, VALUE geometry, VALUE geom_mask) +{ + gtk_window_set_geometry_hints(_SELF(self), + GTK_WIDGET(RVAL2GOBJ(geometry_widget)), + (GdkGeometry*)RVAL2BOXED(geometry, GDK_TYPE_GEOMETRY), + RVAL2GFLAGS(geom_mask, GDK_TYPE_WINDOW_HINTS)); + return self; +} + +static VALUE +rg_s_toplevels(G_GNUC_UNUSED VALUE self) +{ + GList* list = gtk_window_list_toplevels(); + VALUE ret = GLIST2ARY(list); + g_list_foreach(list, (GFunc)g_object_ref, NULL); + g_list_free(list); + return ret; +} + +static VALUE +rg_add_mnemonic(VALUE self, VALUE keyval, VALUE target) +{ + gtk_window_add_mnemonic(_SELF(self), NUM2INT(keyval), GTK_WIDGET(RVAL2GOBJ(target))); + return self; +} + +static VALUE +rg_remove_mnemonic(VALUE self, VALUE keyval, VALUE target) +{ + gtk_window_remove_mnemonic(_SELF(self), NUM2INT(keyval), GTK_WIDGET(RVAL2GOBJ(target))); + return self; +} + +static VALUE +rg_mnemonic_activate(VALUE self, VALUE keyval, VALUE modifier) +{ + return CBOOL2RVAL(gtk_window_mnemonic_activate(_SELF(self), + NUM2INT(keyval), + RVAL2GFLAGS(modifier, GDK_TYPE_MODIFIER_TYPE))); +} + +static VALUE +rg_focus(VALUE self) +{ + return GOBJ2RVAL(gtk_window_get_focus(_SELF(self))); +} + +static VALUE +rg_set_focus(VALUE self, VALUE win) +{ + gtk_window_set_focus(_SELF(self), + NIL_P(win) ? NULL : GTK_WIDGET(RVAL2GOBJ(win))); + return self; +} + +static VALUE +rg_set_default(VALUE self, VALUE win) +{ + gtk_window_set_default(_SELF(self), + NIL_P(win) ? NULL : GTK_WIDGET(RVAL2GOBJ(win))); + return self; +} + +#if GTK_CHECK_VERSION(2,8,0) +static VALUE +rg_present(int argc, VALUE *argv, VALUE self) +{ + VALUE timestamp; + if (rb_scan_args(argc, argv, "01", ×tamp) == 1) { + gtk_window_present_with_time(_SELF(self), NUM2UINT(timestamp)); + } else { + gtk_window_present(_SELF(self)); + } + return self; +} +#else +static VALUE +gwin_present(VALUE self) +{ + gtk_window_present(_SELF(self)); + return self; +} +#endif + +static VALUE +rg_iconify(VALUE self) +{ + gtk_window_iconify(_SELF(self)); + return self; +} + +static VALUE +rg_deiconify(VALUE self) +{ + gtk_window_deiconify(_SELF(self)); + return self; +} + +static VALUE +rg_stick(VALUE self) +{ + gtk_window_stick(_SELF(self)); + return self; +} + +static VALUE +rg_unstick(VALUE self) +{ + gtk_window_unstick(_SELF(self)); + return self; +} + +static VALUE +rg_maximize(VALUE self) +{ + gtk_window_maximize(_SELF(self)); + return self; +} + +static VALUE +rg_unmaximize(VALUE self) +{ + gtk_window_unmaximize(_SELF(self)); + return self; +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_fullscreen(VALUE self) +{ + gtk_window_fullscreen(_SELF(self)); + return self; +} +static VALUE +rg_unfullscreen(VALUE self) +{ + gtk_window_unfullscreen(_SELF(self)); + return self; +} +#endif +#if GTK_CHECK_VERSION(2,4,0) +static VALUE +rg_set_keep_above(VALUE self, VALUE setting) +{ + gtk_window_set_keep_above(_SELF(self), RVAL2CBOOL(setting)); + return self; +} +static VALUE +rg_set_keep_below(VALUE self, VALUE setting) +{ + gtk_window_set_keep_below(_SELF(self), RVAL2CBOOL(setting)); + return self; +} +#endif + +static VALUE +rg_begin_resize_drag(VALUE self, VALUE edge, VALUE button, VALUE root_x, VALUE root_y, VALUE timestamp) +{ + gtk_window_begin_resize_drag(_SELF(self), RVAL2GENUM(edge, GDK_TYPE_WINDOW_EDGE), + NUM2INT(button), NUM2INT(root_x), + NUM2INT(root_y), NUM2UINT(timestamp)); + return self; +} + +static VALUE +rg_begin_move_drag(VALUE self, VALUE button, VALUE root_x, VALUE root_y, VALUE timestamp) +{ + gtk_window_begin_move_drag(_SELF(self), + NUM2INT(button), NUM2INT(root_x), + NUM2INT(root_y), NUM2UINT(timestamp)); + return self; +} + +static VALUE +rg_set_frame_dimensions(VALUE self, VALUE left, VALUE top, VALUE right, VALUE bottom) +{ + gtk_window_set_frame_dimensions(_SELF(self), NUM2INT(left), + NUM2INT(top), NUM2INT(right), + NUM2INT(bottom)); + return self; +} + +static VALUE +rg_set_has_frame(VALUE self, VALUE setting) +{ + gtk_window_set_has_frame(_SELF(self), RVAL2CBOOL(setting)); + return self; +} + +static VALUE +rg_set_mnemonic_modifier(VALUE self, VALUE modifier) +{ + gtk_window_set_mnemonic_modifier(_SELF(self), + RVAL2GFLAGS(modifier, GDK_TYPE_MODIFIER_TYPE)); + return self; +} + +static VALUE +rg_s_default_icon_list(G_GNUC_UNUSED VALUE self) +{ + return GLIST2ARYF(gtk_window_get_default_icon_list()); +} + +static VALUE +rg_default_size(VALUE self) +{ + int width, height; + gtk_window_get_default_size(_SELF(self), &width, &height); + return rb_ary_new3(2, INT2NUM(width), INT2NUM(height)); +} + +static VALUE +rg_frame_dimensions(VALUE self) +{ + int left, top, right, bottom; + gtk_window_get_frame_dimensions(_SELF(self), &left, &top, &right, &bottom); + return rb_ary_new3(4, + INT2NUM(left), + INT2NUM(top), + INT2NUM(right), + INT2NUM(bottom)); +} + +static VALUE +rg_has_frame_p(VALUE self) +{ + return CBOOL2RVAL(gtk_window_get_has_frame(_SELF(self))); +} + +static VALUE +rg_icon_list(VALUE self) +{ + return GLIST2ARYF(gtk_window_get_icon_list(_SELF(self))); +} + +static VALUE +rg_mnemonic_modifier(VALUE self) +{ + return GFLAGS2RVAL(gtk_window_get_mnemonic_modifier(_SELF(self)), GDK_TYPE_MODIFIER_TYPE); +} + +static VALUE +rg_position(VALUE self) +{ + int root_x, root_y; + gtk_window_get_position(_SELF(self), &root_x, &root_y); + return rb_ary_new3(2, INT2NUM(root_x), INT2NUM(root_y)); +} + +static VALUE +rg_size(VALUE self) +{ + int width, height; + gtk_window_get_size(_SELF(self), &width, &height); + return rb_ary_new3(2, INT2NUM(width), INT2NUM(height)); +} + +#if GTK_CHECK_VERSION(2,10,0) +static VALUE +rg_group(VALUE self) +{ + return GOBJ2RVAL(gtk_window_get_group(_SELF(self))); +} +#endif + +static VALUE +rg_move(VALUE self, VALUE x, VALUE y) +{ + gtk_window_move(_SELF(self), NUM2INT(x), NUM2INT(y)); + return self; +} + +static VALUE +rg_parse_geometry(VALUE self, VALUE geometry) +{ + return CBOOL2RVAL(gtk_window_parse_geometry(_SELF(self), RVAL2CSTR(geometry))); +} + +static VALUE +rg_reshow_with_initial_size(VALUE self) +{ + gtk_window_reshow_with_initial_size(_SELF(self)); + return self; +} + +static VALUE +rg_resize(VALUE self, VALUE width, VALUE height) +{ + gtk_window_resize(_SELF(self), NUM2INT(width), NUM2INT(height)); + return self; +} + +static VALUE +rg_s_set_default_icon_list(G_GNUC_UNUSED VALUE self, VALUE rblist) +{ + GList *list = RVAL2GDKPIXBUFGLIST(rblist); + + gtk_window_set_default_icon_list(list); + + g_list_free(list); + + return rblist; +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_s_set_default_icon(VALUE self, VALUE icon_or_filename) +{ + if (TYPE(icon_or_filename) == T_STRING){ + GError* err; + gboolean ret = gtk_window_set_default_icon_from_file(RVAL2CSTR(icon_or_filename), &err); + if (! ret) + RAISE_GERROR(err); + } else { +#if GTK_CHECK_VERSION(2,4,0) + gtk_window_set_default_icon(GDK_PIXBUF(RVAL2GOBJ(icon_or_filename))); +#else + rb_raise(rb_eArgError, "Invalid argument: %s, or you may need to use GTK+-2.4.x", + rb_class2name(CLASS_OF(icon_or_filename))); +#endif + } + return self; +} +#endif + +#if GTK_CHECK_VERSION(2,6,0) +static VALUE +rg_s_set_default_icon_name(VALUE self, VALUE name) +{ + gtk_window_set_default_icon_name(RVAL2CSTR(name)); + return self; +} +#endif + +static VALUE +gwin_set_icon(VALUE self, VALUE icon_or_filename) +{ + if (TYPE(icon_or_filename) == T_STRING){ +#if GTK_CHECK_VERSION(2,2,0) + GError* err; + gboolean ret = gtk_window_set_icon_from_file(_SELF(self), + RVAL2CSTR(icon_or_filename), &err); + if (! ret) + RAISE_GERROR(err); +#else + rb_raise(rb_eArgError, "Invalid argument: %s, or you may need to use GTK+-2.4.x", + rb_class2name(CLASS_OF(icon_or_filename))); +#endif + } else { + gtk_window_set_icon(_SELF(self), GDK_PIXBUF(RVAL2GOBJ(icon_or_filename))); + } + return self; +} + +static VALUE +rg_set_icon_list(VALUE self, VALUE rblist) +{ + GtkWindow *window = _SELF(self); + GList *list = RVAL2GDKPIXBUFGLIST(rblist); + + gtk_window_set_icon_list(window, list); + + g_list_free(list); + + /* TODO: Shouldn't we return self? */ + return rblist; +} + +#if GTK_CHECK_VERSION(2,2,0) +static VALUE +rg_s_set_auto_startup_notification(VALUE self, VALUE setting) +{ + gtk_window_set_auto_startup_notification(RVAL2CBOOL(setting)); + return self; +} +#endif + +/* They are not public methods. +static VALUE +rg_decorated_window_init(VALUE self) +{ + gtk_decorated_window_init(_SELF(self)); + return self; +} + +static VALUE +rg_decorated_window_calculate_frame_size(VALUE self) +{ + gtk_decorated_window_calculate_frame_size(_SELF(self)); + return self; +} + +static VALUE +rg_decorated_window_set_title(VALUE self, VALUE title) +{ + gtk_decorated_window_set_title(_SELF(self), RVAL2CSTR(title)); + return self; +} + +static VALUE +rg_decorated_window_move_resize_window(VALUE self) +{ + int x, y, width, height; + gtk_decorated_window_move_resize_window(_SELF(self), &x, &y, &width, &height); + return rb_ary_new3(4, INT2NUM(x), INT2NUM(y), INT2NUM(width), INT2NUM(height)); +} +*/ + +static void +mark_toplevels(G_GNUC_UNUSED void *_) +{ + GList* list = gtk_window_list_toplevels(); + GList* p; + for (p = list; p; p = g_list_next(p)) + rbgobj_gc_mark_instance(p->data); + g_list_free(list); +} + +void +Init_gtk_window(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_WINDOW, "Window", mGtk); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(set_wmclass, 2); + RG_DEF_METHOD(add_accel_group, 1); + RG_DEF_METHOD(remove_accel_group, 1); + /* active_(focus|default) are deprecated. Use activate_* instead. */ + RG_DEF_METHOD(active_focus, 0); + RG_DEF_METHOD(active_default, 0); + G_REPLACE_ACTION(RG_TARGET_NAMESPACE, "activate_focus", gwin_activate_focus, 0); + G_REPLACE_ACTION(RG_TARGET_NAMESPACE, "activate_default", gwin_activate_default, 0); + RG_DEF_METHOD(set_default_size, 2); + RG_DEF_METHOD(set_geometry_hints, 3); + RG_DEF_SMETHOD(toplevels, 0); + RG_DEF_METHOD(add_mnemonic, 2); + RG_DEF_METHOD(remove_mnemonic, 2); + RG_DEF_METHOD(mnemonic_activate, 2); + RG_DEF_METHOD(focus, 0); + RG_DEF_METHOD(set_focus, 1); + RG_DEF_METHOD(set_default, 1); +#if GTK_CHECK_VERSION(2,8,0) + RG_DEF_METHOD(present, -1); +#else + RG_DEF_METHOD(present, 0); +#endif + RG_DEF_METHOD(iconify, 0); + RG_DEF_METHOD(deiconify, 0); + RG_DEF_METHOD(stick, 0); + RG_DEF_METHOD(unstick, 0); + RG_DEF_METHOD(maximize, 0); + RG_DEF_METHOD(unmaximize, 0); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_METHOD(fullscreen, 0); + RG_DEF_METHOD(unfullscreen, 0); +#endif +#if GTK_CHECK_VERSION(2,4,0) + RG_DEF_METHOD(set_keep_above, 1); + RG_DEF_METHOD(set_keep_below, 1); +#endif + RG_DEF_METHOD(begin_resize_drag, 5); + RG_DEF_METHOD(begin_move_drag, 4); + RG_DEF_METHOD(set_frame_dimensions, 4); + RG_DEF_METHOD(set_mnemonic_modifier, 1); + RG_DEF_METHOD(default_size, 0); + RG_DEF_SMETHOD(default_icon_list, 0); + RG_DEF_METHOD(frame_dimensions, 0); + RG_DEF_METHOD(set_has_frame, 1); + RG_DEF_METHOD_P(has_frame, 0); + RG_DEF_METHOD(icon_list, 0); + RG_DEF_METHOD(mnemonic_modifier, 0); + RG_DEF_METHOD(position, 0); + RG_DEF_METHOD(size, 0); +#if GTK_CHECK_VERSION(2,10,0) + RG_DEF_METHOD(group, 0); +#endif + RG_DEF_METHOD(move, 2); + RG_DEF_METHOD(parse_geometry, 1); + RG_DEF_METHOD(reshow_with_initial_size, 0); + RG_DEF_METHOD(resize, 2); + RG_DEF_SMETHOD(set_default_icon_list, 1); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_SMETHOD(set_default_icon, 1); +#endif +#if GTK_CHECK_VERSION(2,6,0) + RG_DEF_SMETHOD(set_default_icon_name, 1); +#endif + G_REPLACE_SET_PROPERTY(RG_TARGET_NAMESPACE, "icon", gwin_set_icon, 1); + RG_DEF_METHOD(set_icon_list, 1); +#if GTK_CHECK_VERSION(2,2,0) + RG_DEF_SMETHOD(set_auto_startup_notification, 1); +#endif + +/* + RG_DEF_METHOD(decorated_window_init, 0); + RG_DEF_METHOD(decorated_window_calculate_frame_size, 0); + RG_DEF_METHOD(decorated_window_set_title, 1); + RG_DEF_METHOD(decorated_window_move_resize_window, 0); +*/ + G_DEF_SETTERS(RG_TARGET_NAMESPACE); + + /* GtkWindowPosition (from General constants) */ + G_DEF_CLASS(GTK_TYPE_WINDOW_POSITION, "Position", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_WINDOW_POSITION, "GTK_WIN_"); + + /* GtkWindowType (from General constants) */ + G_DEF_CLASS(GTK_TYPE_WINDOW_TYPE, "Type", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_WINDOW_TYPE, "GTK_WINDOW_"); + + { + static VALUE toplevels_marker; + toplevels_marker = + rb_data_object_alloc(rb_cData, NULL, mark_toplevels, NULL); + rb_global_variable(&toplevels_marker); + } +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkwindowgroup.c b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkwindowgroup.c new file mode 100644 index 0000000..53e652c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/ext/gtk2/rbgtkwindowgroup.c @@ -0,0 +1,56 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "global.h" + +#define RG_TARGET_NAMESPACE cWindowGroup + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, gtk_window_group_new()); + return Qnil; +} + +static VALUE +rg_add(VALUE self, VALUE window) +{ + gtk_window_group_add_window(GTK_WINDOW_GROUP(RVAL2GOBJ(self)), + GTK_WINDOW(RVAL2GOBJ(window))); + return self; +} + +static VALUE +rg_remove(VALUE self, VALUE window) +{ + gtk_window_group_remove_window(GTK_WINDOW_GROUP(RVAL2GOBJ(self)), + GTK_WINDOW(RVAL2GOBJ(window))); + return self; +} + +void +Init_gtk_windowgroup(VALUE mGtk) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_WINDOW_GROUP, "WindowGroup", mGtk); + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(add, 1); + RG_DEF_METHOD(remove, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/gtk2/extconf.rb b/lib/ruby-gtk2-2.0.2/gtk2/extconf.rb new file mode 100644 index 0000000..79f5640 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/extconf.rb @@ -0,0 +1,49 @@ +#!/usr/bin/env ruby + +require 'pathname' +require 'mkmf' +require 'rbconfig' +require 'fileutils' + +package = "gtk2" + +base_dir = Pathname(__FILE__).dirname.expand_path +ext_dir = base_dir + "ext" + package +mkmf_gnome2_dir = base_dir + 'lib' + +ruby = File.join(RbConfig::CONFIG['bindir'], + RbConfig::CONFIG['ruby_install_name'] + + RbConfig::CONFIG["EXEEXT"]) + +build_dir = Pathname("ext") + package +FileUtils.mkdir_p(build_dir.to_s) unless build_dir.exist? +extconf_rb_path = ext_dir + "extconf.rb" +system(ruby, "-C", build_dir.to_s, extconf_rb_path.to_s, *ARGV) || exit(false) + +create_makefile(package) +FileUtils.mv("Makefile", "Makefile.lib") + +File.open("Makefile", "w") do |makefile| + makefile.puts(<<-EOM) +all: + (cd ext/#{package} && $(MAKE)) + $(MAKE) -f Makefile.lib + +install: + (cd ext/#{package} && $(MAKE) install) + $(MAKE) -f Makefile.lib install + +site-install: + (cd ext/#{package} && $(MAKE) site-install) + $(MAKE) -f Makefile.lib site-install + +clean: + (cd ext/#{package} && $(MAKE) clean) + $(MAKE) -f Makefile.lib clean + +distclean: + (cd ext/#{package} && $(MAKE) distclean) + $(MAKE) -f Makefile.lib distclean + @rm -f Makefile.lib +EOM +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/lib/gtk2.rb b/lib/ruby-gtk2-2.0.2/gtk2/lib/gtk2.rb new file mode 100644 index 0000000..c8e09f5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/lib/gtk2.rb @@ -0,0 +1,13 @@ +#! /usr/bin/env ruby +=begin + gtk2.rb + + Copyright (c) 2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: gtk2.rb,v 1.9 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2/base' + +Gtk.init diff --git a/lib/ruby-gtk2-2.0.2/gtk2/lib/gtk2/base.rb b/lib/ruby-gtk2-2.0.2/gtk2/lib/gtk2/base.rb new file mode 100755 index 0000000..0b8d567 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/lib/gtk2/base.rb @@ -0,0 +1,105 @@ +#! /usr/bin/env ruby +=begin + gtk2/base.rb + + Copyright (c) 2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: base.rb,v 1.6 2007/08/13 11:09:22 ktou Exp $ +=end + + +require 'glib2' +require 'atk' +require 'pango' +require 'gdk_pixbuf2' + +base_dir = Pathname.new(__FILE__).dirname.dirname.dirname.expand_path +vendor_dir = base_dir + "vendor" + "local" +vendor_bin_dir = vendor_dir + "bin" +GLib.prepend_dll_path(vendor_bin_dir) +begin + major, minor, _ = RUBY_VERSION.split(/\./) + require "#{major}.#{minor}/gtk2.so" +rescue LoadError + require "gtk2.so" +end + +module Gdk + LOG_DOMAIN = "Gdk" +end + +if Gdk.cairo_available? + module Cairo + class Context + if method_defined?(:set_source_color) + alias_method :set_source_not_gdk_color, :set_source_color + def set_source_color(color) + if color.is_a?(Gdk::Color) + set_source_gdk_color(color) + else + set_source_not_gdk_color(color) + end + end + else + alias_method :set_source_color, :set_source_gdk_color + end + + def source_color=(color) + set_source_color(color) + color + end + end + end +end + + +module Gtk + LOG_DOMAIN = "Gtk" + + class Printer + def self.printers(wait = false) + printers = [] + self.each(wait) {|v| printers << v} + printers + end + end + + if check_version?(2, 12, 0) + class Builder + private + def canonical_handler_name(name) + name.gsub(/[-\s]+/, "_") + end + + def __connect_signals__(connector, object, signal_name, + handler_name, connect_object, flags) + handler_name = canonical_handler_name(handler_name) + if connect_object + handler = connect_object.method(handler_name) + else + handler = connector.call(handler_name) + end + unless handler + $stderr.puts("Undefined handler: #{handler_name}") if $DEBUG + return + end + + if flags.after? + signal_connect_method = :signal_connect_after + else + signal_connect_method = :signal_connect + end + + if handler.arity.zero? + object.send(signal_connect_method, signal_name) {handler.call} + else + object.send(signal_connect_method, signal_name, &handler) + end + end + end + end +end + +GLib::Log.set_log_domain(Gdk::LOG_DOMAIN) +GLib::Log.set_log_domain(Gtk::LOG_DOMAIN) diff --git a/lib/ruby-gtk2-2.0.2/gtk2/patches/gtk+-2.24.14-add-missing-exeext.diff b/lib/ruby-gtk2-2.0.2/gtk2/patches/gtk+-2.24.14-add-missing-exeext.diff new file mode 100644 index 0000000..b179d80 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/patches/gtk+-2.24.14-add-missing-exeext.diff @@ -0,0 +1,33 @@ +--- gtk+-2.24.14/gtk/Makefile.am.orig 2012-08-25 08:38:09.000000000 +0900 ++++ gtk+-2.24.14/gtk/Makefile.am 2013-01-20 09:46:54.304458544 +0900 +@@ -1386,7 +1386,7 @@ + gtk_update_icon_cache_program = $(GTK_UPDATE_ICON_CACHE) + else + gtk_update_icon_cache_program = \ +- ./gtk-update-icon-cache ++ ./gtk-update-icon-cache$(EXEEXT) + endif + + gtkbuiltincache.h: @REBUILD@ stamp-icons +--- gtk+-2.24.14/modules/input/Makefile.am.orig 2011-08-16 11:30:52.000000000 +0900 ++++ gtk+-2.24.14/modules/input/Makefile.am 2013-01-20 09:47:21.819837211 +0900 +@@ -189,8 +189,8 @@ + @if $(RUN_QUERY_IMMODULES_TEST) ; then \ + echo $(mkinstalldirs) $(DESTDIR)$(sysconfdir)/gtk-2.0 ; \ + $(mkinstalldirs) $(DESTDIR)$(sysconfdir)/gtk-2.0 ; \ +- echo "$(top_builddir)/gtk/gtk-query-immodules-2.0 > $(DESTDIR)$(sysconfdir)/gtk-2.0/gtk.immodules" ; \ +- $(top_builddir)/gtk/gtk-query-immodules-2.0 > $(DESTDIR)$(sysconfdir)/gtk-2.0/gtk.immodules ; \ ++ echo "$(top_builddir)/gtk/gtk-query-immodules-2.0$(EXEEXT) > $(DESTDIR)$(sysconfdir)/gtk-2.0/gtk.immodules" ; \ ++ $(top_builddir)/gtk/gtk-query-immodules-2.0$(EXEEXT) > $(DESTDIR)$(sysconfdir)/gtk-2.0/gtk.immodules ; \ + else \ + echo "***" ; \ + echo "*** Warning: gtk.immodules not built" ; \ +@@ -238,7 +238,7 @@ + included-modules: $(noinst_LTLIBRARIES) + + gtk.immodules: Makefile.am $(module_LTLIBRARIES) +- $(top_builddir)/gtk/gtk-query-immodules-2.0 $(module_LTLIBRARIES) > gtk.immodules ++ $(top_builddir)/gtk/gtk-query-immodules-2.0$(EXEEXT) $(module_LTLIBRARIES) > gtk.immodules + + CLEANFILES = gtk.immodules + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/README b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/README new file mode 100644 index 0000000..416b053 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/README @@ -0,0 +1,7 @@ +gtk-demo for Ruby/GTK + +To run, do + + ruby main.rb + +in this directory. diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/alphatest.png b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/alphatest.png new file mode 100644 index 0000000..eb5885f Binary files /dev/null and b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/alphatest.png differ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/apple-red.png b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/apple-red.png new file mode 100644 index 0000000..b0a24e9 Binary files /dev/null and b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/apple-red.png differ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/appwindow.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/appwindow.rb new file mode 100644 index 0000000..7b84547 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/appwindow.rb @@ -0,0 +1,233 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: appwindow.rb,v 1.7 2005/03/05 15:01:16 mutoh Exp $ +=begin += Application main window + +Demonstrates a typical application window, with menubar, toolbar, statusbar. +=end + +require 'common' + +module Demo + class AppWindow < BasicWindow + def initialize + register_stock_icons + + ## Create toplevel window + super('Application Window') + + table = Gtk::Table.new(1, 4, false) + add(table) + + ## Create the menubar + accel_group = Gtk::AccelGroup.new + add_accel_group(accel_group) + + item_factory = Gtk::ItemFactory.new(Gtk::ItemFactory::TYPE_MENU_BAR, + '<main>', accel_group) + # create menu items + menuitem_cb = proc do |data, widget| + # TODO: Show item-factory's path to menu item + dialog = Gtk::MessageDialog.new(self, + Gtk::Dialog::DESTROY_WITH_PARENT, + Gtk::MessageDialog::INFO, + Gtk::MessageDialog::BUTTONS_CLOSE, + "You selected or toggled the menu item \"#{Gtk::ItemFactory.path_from_widget(widget)}\"") + + # Close dialog on user response + dialog.signal_connect('response') do |widget, data| + widget.destroy + end + + dialog.show + end + + menu_items = [ + ["/_File"], + ["/_File/_New", + "<StockItem>", "<control>N", Gtk::Stock::NEW, menuitem_cb], + ["/_File/_Open", + "<StockItem>", "<control>O", Gtk::Stock::OPEN, menuitem_cb], + ["/File/_Save", + "<StockItem>", "<control>S", Gtk::Stock::SAVE, menuitem_cb], + ["/File/Save _As...", + "<StockItem>", nil, Gtk::Stock::SAVE, menuitem_cb], + ["/File/sep1", + "<Separator>", nil, nil, menuitem_cb], + ["/File/Quit", + "<StockItem>", "<control>Q", Gtk::Stock::QUIT, menuitem_cb], + + ["/_Preferences"], + ["/_Preferences/_Color"], + ["/_Preferences/Color/_Red", + "<RadioItem>", nil, nil, menuitem_cb], + ["/_Preferences/Color/_Green", + "/Preferences/Color/Red", nil, nil, menuitem_cb], + ["/_Preferences/Color/_Blue", + "/Preferences/Color/Red", nil, nil, menuitem_cb], + + ["/Preferences/_Shape"], + ["/Preferences/Shape/_Square", + "<RadioItem>", nil, nil, menuitem_cb], + ["/Preferences/Shape/_Rectangle", + "/Preferences/Shape/Square", nil, nil, menuitem_cb], + ["/Preferences/Shape/_Oval", + "/Preferences/Shape/Square", nil, nil, menuitem_cb], + + # If you wanted this to be right justified you would use + # "<LastBranch>", not "<Branch>". Right justified help menu + # items are generally considered a bad idea now days. + ["/_Help"], + ["/Help/_About", "<Item>", nil, nil, Proc.new{about_cb}], + ] + item_factory.create_items(menu_items) + + table.attach(item_factory.get_widget('<main>'), + # X direction # Y direction + 0, 1, 0, 1, + Gtk::EXPAND | Gtk::FILL, 0, + 0, 0) + + ## Create the toolbar + toolbar = Gtk::Toolbar.new + # toolbar.set_toolbar_style(Gtk::Toolbar::BOTH) + toolbar.append(Gtk::Stock::OPEN, + "This is a demo button with an 'open' icon" + ) do toolbar_cb end + toolbar.append(Gtk::Stock::QUIT, + "This is a demo button with an 'quit' icon" + ) do toolbar_cb end + toolbar.append_space + toolbar.append(:demo_gtk_logo, + "This is a demo button with an 'gtk' icon" + ) do toolbar_cb end + table.attach(toolbar, + # X direction # Y direction + 0, 1, 1, 2, + Gtk::EXPAND | Gtk::FILL, 0, + 0, 0) + + ## Create document + sw = Gtk::ScrolledWindow.new + sw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) + sw.shadow_type = Gtk::SHADOW_IN + table.attach(sw, + # X direction # Y direction + 0, 1, 2, 3, + Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, + 0, 0) + + set_default_size(200, 200) + + contents = Gtk::TextView.new + sw.add(contents) + + ## Create statusbar + statusbar = Gtk::Statusbar.new + table.attach(statusbar, + # X direction # Y direction + 0, 1, 3, 4, + Gtk::EXPAND | Gtk::FILL, 0, + 0, 0) + + # Show text widget info in the statusbar + buffer = contents.buffer + buffer.signal_connect('changed') do |buffer| + update_statusbar(buffer, statusbar) + end + # cursor moved + buffer.signal_connect('mark_set') do |buffer, iter, mark| + update_statusbar(buffer, statusbar) + end + end + + def toolbar_cb(*args) + dialog = Gtk::MessageDialog.new(self, + Gtk::Dialog::DESTROY_WITH_PARENT, + Gtk::MessageDialog::INFO, + Gtk::MessageDialog::BUTTONS_CLOSE, + "You selected a toolbar button") + + # Close dialog on user response + dialog.signal_connect('response') do |widget, data| + widget.destroy + end + + dialog.show + end + + def about_cb(*args) + unless Gtk.check_version?(2, 6, 0) + puts "This sample requires GTK+ 2.6.0 or later" + return + end + + authors = ["Peter Mattis", "Spencer Kimball", "Josh MacDonald", "and many more..."] + documentors = ["Owen Taylor", "Tony Gale", "Mattias Clasen <mclasen@redhat.com>", + "and many more..."] + license = %Q[ +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 of the +License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the Gnome Library; see the file COPYING.LIB.If not, +write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +] + + transparent = Gdk::Pixbuf.new(Demo.find_file("gtk-logo-rgb.gif")).add_alpha(true, 0xff, 0xff, 0xff) + + Gtk::AboutDialog.set_email_hook {|about, link| + puts "send mail to #{link}" + } + Gtk::AboutDialog.set_url_hook {|about, link| + puts "show url #{link}" + } + Gtk::AboutDialog.show(self, + :name => "GTK+ Code Demos", + :version => Gtk::VERSION.join("."), + :copyright => "(C) 1997-2004 The GTK+ Team", + :license => license, + :website => "http://www.gtk.org", + :comments => "Program to demonstrate GTK+ functions.", + :authors => authors, + :documenters => documentors, + :logo => transparent) + end + + def update_statusbar(buffer, statusbar) + statusbar.pop(0) + + iter = buffer.get_iter_at_mark(buffer.get_mark('insert')) + + statusbar.push(0, + "Cursor at row #{iter.line} column #{iter.line_offset} - #{buffer.char_count} chars in document") + end + + def register_stock_icons + # Register our stock items + Gtk::Stock.add(:demo_gtk_logo, '_GTK!') + + # Add out custom icon factory to the list of defaults + factory = Gtk::IconFactory.new + factory.add_default + + filename = Demo.find_file('gtk-logo-rgb.gif') + pixbuf = Gdk::Pixbuf.new(filename) + + transparent = pixbuf.add_alpha(true, 0xff, 0xff, 0xff) + + icon_set = Gtk::IconSet.new(transparent) + factory.add('demo_gtk_logo', icon_set) + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/background.jpg b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/background.jpg new file mode 100644 index 0000000..86c006a Binary files /dev/null and b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/background.jpg differ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/builder.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/builder.rb new file mode 100644 index 0000000..dc4a1ce --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/builder.rb @@ -0,0 +1,51 @@ +# Copyright (c) 2008 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +=begin += Interface Builder + +Demonstrates an interface loaded from a XML description. +=end + +require 'common' + +module Demo + class Dialog < Demo::BasicWindow + def initialize + super('Interface Builder') + + available = Gtk.check_version?(2, 12, 0) + if available + label = Gtk::Label.new("Build an interface from XML description.") + else + label = Gtk::Label.new("You need GTK+ >= 2.12.0 to run this demo.") + end + add(label) + return unless available + + @builder = Gtk::Builder.new + filename = File.join(File.dirname(__FILE__), "demo.ui") + @builder << filename + @builder.connect_signals {|name| method(name)} + @window = @builder["window1"] + @window.show_all + + signal_connect("destroy") do + @window.destroy unless @window.destroyed? + end + end + + private + def quit_activate + @window.destroy + destroy unless destroyed? + end + + def about_activate + dialog = @builder["aboutdialog1"] + dialog.run + dialog.hide + end + end +end + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/button_box.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/button_box.rb new file mode 100644 index 0000000..a38885c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/button_box.rb @@ -0,0 +1,84 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: button_box.rb,v 1.3 2005/02/12 23:02:43 kzys Exp $ +=begin += Button Boxes + +The Button Box widgets are used to arrange buttons with padding. +=end +require 'common' + +module Demo + class ButtonBox < BasicWindow + def initialize + super('Button Boxes') + set_border_width(10) + + main_vbox = Gtk::VBox.new(false, 0) + add(main_vbox) + + frame_horiz = Gtk::Frame.new('Horizontal Button Boxes') + main_vbox.pack_start(frame_horiz, true, true, 10) + + vbox = Gtk::VBox.new(false, 0) + vbox.set_border_width(10) + frame_horiz.add(vbox) + + vbox.pack_start(create_bbox(true, 'Spread', 40, Gtk::ButtonBox::SPREAD), + true, true, 0) + + vbox.pack_start(create_bbox(true, 'Edge', 40, Gtk::ButtonBox::EDGE), + true, true, 5) + + vbox.pack_start(create_bbox(true, 'Start', 40, Gtk::ButtonBox::START), + true, true, 5) + + vbox.pack_start(create_bbox(true, 'End', 40, Gtk::ButtonBox::END), + true, true, 5) + + frame_vert = Gtk::Frame.new('Vertical Button Boxes') + main_vbox.pack_start(frame_vert, true, true, 10) + + hbox = Gtk::HBox.new(false, 0) + hbox.set_border_width(10) + frame_vert.add(hbox) + + hbox.pack_start(create_bbox(false, 'Spread', 30, Gtk::ButtonBox::SPREAD), + true, true, 0) + + hbox.pack_start(create_bbox(false, 'Edge', 30, Gtk::ButtonBox::EDGE), + true, true, 5) + + hbox.pack_start(create_bbox(false, 'Start', 30, Gtk::ButtonBox::START), + true, true, 5) + + hbox.pack_start(create_bbox(false, 'End', 30, Gtk::ButtonBox::END), + true, true, 5) + + end + + def create_bbox(horizontal, title, spacing, layout) + frame = Gtk::Frame.new(title) + + bbox = if horizontal + Gtk::HButtonBox.new + else + Gtk::VButtonBox.new + end + + bbox.set_border_width(5) + frame.add(bbox) + + bbox.layout_style = layout + bbox.set_spacing(spacing) + + [Gtk::Stock::OK, Gtk::Stock::CANCEL, Gtk::Stock::HELP].each do |stock| + button = Gtk::Button.new(stock) + bbox.add(button) + end + + return frame + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-arc-negative.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-arc-negative.rb new file mode 100644 index 0000000..735dddc --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-arc-negative.rb @@ -0,0 +1,41 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-arc-negative.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Arc Negative + +This demo shows how to use GDK and cairo to draw arc in negative. +From http://cairographics.org/samples/arc_negative.html. +=end +require 'common' + +module Demo + class CairoArcNegative < CairoWindow + CENTER_X = 0.5 + CENTER_Y = 0.5 + RADIUS = 0.4 + ANGLE1 = 45.0 * (Math::PI / 180.0) # angles are specified + ANGLE2 = 180.0 * (Math::PI / 180.0) # in radians + + def initialize + super('cairo arc_negative') + end + + def draw(cr) + cr.arc_negative(CENTER_X, CENTER_Y, RADIUS, ANGLE1, ANGLE2) + cr.stroke + + # draw helping lines + cr.set_source_rgba(1, 0.2, 0.2, 0.6) + cr.arc(CENTER_X, CENTER_Y, 0.05, 0, 2 * Math::PI) + cr.fill + cr.set_line_width(0.03) + cr.arc(CENTER_X, CENTER_Y, RADIUS, ANGLE1, ANGLE1) + cr.line_to(CENTER_X, CENTER_Y) + cr.arc(CENTER_X, CENTER_Y, RADIUS, ANGLE2, ANGLE2) + cr.line_to(CENTER_X, CENTER_Y) + cr.stroke + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-arc.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-arc.rb new file mode 100644 index 0000000..6c7cc35 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-arc.rb @@ -0,0 +1,41 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-arc.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Arc + +This demo shows how to use GDK and cairo to draw arc. +From http://cairographics.org/samples/arc.html. +=end +require 'common' + +module Demo + class CairoArc < CairoWindow + CENTER_X = 0.5 + CENTER_Y = 0.5 + RADIUS = 0.4 + ANGLE1 = 45.0 * (Math::PI / 180.0) # angles are specified + ANGLE2 = 180.0 * (Math::PI / 180.0) # in radians + + def initialize + super('cairo arc') + end + + def draw(cr) + cr.arc(CENTER_X, CENTER_Y, RADIUS, ANGLE1, ANGLE2) + cr.stroke + + # draw helping lines + cr.set_source_rgba(1, 0.2, 0.2, 0.6) + cr.arc(CENTER_X, CENTER_Y, 0.05, 0, 2 * Math::PI) + cr.fill + cr.set_line_width(0.03) + cr.arc(CENTER_X, CENTER_Y, RADIUS, ANGLE1, ANGLE1) + cr.line_to(CENTER_X, CENTER_Y) + cr.arc(CENTER_X, CENTER_Y, RADIUS, ANGLE2, ANGLE2) + cr.line_to(CENTER_X, CENTER_Y) + cr.stroke + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-clip-image.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-clip-image.rb new file mode 100644 index 0000000..b949e07 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-clip-image.rb @@ -0,0 +1,51 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-clip-image.rb,v 1.2 2005/10/16 12:07:32 mutoh Exp $ +=begin += cairo/Clip Image + +This demo shows how to use GDK and cairo to use clip for image. +From http://cairographics.org/samples/clip_image.html. +=end +require 'common' + +module Demo + class CairoClipImage < CairoWindow + def initialize + super('cairo clip image') + end + + def draw(cr) + cr.save do + cr.arc(0.5, 0.5, 0.4, 0, 2 * Math::PI) + cr.clip + + cr.new_path + + loader = Gdk::PixbufLoader.new + File.open("background.jpg", "rb") do |f| + loader.last_write(f.read) + end + pixbuf = loader.pixbuf + cr.scale(1.0 / pixbuf.width, 1.0 / pixbuf.height) + + cr.set_source_pixbuf(pixbuf, 0, 0) + cr.paint + end + + cr.save do + cr.arc(0.5, 0.5, 0.3, 0, 2 * Math::PI) + cr.clip + + cr.new_path + + image = Cairo::ImageSurface.from_png("ruby-gnome2-logo.png") + cr.scale(1.0 / image.width, 1.0 / image.height) + + cr.set_source(image, 0, 0) + cr.paint + end + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-clip-rectangle.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-clip-rectangle.rb new file mode 100644 index 0000000..75fc8e7 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-clip-rectangle.rb @@ -0,0 +1,35 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-clip-rectangle.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Clip Rectangle + +This demo shows how to use GDK and cairo to clip as rectangle. +From http://cairographics.org/samples/xxx_clip_rectangle.html. +=end +require 'common' + +module Demo + class CairoClipRectangle < CairoWindow + def initialize + super('cairo clip rectangle') + end + + def draw(cr) + cr.new_path + cr.move_to(0.25, 0.25) + cr.line_to(0.25, 0.75) + cr.line_to(0.75, 0.75) + cr.line_to(0.75, 0.25) + cr.line_to(0.25, 0.25) + cr.close_path + + cr.clip + + cr.move_to(0, 0) + cr.line_to(1, 1) + cr.stroke + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-clip.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-clip.rb new file mode 100644 index 0000000..3c83e70 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-clip.rb @@ -0,0 +1,35 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-clip.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Clip + +This demo shows how to use GDK and cairo to use clip. +From http://cairographics.org/samples/clip.html. +=end +require 'common' + +module Demo + class CairoClip < CairoWindow + def initialize + super('cairo clip') + end + + def draw(cr) + cr.arc(0.5, 0.5, 0.3, 0, 2 * Math::PI) + cr.clip + + cr.new_path + + cr.rectangle(0, 0, 1, 1) + cr.fill + cr.set_source_rgba(0, 1, 0) + cr.move_to(0, 0) + cr.line_to(1, 1) + cr.move_to(1, 0) + cr.line_to(0, 1) + cr.stroke + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-curve-rectangle.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-curve-rectangle.rb new file mode 100644 index 0000000..1a4e780 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-curve-rectangle.rb @@ -0,0 +1,76 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-curve-rectangle.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Curve Rectangle + +This demo shows how to use GDK and cairo to draw curve rectangle. +From http://cairographics.org/samples/curve_rectangle.html. +=end +require 'common' + +module Demo + class CairoCurveRectangle < CairoWindow + # a custom shape, that could be wrapped in a function + X0 = 0.1 #< parameters like Cairo::Context#rectangle + Y0 = 0.1 + RECT_WIDTH = 0.8 + RECT_HEIGHT = 0.8 + RADIUS = 0.4 #< and an approximate curvature radius + + X1 = X0 + RECT_WIDTH + Y1 = Y0 + RECT_HEIGHT + + def initialize + super('cairo curve rectangle') + end + + def draw(cr) + return if (RECT_WIDTH <= 0 || RECT_HEIGHT <= 0) + + if (RECT_WIDTH / 2 < RADIUS) + if (RECT_HEIGHT / 2 < RADIUS) + cr.move_to(X0, (Y0 + Y1) / 2) + cr.curve_to(X0 ,Y0, X0, Y0, (X0 + X1) / 2, Y0) + cr.curve_to(X1, Y0, X1, Y0, X1, (Y0 + Y1) / 2) + cr.curve_to(X1, Y1, X1, Y1, (X1 + X0) / 2, Y1) + cr.curve_to(X0, Y1, X0, Y1, X0, (Y0 + Y1) / 2) + else + cr.move_to(X0, Y0 + RADIUS) + cr.curve_to(X0 ,Y0, X0, Y0, (X0 + X1) / 2, Y0) + cr.curve_to(X1, Y0, X1, Y0, X1, Y0 + RADIUS) + cr.line_to(X1 , Y1 - RADIUS) + cr.curve_to(X1, Y1, X1, Y1, (X1 + X0) / 2, Y1) + cr.curve_to(X0, Y1, X0, Y1, X0, Y1- RADIUS) + end + else + if (RECT_HEIGHT / 2 < RADIUS) + cr.move_to(X0, (Y0 + Y1) / 2) + cr.curve_to(X0, Y0, X0 , Y0, X0 + RADIUS, Y0) + cr.line_to(X1 - RADIUS, Y0) + cr.curve_to(X1, Y0, X1, Y0, X1, (Y0 + Y1) / 2) + cr.curve_to(X1, Y1, X1, Y1, X1 - RADIUS, Y1) + cr.line_to(X0 + RADIUS, Y1) + cr.curve_to(X0, Y1, X0, Y1, X0, (Y0 + Y1) / 2) + else + cr.move_to(X0, Y0 + RADIUS) + cr.curve_to(X0 , Y0, X0 , Y0, X0 + RADIUS, Y0) + cr.line_to(X1 - RADIUS, Y0) + cr.curve_to(X1, Y0, X1, Y0, X1, Y0 + RADIUS) + cr.line_to(X1 , Y1 - RADIUS) + cr.curve_to(X1, Y1, X1, Y1, X1 - RADIUS, Y1) + cr.line_to(X0 + RADIUS, Y1) + cr.curve_to(X0, Y1, X0, Y1, X0, Y1- RADIUS) + end + end + + cr.close_path + + cr.set_source_rgba(0.5,0.5,1) + cr.fill_preserve + cr.set_source_rgba(0.5, 0, 0, 0.5) + cr.stroke + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-curve-to.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-curve-to.rb new file mode 100644 index 0000000..9032313 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-curve-to.rb @@ -0,0 +1,43 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-curve-to.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Curve To + +This demo shows how to use GDK and cairo to draw curve. +From http://cairographics.org/samples/curve_to.html. +=end +require 'common' + +module Demo + class CairoCurveTo < CairoWindow + X = 0.1 + Y = 0.5 + X1 = 0.4 + Y1 = 0.9 + X2 = 0.6 + Y2 = 0.1 + X3 = 0.9 + Y3 = 0.5 + + def initialize + super('cairo curve to') + end + + def draw(cr) + cr.move_to(X, Y) + cr.curve_to(X1, Y1, X2, Y2, X3, Y3) + + cr.stroke + + cr.set_source_rgba(1, 0.2, 0.2, 0.6) + cr.set_line_width(0.03) + cr.move_to(X, Y) + cr.line_to(X1, Y1) + cr.move_to(X2, Y2) + cr.line_to(X3, Y3) + cr.stroke + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-dash.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-dash.rb new file mode 100644 index 0000000..720b39b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-dash.rb @@ -0,0 +1,39 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-dash.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Dash + +This demo shows how to use GDK and cairo to show dash. +From http://cairographics.org/samples/xxx_dash.html. +=end +require 'common' + +module Demo + class CairoDash < CairoWindow + def initialize + super('cairo dash') + end + + def draw(cr) + dashes = [ + 0.20, # in + 0.05, # skip + 0.05, # ink + 0.05, # skip + ] + + offset = -0.2 + + cr.set_dash(dashes, offset) + + cr.move_to(0.5, 0.1) + cr.line_to(0.9, 0.9) + cr.rel_line_to(-0.4, 0.0) + cr.curve_to(0.2, 0.9, 0.2, 0.5, 0.5, 0.5) + + cr.stroke + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-fill-and-stroke.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-fill-and-stroke.rb new file mode 100644 index 0000000..84e4199 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-fill-and-stroke.rb @@ -0,0 +1,32 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-fill-and-stroke.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Fill And Stroke + +This demo shows how to use GDK and cairo to fill and stroke. +From http://cairographics.org/samples/fill_and_stroke.html. +=end +require 'common' + +module Demo + class CairoFillAndStroke < CairoWindow + def initialize + super('cairo fill and stroke') + end + + def draw(cr) + cr.move_to(0.5, 0.1) + cr.line_to(0.9, 0.9) + cr.rel_line_to(-0.4, 0.0) + cr.curve_to(0.2, 0.9, 0.2, 0.5, 0.5, 0.5) + cr.close_path + + cr.set_source_rgba(0, 0, 1) + cr.fill_preserve + cr.set_source_rgba(0, 0, 0) + cr.stroke + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-fill-and-stroke2.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-fill-and-stroke2.rb new file mode 100644 index 0000000..011d154 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-fill-and-stroke2.rb @@ -0,0 +1,38 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-fill-and-stroke2.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Fill And Stroke2 + +This demo shows how to use GDK and cairo to fill and stroke. +From http://cairographics.org/samples/fill_and_stroke2.html. +=end +require 'common' + +module Demo + class CairoFillAndStroke2 < CairoWindow + def initialize + super('cairo fill and stroke2') + end + + def draw(cr) + cr.move_to(0.5, 0.1) + cr.line_to(0.9, 0.9) + cr.rel_line_to(-0.4, 0.0) + cr.curve_to(0.2, 0.9, 0.2, 0.5, 0.5, 0.5) + cr.close_path + + cr.move_to(0.25, 0.1) + cr.rel_line_to(0.2, 0.2) + cr.rel_line_to(-0.2, 0.2) + cr.rel_line_to(-0.2, -0.2) + cr.close_path + + cr.set_source_rgba(0, 0, 1) + cr.fill_preserve + cr.set_source_rgba(0, 0, 0) + cr.stroke + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-gradient.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-gradient.rb new file mode 100644 index 0000000..f947421 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-gradient.rb @@ -0,0 +1,35 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-gradient.rb,v 1.2 2005/10/12 15:23:49 ktou Exp $ +=begin += cairo/Gradient + +This demo shows how to use GDK and cairo to gradient. +From http://cairographics.org/samples/gradient.html. +=end +require 'common' + +module Demo + class CairoGradient < CairoWindow + def initialize + super('cairo gradient') + end + + def draw(cr) + pat = Cairo::LinearPattern.new(0.0, 0.0, 0.0, 1.0) + pat.add_color_stop_rgb(1, 0, 0, 0) + pat.add_color_stop_rgb(0, 1, 0, 0) + cr.rectangle(0, 0, 1, 1) + cr.set_source(pat) + cr.fill + + pat = Cairo::RadialPattern.new(0.45, 0.4, 0.1, 0.4, 0.4, 0.5) + pat.add_color_stop_rgba(0, 1, 1, 1, 0.8) + pat.add_color_stop_rgba(1, 0, 0, 0) + cr.set_source(pat) + cr.arc(0.5, 0.5, 0.3, 0, 2 * Math::PI) + cr.fill + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-image-pattern.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-image-pattern.rb new file mode 100644 index 0000000..c2a72f0 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-image-pattern.rb @@ -0,0 +1,39 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-image-pattern.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Image Pattern + +This demo shows how to use GDK and cairo to use image pattern. +From http://cairographics.org/samples/imagepattern.html. +=end +require 'common' + +module Demo + class CairoImagePattern < CairoWindow + def initialize + super('cairo image pattern') + end + + def draw(cr) + image = Cairo::ImageSurface.from_png("ruby-gnome2-logo.png") + + pattern = Cairo::SurfacePattern.new(image) + pattern.set_extend(Cairo::EXTEND_REPEAT) + + cr.translate(0.5, 0.5) + cr.rotate(Math::PI / 4) + cr.scale(1 / Math.sqrt(2), 1 / Math.sqrt(2)) + cr.translate(-0.5, -0.5) + + matrix = Cairo::Matrix.scale(image.width * 5, image.height * 5) + pattern.set_matrix(matrix) + + cr.set_source(pattern) + + cr.rectangle(0, 0, 1.0, 1.0) + cr.fill + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-image.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-image.rb new file mode 100644 index 0000000..b102989 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-image.rb @@ -0,0 +1,49 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-image.rb,v 1.2 2005/10/16 12:07:32 mutoh Exp $ +=begin += cairo/Image + +This demo shows how to use GDK and cairo to show image. +From http://cairographics.org/samples/image.html. +=end +require 'common' + +module Demo + class CairoImage < CairoWindow + def initialize + super('cairo gradient') + end + + def draw(cr) + cr.save do + loader = Gdk::PixbufLoader.new + File.open("background.jpg", "rb") do |f| + loader.last_write(f.read) + end + pixbuf = loader.pixbuf + + cr.translate(0.5, 0.5) + cr.rotate(45 * Math::PI / 180) + cr.scale(1.0 / pixbuf.width, 1.0 / pixbuf.height) + cr.translate(-0.5 * pixbuf.width, -0.5 * pixbuf.height) + + cr.set_source_pixbuf(pixbuf, 0, 0) + cr.paint + end + + cr.save do + image = Cairo::ImageSurface.from_png("ruby-gnome2-logo.png") + + cr.translate(0.5, 0.5) + cr.rotate(60 * Math::PI / 180) + cr.scale(0.8 / image.width, 0.8 / image.height) + cr.translate(-0.5 * image.width, -0.5 * image.height) + + cr.set_source(image, 0, 0) + cr.paint + end + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-line-cap.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-line-cap.rb new file mode 100644 index 0000000..cd20cc9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-line-cap.rb @@ -0,0 +1,53 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-line-cap.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Line Cap + +This demo shows how to use GDK and cairo to set line cap. +From http://cairographics.org/samples/set_line_cap.html. +=end +require 'common' + +module Demo + class CairoLineCap < CairoWindow + def initialize + super('cairo line cap') + end + + def draw(cr) + cr.set_line_width(0.12) + + cr.set_line_cap(Cairo::LINE_CAP_BUTT) # default + cr.move_to(0.25, 0.2) + cr.line_to(0.25, 0.8) + cr.stroke + + cr.set_line_cap(Cairo::LINE_CAP_ROUND) + cr.move_to(0.5, 0.2) + cr.line_to(0.5, 0.8) + cr.stroke + + cr.set_line_cap(Cairo::LINE_CAP_SQUARE) + cr.move_to(0.75, 0.2) + cr.line_to(0.75, 0.8) + cr.stroke + + # draw helping lines + cr.set_source_rgba(1, 0.2, 0.2) + cr.set_line_width(0.01) + + cr.move_to(0.25, 0.2) + cr.line_to(0.25, 0.8) + + cr.move_to(0.5, 0.2) + cr.line_to(0.5, 0.8) + + cr.move_to(0.75, 0.2) + cr.line_to(0.75, 0.8) + + cr.stroke + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-line-join.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-line-join.rb new file mode 100644 index 0000000..5b23261 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-line-join.rb @@ -0,0 +1,41 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-line-join.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Line Join + +This demo shows how to use GDK and cairo to set line join. +From http://cairographics.org/samples/set_line_join.html. +=end +require 'common' + +module Demo + class CairoLineJoin < CairoWindow + def initialize + super('cairo line join') + end + + def draw(cr) + cr.set_line_width(0.16) + + cr.move_to(0.3, 0.33) + cr.rel_line_to(0.2, -0.2) + cr.rel_line_to(0.2, 0.2) + cr.set_line_join(Cairo::LINE_JOIN_MITER) # default + cr.stroke + + cr.move_to(0.3, 0.63) + cr.rel_line_to(0.2, -0.2) + cr.rel_line_to(0.2, 0.2) + cr.set_line_join(Cairo::LINE_JOIN_BEVEL) + cr.stroke + + cr.move_to(0.3, 0.93) + cr.rel_line_to(0.2, -0.2) + cr.rel_line_to(0.2, 0.2) + cr.set_line_join(Cairo::LINE_JOIN_ROUND) + cr.stroke + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-long-lines.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-long-lines.rb new file mode 100644 index 0000000..e8c32cc --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-long-lines.rb @@ -0,0 +1,41 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-long-lines.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Long Lines + +This demo shows how to use GDK and cairo to show long lines. +From http://cairographics.org/samples/xxx_long_liens.html. +=end +require 'common' + +module Demo + class CairoLongLines < CairoWindow + def initialize + super('cairo long lines') + end + + def draw(cr) + cr.move_to(0.1, -50) + cr.line_to(0.1, 50) + cr.set_source_rgba(1, 0, 0) + cr.stroke + + cr.move_to(0.2, -60) + cr.line_to(0.2, 60) + cr.set_source_rgba(1, 1, 0) + cr.stroke + + cr.move_to(0.3, -70) + cr.line_to(0.3, 70) + cr.set_source_rgba(0, 1, 0) + cr.stroke + + cr.move_to(0.4, -80) + cr.line_to(0.4, 80) + cr.set_source_rgba(0, 0, 1) + cr.stroke + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-operator.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-operator.rb new file mode 100644 index 0000000..97acff6 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-operator.rb @@ -0,0 +1,83 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-operator.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Operator + +This demo shows how to use GDK and cairo to use Cairo::OPERATOR_* +From http://cairographics.org/samples/operator_add.html, + http://cairographics.org/samples/operator_atop.html, + http://cairographics.org/samples/operator_atop_reverse.html, + http://cairographics.org/samples/operator_in.html, + http://cairographics.org/samples/operator_in_reverse.html, + http://cairographics.org/samples/operator_out.html, + http://cairographics.org/samples/operator_out_reverse.html, + http://cairographics.org/samples/operator_over.html, + http://cairographics.org/samples/operator_over_reverse.html, + http://cairographics.org/samples/operator_saturate.html and + http://cairographics.org/samples/operator_xor.html +=end +require 'common' + +module Demo + class CairoOperator < CairoWindow + def initialize + super('cairo operator') + @operator = Cairo::OPERATOR_ADD + + set_default_size(400, 400) + + @drawing_area = child + remove(@drawing_area) + + vbox = Gtk::VBox.new + vbox.pack_start(@drawing_area, true, true) + vbox.pack_start(operator_selector, false, false) + add(vbox) + end + + def draw(cr) + cr.save do + image = Cairo::ImageSurface.from_png("ruby-gnome2-logo.png") + cr.translate(0.5, 0.5) + cr.rotate(-45 * Math::PI / 180) + cr.scale(0.8 / image.width, 0.8 / image.height) + cr.translate(-0.5 * image.width, -0.5 * image.height) + cr.set_source(image, 0.0, 0.0) + cr.paint + end + + cr.set_operator(@operator) + + cr.set_source_rgba(1, 0, 0, 0.5) + cr.rectangle(0.2, 0.2, 0.5, 0.5) + cr.fill + cr.set_source_rgba(0, 1, 0) + cr.rectangle(0.4, 0.4, 0.4, 0.4) + cr.fill + cr.set_source_rgba(0, 0, 1) + cr.rectangle(0.6, 0.6, 0.3, 0.3) + cr.fill + end + + def operator_selector + combo = Gtk::ComboBox.new + operators = [] + Cairo.constants.each do |name| + operators << name if /^OPERATOR_/ =~ name + end + operators.sort.each_with_index do |name, i| + combo.append_text(name.to_s) + combo.set_active(i) if Cairo.const_get(name) == @operator + end + + combo.signal_connect("changed") do |widget| + text = widget.active_text + @operator = Cairo.const_get(text) if text + @drawing_area.queue_draw + end + combo + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-path.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-path.rb new file mode 100644 index 0000000..7f1dded --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-path.rb @@ -0,0 +1,28 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-path.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Path + +This demo shows how to use GDK and cairo to draw path. +From http://cairographics.org/samples/path.html. +=end +require 'common' + +module Demo + class CairoPath < CairoWindow + def initialize + super('cairo path') + end + + def draw(cr) + cr.move_to(0.5, 0.1) + cr.line_to(0.9, 0.9) + cr.rel_line_to(-0.4, 0.0) + cr.curve_to(0.2, 0.9, 0.2, 0.5, 0.5, 0.5) + + cr.stroke + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-pattern-fill.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-pattern-fill.rb new file mode 100644 index 0000000..0a4e1a9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-pattern-fill.rb @@ -0,0 +1,88 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-pattern-fill.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Pattern Fill + +This demo shows how to use GDK and cairo to fill by pattern. +From http://cairographics.org/samples/pattern_fill.html. +=end +require 'common' + +module Demo + class CairoPatternFill < CairoWindow + X_FUZZ = 0.08 + Y_FUZZ = 0.08 + + X_INNER_RADIUS = 0.3 + Y_INNER_RADIUS = 0.2 + + X_OUTER_RADIUS = 0.45 + Y_OUTER_RADIUS = 0.35 + + SPIKES = 10 + + TEXT = "Ruby!" + + def initialize + super('cairo pattern fill') + end + + def draw(cr) + srand(45) + + cr.set_line_width(0.01) + + x = y = nil + 0.step(SPIKES * 2 - 1, 2) do |i| + x = x_position(i, X_INNER_RADIUS) + y = y_position(i, Y_INNER_RADIUS) + + if (i == 0) + cr.move_to(x, y) + else + cr.line_to(x, y) + end + + i += 1 + + x = x_position(i, X_OUTER_RADIUS) + y = y_position(i, Y_OUTER_RADIUS) + + cr.line_to(x, y) + end + + cr.close_path + cr.stroke + + cr.select_font_face("Sans", + Cairo::FONT_SLANT_NORMAL, + Cairo::FONT_WEIGHT_BOLD) + + cr.move_to(x - 0.5, y) + cr.set_font_size(0.1) + cr.text_path(TEXT) + cr.set_source_rgba(1, 0, 0.5) + cr.fill + + cr.set_font_size(0.2) + extents = cr.text_extents(TEXT) + x = 0.5 - (extents.width / 2 + extents.x_bearing) + y = 0.5 - (extents.height / 2 + extents.y_bearing) + + cr.move_to(x, y) + cr.text_path(TEXT) + cr.set_source_rgba(1, 0, 0) + cr.stroke + end + + def x_position(i, radius) + 0.5 + Math.cos(Math::PI * i / SPIKES) * radius + rand * X_FUZZ + end + + def y_position(i, radius) + 0.5 + Math.sin(Math::PI * i / SPIKES) * radius + rand * Y_FUZZ + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-self-intersect.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-self-intersect.rb new file mode 100644 index 0000000..172949d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-self-intersect.rb @@ -0,0 +1,32 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-self-intersect.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Self Intersect + +This demo shows how to use GDK and cairo to show cross. +From http://cairographics.org/samples/xxx_self_intersect.html. +=end +require 'common' + +module Demo + class CairoSelfIntersect < CairoWindow + def initialize + super('cairo self intersect') + end + + def draw(cr) + cr.move_to(0.3, 0.3) + cr.line_to(0.7, 0.3) + + cr.line_to(0.5, 0.3) + cr.line_to(0.5, 0.7) + + cr.set_line_width(0.22) + cr.set_line_cap(Cairo::LINE_CAP_ROUND) + cr.set_line_join(Cairo::LINE_JOIN_ROUND) + cr.stroke + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-text-align-center.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-text-align-center.rb new file mode 100644 index 0000000..ead78f1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-text-align-center.rb @@ -0,0 +1,45 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-text-align-center.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Text Align Center + +This demo shows how to use GDK and cairo to show text in center. +From http://cairographics.org/samples/text_align_center.html. +=end +require 'common' + +module Demo + class CairoTextAlignCenter < CairoWindow + TEXT = "Ruby" + + def initialize + super('cairo text align center') + end + + def draw(cr) + cr.select_font_face("Sans", + Cairo::FONT_SLANT_NORMAL, + Cairo::FONT_WEIGHT_NORMAL) + + cr.set_font_size(0.2) + extents = cr.text_extents(TEXT) + x = 0.5 - (extents.width / 2 + extents.x_bearing) + y = 0.5 - (extents.height / 2 + extents.y_bearing) + + cr.move_to(x, y) + cr.show_text(TEXT) + + # draw helping lines + cr.set_source_rgba(1, 0.2, 0.2, 0.6) + cr.arc(x, y, 0.05, 0, 2 * Math::PI) + cr.fill + cr.move_to(0.5, 0) + cr.rel_line_to(0, 1) + cr.move_to(0, 0.5) + cr.rel_line_to(1, 0) + cr.stroke + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-text-extents.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-text-extents.rb new file mode 100644 index 0000000..e2a6b4b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-text-extents.rb @@ -0,0 +1,46 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-text-extents.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Text Extents + +This demo shows how to use GDK and cairo to show text extents. +From http://cairographics.org/samples/text.html. +=end +require 'common' + +module Demo + class CairoTextExtents < CairoWindow + TEXT = "Ruby" + + def initialize + super('cairo text') + end + + def draw(cr) + cr.select_font_face("Sans", + Cairo::FONT_SLANT_NORMAL, + Cairo::FONT_WEIGHT_NORMAL) + + cr.set_font_size(0.3) + extents = cr.text_extents(TEXT) + + x = 0.1 + y = 0.6 + + cr.move_to(x, y) + cr.show_text(TEXT) + + # draw helping lines + cr.set_source_rgba(1, 0.2, 0.2, 0.6) + cr.arc(x, y, 0.05, 0, 2 * Math::PI) + cr.fill + cr.move_to(x, y) + cr.rel_line_to(0, -extents.height) + cr.rel_line_to(extents.width, 0) + cr.rel_line_to(extents.x_bearing, -extents.y_bearing) + cr.stroke + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-text.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-text.rb new file mode 100644 index 0000000..69e7abe --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/cairo-text.rb @@ -0,0 +1,43 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: cairo-text.rb,v 1.1 2005/10/12 05:38:30 ktou Exp $ +=begin += cairo/Text + +This demo shows how to use GDK and cairo to show text. +From http://cairographics.org/samples/text.html. +=end +require 'common' + +module Demo + class CairoText < CairoWindow + def initialize + super('cairo text') + end + + def draw(cr) + cr.select_font_face("Sans", + Cairo::FONT_SLANT_NORMAL, + Cairo::FONT_WEIGHT_BOLD) + cr.set_font_size(0.35) + + cr.move_to(0.04, 0.53) + cr.show_text("Hello") + + cr.move_to(0.27, 0.65) + cr.text_path("void") + cr.set_source_rgba(0.5, 0.5, 1) + cr.fill_preserve + cr.set_source_rgba(0, 0, 0) + cr.set_line_width(0.01) + cr.stroke + + # draw helping lines + cr.set_source_rgba(1,0.2,0.2, 0.6) + cr.arc(0.04, 0.53, 0.02, 0, 2 * Math::PI) + cr.arc(0.27, 0.65, 0.02, 0, 2 * Math::PI) + cr.fill + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/changedisplay.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/changedisplay.rb new file mode 100644 index 0000000..5c7563e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/changedisplay.rb @@ -0,0 +1,408 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: changedisplay.rb,v 1.6 2005/07/30 11:22:15 mutoh Exp $ +=begin += Change Display + +Demonstrates migrating a window between different displays and +screens. A display is a mouse and keyboard with some number of +associated monitors. A screen is a set of monitors grouped +into a single physical work area. The neat thing about having +multiple displays is that they can be on a completely separate +computers, as long as there is a network connection to the +computer where the application is running. + +Only some of the windowing systems where GTK+ runs have the +concept of multiple displays and screens. (The X Window System +is the main example.) Other windowing systems can only +handle one keyboard and mouse, and combine all monitors into +a single screen. + +This is a moderately complex example, and demonstrates: + +- Tracking the currently open displays and screens + +- Changing the screen for a window + +- Letting the user choose a window by clicking on it + +- Using Gtk::ListStore and Gtk::TreeView + +- Using Gtk::Dialog +=end + +require 'common' + +module Demo + class ChangeDisplay < Gtk::Dialog + # These enumerations provide symbolic names for the columns + # in the two GtkListStore models. + DISPLAY_COLUMN_NAME, DISPLAY_COLUMN_DISPLAY = 0, 1 + SCREEN_COLUMN_NUMBER, SCREEN_COLUMN_SCREEN = 0, 1 + + # Main entry point. If the dialog for this demo doesn't yet exist, creates + # it. Otherwise, destroys it. + def initialize + @size_group = nil + + @display_model = nil + @screen_model = nil + + @screen_selection = nil + + @current_display = nil + @current_screen = nil + + super('Change Screen or display', + nil, # parent + Gtk::Dialog::NO_SEPARATOR, + [Gtk::Stock::CLOSE, Gtk::Dialog::RESPONSE_CLOSE], + ['Change', Gtk::Dialog::RESPONSE_OK]) + + set_default_size(300, 400) + signal_connect('response') do |dialog, response_id| + if response_id == Gtk::Dialog::RESPONSE_OK + if Gtk.check_version?(2, 2, 0) + query_change_display + else + puts "This sample requires GTK+ 2.2.0 or later" + end + else + destroy # Gtk.main_quit? + end + end + signal_connect('destroy') do + + end + + unless Gtk.check_version?(2, 2, 0) + vbox.add(Gtk::Label.new("This sample requires GTK+ 2.2.0 or later")) + return + end + + vbox = Gtk::VBox.new(false, 5) + vbox.set_border_width(8) + + self.vbox.pack_start(vbox, true, true) + + @size_group = Gtk::SizeGroup.new(Gtk::SizeGroup::HORIZONTAL) + + frame = create_display_frame + vbox.pack_start(frame, true, true) + + frame = create_screen_frame + vbox.pack_start(frame, true, true) + + initialize_displays + end + + # Adds all currently open displays to our list of displays, + # and set up a signal connection so that we'll be notified + # when displays are opened in the future as well. + def initialize_displays + manager = Gdk::DisplayManager.get + + manager.displays.each do |display| + add_display(display) + end + + handler_id = manager.signal_connect('display_opened') do |display| + add_display(display) + end + signal_connect('destroy') do + manager.signal_handler_disconnect(handler_id) + end + end + + # Fills in the screen list based on the current display + def fill_screens + @screen_model.clear + + if @current_display + n_screens = @current_display.n_screens + + n_screens.times do |i| + iter = @screen_model.append + iter.set_value(SCREEN_COLUMN_NUMBER, i) + iter.set_value(SCREEN_COLUMN_SCREEN, @current_display.get_screen(i)) + + if i == 0 + @screen_selection.select_iter(iter) + end + end + end + end + + # Creates the 'Display' frame in the main window. + def create_display_frame + frame, tree_view, button_vbox = create_frame('Display') + + button = left_align_button_new('_Open...') + button.signal_connect('clicked') do + open_display_cb + end + button_vbox.pack_start(button, false, false, 0) + + button = left_align_button_new('_Close') + button.signal_connect('clicked') do + if @current_display + @current_display.close + end + end + button_vbox.pack_start(button, false, false, 0) + + @display_model = Gtk::ListStore.new(String, Gdk::Display) + tree_view.model = @display_model + + column = Gtk::TreeViewColumn.new('Name', + Gtk::CellRendererText.new, + {'text' => DISPLAY_COLUMN_NAME}) + tree_view.append_column(column) + + selection = tree_view.selection + selection.signal_connect('changed') do + display_changed_cb(selection) + end + + return frame + end + + # Creates the 'Screen' frame in the main window. + def create_screen_frame + frame, tree_view, button_vbox = create_frame('Screen') + + @screen_model = Gtk::ListStore.new(Integer, Gdk::Screen) + tree_view.model = @screen_model + + column = Gtk::TreeViewColumn.new('Number', + Gtk::CellRendererText.new, + {'text' => SCREEN_COLUMN_NUMBER}) + tree_view.append_column(column) + + @screen_selection = tree_view.selection + @screen_selection.signal_connect('changed') do |selection| + @current_screen = if iter = selection.selected + iter.get_value(SCREEN_COLUMN_SCREEN) + else + nil + end + end + + return frame + end + + # This function is used both for creating the 'Display' and + # 'Screen' frames, since they have a similar structure. The + # caller hooks up the right context for the value returned + # in tree_view, and packs any relevant buttons into button_vbox. + def create_frame(title) + frame = Gtk::Frame.new(title) + + hbox = Gtk::HBox.new(false, 8) + hbox.set_border_width(8) + frame.add(hbox) + + scrollwin = Gtk::ScrolledWindow.new + scrollwin.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC) + scrollwin.shadow_type = Gtk::SHADOW_IN + hbox.pack_start(scrollwin, true, true) + + tree_view = Gtk::TreeView.new + tree_view.headers_visible = false + scrollwin.add(tree_view) + + selection = tree_view.selection + selection.mode = Gtk::SELECTION_BROWSE + + button_vbox = Gtk::VBox.new(false, 5) + hbox.pack_start(button_vbox, false, false) + + @size_group.add_widget(button_vbox) + + return frame, tree_view, button_vbox + end + + # If we have a stack of buttons, it often looks better if their contents + # are left-aligned, rather than centered. This function creates a button + # and left-aligns it contents. + def left_align_button_new(label) + button = Gtk::Button.new(label, true) + button.child.set_alignment(0.0, 0.5) + + return button + end + + + # Prompts the user for a toplevel window to move, and then moves + # that window to the currently selected display + def query_change_display + screen = self.window.screen + + toplevel = query_for_toplevel(screen, + "Please select the toplevel\n"+ + "to move to the new screen") + + if toplevel + toplevel.screen = @current_screen + else + screen.display.beep + end + end + + # Asks the user to click on a window, then waits for them click + # the mouse. When the mouse is released, returns the toplevel + # window under the pointer, or nil, if there is none. + def query_for_toplevel(screen, prompt) + toplevel = nil + + display = screen.display + + popup = Gtk::Window.new(Gtk::Window::POPUP) + popup.screen = screen + popup.modal = true + popup.window_position = Gtk::Window::POS_CENTER + + frame = Gtk::Frame.new + frame.set_shadow_type(Gtk::SHADOW_OUT) + popup.add(frame) + + label = Gtk::Label.new(prompt) + label.set_padding(10, 10) + frame.add(label) + + popup.show_all + + # TODO: Gdk::Cursor.new(screen.display, Gdk::Cursor::CROSSHAIR) + cursor = Gdk::Cursor.new(Gdk::Cursor::CROSSHAIR) + + if Gdk::pointer_grab(popup.window, false, + Gdk::Event::BUTTON_RELEASE_MASK, + nil, + cursor, + Gdk::Event::CURRENT_TIME) == Gdk::GRAB_SUCCESS + clicked = false + + popup.signal_connect('button-release-event') do + clicked = true + end + + # Process events until clicked is set by button_release_event_cb. + # We pass in may_block = true since we want to wait if there + # are no events currently. + until clicked + Gtk.main_iteration # TODO: GLib::main_context_iteration(nil, true) + + toplevel = find_toplevel_at_pointer(screen.display) + if toplevel == popup + toplevel = nil + end + end + + popup.destroy + Gdk.flush # Really release the grab + + return toplevel + end + end + + # Finds the toplevel window under the mouse pointer, if any. + def find_toplevel_at_pointer(display) + pointer_window, x, y = display.window_at_pointer + + # The user data field of a GdkWindow is used to store a pointer + # to the widget that created it. + if pointer_window + widget = pointer_window.user_data + end + + return (if widget + widget.toplevel + else + nil + end) + end + + # Called when the user clicks on 'Open...' in the display + # frame. Prompts for a new display, and then opens a connection + # to that display. + def open_display_cb + dialog = Gtk::Dialog.new('Open Display', + self, + Gtk::Dialog::MODAL, + [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL], + [Gtk::Stock::OK, Gtk::Dialog::RESPONSE_OK]) + + dialog.default_response = Gtk::Dialog::RESPONSE_OK + display_entry = Gtk::Entry.new + display_entry.activates_default = true + dialog_label = + Gtk::Label.new("Please enter the name of\nthe new display\n") + + dialog.vbox.add(dialog_label) + dialog.vbox.add(display_entry) + + display_entry.grab_focus + dialog.vbox.show_all + + result = nil + until result + response_id = dialog.run + break if response_id != Gtk::Dialog::RESPONSE_OK + + new_screen_name = display_entry.text + + unless new_screen_name.empty? + begin + result = Gdk::Dispaly.open(new_screen_name) + rescue + dialog_label.text = "Can't open display :\n\t%s\nplease try another one\n" % [new_screen_name] + end + end + end + dialog.destroy + end + + # Called when the selected row in the display list changes. + # Updates info.current_display, then refills the list of + # screens. + def display_changed_cb(selection) + @current_display = + if iter = selection.selected + iter.get_value(DISPLAY_COLUMN_DISPLAY) + else + nil + end + fill_screens + end + + # Adds a new display to our list of displays, and connects + # to the 'closed' signal so that we can remove it from the + # list of displays again. + def add_display(display) + iter = @display_model.append + iter.set_value(DISPLAY_COLUMN_NAME, display.name) + iter.set_value(DISPLAY_COLUMN_DISPLAY, display) + + handler_id = display.signal_connect('closed') do + display_closed_cb(display) + end + + signal_connect('destroy') do + display.signal_handler_disconnect(handler_id) + end + end + + # Called when one of the currently open displays is closed. + # Remove it from our list of displays. + def display_closed_cb(display) + @display_model.each do |model, path, iter| + tmp_display = iter.get_value( DISPLAY_COLUMN_DISPLAY) + if tmp_display == display + @display_model.remove(iter) + break + end + end + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/clipboard.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/clipboard.rb new file mode 100644 index 0000000..325ccdb --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/clipboard.rb @@ -0,0 +1,72 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# $Id: clipboard.rb,v 1.3 2005/07/28 14:30:38 mutoh Exp $ +=begin += Clipboard + +GtkClipboard is used for clipboard handling. This demo shows how to +copy and paste text to and from the clipboard. +=end + +require 'common' + +module Demo + class Clipboard < Demo::BasicWindow + def initialize + super('Clipboard') + + unless Gtk.check_version?(2, 2, 0) + add(Gtk::Label.new("This sample requires GTK+ 2.2.0 or later")) + return + end + + vbox = Gtk::VBox.new(false, 0) + vbox.border_width = 8 + + add(vbox) + + label = Gtk::Label.new(%Q["Copy" will copy the text\nin the entry to the clipboard]) + + vbox.pack_start(label, false, false, 0) + + hbox = Gtk::HBox.new(false, 0) + hbox.border_width = 8 + vbox.pack_start(hbox, false, false, 0) + + # Create the first entry + entry = Gtk::Entry.new + hbox.pack_start(entry, true, true, 0) + + # Create the button + button = Gtk::Button.new(Gtk::Stock::COPY) + hbox.pack_start(button, false, false, 0) + button.signal_connect('clicked', entry) do |w, e| + clipboard = e.get_clipboard(Gdk::Selection::CLIPBOARD) + clipboard.text = e.text + end + + label = Gtk::Label.new(%Q["Paste" will paste the text from the clipboard to the entry]) + vbox.pack_start(label, false, false, 0) + + hbox = Gtk::HBox.new(false, 4) + hbox.border_width = 8 + vbox.pack_start(hbox, false, false, 0) + + # Create the second entry + entry = Gtk::Entry.new + hbox.pack_start(entry, true, true, 0) + + # Create the button + button = Gtk::Button.new(Gtk::Stock::PASTE) + hbox.pack_start(button, false, false, 0) + button.signal_connect('clicked', entry) do |w, e| + clipboard = e.get_clipboard(Gdk::Selection::CLIPBOARD) + clipboard.request_text do |board, text, data| + e.text = text + end + end + + end + end +end + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/colorsel.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/colorsel.rb new file mode 100644 index 0000000..69f1249 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/colorsel.rb @@ -0,0 +1,84 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: colorsel.rb,v 1.4 2005/02/12 23:02:43 kzys Exp $ +=begin += Color Selector + +Gtk::ColorSelection lets the user choose a color. Gtk::ColorSelectionDialog +is a prebuilt dialog containing a Gtk::ColorSelection. +=end +require 'common' + +module Demo + class ColorSel < BasicWindow + def initialize + super('Color Selection') + + @color = Gdk::Color.new(0, 0, 65535) + + set_border_width(8) + + vbox = Gtk::VBox.new(false, 0) + vbox.set_border_width(8) + add(vbox) + + ## Create the color swatch area + @frame = Gtk::Frame.new + @frame.set_shadow_type(Gtk::SHADOW_IN) + vbox.pack_start(@frame, true, true, 0) + + @da = Gtk::DrawingArea.new + + @da.signal_connect('expose_event') do |widget, event| + if widget.window + style = widget.style + + widget.window.draw_rectangle(style.bg_gc(Gtk::STATE_NORMAL), + true, + event.area.x, event.area.y, + event.area.width, event.area.height) + end + end + + # set a minimum size + @da.set_size_request(200, 200) + # set the color + @da.modify_bg(Gtk::STATE_NORMAL, @color) + + @frame.add(@da) + + alignment = Gtk::Alignment.new(1.0, 0.5, 0.0, 0.0) + + button = Gtk::Button.new('_Change the above color', true) + alignment.add(button) + + vbox.pack_start(alignment, false, false, 0) + + button.signal_connect('clicked') do + change_color_callback + end + end + + def change_color_callback + dialog = Gtk::ColorSelectionDialog.new('Changing color') + + dialog.set_transient_for(self) + + colorsel = dialog.colorsel + + colorsel.set_previous_color(@color) + colorsel.set_current_color(@color) + colorsel.set_has_palette(true) + + response = dialog.run + + if response == Gtk::Dialog::RESPONSE_OK + @color = colorsel.current_color + @da.modify_bg(Gtk::STATE_NORMAL, @color) + end + + dialog.destroy + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/common.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/common.rb new file mode 100644 index 0000000..d66969d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/common.rb @@ -0,0 +1,88 @@ +=begin + common.rb - Common class for gtk-demo. + + Copyright (c) 2003-2005 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: common.rb,v 1.9 2005/10/15 03:41:36 mutoh Exp $ +=end + +require 'gtk2' + +module Demo + def self.find_file(basename) + %w(. /usr/share/gtk-2.0/demo /usr/local/share/gtk-2.0/demo/).each do |dirname| + path = File.join(dirname, basename) + if File.exist?(path) + return path + end + end + + raise "#{basename}: No such file or directory" + end + + class BasicWindow < Gtk::Window + def initialize(title = nil) + super(Gtk::Window::TOPLEVEL) + if title + set_title("#{title} in Ruby/GTK") + end + + signal_connect("key_press_event") do |widget, event| + if event.state.control_mask? and event.keyval == Gdk::Keyval::GDK_q + destroy + true + else + false + end + end + + signal_connect("delete_event") do |widget, event| + quit + end + end + + def quit + destroy + true + end + end + + class CairoWindow < BasicWindow + + def initialize(title=nil) + super + + unless Gdk.cairo_available? + add_cairo_require_label + return + end + + drawing_area = Gtk::DrawingArea.new + add(drawing_area) + + drawing_area.signal_connect("expose_event") do |widget, event| + cr = widget.window.create_cairo_context + cr.scale(*widget.window.size) + cr.set_line_width(0.04) + + cr.save do + cr.set_source_color(Gdk::Color.new(65535, 65535, 65535)) + cr.gdk_rectangle(Gdk::Rectangle.new(0, 0, 1, 1)) + cr.fill + end + + draw(cr) + end + end + + def add_cairo_require_label + message = "This sample requires GTK+ 2.8.0 or later and cairo support" + add(Gtk::Label.new(message)) + end + + def draw(cr) + raise "not implemented" + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/demo.ui b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/demo.ui new file mode 100644 index 0000000..9d27c85 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/demo.ui @@ -0,0 +1,258 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<interface> + <object class="GtkListStore" id="liststore1"> + <columns> + <column type="gchararray"/> + <column type="gchararray"/> + <column type="gint"/> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0">John</col> + <col id="1">Doe</col> + <col id="2">25</col> + <col id="3">This is the John Doe row</col> + </row> + <row> + <col id="0">Mary</col> + <col id="1">Dole</col> + <col id="2">50</col> + <col id="3">This is the Mary Dole row</col> + </row> + </data> + </object> + <object class="GtkUIManager" id="uimanager"> + <child> + <object class="GtkActionGroup" id="DefaultActions"> + <child> + <object class="GtkAction" id="Copy"> + <property name="name">Copy</property> + <property name="tooltip" translatable="yes">Copy selected object into the clipboard</property> + <property name="stock_id">gtk-copy</property> + </object> + </child> + <child> + <object class="GtkAction" id="Cut"> + <property name="name">Cut</property> + <property name="tooltip" translatable="yes">Cut selected object into the clipboard</property> + <property name="stock_id">gtk-cut</property> + </object> + </child> + <child> + <object class="GtkAction" id="EditMenu"> + <property name="name">EditMenu</property> + <property name="label" translatable="yes">_Edit</property> + </object> + </child> + <child> + <object class="GtkAction" id="FileMenu"> + <property name="name">FileMenu</property> + <property name="label" translatable="yes">_File</property> + </object> + </child> + <child> + <object class="GtkAction" id="New"> + <property name="name">New</property> + <property name="tooltip" translatable="yes">Create a new file</property> + <property name="stock_id">gtk-new</property> + </object> + </child> + <child> + <object class="GtkAction" id="Open"> + <property name="name">Open</property> + <property name="tooltip" translatable="yes">Open a file</property> + <property name="stock_id">gtk-open</property> + </object> + </child> + <child> + <object class="GtkAction" id="Paste"> + <property name="name">Paste</property> + <property name="tooltip" translatable="yes">Paste object from the Clipboard</property> + <property name="stock_id">gtk-paste</property> + </object> + </child> + <child> + <object class="GtkAction" id="Quit"> + <property name="name">Quit</property> + <property name="tooltip" translatable="yes">Quit the program</property> + <property name="stock_id">gtk-quit</property> + <signal handler="quit_activate" name="activate"/> + </object> + </child> + <child> + <object class="GtkAction" id="Save"> + <property name="name">Save</property> + <property name="is_important">True</property> + <property name="tooltip" translatable="yes">Save a file</property> + <property name="stock_id">gtk-save</property> + </object> + </child> + <child> + <object class="GtkAction" id="SaveAs"> + <property name="name">SaveAs</property> + <property name="tooltip" translatable="yes">Save with a different name</property> + <property name="stock_id">gtk-save-as</property> + </object> + </child> + <child> + <object class="GtkAction" id="HelpMenu"> + <property name="name">HelpMenu</property> + <property name="label" translatable="yes">_Help</property> + </object> + </child> + <child> + <object class="GtkAction" id="About"> + <property name="name">About</property> + <property name="stock_id">gtk-about</property> + <signal handler="about_activate" name="activate"/> + </object> + <accelerator key="F1"/> + </child> + </object> + </child> + <ui> + <menubar name="menubar1"> + <menu action="FileMenu" name="FileMenu"> + <menuitem action="New" name="New"/> + <menuitem action="Open" name="Open"/> + <menuitem action="Save" name="Save"/> + <menuitem action="SaveAs" name="SaveAs"/> + <separator/> + <menuitem action="Quit" name="Quit"/> + </menu> + <menu action="EditMenu"> + <menuitem action="Copy" name="Copy"/> + <menuitem action="Cut" name="Cut"/> + <menuitem action="Paste" name="Paste"/> + </menu> + <menu action="HelpMenu" name="HelpMenu"> + <menuitem action="About" name="About"/> + </menu> + </menubar> + <toolbar name="toolbar1"> + <toolitem action="New" name="New"/> + <toolitem action="Open" name="Open"/> + <toolitem action="Save" name="Save"/> + <separator/> + <toolitem action="Copy" name="Copy"/> + <toolitem action="Cut" name="Cut"/> + <toolitem action="Paste" name="Paste"/> + </toolbar> + </ui> + </object> + <object class="GtkAboutDialog" id="aboutdialog1"> + <property name="program-name" translatable="yes">GtkBuilder demo</property> + <accessibility> + <relation target="window1" type="subwindow-of"/> + </accessibility> + </object> + <object class="GtkWindow" id="window1"> + <property name="default_height">250</property> + <property name="default_width">440</property> + <property name="title">GtkBuilder demo</property> + <child> + <object class="GtkVBox" id="vbox1"> + <property name="visible">True</property> + <child> + <object constructor="uimanager" class="GtkMenuBar" id="menubar1"> + <property name="visible">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="a11y-menubar"> + <property name="AtkObject::accessible-name">The menubar</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <object constructor="uimanager" class="GtkToolbar" id="toolbar1"> + <property name="visible">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="a11y-toolbar"> + <property name="AtkObject::accessible-name">The toolbar</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow1"> + <property name="hscrollbar_policy">automatic</property> + <property name="shadow_type">in</property> + <property name="visible">True</property> + <property name="vscrollbar_policy">automatic</property> + <child> + <object class="GtkTreeView" id="treeview1"> + <property name="visible">True</property> + <property name="model">liststore1</property> + <property name="tooltip-column">3</property> + <child internal-child="accessible"> + <object class="AtkObject" id="a11y-treeview"> + <property name="AtkObject::accessible-name">Name list</property> + <property name="AtkObject::accessible-description"> + A list of person with name, surname and age columns + </property> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="column1"> + <property name="title">Name</property> + <child> + <object class="GtkCellRendererText" id="renderer1"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="column2"> + <property name="title">Surname</property> + <child> + <object class="GtkCellRendererText" id="renderer2"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="column3"> + <property name="title">Age</property> + <child> + <object class="GtkCellRendererText" id="renderer3"/> + <attributes> + <attribute name="text">2</attribute> + </attributes> + </child> + </object> + </child> + </object> + </child> + <accessibility> + <action action_name="move-cursor" description="Move the cursor to select another person."/> + </accessibility> + </object> + <packing> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkStatusbar" id="statusbar1"> + <property name="visible">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="position">3</property> + </packing> + </child> + </object> + </child> + </object> +</interface> diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/dialog.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/dialog.rb new file mode 100644 index 0000000..44b8dcc --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/dialog.rb @@ -0,0 +1,137 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: dialog.rb,v 1.5 2005/02/12 23:02:43 kzys Exp $ +=begin += Dialog and Message Boxes + +Dialog widgets are used to pop up a transient window for user feedback. +=end + +require 'common' + +module Demo + class Dialog < Demo::BasicWindow + def initialize + @count = 1 + + super('Dialogs') + set_border_width(8) + + frame = Gtk::Frame.new('Dialogs') + add(frame) + + vbox = Gtk::VBox.new(false, 8) + vbox.set_border_width(8) + frame.add(vbox) + + # Standard message dialog + hbox = Gtk::HBox.new(false, 0) + vbox.pack_start(hbox, false, false, 0) + button = Gtk::Button.new('_Message Dialog', true) + button.signal_connect('clicked') do + message_dialog_clicked + end + hbox.pack_start(button, false, false, 0) + + vbox.pack_start(Gtk::HSeparator.new, false, false, 0) + + # Interactive dialog + hbox = Gtk::HBox.new(false, 8) + vbox.pack_start(hbox, false, false, 0) + vbox2 = Gtk::VBox.new(false, 0) + + button = Gtk::Button.new('_Interactive Dialog') + button.signal_connect('clicked') do + interactive_dialog_clicked + end + hbox.pack_start(vbox2, false, false, 0) + vbox2.pack_start(button, false, false, 0) + + table = Gtk::Table.new(2, 2, false) + table.set_row_spacings(4) + table.set_column_spacings(4) + hbox.pack_start(table, false, false, 0) + + label = Gtk::Label.new('_Entry 1', true) + table.attach_defaults(label, 0, 1, 0, 1) + + @entry1 = Gtk::Entry.new + table.attach_defaults(@entry1, 1, 2, 0, 1) + label.set_mnemonic_widget(@entry1) + + label = Gtk::Label.new('E_ntry 2', true) + + table.attach_defaults(label, 0, 1, 1, 2) + + @entry2 = Gtk::Entry.new + table.attach_defaults(@entry2, 1, 2, 1, 2) + label.set_mnemonic_widget(@entry2) + end + + def message_dialog_clicked + dialog = Gtk::MessageDialog.new(self, + Gtk::Dialog::MODAL | + Gtk::Dialog::DESTROY_WITH_PARENT, + Gtk::MessageDialog::INFO, + Gtk::MessageDialog::BUTTONS_OK, + <<EOS) +This message box has been popped up the following +number of times: + +#{@count} +EOS + dialog.run + dialog.destroy + @count += 1 + end + + def interactive_dialog_clicked + dialog = Gtk::Dialog.new('Interactive Dialog', + self, + Gtk::Dialog::MODAL | + Gtk::Dialog::DESTROY_WITH_PARENT, + [Gtk::Stock::OK, Gtk::Dialog::RESPONSE_OK], + ["_Non-stock Button", Gtk::Dialog::RESPONSE_CANCEL] + ) + + hbox = Gtk::HBox.new(false, 0) + hbox.set_border_width(8) + dialog.vbox.pack_start(hbox, false, false, 0) + + stock = Gtk::Image.new(Gtk::Stock::DIALOG_QUESTION, Gtk::IconSize::DIALOG) + hbox.pack_start(stock, false, false, 0) + + table = Gtk::Table.new(2, 2, false) + table.set_row_spacings(4) + table.set_column_spacings(4) + hbox.pack_start(table, true, true, 0) + label = Gtk::Label.new('_Entry 1', true) + table.attach_defaults(label, + 0, 1, 0, 1) + local_entry1 = Gtk::Entry.new + local_entry1.text = @entry1.text + table.attach_defaults(local_entry1, 1, 2, 0, 1) + label.set_mnemonic_widget(local_entry1) + + label = Gtk::Label.new('E_ntry 2', true) + table.attach_defaults(label, + 0, 1, 1, 2) + + local_entry2 = Gtk::Entry.new + local_entry2.text = @entry2.text + table.attach_defaults(local_entry2, 1, 2, 1, 2) + label.set_mnemonic_widget(local_entry2) + + hbox.show_all + response = dialog.run + + if response == Gtk::Dialog::RESPONSE_OK + @entry1.text = local_entry1.text + @entry2.text = local_entry2.text + end + dialog.destroy + end + end +end + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/drawingarea.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/drawingarea.rb new file mode 100644 index 0000000..dce981b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/drawingarea.rb @@ -0,0 +1,226 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: drawingarea.rb,v 1.5 2005/02/12 23:02:43 kzys Exp $ +=begin += Drawing Area + +Gtk::DrawingArea is a blank area where you can draw custom displays +of various kinds. + +This demo has two drawing areas. The checkerboard area shows +how you can just draw something; all you have to do is write +a signal handler for expose_event, as shown here. + +The 'scribble' area is a bit more advanced, and shows how to handle +events such as button presses and mouse motion. Click the mouse +and drag in the scribble area to draw squiggles. Resize the window +to clear the area. +=end + +require 'common' + +module Demo + class DrawingArea < BasicWindow + def initialize + # Pixmap for scribble area, to store current scribbles + @pixmap = nil + super('Drawing Area') + + self.border_width = 8 + + vbox = Gtk::VBox.new(false, 8) + vbox.border_width = 8 + add(vbox) + + + ## Create the checkerboard area + label = Gtk::Label.new + label.set_markup('<u>Checkerboard pattern</u>') + vbox.pack_start(label, false, false, 0) + + frame = Gtk::Frame.new + frame.shadow_type = Gtk::SHADOW_IN + vbox.pack_start(frame, true, true, 0) + + da = Gtk::DrawingArea.new + # set a minimum size + da.set_size_request(100, 100) + + frame.add(da) + + da.signal_connect('expose_event') do |widget, event| + checkerboard_expose(widget) + end + + ## Create the scribble area + label = Gtk::Label.new + label.set_markup('<u>Scribble area</u>') + vbox.pack_start(label, false, false, 0) + + frame = Gtk::Frame.new + frame.shadow_type = Gtk::SHADOW_IN + vbox.pack_start(frame, true, true, 0) + + da = Gtk::DrawingArea.new + # set a minimum size + da.set_size_request(100, 100) + + frame.add(da) + + # Signals used to handle backing pixmap + da.signal_connect('expose_event') do |*args| + scribble_expose_event(*args) + end + da.signal_connect('configure_event') do |widget, event| + scribble_configure_event(widget) + end + + # Event signals + da.signal_connect('motion_notify_event') do |*args| + scribble_motion_notify_event(*args) + end + da.signal_connect('button_press_event') do |*args| + scribble_button_press_event(*args) + end + + # Ask to receive events the drawing area doesn't normally + # subscribe to + da.events |= (Gdk::Event::LEAVE_NOTIFY_MASK | + Gdk::Event::BUTTON_PRESS_MASK | + Gdk::Event::POINTER_MOTION_MASK | + Gdk::Event::POINTER_MOTION_HINT_MASK) + end + + # Create a new pixmap of the appropriate size to store our scribbles + def scribble_configure_event(widget) + @pixmap = Gdk::Pixmap.new(self.window, + widget.allocation.width, + widget.allocation.height, + -1) + + # Initialize the pixmap to white + @pixmap.draw_rectangle(widget.style.white_gc, + true, + 0, 0, + widget.allocation.width, + widget.allocation.height) + + # We've handled the configure event, no need for further processing. + return true + end + + CHECK_SIZE = 10 + SPACING = 2 + def checkerboard_expose(da) + # At the start of an expose handler, a clip region of event.area + # is set on the window, and event.area has been cleared to the + # widget's background color. The docs for + # gdk_window_begin_paint_region give more details on how this + # works. + + + # It would be a bit more efficient to keep these + # GC's around instead of recreating on each expose, but + # this is the lazy/slow way. + gc1 = Gdk::GC.new(da.window) + gc1.rgb_fg_color = Gdk::Color.new(30000, 0, 30000) + + gc2 = Gdk::GC.new(da.window) + gc2.rgb_fg_color = Gdk::Color.new(65535, 65535, 65535) + + xcount = 0 + SPACING.step(da.allocation.width, CHECK_SIZE + SPACING) do |i| + ycount = xcount % 2; # start with even/odd depending on row + SPACING.step(da.allocation.height, CHECK_SIZE + SPACING) do |j| + gc = if ycount % 2 == 1 + gc1 + else + gc2 + end + + # If we're outside event.area, this will do nothing. + # It might be mildly more efficient if we handled + # the clipping ourselves, but again we're feeling lazy. + + da.window.draw_rectangle(gc, true, i, j, CHECK_SIZE, CHECK_SIZE) + ycount += 1 + end + xcount += 1 + end + # return true because we've handled this event, so no + # further processing is required. + # + return true + end + + # Redraw the screen from the pixmap + def scribble_expose_event(widget, event) + # We use the 'foreground GC' for the widget since it already exists, + # but honestly any GC would work. The only thing to worry about + # is whether the GC has an inappropriate clip region set. + widget.window.draw_drawable(widget.style.fg_gc(widget.state), + @pixmap, + # Only copy the area that was exposed. + event.area.x, event.area.y, + event.area.x, event.area.y, + event.area.width, event.area.height) + return false + end + + + + def draw_brush(widget, x, y) + update_rect = Gdk::Rectangle.new(x - 3, y - 3, 6, 6) + + # Paint to the pixmap, where we store our state + @pixmap.draw_rectangle(widget.style.black_gc, + true, + update_rect.x, update_rect.y, + update_rect.width, update_rect.height) + + # Now invalidate the affected region of the drawing area. + widget.window.invalidate(update_rect, false) + end + + def scribble_button_press_event(widget, event) + unless @pixmap + # paranoia check, in case we haven't gotten a configure event + return false + end + + if event.button == 1 + draw_brush(widget, event.x, event.y) + end + + # We've handled the event, stop processing + return true + end + + def scribble_motion_notify_event(widget, event) + unless @pixmap + # paranoia check, in case we haven't gotten a configure event + return false + end + + # This call is very important; it requests the next motion event. + # If you don't call Gdk::Window#pointer you'll only get + # a single motion event. The reason is that we specified + # Gdk::POINTER_MOTION_HINT_MASK to Gtk::Widget#set_events. + # If we hadn't specified that, we could just use event.x, event.y + # as the pointer location. But we'd also get deluged in events. + # By requesting the next event as we handle the current one, + # we avoid getting a huge number of events faster than we + # can cope. + + win, x, y, state = event.window.pointer + + if (state & Gdk::Window::BUTTON1_MASK) != 0 + draw_brush(widget, x, y) + end + + # We've handled it, stop processing + return true + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/editable_cells.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/editable_cells.rb new file mode 100644 index 0000000..367f087 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/editable_cells.rb @@ -0,0 +1,172 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: editable_cells.rb,v 1.7 2005/02/06 18:25:13 kzys Exp $ +=begin += Tree View/Editable Cells + +This demo demonstrates the use of editable cells in a Gtk::TreeView. If +you're new to the Gtk::TreeView widgets and associates, look into +the Gtk::ListStore example first. +=end +require 'common' + +module Demo + class EditableCells < BasicWindow + Item = Struct.new('Item', :number, :product, :editable) + COLUMN_NUMBER, COLUMN_PRODUCT, COLUMN_EDITABLE, NUM_COLUMNS = *(0..4).to_a + + def initialize + super('Shopping list') + self.border_width = 5 + + vbox = Gtk::VBox.new(false, 5) + add(vbox) + + vbox.pack_start(Gtk::Label.new('Shopping list (you can edit the cells!)'), + false, false, 0) + + sw = Gtk::ScrolledWindow.new + sw.shadow_type = Gtk::SHADOW_ETCHED_IN + sw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) + vbox.pack_start(sw, true, true, 0) + + # create model + model = create_model + + # create tree view + treeview = Gtk::TreeView.new(model) + treeview.rules_hint = true + treeview.selection.mode = Gtk::SELECTION_SINGLE + + add_columns(treeview) + + sw.add(treeview) + + # some buttons + hbox = Gtk::HBox.new(true, 4) + vbox.pack_start(hbox, false, false, 0) + + button = Gtk::Button.new('Add item') + button.signal_connect('clicked') do + add_item(model) + end + hbox.pack_start(button, true, true, 0) + + button = Gtk::Button.new('Remove item') + button.signal_connect('clicked') do + remove_item(treeview) + end + hbox.pack_start(button, true, true, 0) + + set_default_size(320, 200) + end + + def create_model + # create array + @articles = [] + + add_items + + # create list store + model = Gtk::ListStore.new(Integer, String, TrueClass) + + # add items + @articles.each do |article| + iter = model.append + + article.each_with_index do |value, index| + iter.set_value(index, value) + end + end + return model + end + + def add_items + item = Item.new(3, 'bottles of coke', true) + @articles.push(item) + + item = Item.new(5, 'packages of noodles', true) + @articles.push(item) + + item = Item.new(2, 'packages of chocolate chip cookies', true) + @articles.push(item) + + item = Item.new(1, 'can vanilla ice cream', true) + @articles.push(item) + + item = Item.new(6, 'eggs', true) + @articles.push(item) + end + + def add_columns(treeview) + model = treeview.model + + # number column + renderer = Gtk::CellRendererText.new + renderer.signal_connect('edited') do |*args| + cell_edited(*args.push(model)) + end + treeview.insert_column(-1, 'Number', renderer, + { + :text => COLUMN_NUMBER, + :editable => COLUMN_EDITABLE, + }) + def renderer.column + COLUMN_NUMBER + end + + # product column + renderer = Gtk::CellRendererText.new + renderer.signal_connect('edited') do |*args| + cell_edited(*args.push(model)) + end + def renderer.column + COLUMN_PRODUCT + end + treeview.insert_column(-1, 'Product', renderer, + { + :text => COLUMN_PRODUCT, + :editable => COLUMN_EDITABLE, + }) + end + + def cell_edited(cell, path_string, new_text, model) + path = Gtk::TreePath.new(path_string) + + column = cell.column + + iter = model.get_iter(path) + case column + when COLUMN_NUMBER + i = iter.path.indices[0] + @articles[i].number = new_text.to_i + iter.set_value(column, @articles[i].number) + when COLUMN_PRODUCT + i = iter.path.indices[0] + @articles[i].product = new_text + iter.set_value(column, @articles[i].product) + end + end + + def add_item(model) + foo = Item.new(0, 'Description here', true) + @articles.concat([foo]) + + iter = model.append + foo.each_with_index do |value, index| + iter.set_value(index, value) + end + end + + def remove_item(treeview) + model = treeview.model + selection = treeview.selection + + if iter = selection.selected + @articles.delete_at(iter.path.indices[0]) + model.remove(iter) + end + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/entry_completion.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/entry_completion.rb new file mode 100644 index 0000000..4e698ad --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/entry_completion.rb @@ -0,0 +1,63 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# $Id: entry_completion.rb,v 1.3 2005/02/25 17:09:24 kzys Exp $ +=begin += Entry Completion (EntryCompletion) + +GtkEntryCompletion provides a mechanism for adding support for +completion in GtkEntry. +=end + +require 'common' + +module Demo + class EntryCompletion < Gtk::Dialog + def initialize + super('GtkEntryCompletion', + nil, # parent + 0, + [Gtk::Stock::CLOSE, Gtk::Dialog::RESPONSE_NONE]) + + self.resizable = false + + signal_connect('response') do + self.destroy + end + + vbox = Gtk::VBox.new(false, 5) + self.vbox.pack_start(vbox, true, true) + vbox.border_width = 5 + + label = Gtk::Label.new + label.markup = 'Completion demo, try writing <b>total</b> or <b>gnome</b> for example' + vbox.pack_start(label, false, false) + + # Create our entry + entry = Gtk::Entry.new + vbox.pack_start(entry, false, false) + + # Create the completion object + completion = Gtk::EntryCompletion.new + + # Assign the completion to the entry + entry.completion = completion + + # Create a tree model and use it as the completion model + completion.model = create_completion_model + + # Use model column 0 as the text column + completion.text_column = 0 + end + + + def create_completion_model + store = Gtk::ListStore.new(String) + %w(GNOME total totally).each do |word| + iter = store.append + iter[0] = word + end + + store + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/expander.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/expander.rb new file mode 100644 index 0000000..76b06bb --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/expander.rb @@ -0,0 +1,40 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# $Id: expander.rb,v 1.2 2005/02/25 17:09:25 kzys Exp $ +=begin += Expander (Expander) + +GtkExpander allows to provide additional content that is initially hidden. +This is also known as "disclosure triangle". +=end + +require 'common' + +module Demo + class Expander < Gtk::Dialog + def initialize + super('GtkExpander', + nil, # parent + 0, + [Gtk::Stock::CLOSE, Gtk::Dialog::RESPONSE_NONE]) + self.resizable = false + + signal_connect('response') do + self.destroy + end + + vbox = Gtk::VBox.new(false, 5) + self.vbox.pack_start(vbox, true, true) + vbox.border_width = 5 + + label = Gtk::Label.new('Expander demo. CLick on the triangle for details.') + vbox.pack_start(label, false, false) + + # Create the expander + expander = Gtk::Expander.new('Details') + vbox.pack_start(expander, false, false) + + expander.add(Gtk::Label.new('Details can be shown or hidden.')) + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/floppybuddy.gif b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/floppybuddy.gif new file mode 100644 index 0000000..ac986c8 Binary files /dev/null and b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/floppybuddy.gif differ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-applets.png b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-applets.png new file mode 100644 index 0000000..8d3549e Binary files /dev/null and b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-applets.png differ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-calendar.png b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-calendar.png new file mode 100644 index 0000000..889f329 Binary files /dev/null and b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-calendar.png differ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-foot.png b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-foot.png new file mode 100644 index 0000000..0476658 Binary files /dev/null and b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-foot.png differ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-fs-directory.png b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-fs-directory.png new file mode 100644 index 0000000..05921a6 Binary files /dev/null and b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-fs-directory.png differ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-fs-regular.png b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-fs-regular.png new file mode 100644 index 0000000..0f5019c Binary files /dev/null and b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-fs-regular.png differ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-gimp.png b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-gimp.png new file mode 100644 index 0000000..f6bbc6d Binary files /dev/null and b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-gimp.png differ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-gmush.png b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-gmush.png new file mode 100644 index 0000000..0a4b0d0 Binary files /dev/null and b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-gmush.png differ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-gsame.png b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-gsame.png new file mode 100644 index 0000000..01c0611 Binary files /dev/null and b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnome-gsame.png differ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnu-keys.png b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnu-keys.png new file mode 100644 index 0000000..58a3377 Binary files /dev/null and b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gnu-keys.png differ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gtk-logo-rgb.gif b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gtk-logo-rgb.gif new file mode 100644 index 0000000..63c622b Binary files /dev/null and b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/gtk-logo-rgb.gif differ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/hypertext.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/hypertext.rb new file mode 100644 index 0000000..aca83a6 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/hypertext.rb @@ -0,0 +1,211 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: hypertext.rb,v 1.2 2005/12/01 09:27:01 ktou Exp $ +=begin += Text Widget/Hypertext + +Usually, tags modify the appearance of text in the view, e.g. making it +bold or colored or underlined. But tags are not restricted to appearance. +They can also affect the behavior of mouse and key presses, as this demo +shows. +=end + +require 'common' + +module Demo + class Hypertext < BasicWindow + def initialize + super('Hypertext') + + @hand_cursor = Gdk::Cursor.new(Gdk::Cursor::HAND2) + @regular_cursor = Gdk::Cursor.new(Gdk::Cursor::XTERM) + @hovering = false + + set_default_size(450, 450) + self.border_width = 0 + + view = Gtk::TextView.new + + view.wrap_mode = Gtk::TextTag::WRAP_WORD + + view.signal_connect('key-press-event') do |*args| + key_press_event(*args) + end + view.signal_connect('event-after') do |*args| + event_after(*args) + end + view.signal_connect('motion-notify-event') do |*args| + motion_notify_event(*args) + end + view.signal_connect('visibility-notify-event') do |*args| + visibility_notify_event(*args) + end + + buffer = view.buffer + + sw = Gtk::ScrolledWindow.new + sw.set_policy(Gtk::POLICY_AUTOMATIC, + Gtk::POLICY_AUTOMATIC) + + add(sw) + sw.add(view) + + show_page(buffer, 1) + end + + + # Inserts a piece of text into the buffer, giving it the usual + # appearance of a hyperlink in a web browser: blue and underlined. + # Additionally, attaches some data on the tag, to make it recognizable + # as a link. + def insert_link(buffer, iter, text, page) + tag = buffer.create_tag(nil, + { + 'foreground' => 'blue', + 'underline' => Pango::AttrUnderline::SINGLE, + }) + tag.page = page + + buffer.insert(iter, text, tag) + print("Insert #{tag}:#{page}\n") + end + + # Fills the buffer with text and interspersed links. In any real + # hypertext app, this method would parse a file to identify the links. + def show_page(buffer, page) + puts + + buffer.text = '' + iter = buffer.get_iter_at_offset(0) + + case page + when 1 + buffer.insert(iter, 'Some text ot show that simple ') + insert_link(buffer, iter, 'hypertext', 3) + buffer.insert(iter, ' can easily be realized with ') + insert_link(buffer, iter, 'tags', 2) + buffer.insert(iter, '.') + when 2 + buffer.insert(iter, + %Q[A tag is an attribute that can be applied to some range of text. For example, a tag might be called "bold" and make the text insid the tag bold. However, the tag concept is more general than that; tags don't have to affect appearance. They can instead affect the behavior of mouse and key presses, "lock" a range of text so the user can't edit it, or countless other things.]) + buffer.insert(iter, "\n") + insert_link(buffer, iter, 'Go back', 1) + when 3 + tag = buffer.create_tag(nil, + { + 'weight' => + Pango::FontDescription::WEIGHT_BOLD + }) + buffer.insert(iter, "hypertext:\n", tag); + buffer.insert(iter, %Q[machine-readable text that is not sequential but is organized so that related items of information are connected.\n]) + insert_link(buffer, iter, 'Go back', 1) + end + end + + # Looks at all tags covering the position of iter in the text view, + # and if one of them is a link, follow it by showing the page identified + # by the data attached to it. + def follow_if_link(text_view, iter) + tags = iter.tags + tags.each do |tag| + print("Follow #{tag}:#{tag.page}\n") + if tag.page + show_page(text_view.buffer, tag.page) + break + end + end + end + + # Links can be activated by pressing Enter. + def key_press_event(text_view, event) + case event.keyval + when Gdk::Keyval::GDK_Return, Gdk::Keyval::GDK_KP_Enter + buffer = text_view.buffer + iter = buffer.get_iter_at_mark(buffer.get_mark("insert")) + follow_if_link(text_view, iter) + end + + false + end + + # Links can also be activated by clicking. + def event_after(text_view, event) + unless event.kind_of?(Gdk::EventButton) and event.button == 1 + return false + end + + buffer = text_view.buffer + + # we shouldn't follow a link if the user has selected something + range = buffer.selection_bounds + if range and range[0].offset != range[1].offset + return false + end + + x, y = text_view.window_to_buffer_coords(Gtk::TextView::WINDOW_WIDGET, + event.x, event.y) + iter = text_view.get_iter_at_location(x, y) + + follow_if_link(text_view, iter) + end + + # Looks at all tags covering the position (x, y) in the text view, + # and if one of them is a link, change the cursor to the "hands" cursor + # typically used by web browsers. + def set_cursor_if_appropriate(text_view, x, y) + + buffer = text_view.buffer + iter = text_view.get_iter_at_location(x, y) + + hovering = false + + tags = iter.tags + tags.each do |t| + if t.page + hovering = true + break + end + end + + if hovering != @hovering + @hovering = hovering + + window = text_view.get_window(Gtk::TextView::WINDOW_TEXT) + + window.cursor = if @hovering + @hand_cursor + else + @regular_cursor + end + end + end + + # Update the cursor image if the pointer moved. + def motion_notify_event(text_view, event) + x, y = text_view.window_to_buffer_coords(Gtk::TextView::WINDOW_WIDGET, + event.x, event.y) + set_cursor_if_appropriate(text_view, x, y) + text_view.window.pointer + + false + end + + # Also update the cursor image if the window becomes visible + # (e.g. when a window covering it got iconified). + def visibility_notify_event (text_view, event) + window, wx, wy = text_view.window.pointer + bx, by = text_view.window_to_buffer_coords(Gtk::TextView::WINDOW_WIDGET, + wx, wy) + set_cursor_if_appropriate(text_view, bx, by) + + false + end + end +end + +module Gtk + class TextTag + attr_accessor :page + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/iconview.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/iconview.rb new file mode 100644 index 0000000..cb2ac9c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/iconview.rb @@ -0,0 +1,109 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: iconview.rb,v 1.7 2007/08/05 15:41:31 mutoh Exp $ +=begin += Icon View (IconView) + +The Gtk::IconView widget is used to display and manipulate icons. +It uses a Gtk::TreeModel for data storage, so the list store example +might be helpful. +=end +$KCODE="u" +require 'common' + +module Demo + class IconView < Demo::BasicWindow + COL_PATH, COL_DISPLAY_NAME, COL_IS_DIR, COL_PIXBUF = (0..3).to_a + + def fill_store + @store.clear + Dir.glob(File.join(@parent, "*")).each do |path| + is_dir = FileTest.directory?(path) + iter = @store.append + # set COL_DISPLAY_NAME first because changing an iter will trigger the + # sort function; if we set something else first, the value of + # COL_DISPLAY_NAME for this row will be "nil" and the sort function will fail +puts path +#puts GLib.convert(GLib.filename_to_utf8(path), "Shift_JIS", "UTF-8") +#puts File.basename(GLib.convert(GLib.filename_to_utf8(path), "Shift_JIS", "UTF-8")) +# iter[COL_DISPLAY_NAME] = File.basename(GLib.filename_to_utf8(path)) + iter[COL_DISPLAY_NAME] = GLib.filename_to_utf8(path) + iter[COL_PATH] = path + iter[COL_IS_DIR] = is_dir + iter[COL_PIXBUF] = is_dir ? @folder_pixbuf : @file_pixbuf + end + end + + def initialize + super('Gtk::IconView demo') + @file_pixbuf = Gdk::Pixbuf.new(Demo.find_file("gnome-fs-regular.png")) + @folder_pixbuf = Gdk::Pixbuf.new(Demo.find_file("gnome-fs-directory.png")) + + @store = Gtk::ListStore.new(String, String, TrueClass, Gdk::Pixbuf) + @parent = "/" + + @store.set_default_sort_func do |a, b| + if !a[COL_IS_DIR] and b[COL_IS_DIR] + 1 + elsif a[COL_IS_DIR] and !b[COL_IS_DIR] + -1 + else + a[COL_DISPLAY_NAME] <=> b[COL_DISPLAY_NAME] + end + end + @store.set_sort_column_id(Gtk::TreeSortable::DEFAULT_SORT_COLUMN_ID, + Gtk::SORT_ASCENDING) + + fill_store + set_default_size(650, 400) + set_border_width(8) + + vbox = Gtk::VBox.new(false, 0) + add(vbox) + + toolbar = Gtk::Toolbar.new + vbox.pack_start(toolbar, false, false, 0) + + up_button = Gtk::ToolButton.new(Gtk::Stock::GO_UP) + up_button.important = true + up_button.sensitive = false + toolbar.insert(-1, up_button) + up_button.signal_connect("clicked") do + @parent = File.dirname(@parent) + fill_store + up_button.sensitive = @parent != "/" + end + + home_button = Gtk::ToolButton.new(Gtk::Stock::HOME) + home_button.important = true + toolbar.insert(-1, home_button) + home_button.signal_connect("clicked") do + @parent = GLib.home_dir + fill_store + up_button.sensitive = true + end + + sw = Gtk::ScrolledWindow.new + sw.shadow_type = Gtk::SHADOW_ETCHED_IN + sw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) + vbox.pack_start(sw, true, true, 0) + + iconview = Gtk::IconView.new(@store) + iconview.selection_mode = Gtk::SELECTION_MULTIPLE + iconview.text_column = COL_DISPLAY_NAME + iconview.pixbuf_column = COL_PIXBUF + iconview.signal_connect("item_activated") do |iview, path| + iter = @store.get_iter(path) + if iter[COL_DISPLAY_NAME] + @parent = iter[COL_PATH] + fill_store + up_button.sensitive = true + end + end + sw.add(iconview) + iconview.grab_focus + end + end +end + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/images.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/images.rb new file mode 100644 index 0000000..e0edb91 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/images.rb @@ -0,0 +1,197 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: images.rb,v 1.5 2006/04/08 12:30:03 mutoh Exp $ +=begin += Images + +Gtk::Image is used to display an image; the image can be in a number of formats. +Typically, you load an image into a Gdk::Pixbuf, then display the pixbuf. + +This demo code shows some of the more obscure cases, in the simple +case a call to Gtk::Image.new is all you need. + +If you want to put image data in your program as a String variable, +use the make-inline-pixbuf program that comes with GTK+. +This way you won't need to depend on loading external files, your +application binary can be self-contained. +=end +require 'common' + +module Demo + class Images < BasicWindow + def initialize + @pixbuf_loader = nil + @load_timeout = 0 + @image_stream = nil + + super('Images') + signal_connect('destroy') do + cleanup_callback + end + + self.border_width = 8 + + vbox = Gtk::VBox.new(false, 8) + vbox.border_width = 8 + add(vbox) + + label = Gtk::Label.new + label.set_markup('<u>Image loaded from a file</u>') + vbox.pack_start(label, false, false, 0) + + frame = Gtk::Frame.new + frame.shadow_type = Gtk::SHADOW_IN + + # The alignment keeps the frame from growing when users resize + # the window + align = Gtk::Alignment.new(0.5, 0.5, 0, 0) + align.add(frame) + vbox.pack_start(align, false, false, 0) + + # demo_find_file looks in the the current directory first, + # so you can run gtk-demo without installing GTK, then looks + # in the location where the file is installed. + pixbuf = nil + begin + filename = Demo.find_file('gtk-logo-rgb.gif') + pixbuf = Gdk::Pixbuf.new(filename) + rescue + # This code shows off error handling. You can just use + # Gtk::Image.new instead if you don't want to report + # errors to the user. If the file doesn't load when using + # Gtk::Image.new, a 'missing image' icon will + # be displayed instead. + dialog = Gtk::MessageDialog.new(self, + Gtk::Dialog::DESTROY_WITH_PARENT, + Gtk::MessageDialog::ERROR, + Gtk::MessageDialog::BUTTONS_CLOSE, + "Unable to open image file 'gtk-logo-rgb.gif': #{$1}") + + dialog.signal_connect('response') do |widget, data| + widget.destroy + end + dialog.show + end + + image = Gtk::Image.new(pixbuf) + frame.add(image) + + + # Animation + label = Gtk::Label.new + label.set_markup('<u>Animation loaded from a file</u>') + vbox.pack_start(label, false, false, 0) + + frame = Gtk::Frame.new + frame.shadow_type = Gtk::SHADOW_IN + + # The alignment keeps the frame from growing when users resize + # the window + align = Gtk::Alignment.new(0.5, 0.5, 0, 0) + align.add(frame) + vbox.pack_start(align, false, false, 0) + + filename = Demo.find_file('floppybuddy.gif') + image = Gtk::Image.new(filename) + frame.add(image) + + + # Progressive + label = Gtk::Label.new + label.set_markup('<u>Progressive image loading</u>') + vbox.pack_start(label, false, false, 0) + + frame = Gtk::Frame.new(nil) + frame.shadow_type = Gtk::SHADOW_IN + + # The alignment keeps the frame from growing when users resize + # the window + align = Gtk::Alignment.new(0.5, 0.5, 0, 0) + align.add(frame) + vbox.pack_start(align, false, false, 0) + + # Create an empty image for now; the progressive loader + # will create the pixbuf and fill it in. + image = Gtk::Image.new + frame.add(image) + + start_progressive_loading(image) + + # Sensitivity control + button = Gtk::ToggleButton.new('_Insensitive', true) + vbox.pack_start(button, false, false, 0) + + button.signal_connect('toggled') do |widget| + vbox.children.each do |widget| + if widget != button + widget.sensitive = ! button.active? + end + end + end + end + + def start_progressive_loading(image) + @load_timeout = Gtk.timeout_add(150) do + progressive_timeout(image) + end + end + + def progressive_timeout(image) + if @image_stream + buf = @image_stream.read(256) + + @pixbuf_loader.write(buf) + + if @image_stream.eof? + @image_stream.close + @image_stream = nil + + @pixbuf_loader.close + @pixbuf_loader = nil + end + else + filename = Demo.find_file('alphatest.png') + @image_stream = File.open(filename, 'rb') + + if @pixbuf_loader != nil + @pixbuf_loader.close + @pixbuf_loader = nil + end + + @pixbuf_loader = Gdk::PixbufLoader.new + + @pixbuf_loader.signal_connect('area_prepared') do |loader| + pixbuf = loader.pixbuf + + # Avoid displaying random memory contents, since the pixbuf + # isn't filled in yet. + pixbuf.fill!(0xaaaaaaff) + + image.pixbuf = pixbuf + end + + @pixbuf_loader.signal_connect('area_updated') do + # We know the pixbuf inside the Gtk::Image has changed, but the image + # itself doesn't know this; so queue a redraw. If we wanted to be + # really efficient, we could use a drawing area or something + # instead of a Gtk::Image, so we could control the exact position of + # the pixbuf on the display, then we could queue a draw for only + # the updated area of the image. + image.queue_draw + end + end + + # leave timeout installed + return true + end + + def cleanup_callback + @pixbuf_loader.close if @pixbuf_loader + @pixbuf_loader = nil + if @load_timeout != 0 + Gtk.timeout_remove(@load_timeout) + end + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/item_factory.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/item_factory.rb new file mode 100644 index 0000000..6fecc1f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/item_factory.rb @@ -0,0 +1,94 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: item_factory.rb,v 1.4 2005/02/12 23:02:43 kzys Exp $ +=begin += Item Factory + +The Gtk::ItemFactory object allows the easy creation of menus +from an array of descriptions of menu items. +=end +require 'common' + +module Demo + class ItemFactory < BasicWindow + def initialize + super('Item Factory') + + accel_group = Gtk::AccelGroup.new + item_factory = Gtk::ItemFactory.new(Gtk::ItemFactory::TYPE_MENU_BAR, + '<main>', accel_group) + + add_accel_group(accel_group) + set_border_width(0) + ifactory_cb = proc do |data, widget| + puts "ItemFactory: activated \"#{Gtk::ItemFactory.path_from_widget(widget)}\"" + end + menu_items = [ + ['/_File'], + ['/File/tearoff1', + '<Tearoff>', nil, nil, ifactory_cb], + ['/File/_New', + '<Item>', '<control>N', nil, ifactory_cb], + ['/File/_Open', + '<Item>', '<control>O', nil, ifactory_cb], + ['/File/_Save', + '<Item>', '<control>S', nil, ifactory_cb], + ['/File/Save _As...', + '<Item>', nil, nil, ifactory_cb], + ['/File/sep1', '<Separator>'], + ['/File/_Quit', + '<Item>', '<control>Q', nil, ifactory_cb], + + ['/_Preferences'], + ['/_Preferences/_Color'], + [ '/_Preferences/Color/_Red', + '<RadioItem>', nil, nil, ifactory_cb], + ['/_Preferences/Color/_Green', + '/Preferences/Color/Red', nil, nil, ifactory_cb], + ['/_Preferences/Color/_Blue', + '/Preferences/Color/Red', nil, nil, ifactory_cb], + ['/_Preferences/_Shape'], + ['/_Preferences/Shape/_Square', + '<RadioItem>', nil, nil, ifactory_cb], + [ '/_Preferences/Shape/_Rectangle', + '/Preferences/Shape/Square', nil, nil, ifactory_cb], + [ '/_Preferences/Shape/_Oval', + '/Preferences/Shape/Rectangle', nil, nil, ifactory_cb], + + [ '/_Help', '<LastBranch>'], + [ '/Help/_About', '<Item>', nil, nil, ifactory_cb], + ] + item_factory.create_items(menu_items) + + item_factory.get_item('/Preferences/Shape/Oval').set_active(true) + + box1 = Gtk::VBox.new(false, 0) + add(box1) + + box1.pack_start(item_factory.get_widget('<main>'), false, false, 0) + + label = Gtk::Label.new("Type\n<alt>\nto start") + label.set_size_request(200, 200) + label.set_alignment(0.5, 0.5) + box1.pack_start(label, true, true, 0) + + separator = Gtk::HSeparator.new + box1.pack_start(separator) + + + box2 = Gtk::VBox.new(false, 10) + box2.set_border_width(10) + box1.pack_start(box2, false, true, 0) + + button = Gtk::Button.new('close') + # TODO: Need signal_connect_swapped? + button.signal_connect('clicked') do + quit + end + box2.pack_start(button, true, true, 0) + button.set_flags(Gtk::Widget::CAN_DEFAULT) + button.grab_default + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/list_store.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/list_store.rb new file mode 100644 index 0000000..29bfa4c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/list_store.rb @@ -0,0 +1,138 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: list_store.rb,v 1.5 2005/02/06 18:25:13 kzys Exp $ +=begin += Tree View/List Store + +The Gtk::ListStore is used to store data in list form, to be used +later on by a Gtk::TreeView to display it. This demo builds a +simple Gtk::ListStore and displays it. See the Stock Browser +demo for a more advanced example. +=end +require 'common' + +module Demo + class ListStore < BasicWindow + Bug = Struct.new('Bug', :fixed, :number, :severity, :description) + COLUMN_FIXED, COLUMN_NUMBER, COLUMN_SEVERITY, COLUMN_DESCRIPTION, + NUM_COLUMNS = *(0..5).to_a + DATA = [ + [ false, 60482, 'Normal', 'scrollable notebooks and hidden tabs' ], + [ false, 60620, 'Critical', 'gdk_window_clear_area (gdkwindow-win32.c) is not thread-safe' ], + [ false, 50214, 'Major', 'Xft support does not clean up correctly' ], + [ true, 52877, 'Major', 'GtkFileSelection needs a refresh method. ' ], + [ false, 56070, 'Normal', "Can't click button after setting in sensitive" ], + [ true, 56355, 'Normal', 'GtkLabel - Not all changes propagate correctly' ], + [ false, 50055, 'Normal', 'Rework width/height computations for TreeView' ], + [ false, 58278, 'Normal', "gtk_dialog_set_response_sensitive doesn't work" ], + [ false, 55767, 'Normal', 'Getters for all setters' ], + [ false, 56925, 'Normal', 'Gtkcalender size' ], + [ false, 56221, 'Normal', 'Selectable label needs right-click copy menu' ], + [ true, 50939, 'Normal', 'Add shift clicking to GtkTextView' ], + [ false, 6112, 'Enhancement','netscape-like collapsable toolbars' ], + [ false, 1, 'Normal', 'First bug :=)' ], + ].collect do |ary| + Bug.new(*ary) + end + def initialize + super('GtkListStore demo') + self.border_width = 8 + + vbox = Gtk::VBox.new(false, 8) + add(vbox) + + label = Gtk::Label.new('This is the bug list (note: not based on real data, it would be nice to have a nice ODBC interface to bugzilla or so, though).') + vbox.pack_start(label, false, false, 0) + + sw = Gtk::ScrolledWindow.new(nil, nil) + sw.shadow_type = Gtk::SHADOW_ETCHED_IN + sw.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC) + vbox.pack_start(sw, true, true, 0) + + # create tree model + model = create_model + + # create tree view + treeview = Gtk::TreeView.new(model) + treeview.rules_hint = true + treeview.search_column = COLUMN_DESCRIPTION + + sw.add(treeview) + + # add columns to the tree view + add_columns(treeview) + + set_default_size(280, 250) + end + + def create_model + # create list store + store = Gtk::ListStore.new(TrueClass, Integer, String, String) + + # add data to the list store + DATA.each do |bug| + iter = store.append + bug.each_with_index do |value, index| + iter[index] = value + end + end + return store + end + + def add_columns(treeview) + # column for fixed toggles + renderer = Gtk::CellRendererToggle.new + renderer.signal_connect('toggled') do |cell, path| + fixed_toggled(treeview.model, path) + end + + column = Gtk::TreeViewColumn.new('Fixed?', + renderer, + 'active' => COLUMN_FIXED) + + # set this column to a fixed sizing (of 50 pixels) + column.sizing = Gtk::TreeViewColumn::FIXED + column.fixed_width = 50 + treeview.append_column(column) + + # column for bug numbers + renderer = Gtk::CellRendererText.new + column = Gtk::TreeViewColumn.new('Bug number', + renderer, + 'text' => COLUMN_NUMBER) + column.set_sort_column_id(COLUMN_NUMBER) + treeview.append_column(column) + + # column for severities + renderer = Gtk::CellRendererText.new + column = Gtk::TreeViewColumn.new('Severity', + renderer, + 'text' => COLUMN_SEVERITY) + column.set_sort_column_id(COLUMN_SEVERITY) + treeview.append_column(column) + + # column for description + renderer = Gtk::CellRendererText.new + column = Gtk::TreeViewColumn.new('Description', + renderer, + 'text' => COLUMN_DESCRIPTION) + column.set_sort_column_id(COLUMN_DESCRIPTION) + treeview.append_column(column) + end + + def fixed_toggled(model, path_str) + path = Gtk::TreePath.new(path_str) + + # get toggled iter + iter = model.get_iter(path) + fixed =iter[COLUMN_FIXED] + + # do something with the value + fixed ^= 1 + + # set new value + iter[COLUMN_FIXED] = fixed + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/main.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/main.rb new file mode 100755 index 0000000..09b46af --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/main.rb @@ -0,0 +1,382 @@ +#! /usr/bin/env ruby +=begin + main.rb - Main class of gtk-demo. + + Copyright (c) 2003-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: main.rb,v 1.20 2007/07/09 13:21:54 ggc Exp $ +=end + +require 'gtk2' + +$:.unshift(File.dirname(__FILE__)) + +module Demo + + class Main < Gtk::Window + TITLE_COLUMN, FILENAME_COLUMN, CLASS_COLUMN, ITALIC_COLUMN = 0, 1, 2, 3 + + def initialize + super() + + @current_file = nil + + @info_buffer = Gtk::TextBuffer.new + @source_buffer = Gtk::TextBuffer.new + + set_title('Ruby/GTK+ Code Demos') + signal_connect('destroy') do + Gtk.main_quit + end + + signal_connect("key_press_event") do |widget, event| + if event.state.control_mask? and event.keyval == Gdk::Keyval::GDK_q + destroy + true + else + false + end + end + + hbox = Gtk::HBox.new + add(hbox) + + tree = create_tree + scrolled_window = Gtk::ScrolledWindow.new + scrolled_window.add(tree) + hbox.pack_start(scrolled_window, false, false, 0) + + notebook = Gtk::Notebook.new + hbox.pack_start(notebook, true, true, 0) + + notebook.append_page(create_text(@info_buffer, false), + Gtk::Label.new('_Info', true)) + + notebook.append_page(create_text(@source_buffer, true), + Gtk::Label.new('_Source', true)) + + @info_buffer.create_tag('title', + {'font' => 'Sans 18'}) + + @source_buffer.create_tag('comment', + {'foreground' => 'red'}) + @source_buffer.create_tag('const', + {'foreground' => 'ForestGreen'}) + @source_buffer.create_tag('string', + { + 'foreground' => 'RosyBrown', + 'weight' => Pango::FontDescription::WEIGHT_BOLD + }) + @source_buffer.create_tag('reserved', + {'foreground' => 'purple'}) + end + + def script_info(path) + title = nil + klass = nil + depend = nil + + file = File.open(path) + file.each do |ln| + if not title and ln =~ /^=\s+(.*)$/ + title = $1 + if title =~ /^(.*)\((.+?)\)$/ + title = $1 + depend = $2 + end + elsif not klass and ln =~ /\s*class\s+([A-Z][A-Za-z0-9_]*)/ + klass = $1 + end + + if title and klass + break + end + end + + if not klass + raise "File not found: #{path}. This script should be run from its directory." + end + + return title, klass.intern, depend + end + + def generate_index + # Target scripts + scripts = Dir.glob('*.rb') - %w(common.rb main.rb) + + # Generate index tree + children = {} + index = [] + + scripts.each do |fn| + title, klass, depend = script_info(fn) + + if depend and not Gtk.const_defined?(depend) + next + end + + if title =~ %r{^(.+?)/(.+)$} + parent = $1 + child = $2 + + unless children[parent] + children[parent] = [] + index += [[parent, nil, nil, []]] + end + + children[parent] += [[child, fn, klass]] + else + index += [[title, fn, klass]] + end + end + + # Sort children + children.each_key do |parent| + children[parent].sort! do |a, b| + a[0] <=> b[0] + end + end + + # Expand children + index.collect! do |row| + if row[3] + row[3] = children[row[0]] + end + + row + end + + index.sort! do |a, b| + a[0] <=> b[0] + end + + index + end + + def create_tree + model = Gtk::TreeStore.new(String, String, String, TrueClass) + + tree_view = Gtk::TreeView.new + tree_view.set_model(model) + selection = tree_view.selection + + selection.set_mode(Gtk::SELECTION_BROWSE) + tree_view.set_size_request(200, -1) + + append_children(model, generate_index) + + cell = Gtk::CellRendererText.new + cell.style = Pango::FontDescription::STYLE_ITALIC + column = Gtk::TreeViewColumn.new("Widget (double click for demo)", cell, + { + 'text' => TITLE_COLUMN, + 'style_set' => ITALIC_COLUMN, + }) + + tree_view.append_column(column) + + selection.signal_connect('changed') do |selection| + iter = selection.selected + load_file(iter.get_value(FILENAME_COLUMN)) if iter + end + tree_view.signal_connect('row_activated') do |tree_view, path, column| + row_activated_cb(tree_view.model, path) + end + + tree_view.expand_all + return tree_view + end + + def append_children(model, source, parent = nil) + source.each do |title, filename, klass, children| + iter = model.append(parent) + + [title, filename, klass].each_with_index do |value, i| + if value + iter.set_value(i, value) + end + end + iter.set_value(ITALIC_COLUMN, false) + + if children + append_children(model, children, iter) + end + end + end + + def row_activated_cb(model, path) + iter = model.get_iter(path) + iter.set_value(ITALIC_COLUMN, true) + + lib = iter.get_value(FILENAME_COLUMN) + if lib + require(lib) + + klass = Demo.const_get(iter.get_value(CLASS_COLUMN)) + window = klass.new + window.signal_connect('destroy') do + iter.set_value(ITALIC_COLUMN, false) + end + window.show_all + @window = window + end + end + + def create_text(buffer, is_source) + scrolled_window = Gtk::ScrolledWindow.new + scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, + Gtk::POLICY_AUTOMATIC) + scrolled_window.set_shadow_type(Gtk::SHADOW_IN) + + text_view = Gtk::TextView.new + + text_view.set_buffer(buffer) + text_view.set_editable(false) + text_view.set_cursor_visible(false) + + scrolled_window.add(text_view) + + if is_source + font_desc = Pango::FontDescription.new('Monospace 12') + text_view.modify_font(font_desc) + + text_view.set_wrap_mode(Gtk::TextTag::WRAP_NONE) + else + text_view.set_wrap_mode(Gtk::TextTag::WRAP_WORD) + text_view.set_pixels_above_lines(2) + text_view.set_pixels_below_lines(2) + end + + return scrolled_window + end + + def fontify(start_iter = @source_buffer.start_iter, + end_iter = @source_buffer.end_iter) + str = @source_buffer.get_text(start_iter, end_iter, true) + + tokenizer = RubyTokonizer.new + tokenizer.tokenize(str, start_iter.offset) do |tag, start, last| + @source_buffer.apply_tag(tag.to_s, + @source_buffer.get_iter_at_offset(start), + @source_buffer.get_iter_at_offset(last)) + end + end + + + def load_file(filename) + if filename == @current_file + return + end + + @info_buffer.delete(*@info_buffer.bounds) + + @source_buffer.delete(*@source_buffer.bounds) + + file = begin + File.open(filename) + rescue + $stderr.puts "Cannot open: #{$!}" if $DEBUG + return + end + start = @info_buffer.get_iter_at_offset(0) + state = :before_header + + file.each do |line| + case state + when :before_header + if line =~ /^=begin$/ + state = :in_header + end + when :in_header + if line =~ /^=end$/ + state = :body + start = @source_buffer.get_iter_at_offset(0) + elsif line =~ /^=\s+(.*)$/ + title = $1 + title.gsub!(/\s*\(.*\)$/, '') # Delete depend field + + last = start + + @info_buffer.insert(last, title) + start = last.clone + + start.backward_chars(title.length) + @info_buffer.apply_tag('title', start, last) + + start = last + else + @info_buffer.insert(start, line) + end + when :body # Reading program body + @source_buffer.insert(start, line) + end + end + + fontify + + @current_file = filename + end + end + + class RubyTokonizer + RESERVED_WORDS = %w(begin end module class def if then else while unless do case when require yield) + RESERVED_WORDS_PATTERN = Regexp.compile(/(^|\s+)(#{RESERVED_WORDS.collect do |pat| Regexp.quote(pat) end.join('|')})(\s+|$)/) + + def tokenize(str, index = 0) + until str.empty? + tag = nil + + case str + when /".+?"/, /'.+?'/ + tag = :string + when /#.*$/ + tag = :comment + when RESERVED_WORDS_PATTERN + tag = :reserved + when /[A-Z][A-Za-z0-9_]+/ + tag = :const + end + + if tag + tokenize($~.pre_match, index) do |*args| + yield(*args) + end + yield(tag, index + $~.begin(0), index + $~.end(0)) + index += (str.length - $~.post_match.length) + str = $~.post_match + else + index += str.length + str = '' + end + end + end + end +end + + +target = ARGV.shift +if target + Demo::INDEX.each do |title, filename, klass_symbol, children| + if target == filename or target == klass_symbol.id2name + require filename + + window = Demo.const_get(klass_symbol).new + window.show_all + + class << window + def quit + Gtk.main_quit + end + end + + break + end + end +else + main = Demo::Main.new + main.set_default_size(600, 400) + main.show_all +end + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/menus.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/menus.rb new file mode 100644 index 0000000..f33a600 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/menus.rb @@ -0,0 +1,172 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: menus.rb,v 1.4 2005/02/12 23:02:43 kzys Exp $ +=begin += Menus + +There are several widgets involved in displaying menus. The +Gtk::MenuBar widget is a horizontal menu bar, which normally appears +at the top of an application. The Gtk::Menu widget is the actual menu +that pops up. Both Gtk::MenuBar and Gtk::Menu are subclasses of +Gtk::MenuShell; a Gtk::MenuShell contains menu items +(Gtk::MenuItem). Each menu item contains text and/or images and can +be selected by the user. + +There are several kinds of menu item, including plain Gtk::MenuItem, +Gtk::CheckMenuItem which can be checked/unchecked, Gtk::RadioMenuItem +which is a check menu item that's in a mutually exclusive group, +Gtk::SeparatorMenuItem which is a separator bar, Gtk::TearoffMenuItem +which allows a Gtk::Menu to be torn off, and Gtk::ImageMenuItem which +can place a Gtk::Image or other widget next to the menu text. + +A Gtk::MenuItem can have a submenu, which is simply a Gtk::Menu to pop +up when the menu item is selected. Typically, all menu items in a menu bar +have submenus. + +The Gtk::OptionMenu widget is a button that pops up a Gtk::Menu when clicked. +It's used inside dialogs and such. + +Gtk::ItemFactory provides a higher-level interface for creating menu bars +and menus; while you can construct menus manually, most people don't +do that. There's a separate demo for Gtk::ItemFactory. +=end +require 'common' + +module Demo + class Menus < BasicWindow + def initialize + super('menus') + self.border_width = 0 + + accel_group = Gtk::AccelGroup.new + add_accel_group(accel_group) + + + box1 = Gtk::VBox.new(false, 0) + add(box1) + + menubar = Gtk::MenuBar.new + box1.pack_start(menubar, false, true, 0) + + menu = create_menu(2, true) + + menuitem = Gtk::MenuItem.new("test\nline2") + menuitem.submenu = menu + menubar.append(menuitem) + menuitem.show + + menuitem = Gtk::MenuItem.new('foo') + menuitem.submenu = create_menu(3, true) + menubar.append(menuitem) + menuitem.show + + menuitem = Gtk::MenuItem.new('bar') + menuitem.submenu = create_menu(4, true) + menuitem.right_justified = true + menubar.append(menuitem) + menuitem.show + + box2 = Gtk::VBox.new(false, 10) + box2.border_width = 10 + box1.pack_start(box2, true, true, 0) + box2.show + + menu = create_menu(1, false) + # menu.accel_group = accel_group + + menuitem = Gtk::SeparatorMenuItem.new + menu.append(menuitem) + menuitem.show + + menuitem = Gtk::CheckMenuItem.new('Accelerate Me') + menu.append(menuitem) + menuitem.show + menuitem.add_accelerator('activate', + accel_group, + Gdk::Keyval::GDK_F1, + 0, + Gtk::ACCEL_VISIBLE) + menuitem = Gtk::CheckMenuItem.new('Accelerator Locked') + menu.append(menuitem) + menuitem.show + menuitem.add_accelerator('activate', + accel_group, + Gdk::Keyval::GDK_F2, + 0, + Gtk::ACCEL_VISIBLE | Gtk::ACCEL_LOCKED) + menuitem = Gtk::CheckMenuItem.new('Accelerators Frozen') + menu.append(menuitem) + menuitem.show + menuitem.add_accelerator('activate', + accel_group, + Gdk::Keyval::GDK_F2, + 0, + Gtk::ACCEL_VISIBLE) + menuitem.add_accelerator('activate', + accel_group, + Gdk::Keyval::GDK_F3, + 0, + Gtk::ACCEL_VISIBLE) + + optionmenu = Gtk::OptionMenu.new + optionmenu.menu = menu + optionmenu.history = 3 + box2.pack_start(optionmenu, true, true, 0) + optionmenu.show + + separator = Gtk::HSeparator.new + box1.pack_start(separator, false, true, 0) + separator.show + + box2 = Gtk::VBox.new(false, 10) + box2.border_width = 10 + box1.pack_start(box2, false, true, 0) + box2.show + + button = Gtk::Button.new('close') + button.signal_connect('clicked') do + quit + end + box2.pack_start(button, true, true, 0) + button.flags = Gtk::Widget::CAN_DEFAULT + button.grab_default + button.show + end + + + def create_menu (depth, tearoff) + if depth < 1 + return nil + end + + menu = Gtk::Menu.new + group = nil + + if tearoff + menuitem = Gtk::TearoffMenuItem.new + menu.append(menuitem) + menuitem.show + end + + 5.times do |i| + buf = sprintf('item %2d - %d', depth, i + 1) + menuitem = Gtk::RadioMenuItem.new(buf) + group = menuitem.group + + menu.append(menuitem) + menuitem.show + if i == 3 + menuitem.sensitive = false + end + + if submenu = create_menu(depth - 1, true) + menuitem.submenu = submenu + end + end + + menu.show + return menu + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/panes.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/panes.rb new file mode 100644 index 0000000..659fd52 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/panes.rb @@ -0,0 +1,156 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: panes.rb,v 1.5 2005/02/12 23:06:07 kzys Exp $ +=begin += Paned Widgets + +The Gtk::HPaned and Gtk::VPaned Widgets divide their content +area into two panes with a divider in between that the +user can adjust. A separate child is placed into each +pane. + +There are a number of options that can be set for each pane. +This test contains both a horizontal (HPaned) and a vertical +(VPaned) widget, and allows you to adjust the options for +each side of each widget. +=end +require 'common' + +module Demo + class Panes < BasicWindow + def initialize + super('Panes') + self.border_width = 0 + + vbox = Gtk::VBox.new(false, 0) + add(vbox) + + vpaned = Gtk::VPaned.new + vbox.pack_start(vpaned, true, true, 0) + vpaned.border_width = 5 + + hpaned = Gtk::HPaned.new + vpaned.add1(hpaned) + + frame = Gtk::Frame.new + frame.shadow_type = Gtk::SHADOW_IN + frame.set_size_request(60, 60) + hpaned.add1(frame) + + button = Gtk::Button.new('_Hi there', true) + frame.add(button) + + frame = Gtk::Frame.new + frame.shadow_type = Gtk::SHADOW_IN + frame.set_size_request(80, 60) + hpaned.add2(frame) + + frame = Gtk::Frame.new + frame.shadow_type = Gtk::SHADOW_IN + frame.set_size_request(60, 80) + vpaned.add2(frame) + + # Now create toggle buttons to control sizing + + vbox.pack_start(create_pane_options(hpaned, + 'Horizontal', 'Left', 'Right'), + false, false, 0) + + vbox.pack_start(create_pane_options(vpaned, + 'Vertical', 'Top', 'Bottom'), + false, false, 0) + end + + def create_pane_options(paned, frame_label, label1, label2) + frame = Gtk::Frame.new(frame_label) + frame.border_width = 4 + + table = Gtk::Table.new(3, 2, true) + frame.add(table) + + label = Gtk::Label.new(label1) + table.attach_defaults(label, 0, 1, 0, 1) + + check_button = Gtk::CheckButton.new('_Resize', true) + table.attach_defaults(check_button, 0, 1, 1, 2) + check_button.signal_connect('toggled') do + toggle_resize(paned.child1) + end + + check_button = Gtk::CheckButton.new('_Shrink', true) + table.attach_defaults(check_button, 0, 1, 2, 3) + check_button.active = true + check_button.signal_connect('toggled') do + toggle_shrink(paned.child1) + end + + label = Gtk::Label.new(label2) + table.attach_defaults(label, 1, 2, 0, 1) + + check_button = Gtk::CheckButton.new('_Resize') + table.attach_defaults(check_button, 1, 2, 1, 2) + check_button.active = true + check_button.signal_connect('toggled') do + toggle_resize(paned.child2) + end + + check_button = Gtk::CheckButton.new('_Shrink') + table.attach_defaults(check_button, 1, 2, 2, 3) + check_button.active = true + check_button.signal_connect('toggled') do + toggle_shrink(paned.child2) + end + + return frame + end + + def toggle_resize(child) + paned = child.parent + is_child1 = (child == paned.child1) + + resize = if is_child1 + paned.child1_resize? + else + paned.child2_resize? + end + + shrink = if is_child1 + paned.child1_shrink? + else + paned.child2_shrink? + end + + child.parent.remove(child) + if is_child1 + paned.pack1(child, !resize, shrink) + else + paned.pack2(child, !resize, shrink) + end + end + + def toggle_shrink(child) + paned = child.parent + is_child1 = (child == paned.child1) + + resize = if is_child1 + paned.child1_resize? + else + paned.child2_resize? + end + + shrink = if is_child1 + paned.child1_shrink? + else + paned.child2_shrink? + end + + child.parent.remove(child) + if is_child1 + paned.pack1(child, resize, !shrink) + else + paned.pack2(child, resize, !shrink) + end + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/pixbufs.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/pixbufs.rb new file mode 100644 index 0000000..b3616cb --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/pixbufs.rb @@ -0,0 +1,176 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: pixbufs.rb,v 1.5 2005/02/12 23:02:43 kzys Exp $ +=begin += Pixbufs + +A Gdk::Pixbuf represents an image, normally in RGB or RGBA format. +Pixbufs are normally used to load files from disk and perform +image scaling. + +This demo is not all that educational, but looks cool. It was written +by Extreme Pixbuf Hacker Federico Mena Quintero. It also shows +off how to use Gtk::DrawingArea to do a simple animation. + +Look at the Image demo for additional pixbuf usage examples. +=end + +require 'common' + +module Demo + class Pixbufs < BasicWindow + FRAME_DELAY = 50 + + BACKGROUND_NAME = 'background.jpg' + + IMAGE_NAMES = [ + 'apple-red.png', + 'gnome-applets.png', + 'gnome-calendar.png', + 'gnome-foot.png', + 'gnome-gmush.png', + 'gnome-gimp.png', + 'gnome-gsame.png', + 'gnu-keys.png', + 'ruby-gnome2-logo.png' + ] + + CYCLE_LEN = 60 + def initialize + super('Pixbufs') + set_resizable(false) + + @background = nil + @frame = nil + @frame_num = 0 + @images = [] + + begin + load_pixbufs + + set_size_request(@background.width, @background.height) + + @frame = Gdk::Pixbuf.new(Gdk::Pixbuf::COLORSPACE_RGB, + false, 8, + @background.width, @background.height) + + @da = Gtk::DrawingArea.new + + @da.signal_connect('expose_event') do |w, e| + expose_cb(w, e) + end + + add(@da) + + timeout_id = Gtk.timeout_add(FRAME_DELAY) do + timeout + end + signal_connect('destroy') do + Gtk.timeout_remove(timeout_id) + end + rescue + dialog = Gtk::MessageDialog.new(self, + Gtk::Dialog::DESTROY_WITH_PARENT, + Gtk::MessageDialog::ERROR, + Gtk::MessageDialog::BUTTONS_CLOSE, + "Failed to load an image: #{$!.message}") + + dialog.signal_connect('response') do + dialog.destroy + end + + dialog.show + end + end + + def load_pixbufs + # Loads the images for the demo + + if @background + return # already loaded earlier + end + + # demo_find_file() looks in the the current directory first, + # so you can run gtk-demo without installing GTK, then looks + # in the location where the file is installed. + # + filename = Demo.find_file(BACKGROUND_NAME) + @background = Gdk::Pixbuf.new(filename) + + IMAGE_NAMES.each_with_index do |basename, i| + filename = Demo.find_file(basename) + + @images[i] = Gdk::Pixbuf.new(filename) + end + end + + def expose_cb(widget, event) + rowstride = @frame.rowstride + + pixels = @frame.pixels + pixels[0, rowstride * event.area.y + event.area.x * 3] = '' + + Gdk::RGB.draw_rgb_image(widget.window, + widget.style.black_gc, + event.area.x, event.area.y, + event.area.width, event.area.height, + Gdk::RGB::Dither::NORMAL, + pixels, rowstride, + event.area.x, event.area.y) + true + end + + # Timeout handler to regenerate the frame + def timeout + @background.copy_area(0, 0, @background.width, @background.height, + @frame, 0, 0) + + f = Float(@frame_num % CYCLE_LEN) / CYCLE_LEN; + + xmid = @background.width / 2.0 + ymid = @background.height / 2.0 + + radius = [xmid, ymid].min / 2.0 + + @images.each_with_index do |image, i| + ang = 2.0 * Math::PI * Float(i) / IMAGE_NAMES.length - f * 2.0 * Math::PI + + r = radius + (radius / 3.0) * Math.sin(f * 2.0 * Math::PI) + + xpos = (xmid + r * Math.cos(ang) - image.width / 2.0 + 0.5).floor + ypos = (ymid + r * Math.sin(ang) - image.height / 2.0 + 0.5).floor + + k = if (i & 1) == 1 + Math.sin(f * 2.0 * Math::PI) + else + Math.cos(f * 2.0 * Math::PI) + end + k = [0.25, 2.0 * k * k].max + + r1 = Gdk::Rectangle.new(xpos, ypos, image.width * k, image.height * k) + r2 = Gdk::Rectangle.new(0, 0, @background.width, @background.height) + + dest = r1.intersect(r2) + if dest + @frame.composite!(image, dest.x, dest.y, dest.width, dest.height, + xpos, ypos, k, k, Gdk::Pixbuf::INTERP_NEAREST, + if (i & 1) == 1 + [ + 127, + (255 * Math.sin(f * 2.0 * Math::PI)).abs + ].max + else + [ + 127, + (255 * Math.cos(f * 2.0 * Math::PI)).abs + ].max + end) + end + end + @da.queue_draw + @frame_num += 1 + true + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/printing.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/printing.rb new file mode 100644 index 0000000..ac88e31 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/printing.rb @@ -0,0 +1,128 @@ +# Copyright (c) 2008 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +=begin += Printing + +Gtk::PrintOperation offers a simple API to support printing +in a cross-platform way. +=end + +require 'common' + +module Demo + class Printing < BasicWindow + Data = Struct.new(:font_size, :lines_per_page, :lines, :n_pages) + HEADER_HEIGHT = 10 * 72 / 25.4 + HEADER_GAP = 3 * 72 / 25.4 + + def initialize + super('Printing') + + button = Gtk::Button.new("Print...") + button.signal_connect("clicked") do + begin + run_print_operation + rescue + dialog = Gtk::MessageDialog.new(self, :destroy_with_parent, :error, + :close, $!.message) + dialog.signal_connect("response") do + dialog.destroy + true + end + dialog.show + end + true + end + add(button) + end + + private + def run_print_operation + operation = Gtk::PrintOperation.new + + data = Data.new + data.font_size = 12.0 + operation.signal_connect("begin-print") do |_operation, context| + on_begin_print(_operation, context, data) + end + operation.signal_connect("draw-page") do |_operation, context, page_number| + on_draw_page(_operation, context, page_number, data) + end + operation.signal_connect("end-print") do |_operation, context| + on_end_print(_operation, context, data) + end + + operation.use_full_page = false + operation.unit = :points + + operation.run(:print_dialog, self) + end + + def on_begin_print(operation, context, data) + height = context.height - HEADER_HEIGHT - HEADER_GAP + data.lines_per_page = (height / data.font_size).floor + data.lines = File.readlines(__FILE__) + data.n_pages = (data.lines.size - 1) / data.lines_per_page + 1 + operation.set_n_pages(data.n_pages) + end + + def on_draw_page(operation, context, page_number, data) + cr = context.cairo_context + draw_header(cr, operation, context, page_number, data) + draw_body(cr, operation, context, page_number, data) + end + + def draw_header(cr, operation, context, page_number, data) + width = context.width + + cr.rectangle(0, 0, width, HEADER_HEIGHT) + cr.set_source_rgb(0.8, 0.8, 0.8) + cr.fill_preserve + + cr.set_source_rgb(0, 0, 0) + cr.line_width = 1 + cr.stroke + + layout = context.create_pango_layout + layout.font_description = "sans 14" + + layout.text = File.basename(__FILE__) + text_width, text_height = layout.pixel_size + + if (text_width > width) + layout.width = width + layout.ellipsize = :start + text_width, text_height = layout.pixel_size + end + + y = (HEADER_HEIGHT - text_height) / 2 + + cr.move_to((width - text_width) / 2, y) + cr.show_pango_layout(layout) + + layout.text = "#{page_number + 1}/#{data.n_pages}" + layout.width = -1 + text_width, text_height = layout.pixel_size + cr.move_to(width - text_width - 4, y) + cr.show_pango_layout(layout) + end + + def draw_body(cr, operation, context, page_number, data) + layout = context.create_pango_layout + description = Pango::FontDescription.new("monosapce") + description.size = data.font_size * Pango::SCALE + layout.font_description = description + + cr.move_to(0, HEADER_HEIGHT + HEADER_GAP) + start_line = page_number * data.lines_per_page + data.lines[start_line, data.lines_per_page].each do |line| + layout.text = line + cr.show_pango_layout(layout) + cr.rel_move_to(0, data.font_size) + end + end + + def on_end_print(operation, context, data) + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/rotated_text.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/rotated_text.rb new file mode 100644 index 0000000..64a4d80 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/rotated_text.rb @@ -0,0 +1,84 @@ +# Copyright (c) 2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: rotated_text.rb,v 1.2 2005/03/05 15:01:16 mutoh Exp $ +=begin += Rotated Text + +This demo shows how to use GDK and Pango to draw rotated and transformed text. +The use of Gdk::PangoRenderer in this example is a somewhat advanced technique; most applications can simply use Gdk::Drawable#draw_layout. +We use it here mostly because that allows us to work in user coordinates - that is, coordinates prior to the application of the transformation matrix, rather than device coordinates. +As of GTK+-2.6, the ability to draw transformed and anti-aliased graphics as shown in this example is only present for text. +With GTK+-2.8, a new graphics system called "Cairo" will be introduced that provides these capabilities and many more for all types of graphics. +=end +require 'common' + +module Demo + class RotatedText < BasicWindow + RADIUS = 150 + N_WORDS = 10 + FONT = "Sans Bold 27" + + def initialize + super('Rotated Text') + + unless Gtk.check_version?(2, 6, 0) + add(Gtk::Label.new("This sample requires GTK+ 2.6.0 or later")) + return + end + + drawing_area = Gtk::DrawingArea.new + add(drawing_area) + drawing_area.modify_bg(Gtk::STATE_NORMAL, Gdk::Color.new(65535, 65535, 65535)) + + drawing_area.signal_connect("expose_event") do + matrix = Pango::Matrix.new + + # Get the default renderer for the screen, and set it up for drawing + renderer = Gdk::PangoRenderer.get_default(drawing_area.screen) + renderer.drawable = drawing_area.window + renderer.gc = style.black_gc + width = drawing_area.allocation.width + height = drawing_area.allocation.height + + # Set up a transformation matrix so that the user space coordinates for + # the centered square where we draw are [-RADIUS, RADIUS], [-RADIUS, RADIUS] + # We first center, then change the scale + device_radius = [width, height].min / 2.0 + + matrix.translate!(device_radius + (width - 2 * device_radius) / 2.0, + device_radius + (height - 2 * device_radius) / 2.0) + matrix.scale!(device_radius / RADIUS, device_radius / RADIUS) + + # Create a PangoLayout, set the font and text + context = Gdk::Pango.context + layout = Pango::Layout.new(context) + layout.text = "Text" + layout.font_description = Pango::FontDescription.new(FONT) + + # Draw the layout N_WORDS times in a circle + (0...N_WORDS).each do |i| + rotated_matrix = matrix.dup + angle = 360 * i / N_WORDS.to_f + + # Gradient from red at angle == 60 to blue at angle == 300 + red = 65535 * (1 + Math.cos((angle - 60) * Math::PI / 180.0)) / 2 + color = Gdk::Color.new(red, 0, 65535 - red) + renderer.set_override_color(Pango::Renderer::PART_FOREGROUND, color) + + rotated_matrix.rotate!(angle) + context.matrix = rotated_matrix + + # Inform Pango to re-layout the text with the new transformation matrix + layout.context_changed + width, height = layout.size + renderer.draw_layout(layout, - width / 2, - RADIUS * Pango::SCALE) + end + # Clean up default renderer, since it is shared + renderer.set_override_color(Gdk::PangoRenderer::PART_FOREGROUND, nil) + renderer.drawable = nil + renderer.gc = nil + end + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/ruby-gnome2-logo.png b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/ruby-gnome2-logo.png new file mode 100644 index 0000000..0b38a52 Binary files /dev/null and b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/ruby-gnome2-logo.png differ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/sizegroup.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/sizegroup.rb new file mode 100644 index 0000000..71b6dfd --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/sizegroup.rb @@ -0,0 +1,118 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: sizegroup.rb,v 1.5 2005/02/12 23:02:43 kzys Exp $ +=begin += Size Groups + +Gtk::SizeGroup provides a mechanism for grouping a number of +widgets together so they all request the same amount of space. +This is typically useful when you want a column of widgets to +have the same size, but you can't use a Gtk::Table widget. + +Note that size groups only affect the amount of space requested, +not the size that the widgets finally receive. If you want the +widgets in a Gtk::SizeGroup to actually be the same size, you need +to pack them in such a way that they get the size they request +and not more. For example, if you are packing your widgets +into a table, you would not include the Gtk::FILL flag. +=end +require 'common' + +module Demo + class SizeGroup < Gtk::Dialog + def initialize + super('GtkSizeGroup', nil, 0, + [Gtk::Stock::CLOSE, Gtk::Dialog::RESPONSE_NONE]) + + color_options = %w(Red Green Blue) + dash_options = %w(Solid Dashed Dotted) + end_options = %w(Square Round Arrow) + + set_resizable(false) + + signal_connect('response') do + destroy + end + + vbox = Gtk::VBox.new(false, 5) + self.vbox.pack_start(vbox, true, true, 0) + vbox.set_border_width(5) + + size_group = Gtk::SizeGroup.new(Gtk::SizeGroup::HORIZONTAL) + + ## Create one frame holding color options + frame = Gtk::Frame.new('Color Options') + vbox.pack_start(frame, true, true, 0) + + table = Gtk::Table.new(2, 2, false) + table.set_border_width(5) + table.set_row_spacings(5) + table.set_column_spacings(10) + frame.add(table) + + add_row(table, 0, size_group, '_Foreground', color_options) + add_row(table, 1, size_group, '_Background', color_options) + + ## And another frame holding line style options + frame = Gtk::Frame.new('Line Options') + vbox.pack_start(frame, false, false, 0) + + table = Gtk::Table.new(2, 2, false) + table.set_border_width(5) + table.set_row_spacings(5) + table.set_column_spacings(10) + frame.add(table) + + add_row(table, 0, size_group, '_Dashing', dash_options) + add_row(table, 1, size_group, '_Line ends', end_options) + + # And a check button to turn grouping on and off + check_button = Gtk::CheckButton.new('_Enable grouping', true) + vbox.pack_start(check_button, false, false, 0) + + check_button.set_active(true) + check_button.signal_connect('toggled', size_group) do |check_button, size_group| + new_mode = if check_button.active? + Gtk::SizeGroup::HORIZONTAL + else + Gtk::SizeGroup::VERTICAL + end + size_group.set_mode(new_mode) + end + end + + def add_row(table, row, size_group, label_text, options) + label = Gtk::Label.new(label_text, true) + label.set_alignment(0, 1) + table.attach(label, + 0, 1, row, row + 1, + Gtk::EXPAND | Gtk::FILL, 0, + 0, 0) + + option_menu = create_option_menu(options) + label.set_mnemonic_widget(option_menu) + size_group.add_widget(option_menu) + table.attach(option_menu, + 1, 2, row, row + 1, + 0, 0, + 0, 0) + end + + def create_option_menu(strings) + menu = Gtk::Menu.new + + strings.each do |str| + menu_item = Gtk::MenuItem.new(str) + menu_item.show + + menu.append(menu_item) + end + + option_menu = Gtk::OptionMenu.new + option_menu.set_menu(menu) + + return option_menu + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/stock_browser.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/stock_browser.rb new file mode 100644 index 0000000..ae29c0e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/stock_browser.rb @@ -0,0 +1,235 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: stock_browser.rb,v 1.5 2005/02/12 23:02:43 kzys Exp $ +=begin += Stock Item and Icon Browser + +This source code for this demo doesn't demonstrate anything +particularly useful in applications. The purpose of the 'demo' is +just to provide a handy place to browse the available stock icons +and stock items. +=end +require 'common' + +module Demo + class StockBrowser < BasicWindow + Item = + Struct.new('Item', + :stock_id, :label, :modifier, :keyval, :translation_domain) + ItemInfo = + Struct.new('ItemInfo', :id, :item, :small_icon, :const, :accel_str) + ItemDisplay = + Struct.new('ItemDisplay', + :type_label, :const_label, :id_label, :label_accel_label, + :icon_image) + + def initialize + super('Stock Icons and Items') + set_default_size(-1, 500) + + self.border_width = 8 + + hbox = Gtk::HBox.new(false, 8) + add(hbox) + + sw = Gtk::ScrolledWindow.new + sw.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC) + hbox.pack_start(sw, false, false, 0) + + model = create_model + + treeview = Gtk::TreeView.new(model) + sw.add(treeview) + + column = Gtk::TreeViewColumn.new + column.title = 'Const' + + cell_renderer = Gtk::CellRendererPixbuf.new + column.pack_start(cell_renderer, false) + column.set_attributes(cell_renderer, "stock_id" => 1) + + cell_renderer = Gtk::CellRendererText.new + column.pack_start(cell_renderer, true) + column.set_cell_data_func(cell_renderer) do |column, cell, model, iter| + cell.text = iter[0].const + end + + treeview.append_column(column) + + cell_renderer = Gtk::CellRendererText.new + treeview.insert_column(-1, 'Label', cell_renderer) do |col, cell, model, iter| + info = iter[0] + cell.text = info.item.label if info + end + + cell_renderer = Gtk::CellRendererText.new + treeview.insert_column(-1, 'Accel', cell_renderer) do |col, cell, model, iter| + info = iter[0] + cell.text = info.accel_str if info + end + + cell_renderer = Gtk::CellRendererText.new + treeview.insert_column(-1, 'ID', cell_renderer) do |col, cell, model, iter| + info = iter[0] + cell.text = info.id if info + end + + align = Gtk::Alignment.new(0.5, 0.0, 0.0, 0.0) + hbox.pack_end(align, false, false, 0) + + frame = Gtk::Frame.new('Selected Item') + align.add(frame) + + vbox = Gtk::VBox.new(false, 8) + vbox.border_width = 4 + frame.add(vbox) + + display = ItemDisplay.new + class << treeview + @display = nil + attr_accessor :display + end + treeview.display = display + + display.type_label = Gtk::Label.new + display.const_label = Gtk::Label.new + display.id_label = Gtk::Label.new + display.label_accel_label = Gtk::Label.new + display.icon_image = Gtk::Image.new # empty image + + vbox.pack_start(display.type_label, false, false, 0) + + vbox.pack_start(display.icon_image, false, false, 0) + + vbox.pack_start(display.label_accel_label, false, false, 0) + vbox.pack_start(display.const_label, false, false, 0) + vbox.pack_start(display.id_label, false, false, 0) + + selection = treeview.selection + selection.mode = Gtk::SELECTION_SINGLE + + selection.signal_connect('changed') do |s| + selection_changed(s) + end + end + + def create_model + store = Gtk::ListStore.new(ItemInfo, String, String, String) + + list_ids = Gtk::Stock.ids + list_ids.sort! do |a, b| + a.to_s <=> b.to_s + end + list_ids.each do |stock_id| + info = ItemInfo.new + + info.id = stock_id + + begin + info.item = Item.new(*Gtk::Stock.lookup(stock_id)) + rescue ArgumentError + info.item = Item.new + end + + # only show icons for stock IDs that have default icons + icon_set = Gtk::IconFactory.lookup_default(info.id.to_s) + if icon_set + # See what sizes this stock icon really exists at + sizes = icon_set.sizes + + # Use menu size if it exists, otherwise first size found + size = sizes.find do |s| s == Gtk::IconSize::MENU end || sizes.first + + info.small_icon = render_icon(info.id, size, '') + + unless size == Gtk::IconSize::MENU + # Make the result the proper size for our thumbnail + w, h = Gtk::IconSize.lookup(size) + + scaled = info.small_icon.scale(w, h, Gdk::Pixbuf::INTERP_BILINEAR) + info.small_icon = scaled + end + + else + info.small_icon = nil + end + + if info.item.keyval + info.accel_str = Gtk::Accelerator.to_name(info.item.keyval, + info.item.modifier) + else + info.accel_str = '' + end + + info.const = id_to_const(info.id) + + iter = store.append + iter[0] = info + iter[1] = info.id + end + + return store + end + + def selection_changed(selection) + treeview = selection.tree_view + display = treeview.display + + iter = selection.selected + info = iter[0] + + display.type_label.label = if info.small_icon and info.item.label + 'Icon and Item' + elsif info.small_icon + 'Icon Only' + elsif info.item.label + 'Item Only' + else + '???????' + end + display.const_label.label = info.const + display.id_label.label = info.id + + if info.item.label + str = "%s %s" % [info.item.label, info.accel_str] + display.label_accel_label.set_text(str, true) + else + display.label_accel_label.set_text('') + end + + if info.small_icon + display.icon_image.set(info.id, get_largest_size(info.id)) + else + display.icon_image.pixbuf = nil + end + end + + def get_largest_size(symbol) + set = Gtk::IconFactory.lookup_default(symbol.id2name) + best_size = Gtk::IconSize::INVALID + best_pixels = 0 + + sizes = set.sizes + sizes.collect! do |i| + width, height = Gtk::IconSize.lookup(i) + [i, width * height] + end + return (sizes.max do |a, b| a[1] <=> b[1] end)[0] + end + + def id_to_const(id) + const = '' + + s = id.id2name + if s =~ /^gtk-/ + const += 'Gtk::Stock::' + s[0,4] = '' + end + + const += s.upcase.gsub(/-/, '_') + + const + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/textview.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/textview.rb new file mode 100644 index 0000000..a948712 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/textview.rb @@ -0,0 +1,436 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: textview.rb,v 1.8 2005/02/06 18:25:13 kzys Exp $ +=begin += Text Widget/Multiple Views + +The Gtk::TextView widget displays a Gtk::TextBuffer. +One Gtk::TextBuffer can be displayed by multiple Gtk::TextViews. +This demo has two views displaying a single buffer, +and shows off the widget's text formatting features. +=end +require 'common' + +module Demo + class TextView < BasicWindow + + GRAY50_WIDTH = 2 + GRAY50_HEIGHT = 2 + GRAY50_BITS = [0x02, 0x01].pack("c") + @@nest_window = nil + + def initialize + super("TextView Window") + + set_default_size(450, 450) + + set_title("TextView") + set_border_width(0) + + vpaned = Gtk::VPaned.new + vpaned.set_border_width(5) + add(vpaned) + ## + # For convenience, we just use the autocreated buffer from + # the first text view; you could also create the buffer + # by itself with Gtk::TextBuffer.new, then later create + # a view widget. + # + view1 = Gtk::TextView.new + buffer = view1.buffer + view2 = Gtk::TextView.new(buffer) + + sw = Gtk::ScrolledWindow.new(nil, nil) + sw.set_policy(Gtk::POLICY_AUTOMATIC, + Gtk::POLICY_AUTOMATIC) + vpaned.add1(sw) + + sw.add(view1) + + sw = Gtk::ScrolledWindow.new(nil, nil) + sw.set_policy(Gtk::POLICY_AUTOMATIC, + Gtk::POLICY_AUTOMATIC) + vpaned.add2(sw) + + sw.add(view2) + + create_tags(buffer) + insert_text(buffer) + + attach_widgets(view1) + attach_widgets(view2) + + vpaned.show_all + + self.show + end + + def create_tags(buffer) + ## + # Create a bunch of tags. Note that it's also possible to + # create tags with Gtk::TextTag.new then add them to the + # tag table for the buffer, Gtk::TextBuffer#create_tag is + # just a convenience function. Also note that you don't have + # to give tags a name; pass NULL for the name to create an + # anonymous tag. + # + # In any real app, another useful optimization would be to create + # a Gtk::TextTagTable in advance, and reuse the same tag table for + # all the buffers with the same tag set, instead of creating + # new copies of the same tags for every buffer. + # + # Tags are assigned default priorities in order of addition to the + # tag table. That is, tags created later that affect the same text + # property affected by an earlier tag will override the earlier + # tag. You can modify tag priorities with + # Gtk::TextTag#set_priority. + # + + buffer.create_tag('heading', + 'weight' => Pango::FontDescription::WEIGHT_BOLD, + 'size' => 15 * Pango::SCALE) + + buffer.create_tag("italic", + "style" => Pango::FontDescription::STYLE_ITALIC) + + buffer.create_tag("bold", + "weight" => Pango::FontDescription::WEIGHT_BOLD) + + buffer.create_tag("big", + # points times the PANGO_SCALE factor + "size" => 20 * Pango::SCALE) + + buffer.create_tag("xx-small", + "scale" => Pango::AttrScale::XX_SMALL) + + buffer.create_tag("x-large", + "scale" => Pango::AttrScale::X_LARGE) + + buffer.create_tag("monospace", "family" => "monospace") + + buffer.create_tag("blue_foreground", "foreground" => "blue") + + buffer.create_tag("red_background", "background" => "red") + + stipple = Gdk::Pixmap.create_from_data(nil, GRAY50_BITS, GRAY50_WIDTH, + GRAY50_HEIGHT) + + buffer.create_tag("background_stipple", + "background_stipple" => stipple) + + buffer.create_tag("foreground_stipple", + "foreground_stipple" => stipple) + + buffer.create_tag("big_gap_before_line", + "pixels_above_lines" => 30) + + buffer.create_tag("big_gap_after_line", + "pixels_below_lines" => 30) + + buffer.create_tag("double_spaced_line", + "pixels_inside_wrap" => 10) + + buffer.create_tag("not_editable", + "editable" => false) + + buffer.create_tag("word_wrap", + "wrap_mode" => Gtk::TextTag::WRAP_WORD) + + buffer.create_tag("char_wrap", + "wrap_mode" => Gtk::TextTag::WRAP_CHAR) + + buffer.create_tag("no_wrap", + "wrap_mode" => Gtk::TextTag::WRAP_NONE) + + buffer.create_tag("center", + "justification" => Gtk::JUSTIFY_CENTER) + + buffer.create_tag("right_justify", + "justification" => Gtk::JUSTIFY_RIGHT) + + buffer.create_tag("wide_margins", + "left_margin" => 50, + "right_margin" => 50) + + buffer.create_tag("strikethrough", + "strikethrough" => true) + + buffer.create_tag("underline", + "underline" => Pango::AttrUnderline::SINGLE) + + buffer.create_tag("double_underline", + "underline" => Pango::AttrUnderline::DOUBLE) + + buffer.create_tag("superscript", + "rise" => 10 * Pango::SCALE, # 10 pixels + "size" => 8 * Pango::SCALE) # 8 points + + buffer.create_tag("subscript", + "rise" => -10 * Pango::SCALE, # 10 pixels + "size" => 8 * Pango::SCALE) # 8 points + + buffer.create_tag("rtl_quote", + "wrap_mode" => Gtk::TextTag::WRAP_WORD, + "direction" => Gtk::Widget::TEXT_DIR_RTL, + "indent" => 30, + "left_margin" => 20, + "right_margin" => 20) + end + + def insert_text(buffer) + + ## + # Demo.find_file looks in the the current directory first, + # so you can run gtk-demo without installing GTK, then looks + # in the location where the file is installed. + # + + filename = Demo.find_file("gtk-logo-rgb.gif") + pixbuf = Gdk::Pixbuf.new(filename) if filename + + unless pixbuf + $stderr.print "Failed to load image file gtk-logo-rgb.gif\n" + exit 1 + end + + scaled = pixbuf.scale(32, 32, Gdk::Pixbuf::INTERP_BILINEAR) + pixbuf = scaled + + ## + # get start of buffer; each insertion will revalidate the + # iterator to point to just after the inserted text. + # + + iter = buffer.get_iter_at_offset(0) + + buffer.insert(iter, "The text widget can display text with all kinds of nifty attributes. It also supports multiple views of the same buffer; this demo is showing the same buffer in two places.\n\n") + + buffer.insert(iter, "Font styles. ", 'heading') + + buffer.insert(iter, "For example, you can have ") + buffer.insert(iter, "italic", "italic") + buffer.insert(iter, ", ") + buffer.insert(iter, "bold", "bold") + buffer.insert(iter, ", or ") + buffer.insert(iter, "monospace(typewriter)", "monospace") + buffer.insert(iter, ", or ") + buffer.insert(iter, "big", "big") + buffer.insert(iter, " text. ") + buffer.insert(iter, "It's best not to hardcode specific text sizes; you can use relative sizes as with CSS, such as ") + buffer.insert(iter, "xx-small", "xx-small") + buffer.insert(iter, " or ") + buffer.insert(iter, "x-large", "x-large") + buffer.insert(iter, " to ensure that your program properly adapts if the user changes the default font size.\n\n") + + buffer.insert(iter, "Colors. ", "heading") + + buffer.insert(iter, "Colors such as ") + buffer.insert(iter, "a blue foreground", "blue_foreground") + buffer.insert(iter, " or ") + buffer.insert(iter, "a red background", "red_background") + buffer.insert(iter, " or even ") + buffer.insert(iter, "a stippled red background", + "red_background", "background_stipple") + + buffer.insert(iter, " or ") + buffer.insert(iter, "a stippled blue foreground on solid red background", + "blue_foreground", "red_background", "foreground_stipple") + + buffer.insert(iter, "(select that to read it) can be used.\n\n") + + buffer.insert(iter, "Underline, strikethrough, and rise. ", "heading") + + buffer.insert(iter, "Strikethrough", "strikethrough") + buffer.insert(iter, ", ") + buffer.insert(iter, "underline", "underline") + buffer.insert(iter, ", ") + buffer.insert(iter, "double underline", "double_underline") + buffer.insert(iter, ", ") + buffer.insert(iter, "superscript", "superscript") + buffer.insert(iter, ", and ") + buffer.insert(iter, "subscript", "subscript") + buffer.insert(iter, " are all supported.\n\n") + + buffer.insert(iter, "Images. ", "heading") + + buffer.insert(iter, "The buffer can have images in it: ") + buffer.insert(iter, pixbuf) + buffer.insert(iter, pixbuf) + buffer.insert(iter, pixbuf) + buffer.insert(iter, " for example.\n\n") + + buffer.insert(iter, "Spacing. ", "heading") + + buffer.insert(iter, "You can adjust the amount of space before each line.\n") + + buffer.insert(iter, "This line has a whole lot of space before it.\n", + "big_gap_before_line", "wide_margins") + buffer.insert(iter, "You can also adjust the amount of space after each line; this line has a whole lot of space after it.\n", + "big_gap_after_line", "wide_margins") + + buffer.insert(iter, "You can also adjust the amount of space between wrapped lines; this line has extra space between each wrapped line in the same paragraph. To show off wrapping, some filler text: the quick brown fox jumped over the lazy dog. Blah blah blah blah blah blah blah blah blah.\n", + "double_spaced_line", "wide_margins") + + buffer.insert(iter, "Also note that those lines have extra-wide margins.\n\n") + + buffer.insert(iter, "Editability. ", "heading") + + buffer.insert(iter, "This line is 'locked down' and can't be edited by the user - just try it! You can't delete this line.\n\n", + "not_editable") + + buffer.insert(iter, "Wrapping. ", "heading") + + buffer.insert(iter, "This line(and most of the others in this buffer) is word-wrapped, using the proper Unicode algorithm. Word wrap should work in all scripts and languages that GTK+ supports. Let's make this a long paragraph to demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n\n") + + buffer.insert(iter, "This line has character-based wrapping, and can wrap between any two character glyphs. Let's make this a long paragraph to demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n\n", "char_wrap") + + buffer.insert(iter, "This line has all wrapping turned off, so it makes the horizontal scrollbar appear.\n\n\n", "no_wrap") + + buffer.insert(iter, "Justification. ", "heading") + + buffer.insert(iter, "\nThis line has center justification.\n", "center") + + buffer.insert(iter, "This line has right justification.\n", + "right_justify") + + buffer.insert(iter, "\nThis line has big wide margins. Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.\n", "wide_margins") + + buffer.insert(iter, "Internationalization. ", "heading") + + buffer.insert(iter, "You can put all sorts of Unicode text in the buffer.\n\nGerman(Deutsch Süd) Grüß Gott\nGreek(Ελληνικά) Γειά σας\nHebrew שלום\nJapanese(日本語)\n\nThe widget properly handles bidirectional text, word wrapping, DOS/UNIX/Unicode paragraph separators, grapheme boundaries, and so on using the Pango internationalization framework.\n") + + buffer.insert(iter, "Here's a word-wrapped quote in a right-to-left language:\n") + buffer.insert(iter, "??? ??? ???? ?? ???? ???????? ????? ?? ???? ?????? ??????? ??????? ?? ???? ?????? ?? ????? ?? ??????? ????? ??????? ??? ?????? ????? ?????? ????? ???? ?? ?????? ?????? ?? ???????? ?????? ????? ?? ???? ???? ????????? ???????. ???? ???? ??? ???????? ????? ?? »????????« ?? ???????.\n\n", "rtl_quote") + + buffer.insert(iter, "You can put widgets in the buffer: Here's a button: ") + anchor = buffer.create_child_anchor(iter) + buffer.insert(iter, " and a menu: ") + anchor = buffer.create_child_anchor(iter) + buffer.insert(iter, " and a scale: ") + anchor = buffer.create_child_anchor(iter) + buffer.insert(iter, " and an animation: ") + anchor = buffer.create_child_anchor(iter) + buffer.insert(iter, " finally a text entry: ") + anchor = buffer.create_child_anchor(iter) + buffer.insert(iter, ".\n") + + buffer.insert(iter, "\n\nThis demo doesn't demonstrate all the Gtk::TextBuffer features; it leaves out, for example: invisible/hidden text(doesn't work in GTK 2, but planned), tab stops, application-drawn areas on the sides of the widget for displaying breakpoints and such...") + + # Apply word_wrap tag to whole buffer + + buf_start, buf_end = buffer.bounds + buffer.apply_tag("word_wrap", buf_start, buf_end) + end + + def find_anchor(iter) + while iter.forward_char do + return true if iter.child_anchor + end + return false + end + + def attach_widgets(text_view) + + buffer = text_view.buffer; + + iter = buffer.start_iter + + i = 0; + while find_anchor(iter) do + anchor = iter.child_anchor + + if i == 0 + widget = Gtk::Button.new("Click Me") + widget.signal_connect('clicked') { |button| + if @@nest_window and ! @@nest_window.destroyed? + @@nest_window.present + break + end + + buffer = Gtk::TextBuffer.new + iter = buffer.start_iter + + buffer.insert(iter, "This buffer is shared by a set of nested text views.\n Nested view:\n") + anchor = buffer.create_child_anchor(iter) + buffer.insert(iter, "\nDon't do this in real applications, please.\n") + + view = Gtk::TextView.new(buffer) + + recursive_attach_view(0, view, anchor) + + @@nest_window = Gtk::Window.new(Gtk::Window::TOPLEVEL) + sw = Gtk::ScrolledWindow.new(nil, nil) + sw.set_policy(Gtk::POLICY_AUTOMATIC, + Gtk::POLICY_AUTOMATIC) + + @@nest_window.add(sw) + sw.add(view) + + @@nest_window.set_default_size(300, 400) + @@nest_window.show_all + } + elsif i == 1 + menu = Gtk::Menu.new + widget = Gtk::OptionMenu.new + + menu_item = Gtk::MenuItem.new("Option 1") + menu.append(menu_item) + menu_item = Gtk::MenuItem.new("Option 2") + menu.append(menu_item) + menu_item = Gtk::MenuItem.new("Option 3") + menu.append(menu_item) + + widget.menu = menu + + elsif i == 2 + widget = Gtk::HScale.new + widget.set_range(0, 100) + widget.set_size_request(70, -1) + + elsif i == 3 + filename = Demo.find_file("floppybuddy.gif") + widget = Gtk::Image.new(filename) + + elsif i == 4 + widget = Gtk::Entry.new + + else + #widget = nil; avoids a compiler warning + #g_assert_not_reached ; + end + + text_view.add_child_at_anchor(widget, + anchor) + + widget.show_all + i += 1 + end + end + + + def recursive_attach_view(depth, view, anchor) + return if depth > 4 + + child_view = Gtk::TextView.new(view.buffer) + + # Event box is to add a black border around each child view + event_box = Gtk::EventBox.new + color = Gdk::Color.parse("black") + event_box.modify_bg(Gtk::STATE_NORMAL, color) + + align = Gtk::Alignment.new(0.5, 0.5, 1.0, 1.0) + align.set_border_width(1) + + event_box.add(align) + align.add(child_view) + + view.add_child_at_anchor(event_box, anchor) + + recursive_attach_view(depth + 1, child_view, anchor) + end + + end +end + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/tree_store.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/tree_store.rb new file mode 100644 index 0000000..ca9b4a4 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/gtk-demo/tree_store.rb @@ -0,0 +1,270 @@ +# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team +# This program is licenced under the same licence as Ruby-GNOME2. +# +# $Id: tree_store.rb,v 1.7 2005/02/06 18:25:13 kzys Exp $ +=begin += Tree View/Tree Store + +The Gtk::TreeStore is used to store data in tree form, to be +used later on by a Gtk::TreeView to display it. This demo builds +a simple Gtk::TreeStore and displays it. If you're new to the +GtkTreeView widgets and associates, look into the Gtk::ListStore +example first. +=end +require 'common' + +module Demo + class TreeStore < BasicWindow + # TreeItem structure + TreeItem = Struct.new('TreeItem', + :label, + :alex, :havoc, :tim, :owen, :dave, + :world_holiday) # shared by the European hackers + + # columns + ( + HOLIDAY_NAME_COLUMN, + ALEX_COLUMN, + HAVOC_COLUMN, + TIM_COLUMN, + OWEN_COLUMN, + DAVE_COLUMN, + + VISIBLE_COLUMN, + WORLD_COLUMN, + NUM_COLUMNS, + ) = *(0..9).to_a + + + # tree data + TOPLEVEL = [ + ['January', + [ + ["New Years Day", true, true, true, true, false, true], + ["Presidential Inauguration", false, true, false, true, false, false], + ["Martin Luther King Jr. day", false, true, false, true, false, false], + ] + ], + ['February', + [ + ["Presidents' Day", false, true, false, true, false, false], + ["Groundhog Day", false, false, false, false, false, false], + ["Valentine's Day", false, false, false, false, true, true], + ] + ], + ['March', + [ + ["National Tree Planting Day", false, false, false, false, false, false], + [ "St Patrick's Day", false, false, false, false, false, true], + ] + ], + ['April', + [ + [ "April Fools' Day", false, false, false, false, false, true ], + [ "Army Day", false, false, false, false, false, false ], + [ "Earth Day", false, false, false, false, false, true ], + [ "Administrative Professionals' Day", false, false, false, false, false, false ], + ]], + ['May', + [ + [ "Nurses' Day", false, false, false, false, false, false ], + [ "National Day of Prayer", false, false, false, false, false, false ], + [ "Mothers' Day", false, false, false, false, false, true ], + [ "Armed Forces Day", false, false, false, false, false, false ], + [ "Memorial Day", true, true, true, true, false, true ], + + ] + ], + ['June', + [ + [ "June Fathers' Day", false, false, false, false, false, true ], + [ "Juneteenth (Liberation of Slaves)", false, false, false, false, false, false ], + [ "Flag Day", false, true, false, true, false, false ], + ] + ], + ['July', + [ + [ "Parents' Day", false, false, false, false, false, true ], + [ "Independence Day", false, true, false, true, false, false ], + ] + ], + ['August', + [ + [ "Air Force Day", false, false, false, false, false, false ], + [ "Coast Guard Day", false, false, false, false, false, false ], + [ "Friendship Day", false, false, false, false, false, false ], + ] + ], + ['September', + [ + [ "Grandparents' Day", false, false, false, false, false, true ], + [ "Citizenship Day or Constitution Day", false, false, false, false, false, false ], + [ "Labor Day", true, true, true, true, false, true ], + ] + ], + ['October', + [ + [ "National Children's Day", false, false, false, false, false, false ], + [ "Bosses' Day", false, false, false, false, false, false ], + [ "Sweetest Day", false, false, false, false, false, false ], + [ "Mother-in-Law's Day", false, false, false, false, false, false ], + [ "Navy Day", false, false, false, false, false, false ], + [ "Columbus Day", false, true, false, true, false, false ], + [ "Halloween", false, false, false, false, false, true ], + ] + ], + ['November', + [ + [ "Marine Corps Day", false, false, false, false, false, false ], + [ "Veterans' Day", true, true, true, true, false, true ], + [ "Thanksgiving", false, true, false, true, false, false ], + ] + ], + ['December', + [ + [ 'Pearl Harbor Remembrance Day', false, false, false, false, false, false ], + [ 'Christmas', true, true, true, true, false, true ], + [ 'Kwanzaa', false, false, false, false, false, false ], + ] + ], + ].collect do |month_name, holidays| + [ + month_name, + holidays.collect do |args| TreeItem.new(args) end, + ] + end + + def initialize + # create window, etc + super('Card planning sheet') + + vbox = Gtk::VBox.new(false, 8) + vbox.border_width = 8 + add(vbox) + + vbox.pack_start(Gtk::Label.new("Jonathan's Holiday Card Planning Sheet"), + false, false, 0) + + sw = Gtk::ScrolledWindow.new(nil, nil) + sw.shadow_type = Gtk::SHADOW_ETCHED_IN + sw.set_policy(Gtk::POLICY_AUTOMATIC, + Gtk::POLICY_AUTOMATIC) + vbox.pack_start(sw, true, true, 0) + + # create model + model = create_model + + # create tree view + treeview = Gtk::TreeView.new(model) + treeview.rules_hint = true + treeview.selection.mode = Gtk::SELECTION_MULTIPLE + + add_columns(treeview) + + sw.add(treeview) + + # expand all rows after the treeview widget has been realized + treeview.signal_connect('realize') do + treeview.expand_all + end + set_default_size(650, 400) + end + + def create_model + # create tree store + model = Gtk::TreeStore.new(String, + TrueClass, + TrueClass, + TrueClass, + TrueClass, + TrueClass, + TrueClass, + TrueClass) + + # add data to the tree store + TOPLEVEL.each do |month_name, holidays| + iter = model.append(nil) + + iter[HOLIDAY_NAME_COLUMN] = month_name + (ALEX_COLUMN..DAVE_COLUMN).each do |index| + iter[index] = false + end + + # add children + holidays.each do |holiday| + child_iter = model.append(iter) + child_iter[HOLIDAY_NAME_COLUMN] = holiday.label[0] + %w(alex havoc tim owen dave).each_with_index do |person, i| + child_iter[ALEX_COLUMN + i] = holiday[person] + end + child_iter[VISIBLE_COLUMN] = true + child_iter[WORLD_COLUMN] = holiday.world_holiday + end + + end + + return model + end + + def add_columns(treeview) + model = treeview.model + + # column for holiday names + renderer = Gtk::CellRendererText.new + renderer.xalign = 0.0 + + col_offset = treeview.insert_column(-1, 'Holiday', + renderer, + 'text' => HOLIDAY_NAME_COLUMN) + column = treeview.get_column(col_offset - 1) + column.clickable = true + + [ + ['Alex', true ], + ['Havoc', false], + ['Tim', true ], + ['Owen', false], + ['Dave', false], + ].each_with_index do |args, i| + person, european = *args + renderer = Gtk::CellRendererToggle.new + renderer.xalign = 0.0 + eval(%Q[def renderer.column; #{ALEX_COLUMN + i}; end]) + + renderer.signal_connect('toggled') do |cell, path| + item_toggled(cell, path, model) + end + + attributes = { + 'active' => (ALEX_COLUMN + i), + 'visible' => VISIBLE_COLUMN, + } + if european + attributes['activatable'] = WORLD_COLUMN + end + col_offset = treeview.insert_column(-1, person, renderer, attributes) + + column = treeview.get_column(col_offset - 1) + column.sizing = Gtk::TreeViewColumn::FIXED + column.fixed_width = 50 + column.clickable = true + end + end + + def item_toggled (cell, path_str, model) + path = Gtk::TreePath.new(path_str) + + column = cell.column + + # get toggled iter + iter = model.get_iter(path) + toggle_item = iter[column] + + # do something with the value + toggle_item ^= 1 + + # set new value + iter[column] = toggle_item + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/aboutdialog.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/aboutdialog.rb new file mode 100644 index 0000000..812ffe8 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/aboutdialog.rb @@ -0,0 +1,42 @@ +#!/usr/bin/env ruby +=begin + aboutdialog.rb - Ruby/GTK sample script. + + Copyright (c) 2005,2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: aboutdialog.rb,v 1.2 2006/06/17 13:18:12 mutoh Exp $ +=end +require 'gtk2' + +if str = Gtk.check_version(2, 6, 0) + puts "This sample requires GTK+ 2.6.0 or later" + puts str + exit +end + +Gtk::AboutDialog.set_email_hook {|about, link| + p "email_hook" + p link +} +Gtk::AboutDialog.set_url_hook {|about, link| + p "url_hook" + p link +} + +a = Gtk::AboutDialog.new +a.artists = ["Artist 1 <no1@foo.bar.com>", "Artist 2 <no2@foo.bar.com>"] +a.authors = ["Author 1 <no1@foo.bar.com>", "Author 2 <no2@foo.bar.com>"] +a.comments = "This is a sample script for Gtk::AboutDialog" +a.copyright = "Copyright (C) 2005 Ruby-GNOME2 Project" +a.documenters = ["Documenter 1 <no1@foo.bar.com>", "Documenter 2 <no2@foo.bar.com>"] +a.license = "This program is licenced under the same licence as Ruby-GNOME2." +a.logo = Gdk::Pixbuf.new("gnome-logo-icon.png") +a.program_name = "Gtk::AboutDialog sample" +a.translator_credits = "Translator 1\nTranslator 2\n" +a.version = "1.0.0" +a.website = "http://ruby-gnome2.sourceforge.jp" +a.website_label = "Ruby-GNOME2 Project Website" + +p a.run + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/aboutdialog2.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/aboutdialog2.rb new file mode 100644 index 0000000..cb4acdf --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/aboutdialog2.rb @@ -0,0 +1,42 @@ +#!/usr/bin/env ruby +=begin + aboutdialog2.rb - Ruby/GTK sample script. + + Copyright (c) 2005,2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: aboutdialog2.rb,v 1.2 2006/06/17 13:18:12 mutoh Exp $ +=end +require 'gtk2' + +if str = Gtk.check_version(2, 6, 0) + puts "This sample requires GTK+ 2.6.0 or later" + puts str + exit +end + +Gtk::AboutDialog.set_email_hook {|about, link| + p "email_hook" + p link +} +Gtk::AboutDialog.set_url_hook {|about, link| + p "url_hook" + p link +} + +Gtk::AboutDialog.show(nil, + "artists" => ["Artist 1 <no1@foo.bar.com>", "Artist 2 <no2@foo.bar.com>"], + "authors" => ["Author 1 <no1@foo.bar.com>", "Author 2 <no2@foo.bar.com>"], + "comments" => "This is a sample script for Gtk::AboutDialog", + "copyright" => "Copyright (C) 2005 Ruby-GNOME2 Project", + "documenters" => ["Documenter 1 <no1@foo.bar.com>", "Documenter 2 <no2@foo.bar.com>"], + "license" => "This program is licenced under the same licence as Ruby-GNOME2.", + "logo_icon_name" => "gtk-home", + "program_name" => "Gtk::AboutDialog sample", + "translator_credits" => "Translator 1 <no1@foo.bar.com>\nTranslator 2 <no2@foo.bar.com>\n", + "version" => "1.0.0", + "website" => "http://ruby-gnome2.sourceforge.jp", + "website_label" => "Ruby-GNOME2 Project Website" + ) + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/alpha-demo.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/alpha-demo.rb new file mode 100755 index 0000000..4013da8 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/alpha-demo.rb @@ -0,0 +1,70 @@ +#!/usr/bin/env ruby +=begin + alpha-demo.rb - alpha blended window sample script. (need xcompmgr) + + Original: alphademo.py by Mike Hearn (*1) and David Trowbridge (*2) + * (1) http://plan99.net/~mike/blog/2006/06/05/alpha-blended-windows-in-python/ + * (2) http://david.navi.cx/blog/?p=91 + + Translated to Ruby by Juergen Mangler <juergen.mangler@univie.ac.at> + + Copyright (c) 2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: alpha-demo.rb,v 1.1 2007/01/06 03:55:44 ktou Exp $ +=end + +require 'gtk2' +require 'cairo' + +class AlphaDemo < Gtk::Window + + def initialize() + super() + + set_app_paintable(true) + set_title("AlphaDemo") + set_decorated(false) + set_default_size(200, 220) + signal_connect("delete_event") do + Gtk.main_quit + end + set_double_buffered(false) + + signal_connect('expose-event') do |widget, event| + cr = widget.window.create_cairo_context + + rgba = [1.0, 1.0, 1.0] + rgba << 0.0 if @supports_alpha + cr.set_source_rgba(rgba) + cr.set_operator(Cairo::OPERATOR_SOURCE) + cr.paint + + twidth, theight = widget.size + + cr.set_source_rgba(1.0, 0.2, 0.2, 0.6) + radius = [twidth, theight].min.to_f / 2 - 0.8 + + cr.arc(twidth.to_f / 2, theight.to_f / 2, radius, 0, 2.0 * Math::PI) + cr.fill_preserve + cr.stroke + end + signal_connect('screen-changed') do |widget, old_screen| + screen_changed(widget, old_screen) + end + + screen_changed(self) + end + + def screen_changed(widget,old_screen=nil) + tcolormap = widget.screen.rgba_colormap + @supports_alpha = !tcolormap.nil? + tcolormap ||= widget.screen.rgb_colormap + widget.set_colormap(tcolormap) + end +end + +alpha = AlphaDemo.new +alpha.show + +Gtk.main() diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/assistant.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/assistant.rb new file mode 100755 index 0000000..7ab1f0a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/assistant.rb @@ -0,0 +1,347 @@ +#!/usr/bin/env ruby +=begin + test-assistant.rb - Ruby/GTK version of testassistant.c from gtk+ 2.10 sources. + + Guillaume Cottenceau for the ruby-gnome2 project. + + Copyright (c) 2005,2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: assistant.rb,v 1.1 2006/11/23 08:39:12 mutoh Exp $ +=end + +require 'gtk2' + +if str = Gtk.check_version(2, 10, 0) + puts "This sample requires GTK+ 2.10.0 or later" + puts str + exit +end + +class AssistantRunner + def initialize + @simple_assistant = nil + @generous_assistant = nil + @selected_branch = "A" + @nonlinear_assistant = nil + @full_featured_assistant = nil + end + + def run_simple_assistant + @simple_assistant = run_assistant(@simple_assistant, + :create_simple_assistant) + end + + def run_generous_assistant + @generous_assistant = run_assistant(@generous_assistant, + :create_generous_assistant) + end + + def run_nonlinear_assistant + @nonlinear_assistant = run_assistant(@nonlinear_assistant, + :create_nonlinear_assistant) + end + + def run_full_featured_assistant + @full_featured_assistant = run_assistant(@full_featured_assistant, + :create_full_featured_assistant) + end + + private + def run_assistant(assistant, assistant_create_method) + assistant ||= send(assistant_create_method) + if !assistant.visible? + assistant.show + else + assistant.destroy + assistant = nil + end + assistant + end + + def add_completion_test_page(assistant, text, visible, complete) + page = Gtk::VBox.new(0, 0) + check = Gtk::CheckButton.new("Complete") + page.add(Gtk::Label.new(text)) + page.add(check) + check.active = complete + check.signal_connect('toggled') do + complete = check.active? + assistant.set_page_complete(page, complete) + end + page.show_all if visible + assistant.append_page(page) + assistant.set_page_title(page, text) + assistant.set_page_complete(page, complete) + page + end + + def create_test_page(text) + Gtk::Label.new(text) + end + + def prepare_cb(assistant, page) + if page.is_a?(Gtk::Label) + puts "prepare: #{page.text}" + elsif assistant.get_page_type(page) == Gtk::Assistant::PAGE_PROGRESS + progress = page.child + assistant.set_page_complete(page, false) + progress.fraction = 0.0 + Gtk.timeout_add(300) do + page = assistant.get_nth_page(assistant.current_page) + progress = page.child + value = progress.fraction = progress.fraction + 0.1 + continue = value < 1.0 + assistant.set_page_complete(page, true) unless continue + continue + end + else + puts "prepare: #{assistant.current_page}" + end + end + + def create_simple_assistant + assistant = Gtk::Assistant.new + assistant.set_default_size(400, 300) + assistant.signal_connect('cancel') do + puts "cancel" + assistant.hide + end + assistant.signal_connect('close') do + puts "close" + assistant.hide + end + assistant.signal_connect('apply') do + puts "apply" + end + assistant.signal_connect('prepare') do |_assistant, page| + prepare_cb(_assistant, page) + end + + page = create_test_page("Page 1") + page.show + assistant.append_page(page) + assistant.set_page_title(page, "Page 1") + assistant.set_page_complete(page, true) + + page = create_test_page("Page 2") + page.show + assistant.append_page(page) + assistant.set_page_title(page, "Page 2") + assistant.set_page_type(page, :confirm) + assistant.set_page_complete(page, true) + end + + def create_generous_assistant + assistant = Gtk::Assistant.new + assistant.set_default_size(400, 300) + assistant.signal_connect('cancel') do + puts "cancel" + assistant.hide + end + assistant.signal_connect('close') do + puts "close" + assistant.hide + end + assistant.signal_connect('apply') do + puts "apply" + end + assistant.signal_connect('prepare') do|_assistant, page| + prepare_cb(_assistant, page) + end + + page = create_test_page("Introduction") + page.show + assistant.append_page(page) + assistant.set_page_title(page, "Introduction") + assistant.set_page_type(page, :intro) + assistant.set_page_complete(page, true) + + page = add_completion_test_page(assistant, "Content", true, false) + next_page = add_completion_test_page(assistant, "More Content", true, true) + + check = Gtk::CheckButton.new("Next page visible"); + check.active = true + check.signal_connect('toggled') do + puts "beuh" + next_page.visible = check.active? + end + check.show + page.add(check) + + add_completion_test_page(assistant, "Even More Content", true, true) + + page = create_test_page("Confirmation") + page.show + assistant.append_page(page) + assistant.set_page_title(page, "Confirmation") + assistant.set_page_type(page, :confirm) + assistant.set_page_complete(page, true) + + page = Gtk::Alignment.new(0.5, 0.5, 0.9, 0.0) + page.add(Gtk::ProgressBar.new) + page.show_all + assistant.append_page(page) + assistant.set_page_title(page, "Progress") + assistant.set_page_type(page, :progress) + assistant.set_page_complete(page, true) + + page = create_test_page("Summary") + page.show + assistant.append_page(page) + assistant.set_page_title(page, "Summary") + assistant.set_page_type(page, :summary) + assistant.set_page_complete(page, true) + end + + def create_nonlinear_assistant + assistant = Gtk::Assistant.new + assistant.set_default_size(400, 300) + assistant.signal_connect('cancel') do + puts "cancel" + assistant.hide + end + assistant.signal_connect('close') do + puts "close" + assistant.hide + end + assistant.signal_connect('apply') do + puts "apply" + end + assistant.signal_connect('prepare') do |_assistant, page| + prepare_cb(_assistant, page) + end + + assistant.set_forward_page_func do |current_page| + retval = -1 + if current_page == 0 + if @selected_branch == 'A' + retval = 1 + else + retval = 2 + end + elsif current_page == 1 || current_page == 2 + retval = 3 + end + retval + end + + page = Gtk::VBox.new(false, 6) + button = Gtk::RadioButton.new('branch A') + page.pack_start(button, false, false, 0) + button.signal_connect('toggled') do + @selected_branch = 'A' + end + button.active = true + button = Gtk::RadioButton.new(button, 'branch B') + page.pack_start(button, false, false, 0) + button.signal_connect('toggled') do + @selected_branch = 'B' + end + page.show_all + assistant.append_page(page) + assistant.set_page_title(page, "Page 1") + assistant.set_page_complete(page, true) + + page = create_test_page("Page 2A") + page.show + assistant.append_page(page) + assistant.set_page_title(page, "Page 2A") + assistant.set_page_complete(page, true) + + page = create_test_page("Page 2B") + page.show + assistant.append_page(page) + assistant.set_page_title(page, "Page 2B") + assistant.set_page_complete(page, true) + + page = create_test_page("Confirmation") + page.show + assistant.append_page(page) + assistant.set_page_title(page, "Confirmation") + assistant.set_page_type(page, :confirm) + assistant.set_page_complete(page, true) + end + + def create_full_featured_assistant + assistant = Gtk::Assistant.new + assistant.set_default_size(400, 300) + assistant.signal_connect('cancel') do + puts "cancel" + assistant.hide + end + assistant.signal_connect('close') do + puts "close" + assistant.hide + end + assistant.signal_connect('apply') do + puts "apply" + end + assistant.signal_connect('prepare') do |_assistant, page| + prepare_cb(_assistant, page) + end + + button = Gtk::Button.new(Gtk::Stock::STOP) + button.show + assistant.add_action_widget(button) + + page = create_test_page("Page 1") + page.show + assistant.append_page(page) + assistant.set_page_title(page, "Page 1") + assistant.set_page_complete(page, true) + + #- set a side image + pixbuf = page.render_icon(Gtk::Stock::DIALOG_WARNING, :dialog) + assistant.set_page_side_image(page, pixbuf) + + #- set a header image + pixbuf = page.render_icon(Gtk::Stock::DIALOG_INFO, :dialog) + assistant.set_page_header_image(page, pixbuf) + + page = create_test_page("Invisible page") + assistant.append_page(page) + + page = create_test_page("Page 3") + page.show + assistant.append_page(page) + assistant.set_page_title(page, "Page 3") + assistant.set_page_type(page, :confirm) + assistant.set_page_complete(page, true) + + #- set a header image + pixbuf = page.render_icon(Gtk::Stock::DIALOG_INFO, :dialog) + assistant.set_page_header_image(page, pixbuf) + + assistant + end +end + +runner = AssistantRunner.new +buttons = [ + [ 'simple assistant', proc { runner.run_simple_assistant } ], + [ 'generous assistant', proc { runner.run_generous_assistant } ], + [ 'nonlinear assistant', proc { runner.run_nonlinear_assistant } ], + [ 'full featured assistant', proc { runner.run_full_featured_assistant } ], +] + +if ENV['RTL'] + Gtk::Widget.default_direction = Gtk::Widget::TEXT_DIR_RTL +end + +window = Gtk::Window.new(Gtk::Window::TOPLEVEL) +window.signal_connect('destroy') { Gtk.main_quit } +window.signal_connect('delete-event') { false } + +box = Gtk::VBox.new(false, 6) +window.add(box) + +buttons.each do |label, callback| + button = Gtk::Button.new(label) + button.signal_connect('clicked') do + callback.call + end + box.pack_start(button, true, true, 0) +end +window.show_all +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/bindings.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/bindings.rb new file mode 100644 index 0000000..1a878b3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/bindings.rb @@ -0,0 +1,107 @@ +#!/usr/bin/env ruby +=begin + bindings.rb - Ruby/GTK sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: bindings.rb,v 1.7 2006/06/17 13:18:12 mutoh Exp $ +=end + +=begin +Usage: + bindings.rb <filename> + + Following key bindings are effective in the TextView area. + + <space> : scroll down by one page + <backspace> : scroll up by one page + j : move cursor donw by one line + k : move cursor up by one line + + clicking buttons cause following effect + + "space" : same as pressing <space> in text view area. + "back_space" : same as pressing <backspace> in text view area. + "cancel j/k" : disable 'j' and 'k' binding +=end +require 'gtk2' + +class Pager < Gtk::TextView + type_register + + # widget's key binding can be defined like this + binding_set.add_signal(Gdk::Keyval::GDK_space, 0, + "move_cursor", + Gtk::MOVEMENT_PAGES, 1, false) + binding_set.add_signal(Gdk::Keyval::GDK_BackSpace, 0, + "move_cursor", + Gtk::MOVEMENT_PAGES, -1, false) + + def initialize(path) + @path = path + super() + @buffer = self.buffer + load + set_editable(false) + set_size_request(400, 400) + end + + def load + open(@path).read.each_line do |line| + @buffer.insert_at_cursor(line) + end + @buffer.place_cursor(@buffer.start_iter) + end +end + +path = ARGV[0] || __FILE__ + +window = Gtk::Window.new +window.name = "pager_window" +sw = Gtk::ScrolledWindow.new +vbox = Gtk::VBox.new +hbox = Gtk::HBox.new +pager = Pager.new(path) + +hbox.add(button1 = Gtk::Button.new("space")) +hbox.add(button2 = Gtk::Button.new("back_space")) +hbox.add(button3 = Gtk::Button.new("cancel j/k")) + +button1.signal_connect("clicked") do + Pager.binding_set.activate(Gdk::Keyval::GDK_space, 0, pager) +end +button2.signal_connect("clicked") do + pager.bindings_activate(Gdk::Keyval::GDK_BackSpace, 0) +end + +# Key bindings can be attached to any widget by +# Gtk::BindingSet#add_path +# see RC Files section of GTK+ documentation for more detail. +bset = Gtk::BindingSet.new("j_and_k") +bset.add_signal(Gdk::Keyval::GDK_j, 0, + "move_cursor", + Gtk::MOVEMENT_DISPLAY_LINES, 1, false) +bset.add_signal(Gdk::Keyval::GDK_k, 0, + "move_cursor", + Gtk::MOVEMENT_DISPLAY_LINES, -1, false) +bset.add_path(Gtk::PathType::WIDGET, "pager_window.*.Pager", + Gtk::PathPriorityType::APPLICATION) + +button3.signal_connect("clicked") do + bset.entry_clear(Gdk::Keyval::GDK_j, 0) + bset.entry_clear(Gdk::Keyval::GDK_k, 0) +end + +sw.add(pager) +vbox.add(hbox).add(sw) +window.add(vbox) +window.show_all + +pager.grab_focus + +window.signal_connect("destroy") { Gtk.main_quit } + +Gtk.main + + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/button.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/button.rb new file mode 100644 index 0000000..ec290e8 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/button.rb @@ -0,0 +1,69 @@ +#!/usr/bin/env ruby +=begin + button.rb - Ruby/GTK sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: button.rb,v 1.10 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("buttons") +window.border_width = 0 + +box1 = Gtk::VBox.new(false, 0) +window.add(box1) + +table = Gtk::Table.new(3, 3, false) +table.set_row_spacings(5) +table.set_column_spacings(5) +table.set_border_width(10) +box1.pack_start(table, true, true, 0) + +button = [] +0.upto(8) do |i| + button.push Gtk::Button.new("button"+(i+1).to_s) +end +0.upto(8) do |i| + button[i].signal_connect("clicked") do |w| + p [i] + j = (i + 1) % 9 + if button[j].visible? + button[j].hide + else + button[j].show + end + end + button[i].show +end +table.attach(button[0], 0, 1, 0, 1, nil, nil, 0, 0) +table.attach(button[1], 1, 2, 1, 2, nil, nil, 0, 0) +table.attach(button[2], 2, 3, 2, 3, nil, nil, 0, 0) +table.attach(button[3], 0, 1, 2, 3, nil, nil, 0, 0) +table.attach(button[4], 2, 3, 0, 1, nil, nil, 0, 0) +table.attach(button[5], 1, 2, 2, 3, nil, nil, 0, 0) +table.attach(button[6], 1, 2, 0, 1, nil, nil, 0, 0) +table.attach(button[7], 2, 3, 1, 2, nil, nil, 0, 0) +table.attach(button[8], 0, 1, 1, 2, nil, nil, 0, 0) + +separator = Gtk::HSeparator.new +box1.pack_start(separator, false, true, 0) + +box2 = Gtk::VBox.new(false, 10) +box2.border_width = 10 +box1.pack_start(box2, false, true, 0) + +close = Gtk::Button.new("close") +close.signal_connect("clicked") do + Gtk.main_quit +end + +box2.pack_start(close, true, true, 0) +close.can_default = true +close.grab_default + +window.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/button2.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/button2.rb new file mode 100644 index 0000000..72b8865 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/button2.rb @@ -0,0 +1,28 @@ +#!/usr/local/bin/ruby +=begin + button2.rb - Ruby/GTK2 sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: button2.rb,v 1.4 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("Gtk::Button sample") + +button1 = Gtk::Button.new("_HELLO") +button2 = Gtk::Button.new("_HELLO", false) +button3 = Gtk::Button.new(Gtk::Stock::QUIT) + +button3.signal_connect("clicked"){ Gtk.main_quit } + +box = Gtk::VBox.new +box.add(button1) +box.add(button2) +box.add(button3) + +window.add(box).set_default_size(100,100).show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/buttonbox.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/buttonbox.rb new file mode 100644 index 0000000..4e51651 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/buttonbox.rb @@ -0,0 +1,93 @@ +#!/usr/bin/env ruby +=begin + buttonbox.rb - Ruby/GTK2 sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: buttonbox.rb,v 1.9 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +def create_bbox_window(horizontal, title, pos, spacing, layout) + window = Gtk::Window.new(title) + window.signal_connect("delete_event") do + window.destroy + end + + box1 = Gtk::VBox.new(false, 0) + window.add(box1) + + if horizontal + window.set_default_size(550, 60) + window.move(150, pos) + bbox = Gtk::HButtonBox.new + else + window.set_default_size(150, 400) + window.move(pos, 200) + bbox = Gtk::VButtonBox.new + end + + bbox.layout_style = layout + bbox.spacing = spacing + box1.border_width = 25 + box1.pack_start(bbox, true, true, 0) + + button = Gtk::Button.new("OK") + bbox.add(button) + button.signal_connect("clicked") do + window.destroy + end + + button = Gtk::Button.new("Cancel") + bbox.add(button) + button.signal_connect("clicked") do + window.destroy + end + + button = Gtk::Button.new("Help") + bbox.add(button) + window.show_all +end + +def test_hbbox + create_bbox_window(true, "Spread", 50, 40, Gtk::ButtonBox::SPREAD) + create_bbox_window(true, "Edge", 250, 40, Gtk::ButtonBox::EDGE) + create_bbox_window(true, "Start", 450, 40, Gtk::ButtonBox::START) + create_bbox_window(true, "End", 650, 15, Gtk::ButtonBox::END) +end + +def test_vbbox + create_bbox_window(false, "Spread", 50, 40, Gtk::ButtonBox::SPREAD) + create_bbox_window(false, "Edge", 250, 40, Gtk::ButtonBox::EDGE) + create_bbox_window(false, "Start", 450, 40, Gtk::ButtonBox::START) + create_bbox_window(false, "End", 650, 15, Gtk::ButtonBox::END) +end + +window = Gtk::Window.new("button box") +window.signal_connect("delete_event") do + Gtk.main_quit +end +window.border_width = 20 + +bbox = Gtk::HButtonBox.new +window.add(bbox) + +button = Gtk::Button.new("Horizontal") + +button.signal_connect("clicked") do + test_hbbox +end + +bbox.add(button) + +button = Gtk::Button.new("Vertical") +button.signal_connect("clicked") do + test_vbbox +end +bbox.add(button) + +window.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/cairo-pong.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/cairo-pong.rb new file mode 100755 index 0000000..c50d1dd --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/cairo-pong.rb @@ -0,0 +1,215 @@ +#!/usr/bin/env ruby +=begin + cairo-pong.rb - Ruby/GTK with cairo sample script. + + Original: gtkcairo sample by Evan Martins. + + Copyright (c) 2005,2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: cairo-pong.rb,v 1.3 2006/06/17 13:18:12 mutoh Exp $ +=end + +require "gtk2" + +unless Gdk.cairo_available? + raise "GTK+ 2.8.0 or later and cairo support are required." +end + +module Pong + class CenteredItem + attr_accessor :x, :y + attr_reader :width, :height + + def initialize(x, y, width, height) + @x = x + @y = y + @width = width + @height = height + end + + def min_x + @x - @width / 2 + end + + def max_x + @x + @width / 2 + end + + def min_y + @y - @height / 2 + end + + def max_y + @y + @height / 2 + end + end + + class CenteredCircle < CenteredItem + def draw(cr) + cr.translate(min_x, min_y) + cr.scale(@width, @height) + cr.arc(0.5, 0.5, 0.5, 0, 2 * Math::PI) + cr.fill + end + end + + class CenteredRect < CenteredItem + def draw(cr) + cr.translate(min_x, min_y) + cr.scale(@width, @height) + cr.rectangle(0, 0, 1, 1) + cr.fill + end + end + + class Ball < CenteredCircle + attr_accessor :dx, :dy + def initialize(dx=0.02, dy=0.02) + super(0.8, 0.5, 0.04, 0.04) + @dx = dx + @dy = dy + end + + def update + @x += @dx + @y += @dy + + # ball bouncing + if max_y > 1 + @y = 1 - (max_y - 1) + @dy *= -1 + elsif min_y < 0 + @y -= min_y + @dy *= -1 + end + + if max_x > 1 + @x = 1 - (max_x - 1) + @dx *= -1 + elsif min_x < 0 + @x -= min_x + @dx *= -1 + end + end + end + + class Paddle < CenteredRect + def initialize(field, x, y) + super(x, y, 0.05, 0.3) + @field = field + end + + def update(ball) + # is the ball coming towards us? + if (ball.x < @x and ball.dx > 0) or + (ball.x > @x and ball.dx < 0) + # move to intercept it + @y = ball.y + end + end + + def ball_hit?(ball) + ball.y > min_y and ball.y < max_y + end + + def update_ball(ball) + if ball_hit?(ball) + if ball.min_x < @x and ball.max_x > min_x # hit our left side + ball.x -= (ball.max_x - min_x) + ball.dx = -ball.dx + elsif ball.max_x > @x and ball.min_x < max_x # hit our right side + ball.x += (max_x - ball.min_x) + ball.dx = -ball.dx + end + end + end + end + + class Field + attr_accessor :width, :height + + def initialize(margin=0.05) + @margin = margin + + @left_paddle = Paddle.new(self, @margin, 0.5) + @right_paddle = Paddle.new(self, 1 - @margin, 0.7) + @paddles = [@left_paddle, @right_paddle] + @ball = Ball.new + end + + def update + @paddles.each do |paddle| + paddle.update(@ball) + end + @ball.update + @paddles.each do |paddle| + paddle.update_ball(@ball) + end + end + + def draw(cr) + cr.set_source_rgba(1, 1, 1) + cr.rectangle(0, 0, 1, 1) + cr.fill + + cr.save do + cr.set_source_rgba(0.8, 0.8, 0.8, 0.8) + cr.set_line_join(Cairo::LINE_JOIN_ROUND) + @paddles.each do |paddle| + cr.save {paddle.draw(cr)} + end + end + + cr.set_source_rgba(0, 0, 0) + cr.save {@ball.draw(cr)} + end + end + + class Window < Gtk::Window + def initialize(speed=30) + super() + @speed = speed + + self.title = 'Pong Demonstration' + signal_connect('destroy') { Gtk.main_quit } + signal_connect("key_press_event") do |widget, event| + if event.state.control_mask? and event.keyval == Gdk::Keyval::GDK_q + destroy + true + else + false + end + end + + set_default_size(260, 200) + + @field = Field.new + + @drawing_area = Gtk::DrawingArea.new + set_expose_event + + vb = Gtk::VBox.new(false, 5) + vb.border_width = 10 + vb.pack_start(@drawing_area, true, true, 0) + vb.show_all + add(vb) + + Gtk.timeout_add(@speed) do + @field.update + @drawing_area.queue_draw unless @drawing_area.destroyed? + end + end + + def set_expose_event + @drawing_area.signal_connect('expose_event') do |widget, event| + cr = widget.window.create_cairo_context + cr.scale(*widget.window.size) + @field.draw(cr) + end + end + end +end + +Pong::Window.new.show_all +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/calendar.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/calendar.rb new file mode 100644 index 0000000..f467d5d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/calendar.rb @@ -0,0 +1,62 @@ +=begin + calendar.rb - Gtk::Calendar sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: calendar.rb,v 1.7 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +cal = Gtk::Calendar.new + +w = Gtk::Window.new("Calendar sample") +w.add(cal).show_all.signal_connect('delete_event') do + Gtk.main_quit +end + +date = Time.new + +cal.select_month(date.month, date.year) +cal.select_day(date.day) +cal.mark_day(date.day) +#cal.clear_marks +cal.display_options(Gtk::Calendar::SHOW_HEADING | + Gtk::Calendar::SHOW_DAY_NAMES | + Gtk::Calendar::NO_MONTH_CHANGE | + Gtk::Calendar::SHOW_WEEK_NUMBERS | + Gtk::Calendar::WEEK_START_MONDAY) +year, month, day = cal.date +puts "this is #{month} #{day}, #{year}" + +cal.signal_connect('day_selected') do + year, month, day = cal.date + puts "selected day: #{day}" +end +cal.signal_connect('month_changed') do + year, month, day = cal.date + puts "changed month: #{month}" +end +cal.signal_connect('day_selected_double_click') do + year, month, day = cal.date + puts "dclicked day: #{day}" +end +cal.signal_connect('prev_month') do + year, month, day = cal.date + puts "prev month: #{month}" +end +cal.signal_connect('next_month') do + year, month, day = cal.date + puts "next_month: #{month}" +end +cal.signal_connect('prev_year') do + year, month, day = cal.date + puts "prev_year: #{year}" +end +cal.signal_connect('next_year') do + year, month, day = cal.date + puts "next year: #{year}" +end + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/checkbutton.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/checkbutton.rb new file mode 100644 index 0000000..6835879 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/checkbutton.rb @@ -0,0 +1,46 @@ +#!/usr/bin/env ruby +=begin + checkbutton.rb - Ruby/GTK2 sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: checkbutton.rb,v 1.10 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("check buttons") +window.border_width = 0 + +box1 = Gtk::VBox.new +window.add(box1) + +box2 = Gtk::VBox.new(false, 10) +box2.border_width = 10 +box1.pack_start(box2) + +button1 = Gtk::CheckButton.new("_button1") +button2 = Gtk::CheckButton.new("_button2", false) +button3 = Gtk::CheckButton.new(Gtk::Stock::QUIT) +box2.add(button1) +box2.add(button2) +box2.add(button3) + +box1.pack_start(Gtk::HSeparator.new) + +box2 = Gtk::VBox.new(false, 10) +box2.border_width = 10 +box1.pack_start(box2) + +close = Gtk::Button.new("close") +close.signal_connect("clicked") do + Gtk.main_quit +end +box2.pack_start(close) +close.can_default = true +close.grab_default + +window.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/colorselection.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/colorselection.rb new file mode 100644 index 0000000..8c64521 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/colorselection.rb @@ -0,0 +1,25 @@ +=begin + colorselection.rb - Gtk::ColorSelection sample script. + + Copyright (C) 2005,2006 Masao Mutoh + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: colorselection.rb,v 1.3 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +settings = Gtk::Settings.default + +# You can save the palette to use right click on the palette. +Gtk::ColorSelection.set_change_palette_hook{|screen, colors| + puts strs = Gtk::ColorSelection.palette_to_string(colors) + settings.gtk_color_palette = strs +} + +a = Gtk::ColorSelection.new +a.has_palette = true + +Gtk::Window.new.add(a).show_all.signal_connect("destroy"){Gtk.main_quit} + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/combo_check.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/combo_check.rb new file mode 100644 index 0000000..2e698e0 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/combo_check.rb @@ -0,0 +1,71 @@ +#!/usr/bin/env ruby +=begin + combo_check.rb - Ruby/GTK sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: combo_check.rb,v 1.9 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("entry") +window.border_width = 0 + +box1 = Gtk::VBox.new +window.add(box1) + +box2 = Gtk::VBox.new(false, 10) +box2.border_width = 10 +box1.pack_start(box2) + +entry = Gtk::Entry.new +entry.text = "hello world" +entry.select_region(0, -1) +box2.pack_start(entry) + +# +# Gtk::Combo has been deprecated. Use Gtk::ComboBox instead. +# +cb = Gtk::Combo.new +cb.set_popdown_strings(["item0", + "item1 item1", + "item2 item2 item2", + "item3 item3 item3 item3", + "item4 item4 item4 item4 item4", + "item5 item5 item5 item5 item5 item5", + "item6 item6 item6 item6 item6", + "item7 item7 item7 item7", + "item8 item8 item8", + "item9 item9"]) +cb.entry.set_text("hello world") +cb.entry.select_region(0, -1) +box2.pack_start(cb, true, true, 0) + +check = Gtk::CheckButton.new("Editable") +box2.pack_start(check, false, true, 0) +check.signal_connect("toggled") do + cb.entry.set_editable(check.active?) + entry.set_editable(check.active?) +end +check.state = 0 + +box1.pack_start(Gtk::HSeparator.new) + +box2 = Gtk::VBox.new(false, 10) +box2.border_width = 10 +box1.pack_start(box2) + +button = Gtk::Button.new("close") +button.signal_connect("clicked") do + Gtk.main_quit +end +box2.pack_start(button) + +button.can_default = true +button.grab_default + +window.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/combobox.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/combobox.rb new file mode 100644 index 0000000..23242bd --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/combobox.rb @@ -0,0 +1,86 @@ +#!/usr/bin/env ruby +=begin + combobox.rb - Ruby/GTK sample script. + + Copyright (c) 2004-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: combobox.rb,v 1.3 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +if str = Gtk.check_version(2, 4, 0) + puts "This sample requires GTK+ 2.4.0 or later" + puts str + exit +end + +window = Gtk::Window.new("Gtk::ComboBox sample") +window.signal_connect("destroy"){Gtk.main_quit} + +# +# Text only +# +combo1 = Gtk::ComboBox.new +["foo", "bar", "fuga", "hoge"].each do |val| + combo1.append_text(val) +end +combo1.active = 1 + +combo1.signal_connect("changed") do + p "combo1: #{combo1.active}, #{combo1.active_iter[0]}" +end + +# +# Icon and text +# +model = Gtk::ListStore.new(Gdk::Pixbuf, String) +[[Gtk::Stock::QUIT, "quit"], + [Gtk::Stock::CANCEL, "cancel"], + [Gtk::Stock::OK, "ok"]].each do |stock, name| + iter = model.append + iter[0] = window.render_icon(stock, Gtk::IconSize::MENU, "icon") + iter[1] = name +end + +combo2 = Gtk::ComboBox.new(model) + +# column 1 +renderer = Gtk::CellRendererPixbuf.new +combo2.pack_start(renderer, false) +combo2.set_attributes(renderer, :pixbuf => 0) + +# column 2 +renderer = Gtk::CellRendererText.new +combo2.pack_start(renderer, true) +combo2.set_attributes(renderer, :text => 1) + +combo2.active = 2 + +combo2.signal_connect("changed") do + p "combo2: #{combo2.active}, #{combo2.active_iter[1]}" +end + +# +# Gtk::ComboBoxEntry +# +combo3 = Gtk::ComboBoxEntry.new +["foo", "bar", "fuga", "hoge"].each do |val| + combo3.append_text(val) +end +combo3.active = 1 + +combo3.signal_connect("changed") do + if combo3.active_iter + p "combo3: #{combo3.active}, #{combo3.active_iter[0]}" + end +end + +# Show main window +vbox = Gtk::VBox.new +vbox.add(combo1).add(combo2).add(combo3) +window.add(vbox).show_all + +Gtk.main + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/composited-windows.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/composited-windows.rb new file mode 100644 index 0000000..a7a0163 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/composited-windows.rb @@ -0,0 +1,113 @@ +#!/usr/bin/env ruby +=begin + composited-windows.rb - Sample script translated from http://library.gnome.org/devel/gdk/unstable/gdk-Windows.html#composited-window-example + + Copyright (c) 2008 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. +=end + +require 'gtk2' + +if str = Gtk.check_version(2, 12, 0) + puts "This sample requires GTK+ 2.12.0 or later." + puts str + exit +end + +unless Gdk.cairo_available? + puts "This sample requires Cairo support." + exit +end + + +Gtk.init + +# Make the widgets +button = Gtk::Button.new("A Button") +event = Gtk::EventBox.new +window = Gtk::Window.new(Gtk::Window::TOPLEVEL) + +# Put a red background on the window +window.modify_bg(Gtk::STATE_NORMAL, Gdk::Color.parse("red")) + +# Set the colourmap for the event box. Must be done before the event box is realised. +event.colormap = event.screen.rgba_colormap + +# Set our event box to have a fully-transparent background +# drawn on it. Currently there is no way to simply tell GTK+ +# that "transparency" is the background colour for a widget. +event.app_paintable = true + +event.signal_connect('expose-event') do |widget, event| + # This function simply draws a transparency onto a widget on the area + # for which it receives expose events. This is intended to give the + # event box a "transparent" background. + # + # In order for this to work properly, the widget must have an RGBA + # colourmap. The widget should also be set as app-paintable since it + # doesn't make sense for GTK+ to draw a background if we are drawing it + # (and because GTK+ might actually replace our transparency with its + # default background colour). + # + cr = widget.window.create_cairo_context + cr.operator = Cairo::OPERATOR_CLEAR + cr.gdk_region(event.region) + cr.fill + false +end + +# Put them inside one another +window.border_width = 10 +window.add(event) +event.add(button) + +# Realize and show everything +window.show_all + +# Set the event box GdkWindow to be composited. +# Obviously must be performed after event box is realised. +event.window.composited = true + +# Set up the compositing handler. +# Note that we do _after_ so that the normal (red) background is drawn +# by gtk before our compositing occurs. +# +window.signal_connect_after('expose-event') do |widget, event| + # This function performs the actual compositing of the event box onto + # the already-existing background of the window at 50% normal opacity. + # + # In this case we do not want app-paintable to be set on the widget + # since we want it to draw its own (red) background. Because of this, + # however, we must ensure that we use #signal_connect_after so that + # this handler is called after the red has been drawn. If it was + # called before then GTK would just blindly paint over our work. + # + # Note: if the child window has children, then you need a cairo 1.16 + # feature to make this work correctly. + # + + # get our child (in this case, the event box) + child = widget.child + + # create a cairo context to draw to the window + cr = widget.window.create_cairo_context + + # the source data is the (composited) event box + # NOTICE: next line generates a GTK warning, it is maybe a GTK problem, it is tracked + # at http://bugzilla.gnome.org/show_bug.cgi?id=526965 + cr.set_source_pixmap(child.window, child.allocation.x, child.allocation.y) + + # draw no more than our expose event intersects our child + region = Gdk::Region.new(Gdk::Rectangle.new(child.allocation.x, child.allocation.y, child.allocation.width, child.allocation.height)) + region.intersect(event.region) + cr.gdk_region(region) + cr.clip + + # composite, with a 50% opacity + cr.operator = Cairo::OPERATOR_OVER + cr.paint(0.5) + + false +end + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/cursor.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/cursor.rb new file mode 100644 index 0000000..124eb4f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/cursor.rb @@ -0,0 +1,32 @@ +=begin + cursor.rb - Gdk::Cursor sample script. + + Copyright (C) 2001-2006 Masao Mutoh + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: cursor.rb,v 1.7 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("Gdk::Cursor sample") +window.realize + +button = Gtk::Button.new("Click!") +button.use_underline = false + +cursors = Gdk::Cursor::Type.values - [Gdk::Cursor::CURSOR_IS_PIXMAP] + +cnt = 0 +button.signal_connect('clicked') do + cursor = cursors[cnt] +p cursor.inspect + button.set_label(cursor.inspect) + window.window.set_cursor(Gdk::Cursor.new(cursor)) + cnt += 1 + cnt = 0 if cnt == cursors.size +end +window.add(button) +window.set_default_size(400,100).show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/dialog.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/dialog.rb new file mode 100644 index 0000000..f3e132d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/dialog.rb @@ -0,0 +1,44 @@ +#!/usr/bin/env ruby +=begin + dialog.rb - Ruby/GTK2 sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: dialog.rb,v 1.6 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("Gtk::Dialog sample") +button = Gtk::Button.new("Create Dialog") +button.signal_connect("clicked") do + dialog = Gtk::Dialog.new + dialog.title = "Gtk::Dialog Sample" + dialog.transient_for = window + dialog.set_default_size(300, 300) + dialog.vbox.add(Gtk::Label.new("Gtk::Dialog Sample")) + + + dialog.add_button("OK", Gtk::Dialog::RESPONSE_OK) + dialog.add_button(Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL) + dialog.add_button(Gtk::Stock::CLOSE, Gtk::Dialog::RESPONSE_CLOSE) + dialog.set_default_response(Gtk::Dialog::RESPONSE_CANCEL) + + dialog.signal_connect("response") do |widget, response| + case response + when Gtk::Dialog::RESPONSE_OK + p "OK" + when Gtk::Dialog::RESPONSE_CANCEL + p "Cancel" + when Gtk::Dialog::RESPONSE_CLOSE + p "Close" + dialog.destroy + end + end + dialog.show_all +end + +window.add(button).show_all.signal_connect("destroy"){Gtk.main_quit} + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/dialog2.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/dialog2.rb new file mode 100644 index 0000000..c278f08 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/dialog2.rb @@ -0,0 +1,39 @@ +#!/usr/bin/env ruby +=begin + dialog2.rb - Ruby/GTK2 sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: dialog2.rb,v 1.7 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("Gtk::Dialog sample2") +button = Gtk::Button.new("Create Dialog") +button.signal_connect("clicked") do + dialog = Gtk::Dialog.new("Gtk::Dialog Sample 2", window, + Gtk::Dialog::MODAL|Gtk::Dialog::NO_SEPARATOR, + [Gtk::Stock::OK, Gtk::Dialog::RESPONSE_OK], + [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL]) + dialog.vbox.add(Gtk::Label.new("Gtk::Dialog Sample 2")) + dialog.set_default_size(300, 300) + dialog.vbox.show_all + result = dialog.run + case result + when Gtk::Dialog::RESPONSE_OK + p "OK" + when Gtk::Dialog::RESPONSE_CANCEL + p "Cancel" + end + dialog.destroy +end + +window.add(button).show_all.signal_connect("destroy"){Gtk.main_quit} + +Gtk.main + + + + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/dnd.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/dnd.rb new file mode 100644 index 0000000..e61ca36 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/dnd.rb @@ -0,0 +1,65 @@ +=begin + dnd.rb - Drag and Drop sample script. + + Copyright (C) 2002-2006 Masao Mutoh + This program is licenced under the same licence as Ruby-GNOME2. + + $Date: 2006/06/17 13:18:12 $ + $Id: dnd.rb,v 1.9 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +class SrcWindow < Gtk::Window + def initialize + super("Source Window") + @label = Gtk::Label.new("Drag here!") + add(@label) + set_default_size(100, 100) + Gtk::Drag.source_set(self, Gdk::Window::BUTTON1_MASK | + Gdk::Window::BUTTON2_MASK, + [["test", Gtk::Drag::TARGET_SAME_APP, 12345]], + Gdk::DragContext::ACTION_COPY | + Gdk::DragContext::ACTION_MOVE) + signal_connect("drag_data_get") do |widget, context, selection_data, info, time| +# selection_data.set("text/uri-list", 8, "hoge.txt") + selection_data.set(Gdk::Selection::TYPE_STRING, "hoge.txt") + end + end +end + + +class DestWindow < Gtk::Window + def initialize + super("Dest Window") + + @label = Gtk::Label.new("Drop here!") + add(@label) + set_default_size(100, 100) + Gtk::Drag.dest_set(self, Gtk::Drag::DEST_DEFAULT_MOTION | + Gtk::Drag::DEST_DEFAULT_HIGHLIGHT, + [["test", Gtk::Drag::TARGET_SAME_APP, 12345]], + Gdk::DragContext::ACTION_COPY|Gdk::DragContext::ACTION_MOVE) + + signal_connect("drag-data-received") do |w, dc, x, y, selectiondata, info, time| + dc.targets.each do |target| + if target.name == "test" || + selectiondata.type == Gdk::Selection::TYPE_STRING + puts selectiondata.data + end + end + end + signal_connect("drag-drop") do |w, dc, x, y, time| + Gtk::Drag.get_data(w, dc, dc.targets[0], time) + end + end +end + +win1 = SrcWindow.new +win2 = DestWindow.new + +win1.show_all.signal_connect("destroy"){Gtk.main_quit} +win2.show_all.signal_connect("destroy"){Gtk.main_quit} + +Gtk.main + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/dndtreeview.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/dndtreeview.rb new file mode 100644 index 0000000..b47d061 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/dndtreeview.rb @@ -0,0 +1,56 @@ +=begin + dndtreeview.rb - Drag and Drop sample script. + + Copyright (C) 2003-2006 Masao Mutoh + This program is licenced under the same licence as Ruby-GNOME2. + + $Date: 2006/06/17 13:18:12 $ + $Id: dndtreeview.rb,v 1.3 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +class TestWindow < Gtk::Window + attr_reader :list + + TARGET_TABLE = [["GTK_TREE_MODEL_ROW", 0, 0]] + + def initialize() + super("Drag and Drop Gtk::TreeView") + + set_default_size(300,128) + signal_connect("destroy") { Gtk.main_quit } + + data = [["Hello", "KON-NI-CHIWA"], + ["Goodbye", "SAYO-NARA"], + ["Good morning", "OHA-YO-GOZAI-MASU"], + ["Good evening", "KON-BAN-WA"]] + + model = Gtk::ListStore.new(String, String) + view = Gtk::TreeView.new(model) + renderer = Gtk::CellRendererText.new + col1 = Gtk::TreeViewColumn.new("Data", renderer, {:text => 0}) + col2 = Gtk::TreeViewColumn.new("Data", renderer, {:text => 1}) + view.append_column(col1) + view.append_column(col2) + + data.each do |v1, v2| + iter = model.append + iter.set_value(0, v1) + iter.set_value(1, v2) + end + + view.enable_model_drag_source(Gdk::Window::BUTTON1_MASK, + TARGET_TABLE, + Gdk::DragContext::ACTION_COPY|Gdk::DragContext::ACTION_MOVE) + view.enable_model_drag_dest(TARGET_TABLE, + Gdk::DragContext::ACTION_COPY|Gdk::DragContext::ACTION_MOVE) + + add(view) + end +end + +win = TestWindow.new.show_all + +Gtk.main + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/drag-move.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/drag-move.rb new file mode 100644 index 0000000..471da7d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/drag-move.rb @@ -0,0 +1,131 @@ +=begin + drag-move.rb - Move widget by drag sample script. + + Copyright (C) 2006 Kouhei Sutou + This program is licenced under the same licence as Ruby-GNOME2. + + $Date: 2006/06/17 13:18:12 $ + $Id: drag-move.rb,v 1.2 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +class DraggableWidget < Gtk::EventBox + def initialize + super + set_visible_window(false) + @dragging = false + @drag_button = 1 + set_button_press_event + set_button_release_event + set_motion_notify_event + end + + def layout + parent + end + + def move(x, y) + if layout + layout.move(self, x, y) + true + else + false + end + end + + def dragging? + @dragging + end + + private + def set_button_press_event + signal_connect("button_press_event") do |widget, event| + if event.button == @drag_button + Gtk.grab_add(widget) + x, y, w, h = widget.allocation.to_a + drag_start(x, y, event.x_root, event.y_root) + else + false + end + end + end + + def set_motion_notify_event + signal_connect("motion_notify_event") do |widget, event| + if dragging? + drag_motion(event.x_root, event.y_root) + else + false + end + end + end + + def set_button_release_event + signal_connect("button_release_event") do |widget, event| + if event.button == @drag_button + Gtk.grab_remove(widget) + drag_end + else + false + end + end + end + + def set_drag_move_position_event + signal_connect("drag_move_position") do |widget, x, y| + if layout + layout.move(widget, x, y) + true + else + false + end + end + end + + def drag_start(x, y, base_x, base_y) + @dragging = true + @drag_x = x + @drag_y = y + @drag_base_x = base_x + @drag_base_y = base_y + true + end + + def drag_motion(base_x, base_y) + delta_x = base_x - @drag_base_x + delta_y = base_y - @drag_base_y + if delta_x != 0 and delta_y != 0 + move(@drag_x + delta_x, @drag_y + delta_y) + else + false + end + end + + def drag_end + @dragging = false + true + end +end + +window = Gtk::Window.new("Draggable Widget sample") +window.signal_connect("destroy"){Gtk.main_quit} + +layout = Gtk::Layout.new + +draggable_widget = DraggableWidget.new +draggable_widget.set_size_request(50, 50) +layout.put(draggable_widget, 75, 75) + +draggable_widget.signal_connect("expose_event") do |widget, event| + x, y, w, h = widget.allocation.to_a + fg = Gdk::GC.new(widget.window) + widget.window.draw_arc(fg, true, x, y, w, h, 0 * 64, 360 * 64) + false +end + +window.add(layout) + +window.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/drawing.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/drawing.rb new file mode 100644 index 0000000..9deb996 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/drawing.rb @@ -0,0 +1,90 @@ +=begin + drawing.rb - Gtk::Drawing sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: drawing.rb,v 1.7 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +class Canvas < Gtk::DrawingArea + def initialize + super + signal_connect("expose_event") { |w,e| expose_event(w,e) } + signal_connect("configure_event") { |w, e| configure_event(w,e) } + @buffer = nil + @bgc = nil + end + + def expose_event(w,e) + unless @buffer.nil? + rec = e.area + w.window.draw_drawable(@bgc, @buffer, rec.x, rec.y, + rec.x, rec.y, rec.width, rec.height) + end + false + end + + def clear(b = @buffer) + return if b.nil? + + g = b.size + @bgc = self.style.bg_gc(self.state) if @bgc.nil? + if (g[0] > 0 && g[1] > 0) + b.draw_rectangle(@bgc, true, 0,0, g[0], g[1]) + end + end + + def configure_event(w,e) + g = w.window.geometry + if (g[2] > 0 && g[3] > 0) + b = Gdk::Pixmap::new(w.window, g[2], g[3], -1) + clear(b) + if not @buffer.nil? + g = @buffer.size + b.draw_drawable(@bgc, @buffer, 0, 0, 0, 0, g[0], g[1]) + end + @buffer = b + end + true + end +end + +class A < Canvas + def initialize + super + signal_connect("button_press_event") { |w,e| pressed(w,e) } + set_events(Gdk::Event::BUTTON_PRESS_MASK) + end + + def pressed(widget, ev) + if not @last.nil? + @buffer.draw_line(widget.style.fg_gc(widget.state), + @last.x, @last.y, ev.x, ev.y) + + x1,x2 = if (@last.x < ev.x) + then [@last.x, ev.x] + else [ev.x, @last.x] + end + y1,y2 = if (@last.y < ev.y) + then [@last.y, ev.y] + else [ev.y, @last.y] + end + widget.queue_draw_area(x1, y1, x2 - x1 + 1, y2 - y1 + 1) + end + @last = nil + @last = ev + true + end +end + +window = Gtk::Window.new("drawing test") +window.signal_connect("destroy") { Gtk.main_quit } + +canvas = A.new +window.add(canvas) + +window.show_all +Gtk::main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/entry.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/entry.rb new file mode 100644 index 0000000..e508e1d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/entry.rb @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby +=begin + entry.rb - Ruby/GTK2 sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: entry.rb,v 1.9 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("entry") +window.border_width = 0 + +box1 = Gtk::VBox.new(false, 10) +window.add(box1) + +entry = Gtk::Entry.new + +box1.add(entry) +box1.add(Gtk::HSeparator.new) + +button = Gtk::Button.new("close") +button.signal_connect("clicked") do + Gtk.main_quit +end +box1.add(button) + +window.show_all + +entry.text = "hello world" + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/entrycompletion.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/entrycompletion.rb new file mode 100644 index 0000000..d19e7dd --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/entrycompletion.rb @@ -0,0 +1,39 @@ +#!/usr/bin/env ruby +=begin + entrycompletion.rb - Ruby/GTK sample script. + + Copyright (c) 2004-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + Enter "G", "t" on the entry box. + + $Id: entrycompletion.rb,v 1.4 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +if str = Gtk.check_version(2, 4, 0) + puts "This sample requires GTK+ 2.4.0 or later" + puts str + exit +end + +window = Gtk::Window.new +window.set_default_size(200, 200) + +entry = Gtk::Entry.new +completion = Gtk::EntryCompletion.new +entry.completion = completion + +model = Gtk::ListStore.new(String) +["GNOME", "total", "totally"].each do |v| + iter = model.append + iter[0] = v +end + +completion.model = model +completion.text_column = 0 + +window.add(entry).show_all.signal_connect("destroy"){Gtk.main_quit} + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/expander.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/expander.rb new file mode 100644 index 0000000..59df54e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/expander.rb @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +=begin + expander.rb - Ruby/GTK2 sample script. + + Copyright (c) 2004-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: expander.rb,v 1.3 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +expander = Gtk::Expander.new("Expander Sample") +expander.expanded = true + +button = Gtk::Button.new("Hide this button.") +button.signal_connect("clicked") do + expander.expanded = false +end + +button.set_size_request(200, 200) +expander.add(button) + +Gtk::Window.new.add(expander).show_all.signal_connect("destroy"){Gtk.main_quit} + +Gtk.main + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/filechooser.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/filechooser.rb new file mode 100644 index 0000000..e29c754 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/filechooser.rb @@ -0,0 +1,49 @@ +#!/usr/bin/env ruby +=begin + filechooser.rb - Ruby/GTK2 sample script. + + Copyright (c) 2004-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: filechooser.rb,v 1.5 2006/06/17 13:18:12 mutoh Exp $ +=end + +require "gtk2" + +if str = Gtk.check_version(2, 4, 0) + puts "This sample requires GTK+ 2.4.0 or later" + puts str + exit +end + +dialog = Gtk::FileChooserDialog.new("Gtk::FileChooser sample", nil, + Gtk::FileChooser::ACTION_OPEN, + "gnome-vfs", + [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT], + [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL] + ) + +extra_button = Gtk::Button.new("Extra button") +extra_button.signal_connect("clicked") do + puts "extra button is clicked" +end + +dialog.extra_widget = extra_button + +filter_rb = Gtk::FileFilter.new +filter_rb.name = "Ruby Scripts" +filter_rb.add_pattern("*.rb") +filter_rb.add_pattern("*.rbw") +dialog.add_filter(filter_rb) + +filter_c = Gtk::FileFilter.new +filter_c.name = "C sources" +filter_c.add_pattern("*.[c|h]") +dialog.add_filter(filter_c) + +dialog.add_shortcut_folder("/tmp") + +if dialog.run == Gtk::Dialog::RESPONSE_ACCEPT + puts "filename = #{dialog.filename}" + puts "uri = #{dialog.uri}" +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/fileselection.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/fileselection.rb new file mode 100644 index 0000000..86ac0c4 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/fileselection.rb @@ -0,0 +1,26 @@ +#!/usr/bin/env ruby +=begin + fileselection.rb - Ruby/GTK2 sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: fileselection.rb,v 1.10 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +puts "Deprecated. Use Gtk::FileChooserDialog instead." + +window = Gtk::FileSelection.new("file selection dialog") +window.window_position = Gtk::Window::POS_MOUSE +window.border_width = 0 + +ret = window.run +if ret == Gtk::Dialog::RESPONSE_OK + puts "OK" + puts window.filename +elsif ret == Gtk::Dialog::RESPONSE_CANCEL + puts "CANCEL" + puts window.filename +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/frame.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/frame.rb new file mode 100644 index 0000000..6051aa9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/frame.rb @@ -0,0 +1,69 @@ +#!/usr/bin/env ruby +=begin + frame.rb - Ruby/GTK2 sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: frame.rb,v 1.9 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("buttons") +window.signal_connect("destroy") do + Gtk.main_quit +end +window.border_width = 0 + +box1 = Gtk::VBox.new(false, 0) +window.add(box1) + +box2 = Gtk::HBox.new(false, 5) +box2.border_width = 10 +box1.pack_start(box2, true, true, 0) + +label = Gtk::Label.new("Hello World") +frame = Gtk::Frame.new("Frame 1") +box2.pack_start(frame, true, true, 0) + +box3 = Gtk::VBox.new(false, 5) +box3.border_width = 5 +frame.add(box3) + +button = Gtk::Button.new("switch") +button.signal_connect("clicked") do + label.reparent(box3) +end +box3.pack_start(button, false, true, 0) +box3.pack_start(label, false, true, 0) + +frame = Gtk::Frame.new("Frame 2") +box2.pack_start(frame, true, true, 0) + +box4 = Gtk::VBox.new(false, 5) +box4.border_width = 5 +frame.add(box4) + +button = Gtk::Button.new("switch") +button.signal_connect("clicked") do + label.reparent(box4) +end +box4.pack_start(button, false, true, 0) + +separator = Gtk::HSeparator.new +box1.pack_start(separator, false, true, 0) + +box2 = Gtk::HBox.new(false, 10) +box2.border_width = 10 +box1.pack_start(box2, false, true, 0) + +button = Gtk::Button.new("close") +button.signal_connect("clicked") do + Gtk.main_quit +end +box2.pack_start(button) + +window.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/gc.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/gc.rb new file mode 100644 index 0000000..4f76fa6 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/gc.rb @@ -0,0 +1,59 @@ +#!/usr/bin/env ruby +=begin + gc.rb - Ruby/GTK sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: gc.rb,v 1.6 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("Gdk::GC sample") +window.set_default_size(300, 300) +window.app_paintable = true +window.realize + +drawable = window.window +gc = Gdk::GC.new(drawable) + +red = Gdk::Color.new(65535, 0, 0) +green = Gdk::Color.new(0, 65535, 0) +colormap = Gdk::Colormap.system +colormap.alloc_color(red, false, true) +colormap.alloc_color(green, false, true) + +window.signal_connect("expose-event") do |win, evt| + gc.set_foreground(red) + gc.set_background(green) + + gc.set_line_attributes(5, Gdk::GC::LINE_SOLID, Gdk::GC::CAP_NOT_LAST, Gdk::GC::JOIN_MITER) + drawable.draw_line(gc, 20, 10, 150, 10) + gc.set_line_attributes(5, Gdk::GC::LINE_ON_OFF_DASH, Gdk::GC::CAP_NOT_LAST, Gdk::GC::JOIN_MITER) + drawable.draw_line(gc, 20, 30, 150, 30) + gc.set_line_attributes(5, Gdk::GC::LINE_DOUBLE_DASH, Gdk::GC::CAP_NOT_LAST, Gdk::GC::JOIN_MITER) + drawable.draw_line(gc, 20, 50, 150, 50) + + gc.set_line_attributes(30, Gdk::GC::LINE_SOLID, Gdk::GC::CAP_NOT_LAST, Gdk::GC::JOIN_MITER) + drawable.draw_line(gc, 20, 100, 120, 100) + gc.set_line_attributes(30, Gdk::GC::LINE_SOLID, Gdk::GC::CAP_BUTT, Gdk::GC::JOIN_MITER) + drawable.draw_line(gc, 20, 140, 120, 140) + gc.set_line_attributes(30, Gdk::GC::LINE_SOLID, Gdk::GC::CAP_ROUND, Gdk::GC::JOIN_MITER) + drawable.draw_line(gc, 20, 180, 120, 180) + gc.set_line_attributes(30, Gdk::GC::LINE_SOLID, Gdk::GC::CAP_PROJECTING, Gdk::GC::JOIN_MITER) + drawable.draw_line(gc, 20, 220, 120, 220) + + gc.set_line_attributes(40, Gdk::GC::LINE_SOLID, Gdk::GC::CAP_NOT_LAST, Gdk::GC::JOIN_MITER) + drawable.draw_lines(gc, [[200, 80], [220, 30], [280, 50]]) + gc.set_line_attributes(40, Gdk::GC::LINE_SOLID, Gdk::GC::CAP_NOT_LAST, Gdk::GC::JOIN_ROUND) + drawable.draw_lines(gc, [[200, 170], [220, 120], [280, 140]]) + gc.set_line_attributes(40, Gdk::GC::LINE_SOLID, Gdk::GC::CAP_NOT_LAST, Gdk::GC::JOIN_BEVEL) + drawable.draw_lines(gc, [[200, 260], [220, 210], [280, 230]]) +end + +window.show_all.signal_connect("destroy"){Gtk.main_quit} + +Gtk.main + + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/gdkscreen.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/gdkscreen.rb new file mode 100644 index 0000000..617332a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/gdkscreen.rb @@ -0,0 +1,32 @@ +=begin + gdkscreen.rb - Gdk::Screen sample script. + + Copyright (C) 2004-2006 Masao Mutoh + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: gdkscreen.rb,v 1.3 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +screen = Gdk::Screen.default +settings_map = [ + "gtk-double-click-time", + "gtk-dnd-drag-threshold", + "gtk-can-change-accels", + "gtk-color-palette", + "gtk-font-name", + "gtk-icon-sizes", + "gtk-key-theme-name", + "gtk-toolbar-style", + "gtk-toolbar-icon-size", + "gtk-im-preedit-style", + "gtk-im-status-style", + "gtk-cursor-blink", + "gtk-cursor-blink-time", + "gtk-theme-name" +] + +settings_map.each do |v| + puts "#{v}: #{screen.get_setting(v)}" +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/gnome-logo-icon.png b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/gnome-logo-icon.png new file mode 100644 index 0000000..06721a9 Binary files /dev/null and b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/gnome-logo-icon.png differ diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/helloworld.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/helloworld.rb new file mode 100644 index 0000000..f62b0f1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/helloworld.rb @@ -0,0 +1,35 @@ +#!/usr/bin/env ruby +=begin + helloworld.rb - Ruby/GTK2 first sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: helloworld.rb,v 1.7 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +button = Gtk::Button.new("Hello World") +button.signal_connect("clicked") { + puts "Hello World" +} + +window = Gtk::Window.new("Hello World sample") +window.signal_connect("delete_event") { + puts "delete event occurred" + #true + false +} + +window.signal_connect("destroy") { + puts "destroy event occurred" + Gtk.main_quit +} + +window.border_width = 10 +window.add(button) +window.show_all + +Gtk.main + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/iconview.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/iconview.rb new file mode 100644 index 0000000..5c06c4e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/iconview.rb @@ -0,0 +1,38 @@ +#!/usr/bin/env ruby +=begin + iconview.rb - Ruby/GTK2 sample script. + + Copyright (c) 2005,2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: iconview.rb,v 1.2 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +TEXT_COLUMN = 0 +PIXBUF_COLUMN = 1 + +model = Gtk::ListStore.new(String, Gdk::Pixbuf) + +iv = Gtk::IconView.new(model) + +iv.text_column = TEXT_COLUMN +iv.pixbuf_column = PIXBUF_COLUMN + +Dir.glob("../gtk-demo/gnome*.png").each do |f| + iter = model.append + iter[TEXT_COLUMN] = File.basename(f) + iter[PIXBUF_COLUMN] = Gdk::Pixbuf.new(f) +end + +iv.signal_connect("item_activated") do |iv, path| + iter = model.get_iter(path) + p iter [0] +end + +win = Gtk::Window.new("Gtk::IconView sample") +win.signal_connect("destroy"){Gtk.main_quit} +win.add(iv).set_default_size(300,300).show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/image.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/image.rb new file mode 100644 index 0000000..0d0c1f0 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/image.rb @@ -0,0 +1,42 @@ +#!/usr/bin/env ruby +=begin + image.rb - Ruby/GTK sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: image.rb,v 1.9 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("Image") +window.signal_connect("destroy") do + Gtk.main_quit +end +window.border_width = 0 + +box1 = Gtk::VBox.new(false, 10) +box1.border_width = 10 + +button = Gtk::Button.new +box1.add(button) + +label = Gtk::Label.new("Gtk::Image\ntest") +image = Gtk::Image.new("test.xpm") + +box2 = Gtk::HBox.new(false, 5).add(image).add(label) + +button.add(box2) + +box1.add(Gtk::HSeparator.new) + +button = Gtk::Button.new("close") +button.signal_connect("clicked") do + Gtk.main_quit +end +box1.add(button) + +window.add(box1).show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/infobar.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/infobar.rb new file mode 100755 index 0000000..c272e2b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/infobar.rb @@ -0,0 +1,24 @@ +#!/usr/bin/env ruby + +require 'gtk2' + +label=Gtk::Label.new.show + +info=Gtk::InfoBar.new +info.no_show_all=true +info.content_area.add(label) +info.add_button(Gtk::Stock::OK, Gtk::ResponseType::OK) +info.signal_connect('response'){|info, response| info.hide} + +w=Gtk::Window.new +w.add(info) +w.show_all +w.signal_connect("delete_event"){Gtk.main_quit} + +GLib::Timeout.add_seconds(1){ + label.text='ERROR' + info.message_type=Gtk::MessageType::ERROR + info.show + false +} +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/itemfactory.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/itemfactory.rb new file mode 100644 index 0000000..71629b5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/itemfactory.rb @@ -0,0 +1,73 @@ +#!/usr/bin/env ruby +=begin + itemfactory.rb - Ruby/GTK sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + *NOTE* Gtk::ItemFactory has been deprecated. Use Gtk::UIManager instead. + + $Id: itemfactory.rb,v 1.7 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +puts "Deprecated. Use Gtk::UIManager instead." + +window = Gtk::Window.new("Gtk::ItemFactory") +window.signal_connect("destroy") do + Gtk.main_quit +end +window.signal_connect("delete_event") do + Gtk.main_quit +end + +accelgroup = Gtk::AccelGroup.new +window.add_accel_group(accelgroup) + +ifp = Gtk::ItemFactory.new(Gtk::ItemFactory::TYPE_MENU_BAR, "<main>", accelgroup) + +cal_stock = Proc.new {|d, item| p "StockItem, #{d}"} +cal_quit = Proc.new{p "Quit"; Gtk.main_quit} +cal_check = Proc.new {|d, item| p "CheckItem, #{d}"} +cal_toggle = Proc.new {|d, item| p "ToggleItem, #{d}"} +cal_radio = Proc.new {|d, item| p "RadioItem, #{d}"} +cal_misc = Proc.new {|d, item| p "Misc #{d}"} +ifp.create_items([ + ["/_Stock"], + ["/_Stock/_New", "<StockItem>", "<control>N", Gtk::Stock::NEW, cal_stock, 1], + ["/_Stock/_Open", "<StockItem>", "<control>O", Gtk::Stock::OPEN, cal_stock, 2], + ["/_Stock/_Quit", "<StockItem>", "<control>Q", Gtk::Stock::QUIT, cal_quit], + + ["/_Check"], + ["/_Check/Check_1", "<CheckItem>", "", "", cal_check, 1], + ["/_Check/Check_2", "<CheckItem>", "", "", cal_check, 2], + + ["/_Toggle"], + ["/_Toggle/Toggle_1", "<ToggleItem>", "", "", cal_toggle, 1], + ["/_Toggle/Toggle_2", "<ToggleItem>", "", "", cal_toggle, 2], + ["/_Toggle/Toggle_3", "<ToggleItem>", "", "", cal_toggle, 3], + + ["/_Radio", "<Branch>"], + ["/_Radio/Radio_1", "<RadioItem>", nil, nil, cal_radio, 1], + ["/_Radio/Radio_2", "/Radio/Radio1", nil, nil, cal_radio, 2], + ["/_Radio/Radio_3", "/Radio/Radio1", nil, nil, cal_radio, 3], + + ["/_Misc", "<LastBranch>"], + ["/_Misc/Tearoff", "<Tearoff>"], + ["/_Misc/Title", "<Title>"], + ["/_Misc/Image", "<ImageItem>", "", Gdk::Pixbuf.new("gnome-logo-icon.png"), cal_misc, 1], + ["/_Misc/Separator", "<Separator>"], + ["/_Misc/Item", "<Item>", nil, nil, cal_misc, 2] + ]) + +ifp.get_widget("/Stock/Open").sensitive = false +ifp.delete_item("/Toggle/Toggle2") + +vbox = Gtk::VBox.new +vbox.add(ifp.get_widget("<main>")) +vbox.add(Gtk::Label.new("Gtk::ItemFactory sample").set_size_request(400, 200)) +window.add(vbox) +window.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/itemfactory2.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/itemfactory2.rb new file mode 100644 index 0000000..64dd337 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/itemfactory2.rb @@ -0,0 +1,74 @@ +#!/usr/bin/env ruby +=begin + itemfactory2.rb - Ruby/GTK sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + *NOTE* Gtk::ItemFactory has been deprecated. Use Gtk::UIManager instead. + + $Id: itemfactory2.rb,v 1.8 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +puts "Deprecated. Use Gtk::UIManager instead." + +window = Gtk::Window.new("Gtk::ItemFactory2") +window.signal_connect("destroy") do + Gtk.main_quit +end +window.signal_connect("delete_event") do + Gtk.main_quit +end + +accelgroup = Gtk::AccelGroup.new +window.add_accel_group(accelgroup) + +ifp = Gtk::ItemFactory.new(Gtk::ItemFactory::TYPE_MENU_BAR, "<main>", accelgroup) + +ifp.create_item("/_Stock") +ifp.create_item("/_Stock/_New", "<StockItem>", "<control>N", Gtk::Stock::NEW, 1) do |v, _| + p "StockItem #{v}" +end +item = ifp.create_item("/_Stock/_Open", "<StockItem>", "<control>O", Gtk::Stock::OPEN, 2) do |v, _| + p "StockItem #{v}" +end +ifp.create_item("/_Stock/_Quit", "<StockItem>", "<control>Q", Gtk::Stock::QUIT, 3) do |v, _| + p "Quit" + Gtk.main_quit +end + +ifp.create_item("/_Item") +ifp.create_item("/_Item/Item_1", "<Item>"){p "Item1"} +ifp.create_item("/_Item/Item_2", "<Item>"){p "Item2"} + +ifp.create_item("/_Check") +ifp.create_item("/_Check/Check_1", "<CheckItem>"){p "Check1"} +ifp.create_item("/_Check/Check_2", "<CheckItem>"){p "Check2"} + +ifp.create_item("/_Toggle") +ifp.create_item("/_Toggle/Toggle_1", "<ToggleItem>", nil, nil, 1){|v, _| p "Toggle#{v}"} +ifp.create_item("/_Toggle/Toggle_2", "<ToggleItem>", nil, nil, 2){|v, _| p "Toggle#{v}"} + +ifp.create_item("/_Radio") +ifp.create_item("/_Radio/Radio_1", "<RadioItem>", nil, nil, 1){|v, _| p "Radio#{v}"} +ifp.create_item("/_Radio/Radio_2", "/Radio/Radio1", nil, nil, 2){|v, _| p "Radio#{v}"} +ifp.create_item("/_Radio/Radio_3", "/Radio/Radio1", nil, nil, 3){|v, _| p "Radio#{v}"} + +ifp.create_item("/_Misc", "<LastBranch>") +ifp.create_item("/_Misc/Tearoff", "<Tearoff>") +ifp.create_item("/_Misc/Title", "<Title>") +ifp.create_item("/_Misc/Seperator", "<Separator>") +ifp.create_item("/_Misc/Image", "<ImageItem>", "", Gdk::Pixbuf.new("gnome-logo-icon.png")) do + p "ImageItem" +end + +ifp.get_widget("/Stock/Open").sensitive = false +vbox = Gtk::VBox.new +vbox.add(ifp.get_widget("<main>")) +vbox.add(Gtk::Label.new("Gtk::ItemFactory sample").set_size_request(400, 200)) +window.add(vbox) +window.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/keyboard_grab.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/keyboard_grab.rb new file mode 100644 index 0000000..19441bc --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/keyboard_grab.rb @@ -0,0 +1,29 @@ +=begin + keyboard_grab.rb - Gdk::Window#keyboard_grab/ungrab sample script. + + Copyright (C) 2001-2006 Masao Mutoh + This program is licenced under the same licence as Ruby-GNOME. + + $Date: 2006/06/17 13:18:12 $ + $Id: keyboard_grab.rb,v 1.5 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("Keyboard Grab/Ungrab sample") + +button1 = Gtk::Button.new("Grab Keyboard!") +button2 = Gtk::Button.new("Ungrab Keyboard!") + +button1.signal_connect('clicked') do + Gdk.keyboard_grab(window.window, true, Gdk::Event::CURRENT_TIME) +end + +button2.signal_connect('clicked') do + Gdk.keyboard_ungrab(Gdk::Event::CURRENT_TIME) +end + +window.add(Gtk::VBox.new.add(button1).add(button2)) +window.set_default_size(200,100).show_all.signal_connect("destroy"){Gtk.main_quit} + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/label.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/label.rb new file mode 100644 index 0000000..8332a28 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/label.rb @@ -0,0 +1,33 @@ +#!/usr/bin/env ruby +=begin + label.rb - Ruby/GTK2 sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: label.rb,v 1.8 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +win = Gtk::Window.new("Gtk::Label sample") +win.signal_connect("destroy"){Gtk.main_quit} +label1 = Gtk::Label.new("_Not Use Mnemonic") +label1.selectable = true +label2 = Gtk::Label.new("_Use Mnemonic", true) +label3 = Gtk::Label.new.set_markup(%Q[<markup><span size="xx-large" weight="bold" foreground="blue"><u>Ruby-GNOME2</u></span> is <span foreground="red" size="x-large"><i>cool</i></span>!</markup>], true) +label4 = Gtk::Label.new.set_markup(%Q[<span foreground="#999900">_Not Use Mnemonic</span>]) +label5 = Gtk::Label.new.set_markup(%Q[<span foreground="#009999">_Use Mnemonic</span>], true) + +box = Gtk::VBox.new +box.add(label1) +box.add(label2) +box.add(label3) +box.add(label4) +box.add(label5) +win.add(box).show_all + +# This can be called after realized only. +label1.select_region(3, 8) + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/linkbutton.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/linkbutton.rb new file mode 100644 index 0000000..c3632e3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/linkbutton.rb @@ -0,0 +1,42 @@ +#!/usr/bin/env ruby +=begin + linkbutton.rb - Gtk::LinkButton sample. + + Copyright (c) 2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: linkbutton.rb,v 1.1 2006/10/21 16:58:00 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("Gtk::LinkButton sample") +window.signal_connect("destroy"){Gtk.main_quit} + +vbox = Gtk::VBox.new + +# URI only +button1 = Gtk::LinkButton.new("http://ruby-gnome2.sourceforge.jp/") +button1.signal_connect("clicked") do + puts button1.uri +end +vbox.pack_start(button1) + +# URI with a label +button2 = Gtk::LinkButton.new("http://ruby-gnome2.sourceforge.jp/", + "Ruby-GNOME2 Website") +button2.signal_connect("clicked") do + puts button2.uri +end + +# Global setting instead of using clicked signals. +Gtk::LinkButton.set_uri_hook {|button, link| + puts "set_uri_hook: " + link +} + +vbox.pack_start(button2) + +window.add(vbox) +window.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/listview.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/listview.rb new file mode 100644 index 0000000..2bdb58e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/listview.rb @@ -0,0 +1,92 @@ +#!/usr/bin/env ruby +=begin + listview.rb - Ruby/GTK sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: listview.rb,v 1.11 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("Gtk::ListStore sample") +window.border_width = 0 + +box1 = Gtk::VBox.new(false, 0) +window.add(box1) + +box2 = Gtk::VBox.new(false, 10) +box2.border_width = 10 +box1.pack_start(box2, true, true, 0) + +scrolled_win = Gtk::ScrolledWindow.new +scrolled_win.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC) +box2.pack_start(scrolled_win, true, true, 0) + +data = [ + "hello", + "world", + "blah", + "foo", + "bar", + "argh", + "spencer", + "is a", + "wussy", + "programmer" + ] + +model = Gtk::ListStore.new(String) +column = Gtk::TreeViewColumn.new("Data", + Gtk::CellRendererText.new, {:text => 0}) +treeview = Gtk::TreeView.new(model) +treeview.append_column(column) +treeview.selection.set_mode(Gtk::SELECTION_SINGLE) +scrolled_win.add_with_viewport(treeview) + +data.each do |v| + iter = model.append + iter[0] = v +end + +button = Gtk::Button.new("add") +button.set_flags(Gtk::Widget::CAN_FOCUS) + +i = 0 +button.signal_connect("clicked") do + iter = model.append + iter[0] = "add item #{i}" + i += 1 +end + +box2.pack_start(button, false, true, 0) + +button = Gtk::Button.new("remove") +button.set_flags(Gtk::Widget::CAN_FOCUS) +button.signal_connect("clicked") do + iter = treeview.selection.selected + model.remove(iter) if iter +end +box2.pack_start(button, false, true, 0) + +separator = Gtk::HSeparator.new +box1.pack_start(separator, false, true, 0) +separator.show + +box2 = Gtk::VBox.new(false, 10) +box2.border_width = 10 +box1.pack_start(box2, false, true, 0) + +button = Gtk::Button.new("close") +button.signal_connect("clicked") do + Gtk.main_quit +end +box2.pack_start(button, true, true, 0) +button.set_flags(Gtk::Widget::CAN_DEFAULT) +button.grab_default + +window.set_default_size(300, 300) +window.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/menu.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/menu.rb new file mode 100644 index 0000000..311e5ab --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/menu.rb @@ -0,0 +1,81 @@ +#!/usr/bin/env ruby +=begin + menu.rb - Ruby/GTK2 sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: menu.rb,v 1.8 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +def create_menu(depth) + return nil if depth < 1 + + menu = Gtk::Menu.new + group = nil + submenu = nil + + for i in 0..4 + buf = sprintf("item %2d - %d", depth, i + 1) + menuitem = Gtk::RadioMenuItem.new(group, buf) + group = menuitem.group + menu.append(menuitem) + if depth > 1 + menuitem.set_submenu create_menu(depth - 1) + end + end + menu +end + +window = Gtk::Window.new("menus") +window.signal_connect("destroy") do + Gtk.main_quit +end +window.border_width = 0 + +box1 = Gtk::VBox.new(false, 0) +window.add(box1) + +menubar = Gtk::MenuBar.new +box1.pack_start(menubar, false, true, 0) + +menu = create_menu(2) +menuitem = Gtk::MenuItem.new("test\nline2") +menuitem.set_submenu(menu) +menubar.append(menuitem) + +menuitem = Gtk::MenuItem.new("foo") +menuitem.set_submenu(create_menu(3)) +menubar.append(menuitem) + +menuitem = Gtk::MenuItem.new("bar") +menuitem.set_submenu(create_menu(4)) +menubar.append(menuitem) + +box2 = Gtk::VBox.new(false, 10) +box2.border_width = 10 +box1.pack_start(box2, true, true, 0) + +optionmenu = Gtk::OptionMenu.new +optionmenu.set_menu(create_menu(1)) +optionmenu.set_history(4) +box2.pack_start(optionmenu, true, true, 0) + +separator = Gtk::HSeparator.new +box1.pack_start(separator, false, true, 0) + +box2 = Gtk::HBox.new(false, 10) +box2.border_width = 10 +box1.pack_start(box2, false, true, 0) + +button = Gtk::Button.new("close") +button.signal_connect("clicked") do + window.destroy +end +box2.pack_start(button, true, true, 0) + +window.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/misc_button.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/misc_button.rb new file mode 100644 index 0000000..48a3963 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/misc_button.rb @@ -0,0 +1,59 @@ +#!/usr/bin/env ruby +=begin + misc_button.rb - Ruby/GTK sample script. + + Copyright (c) 2004-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: misc_button.rb,v 1.2 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +if str = Gtk.check_version(2, 4, 0) + puts "This sample requires GTK+ 2.4.0 or later" + puts str + exit +end + +box = Gtk::VBox.new + +#Gtk::ColorButton +colorbutton = Gtk::ColorButton.new +colorbutton.signal_connect("color-set") do + p colorbutton.color.to_a +end +box.add(colorbutton) + + +#Gtk::FontButton +fontbutton = Gtk::FontButton.new +fontbutton.signal_connect("font-set") do + p fontbutton.font_name +end +box.add(fontbutton) + +#Gtk::FileChooserButton(GTK+-2.6.0 or later) +if str = Gtk.check_version(2, 6, 0) + puts "Gtk::FileChooserButton requires GTK+ 2.6.0 or later" +else + filebutton = Gtk::FileChooserButton.new("Gtk::FileChooserButton", + Gtk::FileChooser::ACTION_OPEN) + filebutton.filename = GLib.home_dir + filebutton.signal_connect("current-folder-changed") do |w, e| + p filebutton.filename + end + + box.add(filebutton) +end + +#Quit +quitbutton = Gtk::Button.new("Quit") +quitbutton.signal_connect("clicked") do + Gtk.main_quit +end +box.add(quitbutton) + +Gtk::Window.new.add(box).set_default_size(200, 100).show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/mouse-gesture.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/mouse-gesture.rb new file mode 100644 index 0000000..1611242 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/mouse-gesture.rb @@ -0,0 +1,465 @@ +=begin + mouse-gesture.rb - mouse gesture sample script. + + Copyright (C) 2005,2006 Kouhei Sutou + This program is licenced under the same licence as Ruby-GNOME2. + + $Date: 2006/06/17 13:18:12 $ + $Id: mouse-gesture.rb,v 1.2 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +unless Gdk.cairo_available? + STDERR.puts("need cairo and rcairo support for this sample") + exit 1 +end + +class GestureProcessor + DEFAULT_THRESHOLD = 16 + DEFAULT_SKEW_THRESHOLD_ANGLE = 30 + + attr_accessor :threshold, :skew_threshold_angle + attr_reader :motions + + def initialize(threshold=nil, skew_threshold_angle=nil) + @threshold = threshold || DEFAULT_THRESHOLD + @skew_threshold_angle = skew_threshold_angle + @skew_threshold_angle ||= DEFAULT_SKEW_THRESHOLD_ANGLE + reset + end + + def started? + @started + end + + MOTIONS = %w(L R U D UL UR LL LR) + + def available_motion?(motion) + MOTIONS.include?(motion) + end + + def start(x, y) + @prev_x = @x = x + @prev_y = @y = y + @started = true + @motions = [] + end + + def update_position(x, y) + mx = x - @prev_x + my = y - @prev_y + + motion = judge_motion(mx, my) + if motion + @prev_x = @x = x + @prev_y = @y = y + if @motions.last == motion + false + else + @motions << motion + true + end + else + false + end + end + + def reset + @started = false + @x = @y = -1 + @motions = [] + end + + def to_a + @motions + end + + def position + [@x, @y] + end + + private + def judge_motion(mx, my) + mxa = mx.abs + mya = my.abs + distance = Math.sqrt(mxa ** 2 + mya ** 2) + upper_theta = (45 + @skew_threshold_angle) * (Math::PI / 180.0) + lower_theta = (45 - @skew_threshold_angle) * (Math::PI / 180.0) + if distance > @threshold and + mya < Math.tan(upper_theta) * mxa and + mya > Math.tan(lower_theta) * mxa + judge_corner_motion(mx, my) + elsif mxa > @threshold or mya > @threshold + judge_cross_motion(mx, my) + else + nil + end + end + + def judge_corner_motion(mx, my) + if mx < 0 + if my < 0 + "UL" + else + "LL" + end + else + if my < 0 + "UR" + else + "LR" + end + end + end + + def judge_cross_motion(mx, my) + if mx.abs > my.abs + if mx < 0 + "L" + else + "R" + end + else + if my < 0 + "U" + else + "D" + end + end + end +end + +class Gesture < Gtk::EventBox + DEFAULT_BACK_RGBA = [0.2, 0.2, 0.2, 0.5] + DEFAULT_LINE_RGBA = [1, 0, 0, 1] + DEFAULT_NEXT_RGBA = [0, 1, 0, 0.8] + DEFAULT_CURRENT_RGBA = [1, 0, 1, 0.8] + + def initialize(conf={}) + super() + set_visible_window(false) + conf ||= {} + @back_rgba = conf[:back_rgba] || DEFAULT_BACK_RGBA + @line_rgba = conf[:line_rgba] || DEFAULT_LINE_RGBA + @next_rgba = conf[:next_rgba] || DEFAULT_NEXT_RGBA + @current_rgba = conf[:current_rgba] || DEFAULT_CURRENT_RGBA + @processor = GestureProcessor.new(conf[:threshold], + conf[:skew_threshold_angle]) + @actions = [] + set_expose_event + set_motion_notify_event + set_button_release_event + end + + def add_action(sequence, action=Proc.new) + invalid_motion = sequence.find do |motion| + not @processor.available_motion?(motion) + end + raise "invalid motion: #{invalid_motion}" if invalid_motion + @actions << [sequence, action] + end + + def start(widget, button, x, y, base_x, base_y) + Gtk.grab_add(self) + @widget = widget + @button = button + @processor.start(x, y) + @base_x = base_x + @base_y = base_y + @cr = window.create_cairo_context + @cr.set_source_rgba(@line_rgba) + @cr.move_to(x, y) + end + + private + def perform_action + act = action + act.call(@widget) if act + @processor.reset + end + + def action + motions = @processor.motions + @actions.each do |sequence, act| + return act if sequence == motions + end + nil + end + + def available_motions + motions = @processor.motions + @actions.collect do |sequence, act| + if sequence == motions + sequence.last + else + nil + end + end.compact.uniq + end + + def next_available_motions + motions = @processor.motions + @actions.collect do |sequence, act| + if sequence[0..-2] == motions + sequence.last + else + nil + end + end.compact.uniq + end + + def match? + not action.nil? + end + + def set_expose_event + signal_connect("expose_event") do |widget, event| + if @processor.started? + cr = widget.window.create_cairo_context + + cr.rectangle(*widget.allocation.to_a) + cr.set_source_rgba(@back_rgba) + cr.fill + + cr.set_source_rgba(@next_rgba) + draw_available_marks(cr, next_available_motions) + + if action + cr.set_source_rgba(@current_rgba) + draw_mark(cr, *@processor.position) + end + + @cr.stroke_preserve + + true + else + false + end + end + end + + def draw_mark(cr, x=nil, y=nil, radius=nil) + x ||= @processor.position[0] + y ||= @processor.position[1] + radius ||= @processor.threshold + cr.save do + cr.translate(x, y) + cr.scale(radius, radius) + cr.arc(0, 0, 0.5, 0, 2 * Math::PI) + cr.fill + end + end + + def draw_available_marks(cr, motions) + motions.each do |motion| + adjust_x = calc_position_ratio(motion, %w(R), %w(L), %w(UR LR), %w(UL LL)) + adjust_y = calc_position_ratio(motion, %w(D), %w(U), %w(LR LL), %w(UR UL)) + + threshold = @processor.threshold + x, y = @processor.position + x += threshold * adjust_x + y += threshold * adjust_y + draw_mark(cr, x, y, threshold) + end + end + + def calc_position_ratio(motion, inc, dec, inc_skew, dec_skew) + case motion + when *inc + 1 + when *inc_skew + 1 / Math.sqrt(2) + when *dec + -1 + when *dec_skew + -1 / Math.sqrt(2) + else + 0 + end + end + + def set_motion_notify_event + signal_connect("motion_notify_event") do |widget, event| + if @processor.started? + x = @base_x + event.x + y = @base_y + event.y + @cr.line_to(x, y) + @cr.save do + if @processor.update_position(x, y) + queue_draw + end + end + @cr.stroke_preserve + true + else + false + end + end + end + + def set_button_release_event + signal_connect("button_release_event") do |widget, event| + if event.button == @button and @processor.started? + Gtk.grab_remove(self) + perform_action + hide + true + else + false + end + end + end +end + +class GesturedWidget < Gtk::EventBox + DEFAULT_GESTURE_BUTTON = 3 + + def initialize(gesture_button=nil) + super() + set_visible_window(false) + @gesture_button = gesture_button || DEFAULT_GESTURE_BUTTON + set_button_press_event + end + + def layout + parent + end + + def gesture(x, y, base_x, base_y) + if layout + layout.gesture(self, @gesture_button, x, y, base_x, base_y) + end + end + + private + def set_button_press_event + signal_connect("button_press_event") do |widget, event| + if event.button == @gesture_button + x, y, w, h = widget.allocation.to_a + gesture(x + event.x, y + event.y, x, y) + else + false + end + end + end +end + +class Layout < Gtk::Layout + def initialize() + super() + @gesture = Gesture.new() + put(@gesture, 0, 0) + end + + def gesture(widget, button, x, y, base_x, base_y) + remove(@gesture) + put(@gesture, 0, 0) + _, _, w, h = allocation.to_a + @gesture.set_size_request(w, h) + @gesture.show + @gesture.start(widget, button, x, y, base_x, base_y) + end + + def add_gesture_action(sequence, action=Proc.new) + @gesture.add_action(sequence, action) + end +end + +window = Gtk::Window.new("Mouse Gesture sample") + +layout = Layout.new + +gestured_widget = GesturedWidget.new +gestured_widget.set_size_request(50, 50) +gestured_widget.signal_connect("expose_event") do |widget, event| + x, y, w, h = widget.allocation.to_a + cr = widget.window.create_cairo_context + cr.set_source_rgba([0.8, 0.8, 0.3, 1]) + cr.translate(x, y) + cr.scale(w, h) + cr.arc(0.5, 0.5, 0.5, -0.1, 360) + cr.fill + false +end + +layout.put(gestured_widget, 75, 75) + + +gestured_widget2 = GesturedWidget.new +gestured_widget2.set_size_request(100, 50) +gestured_widget2.signal_connect("expose_event") do |widget, event| + x, y, w, h = widget.allocation.to_a + cr = widget.window.create_cairo_context + cr.set_source_rgba([0.3, 0.3, 0.8, 1]) + cr.translate(x, y) + cr.scale(w, h) + cr.arc(0.5, 0.5, 0.5, -0.1, 360) + cr.fill + false +end + +layout.put(gestured_widget2, 0, 25) + + +# gesture handlers +expand_size = 20 + +expand_left = Proc.new do |widget| + x = layout.child_get_property(widget, :x) + y = layout.child_get_property(widget, :y) + w, h = widget.size_request + layout.move(widget, x - expand_size, y) + widget.set_size_request(w + expand_size, h) +end + +expand_right = Proc.new do |widget| + x = layout.child_get_property(widget, :x) + y = layout.child_get_property(widget, :y) + w, h = widget.size_request + layout.move(widget, x, y) + widget.set_size_request(w + expand_size, h) +end + +expand_top = Proc.new do |widget| + x = layout.child_get_property(widget, :x) + y = layout.child_get_property(widget, :y) + w, h = widget.size_request + layout.move(widget, x, y - expand_size) + widget.set_size_request(w, h + expand_size) +end + +expand_bottom = Proc.new do |widget| + x = layout.child_get_property(widget, :x) + y = layout.child_get_property(widget, :y) + w, h = widget.size_request + layout.move(widget, x, y) + widget.set_size_request(w, h + expand_size) +end + +layout.add_gesture_action(["L"]) do |widget| + expand_left.call(widget) +end + +layout.add_gesture_action(["U"]) do |widget| + expand_top.call(widget) +end + +layout.add_gesture_action(["LL"]) do |widget| + expand_left.call(widget) + expand_bottom.call(widget) +end + +layout.add_gesture_action(["R", "LR"]) do |widget| + expand_right.call(widget) + expand_bottom.call(widget) + expand_right.call(widget) +end + + +window.add(layout) +window.signal_connect("destroy"){Gtk.main_quit} + +window.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/pangorenderer.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/pangorenderer.rb new file mode 100644 index 0000000..a3d57e6 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/pangorenderer.rb @@ -0,0 +1,66 @@ +#!/usr/bin/env ruby +=begin + pangorenderer.rb - Ruby/GTK sample script. + + Copyright (c) 2005,2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: pangorenderer.rb,v 1.5 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +RADIUS = 80 +N_WORDS = 16 + +if str = Gtk.check_version(2, 6, 0) + puts "This sample requires GTK+ 2.6.0 or later" + puts str + exit +end + +win = Gtk::Window.new("Gdk::PangoRenderer sample") +win.signal_connect("destroy"){Gtk.main_quit} +win.set_default_size(400, 400) +win.realize + +matrix = Pango::Matrix.new + +renderer = Gdk::PangoRenderer.default +renderer.drawable = win.window +renderer.gc = Gdk::GC.new(win.window) +width, height = win.size + +device_radius = [width, height].min / 6.0 + +matrix.translate!(device_radius + (width - 2 * device_radius) / 2.0, + device_radius + (height - 2 * device_radius) / 2.0) +matrix.scale!(device_radius / RADIUS, device_radius / RADIUS) + +context = Gdk::Pango.context +layout = Pango::Layout.new(context) +layout.text = "Ruby-GNOME2" +layout.font_description = Pango::FontDescription.new("Sans Bold 14") + +background = Gdk::Color.new(65535, 65535, 65535) +Gdk::Colormap.system.alloc_color(background, false, true) +win.window.background = background + +win.signal_connect("expose_event") do + (0...N_WORDS).each do |i| + rotated_matrix = matrix.dup + angle = 360 * i / N_WORDS.to_f + color = Gdk::Color.new(65535 * rand, 65535 * rand, 65535 * rand) + renderer.set_override_color(Pango::Renderer::PART_FOREGROUND, color) + + rotated_matrix.rotate!(angle) + context.set_matrix(rotated_matrix) + layout.context_changed + width, height = layout.size + renderer.draw_layout(layout, width / 2, RADIUS * Pango::SCALE) + end +end + +win.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/pointer_grab.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/pointer_grab.rb new file mode 100644 index 0000000..c4e91bb --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/pointer_grab.rb @@ -0,0 +1,34 @@ +=begin + pointer_grab.rb - Gdk::Window#pointer_grab/ungrab sample script. + + Copyright (C) 2001-2006 Masao Mutoh<mutoh@highway.ne.jp> + This program is licenced under the same licence as Ruby-GNOME. + + $Date: 2006/06/17 13:18:12 $ + $Id: pointer_grab.rb,v 1.5 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("Pointer grab/ungrab sample") + +cursor = Gdk::Cursor.new(Gdk::Cursor::WATCH) +button1 = Gtk::Button.new("Grab Window!") +button2 = Gtk::Button.new("Ungrab Window!") + +button1.signal_connect('clicked') do + Gdk.pointer_grab(window.window, true, Gdk::Event::BUTTON_PRESS_MASK, + window.window, cursor, Gdk::Event::CURRENT_TIME) + p Gdk.pointer_is_grabbed? +end + +button2.signal_connect('clicked') do + Gdk.pointer_ungrab(Gdk::Event::CURRENT_TIME) + p Gdk.pointer_is_grabbed? +end + +window.add(Gtk::VBox.new.add(button1).add(button2)) +window.set_default_size(200,100).show_all +window.signal_connect("destroy"){Gtk.main_quit} + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/print.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/print.rb new file mode 100644 index 0000000..179d0d2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/print.rb @@ -0,0 +1,247 @@ +#!/usr/bin/env ruby +=begin + print.rb - Gtk::Print* sample + + Copyright (C) 2007 Mathieu Blondel + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: print.rb,v 1.1 2007/08/05 15:41:31 mutoh Exp $ +=end + +require 'gtk2' + +# Values returned by a Pango::Layout or set in a Pango::Layout +# are always multiple of Pango::SCALE. Those are convenience methods to +# deal with that. +class Pango::Layout + def size_in_points + self.size.collect { |v| v / Pango::SCALE } + end + + def width_in_points + self.size[0] / Pango::SCALE + end + + def height_in_points + self.size[1] / Pango::SCALE + end + + def width_in_points=(width) + self.width = width * Pango::SCALE + end +end + +class Print < Gtk::PrintOperation + + FONT = Pango::FontDescription.new("sans 12") + FONT_SMALL = Pango::FontDescription.new("sans 8") + + FONT_SIZE = 12 + FONT_SMALL_SIZE = 8 + + def initialize (parent_window, text) + super() + @parent_window = parent_window + @text = text + + # with this option disabled, the origin is the the upper left corner + # *taking into consideration margins* ! + self.use_full_page = false + self.unit = Gtk::PaperSize::UNIT_POINTS + + # set default paper size + page_setup = Gtk::PageSetup.new + paper_size = Gtk::PaperSize.new(Gtk::PaperSize.default) + page_setup.paper_size_and_default_margins = paper_size + self.default_page_setup = page_setup + + # show a progress bar + self.show_progress = true + + # You must choose between "paginate" and "begin-print". + # "begin-print" is emitted only once and "paginate" is emitted + # until the block returns true. + # In both cases, you must set the number of pages at the end with + # Gtk::PrintOperation#n_pages= + signal_connect("begin-print") do |pop, context| + puts "calls begin-print" + cr = context.cairo_context + paragraphs = @text.split("\n") + layouts = [] + paragraphs.each do |para| + layouts << create_layout(cr, para) + end + + # distribute paragraph layouts among pages + @page_layouts = [] + + curr_height = 0 + n_pages = 0 + layouts.each do |layout| + height = layout.height_in_points + if curr_height + height > real_page_height + n_pages += 1 + curr_height = 0 + end + @page_layouts[n_pages] ||= [] + @page_layouts[n_pages] << layout + curr_height += height + end + + pop.n_pages = n_pages + 1 + end + + signal_connect("draw-page") do |pop, context, page_num| + puts "calls draw-page %d" % page_num + + cr = context.cairo_context + + x, y = [0,0] # this means we start at the upper left margin + + if @page_layouts[page_num] + @page_layouts[page_num].each do |layout| + cr.move_to(x,y) + cr.show_pango_layout(layout) + y += layout.height_in_points + end + total_pages = @page_layouts.length + else + total_pages = 1 + end + + # page_num starts at 0 + draw_footer(cr, page_num + 1, total_pages) + end + end + + def run_print_dialog + res = run(ACTION_PRINT_DIALOG, @parent_window) + case res + when RESULT_ERROR + puts "error" + when RESULT_CANCEL + puts "cancelled" + when RESULT_APPLY + puts "applied" + when RESULT_IN_PROGRESS + puts "in progress" + end + end + + def run_preview + res = run(ACTION_PREVIEW, @parent_window) + end + + private + + def page_height + setup = self.default_page_setup + # this takes margins into consideration, contrary to get_paper_height + setup.get_page_height(Gtk::PaperSize::UNIT_POINTS) + end + + def page_width + setup = self.default_page_setup + width = setup.get_page_width(Gtk::PaperSize::UNIT_POINTS) + end + + def real_page_height + page_height - footer_height + end + + def footer_height + 5 * FONT_SMALL_SIZE + end + + def create_layout(cr, text) + layout = cr.create_pango_layout + + layout.width_in_points = page_width + layout.font_description = FONT + layout.wrap = Pango::Layout::WRAP_CHAR + layout.ellipsize = Pango::Layout::ELLIPSIZE_NONE + layout.single_paragraph_mode = false + + layout.text = text + + layout + end + + def draw_footer(cr, nth_page, total_page) + layout = cr.create_pango_layout + layout.alignment = Pango::Layout::ALIGN_RIGHT + layout.font_description = FONT_SMALL + layout.text = "Page %d/%d" % [nth_page, total_page] + "\n" + \ + Time.now.strftime("Printed on %Y/%m/%d at %H:%M") + "\n" + \ + "Powered by Ruby-GNOME2!" + width, height = layout.size_in_points + x, y = [page_width, page_height] + x -= width + y -= height + cr.move_to(x, y) + cr.show_pango_layout(layout) + cr.rel_move_to(width, -2) + cr.rel_line_to(-page_width, 0) + cr.stroke + end + +end + +class Window < Gtk::Window + + def initialize + super + + signal_connect("delete-event") { Gtk.main_quit } + + set_default_size(600, 600) + + @textview = Gtk::TextView.new + @textview.wrap_mode = Gtk::TextTag::WRAP_WORD + + hbox = Gtk::HBox.new + + page_setup_button = Gtk::Button.new + page_setup_button.label = "Page setup" + page_setup_button.signal_connect("clicked") do + @page_setup = Print::run_page_setup_dialog(self, # parent window + @page_setup) + end + + print_preview_button = Gtk::Button.new(Gtk::Stock::PRINT_PREVIEW) + print_preview_button.signal_connect("clicked") do + printop = Print.new(self, @textview.buffer.text) + printop.default_page_setup = @page_setup if @page_setup + printop.run_preview + end + + print_button = Gtk::Button.new(Gtk::Stock::PRINT) + print_button.signal_connect("clicked") do + printop = Print.new(self, @textview.buffer.text) + printop.default_page_setup = @page_setup if @page_setup + printop.run_print_dialog + end + + [page_setup_button, print_preview_button, print_button].each do |b| + hbox.pack_start(b, true, true) # expand, fill + end + + scrollbar = Gtk::VScrollbar.new + + vbox = Gtk::VBox.new + scroll = Gtk::ScrolledWindow.new.add(@textview) + scroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) + vbox.pack_start(scroll) + vbox.pack_end(hbox, false, false) + + add(vbox) + + show_all + + end + +end + +Window.new + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/properties.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/properties.rb new file mode 100755 index 0000000..31235ed --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/properties.rb @@ -0,0 +1,85 @@ +=begin + properties.rb - + + GLib::Object#properties and Gtk::Container#child_properties sample script. + + Copyright (C) 2004-2006 Masao Mutoh + + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: properties.rb,v 1.3 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +class MyButton < Gtk::Button + type_register + + def initialize(label = nil) + # XXX: + # When type_register() is used. + # super is equivalent to GLib::Object#initialize. + super("label" => label) + @fuga = 0 + @hoge = 0 + end + + # define new property "fuga" + install_property(GLib::Param::Int.new("fuga", # name + "Fuga", # nick + "fuga fuga", # blurb + 0, # min + 10000, # max + 0, # default + GLib::Param::READABLE | + GLib::Param::WRITABLE)) + + # define new property "hoge" + install_child_property(GLib::Param::Int.new("hoge", # name + "Hoge", # nick + "hoge hoge", # blurb + 0, # min + 10000, # max + 0, # default + GLib::Param::READABLE | + GLib::Param::WRITABLE)) + + # implementation of the property "fuga" + def fuga + puts "MyButton#fuga is called" + @fuga + end + def fuga=(arg) + puts "MyButton#fuga= is called" + @fuga = arg + notify("fuga") + end + + # implementation of the property "hoge" + def get_hoge(child) + puts "MyButton#get_hoge is called" + @hoge + end + def set_hoge(child, arg) + puts "MyButton#set_hoge is called" + @hoge = arg + end +end + +b = MyButton.new("Hello") +p b +p b.label +p b.gtype + +p MyButton.properties +p b.get_property("fuga") +b.set_property("fuga", 1) +p b.get_property("fuga") + +p MyButton.child_properties +p child = b.child +p b.child_get_property(child, "hoge") +b.child_set_property(child, "hoge", 2) +p b.child_get_property(child, "hoge") + +p MyButton.ancestors diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/radiobutton.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/radiobutton.rb new file mode 100644 index 0000000..489fda2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/radiobutton.rb @@ -0,0 +1,47 @@ +#!/usr/bin/env ruby +=begin + radiobutton.rb - Ruby/GTK2 sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: radiobutton.rb,v 1.10 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("Gtk::RadioButton sample") +window.signal_connect("destroy"){Gtk.main_quit} + +box1 = Gtk::VBox.new +window.add(box1) + +box2 = Gtk::VBox.new(false, 10) +box2.border_width = 10 +box1.add(box2) + +button1 = Gtk::RadioButton.new("_button1") +button2 = Gtk::RadioButton.new(button1, "_button2", false) +button3 = Gtk::RadioButton.new(button1, Gtk::Stock::QUIT) + +box2.add(button1).add(button2).add(button3) + +box1.add(Gtk::HSeparator.new) + +box2 = Gtk::VBox.new(false, 10) +box2.border_width = 10 +box1.add(box2) + +close = Gtk::Button.new("close") +close.signal_connect("clicked") do + Gtk.main_quit +end +box2.add(close) + +close.can_default = true +close.grab_default + +window.signal_connect("destroy"){Gtk.main_quit} +window.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/recentchooserdialog.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/recentchooserdialog.rb new file mode 100644 index 0000000..712aa42 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/recentchooserdialog.rb @@ -0,0 +1,59 @@ +#!/usr/bin/env ruby +=begin + recentchooserdialog.rb - Ruby/GTK2 sample script. + + Copyright (c) 2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: recentchooserdialog.rb,v 1.2 2006/11/15 23:46:13 mutoh Exp $ +=end + +require 'gtk2' + +if str = Gtk.check_version(2, 10, 0) + puts "This sample requires GTK+ 2.10.0 or later" + puts str + exit +end + +dialog = Gtk::RecentChooserDialog.new("Recent Chooser Dialog Sample", + nil, + [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL], + [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT]) + +dialog.signal_connect("response") do |widget, response| + case response + when Gtk::Dialog::RESPONSE_ACCEPT + info = dialog.current_item + if info + puts "----" + puts info.uri + puts info.display_name + puts info.description + puts info.mime_type + puts info.added + puts info.modified + puts info.visited + puts info.private_hint? + p info.application_info("gedit") + p info.applications + puts info.last_application + p info.groups + puts info.has_group?("web") + puts info.has_application?("gedit") + puts info.get_icon(64) + puts info.short_name + puts info.uri_display + puts info.age + puts info.local? + puts info.exist? + end + else + p "Close" + dialog.destroy + Gtk.main_quit + end +end +dialog.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/rgtk+cairo.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/rgtk+cairo.rb new file mode 100644 index 0000000..ee7cdcd --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/rgtk+cairo.rb @@ -0,0 +1,44 @@ +#!/usr/bin/env ruby +=begin + rgtk+cairo.rb - Ruby/GTK2 using Ruby/Cairo sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + Heavily inspired from png.rb example of rcairo. + + $Id: rgtk+cairo.rb,v 1.3 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' +require 'cairo' + +w = Gtk::Window.new.add(vb = Gtk::VBox.new) +vb.add(da = Gtk::DrawingArea.new) +da.set_size_request(200, 200) + +da.signal_connect('expose-event') { |widget, event| + cr = widget.window.create_cairo_context + + # fill background with white + cr.set_source_rgba(1.0, 1.0, 1.0) + cr.paint + + # create shape + cr.move_to(50, 50) + cr.curve_to(100, 25, 100, 75, 150, 50) + cr.line_to(150, 150) + cr.line_to(50, 150) + cr.close_path + + cr.set_source_rgb(0.0, 0.0, 0.0) + cr.fill_preserve + cr.set_source_rgb(1.0, 0.0, 0.0) + cr.set_line_join(Cairo::LINE_JOIN_MITER) + cr.set_line_width(4) + cr.stroke +} + +w.signal_connect("destroy"){Gtk.main_quit} +w.show_all +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/scalebutton.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/scalebutton.rb new file mode 100644 index 0000000..aacab88 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/scalebutton.rb @@ -0,0 +1,25 @@ +#!/usr/bin/env ruby +=begin + scalebutton.rb - Very simple Gtk::ScaleButton example. + + Copyright (c) 2007 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: scalebutton.rb,v 1.1 2007/07/12 14:04:54 ggc Exp $ +=end + +require 'gtk2' + +if str = Gtk.check_version(2, 12, 0) + puts "This sample requires GTK+ 2.12.0 or later" + puts str + exit +end + +window = Gtk::Window.new +window.add(scale = Gtk::ScaleButton.new(Gtk::IconSize::BUTTON)) +scale.set_icons(['gtk-goto-bottom', 'gtk-goto-top', 'gtk-execute']) +scale.signal_connect('value-changed') { |widget, value| puts "value changed: #{value}" } +window.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/settings.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/settings.rb new file mode 100644 index 0000000..d363607 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/settings.rb @@ -0,0 +1,41 @@ +=begin + setting.rb - Gtk::Settings sample script. + + Copyright (C) 2004-2006 Masao Mutoh + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: settings.rb,v 1.3 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +spec = GLib::Param::Int.new("integer", # name + "Integer", # nick + "Integer integer", # blurb + 0, # min + 10000, # max + 0, # default + GLib::Param::READABLE| + GLib::Param::WRITABLE) + +enum = GLib::Param::Enum.new("enum", # name + "Enum", # nick + "Enum enum", # blurb + GLib::Type["GdkCursorType"], #type + Gdk::Cursor::ARROW, #default + GLib::Param::READABLE| + GLib::Param::WRITABLE) + +flags = GLib::Param::Flags.new("flags", # name + "Flags", # nick + "Flags flags", # blurb + GLib::Type["GdkEventMask"], #type + Gdk::Event::LEAVE_NOTIFY_MASK, #default + GLib::Param::READABLE| + GLib::Param::WRITABLE) + +p Gtk::Settings.rc_property_parse_color(spec, "{2222,44444,65535}").to_a +p Gtk::Settings.rc_property_parse_enum(enum, "watch") +p Gtk::Settings.rc_property_parse_flags(flags, "(scroll-mask|structure-mask)") +p Gtk::Settings.rc_property_parse_requisition(spec, "{100, 200}") +p Gtk::Settings.rc_property_parse_border(spec, "{100, 200, 300, 400}").to_a diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/statusicon.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/statusicon.rb new file mode 100644 index 0000000..a652278 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/statusicon.rb @@ -0,0 +1,123 @@ +#!/usr/bin/env ruby +=begin + status_icon.rb - Gtk::StatusIcon sample. + + This sample refers gtk/tests/teststatusicon.c of GTK+-2.10.x. + + Copyright (c) 2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: statusicon.rb,v 1.1 2006/11/17 18:12:41 mutoh Exp $ +=end + +require 'gtk2' + +if str = Gtk.check_version(2, 10, 0) + puts "This sample requires GTK+ 2.10.0 or later" + puts str + exit +end + +class StatusIconSample < Gtk::StatusIcon + STATUS_INFO = 0 + STATUS_QUESTION = 1 + + def initialize + super + @status = STATUS_INFO + update_icon + + set_blinking(true) + signal_connect("activate"){ + icon_activated + } + signal_connect("popup-menu"){|w, button, activate_time| + menu = Gtk::Menu.new + checkmenuitem = Gtk::CheckMenuItem.new("Blink") + checkmenuitem.active = blinking? + checkmenuitem.signal_connect("activate"){|w| + set_blinking(w.active?) + } + menu.append(checkmenuitem) + + menuitem = Gtk::MenuItem.new("Quit") + menuitem.signal_connect("activate"){ + set_visible(false) + Gtk.main_quit + } + menu.append(menuitem) + menu.show_all + menu.popup(nil, nil, button, activate_time) + } + + timeout_func + end + + def update_icon + if @status == STATUS_INFO + set_icon_name(Gtk::Stock::DIALOG_INFO) + set_tooltip("Some Information ...") + else + set_icon_name(Gtk::Stock::DIALOG_QUESTION) + set_tooltip("Some Question ...") + end + end + + def timeout_func + GLib::Timeout.add(2000) { + if @status == STATUS_INFO + @status = STATUS_QUESTION + else + @status = STATUS_INFO + end + update_icon + true + } + end + + def icon_activated + unless @dialog + @dialog = Gtk::MessageDialog.new(nil, 0, + Gtk::MessageDialog::QUESTION, + Gtk::MessageDialog::BUTTONS_CLOSE, + "You wanna test the status icon?") + @dialog.window_position = Gtk::Window::POS_CENTER + + @dialog.signal_connect("response"){ @dialog.hide } + @dialog.signal_connect("delete_event"){ @dialog.hide_on_delete } + + toggle = Gtk::ToggleButton.new("_Show the icon") + @dialog.vbox.pack_end(toggle, true, true, 6) + toggle.active = visible? + toggle.signal_connect("toggled"){|w| + set_visible(w.active?) + } + + toggle = Gtk::ToggleButton.new("_Blink the icon") + @dialog.vbox.pack_end(toggle, true, true, 6) + toggle.active = blinking? + toggle.signal_connect("toggled"){|w| + set_blinking(w.active?) + } + + toggle = Gtk::ToggleButton.new("_Change the icon") + @dialog.vbox.pack_end(toggle, true, true, 6) + toggle.active = (@timeout != 0) + toggle.signal_connect("toggled"){ + if @timeout and @timeout > 0 + GLib::Source.remove(@timeout) + @timeout = 0 + else + @timeout = timeout_func + end + } + end + @dialog.show_all + @dialog.present + end + +end + +StatusIconSample.new + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/stock.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/stock.rb new file mode 100644 index 0000000..d50a12c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/stock.rb @@ -0,0 +1,36 @@ +=begin + stock.rb - Gtk::Stock sample script. + + Copyright (C) 2001-2006 Masao Mutoh + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: stock.rb,v 1.7 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("Gtk::Stock sample") +window.signal_connect("destroy"){Gtk.main_quit} + +stocks = Gtk::Stock.constants.sort + +image = Gtk::Image.new +label = Gtk::Label.new +button = Gtk::Button.new("Click!") +cnt = 0 +button.signal_connect("clicked") do + stock_name = "Gtk::Stock::#{stocks[cnt]}" + label.set_text(stock_name) + image.set(eval(stock_name), Gtk::IconSize::DIALOG) + if cnt < stocks.size - 1 + cnt += 1 + else + cnt = 0 + end +end + +box = Gtk::VBox.new.add(image).add(label).add(button) +window.add(box).set_default_size(200,200).show_all + +Gtk.main + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/style_property.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/style_property.rb new file mode 100755 index 0000000..7842c0f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/style_property.rb @@ -0,0 +1,67 @@ +#!/usr/bin/env ruby +=begin + style_property.rb - Ruby/GTK2 sample script. + + Copyright (c) 2004,2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: style_property.rb,v 1.4 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +class MyButton < Gtk::Button + type_register + + def initialize(label = nil) + # When type_register() is used. + # super is equivalent to GLib::Object#initialize. + super("label" => label) + end + + install_style_property(GLib::Param::Int.new("foo", # name + "Foo", # nick + "FOO", # blurb + 0, #min + 100, #max + 5, #default + GLib::Param::READABLE | + GLib::Param::WRITABLE)) do |pspec, str| + p pspec, str + str.to_i + 10 #return the converted value. + end + + install_style_property(GLib::Param::Enum.new("bar", # name + "Bar", # nick + "BAR", # blurb + GLib::Type["GdkCursorType"], #Enum type + Gdk::Cursor::ARROW, #default + GLib::Param::READABLE | + GLib::Param::WRITABLE)) do |pspec, str| + p pspec, str + if str.strip! == "boat" + Gdk::Cursor::BOAT + else + pspec.default + end + end +end + +Gtk::RC.parse("./style_property.rc") + +win = Gtk::Window.new("Gtk::RC sample") +b = MyButton.new("Hello") +b.signal_connect("clicked"){ Gtk.main_quit } + +p MyButton.style_properties + +win.set_default_size(100, 100) +win.add(b).show_all +win.signal_connect("destroy"){ Gtk.main_quit } + +# You need to call them after "Gtk::Widget#show" +# (Or in expose event). +p b.style_get_property("foo") +p cursor = b.style_get_property("bar") + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/style_property.rc b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/style_property.rc new file mode 100644 index 0000000..75f7017 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/style_property.rc @@ -0,0 +1,19 @@ +/* + style_property.rc - Ruby/GTK sample rc file for style_property.rb. + + Copyright (c) 2004 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: style_property.rc,v 1.1 2004/01/25 15:52:38 mutoh Exp $ +*/ +style "test-default" +{ + bg[NORMAL] = { 0.80, 0.80, 0.40 } + MyButton::focus-line-width = 3 + MyButton::focus-line-pattern = "\10\2" + MyButton::foo = 30 + MyButton::bar = boat +} + +class "MyButton" style "test-default" + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/t-gtkplug.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/t-gtkplug.rb new file mode 100644 index 0000000..213ecc3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/t-gtkplug.rb @@ -0,0 +1,58 @@ +#!/usr/bin/env ruby + +=begin + Sample script using Gtk::Socket and Gtk::Plug. + + $ ruby t-gtksocket.rb + + Written by Alex Boussinet <mailto:dbug@wanadoo.fr> for testing purpose only. + + Copyright (c) 2003-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: t-gtkplug.rb,v 1.5 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +class MyGtkPlug + def initialize(xid, plug) + plug = "Button" if plug.nil? + if xid.nil? + @window = Gtk::Window.new("Gtk::Plug Test") + @window.set_default_size(250, 50) + else + @window = Gtk::Plug.new(xid.to_i) + end + @window.window_position = Gtk::Window::POS_CENTER + @window.signal_connect("delete_event"){Gtk.main_quit} + @vbox = Gtk::VBox.new(true, 5) + @window.add(@vbox) + @button1 = Gtk::Button.new(plug) + @button1.signal_connect("clicked"){ $stderr.puts plug} + @button2 = Gtk::Button.new("Exit") + @button2.signal_connect("clicked"){Gtk.main_quit} + # Exit button to test an unexpected end of child process by Gtk::Socket + @vbox.add(@button1) + @vbox.add(@button2) + @window.show_all + end +end + +xid = nil +ARGV.each_index { |i| + arg = ARGV.at(i) + if arg == "-x" + if arg.length > 2 + xid = arg[2..-1] + else + xid = ARGV.at(i + 1) + ARGV.delete_at(i + 1) + end + xid = nil if xid.to_i <= 0 + ARGV.delete_at(i) + end +} + +MyGtkPlug.new(xid, ARGV.shift) +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/t-gtksocket.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/t-gtksocket.rb new file mode 100644 index 0000000..df48a9e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/t-gtksocket.rb @@ -0,0 +1,65 @@ +#!/usr/bin/env ruby +=begin + Sample script using Gtk::Socket and Gtk::Plug. + + $ ruby t-gtksocket.rb + + Written by Alex Boussinet <mailto:dbug@wanadoo.fr> for testing purpose only. + + Copyright (c) 2003-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: t-gtksocket.rb,v 1.5 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +class MyGtkSocket < Gtk::Window + def initialize + super("Gtk::Socket Test") + set_window_position(Gtk::Window::POS_CENTER) + signal_connect("delete_event"){Gtk::main_quit} + + @buttons = [] + 6.times {|n| + @buttons << Gtk::Button.new("Plug #{n}") + @buttons.last.signal_connect("clicked"){ plug(n) } + } + + @table = Gtk::Table.new(1, 2) + @table.set_size_request(320, 200) + add(@table) + @vbox = Gtk::VBox.new(true, 5) + @buttons.each{|b| @vbox.add(b) } + @vbox.set_size_request(150, 190) + @table.attach(@vbox, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL, 5, 5) + @socket = Gtk::Socket.new + @table.attach(@socket, 1, 2, 0, 1, Gtk::FILL, Gtk::FILL, 5, 5) + @socket.set_size_request(150, 150) + + show_all + @xid = @socket.id + @pid = 0 + end + + def plug(arg) + if @pid != 0 + Process.kill("SIGKILL", @pid) + Process.waitpid(@pid) + begin + @table.remove(@socket) unless @socket.destroyed? + rescue ArgumentError + # socket has been destroyed because child process finished unexpectedly + end + @socket = Gtk::Socket.new + @table.attach(@socket, 1, 2, 0, 1, Gtk::FILL, Gtk::FILL, 5, 5) + @socket.set_size_request(150, 190) + @socket.show + @xid = @socket.id + end + @pid = fork { exec "ruby t-gtkplug.rb -x #{@xid} Plug#{arg}" } + end +end + +MyGtkSocket.new +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/test.xpm b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/test.xpm new file mode 100644 index 0000000..9b0d2ef --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/test.xpm @@ -0,0 +1,92 @@ +/* XPM */ +static char *openfile[] = { +/* width height num_colors chars_per_pixel */ +" 20 19 66 2", +/* colors */ +".. c None", +".# c #000000", +".a c #dfdfdf", +".b c #7f7f7f", +".c c #006f6f", +".d c #00efef", +".e c #009f9f", +".f c #004040", +".g c #00bfbf", +".h c #ff0000", +".i c #ffffff", +".j c #7f0000", +".k c #007070", +".l c #00ffff", +".m c #00a0a0", +".n c #004f4f", +".o c #00cfcf", +".p c #8f8f8f", +".q c #6f6f6f", +".r c #a0a0a0", +".s c #7f7f00", +".t c #007f7f", +".u c #5f5f5f", +".v c #707070", +".w c #00f0f0", +".x c #009090", +".y c #ffff00", +".z c #0000ff", +".A c #00afaf", +".B c #00d0d0", +".C c #00dfdf", +".D c #005f5f", +".E c #00b0b0", +".F c #001010", +".G c #00c0c0", +".H c #000f0f", +".I c #00007f", +".J c #005050", +".K c #002f2f", +".L c #dfcfcf", +".M c #dfd0d0", +".N c #006060", +".O c #00e0e0", +".P c #00ff00", +".Q c #002020", +".R c #dfc0c0", +".S c #008080", +".T c #001f1f", +".U c #003f3f", +".V c #007f00", +".W c #00000f", +".X c #000010", +".Y c #00001f", +".Z c #000020", +".0 c #00002f", +".1 c #000030", +".2 c #00003f", +".3 c #000040", +".4 c #00004f", +".5 c #000050", +".6 c #00005f", +".7 c #000060", +".8 c #00006f", +".9 c #000070", +"#. c #7f7f80", +"## c #9f9f9f", +/* pixels */ +"........................................", +"........................................", +"........................................", +".......................#.#.#............", +".....................#.......#...#......", +"...............................#.#......", +".......#.#.#.................#.#.#......", +".....#.y.i.y.#.#.#.#.#.#.#..............", +".....#.i.y.i.y.i.y.i.y.i.#..............", +".....#.y.i.y.i.y.i.y.i.y.#..............", +".....#.i.y.i.y.#.#.#.#.#.#.#.#.#.#.#....", +".....#.y.i.y.#.s.s.s.s.s.s.s.s.s.#......", +".....#.i.y.#.s.s.s.s.s.s.s.s.s.#........", +".....#.y.#.s.s.s.s.s.s.s.s.s.#..........", +".....#.#.s.s.s.s.s.s.s.s.s.#............", +".....#.#.#.#.#.#.#.#.#.#.#..............", +"........................................", +"........................................", +"........................................" +}; diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/textbuffer_serialize.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/textbuffer_serialize.rb new file mode 100644 index 0000000..14c4273 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/textbuffer_serialize.rb @@ -0,0 +1,130 @@ +#!/usr/bin/env ruby +=begin + textbuffer_serialize.rb - Ruby/GTK sample script. + + Copyright (c) 2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: textbuffer_serialize.rb,v 1.1 2006/11/23 08:39:13 mutoh Exp $ +=end + +require 'gtk2' + +if str = Gtk.check_version(2, 10, 0) + puts "This sample requires GTK+ 2.10.0 or later" + puts str + exit +end + +current_folder = ENV['HOME'] || "." +file_name = "serialized.dat" + +textview = Gtk::TextView.new +textview.set_size_request(600, 400) +buffer = textview.buffer +buffer.text = DATA.read +format = buffer.serialize_formats[0] +buffer.register_serialize_target(nil) +buffer.register_deserialize_target(nil) + +window = Gtk::Window.new("Gtk::TextBuffer Serialize Demo") +vbox = Gtk::VBox.new + +serialize_button = Gtk::FileChooserButton.new("Serialize to a file", + Gtk::FileChooser::ACTION_OPEN) +deserialize_button = Gtk::FileChooserButton.new("Serialize to a file", + Gtk::FileChooser::ACTION_OPEN) + +serialize_button.current_folder = current_folder +deserialize_button.current_folder = current_folder + +toolbar = Gtk::Toolbar.new + +toolbar.append(Gtk::Stock::OPEN, "Deserialize from a file") do + dialog = Gtk::FileChooserDialog.new("Deserialize from a file", + window, + Gtk::FileChooser::ACTION_OPEN, + nil, + [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL], + [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT]) + + dialog.filename = File.expand_path(file_name) + if dialog.run == Gtk::Dialog::RESPONSE_ACCEPT + file_name = dialog.filename + File.open(file_name, "rb") {|io| + buffer.delete(buffer.start_iter, buffer.end_iter) + buffer.deserialize(buffer, format, buffer.start_iter, io.read) + } + end + dialog.destroy +end + +toolbar.append(Gtk::Stock::SAVE, "Serialize to a file") do + dialog = Gtk::FileChooserDialog.new("Serialize from a file", + window, + Gtk::FileChooser::ACTION_SAVE, + nil, + [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL], + [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT]) + dialog.current_name = file_name + if dialog.run == Gtk::Dialog::RESPONSE_ACCEPT + file_name = dialog.filename + File.open(file_name, "wb") {|io| + io.write(buffer.serialize(buffer, format, buffer.start_iter, buffer.end_iter)) + } + end + dialog.destroy +end + +toolbar.append(Gtk::Stock::CLEAR, "Clear all") do + buffer.delete(buffer.start_iter, buffer.end_iter) +end +toolbar.append_space +toolbar.append(Gtk::Stock::SELECT_COLOR, "Color the region") do + dialog = Gtk::ColorSelectionDialog.new("Color the region") + if dialog.run == Gtk::Dialog::RESPONSE_OK + bounds = buffer.selection_bounds + color = dialog.colorsel.current_color + tag_name = color.to_a.inspect + unless tag = buffer.tag_table.lookup(tag_name) + tag = Gtk::TextTag.new(tag_name).set_foreground_gdk(color) + end + buffer.tag_table.add(tag) + buffer.apply_tag(tag, bounds[0], bounds[1]) + end + dialog.destroy +end + +toolbar.append(Gtk::Stock::SELECT_FONT, "Set a font to the region") do + dialog = Gtk::FontSelectionDialog.new("Set font to the region") + if dialog.run == Gtk::Dialog::RESPONSE_OK + bounds = buffer.selection_bounds + font = dialog.font_name + unless tag = buffer.tag_table.lookup(font) + tag = Gtk::TextTag.new(font).set_font(font) + end + buffer.tag_table.add(tag) + buffer.apply_tag(tag, bounds[0], bounds[1]) + end + dialog.destroy +end + +toolbar.append_space +toolbar.append(Gtk::Stock::QUIT, "Quit this application") do + Gtk.main_quit +end + +vbox.pack_start(toolbar, false, false).add(Gtk::ScrolledWindow.new.add(textview)) +window.add(vbox) +window.show_all +window.signal_connect("destroy") { Gtk.main_quit } + +Gtk.main + +__END__ +This is a sample script for rich text serialization/deserialization. + +1. Edit this text using font/color buttons. +2. Click save button and save this text (= serialize this as rich text to a file) +3. Click clear button and clear this text buffer. +4. Click load button and load the file which you save (= deserialize this). diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/threads.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/threads.rb new file mode 100644 index 0000000..3e01425 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/threads.rb @@ -0,0 +1,72 @@ +#!/usr/bin/env ruby +=begin + threads.rb - Ruby/GTK2 sample script. + + Copyright (c) 2003-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: threads.rb,v 1.5 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' +require 'thread' + +label = Gtk::Label.new + +Thread.new { + (0...1000).each { |cnt| + p "A:" + cnt.to_s + label.label = "A:" + cnt.to_s + sleep(2) + } +} + +start_button = Gtk::Button.new("start") +stop_button = Gtk::Button.new("stop") + +start_button.signal_connect("clicked") do + start_button.sensitive=false + @th = Thread.new { + (0...10).each { |cnt| + p "B:" + cnt.to_s + label.label = "B:" + cnt.to_s + sleep(2) + } + @th = nil + start_button.sensitive = true + start_button.grab_focus + stop_button.sensitive = false + } + stop_button.sensitive = true + stop_button.grab_focus +end + +stop_button.signal_connect("clicked") do + if @th + @th.kill + puts "killed" + @th = nil + start_button.sensitive = true + start_button.grab_focus + stop_button.sensitive = false + end +end + +stop_button.sensitive = false + +box = Gtk::VBox.new. + set_size_request(100,100) + +box << label << start_button << stop_button + +win = Gtk::Window.new << box + +win.show_all.signal_connect("delete_event") do + p "Exiting..." + Gtk.main_quit + Thread.list.each {|t| t.kill } +end + +Gtk.main + + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/to_drawable.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/to_drawable.rb new file mode 100644 index 0000000..46844f8 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/to_drawable.rb @@ -0,0 +1,42 @@ +#!/usr/bin/env ruby +=begin + to_drawable.rb - Gdk::Pixbuf(GDK methods) sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: to_drawable.rb,v 1.6 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +filename = ARGV[0] +unless filename + puts "ruby #{$0} filename" + exit(1) +end + +pixbuf = Gdk::Pixbuf.new(filename) + +w = Gtk::Window.new("Drawable sample") +w.realize +w.signal_connect('delete-event') do + Gtk.main_quit +end + +d = Gtk::DrawingArea.new +gc = Gdk::GC.new(w.window) +d.signal_connect('expose-event') do |w, e| + unless e.count > 0 + width = w.allocation.width + height = w.allocation.height + pixbuf = pixbuf.scale(width, height) + d.window.draw_pixbuf(gc, pixbuf, 0, 0, 0, 0, + width, height, Gdk::RGB::DITHER_NORMAL, 0, 0) + end + true +end +w.add(d) +w.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/togglebutton.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/togglebutton.rb new file mode 100644 index 0000000..187cc1b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/togglebutton.rb @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby +=begin + togglebutton.rb - Ruby/GTK sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: togglebutton.rb,v 1.10 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("Gtk::ToggleButton sample") +window.border_width = 10 + +box = Gtk::VBox.new(false, 10) +window.add(box) + +button1 = Gtk::ToggleButton.new("_button1") +button2 = Gtk::ToggleButton.new("_button2", false) +button3 = Gtk::ToggleButton.new(Gtk::Stock::QUIT) +box.add(button1).add(button2).add(button3) + +box.pack_start(Gtk::HSeparator.new) + +close = Gtk::Button.new("close") +close.signal_connect("clicked") do + Gtk.main_quit +end +box.add(close) + +window.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/toolbar.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/toolbar.rb new file mode 100644 index 0000000..b70a055 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/toolbar.rb @@ -0,0 +1,55 @@ +#!/usr/bin/env ruby +=begin + toolbar.rb - Ruby/GTK2 sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: toolbar.rb,v 1.11 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("Gtk::Toolbar sample") + +window.signal_connect("destroy") do + Gtk.main_quit +end + +toolbar = Gtk::Toolbar.new + +toolbar.append("Horizontal", "Horizontal toolbar layout", "Toolbar/Horizontal", + Gtk::Image.new("test.xpm")) do + toolbar.orientation = Gtk::ORIENTATION_HORIZONTAL +end +toolbar.append("Vertical", "Vertical toolbar layout", "Toolbar/Vertical", + Gtk::Image.new("test.xpm")) do + toolbar.orientation = Gtk::ORIENTATION_VERTICAL +end +toolbar.append_space +toolbar.append("Icons", "Only show toolbar icons", "Toolbar/IconsOnly", + Gtk::Image.new("test.xpm")) do + toolbar.toolbar_style = Gtk::Toolbar::ICONS +end +toolbar.append("Text", "Only show toolbar text", "Toolbar/TextOnly", + Gtk::Image.new("test.xpm")) do + toolbar.toolbar_style = Gtk::Toolbar::TEXT +end +toolbar.append("Both", "Show toolbar icons and text", "Toolbar/Both", + Gtk::Image.new("test.xpm")) do + toolbar.toolbar_style = Gtk::Toolbar::BOTH +end +toolbar.append_space +toolbar.append("Enable", "Enable tooltips",nil, + Gtk::Image.new("test.xpm")) do + toolbar.tooltips = true +end +toolbar.append("Disable", "Disable tooltips",nil, + Gtk::Image.new("test.xpm")) do + toolbar.tooltips = false +end + +window.add(toolbar) +window.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/tooltips.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/tooltips.rb new file mode 100644 index 0000000..a317465 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/tooltips.rb @@ -0,0 +1,204 @@ +#!/usr/bin/env ruby +=begin + tooltips.rb - Demonstrates the new tooltip API of Gtk+ 2.12; + rg2 translation from gtk/tests/testtooltips.c. + + Copyright (c) 2007 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: tooltips.rb,v 1.1 2007/07/10 13:17:34 ggc Exp $ +=end + +require 'gtk2' + +if str = Gtk.check_version(2, 12, 0) + puts "This sample requires GTK+ 2.12.0 or later" + puts str + exit +end + +def treeview_query_tooltip(treeview, keyboard_tip, x, y, tooltip) + if keyboard_tip + # Keyboard mode + path, = treeview.cursor + if not path + return false + end + else + bin_x, bin_y = treeview.convert_widget_to_bin_window_coords(x, y) + # Mouse mode + path, = treeview.get_path_at_pos(bin_x, bin_y) + if not path + return false + end + end + data = treeview.model.get_value(treeview.model.get_iter(path), 0) + tooltip.markup = "<b>Path #{path}:</b> #{data}" + return true +end + +def textview_query_tooltip(textview, keyboard_tip, x, y, tooltip, tag) + if keyboard_tip + iter = textview.buffer.get_iter_at_offset(textview.buffer.cursor_position) + else + bx, by = textview.window_to_buffer_coords(Gtk::TextView::WINDOW_TEXT, x, y) + iter, = textview.get_iter_at_position(bx, by) + end + if iter.has_tag?(tag) + tooltip.text = 'Tooltip on text tag' + return true + else + return false + end +end + +def drawingarea_query_tooltip(keyboard_tip, x, y, tooltip, rectangles) + if keyboard_tip + return false + end + for r in rectangles + if r.x < x && x < r.x + 50 && r.y < y && y < r.y + 50 + tooltip.markup = r.tooltip + return true + end + end + return false +end + +Gtk.init + +window = Gtk::Window.new(Gtk::Window::TOPLEVEL) +window.title = 'Tooltips test' +window.border_width = 10 +window.signal_connect('delete-event') { Gtk.main_quit } + +box = Gtk::VBox.new(false, 3) +window.add(box) + +# A check button using the tooltip-markup property +button = Gtk::CheckButton.new('This one uses the tooltip-markup property') +button.tooltip_text = 'Hello, I am a static tooltip.' +box.pack_start(button, false, false, 0) + +raise if button.tooltip_text != 'Hello, I am a static tooltip.' +raise if button.tooltip_markup != 'Hello, I am a static tooltip.' + +# A check button using the query-tooltip signal +button = Gtk::CheckButton.new('I use the query-tooltip signal') +button.has_tooltip = true +button.signal_connect('query-tooltip') { |widget, x, y, keyboard_tip, tooltip| + tooltip.markup = widget.label + tooltip.set_icon_from_stock(Gtk::Stock::DELETE, Gtk::IconSize::MENU) + true +} +box.pack_start(button, false, false, 0) + +# A label +label = Gtk::Label.new('I am just a label') +label.selectable = false +label.tooltip_text = 'Label & and tooltip' +box.pack_start(label, false, false, 0) + +raise if label.tooltip_text != "Label & and tooltip" +raise if label.tooltip_markup != "Label & and tooltip" + +# A selectable label +label = Gtk::Label.new('I am a selectable label') +label.selectable = true +label.tooltip_markup = '<b>Another</b> Label tooltip' +box.pack_start(label, false, false, 0) + +raise if label.tooltip_text != 'Another Label tooltip' +raise if label.tooltip_markup != '<b>Another</b> Label tooltip' + +# Another one, with a custom tooltip window +button = Gtk::CheckButton.new('This one has a custom tooltip window!') +box.pack_start(button, false, false, 0) + +tooltip_window = Gtk::Window.new(Gtk::Window::POPUP) +tooltip_button = Gtk::Label.new('blaat!') +tooltip_window.add(tooltip_button) +tooltip_button.show + +button.tooltip_window = tooltip_window +button.signal_connect('query-tooltip') { |widget, x, y, keyboard_tip, tooltip| + widget.tooltip_window.modify_bg(Gtk::StateType::NORMAL, Gdk::Color.new(0, 65535, 0)) + true +} +button.has_tooltip = true + +# An insensitive button +button = Gtk::Button.new('This one is insensitive') +button.sensitive = false +button.tooltip_text = 'Insensitive!' +box.pack_start(button, false, false, 0) + +# Tree view +store = Gtk::TreeStore.new(String) +iter = store.insert(nil, 0, ['File Manager']) +iter = store.insert(nil, 0, ['Gossip']) +iter = store.insert(nil, 0, ['System Settings']) +iter = store.insert(nil, 0, ['The GIMP']) +iter = store.insert(nil, 0, ['Terminal']) +iter = store.insert(nil, 0, ['Word Processor']) +treeview = Gtk::TreeView.new(store) +treeview.set_size_request(200, 240) +treeview.append_column(Gtk::TreeViewColumn.new('Test', Gtk::CellRendererText.new, { :text => 0 })) +treeview.has_tooltip = true +treeview.signal_connect('query-tooltip') { |widget, x, y, keyboard_tip, tooltip| + treeview_query_tooltip(widget, keyboard_tip, x, y, tooltip) +} +treeview.selection.signal_connect('changed') { treeview.trigger_tooltip_query } +# Set a tooltip on the column +column = treeview.get_column(0) +column.clickable = true +#column.button.tooltip_text = 'Header' .button not available +box.pack_start(treeview, false, false, 2) + +# Text view +buffer = Gtk::TextBuffer.new +buffer.insert(buffer.end_iter, 'Hello, the text ') +tag = buffer.create_tag('bold', { 'weight' => Pango::WEIGHT_BOLD }) +buffer.insert(buffer.end_iter, 'in bold', tag) +buffer.insert(buffer.end_iter, ' has a tooltip!') +textview = Gtk::TextView.new(buffer) +textview.set_size_request(200, 50) +textview.has_tooltip = true +textview.signal_connect('query-tooltip') { |widget, x, y, keyboard_tip, tooltip| + textview_query_tooltip(widget, keyboard_tip, x, y, tooltip, tag) +} +box.pack_start(textview, false, false, 2) + +# Drawing area +if Gdk.cairo_available? + Rectangle = Struct.new("Rectangle", :x, :y, :r, :g, :b, :tooltip) + rectangles = [ Rectangle.new(10, 10, 0.0, 0.0, 0.9, "Blue box!"), + Rectangle.new(200, 170, 1.0, 0.0, 0.0, "Red thing"), + Rectangle.new(100, 50, 0.8, 0.8, 0.0, "Yellow thing") ] + drawingarea = Gtk::DrawingArea.new + drawingarea.set_size_request(320, 240) + drawingarea.has_tooltip = true + drawingarea.signal_connect('expose_event') { + cr = drawingarea.window.create_cairo_context + cr.rectangle(0, 0, drawingarea.allocation.width, drawingarea.allocation.height) + cr.set_source_rgb(1.0, 1.0, 1.0) + cr.fill + rectangles.each { |r| + cr.rectangle(r.x, r.y, 50, 50) + cr.set_source_rgb(r.r, r.g, r.b) + cr.stroke + cr.rectangle(r.x, r.y, 50, 50) + cr.set_source_rgba(r.r, r.g, r.b, 0.5) + cr.fill + } + } + drawingarea.signal_connect('query-tooltip') { |widget, x, y, keyboard_tip, tooltip| + drawingarea_query_tooltip(keyboard_tip, x, y, tooltip, rectangles) + } + box.pack_start(drawingarea, false, false, 2) +else + warn "Part of this sample needs Cairo support. Make sure your ruby-gtk2 is compiled with Cairo support, and rcairo is installed." +end + +window.show_all +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/tree_combo.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/tree_combo.rb new file mode 100644 index 0000000..d4d0128 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/tree_combo.rb @@ -0,0 +1,85 @@ +=begin + tree_combo.rb - Gtk::TreeView and Gtk::CellRendererCombo + sample script. + + Copyright (C) 2006 Masao Mutoh + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: tree_combo.rb,v 1.3 2006/06/17 13:18:12 mutoh Exp $ +=end + + +require 'gtk2' + +if str = Gtk.check_version(2, 6, 0) + puts "This sample requires GTK+ 2.6.0 or later" + puts str + exit +end + +T_APPLICATION = 0 +T_COMBO_TEXT_COLUMN = 1 +T_COMBO_MODEL = 2 +T_COMBO_HAS_ENTRY = 3 +T_COMBO_EDITABLE = 4 +T_COMBO_TEXT = 5 + +# The COMPUTER combo model +combo_model = Gtk::ListStore.new(String) + +["Ruby", "Perl", "Python", "Java"].each do |v| + iter = combo_model.append + iter[0] = v +end + + +# The table model. +model = Gtk::ListStore.new(String, # T_APPLICATION + Integer, # T_COMBO_TEXT_COLUMN + Gtk::ListStore, # T_COMBO_MODEL + TrueClass, # T_COMBO_HAS_ENTRY + TrueClass, # T_COMBO_EDITABLE + String) # T_COMBO_TEXT + +view = Gtk::TreeView.new(model) + +# 1st column(Text) +trenderer = Gtk::CellRendererText.new +tcol = Gtk::TreeViewColumn.new("Application", trenderer, + :text => T_APPLICATION) +view.append_column(tcol) + +# 2nd column(Combo) +crenderer = Gtk::CellRendererCombo.new +crenderer.signal_connect("edited") do |renderer, path, text| + model.get_iter(path)[T_COMBO_TEXT] = text +end + +ccol = Gtk::TreeViewColumn.new("Language", crenderer, + :text_column => T_COMBO_TEXT_COLUMN, + :model => T_COMBO_MODEL, + :has_entry => T_COMBO_HAS_ENTRY, + :editable => T_COMBO_EDITABLE, + :text => T_COMBO_TEXT) +view.append_column(ccol) + + +# Create rows. +(1..2).each do |v| + iter = model.append + iter[T_APPLICATION] = "application #{v}" + iter[T_COMBO_MODEL] = combo_model + iter[T_COMBO_HAS_ENTRY] = false + iter[T_COMBO_EDITABLE] = true + iter[T_COMBO_TEXT] = combo_model.get_iter("0")[0] +end + +win = Gtk::Window.new +win.signal_connect("delete_event"){ + Gtk.main_quit +} + +win.add(view).show_all + +Gtk.main + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/tree_progress.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/tree_progress.rb new file mode 100644 index 0000000..f4e8175 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/tree_progress.rb @@ -0,0 +1,69 @@ +=begin + tree_progress.rb - Gtk::TreeView and Gtk::CellRendererProgress + sample script. + + Copyright (C) 2004-2006 Darren Willis, Masao Mutoh + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: tree_progress.rb,v 1.3 2006/06/17 13:18:12 mutoh Exp $ +=end + + +require 'gtk2' + +if str = Gtk.check_version(2, 6, 0) + puts "This sample requires GTK+ 2.6.0 or later" + puts str + exit +end + +win = Gtk::Window.new("Gtk::CellRendererProgress sample") +win.set_default_size(300, 50) +model = Gtk::ListStore.new(String, Float) +view = Gtk::TreeView.new(model) + +prog = model.append +prog[0] = "bar 1" +prog[1] = 50 + +prog1 = model.append +prog1[0] = "bar 2" +prog1[1] = 5 + +prog2 = model.append +prog2[0] = "bar 3" +prog2[1] = 10 + +arenderer = Gtk::CellRendererText.new +acol = Gtk::TreeViewColumn.new("words", arenderer, :text => 0) +view.append_column(acol) + +prenderer = Gtk::CellRendererProgress.new +pcol = Gtk::TreeViewColumn.new("Progress", prenderer, :value => 1) +view.append_column(pcol) + +win.signal_connect("delete_event"){ + Gtk.main_quit +} + +win.add(view) +win.show_all + +dir = 1 +thr = Thread.new do + loop { + prog2[1] += dir + if prog2[1] > 100 + prog2[1] = 100 + dir = - dir + end + if prog2[1] < 0 + prog2[1] = 0 + dir = - dir + end + sleep 0.01 + } +end + +Gtk.main + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/treemodelfilter.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/treemodelfilter.rb new file mode 100644 index 0000000..5ad3bca --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/treemodelfilter.rb @@ -0,0 +1,55 @@ +#!/usr/bin/env ruby +=begin + treemodelfilter.rb - Gtk::TreeModelFilter sample + + Copyright (c) 2004,2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: treemodelfilter.rb,v 1.3 2006/06/17 13:18:12 mutoh Exp $ +=end +require 'gtk2' + +if str = Gtk.check_version(2, 4, 0) + puts "This sample requires GTK+ 2.4.0 or later" + puts str + exit +end + +ls = Gtk::ListStore.new(String, Integer) + +column1 = Gtk::TreeViewColumn.new("data1", + Gtk::CellRendererText.new, {:text => 0}) +column2 = Gtk::TreeViewColumn.new("data2", + Gtk::CellRendererText.new, {:text => 1}) + +mf = Gtk::TreeModelFilter.new(ls) +mf.set_visible_func do |model, iter| + /a/ =~ iter[0] +end + +mf.set_modify_func(String, String) do |model, iter, column| + child_iter = model.convert_iter_to_child_iter(iter) + if column == 0 + child_iter[0] + else + "#{child_iter[1]} * 2 = #{child_iter[1] * 2}" + end +end + +treeview = Gtk::TreeView.new(mf) +treeview.append_column(column1) +treeview.append_column(column2) + +[ + ["aaa", 1], ["aab", 2], ["aac", 3], + ["bba", 4], ["bbb", 5], ["bbc", 6] +].each do |str, num| + iter = ls.append + iter[0] = str + iter[1] = num +end + +win = Gtk::Window.new("Gtk::TreeModelFilter sample") +win.signal_connect("destroy"){Gtk.main_quit} +win.add(treeview).show_all.signal_connect("destroy"){Gtk.main_quit} +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/treeview.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/treeview.rb new file mode 100644 index 0000000..de0257c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/treeview.rb @@ -0,0 +1,71 @@ +#!/usr/bin/env ruby +=begin + treeview.rb - Gtk::TreeView sample + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: treeview.rb,v 1.8 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("Gtk::TreeView sample") + +# Create data +model = Gtk::TreeStore.new(String, String, Gdk::Color, Float, Gdk::Pixbuf) + +# column 1 +root_iter = model.append(nil) +root_iter[0] = "Root" +root_iter[1] = "red" +root_iter[2] = Gdk::Color.new(0, 65535, 0) +root_iter[3] = 5.0 + +# column 2 +root_iter[4] = window.render_icon(Gtk::Stock::NEW, Gtk::IconSize::DIALOG, "icon1") + +child_iter1 = model.append(root_iter) +child_iter1[0] = "Child_Iter1" +child_iter1[1] = "green" +child_iter1[2] = Gdk::Color.new(65535, 0, 0) +child_iter1[3] = 3.0 + +# column 2 +child_iter1[4] = window.render_icon(Gtk::Stock::OPEN, Gtk::IconSize::MENU, "icon2") + +child_iter2 = model.append(root_iter) +child_iter2[0] = "Child_Iter2" +child_iter2[1] = "yellow" +child_iter2[2] = Gdk::Color.new(0, 0, 65535) +child_iter2[3] = 0.9 + +# column 2 +child_iter2[4] = window.render_icon(Gtk::Stock::QUIT, Gtk::IconSize::BUTTON, "icon3") + + +# Create view +tv = Gtk::TreeView.new(model) + +# column 1 +renderer = Gtk::CellRendererText.new +column = Gtk::TreeViewColumn.new("Gtk::CellRenderText", renderer, { + :text => 0, + :background => 1, + :foreground_gdk => 2, + :scale => 3, + }) +tv.append_column(column) + +# column 2 +renderer = Gtk::CellRendererPixbuf.new +column = Gtk::TreeViewColumn.new("Gtk::CellRenderPixbuf", renderer, { + :pixbuf => 4 + }) + +tv.append_column(column) + +window.add(tv).set_default_size(300, 300).show_all +window.signal_connect("destroy"){Gtk.main_quit} + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/uimanager.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/uimanager.rb new file mode 100644 index 0000000..1aeb779 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/uimanager.rb @@ -0,0 +1,148 @@ +=begin + uimanager.rb - + + Copyright (C) 2004-2006 Masao Mutoh + + Original version is demos/gtk-demo/ui_manager.c. + + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: uimanager.rb,v 1.6 2007/07/12 14:53:09 ggc Exp $ +=end + +require 'gtk2' + +if str = Gtk.check_version(2, 4, 0) + puts "This sample requires GTK+ 2.4.0 or later" + puts str + exit +end + +if not Gtk.check_version(2, 12, 0) + recentmenuitem = "<menuitem name='recent' action='recent'/>" +else + recentmenuitem = "" +end + +ui_info = %Q[ +<ui> + <menubar name='MenuBar'> + <menu action='FileMenu'> + <menuitem action='New'/> + <menuitem action='Open'/> + #{recentmenuitem} + <menuitem action='Save'/> + <menuitem action='SaveAs'/> + <separator/> + <menuitem action='Quit'/> + </menu> + <menu action='PreferencesMenu'> + <menu action='ColorMenu'> + <menuitem action='Red'/> + <menuitem action='Green'/> + <menuitem action='Blue'/> + </menu> + <menu action='ShapeMenu'> + <menuitem action='Square'/> + <menuitem action='Rectangle'/> + <menuitem action='Oval'/> + </menu> + <menuitem action='Bold'/> + </menu> + <menu action='HelpMenu'> + <menuitem action='About'/> + </menu> + </menubar> + <toolbar name='ToolBar'> + <toolitem action='Open'/> + <toolitem action='Quit'/> + <separator action='Sep1'/> + <toolitem action='Logo'/> + </toolbar> +</ui>] + +callback = Proc.new {|actiongroup, action| + puts "`#{action.name}' is clicked. " + if action.is_a? Gtk::ToggleAction + puts "active? = #{action.active?}" + end +} + +callback_quit = Proc.new { + p "Quit is called." + Gtk.main_quit +} + +callback_radio = Proc.new {|action, current| + puts "action = `#{action.name}'" + puts "current = `#{current.name}'" +} + +actions = [ + ["FileMenu", nil, "_File"], + ["PreferencesMenu", nil, "_Preferences"], + ["ColorMenu", nil, "_Color"], + ["ShapeMenu", nil, "_Shape"], + ["HelpMenu", nil, "_Help"], + ["New", Gtk::Stock::NEW, "_New", "<control>N", "Create a new file", callback], + ["Open", Gtk::Stock::OPEN, "_Open", "<control>O", "Open a file", callback], + ["Save", Gtk::Stock::SAVE, "_Save", "<control>S", "Save current file", callback], + ["SaveAs", Gtk::Stock::SAVE, "Save _As...", nil, "Save to a file", callback], + ["Quit", Gtk::Stock::QUIT, "_Quit", "<control>Q", "Quit", callback_quit], + ["About", nil, "_About", "<control>A", "About", callback], + ["Logo", "demo-gtk-logo", nil, nil, "GTK+", callback] +] + +toggle_actions = [ + ["Bold", Gtk::Stock::BOLD, "_Bold", "<control>B", "Bold", callback, true] +] + +color_radio_actions = [ + ["Red", nil, "_Red", "<control>R", "Blood", 0], + ["Green", nil, "_Green", "<control>G", "Grass", 1], + ["Blue", nil, "_Blue", "<control>B", "Sky", 2] +] + +shape_radio_actions = [ + ["Square", nil, "_Square", "<control>S", "Square", 0], + ["Rectangle", nil, "_Rectangle", "<control>R", "Rectangle", 1], + ["Oval", nil, "_Oval", "<control>O", "Egg", 2] +] + +window = Gtk::Window.new("Gtk::UIManager sample") + +actiongroup = Gtk::ActionGroup.new("Actions") +actiongroup.add_actions(actions) +actiongroup.add_toggle_actions(toggle_actions) +actiongroup.add_radio_actions(color_radio_actions, 1) do |action, current| + puts "action = `#{action.name}'" + puts "current = `#{current.name}'" +end +actiongroup.add_radio_actions(shape_radio_actions, 2, callback_radio) + +if not Gtk.check_version(2, 12, 0) + action = Gtk::RecentAction.new('recent', 'Open Recent', nil, 'gtk-open') + [ 'item-activated', 'activate' ].each { |signal| + action.signal_connect(signal) { |action| + puts "`Recent' #{signal}, uri=#{action.current_uri || 'no item selected'}" + } + } + actiongroup.add_action(action) +end + +uimanager = Gtk::UIManager.new +uimanager.insert_action_group(actiongroup, 0) +window.add_accel_group(uimanager.accel_group) + +uimanager.add_ui(ui_info) + +vbox = Gtk::VBox.new +vbox.pack_start(uimanager["/MenuBar"], false, false) +vbox.pack_start(Gtk::Label.new("Gtk::UIManager Sample")) +window.add(vbox) +window.set_default_size(100, 100).show_all + +window.signal_connect("destroy"){Gtk.main_quit} + +Gtk.main + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/uimanager2.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/uimanager2.rb new file mode 100644 index 0000000..fcf018d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/uimanager2.rb @@ -0,0 +1,91 @@ +=begin + uimanager2.rb - + + Copyright (C) 2004-2006 Masao Mutoh + + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: uimanager2.rb,v 1.5 2006/06/17 13:18:12 mutoh Exp $ +=end +require 'gtk2' + +if str = Gtk.check_version(2, 4, 0) + puts "This sample requires GTK+ 2.4.0 or later" + puts str + exit +end + +callback = Proc.new {|actiongroup, action| + puts "`#{action.name}' is clicked. " + if action.is_a? Gtk::ToggleAction + puts "active? = #{action.active?}" + end +} + +callback_quit = Proc.new { + p "Quit is called." + Gtk.main_quit +} + +callback_radio = Proc.new {|action, current| + puts "action = `#{action.name}'" + puts "current = `#{current.name}'" +} + +actions = [ + ["FileMenu", nil, "_File"], + ["PreferencesMenu", nil, "_Preferences"], + ["ColorMenu", nil, "_Color"], + ["ShapeMenu", nil, "_Shape"], + ["HelpMenu", nil, "_Help"], + ["New", Gtk::Stock::NEW, "_New", "<control>N", "Create a new file", callback], + ["Open", Gtk::Stock::OPEN, "_Open", "<control>O", "Open a file", callback], + ["Save", Gtk::Stock::SAVE, "_Save", "<control>S", "Save current file", callback], + ["SaveAs", Gtk::Stock::SAVE, "Save _As...", nil, "Save to a file", callback], + ["Quit", Gtk::Stock::QUIT, "_Quit", "<control>Q", "Quit", callback_quit], + ["About", nil, "_About", "<control>A", "About", callback], + ["Logo", "demo-gtk-logo", nil, nil, "GTK+", callback] +] + +toggle_actions = [ + ["Bold", Gtk::Stock::BOLD, "_Bold", "<control>B", "Bold", callback, true] +] + +color_radio_actions = [ + ["Red", nil, "_Red", "<control>R", "Blood", 0], + ["Green", nil, "_Green", "<control>G", "Grass", 1], + ["Blue", nil, "_Blue", "<control>B", "Sky", 2] +] + +shape_radio_actions = [ + ["Square", nil, "_Square", "<control>S", "Square", 0], + ["Rectangle", nil, "_Rectangle", "<control>R", "Rectangle", 1], + ["Oval", nil, "_Oval", "<control>O", "Egg", 2] +] + +window = Gtk::Window.new("Gtk::UIManager sample2") +window.signal_connect("destroy"){Gtk.main_quit} + +actiongroup = Gtk::ActionGroup.new("Actions") +actiongroup.add_actions(actions) +actiongroup.add_toggle_actions(toggle_actions) +actiongroup.add_radio_actions(color_radio_actions, 1) do |action, current| + puts "action = `#{action.name}'" + puts "current = `#{current.name}'" +end +actiongroup.add_radio_actions(shape_radio_actions, 2, callback_radio) + +uimanager = Gtk::UIManager.new +uimanager.insert_action_group(actiongroup, 0) +window.add_accel_group(uimanager.accel_group) + +uimanager.add_ui("./uimanager2.xml") + +vbox = Gtk::VBox.new +vbox.pack_start(uimanager["/MenuBar"], false, false) +vbox.pack_start(Gtk::Label.new("Gtk::UIManager Sample")) +window.add(vbox) +window.set_default_size(100, 100).show_all + +Gtk.main + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/uimanager2.xml b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/uimanager2.xml new file mode 100644 index 0000000..6bed773 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/uimanager2.xml @@ -0,0 +1,36 @@ +<?xml version="1.0"?> +<ui> + <menubar name='MenuBar'> + <menu action='FileMenu'> + <menuitem action='New'/> + <menuitem action='Open'/> + <menuitem action='Save'/> + <menuitem action='SaveAs'/> + <separator/> + <menuitem action='Quit'/> + </menu> + <menu action='PreferencesMenu'> + <menu action='ColorMenu'> + <menuitem action='Red'/> + <menuitem action='Green'/> + <menuitem action='Blue'/> + </menu> + <menu action='ShapeMenu'> + <menuitem action='Square'/> + <menuitem action='Rectangle'/> + <menuitem action='Oval'/> + </menu> + <menuitem action='Bold'/> + </menu> + <menu action='HelpMenu'> + <menuitem action='About'/> + </menu> + </menubar> + <toolbar name='ToolBar'> + <toolitem action='Open'/> + <toolitem action='Quit'/> + <separator action='Sep1'/> + <toolitem action='Logo'/> + </toolbar> +</ui> + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/window.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/window.rb new file mode 100644 index 0000000..7171e8c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/window.rb @@ -0,0 +1,24 @@ +#!/usr/bin/env ruby +=begin + window.rb - Gtk::Window sample. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: window.rb,v 1.9 2006/10/21 16:58:00 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("Gtk::Window sample") +window.signal_connect("destroy"){Gtk.main_quit} + +button = Gtk::Button.new("Hello World") +button.signal_connect("clicked") do + puts "hello world" + Gtk.main_quit +end +window.add(button) +window.show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/xbm_cursor.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/xbm_cursor.rb new file mode 100644 index 0000000..e1e3964 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/misc/xbm_cursor.rb @@ -0,0 +1,43 @@ +=begin + xbm_cursor.rb - Gdk::Cursor sample script. + + Copyright (C) 2001-2006 Masao Mutoh + This program is licenced under the same licence as Ruby-GNOME2. + + $Date: 2006/06/17 13:18:12 $ + $Id: xbm_cursor.rb,v 1.6 2006/06/17 13:18:12 mutoh Exp $ +=end + +require 'gtk2' + +cursor_bits = [ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xf0, 0x3f, 0x00, 0xe0, 0x78, 0x00, 0xe0, 0x70, 0x00, 0xe0, 0x70, 0x00, + 0xe0, 0x38, 0x00, 0xe0, 0x1f, 0x00, 0xe0, 0x1d, 0x00, 0xe0, 0x38, 0x00, + 0xe0, 0x78, 0x00, 0xe0, 0xf0, 0x00, 0xf0, 0xf3, 0x01, 0xf0, 0xe3, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00].pack("c*") + +cursor_mask_bits = [ + 0x63, 0x8e, 0x0f, 0x67, 0x8e, 0x0f, 0x06, 0xc6, 0x07, 0x04, 0x00, 0x00, + 0xf0, 0x3f, 0x08, 0xe7, 0x78, 0x0e, 0xe7, 0x70, 0x0f, 0xe4, 0x70, 0x03, + 0xe0, 0x38, 0x00, 0xe7, 0x1f, 0x0c, 0xe7, 0x1d, 0x0f, 0xe0, 0x38, 0x0e, + 0xe0, 0x78, 0x08, 0xe7, 0xf0, 0x00, 0xf7, 0xf3, 0x01, 0xf0, 0xe3, 0x01, + 0x04, 0x00, 0x00, 0x46, 0x24, 0x06, 0x67, 0x66, 0x0e, 0x67, 0x66, 0x0e].pack("c*") + +window = Gtk::Window.new("Gdk::Cursor sample") +window.signal_connect("destroy"){Gtk.main_quit} +window.realize + +source = Gdk::Pixmap.create_from_data(window.window, cursor_bits, 19, 19) +mask = Gdk::Pixmap.create_from_data(window.window, cursor_mask_bits, 19, 19) + +fg = Gdk::Color.new(65535, 0, 0) +bg = Gdk::Color.new(65535, 65535, 0) + +cursor = Gdk::Cursor.new(source, mask, fg, bg, 10, 10) + +window.window.set_cursor(cursor) +window.add(Gtk::Label.new("Put your cursor on this window.")) +window.set_default_size(200, 100).show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/3DRings.xpm b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/3DRings.xpm new file mode 100644 index 0000000..1ca75da --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/3DRings.xpm @@ -0,0 +1,116 @@ +/* XPM */ +static char * DRings_xpm[] = { +"48 48 65 1", +" c None", +". c #104010404103", +"X c #1040208130C2", +"o c #104014515144", +"O c #000010402081", +"+ c #1040104030C2", +"@ c #208120815144", +"# c #28A241035965", +"$ c #30C230C26185", +"% c #208130C24103", +"& c #104010402081", +"* c #104000002081", +"= c #000010401040", +"- c #492441036185", +"; c #596559659E79", +": c #30C220815144", +"> c #0820186128A2", +", c #000000001040", +"< c #2081104030C2", +"1 c #514459659658", +"2 c #514455556185", +"3 c #104000001040", +"4 c #000008200000", +"5 c #618569A6AEBA", +"6 c #618569A69658", +"7 c #410345148E38", +"8 c #104020814103", +"9 c #79E782079658", +"0 c #208120814103", +"q c #596571C69E79", +"w c #4103514471C6", +"e c #2081208130C2", +"r c #6185618571C6", +"t c #28A228A25965", +"y c #596561858617", +"u c #96589E79BEFB", +"i c #28A230C271C6", +"p c #38E345145144", +"a c #79E78207A699", +"s c #30C2492469A6", +"d c #410330C25965", +"f c #410351446185", +"g c #AEBAAAAAD75C", +"h c #38E338E34103", +"j c #EFBEEBADEFBE", +"k c #208130C25144", +"l c #9658A289DF7D", +"z c #208110404103", +"x c #28A228A26185", +"c c #8E388A28BEFB", +"v c #208118612081", +"b c #38E3451479E7", +"n c #4924618579E7", +"m c #86178617B6DA", +"M c #30C220814103", +"N c #104030C25144", +"B c #4103410371C6", +"V c #86178A28D75C", +"C c #DF7DDB6CE79D", +"Z c #BEFBC30BD75C", +"A c #410330C271C6", +"S c #30C228A230C2", +"D c #082008201861", +"F c #186130C238E3", +"G c #0000208130C2", +" .Xo ", +" O+O@#$% ", +" &*=+X-;: ", +" >&=,=<11#2 ", +" +O34,X567& ", +" 8X+=,90q9w. ", +" +e<>3r tyu-& ", +" Xi%.= paus+ ", +" Od-@= fga$h ", +" @y7X, Xrjak ", +" 2:eaw+ $ag;@ ", +" .X@8@k@o@X+ +pl9tO ", +" +zX@x$$isikt8o02crv ", +" 8@%ip7757ywbs$Ohn6#. ", +" &0%$p7r215ybw1pzp2-0= ", +" 8tk$#yw21665n;1+%-p$O ", +" O<e7pbryq5am9ay6XMpM>3& ", +" 9.NtpBw16amclVcm1t%kX*88 ", +" +&etd7r6y9ulgglm6>e>3s@83 ", +" +0k$y-y69cgCCCZVam%+#ik8X ", +" O&oi$d725amgCjCZu962ybtx8+p ", +" &X0x$sBym9VZCCCZca;yBbi%08& ", +" =++@sApMy5muZZgum6y2wds:>+& ", +" #tp;1;yB#i25cVucma5;w-pti@8& ", +" .#2alumnBp:@1r59y9y6ywBS$%0X+= ", +" %$wmZVu;#tX8X07r1656y2wbp$k@%@OD ", +" 0Byc9a;h%0>&D&hBrr2r1bwB-AF:0<&*= ", +" kBf;yr#@X+&<%MkhsBwBwpsB#Bktkt8+Oh ", +" xt7B-t8*,3O.X00:$i#dBd#bptFek0X.+* ", +" Xt#b#@=, =&O+X0Ft%ibsp$p$ki%l5sX&= ", +" &<kvX&4 +O*&<X0e:%$pAti%:edugn0= ", +" +X@&+, V,O&>+Xt>tktktv0%@k;Cls+ ", +" =+O*4*X:p;9cy3&&8ve0FMtt$ee0>z7cZ6k ", +" D=D4,=.k$sBs$ee=+X0Fk%-#t%0X&O0nu9bG ", +" ,,434*&ze@F<eeeeee><tdhdSMe<&&XAaawx ", +" 4,4,=+><peeeeee&=<%M%$hSF0X&O&kw5r%Z ", +" D&vSFMF<>&D =0S-2i& ", +" +>puB> >0h7s. ", +" SM5VqM &0t#$8 ", +" XpVV70 &0kMk. ", +" XdyB%z *X<%@+ ", +" &k$b0X+=8X08o ", +" &e:e+=*X.X+& ", +" +X.O+X0O.=, ", +" +>&+0>3&* ", +" &X0k+O, ", +" >v,3 ", +" "}; diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/FilesQueue.xpm b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/FilesQueue.xpm new file mode 100644 index 0000000..586d27e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/FilesQueue.xpm @@ -0,0 +1,98 @@ +/* XPM */ +static char * FilesQueue_xpm[] = { +"44 31 64 1", +" c None", +". c #E79DE38DDF7D", +"X c #CF3CC71BCF3C", +"o c #71C675D671C6", +"O c #B6DAB2CAB6DA", +"+ c #CF3CD34CCF3C", +"@ c #DF7DE38DE79D", +"# c #FFFFFBEEFFFF", +"$ c #EFBEEFBEEFBE", +"% c #DF7DDB6CDF7D", +"& c #BEFBBAEAC71B", +"* c #BEFBBAEABEFB", +"= c #BEFBC30BC71B", +"- c #71C66DB671C6", +"; c #D75CD34CD75C", +": c #9E799A699E79", +"> c #E79DE38DE79D", +", c #CF3CCB2BC71B", +"< c #B6DAB2CABEFB", +"1 c #BEFBBAEAB6DA", +"2 c #B6DAB6DAB6DA", +"3 c #618561856185", +"4 c #C71BBAEABEFB", +"5 c #AEBAAAAAAEBA", +"6 c #965892488E38", +"7 c #A699A699A699", +"8 c #38E338E338E3", +"9 c #F7DEF7DEF7DE", +"0 c #E79DEFBEEFBE", +"q c #DF7DE38DDF7D", +"w c #C71BC71BC71B", +"e c #C71BC30BBEFB", +"r c #BEFBC30BBEFB", +"t c #B6DAAAAAAEBA", +"y c #410345144103", +"u c #D75CDB6CD75C", +"i c #C71BCB2BC71B", +"p c #BEFBCB2BBEFB", +"a c #9E79A289A699", +"s c #86178E388E38", +"d c #CF3CCF3CD75C", +"f c #CF3CD75CCF3C", +"g c #C71BC30BCF3C", +"h c #28A22CB228A2", +"j c #000000000000", +"k c #D75CD34CDF7D", +"l c #10400C300820", +"z c #E79DEBADEFBE", +"x c #DF7DDB6CD75C", +"c c #514459655965", +"v c #8617861779E7", +"b c #DF7DD34CD75C", +"n c #CF3CCB2BCF3C", +"m c #618555555965", +"M c #861786178617", +"N c #30C234D330C2", +"B c #EFBEEBADE79D", +"V c #DF7DDB6CE79D", +"C c #D75CE38DD75C", +"Z c #514449245144", +"A c #186120812081", +"S c #79E77DF779E7", +"D c #6185659569A6", +"F c #9E7992489E79", +" .XoOX+ ", +" @#$%&*=-o;: ", +" @>,=O<12*&:-<3X ", +" >%&1*4*2*OO**56758790 ", +" 9qX+we=r*&e<<<251t5555yu9 ", +" $qu++;ipi=p*=p**2tOOO27a5s<- ", +" #9udfXi;,gi&**4**4r*Ot5t55tehj ", +" 0qku+u;+d,gg=*=r*&**&<255t<*yl1 ", +" $$zq@%xk%uf;,w,i=i=e**r=12tO1=8cvj ", +" $@%>.%.%%%xbkx,w+ni,wwrwe*4*1=;8mMNj ", +" zz@Bz>>>V%%%C+u;;dfnnfwggi&=&X+yZsNll ", +" af#9@B0>q>qqq>xk.;;;kfX+XnXw=g,fycMhhN5 ", +" al5#9$$>qzBV.%x%%b;x+fnf+,X,iiqym6NAo-j ", +" #roS%#$zz>>V%%xkk%f;;+df,XnwnVZD:8AS-j* ", +" D-9Oy*9$Bz>q%qx%%u;x;;dknX+d>Zm:hhSDjr ", +" a3o+>S3z#90@@z.%>qCC%uu;ff%@Zm:NhMoj= ", +" wlvvo#:3599$>B>q>%%%%+f;fk$ymaalMvjr ", +" 0.a--S49mct9$z@.qkkqC;xu%@Zm5AlvSj* ", +" ohu%3:Z:9@y609q@@>..>Cx>$Zm5NhMvjr ", +" -j797Zv5705y=#$0>>V.%>#Z378AMMj* ", +" Zj9Xo-McBXDv%90.%%#9cc78AsMj* ", +" 8hM#M-DSF96cvz0>z#c35Nhs6j1 ", +" jl9#o63vx#-D###mmt8N66j* ", +" 5jc@fZF3o%+ZFDm<8A6FjO ", +" :j50sSay<$ss2Nh:FjO ", +" 6880&SDMF.rNNFFj1 ", +" 8jr#:SFScA6ajO ", +" Alr$DSysajO ", +" >jy#51:jO ", +" %Dy*gjO ", +" alla "}; diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/Modeller.xpm b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/Modeller.xpm new file mode 100644 index 0000000..62e27f9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/Modeller.xpm @@ -0,0 +1,117 @@ +/* XPM */ +static char * InterfaceModeller_app_2_Tile_xpm[] = { +"48 48 66 1", +" c None", +". c #86174D344103", +"X c #69A651445144", +"o c #8617410330C2", +"O c #69A6410338E3", +"+ c #30C218611861", +"@ c #AEBA6DB66185", +"# c #71C638E328A2", +"$ c #69A634D328A2", +"% c #30C228A228A2", +"& c #79E73CF330C2", +"* c #BEFB9E799E79", +"= c #8E3869A66185", +"- c #514424921861", +"; c #A699A289B6DA", +": c #A6999E79A699", +"> c #71C65D756185", +", c #9E799A69A699", +"< c #8E3882078E38", +"1 c #861779E78617", +"2 c #A6999A69AEBA", +"3 c #8E388A289658", +"4 c #71C675D679E7", +"5 c #96588A289E79", +"6 c #30C230C238E3", +"7 c #C71BC71BC71B", +"8 c #9E79A289AEBA", +"9 c #AEBAAAAABEFB", +"0 c #96589248A699", +"q c #A699AAAAB6DA", +"w c #AEBAAAAAB6DA", +"e c #D75CD34CD75C", +"r c #EFBEE79DEFBE", +"t c #BEFBB6DABEFB", +"y c #B6DABAEAC71B", +"u c #AEBAAEBAB6DA", +"i c #E79DDB6CDF7D", +"p c #96588E389658", +"a c #596559656185", +"s c #AEBA8E388E38", +"d c #CF3CCB2BCF3C", +"f c #9E799A699E79", +"g c #86177DF78E38", +"h c #69A6659571C6", +"j c #AEBAAEBABEFB", +"k c #96589E799E79", +"l c #B6DAA699A699", +"z c #E79DC71BC71B", +"x c #B6DAB6DAB6DA", +"c c #861786179658", +"v c #B6DAB2CABEFB", +"b c #BEFBAAAAAEBA", +"n c #C71BBEFBC71B", +"m c #514441034103", +"M c #41033CF34103", +"N c #492428A228A2", +"B c #AEBAA289B6DA", +"V c #618530C22081", +"C c #69A630C228A2", +"Z c #69A630C22081", +"A c #596528A22081", +"S c #492428A22081", +"D c #618528A22081", +"F c #596520811861", +"G c #69A628A22081", +"H c #FFFF14514103", +" .X ", +" .oO+ ", +" @.o#++ ", +" @.o$%+ ", +" @.&#++ ", +" @.o#++ ", +" @.o$++ ", +" @.&#++ ", +" .O#++ ", +" *=-$++ ", +" ;:>+++ ", +" ;,<1% ", +" 2,34 ", +" 2;,51 ", +" 2,,,,6 ", +" 7777 28888,6 ", +" 77777777 2829,,,06 ", +" 9qwwe7rrrrr77rr 828,9tyt,6 ", +" uuwriirrieiiieii77pa< 82,8,,,8,06 ", +" s=1ttiieeeeded77eufgh>j,8,8,k,0,6 ", +" =@lzieeeeee77eeex:fpcg4>9,,,,qjv6 ", +" =O=blt7eeee7deenw:ffp<gha:t979;06 ", +" =OO@=@zieeee7ex:::fffff0,v72444h6 ", +" =OOo&Osst7iee7wkf:f:ff;t721444ham ", +" =#&&&&OO@di7eu:ff:fferiv114444hmMX ", +" =O&&&..o.sdp33fff:errrii7cc1hhh6mmNX= ", +" =O&&&@.o.@sberrrrrriiuxuxnB;44aMmVCO#OX ", +" =O&&o@..o.zrrrie777nnxtuxx:x;n:>mV##&&O$mX ", +" =O&&o....zrrieieuxunx7txx:nnfwpMmVZ#$ZZZVVN ", +" =O&oooo.*rrde77ewxnxxtnw:f4M%M%+NA#$Z$ZZVmN> ", +" =Oo&ooo@iree7inxn7nnuuff4h%M>m%S-AZ$CCZDZmSX ", +" =O&o.o.@rrn7eulun7xxuwp4mm6ahM%--AZCCZDDDANX ", +" =Ooooo.*rixenuwwn7nxupph%M>>h6mAADVVZVVDDANX ", +" =O&o.o.zrexwwnwuxxnughX%mahhmMN-AZCCVVDDAAN> ", +" *XOoo.*iin7n777xxxtphaM+ama>MSNFVCZZVVDAAAS> ", +" 1O..izewxux7nuuux4%++%hha>%N-DDCZZVDAAAASX ", +" 1.=ituu:uButnxxuX%>hh>M%++NADZZZVDADAA--X ", +" :e7f::lnn7*ppnx6ahm6++mNN-ADCZVDDAAAA-SX ", +" 7nupp:wxxg%MMau6%++NmmmADADVVVVVDAA---NX ", +" 7uBgh1wwxg6h>m%:MmmVNAVDZVZCVZZDAAAAF-S+X ", +" nfgaM%pnwhX6%mXb6$DVVZC$C#C$ZZDVAAA---+NX ", +" 27a%MaM47:mN.OoolmODGZ####$$ZZVDDA-----SSX ", +" 2gmg<m6p7wmmOo...O$GZ####$$CZVVDAAA----++X ", +" qBcaM <gxgmXmo.@.o&$$##$$$CZZZDADA-A-++-NX ", +" M6> paMa HX.@@@oZ$###$$CZVDDAAAA---SS+X ", +" 43 p=&@@&&$##$CCCVVVAAA--+S+S+%X ", +" k =o@.##$VVmmmNNNSSSSSS%XXXX ", +" s>OSSNmN>>aaa177777 "}; diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/README b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/README new file mode 100644 index 0000000..3b73366 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/README @@ -0,0 +1,14 @@ +ruby-testgtk - testgtk.c rewritten in Ruby/GTK + +To run, do + + ruby testgtk.rb + +in this directory. + +---- +(Maintainer from Ruby/GTK2) +Masao Mutoh <mutoh@highway.ne.jp> + +(Original Author of Ruby/GTK version) +Hiroshi Igarashi <igarashi@ueda.info.waseda.ac.jp> diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/button.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/button.rb new file mode 100644 index 0000000..5314d1b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/button.rb @@ -0,0 +1,133 @@ +=begin header + + button.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + Rewritten by Hiroshi IGARASHI <igarashi@ueda.info.waseda.ac.jp> + $Date: 2005/07/17 16:55:26 $ + $Id: button.rb,v 1.6 2005/07/17 16:55:26 mutoh Exp $ + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +require 'sample' + +class ButtonSample < SampleWindow + def initialize + super("buttons") + + box1 = Gtk::VBox.new(false, 0) + add(box1) + + table = Gtk::Table.new(3, 3, false) + table.row_spacings = 5 + table.column_spacings = 5 + table.border_width = 10 + box1.pack_start(table, true, true, 0) + + button = [ + Gtk::Button.new("button1"), + Gtk::Button.new("button2"), + Gtk::Button.new("button3"), + Gtk::Button.new("button4"), + Gtk::Button.new("button5"), + Gtk::Button.new("button6"), + Gtk::Button.new("button7"), + Gtk::Button.new("button8"), + Gtk::Button.new("button9"), + ] + + button[0].signal_connect("clicked") do + button_window(button[1]) + end + table.attach(button[0], 0, 1, 0, 1, + Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0) + + button[1].signal_connect("clicked") do + button_window(button[2]) + end + table.attach(button[1], 1, 2, 1, 2, + Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0) + + button[2].signal_connect("clicked") do + button_window(button[3]) + end + table.attach(button[2], 2, 3, 2, 3, + Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0) + + button[3].signal_connect("clicked") do + button_window(button[4]) + end + table.attach(button[3], 0, 1, 2, 3, + Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0) + + button[4].signal_connect("clicked") do + button_window(button[5]) + end + table.attach(button[4], 2, 3, 0, 1, + Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0) + + button[5].signal_connect("clicked") do + button_window(button[6]) + end + table.attach(button[5], 1, 2, 2, 3, + Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0) + + button[6].signal_connect("clicked") do + button_window(button[7]) + end + table.attach(button[6], 1, 2, 0, 1, + Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0) + + button[7].signal_connect("clicked") do + button_window(button[8]) + end + table.attach(button[7], 2, 3, 1, 2, + Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0) + + button[8].signal_connect("clicked") do + button_window(button[0]) + end + table.attach(button[8], 0, 1, 1, 2, + Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0) + + box1.pack_start(Gtk::HSeparator.new, false, true, 0) + + box2 = Gtk::VBox.new(false, 10) + box2.border_width = 10 + box1.pack_start(box2, false, true, 0) + + button[9] = Gtk::Button.new("close") + button[9].signal_connect("clicked") do destroy end + box2.add(button[9]) + end + + private + def button_window(button) + unless button.visible? + button.show + else + button.hide + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/buttonbox.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/buttonbox.rb new file mode 100644 index 0000000..458ef4e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/buttonbox.rb @@ -0,0 +1,108 @@ +=begin header + + buttonbox.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + $Id: buttonbox.rb,v 1.6 2005/07/17 16:55:26 mutoh Exp $ + + Rewritten by Minoru Inachi <inachi@earth.interq.or.jp> + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +require 'sample' + +class ButtonBoxSample < SampleWindow + def initialize + super("Button Boxes") + signal_connect("destroy"){destroy} + set_border_width(10) + + main_vbox = Gtk::VBox.new + add(main_vbox) + + frame_horz = Gtk::Frame.new("Horizontal Button Boxes") + main_vbox.pack_start(frame_horz, true, true, 10) + + vbox = Gtk::VBox.new + vbox.border_width = 10 + frame_horz.add(vbox) + + vbox.pack_start(create_bbox(true, "Spread", 40, + Gtk::ButtonBox::SPREAD)) + + vbox.pack_start(create_bbox(true, "Edge", 40, + Gtk::ButtonBox::EDGE), true, true, 5) + + vbox.pack_start(create_bbox(true, "Start", 40, + Gtk::ButtonBox::START), true, true, 5) + + vbox.pack_start(create_bbox(true, "End", 40, + Gtk::ButtonBox::END), true, true, 5) + + frame_vert = Gtk::Frame.new("Vertical Button Boxes") + main_vbox.pack_start(frame_vert, true, true, 10) + + hbox = Gtk::HBox.new + hbox.border_width = 10 + frame_vert.add(hbox) + + hbox.pack_start(create_bbox(false, "Spread", 30, + Gtk::ButtonBox::SPREAD)) + + hbox.pack_start(create_bbox(false, "Edge", 30, + Gtk::ButtonBox::EDGE), true, true, 5) + + hbox.pack_start(create_bbox(false, "Start", 30, + Gtk::ButtonBox::START), true, true, 5) + + hbox.pack_start(create_bbox(false, "End", 30, + Gtk::ButtonBox::END), true, true, 5) + end + + def create_bbox(horizontal, title, spacing, layout) + frame = Gtk::Frame.new(title) + + if horizontal then + bbox = Gtk::HButtonBox.new + else + bbox = Gtk::VButtonBox.new + end + + bbox.border_width = 5 + frame.add(bbox) + + bbox.set_layout_style(layout) + bbox.set_spacing(spacing) + + button = Gtk::Button.new("OK") + bbox.add(button) + + button = Gtk::Button.new("Cancel") + bbox.add(button) + + button = Gtk::Button.new("Help") + bbox.add(button) + + frame + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/check-n.xpm b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/check-n.xpm new file mode 100644 index 0000000..417ae20 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/check-n.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static char *openfile[] = { +/* width height num_colors chars_per_pixel */ +" 10 9 5 1", +/* colors */ +". c None", +"# c #000000", +"y c #666666", +"i c #ff1f00", +"# c #9f9f9f", +/* pixels */ +"..........", +"........yy", +".......yy.", +"......yy..", +".yyy.yy...", +"..yyyy....", +"...yy.....", +"..........", +"..........", +}; diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/check-y.xpm b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/check-y.xpm new file mode 100644 index 0000000..d82b485 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/check-y.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static char *openfile[] = { +/* width height num_colors chars_per_pixel */ +" 10 9 5 1", +/* colors */ +". c None", +"# c #000000", +"i c #ff0fff", +"y c #ff1f00", +"# c #9f9f9f", +/* pixels */ +"..........", +"........yy", +".......yy.", +"......yy..", +".yyy.yy...", +"..yyyy....", +"...yy.....", +"..........", +"..........", +}; diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/checkbutton.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/checkbutton.rb new file mode 100644 index 0000000..a966822 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/checkbutton.rb @@ -0,0 +1,67 @@ +=begin header + + checkbutton.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + $Id: checkbutton.rb,v 1.6 2005/07/17 16:55:26 mutoh Exp $ + + Rewritten by Hiroshi IGARASHI <igarashi@ueda.info.waseda.ac.jp> + $Date: 2005/07/17 16:55:26 $ + $Id: checkbutton.rb,v 1.6 2005/07/17 16:55:26 mutoh Exp $ + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +require 'sample' + +class CheckButtonSample < SampleWindow + def initialize + super("check buttons") + + box1 = Gtk::VBox.new + add(box1) + + box2 = Gtk::VBox.new(false, 10) + box2.border_width = 10 + box1.add(box2) + + button = Gtk::CheckButton.new("button1") + box2.add(button) + + button = Gtk::CheckButton.new("button2") + box2.add(button) + + button = Gtk::CheckButton.new("button3") + box2.add(button) + + box1.pack_start(Gtk::HSeparator.new) + + box2 = Gtk::VBox.new(false, 10) + box2.border_width = 10 + box1.add(box2) + + button = Gtk::Button.new("close") + button.signal_connect("clicked"){destroy} + + box2.add(button) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/circles.xbm b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/circles.xbm new file mode 100644 index 0000000..d82f655 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/circles.xbm @@ -0,0 +1,46 @@ +#define circles_width 64 +#define circles_height 64 +static unsigned char circles_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfc, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xff, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, + 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, + 0xff, 0xff, 0x01, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, + 0x00, 0xfe, 0xff, 0x01, 0xf0, 0xff, 0x0f, 0x00, 0x00, 0xff, 0x3f, 0x00, + 0x80, 0xff, 0x1f, 0x00, 0x80, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x3f, 0x00, + 0x80, 0xff, 0x03, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0xc0, 0xff, 0x01, 0x00, + 0x00, 0xf0, 0x7f, 0x00, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x00, + 0xf0, 0x3f, 0x00, 0x00, 0x00, 0x80, 0xff, 0x01, 0xf0, 0x1f, 0x00, 0x00, + 0x00, 0x00, 0xff, 0x01, 0xf8, 0x1f, 0x00, 0x20, 0x00, 0x00, 0xff, 0x03, + 0xf8, 0x0f, 0x00, 0xff, 0x07, 0x00, 0xfe, 0x03, 0xfc, 0x07, 0xc0, 0xff, + 0x1f, 0x00, 0xfc, 0x07, 0xfc, 0x07, 0xf0, 0xff, 0x7f, 0x00, 0xfc, 0x07, + 0xfc, 0x03, 0xf8, 0xff, 0xff, 0x00, 0xf8, 0x07, 0xfe, 0x03, 0xfc, 0xff, + 0xff, 0x01, 0xf8, 0x0f, 0xfe, 0x01, 0xfe, 0x8f, 0xff, 0x03, 0xf0, 0x0f, + 0xfe, 0x01, 0xfe, 0x01, 0xfc, 0x03, 0xf0, 0x0f, 0xff, 0x01, 0xff, 0x00, + 0xf8, 0x07, 0xf0, 0x1f, 0xff, 0x00, 0x7f, 0x00, 0xf0, 0x07, 0xe0, 0x1f, + 0xff, 0x80, 0x3f, 0x00, 0xe0, 0x0f, 0xe0, 0x1f, 0xff, 0x80, 0x1f, 0x00, + 0xc0, 0x0f, 0xe0, 0x1f, 0xff, 0x80, 0x1f, 0x00, 0xc0, 0x0f, 0xe0, 0x1f, + 0xff, 0x80, 0x1f, 0x00, 0xc0, 0x0f, 0xe0, 0x1f, 0xff, 0x80, 0x0f, 0x00, + 0x80, 0x0f, 0xe0, 0x1f, 0xff, 0xc0, 0x0f, 0x00, 0x80, 0x1f, 0xe0, 0x1f, + 0xff, 0x80, 0x0f, 0x00, 0x80, 0x0f, 0xe0, 0x1f, 0xff, 0x80, 0x1f, 0x00, + 0xc0, 0x0f, 0xe0, 0x1f, 0xff, 0x80, 0x1f, 0x00, 0xc0, 0x0f, 0xe0, 0x1f, + 0xff, 0x80, 0x1f, 0x00, 0xc0, 0x0f, 0xe0, 0x1f, 0xff, 0x81, 0x3f, 0x00, + 0xe0, 0x0f, 0xf0, 0x1f, 0xfe, 0x01, 0x7f, 0x00, 0xf0, 0x07, 0xf0, 0x0f, + 0xfe, 0x01, 0xff, 0x00, 0xf8, 0x07, 0xf0, 0x0f, 0xfe, 0x03, 0xfe, 0x01, + 0xfc, 0x03, 0xf8, 0x0f, 0xfc, 0x03, 0xfe, 0x8f, 0xff, 0x03, 0xf8, 0x07, + 0xfc, 0x07, 0xfc, 0xff, 0xff, 0x01, 0xfc, 0x07, 0xfc, 0x07, 0xf8, 0xff, + 0xff, 0x00, 0xfc, 0x07, 0xf8, 0x0f, 0xf0, 0xff, 0x7f, 0x00, 0xfe, 0x03, + 0xf8, 0x1f, 0xc0, 0xff, 0x1f, 0x00, 0xff, 0x03, 0xf0, 0x1f, 0x00, 0xff, + 0x07, 0x00, 0xff, 0x01, 0xf0, 0x3f, 0x00, 0x20, 0x00, 0x80, 0xff, 0x01, + 0xe0, 0x7f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x00, 0xc0, 0xff, 0x01, 0x00, + 0x00, 0xf0, 0x7f, 0x00, 0x80, 0xff, 0x03, 0x00, 0x00, 0xf8, 0x3f, 0x00, + 0x80, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0xff, 0x3f, 0x00, + 0x80, 0xff, 0x1f, 0x00, 0x00, 0xfe, 0xff, 0x01, 0xf0, 0xff, 0x0f, 0x00, + 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xf0, 0xff, 0xff, + 0xff, 0xff, 0x01, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, + 0x00, 0xc0, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x07, 0x00, 0x00, + 0x00, 0x00, 0xe0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/colorselect.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/colorselect.rb new file mode 100644 index 0000000..43cdee6 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/colorselect.rb @@ -0,0 +1,33 @@ +=begin + + colorselect.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project + $Id: colorselect.rb,v 1.5 2005/07/17 16:55:27 mutoh Exp $ +=end + +require 'sample' + +class ColorSelectionSample < Gtk::ColorSelectionDialog + include Sample + extend SampleClass + + def initialize + super("color selection dialog") + @destroyed = false + signal_connect("destroy"){destroy} + + colorsel.set_has_opacity_control(true) + set_window_position(Gtk::Window::POS_MOUSE) + + colorsel.signal_connect("color_changed"){ + colorsel.current_color + } + ok_button.signal_connect("clicked"){ + color = colorsel.current_color + colorsel.set_current_color(color) + } + cancel_button.signal_connect("clicked"){destroy} + end +end + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/dialog.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/dialog.rb new file mode 100644 index 0000000..6fe890f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/dialog.rb @@ -0,0 +1,47 @@ +=begin + + dialog.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + $Id: dialog.rb,v 1.6 2005/07/17 16:55:27 mutoh Exp $ + +=end + +require 'sample' + +class DialogSample < SampleDialog + + def initialize + super("Gtk::Dialog") + set_default_size(200, 100) + + button = Gtk::Button.new("OK") + button.can_default = true + + action_area.pack_start(button) + button.grab_default + + button = Gtk::Button.new("Toggle") + button.signal_connect("clicked"){label_toggle} + + button.can_default = true + action_area.pack_start(button) + + @label = nil + end + + private + def label_toggle + if @label == nil then + @label = Gtk::Label.new("Dialog Test") + @label.signal_connect("destroy"){@label = nil} + @label.set_padding(10, 10) + + vbox.pack_start(@label) + @label.show + else + @label.destroy + end + end + +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/entry.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/entry.rb new file mode 100644 index 0000000..99c24fe --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/entry.rb @@ -0,0 +1,73 @@ +=begin header + + entry.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + + $Id: entry.rb,v 1.6 2005/07/17 16:55:27 mutoh Exp $ + +=end + +require 'sample' + +class EntrySample < SampleWindow + def initialize + cbitems = [ + "item0", + "item1 item1", + "item2 item2 item2", + "item3 item3 item3 item3", + "item4 item4 item4 item4 item4", + "item5 item5 item5 item5 item5 item5", + "item6 item6 item6 item6 item6", + "item7 item7 item7 item7", + "item8 item8 item8", + "item9 item9" + ] + + super("entry") + + box = Gtk::VBox.new(false, 5) + add(box) + + entry = Gtk::Entry.new + entry.text = "hello world" + entry.select_region(0, 5) + box.add(entry) + + cb = Gtk::Combo.new + cb.set_popdown_strings(cbitems) + cb.entry.text = "hello world" + cb.entry.select_region(0, -1) + box.add(cb) + + editable_check = Gtk::CheckButton.new("Editable") + box.add(editable_check) + editable_check.signal_connect("toggled"){ + entry.editable = editable_check.active? + } + editable_check.active = true + + visible_check = Gtk::CheckButton.new("Visible") + box.add(visible_check) + visible_check.signal_connect("toggled"){ + entry.visibility = visible_check.active? + } + visible_check.active = true + + sensitive_check = Gtk::CheckButton.new("Sensitive") + box.add(sensitive_check) + sensitive_check.signal_connect("toggled"){ + entry.sensitive = sensitive_check.active? + } + sensitive_check.active = true + + box.pack_start(Gtk::HSeparator.new, false, true, 5) + + button = Gtk::Button.new("close") + button.signal_connect("clicked"){ destroy } + + box.add(button) + + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/filesel.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/filesel.rb new file mode 100644 index 0000000..027ed05 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/filesel.rb @@ -0,0 +1,67 @@ +=begin header + + filesel.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + $Id: filesel.rb,v 1.6 2005/07/17 16:55:27 mutoh Exp $ + + Rewritten by TAKAHASHI Hitoshi <thitoshi@ne.scphys.kyoto-u.ac.jp> + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +require 'sample' + +class FileSelectionSample < Gtk::FileSelection + include Sample + extend SampleClass + + def initialize + super("file selection dialog") + @destroyed = false + signal_connect("destroy") do destroy end + + set_window_position(Gtk::Window::POS_MOUSE) + hide_fileop_buttons + + ok_button.signal_connect("clicked") do + puts filename + destroy + end + cancel_button.signal_connect("clicked") do + destroy + end + + button = Gtk::Button.new("Hide Fileops") + button.signal_connect("clicked") do + hide_fileop_buttons + end + action_area.pack_start(button, false, false, 0) + + button = Gtk::Button.new("Show Fileops") + button.signal_connect("clicked") do + show_fileop_buttons + end + action_area.pack_start(button, false, false, 0) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/fontselection.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/fontselection.rb new file mode 100644 index 0000000..df7a323 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/fontselection.rb @@ -0,0 +1,56 @@ +=begin header + + fontselection.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + $Id: fontselection.rb,v 1.6 2005/07/17 16:55:27 mutoh Exp $ + + Rewritten by Neil Conway <neilconway@rogers.com> + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +require 'sample' + +class FontSelectionSample < Gtk::FontSelectionDialog + include Sample + extend SampleClass + + def initialize + super('Font Selection Dialog') + set_window_position(Gtk::Window::POS_MOUSE) + + signal_connect('destroy') { + destroy + } + + ok_button.signal_connect('clicked') { + puts font_name + destroy + } + + cancel_button.signal_connect('clicked') { + destroy + } + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/gammacurve.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/gammacurve.rb new file mode 100644 index 0000000..6139075 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/gammacurve.rb @@ -0,0 +1,70 @@ +=begin header + + gammacurve.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + $Id: gammacurve.rb,v 1.6 2005/07/17 16:55:27 mutoh Exp $ + + Rewritten by TAKAHASHI Hitoshi <thitoshi@ne.scphys.kyoto-u.ac.jp> + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +require 'sample' + +class GammaCurveSample < SampleWindow + include Math + + def initialize + super("Gtk::GammaCurve") + set_border_width(10) + + @curve = Gtk::GammaCurve.new + add(@curve) + @count = 0 + end + + def update + max = 127 + (@count % 2) * 128 + @curve.curve.set_range(0, max, 0, max) + vec = [] + max.times do |i| + vec[i] = (127 / sqrt(max)) * sqrt(i) + end + @curve.curve.set_vector(max, vec) + @count += 1 + end + + attr_reader :count + + def GammaCurveSample.invoke + @singleton = new if @singleton.nil? or @singleton.destroyed? + @singleton.update + unless @singleton.visible? + @singleton.show_all + end + if @singleton.count == 4 + @singleton.destroy + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/labels.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/labels.rb new file mode 100644 index 0000000..04f59e6 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/labels.rb @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +=begin header + + labels.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002,2003 Ruby-GNOME2 Project Team + + $Id: labels.rb,v 1.7 2005/07/17 16:55:27 mutoh Exp $ + +=end + +require 'sample' + +class LabelSample < SampleWindow + def initialize + super("Gtk::Label") + set_border_width(5) + + vbox = Gtk::VBox::new(false, 5) + hbox = Gtk::HBox::new(false, 5) + hbox.pack_start(vbox, false, false, 0) + + create_frame("Normal Label", + "This is a Normal label", + vbox) + create_frame("Multi-line Label", + "This is a Multi-line label.\nSecond line\nThird line", + vbox) + create_frame("Left Justified Label", + "This is a Left-Justified\nMulti-line label.\nThird line", + vbox) do |label| + label.justify = Gtk::JUSTIFY_LEFT + end + create_frame("Right Justified Label", + "This is a Right-Justified\nMulti-line label.\nFourth line, (j/k)", + vbox) do |label| + label.justify = Gtk::JUSTIFY_RIGHT + end + + vbox = Gtk::VBox::new(false, 5) + hbox.pack_start(vbox, false, false, 0) + + create_frame("Line wrapped label", + "This is an example of a line-wrapped label. It should not be taking up the entire width allocated to it, but automatically wraps the words to fit. The time has come, for all good men, to come to the aid of their party. The sixth sheik's six sheep's sick.\n It supports multiple paragraphs correctly, and correctly adds many extra spaces. ", + vbox) do |label| + label.wrap = true + end + create_frame("Filled, wrapped label", + "This is an example of a line-wrapped, filled label. It should be taking up the entire width allocated to it. Here is a seneance to prove my point. Here is another sentence. Here comes the sun, do de do de do.\n This is a new paragraph.\n This is another newer, longer, better paragraph. It is coming to an end, unfortunately.", + vbox) do |label| + label.justify = Gtk::JUSTIFY_FILL + label.wrap = true + end + create_frame("Underlined label", + "This label is underlined!\nThis one is underlined in 日本語の入用quite a funky fashion", + vbox) do |label| + label.justify = Gtk::JUSTIFY_LEFT + label.pattern = "_________________________ _ _________ _ _____ _ __ __ ___ ____ _____" + end + + add(hbox) + end + + def create_frame(title, label_str, vbox) + frame = Gtk::Frame::new(title) + frame.show + label = Gtk::Label::new(label_str) + yield(label) if iterator? + frame.add(label) + vbox.pack_start(frame, false, false, 0) + end + + private :create_frame +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/layout.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/layout.rb new file mode 100644 index 0000000..4b76650 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/layout.rb @@ -0,0 +1,108 @@ +=begin header + + layout.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + $Id: layout.rb,v 1.6 2005/07/17 16:55:27 mutoh Exp $ + + Rewritten by Minoru Inachi <inachi@earth.interq.or.jp> + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +require 'sample' + +class LayoutSample < SampleWindow + + def initialize + super("Gtk::Layout") + + set_default_size(200, 200) + + scrolledwindow = Gtk::ScrolledWindow.new + + add(scrolledwindow) + + @layout = Gtk::Layout.new(nil, nil) + scrolledwindow.add(@layout) + + # We set step sizes here since GtkLayout does not set + # them itself. + @layout.hadjustment.step_increment = 10.0 + @layout.vadjustment.step_increment = 10.0 + + @layout.set_events(Gdk::Event::EXPOSURE_MASK) + @layout.signal_connect("expose_event") do | w, event | + layout_expose_handler(event) + end + + @layout.set_size(1600, 128000) + + for i in 0..15 do + for j in 0..15 do + buf = "Button #{i}, #{j}" + if ((i + j) % 2) != 0 then + button = Gtk::Button.new(buf) + else + button = Gtk::Label.new(buf) + end + + @layout.put(button, j*100, i*100) + button.show + end + end + + for i in 16..1279 do + buf = "Button #{i}, 0" + if (i % 2) != 0 then + button = Gtk::Button.new(buf) + else + button = Gtk::Label.new(buf) + end + @layout.put(button, 0, i * 100) + end + end + + private + def layout_expose_handler(event) + imin = (event.area.x) / 10 + imax = (event.area.x + event.area.width + 9) / 10 + + jmin = (event.area.y) / 10 + jmax = (event.area.y + event.area.height + 9) / 10 + + for i in imin..imax-1 do + for j in jmin..jmax-1 do + if ((i+j) % 2) != 0 then + @layout.bin_window.draw_rectangle( + @layout.style.black_gc, + true, + 10 * i, 10 * j, + 1 + i % 10, 1 + j % 10) + end + end + end + false + end + +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/marble.xpm b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/marble.xpm new file mode 100644 index 0000000..1ef2607 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/marble.xpm @@ -0,0 +1,408 @@ +/* XPM */ +static char *granite07[] = { +/* width height num_colors chars_per_pixel */ +" 384 384 16 1", +/* colors */ +". c #000000", +"# c #111111", +"a c #222222", +"b c #333333", +"c c #444444", +"d c #555555", +"e c #666666", +"f c #777777", +"g c #888888", +"h c #999999", +"i c #aaaaaa", +"j c #bbbbbb", +"k c #cccccc", +"l c #dddddd", +"m c #eeeeee", +"n c #ffffff", +/* pixels */ +"aacfedbbcbbaaaaaaaaabaabaaaaabcbcbbbabbchfdcccbbabbbaaabaabcbaa#aa#######a#aaaabcddeefhec##dgbabbaaadabbcfbaa##########aaabbaaa#a#####a#aa###a#aaabbbbcbbbccdedaaaaa#aaaaa#a#abaaabbabbbeddbbaaaaaca##a#aaaba########aaaadcababbabdehd.##.a######.cgdcb###b##.##.##aaaaa####abcba######a##aac#a##a####aa#aa##babbbcfccbbbcdccccecbbbcbbbcdccddcbcdfeecbhhjihhgffc.aaa####.#######aaaaaaaabbaaaaa", +"aaacedccbbcbaaaaaa#bbaabbbaaaabcaabbbbbbafhfccbbbbbbabacbacbaaaaa##########a###abbcdeghhhcagb#ababaaccbacdfca#a####aa###aaaaabaaa#####aca#aabaababbcccccccbcdfdaaaa###aaaaaaaaaaabbbbbbccccccbbcbcaaa##aaaaabaaaa###abdaccceebaaaabehja####a######..#aeec#bb##########aa#####abba#########aaca########aa#aa###aaaabddbbbbbbbbbbccbbabbbbabbabbabcbcbcefhfeddccefhhijheecb#...a####aaaaaaaabaaaaa", +"aaabccccccdbabcbaaa#aaaaaaaaaaabbabbbbbccabefdccabcbbabacccbaaabaa######a######aaabceiiiihije#bbabbaaeaabcedcaabaa########aaaabaa##a###ab#aabcababbccccccdeeeecc#a##a##aaaaaaaaaabbbbbbbcccbbbdcbbcdaa#a#aabbaaaaa###acbaa#bccaa#abcfig.#######.#######acddgefdda#######a########a#######aaaaaa#a######aaaa#####aaacdcbabbaaabbbcaaaaaaaaabbbaaabbaabbbcbcbabbabcdeefghjkjgc#..####aaaaaaaaaaaa#", +"#aaaaaacbccbcabbbaaaaaabcaaaaabbbbbbabbbcbaabffccbccbccbbcbaaaabaaaa#aa#aa##a#aaaaabbikkjhijicabbbcc#faaacdebcbda#########aaaaaaaaa####aa##cacccabcccdccccdddfdcbaa##a##abbbabccbbcbbbccccaaa#abbaaba#a##abbbbbaaaaaaaaaaccaaca##aabcfic.###aa#######a####bddeeddb####.##.###aaa#########aaaa###aa####aaaa#######aabdbbbbcabbbaaaa#aaaaaaaaabaaabbbaabbbbdbbaaabccccccdcefhhkhda##aaaa#a#aaaaa##", +"#aaabaabcecbaa##bcaaaaaaaababbabaaabbabbaabb#chhfdccccbcbecaaabaaaaaaaaaa####aaaaaaabdgjkkijijdabbdcabfaabcecbbec###########a#aaaabaa#######abbaaaadddedddeeefeccaa###a#aabcccdcbcbbbbccbbbbaaaaa#aabbaaaabbbbbbaaaaaaabbbbbaaa####acegha##a#aabbb####a##adccdedbcc#######.###a###a#######aaa#a#aa##..#aa#########abdbaabbabbbaa###aaaaaaaaaaaaacbaaababbdbabbabcbbcbcbccbbdegjkgb#aa#aa#aaaaaaa", +"##aa#aabccccaaaaaaaa#aaaaaabbaabbbaaaaabbbcbbcfhhgfcccbbbbccbaabbaaaaaaabaa#aaaabaaaabbcehkljjdabacccbgbaaccdb#adea#########aa#abaaaaa#####ac#ba##accdedddefffeaba##a#aaaaacccccccbbbcccaabaaaaaaaaa#aaaaabcbbaaa#bbbbaaefccdbaaa#aaacdei##aa##aabbbaaa#a#cdcccccbcea.#########bbaaa######a###a#aaaa.#aaba####.###abcbaaabaabbbaa###aaaaaaaaaaaabbaaaaaaaaaaababcbbcbbaabbbdddeghheba##ab#abaa##", +"#####bbaaaaabaaaaa##aa#adccaabaaabbbbabbabbbabccbccfdbccbbbbbcaabcaabaaabbaaaaaaaaaaaabbbcglli#accbbbddgabcddbbaacea#a##########aaa#aaa##aaaa####aabcddeeefffgdbbaaaa###baabbbbbbcdabdcbcaaabaaaaaaa#aaaaaabcbbbbadfbbbaejhhebbccaaaaaccfi.aba##abaaaba####ecbbccba#fc.####.##.bba#a#######aaaaaaaaaaa##aaaa######abcdaa#aaaabaaa###aaaaabaaabbbaaba##aaababcbbcbbbbbcbaaabbccccddgggeb#aadca###", +"#####bcaaaaaabcbaaa#aaaabcccaaaaaaabaaabbbbbbbaacbabeeddddccbcbbcccbabaaaabaabaaaaaaaaabbbbglmdbcbaabebdgdbcecbbaabdbaa#########aabbaaaa#aa#a##a#aabbdceeedccdcbbaaaaa##aaabbcbbbabaaabbababbaaaa#aaaaaaaabcdccbbbabcbbbcfijfbcdcabb#abcbif#abb##aaabaaaa##fcccbbcaa#db#..##.##.aaa#########ab#aaaaaa#aabaaaaa#####abdbbaaaabbaaaa###b#a#aaaabaaaaaaaaaaaaaabbabbbbaabbbaaaabbbbbbbceffecccbaa##", +"#####abaaaaa#accbbbbaaabaaaaaaaaaaadcbaabbabbbabbdcaacgfddddcdddcadfcaaaabcbbabaaaaaabcabbbdjliacbababcbdfcdeeaaaaaabba########a##aa#aabaa##a######abddeggca#bcbaaaaaa####aaaaaabbbbbcbbbbbaaa##a#aaaaaaaabcbccbbaaaabaabfgfiecccccbbaaaccicbbbcbaaabaaabb#ceccccdca##aacdb######aaa###a###aabaaaaaa#aabca#abba#####abca##aaaaaaaaa##a##aaaaaaabaaaaaaabaaaacbcbacdbaaabaaaaaabaaaaabbcddccbaa##", +"####aa#aaaaaaabccbabbaaaaaaaaaaaaabfaaabbcbbbbbabdebaabdffddedefedccecccdcbbbbbccbccbbbbbbccekldaabaaabccbfaaaaaaaaaaaba########aaaaaaaaba##aaa###aabbccfgfaababbbaaaaa#aabbaabaaccaabcccbcbaa##aaaaaabaabbbccbbbaabbbbbbdddghdbbbcccb#abcdebcccbaabbbabbcbaecddddbaa##.#acdeca#######a#aaaaaaaaaaaaaaabba##abba####aacba##aaaaaaaaaaaaa##aba#abaaaaaaabaaaabbbbbbcbabbaabbaaaaabaaaaaaaaccbaa##", +".####aa#aabaa##bccbaabbbba#aaaaabbaefdaabbbbccbbbaddaaabadeeffhhhffdedddeecbbbbcccbbabcbabbcfjjlkeaaaaacdadcaa#aaaaaaa#ab######ba#aaabbabcaa#aa###babcddcedba##acbaaaaaa#ababbbacbbbcccdfffbaa#aaaacbaabcbabccbbcbbbbbbcbbccedbbbccdccbaabcgb#bccbbbababbbcccdededcb#a####...addcba##aabbbbbbbbaaaaabba#aaa##abba####abbaa###a#aa#aa##aaa#a##abaaaaaaaaabababbcdbcb#baaaaaaaaaaaaaaaaaa#aaaaa###", +"######a##aaaaaa#accbaaabbbaaa#aaababdcaaabbbbcccbbbdbabbbacdccgecadbbbcdccddeddcccccbaabcbbcgjhhjgeb#aacdcccaa#aa#aaa#a#aaa##aaaaa#aaabbaabb#aa###aabccddeccbbbaabcbbbcbbb#aacbbadbabcccddbaaa#aaaaabbbbabbbbcdbbbabbcddcbbbccaabbbccbbaaaadi##abbbbbbbaabbbacdeedbd######aa####bceda#aabbabaaaaaaaaba#aaaaa#aabaaa###acaaaa####aa##aaaaaaaa#aaaaaaaaaaababaaaaabcaaaaaaabbcbaaaaaaaaa###aaaa###", +"##########aabaa#accbbabbbbbba##aaaabbcbbbbbbbbcbaaabdbbbbbbddccbbbbaaaabbabbbbcefefdcbaadbcddje#debgfbabecdc####aa##a###a#aa#aa##a##aaabbcabbaa###aabbcceedbcbaaaabdcccbabaaabbbbabbccbbaaaaaa#aaaaaaaabbbbbcbccabcccccdcccbbbbabbababbba#abfe#aaaaaaaabccbbaaaedddc######adcaaaa##dfcaaaaaaaaaa#aaaaa##aabcaaabbaa#aaab###aa###aaaaaaaaaaaa##aaaaaaaaaabaaabaaabcabaaaaaaabcbaabaaa##a###aa####", +"#########aaaaaaabbcbbbbabcbaacbaa##aaabaaabccccccbaabecabbbcddbacdeba#aaaaabaaabbdfgedcbaccdcgica#aadghdbddd#aa#aaa#a###aaaabaa#####aaaaabbbbbba#aaabccceecbddbaa#bbccabcbbbbbacccdbbdabbaaaaaaa#aaaa#aabbbbcccdcbcbbccccccbcaababbdbabbba#bbgaabaaa#aaacccdcddbeedba#a##a#aba#aaaa##decbaaba#aaa###a#a###abba#bba###aaba####a####aaaaaaaaaaaa#aaabbbaaabbaabbaabbaaa#aa#a#abbaabbbaaa#aaaa#####", +"############aaaaaaacbbbbbbbaa#aaa#a##aaaaaaaacbbbbbbabdcabbbcdbaccdba#aaaaaababbcbbdddedccddefihaa#aaahiiiffd#aaaa#abaa##aaaaacaa##a#bcaaaabbbcaaaabccdddecabaaaaacbbbabbccccccbbdbdfdaabbaaa###a#aaaaaaaabbbbbbbaaabdcddccbbbbabbbccaabbbaabfdaaabaa#aa##aabbbbbddba##aa#a#aa##aaaaaabcdbbaaa##aa#####a#aaabbaaaaa##abb######aa###aaaaaaaaaaaaaaaaabaaaaaaaabbbbaaabaaa#aaaaaaabbbaaaaaaaaa####", +"###########aa#aa#aaaccabbaaaaaaabb#######a#aaabcbbbabbaeebbccbcbacdaaa##a#aabbbbccbbcbcdegifdfgifba##aaaagigha#aaaaabbaaaaaaaaabaaa##acaaaaabbbbbbabcdddefeba####abbaabccccbbbcbadcbcbaabba#aaaa#aaaaaababacccbaadbabbccedcccbbccbbabaaaaa##ade###abba#aa##abbba#cebb.#a####.#a#aaaaaaaaacfca#aaa###aa###abaabaaaaaaaabbaa#######aaaaa#aa#aaaaaaaaaaababdaaabbbbbababaaaaaa#aaaaaabbaaabaaaaa###", +"##########a#aaabaaaaccaaaaaaabaaaaaaba###a##abaaabbababaccbcbbcccaaba#a###aaabbccdccccccdeegggfigaabb#aaa#fffcba#abbaaaaaaaaaaa#abba##aaa##aabbbcbbbbcdeegfeb####aabaabacbbbcbccaabbabaaaaaaa##aa#aaaaababbabbcbcdbbcccbddcdcccabcbbababba###afba#aabba#acaaabbbbaddb##aa####.####aabbaaaabffcaaaaaa##a##bcabbaaaaaaabbbc#a#a#######aaaaa#####a##ababbbbbaaaabbcbaaaaaaaaaaa#aaaaaabaaababaaaaa#", +"#######a#####a#aaaaabcbaaaaaa#aabaaaaaa###abbabaaaaaccaaabdbccbccbaaca#####accddcccccccddeeefikjeabcca#a#abfifbaa#abbbbbaaaaaaaaa#bbba#bcaaaaaaaccbcccceffeccaa##aaabbbcabbacbddbbaabdbaaaaaaaaaaaaaaabbbaabbbbbbbbbcbbccccdcdcccabbbbbaaba###dcaaaabbaaabaabcbccaadba#aaa########aaaa##aaaacgdbaaaa####cfffda#a#aaaabbdbaa#aaa########aaaa#aa##aaabbabbbaaabbbaaaaaabaaaaaaaa#aaaaabaaaaaaaaa#a", +"a###########aaaaaaaabbaabaaa###abaaa#a##a###a#aaaaabacaaabccbbbcbbbcbb####a#bdfbbccccccdefecdgiiddaabbaaaabacfeaaaaaabcccbaaaaaaabaaacaa##aaaaaaabccddcfgfgbabaaa#aaabbcccbccbcddbbacabbbbbbbbaaacbaaaabcbabbbbbcbbcbccbccdccdccdcbaabbbaabaaade#aa#baaabaa##abbcbacdb#.#abbccc#.##aaa####aa#aeeaaaaaaabbabddfgfba#aabcd#aaaa########aa##a##aaaaaababbaabbbbbabccbababaaaaaaa##a#aaaabbaaaaaaaa#", +"#a###a######aaaaaaaacdaaaaaaaa#aaaaaaaaaa#####a###abbbbaaaaccbbbcbbbbaa#aaaaaeecabcccbccdedcdfgigeaaaacbaaabaacbaaaaaaabcbbbaaaaaaaaabccaaaaaaaaaacccceffffbabb#a####aaaabcccccddcdedbbbbaabcabbbccbccbcbcbbbbbbbbbcecbccccceccccdccbbaaaaaaabce#bbaaa###aaa##ababcacda#abb##a#######a#########bfdca#abcbaabaabcffddbabdc#aaaaa##########aa####aaaaaaabbabbbbbbbcbbbcbaaaaaaaa#aa#aaaaaabaa##b##", +"##a#########aabaaaabcdbabaaaaa##aaaaabaaba######a##ababbbbbabbbbcbcdddbbaa#abceecabccccccdddfedgjgdbaaabaaabbbaaba#aabaabaccaaaaaaaabbccbbbaaabaaabcddefgfebbbb#aa####aaaabbcccccbbfeccbbbaaababbbbbbbccba#abbbabbcdccdcbddcddcccdcddcbaaaaaabcfbadaa#######a#abbacbbcc###a#a########a######a##aabdcabccbbababaaaacdfededbbaa#aa##aa######ba#aa#aaabbabaababcbbcbcbbbabbaaaaaaaa##aaabaaacba#a##", +"##########a#abaaaaabbbcbbbcaa###a#aaaaa##aba#######aaaaaabbdccbaabccdddecaaaabccdbbacccddcdefdfgiifcba#bbaaabbaaaababbbbbbbabbaabaaaacbbbcbbaaaaaaaceeeefffbaaaa###a##aaaabbcbbbddcddddcbcbbaaabbbbababbabaaabababbbbcccdccddcddccccdecaaaa#abccfbbaaa#######aabbaacabe###a#aa#a#a##.aa#######a#aa#cfeecdcccccabbbabacggcabbaaabbaaaa####aabb#aaaabbababbbbbbcccbbbbbcccbbbaaaa#aaaaaababbaaaa##", +"######a####abcbaaaaabbccbcbaa###a##aaa##a###aa######aaaaaabdgebaaabbbccacbaaaaabbbaaabccddcdeeffgigbaaaaaabaabcaaababbbbaabbacbaaabbaaaababccbabbabbdffefhdcaaa###aaabba#aababcbdeeccceccccbababbbbabbabbaaaaaabbaabbcbcccccdcddddccccdcaaaababcdeaba#####.###aaabaab#b####a####a##aa#b########aaaaabedddcccccaaaabbcabeaaaabbccbaaa#abbaaabbbaaaabbbaaacbcbcbbdccbaabbacbbbbbaaaaaaaaabbaa#####", +"######aaa#abbcbaaaaabdccbbaaa#######aaa#####aaa##a#a##aaaababcbbaaaaabdebbbaaa##aaaaaaaabccddeefggieaaaaaaaacabaabbbabbbbaaaabbaaaaaaabbbabbccbaabbbdfgghebbbaa#####abba#aabbbcbccdcbbbcddcccbbbabbabbbabbabaaaaaaacbbabcbbccccddddccbcccaaaaaabbdcbc##########aaacbbaa####a####aa###a#aa###aaa###abbceddedcccbaaaacccdca##a#abbbabaaaabaaabbba#aabbbbbbccbbbbaaacccbbcbbaaabbbbbbabaaabaaaa####", +"#######aa#aaccabbabaabdecbb#a########aaaa####aaa#aba##a#aaaaaaabbdcaabdcbcaacb####abb#abaabccdeffghfdabaaaa#acbbbbcbabcabcbaaaabbbabaaaabbbbbcccbbbccdfedccbbb#########aaaababbacccbcbbbddbdcccccbbbbaaaabbaabbaaaaabaabbbbccdcceedccccacbaaaabbbbddb####aa######aabbaa####a####aa#aa###a#####aa#aabbddeccddccbbbabbbbceb###aa#aaaaaa##aa####aaaa#abbbbbccacccbaa#accbbbbbaaababbabaaaaaaaaa####", +"##a#####aaaaaabbbbabacdddccaa########aa#a#####aaa#aa#aaaaaaaaaaaabcabbcbbbbababa###baaaaaaabccdeeehifbabaaa###abbcbbcaccbcbbbaabbbbabaaabbbbbbbbcccccddbccbbbbba#######aaabbbaabbcccbdcbbdbbddcdcccbabaabaaaaaaaaaaaaaaaabbcccddecccbbacccbbbaabbbceca############aaaaa#############a#############aaaaabccddcbbbabbbbbbba#####a##a####aaa#######aaa#babaabbcbaaa##abbbaabbcbbbbaaaaaaaabbaaa####", +"#########abaaabbabbbbbddeccca##aa######a#aa####bbaaaaaaaaaaaaaaaaaabccbcccebacfdb#####aaaaaaabcdddcfgfccbaa##a##abcbbcbbdcccccabbabaababbbbbbbbbbcdccddbabbbbbba########aaababbbacdccccaabcbbcabddddbbaaabbabbbaaaaaaaaabbbddcddecbccbbbdcbabbbaabbcda#############abaaaa############a####bb##a####aaaaabcffdcccbbbbbbbb#######aaa###aaaa#######aabaaaabbcbaaaaaaaa#aaaaaabbccbbaaaaaabbbaaa####", +"#########aaabbabcbbbbbdddcbaaaaa###############aabaaaa#aaaaaaaaaaabbabbdefffccbba###aa##aaaaaabcdceecggdcbbaa##aa#aacbb#bcdddddabbbbbabbbabbbbbbbccfeedbbbbbbcbba#a#####a#acababbbdcbcbabbabaabaabeedcaaaaaaaabcbbaaaaaaabbcdfdddccbbbbcbccbabbbaaabcda########a#aaaaaaa#aa#####aaabaaaaaaacb##aaa#aaababbcdefddbbcbccbaa#####aaaaaaaab##a########aa#abbcccbaaaaaa###aaaaabaabccbbbaaaaaaaaa####", +"########aaaaaaabbbbbbcdedbbbbabaa##########aa###bbb###a##aaaaaaabbaabbbdfeedb##a#a##aa###aaabbbbccdefbfecbbbaaa####a#adb#acdecdfcbaabcbbbbcbbbbbbcdeffbcccabbcdbbba#a###a#aabaaaaaccccbaaaaabbbbaabdfedaaaababbbbbaaaaaaababbcedcccbbbbaccccbaaaccbbabeb######aaaaa#aaa###a######aaaaaaabacbca#aaaaaabbbbccdegfeccccccbcbaaa#####aaaa#aaaaa###a###aaaabbbcccb##a#aaa#aaaaaaaabbdeddcbabaaaaa####", +"#########a#aabbbbbbbbdddccbbba#aaaa##aa##a####a#bba#a#a#aaaabaabbbabbeedeeefdaaaa#####bb##aaabbabcddehgifffdcbaaaa#aa#aaaaaccdeddcabbbcbbbccbabbccdceeecdcaaaabbcccaaaaaaaaaaaaaabacdddbaabaabbbbcccccfdbaabbaabbcaaaaaaababbcccccbbbbbbbccbcca#acbbbbbda#####aaaa####ab##a######aaaaaaabaccbaaaaabbbbbbccceffcdeedcbbbbaaaa#aaaaaaaaa#aaabaaaaaa##aaaabbbcbbcbaa#####aaaaaabbbcccddcbbaaaaa####", +"##########a#aabbcbcbbcecccbbbabaaaaaa#####a#aaaabbaa##ba#acaaababbbbbbbcdcfgdbbbaa####aba##aaaabbbccdfefhfgedecaaa##abaaaaacbabebbbbbbbbcccbcbbbbddbedbddcaaaaaabdccaaba#aaaaaa#bbbbbaddccaaabcbbdcbbcbddabbbbbbbccaaaaaaaaabcddcbbbbbbbbbbbbbbaaaabbaabe#########a####bb#aa#####aa#aaaabccdbbbbabbcbbbccccdccbaaeffdbca#aaaa#aaaaaaa#aaaaabaaaa#aaaabaabbccbbcceb#bcaaaaaaaabbbbcdcbbbaaaaa####", +"#######aa#aaaaabbccbbcdccddcabaaaaaaaaa###aaa#aabcaaa#bba#aabaabbbbbbabcccdfedcaa##aaa######aaaabbbbcdddghhgfedcbaaaa#aaaaabcbbbccbbbbbbbcbccdcccccbeebccbbbaaaaaccccccba#aaaaaaabaaabbbddbbbbcccbcccbaceeacbbbcbccbaaabbabbbbceccbbbbbabbbbbbbab#aabbbbcc#.######a####.bcbcba####aaaa#bedccbbbbbbbaabccddedaaaaa##beeda#aaaaaaaaaaaaaaaaaaaaabba##babbabbbbcbbbccccbbaaaaabbabaabddcbbbaaaa####", +"##########aaaabbbbccccbcddddbaaaa##a#a#a###aaaa#baabbaaaaaaaabbbabcbaabccbddfebaaba#ba######aaaabbbbbcddfiiigggedbaaaaaaaaaabcbabccbbbbbbbcccddddccceecccccbbaaaabccddbbba#aaaaaaaaabcbbbcccdccbcbabcbabceecbabbbbbbaaaabaabbbcddbbbbbbbbaabbbcbbbbaaabcbdc########..####ccccba#abbaaaabddbabbbcabbbbcccceeca###aaa##aaa##a#aaaaaaaaaaaaaaaaaaaaa##aabcbbbbbbbccbbbbcddaaaaacbaaaabddbbaaaaaa###", +"############aaabbabcddccdbcdcbcbbbaaaaa##a##aaaa##abaaabaaaaaaabbaacaabddabcefc#aabaaa###a####aaabbbbbbddgihhfffgeaaaaaaaaaaaaabbbcbbbbbbbbbcddeeedceccdcccccaaaaabcbddbaa#a#ab#aaacbbbbbbddebbbbccbbbabbbedbaaaaaaaaaaaabbabbccecbbbbccbbbbaabbbbcc#aaabbcc######a#####.bccabbacbababaabdcabbbabbabbbcbdecabaa##aaaa####aaaaba##aaaaabaaababa##aa#aaabbbbbbbbcbbbbacbedbaaa#bbaaaabcbbbbaaaa#aa", +"#######a####aaaaabaabbcccbabbbbbbbcbaaa######a#aa######aaaa#aaa#acbbbabeeebabddbaaabaa####aa#a#aababbbbbcehhgeeffdca##aaaaaaaaaabbbbabbbbbbcdcdddfgfhcbbcbbbcbaaaaabcccdbba###baaaabcbbaabcdeecaaabbbbbbaabddecaaaaaaaabbbbbbbccfcbcbbbbbbbaaaaabbbcca#aabacc#######a####acdcbbbbbbaaaabbccaabbbbbbbabbceecabb#aa#aaaa#######aaa##aaaaaaabbaaaaaaaaaaaabbbaabccbbcbaaacgdaaaa#aababbbabbbbaaaaa#", +"###a#####a#aaaaaabcbacbbddcaaabbbbbbbaaaaaa##a#####a####aaaaa#aaabdbcbbedefcaaabaaaaabaaa#a##abaaaaababbbcfgggfeefea##aaaaaaaaaaabcbbbbbbbbcdcdddefgeabbbbaabccaabaaceddeeaaa##aaaaaabbbabbcdedbabbbaaaaaaaacfecaaaaabaabbbbbbcdfdbccbbbbbaaaaaabbbcdbaa#aabdb#########a#acdcccbaaab#aabccbbbbbbabbbceedccbcbbaaaa#baa#a###a#a##aa###aaaabaaaaaaaa##aaaabbaaabcbbbbbabbdfeaaaa#ababbcbbaabaaaaaa", +"#####a#####aaaaaabbbbbbbcddcbabccaaabbaaaaa#a##a##a######aaaaaabaaaaacbbbffeaaaababbabbbbbaa##bbaaaabbbbcccghghgeffbaaabbaaaaaabbabccbbbbbbcdddefggecccbabaaabbbacbabbdddecbaa####aabaababbcccdcabaa#aaa###abceedcaaaaabbbbccddefdccdccbcbbaaaaabbccdccdb#abbd###a#####a#a#cddcccaaaaaaaaabccbbbbdeefbba##aabaaa#aaaaaa#aa###aaa##a####aaaaaaaaaaaa##aaaabacbabbbbbcbbbbcfgbaaa#aa#abbab#aaaabba", +"##########abaaabbbbbcbcdcccdcbbbcbbbbbba#aaaaa#a############aa#aaaaaaababbdeaaaacbbbbbddcbaaa##abaaaabbbbcccghhhedecababcbaaaaaababcbbbbbccbddceggffecccbbbaaabca#aaaadddedcb#a##aaaabbbabbbbcccdd###aaaa#aa##bcefeddcddccefdddfdcccccccccbbaaaaaabccccdddaabbda########ab##bbbddcbbaa#aaaabcbbbcdddccaaaaa#abaaaaaaaaaa#aa#aaaabaa#####aaaaaaaa#######aabaacbabbbbbbcbbbbdfbbaaaa###baabaabaaba", +"###########aaaabbcbbbcccbddbcdccbbbbcabbaaaaaaaaa###a##aa###aaaabaaababbccbbdb#abccabddbbbba#aaaabdbbaabbbbcdehihbaabbbbcdcbbbbaababbedcbbaccdddeeefedabbabaaa#aaa#aa#beeeeffca###aaabbbcbbbbbbcced#a###a##aaa#abffgfedcccfhcbdebcbccdccccbbaaaaaabbcccccddbaabdcb#.#aa#aaa##abdddcbbbaaababbbbbcbdbabbbbbb##ababbbaaaaa#aa#aa##aaa######ababaaa#####a#aabcbbbabbbbbbcccbbbeabcbba###aaaaaaaaaab", +"b#########aaaaababbbbabbbbdebcccccbbbabaaaaaaaaaaaa########aa#abbaaabbabbdbcbbbaaadcbcbdbabba##aa##abcb#aaabcdcfhgdabbbccdcbcbbbbbbabcgdcbdbbdedeeehfgdbbbbbaaaa#aaa#abddddgeedcaaaaaabbbdccccccbceeaa###a###aaaacfghhgedccggefbccccccccccbbbbbbaabbcccccccdaabaaccb#aaa###a##adedccbcbaaabbbbcbbcddbaaabbbbaadbbaabbaaa##abaaa#aaaaaaaa#aaabaa########abbadccaaabbbcccccbbdcbcbbba###aaaaaaaabb", +"aa##########aaabbbbbbbaabbaccbceeebbaabbaabaaabbbbaaa###aaaba#aabaaaaababbccggcbaabccbbbccbca##aaaabdbbabbabbcdddghbabbccddcbbbcbbbbbccgfcbccceddddeddedddcbababaaaaaa#accdeffedbaaaaaaaacccccbbbccffb#a#####aaaaabfhgghhhhgghecbccbccccccccbbbbaaabbbbcbbbcdcbbabbcb#####abca#abccccccabbbbbbbbbdddbaaaaabab#cdba#aabaaaaaaaa#aaa#a#aa#####aaaa#######aabbbbccbbbabbdeddcbbeaabbcb###aaaaaaaaab", +"baaa######a#aaabaabdbbcbabbaccccedaaaaaaaaaaaaaaadbaa#aaaa##aaaaaaaaabbbcbcccdbaaaaabdcbacbcdcaaaaaaaabaaccbbccdddhgcabcccdecbcbbcbbabadedbbcdedcddeeccdddeeedcbbcbaabbbabbcddddec#aaaaaabbcccccbccdffc##a##a#aaaaaafheffhgeccefcbbcbcccccccbbbbaaabbbbccbbddedbabbcc.##a##abc###cdcccbcbbbabbbaddccababbbaaabaddba##aaaaaa#aaa#a#aaaaa##aa##aaaa#######abbbbccbcbbbbdefeeccecaaaaa####aabaaaaaa", +"bb#a########aabbbaaababcccdaacdbbaba#aaaaaa#aaa##acaa###aa#aaaaaaaaaaabcdcccaaaaaaaaadbcbbbbacc###aaaaaaaacbbccdcdfggbbbcccdecccddcbbbacdfdbcdebbbcccdcccccdcbefccbaaaaabcbbccabdfcaaaaaaabbdddccccccefe##a##aaaaaaaadfghhhdbbcccccbcbbccdccbbbcaaaabbbbdccddeeba#bbda######.acabbddccabcbbbbbbbddccaaaaaaaaaaabdca#a#aaa#aaaaa##a#aaaaa##aa##aaa#a##a##abbbbccbbdbbccefffeccd#a########abaaaaaa", +"aa##########aaaaabaabbaaccdcaacbbaab####aaaa#aaaaaa#a####abaaaaaaabcaaabddcacda#aaabacbbbbddddcbaaa##aaaaa#abbdcccdegfbbcdcdefccddccccbcbbfdccecabccbcbbbcdddcbffdcccb#aacbaabcbbeecaa#aaaabcedddccccddfeb#####aaaaaabbehhfcccbcccccbbccccccbcbcbbaaabbbcdcceddcbbabba########bcbbcdcbbbbbbbbaacccccaaaaaaaaaaaabcba####aba##aaaaaa#aaaaaa##a#aaaaaaa#aaabaabbcbbbbbbbdffffeeeaa########aabcaaaa", +"aba#a#aa####aaaaabbabbabbaccaaabaaaa#######a####aaaaa####aaa#bbaaaabaaacbddcbccaaaaaaaaaaacdeabcbba#a###a#aaabccccdeegfcbcdddeedcdccddccccfedddcbbccbbbbbbccddedecccdca#aaaaaaabacedcddcbabaabccccccccceccd####aaaaaabaacdghhfecccccbbccccccccbcbbbaabbbcccccddcddceaca########cdccdccbbbbbbbbbccbcdcaaaaaaaaaaaaaaba#####aaaaaaa###aaaaa##a####aaaa###aabbbbbbccbdbbbcdefffgaa#a#######aabaaaaa", +"aa#####aa###aaababbccccbbbbcbaaababa#######a#aabaaaaaa####aa#abbaaaabbaabbdcbbcdbbbbaaaaaabcddbcbba#####a#aaabcdccceefhgbbdcceeeeccccccddeefeeecccacccbcbabbccdefdbcebaaaabaababbbcdcdfffdabbbbbcccccccecade#aa#aabaaaabaackijkidbbbcbccccccccbcbbbbaabbccccccccddegfdaa#######ceedcbbcaacccccbcccccbaaaaaaaaaabaaaaaaaaa####aaa.baa######aaaa####baaa#aaaabbbbbccdcbbcddedfgfb##########abbaaa#", +"#a########aaaaaaccbbcdcccbbbba#aaaaaa#####aa#aaab#aaaa#.###aa#aabababcbabaccbccdedaaaa#aaaaabccacbaa#a######aacbcccdffhigeccccdeedddccbcddffdefcbabbbcdecbabbbbcddecddbbaaabbabbbcccddeeffabbabbbbcccccdecdedb#a#aaabbaaaaahifgikfcbcccccccccccbbaaabbcbbbccbbbbcccdhea#a#####aedfebccccbbcbcccccccbaaaaaabaa#aaaaaaaaaba#b###aaa#b#######a####aa##abbbabaaabbbbbcdecbbcdedefghc#########abcedcb", +"a############a#abcbbbcddccbbbcaaaaaa#a####a#a###ba#aa#######aaba#bbbbbccaabcccddeebaaaa##aaaabaaabaaaa#####a#aaaabcbdeggihfccccdddffdcbcccdfcbcbbbbbbccbbbbabaabcdfebcbbca##aabbbbcdcdfffeeaabbbccbbcccdeeddeed##aaabaaaaachgcccfijebbcccccccccbbaaaaabbbaabbaabbcbbcfecaaa#aaadcddbbdcccabbcccbbbabbaaaa#aaa###aaaaaaaaaaaaa##aaaaba######a######a#abbbbbbabbcbbbddcabcddddefgfa########aacedcc", +"#######aaa#####aaaccccddcdcccbbaaaaa####a####a#aaaa#aa#######abaaabbccacdaadccdddccba#aa#bbaaabaaabaaaaaa#aaaaaababbbdeffiiebcccdddeedcccdcfbcbbbbaabcbbbbbbaaaabcdeefeeddedbaaabcbdccefffffabbbbbbbbbcdcdddddefbaabbbbabaeidccddcejgbbccccccccbbbbaaabaaaaabaaabccccdffebaabbaaddcc#cdccabcccccbbbbbaaaaa#aaaa##aa#aaaaaaaaabaaaba#b##a####a#a#a##a#aabbabbaabbbbddecbbdcccddeega.##.#a##aab###", +"#########a#####ababccbbbdcccccabbb##aaaaaa#aaaaa##aaaaaa#..###aaaaaaccbbdcbbccdbccdaa##a#a#aaaaaa#ba###a#a#aaaaaaabbbcdeefhgeccedbbcdedeedgebbbbbbbbcdcbbbaabaaabacccddccccbdcaabbadddeefffgfbabbbbccccccccdddbggbaabbbbabhefcccddddihdccccccccbbbababaaa###aa#aabbbcdeeffa.##abcfedabccbcccabcbbbbbbabaaaaa###aaaaaaaabaaaaaaaaaaaaba#######aaab#####aaabaaaabbbaceffecbccddccdec#####.##aa#aa#", +"#aa########a####abbccbbccdcccbbbbba#a##aaaaabaa#aa####aaba#.##baaaabccdabdbabbbbbcccbaa####aaaaaaa#aaaa######aaaabbabccdfeehihfggfdbceedddeddfdccbbcbbbbbbbbbbaaabaccccbbccdddecababedefffffhgdaaabccbcccccdddbfhfbbbcbbackdeeccdddccfhgbccccbbbaabaaabba#####a#aabbbdeddeda.###aeddcbaaccccccccbbbbbabaaaaaaaaaa##aba##abbaaaaaaaaaab######aa##aa###aaabbbaaaaabbbeffffdcdcdeffda######.###aaa#", +"#aaa############aabcdcbcdcfedeecbbaba##aaaaabaa###b#a##aaaa####abaaacdcaacdaacbcaaaaaaaabc##aaaabaaaaaa######aaaaabbbdddeddfhhhhhhfcccffffdbaabcbdbabbbbbbbbbbaaaaabbcccbbbbcfdedbbadeddeefdefhffecbbcbcccccceddgibbbbbbdecccbbccccddddhidccccbbaacaaabba########aabccedddeda####cdcecbccccddddcbbbbbabbaaa#a#####a#######abaaaaaaa#aaaa#a##aaaa#a####aabaaaaaaaaabccddfgfddefge################", +"##aaaaa#aa######aaabdccbccdeefebbaccb###aaabcbaa########aa######aaba#bdbbbcabbbbbbaaba##aba#####ababaaa##a#a##aaaabbcddedddeeefhghfddccdhecbbbaaaababbbabbabcbaaaaaabbccbbbbbbeefdbbbddbddffdggihiebbbcbbcccccedeicbcbbcdccccccccddddddcfifccbbbbabbabbbaaa####aa#aabcedddefeb##.bdcdeccbcccdddcbabbbbaaaaaa#aa############abaa#aaaaa#aaaaaaaaaa#######aabaaaaaaaabbabbcefgecbcc############a#a#", +"##aaaa####aa##a##aaabcdcbbccdcdccbcaba##aaaabbbaa#aa#a####a######aabaaabaaaaaaaabbba#aa###a##a###abbbaa#aaaa#a##aabbcededddddeghggcdfedffddcbbbaaabbbbbccabbbbbcaaaaabccbbbbbbeccefdbcdbcbcefefhgghdbbcbcccccccdcefedbadccbbcccccddddddddeggcbbbaacaabbbaaa######aaaabdcdeedefbaa#deddcdcbbcdedccbbbcbaaaaaa##################aaaaa#aa##abaaaa#aaa#aa##aaaaaaaaaabaabbacdbacbaaba###############", +"##a#aaa####aa##a##aaabbbbbcdeccbbaaaaabbaaabbaabaa###aaaa#########aaab#aaaaaaaaabbaaaa#a#a#aa#a#aabaaaa###abb##aaaaabcdeeddefghhhebbbfebbdddccbbbbbaaabdcbcbcbacbaaabbabcbbcccddbbcefecdcbbbcddehgggcbbcbcccccccdddffbbdbbbbbccccddddddddddegcbbaabaaabbbaaa######aaabbbcdefdeca#ddedcdddbacadedccbbbbbabaaaa###############.####aaa##a###a##aaa#aaa#abaabaaaaaaaaaaaaabcdbaaaa#a########a##a###", +"a##a#aaaa#####aaaaaaabcccbbcdebbaaba#a#bbaaabbaaaa####aaa#####aa#abaaaaaaaabaaaaaabbbaaaaaa#aaaaaababaaa####aaaaaaaabcddddefedhhgbbbbcefbcdedcedabbbababbbcbbbbbbaaabbaabbbbbcbcddbbbcdcebbbbdcabehhebbbbcccccccceddhfddbbbbbccccddddddddddcdfdaaaaaababbaaaaaaaaaaabbbbccddcdfededffddddcbcabcddccbbcbbaaaaa#####################aa##a#a#######aa###aaaaaa###aaaaaaaaaabbccaabaaaa######a######", +"aaaabaa##aa####aaaaaabbccccbcccaabbba#a##aaaabbb######aaaaba##aaaaababb##aaaaaa#aabaaaa#aaa#aabaaaaaacbaa####aaaaaaabcdeddefefhheabbbbbdfgfgedcfaaabbbbbbaaaaaacabaa#baaabbabaabbdeeeccabdccbbbcaachifbbbcccccbcccddejkeabbbbccccddddddddddccceebabbaabaaaaaaa#aaaabbbcbbcccddefgedfedddcccbaabcdcccbcbcaabaaaa########.##.########aa###a########aaaaa#a###a###aaaaaaaaababccaabaa#########aa#a#", +"##aaaacb########aaaaabbbbcccbdcddbbcbc#aaaca##a#aba######abca#aaaa#aa###aa###aaaaaabbaaa#a###aaaaaaa##bcbba###a#aaaabbceedddehgfdaaabaccbfhiihffcaaaaccbaaaaaaacabaaabbaabcbbbbbbbcbdeffedfdb#acaabafjgbbcbcccbccccdefiicbbbbacccddddddddccccbbcfbbbbbabaaaaaaaaaabbbcbbbbccccdegfecfdbaabdabbbbcccdcccbbbbaaaa###################a#aa##a#a##a####a#aaaaa###########aaaaaabbbbbaabaa#######aa###", +"###aaacba#######abaabbdcbbcdcbbefcbabcbbaaaaa####aa#a#a#a#a##aaab###a#aa####abb#a#aacbaa####aaaaaaa#aaabdcbaaaaaaaaabaceefeeffffbaaabbabccehigfeeddefdbabaaaaabbbabaabaaaaabbbbbbabccbabdedda##aaabbachhbbcbccccbbcccdeghebbbaccddddddddddccccbacecbabaaaaaa#aaaaabbbccbbbbcccdcdgfdfebbbbbcccbcbcddccccccbbaaaaa################aabbaaaa####aa###a##aba#############aaaaabbbddbbaba##########.#", +"####aaaba#######aaaaabdfdbbcccbbdebbaaaab#aaa#a###aa###aaa###aba#####aaa#####aba#aaa#baaa#####aaaaa###aabcccaabbbbbcbbbdfffgeccebaaabbbbcbbeffedccfghhebaaaaaabbaaaaaaaabaabbabbbbbacbbbbcbdda####abbabghabbbccccbbccddddghdaabcddddeedddddcccbbabdfdaaaaa##aaaaaabccccccbbccddcbefdffdcbbbcdccbbccddcccccbbbaaaa################bbccbaabaa#aaaaaa#aabba##a#########a#aaaaabbccbcabaa###########", +"#####aaaba#######aaacccefcccbcdccbcbbaaaaa#abcba#########aaaaaaa######aaaa####aa##aaa#aaaaaaa##aaaaa##aaaccddcccdddddcceeffdccdccbaaaaabbbbcfggdddfffggfebaaaaaaaaaabaaabccbbbbbbbabccbbbbbcbdb###aabbbbghbacccccccccccdddfigdbcddddddeddddcccbbbabbfeabaa#####aaaabcccccbcbdddecegfffcccabbccccbbccdcccccbbbbaaaa############a#aaaababaaaaaaa#aaa##aaaa#aaa##########aaaaaabbcccbbdba#########.", +"#####aaaaa######aaabddefcccbabdccccbaaaaaa###aaa######aaabaabbba#######aaaa####a###aaaaaa#a##a#aaaaaaaaaabcddddcdeeedefgfefecdaabbaaaaabbbbbadfebcfdfgffeeecaaaaaaabaaacabdbaaabbbcdcbbbbbbbbccb#a###abbaegcabccccdcccccdddcfihfdccdddddddddcccbaaaaaddbaa######aaabccccbcbccdddhfcfgecccbbbbcbccbccbccbcccbbbbaaaa#a##########aaaaaabccbcba#aa#aa#aaaaa#aaaaa###########aaaabbaddedaa##a#.#####", +"####aaaaaa#######cffdabcbcdcbbadfbcbbaa###a#aaa#aaaaaaabaaaababaa#######a##a#########aaa##aa##aa#aaaaaaaaabdeddccddddddffeeeec#a#aaabbbaaabbbcggdcfeeeeegfdccbabccbbaaabbbcaaaaabbbcdbbbbccbbbdbaaa###abbccebabbccccbcccccddcdfhjhedddddddddccbbaaaaaabdda#######aaabbddccbbdddedccdgeeedccbbccdccbccbcbccccbbbaaaaa#########.##aaabbaabbbcbaaa###aaaaaaa#a#a#a########aaaaabbaccddeb###########", +"########aaa######acddbabcbbcccabcddcaabbaaa##aaaaaabbbcaaaabbaaaaaba########aaa#aa###aaa###aa##abaaaaaacbbbcdffeddeccdffffeddbaaaa#abbaaaabaabegebdfeddeffeddddcdddcabbacbcbccbaabbacccbcdbbbcdb#aa##aabbbbbffbbccccbccccccdddedfkkidddddddcccbbaaaaabbabdb#a#####abcccdbccccddfcccdfgeedccbbbcbccccbbabbcccbbbbbbaaa############a#a#aaaacacbaaa####aaa#aa###a##a######aaabaabbbbbbdfa##########", +"#################abbcbaacccccbccaacbcaaaaaaaaaaaaaaabccabbbbaaab##bb######a#aba##aa##aaaaa##a#a#acabbbacdcbcddffffdgeefefeddcb#a##aaaaabaaaaaaddfdcfdccccccdcbcbcccecbbabccdddddcbbbbccccccbbbceb#aa###aaaabbfgbacccbcccdcdddeedgjkihccddcccccbbaaaabaabaadca####aabbcccbcddccefdcdeeeedddcacbccccccbabaaabbbbbbbaaaa###########.#####aaaabacbba##aaaaaaa####a####a######abbabbcbcbcdb###a##.##.", +"###########aa#####bdbaaaaccddbbdcba#bbaa##aa#aaaabbbbbbaaabaaaaba##aa.####aaa##a#aaaaaabbbaa#####abaabbbbbccdddeefeffddefdccaa####aaaaaaaaaabaeefdedeccbabbbdddbbccccabbbbbbbbcdcccbcccccccccbaaaa#a####aaaabacgcabbcccdddefffedgijfehdcccccccbbbaa#aaaaaaabcbaaaaaabbccdcdddefgecddeefedccbbbabccbbbbaaaaaabbbbaaaaaa################aaabcbabbaa#aaaaa#aaa###a####a####aaabaabcbbbcbba###aa####", +"############a#####abaaaaaabddccbcdddbaaaa###aaaabaaabbbaaaabbabba###b######aa######a##aacbcbba##a##babbccccdddddeeefgfeedccdb####a#aaaaaaaaaaadefedecbabbbbbcddddbcddcaabaaaaaabbbbbaabbccdcccbbbcb#a##aa#aaabbbfdbbccddddeffffefggeedjhedcdcccbbaaaaaaaaaaabbcaaaaabbcdcccdeefgdcccdefeccbbbbbbbccbbbbaaaaaaabbbaaaaa#######aa######aaabbbcab#a#aaaaaaaa#a##a#####abaaa#abaabbbbbbdccc####aa#.#", +"###aaa###a#a#a####aabaaaaaabdbbbcecdcbaaaaaaaa#aaaaaaaaaaaaabccbb###a########a#a#aaaaa##aaaabca#a##aabbccccccdcccbbbbcbcabbbb#a#a#a#aaaabaaaabbeffddeabcbbbbcccccdccbbbaaaaa#abaaaaaaaaaababbbbbcbb#a##a##a#aaaabefcbdeeddeffffffeddfbchjieccccbbbaaaaaaaaaaaacfcabbbbcdddcdehggffeeddgfecbbccbbbccbcbbaaaaaaaaabaaa######a##aaa####aaaaaaabbaa##aaaaaaa#aaaa#####aabbaaaabbbbbbccccddbaaaa####.", +"####aaaaa#aaaa#aaaaaaabbaaabccbbbcddbbdcbaaaaaabaaaaaabbbbaaaaabaaa###############aaaaa##a#aaaaaaaaaaabbccccdcbbbaaaaaaaabaaa#######aaaaabbbabaacffffbbbbbbbbbbbbccccbaaaaaaaaaaaa##aaaaaaabbccca#######aa###aaaabcgfcdeeefgggggggeffcbbehkjebbcbbaa##aaaa#aaaadheabbbcdddcegfbccdfffgggedccccbbbbbabbbaaaaaaaaabaaaaaa######aaaaa#aa##aaaabaaaaaaaaaaaaa##aaa##aaa#acbaaabababbcccdecbaaaa###a#", +"#######a###abaaaaaaaaaaabbdccccbbbceefebcaaaaaa#aaaaaabbbcccaabaaa###aaa#######a###aaaba##aaaaaaa#aaaabccccccbbbaaaaaaaaabaa###a###a#aaaaacbababa#eeedbbbbcddbcbccbccccaaaaaaaa#a#aaaaaaaabbbbcba########aa####aabbbghdeeegggggghggfedbbbcdikgbbbbbaa#aaaaaaaaaabheaabccddegdccccdddccfffddbbabbbcbbbbbbbbbbbaaaaaaaa########a###aaaa#a#abaaaaaaaaaaabbabaaaaaaa#a##ccaaaaaaaaaabcccbacaaabaa###", +"##a#aa#####aaaaaaaaaa#aabbbabbcbbabcdeedcbbbaaaaaaabbbccdddccccbbccbdcbcca########aa####aa##a#aaa###aabbccdccbbbaaaaaabaaaaa#########aaaaabcaaabaa#dfcccbcccbcccccdccccdbbaaaaaa###aaaaaaabbbcb######aa###aaaa###abbcfheeffghhghhijifcbbbbbehjhcbbba##aaaa##aaa##afgdbbcefecdcdccddddddeedcbabbcbbabbcbbbaaaaaaaabaa######a#a#a###aaaa#aaabaaaaa#aaaaaaaaaaaaaaaa#a#bcaaaaabaaaaabbcccbcabbbaaa#", +"aaaaaaaaaa#aaaaaaaaaaaa#abaa#aaaaaaaaabcbbaabbbabbbbccddddddefdbcdccdecddcaa##aab######baaaa##ab###aaaabbbcccbbaaaaaaaaaaaaaa########aaaaaacdbaabaa#dcabccdddcccccdeeddddddbaaaaaa###aaaaabbbca#a#########a###a##aaabcegefgfhhggiiihddbbccbbfegihfb###aaaaa#aaaa##adgfefecbddccccddcedccefdcbabcdcaabbbbbbbaaaaaaaaaa#a####aaa#aa###aaaabaaaa#aaaaaaa#aaa##aaabaa##abcbaaa#aaaaaaabbbbdddbbbaaaa", +"aaaabbabaaaaabaaaaa#a#aaa#abaaaaabaaaaaaaaababbbbccdddeeefdfffedccbbbbcccccaaaaacb#abaab#aaba#aaa###a#aaaabccbaaaa##aaa#abaa###a##a#aa#aaaaacca#abaaadbabddddfededcbbcaaabcddcaaaaaa###aabbbcdca######a####aa##aaaaabbcdkgghhhhhgiigecabbbccffedgiida#aaaaaaa#aaaaaabfecbccccbbbabbbddddddccbaaacdcbbcbbbbbbbaaaaaaaaa##################baaaaaaaa######aa#aaaaa#a##abbbbaaaaabbaaaababbddcbbbbaa", +"aaaaabcccbbbaabaaaaa#aaaaa#aaaaaaaaaaaaabaaabaaabbbcdffefgffdcccdddcccccbaabaaacbab#aa##aaabb#a#a##aaaaaaabbbcaaa###aaaa#aaa#a###aaa#abaaaaaacccbaaaabcbaaccbbdccbbbababba#abccbaaaaaaaaaabdeabaa##########aa####aaaabbceghghhihiihhgcbbbbbbegdcdedhhdd#aaaaaaaaaaaaabdccccccaaabbbbcddddfeffdbbabcbbbbbbbbbaaaaaa###a#########aa#######acbaaa#####aaaa##aaaaaaaaa#a#aaaaaaaaaabbbbaabbccddbbbba", +"aaaababbbccbbcbaaaaaa#aaabba#aaaaabaaaaababbbbbaaaaaa#aabbcaaabbbbbbbbbcbaaaaaabaaaa####a##aaaa######aaaaaabbbbb#######a#aaa#a###a##a#aaa#aaacbbcbabbabcabbbcddbaaabbaaaa##aaaabbaaaaaaaabbcdbaaa###########a####aaaaabbbcfihghhhihhhdabbbbbbeeccccbdehfaa##aaaa#aaaaaabedccbaaaabcdcddcbfeffddeedccbbbbbbabbaaaaa#############aa########ababaa###aaaaa###aaaaaaaaa##abaaaaabbbbbbbbbbbbcdffabaa", +"aaaaabbacbbbabaaaa#aaa#aaaacba###aaabaaaaaababaaaaaaaaaa##aaaaaaaaababbccc###aabaaaa##a##aaaaa#aa##aa#abaaaacccb##a#a#a#aaaaa####aaaa###a#aa#ababdbbbabcbabbbbbbbbbcbbaaaaaaaaaaba#a###aaacbcdaaaa#########.#####aaaaaabbccfkjgfhhifdfdaaababbffcbbbbbacgda#aaaaaaaaaaaaaddcba#aabccccdbbdeefeddfdfecbbacaaaabbaa##############aaaaa#######a#aa###aaa####aaaaaabaaaaaaaba#aaababbbcccddddgihcabb", +"baaaaababccccbbaaa##aaaaaaa#cddb#####aabbbbaaaaaaaaaaa#####aaa##aa#aabadedca#abbaaaaaa####aaaa#a#aaaaa##aababcbca#aaaa#####aa###a#aa##aaaaa#a#aaacbaabbbcbabcccbbbbcbabba#aaaaaaaa#bbaaaaabbadb###################aaaaaabacbgkkihhggfedaaaaaaaceecbaaaaabffgeca#aaaaaa###acdca#aaacbbccbcbeeefffdabdfecabaaababbaa#a##########aaaaaa#######abaa##aaaa#####aaaaaaaaaaaaaabaaabaabbbbbcdegghffdabb", +"bbaaaaaabbcccccbbaaaaaaabaaaabccca###aabcceebaaaaaaaaaaa#a##a#####aa#aaaddbbaaabaaaaaaaaaaaaabb##abb#aaaaaaabcbba##aaa###aaa#########a#aaaaaaaaaaaaaabbbccbaabccbcbbbbbaaaaaaaaa##aaabaaaaccbed#################.##aaa#aaaaacekljihhhdbaaaaaaabdeedbaaaaaabceffdaaaaa#####abdd##abbbbccccbcedfeddbbbbdddbbaaababaaa#################aa#aa.###aa##ba##aa###aaaaaaabaaaaabaaaaababbabbbdfhjifeecba", +"bbbaaababaabbcccbaaaaaa#aaaaa#aaba##aaabcbbccbaaaaaaaaaaaaa#aa####aaaaaabccbaaa#aaaabaabaaaa#abdca#acaaaaabaabbaba#aaaaaaabba##aaaaaaaaaaaa##a#aabbbbbbbccbbbacbcbabbbbbaaa#aaa##aaaaaacbccccdbbba#a########a#.####aaaaabaaaaafklljhfcaaaaaaaa#dcgfcbbaaabccccdggcbaaaaa#aaaacdaabbbbbbbbcbddeeddccccbbcecbaaaaaaaa#a##############aaa##a####aa##b###aa#aaaaaaaaaaaaaa#aabaaaaaabaabbdggghhfbdeb", +"bbabbaaaaaabbcbccbabba#aaaa##a#aaa#a#aaabbabbbaaaaaabbabaaaa#a#####aaaaaadcba###aaaaaaaaaaaaaaabbaa#abaaaabbbcbaa#aaaaaaaaaaaa#aaaaaaaaaa#aaaaaaaabbbbbbbcbababbbcbbbbaaaa###a###aaaaaaaccddcddbaaba#aaaa####a#.#.#aaaaabbaaa##djlljc#aaaaaaaa#afdfebaaaabccccddegfdbaabbbbbbabddbbbbbbbbbadceedcdcccbbabdebaaaa#aaa#############aaaaaa#ab####a##ba#####aaaaaaaaaaaaaaaaaaaaaaaaaabcdfebbbabbbcc", +"ecabbaaaaababcdcccbbbcdbaaaabbaa#aaaa##aabcbbbaabaaabbaabaaa#aa###aaaaaabecbaa#a#a#aaaaaaaaaa#aaaaaaaaaaaabbcbaa###aaaaabaaaaaaa#a####aaa#aabaaaaaabbbbbbdcbbabbbcbbaaaaa####aaa#aa###aaabcccccbaabbba##a####aa#####aaaabaaaaa##ahlkfa#aaaaaaa##fbbecaaaabccbcdddceghecbbccccbbbccddbbabaa#ccedddddccbbaaacfbaa#a##a############a##aaaaaaaaa##a###ca#aa###aaaaaaaaabaaaacabbaaabbbbddea###aaaabc", +"abbcbbbbaaaabbccbbbbaaaa#a#aaaabcaaaaaa#aabbbbaabaaccbbabaaaaaaaaaaaabbabdcbaaaaa###aaaaaaaa#aaaaaabbbaabbbabaa#aaaaaa#aaacbbaaa##aa##aaaaabcbaaaaabacbccccabaabaacbcbaaa####aaaaa####aaaabdccdba#abbaaa#######a######aaaaaba#####dljfa#aaaaaaa#ddaadcbccbbbbccccdccehihfddccccccbbdfaaaabbbceefedddcbbbbaaaecaaaaa##a###a####a##a##aaaaaa####a###ba#aa###aaaaaaaaabbbbacbbbbbaaacccdd#####aaaab", +"babbbcccbbbaacdbccbbbaaaaa######aaaaaaaa##abbbbabaaabbaaaaaaaaaaaa##abbbdcccbaa#aa#####aa#aaaaaaaaaaabcbabbabaa##aaaaaab#accbaaaaa#aaaaaaabcddbaaaaabbbccccbaabbbbaabbbbaa###aaaaa#####a#abceeeaaa#aaaaba#######a#######aaaaaaa###.cgjgb#aaaaaaaafcaacdcdcbcbbcbbccdeefeeghfeccccbcddc#aabaaaeffeccccbbbbbaaacdcaaba##aa##a#aa#aaaa#aa###a####a####b#a##aaaaaaaaaaaaabbbbcababbbbcdddeb#a#####aa", +"bacbbcddcbbbbacddccbabbaaaaaa#a##aaaaaa####aabbaaaaaaabaaaaabaaaaaaaaabbcccbbabaaaaa#a#aaaaaaaaaaaaaaaabbccbbba##aaa#aaaaaabbbaaaa#aaa##abbaabbcbaabbcccccbbbbbabbbabbbbaa#############aaabbcedbaaaaaa#aaa######a########a#aaaa##a##adhjc#aaaaaaacdb##bddcbbbbaabbccefgecceffgfcbceccedabbaaacffdccbbbbbbbbbaabccbbaaa#aa####a###aaaaa#a##bb##a###ab##a###aaaaaaaaaaabaaabbbcbcbbbcefeb#####aa#a", +"aaccbcddcbbabcbcddcbbbcbaaaaaaaa#aaaabaa##a#aaaa##aaaaaaaaaaaaaa#aaaaaaaaabbccaaaaaaa#aaabbaaaaaaaaaa##aabccccbaa#aaaa#abaaaaaaaaaaaaaabbbbaabbaccbddedcbbbbbabbbcbcbbcaaaa############a#aacbcba##aaaaaa#aaa#a###########a###aaaaa####adid#aaaaa##eca##addcbbaaaabbcddefddefddgiedccccffbaaaaaefeccbbbbbbbbbaabacdbbba####aa#a##a##aaaaaaccbba###.aa#aa#ba#a#aa#aaaaabbabcbccbcbcccegc######ba#a", +"abcbbccdedcbbbabdddcbabbbbbaa##aa#aaabaa######aaaaaaaaaaaaaaa#aa#######aa#aabcbbaaaaaaaaabcaaa###abaaa#aaabcbcb#aa##aa#abbaaaaaaaabbcaaaaaabbgecbbbbccbbbbbabcabbcbbbbaaaaa##############aaabaaaa#aaba#######a###########ba#aaa#aaa###aabffcaaaaaabeb####cdcbaaaaaaabbccdeffeeegihfddddffcaaaabefeccaabbbbbbbaaaabdba#aa####aaaaa###aaaacccbbba#######aaaa#aa#a##aabbbbbbbccccccccddgf#aa##a#aaa", +"aabcdddddddbbbccabcdccbaaaaaa#####bbaaaa#######aaaaaaa###a#####a#########aaaacbbbaaaa#accdddba#a#aaaaaaaaabbbcbaaaaa#aaaabaaaaabba#bdaaaaabeecbbcbcbccbbbbabbbbbbbabbbbaa#aa####a########aaaaacaabaabaa#######aa########abbbbaa##aaaa###aaegfb#aa##dcaaaabddbaaa##a##aaabcdfgffgiggfffedefea#aabffccbaaabbaaabaaaaacbaaaaaaa####a##aaaaaabbabaaa##aa##aaaaa######aabcbaabbccccbbddedeeaaaaa#baaa", +"aabbdeedeedddaccbbbcbcccbaaaaaabbaccaaa#a#aa###aa#aaaa#########aa#a#####a##babbbbbcbbcfdccccbbaabaaaaabaabbbccbbaaaaaaaaaabaaaaaaaaacfcaaabcbbaaababbcaabbbabbbbbaaacbabaaa####a##.########a#abd##baaaaaa##.###aa#######abbadb#a#########aaeiib####bca#aabadcba########aabccdgghgfeddddeedegdaaabdedbbaaabbabbaaaaa#cbaaaaaaaa#a##a#aaa#abbbbaaa#aa##aaaaaaa#####aaabaabbbbccbbbcdecef######acaa", +"baabcccddedddbacccbccdcbbbbaa####aa##aaa###a###aaaa#a#####aaaa#a#aaa###aaaaabbbbbabcgjfdccbbbaaaaaaaaaaaabbacccba###aaaaaaab##aaaabbbdfdbaabdecbbbabaabbbbbbbbbbbbababbaaaaaa######.########a#acdb#aaaaaaa######aa######abbccb####aa######afiifa###bca#aaaabcbba#a######aaabcdeefcbcedccccceffaaaaacdbaaabbbaabbabaaabcbbaaaaaaaaa##a#a##abbaaaa#ba##aaa###a####aaaaaaaaaaccbbbcccdeff.######aaa", +"a#aabbbcdeddcccbcccccdcbbabaaaa##a###aa#a#a#####aa##a###a##aaa####aa#a#a#aaabbaabbbbbffdccbbbabbaaaabbbbbabcbbbaaa##aaaaaaaaa###aabcbbcdfdaacebbbbbaaabbbbbbbbbaaaaabbabaaaa###aa############abcdcaaaabbaaa######aa#####abbbdc#############adghf###cdaa##aaaabbaa##.##.##aaabcdecedbbcdecbbbccebaabacdaaaaabbbbbbbaaaaabdcbaaabaaaaa##aa#aaabaaa#bcaaaaaa###aa#a#a#aaaaaaaaababccdceec##########", +"###bbbbcdeddddcccccbccbccbbbaaa#####.#a##aa######a##aaaa###aaaaa##a###aaaaaabbbbbbbccddcdcbbbbbcdbbbadecccccbcb###a###aaaabaaaa###accbbccfhcacbbbabbabbbbbbbbaaabbbaabbbaa####aa#########.####aabcbaaaabbaaaa#####a#####aabacfb###############dhhc.ddb###a###bbca#.#....##aaabcdccecbbccedbbcccedbabbdcbaaaaaaaabaaabaaaacccaabaaaaaaaaaaa#abaaabbcaaaaaa###########aaaaaaababbbceeda.#####a###a", +"#baaabbcdeddddddddbbcccbcbbbbaaaa################aaababba####aaaaaa###aaaaaaabbaabbdecbccccccbbbccccbcbbbcbbddeeca###aaaabccaaaaaa##abbbbcdedbbabbaaaaabbbbbbbbaaaaaaabbaa#######aaa##########aabbbaaabbaabaaa########aaaaaabdfb####aa#########cghhceba###a##aabaa#.....###aaabcdceebbbbbddcbccbcdcabcedbbaaaaaaaabaaaaaa#cddbbbaaaaaaaaaaaaaaaaccbaaaaaba#a#a######a##a#aaaaaaccdeed####aa####a", +"aaabaabccceeddeedcabbbcbbcbbbbbbaaaaa#########a##aaaaabbcbaa#aa#aaaaa#aaaaaaaaaaabbcddcbbbbbbbbbbbbbabbbbbbaabbdgfba#aaaaabbaaa##aaaaaabbbcceedaaaaabbabbbabbbbbbaaaaaabba#######aba#########a##abbcaabcbaabbba########aabbaabddca#aaaaa#########adjhaaa#aa#####aaa#...####aaabbcccfdabbbbbddcccbbccacffccbaaaaaaaaababaaa##bccccbabaaaaaa#aaaaabdcaabbaaaaa#########a#a#aaa###bcddhga####aa####", +"##aabbbbcdffeddeebdcbbbbbcbbcbcbaaaaaa##.##aa######aabbbbaaaa#aaaaaaa##aaabb#aaaaacddfbcbabbccbccbbbaabbaaba#abadfdbbaaaabcaaaaaaaaabbbababbceedaaaabbabbbbbbbbbbaaaaaaaaa##.#####aa#########aaa#aacdabbbaaaaaaaa#######bbbbccdcddbaabbaaa####aa###bhgea#######.##aaa#####aaaababbbcebababbabdeccbbbceffeecbaaaaaaaaabaaaaaaa#bcccbbbbaaaaaaababbbbbaaaabaaa#######a##a#aa#aaaaabddhg###########", +"#a#aaabcdddffdddeeedbbbbbcbbbbcbbbaabaaa#a##a##aacaaaaaaaaaa#a##aaaaacdaaaabaaaa#accdeaaaaabbbbccbbbbaaaaabbbababcdddcccbbaaaa#aaaabbbaaaaaabdeeeaaaaaababbbbbbaaaaaaaaaaaa###a####ba####a####aaaaaabecaa######aaa#####a#ababccccbcbabaaaaaaa###a####dijdb########a#a###aa##a#abbbbddbaaaaabbabdddcfeffffeccbbaaaaa#aaaaaaaaaa#abccbcabaaaaaaaabbaaababaaaaa#aaaa###aaa#aaaaaaaaabchga#####aaa##", +"#a#a###abccdddefdeeecbbbbbbaabbbbbbbbba#########abaa#aaaaaaa##a#aaaaaccbaaabbabbcbbccfbcaaaababbbbbaaaaaaaaaaaabbbabbabaabaaa#aaaaaabbabaaa#abcdfea#aaaabbbbaaaaaaaaaaaaaaaa#######bba##########aaaabcedbb#######aa#####a##abdcbbccbaaaaaa#aaaaa#aa###bgjjga#######aba#aadba##aabbbccbaaaaabbaaabedffeffffdcbbaaaaaaaaaaaaaaaa#aaaccbbbaaaaaaaaaaaababbbaaaa#aaa#####aaaaaaaaaaabbbghc#####aaaaa", +"a##a#aa#aabccbdfgeefeccababbbaabaabbbaa#a##.######aaaaaaabba##aa##abbbcbcbbccacbbdedgheccbbabbaaaaaaaaabbaaaaaaaaaaaaaaaaaacbbba#ababbbbaaaaaaabdeeca#aabcbaaaaaaaa#aaabaaaaa####.##ba###########aaabbceeba########a#########cbbbabbbaaa#aa#aaaaaaaaa###djkjb#b#..#abbcaaabcba##aaabbcaaa#aaaaabaacfffffedffccbaaaaaaaaaaaaaaaaaaaabcbbaaaaaa##aaaaabaaabaa#aaaaaaa#a#a#a#aaaabbbbccgc######aaa#", +"##aaaaaa##aaccbaeihfgggcbabbbaaaaacbbceceeca########aaaaaabaaaaaaaabbbdcccdebbcbbabacedecbbbabaa#aaaaaabbbbaaaaaaaaaa#aaaaa#abbbbacbbbbbbaaaaaaaccddbbbbbbbaaaaaaaaa##aaa#a##a#####aa#############aaabbceeea########a########aaaaaaaabbaa###a###aaa######agjkhgfb.#aabddaaaaaaa###aabdb##b###aaaaa#cffffeeeeeccbaaaaa#aaaaaaaaaaaaaabcbaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaabbbbbdfeba####aaa#", +"#a#aaaaa###aacca#cjjhhjebcbaa##a##acegebdcbdb#.#cbcaaaaaaaaaaaaaaaaaabbcdgiecbbaaabbbcbcdcbbbbbaaaa#aabaabcbaaaaa#aa#aa#aaa###aaaaaa####a###aaaabcddbcbbbaaaaaaa#aaaa#aaaaa##a#####baa#.#######a##aabbcdddffa##.####aa##.####aaaaaaaaaabaaa###########a####chhiihc..ceffbabaaabaaaaabccaacc###aaccbbegfffededdccbaa#a#aaaaaaaaaaaaaaaabcbbaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaabcccefeaaa###aa#a", +"aaa#abaaaa##aaba##eiiikhccbddefeeffgecccdccdeffefddc#aaaba#aaabaabbaaaabcdhfbbbbaaacdecbbaabbbcbbbbaaaabbbbbbaaaaaa#######a###aaa#aaaaa######aaaaaccbcbaaaaaaa####aa##aaaaa#####a##############a##aaabcccccdfb##.#####a######aaa#aaaaaaaaaaa##########aaa##.#aejjifb#cffacbbbaaa#acbbcc##ddda##cddeefgfffeedddcabbaa#aaaaaaaaaaaaaaaaaaacbbaaaaaaabbabbbcaabaaaabbabbbbabbbbbbbbbbbdfc####a##aa#", +"#aaa#a#a##a####b###dgkkjgccfiifdfdeeccddddcdcccccbca#aa##aa#aaaaabbbaababeggdbaaaaadfcbbbbbbcccbabcbaaaaabcabbbcbaaaaaa##########a#a########aa##a#accbbaaa#########aa###aaaa###aaa####.#########b##aabcbbcddfb###############aaaa###abbaaba#aaa#########aa#####djjjifbcebccdcba#bbacbcb##addccdcdeeefgfffeecbccbbbaaaaaaaa#aaaaaaaaaaaaaabbaaaaaaabaabbbbbaabababbbbbbbbbccccbbbbcced####a###aa#", +"a##aaaaaaaaa#a#ba..#agkgfecfikgddcccdcccbcccbcbcbbdba##bccaaa#bbccccbaabbefffcaaaabdfbbbbbbbbccaaabaaaaaaabcbbbabbbbaaaa#######aaa############aa###abbaaa####a############a####a#######.#####a##aaa####aaaacfa#######..######aaaa###a#cdcbbbabcbaa#aab#########.chiiihfcddeghhgdccdabdaa#addcddceefeeffeeeedbbcccbbaaaaa#aaaaaaaaaaaaaaaaabbbbaaaaaaabaabbaaaababbbbbbbcccdccdcbbceea####aa###aa", +"a####aaaabaaabbab#.#aaeecdhfijfcccddcccbbbbccbbbccaaa###.a#abccccbcbcbbbbbff#a###abcebabbbbccbcaabbaaaaabccbbbbbbbbbbbaaa#aa####aa##############aaaa#ababaa##############a#a######a####################aabbcacaaab#####.#.##abbaa###aaabcacbcaaaaaaa#aa#########.bgihiifcdgijjjiidaaabe#a#bdcbccccddddddecdecbbbccbbaaaaa##aabbaaaaaaaaaaabbbbbabbbaaaabbbbbaaabbbbbbbccdddedddefeffa####a#####a", +"#######aaaaaaaaaa#.#abcdaahkkjgbbcccbbbbbcbbcbbbbaaaa#a######abddedccccbbacffcbb##acccacdcabbdccdbabaaaa#abbbbbaabbbbcba###a############.##.###########ababaa##################a##a###.################aaabcbcdbbbaa##.#.#.#aabaa###abcdcaabaa####aa#aabbb###a###.#bgjhacegijjjjjjhedfgea##cbbbccbbbcccccdcccbbbccaabaaaaaaaaaaaaaaaaaaaaaabcbabaaabaaabbbbbaababbbbbbccddddedffceedb######aa###", +"aaa#a####a##aaa##a.##acda#cejjfdbbbbbabcbaabbcbbaa#aaa##a#a###baecbdfedddefhhgefea#cedbafecbbcbecbbccbbbbabbbbbbbccabbcdcaa####################.#######aaaaca##########################.########a######aaaaccccbbca#a########aaaa####bedcaabaa##aaaabaaabc########..#figefhikjihhhhiijiihd##bbcdbcccbcccddebcbbbbcdbaaaaaaaaaaaaaaaa#aaaaaabbcbbbbbbbabbbbbbbabbbbbccddedeedffa###a#####aaaaaaa#", +"###aa############a#.##bccbbbbehhaabbbaaabbabbcbaba#aaa#######becdda#fgecddeehghegdabdecaabedbcaacbbddbbbbbbcbbbbbbdbaaccccba#########a################aaaaabcaba###############################a#####.###aaaabccbcb##a######aab##a###accbca#b#####aaaaaaaaa###.####...diihiiihfgeffeffhijid##ddcdccccccddddccbbaabddcaaaaaaabaaaaaaaaaaaaaaabbcbbabbababbbbbbbabbcbccdddedefc.##########aa#aaaa#", +"#aaaaa#aaa##a######.#abbccaaaabgfb#ababa#aaaacbaaaaabbbab####edeefeccgedcddehhfacebadecaaaabcccbbbbcbabbbbbcbbcbccccccabccdb#######abb###a##############aaaacbccba##########a######.########a###a#########aabcceccb###a#####aaaa##aaaaacbb##ac######aaaaa##aaa#######..diihffffffdeddddefiigaaeddddbbcdddccdccbaaabcedbbbaababaaaaaaaaaaaaaaaabdcbaabbababbbbbbbbbbbbcceeegc.#############aaaaaa", +"aabcbbaaaaaaaa########bbcdbaaaaaffa#aaaaa#aaabbaaaabcdeddabaefcdddefcgfddddeghcccffddbaaabbbbbccbccdbcbabbbbbbcbbbbbdcabbbddb########bca#a#######a##a###aaaaaaabdbaa#aaa####aca##...###aa####a##a########aaabbbdecc##aaa############aa#abba##a#########aa#aaaaa########.bgiedcccdccccccccdhigdeeeeedcdddccbcebaaaaaaceebbbbbbbababaaaaaaaaaaaabcccccfedcbbbbbbbbbbbbabcfffe############a###aaaaa", +"a#aaedbbbbaaa#a#######abddca#aaaadcaa##aa####aabababbbccccfggcbcccccfgeccccdddffedfecddcbbbbccbbccdcddbbbbbbcbbbaabbcc#abaacba########aa##..#######aa####aaaaa###bbaaa#aaaaa#cc###a.####aa##aaa#########aaabbbbadcdaaabba##########a#aa#bbaa##a#######a#aa#aaaaaa#######.ageccbbbbbbbbbbbcbehigffeedddddccbcccbbaaa#accdcbbbbbbaaaaaaaaaaaaaabbcbccdbaadfdcbbbbbbbcbcefccba#################aaa#", +"#aaacbaabbcbbbaa#######abcca##aaabbcba########abbaaabaabccdcbabbbccbcedccccccccccccedbbcdbbbccbcbbcbcbbbbbbbbbbabbbbcccbbaaaaaa##a####a#aa####.#####aa##a#aaaaa##abbcaaaabbbabcaaa#.#.###aa#a##a########aaabccabbddbaabaa####.##.aaaaaa##bba##############aaaa##a########.#bddbbbbbbbbbaaaaabfhhgfeedddccbccbdabaaabbbccddcbbbbbbaaaaaaaaaaabacbbcceb#a#babcbbbbbbcbce##.####################aa#", +"aaaaaa#aaaababba#######abcccb#a#aaacddb######aaaaa#aaaaabbbbbbbcbbbbcdcbcbccbccccddbababcccccccccbbbbaaabbbbccbdcbbbbabcbbaa######aa#aaa############aa#####aaaaa#acbabaa#baabbcb#a##.#####baaa#########aaaabcdcccccbaaaa##########abaaa###aa##############a####aaa########.##dcbbbbbbbaaaaaaaabghgffedccccccbbcabbaaabbcbdedbbbbbbaaaaaaaaaabaaabccdecbcabbbcbbbbbcbeea###aa####################", +"aaaaaaaaaaaaaa##########acceeba###bbbcda#######a####aaaaabbbabbabbbbbcccccccccbcbbcdcbaabbcbcccccbbbbbcabbbbddegebbbbbbbcaaaaa#########a######aba#####aa#####abaaaabcbb#aa##abaaba#####a##aaaaa######aaaaaaacccccbccaa##a#######aa#aabaa##aaa####aa########a#aaaaaa###########addcbbbaaaaaaaaaa#fieeeddcccbbbbbaaabaabbaaabdedcccbaaaabaaaaabbaabbbcdebaaccbbdddcbbcdc#aaaa###########.########b", +"aaaaa#aaa#aa#############abcdfdaaaabcdf###aaaa##a#####aaaaabbccabbaaaabbbcccccbcbabbccbbbbbbbbbbbccbbcccbbbcdcdedecabbbbaaaaaaa########abb##aa#aaabaa#aba###a#aa#aabcccbabb###aa#aaa######aa##aa######aaaaaaaccccdaba###########aaa#aaba#aaaa#aa##a########aca##aaa######a######cffaaaaaaaaaaaaa#ehfeeedcbbbbbbcbaabbbbbbbaadeeefedcbaabbabbccbabbdcbcaabdcccccceedffb##aa####################a#", +"aaaaa###aaaaaa#####.####aabccfgbaabbcfeda##aaabaaaaaa#aaaaaaaccbccbaaabcccbbccbbbbbbcbbbbbbbcbbbbbcabcccbababccdeccbabbbbaaaaa#aa########aaaaaaaabedaa##a#aaabaaaaabaccbaaaca###aaaaaa#####a###aa###a##aaa#aaaccbbabaa############aaaaaaaaaaaaa#########a##acdaabaaaa############acecaaaaaaaaaaaaafhffeddcbbabbcbbabbbbbbbbaabbdeddfeddbabbbdcabbabbababbbcbcbccddffcdaaaa##a###################", +"aa#a#####aa#aaaa#########abcdcfeaaacbdccfcbbbdddbbbbbaaaaa#aaaabcbaabbbcccbbbcbbcccccccccbbcbcccbbbbbcccbbabbacddedcaabbabaaaaa##aa########cb##aa#cfdaa##aaababbbbaaaabbbbaabaaa#abaaa#####a#bbaaaa##a##aaaaaabbccdaaaaa#####bb#####aa##aaaaaaaa############aabbbbaaaa##aa##########deaaa###aaaaabcgiggddccccccccabbbbbabbaba#aabcaacccccbbcdbaacbbabbbbabcbcdddd####abaa#a##a#a#aa############a", +"aaa#####aa#a#aaaaaaa######abccdfa#bbcddbcccdcdaaccdecbbbbbbbaabccbaaabbcccbbbccbccccddccccccddccbbbbbbcccbbbbbcccdddbabbbabaaaa########.####bba##a#aca###aaaaaaaaaaaaaabbbaabaabaaabba#######ababba.##aaaaaaaaabcdcb#aaaa#####a##########aaaaaa#a####aaaa##.##abbba#aab#aba#aa#a#####cgeaa####aa#aabfiigdccccbccccbbbbaabbbbaaaaaabccbbccccdabcbccaaaaabbbccdebdbaaaaaaaaa#a######aaaaa#########", +"#aa#a###aaa####aa##a#####aabbbbeb#abbceeba#a####aaaba##cdbbbcccdccbbbbbbccbbabcbbbcbcddccccccddddddccdcabbbcbccbbbddcbbbbbbbaaaa#########.####aaa####a#a#aaaaaaaaaaaaaabbbbaaabaaaaaaba####a#.a##ab##.a##a##aaaabbddb##aa#####aa######.##aaaaaa#aa####a#aaa###abbb###acaacaaaa##a#####bff###a##aaa#aacghhfccbcbcbbcbbbbbbbcaaaabababbdccccddbbccccaaaaaabbccee##aaaabbacaaaa######aaa#aaaaaaa###", +"#aaa##########aaaaa########bbbbbea#babcea#a######aaa####bccddcddedcccccccccbcbccbbbcbcddddcccbbbcccdefedcbaacbbcbbbbbbbbababaaaa############.###aa#a##aaa#aaaaaacbba##abbcbaaa#aaa#aa#########a#######a##aa#a#abbcbcc#a############aa####aaaaaaaaaa#######aa###aabaa##bbaaaa#a##aa######dea#####aaaaaa#behhdccbccacbbbbbbbcbbbaabbabbbcdcccdddbbbba#aaaaabbddb#######bcaaaaaa######aaaabbbaaaaaa", +"aa#aa##########aaa########aabbbbbedbaabddcb#aaaa#aaaa####cccaacdeeggecccccccbbabbbbbbbbccddcccbbbbcbcddeedcbaaabbabbbbcbbbabaaaa###########.#####aba#######aaaaaabbba#aabbbbaa###aa##a#####.#a#.#.####aa##aa#aaabccbca#aa#..########a######aaa##aaa#########aaa#aaaaaabcaaaa##a##a###a#a#bdb#aaaaaaaaaaabcfhfccccabbcbbbbcbcbbbaabaabbabcddcdcccbba##a#a#abddb########aaaaa#aaa####aaaaaaaabbaaa", +"aaa#aa##########aa#a#a#######abbabgebaabacca#ba#aaabaa#########a##bdeddeedddcbbbbbbbcbabacdddcccccbbbcdcdcdcabbbbbbababbbccbabaa###############aaabb####aa##aaaaabbbaaaa#abbbaa###aaaa###a###a##....###a##aa##aaabbbca##aa#.#######aaa##aa######aaa#########abaabaaaaaacbaaaaaa##a###a##a#afb##a##aabbbaaaaeggecebcbbbabbbcbbabaabbbbbbabbdddccccccabaaaaaaccc#####a#aaaa#a#####aaaaaaabbbaaabaa", +"aaaaa############aa#a########.#abbcffcabbceccaaaaaaaaa###a###aa#######aaeebccccccbbbbcbbccbdddccccccbbbccbbbbbbbcbbabbbbbccbbbbaaa########.#aaa#a##aba#aa##aaabbbabbbaaa###abaaa#########aa##a############aa###aabcc#aa#aaa#######.##aaba#aaaaaa##aaaaa######baaaaaaa#aaaaaaaaaa###aaaaaa###ebaaaaaaaaaaaaabbfhgedbbbbbcbbbbbbabbbbbbbabbbbddecbcbbbbbbcbbbceaa#####aabca#a#a#a##a#aaaaaabbbbbaa", +"aaaaaaa####aaaa#aa###########..#aabdddbbcccccaaaaaaaaaa##a##aaa###aa#####eddedddcddccbccbccccbbcbbcedbbcccccbbbbbbbbababbbcbbcbaaaaa############a#a#aa#aaaaabbaabaabaaa#aaa#abaaa#######aaaa#a###########.#aab##aacc#aa####a######..##aa#aaabbaaa##aaaaaaabbaabaccbaa###aaaaaaaaaa##aaaaa##a#ccbaaaaaa###aaaadgggfeababbcbcbcbbaabbbbaaabbbccddbcbbbbbcdccccca#a#a###aaaaaaaaaaaa#aaaaaaababccba", +"aaabaaa#a#######a#aaa####aa###.###bcdcbcbabddbaacbbababaa#a##aaaa#aa#aacdccbddddddbbbbbaa#aaa######bfggfdcccbabbbbabaaabcbccabbaaaa#########a#aaaaa#######aabaaabbabbaa####aaaabaaa##aa##aaa#b####.#########abb#aaee##a###.##.##.###..####abccccbaaaaaaaaabcdaabbccba##a#aa#aaaaa#a#aa#aaaaaaaabebaaaaa#a##aabbfghhgedaaabbbccababcccbbbaabccbcccbbcbbcdcdcaaa########aaaaaaaaaaa#aaaaaaababbccb", +"abaaaaaaaaaa######aaa########aa####bbccbbaabceaa#cbbbbbba#a##aaaa#aa###debacb#aacabaa##aa###########.#afhgeecbccbbbabaacbcccbbbbbbaa#a#########aa#aaaa####aaaaaabbbbbbbaa###aaabbba###a##aaa###.#######ba##aaadbaabeaa##aa#..###.##########abaaabdbaaababababbaabddbaa##aaaaaaaaaaa#aaaaaaaaaaa#aecaaaaa#aa#aaabdghhhfecccbcbbabbacccccbbbbbcbbbbbcbabbdcbcba########aaabaaaa##a###aaaaaaaaaabbb", +"baaabbaaaaaaaaaaaa###########aaa####acccbaaaabcbcabbbbbbba#####aaaba#acbcaa#aaaa#abaa############.#####.dhihgeefccbbbbaabccbbbbbbaaaa##########a#aa#aa####aaa#aabaabcbbaa####a#aaaa###a#aaa################abbeebbbdd##a#######..####.######aaaaabcbbbbbbbbbbb#abcccbaaa#aaa#aaaaaa###aaabaaaaaaa#bcbaaaaaaaaaaaabehhhfedaaabaaabbccccbabbbbccbbabccbbbdcbbaaa#######a#aabaaaaa#aabaaaaaaaaaaabb", +"bbaaaaaaaaaaaaaaaaaaa#########a#a####bbcbaaaaabeecbbaaabbaba###a#aaa##cedb#aaabaaaaa##a#########.##.###a#bfgedeffdccccbaaacdccccbbaa###########aaa######aaba###aabaabbbaaaa#####aa#a##abbaa####.##.####aaa#acbddddfega#a#######.######.##a#aaaa#aaaaaaaabccddebaba#bcba##aaaaaaaaab#aaaaabbbcaabaaaaccaaaaaaaabaabbehhfgebaaaaaaacdcccaabbcbbcbbbbbcdcbbcaaa#a######aa#abbaaaaaa#abbaaaaa#aaaaab", +"bbbaaaaabbbaaabaa#aaaa###.#######a####abb#aa#a#cfecaabbaaaba#######aaa#bddcdaaabaaaa#a#aa######.########ba.a####bfddcccbbacdccccccaa############aaa######adb###aaaaaaabaaaaaa###aaaa##abaaa#####..#####aaaaabbcdeedfgd#aa########.#######a##aa#aaaa#a###a#abeedecc##aaba#aaaaaaaa#bbaaaaabbbbaaaaaaaaaccbaabaaababbadgggfdb#aaaaaabcbbbbbbccccdcaabbcdcccbaaa#######aaaaaaaa##aa###aaaaaaaaaaaba", +"bbbbaa#aaaabaaaaaaaaaba#a######.#######abbbca##acdedcaabca#a#.###a######bddcfcaabaaa##a##a#####...##aa####a####a#abbccddcbbddedccccbaa####a######aaa#####acb###aaaaaaaaaaaaaa###########aaa####.####a##aaaaacdeceeeedc##aa########..#########aaaaa##a###aaaaaabcdedcb##aa#aaaaaaaaacbaaaaabbbbaaaaaaaaadfdaabaaaabbbbcdggfebaaaaaaacccbbbbbbccdcccbbbdcecba#####a####abbaaa#######a#aaabbaabaabb", +"bbaacbabaabaaaabbaaabbaabb#.####.#######abbcba#aabecdbaccaa#a#.##aa##a###acacecbaaaaaa##########..######..abaa#aa####aceeddceggeddccbaa##########a#aaaa##aaa##a##aaaaaaaaaaaaa#########aaa####a#aaa####aaaabbdffffgebca#ab#######.#..#aa######aa###aa####aaaa#baabbdcc##b##aaaaaaaaabaaaaaabbbbaaaaaaaabcegcabaababbbbabgfgfdaaaaaabbabbbabbbcdddbcbccccdbaaa#a##a###aaaaaaa#########abbbbccbaab", +"baaabbaaababaabbaaaaaaaaaaa##############abbaa##aadd##abbaaaa#.##aaa##a####aabcbaaa#aaa###a######..####.#..cdcbbbaa###abdcdedfghffddcbba###########aaaaaaaaaaaaaaaaaaaaaaa#aaaa########a#aaa#####aaa#a#aabbccddghhhfcca#aa##########...##########aa#aa###aaa##aaaa#a#bb####aaaaba#a#aaaaaaaabbcbbaaabaaabbefdabaabbbbbbbbfgggfdcaaaaabbbbbbbccdbdbcbcccbcbba##aaaaaa###aa#aaaa########bbabbbbaaa", +"aa#a#aaaaaaaaaaaaaaaaaabbabaa#######.#.####aaaaaaabdeb#aababaa####aaa#abba#####aaaaa###a##bdba##a######....acdbabbaaaa#####cddaeggffedcba##########aaaa###aaa#abaaaababaaaaaaaaa##a###abaaaa###.#bbaaaaabdcddeefhhifdda#bb#aa##aa######..########ab##a###a##a#aaaa#abaabaaa#aaaaaaaaaaaa#aaaababbbbaaaaaaabcffbbbabaabbbaacefggdba#aabbbbcbacddccecbbbcccbba##aaaaaaaaaaa#a##a#a#######aaaabaa#a", +"ba###aaaaa#cbaaaaa#abababa#a################aabbbbbbbea#aaabbaa#####a##adc##aaaaaaba##a####a########.#####...aca###########.####cffdcdecaaa#######aaabaa##aaaaaaa#aaabbbaaaaaabaaaba##babba######accbbbbbfccdeegdgfggeb#dc#####aaa#####...#######aaaa#aa##a#aaabaaa#bbaaaaa##aaaaaaaaaaaaaaabaabbbbbaaaaababbegdbbaaababbaabffffecb#aabbbbcbbcdddecbaabcbaaba#aaaaaaaaaaaaa###a########a#abbaabc", +"a#######a###aa#abaaaabbccba###.##############abcbcbbcbea#aaaaaaa#######.##ba#a#aa#a#a#a##a####.###########..###ba##############a#aeedbadfcdddcbb##aaaaaaa#aa#aaaa#aaccbbbaabbbbbabcbbcdccb######abcdbddeeefddddb#afdcfebdca#####aaa######.#####aaca####abaa#aa#abcb#accaaaa##aa#aabbaaaaaaaaaaaabbbaaaaaaabbbbbgdbaaabbbbaaaccffgfdcaabbccccccddddfcbaaaaaaaaa#aaabbaaaaaa#a#aab####aa##aaa#bcc#", +"aa###########aa#aaaaabbabbaaaa##..###########abdcccccbcdcaaaaaa#a##########aabb#abaa##########...#.########.######################.bfdaaccefddddbaaaaaaaaaaaaaa#aaababcccbbbbbccbbcddcabca####aaacdcabeggfdda.##.#cc#aefdbaaa###aaa###.##.####aaaaa#a###abd##a###ababbdc#aa#aaaaaaaabaaaaaaaaaaabbcbbaaaaaaabbbbgfbaaabbbbaabbbcefffddbabbcdccccedcabaaaaaaaaaaaaaaaaaaaaaaaaaaa#####aaa#aaaaaaa", +"aaaa##########a######.#a#abbaa##########a####abdedcccccccba##########a######aaaa#abaaaaa#######..################aa#aa###############ddabedcgededbbbaabbabaaaaaaaaaaabbccccccbccdddba###abacbbcccba####aaaaaaaa##.###acfcaaa##aa#a############aa#####a#a##aea#aaa#aabbcda##aaa#aa#aaaaaaabaaaaaaababcbaaaaaaaabbbgfbabbbabaabcdcbdefffdbbcccccccdda#aaaaaaa##abaabbaaaaaaaabbbaaaa####a##aaaabaa", +"aaaaabaa#######a###a##.###abbaa###############acdeccbbccdga##########a######.#aabaaaaaaaaa#a############.###aa###aaaaa###############.cdbbdefhhhfdccccbbbaaabaaaabbbbbccccdddcdccdb#####bbcbcddba####aa####a#a#####.##aedaaaa###aaa#######..#########a###a#bbbbbaaabbbbaba#aaaaaaa#aa#aaaabbaaababbabccbaaaabaabbbggdabbbbcbbbddcbcbdffdcaccccacccd#aaaaaaaaaa#abbbaaaaaaaabbabbabaa#aa####aabaa", +"aaaa#aaa##########a###.##aaaaaaa####.##aa#####abccdcaabccffa##########a###aa####aabaaabaa#aaa####a######..###a#####aaa############aa###bdddeeddfgfeeeddcabaaabbbbbbbbbbcdddddeeeecaa####abbaaaa#######a#a########.###aaadaaaa#####aa########.#..##.##a######aaabbba#bbca##a###aaaaaaaaaaaabbaaaabbbaabddcaaaaaaaaabfgdaaabbbabdacdbcbdfffdbbdccbc#cbaa##aaaaaaa#aaaaaababaaaa#abbaaaaa#aaaaaaa#a", +"###a#aaaaaaa######accbaaab#####aaaa####a#######accccabacccfe##.############aa####aa###aaa#aa####.#########.##########a############abca##bfcfabbbcaafffffdbbbbbbbbbabbcccdeeedefcaaaaaa##aaaaaaaa################a#.###abbcaa#aa#aaaaa#######....########aa####a#abba#bbbbaaaaaaaaaaaaaaaaaaabcabbbbbbabeedaaaaaaaaacfgecaabbabbacdbabcffffccccdda##aaaaaaaaababaaaaaaabaaaaaaaaaabaabaa##abb####", +"a########aaa#######cddebba########aaaaaa#######abccccbabcdefea#.########aaaaabb##aaa#####aaa##.....#.##.##############a#####.#####aabcbaabfc######.afggggcbbbcbcccbbbccceeeeffhgccbaaa#aaabbaa#a######aaa########a#.##aacdba##ab#aabb##.#.####...########aa#####aaaaaaaabbaaaaaaaaaaaaaaaaaaccbabbbbbbabefdaaaaaaaaabeffabaaababdedabbcfffecccddaaaaaaaaababaaaa#aaaabbbaaaaaaaabbaaa#aa##ba###b", +"#####aa#####aaaabbaaaacdb.#a#########aaa########abcbbbbbcdeeeefc.######aaaabaacbaaaaa##########..#..#....##############a###########abbbba#bd#a######aabbcfedccdddccccdddeeeeefgiedeebaaaaaabaaaa#aaaaa#aaaa###########aabcca##aabaaabba#....#....##.###.#aaa#######a#abaabbaaaaaaaaaaaaaaaaaaddbbbabaabbbddaaaaaaaa##adfecbbbbacddedbbccdffdccddaaa#aaa#bbaabca##a#aaabbaaaaaaaaaaaabb#aaaa###a#", +"####aaba######aa#abbaaaba###aa#############.####aabcabcbbdegfebc.########abbbaaaaaaaaaa#########.....#.#.######.#######aa#####.#.##aaabbbbbc##a#######..##ehfeeeedddcedeffeeeeehf#abcecccbabbbbbaabaaaaaaaa########a###aacdba#aaaabaaaaa#..##..##.#..####aaa##a####aa#aaaabaaaaaaaaaaa#aaaaaabeeccbababbbbbaaaaaaaaaaaabcffbbbbcdccdcbbbcdfgfedcabaaaa##bbababa#####abbaaaaaaaaaaaaaaaa#aaaaaa##", +"#a###aabaaaa###ba###ab##ba###a#############..###aaabcaabbdedefgb####aaa###aaaaaaaaabaaaa###########...#.############################aabbbadcaaa#####.######bfhhgggffffffffeeeefhhcaa##acfffeedddbaabaaaabaa########a####abebaaaa#a#a#aa############.###..#aa##a###aba##aaaaba#aaaaaaaaaaaaaaaaccdcdcbbbbabbbaaaaaaaaaaaaacfeaabbbbccdabccbdfffed#aaaaabaaaaaa#aa###aaaaabaaaaaaaaaaaaaaaaaaaaa##", +"###aaa#aaaa#a##.a##a#aba#aa###########.#.#....####abcbbbbccdffegb...##aa###abaaaaaaaa#a#aa#######aaa###.####.#####################a##abbcfda#aaa###########.#acfhihhhijiiiihgfhhgcaaaa#..acccddccecccbaaabcb#######aa###abcdbaaaaa#aaa#aa##########.##########aa##aaa#aaaa########aaaaaabaaabbaaababaacbbabbbaaaaaabaaaaa#cefdabbbabbcbbbccdfggeb#aaaaaa###aaa#a###aabbaaaaaaaaa#aaaaaaaaaaaaaa#", +"#aaaaaaaaaa##aaaaaaaa#aaaaaa##.###aa###.###...####aabdbbabbcfeced.#########aaaba#aaaaaa##ca#######aaaa######.########.########a#####aaabdhgfeaaaa#############.#aaba#addfghiiiiheb###aaaa###.####bdbcdcdcbbca##a##a##a##aabbdbaa####aaaaaaa#############a#.##aaaaaaaaa##aaa##a#a#acbaabbabbbaaaaaaaabbbbbaabbbaaaabaaaaa#a#bfgebaaababbbbbbbcggfeaaaaaaaaaaaaaaaa####aabaaaba###aaaabaaaaaaaaaaa", +"a##ba#abaaaaaaaa####aa###bbaa##.#######b#####.#.###aacbbaabcdeccc##.########aabbba#a##aaa#bba######aaaaa#################.######aa##aabbfhhihdabaa##############aa######.##a#bgfb###aaaaaa########cbacccdfeecaa###aa##a#aaabcdbab##ababaaaaa##########aaa#####aaaaaaaa#a#aaba##aabfdaa#aaaaabbbabaaababdbbbbbbbbbbbbbaaaaaaa#dffcbaabbbbbbbbbcefgdba#abaaaaaaaaa#aa##abbbaaacba##a###aaaaaa##aaa", +"aaaaaaaaaaaaaaaaaa#####a##aaaa########ab##.####..###aadccbbacdcaa###.######aabaaabb#aaaa###############aa#####a#####.##############aabbbehhhfcaaaa#####.########aaaa##aaa##a#.#caa####aa##########cdbbbbbcedefdcbbaa##aaaababbdbaaaaaaaaa#aba#########aa######aaaaaa#a#aa##aaa##addbbaaaaa#aaaaabaaaaaaccccdcbbabbbcbaabaaaaa#cfgdbabbbbabbbbbcfgedda#aaaaaaaaaab#a##aabbbaaaba#aa###a#aaaaaa#aa", +"aaaaaabaaaaaaaa#accb#########babaa###aaa##.##a##.####abcbccabdeaaab#..######aaaaaaa#####################aaa####a#####.############aaaabdgihgcbaaa################aaaaaaaaa#aa###a######a##########dbaaaaaaaacbcefgfddcccddegdcbdbaabaaaaaaaaaaa######aaa####aaaaaaaaa#############aaaaaaaaaaaacaaaaaaaaabbbbdeccdccbbbbaabaaaaabefecbbbabbbbcbcegededcaabaaaabaaaaaa##aabbbaaaa#aa#aaa#bbaaaaa#a", +"a##a#aaaaaa###aa#bbcbaa##aaa#aaaca##abb########a#####aacbbccbdeaaaba#########aaa##a#a####.################ba#########.##..######.bbabaaehhhgbaaaa#################aab#aabaa#aa###a##########a.###.ab#aa#abababbbcbcdcaacecccdefdc##abaaaaa##aa########aaba#aaa#a#aaaaba#a#aa#a##.##abaaaaaaaaabbabbaaaaaaaaaaccbbbcdbbbbaaabbbabbdgfdbbbabcbcccdddeeedcaaaaaaaabaaaaa##aabbaaaaa##aa####aaaaaaa#", +"####aaaaaaa######abbcca##aaaaa##abbabba#a#####aaa######aabccedfaaaab#########aaa###.#######################b########.#ba#...##.#acbccccfgggebaaaa##a###############aababaaaa#a##a#a####a##a########c#aaaaaaaabbaaaaabccdebabbbdgeaaabbbaaaaa##a#######aaab##a##aaaaaabaaa###aaaa####ba#a##aaaaaabbaaaaabbaaaaacbbbcbbbcbbaaabbbbcbcfgecbcbbbccddccceddccaaaaaa#bbaaaaaaaaaaaa#aaa##a#aa#a#aa####", +"##a###aaaaa#######aaaaaaaaaaaaa#aabbcaaaaa#a###aa########aabeeea###aaa#######aabb#####a######.#######aa##.######aaaabedccbbb##bbbbaabbbbccdeaa##a##a########aaa#####aabbbba#a#aaa#a####a###########caba###ababbbaabbabcdcddcbabehcaaaaaaaaaa############ab##aaaaaaaaaaaaaa#baaaaa###bb#a##aaaabbbbbaaaaabbbaabbbbcccbabbbaaaabbccccbfffcccbccccbccccddeedaab#aaaabaaabaaabaaa###aaa###bb##a#####", +"aaaa##aaaaa#aa#######a#abbaaaab######aaaaa#aaaa#aa#######aabdefb#aaa#bc#######abcb#####a#################aa#a..###aabcdfffggfdcbbbbbaaaaaabdeaaa###########aaaa#####aabbbbbaaa#aaa#####aa#a##.#####aaaaaa##abaabcbbbaaabaabbbbcdefaaaabaaaaaa##a######aaa######aaaaa#aaaaaa##aaaa###aa#aaabbbabbaabbaaaaaaaabbbbbacccbaaaaaabbccdccdefegffdccecbccccdeeddcbaaaaaaabbbcbaaabaaaaaa#######aa######", +"#aaaa##aaaa#############abaaaaaba##aaaaaaaabaaaaaba#####a##abdgca#aaadeb########bba#####aa#aaaaaa###aaa#ab#aa#.###.#acfhfddgccbaa#aaaaaa#abcfaaaa#######aaabbaaa#####aaaaaaaaa#aaaaa#aaaa##########aaaa#aa##aaa#acccabaaba#a###acdbaaaaaaaaaaa###a##.##aaaa###a###aaaaaaaaa###aaaa#abb#aaaabbbbbbbabaaaaaaaaaacbbbccbbbbaabaaacccccdfdbdfgeefcddabccbcedddccbbaaaaaabbbababbaa#aaaa#a##ab##a####", +"##aaaa#############aa#####abaaabda##abaaaababbaaaaba####aa#abbdeaaaaaadf###############a#aaabbbbba#aa#aaaa#baba.#accbffffgddcbbaa#####aa##acfeabaaaaa###aabcdcbba######aaaaaaaaaaaaaaa#aaa##########dbaa########bbdcaab#abaaa##abceaaaa#a#aaaaaa#a###.######a#####aabaabb#aa#####a#bcbaaaaa#aaaabbbbbaaaaaaaaaaccccbccabacaaaabceeeeggdcdfffccccca#bbcbddeccccca#abbbbbbbaaabaaa#a#aaaaab#######", +"##aaaa####.##########baaa##aaaaabda#aaaabbaaccbaaaa#####aaaaabbcbbaaabdgfe###aaa#######a##aaabbabbb#a#a#aabdceeedcabcaeddcfhecdb#########aacdhcbccbbbbbbbbdehhedba##aaaabbbbbaaaaaabbaaaaaaa########cba#######a#abbda#aabcbaa##aabceaaa######aaa##aa########aaa##aaaaaa#aaa###.###aabaaa#aaa#aa##abbbaa#baaaaaaabbbbbbdbbabaaaacaddacbbbbddccccbbda#cbbcdcddeccccbaabbbbca#aabaaaaaaaaaaaaa#####", +"#aa###a####.##########aa#a##aaabaccaba#aabbaccbaaaaaaaaaaaaaabbccabaabeffeebbcb#.####.#aaabbaabbccccccccdddcec.#aaaaaaadccbbcccca.#######aabdhecdddeeeddeefecbbeedcaaaaabbbbbbabbbbcbbaaaaaaaaaba##aba####a####aacdccaa#ccbbaa##aabcdaa########a##aa########aaaa##aaaaa##aaa#########aaa##aa#aba#aabbbaaaaaa#aaaaaabaaaccbaaaaabccababbbb###bcbcbbecabbccdcddcdcccaaababbbbaaaaaaaa#aaaaaaaaa###", +"#aa#aa##########a######a#####aaaaabc#abaaaabbcbbaa#a##aa#baaabbbbbabbcfffgghebdcbbacacbbbbbbbcbccdccfdaaabdedcaaabaaaaacccbbbbbbcb########abcfgedeffeeeegfcbbcbadgdddaabbbbbbbbbbcccccbbaabababbbaacbaa#########abcccbabccbbbaa##aabcb#a#######aa######a#a##abbbbabaa###a#aa########.bbaaa#aaaaaa#aaabbbccbaaaaabbbbbbbaaaaaaaaabbbccccaaa###bcdbabcbbbabcdddcbddccbbaaaabcccabaaaa#aabaaaaaaba#", +"#aaaaa#######a####a###aa##.###aaaaabc#abaaabbcbba###aa####a#aaabbbaabcdcdeccdecccccba##aaabbaaaaaa##beaaabacfdeaabdecb#bdcbbbbbbaca#######abcdegeeeeffgfdabbccddeehhhfdbbbddeeccdcccdccbbbbbbcccbcca##a###a########aa#.aceccbbaa#aa#acb###.#####aa#####aba###abcdcbcbaaaaaaa#####a###bc#abaaaa#aaa#ababbbbccbaaaaabbcccbcbaaaaaabccdacccb#a###abddbbbbbbabbcebcbbdcccbbaabbabcabaaaaabcbaaaa#aaa", +"aaaaaaaaaaa####aa#####aaaaa.###a#aaaccaaabaabccaa##aa#######aaaaaaaaadc##abaaaaa###a#######a#########cb#aaaacdddb#bbdda#becbbbbbbac#######abceffhffffda##babcccdeeddbddeecdcdebdeeccdddeddcccdeba#b###aa##a#########a###bedbbbbaa#a##aca###.#####aa####aaa####bbcdddbaaaaaaaaa#######adbbabaaa##aaaaaaacbabbccbaabaabbccccaaabbcbdcbcecccaa#a#a#adcabbbbbcbbcbccaabccdcbbbbcacbaabbaabcbaaaabaab", +"bdbaaaabbaaaa#aa##a#aba#############abcaabababcba##aa#########aaaaaaabdb##aaaaaa###a##################b####aaccdeaabcbbaaeddbabbbabb#######bdfhghhgda###aabbcccecbbbdcccefdbbcbcb#eefgghggfeegdaa##a###aa#######aaa#####bedcabbaa#####acb##########a##aaaa####acbccccaaabaabbbba####a##dbba#aaaaa##aaaabdababbccbabaabbcddcbacbbccdacdbba#####aaaabcbbbbbbbccbbababbcddcbabbbabaaabcaaabaaacabaa", +"aacdbaa##.##a##aa#aa#aba###.#########abca##aabbbca#..###########aaa##aab######aaaa#########aaa#a###aa#######aaccdfbabbaaaeeddbbcbbbdbaa#abcdfhjigca######abccbadb###cfbcbbecabbba#begfhggddcggdbbaaa##############a#aa#.cddccbaaaa#####ab##########aaaaaba####accbbbbaaabaabbbabb#######aba###aaa#aa#aaabcaaaaabccbabbcccdedcbdbbacdcdccaa##a#aaaaabcbbbbbacccbaaaabaccccbaaaaaaaabbbbaaaaababba", +"aababbaa#####a##a##a###a####.##########aba###abbbbba####.#.#######a###aab######aa#a#########aaa#####aaaaa#####bbceebbbba#ceedccedcegdcbcddedbcbed#######aabccdbdda##adeeb##abbaaaaacbadeddfdghdcbbbaaa###########abbbcdbbdcbbca##aa#####bd###.#.###aaaaaaaba##abbbbbbbaaaaaaaabbaaa#######aa###aaa#aaaaaabcaabb##abcbbaabcedccdcbaaccccba####a#aaababcbaaaabbccbbaaababccbaa##aa##aaabaaaaaaabaa", +"aabaaaaa#a#####a###aa##########..######aaba####aaaabb#.###############aaab##.###a#a#######aaaaaaaaa#a#aa###a##aacdceddfgfcfffgdccdeeefggdbaabbbbdcaa###aaabbcddeb##a#adfeaaaaaaaaa#bbaaccbeedhecbabbaaa#########.adccbcdbdbbcbba#######a#cda########abbaaaba##abbacbbaabaaaaabaaaaaa########aba##aaaaaaaaabcaaa#a##abca#aaabdefecbaadbbbaa##aa#aaaaaabdcbaaaaabcbaa#aaaabbbaaaaaaaaaaaaaaaaaaaaa", +"aaabbaaa#########a##aaa###########.##.##aaaa#####aa#cba################abcb.####aaaaaa##aaaabbabaabbbaaa##aaaaaccgghggecdfihhg#a####a#a#abbccccacdcabbbbbacccdfeba#####aaaaaaa###a#ababbccadcgedccbaaa############ccbabccbcacabaa#####a#bacd###.####aaaaaaa###aaabbccaaaaaabbabbaaaa###.##..#bbb###aaaa#aaaaaaa########a#aabccceecbbdbbbbaa#aaaaaabbaadccbaabaabba#####aaaabaabaaa##aaba#aaa#aaa", +"aaaa#aa##############bba##########..#.############aaaaaa#####.##########abca..####abaaaaabbbcccbbccddbbabbbbbcdefebdfd##a#.bedaa#########aabbbcbcddddcbbbcdeffd#########aaaaaaaa#aa#baaabcbacegedbbaaa##########bcdbaabbcccbbbaaaaa#####abbcca####.##aaa####aaabbcccdbaaaaaaabaaaaaaaa####.###abba##aaaa#aa##a############aaaa##cfebdcabcb###a##aaaabbabacbaaaaaba#a####aaa#aaaaaaa####aaaaaaaaa", +"abbaaaa####a##########aa###################aaa####abaa#a################aabc#.#####aaaabbbcdddcdfffefgffeddfgdcdcb####aaaa###bb#######a##aabacdcddbdccacdefecc#a##a#####aaaaaaaaaa##aaaaabbbabfgdcbaa########aaacbbbbabbbbcdaba##a#####a#abccda####aaaaa#aaa#abaaaccbbbaaaababbaa##aaa#########bbba##abaa#####aa#a##aaa#a###aaa##defdcabbbaa##aa#aaaabbbaaccaaaaab######aaba#aaaaab####abaaaaaaa", +"aaabaaa#################abba###############aaaaa##aaaaa#a###############aacaca.#####aabbbbccddfda#adeca#####b###aa#aa#aaaa##aaba#a####aa#aabccdccedebaacccb####aaaa###a###abaaabaaaaa#aaaaaababdgdbb##########cabbdbbbaaaaaccaaaaaaa##aaa##acdc#.#aaaaa##a##aabaa#ccaaabaabbaaacbb##abaa######..abca##aaaa#####aa#aaaaaa######abaabdggcaaa#aaaaaaaaaaacba##bbaaaabba#aa#aaaaa##aaaba###aa#aaaaa#", +"#########.#################aaaa#.#.##aaa###aaa##aaa##a##aa###############abbbba#.##.#aabbbbcefc####...#####aa#####aa###aa####aa#######a#aaacbacbbdddbbccdfecbcc###aa####aa#aaaaaa###aaaaaaa##aaacfdaaa#####aaaabbabbbbaaabbabbaaa###aaaaaaa#abce..##ababc####aaaaabdaabbbbbbaaabbbaaa#a##.#######abaa#aaaba##aaaaa#a##aaa###aaa##ababehcaaaa##aaaaaaaadc####abaaaaaba###aaaaaaa###aaaaa#aaa#####", +"####a######################aab#....##aacaaa#aabbaaaaa#####a##############aabbbcb##.###abbcceca###################aaaaaa#a#aa##a#aaaaaabaabbbbbacaaabbabaafddcbcb###aaa#aab##aaaa######a#######a##cfeaaa#####abcbbbbaaaaaabbabba###aaaaa#aaaabaaee#.##ddaaa####aaaaacaaabdcbbbbaabaaba#aa##.#######aaaa#aaabaaaaaaa##aaa#a##a#aaaaaaabbcgebbba#aaaaabaabbaba###aaaaabbaaaaaaaa#aaa##aa#a##baa#a##", +"####a##aa##################aabda#.#####bcaa#abaabaaaaaa###################aaabcdb.####bbbdea##########.###########aaaaa##aaaaa##aaabbbbcbccbbaaaaaaaabbbaaaacdcbbbaaaaaaaabaa#aaa################abecaa####aadcabcaaaaaaabbaab#####aab#aaaaabaaade#..#ca.#a####abcbbb#abbccaaabbbabbbb#a############aa#aaaaaaaaaacaa##aaa##a#aaaaaacabccfebbbbaaaaabbbbaaba####ababacbaaabaaaa##a#aaaaaa##aaa###", +"#####aaaa###.#a######a#######aab##..####abbbbbbbbaaa#aaa####aaaaa##########aabddea.###abda#################a#########a#####aaa###aaabbcdcbdbbaaaaaaaaabbbaaaaacddcbaaaa###abaa######..############abeda###ababbbccbaa#aaaaaabaa##a###ab#aa#aaaaaacec##ab.########babbaaaabbababababbcda###############a#aa###aaabcbbaaaaa###aaaa#ababbcdcdecaabaaababbaaa#######aaabbbbaaaaaabaaaa######a#aaaaa#", +"a#######aa#a######aa#a#aaa###aaac#########abddccbbaaaaaaa####aa#aa########.abehghhc##abca##aaa##################################a#aabccb#aabaaaaaabbbaaaaaabaaabbbdba#aa###aaa##################aa#abefccaabbbcbabbaaaa#aaaaaaaa#aa###abaa##aaaabbcfdaba.#a######bacc##aaaabaababaabcbca##.#####a#####a#aaa#####aaaaab##aa##aaaa#aaaabccebbffbaaaaaabcaa###a#####bbbbbbbaaaaabaa#aa######aa#aa#a", +"#baa#aaaaa###a#a#aaaaaaa####b#aaba#########aacbdcccaaa##a###aaa#aa##########bbfikjicacc###aa#aaaa#############a###################aaabccca##aaaaaabbaaaaabbbbaa#aabcbbaa####a#################a#aabaabdfbdcccbbbbbbbbaaaaaaaabbaaaaa#a#aaa#aaaaaabbcfdbb#######a#aaac##a#ababaaaabbcdaaaa##########a#aaaa#a#aa##a#aaaaaa#aaaaaaaaaaabbccdcaaegcbaaaaacaa#####a####bbbbbbbaaaabba##a###aaaaaa####", +"####aa#aaaa##a#aaaaaaaaa##a#####aba##########aadcbbba####a####a#aa##########abcdfhiigc#a##aaaaaaaa#aa#####################a#######aadccccaba##aa#abaaaabbbcaabaaba#aaaaaa####a###a#a###.#####acbbcbaabcehfdccccbbbbbbbaaaaaaabaaaaaabaaaa###a#aaaabbcddca####.#####aa##aaacbabbbbaabcba#bc############aaa##aa##aaaaa#baaaaaa#aaaaaaaabccdeba#cgfbaaabca#a###aa#a###bcbbbbbbaabbba##b###aaaa#a###", +"###a#aaaaa#aa######aaaaaaaa######aaaa#######a##aaaa####.###aaaaa#a###########abacdhiiga##abbaaaaaaaa##############a########a##a##abbcabc#abbaaaaaaaaaaaaaacaaabaa###a###aa###a###aaa########bbbbcbbbbddceihebbcbbbbbabbaaaaaaaa#aaaaaab#a#####aaaabbcccfb#.########aa##abaaaaaaabbaaaabbcbc#####a######ba##aaa###aa###aa##abbaa#aaaabbbdcccbbabdhebcbaaaaa####a#####accbbbbcbaacba#aa###a#aaa###", +"#a####a#aaaaa#aaaaaaaaaaaaaa#######aba#######a####ab########aaaa##a#a##.#..#####aehhjihb#abacba#aaaaaa############a#a########aa#aabdcc####abaa##a##aaaaaa#ababa#a##aaaa#######a#aaaaaaaa##aacaabcccbcbabbcghgdbbabbbccba##aaaaaaaaaaaabaaa####aaaabcbcdccaa#########.##aaaaaaaaabababbabaa#######a#a##abbba#a######a###aa#aaaaaabbaabbcdbbbbabbadffbbaaaaaa#a##a####aabcbbbccabbabaaaba##baaaa##", +"##aa###a#aaa#a##aaabbaaaaaaaaa##aa###a#############bba#.###aa#aaaaaa#######.####adfehjif###aaaaaaaabbaaa#a########aaa###a######abbbbcca.###a###########a###aa###a#############aaabbbbbaaceb#aaabbbccbaaabbbdggdcbbabbbbaa###aaaaaaaaaaba#aa#a###aabbbbcdc#####aa#######aaaabbbaaabbbbbbba#aa#######a##aabbaa#######aa###aa#aaaaaabbbbbccaaccbbbccdfgedaaaaaaaaaaaa##aaaccbcccbbccba##aa##abaaa##", +"########a#aaaaa#aaaaaaaaaaaaa#aa#ba###########a####aaaaa#.##aaaaaaa##a#a########bbceeijfc####bbababaaaaaaa#########aa##a#aaaaabbadcccba####.############aaa#aa#############a##abbabbbaa##ceaaa#aaaabbbaaaaabbdgfbbbbbabba####aaaaaa#aaaaa#####a#aabbbccdccca#aaaa######aaaaababbaaabcabba##ba##a##a#aaaaaaaaa#######a#a##aaaaaaaabbbcccaabbddcaabbabdffdbbbaaa#aa####aabbccbbcbbddbaaa####acbaa#", +"#######aa#a#aabbaaaaabaaaaaaaaaa##aa#a#############abaaaa####abb###aaa#a########babcfhiiea###acbbabbaaaaaaaaa####aaba#aaaaa#aaabaccbcbaa###############aaaa###a##############aabaaaaaa####bbbabaaaabbbbaaaabbbcffbbbbbbbbaa##aa##a###aaaa####aa##aabccefcadda##aaaabb#aaaaaaaaaabbbbbbbba##abb######aaaabbba###############aa#aabbcccbabbaabdccccaabacfggccbaaaaaa##a#aabccbbcaabdbacba####bbaaa", +"aaa####aaaaaaaaaaaaababaaaaaaaaaaa#aa##############abbbbaaaaa##bbbaaaaaaa######ab#bccehiic###abcaabbbaaaa#aaaaaaaa#aaaaaaaaabcbccacba########.##########aa###############a#aaa#aa#a##a#####acbddcbaaabbbbbaaaabbefcbbbabaaaaaaaa######aaa###aa#####abcdghedcbbbbbcccdcbbaaaaaaaabbbbbbabaa#.acca#a###aaaaaaa########a##a###aaabbcdcaaaaaabbaccddaaaaacaadggfdbaaaaa#aaaaaabccbbaacbaababaaaabbaa", +"aaa#a#####aaaaaabaaaabbbaaa#aaaaaaa###aa#######.#a###abbbaabbbbaaaaaaaaaaaa####a##ababchie###aabbbaaaaaa#aaaaa#aaaaaaaaaaaabccccbccb####a#############aa######.###########aa###aa#aaaa#a###abcccdbbbbaaaabbaaaabbceebbaabbaaaaa#########aaa##aa#####acdfdefebcddcbbdffdcbaabbaabbbbbcdbbaaa##abca#####aaaa#a##a#aa####a#a##aabbdedaaaaaa#aaccbeda#aabbaaaacefgfdbaaaa#aaaaabcccbccabaaabbaaaacc#", +"##a##aa###aaabbbaaaaabcbaaa#aaaaaaa#a##########a#####aabbaaabaabaaaaaabcccca########aaacfhc##aaabccba#aaaaaabbaaa##abbababbcccbeecba#####a########a####a#a#####.##########b######a##a##aa###aababaaabbaaaaabaaaaaabdfcababbaaaa##############.#######bddcbdeffcbbba##dihdcbaaaaacaabbbdcaaabaa#aba#####aaa######aa##a###aa#abcdccdb#aa###aaaccdcbaaaaaaabbaaabehhebaaaaaaabaccbcbbbaaaaaaaaaaacb", +"a##aa#####aaaabbbaaaaaababaaa#abaaa#############.###aaaabcaabaaaabbbbacdedaaaa######a##bccdccaaaaaacdcaaababbbaababbbccbcbbcdcceedc####a##a###########a#aaa######..####.####.###aa######abbaaaabaaaaaaaaaaaaaaaaaaaacfeedbbaa############.######aaaa#abbaaaaccbabaaa###igdccbbbaaaaaaabcbabcbcb##a######a####a#aaaaa####aaaacb#abdcaaa#a###a#acddcbaabaaaaaaaaadfhhedaaabbabbcccbbaaaaaaaaaaaaaa", +"ba##a##a#aaaaa#aaabaaaaaaacaabcbaaaa#aa#########.#########aaaaaa##ababdefcab#aa########aabdfgbaaaaaacdcaaabaaaaabbbbabbcbbbcccddaaaa####aa#aa########a#aa#########..##.##..###.###aaba###aaaaa#abaaaaaaa#aa#aaaaaa#aaaegdcbbbaa###########.######aaa##aaaaab#abaaaaaa#.febaaabcccbcbbcbbaaadbcecbaa#####a#aaaaa###aaa#aaaaabaaaabccaaaaaa#aa###adbbbcbbaaaabaaaabbchifbabcccabbccaacbaaa##a#aaba", +"#ba########a###aaaaaaa#a#aaa#abaaaaabaa##a#aa###############aab####aaaaabccaaa##a#.#####abcdfb#aaaaaaaaabaabbbcbbbbbababbcdddfedcb#a##aaa#aaaaa###aaaa##aaa##.######.###.###########a#########aaaabbaaaaaaa###aaa##a###bfedcbbaaa############a####a######a#aaabcbbbaaa#gdaaa###bcddcecccca#addefgfddca###a##aaaaaaa##aabaacb####bbdcaaaaaa#aa###ccbbbccbaaaaaaaaabaadhieabaabbccdcbabbaa#####aaa", +"#aab####aa###aaaaaaaaaaaaaaaa#aaaaaaa#####aaa#a##.############aa#abaaaaaaabaaaaa########abccdfcaaaaaaabbbaa#abbcbbaacabbbbcddecdcc####aaa#aaaaa#aaaaaaa##aaaa###..######.#####a########aaa#a####aaaaa#aaaaa########aa####dedbbbaaa##############a###a#####ababccbaaaaa#gcaaaa####bdebbbbbca#bddcbaabccaa##a##aa#aaaaaaabbaca####abdbaaaaaaaaaa#a#ccbbbbbbbaaabbaabba#adhgcbaccccccdccba######aaa", +"a##aa#a###aaaaaaaaaaaaaaaaaaaaaaaaa#aa###aaaaa###.#############a##abababbaaaaaba######aaabbcddhcaaab##baaababaabaaabbabbbbcdddffeeb###aaabcaaaaaaaa###aaa#aa####.######a#######b#####aaacb#######ababaa#aaa##aa########a#aaeecbbbaa##################a##a##bbaabb#aaaa#cd#aaaaaaaace.aaa#bdccdcaaabcacbaba###aaaaaaaabaabccaa#aaabbd#aaaaaaaaaaa#bcccbbbcbbaaaaaaabbaabbhidbbcccbdeddaaa#aa#aa#a", +"aaaa#aaaa##aaaaaaaaaa#aaaaaaaaaaa######aa#aaa####..#########.###aaabbbcbbbaaaaaaba#####aabbcccegcbaaaaaaaacbaabbaaabaaaabcccdeeffddaaaaabcbbbcfffecdcba#abb#############aa#a##acbbcba#bbaa########aabba###a##########aa#aaa#eedccbaaa#####a#a###########aaa#aaa#bcaaaaaafaaaaaaaaacfa##a#aaaba#abaaccbcbbccbaaaaaaabbbbbbaaaa#a#abccc#aaaaabaaaaaadcbbbcbcabbbbaaaaabaaccfjgbccbcccccaa##aabaa#a", +"#a#aa#aabbaa#aaaaaa##abaaaaaaaaa##aaabaa##aa#a###.#.##############aabbbcacbaca#aaca#####aabbccdeedbaabbaaaabbabababaaaabbccdddffedffb###bbccefebccbdeda#aaabbaaa#######aaaaa###aabcca#adaaa#####aba#aaaa##aa################.cedcbbbbaaaaaaaaa##a######aa####aa#bbaaaaaadc#aaaaaabbee####abaaa#aa##abaaabbabdcccdcbbaccbcb##aaaaabbcdbaaaaababaaaacbccbbccbaaabbbbaabababadjiedccccbbbaaaa#aa#a#", +"aaaaa###aaaa##aaaaa####abaa#aaa#a###aaaa######aa#################a##abbbcccbbbaaabba##.#aabbbbddedd#aacb#aaaaaaaaaaaaabbbccdddggffghecbbaabbbddabaa#aaaabaaa#bbbaaaaa##a##aba###aaabb##bbaa####aaaa###########a########.#####aaeecbaabbaaaaaaaaaaaaaa###aaa##a##aa###aaabeabaaaaaabchca###a#aa#a###a##aa####bca#abdecbcdbaaba#aaabbdcaaaaaaaabbaaaaccbbbccdbabaaabbbabbbabacjkjgfdccbaaaabbaaa##", +"#a#aaaa###caa#####aaadb#aaa#aaaa#aaa##aaa###aaaa#a####a##a######a#a##aabbbbabba##aabaa##aaaabacdececaaaba#aaaabaaaa#aaaaccdeeefgeeefbcbbbcbbbcbaaaaaaabaaaaaa##abba##a#####aaa###aaaa##.#ba##.###aa############.##.#############dedcbaabbaaaaaaabaa###a###aa##aa#aaaaaaa#dbbbbbbbaacgg#b####a####a##aaabaaabbcaa#abacdcaaaabaaaaabbccaaaaaaaabbbbcbabcacccccbabbaabbbabcbbaaejklhfcbcbbaaaa#aaaa", +"####aaaaa##aaaaabaaaaabbaaa##aaaa###aabbaa###aa#aaaa###aa#######aa#a##bcccaaabbaa#acaa###aaaabbcdcdcbaabaaaaaabaa##aaaabbccdfffghffdaabbaabccddbabaaaaaaaaaaaaaaaaa##a#######a####aaa###.aba######a#################a############bfedbaabbbbbaaaaabaa##a#########abbbba##dcbabbbaaabcgdc#####aabaa###a#bbbbbbbbbbaaabbcbbabbbaaaabbbdebaabbbaabcbbbbacbabbabbbbabbbaababbbbbghillgcbbbbbaabbaaa#", +"###aaaaaaccdcaaaaaaba##aaaaa##aabaabaaab########aaaba####a###a##aaaaaabccbba##bbba#bca###aaaaabdcddcda#abaaabaaaaccaaabbbccefgfghffaaaabbaaabefbcbaaaaaaaaaaaabaaaa##aa#########a########aaa###a##############.##.#.############a#abdebabcdcbbcbaabba############acdea#abecbaabbbaabbdfc##aaaa#a#aaa##abbbcaba#adebaecabbaccdcbbabbcbdddbabbbabccccbbacbbbbbabccbbbbbaaaabcbcfijjkjfddcbabdebaaa", +"db#bdccbbcb##aabbbbaa###aaabbbbaccaaaabca####.#####baba##a#aaaaa#aba#accbbbbaaaaaaaacbaaaaaaaaacccdccc##abaabbaaabdbabbcccdffffhggbaaaaabdbaaaababbaaaaa#a#a#aaaaba#a#a################aabaaaaa###########.#####...#####.##.####aaaa#bedcccaaaaabbaaaaa##a#####aaaaddaabdebabbbbbabbbbgcaa#a#aaaa###aaabdaddabaadcfdfgdacbaabcbbbcccbdcdffdacdcedccbbbacbbbbcccccbbbbabacabbdgigbbgjjedcbbbccaaa", +"#bbbaaaaaabaaabbbea#aaa#abbbbabaaaaaaaaba#############b####aaaaaabaa###abbbbbaaaaaaaacbaaaaaaabbcccccdd##cbcbcaaaaaaabcdeffgggiigabbbbbaabcaaaaaaaaaaaaaa#aaa##aaaaaaa################aaba###baaaa#######.#####....#########.#a##aa##a#adfca###abbaaaaaaa#####a####bdbacfdaaaaaabbaacedfa#aa#########abefeddcccdebccfggfedaaccbacddecdccdeddccefddcccccccabaabbabaabbaabacbbhijgdbacfkjeedcba#a#", +"###aaaaa#abbaaaaaaa#a####bcaaaba###a#aaaa######a####aa######aaababaaaa##aabbaaaaaaaaabcaabbaaaaabcbccccbcbaaaaababbcccdefgfgghkgbaabbcbccbaaaaaabaaaaaaaa#aaaa#aaaaaaaaa####a########aaabba#aaaa#####a#.###.######.#####.####.##a#abaaa#aaddaaabbaaaaaaaa#########aabgggfbaaaaaabbbabbcfea#a#####aa##afghhfggghhgccddffhfffcccbccdfgeeeceec#aabcddcdddccebaaabaaabaaacbbbb#ejhjgbbceceikibbceba#", +"aaa##a#aabbabbaaaaaaab####bc#aaaa#aaaaaa#ab##aaaa##a#aa######aa#baaaaaaaaaaaaaaaa#aaaaacbaabaaaabbcccccdbaaaabbbbccddeeefeegjheb#a#aabaccdcaaaaaaabbabaa#aa##aaaaaaaaaaaa#######a###aaaabba#abaa####..###.###.####..#####.#######aa##ba#####bcbaaabbaaaaaa########abdfggebabaaaaaabbbbbchfaaa######abbfegggefgghgffeecefggfhheecdddeeefdcefcabaabccbaabcbcbaaaaaaabbabbbbbbfghggdbcbcbbgkjfbbecb", +"#aa#a###aababbbaaaaaaac###.acaaaba#aba####ac#aba###aaaaaaa#aa##a#a########aaaaa#aaaaabbbbbaabbaaabbbccccebaaaabbccddddedegggfhbaaa##aaabcccaaa#aaabbbbcbaaa#####aaaaaa#aaaaa#####a###aaaaaabbdaaa########...##.###..########.#####aa#aba###a#accbaaaaaaa#######aaaaabccdeeccbbaabaabbbbegfgeca#####adefffefgggfghggfeeccegihijigedbccfeceddfeaaabcacbbaaabbaaabaaaabbbbbcbchgghfgdabbaa#bgkjgcdd", +"d#a#a####aaaabbbabaaaaaa####abaabaaaaaaa###acdbaa#a###aaaaaaaa###########aa#a####aaa#abbbbbaabaaaaaabcbccdaaaaabccddeefefhgefgbaaaaaaabaabbaa##ababbaaabcca#aa#aaaaaa##aabaaa####a####aacba#bcb#aa#.####.#...##.##..################a########a#adbaaaabaa#aa##aaaaabbbcdeddddcbabebbcbbffeefdec##adeeefeffefghgghghhgfedfheabfghhfdcegecbbbbccaaaabcaaaaaabaaabaabbbbabbcdfffgffffabbbbbcabgkjec", +"cdaa##aa#aaababbbaabbaaaa####bbabcaaaaaaa##.acaaaaaaaa#aaaaa#ba###########aaa#a###aaaababbaabaaaaaaaabcccdgbbbccccddeffefgfeffbaa###a#aaaaaa#aaaaaaabbbccaaabaaaaa##a###aaabfd#####aaaabbaba#aa########.###.##.###############################bacedcbbbbabaaaaaaaaabcccccddedddbbdeecdefeededdeeffdegffeddefgfgggggcb##abbca###bbefeefeddcdcbeeaaaaab#a###babbbbbababcbccfgfeeefegcbaaabbca#afkh", +"gdcbaaaaaabbbaaabaaabbbbaaa###bbcbaa#aaaa#####a###aaaaaa#aaa#aaaaa##a#####a#aa#aa#a#aaaabbaaacaaabaaaabccdfgddddddccdfhhffddfbaaa####aaaaaaa##a#aaaaaabbdb#aaaaba#a#######aacegdbaa#aaabaabbb########.#.##.##..#...####.#######################babedededcbaaaaaaaaabccddeedefecfffeeffddddddeddeeeddeggfddeeffbaaaaaaaabdb#baa#a##cbdfeaaabbcdfbaaaaa####a##abbbbaabbbbdcgfgeeedeefabba#aaaaaabg", +"gjgccbaaaaabbbbbbbbaacbaaaaa###aaaaaaaaaaa####aaa#####aaa##aaa#a#a#######aaaaaa##aaaaaaaabba#acaacbaaa#acccfgdefefcdecfhhddbcaaa#a#####aaa#aa###aaaaaaabbeebaaaaaaa####.###aaacdcbaaaa#aaabba#############.#.#.#...###########..###############aacddeeededceeedccefggfgggfedggghfdfecdddccccddeeeeefddfffddddbabbbaaaaabefcdb#aa##aaabcaaaaa#bdgb#abaa#######ba#bbaabaaeegfgfeeeecfcaaa#aa#aaaa#", +"#bgifcbaaabbbcbbbbaabbbaba#a#aa##aaaaaaaa######aaaa##a#aabaaaaaaaaabaaaba##aaba###aaaaaaaaabbabbabaa#a#abcceffeecb#cddeeggcdb##a##aa##aa#########aaaaaaa#bedaaaaaa##########abaa#aaaaaa#aaabaa#####a####################..######.#a##.#########aabcccbcda##afgggffdbbbabdhheghifedddeecbccdcdefffeeffdfggfdbaaaaa#aababbacdddb#bb#aaa#a####ababbdebbbaaa####a#babbaaacddfgffeefeeddcbabbaaaa#aaa", +"a##ehiecbbbccdccbbbbaabbaaa#aaa##aabaaaaaaa####aaaa#####aaba#aabcbbbaabbba##abaaa######aa#abbacbaaaaaaaaabcccdfcaa##bbbbceabaa######aa##a##aa####aaaaaaaa#abaaaaaa###a######abbbaba##aaa#a####aaa###a############.########################a####aa#dcddcdb#a#dedeedcaa#baacgegiifedddddddcdddefeffggfgeedbba#aaaabbaabaaaaabceebbdaaaaa######aaaaabdddb#aaaaaabacbbbaabdfffgfgfeeeeddgcbaaaaa####", +"#b##adiifdbcefedccccbaabaaaa#aaaaaaaaaaaaaaaa##abaa######aabbaabbcbbaaaaaaa#abaaa#######aaaaabcca#aaa##aaaabbccc#########a###aa##a###aa########aaa##aaa#aaa#aa#aba##a#######aabbabcaa#ababbca##aa####a#####a.#########################a###a##acba.ddeecccba#cfeeedcaaaaabccbaigfeeeddddcbcdcddfeffggeedaabaaaabaaabbabaaaaa##cffedeaa#a#aaa#aaaaaa#abfebabaaaaaacadcaaffecffffgfffeeggaaabaa####", +"#caaa#.ahjgffefgggffecbbbabaaaaaaaa#aaaaaaaaababaa#aa#a#aaaabaaaacccaaaaaa#a#aaabaa######aaababaaaaaaaaa#aaaabccb####aaa##ab###aa#####a#a####.#aabaaaa########a##aba########acbbaaaaaaaaaabbbaaa################a###a####aa############aaccb#adcbbdddccbcdebdedccba#a#aabdcbaggeeddedcbbbccdeeffffhggfcbaaaabbbcaabaaaba####a#debceea#aaabaaaaaba#aaa#cfgcaa##aabcbcbdffedfeeeefefeedhcaaaa#a###", +"####aa##.behhgfeeeddefedbbbbaaabaaaaabaaaaaaaabaaaa#aaaa#a#abbaaabbcbbaaaaaaaaaaaba####aa#aaabaaaa##a#aa#a#aaabbcc.##ab##aabca##aaaa############aabaaaaa#a#a#####aaa#bb#.####bccbaa##aaaa###aaaaa######a#######bbabba####bb###a#a###a###bcccccdcdccddcbbabcdcddccba####bdddb#bdcecdedcbbbbbcceeeeehhcdaaaababcbcaaaaabaaa#####ab#aabb###bb##abcaa###a##adfeba###aabaaefefffedddeedefefhbaaa###.#", +"#####aaaa###chikjiigedcegcccbabbaaaaaabbaaaaabaa#aaa#a#a##aaaaaaaaabaa#aaaaaaabbbaa######aaaaabaaaaaa##aaba##aaabab.###aaaaaabaa#aa#a#############a###aaba########aa#cbb####abcbaaa##aaa#a######a#.####aa###bbccbbdccbaaabb###a#aaaaa###cbbbaccccbbcccaaaabbccccbbaaa#accdcb##bacgeeedccccbccdeeefggebdaaaaabbbbbbaaabaa#####a#a#aa#####aaaa##ca#####a####beeca#b#abadgefffedeedfdcffeff#a#a###.", +"..######a#aaadd#acdhihecdgecbcaa#aa####ba#aaa##aa##aaa###aaaaaaa##ababaaa#aaaaabbbaa######aaaaaaaabaaaa##baa##a#a#b######aaaaaaaaa#################a#aa#bcb#####aba##a######bbbcbaabcaa#################a#abcdbdefededcbcbaa##aaa#a###bcbababbccbbbbbcaaaaabcccbaabaaaabcdbba###bhhfhgeddccbccddfhhhfbbaaaaaabbbccaaaabaa####aa#a#####b####aa#aa#ab###a##aaabefd#a#abbfgfeeeeeedeeddefggbaaa####", +"##.######aaba#abaaaabeiiebceddcbaaaaa###aaba#########a##aaaaaaaa###aaaaaaaaabaabbbbaaa###aaaaabbbaaabbaaaaa###a###bb#####aa###########a######a#####aa#baaaba##abcedcbaa##a##bcccbaaaddccaa##############a##bbceffgfededdedcbaa#a#aaa#bcabaaabbbccbbbbbbaaaabbcbbbbaaaaabbcda#a##ehgfeeeeecddbcddfhhgcbbbbbbaaaabcbbbaaaaa###.#a#a#a####aaa###aa##a########aabbbedbacfegggfeeefeddccddgihdaaa####", +"##.###a####aaaa#bacbaa#chidccdfdbbabaaa#ababaaa###a###aa#aaaaaaaaaba#aaaabccccbcccccabb###aabaabbbcbaabaa########aaab.####aaa##################a####b##aaaabb#aacdddcbb#######bccaaaabdbba#####aa#a#########abccccccddcffhigcbaaa#aa#acaabaabbbbaaabbbbbaaaabbbbaaaaaabcccdda#a#higheddefedeecdffffeeaaabbbbaaabcbaabaaaa#########a####aaaa######a#######aaabdcbadgfdeddegfgfeedcccccehigaaa####", +"###########aa#####aacdb##ejgcbbfedcaaaaaacbabaa#####aaaa#aaaaaaaaaaa##abbbbbbaaabbcddddbccdcccbababaaaaaab#########aba..####aa###################aa########aa##aaaabbbba##a####ccaababdaa#aa#####aa##########aaaaabbccdfgjjihdcaa#aaaacbaabbababbaabbbabaabbbbbbbbbbbbbcccddebadhggfffeeffffeeeffdccddaaaabaaabbabbbbaaaa######..######aaaaaa#a###a#aaa###aaaccc#ceggedddcffffedcbabccdfgebaa###", +"#########aabaaa####a#aabbachjgbacdedcccbabaaaaaaa#####aa#######aaaaaa#aaaaaaabaaaabbccdccddcbbbabaaaaaabbaa########aabb.#######a##################aaa##########aa##abaaaaa######bbaaaaba#a#a#.##.#a#aa###aa###aaaaaabcddgijijjigeba#abdcbbcdcabbbbaabbabaaabbbbaaabbbbbcacddee#dfeeeffeccdghhfffebccccaaaaababbbbaaabba#a########.###a##aaaa##aa##aaaaa####aababbddceggfedcdffedcbaabcdeeffaaaa#", +"#######a#aaaaaa#a#####aaaabcdiibaaacecddcbaaaaaaaaaa##aaa########a#aa###aaaaaaaaaaaaabcccbbaaaaaaaaabaabbaaa######aaaaca.###.##a#a####a########aaaaaaa##...###a###a##a#aaaa#####bdaaaaaa########a########a##a##aaaaabbbbegfeedeghgeccddeeefgcbbaaaabbbbaaaabbbaababbbbcccbceeebegdddeffedbdeiihecbcbdbaabaaababcbbaaabaaa#a#.############aaaa##b#a##aaaaa##aabbbbccdceghgeddefedcaaaaccdedfaaaa#", +"########bcaaaaa##########aaaa#gidaaabedcccbbbaabdbaa####aba#a#############aaaa###aaaaaaacbbaaaaabbabbbbbcbbabaa######aabb..##.####aa#aaa######aaaaaaa####a#.####aa##ba#aaaba#####dbaaaaa######aaa#aa######aa###aaa#aaabccebabaabbdfhhhgfghggdbaaabbcaaabbaaabaaaaaaabccccccedchigdcdddcedccabghdbaaabcaaabaaaaabbbbcbbaa##a########a##.#aaaaaaaaa#aaaaaaaca#acbbbbbcccdefeddeecdcbaababcfdfeaa##", +"########baaaaba#aaaa#####a####aciib#aacdddbabbaabbb#aa#####aa#############aaaa##aaaabaaaabaa##aabababbbbccbbbcb#######aaaa#...##.#####aa########aaaaa######a############a#aaaab##abbaaaa#######cb############aa#aa#aaaaabaaa#######bfhigihhfbaabaaaaaabaaaabbaaaabaaaccbccdcchiihhdbcddcddccbbeeaaaabbbaaaababaabbbeeeaa#####.###.aaaa#aaaaaa#aaa#aaaaaa#bbadccbbbbccccbcddddcbcccbaaaaddddge###", +"########a##abbaaa#########a#aaabcfjhaaabcdecaabaaaaaaa#######a########a#aa#abaa#####aaabaabaa##ba#abbccbaccaaca########abcb..######################aa###ceb#######aaa#####a#aaa###acaa#aa#######b############a#a##aaaaaabaa########abacfhhfcbbaaaabaaabaaaaccaaaaaaaacbcbbcffgfgcegeddeddcdccbcd#aaababbbaaababcaabaaccba########a#abaa##aaaa##aaaaaaaaaababcbbbaccbbcbccdddcbbbcbbcbbadcdeehd##", +"########bb####aaba#########a####aabfjfbbcbcfdbabaaaaaaba######aa######aaaaaaaaa##a#####aaa######aaaabacbbaaabaa#########aadc...#######.##########aaaaaa#ddeb#a####aaaabeb######a###bbaaaa##b####aa#.##########a#a#a#aaaabaaa##b###.adbaabeecbaaaaaababaaaaabcabaaaabbbbbcdcfgeddgbbggeedddcccccc####aabaaaaabbaabaaa#acda############aaaaaa#aaabaaaaaaaaaabcbabbbabcbbbbcddccbcbbbabbbbccdfggf#a", +"aaaa####bc##a#aaaaaaa###.#####.####aciiecccbceebaabbabbb######a#a####a##aaaaaaa########aaa#######aaabcbbabbaaaaa#########acfc..####.#.###.###aa###a#a#aaabcaaaa###aaaa##########a##bdcaaaa#ba###baa##########aaa####aaa#bbababdcbaacbbbaaaabbaaa##aaaaaaa#aabbbaaabbbbbbcdcccddcdec#adfedddcccbe#####aaaaaaaaaabbbaaa#bdb##.#######.####aaaaa###aaaaa##aaabccbbbaababbbbbcdccccbcbbbcbbbdcefghc#", +"########a#####aa#bbaaaba######...####adhifegfddfdcabccbaa###aaaaaaa######aaaa##aa##a###b##########aa#aaaaaabaaa######a###abdfb..#######.##.#####aaa#a###baaa####aaa#########a####a#bddcbaaaa####aaaa####ad##aaaaaa#######abadddccccdcba##a#ababa###aaaaaaaaabaaabbbbbcbbcbbccdccbaba##afedddccbfa######a#aaaaaabbabaaaaab#####.##..#..a###aaaaa#aabbaaaaaabcccbbbabbbbbbbbddccbbcbbbcbbcfdeeffha", +"##############aababaaaa##########.##.#..chjjhjifffdeccdbaa#aaa###aa#####.##aa#######.#######a#########aaaaaaaaaac########acchc.....#..###########aa##aa#abaaa##aba##a######aaaa##a##bdcbaaaa#####a#aa###bd###aaaa#aa##a####adgdcbbcddbb###aaa#a#####aaa##aaa##abbaabbbbcbbbcccddeccc#a#bhggfedaec##########aa#aaababaaaaaa#####.##.##.####aaaaaaaaaaaaaaaabdcbbbababbabbbabddcbbbbbbccbbdifdefge", +"a###a##########abb#aaab#a#######...#####.##a#acgkigfeefdcaaa##aa#aaba####..######.#a###a#aa#aa##.#######aaaaaa##ba#####aaabbeha...###.###.#######a##aaa#aaa#a#aaaa###aa#a###aa###a###cdcaaa######a#####abb####aaaaa####a####deebbbccdbba##aaa#aa####aabaa#a#aabbbaaaaabcbcbbccbcedbba###cdffffeefba###########aaaaaabcaba#####.####.#######a#aaaaaaaaaaaaacdccabbababbabbaabcccbbbbbbbccdeeedefh", +"f#######aa##a##aaa#aa#bba#########..############afkjgfgfeeeba#aaa##a#######.####.#.#####abbbaa##########aaaa##a#a#######abbcdhe#...######.##a####aa#a###aa#a#aaaaa######aaa###########bdbbaaa####a######aa##.##aaab####aabdecdcbaabbbaba##aaa#########abaaa##abbbaaaaabbbcdbaccbcebaa####adghfedeeba#############aaaaabbcb##########.######aa#aaaaaaa###bcdccbbabbbacbaabbbbbbdcccbbbbbcccccddeh", +"hc#####aa######aa####aaaa#####a###.......##aa##a###gijhhhggeb##baaaa####...#####.#..a###acccaaa##########aa#####aaa####aacdddhf#..###.#..####aaaaaaaaaa###a#aa#aaaaa#####aabb##########cecaaa####a##############aabb##aabacddbcbbabbbaaaaaaaa##a#######baaaaa#abbaaa#abbbabcbbbcdgd####a##adcgfecdeb######a########aaaa#baaba########.######aaaaabbbbbbcbccbbbbbbbbbaaaaabbbbbbccbcbbbbcccccdeed", +"egb##baaaaa####a##aa#aaa#a#######.#..###.###########adfilkhfca#abaaa#####..##....#....###bbccaa##a##aa####aaaaa##a##a##abbcfhjfb#..#####.######aaaaaaa######aa##a#abbbba###aba#aa#######cecaaaa###a#.#######aa##aa#aa###aaabcbcbbcbbaaabb##aaaaa#######abaaaaaabbaaa#abbbbbabbabdfeaaaa##a#ca#eecccfcaaaaaaaaa#a#a######aaaaabca########a####aaaabababbbbbbbbbbbbbbbaaaaaaabababccccbcccdccbdffd", +"cfhd#acaaaa##a#######a#a##a###a##.....######.##########bddjkidca#########..###....######acaacbbb#a###ab##aaaaaaaaaaaaa#aabcfgejfa#.###a######a##aaaa#aaa#a###aa##a#abbcba#####aa####a###aeedbaaa##aa####...#aaaa#bcaccbaaaabcdccabcbbbaaca#aaaaa#########aaaaaaabaaaaabbbbbbbaaabbecbbcaaaaaa#adecccedcaaaaaaaaa##a###########abaa######a####aaaabdbbbbbbbaabbbbbabbaaaaaaaabbaabccbccbccdccdefg", +"fedfea#a####a##a#a#######a####a#.##..#.####...########aaaaaeikhea#####################aaacbabbdfdbbaa#aaabbcbbaabaaaaaaabcdfbbeica..#a########aabaaaaaba#a###aa#######aaa#####aaa#.aa###adffdbaaa##ca####.#########abbcdeeeefcdcbabbbbbaacbbaaaaaa##a##a##baa##aa###aaaabbabbaabaadfb#bbbbbaa###feccbeecbbabaabaaaaaaa#aa###a####a########a##aaaaabbbbbbcbabbaaaaaabbbaaaaaaabbbabccccccddddeeee", +"fggehdaaa######a##########aaaaa#.##.####..#..##.#######aabbaadjljgda.#################aaaccbccddcccccccccccccdcbbccbcbaabbcfdcbgf#...#aa######abcbaaaaabaaaaa############.##aa##a########dffedcbaa#cc##########a####bbbbcdffeedaaabbbbbcbabbaaaaaaa#######abaaaaaaaaaaaabbabbaa#a#bdcbbbaaaaa###cfeeehhecabbbbbbaaaaaa##aaa##a###a########aa#aaaa#bbcbbbabbbbaaaaabbbbbabaaaaaaaabbbbbcccddddeee", +"edehhg#aaa######a#a#####a##abbaa###.###################aaabbcaacjllkhbaa#######a######bbaefddddcbbbaaaababefeedddccffdccdfgeeeefec#...#ab#.####abccbbba#aaaaaa###########..###a##########bfdfdccaaacfb.######aababaaaccccbdffebbbbcbbaacccbabbabaaaa######aaaaaaaaab#aaabaaaabaaaabbeffcaaaa####aeeeefiihfcabbbbbbabaaaaaaaa##a######aaaa####abbabbabcbaaaaccbbbbbbbbcbcaaaaaaaaaaaacbbcdddddede", +"eefgghcaa#######a##aa######abbbcc#.############.###a#aaaaaaaaccbafjllkjecbaaaaaaaa##aabcccgefeecccbba#aaaa.acffffffcacdccbbbfffefda#.##########aabcedba##aa#a#####a#####..#####aa###.####bceecccbaabdfa##aabbbaabbbbdcbbccdcceebabbbaaabcdcbbbbbaaaa######a##aaaaaaacaaaaabbaba###acdeegcbbb#####aeffgfgijkgcbbbbbbbbabbaaaaa##a#aaa#abaaaa##aacdbabbccbaaa#bbbbaabaabccbaaaabbaaaaabbbccdeedddd", +"deeffdfd#####a######a#######aaaca#a############bdca###aca##aaaceddfijjnligdcbbcbaaaaabcddchgedddbccaaa#aaaaa##accfbbbaa####bdhfedhd#.###########bbcccdba###aaa#####a##a#.#####a####.####.#abedebdcbbcfe#####adcbcddbbdbaaacbcbccbbbaaa#bbcbbbbbbaba#a############aaaaaaaaaabaaaaaaabdfcccbbba#####aceffgiijihedccbbbbbabbaaaaaaaaaaaaaaaaa#####aabaaabbbaaaaaabbaabbbbbcabaaaaaaaaabbbbcccdddddd", +"ddddecbdca###a###a##baa#aa##abaaba#a###.#####.#aabaaa#aaa##aa#acdhilmklmlmkheegecbbbbccbcefgedcdcbbbbaaaaa#aba#a#cdabcbaaa#achihggfa############abdb#bcaa##aaa#########a###.######..########beddecbcdffc###.#acdfffdabcca#aabacbbbbbaa#abbbbbbbbbaa#############a#aaa#baaaaaba###aaadfd#babacababbbcegfhhiihgfdddcccbbbaabbaaaaaaaaaaba#aaa###a#aaaaaaaaaaaabbabbaabaaabcbbbaaaaaaababbccdddddcd", +"deddddcacaba###a####aaaaaa#aaaa#aaa###aa#########a##aa#aaa##aba#.cfehhjkjllmllihfedcccbbdefgdcccecbbbccbaaaaaaaaabdbbbcbaaaabhjjhggea#.####a##a#accaa#cdaa#aaa#.#############a##a##.###a####.cedccccefbbaa#####deffeaacdaaaa#aabbbbbaaaaaabbaaabbaba#####a.###a###a#a#aaaaaaa#a##aaacdecaaaabaa#aa#bdgfeeefhhfdccccddcbbaaababaaa##aaaaaaaaa###aaaaaaaaaaaaaaaabbaaababbbbabbbaaaaaabbbbcdcdccdd", +"dddcccdbbbcba#bb#aa###aa##a##a####a##.####aaa##a#aa##a#a#ba######.fffkjlhkkljmmmlieeddccefaeeeccdedbcdccbcbaaaaaabaccbccaaaabeijjigieba.#######aacbaa#accaaaaa##########a#a###aaa#############decabdeeeaba###..adeddcaabcbba##aabbbaaaaaaaaaaaaaaaaa#####a###########aa#abaaaa##a#abbcdeba#b#aa#####cefedcbbdeedcccdddcbbbaabbaaaaaaaaaaabaaa###aaaa#aaaaa###aaaaaaaaaabbbaabbcbaaaaaabcccccccdd", +"ddccbcccbcedaddaaaaaaaaaa#aa#a######...###########aaaaaaaaaa####..cfhjjkmlmklkklmnjfeedeefebdeddegheeedddccbbbaaabbccbcbbaabbbgjkjjhifda.#######aaaaa###abaaaa####aaa###########aa##########..adccaddcecbabbaa##dedddcbabcbca#aaaabbaaaaaaaaaaaaaaaaaa###############aabaa##a####aacbcddebaaa########cffecdcbceeefdddddcbbbaabbbaaaabaaaaaaaaaa###aaa#a#aaaaaaaaaaaaaaaabbbaaaacbbaaabbbbcdcdccb", +"cdcccccbbcdbaacbbbbbbaaa#aa#aaaa#####..#..##.#####a#aaa####aa######eigfcfgijjjlmmmmnlhfhiggdddeefgegfgffdeddcdcbaaccccbcbaaabbcfjkkkijgfb#######a#aa######a#############a###aaaaaba############abcc#ddcccbdecdcaddddddecbbbccaa###aabaaabaaaaaa#aaa#########.####a##a##a#aa#a######abccdgbb#ba#a######cffgfdefffehgdddeccccbaabbbaaabbabaaaaaaaaa###aa##aaaaaaaaaaaaaaaaaaaaaaaabbba#aabbacddccc", +"cddcccbbcccaabbabaacbaaaaa#aa#aa#.#...#...#..###a###a#########aa##adeaaa#abedefijlkmnnlkkjdddfdcebb#degfaefgfeddcbdcddbacbbbbbbdjjklkkihgc#aa#####aa################aaa##a#aaabaaaaa###########aabdbedcabdddeeddddedcccddccbbbca###aaaaabba#a#####a#a###aaa###.###a#######aaaaa###aabbbbcdaaabaa##a####aeghhhggghhhfedddcccccbbbbbbbbbbbbbbaaaaaa####aaba#aca#aaaaaaaaaaaaaaaaaaaaabaaaaabbbcddd", +"dddcccbbdedaabdaaaabbabbbbaaaaaa#.##.##.#.#####################aaaddbbaa#aa##a##aceejnllkkhfhfccfbbaaaabafabdeffgfcdddcabbbbabacgjkkllkhjhbaa#####aa############a##aaaa###aaa#aa#a#####.####a##aa#deedcabdeeeedeeddeedbccdcccdcb####aaabbbaaa#####a##a##a####################aa####aabbbcdea##a########aaabehiiiiiihfedfdccccccbacbbabbbcbbbbaaaaaaaa##ab##bbaaaaaaaaaabaaaaaaaabbbaaaaaabbbbbdd", +"ddccdbcbedcaabbbbaaaaaabbababbaa#################a##########a###a#ecbaababaaaa#####abkllllljgbaaccbababbabaaaa#cedfheedcabbbbbbbchkkkklkhggeba###aba####.####a####a##aa##aaaaaaa##aa####.####a####dfdcba#bdeeeeeefedddcbbcdbbadcba###abaaacaaa###a##a###aa#####.####a######.##a####abbbbccbbc#ab##a#aa#ca###cfggihhihffffedcccccbbabccccdccbbbaaaaaaa#aa#aa#aaababaaabbaaaaaaaaaaaaaa#aa#abbcccc", +"dedcccbcecaaacbababbbaabbbbbcbaaa#..###.#########a##############.cdabbbbbbbba###aabcddilmmljeaaabcbbbbbbbbbbbabaabcefgfecbbbbbbcdfjjkkkmkhfgecbaaabb########a######aaaaa####aaa###################befcbaabbadfeeeeffededcbbccabccccaa#aaa#abaa#######a########...###########.##..###abbbbcbbf#aa###abaa#a#####acfgffgfggefddcccccbbabcecbbbcbbaaaaaaaa##aa#aaaaababbbabbbbbcbbabaaaaa##aaaaabbcc", +"cddecccccdcaaaaaabbbbaaaabbbbaaaa########.####################..aaababaaacbba#abddbcdfeejmllf#aabbbaabbbbbbaaaaaaa#afffdedcbbbddffjfijjkkkhgfed####aba#######a####aaaa#aa#####a######a############adffddcaa#befefedeeddccccbcbaacbaabbaa###aba####a###############.###########.######aabcddcefbb###bbaaaaaabba#cffffghhgfffedccccccbcbbebbbbbbbaaaaaaaa####aaba#aaaabbbbbbcbaaaaabbcbaaaaaaaabcc", +"dddddfebdfeba##aaaaaaabbbbabaaaa####.#########################.abbaaaaaaaaabbaaabba##aceeilmme#aaaaaaaabbbbaaaaabbbbbefgeddcddddegiighiiggjggfdba##aaaa##############ba#b###aaaa#######a##a#aaa####dfgffgcaabefeeededccccdddcbbbbbaaacbab###aaaaaa########a#a########.#########..####aaabdcdecbdc#aa###aabbcccaacegggfgghggfeeeddddcccbccbbbbaaaaaaaaaaba#aaaabaaaaaaaaaaaaaaaaaaabbaaaaabbabbbc", +"bcdeeeeedeeda##aaaaaaaccbbaaaaaaa####..##.#########a##########aaaaaaaaaaaaababba#aa####abbdhkmgbbbaaaaabbabaaaaababbbaehfcdeeeegghkkjjigdeehfeccaaaabcba########a####aaa#####aa####a####aa###baba##adfgfffdeeffdcddddddbcccdccbbbbbbb##bdb###aadb#a##############.##.######.##########abcdcedecegdb#a#aaabbcddaa#adfghfghgffefeefeeddcccccbbcbaaaaaaaaaaa#aa###aaaaaa#aaaab##aaaabbbabaaaabaaabb", +"cbceeeefffffd#aaaaaaaaaddbaaaaaaaa#############.#############cbbaabaaaaaaabaaaaaaaaa###aaa#achlkigdaabbabbbbaabcaacaababccdbbdedcdfehkkjgeceheccda#aabbba###.######a#aaa#####aa######.#a#aa##aa#aa##adgggfeeggffdcccddcccbbcbccbbbaaa####ca##abcba#aa##########.#####a######.#.#######abbcbddbdfhgeaaa##abbcdcaaa##aaceghdfgffffffeeddddcccbbbaaaaaaaaaaaa##aa#aaaaaaaaaaab##a#baabbabbbaaaababb", +"ccddefgfefffd#a##aaaaaabccbabaabaaa##########...############acbaabaabaaaaaaa#aaa#aabaaaa#aaaabgkjiifbabbabbaaaabaaabbabaaaaaaabcc#####cgkmjgfhfcbcaaaabcbaa########a#aa###a###########.####a######aa##bghfefgeddeccbbbccccccbcdcaaa#a##a#aa#a#aaaacbaa##.############aa########.#######bbbccddddggfbaa###abbcbaaaa#aaabeeeeggghgggffeedcccbbbbbcbaaaaaaaaaa###aaaba#aaaabbaa#a#abbbbbbabdbbaaaab", +"bcceddefhgfcbaa#a#aaa###aaabbbaaaaa#######################aababaaaaa#aaaaaaaaaaa#aaaaaaaa#aa###cefllgabaaaaabbbaaaaabaaabbabaaa#ba######bfjljhghcac##aaacaa########a###############aa#.##a#############afgfgfedcccccbbccccccddcccaa##a####aa#aaaaaabaa#################a#a##.#########aaabccccddeegfbaa###abbaaa#aaaaaabdfceghhhhhhgfedddcbbbbbbbbaaaaaaaaaa###a##aaaaaaabbbaaacbbabbbbbcccdaaaa", +"bbcccdefhiea###a##aaa######aaaa#aacb##############a####aaabcbbabbaaaaabaaaaaaaaa##a#aaabaaaaaaaaabekljbaaabbaabaabaaaaaaaabbaaaa#a#aa#####aekkhhiba###aabbbb#####a.#########a#a#####a#######aa####.#aba##gggfeedccbbbbbbcbaabccbcbaa##a###aa##abaaa#aa###..###########.###a##.#######aaaabbbcdddcefgaaaaa##abaabaaaabbaabdeffghighhgfffeeccbababbbbbaaaaa#aaaa#a####aaaaaabbaabbbbbbbcccbcccdbaa", +"bcccccdefgeaaaaaaaaa#a#a#a##aaa#a#aba#######a#.###aa######bcaaaaaaaaaaabaaaaaaaa###aaaaaabbaa#aaabbchkkc#aaaaaaaaaaaaaaaaaaaaa#a#aaa#a#######dkklibca#aaabcdca#a#aa#################a######aaaa######aab#cghhgfddcbbbbaabaaaaabbca##a##abaaa##abaaba#a#aa############...##.###.#..####aaacbbcdccdcdedbaaa#a#acbaaa#aaaaaaabcffffghhhfggfeddbcbbbaaaabbaaaaaaaaaaa#aa#aa#aaabbbcccbbbbbbbbbbcdccb", +"bbbccccdfcec##aaaaaa####a####aa#aa#aca##a####baa#######a##bbbaaaaaaaabbbbbaaaa#aaaa##aaaaabbba#aaaaaadijgaabaabbaaaaaa###aaaaaaaaaaaaaa#######behlidcdbaaabbcecaa######a###aaa###########a####a#######aaacghihgfedcbaaaaaaaaaababbbaa###aaa####a#aba##a#a#####..######......#...#.#.####aaccbcccdcdehhdaa####bcba###aaaaaaabaaadfeeegihgecdedcbcbaaaabbaaabaaaaaaa##aaaa#aaabcbbbccbbbbbbbbbcbbb", +"babbcdddddde######aaa###########aaaabda##a####abaaa#####abbaaaaaaaaaaaaaaabbbaaa#aa##aaaaaaaaabaaaaaabcdkib#aaaabbaaaaaa####aaaaa#aaaaaa##a##a##acgjhfgefcbbacccbaa####a######aaaa########a#############bfffhjigedddbaaaaaabaabbbbccaa####aa###a##aa#################a##.....#..#########aabbbbcccddfheaaa####bba####abba#aaaa##bca.#bghfedecbccbbbaaaaaabaaaaaaaaa#a#aaaaabbbbbbbbbbbbbbbbbbaba", +"bbabbdcdddcec#####aaaa#a####a###abaaaaaa##bda##aaa######aaaaa#######aabbbaaaaaa##a##aa#a#aaaaaaaabaabacbdjjbaaaaaabaaaaaa##########a#aa##aaa##a#a##cfhhededabbdcbcca##########aaaaa############a######a##dffgjiiheedcbaa###bbaabbbddba#########aaa####################a###..###..##..###aaaabbbbcbcfffebaaaa#aabaa##a#aaaaaaa#####aa#.bdegfeccbbaabbaaaaaaaaaaaaaa#aaaaaaaababccbcbaabbbbbbcbbab", +"dbbbbcdcdcdcea###a####a#aab#aaaa##aaaaaaa##a####aaa###.##aa###########aaaabaa#aaaaaaaaaaaaa#aaaaaaabbaabbbhkfcaaaaabbaaaaa##########aaa###aaba######.ekjgddbabbaabccbba########aaa####.#######aa##aaa#####dgfgghgggedcbbaaa#aabbbcbedba#######aaa#a####################aa#.......##..####aabbbbcbcdefeebb#aaa#aaa##ab###aaa#######a###.##cgefdccbbabbbaaaaaaa#aaaa#a#aaaabbccbbcbbbaabbbbcbccbbb", +"bcabbcceffabbc########aaa#aaaaaaba#aaaaaaaa########.#####aa######aa####aabbbaaaaaaa##aaaaaa###aa#aa#aaaaabbfkjhdaaaabaaa#aa##aa#####aa#a#a#aaaa######aikjjhbaaabbaacbaaa###############.###################bfhggggggfedcabaaaaabbcdeccaa########aa##########aa######a#a##a##..#.#...#####aabbbbbcccecdgccb##a####a##a############aaa######agfedccccbbaaaababaaaaaaa####aabbaaaaabbababbbccccbbcb", +"ababbccdffdbbbba###aa#aaaaaaa#baaaaaaaaaaaa#########.####ab###########aaaaaaabcbbbaa###aaaa#ba###aaa###abbbbflljeaaaaaaaaa###########aa##aaaaa#######.afikkiba#abbaaba##########a############################ehffgggfeedcccbaabababcccbaa######aa##aa###.###aa####...#########...########abbbbcbbbcdecfgdaa#######################aa##a####bfeeddccbbbbbaaaaaabaaa#abaaaaaaaaabaaaabbbbbbccccccc", +"adbbbbcdddecbaba#a#######a#a##aaaaaaaaa#aa##########.###aac##########a##aa#aaaabcbbaaaa##aaa####aa#aaba#abbbbdillhcaaaaa####aa####aa#aaaa##aa#########.#chkli#aaaaabbaaa########a#aa###a###############.###aa#fggffgffedeecbbbaaabbbbcbaaa#####aa###a############################.######aababbcbbbccedcfccaaaaaaaa###############.####a#####bffeddccbbaaaaaaaabaaa###aabaaaaaaaaaaababbbbbbbcccc", +"ccbbccddeeeccaaca##a####aaaaaa##aaaaa#a#aaaa#########.###ab####.#a###aaa##aaa#aaaabbaaaaaaaaaaba#abaaaaaaaaaaachkklfbaaaa##########a##abaaa############..#bimiaaaaaabaaba##########aa#babaa##############.##a##aegfcbdeedfedbbbabbabbcbbbaa#####a#####aa######################.#########aabbbbbcbbacddddccaaa#aaaaaa###a#####################afgeecdccbaaaaaaa#abccbaaaaaaa#aaaaaaaaaaaabbbccbcc", +"ccedcdddeeeccbbbcba#a###aaa#a#a#aaa#####aa#a#############ab#####.#####aa#a#aabaaaabbbbabbba##aa###acb#aaaaaaaaacfihkida##a#a###.####aaaaaaaa##a###aa######.ahljc#abaaaaaaa###.####a######abaaa############.#####.bababeedegdcbccbcbabaaabba#a##aa####aba#aba#a###################.####a##ababbbcbbbcdddedea#aaa#a####aa#######.###.######a##a##fgfedddbbaaaa#bcdccbbba####aaaaaaaabbabbbbbbbcbbc", +"cddeddddeefddcbbcc#a#aa#aaaaaaa#aaaa####aaa######aa######ab#a########aa#a#aaaaaaaaaaabbaabba#aab###abb######aaabbcfheihc######a#####aa#aaaaaaa####aaaaaa###.aikjcaaaaaaaa#################aaccbaa#a################aaaaaaabdddcbccbaaaaaaaaaaa##b####abbcccb##.###a#############..###aaaaaabbbbbccbbccccddecaaa#aaaa###a########################effedccaabbaccbbaaaacc####a#aaaa#aabbbbbbbbbbbcc", +"dcdcdcdeddfecdcbcdaa#aaa##a###a###aa##############aaaa###aba#############aaaabaaabaaaabbabbaaa#aba####a##a###aaabccefadhhb##aaa#####aaaaa#aa#a##aaa#aaa#####.aflkcaaaabaa####################ddcbaaa#################a#aaa#bdddbbcbaaaabaaaaaaa#a####a#baa####a###a###aa#############aaaabccccbcccbbcdcdedefb##a###aa##aa###############a##aa####efddcbcecbccabbaa#aacc###a##aa#aaaabbababbbbccc", +"ccdddcbcfhfddcdcbbc#####a#aaa##a########a#a#aaa#####aaa##abaaa##.#######aabbaabbaaaaaaaababbaaa#aaaaa###a#a#a#aaabccdha#diga##aba#####ca##aa####aaaaa#a#######acildaababbaa###########a#######abccbaa#########.#########a###cdedbbdcbbabba#aaa###a####aaaa#aab###a##a#aa######aaa######aabbccccccccccddddeddfca#aa##aaa#aaa#####a####.###aa#a##a#cfeddedacaaabcaa###aacc###########aaaaaabbbbbcc", +"ccccddccdeffdcccdccb########aa##########a#aaabaa#####aa##ab#aa###########aaaaaaababaaaaaaaabaabcabba############aaabcffb.afjfa#aba####a#a########a#a########aa#abhjb#aaaba#a##########a#######aabcccbb####.#..###aba#########abddbcecbbcbba#aaa########aaaa#a#a###aaa########aaaaa#####aabccdcddccccccccddedcec###ba#a####a#a##########.######aa#adedcbbaabaaabbaa###aabca##aaa#a##aaaaaaabbbbbc", +"cccccdcedcddfebbdcbdb#######################abcbba#######bbaa######.######aaaaaabbabaaaa##aaabababaaaaa########aaaabbcfiea#bgjeaaa######aa#a#############a####a#acgigaaabb##########.##a#######aaa#adcba##########ba#a#a#####a#adfcddbcccbaa#aaa######aaaaaa##aa#aabbab#aa####aaaa#####aaabbccdddcdcbbbbcccddegd##baaaaa#########a################abbcccbbbbabbbba#####abca##aaa####aa#aaabbbbbb", +"bbbccddcdcddefdbcdadcaaa#####################aabbbba#a#aabba#aa##########aaaaaabbaaaaaaaaa#a#aaabbbbbaaaa###a#aaaaaaaabfifa##ejgbaaa########a##################acbcfigba#aa###########a#########a#aaabbbba#######.#a#a#######aaaaffddccbccba##aaa##########a######aabaaa#.####aa######aaabbbccdeeefggecdedcdfedcbaacbaaaa##a#a####a############a##aa#accdcbcbbbbbba#####aaca#aaaaaaa###a#aaabaab", +"bbbbcccccddddfecbccbdc#a############a###aaaa#aaa#aa##aabcccc###########aa#aaaaaabaaaaaaaaaa#aaa#aaabbbbbbaa###a#aabaaabbbhie#.bfhfbaaaa###aaaaaaaaa#######a####aaabdhifbaa########aabaa###a######aa#####bccaa#####.#####a########afgeddccdcba###aa########a#a#######aa######.##########aabcbcccdffghihgdcddcbacbbeabaaaaaa#a###################a##aaaa#bcddcdcbbbab##a##aaaba#aabcaa####a#aaaaba", +"bbbbbbcccccdefedbbcacdc####aa##a#.##a#.##abb######a##aabbccc###########aa#aaaabbbbaaabaaaaaaaaaaaaaaabbbccbaa##aaabaabba##diic##adhebaaaa#aaa#aa##aa##########aabaaagjjf#a######a#aaaaaaa#a#######aa#a###bdddaa#a###.#a###########adcdddddcba#aaaaa#a###a##a##ba#b###aa####.###aa#####a#abcdcbbcdghihhgdcaaaaaabcfdccaaaaa#aa###################a##a#a##acbcdcbbcba#a#####aaba##abaaaa###aaaaaaa", +"aaaaabbbbbcddeedccebaccb###a####a####a#..aba##########aaaaccb.############aaaabbaabbaabbaaaaaaaaaa#baaaccbbaaaa#aaaaaaaa####fjfb###egebaabcb##aaa##############aaa#achkjbaa######aaaaaba#a#aa###a###########abba###################abaceddcbaaaaaaaa#####a#####a####a##a######.###a##abaaccddedeeffdghfaaaaaaaabbdfcabbaaaaa###############.#########a###bccbedcbdaa######a#abaaaba########a#aaa", +"#a#aaaabbbbbbcdedcccbabbb##aa######.######ba#############abcc##############aaaaababaaaaabbaaaaaaaaaaaaabbcbbccba#aaaaaaaaaaa#beihb##afgdbbcba#aaaaa######a######aa#abcilheba#####aaaaabaaaaaa#########a####a##a#aaa###############a#aaadedbbaaaaaaaaa##aa##a#######a##aab######.##aaaababceefcddcb#.#gfaaa#aaaaabcfgcaaaaaba########.#####################aabddcbcabaa##a##aaabaaaa######a######", +"##a#aaaabbaabbccdcbcbbbacb###a###########.aba#######aa###aacf#######.#######aaaaaabcaaa#acaabbaaaaaaaaabababbbcdcbaabba#abaaaaabfje#a#aehdaaaaaaaaba#####ab#a####aabaabijiebaa##aaaaaabaaaba##aa#####a#a###########a###a###########aaaaaabbbaaaaaabaaa#aaaaa#####a##abaaaaaa########abbabcdgeba##.##.bdaaa#a#aaaacfgcaaaaaa########.a########.#######a#aa###abccbbbaaaa#aa#abbab#abaa####aa#####", +"#####aaabbaaaabcbccccbbbcca###a############a#########aa##aaacb###.#.########aaaaaaaaabcbaaabaaaaaaaabaaaaaaaaaabcaaaaabaaaaabaabaejhbaa#aggcaaaaaaaaa####abb#a###aa##aabhigddbababba#acbabaaa###aa####a#c#a#############a#a########aaaaaaaabbaaaaaaaaaa#aa##a#####aaaaaa###aaa######aabbabege##b#######aa#a##aaaaaceecbaaa############################aaaa##aaacbbbaaa##aaa#aaaaa##aa#####a#####", +"####aaaaaaaabbabbdcbcdccbbba#aa####a##a####a######..##aaaaabab###.###########aaaaaaabbbbbbaaaaa#aaaabcbaabaaabbaaaaaaabbaaabbabab#bghcaba#dhfaabaaaaaa#aa###aa##aaaaaaaabeegbccbaaabcbbbaababa######aa#aaaaa##aa#.######aaa#########b#aaaaaabaaaaaaaaaaa#a##aa#aaa#aaabbab##a####ab#aabbbbcfhaaca##############abbabddbbaa####################.###a##a#aaaaa#aabbbbbaaaaaa###aaaaaaaa#######a###", +"#####aaaaaabbbbbccdbccdcbcca##########a#####aa##a######a#aaaabc###############aaacaabbabbbbbaaaaaaabccbbaaaaaaababcaa#bbaaaaaaaa#ba#eiebabaafhb#aaa###a#a####aaabbaa#baabbbigcebaaabcbbcdbbbcca#a##a###acbbaa#ab##########aaaa########aababbbaaaaabaaaaa##a###a#aa###aaaca##a#aa.bc#abbdccbdga#####.###########abbbbcdebaa##a##a##########a####.###a#aa###aaa##aabbabbba#a#####aaaaaa########aa#", +"#####bbbabbbabbcddddcccbbbcca#a##aa###a#################aaaaabb#a####.########aaaacaaaaaacaaaaabcaaabbcdcbbbcbabbbabbaaaaaaaaa####aa#cijdbababhfa#aa###aa##a##a#aaaaa#aabbbflggfaabacbaabbbaacbba##aa#abccbbaa###aaa#####a#aaaba###a#aaaaabbacbaaaaaaaaaaaa###aaaaaaaaaacaaaa#bbab#abbcccccbdc#################aabdceedebaa#########################b#####aa#####bbbabbaa#a####a#aa##ba########a", +"aa##aaabbbbccbbcccddcdccabbdfa####a###########aa######a#a#aacc#######.#########aaabababbaaaabbaaaaaaaabbbbaaaaaaabaabbbaaabaaaaacba#a#beijbaaaaehfa###########aa#abaaaabbbbdhjghffedccaaabaabaabbaaaacbcbcccbaa#aaaaaaaa#aaaaaaaa####aaaabbaadebbaaaaaaaaaaa###aaabaa#a#aaaaabbbbbbbabcdcccefe####.##.#######.##a#aacccccaa#aa#####.###############aaa###.#a###a##bbbbbaa#a########aaaaa##a#####", +"###ab#ababbccbcbccdddccccbbbeda##aaa######aa###abaa####a###abdb#a###.######aaa#aaabbbaaaaaa#abbbaa#aaaaabdaabbcbabb#aaaaaaaabaaacbcba####ejdbbbacgjd##aa#aa#####aaabbaabaabbejiiiihhggfbaabbbaabcba#bcdcdddddcaabbbbcbaaaaabaaaaaaa##aaabbbbcdedbcbaaaaabbaa#aa#aabbaaaaaaabccbbbbbcdccddffebb####################aabccccca###########.#########a####aaa####a##aa#abbaaaaaa########aaa####a#####", +"#aaaaabbbabbcccccdedccccedccdebabaa#aa###########baa##.##aaa#aca#######.#####aaa#aaabaaaaaabaaaacbaaaaaaabaaaabcbaabaa##aaabaaaaabaaaa###.cjgcbbbadiib##aaaaa####aaabbaaaaabdhlijjiiihfefcbaabbbbbbababdedfddedccbccdccbccdccccbaa#aaaaababcccdddcccbaaabbaaba#aaaabbaabbaccdddcdefffedeeed..################.######abcbdfbab#a###########################a#a#####aaaaaaaa##aaaa######a##.#a####", +"###aaaaabcbabccccdcddcccccbbccebaaaa##############a#a####aaa##abb##############aabaaababaaabaaaabbaaaaaaaaaaaaaabbcbabbaabaaaaaaaaaaaa####.afhdbbaabfihb.#aa###aa###aaba#aaacclljjiijigddecbaabccbabbbdbadcbeffffeffgghhhighgfhgffcaaababdbbbbcfddddcbbbbbccabaaaaaaababddehggfegjiedaaaa#a####a##############.######bcdcddbaaa##a###################a#a#####aa####aaaa#aaa#a########a#######aaa", +"aa##aaaabaaabbbdddccdbcddcccccdd##a#aa##aa########a######aaba###ab##############abaaaaacbaaaabaaaaaaaaaaaaaabbaabbaccbaaaaaaaaaaaaaa#########bfgbaabbdije.######aa#abbaaaaaaabellkkkkllkiiigfdcdcbabbcbcdcbcgijkjhhhhijjic#dcbcbddghffeeeihiggfgddedcccbcdcdcbcbcbabadeeffghhhebegdddb#########a#a####################babbbcbbb##a##################aa##a####aa#a###aa#a#aaa##a#######aaaaa##aa#", +"a#aaaaabaaaaaabcdcceccefcadgeceebba###a#aaa########a#####aabaa#aabda########a####aaaaaaabbaaaabaaaaaabbaaaabbbbaaaaaabbcbaaaabaaaaaaa#aa######.eiebbbbcfihc#.###abaaa#aa##aaaabellkjlkjklmnnmlkgfccbbdddeefghjijkkllkhd#cfeabcbbcbbdgjjhgecccehieeededccceeedddddefcdffcedbacdec#bbaba#########aaaba#########.#######aaaacccdbbaa####################aa##a####aaaaa#aaaaa#a####aa######aa#aa##aa", +"a#aaaabaaaaaaaabcccdddggedbdfccecaaa###aaba#a#######aa#.##aabba#aabc###########aaaaabcbaaaabaabaabbbabaaaaaabbcccaaaabbbbbbaaabaaaaaa#aa#aba###.bigbbbccdilid.##aaaaaa####aabbbcekmljgdfiijikmlmnkgdeefeeegieeddgdcghgdbabcfdebcccceffggfcbbbbbcefgedddcceeefdedcbccefgb####babedcaa##aa#######aabcda##.#############aaaaabcdcdbaa#########a########a###a###aabbbbaa#aa#aaaaa##aa######aaa##aaa#", +"##aaaaabbaaaaaaabcdceeffedccfgedcaaa##aaaa###a#a#####aa..##abaaaabbd#########aaaaa#a#bbbbbbaaaaaaabbbbbaaaaaabccbbaaabaabbbbab#aaaaaaaaa#aaaaa###ahibbcdccgjkg####a#aa####aabbcddegkhddgihhghiibdilmljjjjiiihfaaa##aeeedcbbdghfdbbdfedfedccbbbbdbffhfededeefhhfc#####cea#####aaabdfda.a######.##abdfb##########.###a##aaaabadefecb#a##########aaa####a##aa####acbbbaa##aaaaaaaaaaa#####a######a#", +"a##aaaaaabaaaaaabacddeddfdccefffd#aaaaabbaa#a#####a#.aaa###aaaa#abbdb########aaaaba#aaaaababbaabbbbbbbbbaaaaaaa#abcbaaababbbbcb#aa#abaaa###########fhdcccdcehihb###aa######a#bccdefggiglkjjhiihba#cglkjhiihgebcaaaaaa#aacdbbdefhfdbbeedbccbbbabdcbgjifefedeggfgfa#aa#a.aa######aaaacffba####.###abdeca######a###########aabbegffgedaaa##########aa####a##aaa#####aaaab#aaa##aaa#aa######a#######", +"##aaaaa#aaaaaaaaabbcdddceddeeecdfbaaaaabbbaa#####ab#########aaaaaabbc########aababbaaaaaaaabbbaaaabcbbabbaaabaaaaaaabbbbaaabaabbbcaaaaaaa##########.bhfcccdddefigc#abaa#aaaaaacccdegeiihkihhjhbbaa#.#a##a#..##aaaaaaaaaaaacaabaacefedefbbedcbaccdbcfgiihhfdec.addb#ba###aa######aaaaadgeca#######aceaaa#################aaabdgeeghffb########a######aa####abaa#####a#aaaaaaa#aa###a#.######aaaa#", +"a##a####aa#aaaaaaabccbccdedefebbef#baaaaaabaa#####a#aaa####aaa##aaaada########aaabbbaaaaabbaaaaccbbcabbbbaaaabaaaaaaaabbbbabbbbaabcb#a##a#########a##bifdccdddefgjeaaabaaaa##accbbcddfhehijhdb#aaaaa#a####a#abaa#aa##aa#aaaaaabbbaabefigffefdbcccdcbaacbbdhhfeaacbabb##a##########aaaaadhgb#####aabecaa########a###########baegfefgfeca##a#######a##aaaaa#aaaaa####aa#aabbaa#aaa###a#.#####a#aaa", +"#aa#####a#a#aaaaaaacccbbccdcdedbcfcaaabbbaaaaa####a###a###abdb####aaeda######a#aa#aabbbabbaaaaacddbaaaaabaaaaaaabcbaabbbaabbbbbbababa####aa###aaa#####dihecccdedeejgaabcbaaaaabcbbbcdeheggeabaaa####aa########aa###aaaaaaaaaaaaaaccbaabdegedddddddccbbbba#abaabcbbaaaa##a##.#.#####a#a#abefb#####abdfaaa#####aaaa#a########aaadfeeffffc#######a######aa#aaaaaaa#aa##aa#aaabaaaaaa#######.###a#aa", +"aaaaaa#aaaaaabaaaaabbcbbabbbcceedffdbaabcaaaa##abaa##aa###acefa####abdaa###.####a##aabbbcbcbaaaaabba##aaabaaaabaabbbaabbbaabbbbabbcbba#a##aa###aaa#####bhjgccdddefdhheabbaaababcbbabcdehfcaaaaaaaaa#aaaa#######aa###a##aaaaaabcdaabbbbabbbefedeccddcbbbaababbbcccca#a####aa#############aaceda###aabfebaa####aaaaa##########aaadefedegca########aaa##aaa#aaaaaaa##aaa##aaaaaaa#bcba#########aa##", +"#aaa#aaa#aaaababcbbbbccbaaabbbbdgffgbaabbbaaaa#aaa####a##abbgea##aa##bca#########a#a#bcbabbbbaaaaaaaa##aabaababbbaabaabbbbbbbbbaaaabbaa##a#####aaa######adhidddddfhdfigbcba#aaaaaaaacbcfdabaaaaaa#aaaaaaa#######bb#####aaa##aabccaaabdcaaaeeefeddefcbbbbaaaabcbbbcdba#####a####..#######a##abdb#aabcefdaa####a#aaaaa#######aaaaaabacefc#########a###aaaaaa##aaaaaaaaaaaaabaaaa##aaaa###.#####aa#", +"#############aabaaaabcbbaaaabbcceeeeeaaabbaa##a###ab#####abddb#####a##cb#######aa#a##aabbbbbbbaaaaabaaa##bbabbbaaabaabbbacbcbbbcbbbbaaa###a######aa##a#baaagkecdeegfeehfcbba##aaaaaaaaccdcbaccbaaaa#aaa##aaa#########a##a###aaabcaaaadeddbbdcdeigfdbcccbaa##cbabcbcdaaa####aaa######.######aa#debaacfdcaa#####aaaabaa########a##aabccdd#############aaaaaaa###aaaaaaaaaaaaaa###aaaaaa#########aa", +"#############aabbbcbbccbaaaabbccddeedca#abaaa#aa###a##.##aaaa#######aaaca############aaaaaabaabaaaaaa##a#aaaaabbaaaaabbbabbbcbbccbccbaba##########a##aaabaabejfddddehddhgdbbba##aaaaabbbcccaabaaaaa#a#a##a#aaa###############aabcaaaaaegeddcecacdghfdccbaaa#cbabcbac#######bba#################bcdcbeebaaa###aaaa#aa#a###a####abaabdcdcba#a##a####aa###aaaaa##aaaa#aaaaaaaaaaa#aaa##aa#########a", +"aca##########a#aaabdbcccbaaaabbccddeedbaaaaaa#aa#########abca#######a#aca############aaaaaaaaaaaaaaaaaaaaaaaaabbabaabbbbbabbbcbbbbcabbbba##########aa###aabbbeidbbccehefhhcbbaaa#aaabbaaabbcaaa#abcaaaaaaaaaaaaa#####.########aaabaacbedfdbbbdccccfhebaabaaa##a#acaba######daa###.######a####aa##acfdfdaa####aaaaaaaa###aca#aaaabaabccdeaaa###aa#aaaa##a#aaaaaa#abaaaaaaaabaaa##############.aab", +"aa#bb#####.######aaabcccbbaaaabbbcddeebaaaa########.#####abca##########abaa####a#####aaaaaaaaaaaaaa#aaaaaaaaabcbbaaaaaaaabbbbbbbbbccabbaa#a#########a#####aaaachdbccdefehgiebbbaaaaabaaabccacbaaaacbaaaaaaa#aaaaaa#############a#baaaaceddbaabcbebbefdcaaaaa###ba#baa#####.aba##############a#a##aacfghdcaaaa#abaaaaaa######acbababbbdbaa###aaa#aaaa#a#aa#aa#aa##abaaaaaaabaaaaa##############ba", +"a#aa#a#####.###a#aaabbcccbbbaabbbccccge#aa#######.#######abbba#######aaabbaa####bba###aaaaaaaaaaaaa#######aaaaabbbbabaabbaabbbbcbbbcbabbbaaa#a##a##########aaaabeccccddfgefhgaccaa#abbabbbbabbbba#aa#aaaaaaaaaaaaa#######a#####aaaaaabacdccabbbcecaacdfecbbaaaa#aaabaaa#####aa########aaab####a###aabeggbaaaaaaaaaaaaa#a##a###aaaabcccccaa###aaaaaaa#aa#aaaaaaaa#abaaaabaaaaaaa#a###########a#aa", +"###aaaa###a######aaaacccbbbbbbbabccccehb#a########..#####abbca#######aaaacaa####cca###aaaaaaaaaaaaa#######aaaabaaaacdbaaabbbbbbbaabbbbcbccaa############a#aaaaabaccbdccegeccffbbaa######.#abaabbbaaaaaaaa#aaa#aaaaaaa#a##########aaaabbcc#abbabaabaddcbceebbba#aaaaaba######a############aba###a##aaaccggbaaaaaaabaaaaabaaaaa#a#bbabbccdb#aa###aa#aa#aaa#a#aaabaaaaab###abbabaaa###a#a########aa", +"###aa#a######.######aacccbbbbbabbbccccfheaaaa#############bbcaa#######aaabcaa#####aa####aaaaaabaaaaa#aaa##aaabaaaaaacdcbaabcbbcbbbabbaabbbbca#a######aaa##a##a#aaacabccdeggacge.#aa####a#baaaabbabaaaaababbaaaaaaaaaaaa#########aaaaaaabda#aaabbbacbcdbbcdeca#a#aaaaa#a#aa#aa#############aa#####a#aaabcfgcabaaaaabaaaa#aaa#####babbbcccc##aa#a#aa#aaaa###aa#aaaaaaaaaaa#aabbaaaa###a#a#####abba", +"###aa##aa##########a#acbcccbbbbbbbbbcceffebaa#############accbaaa######a#bdcaaa####aa##aaaaaaaaabaaaaaaaa#abbbaaaababcddccbcccccbaabaaabbbbbca####a######aaaaa##a##bbabcbdgefeed########a#a###ab#aabbbaaaaaaaaaaabaaabba#####a#.#a##aaaabca##abbbaccbbdcbcdedb#aaaaabaaa###aaa#########aa#aaaaaaaaaaaaabceecc##aaaaaa#a#aa########abbacccc##aaa#aa##aaaa###aabaaaaabaaaaaaabaaaa####aa#####a#a#a", +"b###aaaaa#######.##a##abbdcbaabbbbaabccdegea########a#####abcbba###aa####acccaa######a#####aaaacbbbabbccbbaaccaaaaabbbcccbcbccbbaaaababaaaaabc###a#aa#####a#aa#a#aabdaaacbbafhgbfa.#####aaaaaaaaa#aabaaaaaaaaaaaabbbaaba###a###########baba##aaaabacaabccbccdeeaaaa#aaab####.########.##aabbbaaaaaaaaaaabccaccba##abbaa###a##a###a#aabbccca#aaa#a#abaaaaaaaaacaaaa#aaaabbaaaaa#aaaa#a#######a##a", +"baabaa#######aaa#####aabbccbbaaabbaaabccdfeba#######aaa###abcabbaa##aaa####ddbaa######a###aaaaaaaaaabbcbbbbbccaaaaaabbbbbcccccbbbaaaaaaaaaa#abca##a#aaaaaa##aaaaaaabcaaaabaabgicce##.#a##aa#a#aaaaabaccbaabaaaaaaaaabbbaaa#aabb##########aa#aaaaaaaaaaabccccddfebaaaaabbaa################bbbbbbaaaaaaaabbbc##acbbaaaaaa####a#####aabbbcccb###aaaaaabbaaaa#a##aa####aba#bbaaaaaaabaaa#######a##a", +"baaaaa#######aa#######aabccbabaabbbaabbbcdgdb#a########a##abdbbaaaa##aaa##abdcbaa#############aaaabbbbbbbbbabccaaaaaaaacbbbcccbccccbbaaaaaaaabbca#aaa#a#aaaaaacbabaa#aaaaaccbbjgabc###bb######abaaabbcccbabbbaaaaaaaaaaaaa##aaaaaa#######aa###aabcbaaaabbbccdeeefebaccbbbbb#.####a####.###abaabbbbbcbaa#aaabca.##acccbaaaa########aaababbcba##abaaaaaaaaaaaaaaaa#aaa#baaababa#bbaaaaaaa#######aa", +"aa##aaa###############a#abcbabbaaaabaabbbcffcaa##aa##aaaa#abbbbaaaaaaa##a##abdbaa##############aaaaabbaacbabbbcaaaaaaaabbbaaabacbccbbbaaa#aaa#aabb#aaaaaaaaaaabbbbaaaa##aabbbadiabbc.##c#######aaaaaabbccbbabbaaababaaaaaaaaaa##aa#######a#####aabbaaaabcbbbcddcefhgceeaabba##############abbbbbbcbaa###.###aca####aacdba#a#a######aaaabbcbbaa##aaaaaaaaaaaa#aaaaaaaaaaaaaa#bababaaaabaaaaaaa#ab", +"cb####aa################abcbbbaaaaabbaabbbdgdb##a#aa#aaaaa#abaabaaa#bba####aaddba#######a#########a#abbaaccccccbaaaaabaabccbbabaabcbbbbaaa#aa###acda####aaaabaaabbcbbaaaaa#bcbcebbccd#.aba######aaa#a#acbaaabbbbbaaabbdbbca##ba###abc.#.####.##a#bbaaaaaaccccdecdefghgfccccb#.####.#...###aaaabbabddba###...##bb#####a#bcba##########aaabbccaa###aaaaaaaaaaaaa##a#aa#aaaaaaaa##ababbaabaaaaaaaab", +"ec##########a##aa#.#####abbcbbaaa#aa#ababccfffcaaa#aabaaaaaabbaaaaa#aba###aabbfdaa###.#############a#aaabbccbbccaabbaabbbbbbbbabaaabbbbbaaa#a###aacdba##aa#abbacbbcbbbaabaaabbceabccde.#c#aa######aaa#aaa#aaababbabaabbdefecd#aaaaaaec#.#########aaaaaa#aacdcbdbabdfegddffdba##.#.###.###aabbbbabbccbba###.#.##bc#######abbba########aaabbbddcaa##aaa##aaaaaaaaaa#aaa#aaaa#aaaaaababaabbaaaa##ab", +"bca######.#####aa#######abbbbac#a##aa##abcdcehfaaaabbbaa#abcbbbaaa#aaba#####acegdaa####.############aaaaabbbbccccbabababcbbbbbaabbcbbabaa##aaa###aacebba###bffcdbcbbcbbcaaaabbbhbabbcee.##aa##aaa#acaabbaaaaaaabccaaaaaabdefge##aaaacea###########a######abdfdabaaaaababaceeb###.#...#.##aaabbbabbbaabaaa###..##bea###a##a#aca#a#a#####aaababb####aaaa##aaaaaaaaaaaabaaaaa#aaaaaababaaaaaaa###ab", +".#a###########.b########aacaaaacaaaaaaa##acdffgbaaabaaa##aaehdbaaaa#aaaa#####acfgbaa#########.########aaaabbabcdecbaabbabbbbbbbaaababaaaa######a##aaddbaaaaab##a##abccccccbbaabfhaababgd.######aa#aaaaaaaaaaaaabacdddbaaaaaaddeda#aa#ba######..##a########abdcaaaaababcabbbcddb#a###..#.##aaabccbbaaaaa#########abed#########cb#a#a####a#aaaaacb###a#aaa##aaaaaaaaaaaabaa#aaaaabaaaababaaa######", +"#########aaa###a########abbaaaaaaa#a#aaaaaacdegeaabaaccbaa#acefcaa###aabba###aadfdbbaa####.#############ababaaabcccaaaaabbbbbbbabaaabbbbaaa#####aaaabdeaabbba########aabdedcbabbffaababhd########a#aaaaaaaaaaaaaaacedbabaaba#bfggcaaa#########..#.########aabcb#aaaaaabaababccddba#..##.####aaabbaaaaaa##...#####acecb########abba#aa#a#aaaaabbca##aa#aa#aabbaaaaaaaaaaaaaaaaaaabaaaaaabaaa#aa##", +"##########aa###a#####aaaaaaa##aaaacc#a###aabbcefbabbcfcddddbabgfa#a#aaaadbaa##abdedcaaaaaa#############a#aaaabbbbaacbbabbaabbaaababbaabababa##a##aaaaaccbbbb########.###abbacdcccgbabbbcida####aa#a#baaaaaaaa##aaabccaaaaaacbbabggb#a#####aa##..##aa######aabbcbaaaaaaaba#aabbcccca#.########aaaaaaaaa###...#######abdec########abb#aaaaaaaaaaabcbaaa#####aabbbb#aaaaaa#abba#aaaaaabaaaaaaaaabb#", +"###########aaaaba###aaaaaa####aaabdebca###aabbcfgfbacdccdeheaadgea###a##dcabaaaabdedcbaa##################aaaaabbbccbaabcbaabbbbabbabbbaaabaa#####aa#abddbcb##a########a##.##accdeedbcccejcbaa####aaaaaa#a#aaaa###aabbbbaa#bdbb#chfa####a########.###########babbaaaaaabaa#aaaaabbcdc#..######aa#aaaaaa###.#..#####a#abdeba#######bbbbaaa#aaaaaabcca#aaaa#aaaabbbaabaaaaaaaba#aa#bbaabbaaaa#####", +"######a##a###a#aaaaa#aabaaa##aaacddbbcaa##aaaabdifdadeeddfffaabdddbaaaaabd#aaaaaacfedcaa#################aa###aaaacccbbabbbbaaabbbbbbbbbaaaaa######a#aaacdddaaa#########a######aabbicceedghcbb##aa#aaaaaa#aaa#a####aaabbaa#adffbafgd####aa###################aaaaaaaaaaaaa#ababaaabbbcb#.####aaaa#a#a#a##..########a#aabbcdd#.###a##bbaaaaaaaaabbbbba######aaaacbb#abaaabaa#a#aaaabaabbbabaa####", +"######aaaaa####aaaaba#abaaa###a#bddccaaa######abcfgghhhfdfffcacbabdecca#bca#aba##aeffeba##############.########aaaaccbbbabcbbbaaaababbbbbbbaaaa######aaaabeeaa#aaa######a###a#aaaabfgdbbddhhccb###aaaaaabaaa###aa##aaaaaaaa#bffgd#cda##a#a######a#a###########aaaa#aaaaabb#abaaaa#aaaabbca####aa#aaaa####.#############aaabcdc#####a#abba###aaabababc#aaa##aaabcaaaaabaaaaaaacaaaabaabbbbbaaa###", +"a######aaaa##a#aabbaaaaacba##a##acccddbaa#a##aaaaacccdefefefdacaaaacgebcdb#a##aacbbegfdba#aba##############aa###aaabcdbccbbabcbbbbbbbaabbabaaa###a###aaaabcdb#baa#a###########aaabddgcdcbbcfidbcb#aaaaabaaa#a#a#abaa###a#aa##dfffeaa#####a#####aa##b.######.###aaaaaaaaaacbacaabaaaa#aaaacccaa####################a########abceca###aa#abaa#aaabaaaacda#aa###aacaaaaaabaaa#aaabaaaacbbbbacaaaaaa", +"aa##a###aaaa#a##aaaaabbbbbbba####bbbacbaaaa##aaaaaabccbdedcefaccaaa#accccaa##aaabcddfgefeeffea################aaaaaabbcbcbbcbabbbaabbaacaaaa#a#######a#aaaacfcaaa##a############aacdee#a####eifccc#aaa#ccaa###aaa#ba###a###a#befffd######aaab###aa############aaaaaaaaaabbcbcdbbaa###abbaaabccdca...#######aa#a####a######aaaabcdc######aaaaaaaaaaabbcdbaaa##aababaa##aabaaaaaabaa#abbbbaaba#aaa", +"#aaaaa##a#.###a#aaaaaceccbbbab##aaaaaaaaaba#aaaa#aaabccbcdddgfdaaaa######aa##a#aaaeggihgeefeddeca###############aaaaababcbbbbaabaaaaabacbaaa##a#####ba#aaabadgeaa#a##a####a##a##aabbeeaa#####bhibaca##aadbaaaaaca###########aadfddfda###abaabb#aaba#####a######baa#aaaa#abdc#bccbaaaa###ba#aaabdfeec#########aa#aaaa####aa#aaaaabde###a###aaaaba#aaaabbccbaaaaaaaaaa#a#aaabaaabbaaaababbbbaabaaa", +"##aa####a#####aaaaabcccbbbcbbaa##aaaaaaaaabb#baa##aaabbcccdefgiecbaaa##aabba###a#affghihfccdddddeca################aaabaaaabaaaaaaaaa#aaaabaa########aaaabaabcgcaaaadda#aa#######aacdde#######aegbbdbaa#adbbaabcaa#aa#########acfeeecaaaaaaaabbaaaba###########aaaaaaaaabddfbaaababaaaaaaa##aba#acefgca###aa#####abb######aaaaaaabcfa##a###aaaabdaaaabbbbdb###aa#aaaaaaaaaabcbbbbbbabaabbbbbbaa#", +"####aaaa#a#####aaabccccbaabcbcca##aaababbabbabaaaaaabcccbacddefffdccabccdedaaaabdeeffgggeccddccdcdca#a##############aaacaaaabaabaaaaaaaaaaaaaaaa###aa###aaaaacdgcaaabaaa#######a##abdchaa######.cfcbcb#a.bffcbbbab###aaaa###a###ceedddabcbaaaabbabbaaaa##..#####aa##aaaa#acecbbcbaaaaabaaaa##aba#aecbccdcabaaa##abbaa#a##aaaa##aaaabdd##aa##aaa#aaababbbbbdb#a##aabaaaaaaaaaaaaabbbbbbcbbbbcbbaa", +"aaabaaaa####aaaacccbbcbbbaaaabdaaaaabcaabcbbbbbaa##abcddcbcdefedffedbdccdeec#aafffdddeffcccbcdcccccccaa#############aaaab##aacaaaaaaaaaaaaaaaaaaa###aba#aaababdefaaaaaaa##a###aaaaabccgcaa#######bgcdeca##bhgbabaac##a#aaa##a###befddfdddbddbaacabbbbaa####.#######a#aaaaaacbaabbbaa##ababa##aa##acaaaabbcb#aa#a#aaa##aa#####a#a#aaaabeca#aaaaaaaaabaabbbbbdb#aaa#abaaaaaaaaaaaaaaaaaabcbaababaa", +"aaaaaa#aa#####abbbcbbabcccbbaaabbccccdbabccbbbbbaaabbcddcbceeeddeggddfbcdeec###dffedddeddcccedccccbbcdb#################aa#aaabaaaa#baabaaa#aaa######aaaaaaaabbcdfaaaaaaa#a####a#aaaabge##########bhcbccaabdeeaaaa###a###aaaaaabceedefeeedeeccabbabcbbaaaaa##.#.#######aaaabbb#aaaaaaaaaabaa##a##aaa#acbcabca###aa####aa#########a##aaaedb#abaaaaaaabbabababccb#aaaaba#aaaaaaaaaaaaaaaaabbbbbaaa", +"aaabaaaaaa###aaabbbbbaaaacbbbbbcccddefdaabbbbccbbbbabbccbcdddddeeeffefcedffedbabeeecddcbcccbdbbbabbbabba#aaaaa##a######aa#a##aaaaa#a##aaaaaaaaa###aa##aa###aaabbdedaaaaab#a####aaaaabbgha#a########becaccdfgddda#aa#aaaabaaa#a#addeecdcdfeeeddcacbbbcbbaaaaaa###########aabacbaaaaabaaba#baba#aa##bbbdbacaabcb##aaaaaaaaaa#########a#aaabddbaaaaababbbbbaaabcccbabaaaabaaaaaaaaaabaaabaaaabbbbaa", +"abbabbaaaaaaaaaaaabbabaaaaabbcbbcdedfggccbaaabbbbccccbccddeddccdddcddecddeffddecddccacbaacbbbbaabaabaaaaaaaaaaaaaba####a###ba#ba#aa#####aa#aaaaa############aabbcdebbbaaaa########ababdhf#a#########afecfffebceaa###aaa#aaaaa##abeeddddeegffdcfdbbabcccbaaaaba###########aaaabaaaabbaaabbbaabbaaaaacdcaacaaaabca##aaa#aa#aa#aa#######aaaaacee#bbaababbbbbbbbbccdcaaaabbaaaabbbaaaaaaaaaabaaaaaab", +"babbaaabaaa#aaa#aaaaaaaaaaaabbbbcdbadccdbbbaabbbbbcbbccdeeedeabcccccccccdeedfddcccdbcbaaaaaaabbbaaaaaaaaaccaaa#aa##aaaabbaab#a####aa####aa##aaa###############abcdedbcba#####aaaa#aabbdhie.#####a#####fgffececeda###aaa#aaaaaa#cddecddcddefeegefeccbccccbaa##aaa#.#####.##aaaabaa#aaaaa#aab#bcccbbccbbaab#aaaabcbbaa#aaaa#a#a######aaa##aaabdfdbbbbabbbbbbbbbbccccaaaaaaaaaaabbbbbaaaaaaaaaaba#b", +"bbaaabbaaaaaaaaaaabaabbbaaaabbabcedcbbabccaaaaabbbaabbceffcccbbcbbbbbbbbddcdddbbbabbbbaa####aaabaaaaa##aacfeaa######a##aaabbbaaa##aa#a#####bcca#a##aab##aaa#aaaacccgdbbb#######aaaaabbbdhhb###########aeifddbbceda#aaa##aaabaabefffcdddccdeeeedeffefeddccbaa##aaa###.###..aa##aba##aaa#aaabaaabccddcccaabaababaabcca###aa#aaaaa####aa#####aaacffbbbbbbbbbbbbbbbbcdcaaaabbaaaaaabbaacbaaaaaabbbab", +"babbbabbaaaaaaaaaaaaabbbaaaaabbbceddcbaaabbbbbaaaaaaabcdffdcabbccbbaaaabbbbbbbbaaaaaabaaa#a##aaaaaaa####aadd######a########abbaaaa##a#####a#aa########aaaaaa#aabbbbdgcaaa###aa##aaaaabadfgb######aa###aadidcdbaceca#aaaaaa#abcdeeeccdeddccddeadeefffffffecbaba#######.###.##aa#abaaaaaaaaabcaaabaabcbd#abaabbbbaaabdba#a#a##a###aaaa#########aacefdbbbbbbbbbbbbcbcccaaaabaaabbaabaaccaaabbaabbaa", +"baababbbbabaaaa#a##aaabbbaaaaabccehdbaaaaaaabbaaaa##aabdgieccccbcbaaaaabaaaaaaaaaabaaaaaaaaabaaaaa###a###aaa################aaaaaacba######a#a##########aaaa#abbbbbcdhb##a####aaaaaaaacbfe.##aaaaa#####aadhcbbaaefbdb##aaccddfgedbddccccbbcdedceceggfeefefdcbaaaa#####.###.###aaaaaaaaa##aba#aaaaababdb#aa#aaabaa###bcbaa#######aa#############abdffcabbbabbcbbcbcbcdcbbaaabbbbbbbaacabaaaaaaaaa", +"bbbbabbbbbbbaaaaabdcabdcaaaaaabbcdffcbaabaaabbbaaaaa##bcgjfbbbcdddcbbbbbbbbbaaabaabbbaaaaaaaaaaaba#########a#a###############aaaaaabaa#######a######aa#a##aaaabcbabbcceda#aaaaaaaaaaabbbec.a#aaaaaaa####aadhcabbbeecbaaadefggfeddcddcccccbccdccdddeghggeeeddcbaaaaa############abbaabaa#aaaaaaaaba#ba#aaaa#abaaaaa##aabbb###aa#a#a##a##########abbcffdcabbcbbbcccbbccccbaaaaaabbbbaabbabaaaaabba", +"bbbbbbbbbbbbbbaaabfdcccbcbaaaaacdceebaa####aaabbbbaa##bdghfcbaaacdddccccccccccbbababbbaaaaaaabbbaa#a##aa#a#b##a#aa###a#######abaa###aaaa##a################aaaaabbbcbbcffaaa#cbaaaaaaaacec.#####aadea##a#aabgdababdfda#adfggeddccccbbbaccbbcbcddddgghigffffbabbaaaa##########ab#aaaaaaaaaaaaa####aaaabaaaaaaaaaa####a##aaca##a######a#########acbbbbcdefdabbaabccbbbbccccbcbaaabbbaaaababaaaabcc", +"bcbbbbbbbbbcbbbbbcecccbaccedaaabddcaaa#######aabcbbbaabdfhfdcaa###acdcabdfeeedcccccbbcbbaaaaaaacbaa###aaaa#aaa#####a#aa##aa###ba###aaaaaaaba############aa#aaaaaaaaaabbbfgaa#adbaaa#aaaaehaa###aa#adea#a#aaabgbabacefdb#dfffedccbbaaaaaaccbbcdecdggihihhfdffcbbaaaa###aa###..#aa####baaabaaaaaa#####aaaaaaaa#aba#a###abaa#cbaa##.##aa####aa##aa#baaaacccefdbbabbcccbbbdccdbaabbbbbbbaaabbaaaaabc", +"cabaabbbbbbcbcccccddb##abaccbabbdbcaa#a##a####aabdcdbbcdddghcbaaa####bcacigggecbbbcbcbbabcaaaaaabaaa#a##abb#########a##aaaaaaaaaa###aaaaaaa########aa##aaaa#####aaaaa#acegfaaa#aac##aaaachfc###aa###aabb###a#bbabccddefdceffedbcaaaaa#aaabbbbcdegihhhhgggdcffecabaaaa##a##.###abca#aaa##aaaaaaaa######a###b###baa####aaaaaaaaabca###############aaaabbbbbbdfebbabcccbcdcbbdcbbaababbabaabaaaabbb", +"febaaaabbbbcdcccccb#####abbabbcccbbaaa####aa#a#abdeccbddeeehgcaa#a#aa#addhifdddbbccbcccbbbbaaaaaababaaa#aaba####a##a#a##aaaa#aaaaa#a##baaaaaaa#####b###aaaaaa##a##aaaabcefihefc##aaaaaabbdha####aaaa#ab######aaaabbccdefegffdcccaa#a##aaaaaabbehhhhffffcddbdcdbbba#ac######..###bb###a#abaaaaaabba#####aaa######a#aa#####a#####bbca###########a##aaabbbaaaabdfdbaccbccbcbbccdcbbbbaaaabaaaaaaabb", +"dedbbbbbbccbcdccddb#####bbbaacccacbaaaa###aaaaaaacfdcbcdegghigbaa#aaaaaadfhgedcccccbbbbbbbbbbbbbbbbaaaaaabbba########aa#aaaa#abaaa####aaaaaa############aaaaaaa###aaaabcfghgihfbcb#abaaabbge####aaaaab######a#aaaaaaccdeeddfdbcbaaa##a##aabaafhgggfedccccdccbaaabaaaaaa#########a#####a##aabaabcaa#aaa#a#####.####a###########a#aaaba##a####a#aba#aaaabbaaaaabdeecccbbcbbccccdcbabaaabbbaaaabbba", +"bccdcbbbcccccbcdfda#####acbabcbaabaaa#a###aa#aabbbefedcdffiihhcaaaaaaaabacfffefedcbbbbbaaaabbbbbbbbcaaaaaabaaa####a###a##aaaaaaaaba#####aabaa###########a#a####a###baabccghfhiieaa##aaaaabdga##a#a#aaaa######aabbaaabbbcddegdcbbaa##aaaaaaabbfedfddecbbbbbbaabbabbaaaaaaaaaa####aa####a#a#aaaabcbaaaaaaaa##############.######a#a#aabbba#a####a#aaaabaaabaaabbabcfedcbbbcbccccccbabbabaaaaabbccb", +"bbccccbbcccccdddeca####aabbccca##aaaa##a#####abbbbeeffeeccfjjifbaabaaabbbcdecdeffdbcbbbaabbbccccbbdcbaaaaa###########a#a#aaaaaba#a######aaabcaaabaa###aa#aaa######acedbcdfihfhifba####aaaadhc###aaa###########a#bbaaabbccccfecaaacca##aaaaaccffdfccedbbab#a#aaaabbaaabababaa###########aaa###bbaa#aaa#abaa##########.########aa####a#aabba#a###a###aaaaabaabaaabbbcdfedbcccbcccccabbbbbbabbbbbbc", +"bcdcbbcccccddddddba####abbbbdca#a###a###aa####aaabcededcbbgiijjhcabbaaaaaccddddcceedddddddeeefedbbcbcccbbbbaaa#a###aaaaa###aaaacaaa##a###a##acca############acaaaaa#abbccdghccggfcaba#aaaacggdaaa###############abbbaabbdeefedbaaaadda##aabbchedeefedbaaab#####aabbaabacbabaaaa########aa#a###aa####aaabba##a##.#############a#a####aaa##abdba#########aabbaabbabbaabdeddcbbbcccccbbbbaabbbccbba", +"bbddccbccdccdcebcbb#####abccbcd######aa##a######abcddcdddeggiihhhdaaaabcccceedccbbcbbccbccdeeeggfeddccdeccbbaaaaaaa#a##aaa###aaaba#a##aa######a#####a######aaaaaaabaaababcehb#adcbdbba#aaabdceaa#################abbbbbacgeeecca###bedcaa#adfhccdffbbbba###a####aaaaabbbbaaaba###aaaa##########aa#.##aaaaa#aa#b######a#######aaaa##aaaa###abcdb######a#aabcbaabaabbaaabcdedbbbcddcbbbbcabbbccbbb", +"bcdfdddcccdddcecbb####a#aabccabaa#####aaaaa#####abbccdedeedcijfggfabaabbbbccddccbbbabaaaaaaaaabbbgihihffedccbbbbbbbba#a#aa####aaaaaaa##aa#######a###aaaa########abaabbbbaccega#cdaaabaaaaabbfea#a#################abbbbbaeedddcbaaabacceccefihdccedcbaa##########aaaaaaabbbaaaa#####aaa##a############aa####aaaa######a#####aa##a##aaa###aaa#a#abc#aa###aabcaaaabbbbbbbbbbcddcbccddcbbbbabcccdcc", +"ccbcffhfdddddccadbaa#####aabbaaba##########a##aaabbaacdddfeehjifgha#aabcbacddccbbbbbabbaaa#aabcccefgdddeffeecdedbbbbcba###aa####a##aaaaa##a###aa###aba#aa######a#aaabbba#abbfcbcccccbaaa#abbfjg#aa###########aaabbaaabbcbdedcdbbaaabbbcceghhiiedcedbbaa######a###aaaa#abaaaaaaaa##aaa##a##############aa####aaaaa#####ab#####aa##a###aa#aa#a#####aaaa##aaaaabbbbabbbbbbbbbbbbdddccddccbcbbbcccdd", +"eecbdggfdddedcacda####a###abbaaca######aa##aaa#aabcababcdeeedgigdfgbbcbbbbbcccbbbbbaaaaaaaaaccddddefdecccbbcbbddcbccddedcaaa#a#aa##########a########adbaa#########aabbbcbcabbdcdcbbbcbaa##abbfiaaa##############baaabbbbccedcccbaa#abbbbbefgihfdcccbaaaa###a######aaba#abaaaaaabaa#aaaaaa######...#a#.#####aa#aaaa########a##aaa###a###aa#aa#aaaa#aabbabaaaaabcbbbbbbbbbbbbbbbccdeddcccbdccccdde", +"eedfhhfcba#abb##a#####a#aabcaaccbc#####a#aa#aa###ccbbbabcdfffhgifehfebbbabbcccbbbbbbbbaaaa#ccdcddfghfeccccbbbbabcddegcbccdcaaaaaa###a###a######a#a##accba#########aaaabbccbbcbcehb###cbba##bdehe###############aa##aabbbccdcbccba##aacccbcceffedcbbaaa#####a######aaba##aaaa#ababcbbbbcbaa########.#.##a####a####aa######aaa###aa####a###a##a#aaa####aaadbbaaacccbbbbbbccbcbcccbcceeeeededcdbccd", +"dgghigdb##a#a########baaa#abbcbdbbb#####aa#aaaaaaabaababcdegiihdggffdcbaabbbbabbbbbabaaaaa#ccdccdegedccbbbbbbcbbbbaadbabaacdb###aa###############aaaab#aa##a#######aaaaababbbabbfieaaaa#aaa#chke.#########..#aaaaaaaaababbccbbcbaa#aabbcbabcdeedcba###a#####a#a##.###baabbaaaaaaaabbaaba#########....#.#######ab#a#######a######a#########a##aabba###aaabbbbbbacdcbbbbcbcccccbdddeededegeddddcdc", +"dhghhfa##a######a######aabaacccedaaa#######aaaaaaaababbbccdghgfedgfgcabaaaaaaabababaabaaaaabdcceeeecdbbbababbbbccbbbbbabdbabcba#a############aa##aaaaab#aa###########aababcbbaabeggh######aaagj##############aa#####abbaabbbbbabbbabcabbaaaabcddccba#######.###########ccaaa###aa##aaaa###a###..##....#.aa##a############aaa#####a#####a###aaa#aaaa#aaacaabbbbbbeccccbbccddccdegghhgfeegd#bddccc", +"ffhhhe###########a#####b#bcadddcbaaaa#####abcca#aaaaaaaaabdhihgddfgfgcaaaaaaabbbabbbaabaaaabedcefecbbbbbbabbbaaabbacdca#aaa#bbdb#aaa#########aa####aa#a###a#####.###aaaaadbbaabaddcggbaaaa#bbdia#a##########aaa###aaabaaaabbbbbbaacefebaa#aaaabcccbaaaa###########.#.##ad#####.##aaa#aa#aa#####...#...###ab#ba######a###a##ab#####a###aaa##aa#aaaaaaaabbbbbbbbbbceddeeccbccccddfhijjhggghb#bba##", +"#afhgcaa###########a#a##aabcddca###aa######abbbabaaaaabaaaeiiihgbbgeddaaaaaaaaabbaabbbaaaaabdcccddddccabbbbacaaaaabbbaaabaa##acdd###a######..a#a#####a#aa##a########a##aaecb#abbbcccfgaaaaaaaeia#a#a##############aabbaaaababbababdgeca####aaaaabcbbba#####a####.#######da##############aaaa#######.##.#.#ba########.#a#aa##abba##aa#aa#aa###aaaaaaaaaabbbbbcbccccefgeeccbccbbbbdfiihgggeb#aaaa#", +"##bhgd###############ab#ababcdd###aaaa####aaaaaaaaababaaaadhhigebabfddcaaaaaaaaaaaabaaaaaaabcbbbcbbcecbbbabbbaaaabbaaaaaba###abadea#########.#a##########aa#a###a###a####aabbabbaadccghbbbaaabfi#a##a###aa####a##a#aaabaaaaaaaabbacfdba##a#aaa#aaaabbb######a######.##a#######aa#a##a#a####aa#####a#.#a####aa#########aaaaa##aaa###aa#aaaaa#aaaaabaaaabcbbbbccccceeceeeefedddcbbceeffhgfebaa####", +"##.dhdb#########ab###bdababaddc######a###.#a######aabacaaaadghfdbbabecdba###aaa#aaaaccabaaacababbbbbbbcbcbbcbaaaaababaaaba####abbcfbaa#aaa###.###ab#####aaaa##a######aa#ba#aabbbabdcabefbcaababhe#a##aa##aa###a#####aabba#aaaaabbbefcba###aaaa#aaaaaaaa#########a#.##############aa#bb#aaa##a####.###########aaaaa#######aaaa###a####a##aabaabaaaaaaaaaabbbcccddebbbbdedefdcccccbceeghgfdaaba#aa", +"aa#aeea##########c####ba###aca#####aba#############abcabaa#acdefccbacdbdc##aaaaa###aabdbaaabbcccbbbbbbbccbabcabaabbabbaaaaa###addbcdba#a################a####aaaa#aaaaaaaa#aaacbabdcbbbehca#abbeh#aa######aa######aa#aacfbaaaaaabbdgdbaa###aaaa#aaaa########.###aa#a.###########aaa#bbaaaaaa####a#.##.#######aba#####a#############a#aaaaabbba#bbbbaaaaabbcddddddbaabcedccbaadfdcceeggdbaaaaaaa#", +"aa##ada#a########aaaa###a###a######abaa#########aa#abbbaaaabbcddeeebcdbabb#aaaaaa####aaaabcccbccbaabbbabccbaaaaaaaabbaaaaaaa##aabcccfeb##############a####ab#aaa##aaabbaacababaaaabcdbccffc##abeh.##aa###a#########aaaaacbabaaaccddfgdbaaa##aaaaaaa#######.##.#######.#########aaabaab########a#a##.#########aaa#####aa##a#aa###bdaaba#aa#aabaaaabbbabbbbcddefecbcbaabbdcbaabcecccefgcaaaaaaaaa#", +"aaa#aaaa#aaaaa#####aaaaaa###########a#####a##ab#a##aacabaaabcccbdhedfdbbabc#aaaaaaaba##aaaeheaaaaaaabbbacddbbaaabbbaaaaaaabc#aa#a###cfgb#a#########aa###aaaccaaaaaaaacbabcdaacbaaabcddcccgfcaabeg.#a#aa#a###aaaa####aaaaabaaaaaaceefhfdbaa###aaaaaa########.####.###.####.####aa#abcbaaa####aaa#############aaaaaaaa#aaaa#ba#babffb#acb#aaaabaaabbccabbcccfgdaa##bcbbaaacbcbacebbbcddbbaaa#a####", +"accccedaa#aa#aaa##a#aabda#################a#a#a##aaaabbbabbcccdcccfcfecbaaceca#aacdbcccba#ahgabaaaaababbbccccbaabbbbbbbaaabcb###aca#aabcc##a##########a###a#abaaa#aaabbddddbbbcbaaaaabcdddhecccg######ba#a##.#a###aaceca#cbaaaaacdefhgfcaaa#aaaabba#########..#####...#.#######aaabccbaaa####aa########.####abb##aa#aaa#a#ba#abbefba##bbbaaaaaabbccc#ccddeffcaaaa#baaaaabebbbbcbbbbcbbbbbaa##a##", +"#abeeebaaa###aa###aa###aaa###################aa###a#aabbbbcddddccefegfcca#adhbaacccaaabcbcdecaaa##aaacabdabdcbaabbabbaaababbcb#aabb#aa##dea##aa#######aaa##a##aabaaaacacdfebbbbbbabccccfeddfgfed...#a##aa###########acdbabbb#aa#acddegfecbaaaaaaabaa#########...#####.#########a#abbbabba##aa#####.##....#####a##aaaaaaaa#baaaceeebaaaaeedbbbabbbccb#cedddcccbaaaaaaabaa#bebbbbbbbbbbbbbaaaa####", +"##aadba#aa##a#######abbda################a#######aaaa#ababccdeeddffhhgccbaabefdbbaaa#aabcbbabca#aaaababbbbcccbaaacaabaaabaaaabbaaaab#aaaaefaaaaaaa#.###a#a#a######bbbaabccabbdcbabbcbcdbbaaaefeiiffa####a#######a##aaaaabbcba#baabdddefffdcaaaaaaaaaa##########...##############aabbbbbdabaaa###.....########aaaaaaaaaaaaabcccbdfebaaaaaacfdccbcddc##baabcbabaaaaaaaaabaaaedbcbcccccbbccbaaaaaaa", +"a##aba#a####.######a##bgb#######a########aa#######aaa##aabbcceedddeghiebaaabccebaaaaaaaabaabaaabbaaabbaaabbbbbaaabbaaaaaaaaabbccbbcba#####cfebbabbbacaaaaaa#aaaa###acbbbbbbbbcbaabbbccbaaab#.aceffdfghfa#a####aa#aa##acbacbbbaaaaabcedcddedbaaabaaaaaa#######..#.################aabccccdbbb####.#..#..#.#..########aa#aaa#aaabdddbcababbbdeddedeeb####aaaaaa#ba#aababcbbbaeccbcbcbcbbbbaaaa###a", +"ba#a#####a#############cb#########aa##a###a####ab#aabaaaabbbbedcdccehihcbbbbbbccaaa#a#aaaaabbaaaabbbcbbaaabbbccaaabbaaaaaaaaaabbbbacda####aaedbaaabddba#aaab###aa####aaddcceebabbbcbcdca#aaba#aaabaabfmka##aabaaaaaa#abbabbbbaaa#acccdddccedbbbbaaaaaaaa##a####.#.###############aabddcbbcaaa####.#......aa###aa####aaaa#aa##aacccccbbbabbcdedddea####a##aa#a#bccbccbcbbaaaadddccbbbbbbaa#aa####", +"ab##aaaa######a##########aa###b##aaaaa##a#a#####ababbbaababbbccccdcdgjifbbabbcccca#aaaaaaaaacaaaaabcccbaaa#bbbcaaaaaaaaaaaaaaaaccbaabbaa#a#a#bcbbaa##a###aaba######aaaaaaddfhgccddddacacaaaaa#aaaaaaabhnk.aabbb##aa####aa#acaabb#aabccddeecccbbbabaa##aa###aa#######.######a###aaaabdddcdedda#########...#####aaaaaaaaa##a###aabcbbccbbbbcddeeefc##a####aaaaaacdccbbaababaaabccdccccbbbbaa#a####", +"#####a#aaaaa###aaa######ba###aa#bba#aa#abca##bb#abaabbbbbbaabbbbdccceihgecbcdccbcd#ababa##aaabaaaaaabccbaabbddbbaa#aaaaaaaaaaaaaccbaaa#a######aabdcb##aaa##a#a#####aaaa##aabffebccddcb#aa#######aaaaaadlnd#aabbabaaaaa##aaaa####aaaabccdeedbb#aa##a###############.##..#.#####aaaaabccdeecdaa#####.########.###aaa#aa###aaaa#aaabcbccccbbccddeef##aaaaa####aaaccbaabaaaaaaaaba#bcddcbbbbbb#aaa#a", +"abaa###aaaaa##a#a##a#############a#a#ababda#aaaaaaaabbaabbbbcbbbddbddgifhedbcccbbcc##aabbaa#aaaaaaabaabbbccccdebaa##aa#aaaaaaaaaabedaaaa##########becaaaaa#a#########aaa##abceffdccb##aa########a#abbabilk#a#a######ab#aa#aa#####aaabbcddedbaa#a######a#####################a#aaaaaabdddfgfc##########...a#a###aaa#a#aa##a###aaaabbbbbcbbbcceghfaaaaaaaabbabccbbbaaaaaaaa#abba#aacedcccbaaaaa#aa", +"bbaa##aa#aaaa#aaaaaaaaa#aaa##########abaaaa#baaaaabbbbbabbbbccccddbddggghhfdbbcaabbbbbaabbaaaa#aaabbaaabbb#bbbaaa#####a#aaaaaaaaaabb##aa##########aabdcbabaaaa####aa###aa#abbcdhhcaba#baaa#######aaaaabhlmc#a#####aaaaa#a##abba#aabaaabcdgfbb################################aabbaabbccdhigca#########.########aaa########aa#a##aaabbbbccbccdgfha#caaa.##fedbbcbaaaaaaaaa#aaa###aaadecccbbaaaaaa", +"#aa###aaa#a#aaabbbbbcbaa##a#######aaabaababaa#aaaaabbbbbaaababccdecdfhhiihgfdbccbbcbabaaaaaadca##abbaaaaaaa#bb##aaa####aa#aaa#aaaabbda.##########aaaabddcbbaa#a##aa#aaa##aaabbdecca#a#aa#a########aaaaaeili##a######abaa###aaaaaacfeaabddcdbaa##############################aaabbbbbbcdfgjieba####.#####aa#aa############aaaaa###aaabcbbcbbcefggcbbfeedbedbcbabbaaaaaaaaaaaaaaa#aaa#cdcddcbbaaaa", +"aa#a###aa#a##a#aaaabbccaa#aaa########bacbaaaaaaaaaaaabcbbbbbbcedcdccfhfhkhggfdbbccbbabaabaabdda###aaa#aaaaaaacb#########aaaaaa#aaaabec##########aaaaaaabddcbaaaaaaaaaaaa##aabacbaaaba#####a##a######aaabgklbaaa#####aaaaaaaaaaabbbfdaacddeddcbaaa#########aaab##########a##aaaabbcbbbbeffhjifdcb#####.##acbb#aaaa###########aaaa#aaacbcbbcbcegfaccgghgffdcbbaabbbaaa#aaaaaaaaaba#aaaabeecccbaaaa", +"aaaa########aaaabbabbbbcbbbaaaa#####.##aaaaaaaaaaaaabbbbaaaaadedcdccegijkifddebccbbccaabaaa##aa######aaaaaaba#aa#########aaaaaaaaa#bccda#######aaaaabbaaabddcba#aaaaaaaaaaaaabcdaaaaa##abaaa#a#a#a##aaaafhlg.aa#a#a###ba##b#acaabcdfaaaccdccedba##########adcbca#########a#aaabbcddccbdefggiigecb########aaaa#abba###########aaaaaa#bdbccbccef#abdeddeeddccba#bbbbbaaaaaaaaaaabcaaaaaa#eedccbbba", +"aa#aaaaa###aaaaaaaaabbbbbbbbaaaa#######aabaaaaaaaaaabbaaaaabbbfeccccdfiljigcdeccccbccbccbbaaaa#######a#aa##aaa#####..#..#aaabaaaaaaabacb######aaaaaaabbaaaacddcbaaa##cbabaaaaabcbaaaaa###a##a####a##aababchl#.###a#####aaaaaa#aabbdeaaacbbbbdfdccbabb####a#ddbbbba##########abbbccdcccddefghhfcaaa######aab#abaaddaa########ab###aaaacccccdefd#dbgebcccdcaabbbaaaaaaababbbaaabacaaaaaba#eeddcbba", +"aa#aaaaba#a#a##aaababbccbabbbbba########aa#a#aaaaaaaababbaaaaadcccaddfhkjigdcdecccbbcdcecbaaaa######aca####aa#####a#####.#aaaaa#aabababb######aaaaaabbabaaaaabcdcbaaaaaaaaaabbbcaaaa#a####aa####a#aaaaaababjh.####a#####aaa##aaaabdabaaaabbabdeeeddddcb#.##debaaabaaaba####aaabbccdcccddeffgfgcaa##aa###aaaaaccaddca########a#a###aaaccbbceffbaacgeaabbbbabaaaaaaaaaaabaaaabbcaaabaaaabbbccdedcb", +"ba#a#aaaaa####aaaaaaaaaaccbcbbaa#######aaaa###aa##aaaaaaaabbbabbcbbefffhjihfcbfcbcbbbcfhgcaaa#####a#deaa##aaaa###############a##a###aaaaa###aaaabbaaaababbbbbbbbedcbaa#abbbbbcccaa##a######aa##aaa##abaa#aabja##.#######a#a###aaabecaaaaaaacccbcaaaabbdddefedcbaa###aaaa#aaaabbbcccccccddfggghdba####aababababcbbddba###a###a#aaa##aabbcccegfbaabcaaaaaaabbaaaaabbaabaacaabbbabbadbaaaaabba#aefc", +"ba#a#aa#######aaaaaaabaabbebdbbb######aa####a###a####aaaabbaabcabcccddffjhfdbaefcdbbbbdjkjebaa#####bccb##baba#####aa######a###a#a####aaaaa##a##aabaaaaaaabbbbbbabefdbbcbbbcbbbcbaa####aa#######aaaaadaaaaabbdg###a#a####a#aa#aabccccaaaaaabcdbccaaaaabbdeeedcdcba###aa#aabaaabbbcbcccddddeffffdbaa####abccbb#bbccdbccaa###a#aaaa#a#aabbdcdfgdaaaccaaaaaa#aaaaababbaaabbbbbabbbbbcbcbaaaabaa###be", +"fcb#############aa#aaaaaaadegdacbaa###aa####aaa#a####aaaabbaaabaabddccehieabaabecccbbbbbikkgca####acbb###baba#####aa####aaaaaaaa######aa###aaaaaaabaaaaaaaacbbbbbbeffedccbcddddbaaa##aaaa###a##aaa#adba#aaabbie.#.#aa##aaaaaaacecaaaba###a##aabdb#a#aaccccccccbbba###aaa###aaabbbbcccdddedegcddcbbaaaabbabbabbaabbaaddbaa#####aa##aaabbddefgcabagbaaaaaaaaaaaabbaaacabaaaaabbbbabbaaaaaaaaaaaa#a", +"bdeba#########aaaaa###aaaaacfebbbbaa###aa#####aa########aaababaacbdeccehhbaaaaaddcbbbbbcgijhea####acb########a##aa#a##a#aaaaabaaaa####aaab###aaaaaaaaaababbccbbbbacbedffedcdeeaaaab#aaa#aa##a##aa#a###aa#aabackc.#.##aaaaaabdefb#a#aaaaa#a####abc####abcbbeecbbaaabb#aaaaaaaabbbbcbcdededdefdcaccbca##aaaa###aaaaabaaeccaaa###aaa#aaabcccdffbbacfc#a#a#aaaaaaabbaaaaeabcbbabbbbcbbabb#aaaaaaa#aa", +"##aba######aaaaaaaa##a#aaa#fdaabbccb###################a#aaaabbabccccdehibabbbbcfdcbbbabgihc#a####abbaa##a###aa##a#aaaa##aaa##aaaaba###daaa###abcaaabaaabbbbbccbcbcdcdddggfedbcbaaaaa##a#####aaaa#aa#####abbbbdjb.a##aaaaabeecabba##aabda######aa####aaabbdcdcbaa#bcbbaaaaaaaabbbcccddedefffdcbccbab####a#####a#aaabaabeeba######aaacbcddegebbacccba##a#aaaaaaaaaaaaccbbbbbabaaa#aaabbaaaaaaaaaa", +"aa##baa####aaabaaaaa#####aacaababbccbaa##################aaaaaaaabbccbegifaaaabbcecbbbbaadgb#####aeeabc#.######aa##aaaaa#aaaaa###abaa##edaaaa##aabbaaaabbbbbbbccbbdccccdddehhdabbaaaaaa##a###aaaabb######cebcbcgj#aa##abdfggcbbbaaaabdfea####aaaaa##aa###aaa#aaaa#aaabbaaaaaaaabbccddeeddeffeeeefcabaa#aa#####aa#aabbbacccbaaaaaaaabcccdegfbbbceaacb#####aaaaaaaaaaaacccabaaaaa#a#abbccaabbaaaa#", +"#aaa#daaaaaaaabbbaaaa####abbaabaabcbbbbb##aa################aaaaabbbddehecacbaaaabecbbbbabaa#####adcca#########a#a##daaaaacaaaaaa###aa#aca#aa##aaaabbbaabccbbbbcddaccdeddecfhgcabaaa#ab#a####a####aaa#aaaabbbcbcijdchihgighedbcbbcdfdabbbbccaaaaaa###caa#aaaa#a#a##aaaaaaaaaaaaabcccdddddeeedeeeffbaaaaaa##aa###aaabbbabcdeabaaaabbbbcdegibabbfaabca####a#acca#aaaaaaababbbaaaa##aaababbaaabaaaa", +"#####adcbbbaabbbaaaa#a#a#####aaaabbaaabcbaa#################aa#aaaaabddgeadbcaaaaabccbbbbba#####a#a##aaaaa###aa#aa#bccaabaac#aaa#####a#..#####aaaaaabcbaaabbbbcdccdcddedceefgfccbaaaaaa#aa###aa##accaaaaaaaabbbbdjkfdfgjjhgfeeeeeedcaabaabaaaaa#####ab#a#aaaa###a####aaaaaaaaaaabbccddccccdccdeeegfbcbcaaa#aaba#aaabdcbbbababbbaabbcccdghg#aadbaabbaa###a##acdaaa#a#aa#baaaaaaaaa#a#aaaccbaabaaa", +"a##a#aaedbbcbabaaaa##a##aa####aaaababbaabacaaa###a#######a####aaaaaaaccehbbbbcbaaaaacdbbbcb#a#a#a#.####aaa##a#aaaaaaabaaaaab##aaaaaaaa#####aaa##aa##abbaaabbbccbccbcdcdcddeffcaabaaaabba#aa####a##bcbaaaabababbbbejib#abccdcbbccba##a##aaaa##a######a##aaaaa#a###a#####aaaaaaaaabbccccccccccccdeegfcdabbaaaaaaa#aaaabccbbbaccbabbbcddefedea#cd##a#aaab#aaa##bcb###aaa##abaaaa#####aaaaabbcbaabbb", +"aa##aa#bhgccbbccbbaaaaa########aaaaabcbaaaabbaaaa###aa#####a#a#aaaabbbbcega##acbabababecccdabaa##########aaaaaaaaaaaaaabaaa####aaaaaaaa##.##abaaa#aaaaabbbbbbbbcdbbccddcdcegeaaaab#aaaaaaaaa####aabbabbcbbbcaaabbcegiaaaaaa##abbcbca##.###aaaaa####aaa##abbaa#aaaaa####aaaabbaaabbbbccccbcccdddedfddcaaaaaaaaaaaaabbccdbbbcecbbccdefged#a###fa######aaaaaaaabaa#######aab#aaaa#aa#aaaaaabcccabaa", +"aa##aadafhhfeccbbbaa#aaa##a####a#aaaaaaaaaaaaaaaaabaaaabaa#aa###aaaaaabbcfd#a#acbaaaaabeecdcc#############abbaaaaaaaababbba###aaaaaaa#a#####aa#aaaaaa#aaaabbbabcccehgeecdegebaaaaaaaaa#aaa#aa###aaaaababccbbaa#aabceggaaaaaa#aaaabcb####a###aaba######a#a#####aaaaba#####aabbaaaabcbbbbcbbacceeddeebabdbabbaaaaaababcdccdccdcbbccefecb#####cc#########aaaaaaaaaa##ba#aaaaabbbbaaa#aaaaaabcccdgdb", +"##aaacdggggghgdbbbbbaaaaa#aa###a###aa##aaaaaaaaaaaaabcbbaaaaaa#aaaaaaabbbdfd#aaacdaaaaaadgefc#######a#a###abb##a#aaabaaaaaa#######aaa#a########aaaaa##aabbbbbbbbccefhfeeegfbbba#aaaaaaaaaaaa####aa##abbcdacbaa##aabcehfaaaa###aaababa##.##a#aaaca#a#aaaaaa#aaaa#aabcc#####aaaabbbbbadcabbbbbbceedefcaabcecaaabaaababccdcdddccbbcceda#####baeaa#aaa#####ab##aaaaa##aaa##abbbbbbbbaaaaaaaaabbbagig", +"f#aaaehhfffeffhfbccbbaaaaaaa####a#aaaaa###aaa#a#abaabccabcbabbbbabbaabbbbcehdaaaaaaaaaab#dgeaa##a###########aa####aaaaaaa######a####aaaa###a###aaaaa###aabbbbbacccdedddfgebcbaaaaabbbaabaaba#########abcbdabaaa#aabcdeibaaa######aaaca######aabbb####aaaaaaaaaaa##bbdb####aabbbbaaaacdcaabbbbcceddeccccaba#aaabaaaabccddddddceddeec#aca#aabebaaa#######aaaba#######aaaaabbbabbbbbaaaaaaaaaba#dii", +"hd#aaejiedefeeddedccbaaaaaa########aaa#######a#a#aaaabbaacbbababccbbabbbbbceidbaaaaaaaacbcgeca#############aaaaaaaaaaaba######.a############a##aaaaaaaaaaaacbbbccccedbcfcbbbbaaabbbbaaaaaaababaaa#baaaabababbabaaaaabdfhaaaaa#aa##b#bbaa#####abb##a##aaaabbba#aaaaaacda#####abbbbaa####a#abaabccbdecdbbaaaaaaaaaaaabccceeedcdfgffeba#aa#aa#bcaaa##########aa##a####aaaaa#aaabbbbaaaaabbbcbbbeefh", +"ggecdhjkiefeeddcdefdababaaa########aa##a########abaabaabcdabbcdccbcbabbbbccchiecaa#abbbaaaadeca#####a#######aabaaaaaabba###a##.#############a##aaaaaaaaaaabbbccdddbbeccdbbcbbbabbbbbbcbbaaaabccaaaabaabcabbabaaaabaabcefeabaaaaa####aaccb####aaa###a###aabbab#a#aaa##aaa#####acbba#a######aaaabbbbfefdaaaacaaaaaaaabbbcefffeefbed########a##dbaaa#######a#############a########aaaaaaaaaccfgfhdf", +"efddegijmkfeeeddccdgdbcccbaaa####a#aaa#####a####a###aabbcbabacccdccbbbbbcbbdfijhbaaaaabb###cedbaa###aaa#####aabbccbaaaaa###accb###a##########aaaaaaaaaaaabcbbccddddcddaaaabbbabbbbbbcbaabbbbbaaaabbaaaaabbbbaaa#ccaabbddheabaaaaa####abca#####ba##a####abcaaaaaaaaaa#aaaa#####bbaaa##aaaa##aaabbaaadfdbaabcbaaaaaaabbacehhhhcaaaa#####a#ab##ccaa########aa#############ba#a#aaaa#aaabdaaeffghgff", +"eddcbcdefijgeedcccbbdeccccbaaaaaaaaaa#a#########aaa##a#abcaacccccccbcbbccccdefikibaaaaaaaabbdddca#a#a#aa####aaabbbaaaa##a##aaaba##aa##a######aaaaaaaaaaabbbbbccccddddaabbaabcdbbbccbacbabcbbccbaa#aaaa###baaaaa#a#aaabcdfjb#aaaaaa####abaa.####a##aa####bcbbaaaaaaaa#####aa##abaaa#a##aaaaaaaaaaaaabecbaababaaaaabbbcbcehhcaaa##aaa#######b#.cbabaa#####aa##a#####a#########aa#a#aaabdefffggfefe", +"ddcaaabdefhihecdbbbbacdecccbbaaaaaaaa############aa##aa#ababbcbcbbbababccdceeegijgaaaaaba###bfcdc##aaaaa######aaaaaaaaa#aaaaaacba#aaa#a#ba#aa#aaaaaaaababcbbbbbcedabbaabbaaabbbabbdccbbbaabbbbbaaa#aaaaa##aaaaaa#####abcehka##aaa#####aaaa###..a#aba#####abcaaaaaaa#a##a##a###ba########aaaa####aa#deaaa#aaaaaaabbbbbccefcbaba##abaaaa.#a#ba##dc#a#a####abaabb#a##aa##a###a###aaaaabaceecddhhedd", +"cccbabbcdfffhheccbbbbbcdfccbbbbaaaaaa###############a##aaaabacbbbbaaaacccddcdefhjjhbaaaabaa##dfbbc###aa#aa######aabaabaabbbbbabdb#aa#a###bba#a##aaaabbabbbbbcbbcedbaaaaaaaaabbbbbcbccbcebbbbaaaaaaaaaa#####aaa####aa#aabdegj.############a##a##a#aba####a##baaaaaa#a###aa#aa########a##a#aaaa####a#eeaa###aaaaaaaaabbcdgfdbaa####aabbcb#aabc###cda#aa##aababcbb#a#aa###a##aab#aaaaababdecbcdheed", +"cbbaccbcddeffeedcbbbbbbccffdbbcbabbaaa#aa########a###ca#abaabbbabaaaaabcccddcdgiikjgbaaaaba##afcacba###aa########abbbbaabbbbbbbcbbbb#aa#a###aa##aaaaababbbbcbccdca#a##aaaaabaaabcccbbcbcbaabba##aaaaaba#####aa####aabbbddcdjd.#########.#..#######aba######aaaaaba########aa#######aaa#aba#aaa###aacaaaa##aabaaaaaaabbcefcbbaaaaa##aaacabaaaa###bca#####aaaaacaa#a###a##a#aaa#a#aabbbbcddcccegdd", +"cbbabbbbccddeedddcbbbbbbbbdfheccccbaaaa###########aa#bd##baaaabaaaaaababcddcccggijjjbaaabbaa##bcbabba##aa#######aaaaaaabbbbbbbbbcccaaaa##a##aaa##aaaabbbdbcbbcdfbaaa#aaabbbbbbbbbcccbccdedaaa#aaaabbaaaa#a#aa####a#abcccdccfi###########....#######aa##aaaaaaaaaaa##########a###a##aa#aa#aaa#####aaa#aaaa##abbbaaaaabcdefbbaaaaabaa####aa####a#a#dba#####bb##b###########aaaaa#aaabbaabbbccddede", +"baabbbbbccccdeedcccbbccbcbbcdiheccbbbaaaaa#aab##aa###aa###aaaacbaaaaaababccccdfhjjjl#abbbaaba#abeaabb######a#####bbaa#aaaabbbcbbabbaa###aa####a###aaaabacdcccdceaaaaaaaaaababbbbbbbcbbbcbdba###aabbbaaa#aa##########aabbabccgb.###.#########.########a#aaaa#abaa#########a##aa#####bcaabaaba###aaaaaaaa#####aaaaaabbbdhidabaaaaaaaa###########a###ebbb###aaa####a###aa#aabcaabbaaababaaabbbbbdcb", +"abcbbbbbbbccbbcddbcbbbbbbbbbcfeghfccbbabaaaaabaaaa####a#b##aaaabbaa#aaaaabccbceefhegdedaaaaaaa#abdaaba#aa##a#####aaaabaaaaaaabbbaacc###aa#aa####a#aaaaaaabcccddfbba#aaaaaabbbbabbccccccbcbdaa#####ac#####a##########aa#aabcbdh..#########.#####.####aaa#aaa###abb###########accaa###a##aaabbbba#a##a#abba####aaaaaccegcbbaaaaaaa#aa###.##a########aeaaaa###a#a######aaa##aaaaaaaabbaabbaacaacced", +"cadbbbbbbcbccbbacbbbbbbbbabccdeehgffccbcbaaabaaaaaa###a####aaa#aaaaaaaaaaabccbdeeffeehgcaabaaa##adb#aca##aaa#####aaabaaaaaaaaaabaacdb##aaaaaaa#abbaaabbbabbdecffbaaaaaaaaaaaaaabbaccbcbcccdcaa#############aabb######aaaaabbbehd..###d#.#.######.####adbaaaa##abba########aaaaaaaaaaaaa#aaaaaaa#a#aa#abaaa####aaacdeheaaaaaaaaa##aa#aa#####a####a#.cdaa######a##a###########aa##aabb#aabaaabbadf", +"cabdabbbabcccdccbccbbbbbbaabdcdefdcfgccbbbbaabcbaaa###aa##aca####aaa##aabbbccccddffhihhfbaba#c###bdaaagaaa#a######aabaabaaaaaaaa#a#aa####aaaa#aabbaaaabbbbbcddfeca###aaaaabbaabbabbcbccbbbccdada###aa######aaba####a###abaabcafjlf..defe##...#########bbaaa###aab#a#######aaabcb#aaaaaca##aaaa####a##aab###a##aabdfiida###aaaaa##ca#aa#####a####a###ecaaa########a##a#####a####a###aaaaaaaaaabab", +"ccbbbbabbaaabccdcbbbbbbaaaabcdbbbeeadgeccbbbbabbbaaa##aa#abedbaa####a####bbbcbccddehhhfdaa###da#a#ddaabhaa###########a#abaabbaa######a####aaaaaaaaaabbbbbbcbdeefcb###aaaaaaaaaabbbbccccbbaabbcaaa############aacbaabaaaaaaabccbdejkbd..bgccdcba########aa######aaa#a#######aaaccaba#bcaaba#a##aaa#####abba#aa#aabdgkjkihgdb#.cedcbb#.###dc########b##ebaaaa#########################aaa#aaaaaaba", +"abeecbbaababbbabbdbabbbbbaaabcccbdcb#ehedccbbaabbbaaa#abaaaedba###########acbbbcceeeggdaaa#bacaa#aadabbdf#######.#######aaaaaa######bca###aaaaaaaaaabbbbbbbccfffbaaaa#aaaaa#aaaabbccabbcccbbbbaaaaa#######a#aa#acaaaaaaaaaaaabccceglh.#....#baacca..####ab########aaa####a##ababbbba#ceaaaaaa###a######aa##acbbbbchgcddfgjihddigefegfffba#affeecbbaaabda#aa######a#a################aaaa#aaaaaab", +"babfdcbcbabaabababbbaaaaaaaabcccdbaaaacifddcbbbbbbbabaabaacecabaaaaa######aaabbcdeeedifba#adcbaaba#bcabbfe#aa####aaa###a#abaaaa######aaaac#aaaaaaaabbbdbbbbcceebbba##aaaaaaa#aaabbbbbbcccdcabaaaaab##a#aaaaaaa######abaaaaa#abbbbddei#####a####.#ee######aa######aaaba######abaaaa#a##bc##aa#a####a###a#aaaabcbbbceecbbcbdeffgfdccccdefeefgffedcefeb##cdbcba########a###########a###aaaabaaaaaaa" +}; +SIMPLE = T BITPIX = 8 NAXIS = 2 NAXIS1 = 384 NAXIS2 = 384 HISTORY Written by XV 3.10a END 3"3wUD3D3"3""3"3"333""""""""3DDDU3""""DwUUD3333333"3""3""DfD"3""""""""33DUfffUw3""UD3""3"3D"33wf"""""""3""""""""D""""""""333U3333DDff333"""""""""""333333DDDUD"3"""""3"""""""""3""""""3333UUf"�ff"""""3""3"""""3D"""""""""3D333DffD33D3UfwwwUDDDDUfwffwwwfUDfwf3DU3D3"""""""3""""""""3ffD33""3"333"33U3"33333"""3DDD3UD3ffUDD33""333""""3"""fU3""D333DDfffU"""3"D""""U"33Uw�""""""3D"""""""""""3333333DDwww3"""""""""""""33DD"33DDD3333"""""""""D""""""""""""3DDDfݙ�����3""DD"��"3"""""3"3333"Df""""""""""D3333DDUUwUUfwfwww3""wwffD33"""3U"""""""""""""""3DD3333"33"""3DDUD333333""""3DU333ff"UfDD3333"333""""""3fU3"""333D3DDUUfwU""U""UU""3""""3""33"""""""""""""333333D3UffwD3""""""""""3333DDDD33""33D"""""D3""3"""""""3DD3Uf3U��3DDUD3""""""""""DD"3"3D""3""""""33"""""3U̻̪U3�DfUD33�UD3f3"""""""""""""3"D"3U"333"3DDDUDD3DD333333""3UDUfwUDwDD3333""3D3""""""D""""""333DDDDUUwww3"3"D3U"""""""""3""3"""""""""""""""""33""""33333DUUwfD""""""33""33"33D3DD333DDU"U"""""3"""3""3D"ww��Ufwf���33"""""3""""3D3"""""D""""""""3"""3UwU""""""D"""""fD"""""""""""""""""3"3D"U333333D3DD33"D33333333"3DDUffwwDD3D3"""3"""""""""""""""""""""3DD3UffwwffD""3""""U3"D"""""""3""""""""""3""DU3""""""""33"""333"33UfDww3""""""""""""""33"DD3D3DDDUD""""33"""""333fU��U���"U3"""""33"""""""""""""""""""""""""3""""""DUff"""""""""""""""�DU""""""""33""3"""33"Uw"3D3333333DD33DUU3D333333333DwfwDD33"3"""""3"""""3""""33"""""""3DD3DffwfUfU""""""""3U""3""""""""3"""""""333""DD""""""""""""3DDDUUw33"""""""3333"33DDDDDD3D3U"""D"""""3D3U����"""""""33"DD""""""3333""""33""""""DDfD33"""""""""�""f"""""""""""""""""33""33""D""DDfU3""33333DDDDUffUDDD33DD3D33DUfDD333"""""""3""""""""D3""""""3"3DDDDUw"333""3""3f""33"33""""""333D33"33"""""""""3"DUDDDUDf""""""""""3"3333333D333D3U3"""333"""""""33"3DD3���""""""3"""""3D""3""3"""""""""""""""333UU"3"""""""""f333""""""""3D""33"""3"3"""33333UD3D33"3333DDUUffUUUD33333333UwfDDDD3""""""3U3""""3""""""3"3DUUDDD3"""33""3D3"33""""""""""333333333DDD""""""""""""333U3D33DUw3""""""333333333DDD3DDUfU"""""""33"""""""""3DDDUDDw����""""""""""""""""""""""""""""""333"""""3DUfw33"""""3""""""U3"333""""""""33""333DDUUfUfD33"DD3DUUfwwffUD333333DDwwU33D3"33""""""D""3""333"3"""""3DDDUUDU̻3""""3""wD"D3""""3333""3333333D3333""""""""""3"3333D3DDUD"""""""3"""3DDD33D3D3""33""""""3"""""333UUDUU����"3""""""3"""""""3""""""D""""""3"""""""33DfwD33""""""""D"3""""3D""""""D"""""""""""3333DUUDDDfUUDDD3"33DUwwwfDD33333DUwDD3333"""""""""""3"D3333""""DDDUUDUfw3""""3""Uw33D""""""3""3""33333"3U3"""33""""""33"33333D33DfU3"""""""""33333D3DD3Df3333"""""""""""""""""3Uf�""""3""3""""""""""""""""""ff"""""""""""33DUwU3""""33D3""3DDU"""""3"3D33""""""3"""""3"3UfD3DUffUUUD"""3UfwfDU3333"DUfDDD33"""""""""""""3"33D3D333"3"3DDUDfff"""""3"3wDUD""""""""""""""""""""D3"""""3"""""""""""3"3D33333DfU"33""33"""333"33UDD333""33333"""""""""""""""3Df""""""""��""3""3D""""""""""3"""""""Uf""""""""""33333DDfwD3"3""3""""�"3"UD"""3""33""""""""""3"DffDUUfUUfUUD3DUfwffUDDD33UfDDDD3""""""""""""""""3D""DDDDDDD3D33DDDDUfw̪3""""""""33UUUD""""""""333""""""""3"""""""""""""""33333DDDDUUUU""33""3DU333DD3"D3"3D33DD3""""""3"""""""""3DUw3"""""""3""�"""3D33"""""""""""3"""""""""""""""""3fD3""3"3"""""333D3DfD""""""3�D3"3""""""""""""3UfwwwwfwffwUUfwfffUUDDUU3DDD3"""""""""""33D3"3"DDDUDD33333D33Uw3"""""33DfU3"""""""33DD3""""""DD3"""""""""""""3D33DDUUUUDUU""""333"333333D3""33333""""33"""""3333"""DD""33UUf"3""""""3D"3"""3D""""""""""""""33""""""""""33"""UwU3""3D3"""""""33"DfD""""""3DD""""3"""""""""3U""fwwwwfDU̪fwffUUDUfwU"3"3"""""""3""3""3DU"33DUDD3D3"3333DDDfD"""333""""UfD""""3""""""33""�""""""""""""333DDUUU33fDDU33D333"333333D33""""3DD""""3""3D"33"3""""3""3Dfwf"3"""""""DD3""""""33"3""""""""D33""""""3333wfwU""""D""""""""333Dfwwwffw3fU"U3""""""""""""""DDwwUwU""ffUfwffUUfUDD3"""""""""""""""33""D33"3"3DD33"33333DfU3""""""""D3DfD""""""""""""3"�""""""""""""""D333DDDDfU3DwD3333"""3333"""""""3"3"""3""""3"3"33"3"""""3Uw"""""""333"""33"""""333"""""""DU""3333""""3""3DD3UfDU33""""""""""""3DDDfffUDUwwwf3"""""3D""""""""""""""3333"""""333D333ffww"""fwwwfwww3DD33""""""""""""""""""3""3DD"3D3"3333"33""3333DfU""""""""""3Uf"""""""""""""""""""""""""33333"DDDUfUUUwf3D3"""""333""3""3""3D3U"3"""""3DUf3""""""D"""333"""""""""""33U3""3333""""DUD""3333DDfUUfDDDD"3""""3""""3DDUUUUUUDfUUffD"D"""3f3""""""3""""""333"33333"""""""""3"U"""DUU33333"""""""""""""""""""""""3D33"""""""""""""333UwU"""DU""""""UfwD"""33""""3"""""""""""""""""33333333DDfwwfffw333""""""""""""""""33DU"D3""""3Dfw"""""""3"3"�""""D""""""""""""""3DD""""33333"UD"333333DffUfwD""3DfD"""3"""3"3DDUDUUUDD33DDfU"3"f""""""3"""""""""33333333"""""""""333"""""U"wwfDD333""""""""""""""""""""""""3""""3""""""""""33DwU""D3"""""3ffDUDD"33""""""""3"333"""""""""""""""""""""333"3DDDfffDUff3"""""""""""""""""""3"3DD33""""3Df""""""""""3D3"""3"""""""3"""33""""3D3333D33"DDffUUff3"3U3"33""""""3"3DUDDUDDUD33DDfwfD3DD""""""""""3""""""3333"""""""""3DDDUU3""""3DD33DD33""""""""""3D3""""33""""""""""""3333Df""D3"3"3"3fDDDU"3""""""""""""""""3"""""""""""�"3""""""""33333333DU33DDUUDUDff""""3"""""""""""33"33D333D"""33Df"""""""33D3D"�"""""""""33"""""""""""33"""3333DDDD3DDDUUUfUwUUD"""""""""""""33DDU333DfD33DDUfwfU"w"""""""""3""""3""""""""""""3DDD"3""""""fU33D3"3"""""""""""3"33""3"D""""""""""""DDf3333D3"""""DU333D3"""�"""""""""""3"""""3""""""""""""""33"""333DD3DD3DUDUDUUfwwD""3""""33""""3D3""""3"3"3333f3"3DDUD33DD3""""""""""""""""""""""""33DDDDDDDDDDDDUffwDU"33"""""""""""3DD333"DD3"333DUUfwfUf"DU""""3"""3D3""""3"""""""""33D3""333"UD333""333""""""""""33"""3D3"""""""""3UUf"U3D"""""3DD33333""""""""""""3DD""3""D""""��""""""3D3"""3333DUDDUDUUfUDffwwDD3"""""""""""DD""""""""3333UwUwwffffffUD""3""3""""""3"""""""""""""""""33DDUUDDDDUDDUfffw3D3D"""""3""""3UD333"3"333""33DDDU""U3""33""""DU""""""3"""""""""""""DD3""3""""""U""""""""333"""""33""3""3D33333"""""""333UUffD"D3""""3fD3333"3"""UDD"""U"""""D"""""""""D"""""""333""3DD3333DUU"DDUfUUfDwD"3""""3"""""""""333D3DUDfU3D33DUwU"3333DD""""""D"""""""""""""""""""""3DDDUUUUUfffUfffww3"""""""""""333"3DUf"3""""3333DUf3"33w""3D"""DD""""""""3"333"""""""3"33"""3""""""3"""""3"""""""D""3"33DD3""""""""""33DD3fw""""33DfD3333""U3"ff"3D�"""""""""""""3""fU""""""33""""3333333DD33UDDDDUUUfU"33"""""""""""33Df3D3D"""3UwD333""""3Uwf""""""""""""""""""33""""""""33DDUUffUUfwwffffwD"3""""""""333"DDD3""""""""3DDDUfw333Df""D3""""""""""""DDD"3"""""""33DD""33"""""3"""""""""""""wU""33DD3"""""33"3DDDDUf3"3333DwUD333"3D""33"""""""""""""""""3"U""""3D"""3"""33333DD3D3DUDUUUwfU3D3"""""""""""""3333U3�""""""3ffD"33"""3U""""""33UDUD3""3D33""""""""333DDDUUfUfwwwUD3DD3"3"""""3""3ff3""""D3DUUff33"DDD3""""""""""""""DD33333"3""""""33""""""""""3Uf3"""""""""""Dwf3333"""""""""3"3""D3UfDDf3"""""UUD33333Df""D3""""""""""3"""""""3""""""""""3"33DD3333"D3fUwwfUDUff""""3"""""""""""""3"DD��""""""3Ufw3""""""""3D"3D33ffD33"""33""""""""3333D3DUfUfUUfwUD"DD3D""""""""""3""fDD"""""""""3DDDUww33"DwD"""""""""33""""f"3D33"3333D33"33"""""""""wD3"""""""""UfU"D3""""""""""""33"""3""3UUDDff"3""3fDDD33333̈D""D333"3""""""""""""""""""""3""""""""D333333fwwfUDD3DUUUU3""""""""""""U3""""33f��"""""""""DfD"""3""""3U3"""DDDDDDDD333"""""""3333DDDUUUfUfDUUD33""""33"33"33""33""UU3"""""""33UUfwD"3"3""""""""""""33"""D"3"""""3333"33"""""""""""""3"""""""""""3""33f3U333""""""""33""3D"3DDDUUwwwU3"fwDU3333U̻f3""3DD33"3""""""""""""""3"""""""333333"3fwU33D333D333D3"""""""""U"""""33U"""""""3DDDD""""""3DU3DD"""""33UfffUDUD3"""""3"""333D3DDDUUUUfwwwwU3"""3DD3333DDU3DD""""""""""33UDUwU"""DD"""""""""""3"33"""33333"33333D3D3""""3""3f3"""""""""""""""""DD3D33""""""""""""""""333"33D33fwwwwD3wD3D333DwD""""Uf"""""""""""""""""33""""3"33333333fUD3"""33333DDD"""""""""3""""3"�"""""3fD"""""""DDD3D""""33UUUfwfUD3""""""""""333DDDDDDDUUwU3"""3"3"3"3D33UU3""""""""33DDDfw3""3D"""""""33"""""33""3""D""333"33"U3"""""33""fwD""""""3""""""3"33DD3"33333""""""""""""3"33"""""UDDD"UUw̻UDUfDDD33DUDfD3"""""D""""�"""""""3"3"33""""""33"3"""""3DUD3""""""""""333D""""""""""""""3"3�""""""""3U"3""""33"3UfffUUUUD3�Uf3"""3"""3""""33DDUDDDUUfwwwD"""""""""DD"UUD""""""DD33Dfww3""Df""3333"3"""""""""""3""""33D"""3""""333DDUfUD3""""""""""""""""33333333""""""3""""""""""33"""""333wfDDDDUwݻDUfDDDD3DD3DD33""""""""""����"""3"""""""3"D3"""""""33""""DUUD3"""D3"3"""""3D3""""""""""3"3D�"""""""""33Uf"""D3333UwUDD3"33"UU3333""333DDUDDDUUfwwD"""""3"3""UU"""3""""DDDDDUfwUU3f3DDDUD""333"""""""3"333"""3"D"""""3"ffUUD33"""""""""33"3333D333""""�"""""""""""""3333"""""UfUDUDDf̪wUUf3DD33DD""3"""""""""""3""""""""""""3DDU""""""33"""3UUD3""""""""""""""3DU""""""3""""""""""w݈�""""3"3"D""3DUw"""DDUDDfU3""UD3D"""""33DUUDD3UfwfD3"""""33"""""""3U3DD3DDfw"3UfUUffUUDD3"33333"""""""""""3D""""""ffUDD333""""""""""""33DD"""""3"D3""""""""""""3D333333DfUDUDDww̙wU33DD33"3""3""3UU"""""""""""D3""""""""""3fD"""""""3UUD3""""""""""""""3"D3"""3""""""33""""""""""""""333wU""DUUfUUD3""""""3"""""33D3333fwwwUD3�"D33"""""""""""D3D33D3Dfw"DDwwUD33""333""""""""""""3"""""3ffDDD3"""""""""""""33333D3""""""3""3"3"""""""33333"""3"3DDUfDUwwU3DD33D3"3""""""UD""33"""""""33""""""""""""33U"�""""3UUD33"""""""""""33UfDD""""""""""fݪ""3""""""""Dwf""3UUDU3"""""333333DUwf3"�""""""""""""3D33D33DfwD33wffU3fU3D3"33""""""""""""""""""DUDUUD33""""33"""""""""""""""""""""3""""3"""""33333"3333DDDDUU3UUwU33D""33333""33"""""""33"""333333""""""""""""""33""""3UD3"3"""""""""33DUD"3"3""""""""3D""""""""33"""3"""3DUw33""33""33DDUD"�"""""""""3333DD3DDUw"D"""�wfU33D3"""""""""""""""UfDDD33"""""""3"""""""""""""3"3U"""""""""33""3333D333UU3UUwfU3DDD33DD""33"""""""""3""333DDDDUf3""""""""""""""3fU""""3fD""""""""""3DfwwUDD3""""33"3"""3"""""""33DUUfU3"""""""""""3UUUwwD���"""""""""""""33333D333DDfw""""""""33"3DD333"""""""""33"""DfUDDD3""""""""""""""""3"""33""""3D"33"3""333333""3333UDDDffD3DUDD3DU"3"3""""3""""""3DD3""33UU33"""""""""""""""DD3""""""3UD3"""""""""""3wwf3DDUUD3""""""""UU""33"3"""""""""""""3DDUffU33"""����"""""3DDUffDU""��""""""""""""3D3DDDD33DDUUffw""""""""DD3""3""""""""3"3DUUD333333"""""3"""""""3""""""""3"333""3"333DDDDUDUw33"33DDDD""""""""""D"""""3DDD3"""333D""""""""""""""""DD3""33""""3D33"""""3"""""""UUwDDUUUU"D"D""""""""""""3�""333"""""D""33""3DDUUffDDD333"3""""""�"""""3UUUDUfUU"���""""""""""""3D33DD3333DUUfffwD"""""""DUDD33""3"3"""3DDUDDDD3333"""3"""D3"""""3""3""""3333fUDUDDfD333333DD"""""""""33""""333D33"""333DD"""33""""""""""3333"DU"""fU3"""3UU3""""3""""UUDDff3"333D3DUD"""3""""3""3w"""3"""""""33"3333""""DDDUUUDDfU3333"""""""""��""3UUD33D"""�������""""""""""""DDDDD333"33DUfUUUf"""""3DD3DD3D33""""UUUDD333333""""""3""�"33""""""""33DDffUUUff3"""3DDf3""""""""3""3"""33"""33"""33333"""33"""""""""33DD33D3"Dwf33"333"D"""""""""""D33333333D3""333DD3"""3�"DfwwUww"""""""D3"D333"""""3DfUDUUfU3"""3""""""���""3DDDDU333��������""""""""3UUU3D"3"333UfUUfUff3""""""3"""3"3D333"fDD3D3D3D3333"""""""U3"""""33U"""""""3"3DDUffUUwwDD3""3fwU33"""""3D33"3D"""""3"3333DDD3"""D""3"""3""""33""""3""""fw"""""""�"""333""3DD"33UD3"33D3DU33"""fwfww""""""""33D3"3""3UUUfwwwUD""""""""""���""33333U"3"""�����"""""""""""""3DDD3Uwf3""""""DwUDD3DUUD3""3D3"3"""""""""3"""fU3D3DDDDD33DD3""""""""3fff3"""""""""""""""3333DUUUUDDfwfwDD""U3""DDD"""3D3DUfD""""""D"3U"3UD3""33"33"""3"33D3""33""Uf"""""""""3""""D"DUwf333333"3DDDDwfUUwwfU���""""DU3"333"""DUUfwfD3"""""""3""����""333"33"""�����"""""""""3"""Dfff3""""ffU333"333DD3DfUUUDDD3"""""""3""3f3333333333333"""""DDDDfU""""""""""3U""""""""333"33DDDUDDDwDwfD3""DfD"""DU3DDD3"""3"""""3"333DDDD3""3333333"""3D3"D"""3DD""""3""""""33UUUU333D3"""""3DUUUfDDD3""�"""DfD"D3"""""DUfwwD"""""""33"������"""3DD3"""""�"33""""""3""33fw3"333""""""33DDDDDUUfwwD""""3"""""3f3333D3333D33333""""""""""""""""""""""""3"""D"3"""3DDD3UfUwU33"3D"""""""3""""ff"""""""333"DUU33"""333"""""""3D"""Dw3""""""DD""""""""D3"3DU""D3"""3DUUDDDwD""3f�"""""""""""""3""""""DffwwU3""""""""����"""3D3""""""""""""""""""3"3"3ww3"D3""""3"""33DD"33DDDwU""3D33"""D3D3"Df333DUU33"""""""U"""""""""3"""""333""""33DUUfff3DU3"33""""""""""3DDD3DD3""333"3DD3""""""""33"""""""""3DDDwf3""3""""""33""D"3"3""""3DU3DDwwD"3f�""""""""D3"3"""DDUUwU3""""""""""���"""3""3""�""""""""3U""3"""""3""""333"3333DUUfwfD3D3""33UD3""3DfDDDfwD""""""""""""ff"D3""D""3""3D"3"""DUfwDD3"DU3UD"""""""3U3"""33DDD3333333DD3"3D"3""33"33""""""UU3DU3""""""""""""""""""D3"3UD333fD""33f""""""""Dw3""""""33UU3""""""""""�"""�"""33"""""""��"3""""""""333"3333"""""33DUUUUUU3""3DfUDD3""UwUDDffU3"""""""�UU3"33U"3"3"UUD"�"""3"D""""UwU33"3fDU3""""""""DD"3"""D"3"3333333D3D33D3"""""3"3"""3""33Dw3"""""�"3"""""""3"""333"3UD"3fw3D""3"3f""""""""33""""""333fwD3""""""""""""""�""33""""�"""""""""""""3""3""""""""""333DDDUUf3333UfUfwUDDDDD3DffwU""3"""3U"3"3"3DUU"""""""""""""3"3""""Uf3"3wUUD""""""""""""3"""""""3D333D33DfD333"333""""33"""""3""3"Uf"�""""""""33"33""UDD333"""3w"""""""""3""""""""33"DwU3"""""""""333"�"""""""""�"""""""""""""""""""""""3""""3D3333DDDDDffDffffwfUUUD33Dffwwwf3"""wD""""""3DUUD""""333"3"""""3"""f33fUU"""""""""33""333"""""3UDDDUUUUDD"3333"D"""""333"""3"""DUU"��"""""""""fD3"333DDDw"""""""f"""""33""""3"33"3"3UfD""""""3D333""�U"""""���3"�""""33"""""""""""""""""33333D3DDDDfwffDD3DD3333Uwf3""""wwf"33D"UUUD3"""""3DD""""""""""3UUUwwD"""""""333"333""3""""3fUDfwfD333333"333"""33"DUD""""33U3"""""""""�"""""U33""3"UUD3""""33U""""""""3""""333333""Dfwf3""""""3DDD3""""��"U�"""""""������"33""""3""""""""""""""3333333333DfUUffDD3DDDDUUw333"Uw"""""3""DDDfU"""""""""""3"333DDUwfUwD"3"""""""3"3"3""3"""""3UDDffffDU333"3"3333DD33333"3U3"3D3"""""""""3""""3"3D33""3f""""""33""33333"333"3D"33""""3DUUDD3"�DD""""""""""�������""""""""""""""""""D""333333fDDDD33DDUUDDUfwffU3UUDDDUU3""3""""33D3U333"""""""""3""3"3DUfUwwUD3""3333"33333"3"""""DDUDDUffUDD333333D3333""U3"3""DU3""""""3""""""""3"333"33wf"""""""Df���"""""""""3"33DD33D3""""33D3"3DUffUD3""""�3""33""""""""33""3"�����"3""""""33""""333333"DUD3333D3DDDDD3UUUffUfUffUUUUDUDffUwwD3""33""""3D""DD3D"""""DD333"3DUwwwwfwf333"33DDD33333333""""DDUDUUwwfDDDD3333"3DUUfD3DDUD"""""""""""DD3"""""33DD33D3Df3D33"3Uff""""333DDUD3DD3"""DDD3DDfwwfUD33""""""3""""""3"3D3333D3""��""""""""""""""""""U33"""DDD333333DD3D3DDD3DDfffffUfUDU3DDUffD3UwUUUfUD"DU"""33""D""""""""3D"3"3DUfffUUw33D33333DDD33333"""""""""DDUUUUfwUfDDD33D33UUD3DDUUfUD""""""""U3""""333D3D"33UDUD333D3"""33w"""3"""3333DDfUDDD3"""33333fwwUDDD3"""""""3""3""""""3""""""""���"�"""""""""""""""""""""33"3"""""3D333333333333333DDUfUUDDD3UDDDDUUfDD3DwwwUUUUUDD"U3""""33""3"""""33""DUUUwffw"""3D3"DUUDD33333"33"""""3DDDfwUUUfwwffDUfU3333D3"""""""""""""3"""""""333""33wD3DDDDD3""""33w"""""33"""33D3UfUDU33"""333DDffUDfU33""""""""3""""""""""""""""""""3"""""""""""""""""3333"333333333333UUUDDUUDD3D333DDDUU3DUwUUUDDDUUUDfD33"""3DD"3""""""""33DDUfUffUDww"3""3333DDUUDD333"3"""""""""333wwfUDD33333333"""""""""""""""""""3""3333"DDf"DU"""3"""""33wf"""33333"ffUUUD3"""3"DDfDDfwUDDfUD3"""""""""333""""""""""""""""""""""""""3D""""3D""""3333333333DUUD3DDUUD3333"3DDDUDD33UUDD3DDUDDUDf3D33"3DD3DU""""3DUUDUUUfU""""3DDDDffUDD33D33DD3DDUfffwfUUDDUfDD33""""""""""""""3"""""""""""""3"""3"3Df3"UD3U33""""3UDf"""33333"DfffDD"3fUD"""UwDDUww3333"""""""3333"""3"""""""�"""""""3""""""""""3DU3"""3D3""3""33"""3DUfU333DUUD3333D"333DD3333DUD33DDDDDUUUUUU3""3333UD""""""""3DfUfUD33D"33"""""DDUUUUDDffUUUUUUUfffwfU33D3DDD3333"""""""""""""D""""""DD""D""""""33DDUDDwD"3"""""DU""""333""33UffwfU3""""UU"""33DfUffwfU3"""3""33""3"D3"3""""""""""""33""�""""""3U3"""33""33"33""3UfUUD333DDDDD3333""333DD33"33DDDD33DDDDDUUUfD"""33DDD"""""""3333ffwwffDDww3""3"""333DUfDUfwwU3D333""333DDDD33UD3""""""""""""3"""""3D"""3""""""""DfU3DUwww3"""""UD""""33"""33DDDDwfD"""DD""""""DDwwUwDDfU33"3"""""33"""3"3"3"""""33""""""3""�"""""33""""""""3""3"""333DUwfU3DDD3DDDDD"333333"333333D3DDUD333DDDDD3DUwU""D3"3D3""3""""""""333fwfUDUwwD""""""""3"DwwwfwfUD33333""""33333333D""""""3"""""""""""""3"""3"""""3""3DDwf"""""""3U"""""""""33"""333DUUfUD33"""""""""33wfUwUUfD333333""33"33""""""""""""""""""3D3""""""""�""""333"""""""3"""3"""33"3DwfUD333D3DDDDDD3"33"3"""""33DD3UfU333333DD3DUDDUU3333""DDD"D3"""""""""""DwUD3DUf3""""""""UwfUDDDDD3333333333333333""""""333""""""""3""""""""""""""""""""3Dww3D3"3"""33f"""""3"""""""DDUffUUwU3D3""""""3""wwfUDDDDUDD3"""3""""""""""3""3D""""""�"""""3""""3"""""33"""""3UffDDD33D33DDDDUD3"3"""333""""333"wf3""""3333DUDDDDD3"33"33DDD33"""""""3UfDD3UUfffD""""""UUwUUU33DD3DDD3333""""""3"3"""""3""""""""""""""3"""""""3"""""""""""3DfwfwD""""""33U""""""3""""33DDUfwfwwUDDD"""""""""33fwwwwDUU3UDU333""D��33""3""""""33""""""""33D"""""333""""3UwU3"DD3DD3D33DDUD3333""""3"""""""33D"3""333333D3DDDDDUU3"3"DD3"33U3D""""""3UDU33DUUUD3"""3D"DfD333D3D33"3D""""""3"""""33""""""""""""""""""""""""""""""Dfw"""""D""""DwD""""33"33"3DDUUfwUDfwwfU3D""""""""3333DUfUDwwfD"3"""""�"3D"""""""""""""33"""""""""""3D"""""333333Uwf33"3DDD3DUD33UD33""3"33"3""3""""3333D333333333D33333DfDDD3"DDfU"""3UUD"""""3D333""3UwwUD"""DUD"3UwfffUDDDDD33D33"""""""D3""""""""""""""3""""""""3"""""""""""""333w"""U3"""""""f"""""Uf"""""33"3"DfwU3UwwwfUDD33""""""DD33DUfDUwUwwD33""""""��""3"""3"""""""""""""""3"""3""D3""�""""""3""""DDDfwU33"33DDD333UDDU3""3333333"""33"""""3D33333333333333"""3wUDDD3D3"""""DUDff3"""""3333""3UwD3"""DUUUDDDDDDDDDD33"3"333"""""""333""""""3"""""3""""""""""""333D33Dww"""D3""""""""DfD�""Uf""""3U"3"3UwU""UwfUUDDDD333"DD33D3DUUUUwwww3"33"""""3"""""""""""""""""3"""""""""""""D""""D3333DUfwU"33""3DD3333DDDD3D3"""333""""3"3""""3DD3333"3333333"""""3UD"3UD""""""33DUwwD3""3"""333"""""3Dw333DUUUD333333333"""3""333"""""""""""3"""""""""3""""""""""3D3"33DDfU""""""""""""333fD�""""""""""UD"333ffD3"""UfwwfUUDUUDDDDD3DDUDDUUUffffUUD3""""""33""3""""""""""3"3""""""3"""""""333""""""33DwwUD"33D333DDD33DDDD3""""""3333""33"3"""""33"3""3"3333"3""""""""333"""""3DDfU3"""""""33""""""3UfDDDD3D3"""""3""""""""""3"""""""""3"""""""""""""""D3""""""""33333DU3"""""""""D3wf�"""""""UD33""fw3U3""DDUUwfU3UUDDDD33DUfUDfDfwffwfwUD3""""��""""""""""3""""""3"3U3"""""3""3D3"""""3UwwD"333"33D33D3D3DUD33"""3333333""D"3"""""""""3"333"33"""""""""""""333"""""333DfUUD3"""33333"""""""3DUwwUD"33DD33""""33333333""""""3"""""""""""""UU""33""""""""""""""""3333UD""""""""""3"Uw3""""UUDU3"DfD""""""""3DUfffDDUfUUDDUUf"UffwwwwwwwfD3"3"��"""3"""""""""3D"""3""3D3U"3""3333"""3U3""""""""""DfwU333333333333D3DDD""""3"""33""3""DD"""33""33""33"""33"""""""""""3""333""""33"3DfUD33"3DD"""""333""33DfwwDDD33D33333333UUDUUU333"3333"""""3"""""""Dwf""""""333""""""3DD""""3"""""""DDDU333"""""333U3"fwUU33DfU"""""""3""3fwwwDUUUDDUffffUfwwfwfUUDD3"""""���"""3"""""""3"""3DDUUDDD""3""3"3""3DD"""""""""""""Dww3333333333333333DUD""""33""""""33""D3""""""333"33"33"""3""""""""""""""""""3333DU3"UDDU333""33333D33DDUfffUf"3DDDDDDDDDUffUwUUDDDU3D3"""""""333"""""""""DD"""""""""33""3"""""""""3DUfU3D3"""""""33Uf�"wwwfDfDfU""""""""""DUUfDUUDUUfwfffwfDD3DDDD3"""""��""""3"""""""""33DDD33DD33""3""""3D33""""""""""""""3UwU3333"3333333333DDDD"""""""""""33333""""""""""3"3"33"33""""""""""""33"3"""""33D33DUfUwDD3"""3333DDDD3DDUUfUUDDUUUDUUfDUUfwwUUfDUUDD"D3""D3333""3""3"""""""""""""3""3"3""""""""""""33DUf333"""""3"3Uw""wfDwwwf3Df"""""""""""3ffUUUUffwwUDwU33"3DDD3""""3"""""3""""33"""333""33"""""DUD""D""""3D"""""""""""""""Dff33""3"333333333DDUD""""33""""333""""""""""3""""""3"""3"""""""""33333""""D33333DDDUUfwU""3333DD3333"33DD3DUUUUUfffwwfwDfUwwfU3"3fffDUUD3DDD3U333"333"33""""""""""""""""""""""""""""""""33UfU"""""3""""""33""3fD"DDUwUUU"""""""3"""""UUffDUDUwfffUUD"D333D33""""""""3"D3"""""3""3"3"3"""333U3"D""3D3""""""""""""""3UU3"""""3"33333"""3DDD3"3""""3""""""""""3"""3""""3333"""""""""""333D33"3DDD33"""33DDDDU3"3DD33333"""33DUUD3DfffUUfUUw3DUffDUwwfUUUfUUDDDfUDDDD33DU3"""""3""""3""3""""""""""""""33DUw"""""""""""""3f3D3DD""3Uff"""""""""""3DffUfwfffUffDD"33"3D33"""""��""""333""""""""""3"""""""D3D"3D"""""""""fU3"3"""""""33"3"3"3DD3""""3""""""""""""""""""33333""""""3""""""""DDD33D333""""3U"""""3D""3D33333"""3DUUD3DUfwfUwwfU3UDDUffD""wwwUUUfwwDDD3DUDDDDDDD""""""3""D""""""""""""""""""""3""""3"3Ufw"""""""""""""3DDD""3DUfD"33"3""D"""""3fwUUwUUU3UU3""D"3333""�"""""""D3""333"""3"3""""D""""33D3""""""""""""""3fD""""""""""3""33333U3""""3""""""""""""""""""3D3""3"3""""""""""3DDDD3""3D3DD""""3"33"33"3""""""3DDD3"DUUfwwwUDD"3DDUfU""""3UffwwfDDUUDDUDUD"""""D""""3""3"""""""""""""""""""""""DUD"""3"""""3UD""�DwD3D3"�3wwD333"3"""""DffUUU"3D3""""33"33""""��"""""""DfD33D3"""""3"""""3""fD3DDUD"3""""33"""""""""""3UU""""""""3"33333U3"""3"""""""""""""333333D3333D33""""""""""3DDD333D33"""""""""""333"""""33DDDUfwfD3"""""33"""wwwDDUUUUUfD""""3""""3"""""""""""""3""""""3""3DD""""UU"""""DUUf"f33U3"""U33""3D"""""DwfffD""""""""33"""3""""""""""3UUw3"""3"3""""""""3""DfwD""""33"""""""3Dw""""""3U""""3333U3""""""""""""3D333333"3""333333""""""""�""""""DfDD333"3"""""""""3""""""""3DD3DUUUwU""""""""""fffwfUUfD""""""3"3D3333""3"""""3"D3""""3""""3"Uf""""""""33ff""33"D"""U3"""""D"""UwUUwU""3""33""3""3"""""""3UD3DD3""""3""""3UwffD"""""""""""""3Uf"""""3"""""33DD3""""""""""""""3"""33""""3"3333""3""""""""""""""""3333333"333"D3""""""""""3DD3UfUDfw"DD""""DDDD"""""3DUUwfwffwwf"""""""33D3D33D3"333""33""D""""""""""DwD""""""DUff"fwDDD"""DD"""""3"""3fwwwU"""3""""""""""""33D3DU33"""33"""3DDUD"���""""""""3DUD"""""""""""33DU3"""""3"3""""3""""""3"""3333""3""""""""""""33"""""D3"""DDDUU3""""""""DDDUfwfwfwU"D""""Df3DU3"""D33fwU3""3""""""3DU3DD33"3D3333333""33"3""""""""3DU33""""""3UUDUD33DwU3D3"""""3""""""3"""""Uwwwf"""""3��""""""""""D3"D""3""""""""DDD""""3DfD""""3"""""3""""DU"""""D""""""3""""""3""""D3333"D"""""""""""""""3""3""""3UUDD""""3DwwUwwwD"D3"3UfDD"3D""3""fwwf3"�""""DD333"3D333""""3"3333333""""""""3ff"""""""""""3wU33UUDD3""""""3"""""""""""""3wwUDU""""""""""""""33"3""""""""33D"""""""�"""3DUD""33""""3"3"3D""""""3D"""""3"""""""D""""3""33333"""""""""""""3""""""DUU33D""""""3UwU"UffUUwww""3UUU3"""""3U""""""DwfUD""""""""DDD33"3333"""333333333"""""""""DUUU""""""33DDffUD33"""""""""""""""33"""Uww3"wU""""""""""""""""3"3"""333D3�"""""""��"""33DUU�"33"""""""""33333"""""D33"3"""3"""""""3""333"3""""""3""""""""""3Uf3D"""33Dww3"DUDDUff""Uf""UD"3""""3UfUD3"""""""333DD3""3D3""3333"33"333"""3"""""3UU3D3""�"DDUffU3DDDfD3"""""""""""""""3333""3U33Dw""�3"33""""""3"""""""33DUD��""""""""���""3Uf3"3333"""""""""3DD"""""""""333""3"""""""3"""33""33""""""""""""""""""DD"""33Dfw3"33DwDUUUU3"3w""""""U3"""3UfUD"""""""""""3333""D33"33""33"""3"33""3"3"3"""""""DD3333�"33"DUDDD3"333DU""""3"""""""""""3DD""""""D33"33"""��""""33D3"""""""3"""33DDDD"�"""""""""���"3UfD"33"""""""""""3D3"""""3333"""""""33"""""""3"""""""""33"""""33""""""""""""""DUff""3""DD3"""DfwD""""33"""UwU33""�"3"3"""3DDD"""""3333333"3"""3333"""""""3Uf""333"""3UfUD3"33ww""3"3U""""""""""""""""DfU3"3""3"3wD"""���""3D3""""""3""3"3DDUU3"���"""33""""""���"DfD3"33"""""""""33D"""""""33"""""""""""""""""""3""""""3"""""�"�3""D""""D""""""""DUww3"""3"""""fU3"""""""""Dw3""�""""33"3DUfD3""33"3333333"""3"3"""""""UU3"""""3""3DDDDDD33""3w""3"3U�"""""""""""""""3"DUUU3""""""UUfU"""3"��""3UD"""""3"3D"333DUU3"���"""3DD33""""""3fUD3""""""""D3""""""""""""""""3"""""""3""""3"3"""3D"�"""3333"D""""3DUDfw""""333"""3D333"""""3""DfU""�"""""3333DDDD3"3"3"3D33333""33D33"3"""""""Df33"3wwDU3D33D33D""""3333"33Dff�""""""D""33"""""""3DD""""""3Ufwf""""Df"""3UwU"3"""""3"3"Dff3�����"""333"333""3"""��3f""""D""""""3"33""""""""""""""""3"""""""""""3"3""""""""3fD"""�"33D33""""""3"3DDwwwD"""""3""""""33""""""3"""33wU""�""""33DD33DD""33""33333333"3"""33333""""""DU3""""33"D33D333""3"""33Df"3DDUf�D"""""""""""3"33"3""33UfwfDU""""""fD�""""""""DUD3U3"3UwfUUwwU3"���""3333"33DD33"��3D"333""""333UUD""""""""""""""""""""""""""""3"3""33"""""3D3"""3D333"""""33""333UU3"""""""""3""3"""33"""UU3""""33""DDDDDD3"""""3""3DD33"3""3D3333""""""DU"""""3"""33D33"""""3D3Df33DDU�"3""""""D3"""33333"""33U33D"3""3D���"33""""""DDDDUfDUfwwDDDD3�����""""33"3UU3"���33"3D3""""33DD"""""""""""""""""""""""""""3"33""3""""""""3"""""""3D3"33""""3""333DwwD"""""""""3333"""""""""3U3"""""""33""D3"333D""""""""333"""3"D3DD333""""""""33"""""""""""3333""""""333"U"33D�D""""""33DD33"33"""3"3"""""""""""""""33""""3D333DUUDfwDff""33""333333D3""�"D"""DU3"""""""33D33""""""""""""""""""""""""""""3"3"3""""3""""""""33"""""""""3DD3"3""333""333DUU3"""3U33""""""""3UD3""""""333333333"3DD""""""""D333DDD3DDDD33""""""""33D"""""""""""D3"3"""""""DD33"3D33"3"""33DDD3"333"""""""""""""""""""""""3D3""""333DDUfffwf3"DD33333�"�"3""33333D3"""""3D"�"DDD3"""""""3"33D3""3"""""""""""""""""""3"""3"3"33"""""""""3""3"""""""33DD33"""33"""3DDUwf3"""""3D"33"""""UU3"""""""""""""33D33333DD""""""33333DDDDD333"""""""""""3D"""""""""""""""3D""""3""3DDf�"""""""""3"DD3""3"""""""""333"""""33"""""""""""""3DDDDUUwf3"""""33""333333""""""""333D"D33"""""""""333DDD3""""""33""""""""3"33"""""""3"""""3"""""�""33UD3""3333""3DDUff"""3D33""""DDD"""""""D333"33DD33""DD"""""333DDD3D3DD33""""3"3"""""3D"""""""""3U"""D33"w3w"�"""""""""""3""""""""""""333""3""3"3"""""3"D""3DD3DDUff"""""""3��""333"""""""""""3DD"DD3""33"""""""33DDD""""""3"""""""""D""""""""33""""""""""""""""""D3DDD333333333DDfwwf3"""DD3""""3UD""""""""""""""3"""""""""333""""3"3DUUDD3DDDDD3""3"""33333D""""""""33"3D3UfwffU"""3""333"""""""""""3"""33""�"""""3D""333"DD33UD3DUfU3"""""3"""""""""""""""""""""3DffDD""""""""""33"DDDD"""""""""""3"""""3"""""""3""""""""""""�""DDD33333"333DDDDwf""""33D"""""3D""""""""""3"""""""""""3""""""DUD3""3D33D333"33""3333D""""""""""D"3DDUf"Df�"""3""""33"3"""""3"33"""""""""""""""""""3U""""333"D3DU33DUfD""""""""""""""""""3DwD"3"""""3"""""""3"333DDDD""""""""""""""""""""""""33"""""""33""""""""""DDD3333333"3DDDDf3"��"33D"""""D""DD""""""""""""""""""3""""DU3"""3333333""3333D3DD""""""""3"DD3UDDffDDww33""�"3""333"""""""""""""""""""""""33DD"33"3""3"UUD3Dff333""""""3"""3"""""DD3"""""""3"""""3""""""33"33DDU3"""""""""""""3"""""3"33"3"""""""""""�""""33DDD333""333DDDDf""�"333""""33""33"""""""""""""""""""3333"3""33""3333D333D3"333"""""""""3fDDDDUUwfw"DD"""33"3333"3333"""""""""""""""""""""""3"DUDD"333DfD""DUwfD33"""""""3""""""""3"""3f3"""""""""""""""""""3DDDDD""""""""""""""""""""3""""3"""""""""""""33�"""3DDD33""""333DUUff3""""�"3D""3""""""""""""""""""""""""""3D33""""""""333333333DD"33""""""""DU3DDUfwff333"""""3"""3DD"D3""""D3""""""""""""""3""""DfUU3""3D3f33fwUD"""""3"3""�"3"""""DwUD"""""3"""""""D3"3"333U3"""""""""""""""""3"""""""3"""""3""D"""""3U3DDD3""""33DDUUffU3"""""""""3D"""D""""""""""""""""""""""""""33"3""33333"333D3333D"3333"""""333fU33DDffwD33""""""33"""33D""""3D"""""""""""""�"""3""D3fUwU333UDDDDwf3""3"""""D"3"U""�""""DwUwU"""""""""""D"""""3""3DDUf"""""""""""""""""3""""""""3"""�""3""333D33DD3""""33DDUUffUD""3""""""�"""""""D"""""""3""3""""""""""""33"""""333"333D33DD3DD3"3"""""3""3fwUUUUfUUU333""""""333DDD""3"""""""""""""3D"""""ffUUDfD"DUwUDD3"""D3"3D3"D33"3DUD3ff3""""""""""""3""3UDUD3"""""""""""""""""""""""""""""""""3""""3D33""""33DDfffff"""33""""3"3UU3"D3"""""3333333"""""3"""33"333"""3""333"D3D333D3333"""""""3"""fDUffwffwD33"""""""""DDUD3"DD3"""""""""""""""3D""""UfUU33UDUfwU3DDD3""D3"3D3DU""""""�""Uf3""DwUD""""""3"""""3DDUU"""""""""""""""""""""""""""""""""""""""3"3D3333DD3"""3333Uww3""333"""""""""33f"""3D"""3D3"3333""""""""""3""3"333""3""333333333""""33"""""""UUUUUUwUw3D3"""""""""D3DwU"3"""""""""""""33"""""3DD"""3UD"""fffwfUUfwD3333""""3D333DU3""��""3U3""3DfwU""""""""""""""3"DfwD""""""""""""""""""""3""""""""�""""""""""""""3"""""33D33"333DDffUwwU3""3D"""""3"""""Dfw""3U""�"""333D3D3"""""33""""3""""3""333""333""3333"33D33"""""""3DDUUUfwUf"33"""3"3D33"3DUfwD""""""""""""""""""""""3DU""3333"333fwfUfDDUUD333""3"333DDDD""""""DfU"""3wf3""""""""""UfwfUfD""""""""""""""""""""""""3D3""""""""""""""DDD33DDUDUfU3DwD"""333""""""""3U3""fU""""""333"33"""""DUU3"""""3"""""""3D3""333""333333"3"3""""""UfDDDUfUff""3D3"""""3D333DUfff"3"""""""""""""""""""""DD3""3UffUUUUUUUDD3333""3""3D33"""""��"""3fw3"3Uw"""""""""""UwffwwwwD"""""""""""""""""3""""""�""""""""""""""3DD3DDUfUfwf33fw3""""""3"""""""""""""U""""333"""""33""""DD33D"3333""""3""""""""3333"3333""3D3"""3wUDDUUUfwf"""3"""""DD33DUUwfU3""""""""3""""""""""""333""3fwwwfwU3DDDUD3""D33Uwf""D3"33""""""U3""3fD"""3"fwfwwfD"""""""""""""""""33""""""�""""""""""""""""""33DUUUDfUUfffDUw3"""""333"""3""""""33D""3"33""""""""333""""3D33"33"""3"""""""3333"""3""333D"""""""�3wDDDUUUfwD"3""""""""DDDUff̪33""�""��""""""""""""D""3""DfwfUfw33fUD3"DDU3DwwUfD�"UU33""""""""UfD""Df""""""3Uffww3""""3"""""""""""""�"""""""""""3""""""3"DUUfUUwUDDfwwwU"""""33""""�""""""""33U3""""3""""""3"33""333333333""""""""3D3"""3"3333D3"""3"""wUDDDUDf3"""3DDUfw̻3"D̻f3D""""""""DU33UfwwU33ffU3DD333"3UD3wfwfUfww""""�""""""Dww3"�"3UfD""""33fwwfU"""""""""""""3""""""""""""""33"""""""3DUDffwwfUDDwfUD"""""""""""��"3""""33U""""""333333"""""""33333""""""3DD33"""3""3333"3"""""""""""""""33DUDD̈"""""33DUUf̙UU3Uݻw""""fffUD33UwU33UwfUwfUDD3333U3wwwfUfUffwwDDf""""3UwU"�"�"3Uw3�"""""3"UfwfD3""""""""D333""""""""""""""""""""3""""""""3DDDUUUfU3UwDDfD"""""3""""�""33"""3D"""""3D3""""3""3""333"3""""""33DDD""""333333"""3"""""""""3"�3333DDUݪU�""""""""333DfݻUẅUffwfffffUUUDU3"3DwUf3DDDDfwwwD33333DfwfUUUDDfffwUfUD3DDfw33"3fUD""""""3DU"�"""""3DUDU3"""""""3333"""""""""""""""""""""""3""""""3DUDDfDDfwD"UfDff33""""""""3""""3U"""""""""33""""3""""""33""""3333""""""33D3""""3"""""""""�ff3333DwD�"3"""""""""3f̻̻̈wDD33UUUffw̙UDwf"3D33D33UfDDDffffUfUDDDfffUUUUUfwDUwwDfU3"DUfD33"3""""3"�""""DDDU33""""""""""""""""""""""""""""""3"""333UUUDDU3DUUDDDDDUU""""""""3""3"3"""""D3""""3""""""""""""""33""33"DD3""""""""""""""3w3""33Uf�"""33"""""""3f̪wUDUD3"33D3DUD3D̻DUD3D3UUwwfffwUUfUDDD3DUDUD3D3D3"3"Uffwwf3fUUU3""3"333D333""""""""""""""""""""""""""3D3"3DDDDUDUUDDDDD33DDf3""""""""""33""3"""3"3"""3""""33""""""""""""""33D3"33""3""""""""""""�"wU33""3w3�""""""3""""DDݻUUfD3""3DD3"333U3"UD3fwwwwfwwwwwD"""3"3U3333DwUUUUD33333DD"3"""""""3"3UUfwffU""""""�3DUDUU3"""""""""""""""""""""""""333"33DDDDDUfUDDDDfUDDUf3"3""""3""�""""D"�""""""3""""""3""""D3"""""""3""""3D3""3"""""3"""""3""""�DD333"U3""""""""33"""""3UݪwfwD3""333333"3"3UfUwUUfUDD3DDUDD3DDUDDDD3"""""""3"3DDDUUUDDD3"""33""3"""""33""33"DDUUUDUfwwwfUfffU���"3D3Uw3"3""""""""""""""""�""3"3"33DD3D3DDUUUDDDD333fU"""""""3""""3U3"�""""""333"""""""333"""""""3U""33D3"33""""""""3"""D3D3"fU333"DU"""""""33""3""33fw3""333""3D3"3DUDUUUUUD""3333D3"""""3""""""""""3333DUfU3D3"""""33""""""33"""""""3DD33333DUDDUUwwf33""3DDDDD"�""""""""33"""""""""""""""3333DD33DDDUUDUDD"33Uw""""""""DD�"""3"3"33""""33""""""""3333"""""""3""333"""3"""""D3""3f3""""fw""""3""""3333UwwfUDD"""3""3""33""""D3D3DDD3""""""""""""""""""""""33""Uf33""""""""""""""3""""""""3333333"3DUDDDfwf���"""DDDDD""""�"""�""33333"""""""""333"333"33DUUUUDDD333DD""""""""""33"�""""D""""""D"""""3D"""33DUD333D3"333"33"""""""""""DU3"3"3w""""""""""""""333w݈w""3"D3""333""D33""""3DD33"""""""""3"""""""33"D3""""""""""""""""""""""D""""33"3"33DDDDD3UD""3UDffUf3""3""333"33""""""3""""""""33333DDU3DDUD3DD""""""""""3D"""D""33"33333"""""""3DD33"""""""3"3D""33""""""""3"ff3"3""w3""""""""33""3""333Df3"""3D33DU333DD""""D33"""3""""""3"333"""""3""""""""""""D""""�3D"33UDD3U"�"3333DUf3"""""�""""""""33"333""""""""""""""""""33"33UD3DUDD333""""""��"""""3"3�"""""""333333"""""""""3D3""3"""33"""""""33"""33"3"33D"3"Uw""3""""""""""""""""""3ff3DD3"""3D333""3"3""""""""""�"""3""""""3""""""""""""""""""""33"3""3""3333Dw""D""33"3UU33""�"""""""""33333""""""""""""""""""33""""3D3DDDD333DD""""""""D3��"""""""""3D3"""3""""""""3""""""""""3D"""""3"""""3""3"f3"""D""""""""""33"""""3UU3"3"33""D3"3""""""D"""""""""""33""""""""""""""""""""""""33"3ff3""""""""DffD3""""""""""D333"""""""""""""""""""33""33DDUD3D333"D3"�"3"""""Dw�""""""3D""""D""33"""""""""3"3"333DUD3""33""3"""""3wf""fU""""""""3""3"""3""3f3""""""""3"""3"""""""""""""333""""""3""""""""""3"""""""33"3DUf3"��3U""""""""DwD""""""�"�""""3DD333"""""""33"3"3"""""""""333333DUfUDDD3"333""�3""3DD"""""3"3"""""33"""""""""""""33D33DD3""""""""""""3f3"wU33D3""""""""""3Dݙf3""""""3""""""""""""""""UfU33"""""""""""""""3�""""3"3DffwDUUD3�w""""""""3DwD"""""3"�""3UUD3D"3""""""3""""""""""33333DUUffUDDf3"DD3"""��"3"""""DD3�""""33""33""33""""""""""3"""DD33""""""""""""ww3ff3""3D3"""""""D̻3"""""""3""""""33""3"DfUUD3""""""""""""�""3""DDUUfUffwwUw""""""""33UwD"33"""""�"3DD3fUD3U""""3"""3"""""333333DDDDDUfwfU33D"DUD"""�"�"33"""33DDD""""""3333"""3"""""""""""""""333DD3"""""3""33"UD"Uf3"""""""""""""3"""w"""""""""""""3UUU"""�""UDUUUUUD3"""""""""3"3""�""""3DUD33DUUD""""""3DwUDD"""""""""""D3DUD33D3""""3""3"""""""""""3333DDDDDUUUUwfD3DD3UD"""""""""""""3DDDD""""""""3""""""""""""""""333333"""""3"""333f�3ww3"""""""""""""""""3Uw3""""3"""""3DD""�""wfUUDDUD3"""""""�""3D3DDDUwwUDUUD3"D33f"3""""""""""""3DUUDUD333"3""""3"""3D"""""""3"333DDUUDUDUUfwU3DU"UD"""""3333""""33"""""""""33"""""""""""""33333"""""""""""""3ww"f3"""""D3Dw3""""""""3333"�""""""wwUUDD3DD3"""""""3"""�"""""333DDUfffwfDUfUDUwfUD3""D3"""""""""""DDUD3D333333"""D""""""""""""3""3DDDDDUDfUDUUwf33UD3U3"3D33"33""�""""""33"3"""""""3"3"3"""""""""33Dwf"3f"""""""""D"""33�"""""UD3"3"""""UwDUU3DDD3"""""""""""""""33"3"""""""""33DDUUUDUD3333DDDUUfU3"""""""33DDD3333"3333""3D"""""""""333333DDDDUUDDUfwwUDDDUDD3""""""3"""""3"""""""""3"3""""""""3""3D"33""""3Dww3�"ww""3""""""""33"""3"""""3DDD33���"3""3UU3DfD33D33""""""""""""""""""""3DDUDUUDDDDDDDDUUfUDfD3""""�"""UfUD33""3"""33""""3D""""""""""""33333DDDUUUD3DwwUUDUD33D""""""""""""""3"""�""33""33""""""""3"33""""""""""""""3DDU"U""3"D""""""""""DU""3"33""""3DD3""�"DUfU33UD33"33"""""""""""3"""""""""33DDDDDDDDDDUUUUfUUwD""""""""""�""""DwfUUfU"D"""3D""""DD""""""33333DDUDUDUDUfUUwfDUD3DU""""""""""""""3"""""3"""3""""33"33""""3""""""3DDfw"U3"""""""""""""""""�"wD""""3""UUD3"""""""3UUU33D3""""3"""""""""3""""""""""3DDDD3DDD33DUDUfUfw3""""""""fwUUD3DfD3DD"33""""DD"""""""33"3"3333DDDDUUfUUUUffwUUD33DD""""""""""""""""""""3"""""""""""""""33""33"""3"33"""33DwfD""""""""""""""""�"̻D""""""""""DD3""""""""""3UUUD3DD3"""""""""""3"33DDD3�"��""""""33333DD33DDDDUUfD""""""""fwwfUDD""33"DD33""""DD"""""""33333333333DDDDfUDUUUfffDD333D3""""""""""""""3�"""""3""""3333"333""""D3"""""""""Dw̪U"""�"""""""""""�"ݻD"3"""""""�""3"""��3"3"3ffUfUD3DD3D3"3"""33"""""3""3""�""3"333D333DUUUfUf"""""""��""wwfUUU33""""3DUDD333"""""""""33"3333333D33DDD33DDUUfffDD""D""""""""""""""""""�"3�"""""""""""33""""""""""3""3"""""""""""Dw3""""""3"""��3""""""3""3"""3"3""�""fwD3UffUwfU333"33"33D333"""""�""33333D33"DUUUUDD"""""""""""wffDUDD3""""""""3DD3"""""""""""""""""""333DD3DD"U3333DUUUfD3"3"""""""""""""""�""D"""""""3D33"""""""""""3""3333UݙD"""""""""""""""�Dݪ"""""33"""""""�""wwwwwfUffD333"""3333D3""""""�""3"33D333DDfUDwDD""""""""�"3wwfUUDD33""""""""3"""""3"""""""""""3"3333333DDDD"3"33DDUwwU3333""""""""""3""""""""""""�"3"""""""3D333""""""3"""""3333wݻf""""""""""""""""�"w̪3""33""3""fwwwffUDDD3""3"3"3DDD3""""""�""������"3333D333DUfDwU"""""3wffUUDD33333""""""3""""3"""""""""3""""333333DDDDDDD3D"33DDfww"33D"""""""""3"""""""""�""""""333""""""""""""""""""""""33w̻U""""3""""""""""""""""̻3"""33""D3"""�3wwfUD"3"""""33DUfDD"""""""""������""33333DDDfDUDD3"""""""wfUDDDD33""""3"3"""""""""33"""""33"3"333DDDD33D3U3333DUDUDUDf"""""3"""""""""""""""�""""""3""""""""""""""""""""""33""333wD"""""33""""""""""3"�f̻UU3"33""3DD33""""�"""""UwfUD33"""""333D3fU3"""""""���������""3333D3DUfwff33"""""""3""""�DfwUDD33"333""""""""""""""""33DD33D333""3333D3DD33333"33UDUUUDfD"""""""3""""""3U"""""""""""333""""""""""""""""""3""3"D3U3""""""3""""""""""""""DwfUfU"33UD3DD""""""""UwwffUD3""33""333UU3"""""������""""3333D3Dwwwf3""""""3""""""""""""�3UfwfDD33""33""""""""""""""""""""""3"3DD3D3""333333D33"33"33DUUUUUUf"""""""3U"""3""""33"""""""""""""""333""""""""""""""3""""""3DU̪3""""33""""""""""""""""""""DwfwD33"DDD3""""""""3wwwfUUU3""""""3""3333DD""""""""�������""3333DDDUUwf"""33""33"""""3D"�3wfUfD3DD333""""""3"""""""""""""""333333333333333333"3"333DDDDUwDfD""""""""""""D""3"""333""""""""33333"""""""""""""333"""""""U""3""33""""""""""""""""""""3fݪUDU3"""33DfD"""""""""""DwfUD3""""""""""3"333"""""""3"""�������������""DD3DDDUDUfU""3D3""""""""3"""UwffffDUfUD3D3""""33"""3""""""""""""""3D333DD333333333D3333DDDDDUfwf"""""""""""""""""3""�""3D"""""""""""3""""""""""""""33"""""33DD""""""""""""""""""""""""""Uݪ3D""""3DUD"""""""""""3DwUUD3333""3"""""33D"""3""""3""3""""�������"""D33DUDDUDUfU3"""""D3""""""""""3DwwwwwwfUU3D333""""33""""""""""""""""""333DDD3333333333DUDD333DDDUfwf"""""""""""D3""""3D33"33"""""3"""""""""""""3"""""""""3fݻ3"""33""3""3""""""""33""""""""f̙3"""3333"�"""""�"3"wffUDD333333D3""3DD3D3""""""3"""""���"�""""333DUUUDfw""""""3""3""""33""3UfwwwwwffDD3"3"33333""""""""""""""""33""3333333DDD3DDDU3""3DDfUUfwwD3"""""""""333"""""""3"3""""""""""""""""""""""""""Dfw݈"3"""""333"""""3"""33"3"""3"3wݻD"D"""D"""""�""wwwfUDDDDD33DDDDDDUUDDD"""""""""""3""""�"""3DDDDUUffw3"""33"""""""""3UwDfwfUUUD33333333""""""""""""""""""333"""D33"33333DDDU""""DDUUfwwfwwwU"""""""3DD3"3""3"""���"D3""3""3""""""""""""3""""""""3̻w3"33"33""""3"""33"3"""""""3DDDwwD3D""""3D3""""""�"""3wfwfUUfDD333DDDDDD3DUD""""""""""""D3""�""�333DDUUUUw3"""33D3"""""""3ffffwwffUDDD33333D3"""""""""""""3"""""33""""333333"3U33""""3D3DffffwwwwwU"""""""""UU3""""""""�D33""3"""""""3"""""""""""""D̪U""33"3333""3D""D""3"3DDU33UfUDUwf̻fDffDDU"""333"�""""""�""""""""UwffwwUDDDUUDDD33D3DD333"""D""3D3"""�"��"33D3UU3Uwf""""33DUD"""""DfUwwwwwwwffUUUUDDD333"""""""""""""""""""""""""3"3""33"333""""3"333DUfffffUffU""""""""DD33"""""""���""""""""""""""3"33""""33U333"""""33"3"""""3"333"fwDUffff̻UffwfDD""""3D3""""""""""3"3""UwwwwUffwwUDUUUUUU3DDDUDD33333333U3""U3"���"3DUDfUfDfU3""""33DUU"""UwwwwfwffwffUUDDDDD33D3"""""""""""""""""""""""3""""333"3""""3"""33UUUUUwf3Uwf3""""""""3333"3""""��"33"""""""""33"""33""Dfff""""""""3333"""""33333fwfUUDUUUUfwU3"""""3"3"""""""""UwwwD""3fwfffUfUDDDDUUUD33333"""D3"3""""""""���"""3UDUfD3UD""""33DDD""DfwwfffUUUUDDD3DD3333""""""""""3"""""3"""""""""""""""""""33"""""33"333DDUUfDDDDDUD""""""3333""""3333""""���"""3"3"""D33""3UU3DUwffw""333""333333""""""""wwwUfUD333UUwww̙wfU"3"""""""""""UwwUUD""3fwfwfUffUUDDDD3D3""D3""33"""3""��""3DUUDfw3333""""""33"DwwwwwwwfUDDDDDD3D33f3333333""""""""""3"""""333333D3"""""33D3""""""""3DDUfUDDD3DfD"""D3"3"333""33333D3"""���"�DU"33333333"""3DUUݻf"""3D33333333333"3""3DfwwfD333333DUw̙wfD3"""33"""""""""3fwD3""33"UwffffwwfUfUD33DD"3DDDD""""""3"""������"3333D33w"""3""""DwwwwfwUUDDDDD33"3DfD333D33"""""""""""""""3"333"33333D33"3""""""""""33DDUUDDU3D3fUD""3333""""""33"3"33"""""fD3""3"3"""""3ݻ3""DD3"3"33"3""""DfUwffUD"3333333D̙f3""3"�"""""""""""""�"UwUD3"3UffffffwfUUUD33DU33"UD3""3"""D"""""""�"�""3333DD33D"3"""D"DwwwwwfUDDDDD33"3DDDDUDD333""""""""""""""3"3"""33"""""""""""""""""33DDDDUUUDDD33UfU""3U""""33"3333""""""����"""UU33""""""Dff̙wwDDw33""""3"w"3UfwwwDUUUD"3333"3"D̙3"""""""""""""""�"""UffUD"3UffffUffUUffU3DDUDDDUD3"""333""""""""""333DUf"""""3fwfUwUDDDDDD3"D33"333D3333"""""""""333""""""""""3""""""""333""""""33333UUDUUDDD33DDD""33"3""D3"""""""""���������"""""Uf""""3fUfw̻UUUwUDf33Ufw"fwwfUUD3UDUU3"D333333U̪D"""""""""""3"""""""3U3fUD"3UUUffUUUUfUDDDUUDD333D""""""33"""""""�""""""""3333DU"""3""""fwfUUUDDDDD33333333333333""""""""3""D""""""""""""""""""""""3"""""333DUUUDUDDDDD33DU3""D333333"""""""""�����""""""fwDwݙwUUUffwfwwwUfUUDUD3""DDDD3D3"""33Dw̪w3""""""""""3""3DDUUDDD3UfDUD"UUUUUUfD333DD""""3"""3"""""""""�"""""""3DDU333""DwwwUfwwwfUUUfDDDD3""333"""33"3"""""""""""""""""""""""""""""""""""333"""33"DUUDDDUUDD3DDD3DfU"UU"""""""""""""���""""""""""��DwwffUffwf3UfUUffffUUUDD333"""33DD3D33""333̻wU"�""""""3"""""""""��"UDD"UUDfD3"33""UfUUUD3"3D3D"""""33""""""""""""""""""""3"""""D3DUUf3"""DwwfDUD3DfffwUUUUUD333""333""""3""""""""""""""""""""""""""""""333""""D33"""3333DUDUDD3UUUDDDU333D3"33"""""""�""""""""3"�www̻ݙݻݪffUUDDfw"fffDDUfU3DUDD3D3""""""3"DD3DD""""3ff3"�""D3"""DD""""""""""UfD"3Ufff"3"��"UfUUD""3D33"""333"""""""""""""""""""""3""""""33DUf3"3""DfwfUD33UffUDDDUUUD333""33"""""""""""3""""""""""""""""""""""333""33D3""""""3DDDDDDDUUUfUUUUD"D"3""""""""""""""""""""""""3"�Dwf̻ݪwfUDDD33UfwUDDDfD333DD3"""""""""3U333D3""""3f"�"""DD""DU"""""�""�"�DfUDDDDfw33""Ufwwf""DU""""""33333""""""33"""33"3""�""""""""""""""DUfD""""3""""3UwfffwwUDDDDUUD33"""3"3""""""""""""""""""""""""""""33"""3"3333"333""""""3333DUDUDDUUUUUUfD3UD"""3"""""3""3""��""3"""""""""DU̙fffD3333DD3DfwfUDUD3333""""""3""DU"3D3""""Dw""3U33D""""""���3fUUfD3DUwwD�"DUwwwU"3DD"""3"D33333"""333333333""""""3"""""3""""UwU3"3"D"3"333DfwwUUUDDD333""33""""""""""3"""""""""""""""""33"33""3"""3D333"""""""3"33DDUUUUUDUUffwwUwU"""""D""3UD""D""""DfUUwݪUD33D3"""""3DUUDfUUU3DD"""""""""DDw333""3UwfUU�33DDDU3""""""�"��"3fUf3UD33Dwf"UD3DUU33U3"""D3D3DD333"""33D333333"3""""""""""""3"""""""3UwDDD333""DfwwfUDD33333"33"""""""""""""""""""3"""333""""""33""33333D"3"""""""""3333DDDUUUUUUffwD""""""333DD��"""""""""DD3"w̻fD3""""""""""3DDDfwffDDD33"""""�"DwwwwwwD"DUDD333wwwfwU"�""3DfU3"""""��""�3DffDDD3""3Uw"""333""3333UD33DDUDDff3"333"""3DUD33333""""""""""""D"""""33"3""DUffD333"fwwẅD33333333"33""""""""""3""""""DU3"33DD3"""3333""3""3DD3""""33"""""333DDUffUUUUfUf"""""""33""�"""33D""D̙3"""33"fwUUUUD333""""3"3fwffUUUDDwwUDDUwffffwfD���"3�"3DD333"""""""��"3wUwUDD"""Dw3�""3"3"""DDDD3Uwwf3333D33""DDD3"33"3"""""""""""""3"""3""""3""""33fwwD"""""ffffwwD"333333"3""""""""""""""33"33"3D3""""DD33333333D3D""""""""""""D33DUUUUUfUfwfU"""""""""�������""33""UݻU"�"""DD3DDUUDDDDDDDDDDDDDUD33DD3D3""33DwUD3w���"""3D3"""""3"""""�"""UwwfUD3""DD"3333DUwwffU"""33333D3"33""""""""3""""""""""""33"33"""3UD333"""""DwffffD"333333"""""""""""""""""33D333"3333"""""33333"3""""""""33333DDDUUUUfffwfUwf"""""""�������"""""f̙f""""D3"33UwU33"""""33D33""3"""""""3DUw33fD"��"""3"""""3""""""""""�"""UwwU3"""D"�"33DUffffwDUD3"33333""D33""""""""3""""""""33"33""3""Uw333333""wfDD3ffD33"3""3"""""""""""""""""333333D3"33""""""333"""""""333"3DDDDDDUUUUffffDwU"D"""""""""������3UU̪UD"������"D""D333""3"""""""""""""""3Dwfw"�""""""""""""""33D3"""""ffU3"""""���""""3D"DD3""""3DUDD"3D333""D"""""""""""""3"""""3333333"""33fD33D"""""""UfDDDfUD"""""""""""3"""""""3U3333333""33333"33""""""""33""3DD3DD3DDUDDUfwf33""""""""""""����"Uw̙wD""3"""����������33DD"""""""""""""33Dww3���"""""""""""3333""3"""DfD"""""�"""""""""3D3D33D33"""33""""""3""""""33""""33333"33"3Uwf"""""D"ffDDDwD""""""""""""""""3D""""""3"3"333333333333333"""""""3"3"3DDDD3DDDUDD3UwwUD"""""""""�������"""f33""""������""DDD""""""""""DUUUw�����""""""""""""""""""""33DfD""""""33""3"DUU3D33"333"""""""""3""""""33""""333"3D333DUU""UDwfDUf3"""""3""3"�"""""333333D3DD333333333"""""333333DD3D3333DDDDDUffUw""""""""33"��"w̻wwfff3"""""���"333"""""""""33DUf����"""""""""""""""3U33""""""�"""3""3UfDUD3""333"3"""""3""""333"""""333DU3"DD3Df3"""UwfUff3""""""33D3�"""""""""3DUDD33"333"D3""333333UDDD33333DDDDDUUf"""33"""3"����""D̪wffwUD"""""""3"���""""""�""""""3""""33f"�����""""""""""""""""""DUD"""""33""""""Uff333DDU33""""""""3"""""333"""""3D3D33DD3DfU33"DUwwwwffw3"""""""3D"3"��""""""""""""""DUDD"33"3"33"33""3DDD3333333DDUfffUfw""3"3""""����DwwwUfDDU3"""""""�""�"""""""""""D"DDD�������"""""3""""3"""""""3UD3"""""""3U""""""""UUD33DUU33"""""""""""33""3333D333DDDUUfDDD"3wfU"fD"""""3"3""""""���""""""""""""""""3UD333"3"33"333"3UUD333333DD33UwUfwf"""33"""3"���"UwfwUUwUD"3DD3""""""""""""""""3""""""""3"""""3Uw3����""""3""""""""3UUD3"""""""""U"""""""3"UUUDDDDUD3"""3"3""""""""""3"""33333D33D33DDUDD3"3""wfUUUDD3w""""""""33"3"""""3�����""""""""33""""""3DDD333"33333333UUDD33D333D33DwUffww"""""3D""""""""��"DfDDD3Dff3""33"333""""""""""""""""3D33"33""""""DwD�����"""""""3D"""""""""3UD""""3"3""""""""33"3"3UD3""D333""""33""""""""""""333"""333333DUDDDUUDUfD"UwfUUUDDD3f""""""""""333"""3U3��"""""""""""""3DD333""3"33333DUDDDD3D333D333UDfwD33""3""""3ww33D3DwU3"3""""""3""""""""""""""""""""3"D33"""3""""UD����""""""UUf3"""""3f3"33""""3""�"""""""3"""3�"U3""3ffD3""""""3"3"""""3D"3""""33333DUDwfUU33ffUUUDDDDDD""3"""""33""3""""DU""""""""""3""""""""""3D3"333"3D3333DUUDD3D333"3333DDUww"""33"""""""3Dw"""3DUfD""3""""""""""""3"""""3""3""3""33DD3"DD""D""3D3��""Df3""""""""D""""3""""""""3"""3"DwwD33""""3"""3""""DD""""""""D3D33DwwwDffUUfUUDUDD3DU"""3"333"""3"3D""3""DD3"""3""""""""""""""""3"3D333"DD33D3DDUUUD333D33D33"UDUffU3""""3"""""""D3""DUUU3"33""333""""""""""""3""""3""""3"3"3333DD333D3""""����"""""""""""""3"33""""D3"""""""""3"""3ww3""3""""""3""""33""""3"""DD3DDUDDU3DUUDUUDD33ff""""333""""3"3""333fff""��"""""""""""""""""""33"UDD3333DDDD3DUUUUD3DDD3""""UUUUf3D"""""""""U"""3fUDDD333""3U3"""3"""""""""""""D33"""""33"33333D33"3""""33���"""""""""""""�""3""""3"U3""""""""""""""""""3DDf3"3""33UwwU3"""33D"""33"""3"""""""3DDDDDDfUDUDUUUDfUDD"3U3"""3D"""3"""""3333D33""""�""""""""""""""""D""D33333DDDUfwfUUffDUD3""3"3DwUwf""""""""""""""3DU3"""DfDUUD3"""""""""""""""""""""""""""""3DDD33"""""""""3""33"""""""D"��""""""""""���"""""""3U""""""""""""""3333fwffUffDDUUfffwD33""""3333""""333""3"3333DDD3Dfff3fUUUfwwfU3UffD3D3U3""3"""3"3D33"""3""""�""""3""""""""3333DDUDffUUfwfUD""""DDUfUw""""""3""""""33"D3"DUfUDDD3"3""""""""""""""""""""""3""""33DDUDDUUD333"3""""""33""""33�"""""""3"""""33""""3"""��"""""""""""3DUUf3""3UD33DUD"3333""33"3"""3333"""33333D"DUUffUwfffwwfDDUwwwf3DDDD"""""3"3333"""33""�""""""""""""""3"33UUDfwfUDUwwfUD3""3DUffww""""""""DU3fD33wfUD""""""D3"3""""""""""""""""""333333"""33DUUUU3DDUDDD3"3"3""""""3"3"��""""""""""3333""DD""3"3U"""""""""""33DDUwUD""""""D3""33"3"33""333"3""3333333333333DDDUUf3"UwwwffwwwwfffwwUDDUU""""3"""33"3333""""��""""""""""""""DDDDffUUUDwwwwfUD3"3DDUwf3""�"""""3"D3""DUDDUwU33"3""""3"3"""""""""""""""3"""""3DDDD3DDDDD"33""3""333D3""3"""""3�""""3""""33""DUUUD333DD""""3U33"""""3DDDDDDUUDwwD3""""""D""3""3333"""33333""""3333""""""3DDDUU""fUUfwfUffDUwwwwff"""3333"""3D3""3"""""""""""""3UD3"UwUfUUfwwffUDDDDDf"""�""3""3""""3ff3DfUUD3"""""""3"""""""""""""""""""3""3333""""""""333"""33""""""33""""""3"""3""3DfUD3"""3DDD3"""UUDD"""33DfwwwfUfUUfUD3""""""3D"3"""333DD333333""""33D3333"""""33DU""fwfffffDUU3DUUwD333333""""3D333"""""�"""""""""""333fU3"DwfwfffwfUUDDUUU"""��""""UU"DUfDUfD3D""""3"""""""""""""""""3"3""""""""333""""""""""3""""3""""3""""""""""""3D3"3""333D3""3D""""3DU3UfwfUfUD3D3""""""3D3"3"33DD33333D"""""3DDD3""3""""3DU33"3wfUUDD3DDUUww33""""""333DD""""3"""""3"""""3""""3fwU""33wwffffffUffUUfw3"""""""D̻fUDfDDD3"33""""""33"""""3""""""""""""""""3"""""""""333"""""""3""""""""3""""3"3�""""""3""""""""3"""D33"3D3""""""""�""33DD33UDD3"""33""""""D333"DDDD33DDD""""33DDDD33""""DDUD33"DfffUDDDD3DDUfffwf3U"""""333333"""3""""""""""D""3ffD"3"3"UfwwwfUffUwUDwwfww""�""�3fwfffUUfwfU3333"""3"""""3""""""""3""""""""""33"""33D33"""""""""""3""""""3"""""""""""33DD�"3""3D"""""""3""""""""""33�3DD3""""""""""""33"33"33"""3DDDDDUDUDDUUD33"3DUDUUDD3"3UUU33UDfDUfUD33333DDfffffDU""""3"3D3D"""""3""""3""3333"3D""""Uwf3"""3""fwfwwwfUUUffUfwfw3"""�D"""�"wwfwwwfD333"3"""""""""""""""""3"3"""""""""3""""DDD""""""""""3"""""3"3"""""""""""""3DD3""""3""""�""3""""""3""D33""""""""""333"""""""""DD3"UD33UUUDD3DUf3UfUDD3""""3UD3"ffUUfUD333DDUffwwwwwD3""""333D""3"""3""Uf3Dff""""3"""""3""""DwD""""3D3D3UwwfUwffffwfwffUD"""""3"UwU3DfwfUDDDD3""3"""""""""""""""""""""3""""33""33D33""""""""3""""""""3DD""""""""33DDD""""""""""""""""""3""""33"3D"""3"33D"""""�"""D3"�UUffDDD3"DwfffUD"""""3DD3"wfffUUUUD3DUDUUwfwwffU""3""""3"""33"3"""""DwwfUf"""""""""""""3wf3"3""""""D"UD""wwfDwwwwwwwff"""3"""ffD333DDUDD3333""33""""""""3"""""""""""""3"""3D333""333""3""""""33"D3"""""""""3DDDUwD""3333Df"3""""""""""""""""3""""""""333"3"""""""""�"""UDUUDU3"UfUffUD""3""DfwfUUUUUUUDUUUfwfwwwffU33"""""33""3"""""3Dff33U""""""""""3UUU3""""""3"D333""3UwwwwwffffUUD3"""""3wD3"""333D3333""333"3"""""""""""""""""""3"""""""""3"""3"""3""""""""""33"33"3""""3DDfwwffD3DUUffDU3""""""""""""3fU"""""""3"""""""""""3"""���"�""3DDD3DU""wwwU333"3UfwfUUUffD3DDUDUfwwwffwwUwwU3"""""""3"33"DUUU333"""""3"33Uf333""""3"33"""DUUwwwffwffUUD3"33"""""""DD3"""""33333333""D3"""""""""""""""""""""""""""""""""""""""""33""D""D3""""DDDwUfwfwDUfDwUU3D""""""""""""""""33ff3"""""""�"""DUD3"""""""33"��������""DUUfffUfUDfffUDDfwwwfUwUwfDUUUDDDDUUfffffwUUwwwUUUU3"333"""""3fwDU3"""""3D"""""3U3"3""3"33""3""ffwwffffDwD"""""""""UD3""""""333"""3"""3333"""33D3""""""""""""""""""""""""""""""""33"""D"""3""""3DDUwUUUUUUDDUwwwUUw3"""""""""""""""""33U3""""3""""DfU3"""""3""333���������3"3fUfUfUD3"""""""""3DDUUffUfwfDwwwffwwUUUUUUfUUfffUUfwUUffww3""""""""3U33"""D3Uwf"""33DUw3"""""""3333""3333UDwfffUffw"33"""""""3DU"""""""3"333""33""""33"3D"""""""�"D"""""""""""""3"""""""""3"33""3""""""""3DDDU333DDDDUUfwwfwwfww3""""""""""""""""333DD"""3"""""""""3wU""""33"3"""���3"DfUD3333"3"""""""""3DDDDDUUfUUU33UffDUfwffUfUUffwwUfwwfUUfwwD3"33D"33fwffwfUUDUD3ff"""""3"3"33333"3"3D3DDwwfffwfD3"""33D""w̙U""""""333"3"""""""3""3""""""""DU3""""""""""""""""""33333""3""""""3D3DDU"""""3DDUUffwfwfw3"""""""3""33"""3"33"""3DD"""""""""""3""""""D3"3D3""��������"""U3""""3"""""""""333DUfUUUUD3"3f33D33wwffwUfD"UfffwfwwfwwfUwf"3wwUDffD3333DD""""3D""""""3"""3""3333"33DUwwwwwww"33333D"3̻fD"""""3"333"""""""D�"D"""3""3""D"3""""""""""""""""""""""33333""33"""333DDDDf3""""33DDUUUUfUfw3""""""3DDD""""""3333D3"""""""""""""""""""""33U"""�������"""3"""DD3""""""""""""3DDUffDD33""3""3333fwfD""UfwwwfwwwffDDffU3DDwfDfUUwf"""3D"D33"""33"""3""""33333D3DwU"33""3̻DUU""""""33"33"""""""33D"""""""""""3"""""""""3"""""""""""""""""""""D3""3""""33DDDDDU3""""3333DDUUfffwfff3"""3"DDUD"""""""33"3"""""""""""""""""""""33""3""�������""3"3D3"""33"""""""3Uwf3"3""""""33333Dw""""33wffwwwffDfwwffDUUUfffwUDfwD"3""3DD3""3D3D3"""""""33"333333wU3D3D33̻w33fD3""""""33""""""""3D"""3""""""""""""3"3""""""33"""""""""3D""33"""""3D3DDDD3D3"""""3"33DDDUfwẅ3""33D3DD3""""""3"""""""""""""""""""""""""33""""""�����""3"""""UU"""33""""""""""3w3""""""333"33Dwf"""""wwDDUUwwwwwDDD3DDUwfffDffD""3DUUDUUUDDf3"""3"""3"""D3333f33DfDf̪33Df3"333""""""3"""333f"""""3333"3""""""""3"3""""""3"""33333""""""""D3"""""""33DDDDDUUD3D3D"""""""3DUfww"33333""3D""""""""""""""""""""""""""3"3""""������"""""UwD""33""""""""3U3"DwU""""""33""DfUw""""3fwfUUDDDUf3DDwwfU""DD3"DUUfDUDDUfUUDDfwUUDDDDDDD"3""33"3""33""3"D33U3"Dw̻ffUD3""U33UDD33D3""3333"""""3333"DD""""3D"�3"3""""""""3""DD3333""""""""D3"""""""""DDDUDDD"3""33"""3U3"33DDDUwwww3"""""3U3""""3"33"""""""""""3"""""3"""""������""""3fUDDD"""""33""""""""""UU""3Uf3"33333"3333D""""""""""3U"UU"3""UDwUwU"D3""3D333DDD3UDUwwU"DUDfUDD333"D3333DDDDD3333"3"D"33U33fUD333DD"""""""""DDUD""""""3""""""""3""3"""3"""3"""""""""3DD33"333"3D""""""3UDUUDU""3"""3""""DD"""333DDfwwww""""33"""3fw3D3""""""""""""3"""""""""""���""3Uf3"3DUD33D3""33""DUf""3fD3""333""33UwD"""""""""333D"3""Uf3"fD"33"DDUD33"33D3UUU3"333"3DDDD33"D33333"3DD33333""""3D3Dw̻wUUD3"3Uf3"""""""""""""3"""""33"""""""""33"""""""""""""3DDD"""33"""D""""""33DUDUD3""3""""""3""""""33DDUwwwwwU""33""3DDUU3"3""""""""""""""""""""""�"3"""3wfU3""33333"""""3""""3333"UD3"333"""3DUD""3"""3333333333"""33D33"333""""333Uf3""333""3D3333"D3"33"3333"333""3"33333݈D33333""33""""""""D"""""U3""""""""""""""""""""""""3333"33"""3""""""3"DUfDfD"""3"""""3""""""""DDUfffwfffw3D333D333D3"""""""3"""""""33"""""""""�3"�""��UfUD3""33"""""""3""""""""""""""U3333333""D3"""""3"""33D"""3"DUD""""3"""""33DD""""""""3333D3"3D"DDDDD3"33""333"3D33""fݙwD3D33"""""""""""""""""""""""3""""""""""""""333DDD333"""33"�""3333UUfUU""D3"""""""""""""333DDUUUwwfD33""333UU"3""""""3"""333"""""""3""""3333"""""""�""ffD3""33"""""""""""""""""""""""3f"3""""""3DD""""""""3D""3UfD3DU3""3""""33UD""""""""33""""DD333DDU3"3"""333"333"3"D̻wUDD3""""33""""""""33"""""""""3""""""""""""3"""""��""333D"D3"D"""D"""33DDUffU3""33""""33"3"3"3""""33DDUUUwwfUww333DDfwf3DD3UfU""""33""""""""""3DD""U""""3"""""""�DfUD3333""""""""""""""33""""""UD""""""33ff"3""""""3"""33"3UDDDUD33"DD3D3"""""33DU3"""""3"3""""D3DD33DD3"""3333""3"3"3"UfUDDDD333"""""""""""""""""""""""""""""""""""""""""���"""333D333""""""3"""33DDDfD3""""""""D3""33"""3""""3DDDUffwwUU"""""3D333DwwwfDUD3""33""""D33D3"33""""33"""""""ffUDD3"""""""""""3D""""""w"""""""""Dw"""""3""3""DD3D33DD3"""""""333333""""""3DDD"""""3""""""UD333D3D"3333"""""3""DDw3DD3DDDDD""""3"""""""""""""""""""""""""""""""""""""""�""3"3"33"""""3""""33DUUD"""33"""3"3""3"""33"3333DUUUwwff3"""3D"""""""""""""�"3"""D3"3"3""""""""""ffD333""""33""33""""DU""""""""Df�"""3UDDUD"""3D"D3"3"""""""""3""3DD"""""33U"""""""""""3DDD333D33"""""""33""33U33DDD3UfUU""""""""""3"""""""""""""""""""""""""""""�"""3"""""""3""""""3DDUwD"""""""333"""33D33""D"3333DUUfDUDD"""""""""""""""""""���"""""""""""""""""UfU333""""""3"3DD3"""""D""""3Uf33333D"3UUD3""3DD""""""""""""33"D""3U3"""""""""""DD3333333"""33""33""UD3"DDDDDDUDD3""""3""""""""""""""3"""""3"""""""3"""""3DD""""�"3DUw3"""""""""3""333D33333"3"33DUUUwfUD3""""""""""""""""���"""""33"""""""""""3wfUD33"""""""""3D333"""U"""3DUUDfDDDD""UUfwwUUD"""""""""""3""D333UD""""""""DD333DD3"""""""""3""Uf"3""33DDUD3"33"""""3"""""""""""3"""""""D""3D3""""""�"""""""3"3UfwD"3""""3Uw3""""""DUD"""3"""""3333"33D333DDDUU"""""""""""������""3"""""""3""""""""""""""""""fUD333""�""""""""3"3""""""�wf3"""3DDD3D33D33"""U3DfD3""""""""""""""""3""""3DD"""""""""U333D33""""3""""33Dw3"3DDD"33DD""D3""""""3""""""""333""""""3"3""""3"""�""""3D""3""""3333"DUfU"""""3DDUDD""""""DUD"""3"333""3"333DD3D33DUDDffUD""""""����"""33""""3""""""""""""""""""""DwffU33""�"""""33""""DD3"3"""UDD333"""""""3D3"3D3D3""""""""""""D3"3UD""""""DUUD3""3"""""""""UwfU"""33"33DDD33""""""""""""""""""""333"""""3D3""""""""""""""33"""3""3""""""3DDDD""""DwD"""3DD3"""""""33""""33"3"33DDD3ffD3"""""�3""""""3"3"""33"""""3""""""3UwD"3"33""""�3UUD3UfwwD333"UUD3"""""D""333UD"""3"""3""""""""""3DUDDU3"""""DDUD3"""""""33"""3ff3"""""""3"DD3D333"""""""""""D3""""""""""3""""333""""""""""""�""333""3333""""""""""""""3"3Df""333"""""""""""""""""""""""3DDDD3DD3"""�""""""""""3DDDU3333""""33""""33Dff33""33"""""""""""DUwUfwf3DUUD33UwwUD3""33""33333DU33""""3D"""""""""""""33UfU""""""""DD3fU"""33""""DfwwU3"""""""""3DDD3DD"3"""33""""DD""""""""""""""""3"3""""""""""""""3333"""""333""""""""33DDfD"3D""333"""""""""""""""""""""3D3DD"D3"�"""""""""""D3UUD3"""33333""""33fwD333"3""""""""""""""3DUfUD33333DDDUD33""""""""333333"3""�"DD""""""""""""""33DUD""""""33"DDUU"""""D""UwU3"""""""""""3DD33""D3""3"3""""33"""""""33"""""3""""""""""""""3"""""33""""3"3Dwf""D33"33"""""""""""3"""""""""3"DD3D3"""""""""3""""""333"3""""3333""""333Dww33333333"""""""""""""3DDfwD"UU"""""33""""""""""33333333""33""""333"""""33DDD3"33""3UDDDD""3"DwDD3"""""""""3DD33D""3U3"D3"33""""""""""""""""""""""""3"""""""�"""""""""33DffwD33"3"3"""""""""""""""33"UDDD3"�"""""""33"333""Df"""""""333"""""33Uw33333"33"""""""""""""""333DDUDDD""""""""""3"33"""3D"33"3""""""""""""""""""""""333DDD""33UUD""33"3UwwU333"""""""33DD33D33UU3""""D3""""""""""""33""""""""""""33"�""""""""�"Uwfw""""""""33"""""""""3333DD"�""""""""33333""Df3"""333DD3"""333UUD33"3333""""""""""""3""""""3333DUD""""""333"""3333333""""""33""""""""""""33333DD""DD333DDUwfU"""""""""""""""DD3DDD33DD3""""3"""""""""""""""""""""""""3"""3""""""���"f3"3"D3"""""""""""""3UDD"3""""""""""3"3"""""""""""""""""D""3DDD3D3"33DU33"333DD3"""""""""""""3"""""""3D3DUDD""�"""""""""3"3"33"3"""""333"""""""""""33""33DU3333"33"Uww33""""""""""3D333DD"33"3"""3"3"""""""""""""""""""""""""""""�"""""""3"DU""33""""""""""""33D"3D"33""""""""""""""D"""3"""""""""3333D3333UUDff33D33333"33""""""""""""""3"""""33DDDw3�"""3"""""""33""""33D3D"3"""""""""33""""""333UDDD33"3Uf3D3"""""""DD3333D3""D3"""""""""""""""""""""""""3"""UD333""""""3DUwD""""""""""""""UDDDD"3""""3""""333D""3""3""""""""""�"D33D3""3DfwUDDDD3333333"""""""3""""""3"""""""""33DUUD"�"""""D3"3333""3D3"3D""""""""""3""""""""""""""3DDUf3"Dw3"""3D"""""3D333333""333"3"""""3""""""""""""""""3""3"""D3UDDD"""""""""33w̻D"DD""""""""""3DDD"""""""33"""""3333""""3D33""""""3""3Uw3UDDD33333333""""""""33"""""""""""""""33DwU33""""D""3"3""""33DU""""""""""""""""""""""""""""""33DDUD""fD3"""""D"""3333333""""33"""""""""""""""""""""D"3UUDD33"""""""""""�"3fD"3D"""""""3DD3""3""""""333""""""3"""333U3"""""""""3fwDD""333D3"33"""""""""""""""3""""""33DwU"3"�"3"DD""""3""3"3""3D3D"�""""""""""3""""""""""3DDf33ww3""""""3D"""3333333"""""3"""""""""""""�""""3��"33333333"""""""""""""3UUf"�"3U"""""""""33DUD3U33"""""""""333"""""DUUD3"""""3""��"3fU""3"333DD3""""""""3""""3""""""""DfD"3�3"33""""33"3"3"3"33DU"""""""3D33""""""""""3"33DUDUfD""3"""3"33""""""3333""""""3"""""""""""""""3U"�3D"""3""3"""""""""3DU3�333Uf"�"""""""""""""3333D3DD33""""""""333""""DUD333""""""""3""""""3fD""""UD"3D"""""""33""3""3"""""3"""Uf��D"�""3D333"33DD"""333"3333"""""""""""""D""""""""""""D"3DDwf3333"""""3333""3""3"3"D3"""3"""""""""""""""""3����""D"""""33""""""""333D3�"33DDfD"""""""""""""""""3""33333"D"""33"3""wUUD3D3"""""3""""""Dwf""""3D3333""""""33"33""""""""""3""ff�UU""""""""D"""3UD3333""3""3"""�"""""""3"""""""""""""""""""33Df333""""""3""33"3""""""33""""""""""""""3"""�""""��"""""""""""""3333"��""3333DfwD���""""""""""""D3"D33UUU33DDUwfD3DD""""""""""""""""""""DwU"""""""33"3333"""33"33"""""""""""3Df��"3"3D"""""3U""333333"""333""""�"3"""""3""""""""""""""3"3fD""""""""""""UD"3"""""3"""""""""""""""""""3""""33""""""""""""""D"D"�""3333DDUUwU""UfD"3""""""""""3""""""3DDUDDfUf3""DDD3""""""3"""3"""""""""""3"3UU33D"33U333"""""DD"""""""""""DUD�""""""""3""DD"""3""33"""D33"3""��"3D""""""""""""""3""3UD""""""""""""""D3"33""""33"""""""""""3"""""""""33"""""""""""3"""""3D�""""333DUUUDUwwwfwwwfUUwUDUD3""""33"""3"DUDUU3UDD"DUfwfDD"""""""""""""""""333"3wUD3"""""D3333"3333DU"3""""3DDU""""""""""3"""DD333""""3"33"""""333""3""""""""""""UfwUD"333""""""""333""DD"""""3""3""""""3"3"""""""""""""33"���""""""�"3D"��"3"""""333DDD33DDUU33"33333DUfwf3UwU"�3fU""""333D3DUUUUD333DUfwwU""""""""""3"""3D3"DffU33"""3DU3""33DDD333""""""33DD"�""""""33DDDU3"""""""3""""""""�"33""""""""""""Dwf3UD"3D3"""""33"3"D3"""""3""""""""""""""""""""""""33"""""""��""""""D3""3D3�""""""""""33"3""333""""""""DDfDUw""""33DDDD"DUD"33333"DDDUwf3""""""""""3"33DD"UDfUDD3"""DD3"3DD3D"D"3"""3"DU�""""""""""33DD""""""33"33""""���333""""""""""""""3DDDffD33U3333""""""""33""UDD3""3""33"""""3""3"""""3"""""""""3"""""""""��""3"""""33�"""3�"""""""""""""""""DUDfUUwwDwwwUDDUfffwU3""3333UD"""""33DUUf3""Uwf"""""""""33""DD3ffUfD3"33"""�"UDD3DU3U33D33""DU""33"""3""33"D33""3"""""3"""""""3""""""""""3D"""""3D""""3UfwfD3""U333""""""""""3UD3"""""3D3""""""333"""""""""""""""""""""""3"33""""""�"3""33333"��"""3"""""""""""33Dff3333"DffUDDfUDfUD3DUUfU3D3fU""3DDU3UU""Uff3"33"""""D3"UfUUwUUD333""""333DU33UD33D"""3U��"""""""3""3333333""""""""33""""""""""""""3D""33"3D33""3DfUDDUD3""DDDD3"""""3"3D3""""33DD33"""3"3DD3"""""""3"""""""3""""DU3""�""""""3"�"3D"""333D"��"""""3""""""""""""DDUw3"33"""ffUU33D333U3"""3DUwD""3DD3"U3Dw3D33fD"333"3fwUUDU33""""""�DUUDD3"""""3"""""3""DD3333"""3""333"33"3"""""""""3D"""""3DD3"33DDDUfUD3U33"DUDUDD""""""""3D33333"DDD3""""3"DDDD3""""""""3333"""""3"33"3U3""""33""""""""3""3D""3"3"3D3""""""""""3U3"""""""3""DDUf""3D33""fUU3"333"333UwU"""33DDDfD333UDDDfwU33D3D3ffwwffU""""""""3fUD"33"""D3""""""D3DDDD"""3""3333""U33""""""""""3U"3"33DD3"3""33DUUD3"D33DDU"DU33"""""3D3333333DD33"3"33DUUD3"333"3"""3D"""3"""D"3""""""""""""""""""""�""""DD"""3""3DD"""""""""""""UD"3"""""""D3""""DUUU333UU"3fD333333"D"3DfwwwwwwU"3"3DDDUffUU3UUffDUDUf3UffDDUUUfUUDDDUf3"3""""3fU3333""""D"�"""""33DUUU3""""""""""U33"3""""""""""D3"33DD3""3""33DDDD"""33D3UD3DfDDD"""""UD"33333D33D3DD""3DDUD3333D"D3""33""3D3""""3""3"""""""""�"""""3D"3"""33D33"""""""333""3DUDUfDDUfDDDDD3""""33""""""3f"""3"DwUf""3UfD33UD333333"D""3DUfffffwwwU"33DDUUffwU333UUffDDUDDDUDD333333DDD3DD"""""�"DfDD33"""""D3�"""3""3DUD3D3""""""""3D"3""""""""3"3333DD3"""""33DDD3D3""""""3DDU"DDD3""3UU333333"33Df3D33UDDD33""33"3D"3"""""3D3""""""""""""""""""3D"3""""33D33"""""3"""33333"33Dwwwf3UD33"D"D3333333D3DDUDDwU"""3UfUD"""3"""""DDD333333D3"3DwfUfwwffffwD33D3"UUUU""3333333333DDDDD33""3"3"333""D3"""3DDD3"3DD333""""3D3""""""3333"3"""""�33""""""""""""333DD3"""""3333333"""""""""333DDDD"""3DU3"3D333"3DUUUD3UUDD33""""3DDD"3""""""3""""""3""""�""""""3"DD"3"""33"DD3""""""""""""""33DD"3""3fwwff33D3��"""33""33DDDDDDDDUUUDfD�"""""""UDD33DDDD"�""3UfDUUUfffUUffwfD33ffUD"""""333333"3333D33"""""""""3""3""""DUDD""DD33""""3DU"""""""""""""""""""""""3"""333""""""""""""3"""DD3"""""3DD"3"33333D3D33fD"33DDUDUUDUDDD"""3"3333"""""""""""""""""""""�3""""""""3U"""""33""DD3"""""""""33D33"""3Uwf"""""""33"333""""3UDfffUD"3D"fUUDwfDU3""DUD3DD33333333UffU3"""""33333""""""33"""""""D3"""33U"""3D3""""3Df""""""""""""""""""""�""3"""""""""333""3"""""""333333U33"3""""D"UU"D3333UUDDDD33U"D33DUDUUfDDDD3""3333D"""3""""""""""""""""""""3"""3U""3""""3"33""""3""""33Uf""""""Uw""""33333"""""""3"3"�"DD3wwwwUUD33"""""Dwf"3"""""""3DUD33"""""""""""""""""""U3""33UD""3"3""""3Df""""""""""""�"""3""33"""3D3"""""""""33333""""""""""DDDD3DD"3"D""""3DffffUDUwwwDDDDD"33D3UUfDDDDD""3333333"""3"""""""""3"""""""""3"""""3"""""""""3"""""3"""3UD""""Uf333"""""""""""""3""��"DwwUUDD3"""""""""3Dw"""""""33"""""""""""""""""""""""""""""""DDD"3""3"""DU3""""""""""""�"""""""""""""""""""33""""3333333"3""""""""""D333DD3333""3"""DDDDDUwU3UwffwDUU"3DD3DfUUUDD33""""""333"3"33""""""""3""""""""""""""33""""3"""""""""""""3Ufw3"""3D"3D3""""��""3DUwwwwUD33333""""""3Uf"""""""""33333"""""""""�"""""""3""3D333"""3""3333DUfw""""3""""""""""""""""""""""""""""""333"33""33""""""""33333"DDD3""""""33DDUDDUfwfwwUDDfD3DDDDUffUUD3"""""""333D3"""3"""""""""""""""""""""""""""""33D""""""""""3fff""""""33"�""�""""3fUDD3333333""3333DDUf"""""""""3333"""""""D"3""3"333""33"3DUDUUD3"3fD"""""""""""3""""""""""""""3"""""33"""""33333"""""333""3333DDD3"333""""33DDDD3wwwDDD3DDDD3DDDDUUffU""3""""3"""3"""3""""""33"""""""""33DD"""""""33"33"""""""3DDfUw""""3"""�3�3"����"D3DDDDwf3"""""""3"3"""""""""D""""""""33"""""3DDUf3"333Uf"""333"""""""""3"""""""3"""""""3""""""""33"""""33"""""D333D333D33"""3333D3DwfD3D333DDUUDDDfUUDD""""""33"""""""""""""""""""""""""""""""33D3""""""""D""33"""D33DD3Uf"""3""""""�3"����33"3""f3""""""3""3""""""��"3"""3"3"333D3DUD""DfDDDUfwUD"3"""""""""3"""""""""3"""""�"3"""""""""33"33""""""""""DD333DU3333"""333"33UwU333"3D3DDDUUUfffUD""""""""3"""""""33""""""""""""""""""""3"""""""""DD33"3"""""�"�"3D3DD"3Uf"""3��"""""""""""�""""3UD3""""""""""""""""U3""""""""D3DfwwUUDDDUUfUD3U3""3"""""""""""""""""""""""""""""""""""D"""""""""3333UfDDUDD3333""3"""""3fwfD333"3333D3DffUfUD""3""""3""""""""333"""""""""33""""""""""""""""""""""""""""""3���""UDD33"DUD""�""3"""33"""""""�""333fwD""""�""""""""�D""""DU33333DfUfwUD33""""""3"33U3""""""""""3""""""""""""""""UU33""""""""""3""""""DDDDUD33"333D3""3"""""DwU3"3333"33333DwfUU"""""""""""3"""333"""3"""""""""""""3""3""""""""""33""�3��""D33""3DUfDDD�""333"""""33""""""�""""33wU"3""""�"3w3""""""D3"DDDUwffD""""""""3DU3"3"3"3"""""""""""""""""""3"""3wU"""""""333"3"""3"3U3333333333333"""""""UwwD3""333333333DfwU3""3""""""""""""333"""D3"""""""""""""""""""""""""""""""""""�""����""3U33"33DwfDfU�"""3"""""""D"""""��""""3Uwf""""�""3""UUwf3""""�3U3DUDUD33D""""""33U3""""""""""�"""""""""""""""D3""33"333""""""""33333""333""""3""""""3wf3"""3"3333333Dwf""""""""""""""""""3"""3"""""3"""""""""""""""""""�"""3"""������"3D3333DDUwwf3���"""3""""""""""""""��""33DwU""""�"DwwD""""��"DDDUUDDfDDD3"""3D3"""3DU3""""""""""�"""""""""""""""3"""33"""3"3""D33"333""""""3"""""DfwU"333"33D333DDUwf3""""""""""""33""""""""""""""""""""""""""3""""3""33""��"""3D""33UfUfw3""""""""""""3""""����""333"UD"""�3wwwwwwwwwffffwD"""DwwwffUUU3""3""""3""""3f3""""""""���""""3"""""3"""""""""""""""""DDUDUD3333"333"""""""""""""Dwf""3333DDU"3DD3UwwwfU"""""3"""""""""""""3"""""""""""""""""""""""3""""33"""3"""�""3D"3D33Ufwf3D�"333""""""""""��������""��"""33333D"��fwffffUUUDfUfwwfffffw"3DfDDD3"33333""3"""""""""""DU3"""""3"""""�������""""""""""3"""""""""""""""""3ffDD3"3"33333""""""""""""3Dww3333DUDDUD333DUwwfUD"3""""33"3"3""33""""""""""""""""""""""""""""33""""DU3�"""""3D33333DUffffwD�""""3""D3"""""��������""3333"3U"""33DwfUDDUUUDDDDUUUfffffwfUff3""""""3"""""""""""""""3DD"""3"""33"����������"""""3""33""""""""""""""""""UU333"3""333UU"""""""""UwfD3333"DUUfU33DDUwwUDDUU""""""33""3D"""""33""""""""""""33"""""""""DUUf33""""""""3DDDD3"3DUfwf"�"""""33""""""�������"�""3D3""3wD�"wD333D3DDD333DDDffffwwDD3""""""33"""""""�""DU3""3""33�����""""""""""33""""""""""""""""""DD3"333333"3fwU"""""""""3fww"3"""3"3UfU"33DwwwfDDDUU"""""""""3"3""""""""333""""""""33"""""3"3"""""""""DD3"""3""""""DDDD"3"DDDwf�"""""""""��""3D"3wDw"333D""wwwwwU333333333"33DDDUfffUfwD"""""""""""""""�"33D"""""""""����""""33"3333"""""""""""""""""""3D"333333"3ffU"""""""""DwfD""33"33"DU3"3DwwwwDDDDUU""""""""""3"3"""""""3""""""""""3""3"""33""""""""�"""""""�"""3DDUD""3DDww""""""3"""3""""""��""""""3UUUffUUwwfffUUD"3"""3333333333DUUUUUffffD"""33""""""�"""U""""""����""""333"33D""""""""""""""33""""333""3UUD"""""""""3wU"""333"3U"DU3D3UwwwU33UDD3DD3"""""""""""""""3"3"""""33""""""""""""""""""3""""�"33"""DUfDD33DDU""�""3""""""""""�"""""""�DU33UfwwUDDDD333"""3""""33333DDDDUUUDUDDU333D3DUU3"""""�"fU"""""""��""33333"""3333"3""""""""""""""33"""3"33"3DD3""""3""333U"3333D333UUD3D3UwwUD"DDDD"DDDU"""""""""""333""""""""33"33"3""""""3"""""""�""33""""3UfUDDDDDDD3"""""""3"""""��""""UU"3fUDfUfU333""33"3"""""""""""33DDDDDD3DDUUU3""3"D33DDD3"""""""""�"DwD"""""""""""f""""""33DU"""""""""""""3"""""""3"3D3""""""""333w3"333"3""3DUD3UfwwwU33DDDDDDDUU"""""""""3""33""""""""333"""""""""3"""""""""""33"33""""��"3UDDDDD3DUD"""""""""33"3""������3wU""DDfwUUUU3"""""""""""""""""3"3DDD33333DD33DUUD"3D""""DUD"3fwUU"��DD"fwU3""""""��"""""""3U""3"33UD""""""""""3"""""""""""33D33"""""""3333w3"""3333""333DfwwwUU3"33DUDDDDfUD"3""""""""""""""""""""""""""""""""""""""""""3""""33DD3"�"3D3D33D3f""""""""�3""""""""���3"""ffU3"UwDUUUD33"""""""""""""""DD333""33333"3D33DUDD3"3DU3UUfffwUUUU3"wUDwf3UD""""�""D""3"""""3D3"DD""""""""33""""""""""""333"""""""33333U3"""3333"""DDwwwUD""33DDDDDDUUUUwD3""""""""""""33"""""""""3"""""3DD3""""""D3""""""3"3"3""""3333333f""""33""""UD""""""3"""����"D"�DwwUDUfD""""""3""""""""""""333""""""3"""3"3"33""DD33333wDDUffUwf3UD"""���""""""""""3"""33""""""""""""""""""""3""33333"""""3"33fU33"""3"33""3wwwwfD3""3333D33DUUUfD3""3D3""3"""""""""""""""""33""3D"""""""""""""""""""""33"3""��"""""""3Uf3""3"3""""""33"""""""3U3""����"DU3"33""""DUU"fwwfUD3"""""""""3""""3"3"""""""""""3""""�33"""""3UDUUffwwUU"33""""��"3""""""""3""3"""""""""""""""""""3"3333"""""""3Dww333"3""333""DfwU3"""3333D3"DUUDDfD333DDD33"""""""""""""""""""3"""3"""33"""3"3""33""""""""""""33""""UU"33""""�""""""3D3"""""""�����DUD333"""3UDUfUwwwUUD33""""""""""""""""""""""""""""""""""""""33DDUUwDD"""���""""""""""""33""""3""""""""""33D33"""3"""33fwU"3""33333333wwUD"""""3333333DDU3U3D3DDD3D33"""""""""""""33"3333"""33""D3"3""3""""33"""33""33��"33D3"""3fDU3"DD"""�""""D"DfD3""""""����"3"""""DffUUDffUUDD3"""""""""""""""""""""""""""""""""""33Uwwwwf3D""3���""""""""""3""33UDD3"""""""""3""""""3333""""""""3DfD"3""3"3333"3wwU""""""33"333"333DUUU3D3DDDDU3"""""""""""""3333DD3""33333""""""3"""""""""3""�"333D""DUfUD""3D""�"3UUDwD""3"""""���"""""33DDUUD33UUfUDDDD3"""""""D3"""""""""""""""""�""""""DUfDffffUD""��""""""""""""3DUfUD3"""""""""""D3"""""3333"""""""""UwU""3""""3333DUwf3"""""""DDD333333DDUDDD333UDfD3"""33"""""""33""3""33333"""""333"""3""""""�""33"""DwfD""33"""3""""3UUDU"""3"""""""�3"�"3wUUDDD33"DUDDDDDD""""""U3"""""""3"""""""""""3"""��"""""33DUffUwU""�""""""""""3ffUfDD""3"""""""""33"""""3333"""""""""DD3""3"""3"33"UwU3""""""3D333333DDDDUD""33DUDDD3""""""""""""""""""""""""3"33"""""""""""""""""""""33D3"""""3ffD33"""33"3"""""DfU3"""3""""""��"3wfUfwwUDDDD3"""DUDDDD33"""""""3"""3""333""""""""33""��""""D3UUUUwf""��"""""""""""""3DDUUf3"3"3D3""""""""""3"""""333D""3""""DD""""""""3""33fwf3"""""""DUDDD""33D33D33333DUD33D"""""""33"""""""33""""""""""33"""33""""""""""""""""DDD3""""3D3D"3333333""""3""D3D"""""""3""��UffwDD3333""3DD333333""""""""""""""3""3D33""""""""""""33ff333UU"���"""""3D33333333333"3DDD3"""""""""""""""3"""""""3D3""""""""""""3fwfU"""3"""33DDDD3"3333DD33"3DD333UD33""""""3"""""""3"""""""""""33"3"""""""""""""""33DD33""3Df""D333333""""""""Uf3"D3""D"3""""�"wffD3DD333"3""D3DDD333333"""""""""""""""3333333"""""333"""""�3""""U3""3f""""���"3"""3U3"""3"3"3"33""3UU3"""""""""""""""""""""""""fD""""""""""3UwfDDD3D33"33"DDDDD33333D33333D3"33UD3D3""""3"""""""""""""""333"""3""""""""""�3DUD3D3"3UU3""D33"3"3"""""""""""DUDD3UUUUUU33333"""""3wwUDDD3"3333"3"""3D3DD"33""""""""""""3"""33"33""""""3""""""""3�"33""ff"�����"3DDDD3"""""""""3DU""33DD3""""""""""""""""""""3f3""""""""33wfU"""333DD"3"3DDD333""3DD3DDD33D33DUDUD"""""""""""""""""""""3"33DD3"""""""""""""��""3UUU33DDDDD""""""""""""""""fUUfUUUDUUDD3DD3DDDD33D33DfU33DDDDD33333333"3"333D33D3""""""""""""""33""3""3"""""""3""""""""�""3""DD"""��"""""33""""""""""33""3"DD3""""""""""""""""""DD3""""""""""Uwf"3"33D3D3D33""3333"""333DDUU3D33333DUDDDDD""""""""""""""""""""""3"3DD3"""""""""�"33DwwD"33DfDD""""""""""""""ff3DDDDDD3333D33DD3UUUDDDDDD333DD3333333D33"33333DD3333"""�"""""3""""""333"333""""3""""""""""3DD"""""�""3""""""""""""3"""""""""""""""""""""""f3"""""""""""""33wfU33333D333333"3333333"3333UUfD3D333333D333Df""""3D"""""""""""33333""""""""""""33"3f3""3"DD"3""""3"""3UfUUffUUUD3333333D3"3"DUUUDDDDD333DUDUDUD"333333"3"333DD3"3"""""33"""""""333"""""333""""""""����""""""333D"""�"""""""""3""3""""""D3""""""""""w3"""333""""ffDf3D333"333D33"3""333333"33UUUDDDDDD"3""""""DDD"""""""""""""333"""3"""""""""""33333fU3""3UUD3""""""""DDD""DUfffDDDDDDD33"33333333DDUUDDD3333D3DUUffUD3"""33"3333D333"3""""�"3"""""""333"""3333"""""�"��"""""""3DD3D"""��""""""""""""""""3D""""""""3U3"""""""""""3DwwDDDD"33D3333D3D333""3""33"3DUUDUDDD33""""3UU3""""""""""""""""33"""""""""""33333f"3"3Df"""""3DDUUDUUfUDDDDDDDDD3D3DD333D3DUUUUDDD333DDDUfwfUD3""D33D33333333"3"3""""�""""""""""""D33""33D3""""""""""""""33D3DD"""""""""""""""""3""33"""""""Uf"""""""3fUDD3DD"D3333333D333""33"333DUDDDUUU3333""""""33UU33D""""""""""333"""""""""""""""""3333f3"33Dff3"""""3"DU333DDDUDD333333DD33"3D333D3DUUDDDDDDUUUUUUDDUD"333D3DD333UUD3333333""""�"""""""""""""""""""3333"""3""""""3""�""3�""""""33UU3""""�"""""""""""""333"D""D"""""3ww""""""DwDD3D3D33D3333333D""""3"3"33UDDDDUU33DDDD""""""33DDff""""33"D""""""""""""""""""""""""""""3DDUw"33DUU3DDDUDU""DDUfD3333333""3DD3"""33DDD333DD3DDDDUUDDDDDDUUDD333333DDD33333DDDUUU3"333"3""""�33"""D"""""""""""""""333""3""3"""33""3"33"�"""""""""3DUD3""""""""""""""""�"333"""3"3""""Df""""""3wUDDDD3DDDD3333""3333""""""3DD33DDDDU"3D3DD"""""333DDUf3U3"""""""""""""""""""""""""3DUDwf"""D3UDDwD333UUU33333"""""""""3D3""333DDD333D33DDDDDDDDD33D3DDD33333DDD33"33"DUUfUD""33"3"""""""D3""DwU"""""3"3333""""3333""3""""3""""33"""""""""""33DDU"""""33""""""""""""3333""""""Uf""""""""3DUUDDDDDDDD"33333"33"3"""3D""DDDDD33DU3""D33"3333"3D3DUUUU"3"""""""""""""""""""�""3DDw3""33DwfU""""3"""""""""""""DD3DD3"""3DDD33DD333333D3333333D33333D"3DDD3"3"3DDUfDD3"3333"""""""""""""""3fU""""""3"""""3"DD3"""D"""""""""""""""""DD33"3"""""""""""""""""DU""3"""""DfD"""""""""""""wwwfUUD33"33D33"33333333""33UfUUwfUU3"333UD"33"33"3"333D3D3DDUUwwDU""""""""""""""""3DUwU""""3DUw""""""""""33DD"33""""333DDDDD3D3"33DD33333333333DD33DDD333DUDUfUfD"3333""""""""33"""""3"""3""""""3DDD3"33""""""""""""""""DDDDU"3""""""3"""""""""D"""""Dww"""""""""""""fwfffUD333333D3""3333333""UfffwfUD3""33"33DD3"33UD3D""3UDDDDDDffUww3""""""""""""""""""DDff3"333DU"""""""333"33"33333DDDDDDDDD3D33DUD3""33D3DDDDD33333D"3333UUff3333333D"""""""3""""3""""3D33"""3""3""""""""""""""DDDDD3DD"""""""3"""""""""""""""UUD333""""""""""wfffUUDDD33333"""3""33"""3UfUDDD3""""3"""""33""333DUf3""DD33UUUD33DUD""""�3""""""""""3"33""3DDD3""""DUU3""""""""""3333333D3333DUD3D3DD3DDDDUU3"3"3DDDDDDDDD3333"""3333DD3UD3333"3D33"""""""""""""""D3"3""3""33D3"�3"""""""3DUDDDDD3"""""3"""""""""�UD3333333""""""""3wwfUDDDDDD33D"33"""33D3UfU333333""""""""""3"""3DDUfD3D"333D33333D3ff""""""D3""33D333"""3DD""""33D3""33"""3""3DDUD3"333DD3DfUDDDDDDDDDDDDfU33DU333DD3D33D3D3333333333"3333DDD33""""""""""�"""""""""33D""""333"3D"""��"""""""3DD"33UU3""3""��""""""33""""""�3UU333333333"""""3wwffUUUDD3DD3U"3"""333DDUUD333333"""""""""""3"D33DDf3"3"3D333333D3Df�"""""fU3333"""""3UUD"""""UD""""""3"3"333DDDDwD3DDDDDwfDDDDUUUwwfUwfDUUD3333DD33DDUDUU333333D333""33DD"3""D3"""��"""""""33""""""""DD"�""""""""3333"UDU"""33""""33""""""""""""�"fDD33333333333D3fwwffUUUUUDD3DDD33""""DDUD333333""""""""""""""33D3DDU3""UwUD3333333D3DfwDD3""""""3D33""""""""33DU3"""""ww"""""""""33""""3DUfUU"3"fwDUUUfwDwUUUUfDDDwwUU3"""33333DD3DDU3D3"333333D33333UD"333UU33D"""""""""""3U3""""""D"���"""""""333UfDD""""""33"""""""""�3fUDDDUDDDDDDDDUUfffffUDUUUDD3Df3""""""Dff3333333"3"3""""""""""""3DDDDDwfUD333333333333"3Dwwwf"""""""""""""""�"33DD""""3w3"3"3"""""D3"""""333"3fUffwfDDfUDUUfw"Df3"UfD""""3DDD3333D3"33333D33D3DDDDDD"3DDU3"33"""""D3DD3""�""""3DDfDD3""""""""""D33"D""""""""��UwwwwwwUfUUUUfw""fUUUU33DUUUDDUDD3"""3DfU333""3"3""""""""""""""""3UD3""33"3"333333333333DDfffD�"""""""""�3DD3333f""333"""33"33D3"3""""3fDUU"wfDUUfffU"3UfD""3fU3D""D33UU333333D333333U3""DDDD3"""""""3D"3""�""""3DD3D3"""3""DD3D"3"""""""""����UwfwwfwwUUUDUDDDDDDUUUUDD33""3UUD"""""""3"""""""""""""""33D33"33"3"3333333"33D3DDUUUfUfwD�"""""""""""""""�"DU"DfwU33333"3D3""33D33"""""""3"fD3UwfUUUfwfwf"DfU3"wfD33D3fD33DD3333"3333333DD"33DUD""�""""D"�"""""DDDD33D""""""3fUD""3""""""3"""3D��wfw̻U33DU3DDD3DDDUUf3D3333DU3""""""""""""""""""""""33D3333333"3333333"33333DDUUfUffUww"""""""""""""""""""�"3DU""̻33DDD33333D33D3333""""""3UUfUDDDD33"DwwD33"DDD"DUD"33UDDU3"3"""""33333""3333D3""��"3"3""""�"""3D3DU333""���""3"""3DUD""3""""""333"�3"DffUwf"D333DD333DDDDDUDDD333DD""3""""""""""""""""""""""3D3"3"""3"""33333""3"333333DDUUUUfUwwDffU3"""""""3"""33"3�""ffDUwwDDDUUDDD3333DD333DD"""�""3DDDD3D3D33333ww""3Df3"3333DD3D""33"""""3DD33333333333""""""""""""3"3"""""""33D"D"""3��"33"""""3D"D3D"""""""""�3wDUU"""3f"3UD3DDDDUUUUUUfDUfD333DD33"""""""33"""""""""""33333"333""""33333"""3333333DDUUUfUUUfwfww""""""""""""""3"��"̈wfDẅUUDDDUDDD3DDD3D3D33U3"3DD"""33DDDD3""33fwwwD""""3Uw33333333DD"""3"""""""3D333"3333""""""""""33""""""�""""""""Dw"��"""""DUD333"3D3""""3�DwDUUfUDDU"3U"""UUDUUDffwffwwffffU33DDD33""""""""""""""""""""""3333"""""""3""33""""3"3333333DDDUDDUD33Dff"""""""""""3U̻DDwwUwUffDDUUUUDUDDDDD3D""""""""""333""3"3fU3"""""UwD333333DDD3"3D3"""""3D"333D3""""""""""""DD33""""""""""""�3""3D33DUUw3"""""33""3""""""Uw3Df3DDUD3"33"D3D3"UUDDUDUfffwwwwffD3DD333""""""""""""""""""""""33"""""""3""33333""3"3"333333333DDDD3333DDfU"""""""3""""""3"f̙DD3UUfwffwwfDDDUDDUfwwfwUUD"""3""""3""33""""3DUw3333"""DUfD33""333D3333""""333333""""""""""""""""""""DD3D3"""""""""""""""""""3DDDDDUw3�""""""""""""""""""�"fw3Dww"D333""""D33DDUUU"DUUffwwwwffUUUD"33"""""""""""""""""""""D33"""""""33"333D""3""""33"3333"33333333333UwD"""""""""""DD"Df3D3""""Dff3UD3U3�D3D""""""""""""""""""33DUfD33"""333D3DUD33333""""""3""3D3"""""""""""""""""""""""3DUU3D333"""""""""""""""""3""�"""33DUUUww"�""�""""""""""3""""DD��Dfww3"3"""3"""""3DD""DD""DD33fwwwfUfUUDD3"""""""""""""""""""3D33"""""""""""""3"""""""""""""""""""""""3DDDfwf""""""""""""""DD3"fwD3"333"""""D33DfDffD"""""""3""""""""333UDDDUf33D33"3"DfUfD333"3""""""""3333""""""""""""""""3333"D333333"""""""DDUU3333333"""""""""""""""""""33Dfff""""""""""33"""""""̙w3�""3UU"""""""""3U33"""""DwwwwfffffDD3"""""""""""""""""""3D3"""""""""""""""3"""""""""""""""""""""""33333Uwf3""""""""""3DD3UwffwfDD"3"333""3""333"""�"""""""33""""333D3D33DD"D33UfUfDD33"33"""""""""33""""""""""""""""""D333""3"3333"""""""3UffD"""3D3"""""""""""3"""""�3""""33Dff3""D333"333""""""""""""""U̻33��"33D"""3D3""""33D""""""""3""DwwwwwfUwwDD3""""""""""""""""""""3D33"""""""""""3"""3""""""""""""""""3333DDD""""""3DDUUUfwUfffD333333""333333333""3"""""""""""""""DD3"""33"33D33DDw3D""""3"33333""""""""""""333"33"3""3"""""""""33"3""""3DUwf"""""3333""""""""""""""""33"""""3DfU33""""3UD33DD3"""""""""""""3""3"""U3"""333DD3"""""33"""3fUwwfwwwwUD33"""""""""""""""""""DD333""""""""""""3"333""""""""""""""""""333D"""""""""3DUUUwwUUUfffU33333D3333D333""3"""""""D""""""""""""""""DU""""3"""""DDUf"""""3333DD3333"""""333"3"3DUUUDDD33""""""""333""""""3Ufff""""""3"333333"""""""""""""3""""""""3fD"""""""3"3DDDD3D3"3""""""""UU3""""""3333UU3"""""33"3UUUDwfwwwwfDD33""""""""""""""""3DD3D"3""""""""33"""3"3"""""""""""""""""""""3D""""""3333DUwwfUUff3UD33333D33D3D3""""""�""""3333""""""""""""""33"""""DUUw3D3"33DD3DD333""33""3""3"UwU33""""3D"""""""""333"3"33DffU""""33"3333333333"""""""""�"""""""DU"333""""""""3333DDUDUU3""33"""""3f"�"""""""3"333Df3"3"33"3UfDD333DfwwffD3"""""""""3"""""""3DDD3333"""""""3"33333""""3""""""""""""3UU"""3""3DDDffUUffUD"333D33D333333"""""""""""33D3""""""""""""""""""""33DUUD3333333333333"333333""33Uw3""""""33"""""""""333DDffU"""""33"333"333333""""""33""3"""33D""3D3""333"""33""3UUD"""""""U""""""""���"""33DDDwU"33333UUDDD33DD"DwwDD3"""""""""3"3"""3DDDD3"3"""""""""""3UD""33""""""""""3DUU"""3"""33DUfUUUUUUUU33DDD3D3333"""""""3"33""""""""""""""33""33UfD3DDDDDD333DDDD3D333D33UUffD"""""3DD"""""""3333DUfU33"33"""""33333333"""""""33"""""""333"""33""3"""""""""3Uw3""DDf3""""3""�����"""3DUDff33333UUD3DD3DUD"3DfU33""""""""3""""""DUU333""""""""""""""""DD3"""""3"""""""""""DDUffU"""3333DUfUUUUDDDDD3DD3DD333"""�""""""""""""""""""""3333333DDUUDUD33333DU333"UfDDDDD3D3"""""3"""""DD33DDwD"D333"33"33333333"""333""333""""�""3D3""""33"""""""3"Dw3UD�UU3"33D"�����"""3DUDDfD33DDfU33DDDfU3"33UD3""""""""3"""3""""DDD""3""""""""""""3"""33D"""""""""""""3"333DffU"�"""""333DUfUUDDD3DDDDDUD33"3"""""""""""""""""""""""33""33333wwUDD333"33""""33333"3D333""""""""""""""3D33DUwU""Df33333"""333333333"""""33"3"""""""3DUD""""33""""""333UD"UwDU""""""33""��"""3DUfDfU33DUfD333DDf3""3"DU"""""3333333"""""3UD3"""3""""""""""3"""3D"""""""""""""""""""3"3DDUDffD3""3DDDUUfUUU3"DDD3DDUD3333""""""""""""""""""""""""""33333"3DwUDD333""""""""""""33"DDD3""""""""3""""333UwU3""3UfD333"3""333333333333"3"33""""""�""DU3""""""""""33DD3"""ww"3D"""""3D33"""""3DUffwD3DfUDDDDDfww"""""DU3"""333""33"3"""3D33""""""""""""33""""3"""""""""""""""DD333DDDUfww�"""""33UffUffUUU"DD333D3DDD3""""""33"DD""""""""""""""""3"33333D33DwUDDDD33""3"""""3""333DD33""""""""""3"""""""""DwD"""3D33"""3"33D""333"33333"""D3"3""""�""3U3""""""�"""33"U3"""f33D"""3"UD3"""3DDUwfUUUUffUfU"""3UfU33"""33"33"""""D3""""""""""""""3333"""""""""""""""3""3333DD333DUfDfw"D""""3DUUUUUUU333DD"3DUDD3""""""33"""""""""""""""""D333"""""DDUUU3"""""""""""333D3"""""""""3"""""33"3U"""""3ffD33D3D3DD3333"3333333"3333""""""""""D""3""3"""""3333""""""""fw3""UD""""3UU3"""""""3DUwwwwwwfUfwf"""3wwDD3"""33"""3"""""D3""""""""""""""33"3""""""""""""3D3""33DDDD33UUfUff"""""3""""3D33DDUfUD333"3UUUD3"33333"""""""3"""""""""""""""""""""""3D33"""""""""3D""""3""""""3D3D3"""""33""""""""33D""""""33fD3333DD33333"3D"33D3333""""""""3""""""3""3"""""""""3wwD""""""3f3DUD3"""""""33DDUfwwfffwUUUUwwD""""3fwfDD""3333333""""3U3""""""""""""DDD333""""""""""3333333DDDDDDDDUUw""""""""DD3DUUD33"3D3DUUD333D3""""""""""""3""""""""""""""""""""""""""""""33DD""""""""""33""""""""""""3DDDD3"""""""3""""""""""""""3333""33"DD3UUfUD33333"333D3D33D"""""""D3D3""""""""""""""""""UU"""""fD""UUD33""""33DUUfwUUfwUUfUDDDDww3"""""fwfDD333333333""3"DU333"""""""""""DD33"�""""3"""""""""33"3D3DD3D3DDDfD3""3"D33DUUD3333"DUUDD3"33"""""""""""""""33"""""""3"""""3"""""""""33DDD33"3""""""""""""""""""""""33DD333""""""""""333""""""""33""33D3""33DDDDD33333"333"3333"""""33DfU3"""""""""""""""""UD"""""""DU33UUD3333""33DDfwfDDfwwwD3DfDDfU"33"""DwwUDD333333333""3DD33""""""""""""33""3""""""""""""3"""333D3D333Dfwf3"""3"333DDD333""DU3DD333""""""""""""""3333"3"""33"""""""""""""333UDDD3"""""""""""""""""3D3"33"3""""""""3"DD3""""""""""""3DUU3"""""333DDDD3""3333""3333"""""""""3Dfff"""""""3"""""""""�D3""""""""wD""DUDUD3D33D33DDUffwffwfDDDD3DUUD""3"""fwwfDDDD33333"""DUD""3""""""""""""""3""""""""""""""3333D"3"3333DUUUf3""""33D3333""""33DD3333"""""""""3D""""""""3333""3""DD33"3""""""""""""33"3UD3"""""""""""""""""""333""333"3"""""""""""D33""""""""""3D3"""""3"D3DDDD"3""3""D3D3""""""""""""3UDDU3""33"""""""""3"Uݻw""""""""UU""UD3DD3333DDDDUDDfwUUDDDDDD33Uw""""333DffwfUUUD3333"""fD""""""""""""""""3""""""""""""3333"D33333"""DDDUU""""3fD"33"""""3"3DUDDD333DU3""""33""""""""3D333""3"""33""3"""""""""""3fD3""""""""""""""""""""""""""33D3"""""""3"""""""""""""3""""""333333UD33"333D33"""""""""""""3DDDDD3""333""""""""3""""""w""""""""w33fD""""3DD3DUUUDffD33DDDD333DDUU33"3""DDfUUUUUDD33"""Dw3"""""""""""""""D""""""""""""3""""D"33"""3333UUf"""""3D33"33""""""33D3DD3"33"""""""""""""33"333""""""33"3"""""""""""UD3""""""""""""""""33"""3""""333D3""""""""""""""""""""""""""""""""3333333D3"3"333D3333""""""""""""DDUUDUU3""3""""""��"""""33"""UݻD"""""""""wUwf3""""3DDDDUUfwU3""333333"3UU333333333"UDffUDUDDD33"3Uf3""""""""""""""3"3"""""""""""""""""""""""""""3DUwf333"333DD333"""3"3""33DDD3"""""""""""""3""""3D33DD3"""""""""""""""""""""3DD3"""""""3""3"""""3UD""D"""""3""33"3""""""""33""""""""""""""""3333333DD333"D3D3"33333""""""""""""D3DDDDU333"""�"""""3"""""wݻwD""""""""UDwD33"""3DDDDUD3"""""""""DU""33333333D3UUffUUDDDD33DfD3"""""""""""""""3""""""""""""""""""3""""""3""33Uw3Uf333""""""33DDDDD33"""""""3""""3DDD"""3DDff3""""""""""""""""""UU33"""3"""""""""""""33"33"""""""3D33""""""""""""""""""""""333DD3""3DD3D33333""""""""""""3""""DD3fU�""""""""DfݻU3"""""""3UffU3""""""3DfwwU""""""3UU"3333DDDD3DfUwfUU3333UUU33"""3"3"""""""�""3""""""""""3"""""3"""""3"33"333UwwffD3"3"""""3"3DDDD33""""""""""DUU3""3333""""""""""""""""""3"UfUD""33""""""""""""""""""3"3D3D"""""""""""""""""""D3""333D3"3DDD3333D3"33"""""""""33"""""33"U3""""""3"D3̪wfU"""""""DffD3"""""3wwfD""""""""DUD""""D33DD3D3fffwwwU"3UwfD"3"""3"33""""""""""3""""""""""""""""""""3"""3""33333DUfwwU"33"""""33"D333"3"""""""""""D3""""3""""""3"3"""""""""""""""""""3"33DDD""3"""""""""""""""3""""DDD3""""""""""""""""3"3U333"3D3"333333333D33""""""""""3"""""D3DU""""�""""""33DDw̻wwUwU"""3"33wwD33333"DU""""""""""""""UUD3"""3DDDDU33UffwfUUwUwfD33"D""""33"""""""""""""""""""3"""""""3""""3"333DDDUUUUD"33""""3"333DD33D3"""""""""33""""""3"""""3"33333""""""""33D"""333333333D3""""""3"""""""""""""""33333"""""""""""""D33D3"33"3D"333DUU3"""33""""""""33""""""""33DU3"""""""""333DwU"333333ffDDDD3Ufw""""""""""""3fUDD3""""3DUDUUD3wfwwUUffUDD333333"33""""""""3"3"""""""""""""""""3"""""333333333333DUww"3"""""""3DDD333""3"""""""""""""""""""""""3"""3"""333DUwwfwwwUDDDUUUDDDDD3""3"""D3"3"""""33"""""""""333D"""""""""""""""3""""""DDD3""""3D3""DD33UDD333"3"33""3DD3""""""""""3Uf"3""""""""33DfD333333fUDUfUUU"""""""""""""3UDDDDDD"""3333DUUUUwfwwU33"3D333333333""""""""""D3"""""""""""""""""""""""""""3333""33DDUU3333"""""33"3"""""3""""""""""3"""""3"""""""""3"3333DDUUUfffwUwwwfUDD3333DDDDD"""""D3"3""3""3"""""""""3DD3""""""""3"""""""""""DD""3"""U3"3UUUUwfUfUD33D"""3DUUD""""""""333DUD"""""""""33DÜfD"333DDwwfUU""""""""""""""3wfD3DDDD333"333UUUUUUDD3"""DUD33D3333333"""""""""3"""""""""""""""""3333"""""33""""3"33UUD3333"""""""""""""""""""""""""3"""""""""""3D33""333"3333DDUUUUUUfwU3DUDDUfDUUD""""33"""""3""""333DDD33""""""""""""""""""""DU3""3""UD"3DDUUUDDDDDUffUUUUUU3"""""""""""333D"""""""3DffwwUU33DD33wfw3""""""""""UwfwfD3UUDDDDUUDfUDDfwUD3"3DUD""3333333""""""""""""""""""""3"""""""""""""""""3"""3D3""""""""""3333UUU333"""""""""""""""""""333"33D33"3DUffUD333"""""""333DDUUUDDDD33DD3UD3DD"""""""""""33DDUDD333""""""3""""""""""3D"""3""UwDDD3DDD3DDDDDUDDDDU33"""""""""""""333D3"""""""33DwffwwwD33333fD333"""""""""wU33DfwfDUDUDDUUUUUUffUD3"33D33"33D333""""""""3""""""""""""3""""""""""""""""""""""3D"""""3"""""33DDD3D"333"""""3"""""""""""33UDDDD333Dffwf3D""""""""""""333DDD""3""""""""""3""""""""""""3DDDDDD333"""""""""3"""""""""D3"3"3"fffU3333DUU3D3DD3DDDD"""""""""""""""""3333D3"""""333UfffwfU333DÜ33333""""""""""""3f""3DDUUfUDDDDUUUDDwwwUU33"333D33333333333"""""""""""""""3"""""""""""33"3""""""""DD""""""""""3DDD3"D"""3""""""""""""""""""33"""3DD333DUU33UD3""""""3""""""3333"""""3""""""""""""""""""""33DDDDUD333""""""""3""""""""333"3""Dwwww333333333333DDDD3"""""""""""""""""""33DDD"""""""3DwDUfffwfwwD33f̻f33D33""""""""""Uf"333DUUUDfw3DDUwwwfUDDDD33333"333"""""""""3"""""""""""""""""3""""""""""""""""""""D3"""3"3"33DDDUfD3"""""""""""""3""""""3U333DfDUD3"""""""""""""""""""""3DD33""""""""""""3D""""33DDDDDDUDDD3333D3D"3333"""""""3""""33fwwUUf"3D3333DDDDDUDD333""""""3""""""""""3"33333D33"""""""3fwD3UffUUfwwwwwwfUUw3DfDDDD333""""""""""""DwD"3333DUUUDUfwwffUUwfD33DD333DD3D33"""""""""3""""""""""""""33"""""""""""""""33""""333333DDDDUU3""""�""3""""""3UUDD3DUUU3""""""""3"""333""""33"33"3"""""D3D33""3"33DDDDUUUUUfffwwffUDDU3""""""""""""UfwfUfD3"33333DUUUU3DUUD""3""""""33333""33DDUDDD333D3""""""333wU33DDUUUUfwwwwfwffUfUDUDDD33"""""""""""33D"""""33DUDDDUffwUDDDUfwfDD3333333DD3333"""""""333""""""""""333D"3""""""""""""3""""3""333333UDDD""�""3U3""""DDUU33UD3"33""""""""333333"""3""""3"""�""""""""""333"""3""33333DDUUUffwfwwUUfwUDD""""""""""""3"ffwUfUfDD3"333UUU33DDDD"33333333DUDDD3DDDDDDDDD3"""""""""3"DD"33DDDUUUfwwwfUwfUDDDDDDD333"""""""""3D3""""""33DDUDUUUfwfDUUffwfUDD333"3DD3333""""""3333"""""""""3D3"33"""""""""""""""3""3D333D33""""33D3""DDDDD3DD""D3D"""""""""""""""3DD"3333"""333""3"""""""""""D"333"DUD3DUUwwwwUffwfwfUUD3""""""3""""""UUwUDwUDDDDDDUD3D3DDDfD33"3DDUUUUUD3333DDDDDD333Df3""""""33w3"DDD3DDDUDUUUffU̪DDUUDDDDD33""""3""3""UD"""33DDD3DUUDDfwUDUffffUUUD"D3DDDDDD3"3"""3333333""""�""""3"D33"""""""""""33"33D3D3DU3"��""""DUU3"3D33DDD"3DUUD""33"""""""""333D""""33"""""3""""""""""""3""""""D333DUwwfUUfDDUwwwwfUU3"""""33""""3""3ff3UwfUUfwwfUUUUDUUUD"33"D3D3DD3""33"DDD3DU333DU3""""33333ww33DDDD3DDDDDDUUUfUw̪UUUUUUUDDD33"""""33"3U3""3DDDU3DDDDUUwDDDUwffUDD333D3DDDD33"33DDD333333"""""""""D"D3"""""""""""""3""333333Uw"""""""DwwU"3D3DUD33"Uw3D33"""""""""""""3""""3"3""""""""""""""""""""3UfUUDDUUUUUUwwffffD""""333"""333DUDwfffffwUDD3"3DD33"""333D"""""333DU3333DD333U3""""33DDf3"33DDDD3DDDDDUUDUwfUUUUUUUUUDD33""""""3UU""""33UUDD33UUUfUDDUfffUDD33DDUDD3DD3D3DDDD333"""""�"""33""333D3""""""""""""""""""33"DDUUf3""""""""3UUfwDDD3"3UDDDD3""""""""""""3""333""""""""""""""""""""""""3DUUUUDUfffUfwwfwfDU""33"""""33333"Uwf3DwUwwwfffD"""""""3"""D"3U3"""333DUD33333333DD3""33"fD"3DDDDUDDDDDUUUDwwUDDUUUUUUUUUDDD3"""""UU3"""""3DDDD3D3DDUUUwDwfDDD3333D3DD3DD3DD3DDD3333"""""""""""3DD3D3"""""""""""""""""""33"UUfU"""�"""3""""DDDfwDDD3DUDD3D33""""""3D3""""""""""""""""""""""""""""""""DDUUDDDUUUUUDDffwwUDDUDD3"""""3333DwUUUwwwwf3""""""""""3"""3DD3333333"3DD33333D3U3""33333"DDDDDDDDDDDUUUwU3DUUUUUUfUUUUDDD333"33wf"3""""""3DDDDD3D3UUUfDfwwwDDD"33DDDD33DDUDDDDD3333"""""""""3"3"""""""""""""""""""""""33DDD33U3"�"""3""""""3UwU33DDD33Uf33""""3""""""""""3"""""3""""3""""""""""3DDD""33333D333UwwwfDDf3"""3333D33fwwfUDDwf3""""""33""""""""3""33"33333"D3333D3UU""33"3"333DDDD33DDUUUUU""3DUUUUffUUUUUDDD33"3UwU"""""""""""3DDDDDD33DDUUD3fwUwwUD333DUDD33DDUUDDDDD333""""33DD3""3""""""""""33""""""""33DD3D"3"""""D3""3""33UD33DUD33fwD3"3D33""""""""""""""3""""33"""D3""""""""""""3UD3"""""""""3"Dffwffwwww3"""33"3DDfwffUUfwU3"3"""""333"3""3"""""333333"3DD3"3UfUU""""33"D33D3DDDD33DDDUff333"DDUUUUUUUUUUDDDD3"DfD3"3"""""""""""333DD3333DDDUDUwUwf33333DDD3D3DUUDDDDDD33"""""""33""""""""3""""""333UU33"3"�""""D3"""""3333DDD3UDUU33D3D"""D"""3""3D"""""""""""""""33"""""""""""3D33""""""33DffUUUfwU"""3"DD3wwwD""""DD3"""""""D"3"""33""3D3333333D3UfwwfUwU3"D""3"w33D3DDD3DDDDUfwD3333"DDDUUUUUUUUDDDD33Dw33333"3""""""""""333D3333DDDDUfwfDwU3""3U"3333DDDUDDD3333""""""""""""""""""""""33333""3""""""""3""""""""""33DDDD3DDD""333""""""333""""3""""""3"33""""""""3"""""""""3""""""D3"""""""""3DUfUUfwfwf"33333UwwfUDw"""333333""""""D"3""3"""33"3""33UfffDD"3UDD333D""Dw333DDDDD3DDDUUff"3333DDDDUUUUUUUUUUDDDff3"33""3"""""""""""333D33DDDUUfwfUwfUUUDDD3""3DUDDD3D3D""3""""��"""""""""""""""""""3"3DD""3""""""""""""""""""3DDD33DUf33""3""33"""33""""""""""3""""""""3""""""333""""""""""""3"3"""""""""""3DUUUUfwfU3333Dfw3DUfUDfU"333"3"333D333333"""33""33333D3DUU333DUDf3333UD"3ff3333DDDDDDDDfUUwUU33333DDDDUUUUUUUUUUDUwU""""""3"33"""""""""""3333DDUUDUwfUfUwwUUUUD3D"3DUUDD33D33"""""""""""""""""""""""""""33DD""3"""""""""""""""33333DUfDD33"""""33"""33""3"""""""""3"""""""""33"""""""""""3"""""33"""""3DUffUUfwf333wf33UUUDD33333"""3UD3D3D3"D3"""33"3D33DDDUU33DfwfDUD333DUUfD33D3DDDDDDDUUUww33U33333DDDDUUUUUUUUUUfD33""3"""333""""""333DUfwUfD"UUfUDUUU3"D"UfUDD33333"3""""�""""""""""""3""3"""""""""""""3DU3"""""""""""""""""3DUD33DDUDUDD3D"3"""""333""""""""3"""3""""""""333""""""333"""""""""33DfUfUUUUUfDUwfUwwUUD333"""33333DD"33333D"""""3DD333333fDDfwU3DU3D3DfwfwU33D3DDDDDDDUDfwfU3"UDD33DDDDDUUUUUUUUfD333""D""333"""""""3UDUffUfw3""UfUUDUD33DUfUDD333D3""""""""""""""3"""""""""""""""""""3""33"DU3"D3""3"""""""""""3UDD3DDUffwf33"DD3"""3D3""""""3"3U333D"333333""3""3""3"3"""""""""33DUUfUUUfffwwUUDDUfD333""""3"333"33"3D3""""""33DD333333ffwU333UU3UUwwUf333D33DDDDDfUfD3D33DUDDDDDDDDUUUUUUDwwDD3333"33"333"""""""3DfUUUfwf3�3UDUfDD3DDDUUUD3"3333"""""""""3"""""""""""""""""""3""""""""33"33DfwfD3DD"""""""3DUD3DUDwfUffD33"3""""""3""3""""""3"""DUD""DU""D3D""""""""3D""""3"""""""""""333UUUfUUwwDDDwwwwU3""3D3U3"3333333333"""""33DDD3333DwUfU33"UfUUffwUfwwwfD33D3DDDDDDfUU333333UfDDD33DDDDUUUUUDDDD33""D"""33"""3DDfUUUfU"DUDfD3DDDDUUUUD33333"33""""""3"""""""""""""""""""3"""""""""3DDUUwwUUfwf""""33DD33DDUDDD33333"""""""3""""""3"�3""""3DDU"3U3"33333DDD3"""""""""""""""""33"3DDUwffwwU3DffUUUfUUwUDD33D3333333333"""3"DDDD33DDUUUfD"3"3fUfwwwwwU"""3DD3DDDDDUUU3ww333D33"DUffDDUUUDDw3DDDD333""3"""33""""333UfUUfU"�"fUUD3""DDDDDDDD33333"3"""""""""""3""33""""""""""3"""""""333"""""333fwwwwUDUDUfwwU"�"""""3"3DD333UDDDDD"333"""""""""""""""""��""""""DD33UD33DDU3DDU""""""""""3""""""""""333DUffwfDDfU33DUfUffUf33333333DUD333""3"""3"DDDUUDDDD3UD""33"UUUffwwww3"3333DDDDDDDDUUU33""3333"3fwDDDUUUUUDDDDDDDD333"3"3"""""""333DUffww"�"3DwfU"3DD3DDD"3D333333"3"""""""""""""3""""""""""""3""""3"""3""""333"DfwwfD3DDUUDDUfD�""""""""""DDDDUUDUDDD33""""""""""""""3"""33DD"DU""UDDUUUDD3"""33"""3"""3""""""""""""3"333Ufwwf3DDDUUUffUDDDUDw3D3333""3D333333""""3DUffwffUUfU3"""3D3UDDfwwwww"333333333DUDUUUUUfw3""3333"3"fUDDUUDf33DDDDDDDD3333"""3"""""3"""3DDDDUwwf3""33""UUDDDUDD"3DDDDD33333""""""""""""""""""""3"""3"3"""""""33"33""3333UUfD33UDDDUUff"��"""3"""3D333DUUDD333D"""""""""3"""""3"33333DD""3DDDUUff3""""""""3"""3"""""""""3D3UfwDDDDUUUwwUD3DDDUwD3D333333DD3333"3""3DUwf3D33D"""3333DUDUwwwff""333DD33DDDUffUUffU"""3"""""DDDDwf33DDDDDDDDD33"""""333""33""33D33DwfD""""""UDUU33UDDD"33DDD333"33""""""""""""""""""""""""3""""333333"33D333UUD"3DUUUUfww"""DfUDD"""""""DD33DUDDD3333""""""""""""3""""�""""3"3"3D3"3"DD3DDUfU"""""""""3DD"D3"""""D3DDDUwwfDDDDUffUUUDD3DUUwwUfwD3"333DUfD3"3333DUUfDUU33"""33"333DDDUUffww"33"3333DDDDDUfDUfU3""""33"""""wwD3DDDDDDDDDDD33"""33D333DD3333DDDUf"""fUwf3DDDD33D3DDDDDDD3""""""3"""""""""""3"3"""3""""333"3"""33333DUfD33DUfUfwD"3DfUD3"""""""3"33DDDD3333D3"""3"3""""3"""""""""33""""33""33UD33DU3333""""""3DUU3D33"""""3DUDDDffw33UDDffffDDDDDDUUffwfffDDD"DDD3D3"33DDUfwU3Df3""""3""3"333DUDUwwwU"33333DDDDDDDfD"Uf""""3""""3""D̪̪U333D3DDDDDDDD3D3333""33DDDDDDDDUUfwU""DffUD33D""DDDDD3DDDDD3""""""""""3""""""""""""�3""""""3"""""""33333DDUD33DUUfUww3"33""""3"""""""""33"33"33"DD"""3"""""""""""""33""""3"""D3UUD3DD"""""""""""DUf"3D33""""""3DDDDUffwD3DUUUffUDUDDUUDDDDwfUUUD33DD333333DDUUfUfDDDUD""""""""3"DfUDUUD3"3""3DDDDDDDDDfDDU""""""3""DUwfDDDDD33DDDDDDDD3D333""333DDDDDUUDUUDf"D"DUDDUDD333333333DD3DUD""""""""""""""3""""""""""""""""""""333333DD3U333DUfwww"""""3""""""""""""3""33""DDUD""D33""3""""""""""""3"""""""3D"""3UUD"DU""""3"D3333UUUUD3"""""""""33UDDDUfw33DUDUfwDDUUDDDD3D33wUDDfD"3DD3D333DUUUD3wwUDDD3""D3""3D33ffD""""""3DfUUUDDDDUUwf3""""""33fwDDD3DDDDD33DDDDDD3D3D33"""333DUDDfUUD33"33"3D33DUD33333333""DDDDD""""""""""""3D3""3""""""""""""""""""""""""3""33D3333333Uwwwwfff""""3D""""33"""333"""3"3DDDU""DU33"3"""""""""""D"""""""""""""""3DUDDD"""""""""U3D3333"DD""""""""D33DDUDUw333DDDUfDDDUUD333"DUwU3DUf333DDDUDDDDDUD3fwDD3"""""3D33DD"3UwD"""""""33UUUDDDDDDfwf"""""""""UwU33DDDDD3D33DDUDD333D""""3333UDDUUff3"33U"�"D"33UUDD"3D3333333UUDD"""""""""""3UD""""""""""""""""""""""""3333DD33U33DDfwwwfDDU""3""""""3"""""""3""3U33D3"33"DDDDfU"""""""""""""""U3"""""""""""""""333D3DDDU3"""""3UD3"D3DUD""""""""3""DD33DDUUUD"3DDDUfD3D33D33"3"UfU33DUfUDUUffDDUUUfffUD33D3""333"33DUUUUfD""""""33DDDDD3DDUwwD""""""""wfwwfDDfwD33D3DDDDDDD3333"""3333DD33UUfU3"33DD�""3DDUDDD3D333"333"UUDD"3"333"""3"UU3"""""""""""""""""""""""3333DD3D3333UfwffDDfD"""""""3"""""""""""3333333""33"DD3Dfff33""33""3"""3333""""""3"""3"""""3"33DDD3""3DD333DD3D"""""3U33"33"33DUUU3"33DDUUD333D33333DDwD3DDDfUUUUfUUfUUUD3"3"3"""""""DDUfwwfU3""""""""DDDDD333DDww3""""""3wfD3DD3DDDDDDDD3333"""3333D333DUD33"33D3"3D""3DDDDDD"333333333UUU3"""""3"3DU3"""3""""""""""""""""""""3333DD333"33UfUUD33f""33D3"""""""""33"""""3"3333"3333Uf3DDDDD333"3"""""""""""""""33"""33"33U3D333"""UD3D3U3"33""""3D3"""3DUDwU"333DDUD3D333333"3DUD3U33UfUfffwU33333""""""""3UUUUffUD""""""333UDDDDDD3Dff"""""""DwfUDDfw3DDDDDDDDDD333333""33DDDDDDDU""3""DD3"""""UfUDD3D3"""3333D33DUU3"""3333""U33""33""""3""""""""""""""3"""33"UDD"""333DDDDD33UD3D333"""""""""33""""33D333DDD3UU3DUDD3333D"33""""""""""""""""3"""3"33DD33U3"3DD"3UU3333"""""3U33""3333DUf3""3333DUD3333""3"33fUD33"DDUUUfffwfU"33"3""""""""3ffffwwD""""333D333333DDfU""""""3wwwfUDDDwD3Uf3D3DDUDDDD33""""""33DDDDDUU3""3UD3�""""""3UUUD333"""3"33333D3U3"333333"3"333"""""""""""""3"3""""""3D333"333333DDD333f"3D33"""""""""""3"3"""33333D3DUDDDUD333D333333""""""""""""""""3"33Uf""""D33333UUD3""""3""""3333DDDfUfD"3"3D3""""""3"3D33333DD3UUDfwwfDDD333"""3D"""""UUUfUD3"""""333"3333DDDUU""""""3DfwfUUDUUDDfwUUUwUDDDDDDDDD33""""""3DDDDUUU""33U""3333UUD33""""""3D333DUUUDD""""""3""""""""""""""""3""""""""""""3""D3"333333D3333Uw33""""3""3""3""3""""""""3333333DUUD3"3DD"""33""""""""""""""3"""""D333wwf""""3"33"33333""33""""3333DDDfww3"""33""""""33"3DD333333DUUUfwfDDD3"3"""333"D3"33UUUfD3""""3""3"33DDDUD"3""""""3DffUD"""""3333DDUUfwUDDUDD3D33"""""33DDUDDU3"33U"""DUUDDD"""""""""3DD3333Uffw33"""3"""""""""""""""""""""""""""""""3"D3"33333D3333Dw3""""""33"3""""33"""""""""3D3"D33UUD"""3333333""""""""""""""""3U3D33fUfwD"""3"""""3"""""3"""""3"333Dwwffwf""""""""""""3D33333333DUDUUUfwf"3333""3DD""3""DfUUff"""""""""333"33DUfU3"333""""""""DwfD"""""3""333333DUwU3DD33333""""""333DU3""""3U3""DUDDD3"""3""3DD333333"333DffUDD3D33""""3"""""""""""3""""""""""""33"""3D33333"33Uwf"""""3"33D33""3""""""""""""3""33DDD3"3333333D3""""""""""""""D333"3fff3"3UU3"""3"""""""3"33333DfffwwUD"""""""""""3333"333333DUDUUUwwD33D333D3"""""3DDDU33"3""""3D33""3DUffD"""333333""3UUfD""""""""3333333DDwD3D3333333"""""333DD"""3"DD""DUD333333""""33DD""3333333"33DffD"33""""""""""""""""33""""""""""""333""3DD33D3"""DU""""""3"333"3333""""""""33"3DUUDDU3DUD3D333"""""""""""3"""3"""""""33""D""3UU"3DfwD""3"""""""333333UUwwwf"""""""""""""333D333333333DUUfffUDfDDUDDDDD"""""3D3UU3""""3"""D333333UUf3333DD333"333fU3""""""""""""33"33DDfD3333DD3333""3333DD"""33DD"�3DD"33"D3"3"3""3UD"333"33"333D3UfD"3""""""""""3""""""3"""3"3""""""33333333D3333"D3fU3"""33""""3D3333""""""""""3333DDDD3DUUUU3"""""""""""3""33""""""""333"3D3""3DD3UUwf3""3"3"""""33333DUUwfU3""""""""""3D3"3DD3333333DDDUUUUDDDffDDDDD33""""3DDUU333""""""""""3D333DDDUDD3D3"3D3"3DffD3"333333""""3""333DUU33333333""333D3333"""3D3UD��DDDD3""33""""3UU3"333D"3333DDDDffD"""""""""""""""""""""""""""""""3D3333333DD3333DUU"""""D3""""3UU33"""""""""""""33DD33DUDDUUD"3""""""""""""""3D"""33"""3""333333"3DDDUwfUD"""""""""3333DUUUwfUD3"""""""""3D333DD3333333D3DDUDDDDD3ff3DD333"""""DDDDDD3""""""""3"""333UU3333DDD3DDD3"Dff"D333D3DD3"""33"3333DfDD33333"3333333"3""3333DD�"�3D3D3"""""3fUDD3333333""3DDUUfU"""""3ffU""""""""""""""""""""""33"3"33"3333D333DDDD33"""""33"3""3UUD333"""""""33D3D33DfDDD333"3"""""""""""33""3""D"""3"3333333DUDwU333"""3"""""333DDUwfwwfUfD""""3"""""D3"3f33333333DDD3D3333UU3fU3UUD""""""3UDD""3"""""""33333"UUDD"""3D33UD33D3UU"3333333DD"""""""""3DUUD33333333333333""""33""3f"33""""""""3DDU3333"33D333DDDDUDD3""fwwU3D"""""""""""""""""3""""""""3""33DD33DDf33D""""""""3333DUD333""""""""33333333UUUDD333"""""""""33"""""""3""333"33ffUfffwU""""33"""33"3DUUfwwwUD3"""""""""""DDUfUUD"333D333DD3"33DDUDfffDUD""""33DDD""""""""""""""3"DUUU3""3""3333DDDDDwU3""33""33D"""""""3"33DDDDD3333333DD3DD""D33333U""""""3""""""""3"DD3"""""333333DDDfwwDUffUD3333""""""""""""""""3""""""""""333D33D3""""""""333DDDUUD33""""""""""""333333DUfU3333"3""""333""""""""33""333UwffU3"""""""3333DDUfw3wfD333"""""U3"DUfDUwD3""3D3333D333333DUfww3DDD"33DU333"""""3"""""DDDD3"""""3333""3UwfU""""3"33333"""""""3"33DfUDDD3333"DDDD3"""DD33"3f3""""""""""""""""3"D3D"""""""3333DDUfwfDDDDDD3D3"""""""""""""""""333DDD3""""""""""""33UfUUD3"3""""""""33"3D33333UUUD3"""""""3"""""""""""""""33"33UfwwwDD33"""""""""3DUDffDUD33""""""D333DUUUUU"33333"333"3333333DDwffU333333D33""""D"3"333UD3D3"33"3""3""3ffUD""""""""3D33"""""""33DUwUUUDD3333D3DD3"333"""3DU""""""""""""""3"""""""D3""""""3"33DUfwUU33D3DD3""""""""""3""""33DDD3"""""""""""3""3DD333""""""""""3"""33"33333UUfDDD""""""33""""""""""""""""""3DD3DDDf3"DwU3"""""""3DUUUDwwDD3""""3D33D33UDDDDD"33"3""3"3333333333DUDDUU3"333333""""3"333"DUDDDD""3D33D"3UUUU33"""33"333"""""""""333UUDUUfD3DD333UD3"333""33DU""3"""""33""""""3DwwUDDD33333333"""""""""3""""33D3""""""""""""""33DD33""""""333""""""""""3333"3"DUUUDD""""""""""""""""""""""3D"33D3333"3"3"3"""""""3DDUfffw3"3""""33D33D"DD3D333""3333"3"""33333333DDDDDUU3DD33333""""333""33DDD3UD33U33UUDUDDD3"3""3""""""""""""""""33DDDUUfDDD33"DDD333""333DfD""""""""""""3DDUUD333"3333333"""""""""3"3""33D3""""333""33D3333""""""""33"""""""DD"33"3""3UfD33"""""""""3"""""""""33UD""3UD3D""D3"33"3""3DDUfwwwU"3"""""D3333D3"3D"3D3""""333"3""""33333DDD333DDUwfUDD333""""3"33"DDD3D333UU3UDDDDD3333""""33""33"""""3""3333DDUDDffUDDDD"D3""""3333UU3""""33""""""""""""33UUfDDUUDD333"3333Df3"""""""""""""""33333DD"DDD3"""DD33333"""3"33"3"""""""""""""33D3"""""3UDD33"""""""""""""""3"3D33"""""3Uf333"""""""""""3DDUUffwf""""""""D"3""333"3333""""33"""""""333"33DD3""333Uwf333"""33"""333D3DDUD333DUUDDD333"33"333"33"3"""""""D33"3D33DDDDUUUUDD3DDD""""""33UD3D"""D33""""""""""""33DfUUfUDDD3""""DDDUD"""333"3""""3"""333"""333333DD3333"""DDD33D33"""333333"3"""3""""""3D3"""""33DD3D3"""""""""""""""3Uf3"""333DD"D3"""""333"""3DDUUDUffww3""""""3""3D"""3"3333""33"D3"""33""""3"3DD3"33"33UwwfwUD""""""33"""3"3D3UffDDDfDDDD3"3"3333"33"33""""""33""33D3DDDDDUDUUUUDDDDUD""""3"3DUf"3"�"""3""33""""3"""""3fUUUDDDDD""""33D"3f""""33DD3""""33"""333""""333"""D3D3D33UDD3""33"D33333"""""""""33""""3"""""333D333D"""""""""3"""""""33UDD3""3DDUUUfD""""3DDU33"DDDUUDUfwUwwD3"33"""33""""3"3333333"33""3""""D333D33"""""""Dffffwww3"""""""""33D333UUDUUUUD3D33"""3333"3"33"3"""3"3"3333DDDUDDUUDUUDDDDUfD"""""3DDw33"""""33""D"3f"""""�"""""DwffDUDDDDD"333"3"DD"33"""33""""""33""""33"3"333333DDD33333DDD333""""""""""3"33"""""""3""""3DU3"3""""""""""3""3"""3"33333"3333D3DUUU33"""3DffD"3DDDDDDUUUwfUU3"""3"""333""3"""3""3"DD""""""""33DD333"""3"""3DUUfwwf3333""""""33DDDDD33wfDD333"""3"3333333DD3""333"33DUDDUD3UUDUUDDDUDUUD3""""""3Dw3"U""""33"D33DD""""""3UD"3DD33"3"3""""DUwfUfU33""""""3""""""33"3""3"3D33D3D333"33"""""""""""3"""D3""""""""""""DU""""""""""""""""""""3333""""DD333D3333"""""""ffD"3DDD3DDUfUDUwf""""D3"""3""D3"""""""3D333"""""""""3DD""""""""""DDDDfwwww3"33"""""3DDDDDUUDUfU3333""3D"333DD3DD3D3D333333333DfD3DDDDDfDDDDUDD33"""""""3Df33"""""""3"3D"DU""33""3wUD""3D3""3""3DwwUU3"3UD""""""""""""""33"3333333D333D3""""""""""""""""3""3"""""""""33""3""""3"""""""""""3"D"""3DD333D333D33"3Uw33DDDDDDUfwfDUUU""33""""3"Dwf""""""3DDD3"""""""3"""D"""""""""3DDUUDww3"3""""""33DDD3DD3DUU33"D"33333333"""D3""""3D3"33333D33D3DD3DDUDDUDDUD3""333""3"""Uf""3"""3"""33D3"DU3�"33DDD�""""""ff"""""""33"3UUww3"""3DU"""""""""""""3"33""33333"3DD3"3"3""""""""""""33"""""""""""""""3D3""""""""3"""""""33"3"""""DD"""3U3DD3DD3""D""DDUUDDDDDDDUUfffw̻f"3DD"""3ww3"""33333"""""""""333"3D"""""""DD3DDDDfwwfDD"""""333D"33"D3UU33""3U3"""""""""""""""333""333333333D33DDDDUDUDDD"33333""3"UD""""33"""3""3D3DD""U3""""""""""""DU3""""DwwwU""""""33U3""""""""""""""33"333"""333""""""3"""""""""""""3""""""""""""""3""""DD"""""""3""""""3"""3"""33"3"3"DD3D33DDD""3"""""33DDUDDDDDDUffw""33"""wwwD3""33""""""""""""33""""""333D3333DUffwf3""3""3"D333D3DD""33"3""""""""""""""3"33"33D3DU33DDD3UUDUDDD"3D33"3"33""w3"""33""D"""3333"UU3""�""33""""3wwD"""""""3D"33"""""""333D"""""""""3"33333""""33D3"""""""""""""""""3"""3"3""""""""""""DD"33"""""""33""""3D333"33"ff33DD3D3"DU""""""3333DD33D3DUfwUww3"""""""""""33"""""""""3""""D"""""333333"3DUUUfwf3""33""3DDDD333D3"UD3D3""33"""""""""""3"3"DDD3""U3"33DDfUDDD33DD33"3""""""Uf"33""""333"Df33�"�""""""""""DwD"""""""3""3""""""""33""""""""""""""""""""3"3U"""33333"3"3""""""""""""33"""3""""""""""""D3333333""""""""""""""D333333"3UD"333DU3"DDU3"""""""3"33D33UUUfUDDUUfw"""""wwU"""""3"""""""D"""3D""""333D""""3DDUUUfD"3"""""D333"33DDDDDD33U3UwU""33""""""""""""3333333"""3UDUUDD3333"333DD""333""3wU"""3""""""33333UU3""""""""""""3DU33"""""""""33""""""33"""""""""""""""""""3""""""""3333"""3""""""""""333""""""""""""""""33D3333"3D3""D3"""""3"""3DDDDDD3""3fD"333DUU3"DUf3""""""3"""33UwfUD3"DDUDD"""UU3UUU""""""""""3"""""""333333""""3DDDffD3UU3""33DD"3D33333"DDDU33U"33"""""""""""""3333DDDUD3D33DDDDDD3D""3"33U3"333"33""3""""""DDDUDUU3ffU3""""3"""""UfD3""3"""""""33"33"""3"""""""""""""""""333"""33""33""33"""""""33""333"""""""""3"""DD33"333333"""""33D33333333D3"""3U333333UUDD3333""""33"3333DfwfwUD3""U3DUUfUf3w3"3fDUD""""""""""""33D"33""""33DDffU3D3""""3UDDD3"3"""3333"33DD33""""""""""""""33333D3DD"3DDDDDUDDD3333"33"3"333""3wf""""""""3DD33"""fUUUD"UD""""UwD"""""""""""""""""3D"""33"""""3""""""""""""""""""""""""3"""3"""3D"3"""""""3D3""3""""""""""""""DD3"""333""""""3"3UD"""3333DDD333U3"333"DUDDfD"U333DUDDUUfUUDDDDD3""3D33Df3""DUDDD"""""""""""""""""""33""33""""3DDUUfDD333""3D333D333""D33"U3"3DDDUU3""""""""3333"3333DU333"33DUUD333DD""333DD33""""U"3333333""333"DUffU3U""3DfU"""33"3""""""""3""""""""3""""D"""""""""""""""""""""""""3"3"""""3D"""""""33D3"""""""""""""�""""3""3DD3""3333""""""33"fwU""3333DD333"UU"""3"UffwwwwUfUUUffD3333DDD33"3D3"33Dwf"""""DU"UD""""""""""33""""33"3D""""3"3DUUDfU3""D3"""""""3"333"D333DDDUwww3""""""D3""3D3"3DD33D333333D33DDfU333DDUDD3""3D33DD333"3"333DDDUfUfUD3"���"UUD3"""33333333"""""33"""""33""33""""""""""""3"""""""""3"3"33DU3D33""""""""""""""""""""""""""""""""3DD3"33"""""""""""""3w"""33D33333"3Uf3""3UwwUUfUfwfUDDfDDDUD33333DD3DD333333DDfU""3"""3DD3w"""""""""""3"""""""""3""""""33DDww""3"333"""""""33""3""DD""3DDD3D3""""""""3""333DD333""333333UUUU333DDD3"3DUf3DDD3""333"33D3"fDUUUU3""�"DUfD"""""""""""""""""33""33"""D3"""""""""""""""3""3"""""""3""""333333D3"33""33"""""3""""""""DD3"""3""""""DD3333"""3"""""""""""UD3""33"333"33UD""DwUUUUDUUUD"UwD""""3D33"3""""""3D"333Uݪ"D3"3"3D3UwDUff""""""33""""""3""""3UUfD"3D3""""""""""""33333D33333""""""""""""3D3DD33""""3""3wwfDDDDD33"""DDD333D3"""3"""33DfDDDDUD"""DU3""""""3""""""""3D""33""3D""""""""""""""""""3"""""""3""""D3D3"DU3"""3""""""3"""""33DUUDD3""3D""""""3D3"""""""3DDD"""""""3"""3333333""D3"3ffUUUUDD3D33DDD3"3""""3""3"""""""""3333U3D3""3f3UU3DfD33""3U3""""33""""""""""33UDfffUDDUD33""""""""33D333"3"""33"3"33""""""""""""3DUDD333"3D333Dww3DUD"33"3D3w"33"""3""""wDDD33D""U3����""""3""""""""3""""""3U33""""33""""3"""""3""""""""""""""33"3333""333""""3333333DfwwfDDD3""33"""""3""""""""UDD""3"""3333"33"333"3DD3DDwU3DD33333D""3D""3"""33""""""""""""333Dݪ"DD333UU"3DUU33""Df""""""""""""""3DUUfffwwwU33""""3""333333DU"3UD3D"""3"""""""""""""3D3333"Uw333"ff33DD"""""DDw�"3""3"""3"fD33DD3"wD���33""""""""""""""""""3DU""""""3""""""""3"""333""3""""3"3D33D33333D3"""33DDDDUUf3""UD"""""3DDDD""""""""""""""33""333"""""333D33DwwDDD3333DD3""33"""""""3""""""3""""33DfݻU"3"DDD33""DDU3"Uf""""3""""""D3""DDUfUUUfwwwf"3"""""""DDDDDDD333DDD""3""""""""""""""3D33"""3333""fwDDU3""""""DUf""""333""""DUDDDDD3Df"�33"""""""""�""3"�"3D3"""3""333""""""""""""""33"""""""""""3"3D33D33""333UUUff3""3"3"""""3""3DfD3""3D""""""""3"33"3"""33"33""33DwUDDDD3D3fD"""3"""""""""""""""""3U̪U"33UD"3w""3DfD33fD"""""3"""33""""UUUfUUUfffwfDD"""""3DDDUD3D3333DD3333"""""""33""""333333"""""""33333""""Df""""333""UDDUfU3DD�""""""""��"""3U3""33"333"""""""""""""""D3"""3"33U3"33"3D33D3D3DD33Uf̈3"""""""""""""""""D3DD3D"333""""""3D"""""333333"333D3""3wwDD3DD3DD33D3""""3""""""""""""""33̻D"333DDw"""DUf3D3U""""""""""""D"DDD"3DDDUDDDDUUUwUD3""""333"3DD33D333DDDD""""33""3"""33333""""""""""DD""D"""3DwD�"""3UUffUU3��"""""""""""""""3U3333D"333"""""""""""""3"""333""3333U33"""3DDDDDDUDfw̙U""""""""""""""3DDDDDDU3"3D3""""""""""""""33"33333DD"3fwUDD"3D33"3"DDD3"""3""""""3Dff33"33""f""3DfUD""3""""""3""""3""3D"3"33DDDDDDUffffDD""""""""""""3333333DDD333UD33DU"""""33""""""D3""3DD"""3Dw��"DUUfwUU"""""""""""""""""DUD3"33"""333D"""""""""333"""33""333D3D3"33"3DUffw̻D��"""""""""""""""DfUDD33D3""""""33""333""""3D""333333"wwDD333333"3"D3"D3"""""""33DUfD"3"3"3""DD3"DUwD"""""""""3""""D"""3""3"33DDDDDDD3DUwU"""""""""""""""333333DDDDDD33D3D""""""""3"""""3U"DDDff3""""3f""��"ffD33"""33"""D"""""""""3UU3333333333DD33"3333"33"33"3D3D3DfwwfUUDDfwffD3���"""""""""3"""""""DwfU33D33"""""""""3""3"""""3D3D333"33DwUDDD33"333"""3""3D3"""""""""3DUUffwfDU3"33"""U"33Dw3"""""33"""""""""""3333D333DDUfU""""""""""""3"""33"333fUU33"""""D"""""3"""""UD"3"33"3UfU��"�DUD33��""""""3D3""""D""""""3"333DwDD333DUDDDDfD333D333DUDDUUD3DUwffD3wwD�"""�""""""""33"""""������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ \ No newline at end of file diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/menu.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/menu.rb new file mode 100644 index 0000000..acd01f3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/menu.rb @@ -0,0 +1,79 @@ +=begin header + + menu.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + $Id: menu.rb,v 1.6 2005/07/18 17:13:32 mutoh Exp $ + +=end + +require 'sample' + +class MenuSample < SampleWindow + def initialize + super("menus") + signal_connect("delete_event") do true end + + box = Gtk::VBox.new(false, 10) + add(box) + + menubar = Gtk::MenuBar.new + box.pack_start(menubar, false, true, 0) + + menu = create_menu(2, true) + + menuitem = Gtk::MenuItem.new("test\nline2") + menuitem.set_submenu(menu) + menubar.append(menuitem) + + menuitem = Gtk::MenuItem.new("foo") + menuitem.set_submenu(create_menu(3, true)) + menubar.append(menuitem) + + menuitem = Gtk::MenuItem.new("bar") + menuitem.set_submenu(create_menu(4, true)) + menuitem.right_justified = true + menubar.append(menuitem) + + optionmenu = Gtk::OptionMenu.new + optionmenu.set_menu(create_menu(1, false)) + optionmenu.history = 4 + box.add(optionmenu) + + box.add(Gtk::HSeparator.new) + + button = Gtk::Button.new("close") + button.signal_connect("clicked"){destroy} + + box.add(button) + + button.set_flags(Gtk::Widget::CAN_DEFAULT) + button.grab_default + end + private + def create_menu(depth, tearoff) + return nil if depth < 1 + + menu = Gtk::Menu.new + group = nil + + if tearoff then + menuitem = Gtk::TearoffMenuItem.new + menu.append(menuitem) + end + + for i in 0..4 + j = i + 1 + buf = sprintf("item %2d - %d", depth, j) + menuitem = Gtk::RadioMenuItem.new(group, buf) + group = menuitem.group + menu.append(menuitem) + menuitem.set_sensitive(false) if i == 3 + submenu = create_menu(depth - 1, true) + menuitem.set_submenu(submenu) unless submenu.nil? + end + + menu + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/notebook.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/notebook.rb new file mode 100644 index 0000000..3a57586 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/notebook.rb @@ -0,0 +1,281 @@ +=begin header + + notebook.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + $Id: notebook.rb,v 1.11 2005/07/18 17:13:32 mutoh Exp $ + + Rewritten by TAKAHASHI Hitoshi <thitoshi@ne.scphys.kyoto-u.ac.jp> + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +require 'sample' + +$book_open_xpm = [ +"16 16 4 1", +" c None s None", +". c black", +"X c #808080", +"o c white", +" ", +" .. ", +" .Xo. ... ", +" .Xoo. ..oo. ", +" .Xooo.Xooo... ", +" .Xooo.oooo.X. ", +" .Xooo.Xooo.X. ", +" .Xooo.oooo.X. ", +" .Xooo.Xooo.X. ", +" .Xooo.oooo.X. ", +" .Xoo.Xoo..X. ", +" .Xo.o..ooX. ", +" .X..XXXXX. ", +" ..X....... ", +" .. ", +" " +] + +$book_closed_xpm = [ +"16 16 6 1", +" c None s None", +". c black", +"X c red", +"o c yellow", +"O c #808080", +"# c white", +" ", +" .. ", +" ..XX. ", +" ..XXXXX. ", +" ..XXXXXXXX. ", +".ooXXXXXXXXX. ", +"..ooXXXXXXXXX. ", +".X.ooXXXXXXXXX. ", +".XX.ooXXXXXX.. ", +" .XX.ooXXX..#O ", +" .XX.oo..##OO. ", +" .XX..##OO.. ", +" .X.#OO.. ", +" ..O.. ", +" .. ", +" " +] + +class NotebookSample < SampleWindow + def initialize + super("notebook") + + vbox = Gtk::VBox.new(false, 0) + add(vbox) + + @notebook = Gtk::Notebook.new + @notebook.signal_connect("switch_page") do |widget, page, num_page| + unless destroyed? + page_switch(widget, page, num_page) + end + end + @notebook.tab_pos = Gtk::POS_TOP + vbox.add(@notebook) + @notebook.border_width = 10 + + @notebook.realize + + @book_open, @book_open_mask = + Gdk::Pixmap::create_from_xpm_d(@notebook.window, nil, $book_open_xpm) + @book_closed, @book_closed_mask = + Gdk::Pixmap::create_from_xpm_d(@notebook.window, nil, $book_closed_xpm) + + create_pages(1, 5) + + vbox.add(Gtk::HSeparator.new) + + cbutton1 = Gtk::CheckButton.new("popup menu") + vbox.add(cbutton1) + cbutton1.signal_connect("clicked"){ + @notebook.enable_popup = cbutton1.active? + } + + hbox = Gtk::HBox.new(false, 5) + hbox.border_width = 10 + vbox.pack_start(hbox, false, false, 0) + + label = Gtk::Label.new("Notebook Style :") + hbox.add(label) + + omenu = build_option_menu([ + OptionMenuItem.new("Standard", proc { standard_notebook }), + OptionMenuItem.new("No tabs", proc { notabs_notebook }), + OptionMenuItem.new("Scrollable", proc { scrollable_notebook }) ], 0) + + hbox.add(omenu) + + button = Gtk::Button.new("Show all Pages") + + hbox.add(button) + button.signal_connect('clicked'){ + @notebook.each do |w| + w.show + end + } + + hbox = Gtk::HBox.new(true, 10) + hbox.set_border_width(10) + vbox.pack_start(hbox, false, true, 0) + + button = Gtk::Button.new("prev") + button.signal_connect("clicked"){ + @notebook.prev_page + } + hbox.pack_start(button, true, true, 0) + + button = Gtk::Button.new("next") + button.signal_connect("clicked"){ + @notebook.next_page + } + hbox.pack_start(button, true, true, 0) + + button = Gtk::Button.new("rotate") + button.signal_connect("clicked"){ + @notebook.tab_pos = (@notebook.tab_pos.to_i + 1) % 4 + } + hbox.pack_start(button, true, true, 0) + + vbox.add(Gtk::HSeparator.new) + + button = Gtk::Button.new("close") + button.signal_connect("clicked"){destroy} + + vbox.pack_start(button, false, false, 5) + + button.can_default = true + button.grab_default + end + + def standard_notebook + @notebook.set_show_tabs(true) + @notebook.set_scrollable(false) + if @notebook.children.size == 15 + 10.times do + @notebook.remove_page(5) + end + end + end + + def notabs_notebook + @notebook.set_show_tabs(false) + if @notebook.children.size == 15 + 10.times do + @notebook.remove_page(5) + end + end + end + + def scrollable_notebook + @notebook.set_show_tabs(true) + @notebook.set_scrollable(true) + if @notebook.children.size == 5 + create_pages(6, 15) + end + end + + def create_pages(start_page, end_page) + start_page.upto(end_page) do |i| + buffer = "Page #{i}" + + child = Gtk::Frame.new(buffer) + child.border_width = 10 + + vbox = Gtk::VBox.new(true, 0) + vbox.border_width = 10 + child.add(vbox) + + hbox = Gtk::HBox.new(true, 0) + vbox.pack_start(hbox, false, true, 5) + + button1 = Gtk::CheckButton.new("Fill Tab") + hbox.pack_start(button1, true, true, 5) + button1.active = true + button1.signal_connect('toggled'){ + expand, fill, pack = @notebook.query_tab_label_packing(child) + @notebook.set_tab_label_packing(child, expand, button1.active?, pack) + } + + button2 = Gtk::CheckButton.new("Expand Tab") + hbox.pack_start(button2, true, true, 5) + button2.signal_connect('toggled'){ + expand, fill, pack = @notebook.query_tab_label_packing(child) + @notebook.set_tab_label_packing(child, button2.active?, fill, pack) + } + + button3 = Gtk::CheckButton.new("Pack end") + hbox.pack_start(button3, true, true, 5) + button3.signal_connect('toggled'){ + expand, fill, pack = @notebook.query_tab_label_packing(child) + @notebook.set_tab_label_packing(child, expand, fill, + if button3.active? then Gtk::PACK_END else Gtk::PACK_START end) + } + + button = Gtk::Button.new("Hide Page") + vbox.pack_end(button, false, false, 5) + button.signal_connect('clicked'){ + child.hide + } + + child.show_all + + label_box = Gtk::HBox.new(false, 0) + pixwid = Gtk::Image.new(@book_closed, @book_closed_mask) + label_box.pack_start(pixwid, false, true, 0) + pixwid.set_padding(3, 1) + label = Gtk::Label.new(buffer) + label_box.pack_start(label, false, true, 0) + label_box.show_all + + menu_box = Gtk::HBox.new(false, 0) + pixwid = Gtk::Image.new(@book_closed, @book_closed_mask) + menu_box.pack_start(pixwid, false, true, 0) + pixwid.set_padding(3, 1) + label = Gtk::Label.new(buffer) + menu_box.pack_start(label, false, true, 0) + menu_box.show_all + + @notebook.append_page_menu(child, label_box, menu_box) + end + end + + def set_page_pixmaps(notebook, page_num, pix, mask) + child = notebook.get_nth_page(page_num) + label = notebook.get_tab_label(child).children[0].set(pix, mask) + end + + def page_switch(notebook, page, page_num) + old_page_num = notebook.page + return if (page_num == old_page_num) + set_page_pixmaps(notebook, page_num, @book_open, @book_open_mask) + if (old_page_num != -1) + set_page_pixmaps(notebook, old_page_num, @book_closed, @book_closed_mask) + end + end +end + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/pixmap.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/pixmap.rb new file mode 100644 index 0000000..d02a94b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/pixmap.rb @@ -0,0 +1,58 @@ +=begin header + + pixmap.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + Rewritten by Hiroshi IGARASHI <igarashi@ueda.info.waseda.ac.jp> + $Date: 2005/07/18 17:13:32 $ + $Id: pixmap.rb,v 1.5 2005/07/18 17:13:32 mutoh Exp $ + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +require 'sample' + +class PixmapSample < SampleWindow + def initialize + super("pixmap") + + vbox = Gtk::VBox.new(false, 0) + add(vbox) + + button = Gtk::Button.new + vbox.pack_start(button, false, false, 10) + + label = Gtk::Label.new("Pixmap\ntest") + boxbutton = Gtk::HBox.new(false, 0) + boxbutton.border_width = 2 + boxbutton.add(Gtk::Image.new("test.xpm")) + boxbutton.add(label) + button.add(boxbutton) + + vbox.add(Gtk::HSeparator.new) + + button = Gtk::Button.new("close") + button.signal_connect("clicked"){destroy} + vbox.pack_start(button, false, false, 10) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/progressbar.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/progressbar.rb new file mode 100644 index 0000000..c1dab06 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/progressbar.rb @@ -0,0 +1,181 @@ +=begin header + + progressbar.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + $Id: progressbar.rb,v 1.9 2005/07/18 17:13:32 mutoh Exp $ + + Rewritten by Minoru Inachi <inachi@earth.interq.or.jp> + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +require 'sample' + +class ProgressBarSample < SampleDialog + + def initialize + super("Gtk::ProgressBar") + set_border_width(10) + + vbox1 = Gtk::VBox.new(false, 5) + vbox1.border_width = 10 + vbox.add(vbox1) + + frame = Gtk::Frame.new("Progress") + vbox1.add(frame) + + vbox2 = Gtk::VBox.new(false, 5) + frame.add(vbox2) + + align = Gtk::Alignment.new(0.5, 0.5, 0, 0) + vbox2.pack_start(align, FALSE, FALSE, 5) + + @pbar = Gtk::ProgressBar.new + align.add(@pbar) + @timer = Gtk.timeout_add(100){progress_timeout} + + align = Gtk::Alignment.new(0.5, 0.5, 0, 0) + vbox2.pack_start(align, false, false, 5); + + hbox = Gtk::HBox.new(false, 5) + align.add(hbox) + label = Gtk::Label.new("Label updated by user :") + hbox.add(label) + @label = Gtk::Label.new("") + hbox.add(@label) + + frame = Gtk::Frame.new("Options") + vbox1.add(frame) + + vbox2 = Gtk::VBox.new(false, 5) + frame.add(vbox2) + + tab = Gtk::Table.new(3, 2, false) + vbox2.add(tab) + + label = Gtk::Label.new("Orientation :"); + tab.attach(label, 0, 1, 0, 1, + Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, + 5, 5) + label.set_alignment(0, 0.5) + + @omenu1 = build_option_menu( + [ OptionMenuItem.new("Left-Right", proc { |w| toggle_orientation(w) }), + OptionMenuItem.new("Right-Left", proc { |w| toggle_orientation(w) }), + OptionMenuItem.new("Bottom-Top", proc { |w| toggle_orientation(w) }), + OptionMenuItem.new("Top-Bottom", proc { |w| toggle_orientation(w) }) + ], 0) + hbox = Gtk::HBox.new(false, 0) + tab.attach(hbox, 1, 2, 0, 1, + Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, + 5, 5); + hbox.add(@omenu1) + + check = Gtk::CheckButton.new("Show text") + check.signal_connect("clicked") do |w| toggle_show_text(w) end + tab.attach(check, 0, 1, 1, 2, + Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, + 5, 5) + + hbox = Gtk::HBox.new(false, 0) + tab.attach(hbox, 1, 2, 1, 2, + Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, + 5, 5) + + label = Gtk::Label.new("Text align :") + tab.attach(label, 0, 1, 2, 3, + Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, + 5, 5) + label.set_alignment(0, 0.5) + + hbox = Gtk::HBox.new(false, 0) + tab.attach(hbox, 1, 2, 2, 3, + Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, + 5, 5) + + label = Gtk::Label.new("x :") + hbox.pack_start(label, false, true, 5) + + adj = Gtk::Adjustment.new(0.5, 0, 1, 0.1, 0.1, 0) + @x_align_spin = Gtk::SpinButton.new(adj, 0, 1) + adj.signal_connect("value_changed"){adjust_align} + hbox.pack_start(@x_align_spin, false, true, 0) + @x_align_spin.sensitive = false + + label = Gtk::Label.new("y :") + hbox.pack_start(label, false, true, 5) + + adj = Gtk::Adjustment.new(0.5, 0, 1, 0.1, 0.1, 0) + @y_align_spin = Gtk::SpinButton.new(adj, 0, 1) + adj.signal_connect("value_changed"){adjust_align} + hbox.pack_start(@y_align_spin, false, true, 0) + @y_align_spin.sensitive = false + + button = Gtk::Button.new("close") + button.signal_connect("clicked"){ + Gtk::timeout_remove(@timer) + destroy + } + button.can_default = true + self.action_area.add(button) + button.grab_default + end + + private + def toggle_orientation(rmitem) + return unless rmitem.mapped? + + i = 3 + group = rmitem.group + group.each do |g| + break if g.active? + i -= 1 + end + + @pbar.orientation = i + end + + private + def progress_timeout + new_val = @pbar.fraction + 0.05 + new_val = 0.0 if new_val > 1.0 + @pbar.fraction = new_val + @label.text = "#{(new_val * 100).to_i}" + true + end + + private + def toggle_show_text(cbutton) + @pbar.show_text = cbutton.active? + @x_align_spin.sensitive = cbutton.active? + @y_align_spin.sensitive = cbutton.active? + end + + private + def adjust_align + @pbar.text_xalign = @x_align_spin.value + @pbar.text_yalign = @y_align_spin.value + end + +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/radiobutton.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/radiobutton.rb new file mode 100644 index 0000000..5ca6b2b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/radiobutton.rb @@ -0,0 +1,61 @@ +=begin header + + radiobutton.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + Rewritten by Hiroshi IGARASHI <igarashi@ueda.info.waseda.ac.jp> + $Date: 2005/07/18 17:13:32 $ + $Id: radiobutton.rb,v 1.7 2005/07/18 17:13:32 mutoh Exp $ + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +require 'sample' + +class RadioButtonSample < SampleWindow + def initialize + super("radio buttons") + set_border_width(10) + + vbox = Gtk::VBox.new(false, 10) + add(vbox) + + button1 = Gtk::RadioButton.new("button1") + vbox.add(button1) + + button2 = Gtk::RadioButton.new(button1, "button2") + vbox.add(button2) + + button3 = Gtk::RadioButton.new(button1, "button3") + vbox.add(button3) + + vbox.add(Gtk::HSeparator.new) + + button = Gtk::Button.new("close") + button.signal_connect("clicked"){destroy} + vbox.pack_start(button, false, true) + + button.can_default = true + button.grab_default + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/range.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/range.rb new file mode 100644 index 0000000..a24e390 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/range.rb @@ -0,0 +1,65 @@ +=begin header + + range.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + $Id: range.rb,v 1.6 2005/07/18 17:13:32 mutoh Exp $ + + Rewritten by TAKAHASHI Hitoshi <thitoshi@ne.scphys.kyoto-u.ac.jp> + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +require 'sample' + +class RangeSample < SampleWindow + def initialize + super("range controls") + + vbox = Gtk::VBox.new(false, 10) + add(vbox) + + adjustment = Gtk::Adjustment.new(0.0, 0.0, 101.0, 0.1, 1.0, 1.0) + + scale = Gtk::HScale.new(adjustment) + scale.set_size_request(150, 50) + scale.update_policy = Gtk::UPDATE_DELAYED + scale.digits = 1 + scale.draw_value = true + + vbox.add(scale) + + scrollbar = Gtk::HScrollbar.new(adjustment) + scrollbar.update_policy = Gtk::UPDATE_CONTINUOUS + vbox.add(scrollbar) + + vbox.add(Gtk::HSeparator.new) + + button = Gtk::Button.new("close") + button.signal_connect("clicked"){destroy} + + vbox.pack_start(button, true, true, 0) + button.can_default = true + button.grab_default + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/reparent.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/reparent.rb new file mode 100644 index 0000000..56c8def --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/reparent.rb @@ -0,0 +1,91 @@ +=begin header + + reparent.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + $Id: reparent.rb,v 1.6 2005/07/18 17:13:33 mutoh Exp $ + + Rewritten by TAKAHASHI Hitoshi <thitoshi@ne.scphys.kyoto-u.ac.jp> + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +require 'sample' + +class ReparentSample < SampleWindow + def initialize + super("reparent") + + vbox = Gtk::VBox.new(false, 0) + add(vbox) + + box2 = Gtk::HBox.new(false, 5) + box2.set_border_width(10) + vbox.pack_start(box2, true, true, 0) + + label = Gtk::Label.new("Hello World") + + frame = Gtk::Frame.new("Frame 1") + box2.pack_start(frame, true, true, 0) + + framebox1 = Gtk::VBox.new(false, 5) + framebox1.border_width = 5 + frame.add(framebox1) + + button = Gtk::Button.new("switch") + button.signal_connect("clicked"){ + label.reparent(framebox1) + } + framebox1.pack_start(button, false, true, 0) + + framebox1.add(label) + label.signal_connect("parent_set"){ |child, old_parent| + puts "set_parent for \"#{child.class}\":" + puts " new parent: \"#{if child.parent then child.parent.class else 'NULL' end}\"," + puts " old parent: \"#{if old_parent then old_parent.class else 'NULL' end}\"," + puts " data: 42\n" + } + + frame = Gtk::Frame.new("Frame 2") + box2.pack_start(frame, true, true, 0) + + framebox2 = Gtk::VBox.new(false, 5) + framebox2.border_width = 5 + frame.add(framebox2) + + button = Gtk::Button.new("switch") + button.signal_connect("clicked"){ + label.reparent(framebox2) + } + framebox2.pack_start(button, false, true, 0) + + vbox.pack_start(Gtk::HSeparator.new, false, true) + + button = Gtk::Button.new("close") + button.signal_connect("clicked"){destroy} + + vbox.pack_start(button, false, true, 10) + button.can_default = true + button.grab_default + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/rulers.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/rulers.rb new file mode 100644 index 0000000..9a37c6e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/rulers.rb @@ -0,0 +1,46 @@ +=begin header + + rulers.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + $Id: rulers.rb,v 1.9 2005/07/18 17:13:33 mutoh Exp $ + +=end + +require 'sample' + +class RulerSample < SampleWindow + def initialize + super("rulers") + + set_default_size(300, 300) + + set_events(Gdk::Event::POINTER_MOTION_MASK | + Gdk::Event::POINTER_MOTION_HINT_MASK) + + table = Gtk::Table.new(2, 2, false) + add(table) + + hruler = Gtk::HRuler.new + hruler.metric = Gtk::CENTIMETERS + hruler.set_range(100, 0, 0, 20) + + vruler = Gtk::VRuler.new + vruler.set_range(5, 15, 0, 20) + + signal_connect("motion_notify_event"){ |w, e| + vruler.signal_emit("motion_notify_event", e) + } + + table.attach(hruler, 1, 2, 0, 1, + Gtk::EXPAND | Gtk::FILL, Gtk::FILL, 0, 0) + + signal_connect("motion_notify_event"){ |w, e| + hruler.signal_emit("motion_notify_event", e) + } + + table.attach(vruler, 0, 1, 1, 2, + Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/sample.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/sample.rb new file mode 100644 index 0000000..c4e2021 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/sample.rb @@ -0,0 +1,80 @@ +=begin header + + sample.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + $Id: sample.rb,v 1.9 2005/07/21 17:47:19 mutoh Exp $ + +=end + +require 'gtk2' + +module Sample + def destroy + super + @destroyed = true + end + def destroyed? + @destroyed + end +end + +module SampleClass + def invoke + @singleton = nil unless defined? @singleton + @singleton = new if @singleton.nil? or @singleton.destroyed? + unless @singleton.visible? + @singleton.show_all + else + @singleton.destroy + end + end +end + +class SampleWindow < Gtk::Window + include Sample + extend SampleClass + + def initialize(title) + super(title) + @destroyed = false + signal_connect("destroy") do destroy end + end +end + +class SampleDialog < Gtk::Dialog + include Sample + extend SampleClass + + def initialize(title) + super(title) + @destroyed = false + signal_connect("destroy") do destroy end + end +end + +OptionMenuItem = Struct.new("OptionMenuItem", :name, :block) + +def build_option_menu(items, history) + omenu = Gtk::OptionMenu.new + + menu = Gtk::Menu.new + group = nil + + items.size.times do |i| + menu_item = Gtk::RadioMenuItem.new(group, items[i].name) + menu_item.signal_connect("activate") do |widget| + items[i].block.call(widget) + end + group = menu_item.group + menu.append(menu_item) + menu_item.active = true if i == history + menu_item.show + end + + omenu.menu = menu + omenu.history = history + + omenu +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/savedposition.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/savedposition.rb new file mode 100644 index 0000000..4e737be --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/savedposition.rb @@ -0,0 +1,87 @@ +=begin + + savedposition.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + $Id: savedposition.rb,v 1.7 2005/07/21 17:47:19 mutoh Exp $ + + Rewritten by TAKAHASHI Hitoshi <thitoshi@ne.scphys.kyoto-u.ac.jp> + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +require 'sample' + +class SavedPositionSample < SampleWindow + Pos = [ 0, 0 ] + + def initialize + super("Saved Position") + move(Pos[0], Pos[1]) + set_default_size(200, 100) + set_border_width = 5 + + vbox = Gtk::VBox.new + add(vbox) + + hbox1 = Gtk::HBox.new + hbox1.border_width = 5 + vbox.add(hbox1) + + label = Gtk::Label.new("X Origin : ") + label.set_alignment(0, 0.5) + hbox1.add(label) + + x_label = Gtk::Label.new("") + hbox1.add(x_label) + + hbox2 = Gtk::HBox.new + hbox2.set_border_width(5) + vbox.add(hbox2) + + label = Gtk::Label.new("Y Origin : ") + label.set_alignment(0, 0.5) + hbox2.add(label) + + y_label = Gtk::Label.new("") + hbox2.add(y_label) + + signal_connect("configure_event") do + x, y = window.root_origin + Pos[0] = x + Pos[1] = y + x_label.text = x.to_s + y_label.text = y.to_s + false + end + + vbox.pack_start(Gtk::HSeparator.new, false, true, 10) + + button = Gtk::Button.new("Close") + button.signal_connect("clicked"){destroy} + + vbox.add(button) + button.can_default = true + button.grab_default + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/scrolledwindow.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/scrolledwindow.rb new file mode 100644 index 0000000..b140d72 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/scrolledwindow.rb @@ -0,0 +1,67 @@ +=begin header + + scrolledwindow.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + Rewritten by Hiroshi IGARASHI <igarashi@ueda.info.waseda.ac.jp> + $Date: 2005/07/21 17:47:19 $ + $Id: scrolledwindow.rb,v 1.7 2005/07/21 17:47:19 mutoh Exp $ + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +require 'sample' + +class ScrolledWindowSample < SampleDialog + def initialize + super("dialog") + + scrolled_window = Gtk::ScrolledWindow.new + scrolled_window.border_width = 10 + scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, + Gtk::POLICY_AUTOMATIC) + vbox.add(scrolled_window) + + table = Gtk::Table.new(20, 20, false) + table.row_spacings = 10 + table.column_spacings = 10 + scrolled_window.add_with_viewport(table) + + table.focus_hadjustment = scrolled_window.hadjustment + table.focus_vadjustment = scrolled_window.vadjustment + + for i in 0..19 + for j in 0..19 + buffer = "button (#{i},#{j})" + button = Gtk::ToggleButton.new(buffer) + table.attach(button, i, i + 1, j, j + 1) + end + end + + button = Gtk::Button.new("close") + button.signal_connect("clicked"){destroy} + action_area.pack_start(button, true, true, 0) + + set_default_size(300, 300) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/shapedwindow.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/shapedwindow.rb new file mode 100644 index 0000000..cf6395d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/shapedwindow.rb @@ -0,0 +1,99 @@ +=begin header + + shapedwindow.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + $Id: shapedwindow.rb,v 1.7 2005/07/21 17:47:19 mutoh Exp $ + +=end + +require 'sample' + +class ShapeSampleBasic < Gtk::Window + include Sample + extend SampleClass + + @@root_win = nil + + def initialize(xpm_file, x, y, px, py, type) + super(type) + @destroyed = false + signal_connect("destroy"){destroy} + + realize + + @@root_win = Gdk::Window.default_root_window unless @@root_win + + window.set_events(window.events | Gdk::Event::BUTTON_MOTION_MASK | + Gdk::Event::POINTER_MOTION_HINT_MASK | + Gdk::Event::BUTTON_PRESS_MASK) + + signal_connect("button_press_event") do |w, event| + if (event.event_type == Gdk::Event::BUTTON_PRESS) + @x = event.x + @y = event.y + Gtk.grab_add(self) + Gdk.pointer_grab(window, true, + Gdk::Event::BUTTON_RELEASE_MASK | + Gdk::Event::BUTTON_MOTION_MASK | + Gdk::Event::POINTER_MOTION_HINT_MASK, + nil, nil, 0) + end + end + signal_connect("button_release_event") do + Gtk.grab_remove(self) + Gdk.pointer_ungrab(0) + end + signal_connect("motion_notify_event") do + xp, yp, mask = @@root_win.pointer + move(xp - @x, yp - @y) + end + + move(x, y) + + style = Gtk::Widget.default_style + + fixed = Gtk::Fixed.new + fixed.set_size_request(100, 100) + add(fixed) + + gdk_pixmap, gdk_pixmap_mask = + Gdk::Pixmap::create_from_xpm(window, + style.bg(Gtk::STATE_NORMAL), + xpm_file) + pixmap = Gtk::Image.new(gdk_pixmap, gdk_pixmap_mask) + + fixed.put(pixmap, px, py) + + shape_combine_mask(gdk_pixmap_mask, px, py) + end +end + +class ShapeSampleModeller < ShapeSampleBasic + def initialize + super("Modeller.xpm", 440, 140, 0, 0, Gtk::Window::POPUP) + end +end + +class ShapeSampleSheets < ShapeSampleBasic + def initialize + super("FilesQueue.xpm", 580, 170, 0, 0, Gtk::Window::POPUP) + end +end + +class ShapeSampleRings < ShapeSampleBasic + def initialize + super("3DRings.xpm", 460, 270, 25, 25, Gtk::Window::TOPLEVEL) + end +end + + +ShapesSample = Class.new +class << ShapesSample + def invoke + ShapeSampleModeller.invoke + ShapeSampleSheets.invoke + ShapeSampleRings.invoke + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/spinbutton.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/spinbutton.rb new file mode 100644 index 0000000..e120446 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/spinbutton.rb @@ -0,0 +1,181 @@ +=begin header + + spinbutton.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + $Id: spinbutton.rb,v 1.7 2005/07/30 10:24:57 mutoh Exp $ + + Rewritten by Hiroshi IGARASHI <igarashi@ueda.info.waseda.ac.jp> + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +require 'sample' + +class SpinButtonSample < SampleWindow + + def get_value(spin, label, data) + if (data == 1) + buf = sprintf("%d", spin.value_as_int) + else + buf = sprintf("%0.*f", spin.digits, spin.value) + end + label.text = buf + end + + def initialize + super("Gtk::SpinButton") + + main_vbox = Gtk::VBox.new(false, 5) + main_vbox.set_border_width(10) + add(main_vbox) + + frame = Gtk::Frame.new("Not accelerated") + main_vbox.pack_start(frame, true, true, 0) + + vbox = Gtk::VBox.new(false, 0) + vbox.set_border_width(5) + frame.add(vbox) + + # Day, month, year spinners + + hbox = Gtk::HBox.new(false, 0) + vbox.pack_start(hbox, true, true, 5) + + vbox2 = Gtk::VBox.new(false, 0) + hbox.pack_start(vbox2, true, true, 5) + + label = Gtk::Label.new("Day :") + label.set_alignment(0, 0.5) + vbox2.pack_start(label, false, true, 0) + + adj = Gtk::Adjustment.new(1.0, 1.0, 31.0, 1.0, 5.0, 0.0) + spinner = Gtk::SpinButton.new(adj, 0, 0) + spinner.wrap = true + vbox2.pack_start(spinner, false, true, 0) + + vbox2 = Gtk::VBox.new(false, 0) + hbox.pack_start(vbox2, true, true, 5) + + label = Gtk::Label.new("Month :") + label.set_alignment(0, 0.5) + vbox2.pack_start(label, false, true, 0) + + adj = Gtk::Adjustment.new(1.0, 1.0, 12.0, 1.0, 5.0, 0.0) + spinner = Gtk::SpinButton.new(adj, 0, 0) + spinner.wrap = true + vbox2.pack_start(spinner, false, true, 0) + + vbox2 = Gtk::VBox.new(false, 0) + hbox.pack_start(vbox2, true, true, 5) + + label = Gtk::Label.new("Year :") + label.set_alignment(0, 0.5) + vbox2.pack_start(label, false, true, 0) + + adj = Gtk::Adjustment.new(1998.0, 0.0, 2100.0, 1.0, 100.0, 0.0) + spinner = Gtk::SpinButton.new(adj, 0, 0) + spinner.wrap = true + spinner.set_size_request(55, -1) + vbox2.pack_start(spinner, false, true, 0) + + frame = Gtk::Frame.new("Accelerated") + main_vbox.pack_start(frame, true, true, 0) + + vbox = Gtk::VBox.new(false, 0) + vbox.set_border_width(5) + frame.add(vbox) + + hbox = Gtk::HBox.new(false, 0) + vbox.pack_start(hbox, false, true, 5) + + vbox2 = Gtk::VBox.new(false, 0) + hbox.pack_start(vbox2, true, true, 5) + + label = Gtk::Label.new("Value :") + label.set_alignment(0, 0.5) + vbox2.pack_start(label, false, true, 0) + + adj = Gtk::Adjustment.new(0.0, -10000.0, 10000.0, 0.5, 100.0, 0.0) + spinner1 = Gtk::SpinButton.new(adj, 1.0, 2) + spinner1.set_wrap(true) + spinner1.set_size_request(100, -1) + spinner1.set_update_policy(Gtk::SpinButton::UPDATE_ALWAYS) + vbox2.pack_start(spinner1, false, true, 0) + + vbox2 = Gtk::VBox.new(false, 0) + hbox.pack_start(vbox2, true, true, 5) + + label = Gtk::Label.new("Digits :") + label.set_alignment(0, 0.5) + vbox2.pack_start(label, false, true, 0) + + adj = Gtk::Adjustment.new(2, 1, 5, 1, 1, 0) + spinner2 = Gtk::SpinButton.new(adj, 0.0, 0) + spinner2.wrap = true + adj.signal_connect("value_changed"){ + spinner1.digits = spinner2.value_as_int + } + vbox2.pack_start(spinner2, false, true, 0) + + hbox = Gtk::HBox.new(false, 0) + vbox.pack_start(hbox, false, true, 5) + + button = Gtk::CheckButton.new("Snap to 0.5-ticks") + button.signal_connect("clicked"){ + spinner1.snap_to_ticks = button.active? + } + vbox.pack_start(button, true, true, 0) + button.set_active(true) + + button2 = Gtk::CheckButton.new("Numeric only input mode") + button2.signal_connect("clicked"){ + spinner1.numeric = button2.active? + } + vbox.pack_start(button2, true, true, 0) + button2.active = true + + val_label = Gtk::Label.new("") + + hbox = Gtk::HBox.new(false, 0) + vbox.pack_start(hbox, false, true, 5) + + button3 = Gtk::Button.new("Value as Int") + button3.signal_connect("clicked"){get_value(spinner1, val_label, 1)} + hbox.pack_start(button3, true, true, 5) + + button4 = Gtk::Button.new("Value as Float") + button4.signal_connect("clicked"){get_value(spinner1, val_label, 2)} + hbox.pack_start(button4, true, true, 5) + + vbox.pack_start(val_label, true, true, 0) + val_label.text = "0" + + hbox = Gtk::HBox.new(false, 0) + main_vbox.pack_start(hbox, false, true, 0) + + button5 = Gtk::Button.new("Close") + button5.signal_connect("clicked"){destroy} + hbox.pack_start(button5, true, true, 5) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/statusbar.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/statusbar.rb new file mode 100644 index 0000000..a9e218e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/statusbar.rb @@ -0,0 +1,89 @@ +=begin header + + statusbar.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + Rewritten by Hiroshi IGARASHI <igarashi@ueda.info.waseda.ac.jp> + $Date: 2005/07/21 17:47:19 $ + $Id: statusbar.rb,v 1.6 2005/07/21 17:47:19 mutoh Exp $ + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +require 'sample' + +class StatusbarSample < SampleWindow + def initialize + super("statusbar") + + set_border_width(5) + + @counter = 1 + + vbox = Gtk::VBox.new(false, 5) + add(vbox) + + statusbar = Gtk::Statusbar.new + + vbox.pack_end(statusbar, true, true, 0) + statusbar.signal_connect("text_popped"){|o, mid, text| + @counter = 1 if text + puts "poped" + } + statusbar.signal_connect("text_pushed"){|o, mid, text| + # do nothing... as of gtk 1.2.6 + puts "pushed" + } + + button_push = Gtk::Button.new("push something") + vbox.add(button_push) + button_push.signal_connect("clicked"){ + @counter += 1 + statusbar.push(1, "something #{@counter}") + } + + button_pop = Gtk::Button.new("pop") + vbox.add(button_pop) + button_pop.signal_connect("clicked"){ + statusbar.pop(1) + } + button_steal = Gtk::Button.new("steal #4") + vbox.add(button_steal) + button_steal.signal_connect("clicked"){ + statusbar.remove(1, 4) + } + button_context = Gtk::Button.new("test contexts") + vbox.add(button_context) + button_context.signal_connect("clicked"){ + ["any context", "idle messages", "some text", + "hit the mouse", "hit the mouse2"].each do |str| + puts "Gtk::StatusBar: context=\"#{str}\", context_id=#{statusbar.get_context_id(str)}" + end + } + vbox.add(Gtk::HSeparator.new) + + button_close = Gtk::Button.new("close") + button_close.signal_connect("clicked"){destroy} + vbox.add(button_close) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/test.xpm b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/test.xpm new file mode 100644 index 0000000..9b0d2ef --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/test.xpm @@ -0,0 +1,92 @@ +/* XPM */ +static char *openfile[] = { +/* width height num_colors chars_per_pixel */ +" 20 19 66 2", +/* colors */ +".. c None", +".# c #000000", +".a c #dfdfdf", +".b c #7f7f7f", +".c c #006f6f", +".d c #00efef", +".e c #009f9f", +".f c #004040", +".g c #00bfbf", +".h c #ff0000", +".i c #ffffff", +".j c #7f0000", +".k c #007070", +".l c #00ffff", +".m c #00a0a0", +".n c #004f4f", +".o c #00cfcf", +".p c #8f8f8f", +".q c #6f6f6f", +".r c #a0a0a0", +".s c #7f7f00", +".t c #007f7f", +".u c #5f5f5f", +".v c #707070", +".w c #00f0f0", +".x c #009090", +".y c #ffff00", +".z c #0000ff", +".A c #00afaf", +".B c #00d0d0", +".C c #00dfdf", +".D c #005f5f", +".E c #00b0b0", +".F c #001010", +".G c #00c0c0", +".H c #000f0f", +".I c #00007f", +".J c #005050", +".K c #002f2f", +".L c #dfcfcf", +".M c #dfd0d0", +".N c #006060", +".O c #00e0e0", +".P c #00ff00", +".Q c #002020", +".R c #dfc0c0", +".S c #008080", +".T c #001f1f", +".U c #003f3f", +".V c #007f00", +".W c #00000f", +".X c #000010", +".Y c #00001f", +".Z c #000020", +".0 c #00002f", +".1 c #000030", +".2 c #00003f", +".3 c #000040", +".4 c #00004f", +".5 c #000050", +".6 c #00005f", +".7 c #000060", +".8 c #00006f", +".9 c #000070", +"#. c #7f7f80", +"## c #9f9f9f", +/* pixels */ +"........................................", +"........................................", +"........................................", +".......................#.#.#............", +".....................#.......#...#......", +"...............................#.#......", +".......#.#.#.................#.#.#......", +".....#.y.i.y.#.#.#.#.#.#.#..............", +".....#.i.y.i.y.i.y.i.y.i.#..............", +".....#.y.i.y.i.y.i.y.i.y.#..............", +".....#.i.y.i.y.#.#.#.#.#.#.#.#.#.#.#....", +".....#.y.i.y.#.s.s.s.s.s.s.s.s.s.#......", +".....#.i.y.#.s.s.s.s.s.s.s.s.s.#........", +".....#.y.#.s.s.s.s.s.s.s.s.s.#..........", +".....#.#.s.s.s.s.s.s.s.s.s.#............", +".....#.#.#.#.#.#.#.#.#.#.#..............", +"........................................", +"........................................", +"........................................" +}; diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/testgtk.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/testgtk.rb new file mode 100644 index 0000000..c037a6b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/testgtk.rb @@ -0,0 +1,181 @@ +#!/usr/bin/env ruby + +=begin header + + testgtk.rb - testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2006 Ruby-GNOME2 Project Team + + $Id: testgtk.rb,v 1.16 2006/06/17 13:18:12 mutoh Exp $ + + Rewritten by Hiroshi IGARASHI <igarashi@ueda.info.waseda.ac.jp> + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +$:.unshift(File.dirname(__FILE__)) + +require 'gtk2' +require 'sample' +require 'button' +require 'checkbutton' +require 'togglebutton' +require 'radiobutton' +require 'buttonbox' +require 'toolbar' +require 'statusbar' +require 'reparent' +require 'pixmap' +require 'tooltips' +require 'labels' +require 'layout' +require 'menu' +require 'scrolledwindow' +require 'entry' +require 'spinbutton' +require 'colorselect' +require 'dialog' +require 'range' +require 'rulers' +require 'notebook' +require 'shapedwindow' +require 'wmhints' +require 'progressbar' +require 'gammacurve' +require 'savedposition' +require 'filesel' +require 'fontselection' + +# +# Main Window +# +def create_main_window + buttons = [ + ["button box", ButtonBoxSample], + ["buttons", ButtonSample], + ["check buttons", CheckButtonSample], + ["color selection", ColorSelectionSample], + ["dialog", DialogSample], + ["entry", EntrySample], + ["file selection", FileSelectionSample], + ["font selection", FontSelectionSample], + ["gamma curve", GammaCurveSample], + ["labels", LabelSample], + ["layout", LayoutSample], + ["menus", MenuSample], + ["notebook", NotebookSample], + ["pixmap", PixmapSample], + ["progress bar", ProgressBarSample], + ["radio buttons", RadioButtonSample], + ["range controls", RangeSample], + ["reparent", ReparentSample], + ["rulers", RulerSample], + ["saved position", SavedPositionSample], + ["scrolled windows", ScrolledWindowSample], + ["shapes", ShapesSample], + ["spinbutton", SpinButtonSample], + ["statusbar", StatusbarSample], + ["toggle buttons", ToggleButtonSample], + ["toolbar", ToolbarSample], + ["tooltips", TooltipsSample], + ["WM hints", WMHintsSample], + ] + nbuttons = buttons.size + + window = Gtk::Window.new + window.name = "main window" + + window.set_default_size(200, 400) + window.move(20, 20) + + window.signal_connect("destroy"){Gtk.main_quit} + + box1 = Gtk::VBox.new(false, 0) + window.add(box1) + + label = Gtk::Label.new("Gtk+ v#{Gtk::MAJOR_VERSION}.#{Gtk::MINOR_VERSION}.#{Gtk::MICRO_VERSION}") + box1.pack_start(label, false, false, 0) + + label = Gtk::Label.new("Ruby/GTK2 v#{Gtk::BINDING_VERSION.join(".")}") + box1.pack_start(label, false, false, 0) + + scrolled_window = Gtk::ScrolledWindow.new(nil, nil) + scrolled_window.border_width = 10 + scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, + Gtk::POLICY_AUTOMATIC) + box1.pack_start(scrolled_window, true, true, 0) + + box2 = Gtk::VBox.new(false, 0) + box2.border_width = 10 + scrolled_window.add_with_viewport(box2); + box2.focus_vadjustment = scrolled_window.vadjustment + + buttons.each do |title, sample_class| + button = Gtk::Button.new(title) + unless sample_class.nil? + button.signal_connect("clicked"){|obj| + sample_class.invoke + } + else + button.sensitive = false + end + box2.pack_start(button, true, true, 0) + end + + box1.pack_start(Gtk::HSeparator.new, false, true, 0) + + button = Gtk::Button.new("close") + button.signal_connect("clicked") do + window.destroy + Gtk.main_quit + end + box1.pack_start(button, false, true, 5) + window.show_all +end + +def main + srand + Gtk::RC.parse("testgtkrc") + create_main_window + Gtk.main +end + +if $DEBUG + $stderr.sync = true + Thread.start do + loop do + STDERR.print("+") + GC.start + sleep(1) + end + end + $stderr.puts("#{$0}: started GC-thread for debugging.") + + # timeout + Gtk.timeout_add(1000) do + $stderr.print("*") + true + end +end + +main +puts("#{$0}: done.") diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/testgtkrc b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/testgtkrc new file mode 100644 index 0000000..19b3539 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/testgtkrc @@ -0,0 +1,146 @@ +# pixmap_path "<dir 1>:<dir 2>:<dir 3>:..." +# +# include "rc-file" +# +# style <name> [= <name>] +# { +# <option> +# } +# +# widget <widget_set> style <style_name> +# widget_class <widget_class_set> style <style_name> + +# testgtkrc2 sets all the buttons in the main window to blue by default +include "testgtkrc2" + +#include "/usr/local/share/themes/Pixmap/gtk/gtkrc" +#include "/usr/local/share/themes/Redmond95/gtk/gtkrc" +#include "/usr/local/share/themes/Metal/gtk/gtkrc" +#include "/usr/local/share/themes/Notif/gtk/gtkrc" +#include "/usr/local/share/themes/Default/gtk/gtkrc" + +#pixmap_path "." + +style "defaultfont" +{ +# fontset = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*,*" + font = "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*,*" +} + +# common default +class "GtkWidget" style "defaultfont" + +style "window" +{ +# bg_pixmap[NORMAL] = "marble.xpm" +} + +style "scale" +{ + fg[NORMAL] = { 1.0, 0, 0 } + bg_pixmap[NORMAL] = "<parent>" +} + +style "button" = "default" +{ +# fg[PRELIGHT] = { 1.0, 1.0, 1.0 } +# bg[PRELIGHT] = { 0, 0, 0.75 } +# bg[PRELIGHT] = { 0.75, 0, 0x00 } +} + +style "toggle_button" = "button" +{ + fg[NORMAL] = { 1.0, 0, 0 } + fg[ACTIVE] = { 1.0, 0, 0 } +# bg_pixmap[ACTIVE] = "check-y.xpm" +# bg_pixmap[NORMAL] = "check-n.xpm" +} + +style "text" +{ + bg_pixmap[NORMAL] = "marble.xpm" + text[NORMAL] = { 1.0, 1.0, 1.0 } + fg[NORMAL] = { 1.0, 1.0, 1.0 } + base[NORMAL] = { 0.0, 0.0, 0.0 } +} + +style "slider" +{ + fg[NORMAL] = { 1.0, 1.0, 1.0 } + bg[NORMAL] = { 0.0, 0.0, 1.0 } + bg[ACTIVE] = { 0.0 ,0.0, 0.5 } + bg[PRELIGHT] = { 0.75 ,0.75, 1.0 } +} + +style "ruler" +{ + font = '-adobe-helvetica-medium-r-normal--*-80-*-*-*-*-*-*' +} + +style "curve" +{ + fg[NORMAL] = { 58000, 0, 0 } # red +} + +style "red-bar" +{ + bg[PRELIGHT] = { 0.95, .55, 0.55 } +} + +# override testgtk2, introduce the green color in the button list +style 'button_list' = 'button' +{ + font = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*" + bg[PRELIGHT] = { 0, 0.75, 0x00 } +} +widget "main window.*GtkScrolledWindow.*GtkButton*" style "button_list" + + +class "GtkScrollbar" style "red-bar" + +widget_class "GtkWindow" style "window" +widget_class "GtkDialog" style "window" +widget_class "GtkFileSelection" style "window" +widget_class "*Gtk*Scale" style "scale" +widget_class "*GtkCheckButton*" style "toggle_button" +widget_class "*GtkRadioButton*" style "toggle_button" +widget_class "*GtkButton*" style "button" +widget_class "*Ruler" style "ruler" +widget_class "*GtkText" style "text" +widget "*GtkCurve" style "curve" + +binding "test1" +{ + bind "<ctrl>1" { + "debug-msg" ("jup!") + } +} + +binding "test2" +{ + bind "<ctrl>1" { + "debug-msg" ("hallo and") + "debug-msg" ("huhu") + } +} + +# possible priorities are (in ascending order): +# lowest +# gtk (used by gtk for internal class bindings) +# application (for hard coded bindings on application basis) +# rc (used implicitel by rc files) +# highest +class "GtkCList" binding "test1" # implicit : rc +#class "GtkWindow" binding : highest "test2" # override "rc" priority + +binding "clist-test" +{ + bind "j" { + "scroll-vertical" (step-backward, 0.0) + } + bind "k" { + "scroll-vertical" (step-forward, 0.0) + } +} + +class "GtkCList" binding "clist-test" diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/testgtkrc2 b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/testgtkrc2 new file mode 100644 index 0000000..71d2891 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/testgtkrc2 @@ -0,0 +1,21 @@ +# pixmap_path "<dir 1>:<dir 2>:<dir 3>:..." +# +# include "rc-file" +# +# style <name> [= <name>] +# { +# <option> +# } +# +# widget <widget_set> style <style_name> +# widget_class <widget_class_set> style <style_name> + +# this file gets included from testgtkrc + +style 'main_buttons' = 'button' +{ + font = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*" + bg[PRELIGHT] = { 0, 0, 0.75 } +} + +widget "main window.*GtkButton*" style "main_buttons" diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/togglebutton.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/togglebutton.rb new file mode 100644 index 0000000..4eb6c33 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/togglebutton.rb @@ -0,0 +1,53 @@ +=begin header + + togglebutton.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + Rewritten by Hiroshi IGARASHI <igarashi@ueda.info.waseda.ac.jp> + $Date: 2005/07/21 17:47:19 $ + $Id: togglebutton.rb,v 1.6 2005/07/21 17:47:19 mutoh Exp $ + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +require 'sample' + +class ToggleButtonSample < SampleWindow + def initialize + super("toggle buttons") + + set_border_width(5) + + vbox = Gtk::VBox.new(false, 5) + add(vbox) + + (1..3).each do |i| + vbox.add(Gtk::ToggleButton.new("button#{i}")) + end + vbox.pack_start(Gtk::HSeparator.new, false, true, 0) + + button = Gtk::Button.new("close") + button.signal_connect("clicked"){destroy} + vbox.add(button) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/toolbar.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/toolbar.rb new file mode 100644 index 0000000..0f6c26b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/toolbar.rb @@ -0,0 +1,82 @@ +=begin header + + toolbar.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + Rewritten by Hiroshi IGARASHI <igarashi@ueda.info.waseda.ac.jp> + $Id: toolbar.rb,v 1.7 2005/07/21 17:47:19 mutoh Exp $ + +Original Copyright: + + GTK - The GIMP Toolkit + Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + + 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 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +=end + +require 'sample' + +class ToolbarSample < SampleWindow + def initialize + super("Toolbar test") + + toolbar = Gtk::Toolbar.new + + toolbar.append("Horizontal", "Horizontal toolbar layout", + "Toolbar/Horizontal", Gtk::Image.new("test.xpm")){ + toolbar.orientation = Gtk::ORIENTATION_HORIZONTAL + } + toolbar.append("Vertical", "Vertical toolbar layout", + "Toolbar/Vertical", Gtk::Image.new("test.xpm")){ + toolbar.orientation = Gtk::ORIENTATION_VERTICAL + } + + toolbar.append_space + + toolbar.append("Icons", "Only show toolbar icons", + "Toolbar/IconsOnly", Gtk::Image.new("test.xpm")){ + toolbar.toolbar_style = Gtk::Toolbar::ICONS + } + toolbar.append("Text", "Only show toolbar text", "Toolbar/TextOnly", + Gtk::Image.new("test.xpm")){ + toolbar.toolbar_style = Gtk::Toolbar::TEXT + } + toolbar.append("Both", "Show toolbar icons and text", "Toolbar/Both", + Gtk::Image.new("test.xpm")){ + toolbar.toolbar_style = Gtk::Toolbar::BOTH + } + + toolbar.append_space + + toolbar.append(Gtk::Entry.new, "This is an unusable Gtk::Entry ;)", + "Hey don't click me!!!") + + toolbar.append_space + + toolbar.append("Enable", "Enable tooltips", nil, + Gtk::Image.new("test.xpm")){ + toolbar.tooltips = true + } + toolbar.append("Disable", "Disable tooltips", nil, + Gtk::Image.new("test.xpm")){ + toolbar.tooltips = false + } + + add(toolbar) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/tooltips.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/tooltips.rb new file mode 100644 index 0000000..c8482d8 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/tooltips.rb @@ -0,0 +1,41 @@ +=begin + + tooltips.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + $Id: tooltips.rb,v 1.6 2005/07/21 17:47:19 mutoh Exp $ + +=end + +require 'sample' + +class TooltipsSample < SampleWindow + def initialize + super("Tooltips") + set_default_size(200, -1) + set_border_width(5) + + tooltips = Gtk::Tooltips.new + + button = Gtk::ToggleButton.new("button1") + tooltips.set_tip(button,"This is button 1", "ContextHelp/buttons/1") + + button2 = Gtk::ToggleButton.new("button2") + tooltips.set_tip(button2, + "This is button 2. This is also a really long tooltip which probably won't fit on a single line and will therefore need to be wrapped. Hopefully the wrapping will work correctly.", + "ContextHelp/buttons/2_long") + vbox = Gtk::VBox.new(false, 10) + vbox.add(button) + vbox.add(button2) + vbox.add(Gtk::HSeparator.new) + + button4 = Gtk::Button.new("close") + button4.signal_connect("clicked"){destroy} + vbox.pack_start(button4) + + tooltips.set_tip(button4, "Push this button to close window", "ContextHelp/buttons/Close") + + add(vbox) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/wmhints.rb b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/wmhints.rb new file mode 100644 index 0000000..f79e2c1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/sample/testgtk/wmhints.rb @@ -0,0 +1,40 @@ +=begin header + + wmhints.rb - a part of testgtk.c rewritten in Ruby/GTK2 + + Copyright (C) 2002-2005 Ruby-GNOME2 Project Team + + $Id: wmhints.rb,v 1.8 2005/07/21 17:47:19 mutoh Exp $ +=end + +require 'sample' + +class WMHintsSample < SampleWindow + def initialize + super("WM Hints") + + realize + + circles = Gdk::Pixmap.create_from_xbm(window, "circles.xbm") + window.set_icon(nil, circles, circles) + window.icon_name = "WMHints Test Icon" + window.decorations = Gdk::Window::DECOR_ALL | Gdk::Window::DECOR_MENU + window.functions = Gdk::Window::FUNC_ALL | Gdk::Window::FUNC_RESIZE + + vbox = Gtk::VBox.new(false, 10) + add(vbox) + + label = Gtk::Label.new("Try iconizing me!") + label.set_size_request(150, 50) + vbox.pack_start(label, true, true, 0) + + vbox.pack_start(Gtk::HSeparator.new, false, true, 0) + + button = Gtk::Button.new("close") + button.signal_connect("clicked"){destroy} + + vbox.pack_start(button, true, true, 0) + button.can_default = true + button.grab_default + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/gtk-test-utils.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/gtk-test-utils.rb new file mode 100644 index 0000000..22b1f87 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/gtk-test-utils.rb @@ -0,0 +1,15 @@ +require 'tempfile' + +module GtkTestUtils + private + def only_gtk_version(major, minor, micro=nil) + micro ||= 0 + unless Gtk.check_version?(major, minor, micro) + omit("Require GTK+ >= #{major}.#{minor}.#{micro}") + end + end + + def only_x11 + omit("Only for X11 backend") unless Gdk.windowing_x11? + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/run-test.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/run-test.rb new file mode 100755 index 0000000..05e5c59 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/run-test.rb @@ -0,0 +1,32 @@ +#!/usr/bin/env ruby + +ruby_gnome2_base = File.join(File.dirname(__FILE__), "..", "..") +ruby_gnome2_base = File.expand_path(ruby_gnome2_base) + +glib_base = File.join(ruby_gnome2_base, "glib2") +atk_base = File.join(ruby_gnome2_base, "atk") +pango_base = File.join(ruby_gnome2_base, "pango") +gdk_pixbuf_base = File.join(ruby_gnome2_base, "gdk_pixbuf2") +gtk_base = File.join(ruby_gnome2_base, "gtk2") + +[[glib_base, "glib2"], + [atk_base, "atk"], + [pango_base, "pango"], + [gdk_pixbuf_base, "gdk_pixbuf2"], + [gtk_base, "gtk2"]].each do |target, module_name| + if system("which make > /dev/null") + `make -C #{target.dump} > /dev/null` or exit(false) + end + $LOAD_PATH.unshift(File.join(target, "ext", module_name)) + $LOAD_PATH.unshift(File.join(target, "lib")) +end + +$LOAD_PATH.unshift(File.join(glib_base, "test")) +require 'glib-test-init' + +$LOAD_PATH.unshift(File.join(gtk_base, "test")) +require 'gtk-test-utils' + +require 'gtk2' + +exit Test::Unit::AutoRunner.run(true) diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gc.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gc.rb new file mode 100644 index 0000000..490a234 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gc.rb @@ -0,0 +1,25 @@ +require 'test/unit' +require 'gtk2' + +class TestGC < Test::Unit::TestCase + priority :must + def test_closure + 10.times do + invisible = Gtk::Invisible.new + invisible.signal_connect("destroy") {} + GC.start + end + end + + def test_inheritance_and_gc + button = Class.new(Gtk::Button) + box = Gtk::HBox.new + n = 10 + n.times do + box.add(button.new) + end + GC.start + assert_equal([button] * 10, + box.children.collect {|item| item.class}) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk.rb new file mode 100644 index 0000000..5b8761b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk.rb @@ -0,0 +1,18 @@ +class TestGdk < Test::Unit::TestCase + include GtkTestUtils + + def test_notify_startup_complete + assert_nothing_raised do + Gdk.notify_startup_complete + end + + notify_with_id = Proc.new do + Gdk.notify_startup_complete("startup-id") + end + if Gtk.check_version?(2, 12, 0) + assert_nothing_raised(¬ify_with_id) + else + assert_raise(NotImplementedError, ¬ify_with_id) + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_color.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_color.rb new file mode 100644 index 0000000..88cc7b1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_color.rb @@ -0,0 +1,10 @@ +class TestGdkColor < Test::Unit::TestCase + def test_to_s + color = Gdk::Color.new(0xffff, 0x1234, 0xabcd) + if Gtk.check_version?(2, 12, 0) + assert_equal("#ffff1234abcd", color.to_s) + else + assert_match(/\A#<Gdk::Color:.*>\z/, color.to_s) + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_display.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_display.rb new file mode 100644 index 0000000..9ac095e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_display.rb @@ -0,0 +1,37 @@ +class TestGdkDisplay < Test::Unit::TestCase + include GtkTestUtils + + def test_supports_predicates + display = Gdk::Display.default + + assert_boolean(display.supports_shapes?) + assert_boolean(display.supports_input_shapes?) + only_gtk_version(2, 12, 0) + assert_boolean(display.supports_composite?) + end + + def test_startup_notification_id + only_gtk_version(2, 12, 0) + only_x11 + + display = Gdk::Display.default + assert_nil(display.startup_notification_id) + end + + def test_broadcast_startup_message + omit("Not yet implemented (GNOME bug #528020)") + only_gtk_version(2, 16, 0) + only_x11 + + id = "#{$$}_TIME_#{Time.now.to_i}" + screen = Gdk::Screen.default.number.to_s + assert_nothing_raised do + Gdk::Display.default.broadcast_startup_message("new", + "ID" => id, + "NAME" => "Hello World", + "SCREEN" => screen) + Gdk::Display.default.broadcast_startup_message("remove", + "ID" => id) + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_event.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_event.rb new file mode 100644 index 0000000..c86ce36 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_event.rb @@ -0,0 +1,11 @@ +class TestGdkEvent < Test::Unit::TestCase + include GtkTestUtils + + def test_motion_request + only_gtk_version(2, 12, 0) + motion = Gdk::EventMotion.new + assert_nothing_raised do + motion.request + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_gc.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_gc.rb new file mode 100644 index 0000000..051b310 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_gc.rb @@ -0,0 +1,7 @@ +class TestGdkGC < Test::Unit::TestCase + include GtkTestUtils + + def test_constant + assert_const_defined(Gdk, :GC) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_geometry.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_geometry.rb new file mode 100644 index 0000000..087dbbf --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_geometry.rb @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestGdkGeometry < Test::Unit::TestCase + def test_min_width + geometry = Gdk::Geometry.new + assert_equal(0, geometry.min_width) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_keymap.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_keymap.rb new file mode 100644 index 0000000..d0f9b00 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_keymap.rb @@ -0,0 +1,8 @@ +class TestGdkKeymap < Test::Unit::TestCase + include GtkTestUtils + + def test_have_bidi_layouts? + only_gtk_version(2, 12, 0) + assert_boolean(Gdk::Keymap.default.have_bidi_layouts?) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_pango.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_pango.rb new file mode 100644 index 0000000..9c85a6f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_pango.rb @@ -0,0 +1,9 @@ +class TestGdkPango < Test::Unit::TestCase + include GtkTestUtils + + def test_emboss_color_attribute + only_gtk_version(2, 12, 0) + color = Gdk::PangoAttrEmbossColor.new(Gdk::Color.parse("red")) + assert_equal([65535, 0, 0], color.value.to_a) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_rectangle.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_rectangle.rb new file mode 100644 index 0000000..8c0548e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_rectangle.rb @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestGdkRectangle < Test::Unit::TestCase + def test_width + rectangle = Gdk::Rectangle.new(0, 10, 20, 30) + assert_equal(20, rectangle.width) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_selection_data.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_selection_data.rb new file mode 100644 index 0000000..628e070 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_selection_data.rb @@ -0,0 +1,17 @@ +class TestSelectionData < Test::Unit::TestCase + def setup + @window = Gtk::Invisible.new.window + end + + def test_type_integer + name = "ID" + value = 10 + Gdk::Property.change(@window, name, + Gdk::Selection::TYPE_INTEGER, + :replace, value) + assert_equal([Gdk::Selection::TYPE_INTEGER, [value]], + Gdk::Property.get(@window, name, + Gdk::Selection::TYPE_INTEGER, + false)[0, 2]) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_window.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_window.rb new file mode 100644 index 0000000..87ce518 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_window.rb @@ -0,0 +1,29 @@ +class TestGdkWindow < Test::Unit::TestCase + include GtkTestUtils + + def setup + @window = Gtk::Invisible.new.window + end + + def test_set_composited + only_gtk_version(2, 12, 0) + assert_nothing_raised do + @window.composited = false + end + end + + def test_set_opacity + only_gtk_version(2, 12, 0) + assert_nothing_raised do + @window.opacity = 0.5 + end + end + + def test_set_startup_id + only_gtk_version(2, 12, 0) + assert_nothing_raised do + @window.startup_id = "startup-id" + @window.startup_id = nil + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_window_attribute.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_window_attribute.rb new file mode 100644 index 0000000..adf701b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gdk_window_attribute.rb @@ -0,0 +1,9 @@ +class TestGtkWindowAttribute < Test::Unit::TestCase + include GtkTestUtils + + def test_initialize + attrs = Gdk::WindowAttr.new(100, 100, :only, :temp) + assert_equal([100, 100, Gdk::Window::INPUT_ONLY, Gdk::Window::TEMP], + [attrs.width, attrs.height, attrs.wclass, attrs.window_type]) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_about_dialog.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_about_dialog.rb new file mode 100644 index 0000000..a8c3c74 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_about_dialog.rb @@ -0,0 +1,14 @@ +class TestGtkAboutDialog < Test::Unit::TestCase + include GtkTestUtils + + def setup + @dialog = Gtk::AboutDialog.new + end + + def test_program_name + only_gtk_version(2, 12, 0) + assert_equal(File.basename($0), @dialog.program_name) + @dialog.program_name = "my-program" + assert_equal("my-program", @dialog.program_name) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_accel_group_entry.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_accel_group_entry.rb new file mode 100644 index 0000000..920e1e9 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_accel_group_entry.rb @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestGtkAccelGroupEntry < Test::Unit::TestCase + def test_accel_path + entry = Gtk::AccelGroupEntry.new + assert_nil(entry.accel_path) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_accel_key.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_accel_key.rb new file mode 100644 index 0000000..b9077fc --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_accel_key.rb @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestGtkAccelKey < Test::Unit::TestCase + def test_flags + key = Gtk::AccelKey.new + assert_equal(0, key.flags) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_allocation.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_allocation.rb new file mode 100644 index 0000000..ed60dc4 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_allocation.rb @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestGtkAllocation < Test::Unit::TestCase + def test_width + allocation = Gtk::Allocation.new(0, 10, 20, 30) + assert_equal(20, allocation.width) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_border.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_border.rb new file mode 100644 index 0000000..886067f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_border.rb @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestGtkBorder < Test::Unit::TestCase + def test_left + border = Gtk::Border.new(10, 15, 20, 25) + assert_equal(10, border.left) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_buildable.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_buildable.rb new file mode 100644 index 0000000..cd3a25c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_buildable.rb @@ -0,0 +1,66 @@ +class TestGtkBuildable < Test::Unit::TestCase + include GtkTestUtils + + def setup + @buildable = Gtk::HBox.new + end + + def test_name + only_gtk_version(2, 12, 0) + + assert_equal("", @buildable.name) + @buildable.name = "YYY" + assert_equal("YYY", @buildable.name) + + @buildable.name = nil + assert_equal("", @buildable.name) + end + + def test_add_child + only_gtk_version(2, 12, 0) + + assert_equal([], @buildable.children) + + builder = Gtk::Builder.new + entry = Gtk::Entry.new + @buildable.add_child(builder, entry) + assert_equal([entry], @buildable.children) + end + + def test_set_buildable_property + only_gtk_version(2, 12, 0) + + assert_nil(@buildable.parent) + + builder = Gtk::Builder.new + parent = Gtk::HBox.new + @buildable.set_buildable_property(builder, "parent", parent) + assert_equal(parent, @buildable.parent) + end + + def test_construct_child + only_gtk_version(2, 12, 0) + + assert_nil(@buildable.parent) + + @buildable = Gtk::UIManager.new + @buildable.add_ui(<<-EOU) +<ui> + <toolbar name='Toolbar'> + </toolbar> +</ui> +EOU + builder = Gtk::Builder.new + assert_kind_of(Gtk::Toolbar, @buildable.construct_child(builder, "Toolbar")) + end + + def test_get_internal_child + only_gtk_version(2, 12, 0) + + assert_nil(@buildable.parent) + + @buildable = Gtk::Dialog.new + builder = Gtk::Builder.new + assert_kind_of(Gtk::VBox, @buildable.get_internal_child(builder, "vbox")) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_builder.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_builder.rb new file mode 100644 index 0000000..a36d8fa --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_builder.rb @@ -0,0 +1,188 @@ +class TestGtkBuilder < Test::Unit::TestCase + include GtkTestUtils + + def test_constants + only_gtk_version(2, 12, 0) + assert_kind_of(Gtk::BuilderError, Gtk::BuilderError::INVALID_TAG) + end + + def test_new + only_gtk_version(2, 12, 0) + assert_nothing_raised do + Gtk::Builder.new + end + end + + def test_add_from_file + only_gtk_version(2, 12, 0) + + builder = Gtk::Builder.new + assert_nothing_raised do + builder.add_from_file(ui_definition_file.path) + end + assert_kind_of(Gtk::Dialog, builder["dialog1"]) + end + + def test_add_from_string + only_gtk_version(2, 12, 0) + + builder = Gtk::Builder.new + assert_nothing_raised do + builder.add_from_string(ui_definition) + end + assert_kind_of(Gtk::VBox, builder["vbox1"]) + end + + def test_add_with_file + only_gtk_version(2, 12, 0) + + builder = Gtk::Builder.new + assert_nothing_raised do + builder.add(ui_definition_file.path) + end + assert_kind_of(Gtk::HButtonBox, builder["hbuttonbox1"]) + end + + def test_add_with_string + only_gtk_version(2, 12, 0) + + builder = Gtk::Builder.new + assert_nothing_raised do + builder.add(ui_definition) + end + assert_kind_of(Gtk::Button, builder["ok_button"]) + end + + def test_add_chain + only_gtk_version(2, 12, 0) + + builder = Gtk::Builder.new + assert_nothing_raised do + builder << ui_definition_file.path << ui_definition_simple + end + assert_kind_of(Gtk::Dialog, builder["dialog1"]) + assert_kind_of(Gtk::Window, builder["main-window"]) + end + + def test_objects + only_gtk_version(2, 12, 0) + + builder = Gtk::Builder.new + assert_nothing_raised do + builder << ui_definition_file.path << ui_definition_simple + end + assert_equal(["dialog1", "vbox1", "hbuttonbox1", "ok_button", + "main-window"].sort, + builder.objects.collect {|object| object.builder_name}.sort) + end + + def test_translation_domain + only_gtk_version(2, 12, 0) + + builder = Gtk::Builder.new + assert_nil(builder.translation_domain) + builder.translation_domain = "ruby-gnome2" + assert_equal("ruby-gnome2", builder.translation_domain) + end + + def test_connect_signals + only_gtk_version(2, 12, 0) + + handler_names = [] + + builder = Gtk::Builder.new + builder.connect_signals do |name| + handler_names << name + Proc.new {} + end + assert_equal([].sort, handler_names.sort) + + builder << ui_definition + ok_button = builder["ok_button"] + builder.connect_signals do |name| + handler_names << name + Proc.new {} + end + assert_equal(["ok_button_clicked"].sort, handler_names.sort) + end + + def test_connect_signals_with_no_signal_ui_definition + only_gtk_version(2, 12, 0) + + handler_names = [] + + builder = Gtk::Builder.new + builder.connect_signals do |name| + handler_names << name + Proc.new {} + end + assert_equal([].sort, handler_names.sort) + + builder << ui_definition_simple + builder.connect_signals do |name| + handler_names << name + Proc.new {} + end + assert_equal([].sort, handler_names.sort) + end + + def test_get_type_from_name + only_gtk_version(2, 12, 0) + + builder = Gtk::Builder.new + assert_nil(builder.get_type("XXX")) + assert_equal(Gtk::VBox, builder.get_type("GtkVBox")) + end + + private + def ui_definition + <<-EOX +<interface> + <object class="GtkDialog" id="dialog1"> + <child internal-child="vbox"> + <object class="GtkVBox" id="vbox1"> + <property name="border-width">10</property> + <child internal-child="action_area"> + <object class="GtkHButtonBox" id="hbuttonbox1"> + <property name="border-width">20</property> + <child> + <object class="GtkButton" id="ok_button"> + <property name="label">gtk-ok</property> + <property name="use-stock">TRUE</property> + <signal name="clicked" handler="ok_button_clicked"/> + </object> + </child> + </object> + </child> + </object> + </child> + </object> +</interface> +EOX + end + + def ui_definition_simple + <<-EOX +<interface> + <object class="GtkWindow" id="main-window"> + </object> +</interface> +EOX + end + + def ui_definition_with_signal + <<-EOX +<interface> + <object class="GtkWindow" id="main-window"> + </object> +</interface> +EOX + end + + def ui_definition_file + xml = Tempfile.new("Gtk::Builder") + xml.print(ui_definition) + xml.close + xml + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_entry.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_entry.rb new file mode 100644 index 0000000..1d14893 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_entry.rb @@ -0,0 +1,18 @@ +class TestGtkEntry < Test::Unit::TestCase + include GtkTestUtils + + def setup + @entry = Gtk::Entry.new + end + + def test_cursor_hadjustment + only_gtk_version(2, 12) + + assert_nil(@entry.cursor_hadjustment) + adjustment = Gtk::Adjustment.new(0.0, 0.0, + 100.0, 100.0, + 1.0, 1.0) + @entry.cursor_hadjustment = adjustment + assert_equal(adjustment, @entry.cursor_hadjustment) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_icon_theme.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_icon_theme.rb new file mode 100644 index 0000000..b7b1906 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_icon_theme.rb @@ -0,0 +1,30 @@ +class TestGtkIconTheme < Test::Unit::TestCase + include GtkTestUtils + + def setup + @theme = Gtk::IconTheme.default + end + + def test_choose_icon + only_gtk_version(2, 12) + + assert_nil(@theme.choose_icon("non-existent", 100)) + + icon = @theme.choose_icon("undo", 10) + assert_not_nil(icon) + assert_match(/undo/, icon.filename) + + assert_not_nil(@theme.choose_icon("undo", 29, [:use_builtin, :no_svg])) + end + + def test_contexts + only_gtk_version(2, 12) + + assert_operator(@theme.contexts, :include?, "MimeTypes") + end + + def test_icons + assert_operator(@theme.icons, :include?, "undo") + assert_operator(@theme.icons("Actions"), :include?, "remove") + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_image.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_image.rb new file mode 100644 index 0000000..193d617 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_image.rb @@ -0,0 +1,8 @@ +class TestGtkImage < Test::Unit::TestCase + include GtkTestUtils + + def test_stock + image = Gtk::Image.new(Gtk::Stock::GO_FORWARD, Gtk::IconSize::DIALOG) + assert_equal(Gtk::Stock::GO_FORWARD, image.stock) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_list_store.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_list_store.rb new file mode 100644 index 0000000..e195afe --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_list_store.rb @@ -0,0 +1,92 @@ +class TestGtkListStore < Test::Unit::TestCase + include GtkTestUtils + + ID = 0 + NAME = 1 + + COLUMNS = { + ID => Integer, + NAME => String, + } + + def setup + columns = COLUMNS.keys.sort.collect do |key| + COLUMNS[key] + end + @store = Gtk::ListStore.new(*columns) + end + + def test_set_values + only_gtk_version(2, 12) + + iter = @store.append + assert_nothing_raised do + @store.set_values(iter, [0, '1']) + end + assert_equal([0, '1'], [iter[0], iter[1]]) + + iter = @store.append + assert_nothing_raised do + @store.set_values(iter, [2, '3']) + end + assert_equal([2, '3'], [iter[0], iter[1]]) + + assert_nothing_raised do + @store.set_values(iter, []) + end + assert_equal([2, '3'], [iter[0], iter[1]]) + end + + def test_set_values_with_hash + only_gtk_version(2, 12) + + iter = @store.append + assert_nothing_raised do + @store.set_values(iter, {ID => 0, NAME => 'me'}) + end + assert_equal([0, 'me'], [iter[ID], iter[NAME]]) + + iter = @store.append + assert_nothing_raised do + @store.set_values(iter, {NAME => 'you', ID => 2}) + end + assert_equal([2, 'you'], [iter[ID], iter[NAME]]) + + assert_nothing_raised do + @store.set_values(iter, {NAME => "she"}) + end + assert_equal([2, 'she'], [iter[ID], iter[NAME]]) + + assert_nothing_raised do + @store.set_values(iter, {}) + end + assert_equal([2, 'she'], [iter[ID], iter[NAME]]) + end + + def test_iter_gc + n_iterators = count_objects(Gtk::TreeIter) + 50.times do |i| + iter = @store.append + iter[ID] = i + iter[NAME] = i.to_s + end + 100.times do + @store.iter_first + end + iter = @store.iter_first + while @store.remove(iter); end + iter = nil + assert_equal(0, @store.to_enum(:each).to_a.size) + GC.start + assert_equal(n_iterators, count_objects(Gtk::TreeIter)) + end + + private + def count_objects(klass) + n_objects = ObjectSpace.each_object(Gtk::TreeIter) do + # do nothing + end + n_objects + end +end + diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_menu_item.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_menu_item.rb new file mode 100644 index 0000000..b942fb0 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_menu_item.rb @@ -0,0 +1,13 @@ +class TestGtkMenuItem < Test::Unit::TestCase + include GtkTestUtils + + def test_new_with_label + item = Gtk::MenuItem.new("Label") + assert_equal("Label", item.label) + end + + def test_new_with_nil_label + item = Gtk::MenuItem.new(nil) + assert_equal("", item.label) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_rc_style.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_rc_style.rb new file mode 100644 index 0000000..8dcc173 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_rc_style.rb @@ -0,0 +1,14 @@ +class TestGtkRcStyle < Test::Unit::TestCase + include GtkTestUtils + + def setup + @style = Gtk::RcStyle.new + end + + def test_color_flags + assert_equal(Gtk::RC::Flags.new, @style.color_flags(:normal)) + @style.set_color_flags(:normal, [:fg, :bg]) + assert_equal(Gtk::RC::Flags::FG | Gtk::RC::Flags::BG, + @style.color_flags(:normal)) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_recent_data.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_recent_data.rb new file mode 100644 index 0000000..d66d130 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_recent_data.rb @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestGtkRecentData < Test::Unit::TestCase + def test_mime_type + data = Gtk::RecentData.new + assert_nil(data.mime_type) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_recent_filter_info.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_recent_filter_info.rb new file mode 100644 index 0000000..0e28edb --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_recent_filter_info.rb @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestGtkRecentFilterInfo < Test::Unit::TestCase + include GtkTestUtils + + def test_contains + info = Gtk::RecentFilterInfo.new + assert_equal(Gtk::RecentFilter::Flags.new, info.contains) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_tree_path.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_tree_path.rb new file mode 100644 index 0000000..958abb4 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_tree_path.rb @@ -0,0 +1,20 @@ +class TestGtkTreePath < Test::Unit::TestCase + include GtkTestUtils + + def test_compare + assert_equal(-1, tree_path("0") <=> tree_path("1")) + assert_equal(0, tree_path("0") <=> tree_path("0")) + assert_equal(1, tree_path("1") <=> tree_path("0")) + end + + def test_equal + assert_equal(tree_path("0"), tree_path("0")) + assert_not_equal(tree_path("0"), tree_path("1")) + assert_not_equal(tree_path("0"), "0") + end + + private + def tree_path(path) + Gtk::TreePath.new(path) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_unix_print.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_unix_print.rb new file mode 100644 index 0000000..8a58f48 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_unix_print.rb @@ -0,0 +1,14 @@ +class TestGtkUnixPrint < Test::Unit::TestCase + def test_classes + if GLib.os_unix? + assertion = :assert_const_defined + else + assertion = :assert_not_const_defined + end + send(assertion, Gtk, :PageSetupUnixDialog) + send(assertion, Gtk, :Printer) + send(assertion, Gtk, :PrintCapabilities) + send(assertion, Gtk, :PrintJob) + send(assertion, Gtk, :PrintUnixDialog) + end +end diff --git a/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_widget.rb b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_widget.rb new file mode 100644 index 0000000..34af7e5 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/gtk2/test/test_gtk_widget.rb @@ -0,0 +1,32 @@ +class TestGtkWidget < Test::Unit::TestCase + include GtkTestUtils + + def setup + @widget = Gtk::Invisible.new + end + + def test_set_window + attrs = Gdk::WindowAttr.new(100, 100, :only, :temp) + window = Gdk::Window.new(nil, attrs, 0) + @widget.window = window + assert_equal(window, @widget.window) + end + + def test_modify_color_component_with_nil_color + assert_nothing_raised do + @widget.modify_base(:normal, nil) + end + + assert_nothing_raised do + @widget.modify_text(:normal, nil) + end + + assert_nothing_raised do + @widget.modify_fg(:normal, nil) + end + + assert_nothing_raised do + @widget.modify_bg(:normal, nil) + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/pango/COPYING.LIB b/lib/ruby-gtk2-2.0.2/pango/COPYING.LIB new file mode 100644 index 0000000..b1e3f5a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/COPYING.LIB @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. + + GNU LESSER GENERAL PUBLIC LICENSE + 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 + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + <one line to give the library's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + <signature of Ty Coon>, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/lib/ruby-gtk2-2.0.2/pango/README b/lib/ruby-gtk2-2.0.2/pango/README new file mode 100644 index 0000000..814fd40 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/README @@ -0,0 +1,33 @@ +Ruby/Pango +========== +Ruby/Pango is a Ruby binding of pango-1.x. + +Requirements +------------ + Ruby: http://www.ruby-lang.org/ + GLib: http://www.gtk.org/ + Pango: http://www.pango.org/ + cairo/rcairo: http://cairographics.org/ (optional) + Ruby/GLib2: http://ruby-gnome2.sourceforge.net/ + +Install +------- + 0. install ruby-1.6.x or later, GLib, Pango, Ruby/GLib2, Ruby/GTK2 + (and cairo/rcairo). + 1. ruby extconf.rb + (To use rcairo on Win32, set CAIRO_PATH as a environment variable first) + 2. make + 3. su + 4. make install + +Copying +------- + Copyright (c) 2002-2005 Ruby-GNOME2 Project Team + + This program is free software. + You can distribute/modify this program under the terms of + the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. + +Project Website +--------------- + http://ruby-gnome2.sourceforge.jp/ diff --git a/lib/ruby-gtk2-2.0.2/pango/Rakefile b/lib/ruby-gtk2-2.0.2/pango/Rakefile new file mode 100644 index 0000000..dfbee19 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/Rakefile @@ -0,0 +1,61 @@ +# -*- ruby -*- + +$LOAD_PATH.unshift("./../glib2/lib") +require "gnome2/rake/package-task" + +package_task = GNOME2::Rake::PackageTask.new do |package| + package.summary = "Ruby/Pango is a Ruby binding of pango-1.x." + package.description = "Ruby/Pango is a Ruby binding of pango-1.x." + package.dependency.gem.runtime = [["cairo", ">= 1.12.5"], "glib2"] + package.windows.packages = [] + package.windows.dependencies = [] + package.windows.build_dependencies = ["glib2", "gobject-introspection"] + package.external_packages = [ + { + :name => "harfbuzz", + :download_base_url => "http://www.freedesktop.org/software/harfbuzz/release", + :label => "HarfBuzz", + :version => "0.9.17", + :compression_method => "bz2", + :windows => { + :patches => [ + "harfbuzz-0.9.17-disable-uniscribe.diff", + ], + :need_autoreconf => true, + }, + }, + { + :name => "pango", + :download_site => :gnome, + :label => "pango", + :version => "1.34.1", + :compression_method => "xz", + :windows => { + :configure_args => [ + "--enable-introspection", + ], + :patches => [ + "pango-1.34.0-enable-fc-font.diff", + ], + }, + }, + ] +end +package_task.define + +namespace :gcc do + namespace :dll do + desc "Bundle GCC related DLLs" + task(:bundle) do + dlls = ["libgcc_s_sjlj-1.dll", "libstdc++-6.dll"] + dlls.each do |dll| + host = package_task.windows.build_host + binary_dir = package_task.windows.absolute_binary_dir + full_path = `#{host}-g++ -print-file-name=#{dll}`.strip + cp(full_path, (binary_dir + "bin").to_s) + end + end + end +end + +task "win32:builder:build:harfbuzz:after" => "gcc:dll:bundle" diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/depend b/lib/ruby-gtk2-2.0.2/pango/ext/pango/depend new file mode 100644 index 0000000..b818ee2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/depend @@ -0,0 +1,12 @@ +install-so: install-headers +install-headers: + $(INSTALL_DATA) $(srcdir)/rbpango.h $(RUBYARCHDIR) + $(INSTALL_DATA) $(srcdir)/rbpangoconversions.h $(RUBYARCHDIR) + $(INSTALL_DATA) rbpangoversion.h $(RUBYARCHDIR) + +install: install-pc +install-pc: + if test -n "$(pkgconfigdir)"; then \ + $(MAKEDIRS) $(pkgconfigdir); \ + $(INSTALL_DATA) ruby-pango.pc $(pkgconfigdir); \ + fi diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/extconf.rb b/lib/ruby-gtk2-2.0.2/pango/ext/pango/extconf.rb new file mode 100644 index 0000000..8d1b60d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/extconf.rb @@ -0,0 +1,102 @@ +=begin +extconf.rb for Ruby/Pango extention library +=end + +require 'pathname' + +base_dir = Pathname(__FILE__).dirname.parent.parent.expand_path +top_dir = base_dir.parent +top_build_dir = Pathname(".").parent.parent.parent.expand_path + +mkmf_gnome2_dir = top_dir + "glib2" + 'lib' +version_suffix = "" +unless mkmf_gnome2_dir.exist? + if /(-\d+\.\d+\.\d+)(?:\.\d+)?\z/ =~ base_dir.basename.to_s + version_suffix = $1 + mkmf_gnome2_dir = top_dir + "glib2#{version_suffix}" + 'lib' + end +end + +$LOAD_PATH.unshift(mkmf_gnome2_dir.to_s) + +module_name = "pango" +package_id = "pango" + +begin + require 'mkmf-gnome2' +rescue LoadError + require 'rubygems' + gem 'glib2' + require 'mkmf-gnome2' +end + +ruby_header = "ruby.h" +have_func("rb_errinfo", ruby_header) + +["glib2"].each do |package| + directory = "#{package}#{version_suffix}" + build_dir = "#{directory}/tmp/#{RUBY_PLATFORM}/#{package}/#{RUBY_VERSION}" + add_depend_package(package, "#{directory}/ext/#{package}", + top_dir.to_s, + :top_build_dir => top_build_dir.to_s, + :target_build_dir => build_dir) +end + +rcairo_options = {} +rcairo_source_dir_names = ["rcairo"] +if /mingw|cygwin|mswin/ =~ RUBY_PLATFORM + rcairo_source_dir_names.unshift("rcairo.win32") +end +rcairo_source_dir_names.each do |rcairo_source_dir_name| + rcairo_source_dir = top_dir.parent.expand_path + rcairo_source_dir_name + if rcairo_source_dir.exist? + rcairo_options[:rcairo_source_dir] = rcairo_source_dir.to_s + break + end +end +check_cairo(rcairo_options) + +setup_win32(module_name, base_dir) + +unless required_pkg_config_package(package_id, + :debian => "libpango1.0-dev", + :redhat => "pango-devel", + :homebrew => "pango", + :macports => "pango") + exit(false) +end +PKGConfig.have_package('pangocairo') + +if PKGConfig.have_package("pangowin32") + $defs << " -DHAVE_PANGO_WIN32" +end +if PKGConfig.have_package("pangoft2") + $defs << " -DHAVE_PANGO_FT2" +end + +pango_header = "pango/pango.h" +have_func("pango_layout_iter_get_type", pango_header) +have_func("pango_layout_set_ellipsize", pango_header) +have_func("pango_layout_get_font_description", pango_header) +have_func("pango_render_part_get_type", pango_header) +have_func("pango_attr_strikethrough_color_new", pango_header) +have_func("pango_attr_underline_color_new", pango_header) +have_func("pango_glyph_item_free", pango_header) +have_func("pango_glyph_item_get_type", pango_header) +have_func("pango_attr_iterator_get_attrs", pango_header) +have_func("pango_itemize_with_base_dir", pango_header) +have_func("pango_font_family_is_monospace", pango_header) + +make_version_header("PANGO", "pango", ".") + +create_pkg_config_file("Ruby/Pango", package_id) +$defs << " -DRUBY_PANGO_COMPILATION" +create_makefile(module_name) + +pkg_config_dir = with_config("pkg-config-dir") +if pkg_config_dir.is_a?(String) + File.open("Makefile", "ab") do |makefile| + makefile.puts + makefile.puts("pkgconfigdir=#{pkg_config_dir}") + end +end diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/pango.def b/lib/ruby-gtk2-2.0.2/pango/ext/pango/pango.def new file mode 100644 index 0000000..0eb7175 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/pango.def @@ -0,0 +1,18 @@ +EXPORTS + Init_pango + mPango DATA + attrstring DATA + pattr DATA + pattrbool DATA + pattrcolor DATA + pattrfloat DATA + pattrint DATA + pango_add_attribute + pango_attr_iter_get_type + pango_get_attribute + pango_get_attribute_klass + pango_item_get_type + pango_layout_iter_get_type + pango_layout_line_get_type + pango_make_attribute + pango_rectangle_get_type diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpango.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpango.c new file mode 100644 index 0000000..6189053 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpango.c @@ -0,0 +1,327 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE mPango + +VALUE RG_TARGET_NAMESPACE; + +extern void Init_pango(void); + +/* + * Rendering + */ + +struct rpango_reorder_items_args { + PangoItem *item; + VALUE ary; + long n; + GList *result; +}; + +static VALUE +rpango_reorder_items_body(VALUE value) +{ + struct rpango_reorder_items_args *args = (struct rpango_reorder_items_args *)value; + long i; + GList *result; + + for (i = 0; i < args->n; i++) + args->result = g_list_append(args->result, + RVAL2PANGOITEM(RARRAY_PTR(args->ary)[i])); + + result = pango_reorder_items(args->result); + g_list_free(args->result); + + return GLIST2ARY2(result, PANGO_TYPE_ITEM); +} + +static VALUE +rpango_reorder_items_ensure(VALUE value) +{ + g_list_free(((struct rpango_reorder_items_args *)value)->result); + + return Qnil; +} + +static VALUE +rg_s_reorder_items(G_GNUC_UNUSED VALUE self, VALUE attrs) +{ + struct rpango_reorder_items_args args; + args.ary = rb_ary_to_ary(attrs); + args.n = RARRAY_LEN(args.ary); + args.result = NULL; + + return rb_ensure(rpango_reorder_items_body, (VALUE)&args, + rpango_reorder_items_ensure, (VALUE)&args); +} + +#if PANGO_CHECK_VERSION(1,4,0) +static VALUE +rg_s_unichar_direction(G_GNUC_UNUSED VALUE self, VALUE ch) +{ + return PANGODIRECTION2RVAL(pango_unichar_direction(NUM2UINT(ch))); +} + +static VALUE +rg_s_find_base_dir(G_GNUC_UNUSED VALUE self, VALUE text) +{ + StringValue(text); + return PANGODIRECTION2RVAL(pango_find_base_dir(RSTRING_PTR(text), RSTRING_LEN(text))); +} +#endif + +struct rbg_pangologattrs2rval_free_args { + PangoLogAttr *attrs; + long n; +}; + +static VALUE +rbg_pangologattrs2rval_free_body(VALUE value) +{ + struct rbg_pangologattrs2rval_free_args *args = (struct rbg_pangologattrs2rval_free_args *)value; + long i; + VALUE ary = rb_ary_new(); + + for (i = 0; i < args->n; i++) + rb_ary_push(ary, PANGOLOGATTR2RVAL(&args->attrs[i])); + + return ary; +} + +static VALUE +rbg_pangologattrs2rval_free_ensure(VALUE value) +{ + g_free(((struct rbg_pangologattrs2rval_free_args *)value)->attrs); + + return Qnil; +} + +static VALUE +rbg_pangologattrs2rval_free(PangoLogAttr *attrs, long n) +{ + struct rbg_pangologattrs2rval_free_args args = { attrs, n }; + + return rb_ensure(rbg_pangologattrs2rval_free_body, (VALUE)&args, + rbg_pangologattrs2rval_free_ensure, (VALUE)&args); +} + +#define PANGOLOGATTRS2RVAL_FREE(attrs, n) rbg_pangologattrs2rval_free(attrs, n) + +static VALUE +rg_s_break(G_GNUC_UNUSED VALUE self, VALUE rbtext, VALUE rbanalysis) +{ + const gchar *text = RVAL2CSTR(rbtext); + long length = RSTRING_LEN(rbtext); + PangoAnalysis *analysis = RVAL2PANGOANALYSIS(rbanalysis); + long n = g_utf8_strlen(text, length) + 1; + PangoLogAttr *attrs = g_new(PangoLogAttr, n); + + pango_break(text, length, analysis, attrs, n); + + return PANGOLOGATTRS2RVAL_FREE(attrs, n); +} + +static VALUE +rg_s_get_log_attrs(G_GNUC_UNUSED VALUE self, VALUE rbtext, VALUE rblevel, VALUE rblanguage) +{ + const gchar *text = RVAL2CSTR(rbtext); + long length = RSTRING_LEN(rbtext); + int level = NUM2INT(rblevel); + PangoLanguage *language = RVAL2PANGOLANGUAGE(rblanguage); + long n = g_utf8_strlen(text, length) + 1; + PangoLogAttr *attrs = g_new(PangoLogAttr, n); + + pango_get_log_attrs(text, length, level, language, attrs, n); + + return PANGOLOGATTRS2RVAL_FREE(attrs, n); +} + +static VALUE +rg_s_find_paragraph_boundary(G_GNUC_UNUSED VALUE self, VALUE text) +{ + gint paragraph_delimiter_index, next_paragraph_start; + + StringValue(text); + pango_find_paragraph_boundary(RSTRING_PTR(text), RSTRING_LEN(text), + ¶graph_delimiter_index, + &next_paragraph_start); + return rb_ary_new3(2, INT2NUM(paragraph_delimiter_index), + INT2NUM(next_paragraph_start)); +} + +/* +Don't need to implement this. Use pango_break instead. +void pango_default_break (const gchar *text, + int length, + PangoAnalysis *analysis, + PangoLogAttr *attrs, + int attrs_len); +*/ + +static VALUE +rpango_shape_result(VALUE value) +{ + return PANGOGLYPHSTRING2RVAL((PangoGlyphString *)value); +} + +static VALUE +rpango_shape_ensure(VALUE value) +{ + pango_glyph_string_free((PangoGlyphString *)value); + + return Qnil; +} + +static VALUE +rg_s_shape(G_GNUC_UNUSED VALUE self, VALUE rbtext, VALUE rbanalysis) +{ + const gchar *text = RVAL2CSTR(rbtext); + long length = RSTRING_LEN(rbtext); + PangoAnalysis *analysis = RVAL2PANGOANALYSIS(rbanalysis); + PangoGlyphString *glyphs = pango_glyph_string_new(); + + pango_shape(text, length, analysis, glyphs); + + return rb_ensure(rpango_shape_result, (VALUE)glyphs, + rpango_shape_ensure, (VALUE)glyphs); +} + +/* This method is from rbpangoattribute.c */ +static VALUE +rg_s_parse_markup(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) +{ + VALUE markup_text, accel_marker; + PangoAttrList *pattr_list; + gchar* gtext; + gunichar accel_char; + GError *error = NULL; + gboolean ret; + char c; + VALUE text = Qnil; + VALUE attr_list = Qnil; + + rb_scan_args(argc, argv, "11", &markup_text, &accel_marker); + + if (NIL_P(markup_text)) rb_raise(rb_eRuntimeError, "1st argument can't accept nil"); + + StringValue(markup_text); + ret = pango_parse_markup(RSTRING_PTR(markup_text), + RSTRING_LEN(markup_text), + NIL_P(accel_marker) ? 0 : NUM2CHR(accel_marker), + &pattr_list, >ext, &accel_char, &error); + + if (!ret) RAISE_GERROR(error); + + if (pattr_list){ + attr_list = PANGOATTRLIST2RVAL(pattr_list); + pango_attr_list_unref(pattr_list); + } + + c = (char)accel_char; + if (text){ + text = CSTR2RVAL(gtext); + g_free(gtext); + } + return rb_ary_new3(3, attr_list, text, + accel_char ? rb_str_new(&c, 1) : Qnil); +} + +static VALUE +rg_s_pixels(G_GNUC_UNUSED VALUE self, VALUE pixels) +{ + return rb_float_new(PANGO_PIXELS(NUM2DBL(pixels))); +} + +static VALUE +rg_s_cairo_available_p(G_GNUC_UNUSED VALUE self) +{ +#ifdef CAIRO_AVAILABLE + return Qtrue; +#else + return Qfalse; +#endif +} + +void +Init_pango(void) +{ + RG_TARGET_NAMESPACE = rb_define_module("Pango"); + + rb_define_const(RG_TARGET_NAMESPACE, "BUILD_VERSION", + rb_ary_new3(3, + INT2FIX(PANGO_MAJOR_VERSION), + INT2FIX(PANGO_MINOR_VERSION), + INT2FIX(PANGO_MICRO_VERSION))); + + RG_DEF_SMETHOD(reorder_items, 1); + +#if PANGO_CHECK_VERSION(1,4,0) + RG_DEF_SMETHOD(unichar_direction, 1); + RG_DEF_SMETHOD(find_base_dir, 1); +#endif + RG_DEF_SMETHOD(break, 2); + RG_DEF_SMETHOD(get_log_attrs, 3); + RG_DEF_SMETHOD(find_paragraph_boundary, 1); + RG_DEF_SMETHOD(shape, 2); + RG_DEF_SMETHOD(parse_markup, -1); + RG_DEF_SMETHOD(pixels, 1); + + rb_define_const(RG_TARGET_NAMESPACE, "SCALE", INT2FIX(PANGO_SCALE)); + + RG_DEF_SMETHOD_P(cairo_available, 0); + + Init_pango_analysis(RG_TARGET_NAMESPACE); + Init_pango_attribute(RG_TARGET_NAMESPACE); + Init_pango_attriterator(RG_TARGET_NAMESPACE); + Init_pango_attrlist(RG_TARGET_NAMESPACE); + Init_pango_cairo(RG_TARGET_NAMESPACE); + Init_pango_cairo_context(RG_TARGET_NAMESPACE); + Init_pango_color(RG_TARGET_NAMESPACE); + Init_pango_context(RG_TARGET_NAMESPACE); + Init_pango_coverage(RG_TARGET_NAMESPACE); + Init_pango_engine(RG_TARGET_NAMESPACE); + Init_pango_font(RG_TARGET_NAMESPACE); + Init_pango_font_description(RG_TARGET_NAMESPACE); + Init_pango_font_face(RG_TARGET_NAMESPACE); + Init_pango_font_family(RG_TARGET_NAMESPACE); + Init_pango_font_map(RG_TARGET_NAMESPACE); + Init_pango_font_metrics(RG_TARGET_NAMESPACE); + Init_pango_fontset(RG_TARGET_NAMESPACE); + Init_pango_fontset_simple(RG_TARGET_NAMESPACE); + Init_pango_glyph_info(RG_TARGET_NAMESPACE); + Init_pango_glyph_item(RG_TARGET_NAMESPACE); + Init_pango_glyph_string(RG_TARGET_NAMESPACE); + Init_pango_gravity(RG_TARGET_NAMESPACE); + Init_pango_item(RG_TARGET_NAMESPACE); + Init_pango_language(RG_TARGET_NAMESPACE); + Init_pango_layout(RG_TARGET_NAMESPACE); + Init_pango_layout_iter(RG_TARGET_NAMESPACE); + Init_pango_layout_line(RG_TARGET_NAMESPACE); + Init_pango_logattr(RG_TARGET_NAMESPACE); + Init_pango_matrix(RG_TARGET_NAMESPACE); + Init_pango_rectangle(RG_TARGET_NAMESPACE); + Init_pangorenderer(RG_TARGET_NAMESPACE); + Init_pango_script(RG_TARGET_NAMESPACE); + Init_pango_script_iter(RG_TARGET_NAMESPACE); + Init_pango_array(RG_TARGET_NAMESPACE); +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpango.h b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpango.h new file mode 100644 index 0000000..117811d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpango.h @@ -0,0 +1,104 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "ruby.h" +#define PANGO_ENABLE_ENGINE +#define PANGO_ENABLE_BACKEND +#include <pango/pango.h> + +#ifdef HAVE_FREETYPE2 +#include <pango/pangofc-font.h> +#endif + +#include "rbgobject.h" +#include "rbpangoversion.h" +#include "rbpangoconversions.h" + +#if PANGO_CHECK_VERSION(1,10,0) +#include <pango/pangocairo.h> +# ifdef HAVE_RB_CAIRO_H +#include <rb_cairo.h> +# endif +#endif + +#if defined(G_PLATFORM_WIN32) && !defined(RUBY_PANGO_STATIC_COMPILATION) +# ifdef RUBY_PANGO_COMPILATION +# define RUBY_PANGO_VAR __declspec(dllexport) +# else +# define RUBY_PANGO_VAR extern __declspec(dllimport) +# endif +#else +# define RUBY_PANGO_VAR extern +#endif + +extern void Init_pango_inits(); +RUBY_PANGO_VAR VALUE mPango; + +#ifndef PANGO_TYPE_ITEM +#define PANGO_TYPE_ITEM (pango_item_get_type()) +#endif +#define PANGO_TYPE_ANALYSIS (pango_analysis_get_type()) +#define PANGO_TYPE_LOG_ATTR (pango_log_attr_get_type()) +#ifndef PANGO_TYPE_LAYOUT_ITER +#define PANGO_TYPE_LAYOUT_ITER (pango_layout_iter_get_type()) +#endif +#ifndef PANGO_TYPE_LAYOUT_LINE +#define PANGO_TYPE_LAYOUT_LINE (pango_layout_line_get_type()) +#endif +#define PANGO_TYPE_RECTANGLE (pango_rectangle_get_type()) +#define PANGO_TYPE_ATTR_ITERATOR (pango_attr_iter_get_type()) +#define PANGO_TYPE_COVERAGE (pango_coverage_get_type()) +#define PANGO_TYPE_GLYPH_INFO (pango_glyph_info_get_type()) +#ifndef PANGO_TYPE_GLYPH_ITEM +# define PANGO_TYPE_GLYPH_ITEM (pango_glyph_item_get_type()) +#endif + +#if PANGO_CHECK_VERSION(1,4,0) +#define PANGO_TYPE_SCRIPT_ITER (pango_script_iter_get_type()) +#endif + +#define ATTR2RVAL(attr) (pango_make_attribute(attr)) +#define RVAL2ATTR(attr) (pango_get_attribute(attr)) +#define ATTRTYPE2CLASS(attr_type) (pango_get_attribute_klass(attr_type)) +#define RBPANGO_ADD_ATTRIBUTE(type, klass) (pango_add_attribute(type, klass)) + +extern VALUE pango_make_attribute(PangoAttribute* attr); +extern PangoAttribute* pango_get_attribute(VALUE attr); + +extern GType pango_item_get_type(void); +extern GType pango_analysis_get_type(void); +extern GType pango_log_attr_get_type(void); +extern GType pango_layout_iter_get_type(void); +extern GType pango_layout_line_get_type(void); +extern GType pango_rectangle_get_type(void); +extern GType pango_attr_iter_get_type(void); +extern GType pango_coverage_get_type(void); +extern GType pango_glyph_info_get_type(void); +#ifndef HAVE_PANGO_GLYPH_ITEM_GET_TYPE +extern GType pango_glyph_item_get_type(void); +#endif + +#if PANGO_CHECK_VERSION(1,4,0) +extern GType pango_script_iter_get_type(void); +#endif + +extern VALUE pango_get_attribute_klass(VALUE attr_type); +extern void pango_add_attribute(int attr_type, VALUE klass); diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoanalysis.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoanalysis.c new file mode 100644 index 0000000..b1f33a3 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoanalysis.c @@ -0,0 +1,222 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cAnalysis +#define _SELF(s) (RVAL2PANGOANALYSIS(s)) + +/**********************************/ +static PangoAnalysis* +ana_copy(const PangoAnalysis* val) +{ + PangoAnalysis* new_val; + g_return_val_if_fail (val != NULL, NULL); + new_val = g_new(PangoAnalysis, 1); + *new_val = *val; + return new_val; +} + +GType +pango_analysis_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("PangoAnalysis", + (GBoxedCopyFunc)ana_copy, + (GBoxedFreeFunc)g_free); + return our_type; +} +/**********************************/ + +static VALUE +rg_initialize(VALUE self) +{ + PangoAnalysis analysis = { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL }; + G_INITIALIZE(self, g_boxed_copy(PANGO_TYPE_ANALYSIS, &analysis)); + return Qnil; +} + +#if PANGO_CHECK_VERSION(1,4,0) +static VALUE +rg_set_shape_engine(VALUE self, VALUE engine) +{ + _SELF(self)->shape_engine = RVAL2PANGOENGINESHAPE(engine); + return self; +} +static VALUE +rg_shape_engine(VALUE self) +{ + VALUE ret; + if (_SELF(self)->shape_engine){ + const gchar* gname = G_OBJECT_TYPE_NAME(_SELF(self)->shape_engine); + gchar* name = g_strdup(gname); + name[0] = g_ascii_toupper(name[0]); + G_DEF_CLASS3(gname, name, mPango); + ret = GOBJ2RVAL(_SELF(self)->shape_engine); + } else { + ret = Qnil; + } + return ret; +} + +static VALUE +rg_set_lang_engine(VALUE self, VALUE engine) +{ + _SELF(self)->lang_engine = RVAL2PANGOENGINELANG(engine); + return self; +} +static VALUE +rg_lang_engine(VALUE self) +{ + VALUE ret; + if (_SELF(self)->lang_engine){ + const gchar* gname = G_OBJECT_TYPE_NAME(_SELF(self)->lang_engine); + gchar* name = g_strdup(gname); + name[0] = g_ascii_toupper(name[0]); + G_DEF_CLASS3(name, name, mPango); + ret = GOBJ2RVAL(_SELF(self)->lang_engine); + } else { + ret = Qnil; + } + return ret; +} +#endif + +static VALUE +rg_set_font(VALUE self, VALUE font) +{ + _SELF(self)->font = RVAL2PANGOFONT(font); + return self; +} + +static VALUE +rg_font(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->font); +} + +static VALUE +rg_set_level(VALUE self, VALUE level) +{ + _SELF(self)->level = NUM2UINT(level); + return self; +} + +static VALUE +rg_level(VALUE self) +{ + return UINT2NUM(_SELF(self)->level); +} + +static VALUE +rg_set_language(VALUE self, VALUE lang) +{ + _SELF(self)->language = RVAL2PANGOLANGUAGE(lang); + return self; +} + +static VALUE +rg_language(VALUE self) +{ + return PANGOLANGUAGE2RVAL(_SELF(self)->language); +} + +struct ana_set_extra_attrs_args { + PangoAnalysis *analysis; + VALUE ary; + long n; + GSList *result; +}; + +static VALUE +ana_set_extra_attrs_body(VALUE value) +{ + struct ana_set_extra_attrs_args *args = (struct ana_set_extra_attrs_args *)value; + long i; + + for (i = 0; i < args->n; i++) + args->result = g_slist_append(args->result, RVAL2ATTR(RARRAY_PTR(args->ary)[i])); + + args->analysis->extra_attrs = args->result; + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +ana_set_extra_attrs_rescue(VALUE value) +{ + g_slist_free(((struct ana_set_extra_attrs_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static VALUE +rg_set_extra_attrs(VALUE self, VALUE attrs) +{ + struct ana_set_extra_attrs_args args; + args.analysis = _SELF(self); + args.ary = rb_ary_to_ary(attrs); + args.n = RARRAY_LEN(args.ary); + args.result = NULL; + + rb_rescue(ana_set_extra_attrs_body, (VALUE)&args, + ana_set_extra_attrs_rescue, (VALUE)&args); + + return self; +} + +static VALUE +rg_extra_attrs(VALUE self) +{ + VALUE ary = rb_ary_new(); + GSList* list = _SELF(self)->extra_attrs; + + while (list) { + rb_ary_push(ary, ATTR2RVAL(list->data)); + list = list->next; + } + return ary; +} + +void +Init_pango_analysis(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_ANALYSIS, "Analysis", mPango); + + RG_DEF_METHOD(initialize, 0); +#if PANGO_CHECK_VERSION(1,4,0) + RG_DEF_METHOD(set_shape_engine, 1); + RG_DEF_METHOD(shape_engine, 0); + RG_DEF_METHOD(set_lang_engine, 1); + RG_DEF_METHOD(lang_engine, 0); +#endif + RG_DEF_METHOD(set_font, 1); + RG_DEF_METHOD(font, 0); + RG_DEF_METHOD(set_level, 1); + RG_DEF_METHOD(level, 0); + RG_DEF_METHOD(set_language, 1); + RG_DEF_METHOD(language, 0); + + RG_DEF_METHOD(set_extra_attrs, 1); + RG_DEF_METHOD(extra_attrs, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoattribute.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoattribute.c new file mode 100644 index 0000000..f169f30 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoattribute.c @@ -0,0 +1,524 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE pattr + +VALUE RG_TARGET_NAMESPACE, attrstring, pattrint, pattrfloat, pattrcolor, pattrbool; +static VALUE type_to_klass; + +/***********************************************/ +void +pango_add_attribute(int attr_type, VALUE klass) +{ + rb_hash_aset(type_to_klass, INT2FIX(attr_type), klass); +} + +/* This is for Attributes which has PangoAttrType. */ +VALUE +pango_get_attribute_klass(VALUE attr_type) +{ + VALUE type = Qnil; + if (TYPE(attr_type) == T_STRING){ + const char *strtype = RVAL2CSTR(attr_type); + if (strcmp(strtype, "Attribute") == 0){ + type = RG_TARGET_NAMESPACE; + } else if (strcmp(strtype, "AttrString") == 0){ + type = attrstring; + } else if (strcmp(strtype, "AttrInt") == 0){ + type = pattrint; + } else if (strcmp(strtype, "AttrFloat") == 0){ + type = pattrfloat; + } else if (strcmp(strtype, "AttrColor") == 0){ + type = pattrcolor; + } else if (strcmp(strtype, "AttrBool") == 0){ + type = pattrbool; + } + } else { + type = rb_hash_aref(type_to_klass, INT2FIX(attr_type)); + } + return type; +} + +VALUE +pango_make_attribute(PangoAttribute *attr) +{ + if (attr == NULL) return Qnil; + return Data_Wrap_Struct(rb_hash_aref(type_to_klass, INT2FIX(attr->klass->type)), 0, + pango_attribute_destroy, + pango_attribute_copy(attr)); +} + +PangoAttribute* +pango_get_attribute(VALUE attr) +{ + PangoAttribute *gattr; + + if (NIL_P(attr)) return NULL; + + if (!rb_obj_is_kind_of(attr, RG_TARGET_NAMESPACE)) { + rb_raise(rb_eTypeError, "not a Pango::Attribute..."); + } + Data_Get_Struct(attr, PangoAttribute, gattr); + return gattr; +} + +/***********************************************/ +static VALUE +rg_s_allocate(VALUE klass) +{ + /* Don't define destroy method here. + return Data_Wrap_Struct(klass, 0, pango_attribute_destroy, 0); + */ + return Data_Wrap_Struct(klass, NULL, NULL, 0); +} + +#ifdef HAVE_OBJECT_ALLOCATE +#define attr_s_new rb_class_new_instance +#else +static VALUE +rg_s_new(int argc, VALUE *argv, VALUE klass) +{ + VALUE obj = rg_s_allocate(klass); + rb_obj_call_init(obj, argc, argv); + return obj; +} +#endif + +/***********************************************/ + +/* This method implemented at rbpangomain.c +gboolean pango_parse_markup (const char *markup_text, + int length, + gunichar accel_marker, + PangoAttrList **attr_list, + char **text, + gunichar *accel_char, + GError **error); +*/ + +static VALUE +rg_s_type_register(G_GNUC_UNUSED VALUE self, VALUE name) +{ + return INT2NUM(pango_attr_type_register(RVAL2CSTR(name))); +} + +static VALUE +rg_operator_attr_equal(VALUE self, VALUE other) +{ + return CBOOL2RVAL(pango_attribute_equal(RVAL2ATTR(self), RVAL2ATTR(other))); +} + +/* + * Structure accessors + */ +/* PangoAttribute */ +static VALUE +rg_start_index(VALUE self) +{ + return UINT2NUM(RVAL2ATTR(self)->start_index); +} + +static VALUE +rg_set_start_index(VALUE self, VALUE value) +{ + RVAL2ATTR(self)->start_index = NUM2UINT(value); + return Qnil; +} + +static VALUE +rg_end_index(VALUE self) +{ + return UINT2NUM(RVAL2ATTR(self)->end_index); +} + +static VALUE +rg_set_end_index(VALUE self, VALUE value) +{ + RVAL2ATTR(self)->end_index = NUM2UINT(value); + return Qnil; +} + +/* PangoAttrString */ +static VALUE +attr_string_value(VALUE self) +{ + return CSTR2RVAL(((PangoAttrString*)RVAL2ATTR(self))->value); +} + +/* PangoAttrLanguage */ +static VALUE +attr_language_value(VALUE self) +{ + return PANGOLANGUAGE2RVAL(((PangoAttrLanguage*)RVAL2ATTR(self))->value); +} + +/* PangoAttrColor */ +static VALUE +attr_color_value(VALUE self) +{ + PangoColor color = ((PangoAttrColor*)RVAL2ATTR(self))->color; + return PANGOCOLOR2RVAL(&color); +} + +/* PangoAttrInt */ +static VALUE +attr_int_value(VALUE self) +{ + return INT2NUM(((PangoAttrInt*)RVAL2ATTR(self))->value); +} + +/* PangoAttrFloat */ +static VALUE +attr_float_value(VALUE self) +{ + return rb_float_new(((PangoAttrFloat*)RVAL2ATTR(self))->value); +} + +/* PangoAttrBool(This is Ruby/Pango's original class) */ +static VALUE +attr_bool_value(VALUE self) +{ + return CBOOL2RVAL(((PangoAttrInt*)RVAL2ATTR(self))->value); +} + +/* PangoAttrFontDesc */ +static VALUE +attr_fontdesc_value(VALUE self) +{ + return PANGOFONTDESCRIPTION2RVAL(((PangoAttrFontDesc*)RVAL2ATTR(self))->desc); +} + +/* PangoAttrShape */ +static VALUE +attr_shape_ink_rect(VALUE self) +{ + PangoRectangle rect = ((PangoAttrShape*)RVAL2ATTR(self))->ink_rect; + return PANGORECTANGLE2RVAL(&rect); +} + +static VALUE +attr_shape_logical_rect(VALUE self) +{ + PangoRectangle rect = ((PangoAttrShape*)RVAL2ATTR(self))->logical_rect; + return PANGORECTANGLE2RVAL(&rect); +} + +static VALUE +attr_shape_value(VALUE self) +{ + return rb_ary_new3(2, attr_shape_ink_rect(self), attr_shape_logical_rect(self)); +} + +/* + * Initialize methods + */ +#define MAKE_ATTRINT_INIT(klassname, funcname)\ +static VALUE \ +attr_ ## klassname ## _initialize(VALUE self, VALUE val)\ +{\ + DATA_PTR(self) = pango_attr_ ## funcname ## _new(NUM2INT(val));\ + return Qnil;\ +} + +#define MAKE_ATTRENUM_INIT(klassname, funcname, type)\ +static VALUE \ +attr_ ## klassname ## _initialize(VALUE self, VALUE val)\ +{\ + DATA_PTR(self) = pango_attr_ ## funcname ## _new(RVAL2GENUM(val, type));\ + return Qnil;\ +} + +static VALUE +attr_AttrLanguage_initialize(VALUE self, VALUE lang) +{ + DATA_PTR(self) = pango_attr_language_new( + RVAL2PANGOLANGUAGE(lang)); + return Qnil; +} + +static VALUE +attr_AttrFamily_initialize(VALUE self, VALUE family) +{ + DATA_PTR(self) = pango_attr_family_new(RVAL2CSTR(family)); + return Qnil; +} + +MAKE_ATTRENUM_INIT(AttrStyle, style, PANGO_TYPE_STYLE); +MAKE_ATTRENUM_INIT(AttrVariant, variant, PANGO_TYPE_VARIANT); +MAKE_ATTRENUM_INIT(AttrStretch, stretch, PANGO_TYPE_STRETCH); +MAKE_ATTRENUM_INIT(AttrWeight, weight, PANGO_TYPE_WEIGHT); + +static VALUE +attr_AttrSize_initialize(VALUE self, VALUE size) +{ + DATA_PTR(self) = pango_attr_size_new(NUM2INT(size)); + return Qnil; +} +#if PANGO_CHECK_VERSION(1,8,1) +static VALUE +attr_AttrAbsoluteSize_initialize(VALUE self, VALUE size) +{ + DATA_PTR(self) = pango_attr_size_new_absolute(NUM2INT(size)); + return Qnil; +} +#endif + +#if PANGO_CHECK_VERSION(1,16,0) +static VALUE +attr_AttrGravity_initialize(VALUE self, VALUE gravity) +{ + DATA_PTR(self) = pango_attr_gravity_new(RVAL2PANGOGRAVITY(gravity)); + return Qnil; +} + +static VALUE +attr_AttrGravityHint_initialize(VALUE self, VALUE gravity_hint) +{ + DATA_PTR(self) = pango_attr_gravity_hint_new(RVAL2PANGOGRAVITYHINT(gravity_hint)); + return Qnil; +} +#endif + +static VALUE +attr_AttrFontDescription_initialize(VALUE self, VALUE fontdescription) +{ + DATA_PTR(self) = pango_attr_font_desc_new(RVAL2PANGOFONTDESCRIPTION(fontdescription)); + return Qnil; +} + +static VALUE +attr_AttrForeground_initialize(VALUE self, VALUE r, VALUE g, VALUE b) +{ + DATA_PTR(self) = pango_attr_foreground_new(FIX2UINT(r), FIX2UINT(g), FIX2UINT(b)); + return Qnil; +} + +static VALUE +attr_AttrBackground_initialize(VALUE self, VALUE r, VALUE g, VALUE b) +{ + DATA_PTR(self) = pango_attr_background_new(FIX2UINT(r), FIX2UINT(g), FIX2UINT(b)); + return Qnil; +} + +static VALUE +attr_AttrStrikethrough_initialize(VALUE self, VALUE strikethrough) +{ + DATA_PTR(self) = pango_attr_strikethrough_new(RVAL2CBOOL(strikethrough)); + return Qnil; +} +#ifdef HAVE_PANGO_ATTR_STRIKETHROUGH_COLOR_NEW +static VALUE +attr_AttrStrikethroughColor_initialize(VALUE self, VALUE r, VALUE g, VALUE b) +{ + DATA_PTR(self) = pango_attr_strikethrough_color_new(FIX2UINT(r), FIX2UINT(g), FIX2UINT(b)); + return Qnil; +} +#endif + +MAKE_ATTRENUM_INIT(AttrUnderline, underline, PANGO_TYPE_UNDERLINE); +#ifdef HAVE_PANGO_ATTR_UNDERLINE_COLOR_NEW +static VALUE +attr_AttrUnderlineColor_initialize(VALUE self, VALUE r, VALUE g, VALUE b) +{ + DATA_PTR(self) = pango_attr_underline_color_new(FIX2UINT(r), FIX2UINT(g), FIX2UINT(b)); + return Qnil; +} +#endif + +static VALUE +attr_AttrShape_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE ink_rect, logical_rect, data; + + rb_scan_args(argc, argv, "21", &ink_rect, &logical_rect, &data); + + if (NIL_P(data)){ + DATA_PTR(self) = pango_attr_shape_new( + RVAL2PANGORECTANGLE(ink_rect), + RVAL2PANGORECTANGLE(logical_rect)); + } else { +#if PANGO_CHECK_VERSION(1,8,0) + G_RELATIVE(self, data); + DATA_PTR(self) = pango_attr_shape_new_with_data( + RVAL2PANGORECTANGLE(ink_rect), + RVAL2PANGORECTANGLE(logical_rect), + (gpointer)data, NULL, NULL); +#else + rb_warning("not supported in Pango-1.6.x. the 3rd parameter was ignored."); + DATA_PTR(self) = pango_attr_shape_new( + RVAL2PANGORECTANGLE(ink_rect), + RVAL2PANGORECTANGLE(logical_rect)); +#endif + } + + return Qnil; +} + +static VALUE +attr_AttrScale_initialize(VALUE self, VALUE scale) +{ + DATA_PTR(self) = pango_attr_scale_new(NUM2DBL(scale)); + return Qnil; +} + +#if PANGO_CHECK_VERSION(1,4,0) +static VALUE +attr_AttrFallback_initialize(VALUE self, VALUE enable_fallback) +{ + DATA_PTR(self) = pango_attr_fallback_new(RVAL2CBOOL(enable_fallback)); + return Qnil; +} +#endif + +MAKE_ATTRINT_INIT(AttrRise, rise); + +#if PANGO_CHECK_VERSION(1,6,0) +MAKE_ATTRINT_INIT(AttrLetterSpacing, letter_spacing); +#endif + +#define MAKE_ATTR(gtype, name, parent, num)\ +tmpklass = rb_define_class_under(mPango, #name, parent);\ +rb_hash_aset(type_to_klass, INT2FIX(gtype), tmpklass);\ +rbg_define_method(tmpklass, "initialize", attr_## name ## _initialize , num); + +void +Init_pango_attribute(VALUE mPango) +{ + VALUE tmpklass; + RG_TARGET_NAMESPACE = rb_define_class_under(mPango, "Attribute", rb_cData); + + RG_DEF_SMETHOD(type_register, 1); + RG_DEF_METHOD_OPERATOR("==", attr_equal, 1); + RG_DEF_METHOD(start_index, 0); + RG_DEF_METHOD(set_start_index, 1); + RG_DEF_METHOD(end_index, 0); + RG_DEF_METHOD(set_end_index, 1); + +#ifndef HAVE_RB_DEFINE_ALLOC_FUNC + RG_DEF_SMETHOD(allocate, 0); +#else + rb_define_alloc_func(RG_TARGET_NAMESPACE, (VALUE(*)_((VALUE)))rg_s_allocate); +#endif +#ifndef HAVE_OBJECT_ALLOCATE + RG_DEF_SMETHOD(new, -1); +#endif + + attrstring = rb_define_class_under(mPango, "AttrString", RG_TARGET_NAMESPACE); + rbg_define_method(attrstring, "value", attr_string_value, 0); + + pattrint = rb_define_class_under(mPango, "AttrInt", RG_TARGET_NAMESPACE); + rbg_define_method(pattrint, "value", attr_int_value, 0); + + pattrfloat = rb_define_class_under(mPango, "AttrFloat", RG_TARGET_NAMESPACE); + rbg_define_method(pattrfloat, "value", attr_float_value, 0); + + pattrcolor = rb_define_class_under(mPango, "AttrColor", RG_TARGET_NAMESPACE); + rbg_define_method(pattrcolor, "value", attr_color_value, 0); + + pattrbool = rb_define_class_under(mPango, "AttrBool", RG_TARGET_NAMESPACE); + rbg_define_method(pattrbool, "value", attr_bool_value, 0); + + rb_global_variable(&type_to_klass); + type_to_klass = rb_hash_new(); + + MAKE_ATTR(PANGO_ATTR_LANGUAGE, AttrLanguage, RG_TARGET_NAMESPACE, 1); + rbg_define_method(tmpklass, "value", attr_language_value, 0); + + MAKE_ATTR(PANGO_ATTR_FAMILY, AttrFamily, attrstring, 1); + MAKE_ATTR(PANGO_ATTR_STYLE, AttrStyle, pattrint, 1); + MAKE_ATTR(PANGO_ATTR_WEIGHT, AttrWeight, pattrint, 1); + MAKE_ATTR(PANGO_ATTR_VARIANT, AttrVariant, pattrint, 1); + MAKE_ATTR(PANGO_ATTR_STRETCH, AttrStretch, pattrint, 1); + MAKE_ATTR(PANGO_ATTR_SIZE, AttrSize, pattrint, 1); +#if PANGO_CHECK_VERSION(1,8,1) + MAKE_ATTR(PANGO_ATTR_ABSOLUTE_SIZE, AttrAbsoluteSize, pattrint, 1); +#endif +#if PANGO_CHECK_VERSION(1,16,0) + MAKE_ATTR(PANGO_ATTR_GRAVITY, AttrGravity, pattrint, 1); + MAKE_ATTR(PANGO_ATTR_GRAVITY_HINT, AttrGravityHint, pattrint, 1); +#endif + MAKE_ATTR(PANGO_ATTR_FONT_DESC, AttrFontDescription, RG_TARGET_NAMESPACE, 1); + rbg_define_method(tmpklass, "value", attr_fontdesc_value, 0); + MAKE_ATTR(PANGO_ATTR_FOREGROUND, AttrForeground, pattrcolor, 3); + MAKE_ATTR(PANGO_ATTR_BACKGROUND, AttrBackground, pattrcolor, 3); + MAKE_ATTR(PANGO_ATTR_UNDERLINE, AttrUnderline, pattrint, 1); + /* PangoUnderline */ + G_DEF_CLASS(PANGO_TYPE_UNDERLINE, "Underline", tmpklass); + G_DEF_CONSTANTS(tmpklass, PANGO_TYPE_UNDERLINE, "PANGO_UNDERLINE_"); +#ifdef HAVE_PANGO_ATTR_UNDERLINE_COLOR_NEW + MAKE_ATTR(PANGO_ATTR_UNDERLINE_COLOR, AttrUnderlineColor, pattrcolor, 3); +#endif + + MAKE_ATTR(PANGO_ATTR_STRIKETHROUGH, AttrStrikethrough, pattrbool, 1); +#ifdef HAVE_PANGO_ATTR_STRIKETHROUGH_COLOR_NEW + MAKE_ATTR(PANGO_ATTR_STRIKETHROUGH_COLOR, AttrStrikethroughColor, pattrcolor, 3); +#endif + MAKE_ATTR(PANGO_ATTR_RISE, AttrRise, pattrint, 1); +#if PANGO_CHECK_VERSION(1,6,0) + MAKE_ATTR(PANGO_ATTR_LETTER_SPACING, AttrLetterSpacing, pattrint, 1); +#endif + MAKE_ATTR(PANGO_ATTR_SHAPE, AttrShape, RG_TARGET_NAMESPACE, -1); + rbg_define_method(tmpklass, "ink_rect", attr_shape_ink_rect, 0); + rbg_define_method(tmpklass, "logical_rect", attr_shape_logical_rect, 0); + rbg_define_method(tmpklass, "value", attr_shape_value, 0); + MAKE_ATTR(PANGO_ATTR_SCALE, AttrScale, pattrfloat, 1); + /* PangoScale */ + rb_define_const(tmpklass, "XX_SMALL", rb_float_new(PANGO_SCALE_XX_SMALL)); + rb_define_const(tmpklass, "X_SMALL", rb_float_new(PANGO_SCALE_X_SMALL)); + rb_define_const(tmpklass, "SMALL", rb_float_new(PANGO_SCALE_SMALL)); + rb_define_const(tmpklass, "MEDIUM", rb_float_new(PANGO_SCALE_MEDIUM)); + rb_define_const(tmpklass, "LARGE", rb_float_new(PANGO_SCALE_LARGE)); + rb_define_const(tmpklass, "X_LARGE", rb_float_new(PANGO_SCALE_X_LARGE)); + rb_define_const(tmpklass, "XX_LARGE", rb_float_new(PANGO_SCALE_XX_LARGE)); +#if PANGO_CHECK_VERSION(1,4,0) + MAKE_ATTR(PANGO_ATTR_FALLBACK, AttrFallback, pattrbool, 1); +#endif + /* PangoAttrType */ + G_DEF_CLASS(PANGO_TYPE_ATTR_TYPE, "Type", RG_TARGET_NAMESPACE); +#define INT2ATTRTYPE(x) rbgobj_make_enum((x), PANGO_TYPE_ATTR_TYPE) + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_INVALID", INT2ATTRTYPE(PANGO_ATTR_INVALID)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_LANGUAGE", INT2ATTRTYPE(PANGO_ATTR_LANGUAGE)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_FAMILY", INT2ATTRTYPE(PANGO_ATTR_FAMILY)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_STYLE", INT2ATTRTYPE(PANGO_ATTR_STYLE)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_WEIGHT", INT2ATTRTYPE(PANGO_ATTR_WEIGHT)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_VARIANT", INT2ATTRTYPE(PANGO_ATTR_VARIANT)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_STRETCH", INT2ATTRTYPE(PANGO_ATTR_STRETCH)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_SIZE", INT2ATTRTYPE(PANGO_ATTR_SIZE)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_FONT_DESC", INT2ATTRTYPE(PANGO_ATTR_FONT_DESC)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_FOREGROUND", INT2ATTRTYPE(PANGO_ATTR_FOREGROUND)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_BACKGROUND", INT2ATTRTYPE(PANGO_ATTR_BACKGROUND)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_UNDERLINE", INT2ATTRTYPE(PANGO_ATTR_UNDERLINE)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_STRIKETHROUGH", INT2ATTRTYPE(PANGO_ATTR_STRIKETHROUGH)); +#if PANGO_CHECK_VERSION(1,8,0) + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_STRIKETHROUGH_COLOR", INT2ATTRTYPE(PANGO_ATTR_STRIKETHROUGH_COLOR)); +#endif + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_RISE", INT2ATTRTYPE(PANGO_ATTR_RISE)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_SHAPE", INT2ATTRTYPE(PANGO_ATTR_SHAPE)); + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_SCALE", INT2ATTRTYPE(PANGO_ATTR_SCALE)); +#if PANGO_CHECK_VERSION(1,8,0) + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_FALLBACK", INT2ATTRTYPE(PANGO_ATTR_FALLBACK)); +#endif +#if PANGO_CHECK_VERSION(1,6,0) + rb_define_const(RG_TARGET_NAMESPACE, "TYPE_LETTER_SPACING", INT2ATTRTYPE(PANGO_ATTR_LETTER_SPACING)); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoattriterator.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoattriterator.c new file mode 100644 index 0000000..7a20445 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoattriterator.c @@ -0,0 +1,141 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cAttrIterator +#define _SELF(self) (RVAL2PANGOATTRITERATOR(self)) + +/**********************************/ +GType +pango_attr_iter_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("PangoAttrIterator", + (GBoxedCopyFunc)pango_attr_iterator_copy, + (GBoxedFreeFunc)pango_attr_iterator_destroy); + return our_type; +} +/**********************************/ + +static VALUE +rg_next_bang(VALUE self) +{ + return CBOOL2RVAL(pango_attr_iterator_next(_SELF(self))); +} + +static VALUE +rg_range(VALUE self) +{ + gint start = 0; + gint end = 0; + pango_attr_iterator_range(_SELF(self), &start, &end); + return rb_ary_new3(2, INT2NUM(start), INT2NUM(end)); +} + +static VALUE +rg_get(int argc, VALUE *argv, VALUE self) +{ + VALUE type, ret; + PangoAttribute* attr; + int i; + + rb_scan_args(argc, argv, "01", &type); + + if (NIL_P(type)){ + PangoAttrIterator* iter = _SELF(self); + ret = rb_ary_new(); + for (i = 0; i < PANGO_ATTR_SCALE + 1; i++){ + attr = pango_attr_iterator_get(iter, i); + if (attr) + rb_ary_push(ret, ATTR2RVAL(attr)); + } + } else { + attr = pango_attr_iterator_get(_SELF(self), FIX2INT(type)); + ret = attr ? ATTR2RVAL(attr) : Qnil; + } + return ret; +} + +static VALUE +rg_font(VALUE self) +{ + PangoFontDescription* desc; + PangoLanguage* lang; + GSList* extra_attrs; + VALUE ary, ret; + + desc = pango_font_description_new(); + + pango_attr_iterator_get_font(_SELF(self), desc, &lang, &extra_attrs); + + ary = rb_ary_new(); + while(extra_attrs) { + rb_ary_push(ary, ATTR2RVAL(extra_attrs->data)); + extra_attrs = extra_attrs->next; + } + + ret = rb_ary_new3(3, PANGOFONTDESCRIPTION2RVAL(desc), + PANGOLANGUAGE2RVAL(lang), + ary); + + pango_font_description_free(desc); + return ret; +} + +#ifdef HAVE_PANGO_ATTR_ITERATOR_GET_ATTRS +static VALUE +rg_attrs(VALUE self) +{ + GSList* list = pango_attr_iterator_get_attrs(_SELF(self)); + GSList* base = list; + GSList* old = list; + VALUE ary = rb_ary_new(); + + while (list) { + rb_ary_push(ary, ATTR2RVAL(list->data)); + list = list->next; + } + while (old) { + pango_attribute_destroy((PangoAttribute*)old); + old = old->next; + } + g_slist_free(base); + + return ary; +} +#endif + +void +Init_pango_attriterator(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_ATTR_ITERATOR, "AttrIterator", mPango); + + RG_DEF_METHOD_BANG(next, 0); + RG_DEF_METHOD(range, 0); + RG_DEF_METHOD(get, -1); + RG_DEF_METHOD(font, 0); +#ifdef HAVE_PANGO_ATTR_ITERATOR_GET_ATTRS + RG_DEF_METHOD(attrs, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoattrlist.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoattrlist.c new file mode 100644 index 0000000..aeb403b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoattrlist.c @@ -0,0 +1,105 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +static ID id_call; + +#define RG_TARGET_NAMESPACE cAttrList +#define _SELF(self) (RVAL2PANGOATTRLIST(self)) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, pango_attr_list_new()); + return Qnil; +} + +static VALUE +rg_insert(VALUE self, VALUE attr) +{ + pango_attr_list_insert(_SELF(self), RVAL2ATTR(attr)); + return self; +} + +static VALUE +rg_insert_before(VALUE self, VALUE attr) +{ + pango_attr_list_insert_before(_SELF(self), RVAL2ATTR(attr)); + return self; +} + +static VALUE +rg_change(VALUE self, VALUE attr) +{ + pango_attr_list_change(_SELF(self), RVAL2ATTR(attr)); + return self; +} + +static VALUE +rg_splice(VALUE self, VALUE other, VALUE pos, VALUE len) +{ + pango_attr_list_splice(_SELF(self), _SELF(other), NUM2INT(pos), NUM2INT(len)); + return self; +} + +#if PANGO_CHECK_VERSION(1,4,0) +static gboolean +filter_func(PangoAttribute *attr, gpointer data) +{ + return CBOOL2RVAL(rb_funcall((VALUE)data, id_call, 1, ATTR2RVAL(attr))); +} + +static VALUE +rg_filter(VALUE self) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + return PANGOATTRLIST2RVAL(pango_attr_list_filter(_SELF(self), + (PangoAttrFilterFunc)filter_func, + (gpointer)func)); +} +#endif + +static VALUE +rg_iterator(VALUE self) +{ + return PANGOATTRITERATOR2RVAL(pango_attr_list_get_iterator(_SELF(self))); +} + +void +Init_pango_attrlist(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_ATTR_LIST, "AttrList", mPango); + + id_call = rb_intern("call"); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(insert, 1); + RG_DEF_METHOD(insert_before, 1); + RG_DEF_METHOD(change, 1); + RG_DEF_METHOD(splice, 3); +#if PANGO_CHECK_VERSION(1,4,0) + RG_DEF_METHOD(filter, 0); +#endif + RG_DEF_METHOD(iterator, 0); + +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangocairo.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangocairo.c new file mode 100644 index 0000000..1bf4e84 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangocairo.c @@ -0,0 +1,115 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#ifdef CAIRO_AVAILABLE + +#define RG_TARGET_NAMESPACE cCairoFontMap +#define _SELF(self) (RVAL2PANGOCAIROFONTMAP(self)) + +static VALUE +rg_s_create(int argc, VALUE *argv, G_GNUC_UNUSED VALUE klass) +{ + VALUE rb_font_type; + PangoFontMap *font_map = NULL; + + rb_scan_args(argc, argv, "01", &rb_font_type); + if (NIL_P(rb_font_type)) { + font_map = pango_cairo_font_map_new(); + } else { + cairo_font_type_t font_type = CAIRO_FONT_TYPE_USER; + if (rbgutil_key_equal(rb_font_type, "ft") || + rbgutil_key_equal(rb_font_type, "freetype")) { + font_type = CAIRO_FONT_TYPE_FT; + } else if (rbgutil_key_equal(rb_font_type, "win32")) { + font_type = CAIRO_FONT_TYPE_WIN32; + } else if (rbgutil_key_equal(rb_font_type, "quartz")) { + font_type = CAIRO_FONT_TYPE_QUARTZ; + } else { + rb_raise(rb_eArgError, + "font type must be one of " + ":ft, :freetype, :win32 or :quartz: %s", + RBG_INSPECT(rb_font_type)); + } + font_map = pango_cairo_font_map_new_for_font_type(font_type); + } + + return GOBJ2RVAL(font_map); +} + +static VALUE +rg_s_default(G_GNUC_UNUSED VALUE klass) +{ + return GOBJ2RVAL(pango_cairo_font_map_get_default()); +} + +# if PANGO_CHECK_VERSION(1, 22, 0) +static VALUE +rg_s_set_default(VALUE klass, VALUE font_map) +{ + pango_cairo_font_map_set_default(RVAL2GOBJ(font_map)); + return klass; +} +# endif + +static VALUE +rg_set_resolution(VALUE self, VALUE dpi) +{ + pango_cairo_font_map_set_resolution(_SELF(self), NUM2DBL(dpi)); + return self; +} + +static VALUE +rg_resolution(VALUE self) +{ + return rb_float_new(pango_cairo_font_map_get_resolution(_SELF(self))); +} + +static VALUE +rg_create_context(VALUE self) +{ + return GOBJ2RVAL_UNREF(pango_cairo_font_map_create_context(_SELF(self))); +} + +#endif + +void +Init_pango_cairo(VALUE mPango) +{ +#ifdef CAIRO_AVAILABLE + VALUE RG_TARGET_NAMESPACE; + + /* Pango::CairoFontMap */ + RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_CAIRO_FONT_MAP, "CairoFontMap", mPango); + + RG_DEF_SMETHOD(create, -1); + RG_DEF_SMETHOD(default, 0); +# if PANGO_CHECK_VERSION(1, 22, 0) + RG_DEF_SMETHOD(set_default, 1); +# endif + + RG_DEF_METHOD(set_resolution, 1); + RG_DEF_METHOD(resolution, 0); + RG_DEF_METHOD(create_context, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangocairocontext.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangocairocontext.c new file mode 100644 index 0000000..7f7137e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangocairocontext.c @@ -0,0 +1,151 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2006 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#if PANGO_CHECK_VERSION(1,10,0) && defined(HAVE_RB_CAIRO_H) +# define CAIRO_AVAILABLE 1 +#endif + +#ifdef CAIRO_AVAILABLE + +#define RG_TARGET_NAMESPACE rb_cCairo_Context + +static VALUE +rg_update_pango_context(VALUE self, VALUE context) +{ + pango_cairo_update_context(RVAL2CRCONTEXT(self), RVAL2PANGOCONTEXT(context)); + return self; +} + +/* Convenience */ +static VALUE +rg_create_pango_layout(VALUE self) +{ + return GOBJ2RVAL_UNREF(pango_cairo_create_layout(RVAL2CRCONTEXT(self))); +} + +static VALUE +rg_update_pango_layout(VALUE self, VALUE layout) +{ + pango_cairo_update_layout(RVAL2CRCONTEXT(self), RVAL2PANGOLAYOUT(layout)); + return self; +} + +/* Rendering */ +static VALUE +rg_show_pango_glyph_string(VALUE self, VALUE font, VALUE glyphs) +{ + pango_cairo_show_glyph_string(RVAL2CRCONTEXT(self), + RVAL2PANGOFONT(font), + RVAL2PANGOGLYPHSTRING(glyphs)); + return self; +} + +static VALUE +rg_show_pango_layout_line(VALUE self, VALUE line) +{ + pango_cairo_show_layout_line(RVAL2CRCONTEXT(self), RVAL2PANGOLAYOUTLINE(line)); + return self; +} + +static VALUE +rg_show_pango_layout(VALUE self, VALUE layout) +{ + pango_cairo_show_layout(RVAL2CRCONTEXT(self), RVAL2PANGOLAYOUT(layout)); + return self; +} + +#if PANGO_CHECK_VERSION(1,14,0) +static VALUE +rg_show_pango_error_underline(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height) +{ + pango_cairo_show_error_underline(RVAL2CRCONTEXT(self), + NUM2DBL(x), NUM2DBL(y), + NUM2DBL(width), NUM2DBL(height)); + return self; +} +#endif + +/* Rendering to a path */ +static VALUE +rg_pango_glyph_string_path(VALUE self, VALUE font, VALUE glyphs) +{ + pango_cairo_glyph_string_path(RVAL2CRCONTEXT(self), + RVAL2PANGOFONT(font), + RVAL2PANGOGLYPHSTRING(glyphs)); + return self; +} + +static VALUE +rg_pango_layout_line_path(VALUE self, VALUE line) +{ + pango_cairo_layout_line_path(RVAL2CRCONTEXT(self), RVAL2PANGOLAYOUTLINE(line)); + return self; +} + +static VALUE +rg_pango_layout_path(VALUE self, VALUE layout) +{ + pango_cairo_layout_path(RVAL2CRCONTEXT(self), RVAL2PANGOLAYOUT(layout)); + return self; +} + +#if PANGO_CHECK_VERSION(1,14,0) +static VALUE +rg_pango_error_underline_path(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height) +{ + pango_cairo_error_underline_path(RVAL2CRCONTEXT(self), + NUM2DBL(x), NUM2DBL(y), + NUM2DBL(width), NUM2DBL(height)); + return self; +} +#endif + +#endif + +void +Init_pango_cairo_context(VALUE mPango) +{ +#ifdef CAIRO_AVAILABLE + /* Cairo::Context */ + RG_DEF_METHOD(update_pango_context, 1); + /* Convenience */ + RG_DEF_METHOD(create_pango_layout, 0); + RG_DEF_METHOD(update_pango_layout, 1); + /* Rendering */ + RG_DEF_METHOD(show_pango_glyph_string, 2); + RG_DEF_METHOD(show_pango_layout_line, 1); + RG_DEF_METHOD(show_pango_layout, 1); +#if PANGO_CHECK_VERSION(1,14,0) + RG_DEF_METHOD(show_pango_error_underline, 4); +#endif + /* Rendering to a path */ + RG_DEF_METHOD(pango_glyph_string_path, 2); + RG_DEF_METHOD(pango_layout_line_path, 1); + RG_DEF_METHOD(pango_layout_path, 1); + +#if PANGO_CHECK_VERSION(1,14,0) + RG_DEF_METHOD(pango_error_underline_path, 4); +#endif +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangocolor.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangocolor.c new file mode 100644 index 0000000..9cd9300 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangocolor.c @@ -0,0 +1,120 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cColor +#define _SELF(self) (RVAL2PANGOCOLOR(self)) + +static VALUE +rg_initialize(VALUE self, VALUE red, VALUE green, VALUE blue) +{ + PangoColor color; + + color.red = NUM2UINT(red); + color.green = NUM2UINT(green); + color.blue = NUM2UINT(blue); + + G_INITIALIZE(self, g_boxed_copy(PANGO_TYPE_COLOR, &color)); + return Qnil; +} + +static VALUE +rg_parse(VALUE self, VALUE spec) +{ + return CBOOL2RVAL(pango_color_parse(_SELF(self), RVAL2CSTR(spec))); +} + +static VALUE +rg_red(VALUE self) +{ + return UINT2NUM(_SELF(self)->red); +} + +static VALUE +rg_set_red(VALUE self, VALUE red) +{ + _SELF(self)->red = NUM2UINT(red); + return self; +} + +static VALUE +rg_green(VALUE self) +{ + return UINT2NUM(_SELF(self)->green); +} + +static VALUE +rg_set_green(VALUE self, VALUE green) +{ + _SELF(self)->green = NUM2UINT(green); + return self; +} + +static VALUE +rg_blue(VALUE self) +{ + return UINT2NUM(_SELF(self)->blue); +} + +static VALUE +rg_set_blue(VALUE self, VALUE blue) +{ + _SELF(self)->blue = NUM2UINT(blue); + return self; +} + +static VALUE +rg_to_a(VALUE self) +{ + PangoColor *c = _SELF(self); + return rb_ary_new3(3, + UINT2NUM(c->red), + UINT2NUM(c->green), + UINT2NUM(c->blue)); +} + +static VALUE +rg_operator_color_equal(VALUE self, VALUE other) +{ + PangoColor* c1 = _SELF(self); + PangoColor* c2 = _SELF(other); + + return CBOOL2RVAL((c1->red == c2->red) && (c1->green == c2->green) && + (c1->blue == c2->blue)); +} + +void +Init_pango_color(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_COLOR, "Color", mPango); + + RG_DEF_METHOD(initialize, 3); + RG_DEF_METHOD(parse, 1); + RG_DEF_METHOD(red, 0); + RG_DEF_METHOD(set_red, 1); + RG_DEF_METHOD(green, 0); + RG_DEF_METHOD(set_green, 1); + RG_DEF_METHOD(blue, 0); + RG_DEF_METHOD(set_blue, 1); + RG_DEF_METHOD(to_a, 0); + RG_DEF_METHOD_OPERATOR("==", color_equal, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangocontext.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangocontext.c new file mode 100644 index 0000000..ecd9b8c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangocontext.c @@ -0,0 +1,321 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cContext +#define _SELF(self) (RVAL2PANGOCONTEXT(self)) + +static VALUE +rg_itemize(int argc, VALUE *argv, VALUE self) +{ + VALUE arg1, arg2, arg3, arg4, arg5, arg6; + GList* list; + + rb_scan_args(argc, argv, "42", &arg1, &arg2, &arg3, &arg4, &arg5, &arg6); + + if (TYPE(arg1) == T_STRING) { + list = pango_itemize(_SELF(self), + RVAL2CSTR(arg1), /* text */ + NUM2INT(arg2), /* start_index */ + NUM2INT(arg3), /* length */ + RVAL2PANGOATTRLIST(arg4), /* attrs */ + NIL_P(arg5) ? NULL : RVAL2PANGOATTRITERATOR(arg5)); /* cached_iter */ + } else { +#ifdef HAVE_PANGO_ITEMIZE_WITH_BASE_DIR + list = pango_itemize_with_base_dir(_SELF(self), + RVAL2PANGODIRECTION(arg1), /* base_dir */ + RVAL2CSTR(arg2), /* text */ + NUM2INT(arg3), /* start_index */ + NUM2INT(arg4), /* length */ + RVAL2PANGOATTRLIST(arg5), /* attrs */ + NIL_P(arg6) ? NULL : RVAL2PANGOATTRITERATOR(arg6)); /* cached_iter */ +#else + rb_warn("Pango::Context#itemize(base_dir, text, start_index, length, attrs, cached_iter) isn't supported on this environment."); + list = pango_itemize(_SELF(self), + RVAL2CSTR(arg1), /* text */ + NUM2INT(arg2), /* start_index */ + NUM2INT(arg3), /* length */ + RVAL2PANGOATTRLIST(arg4), /* attrs */ + NIL_P(arg5) ? NULL : RVAL2PANGOATTRITERATOR(arg5)); /* cached_iter */ +#endif + } + return GLIST2ARY2F(list, PANGO_TYPE_ITEM); +} + +/* Move to Pango module (rbpangomain.c) +GList* pango_reorder_items (GList *logical_items); +*/ + +#ifdef PANGO_ENABLE_BACKEND +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, pango_context_new()); + return Qnil; +} + +static VALUE +rg_set_font_map(VALUE self, VALUE font_map) +{ + pango_context_set_font_map(_SELF(self), RVAL2PANGOFONTMAP(font_map)); + return self; +} + +#if PANGO_CHECK_VERSION(1,6,0) +static VALUE +rg_font_map(VALUE self) +{ + return GOBJ2RVAL(pango_context_get_font_map(_SELF(self))); +} +#endif +#endif /* PANGO_ENABLE_BACKEND */ + +static VALUE +rg_font_description(VALUE self) +{ + PangoFontDescription* ret = pango_context_get_font_description(_SELF(self)); + return PANGOFONTDESCRIPTION2RVAL(ret); +} + +static VALUE +rg_set_font_description(VALUE self, VALUE desc) +{ + pango_context_set_font_description(_SELF(self), RVAL2PANGOFONTDESCRIPTION(desc)); + return self; +} + +static VALUE +rg_language(VALUE self) +{ + PangoLanguage* ret = pango_context_get_language(_SELF(self)); + return PANGOLANGUAGE2RVAL(ret); +} + +static VALUE +rg_set_language(VALUE self, VALUE lang) +{ + pango_context_set_language(_SELF(self), + RVAL2PANGOLANGUAGE(lang)); + return self; +} + +static VALUE +rg_base_dir(VALUE self) +{ + return PANGODIRECTION2RVAL(pango_context_get_base_dir(_SELF(self))); +} + +static VALUE +rg_set_base_dir(VALUE self, VALUE direction) +{ + pango_context_set_base_dir(_SELF(self), RVAL2PANGODIRECTION(direction)); + return self; +} + +#if PANGO_CHECK_VERSION(1,16,0) +static VALUE +rg_base_gravity(VALUE self) +{ + return PANGOGRAVITY2RVAL(pango_context_get_base_gravity(_SELF(self))); +} + +static VALUE +rg_set_base_gravity(VALUE self, VALUE gravity) +{ + pango_context_set_base_gravity(_SELF(self), RVAL2PANGOGRAVITY(gravity)); + return self; +} + +static VALUE +rg_gravity_hint(VALUE self) +{ + return PANGOGRAVITYHINT2RVAL(pango_context_get_gravity_hint(_SELF(self))); +} + +static VALUE +rg_set_gravity_hint(VALUE self, VALUE gravity_hint) +{ + pango_context_set_gravity_hint(_SELF(self), RVAL2PANGOGRAVITYHINT(gravity_hint)); + return self; +} +#endif + +#if PANGO_CHECK_VERSION(1,6,0) +static VALUE +rg_matrix(VALUE self) +{ + const PangoMatrix* matrix = pango_context_get_matrix(_SELF(self)); + return PANGOMATRIX2RVAL((PangoMatrix*)matrix); +} + +static VALUE +rg_set_matrix(VALUE self, VALUE matrix) +{ + pango_context_set_matrix(_SELF(self), + RVAL2PANGOMATRIX(matrix)); + return self; +} +#endif + +static VALUE +rg_load_font(VALUE self, VALUE desc) +{ + return GOBJ2RVAL(pango_context_load_font(_SELF(self), RVAL2PANGOFONTDESCRIPTION(desc))); +} + +static VALUE +rg_load_fontset(VALUE self, VALUE desc, VALUE lang) +{ + return GOBJ2RVAL(pango_context_load_fontset(_SELF(self), + RVAL2PANGOFONTDESCRIPTION(desc), RVAL2PANGOLANGUAGE(lang))); +} + +static VALUE +rg_get_metrics(int argc, VALUE *argv, VALUE self) +{ + VALUE desc, lang; + + rb_scan_args(argc, argv, "11", &desc, &lang); + + return PANGOFONTMETRICS2RVAL(pango_context_get_metrics(_SELF(self), + RVAL2PANGOFONTDESCRIPTION(desc), + NIL_P(lang) ? NULL : RVAL2PANGOLANGUAGE(lang))); +} + +static VALUE +rg_families(VALUE self) +{ + int n_families; + PangoFontFamily** families; + int i; + VALUE result; + + pango_context_list_families(_SELF(self), + &families, + &n_families); + + result = rb_ary_new2(n_families); + for (i = 0; i < n_families; i++) + rb_ary_store(result, i, GOBJ2RVAL(families[i])); + + g_free(families); + + return result; +} + +#if PANGO_CHECK_VERSION(1,10,0) +# ifdef HAVE_RB_CAIRO_H +static VALUE +rg_set_font_options(VALUE self, VALUE options) +{ + if (NIL_P(options)) + pango_cairo_context_set_font_options(_SELF(self), NULL); + else + pango_cairo_context_set_font_options(_SELF(self), + RVAL2CRFONTOPTIONS(options)); + return self; +} + +static VALUE +rg_font_options(VALUE self) +{ + const cairo_font_options_t *options; + options = pango_cairo_context_get_font_options(_SELF(self)); + if (options) + return CRFONTOPTIONS2RVAL(cairo_font_options_copy(options)); + else + return Qnil; +} + +static VALUE +rg_set_resolution(VALUE self, VALUE dpi) +{ + pango_cairo_context_set_resolution(_SELF(self), NUM2DBL(dpi)); + return self; +} + +static VALUE +rg_resolution(VALUE self) +{ + return rb_float_new(pango_cairo_context_get_resolution(_SELF(self))); +} +# endif +#endif + +static VALUE +rg_list_families(VALUE self) +{ + rb_warn("Deprecated. Use Pango::Context#families instead."); + return rg_families(self); +} + +void +Init_pango_context(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_CONTEXT, "Context", mPango); + + RG_DEF_METHOD(itemize, -1); + +#ifdef PANGO_ENABLE_BACKEND + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(set_font_map, 1); +#if PANGO_CHECK_VERSION(1,6,0) + RG_DEF_METHOD(font_map, 0); +#endif +#endif /* PANGO_ENABLE_BACKEND */ + RG_DEF_METHOD(font_description, 0); + RG_DEF_METHOD(set_font_description, 1); + RG_DEF_METHOD(language, 0); + RG_DEF_METHOD(set_language, 1); + RG_DEF_METHOD(base_dir, 0); + RG_DEF_METHOD(set_base_dir, 1); +#if PANGO_CHECK_VERSION(1,16,0) + RG_DEF_METHOD(base_gravity, 0); + RG_DEF_METHOD(set_base_gravity, 1); + RG_DEF_METHOD(gravity_hint, 0); + RG_DEF_METHOD(set_gravity_hint, 1); +#endif +#if PANGO_CHECK_VERSION(1,6,0) + RG_DEF_METHOD(matrix, 0); + RG_DEF_METHOD(set_matrix, 1); +#endif + RG_DEF_METHOD(load_font, 1); + RG_DEF_METHOD(load_fontset, 2); + RG_DEF_METHOD(get_metrics, -1); + RG_DEF_METHOD(families, 0); + +#if PANGO_CHECK_VERSION(1,10,0) +# ifdef HAVE_RB_CAIRO_H + RG_DEF_METHOD(set_font_options, 1); + RG_DEF_METHOD(font_options, 0); + RG_DEF_METHOD(set_resolution, 1); + RG_DEF_METHOD(resolution, 0); +# endif +#endif + + /* This will remove 2 or 3 releases later since 0.14.0. */ + RG_DEF_METHOD(list_families, 0); + + /* PangoDirection */ + G_DEF_CLASS(PANGO_TYPE_DIRECTION, "Direction", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, PANGO_TYPE_DIRECTION, "PANGO_"); +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoconversions.h b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoconversions.h new file mode 100644 index 0000000..0ab6c18 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoconversions.h @@ -0,0 +1,111 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __PANGOCONVERSIONS_H__ +#define __PANGOCONVERSIONS_H__ + +#define RVAL2PANGOCAIROFONTMAP(o) (PANGO_CAIRO_FONT_MAP(RVAL2GOBJ(o))) +#define RVAL2PANGOCONTEXT(o) (PANGO_CONTEXT(RVAL2GOBJ(o))) +#define RVAL2PANGOENGINE(o) (PANGO_ENGINE(RVAL2GOBJ(o))) +#define RVAL2PANGOENGINELANG(o) (PANGO_ENGINE_LANG(RVAL2GOBJ(o))) +#define RVAL2PANGOENGINESHAPE(o) (PANGO_ENGINE_SHAPE(RVAL2GOBJ(o))) +#define RVAL2PANGOFONT(o) (PANGO_FONT(RVAL2GOBJ(o))) +#define RVAL2PANGOFONTSET(o) (PANGO_FONTSET(RVAL2GOBJ(o))) +#define RVAL2PANGOFONTSETSIMPLE(o) (PANGO_FONTSET_SIMPLE(RVAL2GOBJ(o))) +#define RVAL2PANGOFONTFACE(o) (PANGO_FONT_FACE(RVAL2GOBJ(o))) +#define RVAL2PANGOFONTFAMILY(o) (PANGO_FONT_FAMILY(RVAL2GOBJ(o))) +#define RVAL2PANGOFONTMAP(o) (PANGO_FONT_MAP(RVAL2GOBJ(o))) +#define RVAL2PANGOLAYOUT(o) (PANGO_LAYOUT(RVAL2GOBJ(o))) +#define RVAL2PANGORENDERER(o) (PANGO_RENDERER(RVAL2GOBJ(o))) + +#define RVAL2PANGOANALYSIS(o) ((PangoAnalysis*)RVAL2BOXED(o, PANGO_TYPE_ANALYSIS)) +#define PANGOANALYSIS2RVAL(o) (BOXED2RVAL(o, PANGO_TYPE_ANALYSIS)) +#define RVAL2PANGOATTRITERATOR(o) ((PangoAttrIterator*)RVAL2BOXED(o, PANGO_TYPE_ATTR_ITERATOR)) +#define PANGOATTRITERATOR2RVAL(o) (BOXED2RVAL(o, PANGO_TYPE_ATTR_ITERATOR)) +#define RVAL2PANGOATTRLIST(o) ((PangoAttrList*)RVAL2BOXED(o, PANGO_TYPE_ATTR_LIST)) +#define PANGOATTRLIST2RVAL(o) (BOXED2RVAL(o, PANGO_TYPE_ATTR_LIST)) +#define RVAL2PANGOCOLOR(o) ((PangoColor*)RVAL2BOXED(o, PANGO_TYPE_COLOR)) +#define PANGOCOLOR2RVAL(o) (BOXED2RVAL(o, PANGO_TYPE_COLOR)) +#define RVAL2PANGOCOVERAGE(o) ((PangoCoverage*)RVAL2BOXED(o, PANGO_TYPE_COVERAGE)) +#define PANGOCOVERAGE2RVAL(o) (BOXED2RVAL(o, PANGO_TYPE_COVERAGE)) +#define RVAL2PANGOFONTDESCRIPTION(o) ((PangoFontDescription*)RVAL2BOXED(o, PANGO_TYPE_FONT_DESCRIPTION)) +#define PANGOFONTDESCRIPTION2RVAL(o) (BOXED2RVAL(o, PANGO_TYPE_FONT_DESCRIPTION)) +#define RVAL2PANGOFONTMETRICS(o) ((PangoFontMetrics*)RVAL2BOXED(o, PANGO_TYPE_FONT_METRICS)) +#define PANGOFONTMETRICS2RVAL(o) (BOXED2RVAL(o, PANGO_TYPE_FONT_METRICS)) +#define RVAL2PANGOGLYPHINFO(o) ((PangoGlyphInfo*)RVAL2BOXED(o, PANGO_TYPE_GLYPH_INFO)) +#define PANGOGLYPHINFO2RVAL(o) (BOXED2RVAL(o, PANGO_TYPE_GLYPH_INFO)) +#define RVAL2PANGOGLYPHITEM(o) ((PangoGlyphItem*)RVAL2BOXED(o, PANGO_TYPE_GLYPH_ITEM)) +#define PANGOGLYPHITEM2RVAL(o) (BOXED2RVAL(o, PANGO_TYPE_GLYPH_ITEM)) +#define RVAL2PANGOGLYPHSTRING(o) ((PangoGlyphString*)RVAL2BOXED(o, PANGO_TYPE_GLYPH_STRING)) +#define PANGOGLYPHSTRING2RVAL(o) (BOXED2RVAL(o, PANGO_TYPE_GLYPH_STRING)) +#define RVAL2PANGOITEM(o) ((PangoItem*)RVAL2BOXED(o, PANGO_TYPE_ITEM)) +#define PANGOITEM2RVAL(o) (BOXED2RVAL(o, PANGO_TYPE_ITEM)) +#define RVAL2PANGOLANGUAGE(o) ((PangoLanguage*)RVAL2BOXED(o, PANGO_TYPE_LANGUAGE)) +#define PANGOLANGUAGE2RVAL(o) (BOXED2RVAL(o, PANGO_TYPE_LANGUAGE)) +#define RVAL2PANGOLAYOUTITER(o) ((PangoLayoutIter*)RVAL2BOXED(o, PANGO_TYPE_LAYOUT_ITER)) +#define PANGOLAYOUTITER2RVAL(o) (BOXED2RVAL(o, PANGO_TYPE_LAYOUT_ITER)) +#define RVAL2PANGOLAYOUTLINE(o) ((PangoLayoutLine*)RVAL2BOXED(o, PANGO_TYPE_LAYOUT_LINE)) +#define PANGOLAYOUTLINE2RVAL(o) (BOXED2RVAL(o, PANGO_TYPE_LAYOUT_LINE)) +#define RVAL2PANGOLOGATTR(o) ((PangoLogAttr*)RVAL2BOXED(o, PANGO_TYPE_LOG_ATTR)) +#define PANGOLOGATTR2RVAL(o) (BOXED2RVAL(o, PANGO_TYPE_LOG_ATTR)) +#define RVAL2PANGOMATRIX(o) ((PangoMatrix*)RVAL2BOXED(o, PANGO_TYPE_MATRIX)) +#define PANGOMATRIX2RVAL(o) (BOXED2RVAL(o, PANGO_TYPE_MATRIX)) +#define RVAL2PANGORECTANGLE(o) ((PangoRectangle*)RVAL2BOXED(o, PANGO_TYPE_RECTANGLE)) +#define PANGORECTANGLE2RVAL(o) (BOXED2RVAL(o, PANGO_TYPE_RECTANGLE)) +#define RVAL2PANGOSCRIPTITER(o) ((PangoScriptIter*)RVAL2BOXED(o, PANGO_TYPE_SCRIPT_ITER)) +#define PANGOSCRIPTITER2RVAL(o) (BOXED2RVAL(o, PANGO_TYPE_SCRIPT_ITER)) +#define RVAL2PANGOTABARRAY(o) ((PangoTabArray*)RVAL2BOXED(o, PANGO_TYPE_TAB_ARRAY)) +#define PANGOTABARRAY2RVAL(o) (BOXED2RVAL(o, PANGO_TYPE_TAB_ARRAY)) + +#define RVAL2PANGOALIGNMENT(o) (RVAL2GENUM(o, PANGO_TYPE_ALIGNMENT)) +#define PANGOALIGNMENT2RVAL(o) (GENUM2RVAL(o, PANGO_TYPE_ALIGNMENT)) +#define RVAL2PANGOCOVERAGELEVEL(o) (RVAL2GENUM(o, PANGO_TYPE_COVERAGE_LEVEL)) +#define PANGOCOVERAGELEVEL2RVAL(o) (GENUM2RVAL(o, PANGO_TYPE_COVERAGE_LEVEL)) +#define RVAL2PANGODIRECTION(o) (RVAL2GENUM(o, PANGO_TYPE_DIRECTION)) +#define PANGODIRECTION2RVAL(o) (GENUM2RVAL(o, PANGO_TYPE_DIRECTION)) +#define RVAL2PANGOELLIPSIZEMODE(o) (RVAL2GENUM(o, PANGO_TYPE_ELLIPSIZE_MODE)) +#define PANGOELLIPSIZEMODE2RVAL(o) (GENUM2RVAL(o, PANGO_TYPE_ELLIPSIZE_MODE)) +#define RVAL2PANGOGRAVITY(o) (RVAL2GENUM(o, PANGO_TYPE_GRAVITY)) +#define PANGOGRAVITY2RVAL(o) (GENUM2RVAL(o, PANGO_TYPE_GRAVITY)) +#define RVAL2PANGOGRAVITYHINT(o) (RVAL2GENUM(o, PANGO_TYPE_GRAVITY_HINT)) +#define PANGOGRAVITYHINT2RVAL(o) (GENUM2RVAL(o, PANGO_TYPE_GRAVITY_HINT)) +#define RVAL2PANGORENDERPART(o) (RVAL2GENUM(o, PANGO_TYPE_RENDER_PART)) +#define PANGORENDERPART2RVAL(o) (GENUM2RVAL(o, PANGO_TYPE_RENDER_PART)) +#define RVAL2PANGOSCRIPT(o) (RVAL2GENUM(o, PANGO_TYPE_SCRIPT)) +#define PANGOSCRIPT2RVAL(o) (GENUM2RVAL(o, PANGO_TYPE_SCRIPT)) +#define RVAL2PANGOSTRETCH(o) (RVAL2GENUM(o, PANGO_TYPE_STRETCH)) +#define PANGOSTRETCH2RVAL(o) (GENUM2RVAL(o, PANGO_TYPE_STRETCH)) +#define RVAL2PANGOSTYLE(o) (RVAL2GENUM(o, PANGO_TYPE_STYLE)) +#define PANGOSTYLE2RVAL(o) (GENUM2RVAL(o, PANGO_TYPE_STYLE)) +#define RVAL2PANGOTABALIGN(o) (RVAL2GENUM(o, PANGO_TYPE_TAB_ALIGN)) +#define PANGOTABALIGN2RVAL(o) (GENUM2RVAL(o, PANGO_TYPE_TAB_ALIGN)) +#define RVAL2PANGOUNDERLINE(o) (RVAL2GENUM(o, PANGO_TYPE_UNDERLINE)) +#define PANGOUNDERLINE2RVAL(o) (GENUM2RVAL(o, PANGO_TYPE_UNDERLINE)) +#define RVAL2PANGOVARIANT(o) (RVAL2GENUM(o, PANGO_TYPE_VARIANT)) +#define PANGOVARIANT2RVAL(o) (GENUM2RVAL(o, PANGO_TYPE_VARIANT)) +#define RVAL2PANGOWEIGHT(o) (RVAL2GENUM(o, PANGO_TYPE_WEIGHT)) +#define PANGOWEIGHT2RVAL(o) (GENUM2RVAL(o, PANGO_TYPE_WEIGHT)) +#define RVAL2PANGOWRAPMODE(o) (RVAL2GENUM(o, PANGO_TYPE_WRAP_MODE)) +#define PANGOWRAPMODE2RVAL(o) (GENUM2RVAL(o, PANGO_TYPE_WRAP_MODE)) + +#define RVAL2PANGOFONTMASK(o) (RVAL2GFLAGS(o, PANGO_TYPE_FONT_MASK)) +#define PANGOFONTMASK2RVAL(o) (GFLAGS2RVAL(o, PANGO_TYPE_FONT_MASK)) + +#endif /* __PANGOCONVERSIONS_H__ */ diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangocoverage.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangocoverage.c new file mode 100644 index 0000000..6606133 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangocoverage.c @@ -0,0 +1,106 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cCoverage +#define _SELF(self) (RVAL2PANGOCOVERAGE(self)) + +/**********************************/ +GType +pango_coverage_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("PangoCoverage", + (GBoxedCopyFunc)pango_coverage_copy, + (GBoxedFreeFunc)pango_coverage_unref); + return our_type; +} +/**********************************/ + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, pango_coverage_new()); + return Qnil; +} + +static VALUE +rg_get_level(VALUE self, VALUE index_) +{ + return PANGOCOVERAGELEVEL2RVAL(pango_coverage_get(_SELF(self), NUM2INT(index_))); +} + +static VALUE +rg_max_bang(VALUE self, VALUE other) +{ + pango_coverage_max(_SELF(self), _SELF(other)); + return self; +} + +static VALUE +rg_set(VALUE self, VALUE index_, VALUE level) +{ + pango_coverage_set(_SELF(self), NUM2INT(index_), + RVAL2PANGOCOVERAGELEVEL(level)); + return self; +} + +static VALUE +rg_to_bytes(VALUE self) +{ + guchar* bytes; + int n_bytes; + VALUE ret; + + pango_coverage_to_bytes(_SELF(self), &bytes, &n_bytes); + ret = rb_str_new((const char*)bytes, n_bytes); + g_free(bytes); + + return ret; +} + +static VALUE +rg_s_from_bytes(G_GNUC_UNUSED VALUE self, VALUE bytes) +{ + StringValue(bytes); + return PANGOCOVERAGE2RVAL(pango_coverage_from_bytes((guchar *)RSTRING_PTR(bytes), + RSTRING_LEN(bytes))); +} + +void +Init_pango_coverage(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_COVERAGE, "Coverage", mPango); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(get_level, 0); + RG_DEF_METHOD_BANG(max, 1); + RG_DEF_METHOD(set, 2); + RG_DEF_METHOD(to_bytes, 0); + RG_DEF_SMETHOD(from_bytes, 1); + + /* PangoCoverageLevel */ + G_DEF_CLASS(PANGO_TYPE_COVERAGE_LEVEL, "Level", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, PANGO_TYPE_COVERAGE_LEVEL, "PANGO_COVERAGE_"); +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoengine.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoengine.c new file mode 100644 index 0000000..a0b49f2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoengine.c @@ -0,0 +1,73 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#ifdef PANGO_TYPE_ENGINE + +#define _SELF(self) (RVAL2PANGOENGINE(self)) + +/* FIXME +static VALUE +rbpango_s_engine_list(VALUE self) +{ + PangoEngineInfo* engines = g_new(PangoEngineInfo, 1); + int i, n; + VALUE ary; + + script_engine_list(&engines, &n); + ary = rb_ary_new(); + + for(i = 0; i < n; i++){ + rb_ary_push(ary, GOBJ2RVAL(&engines[i])); + } + return ary; +} + +static VALUE +rbpango_s_engine_create(VALUE self, VALUE id) +{ + return GOBJ2RVAL(script_engine_create(RVAL2CSTR(id))); +} +*/ +/* +void script_engine_init (GTypeModule *module); +void script_engine_exit (void); +PangoEngine* script_engine_create (const char *id); +*/ + +#endif + +void +Init_pango_engine(VALUE mPango) +{ +#ifdef PANGO_TYPE_ENGINE + G_DEF_CLASS(PANGO_TYPE_ENGINE, "Engine", mPango); + +/* FIXME + rb_define_singleton_method(engine, "engines", rbpango_s_engine_list, 0); + rb_define_singleton_method(engine, "create", rbpango_s_engine_create, 1); +*/ + G_DEF_CLASS(PANGO_TYPE_ENGINE_LANG, "EngineLang", mPango); + G_DEF_CLASS(PANGO_TYPE_ENGINE_SHAPE, "EngineShape", mPango); +#endif +} + diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofont.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofont.c new file mode 100644 index 0000000..03ce768 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofont.c @@ -0,0 +1,122 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cFont +#define _SELF(self) (RVAL2PANGOFONT(self)) + +static VALUE +rg_find_shaper(VALUE self, VALUE language, VALUE ch) +{ + return GOBJ2RVAL(pango_font_find_shaper(_SELF(self), + RVAL2PANGOLANGUAGE(language), + NUM2UINT(ch))); +} + +static VALUE +rg_describe(int argc, VALUE *argv, VALUE self) +{ + VALUE desc, absolute_size; + rb_scan_args(argc, argv, "01", &absolute_size); + + if (NIL_P(absolute_size) || ! RVAL2CBOOL(absolute_size)){ + desc = PANGOFONTDESCRIPTION2RVAL(pango_font_describe(_SELF(self))); + } else { +#if PANGO_CHECK_VERSION(1,14,0) + desc = PANGOFONTDESCRIPTION2RVAL(pango_font_describe_with_absolute_size(_SELF(self))); +#else + rb_warning("Pango::Font#describe(absolute) has been supported since GTK+-2.10.x. Use Pango::Font#describe() instead."); + desc = PANGOFONTDESCRIPTION2RVAL(pango_font_describe(_SELF(self))); +#endif + } + return desc; +} + +static VALUE +rg_get_coverage(VALUE self, VALUE language) +{ + PangoCoverage* c = pango_font_get_coverage(_SELF(self), + RVAL2PANGOLANGUAGE(language)); + return PANGOCOVERAGE2RVAL(c); +} + +static VALUE +rg_get_glyph_extents(VALUE self, VALUE glyph) +{ + PangoRectangle ink_rect, logical_rect; + pango_font_get_glyph_extents(_SELF(self), + NUM2UINT(glyph), + &ink_rect, &logical_rect); + + return rb_assoc_new(PANGORECTANGLE2RVAL(&ink_rect), + PANGORECTANGLE2RVAL(&logical_rect)); + +} + +static VALUE +rg_metrics(int argc, VALUE *argv, VALUE self) +{ + VALUE language; + PangoLanguage* lang = NULL; + + rb_scan_args(argc, argv, "01", &language); + + if (!NIL_P(language)) + lang = RVAL2PANGOLANGUAGE(language); + + return PANGOFONTMETRICS2RVAL(pango_font_get_metrics(_SELF(self), lang)); +} + +#if PANGO_CHECK_VERSION(1,9,0) +static VALUE +rg_font_map(VALUE self) +{ + return GOBJ2RVAL(pango_font_get_font_map(_SELF(self))); +} +#endif + +void +Init_pango_font(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_FONT, "Font", mPango); + + RG_DEF_METHOD(find_shaper, 2); + RG_DEF_METHOD(describe, -1); + RG_DEF_METHOD(get_coverage, 1); + RG_DEF_METHOD(get_glyph_extents, 1); + RG_DEF_METHOD(metrics, -1); + +#if PANGO_CHECK_VERSION(1,9,0) + RG_DEF_METHOD(font_map, 0); +#endif + + G_DEF_CLASS3("PangoXFont", "XFont", mPango); + G_DEF_CLASS3("PangoFT2Font", "FT2Font", mPango); + G_DEF_CLASS3("PangoFcFont", "FcFont", mPango); + G_DEF_CLASS3("PangoXftFont", "XftFont", mPango); + G_DEF_CLASS3("PangoCairoFcFont", "CairoFcFont", mPango); + G_DEF_CLASS3("PangoCairoFont", "CairoFont", mPango); + G_DEF_CLASS3("PangoCairoWin32Font", "CairoWin32Font", mPango); +#if PANGO_CHECK_VERSION(1,12,0) + G_DEF_CLASS3("PangoATSUIFont", "ATSUIFont", mPango); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontdescription.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontdescription.c new file mode 100644 index 0000000..31f0066 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontdescription.c @@ -0,0 +1,287 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011-2013 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cFontDescription +#define _SELF(self) (RVAL2PANGOFONTDESCRIPTION(self)) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE str; + PangoFontDescription *description; + + rb_scan_args(argc, argv, "01", &str); + + if (NIL_P(str)) { + description = pango_font_description_new(); + } else { + description = pango_font_description_from_string(RVAL2CSTR(str)); + } + + G_INITIALIZE(self, description); + + return Qnil; +} +/* +PangoFontDescription* pango_font_description_copy + (const PangoFontDescription *desc); +PangoFontDescription* pango_font_description_copy_static + (const PangoFontDescription *desc); +*/ + +static VALUE +rg_hash(VALUE self) +{ + return UINT2NUM(pango_font_description_hash(_SELF(self))); +} + +static VALUE +rg_operator_font_desc_equal(VALUE self, VALUE other) +{ + return CBOOL2RVAL(pango_font_description_equal(_SELF(self), _SELF(other))); +} + +/* Don't we need this? +void pango_font_descriptions_free (PangoFontDescription **descs, + int n_descs); +*/ + +static VALUE +rg_set_family(VALUE self, VALUE family) +{ + pango_font_description_set_family(_SELF(self), RVAL2CSTR(family)); + return self; +} +/* Don't we need this? +void pango_font_description_set_family_static + (PangoFontDescription *desc, + const char *family); +*/ + +static VALUE +rg_family(VALUE self) +{ + return CSTR2RVAL(pango_font_description_get_family(_SELF(self))); +} + +static VALUE +rg_set_style(VALUE self, VALUE style) +{ + pango_font_description_set_style(_SELF(self), RVAL2PANGOSTYLE(style)); + return self; +} + +static VALUE +rg_style(VALUE self) +{ + return PANGOSTYLE2RVAL(pango_font_description_get_style(_SELF(self))); +} + +static VALUE +rg_set_variant(VALUE self, VALUE variant) +{ + pango_font_description_set_variant(_SELF(self), RVAL2PANGOVARIANT(variant)); + return self; +} + +static VALUE +rg_variant(VALUE self) +{ + return PANGOVARIANT2RVAL(pango_font_description_get_variant(_SELF(self))); +} + +static VALUE +rg_set_weight(VALUE self, VALUE weight) +{ + pango_font_description_set_weight(_SELF(self), + RVAL2PANGOWEIGHT(weight)); + return self; +} + +static VALUE +rg_weight(VALUE self) +{ + return PANGOWEIGHT2RVAL(pango_font_description_get_weight(_SELF(self))); +} + +static VALUE +rg_set_stretch(VALUE self, VALUE stretch) +{ + pango_font_description_set_stretch(_SELF(self), RVAL2PANGOSTRETCH(stretch)); + return self; +} + +static VALUE +rg_stretch(VALUE self) +{ + return PANGOSTRETCH2RVAL(pango_font_description_get_stretch(_SELF(self))); +} + +static VALUE +rg_set_size(VALUE self, VALUE size) +{ + pango_font_description_set_size(_SELF(self), NUM2INT(size)); + return self; +} + +static VALUE +rg_size(VALUE self) +{ + return INT2NUM(pango_font_description_get_size(_SELF(self))); +} + +#if PANGO_CHECK_VERSION(1,8,0) +static VALUE +rg_set_absolute_size(VALUE self, VALUE size) +{ + pango_font_description_set_absolute_size(_SELF(self), NUM2INT(size)); + return self; +} + +static VALUE +rg_size_is_absolute_p(VALUE self) +{ + return CBOOL2RVAL(pango_font_description_get_size_is_absolute(_SELF(self))); +} +#endif + +#if PANGO_CHECK_VERSION(1,16,0) +static VALUE +rg_gravity(VALUE self) +{ + return PANGOGRAVITY2RVAL(pango_font_description_get_gravity(_SELF(self))); +} + +static VALUE +rg_set_gravity(VALUE self, VALUE gravity) +{ + pango_font_description_set_gravity(_SELF(self), RVAL2PANGOGRAVITY(gravity)); + return self; +} +#endif + +static VALUE +rg_set_fields(VALUE self) +{ + return PANGOFONTMASK2RVAL(pango_font_description_get_set_fields(_SELF(self))); +} + +static VALUE +rg_unset_fields(VALUE self, VALUE to_unset) +{ + pango_font_description_unset_fields(_SELF(self), RVAL2PANGOFONTMASK(to_unset)); + return self; +} + +static VALUE +rg_merge(VALUE self, VALUE desc_to_merge, VALUE replace_existing) +{ + pango_font_description_merge(_SELF(self), _SELF(desc_to_merge), + RVAL2CBOOL(replace_existing)); + return self; +} + +/* Don't we need this? +void pango_font_description_merge_static + (PangoFontDescription *desc, + const PangoFontDescription *desc_to_merge, + gboolean replace_existing); +*/ + +static VALUE +rg_better_match(VALUE self, VALUE old_match, VALUE new_match) +{ + return CBOOL2RVAL(pango_font_description_better_match(_SELF(self), + _SELF(old_match), + _SELF(new_match))); +} + +static VALUE +rg_to_str(VALUE self) +{ + return CSTR2RVAL(pango_font_description_to_string(_SELF(self))); +} + +static VALUE +rg_to_filename(VALUE self) +{ + return CSTR2RVAL(pango_font_description_to_filename(_SELF(self))); +} + +void +Init_pango_font_description(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_FONT_DESCRIPTION, "FontDescription", mPango); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(hash, 0); + RG_DEF_METHOD_OPERATOR("==", font_desc_equal, 1); + RG_DEF_METHOD(set_family, 1); + RG_DEF_METHOD(family, 0); + RG_DEF_METHOD(set_style, 1); + RG_DEF_METHOD(style, 0); + RG_DEF_METHOD(set_variant, 1); + RG_DEF_METHOD(variant, 0); + RG_DEF_METHOD(set_weight, 1); + RG_DEF_METHOD(weight, 0); + RG_DEF_METHOD(set_stretch, 1); + RG_DEF_METHOD(stretch, 0); + RG_DEF_METHOD(set_size, 1); + RG_DEF_METHOD(size, 0); + +#if PANGO_CHECK_VERSION(1,8,0) + RG_DEF_METHOD(set_absolute_size, 1); + RG_DEF_METHOD_P(size_is_absolute, 0); +#endif +#if PANGO_CHECK_VERSION(1,16,0) + RG_DEF_METHOD(set_gravity, 1); + RG_DEF_METHOD(gravity, 0); +#endif + RG_DEF_METHOD(set_fields, 0); + RG_DEF_METHOD(unset_fields, 1); + RG_DEF_METHOD(merge, 2); + RG_DEF_METHOD(better_match, 2); + RG_DEF_METHOD(to_str, 0); + RG_DEF_ALIAS("to_s", "to_str"); + RG_DEF_METHOD(to_filename, 0); + + /* PangoStyle */ + G_DEF_CLASS(PANGO_TYPE_STYLE, "Style", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, PANGO_TYPE_STYLE, "PANGO_"); + + /* PangoWeight */ + G_DEF_CLASS(PANGO_TYPE_WEIGHT, "Weight", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, PANGO_TYPE_WEIGHT, "PANGO_"); + + /* PangoVariant */ + G_DEF_CLASS(PANGO_TYPE_VARIANT, "Variant", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, PANGO_TYPE_VARIANT, "PANGO_"); + + /* PangoStretch */ + G_DEF_CLASS(PANGO_TYPE_STRETCH, "Stretch", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, PANGO_TYPE_STRETCH, "PANGO_"); + + /* PangoFontMask */ + G_DEF_CLASS(PANGO_TYPE_FONT_MASK, "FontMask", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, PANGO_TYPE_FONT_MASK, "PANGO_"); +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontface.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontface.c new file mode 100644 index 0000000..d3c1a94 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontface.c @@ -0,0 +1,79 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh <mutoh@highway.ne.jp> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cFontFace +#define _SELF(self) (RVAL2PANGOFONTFACE(self)) + +static VALUE +rg_name(VALUE self) +{ + return CSTR2RVAL(pango_font_face_get_face_name(_SELF(self))); +} + +static VALUE +rg_describe(VALUE self) +{ + return PANGOFONTDESCRIPTION2RVAL(pango_font_face_describe(_SELF(self))); +} + +#if PANGO_CHECK_VERSION(1,4,0) +static VALUE +rg_sizes(VALUE self) +{ + int n_sizes; + int* sizes; + int i; + VALUE result; + + pango_font_face_list_sizes(_SELF(self), + &sizes, + &n_sizes); + + result = rb_ary_new(); + for (i = 0; i < n_sizes; i++) + rb_ary_push(result, GOBJ2RVAL(&sizes[i])); + + g_free(sizes); + return result; +} +#endif + +void +Init_pango_font_face(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_FONT_FACE, "FontFace", mPango); + + RG_DEF_METHOD(name, 0); + RG_DEF_METHOD(describe, 0); +#if PANGO_CHECK_VERSION(1,4,0) + RG_DEF_METHOD(sizes, 0); +#endif + G_DEF_CLASS3("PangoFcFace", "FcFace", mPango); + G_DEF_CLASS3("PangoFT2Face", "FT2Face", mPango); + G_DEF_CLASS3("PangoXftFace", "XftFace", mPango); + G_DEF_CLASS3("PangoXFace", "XFace", mPango); + G_DEF_CLASS3("PangoWin32Face", "Win32Face", mPango); +#if PANGO_CHECK_VERSION(1,12,0) + G_DEF_CLASS3("PangoATSUIFace", "ATSUIFace", mPango); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontfamily.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontfamily.c new file mode 100644 index 0000000..5c01cce --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontfamily.c @@ -0,0 +1,82 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cFontFamily +#define _SELF(self) (RVAL2PANGOFONTFAMILY(self)) + +static VALUE +rg_name(VALUE self) +{ + return CSTR2RVAL(pango_font_family_get_name(_SELF(self))); +} + +#ifdef HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE +static VALUE +rg_monospace_p(VALUE self) +{ + return CBOOL2RVAL(pango_font_family_is_monospace(_SELF(self))); +} +#endif + +static VALUE +rg_faces(VALUE self) +{ + int n_faces; + PangoFontFace** faces; + int i; + VALUE result; + + pango_font_family_list_faces(_SELF(self), + &faces, + &n_faces); + + result = rb_ary_new2(n_faces); + for (i = 0; i < n_faces; i++) + rb_ary_store(result, i, GOBJ2RVAL(faces[i])); + + g_free(faces); + + return result; +} + +void +Init_pango_font_family(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_FONT_FAMILY, "FontFamily", mPango); + + RG_DEF_METHOD(name, 0); +#ifdef HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE + RG_DEF_METHOD_P(monospace, 0); +#endif + RG_DEF_METHOD(faces, 0); + + G_DEF_CLASS3("PangoFcFamily", "FcFamily", mPango); + G_DEF_CLASS3("PangoFT2Family", "FT2Family", mPango); + G_DEF_CLASS3("PangoXftFamily", "XftFamily", mPango); + G_DEF_CLASS3("PangoXFamily", "XFamily", mPango); + G_DEF_CLASS3("PangoWin32Family", "Win32Family", mPango); +#if PANGO_CHECK_VERSION(1,12,0) + G_DEF_CLASS3("PangoATSUIFamily", "ATSUIFamily", mPango); +#endif + +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontmap.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontmap.c new file mode 100644 index 0000000..8a4ac8e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontmap.c @@ -0,0 +1,106 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011-2013 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cFontMap +#define _SELF(self) (RVAL2PANGOFONTMAP(self)) + +/* +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, pango_ft2_font_map_new()); + return Qnil; +} +*/ + +static VALUE +rg_load_font(VALUE self, VALUE context, VALUE desc) +{ + return GOBJ2RVAL(pango_font_map_load_font(_SELF(self), + RVAL2PANGOCONTEXT(context), + RVAL2PANGOFONTDESCRIPTION(desc))); +} + +static VALUE +rg_load_fontset(VALUE self, VALUE context, VALUE desc, VALUE lang) +{ + return GOBJ2RVAL(pango_font_map_load_fontset(_SELF(self), + RVAL2PANGOCONTEXT(context), + RVAL2PANGOFONTDESCRIPTION(desc), + RVAL2PANGOLANGUAGE(lang))); +} + +static VALUE +rg_families(VALUE self) +{ + int n_families; + PangoFontFamily** families; + int i; + VALUE result; + + pango_font_map_list_families(_SELF(self), + &families, + &n_families); + + result = rb_ary_new2(n_families); + for (i = 0; i < n_families; i++) + rb_ary_store(result, i, GOBJ2RVAL(families[i])); + + g_free(families); + + return result; +} + +#if PANGO_CHECK_VERSION(1,4,0) +static VALUE +rg_shape_engine_type(VALUE self) +{ + return CSTR2RVAL(pango_font_map_get_shape_engine_type(_SELF(self))); +} +#endif + +void +Init_pango_font_map(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_FONT_MAP, "FontMap", mPango); + + /* + RG_DEF_METHOD(initialize, 0); + */ + RG_DEF_METHOD(load_font, 2); + RG_DEF_METHOD(load_fontset, 3); + RG_DEF_METHOD(families, 0); +#if PANGO_CHECK_VERSION(1,4,0) + RG_DEF_METHOD(shape_engine_type, 0); +#endif + + G_DEF_CLASS3("PangoFcFontMap", "FcFontMap", mPango); + G_DEF_CLASS3("PangoXftFontMap", "XftFontMap", mPango); + G_DEF_CLASS3("PangoFT2FontMap", "FT2FontMap", mPango); + G_DEF_CLASS3("PangoXFontMap", "XFontMap", mPango); + G_DEF_CLASS3("PangoWin32FontMap", "Win32FontMap", mPango); + G_DEF_CLASS3("PangoCoreTextFontMap", "CoreTextFontMap", mPango); + G_DEF_CLASS3("PangoCairoFcFontMap", "CairoFcFontMap", mPango); + G_DEF_CLASS3("PangoCairoWin32FontMap", "CairoWin32FontMap", mPango); + G_DEF_CLASS3("PangoCairoCoreTextFontMap", "CairoCoreTextFontMap", mPango); +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontmetrics.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontmetrics.c new file mode 100644 index 0000000..ad4804d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontmetrics.c @@ -0,0 +1,88 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cFontMetrics +#define _SELF(self) (RVAL2PANGOFONTMETRICS(self)) + +static VALUE +rg_ascent(VALUE self) +{ + return INT2NUM(pango_font_metrics_get_ascent(_SELF(self))); +} + +static VALUE +rg_descent(VALUE self) +{ + return INT2NUM(pango_font_metrics_get_descent(_SELF(self))); +} + +static VALUE +rg_approximate_char_width(VALUE self) +{ + return INT2NUM(pango_font_metrics_get_approximate_char_width(_SELF(self))); +} + +static VALUE +rg_approximate_digit_width(VALUE self) +{ + return INT2NUM(pango_font_metrics_get_approximate_digit_width(_SELF(self))); +} + +#if PANGO_CHECK_VERSION(1,6,0) +static VALUE +rg_underline_thickness(VALUE self) +{ + return INT2NUM(pango_font_metrics_get_underline_thickness(_SELF(self))); +} +static VALUE +rg_underline_position(VALUE self) +{ + return INT2NUM(pango_font_metrics_get_underline_position(_SELF(self))); +} +static VALUE +rg_strikethrough_thickness(VALUE self) +{ + return INT2NUM(pango_font_metrics_get_strikethrough_thickness(_SELF(self))); +} +static VALUE +rg_strikethrough_position(VALUE self) +{ + return INT2NUM(pango_font_metrics_get_strikethrough_position(_SELF(self))); +} +#endif +void +Init_pango_font_metrics(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_FONT_METRICS, "FontMetrics", mPango); + + RG_DEF_METHOD(ascent, 0); + RG_DEF_METHOD(descent, 0); + RG_DEF_METHOD(approximate_char_width, 0); + RG_DEF_METHOD(approximate_digit_width, 0); +#if PANGO_CHECK_VERSION(1,6,0) + RG_DEF_METHOD(underline_thickness, 0); + RG_DEF_METHOD(underline_position, 0); + RG_DEF_METHOD(strikethrough_thickness, 0); + RG_DEF_METHOD(strikethrough_position, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontset.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontset.c new file mode 100644 index 0000000..57e9837 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontset.c @@ -0,0 +1,73 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cFontset +#define _SELF(self) (RVAL2PANGOFONTSET(self)) + +static ID id_call; + +static VALUE +rg_get_font(VALUE self, VALUE wc) +{ + return GOBJ2RVAL(pango_fontset_get_font(_SELF(self), NUM2UINT(wc))); +} + +static VALUE +rg_metrics(VALUE self) +{ + return PANGOFONTMETRICS2RVAL(pango_fontset_get_metrics(_SELF(self))); +} + +#if PANGO_CHECK_VERSION(1,4,0) +static gboolean +fontset_each(PangoFontset *fontset, PangoFont *font, gpointer func) +{ + return RVAL2CBOOL(rb_funcall((VALUE)func, id_call, + 2, GOBJ2RVAL(fontset), GOBJ2RVAL(font))); +} + +static VALUE +rg_each(VALUE self) +{ + VALUE func = rb_block_proc(); + G_RELATIVE(self, func); + pango_fontset_foreach(_SELF(self), + (PangoFontsetForeachFunc)fontset_each, + (gpointer)func); + return self; +} +#endif + +void +Init_pango_fontset(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_FONTSET, "Fontset", mPango); + + id_call = rb_intern("call"); + + RG_DEF_METHOD(get_font, 1); + RG_DEF_METHOD(metrics, 0); +#if PANGO_CHECK_VERSION(1,4,0) + RG_DEF_METHOD(each, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontsetsimple.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontsetsimple.c new file mode 100644 index 0000000..196a7d0 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangofontsetsimple.c @@ -0,0 +1,60 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#ifdef PANGO_ENABLE_BACKEND + +#define RG_TARGET_NAMESPACE cFontsetSimple +#define _SELF(self) (RVAL2PANGOFONTSETSIMPLE(self)) + +static VALUE +rg_initialize(VALUE self, VALUE lang) +{ + G_INITIALIZE(self, pango_fontset_simple_new(RVAL2PANGOLANGUAGE(lang))); + return Qnil; +} + +static VALUE +rg_append(VALUE self, VALUE font) +{ + pango_fontset_simple_append(_SELF(self), RVAL2PANGOFONT(font)); + return self; +} + +static VALUE +rg_size(VALUE self) +{ + return INT2NUM(pango_fontset_simple_size(_SELF(self))); +} + +#endif +void +Init_pango_fontset_simple(VALUE mPango) +{ +#ifdef PANGO_ENABLE_BACKEND + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_FONTSET_SIMPLE, "FontsetSimple", mPango); + + RG_DEF_METHOD(initialize, 1); + RG_DEF_METHOD(append, 1); + RG_DEF_METHOD(size, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoglyphinfo.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoglyphinfo.c new file mode 100644 index 0000000..0d5269d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoglyphinfo.c @@ -0,0 +1,123 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cGlyphInfo +#define _SELF(self) (RVAL2PANGOGLYPHINFO(self)) + +/**********************************/ +static PangoGlyphInfo * +pango_glyph_info_copy(const PangoGlyphInfo *info) +{ + PangoGlyphInfo *data; + + g_return_val_if_fail(info != NULL, NULL); + + data = g_new(PangoGlyphInfo, 1); + *data = *info; + + return data; +} + +GType +pango_glyph_info_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("PangoGlyphInfo", + (GBoxedCopyFunc)pango_glyph_info_copy, + (GBoxedFreeFunc)g_free); + return our_type; +} +/**********************************/ + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, g_new0(PangoGlyphInfo, 1)); + return Qnil; +} + +static VALUE +rg_glyph(VALUE self) +{ + return UINT2NUM(_SELF(self)->glyph); +} + +static VALUE +rg_set_glyph(VALUE self, VALUE val) +{ + _SELF(self)->glyph = NUM2UINT(val); + return self; +} + +static VALUE +rg_geometry(VALUE self) +{ + PangoGlyphGeometry geo = _SELF(self)->geometry; + + return rb_ary_new3(3, INT2NUM(geo.width), + INT2NUM(geo.x_offset), INT2NUM(geo.y_offset)); +} + +static VALUE +rg_set_geometry(VALUE self, VALUE width, VALUE x_offset, VALUE y_offset) +{ + PangoGlyphGeometry geo = _SELF(self)->geometry; + + geo.width = NUM2INT(width); + geo.x_offset = NUM2INT(x_offset); + geo.y_offset = NUM2INT(y_offset); + + return self; +} + +/* + This method may be changed in the future following Pango implementation. + */ +static VALUE +rg_cluster_start_p(VALUE self) +{ + return CBOOL2RVAL(_SELF(self)->attr.is_cluster_start); +} + +static VALUE +rg_set_cluster_start(VALUE self, VALUE val) +{ + _SELF(self)->attr.is_cluster_start = RVAL2CBOOL(val); + return self; +} + +void +Init_pango_glyph_info(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_GLYPH_INFO, "GlyphInfo", mPango); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(glyph, 0); + RG_DEF_METHOD(set_glyph, 1); + RG_DEF_METHOD(geometry, 0); + RG_DEF_METHOD(set_geometry, 3); + RG_DEF_METHOD_P(cluster_start, 0); + RG_DEF_METHOD(set_cluster_start, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoglyphitem.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoglyphitem.c new file mode 100644 index 0000000..2bdbcf6 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoglyphitem.c @@ -0,0 +1,133 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#if PANGO_CHECK_VERSION(1,2,0) +#define RG_TARGET_NAMESPACE cGlyphItem +#define _SELF(r) (RVAL2PANGOGLYPHITEM(r)) + +/**********************************/ +#ifndef HAVE_PANGO_GLYPH_ITEM_GET_TYPE +static PangoGlyphItem* +glyph_item_copy(const PangoGlyphItem *ref) +{ + PangoGlyphItem* new_ref; + g_return_val_if_fail (ref != NULL, NULL); + new_ref = g_new(PangoGlyphItem, 1); + *new_ref = *ref; + return new_ref; +} + +# ifndef HAVE_PANGO_GLYPH_ITEM_FREE +void +pango_glyph_item_free(PangoGlyphItem* glyph_item) +{ + if (glyph_item->item) + pango_item_free(glyph_item->item); + if (glyph_item->glyphs) + pango_glyph_string_free(glyph_item->glyphs); + g_free(glyph_item); +} +# endif + +GType +pango_glyph_item_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("PangoGlyphItem", + (GBoxedCopyFunc)glyph_item_copy, + (GBoxedFreeFunc)pango_glyph_item_free); + return our_type; +} +#endif +/**********************************/ + +static VALUE +rg_item(VALUE self) +{ + PangoItem* item = _SELF(self)->item; + return PANGOITEM2RVAL(item); +} + +static VALUE +rg_glyphs(VALUE self) +{ + PangoGlyphString* glyphs = _SELF(self)->glyphs; + return PANGOGLYPHSTRING2RVAL(glyphs); +} + +static VALUE +rg_split(VALUE self, VALUE text, VALUE split_index) +{ + return PANGOGLYPHITEM2RVAL(pango_glyph_item_split(_SELF(self), RVAL2CSTR(text), + NUM2INT(split_index))); +} + +static VALUE +rg_appy_attrs(VALUE self, VALUE text, VALUE attrs) +{ + GSList* list = pango_glyph_item_apply_attrs(_SELF(self), RVAL2CSTR(text), + RVAL2PANGOATTRLIST(attrs)); + + VALUE ret = rb_ary_new(); + + while (list) { + rb_ary_push(ret, PANGOGLYPHITEM2RVAL(list->data)); + pango_glyph_item_free(list->data); + list = list->next; + } + + g_slist_free(list); + return ret; +} + +#if PANGO_CHECK_VERSION(1,6,0) +static VALUE +rg_letter_space(VALUE self, VALUE text, VALUE log_attrs, VALUE letter_spacing) +{ + pango_glyph_item_letter_space(_SELF(self), RVAL2CSTR(text), + RVAL2PANGOLOGATTR(log_attrs), + NUM2INT(letter_spacing)); + return self; +} +#endif +#endif + +void +Init_pango_glyph_item(VALUE mPango) +{ +#if PANGO_CHECK_VERSION(1,2,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_GLYPH_ITEM, "GlyphItem", mPango); + + RG_DEF_METHOD(item, 0); + RG_DEF_METHOD(glyphs, 0); + + RG_DEF_METHOD(split, 2); + RG_DEF_METHOD(appy_attrs, 2); + +#if PANGO_CHECK_VERSION(1,6,0) + RG_DEF_METHOD(letter_space, 3); +#endif +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoglyphstring.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoglyphstring.c new file mode 100644 index 0000000..8cc8481 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoglyphstring.c @@ -0,0 +1,155 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2006 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cGlyphString +#define _SELF(self) (RVAL2PANGOGLYPHSTRING(self)) + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, pango_glyph_string_new()); + return Qnil; +} + +static VALUE +rg_set_size(VALUE self, VALUE len) +{ + pango_glyph_string_set_size(_SELF(self), NUM2INT(len)); + return self; +} + +static VALUE +rg_extents(int argc, VALUE *argv, VALUE self) +{ + VALUE font, start_index, end_index; + PangoRectangle ink_rect; + PangoRectangle logical_rect; + + rb_scan_args(argc, argv, "12", &font, &start_index, &end_index); + + if (NIL_P(start_index)){ + pango_glyph_string_extents(_SELF(self), + RVAL2PANGOFONT(font), + &ink_rect, &logical_rect); + } else { + pango_glyph_string_extents_range(_SELF(self), + NUM2INT(start_index), NUM2INT(end_index), + RVAL2PANGOFONT(font), + &ink_rect, &logical_rect); + } + + return rb_assoc_new(PANGORECTANGLE2RVAL(&ink_rect), + PANGORECTANGLE2RVAL(&logical_rect)); +} + +#if PANGO_CHECK_VERSION(1,14,0) +static VALUE +rg_width(VALUE self) +{ + return INT2NUM(pango_glyph_string_get_width(_SELF(self))); +} +#endif + +static VALUE +rg_index_to_x(VALUE self, VALUE text, VALUE analysis, VALUE index, VALUE trailing) +{ + int x_pos; + StringValue(text); + + pango_glyph_string_index_to_x(_SELF(self), + /* NOTE: This is a bug in the signature of + * pango_glyph_string_index_to_x */ + (char *)RSTRING_PTR(text), + RSTRING_LEN(text), + RVAL2PANGOANALYSIS(analysis), + NUM2INT(index), RVAL2CBOOL(trailing), + &x_pos); + return INT2NUM(x_pos); +} + +static VALUE +rg_x_to_index(VALUE self, VALUE text, VALUE analysis, VALUE x_pos) +{ + int index; + int trailing; + + StringValue(text); + pango_glyph_string_x_to_index(_SELF(self), + /* NOTE: This is a bug in the signature of + * pango_glyph_string_index_to_x */ + (char *)RSTRING_PTR(text), + RSTRING_LEN(text), + RVAL2PANGOANALYSIS(analysis), + NUM2INT(x_pos), + &index, &trailing); + return rb_assoc_new(INT2NUM(index), CBOOL2RVAL(trailing)); +} + +static VALUE +rg_get_logical_widths(VALUE self, VALUE rbtext, VALUE rbembedding_level) +{ + PangoGlyphString *glyphs = _SELF(self); + const char *text = RVAL2CSTR(rbtext); + long length = RSTRING_LEN(rbtext); + int embedding_level = NUM2INT(rbembedding_level); + glong n = g_utf8_strlen(text, length); + int *logical_widths = g_new(int, n); + + pango_glyph_string_get_logical_widths(glyphs, text, length, embedding_level, + logical_widths); + + return GINTS2RVAL_FREE(logical_widths, n); +} + +static VALUE +rg_glyphs(VALUE self) +{ + int i; + PangoGlyphInfo *glyphs = _SELF(self)->glyphs; + gint* log_clusters = _SELF(self)->log_clusters; + + VALUE ret = rb_ary_new(); + for (i = 0; i < _SELF(self)->num_glyphs; i++) { + rb_ary_push(ret, + rb_assoc_new(PANGOGLYPHINFO2RVAL(glyphs + i), + INT2NUM(log_clusters[i]))); + } + return ret; +} + +void +Init_pango_glyph_string(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_GLYPH_STRING, "GlyphString", mPango); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(set_size, 1); + RG_DEF_METHOD(extents, -1); +#if PANGO_CHECK_VERSION(1,14,0) + RG_DEF_METHOD(width, 0); +#endif + RG_DEF_METHOD(index_to_x, 4); + RG_DEF_METHOD(x_to_index, 3); + RG_DEF_METHOD(get_logical_widths, 2); + RG_DEF_METHOD(glyphs, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangogravity.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangogravity.c new file mode 100644 index 0000000..44b64be --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangogravity.c @@ -0,0 +1,54 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#if PANGO_CHECK_VERSION(1,16,0) + +#define RG_TARGET_NAMESPACE mGravity + +static VALUE +rg_s_to_rotation(G_GNUC_UNUSED VALUE self, VALUE gravity) +{ + return rb_float_new(pango_gravity_to_rotation(RVAL2PANGOGRAVITY(gravity))); +} + +static VALUE +rg_s_vertical_p(G_GNUC_UNUSED VALUE self, VALUE gravity) +{ + return CBOOL2RVAL(PANGO_GRAVITY_IS_VERTICAL(RVAL2PANGOGRAVITY(gravity))); +} +#endif + +void +Init_pango_gravity(VALUE mPango) +{ +#if PANGO_CHECK_VERSION(1,16,0) + VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mPango, "Gravity"); + + RG_DEF_SMETHOD(to_rotation, 1); + RG_DEF_SMETHOD_P(vertical, 1); + + G_DEF_CLASS(PANGO_TYPE_GRAVITY, "Gravity", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, PANGO_TYPE_GRAVITY, "PANGO_GRAVITY_"); + G_DEF_CLASS(PANGO_TYPE_GRAVITY_HINT, "Hint", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, PANGO_TYPE_GRAVITY_HINT, "PANGO_GRAVITY_"); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoitem.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoitem.c new file mode 100644 index 0000000..3ba470b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoitem.c @@ -0,0 +1,111 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cItem +#define _SELF(self) (RVAL2PANGOITEM(self)) + +#define ATTR_INT(name)\ +static VALUE \ +item_int_ ## name (VALUE self)\ +{\ + return INT2NUM(_SELF(self)->name);\ +}\ +static VALUE \ +item_int_set_ ## name (VALUE self, VALUE val)\ +{\ + _SELF(self)->name = NUM2INT(val); \ + return self;\ +} + +#define DEF_INT_ACCESSOR(name) \ + rbg_define_method(RG_TARGET_NAMESPACE, G_STRINGIFY(name), item_int_ ## name, 0);\ + rbg_define_method(RG_TARGET_NAMESPACE, G_STRINGIFY(set_ ## name), item_int_set_ ## name, 1); + +/**********************************/ +#if ! PANGO_CHECK_VERSION(1,9,0) +GType +pango_item_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("PangoItem", + (GBoxedCopyFunc)pango_item_copy, + (GBoxedFreeFunc)pango_item_free); + return our_type; +} +#endif +/**********************************/ + +static VALUE +rg_initialize(VALUE self) +{ + G_INITIALIZE(self, pango_item_new()); + return Qnil; +} + +static VALUE +rg_split(VALUE self, VALUE split_index, VALUE split_offset) +{ + return PANGOITEM2RVAL(pango_item_split(_SELF(self), + NUM2INT(split_index), + NUM2INT(split_offset))); +} +/* Move to Pango module (rbpangomain.c) +GList* pango_reorder_items (GList *logical_items); +*/ + +ATTR_INT(offset); +ATTR_INT(length); +ATTR_INT(num_chars); + +static VALUE +rg_analysis(VALUE self) +{ + PangoAnalysis ana = _SELF(self)->analysis; + return PANGOANALYSIS2RVAL(&ana); +} + +static VALUE +rg_set_analysis(VALUE self, VALUE val) +{ + PangoAnalysis* ana = RVAL2PANGOANALYSIS(val); + _SELF(self)->analysis = *ana; + return self; +} + +void +Init_pango_item(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_ITEM, "Item", mPango); + + RG_DEF_METHOD(initialize, 0); + RG_DEF_METHOD(split, 2); + + DEF_INT_ACCESSOR(offset); + DEF_INT_ACCESSOR(length); + DEF_INT_ACCESSOR(num_chars); + + RG_DEF_METHOD(analysis, 0); + RG_DEF_METHOD(set_analysis, 1); +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangolanguage.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangolanguage.c new file mode 100644 index 0000000..8448bd4 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangolanguage.c @@ -0,0 +1,91 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2009 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh <mutoh@highway.ne.jp> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cLanguage +#define _SELF(self) (RVAL2PANGOLANGUAGE(self)) + +static VALUE +rg_s_default(G_GNUC_UNUSED VALUE self) +{ + return PANGOLANGUAGE2RVAL(pango_language_get_default()); +} + +static VALUE +rg_initialize(VALUE self, VALUE language) +{ + G_INITIALIZE(self, pango_language_from_string(RVAL2CSTR(language))); + return Qnil; +} + +static VALUE +rg_s_to_string(G_GNUC_UNUSED VALUE self, VALUE language) +{ + return CSTR2RVAL(pango_language_to_string(RVAL2CSTR(language))); +} + +static VALUE +rg_matches(int argc, VALUE *argv, VALUE self) +{ + VALUE range_list; + + rb_scan_args(argc, argv, "01", &range_list); + + return CBOOL2RVAL(pango_language_matches(_SELF(self), + RVAL2CSTR_ACCEPT_NIL(range_list))); +} + +static VALUE +rg_to_str(VALUE self) +{ + return CSTR2RVAL(pango_language_to_string(_SELF(self))); +} + +#if PANGO_CHECK_VERSION(1,4,0) +/* Moved from Pango::Script */ +static VALUE +rg_includes_script(VALUE self, VALUE script) +{ + return CBOOL2RVAL(pango_language_includes_script(_SELF(self), + RVAL2PANGOSCRIPT(script))); +} +#endif + +void +Init_pango_language(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_LANGUAGE, "Language", mPango); + + RG_DEF_SMETHOD(default, 0); + + RG_DEF_METHOD(initialize, 1); + RG_DEF_SMETHOD(to_string, 1); + RG_DEF_METHOD(matches, -1); + RG_DEF_METHOD(to_str, 0); + RG_DEF_ALIAS("to_s", "to_str"); + +#if PANGO_CHECK_VERSION(1,4,0) + RG_DEF_METHOD(includes_script, 1); +#endif + +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangolayout.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangolayout.c new file mode 100644 index 0000000..14b8dca --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangolayout.c @@ -0,0 +1,555 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cLayout +#define _SELF(self) (RVAL2PANGOLAYOUT(self)) + +static VALUE +rg_initialize(VALUE self, VALUE context) +{ + G_INITIALIZE(self, pango_layout_new(RVAL2PANGOCONTEXT(context))); + return Qnil; +} + +static VALUE +rg_copy(VALUE self) +{ + return GOBJ2RVAL_UNREF(pango_layout_copy(_SELF(self))); +} + +static VALUE +rg_context(VALUE self) +{ + return GOBJ2RVAL(pango_layout_get_context(_SELF(self))); +} + +static VALUE +rg_context_changed(VALUE self) +{ + pango_layout_context_changed(_SELF(self)); + return Qnil; +} + +static VALUE +rg_set_text(VALUE self, VALUE text) +{ + StringValue(text); + + pango_layout_set_text(_SELF(self), RSTRING_PTR(text), RSTRING_LEN(text)); + + return self; +} + +static VALUE +rg_text(VALUE self) +{ + return CSTR2RVAL(pango_layout_get_text(_SELF(self))); +} + +static VALUE +rg_set_markup(int argc, VALUE *argv, VALUE self) +{ + VALUE markup, accel_marker; + gunichar accel_char = 0; + + rb_scan_args(argc, argv, "11", &markup, &accel_marker); + + StringValue(markup); + + if (NIL_P(accel_marker)){ + pango_layout_set_markup(_SELF(self), + RSTRING_PTR(markup), + RSTRING_LEN(markup)); + } else { + pango_layout_set_markup_with_accel(_SELF(self), + RSTRING_PTR(markup), + RSTRING_LEN(markup), + NUM2CHR(accel_marker), &accel_char); + } + return CHR2FIX(accel_char); +} + +static VALUE +rg_operator_layout_set_markup_eq(VALUE self, VALUE markup) +{ + StringValue(markup); + + pango_layout_set_markup(_SELF(self), RSTRING_PTR(markup), RSTRING_LEN(markup)); + + return markup; +} + +static VALUE +rg_set_attributes(VALUE self, VALUE attrs) +{ + pango_layout_set_attributes(_SELF(self), + RVAL2PANGOATTRLIST(attrs)); + return self; +} + +static VALUE +rg_attributes(VALUE self) +{ + return PANGOATTRLIST2RVAL(pango_layout_get_attributes(_SELF(self))); +} + +static VALUE +rg_set_font_description(VALUE self, VALUE rb_desc) +{ + PangoFontDescription *desc; + gboolean desc_created = FALSE; + + if (RVAL2CBOOL(rb_obj_is_kind_of(rb_desc, rb_cString))) { + desc = pango_font_description_from_string(RVAL2CSTR(rb_desc)); + desc_created = TRUE; + } else { + desc = RVAL2PANGOFONTDESCRIPTION(rb_desc); + } + + pango_layout_set_font_description(_SELF(self), desc); + + if (desc_created) + pango_font_description_free(desc); + + return self; +} + +#ifdef HAVE_PANGO_LAYOUT_GET_FONT_DESCRIPTION +static VALUE +rg_font_description(VALUE self) +{ + const PangoFontDescription* desc = pango_layout_get_font_description(_SELF(self)); + return PANGOFONTDESCRIPTION2RVAL((gpointer)desc); +} +#endif + +static VALUE +rg_set_width(VALUE self, VALUE width) +{ + pango_layout_set_width(_SELF(self), NUM2INT(width)); + return self; +} + +static VALUE +rg_width(VALUE self) +{ + return INT2NUM(pango_layout_get_width(_SELF(self))); +} + +static VALUE +rg_set_wrap(VALUE self, VALUE wrap) +{ + pango_layout_set_wrap(_SELF(self), RVAL2PANGOWRAPMODE(wrap)); + return self; +} + +static VALUE +rg_wrap(VALUE self) +{ + return PANGOWRAPMODE2RVAL(pango_layout_get_wrap(_SELF(self))); +} + +#ifdef HAVE_PANGO_LAYOUT_SET_ELLIPSIZE +static VALUE +rg_set_ellipsize(VALUE self, VALUE ellipsize) +{ + pango_layout_set_ellipsize(_SELF(self), RVAL2PANGOELLIPSIZEMODE(ellipsize)); + return self; +} +static VALUE +rg_ellipsize(VALUE self) +{ + return PANGOELLIPSIZEMODE2RVAL(pango_layout_get_ellipsize(_SELF(self))); +} +#endif + +static VALUE +rg_set_indent(VALUE self, VALUE indent) +{ + pango_layout_set_indent(_SELF(self), NUM2INT(indent)); + return self; +} + +static VALUE +rg_indent(VALUE self) +{ + return INT2NUM(pango_layout_get_indent(_SELF(self))); +} + +static VALUE +rg_spacing(VALUE self) +{ + return INT2NUM(pango_layout_get_spacing(_SELF(self))); +} + +static VALUE +rg_set_spacing(VALUE self, VALUE spacing) +{ + pango_layout_set_spacing(_SELF(self), NUM2INT(spacing)); + return self; +} + +static VALUE +rg_set_justify(VALUE self, VALUE justify) +{ + pango_layout_set_justify(_SELF(self), RVAL2CBOOL(justify)); + return self; +} +static VALUE +rg_justify_p(VALUE self) +{ + return CBOOL2RVAL(pango_layout_get_justify(_SELF(self))); +} + +#if PANGO_CHECK_VERSION(1,4,0) +static VALUE +rg_set_auto_dir(VALUE self, VALUE auto_dir) +{ + pango_layout_set_auto_dir(_SELF(self), RVAL2CBOOL(auto_dir)); + return self; +} +static VALUE +rg_auto_dir_p(VALUE self) +{ + return CBOOL2RVAL(pango_layout_get_auto_dir(_SELF(self))); +} +#endif + +static VALUE +rg_set_alignment(VALUE self, VALUE align) +{ + pango_layout_set_alignment(_SELF(self), RVAL2PANGOALIGNMENT(align)); + return self; +} + +static VALUE +rg_alignment(VALUE self) +{ + return PANGOALIGNMENT2RVAL(pango_layout_get_alignment(_SELF(self))); +} + +static VALUE +rg_set_tabs(VALUE self, VALUE tabs) +{ + pango_layout_set_tabs(_SELF(self), + RVAL2PANGOTABARRAY(tabs)); + return self; +} + +static VALUE +rg_tabs(VALUE self) +{ + VALUE ret = Qnil; + PangoTabArray* tabs = pango_layout_get_tabs(_SELF(self)); + + if (tabs) { + ret = PANGOTABARRAY2RVAL(tabs); + pango_tab_array_free(tabs); + } + return ret; +} + +static VALUE +rg_set_single_paragraph_mode(VALUE self, VALUE setting) +{ + pango_layout_set_single_paragraph_mode(_SELF(self), RVAL2CBOOL(setting)); + return self; +} + +static VALUE +rg_single_paragraph_mode_p(VALUE self) +{ + return CBOOL2RVAL(pango_layout_get_single_paragraph_mode(_SELF(self))); +} + +static VALUE +rg_log_attrs(VALUE self) +{ + PangoLogAttr* attrs; + gint i, n_attrs; + VALUE ary; + + pango_layout_get_log_attrs(_SELF(self), &attrs, &n_attrs); + + ary = rb_ary_new(); + + for (i = 0; i < n_attrs; i++) { + rb_ary_assoc(ary, PANGOLOGATTR2RVAL(&attrs[i])); + } + g_free(attrs); + + return ary; +} + +static VALUE +rg_xy_to_index(VALUE self, VALUE x, VALUE y) +{ + int index, trailing; + gboolean ret = pango_layout_xy_to_index(_SELF(self), + NUM2INT(x), NUM2INT(y), + &index, &trailing); + + return rb_ary_new3(3, CBOOL2RVAL(ret), INT2NUM(index), INT2NUM(trailing)); +} + +static VALUE +rg_index_to_pos(VALUE self, VALUE index) +{ + PangoRectangle pos; + pango_layout_index_to_pos(_SELF(self), NUM2INT(index), &pos); + return PANGORECTANGLE2RVAL(&pos); +} + +static VALUE +rg_get_cursor_pos(VALUE self, VALUE index) +{ + PangoRectangle strong_pos, weak_pos; + pango_layout_get_cursor_pos(_SELF(self), NUM2INT(index), &strong_pos, &weak_pos); + return rb_ary_new3(2, PANGORECTANGLE2RVAL(&strong_pos), + PANGORECTANGLE2RVAL(&weak_pos)); +} + +static VALUE +rg_move_cursor_visually(VALUE self, VALUE strong, VALUE old_index, VALUE old_trailing, VALUE direction) +{ + int new_index, new_trailing; + pango_layout_move_cursor_visually(_SELF(self), RVAL2CBOOL(strong), + NUM2INT(old_index), NUM2INT(old_trailing), + NUM2INT(direction), + &new_index, &new_trailing); + return rb_ary_new3(2, INT2NUM(new_index), INT2NUM(new_trailing)); +} + +static VALUE +rg_get_extents(int argc, VALUE *argv, VALUE self) +{ + VALUE ink_rect, logical_rect; + PangoRectangle rink, rlog; + + rb_scan_args(argc, argv, "02", &ink_rect, &logical_rect); + + if (NIL_P(ink_rect)){ + rink.x = 0; + rink.y = 0; + rink.width = 0; + rink.height = 0; + } else { + PangoRectangle* rect = RVAL2PANGORECTANGLE(ink_rect); + rink.x = rect->x; + rink.y = rect->y; + rink.width = rect->width; + rink.height = rect->height; + } + if (NIL_P(logical_rect)){ + rlog.x = 0; + rlog.y = 0; + rlog.width = 0; + rlog.height = 0; + } else { + PangoRectangle* rect = RVAL2PANGORECTANGLE(logical_rect); + rlog.x = rect->x; + rlog.y = rect->y; + rlog.width = rect->width; + rlog.height = rect->height; + } + + pango_layout_get_extents(_SELF(self), &rink, &rlog); + + return rb_assoc_new(PANGORECTANGLE2RVAL(&rink), + PANGORECTANGLE2RVAL(&rlog)); +} + +static VALUE +rg_extents(VALUE self) +{ + PangoRectangle rink = {0, 0, 0, 0}; + PangoRectangle rlog = {0, 0, 0, 0}; + + pango_layout_get_extents(_SELF(self), &rink, &rlog); + return rb_assoc_new(PANGORECTANGLE2RVAL(&rink), + PANGORECTANGLE2RVAL(&rlog)); +} + +static VALUE +rg_get_pixel_extents(int argc, VALUE *argv, VALUE self) +{ + VALUE ink_rect, logical_rect; + PangoRectangle rink, rlog; + + rb_scan_args(argc, argv, "02", &ink_rect, &logical_rect); + + if (NIL_P(ink_rect)){ + rink.x = 0; + rink.y = 0; + rink.width = 0; + rink.height = 0; + } else { + PangoRectangle* rect = RVAL2PANGORECTANGLE(ink_rect); + rink.x = rect->x; + rink.y = rect->y; + rink.width = rect->width; + rink.height = rect->height; + } + if (NIL_P(logical_rect)){ + rlog.x = 0; + rlog.y = 0; + rlog.width = 0; + rlog.height = 0; + } else { + PangoRectangle* rect = RVAL2PANGORECTANGLE(logical_rect); + rlog.x = rect->x; + rlog.y = rect->y; + rlog.width = rect->width; + rlog.height = rect->height; + } + + pango_layout_get_pixel_extents(_SELF(self), &rink, &rlog); + + return rb_assoc_new(PANGORECTANGLE2RVAL(&rink), + PANGORECTANGLE2RVAL(&rlog)); +} + +static VALUE +rg_pixel_extents(VALUE self) +{ + PangoRectangle rink = {0, 0, 0, 0}; + PangoRectangle rlog = {0, 0, 0, 0}; + + pango_layout_get_pixel_extents(_SELF(self), &rink, &rlog); + return rb_assoc_new(PANGORECTANGLE2RVAL(&rink), + PANGORECTANGLE2RVAL(&rlog)); +} + +static VALUE +rg_size(VALUE self) +{ + int width, height; + pango_layout_get_size(_SELF(self), &width, &height); + return rb_ary_new3(2, INT2NUM(width), INT2NUM(height)); +} + +static VALUE +rg_pixel_size(VALUE self) +{ + int width, height; + pango_layout_get_pixel_size(_SELF(self), &width, &height); + return rb_ary_new3(2, INT2NUM(width), INT2NUM(height)); +} + +static VALUE +rg_line_count(VALUE self) +{ + return INT2NUM(pango_layout_get_line_count(_SELF(self))); +} + +static VALUE +rg_get_line(VALUE self, VALUE line) +{ + return PANGOLAYOUTLINE2RVAL(pango_layout_get_line(_SELF(self), NUM2INT(line))); +} + +static VALUE +rg_lines(VALUE self) +{ + return GSLIST2ARY2(pango_layout_get_lines(_SELF(self)), PANGO_TYPE_LAYOUT_LINE); +} + +static VALUE +rg_iter(VALUE self) +{ + return PANGOLAYOUTITER2RVAL(pango_layout_get_iter(_SELF(self))); +} + +void +Init_pango_layout(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_LAYOUT, "Layout", mPango); + + RG_DEF_METHOD(initialize, 1); + RG_DEF_METHOD(copy, 0); + RG_DEF_METHOD(context, 0); + RG_DEF_METHOD(context_changed, 0); + RG_DEF_METHOD(set_text, 1); + RG_DEF_METHOD(text, 0); + RG_DEF_METHOD(set_markup, -1); + RG_DEF_METHOD_OPERATOR("markup=", layout_set_markup_eq, 1); + RG_DEF_METHOD(set_attributes, 1); + RG_DEF_METHOD(attributes, 0); + RG_DEF_METHOD(set_font_description, 1); +#ifdef HAVE_PANGO_LAYOUT_GET_FONT_DESCRIPTION + RG_DEF_METHOD(font_description, 0); +#endif + RG_DEF_METHOD(set_width, 1); + RG_DEF_METHOD(width, 0); + RG_DEF_METHOD(set_wrap, 1); + RG_DEF_METHOD(wrap, 0); +#ifdef HAVE_PANGO_LAYOUT_SET_ELLIPSIZE + RG_DEF_METHOD(set_ellipsize, 1); + RG_DEF_METHOD(ellipsize, 0); +#endif + RG_DEF_METHOD(set_indent, 1); + RG_DEF_METHOD(indent, 0); + RG_DEF_METHOD(spacing, 0); + RG_DEF_METHOD(set_spacing, 1); + RG_DEF_METHOD(set_justify, 1); + RG_DEF_METHOD_P(justify, 0); +#if PANGO_CHECK_VERSION(1,4,0) + RG_DEF_METHOD(set_auto_dir, 1); + RG_DEF_METHOD_P(auto_dir, 0); +#endif + RG_DEF_METHOD(set_alignment, 1); + RG_DEF_METHOD(alignment, 0); + RG_DEF_METHOD(set_tabs, 1); + RG_DEF_METHOD(tabs, 0); + RG_DEF_METHOD(set_single_paragraph_mode, 1); + RG_DEF_METHOD_P(single_paragraph_mode, 0); + RG_DEF_METHOD(log_attrs, 0); + RG_DEF_METHOD(xy_to_index, 2); + RG_DEF_METHOD(index_to_pos, 1); + RG_DEF_METHOD(get_cursor_pos, 1); + RG_DEF_METHOD(move_cursor_visually, 4); + RG_DEF_METHOD(get_extents, -1); + RG_DEF_METHOD(extents, 0); + RG_DEF_METHOD(get_pixel_extents, -1); + RG_DEF_METHOD(pixel_extents, 0); + RG_DEF_METHOD(size, 0); + RG_DEF_METHOD(pixel_size, 0); + RG_DEF_METHOD(line_count, 0); + RG_DEF_METHOD(get_line, 1); + RG_DEF_METHOD(lines, 0); + RG_DEF_METHOD(iter, 0); + + /* PangoWrapMode */ + G_DEF_CLASS(PANGO_TYPE_WRAP_MODE, "WrapMode", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, PANGO_TYPE_WRAP_MODE, "PANGO_"); + + /* PangoAlignment */ + G_DEF_CLASS(PANGO_TYPE_ALIGNMENT, "Alignment", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, PANGO_TYPE_ALIGNMENT, "PANGO_"); + +#ifdef HAVE_PANGO_LAYOUT_SET_ELLIPSIZE + /* PangoEllipsizeMode */ + G_DEF_CLASS(PANGO_TYPE_ELLIPSIZE_MODE, "EllipsizeMode", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, PANGO_TYPE_ELLIPSIZE_MODE, "PANGO_"); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangolayoutiter.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangolayoutiter.c new file mode 100644 index 0000000..834fa59 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangolayoutiter.c @@ -0,0 +1,189 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cLayoutIter +#define _SELF(r) (RVAL2PANGOLAYOUTITER(r)) + +/**********************************/ +#ifndef HAVE_PANGO_LAYOUT_ITER_GET_TYPE +static PangoLayoutIter * +layout_iter_copy(const PangoLayoutIter *ref) +{ + return (PangoLayoutIter *)ref; +} + +GType +pango_layout_iter_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("PangoLayoutIter", + (GBoxedCopyFunc)layout_iter_copy, + (GBoxedFreeFunc)pango_layout_iter_free); + return our_type; +} +#endif +/**********************************/ + +static VALUE +rg_next_run_bang(VALUE self) +{ + return CBOOL2RVAL(pango_layout_iter_next_run(_SELF(self))); +} + +static VALUE +rg_next_char_bang(VALUE self) +{ + return CBOOL2RVAL(pango_layout_iter_next_char(_SELF(self))); +} + +static VALUE +rg_next_cluster_bang(VALUE self) +{ + return CBOOL2RVAL(pango_layout_iter_next_cluster(_SELF(self))); +} + +static VALUE +rg_next_line_bang(VALUE self) +{ + return CBOOL2RVAL(pango_layout_iter_next_line(_SELF(self))); +} + +static VALUE +rg_at_last_line_p(VALUE self) +{ + return CBOOL2RVAL(pango_layout_iter_at_last_line(_SELF(self))); +} + +static VALUE +rg_index(VALUE self) +{ + return INT2NUM(pango_layout_iter_get_index(_SELF(self))); +} + +static VALUE +rg_baseline(VALUE self) +{ + return INT2NUM(pango_layout_iter_get_baseline(_SELF(self))); +} + +static VALUE +rg_run(VALUE self) +{ + PangoLayoutRun* run = pango_layout_iter_get_run(_SELF(self)); + return PANGOGLYPHITEM2RVAL(run); +} + +static VALUE +rg_line(VALUE self) +{ + return PANGOLAYOUTLINE2RVAL(pango_layout_iter_get_line(_SELF(self))); +} + +static VALUE +rg_char_extents(VALUE self) +{ + PangoRectangle logical_rect; + + pango_layout_iter_get_char_extents(_SELF(self), &logical_rect); + return PANGORECTANGLE2RVAL(&logical_rect); +} + +static VALUE +rg_cluster_extents(VALUE self) +{ + PangoRectangle ink_rect, logical_rect; + + pango_layout_iter_get_cluster_extents(_SELF(self), &ink_rect, &logical_rect); + + return rb_assoc_new(PANGORECTANGLE2RVAL(&ink_rect), + PANGORECTANGLE2RVAL(&logical_rect)); +} + +static VALUE +rg_run_extents(VALUE self) +{ + PangoRectangle ink_rect, logical_rect; + + pango_layout_iter_get_run_extents(_SELF(self), &ink_rect, &logical_rect); + + return rb_assoc_new(PANGORECTANGLE2RVAL(&ink_rect), + PANGORECTANGLE2RVAL(&logical_rect)); +} + +static VALUE +rg_line_yrange(VALUE self) +{ + int y0, y1; + pango_layout_iter_get_line_yrange(_SELF(self), &y0, &y1); + return rb_assoc_new(INT2NUM(y0), INT2NUM(y1)); +} + +static VALUE +rg_line_extents(VALUE self) +{ + PangoRectangle ink_rect, logical_rect; + + pango_layout_iter_get_line_extents(_SELF(self), &ink_rect, &logical_rect); + + return rb_assoc_new(PANGORECTANGLE2RVAL(&ink_rect), + PANGORECTANGLE2RVAL(&logical_rect)); +} +static VALUE +rg_layout_extents(VALUE self) +{ + PangoRectangle ink_rect, logical_rect; + + pango_layout_iter_get_layout_extents(_SELF(self), &ink_rect, &logical_rect); + + return rb_assoc_new(PANGORECTANGLE2RVAL(&ink_rect), + PANGORECTANGLE2RVAL(&logical_rect)); +} + +void +Init_pango_layout_iter(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_LAYOUT_ITER, "LayoutIter", mPango); + + rbgobj_boxed_not_copy_obj(PANGO_TYPE_LAYOUT_ITER); + + RG_DEF_METHOD_BANG(next_run, 0); + RG_DEF_METHOD_BANG(next_char, 0); + RG_DEF_METHOD_BANG(next_cluster, 0); + RG_DEF_METHOD_BANG(next_line, 0); + RG_DEF_METHOD_P(at_last_line, 0); + /* for backword compatibility. :< */ + RG_DEF_ALIAS("at_last_line!", "at_last_line?"); + RG_DEF_METHOD(index, 0); + RG_DEF_METHOD(baseline, 0); + RG_DEF_METHOD(run, 0); + RG_DEF_METHOD(line, 0); + RG_DEF_METHOD(char_extents, 0); + RG_DEF_METHOD(cluster_extents, 0); + RG_DEF_METHOD(run_extents, 0); + RG_DEF_METHOD(line_yrange, 0); + RG_DEF_METHOD(line_extents, 0); + RG_DEF_METHOD(layout_extents, 0); + +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangolayoutline.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangolayoutline.c new file mode 100644 index 0000000..0949eb1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangolayoutline.c @@ -0,0 +1,272 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002-2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cLayoutLine +#define _SELF(r) (RVAL2PANGOLAYOUTLINE(r)) + +/**********************************/ +#if !PANGO_CHECK_VERSION(1,9,0) +static PangoLayoutLine* +layout_line_copy(PangoLayoutLine *ref) +{ + g_return_val_if_fail (ref != NULL, NULL); + pango_layout_line_ref(ref); + return ref; +} + +GType +pango_layout_line_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("PangoLayoutLine", + (GBoxedCopyFunc)layout_line_copy, + (GBoxedFreeFunc)pango_layout_line_unref); + return our_type; +} +#endif +/**********************************/ + +static VALUE +rg_extents(VALUE self) +{ + PangoRectangle ink_rect, logical_rect; + + pango_layout_line_get_extents(_SELF(self), &ink_rect, &logical_rect); + + return rb_assoc_new(PANGORECTANGLE2RVAL(&ink_rect), + PANGORECTANGLE2RVAL(&logical_rect)); +} + +static VALUE +rg_pixel_extents(VALUE self) +{ + PangoRectangle ink_rect, logical_rect; + + pango_layout_line_get_pixel_extents(_SELF(self), &ink_rect, &logical_rect); + + return rb_assoc_new(PANGORECTANGLE2RVAL(&ink_rect), + PANGORECTANGLE2RVAL(&logical_rect)); +} + +static VALUE +rg_index_to_x(VALUE self, VALUE index, VALUE trailing) +{ + int x_pos; + pango_layout_line_index_to_x(_SELF(self), NUM2INT(index), + RVAL2CBOOL(trailing), &x_pos); + return INT2NUM(x_pos); +} + +static VALUE +rg_x_to_index(VALUE self, VALUE x_pos) +{ + int index, trailing; + + gboolean ret = pango_layout_line_x_to_index(_SELF(self), NUM2INT(x_pos), + &index, &trailing); + return rb_ary_new3(CBOOL2RVAL(ret), INT2NUM(index), INT2NUM(trailing)); +} + +static VALUE +rg_get_x_ranges(VALUE self, VALUE start_index, VALUE end_index) +{ + int* ranges; + int i, n_ranges; + VALUE ary; + + pango_layout_line_get_x_ranges(_SELF(self), NUM2INT(start_index), + NUM2INT(end_index), &ranges, &n_ranges); + + ary = rb_ary_new(); + for (i = 0; i < n_ranges; i++) { + rb_ary_push(ary, INT2NUM(ranges[i])); + } + + g_free(ranges); + return ary; +} + +/* Structure members */ +static VALUE +rg_layout(VALUE self) +{ + return GOBJ2RVAL(_SELF(self)->layout); +} + +static VALUE +rg_set_layout(VALUE self, VALUE val) +{ + _SELF(self)->layout = RVAL2PANGOLAYOUT(val); + return self; +} + +static VALUE +rg_start_index(VALUE self) +{ + return INT2NUM(_SELF(self)->start_index); +} + +static VALUE +rg_set_start_index(VALUE self, VALUE val) +{ + _SELF(self)->start_index = NUM2INT(val); + return self; +} + +static VALUE +rg_length(VALUE self) +{ + return INT2NUM(_SELF(self)->length); +} + +static VALUE +rg_set_length(VALUE self, VALUE val) +{ + _SELF(self)->length = NUM2INT(val); + return self; +} + +#if PANGO_CHECK_VERSION(1,2,0) +static VALUE +rg_runs(VALUE self) +{ + GSList* list = _SELF(self)->runs; + VALUE ary = rb_ary_new(); + while (list) { + PangoGlyphItem* old_item = (PangoGlyphItem*)list->data; + PangoGlyphItem new_item; + + new_item.item = pango_item_copy(old_item->item); + new_item.glyphs = pango_glyph_string_copy(old_item->glyphs); + + rb_ary_push(ary, PANGOGLYPHITEM2RVAL(&new_item)); + list = list->next; + } + return ary; +} +#endif + +struct layout_line_set_runs_args { + PangoLayoutLine *line; + VALUE ary; + long n; + GSList *result; +}; + +static VALUE +layout_line_set_runs_body(VALUE value) +{ + struct layout_line_set_runs_args *args = (struct layout_line_set_runs_args *)value; + long i; + + for (i = 0; i < args->n; i++) + args->result = g_slist_append(args->result, + RVAL2PANGOGLYPHITEM(RARRAY_PTR(args->ary)[i])); + + g_slist_free(args->line->runs); + args->line->runs = args->result; + + return Qnil; +} + +static G_GNUC_NORETURN VALUE +layout_line_set_runs_rescue(VALUE value) +{ + g_slist_free(((struct layout_line_set_runs_args *)value)->result); + + rb_exc_raise(rb_errinfo()); +} + +static VALUE +rg_set_runs(VALUE self, VALUE attrs) +{ + struct layout_line_set_runs_args args; + args.line = _SELF(self); + args.ary = rb_ary_to_ary(attrs); + args.n = RARRAY_LEN(args.ary); + args.result = NULL; + + rb_rescue(layout_line_set_runs_body, (VALUE)&args, + layout_line_set_runs_rescue, (VALUE)&args); + + return self; +} + +#if PANGO_CHECK_VERSION(1,4,0) +static VALUE +rg_paragraph_start_p(VALUE self) +{ + return CBOOL2RVAL(_SELF(self)->is_paragraph_start); +} + +static VALUE +rg_set_paragraph_start(VALUE self, VALUE val) +{ + _SELF(self)->is_paragraph_start = RVAL2CBOOL(val); + return self; +} + +static VALUE +rg_resolved_dir(VALUE self) +{ + return UINT2NUM(_SELF(self)->resolved_dir); +} + +static VALUE +rg_set_resolved_dir(VALUE self, VALUE val) +{ + _SELF(self)->resolved_dir = NUM2UINT(val); + return self; +} +#endif + +void +Init_pango_layout_line(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_LAYOUT_LINE, "LayoutLine", mPango); + + RG_DEF_METHOD(extents, 0); + RG_DEF_METHOD(pixel_extents, 0); + RG_DEF_METHOD(index_to_x, 2); + RG_DEF_METHOD(x_to_index, 1); + RG_DEF_METHOD(get_x_ranges, 2); + RG_DEF_METHOD(layout, 0); + RG_DEF_METHOD(set_layout, 1); + RG_DEF_METHOD(start_index, 0); + RG_DEF_METHOD(set_start_index, 1); + RG_DEF_METHOD(length, 0); + RG_DEF_METHOD(set_length, 1); +#if PANGO_CHECK_VERSION(1,2,0) + RG_DEF_METHOD(runs, 0); +#endif + RG_DEF_METHOD(set_runs, 1); + +#if PANGO_CHECK_VERSION(1,4,0) + RG_DEF_METHOD_P(paragraph_start, 0); + RG_DEF_METHOD(set_paragraph_start, 1); + RG_DEF_METHOD(resolved_dir, 0); + RG_DEF_METHOD(set_resolved_dir, 1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangologattr.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangologattr.c new file mode 100644 index 0000000..9174398 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangologattr.c @@ -0,0 +1,114 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cLogAttr +#define _SELF(s) (RVAL2PANGOLOGATTR(s)) + +/**********************************/ +static PangoLogAttr* +log_copy(const PangoLogAttr* val) +{ + PangoLogAttr* new_val; + g_return_val_if_fail (val != NULL, NULL); + new_val = g_new(PangoLogAttr, 1); + *new_val = *val; + return new_val; +} + +GType +pango_log_attr_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("PangoLogAttr", + (GBoxedCopyFunc)log_copy, + (GBoxedFreeFunc)g_free); + return our_type; +} +/**********************************/ + +#define ATTR_BOOL(name)\ +static VALUE \ +log_get_ ## name (VALUE self)\ +{\ + return CBOOL2RVAL(_SELF(self)->name);\ +}\ +static VALUE \ +log_set_ ## name (VALUE self, VALUE val)\ +{\ + _SELF(self)->name = RVAL2CBOOL(val);\ + return self;\ +} + +static VALUE +rg_initialize(VALUE self) +{ + PangoLogAttr attribute; + memset(&attribute, 0, sizeof(PangoLogAttr)); + G_INITIALIZE(self, g_boxed_copy(PANGO_TYPE_LOG_ATTR, &attribute)); + return Qnil; +} + +#define DEFINE_ACCESSOR(logattr, name) \ + rbg_define_method(logattr, G_STRINGIFY(name?), log_get_is_ ## name, 0);\ + rbg_define_method(logattr, G_STRINGIFY(set_ ## name), log_set_is_ ## name, 1); + +ATTR_BOOL(is_line_break); +ATTR_BOOL(is_mandatory_break); +ATTR_BOOL(is_char_break); +ATTR_BOOL(is_white); +ATTR_BOOL(is_cursor_position); +ATTR_BOOL(is_word_start); +ATTR_BOOL(is_word_end); +ATTR_BOOL(is_sentence_boundary); +ATTR_BOOL(is_sentence_start); +ATTR_BOOL(is_sentence_end); + +#if PANGO_CHECK_VERSION(1,4,0) +ATTR_BOOL(backspace_deletes_character); +#endif + +void +Init_pango_logattr(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_LOG_ATTR, "LogAttr", mPango); + + RG_DEF_METHOD(initialize, 0); + + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, line_break); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, mandatory_break); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, char_break); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, white); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, cursor_position); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, word_start); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, word_end); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, sentence_boundary); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, sentence_start); + DEFINE_ACCESSOR(RG_TARGET_NAMESPACE, sentence_end); + +#if PANGO_CHECK_VERSION(1,4,0) + rbg_define_method(RG_TARGET_NAMESPACE, "backspace_deletes_character?", log_get_backspace_deletes_character, 0); + rbg_define_method(RG_TARGET_NAMESPACE, "set_backspace_deletes_character", log_set_backspace_deletes_character, 1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangomatrix.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangomatrix.c new file mode 100644 index 0000000..f3974e1 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangomatrix.c @@ -0,0 +1,153 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#if PANGO_CHECK_VERSION(1,6,0) + +#define RG_TARGET_NAMESPACE cMatrix +#define _SELF(self) (RVAL2PANGOMATRIX(self)) + +#define ATTR_FLOAT(name)\ +static VALUE \ +matrix_get_ ## name (VALUE self)\ +{\ + return rb_float_new(_SELF(self)->name);\ +}\ +static VALUE \ +matrix_set_ ## name (VALUE self, VALUE val)\ +{\ + _SELF(self)->name = NUM2DBL(val);\ + return self;\ +} + +#define DEFINE_ACCESSOR(name) \ + rbg_define_method(RG_TARGET_NAMESPACE, G_STRINGIFY(name), matrix_get_ ## name, 0);\ + rbg_define_method(RG_TARGET_NAMESPACE, G_STRINGIFY(set_ ## name), matrix_set_## name, 1); + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + PangoMatrix matrix = PANGO_MATRIX_INIT; + VALUE xx, xy, yx, yy, x0, y0; + + rb_scan_args(argc, argv, "06", &xx, &xy, &yx, &yy, &x0, &y0); + + if (argc > 0){ + matrix.xx = NUM2DBL(xx); + matrix.xy = NUM2DBL(xy); + matrix.yx = NUM2DBL(yx); + matrix.yy = NUM2DBL(yy); + matrix.x0 = NUM2DBL(x0); + matrix.y0 = NUM2DBL(y0); + } + G_INITIALIZE(self, g_boxed_copy(PANGO_TYPE_MATRIX, &matrix)); + return Qnil; +} + +static VALUE +rg_translate_bang(VALUE self, VALUE tx, VALUE ty) +{ + pango_matrix_translate(_SELF(self), NUM2DBL(tx), NUM2DBL(ty)); + return self; +} + +static VALUE +rg_scale_bang(VALUE self, VALUE scale_x, VALUE scale_y) +{ + pango_matrix_scale(_SELF(self), NUM2DBL(scale_x), NUM2DBL(scale_y)); + return self; +} + +static VALUE +rg_rotate_bang(VALUE self, VALUE degrees) +{ + pango_matrix_rotate(_SELF(self), NUM2DBL(degrees)); + return self; +} + +#if PANGO_CHECK_VERSION(1,16,0) +static VALUE +rg_gravity(VALUE self) +{ + return PANGOGRAVITY2RVAL(pango_gravity_get_for_matrix(_SELF(self))); +} +#endif + +static VALUE +rg_concat_bang(VALUE self, VALUE new_matrix) +{ + pango_matrix_concat(_SELF(self), _SELF(new_matrix)); + return self; +} + +#if PANGO_CHECK_VERSION(1,12,0) +static VALUE +rg_font_scale_factor(VALUE self) +{ + return rb_float_new(pango_matrix_get_font_scale_factor(_SELF(self))); +} +#endif + +ATTR_FLOAT(xx); +ATTR_FLOAT(xy); +ATTR_FLOAT(yx); +ATTR_FLOAT(yy); +ATTR_FLOAT(x0); +ATTR_FLOAT(y0); + +static VALUE +rg_to_a(VALUE self) +{ + PangoMatrix* matrix = _SELF(self); + return rb_ary_new3(6, INT2NUM(matrix->xx), INT2NUM(matrix->xy), INT2NUM(matrix->yx), + INT2NUM(matrix->yy), INT2NUM(matrix->x0), INT2NUM(matrix->y0)); +} + +#endif + +void +Init_pango_matrix(VALUE mPango) +{ +#if PANGO_CHECK_VERSION(1,6,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_MATRIX, "Matrix", mPango); + + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD_BANG(translate, 2); + RG_DEF_METHOD_BANG(scale, 2); + RG_DEF_METHOD_BANG(rotate, 1); + RG_DEF_METHOD_BANG(concat, 1); +#if PANGO_CHECK_VERSION(1,12,0) + RG_DEF_METHOD(font_scale_factor, 0); +#endif +#if PANGO_CHECK_VERSION(1,16,0) + RG_DEF_METHOD(gravity, 0); +#endif + RG_DEF_METHOD(to_a, 0); + + DEFINE_ACCESSOR(xx); + DEFINE_ACCESSOR(xy); + DEFINE_ACCESSOR(yx); + DEFINE_ACCESSOR(yy); + DEFINE_ACCESSOR(x0); + DEFINE_ACCESSOR(y0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoprivate.h b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoprivate.h new file mode 100644 index 0000000..1b14542 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoprivate.h @@ -0,0 +1,53 @@ +#ifndef RB_PANGO_PRIVATE_H +#define RB_PANGO_PRIVATE_H + +#include "rbpango.h" + +#ifndef HAVE_RB_ERRINFO +# define rb_errinfo() (ruby_errinfo) +#endif + +#if PANGO_CHECK_VERSION(1,10,0) && defined(HAVE_RB_CAIRO_H) +# define CAIRO_AVAILABLE 1 +#endif + +G_BEGIN_DECLS + +G_GNUC_INTERNAL void Init_pango_analysis(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_attribute(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_attriterator(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_attrlist(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_cairo(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_cairo_context(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_color(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_context(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_coverage(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_engine(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_font(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_font_description(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_font_face(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_font_family(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_font_map(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_font_metrics(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_fontset(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_fontset_simple(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_glyph_info(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_glyph_item(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_glyph_string(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_gravity(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_item(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_language(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_layout(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_layout_iter(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_layout_line(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_logattr(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_matrix(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_rectangle(VALUE mPango); +G_GNUC_INTERNAL void Init_pangorenderer(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_script(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_script_iter(VALUE mPango); +G_GNUC_INTERNAL void Init_pango_array(VALUE mPango); + +G_END_DECLS + +#endif /* RB_PANGO_PRIVATE_H */ diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangorectangle.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangorectangle.c new file mode 100644 index 0000000..1b20eec --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangorectangle.c @@ -0,0 +1,170 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cRectangle +#define _SELF(s) (RVAL2PANGORECTANGLE(s)) + +/**********************************/ +static PangoRectangle* +pango_rectangle_copy(const PangoRectangle *ref) +{ + PangoRectangle* new_ref; + g_return_val_if_fail (ref != NULL, NULL); + new_ref = g_new(PangoRectangle, 1); + *new_ref = *ref; + return new_ref; +} + +GType +pango_rectangle_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("PangoRectangle", + (GBoxedCopyFunc)pango_rectangle_copy, + (GBoxedFreeFunc)g_free); + return our_type; +} +/**********************************/ + +static VALUE +rg_initialize(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height) +{ + PangoRectangle rectangle; + + rectangle.x = NUM2INT(x); + rectangle.y = NUM2INT(y); + rectangle.width = NUM2INT(width); + rectangle.height = NUM2INT(height); + + G_INITIALIZE(self, g_boxed_copy(PANGO_TYPE_RECTANGLE, &rectangle)); + return Qnil; +} + +static VALUE +rg_x(VALUE self) +{ + return INT2NUM(_SELF(self)->x); +} + +static VALUE +rg_y(VALUE self) +{ + return INT2NUM(_SELF(self)->y); +} + +static VALUE +rg_width(VALUE self) +{ + return INT2NUM(_SELF(self)->width); +} + +static VALUE +rg_height(VALUE self) +{ + return INT2NUM(_SELF(self)->height); +} + +static VALUE +rg_set_x(VALUE self, VALUE x) +{ + _SELF(self)->x = NUM2INT(x); + return self; +} + +static VALUE +rg_set_y(VALUE self, VALUE y) +{ + _SELF(self)->y = NUM2INT(y); + return self; +} +static VALUE +rg_set_width(VALUE self, VALUE width) +{ + _SELF(self)->width = NUM2INT(width); + return self; +} + +static VALUE +rg_set_height(VALUE self, VALUE height) +{ + _SELF(self)->height = NUM2INT(height); + return self; +} +static VALUE +rg_to_a(VALUE self) +{ + PangoRectangle* a = _SELF(self); + return rb_ary_new3(4, INT2FIX(a->x), INT2FIX(a->y), + INT2FIX(a->width), INT2FIX(a->height)); +} + +static VALUE +rg_ascent(VALUE self) +{ + PangoRectangle* r =_SELF(self); + return INT2NUM(PANGO_ASCENT(*r)); +} + +static VALUE +rg_descent(VALUE self) +{ + PangoRectangle* r =_SELF(self); + return INT2NUM(PANGO_DESCENT(*r)); +} + +static VALUE +rg_lbearing(VALUE self) +{ + PangoRectangle* r =_SELF(self); + return INT2NUM(PANGO_LBEARING(*r)); +} + +static VALUE +rg_rbearing(VALUE self) +{ + PangoRectangle* r =_SELF(self); + return INT2NUM(PANGO_RBEARING(*r)); +} + +void +Init_pango_rectangle(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_RECTANGLE, "Rectangle", mPango); + RG_DEF_METHOD(initialize, 4); + RG_DEF_METHOD(x, 0); + RG_DEF_METHOD(y, 0); + RG_DEF_METHOD(width, 0); + RG_DEF_METHOD(height, 0); + RG_DEF_METHOD(set_x, 1); + RG_DEF_METHOD(set_y, 1); + RG_DEF_METHOD(set_width, 1); + RG_DEF_METHOD(set_height, 1); + RG_DEF_METHOD(to_a, 0); + + RG_DEF_METHOD(ascent, 0); + RG_DEF_METHOD(descent, 0); + RG_DEF_METHOD(lbearing, 0); + RG_DEF_METHOD(rbearing, 0); +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangorenderer.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangorenderer.c new file mode 100644 index 0000000..121259c --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangorenderer.c @@ -0,0 +1,199 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#if PANGO_CHECK_VERSION(1,8,0) +#define RG_TARGET_NAMESPACE cRenderer +#define _SELF(self) (RVAL2PANGORENDERER(self)) + +static VALUE +rg_draw_layout(VALUE self, VALUE layout, VALUE x, VALUE y) +{ + pango_renderer_draw_layout(_SELF(self), + RVAL2PANGOLAYOUT(layout), + NUM2INT(x), NUM2INT(y)); + return self; +} + +static VALUE +rg_draw_layout_line(VALUE self, VALUE line, VALUE x, VALUE y) +{ + pango_renderer_draw_layout_line(_SELF(self), + RVAL2PANGOLAYOUTLINE(line), + NUM2INT(x), NUM2INT(y)); + return self; +} + +static VALUE +rg_draw_glyphs(VALUE self, VALUE font, VALUE glyphs, VALUE x, VALUE y) +{ + pango_renderer_draw_glyphs(_SELF(self), + RVAL2PANGOFONT(font), + RVAL2PANGOGLYPHSTRING(glyphs), + NUM2INT(x), NUM2INT(y)); + return self; +} + +static VALUE +rg_draw_rectangle(VALUE self, VALUE part, VALUE x, VALUE y, VALUE width, VALUE height) +{ +#ifdef HAVE_PANGO_RENDER_PART_GET_TYPE + pango_renderer_draw_rectangle(_SELF(self), RVAL2PANGORENDERPART(part), + NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height)); +#else + pango_renderer_draw_rectangle(_SELF(self), NUM2INT(part), + NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height)); +#endif + return self; +} + +static VALUE +rg_draw_error_underline(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height) +{ + pango_renderer_draw_error_underline(_SELF(self), + NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height)); + return self; +} + +static VALUE +rg_draw_trapezoid(VALUE self, VALUE part, VALUE y1, VALUE x11, VALUE x21, VALUE y2, VALUE x12, VALUE x22) +{ +#ifdef HAVE_PANGO_RENDER_PART_GET_TYPE + pango_renderer_draw_trapezoid(_SELF(self), + RVAL2PANGORENDERPART(part), + NUM2DBL(y1), NUM2DBL(x11), NUM2DBL(x21), + NUM2DBL(y2), NUM2DBL(x12), NUM2DBL(x22)); +#else + pango_renderer_draw_trapezoid(_SELF(self), NUM2INT(part), + NUM2DBL(y1), NUM2DBL(x11), NUM2DBL(x21), + NUM2DBL(y2), NUM2DBL(x12), NUM2DBL(x22)); +#endif + return self; +} + +static VALUE +rg_draw_glyph(VALUE self, VALUE font, VALUE glyph, VALUE x, VALUE y) +{ + pango_renderer_draw_glyph(_SELF(self), RVAL2PANGOFONT(font), + NUM2INT(glyph), NUM2INT(x), NUM2INT(y)); + return self; +} + +static VALUE +rg_deactivate(VALUE self) +{ + pango_renderer_deactivate(_SELF(self)); + return self; +} + +static VALUE +rg_activate(VALUE self) +{ + pango_renderer_activate(_SELF(self)); + if (rb_block_given_p()) { + rb_ensure(rb_yield, self, rg_deactivate, self); + } + return self; +} + +static VALUE +rg_part_changed(VALUE self, VALUE part) +{ +#ifdef HAVE_PANGO_RENDER_PART_GET_TYPE + pango_renderer_part_changed(_SELF(self), RVAL2PANGORENDERPART(part)); +#else + pango_renderer_part_changed(_SELF(self), NUM2INT(part)); +#endif + return self; +} + +static VALUE +rg_set_color(VALUE self, VALUE part, VALUE color) +{ +#ifdef HAVE_PANGO_RENDER_PART_GET_TYPE + pango_renderer_set_color(_SELF(self), RVAL2PANGORENDERPART(part), + NIL_P(color) ? NULL : RVAL2PANGOCOLOR(color)); +#else + pango_renderer_set_color(_SELF(self), NUM2INT(part), + NIL_P(color) ? NULL : RVAL2PANGOCOLOR(color)); +#endif + return self; +} + +static VALUE +rg_get_color(VALUE self, VALUE part) +{ +#ifdef HAVE_PANGO_RENDER_PART_GET_TYPE + PangoColor* color = pango_renderer_get_color(_SELF(self), + RVAL2PANGORENDERPART(part)); +#else + PangoColor* color = pango_renderer_get_color(_SELF(self),NUM2INT(part)); +#endif + return PANGOCOLOR2RVAL(color); +} + +static VALUE +rg_set_matrix(VALUE self, VALUE matrix) +{ + pango_renderer_set_matrix(_SELF(self), + NIL_P(matrix) ? NULL : RVAL2PANGOMATRIX(matrix)); + return self; +} + +static VALUE +rg_matrix(VALUE self) +{ + const PangoMatrix* matrix = pango_renderer_get_matrix(_SELF(self)); + return PANGOMATRIX2RVAL((PangoMatrix*)matrix); +} + +#endif + +void +Init_pangorenderer(VALUE mPango) +{ +#if PANGO_CHECK_VERSION(1,8,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_RENDERER, "Renderer", mPango); + + RG_DEF_METHOD(draw_layout, 3); + RG_DEF_METHOD(draw_layout_line, 3); + RG_DEF_METHOD(draw_glyphs, 4); + RG_DEF_METHOD(draw_rectangle, 5); + RG_DEF_METHOD(draw_error_underline, 4); + RG_DEF_METHOD(draw_trapezoid, 7); + RG_DEF_METHOD(draw_glyph, 4); + RG_DEF_METHOD(activate, 0); + RG_DEF_METHOD(deactivate, 0); + RG_DEF_METHOD(part_changed, 1); + RG_DEF_METHOD(set_color, 2); + RG_DEF_METHOD(get_color, 1); + RG_DEF_METHOD(set_matrix, 1); + RG_DEF_METHOD(matrix, 0); + + /* PangoRenderPart */ +#ifdef HAVE_PANGO_RENDER_PART_GET_TYPE + G_DEF_CLASS(PANGO_TYPE_RENDER_PART, "Part", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, PANGO_TYPE_RENDER_PART, "PANGO_RENDER_"); +#endif + +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoscript.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoscript.c new file mode 100644 index 0000000..3d5d0fd --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoscript.c @@ -0,0 +1,88 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#if PANGO_CHECK_VERSION(1,4,0) +#define RG_TARGET_NAMESPACE cScript +#define _SELF(r) (RVAL2PANGOSCRIPT(r)) + +static VALUE +rg_s_for_unichar(G_GNUC_UNUSED VALUE self, VALUE ch) +{ + return PANGOSCRIPT2RVAL(pango_script_for_unichar(NUM2UINT(ch))); +} + +static VALUE +rg_sample_language(VALUE self) +{ + PangoLanguage* lang = pango_script_get_sample_language(_SELF(self)); + return PANGOLANGUAGE2RVAL(lang); +} + +#if PANGO_CHECK_VERSION(1,16,0) +static VALUE +rg_get_gravity(int argc, VALUE *argv, VALUE self) +{ + VALUE wide, gravity, gravity_hint; + int n; + PangoGravity g; + + n = rb_scan_args(argc, argv, "21", &gravity, &gravity_hint, &wide); + + if (n == 2) { + g = pango_gravity_get_for_script(_SELF(self), + RVAL2PANGOGRAVITY(gravity), + RVAL2PANGOGRAVITYHINT(gravity_hint)); + } else { +# if PANGO_CHECK_VERSION(1,26,0) + g = pango_gravity_get_for_script_and_width(_SELF(self), + RVAL2CBOOL(wide), + RVAL2PANGOGRAVITY(gravity), + RVAL2PANGOGRAVITYHINT(gravity_hint)); +# else + rb_raise(rb_eArgError, + "the 3rd 'wide' argument requires Pango >= 1.26"); +# endif + } + return PANGOGRAVITY2RVAL(g); +} +#endif + +/* Move to Pango::Language +gboolean pango_language_includes_script (PangoLanguage *language, + PangoScript script); +*/ +#endif + +void +Init_pango_script(VALUE mPango) +{ +#if PANGO_CHECK_VERSION(1,4,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_SCRIPT, "Script", mPango); + + RG_DEF_SMETHOD(for_unichar, 1); + RG_DEF_METHOD(sample_language, 0); +#endif +#if PANGO_CHECK_VERSION(1,16,0) + RG_DEF_METHOD(get_gravity, -1); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoscriptiter.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoscriptiter.c new file mode 100644 index 0000000..601c8e2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangoscriptiter.c @@ -0,0 +1,97 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2005 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#if PANGO_CHECK_VERSION(1,4,0) + +/**********************************/ +static PangoScriptIter* +rbpango_script_iter_copy(PangoScriptIter *ref) +{ +/* + PangoScriptIter* new_ref = pango_script_iter_new("", 0); + g_return_val_if_fail (ref != NULL, NULL); + new_ref = g_new(PangoScriptIter, 1); + *new_ref = *ref; + return new_ref; +*/ + return ref; +} + +GType +pango_script_iter_get_type(void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("PangoScriptIter", + (GBoxedCopyFunc)rbpango_script_iter_copy, + (GBoxedFreeFunc)pango_script_iter_free); + return our_type; +} +/**********************************/ + +#define RG_TARGET_NAMESPACE cScriptIter +#define _SELF(r) (RVAL2PANGOSCRIPTITER(r)) + +static VALUE +rg_initialize(VALUE self, VALUE text) +{ + PangoScriptIter* iter; + + StringValue(text); + iter = pango_script_iter_new(RSTRING_PTR(text), RSTRING_LEN(text)); + G_INITIALIZE(self, iter); + return Qnil; +} + +static VALUE +rg_range(VALUE self) +{ + G_CONST_RETURN char* start; + G_CONST_RETURN char* end; + PangoScript script; + + pango_script_iter_get_range(_SELF(self), &start, &end, &script); + + return rb_ary_new3(3, CSTR2RVAL(start), CSTR2RVAL(end), + PANGOSCRIPT2RVAL(script)); +} + +static VALUE +rg_next_bang(VALUE self) +{ + return CBOOL2RVAL(pango_script_iter_next(_SELF(self))); +} +#endif + +void +Init_pango_script_iter(VALUE mPango) +{ +#if PANGO_CHECK_VERSION(1,4,0) + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_SCRIPT_ITER, "ScriptIter", mPango); + + RG_DEF_METHOD(initialize, 1); + RG_DEF_METHOD(range, 0); + RG_DEF_METHOD_BANG(next, 0); +#endif +} diff --git a/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangotabarray.c b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangotabarray.c new file mode 100644 index 0000000..2f5394a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/ext/pango/rbpangotabarray.c @@ -0,0 +1,128 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ +/* + * Copyright (C) 2011 Ruby-GNOME2 Project Team + * Copyright (C) 2002,2003 Masao Mutoh + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "rbpangoprivate.h" + +#define RG_TARGET_NAMESPACE cTabArray +#define _SELF(self) (RVAL2PANGOTABARRAY(self)) + +static VALUE +rg_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE size, positions_in_pixels, attr_ary; + PangoTabArray *array; + int i; + + rb_scan_args(argc, argv, "2*", &size, &positions_in_pixels, &attr_ary); + + array = pango_tab_array_new(NUM2INT(size), + RVAL2CBOOL(positions_in_pixels)); + G_INITIALIZE(self, array); + + if (! NIL_P(attr_ary)){ + for (i = 0; i < RARRAY_LEN(attr_ary); i++) { + pango_tab_array_set_tab(array, i, + RVAL2PANGOTABALIGN(RARRAY_PTR(RARRAY_PTR(attr_ary)[i])[0]), + FIX2INT(RARRAY_PTR(RARRAY_PTR(attr_ary)[i])[1])); + } + } + + return Qnil; +} +/* This is implemented in rtab_initialize. +PangoTabArray* pango_tab_array_new_with_positions + (gint size, + gboolean positions_in_pixels, + PangoTabAlign first_alignment, + gint first_position, + ...); +*/ +static VALUE +rg_size(VALUE self) +{ + return INT2NUM(pango_tab_array_get_size(_SELF(self))); +} + +static VALUE +rg_resize(VALUE self, VALUE size) +{ + pango_tab_array_resize(_SELF(self), NUM2INT(size)); + return self; +} + +static VALUE +rg_set_tab(VALUE self, VALUE tab_index, VALUE align, VALUE location) +{ + pango_tab_array_set_tab(_SELF(self), NUM2INT(tab_index), RVAL2PANGOTABALIGN(align), + NUM2INT(location)); + return self; +} + +static VALUE +rg_get_tab(VALUE self, VALUE tab_index) +{ + PangoTabAlign align; + gint location; + pango_tab_array_get_tab(_SELF(self), NUM2INT(tab_index), + &align, &location); + return rb_ary_new3(2, PANGOTABALIGN2RVAL(align), INT2NUM(location)); +} + +static VALUE +rg_tabs(VALUE self) +{ + PangoTabAlign* aligns; + gint* locations; + VALUE ary = rb_ary_new(); + PangoTabArray* tab_array = _SELF(self); + gint i; + + pango_tab_array_get_tabs(tab_array, &aligns, &locations); + + for (i = 0; i < pango_tab_array_get_size(tab_array); i++){ + rb_ary_push(ary, rb_ary_new3(2, PANGOTABALIGN2RVAL(aligns[i]), + INT2NUM(locations[i]))); + } + return ary; +} + +static VALUE +rg_positions_in_pixels_p(VALUE self) +{ + return CBOOL2RVAL(pango_tab_array_get_positions_in_pixels(_SELF(self))); +} + +void +Init_pango_array(VALUE mPango) +{ + VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_TAB_ARRAY, "TabArray", mPango); + RG_DEF_METHOD(initialize, -1); + RG_DEF_METHOD(size, 0); + RG_DEF_METHOD(resize, 1); + RG_DEF_METHOD(set_tab, 3); + RG_DEF_METHOD(get_tab, 1); + RG_DEF_METHOD(tabs, 0); + RG_DEF_METHOD_P(positions_in_pixels, 0); + + /* PangoTabAlign */ + G_DEF_CLASS(PANGO_TYPE_TAB_ALIGN, "TabAlign", RG_TARGET_NAMESPACE); + G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, PANGO_TYPE_TAB_ALIGN, "PANGO_"); +} diff --git a/lib/ruby-gtk2-2.0.2/pango/extconf.rb b/lib/ruby-gtk2-2.0.2/pango/extconf.rb new file mode 100644 index 0000000..e048461 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/extconf.rb @@ -0,0 +1,49 @@ +#!/usr/bin/env ruby + +require 'pathname' +require 'mkmf' +require 'rbconfig' +require 'fileutils' + +package = "pango" + +base_dir = Pathname(__FILE__).dirname.expand_path +ext_dir = base_dir + "ext" + package +mkmf_gnome2_dir = base_dir + 'lib' + +ruby = File.join(RbConfig::CONFIG['bindir'], + RbConfig::CONFIG['ruby_install_name'] + + RbConfig::CONFIG["EXEEXT"]) + +build_dir = Pathname("ext") + package +FileUtils.mkdir_p(build_dir.to_s) unless build_dir.exist? +extconf_rb_path = ext_dir + "extconf.rb" +system(ruby, "-C", build_dir.to_s, extconf_rb_path.to_s, *ARGV) || exit(false) + +create_makefile(package) +FileUtils.mv("Makefile", "Makefile.lib") + +File.open("Makefile", "w") do |makefile| + makefile.puts(<<-EOM) +all: + (cd ext/#{package} && $(MAKE)) + $(MAKE) -f Makefile.lib + +install: + (cd ext/#{package} && $(MAKE) install) + $(MAKE) -f Makefile.lib install + +site-install: + (cd ext/#{package} && $(MAKE) site-install) + $(MAKE) -f Makefile.lib site-install + +clean: + (cd ext/#{package} && $(MAKE) clean) + $(MAKE) -f Makefile.lib clean + +distclean: + (cd ext/#{package} && $(MAKE) distclean) + $(MAKE) -f Makefile.lib distclean + @rm -f Makefile.lib +EOM +end diff --git a/lib/ruby-gtk2-2.0.2/pango/lib/pango.rb b/lib/ruby-gtk2-2.0.2/pango/lib/pango.rb new file mode 100644 index 0000000..a540e87 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/lib/pango.rb @@ -0,0 +1,79 @@ +# +# pango.rb +# Copyright(C) 2005, 2009 Ruby-GNOME2 Project. +# +# This program is licenced under the same +# license of Ruby-GNOME2. +# + +require 'glib2' +begin + begin + require 'cairo' + rescue LoadError + require 'rubygems' + require 'cairo' + end +rescue LoadError +end + +base_dir = Pathname.new(__FILE__).dirname.dirname.expand_path +vendor_dir = base_dir + "vendor" + "local" +vendor_bin_dir = vendor_dir + "bin" +GLib.prepend_dll_path(vendor_bin_dir) +begin + major, minor, _ = RUBY_VERSION.split(/\./) + require "#{major}.#{minor}/pango.so" +rescue LoadError + require "pango.so" +end + +if vendor_dir.exist? + begin + require "gobject-introspection" + vendor_girepository_dir = vendor_dir + "lib" + "girepository-1.0" + GObjectIntrospection.prepend_typelib_path(vendor_girepository_dir) + rescue LoadError + end +end + +module Pango + LOG_DOMAIN = "Pango" + + class AttrList + def each(text = nil) + iter = iterator + begin + if text + s, e = iter.range + yield(iter, text[s, e - s], s, e) + else + yield(iter) + end + end while iter.next! + end + end + + # [[klass, prefix], ....]] + targets = [[Layout::Alignment, "ALIGN_"], [AttrScale, "SCALE_"], + [Coverage::Level, "COVERAGE_"], [Context::Direction, "DIRECTION_"], + [Layout::WrapMode, "WRAP_"], [FontDescription::FontMask, "FONT_MASK_"], + [FontDescription::Stretch, "STRETCH_"], [FontDescription::Style, "STYLE_"], + [FontDescription::Variant, "VARIANT_"], [FontDescription::Weight, "WEIGHT_"], + [TabArray::TabAlign, "TAB_"], + [AttrUnderline::Underline, "UNDERLINE_"]] + + targets << [Script, "SCRIPT_"] if defined? Script + targets << [Layout::EllipsizeMode, "ELLIPSIZE_"] if defined? Layout::EllipsizeMode + targets << [Renderer::Part, "PART_"] if defined? Renderer::Part + + targets.each do |klass, prefix| + (klass.constants - klass.superclass.constants).each do |name| + unless klass.const_get(name).is_a? Class + const_set("#{prefix}#{name}", klass.const_get(name)) + end + end + end +end + +GLib::Log.set_log_domain(Pango::LOG_DOMAIN) diff --git a/lib/ruby-gtk2-2.0.2/pango/patches/harfbuzz-0.9.17-disable-uniscribe.diff b/lib/ruby-gtk2-2.0.2/pango/patches/harfbuzz-0.9.17-disable-uniscribe.diff new file mode 100644 index 0000000..d37dcca --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/patches/harfbuzz-0.9.17-disable-uniscribe.diff @@ -0,0 +1,12 @@ +diff -ru harfbuzz-0.9.17.orig/configure.ac harfbuzz-0.9.17/configure.ac +--- harfbuzz-0.9.17.orig/configure.ac 2013-05-20 22:21:57.000000000 +0900 ++++ harfbuzz-0.9.17/configure.ac 2013-05-26 09:01:41.881876729 +0900 +@@ -248,7 +248,7 @@ + LIBS="$LIBS -lusp10 -lgdi32" + AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ +- #define _WIN32_WINNT 0x0600 ++ #define _WIN32_WINNT 0x0501 + #include <windows.h> + #include <usp10.h> + ]], diff --git a/lib/ruby-gtk2-2.0.2/pango/patches/pango-1.34.0-enable-fc-font.diff b/lib/ruby-gtk2-2.0.2/pango/patches/pango-1.34.0-enable-fc-font.diff new file mode 100644 index 0000000..ec8d18f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/patches/pango-1.34.0-enable-fc-font.diff @@ -0,0 +1,14 @@ +diff -ru pango-1.34.0.orig/pango/pangocairo.def pango-1.34.0/pango/pangocairo.def +--- pango-1.34.0.orig/pango/pangocairo.def 2013-01-24 12:39:14.000000000 +0900 ++++ pango-1.34.0/pango/pangocairo.def 2013-05-18 20:28:04.017761164 +0900 +@@ -8,8 +8,8 @@ + pango_cairo_create_context + pango_cairo_create_layout + pango_cairo_error_underline_path +-; pango_cairo_fc_font_get_type +-; pango_cairo_fc_font_map_get_type ++ pango_cairo_fc_font_get_type ++ pango_cairo_fc_font_map_get_type + pango_cairo_font_get_type + pango_cairo_font_get_scaled_font + pango_cairo_font_map_create_context diff --git a/lib/ruby-gtk2-2.0.2/pango/sample/attribute.rb b/lib/ruby-gtk2-2.0.2/pango/sample/attribute.rb new file mode 100644 index 0000000..c2fa94f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/sample/attribute.rb @@ -0,0 +1,82 @@ +=begin + attribute.rb - Ruby/Pango sample script. + + Copyright (c) 2002,2003 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: attribute.rb,v 1.6 2006/06/17 13:37:01 mutoh Exp $ +=end + +require 'pango' + +p a = Pango::AttrSize.new(1) +puts "value = #{a.value}" +puts "start_index = #{a.start_index}" +puts "end_index = #{a.end_index}" + +p a = Pango::AttrStyle.new(Pango::FontDescription::STYLE_NORMAL) +puts "value = #{a.value}" + +p a = Pango::AttrVariant.new(Pango::FontDescription::VARIANT_SMALL_CAPS) +puts "value = #{a.value}" + +p a = Pango::AttrStretch.new(Pango::FontDescription::STRETCH_EXPANDED) +puts "value = #{a.value}" + +p a = Pango::AttrWeight.new(Pango::FontDescription::WEIGHT_BOLD) +puts "value = #{a.value}" + +p a = Pango::AttrRise.new(10) +puts "value = #{a.value}" + +p a = Pango::AttrLanguage.new(Pango::Language.new("ja")) +p a.value +p a.value.to_str + +p a = Pango::AttrFamily.new("family") +p a.value + +p b = Pango::FontDescription.new +p b.to_str +p a = Pango::AttrFontDescription.new(b) +p a.value +p a.value.to_str + +p a = Pango::AttrForeground.new(10, 20, 30) +p a.value +p a.value.to_a + +p a = Pango::AttrBackground.new(20, 30, 40) +p a.value +p a.value.to_a + +p a = Pango::AttrStrikethrough.new(true) +p a.value + +p Pango::AttrUnderline::SINGLE +p a = Pango::AttrUnderline.new(Pango::AttrUnderline::SINGLE) +p a.value + +p ink = Pango::Rectangle.new(1, 2, 3, 4) +p log = Pango::Rectangle.new(5, 6, 7, 8) +p a = Pango::AttrShape.new(ink, log) +p a.value[0].to_a +p a.value[1].to_a + +p a = Pango::AttrScale.new(2.3) +p a.value + +begin + require 'gtk2' +rescue + p "Ruby/GTK2 is not existed." + exit 0 +end + p a = Gdk::PangoAttrEmbossed.new(true) + p a.value + + mask = Gdk::Pixmap.new(Gtk::Window.new.realize.window, 100, 100, 1) + p a = Gdk::PangoAttrStipple.new(mask) + p a.value + + diff --git a/lib/ruby-gtk2-2.0.2/pango/sample/break.rb b/lib/ruby-gtk2-2.0.2/pango/sample/break.rb new file mode 100644 index 0000000..1eae42a --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/sample/break.rb @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +=begin + break.rb - Ruby/Pango sample script. + + Copyright (c) 2005 Ruby-GNOME2 Project + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: break.rb,v 1.1 2005/09/17 17:09:12 mutoh Exp $ +=end + +require 'pango' + +attr = Pango.break("Hello Worldです\n2nd line", Pango::Analysis.new) + +p attr.length +attr.each do |v| + print "line_break:#{v.line_break?}" + print ", mandatory_break:#{v.mandatory_break?}" + print ", char_break:#{v.char_break?}" + print ", white:#{v.white?}" + print ", cursor_position:#{v.cursor_position?}" + print ", word_start:#{v.word_start?}" + print ", word_end:#{v.word_end?}" + print ", sentence_boundary:#{v.sentence_boundary?}" + print ", sentence_start:#{v.sentence_start?}" + print ", sentence_end:#{v.sentence_end?}\n" +end diff --git a/lib/ruby-gtk2-2.0.2/pango/sample/gdk_layout.rb b/lib/ruby-gtk2-2.0.2/pango/sample/gdk_layout.rb new file mode 100644 index 0000000..e7e8d14 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/sample/gdk_layout.rb @@ -0,0 +1,27 @@ +=begin + gdk_layout.rb - Ruby/Pango sample script. + + Copyright (c) 2003-2006 Ruby-GNOME2 Project + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: gdk_layout.rb,v 1.7 2006/06/17 13:36:11 mutoh Exp $ +=end + +require 'gtk2' + +window = Gtk::Window.new("Ruby/Pango sample") +window.signal_connect("destroy"){Gtk.main_quit} +window.realize + +gdkwin = window.window +gc = Gdk::GC.new(gdkwin) + +layout = window.create_pango_layout +layout.set_markup(File.read("sample.txt"), "$") +window.signal_connect("expose_event") do + gdkwin.draw_layout(gc, 10, 10, layout) +end + +window.set_default_size(500,400).show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/pango/sample/glyphstring.rb b/lib/ruby-gtk2-2.0.2/pango/sample/glyphstring.rb new file mode 100755 index 0000000..3eaa8b2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/sample/glyphstring.rb @@ -0,0 +1,61 @@ +#!/usr/bin/env ruby +=begin + glyphstring.rb - Ruby/Pango sample script. + + Copyright (c) 2002-2006 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: glyphstring.rb,v 1.3 2006/06/17 14:16:53 ktou Exp $ +=end + +require 'gtk2' + +str = "Hello World" + +lang = Pango::Language.new("ja_JP") +fd = Pango::FontDescription.new("Sans 18") + +context = Gdk::Pango.context +context.language = lang +context.base_dir = Pango::DIRECTION_LTR +context.font_description = fd + +p font = context.load_font(fd) +family = context.families[10] +puts "#{family.class}, #{family.name}" + +family.faces.each do |face| + puts face.name +end + +p fmap = font.font_map + +p fset = fmap.load_fontset(context, fd, lang) + + +gs = Pango::GlyphString.new + +ink_rect, logical_rect = gs.extents(font) + +p ink_rect.to_a +p logical_rect.to_a + +item = Pango::Item.new +item.analysis.font = font +item.analysis.shape_engine = font.find_shaper(lang, str.codepoints.first) + +gs = Pango.shape(str, item.analysis) + +ink_rect, logical_rect = gs.extents(font, 0, 11) + +p ink_rect.to_a +p logical_rect.to_a + +gs.glyphs.each do |info, log_clusters| + puts "Pango::GlyphInfo: log_clusters = #{log_clusters}, glyph = #{info.glyph}, geometry = #{info.geometry.inspect}, cluster_start? = #{info.cluster_start?}" +end + +p gs.index_to_x(str, item.analysis, 3, false) +p gs.x_to_index(str, item.analysis, 103) + +p logical_widths = gs.get_logical_widths(str, item.analysis.level) diff --git a/lib/ruby-gtk2-2.0.2/pango/sample/item.rb b/lib/ruby-gtk2-2.0.2/pango/sample/item.rb new file mode 100644 index 0000000..4672c44 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/sample/item.rb @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- + +=begin + item.rb - Ruby/Pango sample script. + + Copyright (c) 2005 Ruby-GNOME2 Project + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: item.rb,v 1.3 2006/06/17 13:37:01 mutoh Exp $ +=end + +require 'gtk2' + +str = "Ruby-GNOME2こんにちわ" +win = Gtk::Window.new("Ruby/Pango sample") +win.realize + +p screen = Gdk::Screen.default +p context = Gdk::Pango.context(screen) +p attrlist = Pango::AttrList.new + +p a = Pango::AttrBackground.new(65535, 0, 0) + +attrlist.insert(Pango::AttrBackground.new(65535, 0,0)) + +attrs = [Pango::AttrBackground.new(65535, 0,0), Pango::AttrForeground.new(65535, 0,0)] + +items = context.itemize(Pango::Context::DIRECTION_RTL, str, 0, 40, attrlist) + +items.each do |v| + ana = v.analysis + puts "shape_engine = #{ana.shape_engine}, lang_engine = #{ana.lang_engine}, font = #{ana.font}, level = #{ana.level}" + puts "language = #{ana.language}" + p ana.font.get_glyph_extents("a".codepoints.first)[0].to_a + ana.set_extra_attrs(attrs) + p ana.extra_attrs +end diff --git a/lib/ruby-gtk2-2.0.2/pango/sample/label.rb b/lib/ruby-gtk2-2.0.2/pango/sample/label.rb new file mode 100644 index 0000000..ad30169 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/sample/label.rb @@ -0,0 +1,23 @@ +=begin + label.rb - Ruby/Pango sample script. + + Copyright (c) 2002,2003 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: label.rb,v 1.4 2006/06/17 13:36:11 mutoh Exp $ +=end + +require 'gtk2' + +str = File.read("sample.txt") +attrs, text, accel_char = Pango.parse_markup(str, '$') + +#This is same as Gtk::Label#set_markup() +label = Gtk::Label.new(text) +label.attributes = attrs + +win = Gtk::Window.new +win.signal_connect("destroy"){Gtk.main_quit} +win.add(label).show_all + +Gtk.main diff --git a/lib/ruby-gtk2-2.0.2/pango/sample/layout.rb b/lib/ruby-gtk2-2.0.2/pango/sample/layout.rb new file mode 100644 index 0000000..58e7cff --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/sample/layout.rb @@ -0,0 +1,102 @@ +#!/usr/local/bin/ruby +=begin + layout.rb - Ruby/Pango sample script. + + Copyright (c) 2005 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: layout.rb,v 1.2 2006/06/17 13:36:11 mutoh Exp $ +=end + +require 'gtk2' +require 'pp' + +puts +puts "Start----------" +puts +str = File.read("sample.txt") +context = Gdk::Pango.context +context.base_dir = Pango::Context::DIRECTION_LTR +context.language = Pango::Language.new("ja_JP") +fd = Pango::FontDescription.new("Sans 18") +font = context.load_font(fd) +font_map = context.font_map + +p "context: #{context}" +p "font_desc: #{fd}" +p "font: #{font}" +p "font_map: #{font_map}" + +puts +puts "Pango::Layout----------" +puts +p layout = Pango::Layout.new(context) + +layout.set_markup(str) +layout.font_description = fd +layout.auto_dir = true +layout.alignment = Pango::Layout::ALIGN_LEFT + +p "attributes: #{layout.attributes}" +p "font_description: #{layout.font_description}" +p "width: #{layout.width}" +p "wrap: #{layout.wrap}" +p "ellipsize: #{layout.ellipsize}" +p "indent: #{layout.indent}" +p "spacing: #{layout.spacing}" +p "justify?: #{layout.justify?}" +p "auto_dir?: #{layout.auto_dir?}" +p "alignment: #{layout.alignment.inspect}" +p "tabs: #{layout.tabs}" +p "single_paragraph_mode?: #{layout.single_paragraph_mode?}" +p "size: #{layout.size}" +p "pixel_size: #{layout.pixel_size}" +p "line_count: #{layout.line_count}" + +puts "lines:" +pp layout.lines + +puts +puts "Pango::LayoutIter--------" +puts +iter = layout.iter +p "iter: #{iter}" +p "index: #{iter.index}" +p "baseline: #{iter.baseline}" +p "line: #{iter.line}" +p "char_extents: #{iter.char_extents}" +p "cluster_extents: #{iter.cluster_extents}" +p "run_extents: #{iter.run_extents}" +p "layout_extents: #{iter.layout_extents}" +p "line_extents: #{iter.line_extents}" +p "line_yrange: #{iter.line_yrange}" + +puts +puts "Pango::GlyphItem-------" +puts +glyph = iter.run +p "glyph: #{glyph}" +p "item: #{glyph.item}" +p "glyphs: #{glyph.glyphs}" + +puts +puts "Pango::LayoutLine ----------" +puts + +line = iter.line + +p "line = #{line}" +p "extents: #{line.extents}" +p "pixel_extents: #{line.pixel_extents}" +p "index_to_x: #{line.index_to_x(1, true)}" +p "x_to_index: #{line.x_to_index(1)}" +p "x_ranges: #{line.get_x_ranges(0, 2)}" +p "layout: #{line.layout}" +p "start_index: #{line.start_index}" +p "length: #{line.length}" +p "paragraph_start?: #{line.paragraph_start?}" +p "resolved_dir: #{line.resolved_dir}" +puts "runs:" +pp line.runs +puts +puts "End----------" diff --git a/lib/ruby-gtk2-2.0.2/pango/sample/pango_cairo.rb b/lib/ruby-gtk2-2.0.2/pango/sample/pango_cairo.rb new file mode 100644 index 0000000..0b05a09 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/sample/pango_cairo.rb @@ -0,0 +1,66 @@ +=begin + cairo.rb - Ruby/Pango with cairo sample script. + + Copyright (c) 2005 Ruby-GNOME2 Project + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: pango_cairo.rb,v 1.1 2005/10/15 07:57:52 mutoh Exp $ +=end + +require 'pango' + +unless Pango.cairo_available? + STDERR.puts "This sample requires Pango 1.0.0 or later and cairo support" + exit 1 +end + +filename = ARGV.shift +filename ||= "cairo.png" + +RADIUS = 150 +N_WORDS = 10 +FONT = "Sans Bold 27" + +def draw_text(cr) + # Center coordinates on the middle of the region we are drawing + cr.translate(RADIUS, RADIUS); + + # Create a PangoLayout, set the font and text + layout = cr.create_pango_layout + + layout.set_text("Text") + desc = Pango::FontDescription.new(FONT) + layout.set_font_description(desc) + + # Draw the layout N_WORDS times in a circle + N_WORDS.times do |i| + angle = (360.0 * i) / N_WORDS; + cr.save do + # Gradient from red at angle == 60 to blue at angle == 300 + red = (1 + Math.cos((angle - 60) * Math::PI / 180.0)) / 2 + cr.set_source_rgb(red, 0, 1.0 - red) + cr.rotate(angle * Math::PI / 180.0) + + # Inform Pango to re-layout the text with the new transformation + cr.update_pango_layout(layout) + + width, height = layout.size + cr.move_to(-(width.to_f / Pango::SCALE) / 2, -RADIUS) + cr.show_pango_layout(layout) + end + end +end + +diameter = 2 * RADIUS +surface = Cairo::ImageSurface.new(Cairo::FORMAT_ARGB32, diameter, diameter) +cr = Cairo::Context.new(surface) +cr.set_source_rgb(1.0, 1.0, 1.0) +cr.rectangle(0, 0, diameter, diameter); +cr.fill +draw_text(cr) + +File.open(filename, "wb") do |f| + cr.target.write_to_png(f) +end +# or +# cr.target.write_to_png(filename) diff --git a/lib/ruby-gtk2-2.0.2/pango/sample/parse.rb b/lib/ruby-gtk2-2.0.2/pango/sample/parse.rb new file mode 100644 index 0000000..bf08906 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/sample/parse.rb @@ -0,0 +1,33 @@ +#!/usr/bin/env ruby +=begin + parse.rb - Ruby/Pango sample script. + + Copyright (c) 2002,2003 Ruby-GNOME2 Project Team + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: parse.rb,v 1.4 2005/03/22 17:41:29 silicio Exp $ +=end + +require 'pango' + +str = File.read("sample.txt") +puts str +puts "------" + +attr_list, text, accel_char = Pango.parse_markup(str, '$') +puts "attr_list = #{attr_list}" +puts "text = #{text}" +puts "accel_char = #{accel_char}" +puts "------" + +iterator = attr_list.iterator + +attr_list.each(text) do |iterator, text, start_pos, end_pos| + puts "range = #{start_pos}, #{end_pos}" + puts "text = #{text}" + iterator.get.each do |attr| + puts "#{attr} = #{attr.value}" + end + puts "---" +end + diff --git a/lib/ruby-gtk2-2.0.2/pango/sample/sample.txt b/lib/ruby-gtk2-2.0.2/pango/sample/sample.txt new file mode 100644 index 0000000..471d7f2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/sample/sample.txt @@ -0,0 +1,10 @@ +<u><span foreground="red" size="x-large" style="italic" +lang="en">Hello World!</span></u> <span background="yellow" lang="ja" +font_desc="Sans Italic 20" stretch="normal">こんにちわ世界!</span> + +<span size="xx-large" face="Serif" foreground="#006600" background="#ffffee"> +<span size="larger" underline="double" weight="heavy">Ruby/Pango</span> <span +rise="10000" variant="normal" weight="heavy">$Ruby-GNOME2</span> +</span> + +<span strikethrough="true" size="xx-large" style="oblique" foreground="blue">ABCDEF</span> diff --git a/lib/ruby-gtk2-2.0.2/pango/sample/script.rb b/lib/ruby-gtk2-2.0.2/pango/sample/script.rb new file mode 100644 index 0000000..b856377 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/sample/script.rb @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +=begin + script.rb - Ruby/Pango sample script. + + Copyright (c) 2005 Ruby-GNOME2 Project + This program is licenced under the same licence as Ruby-GNOME2. + + $Id: script.rb,v 1.1 2005/09/17 17:09:12 mutoh Exp $ +=end + +require 'pango' + +iter = Pango::ScriptIter.new("Helloこんにちはコンニチハ안녕하세요السلام عليكمΕλληνικάவணக்கம்") +begin + start_pos, end_pos, script = iter.range + puts "-----" + puts "start : #{start_pos}" + puts "end : #{end_pos}" + puts "script: #{script.nick}" + puts "sample_language: #{script.sample_language.to_s}" +end while iter.next! + diff --git a/lib/ruby-gtk2-2.0.2/pango/test/pango-test-utils.rb b/lib/ruby-gtk2-2.0.2/pango/test/pango-test-utils.rb new file mode 100644 index 0000000..918696f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/test/pango-test-utils.rb @@ -0,0 +1,9 @@ +module PangoTestUtils + private + def only_pango_version(major, minor, micro=nil) + micro ||= 0 + unless Pango.check_version?(major, minor, micro) + omit("Require Pango >= #{major}.#{minor}.#{micro}") + end + end +end diff --git a/lib/ruby-gtk2-2.0.2/pango/test/run-test.rb b/lib/ruby-gtk2-2.0.2/pango/test/run-test.rb new file mode 100755 index 0000000..fab521d --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/test/run-test.rb @@ -0,0 +1,28 @@ +#!/usr/bin/env ruby + +$VERBOSE = true + +ruby_gnome2_base = File.join(File.dirname(__FILE__), "..", "..") +ruby_gnome2_base = File.expand_path(ruby_gnome2_base) + +glib_base = File.join(ruby_gnome2_base, "glib2") +pango_base = File.join(ruby_gnome2_base, "pango") + +$LOAD_PATH.unshift(File.join(glib_base, "test")) +require 'glib-test-init' + +[[glib_base, "glib2"], + [pango_base, "pango"]].each do |target, module_name| + if system("which make > /dev/null") + `make -C #{target.dump} > /dev/null` or exit(1) + end + $LOAD_PATH.unshift(File.join(target, "ext", module_name)) + $LOAD_PATH.unshift(File.join(target, "lib")) +end + +$LOAD_PATH.unshift(File.join(pango_base, "test")) +require 'pango-test-utils' + +require 'pango' + +exit Test::Unit::AutoRunner.run(true) diff --git a/lib/ruby-gtk2-2.0.2/pango/test/test-analysis.rb b/lib/ruby-gtk2-2.0.2/pango/test/test-analysis.rb new file mode 100644 index 0000000..c44a62e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/test/test-analysis.rb @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestPangoAnalysis < Test::Unit::TestCase + include PangoTestUtils + + def test_level + analysis = Pango::Analysis.new + assert_equal(0, analysis.level) + end +end diff --git a/lib/ruby-gtk2-2.0.2/pango/test/test-attribute.rb b/lib/ruby-gtk2-2.0.2/pango/test/test-attribute.rb new file mode 100644 index 0000000..858b20e --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/test/test-attribute.rb @@ -0,0 +1,19 @@ +class TestAttribute < Test::Unit::TestCase + include PangoTestUtils + + def setup + @attribute = Pango::AttrLanguage.new(Pango::Language.default) + end + + def test_start_index + assert_equal(0, @attribute.start_index) + @attribute.start_index = 5 + assert_equal(5, @attribute.start_index) + end + + def test_end_index + assert_equal(GLib::MAXUINT, @attribute.end_index) + @attribute.end_index = 5 + assert_equal(5, @attribute.end_index) + end +end diff --git a/lib/ruby-gtk2-2.0.2/pango/test/test-color.rb b/lib/ruby-gtk2-2.0.2/pango/test/test-color.rb new file mode 100644 index 0000000..88cc97b --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/test/test-color.rb @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestPangoColor < Test::Unit::TestCase + include PangoTestUtils + + def test_red + color = Pango::Color.new(0, 0, 0) + assert_equal(0, color.red) + color.red = 32768 + assert_equal(32768, color.red) + end + + def test_blue + color = Pango::Color.new(0, 0, 0) + assert_equal(0, color.blue) + color.blue = 32768 + assert_equal(32768, color.blue) + end + + def test_green + color = Pango::Color.new(0, 0, 0) + assert_equal(0, color.green) + color.green = 32768 + assert_equal(32768, color.green) + end + + def test_to_a + color = Pango::Color.new(65535, 32768, 0) + assert_equal([65535, 32768, 0], color.to_a) + end +end diff --git a/lib/ruby-gtk2-2.0.2/pango/test/test-language.rb b/lib/ruby-gtk2-2.0.2/pango/test/test-language.rb new file mode 100644 index 0000000..61f7ba2 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/test/test-language.rb @@ -0,0 +1,7 @@ +class TestLanguage < Test::Unit::TestCase + include PangoTestUtils + + def test_default + assert_match(/\A[a-z]{2}-[a-z]{2}\z/, Pango::Language.default.to_s) + end +end diff --git a/lib/ruby-gtk2-2.0.2/pango/test/test-log-attr.rb b/lib/ruby-gtk2-2.0.2/pango/test/test-log-attr.rb new file mode 100644 index 0000000..41a2633 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/test/test-log-attr.rb @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestPangoLogAttr < Test::Unit::TestCase + include PangoTestUtils + + def test_line_break? + attribute = Pango::LogAttr.new + assert_false(attribute.line_break?) + end +end diff --git a/lib/ruby-gtk2-2.0.2/pango/test/test-matrix.rb b/lib/ruby-gtk2-2.0.2/pango/test/test-matrix.rb new file mode 100644 index 0000000..3c66b5f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/test/test-matrix.rb @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestPangoMatrix < Test::Unit::TestCase + include PangoTestUtils + + def test_xx + matrix = Pango::Matrix.new + assert_equal(1.0, matrix.xx) + end +end diff --git a/lib/ruby-gtk2-2.0.2/pango/test/test-rectangle.rb b/lib/ruby-gtk2-2.0.2/pango/test/test-rectangle.rb new file mode 100644 index 0000000..82598ba --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/test/test-rectangle.rb @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestPangoRectangle < Test::Unit::TestCase + include PangoTestUtils + + def test_width + rectangle = Pango::Rectangle.new(0, 10, 20, 30) + assert_equal(20, rectangle.width) + end +end diff --git a/lib/ruby-gtk2-2.0.2/pango/test/test_layout.rb b/lib/ruby-gtk2-2.0.2/pango/test/test_layout.rb new file mode 100644 index 0000000..e8fb81f --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/pango/test/test_layout.rb @@ -0,0 +1,20 @@ +class TestLayout < Test::Unit::TestCase + include PangoTestUtils + + def setup + @context = Pango::Context.new + @layout = Pango::Layout.new(@context) + end + + def test_set_font_description + assert_nil(@layout.font_description) + + @layout.font_description = "sans 14" + assert_equal("sans 14", @layout.font_description.to_s) + + description = Pango::FontDescription.new("monospace") + description.size = 10 * Pango::SCALE + @layout.font_description = description + assert_equal("monospace 10", @layout.font_description.to_s) + end +end diff --git a/lib/ruby-gtk2-2.0.2/run-test.rb b/lib/ruby-gtk2-2.0.2/run-test.rb new file mode 100755 index 0000000..4174639 --- /dev/null +++ b/lib/ruby-gtk2-2.0.2/run-test.rb @@ -0,0 +1,48 @@ +#!/usr/bin/env ruby + +# quick & dirty script for running all available tests for each module +# Author: Joachim Glauche + +require "rbconfig" +require "pathname" + +ruby = File.join(RbConfig::CONFIG['bindir'], + RbConfig::CONFIG['RUBY_INSTALL_NAME'] + RbConfig::CONFIG['EXEEXT']) + +# for creating a separating line +def separator + "-" * 80 +end + +targets = [] +includes = [] + +base_dir = Pathname(File.dirname(__FILE__)) +Pathname.glob((base_dir + "*").to_s) do |dir| + next unless dir.directory? + dir = dir.expand_path + ext_dir = dir + "ext" + dir.basename + includes.concat(["-I", (dir + "lib").to_s, "-I", ext_dir.to_s]) + next unless (dir + "test").directory? + targets << dir +end + +ignored_modules = ["gstreamer", "webkit-gtk", "webkit-gtk2"] + +succeeded = true +targets.each do |target| + next if ignored_modules.include?(target.basename.to_s) + Dir.chdir(target.to_s) do + puts "#{Time.now} running test for #{target}" + puts separator + + args = includes + ["test/run-test.rb"] + command = [ruby, *args] + unless system(command.collect {|arg| "'#{arg.gsub(/'/, '\\\'')}'"}.join(' ')) + succeeded = false + end + + puts separator + end +end +exit(succeeded)