diff options
author | James Henstridge <jamesh@src.gnome.org> | 1998-12-06 10:08:08 +0000 |
---|---|---|
committer | James Henstridge <jamesh@src.gnome.org> | 1998-12-06 10:08:08 +0000 |
commit | 997c302f261c2000d057bdaa989ec12ca00d7fa9 (patch) | |
tree | 32fd0d0cf70a0d804df0765d610518db281801a0 | |
download | pygtk-997c302f261c2000d057bdaa989ec12ca00d7fa9.tar.gz |
Initial revision
91 files changed, 26045 insertions, 0 deletions
diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 00000000..12d599ea --- /dev/null +++ b/.cvsignore @@ -0,0 +1,33 @@ +Makefile +Makefile.in +aclocal.m4 +config.cache +config.guess +config.h +config.log +config.status +config.sub +configure +configure.scan +libtool +ltconfig +ltmain.sh +stamp-h +stamp-h.in +stamp.h +version.h +config.h.in +.exrc +gnome-config +install-sh +missing +mkinstalldirs +INSTALL +intl +ABOUT-NLS +py-compile +*_defs.c +*_impl.c +*.pyc +*.pyo + diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 00000000..2f727685 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,2 @@ +James Henstridge <james@daa.com.au> + diff --git a/COPYING b/COPYING new file mode 100644 index 00000000..eb685a5e --- /dev/null +++ b/COPYING @@ -0,0 +1,481 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, 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 library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + 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 Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the 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 a program 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. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + 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, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +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 compile 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) 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. + + c) 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. + + d) 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 source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + 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 to +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 Library 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 + + Appendix: 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 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., 675 Mass Ave, Cambridge, MA 02139, 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/ChangeLog b/ChangeLog new file mode 100644 index 00000000..e82e035e --- /dev/null +++ b/ChangeLog @@ -0,0 +1,138 @@ +1998-12-05 James Henstridge <james@daa.com.au> + + * gtkmodule.c, generate/*.defs, gtk.py: updated to latest CVS. This + includes the function name changes Tim Janik introduced. I have + added backward compatibility wrappers for the old functions in gtk.py, + which also print out a deprecation message. + +1998-12-01 James Henstridge <james@daa.com.au> + + * gtk.py (GtkLayout): I had left a few remnants from when this class + was in gnome.ui. This is now fixed. + +1998-11-29 James Henstridge <james@daa.com.au> + + * description.py: Added a description of the GtkCTreeNode type. + + * gtk.py (GtkCTree): Added the GtkCTree class to this layer. + Hopefully I haven't made any mistakes. + +1998-11-28 James Henstridge <james@daa.com.au> + + * generate/gtklists.defs: added entries for GtkCTree. + + * gtkmodule.c: Added the GtkCTreeNode type. It exports some of the + attributes of the GtkCTreeRow associated with the node. Specifically, + the parent, next sibling links, and a list of children. This should + be enough attributes to make the type useful. + Also added extra functions for GtkCTree. + +1998-11-27 James Henstridge <james@daa.com.au> + + * generate/gtk*.defs: updated for GTK+-1.1.5. + + * gtkmodule.c: added the PyGtk_RegisterBoxed function, exported through + the _private dictionary. This allows adding extra boxed types so they + will be recognised in signal handlers and the like. + + * gtk.py: this file used to be Gtkinter.py. People should make this + change in their programs. Also updated for changes to the API. + + * Gtkinter.py: new file. Simply does a "from gtk import *", so old + programs will still run properly. + + * examples/*/*.py, pyglade/*.py, GdkImlib.py, GtkExtra.py: changed + occurences of Gtkinter to gtk. + +1998-11-17 James Henstridge <james@daa.com.au> + + * GdkImlib.py: missed a closing parenthesis. This caused problems. + + * generate/gtk.defs(gtk_rc_add_*_style): removed these functions. + They weren't exported by Gtkinter, and their declaration has changed + in newer GTK+'s. Now pygtk should compile with both GTK+-1.1.3 and + CVS GTK (tested for a 1998-11-16 checkout). + + * configure.in, NEWS: bumped version up to 0.5.5, and made new release. + + * generate/gtkmisc.defs, Gtkinter.py: added the GtkCalendar widget. + +1998-11-15 James Henstridge <james@daa.com.au> + + * gtkmodule.c: added GdkCursor type. + + * gtkmodule.c(GdkWindow.set_cursor): function to set cursor for window + + * generate/gtk.defs (gtk_cursor_*): new functions to create cursors + + * gtkmodule.c(gtk_pixmap_create_from_xpm_d): new function to create + a GdkPixmap from a list of strings (XPM data). This allows you to + store pixmaps inline with your program for distribution. + + * gdkimlibmodule.c: export the GdkImlibImageType, and a _private + dictionary that holds exported functions. I should be able to + add the GdkImlibImage dependent functions to _gnomeui now. + + * GDK.py, GTK.py: updated with new constants. + + * examples/simple/*1.py: stopped importing _gtkbase, and don't call + _gtk.pygtk_init(). + + * pyglade/build.py: added menu widgets to the interface building code. + + * pygtk.spec: new file -- an RPM spec file for this package. + + * NEWS: add information about this new version. + +1998-11-15 James Henstridge <james@daa.com.au> + + * gtkmodule.c: added GdkAtom handling. There is now a special type for + GdkAtoms that can be cast to string and int with str() and int() + respectively, and it supports coercions, so it should act like an + int in most cases. Functions that take GdkAtom's as arguments + actually take ints, so backward compatibility is kept, but functions + that return GdkAtoms now return this special type. + + * gtkmodule.c, generate/gtkdnd.defs, Gtkinter.py: added the new DnD + code, and support for selections. The gtk_selection_* functions have + been mapped to GtkWidget.selection_*, and the gtk_drag_* functions + have been mapped to GtkWidget.drag_* + + * GdkImlib.py: added function create_image_from_data, so you can + create an image from raw RGB data. Also added the Image.get_pixmap + method, which is like Image.make_pixmap, except it returns the + GdkPixmap,GdkBitmap pair, instead of a GtkPixmap widget. + +1998-11-14 James Henstridge <james@daa.com.au> + + * generate/*.defs: changes to bring pygtk up to date with GTK+-1.1.3 + +1998-11-13 James Henstridge <james@daa.com.au> + + * gtkmodule.c: added wrappers for GdkDragContext and GtkSelectionData. + Also removed all the old DnD GdkEvent mappings, and added the + GdkEventDND mapping. This should be enough to get the new Dnd signals + working. + + * generate/gtkbase.defs, gtkmodule.c(_wrap_gtk_widget_dnd_*): removed + the old gtk_widget_dnd_* functions from the bindings. + +1998-11-10 James Henstridge <james@daa.com.au> + + * build system: Converted over to using automake. Note thay some + modifications have been made to the original version of automake, + so you will need to apply my patches if you want to modify pygtk. + + * swigsrc/*: removed. I am now using some code generation tools + that take .defs files as input. + + * gdkimlibmodule.c: got rid of all the swig stuff, and cleaned up the + code a bit. This has reduced the source code size by half. + +1998-11-10 James Henstridge <james@daa.com.au> + + * ChangeLog: started change log. Old Changelog file has been moved + to NEWS + + * NEWS: used to be Changelog + @@ -0,0 +1,1597 @@ +# +# GDK.py -- this file contains GDK constants relevant to pygtk +# + +# GdkInputCondition's +INPUT_READ = 1 << 0 +INPUT_WRITE = 1 << 1 +INPUT_EXCEPTION = 1 << 2 + +# GdkEventType's +NOTHING = -1 +DELETE = 0 +DESTROY = 1 +EXPOSE = 2 +MOTION_NOTIFY = 3 +BUTTON_PRESS = 4 +_2BUTTON_PRESS = 5 +_3BUTTON_PRESS = 6 +BUTTON_RELEASE = 7 +KEY_PRESS = 8 +KEY_RELEASE = 9 +ENTER_NOTIFY = 10 +LEAVE_NOTIFY = 11 +FOCUS_CHANGE = 12 +CONFIGURE = 13 +MAP = 14 +UNMAP = 15 +PROPERTY_NOTIFY = 16 +SELECTION_CLEAR = 17 +SELECTION_REQUEST = 18 +SELECTION_NOTIFY = 19 +PROXIMITY_IN = 20 +PROXIMITY_OUT = 21 +DRAG_ENTER = 22 +DRAG_LEAVE = 23 +DRAG_MOTION = 24 +DRAG_STATUS = 25 +DROP_START = 26 +DROP_FINISHED = 27 +CLIENT_EVENT = 28 +VISIBILITY_NOTIFY = 29 +NO_EXPOSE = 30 + +# GdkEventMask's +EXPOSURE_MASK = 1 << 1 +POINTER_MOTION_MASK = 1 << 2 +POINTER_MOTION_HINT_MASK = 1 << 3 +BUTTON_MOTION_MASK = 1 << 4 +BUTTON1_MOTION_MASK = 1 << 5 +BUTTON2_MOTION_MASK = 1 << 6 +BUTTON3_MOTION_MASK = 1 << 7 +BUTTON_PRESS_MASK = 1 << 8 +BUTTON_RELEASE_MASK = 1 << 9 +KEY_PRESS_MASK = 1 << 10 +KEY_RELEASE_MASK = 1 << 11 +ENTER_NOTIFY_MASK = 1 << 12 +LEAVE_NOTIFY_MASK = 1 << 13 +FOCUS_CHANGE_MASK = 1 << 14 +STRUCTURE_MASK = 1 << 15 +PROPERTY_CHANGE_MASK = 1 << 16 +VISIBILITY_NOTIFY_MASK = 1 << 17 +PROXIMITY_IN_MASK = 1 << 18 +PROXIMITY_OUT_MASK = 1 << 19 +SUBSTRUCTURE_MASK = 1 << 20 +ALL_EVENTS_MASK = 0x0FFFFF + +# GdkFontType's +FONT_FONT = 0 +FONT_FONTSET = 0 + +# GdkNotifyType's +NOTIFY_ANCESTOR = 0 +NOTIFY_VIRTUAL = 1 +NOTIFY_INFERIOR = 2 +NOTIFY_NONLINEAR = 3 +NOTIFY_NONLINEAR_VIRTUAL = 4 +NOTIFY_UNKNOWN = 5 + +# GdkCrossingMode's +CROSSING_NORMAL = 0 +CROSSING_GRAB = 1 +CROSSING_UNGRAB = 2 + +# GdkModifierType's +SHIFT_MASK = 1 << 0 +LOCK_MASK = 1 << 1 +CONTROL_MASK = 1 << 2 +MOD1_MASK = 1 << 3 +MOD2_MASK = 1 << 4 +MOD3_MASK = 1 << 5 +MOD4_MASK = 1 << 6 +MOD5_MASK = 1 << 7 +BUTTON1_MASK = 1 << 8 +BUTTON2_MASK = 1 << 9 +BUTTON3_MASK = 1 << 10 +BUTTON4_MASK = 1 << 11 +BUTTON5_MASK = 1 << 12 +RELEASE_MASK = 1 << 13 + +# GdkPropertyState's +PROPERTY_NEW_VALUE = 0 +PROPERTY_DELETE = 1 + +# GdkPropMode's +PROP_MODE_REPLACE = 0 +PROP_MODE_PREPEND = 1 +PROP_MODE_APPEND = 2 + +# GdkDragAction's +ACTION_DEFAULT = 1 << 0 +ACTION_COPY = 1 << 1 +ACTION_MOVE = 1 << 2 +ACTION_LINK = 1 << 3 +ACTION_PRIVATE = 1 << 4 +ACTION_ASK = 1 << 5 + +# GdkDragProtocol's +DRAG_PROTO_MOTIF = 0 +DRAG_PROTO_XDND = 1 +DRAG_PROTO_ROOTWIN = 2 + +# GdkSelectionType's +SELECTION_TYPE_ATOM = 4 +SELECTION_TYPE_BITMAP = 5 +SELECTION_TYPE_COLORMAP = 7 +SELECTION_TYPE_DRAWABLE = 17 +SELECTION_TYPE_INTEGER = 19 +SELECTION_TYPE_PIXMAP = 20 +SELECTION_TYPE_WINDOW = 33 +SELECTION_TYPE_STRING = 31 + +# GdkInputSource's +SOURCE_MOUSE = 0 +SOURCE_PEN = 1 +SOURCE_ERASER = 2 +SOURCE_CURSOR = 3 + +# GdkInputMode's +MODE_DISABLED = 0 +MODE_SCREEN = 1 +MODE_WINDOW = 2 + +# GdkExtensionMode's +EXTENSION_EVENTS_NONE = 0 +EXTENSION_EVENTS_ALL = 1 +EXTENSION_EVENTS_CURSOR = 2 + +# Motif WM Hints +DECOR_ALL = 1 << 0 +DECOR_BORDER = 1 << 1 +DECOR_RESIZEH = 1 << 2 +DECOR_TITLE = 1 << 3 +DECOR_MENU = 1 << 4 +DECOR_MINIMIZE = 1 << 5 +DECOR_MAXIMIZE = 1 << 6 +FUNC_ALL = 1 << 0 +FUNC_RESIZE = 1 << 1 +FUNC_MOVE = 1 << 2 +FUNC_MINIMIZE = 1 << 3 +FUNC_MAXIMIZE = 1 << 4 +FUNC_CLOSE = 1 << 5 + +# GdkVisibilityState's +VISIBILITY_UNOBSCURED = 0 +VISIBILITY_PARTIAL = 1 +VISIBILITY_FULLY_OBSCURED = 2 + +# GdkFunction's +COPY = 0 +INVERT = 1 +XOR = 2 +CLEAR = 3 +AND = 4 +AND_REVERSE = 5 +AND_INVERT = 6 +NOOP = 7 +OR = 8 +EQUIV = 9 +OR_REVERSE = 10 +COPY_INVERT = 11 +OR_INVERT = 12 +NAND = 13 +SET = 14 + +# GdkFill's +SOLID = 0 +TILED = 1 +STIPPLED = 2 +OPAQUE_STIPPLED = 3 + +# GdkFillRule's +EVEN_ODD_RULE = 0 +WINGDING_RULE = 1 + +# GdkLineStyle's +LINE_SOLID = 0 +LINE_ON_OFF_DASH = 1 +LINE_DOUBLE_DASH = 2 + +# GdkCapStyle's +CAP_NOT_LAST = 0 +CAP_BUTT = 1 +CAP_ROUND = 2 +CAP_PROJECTING = 3 + +# GdkJoinStyle's +JOIN_MITER = 0 +JOIN_ROUND = 1 +JOIN_BEVEL = 2 + +# GdkRgbDither's +RGB_DITHER_NONE = 0 +RGB_DITHER_NORMAL = 1 +RGB_DITHER_MAX = 2 + +# GdkCursorType's +X_CURSOR = 0 +ARROW = 2 +BASED_ARROW_DOWN = 4 +BASED_ARROW_UP = 6 +BOAT = 8 +BOGOSITY = 10 +BOTTOM_LEFT_CORNER = 12 +BOTTOM_RIGHT_CORNER = 14 +BOTTOM_SIDE = 16 +BOTTOM_TEE = 18 +BOX_SPIRAL = 20 +CENTER_PTR = 22 +CIRCLE = 24 +CLOCK = 26 +COFFEE_MUG = 28 +CROSS = 30 +CROSS_REVERSE = 32 +CROSSHAIR = 34 +DIAMOND_CROSS = 36 +DOT = 38 +DOTBOX = 40 +DOUBLE_ARROW = 42 +DRAFT_LARGE = 44 +DRAFT_SMALL = 46 +DRAPED_BOX = 48 +EXCHANGE = 50 +FLEUR = 52 +GOBBLER = 54 +GUMBY = 56 +HAND1 = 58 +HAND2 = 60 +HEART = 62 +ICON = 64 +IRON_CROSS = 66 +LEFT_PTR = 68 +LEFT_SIDE = 70 +LEFT_TEE = 72 +LEFTBUTTON = 74 +LL_ANGLE = 76 +LR_ANGLE = 78 +MAN = 80 +MIDDLEBUTTON = 82 +MOUSE = 84 +PENCIL = 86 +PIRATE = 88 +PLUS = 90 +QUESTION_ARROW = 92 +RIGHT_PTR = 94 +RIGHT_SIDE = 96 +RIGHT_TEE = 98 +RIGHTBUTTON = 100 +RTL_LOGO = 102 +SAILBOAT = 104 +SB_DOWN_ARROW = 106 +SB_H_DOUBLE_ARROW = 108 +SB_LEFT_ARROW = 110 +SB_RIGHT_ARROW = 112 +SB_UP_ARROW = 114 +SB_V_DOUBLE_ARROW = 116 +SHUTTLE = 118 +SIZING = 120 +SPIDER = 122 +SPRAYCAN = 124 +STAR = 126 +TARGET = 128 +TCROSS = 130 +TOP_LEFT_ARROW = 132 +TOP_LEFT_CORNER = 134 +TOP_RIGHT_CORNER = 136 +TOP_SIDE = 138 +TOP_TEE = 140 +TREK = 142 +UL_ANGLE = 144 +UMBRELLA = 146 +UR_ANGLE = 148 +WATCH = 150 +XTERM = 152 +CURSOR_IS_PIXMAP = -1 + + +# these are the Key Symbols for GDK +# they were created with sed -n 's/#define GDK)\([^ ]*\)/\1 =/p' <gdkkeysyms.h +VoidSymbol = 0xFFFFFF +BackSpace = 0xFF08 +Tab = 0xFF09 +Linefeed = 0xFF0A +Clear = 0xFF0B +Return = 0xFF0D +Pause = 0xFF13 +Scroll_Lock = 0xFF14 +Sys_Req = 0xFF15 +Escape = 0xFF1B +Delete = 0xFFFF +Multi_key = 0xFF20 +Kanji = 0xFF21 +Muhenkan = 0xFF22 +Henkan_Mode = 0xFF23 +Henkan = 0xFF23 +Romaji = 0xFF24 +Hiragana = 0xFF25 +Katakana = 0xFF26 +Hiragana_Katakana = 0xFF27 +Zenkaku = 0xFF28 +Hankaku = 0xFF29 +Zenkaku_Hankaku = 0xFF2A +Touroku = 0xFF2B +Massyo = 0xFF2C +Kana_Lock = 0xFF2D +Kana_Shift = 0xFF2E +Eisu_Shift = 0xFF2F +Eisu_toggle = 0xFF30 +Home = 0xFF50 +Left = 0xFF51 +Up = 0xFF52 +Right = 0xFF53 +Down = 0xFF54 +Prior = 0xFF55 +Page_Up = 0xFF55 +Next = 0xFF56 +Page_Down = 0xFF56 +End = 0xFF57 +Begin = 0xFF58 +Select = 0xFF60 +Print = 0xFF61 +Execute = 0xFF62 +Insert = 0xFF63 +Undo = 0xFF65 +Redo = 0xFF66 +Menu = 0xFF67 +Find = 0xFF68 +Cancel = 0xFF69 +Help = 0xFF6A +Break = 0xFF6B +Mode_switch = 0xFF7E +script_switch = 0xFF7E +Num_Lock = 0xFF7F +KP_Space = 0xFF80 +KP_Tab = 0xFF89 +KP_Enter = 0xFF8D +KP_F1 = 0xFF91 +KP_F2 = 0xFF92 +KP_F3 = 0xFF93 +KP_F4 = 0xFF94 +KP_Home = 0xFF95 +KP_Left = 0xFF96 +KP_Up = 0xFF97 +KP_Right = 0xFF98 +KP_Down = 0xFF99 +KP_Prior = 0xFF9A +KP_Page_Up = 0xFF9A +KP_Next = 0xFF9B +KP_Page_Down = 0xFF9B +KP_End = 0xFF9C +KP_Begin = 0xFF9D +KP_Insert = 0xFF9E +KP_Delete = 0xFF9F +KP_Equal = 0xFFBD +KP_Multiply = 0xFFAA +KP_Add = 0xFFAB +KP_Separator = 0xFFAC +KP_Subtract = 0xFFAD +KP_Decimal = 0xFFAE +KP_Divide = 0xFFAF +KP_0 = 0xFFB0 +KP_1 = 0xFFB1 +KP_2 = 0xFFB2 +KP_3 = 0xFFB3 +KP_4 = 0xFFB4 +KP_5 = 0xFFB5 +KP_6 = 0xFFB6 +KP_7 = 0xFFB7 +KP_8 = 0xFFB8 +KP_9 = 0xFFB9 +F1 = 0xFFBE +F2 = 0xFFBF +F3 = 0xFFC0 +F4 = 0xFFC1 +F5 = 0xFFC2 +F6 = 0xFFC3 +F7 = 0xFFC4 +F8 = 0xFFC5 +F9 = 0xFFC6 +F10 = 0xFFC7 +F11 = 0xFFC8 +L1 = 0xFFC8 +F12 = 0xFFC9 +L2 = 0xFFC9 +F13 = 0xFFCA +L3 = 0xFFCA +F14 = 0xFFCB +L4 = 0xFFCB +F15 = 0xFFCC +L5 = 0xFFCC +F16 = 0xFFCD +L6 = 0xFFCD +F17 = 0xFFCE +L7 = 0xFFCE +F18 = 0xFFCF +L8 = 0xFFCF +F19 = 0xFFD0 +L9 = 0xFFD0 +F20 = 0xFFD1 +L10 = 0xFFD1 +F21 = 0xFFD2 +R1 = 0xFFD2 +F22 = 0xFFD3 +R2 = 0xFFD3 +F23 = 0xFFD4 +R3 = 0xFFD4 +F24 = 0xFFD5 +R4 = 0xFFD5 +F25 = 0xFFD6 +R5 = 0xFFD6 +F26 = 0xFFD7 +R6 = 0xFFD7 +F27 = 0xFFD8 +R7 = 0xFFD8 +F28 = 0xFFD9 +R8 = 0xFFD9 +F29 = 0xFFDA +R9 = 0xFFDA +F30 = 0xFFDB +R10 = 0xFFDB +F31 = 0xFFDC +R11 = 0xFFDC +F32 = 0xFFDD +R12 = 0xFFDD +F33 = 0xFFDE +R13 = 0xFFDE +F34 = 0xFFDF +R14 = 0xFFDF +F35 = 0xFFE0 +R15 = 0xFFE0 +Shift_L = 0xFFE1 +Shift_R = 0xFFE2 +Control_L = 0xFFE3 +Control_R = 0xFFE4 +Caps_Lock = 0xFFE5 +Shift_Lock = 0xFFE6 +Meta_L = 0xFFE7 +Meta_R = 0xFFE8 +Alt_L = 0xFFE9 +Alt_R = 0xFFEA +Super_L = 0xFFEB +Super_R = 0xFFEC +Hyper_L = 0xFFED +Hyper_R = 0xFFEE +ISO_Lock = 0xFE01 +ISO_Level2_Latch = 0xFE02 +ISO_Level3_Shift = 0xFE03 +ISO_Level3_Latch = 0xFE04 +ISO_Level3_Lock = 0xFE05 +ISO_Group_Shift = 0xFF7E +ISO_Group_Latch = 0xFE06 +ISO_Group_Lock = 0xFE07 +ISO_Next_Group = 0xFE08 +ISO_Next_Group_Lock = 0xFE09 +ISO_Prev_Group = 0xFE0A +ISO_Prev_Group_Lock = 0xFE0B +ISO_First_Group = 0xFE0C +ISO_First_Group_Lock = 0xFE0D +ISO_Last_Group = 0xFE0E +ISO_Last_Group_Lock = 0xFE0F +ISO_Left_Tab = 0xFE20 +ISO_Move_Line_Up = 0xFE21 +ISO_Move_Line_Down = 0xFE22 +ISO_Partial_Line_Up = 0xFE23 +ISO_Partial_Line_Down = 0xFE24 +ISO_Partial_Space_Left = 0xFE25 +ISO_Partial_Space_Right = 0xFE26 +ISO_Set_Margin_Left = 0xFE27 +ISO_Set_Margin_Right = 0xFE28 +ISO_Release_Margin_Left = 0xFE29 +ISO_Release_Margin_Right = 0xFE2A +ISO_Release_Both_Margins = 0xFE2B +ISO_Fast_Cursor_Left = 0xFE2C +ISO_Fast_Cursor_Right = 0xFE2D +ISO_Fast_Cursor_Up = 0xFE2E +ISO_Fast_Cursor_Down = 0xFE2F +ISO_Continuous_Underline = 0xFE30 +ISO_Discontinuous_Underline = 0xFE31 +ISO_Emphasize = 0xFE32 +ISO_Center_Object = 0xFE33 +ISO_Enter = 0xFE34 +dead_grave = 0xFE50 +dead_acute = 0xFE51 +dead_circumflex = 0xFE52 +dead_tilde = 0xFE53 +dead_macron = 0xFE54 +dead_breve = 0xFE55 +dead_abovedot = 0xFE56 +dead_diaeresis = 0xFE57 +dead_abovering = 0xFE58 +dead_doubleacute = 0xFE59 +dead_caron = 0xFE5A +dead_cedilla = 0xFE5B +dead_ogonek = 0xFE5C +dead_iota = 0xFE5D +dead_voiced_sound = 0xFE5E +dead_semivoiced_sound = 0xFE5F +First_Virtual_Screen = 0xFED0 +Prev_Virtual_Screen = 0xFED1 +Next_Virtual_Screen = 0xFED2 +Last_Virtual_Screen = 0xFED4 +Terminate_Server = 0xFED5 +Pointer_Left = 0xFEE0 +Pointer_Right = 0xFEE1 +Pointer_Up = 0xFEE2 +Pointer_Down = 0xFEE3 +Pointer_UpLeft = 0xFEE4 +Pointer_UpRight = 0xFEE5 +Pointer_DownLeft = 0xFEE6 +Pointer_DownRight = 0xFEE7 +Pointer_Button_Dflt = 0xFEE8 +Pointer_Button1 = 0xFEE9 +Pointer_Button2 = 0xFEEA +Pointer_Button3 = 0xFEEB +Pointer_Button4 = 0xFEEC +Pointer_Button5 = 0xFEED +Pointer_DblClick_Dflt = 0xFEEE +Pointer_DblClick1 = 0xFEEF +Pointer_DblClick2 = 0xFEF0 +Pointer_DblClick3 = 0xFEF1 +Pointer_DblClick4 = 0xFEF2 +Pointer_DblClick5 = 0xFEF3 +Pointer_Drag_Dflt = 0xFEF4 +Pointer_Drag1 = 0xFEF5 +Pointer_Drag2 = 0xFEF6 +Pointer_Drag3 = 0xFEF7 +Pointer_Drag4 = 0xFEF8 +Pointer_EnableKeys = 0xFEF9 +Pointer_Accelerate = 0xFEFA +Pointer_DfltBtnNext = 0xFEFB +Pointer_DfltBtnPrev = 0xFEFC +_3270_Duplicate = 0xFD01 +_3270_FieldMark = 0xFD02 +_3270_Right2 = 0xFD03 +_3270_Left2 = 0xFD04 +_3270_BackTab = 0xFD05 +_3270_EraseEOF = 0xFD06 +_3270_EraseInput = 0xFD07 +_3270_Reset = 0xFD08 +_3270_Quit = 0xFD09 +_3270_PA1 = 0xFD0A +_3270_PA2 = 0xFD0B +_3270_PA3 = 0xFD0C +_3270_Test = 0xFD0D +_3270_Attn = 0xFD0E +_3270_CursorBlink = 0xFD0F +_3270_AltCursor = 0xFD10 +_3270_KeyClick = 0xFD11 +_3270_Jump = 0xFD12 +_3270_Ident = 0xFD13 +_3270_Rule = 0xFD14 +_3270_Copy = 0xFD15 +_3270_Play = 0xFD16 +_3270_Setup = 0xFD17 +_3270_Record = 0xFD18 +_3270_ChangeScreen = 0xFD19 +_3270_DeleteWord = 0xFD1A +_3270_ExSelect = 0xFD1B +_3270_CursorSelect = 0xFD1C +_3270_PrintScreen = 0xFD1D +_3270_Enter = 0xFD1E +space = 0x020 +exclam = 0x021 +quotedbl = 0x022 +numbersign = 0x023 +dollar = 0x024 +percent = 0x025 +ampersand = 0x026 +apostrophe = 0x027 +quoteright = 0x027 +parenleft = 0x028 +parenright = 0x029 +asterisk = 0x02a +plus = 0x02b +comma = 0x02c +minus = 0x02d +period = 0x02e +slash = 0x02f +_0 = 0x030 +_1 = 0x031 +_2 = 0x032 +_3 = 0x033 +_4 = 0x034 +_5 = 0x035 +_6 = 0x036 +_7 = 0x037 +_8 = 0x038 +_9 = 0x039 +colon = 0x03a +semicolon = 0x03b +less = 0x03c +equal = 0x03d +greater = 0x03e +question = 0x03f +at = 0x040 +A = 0x041 +B = 0x042 +C = 0x043 +D = 0x044 +E = 0x045 +F = 0x046 +G = 0x047 +H = 0x048 +I = 0x049 +J = 0x04a +K = 0x04b +L = 0x04c +M = 0x04d +N = 0x04e +O = 0x04f +P = 0x050 +Q = 0x051 +R = 0x052 +S = 0x053 +T = 0x054 +U = 0x055 +V = 0x056 +W = 0x057 +X = 0x058 +Y = 0x059 +Z = 0x05a +bracketleft = 0x05b +backslash = 0x05c +bracketright = 0x05d +asciicircum = 0x05e +underscore = 0x05f +grave = 0x060 +quoteleft = 0x060 +a = 0x061 +b = 0x062 +c = 0x063 +d = 0x064 +e = 0x065 +f = 0x066 +g = 0x067 +h = 0x068 +i = 0x069 +j = 0x06a +k = 0x06b +l = 0x06c +m = 0x06d +n = 0x06e +o = 0x06f +p = 0x070 +q = 0x071 +r = 0x072 +s = 0x073 +t = 0x074 +u = 0x075 +v = 0x076 +w = 0x077 +x = 0x078 +y = 0x079 +z = 0x07a +braceleft = 0x07b +bar = 0x07c +braceright = 0x07d +asciitilde = 0x07e +nobreakspace = 0x0a0 +exclamdown = 0x0a1 +cent = 0x0a2 +sterling = 0x0a3 +currency = 0x0a4 +yen = 0x0a5 +brokenbar = 0x0a6 +section = 0x0a7 +diaeresis = 0x0a8 +copyright = 0x0a9 +ordfeminine = 0x0aa +guillemotleft = 0x0ab +notsign = 0x0ac +hyphen = 0x0ad +registered = 0x0ae +macron = 0x0af +degree = 0x0b0 +plusminus = 0x0b1 +twosuperior = 0x0b2 +threesuperior = 0x0b3 +acute = 0x0b4 +mu = 0x0b5 +paragraph = 0x0b6 +periodcentered = 0x0b7 +cedilla = 0x0b8 +onesuperior = 0x0b9 +masculine = 0x0ba +guillemotright = 0x0bb +onequarter = 0x0bc +onehalf = 0x0bd +threequarters = 0x0be +questiondown = 0x0bf +Agrave = 0x0c0 +Aacute = 0x0c1 +Acircumflex = 0x0c2 +Atilde = 0x0c3 +Adiaeresis = 0x0c4 +Aring = 0x0c5 +AE = 0x0c6 +Ccedilla = 0x0c7 +Egrave = 0x0c8 +Eacute = 0x0c9 +Ecircumflex = 0x0ca +Ediaeresis = 0x0cb +Igrave = 0x0cc +Iacute = 0x0cd +Icircumflex = 0x0ce +Idiaeresis = 0x0cf +ETH = 0x0d0 +Eth = 0x0d0 +Ntilde = 0x0d1 +Ograve = 0x0d2 +Oacute = 0x0d3 +Ocircumflex = 0x0d4 +Otilde = 0x0d5 +Odiaeresis = 0x0d6 +multiply = 0x0d7 +Ooblique = 0x0d8 +Ugrave = 0x0d9 +Uacute = 0x0da +Ucircumflex = 0x0db +Udiaeresis = 0x0dc +Yacute = 0x0dd +THORN = 0x0de +Thorn = 0x0de +ssharp = 0x0df +agrave = 0x0e0 +aacute = 0x0e1 +acircumflex = 0x0e2 +atilde = 0x0e3 +adiaeresis = 0x0e4 +aring = 0x0e5 +ae = 0x0e6 +ccedilla = 0x0e7 +egrave = 0x0e8 +eacute = 0x0e9 +ecircumflex = 0x0ea +ediaeresis = 0x0eb +igrave = 0x0ec +iacute = 0x0ed +icircumflex = 0x0ee +idiaeresis = 0x0ef +eth = 0x0f0 +ntilde = 0x0f1 +ograve = 0x0f2 +oacute = 0x0f3 +ocircumflex = 0x0f4 +otilde = 0x0f5 +odiaeresis = 0x0f6 +division = 0x0f7 +oslash = 0x0f8 +ugrave = 0x0f9 +uacute = 0x0fa +ucircumflex = 0x0fb +udiaeresis = 0x0fc +yacute = 0x0fd +thorn = 0x0fe +ydiaeresis = 0x0ff +Aogonek = 0x1a1 +breve = 0x1a2 +Lstroke = 0x1a3 +Lcaron = 0x1a5 +Sacute = 0x1a6 +Scaron = 0x1a9 +Scedilla = 0x1aa +Tcaron = 0x1ab +Zacute = 0x1ac +Zcaron = 0x1ae +Zabovedot = 0x1af +aogonek = 0x1b1 +ogonek = 0x1b2 +lstroke = 0x1b3 +lcaron = 0x1b5 +sacute = 0x1b6 +caron = 0x1b7 +scaron = 0x1b9 +scedilla = 0x1ba +tcaron = 0x1bb +zacute = 0x1bc +doubleacute = 0x1bd +zcaron = 0x1be +zabovedot = 0x1bf +Racute = 0x1c0 +Abreve = 0x1c3 +Lacute = 0x1c5 +Cacute = 0x1c6 +Ccaron = 0x1c8 +Eogonek = 0x1ca +Ecaron = 0x1cc +Dcaron = 0x1cf +Dstroke = 0x1d0 +Nacute = 0x1d1 +Ncaron = 0x1d2 +Odoubleacute = 0x1d5 +Rcaron = 0x1d8 +Uring = 0x1d9 +Udoubleacute = 0x1db +Tcedilla = 0x1de +racute = 0x1e0 +abreve = 0x1e3 +lacute = 0x1e5 +cacute = 0x1e6 +ccaron = 0x1e8 +eogonek = 0x1ea +ecaron = 0x1ec +dcaron = 0x1ef +dstroke = 0x1f0 +nacute = 0x1f1 +ncaron = 0x1f2 +odoubleacute = 0x1f5 +udoubleacute = 0x1fb +rcaron = 0x1f8 +uring = 0x1f9 +tcedilla = 0x1fe +abovedot = 0x1ff +Hstroke = 0x2a1 +Hcircumflex = 0x2a6 +Iabovedot = 0x2a9 +Gbreve = 0x2ab +Jcircumflex = 0x2ac +hstroke = 0x2b1 +hcircumflex = 0x2b6 +idotless = 0x2b9 +gbreve = 0x2bb +jcircumflex = 0x2bc +Cabovedot = 0x2c5 +Ccircumflex = 0x2c6 +Gabovedot = 0x2d5 +Gcircumflex = 0x2d8 +Ubreve = 0x2dd +Scircumflex = 0x2de +cabovedot = 0x2e5 +ccircumflex = 0x2e6 +gabovedot = 0x2f5 +gcircumflex = 0x2f8 +ubreve = 0x2fd +scircumflex = 0x2fe +kra = 0x3a2 +kappa = 0x3a2 +Rcedilla = 0x3a3 +Itilde = 0x3a5 +Lcedilla = 0x3a6 +Emacron = 0x3aa +Gcedilla = 0x3ab +Tslash = 0x3ac +rcedilla = 0x3b3 +itilde = 0x3b5 +lcedilla = 0x3b6 +emacron = 0x3ba +gcedilla = 0x3bb +tslash = 0x3bc +ENG = 0x3bd +eng = 0x3bf +Amacron = 0x3c0 +Iogonek = 0x3c7 +Eabovedot = 0x3cc +Imacron = 0x3cf +Ncedilla = 0x3d1 +Omacron = 0x3d2 +Kcedilla = 0x3d3 +Uogonek = 0x3d9 +Utilde = 0x3dd +Umacron = 0x3de +amacron = 0x3e0 +iogonek = 0x3e7 +eabovedot = 0x3ec +imacron = 0x3ef +ncedilla = 0x3f1 +omacron = 0x3f2 +kcedilla = 0x3f3 +uogonek = 0x3f9 +utilde = 0x3fd +umacron = 0x3fe +overline = 0x47e +kana_fullstop = 0x4a1 +kana_openingbracket = 0x4a2 +kana_closingbracket = 0x4a3 +kana_comma = 0x4a4 +kana_conjunctive = 0x4a5 +kana_middledot = 0x4a5 +kana_WO = 0x4a6 +kana_a = 0x4a7 +kana_i = 0x4a8 +kana_u = 0x4a9 +kana_e = 0x4aa +kana_o = 0x4ab +kana_ya = 0x4ac +kana_yu = 0x4ad +kana_yo = 0x4ae +kana_tsu = 0x4af +kana_tu = 0x4af +prolongedsound = 0x4b0 +kana_A = 0x4b1 +kana_I = 0x4b2 +kana_U = 0x4b3 +kana_E = 0x4b4 +kana_O = 0x4b5 +kana_KA = 0x4b6 +kana_KI = 0x4b7 +kana_KU = 0x4b8 +kana_KE = 0x4b9 +kana_KO = 0x4ba +kana_SA = 0x4bb +kana_SHI = 0x4bc +kana_SU = 0x4bd +kana_SE = 0x4be +kana_SO = 0x4bf +kana_TA = 0x4c0 +kana_CHI = 0x4c1 +kana_TI = 0x4c1 +kana_TSU = 0x4c2 +kana_TU = 0x4c2 +kana_TE = 0x4c3 +kana_TO = 0x4c4 +kana_NA = 0x4c5 +kana_NI = 0x4c6 +kana_NU = 0x4c7 +kana_NE = 0x4c8 +kana_NO = 0x4c9 +kana_HA = 0x4ca +kana_HI = 0x4cb +kana_FU = 0x4cc +kana_HU = 0x4cc +kana_HE = 0x4cd +kana_HO = 0x4ce +kana_MA = 0x4cf +kana_MI = 0x4d0 +kana_MU = 0x4d1 +kana_ME = 0x4d2 +kana_MO = 0x4d3 +kana_YA = 0x4d4 +kana_YU = 0x4d5 +kana_YO = 0x4d6 +kana_RA = 0x4d7 +kana_RI = 0x4d8 +kana_RU = 0x4d9 +kana_RE = 0x4da +kana_RO = 0x4db +kana_WA = 0x4dc +kana_N = 0x4dd +voicedsound = 0x4de +semivoicedsound = 0x4df +kana_switch = 0xFF7E +Arabic_comma = 0x5ac +Arabic_semicolon = 0x5bb +Arabic_question_mark = 0x5bf +Arabic_hamza = 0x5c1 +Arabic_maddaonalef = 0x5c2 +Arabic_hamzaonalef = 0x5c3 +Arabic_hamzaonwaw = 0x5c4 +Arabic_hamzaunderalef = 0x5c5 +Arabic_hamzaonyeh = 0x5c6 +Arabic_alef = 0x5c7 +Arabic_beh = 0x5c8 +Arabic_tehmarbuta = 0x5c9 +Arabic_teh = 0x5ca +Arabic_theh = 0x5cb +Arabic_jeem = 0x5cc +Arabic_hah = 0x5cd +Arabic_khah = 0x5ce +Arabic_dal = 0x5cf +Arabic_thal = 0x5d0 +Arabic_ra = 0x5d1 +Arabic_zain = 0x5d2 +Arabic_seen = 0x5d3 +Arabic_sheen = 0x5d4 +Arabic_sad = 0x5d5 +Arabic_dad = 0x5d6 +Arabic_tah = 0x5d7 +Arabic_zah = 0x5d8 +Arabic_ain = 0x5d9 +Arabic_ghain = 0x5da +Arabic_tatweel = 0x5e0 +Arabic_feh = 0x5e1 +Arabic_qaf = 0x5e2 +Arabic_kaf = 0x5e3 +Arabic_lam = 0x5e4 +Arabic_meem = 0x5e5 +Arabic_noon = 0x5e6 +Arabic_ha = 0x5e7 +Arabic_heh = 0x5e7 +Arabic_waw = 0x5e8 +Arabic_alefmaksura = 0x5e9 +Arabic_yeh = 0x5ea +Arabic_fathatan = 0x5eb +Arabic_dammatan = 0x5ec +Arabic_kasratan = 0x5ed +Arabic_fatha = 0x5ee +Arabic_damma = 0x5ef +Arabic_kasra = 0x5f0 +Arabic_shadda = 0x5f1 +Arabic_sukun = 0x5f2 +Arabic_switch = 0xFF7E +Serbian_dje = 0x6a1 +Macedonia_gje = 0x6a2 +Cyrillic_io = 0x6a3 +Ukrainian_ie = 0x6a4 +Ukranian_je = 0x6a4 +Macedonia_dse = 0x6a5 +Ukrainian_i = 0x6a6 +Ukranian_i = 0x6a6 +Ukrainian_yi = 0x6a7 +Ukranian_yi = 0x6a7 +Cyrillic_je = 0x6a8 +Serbian_je = 0x6a8 +Cyrillic_lje = 0x6a9 +Serbian_lje = 0x6a9 +Cyrillic_nje = 0x6aa +Serbian_nje = 0x6aa +Serbian_tshe = 0x6ab +Macedonia_kje = 0x6ac +Byelorussian_shortu = 0x6ae +Cyrillic_dzhe = 0x6af +Serbian_dze = 0x6af +numerosign = 0x6b0 +Serbian_DJE = 0x6b1 +Macedonia_GJE = 0x6b2 +Cyrillic_IO = 0x6b3 +Ukrainian_IE = 0x6b4 +Ukranian_JE = 0x6b4 +Macedonia_DSE = 0x6b5 +Ukrainian_I = 0x6b6 +Ukranian_I = 0x6b6 +Ukrainian_YI = 0x6b7 +Ukranian_YI = 0x6b7 +Cyrillic_JE = 0x6b8 +Serbian_JE = 0x6b8 +Cyrillic_LJE = 0x6b9 +Serbian_LJE = 0x6b9 +Cyrillic_NJE = 0x6ba +Serbian_NJE = 0x6ba +Serbian_TSHE = 0x6bb +Macedonia_KJE = 0x6bc +Byelorussian_SHORTU = 0x6be +Cyrillic_DZHE = 0x6bf +Serbian_DZE = 0x6bf +Cyrillic_yu = 0x6c0 +Cyrillic_a = 0x6c1 +Cyrillic_be = 0x6c2 +Cyrillic_tse = 0x6c3 +Cyrillic_de = 0x6c4 +Cyrillic_ie = 0x6c5 +Cyrillic_ef = 0x6c6 +Cyrillic_ghe = 0x6c7 +Cyrillic_ha = 0x6c8 +Cyrillic_i = 0x6c9 +Cyrillic_shorti = 0x6ca +Cyrillic_ka = 0x6cb +Cyrillic_el = 0x6cc +Cyrillic_em = 0x6cd +Cyrillic_en = 0x6ce +Cyrillic_o = 0x6cf +Cyrillic_pe = 0x6d0 +Cyrillic_ya = 0x6d1 +Cyrillic_er = 0x6d2 +Cyrillic_es = 0x6d3 +Cyrillic_te = 0x6d4 +Cyrillic_u = 0x6d5 +Cyrillic_zhe = 0x6d6 +Cyrillic_ve = 0x6d7 +Cyrillic_softsign = 0x6d8 +Cyrillic_yeru = 0x6d9 +Cyrillic_ze = 0x6da +Cyrillic_sha = 0x6db +Cyrillic_e = 0x6dc +Cyrillic_shcha = 0x6dd +Cyrillic_che = 0x6de +Cyrillic_hardsign = 0x6df +Cyrillic_YU = 0x6e0 +Cyrillic_A = 0x6e1 +Cyrillic_BE = 0x6e2 +Cyrillic_TSE = 0x6e3 +Cyrillic_DE = 0x6e4 +Cyrillic_IE = 0x6e5 +Cyrillic_EF = 0x6e6 +Cyrillic_GHE = 0x6e7 +Cyrillic_HA = 0x6e8 +Cyrillic_I = 0x6e9 +Cyrillic_SHORTI = 0x6ea +Cyrillic_KA = 0x6eb +Cyrillic_EL = 0x6ec +Cyrillic_EM = 0x6ed +Cyrillic_EN = 0x6ee +Cyrillic_O = 0x6ef +Cyrillic_PE = 0x6f0 +Cyrillic_YA = 0x6f1 +Cyrillic_ER = 0x6f2 +Cyrillic_ES = 0x6f3 +Cyrillic_TE = 0x6f4 +Cyrillic_U = 0x6f5 +Cyrillic_ZHE = 0x6f6 +Cyrillic_VE = 0x6f7 +Cyrillic_SOFTSIGN = 0x6f8 +Cyrillic_YERU = 0x6f9 +Cyrillic_ZE = 0x6fa +Cyrillic_SHA = 0x6fb +Cyrillic_E = 0x6fc +Cyrillic_SHCHA = 0x6fd +Cyrillic_CHE = 0x6fe +Cyrillic_HARDSIGN = 0x6ff +Greek_ALPHAaccent = 0x7a1 +Greek_EPSILONaccent = 0x7a2 +Greek_ETAaccent = 0x7a3 +Greek_IOTAaccent = 0x7a4 +Greek_IOTAdiaeresis = 0x7a5 +Greek_OMICRONaccent = 0x7a7 +Greek_UPSILONaccent = 0x7a8 +Greek_UPSILONdieresis = 0x7a9 +Greek_OMEGAaccent = 0x7ab +Greek_accentdieresis = 0x7ae +Greek_horizbar = 0x7af +Greek_alphaaccent = 0x7b1 +Greek_epsilonaccent = 0x7b2 +Greek_etaaccent = 0x7b3 +Greek_iotaaccent = 0x7b4 +Greek_iotadieresis = 0x7b5 +Greek_iotaaccentdieresis = 0x7b6 +Greek_omicronaccent = 0x7b7 +Greek_upsilonaccent = 0x7b8 +Greek_upsilondieresis = 0x7b9 +Greek_upsilonaccentdieresis = 0x7ba +Greek_omegaaccent = 0x7bb +Greek_ALPHA = 0x7c1 +Greek_BETA = 0x7c2 +Greek_GAMMA = 0x7c3 +Greek_DELTA = 0x7c4 +Greek_EPSILON = 0x7c5 +Greek_ZETA = 0x7c6 +Greek_ETA = 0x7c7 +Greek_THETA = 0x7c8 +Greek_IOTA = 0x7c9 +Greek_KAPPA = 0x7ca +Greek_LAMDA = 0x7cb +Greek_LAMBDA = 0x7cb +Greek_MU = 0x7cc +Greek_NU = 0x7cd +Greek_XI = 0x7ce +Greek_OMICRON = 0x7cf +Greek_PI = 0x7d0 +Greek_RHO = 0x7d1 +Greek_SIGMA = 0x7d2 +Greek_TAU = 0x7d4 +Greek_UPSILON = 0x7d5 +Greek_PHI = 0x7d6 +Greek_CHI = 0x7d7 +Greek_PSI = 0x7d8 +Greek_OMEGA = 0x7d9 +Greek_alpha = 0x7e1 +Greek_beta = 0x7e2 +Greek_gamma = 0x7e3 +Greek_delta = 0x7e4 +Greek_epsilon = 0x7e5 +Greek_zeta = 0x7e6 +Greek_eta = 0x7e7 +Greek_theta = 0x7e8 +Greek_iota = 0x7e9 +Greek_kappa = 0x7ea +Greek_lamda = 0x7eb +Greek_lambda = 0x7eb +Greek_mu = 0x7ec +Greek_nu = 0x7ed +Greek_xi = 0x7ee +Greek_omicron = 0x7ef +Greek_pi = 0x7f0 +Greek_rho = 0x7f1 +Greek_sigma = 0x7f2 +Greek_finalsmallsigma = 0x7f3 +Greek_tau = 0x7f4 +Greek_upsilon = 0x7f5 +Greek_phi = 0x7f6 +Greek_chi = 0x7f7 +Greek_psi = 0x7f8 +Greek_omega = 0x7f9 +Greek_switch = 0xFF7E +leftradical = 0x8a1 +topleftradical = 0x8a2 +horizconnector = 0x8a3 +topintegral = 0x8a4 +botintegral = 0x8a5 +vertconnector = 0x8a6 +topleftsqbracket = 0x8a7 +botleftsqbracket = 0x8a8 +toprightsqbracket = 0x8a9 +botrightsqbracket = 0x8aa +topleftparens = 0x8ab +botleftparens = 0x8ac +toprightparens = 0x8ad +botrightparens = 0x8ae +leftmiddlecurlybrace = 0x8af +rightmiddlecurlybrace = 0x8b0 +topleftsummation = 0x8b1 +botleftsummation = 0x8b2 +topvertsummationconnector = 0x8b3 +botvertsummationconnector = 0x8b4 +toprightsummation = 0x8b5 +botrightsummation = 0x8b6 +rightmiddlesummation = 0x8b7 +lessthanequal = 0x8bc +notequal = 0x8bd +greaterthanequal = 0x8be +integral = 0x8bf +therefore = 0x8c0 +variation = 0x8c1 +infinity = 0x8c2 +nabla = 0x8c5 +approximate = 0x8c8 +similarequal = 0x8c9 +ifonlyif = 0x8cd +implies = 0x8ce +identical = 0x8cf +radical = 0x8d6 +includedin = 0x8da +includes = 0x8db +intersection = 0x8dc +union = 0x8dd +logicaland = 0x8de +logicalor = 0x8df +partialderivative = 0x8ef +function = 0x8f6 +leftarrow = 0x8fb +uparrow = 0x8fc +rightarrow = 0x8fd +downarrow = 0x8fe +blank = 0x9df +soliddiamond = 0x9e0 +checkerboard = 0x9e1 +ht = 0x9e2 +ff = 0x9e3 +cr = 0x9e4 +lf = 0x9e5 +nl = 0x9e8 +vt = 0x9e9 +lowrightcorner = 0x9ea +uprightcorner = 0x9eb +upleftcorner = 0x9ec +lowleftcorner = 0x9ed +crossinglines = 0x9ee +horizlinescan1 = 0x9ef +horizlinescan3 = 0x9f0 +horizlinescan5 = 0x9f1 +horizlinescan7 = 0x9f2 +horizlinescan9 = 0x9f3 +leftt = 0x9f4 +rightt = 0x9f5 +bott = 0x9f6 +topt = 0x9f7 +vertbar = 0x9f8 +emspace = 0xaa1 +enspace = 0xaa2 +em3space = 0xaa3 +em4space = 0xaa4 +digitspace = 0xaa5 +punctspace = 0xaa6 +thinspace = 0xaa7 +hairspace = 0xaa8 +emdash = 0xaa9 +endash = 0xaaa +signifblank = 0xaac +ellipsis = 0xaae +doubbaselinedot = 0xaaf +onethird = 0xab0 +twothirds = 0xab1 +onefifth = 0xab2 +twofifths = 0xab3 +threefifths = 0xab4 +fourfifths = 0xab5 +onesixth = 0xab6 +fivesixths = 0xab7 +careof = 0xab8 +figdash = 0xabb +leftanglebracket = 0xabc +decimalpoint = 0xabd +rightanglebracket = 0xabe +marker = 0xabf +oneeighth = 0xac3 +threeeighths = 0xac4 +fiveeighths = 0xac5 +seveneighths = 0xac6 +trademark = 0xac9 +signaturemark = 0xaca +trademarkincircle = 0xacb +leftopentriangle = 0xacc +rightopentriangle = 0xacd +emopencircle = 0xace +emopenrectangle = 0xacf +leftsinglequotemark = 0xad0 +rightsinglequotemark = 0xad1 +leftdoublequotemark = 0xad2 +rightdoublequotemark = 0xad3 +prescription = 0xad4 +minutes = 0xad6 +seconds = 0xad7 +latincross = 0xad9 +hexagram = 0xada +filledrectbullet = 0xadb +filledlefttribullet = 0xadc +filledrighttribullet = 0xadd +emfilledcircle = 0xade +emfilledrect = 0xadf +enopencircbullet = 0xae0 +enopensquarebullet = 0xae1 +openrectbullet = 0xae2 +opentribulletup = 0xae3 +opentribulletdown = 0xae4 +openstar = 0xae5 +enfilledcircbullet = 0xae6 +enfilledsqbullet = 0xae7 +filledtribulletup = 0xae8 +filledtribulletdown = 0xae9 +leftpointer = 0xaea +rightpointer = 0xaeb +club = 0xaec +diamond = 0xaed +heart = 0xaee +maltesecross = 0xaf0 +dagger = 0xaf1 +doubledagger = 0xaf2 +checkmark = 0xaf3 +ballotcross = 0xaf4 +musicalsharp = 0xaf5 +musicalflat = 0xaf6 +malesymbol = 0xaf7 +femalesymbol = 0xaf8 +telephone = 0xaf9 +telephonerecorder = 0xafa +phonographcopyright = 0xafb +caret = 0xafc +singlelowquotemark = 0xafd +doublelowquotemark = 0xafe +cursor = 0xaff +leftcaret = 0xba3 +rightcaret = 0xba6 +downcaret = 0xba8 +upcaret = 0xba9 +overbar = 0xbc0 +downtack = 0xbc2 +upshoe = 0xbc3 +downstile = 0xbc4 +underbar = 0xbc6 +jot = 0xbca +quad = 0xbcc +uptack = 0xbce +circle = 0xbcf +upstile = 0xbd3 +downshoe = 0xbd6 +rightshoe = 0xbd8 +leftshoe = 0xbda +lefttack = 0xbdc +righttack = 0xbfc +hebrew_doublelowline = 0xcdf +hebrew_aleph = 0xce0 +hebrew_bet = 0xce1 +hebrew_beth = 0xce1 +hebrew_gimel = 0xce2 +hebrew_gimmel = 0xce2 +hebrew_dalet = 0xce3 +hebrew_daleth = 0xce3 +hebrew_he = 0xce4 +hebrew_waw = 0xce5 +hebrew_zain = 0xce6 +hebrew_zayin = 0xce6 +hebrew_chet = 0xce7 +hebrew_het = 0xce7 +hebrew_tet = 0xce8 +hebrew_teth = 0xce8 +hebrew_yod = 0xce9 +hebrew_finalkaph = 0xcea +hebrew_kaph = 0xceb +hebrew_lamed = 0xcec +hebrew_finalmem = 0xced +hebrew_mem = 0xcee +hebrew_finalnun = 0xcef +hebrew_nun = 0xcf0 +hebrew_samech = 0xcf1 +hebrew_samekh = 0xcf1 +hebrew_ayin = 0xcf2 +hebrew_finalpe = 0xcf3 +hebrew_pe = 0xcf4 +hebrew_finalzade = 0xcf5 +hebrew_finalzadi = 0xcf5 +hebrew_zade = 0xcf6 +hebrew_zadi = 0xcf6 +hebrew_qoph = 0xcf7 +hebrew_kuf = 0xcf7 +hebrew_resh = 0xcf8 +hebrew_shin = 0xcf9 +hebrew_taw = 0xcfa +hebrew_taf = 0xcfa +Hebrew_switch = 0xFF7E +Thai_kokai = 0xda1 +Thai_khokhai = 0xda2 +Thai_khokhuat = 0xda3 +Thai_khokhwai = 0xda4 +Thai_khokhon = 0xda5 +Thai_khorakhang = 0xda6 +Thai_ngongu = 0xda7 +Thai_chochan = 0xda8 +Thai_choching = 0xda9 +Thai_chochang = 0xdaa +Thai_soso = 0xdab +Thai_chochoe = 0xdac +Thai_yoying = 0xdad +Thai_dochada = 0xdae +Thai_topatak = 0xdaf +Thai_thothan = 0xdb0 +Thai_thonangmontho = 0xdb1 +Thai_thophuthao = 0xdb2 +Thai_nonen = 0xdb3 +Thai_dodek = 0xdb4 +Thai_totao = 0xdb5 +Thai_thothung = 0xdb6 +Thai_thothahan = 0xdb7 +Thai_thothong = 0xdb8 +Thai_nonu = 0xdb9 +Thai_bobaimai = 0xdba +Thai_popla = 0xdbb +Thai_phophung = 0xdbc +Thai_fofa = 0xdbd +Thai_phophan = 0xdbe +Thai_fofan = 0xdbf +Thai_phosamphao = 0xdc0 +Thai_moma = 0xdc1 +Thai_yoyak = 0xdc2 +Thai_rorua = 0xdc3 +Thai_ru = 0xdc4 +Thai_loling = 0xdc5 +Thai_lu = 0xdc6 +Thai_wowaen = 0xdc7 +Thai_sosala = 0xdc8 +Thai_sorusi = 0xdc9 +Thai_sosua = 0xdca +Thai_hohip = 0xdcb +Thai_lochula = 0xdcc +Thai_oang = 0xdcd +Thai_honokhuk = 0xdce +Thai_paiyannoi = 0xdcf +Thai_saraa = 0xdd0 +Thai_maihanakat = 0xdd1 +Thai_saraaa = 0xdd2 +Thai_saraam = 0xdd3 +Thai_sarai = 0xdd4 +Thai_saraii = 0xdd5 +Thai_saraue = 0xdd6 +Thai_sarauee = 0xdd7 +Thai_sarau = 0xdd8 +Thai_sarauu = 0xdd9 +Thai_phinthu = 0xdda +Thai_maihanakat_maitho = 0xdde +Thai_baht = 0xddf +Thai_sarae = 0xde0 +Thai_saraae = 0xde1 +Thai_sarao = 0xde2 +Thai_saraaimaimuan = 0xde3 +Thai_saraaimaimalai = 0xde4 +Thai_lakkhangyao = 0xde5 +Thai_maiyamok = 0xde6 +Thai_maitaikhu = 0xde7 +Thai_maiek = 0xde8 +Thai_maitho = 0xde9 +Thai_maitri = 0xdea +Thai_maichattawa = 0xdeb +Thai_thanthakhat = 0xdec +Thai_nikhahit = 0xded +Thai_leksun = 0xdf0 +Thai_leknung = 0xdf1 +Thai_leksong = 0xdf2 +Thai_leksam = 0xdf3 +Thai_leksi = 0xdf4 +Thai_lekha = 0xdf5 +Thai_lekhok = 0xdf6 +Thai_lekchet = 0xdf7 +Thai_lekpaet = 0xdf8 +Thai_lekkao = 0xdf9 +Hangul = 0xff31 +Hangul_Start = 0xff32 +Hangul_End = 0xff33 +Hangul_Hanja = 0xff34 +Hangul_Jamo = 0xff35 +Hangul_Romaja = 0xff36 +Hangul_Codeinput = 0xff37 +Hangul_Jeonja = 0xff38 +Hangul_Banja = 0xff39 +Hangul_PreHanja = 0xff3a +Hangul_PostHanja = 0xff3b +Hangul_SingleCandidate = 0xff3c +Hangul_MultipleCandidate = 0xff3d +Hangul_PreviousCandidate = 0xff3e +Hangul_Special = 0xff3f +Hangul_switch = 0xFF7E +Hangul_Kiyeog = 0xea1 +Hangul_SsangKiyeog = 0xea2 +Hangul_KiyeogSios = 0xea3 +Hangul_Nieun = 0xea4 +Hangul_NieunJieuj = 0xea5 +Hangul_NieunHieuh = 0xea6 +Hangul_Dikeud = 0xea7 +Hangul_SsangDikeud = 0xea8 +Hangul_Rieul = 0xea9 +Hangul_RieulKiyeog = 0xeaa +Hangul_RieulMieum = 0xeab +Hangul_RieulPieub = 0xeac +Hangul_RieulSios = 0xead +Hangul_RieulTieut = 0xeae +Hangul_RieulPhieuf = 0xeaf +Hangul_RieulHieuh = 0xeb0 +Hangul_Mieum = 0xeb1 +Hangul_Pieub = 0xeb2 +Hangul_SsangPieub = 0xeb3 +Hangul_PieubSios = 0xeb4 +Hangul_Sios = 0xeb5 +Hangul_SsangSios = 0xeb6 +Hangul_Ieung = 0xeb7 +Hangul_Jieuj = 0xeb8 +Hangul_SsangJieuj = 0xeb9 +Hangul_Cieuc = 0xeba +Hangul_Khieuq = 0xebb +Hangul_Tieut = 0xebc +Hangul_Phieuf = 0xebd +Hangul_Hieuh = 0xebe +Hangul_A = 0xebf +Hangul_AE = 0xec0 +Hangul_YA = 0xec1 +Hangul_YAE = 0xec2 +Hangul_EO = 0xec3 +Hangul_E = 0xec4 +Hangul_YEO = 0xec5 +Hangul_YE = 0xec6 +Hangul_O = 0xec7 +Hangul_WA = 0xec8 +Hangul_WAE = 0xec9 +Hangul_OE = 0xeca +Hangul_YO = 0xecb +Hangul_U = 0xecc +Hangul_WEO = 0xecd +Hangul_WE = 0xece +Hangul_WI = 0xecf +Hangul_YU = 0xed0 +Hangul_EU = 0xed1 +Hangul_YI = 0xed2 +Hangul_I = 0xed3 +Hangul_J_Kiyeog = 0xed4 +Hangul_J_SsangKiyeog = 0xed5 +Hangul_J_KiyeogSios = 0xed6 +Hangul_J_Nieun = 0xed7 +Hangul_J_NieunJieuj = 0xed8 +Hangul_J_NieunHieuh = 0xed9 +Hangul_J_Dikeud = 0xeda +Hangul_J_Rieul = 0xedb +Hangul_J_RieulKiyeog = 0xedc +Hangul_J_RieulMieum = 0xedd +Hangul_J_RieulPieub = 0xede +Hangul_J_RieulSios = 0xedf +Hangul_J_RieulTieut = 0xee0 +Hangul_J_RieulPhieuf = 0xee1 +Hangul_J_RieulHieuh = 0xee2 +Hangul_J_Mieum = 0xee3 +Hangul_J_Pieub = 0xee4 +Hangul_J_PieubSios = 0xee5 +Hangul_J_Sios = 0xee6 +Hangul_J_SsangSios = 0xee7 +Hangul_J_Ieung = 0xee8 +Hangul_J_Jieuj = 0xee9 +Hangul_J_Cieuc = 0xeea +Hangul_J_Khieuq = 0xeeb +Hangul_J_Tieut = 0xeec +Hangul_J_Phieuf = 0xeed +Hangul_J_Hieuh = 0xeee +Hangul_RieulYeorinHieuh = 0xeef +Hangul_SunkyeongeumMieum = 0xef0 +Hangul_SunkyeongeumPieub = 0xef1 +Hangul_PanSios = 0xef2 +Hangul_KkogjiDalrinIeung = 0xef3 +Hangul_SunkyeongeumPhieuf = 0xef4 +Hangul_YeorinHieuh = 0xef5 +Hangul_AraeA = 0xef6 +Hangul_AraeAE = 0xef7 +Hangul_J_PanSios = 0xef8 +Hangul_J_KkogjiDalrinIeung = 0xef9 +Hangul_J_YeorinHieuh = 0xefa +Korean_Won = 0xeff @@ -0,0 +1,332 @@ +# +# Constants for gtk.py +# + +# true/false +FALSE = 0 +TRUE = 1 + +# GtkAccelFlag's +ACCEL_VISIBLE = 1 << 0 +ACCEL_SIGNAL_VISIBLE = 1 << 1 +ACCEL_LOCKED = 1 << 2 +ACCEL_MASK = 0x07 + +# GtkArrowType's +ARROW_UP = 0 +ARROW_DOWN = 1 +ARROW_LEFT = 2 +ARROW_RIGHT = 3 + +# GtkAttachOptions +EXPAND = 1 << 0 +SHRINK = 1 << 1 +FILL = 1 << 2 + +# GtkButtonBoxStyle's +BUTTONBOX_DEFAULT_STYLE = 0 +BUTTONBOX_SPREAD = 1 +BUTTONBOX_EDGE = 2 +BUTTONBOX_START = 3 +BUTTONBOX_END = 4 + +# GtkCalendarDisplayOptions's +CALENDAR_SHOW_HEADING = 1 << 0 +CALENDAR_SHOW_DAY_NAMES = 1 << 1 +CALENDAR_NO_MONTH_CHANGE = 1 << 2 +CALENDAR_SHOW_WEEK_NUMBERS = 1 << 3 +CALENDAR_WEEK_START_MONDAY = 1 << 4 + +# GtkCurveType's +CURVE_TYPE_LINEAR = 0 +CURVE_TYPE_SPLINE = 1 +CURVE_TYPE_FREE = 2 + +# GtkDirectionType's +DIR_TAB_FORWARD = 0 +DIR_TAB_BACKWARD = 1 +DIR_UP = 2 +DIR_DOWN = 3 +DIR_LEFT = 4 +DIR_RIGHT = 5 + +# GtkJustification's +JUSTIFY_LEFT = 0 +JUSTIFY_RIGHT = 1 +JUSTIFY_CENTER = 2 +JUSTIFY_FILL = 3 + +# GtkMatchType's +MATCH_ALL = 0 +MATCH_ALL_TAIL = 1 +MATCH_HEAD = 2 +MATCH_TAIL = 3 +MATCH_EXACT = 4 +MATCH_LAST = 5 + +# GtkMenuDirectionType's +MENU_DIR_PARENT = 0 +MENU_DIR_CHILD = 1 +MENU_DIR_NEXT = 2 +MENU_DIR_PREV = 3 + +# GtkMenuFactoryType's +MENU_FACTORY_MENU = 0 +MENU_FACTORY_MENU_BAR = 1 +MENU_FACTORY_OPTION_MENU = 2 + +# GtkMetricType's +PIXELS = 0 +INCHES = 1 +CENTIMETERS = 2 + +# GtkOrientation's +ORIENTATION_HORIZONTAL = 0 +ORIENTATION_VERTICAL = 1 + +# GtkPackType's +PACK_START = 0 +PACK_END = 1 + +# GtkPathPriorityType's +PATH_PRIO_LOWEST = 0 +PATH_PRIO_GTK = 4 +PATH_PRIO_APPLICATION = 8 +PATH_PRIO_RC = 12 +PATH_PRIO_HIGHEST = 15 +PATH_PRIO_MASK = 0x0f + +# GtkPathType's +PATH_WIDGET = 0 +PATH_WIDGET_CLASS = 1 +PATH_CLASS = 2 + +# GtkPolicyType's +POLICY_ALWAYS = 0 +POLICY_AUTOMATIC = 1 +POLICY_NEVER = 2 + +# GtkPositionType's +POS_LEFT = 0 +POS_RIGHT = 1 +POS_TOP = 2 +POS_BOTTOM = 3 + +# GtkPreviewType's +PREVIEW_COLOR = 0 +PREVIEW_GRAYSCALE = 1 + +# GtkReliefStyle's +RELIEF_NORMAL = 0 +RELIEF_HALF = 1 +RELIEF_NONE = 2 + +# GtkResizeMode's +RESIZE_PARENT = 0 +RESIZE_QUEUE = 1 +RESIZE_IMMEDIATE = 2 + +# GtkScrollType's +SCROLL_NONE = 0 +SCROLL_STEP_BACKWARD = 1 +SCROLL_STEP_FORWARD = 2 +SCROLL_PAGE_BACKWARD = 3 +SCROLL_PAGE_FORWARD = 4 +SCROLL_JUMP = 5 + +# GtkSelectionMode's +SELECTION_SINGLE = 0 +SELECTION_BROWSE = 1 +SELECTION_MULTIPLE = 2 +SELECTION_EXTENDED = 3 + +# GtkShadowType's +SHADOW_NONE = 0 +SHADOW_IN = 1 +SHADOW_OUT = 2 +SHADOW_ETCHED_IN = 3 +SHADOW_ETCHED_OUT = 4 + +# GtkSortType's +SORT_ASCENDING = 0 +SORT_DESCENDING = 1 + +# GtkStateType's +STATE_NORMAL = 0 +STATE_ACTIVE = 1 +STATE_PRELIGHT = 2 +STATE_SELECTED = 3 +STATE_INSENSITIVE = 4 + +# GtkSubmenuDirection's +DIRECTION_LEFT = 0 +DIRECTION_RIGHT = 1 + +# GtkSubmenuPlacement's +TOP_BOTTOM = 0 +LEFT_RIGHT = 1 + +# GtkTargetFlags +TARGET_SAME_APP = 1 << 0 +TARGET_SAME_WIDGET = 1 << 1 + +# GtkToolbarStyle's +TOOLBAR_ICONS = 0 +TOOLBAR_TEXT = 1 +TOOLBAR_BOTH = 2 + +# GtkTroughType's +TROUGH_NONE = 0 +TROUGH_START = 1 +TROUGH_END = 2 +TROUGH_JUMP = 3 + +# GtkUpdateType's +UPDATE_CONTINUOUS = 0 +UPDATE_DISCONTINUOUS = 1 +UPDATE_DELAYED = 2 + +# GtkVisibility's +VISIBILITY_NONE = 0 +VISIBILITY_PARTIAL = 1 +VISIBILITY_FULL = 2 + +# GtkWindowPosition's +WIN_POS_NONE = 0 +WIN_POS_CENTER = 1 +WIN_POS_MOUSE = 2 + +# GtkWindowType's +WINDOW_TOPLEVEL = 0 +WINDOW_DIALOG = 1 +WINDOW_POPUP = 2 + +# GtkObjectFlag's +DESTROYED = 1 << 0 +FLOATING = 1 << 1 +CONNECTED = 1 << 2 +RESERVED_2 = 1 << 3 +# GtkWidgetFlag's +TOPLEVEL = 1 << 4 +NO_WINDOW = 1 << 5 +REALIZED = 1 << 6 +MAPPED = 1 << 7 +VISIBLE = 1 << 8 +SENSITIVE = 1 << 9 +PARENT_SENSITIVE = 1 << 10 +CAN_FOCUS = 1 << 11 +HAS_FOCUS = 1 << 12 +CAN_DEFAULT = 1 << 13 +HAS_DEFAULT = 1 << 14 +HAS_GRAB = 1 << 15 +RC_STYLE = 1 << 16 +COMPOSITE_CHILD = 1 << 17 +BASIC = 1 << 18 + +# GtkCellType's +CELL_EMPTY = 0 +CELL_TEXT = 1 +CELL_PIXMAP = 2 +CELL_PIXTEXT = 3 +CELL_WIDGET = 4 + +# GtkCTreePos's +CTREE_POS_BEFORE = 0 +CTREE_POS_AS_CHILD = 1 +CTREE_POS_AFTER = 2 + +# GtkCTreeLineStyle's +CTREE_LINES_NONE = 0 +CTREE_LINES_SOLID = 1 +CTREE_LINES_DOTTED = 2 +CTREE_LINES_TABBED = 3 + +# GtkCTreeExpanderStyle's +CTREE_EXPANDER_NONE = 0 +CTREE_EXPANDER_SQUARE = 1 +CTREE_EXPANDER_TRIANGLE = 2 +CTREE_EXPANDER_CIRCULAR = 3 + +# GtkCTreeExpansionType's +CTREE_EXPANSION_EXPAND = 0 +CTREE_EXPANSION_EXPAND_RECURSIVE = 1 +CTREE_EXPANSION_COLLAPSE = 2 +CTREE_EXPANSION_COLLAPSE_RECURSIVE = 3 +CTREE_EXPANSION_TOGGLE = 4 +CTREE_EXPANSION_TOGGLE_RECURSIVE = 5 + +# GtkDestDefaults ... +DEST_DEFAULT_MOTION = 1 << 0 +DEST_DEFAULT_HIGHLIGHT = 1 << 1 +DEST_DEFAULT_DROP = 1 << 2 +DEST_DEFAULT_ALL = 0x07 + +# GtkFontMetricType's +PIXELS_METRIC = 0 +POINTS_METRIC = 1 + +# GtkPackerOption's +PACK_EXPAND = 1 << 0 +FILL_X = 1 << 1 +FILL_Y = 1 << 2 + +# GtkSideType's +SIDE_TOP = 0 +SIDE_BOTTOM = 1 +SIDE_LEFT = 2 +SIDE_RIGHT = 3 + +# GtkAnchorType's +ANCHOR_CENTER = 0 +ANCHOR_NORTH = 1 +ANCHOR_NORTH_WEST = 2 +ANCHOR_NORTH_EAST = 3 +ANCHOR_SOUTH = 4 +ANCHOR_SOUTH_WEST = 5 +ANCHOR_SOUTH_EAST = 6 +ANCHOR_WEST = 7 +ANCHOR_EAST = 8 +ANCHOR_N = ANCHOR_NORTH +ANCHOR_NW = ANCHOR_NORTH_WEST +ANCHOR_NE = ANCHOR_NORTH_EAST +ANCHOR_S = ANCHOR_SOUTH +ANCHOR_SW = ANCHOR_SOUTH_WEST +ANCHOR_SE = ANCHOR_SOUTH_EAST +ANCHOR_W = ANCHOR_WEST +ANCHOR_E = ANCHOR_EAST + +# GtkProgressBarStyle's +PROGRESS_CONTINUOUS = 0 +PROGRESS_DISCRETE = 1 + +# GtkProgressBarOrientation's +PROGRESS_LEFT_TO_RIGHT = 0 +PROGRESS_RIGHT_TO_LEFT = 1 +PROGRESS_BOTTOM_TO_TOP = 2 +PROGRESS_TOP_TO_BOTTOM = 3 + +# GtkSpinButtonUpdatePolicy's +UPDATE_ALWAYS = 0 +UPDATE_IF_VALID = 1 + +# GtkSpinType's +SPIN_STEP_FORWARD = 0 +SPIN_STEP_BACKWARD = 1 +SPIN_PAGE_FORWARD = 2 +SPIN_PAGE_BACKWARD = 3 +SPIN_HOME = 4 +SPIN_END = 5 +SPIN_USER_DEFINED = 6 + +# GtkToolbarChildType's +TOOLBAR_CHILD_SPACE = 0 +TOOLBAR_CHILD_BUTTON = 1 +TOOLBAR_CHILD_TOGGLEBUTTON = 2 +TOOLBAR_CHILD_RADIOBUTTON = 3 +TOOLBAR_CHILD_WIDGET = 4 + +# GtkTreeViewMode's +TREE_VIEW_LINE = 0 +TREE_VIEW_ITEM = 1 + + diff --git a/GdkImlib.py b/GdkImlib.py new file mode 100644 index 00000000..d74195ef --- /dev/null +++ b/GdkImlib.py @@ -0,0 +1,146 @@ +# +# GdkImlib: An interface to gdk_imlib to go with gtk.py. It wraps the +# native module _gdkimlib. It is sugested that you import it as +# "import GdkImlib". +# +# Author: James Henstridge <james@daa.com.au> +# +# To use GdkImlib, create an instance of the GdkImlib.Image class. The +# constructor takes a filename as its one argument. Then call the render +# method (optionally with width and height arguments), and finally call +# the make_pixamp method to get a GTK pixmap widget with the image loaded. +# +# For extra information, read the rest of this file, and Imlib's documentation. +# + +import _gdkimlib + +from gtk import GtkPixmap + +#some constants ... +RT_PLAIN_PALETTE = 0 +RT_PLAIN_PALETTE_FAST = 1 +RT_DITHER_PALETTE = 2 +RT_DITHER_PALETTE_FAST = 3 +RT_PLAIN_TRUECOL = 4 +RT_DITHER_TRUECOL = 5 + +_gdkimlib.gdk_imlib_init() + +class Image: + def __init__(self, filename="", _obj=None): + if _obj: self._im = _obj; return + self._im = _gdkimlib.gdk_imlib_load_image(filename) + def __getattr__(self, attr): + attrs = { + 'rgb_width': _gdkimlib.gdk_imlib_get_rgb_width, + 'rgb_height': _gdkimlib.gdk_imlib_get_rgb_height, + 'filename': _gdkimlib.gdk_imlib_get_filename + } + if attrs.has_key(attr): + return attrs[attr](self._im) + raise AttributeError, attr + def render(self, width=None, height=None): + return _gdkimlib.gdk_imlib_render(self._im, + width or self.rgb_width, + height or self.rgb_height) + def get_image_border(self): + return _gdkimlib.gdk_imlib_get_image_border(self._im) + def set_image_border(self, left=0, right=0, top=0, bottom=0): + _gdkimlib.gdk_imlib_set_image_border(self._im, (left, right, + top, bottom)) + def get_image_shape(self): + return _gdkimlib.gdk_imlib_get_image_shape(self._im) + def set_image_shape(self, red, green, blue): + _gdkimlib.gdk_imlib_set_image_shape(self._im,(red,green,blue)) + def save_image_to_eim(self, file): + _gdkimlib.gdk_imlib_save_image_to_eim(self._im, file) + def add_image_to_eim(self, file): + _gdkimlib.gdk_imlib_add_image_to_eim(self._im, file) + def save_image_to_ppm(self, file): + _gdkimlib.gdk_imlib_save_image_to_ppm(self._im, file) + def set_image_modifier(self, gamma, brightness, contrast): + _gdkimlib.gdk_imlib_set_image_modifier(self._im, + (gamma, brightness, contrast)) + def set_image_red_modifier(self, gamma, brightness, contrast): + _gdkimlib.gdk_imlib_set_image_red_modifier(self._im, + (gamma, brightness, contrast)) + def set_image_blue_modifier(self, gamma, brightness, contrast): + _gdkimlib.gdk_imlib_set_image_red_modifier(self._im, + (gamma, brightness, contrast)) + def set_image_green_modifier(self, gamma, brightness, contrast): + _gdkimlib.gdk_imlib_set_image_red_modifier(self._im, + (gamma, brightness, contrast)) + def get_image_modifier(self): + return _gdkimlib.gdk_imlib_get_image_modifier(self._im) + def get_image_red_modifier(self): + return _gdkimlib.gdk_imlib_get_image_red_modifier(self._im) + def get_image_green_modifier(self): + return _gdkimlib.gdk_imlib_get_image_green_modifier(self._im) + def get_image_blue_modifier(self): + return _gdkimlib.gdk_imlib_get_image_blue_modifier(self._im) + def set_image_red_curve(self, curve): + _gdkimlib.gdk_imlib_set_image_red_curve(self._im, curve) + def set_image_green_curve(self, curve): + _gdkimlib.gdk_imlib_set_image_green_curve(self._im, curve) + def set_image_blue_curve(self, curve): + _gdkimlib.gdk_imlib_set_image_blue_curve(self._im, curve) + def get_image_red_curve(self): + return _gdkimlib.gdk_imlib_get_image_red_curve(self._im) + def get_image_green_curve(self): + return _gdkimlib.gdk_imlib_get_image_green_curve(self._im) + def get_image_blue_curve(self): + return _gdkimlib.gdk_imlib_get_image_blue_curve(self._im) + def apply_modifiers_to_rgb(self): + _gdkimlib.gdk_imlib_apply_modifiers_to_rgb(self._im) + def changed_image(self): + _gdkimlib.gdk_imlib_changed_image(self._im) + def flip_image_horizontal(self): + _gdkimlib.gdk_imlib_flip_image_horizontal(self._im) + def flip_image_vertical(self): + _gdkimlib.gdk_imlib_flip_image_vertical(self._im) + def rotate_image(self, d): + _gdkimlib.gdk_imlib_rotate_image(self._im, d) + def clone_image(self): + return Image(_obj=_gdkimlib.gdk_imlib_clone_image(self._im)) + def clone_scaled_image(self, width, height): + return Image(_obj=_gdkimlib.gdk_imlib_clone_scaled_image( + self._im, width, height)) + def crop_image(self, x, y, w, h): + _gdkimlib.gdk_imlib_crop_image(self._im, x, y, w, h) + def save_image(self, file): + return _gdkimlib.gdk_imlib_save_image(self._im, file) + def crop_and_clone_image(self, x, y, w, h): + return Image(_obj=_gdkimlib.gdk_imlib_crop_and_clone_image( + self._im, x, y, w, h)) + def make_pixmap(self): + return GtkPixmap(_obj= + _gdkimlib.gdk_imlib_make_pixmap(self._im)) + def get_pixmap(self): + return _gdkimlib.gdk_imlib_get_pixmap(self._im) + +def create_image_from_data(data, alpha, width, height): + # alpha can be None + return Image(_obj=_gdkimlib.gdk_imlib_create_image_from_data( + data, alpha, width, height)) + +def create_image_from_drawable(drawable, mask, x, y, width, height): + return Image(_obj=_gdkimlib.gdk_imlib_create_image_from_drawable( + drawable, mask, x, y, width, height)) + +def get_render_type(): + return _gdkimlib.gdk_imlib_get_render_type() +def set_render_type(rend_type): + _gdkimlib.gdk_imlib_set_render_type(rend_type) +def load_colors(file): + return _gdkimlib.gdk_imlib_load_colors(file) +def free_colors(): + _gdkimlib.gdk_imlib_free_colors() +def get_fallback(): + return _gdkimlib.gdk_imlib_get_fallback() +def set_fallback(fallback): + _gdkimlib.gdk_imlib_set_fallback(fallback) +def get_sysconfig(): + return _gdkimlib.gdk_imlib_get_sysconfig() +def best_color_match(r, g, b): + return _gdkimlib.gdk_imlib_best_color_match(r, g, b) diff --git a/GtkExtra.py b/GtkExtra.py new file mode 100644 index 00000000..69425ed3 --- /dev/null +++ b/GtkExtra.py @@ -0,0 +1,249 @@ +# +# This file contains some convenience routines for gtk.py. +# It includes a python implementation of the GtkMenuFactory, and +# the functions message_box, file_open_box and file_save_box create +# and manage the respective dialogs. +# + +from gtk import * +import string + +MENU_FACTORY_MENU_BAR = 0 +MENU_FACTORY_MENU = 1 +MENU_FACTORY_OPTION_MENU = 2 + +# type is MENU_FACTORY_{MENU,MENU_BAR,OPTION_MENU} +class MenuFactory: + def __init__(self, type=MENU_FACTORY_MENU_BAR): + self.accelerator = GtkAccelGroup() + if type == MENU_FACTORY_MENU_BAR: + self.__w = GtkMenuBar() + self.__ret = self.__w + elif type == MENU_FACTORY_MENU: + self.__w = GtkMenu() + self.__w.set_accel_group(self.accelerator) + self.__ret = self.__w + elif type == MENU_FACTORY_OPTION_MENU: + self.__w = GtkMenu() + self.__w.set_accel_group(self.accelerator) + self.__ret = GtkOptionMenu() + self.__ret.set_menu(self.__w) + self.__menus = {} + self.__items = {} + def __getattr__(self, key): + return getattr(self.__ret, key) + def add_entries(self, entries): + for entry in entries: + apply(self.create, tuple(entry)) + def create(self, path, accelerator=None, callback=None, *args): + last_slash = string.rfind(path, '/') + if last_slash < 0: + parentmenu = self.__w + else: + parentmenu = self.get_menu(path[:last_slash]) + label = path[last_slash+1:] + if label == '<separator>': + item = GtkMenuItem() + elif label[:7] == '<check>': + item = GtkCheckMenuItem(label[7:]) + else: + item = GtkMenuItem(label) + if label != '<nothing>': + item.show() + if accelerator: + key, mods = self.parse_accelerator(accelerator) + item.add_accelerator("activate", self.accelerator, + key, mods, 'visible') + if callback: + item.connect("activate", callback) + # right justify the help menu automatically + if string.lower(label) == 'help' and parentmenu == self.__w: + item.right_justify() + parentmenu.append(item) + self.__items[path] = item + return item + def get_menu(self, path): + if path == '': + return self.__w + if self.__menus.has_key(path): + return self.__menus[path] + wid = self.create(path) + menu = GtkMenu() + menu.set_accel_group(self.accelerator) + wid.set_submenu(menu) + self.__menus[path] = menu + return menu + def parse_accelerator(self, accelerator): + key = 0 + mods = 0 + done = FALSE + while not done: + if accelerator[:7] == '<shift>': + mods = mods | GDK.SHIFT_MASK + accelerator = accelerator[7:] + elif accelerator[:5] == '<alt>': + mods = mods | GDK.MOD1_MASK + accelerator = accelerator[5:] + elif accelerator[:6] == '<meta>': + mods = mods | GDK.MOD1_MASK + accelerator = accelerator[6:] + elif accelerator[:9] == '<control>': + mods = mods | GDK.CONTROL_MASK + accelerator = accelerator[9:] + else: + done = TRUE + key = ord(accelerator[0]) + return key, mods + def remove_entry(self, path): + if path not in self.__items.keys(): + return + item = self.__items[path] + item.destroy() + length = len(path) + # clean up internal hashes + for i in self.__items.keys(): + if i[:length] == path: + del self.__items[i] + for i in self.__menus.keys(): + if i[:length] == path: + del self.__menus[i] + def remove_entries(self, paths): + for path in paths: + self.remove_entry(path) + def find(self, path): + return self.__items[path] + +class _MessageBox(GtkDialog): + def __init__(self, message="", buttons=(), pixmap=None, modal=TRUE): + GtkDialog.__init__(self) + self.connect("destroy", self.quit) + self.connect("delete_event", self.quit) + if modal: + grab_add(self) + hbox = GtkHBox(spacing=5) + hbox.border_width(5) + self.vbox.pack_start(hbox) + hbox.show() + if pixmap: + self.realize() + pixmap = GtkPixmap(self, pixmap) + hbox.pack_start(pixmap, expand=FALSE) + pixmap.show() + label = GtkLabel(message) + hbox.pack_start(label) + label.show() + + for text in buttons: + b = GtkButton(text) + b.set_flags(CAN_DEFAULT) + b.set_data("user_data", text) + b.connect("clicked", self.click) + self.action_area.pack_start(b) + b.show() + self.ret = None + def quit(self, *args): + self.hide() + self.destroy() + mainquit() + def click(self, button): + self.ret = button.get_data("user_data") + self.quit() + +# create a message box, and return which button was pressed +def message_box(title="Message Box", message="", buttons=(), pixmap=None, + modal=TRUE): + win = _MessageBox(message, buttons, pixmap=pixmap, modal=modal) + win.set_title(title) + win.show() + mainloop() + return win.ret + +class _EntryDialog(GtkDialog): + def __init__(self, message="", modal=TRUE): + GtkDialog.__init__(self) + self.connect("destroy", self.quit) + self.connect("delete_event", self.quit) + if modal: + grab_add(self) + box = GtkVBox(spacing=10) + box.border_width(10) + self.vbox.pack_start(box) + box.show() + if message: + label = GtkLabel(message) + box.pack_start(label) + label.show() + self.entry = GtkEntry() + box.pack_start(self.entry) + self.entry.show() + self.entry.grab_focus() + + button = GtkButton("OK") + button.connect("clicked", self.click) + button.set_flags(CAN_DEFAULT) + self.action_area.pack_start(button) + button.show() + button.grab_default() + button = GtkButton("Cancel") + button.connect("clicked", self.quit) + button.set_flags(CAN_DEFAULT) + self.action_area.pack_start(button) + button.show() + + self.ret = None + def quit(self, w=None, event=None): + self.hide() + self.destroy() + mainquit() + def click(self, button): + self.ret = self.entry.get_text() + self.quit() + +def input_box(title="Input Box", message="", modal=TRUE): + win = _EntryDialog(message, modal=modal) + win.set_title(title) + win.show() + mainloop() + return win.ret + +# File selection helper functions +class _FileSelection(GtkFileSelection): + def __init__(self, modal=TRUE): + GtkFileSelection.__init__(self) + self.connect("destroy", self.quit) + self.connect("delete_event", self.quit) + if modal: + grab_add(self) + self.cancel_button.connect('clicked', self.quit) + self.ok_button.connect('clicked', self.ok_cb) + self.ret = None + def quit(self, *args): + self.hide() + self.destroy() + mainquit() + def ok_cb(self, b): + self.ret = self.get_filename() + self.quit() + +def file_sel_box(title="Browse", modal=FALSE): + win = _FileSelection(modal=modal) + win.set_title(title) + win.show() + mainloop() + return win.ret + +def file_open_box(modal=TRUE): + return file_sel_box("Open", modal=modal) +def file_save_box(modal=TRUE): + return file_sel_box("Save As", modal=modal) + +def debug_main_quit(): + """Create a window with a button to call mainquit""" + win = GtkWindow() + win.set_title("Quit") + win.set_usize(125, -1) + b = GtkButton("Main Quit") + b.connect("clicked", mainquit) + win.add(b) + b.show() + win.show() diff --git a/Gtkinter.py b/Gtkinter.py new file mode 100644 index 00000000..65f70b56 --- /dev/null +++ b/Gtkinter.py @@ -0,0 +1,8 @@ + +#This is for compatibility. + +print "importing Gtkinter is deprecated -- use 'from gtk import *'" + +from gtk import * +from gtk import _name2cls,_obj2inst + diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 00000000..1992291f --- /dev/null +++ b/Makefile.am @@ -0,0 +1,78 @@ +SUBDIRS = generate pyglade + +INCLUDES= $(PYTHON_INCLUDES) $(PYTHON_CFLAGS) $(GTK_CFLAGS) $(GDK_IMLIB_CFLAGS) + +## BUILD_IMLIB == # if imlib wasn't found +pyexec_PROGRAMS = _gtkmodule$(SO) @BUILD_IMLIB@ _gdkimlibmodule$(SO) +EXTRA_PROGRAMS = + +_gtkmodule__SO__SOURCES = gtkmodule.c +_gtkmodule__SO__LDADD = $(GTK_LIBS) +_gtkmodule__SO__LINK = $(PYTHON_LINK) + + +_gdkimlibmodule__SO__SOURCES = gdkimlibmodule.c +_gdkimlibmodule__SO__LDADD = $(GDK_IMLIB_LIBS) +_gdkimlibmodule__SO__LINK = $(PYTHON_LINK) + +python_PYTHON = gtk.py Gtkinter.py GTK.py GDK.py GtkExtra.py GdkImlib.py +noinst_PYTHON = mkgtk.py description.py + +# stuff to automatically generate gtkmodule_*.c + +GENERATE = generate/scmexpr.py generate/generate.py +GTKMODULE_DEFS = generate/gtk.defs generate/gtkbase.defs \ + generate/gtkcontainers.defs generate/gtkdata.defs generate/gtkedit.defs \ + generate/gtkenums.defs generate/gtklists.defs generate/gtkmenus.defs \ + generate/gtkmisc.defs generate/gtkranges.defs generate/gtkdnd.defs + +gtkmodule_defs.c gtkmodule_impl.c: mkgtk.py $(GENERATE) $(GTKMODULE_DEFS) + cd $(srcdir) && $(PYTHON) mkgtk.py + +gtkmodule.o: gtkmodule_defs.c gtkmodule_impl.c + +EXTRA_DIST = \ + pygtk.spec \ + examples/imlib/view.py \ + examples/ide/gtkcons.py \ + examples/ide/gtkdb.py \ + examples/ide/edit.py \ + examples/ide/browse.py \ + examples/ide/minibreak.xpm \ + examples/ide/README \ + examples/ide/gtkprof.py \ + examples/ide/pyide.py \ + examples/ide/break.xpm \ + examples/ide/return.xpm \ + examples/ide/next.xpm \ + examples/ide/continue.xpm \ + examples/ide/step.xpm \ + examples/ide/edit.xpm \ + examples/ide/run.xpm \ + examples/ide/quit.xpm \ + examples/simple/hello1.py \ + examples/simple/hello2.py \ + examples/simple/simple1.py \ + examples/simple/simple2.py \ + examples/simple/tooltip1.py \ + examples/simple/tooltip2.py \ + examples/simple/scribble.py \ + examples/simple/README \ + examples/testgtk/testgtk.py \ + examples/testgtk/test.xpm \ + examples/testgtk/testgtkrc \ + examples/testgtk/README \ + examples/neil/TAppli.py \ + examples/neil/TAppli2.py \ + examples/neil/TAppli3.py \ + examples/neil/TAppli4.py \ + examples/neil/TAppli5.py \ + examples/neil/bomb.xpm \ + examples/neil/gtk-logo.xpm \ + examples/neil/question.xpm \ + examples/neil/notebook.py \ + examples/neil/README \ + examples/glade/README \ + examples/glade/test2.glade \ + examples/glade/glade.py \ + examples/glade/test.glade @@ -0,0 +1,393 @@ +pygtk-0.5.6: 27-November-1998 + - Updated for gtk+-1.1.5. + - Renamed Gtkinter.py to gtk.py. This follows the naming scheme of + other modules more closely, and is easier for people who prefer to + use "import ...". It is also not a big change for people who + use "from ... import *". I have included a simple Gtkinter.py + module for backward compatibility. + - Added a private function PyGtk_RegisterBoxed that can be used to add + extra boxed types to the list of those registered in the callback + marshals and the like. + +pygtk-0.5.5: 17-November-1998 + - Fixed a small bug in GdkImlib that caused a syntax error (I should + have picked this up for the last release). + - Removed some function wrappers that are not used anywhere, in order + to get pygtk to compile cleanly on newer CVS GTK's. + - I forgot to include the wrappings for the new GtkCalendar widget in + the previous release. It is in this one. + +pygtk-0.5.4: 15-November-1998 + - updated for gtk+-1.1.3 (so you will need glib-1.1.4 as well). This + release adds support for the new DnD functions, support for + selection (through the gtk_selection_* functions, which I have + mapped to GtkWidget.selection_*) and GdkAtoms, and support for + GdkCursors. + - To create a new cursor, use the cursor_new or cursor_new_from_pixmap + function, and then call the GdkWindow.set_cursor method to attach + it to a window. + - Added create_pixmap_from_xpm_d function that allows you to embed + XPM data into your program for easier distribution. + - Updated the GdkImlib module to the features found in imlib-1.8. + - Changed the build system, so SWIG is no longer needed. Also now + using a modified version of automake to generate the makefiles. + - Updated the pyglade code to handle menus and the like. + +pygtk-0.5.3: 27-September-1998 + - Updated for GTK+-1.1.2 (note that this version of gtk requires + glib-1.1.3). This version adds the support for the tearoff menus + and keyboard navigation of menus (if you use item factory). + - This is the version of pygtk you will need for the pygnome wrapper + for gnome v0.30 (when I finish writing them). + - added events_pending function. Now you can use code like: + while events_pending(): + mainiteration() + to be sure that a scrollbar has been updated. + - I have updated the examples/neil/*.py examples to use the + GtkItemFactory class. This shows how to make keyboard navigable + menus. + - Fixed a typo in GtkWindow.set_focus + - Fixed signal handler wrapper, so that handlers that return GtkObject + classes get the return type converted back to the lower level + GtkObjects. Also fixed _gtkbasemodule.c, so that return values from + signals get returned to GTK properly. These fixes should allow + people to use the GnomeMDI wrappers in pygnome if you change + there signal definitions to use GTK_TYPE_OBJECT rather than + GTK_TYPE_POINTER (I will ask the author to make this change). + +pygtk-0.5.2: 31-August-1998 + - fixed the ancestory for the GtkScrolledWindow class, fixed the + GtkPreview constructor. Fixed some more spots in _gtkmodule.i + where I'd used int types instead of the correct enumeration. + - added the pyglade package. This will allow you to put a bit of + code behind interfaces built with GLADE, which can be found at + http://www.comp.lancs.ac.uk/~damon/builder/index.html + In my current code, I have implemented most widgets on the + palette, although the .glade file reader is a bit fragile. Note + that this package is not a code generator (yet). It reads the + interface description and builds the interface at runtime. This + way you can keep the interface separate from the implementation. + For an example of use, check the examples/glade directory. + - Added support for the GtkItemFactory. Still no support for the + GtkCTree -- even if I did put in support for it, the signal + definitions define the GtkCTreeNode's as pointers, making it + almost useless. + +pygtk-0.5.1: 19-August-1998 + - fix a small bug in configure script that prevented building. + +pygtk-0.5.0: 18-August-1998 + - Updated for GTK+-1.1.1 + - Replaced GtkAcceleratorTable with GtkAccelGroup. + - Made use of the GtkFlagInfo and GtkEnumInfo structures. You can now + specify enum values by a string as well as by a number. Flag values + can be given as strings, or as a tuple of strings or numbers that + are ORed together. + - Added GtkAccelLabel, GtkFontSelection, GtkFontSelectionDialog, + GtkPacker and GtkProgress widgets. Also updated the methods on all + the other objects. I haven't yet done GtkCTree or GtkItemFactory. + - Fixed the gtk_widget_size_request wrapper - it now returns the size + requisition as a (w,h) tuple. + - I have split gtkmodule into _gtkbasemodule and _gtkmodule. The code + in _gtkbase is no longer generated. I have gone through and removed + uneeded code put in by swig. This reduced the size of that piece + of source by 25%. Hopefuly this will speed up some of the core + functions a bit. If you use Gtkinter, this change is invisible. + If you use gtkmodule directly, change: + from gtk import * + to + from _gtkbase import * + from _gtk import * + pygtk_init() + The pygtk_init function is part of the _gtk module, and is called + to tell it about all the types in _gtkbase. (it should be called + by the module's init routine, but I can't find out how to make that + happen. + - Updated the Gtkinter.new command. Now widget arguments don't get + the widget name prepended, so I have changed the function from + accepting the arguments as a dictionary to accepting them as + keyword arguments. (eg you can do new(GtkWindow, title="title", + allow_shrink=FALSE)). On a side note, the GTK_IS_*() functions + have been removed from gtkmodule and added in gtk_*_get_type() + functions. You can get the functionality of the removed functions + with something like GTK_CHECK_TYPE(obj, gtk_*_get_type()). + +pygtk-0.4.5: 5-August-1998 + - This may be the last gtk v1.0 release of pygtk. If you have anymore + nagging bugs, tell me now, or they won't be fixed in a version that + can compile for gtk v1.0 (I will be moving to gtk v1.1) + - Fixed some small bugs which I got bug reports about, but forgot to + patch (in draw_polygon, GtkDrawingArea.draw_polygon and load_fontset) + Also added the font argument to draw_string,draw_text. This was + what was causing those problems. + - Now gtk_set_locale is called when Gtkinter is loaded. This will + make pygtk more useful for languages with non-latin character sets + (eg Japanese). + - Fixed up new_gc, so that if you don't pass it any arguments, it + doesn't cause your program to segfault. + - Made GtkObject.connect and GtkObject.connect_after var arg functions. + Any extra arguments passed will be added to the argument list for + the signal handler. + - Added some attributes to the GdkFont object. You can now access + the ascent and descent attributes, and call the width and measure + methods, which both take a string as an argument. + +pygtk-0.4.4: 17-June-1998 + - Updated for gtk+-1.0.4, although it will work with gtk+-1.0.2 (No + new features were added between these releases). + - Fixed the date on the last changelog entry :( + - Added the file description.py. It contains a breif description + of some of the objects used in Gtkinter, such as GtkStyle's, + GdkColors, GdkGC's and so on. It is structured as a python module, + but is not intended to be imported. It can be used as a small + reference. + - Added variable GtkCList.selection, and method + GtkCList.get_selection_info. These should help using clists, and + help trap double clicks in a clist, since you can now do something + like this: + row, col = clist.get_selection_info(event.x, event.y) + in a signal handler (maybe button_press). + - Changed the GdkWindow destroy function to call gdk_pixmap_unref, if + the window was a pixmap. This gets rid of the annoying warning + when you close scribble.py. + - pointer types and unknown boxed types are now passed as Python + C objects in signal handlers. This is so wrappers for add on + widgets that use pointer arguments can write code to convert + the pointers to a more usable format. + - Changed the behaviour of the PyObject -> GtkArg routines so that + that they use python's conversion routines. Now you can pass a + class instance which has a __int__ method in place of an integer + in those routines (it implicitly uses int(o) on the instance). + - Added method GtkObject.emit, which acts like gtk_signal_emit. Now + widget.show() and widget.emit('show') are equivalent (although the + first is faster). Now you should be able to use rulers properly. + The specification is GtkObject.emit(signal_name, arg1, ...). It + returns whatever the signal handler was supposed to. The rulers + example in the testgtk.py program has been fixed, and gives an + example of the GtkObject.emit method. + - Added test of statusbar in testgtk.py. (The code was submited by + Andrew Kuchling <akuchlin@cnri.reston.va.us>) + - Fixed hude memory leak in GdkEvent initialisation -- when adding + items to a dictionary with PyDict_SetItemString, the third argument + is INCREF'd. I was forgetting to DECREF it after finishing with + it. + - Added method GdkWindow.new_gc. It takes keyword arguments with + names matching the fields of the structure GdkGCValues, defined + in gdk/gdktypes.h. It creates a gc for that window with the + given attributes. Also, the GdkGC type now has the same attributes + as the GdkGCValues structure, and they can be read and set. + - Added a wrapper for the GdkColormap type. It can be accessed as a + sequence (eg len(cmap), a = cmap[42], print cmap[:10]). The + sequence items are colours. Also, the GtkStyle and GdkWindow types + now also have the attribute colormap, which can be used for accessing + the colormap. Also, the GdkColor type now has the attributes red, + green, blue and pixel. + The colormap also has a single method -- GdkColormap.alloc. It can + either be called with a string argument (a colour name), or three + integers (RGB components). It does the same thing as the function + color_alloc (in fact, color_alloc is now implemented using it). + +pygtk-0.4.3: 7-May-1998 + - Updated for gtk+-1.0.1. This version of pygtk will not work with + earlier versions. (You should upgrade anyway, since this version + plugs some security holes and memory leaks). + - Updated the GdkImlib module to take advntage of new features found + in Imlib 1.3. You can now save images into just about any format. + - Added the types GdkWindow and GdkGC. Also changed some of the + functions like gtk_widget_shape_combine_mask to take their correct + arguments. This will not break any code written with Gtkinter, + as I have put in backward compatibility. However, if you used any + of these functions in code that directly accessed the gtk module, + you may have to recode some of your work. + I have updated some of the testgtk.py examples. You will notice + that the toolbar example loads quicker, since the test.xpm is only + read off disk once. + - Added the gdk_draw_* functions, and wrote wrappers for them as + methods of the GtkDrawingArea class. See examples/simple/scribble.py + for an example of using pixmaps and the drawing area. + +pygtk-0.4.2: 22-April-1998 + - Updated for gtk+-1.0.0. Since there have been no API changes + between 0.99.10 and 1.0.0, it should work with that version as well. + - Updated the configure script. It now uses the gtk-config script to + work out the cflags and libraries for GTK. If gtk-config is not on + the path, you can pass configure an argument something like + --with-gtk-config=/subdir/gtk-config. + - You can now specify the path name for the python executable (if it + isn't on the path) with the --with-python=/subdir/python argument. + - There is now a 'make install' option. It should work with both + python 1.4 and 1.5.x. It defaults to installing scripts the + $(prefix)/lib/site-python, with $(prefix)/lib/python$(version) as + a backup, and shared modules in $(prefix)/lib/python$(version) + /site-packages with $(prefix)/lib/python$(version)/lib-dynload and + $(prefix)/lib/python$(version)/sharedmodules as backup locations. + It also checks that the directory is in python's search path before + making the choice. + If you have installed previous versions of pygtk, it is probably a + good idea to remove those files before running 'make install', as + the locations chosen by this routine may be different from where + you installed previous versions. + - Changed the gtk_init function slightly, so it doesn't immediately + call the gtk_*get_type functions, instead deferring this till the + first call to gtk_object_new. This shouldn't affect anyone's + programs, other than making loading slightly quicker. + - Also added support for return types for signals (this only breaks + compatibility if your handlers didn't return None or 0 or whatever). + You should now be able to do things like returning TRUE from a + delete_event signal handler to prevent a window being destroyed. + - Added some functions for GtkCurve's and GtkPreview's that were + previously missing. + - Fixed some of the typemap stuff. GtkAspectFrame, GtkToolQuery and + GtkCList.get_row_data now work properly. Also fixed a few similar + problems in GdkImlib. + +pygtk-0.4.1: 6-April-1998 + - This archive is slightly smaller than the previous version, because + I accidently included some unneeded files. (The package isn't + missing anything that is required). + - Updated for gtk+-0.99.9. Note that the previous version of pygtk + works fine with 0.99.9, so this release is mainly new features. + - There is now a mailing list for pygtk. To subscribe, send mail to + pygtk-request@daa.com.au, with the word subscribe in the body. + There is also a web site at http://www.daa.com.au/~james/pygtk/, + although it isn't very interesting yet. + - updated the examples/ide/gtkcons.py to take advantage of word + wrapping in the text widget. + - Added a function to export the Python types used in Gtkinter, so + other python bindings (such as the imlib one) can use them. + (It should be possible to do gnome bindings -- I will look at that + in a little while). + - Added support for gdk_imlib. Note that this does not change + what libraries are required to build Gtkinter. If you don't + have gdk_imlib, the configure script will notice, and decide not + to build support for it. If you have gdk_imlib, and don't want to + build it, you can pass configure the argument --without-imlib. + - Added the directory examples/imlib, and a simple multi format + image viewer called examples/imlib/view.py. This example requires + the imlib bindings to have been built. + +pygtk-0.4.0: 23-Mar-1998 + - Updated for gtk+-0.99.8, so won't work with older versions (although + your old pygtk programs will still work). + - Added support quit handlers and input handlers. + - Fixed a long standing bug in idle/timeout/quit function reactivation. + Before, in order for an idle or timeout function to be reactivated, + it needed to call idle_add or timeout_add again. Now they just have + to return TRUE (like in C). This simplifies these functions + substantially. The old behaviour still works. + If you are using gtk+-0.99.7, you will find that timeout handlers + don't work. This is caused by a bug in GTK, which was fixed in + gtk+-0.99.8. + - Found that GtkPixamp.__init__, GtkCList.set_pixtmap and GtkCList. + set_pixtext all kept references to the pixmaps when they shouldn't. + This is now fixed. + - Added the module GtkExtra, which contains some convenience routines + for writing pygtk programs. It includes an implementation of the + menu factory (allows creation of arbitrary sized menus with about + four function calls), and single function call interfaces for + handling message boxes, file selection dialogs and input boxes. + - Added the module GDK.py, that contains relevant constants from GDK. + It is automatically imported by Gtkinter, so it is possible to do + things like widget.set_events(GDK.ALL_EVENTS_MASK) + - Added a crude integrated development environment (pyide.py) that + pulls together the debugger, profiler, console and editor examples + in the examples/ide directory. + - Added a function colour_alloc (or color_alloc) that can be used to + allocate new colours for use in the text widget and others. + - Added the drag and drop functions (finally). Check the example in + testgtk.py for the details. + - Added GtkWidget.shape_combine_mask, which takes a pixmap as its first + argument, and uses its mask as the shape mask. + - Added the GtkCList.{set,get}_row_data functions. + +pygtk-0.3.0: 10-Mar-1998 + - Updated for gtk+-0.99.4. This means that it will not compile + properly with previous versions. These incompatibilities are + justified since according to the authors of gtk, gtk+-0.99.4 is + very close to what 1.0.0 will look like. + - Joined the reference counting revolution :) This doesn't affect + anyone's programs, since reference counting (like type casting) is + handled automatically by pygtk. + - Check out the examples/ide directory. It contains a Gtkinter front + end to the python debugger and profiler and also a graphical + python console (which now works with different fonts and everything. + - Added more of the functions I left out from previous versions. I + still haven't fiddled round with dnd yet. + - Fixed the gtk_object_get function (I had an '=' instead of a '=='). + You can now use Gtkinter objects as dictionaries. An example is + >>> win = GtkWindow(WINDOW_TOPLEVEL) + >>> # next line is equivalent to win['GtkWindow::title'] = 'a' + >>> win.set_title("a") + >>> win['GtkWindow::title'] + 'a' + - Added the object data facility. You can use GtkObject.set_data, + get_data and remove_data to manipulate it. + - Added gtk_window_set_icon and gtk_window_set_icon_name. They are + wrappers for the gdk counterparts. The functions are also exposed + in Gtkinter as GtkWindow.set_icon[_name]. The set_icon function + takes a GtkPixmap as its argumnet, extracts the GdkPixmap and mask + from it and calls gtk_object_sink on the GtkPixmap, in case it never + gets packed in another widget. + - Similar wrappers are given for GtkCList.set_pixmap and + GtkCList.set_pixtext. Once again, you pass a GtkPixmap instead of + a GdkPixmap/GdkBitmap pair. + +pygtk-0.2.0: 12-Feb-1998 + - Fixed tooltips properly this time. Now you need to keep a reference + to the GtkTooltips object for as long as you want to display those + tips. + - Added the example examples/testgtk/testgtk.py. This is a + translation of the example with the same name that comes with the + gtk distribution. The plus side of this is that I found and fixed + many bits of pygtk that were either broken or missing. (eg. + getting the selection of a list, connecting signals for a toolbar) + - Added an example of using trees (examples/ide/browse.py). This one + shows how you might set up a file manager where you only create + as much of the tree as you are using. + - Altered the signal handling behaviour so that the arguments to + a signal handler are converted to their Gtkinter equivalents. + - Pygtk should be complete enough for writing applications the size of + ones you might use guile-gtk for, and as far as I know is the most + complete out of the other python-gtk bindings I know of. + +pygtk-0.1.1: 4-Feb-1998 + - I accidentally broke tooltips in the previous version in such a way + that you would get a seg fault when creating a GtkTooltips object. + This has been fixed. + - Added a new example called gtkcons.py. This is a simple interactive + Python session in a GTK window. Currently it has some bugs, the + most prominent being that the first character of output from a + command remains hidden until the next command is executed. It + also demonstrates GtkHandleBox's. + +pygtk-0.1.0: 2-Feb-1998 + - Changed the copyright to LGPL. (There is no point in making it + more free, since this is the lisence on GTK itself). + - Integrated some changes sent in by Neil Schemenauer + <nascheme@acs.ucalgary.ca>. (Mainly spelling mistakes in + Gtkinter.py, and a number of extra examples). The new examples + are TAppli*.py and notebook.py. + - Updated package for gtk+-0.99.3. (updates include addition of + GtkCList, GtkCombo, GtkHandleBox, GtkStatusbar and GtkToolbar). + - Updated the GTK.py, the constants module. + - Updated the GtkStyle and GdkEvent types. You can now get the + different colours of a style, and you can access the relevant + information associated with a given type of GdkEvent. This means + that you can now use signals that look at button clicks or key + strokes. + - Added support for GtkAcceleratorTable and GtkTooltips in + Gtkinter.py. The types GdkColor, GdkEvent, GdkFont and GtkStyle + don't have wrappers, but are clean enough to be used without any. + - Added the GtkText.insert method. There is also a + GtkText.insert_defaults that takes a single string argument. + +pygtk-0.0.2: 21-Jan-1998 + - Added file Gtkinter.py. This gives an object oriented + interface to gtk accessable from Python. This is still not + quite complete. + - Added some example programs in the examples directory + - Decided to release the code -- I wonder if anyone will use it? + +pygtk-0.0.1: (never released) + - first release + - contains basic functionality of gtk through use of SWIG @@ -0,0 +1,209 @@ +Gtkmodule and Gtkinter +====================== +Author: James Henstridge <james@daa.com.au> + + +This archive contains modules that allow you to use gtk in Python +programs. At present, it is a fairly complete set of bindings. +Despite the low version number, this peice of software is quite +useful, and is usable to write moderately complex programs. (see the +examples directory for some examples of the simpler programs you could +write). + +If you have any enhancements or bug reports, please send them to me at +james@daa.com.au. If you are going to send me diffs, my prefered +format is unified diff (ie. diff -u), followed by context diffs. +Please don't send me diffs which don't have any context, as these are +almost useless if I try to apply them manually, or have a different +version of the source tree. + + +New Versions +============ + +New versions of this package can be found at + ftp://ftp.daa.com.au/pub/james/python/ + ftp://ftp.gtk.org/pub/gtk/python/ + ftp://ftp.python.org/pub/contrib/Graphics/ + + +Mailing list +============ + +There is a mailing list for pygtk. You can subscribe to it by sending mail +to pygtk-request@daa.com.au with the word subscribe in the body. The list +address is pygtk@daa.com.au. + + +Copyright Information +===================== + +This software is covered by the GNU Library General Public Licence +(version 2, or if you choose, a later version). Basically just don't +say you wrote bits you didn't. + + +Compilation +=========== + +This archive contains a single C module called gtkmodule. It contains +an almost direct mapping of the functions in GTK including GTK signal +handling, and the gtk_object_new/gtk_object_set commands. This +version REQUIRES gtk+-1.1.3 or later, as it includes support for +features not found in previous versions, and there are +incompatibilities between versions. Also if you want the GdkImlib +extension, you must have Imlib version 1.8 or greater. I recommend +getting the latest stable versions of these libraries before compiling +pygtk, as it will make your system more stable. + +Parts of this module are automatically generated from the .defs file +in the generate directory, by the two python scripts in that +directory. + +To compile gtkmodule, first run "./configure" from the base directory +of the distribution. It requires that you have python in the path, +and python has been installed properly. If python is not in the path, +you could try running "PYTHON=/subdir/python ./configure". This +should generate Makefile from the files Makefile.pre.in and Setup.in. + +Now you should be able to run "make" to compile the module. Now you +should install the files. I have provided an install target to the +makefile, so you should be able to just type "make install". On +systems with Python 1.5 and later, it installs to the site-packages +directory (using prefix and exec_prefix where appropriate). For +Python 1.4, it installs the python code to $(prefix)/lib/python$(version), +and the libraries to $(excec_prefix)/lib/python$(version)/sharedmodules. +It also compiles .pyc files from the python code. + +If you had a copy of gdk_imlib installed on your system (and configure +could find it) when you built pygtk, a wrapper for it will have been +installed with the main pygtk modules. A simple example of using the +GdkImlib module is in the directory examples/imlib. + +If you have trouble with building or installing any of the code, please +tell me -- it is the only way I can fix the problem. If you do mail me, +please put something sensible in the subject line so I can tell what it +is about. + + +Upgrading +========= + +Note that from version 0.5.0 up, pygtk uses GTK v1.1. Since there +were some changes to the API, pygtk has changed accordingly. The main +one that will cause problems is the GtkAcceleratorTable. In this +version, it has been removed and replaced with the GtkAccelGroup. +Also note that some of the functions that refer to that type may have +changed slightly. The rest of the changes are mostly invisible, since +they are mainly internal, and not touched upon by most people's code. + +Also, I have changed the arguments for the Gtkinter.new function. Now +instead of object arguments being passed in as a dictionary, they are +passed in as keyword arguments. This is possible because the 'Gtk*::' +prefix is no longer needed. + +If you have a previous 0.5.x version of pygtk, and you weren't using +the Gtkinter.py wrapper, there is no _gtkbase module any more, so +don't include it. Also don't call pygtk_init, as it is now done +automatically during module initialisation. + + +Tests +===== + +After having compiled and installed gtkmodule, GTK and Gtkinter, you +may want to test them. In the examples directory there are a number +of programs you may want to use to test gtkmodule and Gtkinter. These +programs rely on being able to find gtkmodule, GTK and Gtkinter, so +you must have installed them somewhere on your python path. (Typing +"PYTHONPATH=../.. python filename.py" from the examples directory is +enough, after building gtkmodule) + + +_gtkmodule and GTK.py +==================== + +This module contains an almost complete translation of the functions +in the gtk library. To start up, put in the command "from gtk import +*". If you want to use any of the constants, type "from GTK import +*". The constants all have the "GTK_" removed from the start. Before +creating any GtkObjects, you should execute the command "gtk_init()". +Unlike the C equivalent, you don't have to specify an argument list, +since there are other ways to get at it. + +When you are using the functions in this module, you will find that +there is no need to use any of the type casting macros on GtkObjects, +since they are all stored inside the same python type. Each function +in the module does its own type casting. + +In this module there are only two signal connection functions -- +gtk_signal_connect and gtk_signal_connect_after. The other functions +can be emulated with the use of callable class instances wrapped +around the signal handler. Also signal handlers are not parsed the +extra data argument. The reason for this is because the code has to +keep track of both the python signal handler and its C wrapper. + +In the gtk_object_new and gtk_object_set functions, the property +setting argumetns have been compressed into a single dictionary as an +argument. This dictionary has string keys that correspond to the +property names, and the values are the property values. The reason +that I did not use keyword arguments is that things like +"GtkWindow::title" are not valid keywords, so unfortunately we have to +use this clumsy syntax. + + +Gtkinter.py +=========== + +This module is a wrapper for gtkmodule. You start using it by +executing the command "from Gtkinter import *". This will give you +access to all of Gtkinter, and also import GTK, the constants module, +for you. + +This module implements an object oriented wrapper for gtk. Probably +the best way to get a feel for it, is to read some of the source +code. Basically, there is a class for each GtkObject type. Each +class implements the functions specific to that GtkObject type as +methods. (ie. GtkWidget.show() is equivalent to gtk_widget_show()). + +The classes are set up such that their inheritance tree matches that +of the actual GtkObjects. This means that you can call +GtkWidget.show() from a GtkWindow class instance. + +The constructors for each of these classes corresponds to the +gtk_*_new functions. Through the use of default arguments, both the +gtk_*_new and gtk_*_new_* functions are both supported through the +constructor. + +There are also a few extra functions in Gtkinter. These are new(), +mainloop() and mainquit(). The function new() implements +gtk_object_new. It's first argument can be either a string, or one of +the classes in the module. The second argument is a dictionary that +is almost passed to gtk_object_new after converting Gtkinter Objects +to GtkObjects. + +The function mainloop() is basically just the function gtk_main(), and +the function mainquit is equivalent to gtk_main_quit(). + +For further information on the interface, please see the source file +Gtkinter.py. + + +Should I Use Gtkmodule or GtkInter? +=================================== + +You should probably use the striaght gtkmodule, if you are using +python to prototype a C application that will use GTK, but in most +other cases, Gtkinter will probably be a lot easier to use, and will +look more natural in a python program. + + +Contacting the Author +===================== + +You can contact me at the email address <james@daa.com.au>. I try to +answer my email quickly, but occasionally there will be a bit of a +delay. If you have an idea for a way to extend GTK, have found a +problem with the code (I don't think there are many bugs anymore), or +would like to contribute some code, please feel free to contact me. + diff --git a/configure.in b/configure.in new file mode 100644 index 00000000..fc270f70 --- /dev/null +++ b/configure.in @@ -0,0 +1,16 @@ +AC_INIT + +dnl for gnome-python: + +AM_INIT_AUTOMAKE(pygtk, 0.5.6) + +AM_PATH_PYTHON +AM_INIT_PYEXEC_MOD + +AM_PATH_GTK(1.1.6) +AM_PATH_GDK_IMLIB(1.8, [BUILD_IMLIB=], [BUILD_IMLIB="#"]) +AC_SUBST(BUILD_IMLIB) + +AC_OUTPUT(Makefile generate/Makefile pyglade/Makefile) + + diff --git a/description.py b/description.py new file mode 100644 index 00000000..e55b4ef8 --- /dev/null +++ b/description.py @@ -0,0 +1,296 @@ +"""This file describes the types defined in gtkmodule that don't have Python +class wrappers in gtk.py, but are still used. This module shouldn't be +imported, as it is only meant to be documentation + +In this file, when I assign '_' to a variable, it represents whatever should +be in that variable.""" + +raise ImportError, "I told you not to import this module" + +_ = None + +class GtkCTreeNode: + """This representsa node in a GtkCTree. It is a cross between the""" + """C GtkCTreeNode and GtkCTreeRow structs.""" + + """The parent of this node (or None for no parent)""" + parent = _ + """This node's next sibling (or None if this is the last)""" + sibling = _ + """A list of this node's children""" + children = [] + """The level of this node""" + level = _ + """TRUE if this node is a leaf node""" + is_leaf = _ + """TRUE if this node has been expanded""" + expanded = _ + +class GtkStyle: + """Currently you can't assign to any of the attributes of a GtkStyle""" + """This type can't be instantiated directly""" + + """COLORS""" + black = _ + white = _ + """These variables should be indexed with the STATE_* constants""" + fg = (_, _, _, _, _) + bg = (_, _, _, _, _) + light = (_, _, _, _, _) + dark = (_, _, _, _, _) + mid = (_, _, _, _, _) + text = (_, _, _, _, _) + base = (_, _, _, _, _) + + """The font used for text for widgets of this style""" + font = _ + + """GC's""" + black_gc = _ + white_gc = _ + """These variables should be indexed with the STATE_* constants""" + fg_gc = (_, _, _, _, _) + bg_gc = (_, _, _, _, _) + light_gc = (_, _, _, _, _) + dark_gc = (_, _, _, _, _) + mid_gc = (_, _, _, _, _) + text_gc = (_, _, _, _, _) + base_gc = (_, _, _, _, _) + + """These are background pixmaps for the various states""" + bg_pixmap = (_, _, _, _, _) + + """The colormap for this style""" + colormap = _ + +class GtkSelectionData: + """This type represents the selection. Do not keep a reference""" + """to it past the life of a callback""" + """The selection atom""" + selection = _ + """target atom""" + target = _ + """type atom""" + type = _ + """format type""" + format = _ + """The data in this selection""" + data = "some_data" + def set(self, type, format, data): + """Set the type, format and data parts of the selection data""" + pass + +class GdkAtom: + """This type represents a GdkAtom. The reason for not using ints""" + """is that this type can automatically coerce to int, long, float""" + """or string, reducing the need for gdk_atom_intern/name in a lot""" + """of cases. Functions that take atoms as input are really reading""" + """ints, and this type just gets coerced.""" + def __int__(self): pass + def __long__(self): pass + def __float__(self): pass + def __oct__(self): pass + def __hex__(self): pass + def __coerce__(self, other): + """will corece self to any of int, long, float or string if""" + """other type matches, otherwise fail""" + pass + +class GdkColor: + """These are the attributes of a GdkColor:""" + red = _ + green = _ + blue = _ + + """This is the pixel value for the color""" + pixel = _ + +class GdkColormap: + def __len__(self): + """return the size of the colormap""" + pass + def __getitem__(self, pos): + """return the GdkColor at position pos in the colormap""" + pass + def __getslice__(self, lo, up): + """return a tuple of GdkColor's according to the given slice""" + pass + def alloc(self, color_name): + """return a GdkColor matching the color name given, that has + been allocated in the colormap""" + pass + def alloc(self, red, green, blue): + """return a GdkColor matching the 16-bit RGB values given, + that has been allocated in the colormap""" + pass + +class GdkDragContext: + """This event holds the context of a DND drag""" + + """The protocol""" + protocol = _ + """True if we are on the source end (I think)""" + is_source = _ + """source and destination windows""" + source_window = _ + dest_window = _ + """A list of target atoms for this drag""" + targets = [_, _, _] + """A combination of the GdkDragAction flags""" + actions = _ + """The suggested action atom""" + suggested_action = _ + """The action atom""" + action = _ + """The start time for the drag""" + start_time = _ + +class GdkEvent: + """The type of the event -- this decides on what other attributes the + object has""" + type = _ + """The GdkWindow associated with the event""" + window = _ + send_event = _ + + """You can convert the event names to widget signal names by knocking + off the GDK., converting to lower case, and adding '_event'.""" + if type in (GDK.NOTHING, GDK.DELETE, GDK.DESTROY, GDK.EXPOSE): + """No extra info for these events""" + pass + elif type == GDK.EXPOSE: + """The exposed area""" + area = (_, _, _, _) + count = _ + elif type == GDK.MOTION_NOTIFY: + time = _ ; x = _ ; y = _ ; pressure = _ ; xtilt = _ ; ytilt = _ + state = _ ; is_hint = _ ; source = _ ; x_root = _ ; y_root = _ + elif type in (GDK.BUTTON_PRESS,GDK._2BUTTON_PRESS,GDK._3BUTTON_PRESS): + time = _ ; x = _ ; y = _ ; pressure = _ ; xtilt = _ ; ytilt = _ + state = _ ; button = _ ; source = _ ; deviceid = _ + x_root = _ ; y_root = _ + elif type in (GDK.KEY_PRESS, GDK.KEY_RELEASE): + time = _ ; keyval = _ ; string = _ + elif type in (GDK.ENTER_NOTIFY, GDK.LEAVE_NOTIFY): + detail = _ + elif type == GDK.FOCUS_CHANGE: + _in = _ + elif type == GDK.CONFIGURE: + x = _ ; y = _ ; width = _ ; height = _ + elif type in (GDK.MAP, GDK.UNMAP): + """No extra parameters""" + pass + elif type == GDK.PROPERTY_NOTIFY: + atom = _ ; time = _ ; state = _ + elif type in (GDK.SELECTION_CLEAR, GDK.SELECTION_REQUEST, + GDK.SELECTION_NOTIFY): + selection = _ ; target = _ ; property = _ ; requestor = _ + time = _ + elif type in (GDK.PROXIMITY_IN, GDK.PROXIMITY_OUT): + time = _ ; source = _ ; deviceid = _ + elif type == GDK.DRAG_BEGIN: + protocol_version = _ + elif type == GDK.DRAG_REQUEST: + protocol_version = _ ; sendreply = _ ; willaccept = _ + delete_data = _ ; senddata = _ ; isdrop = _ + drop_coords = (_, _) ; data_type = _ ; timestamp = _ + elif type == GDK.DROP_ENTER: + requestor = _ ; protocol_version = _ ; sendreply = _ + extended_typelist = _ + elif type == GDK.DROP_LEAVE: + requestor = _ ; protocol_version = _ + elif type == GDK.DROP_DATA_AVAIL: + requestor = _ ; protocol_version = _ ; isdrop = _ + data_type = _ ; data = _ ; timestamp = _ ; coords = (_, _) + elif type == GDK.CLIENT_EVENT: + message_type = _ ; data_format = _ ; data = _ + elif type == GDK.VISIBILITY_NOTIFY: + state = _ + elif type == GDK.NO_EXPOSE: pass + elif type == GDK.OTHER_EVENT: pass + + +class GdkFont: + """ the ascent and descent of a font""" + ascent = _ + descent = _ + """ the font type (GDK.FONT_FONT or GDK.FONT_FONTSET) """ + type = _ + def width(self, str): + """return the width of the string""" + pass + def height(self, str): + """return the height of the string""" + pass + def measure(self, str): + """return the width of the string, taking into account kerning + of the final character""" + pass + def extents(self, str): + """return (lbearing,rbearing,width,ascent,descent)""" + pass + + +class GdkGC: + """GdkGC's are created with the GdkWindow.new_gc method. It + is impossible to directly create one.""" + + """These attributes match the parameters to GdkWindow.new_gc, and can + be read and set""" + foreground = _ + background = _ + font = _ + function = _ + fill = _ + tile = _ + stipple = _ + clip_mask = _ + ts_x_origin, ts_y_origin = (_, _) + clip_x_origin, clip_y_origin = (_, _) + graphics_exposures = _ + line_width = _ + line_style = _ + cap_style = _ + join_style = _ + +class GdkWindow: + """All attributes are read only for GdkWindow's""" + """The type of window -- you shouldn't need this""" + type = _ + """Child windows""" + children = [_, _, '...'] + """A GdkColormap object""" + colormap = _ + width = _ ; height = _ + x = _ ; y = _ + """parent windows""" + parent = _ + toplevel = _ + """Pointer info""" + pointer = (_, _) + pointer_state = _ + + def new_gc(self, foreground=None, background=None, font=None, + tile=None, stipple=None, clip_mask=None, + function=None, fill=None, subwindow_mode=None, + ts_x_origin=None, ts_y_origin=None, + clip_x_origin=None, clip_y_origin=None, + line_width=None, line_style=None, cap_style=None, + join_style=None): + """Creates a new GC for this + window with the given settings. The settings must + be given as keyword arguments. If a setting isn't + given, then its default will be used""" + pass + def set_cursor(self, cursor): + """Sets the cursor for this window""" + pass + +"""Aliases for GdkWindow. GdkPixmap refers to an offscreen pixmap. +GdkDrawable refers to either a GdkWindow or a GdkPixmap""" +GdkPixmap = GdkWindow +GdkBitmap = GdkPixmap +GdkDrawable = GdkWindow + + + diff --git a/examples/glade/.cvsignore b/examples/glade/.cvsignore new file mode 100644 index 00000000..c2831020 --- /dev/null +++ b/examples/glade/.cvsignore @@ -0,0 +1,6 @@ +Makefile.in +Makefile +*~ +*.pyc +*.pyo + diff --git a/examples/glade/README b/examples/glade/README new file mode 100644 index 00000000..d83c582d --- /dev/null +++ b/examples/glade/README @@ -0,0 +1,12 @@ +This directory contains examples of the use of the pyglade module, which can +be used for creating user interfaces from the .glade files created by the +GLADE UI builder. + +Just put a glade file in this directory and run: + ./glade.py filename.glade + +The pyglade module should make it even easier to prototype interfaces in +python, since you can get it to look right, and act correctly when signals +get emitted, then generate a C skeleton for the UI. + +You can find GLADE at http://www.comp.lancs.ac.uk/~damon/builder/index.html
\ No newline at end of file diff --git a/examples/glade/glade.py b/examples/glade/glade.py new file mode 100755 index 00000000..a7778783 --- /dev/null +++ b/examples/glade/glade.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +import sys +if sys.version[:3] == '1.4': + import ni +from gtk import * +import pyglade + +if len(sys.argv) > 1: + fname = sys.argv[1] +else: + fname = 'test.glade' + +# create widget tree ... +wtree = pyglade.construct(fname) + +# if there is anything that needs to be added to the UI, we can access all +# the widgets like this: +try: + win = wtree.get_widget('window1') +except: pass + +# we can connect to any of the signals named in the template: +try: + wtree.connect('close_window', mainquit) +except: pass + +mainloop() diff --git a/examples/glade/test.glade b/examples/glade/test.glade new file mode 100644 index 00000000..85d288f8 --- /dev/null +++ b/examples/glade/test.glade @@ -0,0 +1,499 @@ +<?xml version="1.0"?> +<GTK-Interface> + + +<widget> + <class>GtkWindow</class> + <name>window1</name> + <Signal> + <name>destroy</name> + <handler>close_window</handler> + </Signal> + <title>window1</title> + <type>GTK_WINDOW_TOPLEVEL</type> + <position>GTK_WIN_POS_NONE</position> + <allow_shrink>True</allow_shrink> + <allow_grow>True</allow_grow> + <auto_shrink>False</auto_shrink> + + <widget> + <class>GtkTable</class> + <name>table1</name> + <border_width>2</border_width> + <rows>5</rows> + <columns>3</columns> + <homogeneous>False</homogeneous> + <row_spacing>2</row_spacing> + <column_spacing>2</column_spacing> + + <widget> + <class>GtkLabel</class> + <name>label1</name> + <child> + <left_attach>0</left_attach> + <right_attach>1</right_attach> + <top_attach>1</top_attach> + <bottom_attach>2</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>True</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>True</yfill> + </child> + <label>Hello</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkEntry</class> + <name>entry1</name> + <child> + <left_attach>1</left_attach> + <right_attach>2</right_attach> + <top_attach>1</top_attach> + <bottom_attach>2</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>True</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>True</yfill> + </child> + <width>50</width> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text></text> + </widget> + + <widget> + <class>GtkArrow</class> + <name>arrow1</name> + <child> + <left_attach>2</left_attach> + <right_attach>3</right_attach> + <top_attach>1</top_attach> + <bottom_attach>2</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>True</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>True</yfill> + </child> + <arrow_type>GTK_ARROW_LEFT</arrow_type> + <shadow_type>GTK_SHADOW_OUT</shadow_type> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkSpinButton</class> + <name>spinbutton1</name> + <child> + <left_attach>0</left_attach> + <right_attach>1</right_attach> + <top_attach>2</top_attach> + <bottom_attach>3</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>True</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>True</yfill> + </child> + <can_focus>True</can_focus> + <climb_rate>1</climb_rate> + <digits>0</digits> + <numeric>False</numeric> + <update_policy>GTK_UPDATE_IF_VALID</update_policy> + <snap>False</snap> + <wrap>False</wrap> + <hvalue>1</hvalue> + <hlower>0</hlower> + <hupper>100</hupper> + <hstep>1</hstep> + <hpage>10</hpage> + <hpage_size>10</hpage_size> + </widget> + + <widget> + <class>GtkHScale</class> + <name>hscale1</name> + <child> + <left_attach>1</left_attach> + <right_attach>2</right_attach> + <top_attach>2</top_attach> + <bottom_attach>3</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>True</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>True</yfill> + </child> + <width>75</width> + <can_focus>True</can_focus> + <draw_value>True</draw_value> + <value_pos>GTK_POS_TOP</value_pos> + <digits>1</digits> + <policy>GTK_UPDATE_CONTINUOUS</policy> + <hvalue>0</hvalue> + <hlower>0</hlower> + <hupper>100</hupper> + <hstep>1</hstep> + <hpage>10</hpage> + <hpage_size>10</hpage_size> + </widget> + + <widget> + <class>GtkFixed</class> + <name>fixed1</name> + <child> + <left_attach>2</left_attach> + <right_attach>3</right_attach> + <top_attach>2</top_attach> + <bottom_attach>3</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>True</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>True</yfill> + </child> + + <widget> + <class>GtkButton</class> + <name>button1</name> + <x>40</x> + <y>40</y> + <width>47</width> + <height>22</height> + <can_focus>True</can_focus> + <label>button1</label> + </widget> + + <widget> + <class>GtkSpinButton</class> + <name>spinbutton2</name> + <x>16</x> + <y>0</y> + <width>45</width> + <height>22</height> + <can_focus>True</can_focus> + <climb_rate>1</climb_rate> + <digits>0</digits> + <numeric>False</numeric> + <update_policy>GTK_UPDATE_ALWAYS</update_policy> + <snap>False</snap> + <wrap>False</wrap> + <hvalue>1</hvalue> + <hlower>0</hlower> + <hupper>100</hupper> + <hstep>1</hstep> + <hpage>10</hpage> + <hpage_size>10</hpage_size> + </widget> + </widget> + + <widget> + <class>GtkFrame</class> + <name>frame1</name> + <child> + <left_attach>0</left_attach> + <right_attach>3</right_attach> + <top_attach>3</top_attach> + <bottom_attach>4</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>True</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>True</yfill> + </child> + <label_xalign>0</label_xalign> + <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> + + <widget> + <class>GtkHButtonBox</class> + <name>hbuttonbox1</name> + <layout_style>GTK_BUTTONBOX_DEFAULT_STYLE</layout_style> + <spacing>30</spacing> + <child_min_width>85</child_min_width> + <child_min_height>27</child_min_height> + <child_ipad_x>7</child_ipad_x> + <child_ipad_y>0</child_ipad_y> + + <widget> + <class>GtkButton</class> + <name>button2</name> + <can_focus>True</can_focus> + <label>button2</label> + </widget> + + <widget> + <class>GtkButton</class> + <name>button3</name> + <can_focus>True</can_focus> + <label>button3</label> + </widget> + + <widget> + <class>GtkButton</class> + <name>button4</name> + <can_focus>True</can_focus> + <label>button4</label> + </widget> + </widget> + </widget> + + <widget> + <class>GtkAlignment</class> + <name>alignment1</name> + <child> + <left_attach>1</left_attach> + <right_attach>2</right_attach> + <top_attach>4</top_attach> + <bottom_attach>5</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>True</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>True</yfill> + </child> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xscale>1</xscale> + <yscale>1</yscale> + + <widget> + <class>GtkVScrollbar</class> + <name>vscrollbar1</name> + <can_focus>True</can_focus> + <policy>GTK_UPDATE_CONTINUOUS</policy> + <vvalue>0</vvalue> + <vlower>0</vlower> + <vupper>0</vupper> + <vstep>0</vstep> + <vpage>0</vpage> + <vpage_size>0</vpage_size> + </widget> + </widget> + + <widget> + <class>GtkAlignment</class> + <name>alignment2</name> + <child> + <left_attach>0</left_attach> + <right_attach>1</right_attach> + <top_attach>4</top_attach> + <bottom_attach>5</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>True</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>True</yfill> + </child> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xscale>1</xscale> + <yscale>1</yscale> + + <widget> + <class>GtkCurve</class> + <name>curve1</name> + <curve_type>GTK_CURVE_TYPE_SPLINE</curve_type> + <min_x>0</min_x> + <max_x>1</max_x> + <min_y>0</min_y> + <max_y>1</max_y> + </widget> + </widget> + + <widget> + <class>GtkCList</class> + <name>clist1</name> + <child> + <left_attach>2</left_attach> + <right_attach>3</right_attach> + <top_attach>4</top_attach> + <bottom_attach>5</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>True</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>True</yfill> + </child> + <can_focus>True</can_focus> + <columns>3</columns> + <column_widths>80,80,80</column_widths> + <selection_mode>GTK_SELECTION_SINGLE</selection_mode> + <show_titles>True</show_titles> + <shadow_type>GTK_SHADOW_IN</shadow_type> + <hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy> + <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy> + + <widget> + <class>GtkLabel</class> + <child_name>CList:title</child_name> + <name>label2</name> + <label>Col1</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>CList:title</child_name> + <name>label3</name> + <label>Col3</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkArrow</class> + <child_name>CList:title</child_name> + <name>arrow2</name> + <arrow_type>GTK_ARROW_DOWN</arrow_type> + <shadow_type>GTK_SHADOW_OUT</shadow_type> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + </widget> + + <widget> + <class>GtkNotebook</class> + <name>notebook1</name> + <child> + <left_attach>0</left_attach> + <right_attach>3</right_attach> + <top_attach>0</top_attach> + <bottom_attach>1</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>True</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>True</yfill> + </child> + <can_focus>True</can_focus> + <show_tabs>True</show_tabs> + <show_border>True</show_border> + <tab_pos>GTK_POS_TOP</tab_pos> + <scrollable>False</scrollable> + <tab_border>3</tab_border> + <popup_enable>False</popup_enable> + + <widget> + <class>GtkHRuler</class> + <name>hruler1</name> + <metric>GTK_PIXELS</metric> + <lower>0</lower> + <upper>10</upper> + <position>0</position> + <max_size>10</max_size> + </widget> + + <widget> + <class>GtkHScale</class> + <name>hscale2</name> + <can_focus>True</can_focus> + <draw_value>True</draw_value> + <value_pos>GTK_POS_TOP</value_pos> + <digits>1</digits> + <policy>GTK_UPDATE_CONTINUOUS</policy> + <hvalue>0</hvalue> + <hlower>0</hlower> + <hupper>100</hupper> + <hstep>1</hstep> + <hpage>10</hpage> + <hpage_size>10</hpage_size> + </widget> + + <widget> + <class>GtkProgressBar</class> + <name>progressbar1</name> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>Notebook:tab</child_name> + <name>label5</name> + <label>label5</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>Notebook:tab</child_name> + <name>label6</name> + <label>label6</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>Notebook:tab</child_name> + <name>label7</name> + <label>label7</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + </widget> + </widget> +</widget> + +</GTK-Interface> diff --git a/examples/glade/test2.glade b/examples/glade/test2.glade new file mode 100644 index 00000000..d128d2cf --- /dev/null +++ b/examples/glade/test2.glade @@ -0,0 +1,89 @@ +<?xml version="1.0"?> +<GTK-Interface> + +<style> + <style_name>Hello</style_name> + <style_font>-adobe-helvetica-bold-r-normal-*-*-180-*-*-p-*-iso8859-1</style_font> + <fg:NORMAL>0,0,255</fg:NORMAL> +</style> + +<widget> + <class>GtkWindow</class> + <name>window1</name> + <Signal> + <name>destroy</name> + <handler>close_window</handler> + </Signal> + <title>window1</title> + <type>GTK_WINDOW_TOPLEVEL</type> + <position>GTK_WIN_POS_NONE</position> + <allow_shrink>True</allow_shrink> + <allow_grow>True</allow_grow> + <auto_shrink>False</auto_shrink> + + <widget> + <class>GtkVBox</class> + <name>vbox1</name> + <homogeneous>False</homogeneous> + <spacing>0</spacing> + + <widget> + <class>GtkCombo</class> + <name>combo1</name> + <border_width>5</border_width> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>True</fill> + </child> + <Signal> + <name>add</name> + <handler>on_combo1_add</handler> + <object>window1</object> + </Signal> + <case_sensitive>False</case_sensitive> + <use_arrows>True</use_arrows> + <use_arrows_always>False</use_arrows_always> + </widget> + + <widget> + <class>GtkHRuler</class> + <name>hruler1</name> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>True</fill> + </child> + <height>32</height> + <style_name>Hello</style_name> + <Accelerator> + <modifiers>GDK_CONTROL_MASK</modifiers> + <key>GDK_0</key> + <signal>hide</signal> + </Accelerator> + <Accelerator> + <modifiers>GDK_CONTROL_MASK</modifiers> + <key>GDK_1</key> + <signal>show</signal> + </Accelerator> + <metric>GTK_PIXELS</metric> + <lower>0</lower> + <upper>10</upper> + <position>0</position> + <max_size>10</max_size> + </widget> + + <widget> + <class>GtkStatusbar</class> + <name>statusbar1</name> + <border_width>10</border_width> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + </widget> + </widget> +</widget> + +</GTK-Interface> diff --git a/examples/glade/tmp b/examples/glade/tmp new file mode 100644 index 00000000..c45f34d7 --- /dev/null +++ b/examples/glade/tmp @@ -0,0 +1,1692 @@ +xml: encoding = None standalone = None +data: '\012' +start tag: <GTK-Interface> +data: '\012\012\012' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkWindow' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'window1' +end tag: </name> +data: '\012 ' +start tag: <Signal> +data: '\012 ' +start tag: <name> +data: 'destroy' +end tag: </name> +data: '\012 ' +start tag: <handler> +data: 'close_window' +end tag: </handler> +data: '\012 ' +end tag: </Signal> +data: '\012 ' +start tag: <title> +data: 'window1' +end tag: </title> +data: '\012 ' +start tag: <type> +data: 'GTK_WINDOW_TOPLEVEL' +end tag: </type> +data: '\012 ' +start tag: <position> +data: 'GTK_WIN_POS_NONE' +end tag: </position> +data: '\012 ' +start tag: <allow_shrink> +data: 'True' +end tag: </allow_shrink> +data: '\012 ' +start tag: <allow_grow> +data: 'True' +end tag: </allow_grow> +data: '\012 ' +start tag: <auto_shrink> +data: 'False' +end tag: </auto_shrink> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkTable' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'table1' +end tag: </name> +data: '\012 ' +start tag: <border_width> +data: '2' +end tag: </border_width> +data: '\012 ' +start tag: <rows> +data: '5' +end tag: </rows> +data: '\012 ' +start tag: <columns> +data: '3' +end tag: </columns> +data: '\012 ' +start tag: <homogeneous> +data: 'False' +end tag: </homogeneous> +data: '\012 ' +start tag: <row_spacing> +data: '2' +end tag: </row_spacing> +data: '\012 ' +start tag: <column_spacing> +data: '2' +end tag: </column_spacing> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkLabel' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'label1' +end tag: </name> +data: '\012 ' +start tag: <child> +data: '\012 ' +start tag: <left_attach> +data: '0' +end tag: </left_attach> +data: '\012 ' +start tag: <right_attach> +data: '1' +end tag: </right_attach> +data: '\012 ' +start tag: <top_attach> +data: '1' +end tag: </top_attach> +data: '\012 ' +start tag: <bottom_attach> +data: '2' +end tag: </bottom_attach> +data: '\012 ' +start tag: <xpad> +data: '0' +end tag: </xpad> +data: '\012 ' +start tag: <ypad> +data: '0' +end tag: </ypad> +data: '\012 ' +start tag: <xexpand> +data: 'True' +end tag: </xexpand> +data: '\012 ' +start tag: <yexpand> +data: 'True' +end tag: </yexpand> +data: '\012 ' +start tag: <xshrink> +data: 'False' +end tag: </xshrink> +data: '\012 ' +start tag: <yshrink> +data: 'False' +end tag: </yshrink> +data: '\012 ' +start tag: <xfill> +data: 'True' +end tag: </xfill> +data: '\012 ' +start tag: <yfill> +data: 'True' +end tag: </yfill> +data: '\012 ' +end tag: </child> +data: '\012 ' +start tag: <label> +data: 'Hello' +end tag: </label> +data: '\012 ' +start tag: <justify> +data: 'GTK_JUSTIFY_CENTER' +end tag: </justify> +data: '\012 ' +start tag: <xalign> +data: '0.5' +end tag: </xalign> +data: '\012 ' +start tag: <yalign> +data: '0.5' +end tag: </yalign> +data: '\012 ' +start tag: <xpad> +data: '0' +end tag: </xpad> +data: '\012 ' +start tag: <ypad> +data: '0' +end tag: </ypad> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkEntry' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'entry1' +end tag: </name> +data: '\012 ' +start tag: <child> +data: '\012 ' +start tag: <left_attach> +data: '1' +end tag: </left_attach> +data: '\012 ' +start tag: <right_attach> +data: '2' +end tag: </right_attach> +data: '\012 ' +start tag: <top_attach> +data: '1' +end tag: </top_attach> +data: '\012 ' +start tag: <bottom_attach> +data: '2' +end tag: </bottom_attach> +data: '\012 ' +start tag: <xpad> +data: '0' +end tag: </xpad> +data: '\012 ' +start tag: <ypad> +data: '0' +end tag: </ypad> +data: '\012 ' +start tag: <xexpand> +data: 'True' +end tag: </xexpand> +data: '\012 ' +start tag: <yexpand> +data: 'True' +end tag: </yexpand> +data: '\012 ' +start tag: <xshrink> +data: 'False' +end tag: </xshrink> +data: '\012 ' +start tag: <yshrink> +data: 'False' +end tag: </yshrink> +data: '\012 ' +start tag: <xfill> +data: 'True' +end tag: </xfill> +data: '\012 ' +start tag: <yfill> +data: 'True' +end tag: </yfill> +data: '\012 ' +end tag: </child> +data: '\012 ' +start tag: <width> +data: '50' +end tag: </width> +data: '\012 ' +start tag: <can_focus> +data: 'True' +end tag: </can_focus> +data: '\012 ' +start tag: <editable> +data: 'True' +end tag: </editable> +data: '\012 ' +start tag: <text_visible> +data: 'True' +end tag: </text_visible> +data: '\012 ' +start tag: <text_max_length> +data: '0' +end tag: </text_max_length> +data: '\012 ' +start tag: <text> +end tag: </text> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkArrow' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'arrow1' +end tag: </name> +data: '\012 ' +start tag: <child> +data: '\012 ' +start tag: <left_attach> +data: '2' +end tag: </left_attach> +data: '\012 ' +start tag: <right_attach> +data: '3' +end tag: </right_attach> +data: '\012 ' +start tag: <top_attach> +data: '1' +end tag: </top_attach> +data: '\012 ' +start tag: <bottom_attach> +data: '2' +end tag: </bottom_attach> +data: '\012 ' +start tag: <xpad> +data: '0' +end tag: </xpad> +data: '\012 ' +start tag: <ypad> +data: '0' +end tag: </ypad> +data: '\012 ' +start tag: <xexpand> +data: 'True' +end tag: </xexpand> +data: '\012 ' +start tag: <yexpand> +data: 'True' +end tag: </yexpand> +data: '\012 ' +start tag: <xshrink> +data: 'False' +end tag: </xshrink> +data: '\012 ' +start tag: <yshrink> +data: 'False' +end tag: </yshrink> +data: '\012 ' +start tag: <xfill> +data: 'True' +end tag: </xfill> +data: '\012 ' +start tag: <yfill> +data: 'True' +end tag: </yfill> +data: '\012 ' +end tag: </child> +data: '\012 ' +start tag: <arrow_type> +data: 'GTK_ARROW_LEFT' +end tag: </arrow_type> +data: '\012 ' +start tag: <shadow_type> +data: 'GTK_SHADOW_OUT' +end tag: </shadow_type> +data: '\012 ' +start tag: <xalign> +data: '0.5' +end tag: </xalign> +data: '\012 ' +start tag: <yalign> +data: '0.5' +end tag: </yalign> +data: '\012 ' +start tag: <xpad> +data: '0' +end tag: </xpad> +data: '\012 ' +start tag: <ypad> +data: '0' +end tag: </ypad> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkSpinButton' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'spinbutton1' +end tag: </name> +data: '\012 ' +start tag: <child> +data: '\012 ' +start tag: <left_attach> +data: '0' +end tag: </left_attach> +data: '\012 ' +start tag: <right_attach> +data: '1' +end tag: </right_attach> +data: '\012 ' +start tag: <top_attach> +data: '2' +end tag: </top_attach> +data: '\012 ' +start tag: <bottom_attach> +data: '3' +end tag: </bottom_attach> +data: '\012 ' +start tag: <xpad> +data: '0' +end tag: </xpad> +data: '\012 ' +start tag: <ypad> +data: '0' +end tag: </ypad> +data: '\012 ' +start tag: <xexpand> +data: 'True' +end tag: </xexpand> +data: '\012 ' +start tag: <yexpand> +data: 'True' +end tag: </yexpand> +data: '\012 ' +start tag: <xshrink> +data: 'False' +end tag: </xshrink> +data: '\012 ' +start tag: <yshrink> +data: 'False' +end tag: </yshrink> +data: '\012 ' +start tag: <xfill> +data: 'True' +end tag: </xfill> +data: '\012 ' +start tag: <yfill> +data: 'True' +end tag: </yfill> +data: '\012 ' +end tag: </child> +data: '\012 ' +start tag: <can_focus> +data: 'True' +end tag: </can_focus> +data: '\012 ' +start tag: <climb_rate> +data: '1' +end tag: </climb_rate> +data: '\012 ' +start tag: <digits> +data: '0' +end tag: </digits> +data: '\012 ' +start tag: <numeric> +data: 'False' +end tag: </numeric> +data: '\012 ' +start tag: <update_policy> +data: 'GTK_UPDATE_IF_VALID' +end tag: </update_policy> +data: '\012 ' +start tag: <snap> +data: 'False' +end tag: </snap> +data: '\012 ' +start tag: <wrap> +data: 'False' +end tag: </wrap> +data: '\012 ' +start tag: <hvalue> +data: '1' +end tag: </hvalue> +data: '\012 ' +start tag: <hlower> +data: '0' +end tag: </hlower> +data: '\012 ' +start tag: <hupper> +data: '100' +end tag: </hupper> +data: '\012 ' +start tag: <hstep> +data: '1' +end tag: </hstep> +data: '\012 ' +start tag: <hpage> +data: '10' +end tag: </hpage> +data: '\012 ' +start tag: <hpage_size> +data: '10' +end tag: </hpage_size> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkHScale' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'hscale1' +end tag: </name> +data: '\012 ' +start tag: <child> +data: '\012 ' +start tag: <left_attach> +data: '1' +end tag: </left_attach> +data: '\012 ' +start tag: <right_attach> +data: '2' +end tag: </right_attach> +data: '\012 ' +start tag: <top_attach> +data: '2' +end tag: </top_attach> +data: '\012 ' +start tag: <bottom_attach> +data: '3' +end tag: </bottom_attach> +data: '\012 ' +start tag: <xpad> +data: '0' +end tag: </xpad> +data: '\012 ' +start tag: <ypad> +data: '0' +end tag: </ypad> +data: '\012 ' +start tag: <xexpand> +data: 'True' +end tag: </xexpand> +data: '\012 ' +start tag: <yexpand> +data: 'True' +end tag: </yexpand> +data: '\012 ' +start tag: <xshrink> +data: 'False' +end tag: </xshrink> +data: '\012 ' +start tag: <yshrink> +data: 'False' +end tag: </yshrink> +data: '\012 ' +start tag: <xfill> +data: 'True' +end tag: </xfill> +data: '\012 ' +start tag: <yfill> +data: 'True' +end tag: </yfill> +data: '\012 ' +end tag: </child> +data: '\012 ' +start tag: <width> +data: '75' +end tag: </width> +data: '\012 ' +start tag: <can_focus> +data: 'True' +end tag: </can_focus> +data: '\012 ' +start tag: <draw_value> +data: 'True' +end tag: </draw_value> +data: '\012 ' +start tag: <value_pos> +data: 'GTK_POS_TOP' +end tag: </value_pos> +data: '\012 ' +start tag: <digits> +data: '1' +end tag: </digits> +data: '\012 ' +start tag: <policy> +data: 'GTK_UPDATE_CONTINUOUS' +end tag: </policy> +data: '\012 ' +start tag: <hvalue> +data: '0' +end tag: </hvalue> +data: '\012 ' +start tag: <hlower> +data: '0' +end tag: </hlower> +data: '\012 ' +start tag: <hupper> +data: '100' +end tag: </hupper> +data: '\012 ' +start tag: <hstep> +data: '1' +end tag: </hstep> +data: '\012 ' +start tag: <hpage> +data: '10' +end tag: </hpage> +data: '\012 ' +start tag: <hpage_size> +data: '10' +end tag: </hpage_size> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkFixed' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'fixed1' +end tag: </name> +data: '\012 ' +start tag: <child> +data: '\012 ' +start tag: <left_attach> +data: '2' +end tag: </left_attach> +data: '\012 ' +start tag: <right_attach> +data: '3' +end tag: </right_attach> +data: '\012 ' +start tag: <top_attach> +data: '2' +end tag: </top_attach> +data: '\012 ' +start tag: <bottom_attach> +data: '3' +end tag: </bottom_attach> +data: '\012 ' +start tag: <xpad> +data: '0' +end tag: </xpad> +data: '\012 ' +start tag: <ypad> +data: '0' +end tag: </ypad> +data: '\012 ' +start tag: <xexpand> +data: 'True' +end tag: </xexpand> +data: '\012 ' +start tag: <yexpand> +data: 'True' +end tag: </yexpand> +data: '\012 ' +start tag: <xshrink> +data: 'False' +end tag: </xshrink> +data: '\012 ' +start tag: <yshrink> +data: 'False' +end tag: </yshrink> +data: '\012 ' +start tag: <xfill> +data: 'True' +end tag: </xfill> +data: '\012 ' +start tag: <yfill> +data: 'True' +end tag: </yfill> +data: '\012 ' +end tag: </child> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkButton' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'button1' +end tag: </name> +data: '\012 ' +start tag: <x> +data: '40' +end tag: </x> +data: '\012 ' +start tag: <y> +data: '40' +end tag: </y> +data: '\012 ' +start tag: <width> +data: '47' +end tag: </width> +data: '\012 ' +start tag: <height> +data: '22' +end tag: </height> +data: '\012 ' +start tag: <can_focus> +data: 'True' +end tag: </can_focus> +data: '\012 ' +start tag: <label> +data: 'button1' +end tag: </label> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkSpinButton' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'spinbutton2' +end tag: </name> +data: '\012 ' +start tag: <x> +data: '16' +end tag: </x> +data: '\012 ' +start tag: <y> +data: '0' +end tag: </y> +data: '\012 ' +start tag: <width> +data: '45' +end tag: </width> +data: '\012 ' +start tag: <height> +data: '22' +end tag: </height> +data: '\012 ' +start tag: <can_focus> +data: 'True' +end tag: </can_focus> +data: '\012 ' +start tag: <climb_rate> +data: '1' +end tag: </climb_rate> +data: '\012 ' +start tag: <digits> +data: '0' +end tag: </digits> +data: '\012 ' +start tag: <numeric> +data: 'False' +end tag: </numeric> +data: '\012 ' +start tag: <update_policy> +data: 'GTK_UPDATE_ALWAYS' +end tag: </update_policy> +data: '\012 ' +start tag: <snap> +data: 'False' +end tag: </snap> +data: '\012 ' +start tag: <wrap> +data: 'False' +end tag: </wrap> +data: '\012 ' +start tag: <hvalue> +data: '1' +end tag: </hvalue> +data: '\012 ' +start tag: <hlower> +data: '0' +end tag: </hlower> +data: '\012 ' +start tag: <hupper> +data: '100' +end tag: </hupper> +data: '\012 ' +start tag: <hstep> +data: '1' +end tag: </hstep> +data: '\012 ' +start tag: <hpage> +data: '10' +end tag: </hpage> +data: '\012 ' +start tag: <hpage_size> +data: '10' +end tag: </hpage_size> +data: '\012 ' +end tag: </widget> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkFrame' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'frame1' +end tag: </name> +data: '\012 ' +start tag: <child> +data: '\012 ' +start tag: <left_attach> +data: '0' +end tag: </left_attach> +data: '\012 ' +start tag: <right_attach> +data: '3' +end tag: </right_attach> +data: '\012 ' +start tag: <top_attach> +data: '3' +end tag: </top_attach> +data: '\012 ' +start tag: <bottom_attach> +data: '4' +end tag: </bottom_attach> +data: '\012 ' +start tag: <xpad> +data: '0' +end tag: </xpad> +data: '\012 ' +start tag: <ypad> +data: '0' +end tag: </ypad> +data: '\012 ' +start tag: <xexpand> +data: 'True' +end tag: </xexpand> +data: '\012 ' +start tag: <yexpand> +data: 'True' +end tag: </yexpand> +data: '\012 ' +start tag: <xshrink> +data: 'False' +end tag: </xshrink> +data: '\012 ' +start tag: <yshrink> +data: 'False' +end tag: </yshrink> +data: '\012 ' +start tag: <xfill> +data: 'True' +end tag: </xfill> +data: '\012 ' +start tag: <yfill> +data: 'True' +end tag: </yfill> +data: '\012 ' +end tag: </child> +data: '\012 ' +start tag: <label_xalign> +data: '0' +end tag: </label_xalign> +data: '\012 ' +start tag: <shadow_type> +data: 'GTK_SHADOW_ETCHED_IN' +end tag: </shadow_type> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkHButtonBox' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'hbuttonbox1' +end tag: </name> +data: '\012 ' +start tag: <layout_style> +data: 'GTK_BUTTONBOX_DEFAULT_STYLE' +end tag: </layout_style> +data: '\012 ' +start tag: <spacing> +data: '30' +end tag: </spacing> +data: '\012 ' +start tag: <child_min_width> +data: '85' +end tag: </child_min_width> +data: '\012 ' +start tag: <child_min_height> +data: '27' +end tag: </child_min_height> +data: '\012 ' +start tag: <child_ipad_x> +data: '7' +end tag: </child_ipad_x> +data: '\012 ' +start tag: <child_ipad_y> +data: '0' +end tag: </child_ipad_y> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkButton' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'button2' +end tag: </name> +data: '\012 ' +start tag: <can_focus> +data: 'True' +end tag: </can_focus> +data: '\012 ' +start tag: <label> +data: 'button2' +end tag: </label> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkButton' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'button3' +end tag: </name> +data: '\012 ' +start tag: <can_focus> +data: 'True' +end tag: </can_focus> +data: '\012 ' +start tag: <label> +data: 'button3' +end tag: </label> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkButton' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'button4' +end tag: </name> +data: '\012 ' +start tag: <can_focus> +data: 'True' +end tag: </can_focus> +data: '\012 ' +start tag: <label> +data: 'button4' +end tag: </label> +data: '\012 ' +end tag: </widget> +data: '\012 ' +end tag: </widget> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkAlignment' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'alignment1' +end tag: </name> +data: '\012 ' +start tag: <child> +data: '\012 ' +start tag: <left_attach> +data: '1' +end tag: </left_attach> +data: '\012 ' +start tag: <right_attach> +data: '2' +end tag: </right_attach> +data: '\012 ' +start tag: <top_attach> +data: '4' +end tag: </top_attach> +data: '\012 ' +start tag: <bottom_attach> +data: '5' +end tag: </bottom_attach> +data: '\012 ' +start tag: <xpad> +data: '0' +end tag: </xpad> +data: '\012 ' +start tag: <ypad> +data: '0' +end tag: </ypad> +data: '\012 ' +start tag: <xexpand> +data: 'True' +end tag: </xexpand> +data: '\012 ' +start tag: <yexpand> +data: 'True' +end tag: </yexpand> +data: '\012 ' +start tag: <xshrink> +data: 'False' +end tag: </xshrink> +data: '\012 ' +start tag: <yshrink> +data: 'False' +end tag: </yshrink> +data: '\012 ' +start tag: <xfill> +data: 'True' +end tag: </xfill> +data: '\012 ' +start tag: <yfill> +data: 'True' +end tag: </yfill> +data: '\012 ' +end tag: </child> +data: '\012 ' +start tag: <xalign> +data: '0.5' +end tag: </xalign> +data: '\012 ' +start tag: <yalign> +data: '0.5' +end tag: </yalign> +data: '\012 ' +start tag: <xscale> +data: '1' +end tag: </xscale> +data: '\012 ' +start tag: <yscale> +data: '1' +end tag: </yscale> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkVScrollbar' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'vscrollbar1' +end tag: </name> +data: '\012 ' +start tag: <can_focus> +data: 'True' +end tag: </can_focus> +data: '\012 ' +start tag: <policy> +data: 'GTK_UPDATE_CONTINUOUS' +end tag: </policy> +data: '\012 ' +start tag: <vvalue> +data: '0' +end tag: </vvalue> +data: '\012 ' +start tag: <vlower> +data: '0' +end tag: </vlower> +data: '\012 ' +start tag: <vupper> +data: '0' +end tag: </vupper> +data: '\012 ' +start tag: <vstep> +data: '0' +end tag: </vstep> +data: '\012 ' +start tag: <vpage> +data: '0' +end tag: </vpage> +data: '\012 ' +start tag: <vpage_size> +data: '0' +end tag: </vpage_size> +data: '\012 ' +end tag: </widget> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkAlignment' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'alignment2' +end tag: </name> +data: '\012 ' +start tag: <child> +data: '\012 ' +start tag: <left_attach> +data: '0' +end tag: </left_attach> +data: '\012 ' +start tag: <right_attach> +data: '1' +end tag: </right_attach> +data: '\012 ' +start tag: <top_attach> +data: '4' +end tag: </top_attach> +data: '\012 ' +start tag: <bottom_attach> +data: '5' +end tag: </bottom_attach> +data: '\012 ' +start tag: <xpad> +data: '0' +end tag: </xpad> +data: '\012 ' +start tag: <ypad> +data: '0' +end tag: </ypad> +data: '\012 ' +start tag: <xexpand> +data: 'True' +end tag: </xexpand> +data: '\012 ' +start tag: <yexpand> +data: 'True' +end tag: </yexpand> +data: '\012 ' +start tag: <xshrink> +data: 'False' +end tag: </xshrink> +data: '\012 ' +start tag: <yshrink> +data: 'False' +end tag: </yshrink> +data: '\012 ' +start tag: <xfill> +data: 'True' +end tag: </xfill> +data: '\012 ' +start tag: <yfill> +data: 'True' +end tag: </yfill> +data: '\012 ' +end tag: </child> +data: '\012 ' +start tag: <xalign> +data: '0.5' +end tag: </xalign> +data: '\012 ' +start tag: <yalign> +data: '0.5' +end tag: </yalign> +data: '\012 ' +start tag: <xscale> +data: '1' +end tag: </xscale> +data: '\012 ' +start tag: <yscale> +data: '1' +end tag: </yscale> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkCurve' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'curve1' +end tag: </name> +data: '\012 ' +start tag: <curve_type> +data: 'GTK_CURVE_TYPE_SPLINE' +end tag: </curve_type> +data: '\012 ' +start tag: <min_x> +data: '0' +end tag: </min_x> +data: '\012 ' +start tag: <max_x> +data: '1' +end tag: </max_x> +data: '\012 ' +start tag: <min_y> +data: '0' +end tag: </min_y> +data: '\012 ' +start tag: <max_y> +data: '1' +end tag: </max_y> +data: '\012 ' +end tag: </widget> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkCList' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'clist1' +end tag: </name> +data: '\012 ' +start tag: <child> +data: '\012 ' +start tag: <left_attach> +data: '2' +end tag: </left_attach> +data: '\012 ' +start tag: <right_attach> +data: '3' +end tag: </right_attach> +data: '\012 ' +start tag: <top_attach> +data: '4' +end tag: </top_attach> +data: '\012 ' +start tag: <bottom_attach> +data: '5' +end tag: </bottom_attach> +data: '\012 ' +start tag: <xpad> +data: '0' +end tag: </xpad> +data: '\012 ' +start tag: <ypad> +data: '0' +end tag: </ypad> +data: '\012 ' +start tag: <xexpand> +data: 'True' +end tag: </xexpand> +data: '\012 ' +start tag: <yexpand> +data: 'True' +end tag: </yexpand> +data: '\012 ' +start tag: <xshrink> +data: 'False' +end tag: </xshrink> +data: '\012 ' +start tag: <yshrink> +data: 'False' +end tag: </yshrink> +data: '\012 ' +start tag: <xfill> +data: 'True' +end tag: </xfill> +data: '\012 ' +start tag: <yfill> +data: 'True' +end tag: </yfill> +data: '\012 ' +end tag: </child> +data: '\012 ' +start tag: <can_focus> +data: 'True' +end tag: </can_focus> +data: '\012 ' +start tag: <columns> +data: '3' +end tag: </columns> +data: '\012 ' +start tag: <column_widths> +data: '80,80,80' +end tag: </column_widths> +data: '\012 ' +start tag: <selection_mode> +data: 'GTK_SELECTION_SINGLE' +end tag: </selection_mode> +data: '\012 ' +start tag: <show_titles> +data: 'True' +end tag: </show_titles> +data: '\012 ' +start tag: <shadow_type> +data: 'GTK_SHADOW_IN' +end tag: </shadow_type> +data: '\012 ' +start tag: <hscrollbar_policy> +data: 'GTK_POLICY_AUTOMATIC' +end tag: </hscrollbar_policy> +data: '\012 ' +start tag: <vscrollbar_policy> +data: 'GTK_POLICY_AUTOMATIC' +end tag: </vscrollbar_policy> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkLabel' +end tag: </class> +data: '\012 ' +start tag: <child_name> +data: 'CList:title' +end tag: </child_name> +data: '\012 ' +start tag: <name> +data: 'label2' +end tag: </name> +data: '\012 ' +start tag: <label> +data: 'Col1' +end tag: </label> +data: '\012 ' +start tag: <justify> +data: 'GTK_JUSTIFY_CENTER' +end tag: </justify> +data: '\012 ' +start tag: <xalign> +data: '0.5' +end tag: </xalign> +data: '\012 ' +start tag: <yalign> +data: '0.5' +end tag: </yalign> +data: '\012 ' +start tag: <xpad> +data: '0' +end tag: </xpad> +data: '\012 ' +start tag: <ypad> +data: '0' +end tag: </ypad> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkLabel' +end tag: </class> +data: '\012 ' +start tag: <child_name> +data: 'CList:title' +end tag: </child_name> +data: '\012 ' +start tag: <name> +data: 'label3' +end tag: </name> +data: '\012 ' +start tag: <label> +data: 'Col3' +end tag: </label> +data: '\012 ' +start tag: <justify> +data: 'GTK_JUSTIFY_CENTER' +end tag: </justify> +data: '\012 ' +start tag: <xalign> +data: '0.5' +end tag: </xalign> +data: '\012 ' +start tag: <yalign> +data: '0.5' +end tag: </yalign> +data: '\012 ' +start tag: <xpad> +data: '0' +end tag: </xpad> +data: '\012 ' +start tag: <ypad> +data: '0' +end tag: </ypad> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkArrow' +end tag: </class> +data: '\012 ' +start tag: <child_name> +data: 'CList:title' +end tag: </child_name> +data: '\012 ' +start tag: <name> +data: 'arrow2' +end tag: </name> +data: '\012 ' +start tag: <arrow_type> +data: 'GTK_ARROW_DOWN' +end tag: </arrow_type> +data: '\012 ' +start tag: <shadow_type> +data: 'GTK_SHADOW_OUT' +end tag: </shadow_type> +data: '\012 ' +start tag: <xalign> +data: '0.5' +end tag: </xalign> +data: '\012 ' +start tag: <yalign> +data: '0.5' +end tag: </yalign> +data: '\012 ' +start tag: <xpad> +data: '0' +end tag: </xpad> +data: '\012 ' +start tag: <ypad> +data: '0' +end tag: </ypad> +data: '\012 ' +end tag: </widget> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkNotebook' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'notebook1' +end tag: </name> +data: '\012 ' +start tag: <child> +data: '\012 ' +start tag: <left_attach> +data: '0' +end tag: </left_attach> +data: '\012 ' +start tag: <right_attach> +data: '3' +end tag: </right_attach> +data: '\012 ' +start tag: <top_attach> +data: '0' +end tag: </top_attach> +data: '\012 ' +start tag: <bottom_attach> +data: '1' +end tag: </bottom_attach> +data: '\012 ' +start tag: <xpad> +data: '0' +end tag: </xpad> +data: '\012 ' +start tag: <ypad> +data: '0' +end tag: </ypad> +data: '\012 ' +start tag: <xexpand> +data: 'True' +end tag: </xexpand> +data: '\012 ' +start tag: <yexpand> +data: 'True' +end tag: </yexpand> +data: '\012 ' +start tag: <xshrink> +data: 'False' +end tag: </xshrink> +data: '\012 ' +start tag: <yshrink> +data: 'False' +end tag: </yshrink> +data: '\012 ' +start tag: <xfill> +data: 'True' +end tag: </xfill> +data: '\012 ' +start tag: <yfill> +data: 'True' +end tag: </yfill> +data: '\012 ' +end tag: </child> +data: '\012 ' +start tag: <can_focus> +data: 'True' +end tag: </can_focus> +data: '\012 ' +start tag: <show_tabs> +data: 'True' +end tag: </show_tabs> +data: '\012 ' +start tag: <show_border> +data: 'True' +end tag: </show_border> +data: '\012 ' +start tag: <tab_pos> +data: 'GTK_POS_TOP' +end tag: </tab_pos> +data: '\012 ' +start tag: <scrollable> +data: 'False' +end tag: </scrollable> +data: '\012 ' +start tag: <tab_border> +data: '3' +end tag: </tab_border> +data: '\012 ' +start tag: <popup_enable> +data: 'False' +end tag: </popup_enable> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkHRuler' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'hruler1' +end tag: </name> +data: '\012 ' +start tag: <metric> +data: 'GTK_PIXELS' +end tag: </metric> +data: '\012 ' +start tag: <lower> +data: '0' +end tag: </lower> +data: '\012 ' +start tag: <upper> +data: '10' +end tag: </upper> +data: '\012 ' +start tag: <position> +data: '0' +end tag: </position> +data: '\012 ' +start tag: <max_size> +data: '10' +end tag: </max_size> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkHScale' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'hscale2' +end tag: </name> +data: '\012 ' +start tag: <can_focus> +data: 'True' +end tag: </can_focus> +data: '\012 ' +start tag: <draw_value> +data: 'True' +end tag: </draw_value> +data: '\012 ' +start tag: <value_pos> +data: 'GTK_POS_TOP' +end tag: </value_pos> +data: '\012 ' +start tag: <digits> +data: '1' +end tag: </digits> +data: '\012 ' +start tag: <policy> +data: 'GTK_UPDATE_CONTINUOUS' +end tag: </policy> +data: '\012 ' +start tag: <hvalue> +data: '0' +end tag: </hvalue> +data: '\012 ' +start tag: <hlower> +data: '0' +end tag: </hlower> +data: '\012 ' +start tag: <hupper> +data: '100' +end tag: </hupper> +data: '\012 ' +start tag: <hstep> +data: '1' +end tag: </hstep> +data: '\012 ' +start tag: <hpage> +data: '10' +end tag: </hpage> +data: '\012 ' +start tag: <hpage_size> +data: '10' +end tag: </hpage_size> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkProgressBar' +end tag: </class> +data: '\012 ' +start tag: <name> +data: 'progressbar1' +end tag: </name> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkLabel' +end tag: </class> +data: '\012 ' +start tag: <child_name> +data: 'Notebook:tab' +end tag: </child_name> +data: '\012 ' +start tag: <name> +data: 'label5' +end tag: </name> +data: '\012 ' +start tag: <label> +data: 'label5' +end tag: </label> +data: '\012 ' +start tag: <justify> +data: 'GTK_JUSTIFY_CENTER' +end tag: </justify> +data: '\012 ' +start tag: <xalign> +data: '0.5' +end tag: </xalign> +data: '\012 ' +start tag: <yalign> +data: '0.5' +end tag: </yalign> +data: '\012 ' +start tag: <xpad> +data: '0' +end tag: </xpad> +data: '\012 ' +start tag: <ypad> +data: '0' +end tag: </ypad> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkLabel' +end tag: </class> +data: '\012 ' +start tag: <child_name> +data: 'Notebook:tab' +end tag: </child_name> +data: '\012 ' +start tag: <name> +data: 'label6' +end tag: </name> +data: '\012 ' +start tag: <label> +data: 'label6' +end tag: </label> +data: '\012 ' +start tag: <justify> +data: 'GTK_JUSTIFY_CENTER' +end tag: </justify> +data: '\012 ' +start tag: <xalign> +data: '0.5' +end tag: </xalign> +data: '\012 ' +start tag: <yalign> +data: '0.5' +end tag: </yalign> +data: '\012 ' +start tag: <xpad> +data: '0' +end tag: </xpad> +data: '\012 ' +start tag: <ypad> +data: '0' +end tag: </ypad> +data: '\012 ' +end tag: </widget> +data: '\012\012 ' +start tag: <widget> +data: '\012 ' +start tag: <class> +data: 'GtkLabel' +end tag: </class> +data: '\012 ' +start tag: <child_name> +data: 'Notebook:tab' +end tag: </child_name> +data: '\012 ' +start tag: <name> +data: 'label7' +end tag: </name> +data: '\012 ' +start tag: <label> +data: 'label7' +end tag: </label> +data: '\012 ' +start tag: <justify> +data: 'GTK_JUSTIFY_CENTER' +end tag: </justify> +data: '\012 ' +start tag: <xalign> +data: '0.5' +end tag: </xalign> +data: '\012 ' +start tag: <yalign> +data: '0.5' +end tag: </yalign> +data: '\012 ' +start tag: <xpad> +data: '0' +end tag: </xpad> +data: '\012 ' +start tag: <ypad> +data: '0' +end tag: </ypad> +data: '\012 ' +end tag: </widget> +data: '\012 ' +end tag: </widget> +data: '\012 ' +end tag: </widget> +data: '\012' +end tag: </widget> +data: '\012\012' +end tag: </GTK-Interface> diff --git a/examples/ide/.cvsignore b/examples/ide/.cvsignore new file mode 100644 index 00000000..c2831020 --- /dev/null +++ b/examples/ide/.cvsignore @@ -0,0 +1,6 @@ +Makefile.in +Makefile +*~ +*.pyc +*.pyo + diff --git a/examples/ide/README b/examples/ide/README new file mode 100644 index 00000000..99568b0f --- /dev/null +++ b/examples/ide/README @@ -0,0 +1,7 @@ +This directory contains some tools that can be used to help develop python +applications. There is a graphical front end to the profiler and debugger, +and a graphical python console, and a 'module browser'. + +I will probably link these together with an editor (just use emacs, or write +one in python?). + diff --git a/examples/ide/break.xpm b/examples/ide/break.xpm new file mode 100644 index 00000000..f5221a30 --- /dev/null +++ b/examples/ide/break.xpm @@ -0,0 +1,29 @@ +/* XPM */ +static char * break_xpm[] = { +"21 22 4 1", +" c None", +". c #000000", +"X c #FFFFFF", +"o c #FF0000", +" ......... ", +" .XXXXXXXXX. ", +" .XXoooooooXX. ", +" .XXoooooooooXX. ", +" .XXoooooooooooXX. ", +" .XXoooooooooooooXX. ", +".XXoooooooooooooooXX.", +".XoooooooooooooooooX.", +".XooXXoXXXoXXooXXooX.", +".XoXooXoXoXooXoXoXoX.", +".XoXooooXoXooXoXoXoX.", +".XooXXooXoXooXoXXooX.", +".XooooXoXoXooXoXoooX.", +".XoXooXoXoXooXoXoooX.", +".XooXXooXooXXooXoooX.", +".XXoooooooooooooooXX.", +" .XXoooooooooooooXX. ", +" .XXoooooooooooXX. ", +" .XXoooooooooXX. ", +" .XXoooooooXX. ", +" .XXXXXXXXX. ", +" ......... "}; diff --git a/examples/ide/browse.py b/examples/ide/browse.py new file mode 100755 index 00000000..ba8e55d1 --- /dev/null +++ b/examples/ide/browse.py @@ -0,0 +1,117 @@ +#!/usr/bin/env python + +# This is an example of using dynamic trees (trees where nodes are only +# calculated as they are needed) with pygtk. This particular example +# allows for the browsing of the variables in a module, allowing the +# descent into classes and modules and other objects with a __dict__ +# attribute. + +# If this file is run straight, it will let you browse the gtk module. + +from gtk import * + +class BrowseTreeItem(GtkTreeItem): + def __init__(self, name, dict=None, disp=None): + GtkTreeItem.__init__(self, name) + self.name = name + self.dict = dict + self.disp = disp + self.exp_id = self.connect("expand", self.sig_expand) + def init_subtree(self): + if self.dict: + self.subtree = GtkTree() + self.subtree.set_selection_mode(SELECTION_BROWSE) + self.subtree.connect("select_child", self.subsel_child) + self.set_subtree(self.subtree) + self.subtree.show() + def subsel_child(self, _t, _c): + if self.disp: + key = _c.children()[0].get() + if key == '__builtins__': # builtins includes itself + value = key + else: + value = `self.dict[key]` + self.disp.set_text(value) + def sig_select(self): + if self.disp: + self.disp.set_text(value) + def sig_expand(self, _t): + keys = self.dict.keys() + keys.sort() + for key in keys: + dict = None + try: + dict = vars(self.dict[key]) + except TypeError: + pass + item = BrowseTreeItem(key, dict, self.disp) + self.subtree.append(item) + item.init_subtree() + item.show() + self.disconnect(self.exp_id) + +class BrowseVariables(GtkVBox): + def __init__(self, name, dict): + GtkVBox.__init__(self) + self.set_spacing(2) + + self.sw = GtkScrolledWindow() + self.sw.set_usize(300, 200) + self.sw.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) + self.pack_start(self.sw) + self.sw.show() + + self.disp = GtkEntry() + self.disp.set_editable(FALSE) + self.pack_start(self.disp, expand=FALSE) + self.disp.show() + + self.root_tree = GtkTree() + self.sw.add(self.root_tree) + self.root_tree.show() + + self.browse = BrowseTreeItem(name, dict, self.disp) + self.root_tree.append(self.browse) + self.browse.init_subtree() + self.browse.show() + +class BrowseWindow(GtkWindow): + def __init__(self, name, dict): + GtkWindow.__init__(self) + self.set_title("Browse Window") + + box = GtkVBox() + self.add(box) + box.show() + + browse = BrowseVariables(name, dict) + browse.border_width(10) + box.pack_start(browse) + browse.show() + + separator = GtkHSeparator() + box.pack_start(separator, expand=FALSE) + separator.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box.pack_start(box2, expand=FALSE) + box2.show() + + button = GtkButton("Close") + box2.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + self.close_button = button + +if __name__ == '__main__': + import gtk + win = BrowseWindow('gtk', vars(gtk)) + win.set_title("Browse gtk.py") + win.connect("destroy", mainquit) + win.connect("delete_event", mainquit) + win.close_button.connect("clicked", mainquit) + win.show() + + mainloop() diff --git a/examples/ide/continue.xpm b/examples/ide/continue.xpm new file mode 100644 index 00000000..f44f61d7 --- /dev/null +++ b/examples/ide/continue.xpm @@ -0,0 +1,27 @@ +/* XPM */ +static char * continue_xpm[] = { +"20 22 2 1", +" c None", +". c #000000", +" ", +" ", +" . . ", +" .. .. ", +" ... ... ", +" .... .... ", +" ..... ..... ", +" ...... ...... ", +" ....... ....... ", +" ........ ........ ", +" .................. ", +" .................. ", +" ........ ........ ", +" ....... ....... ", +" ...... ...... ", +" ..... ..... ", +" .... .... ", +" ... ... ", +" .. .. ", +" . . ", +" ", +" "}; diff --git a/examples/ide/edit.py b/examples/ide/edit.py new file mode 100644 index 00000000..7b0f0349 --- /dev/null +++ b/examples/ide/edit.py @@ -0,0 +1,181 @@ +#!/usr/bin/env python + +# This is a sample implementation of an editor. + +from gtk import * +import GtkExtra +import os + +BLOCK_SIZE = 2048 + +class EditWindow(GtkWindow): + def __init__(self, quit_cb=None): + GtkWindow.__init__(self, WINDOW_TOPLEVEL) + self.set_usize(470, 300) + self.connect("delete_event", self.file_exit) + + self.quit_cb = quit_cb + + self.table = GtkTable(2,3) + self.add(self.table) + self.table.show() + hdlbox = GtkHandleBox() + self.table.attach(hdlbox, 0,2, 0,1, xoptions=FILL, + yoptions=FILL) + hdlbox.show() + self.menubar = self.create_menu() + hdlbox.add(self.menubar) + self.menubar.show() + + self.text = GtkText() + self.text.connect("changed", self.set_dirty) + self.text.set_editable(TRUE) + self.table.attach(self.text, 0,1, 1,2) + self.text.show() + + vadj = self.text.get_vadjustment() + self.vscroll = GtkVScrollbar(vadj) + self.table.attach(self.vscroll, 1,2, 1,2, xoptions=FILL) + self.vscroll.show() + vadj.connect('changed', self.chk_scroll) + + self.text.realize() + self.dirty = 0 + self.file_new() + self.text.grab_focus() + + def set_dirty(self, text=None): + self.dirty = 1 + def chk_scroll(self, adj): + if adj.upper - adj.lower <= adj.page_size: + self.vscroll.hide() + else: + self.vscroll.show() + + def load_file(self, fname): + try: + fd = open(fname) + self.text.freeze() + self.text.delete_text(0, self.text.get_length()) + buf = fd.read(BLOCK_SIZE) + while buf != '': + self.text.insert_defaults(buf) + buf = fd.read(BLOCK_SIZE) + self.text.thaw() + self.text.get_vadjustment().set_value(0) + self.text.queue_draw() + self.set_title(os.path.basename(fname)) + self.fname = fname + self.dirty = 0 + self.new = 0 + except: + GtkExtra.message_box('Edit', "Can't open " + fname, + ("OK",)) + + def create_menu(self): + mf = GtkExtra.MenuFactory() + + mf.add_entries([ + ('File/New', '<control>N', self.file_new), + ('File/Open...', '<control>O', self.file_open), + ('File/Save', '<control>S', self.file_save), + ('File/Save As...', None, self.file_saveas), + ('File/<separator>',None, None), + ('File/Exit', '<control>Q', self.file_exit), + ('Edit/Cut', '<control>X', self.edit_cut), + ('Edit/Copy', '<control>C', self.edit_copy), + ('Edit/Paste', '<control>V', self.edit_paste), + ('Edit/Clear', None, self.edit_clear), + ('Edit/<separator>',None, None), + ('Edit/Find...', None, self.edit_find), + ('Edit/Find Next', None, self.edit_find_next), + ('Help/About...', None, self.help_about) + ]) + # activate key bindings ... + self.add_accel_group(mf.accelerator) + self.mf = mf + return mf + + def chk_save(self): + if self.dirty: + ret = GtkExtra.message_box("Unsaved File", + (self.fname or "Untitled")+ + " has not been saved\n" + + "Do you want to save it?", + ("Yes", "No", "Cancel")) + if ret == None or ret == "Cancel": return 1 + if ret == "Yes": self.file_save() + return 0 + + def file_new(self, mi=None): + if self.chk_save(): return + self.text.freeze() + self.text.delete_text(0, self.text.get_length()) + self.text.thaw() + self.dirty = 0 + self.fname = None + self.set_title("Untitled") + self.new = 1 + def file_open(self, mi=None): + if self.chk_save(): return + fname = GtkExtra.file_open_box(modal=FALSE) + if not fname: return + self.load_file(fname) + def file_save(self, mi=None): + if self.new: + self.file_saveas() + return + try: + pos = 0 + length = self.text.get_length() + fd = open(self.fname, "w") + while pos < length: + buf = self.text.get_chars(pos, + min(pos+BLOCK_SIZE, length)) + if buf != None: fd.write(buf) + pos = pos + BLOCK_SIZE + self.dirty = 0 + except: + GtkExtra.message_box("Save", "Error saving file " + + self.fname, ("OK",)) + + def file_saveas(self, mi=None): + fname = GtkExtra.file_save_box(modal=FALSE) + if not fname: return + self.fname = fname + self.set_title(os.path.basename(fname)) + self.new = 0 + self.file_save() + def file_exit(self, mi=None, event=None): + if self.chk_save(): return + self.hide() + self.destroy() + if self.quit_cb: self.quit_cb(self) + def edit_cut(self, mi): + self.text.cut_clipboard(0) + def edit_copy(self, mi): + self.text.copy_clipboard(0) + def edit_paste(self, mi): + self.text.paste_clipboard(0) + def edit_clear(self, mi): + self.text.delete_selection() + # I'll implement these later + def edit_find(self, mi): pass + def edit_find_next(self, mi): pass + def help_about(self, mi): + GtkExtra.message_box("Edit Window", "Copyright (C) 1998 " + + "James Henstridge\n" + + "This program is covered by the GPL>=2", + ("OK",)) + +def edit(fname, mainwin=FALSE): + if mainwin: quit_cb = mainquit + else: quit_cb = None + w = EditWindow(quit_cb=quit_cb) + w.load_file(fname) + w.show() + w.set_usize(0,0) + if mainwin: mainloop() +if __name__ == '__main__': + import sys + edit(sys.argv[-1], mainwin=TRUE) diff --git a/examples/ide/edit.xpm b/examples/ide/edit.xpm new file mode 100644 index 00000000..a2291f36 --- /dev/null +++ b/examples/ide/edit.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char *edit[] = { +/* width height num_colors chars_per_pixel */ +" 20 22 8 1", +/* colors */ +". c #ffffff", +"# c None", +"a c #9999ff", +"b c #999999", +"c c #6666cc", +"d c #663399", +"e c #333333", +"f c #000000", +/* pixels */ +"eeeeeeeeeeeee#######", +"e..........e.e######", +"e..........e..eeffff", +"e..........e.effadf#", +"e..........effacdf##", +"e.........ffaccdff##", +"e........facccdfbf##", +"e.......faccddfbbf##", +"e......faccddf..bf##", +"e.....faccddf...bf##", +"e....faccddf....bf##", +"e...eaccddf.....bf##", +"e...facddf......bf##", +"e..eacddf.......bf##", +"e..faeff........bf##", +"e.eaeb..........bf##", +"e.feb...........bf##", +"e.fb............bf##", +"e.f.............bf##", +"e...............bf##", +"eebbbbbbbbbbbbbbef##", +"##ffffffffffffffff##" +}; + diff --git a/examples/ide/gtkcons.py b/examples/ide/gtkcons.py new file mode 100755 index 00000000..140dca93 --- /dev/null +++ b/examples/ide/gtkcons.py @@ -0,0 +1,329 @@ +#!/usr/bin/env python + +# Interactive Python-GTK Console +# Copyright (C), 1998 James Henstridge <james@daa.com.au> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# This module implements an interactive python session in a GTK window. To +# start the session, use the gtk_console command. Its specification is: +# gtk_console(namespace, title, copyright) +# where namespace is a dictionary representing the namespace of the session, +# title is the title on the window and +# copyright is any additional copyright info to print. +# +# As well as the starting attributes in namespace, the session will also +# have access to the list __history__, which is the command history. + +import sys, string, traceback +#sys.path.append('/home/james/.gimp/plug-ins') +from gtk import * + +stdout = sys.stdout + +if not hasattr(sys, 'ps1'): sys.ps1 = '>>> ' +if not hasattr(sys, 'ps2'): sys.ps2 = '... ' + +# some functions to help recognise breaks between commands +def remQuotStr(s): + '''Returns s with any quoted strings removed (leaving quote marks)''' + r = '' + inq = 0 + qt = '' + prev = '_' + while len(s): + s0, s = s[0], s[1:] + if inq and (s0 != qt or prev == '\\'): + prev = s0 + continue + prev = s0 + if s0 in '\'"': + if inq: + inq = 0 + else: + inq = 1 + qt = s0 + r = r + s0 + return r + +def bracketsBalanced(s): + '''Returns true iff the brackets in s are balanced''' + s = filter(lambda x: x in '()[]{}', s) + stack = [] + brackets = {'(':')', '[':']', '{':'}'} + while len(s) != 0: + if s[0] in ")]}": + if len(stack) != 0 and brackets[stack[-1]] == s[0]: + del stack[-1] + else: + return 0 + else: + stack.append(s[0]) + s = s[1:] + return len(stack) == 0 + +class gtkoutfile: + '''A fake output file object. It sends output to a TK test widget, + and if asked for a file number, returns one set on instance creation''' + def __init__(self, w, fn, font): + self.__fn = fn + self.__w = w + self.__font = font + def close(self): pass + flush = close + def fileno(self): return self.__fn + def isatty(self): return 0 + def read(self, a): return '' + def readline(self): return '' + def readlines(self): return [] + def write(self, s): + #stdout.write(str(self.__w.get_point()) + '\n') + self.__w.freeze() + self.__w.insert(self.__font, self.__w.fg, + self.__w.bg, s) + self.__w.thaw() + self.__w.queue_draw() + def writelines(self, l): + self.__w.freeze() + for s in l: self.__w.insert(self.__font, + self.__w.fg, self.__w.bg, s) + self.__w.thaw() + self.__w.queue_draw() + def seek(self, a): raise IOError, (29, 'Illegal seek') + def tell(self): raise IOError, (29, 'Illegal seek') + truncate = tell + +class Console(GtkVBox): + def __init__(self, namespace={}, copyright='', quit_cb=None): + GtkVBox.__init__(self, spacing=2) + self.border_width(2) + self.copyright = copyright + #self.set_usize(475, 300) + + self.quit_cb = quit_cb + + #load the fonts we will use + self.normal = load_font( + "-*-helvetica-medium-r-normal-*-*-100-*-*-*-*-*-*") + self.title = load_font( + "-*-helvetica-bold-r-normal-*-*-100-*-*-*-*-*-*") + self.error = load_font( + "-*-helvetica-medium-o-normal-*-12-100-*-*-*-*-*-*") + self.command = load_font( + "-*-helvetica-bold-r-normal-*-*-100-*-*-*-*-*-*") + + self.inp = GtkHBox() + self.pack_start(self.inp) + self.inp.show() + + self.text = GtkText() + self.text.set_editable(FALSE) + self.text.set_word_wrap(TRUE) + self.text.set_usize(500, 400) + self.inp.pack_start(self.text, padding=1) + self.text.show() + + self.vscroll = GtkVScrollbar(self.text.get_vadjustment()) + self.vscroll.set_update_policy(POLICY_AUTOMATIC) + self.inp.pack_end(self.vscroll, expand=FALSE) + self.vscroll.show() + + self.inputbox = GtkHBox(spacing=2) + self.pack_end(self.inputbox, expand=FALSE) + self.inputbox.show() + + self.prompt = GtkLabel(sys.ps1) + self.prompt.set_padding(xp=2, yp=0) + self.prompt.set_usize(26, -1) + self.inputbox.pack_start(self.prompt, fill=FALSE, expand=FALSE) + self.prompt.show() + + self.closer = GtkButton("Close") + self.closer.connect("clicked", self.quit) + self.inputbox.pack_end(self.closer, fill=FALSE, expand=FALSE) + self.closer.show() + + self.line = GtkEntry() + self.line.set_usize(400,-1) + self.line.connect("key_press_event", self.key_function) + self.inputbox.pack_start(self.line, padding=2) + self.line.show() + + # now let the text box be resized + self.text.set_usize(0, 0) + self.line.set_usize(0, -1) + + self.namespace = namespace + + self.cmd = '' + self.cmd2 = '' + + # set up hooks for standard output. + self.stdout = gtkoutfile(self.text, sys.stdout.fileno(), + self.normal) + self.stderr = gtkoutfile(self.text, sys.stderr.fileno(), + self.error) + + # set up command history + self.history = [''] + self.histpos = 0 + self.namespace['__history__'] = self.history + + def init(self): + self.text.realize() + self.text.style = self.text.get_style() + self.text.fg = self.text.style.fg[STATE_NORMAL] + self.text.bg = self.text.style.white + + self.text.insert(self.title, self.text.fg, + self.text.bg, 'Python %s\n%s\n\n' % + (sys.version, sys.copyright) + + 'Interactive Python-GTK Console - ' + + 'Copyright (C) 1998 James Henstridge\n\n' + + self.copyright + '\n') + self.line.grab_focus() + + def quit(self, *args): + self.hide() + self.destroy() + if self.quit_cb: self.quit_cb() + + def key_function(self, entry, event): + if event.keyval == GDK.Return: + self.line.emit_stop_by_name("key_press_event") + self.eval() + if event.keyval == GDK.Tab: + self.line.emit_stop_by_name("key_press_event") + self.line.append_text('\t') + idle_add(self.focus_text) + elif event.keyval in (GDK.KP_Up, GDK.Up): + self.line.emit_stop_by_name("key_press_event") + self.historyUp() + idle_add(self.focus_text) + elif event.keyval in (GDK.KP_Down, GDK.Down): + self.line.emit_stop_by_name("key_press_event") + self.historyDown() + idle_add(self.focus_text) + elif event.keyval in (GDK.D, GDK.d) and \ + event.state & GDK.CONTROL_MASK: + self.line.emit_stop_by_name("key_press_event") + self.ctrld() + + def focus_text(self): + self.line.grab_focus() + return FALSE # don't requeue this handler + + def ctrld(self): + self.quit() + + def historyUp(self): + if self.histpos > 0: + l = self.line.get_text() + if len(l) > 0 and l[0] == '\n': l = l[1:] + if len(l) > 0 and l[-1] == '\n': l = l[:-1] + self.history[self.histpos] = l + self.histpos = self.histpos - 1 + self.line.set_text(self.history[self.histpos]) + + def historyDown(self): + if self.histpos < len(self.history) - 1: + l = self.line.get_text() + if len(l) > 0 and l[0] == '\n': l = l[1:] + if len(l) > 0 and l[-1] == '\n': l = l[:-1] + self.history[self.histpos] = l + self.histpos = self.histpos + 1 + self.line.set_text(self.history[self.histpos]) + + def eval(self): + l = self.line.get_text() + '\n' + if len(l) > 1 and l[0] == '\n': l = l[1:] + self.histpos = len(self.history) - 1 + if len(l) > 0 and l[-1] == '\n': + self.history[self.histpos] = l[:-1] + else: + self.history[self.histpos] = l + self.line.set_text('') + self.text.freeze() + self.text.insert(self.command, self.text.fg, self.text.bg, + self.prompt.get() + l) + self.text.thaw() + if l == '\n': + self.run(self.cmd) + self.cmd = '' + self.cmd2 = '' + return + self.histpos = self.histpos + 1 + self.history.append('') + self.cmd = self.cmd + l + self.cmd2 = self.cmd2 + remQuotStr(l) + l = string.rstrip(l) + if not bracketsBalanced(self.cmd2) or l[-1] == ':' or \ + l[-1] == '\\' or l[0] in ' \11': + self.prompt.set(sys.ps2) + self.prompt.queue_draw() + return + self.run(self.cmd) + self.cmd = '' + self.cmd2 = '' + + def run(self, cmd): + sys.stdout, self.stdout = self.stdout, sys.stdout + sys.stderr, self.stderr = self.stderr, sys.stderr + try: + try: + r = eval(cmd, self.namespace, self.namespace) + if r is not None: + print `r` + except SyntaxError: + exec cmd in self.namespace + except: + if hasattr(sys, 'last_type') and \ + sys.last_type == SystemExit: + self.quit() + else: + traceback.print_exc() + self.prompt.set(sys.ps1) + self.prompt.queue_draw() + adj = self.text.get_vadjustment() + adj.set_value(adj.upper - adj.page_size) + sys.stdout, self.stdout = self.stdout, sys.stdout + sys.stderr, self.stderr = self.stderr, sys.stderr + +def gtk_console(ns, title='Python', copyright='', menu=None): + win = GtkWindow() + win.set_usize(475, 300) + win.connect("destroy", mainquit) + win.connect("delete_event", mainquit) + win.set_title(title) + cons = Console(namespace=ns, copyright=copyright, quit_cb=mainquit) + if menu: + box = GtkVBox() + win.add(box) + box.show() + box.pack_start(menu, expand=FALSE) + menu.show() + box.pack_start(cons) + else: + win.add(cons) + cons.show() + win.show() + win.set_usize(0,0) + cons.init() + mainloop() + +if __name__ == '__main__': + gtk_console({'__builtins__': __builtins__, '__name__': '__main__', + '__doc__': None}) + diff --git a/examples/ide/gtkdb.py b/examples/ide/gtkdb.py new file mode 100755 index 00000000..6874d34b --- /dev/null +++ b/examples/ide/gtkdb.py @@ -0,0 +1,350 @@ +#!/usr/bin/env python + +import sys +import bdb +import repr +import string +import linecache # for linecache.getlines(filename) +from gtk import * +import GtkExtra + +class GtkDb(GtkWindow, bdb.Bdb): + def __init__(self): + GtkWindow.__init__(self) + bdb.Bdb.__init__(self) + self.realize() + + self.set_title("GtkDb") + self.connect("destroy", self.do_quit) + self.connect("delete_event", self.do_quit) + + self.box = GtkVBox() + self.add(self.box) + self.box.show() + + toolbar = GtkToolbar(ORIENTATION_HORIZONTAL, TOOLBAR_BOTH) + toolbar.set_space_size(10) + self.box.pack_start(toolbar, expand=FALSE) + toolbar.show() + + toolbar.append_item("next", "Next statement", None, + GtkPixmap(self, "next.xpm"), self.do_next) + toolbar.append_item("step", "Step into function", None, + GtkPixmap(self, "step.xpm"), self.do_step) + toolbar.append_space() + toolbar.append_item("return", + "Continue execution to end of function", + None, GtkPixmap(self, "return.xpm"), + self.do_return) + toolbar.append_space() + toolbar.append_item("continue", + "Continue execution to next break point", + None, GtkPixmap(self, "continue.xpm"), + self.do_continue) + toolbar.append_item("break", + "toggle break point at selected line",None, + GtkPixmap(self,"break.xpm"),self.do_break) + toolbar.append_space() + toolbar.append_item("edit", + "edit the value of the selected variable", + None, GtkPixmap(self, "edit.xpm"), + self.do_edit) + toolbar.append_item("run", + "Execute some code in the current stack context", + None, GtkPixmap(self, "run.xpm"), + self.do_run) + toolbar.append_space() + toolbar.append_item("quit", "Quit the debugger", None, + GtkPixmap(self, "quit.xpm"), self.do_quit) + + sep = GtkHSeparator() + self.box.pack_start(sep, expand=FALSE) + sep.show() + + vpane = GtkVPaned() + self.box.pack_start(vpane) + vpane.show() + + hpane = GtkHPaned() + vpane.add1(hpane) + hpane.show() + + self.stackdisp = GtkCList(1, ['Stack Frame']) + self.stackdisp.connect("select_row", self.update_curstack) + self.stackdisp.set_usize(280, 125) + self.stackdisp.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) + self.stackdisp.set_selection_mode(SELECTION_BROWSE) + self.stackdisp.border_width(2) + hpane.add1(self.stackdisp) + self.stackdisp.show() + + self.vardisp = GtkCList(3, ['local var', 'type', 'value']) + self.vardisp.connect("select_row", self.update_selectedvar) + self.vardisp.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) + self.vardisp.set_selection_mode(SELECTION_BROWSE) + self.vardisp.set_column_width(0, 75) + self.vardisp.set_column_width(1, 30) + self.vardisp.border_width(2) + hpane.add2(self.vardisp) + self.vardisp.show() + self.vardisp.selected = 0 + self.vardisp.varnames = [] + + self.filedisp = GtkCList(3, ['break', 'lineno', 'line']) + self.minibreak = GtkPixmap(self, "minibreak.xpm") + # This is giving a warning -- probably a bug in GTK + self.filedisp.set_column_widget(0, self.minibreak) + self.filedisp.column_titles_show() + self.filedisp.set_column_width(0, 14) + self.filedisp.set_column_width(1, 35) + self.filedisp.connect("select_row", self.update_selection) + self.filedisp.set_column_justification(1, JUSTIFY_RIGHT) + self.filedisp.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) + self.filedisp.set_selection_mode(SELECTION_BROWSE) + self.filedisp.border_width(2) + self.filedisp.set_usize(600, 200) + vpane.add2(self.filedisp) + self.filedisp.show() + + separator = GtkHSeparator() + self.box.pack_start(separator, expand=FALSE) + separator.show() + + align = GtkAlignment(0.0, 0.5, 0.0, 0.0) + self.box.pack_start(align, expand=FALSE) + align.show() + self.status = GtkLabel() + self.status.set_padding(4, 1) + align.add(self.status) + self.status.show() + + self.filename = None + self.selected = 0 + self.blockupdate = 0 + + def set_status(self, str): + self.status.set(str) + + def update_selection(self, clist, r, c, event): + if self.blockupdate: return + self.selected = r + 1 + if c == 0: # break point column + self.do_break() + + def update_curstack(self, clist, r, c, event): + if self.blockupdate: return + self.curindex = r + self.curframe = self.stack[self.curindex][0] + self.lineno = None + self.update_code_listing() + self.update_var_listing() + + def update_selectedvar(self, clist, r, c, event): + self.vardisp.selected = r + + def set_quit(self): + self.hide() + self.destroy() + bdb.Bdb.set_quit(self) + + def reset(self): + bdb.Bdb.reset(self) + self.forget() + def forget(self): + self.lineno = None + self.stack = [] + self.curindex = 0 + self.curframe = None + def setup(self, f, t): + self.forget() + self.stack, self.curindex = self.get_stack(f, t) + self.curframe = self.stack[self.curindex][0] + + # interaction functions -- overriden from bdb + def user_line(self, frame): + # called when we stop or break at this line + self.interaction(frame, None) + def user_return(self, frame, return_value): + # called when a return trap is set here + frame.f_locals['__return__'] = return_value + if frame.f_code.co_name: + func = frame.f_code.co_name + else: + func = "<lambda>" + self.set_status(func + " rerturned " + repr.repr(return_value)) + self.interaction(frame, None) + def user_exception(self, frame, (exc_type, exc_value, exc_traceback)): + frame.f_locals['__exception__'] = exc_type, exc_value + if type(exc_type) == type(''): + exc_type_name = exc_type + else: exc_type_name = exc_type.__name__ + self.set_status(exc_type_name + ':' + repr.repr(exc_value)) + self.interaction(frame, exc_traceback) + + def interaction(self, frame, traceback): + self.setup(frame, traceback) + self.update_stack_listing(self.curindex) + mainloop() + self.forget() + + def update_stack_listing(self, curindex): + self.stackdisp.freeze() + self.blockupdate = 1 + self.stackdisp.clear() + for i in range(len(self.stack)): + frame_lineno = self.stack[i] + row = self.format_stack_entry(frame_lineno, "##!##") + row = string.split(row, "##!##")[0] + self.stackdisp.append([row]) + self.blockupdate = 0 + self.stackdisp.moveto(curindex, 0, 1.0, 0.0) + self.stackdisp.select_row(curindex, 0) + self.stackdisp.thaw() + + def update_var_listing(self): + self.vardisp.freeze() + self.vardisp.clear() + locals = self.curframe.f_locals + self.vardisp.varnames = locals.keys() + self.vardisp.varnames.sort() + for var in self.vardisp.varnames: + row = [var, type(locals[var]).__name__, repr.repr( + locals[var])] + self.vardisp.append(row) + self.vardisp.thaw() + + def update_code_listing(self): + frame = self.curframe + newfile = frame.f_code.co_filename + if newfile != self.filename: + lines = linecache.getlines(newfile) + self.filename = newfile + self.filedisp.freeze() + self.blockupdate = 1 + self.filedisp.clear() + breaks = self.get_file_breaks(newfile) + for line in range(len(lines)): + self.filedisp.append(['', repr.repr(line+1), + lines[line]]) + if line+1 in breaks: + self.filedisp.set_pixmap(line, 0, + self.minibreak) + self.blockupdate = 0 + self.filedisp.thaw() + self.selected = frame.f_lineno + lineno = self.selected + self.filedisp.moveto(lineno - 1, 2) + self.filedisp.select_row(lineno - 1, 2) + + def do_next(self, _b=None): + self.set_next(self.curframe) + mainquit() + def do_step(self, _b=None): + self.set_step() + mainquit() + def do_return(self, _b=None): + self.set_return(self.curframe) + mainquit() + def do_continue(self, _b=None): + self.set_continue() + mainquit() + def do_quit(self, _b=None, _e=None): + self.set_quit() + mainquit() + def do_break(self, _b=None): + breaks = self.get_file_breaks(self.filename) + if self.selected in breaks: + err = self.clear_break(self.filename, self.selected) + if err: + self.set_status(err) + return + self.filedisp.set_text(self.selected-1, 0, ' ') + else: + err = self.set_break(self.filename, self.selected) + if err: + self.set_status(err) + return + self.filedisp.set_pixmap(self.selected-1, 0, + self.minibreak) + def do_run(self, _b=None): + line = GtkExtra.input_box("Execute Code", + "Enter code to execute:") + if line == None: return + locals = self.curframe.f_locals + globals = self.curframe.f_globals + globals['__privileged__'] = 1 + try: + code = compile(line + '\n', '<stdin>', 'single') + exec code in globals, locals + except: + if type(sys.exc_type) == type(''): + exc_type_name = sys.exc_type + else: exc_type_name = sys.exc_type.__name__ + self.set_status('*** ' + exc_type_name + ': ' + + str(sys.exc_value)) + return + self.update_var_listing() + + def do_edit(self, _b=None): + locals = self.curframe.f_locals + varname = self.vardisp.varnames[self.vardisp.selected] + val = repr.repr(locals[varname]) + value = GtkExtra.input_box("Edit Variable", + "Enter new value for" + varname + ":", val) + if value == None: return + globals = self.curframe.f_globals + globals['__privileged__'] = 1 + try: + val = eval(value, globals, locals) + self.curframe.f_locals[varname] = val + except: + if type(sys.exc_type) == type(''): + exc_type_name = sys.exc_type + else: exc_type_name = sys.exc_type.__name__ + self.set_status('*** ' + exc_type_name + ': ' + + str(sys.exc_value)) + return + row = self.vardisp.selected + self.vardisp.set_text(row, 1, type(val).__name__) + self.vardisp.set_text(row, 2, repr.repr(val)) + +# this makes up the interface that is compatible with pdb. +def run(statement, globals=None, locals=None): + win = GtkDb() + win.show() + win.run(statement, globals, locals) + +def runeval(expression, globals=None, locals=None): + win = GtkDb() + win.show() + return win.runeval(expression, globals, locals) + +def runcall(*args): + win = GtkDb() + win.show() + return apply(win.runcall, args) + +def set_trace(): + win = GtkDb() + win.show() + win.set_trace() + +def post_mortem(traceback): + win = GtkDb() + win.show() + win.reset() + win.interaction(None, traceback) + +def pm(): + post_mortem(sys.last_traceback) + +if __name__ == '__main__': + import os + if not sys.argv[1:]: + print "usage: gtkdb.py scriptfile [args ...]" + sys.exit(2) + filename = sys.argv[1] + del sys.argv[0] # delete gtkdb.py + sys.path.insert(0, os.path.dirname(filename)) + + run('execfile("' + filename + '")', {'__name__': '__main__'}) diff --git a/examples/ide/gtkprof.py b/examples/ide/gtkprof.py new file mode 100755 index 00000000..c005e166 --- /dev/null +++ b/examples/ide/gtkprof.py @@ -0,0 +1,133 @@ +#!/usr/bin/env python + +import profile, pstats, fpformat + +from gtk import * + +class PStatWindow(GtkWindow): + def __init__(self, stats): + GtkWindow.__init__(self) + self.connect("destroy", self.quit) + self.connect("delete_event", self.quit) + self.set_title("Profile Statistics") + + self.stats = stats + + box1 = GtkVBox() + self.add(box1) + box1.show() + + text = `stats.total_calls` + " function calls " + if stats.total_calls != stats.prim_calls: + text = text + "( " + `stats.prim_calls` + \ + " primitive calls) " + text = text + "in " + fpformat.fix(stats.total_tt, 3) + \ + " CPU seconds" + label = GtkLabel(text) + label.set_padding(2, 2) + box1.pack_start(label, expand=FALSE) + label.show() + + titles = ['ncalls', 'tottime', 'percall', 'cumtime', + 'percall', 'filename:lineno(function)'] + clist = GtkCList(len(titles), titles) + clist.set_column_width(0, 40) + clist.set_column_width(1, 50) + clist.set_column_width(2, 50) + clist.set_column_width(3, 50) + clist.set_column_width(4, 50) + clist.set_usize(500, 200) + clist.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) + self.clist = clist + clist.border_width(10) + box1.pack_start(clist) + clist.show() + + for i in range(5): + clist.set_column_justification(i, JUSTIFY_RIGHT) + + self.insert_stats() + + separator = GtkHSeparator() + box1.pack_start(separator, expand=FALSE) + separator.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2, expand=FALSE) + box2.show() + + button = GtkButton("close") + button.connect("clicked", self.quit) + self.close_button = button + box2.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + + def quit(self, *args): + self.hide() + self.destroy() + mainquit() + + def get_stats_list(self): + if self.stats.fcn_list: + return self.stats.fcn_list[:] + else: + return sekf.stats.stats.keys() + + def insert_stats(self): + list = self.get_stats_list() + if list: + row = [None] * 6 + self.clist.clear() + self.clist.freeze() + for func in list: + cc,nc,tt,ct,callers = self.stats.stats[func] + row[0] = `nc` + if nc != cc: + row[0] = row[0] + '/' + `cc` + row[1] = fpformat.fix(tt, 3) + if nc == 0: + row[2] = '' + else: + row[2] = fpformat.fix(tt/nc, 3) + row[3] = fpformat.fix(ct, 3) + if cc == 0: + row[4] = '' + else: + row[4] = fpformat.fix(ct/cc, 3) + file,line,name = func + row[5] = file + ":" + `line` + "(" + name + \ + ")" + self.clist.append(row) + self.clist.thaw() + + +def run(cmd): + prof = profile.Profile() + try: + stats = pstats.Stats(prof.run(cmd)) + except SystemExit: + pass + stats.strip_dirs().sort_stats("time", "module", "name") + win = PStatWindow(stats) + win.show() + mainloop() + +def run_file(file): + return run('execfile("' + file + '")') + + +if __name__ == '__main__': + import sys, os + if not sys.argv[1:]: + print "usage: gtkprof.py scriptfile [args ...]" + sys.exit(2) + filename = sys.argv[1] + del sys.argv[0] + sys.path.insert(0, os.path.dirname(filename)) + + run_file(filename) + + diff --git a/examples/ide/minibreak.xpm b/examples/ide/minibreak.xpm new file mode 100644 index 00000000..6fd11e7c --- /dev/null +++ b/examples/ide/minibreak.xpm @@ -0,0 +1,19 @@ +/* XPM */ +static char * minibreak_xpm[] = { +"12 12 4 1", +" c None", +". c #000000", +"X c #FF0000", +"o c #FFFFFF", +" ...... ", +" .oooooo. ", +" .ooXXXXoo. ", +".ooXXXXXXoo.", +".oXXXXXXXXo.", +".oXXXXXXXXo.", +".oXXXXXXXXo.", +".oXXXXXXXXo.", +".ooXXXXXXoo.", +" .ooXXXXoo. ", +" .oooooo. ", +" ...... "}; diff --git a/examples/ide/next.xpm b/examples/ide/next.xpm new file mode 100644 index 00000000..6c0cf361 --- /dev/null +++ b/examples/ide/next.xpm @@ -0,0 +1,32 @@ +/* XPM */ +static char *next[] = { +/* width height num_colors chars_per_pixel */ +" 20 22 2 1", +/* colors */ +". c None", +"# c #000000", +/* pixels */ +"....................", +"....................", +"......#.............", +"......##............", +"......###...........", +"......####..........", +"......#####.........", +"......######........", +"......#######.......", +"......########......", +"......#########.....", +"......#########.....", +"......########......", +"......#######.......", +"......######........", +"......#####.........", +"......####..........", +"......###...........", +"......##............", +"......#.............", +"....................", +"...................." +}; + diff --git a/examples/ide/pyide.py b/examples/ide/pyide.py new file mode 100755 index 00000000..545ec4cd --- /dev/null +++ b/examples/ide/pyide.py @@ -0,0 +1,180 @@ +#!/usr/bin/env python + +from gtk import * +import GtkExtra +import gtkcons, gtkdb, gtkprof, edit +import os, sys, string + +# select a good VT emulator +for vt in 'Eterm', 'nxterm', 'xterm-color', 'xterm', 'rxvt': + for dirname in string.split(os.environ['PATH'], os.pathsep): + fullname = os.path.join(dirname, vt) + if os.path.exists(fullname): + VT_CMD = fullname + ' -geometry 80x6 -e ' + break + else: + continue + break +else: + VT_CMD='' # this is not ideal + +class Application(GtkWindow): + def __init__(self): + GtkWindow.__init__(self, WINDOW_TOPLEVEL) + self.connect("destroy", self.quit) + self.connect("delete_event", self.quit) + self.set_title("Python") + self.set_usize(475, 325) + self.main_box = GtkVBox() + self.add(self.main_box) + self.main_box.show() + hdlbox = GtkHandleBox() + self.main_box.pack_start(hdlbox, expand=FALSE) + hdlbox.show() + mf = GtkExtra.MenuFactory() + mf.add_entries([ + ('File/New', '<control>N', self.file_new), + ('File/Open...', '<control>O', self.file_open), + ('File/<separator>', None, None), + ('File/Exit', '<control>Q', self.file_exit), + ('Edit/Copy', '<control>C', self.edit_copy), + ('Edit/Paste', '<control>V', self.edit_paste), + ('Edit/Clear', None, self.edit_clear), + ('Python/Reload Module...', None, self.python_reload), + ('Python/<separator>', None, None), + ('Python/Run...', None, self.python_run), + ('Python/Debug...', None, self.python_debug), + ('Python/Profile...', None, self.python_prof), + ('Help/About...', None, self.help_about), + ]) + self.add_accel_group(mf.accelerator) + hdlbox.add(mf) + mf.show() + self.mf = mf + self.interp = gtkcons.Console( + namespace={'__builtins__': __builtins__, + '__name__': '__main__', + '__doc__': None}, quit_cb=self.quit) + self.main_box.pack_start(self.interp) + self.interp.show() + self.interp.init() + self.editwins = [] + def quit(self, *args): + for win in self.editwins: + if win.chk_save(): return + win.hide() + win.destroy() + mainquit() + + def reload_file(self, fname): + if not os.path.isfile(fname): + GtkExtra.message_box("File Not Found", fname + + " was not found.", ("OK",)) + dir = os.path.dirname(fname) + base = os.path.basename(fname) + if dir not in sys.path: sys.path.insert(0, dir) + if string.lower(base[-3:]) == '.py': base = base[:-3] + elif string.lower(base[-4:]) == '.pyc': base = base[:-4] + if not sys.modules.has_key(base): + self.interp.run('import ' + base) + else: + self.interp.run('import ' + base) + self.interp.run('reload(' + base + ')') + + # execute a python script normally or with the debugger or profiler + def run_script(self, fname): + if not fname or os.path.exists(fname): + GtkExtra.message_box("Run","Invalid filename",("OK",)) + return + args = GtkExtra.input_box("Arguments", + "Enter any command line arguments") + if args == None: return + os.system(VT_CMD+'python "'+fname+'" ' + args + ' &') + def debug_script(self, fname): + if not fname or os.path.exists(fname): + GtkExtra.message_box("Debug", "Invalid filename", + ("OK",)) + return + args = GtkExtra.input_box("Arguments", + "Enter any command line arguments") + if args == None: return + os.system(VT_CMD+'python '+gtkdb.__file__+' "'+fname+'" ' + + args + ' &') + def profile_script(self, fname): + if not fname or not os.ppath.exists(fname): + GtkExtra.message_box("Profile", "Invalid filename", + ("OK",)) + return + args = GtkExtra.input_box("Arguments", + "Enter any command line arguments") + if args == None: return + os.system(VT_CMD+'python '+gtkprof.__file__+' "'+fname+'" ' + + args + ' &') + + def add_py_menu(self, ew): + def run(b=None, ew=ew, app=self): app.run_script(ew.fname) + def dbg(b=None, ew=ew, app=self): app.debug_script(ew.fname) + def prf(b=None, ew=ew, app=self): app.profile_script(ew.fname) + py_menu = GtkExtra.MenuFactory(MENU_FACTORY_MENU) + py_menu.add_entries([ + ('Run...', None, run), + ('Debug...', None, dbg), + ('Profile...', None, prf) + ]) + mi = GtkMenuItem('Python') + ew.mf.insert(mi, 2) + mi.show() + mi.set_submenu(py_menu) + ew.mf.hide() + ew.mf.show() + + def file_new(self, mi=None): + ew = edit.EditWindow(quit_cb=self.rem_editwin) + self.editwins.append(ew) + self.add_py_menu(ew) + ew.show() + ew.set_usize(0,0) + def file_open(self, mi=None): + fname = GtkExtra.file_open_box(modal=FALSE) + if fname: + ew = edit.EditWindow(quit_cb=self.rem_editwin) + ew.load_file(fname) + self.editwins.append(ew) + self.add_py_menu(ew) + ew.show() + ew.set_usize(0,0) + def rem_editwin(self, win=None, event=None): + for i in range(len(self.editwins)): + if self.editwins[i] == win: + del self.editwins[i] + break + def file_exit(self, mi=None): + self.quit() + def edit_copy(self, mi=None): + self.interp.text.copy_clipboard(0) + def edit_paste(self, mi=None): + self.interp.line.paste_clipboard(0) + def edit_clear(self, mi=None): + self.interp.line.delete_selection() + def python_reload(self, mi=None): + print "python_reload" + def python_run(self, mi=None): + fname = GtkExtra.file_sel_box("Run") + if fname: + self.run_script(fname) + def python_debug(self, mi=None): + fname = GtkExtra.file_sel_box("Debug") + if fname: + self.debug_script(fname) + def python_prof(self, mi=None): + fname = GtkExtra.file_sel_box("Profile") + if fname: + self.profile_script(fname) + def help_about(self, mi=None): + print "help_about" + +if __name__ == '__main__': + app = Application() + app.show() + app.set_usize(0,0) + mainloop() diff --git a/examples/ide/quit.xpm b/examples/ide/quit.xpm new file mode 100644 index 00000000..11d0bb01 --- /dev/null +++ b/examples/ide/quit.xpm @@ -0,0 +1,36 @@ +/* XPM */ +static char *quit[] = { +/* width height num_colors chars_per_pixel */ +" 20 22 6 1", +/* colors */ +". c #ffcc33", +"# c None", +"a c #996600", +"b c #666666", +"c c #333333", +"d c #000000", +/* pixels */ +"####################", +"####################", +"####################", +"########d####d######", +"#######dad##dd###dd#", +"#######d.addaad#dad#", +"######da......dda.d#", +"#dddddd..........ad#", +"da...............dc#", +"cda..............dc#", +"#cd..............ad#", +"##d...............ad", +"#da.............addc", +"#d.............ddcc#", +"da.............dc###", +"dddd...........ad###", +"#ccd........adaad###", +"###d..da....dcddd###", +"###dbdcda...c#ccc###", +"###cdc#ccdadc#######", +"####c###ccdc########", +"##########c#########" +}; + diff --git a/examples/ide/return.xpm b/examples/ide/return.xpm new file mode 100644 index 00000000..a908f597 --- /dev/null +++ b/examples/ide/return.xpm @@ -0,0 +1,35 @@ +/* XPM */ +static char *return[] = { +/* width height num_colors chars_per_pixel */ +" 20 22 5 1", +/* colors */ +". c None", +"# c #999999", +"a c #666666", +"b c #333333", +"c c #000000", +/* pixels */ +"....................", +"..............c.....", +"..............cc....", +".........#bcccccc...", +".....#bccccccccccc..", +"..#bccccccccccccccc.", +".acccccccccccccccccc", +"#cccccccccccccccccc.", +"bccccccccccccccccc..", +"ccccccccccccccccc...", +"cccccccccb#...cc....", +"ccccccb#......c.....", +"cccb#..b............", +"cc..bbbbbb..........", +"c.bbbbbbbb.a........", +"bbbbbbbbbbb#........", +".bbbbbbbbb.a........", +"..bbbbbbbbb#........", +"...bbbbbbb.a........", +".....bbbbbb#........", +"........bb.a........", +"...................." +}; + diff --git a/examples/ide/run.xpm b/examples/ide/run.xpm new file mode 100644 index 00000000..fbfb4ed8 --- /dev/null +++ b/examples/ide/run.xpm @@ -0,0 +1,28 @@ +/* XPM */ +static char * run_xpm[] = { +"20 22 3 1", +" c None", +". c #000000", +"X c #C00080", +" ", +" ", +" .... ", +" .XXXX. ", +" .XXXX. ", +" .XXXX. ", +" .XXXX. ", +" .XX. ", +" .XX. ", +" .XX. ", +" .XX. ", +" .. ", +" .. ", +" .. ", +" .. ", +" ", +" .. ", +" .XX. ", +" .XX. ", +" .. ", +" ", +" "}; diff --git a/examples/ide/step.xpm b/examples/ide/step.xpm new file mode 100644 index 00000000..4e5c7bb3 --- /dev/null +++ b/examples/ide/step.xpm @@ -0,0 +1,35 @@ +/* XPM */ +static char *forward[] = { +/* width height num_colors chars_per_pixel */ +" 20 22 5 1", +/* colors */ +". c None", +"# c #999999", +"a c #666666", +"b c #333333", +"c c #000000", +/* pixels */ +"....................", +"........bb.a........", +".....bbbbbb#........", +"...bbbbbbb.a........", +"..bbbbbbbbb#........", +".bbbbbbbbb.a........", +"bbbbbbbbbbb#........", +"c.bbbbbbbb.a........", +"cc..bbbbbb..........", +"cccb#..b............", +"ccccccb#......c.....", +"cccccccccb#...cc....", +"ccccccccccccccccc...", +"bccccccccccccccccc..", +"#cccccccccccccccccc.", +".acccccccccccccccccc", +"..#bccccccccccccccc.", +".....#bccccccccccc..", +".........#bcccccc...", +"..............cc....", +"..............c.....", +"...................." +}; + diff --git a/examples/imlib/.cvsignore b/examples/imlib/.cvsignore new file mode 100644 index 00000000..c2831020 --- /dev/null +++ b/examples/imlib/.cvsignore @@ -0,0 +1,6 @@ +Makefile.in +Makefile +*~ +*.pyc +*.pyo + diff --git a/examples/imlib/view.py b/examples/imlib/view.py new file mode 100755 index 00000000..9817a1f4 --- /dev/null +++ b/examples/imlib/view.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python + +from gtk import * +import GdkImlib + +def close(win, _event=None): + win.hide() + win.destroy() + +def resize(win, event): + im = win.get_data('user_data') + # note that render must be called once before each call to make_pixmap + im.render(event.width, event.height) + pix = win.children()[0] + win.remove(pix) + pix = im.make_pixmap() + pix.show() + win.add(pix) + +def open_img(_b): + file = fs.get_filename() + try: + im = GdkImlib.Image(file) + except RuntimeError: return + win = GtkWindow() + win.connect('destroy', close) + win.connect('delete_event', close) + win.connect('configure_event', resize) + win.set_title(file) + win.set_data('user_data', im) + im.render() + pix = im.make_pixmap() + pix.show() + win.add(pix) + win.show() + +fs = GtkFileSelection() +fs.set_title('Image Viewer') +fs.connect('destroy', mainquit) +fs.connect('delete_event', mainquit) + +label = fs.ok_button.children()[0] +label.set('View') +fs.ok_button.connect('clicked', open_img) + +label = fs.cancel_button.children()[0] +label.set('Quit') +fs.cancel_button.connect('clicked', mainquit) + +fs.show() + +mainloop() diff --git a/examples/neil/.cvsignore b/examples/neil/.cvsignore new file mode 100644 index 00000000..c2831020 --- /dev/null +++ b/examples/neil/.cvsignore @@ -0,0 +1,6 @@ +Makefile.in +Makefile +*~ +*.pyc +*.pyo + diff --git a/examples/neil/README b/examples/neil/README new file mode 100644 index 00000000..071e73a6 --- /dev/null +++ b/examples/neil/README @@ -0,0 +1,4 @@ +The examples in this directory were originally sent in by Neil Schemenauer +<nascheme@acs.ucalgary.ca>, but have since had small modifications and +additions made by me (such as change over to using GtkItemFactory). + diff --git a/examples/neil/TAppli.py b/examples/neil/TAppli.py new file mode 100755 index 00000000..1ab9e771 --- /dev/null +++ b/examples/neil/TAppli.py @@ -0,0 +1,142 @@ +#!/usr/bin/env python +# +# Test the GtkMenuBar, GtkMenu and GtkMenuItem, GtkList and +# GtkListItem, GtkFileSelection objects +# + +import sys +import time +from gtk import * + +class Application: + def __init__(self, argv): + self.w_window=GtkWindow() + self.w_window.set_title("Test application") + self.w_window.border_width(10) + self.w_vbox=GtkVBox() + + self.init_menu() + self.init_list() + self.init_button() + + self.w_window.add(self.w_vbox) + self.w_vbox.show() + self.w_window.show() + + self.idlecount=0 + idle_add(self.idle) + + def mainloop(self): + mainloop() + + def quit(self, mi): + mainquit() + + def doit(self, button): + z=[] + for x in range(10,20): + item=GtkListItem(label="line %d" % x) + item.show() + z.append(item) + self.w_listbox.append_items(z) + + + def init_menu(self): + ag = GtkAccelGroup() + itemf = GtkItemFactory(GtkMenuBar, "<main>", ag) + self.w_window.add_accel_group(ag) + file_cb = self.process_file + edit_cb = self.process_edit + itemf.create_items([ + ('/_File', None, None, 0, '<Branch>'), + ('/_File/_New', '<control>N', file_cb, 1, ''), + ('/_File/_Open', '<control>O', file_cb, 2, ''), + ('/_File/_Save', '<control>S', file_cb, 3, ''), + ('/_File/Save _As', None, file_cb, 4, ''), + ('/_File/_Close', None, file_cb, 5, ''), + ('/_File/sep1', None, file_cb, 0, '<Separator>'), + ('/_File/E_xit', '<alt>F4', file_cb, 6, ''), + ('/_Edit', None, None, 0, '<Branch>'), + ('/_Edit/C_ut', '<control>X', edit_cb, 1, ''), + ('/_Edit/_Copy', '<control>C', edit_cb, 2, ''), + ('/_Edit/_Paste', '<control>V', edit_cb, 3, '') + ]) + self.w_menubar = itemf.get_widget('<main>') + self.w_vbox.pack_start(self.w_menubar, expand=FALSE) + self.w_menubar.show() + + def init_list(self): + c=GtkScrolledWindow() + c.set_usize(250,200) + self.w_listbox=GtkList() + self.w_listbox.set_selection_mode(SELECTION_MULTIPLE) + c.add(self.w_listbox) + self.w_vbox.pack_start(c) + + for x in range(0,10): + item=GtkListItem(label="line %d" % x) + item.show() + self.w_listbox.add(item) + self.w_listbox.show() + c.show() + + def init_button(self): + t = GtkTable(rows=1, cols=2, homogeneous=TRUE) + b1 = GtkButton('Do it!') + b1.connect('clicked', self.doit) + b2 = GtkButton('Quit') + b2.connect('clicked', self.quit) + t.attach(b1, 0, 1, 0, 1, yoptions=0, xpadding=2, ypadding=2) + t.attach(b2, 1, 2, 0, 1, yoptions=0, xpadding=2, ypadding=2) + + self.w_vbox.pack_end(t, expand=FALSE) + + b1.show() + b2.show() + t.show() + + def process_file(self, action, widget): + if action == 0: print "unknown" + elif action == 1: print "File:New" + elif action == 2: print "File:Open" + elif action == 3: print "File:Save" + elif action == 4: print "File:Save As" + elif action == 5: print "File:Close" + elif action == 6: + print "File:Exit" + mainquit() + def process_edit(self, action, widget): + if action == 0: print "Edit:<unknown>" + elif action == 1: print "Edit:Cut" + elif action == 2: print "Edit:Copy" + elif action == 3: print "Edit:Paste" + + def idle(self): + self.idlecount = self.idlecount + 1 + if(self.idlecount % 1000 == 0): + print "Idle:", self.idlecount + # if measuring time + ##self.quit() + return TRUE + + +if(__name__=="__main__"): + use_defaults=1 + for arg in sys.argv: + if(arg=="-d"): + import pdb + pdb.set_trace() + + if(arg=="-n"): + use_defaults=0 + + start_time = time.time() + +# if(use_defaults==1): +# gtk.rc_parse("defaults.rc") + + app=Application(sys.argv) + app.mainloop() + the_time = time.time() - start_time + print "Application ran %.2f s." % the_time + diff --git a/examples/neil/TAppli2.py b/examples/neil/TAppli2.py new file mode 100755 index 00000000..5fa56d84 --- /dev/null +++ b/examples/neil/TAppli2.py @@ -0,0 +1,129 @@ +#!/usr/bin/env python +# +# Test of gtk.Text widget. +# + +import sys +import time +from gtk import * +import GtkExtra + +class Application: + def __init__(self, argv): + self.w_window=GtkWindow() + self.w_window.set_title("Test application") + self.w_window.border_width(10) + self.w_vbox=GtkVBox() + + self.init_menu() + self.init_text() + + self.w_window.add(self.w_vbox) + self.w_vbox.show() + self.w_window.show() + + def mainloop(self): + mainloop() + + def init_menu(self): + ag = GtkAccelGroup() + itemf = GtkItemFactory(GtkMenuBar, "<main>", ag) + self.w_window.add_accel_group(ag) + file_cb = self.process_file + edit_cb = self.process_edit + itemf.create_items([ + ('/_File', None, None, 0, '<Branch>'), + ('/_File/_New', '<control>N', file_cb, 1, ''), + ('/_File/_Open', '<control>O', file_cb, 2, ''), + ('/_File/_Save', '<control>S', file_cb, 3, ''), + ('/_File/Save _As', None, file_cb, 4, ''), + ('/_File/_Close', None, file_cb, 5, ''), + ('/_File/sep1', None, file_cb, 0, '<Separator>'), + ('/_File/E_xit', '<alt>F4', file_cb, 6, ''), + ('/_Edit', None, None, 0, '<Branch>'), + ('/_Edit/C_ut', '<control>X', edit_cb, 1, ''), + ('/_Edit/_Copy', '<control>C', edit_cb, 2, ''), + ('/_Edit/_Paste', '<control>V', edit_cb, 3, '') + ]) + self.w_menubar = itemf.get_widget('<main>') + self.w_vbox.pack_start(self.w_menubar, expand=FALSE) + self.w_menubar.show() + + def init_text(self): + self.w_table=GtkTable(2,2,0) + self.w_table.show() + + self.w_text=GtkText() + self.w_text.set_usize(350,250) + ## Note: editable text is disable in gtk+-971109 + self.w_text.set_editable(0) + self.w_table.attach(self.w_text,0,1,0,1,xpadding=1,ypadding=1) + self.w_text.show() + + self.w_hscrollbar=GtkHScrollbar(self.w_text.get_hadjustment()) + self.w_table.attach(self.w_hscrollbar,0,1,1,2,yoptions=FILL) + self.w_hscrollbar.show() + + self.w_vscrollbar=GtkVScrollbar(self.w_text.get_vadjustment()) + self.w_table.attach(self.w_vscrollbar,1,2,0,1,xoptions=FILL) + self.w_vscrollbar.show() + + self.w_vbox.pack_start(self.w_table) + + def process_file(self, action, widget): + if action == 0: print "File:<unknown>" + elif action == 1: + print "File:New" + self.w_text.freeze() + self.w_text.set_point(0) + self.w_text.forward_delete(self.w_text.get_length()) + self.w_text.insert_defaults("Hello") + self.w_text.thaw() + #self.w_text.queueDraw() + elif action == 2: + print "File:Open" + fname = GtkExtra.file_open_box(modal=FALSE) + if fname: + try: + f=open(fname, "r") + except IOError: + return + self.w_text.freeze() + while TRUE: + line = f.readline() + if line == "": + break + self.w_text.insert_defaults(line) + self.w_text.thaw() + elif action == 3: + print "File:Save" + elif action == 4: + print "File:Save As" + print GtkExtra.file_save_box(modal=FALSE), "chosen" + elif action == 5: + print "File:Close" + elif action == 6: + print "File:Exit" + mainquit() + def process_edit(self, action, widget): + if action == 0: print "Edit:<unknown>" + elif action == 1: print "Edit:Cut" + elif action == 2: print "Edit:Copy" + elif action == 3: print "Edit:Paste" + +if __name__ == "__main__": + use_defaults=0 + for arg in sys.argv: + if arg == "-d": + import pdb + pdb.set_trace() + + if arg == "-n": + use_defaults=0 + + if use_defaults == 1: + gtk.rc_parse("defaults.rc") + + app=Application(sys.argv) + app.mainloop() + diff --git a/examples/neil/TAppli3.py b/examples/neil/TAppli3.py new file mode 100755 index 00000000..08433448 --- /dev/null +++ b/examples/neil/TAppli3.py @@ -0,0 +1,141 @@ +#!/usr/bin/env python +# +# Tests of pygtk +# + +import sys +from gtk import * +import GtkExtra + +class Application: + def __init__(self, argv): + self.w_window=GtkWindow(title="Test Application") + self.w_window.border_width(10) + self.w_vbox=GtkVBox() + + self.init_menu() + self.init_text() + + self.w_window.add(self.w_vbox) + self.w_vbox.show() + self.w_window.show() + + def mainloop(self): + mainloop() + + def init_menu(self): + ag = GtkAccelGroup() + itemf = GtkItemFactory(GtkMenuBar, "<main>", ag) + self.w_window.add_accel_group(ag) + file_cb = self.process_file + edit_cb = self.process_edit + itemf.create_items([ + ('/_File', None, None, 0, '<Branch>'), + ('/_File/_New', '<control>N', file_cb, 1, ''), + ('/_File/_Open', '<control>O', file_cb, 2, ''), + ('/_File/_Save', '<control>S', file_cb, 3, ''), + ('/_File/Save _As', None, file_cb, 4, ''), + ('/_File/_Close', None, file_cb, 5, ''), + ('/_File/sep1', None, file_cb, 0, '<Separator>'), + ('/_File/E_xit', '<alt>F4', file_cb, 6, ''), + ('/_Edit', None, None, 0, '<Branch>'), + ('/_Edit/C_ut', '<control>X', edit_cb, 1, ''), + ('/_Edit/_Copy', '<control>C', edit_cb, 2, ''), + ('/_Edit/_Paste', '<control>V', edit_cb, 3, '') + ]) + self.w_menubar = itemf.get_widget('<main>') + self.w_vbox.pack_start(self.w_menubar, expand=FALSE) + self.w_menubar.show() + + def init_text(self): + self.w_table=GtkTable(2,2,0) + self.w_table.show() + + self.w_text=GtkText() + self.w_text.set_usize(350,250) + ## Note: editable text is disable in gtk+-971109 + self.w_text.set_editable(1) + self.w_table.attach(self.w_text,0,1,0,1,xpadding=1,ypadding=1) + self.w_text.show() + + self.w_hscrollbar=GtkHScrollbar(self.w_text.get_hadjustment()) + self.w_table.attach(self.w_hscrollbar,0,1,1,2,yoptions=FILL) + self.w_hscrollbar.show() + + self.w_vscrollbar=GtkVScrollbar(self.w_text.get_vadjustment()) + self.w_table.attach(self.w_vscrollbar,1,2,0,1,xoptions=FILL) + self.w_vscrollbar.show() + + self.w_vbox.pack_start(self.w_table) + + def process_file(self, action, widget): + if action == 0: print "File:<unknown>" + elif action == 1: + print "File:New" + self.w_text.freeze() + self.w_text.set_point(0) + self.w_text.insert_defaults("*new file*") + self.w_text.thaw() + #self.w_text.queueDraw() + elif action == 2: + print "File:Open" + fname = GtkExtra.file_open_box(modal=FALSE) + if fname: + try: + f=open(fname, "r") + except IOError: + return + self.w_text.freeze() + while TRUE: + line = f.readline() + if line == "": + break + self.w_text.insert_defaults(line) + self.w_text.thaw() + elif action == 3: + print "File:Save" + GtkExtra.message_box("Test Application", + "Not implemented", + pixmap='bomb.xpm') + elif action == 4: + print "File:Save As" + print GtkExtra.file_save_box(modal=FALSE), "chosen" + elif action == 5: + print "File:Close" + elif action == 6: + print "File:Exit" + mainquit() + + def process_edit(self, action, widget): + if action == 0: print "Edit:<unknown>" + elif action == 1: + print "Edit:Cut" + self.w_text.cut_clipboard(0) + elif action == 2: + print "Edit:Copy" + self.w_text.copy_clipboard(0) + elif action == 3: + print "Edit:Paste" + self.w_text.paste_clipboard(0) + + def process_character(self, *args): + print "process_character" + def process_button(self, *args): + print "process_button" + +if(__name__=="__main__"): + use_defaults=1 + for arg in sys.argv: + if(arg=="-d"): + import pdb + pdb.set_trace() + + if(arg=="-n"): + use_defaults=0 + +# if(use_defaults==1): +# Gtkrc_parse("defaults.rc") + + app=Application(sys.argv) + app.mainloop() + diff --git a/examples/neil/TAppli4.py b/examples/neil/TAppli4.py new file mode 100755 index 00000000..0c45a653 --- /dev/null +++ b/examples/neil/TAppli4.py @@ -0,0 +1,126 @@ +#!/usr/bin/env python +# +# Tests of python-Gtk +# + +import sys +from gtk import * +import GtkExtra + +class Application: + def __init__(self, argv): + self.w_window=GtkWindow(title="Test Application") + self.w_window.border_width(10) + self.w_vbox=GtkVBox() + + self.init_menu() + self.init_canvas() + + self.w_window.add(self.w_vbox) + self.w_vbox.show() + self.w_window.show() + + def mainloop(self): + mainloop() + + def init_menu(self): + ag = GtkAccelGroup() + itemf = GtkItemFactory(GtkMenuBar, "<main>", ag) + self.w_window.add_accel_group(ag) + file_cb = self.process_file + edit_cb = self.process_edit + help_cb = self.process_help + itemf.create_items([ + ('/_File', None, None, 0, '<Branch>'), + ('/_File/_New', '<control>N', file_cb, 1, ''), + ('/_File/_Open', '<control>O', file_cb, 2, ''), + ('/_File/_Save', '<control>S', file_cb, 3, ''), + ('/_File/Save _As', None, file_cb, 4, ''), + ('/_File/_Close', None, file_cb, 5, ''), + ('/_File/sep1', None, file_cb, 0, '<Separator>'), + ('/_File/E_xit', '<alt>F4', file_cb, 6, ''), + ('/_Edit', None, None, 0, '<Branch>'), + ('/_Edit/C_ut', '<control>X', edit_cb, 1, ''), + ('/_Edit/_Copy', '<control>C', edit_cb, 2, ''), + ('/_Edit/_Paste', '<control>V', edit_cb, 3, ''), + ('/_Help', None, None, 0, '<LastBranch>'), + ('/_Help/_About', '<control>A', help_cb, 1, '') + ]) + self.w_menubar = itemf.get_widget('<main>') + self.w_vbox.pack_start(self.w_menubar, expand=FALSE) + self.w_menubar.show() + + def init_canvas(self): + self.w_canvas=GtkDrawingArea() + self.w_canvas.size(350,250) + self.w_canvas.show() + self.w_vbox.pack_start(self.w_canvas) + + self.w_canvas.connect("button_press_event", self.process_button) + self.w_canvas.connect("motion_notify_event", self.process_motion) + self.w_canvas.connect("key_press_event", self.process_key) + self.w_canvas.set_events(GDK.BUTTON_PRESS_MASK | + GDK.POINTER_MOTION_MASK | + GDK.POINTER_MOTION_HINT_MASK | + GDK.KEY_PRESS_MASK) + + def process_file(self, action, widget): + if action == 0: print "File:<unknwon>" + elif action == 1: + print "File:New" + elif action == 2: + print "File:Open" + print GtkExtra.file_open_box(modal=FALSE), "chosen" + elif action == 3: + print "FileSave" + dlg=GtkExtra.message_box("Test Application", + "Not implemented", + ("OK",), pixmap='bomb.xpm') + elif action == 4: + print "File:Save As" + print GtkExtra.file_save_box(modal=FALSE), "chosen" + elif action == 5: + print "File:Close" + elif action == 6: + print "File:Exit" + mainquit() + def process_edit(self, action, widget): + if action == 0: print "Edit:<unknown>" + elif action == 1: print "Edit:Cut" + elif action == 2: print "Edit:Copy" + elif action == 3: print "Edit:Paste" + + def process_help(self, action, widget): + dlg=GtkExtra.message_box("Test Application", + "Test Application for Python-Gtk.\n" + + "This is free software.\n" + + "This application tests mouse and " + + "key press events.", ("OK",), + pixmap='question.xpm') + + def process_button(self, win, event): + print event, "b =", event.button, "x =", event.x, "y =", event.y + + def process_motion(self, win, event): + print event, "is_hint =", event.is_hint, "x =", event.x, "y =", event.y + + def process_key(self, win, event): + print event, "keyval =", event.keyval, "state =", event.state + + +if(__name__=="__main__"): + use_defaults=1 + for arg in sys.argv: + if(arg=="-d"): + import pdb + pdb.set_trace() + + if(arg=="-n"): + use_defaults=0 + +# if(use_defaults==1): +# rc_parse("defaults.rc") + + app=Application(sys.argv) + app.mainloop() + diff --git a/examples/neil/TAppli5.py b/examples/neil/TAppli5.py new file mode 100755 index 00000000..1402e2a9 --- /dev/null +++ b/examples/neil/TAppli5.py @@ -0,0 +1,188 @@ +#!/usr/bin/env python +# +# Tests of python-gtk. +# + +import sys +from gtk import * +import GtkExtra + +class Application: + def __init__(self, argv): + + # hardcoded font - maybe not on every server ? + self.medium_fonts= [ + "lucidasanstypewriter-10", + "lucidasanstypewriter-12", + "lucidasanstypewriter-14", + "lucidasanstypewriter-18", + "lucidasanstypewriter-24" + ] + self.bold_fonts= [ + "lucidasanstypewriter-bold-10", + "lucidasanstypewriter-bold-12", + "lucidasanstypewriter-bold-14", + "lucidasanstypewriter-bold-18", + "lucidasanstypewriter-bold-24" + ] + self.font_type=0 + self.font_index=0 + # dictionary of loaded fonts + self.fonts={} + + self.w_window=GtkWindow() + self.w_window.set_title("Test application") + self.w_window.border_width(10) + self.w_vbox=GtkVBox() + + self.init_menu() + self.init_text() + + self.w_window.add(self.w_vbox) + self.w_vbox.show() + self.w_window.show() + + def mainloop(self): + mainloop() + + def init_menu(self): + ag = GtkAccelGroup() + itemf = GtkItemFactory(GtkMenuBar, "<main>", ag) + self.w_window.add_accel_group(ag) + file_cb = self.process_file + edit_cb = self.process_edit + help_cb = self.process_help + itemf.create_items([ + ('/_File', None, None, 0, '<Branch>'), + ('/_File/_New', '<control>N', file_cb, 1, ''), + ('/_File/_Open', '<control>O', file_cb, 2, ''), + ('/_File/_Save', '<control>S', file_cb, 3, ''), + ('/_File/Save _As', None, file_cb, 4, ''), + ('/_File/_Close', None, file_cb, 5, ''), + ('/_File/sep1', None, file_cb, 0, '<Separator>'), + ('/_File/E_xit', '<alt>F4', file_cb, 6, ''), + ('/_Edit', None, None, 0, '<Branch>'), + ('/_Edit/C_ut', '<control>X', edit_cb, 1, ''), + ('/_Edit/_Copy', '<control>C', edit_cb, 2, ''), + ('/_Edit/_Paste', '<control>V', edit_cb, 3, ''), + ('/_Help', None, None, 0, '<LastBranch>'), + ('/_Help/_About', '<control>A', help_cb, 1, '') + ]) + self.w_menubar = itemf.get_widget('<main>') + self.w_vbox.pack_start(self.w_menubar, expand=FALSE) + self.w_menubar.show() + + def init_text(self): + self.w_table=GtkTable(2,2,0) + self.w_table.show() + + self.w_text=GtkText() + self.w_text.set_usize(350,250) + ## Note: editable text is disable in gtk+-971109 + self.w_text.set_editable(0) + self.w_table.attach(self.w_text,0,1,0,1,xpadding=1,ypadding=1) + self.w_text.show() + + self.w_text.connect("key_press_event", self.process_key) + self.w_text.set_events(GDK.KEY_PRESS_MASK) + + self.w_hscrollbar=GtkHScrollbar(self.w_text.get_hadjustment()) + self.w_table.attach(self.w_hscrollbar,0,1,1,2, + yoptions=FILL) + self.w_hscrollbar.show() + + self.w_vscrollbar=GtkVScrollbar(self.w_text.get_vadjustment()) + self.w_table.attach(self.w_vscrollbar,1,2,0,1, + xoptions=FILL) + self.w_vscrollbar.show() + + self.w_vbox.pack_start(self.w_table) + + def process_file(self, action, widget): + if action == 0: print "File:<unknown>" + elif action == 1: + print "File:New" + self.w_text.freeze() + self.w_text.set_point(0) + self.w_text.insert_defaults("*new file*") + self.w_text.thaw() + #self.w_text.queueDraw() + elif action == 2: + print "File:Open" + print GtkExtra.file_open_box(modal=FALSE), "chosen" + elif action == 3: + print "File:Save" + GtkExtra.message_box("Test Application", + "Not Implemented", + ("OK",), pixmap='bomb.xpm') + elif action == 4: + print "File:Save As" + print GtkExtra.message_box(modal=FALSE), "chosen" + elif action == 5: + print "File:Close" + GtkExtra.message_box("Test Application", + "Not Implemented", + ("OK",), pixmap='bomb.xpm') + elif action == 6: + print "File:Exit" + mainquit() + + def process_edit(self, action, widget): + if action == 0: print "Edit:<unknown>" + elif action == 1: print "Edit:Cut" + elif action == 2: print "Edit:Copy" + elif action == 3: print "Edit:Paste" + + def process_help(self, action, widget): + GtkExtra.message_box("Test Application", + """Test Application for Python-Gtk. + This is free software. + This application tests key press events and text display. + Any entered key (printable character) is displayed on + screen. <F1> toggle medium and bold font. <F2> permits + to change font size. + """, ("OK",), pixmap='question.xpm') + + def process_key(self, win, event): + if(event.keyval>=32 and event.keyval<=256): + if(self.font_type==0): + font=self.medium_fonts[self.font_index] + if(not self.fonts.has_key(font)): + self.fonts[font] = load_font(font) + f=self.fonts[font] + else: + font=self.bold_fonts[self.font_index] + if(not self.fonts.has_key(font)): + self.fonts[font] = load_font(font) + f=self.fonts[font] + self.w_text.freeze() + style = self.w_text.get_style() + self.w_text.insert(f, style.fg[STATE_NORMAL], + style.bg[STATE_NORMAL], + chr(event.keyval)) + self.w_text.thaw() + else: + # hardcoded key interpretation... XXX need some python keysymdef ? + if(event.keyval==65470): + # this is F1 + self.font_type = (self.font_type+1)%2 + elif(event.keyval==65471): + # this is F2 + self.font_index=(self.font_index+1)%len(self.medium_fonts) + +if(__name__=="__main__"): + use_defaults=0 + for arg in sys.argv: + if(arg=="-d"): + import pdb + pdb.set_trace() + + if(arg=="-n"): + use_defaults=0 + + if(use_defaults==1): + gtk.rc_parse("defaults.rc") + + app=Application(sys.argv) + app.mainloop() + diff --git a/examples/neil/bomb.xpm b/examples/neil/bomb.xpm new file mode 100644 index 00000000..a0af5157 --- /dev/null +++ b/examples/neil/bomb.xpm @@ -0,0 +1,47 @@ +/* XPM */ +static char * icl8_11432_xpm[] = { +/* width height ncolors chars_per_pixel */ +"32 32 9 1", +/* colors */ +" s None c None", +"o c #999999", +"O c black", +"+ c #333333", +"@ c #111111", +"# c #FF6666", +"$ c #FEFE00", +"% c #DDDDDD", +"& c #BBBBBB", +/* pixels */ +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" oOoOo ", +" O Oo ", +" o O ", +" O o ", +" +++++ O ", +" +@@@+ o ", +" +@@O@@+ O ", +" ++@OOO@O@++ o # $", +" +@@OOOOOOO@@+ O $ # ", +" +@OOOOOOOOOOO@+ o $ ", +" +@OOOOOO%&oOO@+ O # $ ", +" +@OOOOOOOO%&oOO@+ o ", +" +@OOOOOOOOOOOOO@+ OoO # $ #", +" +@OOOOOOOOO%&oO@+ ", +" +@OOOOOOOOO%&oO@+ $ $ ", +" +@OOOOOOOOO%&oO@+ # # ", +" +@OOOOOOOO%&oOO@+ # ", +" +@OOOOOOOO%&oOO@+ $ $ $", +" +@OOOOOO%&oOO@+ ", +" +@OOOOOOOOOOO@+ # ", +" +@@OOOOOOO@@+ ", +" ++@@@@@@@++ ", +" +++++++ ", +" "}; diff --git a/examples/neil/gtk-logo.xpm b/examples/neil/gtk-logo.xpm new file mode 100644 index 00000000..d0bc8c39 --- /dev/null +++ b/examples/neil/gtk-logo.xpm @@ -0,0 +1,162 @@ +/* XPM */ +static char *magick[] = { +/* columns rows colors chars-per-pixel */ +"107 140 16 1", +" c #06060a", +". c #181922", +"X c #32383c", +"o c #3d73e1", +"O c #3465cb", +"+ c #334fa0", +"@ c #3ce73c", +"# c #34ce38", +"$ c #31a535", +"% c #f44e4c", +"& c #ab323a", +"* c #9668a4", +"= c #fefefc", +"- c #dce0e4", +"; c #aeaabc", +": c #648bc2", +/* pixels */ +"===========================================================================================================", +"===========================================================================================================", +"===========================================================================================================", +"===========================================================================================================", +"===========================================================================================================", +"===========================================================================================================", +"===========================================================================================================", +"===========================================================================================================", +"===========================================================================================================", +"=========================================================;-================================================", +"================================================-*;=====;+O*.;=============================================", +"==============================================-...-==;*++.X.X X;===========================================", +"=============================================;X..+X+X+XXX... .-=========================================", +"===========================================;+XXXXXXX...+.++.. X-=======================================", +"=========================================-XX.XX.........O..oo.. .*======================================", +"=======================================-*. XX. ........+.Ooooo+ . X-====================================", +"======================================-X. .. . ........+OooooooO. X===================================", +"====================================-:..... .. +.....Oooooooooooo+ .;=================================", +"===================================-X .. ...+.....Oooooooooooooooo.. *================================", +"==================================X ... ..OooooooooooooooooooX X===============================", +"===============================-X.. . . ......O++ooooooooooooooooooo+. .-=============================", +"==============================;.. . .....OOOoooooooooooooooooooooOO.. *============================", +"============================-. .....+oOooooooooooooooooooooooooooOX. X-==========================", +"==========================-+. ....+oooooooO++O++.+.++Oooooooooooooo+.. .;=========================", +"=========================;. . ...+Oooo+. ............ ...OoooooooooooO... +========================", +"=======================-X . . .+oOoO....+X+....... . ..+oooooooooO+.. ;======================", +"======================: . . .OOOoo+....... . . ..OOooooooo++. X=====================", +"====================-X ..+OooooX .. ..X . . . .. .XooooooOO+. .;===================", +"===================;. . +Ooooo+. . . . .. . ..OooooooO+. X==================", +"==================. .XOoooooO. . .XOOooOX++......... . Ooooooooo+X .-================", +"================; . ...+ooooooO.. . ..ooooooooooOoo+..... . .oooooooooo+. *===============", +"==============-$ .X++oooooooO. . ..+OooooooooooooooO...... ....OoooooooooooX .-=============", +"=============;. .Oooooooooo+. . .. .OOOooooooooooooooooO .+X. .. +ooooooooooooO. *============", +"====;======-. +oooooooooo+X. .X +oooooooooooooooooooO+.... ..ooooooooooooooX. .-==========", +"====*=====* . .Oooooooooooo.... .+ Xooooooooooooooooooooooo+... ...ooooooooooooooo+ .;=========", +"====X-==; .ooooooooooooO.+. ... ..OooooooooooooooooooooooOoo+. ..OooooooooooooooOo. .*========", +"====X;--$. .OoooooooooooooO.O . .. .oooooooooooooooooooooooooo .. ..oooooooooooooooooo+ +=======", +"====+X.-X ..+oooooooooooooooOO.+ . .OooooooooooooooOoOooooooooO+ ... .+oooooooooooooooooooo. :*====", +"====;XX. ++OoooooooooooooooO..+ . .+ooooooooooooo++ ++OoooooooOooo+X.OoooooooooooooooooooooO X==-=", +"====*X.. ..+oooooooooooooooO+. ..OoooooooooooOX. .+Ooooooooooooooooooooooooooooooooooooo::. X====", +"====;X.. .&.X.X+Oooooooooooooooo+ .++oooooooooo+. ..XOoooooooooooooooooooooooooooooooooooO::X +-===", +"===-;X. ..&%...X+Ooooooooooooooo+. . +OooooooooooO+ ....OoooooooooooooooooooooooooooooOO:XXX.XX.*====", +"====-... .%%& .XOooooooooooooooo . .oooooooooooO.. . ..OOoooooooooooooooooooooooooooo+XX.XX#X *-===", +"====-XX ..%%%&. .X+oooooooooooooo+ . +oooooooooo+. . .X+OoOoooooooooooooooooooooo:+..XX;@$ .;====", +"====-. .%%%%& .+OooooooooooooO . OooooooooooX. ..+.+ooooooooooooooooooooO*X..X#@@@X -=-==", +"====-XX ..%%%%%& .Xooooooooooooo. ... +oooooooOoO+. ...Xoooooooooooooooooo:XX...$@@@@@X .-====", +"====-X.. .%%%%%%&. .X+oooooooooooo. ... .XoooooooooO+ ..+ooooooooooooooooooXX...X##@@@@@. .-====", +"====-X....%%%%%%%%. XXOOoooooooooX .... ..ooooooooOo ..OOooooooooooooooO+X. X#@@@@@@@@. .;====", +"=====X.. &&%%%%%%%%. .X+oooooooooo. ... ..+ooooooooX ..ooooooooooooooo+OX ..$#@@@@@@@@@. -====", +"====-$.. .%%%%%%%%%%. ..+Ooooooooo+ .. .. . ..+OOo+. ..Oooooooooooooo++X. .$#@@@@@@@@@@. .-====", +"=====X. &%%%%%%%%%%%. ..ooooooooo+ .. . .X. .+oooooooooooooXX.. .$#@@@@@@@@@@@# .=====", +"=====.. %%%%%%%%%%%%& ... .oOooooooo. . ..Ooooooooooooo+X. .X#@@@@@@@@@@@@@$. X=====", +"=====$. .%%%%%%%%%%%%%. .. ..XOoooooooO. . .++Oooooooooooo:X.. ..#@@@@@@@@@@@@@@@$ *-====", +"=====X. ..%%%%%%%%%%%%%%&... ..X+ooooooooX. .+OOoooooooooOOX.. .$@@@@@@@@@@@@@@@@@. *=====", +"=====X . .%%%%%%%%%%%%%%&...& .X+ooooooooooX.... .Oooooooooooo+.X. X@@@@@@@@@@@@@@@@@@@@. *-====", +"====-X ..%%%%%%%%%%%%%%%%. &&. .XOooooooooooO+O+...+Ooooooooooo++... . $@@@@@@@@@@@@@@@@@@@@@. *=====", +"=====$ .%%%%%%%%%%%%%%%%%.. &&. XOooooooooooooooooooooooooooOX. ... X#@@@@@@@@@@@@@@@@@@@@@@. ;=====", +"=====X .%%%%%%%%%%%%%%%%%%...&&. +oooooooooooooooooooooooOX..... .X@@@@@@@@@@@@@@@@@@@@@@@@@. -=====", +"====-X .%%%%%%%%%%%%%%%%%%%..&&%&. XooooooooooooooooooooO+..... . .$@@@@@@@@@@@@@@@@@@@@@@@@@# ;=====", +"====-$. . %%%%%%%%%%%%%%%%%%%% .%%%& .Oooooooooooooooooo+....... .X@@@@@@@@@@@@@@@@@@@X.@@@@@#. *-====", +"=====X .%%%%%%%%%%&&%%%%%%%%%. .%%%%X XOooooooooooooO++..XX.. .#@@@@@@@@@@@@@@@@@@@...@@@@@#. +-=====", +"=====X . %%%%%%%%%X &%%%%%%%%%%. %%%%& +oooooooooo. . OX. $#@@@@@@@@@@@@@@@@#X$$..$@@@@@#. *======", +"=====X. .&%%%%%%%%. ..&%%%%%%%%%. .&%%%%. .OooooooooX..X.. X$@@@@@@@@@@@@@@@@@$ .. .@@@@@@$ *-=====", +"====-X. ..&%%%%%%%&. %%%%%%%%%.. &%%%%X. ..+ooooOOoX... $@@@@@@@@@@@@@@@@@@$ ....#@@@@@@$ .;======", +"=====X & &%%%%%%%&. &%%%%%%%.. &%%%%X.. .+o+ooOX.. X##@@@@@@@@@@@@@@@@@#. $#@@@@@@$ ;======", +"====-X. ...%%%%%%%X.. .&%%%%%%& &%%%%&... ..O+$X .$@@@@@@@@@@@@@@@@@@@@X .$@@@@@@@. .-======", +"====-X & &%%%%%%&X.. &%%%%%%. .%%%&&.. ..$ .$@@@@@@@@@@@@@@@@@@@@$ X@@@@@@@@. .-======", +"====-X &..%%%%%%&... .%%%%%%& ..%%%%&&.. ... X##@@@@@@@@@#@@@@@@@@@@@# . @@@@@@@@@. X=======", +"====-X. ..&%%%%%%X... .. . .&&%%%%& .%%%%%.. .@@@#@@@@@@@@@#$..#@@@@@@@@@. $@@@@@@@@#. X=======", +"====-X &. %%%%%%. ... %%%%%&. &%%%.. $@@@@@@@@@@$.... $@@@@@@@@@. .@@@@@@@@@# +=======", +"====-X &..%%%%%%X. . . .%%%&&. &%%X. .$@@@@@@@@$ X$#@@@@@@@$ $@@@@@@@@@$ &-======", +"====-X .&.%%%%%%&.. .&&&&&. &%&X .@@@@@@@$$ .$$#@@@@@@$ $@@@@@@@@@#$ +=======", +"====-X &. %%%%%%%%%& &%&& % . X#@@@@@@$ .$.@@@@@@#. .@@@@@@@@@@@. *=======", +"====-X &&.%%%%%%%%%%%&... &%% &%XX $@@@@@@@... #.#@@@@@. X@@@@@@@@@@@. .;-======", +"====-X. &. &%%%%%%%%%%%& .& .%%%%%... .@@@@@@# . . .$.$@@@@$ $$@@@@@@@@@@@. -=======", +"====-X .&.&%%%%%%%%%%%%&. .%%%%%X& X@@@@@@@. . $..@@@$ .#@#@@@@@@@@@@ .--======", +"====-. && &%%%%%%%%%%%%%& %%%%%.X .@@@@@@#.. $..##$. #@@@@@@@@@@@@# .========", +"====;X .. .%%%%%%%%%%%%%X %%%%%XX .@@@@@@#... #..##$ .@@@@@@@@@@@@@# .-=======", +"====;. .& &%%%%%%%%%%%%%& &%%%%%& $#@@@@@$ . . $..#$. $@@@@@@@@@@@@@$ X========", +"====-X && &%%%%%%%%%%%%%X ....%%%%%X. .@@@@@#$ $$ $$ $@@@@@@@@@@@@@@. *-=======", +"====-X &X.&%%%%%%%%%%%%%. .. &%%%%%X. $#@@@@@. $ $ .@@@@@@@@@@@@@@@. *-=======", +"====-. .& &%%%%%%%%%%%%%X .& .&%%%%%X. $@@@@@@. $. . $@@@@@@@@@@@@@@@. *========", +"====-X &&.&%%%%%%%%%%%%%. &&%X.. &%%%%%... X@@@@@@$ $... $$@@@@@@@@@@@@@@# ;========", +"====-X .& &%%%%%%%%%%%%%. &%%%%%& .%%%%&. .@@@@@# $.. .$@@@@@@@@@@@@@@@$ .--=======", +"=====X && &%%%%%%%%%%%%%. &%%%%%& ..&%%%%.. .@@@@@@. .. $#@@@@@@@@@@@@@@.. .=========", +"====-$ .&..%%%%%%%%%%%%%. &%%%%%%%%%%%%%%X @@@@@#$ ... .#@@@@@@@@@@@@#$ .=========", +"=====. .& &%%%%%%%%%%%%%. .%%%%%%%%%%%%%%%.. #@@@@#. . $@@@@@@@@@@@#. X=========", +"=====X .& &%%%%%%%%%%%%% &%%%%%%%%%%%%%%X @@@@@@. .@@@@@@@@@@#. .X=========", +"=====X. && &%%%%%%%%%%%%%. .%%%%%%%%%%%%%%%X. $@@@@@@.. .... .#@@@@@@@$.. *=========", +"====-$ &.&%%%%%%%%%%%%& .%%%%%%%%%%%%%%%. $@@@@@@. ....... #@@@@@@#.. .*=========", +"=====X & &%%%%%%%%%%%%% &%%%%%%%%%%%%%%%.. $@@@@@@. .$@$ . .@@@@@$ .--========", +"====-X &.&%%%%%%%%%%%%% &%%%%%%%%%%%%%%%. $@@@@@@. #@@@#. #@@#$ .*=========", +"=====X .& &%%%%%%%%%%%%& &%%%%%%%%%%%%%%%.. $@@@@@@.. $#@@@@#. #@#.. X-=========", +"=====. &.&%%%%%%%%%%%%%. %%%%%%%%%%%%%%%%. $@@@@@@. $@@@@@@@@. .##$. X==========", +"=====$ ..%%%%%%%%%%%%%& &%%%%%%%%%%%%%%%.. #@@@@@@. @@@@@@@@@@.. .#@##. +==========", +"=====X ....%%%%%%%%%%%%%& .&%%%%%%%%%%%%%%%. #@@@@@@. #@@@@@@@@@@@#$ $$#@@#. *--X.======", +"=====$ ....%%%%%%%%%%%%%& %%%%%%%%%%%%%%%%. #@@@@@$ .@@@@@@@@@@@@@#$ .@@@@@$. XX *=====", +"====-$ &...%%%%%%%%%%%%%& .%%%%%%%%%%%%%%%%. #@@@@@# @@@@@@@@@@@@@@$$. X@@@@@#$ . .======", +"=====$ ..& %%%%%%%%%%%%%& %%%%%%%%%%%%%%%%. #@@@@@$ .@@@@@@@@@@@@@@@@@@@@@@@@@.. ;======", +"=====; &&..%%%%%%%%%%%%%%X .%%%%%%%%%%%%%%%%. .#@@@@@$ X@@@@@@@@@@@@@@@@@@@@@@@@#$ .X========", +"======X.%.&&%%%%%%%%%%%%%%& .%%%%%%%%%%%%%%%% @@@@@@$ X@@@@@@@@@@@@@@@@@@@@@@@@$ *;*.-======", +"======X &...&%%%%%%%%%%%%%%. .%%%%%%%%%%%%%%%% .@@@@@@$ $@@@@@@@@@@@@@@@@@@@@@@@#. .*. .==-====", +"======;X. ...%%%%%%%%%%%%%%X .%%%%%%%%%%%%%%%% .@@@@@@$ #@@@@@@@@@@@@@@@@@@@@@@$ . ;-======", +"========;.. ....%%%%%%%%%%%%%%. %%%%%%%%%%%%%%%% X@@@@@@ @@@@@@@@@@@@@@@@@@@@@#$ .X X*========", +"========-X .. . .&%%%%%%%%%%%%&&%%%%%%%%%%%%%%%& $#@@@@# ..#@@@@@@@@@@@@@@@@@@@# .*. -==========", +"=========$ ... . &%%%%%%%%%%%%%%%%%%%%%%%%%%%%% X@@@@@@. ..@@@@@@@@@@@@@@@@@@@$. XX X;===========", +"=========XX.XX. &%%%%%%%%%%%%%%%%%%%%%%%%%%%& $@@@@@@$ .#@@@@@@@@@@@@@@@@@#.. X -============", +"=========-X-&XX.. X%%%%%%%%%%%%%%%%%%%%%%%%%%& $@@@@@@$ . X#@@@@@@@@@@@@@@@@@#... .-==============", +"============-XX*X X%%%%%%%%%%%%%%%%%%%%%%%%%& $@@@@@#...#@@@@@@@@@@@@@@@@@@... *================", +"==============$X;*. ..%%%%%%%%%%%%%%%%%%%%%%%%X #@@@@$..@@@@@@@@@@@@@@@@@@@@... .-=================", +"===============*X*$.. .%%%%%%%%%%%%%%%%%%%%%%%& $@@@@$.@@@@@@@@@@@@@@@@@@@X . ;===================", +"================;X&*. . %%%%%%%%%%%%%%%%%%%%%%. @@@@@@@@@@@@@@@@@@@@@@@@#. X-====================", +"==================+$*. &%%%%%%%%%%%%%%%%%%%%. @@@@@@@@@@@@@@@@@@@@@@@$ .-======================", +"==================-*.*... &%%%%%%%%%%%%%%%%%%%. .#@@@@@@@@@@@@@@@@@@@@@. .X========================", +"====================;XX.. .%%%%%%%%%%%%%%%%%%. .#@@@@@@@@@@@@@@@@@@@$ .-=========================", +"=====================-XX. X%%%%%%%%%%%%%%%%% @@@@@@@@@@@@@@@@@@@. *===========================", +"=======================XX .. .%%%%%%%%%%%%%%%&. .@@@@@@@@@@@@@@@@@# X=============================", +"========================*X... .%%%%%%%%%%%%%%& .@@@@@@@@@@@@@@@@. ;==============================", +"=========================-XX... .%%%%%%%%%%%%%& X@@@@@@@@@@@@@@$ X================================", +"===========================*.... .%%%%%%%%%%%%& .@@@@@@@@@@@@#. -=================================", +"============================;... &%%%%%%%%%%X X@@@@@@@@@@@.. X===================================", +"=============================;X.. .+%%%%%%%%%.. $@@@@@@@@@#. .=====================================", +"===============================X.. X%%%%%%%%. $@@@@@@@@. . ;======================================", +"================================;X. ..+%%%%%%%. $@@@@@@#$ X========================================", +"=================================-XX X;%%%%%. $@@@@@@$ . .;=========================================", +"===================================;.. ..*%%%& . $@@@@X.. X===========================================", +"=====================================* X%%%. . #@@.. . ;============================================", +"=====================================-*. .XX&.. $$ . .. X==============================================", +"=======================================$. .X... *==-============================================", +"========================================$.. XX:X +=================================================", +"=========================================X... .*;X *-=-===============================================", +"==========================================;.. . .X;X .*===================================================", +"===========================================-... ..X -====================================================", +"============================================-X. +;======================================================", +"=============================================-. *==-====================================================", +"==============================================$ *========================================================", +"=============================================== X=========================================================", +"===========================================================================================================", +"===========================================================================================================", +"===========================================================================================================" +}; diff --git a/examples/neil/notebook.py b/examples/neil/notebook.py new file mode 100755 index 00000000..5b9704ab --- /dev/null +++ b/examples/neil/notebook.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python + +from gtk import * + +def destroy(args): + window.destroy() + mainquit() + + +window = GtkWindow() +window.connect("destroy", destroy) +window.set_title('Notebook') +window.border_width(0) +window.set_usize(400, 400) + +box1 = GtkVBox() +window.add(box1) +box1.show() + +box2 = GtkVBox(spacing=10) +box2.border_width(10) +box1.pack_start(box2) +box2.show() + +notebook = GtkNotebook() +notebook.set_tab_pos(POS_TOP) +box2.pack_start(notebook) +notebook.show() + +names = ['Background', 'Colors', 'System', 'Setup', 'Samba'] + +for i in range(len(names)): + buffer = names[i] + frame = GtkFrame(buffer) + frame.border_width(10) + frame.set_usize(200, 300) + frame.set_shadow_type(SHADOW_ETCHED_OUT) + frame.show() + + label = GtkLabel(buffer) + frame.add(label) + label.show() + + label = GtkLabel(buffer) + label.set_padding(2, 2) + notebook.append_page(frame, label) + +separator = GtkHSeparator() +box1.pack_start(separator) +separator.show() + +box3 = GtkVBox(spacing=10) +box3.border_width(10) +box1.pack_start(box3) +box3.show() + +button = GtkButton(label='close') +box3.pack_start(button) +button.connect('clicked', destroy) +button.show() + +window.show() +mainloop() diff --git a/examples/neil/question.xpm b/examples/neil/question.xpm new file mode 100644 index 00000000..8cf1e088 --- /dev/null +++ b/examples/neil/question.xpm @@ -0,0 +1,42 @@ +/* XPM */ +static char * question_xpm[] = { +/**/ +"23 33 4 1", +/**/ +" s None c none", +". c black", +"X c yellow", +"O c midnightblue", +" ..... ", +" ..XXXX.. ", +" ..XXX....... ", +" .XXX.......... ", +" .XX... ..... ", +" .XX... ..... ", +" .XX... ..... ", +" .XX.. ..... ", +" .X... .....", +" ..... OOOO .....", +" ... OO OO .....", +" OO .....", +" O .X...", +" .X... ", +" O .X... ", +" O .XX.. ", +" .XX.. ", +" .XX.. ", +" .XX.. ", +" .XX.. ", +" .XX.. ", +" .XX.. ", +" .X... ", +" .X... ", +" .X... ", +" .X... ", +" .. ..... ", +" . . ... ", +" . ", +" . ... ", +" .X... ", +" . .X... ", +" ... "}; diff --git a/examples/simple/.cvsignore b/examples/simple/.cvsignore new file mode 100644 index 00000000..c2831020 --- /dev/null +++ b/examples/simple/.cvsignore @@ -0,0 +1,6 @@ +Makefile.in +Makefile +*~ +*.pyc +*.pyo + diff --git a/examples/simple/README b/examples/simple/README new file mode 100644 index 00000000..9bcb80cc --- /dev/null +++ b/examples/simple/README @@ -0,0 +1,5 @@ +These are some of the simplest examples you can do. They are only intended +to help you see how to use pygtk. The examples ending in 1.py use the low +level C-like interface, while the ones ending in 2.py are translations that +use Gtkinter. + diff --git a/examples/simple/dnd.py b/examples/simple/dnd.py new file mode 100644 index 00000000..f5bf6d75 --- /dev/null +++ b/examples/simple/dnd.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python +from gtk import * + +# a nice easy to read fixed spacing font. +font = load_font("-*-lucidatypewriter-medium-r-*-*-14-*-*-*-*-*-*-*") + +list = "abcdefghijklmnopqrstuvwxyz" + \ + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + \ + "0123456789" + \ + "`~!@#$%^&*()-_=+\|[]{};:'\",.<>/? " +printable = '' +for c in map(chr, range(256)): + if c in list: + printable = printable + c + else: + printable = printable + '.' +del list, c + +def format_line(str): + hexstr = reduce(lambda x, a: x + hex(256+ord(a))[-2:] + ' ', str, '') + if len(hexstr) < 48: + hexstr = (hexstr + ' '*48)[:48] + return hexstr + ' ' + reduce(lambda x, a: x + printable[ord(a)],str,'') + +def format_data(str): + ret = '' + while len(str) > 16: + line = str[:16] + str = str[16:] + ret = ret + format_line(line) + '\n' + if str: ret = ret + format_line(str) + return ret + +def dnd_drop(b, event): + data_type.set(event.data_type) + data.delete_text(0, data.get_length()) + data.insert(font, black, white, format_data(event.data)) + pass + +win = GtkWindow() +win.set_title("Drag to Me") +win.border_width(10) + +t = GtkTable(5,4) +win.add(t) +t.show() + +l = GtkLabel("Data Type") +l.set_justify(JUSTIFY_RIGHT) +t.attach(l, 0,1, 0,1, xoptions=FILL) +l.show() + +data_type = GtkLabel("*None*") +data_type.set_justify(JUSTIFY_LEFT) +t.attach(data_type, 1,2, 0,1) +data_type.show() + +l = GtkLabel("Data") +l.set_justify(JUSTIFY_RIGHT) +t.attach(l, 0,1, 1,2, xoptions=FILL) +l.show() + +data = GtkText() +data.set_usize(600, -1) +style = data.get_style() +white = style.white +black = style.black +t.attach(data, 1,2, 1,2) +data.show() + +win.connect("drop_data_available_event", dnd_drop) +win.dnd_drop_set(TRUE, ['text/plain', 'application/x-color', 'ALL'], FALSE) + +win.connect("destroy", mainquit) +win.show() + +mainloop() diff --git a/examples/simple/hello1.py b/examples/simple/hello1.py new file mode 100755 index 00000000..60b9ab18 --- /dev/null +++ b/examples/simple/hello1.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +# this is a translation of "Hello World III" from the GTK manual, +# using gtkmodule + +from _gtk import * +from GTK import * + +def hello(*args): + print "Hello World" + gtk_widget_destroy(window) + +def destroy(*args): + gtk_widget_hide(window) + gtk_main_quit() + +gtk_init() + +window = gtk_window_new(WINDOW_TOPLEVEL) +gtk_signal_connect(window, "destroy", destroy) +gtk_container_border_width(window, 10) + +button = gtk_button_new_with_label("Hello World") +gtk_signal_connect(button, "clicked", hello) +gtk_container_add(window, button) +gtk_widget_show(button) + +gtk_widget_show(window) + +gtk_main() + + diff --git a/examples/simple/hello2.py b/examples/simple/hello2.py new file mode 100755 index 00000000..b247f523 --- /dev/null +++ b/examples/simple/hello2.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +# this is a translation of "Hello World III" from the GTK manual, +# using gtk.py + +from gtk import * + +def hello(*args): + print "Hello World" + window.destroy() + +def destroy(*args): + window.hide() + mainquit() + +window = GtkWindow(WINDOW_TOPLEVEL) +window.connect("destroy", destroy) +window.border_width(10) + +button = GtkButton("Hello World") +button.connect("clicked", hello) +window.add(button) +button.show() + +window.show() + +mainloop() + + diff --git a/examples/simple/scribble.py b/examples/simple/scribble.py new file mode 100755 index 00000000..d0aee9e0 --- /dev/null +++ b/examples/simple/scribble.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python + +#this is a simple translation of the scribble example that comes with GTK+ + +import sys +from gtk import * + +pixmap = None + +def configure_event(widget, event): + global pixmap + win = widget.get_window() + pixmap = create_pixmap(win, win.width, win.height, -1) + draw_rectangle(pixmap, widget.get_style().white_gc, TRUE, + 0, 0, win.width, win.height) + return TRUE + +def expose_event(widget, event): + area = event.area + gc = widget.get_style().fg_gc[STATE_NORMAL] + widget.draw_pixmap(gc, pixmap, area[0], area[1], area[0], area[1], + area[2], area[3]) + return FALSE + +def draw_brush(widget, x, y): + rect = (x-5, y-5, 10, 10) + draw_rectangle(pixmap, widget.get_style().black_gc, TRUE, + x-5, y-5, 10, 10) + widget.queue_draw() + +def button_press_event(widget, event): + if event.button == 1 and pixmap != None: + draw_brush(widget, event.x, event.y) + return TRUE + +def motion_notify_event(widget, event): + if event.is_hint: + x, y = event.window.pointer + state = event.window.pointer_state + else: + x = event.x; y = event.y + state = event.state + if state & GDK.BUTTON1_MASK and pixmap != None: + draw_brush(widget, x, y) + return TRUE + +def main(): + win = GtkWindow() + win.set_name("Test Input") + win.connect("destroy", mainquit) + win.border_width(5) + + vbox = GtkVBox(spacing=3) + win.add(vbox) + vbox.show() + + drawing_area = GtkDrawingArea() + drawing_area.size(200, 200) + vbox.pack_start(drawing_area) + drawing_area.show() + + drawing_area.connect("expose_event", expose_event) + drawing_area.connect("configure_event", configure_event) + drawing_area.connect("motion_notify_event", motion_notify_event) + drawing_area.connect("button_press_event", button_press_event) + drawing_area.set_events(GDK.EXPOSURE_MASK | + GDK.LEAVE_NOTIFY_MASK | + GDK.BUTTON_PRESS_MASK | + GDK.POINTER_MOTION_MASK | + GDK.POINTER_MOTION_HINT_MASK) + + button = GtkButton("Quit") + vbox.pack_start(button, expand=FALSE, fill=FALSE) + button.connect("clicked", win.destroy) + button.show() + win.show() + mainloop() + +if __name__ == '__main__': + main() + diff --git a/examples/simple/simple1.py b/examples/simple/simple1.py new file mode 100755 index 00000000..63980ecd --- /dev/null +++ b/examples/simple/simple1.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +# translation of "Hello World III" from GTK manual, using gtk_object_new +# with gtkmodule + +from _gtk import * +from GTK import * + +def hello(*args): + print "Hello World" + gtk_widget_destroy(window) + +def destroy(*args): + gtk_widget_hide(window) + gtk_main_quit() + +gtk_init() + +window = gtk_object_new(gtk_window_get_type(), { + 'type': WINDOW_TOPLEVEL, + 'title': 'Hello World', + 'allow_grow': 0, + 'allow_shrink': 0, + 'border_width': 10 +}) +gtk_signal_connect(window, "destroy", destroy) + +button = gtk_object_new(gtk_button_get_type(), { + 'label': 'Hello World', + 'parent': window, + 'visible': 1 +}) +gtk_signal_connect(button, "clicked", hello); + +gtk_widget_show(window) +gtk_main() + diff --git a/examples/simple/simple2.py b/examples/simple/simple2.py new file mode 100755 index 00000000..f541b275 --- /dev/null +++ b/examples/simple/simple2.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +# translation of "Hello World III" from gtk manual, using the new() function +# from gtk.py + +from gtk import * + +def hello(*args): + print "Hello World" + window.destroy() + +def destroy(*args): + window.hide() + mainquit() + +window = new(GtkWindow, type=WINDOW_TOPLEVEL, title='Hello World', + allow_grow=FALSE, allow_shrink=FALSE, border_width=10) +window.connect("destroy", destroy) + +print "" +button = new(GtkButton, label="Hello World", parent=window, visible=TRUE) +button.connect("clicked", hello) + +window.show_all() +mainloop() + diff --git a/examples/simple/tooltip1.py b/examples/simple/tooltip1.py new file mode 100755 index 00000000..93f0bcda --- /dev/null +++ b/examples/simple/tooltip1.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python + +# translation of "Hello World III" from GTK manual, using gtk_object_new +# with gtkmodule. Also implements a tooltip for the button. + +from _gtk import * +from GTK import * + +def hello(*args): + print "Hello World" + gtk_widget_destroy(window) + +def destroy(*args): + gtk_widget_hide(window) + gtk_main_quit() + +gtk_init() + +tt = gtk_tooltips_new() +gtk_tooltips_set_delay(tt, 500) + +window = gtk_object_new("GtkWindow", { + 'type': WINDOW_TOPLEVEL, + 'title': 'Hello World', + 'allow_grow': 0, + 'allow_shrink': 0, + 'border_width': 10 +}) +gtk_signal_connect(window, "destroy", destroy) + +button = gtk_object_new("GtkButton", { + 'label': 'Hello World', + 'parent': window, + 'visible': 1 +}) +gtk_signal_connect(button, "clicked", hello) + +gtk_tooltips_set_tip(tt, button, 'Prints "Hello World"', '') +gtk_tooltips_enable(tt) + +gtk_widget_show(window) +gtk_main() + diff --git a/examples/simple/tooltip2.py b/examples/simple/tooltip2.py new file mode 100755 index 00000000..3fad341b --- /dev/null +++ b/examples/simple/tooltip2.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +# translation of "Hello World III" from GTK manual, using new() function +# from gtk.py. Also implements a tooltip for the button. + +from gtk import * + +def hello(*args): + print "Hello World" + window.destroy() + +def destroy(*args): + window.hide() + mainquit() + +tt = GtkTooltips() +tt.set_delay(500) + +window = new(GtkWindow, type=WINDOW_TOPLEvEL, title="Hello World", + allow_grow=FALSE, allow_shrink=FALSE, border_width=10) +window.connect("destroy", destroy) + +button = new(GtkButton, label="Hello World", parent=window, visible=TRUE) +button.connect("clicked", hello) + +tt.set_tip(button, 'Prints "Hello World"', '') +tt.enable() + +window.show() +mainloop() + + diff --git a/examples/testgtk/.cvsignore b/examples/testgtk/.cvsignore new file mode 100644 index 00000000..c2831020 --- /dev/null +++ b/examples/testgtk/.cvsignore @@ -0,0 +1,6 @@ +Makefile.in +Makefile +*~ +*.pyc +*.pyo + diff --git a/examples/testgtk/README b/examples/testgtk/README new file mode 100644 index 00000000..739eeae2 --- /dev/null +++ b/examples/testgtk/README @@ -0,0 +1,4 @@ +This directory contains a translation of most of the testgtk example found +in the gtk distribution. I wrote it mainly to iron out bugs in pygtk, but +it is also useful to see how to use the various widgets. + diff --git a/examples/testgtk/test.xpm b/examples/testgtk/test.xpm new file mode 100644 index 00000000..9b0d2efd --- /dev/null +++ b/examples/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/examples/testgtk/testgtk.py b/examples/testgtk/testgtk.py new file mode 100755 index 00000000..e6fd168c --- /dev/null +++ b/examples/testgtk/testgtk.py @@ -0,0 +1,1525 @@ +#!/usr/bin/env python + +from gtk import * +import GtkExtra + +wins = {} + +def delete_event(win, event=None): + win.hide() + # don't destroy window -- just leave it hidden + return TRUE + +def create_statusbar_test(_button): + if not wins.has_key('statusbar_test'): + win = GtkDialog() + wins["statusbar_test"] = win + win.connect("delete_event", delete_event) + win.set_title("Status Bar Test") + + vbox = GtkVBox() + win.action_area.pack_start( vbox ) + hbox = GtkHBox() + vbox.add( hbox ) + statusbar = win.statusbar = GtkStatusbar() + vbox.add( statusbar ) + statusbar.show() + + c = win.context_id = statusbar.get_context_id("test") + statusbar.push( c, "First message") + def pop_statusbar_test(_b, sbar = statusbar, context = c): + sbar.pop( context ) + def push_statusbar_test(_b, sbar = statusbar, context = c): + import time + sbar.push( context, "Message "+str(time.time() )) + + button = GtkButton("Pop") + button.connect("clicked", pop_statusbar_test) + hbox.add(button) + button.show() + + button = GtkButton("Push") + button.connect("clicked", push_statusbar_test) + hbox.add(button) + button.show() + + button = GtkButton("close") + button.connect("clicked", win.hide) + hbox.add(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + + hbox.show() + vbox.show() + wins["statusbar_test"].show() + + +def create_buttons(_button): + if not wins.has_key("buttons"): + win = GtkWindow() + wins["buttons"] = win + win.connect("delete_event", delete_event) + win.set_title("buttons") + box1 = GtkVBox() + win.add(box1) + box1.show() + table = GtkTable(3, 3, FALSE) + table.set_row_spacings(5) + table.set_col_spacings(5) + table.border_width(10) + box1.pack_start(table) + table.show() + + def toggle_show(b): + if b.flags(VISIBLE): + b.hide() + else: + b.show() + button = map(lambda i: GtkButton("button"+str(i)), range(9)) + for i in range(9): + button[i].connect("clicked", + lambda _b, _b2=button[(i+1)%9], + t=toggle_show: t(_b2)) + y,x = divmod(i, 3) + table.attach(button[i], x,x+1, y,y+1) + button[i].show() + + separator = GtkHSeparator() + box1.pack_start(separator, expand=FALSE) + separator.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2, expand=FALSE) + box2.show() + + button = GtkButton("close") + button.connect("clicked", win.hide) + box2.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + wins["buttons"].show() + +def create_toggle_buttons(_button): + if not wins.has_key("toggle_buttons"): + win = GtkWindow() + wins["toggle_buttons"] = win + win.connect("delete_event", delete_event) + win.set_title("toggle butttons") + win.border_width(0) + box1 = GtkVBox() + win.add(box1) + box1.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2) + box2.show() + for i in range(1, 4): + button = GtkToggleButton("button" + str(i)) + box2.pack_start(button) + button.show() + separator = GtkHSeparator() + box1.pack_start(separator, expand=FALSE) + separator.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2, expand=FALSE) + box2.show() + + button = GtkButton("close") + button.connect("clicked", win.hide) + box2.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + wins["toggle_buttons"].show() + +def create_check_buttons(_button): + if not wins.has_key("check_buttons"): + win = GtkWindow() + wins["check_buttons"] = win + win.connect("delete_event", delete_event) + win.set_title("check buttons") + box1 = GtkVBox() + win.add(box1) + box1.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2) + box2.show() + + for i in range(1,4): + button = GtkCheckButton("button" + str(i)) + box2.pack_start(button) + button.show() + separator = GtkHSeparator() + box1.pack_start(separator, expand=FALSE) + separator.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2, expand=FALSE) + box2.show() + + button = GtkButton("close") + button.connect("clicked", win.hide) + box2.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + wins["check_buttons"].show() + +def create_radio_buttons(_button): + if not wins.has_key("radio_buttons"): + win = GtkWindow() + wins["radio_buttons"] = win + win.connect("delete_event", delete_event) + win.set_title("radio buttons") + box1 = GtkVBox() + win.add(box1) + box1.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2) + box2.show() + + button1 = GtkRadioButton(None, "button1") + box2.pack_start(button1) + button1.show() + for i in range(2,4): + button = GtkRadioButton(button1, "button" + str(i)) + box2.pack_start(button) + button.show() + separator = GtkHSeparator() + box1.pack_start(separator, expand=FALSE) + separator.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2, expand=FALSE) + box2.show() + + button = GtkButton("close") + button.connect("clicked", win.hide) + box2.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + wins["radio_buttons"].show() + +def create_button_box(_button): + if not wins.has_key("button_box"): + win = GtkDialog() + win.set_title("button box") + wins["button_box"] = win + win.connect("delete_event", delete_event) + + box1 = GtkHButtonBox() + box1.set_usize(550, -1) + box1.set_spacing(25) + box1.set_layout(BUTTONBOX_EDGE) + box1.border_width(10) + win.vbox.pack_start(box1) + box1.show() + + def bbox_start(_b, bbox=box1): + bbox.set_layout(BUTTONBOX_START) + bbox.queue_resize() + def bbox_edge(_b, bbox=box1): + bbox.set_layout(BUTTONBOX_EDGE) + bbox.queue_resize() + def bbox_spread(_b, bbox=box1): + bbox.set_layout(BUTTONBOX_SPREAD) + bbox.queue_resize() + def bbox_end(_b, bbox=box1): + bbox.set_layout(BUTTONBOX_END) + bbox.queue_resize() + + button = GtkButton("start") + button.connect("clicked", bbox_start) + box1.add(button) + button.show() + button = GtkButton("edge") + button.connect("clicked", bbox_edge) + box1.add(button) + button.show() + button = GtkButton("spread") + button.connect("clicked", bbox_spread) + box1.add(button) + button.show() + button = GtkButton("end") + button.connect("clicked", bbox_end) + box1.add(button) + button.show() + + button = GtkButton("close") + button.connect("clicked", win.hide) + win.action_area.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + wins["button_box"].show() + +def make_toolbar(win): + toolbar = GtkToolbar(ORIENTATION_HORIZONTAL, TOOLBAR_BOTH) + bg = win.get_style().bg[STATE_NORMAL] + if not win.flags(REALIZED): + win.realize() + + pix, mask = create_pixmap_from_xpm(win, None, "test.xpm") + + def set_toolbar_horizontal(_b, toolbar=toolbar): + toolbar.set_orientation(ORIENTATION_HORIZONTAL) + def set_toolbar_vertical(_b, toolbar=toolbar): + toolbar.set_orientation(ORIENTATION_VERTICAL) + def set_toolbar_icons(_b, toolbar=toolbar): + toolbar.set_style(TOOLBAR_ICONS) + def set_toolbar_text(_b, toolbar=toolbar): + toolbar.set_style(TOOLBAR_TEXT) + def set_toolbar_both(_b, toolbar=toolbar): + toolbar.set_style(TOOLBAR_BOTH) + def set_toolbar_small_space(_b, toolbar=toolbar): + toolbar.set_space_size(5) + def set_toolbar_big_space(_b, toolbar=toolbar): + toolbar.set_space_size(10) + def set_toolbar_enable(_b, toolbar=toolbar): + toolbar.set_tooltips(TRUE) + def set_toolbar_disable(_b, toolbar=toolbar): + toolbar.set_tooltips(FALSE) + print "Hello" + + toolbar.append_item("Horizontal", "Horizontal toolbar layout", + "Horizontal toolbar layout", + GtkPixmap(pix, mask), + set_toolbar_horizontal) + toolbar.append_item("Vertical", "Vertical toolbar layout", + "Vertical toolbar layout", + GtkPixmap(pix, mask), + set_toolbar_vertical) + toolbar.append_space() + toolbar.append_item("Icons", "Only show toolbar icons", + "Only Icons", + GtkPixmap(pix, mask), + set_toolbar_icons) + toolbar.append_item("Text", "Only show toolbar text", + "Only Text", + GtkPixmap(pix, mask), + set_toolbar_text) + toolbar.append_item("Both", "Show toolbar icons and text", + "Both Text and Icons", + GtkPixmap(pix, mask), + set_toolbar_both) + toolbar.append_space() + + entry = GtkEntry() + entry.show() + toolbar.append_widget(entry, "", "") + + toolbar.append_space() + toolbar.append_item("Small", "Use small spaces", + "Small spaces", + GtkPixmap(pix, mask), + set_toolbar_small_space) + toolbar.append_item("Big", "Use big spaces", + "Big spaces", + GtkPixmap(pix, mask), + set_toolbar_big_space) + toolbar.append_space() + toolbar.append_item("Enable", "Enable tooltips", + "Enable tooltips", + GtkPixmap(pix, mask), + set_toolbar_enable) + toolbar.append_item("Disable", "Disable tooltips", + "Disable tooltips", + GtkPixmap(pix, mask), + set_toolbar_disable) + return toolbar + +def create_toolbar(_button): + if not wins.has_key("toolbar"): + win = GtkWindow() + wins["toolbar"] = win + win.set_title("Toolbar test") + win.set_policy(FALSE, TRUE, TRUE) + win.connect("delete_event", delete_event) + win.realize() + toolbar = make_toolbar(win) + win.add(toolbar) + toolbar.show() + wins["toolbar"].show() + +def create_handle_box(_button): + if not wins.has_key("handle_box"): + win = GtkWindow() + wins["handle_box"] = win + win.set_title("Handle Box Test") + win.connect("delete_event", delete_event) + win.border_width(20) + win.realize() + + hbox = GtkHandleBox() + win.add(hbox) + hbox.show() + + toolbar = make_toolbar(win) + hbox.add(toolbar) + toolbar.show() + wins["handle_box"].show() + +def create_reparent(_button): + if not wins.has_key("reparent"): + win = GtkWindow() + wins["reparent"] = win + win.connect("delete_event", delete_event) + win.set_title("buttons") + + box1 = GtkVBox() + win.add(box1) + box1.show() + + box2 = GtkHBox(spacing=5) + box2.border_width(10) + box1.pack_start(box2) + box2.show() + + label = GtkLabel("Hello World") + frame = GtkFrame("Frame 1") + box2.pack_start(frame) + frame.show() + box3 = GtkVBox(spacing=5) + box3.border_width(5) + frame.add(box3) + box3.show() + def reparent_label(button, new_parent=box3, label=label): + label.reparent(new_parent) + button = GtkButton("switch") + button.connect("clicked", reparent_label) + box3.pack_start(button, expand=FALSE) + button.show() + + box3.pack_start(label, expand=FALSE) + label.show() + + frame = GtkFrame("Frame 2") + box2.pack_start(frame) + frame.show() + box3 = GtkVBox(spacing=5) + box3.border_width(5) + frame.add(box3) + box3.show() + def reparent_label(button, new_parent=box3, label=label): + label.reparent(new_parent) + button = GtkButton("switch") + button.connect("clicked", reparent_label) + box3.pack_start(button, expand=FALSE) + button.show() + + separator = GtkHSeparator() + box1.pack_start(separator, expand=FALSE) + separator.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2, expand=FALSE) + box2.show() + + button = GtkButton("close") + button.connect("clicked", win.hide) + box2.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + wins["reparent"].show() + +def create_pixmap(_button): + if not wins.has_key("pixmap"): + win = GtkWindow() + wins["pixmap"] = win + win.connect("delete_event", delete_event) + win.set_title("pixmap") + win.realize() + + box1 = GtkVBox() + win.add(box1) + box1.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2) + box2.show() + + button = GtkButton() + box2.pack_start(button, expand=FALSE, fill=FALSE) + button.show() + + pixmap = GtkPixmap(win, "test.xpm", + button.get_style().bg[STATE_NORMAL]) + label = GtkLabel("Pixmap\ntest") + box3 = GtkHBox() + box3.border_width(2) + box3.add(pixmap) + box3.add(label) + button.add(box3) + pixmap.show() + label.show() + box3.show() + + separator = GtkHSeparator() + box1.pack_start(separator, expand=FALSE) + separator.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2, expand=FALSE) + box2.show() + button = GtkButton("close") + button.connect("clicked", win.hide) + box2.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + wins["pixmap"].show() + +def create_tooltips(_button): + if not wins.has_key("tooltips"): + win = GtkWindow() + wins["tooltips"] = win + win.connect("delete_event", delete_event) + win.set_title("tooltips") + + tooltips = GtkTooltips() + + box1 = GtkVBox() + win.add(box1) + box1.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2) + box2.show() + + button = GtkToggleButton("button1") + box2.pack_start(button) + button.show() + tooltips.set_tip(button, "This is button 1", "button 1") + + button = GtkToggleButton("button2") + box2.pack_start(button) + button.show() + tooltips.set_tip(button, "This is button 2", "button 2") + + button = GtkToggleButton("button3") + box2.pack_start(button) + button.show() + tooltips.set_tip(button, "This is button 3. 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.", "long") + + separator = GtkHSeparator() + box1.pack_start(separator, expand=FALSE) + separator.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2, expand=FALSE) + box2.show() + + button = GtkButton("close") + button.connect("clicked", win.hide) + box2.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + + tooltips.set_tip(button, "Push this button to close window", + "push") + tooltips.enable() + wins["tooltips"].show() + +def create_menu(depth): + if depth < 1: return None + menu = GtkMenu() + group = None + for i in range(5): + menuitem = GtkRadioMenuItem(group, + "item %2d - %d" % (depth, i+1)) + group = menuitem + menu.append(menuitem) + menuitem.show() + if depth > 1: + submenu = create_menu(depth - 1) + menuitem.set_submenu(submenu) + return menu +def create_menus(_button): + if not wins.has_key("menus"): + win = GtkWindow() + wins["menus"] = win + win.connect("delete_event", delete_event) + win.set_title("menus") + + box1 = GtkVBox() + win.add(box1) + box1.show() + + menubar = GtkMenuBar() + box1.pack_start(menubar, expand=FALSE) + menubar.show() + + menuitem = GtkMenuItem("test\nline2") + menuitem.set_submenu(create_menu(2)) + menubar.append(menuitem) + menuitem.show() + + menuitem = GtkMenuItem("foo") + menuitem.set_submenu(create_menu(2)) + menubar.append(menuitem) + menuitem.show() + + menuitem = GtkMenuItem("bar") + menuitem.set_submenu(create_menu(2)) + menuitem.right_justify() + menubar.append(menuitem) + menuitem.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2) + box2.show() + + optionmenu = GtkOptionMenu() + optionmenu.set_menu(create_menu(1)) + box2.pack_start(optionmenu) + optionmenu.show() + + separator = GtkHSeparator() + box1.pack_start(separator, expand=FALSE) + separator.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2, expand=FALSE) + box2.show() + + button = GtkButton("close") + button.connect("clicked", win.hide) + box2.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + wins["menus"].show() + +def create_scrolled_windows(_button): + if not wins.has_key("scrolled_windows"): + win = GtkDialog() + wins["scrolled_windows"] = win + win.connect("delete_event", delete_event) + win.set_title("dialog") + + scrolled_window = GtkScrolledWindow() + scrolled_window.border_width(10) + scrolled_window.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) + win.vbox.pack_start(scrolled_window) + scrolled_window.show() + + table = GtkTable(20, 20) + table.set_row_spacings(10) + table.set_col_spacings(10) + scrolled_window.add(table) + table.show() + + for i in range(20): + for j in range(20): + button = GtkToggleButton("button (%d,%d)" % + (i, j)) + table.attach(button, i,i+1, j,j+1) + button.show() + button = GtkButton("close") + button.connect("clicked", win.hide) + win.action_area.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + wins["scrolled_windows"].show() + +def create_entry(_button): + if not wins.has_key("entry"): + win = GtkWindow() + wins["entry"] = win + win.connect("delete_event", delete_event) + win.set_title("entry") + + box1 = GtkVBox() + win.add(box1) + box1.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2) + box2.show() + + entry = GtkEntry() + entry.set_text("Hello World") + box2.pack_start(entry) + entry.show() + + separator = GtkHSeparator() + box1.pack_start(separator, expand=FALSE) + separator.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2, expand=FALSE) + box2.show() + + button = GtkButton("close") + button.connect("clicked", win.hide) + box2.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + wins["entry"].show() + +def create_list(_button): + if not wins.has_key("list"): + win = GtkWindow() + wins["list"] = win + win.connect("delete_event", delete_event) + win.set_title("list") + + box1 = GtkVBox() + win.add(box1) + box1.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2) + box2.show() + + scrolled_win = GtkScrolledWindow() + scrolled_win.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) + box2.pack_start(scrolled_win) + scrolled_win.show() + + list = GtkList() + list.set_selection_mode(SELECTION_MULTIPLE) + list.set_selection_mode(SELECTION_BROWSE) + scrolled_win.add(list) + list.show() + + list_items = ("hello", "world", "blah", "foo", "bar", "argh") + for i in list_items: + list_item = GtkListItem(i) + list.add(list_item) + list_item.show() + + def list_add(_button, list=list, num=[1]): + list_item = GtkListItem("added item "+str(num[0])) + num[0] = num[0] + 1 + list_item.show() + list.add(list_item) + + def list_remove(_button, list=list): + selection = list.get_selection() + list.remove_items(selection) + for i in selection: i.destroy() + + box3 = GtkHBox(spacing=10) + box2.pack_start(box3, expand=FALSE) + box3.show() + + button = GtkButton("add") + button.connect("clicked", list_add) + box3.pack_start(button) + button.show() + + button = GtkButton("remove") + button.connect("clicked", list_remove) + box3.pack_start(button) + button.show() + + separator = GtkHSeparator() + box1.pack_start(separator, expand=FALSE) + separator.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2, expand=FALSE) + box2.show() + + button = GtkButton("close") + button.connect("clicked", win.hide) + box2.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + wins["list"].show() + +def create_clist(_button): + if not wins.has_key("clist"): + win = GtkWindow() + wins["clist"] = win + win.connect("delete_event", delete_event) + win.set_title("clist") + + box1 = GtkVBox() + win.add(box1) + box1.show() + + box2 = GtkHBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2, expand=FALSE, fill=FALSE) + box2.show() + + clist = GtkCList(7, map(lambda i: "Title "+str(i), range(7))) + clist.set_column_width(0, 100) + for i in range(1, 7): + clist.set_column_width(i, 80) + + text = map(lambda i: "Column "+str(i), range(7)) + text[1] = "Right" + text[2] = "Center" + + def add1000_clist(_button, clist=clist, t=text): + clist.freeze() + for i in range(1000): + t[0] = "Row "+str(i) + clist.append(t) + clist.thaw() + def add10000_clist(_button, clist=clist, t=text): + clist.freeze() + for i in range(10000): + t[0] = "Row "+str(i) + clist.append(t) + clist.thaw() + def clear_clist(_button, clist=clist): + clist.clear() + s = [0] + def remove_row_clist(_button, clist=clist, selected=s): + clist.remove(selected[0]) + def select_clist(_clist, r, c, event, selected=s): + selected[0] = r + + button = GtkButton("Add 1,000 Rows") + box2.pack_start(button) + button.connect("clicked", add1000_clist) + button.show() + + button = GtkButton("Add 10,000 Rows") + box2.pack_start(button) + button.connect("clicked", add10000_clist) + button.show() + + button = GtkButton("Clear List") + box2.pack_start(button) + button.connect("clicked", clear_clist) + button.show() + + button = GtkButton("Remove Row") + box2.pack_start(button) + button.connect("clicked", remove_row_clist) + button.show() + + box2 = GtkHBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2, expand=FALSE, fill=FALSE) + box2.show() + + button = GtkButton("Show Title Buttons") + box2.pack_start(button) + button.connect("clicked", clist.column_titles_show) + button.show() + + button = GtkButton("Hide Title Buttons") + box2.pack_start(button) + button.connect("clicked", clist.column_titles_hide) + button.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2) + box2.show() + + clist.set_row_height(20) + clist.connect("select_row", select_clist) + clist.set_column_width(0, 100) + + for i in range(1, 7): + clist.set_column_width(0, 80) + clist.set_selection_mode(SELECTION_BROWSE) + clist.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) + clist.set_column_justification(1, JUSTIFY_RIGHT) + clist.set_column_justification(2, JUSTIFY_CENTER) + + for i in range(100): + text[0] = "Row "+str(i) + clist.append(text) + clist.border_width(5) + box2.pack_start(clist) + clist.show() + + separator = GtkHSeparator() + box1.pack_start(separator, expand=FALSE) + separator.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2, expand=FALSE) + box2.show() + + button = GtkButton("close") + button.connect("clicked", win.hide) + box2.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + wins["clist"].show() + +def create_color_selection(_button): + if not wins.has_key("color_selection"): + win = GtkColorSelectionDialog("color selection dialog") + wins["color_selection"] = win + win.colorsel.set_opacity(TRUE) + win.colorsel.set_update_policy(UPDATE_CONTINUOUS) + win.position(WIN_POS_MOUSE) + win.connect("delete_event", delete_event) + + win.cancel_button.connect("clicked", win.hide) + wins["color_selection"].show() + +def create_file_selection(_button): + if not wins.has_key("file_selection"): + win = GtkFileSelection("file selection dialog") + wins["file_selection"] = win + win.connect("delete_event", delete_event) + def file_selection_ok(_button, fs=win): + print fs.get_filename() + win.ok_button.connect("clicked", file_selection_ok) + win.cancel_button.connect("clicked", win.hide) + wins["file_selection"].show() + +def create_dialog(_button): + if not wins.has_key("dialog"): + win = GtkDialog() + wins["dialog"] = win + win.connect("delete_event", delete_event) + win.set_title("dialog") + + button = GtkButton("OK") + button.connect("clicked", win.hide) + win.action_area.pack_start(button) + button.show() + + def label_toggle(_button, label=[None], box=win.vbox): + l = label[0] + if not l: + l = GtkLabel("Dialog Test") + l.set_padding(10, 10) + box.pack_start(l) + l.show() + label[0] = l + else: + l.destroy() + label[0] = None + + button = GtkButton("Toggle") + button.connect("clicked", label_toggle) + win.action_area.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + wins["dialog"].show() + +def create_range_controls(_button): + if not wins.has_key("range_controls"): + win = GtkWindow() + wins["range_controls"] = win + win.connect("delete_event", delete_event) + win.set_title("range_controls") + + box1 = GtkVBox() + win.add(box1) + box1.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2) + box2.show() + + adjustment = GtkAdjustment(0, 0, 101, 0.1, 1, 1) + + scale = GtkHScale(adjustment) + scale.set_usize(150, 30) + scale.set_update_policy(UPDATE_DELAYED) + scale.set_digits(1) + scale.set_draw_value(TRUE) + box2.pack_start(scale) + scale.show() + + scrollbar = GtkHScrollbar(adjustment) + scrollbar.set_update_policy(UPDATE_DELAYED) + box2.pack_start(scrollbar) + scrollbar.show() + + separator = GtkHSeparator() + box1.pack_start(separator, expand=FALSE) + separator.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2, expand=FALSE) + box2.show() + + button = GtkButton("close") + button.connect("clicked", win.hide) + box2.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + wins["range_controls"].show() + +def create_rulers(_button): + if not wins.has_key("rulers"): + win = GtkWindow() + wins["rulers"] = win + win.connect("delete_event", delete_event) + win.set_title("rulers") + win.set_usize(300, 300) + # these should be defined elsewhere + GDK_POINTER_MOTION_MASK = 1 << 2 + GDK_POINTER_MOTION_HINT_MASK = 1 << 3 + win.set_events(GDK_POINTER_MOTION_MASK | + GDK_POINTER_MOTION_HINT_MASK) + + table = GtkTable(2, 3) + win.add(table) + table.show() + + ruler = GtkHRuler() + ruler.set_range(5, 15, 0, 20) + ruler.set_metric(PIXELS) + def motion_notify(obj, event, ruler=ruler): + return ruler.emit("motion_notify_event", event) + win.connect("motion_notify_event", motion_notify) + table.attach(ruler, 1,2, 0,1, yoptions=FILL) + ruler.show() + + ruler = GtkVRuler() + ruler.set_range(5, 15, 0, 20) + ruler.set_metric(PIXELS) + def motion_notify(obj, event, ruler=ruler): + return ruler.emit("motion_notify_event", event) + win.connect("motion_notify_event", motion_notify) + table.attach(ruler, 0,1, 1,2, xoptions=FILL) + ruler.show() + + label = GtkLabel("The rulers now work!\n" + + "They use the new interface to\n" + + "gtk_signal_emit.") + table.attach(label, 1,2, 1,2) + label.show() + + # XXX Finish this + wins["rulers"].show() + +def create_text(_button): + if not wins.has_key("text"): + win = GtkWindow() + wins["text"] = win + win.connect("delete_event", delete_event) + win.set_title("text") + + box1 = GtkVBox() + win.add(box1) + box1.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2) + box2.show() + + table = GtkTable(2, 2) + table.set_row_spacing(0, 2) + table.set_col_spacing(0, 2) + box2.pack_start(table) + table.show() + + text = GtkText() + text.set_editable(FALSE) + table.attach(text, 0,1, 0,1) + text.show() + + hscrollbar = GtkHScrollbar(text.get_hadjustment()) + table.attach(hscrollbar, 0,1, 1,2, yoptions=FILL) + hscrollbar.show() + + vscrollbar = GtkVScrollbar(text.get_vadjustment()) + table.attach(vscrollbar, 1,2, 0,1, xoptions=FILL) + vscrollbar.show() + + text.freeze() + text.realize() +# style = text.get_style() +# font = style.font ; fg = style.white; bg = style.bg[ + text.insert_defaults("some text\n") + text.insert_defaults("more text\n") + text.insert_defaults("\n") + text.insert_defaults("(a blank line)\n") + text.insert_defaults("\n") + text.insert_defaults("beaverloop\n") + text.insert_defaults("\n") + text.insert_defaults("Bad Acid ... Jazz!\n") + text.insert_defaults("\n") + text.insert_defaults("They all call me mellow yellow,\n") + text.insert_defaults("Thats 'cause I'm a mellow fellow,\n") + text.insert_defaults("You walk by and I'll say hello,\n") + text.thaw() + + separator = GtkHSeparator() + box1.pack_start(separator, expand=FALSE) + separator.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2, expand=FALSE) + box2.show() + + button = GtkButton("close") + button.connect("clicked", win.hide) + box2.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + wins["text"].show() + +def create_notebook(_button): + if not wins.has_key("notebook"): + win = GtkWindow() + wins["notebook"] = win + win.connect("delete_event", delete_event) + win.set_title("notebook") + + box1 = GtkVBox() + win.add(box1) + box1.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2) + box2.show() + + notebook = GtkNotebook() + notebook.set_tab_pos(POS_TOP) + box2.pack_start(notebook) + notebook.show() + + for i in range(5): + frame = GtkFrame("Page " + str(i)) + frame.border_width(10) + frame.set_usize(200, 150) + frame.show() + label = GtkLabel("Page " + str(i)) + frame.add(label) + label.show() + label = GtkLabel("Tab " + str(i)) + notebook.append_page(frame, label) + separator = GtkHSeparator() + box1.pack_start(separator, expand=FALSE) + separator.show() + + box2 = GtkHBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2, expand=FALSE) + box2.show() + + button = GtkButton("close") + button.connect("clicked", win.hide) + box2.pack_start(button) + button.show() + + button = GtkButton("next") + button.connect("clicked", notebook.next_page) + box2.pack_start(button) + button.show() + + button = GtkButton("prev") + button.connect("clicked", notebook.prev_page) + box2.pack_start(button) + button.show() + + def rotate_notebook(_b, note=notebook, pos=[POS_TOP]): + pos[0] = (pos[0] + 1) % 4 + note.set_tab_pos(pos[0]) + + button = GtkButton("rotate") + button.connect("clicked", rotate_notebook) + box2.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + wins["notebook"].show() + + +def create_panes(_button): + if not wins.has_key("panes"): + win = GtkWindow() + wins["panes"] = win + win.connect("delete_event", delete_event) + win.set_title("Panes") + + vpaned = GtkVPaned() + win.add(vpaned) + vpaned.border_width(5) + vpaned.show() + + hpaned = GtkHPaned() + vpaned.add1(hpaned) + + frame = GtkFrame() + frame.set_shadow_type(SHADOW_IN) + frame.set_usize(60, 60) + hpaned.add1(frame) + frame.show() + + frame = GtkFrame() + frame.set_shadow_type(SHADOW_IN) + frame.set_usize(80, 60) + hpaned.add2(frame) + frame.show() + + hpaned.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + vpaned.add2(box2) + box2.show() + + button = GtkButton("close") + button.connect("clicked", win.hide) + box2.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + wins["panes"].show() + +def create_dnd(_button): + if not wins.has_key("dnd"): + # note that these two functions don't use any global variables + # to communicate. In fact, try openning two copies of + # testgtk.py (or the C version) and drag between them. + def dnd_drop(button, event): + msg = "Drop data of type %s was:\n\n%s" % \ + (event.data_type, event.data) + GtkExtra.message_box("Drop", msg, + ("Continue with life in\n" + + "spite of this oppression",)) + def dnd_drag_request(button, event): + dnd_string = "Bill Gates demands royalties for\n" + \ + "your use of his innovation." + button.dnd_data_set(event, dnd_string) + win = GtkWindow(WINDOW_TOPLEVEL) + wins["dnd"] = win + win.connect("delete_event", lambda win,_e: win.hide()) + win.set_title("Drag -N- Drop") + + box1 = GtkVBox() + win.add(box1) + box1.show() + + box2 = GtkHBox(spacing=5) + box2.border_width(10) + box1.pack_start(box2) + box2.show() + + frame = GtkFrame("Drag") + box2.pack_start(frame) + frame.show() + + box3 = GtkVBox(spacing=5) + box3.border_width(5) + frame.add(box3) + box3.show() + + button = GtkButton("Drag me!") + box3.pack_start(button) + button.show() + button.realize() + button.connect("drag_request_event", dnd_drag_request) + button.dnd_drag_set(TRUE, ['text/plain']) + + frame = GtkFrame("Drop") + box2.pack_start(frame) + frame.show() + + box3 = GtkVBox(spacing=5) + box3.border_width(5) + frame.add(box3) + box3.show() + + button = GtkButton("To") + box3.pack_start(button) + button.show() + button.realize() + button.connect("drop_data_available_event", dnd_drop) + button.dnd_drop_set(TRUE, ['text/plain'], FALSE) + + separator = GtkHSeparator() + box1.pack_start(separator, expand=FALSE) + separator.show() + + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2, expand=FALSE) + box2.show() + + button = GtkButton("close") + button.connect("clicked", win.hide) + box2.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + wins['dnd'].show() + +def create_progress_bar(_button): + if not wins.has_key("progress_bar"): + win = GtkDialog() + wins["progress_bar"] = win + win.set_title("dialog") + + vbox = GtkVBox(spacing=5) + vbox.border_width(10) + win.vbox.pack_start(vbox) + vbox.show() + + label = GtkLabel("progress...") + label.set_alignment(0, 0.5) + vbox.pack_start(label, expand=FALSE) + label.show() + + pbar = GtkProgressBar() + pbar.set_usize(200, 20) + vbox.pack_start(pbar) + pbar.show() + + def timeout(pbar=pbar, pcnt=[0]): + pcnt[0] = (pcnt[0] + 0.02) % 1.0 + pbar.update(pcnt[0]) + return TRUE + + win.func = [timeout, 0] + + def killit(arg1=None, arg2=None, tid=win.func, win=win): + timeout_remove(tid[1]) + win.hide() + win.connect("destroy", killit) + win.connect("delete_event", killit) + + button = GtkButton("close") + button.connect("clicked", killit) + win.action_area.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + win = wins["progress_bar"] + win.show() + win.func[1] = timeout_add(100, win.func[0]) + +def create_gamma_curve(_button): + if not wins.has_key("gamma_curve"): + win = GtkWindow() + wins["gamma_curve"] = win + win.connect("delete_event", lambda _w, _e, win=win: win.hide()) + win.set_title("test") + win.set_usize(200, 150) + + curve = GtkGammaCurve() + win.add(curve) + curve.realize() + curve.show() + wins["gamma_curve"].show() + +def create_timeout_test(_button): + if not wins.has_key("timeout_test"): + win = GtkDialog() + wins["timeout_test"] = win + win.connect("delete_event", delete_event) + win.set_title("Timeout Test") + + label = GtkLabel("count: 0") + label.set_padding(10, 10) + win.vbox.pack_start(label) + label.show() + + func = [None, 0] + def timeout_test(label=label, count=[0]): + count[0] = count[0] + 1 + label.set("count: " + str(count[0])) + return TRUE + + func = [timeout_test, 0] + def start_timeout_test(_button, func=func): + if not func[1]: + func[1] = timeout_add(100, func[0]) + def stop_timeout_test(_button, func=func): + if func[1]: + timeout_remove(func[1]) + func[1] = 0 + + button = GtkButton("close") + button.connect("clicked", win.hide) + win.action_area.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + + button = GtkButton("start") + button.connect("clicked", start_timeout_test) + win.action_area.pack_start(button) + button.show() + + button = GtkButton("stop") + button.connect("clicked", stop_timeout_test) + win.action_area.pack_start(button) + button.show() + wins["timeout_test"].show() + +def create_idle_test(_button): + if not wins.has_key("idle_test"): + win = GtkDialog() + wins["idle_test"] = win + win.connect("delete_event", delete_event) + win.set_title("Idle Test") + + label = GtkLabel("count: 0") + label.set_padding(10, 10) + win.vbox.pack_start(label) + label.show() + + def idle_test(label=label, count=[0]): + count[0] = count[0] + 1 + label.set("count: " + str(count[0])) + return TRUE + + win.func = [idle_test, 0] + def start_idle_test(_button, func=win.func): + if not func[1]: + func[1] = idle_add(func[0]) + def stop_idle_test(_button, func=win.func): + if func[1]: + idle_remove(func[1]) + func[1] = 0 + + button = GtkButton("close") + button.connect("clicked", win.hide) + win.action_area.pack_start(button) + button.set_flags(CAN_DEFAULT) + button.grab_default() + button.show() + + button = GtkButton("start") + button.connect("clicked", start_idle_test) + win.action_area.pack_start(button) + button.show() + + button = GtkButton("stop") + button.connect("clicked", stop_idle_test) + win.action_area.pack_start(button) + button.show() + wins["idle_test"].show() + +def do_exit(button): + mainquit() + +def create_main_window(): + buttons = { + "buttons": create_buttons, + "toggle buttons": create_toggle_buttons, + "check buttons": create_check_buttons, + "radio buttons": create_radio_buttons, + "button box": create_button_box, + "toolbar": create_toolbar, + "handle box": create_handle_box, + "reparent": create_reparent, + "pixmap": create_pixmap, + "tooltips": create_tooltips, + "menus": create_menus, + "scrolled windows": create_scrolled_windows, + "drawing areas": None, + "entry": create_entry, + "list": create_list, + "clist": create_clist, + "color selection": create_color_selection, + "file selection": create_file_selection, + "dialog": create_dialog, + "miscellaneous": None, + "range controls": create_range_controls, + "rulers": create_rulers, + "text": create_text, + "notebook": create_notebook, + "panes": create_panes, + "shapes": None, #create_shapes, + "dnd": create_dnd, + "progress bar": create_progress_bar, + "preview color": None, #create_color_preview, + "preview gray": None, #create_gray_preview, + "gamma curve": create_gamma_curve, + "test scrolling": None, #creaate_scroll_text, + "test selection": None, #create_selection_test, + "test timeout": create_timeout_test, + "test idle": create_idle_test, + "test": None, #create_test + "status bar": create_statusbar_test, + } + win = GtkWindow() + win.set_name("main window") + win.set_usize(200, 400) + win.set_uposition(20, 20) + win.connect("destroy", mainquit) + win.connect("delete_event", mainquit) + win.set_title("gtktest") + box1 = GtkVBox(FALSE, 0) + win.add(box1) + box1.show() + scrolled_window = GtkScrolledWindow() + scrolled_window.border_width(10) + scrolled_window.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) + box1.pack_start(scrolled_window) + scrolled_window.show() + box2 = GtkVBox() + box2.border_width(10) + scrolled_window.add(box2) + box2.show() + k = buttons.keys() + k.sort() + for i in k: + button = GtkButton(i) + if buttons[i]: + button.connect("clicked", buttons[i]) + else: + button.set_sensitive(FALSE) + box2.pack_start(button) + button.show() + separator = GtkHSeparator() + box1.pack_start(separator, expand=FALSE) + separator.show() + box2 = GtkVBox(spacing=10) + box2.border_width(10) + box1.pack_start(box2, expand=FALSE) + box2.show() + button = GtkButton("close") + button.connect("clicked", do_exit) + button.set_flags(CAN_DEFAULT) + box2.pack_start(button) + button.grab_default() + button.show() + win.show() + +def main(): + rc_parse("testgtkrc") + create_main_window() + mainloop() + +if __name__ == '__main__': main() diff --git a/examples/testgtk/testgtkrc b/examples/testgtk/testgtkrc new file mode 100644 index 00000000..68e5578a --- /dev/null +++ b/examples/testgtk/testgtkrc @@ -0,0 +1,69 @@ +# pixmap_path "<dir 1>:<dir 2>:<dir 3>:..." +# +# style <name> [= <name>] +# { +# <option> +# } +# +# widget <widget_set> style <style_name> +# widget_class <widget_class_set> style <style_name> + +pixmap_path "." + +style "window" +{ +# bg_pixmap[NORMAL] = "warning.xpm" +} + +style "scale" +{ + fg[NORMAL] = { 1.0, 0, 0 } + bg_pixmap[NORMAL] = "<parent>" +} + +style "button" +{ + fg[PRELIGHT] = { 1.0, 1.0, 1.0 } + bg[PRELIGHT] = { 0, 0, 0.75 } +} + +style "main_button" = "button" +{ + font = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*" + bg[PRELIGHT] = { 0.75, 0, 0 } +} + +style "toggle_button" = "button" +{ + fg[NORMAL] = { 1.0, 0, 0 } + fg[ACTIVE] = { 1.0, 0, 0 } + bg_pixmap[NORMAL] = "<parent>" +} + +style "text" +{ + fg[NORMAL] = { 1.0, 1.0, 1.0 } + base[NORMAL] = { 0, 0, 0 } +} + +style "ruler" +{ + font = "-adobe-helvetica-medium-r-normal--*-80-*-*-*-*-*-*" +} + +style "curve" +{ + fg[NORMAL] = { 58000, 0, 0 } # red +} + +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 "main window.*GtkButton*" style "main_button" +widget "*GtkCurve" style "curve" diff --git a/gdkimlibmodule.c b/gdkimlibmodule.c new file mode 100644 index 00000000..3407cf5a --- /dev/null +++ b/gdkimlibmodule.c @@ -0,0 +1,804 @@ +/* PyGTK imlib module - python bindings for gdk_imlib + * Copyright (C) 1998 James Henstridge <james@daa.com.au> + * + * 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. + */ + +#include <Python.h> +#include <gtk/gtk.h> +#include <gdk_imlib.h> + + +typedef struct { + PyObject_HEAD + GtkObject *go; +} PyGtk_Object; +PyTypeObject *PyGtk_Type; +#define PyGtk_Check(op) ((op)->ob_type == PyGtk_Type) + +static PyObject *(*PyGtk_New)(GtkObject *go); + +typedef struct { + PyObject_HEAD + GdkWindow *obj; +} PyGdkWindow_Object; +PyTypeObject *PyGdkWindow_Type; +#define PyGdkWindow_Check(op) ((op)->ob_type == PyGdkWindow_Type) +#define PyGdkWindow_Get(op) (((PyGdkWindow_Object *)(op))->obj) +static PyObject *(*PyGdkWindow_New)(GdkWindow *win); + + +typedef struct { + PyObject_HEAD + GdkImlibImage *obj; +} PyGdkImlibImage_Object; + +staticforward PyTypeObject PyGdkImlibImage_Type; +#define PyGdkImlibImage_Check(ob) ((ob)->ob_type == &PyGdkImlibImage_Type) +#define PyGdkImlibImage_Get(ob) (((PyGdkImlibImage_Object *)(ob))->obj) + +static PyObject * +PyGdkImlibImage_New(GdkImlibImage *obj) { + PyGdkImlibImage_Object *self; + + if (obj == NULL) { + PyErr_SetString(PyExc_IOError, "couldn't load image"); + return NULL; + } + + self = (PyGdkImlibImage_Object *)PyObject_NEW(PyGdkImlibImage_Object, + &PyGdkImlibImage_Type); + if (self == NULL) + return NULL; + self->obj = obj; + return (PyObject *)self; +} + +static void +PyGdkImlibImage_Dealloc(PyGdkImlibImage_Object *self) { + gdk_imlib_destroy_image(self->obj); + PyMem_DEL(self); +} + +static int +PyGdkImlibImage_Compare(PyGdkImlibImage_Object *self, + PyGdkImlibImage_Object *v) { + if (self->obj == v->obj) return 0; + if (self->obj > v->obj) return -1; + return 1; +} + +static PyTypeObject PyGdkImlibImage_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "GdkImlibImage", + sizeof(PyGdkImlibImage_Object), + 0, + (destructor)PyGdkImlibImage_Dealloc, + (printfunc)0, + (getattrfunc)0, + (setattrfunc)0, + (cmpfunc)PyGdkImlibImage_Compare, + (reprfunc)0, + 0, + 0, + 0, + (hashfunc)0, + (ternaryfunc)0, + (reprfunc)0, + 0L,0L,0L,0L, + NULL +}; + + +static PyObject *_wrap_gdk_imlib_init(PyObject *self, PyObject *args) { + static called = 0; + + if (called) { + Py_INCREF(Py_None); + return Py_None; + } + called = 1; + if (!PyArg_ParseTuple(args, ":gdk_imlib_init")) + return NULL; + + /* now actually initialise imlib */ + gdk_imlib_init(); + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_get_render_type(PyObject *self, PyObject *args) { + if (!PyArg_ParseTuple(args,":gdk_imlib_get_render_type")) + return NULL; + return PyInt_FromLong(gdk_imlib_get_render_type()); +} + +static PyObject *_wrap_gdk_imlib_set_render_type(PyObject *self, PyObject *args) { + int rend_type; + + if (!PyArg_ParseTuple(args,"i:gdk_imlib_set_render_type", &rend_type)) + return NULL; + gdk_imlib_set_render_type(rend_type); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_load_colors(PyObject *self, PyObject *args) { + char *file; + + if (!PyArg_ParseTuple(args,"s:gdk_imlib_load_colors",&file)) + return NULL; + return PyInt_FromLong(gdk_imlib_load_colors(file)); +} + +static PyObject *_wrap_gdk_imlib_load_image(PyObject *self, PyObject *args) { + char *file; + + if(!PyArg_ParseTuple(args,"s:gdk_imlib_load_image",&file)) + return NULL; + return PyGdkImlibImage_New(gdk_imlib_load_image(file)); +} + +static PyObject *_wrap_gdk_imlib_best_color_match(PyObject *self, PyObject *args) { + int r, g, b; + if (!PyArg_ParseTuple(args, "iii:gdk_imlib_best_color_match", &r, &g, &b)) + return NULL; + gdk_imlib_best_color_match(&r, &g, &b); + return Py_BuildValue("(iii)", r, g, b); +} + +static PyObject *_wrap_gdk_imlib_render(PyObject *self, PyObject *args) { + int width; + int height; + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!ii:gdk_imlib_render", &PyGdkImlibImage_Type, + &image, &width, &height)) + return NULL; + return PyInt_FromLong(gdk_imlib_render(PyGdkImlibImage_Get(image), + width, height)); +} + +static PyObject *_wrap_gdk_imlib_get_pixmap(PyObject *self, PyObject *args) { + PyObject *image, *ret; + GdkPixmap *pix; + GdkBitmap *mask; + + if (!PyArg_ParseTuple(args, "O!:gdk_imlib_make_pixmap", + &PyGdkImlibImage_Type, &image)) + return NULL; + pix = gdk_imlib_move_image(PyGdkImlibImage_Get(image)); + mask = gdk_imlib_move_mask(PyGdkImlibImage_Get(image)); + ret = PyTuple_New(2); + PyTuple_SetItem(ret, 0, PyGdkWindow_New(pix)); + if (mask) + PyTuple_SetItem(ret, 1, PyGdkWindow_New(mask)); + else { + Py_INCREF(Py_None); + PyTuple_SetItem(ret, 1, Py_None); + } + gdk_imlib_free_pixmap(pix); + return ret; +} + +static PyObject *_wrap_gdk_imlib_make_pixmap(PyObject *self, PyObject *args) { + GtkWidget *w; + GdkPixmap *p; + GdkBitmap *b; + PyObject *image; + + if (!PyArg_ParseTuple(args, "O!:gdk_imlib_make_pixmap", + &PyGdkImlibImage_Type, &image)) + return NULL; + p = gdk_imlib_move_image(PyGdkImlibImage_Get(image)); + b = gdk_imlib_move_mask(PyGdkImlibImage_Get(image)); + + gtk_widget_push_visual(gdk_imlib_get_visual()); + gtk_widget_push_colormap(gdk_imlib_get_colormap()); + w = gtk_pixmap_new(p, b); + gtk_widget_pop_visual(); + gtk_widget_pop_colormap(); + + gdk_imlib_free_pixmap(p); + return PyGtk_New((GtkObject *)w); +} + +static PyObject *_wrap_gdk_imlib_free_colors(PyObject *self, PyObject *args) { + if(!PyArg_ParseTuple(args,":gdk_imlib_free_colors")) + return NULL; + gdk_imlib_free_colors(); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_get_image_border(PyObject *self, PyObject *args) { + GdkImlibBorder border; + PyObject *image ; + + if(!PyArg_ParseTuple(args,"O!:gdk_imlib_get_image_border", + &PyGdkImlibImage_Type, &image)) + return NULL; + gdk_imlib_get_image_border(PyGdkImlibImage_Get(image), &border); + return Py_BuildValue("(iiii)", border.left, border.right, + border.top, border.bottom); +} + +static PyObject *_wrap_gdk_imlib_set_image_border(PyObject *self, PyObject *args) { + GdkImlibBorder border; + PyObject *image; + + if(!PyArg_ParseTuple(args, "O!(iiii):gdk_imlib_set_image_border", + &PyGdkImlibImage_Type, &image, + &(border.left), &(border.right), + &(border.top), &(border.bottom))) + return NULL; + gdk_imlib_set_image_border(PyGdkImlibImage_Get(image), &border); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_get_image_shape(PyObject *self, PyObject *args) { + GdkImlibColor color; + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!:gdk_imlib_get_image_shape", + &PyGdkImlibImage_Type, &image)) + return NULL; + gdk_imlib_get_image_shape(PyGdkImlibImage_Get(image), &color); + return Py_BuildValue("(iii)", color.r, color.g, color.b); +} + +static PyObject *_wrap_gdk_imlib_set_image_shape(PyObject *self, PyObject *args) { + GdkImlibColor color; + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!(iii):gdk_imlib_set_image_shape", + &PyGdkImlibImage_Type, &image, + &(color.r), &(color.g), &(color.b))) + return NULL; + gdk_imlib_set_image_shape(PyGdkImlibImage_Get(image), &color); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_save_image_to_eim(PyObject *self, PyObject *args) { + char *file; + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!s:gdk_imlib_save_image_to_eim", + &PyGdkImlibImage_Type, &image, &file)) + return NULL; + return PyInt_FromLong(gdk_imlib_save_image_to_eim( + PyGdkImlibImage_Get(image), file)); +} + +static PyObject *_wrap_gdk_imlib_add_image_to_eim(PyObject *self, PyObject *args) { + char *file; + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!s:gdk_imlib_add_image_to_eim", + &PyGdkImlibImage_Type, &image, &file)) + return NULL; + return PyInt_FromLong(gdk_imlib_add_image_to_eim( + PyGdkImlibImage_Get(image), file)); +} + +static PyObject *_wrap_gdk_imlib_save_image_to_ppm(PyObject *self, PyObject *args) { + char *file; + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!s:gdk_imlib_save_image_to_ppm", + &PyGdkImlibImage_Type, &image, &file)) + return NULL; + return PyInt_FromLong(gdk_imlib_save_image_to_ppm( + PyGdkImlibImage_Get(image), file)); +} + +static PyObject *_wrap_gdk_imlib_set_image_modifier(PyObject *self, PyObject *args) { + GdkImlibColorModifier mods; + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!(iii):gdk_imlib_set_image_modifier", + &PyGdkImlibImage_Type, &image, + &(mods.gamma), &(mods.brightness), &(mods.contrast))) + return NULL; + gdk_imlib_set_image_modifier(PyGdkImlibImage_Get(image), &mods); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_set_image_red_modifier(PyObject *self, PyObject *args) { + GdkImlibColorModifier mods; + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!(iii):gdk_imlib_set_image_red_modifier", + &PyGdkImlibImage_Type, &image, + &(mods.gamma), &(mods.brightness), &(mods.contrast))) + return NULL; + gdk_imlib_set_image_red_modifier(PyGdkImlibImage_Get(image), &mods); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_set_image_green_modifier(PyObject *self, PyObject *args) { + GdkImlibColorModifier mods; + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!(iii):gdk_imlib_set_image_green_modifier", + &PyGdkImlibImage_Type, &image, + &(mods.gamma), &(mods.brightness), &(mods.contrast))) + return NULL; + gdk_imlib_set_image_green_modifier(PyGdkImlibImage_Get(image), &mods); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_set_image_blue_modifier(PyObject *self, PyObject *args) { + GdkImlibColorModifier mods; + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!(iii):gdk_imlib_set_image_blue_modifier", + &PyGdkImlibImage_Type, &image, + &(mods.gamma), &(mods.brightness), &(mods.contrast))) + return NULL; + gdk_imlib_set_image_blue_modifier(PyGdkImlibImage_Get(image), &mods); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_get_image_modifier(PyObject *self, PyObject *args) { + GdkImlibColorModifier mods; + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!:gdk_imlib_get_image_modifier", + &PyGdkImlibImage_Type, &image)) + return NULL; + gdk_imlib_get_image_modifier(PyGdkImlibImage_Get(image), &mods); + return Py_BuildValue("(iii)", mods.gamma, mods.brightness, mods.contrast); +} + +static PyObject *_wrap_gdk_imlib_get_image_red_modifier(PyObject *self, PyObject *args) { + GdkImlibColorModifier mods; + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!:gdk_imlib_get_image_red_modifier", + &PyGdkImlibImage_Type, &image)) + return NULL; + gdk_imlib_get_image_red_modifier(PyGdkImlibImage_Get(image), &mods); + return Py_BuildValue("(iii)", mods.gamma, mods.brightness, mods.contrast); +} + +static PyObject *_wrap_gdk_imlib_get_image_green_modifier(PyObject *self, PyObject *args) { + GdkImlibColorModifier mods; + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!:gdk_imlib_get_image_green_modifier", + &PyGdkImlibImage_Type, &image)) + return NULL; + gdk_imlib_get_image_green_modifier(PyGdkImlibImage_Get(image), &mods); + return Py_BuildValue("(iii)", mods.gamma, mods.brightness, mods.contrast); +} + +static PyObject *_wrap_gdk_imlib_get_image_blue_modifier(PyObject *self, PyObject *args) { + GdkImlibColorModifier mods; + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!:gdk_imlib_get_image_blue_modifier", + &PyGdkImlibImage_Type, &image)) + return NULL; + gdk_imlib_get_image_blue_modifier(PyGdkImlibImage_Get(image), &mods); + return Py_BuildValue("(iii)", mods.gamma, mods.brightness, mods.contrast); +} + +static PyObject *_wrap_gdk_imlib_set_image_red_curve(PyObject *self, PyObject *args) { + PyObject *image, *list, *item; + unsigned char mod[256]; + int i; + + if(!PyArg_ParseTuple(args,"O!O:gdk_imlib_set_image_red_curve", + &PyGdkImlibImage_Type, &image, &list)) + return NULL; + if (!PySequence_Check(list) || PySequence_Length(list) < 256) { + PyErr_SetString(PyExc_TypeError, "second arg must be sequence"); + return NULL; + } + for (i = 0; i < 256; i++) { + item = PySequence_GetItem(list, i); + if (!PyInt_Check(item)) { + PyErr_SetString(PyExc_TypeError,"item of sequence not an integer"); + return NULL; + } + mod[i] = PyInt_AsLong(item); + } + gdk_imlib_set_image_red_curve(PyGdkImlibImage_Get(image), mod); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_set_image_green_curve(PyObject *self, PyObject *args) { + PyObject *image, *list, *item; + unsigned char mod[256]; + int i; + + if(!PyArg_ParseTuple(args,"O!O:gdk_imlib_set_image_green_curve", + &PyGdkImlibImage_Type, &image, &list)) + return NULL; + if (!PySequence_Check(list) || PySequence_Length(list) < 256) { + PyErr_SetString(PyExc_TypeError, "second arg must be sequence"); + return NULL; + } + for (i = 0; i < 256; i++) { + item = PySequence_GetItem(list, i); + if (!PyInt_Check(item)) { + PyErr_SetString(PyExc_TypeError,"item of sequence not an integer"); + return NULL; + } + mod[i] = PyInt_AsLong(item); + } + gdk_imlib_set_image_green_curve(PyGdkImlibImage_Get(image), mod); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_set_image_blue_curve(PyObject *self, PyObject *args) { + PyObject *image, *list, *item; + unsigned char mod[256]; + int i; + + if(!PyArg_ParseTuple(args,"O!O:gdk_imlib_set_image_blue_curve", + &PyGdkImlibImage_Type, &image, &list)) + return NULL; + if (!PySequence_Check(list) || PySequence_Length(list) < 256) { + PyErr_SetString(PyExc_TypeError, "second arg must be sequence"); + return NULL; + } + for (i = 0; i < 256; i++) { + item = PySequence_GetItem(list, i); + if (!PyInt_Check(item)) { + PyErr_SetString(PyExc_TypeError,"item of sequence not an integer"); + return NULL; + } + mod[i] = PyInt_AsLong(item); + } + gdk_imlib_set_image_blue_curve(PyGdkImlibImage_Get(image), mod); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_get_image_red_curve(PyObject *self, PyObject *args) { + PyObject *image, *ret; + unsigned char mod[256]; + int i; + + if(!PyArg_ParseTuple(args,"O!:gdk_imlib_get_image_red_curve", + &PyGdkImlibImage_Type, &image)) + return NULL; + gdk_imlib_get_image_red_curve(PyGdkImlibImage_Get(image), mod); + ret = PyList_New(256); + for (i = 0; i < 256; i++) + PyList_SetItem(ret, i, PyInt_FromLong(mod[i])); + return ret; +} + +static PyObject *_wrap_gdk_imlib_get_image_green_curve(PyObject *self, PyObject *args) { + PyObject *image, *ret; + unsigned char mod[256]; + int i; + + if(!PyArg_ParseTuple(args,"O!:gdk_imlib_get_image_green_curve", + &PyGdkImlibImage_Type, &image)) + return NULL; + gdk_imlib_get_image_green_curve(PyGdkImlibImage_Get(image), mod); + ret = PyList_New(256); + for (i = 0; i < 256; i++) + PyList_SetItem(ret, i, PyInt_FromLong(mod[i])); + return ret; +} + +static PyObject *_wrap_gdk_imlib_get_image_blue_curve(PyObject *self, PyObject *args) { + PyObject *image, *ret; + unsigned char mod[256]; + int i; + + if(!PyArg_ParseTuple(args,"O!:gdk_imlib_get_image_blue_curve", + &PyGdkImlibImage_Type, &image)) + return NULL; + gdk_imlib_get_image_blue_curve(PyGdkImlibImage_Get(image), mod); + ret = PyList_New(256); + for (i = 0; i < 256; i++) + PyList_SetItem(ret, i, PyInt_FromLong(mod[i])); + return ret; +} + +static PyObject *_wrap_gdk_imlib_apply_modifiers_to_rgb(PyObject *self, PyObject *args) { + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!:gdk_imlib_apply_modifiers_to_rgb", + &PyGdkImlibImage_Type, &image)) + return NULL; + gdk_imlib_apply_modifiers_to_rgb(PyGdkImlibImage_Get(image)); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_changed_image(PyObject *self, PyObject *args) { + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!:gdk_imlib_changed_image", + &PyGdkImlibImage_Type, &image)) + return NULL; + gdk_imlib_changed_image(PyGdkImlibImage_Get(image)); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_flip_image_horizontal(PyObject *self, PyObject *args) { + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!:gdk_imlib_flip_image_horizontal", + &PyGdkImlibImage_Type, &image)) + return NULL; + gdk_imlib_flip_image_horizontal(PyGdkImlibImage_Get(image)); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_flip_image_vertical(PyObject *self, PyObject *args) { + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!:gdk_imlib_flip_image_vertical", + &PyGdkImlibImage_Type, &image)) + return NULL; + gdk_imlib_flip_image_vertical(PyGdkImlibImage_Get(image)); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_rotate_image(PyObject *self, PyObject *args) { + PyObject *image; + int degrees; + + if(!PyArg_ParseTuple(args,"O!i:gdk_imlib_rotate_image", + &PyGdkImlibImage_Type, &image, °rees)) + return NULL; + gdk_imlib_rotate_image(PyGdkImlibImage_Get(image), degrees); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_create_image_from_data(PyObject *self, PyObject *args) { + unsigned char *data, *alpha; + int w, h; + + if (!PyArg_ParseTuple(args, "szii:gdk_imlib_create_image_from_data", + &data, &alpha, &w, &h)) + return NULL; + return PyGdkImlibImage_New(gdk_imlib_create_image_from_data( + data, alpha, w, h)); +} + +static PyObject *_wrap_gdk_imlib_clone_image(PyObject *self, PyObject *args) { + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!:gdk_imlib_clone_image", + &PyGdkImlibImage_Type, &image)) + return NULL; + return PyGdkImlibImage_New(gdk_imlib_clone_image( + PyGdkImlibImage_Get(image))); +} + +static PyObject *_wrap_gdk_imlib_clone_scaled_image(PyObject *self, PyObject *args) { + PyObject *image; + int width, height; + + if(!PyArg_ParseTuple(args,"O!ii:gdk_imlib_clone_scaled_image", + &PyGdkImlibImage_Type, &image, &width, &height)) + return NULL; + return PyGdkImlibImage_New(gdk_imlib_clone_scaled_image( + PyGdkImlibImage_Get(image), width, height)); +} + +static PyObject *_wrap_gdk_imlib_get_fallback(PyObject *self, PyObject *args) { + if(!PyArg_ParseTuple(args,":gdk_imlib_get_fallback")) + return NULL; + return PyInt_FromLong(gdk_imlib_get_fallback()); +} + +static PyObject *_wrap_gdk_imlib_set_fallback(PyObject *self, PyObject *args) { + int fallback; + + if(!PyArg_ParseTuple(args,"i:gdk_imlib_set_fallback",&fallback)) + return NULL; + gdk_imlib_set_fallback(fallback); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_get_sysconfig(PyObject *self, PyObject *args) { + if(!PyArg_ParseTuple(args,":gdk_imlib_get_sysconfig")) + return NULL; + return PyString_FromString(gdk_imlib_get_sysconfig()); +} + +static PyObject *_wrap_gdk_imlib_crop_image(PyObject *self, PyObject *args) { + PyObject *image; + int x, y, w, h; + + if(!PyArg_ParseTuple(args,"O!iiii:gdk_imlib_crop_image", + &PyGdkImlibImage_Type, &image, &x, &y, &w, &h)) + return NULL; + gdk_imlib_crop_image(PyGdkImlibImage_Get(image), x, y, w, h); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_save_image(PyObject *self, PyObject *args) { + PyObject *image; + char *file; + + if(!PyArg_ParseTuple(args,"O!s:gdk_imlib_save_image", + &PyGdkImlibImage_Type, &image, &file)) + return NULL; + return PyInt_FromLong(gdk_imlib_save_image( + PyGdkImlibImage_Get(image), file, NULL)); +} + +static PyObject *_wrap_gdk_imlib_crop_and_clone_image(PyObject *self, PyObject *args) { + PyObject *image; + int x, y, w, h; + + if (!PyArg_ParseTuple(args, "O!iiii:gdk_imlib_crop_and_clone_image", + &PyGdkImlibImage_Type, &image, &x, &y, &w, &h)) + return NULL; + return PyGdkImlibImage_New(gdk_imlib_crop_and_clone_image( + PyGdkImlibImage_Get(image), x, y, w, h)); +} + +static PyObject *_wrap_gdk_imlib_create_image_from_drawable(PyObject *self, PyObject *args) { + PyObject *win, *py_mask; + int x, y, w, h; + GdkBitmap *mask = NULL; + + if (!PyArg_ParseTuple(args, "O!Oiiii:gdk_imlib_create_image_from_drawable", + &PyGdkWindow_Type, &win, &py_mask, &x, &y, &w, &h)) + return NULL; + if (py_mask != Py_None && !PyGdkWindow_Check(py_mask)) { + PyErr_SetString(PyExc_TypeError, + "second argument must be a GdkBitmap or None"); + return NULL; + } + if (py_mask != Py_None) mask = PyGdkWindow_Get(py_mask); + return PyGdkImlibImage_New(gdk_imlib_create_image_from_drawable( + PyGdkWindow_Get(win), mask, x, y, w, h)); +} + +static PyObject *_wrap_gdk_imlib_get_rgb_width(PyObject *self, PyObject *args) { + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!:gdk_imlib_get_rgb_width", + &PyGdkImlibImage_Type, &image)) + return NULL; + return PyInt_FromLong(PyGdkImlibImage_Get(image)->rgb_width); +} + +static PyObject *_wrap_gdk_imlib_get_rgb_height(PyObject *self, PyObject *args) { + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!:gdk_imlib_get_rgb_height", + &PyGdkImlibImage_Type, &image)) + return NULL; + return PyInt_FromLong(PyGdkImlibImage_Get(image)->rgb_width); +} + +static PyObject *_wrap_gdk_imlib_get_filename(PyObject *self, PyObject *args) { + PyObject *image; + + if(!PyArg_ParseTuple(args,"O!:gdk_imlib_get_filename", + &PyGdkImlibImage_Type, &image)) + return NULL; + return PyString_FromString(PyGdkImlibImage_Get(image)->filename); +} + +static PyMethodDef _gdkimlibMethods[] = { + { "gdk_imlib_get_filename", _wrap_gdk_imlib_get_filename, 1 }, + { "gdk_imlib_get_rgb_height", _wrap_gdk_imlib_get_rgb_height, 1 }, + { "gdk_imlib_get_rgb_width", _wrap_gdk_imlib_get_rgb_width, 1 }, + { "gdk_imlib_create_image_from_drawable", _wrap_gdk_imlib_create_image_from_drawable, 1 }, + { "gdk_imlib_crop_and_clone_image", _wrap_gdk_imlib_crop_and_clone_image, 1 }, + { "gdk_imlib_save_image", _wrap_gdk_imlib_save_image, 1 }, + { "gdk_imlib_crop_image", _wrap_gdk_imlib_crop_image, 1 }, + { "gdk_imlib_get_sysconfig", _wrap_gdk_imlib_get_sysconfig, 1 }, + { "gdk_imlib_set_fallback", _wrap_gdk_imlib_set_fallback, 1 }, + { "gdk_imlib_get_fallback", _wrap_gdk_imlib_get_fallback, 1 }, + { "gdk_imlib_clone_scaled_image", _wrap_gdk_imlib_clone_scaled_image, 1 }, + { "gdk_imlib_clone_image", _wrap_gdk_imlib_clone_image, 1 }, + { "gdk_imlib_create_image_from_data", _wrap_gdk_imlib_create_image_from_data, 1 }, + { "gdk_imlib_rotate_image", _wrap_gdk_imlib_rotate_image, 1 }, + { "gdk_imlib_flip_image_vertical", _wrap_gdk_imlib_flip_image_vertical, 1 }, + { "gdk_imlib_flip_image_horizontal", _wrap_gdk_imlib_flip_image_horizontal, 1 }, + { "gdk_imlib_changed_image", _wrap_gdk_imlib_changed_image, 1 }, + { "gdk_imlib_apply_modifiers_to_rgb", _wrap_gdk_imlib_apply_modifiers_to_rgb, 1 }, + { "gdk_imlib_get_image_blue_curve", _wrap_gdk_imlib_get_image_blue_curve, 1 }, + { "gdk_imlib_get_image_green_curve", _wrap_gdk_imlib_get_image_green_curve, 1 }, + { "gdk_imlib_get_image_red_curve", _wrap_gdk_imlib_get_image_red_curve, 1 }, + { "gdk_imlib_set_image_blue_curve", _wrap_gdk_imlib_set_image_blue_curve, 1 }, + { "gdk_imlib_set_image_green_curve", _wrap_gdk_imlib_set_image_green_curve, 1 }, + { "gdk_imlib_set_image_red_curve", _wrap_gdk_imlib_set_image_red_curve, 1 }, + { "gdk_imlib_get_image_blue_modifier", _wrap_gdk_imlib_get_image_blue_modifier, 1 }, + { "gdk_imlib_get_image_green_modifier", _wrap_gdk_imlib_get_image_green_modifier, 1 }, + { "gdk_imlib_get_image_red_modifier", _wrap_gdk_imlib_get_image_red_modifier, 1 }, + { "gdk_imlib_get_image_modifier", _wrap_gdk_imlib_get_image_modifier, 1 }, + { "gdk_imlib_set_image_blue_modifier", _wrap_gdk_imlib_set_image_blue_modifier, 1 }, + { "gdk_imlib_set_image_green_modifier", _wrap_gdk_imlib_set_image_green_modifier, 1 }, + { "gdk_imlib_set_image_red_modifier", _wrap_gdk_imlib_set_image_red_modifier, 1 }, + { "gdk_imlib_set_image_modifier", _wrap_gdk_imlib_set_image_modifier, 1 }, + { "gdk_imlib_save_image_to_ppm", _wrap_gdk_imlib_save_image_to_ppm, 1 }, + { "gdk_imlib_add_image_to_eim", _wrap_gdk_imlib_add_image_to_eim, 1 }, + { "gdk_imlib_save_image_to_eim", _wrap_gdk_imlib_save_image_to_eim, 1 }, + { "gdk_imlib_set_image_shape", _wrap_gdk_imlib_set_image_shape, 1 }, + { "gdk_imlib_get_image_shape", _wrap_gdk_imlib_get_image_shape, 1 }, + { "gdk_imlib_set_image_border", _wrap_gdk_imlib_set_image_border, 1 }, + { "gdk_imlib_get_image_border", _wrap_gdk_imlib_get_image_border, 1 }, + { "gdk_imlib_free_colors", _wrap_gdk_imlib_free_colors, 1 }, + { "gdk_imlib_make_pixmap", _wrap_gdk_imlib_make_pixmap, 1 }, + { "gdk_imlib_get_pixmap", _wrap_gdk_imlib_get_pixmap, 1 }, + { "gdk_imlib_render", _wrap_gdk_imlib_render, 1 }, + { "gdk_imlib_best_color_match", _wrap_gdk_imlib_best_color_match, 1 }, + { "gdk_imlib_load_image", _wrap_gdk_imlib_load_image, 1 }, + { "gdk_imlib_load_colors", _wrap_gdk_imlib_load_colors, 1 }, + { "gdk_imlib_set_render_type", _wrap_gdk_imlib_set_render_type, 1 }, + { "gdk_imlib_get_render_type", _wrap_gdk_imlib_get_render_type, 1 }, + { "gdk_imlib_init", _wrap_gdk_imlib_init, 1 }, + { NULL, NULL } +}; + +void init_gdkimlib() { + PyObject *m, *d, *private; + + m = Py_InitModule("_gdkimlib", _gdkimlibMethods); + d = PyModule_GetDict(m); + + PyDict_SetItemString(d, "GdkImlibImageType", + (PyObject *)&PyGdkImlibImage_Type); + + private = PyDict_New(); + PyDict_SetItemString(d, "_private", private); Py_DECREF(private); + + PyDict_SetItemString(private, "PyGdkImlibImage_New", + d=PyCObject_FromVoidPtr(PyGdkImlibImage_New, NULL)); + Py_DECREF(d); + + /* get types and exported functions out of _gtkmodule */ + m = PyImport_ImportModule("_gtk"); + d = PyModule_GetDict(m); + Py_DECREF(m); + + PyGtk_Type = (PyTypeObject *)PyDict_GetItemString(d, "GtkObjectType"); + Py_INCREF(PyGtk_Type); + PyGdkWindow_Type = (PyTypeObject *)PyDict_GetItemString(d,"GdkWindowType"); + Py_INCREF(PyGdkWindow_Type); + + d = PyDict_GetItemString(d, "_private"); + PyGtk_New = PyCObject_AsVoidPtr(PyDict_GetItemString(d, "PyGtk_New")); + PyGdkWindow_New = PyCObject_AsVoidPtr(PyDict_GetItemString(d, + "PyGdkWindow_New")); + + + if (PyErr_Occurred()) + Py_FatalError("can't initialise module _gdkimlib"); +} diff --git a/generate/.cvsignore b/generate/.cvsignore new file mode 100644 index 00000000..20cd74d3 --- /dev/null +++ b/generate/.cvsignore @@ -0,0 +1,7 @@ +Makefile.in +Makefile +*~ +*.pyc +*.pyo +*.ignore + diff --git a/generate/Makefile.am b/generate/Makefile.am new file mode 100644 index 00000000..681ec31a --- /dev/null +++ b/generate/Makefile.am @@ -0,0 +1,13 @@ +noinst_PYTHON = generate.py scmexpr.py + +EXTRA_DIST = gtk.defs gtkbase.defs gtkcontainers.defs gtkdata.defs \ + gtkedit.defs gtkenums.defs gtklists.defs gtkmenus.defs gtkmisc.defs \ + gtkranges.defs gtkdnd.defs gtk.ignore + +all: gtk.ignore + +gtk.ignore: ../gtkmodule.c + echo "# ignore list for gtkmodule" > gtk.ignore + echo "# (automatically generated)" >> gtk.ignore + sed -n 's/^.*_wrap_\([a-zA-Z_]*\),.*$$/\1/p' \ + < ../gtkmodule.c >> gtk.ignore
\ No newline at end of file diff --git a/generate/generate.py b/generate/generate.py new file mode 100644 index 00000000..df04981e --- /dev/null +++ b/generate/generate.py @@ -0,0 +1,411 @@ +import os +import string +import scmexpr +try: + from cStringIO import StringIO +except ImportError: + from StringIO import StringIO +# for fnmatchcase -- filename globbing +import fnmatch + +funcDefTmpl = ' { "%s", _wrap_%s, 1 },\n' +funcLeadTmpl = 'static PyObject *_wrap_%s(PyObject *self, PyObject *args) {\n' +enumCodeTmpl = ''' if (PyGtkEnum_get_value(%s, %s, (gint *)&%s)) + return NULL;\n''' +flagCodeTmpl = ''' if (PyGtkFlag_get_value(%s, %s, (gint *)&%s)) + return NULL;\n''' +setVarTmpl = ''' if (py_%s) + %s = %s;\n''' +getTypeTmpl = '''static PyObject *_wrap_%s(PyObject *self, PyObject *args) { + if (!PyArg_ParseTuple(args, ":%s")) + return NULL; + return PyInt_FromLong(%s()); +}\n\n''' + +convSpecialCases = { + 'GtkCList': '_GTK_CLIST', + 'GtkCTree': '_GTK_CTREE', + 'GtkCTreePos': '_GTK_CTREE_POS', + 'GtkCTreeLineStyle': '_GTK_CTREE_LINE_STYLE', + 'GtkCTreeExpanderStyle': '_GTK_CTREE_EXPANDER_STYLE', + 'GtkCTreeExpansionStyle': '_GTK_CTREE_EXPANSION_STYLE', + 'GnomeRootWin': '_GNOME_ROOTWIN', + 'GnomeAppBar': '_GNOME_APPBAR', + 'GnomeDEntryEdit': '_GNOME_DENTRY_EDIT', +} + +def toUpperStr(str): + """Converts a typename to the equivalent upercase and underscores + name. This is used to form the type conversion macros and enum/flag + name variables""" + if convSpecialCases.has_key(str): + return convSpecialCases[str] + ret = [] + while str: + if len(str) > 1 and str[0] in string.uppercase and \ + str[1] in string.lowercase: + ret.append("_" + str[:2]) + str = str[2:] + elif len(str) > 3 and \ + str[0] in string.lowercase and \ + str[1] in 'HV' and \ + str[2] in string.uppercase and \ + str[3] in string.lowercase: + ret.append(str[0] + "_" + str[1:3]) + str = str[3:] + elif len(str) > 2 and \ + str[0] in string.lowercase and \ + str[1] in string.uppercase and \ + str[2] in string.uppercase: + ret.append(str[0] + "_" + str[1]) + str = str[2:] + else: + ret.append(str[0]) + str = str[1:] + return string.upper(string.join(ret, '')) + +def enumName(typename): + """create a GTK_TYPE_* name from the given type""" + part = toUpperStr(typename) + if len(part) > 4 and part[:4] == '_GTK': + return 'GTK_TYPE' + part[4:] + else: + return 'GTK_TYPE' + part + +def conversionMacro(typename): + """get the conversion macro for the given type""" + return toUpperStr(typename)[1:] + +# a dictionary of known enum types ... +# the value is a cached copy of the GTK_TYPE name +enums = {} +# and flags ... +flags = {} + +# a dictionary of objects ... +# the values are the conversion macros +objects = {} + +# the known boxed types +boxed = { + 'GtkAccelGroup': ('PyGtkAccelGroup_Type', 'PyGtkAccelGroup_Get', + 'PyGtkAccelGroup_New'), + 'GtkStyle': ('PyGtkStyle_Type', 'PyGtkStyle_Get', 'PyGtkStyle_New'), + 'GdkFont': ('PyGdkFont_Type', 'PyGdkFont_Get', 'PyGdkFont_New'), + 'GdkColor': ('PyGdkColor_Type', 'PyGdkColor_Get', 'PyGdkColor_New'), + 'GdkEvent': ('PyGdkEvent_Type', 'PyGdkEvent_Get', 'PyGdkEvent_New'), + 'GdkWindow': ('PyGdkWindow_Type', 'PyGdkWindow_Get','PyGdkWindow_New'), + 'GdkPixmap': ('PyGdkWindow_Type', 'PyGdkWindow_Get','PyGdkWindow_New'), + 'GdkBitmap': ('PyGdkWindow_Type', 'PyGdkWindow_Get','PyGdkWindow_New'), + 'GdkDrawable':('PyGdkWindow_Type','PyGdkWindow_Get','PyGdkWindow_New'), + 'GdkGC': ('PyGdkGC_Type', 'PyGdkGC_Get', 'PyGdkGC_New'), + 'GdkColormap': ('PyGdkColormap_Type', 'PyGdkColormap_Get', + 'PyGdkColormap_New'), + 'GdkDragContext': ('PyGdkDragContext_Type', 'PyGdkDragContext_Get', + 'PyGdkDragContext_New'), + 'GtkSelectionData': ('PyGtkSelectionData_Type', + 'PyGtkSelectionData_Get', + 'PyGtkSelectionData_New'), + 'GdkAtom': ('PyGdkAtom_Type', 'PyGdkAtom_Get', 'PyGdkAtom_New'), + 'GdkCursor': ('PyGdkCursor_Type', 'PyGdkCursor_Get', + 'PyGdkCursor_New'), + 'GtkCTreeNode': ('PyGtkCTreeNode_Type', 'PyGtkCTreeNode_Get', + 'PyGtkCTreeNode_New'), +} + +class VarDefs: + def __init__(self): + self.vars = {} + def add(self, type, name): + if self.vars.has_key(type): + self.vars[type] = self.vars[type] + (name,) + else: + self.vars[type] = (name,) + def __str__(self): + ret = [] + for type in self.vars.keys(): + ret.append(' ') + ret.append(type) + ret.append(' ') + ret.append(string.join(self.vars[type], ', ')) + ret.append(';\n') + if ret: ret.append('\n') + return string.join(ret, '') + +class TypesParser(scmexpr.Parser): + """A parser that only parses definitions -- no output""" + def define_enum(self, name, *values): + if not enums.has_key(name): + enums[name] = enumName(name) + def define_flags(self, name, *values): + if not flags.has_key(name): + flags[name] = enumName(name) + def define_object(self, name, *args): + if not objects.has_key(name): + objects[name] = conversionMacro(name) + def define_boxed(self, name, reffunc=None, unreffunc=None, size=None): + if not boxed.has_key(name): + print "Warning --", name, "not supported" + def include(self, filename): + if filename[0] != '/': + # filename relative to file being parsed + afile = os.path.join(os.path.dirname(self.filename), + filename) + else: + afile = filename + if not os.path.exists(afile): + # fallback on PWD relative filename + afile = filename + #print "including file", afile + fp = open(afile) + self.startParsing(scmexpr.parse(fp)) + +class FunctionDefsParser(TypesParser): + def __init__(self, input, prefix='gtkmodule', typeprefix=''): + # typeprefix is set to & if type structs are not pointers + TypesParser.__init__(self, input) + self.impl = open(prefix + '_impl.c', "w") + self.defs = open(prefix + '_defs.c', "w") + self.tp = typeprefix + + def unknown(self, tup): + print "Unknown function:", (tup and tup[0] or "") + + def define_object(self, name, parent=(), fields=()): + TypesParser.define_object(self, name) + get_type = string.lower(objects[name]) + '_get_type' + self.defs.write(funcDefTmpl % (get_type,get_type)) + self.impl.write(getTypeTmpl % (get_type,get_type,get_type)) + + if fields and fields[0] == 'fields': + for retType, attrname in fields[1:]: + self.get_attr_func(name, retType, attrname) + + def get_attr_func(self, name, retType, attrname): + impl = StringIO() + funcName = string.lower(objects[name]) + '_get_' + attrname + impl.write(funcLeadTmpl % (funcName,)) + impl.write(' PyObject *obj;\n\n') + impl.write(' if (!PyArg_ParseTuple(args, "O!:') + impl.write(funcName) + impl.write('", ' + self.tp + 'PyGtk_Type, &obj))\n') + impl.write(' return NULL;\n') + funcCall = '%s(PyGtk_Get(obj))->%s' % (objects[name], attrname) + if self.decodeRet(impl, funcCall, retType): + return + impl.write('}\n\n') + # actually write the info to the output files + self.defs.write(funcDefTmpl % (funcName, funcName)) + self.impl.write(impl.getvalue()) + + def define_func(self, name, retType, args): + # we write to a temp file, in case any errors occur ... + impl = StringIO() + impl.write(funcLeadTmpl % (name,)) + varDefs = VarDefs() + parseStr = '' # PyArg_ParseTuple string + parseList = [] # args to PyArg_ParseTuple + argList = [] # args to actual function + extraCode = [] # any extra code (for enums, flags) + if retType == 'string': + # this is needed so we can free result string + varDefs.add('char', '*ret') + varDefs.add('PyObject', '*py_ret') + for arg in args: + argType = arg[0] + argName = arg[1] + # munge special names ... + if argName in ('default', 'if', 'then', 'else', + 'while', 'for', 'do', 'case', 'select'): + argName = '_' + argName + default = '' + if len(arg) > 2: + for a in arg[2:]: + if a[0] == '=': + default = ' = ' + a[1] + if '|' not in parseStr: + parseStr = parseStr+'|' + if argType == 'string': + varDefs.add('char', '*' + argName + default) + parseStr = parseStr + 's' + parseList.append('&' + argName) + argList.append(argName) + elif argType in ('char', 'uchar'): + varDefs.add('char', argName + default) + parseStr = parseStr + 'c' + parseList.append('&' + argName) + argList.append(argName) + elif argType in ('bool', 'int', 'uint', 'long', + 'ulong', 'guint', 'GdkAtom'): + # pretend atoms are integers for input ... + varDefs.add('int', argName + default) + parseStr = parseStr + 'i' + parseList.append('&' + argName) + argList.append(argName) + elif argType in ('float', 'double'): + varDefs.add('double', argName + default) + parseStr = parseStr + 'd' + parseList.append('&' + argName) + argList.append(argName) + elif argType == 'FILE': + varDefs.add('PyObject', '*' + argName+default) + parseStr = parseStr + 'O!' + parseList.append('&PyFile_Type') + parseList.append('&' + argName) + argList.append('PyFile_AsFile(' + + argName + ')') + elif argType in enums.keys(): + varDefs.add(argType, argName + default) + if default: + varDefs.add('PyObject', '*py_' + \ + argName + ' = NULL') + else: + varDefs.add('PyObject', '*py_'+argName) + parseStr = parseStr + 'O' + parseList.append('&py_' + argName) + argList.append(argName) + extraCode.append(enumCodeTmpl % + (enums[argType], + 'py_' + argName, + argName)) + elif argType in flags.keys(): + varDefs.add(argType, argName + default) + if default: + varDefs.add('PyObject', '*py_' + \ + argName + ' = NULL') + else: + varDefs.add('PyObject', '*py_'+argName) + parseStr = parseStr + 'O' + parseList.append('&py_' + argName) + argList.append(argName) + extraCode.append(flagCodeTmpl % + (flags[argType], + 'py_' + argName, + argName)) + elif argType in objects.keys(): + parseStr = parseStr + 'O!' + parseList.append(self.tp + 'PyGtk_Type') + if default: + varDefs.add('PyObject', '*py_' + + argName + ' = NULL') + varDefs.add(argType, '*' + argName + + default) + parseList.append('&py_' + argName) + extraCode.append(setVarTmpl % + (argName, argName, + objects[argType] + + '(PyGtk_Get(py_' + + argName + '))')) + argList.append(argName) + else: + varDefs.add('PyObject', '*' + argName) + parseList.append('&' + argName) + argList.append(objects[argType] + + '(PyGtk_Get(' + + argName + '))') + elif argType in boxed.keys(): + tp, get, new = boxed[argType] + varDefs.add('PyObject', '*' + argName) + parseStr = parseStr + 'O!' + parseList.append(self.tp + tp) + parseList.append('&' + argName) + argList.append(get + '(' + argName + ')') + else: + print "%s: unknown arg type '%s'" % (name, + argType) + return + + impl.write(str(varDefs)) + impl.write(' if (!PyArg_ParseTuple(args, "') + impl.write(parseStr) + impl.write(':') + impl.write(name) + impl.write('"') + if parseList: + impl.write(', ') + impl.write(string.join(parseList, ', ')) + impl.write('))\n return NULL;\n') + impl.write(string.join(extraCode, '')) + + funcCall = name + '(' + string.join(argList, ', ') + ')' + if self.decodeRet(impl, funcCall, retType): + return + impl.write('}\n\n') + # actually write the info to the output files + self.defs.write(funcDefTmpl % (name,name)) + self.impl.write(impl.getvalue()) + + def decodeRet(self, impl, funcCall, retType): + if retType == 'none': + impl.write(' ') + impl.write(funcCall) + impl.write(';\n Py_INCREF(Py_None);\n return Py_None;\n') + elif retType == 'static_string': + impl.write(' return PyString_FromString(') + impl.write(funcCall) + impl.write(');\n') + elif retType == 'string': + impl.write(' ret = ') + impl.write(funcCall) + impl.write(';\n py_ret = PyString_FromString(ret);\n g_free(ret);\n return py_ret;\n') + elif retType in ('char', 'uchar'): + impl.write(' return PyString_fromStringAndSize(*(') + impl.write(funcCall) + impl.write('));\n') + elif retType in ('bool','int','uint','long','ulong','guint') \ + or retType in enums.keys() or retType in flags.keys(): + impl.write(' return PyInt_FromLong(') + impl.write(funcCall) + impl.write(');\n') + elif retType in ('float','double'): + impl.write(' return PyFloat_FromDouble(') + impl.write(funcCall) + impl.write(');\n') + elif retType in boxed.keys(): + impl.write(' return ') + impl.write(boxed[retType][2]) + impl.write('(') + impl.write(funcCall) + impl.write(');\n') + elif retType in objects.keys(): + impl.write(' return PyGtk_New((GtkObject *)') + impl.write(funcCall) + impl.write(');\n') + else: + print "%s: unknown return type '%s'" % (name, retType) + return 1 + return 0 + +class FilteringParser(FunctionDefsParser): + """A refinement of FunctionDefsParser with some common filter types + built in""" + def __init__(self, input, prefix='gtkmodule', typeprefix=''): + FunctionDefsParser.__init__(self, input, prefix, typeprefix) + # hash lookups are pretty fast ... + self.excludeList = {} + self.excludeGlob = [] + def filter(self, name): + if self.excludeList.has_key(name): + return 0 + for glob in self.excludeGlob: + if fnmatch.fnmatchcase(name, glob): + return 0 + return 1 + def define_func(self, name, retType, args): + if self.filter(name): + FunctionDefsParser.define_func(self,name,retType,args) + else: + print "%s: filtered out" % (name) + def addExcludeFile(self, fname): + """Adds the function names from file fname to excludeList""" + lines = open(fname).readlines() + # remove \n from each line ... + lines = map(lambda x: x[:-1], lines) + # remove comments and blank lines ... + lines = filter(lambda x: x and x[0] != '#', lines) + for name in lines: + self.excludeList[name] = None + def addExcludeGlob(self, glob): + if glob not in self.excludeGlob: + self.excludeGlob.append(glob) + diff --git a/generate/gtk.defs b/generate/gtk.defs new file mode 100644 index 00000000..b1d4ab02 --- /dev/null +++ b/generate/gtk.defs @@ -0,0 +1,300 @@ +;; -*- scheme -*- + +;; These are snarfed from the GTK distribution. It needs to be updated from +;; time to time +(include "gtkenums.defs") + +;;; Boxed types +(define-boxed GtkAccelGroup + gtk_accel_group_ref + gtk_accel_group_unref) + +(define-boxed GtkStyle + gtk_style_ref + gtk_style_unref) + +(define-boxed GtkSelectionData + gtk_selection_copy + gtk_selection_free) + +(define-boxed GdkDragContext + gdk_drag_context_ref + gdk_drag_context_unref) + +(define-boxed GdkColormap + gdk_colormap_ref + gdk_colormap_unref) + +(define-boxed GdkFont + gdk_font_ref + gdk_font_unref) + +(define-boxed GdkWindow + gdk_window_ref + gdk_window_unref) +(define-boxed GdkPixmap + gdk_window_ref + gdk_window_unref) +(define-boxed GdkBitmap + gdk_window_ref + gdk_window_unref) +(define-boxed GdkDrawable + gdk_window_ref + gdk_window_unref) + +(define-boxed GdkEvent + gdk_event_copy + gdk_event_free + "sizeof(GdkEvent)") + +(define-boxed GdkColor + gdk_color_copy + gdk_color_free + "sizeof(GdkColor)") + +(define-boxed GdkGC + gdk_gc_ref + gdk_gc_unref) + +(define-boxed GdkCursor +) + +(define-boxed GtkCTreeNode +) + +;;; Gdk Functions +(define-func gdk_font_load + GdkFont + ((string name))) +(define-func gdk_fontset_load + GdkFont + ((string name))) + +(define-func gdk_draw_point + none + ((GdkDrawable drawable) + (GdkGC gc) + (int x) (int y))) +(define-func gdk_draw_line + none + ((GdkDrawable drawable) + (GdkGC gc) + (int x1) (int y1) + (int x2) (int y2))) +(define-func gdk_draw_rectangle + none + ((GdkDrawable drawable) + (GdkGC gc) + (int filled) + (int x) (int y) + (int width) (int height))) +(define-func gdk_draw_arc + none + ((GdkDrawable drawable) + (GdkGC gc) + (int filled) + (int x) (int y) + (int width) (int height) + (int angle1) (int angle2))) +; gdk_draw_polygon +(define-func gdk_draw_string + none + ((GdkDrawable drawable) + (GdkFont font) + (GdkGC gc) + (int x) (int y) + (string str))) +; gdk_draw_text +(define-func gdk_draw_pixmap + none + ((GdkDrawable drawable) + (GdkGC gc) + (GdkDrawable src) + (int xsrc) (int ysrc) + (int xdest) (int ydest) + (int width) (int height))) +;gdk_draw_points +;gdk_draw_segments +;gdk_draw_lines + +(define-func gdk_cursor_new + GdkCursor + ((GdkCursorType cursor_type))) + +(define-func gdk_cursor_new_from_pixmap + GdkCursor + ((GdkPixmap source) + (GdkBitmap mask) + (GdkColor fg) + (GdkColor bg) + (int x) (int y))) + +;; these two are used extensively -- define early +(define-object GtkObject (nil)) +(define-object GtkWidget (GtkObject)) + +; from gtktypeutils.h +(define-func gtk_type_from_name + uint + ((string name))) + +(define-func gtk_type_name + static_string + ((uint type))) + +;;; gtkmain.h +;; main + +(define-func gtk_exit + none + ((int code (= "0")))) + +(define-func gtk_main + none + ()) + +(define-func gtk_main_quit + none + ()) +;gtk_main_iteration + +(define-func gtk_set_locale + static_string + ()) + +(define-func gtk_quit_add_destroy + none + ((uint main_level) + (GtkObject object))) + +(define-func gtk_quit_remove + none + ((uint quit_id))) + +;gtk_timeout_add +(define-func gtk_timeout_remove + none + ((int tag))) + +;gtk_idle_add +(define-func gtk_idle_remove + none + ((int tag))) + +;gtk_input_add +(define-func gtk_input_remove + none + ((int tag))) + +(define-func gtk_events_pending + int + ()) + +;; gtkrc.h +(define-func gtk_rc_parse + none + ((string file))) +(define-func gtk_rc_parse_string + none + ((string rc_string))) +(define-func gtk_rc_reparse_all + none + ()) +(define-func gtk_rc_get_style + GtkStyle + ((GtkWidget widget))) +;(define-func gtk_rc_add_widget_name_style +; none +; ((GtkStyle style) +; (string pattern))) +;(define-func gtk_rc_add_widget_class_style +; none +; ((GtkStyle style) +; (string pattern))) +;(define-func gtk_rc_add_class_style +; none +; ((GtkStyle style) +; (string pattern))) + +;; gtkaccelgroup.h +(define-func gtk_accel_group_new + GtkAccelGroup + ()) +(define-func gtk_accel_group_get_default + GtkAccelGroup + ()) +(define-func gtk_accel_group_activate + bool + ((GtkAccelGroup group) + (uint key) + (GdkModifierType modifiers))) +(define-func gtk_accel_groups_activate + bool + ((GtkObject object) + (uint key) + (GdkModifierType modifiers))) +(define-func gtk_accel_group_attach + none + ((GtkAccelGroup group) + (GtkObject object))) +(define-func gtk_accel_group_detach + none + ((GtkAccelGroup group) + (GtkObject object))) +(define-func gtk_accel_group_lock + none + ((GtkAccelGroup group))) +(define-func gtk_accel_group_unlock + none + ((GtkAccelGroup group))) +(define-func gtk_accel_group_lock_entry + none + ((GtkAccelGroup group) + (uint key) + (GdkModifierType modifiers))) +(define-func gtk_accel_group_unlock_entry + none + ((GtkAccelGroup group) + (uint key) + (GdkModifierType modifiers))) +(define-func gtk_accel_group_add + none + ((GtkAccelGroup group) + (uint key) + (GdkModifierType modifiers) + (GtkAccelFlags flags) + (GtkObject object) + (string signal))) +(define-func gtk_accel_group_remove + none + ((GtkAccelGroup group) + (uint key) + (GdkModifierType modifiers) + (GtkObject object))) + +;; base functionality (GtkObject, signals, GtkWidget) +(include "gtkbase.defs") + +;; dnd and selection stuff ... +(include "gtkdnd.defs") + +;; descendents of GtkData (alignments, tooltips, etc) +(include "gtkdata.defs") + +;; all the different containers +(include "gtkcontainers.defs") + +;; all the rest ... +(include "gtkmisc.defs") + +;; trees/lists ... +(include "gtklists.defs") + +;; menus, menubars ... +(include "gtkmenus.defs") + +;; ranges, rulers, scrollbars ... +(include "gtkranges.defs") + +;; editable components ... +(include "gtkedit.defs") diff --git a/generate/gtkbase.defs b/generate/gtkbase.defs new file mode 100644 index 00000000..f82a29bc --- /dev/null +++ b/generate/gtkbase.defs @@ -0,0 +1,418 @@ +; -*- scheme -*- +;; gtkobject.h +(define-func GTK_OBJECT_FLAGS + GtkWidgetFlags + ((GtkObject object))) + +(define-func GTK_OBJECT_SET_FLAGS + none + ((GtkObject object) + (GtkWidgetFlags flags))) + +(define-func GTK_OBJECT_UNSET_FLAGS + none + ((GtkObject object) + (GtkWidgetFlags flags))) + +(define-func GTK_OBJECT_TYPE + uint + ((GtkObject object))) + +(define-func gtk_object_destroy + none + ((GtkObject object))) +;gtk_object_new +;gtk_object_set +;gtk_object_get +;gtk_object_set_data +;gtk_object_get_data +;gtk_object_remove_data + +(define-func GTK_CHECK_TYPE ; this is really from gtktypeutils.h ... + bool + ((GtkObject object) + (uint type))) + +; gtksignal.h + +;gtk_signal_connect +;gtk_signal_connect_after +(define-func gtk_signal_disconnect + none + ((GtkObject object) + (uint handler_id))) +;gtk_signal_disconnect_by_data +(define-func gtk_signal_emit_stop_by_name + none + ((GtkObject object) + (string name))) +(define-func gtk_signal_handler_block + none + ((GtkObject object) + (uint id))) +(define-func gtk_signal_handler_unblock + none + ((GtkObject object) + (uint id))) +(define-func gtk_signal_handlers_destroy + none + ((GtkObject object))) + +;; Data + +(define-object GtkData (GtkObject)) + +;; Adjustment + +(define-object GtkAdjustment (GtkData) + (fields + (float value) + (float lower) + (float upper) + (float step_increment) + (float page_increment) + (float page_size))) + +(define-func gtk_adjustment_new + GtkObject + ((float value) + (float lower) + (float upper) + (float step_increment) + (float page_increment) + (float page_size))) + +(define-func gtk_adjustment_changed + none + ((GtkAdjustment adjustment))) + +(define-func gtk_adjustment_value_changed + none + ((GtkAdjustment adjustment))) + +(define-func gtk_adjustment_clamp_page + none + ((GtkAdjustment adjustment) + (float lower) + (float upper))) + +(define-func gtk_adjustment_set_value + none + ((GtkAdjustment adjustment) + (float value))) + +; gtkwidget.h + +(define-func gtk_widget_destroy + none + ((GtkWidget widget))) + +(define-func gtk_widget_unparent + none + ((GtkWidget widget))) + +(define-func gtk_widget_show + none + ((GtkWidget widget))) + +(define-func gtk_widget_show_now + none + ((GtkWidget widget))) + +(define-func gtk_widget_hide + none + ((GtkWidget widget))) + +(define-func gtk_widget_show_all + none + ((GtkWidget widget))) + +(define-func gtk_widget_hide_all + none + ((GtkWidget widget))) + +(define-func gtk_widget_map + none + ((GtkWidget widget))) + +(define-func gtk_widget_unmap + none + ((GtkWidget widget))) + +(define-func gtk_widget_realize + none + ((GtkWidget widget))) + +(define-func gtk_widget_unrealize + none + ((GtkWidget widget))) + +(define-func gtk_widget_queue_draw + none + ((GtkWidget widget))) + +(define-func gtk_widget_queue_resize + none + ((GtkWidget widget))) + +(define-func gtk_widget_draw_focus + none + ((GtkWidget widget))) + +(define-func gtk_widget_draw_default + none + ((GtkWidget widget))) + +;gtk_widget_size_request +;gtk_widget_size_allocate + +(define-func gtk_widget_add_accelerator + none + ((GtkWidget widget) + (string signal_name) + (GtkAccelGroup group) + (uint key) + (GdkModifierType modifiers) + (GtkAccelFlags flags))) + +(define-func gtk_widget_remove_accelerator + none + ((GtkWidget widget) + (GtkAccelGroup group) + (uint key) + (GdkModifierType modifiers))) + +(define-func gtk_widget_remove_accelerators + none + ((GtkWidget widget) + (string signal_name) + (bool visible_only))) + +(define-func gtk_widget_accelerator_signal + uint + ((GtkWidget widget) + (GtkAccelGroup group) + (uint key) + (GdkModifierType modifiers))) + +(define-func gtk_widget_lock_accelerators + none + ((GtkWidget widget))) + +(define-func gtk_widget_unlock_accelerators + none + ((GtkWidget widget))) + +(define-func gtk_widget_event + bool + ((GtkWidget widget) + (GdkEvent event))) + +(define-func gtk_widget_activate + bool + ((GtkWidget widget))) + +(define-func gtk_widget_set_scroll_adjustments + bool + ((GtkWidget widget) + (GtkAdjustment hadjustment) + (GtkAdjustment vadjustment))) + +(define-func gtk_widget_reparent + none + ((GtkWidget widget) + (GtkWidget new_parent))) + +(define-func gtk_widget_popup + none + ((GtkWidget widget) + (int x) + (int y))) + +;gtk_widget_intersect + +(define-func gtk_widget_grab_focus + none + ((GtkWidget widget))) + +(define-func gtk_widget_grab_default + none + ((GtkWidget widget))) + +(define-func gtk_widget_set_name + none + ((GtkWidget widget) + (string name))) + +(define-func gtk_widget_get_name + static_string + ((GtkWidget widget))) + +(define-func gtk_widget_set_state + none + ((GtkWidget widget) + (GtkStateType state))) + +(define-func gtk_widget_set_sensitive + none + ((GtkWidget widget) + (bool sensitive))) + +(define-func gtk_widget_set_parent + none + ((GtkWidget widget) + (GtkWidget parent))) + +(define-func gtk_widget_set_parent_window + none + ((GtkWidget widget) + (GdkWindow parent_window))) + +(define-func gtk_widget_get_parent_window + GdkWindow + ((GtkWidget widget))) + +(define-func gtk_widget_set_uposition + none + ((GtkWidget widget) + (int x) + (int y))) + +(define-func gtk_widget_set_usize + none + ((GtkWidget widget) + (int height) + (int width))) + +(define-func gtk_widget_set_events + none + ((GtkWidget widget) + (GdkEventMask events))) + +(define-func gtk_widget_add_events + none + ((GtkWidget widget) + (GdkEventMask events))) + +(define-func gtk_widget_set_extension_events + none + ((GtkWidget widget) + (GdkEventMask events))) + +(define-func gtk_widget_get_extension_events + GdkEventMask + ((GtkWidget widget))) + +(define-func gtk_widget_get_toplevel + GtkWidget + ((GtkWidget widget))) + +(define-func gtk_widget_get_ancestor + GtkWidget + ((GtkWidget widget) + (uint type))) + +(define-func gtk_widget_get_colormap + GdkColormap + ((GtkWidget widget))) + +(define-func gtk_widget_get_events + GdkEventMask + ((GtkWidget widget))) + +;gtk_widget_get_pointer + +(define-func gtk_widget_is_ancestor + bool + ((GtkWidget widget) + (GtkWidget ancestor))) + +(define-func gtk_widget_hide_on_delete + int + ((GtkWidget widget))) + +(define-func gtk_widget_set_style + none + ((GtkWidget widget) + (GtkStyle style))) + +(define-func gtk_widget_set_rc_style + none + ((GtkWidget widget))) + +(define-func gtk_widget_ensure_style + none + ((GtkWidget widget))) + +(define-func gtk_widget_get_style + GtkStyle + ((GtkWidget widget))) + +(define-func gtk_widget_restore_default_style + none + ((GtkWidget widget))) + +(define-func gtk_widget_set_composite_name + none + ((GtkWidget widget) + (string name))) + +(define-func gtk_widget_get_composite_name + string + ((GtkWidget widget))) + +(define-func gtk_widget_reset_rc_styles + none + ((GtkWidget widget))) + +(define-func gtk_widget_push_style + none + ((GtkStyle style))) + +(define-func gtk_widget_push_colormap + none + ((GdkColormap cmap))) + +(define-func gtk_widget_pop_style + none + ()) + +(define-func gtk_widget_pop_colormap + none + ()) + +(define-func gtk_widget_set_default_style + none + ((GtkStyle style))) + +(define-func gtk_widget_set_default_colormap + none + ((GdkColormap cmap))) + +(define-func gtk_widget_get_default_style + GtkStyle + ()) + +(define-func gtk_widget_get_default_colormap + GdkColormap + ()) + +; shaped widgets ... +(define-func gtk_widget_shape_combine_mask + none + ((GtkWidget widget) + (GdkBitmap mask) + (int ofs_x) (int ofs_y))) + +; these are in gtkmain.h ... +(define-func gtk_grab_add + none + ((GtkWidget widget))) + +(define-func gtk_grab_get_current + GtkWidget + ()) + +(define-func gtk_grab_remove + none + ((GtkWidget widget)))
\ No newline at end of file diff --git a/generate/gtkcontainers.defs b/generate/gtkcontainers.defs new file mode 100644 index 00000000..d9cd2f57 --- /dev/null +++ b/generate/gtkcontainers.defs @@ -0,0 +1,921 @@ +; -*- scheme -*- + +(define-object GtkContainer (GtkWidget)) + +(define-func gtk_container_set_border_width + none + ((GtkContainer container) + (int border_width))) + +(define-func gtk_container_add + none + ((GtkContainer container) + (GtkWidget widget))) + +(define-func gtk_container_remove + none + ((GtkContainer container) + (GtkWidget widget))) + +(define-func gtk_container_set_resize_mode + none + ((GtkContainer container) + (GtkResizeMode resize_mode))) + +(define-func gtk_container_check_resize + none + ((GtkContainer container))) + +;gtk_container_children + +(define-func gtk_container_child_composite_name + string + ((GtkContainer container) + (GtkWidget child))) + +(define-func gtk_container_focus + int + ((GtkContainer container) + (GtkDirectionType direction))) + +(define-func gtk_container_set_focus_child + none + ((GtkContainer container) + (GtkWidget child))) + +(define-func gtk_container_set_focus_vadjustment + none + ((GtkContainer container) + (GtkAdjustment adjustment))) + +(define-func gtk_container_set_focus_hadjustment + none + ((GtkContainer container) + (GtkAdjustment adjustment))) + +(define-func gtk_container_register_toplevel + none + ((GtkContainer container))) + +(define-func gtk_container_unregister_toplevel + none + ((GtkContainer container))) + +(define-func gtk_container_resize_children + none + ((GtkContainer container))) + +(define-func gtk_container_child_type + uint + ((GtkContainer container))) + +;gtk_container_child_set +;gtk_container_child_get + +;;; Fixed + +(define-object GtkFixed (GtkContainer)) + +(define-func gtk_fixed_new + GtkWidget + ()) + +(define-func gtk_fixed_put + none + ((GtkFixed fixed) + (GtkWidget widget) + (int x) + (int y))) + +(define-func gtk_fixed_move + none + ((GtkFixed fixed) + (GtkWidget widget) + (int x) + (int y))) + +;;; Bin + +(define-object GtkBin (GtkContainer)) + +;;; Event Box + +(define-object GtkEventBox (GtkBin)) + +(define-func gtk_event_box_new + GtkWidget + ()) + +;;; Window + +(define-object GtkWindow (GtkBin)) + +(define-func gtk_window_new + GtkWidget + ((GtkWindowType type))) + +(define-func gtk_window_set_title + none + ((GtkWindow window) + (string title))) + +(define-func gtk_window_set_wmclass + none + ((GtkWindow window) + (string wmclass_class) + (string wmclass_name))) + +(define-func gtk_window_set_focus + none + ((GtkWindow window) + (GtkWidget focus))) + +(define-func gtk_window_set_default + none + ((GtkWindow window) + (GtkWidget default))) + +(define-func gtk_window_set_policy + none + ((GtkWindow window) + (bool allow_shrink) + (bool allow_grow) + (bool auto_shrink))) + +(define-func gtk_window_add_accel_group + none + ((GtkWindow window) + (GtkAccelGroup group))) + +(define-func gtk_window_remove_accel_group + none + ((GtkWindow window) + (GtkAccelGroup group))) + +(define-func gtk_window_set_position + none + ((GtkWindow window) + (GtkWindowPosition position))) + +(define-func gtk_window_activate_focus + int + ((GtkWindow window))) + +(define-func gtk_window_activate_default + int + ((GtkWindow window))) + +(define-func gtk_window_set_modal + none + ((GtkWindow window) + (bool modal))) + +;; DrawWindow + +(define-object GtkDrawWindow (GtkWindow)) + +(define-func gtk_draw_window_new + GtkWidget + ((GtkWindowType type))) + +;; Dialog + +(define-object GtkDialog (GtkWindow) + (fields + (GtkWidget vbox) + (GtkWidget action_area))) + +(define-func gtk_dialog_new + GtkWidget + ()) + +;;; HandleBox + +(define-object GtkHandleBox (GtkBin)) + +(define-func gtk_handle_box_new + GtkWidget + ()) + +(define-func gtk_handle_box_set_shadow_type + none + ((GtkHandleBox handle_box) + (GtkShadowType type))) + +;;; Box + +(define-object GtkBox (GtkContainer)) + +(define-func gtk_box_pack_start + none + ((GtkBox box) + (GtkWidget child) + (bool expand (= "TRUE")) + (bool fill (= "TRUE")) + (int padding (= "0")))) + +(define-func gtk_box_pack_end + none + ((GtkBox box) + (GtkWidget child) + (bool expand (= "TRUE")) + (bool fill (= "TRUE")) + (int padding (= "0")))) + +(define-func gtk_box_pack_start_defaults + none + ((GtkBox box) + (GtkWidget child))) + +(define-func gtk_box_pack_end_defaults + none + ((GtkBox box) + (GtkWidget child))) + +(define-func gtk_box_set_homogeneous + none + ((GtkBox box) + (bool homogenous))) + +(define-func gtk_box_set_spacing + none + ((GtkBox box) + (int spacing))) + +(define-func gtk_box_reorder_child + none + ((GtkBox box) + (GtkWidget child) + (uint pos))) + +;gtk_box_query_child_packing + +(define-func gtk_box_set_child_packing + none + ((GtkBox box) + (GtkWidget child) + (bool expand) + (bool fill) + (int padding) + (GtkPackType pack_type))) + +(define-object GtkHBox (GtkBox)) +(define-func gtk_hbox_new + GtkWidget + ((int homogeneous) (int spacing))) + +(define-object GtkVBox (GtkBox)) +(define-func gtk_vbox_new + GtkWidget + ((int homogeneous) (int spacing))) + +;;; ButtonBox + +(define-object GtkButtonBox (GtkBox)) + +;; XXX - needs multiple return values +;; (define-func gtk_button_box_get_child_size_default) + +;; XXX - needs multiple return values +;; (define-func gtk_button_box_get_child_ipadding_default) + +(define-func gtk_button_box_set_child_size_default + none + ((int min_width) + (int min_height))) + +(define-func gtk_button_box_set_child_ipadding_default + none + ((int ipad_x) + (int ipad_y))) + +(define-func gtk_button_box_get_spacing + int + ((GtkButtonBox widget))) + +(define-func gtk_button_box_get_layout + GtkButtonBoxStyle + ((GtkButtonBox widget))) + +;; XXX - needs multiple return values +;; (define-func gtk_button_box_get_child_size) + +;; XXX - needs multiple return values +;; (define-func gtk_button_box_get_child_ipadding) + +(define-func gtk_button_box_set_spacing + none + ((GtkButtonBox widget) + (int spacing))) + +(define-func gtk_button_box_set_layout + none + ((GtkButtonBox widget) + (GtkButtonBoxStyle layout_style))) + +(define-func gtk_button_box_set_child_size + none + ((GtkButtonBox widget) + (int min_width) + (int min_height))) + +(define-func gtk_button_box_set_child_ipadding + none + ((GtkButtonBox widget) + (int ipad_x) + (int ipad_y))) + +;;; HButtonBox + +(define-object GtkHButtonBox (GtkButtonBox)) + +(define-func gtk_hbutton_box_new + GtkWidget + ()) + +(define-func gtk_hbutton_box_get_spacing_default + int + ()) + +(define-func gtk_hbutton_box_get_layout_default + GtkButtonBoxStyle + ()) + +(define-func gtk_hbutton_box_set_spacing_default + none + ((int spacing))) + +(define-func gtk_hbutton_box_set_layout_default + none + ((GtkButtonBoxStyle layout))) + +;;; HVuttonBox + +(define-object GtkVButtonBox (GtkButtonBox)) + +(define-func gtk_vbutton_box_new + GtkWidget + ()) + +(define-func gtk_vbutton_box_get_spacing_default + int + ()) + +(define-func gtk_vbutton_box_get_layout_default + GtkButtonBoxStyle + ()) + +(define-func gtk_vbutton_box_set_spacing_default + none + ((int spacing))) + +(define-func gtk_vbutton_box_set_layout_default + none + ((GtkButtonBoxStyle layout))) + +;;; Table + +(define-object GtkTable (GtkContainer)) + +(define-func gtk_table_new + GtkWidget + ((int rows) + (int columns) + (bool homogenous))) + +(define-func gtk_table_attach + none + ((GtkTable table) + (GtkWidget child) + (int left_attach) + (int right_attach) + (int top_attach) + (int bottom_attach) + (GtkAttachOptions xoptions (= "GTK_EXPAND|GTK_FILL")) + (GtkAttachOptions yoptions (= "GTK_EXPAND|GTK_FILL")) + (int xpadding (= "0")) + (int ypadding (= "0")))) + +(define-func gtk_table_attach_defaults + none + ((GtkTable table) + (GtkWidget child) + (int left_attach) + (int right_attach) + (int top_attach) + (int bottom_attach))) + +(define-func gtk_table_set_row_spacing + none + ((GtkTable table) + (int row) + (int spacing))) + +(define-func gtk_table_set_col_spacing + none + ((GtkTable table) + (int column) + (int spacing))) + +(define-func gtk_table_set_row_spacings + none + ((GtkTable table) + (int spacing))) + +(define-func gtk_table_set_col_spacings + none + ((GtkTable table) + (int spacing))) + +(define-func gtk_table_set_homogeneous + none + ((GtkTable table) + (bool homogeneous))) + +;; Packer + +(define-object GtkPacker (GtkContainer)) + +(define-func gtk_packer_new + GtkWidget + ()) + +(define-func gtk_packer_add_defaults + none + ((GtkPacker packer) + (GtkWidget child) + (GtkSideType side) + (GtkAnchorType anchor) + (GtkPackerOptions options))) + +(define-func gtk_packer_add + none + ((GtkPacker packer) + (GtkWidget child) + (GtkSideType side) + (GtkAnchorType anchor) + (GtkPackerOptions options) + (uint border_width (= "0")) + (uint pad_x (= "0")) (uint pad_y (= "0")) + (uint ipad_x (= "0")) (uint ipad_y (= "0")))) + +(define-func gtk_packer_set_child_packing + none + ((GtkPacker packer) + (GtkWidget child) + (GtkSideType size) + (GtkAnchorType anchor) + (GtkPackerOptions options) + (uint border_width (= "0")) + (uint pad_x (= "0")) (uint pad_y (= "0")) + (uint ipad_x (= "0")) (uint ipad_y (= "0")))) + +(define-func gtk_packer_reorder_child + none + ((GtkPacker packer) + (GtkWidget widget) + (int position))) + +(define-func gtk_packer_set_spacing + none + ((GtkPacker packer) + (uint spacing))) + +(define-func gtk_packer_set_default_border_width + none + ((GtkPacker packer) + (uint border))) + +(define-func gtk_packer_set_default_pad + none + ((GtkPacker packer) + (uint pad_x) (uint pad_y))) + +(define-func gtk_packer_set_default_ipad + none + ((GtkPacker packer) + (uint ipad_x) (uint ipad_y))) + + +;; Panes + +(define-object GtkPaned (GtkContainer)) + +(define-func gtk_paned_add1 + none + ((GtkPaned paned) + (GtkWidget child))) + +(define-func gtk_paned_add2 + none + ((GtkPaned paned) + (GtkWidget child))) + +(define-func gtk_paned_set_handle_size + none + ((GtkPaned paned) + (uint size))) + +(define-func gtk_paned_set_gutter_size + none + ((GtkPaned paned) + (uint size))) + +(define-object GtkHPaned (GtkPaned)) +(define-func gtk_hpaned_new + GtkWidget + ()) + +(define-object GtkVPaned (GtkPaned)) +(define-func gtk_vpaned_new + GtkWidget + ()) + +;; Frame + +(define-object GtkFrame (GtkBin)) + +(define-func gtk_frame_new + GtkWidget + ((string label (null-ok)))) + +(define-func gtk_frame_set_label + none + ((GtkFrame frame) + (string label))) + +(define-func gtk_frame_set_label_align + none + ((GtkFrame frame) + (float xalign) + (float yalign))) + +(define-func gtk_frame_set_shadow_type + none + ((GtkFrame frame) + (GtkShadowType type))) + +;; Aspect Frame + +(define-object GtkAspectFrame (GtkFrame)) + +(define-func gtk_aspect_frame_new + GtkWidget + ((string label) + (float xalign) + (float yalign) + (float ratio) + (int obey_child))) + +(define-func gtk_aspect_frame_set + none + ((GtkAspectFrame aspect_frame) + (float xalign) + (float yalign) + (float ratio) + (int obey_child))) + +;;; Viewport + +(define-object GtkViewport (GtkBin)) + +(define-func gtk_viewport_new + GtkWidget + ((GtkAdjustment hadjustment) + (GtkAdjustment vadjustment))) + +(define-func gtk_viewport_get_hadjustment + GtkAdjustment + ((GtkViewport viewport))) + +(define-func gtk_viewport_get_vadjustment + GtkAdjustment + ((GtkViewport viewport))) + +(define-func gtk_viewport_set_hadjustment + none + ((GtkViewport viewport) + (GtkAdjustment adjustment))) + +(define-func gtk_viewport_set_vadjustment + none + ((GtkViewport viewport) + (GtkAdjustment adjustment))) + +(define-func gtk_viewport_set_shadow_type + none + ((GtkViewport viewport) + (GtkShadowType type))) + +;; ScrolledWidow + +(define-object GtkScrolledWindow (GtkContainer)) + +(define-func gtk_scrolled_window_new + GtkWidget + ((GtkAdjustment hadjustment (null-ok) (= "NULL")) + (GtkAdjustment vadjustment (null-ok) (= "NULL")))) + +(define-func gtk_scrolled_window_set_hadjustment + none + ((GtkScrolledWindow scrolled_window) + (GtkAdjustment adjustment))) + +(define-func gtk_scrolled_window_set_vadjustment + none + ((GtkScrolledWindow scrolled_window) + (GtkAdjustment adjustment))) + +(define-func gtk_scrolled_window_get_hadjustment + GtkAdjustment + ((GtkScrolledWindow scrolled_window))) + +(define-func gtk_scrolled_window_get_vadjustment + GtkAdjustment + ((GtkScrolledWindow scrolled_window))) + +(define-func gtk_scrolled_window_set_policy + none + ((GtkScrolledWindow scrolled_window) + (GtkPolicyType hscrollbar_policy) + (GtkPolicyType vscrollbar_policy))) + +(define-func gtk_scrolled_window_set_placement + none + ((GtkScrolledWindow scrolled_window) + (GtkCornerType window_placement))) + +(define-func gtk_scrolled_window_add_with_viewport + none + ((GtkScrolledWindow scrolled_window) + (GtkWidget child))) + +;; Notebook + +(define-object GtkNotebook (GtkContainer) + (fields + (GtkPositionType tab_pos))) + +(define-func gtk_notebook_new + GtkWidget + ()) + +(define-func gtk_notebook_append_page + none + ((GtkNotebook notebook) + (GtkWidget child) + (GtkWidget tab_label))) + +(define-func gtk_notebook_append_page_menu + none + ((GtkNotebook notebook) + (GtkWidget child) + (GtkWidget tab_label) + (GtkWidget menu_label))) + +(define-func gtk_notebook_prepend_page + none + ((GtkNotebook notebook) + (GtkWidget child) + (GtkWidget tab_label))) + +(define-func gtk_notebook_prepend_page_menu + none + ((GtkNotebook notebook) + (GtkWidget child) + (GtkWidget tab_label) + (GtkWidget menu_label))) + +(define-func gtk_notebook_insert_page + none + ((GtkNotebook notebook) + (GtkWidget child) + (GtkWidget tab_label) + (int position))) + +(define-func gtk_notebook_insert_page_menu + none + ((GtkNotebook notebook) + (GtkWidget child) + (GtkWidget tab_label) + (GtkWidget menu_label) + (int position))) + +(define-func gtk_notebook_remove_page + none + ((GtkNotebook notebook) + (int page_num))) + +(define-func gtk_notebook_get_current_page + int + ((GtkNotebook notebook))) + +(define-func gtk_notebook_get_nth_page + GtkWidget + ((GtkNotebook notebook) + (int page_num))) + +(define-func gtk_notebook_page_num + int + ((GtkNotebook notebook) + (GtkWidget page))) + +(define-func gtk_notebook_set_page + none + ((GtkNotebook notebook) + (int page_num))) + +(define-func gtk_notebook_next_page + none + ((GtkNotebook notebook))) + +(define-func gtk_notebook_prev_page + none + ((GtkNotebook notebook))) + +(define-func gtk_notebook_reorder_child + none + ((GtkNotebook notebook) + (GtkWidget child) + (int position))) + +(define-func gtk_notebook_set_tab_pos + none + ((GtkNotebook notebook) + (GtkPositionType pos))) + +(define-func gtk_notebook_set_show_tabs + none + ((GtkNotebook notebook) + (bool show_tabs))) + +(define-func gtk_notebook_set_show_border + none + ((GtkNotebook notebook) + (bool show_border))) + +(define-func gtk_notebook_set_scrollable + none + ((GtkNotebook notebook) + (int scrollable))) + +(define-func gtk_notebook_set_homogeneous_tabs + none + ((GtkNotebook notebook) + (bool homogeneous))) + +(define-func gtk_notebook_set_tab_border + none + ((GtkNotebook notebook) + (int border_width))) + +(define-func gtk_notebook_set_tab_hborder + none + ((GtkNotebook notebook) + (uint tab_hborder))) + +(define-func gtk_notebook_set_tab_vborder + none + ((GtkNotebook notebook) + (uint tab_vborder))) + +(define-func gtk_notebook_popup_enable + none + ((GtkNotebook notebook))) + +(define-func gtk_notebook_popup_disable + none + ((GtkNotebook notebook))) + +(define-func gtk_notebook_get_tab_label + GtkWidget + ((GtkNotebook notebook) + (GtkWidget child))) + +(define-func gtk_notebook_set_tab_label + none + ((GtkNotebook notebook) + (GtkWidget child) + (GtkWidget tab_label))) + +(define-func gtk_notebook_set_tab_label_text + none + ((GtkNotebook notebook) + (GtkWidget child) + (string tab_text))) + +(define-func gtk_notebook_get_menu_label + GtkWidget + ((GtkNotebook notebook) + (GtkWidget child))) + +(define-func gtk_notebook_set_menu_label + none + ((GtkNotebook notebook) + (GtkWidget child) + (GtkWidget menu_label))) + +(define-func gtk_notebook_set_menu_label_text + none + ((GtkNotebook notebook) + (GtkWidget child) + (string menu_text))) + +; gtk_notebook_query_tab_label_packing +(define-func gtk_notebook_set_tab_label_packing + none + ((GtkNotebook notebook) + (GtkWidget child) + (bool expand) + (bool fill) + (GtkPackType pack_type))) + +;; Alignment + +(define-object GtkAlignment (GtkBin)) + +(define-func gtk_alignment_new + GtkWidget + ((float xalign) + (float yalign) + (float xscale) + (float yscale))) + +(define-func gtk_alignment_set + none + ((GtkAlignment alignment) + (float xalign) + (float yalign) + (float xscale) + (float yscale))) + +;; gtklayout.h +(define-object GtkLayout (GtkContainer)) + +(define-func gtk_layout_new + GtkWidget + ((GtkAdjustment hadjustment (= "NULL")) + (GtkAdjustment vadjustment (= "NULL")))) + +(define-func gtk_layout_put + none + ((GtkLayout layout) + (GtkWidget child) + (int x) (int y))) + +(define-func gtk_layout_move + none + ((GtkLayout layout) + (GtkWidget child) + (int x) (int y))) + +(define-func gtk_layout_set_size + none + ((GtkLayout layout) + (uint width) (uint height))) + +(define-func gtk_layout_freeze + none + ((GtkLayout layout))) + +(define-func gtk_layout_thaw + none + ((GtkLayout layout))) + +(define-func gtk_layout_get_hadjustment + GtkAdjustment + ((GtkLayout layout))) + +(define-func gtk_layout_get_vadjustment + GtkAdjustment + ((GtkLayout layout))) + +(define-func gtk_layout_set_hadjustment + none + ((GtkLayout layout) + (GtkAdjustment adjustment))) + +(define-func gtk_layout_set_vadjustment + none + ((GtkLayout layout) + (GtkAdjustment adjustment))) + +;; gtk-plug.h +(define-object GtkPlug (GtkWindow)) + +(define-func gtk_plug_new + GtkWidget + ((uint socket_id))) + +;; gtk-socket.h +(define-object GtkSocket (GtkContainerClass)) + +(define-func gtk_socket_new + GtkWidget + ()) + +(define-func gtk_socket_steal + none + ((GtkSocket socket) + (uint window_id))) + diff --git a/generate/gtkdata.defs b/generate/gtkdata.defs new file mode 100644 index 00000000..5c58b140 --- /dev/null +++ b/generate/gtkdata.defs @@ -0,0 +1,42 @@ +; -*- scheme -*- + +;; GtkData and GtkAdjustment are defined in gtkbase.defs now. + +; Tooltips ... +(define-object GtkTooltips (GtkData)) + +(define-func gtk_tooltips_new + GtkTooltips + ()) + +(define-func gtk_tooltips_enable + none + ((GtkTooltips tooltips))) + +(define-func gtk_tooltips_disable + none + ((GtkTooltips tooltips))) + +(define-func gtk_tooltips_set_delay + none + ((GtkTooltips tooltips) + (int delay))) + +(define-func gtk_tooltips_set_tip + none + ((GtkTooltips tooltips) + (GtkWidget widget) + (string tip_text (null-ok)) + (string tip_private))) + +(define-func gtk_tooltips_set_colors + none + ((GtkTooltips tooltips) + (GdkColor background) + (GdkColor foreground))) + +(define-func gtk_tooltips_force_window + none + ((GtkTooltips tooltips))) + + diff --git a/generate/gtkdnd.defs b/generate/gtkdnd.defs new file mode 100644 index 00000000..c045b2a8 --- /dev/null +++ b/generate/gtkdnd.defs @@ -0,0 +1,115 @@ +; -*- scheme -*- + +;; DnD functions ... + +(define-func gtk_drag_get_data + none + ((GtkWidget widget) + (GdkDragContext context) + (GdkAtom target) + (uint time))) + +(define-func gtk_drag_finish + none + ((GdkDragContext context) + (bool success) + (bool del) + (uint time))) + +(define-func gtk_drag_get_source_widget + GtkWidget + ((GdkDragContext context))) + +(define-func gtk_drag_highlight + none + ((GtkWidget widget))) + +(define-func gtk_drag_unhighlight + none + ((GtkWidget widget))) + +;; gtk_drag_dest_set + +(define-func gtk_drag_dest_set_proxy + none + ((GtkWidget widget) + (GdkWindow proxy_window) + (GdkDragProtocol protocol) + (bool use_coordinates))) + +(define-func gtk_drag_dest_unset + none + ((GtkWidget widget))) + +;; gtk_drag_source_set + +(define-func gtk_drag_source_set_icon + none + ((GtkWidget widget) + (GdkColormap colormap) + (GdkPixmap pixmap) + (GdkBitmap mask))) + +;; gtk_drag_begin + +(define-func gtk_drag_set_icon_widget + none + ((GdkDragContext context) + (GtkWidget widget) + (int hot_x) (int hot_y))) + +(define-func gtk_drag_set_icon_pixmap + none + ((GdkDragContext context) + (GdkColormap colormap) + (GdkPixmap pixmap) + (GdkBitmap mask) + (int hot_x) (int hot_y))) + +(define-func gtk_drag_set_icon_default + none + ((GdkDragContext context))) + +(define-func gtk_drag_set_default_icon + none + ((GdkColormap colormap) + (GdkPixmap pixmap) + (GdkBitmap mask) + (int hot_x) (int hot_y))) + +;; Selection functions ... + +(define-func gdk_atom_intern + GdkAtom + ((string atom_name) + (int only_if_exists (= "FALSE")))) + +(define-func gdk_atom_name + string + ((GdkAtom atom))) + +(define-func gtk_selection_owner_set + int + ((GtkWidget widget) + (GdkAtom selection) + (uint time))) + +(define-func gtk_selection_add_target + none + ((GtkWidget widget) + (GdkAtom selection) + (GdkAtom target) + (uint info))) + +(define-func gtk_selection_convert + int + ((GtkWidget widget) + (GdkAtom selection) + (GdkAtom target) + (uint time))) + +;; gtk_selection_data_set -- implemented as method in pygtk. + +(define-func gtk_selection_remove_all + none + ((GtkWidget widget)))
\ No newline at end of file diff --git a/generate/gtkedit.defs b/generate/gtkedit.defs new file mode 100644 index 00000000..d5e18165 --- /dev/null +++ b/generate/gtkedit.defs @@ -0,0 +1,260 @@ +; -*- scheme -*- +;; Editable + +(define-object GtkEditable (GtkWidget)) + +(define-func gtk_editable_select_region + none + ((GtkEditable editable) + (int start) (int end))) + +;gtk_editable_insert_text +(define-func gtk_editable_delete_text + none + ((GtkEditable editable) + (int start) (int end))) + +(define-func gtk_editable_get_chars + string + ((GtkEditable editable) + (int start) (int end))) + +(define-func gtk_editable_cut_clipboard + none + ((GtkEditable edtiable))) + +(define-func gtk_editable_copy_clipboard + none + ((GtkEditable editable))) + +(define-func gtk_editable_paste_clipboard + none + ((GtkEditable editable))) + +(define-func gtk_editable_claim_selection + none + ((GtkEditable editable) + (bool claim) + (uint time))) + +(define-func gtk_editable_delete_selection + none + ((GtkEditable editable))) + +(define-func gtk_editable_changed + none + ((GtkEditable editable))) + +(define-func gtk_editable_set_position + none + ((GtkEditable editable) + (int position))) + +(define-func gtk_editable_get_position + int + ((GtkEditable editable))) + +(define-func gtk_editable_set_editable + none + ((GtkEditable editable) + (bool is_editable))) + +;; Entry + +(define-object GtkEntry (GtkEditable)) + +(define-func gtk_entry_new + GtkWidget + ()) + +(define-func gtk_entry_new_with_max_length + GtkWidget +;; should actually be int16 - does it matter? + ((int max))) + +(define-func gtk_entry_set_text + none + ((GtkEntry entry) + (string text))) + +(define-func gtk_entry_append_text + none + ((GtkEntry entry) + (string text))) + +(define-func gtk_entry_prepend_text + none + ((GtkEntry entry) + (string text))) + +(define-func gtk_entry_set_position + none + ((GtkEntry entry) + (int position))) + +(define-func gtk_entry_get_text + static_string + ((GtkEntry entry))) + +(define-func gtk_entry_select_region + none + ((GtkEntry entry) + (int start) + (int end))) + +(define-func gtk_entry_set_visibility + none + ((GtkEntry entry) + (bool visible))) + +(define-func gtk_entry_set_editable + none + ((GtkEntry entry) + (bool editable))) + +(define-func gtk_entry_set_max_length + none + ((GtkEntry entry) + (uint max))) + +;; SpinButton + +(define-object GtkSpinButton (GtkEntry)) + +(define-func gtk_spin_button_new + GtkWidget + ((GtkAdjustment adjustment) + (float climb_rate) + (uint digits))) + +(define-func gtk_spin_button_set_adjustment + none + ((GtkSpinButton spin_button) + (GtkAdjustment adjustment))) + +(define-func gtk_spin_button_get_adjustment + GtkAdjustment + ((GtkSpinButton spin_button))) + +(define-func gtk_spin_button_set_digits + none + ((GtkSpinButton spin_button) + (uint digits))) + +(define-func gtk_spin_button_get_value_as_float + float + ((GtkSpinButton spin_button))) + +(define-func gtk_spin_button_get_value_as_int + int + ((GtkSpinButton spin_button))) + +(define-func gtk_spin_button_set_value + none + ((GtkSpinButton spin_button) + (float value))) + +(define-func gtk_spin_button_set_update_policy + none + ((GtkSpinButton spin_button) + (GtkSpinButtonUpdatePolicy policy))) + +(define-func gtk_spin_button_set_numeric + none + ((GtkSpinButton spin_button) + (bool numeric))) + +(define-func gtk_spin_button_spin + none + ((GtkSpinButton spin_button) + (GtkSpinType direction) + (float increment))) + +(define-func gtk_spin_button_set_wrap + none + ((GtkSpinButton spin_button) + (bool wrap))) + +(define-func gtk_spin_button_set_shadow_type + none + ((GtkSpinButton spin_button) + (GtkShadowType shadow_type))) + +(define-func gtk_spin_button_set_snap_to_ticks + none + ((GtkSpinButton spin_button) + (bool snap_to_ticks))) + +;; Text + +(define-object GtkText (GtkEditable) + (fields + (GtkAdjustment hadj) + (GtkAdjustment vadj))) + +(define-func gtk_text_new + GtkWidget + ((GtkAdjustment hadj (= "NULL")) + (GtkAdjustment vadj (= "NULL")))) + +(define-func gtk_text_set_editable + none + ((GtkText text) + (bool editable))) + +(define-func gtk_text_set_word_wrap + none + ((GtkText text) + (int word_wrap))) + +(define-func gtk_text_set_line_wrap + none + ((GtkText text) + (int line_wrap))) + +(define-func gtk_text_set_adjustments + none + ((GtkText text) + (GtkAdjustment hadj) + (GtkAdjustment vadj))) + +(define-func gtk_text_set_point + none + ((GtkText text) + (uint index))) + +(define-func gtk_text_get_point + uint + ((GtkText text))) + +(define-func gtk_text_get_length + uint + ((GtkText text))) + +(define-func gtk_text_freeze + none + ((GtkText text))) + +(define-func gtk_text_thaw + none + ((GtkText text))) + +(define-func gtk_text_insert + none + ((GtkText text) + (GdkFont font (null-ok)) + (GdkColor fore (null-ok)) + (GdkColor back (null-ok)) + (string chars) + (int length))) + +(define-func gtk_text_backward_delete + none + ((GtkText text) + (uint nchars))) + +(define-func gtk_text_forward_delete + none + ((GtkText text) + (uint nchars))) + diff --git a/generate/gtkenums.defs b/generate/gtkenums.defs new file mode 100644 index 00000000..78b1eb3d --- /dev/null +++ b/generate/gtkenums.defs @@ -0,0 +1,883 @@ +;; generated by makeenums.pl ; -*- scheme -*- + + +; enumerations from "gtkcalendar.h" + +(define-flags GtkCalendarDisplayOptions + (show-heading GTK_CALENDAR_SHOW_HEADING) + (show-day-names GTK_CALENDAR_SHOW_DAY_NAMES) + (no-month-change GTK_CALENDAR_NO_MONTH_CHANGE) + (show-week-numbers GTK_CALENDAR_SHOW_WEEK_NUMBERS) + (week-start-monday GTK_CALENDAR_WEEK_START_MONDAY)) + +; enumerations from "gtkclist.h" + +(define-enum GtkCellType + (empty GTK_CELL_EMPTY) + (text GTK_CELL_TEXT) + (pixmap GTK_CELL_PIXMAP) + (pixtext GTK_CELL_PIXTEXT) + (widget GTK_CELL_WIDGET)) + +; enumerations from "gtkctree.h" + +(define-enum GtkCTreePos + (before GTK_CTREE_POS_BEFORE) + (as-child GTK_CTREE_POS_AS_CHILD) + (after GTK_CTREE_POS_AFTER)) + +(define-enum GtkCTreeLineStyle + (none GTK_CTREE_LINES_NONE) + (solid GTK_CTREE_LINES_SOLID) + (dotted GTK_CTREE_LINES_DOTTED) + (tabbed GTK_CTREE_LINES_TABBED)) + +(define-enum GtkCTreeExpanderStyle + (none GTK_CTREE_EXPANDER_NONE) + (square GTK_CTREE_EXPANDER_SQUARE) + (triangle GTK_CTREE_EXPANDER_TRIANGLE) + (circular GTK_CTREE_EXPANDER_CIRCULAR)) + +(define-enum GtkCTreeExpansionType + (expand GTK_CTREE_EXPANSION_EXPAND) + (expand-recursive GTK_CTREE_EXPANSION_EXPAND_RECURSIVE) + (collapse GTK_CTREE_EXPANSION_COLLAPSE) + (collapse-recursive GTK_CTREE_EXPANSION_COLLAPSE_RECURSIVE) + (toggle GTK_CTREE_EXPANSION_TOGGLE) + (toggle-recursive GTK_CTREE_EXPANSION_TOGGLE_RECURSIVE)) + +; enumerations from "gtkdebug.h" + +(define-flags GtkDebugFlag + (objects GTK_DEBUG_OBJECTS) + (misc GTK_DEBUG_MISC) + (signals GTK_DEBUG_SIGNALS) + (dnd GTK_DEBUG_DND)) + +; enumerations from "gtkdnd.h" + +(define-flags GtkDestDefaults + (motion GTK_DEST_DEFAULT_MOTION) + (highlight GTK_DEST_DEFAULT_HIGHLIGHT) + (drop GTK_DEST_DEFAULT_DROP) + (all GTK_DEST_DEFAULT_ALL)) + +; enumerations from "gtkenums.h" + +(define-flags GtkAccelFlags + (visible GTK_ACCEL_VISIBLE) + (signal-visible GTK_ACCEL_SIGNAL_VISIBLE) + (locked GTK_ACCEL_LOCKED) + (mask GTK_ACCEL_MASK)) + +(define-enum GtkArrowType + (up GTK_ARROW_UP) + (down GTK_ARROW_DOWN) + (left GTK_ARROW_LEFT) + (right GTK_ARROW_RIGHT)) + +(define-flags GtkAttachOptions + (expand GTK_EXPAND) + (shrink GTK_SHRINK) + (fill GTK_FILL)) + +(define-enum GtkButtonBoxStyle + (default-style GTK_BUTTONBOX_DEFAULT_STYLE) + (spread GTK_BUTTONBOX_SPREAD) + (edge GTK_BUTTONBOX_EDGE) + (start GTK_BUTTONBOX_START) + (end GTK_BUTTONBOX_END)) + +(define-enum GtkCurveType + (linear GTK_CURVE_TYPE_LINEAR) + (spline GTK_CURVE_TYPE_SPLINE) + (free GTK_CURVE_TYPE_FREE)) + +(define-enum GtkDirectionType + (tab-forward GTK_DIR_TAB_FORWARD) + (tab-backward GTK_DIR_TAB_BACKWARD) + (up GTK_DIR_UP) + (down GTK_DIR_DOWN) + (left GTK_DIR_LEFT) + (right GTK_DIR_RIGHT)) + +(define-enum GtkJustification + (left GTK_JUSTIFY_LEFT) + (right GTK_JUSTIFY_RIGHT) + (center GTK_JUSTIFY_CENTER) + (fill GTK_JUSTIFY_FILL)) + +(define-enum GtkMatchType + (all GTK_MATCH_ALL) + (all-tail GTK_MATCH_ALL_TAIL) + (head GTK_MATCH_HEAD) + (tail GTK_MATCH_TAIL) + (exact GTK_MATCH_EXACT) + (last GTK_MATCH_LAST)) + +(define-enum GtkMenuDirectionType + (parent GTK_MENU_DIR_PARENT) + (child GTK_MENU_DIR_CHILD) + (next GTK_MENU_DIR_NEXT) + (prev GTK_MENU_DIR_PREV)) + +(define-enum GtkMenuFactoryType + (menu GTK_MENU_FACTORY_MENU) + (menu-bar GTK_MENU_FACTORY_MENU_BAR) + (option-menu GTK_MENU_FACTORY_OPTION_MENU)) + +(define-enum GtkMetricType + (pixels GTK_PIXELS) + (inches GTK_INCHES) + (centimeters GTK_CENTIMETERS)) + +(define-enum GtkOrientation + (horizontal GTK_ORIENTATION_HORIZONTAL) + (vertical GTK_ORIENTATION_VERTICAL)) + +(define-enum GtkCornerType + (top-left GTK_CORNER_TOP_LEFT) + (bottom-left GTK_CORNER_BOTTOM_LEFT) + (top-right GTK_CORNER_TOP_RIGHT) + (bottom-right GTK_CORNER_BOTTOM_RIGHT)) + +(define-enum GtkPackType + (start GTK_PACK_START) + (end GTK_PACK_END)) + +(define-enum GtkPathPriorityType + (lowest GTK_PATH_PRIO_LOWEST) + (gtk GTK_PATH_PRIO_GTK) + (application GTK_PATH_PRIO_APPLICATION) + (rc GTK_PATH_PRIO_RC) + (highest GTK_PATH_PRIO_HIGHEST) + (mask GTK_PATH_PRIO_MASK)) + +(define-enum GtkPathType + (widget GTK_PATH_WIDGET) + (widget-class GTK_PATH_WIDGET_CLASS) + (class GTK_PATH_CLASS)) + +(define-enum GtkPolicyType + (always GTK_POLICY_ALWAYS) + (automatic GTK_POLICY_AUTOMATIC)) + +(define-enum GtkPositionType + (left GTK_POS_LEFT) + (right GTK_POS_RIGHT) + (top GTK_POS_TOP) + (bottom GTK_POS_BOTTOM)) + +(define-enum GtkPreviewType + (color GTK_PREVIEW_COLOR) + (grayscale GTK_PREVIEW_GRAYSCALE)) + +(define-enum GtkReliefStyle + (normal GTK_RELIEF_NORMAL) + (half GTK_RELIEF_HALF) + (none GTK_RELIEF_NONE)) + +(define-enum GtkResizeMode + (parent GTK_RESIZE_PARENT) + (queue GTK_RESIZE_QUEUE) + (immediate GTK_RESIZE_IMMEDIATE)) + +(define-flags GtkSignalRunType + (first GTK_RUN_FIRST) + (last GTK_RUN_LAST) + (both GTK_RUN_BOTH) + (mask GTK_RUN_MASK) + (no-recurse GTK_RUN_NO_RECURSE) + (action GTK_RUN_ACTION)) + +(define-enum GtkScrollType + (none GTK_SCROLL_NONE) + (step-backward GTK_SCROLL_STEP_BACKWARD) + (step-forward GTK_SCROLL_STEP_FORWARD) + (page-backward GTK_SCROLL_PAGE_BACKWARD) + (page-forward GTK_SCROLL_PAGE_FORWARD) + (jump GTK_SCROLL_JUMP)) + +(define-enum GtkSelectionMode + (single GTK_SELECTION_SINGLE) + (browse GTK_SELECTION_BROWSE) + (multiple GTK_SELECTION_MULTIPLE) + (extended GTK_SELECTION_EXTENDED)) + +(define-enum GtkShadowType + (none GTK_SHADOW_NONE) + (in GTK_SHADOW_IN) + (out GTK_SHADOW_OUT) + (etched-in GTK_SHADOW_ETCHED_IN) + (etched-out GTK_SHADOW_ETCHED_OUT)) + +(define-enum GtkStateType + (normal GTK_STATE_NORMAL) + (active GTK_STATE_ACTIVE) + (prelight GTK_STATE_PRELIGHT) + (selected GTK_STATE_SELECTED) + (insensitive GTK_STATE_INSENSITIVE)) + +(define-enum GtkSubmenuDirection + (left GTK_DIRECTION_LEFT) + (right GTK_DIRECTION_RIGHT)) + +(define-enum GtkSubmenuPlacement + (top-bottom GTK_TOP_BOTTOM) + (left-right GTK_LEFT_RIGHT)) + +(define-enum GtkToolbarStyle + (icons GTK_TOOLBAR_ICONS) + (text GTK_TOOLBAR_TEXT) + (both GTK_TOOLBAR_BOTH)) + +(define-enum GtkTroughType + (none GTK_TROUGH_NONE) + (start GTK_TROUGH_START) + (end GTK_TROUGH_END) + (jump GTK_TROUGH_JUMP)) + +(define-enum GtkUpdateType + (continuous GTK_UPDATE_CONTINUOUS) + (discontinuous GTK_UPDATE_DISCONTINUOUS) + (delayed GTK_UPDATE_DELAYED)) + +(define-enum GtkVisibility + (none GTK_VISIBILITY_NONE) + (partial GTK_VISIBILITY_PARTIAL) + (full GTK_VISIBILITY_FULL)) + +(define-enum GtkWindowPosition + (none GTK_WIN_POS_NONE) + (center GTK_WIN_POS_CENTER) + (mouse GTK_WIN_POS_MOUSE)) + +(define-enum GtkWindowType + (toplevel GTK_WINDOW_TOPLEVEL) + (dialog GTK_WINDOW_DIALOG) + (popup GTK_WINDOW_POPUP)) + +(define-enum GtkSortType + (ascending GTK_SORT_ASCENDING) + (descending GTK_SORT_DESCENDING)) + +; enumerations from "gtkfontsel.h" + +(define-enum GtkFontMetricType + (pixels GTK_FONT_METRIC_PIXELS) + (points GTK_FONT_METRIC_POINTS)) + +(define-flags GtkFontType + (bitmap GTK_FONT_BITMAP) + (scalable GTK_FONT_SCALABLE) + (scalable-bitmap GTK_FONT_SCALABLE_BITMAP) + (all GTK_FONT_ALL)) + +(define-enum GtkFontFilterType + (base GTK_FONT_FILTER_BASE) + (user GTK_FONT_FILTER_USER)) + +; enumerations from "gtkobject.h" + +(define-flags GtkObjectFlags + (destroyed GTK_DESTROYED) + (floating GTK_FLOATING) + (connected GTK_CONNECTED) + (reserved-2 GTK_RESERVED_2) + (object-flag-last GTK_OBJECT_FLAG_LAST)) + +(define-flags GtkArgFlags + (readable GTK_ARG_READABLE) + (writable GTK_ARG_WRITABLE) + (construct GTK_ARG_CONSTRUCT) + (child-arg GTK_ARG_CHILD_ARG) + (mask GTK_ARG_MASK) + (readwrite GTK_ARG_READWRITE)) + +; enumerations from "gtkpacker.h" + +(define-flags GtkPackerOptions + (expand GTK_PACK_EXPAND) + (fill-x GTK_FILL_X) + (fill-y GTK_FILL_Y)) + +(define-enum GtkSideType + (top GTK_SIDE_TOP) + (bottom GTK_SIDE_BOTTOM) + (left GTK_SIDE_LEFT) + (right GTK_SIDE_RIGHT)) + +(define-enum GtkAnchorType + (center GTK_ANCHOR_CENTER) + (north GTK_ANCHOR_NORTH) + (north-west GTK_ANCHOR_NORTH_WEST) + (north-east GTK_ANCHOR_NORTH_EAST) + (south GTK_ANCHOR_SOUTH) + (south-west GTK_ANCHOR_SOUTH_WEST) + (south-east GTK_ANCHOR_SOUTH_EAST) + (west GTK_ANCHOR_WEST) + (east GTK_ANCHOR_EAST) + (n GTK_ANCHOR_N) + (nw GTK_ANCHOR_NW) + (ne GTK_ANCHOR_NE) + (s GTK_ANCHOR_S) + (sw GTK_ANCHOR_SW) + (se GTK_ANCHOR_SE) + (w GTK_ANCHOR_W) + (e GTK_ANCHOR_E)) + +; enumerations from "gtkprivate.h" + +(define-flags GtkPrivateFlags + (user-style PRIVATE_GTK_USER_STYLE) + (redraw-pending PRIVATE_GTK_REDRAW_PENDING) + (resize-pending PRIVATE_GTK_RESIZE_PENDING) + (resize-needed PRIVATE_GTK_RESIZE_NEEDED) + (leave-pending PRIVATE_GTK_LEAVE_PENDING) + (has-shape-mask PRIVATE_GTK_HAS_SHAPE_MASK) + (in-reparent PRIVATE_GTK_IN_REPARENT)) + +; enumerations from "gtkprogressbar.h" + +(define-enum GtkProgressBarStyle + (continuous GTK_PROGRESS_CONTINUOUS) + (discrete GTK_PROGRESS_DISCRETE)) + +(define-enum GtkProgressBarOrientation + (left-to-right GTK_PROGRESS_LEFT_TO_RIGHT) + (right-to-left GTK_PROGRESS_RIGHT_TO_LEFT) + (bottom-to-top GTK_PROGRESS_BOTTOM_TO_TOP) + (top-to-bottom GTK_PROGRESS_TOP_TO_BOTTOM)) + +; enumerations from "gtkrc.h" + +(define-enum GtkRcTokenType + (invalid GTK_RC_TOKEN_INVALID) + (include GTK_RC_TOKEN_INCLUDE) + (normal GTK_RC_TOKEN_NORMAL) + (active GTK_RC_TOKEN_ACTIVE) + (prelight GTK_RC_TOKEN_PRELIGHT) + (selected GTK_RC_TOKEN_SELECTED) + (insensitive GTK_RC_TOKEN_INSENSITIVE) + (fg GTK_RC_TOKEN_FG) + (bg GTK_RC_TOKEN_BG) + (base GTK_RC_TOKEN_BASE) + (text GTK_RC_TOKEN_TEXT) + (font GTK_RC_TOKEN_FONT) + (fontset GTK_RC_TOKEN_FONTSET) + (bg-pixmap GTK_RC_TOKEN_BG_PIXMAP) + (pixmap-path GTK_RC_TOKEN_PIXMAP_PATH) + (style GTK_RC_TOKEN_STYLE) + (binding GTK_RC_TOKEN_BINDING) + (bind GTK_RC_TOKEN_BIND) + (widget GTK_RC_TOKEN_WIDGET) + (widget-class GTK_RC_TOKEN_WIDGET_CLASS) + (class GTK_RC_TOKEN_CLASS) + (lowest GTK_RC_TOKEN_LOWEST) + (gtk GTK_RC_TOKEN_GTK) + (application GTK_RC_TOKEN_APPLICATION) + (rc GTK_RC_TOKEN_RC) + (highest GTK_RC_TOKEN_HIGHEST) + (last GTK_RC_TOKEN_LAST)) + +; enumerations from "gtkspinbutton.h" + +(define-enum GtkSpinButtonUpdatePolicy + (always GTK_UPDATE_ALWAYS) + (if-valid GTK_UPDATE_IF_VALID)) + +(define-enum GtkSpinType + (step-forward GTK_SPIN_STEP_FORWARD) + (step-backward GTK_SPIN_STEP_BACKWARD) + (page-forward GTK_SPIN_PAGE_FORWARD) + (page-backward GTK_SPIN_PAGE_BACKWARD) + (home GTK_SPIN_HOME) + (end GTK_SPIN_END) + (user-defined GTK_SPIN_USER_DEFINED)) + +; enumerations from "gtktoolbar.h" + +(define-enum GtkToolbarChildType + (space GTK_TOOLBAR_CHILD_SPACE) + (button GTK_TOOLBAR_CHILD_BUTTON) + (togglebutton GTK_TOOLBAR_CHILD_TOGGLEBUTTON) + (radiobutton GTK_TOOLBAR_CHILD_RADIOBUTTON) + (widget GTK_TOOLBAR_CHILD_WIDGET)) + +; enumerations from "gtktree.h" + +(define-enum GtkTreeViewMode + (line GTK_TREE_VIEW_LINE) + (item GTK_TREE_VIEW_ITEM)) + +; enumerations from "gtktypeutils.h" + +(define-enum GtkFundamentalType + (invalid GTK_TYPE_INVALID) + (none GTK_TYPE_NONE) + (char GTK_TYPE_CHAR) + (uchar GTK_TYPE_UCHAR) + (bool GTK_TYPE_BOOL) + (int GTK_TYPE_INT) + (uint GTK_TYPE_UINT) + (long GTK_TYPE_LONG) + (ulong GTK_TYPE_ULONG) + (float GTK_TYPE_FLOAT) + (double GTK_TYPE_DOUBLE) + (string GTK_TYPE_STRING) + (enum GTK_TYPE_ENUM) + (flags GTK_TYPE_FLAGS) + (boxed GTK_TYPE_BOXED) + (pointer GTK_TYPE_POINTER) + (signal GTK_TYPE_SIGNAL) + (args GTK_TYPE_ARGS) + (callback GTK_TYPE_CALLBACK) + (c-callback GTK_TYPE_C_CALLBACK) + (foreign GTK_TYPE_FOREIGN) + (object GTK_TYPE_OBJECT)) + +; enumerations from "gtkwidget.h" + +(define-flags GtkWidgetFlags + (toplevel GTK_TOPLEVEL) + (no-window GTK_NO_WINDOW) + (realized GTK_REALIZED) + (mapped GTK_MAPPED) + (visible GTK_VISIBLE) + (sensitive GTK_SENSITIVE) + (parent-sensitive GTK_PARENT_SENSITIVE) + (can-focus GTK_CAN_FOCUS) + (has-focus GTK_HAS_FOCUS) + (can-default GTK_CAN_DEFAULT) + (has-default GTK_HAS_DEFAULT) + (has-grab GTK_HAS_GRAB) + (rc-style GTK_RC_STYLE) + (composite-child GTK_COMPOSITE_CHILD) + (basic GTK_BASIC)) + +; enumerations from "../gdk/gdktypes.h" + +(define-enum GdkWindowType + (root GDK_WINDOW_ROOT) + (toplevel GDK_WINDOW_TOPLEVEL) + (child GDK_WINDOW_CHILD) + (dialog GDK_WINDOW_DIALOG) + (temp GDK_WINDOW_TEMP) + (pixmap GDK_WINDOW_PIXMAP) + (foreign GDK_WINDOW_FOREIGN)) + +(define-enum GdkWindowClass + (output GDK_INPUT_OUTPUT) + (only GDK_INPUT_ONLY)) + +(define-enum GdkImageType + (normal GDK_IMAGE_NORMAL) + (shared GDK_IMAGE_SHARED) + (fastest GDK_IMAGE_FASTEST)) + +(define-enum GdkVisualType + (static-gray GDK_VISUAL_STATIC_GRAY) + (grayscale GDK_VISUAL_GRAYSCALE) + (static-color GDK_VISUAL_STATIC_COLOR) + (pseudo-color GDK_VISUAL_PSEUDO_COLOR) + (true-color GDK_VISUAL_TRUE_COLOR) + (direct-color GDK_VISUAL_DIRECT_COLOR)) + +(define-enum GdkFontType + (font GDK_FONT_FONT) + (fontset GDK_FONT_FONTSET)) + +(define-flags GdkWindowAttributesType + (title GDK_WA_TITLE) + (x GDK_WA_X) + (y GDK_WA_Y) + (cursor GDK_WA_CURSOR) + (colormap GDK_WA_COLORMAP) + (visual GDK_WA_VISUAL) + (wmclass GDK_WA_WMCLASS) + (noredir GDK_WA_NOREDIR)) + +(define-flags GdkWindowHints + (pos GDK_HINT_POS) + (min-size GDK_HINT_MIN_SIZE) + (max-size GDK_HINT_MAX_SIZE)) + +(define-enum GdkFunction + (copy GDK_COPY) + (invert GDK_INVERT) + (xor GDK_XOR) + (clear GDK_CLEAR) + (and GDK_AND) + (and-reverse GDK_AND_REVERSE) + (and-invert GDK_AND_INVERT) + (noop GDK_NOOP) + (or GDK_OR) + (equiv GDK_EQUIV) + (or-reverse GDK_OR_REVERSE) + (copy-invert GDK_COPY_INVERT) + (or-invert GDK_OR_INVERT) + (nand GDK_NAND) + (set GDK_SET)) + +(define-enum GdkFill + (solid GDK_SOLID) + (tiled GDK_TILED) + (stippled GDK_STIPPLED) + (opaque-stippled GDK_OPAQUE_STIPPLED)) + +(define-enum GdkFillRule + (even-odd-rule GDK_EVEN_ODD_RULE) + (winding-rule GDK_WINDING_RULE)) + +(define-enum GdkLineStyle + (solid GDK_LINE_SOLID) + (on-off-dash GDK_LINE_ON_OFF_DASH) + (double-dash GDK_LINE_DOUBLE_DASH)) + +(define-enum GdkCapStyle + (not-last GDK_CAP_NOT_LAST) + (butt GDK_CAP_BUTT) + (round GDK_CAP_ROUND) + (projecting GDK_CAP_PROJECTING)) + +(define-enum GdkJoinStyle + (miter GDK_JOIN_MITER) + (round GDK_JOIN_ROUND) + (bevel GDK_JOIN_BEVEL)) + +(define-enum GdkCursorType + (num-glyphs GDK_NUM_GLYPHS) + (x-cursor GDK_X_CURSOR) + (arrow GDK_ARROW) + (based-arrow-down GDK_BASED_ARROW_DOWN) + (based-arrow-up GDK_BASED_ARROW_UP) + (boat GDK_BOAT) + (bogosity GDK_BOGOSITY) + (bottom-left-corner GDK_BOTTOM_LEFT_CORNER) + (bottom-right-corner GDK_BOTTOM_RIGHT_CORNER) + (bottom-side GDK_BOTTOM_SIDE) + (bottom-tee GDK_BOTTOM_TEE) + (box-spiral GDK_BOX_SPIRAL) + (center-ptr GDK_CENTER_PTR) + (circle GDK_CIRCLE) + (clock GDK_CLOCK) + (coffee-mug GDK_COFFEE_MUG) + (cross GDK_CROSS) + (cross-reverse GDK_CROSS_REVERSE) + (crosshair GDK_CROSSHAIR) + (diamond-cross GDK_DIAMOND_CROSS) + (dot GDK_DOT) + (dotbox GDK_DOTBOX) + (double-arrow GDK_DOUBLE_ARROW) + (draft-large GDK_DRAFT_LARGE) + (draft-small GDK_DRAFT_SMALL) + (draped-box GDK_DRAPED_BOX) + (exchange GDK_EXCHANGE) + (fleur GDK_FLEUR) + (gobbler GDK_GOBBLER) + (gumby GDK_GUMBY) + (hand1 GDK_HAND1) + (hand2 GDK_HAND2) + (heart GDK_HEART) + (icon GDK_ICON) + (iron-cross GDK_IRON_CROSS) + (left-ptr GDK_LEFT_PTR) + (left-side GDK_LEFT_SIDE) + (left-tee GDK_LEFT_TEE) + (leftbutton GDK_LEFTBUTTON) + (ll-angle GDK_LL_ANGLE) + (lr-angle GDK_LR_ANGLE) + (man GDK_MAN) + (middlebutton GDK_MIDDLEBUTTON) + (mouse GDK_MOUSE) + (pencil GDK_PENCIL) + (pirate GDK_PIRATE) + (plus GDK_PLUS) + (question-arrow GDK_QUESTION_ARROW) + (right-ptr GDK_RIGHT_PTR) + (right-side GDK_RIGHT_SIDE) + (right-tee GDK_RIGHT_TEE) + (rightbutton GDK_RIGHTBUTTON) + (rtl-logo GDK_RTL_LOGO) + (sailboat GDK_SAILBOAT) + (sb-down-arrow GDK_SB_DOWN_ARROW) + (sb-h-double-arrow GDK_SB_H_DOUBLE_ARROW) + (sb-left-arrow GDK_SB_LEFT_ARROW) + (sb-right-arrow GDK_SB_RIGHT_ARROW) + (sb-up-arrow GDK_SB_UP_ARROW) + (sb-v-double-arrow GDK_SB_V_DOUBLE_ARROW) + (shuttle GDK_SHUTTLE) + (sizing GDK_SIZING) + (spider GDK_SPIDER) + (spraycan GDK_SPRAYCAN) + (star GDK_STAR) + (target GDK_TARGET) + (tcross GDK_TCROSS) + (top-left-arrow GDK_TOP_LEFT_ARROW) + (top-left-corner GDK_TOP_LEFT_CORNER) + (top-right-corner GDK_TOP_RIGHT_CORNER) + (top-side GDK_TOP_SIDE) + (top-tee GDK_TOP_TEE) + (trek GDK_TREK) + (ul-angle GDK_UL_ANGLE) + (umbrella GDK_UMBRELLA) + (ur-angle GDK_UR_ANGLE) + (watch GDK_WATCH) + (xterm GDK_XTERM) + (last-cursor GDK_LAST_CURSOR) + (cursor-is-pixmap GDK_CURSOR_IS_PIXMAP)) + +(define-enum GdkFilterReturn + (continue GDK_FILTER_CONTINUE) + (translate GDK_FILTER_TRANSLATE) + (remove GDK_FILTER_REMOVE)) + +(define-enum GdkVisibilityState + (unobscured GDK_VISIBILITY_UNOBSCURED) + (partial GDK_VISIBILITY_PARTIAL) + (fully-obscured GDK_VISIBILITY_FULLY_OBSCURED)) + +(define-enum GdkEventType + (nothing GDK_NOTHING) + (delete GDK_DELETE) + (destroy GDK_DESTROY) + (expose GDK_EXPOSE) + (motion-notify GDK_MOTION_NOTIFY) + (button-press GDK_BUTTON_PRESS) + (2button-press GDK_2BUTTON_PRESS) + (3button-press GDK_3BUTTON_PRESS) + (button-release GDK_BUTTON_RELEASE) + (key-press GDK_KEY_PRESS) + (key-release GDK_KEY_RELEASE) + (enter-notify GDK_ENTER_NOTIFY) + (leave-notify GDK_LEAVE_NOTIFY) + (focus-change GDK_FOCUS_CHANGE) + (configure GDK_CONFIGURE) + (map GDK_MAP) + (unmap GDK_UNMAP) + (property-notify GDK_PROPERTY_NOTIFY) + (selection-clear GDK_SELECTION_CLEAR) + (selection-request GDK_SELECTION_REQUEST) + (selection-notify GDK_SELECTION_NOTIFY) + (proximity-in GDK_PROXIMITY_IN) + (proximity-out GDK_PROXIMITY_OUT) + (drag-enter GDK_DRAG_ENTER) + (drag-leave GDK_DRAG_LEAVE) + (drag-motion GDK_DRAG_MOTION) + (drag-status GDK_DRAG_STATUS) + (drop-start GDK_DROP_START) + (drop-finished GDK_DROP_FINISHED) + (client-event GDK_CLIENT_EVENT) + (visibility-notify GDK_VISIBILITY_NOTIFY) + (no-expose GDK_NO_EXPOSE)) + +(define-flags GdkEventMask + (exposure-mask GDK_EXPOSURE_MASK) + (pointer-motion-mask GDK_POINTER_MOTION_MASK) + (pointer-motion-hint-mask GDK_POINTER_MOTION_HINT_MASK) + (button-motion-mask GDK_BUTTON_MOTION_MASK) + (button1-motion-mask GDK_BUTTON1_MOTION_MASK) + (button2-motion-mask GDK_BUTTON2_MOTION_MASK) + (button3-motion-mask GDK_BUTTON3_MOTION_MASK) + (button-press-mask GDK_BUTTON_PRESS_MASK) + (button-release-mask GDK_BUTTON_RELEASE_MASK) + (key-press-mask GDK_KEY_PRESS_MASK) + (key-release-mask GDK_KEY_RELEASE_MASK) + (enter-notify-mask GDK_ENTER_NOTIFY_MASK) + (leave-notify-mask GDK_LEAVE_NOTIFY_MASK) + (focus-change-mask GDK_FOCUS_CHANGE_MASK) + (structure-mask GDK_STRUCTURE_MASK) + (property-change-mask GDK_PROPERTY_CHANGE_MASK) + (visibility-notify-mask GDK_VISIBILITY_NOTIFY_MASK) + (proximity-in-mask GDK_PROXIMITY_IN_MASK) + (proximity-out-mask GDK_PROXIMITY_OUT_MASK) + (substructure-mask GDK_SUBSTRUCTURE_MASK) + (all-events-mask GDK_ALL_EVENTS_MASK)) + +(define-enum GdkNotifyType + (ancestor GDK_NOTIFY_ANCESTOR) + (virtual GDK_NOTIFY_VIRTUAL) + (inferior GDK_NOTIFY_INFERIOR) + (nonlinear GDK_NOTIFY_NONLINEAR) + (nonlinear-virtual GDK_NOTIFY_NONLINEAR_VIRTUAL) + (unknown GDK_NOTIFY_UNKNOWN)) + +(define-enum GdkCrossingMode + (normal GDK_CROSSING_NORMAL) + (grab GDK_CROSSING_GRAB) + (ungrab GDK_CROSSING_UNGRAB)) + +(define-flags GdkModifierType + (shift-mask GDK_SHIFT_MASK) + (lock-mask GDK_LOCK_MASK) + (control-mask GDK_CONTROL_MASK) + (mod1-mask GDK_MOD1_MASK) + (mod2-mask GDK_MOD2_MASK) + (mod3-mask GDK_MOD3_MASK) + (mod4-mask GDK_MOD4_MASK) + (mod5-mask GDK_MOD5_MASK) + (button1-mask GDK_BUTTON1_MASK) + (button2-mask GDK_BUTTON2_MASK) + (button3-mask GDK_BUTTON3_MASK) + (button4-mask GDK_BUTTON4_MASK) + (button5-mask GDK_BUTTON5_MASK) + (release-mask GDK_RELEASE_MASK) + (modifier-mask GDK_MODIFIER_MASK)) + +(define-enum GdkSubwindowMode + (clip-by-children GDK_CLIP_BY_CHILDREN) + (include-inferiors GDK_INCLUDE_INFERIORS)) + +(define-flags GdkInputCondition + (read GDK_INPUT_READ) + (write GDK_INPUT_WRITE) + (exception GDK_INPUT_EXCEPTION)) + +(define-enum GdkStatus + (ok GDK_OK) + (error GDK_ERROR) + (error-param GDK_ERROR_PARAM) + (error-file GDK_ERROR_FILE) + (error-mem GDK_ERROR_MEM)) + +(define-enum GdkByteOrder + (lsb-first GDK_LSB_FIRST) + (msb-first GDK_MSB_FIRST)) + +(define-flags GdkGCValuesMask + (foreground GDK_GC_FOREGROUND) + (background GDK_GC_BACKGROUND) + (font GDK_GC_FONT) + (function GDK_GC_FUNCTION) + (fill GDK_GC_FILL) + (tile GDK_GC_TILE) + (stipple GDK_GC_STIPPLE) + (clip-mask GDK_GC_CLIP_MASK) + (subwindow GDK_GC_SUBWINDOW) + (ts-x-origin GDK_GC_TS_X_ORIGIN) + (ts-y-origin GDK_GC_TS_Y_ORIGIN) + (clip-x-origin GDK_GC_CLIP_X_ORIGIN) + (clip-y-origin GDK_GC_CLIP_Y_ORIGIN) + (exposures GDK_GC_EXPOSURES) + (line-width GDK_GC_LINE_WIDTH) + (line-style GDK_GC_LINE_STYLE) + (cap-style GDK_GC_CAP_STYLE) + (join-style GDK_GC_JOIN_STYLE)) + +(define-enum GdkSelection + (primary GDK_SELECTION_PRIMARY) + (secondary GDK_SELECTION_SECONDARY)) + +(define-enum GdkPropertyState + (new-value GDK_PROPERTY_NEW_VALUE) + (delete GDK_PROPERTY_DELETE)) + +(define-enum GdkPropMode + (replace GDK_PROP_MODE_REPLACE) + (prepend GDK_PROP_MODE_PREPEND) + (append GDK_PROP_MODE_APPEND)) + +(define-enum GdkInputSource + (mouse GDK_SOURCE_MOUSE) + (pen GDK_SOURCE_PEN) + (eraser GDK_SOURCE_ERASER) + (cursor GDK_SOURCE_CURSOR)) + +(define-enum GdkInputMode + (disabled GDK_MODE_DISABLED) + (screen GDK_MODE_SCREEN) + (window GDK_MODE_WINDOW)) + +(define-enum GdkAxisUse + (ignore GDK_AXIS_IGNORE) + (x GDK_AXIS_X) + (y GDK_AXIS_Y) + (pressure GDK_AXIS_PRESSURE) + (xtilt GDK_AXIS_XTILT) + (ytilt GDK_AXIS_YTILT) + (last GDK_AXIS_LAST)) + +(define-enum GdkTarget + (bitmap GDK_TARGET_BITMAP) + (colormap GDK_TARGET_COLORMAP) + (drawable GDK_TARGET_DRAWABLE) + (pixmap GDK_TARGET_PIXMAP) + (string GDK_TARGET_STRING)) + +(define-enum GdkSelectionType + (atom GDK_SELECTION_TYPE_ATOM) + (bitmap GDK_SELECTION_TYPE_BITMAP) + (colormap GDK_SELECTION_TYPE_COLORMAP) + (drawable GDK_SELECTION_TYPE_DRAWABLE) + (integer GDK_SELECTION_TYPE_INTEGER) + (pixmap GDK_SELECTION_TYPE_PIXMAP) + (window GDK_SELECTION_TYPE_WINDOW) + (string GDK_SELECTION_TYPE_STRING)) + +(define-enum GdkExtensionMode + (none GDK_EXTENSION_EVENTS_NONE) + (all GDK_EXTENSION_EVENTS_ALL) + (cursor GDK_EXTENSION_EVENTS_CURSOR)) + +(define-flags GdkIMStyle + (preedit-area GDK_IM_PREEDIT_AREA) + (preedit-callbacks GDK_IM_PREEDIT_CALLBACKS) + (preedit-position GDK_IM_PREEDIT_POSITION) + (preedit-nothing GDK_IM_PREEDIT_NOTHING) + (preedit-none GDK_IM_PREEDIT_NONE) + (preedit-mask GDK_IM_PREEDIT_MASK) + (status-area GDK_IM_STATUS_AREA) + (status-callbacks GDK_IM_STATUS_CALLBACKS) + (status-nothing GDK_IM_STATUS_NOTHING) + (status-none GDK_IM_STATUS_NONE) + (status-mask GDK_IM_STATUS_MASK)) + +(define-flags GdkWMDecoration + (all GDK_DECOR_ALL) + (border GDK_DECOR_BORDER) + (resizeh GDK_DECOR_RESIZEH) + (title GDK_DECOR_TITLE) + (menu GDK_DECOR_MENU) + (minimize GDK_DECOR_MINIMIZE) + (maximize GDK_DECOR_MAXIMIZE)) + +(define-flags GdkWMFunction + (all GDK_FUNC_ALL) + (resize GDK_FUNC_RESIZE) + (move GDK_FUNC_MOVE) + (minimize GDK_FUNC_MINIMIZE) + (maximize GDK_FUNC_MAXIMIZE) + (close GDK_FUNC_CLOSE)) + +(define-enum GdkColorContextMode + (undefined GDK_CC_MODE_UNDEFINED) + (bw GDK_CC_MODE_BW) + (std-cmap GDK_CC_MODE_STD_CMAP) + (true GDK_CC_MODE_TRUE) + (my-gray GDK_CC_MODE_MY_GRAY) + (palette GDK_CC_MODE_PALETTE)) + +(define-enum GdkOverlapType + (in GDK_OVERLAP_RECTANGLE_IN) + (out GDK_OVERLAP_RECTANGLE_OUT) + (part GDK_OVERLAP_RECTANGLE_PART)) + +(define-flags GdkDragAction + (default GDK_ACTION_DEFAULT) + (copy GDK_ACTION_COPY) + (move GDK_ACTION_MOVE) + (link GDK_ACTION_LINK) + (private GDK_ACTION_PRIVATE) + (ask GDK_ACTION_ASK)) + +(define-enum GdkDragProtocol + (motif GDK_DRAG_PROTO_MOTIF) + (xdnd GDK_DRAG_PROTO_XDND) + (rootwin GDK_DRAG_PROTO_ROOTWIN)) + +; enumerations from "../gdk/gdkrgb.h" + +(define-enum GdkRgbDither + (none GDK_RGB_DITHER_NONE) + (normal GDK_RGB_DITHER_NORMAL) + (max GDK_RGB_DITHER_MAX)) diff --git a/generate/gtklists.defs b/generate/gtklists.defs new file mode 100644 index 00000000..22dcf588 --- /dev/null +++ b/generate/gtklists.defs @@ -0,0 +1,896 @@ +; -*- scheme -*- +(define-object GtkTreeItem (GtkItem)) + +(define-func gtk_tree_item_new + GtkWidget + ()) + +(define-func gtk_tree_item_new_with_label + GtkWidget + ((string label))) + +(define-func gtk_tree_item_set_subtree + none + ((GtkTreeItem tree_item) + (GtkWidget subtree))) + +(define-func gtk_tree_item_remove_subtree + none + ((GtkTreeItem tree_item))) + +(define-func gtk_tree_item_select + none + ((GtkTreeItem tree_item))) + +(define-func gtk_tree_item_deselect + none + ((GtkTreeItem tree_item))) + +(define-func gtk_tree_item_expand + none + ((GtkTreeItem tree_item))) + +(define-func gtk_tree_item_collapse + none + ((GtkTreeItem tree_item))) + +;;; Tree + +(define-object GtkTree (GtkContainer)) + +(define-func gtk_tree_new + GtkWidget + ()) + +(define-func gtk_tree_append + none + ((GtkTree tree) + (GtkWidget child))) + +(define-func gtk_tree_prepend + none + ((GtkTree tree) + (GtkWidget child))) + +(define-func gtk_tree_insert + none + ((GtkTree tree) + (GtkWidget child) + (int position))) + +;; XXX - need GList support +;; (define-func gtk_tree_remove_items) + +(define-func gtk_tree_clear_items + none + ((GtkTree tree) + (int start) + (int end))) + +(define-func gtk_tree_select_item + none + ((GtkTree tree) + (int item))) + +(define-func gtk_tree_unselect_item + none + ((GtkTree tree) + (int item))) + +(define-func gtk_tree_select_child + none + ((GtkTree tree) + (GtkWidget child))) + +(define-func gtk_tree_unselect_child + none + ((GtkTree tree) + (GtkWidget child))) + +(define-func gtk_tree_child_position + int + ((GtkTree tree) + (GtkWidget child))) + +(define-func gtk_tree_set_selection_mode + none + ((GtkTree tree) + (GtkSelectionMode mode))) + +(define-func gtk_tree_set_view_mode + none + ((GtkTree tree) + (GtkTreeViewMode mode))) + +(define-func gtk_tree_set_view_lines + none + ((GtkTree tree) + (bool flag))) + +;;; GtkCList + +(define-object GtkCList (GtkContainer)) + +(define-func gtk_clist_new + GtkWidget + ((int columns))) + +;gtk_clist_new_with_titles + +(define-func gtk_clist_set_shadow_type + none + ((GtkCList clist) + (GtkShadowType border))) + +(define-func gtk_clist_set_selection_mode + none + ((GtkCList clist) + (GtkSelectionMode mode))) + +;(define-func gtk_clist_set_policy +; none +; ((GtkCList clist) +; (GtkPolicyType vscrollbar_policy) +; (GtkPolicyType hscrollbar_policy))) +(define-func gtk_clist_set_hadjustment + none + ((GtkCList clist) + (GtkAdjustment adjustment))) + +(define-func gtk_clist_set_vadjustment + none + ((GtkCList clist) + (GtkAdjustment adjustment))) + +(define-func gtk_clist_get_hadjustment + GtkAdjustment + ((GtkCList clist))) + +(define-func gtk_clist_get_vadjustment + GtkAdjustment + ((GtkCList clist))) + +(define-func gtk_clist_freeze + none + ((GtkCList clist))) + +(define-func gtk_clist_thaw + none + ((GtkCList clist))) + +(define-func gtk_clist_column_titles_show + none + ((GtkCList clist))) + +(define-func gtk_clist_column_titles_hide + none + ((GtkCList clist))) + +(define-func gtk_clist_column_title_active + none + ((GtkCList clist) + (int column))) + +(define-func gtk_clist_column_title_passive + none + ((GtkCList clist) + (int column))) + +(define-func gtk_clist_column_titles_active + none + ((GtkCList clist))) + +(define-func gtk_clist_column_titles_passive + none + ((GtkCList clist))) + +(define-func gtk_clist_set_column_title + none + ((GtkCList clist) + (int column) + (string title))) + +(define-func gtk_clist_get_column_title + static_string + ((GtkCList clist) + (int column))) + +(define-func gtk_clist_set_column_widget + none + ((GtkCList clist) + (int column) + (GtkWidget widget))) + +(define-func gtk_clist_get_column_widget + GtkWidget + ((GtkCList clist) + (int column))) + +(define-func gtk_clist_set_column_justification + none + ((GtkCList clist) + (int column) + (GtkJustification justification))) + +(define-func gtk_clist_set_column_visibility + none + ((GtkCList clist) + (int column) + (bool visible))) + +(define-func gtk_clist_set_column_resizeable + none + ((GtkCList clist) + (int column) + (bool resizeable))) + +(define-func gtk_clist_set_column_auto_resize + none + ((GtkCList clist) + (int column) + (bool auto_resize))) + +(define-func gtk_clist_columns_autosize + int + ((GtkCList clist))) + +(define-func gtk_clist_optimal_column_width + int + ((GtkCList clist) + (int column))) + +(define-func gtk_clist_set_column_width + none + ((GtkCList clist) + (int column) + (int width))) + +(define-func gtk_clist_set_column_min_width + none + ((GtkCList clist) + (int column) + (int min_width))) + +(define-func gtk_clist_set_column_max_width + none + ((GtkCList clist) + (int column) + (int max_width))) + +(define-func gtk_clist_set_row_height + none + ((GtkCList clist) + (uint height))) + +(define-func gtk_clist_moveto + none + ((GtkCList clist) + (int row) + (int column) + (float row_align) + (float column_align))) + +(define-func gtk_clist_row_is_visible + bool + ((GtkCList clist) + (int row))) + +(define-func gtk_clist_get_cell_type + GtkCellType + ((GtkCList clist) + (int row) (int column))) + +(define-func gtk_clist_set_text + none + ((GtkCList clist) + (int row) + (int column) + (string text))) + +;gtk_clist_get_text + +;gtk_clist_set_pixmap +;gtk_clist_get_pixmap +(define-func gtk_clist_set_pixmap + none + ((GtkCList clist) + (int row) (int col) + (GdkPixmap pixmap) + (GdkBitmap mask))) + +(define-func gtk_clist_set_pixtext + none + ((GtkCList clist) + (int row) (int col) + (string text) + (uint spacing) + (GdkPixmap pixmap) + (GdkBitmap mask))) + +(define-func gtk_clist_set_foreground + none + ((GtkCList clist) + (int row) + (GdkColor color))) + +(define-func gtk_clist_set_background + none + ((GtkCList clist) + (int row) + (GdkColor color))) + +(define-func gtk_clist_set_cell_style + none + ((GtkCList clist) + (int row) + (int column) + (GtkStyle style))) + +(define-func gtk_clist_get_cell_style + GtkStyle + ((GtkCList clist) + (int row) + (int column))) + +(define-func gtk_clist_set_row_style + none + ((GtkCList clist) + (int row) + (GtkStyle style))) + +(define-func gtk_clist_get_row_style + GtkStyle + ((GtkCList clist) + (int row))) + +(define-func gtk_clist_set_shift + none + ((GtkCList clist) + (int row) + (int column) + (int vertical) + (int horizontal))) + +(define-func gtk_clist_set_selectable + none + ((GtkCList clist) + (int row) + (bool selectable))) + +(define-func gtk_clist_get_selectable + none + ((GtkCList clist) + (int row))) + +;gtk_clist_append +;gtk_clist_insert + +(define_func gtk_clist_remove + none + ((GtkCList clist) + (int row))) + +;gtk_clist_set_row_data +;gtk_clist_get_row_data +;gtk_clist_find_row_from_data + +(define-func gtk_clist_select_row + none + ((GtkCList clist) + (int row) + (int column))) + +(define-func gtk_clist_unselect_row + none + ((GtkCList clist) + (int row) + (int column))) + +(define-func gtk_clist_undo_selection + none + ((GtkCList clist))) + +(define-func gtk_clist_clear + none + ((GtkCList clist))) + +;gtk_clist_get_selection_info + +(define-func gtk_clist_select_all + none + ((GtkCList clist))) + +(define-func gtk_clist_unselect_all + none + ((GtkCList clist))) + +(define-func gtk_clist_swap_rows + none + ((GtkCList clist) + (int row1) (int row2))) + +(define-func gtk_clist_row_move + none + ((GtkCList clist) + (int source_row) + (int dest_row))) + +(define-func gtk_clist_set_sort_column + none + ((GtkCList clist) + (int column))) + +(define-func gtk_clist_set_sort_type + none + ((GtkCList clist) + (GtkSortType sort_type))) + +(define-func gtk_clist_sort + none + ((GtkCList clist))) + +(define-func gtk_clist_set_auto_sort + none + ((GtkCList clist) + (bool auto_sort))) + +;;;; GtkCombo + +(define-object GtkCombo (GtkHBox) + (fields + (GtkWidget entry) + (GtkWidget list))) + +(define-func gtk_combo_new + GtkWidget + ()) + +(define-func gtk_combo_set_value_in_list + none + ((GtkCombo combo) + (bool val) + (bool ok_if_empty))) + +(define-func gtk_combo_set_use_arrows + none + ((GtkCombo combo) + (bool val))) + +(define-func gtk_combo_set_use_arrows_always + none + ((GtkCombo combo) + (bool val))) + +(define-func gtk_combo_set_case_sensitive + none + ((GtkCombo combo) + (bool val))) + +(define-func gtk_combo_set_item_string + none + ((GtkCombo combo) + (GtkItem item) + (string item_value))) + +;gtk_combo_set_popdown_strings + +(define-func gtk_combo_disable_activate + none + ((GtkCombo combo))) + + +;; ListItem + +(define-object GtkListItem (GtkItem)) + +(define-func gtk_list_item_new + GtkWidget + ()) + +(define-func gtk_list_item_new_with_label + GtkWidget + ((string label))) + +(define-func gtk_list_item_select + none + ((GtkListItem list_item))) + +(define-func gtk_list_item_deselect + none + ((GtkListItem list_item))) + +;; List + +(define-object GtkList (GtkContainer)) + +(define-func gtk_list_new + GtkWidget + ()) + +;gtk_list_insert_items +;gtk_list_append_items +;gtk_list_prepend_items +;gtk_list_remove_items + +(define-func gtk_list_clear_items + none + ((GtkList list) + (int start) + (int end))) + +(define-func gtk_list_select_item + none + ((GtkList list) + (int item))) + +(define-func gtk_list_unselect_item + none + ((GtkList list) + (int item))) + +(define-func gtk_list_select_child + none + ((GtkList list) + (GtkWidget child))) + +(define-func gtk_list_unselect_child + none + ((GtkList list) + (GtkWidget child))) + +(define-func gtk_list_child_position + int + ((GtkList list) + (GtkWidget child))) + +(define-func gtk_list_set_selection_mode + none + ((GtkList list) + (GtkSelectionMode mode))) + +(define-func gtk_list_extend_selection + none + ((GtkList list) + (GtkScrollType scroll_type) + (float position) + (bool auto_start))) + +(define-func gtk_list_start_selection + none + ((GtkList list))) + +(define-func gtk_list_end_selection + none + ((GtkList list))) + +(define-func gtk_list_select_all + none + ((GtkList list))) + +(define-func gtk_list_unselect_all + none + ((GtkList list))) + +(define-func gtk_list_scroll_horizontal + none + ((GtkList list) + (GtkScrollType scroll_type) + (float pos))) + +(define-func gtk_list_scroll_vertical + none + ((GtkList list) + (GtkScrollType scroll_type) + (float pos))) + +(define-func gtk_list_toggle_add_mode + none + ((GtkList list))) + +(define-func gtk_list_toggle_focus_row + none + ((GtkList list))) + +(define-func gtk_list_toggle_row + none + ((GtkList list) + (GtkWidget item))) + +(define-func gtk_list_undo_selection + none + ((GtkList list))) + +(define-func gtk_list_end_drag_selection + none + ((GtkList list))) + + +;; GtkCTree + +(define-object GtkCTree (GtkCList)) + +; gtk_ctree_new_with_titles + +(define-func gtk_ctree_new_with_titles + GtkWidget + ((int columns) + (int tree_column))) + +;gtk_ctree_insert_node +(define-func gtk_ctree_remove_node + none + ((GtkCTree ctree) + (GtkCTreeNode node))) + +(define-func gtk_ctree_is_viewable + bool + ((GtkCTree ctree) + (GtkCTreeNode node))) + +(define-func gtk_ctree_last + GtkCTreeNode + ((GtkCTree ctree) + (GtkCTreeNode node))) + +;gtk_ctree_find_node_ptr +(define-func gtk_ctree_node_nth + GtkCTreeNode + ((GtkCTree ctree) + (uint row))) + +(define-func gtk_ctree_find + bool + ((GtkCTree ctree) + (GtkCTreeNode node) + (GtkCTreeNode child))) + +(define-func gtk_ctree_is_ancestor + bool + ((GtkCTree ctree) + (GtkCTreeNode node) + (GtkCTreeNode child))) + +; gtk_ctree_find_by_row_data +; gtk_ctree_find_all_by_row_data +(define-func gtk_ctree_is_hot_spot + bool + ((GtkCTree ctree) + (int x) (int y))) + +;; defined in gtkmodule.c (so that parent and sibling can be None) +;(define-func gtk_ctree_move +; none +; ((GtkCTree ctree) +; (GtkCTreeNode node) +; (GtkCTreeNode new_parent) +; (GtkCTreeNode new_sibling))) + +(define-func gtk_ctree_expand + none + ((GtkCTree ctree) + (GtkCTreeNode node))) + +(define-func gtk_ctree_expand_recursive + none + ((GtkCTree ctree) + (GtkCTreeNode node))) + +(define-func gtk_ctree_expand_to_depth + none + ((GtkCTree ctree) + (GtkCTreeNode node) + (int depth))) + +(define-func gtk_ctree_collapse + none + ((GtkCTree ctree) + (GtkCTreeNode node))) + +(define-func gtk_ctree_collapse_recursive + none + ((GtkCTree ctree) + (GtkCTreeNode node))) + +(define-func gtk_ctree_collapse_to_depth + none + ((GtkCTree ctree) + (GtkCTreeNode node) + (int depth))) + +(define-func gtk_ctree_toggle_expansion + none + ((GtkCTree ctree) + (GtkCTreeNode node))) + +(define-func gtk_ctree_toggle_expansion_recursive + none + ((GtkCTree ctree) + (GtkCTreeNode node))) + +(define-func gtk_ctree_select + none + ((GtkCTree ctree) + (GtkCTreeNode node))) + +(define-func gtk_ctree_select_recursive + none + ((GtkCTree ctree) + (GtkCTreeNode node))) + +(define-func gtk_ctree_unselect + none + ((GtkCTree ctree) + (GtkCTreeNode node))) + +(define-func gtk_ctree_unselect_recursive + none + ((GtkCTree ctree) + (GtkCTreeNode node))) + +(define-func gtk_ctree_real_select_recursive + none + ((GtkCTree ctree) + (GtkCTreeNode node) + (int state))) + +(define-func gtk_ctree_node_set_text + none + ((GtkCTree ctree) + (GtkCTreeNode node) + (int column) + (string text))) + +(define-func gtk_ctree_node_set_pixmap + none + ((GtkCTree ctree) + (GtkCTreeNode node) + (int column) + (GdkPixmap pixmap) + (GdkBitmap mask))) + +(define-func gtk_ctree_node_set_pixtext + none + ((GtkCTree ctree) + (GtkCTreeNode node) + (int column) + (string text) + (uint spacing) + (GdkPixmap pixmap) + (GdkBitmap mask))) + +(define-func gtk_ctree_set_node_info + none + ((GtkCTree ctree) + (GtkCTreeNode node) + (string text) + (uint spacing) + (GdkPixmap pixmap_closed) (GdkBitmap mask_closed) + (GdkPixmap pixmap_opened) (GdkBitmap mask_opened) + (bool is_leaf) + (bool expanded))) + +(define-func gtk_ctree_node_set_shift + none + ((GtkCTree ctree) + (GtkCTreeNode node) + (int column) + (int vertical) (int horizontal))) + +(define-func gtk_ctree_node_set_selectable + none + ((GtkCTree ctree) + (GtkCTreeNode node) + (bool selectable))) + +(define-func gtk_ctree_node_get_selectable + bool + ((GtkCTree ctree) + (GtkCTreeNode node))) + +(define-func gtk_ctree_node_get_cell_type + GtkCellType + ((GtkCTree ctree) + (GtkCTreeNode node) + (int column))) + +;gtk_ctree_node_get_text +;gtk_ctree_node_get_pixmap +;gtk_ctree_node_get_pixtext +;gtk_ctree_get_node_info + +(define-func gtk_ctree_node_set_row_style + none + ((GtkCTree ctree) + (GtkCTreeNode node) + (GtkStyle style))) + +(define-func gtk_ctree_node_get_row_style + GtkStyle + ((GtkCTree ctree) + (GtkCTreeNode node))) + +(define-func gtk_ctree_node_set_cell_style + none + ((GtkCTree ctree) + (GtkCTreeNode node) + (int column) + (GtkStyle style))) + +(define-func gtk_ctree_node_get_cell_style + GtkStyle + ((GtkCTree ctree) + (GtkCTreeNode node) + (int column))) + +(define-func gtk_ctree_node_set_foreground + none + ((GtkCTree ctree) + (GtkCTreeNode node) + (GdkColor color))) + +(define-func gtk_ctree_node_set_background + none + ((GtkCTree ctree) + (GtkCTreeNode node) + (GdkColor color))) + +;gtk_ctree_node_set_row_data +;gtk_ctree_node_get_row_data +(define-func gtk_ctree_node_moveto + none + ((GtkCTree ctree) + (GtkCTreeNode node) + (int column) + (float row_align) + (float col_align))) + +(define-func gtk_ctree_node_is_visible + GtkVisibility + ((GtkCTree ctree) + (GtkCTreeNode node))) + +(define-func gtk_ctree_set_indent + none + ((GtkCTree ctree) + (int indent))) + +(define-func gtk_ctree_set_spacing + none + ((GtkCTree ctree) + (int spacing))) + +(define-func gtk_ctree_set_show_stub + none + ((GtkCTree ctree) + (bool show_stub))) + +(define-func gtk_ctree_set_reorderable + none + ((GtkCTree ctree) + (bool reorderable))) + +(define-func gtk_ctree_set_use_drag_icons + none + ((GtkCTree ctree) + (bool use_icons))) + +(define-func gtk_ctree_set_line_style + none + ((GtkCTree ctree) + (GtkCTreeLineStyle style))) + +(define-func gtk_ctree_set_expander_style + none + ((GtkCTree ctree) + (GtkCTreeExpanderStyle style))) + +(define-func gtk_ctree_sort_node + none + ((GtkCTree ctree) + (GtkCTreeNode node))) + +(define-func gtk_ctree_sort_recursive + none + ((GtkCTree ctree) + (GtkCTreeNode node))) + diff --git a/generate/gtkmenus.defs b/generate/gtkmenus.defs new file mode 100644 index 00000000..becd30d7 --- /dev/null +++ b/generate/gtkmenus.defs @@ -0,0 +1,295 @@ +; -*- scheme -*- +;; MenuShell + +(define-object GtkMenuShell (GtkContainer)) + +(define-func gtk_menu_shell_append + none + ((GtkMenuShell menu_shell) + (GtkWidget child))) + +(define-func gtk_menu_shell_prepend + none + ((GtkMenuShell menu_shell) + (GtkWidget child))) + +(define-func gtk_menu_shell_insert + none + ((GtkMenuShell menu_shell) + (GtkWidget child) + (int position))) + +(define-func gtk_menu_shell_deactivate + none + ((GtkMenuShell menu_shell))) + +(define-func gtk_menu_shell_select_item + none + ((GtkMenuShell menu_shell) + (GtkWidget menu_item))) + +(define-func gtk_menu_shell_activate_item + none + ((GtkMenuShell menu_shell) + (GtkWidget menu_item) + (bool force_deactivate))) + +;; MenuBar + +(define-object GtkMenuBar (GtkMenuShell)) + +(define-func gtk_menu_bar_new + GtkWidget + ()) + +(define-func gtk_menu_bar_append + none + ((GtkMenuBar menu_bar) + (GtkWidget child))) + +(define-func gtk_menu_bar_prepend + none + ((GtkMenuBar menu_bar) + (GtkWidget child))) + +(define-func gtk_menu_bar_insert + none + ((GtkMenuBar menu_bar) + (GtkWidget child) + (int position))) + +(define-func gtk_menu_bar_set_shadow_type + none + ((GtkMenuBar menu_bar) + (GtkShadowType type))) + +;; Menu + +(define-object GtkMenu (GtkMenuShell)) + +(define-func gtk_menu_new + GtkWidget + ()) + +(define-func gtk_menu_append + none + ((GtkMenu menu) + (GtkWidget child))) + +(define-func gtk_menu_prepend + none + ((GtkMenu menu) + (GtkWidget child))) + +(define-func gtk_menu_insert + none + ((GtkMenu menu) + (GtkWidget child) + (int position))) + +;gtk_menu_popup +(define-func gtk_menu_reposition + none + ((GtkMenu menu))) + +(define-func gtk_menu_popdown + none + ((GtkMenu menu))) + +(define-func gtk_menu_get_active + GtkWidget + ((GtkMenu menu))) + +(define-func gtk_menu_set_active + none + ((GtkMenu menu) + (int index))) + +(define-func gtk_menu_set_accel_group + none + ((GtkMenu menu) + (GtkAccelGroup group))) + +;; gtk_menu_attach_to_widget + +(define-func gtk_menu_get_attach_widget + GtkWidget + ((GtkMenu menu))) + +(define-func gtk_menu_detach + none + ((GtkMenu menu))) + +(define-func gtk_menu_set_tearoff_state + none + ((GtkMenu menu) + (bool torn_off))) + +;; MenuItem + +(define-object GtkMenuItem (GtkItem)) + +(define-func gtk_menu_item_new + GtkWidget + ()) + +(define-func gtk_menu_item_new_with_label + GtkWidget + ((string label))) + +(define-func gtk_menu_item_set_submenu + none + ((GtkMenuItem menu_item) + (GtkWidget submenu))) + +(define-func gtk_menu_item_remove_submenu + none + ((GtkMenuItem menu_item))) + +(define-func gtk_menu_item_set_placement + none + ((GtkMenuItem menu_item) + (GtkSubmenuPlacement placement))) + +(define-func gtk_menu_item_configure + none + ((GtkMenuItem menu_item) + (bool show_toggle_indicator) + (bool show_submenu_indicator))) + +(define-func gtk_menu_item_select + none + ((GtkMenuItem menu_item))) + +(define-func gtk_menu_item_deselect + none + ((GtkMenuItem menu_item))) + +(define-func gtk_menu_item_activate + none + ((GtkMenuItem menu_item))) + +(define-func gtk_menu_item_right_justify + none + ((GtkMenuItem menu_item))) + +;; CheckMenuItem + +(define-object GtkCheckMenuItem (GtkMenuItem) + (fields + (uint active))) + +(define-func gtk_check_menu_item_new + GtkWidget + ()) + +(define-func gtk_check_menu_item_new_with_label + GtkWidget + ((string label))) + +(define-func gtk_check_menu_item_set_state + none + ((GtkCheckMenuItem check_menu_item) + (bool state))) + +(define-func gtk_check_menu_item_set_show_toggle + none + ((GtkCheckMenuItem menu_item) + (bool always))) + +(define-func gtk_check_menu_item_toggled + none + ((GtkCheckMenuItem check_menu_item))) + +;; RadioMenuItem + +(define-object GtkRadioMenuItem (GtkCheckMenuItem)) + +;(define-func gtk_radio_menu_item_new_interp +; GtkWidget +; ((GtkRadioMenuItem group (null-ok)))) + +;(define-func gtk_radio_menu_item_new_with_label_interp +; GtkWidget +; ((GtkRadioMenuItem group (null-ok)) +; (string label))) + +;; OptionMenu + +(define-object GtkOptionMenu (GtkButton)) + +(define-func gtk_option_menu_new + GtkWidget + ()) + +(define-func gtk_option_menu_get_menu + GtkWidget + ((GtkOptionMenu option_menu))) + +(define-func gtk_option_menu_set_menu + none + ((GtkOptionMenu option_menu) + (GtkWidget menu))) + +(define-func gtk_option_menu_remove_menu + none + ((GtkOptionMenu option_menu))) + +(define-func gtk_option_menu_set_history + none + ((GtkOptionMenu option_menu) + (int index))) + +;; Tearoffs +(define-object GtkTearoffMenuItem (GtkMenuItem)) +(define-func gtk_tearoff_menu_item_new + GtkWidget + ()) + +;; Item Factory +(define-object GtkItemFactory (GtkObject)) + +(define-func gtk_item_factory_new + GtkItemFactory + ((uint container_type) + (string path) + (GtkAccelGroup group))) + +(define-func gtk_item_factory_parse_rc + none + ((string file_name))) + +(define-func gtk_item_factory_parse_rc_string + none + ((string rc_string))) + +(define-func gtk_item_factory_from_widget + GtkItemFactory + ((GtkWidget widget))) + +(define-func gtk_item_factory_path_from_widget + static_string + ((GtkWidget widget))) + +(define-func gtk_item_factory_get_widget + GtkWidget + ((GtkItemFactory ifactory) + (string path))) + +(define-func gtk_item_factory_get_widget_by_action + GtkWidget + ((GtkItemFactory ifactory) + (uint action))) + +;gtk_item_factory_create_items +(define-func gtk_item_factory_delete_item + none + ((GtkItemFactory ifactory) + (string path))) + +(define-func gtk_item_factory_popup + none + ((GtkItemFactory ifactory) + (uint x) (uint y) + (uint mouse_button) + (uint time)))
\ No newline at end of file diff --git a/generate/gtkmisc.defs b/generate/gtkmisc.defs new file mode 100644 index 00000000..d16ebc74 --- /dev/null +++ b/generate/gtkmisc.defs @@ -0,0 +1,803 @@ +; -*- scheme -*- +;;;; Toolbar + +(define-object GtkToolbar (GtkContainer)) + +(define-func gtk_toolbar_new + GtkWidget + ((GtkOrientation orientation) + (GtkToolbarStyle style))) + +;; gtk_toolbar_append_item +;; gtk_toolbar_prepend_item +;; gtk_toolbar_insert_item + +(define-func gtk_toolbar_append_space + none + ((GtkToolbar toolbar))) + +(define-func gtk_toolbar_prepend_space + none + ((GtkToolbar toolbar))) + +(define-func gtk_toolbar_insert_space + none + ((GtkToolbar toolbar) + (int position))) + +;; XXX - need interp version to handle the callback properly, probably +;; some null-ok stuff to handle missing fields. +;; (define-func gtk_toolbar_append_element) +;; (define-func gtk_toolbar_prepend_element) +;; (define-func gtk_toolbar_insert_element) + +(define-func gtk_toolbar_append_widget + none + ((GtkToolbar Toolbar) + (GtkWidget Widget) + (string tooltip_text) + (string tooltip_private_text))) + +(define-func gtk_toolbar_prepend_widget + none + ((GtkToolbar Toolbar) + (GtkWidget Widget) + (string tooltip_text) + (string tooltip_private_text))) + +(define-func gtk_toolbar_insert_widget + none + ((GtkToolbar toolbar) + (GtkWidget widget) + (string tooltip_text) + (string tooltip_private_text) + (int position))) + +(define-func gtk_toolbar_set_orientation + none + ((GtkToolbar toolbar) + (GtkOrientation orientation))) + +(define-func gtk_toolbar_set_style + none + ((GtkToolbar toolbar) + (GtkToolbarStyle style))) + +(define-func gtk_toolbar_set_space_size + none + ((GtkToolbar toolbar) + (int space_size))) + +(define-func gtk_toolbar_set_tooltips + none + ((GtkToolbar toolbar) + (bool enable))) + +(define-func gtk_toolbar_set_button_relief + none + ((GtkToolbar toolbar) + (GtkReliefStyle relief))) + +(define-func gtk_toolbar_get_button_relief + GtkReliefStyle + ((GtkToolbar toolbar))) + +;;; Button + +(define-object GtkButton (GtkContainer)) + +(define-func gtk_button_new + GtkWidget + ()) + +(define-func gtk_button_new_with_label + GtkWidget + ((string label))) + +(define-func gtk_button_pressed + none + ((GtkButton button))) + +(define-func gtk_button_released + none + ((GtkButton button))) + +(define-func gtk_button_clicked + none + ((GtkButton button))) + +(define-func gtk_button_enter + none + ((GtkButton button))) + +(define-func gtk_button_leave + none + ((GtkButton button))) + +(define-func gtk_button_set_relief + none + ((GtkButton button) + (GtkReliefStyle newstyle))) + +(define-func gtk_button_get_relief + GtkReliefStyle + ((GtkButton button))) + +;;; ToggleButton + +(define-object GtkToggleButton (GtkButton) + (fields + (bool active) + (bool draw_indicator))) + +(define-func gtk_toggle_button_new + GtkWidget + ()) + +(define-func gtk_toggle_button_new_with_label + GtkWidget + ((string label))) + +(define-func gtk_toggle_button_set_mode + none + ((GtkToggleButton toggle_button) + (bool draw_indicator))) + +(define-func gtk_toggle_button_set_state + none + ((GtkToggleButton toggle_button) + (bool state))) + +(define-func gtk_toggle_button_toggled + none + ((GtkToggleButton toggle_button))) + +;;; CheckButton + +(define-object GtkCheckButton (GtkToggleButton)) + +(define-func gtk_check_button_new + GtkWidget + ()) + +(define-func gtk_check_button_new_with_label + GtkWidget + ((string label))) + +;;; RadioButton + +(define-object GtkRadioButton (GtkCheckButton)) + +(define-func gtk_radio_button_new_from_widget + GtkWidget + ((GtkRadioButton group))) + +(define-func gtk_radio_button_new_with_label_from_widget + GtkWidget + ((GtkRadioButton group (null-ok)) + (string label))) + +;;; Misc + +(define-object GtkMisc (GtkWidget)) + +(define-func gtk_misc_set_alignment + none + ((GtkMisc misc) + (float xalign) + (float yalign))) + +(define-func gtk_misc_set_padding + none + ((GtkMisc misc) + (int xpad) + (int ypad))) + +;;; Arrow + +(define-object GtkArrow (GtkMisc)) + +(define-func gtk_arrow_new + GtkWidget + ((GtkArrowType arrow_type) + (GtkShadowType shadow_type))) + +(define-func gtk_arrow_set + none + ((GtkArrow arrow) + (GtkArrowType arrow_type) + (GtkShadowType shadow_type))) + +;;; Label + +(define-object GtkLabel (GtkMisc)) + +(define-func gtk_label_new + GtkWidget + ((string str))) + +(define-func gtk_label_set + none + ((GtkLabel label) + (string str))) + +(define-func gtk_label_set_pattern + none + ((GtkLabel label) + (string pattern))) + +(define-func gtk_label_set_justify + none + ((GtkLabel label) + (GtkJustification jtype))) + +(define-func gtk_label_parse_uline + uint + ((GtkLabel label) + (string string))) + +;; Accel Label +(define-object GtkAccelLabel (GtkLabel)) + +(define-func gtk_accel_label_new + GtkWidget + ((string string))) + +(define-func gtk_accel_label_get_accel_width + uint + ((GtkAccelLabel accel_label))) + +(define-func gtk_accel_label_set_accel_widget + none + ((GtkAccelLabel accel_label) + (GtkWidget accel_widget))) + +(define-func gtk_accel_label_refetch + bool + ((GtkAccelLabel accel_label))) + +;; Tips Query + +(define-object GtkTipsQuery (GtkLabel)) + +(define-func gtk_tips_query_new + GtkWidget + ()) + +(define-func gtk_tips_query_start_query + none + ((GtkTipsQuery tips_query))) + +(define-func gtk_tips_query_stop_query + none + ((GtkTipsQuery tips_query))) + +(define-func gtk_tips_query_set_caller + none + ((GtkTipsQuery tips_query) + (GtkWidget caller))) + +(define-func gtk_tips_query_set_labels + none + ((GtkTipsQuery tips_query) + (string label_inactive) + (string label_no_tip))) + +;; Item + +(define-object GtkItem (GtkBin)) + +(define-func gtk_item_select + none + ((GtkItem item))) + +(define-func gtk_item_deselect + none + ((GtkItem item))) + +(define-func gtk_item_toggle + none + ((GtkItem item))) + +;;;; StatusBar + +(define-object GtkStatusbar (GtkHBox)) + +(define-func gtk_statusbar_new + GtkWidget + ()) + +(define-func gtk_statusbar_push + uint + ((GtkStatusbar statusbar) + (uint context_id) + (string text))) + +(define-func gtk_statusbar_pop + none + ((GtkStatusbar statusbar) + (uint context_id))) + +(define-func gtk_statusbar_get_context_id + uint + ((GtkStatusbar statusbar) + (string context_description))) + +(define-func gtk_statusbar_remove + none + ((GtkStatusbar statusbar) + (uint context_id) + (uint message_id))) + +;; Separator + +(define-object GtkSeparator (GtkWidget)) + +;; HSeparator + +(define-object GtkHSeparator (GtkSeparator)) + +(define-func gtk_hseparator_new + GtkWidget + ()) + +;; VSeparator + +(define-object GtkVSeparator (GtkSeparator)) + +(define-func gtk_vseparator_new + GtkWidget + ()) + +;; Progress +(define-object GtkProgress (GtkWidget)) + +(define-func gtk_progress_set_show_text + none + ((GtkProgress progress) + (int show_text))) + +(define-func gtk_progress_set_text_alignment + none + ((GtkProgress progress) + (float x_align) (float y_align))) + +(define-func gtk_progress_set_format_string + none + ((GtkProgress progress) + (string format))) + +(define-func gtk_progress_set_adjustment + none + ((GtkProgress progress) + (GtkAdjustment adjustment))) + +(define-func gtk_progress_configure + none + ((GtkProgress progress) + (float value) (float min) (float max))) + +(define-func gtk_progress_set_percentage + none + ((GtkProgress progress) + (float percentage))) + +(define-func gtk_progress_set_value + none + ((GtkProgress progress) + (float value))) + +(define-func gtk_progress_get_value + float + ((GtkProgress progress))) + +(define-func gtk_progress_set_activity_mode + none + ((GtkProgress progress) + (uint activity_mode))) + +(define-func gtk_progress_get_current_text + string + ((GtkProgress progress))) + +(define-func gtk_progress_get_text_from_value + string + ((GtkProgress progress) + (float value))) + +(define-func gtk_progress_get_current_percentage + float + ((GtkProgress progress))) + +(define-func gtk_progress_get_percentage_from_value + float + ((GtkProgress progress) + (float value))) + +;; Progress Bar + +(define-object GtkProgressBar (GtkProgressBar)) + +(define-func gtk_progress_bar_new + GtkWidget + ()) + +(define-func gtk_progress_bar_new_with_adjustment + GtkWidget + ((GtkAdjustment adjustment))) + +(define-func gtk_progress_bar_set_bar_style + none + ((GtkProgressBar pbar) + (GtkProgressBarStyle style))) + +(define-func gtk_progress_bar_set_discrete_blocks + none + ((GtkProgressBar pbar) + (uint blocks))) + +(define-func gtk_progress_bar_set_activity_step + none + ((GtkProgressBar pbar) + (uint step))) + +(define-func gtk_progress_bar_set_activity_blocks + none + ((GtkProgressBar pbar) + (uint blocks))) + +(define-func gtk_progress_bar_set_orientation + none + ((GtkProgressBar pbar) + (GtkProgressBarOrientation orientation))) + +(define-func gtk_progress_bar_update + none + ((GtkProgressBar progress_bar) + (float percentage))) + +;;(define-func gtk_progress_bar_percentage +;; float +;; ((GtkProgressBar progress_bar))) + +;; Pixmaps + +(define-object GtkPixmap (GtkMisc)) + +(define-func gtk_pixmap_new + GtkWidget + ((GdkPixmap pixmap) + (GdkBitmap mask))) + +(define-func gtk_pixmap_set + none + ((GtkPixmap pixmap) + (GdkPixmap val) + (GdkBitmap mask))) +;gtk_pixmap_get + +(define-func gtk_pixmap_set_build_insensitive + none + ((GtkPixmap pixmap) + (uint build))) + +;; ColorSelectionDialog + +(define-object GtkColorSelectionDialog (GtkWindow) + (fields + (GtkWidget colorsel) + (GtkWidget main_vbox) + (GtkWidget ok_button) + (GtkWidget reset_button) + (GtkWidget cancel_button) + (GtkWidget help_button))) + +(define-func gtk_color_selection_dialog_new + GtkWidget + ((string title))) + +;; ColorSelection + +(define-object GtkColorSelection (GtkVBox)) + +(define-func gtk_color_selection_new + GtkWidget + ()) + +(define-func gtk_color_selection_set_update_policy + none + ((GtkColorSelection colorsel) + (GtkUpdateType policy))) + +(define-func gtk_color_selection_set_opacity + none + ((GtkColorSelection colorsel) + (bool use_opacity))) + +;; XXX - uses gdouble * argument, an array of doubles, to represent colors +;; (define-func gtk_color_selection_set_color) + +;; XXX - uses gdouble * argument, an array of doubles, to represent colors +;; (define-func gtk_color_selection_get_color) + +;; Curve + +(define-object GtkCurve (GtkDrawingArea)) + +(define-func gtk_curve_new + GtkWidget + ()) + +(define-func gtk_curve_reset + none + ((GtkCurve curve))) + +(define-func gtk_curve_set_gamma + none + ((GtkCurve curve) + (float gamma))) + +(define-func gtk_curve_set_range + none + ((GtkCurve curve) + (float min_x) + (float max_x) + (float min_y) + (float max_y))) + +;; XXX - needs to convert something to length and array of floats +;; (define-func gtk_curve_set_vector) + +;; XXX - needs to conver something to length and array of floats +;; (define-func gtk_curve_get_vector) + +(define-func gtk_curve_set_curve_type + none + ((GtkCurve curve) + (GtkCurveType type))) + +;;;; GammaCurve + +(define-object GtkGammaCurve (GtkVBox) + (fields + (GtkWidget table) + (GtkWidget curve) + (float gamma) + (GtkWidget gamma_dialog) + (GtkWidget gamma_text))) + +(define-func gtk_gamma_curve_new + GtkWidget + ()) + +;; InputDialog + +(define-object GtkInputDialog (GtkDialog) + (fields + (GtkWidget close_button) + (GtkWidget save_button))) + +(define-func gtk_input_dialog_new + GtkWidget + ()) + +;; DrawingArea + +(define-object GtkDrawingArea (GtkWidget)) + +(define-func gtk_drawing_area_new + GtkWidget + ()) + +(define-func gtk_drawing_area_size + none + ((GtkDrawingArea darea) + (int width) + (int height))) + +;; FileSelection + +(define-object GtkFileSelection (GtkWindow) + (fields + (GtkWidget dir_list) + (GtkWidget file_list) + (GtkWidget selection_entry) + (GtkWidget selection_text) + (GtkWidget main_vbox) + (GtkWidget ok_button) + (GtkWidget cancel_button) + (GtkWidget help_button))) + +(define-func gtk_file_selection_new + GtkWidget + ((string title))) + +(define-func gtk_file_selection_set_filename + none + ((GtkFileSelection filesel) + (string filename))) + +(define-func gtk_file_selection_get_filename + static_string + ((GtkFileSelection filesel))) + +(define-func gtk_file_selection_complete + none + ((GtkFileSelection filesel) + (string pattern))) + +(define-func gtk_file_selection_show_fileop_buttons + none + ((GtkFileSelection filesel))) + +(define-func gtk_file_selection_hide_fileop_buttons + none + ((GtkFileSelection filesel))) + +;; Font Selection +(define-object GtkFontSelection (GtkNotebook)) + +(define-func gtk_font_selection_new + GtkWidget + ()) + +(define-func gtk_font_selection_get_font_name + string + ((GtkFontSelection fontsel))) + +(define-func gtk_font_selection_get_font + GdkFont + ((GtkFontSelection fontsel))) + +(define-func gtk_font_selection_set_font_name + bool + ((GtkFontSelection fontsel) + (string fontname))) + +(define-func gtk_font_selection_get_preview_text + static_string + ((GtkFontSelection fontsel))) + +(define-func gtk_font_selection_set_preview_text + none + ((GtkFontSelection fontsel) + (string text))) + +(define-object GtkFontSelectionDialog (GtkWindow) + (fields + (GtkWidget fontsel) + (GtkWidget main_vbox) + (GtkWidget action_area) + (GtkWidget ok_button) + (GtkWidget apply_button) + (GtkWidget cancel_button))) + +(define-func gtk_font_selection_dialog_new + GtkWidget + ((string title))) + +(define-func gtk_font_selection_dialog_get_font_name + string + ((GtkFontSelectionDialog fsd))) + +(define-func gtk_font_selection_dialog_get_font + GdkFont + ((GtkFontSelectionDialog fsd))) + +(define-func gtk_font_selection_dialog_set_font_name + bool + ((GtkFontSelectionDialog fsd) + (string fontname))) + +(define-func gtk_font_selection_dialog_get_preview_text + static_string + ((GtkFontSelectionDialog fsd))) + +(define-func gtk_font_selection_dialog_set_preview_text + none + ((GtkFontSelectionDialog fsd) + (string text))) + +(define-object GtkPreview (GtkWidget)) + +(define-func gtk_preview_new + GtkWidget + ((GtkPreviewType type))) + +(define-func gtk_preview_size + none + ((GtkPreview preview) + (int width) + (int height))) + +(define-func gtk_preview_put + none + ((GtkPreview preview) + (GdkWindow window) + (GdkGC gc) + (int srcx) (int srcy) + (int destx) (int desty) + (int width) (int height))) + +(define-func gtk_preview_draw_row + none + ((GtkPreview preview) + (string data) + (int x) (int y) + (int width))) + +(define-func gtk_preview_set_expand + none + ((GtkPreview preview) + (int expand))) + +(define-func gtk_preview_set_gamma + none + ((double gamma))) + +(define-func gtk_preview_set_color_cube + none + ((uint nred_shades) + (uint ngreen_shades) + (uint nblue_shades) + (uint ngray_shades))) + +(define-func gtk_preview_set_install_cmap + none + ((int install_cmap))) + +(define-func gtk_preview_set_reserved + none + ((int nreserved))) + +(define-func gtk_preview_set_dither + none + ((GtkPreview preview) + (GdkRgbDither dither))) + +;; Calendar widget +(define-object GtkCalendar (GtkWidget)) + +(define-func gtk_calendar_new + GtkWidget + ()) + +(define-func gtk_calendar_select_month + int + ((GtkCalendar calendar) + (uint month) + (uint year))) + +(define-func gtk_calendar_select_day + none + ((GtkCalendar calendar) + (uint day))) + +(define-func gtk_calendar_mark_day + int + ((GtkCalendar calendar) + (uint day))) + +(define-func gtk_calendar_unmark_day + int + ((GtkCalendar calendar) + (uint day))) + +(define-func gtk_calendar_clear_marks + none + ((GtkCalendar calendar))) + +(define-func gtk_calendar_display_options + none + ((GtkCalendar calendar) + (GtkCalendarDisplayOptions flags))) + +;; gtk_calendar_get_date + +(define-func gtk_calendar_freeze + none + ((GtkCalendar calendar))) + +(define-func gtk_calendar_thaw + none + ((GtkCalendar calendar))) diff --git a/generate/gtkranges.defs b/generate/gtkranges.defs new file mode 100644 index 00000000..a4f827c8 --- /dev/null +++ b/generate/gtkranges.defs @@ -0,0 +1,149 @@ +; -*- scheme -*- +(define-object GtkRange (GtkWidget)) + +(define-func gtk_range_get_adjustment + GtkAdjustment + ((GtkRange range))) + +(define-func gtk_range_set_update_policy + none + ((GtkRange range) + (GtkUpdateType policy))) + +(define-func gtk_range_set_adjustment + none + ((GtkRange range) + (GtkAdjustment adjustment))) + +(define-func gtk_range_draw_background + none + ((GtkRange range))) + +(define-func gtk_range_clear_background + none + ((GtkRange range))) + +(define-func gtk_range_draw_trough + none + ((GtkRange range))) + +(define-func gtk_range_draw_slider + none + ((GtkRange range))) + +(define-func gtk_range_draw_step_forw + none + ((GtkRange range))) + +(define-func gtk_range_draw_step_back + none + ((GtkRange range))) + +(define-func gtk_range_slider_update + none + ((GtkRange range))) + +;; Scale + +(define-object GtkScale (GtkRange)) + +(define-func gtk_scale_set_digits + none + ((GtkScale scale) + (uint digits))) + +(define-func gtk_scale_set_draw_value + none + ((GtkScale scale) + (bool draw_value))) + +(define-func gtk_scale_set_value_pos + none + ((GtkScale scale) + (GtkPositionType pos))) + +(define-func gtk_scale_get_value_width + int + ((GtkScale scale))) + +(define-func gtk_scale_draw_value + none + ((GtkScale scale))) + +;; HScale + +(define-object GtkHScale (GtkScale)) + +(define-func gtk_hscale_new + GtkWidget + ((GtkAdjustment adjustment))) + +;; VScale + +(define-object GtkVScale (GtkScale)) + +(define-func gtk_vscale_new + GtkWidget + ((GtkAdjustment adjustment))) + +;; Scrollbar + +(define-object GtkScrollbar (GtkRange)) + +;; HScrollbar + +(define-object GtkHScrollbar (GtkScrollbar)) + +(define-func gtk_hscrollbar_new + GtkWidget + ((GtkAdjustment adjustment))) + +;; VScrollbar + +(define-object GtkVScrollbar (GtkScrollbar)) + +(define-func gtk_vscrollbar_new + GtkWidget + ((GtkAdjustment adjustment))) + +;; Ruler + +(define-object GtkRuler (GtkWidget)) + +(define-func gtk_ruler_set_metric + none + ((GtkRuler ruler) + (GtkMetricType metric))) + +(define-func gtk_ruler_set_range + none + ((GtkRuler ruler) + (float lower) + (float upper) + (float position) + (float max_size))) + +(define-func gtk_ruler_draw_ticks + none + ((GtkRuler ruler))) + +(define-func gtk_ruler_draw_pos + none + ((GtkRuler ruler))) + +;; HRuler + +(define-object GtkHRuler (GtkRuler)) + +(define-func gtk_hruler_new + GtkWidget + ()) + +;; VRuler + +(define-object GtkVRuler (GtkRuler)) + +(define-func gtk_vruler_new + GtkWidget + ()) + diff --git a/generate/scmexpr.py b/generate/scmexpr.py new file mode 100644 index 00000000..daa769bd --- /dev/null +++ b/generate/scmexpr.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python +import string +import types +# get the fastest implementation of StringIO +try: + from cStringIO import StringIO +except ImportError: + from StringIO import StringIO + +trans = [' '] * 256 +for i in range(256): + if chr(i) in string.letters + string.digits + '_': + trans[i] = chr(i) + else: + trans[i] = '_' +trans = string.join(trans, '') + +def parse(fp): + stack = [()] + line = fp.readline() + while line: + while line: + line = string.lstrip(line) + if not line: + break + elif line[0] == '(': + stack.append(()) + line = line[1:] + elif line[0] == ')': + closed = stack[-1] + del stack[-1] + stack[-1] = stack[-1] + (closed,) + line = line[1:] + elif line[0] == '"': + pos = string.index(line[1:], '"') + stack[-1] = stack[-1] + (eval(line[:pos+2]),) + line = line[pos+2:] + elif line[0] in string.digits: + str = "" + while line and line[0] in "0123456789+-.": + str = str + line[0] + line = line[1:] + stack[-1] = stack[-1] + (string.atof(str),) + elif line[0] == ';': + break + else: + str = "" + while line and line[0] not in " \t();\n": + str = str + line[0] + line = line[1:] + stack[-1] = stack[-1] + (str,) + line = fp.readline() + if len(stack) != 1: + raise IOError, "parentheses don't match" + return stack[0] + +class Parser: + def __init__(self, arg): + """Argument is either a string, a parse tree, or file object""" + if type(arg) == types.StringType: + self.filename = arg + self.parseTree = parse(open(arg)) + elif type(arg) == types.TupleType: + self.filename = '<none>' + self.parseTree = arg + elif type(arg) == types.FileType: + self.filename = arg.name + self.parseTree = parse(arg) + else: + raise TypeError, \ + 'second arg must be string, tuple or file' + def startParsing(self, tuples=None): + if tuples == None: tuples = self.parseTree + for tup in tuples: + self.handle(tup) + def handle(self, tup): + cmd = string.translate(tup[0], trans) + if hasattr(self, cmd): + apply(getattr(self, cmd), tup[1:]) + else: + self.unknown(tup) + def unknown(self, tup): + pass + +_testString = """; a scheme file +(define-func gdk_font_load ; a comment at end of line + GdkFont + ((string name))) + +(define-boxed GdkEvent + gdk_event_copy + gdk_event_free + "sizeof(GdkEvent)") +""" + +if __name__ == '__main__': + import sys + if sys.argv[1:]: + fp = open(sys.argv[1]) + else: + fp = StringIO(_testString) + statements = parse(fp) + for s in statements: + print `s` @@ -0,0 +1,2494 @@ +# +# gtk.py: Wrapper for the gtk module. This one gives an object oriented +# feel for the library. Just type "from gtk import *" +# +# Author: James Henstridge <james@daa.com.au> +# +# TODO +# 1. document some of this (maybe all of it) + +# The _obj argument in each constructor is used to create a gtk object +# that coresponds to an already created GTK Object. It should be possible +# to call any of the gtk object constructors something like this: +# GtkContainer(_obj=gtk_obj) where gtk_obj is an already created GtkObject. +# +# To make the use of this system easier, you can use the _obj2inst function +# to create a gtk object of the correct type from a GtkObject. This +# is the function the new() command uses. + +from GTK import * +import GDK # make the GDK constants available +import _gtk +import sys, os + +# this sets up i18n input stuff +_gtk.gtk_set_locale() + +# initialise GTK (only if it can find the display -- this avoids segfaults) +if '--display' in sys.argv or os.environ.has_key('DISPLAY'): + _gtk.gtk_init() +else: + print 'No display information -- gtk_init not called' +del sys, os + +class GtkObject: + get_type = _gtk.gtk_object_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + def set(self, dict): + _filtprops(dict) + _gtk.gtk_object_set(self._o, dict) + def __getitem__(self, key): + ret = _gtk.gtk_object_get(self._o, key) + if type(ret) == _gtk.GtkObjectType: + return _obj2inst(ret) + else: + return ret + def __setitem__(self, key, v): + if hasattr(v, '_o') and type(v._o) == _gtk.GtkObjectType: + v = v._o + _gtk.gtk_object_set(self._o, {key: v}); + def __cmp__(self, other): + if hasattr(other, '_o'): + return cmp(self._o, other._o) + else: + return cmp(id(self), id(other)) + def flags(self, mask=None): + if mask: + return _gtk.GTK_OBJECT_FLAGS(self._o) & mask + else: + return _gtk.GTK_OBJECT_FLAGS(self._o) + def set_flags(self, flags): + _gtk.GTK_OBJECT_SET_FLAGS(self._o, flags) + def unset_flags(self, flags): + _gtk.GTK_OBJECT_UNSET_FLAGS(self._o, flags) + def set_data(self, key, value): + _gtk.gtk_object_set_data(self._o, key, value) + def get_data(self, key): + return _gtk.gtk_object_get_data(self._o, key) + def remove_data(self, key): + _gtk.gtk_object_remove_data(self._o) + class __cnv: + def __init__(self, func): + self.func = func + def __call__(self, *args): + a = list(args) + for i in range(len(args)): + if type(args[i]) == _gtk.GtkObjectType: + a[i] = _obj2inst(args[i]) + a = tuple(a) + ret = apply(self.func, a) + if hasattr(ret, '_o'): ret = ret._o + return ret + def connect(self, name, f, *extra): + callback = self.__cnv(f) + return _gtk.gtk_signal_connect(self._o, name, + callback.__call__, extra) + signal_connect = connect + def connect_after(self, name, f, *extra): + callback = self.__cnv(f) + return _gtk.gtk_signal_connect_after(self._o, name, + callback.__call__, extra) + signal_connect_after = connect_after + def disconnect(self, id): + _gtk.gtk_signal_disconnect(self._o, id) + def signal_handler_block(self, id): + _gtk.gtk_signal_handler_block(self._o, id) + def signal_handler_unblock(self, id): + _gtk.gtk_signal_handler_unblock(self._o, id) + def signal_handlers_destroy(self): + _gtk.gtk_signal_handlers_destroy(self._o) + def emit(self, signal, *args): + params = [] + for i in args: + if hasattr(i, '_o'): params.append(i._o) + elif hasattr(i, '_ag'): params.append(i._ag) + else: params.append(i) + return _gtk.gtk_signal_emitv_by_name(self._o,signal,params) + def emit_stop_by_name(self, sig): + _gtk.gtk_signal_emit_stop_by_name(self._o, sig) + def destroy(self, _obj=None): + _gtk.gtk_object_destroy(self._o) + +class GtkData(GtkObject): + get_type = _gtk.gtk_data_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + +class GtkAdjustment(GtkData): + get_type = _gtk.gtk_adjustment_get_type + def __init__(self, value=0, lower=0, upper=0, step_incr=0, page_incr=0, + page_size=0, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_adjustment_new(value, lower, upper, + step_incr, page_incr, page_size) + def __getattr__(self, attr): + attrs = { + 'lower': _gtk.gtk_adjustment_get_lower, + 'upper': _gtk.gtk_adjustment_get_upper, + 'value': _gtk.gtk_adjustment_get_value, + 'step_increment': _gtk.gtk_adjustment_get_step_increment, + 'page_increment': _gtk.gtk_adjustment_get_page_increment, + 'page_size': _gtk.gtk_adjustment_get_page_size + } + if attr in attrs.keys(): + return attrs[attr](self._o) + raise AttributeError, attr + def set_value(self, value): + _gtk.gtk_adjustment_set_value(self._o, value) + def clamp_page(self, lower, upper): + _gtk.gtk_adjustment_clamp_page(self._o, lower, upper) + def changed(self, obj=None): + _gtk.gtk_adjustment_changed(self._o) + def value_changed(self, obj=None): + _gtk.gtk_adjustment_value_changed(self._o) + +class GtkTooltips(GtkData): + get_type = _gtk.gtk_tooltips_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_tooltips_new() + def enable(self): + _gtk.gtk_tooltips_enable(self._o) + def disable(self, obj=None): + _gtk.gtk_tooltips_disable(self._o) + def set_delay(self, delay): + _gtk.gtk_tooltips_set_delay(self._o, delay) + def set_tip(self, w, tip, tip_private): + _gtk.gtk_tooltips_set_tip(self._o, w._o, tip, tip_private) + def set_tips(self, w, tip): + print "GtkTooltip.set_tips deprecated -- use set_tip instead" + self.set_tip(w, tip, tip) + def set_colors(self, back, fore): + _gtk.gtk_tooltips_set_colors(self._o, back, fore) + def force_window(self): + _gtk.gtk_tooltips_force_window(self._o) + +class GtkItemFactory(GtkObject): + get_type = _gtk.gtk_item_factory_get_type + def __init__(self, type=_gtk.gtk_menu_bar_get_type(), path='', + accel_group=None, _obj=None): + if _obj: self._o = _obj; return + if hasattr(type, 'get_type'): type = type.get_type() + self._o = _gtk.gtk_item_factory_new(type,path,accel_group._ag) + parse_rc = _gtk.gtk_item_factory_parse_rc + parse_rc_string = _gtk.gtk_item_factory_parse_rc_string + def get_widget(self, path): + return _obj2inst(_gtk.gtk_item_factory_get_widget(self._o, + path)) + def get_widget_by_action(self, action): + return _obj2inst(_gtk.gtk_item_factory_get_widget_by_action( + self._o, action)) + class __wrap_cb: + def __init__(self, cb): + self.cb = cb + def __call__(self, action, widget): + self.cb(action, _obj2inst(widget)) + def create_items(self, items): + def map_func((path,accel,cb,action,type), wrap=self.__wrap_cb): + if cb: + return (path,accel,wrap(cb).__call__,action, + type) + else: + return (path,accel,None,action,type) + items = map(map_func, items) + _gtk.gtk_item_factory_create_items(self._o, items) + def delete_item(self, path): + _gtk.gtk_item_factory_delete_item(self._o, path) + def popup(self, x, y, button, time): + _gtk.gtk_item_factory_popup(self._o, x, y, button, time) + +class GtkWidget(GtkObject): + get_type = _gtk.gtk_widget_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + # extra parameter is so that these funcs can be used as signal funcs + def activate(self, obj=None): + return _gtk.gtk_widget_activate(self._o) + def add_accelerator(self, signal, group, key, mods, flags): + _gtk.gtk_widget_add_accelerator(self._o, signal, group._ag, + key, mods, flags) + def destroy(self, obj=None): + _gtk.gtk_widget_destroy(self._o) + def drag_get_data(self, context, target, time): + _gtk.gtk_drag_get_data(self._o, context, target, time) + def drag_finish(self, context, success, delete, time): + _gtk.gtk_drag_finish(context, success, delete, time) + def drag_highlight(self): + _gtk.gtk_drag_highlight(self._o) + def drag_unhighlight(self): + _gtk.gtk_drag_unhighlight(self._o) + # targets is a list of 3-tuples of form + # (string target, int flags ,int info) + def drag_dest_set(self, flags, targets, actions): + _gtk.gtk_drag_dest_set(self._o, flags, targets, actions) + def drag_dest_set_proxy(self, proxy_window, protocol, use_coordinates): + _gtk.gtk_drag_dest_set_proxy(self._o, proxy_window, protocol, + use_coordinates) + def drag_dest_unset(self): + _gtk.gtk_drag_dest_unset(self._o) + # targets as for drag_dest_set + def drag_source_set(self, button_mask, targets, actions): + _gtk.gtk_drag_source_set(self._o, button_mask, targets,actions) + def drag_source_set_icon(self, colormap, pixmap, mask): + _gtk.gtk_drag_source_set_icon(self._o, colormap, pixmap, mask) + # targets as for drag_dest_set + def drag_begin(self, targets, actions, button, event): + return _gtk.gtk_drag_begine(self._o, targets, actions, button, + event) + def drag_set_icon_widget(self, context, widget, hot_x, hot_y): + _gtk.gtk_drag_set_icon_widget(context, widget._o, hot_x, hot_y) + def drag_set_icon_pixmap(self, context, colormap, pixmap, mask, + hot_x, hot_y): + _gtk.gtk_drag_set_icon_pixmap(context, colormap, pixmap, mask, + hot_x, hot_y) + def drag_set_icon_default(self, context): + _gtk.gtk_drag_set_icon_default(context) + def drag_set_default_icon(self, colormap, pixmap, mask, hot_x, hot_y): + _gtk.gtk_drag_set_default_icon(colormap, pixmap, mask, + hot_x, hot_y) + def drag_get_source_widget(self, context): + return _obj2inst(_gtk.gtk_drag_get_source_widget(context)) + def draw(self, rect): + _gtk.gtk_widget_draw(self._o, rect) + def draw_default(self, obj=None): + _gtk.gtk_widget_draw_default(self._o) + def draw_focus(self, obj=None): + _gtk.gtk_widget_draw_focus(self._o) + def ensure_style(self): + _gtk.gtk_widget_ensure_style(self._o) + def event(self, event): + _gtk.gtk_widget_event + def lock_accelerators(self): + _gtk.gtk_widget_lock_accelerators(self._o) + def get_ancestor(self, type): + return _obj2inst(_gtk.gtk_widget_get_ancestor(self._o, type)) + def get_composite_name(self): + return _gtk.gtk_widget_get_composite_name(self._o) + def get_events(self): + return _gtk.gtk_widget_get_events(self._o) + def get_extension_events(self): + return _gtk.gtk_widget_get_extension_events(self._o) + def get_name(self): + return _gtk.gtk_widget_get_name(self._o) + def get_parent_window(self): + return _gtk.gtk_widget_get_parent_window(self._o) + def get_pointer(self): + return _gtk.gtk_widget_get_pointer(self._o) + def get_style(self): + return _gtk.gtk_widget_get_style(self._o) + def get_toplevel(self): + return _obj2inst(_gtk.gtk_widget_get_toplevel(self._o)) + def get_window(self): + return _gtk.gtk_widget_get_window(self._o) + def grab_focus(self, obj=None): + _gtk.gtk_widget_grab_focus(self._o) + def grab_default(self, obj=None): + _gtk.gtk_widget_grab_default(self._o) + def hide(self, obj=None): + _gtk.gtk_widget_hide(self._o) + def hide_all(self, obj=None): + _gtk.gtk_widget_hide_all(self._o) + def hide_on_delete(self, obj=None): + return _gtk.gtk_widget_hide_on_delete(self._o) + def intersect(self, rect): + return _gtk.gtk_widget_intersect(self._o, rect) + def is_ancestor(self, a): + return _gtk.gtk_widget_is_ancestor(self._o, a._o) + def map(self, obj=None): + _gtk.gtk_widget_map(self._o) + def popup(self, x, y): + _gtk.gtk_widget_popup(self._o, x, y) + def queue_draw(self, obj=None): + _gtk.gtk_widget_queue_draw(self._o) + def queue_resize(self, obj=None): + _gtk.gtk_widget_queue_resize(self._o) + def realize(self, obj=None): + _gtk.gtk_widget_realize(self._o) + def remove_accelerator(self, group, key, mods): + _gtk.gtk_widget_remove_accelerator(self._o, group._ag, + key, mods) + def remove_accelerators(self, signal, visible_only): + _gtk.gtk_widget_remove_accelerators(self._o, signal, + visible_only) + def reparent(self, new_parent): + _gtk.gtk_widget_reparent(self._o, new_parent._o) + def reset_rc_styles(self): + _gtk.gtk_widget_reset_rc_styles(self._o) + def restore_default_style(self): + _gtk.gtk_widget_restore_default_style(self._o) + def selection_owner_set(self, selection, time): + return _gtk.gtk_selection_owner_set(self._o, selection, time) + def selection_add_target(self, selection, target, info): + _gtk.gtk_selection_add_target(self._o, selection, target, info) + def selection_convert(self, selection, target, time): + return _gtk.gtk_selection_convert(self._o, selection, + target, time) + def selection_remove_all(self): + _gtk.gtk_selection_remove_all(self._o) + def set_events(self, events): + _gtk.gtk_widget_set_events(self._o, events) + def add_events(self, events): + _gtk.gtk_widget_add_events(self._o, events) + def set_composite_name(self, name): + _gtk.gtk_widget_set_composite_name(self._o, name) + def set_extension_events(self, exevents): + _gtk.gtk_widget_set_extension_events(self._o, exevents) + def set_name(self, name): + _gtk.gtk_widget_set_name(self._o, name) + def set_parent(self, parent): + _gtk.gtk_widget_set_parent(self._o, parent._o) + def set_parent_window(self, parent): + _gtk.gtk_widget_set_parent_window(self._o, parent) + def set_scroll_adjustments(self, hadj, vadj): + _gtk.gtk_widget_set_scroll_adjustments(self._o,hadj._o,vadj._o) + def set_sensitive(self, s): + _gtk.gtk_widget_set_sensitive(self._o, s) + def set_state(self, s): + _gtk.gtk_widget_set_state(self._o, s) + def set_style(self, style): + _gtk.gtk_widget_set_style(self._o, style) + def set_rc_style(self): + _gtk.gtk_widget_set_rc_style(self._o) + def set_uposition(self, x, y): + _gtk.gtk_widget_set_uposition(self._o, x, y) + def set_usize(self, w, h): + _gtk.gtk_widget_set_usize(self._o, w, h) + def shape_combine_mask(self, mask, ofs_x, ofs_y): + if hasattr(mask, '_o'): + tmp, mask = mask.get() + _gtk.gtk_widget_shape_combine_mask(self._o, mask, ofs_x, ofs_y) + def show(self, obj=None): + _gtk.gtk_widget_show(self._o) + def show_all(self, obj=None): + _gtk.gtk_widget_show_all(self._o) + def show_now(self, obj=None): + _gtk.gtk_widget_show_now(self._o) + def size_allocate(self, a): + _gtk.gtk_widget_size_allocate(self._o, a) + def size_request(self): + return _gtk.gtk_widget_size_request(self._o) + def unlock_accelerators(self): + _gtk.gtk_widget_unlock_accelerators(self._o) + def unmap(self, obj=None): + _gtk.gtk_widget_unmap(self._o) + def unparent(self): + _gtk.gtk_widget_unparent(self._o) + def unrealize(self, obj=None): + _gtk.gtk_widget_unrealize(self._o) + +class GtkCalendar(GtkWidget): + get_type = _gtk.gtk_calendar_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_calendar_new() + def select_month(self, month, year): + return _gtk.gtk_calendar_select_month(self._o, month, year) + def select_day(self, day): + _gtk.gtk_calendar_select_day(self._o, day) + def mark_day(self, day): + return _gtk.gtk_calendar_mark_day(self._o, day) + def unmark_day(self, day): + return _gtk.gtk_calendar_unmark_day(self._o, day) + def clear_marks(self): + _gtk.gtk_calendar_clear_marks(self._o) + def display_options(self, flags): + _gtk.gtk_calendar_display_options(self._o, flags) + def get_date(self): + return _gtk.gtk_calendar_get_date(self._o) + def freeze(self): + _gtk.gtk_calendar_freeze(self._o) + def thaw(self): + _gtk.gtk_calendar_thaw(self._o) + +class GtkContainer(GtkWidget): + get_type = _gtk.gtk_container_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + def add(self, child, **args): + if args == {}: + _gtk.gtk_container_add(self._o, child._o) + else: + _gtk.gtk_container_add(self._o, child._o, args) + def border_width(self, bw): + print "border_width deprecated -- use set_border_width" + self.set_border_width(bw) + def set_border_width(self, bw): + _gtk.gtk_container_set_border_width(self._o, bw) + def check_resize(self): + _gtk.gtk_container_check_resize(self._o) + def child_composite_name(self, child): + return _gtk.gtk_container_child_composite_name(self._o, + child._o) + def child_set(self, child, **args): + _gtk.gtk_container_child_set(self._o, child._o, args) + def child_get(self, child, arg): + return _gtk.gtk_container_child_get(self._o, child._o, arg) + def children(self): + l = _gtk.gtk_container_children(self._o) + return map(_obj2inst, l) + def child_type(self): + return _gtk.gtk_container_child_type(self._o) + def focus(self, d): + _gtk.gtk_container_focus(self._o, d) + def foreach(self, f): + for child in self.children(): + f(child) + def register_toplevel(self): + _gtk.gtk_container_register_toplevel(self._o) + def remove(self, child): + _gtk.gtk_container_remove(self._o, child._o) + def resize_children(self): + _gtk.gtk_container_resize_children(self._o) + def set_focus_child(self, child): + _gtk.gtk_container_set_focus_child(self._o, child._o) + def set_focus_vadjustment(self, adj): + _gtk.gtk_container_set_focus_vadjustment(self._o, adj._o) + def set_focus_hadjustment(self, adj): + _gtk.gtk_container_set_focus_hadjustment(self._o, adj._o) + def set_resize_mode(self, mode): + _gtk.gtk_container_set_resize_mode(self._o, mode) + def unregister_toplevel(self): + _gtk.gtk_container_unregister_toplevel(self._o) + +class GtkBin(GtkContainer): + get_type = _gtk.gtk_bin_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + +class GtkAlignment(GtkBin): + get_type = _gtk.gtk_alignment_get_type + def __init__(self, xa=0, ya=0, xs=0, ys=0, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_alignment_new(xa, ya, xs, ys) + def set(self, xa, ya, xs, ys): + _gtk.gtk_alignment_set(self._o, xa, ya, xs, ys) + +class GtkButton(GtkBin): + get_type = _gtk.gtk_button_get_type + def __init__(self, label=None, _obj=None): + if _obj: self._o = _obj; return + if label == None: + self._o = _gtk.gtk_button_new() + else: + self._o = _gtk.gtk_button_new_with_label(label) + def pressed(self, obj=None): + _gtk.gtk_button_pressed(self._o) + def released(self, obj=None): + _gtk.gtk_button_released(self._o) + def clicked(self, obj=None): + _gtk.gtk_button_clicked(self._o) + def enter(self, obj=None): + _gtk.gtk_button_enter(self._o) + def leave(self, obj=None): + _gtk.gtk_button_leave(self._o) + def set_relief(self, style): + _gtk.gtk_button_set_relief(self._o, style) + def get_relief(self): + return _gtk.gtk_button_get_relief(self._o) + +class GtkOptionMenu(GtkButton): + get_type = _gtk.gtk_option_menu_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_option_menu_new() + def get_menu(self): + return _obj2inst(_gtk.gtk_option_menu_get_menu(self._o)) + def set_menu(self, menu): + _gtk.gtk_option_menu_set_menu(self._o, menu._o) + def remove_menu(self): + _gtk.gtk_option_menu_remove_menu(self._o) + def set_history(self, index): + _gtk.gtk_option_menu_set_history(self._o, index) + +class GtkToggleButton(GtkButton): + get_type = _gtk.gtk_toggle_button_get_type + def __init__(self, label=None, _obj=None): + if _obj: self._o = _obj; return + if label == None: + self._o = _gtk.gtk_toggle_button_new() + else: + self._o = _gtk.gtk_toggle_button_new_with_label(label) + def __getattr__(self, attr): + attrs = { + 'active': _gtk.gtk_toggle_button_get_active, + 'draw_indicator':_gtk.gtk_toggle_button_get_draw_indicator, + } + if attrs.has_key(attr): + return attrs[attr](self._o) + raise AttributeError, attr + def set_mode(self, di): + _gtk.gtk_toggle_button_set_mode(self._o, di) + def set_state(self, state): + _gtk.gtk_toggle_button_set_state(self._o, state) + def toggled(self, obj): + _gtk.gtk_toggle_button_toggled(self._o) + +class GtkCheckButton(GtkToggleButton): + get_type = _gtk.gtk_check_button_get_type + def __init__(self, label=None, _obj=None): + if _obj: self._o = _obj; return + if label == None: + self._o = _gtk.gtk_check_button_new() + else: + self._o = _gtk.gtk_check_button_new_with_label(label) + +class GtkRadioButton(GtkCheckButton): + get_type = _gtk.gtk_radio_button_get_type + def __init__(self, group=None, label=None, _obj=None): + if _obj: self._o = _obj; return + if label == None: + if group == None: + self._o = _gtk.gtk_radio_button_new() + else: + self._o = \ + _gtk.gtk_radio_button_new_from_widget( + group._o) + else: + if group == None: + self._o = _gtk.gtk_radio_button_new_with_label( + None, label) + else: + self._o = _gtk.gtk_radio_button_new_with_label_from_widget(group._o, label) + +class GtkFrame(GtkBin): + get_type = _gtk.gtk_frame_get_type + def __init__(self, label=None, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_frame_new(label) + def set_label(self, label): + _gtk.gtk_frame_set_label(self._o, label) + def set_label_align(self, x, y): + _gtk.gtk_frame_set_label_align(self._o, x, y) + def set_shadow_type(self, tp=SHADOW_ETCHED_IN): + _gtk.gtk_frame_set_shadow_type(self._o, tp) + +class GtkAspectFrame(GtkFrame): + get_type = _gtk.gtk_aspect_frame_get_type + def __init__(self, xa=0, ya=0, ratio=1, obey_child=1, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_aspect_frame_new(xa, ya, ratio, obey_child) + def set(self, xa, ya, ratio, obey_child): + _gtk.gtk_aspect_frame_set(self._o, xa, ya, ratio, obey_child) + +class GtkEventBox(GtkBin): + get_type = _gtk.gtk_event_box_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_event_box_new() + +class GtkHandleBox(GtkBin): + get_type = _gtk.gtk_handle_box_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_handle_box_new() + def set_shadow_type(self, type): + _gtk.gtk_handle_box_set_shadow_type(self._o, type) + +class GtkItem(GtkBin): + get_type = _gtk.gtk_item_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + def select(self, obj=None): + _gtk.gtk_item_select(self._o) + def deselect(self, obj=None): + _gtk.gtk_item_deselect(self._o) + def toggle(self, obj=None): + _gtk.gtk_item_toggle(self._o) + +class GtkMenuItem(GtkItem): + get_type = _gtk.gtk_menu_item_get_type + def __init__(self, label=None, _obj=None): + if _obj: self._o = _obj; return + if label == None: + self._o = _gtk.gtk_menu_item_new() + else: + self._o = _gtk.gtk_menu_item_new_with_label(label) + def set_submenu(self, sub): + _gtk.gtk_menu_item_set_submenu(self._o, sub._o) + def set_placement(self, placement): + _gtk.gtk_menu_item_set_placement(self._o, placement) + def configure(self, show_toggle, show_sub): + _gtk.gtk_menu_item_configure(self._o, show_toggle. show_sub) + def select(self, obj=None): + _gtk.gtk_menu_item_select(self._o) + def deselect(self, obj=None): + _gtk.gtk_menu_item_deselect(self._o) + def activate(self, obj=None): + _gtk.gtk_menu_item_activate(self._o) + def remove_submenu(self): + _gtk.gtk_menu_item_remove_submenu(self._o) + def right_justify(self, obj=None): + _gtk.gtk_menu_item_right_justify(self._o) + +class GtkCheckMenuItem(GtkMenuItem): + get_type = _gtk.gtk_check_menu_item_get_type + def __init__(self, label=None, _obj=None): + if _obj: self._o = _obj; return + if label == None: + self._o = _gtk.gtk_check_menu_item_new() + else: + self._o =_gtk.gtk_check_menu_item_new_with_label(label) + def __getattr__(self, attr): + attrs = { + 'active': _gtk.gtk_check_menu_item_get_active + } + if attrs.has_key(attr): + return attrs[attr](self._o) + raise AttributeError, attr + def set_show_toggle(self, always): + _gtk.gtk_check_menu_item_set_show_toggle(self._o, always) + def set_state(self, state): + _gtk.gtk_check_menu_item_set_state(self._o, state) + def toggled(self, obj=None): + _gtk.gtk_check_menu_item_toggled(self._o) + +class GtkRadioMenuItem(GtkCheckMenuItem): + get_type = _gtk.gtk_radio_menu_item_get_type + def __init__(self, group=None, label=None, _obj=None): + if _obj: self._o = _obj; return + if label == None: + if group == None: + self._o = _gtk.gtk_radio_menu_item_new() + else: + self._o =_gtk.gtk_radio_menu_item_new(group._o) + else: + if group == None: + self._o=_gtk.gtk_radio_menu_item_new_with_label( + None, label) + else: + self._o=_gtk.gtk_radio_menu_item_new_with_label( + group._o, label) + +class GtkTearoffMenuItem(GtkMenuItem): + get_type = _gtk.gtk_tearoff_menu_item_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_tearoff_menu_item_new() + +class GtkListItem(GtkItem): + get_type = _gtk.gtk_list_item_get_type + def __init__(self, label=None, _obj=None): + if _obj: self._o = _obj; return + if label == None: + self._o = _gtk.gtk_list_item_new() + else: + self._o = _gtk.gtk_list_item_new_with_label(label) + def select(self, obj=None): + _gtk.gtk_list_item_select(self._o) + def deselect(self, obj=None): + _gtk.gtk_list_item_deselect(self._o) + +class GtkTreeItem(GtkItem): + get_type = _gtk.gtk_tree_item_get_type + def __init__(self, label=None, _obj=None): + if _obj: self._o = _obj; return + if label == None: + self._o = _gtk.gtk_tree_item_new() + else: + self._o = _gtk.gtk_tree_item_new_with_label(label) + def set_subtree(self, subtree): + _gtk.gtk_tree_item_set_subtree(self._o, subtree._o) + def select(self, obj=None): + _gtk.gtk_tree_item_select(self._o) + def deselect(self, obj=None): + _gtk.gtk_tree_item_deselect(self._o) + def expand(self, obj=None): + _gtk.gtk_tree_item_expand(self._o) + def collapse(self, obj=None): + _gtk.gtk_tree_item_collapse(self._o) + def remove_subtree(self): + _gtk.gtk_tree_item_remove_subtree(self._o) + +class GtkViewport(GtkBin): + get_type = _gtk.gtk_viewport_get_type + def __init__(self, ha=None, va=None, _obj=None): + if _obj: self._o = _obj; return + if ha or va: + self._o = _gtk.gtk_viewport_new(ha._o, va._o) + else: + self._o = _gtk.gtk_viewport_new() + def get_hadjustment(self): + return _obj2inst(_gtk.gtk_viewport_get_hadjustment(self._o)) + def get_vdjustment(self): + return _obj2inst(_gtk.gtk_viewport_get_vadjustment(self._o)) + def set_hadjustment(self, ha): + _gtk.gtk_viewport_set_hadjustment(self._o, ha._o) + def set_vadjustment(self, va): + _gtk.gtk_viewport_set_vadjustment(self._o, va._o) + def set_shadow_type(self, tp=SHADOW_ETCHED_IN): + _gtk.gtk_viewport_set_shadow_type(self._o, tp) + +class GtkWindow(GtkBin): + get_type = _gtk.gtk_window_get_type + def __init__(self, type=WINDOW_TOPLEVEL, title=None, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_window_new(type) + if title is not None: + self.set_title(title) + def activate_focus(self, obj=None): + _gtk.gtk_window_activate_focus(self._o) + def activate_default(self, obj=None): + _gtk.gtk_window_activate_default(self._o) + def set_title(self, title): + _gtk.gtk_window_set_title(self._o, title) + def set_focus(self, focus): + _gtk.gtk_window_set_focus(self._o, focus._o) + def set_default(self, defaultw): + _gtk.gtk_window_set_default(self._o, defaultw._o) + def set_policy(self, as, ag, autos): + _gtk.gtk_window_set_policy(self._o, as, ag, autos) + def add_accel_group(self, group): + _gtk.gtk_window_add_accel_group(self._o, group._ag) + def remove_accel_group(self, group): + _gtk.gtk_window_remove_accel_group(self._o, group._ag) + def position(self, pos): + print "position deprecated -- use set_position" + self.set_position(pos) + def set_position(self, pos): + _gtk.gtk_window_set_position(self._o, pos) + def set_wmclass(self, wmc_name, wmc_class): + _gtk.gtk_window_set_wmclass(self._o, wmc_name, wmc_class) + def set_icon(self, pixmap, mask=None): + if not mask and hasattr(pixmap, '_o'): + pixmap, mask = pixmap.get() + _gtk.gtk_window_set_icon(self._o, pixmap, mask) + def set_icon_name(self, name): + _gtk.gtk_window_set_icon_name(self._o, name) + def set_modal(self, modal): + _gtk.gtk_window_set_modal(self._o, modal) + +class GtkColorSelectionDialog(GtkWindow): + get_type = _gtk.gtk_color_selection_dialog_get_type + def __init__(self, name="", _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_color_selection_dialog_new(name) + def __getattr__(self, attr): + attrs = { + 'colorsel':_gtk.gtk_color_selection_dialog_get_colorsel, + 'main_vbox':_gtk.gtk_color_selection_dialog_get_main_vbox, + 'ok_button': _gtk.gtk_color_selection_dialog_get_ok_button, + 'reset_button': _gtk.gtk_color_selection_dialog_get_reset_button, + 'cancel_button': _gtk.gtk_color_selection_dialog_get_cancel_button, + 'help_button': _gtk.gtk_color_selection_dialog_get_help_button + } + if attrs.has_key(attr): + return _obj2inst(attrs[attr](self._o)) + raise AttributeError, attr + +class GtkDialog(GtkWindow): + get_type = _gtk.gtk_dialog_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_dialog_new() + def __getattr__(self, attr): + attrs = { + 'vbox': _gtk.gtk_dialog_get_vbox, + 'action_area': _gtk.gtk_dialog_get_action_area + } + if attrs.has_key(attr): + return _obj2inst(attrs[attr](self._o)) + raise AttributeError, attr + +class GtkDrawWindow(GtkWindow): + get_type = _gtk.gtk_draw_window_get_type + def __init__(self, type=WINDOW_TOPLEVEL, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_draw_window_new(type) + +class GtkFileSelection(GtkWindow): + get_type = _gtk.gtk_file_selection_get_type + def __init__(self, title='', _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_file_selection_new(title) + + def __getattr__(self, attr): + attrs = { + 'cancel_button': _gtk.gtk_file_selection_get_cancel_button, + 'dir_list': _gtk.gtk_file_selection_get_dir_list, + 'file_list': _gtk.gtk_file_selection_get_file_list, + 'help_button': _gtk.gtk_file_selection_get_help_button, + 'main_vbox': _gtk.gtk_file_selection_get_main_vbox, + 'ok_button': _gtk.gtk_file_selection_get_ok_button, + 'selection_entry': _gtk.gtk_file_selection_get_selection_entry, + 'selection_text': _gtk.gtk_file_selection_get_selection_text + } + if not attrs.has_key(attr): raise AttributeError, attr + return _obj2inst(attrs[attr](self._o)) + def set_filename(self, filename): + _gtk.gtk_file_selection_set_filename(self._o, filename) + def get_filename(self): + return _gtk.gtk_file_selection_get_filename(self._o) + def complete(self): + _gtk.gtk_file_selection_complete(self._o) + def show_fileop_buttons(self): + _gtk.gtk_file_selection_show_fileop_buttons(self._o) + def hide_fileop_buttons(self): + _gtk.gtk_file_selection_hide_fileop_buttons(self._o) + +class GtkInputDialog(GtkWindow): + get_type = _gtk.gtk_input_dialog_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_input_dialog_new() + def __getattr__(self, attr): + attrs = { + 'close_button': _gtk.gtk_input_dialog_get_close_button, + 'save_button': _gtk.gtk_input_dialog_get_save_button + } + if attrs.has_key(attr): + return _obj2inst(attrs[attr](self._o)) + raise AttributeError, attr + +class GtkFontSelectionDialog(GtkWindow): + get_type = _gtk.gtk_font_selection_dialog_get_type + def __init__(self, title=None, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_font_selection_dialog_new(title) + def __getattr__(self, attr): + attrs = { + "fontsel": _gtk.gtk_font_selection_dialog_get_fontsel, + "main_vbox": _gtk.gtk_font_selection_dialog_get_main_vbox, + "action_area": _gtk.gtk_font_selection_dialog_get_action_area, + "ok_button": _gtk.gtk_font_selection_dialog_get_ok_button, + "apply_button":_gtk.gtk_font_selection_dialog_get_apply_button, + "cancel_button": + _gtk.gtk_font_selection_dialog_get_cancel_button + } + if not attrs.has_key(attr): raise AttributeError, attr + return _obj2inst(attrs[attr](self._o)) + def get_font_name(self): + return _gtk.gtk_font_selection_dialog_get_font_name(self._o) + def get_font(self): + return _gtk.gtk_font_selection_dialog_get_font(self._o) + def set_font_name(self, name): + return _gtk.gtk_font_selection_dialog_set_font_name(self._o, + name) + def get_preview_text(self): + return _gtk.gtk_font_selection_dialog_get_preview_text(self._o) + def set_preview_text(self, text): + _gtk.gtk_font_selection_dialog_set_preview_text(self._o, text) + +class GtkPlug(GtkWindow): + get_type = _gtk.gtk_plug_get_type + def __init__(self, socket_id=-1, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_plug_new(socket_id) + +class GtkBox(GtkContainer): + get_type = _gtk.gtk_box_get_type + def __init__(self, _obj=None): + if nonint: return + def pack_start(self, child, expand=TRUE, fill=TRUE, padding=0): + _gtk.gtk_box_pack_start(self._o, child._o, expand,fill,padding) + def pack_end(self, child, expand=TRUE, fill=TRUE, padding=0): + _gtk.gtk_box_pack_end(self._o, child._o, expand,fill,padding) + def reorder_child(self, child, pos): + _gtk.gtk_box_reorder_child(self._o, child._o, pos) + def set_homogeneous(self, homogeneous): + _gtk.gtk_box_set_homogeneous(self._o, homogeneous) + def set_spacing(self, spacing): + _gtk.gtk_box_set_spacing(self._o, spacing) + def query_child_packing(self, child): + return _gtk.gtk_box_query_child_packing(self._o, child._o) + def set_child_packing(self, child, expand, fill, padding, pack_type): + _gtk.gtk_box_set_child_packing(self._o, child._o, expand, fill, + padding, pack_type) + def reorder_child(self, child, pos): + _gtk.gtk_box_reorder_child(self._o, child._o, pos) + +class GtkHBox(GtkBox): + get_type = _gtk.gtk_hbox_get_type + def __init__(self, homogeneous=0, spacing=0, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_hbox_new(homogeneous, spacing) + +class GtkCombo(GtkHBox): + get_type = _gtk.gtk_combo_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_combo_new() + def disable_activate(self, obj=None): + _gtk.gtk_combo_disable_activate(self._o) + def set_use_arrows(self, val): + _gtk.gtk_combo_set_use_arrows(self._o, val) + def set_use_arrows_always(self, val): + _gtk.gtk_combo_set_use_arrows_always(self._o, val) + def set_case_sensitive(self, val): + _gtk.gtk_combo_set_case_sensitive(self._o, val) + def set_item_string(self, item, val): + _gtk.gtk_combo_set_item_string(self._o, item._o, val) + def set_value_in_list(self, val, ok_if_empty): + _gtk.gtk_combo_set_value_in_list(self._o, val, ok_if_empty) + def set_popdown_strings(self, strings): + _gtk.gtk_combo_set_popdown_strings(self._o, strings) + def __getattr__(self, attr): + attrs = { + 'entry': _gtk.gtk_combo_get_entry, + 'list': _gtk.gtk_combo_get_list + } + if attrs.has_key(attr): + return _obj2inst(attrs[attr](self._o)) + raise AttributeError, attr + +class GtkStatusbar(GtkHBox): + get_type = _gtk.gtk_statusbar_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_statusbar_new() + def get_context_id(self, desc): + return _gtk.gtk_statusbar_get_context_id(self._o, desc) + def pop(self, cid): + _gtk.gtk_statusbar_pop(self._o, cid) + def push(self, cid, text): + return _gtk.gtk_statusbar_push(self._o, cid, text) + def remove(self, cid, msg_id): + _gtk.gtk_statusbar_remove(self._o, cid, msg_id) + +class GtkVBox(GtkBox): + get_type = _gtk.gtk_vbox_get_type + def __init__(self, homogeneous=0, spacing=0, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_vbox_new(homogeneous, spacing) + +class GtkColorSelection(GtkVBox): + get_type = _gtk.gtk_color_selection_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_color_selection_new() + def set_update_policy(self, p): + _gtk.gtk_color_selection_set_update_policy(self._o, p) + def set_opacity(self, use_opacity): + _gtk.gtk_color_selection_set_opacity(self._o, use_opacity) + def set_color(self, c): + _gtk.gtk_color_selection_set_color(self._o, c) + def get_color(self): + return _gtk.gtk_color_selection_get_color(self._o) + +class GtkGammaCurve(GtkVBox): + get_type = _gtk.gtk_gamma_curve_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_gamma_curve_new() + def __getattr__(self, attr): + if attr == 'gamma': + return _gtk.gtk_gamma_curve_get_gamma(self._o) + attrs = { + 'curve': _gtk.gtk_gamma_curve_get_curve, + 'gamma_dialog': _gtk.gtk_gamma_curve_get_gamma_dialog, + 'gamma_text': _gtk.gtk_gamma_curve_get_gamma_text, + 'table': _gtk.gtk_gamma_curve_get_table, + } + if attrs.has_key(attr): + return _obj2inst(attrs[attr](self._o)) + raise AttributeError, attr + +class GtkButtonBox(GtkBox): + get_type = _gtk.gtk_button_box_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + def get_child_size_default(self): + return _gtk.gtk_button_box_get_child_size_default() + def get_child_ipadding_default(self): + return _gtk.gtk_button_box_get_child_ipadding_default() + def set_child_size_default(self, mw, mh): + _gtk.gtk_button_box_set_child_size_default(mw, mh) + def set_child_ipadding_default(self, ix, iy): + _gtk.gtk_button_box_set_child_ipadding_default(ix, iy) + def get_spacing(self): + return _gtk.gtk_button_box_get_spacing(self._o) + def get_layout(self): + return _gtk.gtk_button_box_get_layout(self._o) + def get_child_size(self): + return _gtk.gtk_button_box_get_child_size(self._o) + def get_child_ipadding(self): + return _gtk.gtk_button_box_get_child_ipadding(self._o) + def set_spacing(self, spacing): + _gtk.gtk_button_box_set_spacing(self._o, spacing) + def set_layout(self, layout): + _gtk.gtk_button_box_set_layout(self._o, layout) + def set_child_size(self, mw, mh): + _gtk.gtk_button_box_set_child_size(self._o, mw, mh) + def set_child_ipadding(self, ix, iy): + _gtk.gtk_button_box_set_child_ipadding(self._o, ix, iy) + +class GtkHButtonBox(GtkButtonBox): + get_type = _gtk.gtk_hbutton_box_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_hbutton_box_new() + def get_spacing_default(self): + return _gtk.gtk_hbutton_box_get_spacing_default() + def get_layout_default(self): + return _gtk.gtk_hbutton_box_get_layout_default() + def set_spacing_default(self, spacing): + _gtk.gtk_hbutton_box_set_spacing_default(spacing) + def set_layout_default(self, layout): + _gtk.gtk_hbutton_box_set_layout_default(layout) + +class GtkVButtonBox(GtkButtonBox): + get_type = _gtk.gtk_vbutton_box_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_vbutton_box_new() + def get_spacing_default(self): + return _gtk.gtk_vbutton_box_get_spacing_default() + def get_layout_default(self): + return _gtk.gtk_vbutton_box_get_layout_default() + def set_spacing_default(self, spacing): + _gtk.gtk_vbutton_box_set_spacing_default(spacing) + def set_layout_default(self, layout): + _gtk.gtk_vbutton_box_set_layout_default(layout) + +class GtkCList(GtkContainer): + get_type = _gtk.gtk_clist_get_type + def __init__(self, cols=1, titles=None, _obj=None): + if _obj: self._o = _obj; return + if titles == None: + self._o = _gtk.gtk_clist_new(cols) + else: + self._o = _gtk.gtk_clist_new_with_titles(cols, titles) + def __getattr__(self, attr): + attrs = { + 'selection':_gtk.gtk_clist_get_selection, + } + if attrs.has_key(attr): + return attrs[attr](self._o) + else: + raise AttributeError, attr + def append(self, values): + return _gtk.gtk_clist_append(self._o, values) + def clear(self, obj=None): + _gtk.gtk_clist_clear(self._o) + def column_title_active(self, col): + _gtk.gtk_clist_column_title_active(self._o, col) + def column_title_passive(self, col): + _gtk.gtk_clist_column_title_passive(self._o, col) + def column_titles_active(self, obj=None): + _gtk.gtk_clist_column_titles_active(self._o) + def column_titles_hide(self, obj=None): + _gtk.gtk_clist_column_titles_hide(self._o) + def column_titles_passive(self, obj=None): + _gtk.gtk_clist_column_titles_passive(self._o) + def column_titles_show(self, obj=None): + _gtk.gtk_clist_column_titles_show(self._o) + def columns_autosize(self): + return _gtk.gtk_clist_columns_autosize(self._o) + def find_row_from_data(self, data): + return _gtk.gtk_clist_find_row_from_data(self._o, data) + def freeze(self, obj=None): + _gtk.gtk_clist_freeze(self._o) + def get_cell_style(self, row, col): + return _gtk.gtk_clist_get_cell_style(self._o, row, col) + def get_cell_type(self, r, c): + return _gtk.gtk_clist_get_cell_type(self._o, r, c) + def get_column_title(self, col): + return _gtk.gtk_clist_get_column_title(self._o, col) + def get_column_widget(self, col): + return _obj2inst(_gtk.gtk_clist_get_column_widget(self._o,col)) + def get_row_data(self, row): + return _gtk.gtk_clist_get_row_data(self._o, row) + def get_row_style(self, row): + return _gtk.gtk_clist_get_row_style(self._o, row) + def get_text(self, r, c): + return _gtk.gtk_clist_get_text(self._o, r, c) + def get_pixmap(self, r, c): + return _gtk.gtk_clist_get_pixmap(self._o, r, c) + def get_pixtext(self, r, c): + return _gtk.gtk_clist_get_pixtext(self._o, r, c) + def get_selectable(self, row): + return _gtk.gtk_clist_get_selectable(self._o, row) + def get_selection_info(self, x, y): + return _gtk.gtk_clist_get_selection_info(self._o, x, y) + def insert(self, row, values): + return _gtk.gtk_clist_insert(self._o, row, values) + def moveto(self, row=-1, col=-1, row_align=0.5, col_align=0.5): + _gtk.gtk_clist_moveto(self._o, row, col, row_align, col_align) + def optimal_column_width(self, col): + return _gtk.gtk_clist_optimal_column_width(self._o, col) + def remove(self, row): + _gtk.gtk_clist_remove(self._o, row) + def row_is_visible(self, row): + return _gtk.gtk_clist_row_is_visible(self._o, row) + def row_move(self, soure_row, dest_row): + _gtk.gtk_clist_row_move(self._o, source_row, dest_row) + def select_all(self): + _gtk.gtk_clist_select_all(self._o) + def select_row(self, row, col): + _gtk.gtk_clist_select_row(self._o, row, col) + def set_auto_sort(self, auto_sort): + _gtk.gtk_clist_set_auto_sort(self._o, auto_sort) + def set_background(self, row, colour): + _gtk.gtk_clist_set_background(self._o, row, colour) + def set_cell_style(self, row, col, style): + _gtk.gtk_clist_set_cell_style(self._o, row, col, style) + def set_column_auto_resize(self, col, auto): + _gtk.gtk_clist_set_column_auto_resize(self._o, col, auto) + def set_column_justification(self, col, just): + _gtk.gtk_clist_set_column_justification(self._o, col, just) + def set_column_max_width(self, col, width): + _gtk.gtk_clist_set_column_max_width(self._o, col, width) + def set_column_min_width(self, col, width): + _gtk.gtk_clist_set_column_min_width(self._o, col, width) + def set_column_resizeable(self, col, resizeable): + _gtk.gtk_clist_set_column_resizeable(self._o, col, resizeable) + def set_column_title(self, col, title): + _gtk.gtk_clist_set_column_title(self._o, col, title) + def set_column_visibility(self, col, visible): + _gtk.gtk_clist_set_column_visibility(self._o, col, visible) + def set_column_widget(self, col, w): + _gtk.gtk_clist_set_column_widget(self._o, col, w._o) + def set_column_width(self, col, width): + _gtk.gtk_clist_set_column_width(self._o, col, width) + def set_foreground(self, row, colour): + _gtk.gtk_clist_set_foreground(self._o, row, colour) + def set_hadjustment(self, adj): + _gtk.gtk_clist_set_hadjustment(self._o, adj._o) + def set_vadjustment(self, adj): + _gtk.gtk_clist_set_vadjustment(self._o, adj._o) + def get_hadjustment(self): + return GtkAdjusment(_obj= + _gtk.gtk_clist_get_hadjustment(self._o)) + def get_vadjustment(self): + return GtkAdjusment(_obj= + _gtk.gtk_clist_get_vadjustment(self._o)) + def set_row_data(self, row, data): + _gtk.gtk_clist_set_row_data(self._o, row, data) + def set_row_height(self, height): + _gtk.gtk_clist_set_row_height(self._o, height) + def set_row_style(self, row, style): + _gtk.gtk_clist_set_row_style(self._o, row, style) + def set_shift(self, row, col, v, h): + _gtk.gtk_clist_set_shift(self._o, row, col, v, h) + def set_selectable(self, row, selectable): + _gtk.gtk_clist_set_selectable(self._o, row, selectable) + def set_selection_mode(self, mode): + _gtk.gtk_clist_set_selection_mode(self._o, mode) + def set_shadow_type(self, border): + _gtk.gtk_clist_set_shadow_type(self._o, border) + def set_sort_column(self, col): + _gtk.gtk_clist_set_sort_column(self._o, col) + def set_sort_type(self, sort_type): + _gtk.gtk_clist_set_sort_type(self._o, sort_type) + def set_text(self, r, c, text): + _gtk.gtk_clist_set_text(self._o, r, c, text) + def set_pixmap(self, r, c, pixmap, mask=None): + if not mask and hasattr(pixmap, '_o'): + pixmap, mask = pixmap.get() + _gtk.gtk_clist_set_pixmap(self._o, r, c, pixmap, mask) + def set_pixtext(self, r, c, text, spacing, pixmap, mask=None): + if not mask and hasattr(pixmap, '_o'): + pixmap, mask = pixmap.get() + _gtk.gtk_clist_set_pixtext(self._o, r, c, text, spacing, + pixmap, mask) + def sort(self): + _gtk.gtk_clist_sort(self._o) + def swap_rows(self, row1, row2): + _gtk.gtk_clist_swap_rows(self._o, row1, row2) + def thaw(self): + _gtk.gtk_clist_thaw(self._o) + def undo_selection(self): + _gtk.gtk_clist_undo_selection(self._o) + def unselect_all(self): + _gtk.gtk_clist_unselect_all(self._o) + def unselect_row(self, row, col): + _gtk.gtk_clist_unselect_row(self._o, row, col) + +class GtkCTree(GtkCList): + get_type = _gtk.gtk_ctree_get_type + def __init__(self, cols=1, tree_col=0, titles=None, _obj=None): + if _obj: self._o = _obj; return + if titles == None: + self._o = _gtk.gtk_ctree_new(cols, tree_col) + else: + self._o = _gtk.gtk_ctree_new_with_titles(cols, + tree_col, + titles) + def base_nodes(self): + # this returns a list of the base nodes. Useful for recursion + return _gtk.gtk_ctree_base_nodes(self._o) + def insert_node(self, parent, sibling, text, spacing=5, + pixmap_closed=None, mask_closed=None, + pixmap_opened=None, mask_opened=None, is_leaf=TRUE, + expanded=FALSE): + # parent and sibling can also be None + return _gtk.gtk_ctree_insert_node(self._o, parent, sibling, + text, spacing, + pixmap_closed, mask_closed, + pixmap_opened, mask_opened, + is_leaf, expanded) + def remove_node(self, node): + _gtk.gtk_ctree_remove_node(self._o, node) + def is_viewable(self, node): + return _gtk.gtk_ctree_is_viewable(self._o, node) + def last(self, node): + return _gtk.gtk_ctree_last(self._o, node) + def node_nth(self, row): + return _gtk.gtk_ctree_node_nth(self._o, row) + def find(self, node, child): + return _gtk.gtk_ctree_find(self._o, node, child) + def is_ancestor(self, node, child): + return _gtk.gtk_ctree_is_ancestor(self._o, node, child) + def find_by_row_data(self, node, data): + return _gtk.gtk_ctree_find_by_row_data(self._o, node, data) + def find_all_by_row_data(self, node, data): + return _gtk.gtk_ctree_find_all_by_row_data(self._o, node, data) + def is_hot_spot(self, x, y): + return _gtk.gtk_ctree_is_hot_spot(self._o, x, y) + def move(self, node, new_parent, new_sibling): + _gtk.gtk_ctree_move(self._o, node, new_parent, new_sibling) + def expand(self, node): + _gtk.gtk_ctree_expand(self._o, node) + def expand_recursive(self, node): + _gtk.gtk_ctree_expand_recursive(self._o, node) + def expand_to_depth(self, node, depth): + _gtk.gtk_ctree_expand_to_depth(self._o, node, depth) + def collapse(self, node): + _gtk.gtk_ctree_collapse(self._o, node) + def collapse_recursive(self, node): + _gtk.gtk_ctree_collapse_recursive(self._o, node) + def collapse_to_depth(self, node, depth): + _gtk.gtk_ctree_collapse_to_depth(self._o, node, depth) + def toggle_expansion(self, node): + _gtk.gtk_ctree_toggle_expansion(self._o, node) + def toggle_expansion_recursive(self, node): + _gtk.gtk_ctree_toggle_expansion_recursive(self._o, node) + def select(self, node): + _gtk.gtk_ctree_select(self._o, node) + def select_recursive(self, node): + _gtk.gtk_ctree_select_recursive(self._o, node) + def unselect(self, node): + _gtk.gtk_ctree_unselect(self._o, node) + def unselect_recursive(self, node): + _gtk.gtk_ctree_unselect_recursive(self._o, node) + def real_select_recursive(self, node, state): + _gtk.gtk_ctree_real_select_recursive(self._o, node, state) + def node_set_text(self, node, col, text): + _gtk.gtk_ctree_node_set_text(self._o, node, col, text) + def node_set_pixmap(self, node, col, pixmap, mask): + _gtk.gtk_ctree_node_set_pixmap(self._o, node, col, pixmap,mask) + def node_set_pixtext(self, node, col, text, spacing, pixmap, mask): + _gtk.gtk_ctree_node_set_pixtext(self._o, node, col, text, + spacing, pixmap, mask) + def set_node_info(self, node, text, spacing, pixmap_closed, + mask_closed, pixmap_opened, mask_opened, is_leaf, + expanded): + _gtk.gtk_ctree_set_node_info(self._o, node, text, spacing, + pixmap_closed, mask_closed, + pixmap_opened, mask_opened, + is_leaf, expanded) + def node_set_shift(self, node, col, vert, horiz): + _gtk.gtk_ctree_node_set_shift(self._o, node, col, vert, horiz) + def node_set_selectable(self, node, selectable): + _gtk.gtk_ctree_node_set_selectable(self._o, node, selectable) + def node_get_cell_type(self, node, col): + return _gtk.gtk_ctree_node_get_cell_type(self._o, node, col) + def node_get_text(self, node, col): + return _gtk.gtk_ctree_node_get_text(self._o, node, col) + def node_get_pixmap(self, node, col): + return _gtk.gtk_ctree_node_get_pixmap(self._o, node, col) + def node_get_pixtext(self, node, col): + return _gtk.gtk_ctree_node_get_pixtext(self._o, node, col) + def get_node_info(self, node): + return _gtk.gtk_ctree_get_node_info(self._o, node) + def node_set_row_style(self, node, style): + _gtk.gtk_ctree_node_set_row_style(self._o, node, style) + def node_get_row_style(self, node): + return _gtk.gtk_ctree_node_get_row_style(self._o, node) + def node_set_cell_style(self, node, col, style): + _gtk.gtk_ctree_node_set_row_style(self._o, node, col, style) + def node_get_cell_style(self, node, col): + return _gtk.gtk_ctree_node_get_row_style(self._o, node, col) + def node_set_foreground(self, node, color): + _gtk.gtk_ctree_node_set_foreground(self._o, node, color) + def node_set_background(self, node, color): + _gtk.gtk_ctree_node_set_background(self._o, node, color) + def node_set_row_data(self, node, data): + _gtk.gtk_ctree_node_set_row_data(self._o, node, data) + def node_get_row_data(self, node): + return _gtk.gtk_ctree_node_get_row_data(self._o, node) + def node_moveto(self, node, col, row_align, col_align): + _gtk.gtk_ctree_node_moveto(self._o, node, col, row_align, + col_align) + def node_is_visible(self, node): + return _gtk.gtk_ctree_node_is_visible(self._o, node) + def set_indent(self, indent): + _gtk.gtk_ctree_set_indent(self._o, indent) + def set_spacing(self, spacing): + _gtk.gtk_ctree_set_spacing(self._o, spacing) + def set_show_stub(self, show_stub): + _gtk.gtk_ctree_set_show_stub(self._o, show_stub) + def set_reorderable(self, reorderable): + _gtk.gtk_ctree_set_reorderable(self._o, reorderable) + def set_use_drag_icons(self, use_icons): + _gtk.gtk_ctree_set_use_drag_icons(self._o, use_icons) + def set_line_style(self, style): + _gtk.gtk_ctree_set_line_style(self._o, style) + def set_expander_style(self, style): + _gtk.gtk_ctree_set_expander_style(self._o, style) + def sort_node(self, node): + _gtk.gtk_ctree_sort_node(self._o, node) + def sort_recursive(self, node): + _gtk.gtk_ctree_sort_recursive(self._o, node) + +class GtkFixed(GtkContainer): + get_type = _gtk.gtk_fixed_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_fixed_new() + def put(self, child, x, y): + _gtk.gtk_fixed_put(self._o, child._o, x, y) + def move(self, child, x, y): + _gtk.gtk_fixed_move(self._o, child._o, x, y) + +class GtkLayout(GtkContainer): + get_type = _gtk.gtk_layout_get_type + def __init__(self, hadj=None, vadj=None, _obj=None): + if _obj: self._o = _obj; return + if hadj and vadj: + self._o = _gtk.gtk_layout_new(hadj._o, vadj._o) + else: + self._o = _gtk.gtk_layout_new() + def put(self, child, x, y): + _gtk.gtk_layout_put(self._o, child._o, x, y) + def move(self, child, x, y): + _gtk.gtk_layout_move(self._o, child._o, x, y) + def set_size(self, width, height): + _gtk.gtk_layout_set_size(self._o, width, height) + def freeze(self): + _gtk.gtk_layout_freeze(self._o) + def thaw(self): + _gtk.gtk_layout_thaw(self._o) + def get_hadjustment(self): + return GtkAdjustment( + _obj=_gtk.gtk_layout_get_hadjustment(self._o)) + def get_vadjustment(self): + return GtkAdjustment( + _obj=_gtk.gtk_layout_get_vadjustment(self._o)) + def set_hadjustment(self, adj): + _gtk.gtk_layout_set_hadjustment(self._o, adj._o) + def set_vadjustment(self, adj): + _gtk.gtk_layout_set_vadjustment(self._o, adj._o) + +class GtkList(GtkContainer): + get_type = _gtk.gtk_list_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_list_new() + def get_selection(self): + l = _gtk.gtk_list_get_selection(self._o) + return map(_obj2inst, l) + def insert_items(self, items, pos): + _gtk.gtk_list_insert_items(self._o, items, pos) + def append_items(self, items): + items = map(lambda i: i._o, items) + _gtk.gtk_list_append_items(self._o, items) + def prepend_items(self, items): + items = map(lambda i: i._o, items) + _gtk.gtk_list_prepend_items(self._o, items) + def remove_items(self, items): + items = map(lambda i: i._o, items) + _gtk.gtk_list_remove_items(self._o, items) + def clear_items(self, start, end): + _gtk.gtk_list_clear_items(self._o, start, end) + def select_item(self, item): + _gtk.gtk_list_select_item(self._o, item._o) + def unselect_item(self, item): + _gtk.gtk_list_unselect_item(self._o, item._o) + def select_child(self, child): + _gtk.gtk_list_select_child(self._o, child._o) + def unselect_child(self, child): + _gtk.gtk_list_unselect_child(self._o, child._o) + def child_position(self, child): + return _gtk.gtk_list_child_position(self._o, child._o) + def set_selection_mode(self, mode): + _gtk.gtk_list_set_selection_mode(self._o, mode) + def extend_selection(self, scroll_type, pos, auto): + _gtk.gtk_list_extend_selection(self._o, scroll_type, pos, auto) + def start_selection(self): + _gtk.gtk_list_start_selection(self._o) + def end_selection(self): + _gtk.gtk_list_end_selection(self._o) + def select_all(self): + _gtk.gtk_list_select_all(self._o) + def unselect_all(self): + _gtk.gtk_list_unselect_all(self._o) + def scroll_horizontal(self, scroll_type, pos): + _gtk.gtk_list_scroll_horizontal(self._o, scroll_type, pos) + def scroll_vertical(self, scroll_type, pos): + _gtk.gtk_list_scroll_vertical(self._o, scroll_type, pos) + def toggle_add_mode(self): + _gtk.gtk_list_toggle_add_mode(self._o) + def toggle_focus_row(self): + _gtk.gtk_list_toggle_focus_row(self._o) + def toggle_row(self, item): + _gtk.gtk_list_toggle_row(self._o, item._o) + def undo_selection(self): + _gtk.gtk_list_undo_selection(self._o) + def end_drag_selection(self): + _gtk.gtk_list_end_drag_selection(self._o) + +class GtkMenuShell(GtkContainer): + get_type = _gtk.gtk_menu_shell_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + def append(self, child): + _gtk.gtk_menu_shell_append(self._o, child._o) + def prepend(self, child): + _gtk.gtk_menu_shell_prepend(self._o, child._o) + def insert(self, child, pos): + _gtk.gtk_menu_shell_insert(self._o, child._o, pos) + def deactivate(self, obj=None): + _gtk.gtk_menu_shell_deactivate(self._o) + def select_item(self, item): + _gtk.gtk_menu_shell_select_item(self._o, item._o) + def activate_item(self, item, force_deactivate): + _gtk.gtk_menu_shell_activate_item(self._o, item._o, + force_deactivate) + +class GtkMenuBar(GtkMenuShell): + get_type = _gtk.gtk_menu_bar_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_menu_bar_new() + def append(self, child): + _gtk.gtk_menu_bar_append(self._o, child._o) + def prepend(self, child): + _gtk.gtk_menu_bar_prepend(self._o, child._o) + def insert(self, child, pos): + _gtk.gtk_menu_bar_insert(self._o, child._o, pos) + def set_shadow_type(self, type): + _gtk.gtk_menu_bar_set_shadow_type(self._o, type) + +class GtkMenu(GtkMenuShell): + get_type = _gtk.gtk_menu_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_menu_new() + def append(self, child): + _gtk.gtk_menu_append(self._o, child._o) + def prepend(self, child): + _gtk.gtk_menu_prepend(self._o, child._o) + def insert(self, child, pos): + _gtk.gtk_menu_insert(self._o, child._o, pos) + def popup(self, pms, pmi, func, button, time): + _gtk.gtk_menu_popup(self._o, pms._o, pmi._o, func,button,time) + def reposition(self): + _gtk.gtk_menu_reposition(self._o) + def popdown(self, obj=None): + _gtk.gtk_menu_popdown(self._o) + def get_active(self): + return _obj2inst(_gtk.gtk_menu_get_active(self._o)) + def get_attach_widget(self): + return _obj2inst(_gtk.gtk_menu_get_attach_widget(self._o)) + def detach(self): + _gtk.gtk_menu_detach(self._o) + def set_active(self, index): + _gtk.gtk_menu_set_active(self._o, index) + def set_accel_group(self, group): + _gtk.gtk_menu_set_accel_group(self._o, group._ag) + def set_tearoff_state(self, torn_off): + _gtk.gtk_menu_set_tearoff_state(self._o, torn_off) + +class GtkNotebook(GtkContainer): + get_type = _gtk.gtk_notebook_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_notebook_new() + def append_page(self, child, tab): + _gtk.gtk_notebook_append_page(self._o, child._o, tab._o) + def append_page_menu(self, child, tab, ml): + _gtk.gtk_notebook_append_page_menu(self._o, child._o, tab._o, + ml._o) + def prepend_page(self, child, tab): + _gtk.gtk_notebook_prepend_page(self._o, child._o, tab._o) + def prepend_page_menu(self, child, tab, ml): + _gtk.gtk_notebook_prepend_page_menu(self._o, child._o, tab._o, + ml._o) + def insert_page(self, child, tab, pos): + _gtk.gtk_notebook_insert_page(self._o, child._o, tab._o, pos) + def insert_page_menu(self, child, tab, ml, pos): + _gtk.gtk_notebook_insert_page_menu(self._o, child._o, tab._o, + ml._o, pos) + def remove_page(self, pos): + _gtk.gtk_notebook_remove_page(self._o, pos) + def current_page(self): + print "current_page deprecated -- use get_current_page" + return self.current_page() + def get_current_page(self): + return _gtk.gtk_notebook_get_current_page(self._o) + def get_nth_page(self, page_num): + return _obj2inst(_gtk.gtk_notebook_get_nth_page(self._o, + page_num)) + def page_num(self, child): + return _gtk.gtk_notebook_page_num(self._o, child._o) + def set_page(self, pos): + _gtk.gtk_notebook_set_page(self._o, pos) + def next_page(self, obj=None): + _gtk.gtk_notebook_next_page(self._o) + def prev_page(self, obj=None): + _gtk.gtk_notebook_prev_page(self._o) + def reorder_child(self, child, pos): + _gtk.gtk_notebook_reorder_child(self._o, child._o, pos) + def set_tab_border(self, border): + _gtk.gtk_notebook_set_tab_border(self._o, border) + def set_tab_hborder(self, tab_hborder): + _gtk.gtk_notebook_set_tab_hborder(self._o, tab_hborder) + def set_tab_vborder(self, tab_vborder): + _gtk.gtk_notebook_set_tab_hborder(self._o, tab_vborder) + def get_tab_pos(self): + return _gtk.gtk_notebook_get_tab_pos(self._o) + def set_tab_pos(self, pos): + _gtk.gtk_notebook_set_tab_pos(self._o, pos) + def set_homogeneous_tabs(self, homog): + _gtk.gtk_notebook_set_homogeneous_tabs(self._o, homog) + def set_scrollable(self, scrollable): + _gtk.gtk_notebook_set_scrollable(self._o, scrollable) + def set_show_tabs(self, show): + _gtk.gtk_notebook_set_show_tabs(self._o, show) + def set_show_border(self, show): + _gtk.gtk_notebook_set_show_border(self._o, show) + def popup_enable(self, obj=None): + _gtk.gtk_notebook_popup_enable(self._o) + def popup_disable(self, obj=None): + _gtk.gtk_notebook_popup_disable(self._o) + def query_tab_label(self, child): + print "query_tab_label deprecated -- use get_tab_label" + return self.get_tab_label(child) + def get_tab_label(self, child): + return _obj2inst(_gtk.gtk_notebook_get_tab_label(self._o, + child._o)) + def set_tab_label(self, child, tab_label): + _gtk.gtk_notebook_set_tab_label(self._o, child._o, + tab_label._o) + def set_tab_label_text(self, child, tab_text): + _gtk.gtk_notebook_set_tab_label(self._o, child._o, tab_text) + def query_menu_label(self, child): + print "query_menu_label deprecated -- use get_menu_label" + return self.get_menu_label(child) + def get_menu_label(self, child): + return _obj2inst(_gtk.gtk_notebook_get_menu_label(self._o, + child._o)) + def set_menu_label(self, child, menu_label): + _gtk.gtk_notebook_set_menu_label(self._o, child._o, + menu_label._o) + def set_menu_label_text(self, child, menu_text): + _gtk.gtk_notebook_set_menu_label(self._o, child._o, menu_text) + def query_tab_label_packing(self, child): + # returns (expand,fill,pack_type) + return _gtk.gtk_notebook_query_tab_label_packing(self._o, + child._o) + def set_tab_label_packing(self, child, expand, fill, pack_type): + _gtk.gtk_notebook_set_tab_label_packing(self._o, child._o, + expand, fill, + pack_type) + +class GtkFontSelection(GtkNotebook): + get_type = _gtk.gtk_font_selection_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_font_selection_new() + def get_font_name(self): + return _gtk.gtk_font_selection_get_font_name(self._o) + def get_font(self): + return _gtk.gtk_font_selection_get_font(self._o) + def set_font_name(self, name): + return _gtk.gtk_font_selection_set_font_name(self._o, name) + def get_preview_text(self): + return _gtk.gtk_font_selection_get_preview_text(self._o) + def set_preview_text(self, text): + _gtk.gtk_font_selection_set_preview_text(self._o, text) + +class GtkPacker(GtkContainer): + get_type = _gtk.gtk_packer_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_packer_new() + def add_defaults(self, child, side, anchor, options): + _gtk.gtk_packer_add_defaults(self._o, child._o, side, anchor, + options) + def add(self, child, side, anchor, options, border_width, pad_x, + pad_y, i_pad_x, i_pad_y): + _gtk.gtk_packer_add(self._o, child._o, side, anchor, options, + border_width, pad_x, pad_y, i_pad_x, + i_pad_y) + def configure(self, child, side, anchor, options, border_width, pad_x, + pad_y, i_pad_x, i_pad_y): + print "configure deprecated -- use set_child_packing" + self.set_child_packing(child, side, anchor, options, + border_width, pad_x, pad_y, i_pad_x, + i_pad_y) + def set_child_packing(self, child, side, anchor, options, + border_width, pad_x, pad_y, i_pad_x, i_pad_y): + _gtk.gtk_packer_set_child_packing(self._o, child._o, side, + anchor, options, + border_width, pad_x, pad_y, + i_pad_x, i_pad_y) + def reorder_child(self, child, pos): + _gtk.gtk_packer_reorder_child(self._o, child._o, pos) + def set_spacing(self, spacing): + _gtk.gtk_packer_set_spacing(self._o, spacing) + def set_default_pad(self, pad_x, pad_y): + _gtk.gtk_packer_set_default_pad(self._o, pad_x, pad_y) + def set_default_ipad(self, i_pad_x, i_pad_y): + _gtk.gtk_packer_set_default_ipad(self._o, i_pad_x, i_pad_y) + +class GtkPaned(GtkContainer): + get_type = _gtk.gtk_paned_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + def add1(self, child): + _gtk.gtk_paned_add1(self._o, child._o) + def add2(self, child): + _gtk.gtk_paned_add2(self._o, child._o) + def handle_size(self, size): + print "handle_size deprecated -- use set_handle_size" + self.set_handle_size(size) + def set_handle_size(self, size): + _gtk.gtk_paned_set_handle_size(self._o, size) + def gutter_size(self, size): + print "gutter_size deprecated -- use set_gutter_size" + self.set_gutter_size(size) + def set_gutter_size(self, size): + _gtk.gtk_paned_set_gutter_size(self._o, size) + +class GtkHPaned(GtkPaned): + get_type = _gtk.gtk_hpaned_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_hpaned_new() + +class GtkVPaned(GtkPaned): + get_type = _gtk.gtk_vpaned_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_vpaned_new() + +class GtkScrolledWindow(GtkContainer): + get_type = _gtk.gtk_scrolled_window_get_type + def __init__(self, hadj=None, vadj=None, _obj=None): + if _obj: self._o = _obj; return + if not (vadj or hadj): + self._o = _gtk.gtk_scrolled_window_new() + else: + self._o = _gtk.gtk_scrolled_window_new(hadj._o, vadj._o) + def get_hadjustment(self): + return _obj2inst(_gtk.gtk_scrolled_window_get_hadjustment( + self._o)) + def get_vadjustment(self): + return _obj2inst(_gtk.gtk_scrolled_window_get_vadjustment( + self._o)) + def set_hadjustment(self, adjustment): + _gtk.gtk_scrolled_window_set_hadjustment(self._o,adjustment._o) + def set_vadjustment(self, adjustment): + _gtk.gtk_scrolled_window_set_vadjustment(self._o,adjustment._o) + def set_policy(self, hp, vp): + _gtk.gtk_scrolled_window_set_policy(self._o, hp, vp) + def set_placement(self, window_place): + _gtk.gtk_scrolled_window_set_placement(self._o, window_place) + def add_with_viewport(self, child): + _gtk.gtk_scrolled_window_add_with_viewport(self._o, child._o) + +class GtkSocket(GtkContainer): + get_type = _gtk.gtk_socket_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_socket_new() + def steal(self, wid): + _gtk.gtk_socket_steal(self._o, wid) + +class GtkTable(GtkContainer): + get_type = _gtk.gtk_table_get_type + def __init__(self, rows=1, cols=1, homogeneous=0, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_table_new(rows, cols, homogeneous) + def attach(self, child, la, ra, ta, ba, xoptions=EXPAND|FILL, + yoptions=EXPAND|FILL, xpadding=0, ypadding=0): + _gtk.gtk_table_attach(self._o, child._o, la,ra,ta,ba, + xoptions,yoptions, xpadding,ypadding) + def set_row_spacing(self, row, s): + _gtk.gtk_table_set_row_spacing(self._o, row, s) + def set_col_spacing(self, col, s): + _gtk.gtk_table_set_col_spacing(self._o, col, s) + def set_row_spacings(self, s): + _gtk.gtk_table_set_row_spacings(self._o, s) + def set_col_spacings(self, s): + _gtk.gtk_table_set_col_spacings(self._o, s) + def set_homogeneous(self, homogeneous): + _gtk.gtk_table_set_homogeneous(self._o, homogeneous) + +class GtkTree(GtkContainer): + get_type = _gtk.gtk_tree_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_tree_new() + def get_selection(self): + return map(_obj2inst, _gtk.gtk_tree_get_selection(self._o)) + def append(self, child): + _gtk.gtk_tree_append(self._o, child._o) + def prepend(self, child): + _gtk.gtk_tree_prepend(self._o, child._o) + def insert(self, child, pos): + _gtk.gtk_tree_insert(self._o, child._o, pos) + def remove_item(self, child): + # fix this when the function starts existing + #_gtk.gtk_tree_remove_item(self._o, child._o) + self.remove_items([child]) + def remove_items(self, children): + children = map(lambda x: x._o, children) + _gtk.gtk_tree_remove_items(self._o, children) + def clear_items(self, start, end): + _gtk.gtk_tree_clear_items(self._o, start, end) + def select_item(self, item): + _gtk.gtk_tree_select_item(self._o, item) + def unselect_item(self, item): + _gtk.gtk_tree_unselect_item(self._o, item) + def select_child(self, child): + _gtk.gtk_tree_select_child(self._o, child._o) + def unselect_child(self, child): + _gtk.gtk_tree_unselect_child(self._o, child._o) + def child_position(self, child): + return _gtk.gtk_tree_child_position(self._o, child._o) + def set_selection_mode(self, mode): + _gtk.gtk_tree_set_selection_mode(self._o, mode) + def set_view_mode(self, mode): + _gtk.gtk_tree_set_view_mode(self._o, mode) + def set_view_lines(self, flag): + _gtk.gtk_tree_set_view_lines(self._o, flag) + +class GtkToolbar(GtkContainer): + get_type = _gtk.gtk_toolbar_get_type + def __init__(self, orientation=ORIENTATION_HORIZONTAL, + style=TOOLBAR_ICONS, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_toolbar_new(orientation, style) + def append_item(self, text, tooltip, tp, icon, callback): + _gtk.gtk_toolbar_append_item(self._o, text, tooltip, tp, + icon._o, callback) + def append_space(self): + _gtk.gtk_toolbar_append_space(self._o) + def append_widget(self, w, tooltip, tp): + _gtk.gtk_toolbar_append_widget(self._o, w._o, tooltip, tp) + def insert_item(self, text, tooltip, tp, icon, callback, pos): + _gtk.gtk_toolbar_insert_item(self._o, text, tooltip, tp, + icon._o, callback, pos) + def insert_space(self, pos): + _gtk.gtk_toolbar_insert_space(self._o, pos) + def insert_widget(self, w, tooltip, tp, pos): + _gtk.gtk_toolbar_insert_widget(self._o, w._o, tooltip, tp, pos) + def prepend_item(self, text, tooltip, tp, icon, callback): + _gtk.gtk_toolbar_prepend_item(self._o, text, tooltip, tp, + icon._o, callback) + def prepend_space(self): + _gtk.gtk_toolbar_prepend_space(self._o) + def prepend_widget(self, w, tooltip, tp): + _gtk.gtk_toolbar_prepend_widget(self._o, w._o, tooltip, tp) + def set_orientation(self, orientation): + _gtk.gtk_toolbar_set_orientation(self._o, orientation) + def set_style(self, style): + _gtk.gtk_toolbar_set_style(self._o, style) + def set_space_size(self, size): + _gtk.gtk_toolbar_set_space_size(self._o, size) + def set_tooltips(self, enable): + _gtk.gtk_toolbar_set_tooltips(self._o, enable) + def set_button_relief(self, relief): + _gtk.gtk_toolbar_set_button_relief(self._o, relief) + def get_button_relief(self): + return _gtk.gtk_toolbar_get_button_relief(self._o) + +class GtkDrawingArea(GtkWidget): + get_type = _gtk.gtk_drawing_area_get_type + def __init__(self, _obj=None): + self.__win = None + if _obj: self._o = _obj; return + self._o = _gtk.gtk_drawing_area_new() + def size(self, w, h): + _gtk.gtk_drawing_area_size(self._o, w, h) + def __cache_win(self): + self.realize() + self.__win = self.get_window() + def draw_point(self, gc, x, y): + if not self.__win: self.__cache_win() + _gtk.gdk_draw_point(self.__win, gc, x, y) + def draw_line(self, gc, x1, y1, x2, y2): + if not self.__win: self.__cache_win() + _gtk.gdk_draw_line(self.__win, gc, x1, y1, x2, y2) + def draw_rectangle(self, gc, fill, x, y, width, height): + if not self.__win: self.__cache_win() + _gtk.gdk_draw_rectangle(self.__win, gc, fill, x, y, + width, height) + def draw_arc(self, gc, fill, x, y, width, height, angle1, angle2): + if not self.__win: self.__cache_win() + _gtk.gdk_draw_arc(self.__win, gc, fill, x, y, width, height, + angle1, angle2) + def draw_polygon(self, gc, fill, points): + if not self.__win: self.__cache_win() + _gtk.gdk_draw_polygon(self.__win, gc, fill, points) + def draw_string(self, font, gc, x, y, string): + if not self.__win: self.__cache_win() + _gtk.gdk_draw_string(self.__win, font, gc, x, y, string) + def draw_text(self, font, gc, x, y, text): + if not self.__win: self.__cache_win() + _gtk.gdk_draw_text(self.__win, font, gc, x, y, text) + def draw_pixmap(self, gc, src, xsrc,ysrc, xdest,ydest, width,height): + if not self.__win: self.__cache_win() + _gtk.gdk_draw_pixmap(self.__win, gc, src, xsrc,ysrc, + xdest,ydest, width,height) + def draw_points(self, gc, points): + if not self.__win: self.__cache_win() + _gtk.gdk_draw_points(self.__win, gc, points) + def draw_segments(self, gc, segs): + if not self.__win: self.__cache_win() + _gtk.gdk_draw_segments(self.__win, gc, segs) + def draw_lines(self, gc, points): + if not self.__win: self.__cache_win() + _gtk.gdk_draw_lines(self.__win, gc, points) + +class GtkCurve(GtkDrawingArea): + get_type = _gtk.gtk_curve_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_curve_new() + def reset(self): + _gtk.gtk_curve_reset(self._o) + def get_vector(self, size=-1): + return _gtk.gtk_curve_get_vector(self._o, size) + def set_vector(self, vector): + _gtk.gtk_curve_set_vector(self._o, vector) + def set_gamma(self, g): + _gtk.gtk_curve_set_gamma(self._o, g) + def set_range(self, minx,maxx, miny,maxy): + _gtk.gtk_curve_set_range(self._o, minx,maxx, miny,maxy) + def set_curve_type(self, tp): + _gtk.gtk_curve_set_curve_type(self._o, tp) + +class GtkEditable(GtkWidget): + get_type = _gtk.gtk_editable_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + def select_region(self, start, end): + _gtk.gtk_editable_select_region(self._o, start, end) + def insert_text(self, new_text): + return _gtk.gtk_editable_insert_text(self._o, new_text) + def delete_text(self, start, end): + _gtk.gtk_editable_delete_text(self._o, start, end) + def get_chars(self, start, end): + return _gtk.gtk_editable_get_chars(self._o, start, end) + def cut_clipboard(self): + _gtk.gtk_editable_cut_clipboard(self._o) + def copy_clipboard(self): + _gtk.gtk_editable_copy_clipboard(self._o) + def paste_clipboard(self): + _gtk.gtk_editable_paste_clipboard(self._o) + def claim_selection(self, claim, time): + _gtk.gtk_editable_claim_selection(self._o, claim, time) + def delete_selection(self): + _gtk.gtk_editable_delete_selection(self._o) + def changed(self): + _gtk.gtk_editable_changed(self._o) + def set_position(self, pos): + _gtk.gtk_editable_set_position(self._o, pos) + def get_position(self): + return _gtk.gtk_editable_get_position(self._o) + def set_editable(self, is_editable): + _gtk.gtk_editable_set_editable(self._o, is_editable) + +class GtkEntry(GtkEditable): + get_type = _gtk.gtk_entry_get_type + def __init__(self, maxlen=-1, _obj=None): + if _obj: self._o = _obj; return + if maxlen == -1: + self._o = _gtk.gtk_entry_new() + else: + self._o = _gtk.gtk_entry_new_with_max_length(maxlen) + def set_text(self, text): + _gtk.gtk_entry_set_text(self._o, text) + def append_text(self, text): + _gtk.gtk_entry_append_text(self._o, text) + def prepend_text(self, text): + _gtk.gtk_entry_prepend_text(self._o, text) + def set_position(self, pos): + _gtk.gtk_entry_set_position(self._o, pos) + def get_text(self): + return _gtk.gtk_entry_get_text(self._o) + def select_region(self, start, stop): + _gtk.gtk_entry_select_region(self._o, start, stop) + def set_visibility(self, visible): + _gtk.gtk_entry_set_visibility(self._o, visible) + def set_editable(self, editable): + _gtk.gtk_entry_set_editable(self._o, editable) + def set_max_length(self, max): + _gtk.gtk_entry_set_max_length(self._o, max) + +class GtkSpinButton(GtkEntry): + get_type = _gtk.gtk_spin_button_get_type + def __init__(self, adj=None, climb_rate=1, digits=1, _obj=None): + if _obj: self._o = _obj; return + if adj: + self._o = _gtk.gtk_spin_button_new(adj._o, climb_rate, + digits) + else: + self._o = _gtk.gtk_spin_button_new_no_adj(climb_rate, + digits) + def set_adjustment(self, adj): + _gtk.gtk_spin_button_set_adjustment(self._o, adj._o) + def get_adjustment(self): + return _obj2inst(_gtk.gtk_spin_button_get_adjustment(sel._o)) + def set_digits(self, digits): + _gtk.gtk_spin_button_set_digits(self._o, digits) + def get_value_as_float(self): + return _gtk.gtk_spin_button_get_value_as_float(self._o) + def get_value_as_int(self): + return _gtk.gtk_spin_button_get_value_as_int(self._o) + get_value = get_value_as_float + def set_value(self, val): + _gtk.gtk_spin_button_set_value(self._o, val) + def set_update_policy(self, pol): + _gtk.gtk_spin_button_set_update_policy(self._o, pol) + def set_numeric(self, numeric): + _gtk.gtk_spin_button_set_numeric(self._o, numeric) + def spin(self, direction, step): + _gtk.gtk_spin_button_spin(self._o, direction, step) + def set_wrap(self, wrap): + _gtk.gtk_spin_button_set_wrap(self._o, wrap) + def set_shadow_type(self, shadow_type): + _gtk.gtk_spin_button_set_shadow_type(self._o, shadow_type) + def set_snap_to_ticks(self, snap): + _gtk.gtk_spin_button_set_snap_to_ticks(self._o, snap) + +class GtkText(GtkEditable): + get_type = _gtk.gtk_text_get_type + def __init__(self, hadj=None, vadj=None, _obj=None): + if _obj: self._o = _obj; return + if not (hadj or vadj): + self._o = _gtk.gtk_text_new() + else: + self._o = _gtk.gtk_text_new(hadj._o, vadj._o) + def set_editable(self, editable): + _gtk.gtk_text_set_editable(self._o, editable) + def set_word_wrap(self, word_wrap): + _gtk.gtk_text_set_word_wrap(self._o, word_wrap) + def set_line_wrap(self, line_wrap): + _gtk.gtk_text_set_line_wrap(self._o, line_wrap) + def set_adjustments(self, hadj, vadj): + _gtk.gtk_text_set_adjustments(self._o, hadj._o, vadj._o) + def get_hadjustment(self): + return _obj2inst(_gtk.gtk_text_get_hadj(self._o)) + def get_vadjustment(self): + return _obj2inst(_gtk.gtk_text_get_vadj(self._o)) + def set_point(self, point): + _gtk.gtk_text_set_point(self._o, point) + def get_point(self): + return _gtk.gtk_text_get_point(self._o) + def get_length(self): + return _gtk.gtk_text_get_length(self._o) + def freeze(self, obj=None): + _gtk.gtk_text_freeze(self._o) + def thaw(self, obj=None): + _gtk.gtk_text_thaw(self._o) + def insert(self, font, fg, bg, string): + _gtk.gtk_text_insert(self._o, font, fg, bg, string, + len(string)) + def insert_defaults(self, chars): + _gtk.gtk_text_insert_defaults(self._o, chars) + def backward_delete(self, nchars): + _gtk.gtk_text_backward_delete(self._o, nchars) + def forward_delete(self, nchars): + _gtk.gtk_text_forward_delete(self._o, nchars) + +class GtkMisc(GtkWidget): + get_type = _gtk.gtk_misc_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + def set_alignment(self, xa, ya): + _gtk.gtk_misc_set_alignment(self._o, xa, ya) + def set_padding(self, xp, yp): + _gtk.gtk_misc_set_padding(self._o, xp, yp) + +class GtkArrow(GtkMisc): + get_type = _gtk.gtk_arrow_get_type + def __init__(self, at=ARROW_RIGHT, st=SHADOW_OUT, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_arrow_new(at, st) + def set(self, at, st): + _gtk.gtk_arrow_set(self._o, at, st) + +class GtkPixmap(GtkMisc): + get_type = _gtk.gtk_pixmap_get_type + def __init__(self, parent_or_pixmap=None, xpm_or_mask=None, bg=None, + _obj=None): + # This function can be called with two argument models: + # The old model: + # GtkPixmap(parent_win, xpm_file, bg_colour) + # or the one closer to the C version: + # GtkPixmap(pixmap, mask) + if _obj: self._o = _obj; return + if type(xpm_or_mask) == type(''): + pix, mask = create_pixmap_from_xpm(parent_or_pixmap, + bg, xpm_or_mask) + self._o = _gtk.gtk_pixmap_new(pix, mask) + else: + self._o = _gtk.gtk_pixmap_new(parent_or_pixmap, + xpm_or_mask) + def get(self): + return _gtk.gtk_pixmap_get(self._o) + def set(self, pixmap, mask): + _gtk.gtk_pixmap_set(self._o, pixmap, mask) + def set_build_insensitive(self, build): + _gtk.gtk_pixmap_set_build_insensitive(self._o, build) + +class GtkLabel(GtkMisc): + get_type = _gtk.gtk_label_get_type + def __init__(self, label="", _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_label_new(label) + def set(self, str): + _gtk.gtk_label_set(self._o, str) + def set_justify(self, jtype): + _gtk.gtk_label_set_justify(self._o, jtype) + def set_pattern(self, pattern): + _gtk.gtk_label_set_pattern(self._o, pattern) + def get(self): + return _gtk.gtk_label_get(self._o) + def parse_uline(self, string): + return _gtk.gtk_label_parse_uline(self._o, string) + +class GtkAccelLabel(GtkLabel): + get_type = _gtk.gtk_accel_label_get_type + def __init__(self, string=None, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_accel_label_new(string) + def accelerator_width(self): + print "accelerator_width deprecated -- use get_accel_width" + return self.get_accel_width() + def get_accel_width(self): + return _gtk.gtk_accel_label_get_accel_width(self._o) + def set_accel_widget(self, widget): + _gtk.gtk_accel_label_set_accel_widget(self._o, widget._o) + def refetch(self): + _gtk.gtk_accel_label_refetch(self._o) + +class GtkTipsQuery(GtkLabel): + get_type = _gtk.gtk_tips_query_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_tips_query_new() + def start_query(self, obj=None): + _gtk.gtk_tips_query_start_query(self._o) + def stop_query(self, obj=None): + _gtk.gtk_tips_query_stop_query(self._o) + def set_caller(self, caller): + _gtk.gtk_tips_query_set_caller(self._o, caller._o) + def set_labels(self, inactive, no_tip): + _gtk.gtk_tips_query_set_labels(self._o, inactive, no_tip) + +class GtkPreview(GtkWidget): + get_type = _gtk.gtk_preview_get_type + def __init__(self, type=PREVIEW_COLOR, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_preview_new(type) + def size(self, w, h): + _gtk.gtk_preview_size(self._o, w, h) + def put(self, win, gc, srcx, srcy, dstx, dsty, width, height): + _gtk.gtk_preview_put(self._o, win, gc, srcx, srcy, + dstx, dsty, width, height) + def draw_row(self, data, x, y, w=None): + _gtk.gtk_preview_draw_row(self._o, data, x, y, w or len(data)) + def set_expand(self, expand): + _gtk.gtk_preview_set_expand(self._o, expand) + def set_gamma(self, gamma): + _gtk.gtk_preview_set_gamma(self._o, gamma) + def set_color_cube(self, nr, ng, nb, ngrey): + _gtk.gtk_preview_set_color_cube(self._o, nr,ng,nb, ngrey) + def set_install_cmap(self, install): + _gtk.gtk_preview_set_install_cmap(install) + def set_reserved(self, reserved): + _gtk.gtk_preview_set_reserved(reserved) + def set_dither(self, dither): + _gtk.gtk_preview_set_dither(self._o, dither) + +class GtkProgress(GtkWidget): + get_type = _gtk.gtk_progress_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + def set_show_text(self, show_text): + _gtk.gtk_progress_set_show_text(self._o, show_text) + def set_text_alignment(self, x_align, y_align): + _gtk.gtk_progress_set_text_alignment(self._o, x_align, + y_align) + def set_format_string(self, format): + _gtk.gtk_progress_set_format_string(self._o, format) + def set_adjustment(self, adj): + _gtk.gtk_progress_set_adjustment(self._o, adj._o) + def reconfigure(self, value, min, max): + print "reconfigure deprecated -- use configure" + self.configure(value, min, max) + def configure(self, value, min, max): + _gtk.gtk_progress_reconfigure(self._o, value, min, max) + def set_percentage(self, pcnt): + _gtk.gtk_progress_set_percentage(self._o, pcnt) + def set_value(self, value): + _gtk.gtk_progress_set_value(self._o, value) + def get_value(self): + return _gtk.gtk_progress_get_value(self._o) + def set_activity_mode(self, activity_mode): + _gtk.gtk_progress_set_activity_mode(self._o, activity_mode) + def get_current_text(self): + return _gtk.gtk_progress_get_current_text(self._o) + def get_text_from_value(self, value): + return _gtk.gtk_progress_get_text_from_value(self._o, value) + def get_current_percentage(self): + return _gtk.gtk_progress_get_percentage(self._o) + def get_percentage_from_value(self, value): + return _gtk.gtk_progress_get_percentage_from_value(self._o, + value) + +class GtkProgressBar(GtkProgress): + get_type = _gtk.gtk_progress_bar_get_type + def __init__(self, adjustment=None, _obj=None): + if _obj: self._o = _obj; return + if adjustment: + self._o = _gtk.gtk_progress_bar_new_with_adjustment( + adjustment._o) + else: + self._o = _gtk.gtk_progress_bar_new() + def set_bar_style(self, style): + _gtk.gtk_progress_bar_set_bar_style(self._o, style) + def set_discrete_blocks(self, blocks): + _gtk.gtk_progress_bar_set_discrete_blocks(self._o, blocks) + def set_activity_step(self, step): + _gtk.gtk_progress_bar_set_activity_step(self._o, step) + def set_activity_blocks(self, blocks): + _gtk.gtk_progress_bar_set_activity_blocks(self._o, blocks) + def set_orientation(self, orient): + _gtk.gtk_progress_bar_set_orientation(self._o, orient) + def update(self, pcnt): + _gtk.gtk_progress_bar_update(self._o, pcnt) + +class GtkRange(GtkWidget): + get_type = _gtk.gtk_range_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + def get_adjustment(self): + return _obj2inst(_gtk.gtk_range_get_adjustment(self._o)) + def set_update_policy(self, pol): + _gtk.gtk_range_set_update_policy(self._o, pol) + def set_adjustment(self, adj): + _gtk.gtk_range_set_adjustment(self._o, adj._o) + def draw_background(self, obj=None): + _gtk.gtk_range_draw_background(self._o) + def clear_background(self, _obj=None): + _gtk.gtk_range_clear_background(self._o) + def draw_trough(self, obj=None): + _gtk.gtk_range_draw_trough(self._o) + def draw_step_forw(self, obj=None): + _gtk.gtk_range_draw_step_forw(self._o) + def draw_step_back(self, obj=None): + _gtk.gtk_range_draw_step_back(self._o) + +class GtkScale(GtkRange): + get_type = _gtk.gtk_scale_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + def set_digits(self, digits): + _gtk.gtk_scale_set_digits(self._o, digits) + def set_draw_value(self, draw_value): + _gtk.gtk_scale_set_draw_value(self._o, draw_value) + def set_value_pos(self, pos): + _gtk.gtk_scale_set_value_pos(self._o, pos) + def value_width(self): + print "value_width deprecated -- use get_value_width" + return self.get_value_width() + def get_value_width(self): + return _gtk.gtk_scale_get_value_width(self._o) + def draw_value(self, obj=None): + _gtk.gtk_scale_draw_value(self._o) + +class GtkHScale(GtkScale): + get_type = _gtk.gtk_hscale_get_type + def __init__(self, adj=None, _obj=None): + if _obj: self._o = _obj; return + if adj: + self._o = _gtk.gtk_hscale_new(adj._o) + else: + self._o = _gtk.gtk_hscale_new() + +class GtkVScale(GtkScale): + get_type = _gtk.gtk_vscale_get_type + def __init__(self, adj=None, _obj=None): + if _obj: self._o = _obj; return + if adj: + self._o = _gtk.gtk_vscale_new(adj._o) + else: + self._o = _gtk.gtk_vscale_new() + +class GtkScrollbar(GtkRange): + get_type = _gtk.gtk_scrollbar_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + +class GtkHScrollbar(GtkScrollbar): + get_type = _gtk.gtk_hscrollbar_get_type + def __init__(self, adj=None, _obj=None): + if _obj: self._o = _obj; return + if adj: + self._o = _gtk.gtk_hscrollbar_new(adj._o) + else: + self._o = _gtk.gtk_hscrollbar_new() + +class GtkVScrollbar(GtkScrollbar): + get_type = _gtk.gtk_vscrollbar_get_type + def __init__(self, adj=None, _obj=None): + if _obj: self._o = _obj; return + if adj: + self._o = _gtk.gtk_vscrollbar_new(adj._o) + else: + self._o = _gtk.gtk_vscrollbar_new() + +class GtkRuler(GtkWidget): + get_type = _gtk.gtk_ruler_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + def set_metric(self, metric): + _gtk.gtk_ruler_set_metric(self._o, metric) + def set_range(self, lo, up, pos, max): + _gtk.gtk_ruler_set_range(self._o, lo, up, pos, max) + def draw_ticks(self, obj=None): + _gtk.gtk_ruler_draw_ticks(self._o) + def draw_pos(self, obj=None): + _gtk.gtk_ruler_draw_pos(self._o) + +class GtkHRuler(GtkRuler): + get_type = _gtk.gtk_hruler_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_hruler_new() + +class GtkVRuler(GtkRuler): + get_type = _gtk.gtk_vruler_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_vruler_new() + +class GtkSeparator(GtkWidget): + get_type = _gtk.gtk_separator_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + +class GtkHSeparator(GtkSeparator): + get_type = _gtk.gtk_hseparator_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_hseparator_new() + +class GtkVSeparator(GtkSeparator): + get_type = _gtk.gtk_vseparator_get_type + def __init__(self, _obj=None): + if _obj: self._o = _obj; return + self._o = _gtk.gtk_vseparator_new() + + +_name2cls = {} +_supported = map(lambda x: eval(x), filter(lambda x: x[:3] == 'Gtk', dir())) +for m in _supported: + _name2cls[m.__name__] = m +del m + +class GtkAccelGroup: + def __init__(self, _obj=None): + if _obj: self._ag = _obj; return + self._ag = _gtk.gtk_accel_group_new() + def activate(self, key, mods): + _gtk.gtk_accel_group_activate(self._ag, key, mods) + def attach(self, obj): + _gtk.gtk_accel_group_attach(self._ag, obj._o) + def detach(self, obj): + _gtk.gtk_accel_group_detach(self._ag, obj._o) + def lock(self): + _gtk.gtk_accel_group_lock(self._ag) + def unlock(self): + _gtk.gtk_accel_group_unlock(self._ag) + def lock_entry(self, key, mods): + _gtk.gtk_accel_group_lock_entry(self._ag, key, mods) + def unlock_entry(self, key, mods): + _gtk.gtk_accel_group_unlock_entry(self._ag, key, mods) + def add(self, key, mods, flags, obj, signal): + _gtk.gtk_accel_group_add(self._ag, key, mods, flags, + obj._o, signal) + def remove(self, key, mods, obj): + _gtk.gtk_accel_group_remove(self._ag, key, mods, obj._o) + +def _obj2inst(obj): + objname = _gtk.gtk_type_name(_gtk.GTK_OBJECT_TYPE(obj)) + if _name2cls.has_key(objname): + return _name2cls[objname](_obj=obj) + # if I don't know what the object is, guess + elif _gtk.GTK_CHECK_TYPE(obj, GtkBox.get_type()): + return GtkBox(_obj=obj) + elif _gtk.GTK_CHECK_TYPE(obj, GtkBin.get_type()): + return GtkBin(_obj=obj) + elif _gtk.GTK_CHECK_TYPE(obj, GtkWindow.get_type()): + return GtkWindow(_obj=obj) + elif _gtk.GTK_CHECK_TYPE(obj, GtkContainer.get_type()): + return GtkContainer(_obj=obj) + elif _gtk.GTK_CHECK_TYPE(obj, GtkWidget.get_type()): + return GtkWidget(_obj=obj) + else: + return GtkObject(_obj=obj) + +def _filtprops(props): + for k in props.keys(): + v = props[k] + if hasattr(v, '_o') and type(v._o) == _gtk.GtkObjectType: + props[k] = v._o + +def new(tp, **props): + if type(tp) == type(GtkObject): + tp = tp.get_type() + elif type(tp) == type('forty-two'): + tp = _name2cls[tp].get_type() + elif type(tp) != type(0): + raise TypeError, "unknow type argument: " + tp + _filtprops(props) + return _obj2inst(_gtk.gtk_object_new(tp, props)) + +# flow control +def mainloop(): + _gtk.gtk_main() +def mainquit(*args): + _gtk.gtk_main_quit() +def mainiteration(block=TRUE): + return _gtk.gtk_main_iteration(block) +def events_pending(): + return _gtk.gtk_events_pending() + +# idle/quit/timeout handlers +def idle_add(callback): + return _gtk.gtk_idle_add(callback) +def idle_add_priority(priority, callback): + return _gtk.gtk_idle_add_priority(priority, callback) +def idle_remove(tag): + _gtk.gtk_idle_remove(tag) +def quit_add(mainlevel, callback): + return _gtk.gtk_quit_add(mainlevel, callback) +def quit_add_destroy(mainlevel, object): + _gtk.gtk_quit_add_destroy(mainlevel, object._o) +def quit_remove(tag): + _gtk.gtk_quit_remove(tag) +def timeout_add(timeout, callback): + return _gtk.gtk_timeout_add(timeout, callback) +def timeout_remove(tag): + _gtk.gtk_timeout_remove(tag) + +# input (file handle) handler +def input_add(source, condition, callback): + if hasattr(source, 'fileno'): + # handle python file handles + def wrapper(source, condition, real_s=source,real_cb=callback): + real_cb(real_s, condition) + return _gtk.gtk_input_add(source.fileno(), condition, wrapper) + else: + return _gtk.gtk_input_add(source, condition, callback) +def input_remove(tag): + _gtk.gtk_input_remove(tag) + +# these functions govern modality +def grab_add(wid): + _gtk.gtk_grab_add(wid._o) +def grab_remove(wid): + _gtk.gtk_grab_remove(wid._o) +def grab_get_current(): + return _obj2inst(_gtk.gtk_grab_get_current()) + +# RC parsing +def rc_parse(fname): + _gtk.gtk_rc_parse(fname) +def rc_parse_string(string): + _gtk.gtk_rc_parse_string(string) +def rc_reparse_all(): + _gtk.gtk_rc_repase_all() + +# font loading +def load_font(font): + return _gtk.gdk_font_load(font) +def load_fontset(fontset): + return _gtk.gdk_fontset_load(fontset) + +# cursor loading +def cursor_new(type): + return _gtk.gdk_cursor_new(type) +def cursor_new_from_pixmap(source, mask, fg, bg, x, y): + return _gtk.gdk_cursor_new_from_pixmap(source, mask, fg, bg, x, y) + +# colour allocation +def colour_alloc(parent, red, green=None, blue=None): + print "colour_alloc deprecated. Use GdkColormap.alloc" + if hasattr(parent, '_o'): cmap = parent.get_window().colormap + elif hasattr(parent, 'colormap'): cmap = parent.colormap + else: cmap = parent + if type(red) == type(''): + return cmap.alloc(red) + # red assumed to be an int + if green == None and blue == None: + green, blue = divmod(red, 256) + red, green = divmod(green, 256) + red = red % 256 + + red = (red + 1) * 256 - 1 + green = (green + 1) * 256 - 1 + blue = (blue + 1) * 256 - 1 + return cmap.alloc(red, green, blue) +# This one's for the Americans... +color_alloc = colour_alloc + +# atoms ... +def atom_intern(name, only_if_exists=FALSE): + return _gtk.gdk_atom_intern(name, only_if_exists) +def atom_name(atom): + return _gtk.gdk_atom_name(atom) + +# pixmap loading +def create_pixmap_from_xpm(window, bg, xpm): + if hasattr(window, '_o'): + window.realize() + window = window.get_window() + return _gtk.gdk_pixmap_create_from_xpm(window, bg, xpm) +# use XPM data ... +def create_pixmap_from_xpm_d(window, bg, xpm_d): + if hasattr(window, '_o'): + window.realize() + window = window.get_window() + return _gtk.gdk_pixmap_create_from_xpm_d(window, bg, xpm_d) +def create_pixmap(window, width, height, depth=-1): + if (hasattr(window, '_o')): + window.realize() + window = window.get_window() + return _gtk.gdk_pixmap_new(window, width, height, depth) + +# drawing functions... +def draw_point(drawable, gc, x, y): + _gtk.gdk_draw_point(drawable, gc, x, y) +def draw_line(drawable, gc, x1, y1, x2, y2): + _gtk.gdk_draw_line(drawable, gc, x1, y1, x2, y2) +def draw_rectangle(drawable, gc, fill, x, y, width, height): + _gtk.gdk_draw_rectangle(drawable, gc, fill, x, y, + width, height) +def draw_arc(drawable, gc, fill, x, y, width, height, angle1, angle2): + _gtk.gdk_draw_arc(drawable, gc, fill, x, y, width, height, angle1, + angle2) +def draw_polygon(drawable, gc, fill, points): + _gtk.gdk_draw_polygon(drawable, gc, fill, points) +def draw_string(drawable, font, gc, x, y, string): + _gtk.gdk_draw_string(drawable, font, gc, x, y, string) +def draw_text(drawable, font, gc, x, y, text): + _gtk.gdk_draw_text(drawable, font, gc, x, y, text) +def draw_pixmap(drawable, gc, src, xsrc,ysrc, xdest,ydest, width,height): + _gtk.gdk_draw_pixmap(drawable, gc, src, xsrc,ysrc, + xdest,ydest, width,height) +def draw_points(drawable, gc, points): + _gtk.gdk_draw_points(drawable, gc, points) +def draw_segments(drawable, gc, segs): + _gtk.gdk_draw_segments(drawable, gc, segs) +def draw_lines(drawable, gc, points): + _gtk.gdk_draw_lines(drawable, gc, points) + diff --git a/gtkmodule.c b/gtkmodule.c new file mode 100644 index 00000000..3a16f6c0 --- /dev/null +++ b/gtkmodule.c @@ -0,0 +1,5045 @@ +/* PyGTK - python bindings for GTK+ + * Copyright (C) 1997-1998 James Henstridge <james@daa.com.au> + * + * 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. + */ + +#include <Python.h> +#include <sysmodule.h> +#include <gtk/gtk.h> + +typedef struct { + PyObject_HEAD + GtkObject *obj; +} PyGtk_Object; + +staticforward PyTypeObject PyGtk_Type; + +#define PyGtk_Check(v) ((v)->ob_type == &PyGtk_Type) +#define PyGtk_Get(v) (((PyGtk_Object *)(v))->obj) + +static PyObject * +PyGtk_New(GtkObject *go) { + PyGtk_Object *self; + + self = (PyGtk_Object *)PyObject_NEW(PyGtk_Object, &PyGtk_Type); + if (self == NULL) + return NULL; + self->obj = go; + gtk_object_ref(self->obj); + return (PyObject *)self; +} + +static void +PyGtk_dealloc(PyGtk_Object *self) { + gtk_object_unref(self->obj); + PyMem_DEL(self); +} + +static int +PyGtk_compare(PyGtk_Object *self, PyGtk_Object *v) { + if (self->obj == v->obj) return 0; + if (self->obj > v->obj) return -1; + return 1; +} + +static PyObject * +PyGtk_repr(PyGtk_Object *self) { + char buf[100]; + + sprintf(buf, "<GtkObject of type %s at %lx>", + gtk_type_name(PyGtk_Get(self)->klass->type), (long)PyGtk_Get(self)); + return PyString_FromString(buf); +} + +static char PyGtk_Type__doc__[] = "This is the type of GTK Objects"; + +static PyTypeObject PyGtk_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /*ob_size*/ + "GtkObject", /*tp_name*/ + sizeof(PyGtk_Object), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)PyGtk_dealloc, /*tp_dealloc*/ + (printfunc)0, /*tp_print*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ + (cmpfunc)PyGtk_compare, /*tp_compare*/ + (reprfunc)PyGtk_repr, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + (hashfunc)0, /*tp_hash*/ + (ternaryfunc)0, /*tp_call*/ + (reprfunc)0, /*tp_str*/ + 0L,0L,0L,0L, + PyGtk_Type__doc__ +}; + +/* return 1 on failure */ +gint PyGtkEnum_get_value(GtkType enum_type, PyObject *obj, int *val) { + if (PyInt_Check(obj)) { + *val = PyInt_AsLong(obj); + return 0; + } else if (PyString_Check(obj)) { + GtkEnumValue *info = gtk_type_enum_find_value(enum_type, + PyString_AsString(obj)); + if (!info) { + PyErr_SetString(PyExc_TypeError, "couldn't translate string"); + return 1; + } + *val = info->value; + return 0; + } + PyErr_SetString(PyExc_TypeError, "enum values must be integers or strings"); + return 1; +} + +gint PyGtkFlag_get_value(GtkType flag_type, PyObject *obj, int *val) { + if (PyInt_Check(obj)) { + *val = PyInt_AsLong(obj); + return 0; + } else if (PyString_Check(obj)) { + GtkFlagValue *info = gtk_type_flags_find_value(flag_type, + PyString_AsString(obj)); + if (!info) { + PyErr_SetString(PyExc_TypeError, "couldn't translate string"); + return 1; + } + *val = info->value; + return 0; + } else if (PyTuple_Check(obj)) { + int i, len; + PyObject *item; + len = PyTuple_Size(obj); + *val = 0; + for (i = 0; i < len; i++) { + item = PyTuple_GetItem(obj, i); + if (PyInt_Check(item)) + *val |= PyInt_AsLong(item); + else if (PyString_Check(item)) { + GtkFlagValue *info = gtk_type_flags_find_value(flag_type, + PyString_AsString(item)); + if (!info) { + PyErr_SetString(PyExc_TypeError, "couldn't translate string"); + return 1; + } + *val |= info->value; + } else { + PyErr_SetString(PyExc_TypeError, + "tuple components must be ints or strings"); + return 1; + } + } + return 0; + } + PyErr_SetString(PyExc_TypeError, + "flag values must be ints, strings or tuples"); + return 1; +} + + +typedef struct { + PyObject_HEAD + GtkAccelGroup *obj; +} PyGtkAccelGroup_Object; +staticforward PyTypeObject PyGtkAccelGroup_Type; + +typedef struct { + PyObject_HEAD + GtkStyle *obj; +} PyGtkStyle_Object; +staticforward PyTypeObject PyGtkStyle_Type; + +typedef struct { + PyObject_HEAD + GdkFont *obj; +} PyGdkFont_Object; +staticforward PyTypeObject PyGdkFont_Type; + +typedef struct { + PyObject_HEAD + GdkColor obj; +} PyGdkColor_Object; +staticforward PyTypeObject PyGdkColor_Type; + +typedef struct { + PyObject_HEAD + GdkEvent *obj; + PyObject *attrs; +} PyGdkEvent_Object; +staticforward PyTypeObject PyGdkEvent_Type; + +typedef struct { + PyObject_HEAD + GdkWindow *obj; +} PyGdkWindow_Object; +staticforward PyTypeObject PyGdkWindow_Type; + +typedef struct { + PyObject_HEAD + GdkGC *obj; +} PyGdkGC_Object; +staticforward PyTypeObject PyGdkGC_Type; + +typedef struct { + PyObject_HEAD + GdkColormap *obj; +} PyGdkColormap_Object; +staticforward PyTypeObject PyGdkColormap_Type; + +typedef struct { + PyObject_HEAD + GdkDragContext *obj; +} PyGdkDragContext_Object; +staticforward PyTypeObject PyGdkDragContext_Type; + +typedef struct { + PyObject_HEAD + GtkSelectionData *obj; +} PyGtkSelectionData_Object; +staticforward PyTypeObject PyGtkSelectionData_Type; + +typedef struct { + PyObject_HEAD + gchar *name; + GdkAtom atom; +} PyGdkAtom_Object; +staticforward PyTypeObject PyGdkAtom_Type; + +typedef struct { + PyObject_HEAD + GdkCursor *obj; +} PyGdkCursor_Object; +staticforward PyTypeObject PyGdkCursor_Type; + +typedef struct { + PyObject_HEAD + GtkCTreeNode *node; +} PyGtkCTreeNode_Object; +staticforward PyTypeObject PyGtkCTreeNode_Type; + +#define PyGtkAccelGroup_Check(v) ((v)->ob_type == &PyGtkAccelGroup_Type) +#define PyGtkAccelGroup_Get(v) (((PyGtkAccelGroup_Object *)(v))->obj) +#define PyGtkStyle_Check(v) ((v)->ob_type == &PyGtkStyle_Type) +#define PyGtkStyle_Get(v) (((PyGtkStyle_Object *)(v))->obj) +#define PyGdkFont_Check(v) ((v)->ob_type == &PyGdkFont_Type) +#define PyGdkFont_Get(v) (((PyGdkFont_Object *)(v))->obj) +#define PyGdkColor_Check(v) ((v)->ob_type == &PyGdkColor_Type) +#define PyGdkColor_Get(v) (&((PyGdkColor_Object *)(v))->obj) +#define PyGdkEvent_Check(v) ((v)->ob_type == &PyGdkEvent_Type) +#define PyGdkEvent_Get(v) (((PyGdkEvent_Object *)(v))->obj) +#define PyGdkWindow_Check(v) ((v)->ob_type == &PyGdkWindow_Type) +#define PyGdkWindow_Get(v) (((PyGdkWindow_Object *)(v))->obj) +#define PyGdkGC_Check(v) ((v)->ob_type == &PyGdkGC_Type) +#define PyGdkGC_Get(v) (((PyGdkGC_Object *)(v))->obj) +#define PyGdkColormap_Check(v) ((v)->ob_type == &PyGdkColormap_Type) +#define PyGdkColormap_Get(v) (((PyGdkColormap_Object *)(v))->obj) +#define PyGdkDragContext_Check(v) ((v)->ob_type == &PyGdkDragContext_Type) +#define PyGdkDragContext_Get(v) (((PyGdkDragContext_Object *)(v))->obj) +#define PyGtkSelectionData_Check(v) ((v)->ob_type == &PyGtkSelectionData_Type) +#define PyGtkSelectionData_Get(v) (((PyGtkSelectionData_Object *)(v))->obj) +#define PyGdkAtom_Check(v) ((v)->ob_type == &PyGdkAtom_Type) +#define PyGdkAtom_Get(v) (((PyGdkAtom_Object *)(v))->atom) +#define PyGdkCursor_Check(v) ((v)->ob_type == &PyGdkCursor_Type) +#define PyGdkCursor_Get(v) (((PyGdkCursor_Object *)(v))->obj) +#define PyGtkCTreeNode_Check(v) ((v)->ob_type == &PyGtkCTreeNode_Type) +#define PyGtkCTreeNode_Get(v) (((PyGtkCTreeNode_Object *)(v))->node) + +static PyObject * +PyGtkAccelGroup_New(GtkAccelGroup *obj) { + PyGtkAccelGroup_Object *self; + + self = (PyGtkAccelGroup_Object *)PyObject_NEW(PyGtkAccelGroup_Object , + &PyGtkAccelGroup_Type); + if (self == NULL) + return NULL; + self->obj = obj; + gtk_accel_group_ref(self->obj); + return (PyObject *)self; +} + +static PyObject * +PyGtkStyle_New(GtkStyle *obj) { + PyGtkStyle_Object *self; + + self = (PyGtkStyle_Object *)PyObject_NEW(PyGtkStyle_Object, + &PyGtkStyle_Type); + if (self == NULL) + return NULL; + self->obj = obj; + gtk_style_ref(self->obj); + return (PyObject *)self; +} + +static PyObject * +PyGdkFont_New(GdkFont *obj) { + PyGdkFont_Object *self; + + self = (PyGdkFont_Object *)PyObject_NEW(PyGdkFont_Object, &PyGdkFont_Type); + if (self == NULL) + return NULL; + self->obj = obj; + gdk_font_ref(self->obj); + return (PyObject *)self; +} + +static PyObject * +PyGdkColor_New(GdkColor *obj) { + PyGdkColor_Object *self; + + self = (PyGdkColor_Object *)PyObject_NEW(PyGdkColor_Object,&PyGdkColor_Type); + if (self == NULL) + return NULL; + self->obj.pixel = obj->pixel; + self->obj.red = obj->red; + self->obj.green = obj->green; + self->obj.blue = obj->blue; + return (PyObject *)self; +} + +static PyObject * +PyGdkWindow_New(GdkWindow *win) { + PyGdkWindow_Object *self; + + self = (PyGdkWindow_Object *)PyObject_NEW(PyGdkWindow_Object, + &PyGdkWindow_Type); + if (self == NULL) + return NULL; + self->obj = win; + gdk_window_ref(self->obj); + return (PyObject *)self; +} + +static PyObject * +PyGdkGC_New(GdkGC *gc) { + PyGdkGC_Object *self; + + self = (PyGdkGC_Object *)PyObject_NEW(PyGdkGC_Object, &PyGdkGC_Type); + if (self == NULL) + return NULL; + self->obj = gc; + gdk_gc_ref(self->obj); + return (PyObject *)self; +} + +static PyObject * +PyGdkColormap_New(GdkColormap *cmap) { + PyGdkColormap_Object *self; + + self = (PyGdkColormap_Object *)PyObject_NEW(PyGdkColormap_Object, + &PyGdkColormap_Type); + if (self == NULL) + return NULL; + self->obj = cmap; + gdk_colormap_ref(self->obj); + return (PyObject *)self; +} + +static PyObject * +PyGdkDragContext_New(GdkDragContext *ctx) { + PyGdkDragContext_Object *self; + + self = (PyGdkDragContext_Object *)PyObject_NEW(PyGdkDragContext_Object, + &PyGdkDragContext_Type); + if (!self) + return NULL; + self->obj = ctx; + gdk_drag_context_ref(self->obj); + return (PyObject *)self; +} + +static PyObject * +PyGtkSelectionData_New(GtkSelectionData *data) { + PyGtkSelectionData_Object *self; + + self = (PyGtkSelectionData_Object *)PyObject_NEW(PyGtkSelectionData_Object, + &PyGtkSelectionData_Type); + if (!self) + return NULL; + self->obj = gtk_selection_data_copy(data); + return (PyObject *)self; +} + +static PyObject * +PyGdkAtom_New(GdkAtom atom) { + PyGdkAtom_Object *self; + + self = (PyGdkAtom_Object *)PyObject_NEW(PyGdkAtom_Object, &PyGdkAtom_Type); + if (!self) + return NULL; + self->atom = atom; + self->name = NULL; + return (PyObject *)self; +} + +static PyObject * +PyGdkCursor_New(GdkCursor *obj) { + PyGdkCursor_Object *self; + + self = (PyGdkCursor_Object *)PyObject_NEW(PyGdkCursor_Object, + &PyGdkCursor_Type); + if (!self) + return NULL; + self->obj = obj; + return (PyObject *)self; +} + +static PyObject * +PyGtkCTreeNode_New(GtkCTreeNode *node) { + PyGtkCTreeNode_Object *self; + + self = (PyGtkCTreeNode_Object *)PyObject_NEW(PyGtkCTreeNode_Object, + &PyGtkCTreeNode_Type); + if (!self) + return NULL; + self->node = node; + return (PyObject *)self; +} + +static void +PyGtkAccelGroup_Dealloc(PyGtkAccelGroup_Object *self) { + gtk_accel_group_unref(self->obj); + PyMem_DEL(self); +} + +static int +PyGtkAccelGroup_Compare(PyGtkAccelGroup_Object *self, + PyGtkAccelGroup_Object *v) { + if (self->obj == v->obj) return 0; + if (self->obj > v->obj) return -1; + return 1; +} + +static PyTypeObject PyGtkAccelGroup_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "GtkAccelGroup", + sizeof(PyGtkAccelGroup_Object), + 0, + (destructor)PyGtkAccelGroup_Dealloc, + (printfunc)0, + (getattrfunc)0, + (setattrfunc)0, + (cmpfunc)PyGtkAccelGroup_Compare, + (reprfunc)0, + 0, + 0, + 0, + (hashfunc)0, + (ternaryfunc)0, + (reprfunc)0, + 0L,0L,0L,0L, + NULL +}; + +static void +PyGtkStyle_Dealloc(PyGtkStyle_Object *self) { + gtk_style_unref(self->obj); + PyMem_DEL(self); +} + +static int +PyGtkStyle_Compare(PyGtkStyle_Object *self, PyGtkStyle_Object *v) { + if (self->obj == v->obj) return 0; + if (self->obj > v->obj) return -1; + return 1; +} + +static PyObject *PyGtkStyle_GetAttr(PyGtkStyle_Object *self, char *attr) { + GtkStyle *style = self->obj; + PyObject *ret; + int i; + + if (!strcmp(attr, "__members__")) + return Py_BuildValue("[sssssssssssssssssssss]", "base", "base_gc", "bg", + "bg_gc", "bg_pixmap", "black", "black_gc", "colormap", + "dark", "dark_gc", "fg", "fg_gc", "font", "light", + "light_gc", "mid", "mid_gc", "text", "text_gc", + "white", "white_gc"); + if (!strcmp(attr, "fg")) { + ret = PyTuple_New(5); + for (i = 0; i < 5; i++) + PyTuple_SetItem(ret, i, PyGdkColor_New(&style->fg[i])); + return ret; + } + if (!strcmp(attr, "bg")) { + ret = PyTuple_New(5); + for (i = 0; i < 5; i++) + PyTuple_SetItem(ret, i, PyGdkColor_New(&style->bg[i])); + return ret; + } + if (!strcmp(attr, "light")) { + ret = PyTuple_New(5); + for (i = 0; i < 5; i++) + PyTuple_SetItem(ret, i, PyGdkColor_New(&style->light[i])); + return ret; + } + if (!strcmp(attr, "dark")) { + ret = PyTuple_New(5); + for (i = 0; i < 5; i++) + PyTuple_SetItem(ret, i, PyGdkColor_New(&style->dark[i])); + return ret; + } + if (!strcmp(attr, "mid")) { + ret = PyTuple_New(5); + for (i = 0; i < 5; i++) + PyTuple_SetItem(ret, i, PyGdkColor_New(&style->mid[i])); + return ret; + } + if (!strcmp(attr, "text")) { + ret = PyTuple_New(5); + for (i = 0; i < 5; i++) + PyTuple_SetItem(ret, i, PyGdkColor_New(&style->text[i])); + return ret; + } + if (!strcmp(attr, "base")) { + ret = PyTuple_New(5); + for (i = 0; i < 5; i++) + PyTuple_SetItem(ret, i, PyGdkColor_New(&style->base[i])); + return ret; + } + if (!strcmp(attr, "black")) + return PyGdkColor_New(&style->black); + if (!strcmp(attr, "white")) + return PyGdkColor_New(&style->white); + if (!strcmp(attr, "font")) + return PyGdkFont_New(style->font); + if (!strcmp(attr, "fg_gc")) { + ret = PyTuple_New(5); + for (i = 0; i < 5; i++) + PyTuple_SetItem(ret, i, PyGdkGC_New(style->fg_gc[i])); + return ret; + } + if (!strcmp(attr, "bg_gc")) { + ret = PyTuple_New(5); + for (i = 0; i < 5; i++) + PyTuple_SetItem(ret, i, PyGdkGC_New(style->bg_gc[i])); + return ret; + } + if (!strcmp(attr, "light_gc")) { + ret = PyTuple_New(5); + for (i = 0; i < 5; i++) + PyTuple_SetItem(ret, i, PyGdkGC_New(style->light_gc[i])); + return ret; + } + if (!strcmp(attr, "dark_gc")) { + ret = PyTuple_New(5); + for (i = 0; i < 5; i++) + PyTuple_SetItem(ret, i, PyGdkGC_New(style->dark_gc[i])); + return ret; + } + if (!strcmp(attr, "mid_gc")) { + ret = PyTuple_New(5); + for (i = 0; i < 5; i++) + PyTuple_SetItem(ret, i, PyGdkGC_New(style->mid_gc[i])); + return ret; + } + if (!strcmp(attr, "text_gc")) { + ret = PyTuple_New(5); + for (i = 0; i < 5; i++) + PyTuple_SetItem(ret, i, PyGdkGC_New(style->text_gc[i])); + return ret; + } + if (!strcmp(attr, "base_gc")) { + ret = PyTuple_New(5); + for (i = 0; i < 5; i++) + PyTuple_SetItem(ret, i, PyGdkGC_New(style->base_gc[i])); + return ret; + } + if (!strcmp(attr, "black_gc")) + return PyGdkGC_New(style->black_gc); + if (!strcmp(attr, "white_gc")) + return PyGdkGC_New(style->white_gc); + if (!strcmp(attr, "bg_pixmap")) { + ret = PyTuple_New(5); + for (i = 0; i < 5; i++) + PyTuple_SetItem(ret, i,PyGdkWindow_New(style->bg_pixmap[i])); + return ret; + } + if (!strcmp(attr, "colormap")) { + if (style->colormap) + return PyGdkColormap_New(style->colormap); + Py_INCREF(Py_None); + return Py_None; + } + + PyErr_SetString(PyExc_AttributeError, attr); + return NULL; +} + +static PyTypeObject PyGtkStyle_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "GtkStyle", + sizeof(PyGtkStyle_Object), + 0, + (destructor)PyGtkStyle_Dealloc, + (printfunc)0, + (getattrfunc)PyGtkStyle_GetAttr, + (setattrfunc)0, + (cmpfunc)PyGtkStyle_Compare, + (reprfunc)0, + 0, + 0, + 0, + (hashfunc)0, + (ternaryfunc)0, + (reprfunc)0, + 0L,0L,0L,0L, + NULL +}; + +static void +PyGdkFont_Dealloc(PyGdkFont_Object *self) { + gdk_font_unref(self->obj); + PyMem_DEL(self); +} + +static PyObject * +PyGdkFont_Width(PyGdkFont_Object *self, PyObject *args) { + char *text; + int length; + + if (!PyArg_ParseTuple(args, "s#:GdkFont.width", &text, &length)) + return NULL; + return PyInt_FromLong(gdk_text_width(self->obj, text, length)); +} + +static PyObject * +PyGdkFont_Measure(PyGdkFont_Object *self, PyObject *args) { + char *text; + int length; + + if (!PyArg_ParseTuple(args, "s#:GdkFont.measure", &text, &length)) + return NULL; + return PyInt_FromLong(gdk_text_measure(self->obj, text, length)); +} + +static PyObject * +PyGdkFont_Height(PyGdkFont_Object *self, PyObject *args) { + char *text; + int length; + + if (!PyArg_ParseTuple(args, "s#:GdkFont.height", &text, &length)) + return NULL; + return PyInt_FromLong(gdk_text_height(self->obj, text, length)); +} + +static PyObject * +PyGdkFont_Extents(PyGdkFont_Object *self, PyObject *args) { + char *text; + int length, lbearing, rbearing, width, ascent, descent; + if (!PyArg_ParseTuple(args, "s#:GdkFont.extents", &text, &length)) + return NULL; + gdk_text_extents(self->obj, text, length, &lbearing, &rbearing, + &width, &ascent, &descent); + return Py_BuildValue("(iiiii)", lbearing, rbearing, width, ascent, descent); +} + +static PyMethodDef PyGdkFont_methods[] = { + {"width", (PyCFunction)PyGdkFont_Width, METH_VARARGS, NULL}, + {"measure", (PyCFunction)PyGdkFont_Measure, METH_VARARGS, NULL}, + {"height", (PyCFunction)PyGdkFont_Height, METH_VARARGS, NULL}, + {"extents", (PyCFunction)PyGdkFont_Extents, METH_VARARGS, NULL}, + {NULL, 0, 0, NULL} +}; + +static PyObject * +PyGdkFont_GetAttr(PyGdkFont_Object *self, char *key) { + if (!strcmp(key, "__members__")) + return Py_BuildValue("[sss]", "ascent", "descent", "type"); + if (!strcmp(key, "ascent")) + return PyInt_FromLong(self->obj->ascent); + if (!strcmp(key, "descent")) + return PyInt_FromLong(self->obj->descent); + if (!strcmp(key, "type")) + return PyInt_FromLong(self->obj->type); + return Py_FindMethod(PyGdkFont_methods, (PyObject *)self, key); +} + +static int +PyGdkFont_Compare(PyGdkFont_Object *self, PyGdkFont_Object *v) { + if (self->obj == v->obj) return 0; + if (self->obj > v->obj) return -1; + return 1; +} + +static PyTypeObject PyGdkFont_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "GdkFont", + sizeof(PyGdkFont_Object), + 0, + (destructor)PyGdkFont_Dealloc, + (printfunc)0, + (getattrfunc)PyGdkFont_GetAttr, + (setattrfunc)0, + (cmpfunc)PyGdkFont_Compare, + (reprfunc)0, + 0, + 0, + 0, + (hashfunc)0, + (ternaryfunc)0, + (reprfunc)0, + 0L,0L,0L,0L, + NULL +}; + +static void +PyGdkColor_Dealloc(PyGdkColor_Object *self) { + PyMem_DEL(self); +} + +static PyObject * +PyGdkColor_GetAttr(PyGdkColor_Object *self, char *key) { + if (!strcmp(key, "red")) + return PyInt_FromLong(self->obj.red); + if (!strcmp(key, "green")) + return PyInt_FromLong(self->obj.green); + if (!strcmp(key, "blue")) + return PyInt_FromLong(self->obj.blue); + if (!strcmp(key, "pixel")) + return PyInt_FromLong(self->obj.pixel); + PyErr_SetString(PyExc_AttributeError, key); + return NULL; +} + +static int +PyGdkColor_Compare(PyGdkColor_Object *self, PyGdkColor_Object *v) { + if (self->obj.pixel == v->obj.pixel) return 0; + if (self->obj.pixel > v->obj.pixel) return -1; + return 1; +} + +static PyObject * +PyGdkColor_Repr(PyGdkColor_Object *self) { + char buf[80]; + + g_snprintf(buf, 79, "<GdkColor (%hu, %hu, %hu)>", self->obj.red, + self->obj.green, self->obj.blue); + return PyString_FromString(buf); +} + +static PyTypeObject PyGdkColor_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "GdkColor", + sizeof(PyGdkColor_Object), + 0, + (destructor)PyGdkColor_Dealloc, + (printfunc)0, + (getattrfunc)PyGdkColor_GetAttr, + (setattrfunc)0, + (cmpfunc)PyGdkColor_Compare, + (reprfunc)PyGdkColor_Repr, + 0, + 0, + 0, + (hashfunc)0, + (ternaryfunc)0, + (reprfunc)0, + 0L,0L,0L,0L, + NULL +}; + +static PyObject * +PyGdkEvent_New(GdkEvent *obj) { + PyGdkEvent_Object *self; + PyObject *v; + + if (obj == NULL) { + Py_INCREF(Py_None); + return Py_None; + } + self = (PyGdkEvent_Object *)PyObject_NEW(PyGdkEvent_Object,&PyGdkEvent_Type); + if (self == NULL) + return NULL; + self->obj = obj; + self->attrs = PyDict_New(); + PyDict_SetItemString(self->attrs, "type", v=PyInt_FromLong(obj->type)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "window", v=PyGdkWindow_New( + obj->any.window)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "send_event", v=PyInt_FromLong( + obj->any.send_event)); + Py_DECREF(v); + /* XXX Does anyone need the window attribute?? */ + switch(obj->type) { + case GDK_NOTHING: break; + case GDK_DELETE: break; + case GDK_DESTROY: break; + case GDK_EXPOSE: /*GdkEventExpose expose*/ + PyDict_SetItemString(self->attrs, "area", v=Py_BuildValue("(iiii)", + obj->expose.area.x, obj->expose.area.y, obj->expose.area.width, + obj->expose.area.height)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "count", v=PyInt_FromLong( + obj->expose.count)); + Py_DECREF(v); + break; + case GDK_MOTION_NOTIFY: /*GdkEventMotion motion*/ + PyDict_SetItemString(self->attrs, "time", v=PyInt_FromLong( + obj->motion.time)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs,"x",v=PyFloat_FromDouble(obj->motion.x)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs,"y",v=PyFloat_FromDouble(obj->motion.y)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "pressure", v=PyFloat_FromDouble( + obj->motion.pressure)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "xtilt", v=PyFloat_FromDouble( + obj->motion.xtilt)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "ytilt", v=PyFloat_FromDouble( + obj->motion.ytilt)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "state", v=PyInt_FromLong( + obj->motion.state)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "is_hint", v=PyInt_FromLong( + obj->motion.is_hint)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "source", v=PyInt_FromLong( + obj->motion.source)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "deviceid", v=PyInt_FromLong( + obj->motion.deviceid)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "x_root", v=PyFloat_FromDouble( + obj->motion.x_root)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "y_root", v=PyFloat_FromDouble( + obj->motion.y_root)); + Py_DECREF(v); + break; + case GDK_BUTTON_PRESS: /*GdkEventButton button*/ + case GDK_2BUTTON_PRESS: /*GdkEventButton button*/ + case GDK_3BUTTON_PRESS: /*GdkEventButton button*/ + PyDict_SetItemString(self->attrs, "time", v=PyInt_FromLong( + obj->button.time)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs,"x",v=PyFloat_FromDouble(obj->button.x)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs,"y",v=PyFloat_FromDouble(obj->button.y)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "pressure", v=PyFloat_FromDouble( + obj->button.pressure)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "xtilt", v=PyFloat_FromDouble( + obj->button.xtilt)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "ytilt", v=PyFloat_FromDouble( + obj->button.ytilt)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "state", v=PyInt_FromLong( + obj->button.state)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "button", v=PyInt_FromLong( + obj->button.button)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "source", v=PyInt_FromLong( + obj->button.source)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "deviceid", v=PyInt_FromLong( + obj->button.deviceid)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "x_root", v=PyFloat_FromDouble( + obj->button.x_root)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "y_root", v=PyFloat_FromDouble( + obj->button.y_root)); + Py_DECREF(v); + break; + case GDK_KEY_PRESS: /*GdkEventKey key*/ + case GDK_KEY_RELEASE: /*GdkEventKey key*/ + PyDict_SetItemString(self->attrs, "time", v=PyInt_FromLong( + obj->key.time)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "state", v=PyInt_FromLong( + obj->key.state)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "keyval", v=PyInt_FromLong( + obj->key.keyval)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "string", v=PyString_FromStringAndSize( + obj->key.string, obj->key.length)); + Py_DECREF(v); + break; + case GDK_ENTER_NOTIFY: /*GdkEventCrossing crossing*/ + case GDK_LEAVE_NOTIFY: /*GdkEventCrossing crossing*/ + PyDict_SetItemString(self->attrs, "subwindow", v=PyGdkWindow_New( + obj->crossing.subwindow)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "time", v=PyInt_FromLong( + obj->crossing.time)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "x", v=PyFloat_FromDouble( + obj->crossing.x)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "y", v=PyFloat_FromDouble( + obj->crossing.y)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "x_root", v=PyFloat_FromDouble( + obj->crossing.x_root)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "y_root", v=PyFloat_FromDouble( + obj->crossing.y_root)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "mode", v=PyInt_FromLong( + obj->crossing.mode)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "detail", v=PyInt_FromLong( + obj->crossing.detail)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "focus", v=PyInt_FromLong( + obj->crossing.focus)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "state", v=PyInt_FromLong( + obj->crossing.state)); + Py_DECREF(v); + break; + case GDK_FOCUS_CHANGE: /*GdkEventFocus focus_change*/ + PyDict_SetItemString(self->attrs, "_in", v=PyInt_FromLong( + obj->focus_change.in)); + Py_DECREF(v); + break; + case GDK_CONFIGURE: /*GdkEventConfigure configure*/ + PyDict_SetItemString(self->attrs, "x", v=PyInt_FromLong(obj->configure.x)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "y", v=PyInt_FromLong(obj->configure.y)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "width", v=PyInt_FromLong( + obj->configure.width)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "height", v=PyInt_FromLong( + obj->configure.height)); + Py_DECREF(v); + break; + case GDK_MAP: break; + case GDK_UNMAP: break; + case GDK_PROPERTY_NOTIFY: /*GdkEventProperty property*/ + PyDict_SetItemString(self->attrs, "atom", v=PyGdkAtom_New( + obj->property.atom)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "time", v=PyInt_FromLong( + obj->property.time)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "state", v=PyInt_FromLong( + obj->property.state)); + Py_DECREF(v); + break; + case GDK_SELECTION_CLEAR: /*GdkEventSelection selection*/ + case GDK_SELECTION_REQUEST: /*GdkEventSelection selection*/ + case GDK_SELECTION_NOTIFY: /*GdkEventSelection selection*/ + PyDict_SetItemString(self->attrs, "selection", v=PyGdkAtom_New( + obj->selection.selection)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "target", v=PyGdkAtom_New( + obj->selection.target)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "property", v=PyGdkAtom_New( + obj->selection.property)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "requestor", v=PyInt_FromLong( + obj->selection.requestor)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "time", v=PyInt_FromLong( + obj->selection.time)); + Py_DECREF(v); + break; + case GDK_PROXIMITY_IN: /*GdkEventProximity proximity*/ + case GDK_PROXIMITY_OUT: /*GdkEventProximity proximity*/ + PyDict_SetItemString(self->attrs, "time", v=PyInt_FromLong( + obj->proximity.time)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "source", v=PyInt_FromLong( + obj->proximity.source)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "deviceid", v=PyInt_FromLong( + obj->proximity.deviceid)); + Py_DECREF(v); + break; + case GDK_DRAG_ENTER: /*GdkEventDND dnd*/ + case GDK_DRAG_LEAVE: /*GdkEventDND dnd*/ + case GDK_DRAG_MOTION: /*GdkEventDND dnd*/ + case GDK_DRAG_STATUS: /*GdkEventDND dnd*/ + case GDK_DROP_START: /*GdkEventDND dnd*/ + case GDK_DROP_FINISHED: /*GdkEventDND dnd*/ + PyDict_SetItemString(self->attrs, "context", v=PyGdkDragContext_New( + obj->dnd.context)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "time", v=PyInt_FromLong(obj->dnd.time)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "x_root", v=PyInt_FromLong( + obj->dnd.x_root)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "y_root", v=PyInt_FromLong( + obj->dnd.y_root)); + Py_DECREF(v); + break; + case GDK_CLIENT_EVENT: /*GdkEventClient client*/ + PyDict_SetItemString(self->attrs, "message_type", v=PyGdkAtom_New( + obj->client.message_type)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "data_format", v=PyInt_FromLong( + obj->client.data_format)); + Py_DECREF(v); + PyDict_SetItemString(self->attrs, "data", v=PyString_FromStringAndSize( + obj->client.data.b, 20)); + Py_DECREF(v); + break; + case GDK_VISIBILITY_NOTIFY: /*GdkEventVisibility visibility*/ + PyDict_SetItemString(self->attrs, "state", v=PyInt_FromLong( + obj->visibility.state)); + Py_DECREF(v); + break; + case GDK_NO_EXPOSE: /*GdkEventNoExpose no_expose*/ + break; + default: + break; + } + return (PyObject *)self; +} + +static void +PyGdkEvent_Dealloc(PyGdkEvent_Object *self) { + Py_XDECREF(self->attrs); + PyMem_DEL(self); +} + +static PyObject * +PyGdkEvent_GetAttr(PyGdkEvent_Object *self, char *attr) { + PyObject *ret; + ret = PyDict_GetItemString(self->attrs, attr); + if (ret != NULL) { + Py_INCREF(ret); + return ret; + } + PyErr_SetString(PyExc_AttributeError, attr); + return NULL; +} + +static int +PyGdkEvent_Compare(PyGdkEvent_Object *self, PyGdkEvent_Object *v) { + if (self->obj == v->obj) return 0; + if (self->obj > v->obj) return -1; + return 1; +} + +static PyTypeObject PyGdkEvent_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "GdkEvent", + sizeof(PyGdkEvent_Object), + 0, + (destructor)PyGdkEvent_Dealloc, + (printfunc)0, + (getattrfunc)PyGdkEvent_GetAttr, + (setattrfunc)0, + (cmpfunc)PyGdkEvent_Compare, + (reprfunc)0, + 0, + 0, + 0, + (hashfunc)0, + (ternaryfunc)0, + (reprfunc)0, + 0L,0L,0L,0L, + NULL +}; + +static void +PyGdkWindow_Dealloc(PyGdkWindow_Object *self) { + if (gdk_window_get_type(self->obj) == GDK_WINDOW_PIXMAP) + gdk_pixmap_unref(self->obj); + else + gdk_window_unref(self->obj); + PyMem_DEL(self); +} + +static int +PyGdkWindow_Compare(PyGdkWindow_Object *self, PyGdkWindow_Object *v) { + if (self->obj == v->obj) return 0; + if (self->obj > v->obj) return -1; + return 1; +} + +static PyObject * +PyGdkWindow_Repr(PyGdkWindow_Object *self) { + char buf[100]; + if (gdk_window_get_type(self->obj) == GDK_WINDOW_PIXMAP) + sprintf(buf, "<GdkPixmap at %lx>", (long)PyGdkWindow_Get(self)); + else + sprintf(buf, "<GdkWindow at %lx>", (long)PyGdkWindow_Get(self)); + return PyString_FromString(buf); +} + +static PyObject * +PyGdkWindow_NewGC(PyGdkWindow_Object *self, PyObject *args, PyObject *kws) { + int i = 0; + PyObject *key, *value; + char *strkey; + GdkGCValues values; + GdkGCValuesMask mask = 0; + GdkGC *gc; + + if (kws != NULL) + while (PyDict_Next(kws, &i, &key, &value)) { + strkey = PyString_AsString(key); + if (!strcmp(strkey, "foreground")) { + if (!PyGdkColor_Check(value)) { + PyErr_SetString(PyExc_TypeError, "foreground argument takes a GdkColor"); + return NULL; + } + mask |= GDK_GC_FOREGROUND; + values.foreground.red = PyGdkColor_Get(value)->red; + values.foreground.green = PyGdkColor_Get(value)->green; + values.foreground.blue = PyGdkColor_Get(value)->blue; + values.foreground.pixel = PyGdkColor_Get(value)->pixel; + } else if (!strcmp(strkey, "background")) { + if (!PyGdkColor_Check(value)) { + PyErr_SetString(PyExc_TypeError, "background argument takes a GdkColor"); + return NULL; + } + mask |= GDK_GC_BACKGROUND; + values.background.red = PyGdkColor_Get(value)->red; + values.background.green = PyGdkColor_Get(value)->green; + values.background.blue = PyGdkColor_Get(value)->blue; + values.background.pixel = PyGdkColor_Get(value)->pixel; + } else if (!strcmp(strkey, "font")) { + if (!PyGdkFont_Check(value)) { + PyErr_SetString(PyExc_TypeError, "font argument takes a GdkFont"); + return NULL; + } + mask |= GDK_GC_FONT; + values.font = PyGdkFont_Get(value); + } else if (!strcmp(strkey, "tile")) { + if (!PyGdkWindow_Check(value)) { + PyErr_SetString(PyExc_TypeError, "tile argument takes a GdkPixmap"); + return NULL; + } + mask |= GDK_GC_TILE; + values.tile = PyGdkWindow_Get(value); + } else if (!strcmp(strkey, "stipple")) { + if (!PyGdkWindow_Check(value)) { + PyErr_SetString(PyExc_TypeError, "stipple argument takes a GdkPixmap"); + return NULL; + } + mask |= GDK_GC_STIPPLE; + values.stipple = PyGdkWindow_Get(value); + } else if (!strcmp(strkey, "clip_mask")) { + if (!PyGdkWindow_Check(value)) { + PyErr_SetString(PyExc_TypeError, "clip_mask argument takes a GdkPixmap"); + return NULL; + } + mask |= GDK_GC_CLIP_MASK; + values.clip_mask = PyGdkWindow_Get(value); + } else { + int i = 0; +#ifndef offsetof +#define offsetof(type, member) ( (int) &((type*)0)->member) +#endif +#define OFF(x) offsetof(GdkGCValues, x) + static struct {char *name;GdkGCValuesMask mask;int offs; } others[] = { + {"function", GDK_GC_FUNCTION, OFF(function)}, + {"fill", GDK_GC_FILL, OFF(fill)}, + {"subwindow_mode", GDK_GC_SUBWINDOW, OFF(subwindow_mode)}, + {"ts_x_origin", GDK_GC_TS_X_ORIGIN, OFF(ts_x_origin)}, + {"ts_y_origin", GDK_GC_TS_Y_ORIGIN, OFF(ts_y_origin)}, + {"clip_x_origin", GDK_GC_CLIP_X_ORIGIN, OFF(clip_x_origin)}, + {"clip_y_origin", GDK_GC_CLIP_Y_ORIGIN, OFF(clip_y_origin)}, + {"graphics_exposures", GDK_GC_EXPOSURES, OFF(graphics_exposures)}, + {"line_width", GDK_GC_LINE_WIDTH, OFF(line_width)}, + {"line_style", GDK_GC_LINE_STYLE, OFF(line_style)}, + {"cap_style", GDK_GC_CAP_STYLE, OFF(cap_style)}, + {"join_style", GDK_GC_JOIN_STYLE, OFF(join_style)}, + {NULL, 0, 0} + }; +#undef OFF + while (others[i].name != NULL) { + if (!strcmp(strkey, others[i].name)) { + if (!PyInt_Check(value)) { + char buf[80]; + g_snprintf(buf, 79, "%s argument expects an integer", + others[i].name); + PyErr_SetString(PyExc_TypeError, buf); + return NULL; + } + mask |= others[i].mask; + *((int *)((char *)&values + others[i].offs)) = PyInt_AsLong(value); + break; + } + i++; + } + if (others[i].name == NULL) { + PyErr_SetString(PyExc_TypeError, "unknown argument"); + return NULL; + } + } + } + if (!PyArg_ParseTuple(args, ":GdkWindow.new_gc")) + return NULL; + gc = gdk_gc_new_with_values(PyGdkWindow_Get(self), &values, mask); + value = PyGdkGC_New(gc); + gdk_gc_unref(gc); + return value; +} + +static PyObject *PyGdkWindow_SetCursor(PyGdkWindow_Object *self, + PyObject *args) { + PyObject *cursor; + + if (!PyArg_ParseTuple(args, "O!:GdkWindow.set_cursor", &PyGdkCursor_Type, + &cursor)) + return NULL; + gdk_window_set_cursor(self->obj, PyGdkCursor_Get(cursor)); + Py_INCREF(Py_None); + return Py_None; +} + +static PyMethodDef PyGdkWindow_methods[] = { + {"new_gc", (PyCFunction)PyGdkWindow_NewGC, METH_VARARGS|METH_KEYWORDS, NULL}, + {"set_cursor", (PyCFunction)PyGdkWindow_SetCursor, METH_VARARGS, NULL}, + {NULL, 0, 0, NULL} +}; + +static PyObject * +PyGdkWindow_GetAttr(PyGdkWindow_Object *self, char *key) { + GdkWindow *win = PyGdkWindow_Get(self); + gint x, y; + GdkModifierType p_mask; + + if (!strcmp(key, "__members__")) + return Py_BuildValue("[sssssssssss]", "children", "colormap", "height", + "parent", "pointer", "pointer_state", "toplevel", + "type", "width", "x", "y"); + if (!strcmp(key, "width")) { + gdk_window_get_size(win, &x, NULL); + return PyInt_FromLong(x); + } + if (!strcmp(key, "height")) { + gdk_window_get_size(win, NULL, &y); + return PyInt_FromLong(y); + } + if (!strcmp(key, "x")) { + gdk_window_get_position(win, &x, NULL); + return PyInt_FromLong(x); + } + if (!strcmp(key, "y")) { + gdk_window_get_position(win, NULL, &y); + return PyInt_FromLong(y); + } + if (!strcmp(key, "colormap")) + return PyGdkColormap_New(gdk_window_get_colormap(win)); + if (!strcmp(key, "pointer")) { + gdk_window_get_pointer(win, &x, &y, NULL); + return Py_BuildValue("(ii)", x, y); + } + if (!strcmp(key, "pointer_state")) { + gdk_window_get_pointer(win, NULL, NULL, &p_mask); + return PyInt_FromLong(p_mask); + } + if (!strcmp(key, "parent")) + return PyGdkWindow_New(gdk_window_get_parent(win)); + if (!strcmp(key, "toplevel")) + return PyGdkWindow_New(gdk_window_get_toplevel(win)); + if (!strcmp(key, "children")) { + GList *children, *tmp; + PyObject *ret; + children = gdk_window_get_children(win); + ret = PyList_New(0); + for (tmp = children; tmp != NULL; tmp = tmp->next) + PyList_Append(ret, PyGdkWindow_New(tmp->data)); + g_list_free(children); + return ret; + } + if (!strcmp(key, "type")) + return PyInt_FromLong(gdk_window_get_type(win)); + return Py_FindMethod(PyGdkWindow_methods, (PyObject *)self, key); +} + +static PyTypeObject PyGdkWindow_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "GdkWindow", + sizeof(PyGdkWindow_Object), + 0, + (destructor)PyGdkWindow_Dealloc, + (printfunc)0, + (getattrfunc)PyGdkWindow_GetAttr, + (setattrfunc)0, + (cmpfunc)PyGdkWindow_Compare, + (reprfunc)PyGdkWindow_Repr, + 0, + 0, + 0, + (hashfunc)0, + (ternaryfunc)0, + (reprfunc)0, + 0L,0L,0L,0L, + NULL +}; + +static void +PyGdkGC_Dealloc(PyGdkGC_Object *self) { + gdk_gc_unref(self->obj); + PyMem_DEL(self); +} + +static PyObject * +PyGdkGC_GetAttr(PyGdkGC_Object *self, char *key) { + GdkGCValues gc; + + if (!strcmp(key, "__members__")) + return Py_BuildValue("[ssssssssssssssssss]", "background", "cap_style", + "clip_mask", "clip_x_origin", "clip_y_origin", + "fill", "font", "foreground", "function", + "graphics_exposures", "join_style", "line_style", + "line_width", "stipple", "sub_window", "tile", + "ts_x_origin", "ts_y_origin"); + gdk_gc_get_values(self->obj, &gc); + if (!strcmp(key, "foreground")) return PyGdkColor_New(&(gc.foreground)); + if (!strcmp(key, "background")) return PyGdkColor_New(&(gc.background)); + if (!strcmp(key, "font")) return PyGdkFont_New(gc.font); + if (!strcmp(key, "function")) return PyInt_FromLong(gc.function); + if (!strcmp(key, "fill")) return PyInt_FromLong(gc.fill); + if (!strcmp(key, "tile")) { + if (gc.tile != NULL) return PyGdkWindow_New(gc.tile); + Py_INCREF(Py_None); return Py_None; + } + if (!strcmp(key, "stipple")) { + if (gc.stipple != NULL) return PyGdkWindow_New(gc.stipple); + Py_INCREF(Py_None); return Py_None; + } + if (!strcmp(key, "clip_mask")) { + if (gc.clip_mask!=NULL) return PyGdkWindow_New(gc.clip_mask); + Py_INCREF(Py_None); return Py_None; + } + if (!strcmp(key, "subwindow_mode")) + return PyInt_FromLong(gc.subwindow_mode); + if (!strcmp(key, "ts_x_origin")) return PyInt_FromLong(gc.ts_x_origin); + if (!strcmp(key, "ts_y_origin")) return PyInt_FromLong(gc.ts_y_origin); + if (!strcmp(key, "clip_x_origin")) return PyInt_FromLong(gc.clip_x_origin); + if (!strcmp(key, "clip_y_origin")) return PyInt_FromLong(gc.clip_y_origin); + if (!strcmp(key, "graphics_exposures")) + return PyInt_FromLong(gc.graphics_exposures); + if (!strcmp(key, "line_width")) return PyInt_FromLong(gc.line_width); + if (!strcmp(key, "line_style")) return PyInt_FromLong(gc.line_style); + if (!strcmp(key, "cap_style")) return PyInt_FromLong(gc.cap_style); + if (!strcmp(key, "join_style")) return PyInt_FromLong(gc.join_style); + PyErr_SetString(PyExc_AttributeError, key); + return NULL; +} + +static int +PyGdkGC_SetAttr(PyGdkGC_Object *self, char *key, PyObject *value) { + GdkGC *gc = self->obj; + + if (value == NULL) { + PyErr_SetString(PyExc_TypeError, "can't delete attributes"); + return -1; + } + if (PyInt_Check(value)) { + int i = PyInt_AsLong(value); + GdkGCValues v; + gdk_gc_get_values(gc, &v); + if (!strcmp(key, "function")) gdk_gc_set_function(gc, i); + else if (!strcmp(key, "fill")) gdk_gc_set_fill(gc, i); + else if (!strcmp(key, "subwindow_mode")) gdk_gc_set_subwindow(gc, i); + else if (!strcmp(key, "ts_x_origin")) + gdk_gc_set_ts_origin(gc, i, v.ts_y_origin); + else if (!strcmp(key, "ts_y_origin")) + gdk_gc_set_ts_origin(gc, v.ts_x_origin, i); + else if (!strcmp(key, "clip_x_origin")) + gdk_gc_set_clip_origin(gc, i, v.clip_y_origin); + else if (!strcmp(key, "clip_y_origin")) + gdk_gc_set_clip_origin(gc, v.clip_x_origin, i); + else if (!strcmp(key, "graphics_exposures")) gdk_gc_set_exposures(gc, i); + else if (!strcmp(key, "line_width")) + gdk_gc_set_line_attributes(gc, i,v.line_style,v.cap_style,v.join_style); + else if (!strcmp(key, "line_style")) + gdk_gc_set_line_attributes(gc, v.line_width,i,v.cap_style,v.join_style); + else if (!strcmp(key, "cap_style")) + gdk_gc_set_line_attributes(gc, v.line_width,v.line_style,i,v.join_style); + else if (!strcmp(key, "join_style")) + gdk_gc_set_line_attributes(gc, v.line_width,v.line_style,v.cap_style,i); + else { + PyErr_SetString(PyExc_TypeError,"type mismatch"); + return -1; + } + } else if (PyGdkColor_Check(value)) { + GdkColor *c = PyGdkColor_Get(value); + if (!strcmp(key, "foreground")) gdk_gc_set_foreground(gc, c); + else if (!strcmp(key, "background")) gdk_gc_set_background(gc, c); + else { + PyErr_SetString(PyExc_TypeError,"type mismatch"); + return -1; + } + } else if (PyGdkFont_Check(value)) { + if (!strcmp(key, "font")) gdk_gc_set_font(gc, PyGdkFont_Get(value)); + else{ + PyErr_SetString(PyExc_TypeError,"type mismatch"); + return -1; + } + } else if (PyGdkWindow_Check(value) || value == Py_None) { + GdkWindow *w = (value==Py_None)?NULL:PyGdkWindow_Get(value); + if (!strcmp(key, "tile")) gdk_gc_set_tile(gc, w); + else if (!strcmp(key, "stipple")) gdk_gc_set_stipple(gc, w); + else if (!strcmp(key, "clip_mask")) gdk_gc_set_clip_mask(gc, w); + else { + PyErr_SetString(PyExc_TypeError,"type mismatch"); + return -1; + } + } else { + PyErr_SetString(PyExc_TypeError,"type mismatch"); + return -1; + } + return 0; +} + +static int +PyGdkGC_Compare(PyGdkGC_Object *self, PyGdkGC_Object *v) { + if (self->obj == v->obj) return 0; + if (self->obj > v->obj) return -1; + return 1; +} + +static PyTypeObject PyGdkGC_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "GdkGC", + sizeof(PyGdkGC_Object), + 0, + (destructor)PyGdkGC_Dealloc, + (printfunc)0, + (getattrfunc)PyGdkGC_GetAttr, + (setattrfunc)PyGdkGC_SetAttr, + (cmpfunc)PyGdkGC_Compare, + (reprfunc)0, + 0, + 0, + 0, + (hashfunc)0, + (ternaryfunc)0, + (reprfunc)0, + 0L,0L,0L,0L, + NULL +}; + +static void +PyGdkColormap_Dealloc(PyGdkColormap_Object *self) { + gdk_colormap_unref(self->obj); + PyMem_DEL(self); +} + +static PyObject * +PyGdkColor_Alloc(PyGdkColormap_Object *self, PyObject *args) { + GdkColor color = {0, 0, 0, 0}; + gchar *color_name; + if (!PyArg_ParseTuple(args, "iii:GdkColormap.alloc", + &(color.red), &(color.green), &(color.blue))) { + PyErr_Clear(); + if (!PyArg_ParseTuple(args, "s:GdkColormap.alloc", &color_name)) + return NULL; + if (!gdk_color_parse(color_name, &color)) { + PyErr_SetString(PyExc_TypeError, "unable to parse color specification"); + return NULL; + } + } + if (!gdk_color_alloc(self->obj, &color)) { + PyErr_SetString(PyExc_RuntimeError, "couldn't allocate color"); + return NULL; + } + return PyGdkColor_New(&color); +} + +static PyMethodDef PyGdkColormap_methods[] = { + {"alloc", (PyCFunction)PyGdkColor_Alloc, METH_VARARGS, NULL}, + {NULL, 0, 0, NULL} +}; + +static PyObject * +PyGdkColormap_GetAttr(PyObject *self, char *key) { + return Py_FindMethod(PyGdkColormap_methods, self, key); +} + +static int +PyGdkColormap_Compare(PyGdkColormap_Object *self, PyGdkColormap_Object *v) { + if (self->obj == v->obj) return 0; + if (self->obj > v->obj) return -1; + return 1; +} + +static int +PyGdkColormap_Length(PyGdkColormap_Object *self) { + return self->obj->size; +} + +static PyObject * +PyGdkColormap_GetItem(PyGdkColormap_Object *self, int pos) { + if (pos < 0 || pos >= self->obj->size) { + PyErr_SetString(PyExc_IndexError, "index out of range"); + return NULL; + } + return PyGdkColor_New(&(self->obj->colors[pos])); +} + +static PyObject * +PyGdkColormap_GetSlice(PyGdkColormap_Object *self, int lo, int up) { + PyObject *ret; + int i; + + if (lo < 0) lo = 0; + if (up > self->obj->size) up = self->obj->size; + if (up < lo) up = lo; + + ret = PyTuple_New(up - lo); + if (ret == NULL) return NULL; + for (i = lo; i < up; i++) + PyTuple_SetItem(ret, i - lo, PyGdkColor_New(&(self->obj->colors[i]))); + return ret; +} + +static PySequenceMethods PyGdkColormap_Sequence = { + (inquiry)PyGdkColormap_Length, + (binaryfunc)0, + (intargfunc)0, + (intargfunc)PyGdkColormap_GetItem, + (intintargfunc)PyGdkColormap_GetSlice, + (intobjargproc)0, + (intintobjargproc)0 +}; + +static PyTypeObject PyGdkColormap_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "GdkColormap", + sizeof(PyGdkColormap_Object), + 0, + (destructor)PyGdkColormap_Dealloc, + (printfunc)0, + (getattrfunc)PyGdkColormap_GetAttr, + (setattrfunc)0, + (cmpfunc)PyGdkColormap_Compare, + (reprfunc)0, + 0, + &PyGdkColormap_Sequence, + 0, + (hashfunc)0, + (ternaryfunc)0, + (reprfunc)0, + 0L,0L,0L,0L, + NULL +}; + +static void +PyGdkDragContext_Dealloc(PyGdkDragContext_Object *self) { + gdk_drag_context_unref(self->obj); + PyMem_DEL(self); +} + +static int +PyGdkDragContext_Compare(PyGdkDragContext_Object *self, + PyGdkDragContext_Object *v) { + if (self->obj == v->obj) return 0; + if (self->obj > v->obj) return -1; + return 1; +} + +static PyObject * +PyGdkDragContext_GetAttr(PyGdkDragContext_Object *self, char *key) { + if (!strcmp(key, "__members__")) + return Py_BuildValue("[sssssssss]", "action", "actions", "dest_window", + "is_source", "protocol", "source_window", + "start_window", "suggested_action", "targets"); + else if (!strcmp(key, "protocol")) + return PyInt_FromLong(self->obj->protocol); + else if (!strcmp(key, "is_source")) + return PyInt_FromLong(self->obj->is_source); + else if (!strcmp(key, "source_window")) + if (self->obj->source_window) + return PyGdkWindow_New(self->obj->source_window); + else { + Py_INCREF(Py_None); + return Py_None; + } + else if (!strcmp(key, "dest_window")) + if (self->obj->dest_window) + return PyGdkWindow_New(self->obj->dest_window); + else { + Py_INCREF(Py_None); + return Py_None; + } + else if (!strcmp(key, "targets")) { + PyObject *ret = PyList_New(0); + GList *tmp; + for (tmp = self->obj->targets; tmp != NULL; tmp = tmp->next) + PyList_Append(ret, PyGdkAtom_New(GPOINTER_TO_INT(tmp->data))); + return ret; + } else if (!strcmp(key, "actions")) + return PyInt_FromLong(self->obj->actions); + else if (!strcmp(key, "suggested_action")) + return PyInt_FromLong(self->obj->suggested_action); + else if (!strcmp(key, "action")) + return PyInt_FromLong(self->obj->action); + else if (!strcmp(key, "start_time")) + return PyInt_FromLong(self->obj->start_time); + PyErr_SetString(PyExc_AttributeError, key); + return NULL; +} + +static PyTypeObject PyGdkDragContext_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "GdkDragContext", + sizeof(PyGdkDragContext_Object), + 0, + (destructor)PyGdkDragContext_Dealloc, + (printfunc)0, + (getattrfunc)PyGdkDragContext_GetAttr, + (setattrfunc)0, + (cmpfunc)PyGdkDragContext_Compare, + (reprfunc)0, + 0, + 0, + 0, + (hashfunc)0, + (ternaryfunc)0, + (reprfunc)0, + 0L,0L,0L,0L, + NULL +}; + +static void +PyGtkSelectionData_Dealloc(PyGtkSelectionData_Object *self) { + gtk_selection_data_free(self->obj); + PyMem_DEL(self); +} + +static int +PyGtkSelectionData_Compare(PyGtkSelectionData_Object *self, + PyGtkSelectionData_Object *v) { + if (self->obj == v->obj) return 0; + if (self->obj > v->obj) return -1; + return 1; +} + +static PyObject * +PyGtkSelectionData_Set(PyGtkSelectionData_Object *self, PyObject *args) { + GdkAtom type; + int format, length; + guchar *data; + + if (!PyArg_ParseTuple(args, "iis#:GtkSelectionData.set", &type, &format, + &data, &length)) + return NULL; + gtk_selection_data_set(self->obj, type, format, data, length); + Py_INCREF(Py_None); + return Py_None; +} + +static PyMethodDef PyGtkSelectionData_methods[] = { + {"set", (PyCFunction)PyGtkSelectionData_Set, METH_VARARGS, NULL}, + {NULL, 0, 0, NULL} +}; + +static PyObject * +PyGtkSelectionData_GetAttr(PyGtkSelectionData_Object *self, char *key) { + if (!strcmp(key, "__members__")) + return Py_BuildValue("[sssss]", "data", "format", "selection", "target", + "type"); + else if (!strcmp(key, "selection")) + return PyGdkAtom_New(self->obj->selection); + else if (!strcmp(key, "target")) + return PyGdkAtom_New(self->obj->target); + else if (!strcmp(key, "type")) + return PyGdkAtom_New(self->obj->type); + else if (!strcmp(key, "format")) + return PyInt_FromLong(self->obj->format); + else if (!strcmp(key, "data")) + return PyString_FromStringAndSize(self->obj->data, self->obj->length); + return Py_FindMethod(PyGtkSelectionData_methods, (PyObject *)self, key); +} + +static PyTypeObject PyGtkSelectionData_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "GtkSelectionData", + sizeof(PyGtkSelectionData_Object), + 0, + (destructor)PyGtkSelectionData_Dealloc, + (printfunc)0, + (getattrfunc)PyGtkSelectionData_GetAttr, + (setattrfunc)0, + (cmpfunc)PyGtkSelectionData_Compare, + (reprfunc)0, + 0, + 0, + 0, + (hashfunc)0, + (ternaryfunc)0, + (reprfunc)0, + 0L,0L,0L,0L, + NULL +}; + +static void +PyGdkAtom_Dealloc(PyGdkAtom_Object *self) { + if (self->name) g_free(self->name); + PyMem_DEL(self); +} + +static int +PyGdkAtom_Compare(PyGdkAtom_Object *self, PyGdkAtom_Object *v) { + if (self->atom == v->atom) return 0; + if (self->atom > v->atom) return -1; + return 1; +} + +static PyObject * +PyGdkAtom_Repr(PyGdkAtom_Object *self) { + char buf[256]; + if (!self->name) self->name = gdk_atom_name(self->atom); + g_snprintf(buf, 256, "<GdkAtom 0x%lx = '%s'>", (unsigned long)self->atom, + self->name); + return PyString_FromString(buf); +} + +static int +PyGdkAtom_Coerce(PyObject **self, PyObject **other) { + PyGdkAtom_Object *old = (PyGdkAtom_Object *)*self; + if (PyInt_Check(*other)) { + *self = PyInt_FromLong(old->atom); + Py_INCREF(*other); + return 0; + } else if (PyFloat_Check(*other)) { + *self = PyFloat_FromDouble((double)old->atom); + Py_INCREF(*other); + return 0; + } else if (PyLong_Check(*other)) { + *self = PyLong_FromUnsignedLong(old->atom); + Py_INCREF(*other); + return 0; + } else if (PyString_Check(*other)) { + if (!old->name) + old->name = gdk_atom_name(old->atom); + *self = PyString_FromString(old->name); + Py_INCREF(*other); + return 0; + } + return 1; /* don't know how to convert */ +} + +static PyObject * +PyGdkAtom_Int(PyGdkAtom_Object *self) { + return PyInt_FromLong(self->atom); +} + +static PyObject * +PyGdkAtom_Long(PyGdkAtom_Object *self) { + return PyLong_FromUnsignedLong(self->atom); +} + +static PyObject * +PyGdkAtom_Float(PyGdkAtom_Object *self) { + return PyFloat_FromDouble(self->atom); +} + +static PyObject * +PyGdkAtom_Oct(PyGdkAtom_Object *self) { + char buf[100]; + if (self->atom == 0) return PyString_FromString("0"); + g_snprintf(buf, 100, "0%lo", self->atom); + return PyString_FromString(buf); +} + +static PyObject * +PyGdkAtom_Hex(PyGdkAtom_Object *self) { + char buf[100]; + g_snprintf(buf, 100, "0x%lx", self->atom); + return PyString_FromString(buf); +} + +static PyObject * +PyGdkAtom_Str(PyGdkAtom_Object *self) { + if (!self->name) self->name = gdk_atom_name(self->atom); + return PyString_FromString(self->name); +} + +static PyNumberMethods PyGdkAtom_Number = { + (binaryfunc)0, + (binaryfunc)0, + (binaryfunc)0, + (binaryfunc)0, + (binaryfunc)0, + (binaryfunc)0, + (ternaryfunc)0, + (unaryfunc)0, + (unaryfunc)0, + (unaryfunc)0, + (inquiry)0, + (unaryfunc)0, + (binaryfunc)0, + (binaryfunc)0, + (binaryfunc)0, + (binaryfunc)0, + (binaryfunc)0, + (coercion)PyGdkAtom_Coerce, + (unaryfunc)PyGdkAtom_Int, + (unaryfunc)PyGdkAtom_Long, + (unaryfunc)PyGdkAtom_Float, + (unaryfunc)PyGdkAtom_Oct, + (unaryfunc)PyGdkAtom_Hex +}; + +static PyTypeObject PyGdkAtom_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "GdkAtom", + sizeof(PyGdkAtom_Object), + 0, + (destructor)PyGdkAtom_Dealloc, + (printfunc)0, + (getattrfunc)0, + (setattrfunc)0, + (cmpfunc)PyGdkAtom_Compare, + (reprfunc)PyGdkAtom_Repr, + &PyGdkAtom_Number, + 0, + 0, + (hashfunc)0, + (ternaryfunc)0, + (reprfunc)PyGdkAtom_Str, + 0L,0L,0L,0L, + NULL +}; + +static void +PyGdkCursor_Dealloc(PyGdkCursor_Object *self) { + gdk_cursor_destroy(self->obj); + PyMem_DEL(self); +} + +static int +PyGdkCursor_Compare(PyGdkCursor_Object *self, PyGdkCursor_Object *v) { + if (self->obj == v->obj) return 0; + if (self->obj > v->obj) return -1; + return 1; +} + +static PyObject * +PyGdkCursor_Repr(PyGdkCursor_Object *self) { + char buf[256], *cname = NULL; + + if (self->obj->type == GDK_CURSOR_IS_PIXMAP) + cname = "*pixmap*"; + else { + GtkEnumValue *vals = gtk_type_enum_get_values(GTK_TYPE_GDK_CURSOR_TYPE); + while (vals->value_name != NULL && vals->value != self->obj->type) + vals++; + if (vals->value_nick) cname = vals->value_nick; + else cname = "*unknown"; + } + + g_snprintf(buf, 256, "<GdkCursor '%s'>", cname); + return PyString_FromString(buf); +} + +static PyTypeObject PyGdkCursor_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "GdkCursor", + sizeof(PyGdkCursor_Object), + 0, + (destructor)PyGdkCursor_Dealloc, + (printfunc)0, + (getattrfunc)0, + (setattrfunc)0, + (cmpfunc)PyGdkCursor_Compare, + (reprfunc)PyGdkCursor_Repr, + 0, + 0, + 0, + (hashfunc)0, + (ternaryfunc)0, + (reprfunc)0, + 0L,0L,0L,0L, + NULL +}; + +static void PyGtkCTreeNode_Dealloc(PyGtkCTreeNode_Object *self) { + PyMem_DEL(self); +} + +static int PyGtkCTreeNode_Compare(PyGtkCTreeNode_Object *self, + PyGtkCTreeNode_Object *v) { + if (self->node == v->node) return 0; + if (self->node > v->node) return -1; + return 1; +} + +static PyObject *PyGtkCTreeNode_GetAttr(PyGtkCTreeNode_Object *self, + char *key) { + if (!strcmp(key, "__members__")) + return Py_BuildValue("[ssssss]", "children", "expanded", "is_leaf", + "level", "parent", "sibling"); + if (!strcmp(key, "parent")) { + GtkCTreeNode *node = GTK_CTREE_ROW(self->node)->parent; + if (node) + return PyGtkCTreeNode_New(node); + Py_INCREF(Py_None); + return Py_None; + } else if (!strcmp(key, "sibling")) { + GtkCTreeNode *node = GTK_CTREE_ROW(self->node)->sibling; + if (node) + return PyGtkCTreeNode_New(node); + Py_INCREF(Py_None); + return Py_None; + } else if (!strcmp(key, "children")) { + GtkCTreeNode *node = GTK_CTREE_ROW(self->node)->children; + PyObject *ret = PyList_New(0); + while (node) { + PyList_Append(ret, PyGtkCTreeNode_New(node)); + node = GTK_CTREE_ROW(node)->sibling; + } + return ret; + } else if (!strcmp(key, "level")) + return PyInt_FromLong(GTK_CTREE_ROW(self->node)->level); + else if (!strcmp(key, "is_leaf")) + return PyInt_FromLong(GTK_CTREE_ROW(self->node)->is_leaf); + else if (!strcmp(key, "expanded")) + return PyInt_FromLong(GTK_CTREE_ROW(self->node)->expanded); + PyErr_SetString(PyExc_AttributeError, key); + return NULL; +} + +static PyTypeObject PyGtkCTreeNode_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "GtkCTreeNode", + sizeof(PyGtkCTreeNode_Object), + 0, + (destructor)PyGtkCTreeNode_Dealloc, + (printfunc)0, + (getattrfunc)PyGtkCTreeNode_GetAttr, + (setattrfunc)0, + (cmpfunc)PyGtkCTreeNode_Compare, + (reprfunc)0, + 0, + 0, + 0, + (hashfunc)0, + (ternaryfunc)0, + (reprfunc)0, + 0L,0L,0L,0L, + NULL +}; + +/* This file contains routines used to convert GtkArg structures and arrays + * to and from Python objects. This code is used for the callback marshalling + * code, signal handling, and GtkObject properties (gtk_object_[gs]et). + * + * It is collected here, so I don't accidentally reproduce it elsewhere in + * pygtk. */ + +/* destroy notify for PyObject */ +static void PyGtk_DestroyNotify(gpointer data) { + Py_DECREF((PyObject *)data); +} +static void PyGtk_CallbackMarshal(GtkObject *o, gpointer d, int nargs, + GtkArg *args); +static PyObject *GtkArgs_AsTuple(int nparams, GtkArg *args); +static int GtkArgs_FromSequence(GtkArg *args, int nparams, PyObject *seq); + +/* this hash table is used to let these functions know about new boxed + * types (eg. maybe some from GNOME). The functions return TRUE on error */ +typedef PyObject *(*fromargfunc)(gpointer boxed); +typedef int (*toargfunc)(gpointer *boxed, PyObject *obj); +typedef struct { + fromargfunc fromarg; + toargfunc toarg; +} PyGtk_BoxFuncs; +/* keys are GUINT_TO_POINTER(GtkType) */ +static GHashTable *boxed_funcs; + +static void PyGtk_RegisterBoxed(GtkType boxed_type, + fromargfunc fromarg, toargfunc toarg) { + PyGtk_BoxFuncs *fs = g_new(PyGtk_BoxFuncs, 1); + + fs->fromarg = fromarg; + fs->toarg = toarg; + g_hash_table_insert(boxed_funcs, GUINT_TO_POINTER(boxed_type), fs); +} + +#define PyGtk_get_boxed(type) (PyGtk_BoxFuncs *)g_hash_table_lookup( \ + boxed_funcs, GUINT_TO_POINTER(type)) + +/* create a GtkArg from a PyObject, using the GTK_VALUE_* routines. + * returns -1 if it couldn't set the argument. */ +static int GtkArg_FromPyObject(GtkArg *arg, PyObject *obj) { + PyObject *tmp; + switch (GTK_FUNDAMENTAL_TYPE(arg->type)) { + case GTK_TYPE_NONE: + case GTK_TYPE_INVALID: + GTK_VALUE_INT(*arg) = 0; + break; + case GTK_TYPE_BOOL: + if (tmp = PyNumber_Int(obj)) + GTK_VALUE_BOOL(*arg) = (PyInt_AsLong(tmp) != 0); + else + return -1; + Py_DECREF(tmp); + break; + case GTK_TYPE_CHAR: + if (tmp = PyObject_Str(obj)) + GTK_VALUE_CHAR(*arg) = PyString_AsString(tmp)[0]; + else + return -1; + Py_DECREF(tmp); + break; + case GTK_TYPE_ENUM: + if (PyGtkEnum_get_value(arg->type, obj, &(GTK_VALUE_ENUM(*arg)))) + return -1; + break; + case GTK_TYPE_FLAGS: + if (PyGtkFlag_get_value(arg->type, obj, &(GTK_VALUE_FLAGS(*arg)))) + return -1; + break; + case GTK_TYPE_INT: + if (tmp = PyNumber_Int(obj)) + GTK_VALUE_INT(*arg) = PyInt_AsLong(tmp); + else + return -1; + Py_DECREF(tmp); + break; + case GTK_TYPE_UINT: + if (tmp = PyNumber_Int(obj)) + GTK_VALUE_UINT(*arg) = PyInt_AsLong(tmp); + else + return -1; + Py_DECREF(tmp); + break; + case GTK_TYPE_LONG: + if (tmp = PyNumber_Int(obj)) + GTK_VALUE_LONG(*arg) = PyInt_AsLong(tmp); + else + return -1; + Py_DECREF(tmp); + break; + case GTK_TYPE_ULONG: + if (tmp = PyNumber_Int(obj)) + GTK_VALUE_ULONG(*arg) = PyInt_AsLong(tmp); + else + return -1; + Py_DECREF(tmp); + break; + case GTK_TYPE_FLOAT: + if (tmp = PyNumber_Float(obj)) + GTK_VALUE_FLOAT(*arg) = PyFloat_AsDouble(tmp); + else + return -1; + Py_DECREF(tmp); + break; + case GTK_TYPE_STRING: + if (tmp = PyObject_Str(obj)) + GTK_VALUE_STRING(*arg) = PyString_AsString(tmp); + else + return -1; + Py_DECREF(tmp); + break; + case GTK_TYPE_OBJECT: + if (PyGtk_Check(obj)) + GTK_VALUE_OBJECT(*arg) = PyGtk_Get(obj); + else + return -1; + break; + case GTK_TYPE_BOXED: + if (arg->type == GTK_TYPE_ACCEL_GROUP) { + if (PyGtkAccelGroup_Check(obj)) + GTK_VALUE_BOXED(*arg) = PyGtkAccelGroup_Get(obj); + else + return -1; + } else if (arg->type == GTK_TYPE_STYLE) { + if (PyGtkStyle_Check(obj)) + GTK_VALUE_BOXED(*arg) = PyGtkStyle_Get(obj); + else + return -1; + } else if (arg->type == GTK_TYPE_GDK_EVENT) { + if (PyGdkEvent_Check(obj)) + GTK_VALUE_BOXED(*arg) = PyGdkEvent_Get(obj); + else + return -1; + } else if (arg->type == GTK_TYPE_GDK_FONT) { + if (PyGdkFont_Check(obj)) + GTK_VALUE_BOXED(*arg) = PyGdkFont_Get(obj); + else + return -1; + } else if (arg->type == GTK_TYPE_GDK_COLOR) { + if (PyGdkColor_Check(obj)) + GTK_VALUE_BOXED(*arg) = PyGdkColor_Get(obj); + else + return -1; + } else if (arg->type == GTK_TYPE_GDK_WINDOW) { + if (PyGdkWindow_Check(obj)) + GTK_VALUE_BOXED(*arg) = PyGdkWindow_Get(obj); + else + return -1; + } else if (arg->type == GTK_TYPE_GDK_COLORMAP) { + if (PyGdkColormap_Check(obj)) + GTK_VALUE_BOXED(*arg) = PyGdkColormap_Get(obj); + else + return -1; + } else if (arg->type == GTK_TYPE_GDK_DRAG_CONTEXT) { + if (PyGdkDragContext_Check(obj)) + GTK_VALUE_BOXED(*arg) = PyGdkDragContext_Get(obj); + else + return -1; + } else if (arg->type == GTK_TYPE_SELECTION_DATA) { + if (PyGtkSelectionData_Check(obj)) + GTK_VALUE_BOXED(*arg) = PyGtkSelectionData_Get(obj); + else + return -1; + } else if (arg->type == GTK_TYPE_CTREE_NODE) { + if (obj == Py_None) + GTK_VALUE_BOXED(*arg) = NULL; + else if (PyGtkSelectionData_Check(obj)) + GTK_VALUE_BOXED(*arg) = PyGtkSelectionData_Get(obj); + else + return -1; + } else { + PyGtk_BoxFuncs *fs= PyGtk_get_boxed(arg->type); + if (fs && fs->toarg) { + if (fs->toarg(&(GTK_VALUE_BOXED(*arg)), obj)) + return -1; + } else if (PyCObject_Check(obj)) + GTK_VALUE_BOXED(*arg) = PyCObject_AsVoidPtr(obj); + else + return -1; + } + break; + case GTK_TYPE_POINTER: + if (PyCObject_Check(obj)) + GTK_VALUE_BOXED(*arg) = PyCObject_AsVoidPtr(obj); + else + return -1; + break; + case GTK_TYPE_FOREIGN: + Py_INCREF(obj); + GTK_VALUE_FOREIGN(*arg).data = obj; + GTK_VALUE_FOREIGN(*arg).notify = PyGtk_DestroyNotify; + break; + case GTK_TYPE_SIGNAL: + if (PyCallable_Check(obj)) { + Py_INCREF(obj); + GTK_VALUE_SIGNAL(*arg).f = NULL; + GTK_VALUE_SIGNAL(*arg).d = obj; + } else + return -1; + break; + case GTK_TYPE_CALLBACK: + if (PyCallable_Check(obj)) { + Py_INCREF(obj); + GTK_VALUE_CALLBACK(*arg).marshal = + (GtkCallbackMarshal)PyGtk_CallbackMarshal; + GTK_VALUE_CALLBACK(*arg).data = obj; + GTK_VALUE_CALLBACK(*arg).notify = PyGtk_DestroyNotify; + } else + return -1; + break; + case GTK_TYPE_ARGS: + case GTK_TYPE_C_CALLBACK: + fprintf(stderr, "unsupported type"); + g_assert_not_reached(); + return -1; + } + return 0; +} + +/* convert a GtkArg structure to a PyObject, using the GTK_VALUE_* routines. + * conversion is always possible. */ +static PyObject *GtkArg_AsPyObject(GtkArg *arg) { + switch (GTK_FUNDAMENTAL_TYPE(arg->type)) { + case GTK_TYPE_INVALID: + case GTK_TYPE_NONE: + Py_INCREF(Py_None); + return Py_None; + case GTK_TYPE_CHAR: + return PyString_FromStringAndSize(>K_VALUE_CHAR(*arg), 1); + case GTK_TYPE_BOOL: + return PyInt_FromLong(GTK_VALUE_BOOL(*arg)); + case GTK_TYPE_ENUM: + case GTK_TYPE_FLAGS: + case GTK_TYPE_INT: + return PyInt_FromLong(GTK_VALUE_INT(*arg)); + case GTK_TYPE_UINT: + return PyInt_FromLong(GTK_VALUE_UINT(*arg)); + case GTK_TYPE_LONG: + return PyInt_FromLong(GTK_VALUE_LONG(*arg)); + case GTK_TYPE_ULONG: + return PyInt_FromLong(GTK_VALUE_ULONG(*arg)); + case GTK_TYPE_FLOAT: + return PyFloat_FromDouble(GTK_VALUE_FLOAT(*arg)); + case GTK_TYPE_DOUBLE: + return PyFloat_FromDouble(GTK_VALUE_DOUBLE(*arg)); + case GTK_TYPE_STRING: + if (GTK_VALUE_STRING(*arg) != NULL) + return PyString_FromString(GTK_VALUE_STRING(*arg)); + else { + Py_INCREF(Py_None); + return Py_None; + } + case GTK_TYPE_ARGS: + return GtkArgs_AsTuple(GTK_VALUE_ARGS(*arg).n_args, + GTK_VALUE_ARGS(*arg).args); + case GTK_TYPE_OBJECT: + return PyGtk_New(GTK_VALUE_OBJECT(*arg)); + case GTK_TYPE_POINTER: + return PyCObject_FromVoidPtr(GTK_VALUE_POINTER(*arg), NULL); + case GTK_TYPE_BOXED: + if (arg->type == GTK_TYPE_ACCEL_GROUP) + return PyGtkAccelGroup_New(GTK_VALUE_BOXED(*arg)); + else if (arg->type == GTK_TYPE_STYLE) + return PyGtkStyle_New(GTK_VALUE_BOXED(*arg)); + else if (arg->type == GTK_TYPE_GDK_EVENT) + return PyGdkEvent_New(GTK_VALUE_BOXED(*arg)); + else if (arg->type == GTK_TYPE_GDK_FONT) + return PyGdkFont_New(GTK_VALUE_BOXED(*arg)); + else if (arg->type == GTK_TYPE_GDK_COLOR) + return PyGdkColor_New(GTK_VALUE_BOXED(*arg)); + else if (arg->type == GTK_TYPE_GDK_WINDOW) + return PyGdkWindow_New(GTK_VALUE_BOXED(*arg)); + else if (arg->type == GTK_TYPE_GDK_COLORMAP) + return PyGdkColormap_New(GTK_VALUE_BOXED(*arg)); + else if (arg->type == GTK_TYPE_GDK_DRAG_CONTEXT) + return PyGdkDragContext_New(GTK_VALUE_BOXED(*arg)); + else if (arg->type == GTK_TYPE_SELECTION_DATA) + return PyGtkSelectionData_New(GTK_VALUE_BOXED(*arg)); + else if (arg->type == GTK_TYPE_CTREE_NODE) { + if (GTK_VALUE_BOXED(*arg)) + return PyGtkCTreeNode_New(GTK_VALUE_BOXED(*arg)); + Py_INCREF(Py_None); + return Py_None; + } else { + PyGtk_BoxFuncs *fs = PyGtk_get_boxed(arg->type); + if (fs && fs->fromarg) + return fs->fromarg(GTK_VALUE_BOXED(*arg)); + return PyCObject_FromVoidPtr(GTK_VALUE_BOXED(*arg), NULL); + } + case GTK_TYPE_FOREIGN: + Py_INCREF((PyObject *)GTK_VALUE_FOREIGN(*arg).data); + return (PyObject *)GTK_VALUE_FOREIGN(*arg).data; + case GTK_TYPE_CALLBACK: + Py_INCREF((PyObject *)GTK_VALUE_CALLBACK(*arg).data); + return (PyObject *)GTK_VALUE_CALLBACK(*arg).data; + case GTK_TYPE_SIGNAL: + Py_INCREF((PyObject *)GTK_VALUE_SIGNAL(*arg).d); + return (PyObject *)GTK_VALUE_SIGNAL(*arg).d; + default: + g_assert_not_reached(); + break; + } + return NULL; +} + +/* set a GtkArg structure's data from a PyObject, using the GTK_RETLOC_* + * routines. If it can't make the conversion, set the return to a zero + * equivalent. */ +static void GtkRet_FromPyObject(GtkArg *ret, PyObject *py_ret) { + PyObject *tmp; + switch (GTK_FUNDAMENTAL_TYPE(ret->type)) { + case GTK_TYPE_NONE: + case GTK_TYPE_INVALID: + break; + case GTK_TYPE_BOOL: + if (tmp = PyNumber_Int(py_ret)) { + *GTK_RETLOC_BOOL(*ret) = (PyInt_AsLong(tmp) != 0); + Py_DECREF(tmp); + } else + *GTK_RETLOC_BOOL(*ret) = FALSE; + break; + case GTK_TYPE_CHAR: + if (tmp = PyObject_Str(py_ret)) { + *GTK_RETLOC_CHAR(*ret) = PyString_AsString(tmp)[0]; + Py_DECREF(tmp); + } else + *GTK_RETLOC_CHAR(*ret) = '\0'; + break; + case GTK_TYPE_ENUM: + if (PyGtkEnum_get_value(ret->type, py_ret, GTK_RETLOC_ENUM(*ret))) { + PyErr_Clear(); + *GTK_RETLOC_ENUM(*ret) = 0; + } + break; + case GTK_TYPE_FLAGS: + if (PyGtkFlag_get_value(ret->type, py_ret, GTK_RETLOC_FLAGS(*ret))) { + PyErr_Clear(); + *GTK_RETLOC_FLAGS(*ret) = 0; + } + break; + case GTK_TYPE_INT: + if (tmp = PyNumber_Int(py_ret)) { + *GTK_RETLOC_INT(*ret) = PyInt_AsLong(tmp); + Py_DECREF(tmp); + } else + *GTK_RETLOC_INT(*ret) = 0; + break; + case GTK_TYPE_UINT: + if (tmp = PyNumber_Int(py_ret)) { + *GTK_RETLOC_UINT(*ret) = PyInt_AsLong(tmp); + Py_DECREF(tmp); + } else + *GTK_RETLOC_UINT(*ret) = 0; + break; + case GTK_TYPE_LONG: + if (tmp = PyNumber_Int(py_ret)) { + *GTK_RETLOC_LONG(*ret) = PyInt_AsLong(tmp); + Py_DECREF(tmp); + } else + *GTK_RETLOC_LONG(*ret) = 0; + break; + case GTK_TYPE_ULONG: + if (tmp = PyNumber_Int(py_ret)) { + *GTK_RETLOC_ULONG(*ret) = PyInt_AsLong(tmp); + Py_DECREF(tmp); + } else + *GTK_RETLOC_ULONG(*ret) = 0; + break; + case GTK_TYPE_FLOAT: + if (tmp = PyNumber_Float(py_ret)) { + *GTK_RETLOC_FLOAT(*ret) = PyFloat_AsDouble(tmp); + Py_DECREF(tmp); + } else + *GTK_RETLOC_FLOAT(*ret) = 0; + break; + case GTK_TYPE_DOUBLE: + if (tmp = PyNumber_Float(py_ret)) { + *GTK_RETLOC_DOUBLE(*ret) = PyFloat_AsDouble(tmp); + Py_DECREF(tmp); + } else + *GTK_RETLOC_DOUBLE(*ret) = 0; + break; + case GTK_TYPE_STRING: + if (tmp = PyObject_Str(py_ret)) { + *GTK_RETLOC_STRING(*ret) = g_strdup(PyString_AsString(py_ret)); + Py_DECREF(tmp); + } else + *GTK_RETLOC_STRING(*ret) = NULL; + break; + case GTK_TYPE_OBJECT: + if (PyGtk_Check(py_ret)) + *GTK_RETLOC_OBJECT(*ret) = PyGtk_Get(py_ret); + else + *GTK_RETLOC_OBJECT(*ret) = NULL; + break; + case GTK_TYPE_BOXED: + if (ret->type == GTK_TYPE_ACCEL_GROUP) { + if (PyGtkAccelGroup_Check(py_ret)) + *GTK_RETLOC_BOXED(*ret) = PyGtkAccelGroup_Get(py_ret); + else + *GTK_RETLOC_BOXED(*ret) = NULL; + } else if (ret->type == GTK_TYPE_STYLE) { + if (PyGtkStyle_Check(py_ret)) + *GTK_RETLOC_BOXED(*ret) = PyGtkStyle_Get(py_ret); + else + *GTK_RETLOC_BOXED(*ret) = NULL; + } else if (ret->type == GTK_TYPE_GDK_EVENT) { + if (PyGdkEvent_Check(py_ret)) + *GTK_RETLOC_BOXED(*ret) = PyGdkEvent_Get(py_ret); + else + *GTK_RETLOC_BOXED(*ret) = NULL; + } else if (ret->type == GTK_TYPE_GDK_FONT) { + if (PyGdkFont_Check(py_ret)) + *GTK_RETLOC_BOXED(*ret) = PyGdkFont_Get(py_ret); + else + *GTK_RETLOC_BOXED(*ret) = NULL; + } else if (ret->type == GTK_TYPE_GDK_COLOR) { + if (PyGdkColor_Check(py_ret)) + *GTK_RETLOC_BOXED(*ret) = PyGdkColor_Get(py_ret); + else + *GTK_RETLOC_BOXED(*ret) = NULL; + } else if (ret->type == GTK_TYPE_GDK_WINDOW) { + if (PyGdkWindow_Check(py_ret)) + *GTK_RETLOC_BOXED(*ret) = PyGdkWindow_Get(py_ret); + else + *GTK_RETLOC_BOXED(*ret) = NULL; + } else if (ret->type == GTK_TYPE_GDK_COLORMAP) { + if (PyGdkColormap_Check(py_ret)) + *GTK_RETLOC_BOXED(*ret) = PyGdkColormap_Get(py_ret); + else + *GTK_RETLOC_BOXED(*ret) = NULL; + } else if (ret->type == GTK_TYPE_GDK_DRAG_CONTEXT) { + if (PyGdkDragContext_Check(py_ret)) + *GTK_RETLOC_BOXED(*ret) = PyGdkDragContext_Get(py_ret); + else + *GTK_RETLOC_BOXED(*ret) = NULL; + } else if (ret->type == GTK_TYPE_SELECTION_DATA) { + if (PyGtkSelectionData_Check(py_ret)) + *GTK_RETLOC_BOXED(*ret) = PyGtkSelectionData_Get(py_ret); + else + *GTK_RETLOC_BOXED(*ret) = NULL; + } else if (ret->type == GTK_TYPE_CTREE_NODE) { + if (PyGtkSelectionData_Check(py_ret)) + *GTK_RETLOC_BOXED(*ret) = PyGtkCTreeNode_Get(py_ret); + else + *GTK_RETLOC_BOXED(*ret) = NULL; + } else { + PyGtk_BoxFuncs *fs = PyGtk_get_boxed(ret->type); + if (fs && fs->toarg) { + if (fs->toarg(GTK_RETLOC_BOXED(*ret), py_ret)) + *GTK_RETLOC_BOXED(*ret) = NULL; + } else + if (PyCObject_Check(py_ret)) + *GTK_RETLOC_BOXED(*ret) = PyCObject_AsVoidPtr(py_ret); + else + *GTK_RETLOC_BOXED(*ret) = NULL; + } + break; + case GTK_TYPE_POINTER: + if (PyCObject_Check(py_ret)) + *GTK_RETLOC_POINTER(*ret) = PyCObject_AsVoidPtr(py_ret); + else + *GTK_RETLOC_POINTER(*ret) = NULL; + default: + g_assert_not_reached(); + break; + } +} + +/* convert a GtkArg structure to a PyObject, using the GTK_RETLOC_* routines. + * conversion is always possible. */ +static PyObject *GtkRet_AsPyObject(GtkArg *arg) { + switch (GTK_FUNDAMENTAL_TYPE(arg->type)) { + case GTK_TYPE_INVALID: + case GTK_TYPE_NONE: + Py_INCREF(Py_None); + return Py_None; + case GTK_TYPE_CHAR: + return PyString_FromStringAndSize(GTK_RETLOC_CHAR(*arg), 1); + case GTK_TYPE_BOOL: + return PyInt_FromLong(*GTK_RETLOC_BOOL(*arg)); + case GTK_TYPE_ENUM: + case GTK_TYPE_FLAGS: + case GTK_TYPE_INT: + return PyInt_FromLong(*GTK_RETLOC_INT(*arg)); + case GTK_TYPE_UINT: + return PyInt_FromLong(*GTK_RETLOC_UINT(*arg)); + case GTK_TYPE_LONG: + return PyInt_FromLong(*GTK_RETLOC_LONG(*arg)); + case GTK_TYPE_ULONG: + return PyInt_FromLong(*GTK_RETLOC_ULONG(*arg)); + case GTK_TYPE_FLOAT: + return PyFloat_FromDouble(*GTK_RETLOC_FLOAT(*arg)); + case GTK_TYPE_DOUBLE: + return PyFloat_FromDouble(*GTK_RETLOC_DOUBLE(*arg)); + case GTK_TYPE_STRING: + if (*GTK_RETLOC_STRING(*arg) != NULL) + return PyString_FromString(*GTK_RETLOC_STRING(*arg)); + else { + Py_INCREF(Py_None); + return Py_None; + } + case GTK_TYPE_ARGS: + break; + case GTK_TYPE_OBJECT: + return PyGtk_New(*GTK_RETLOC_OBJECT(*arg)); + case GTK_TYPE_POINTER: + return PyCObject_FromVoidPtr(*GTK_RETLOC_POINTER(*arg), NULL); + case GTK_TYPE_BOXED: + if (arg->type == GTK_TYPE_ACCEL_GROUP) + return PyGtkAccelGroup_New(*GTK_RETLOC_BOXED(*arg)); + else if (arg->type == GTK_TYPE_STYLE) + return PyGtkStyle_New(*GTK_RETLOC_BOXED(*arg)); + else if (arg->type == GTK_TYPE_GDK_EVENT) + return PyGdkEvent_New(*GTK_RETLOC_BOXED(*arg)); + else if (arg->type == GTK_TYPE_GDK_FONT) + return PyGdkFont_New(*GTK_RETLOC_BOXED(*arg)); + else if (arg->type == GTK_TYPE_GDK_COLOR) + return PyGdkColor_New(*GTK_RETLOC_BOXED(*arg)); + else if (arg->type == GTK_TYPE_GDK_WINDOW) + return PyGdkWindow_New(*GTK_RETLOC_BOXED(*arg)); + else if (arg->type == GTK_TYPE_GDK_COLORMAP) + return PyGdkColormap_New(*GTK_RETLOC_BOXED(*arg)); + else if (arg->type == GTK_TYPE_GDK_DRAG_CONTEXT) + return PyGdkDragContext_New(*GTK_RETLOC_BOXED(*arg)); + else if (arg->type == GTK_TYPE_SELECTION_DATA) + return PyGtkSelectionData_New(*GTK_RETLOC_BOXED(*arg)); + else if (arg->type == GTK_TYPE_CTREE_NODE) { + if (*GTK_RETLOC_BOXED(*arg)) + return PyGtkCTreeNode_New(*GTK_RETLOC_BOXED(*arg)); + Py_INCREF(Py_None); + return Py_None; + } else { + PyGtk_BoxFuncs *fs = PyGtk_get_boxed(arg->type); + if (fs && fs->fromarg) + return fs->fromarg(*GTK_RETLOC_BOXED(*arg)); + return PyCObject_FromVoidPtr(*GTK_RETLOC_BOXED(*arg), NULL); + } + default: + g_assert_not_reached(); + break; + } + return NULL; +} + +/* convert the GtkArg array ARGS to a python tuple */ +static PyObject *GtkArgs_AsTuple(int nparams, GtkArg *args) { + PyObject *tuple, *item; + int i; + + tuple = PyTuple_New(nparams); + for (i = 0; i < nparams; i++) { + item = GtkArg_AsPyObject(&args[i]); + if (item == NULL) { + Py_INCREF(Py_None); + item = Py_None; + } + PyTuple_SetItem(tuple, i, item); + } + return tuple; +} + +/* converts a Python sequence to a GtkArg array. Returns -1 if the sequence + * doesn't match the specification in ARGS */ +static int GtkArgs_FromSequence(GtkArg *args, int nparams, PyObject *seq) { + PyObject *item; + int i; + if (!PySequence_Check(seq)) + return -1; + for (i = 0; i < nparams; i++) { + item = PySequence_GetItem(seq, i); + if (GtkArg_FromPyObject(&args[i], item)) { + gchar buf[512]; + if (args[i].name == NULL) + g_snprintf(buf, 511, "argument %d: expected %s, %s found", i+1, + gtk_type_name(args[i].type), item->ob_type->tp_name); + else + g_snprintf(buf, 511, "argument %s: expected %s, %s found", + args[i].name, gtk_type_name(args[i].type), + item->ob_type->tp_name); + PyErr_SetString(PyExc_TypeError, buf); + return -1; + } + } + return 0; +} + +/* generic callback marshal */ +static void PyGtk_CallbackMarshal(GtkObject *o, gpointer data, int nargs, + GtkArg *args) { + PyObject *func = data, *ret, *a, *params; + + a = GtkArgs_AsTuple(nargs, args); + if (a == NULL) { + PyErr_Clear(); + fprintf(stderr, "can't decode params -- callback not run\n"); + return; + } + if (o == NULL) + params = a; + else { + /* prepend object to argument list */ + ret = PyTuple_New(1); + PyTuple_SetItem(ret, 0, PyGtk_New(o)); + params = PySequence_Concat(ret, a); + Py_DECREF(ret); Py_DECREF(a); + } + ret = PyObject_CallObject(func, params); + Py_DECREF(params); + if (ret == NULL) { + PyErr_Print(); + PyErr_Clear(); + return; + } + GtkRet_FromPyObject(&args[nargs], ret); + Py_DECREF(ret); +} + + + +static +void PyGtk_SignalMarshal(GtkObject *object, /*gpointer*/ PyObject *func, + int nparams, GtkArg *args, GtkType *arg_types, + GtkType return_type) { + PyObject *arg_list, *params, *ret; + + ret = PyTuple_New(1); + PyTuple_SetItem(ret, 0, PyGtk_New(object)); + arg_list = GtkArgs_AsTuple(nparams, args); + params = PySequence_Concat(ret, arg_list); + Py_DECREF(ret); + Py_DECREF(arg_list); + if (PyTuple_Check(func)) { /* extra arguments given with func */ + arg_list = PyTuple_GetItem(func, 1); + func = PyTuple_GetItem(func, 0); + if (PyTuple_Check(arg_list)) { + ret = params; + params = PySequence_Concat(ret, arg_list); + Py_DECREF(ret); + } + } + ret = PyObject_CallObject(func, params); + Py_DECREF(params); + + if (ret == NULL) { + PyErr_Print(); + PyErr_Clear(); + return; + } + GtkRet_FromPyObject(&args[nparams], ret); + Py_DECREF(ret); +} + +static +void PyGtk_SignalDestroy(/*gpointer*/ PyObject *func) { + Py_DECREF(func); +} + +/* simple callback handler -- this one actually looks at the return type */ +/* used for timeout and idle functions */ +static void PyGtk_HandlerMarshal(gpointer a, PyObject *func, int nargs, + GtkArg *args) { + PyObject *ret; + + ret = PyObject_CallObject(func, NULL); + if (ret == NULL) { + PyErr_Print(); + PyErr_Clear(); + *GTK_RETLOC_BOOL(args[0]) = FALSE; + return; + } + if (ret == Py_None || (PyInt_Check(ret) && PyInt_AsLong(ret) == 0)) + *GTK_RETLOC_BOOL(args[0]) = FALSE; + else + *GTK_RETLOC_BOOL(args[0]) = TRUE; + Py_DECREF(ret); +} + +/* callback for input handlers */ +static void PyGtk_InputMarshal(gpointer a, PyObject *func, int nargs, + GtkArg *args) { + PyObject *tuple, *ret; + + tuple = Py_BuildValue("(ii)", GTK_VALUE_INT(args[0]), + GTK_VALUE_FLAGS(args[1])); + ret = PyObject_CallObject(func, tuple); + Py_DECREF(tuple); + if (ret == NULL) { + PyErr_Print(); + PyErr_Clear(); + } else + Py_DECREF(ret); +} + +static GtkArg *PyDict_AsGtkArgs(PyObject *dict, GtkType type, gint *nargs) { + PyObject *key, *item; + gint i = 0, pos; + GtkArg *arg; + GtkArgInfo *info; + gchar *err, buf[128]; + + gtk_type_class(type); /* initialise the class structure (and setup args) */ + *nargs = PyDict_Size(dict); + arg = g_new(GtkArg, *nargs); + pos = 0; + while (PyDict_Next(dict, &i, &key, &item)) { + if (!PyString_Check(key)) { + PyErr_SetString(PyExc_TypeError,"dictionary keys must be strings"); + g_free(arg); + return NULL; + } + arg[pos].name = PyString_AsString(key); + err = gtk_object_arg_get_info(type, arg[pos].name, &info); + if (info == NULL) { + PyErr_SetString(PyExc_TypeError, err); + g_free(err); + g_free(arg); + return NULL; + } + arg[pos].type = info->type; + arg[pos].name = info->name; + if (GtkArg_FromPyObject(&(arg[pos]), item)) { + g_snprintf(buf, 255, "arg %s: expected type %s, found %s", + arg[pos].name, gtk_type_name(arg[pos].type), + item->ob_type->tp_name); + PyErr_SetString(PyExc_TypeError, buf); + g_free(arg); + return NULL; + } + pos++; + } + return arg; +} + +static void PyGtk_object_set(GtkObject *o, PyObject *dict) { + int i = 0; + PyObject *key, *item; + char *name, *err; + GtkType obtype; + GtkArg arg; + GtkArgInfo *info; + + obtype = GTK_OBJECT_TYPE(o); + + while (PyDict_Next(dict, &i, &key, &item)) { + if (!PyString_Check(key)) { + fprintf(stderr, "Key not a string\n"); + continue; + } + name = PyString_AsString(key); + err = gtk_object_arg_get_info(obtype, name, &info); + if (info == NULL) { + fprintf(stderr, err); + g_free(err); + continue; + } + + arg.type = info->type; + arg.name = info->name; + if (GtkArg_FromPyObject(&arg, item)) { + fprintf(stderr, "%s: expected %s, %s found\n", name, + gtk_type_name(arg.type), item->ob_type->tp_name); + continue; + } + gtk_object_setv(o, 1, &arg); + } +} + +static GtkArg *PyDict_AsContainerArgs(PyObject *dict,GtkType type,gint *nargs){ + PyObject *key, *item; + gint i = 0, pos; + GtkArg *arg; + GtkArgInfo *info; + gchar *err, buf[128]; + + *nargs = PyDict_Size(dict); + arg = g_new(GtkArg, *nargs); + pos = 0; + while (PyDict_Next(dict, &i, &key, &item)) { + if (!PyString_Check(key)) { + PyErr_SetString(PyExc_TypeError,"dictionary keys must be strings"); + g_free(arg); + return NULL; + } + arg[pos].name = PyString_AsString(key); + err = gtk_container_child_arg_get_info(type, arg[pos].name, &info); + if (info == NULL) { + PyErr_SetString(PyExc_TypeError, err); + g_free(err); + g_free(arg); + return NULL; + } + arg[pos].type = info->type; + arg[pos].name = info->name; + if (GtkArg_FromPyObject(&(arg[pos]), item)) { + g_snprintf(buf, 255, "arg %s: expected type %s, found %s", + arg[pos].name, gtk_type_name(arg[pos].type), + item->ob_type->tp_name); + PyErr_SetString(PyExc_TypeError, buf); + g_free(arg); + return NULL; + } + pos++; + } + return arg; +} + +static PyObject *_wrap_gtk_signal_connect(PyObject *self, PyObject *args) { + PyGtk_Object *obj; + char *name; + PyObject *func, *extra = NULL; + int signum; + + if (!PyArg_ParseTuple(args, "O!sO|O!:gtk_signal_connect", &PyGtk_Type, + &obj, &name, &func, &PyTuple_Type, &extra)) + return NULL; + if (!PyCallable_Check(func)) { + PyErr_SetString(PyExc_TypeError, "third argument must be callable"); + return NULL; + } + Py_INCREF(func); + if (extra) { + PyObject *tmp; + tmp = PyTuple_New(2); + PyTuple_SetItem(tmp, 0, func); + Py_INCREF(extra); + PyTuple_SetItem(tmp, 1, extra); + func = tmp; + } + signum = gtk_signal_connect(PyGtk_Get(obj), name, NULL, func); + return PyInt_FromLong(signum); +} + +static PyObject *_wrap_gtk_signal_connect_after(PyObject *self, PyObject *args) { + PyGtk_Object *obj; + char *name; + PyObject *func, *extra = NULL; + int signum; + + if (!PyArg_ParseTuple(args, "O!sO|O!:gtk_signal_connect_after", + &PyGtk_Type, &obj, &name, &func, &PyTuple_Type, &extra)) + return NULL; + if (!PyCallable_Check(func)) { + PyErr_SetString(PyExc_TypeError, "third argument must be callable"); + return NULL; + } + Py_INCREF(func); + if (extra) { + PyObject *tmp; + tmp = PyTuple_New(2); + PyTuple_SetItem(tmp, 0, func); + Py_INCREF(extra); + PyTuple_SetItem(tmp, 1, extra); + func = tmp; + } + signum = gtk_signal_connect_after(PyGtk_Get(obj), name, NULL, func); + return PyInt_FromLong(signum); +} + +static PyObject *_wrap_gtk_signal_disconnect_by_data(PyObject *self, PyObject *args) { + PyObject *obj; + PyObject *data; + + self = self; + if(!PyArg_ParseTuple(args,"O!O:gtk_signal_disconnect_by_data", + &PyGtk_Type, &obj, &data)) + return NULL; + gtk_signal_disconnect_by_data(PyGtk_Get(obj), data); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_signal_handler_block_by_data(PyObject *self, PyObject *args) { + PyObject *obj; + PyObject *data; + + if(!PyArg_ParseTuple(args,"O!O:gtk_signal_handler_block_by_data", + &PyGtk_Type, &obj, &data)) + return NULL; + gtk_signal_handler_block_by_data(PyGtk_Get(obj), data); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_signal_handler_unblock_by_data(PyObject *self, PyObject *args) { + PyObject *obj; + PyObject *data; + + if(!PyArg_ParseTuple(args,"O!O:gtk_signal_handler_unblock_by_data", + &PyGtk_Type, &obj, &data)) + return NULL; + gtk_signal_handler_unblock_by_data(PyGtk_Get(obj), data); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_signal_emitv_by_name(PyObject *self, PyObject *args) { + guint signal_id, i, nparams; + GtkSignalQuery *query; + GtkArg *params; + PyObject *obj, *py_params; + gchar *name, buf[sizeof(GtkArg)]; /* large enough to hold any return value */ + + if (!PyArg_ParseTuple(args, "O!sO:gtk_signal_emitv_by_name", &PyGtk_Type, + &obj, &name, &py_params)) + return NULL; + if (!PySequence_Check(py_params)) { + PyErr_SetString(PyExc_TypeError, "third argument not a sequence"); + return NULL; + } + + signal_id = gtk_signal_lookup(name, GTK_OBJECT_TYPE(PyGtk_Get(obj))); + if (signal_id <= 0) { + PyErr_SetString(PyExc_KeyError, "can't find signal in classes ancestry"); + return NULL; + } + query = gtk_signal_query(signal_id); + params = g_new(GtkArg, query->nparams + 1); + nparams = query->nparams; + for (i = 0; i < nparams; i++) { + params[i].type = query->params[i]; + params[i].name = NULL; + } + params[i].type = query->return_val; + params[i].name = NULL; + params[i].d.pointer_data = buf; /* buffer to hold return value */ + g_free(query); + if (GtkArgs_FromSequence(params, query->nparams, py_params)) { + g_free(params); + return NULL; + } + gtk_signal_emitv(PyGtk_Get(obj), signal_id, params); + obj = GtkRet_AsPyObject(¶ms[nparams]); + g_free(params); + if (obj == NULL) { Py_INCREF(Py_None); obj = Py_None; } + return obj; +} + +static PyObject * _wrap_gtk_init(PyObject *self, PyObject *args) { + PyObject *av; + int argc, i; + char **argv; + + /* ensure that this procedure only gets run once */ + static int run_already = 0; + if (run_already) { + Py_INCREF(Py_None); + return Py_None; + } + run_already = 1; + + if (!PyArg_ParseTuple(args, ":gtk_init")) + return NULL; + + av = PySys_GetObject("argv"); + argc = PyList_Size(av); + argv = malloc(argc * sizeof(char *)); + for (i = 0; i < argc; i++) + argv[i] = strdup(PyString_AsString(PyList_GetItem(av, i))); + + gtk_init(&argc, &argv); + PySys_SetArgv(argc, argv); + + if (argv != NULL) { + for (i = 0; i < argc; i++) + if (argv[i] != NULL) + free(argv[i]); + free(argv); + } + gtk_signal_set_funcs((GtkSignalMarshal)PyGtk_SignalMarshal, + (GtkSignalDestroy)PyGtk_SignalDestroy); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_main_iteration(PyObject *self, PyObject *args) { + int block = 1; + + if(!PyArg_ParseTuple(args,"|i:gtk_main_iteration", &block)) + return NULL; + return PyInt_FromLong(gtk_main_iteration_do(block)); +} + +static PyObject * +_wrap_gtk_timeout_add(PyObject *self, PyObject *args) { + guint32 interval; + PyObject *callback; + if (!PyArg_ParseTuple(args, "iO:gtk_timeout_add", &interval, &callback)) + return NULL; + if (!PyCallable_Check(callback)) { + PyErr_SetString(PyExc_TypeError, "second arg not callable"); + return NULL; + } + Py_INCREF(callback); + return PyInt_FromLong(gtk_timeout_add_interp(interval, + (GtkCallbackMarshal)PyGtk_HandlerMarshal, callback, + (GtkDestroyNotify)PyGtk_DestroyNotify)); +} + +static PyObject * +_wrap_gtk_idle_add(PyObject *self, PyObject *args) { + PyObject *callback; + if (!PyArg_ParseTuple(args, "O:gtk_idle_add", &callback)) + return NULL; + if (!PyCallable_Check(callback)) { + PyErr_SetString(PyExc_TypeError, "arg not callable"); + return NULL; + } + Py_INCREF(callback); + return PyInt_FromLong(gtk_idle_add_interp( + (GtkCallbackMarshal)PyGtk_HandlerMarshal, callback, + (GtkDestroyNotify)PyGtk_DestroyNotify)); +} + +static PyObject * +_wrap_gtk_idle_add_priority(PyObject *self, PyObject *args) { + int p; + PyObject *callback; + if (!PyArg_ParseTuple(args, "iO:gtk_idle_add_priority", &p, &callback)) + return NULL; + if (!PyCallable_Check(callback)) { + PyErr_SetString(PyExc_TypeError, "2nd arg not callable"); + return NULL; + } + Py_INCREF(callback); + return PyInt_FromLong(gtk_idle_add_full(p, NULL, + (GtkCallbackMarshal)PyGtk_HandlerMarshal, callback, + (GtkDestroyNotify)PyGtk_DestroyNotify)); +} + +static PyObject *_wrap_gtk_idle_remove_function(PyObject *self, PyObject *args) { + PyObject *data; + + if(!PyArg_ParseTuple(args,"O:gtk_idle_remove_function", &data)) + return NULL; + gtk_idle_remove_by_data(data); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +_wrap_gtk_quit_add(PyObject *self, PyObject *args) { + int main_level; + PyObject *callback; + if (!PyArg_ParseTuple(args, "iO:gtk_quit_add", &main_level, &callback)) + return NULL; + if (!PyCallable_Check(callback)) { + PyErr_SetString(PyExc_TypeError, "2nd arg not callable"); + return NULL; + } + Py_INCREF(callback); + return PyInt_FromLong(gtk_quit_add_full(main_level, NULL, + (GtkCallbackMarshal)PyGtk_HandlerMarshal, callback, + (GtkDestroyNotify)PyGtk_DestroyNotify)); +} + +static PyObject *_wrap_gtk_quit_remove_function(PyObject *self, PyObject *args) { + PyObject *data; + + if(!PyArg_ParseTuple(args,"O:gtk_quit_remove_function",&data)) + return NULL; + gtk_quit_remove_by_data(data); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +_wrap_gtk_input_add(PyObject *self, PyObject *args) { + int source; + GdkInputCondition condition; + PyObject *callback; + if (!PyArg_ParseTuple(args, "iiO:gtk_input_add", &source, &condition, + &callback)) + return NULL; + if (!PyCallable_Check(callback)) { + PyErr_SetString(PyExc_TypeError, "3rd arg not callable."); + return NULL; + } + Py_INCREF(callback); + return PyInt_FromLong(gtk_input_add_full(source, condition, NULL, + (GtkCallbackMarshal)PyGtk_InputMarshal, callback, + (GtkDestroyNotify)PyGtk_DestroyNotify)); +} + +static PyObject *_wrap_gtk_object_set(PyObject *self, PyObject *args) { + PyObject *obj, *dict; + GtkArg *arg; + gint nargs; + + if (!PyArg_ParseTuple(args, "O!O!:gtk_object_set", &PyGtk_Type, &obj, + &PyDict_Type, &dict)) + return NULL; + arg = PyDict_AsGtkArgs(dict, GTK_OBJECT_TYPE(PyGtk_Get(obj)), &nargs); + if (arg == NULL && nargs != 0) + return NULL; + gtk_object_setv(PyGtk_Get(obj), nargs, arg); + g_free(arg); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_object_new(PyObject *self, PyObject *args) { + GtkType type; + gint nargs, i; + GtkArg *arg; + PyObject *dict; + GtkObject *obj; + + if (!PyArg_ParseTuple(args, "iO!:gtk_object_new", &type, &PyDict_Type, + &dict)) + return NULL; + arg = PyDict_AsGtkArgs(dict, type, &nargs); + if (arg == NULL && nargs != 0) + return NULL; + obj = gtk_object_newv(type, nargs, arg); + g_free(arg); + return PyGtk_New(obj); +} + +static PyObject *_wrap_gtk_object_get(PyObject *self, PyObject *args) { + PyGtk_Object *o; + char *name; + GtkArg garg; + PyObject *ret; + + if (!PyArg_ParseTuple(args, "O!s:gtk_object_get", &PyGtk_Type, &o, &name)) + return NULL; + garg.name = name; + gtk_object_getv(PyGtk_Get(o), 1, &garg); + + if (garg.type == GTK_TYPE_INVALID) { + PyErr_SetString(PyExc_AttributeError, "invalid property"); + return NULL; + } + ret = GtkArg_AsPyObject(&garg); + if (ret == NULL) { + PyErr_SetString(PyExc_TypeError, "couldn't translate type"); + return NULL; + } + return ret; +} + +static PyObject *_wrap_gtk_object_set_data(PyObject *self, PyObject *args) { + PyGtk_Object *obj; + char *key; + PyObject *data; + if (!PyArg_ParseTuple(args, "O!sO:gtk_object_set_data", &PyGtk_Type, + &obj, &key, &data)) + return NULL; + Py_INCREF(data); + gtk_object_set_data_full(PyGtk_Get(obj), key, data, + (GtkDestroyNotify)PyGtk_DestroyNotify); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_object_get_data(PyObject *self, PyObject *args) { + PyGtk_Object *obj; + char *key; + PyObject *data; + if (!PyArg_ParseTuple(args, "O!s:gtk_object_get_data", &PyGtk_Type, + &obj, &key)) + return NULL; + data = gtk_object_get_data(PyGtk_Get(obj), key); + if (data != NULL) { + Py_INCREF(data); + return data; + } else { + Py_INCREF(Py_None); + return Py_None; + } +} + +static PyObject *_wrap_gtk_object_remove_data(PyObject *self, PyObject *args) { + char *key; + PyObject *obj; + + if(!PyArg_ParseTuple(args,"O!s:gtk_object_remove_data", &PyGtk_Type, + &obj, &key)) + return NULL; + gtk_object_remove_data(PyGtk_Get(obj), key); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_widget_get_window(PyObject *self, PyObject *args) { + GdkWindow *win; + PyObject *obj; + + if(!PyArg_ParseTuple(args,"O!:gtk_widget_get_window", &PyGtk_Type, &obj)) + return NULL; + win = GTK_WIDGET(PyGtk_Get(obj))->window; + if (win == NULL) { + Py_INCREF(Py_None); + return Py_None; + } else + return PyGdkWindow_New(win); +} + +static PyObject *_wrap_gtk_widget_draw(PyObject *self, PyObject *args) { + GdkRectangle rect; + PyObject *obj; + + if (!PyArg_ParseTuple(args,"O!(iiii):gtk_widget_draw", &PyGtk_Type, &obj, + &(rect.x), &(rect.y), &(rect.width), &(rect.height))) + return NULL; + gtk_widget_draw(GTK_WIDGET(PyGtk_Get(obj)), &rect); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_widget_size_request(PyObject *self, PyObject *args) { + GtkRequisition requisition; + PyObject *obj; + + if(!PyArg_ParseTuple(args,"O!:gtk_widget_size_request", &PyGtk_Type, &obj)) + return NULL; + gtk_widget_size_request(GTK_WIDGET(PyGtk_Get(obj)), &requisition); + return Py_BuildValue("(ii)", requisition.width, requisition.height); +} + +static PyObject *_wrap_gtk_widget_size_allocate(PyObject *self, PyObject *args) { + GtkAllocation allocation; + PyObject *obj; + + if(!PyArg_ParseTuple(args,"O!(ii):gtk_widget_size_allocate", &PyGtk_Type, + &obj, &(allocation.x), &(allocation.y))) + return NULL; + gtk_widget_size_allocate(GTK_WIDGET(PyGtk_Get(obj)), &allocation); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_widget_intersect(PyObject *self, PyObject *args) { + PyObject *obj; + GdkRectangle area; + GdkRectangle intersect; + + if(!PyArg_ParseTuple(args,"O!(iiii):gtk_widget_intersect", &PyGtk_Type, + &obj, &(area.x), &(area.y), &(area.width), + &(area.height))) + return NULL; + if (gtk_widget_intersect(GTK_WIDGET(PyGtk_Get(obj)), &area, &intersect)) + return Py_BuildValue("(iiii)", intersect.x, intersect.y, + intersect.width, intersect.height); + else { + Py_INCREF(Py_None); + return Py_None; + } +} + +static PyObject *_wrap_gtk_widget_get_pointer(PyObject *self, PyObject *args) { + int x, y; + PyObject *w; + if (!PyArg_ParseTuple(args, "O!:gtk_widget_get_pointer", &PyGtk_Type, &w)) + return NULL; + gtk_widget_get_pointer(GTK_WIDGET(PyGtk_Get(w)), &x, &y); + return Py_BuildValue("(ii)", x, y); +} + +static PyObject *_wrap_gtk_container_add(PyObject *self, PyObject *args) { + PyObject *obj, *child, *dict = NULL; + + if(!PyArg_ParseTuple(args,"O!O!|O!:gtk_container_add", &PyGtk_Type, &obj, + &PyGtk_Type, &child, &PyDict_Type, &dict)) + return NULL; + if (dict == NULL) + gtk_container_add(GTK_CONTAINER(PyGtk_Get(obj)), + GTK_WIDGET(PyGtk_Get(child))); + else { + gint nargs; + GtkArg *arg = PyDict_AsContainerArgs(dict, + GTK_OBJECT_TYPE(PyGtk_Get(obj)), + &nargs); + if (arg == NULL && nargs != 0) + return NULL; + gtk_container_addv(GTK_CONTAINER(PyGtk_Get(obj)), + GTK_WIDGET(PyGtk_Get(child)), nargs, arg); + g_free(arg); + } + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_container_child_set(PyObject *self, PyObject *args){ + PyObject *obj, *child, *dict; + gint nargs; + GtkArg *arg; + + if (!PyArg_ParseTuple(args, "O!O!O!:gtk_container_child_set", &PyGtk_Type, + &obj, &PyGtk_Type, &child, &PyDict_Type, &dict)) + return NULL; + arg = PyDict_AsContainerArgs(dict, GTK_OBJECT_TYPE(PyGtk_Get(obj)),&nargs); + if (arg == NULL && nargs != 0) + return NULL; + gtk_container_child_setv(GTK_CONTAINER(PyGtk_Get(obj)), + GTK_WIDGET(PyGtk_Get(child)), nargs, arg); + g_free(arg); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_container_child_get(PyObject *self, PyObject *args){ + PyObject *obj, *child, *ret; + GtkArg arg; + + if (!PyArg_ParseTuple(args, "O!O!s:gtk_container_child_get", &PyGtk_Type, + &obj, &PyGtk_Type, &child, &(arg.name))) + return NULL; + gtk_container_child_getv(GTK_CONTAINER(PyGtk_Get(obj)), + GTK_WIDGET(PyGtk_Get(child)), 1, &arg); + if (arg.type == GTK_TYPE_INVALID) { + PyErr_SetString(PyExc_AttributeError, "invalid property"); + return NULL; + } + ret = GtkArg_AsPyObject(&arg); + if (ret == NULL) { + PyErr_SetString(PyExc_TypeError, "couldn't translate type"); + return NULL; + } + return ret; +} + +static PyObject *_wrap_gtk_container_children(PyObject *self, PyObject *args) { + PyObject *obj; + GList *list, *tmp; + PyObject *py_list; + + if(!PyArg_ParseTuple(args,"O!:gtk_container_children", &PyGtk_Type, &obj)) + return NULL; + list = gtk_container_children(GTK_CONTAINER(PyGtk_Get(obj))); + py_list = PyList_New(0); + for (tmp = list; tmp != NULL; tmp = tmp->next) + PyList_Append(py_list, PyGtk_New(GTK_OBJECT(tmp->data))); + g_list_free(list); + return py_list; +} + +static PyObject *_wrap_gtk_window_set_icon(PyObject *self, PyObject *args) { + PyGtk_Object *o, *pix, *mask; + GtkWidget *win; + if (!PyArg_ParseTuple(args, "O!O!O!:gtk_window_set_icon", &PyGtk_Type, + &o, &PyGdkWindow_Type, &pix, &PyGdkWindow_Type, &mask)) + return NULL; + win = GTK_WIDGET(PyGtk_Get(o)); + gtk_widget_realize(win); + gdk_window_set_icon(win->window, NULL, PyGdkWindow_Get(pix), + PyGdkWindow_Get(mask)); + Py_INCREF(Py_None); + return Py_None; +} +static PyObject *_wrap_gtk_window_set_icon_name(PyObject *self, PyObject *args) { + PyGtk_Object *o; + char *name; + if (!PyArg_ParseTuple(args, "O!s:gtk_window_set_icon_name", + &PyGtk_Type, &o, &name)) + return NULL; + gdk_window_set_icon_name(GTK_WIDGET(PyGtk_Get(o))->window, name); + Py_INCREF(Py_None); + return Py_None; +} +/* --- */ +static PyObject * +_wrap_gtk_box_query_child_packing(PyObject *self, PyObject *args) { + PyObject *box, *child; + gboolean expand, fill; + guint padding; + GtkPackType pack_type; + if (!PyArg_ParseTuple(args, "O!O!:gtk_box_query_child_packing", &PyGtk_Type, + &box, &PyGtk_Type, &child)) + return NULL; + gtk_box_query_child_packing(GTK_BOX(PyGtk_Get(box)), + GTK_WIDGET(PyGtk_Get(child)), &expand, &fill, + &padding, &pack_type); + return Py_BuildValue("(iiii)", (int)expand, (int)fill, padding, pack_type); +} + +static PyObject * +_wrap_gtk_button_box_get_child_size_default(PyObject *self, PyObject *args) { + int mw, mh; + if (!PyArg_ParseTuple(args, ":gtk_button_box_get_child_size_default")) + return NULL; + gtk_button_box_get_child_size_default(&mw, &mh); + return Py_BuildValue("(ii)", mw, mh); +} +static PyObject * +_wrap_gtk_button_box_get_child_ipadding_default(PyObject *self, PyObject *args) { + int ipx, ipy; + if (!PyArg_ParseTuple(args, ":gtk_button_box_get_child_ipadding_default")) + return NULL; + gtk_button_box_get_child_ipadding_default(&ipx, &ipy); + return Py_BuildValue("(ii)", ipx, ipy); +} +static PyObject * +_wrap_gtk_button_box_get_child_size(PyObject *self, PyObject *args) { + int mw, mh; + PyGtk_Object *o; + if (!PyArg_ParseTuple(args, "O!:gtk_button_box_get_child_size", + &PyGtk_Type, &o)) + return NULL; + gtk_button_box_get_child_size(GTK_BUTTON_BOX(PyGtk_Get(o)), &mw, &mh); + return Py_BuildValue("(ii)", mw, mh); +} +static PyObject * +_wrap_gtk_button_box_get_child_ipadding(PyObject *self, PyObject *args) { + int ipx, ipy; + PyGtk_Object *o; + if (!PyArg_ParseTuple(args, "O!:gtk_button_box_get_child_ipadding", + &PyGtk_Type, &o)) + return NULL; + gtk_button_box_get_child_ipadding(GTK_BUTTON_BOX(PyGtk_Get(o)),&ipx,&ipy); + return Py_BuildValue("(ii)", ipx, ipy); +} + +static PyObject *_wrap_gtk_clist_get_selection(PyObject *self, PyObject *args) { + GList *selection; + guint row; + PyObject *clist, *ret; + if (!PyArg_ParseTuple(args, "O!:gtk_clist_get_selection", &PyGtk_Type, + &clist)) + return NULL; + ret = PyList_New(0); + for (selection = GTK_CLIST(PyGtk_Get(clist))->selection; selection != NULL; + selection = selection->next) { + row = (guint)selection->data; + PyList_Append(ret, PyInt_FromLong(row)); + } + return ret; +} +static PyObject *_wrap_gtk_clist_new_with_titles(PyObject *self, PyObject *args) { + int c, i; + PyObject *l, *item; + char **list; + if (!PyArg_ParseTuple(args, "iO:gtk_clist_new_with_titles", + &c, &l)) + return NULL; + if (!PySequence_Check(l)) { + PyErr_SetString(PyExc_TypeError,"3rd argument not a sequence"); + return NULL; + } + if (PySequence_Length(l) < c) { + PyErr_SetString(PyExc_TypeError, "sequence not long enough"); + return NULL; + } + list = malloc(sizeof(char *)*c); + for (i = 0; i < c; i++) { + item = PySequence_GetItem(l, i); + if (!PyString_Check(item)) { + PyErr_SetString(PyExc_TypeError, + "sequence item not a string"); + free(list); + return NULL; + } + list[i] = PyString_AsString(item); + } + item = (PyObject *) PyGtk_New((GtkObject *)gtk_clist_new_with_titles + (c, list)); + free(list); + return item; +} + +static PyObject *_wrap_gtk_clist_get_text(PyObject *self, PyObject *args) { + PyObject *w; + int r, c; + char *text; + + if (!PyArg_ParseTuple(args, "O!ii:gtk_clist_get_text", &PyGtk_Type, + &w, &r, &c)) + return NULL; + if (!gtk_clist_get_text(GTK_CLIST(PyGtk_Get(w)), r, c, &text)) { + PyErr_SetString(PyExc_ValueError, "can't get text value"); + return NULL; + } + return PyString_FromString(text); +} + +static PyObject *_wrap_gtk_clist_get_pixmap(PyObject *self, PyObject *args) { + PyObject *o, *mask; + int r, c; + GdkPixmap *p; + GdkBitmap *m; + + if (!PyArg_ParseTuple(args, "O!iiO!:gtk_clist_get_pixmap", &PyGtk_Type, + &o, &r, &c)) + return NULL; + if (!gtk_clist_get_pixmap(GTK_CLIST(PyGtk_Get(o)), r, c, &p, &m)) { + PyErr_SetString(PyExc_ValueError, "can't get pixmap value"); + return NULL; + } + if (m) + mask = PyGdkWindow_New(m); + else { + Py_INCREF(Py_None); + mask = Py_None; + } + return Py_BuildValue("(OO)", PyGdkWindow_New(p), PyGdkWindow_New(m)); +} + +static PyObject *_wrap_gtk_clist_get_pixtext(PyObject *self, PyObject *args) { + PyObject *o, *mask; + int r, c; + guint8 spacing; + char *text; + GdkPixmap *p; + GdkBitmap *m; + + if (!PyArg_ParseTuple(args, "O!ii:gtk_clist_get_pixtext", + &PyGtk_Type, &o, &r, &c)) + return NULL; + if (!gtk_clist_get_pixtext(GTK_CLIST(PyGtk_Get(o)), r, c, + &text, &spacing, &p, &m)) { + PyErr_SetString(PyExc_ValueError, "can't get pixtext value"); + return NULL; + } + if (m) + mask = PyGdkWindow_New(m); + else { + Py_INCREF(Py_None); + mask = Py_None; + } + return Py_BuildValue("(siOO)", text, (int)spacing, + PyGdkWindow_New(p), mask); +} + +static PyObject *_wrap_gtk_clist_prepend(PyObject *self, PyObject *args) { + PyGtk_Object *cl; + int col, i; + PyObject *l, *item; + char **list; + if (!PyArg_ParseTuple(args, "O!O:gtk_clist_prepend", &PyGtk_Type, &cl, + &l)) + return NULL; + if (!PySequence_Check(l)) { + PyErr_SetString(PyExc_TypeError, "argument not a sequence"); + return NULL; + } + col = GTK_CLIST(PyGtk_Get(cl))->columns; + if (PySequence_Length(l) < col) { + PyErr_SetString(PyExc_TypeError, "sequnce too short"); + return NULL; + } + list = g_new(gchar *, col); + for (i = 0; i < col; i++) { + item = PySequence_GetItem(l, i); + if (!PyString_Check(item)) { + PyErr_SetString(PyExc_TypeError, + "sequence item not a string"); + g_free(list); + return NULL; + } + list[i] = PyString_AsString(item); + } + i = gtk_clist_prepend(GTK_CLIST(PyGtk_Get(cl)), list); + g_free(list); + return PyInt_FromLong(i); +} + +static PyObject *_wrap_gtk_clist_append(PyObject *self, PyObject *args) { + PyGtk_Object *cl; + int col, i; + PyObject *l, *item; + char **list; + if (!PyArg_ParseTuple(args, "O!O:gtk_clist_append", &PyGtk_Type, &cl, + &l)) + return NULL; + if (!PySequence_Check(l)) { + PyErr_SetString(PyExc_TypeError, "argument not a sequence"); + return NULL; + } + col = GTK_CLIST(PyGtk_Get(cl))->columns; + if (PySequence_Length(l) < col) { + PyErr_SetString(PyExc_TypeError, "sequnce too short"); + return NULL; + } + list = g_new(gchar *, col); + for (i = 0; i < col; i++) { + item = PySequence_GetItem(l, i); + if (!PyString_Check(item)) { + PyErr_SetString(PyExc_TypeError, + "sequence item not a string"); + g_free(list); + return NULL; + } + list[i] = PyString_AsString(item); + } + i = gtk_clist_append(GTK_CLIST(PyGtk_Get(cl)), list); + g_free(list); + return PyInt_FromLong(i); +} + +static PyObject *_wrap_gtk_clist_insert(PyObject *self, PyObject *args) { + PyGtk_Object *cl; + int col, r, i; + PyObject *l, *item; + char **list; + if (!PyArg_ParseTuple(args, "O!iO:gtk_clist_insert", &PyGtk_Type, &cl, + &r, &l)) + return NULL; + if (!PySequence_Check(l)) { + PyErr_SetString(PyExc_TypeError, "argument not a sequence"); + return NULL; + } + col = GTK_CLIST(PyGtk_Get(cl))->columns; + if (PySequence_Length(l) < col) { + PyErr_SetString(PyExc_TypeError, "sequnce too short"); + return NULL; + } + list = g_new(gchar *, col); + for (i = 0; i < col; i++) { + item = PySequence_GetItem(l, i); + if (!PyString_Check(item)) { + PyErr_SetString(PyExc_TypeError, + "sequence item not a string"); + g_free(list); + return NULL; + } + list[i] = PyString_AsString(item); + } + i = gtk_clist_insert(GTK_CLIST(PyGtk_Get(cl)), r, list); + g_free(list); + return PyInt_FromLong(i); +} +static PyObject *_wrap_gtk_clist_set_row_data(PyObject *self, PyObject *args) { + PyGtk_Object *obj; + int row; + PyObject *data; + if (!PyArg_ParseTuple(args, "O!iO:gtk_clist_set_row_data", &PyGtk_Type, + &obj, &row, &data)) + return NULL; + Py_INCREF(data); + gtk_clist_set_row_data_full(GTK_CLIST(PyGtk_Get(obj)), row, data, + (GtkDestroyNotify)PyGtk_DestroyNotify); + Py_INCREF(Py_None); + return Py_None; +} +static PyObject *_wrap_gtk_clist_get_row_data(PyObject *s, PyObject *args) { + PyObject *clist, *ret; + int row; + + if (!PyArg_ParseTuple(args, "O!i:gtk_clist_get_row_data", &PyGtk_Type, + &clist, &row)) + return NULL; + ret = gtk_clist_get_row_data(GTK_CLIST(PyGtk_Get(clist)), row); + if (!ret) ret = Py_None; + Py_INCREF(ret); + return ret; +} +static PyObject *_wrap_gtk_clist_find_row_from_data(PyObject *s, PyObject *args) { + PyObject *clist, *data; + + if (!PyArg_ParseTuple(args, "O!O:gtk_clist_find_row_from_data", + &PyGtk_Type, &clist, &data)) + return NULL; + return PyInt_FromLong(gtk_clist_find_row_from_data( + GTK_CLIST(PyGtk_Get(clist)), data)); +} +static PyObject *_wrap_gtk_clist_get_selection_info(PyObject *s, PyObject *args) { + PyObject *clist; + gint x, y, row, column; + if (!PyArg_ParseTuple(args, "O!ii:gtk_clist_get_selection_info", &PyGtk_Type, + &clist, &x, &y)) + return NULL; + if (gtk_clist_get_selection_info(GTK_CLIST(PyGtk_Get(clist)), x, y, + &row, &column)) + return Py_BuildValue("(ii)", row, column); + else { + Py_INCREF(Py_None); + return Py_None; + } +} + +static PyObject * +_wrap_gtk_combo_set_popdown_strings(PyObject *self, PyObject *args) { + PyObject *obj, *list, *item; + GList *glist = NULL; + int len, i; + if (!PyArg_ParseTuple(args, "O!O!:gtk_combo_set_popdown_strings", + &PyGtk_Type, &obj, &PyList_Type, &list)) + return NULL; + len = PyList_Size(list); + for (i = 0; i < len; i++) { + item = PyList_GetItem(list, i); + if (!PyString_Check(item)) { + PyErr_SetString(PyExc_TypeError, "list item not a string"); + g_list_free(glist); + return NULL; + } + glist = g_list_append(glist, PyString_AsString(item)); + } + gtk_combo_set_popdown_strings(GTK_COMBO(PyGtk_Get(obj)), glist); + g_list_free(glist); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_curve_get_vector(PyObject *self, PyObject *args) { + PyGtk_Object *obj; + int size=-1, i; + gfloat *vector; + PyObject *ret; + + if (!PyArg_ParseTuple(args, "O!|i:gtk_curve_get_vector", &PyGtk_Type, &obj, + &size)) + return NULL; + if (size < 0) size = GTK_CURVE(PyGtk_Get(obj))->num_points; + vector = g_new(gfloat, size); + gtk_curve_get_vector(GTK_CURVE(PyGtk_Get(obj)), size, vector); + ret = PyTuple_New(size); + for (i = 0; i < size; i++) + PyTuple_SetItem(ret, i, PyFloat_FromDouble(vector[i])); + g_free(vector); + return ret; +} +static PyObject *_wrap_gtk_curve_set_vector(PyObject *self, PyObject *args) { + PyGtk_Object *obj; + PyObject *seq, *item; + int size, i; + gfloat *vector; + + if (!PyArg_ParseTuple(args, "O!O:gtk_curve_set_vector", &PyGtk_Type, &obj, + &seq)) + return NULL; + if (!PySequence_Check(seq)) { + PyErr_SetString(PyExc_TypeError, "2nd argument is not a sequence"); + return NULL; + } + size = PySequence_Length(seq); + vector = g_new(gfloat, size); + for (i = 0; i < size; i++) { + item = PyNumber_Float(PySequence_GetItem(seq, i)); + if (item == NULL) { + g_free(vector); + return NULL; + } + vector[i] = PyFloat_AsDouble(item); + Py_DECREF(item); + } + gtk_curve_set_vector(GTK_CURVE(PyGtk_Get(obj)), size, vector); + g_free(vector); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_editable_insert_text(PyObject *self, PyObject *args) { + PyGtk_Object *o; + char *text; + int len, pos; + if (!PyArg_ParseTuple(args, "O!s#:gtk_editable_insert_text", + &PyGtk_Type, &o, &text, &len)) + return NULL; + gtk_editable_insert_text(GTK_EDITABLE(PyGtk_Get(o)), text, len, &pos); + return PyInt_FromLong(pos); +} + +static PyObject *_wrap_gtk_frame_new(PyObject *self, PyObject *args) { + char *label; + + if (!PyArg_ParseTuple(args, "z:gtk_frame_new", &label)) + return NULL; + return PyGtk_New((GtkObject *)gtk_frame_new(label)); +} + +static void PyGtk_item_factory_cb(PyObject *callback, guint action, + GtkWidget *widget) { + PyObject *ret; + ret = PyObject_CallFunction(callback, "iO", action, + PyGtk_New((GtkObject *)widget)); + if (ret == NULL) { + PyErr_Print(); + PyErr_Clear(); + } else + Py_DECREF(ret); +} +static PyObject *_wrap_gtk_item_factory_create_items(PyObject *self,PyObject *args){ + PyObject *obj, *list, *item, *cb; + GtkItemFactoryEntry ent; + GtkItemFactory *ifact; + int i, len; + if (!PyArg_ParseTuple(args, "O!O!:gtk_item_factory_create_items", + &PyGtk_Type, &obj, &PyList_Type, &list)) + return NULL; + ifact = GTK_ITEM_FACTORY(PyGtk_Get(obj)); + len = PyList_Size(list); + for (i = 0; i < len; i++) { + item = PyList_GetItem(list, i); + if (!PyArg_ParseTuple(item, "zzOiz", &(ent.path), &(ent.accelerator), + &cb, &(ent.callback_action), &(ent.item_type))) + return NULL; + if (cb == Py_None) + ent.callback = NULL; + else { + Py_INCREF(cb); + ent.callback = (GtkItemFactoryCallback)PyGtk_item_factory_cb; + } + gtk_item_factory_create_item(ifact, &ent, cb, 1); + } + Py_INCREF(Py_None); + return Py_None; +} + +static void PyGtk_MenuPosition(GtkMenu *menu, int *x, int *y, PyObject *func) { + PyObject *ret; + ret = PyObject_CallFunction(func, "(O)", PyGtk_New(GTK_OBJECT(menu))); + if (ret == NULL || !PyArg_ParseTuple(ret, "ii", x, y)) { + PyErr_Print(); + PyErr_Clear(); + *x = 0; + *y = 0; + } else + Py_DECREF(ret); +} +static PyObject *_wrap_gtk_menu_popup(PyObject *self, PyObject *args) { + PyGtk_Object *m, *pms, *pmi; + PyObject *func; + int button, time; + if (!PyArg_ParseTuple(args, "O!O!O!Oii:gtk_menu_item", &PyGtk_Type, &m, + &PyGtk_Type, &pms, &PyGtk_Type, &pmi, &func, &button, &time)) + return NULL; + if (!PyCallable_Check(func)) { + PyErr_SetString(PyExc_TypeError, "forth argument not callable"); + return NULL; + } + Py_INCREF(func); + gtk_menu_popup(GTK_MENU(PyGtk_Get(m)), GTK_WIDGET(PyGtk_Get(pms)), + GTK_WIDGET(PyGtk_Get(pmi)), (GtkMenuPositionFunc)PyGtk_MenuPosition, + func, button, time); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_pixmap_new_from_xpm(PyObject *self, PyObject *args) { + PyGtk_Object *win; + PyGdkColor_Object *tc = NULL; + char *name; + GdkColor *bg; + GdkPixmap *pm; + GdkBitmap *bm; + PyObject *ret; + + if (!PyArg_ParseTuple(args, "O!s|O!:gtk_pixmap_new_from_xpm", &PyGtk_Type, + &win, &name, &PyGdkColor_Type, &tc)) + return NULL; + if (tc == NULL) + bg = NULL; + else + bg = PyGdkColor_Get(tc); + pm = gdk_pixmap_create_from_xpm(GTK_WIDGET(PyGtk_Get(win))->window, &bm, + bg, name); + if (pm == NULL) { + PyErr_SetString(PyExc_IOError, "can't load pixmap"); + return NULL; + } + ret = PyGtk_New(GTK_OBJECT(gtk_pixmap_new(pm, bm))); + /* gtk_pixmap_new ref's the pixmap and mask, so we can unref out vars */ + gdk_pixmap_unref(pm); + gdk_bitmap_unref(bm); + return ret; +} +static PyObject *_wrap_gtk_pixmap_get(PyObject *self, PyObject *args) { + PyObject *pix; + GdkPixmap *pixmap; + GdkBitmap *mask; + if (!PyArg_ParseTuple(args, "O!:gtk_pixmap_get", &PyGtk_Type, &pix)) + return NULL; + gtk_pixmap_get(GTK_PIXMAP(PyGtk_Get(pix)), &pixmap, &mask); + if (!mask) Py_INCREF(Py_None); + return Py_BuildValue("(OO)", PyGdkWindow_New(pixmap), + mask ? PyGdkWindow_New(mask) : Py_None); +} + +static PyObject *_wrap_gtk_radio_menu_item_new(PyObject *self, PyObject *args) { + PyGtk_Object *g = NULL; + GSList *l = NULL; + if (!PyArg_ParseTuple(args, "|O!:gtk_radio_menu_item_new",&PyGtk_Type, &g)) + return NULL; + if (g) + l = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(PyGtk_Get(g))); + return PyGtk_New(GTK_OBJECT(gtk_radio_menu_item_new(l))); +} +static PyObject *_wrap_gtk_radio_menu_item_new_with_label(PyObject *s,PyObject *a) { + PyGtk_Object *g = NULL; + char *label = ""; + GSList *l = NULL; + if (!PyArg_ParseTuple(a, "|Os:gtk_radio_menu_item_new_with_label", + &g, &label)) + return NULL; + if (g != NULL) + if (!PyGtk_Check(g) && (PyObject *)g != Py_None) { + PyErr_SetString(PyExc_TypeError, + "first argument not a GtkObject or None"); + return NULL; + } + if ((PyObject *)g == Py_None) g = NULL; + if (g) + l = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(PyGtk_Get(g))); + return PyGtk_New(GTK_OBJECT(gtk_radio_menu_item_new_with_label(l, label))); +} + +static PyObject *_wrap_gtk_radio_button_new(PyObject *self, PyObject *args) { + if (!PyArg_ParseTuple(args, ":gtk_radio_button_new")) + return NULL; + return PyGtk_New((GtkObject *)gtk_radio_button_new(NULL)); +} + +static PyObject *_wrap_gtk_radio_button_new_with_label(PyObject *self, PyObject *args) { + PyObject *nothing; + char *label; + + if (!PyArg_ParseTuple(args, "Os:gtk_radio_button_new_with_label", + ¬hing, &label)) + return NULL; + return PyGtk_New((GtkObject *)gtk_radio_button_new_with_label(NULL,label)); +} + +static PyObject *_wrap_gtk_text_insert_defaults(PyObject *self, PyObject *args) { + PyGtk_Object *txt; + char *chars; + int l; + GtkStyle *style; + if (!PyArg_ParseTuple(args, "O!s#:gtk_text_insert_defaults", &PyGtk_Type, + &txt, &chars, &l)) + return NULL; + style = gtk_widget_get_style(GTK_WIDGET(PyGtk_Get(txt))); + gtk_text_insert(GTK_TEXT(PyGtk_Get(txt)), NULL, + &style->fg[GTK_STATE_NORMAL], NULL, chars, l); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_toolbar_append_item(PyObject *self, PyObject *args) { + PyGtk_Object *t, *icon; + char *text, *tooltip, *tip_private; + PyObject *callback; + GList *tmp_list; + if (!PyArg_ParseTuple(args, "O!zzzO!O|gtk_toolbar_append_item", + &PyGtk_Type, &t, &text, &tooltip, &tip_private, + &PyGtk_Type, &icon, &callback)) + return NULL; + if (!PyCallable_Check(callback) && callback != Py_None) { + PyErr_SetString(PyExc_TypeError,"sixth argument not callable"); + return NULL; + } + Py_INCREF(callback); + /* if you set sigfunc to NULL, no signal is connected, rather than + the default signal handler being used */ + gtk_toolbar_append_item(GTK_TOOLBAR(PyGtk_Get(t)), text, tooltip, + tip_private, GTK_WIDGET(PyGtk_Get(icon)), NULL, NULL); + if (callback != Py_None) { + tmp_list = g_list_last(gtk_container_children(GTK_CONTAINER( + PyGtk_Get(t)))); + gtk_signal_connect(GTK_OBJECT(tmp_list->data), "clicked", NULL, + callback); + } + Py_INCREF(Py_None); + return Py_None; +} +static PyObject *_wrap_gtk_toolbar_prepend_item(PyObject *self, PyObject *args) { + PyGtk_Object *t, *icon; + char *text, *tooltip, *tip_private; + PyObject *callback; + if (!PyArg_ParseTuple(args, "O!zzzO!O|gtk_toolbar_prepend_item", + &PyGtk_Type, &t, &text, &tooltip, &tip_private, + &PyGtk_Type, &icon, &callback)) + return NULL; + if (!PyCallable_Check(callback) && callback != Py_None) { + PyErr_SetString(PyExc_TypeError,"sixth argument not callable"); + return NULL; + } + Py_INCREF(callback); + gtk_toolbar_prepend_item(GTK_TOOLBAR(PyGtk_Get(t)), text, tooltip, + tip_private, GTK_WIDGET(PyGtk_Get(icon)), NULL, NULL); + if (callback != Py_None) + gtk_signal_connect(GTK_OBJECT(gtk_container_children( + GTK_CONTAINER(PyGtk_Get(t)))->data), "clicked", NULL, + callback); + Py_INCREF(Py_None); + return Py_None; +} +static PyObject *_wrap_gtk_toolbar_insert_item(PyObject *self, PyObject *args) { + PyGtk_Object *t, *icon; + char *text, *tooltip, *tip_private; + PyObject *callback; + int pos; + GList *tmp_list; + if (!PyArg_ParseTuple(args, "O!zzzO!Oi|gtk_toolbar_insert_item", + &PyGtk_Type, &t, &text, &tooltip, &tip_private, + &PyGtk_Type, &icon, &callback, &pos)) + return NULL; + if (!PyCallable_Check(callback) && callback != Py_None) { + PyErr_SetString(PyExc_TypeError,"sixth argument not callable"); + return NULL; + } + Py_INCREF(callback); + gtk_toolbar_insert_item(GTK_TOOLBAR(PyGtk_Get(t)), text, tooltip, + tip_private, GTK_WIDGET(PyGtk_Get(icon)), NULL, NULL, pos); + if (callback != Py_None) { + tmp_list = g_list_nth(gtk_container_children(GTK_CONTAINER( + PyGtk_Get(t))), pos); + gtk_signal_connect(GTK_OBJECT(tmp_list->data), "clicked", NULL, + callback); + } + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_drag_dest_set(PyObject *self, PyObject *args) { + PyObject *widget, *py_flags, *py_actions, *py_list; + GtkDestDefaults flags; + GdkDragAction actions; + GtkTargetEntry *targets; + gint n_targets, i; + + if (!PyArg_ParseTuple(args, "O!OO!O:gtk_drag_dest_set", &PyGtk_Type, &widget, + &py_flags, &PyList_Type, &py_list, &py_actions)) + return NULL; + if (PyGtkFlag_get_value(GTK_TYPE_DEST_DEFAULTS, py_flags, (gint *)&flags)) + return NULL; + if (PyGtkFlag_get_value(GTK_TYPE_GDK_DRAG_ACTION,py_actions,(gint*)&actions)) + return NULL; + n_targets = PyList_Size(py_list); + targets = g_new(GtkTargetEntry, n_targets); + for (i = 0; i < n_targets; i++) { + PyObject *item = PyList_GetItem(py_list, i); + if (!PyArg_ParseTuple(item, "zii", &(targets[i].target), + &(targets[i].flags), &(targets[i].info))) { + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError,"list items should be (string,int,int)"); + g_free(targets); + return NULL; + } + } + gtk_drag_dest_set(GTK_WIDGET(PyGtk_Get(widget)), flags, targets, n_targets, + actions); + g_free(targets); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_drag_source_set(PyObject *self, PyObject *args) { + PyObject *widget, *py_bmask, *py_list, *py_actions; + GdkModifierType bmask; + GtkTargetEntry *targets; + gint n_targets, i; + GdkDragAction actions; + + if (!PyArg_ParseTuple(args, "O!OO!O:gtk_drag_source_set", &PyGtk_Type, + &widget, &py_bmask, &PyList_Type,&py_list,&py_actions)) + return NULL; + if (PyGtkFlag_get_value(GTK_TYPE_GDK_MODIFIER_TYPE, py_bmask, (gint*)&bmask)) + return NULL; + if (PyGtkFlag_get_value(GTK_TYPE_GDK_DRAG_ACTION,py_actions,(gint*)&actions)) + return NULL; + n_targets = PyList_Size(py_list); + targets = g_new(GtkTargetEntry, n_targets); + for (i = 0; i < n_targets; i++) { + PyObject *item = PyList_GetItem(py_list, i); + if (!PyArg_ParseTuple(item, "zii", &(targets[i].target), + &(targets[i].flags), &(targets[i].info))) { + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError,"list items should be (string,int,int)"); + g_free(targets); + return NULL; + } + } + gtk_drag_source_set(GTK_WIDGET(PyGtk_Get(widget)), bmask, targets, n_targets, + actions); + g_free(targets); + Py_INCREF(Py_None); + return Py_None; +} + +PyObject *_wrap_gtk_drag_begin(PyObject *self, PyObject *args) { + PyObject *widget, *py_list, *py_actions, *event; + GdkDragAction actions; + gint button, n_targets, i; + GtkTargetEntry *targets; + GtkTargetList *list; + GdkDragContext *context; + + if (!PyArg_ParseTuple(args, "O!O!OiO!:gtk_drag_begin", &PyGtk_Type, &widget, + &PyList_Type, &py_list, &py_actions, &button, + &PyGdkEvent_Type, &event)) + return NULL; + if (PyGtkFlag_get_value(GTK_TYPE_GDK_DRAG_ACTION,py_actions,(gint*)&actions)) + return NULL; + n_targets = PyList_Size(py_list); + targets = g_new(GtkTargetEntry, n_targets); + for (i = 0; i < n_targets; i++) { + PyObject *item = PyList_GetItem(py_list, i); + if (!PyArg_ParseTuple(item, "zii", &(targets[i].target), + &(targets[i].flags), &(targets[i].info))) { + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError,"list items should be (string,int,int)"); + g_free(targets); + return NULL; + } + } + list = gtk_target_list_new(targets, n_targets); + g_free(targets); + context = gtk_drag_begin(GTK_WIDGET(PyGtk_Get(widget)), list, actions, + button, PyGdkEvent_Get(event)); + gtk_target_list_unref(list); + return PyGdkDragContext_New(context); +} + +#include "gtkmodule_impl.c" + +static PyObject *_wrap_gdk_pixmap_new(PyObject *self, PyObject *args) { + GdkPixmap *pix; + PyObject *win, *ret; + int w, h, d; + if (!PyArg_ParseTuple(args, "O!iii:gdk_pixmap_new", &PyGdkWindow_Type, &win, + &w, &h, &d)) + return NULL; + pix = gdk_pixmap_new(PyGdkWindow_Get(win), w, h, d); + ret = PyGdkWindow_New(pix); + gdk_pixmap_unref(pix); + return ret; +} +static PyObject *_wrap_gdk_pixmap_create_from_xpm(PyObject *self, PyObject *args) { + GdkPixmap *pix; + GdkBitmap *mask; + PyObject *parent_win, *colour, *ret; + GdkColor *col; + gchar *fname; + + if (!PyArg_ParseTuple(args, "O!Os:gdk_pixmap_create_from_xpm", + &PyGdkWindow_Type, &parent_win, &colour, &fname)) + return NULL; + if (colour == Py_None) col = NULL; + else if (PyGdkColor_Check(colour)) col = PyGdkColor_Get(colour); + else { + PyErr_SetString(PyExc_TypeError, + "second argument must be a colour or None"); + return NULL; + } + pix = gdk_pixmap_create_from_xpm(PyGdkWindow_Get(parent_win), &mask, col, + fname); + if (pix == NULL) { + PyErr_SetString(PyExc_IOError, "can't load pixmap"); + return NULL; + } + ret = Py_BuildValue("(OO)", PyGdkWindow_New(pix), PyGdkWindow_New(mask)); + gdk_pixmap_unref(pix); + gdk_bitmap_unref(mask); + return ret; +} + +static PyObject *_wrap_gdk_pixmap_create_from_xpm_d(PyObject *self, PyObject *args) { + GdkPixmap *pix; + GdkBitmap *mask; + PyObject *parent_win, *colour, *ret, *py_lines; + GdkColor *col; + int len, i; + char **data; + + if (!PyArg_ParseTuple(args, "O!OO!:gdk_pixmap_create_from_xpm_d", + &PyGdkWindow_Type, &parent_win, &colour, + &PyList_Type, &py_lines)) + return NULL; + if (colour == Py_None) col = NULL; + else if (PyGdkColor_Check(colour)) col = PyGdkColor_Get(colour); + else { + PyErr_SetString(PyExc_TypeError, + "second argument must be a colour or None"); + return NULL; + } + len = PyList_Size(py_lines); + data = g_new(char *, len); + for (i = 0; i < len; i++) { + PyObject *item = PyList_GetItem(py_lines, i); + if (!PyString_Check(item)) { + PyErr_SetString(PyExc_TypeError, "list items must be strings"); + g_free(data); + return NULL; + } + data[i] = PyString_AsString(item); + } + pix = gdk_pixmap_create_from_xpm_d(PyGdkWindow_Get(parent_win), &mask, col, + data); + g_free(data); + if (pix == NULL) { + PyErr_SetString(PyExc_IOError, "can't load pixmap"); + return NULL; + } + ret = Py_BuildValue("(OO)", PyGdkWindow_New(pix), PyGdkWindow_New(mask)); + gdk_pixmap_unref(pix); + gdk_bitmap_unref(mask); + return ret; +} + +static PyObject *_wrap_gdk_draw_polygon(PyObject *self, PyObject *args) { + PyObject *win, *gc, *seq, *item; + gint filled, npoints, i; + GdkPoint *points; + + if (!PyArg_ParseTuple(args, "O!O!iO:gdk_draw_polygon", &PyGdkWindow_Type, + &win, &PyGdkGC_Type, &gc, &filled, &seq)) + return NULL; + if (!PySequence_Check(seq)) { + PyErr_SetString(PyExc_TypeError, "forth argument not a sequence"); + return NULL; + } + npoints = PySequence_Length(seq); + points = g_new(GdkPoint, npoints); + for (i = 0; i < npoints; i++) { + item = PySequence_GetItem(seq, i); + if (!PyArg_ParseTuple(item, "hh", &(points[i].x), &(points[i].y))) { + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError, "sequence member not a 2-tuple"); + g_free(points); + return NULL; + } + } + gdk_draw_polygon(PyGdkWindow_Get(win),PyGdkGC_Get(gc),filled,points,npoints); + g_free(points); + Py_INCREF(Py_None); + return Py_None; +} +static PyObject *_wrap_gdk_draw_text(PyObject *self, PyObject *args) { + PyObject *win, *font, *gc; + int x, y, len; + char *str; + if (!PyArg_ParseTuple(args, "O!O!O!iis#:gdk_draw_text", &PyGdkWindow_Type, + &win, &PyGdkFont_Type, &font, &PyGdkGC_Type, &gc, + &x, &y, &str, &len)) + return NULL; + gdk_draw_text(PyGdkWindow_Get(win), PyGdkFont_Get(font), PyGdkGC_Get(gc), + x, y, str, len); + Py_INCREF(Py_None); + return Py_None; +} +static PyObject *_wrap_gdk_draw_points(PyObject *self, PyObject *args) { + PyObject *win, *gc, *seq, *item; + gint npoints, i; + GdkPoint *points; + + if (!PyArg_ParseTuple(args, "O!O!O:gdk_draw_points", &PyGdkWindow_Type, + &win, &PyGdkGC_Type, &gc, &seq)) + return NULL; + if (!PySequence_Check(seq)) { + PyErr_SetString(PyExc_TypeError, "third argument not a sequence"); + return NULL; + } + npoints = PySequence_Length(seq); + points = g_new(GdkPoint, npoints); + for (i = 0; i < npoints; i++) { + item = PySequence_GetItem(seq, i); + if (!PyArg_ParseTuple(item, "hh", &(points[i].x), &(points[i].y))) { + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError, "sequence member not a 2-tuple"); + g_free(points); + return NULL; + } + } + gdk_draw_points(PyGdkWindow_Get(win), PyGdkGC_Get(gc), points, npoints); + g_free(points); + Py_INCREF(Py_None); + return Py_None; +} +static PyObject *_wrap_gdk_draw_segments(PyObject *self, PyObject *args) { + PyObject *win, *gc, *seq, *item; + gint nsegs, i; + GdkSegment *segs; + + if (!PyArg_ParseTuple(args, "O!O!O:gdk_draw_segments", &PyGdkWindow_Type, + &win, &PyGdkGC_Type, &gc, &seq)) + return NULL; + if (!PySequence_Check(seq)) { + PyErr_SetString(PyExc_TypeError, "third argument not a sequence"); + return NULL; + } + nsegs = PySequence_Length(seq); + segs = g_new(GdkSegment, nsegs); + for (i = 0; i < nsegs; i++) { + item = PySequence_GetItem(seq, i); + if (!PyArg_ParseTuple(item, "hhhh", &(segs[i].x1), &(segs[i].y1), + &(segs[i].x2), &(segs[i].y2))) { + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError, "sequence member not a 4-tuple"); + g_free(segs); + return NULL; + } + } + gdk_draw_segments(PyGdkWindow_Get(win), PyGdkGC_Get(gc), segs, nsegs); + g_free(segs); + Py_INCREF(Py_None); + return Py_None; +} +static PyObject *_wrap_gdk_draw_lines(PyObject *self, PyObject *args) { + PyObject *win, *gc, *seq, *item; + gint npoints, i; + GdkPoint *points; + + if (!PyArg_ParseTuple(args, "O!O!O:gdk_draw_lines", &PyGdkWindow_Type, + &win, &PyGdkGC_Type, &gc, &seq)) + return NULL; + if (!PySequence_Check(seq)) { + PyErr_SetString(PyExc_TypeError, "third argument not a sequence"); + return NULL; + } + npoints = PySequence_Length(seq); + points = g_new(GdkPoint, npoints); + for (i = 0; i < npoints; i++) { + item = PySequence_GetItem(seq, i); + if (!PyArg_ParseTuple(item, "hh", &(points[i].x), &(points[i].y))) { + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError, "sequence member not a 2-tuple"); + g_free(points); + return NULL; + } + } + gdk_draw_lines(PyGdkWindow_Get(win), PyGdkGC_Get(gc), points, npoints); + g_free(points); + Py_INCREF(Py_None); + return Py_None; +} +/* gdk_color_alloc analog */ +static PyObject *_wrap_gdk_color_alloc(PyObject *self, PyObject *args) { + GdkColor gdk_color; + GdkColormap *colormap; + PyGtkStyle_Object *style; + PyGtk_Object *obj; + if (PyArg_ParseTuple(args, "O!iii:gdk_color_alloc", &PyGtkStyle_Type, + &style, &(gdk_color.red), &(gdk_color.green), + &(gdk_color.blue))) + colormap = PyGtkStyle_Get(style)->colormap; + else { + PyErr_Clear(); + if (!PyArg_ParseTuple(args, "O!iii:gdk_color_alloc", &PyGtk_Type, + &obj, &(gdk_color.red), &(gdk_color.green), + &(gdk_color.blue))) + return NULL; + if (GTK_WIDGET_NO_WINDOW(PyGtk_Get(obj))) { + PyErr_SetString(PyExc_TypeError, "widget has no window"); + return NULL; + } + colormap = gdk_window_get_colormap(GTK_WIDGET(PyGtk_Get(obj))->window); + } + gdk_color_alloc(colormap, &gdk_color); + return PyGdkColor_New(&gdk_color); +} + +static PyObject *_wrap_gtk_label_get(PyObject *self, PyObject *args) { + PyObject *label; + char *text; + + if (!PyArg_ParseTuple(args, "O!:gtk_label_get", &PyGtk_Type, &label)) + return NULL; + gtk_label_get(GTK_LABEL(PyGtk_Get(label)), &text); + return PyString_FromString(text); +} + +static PyObject *_wrap_gtk_color_selection_get_color(PyObject *self, PyObject *args) { + PyObject *colorsel; + double value[4]; + + if (!PyArg_ParseTuple(args, "O!:gtk_color_selection_get_color", &PyGtk_Type, &colorsel)) + return NULL; + gtk_color_selection_get_color(GTK_COLOR_SELECTION(PyGtk_Get(colorsel)), + value); + if (GTK_COLOR_SELECTION(PyGtk_Get(colorsel))->use_opacity) + return Py_BuildValue("(dddd)", value[0],value[1],value[2],value[3]); + else + return Py_BuildValue("(dddd)", value[0], value[1], value[2]); +} + +static PyObject *_wrap_gtk_color_selection_set_color(PyObject *self, PyObject *args) { + PyObject *colorsel; + double value[4]; + + value[3] = 1.0; + if (!PyArg_ParseTuple(args, "O!(ddd):gtk_color_selection_set_color", + &PyGtk_Type, &colorsel, &value[0], &value[1], + &value[2])) { + PyErr_Clear(); + if (!PyArg_ParseTuple(args, "O!(dddd):gtk_color_selection_set_color", + &PyGtk_Type, &colorsel, &value[0], &value[1], + &value[2], &value[3])) + return NULL; + } + gtk_color_selection_set_color(GTK_COLOR_SELECTION(PyGtk_Get(colorsel)), + value); + Py_INCREF(Py_None); + return Py_None; +} + +static GList *GList_FromPyList(PyObject *list) { + GList *ret = NULL; + PyObject *item; + int i, len; + + len = PyList_Size(list); + for (i = 0; i < len; i++) { + item = PyList_GetItem(list, i); + if (!PyGtk_Check(item)) { + PyErr_SetString(PyExc_TypeError, "list item not a GtkObject"); + g_list_free(ret); + return NULL; + } + ret = g_list_append(ret, PyGtk_Get(item)); + } + return ret; +} + +static PyObject *_wrap_gtk_list_insert_items(PyObject *self, PyObject *args) { + PyObject *list, *py_items; + GList *items = NULL; + int pos; + + if (!PyArg_ParseTuple(args, "O!O!i:gtk_list_insert_items", &PyGtk_Type, + &list, &PyList_Type, &py_items, &pos)) + return NULL; + if (PyList_Size(py_items) && (items = GList_FromPyList(py_items)) == NULL) + return NULL; + gtk_list_insert_items(GTK_LIST(PyGtk_Get(list)), items, pos); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_list_append_items(PyObject *self, PyObject *args) { + PyObject *list, *py_items; + GList *items = NULL; + + if (!PyArg_ParseTuple(args, "O!O!:gtk_list_append_items", &PyGtk_Type, + &list, &PyList_Type, &py_items)) + return NULL; + if (PyList_Size(py_items) && (items = GList_FromPyList(py_items)) == NULL) + return NULL; + gtk_list_append_items(GTK_LIST(PyGtk_Get(list)), items); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_list_prepend_items(PyObject *self, PyObject *args) { + PyObject *list, *py_items; + GList *items = NULL; + + if (!PyArg_ParseTuple(args, "O!O!:gtk_list_prepend_items", &PyGtk_Type, + &list, &PyList_Type, &py_items)) + return NULL; + if (PyList_Size(py_items) && (items = GList_FromPyList(py_items)) == NULL) + return NULL; + gtk_list_prepend_items(GTK_LIST(PyGtk_Get(list)), items); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_list_remove_items(PyObject *self, PyObject *args) { + PyObject *list, *py_items; + GList *items = NULL; + + if (!PyArg_ParseTuple(args, "O!O!:gtk_list_remove_items", &PyGtk_Type, + &list, &PyList_Type, &py_items)) + return NULL; + if (PyList_Size(py_items) && (items = GList_FromPyList(py_items)) == NULL) + return NULL; + gtk_list_remove_items(GTK_LIST(PyGtk_Get(list)), items); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_list_get_selection(PyObject *self, PyObject *args) { + PyObject *list, *ret; + GList *tmp; + + if (!PyArg_ParseTuple(args, "O!:gtk_list_get_selection",&PyGtk_Type,&list)) + return NULL; + tmp = GTK_LIST(PyGtk_Get(list))->selection; + ret - PyList_New(0); + for (; tmp; tmp = tmp->next) + PyList_Append(ret, PyGtk_New(tmp->data)); + return ret; +} + +static PyObject *_wrap_gtk_tree_remove_items(PyObject *self, PyObject *args) { + PyObject *tree, *py_items; + GList *items = NULL; + + if (!PyArg_ParseTuple(args, "O!O!:gtk_tree_remove_items", &PyGtk_Type, + &tree, &PyList_Type, &py_items)) + return NULL; + if (PyList_Size(py_items) && (items = GList_FromPyList(py_items)) == NULL) + return NULL; + gtk_tree_remove_items(GTK_TREE(PyGtk_Get(tree)), items); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_tree_get_selection(PyObject *self, PyObject *args) { + PyObject *tree, *ret; + GList *tmp; + + if (!PyArg_ParseTuple(args, "O!:gtk_tree_get_selection",&PyGtk_Type,&tree)) + return NULL; + tmp = GTK_TREE(PyGtk_Get(tree))->selection; + ret - PyList_New(0); + for (; tmp; tmp = tmp->next) + PyList_Append(ret, PyGtk_New(tmp->data)); + return ret; +} + +static PyObject *_wrap_gtk_spin_button_new_no_adj(PyObject *self, PyObject *args) { + double climb_rate; + int digits; + + if (!PyArg_ParseTuple(args, "di:gtk_spin_button_new_no_adj", + &climb_rate, &digits)) + return NULL; + return PyGtk_New((GtkObject *)gtk_spin_button_new(NULL,climb_rate,digits)); +} + +static PyObject *_wrap_gtk_calendar_get_date(PyObject *self, PyObject *args) { + PyObject *cal; + guint year, month, day; + + if (!PyArg_ParseTuple(args, "O!:gtk_calendar_get_date", &PyGtk_Type, &cal)) + return NULL; + gtk_calendar_get_date(GTK_CALENDAR(PyGtk_Get(cal)), &year, &month, &day); + return Py_BuildValue("(iii)", year, month, day); +} + +static PyObject *_wrap_gtk_notebook_query_tab_label_packing(PyObject *self, PyObject *args) { + PyObject *notebook, *child; + gboolean expand, fill; + GtkPackType pack_type; + + if (!PyArg_ParseTuple(args, "O!O!:gtk_notebook_query_tab_label_packing", + &PyGtk_Type, ¬ebook, &PyGtk_Type, &child)) + return NULL; + gtk_notebook_query_tab_label_packing(GTK_NOTEBOOK(PyGtk_Get(notebook)), + GTK_WIDGET(PyGtk_Get(child)), + &expand, &fill, &pack_type); + return Py_BuildValue("(iii)", (int)expand, (int)fill, pack_type); +} + +static PyObject *_wrap_gtk_ctree_new_with_titles(PyObject *self, PyObject *args) { + int c, tree_col, i; + PyObject *l, *item; + char **list; + if (!PyArg_ParseTuple(args, "iiO:gtk_ctree_new_with_titles", + &c, &tree_col, &l)) + return NULL; + if (!PySequence_Check(l)) { + PyErr_SetString(PyExc_TypeError,"3rd argument not a sequence"); + return NULL; + } + if (PySequence_Length(l) < c) { + PyErr_SetString(PyExc_TypeError, "sequence not long enough"); + return NULL; + } + list = malloc(sizeof(char *)*c); + for (i = 0; i < c; i++) { + item = PySequence_GetItem(l, i); + if (!PyString_Check(item)) { + PyErr_SetString(PyExc_TypeError, + "sequence item not a string"); + free(list); + return NULL; + } + list[i] = PyString_AsString(item); + } + item = (PyObject *) PyGtk_New((GtkObject *)gtk_ctree_new_with_titles( + c, tree_col, list)); + free(list); + return item; +} + +static PyObject *_wrap_gtk_ctree_insert_node(PyObject *self, PyObject *args) { + PyObject *ctree, *py_parent, *py_sibling, *py_text; + PyObject *py_pixmap_closed, *py_mask_closed; + PyObject *py_pixmap_opened, *py_mask_opened; + GtkCTreeNode *parent = NULL, *sibling = NULL, *ret; + gchar **text = NULL; + GdkPixmap *pixmap_closed = NULL, *pixmap_opened = NULL; + GdkBitmap *mask_closed = NULL, *mask_opened = NULL; + gint spacing, is_leaf, expanded, col, i; + + /* just about all the arguments can be substituted with None */ + if (!PyArg_ParseTuple(args, "O!OOOiOOOOii:gtk_ctree_insert_node", + &PyGtk_Type, &ctree, &py_parent, &py_sibling, &py_text, + spacing, &py_pixmap_closed, &py_mask_closed, + &py_pixmap_opened, &py_mask_opened, &is_leaf, + &expanded)) + return NULL; + if (PyGtkCTreeNode_Check(py_parent)) + parent = PyGtkCTreeNode_Get(py_parent); + else if (py_parent != Py_None) { + PyErr_SetString(PyExc_TypeError, "2nd arg must be a CTreeNode or None"); + return NULL; + } + if (PyGtkCTreeNode_Check(py_sibling)) + sibling = PyGtkCTreeNode_Get(py_sibling); + else if (py_sibling != Py_None) { + PyErr_SetString(PyExc_TypeError, "3rd arg must be a CTreeNode or None"); + return NULL; + } + if (PyGdkWindow_Check(py_pixmap_closed)) + pixmap_closed = PyGdkWindow_Get(py_pixmap_closed); + else if (py_pixmap_closed != Py_None) { + PyErr_SetString(PyExc_TypeError, "6th arg must be a GdkWindow or None"); + return NULL; + } + if (PyGdkWindow_Check(py_mask_closed)) + mask_closed = PyGdkWindow_Get(py_mask_closed); + else if (py_mask_closed != Py_None) { + PyErr_SetString(PyExc_TypeError, "7th arg must be a GdkWindow or None"); + return NULL; + } + if (PyGdkWindow_Check(py_pixmap_opened)) + pixmap_opened = PyGdkWindow_Get(py_pixmap_opened); + else if (py_pixmap_opened != Py_None) { + PyErr_SetString(PyExc_TypeError, "8th arg must be a GdkWindow or None"); + return NULL; + } + if (PyGdkWindow_Check(py_mask_opened)) + mask_opened = PyGdkWindow_Get(py_mask_opened); + else if (py_mask_opened != Py_None) { + PyErr_SetString(PyExc_TypeError, "9th arg must be a GdkWindow or None"); + return NULL; + } + if (!PySequence_Check(py_text)) { + PyErr_SetString(PyExc_TypeError, "4th arg must be a sequence"); + return NULL; + } + col = GTK_CLIST(PyGtk_Get(ctree))->columns; + if (PySequence_Length(py_text) < col) { + PyErr_SetString(PyExc_TypeError, "sequence too short"); + return NULL; + } + text = g_new(gchar *, col); + for (i = 0; i < col; i++) { + PyObject *item = PySequence_GetItem(py_text, i); + if (!PyString_Check(item)) { + PyErr_SetString(PyExc_TypeError, "sequence item not a string"); + g_free(text); + return NULL; + } + text[i] = PyString_AsString(item); + } + ret = gtk_ctree_insert_node(GTK_CTREE(PyGtk_Get(ctree)), parent, sibling, + text, spacing, pixmap_closed, mask_closed, + pixmap_opened, mask_opened, is_leaf, expanded); + g_free(text); + return PyGtkCTreeNode_New(ret); +} + +static PyObject *_wrap_gtk_ctree_find_by_row_data(PyObject *self, PyObject *args) { + PyObject *ctree, *py_node, *data; + GtkCTreeNode *node = NULL, *ret; + + if (!PyArg_ParseTuple(args, "O!OO:gtk_ctree_find_by_row_data", &PyGtk_Type, + &ctree, &py_node, &data)) + return NULL; + if (PyGtkCTreeNode_Check(py_node)) + node = PyGtkCTreeNode_Get(py_node); + else if (py_node != Py_None) { + PyErr_SetString(PyExc_TypeError, "2nd arg must be a GTreeNode or None"); + return NULL; + } + ret = gtk_ctree_find_by_row_data(GTK_CTREE(PyGtk_Get(ctree)), node, data); + if (ret) + return PyGtkCTreeNode_New(ret); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_ctree_find_all_by_row_data(PyObject *self, PyObject *args) { + PyObject *ctree, *py_node, *data, *list; + GtkCTreeNode *node = NULL; + GList *ret, *tmp; + + if (!PyArg_ParseTuple(args, "O!OO:gtk_ctree_find_all_by_row_data", + &PyGtk_Type, &ctree, &py_node, &data)) + return NULL; + if (PyGtkCTreeNode_Check(py_node)) + node = PyGtkCTreeNode_Get(py_node); + else if (py_node != Py_None) { + PyErr_SetString(PyExc_TypeError, "2nd arg must be a GTreeNode or None"); + return NULL; + } + ret = gtk_ctree_find_all_by_row_data(GTK_CTREE(PyGtk_Get(ctree)), node,data); + list = PyList_New(0); + for (tmp = ret; tmp; tmp = tmp->next) + PyList_Append(list, PyGtkCTreeNode_New(ret->data)); + g_list_free(ret); + return list; +} + +static PyObject *_wrap_gtk_ctree_move(PyObject *self, PyObject *args) { + PyObject *ctree, *node, *py_parent, *py_sibling; + GtkCTreeNode *parent, *sibling; + + if (!PyArg_ParseTuple(args, "O!O!OO:gtk_ctree_move", &PyGtk_Type, &ctree, + &PyGtkCTreeNode_Type, &node, &py_parent, &py_sibling)) + return NULL; + if (PyGtkCTreeNode_Check(py_parent)) + parent = PyGtkCTreeNode_Get(py_parent); + else if (py_parent != Py_None) { + PyErr_SetString(PyExc_TypeError, "3rd arg must be a CTreeNode or None"); + return NULL; + } + if (PyGtkCTreeNode_Check(py_sibling)) + sibling = PyGtkCTreeNode_Get(py_sibling); + else if (py_sibling != Py_None) { + PyErr_SetString(PyExc_TypeError, "4th arg must be a CTreeNode or None"); + return NULL; + } + gtk_ctree_move(GTK_CTREE(PyGtk_Get(ctree)), PyGtkCTreeNode_Get(node), + parent, sibling); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_ctree_node_get_text(PyObject *self, PyObject *args) { + PyObject *ctree, *node; + int col; + char *text; + + if (!PyArg_ParseTuple(args, "O!O!i:gtk_ctree_node_get_text", &PyGtk_Type, + &ctree, &PyGtkCTreeNode_Type, *node, &col)) + return NULL; + if (!gtk_ctree_node_get_text(GTK_CTREE(PyGtk_Get(ctree)), + PyGtkCTreeNode_Get(node), col, &text)) { + PyErr_SetString(PyExc_ValueError, "can't get text value"); + return NULL; + } + return PyString_FromString(text); +} + +static PyObject *_wrap_gtk_ctree_node_get_pixmap(PyObject *self, PyObject *args) { + PyObject *ctree, *node, *mask; + int col; + GdkPixmap *p; + GdkBitmap *m; + + if (!PyArg_ParseTuple(args, "O!O!i:gtk_ctree_node_get_pixmap", &PyGtk_Type, + &ctree, &PyGtkCTreeNode_Type, *node, &col)) + return NULL; + if (!gtk_ctree_node_get_pixmap(GTK_CTREE(PyGtk_Get(ctree)), + PyGtkCTreeNode_Get(node), col, &p, &m)) { + PyErr_SetString(PyExc_ValueError, "can't get pixmap value"); + return NULL; + } + if (m) + mask = PyGdkWindow_New(m); + else { + Py_INCREF(Py_None); + mask = Py_None; + } + return Py_BuildValue("(OO)", PyGdkWindow_New(p), PyGdkWindow_New(m)); +} + +static PyObject *_wrap_gtk_ctree_node_get_pixtext(PyObject *self, PyObject *args) { + PyObject *ctree, *node, *mask; + int col; + guint8 spacing; + char *text; + GdkPixmap *p; + GdkBitmap *m; + + if (!PyArg_ParseTuple(args, "O!O!i:gtk_ctree_node_get_pixtext", &PyGtk_Type, + &ctree, &PyGtkCTreeNode_Type, *node, &col)) + return NULL; + if (!gtk_ctree_node_get_pixtext(GTK_CTREE(PyGtk_Get(ctree)), + PyGtkCTreeNode_Get(node), col, + &text, &spacing, &p, &m)) { + PyErr_SetString(PyExc_ValueError, "can't get pixtext value"); + return NULL; + } + if (m) + mask = PyGdkWindow_New(m); + else { + Py_INCREF(Py_None); + mask = Py_None; + } + return Py_BuildValue("(siOO)", text, (int)spacing, + PyGdkWindow_New(p), mask); +} + +static PyObject *_wrap_gtk_ctree_get_node_info(PyObject *self, PyObject *args) { + PyObject *ctree, *node, *p_c, *m_c, *p_o, *m_o; + gchar *text; + guint8 spacing; + GdkPixmap *pixmap_closed, *pixmap_opened; + GdkBitmap *mask_closed, *mask_opened; + gboolean is_leaf, expanded; + + if (!PyArg_ParseTuple(args, "O!O!:gtk_ctree_get_node_info", &PyGtk_Type, + &ctree, &PyGtkCTreeNode_Type, &node)) + return NULL; + if (!gtk_ctree_get_node_info(GTK_CTREE(PyGtk_Get(ctree)), + PyGtkCTreeNode_Get(node), &text, &spacing, + &pixmap_closed, &mask_closed, &pixmap_opened, + &mask_opened, &is_leaf, &expanded)) { + PyErr_SetString(PyExc_ValueError, "can't retrieve node info"); + return NULL; + } + if (pixmap_closed) + p_c = PyGdkWindow_New(pixmap_closed); + else { + Py_INCREF(Py_None); + p_c = Py_None; + } + if (mask_closed) + m_c = PyGdkWindow_New(mask_closed); + else { + Py_INCREF(Py_None); + m_c = Py_None; + } + if (pixmap_opened) + p_o = PyGdkWindow_New(pixmap_opened); + else { + Py_INCREF(Py_None); + p_o = Py_None; + } + if (mask_opened) + m_o = PyGdkWindow_New(mask_opened); + else { + Py_INCREF(Py_None); + m_o = Py_None; + } + return Py_BuildValue("(siOOOOii)", text, (int)spacing, p_c, m_c, p_o, m_o, + (int)is_leaf, (int)expanded); +} + +static PyObject *_wrap_gtk_ctree_node_set_row_data(PyObject *self, PyObject *args) { + PyObject *ctree, *node, *data; + + if (!PyArg_ParseTuple(args, "O!O!O:gtk_ctree_node_set_row_data", &PyGtk_Type, + &ctree, &PyGtkCTreeNode_Type, &node, &data)) + return NULL; + Py_INCREF(data); + gtk_ctree_node_set_row_data_full(GTK_CTREE(PyGtk_Get(ctree)), + PyGtkCTreeNode_Get(node), data, + (GtkDestroyNotify)PyGtk_DestroyNotify); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gtk_ctree_node_get_row_data(PyObject *self, PyObject *args) { + PyObject *ctree, *node, *data; + + if (!PyArg_ParseTuple(args, "O!O!:gtk_ctree_node_get_row_data", &PyGtk_Type, + &ctree, &PyGtkCTreeNode_Type, *node)) + return NULL; + data = gtk_ctree_node_get_row_data(GTK_CTREE(PyGtk_Get(ctree)), + PyGtkCTreeNode_Get(node)); + if (!data) data = Py_None; + Py_INCREF(data); + return data; +} + +static PyObject *_wrap_gtk_ctree_base_nodes(PyObject *self, PyObject *args) { + PyObject *ctree, *ret; + GtkCTreeNode *node; + + if (!PyArg_ParseTuple(args, "O!:gtk_ctree_base_nodes", &PyGtk_Type, &ctree)) + return NULL; + /* the first row is always a base node */ + node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list); + ret = PyList_New(0); + while (node) { + PyList_Append(ret, PyGtkCTreeNode_New(node)); + node = GTK_CTREE_ROW(node)->sibling; + } + return ret; +} + +static PyMethodDef _gtkmoduleMethods[] = { + { "gtk_signal_connect", _wrap_gtk_signal_connect, 1 }, + { "gtk_signal_connect_after", _wrap_gtk_signal_connect_after, 1 }, + { "gtk_signal_disconnect_by_data", _wrap_gtk_signal_disconnect_by_data, 1 }, + { "gtk_signal_handler_block_by_data", _wrap_gtk_signal_handler_block_by_data, 1 }, + { "gtk_signal_handler_unblock_by_data", _wrap_gtk_signal_handler_unblock_by_data, 1 }, + { "gtk_signal_emitv_by_name", _wrap_gtk_signal_emitv_by_name, 1 }, + { "gtk_init", _wrap_gtk_init, 1 }, + { "gtk_main_iteration", _wrap_gtk_main_iteration, 1 }, + { "gtk_timeout_add", _wrap_gtk_timeout_add, 1 }, + { "gtk_idle_add", _wrap_gtk_idle_add, 1 }, + { "gtk_idle_add_priority", _wrap_gtk_idle_add_priority, 1 }, + { "gtk_idle_remove_function", _wrap_gtk_idle_remove_function, 1 }, + { "gtk_quit_add", _wrap_gtk_quit_add, 1 }, + { "gtk_quit_remove_function", _wrap_gtk_quit_remove_function, 1 }, + { "gtk_input_add", _wrap_gtk_input_add, 1 }, + { "gtk_object_set", _wrap_gtk_object_set, 1 }, + { "gtk_object_new", _wrap_gtk_object_new, 1 }, + { "gtk_object_get", _wrap_gtk_object_get, 1 }, + { "gtk_object_set_data", _wrap_gtk_object_set_data, 1 }, + { "gtk_object_get_data", _wrap_gtk_object_get_data, 1 }, + { "gtk_object_remove_data", _wrap_gtk_object_remove_data, 1 }, + { "gtk_widget_get_window", _wrap_gtk_widget_get_window, 1 }, + { "gtk_widget_draw", _wrap_gtk_widget_draw, 1 }, + { "gtk_widget_size_request", _wrap_gtk_widget_size_request, 1 }, + { "gtk_widget_size_allocate", _wrap_gtk_widget_size_allocate, 1 }, + { "gtk_widget_intersect", _wrap_gtk_widget_intersect, 1 }, + { "gtk_widget_get_pointer", _wrap_gtk_widget_get_pointer, 1 }, + { "gtk_container_add", _wrap_gtk_container_add, 1 }, + { "gtk_container_child_set", _wrap_gtk_container_child_set, 1 }, + { "gtk_container_child_get", _wrap_gtk_container_child_get, 1 }, + { "gtk_container_children", _wrap_gtk_container_children, 1 }, + { "gtk_window_set_icon", _wrap_gtk_window_set_icon, 1 }, + { "gtk_window_set_icon_name", _wrap_gtk_window_set_icon_name, 1 }, + { "gtk_box_query_child_packing", _wrap_gtk_box_query_child_packing, 1 }, + { "gtk_button_box_get_child_size_default", _wrap_gtk_button_box_get_child_size_default, 1 }, + { "gtk_button_box_get_child_ipadding_default", _wrap_gtk_button_box_get_child_ipadding_default, 1 }, + { "gtk_button_box_get_child_size", _wrap_gtk_button_box_get_child_size, 1 }, + { "gtk_button_box_get_child_ipadding", _wrap_gtk_button_box_get_child_ipadding, 1 }, + { "gtk_clist_get_selection", _wrap_gtk_clist_get_selection, 1 }, + { "gtk_clist_new_with_titles", _wrap_gtk_clist_new_with_titles, 1 }, + { "gtk_clist_get_text", _wrap_gtk_clist_get_text, 1 }, + { "gtk_clist_get_pixmap", _wrap_gtk_clist_get_pixmap, 1 }, + { "gtk_clist_get_pixtext", _wrap_gtk_clist_get_pixtext, 1 }, + { "gtk_clist_prepend", _wrap_gtk_clist_prepend, 1 }, + { "gtk_clist_append", _wrap_gtk_clist_append, 1 }, + { "gtk_clist_insert", _wrap_gtk_clist_insert, 1 }, + { "gtk_clist_set_row_data", _wrap_gtk_clist_set_row_data, 1 }, + { "gtk_clist_get_row_data", _wrap_gtk_clist_get_row_data, 1 }, + { "gtk_clist_find_row_from_data", _wrap_gtk_clist_find_row_from_data, 1 }, + { "gtk_clist_get_selection_info", _wrap_gtk_clist_get_selection_info, 1 }, + { "gtk_combo_set_popdown_strings", _wrap_gtk_combo_set_popdown_strings,1 }, + { "gtk_curve_get_vector", _wrap_gtk_curve_get_vector, 1 }, + { "gtk_curve_set_vector", _wrap_gtk_curve_set_vector, 1 }, + { "gtk_editable_insert_text", _wrap_gtk_editable_insert_text, 1 }, + { "gtk_frame_new", _wrap_gtk_frame_new, 1 }, + { "gtk_item_factory_create_items", _wrap_gtk_item_factory_create_items,1 }, + { "gtk_menu_popup", _wrap_gtk_menu_popup, 1 }, + { "gtk_pixmap_new_from_xpm", _wrap_gtk_pixmap_new_from_xpm, 1 }, + { "gtk_pixmap_get", _wrap_gtk_pixmap_get, 1 }, + { "gtk_radio_menu_item_new", _wrap_gtk_radio_menu_item_new, 1 }, + { "gtk_radio_menu_item_new_with_label", _wrap_gtk_radio_menu_item_new_with_label, 1 }, + { "gtk_radio_button_new", _wrap_gtk_radio_button_new, 1 }, + { "gtk_radio_button_new_with_label", _wrap_gtk_radio_button_new_with_label, 1 }, + { "gtk_text_insert_defaults", _wrap_gtk_text_insert_defaults, 1 }, + { "gtk_toolbar_append_item", _wrap_gtk_toolbar_append_item, 1 }, + { "gtk_toolbar_prepend_item", _wrap_gtk_toolbar_prepend_item, 1 }, + { "gtk_toolbar_insert_item", _wrap_gtk_toolbar_insert_item, 1 }, + { "gtk_label_get", _wrap_gtk_label_get, 1 }, + { "gtk_color_selection_get_color", _wrap_gtk_color_selection_get_color,1 }, + { "gtk_color_selection_set_color", _wrap_gtk_color_selection_set_color,1 }, + { "gtk_list_insert_items", _wrap_gtk_list_insert_items, 1 }, + { "gtk_list_append_items", _wrap_gtk_list_append_items, 1 }, + { "gtk_list_prepend_items", _wrap_gtk_list_prepend_items, 1 }, + { "gtk_list_remove_items", _wrap_gtk_list_remove_items, 1 }, + { "gtk_list_get_selection", _wrap_gtk_list_get_selection, 1 }, + { "gtk_tree_remove_items", _wrap_gtk_tree_remove_items, 1 }, + { "gtk_tree_get_selection", _wrap_gtk_tree_get_selection, 1 }, + { "gtk_spin_button_new_no_adj", _wrap_gtk_spin_button_new_no_adj, 1 }, + { "gtk_calendar_get_date", _wrap_gtk_calendar_get_date, 1 }, + { "gtk_notebook_query_tab_label_packing", _wrap_gtk_notebook_query_tab_label_packing, 1 }, + { "gtk_drag_dest_set", _wrap_gtk_drag_dest_set, 1 }, + { "gtk_drag_source_set", _wrap_gtk_drag_source_set, 1 }, + { "gtk_drag_begin", _wrap_gtk_drag_begin, 1 }, + { "gtk_ctree_new_with_titles", _wrap_gtk_ctree_new_with_titles, 1 }, + { "gtk_ctree_insert_node", _wrap_gtk_ctree_insert_node, 1 }, + { "gtk_ctree_find_by_row_data", _wrap_gtk_ctree_find_by_row_data, 1 }, + { "gtk_ctree_find_all_by_row_data", _wrap_gtk_ctree_find_all_by_row_data, 1 }, + { "gtk_ctree_move", _wrap_gtk_ctree_move, 1 }, + { "gtk_ctree_node_get_text", _wrap_gtk_ctree_node_get_text, 1 }, + { "gtk_ctree_node_get_pixmap", _wrap_gtk_ctree_node_get_pixmap, 1 }, + { "gtk_ctree_node_get_pixtext", _wrap_gtk_ctree_node_get_pixtext, 1 }, + { "gtk_ctree_get_node_info", _wrap_gtk_ctree_get_node_info, 1 }, + { "gtk_ctree_node_set_row_data", _wrap_gtk_ctree_node_set_row_data, 1 }, + { "gtk_ctree_node_get_row_data", _wrap_gtk_ctree_node_get_row_data, 1 }, + { "gtk_ctree_base_nodes", _wrap_gtk_ctree_base_nodes, 1 }, +#include "gtkmodule_defs.c" + { "gdk_pixmap_new", _wrap_gdk_pixmap_new, 1 }, + { "gdk_pixmap_create_from_xpm", _wrap_gdk_pixmap_create_from_xpm, 1 }, + { "gdk_pixmap_create_from_xpm_d", _wrap_gdk_pixmap_create_from_xpm_d, 1 }, + { "gdk_draw_polygon", _wrap_gdk_draw_polygon, 1 }, + { "gdk_draw_text", _wrap_gdk_draw_text, 1 }, + { "gdk_draw_points", _wrap_gdk_draw_points, 1 }, + { "gdk_draw_segments", _wrap_gdk_draw_segments, 1 }, + { "gdk_draw_lines", _wrap_gdk_draw_lines, 1 }, + { "gdk_color_alloc", _wrap_gdk_color_alloc, 1 }, + { NULL, NULL } +}; + +void init_gtk() { + PyObject *m, *d, *private; + m = Py_InitModule("_gtk", _gtkmoduleMethods); + d = PyModule_GetDict(m); + + /* initialise the boxed_funcs hash_table */ + boxed_funcs = g_hash_table_new(g_direct_hash, g_direct_equal); + + PyDict_SetItemString(d, "GtkObjectType", (PyObject *)&PyGtk_Type); + PyDict_SetItemString(d, "GtkAccelGroupType", + (PyObject *)&PyGtkAccelGroup_Type); + PyDict_SetItemString(d, "GtkStyleType", (PyObject *)&PyGtkStyle_Type); + PyDict_SetItemString(d, "GdkFontType", (PyObject *)&PyGdkFont_Type); + PyDict_SetItemString(d, "GdkColorType", (PyObject *)&PyGdkColor_Type); + PyDict_SetItemString(d, "GdkEventType", (PyObject *)&PyGdkEvent_Type); + PyDict_SetItemString(d, "GdkWindowType", (PyObject *)&PyGdkWindow_Type); + PyDict_SetItemString(d, "GdkGCType", (PyObject *)&PyGdkGC_Type); + PyDict_SetItemString(d, "GdkColormapType",(PyObject*)&PyGdkColormap_Type); + PyDict_SetItemString(d, "GdkDragContextType", + (PyObject *)&PyGdkDragContext_Type); + PyDict_SetItemString(d, "GtkSelectionDataType", + (PyObject *)&PyGtkSelectionData_Type); + PyDict_SetItemString(d, "GdkAtomType", (PyObject *)&PyGdkAtom_Type); + PyDict_SetItemString(d, "GdkCursorType", (PyObject *)&PyGdkCursor_Type); + PyDict_SetItemString(d, "GtkCTreeNodeType", + (PyObject *)&PyGtkCTreeNode_Type); + + private = PyDict_New(); + PyDict_SetItemString(d, "_private", private); Py_DECREF(private); + PyDict_SetItemString(private, "PyGtk_New", + d=PyCObject_FromVoidPtr(PyGtk_New, NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "PyGtkAccelGroup_New", + d=PyCObject_FromVoidPtr(PyGtkAccelGroup_New,NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "PyGtkStyle_New", + d=PyCObject_FromVoidPtr(PyGtkStyle_New,NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "PyGdkFont_New", + d=PyCObject_FromVoidPtr(PyGdkFont_New,NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "PyGdkColor_New", + d=PyCObject_FromVoidPtr(PyGdkColor_New,NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "PyGdkEvent_New", + d=PyCObject_FromVoidPtr(PyGdkEvent_New,NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "PyGdkWindow_New", + d=PyCObject_FromVoidPtr(PyGdkWindow_New,NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "PyGdkGC_New", + d=PyCObject_FromVoidPtr(PyGdkGC_New,NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "PyGdkColormap_New", + d=PyCObject_FromVoidPtr(PyGdkColormap_New,NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "PyGdkDragContext_New", + d=PyCObject_FromVoidPtr(PyGdkDragContext_New,NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "PyGtkSelectionData_New", + d=PyCObject_FromVoidPtr(PyGtkSelectionData_New,NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "PyGdkAtom_New", + d=PyCObject_FromVoidPtr(PyGdkAtom_New, NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "PyGdkCursor_New", + d=PyCObject_FromVoidPtr(PyGdkCursor_New, NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "PyGtkCTreeNode_New", + d=PyCObject_FromVoidPtr(PyGtkCTreeNode_New,NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "PyGtk_DestroyNotify", + d=PyCObject_FromVoidPtr(PyGtk_DestroyNotify,NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "PyGtk_CallbackMarshal", + d=PyCObject_FromVoidPtr(PyGtk_CallbackMarshal,NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "GtkArgs_AsTuple", + d=PyCObject_FromVoidPtr(GtkArgs_AsTuple,NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "GtkArgs_FromSequence", + d=PyCObject_FromVoidPtr(GtkArgs_FromSequence,NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "GtkArg_FromPyObject", + d=PyCObject_FromVoidPtr(GtkArg_FromPyObject,NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "GtkArg_AsPyObject", + d=PyCObject_FromVoidPtr(GtkArg_AsPyObject,NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "GtkRet_FromPyObject", + d=PyCObject_FromVoidPtr(GtkRet_FromPyObject,NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "GtkRet_AsPyObject", + d=PyCObject_FromVoidPtr(GtkRet_AsPyObject,NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "PyGtkEnum_get_value", + d=PyCObject_FromVoidPtr(PyGtkEnum_get_value, NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "PyGtkFlag_get_value", + d=PyCObject_FromVoidPtr(PyGtkFlag_get_value, NULL)); + Py_DECREF(d); + PyDict_SetItemString(private, "PyDict_AsGtkArgs", + d=PyCObject_FromVoidPtr(PyDict_AsGtkArgs, NULL)); + Py_DECREF(d); + + PyDict_SetItemString(private, "PyGtk_RegisterBoxed", + d=PyCObject_FromVoidPtr(PyGtk_RegisterBoxed, NULL)); + Py_DECREF(d); + + if (PyErr_Occurred()) + Py_FatalError("can't initialise module _gtk"); +} diff --git a/mkgtk.py b/mkgtk.py new file mode 100644 index 00000000..6a4be604 --- /dev/null +++ b/mkgtk.py @@ -0,0 +1,14 @@ +import sys +# add the generate directory to beginning of path ... +sys.path.insert(0, './generate') + +import generate + +p = generate.FilteringParser(input='generate/gtk.defs', + prefix='gtkmodule', + typeprefix='&') +p.addExcludeFile('generate/gtk.ignore') +p.addExcludeGlob('*_interp') +p.addExcludeGlob('*_visual') +p.startParsing() + diff --git a/pyglade/.cvsignore b/pyglade/.cvsignore new file mode 100644 index 00000000..c2831020 --- /dev/null +++ b/pyglade/.cvsignore @@ -0,0 +1,6 @@ +Makefile.in +Makefile +*~ +*.pyc +*.pyo + diff --git a/pyglade/Makefile.am b/pyglade/Makefile.am new file mode 100644 index 00000000..77ea0e49 --- /dev/null +++ b/pyglade/Makefile.am @@ -0,0 +1,3 @@ +pygladedir = $(pythondir)/pyglade + +pyglade_PYTHON = __init__.py build.py style.py xmlparse.py diff --git a/pyglade/__init__.py b/pyglade/__init__.py new file mode 100644 index 00000000..7e5267c4 --- /dev/null +++ b/pyglade/__init__.py @@ -0,0 +1,14 @@ +__all__ = ['build', 'style', 'xmlparse'] +import build, xmlparse + +def construct(filename): + tree = xmlparse.read(filename)['gtk-interface'] + wtree = build.WidgetTree(tree) + tree.destroy() + return wtree + +# for ni ... +try: + __.__dict__['construct'] = construct +except NameError: + pass diff --git a/pyglade/build.py b/pyglade/build.py new file mode 100644 index 00000000..cdc5f2b7 --- /dev/null +++ b/pyglade/build.py @@ -0,0 +1,724 @@ +"""This module is responsible for creating widgets from a +pyglade.xmhtml.TagTree. As opposed to the C code generation approach, +this will build the widget tree at runtime. There is nothing wrong with +the code generation approach, but this one is what I have decided to do. +I may write a code generator at some later point (the tag tree and style +generators are sufficiently general). +""" + +import sys +import string +from gtk import * +# the style sheet generator +import style + +error = "pyglade.build.error" + +# This is a dictionary of widget creation routines. +# It should have string keys representing widget classes, and a tuple as +# the value. The first function is for creation of this widget type. +# It should take one argument (the TagTree node), and returns a widget +# with those attributes. Note that it doesn't have to set the widget +# names or connect signal handlers (in fact it shouldn't do this). +# +# The second function is for adding a child to this container widget. If +# this widget class is not a container, the second item in the tuple should +# be None. If it is a container, the function should take as arguments the +# container, the child, and finally the 'child' TagTree node corresponding to +# the child widget (or None if there is no child TagTree node). + +_widgets = {} + +class WidgetTree: + def __init__(self, tree): + if tree.has_key('gtk-interface'): tree = tree['gtk-interface'] + if tree.tag != 'gtk-interface': + raise error, "first argument not the base of tag tree" + self.__signals = {} # signals + self.__widgets = {} # widgets by name + self.__paths = {} # widgets by path + self.tooltips = None + + # parse rc strings + if tree.has_key('style'): + rc_parse_string(style.as_string(tree)) + + # create widgets + if tree.has_key('widget'): + children = tree.widget + if type(children) != type(()): children = (children,) + for child in children: + self.__new_widget(child) + if self.tooltips: + self.tooltips.enable(); + + def get_widget(self, name): + if string.find(name, '.') == -1: # no dot + return self.__widgets[name] + else: + return self.__paths[name] + + def connect(self, signame, handler, *data): + self.__signals[signame] = (self.__signals[signame][0], data, + handler) + def disconnect(self, signame): + self.__signals[signame] = (self.__signals[signame][0], (),None) + + def __signal_handler(self, wid, *args): + signame = args[-1] + args = args[:-1] + objname, data, handler = self.__signals[signame] + if not handler: return + obj = self.__widgets[objname] + return apply(handler, (obj,) + args + data) + + def __new_widget(self, node, parent=''): + path = parent + '.' + node.name + wclass = node['class'] + if wclass == 'Placeholder': + sys.stderr.write( + "warning: placeholders still in description\n") + return + create, add = _widgets[wclass] + widget = create(node) + if node.has_key('name'): widget.set_name(node.name) + self.__widgets[node.name] = widget + self.__paths[path[:-1]] = widget + self.__set_common_params(widget, node) + + if node.has_key('signal'): + self.__setup_sighandlers(widget, node) + if node.has_key('widget'): + if not add: + raise error, "don't know how to add " + \ + "widgets to this container" + children = node.widget + if type(children) != type(()): children = (children,) + for child in children: + self.__new_widget(child, parent=path) + cwidget = self.get_widget(child.name) + add(widget, cwidget, child) + + # these can only be set after packing + has_default = child.get_bool('has_default', + FALSE) + if has_default: cwidget.grab_default() + has_focus = child.get_bool('has_focus', FALSE) + if has_focus: cwidget.grab_focus() + + if node.get_bool('visible', TRUE): + widget.show() + + def __set_common_params(self, widget, node): + width = node.get_int('width', -1) + height = node.get_int('height', -1) + if width != -1 or height != -1: + widget.set_usize(width, height) + sensitive = node.get_bool('sensitive', TRUE) + if not sensitive: + widget.set_sensitive(FALSE) + tooltip = node.get('tooltip', None) + if tooltip: + if not self.tooltips: self.tooltips = GtkTooltips() + self.tooltips.set_tip(widget, tooltip, '') + can_default = node.get_bool('can_default', FALSE) + if can_default: widget.set_flags(CAN_DEFAULT) + can_focus = node.get_bool('can_focus', FALSE) + if can_focus: widget.set_flags(CAN_FOCUS) + events = node.get_int('events', 0) + if events: widget.set_events(events) + extension = node.get('extension_events', None) + if extension: widget.set_extension_events(extension) + border_width = node.get_int('border_width', 0) + if border_width: widget.border_width(border_width) + + def __setup_sighandlers(self, widget, node): + signals = node.signal + if type(signals) != type(()): signals = (signals,) + for sig in signals: + signame = sig.name + self.__signals[sig.handler] = ( + sig.get('object', node.name), (), None) + if sig.get_bool('after', FALSE): + widget.connect_after(signame, + self.__signal_handler, + sig.handler) + else: + widget.connect(signame, self.__signal_handler, + sig.handler) + + +# These functions handle adding elements to the various container types +def container_add(cont, child, info): + cont.add(child) +def box_add(box, child, info): + info = info.child + expand = info.get_bool('expand', TRUE) + fill = info.get_bool('fill', TRUE) + padding = info.get_int('padding', 0) + if info.get('pack', 'GTK_PACK_START') == 'GTK_PACK_START': + box.pack_start(child, expand=expand, fill=fill,padding=padding) + else: + box.pack_end(child, expand=expand, fill=fill,padding=padding) +def table_add(table, child, info): + info = info.child + la = info.get_int('left_attach', 0) + ra = info.get_int('right_attach', 1) + ta = info.get_int('top_attach', 0) + ba = info.get_int('bottom_attach', 1) + xpad = info.get_int('xpad', 0) + ypad = info.get_int('ypad', 0) + xoptions=0 + yoptions=0 + if info.get_bool('xexpand', TRUE): xoptions = xoptions | EXPAND + if info.get_bool('xshrink', FALSE): xoptions = xoptions | SHRINK + if info.get_bool('xfill', TRUE): xoptions = xoptions | FILL + if info.get_bool('yexpand', TRUE): yoptions = yoptions | EXPAND + if info.get_bool('yshrink', FALSE): yoptions = yoptions | SHRINK + if info.get_bool('yfill', TRUE): yoptions = yoptions | FILL + table.attach(child, la,ra, ta,ba, xoptions=xoptions, yoptions=yoptions, + xpadding=xpad, ypadding=ypad) +def fixed_add(fix, child, info): + x = info.get_int('x', 0) + y = info.get_int('y', 0) + fix.put(child, x, y) +def clist_add(clist, child, info): + col = info.parent.get('col_no', 0) + info.parent['col_no'] = col + 1 + clist.set_column_widget(col, child) +def paned_add(paned, child, info): + pane = info.parent.get('pane2', FALSE) + info.parent['pane2'] = TRUE + if not pane: + paned.add1(child) + else: + paned.add2(child) +def notebook_add(book, child, info): + pages = info.parent.pages + if not info.has_key('child_name') or info.child_name != 'Notebook:tab': + pages.append(child) + else: + # child is a label + book.append_page(pages[0], child) + del pages[0] +def dialog_add(dlg, child, info): + # the widgets are already added + pass + +def menuitem_add(mi, menu, info): + mi.set_submenu(menu) +def menushell_add(menu, mi, info): + menu.append(mi) + +def misc_set(misc, info): + xalign = info.get_float('xalign', 0.5) + yalign = info.get_float('yalign', 0.5) + misc.set_alignment(xalign, yalign) + xpad = info.get_int('xpad', 0) + ypad = info.get_int('ypad', 0) + misc.set_padding(xpad, ypad) + + +def label_new(node): + str = node.get('label', '') + label = GtkLabel(str) + misc_set(label, node) + just = node.get('justify', JUSTIFY_CENTER) + label.set_justify(just) + return label +def entry_new(node): + ent = GtkEntry(maxlen=node.get_int('text_max_length', -1)) + if not node.get_bool('editable', TRUE): + ent.set_editable(FALSE) + if not node.get_bool('text_visible', TRUE): + ent.set_visibility(FALSE) + text = node.get('text', '') + if text: ent.set_text(text) + return ent +def text_new(node): + text = GtkText() + if not node.get_bool('editable', TRUE): + text.get_editable(FALSE) + t = node.get('text', '') + if t: + text.insert_text(t) + return text +def button_new(node): + label = node.get('label', '') + return GtkButton(label) +def togglebutton_new(node): + label = node.get('label', '') + tog = GtkToggleButton(label) + if node.get_bool('active', FALSE): + tog.set_state(TRUE) + return tog +def checkbutton_new(node): + label = node.get('label', '') + cb = GtkCheckButton(label) + if node.get_bool('active', FALSE): + cb.set_state(TRUE) + if not node.get_bool('draw_indicator', TRUE): + cb.set_mode(FALSE) + return cb +def radiobutton_new(node): + label = node.get('label', '') + # do something about radio button groups ... + rb = GtkRadioButton(label) + if node.get_bool('active', FALSE): + rb.set_state(TRUE) + if not node.get_bool('draw_indicator', TRUE): + rb.set_mode(FALSE) + return rb +def optionmenu_new(node): + menu = GtkOptionMenu() + # My XML parser won't do the <items> tag yet ... + return menu +def combo_new(node): + combo = GtkCombo() + if node.get_bool('case_sensitive', FALSE): + combo.set_case_sensitive(TRUE) + if not node.get_bool('use_arrows', TRUE): + combo.set_use_arrows(FALSE) + if node.get_bool('use_arrows_always', FALSE): + combo.set_use_arrows_always(TRUE) + return combo +def list_new(node): + list = GtkList() + mode = node.get('selection_mode', SELECTION_SINGLE) + list.set_selection_mode(mode) + return list +def clist_new(node): + numcols = node.get_int('columns', 1) + clist = GtkCList(numcols) + widths = node.get('column_widths', None) + if widths: + widths = map(string.atoi, string.split(widths, ',')) + for i in range(numcols): + clist.set_column_width(i, widths[i]) + if node.get_bool('show_titles', TRUE): + clist.column_titles_show() + mode = node.get('selection_mode', SELECTION_SINGLE) + clist.set_selection_mode(mode) + shadow = node.get('shadow_type', SHADOW_IN) + clist.set_border(shadow) + hpol = node.get('hscrollbar_policy', POLICY_ALWAYS) + vpol = node.get('vscrollbar_policy', POLICY_ALWAYS) + clist.set_policy(hpol, vpol) + return clist +def tree_new(node): + tree = GtkTree() + mode = node.get('selection_mode', SELECTION_SINGLE) + tree.set_selection_mode(mode) + mode = node.get('view_mode', TREE_VIEW_LINE) + tree.set_view_mode(mode) + if not node.get_bool('view_line', TRUE): + tree.set_view_lines(FALSE) + return tree +def spinbutton_new(node): + climb_rate = node.get_int('climb_rate', 1) + digits = node.get_int('digits', 0) + hvalue = node.get_float('hvalue', 1) + hlower = node.get_float('hlower', 0) + hupper = node.get_float('hupper', 100) + hstep = node.get_float('hstep', 1) + hpage = node.get_float('hpage', 10) + hpage_size = node.get_float('hpage_size', 10) + adj = GtkAdjustment(hvalue, hlower, hupper, hstep, hpage, hpage_size) + spin = GtkSpinButton(adj=adj, climb_rate=climb_rate, digits = digits) + spin.set_numeric(node.get_bool('numeric', FALSE)) + pol = node.get('update_policy', UPDATE_IF_VALID) + spin.set_update_policy(pol) + spin.set_snap_to_ticks(node.get_bool('snap', FALSE)) + spin.set_wrap(node.get_bool('wrap', FALSE)) + return spin +def hscale_new(node): + hvalue = node.get_float('hvalue', 1) + hlower = node.get_float('hlower', 0) + hupper = node.get_float('hupper', 100) + hstep = node.get_float('hstep', 1) + hpage = node.get_float('hpage', 10) + hpage_size = node.get_float('hpage_size', 10) + adj = GtkAdjustment(hvalue, hlower, hupper, hstep, hpage, hpage_size) + scale = GtkHScale(adj) + scale.set_draw_value(node.get_bool('draw_value', TRUE)) + scale.set_value_pos(node.get('value_pos', POS_TOP)) + scale.set_digits(node.get_int('digits', 1)) + scale.set_update_policy(node.get('policy', UPDATE_CONTINUOUS)) + return scale +def vscale_new(node): + hvalue = node.get_float('hvalue', 1) + hlower = node.get_float('hlower', 0) + hupper = node.get_float('hupper', 100) + hstep = node.get_float('hstep', 1) + hpage = node.get_float('hpage', 10) + hpage_size = node.get_float('hpage_size', 10) + adj = GtkAdjustment(hvalue, hlower, hupper, hstep, hpage, hpage_size) + scale = GtkVScale(adj) + scale.set_draw_value(node.get_bool('draw_value', TRUE)) + scale.set_value_pos(node.get('value_pos', POS_TOP)) + scale.set_digits(node.get_int('digits', 1)) + scale.set_update_policy(node.get('policy', UPDATE_CONTINUOUS)) + return scale +def hruler_new(node): + widget = GtkHRuler() + widget.set_metric(node.get('metric', PIXELS)) + lower = node.get_int('lower', 0) + upper = node.get_int('upper', 10) + pos = node.get_int('position', 0) + max = node.get_int('max_size', 10) + widget.set_range(lower, upper, pos, max) + return widget +def vruler_new(node): + widget = GtkVRuler() + widget.set_metric(node.get('metric', PIXELS)) + lower = node.get_int('lower', 0) + upper = node.get_int('upper', 10) + pos = node.get_int('position', 0) + max = node.get_int('max_size', 10) + widget.set_range(lower, upper, pos, max) + return widget +def hscrollbar_new(node): + hvalue = node.get_float('hvalue', 1) + hlower = node.get_float('hlower', 0) + hupper = node.get_float('hupper', 100) + hstep = node.get_float('hstep', 1) + hpage = node.get_float('hpage', 10) + hpage_size = node.get_float('hpage_size', 10) + adj = GtkAdjustment(hvalue, hlower, hupper, hstep, hpage, hpage_size) + scroll = GtkHScrollbar(adj) + scroll.set_update_policy(node.get('policy', UPDATE_CONTINUOUS)) + return scroll +def vscrollbar_new(node): + hvalue = node.get_float('hvalue', 1) + hlower = node.get_float('hlower', 0) + hupper = node.get_float('hupper', 100) + hstep = node.get_float('hstep', 1) + hpage = node.get_float('hpage', 10) + hpage_size = node.get_float('hpage_size', 10) + adj = GtkAdjustment(hvalue, hlower, hupper, hstep, hpage, hpage_size) + scroll = GtkVScrollbar(adj) + scroll.set_update_policy(node.get('policy', UPDATE_CONTINUOUS)) + return scroll +def statusbar_new(node): + return GtkStatusbar() +def toolbar_new(node): + orient = node.get('orientation', ORIENTATION_HORIZONTAL) + style = node.get('type', TOOLBAR_ICONS) + tool = GtkToolbar(orient, style) + tool.set_space_size(node.get_int('space_size', 5)) + tool.set_tooltips(node.get_bool('tooltips', TRUE)) + return tool +def progressbar_new(node): + return GtkProgressBar() +def arrow_new(node): + dir = node.get('arrow_type', ARROW_RIGHT) + shadow = node.get('shadow_type', SHADOW_OUT) + arr = GtkArrow(dir, shadow) + misc_set(arr, node) + return arr +# image not supported +def pixmap_new(node): + # the first parameter needs to be the toplevel widget + pix,bit = create_pixmap_from_xpm(None, None, node.get('filename', '')) + pixmap = GtkPixmap(pix, bit) + misc_set(pixmap) + return pixmap +def drawingarea_new(node): + return GtkDrawingArea() +def hseparator_new(node): + return GtkHSeparator() +def vseparator_new(node): + return GtkVSeparator() + +def menubar_new(node): + return GtkMenuBar() +def menu_new(node): + return GtkMenu() +def menuitem_new(node): + if node.has_key('label'): + ret = GtkMenuItem(node.label) + else: + ret = GtkMenuItem() + if node.get_bool('right_justify', FALSE): + ret.right_justify() + return ret +def checkmenuitem_new(node): + ret = GtkCheckMenuItem(node.label) + if node.get_bool('right_justify', FALSE): + ret.right_justify() + if node.get_bool('active', FALSE): + ret.set_state(TRUE) + if node.get_bool('always_show_toggle', FALSE): + ret.set_show_toggle(TRUE) + return ret +def radiomenuitem_new(node): + ret = GtkRadioMenuItem(node.label) + if node.get_bool('right_justify', FALSE): + ret.right_justify() + if node.get_bool('active', FALSE): + ret.set_state(TRUE) + if node.get_bool('always_show_toggle', FALSE): + ret.set_show_toggle(TRUE) + return ret + +def hbox_new(node): + if node.has_key('child_name') and node.child_name[:7] == 'Dialog:': + return node.__wid + homogeneous = node.get_bool('homogeneous', FALSE) + spacing = node.get_int('spacing', 0) + return GtkHBox(homogeneous=homogeneous, spacing=spacing) +def vbox_new(node): + if node.has_key('child_name') and node.child_name[:7] == 'Dialog:': + return node.__wid + homogeneous = node.get_bool('homogeneous', FALSE) + spacing = node.get_int('spacing', 0) + return GtkVBox(homogeneous=homogeneous, spacing=spacing) +def table_new(node): + rows = node.get_int('rows', 1) + cols = node.get_int('columns', 1) + homog = node.get_bool('homogeneous', FALSE) + table = GtkTable(rows, cols, homog) + table.set_row_spacings(node.get_int('row_spacing', 0)) + table.set_col_spacings(node.get_int('col_spacing', 0)) + return table +def fixed_new(node): + return GtkFixed() +def hbuttonbox_new(node): + bbox = GtkHButtonBox() + layout = node.get('layout_style', BUTTONBOX_DEFAULT_STYLE) + bbox.set_layout(layout) + spacing = node.get_int('child_min_width', None) + if spacing: bbox.set_spacing(spacing) + width, height = bbox.get_child_size_default() + width = node.get_int('child_min_width', width) + height = node.get_int('child_min_height', height) + bbox.set_child_size(width, height) + ipx, ipy = bbox.get_child_ipadding_default() + ipx = node.get_int('child_ipad_x', ipx) + ipy = node.get_int('child_ipad_y', ipy) + bbox.set_child_ipadding(ipx, ipy) + return bbox +def vbuttonbox_new(node): + bbox = GtkVButtonBox() + layout = node.get('layout_style', BUTTONBOX_DEFAULT_STYLE) + bbox.set_layout(layout) + spacing = node.get_int('child_min_width', None) + if spacing: bbox.set_spacing(spacing) + width, height = bbox.get_child_size_default() + width = node.get_int('child_min_width', width) + height = node.get_int('child_min_height', height) + bbox.set_child_size(width, height) + ipx, ipy = bbox.get_child_ipadding_default() + ipx = node.get_int('child_ipad_x', ipx) + ipy = node.get_int('child_ipad_y', ipy) + bbox.set_child_ipadding(ipx, ipy) + return bbox +def frame_new(node): + label = node.get('label', '') + frame = GtkFrame(label) + xalign = node.get_int('label_xalign', 0) + frame.set_label_align(xalign, 0.5) + shadow = node.get('shadow_type', SHADOW_ETCHED_IN) + frame.set_shadow_type(shadow) + return frame +def aspectframe_new(node): + xalign = node.get_int('xalign', 0) + yalign = node.get_int('yalign', 0) + ratio = node.get_float('ratio', 1) + obey = node.get_bool('obey_child', TRUE) + frame = GtkAspectFrame(xalign, yalign, ratio, obey_child) + label = node.get('label', '') + if label: frame.set_label(label) + xalign = node.get_int('label_xalign', 0) + frame.set_label_align(xalign, 0.5) + shadow = node.get('shadow_type', SHADOW_ETCHED_IN) + frame.set_shadow_type(shadow) + return frame +def hpaned_new(node): + paned = GtkHPaned() + handle_size = node.get_int('handle_size', 0) + if handle_size: paned.handle_size(handle_size) + gutter_size = node.get_int('gutter_size', 0) + if gutter_size: paned.gutter_size(gutter_size) + return paned +def vpaned_new(node): + paned = GtkVPaned() + handle_size = node.get_int('handle_size', 0) + if handle_size: paned.handle_size(handle_size) + gutter_size = node.get_int('gutter_size', 0) + if gutter_size: paned.gutter_size(gutter_size) + return paned +def handlebox_new(node): + return GtkHandleBox() +def notebook_new(node): + book = GtkNotebook() + book.set_show_tabs(node.get_bool('show_tabs', TRUE)) + book.set_show_border(node.get_bool('show_border', TRUE)) + book.set_tab_pos(node.get('tab_pos', POS_TOP)) + book.set_scrollable(node.get_bool('scrollable', FALSE)) + book.set_tab_border(node.get_int('tab_border', 3)) + book.popup_enable(node.get_bool('popup_enable', FALSE)) + node['pages'] = [] + return book +def alignment_new(node): + xalign = node.get_float('xalign', 0.5) + yalign = node.get_float('yalign', 0.5) + xscale = node.get_float('xscale', 0) + yscale = node.get_float('yscale', 0) + return GtkAlignment(xalign, yalign, xscale, yscale) +def eventbox_new(node): + return GtkEventBox() +def scrolledwindow_new(node): + win = GtkScrolledWindow() + shadow = node.get('shadow_type', SHADOW_IN) + win.set_shadow_type(shadow) + hpol = node.get('hscrollbar_policy', POLICY_ALWAYS) + vpol = node.get('vscrollbar_policy', POLICY_ALWAYS) + win.set_policy(hpol, vpol) + # do something about update policies here ... + return win +def viewport_new(node): + port = GtkViewport() + shadow = node.get('shadow_type', SHADOW_IN) + port.set_shadow_type(shadow) + return port + +def curve_new(node): + curve = GtkCurve() + curve.set_curve_type(node.get('curve_type', CURVE_TYPE_SPLINE)) + minx = node.get_float('min_x', 0) + maxx = node.get_float('max_x', 1) + miny = node.get_float('min_y', 0) + maxy = node.get_float('max_y', 1) + curve.set_range(minx, maxx, miny, maxy) + return curve +def gammacurve_new(node): + gamma = GtkGammaCurve() + # do something about the curve parameters ... + return gamma +def colorselection_new(node): + cs = GtkColorSelection() + cs.set_update_policy(node.get('policy', UPDATE_CONTINUOUS)) + return cs +def preview_new(node): + type = node.get('type', PREVIEW_COLOR) + prev = GtkPreview(type) + prev.set_expand(node.get_bool('expand', TRUE)) + return prev + +def window_new(node): + wintype = node.get('type', 'toplevel') + widget = GtkWindow(wintype) + widget.set_title(node.get('title', node.name)) + x = node.get_int('x', -1) + y = node.get_int('y', -1) + if x != -1 or y != -1: + widget.set_uposition(x, y) + pos = node.get('position', None) + if pos: widget.position(pos) + ashrink = node.get_bool('allow_shrink', TRUE) + agrow = node.get_bool('allow_grow', TRUE) + autoshrink = node.get_bool('auto_shrink', FALSE) + if not ashrink or not agrow or autoshrink: + widget.set_policy(ashrink, agrow, autoshrink) + return widget +def dialog_new(node): + widget = GtkDialog() + widget.set_title(node.get('title', node.name)) + x = node.get_int('x', -1) + y = node.get_int('y', -1) + if x != -1 or y != -1: + widget.set_uposition(x, y) + pos = node.get('position', None) + if pos: widget.position(pos) + ashrink = node.get_bool('allow_shrink', TRUE) + agrow = node.get_bool('allow_grow', TRUE) + autoshrink = node.get_bool('auto_shrink', FALSE) + if not ashrink or not agrow or autoshrink: + widget.set_policy(ashrink, agrow, autoshrink) + # do some weird stuff because the vbox/action area is already created + node.widget['__wid'] = widget.vbox + children = node.widget.widget + if type(children) != type(()): children = (children,) + for i in range(len(children)): + if children[i].has_key('child_name') and \ + children[i].child_name == 'Dialog:action_area': + node['widget'] = (node.widget, children[i]) + children[i].parent = node + children[i]['__wid'] = widget.action_area + node.widget[0]['widget'] = children[0:i]+children[i+1:] + break + return widget +def colorselectiondialog_new(node): + return GtkColorSelectionDialog() + + +_widgets = { + # widgets ... + 'GtkLabel': (label_new, None), + 'GtkEntry': (entry_new, None), + 'GtkText': (text_new, None), + 'GtkButton': (button_new, None), + 'GtkToggleButton': (togglebutton_new, None), + 'GtkCheckButton': (checkbutton_new, None), + 'GtkRadioButton': (radiobutton_new, None), + 'GtkOptionMenu': (optionmenu_new, None), + 'GtkCombo': (combo_new, None), + 'GtkList': (list_new, None), + 'GtkCList': (clist_new, clist_add), + 'GtkTree': (tree_new, None), + 'GtkSpinButton': (spinbutton_new, None), + 'GtkHScale': (hscale_new, None), + 'GtkVScale': (vscale_new, None), + 'GtkHRuler': (hruler_new, None), + 'GtkVRuler': (vruler_new, None), + 'GtkHScrollbar': (hscrollbar_new, None), + 'GtkVScrollbar': (vscrollbar_new, None), + 'GtkStatusbar': (statusbar_new, None), + 'GtkToolbar': (toolbar_new, None), + 'GtkProgressBar': (progressbar_new, None), + 'GtkArrow': (arrow_new, None), + 'GtkPixmap': (pixmap_new, None), + 'GtkDrawingArea': (drawingarea_new, None), + 'GtkHSeparator': (hseparator_new, None), + 'GtkVSeparator': (vseparator_new, None), + + # Menu stuff ... + 'GtkMenuBar': (menubar_new, menushell_add), + 'GtkMenu': (menu_new, menushell_add), + 'GtkMenuItem': (menuitem_new, menuitem_add), + 'GtkCheckMenuItem':(checkmenuitem_new,menuitem_add), + 'GtkRadioMenuItem':(radiomenuitem_new,menuitem_add), + + # Containers ... + 'GtkHBox': (hbox_new, box_add), + 'GtkVBox': (vbox_new, box_add), + 'GtkTable': (table_new, table_add), + 'GtkFixed': (fixed_new, fixed_add), + 'GtkHButtonBox': (hbuttonbox_new, container_add), + 'GtkVButtonBox': (vbuttonbox_new, container_add), + 'GtkFrame': (frame_new, container_add), + 'GtkAspectFrame': (aspectframe_new, container_add), + 'GtkHPaned': (hpaned_new, paned_add), + 'GtkVPaned': (vpaned_new, paned_add), + 'GtkHandleBox': (handlebox_new, container_add), + 'GtkNotebook': (notebook_new, notebook_add), + 'GtkAlignment': (alignment_new, container_add), + 'GtkEventBox': (eventbox_new, container_add), + 'GtkScrolledWindow': (scrolledwindow_new, container_add), + 'GtkViewport': (viewport_new, container_add), + + # Miscellaneous ... + 'GtkCurve': (curve_new, None), + 'GtkGammaCurve': (gammacurve_new, None), + 'GtkColorSelection': (colorselection_new, None), + 'GtkPreview': (preview_new, None), + + # Windows ... + 'GtkWindow': (window_new, container_add), + 'GtkDialog': (dialog_new, dialog_add), + 'GtkColorSelectionDialog': (colorselectiondialog_new, None), +} + + + diff --git a/pyglade/style.py b/pyglade/style.py new file mode 100644 index 00000000..d0215c25 --- /dev/null +++ b/pyglade/style.py @@ -0,0 +1,77 @@ +"""This file creates a GTK rc file to work with a widget tree created from +the XML output of GLADE. + +It outputs both the style definitions, and links to the names of the widgets +that use it. The style namesare of the form "PyGLADE_<name>_style". Then +there is a number of "widget <path> style PyGLADE_<name>_style" lines that +bind the styles to particular widgets. +""" +import string + +# Get the fastest implementation of StringIO ... +try: + from cStringIO import StringIO +except ImportError: + from StringIO import StringIO + +error = 'pyglade.style.error' + +def convert_colour(str): + r, g, b = map(string.atoi, string.split(str, ',')) + return "{ %.3f, %.3f, %.3f }" % (r/255.0, g/255.0, b/255.0) + +def output_widget_names(fp, widget, parent): + parent = parent + '.' + widget.name + if widget.has_key('style_name'): + fp.write('widget "%s" style "PyGLADE_%s_style"\n' % + (parent[1:], widget.style_name)) + if not widget.has_key('widget'): + return + children = widget.widget + if type(children) != type(()): children = (children,) + for child in children: + output_widget_names(fp, child, parent) + +def write_stream(tree, fp): + if tree.has_key('gtk-interface'): + # let the user off if they just used the top of the parse tree + # instead of the GTK-Interface node + tree = tree['gtk-interface'] + if tree.tag != 'gtk-interface': + raise error, "Not at the top node of the GLADE output" + + styles = tree.style + if type(styles) != type(()): styles = (styles,) + for style in styles: + name = "PyGLADE_" + style.style_name + "_style" + fp.write('style "%s"\n{\n' % (name,)) + if style.has_key('style_font'): + fp.write(' font = "%s"\n' % (style.style_font,)) + for state in ('NORMAL', 'ACTIVE', 'PRELIGHT', + 'SELECTED', 'INSENSITIVE'): + for colour in 'fg', 'bg', 'text', 'base': + key = colour + ':' + string.lower(state) + if style.has_key(key): + cstr = convert_colour(style[key]) + fp.write(" %s[%s] = %s\n" % ( + colour, string.upper(state), + cstr)) + key = "bg_pixmap:" + state + if style.has_key(key): + fp.write(" bg_pixmap[%s] = \"%s\"\n" % ( + state, style[key])) + fp.write("}\n\n") + if not tree.has_key('widget'): + return + children = tree.widget + if type(children) != type(()): children = (children,) + for child in children: + output_widget_names(fp, child, '') + +def write(tree, fname): + write_stream(tree, open(fname, "w")) + +def as_string(tree): + fp = StringIO() + write_stream(tree, fp) + return fp.getvalue() diff --git a/pyglade/xmlparse.py b/pyglade/xmlparse.py new file mode 100644 index 00000000..59abbde7 --- /dev/null +++ b/pyglade/xmlparse.py @@ -0,0 +1,145 @@ +"""This file contains a simple parser for the XML output of GLADE. + +It is not a true XML parser, since it requires tags to be of the form + + <tag> + <tag2>data</tag2> + </tag> + +That is tags with embeded tags in them must have the opening tag on a single +line, and the closing tag on another line by itself. Tags with no embedded +tags should have openning tag, data and closing tag all on one line. Also +tag attributes are not supported. Yes I know this is a bit lame, but it is +the minimum required for reading GLADE output. + +This module is not really glade specific, except that it can read GLADE +output (it can probably also read some other types of XML documents) + +You should call one of read(fname), read_stream(fp) or read_string(str). +The output is a tree of TagTree. Tags of a node can be accessed either as +attributes (eg node.tag) or as list items (eg node['tag']). If there was +more than one of that tag name at this level, they will be returned as a +tuple by the previous two methods. +""" + +import string +import regex + +# StringIO module for parsing an XML document stored in a string. We pick +# the faster cStringIO implementation if present. +try: + from cStringIO import StringIO +except ImportError: + from StringIO import StringIO + +error = "pyglade.xmlparse.error" + +comment_line = regex.compile('<\\?.*>') +# data_tag must be checked first, since open_tag and close_tag will match +# the same strings data_tag matches. +data_tag = regex.compile('<\([^>]+\)>\(.*\)</\([^>]+\)>') +open_tag = regex.compile('<\([^/>][^>]*\)>') +close_tag = regex.compile('</\([^>]+\)>') + +class TagTree: + def __init__(self, parent, tag): + self.parent = parent + self.tag = tag + self.__tags = {} + def __getitem__(self, key): + return self.__tags[key] + __getattr__ = __getitem__ + def __setitem__(self, key, value): + self.__tags[key] = value + def __len__(self): + return len(self.__tags) + def has_key(self, key): + return self.__tags.has_key(key) + def keys(self): + return self.__tags.keys() + def get(self, key, default): + if self.__tags.has_key(key): + return self.__tags[key] + else: + return default + def get_bool(self, key, default=0): + if self.__tags.has_key(key): + return string.lower(self.__tags[key]) == 'true' + else: + return default + def get_int(self, key, default=0): + if self.__tags.has_key(key): + return string.atoi(self.__tags[key]) + else: + return default + def get_float(self, key, default=0.0): + if self.__tags.has_key(key): + return string.atof(self.__tags[key]) + else: + return default + def destroy(self): + # This is required to break a dependency loop + del self.parent + for key in self.__tags.keys(): + vals = self.__tags[key] + if type(vals) != type(()): vals = (vals,) + for val in vals: + if hasattr(val, 'destroy'): val.destroy() + del self.__tags[key] + +def read_stream(fp): + base = TagTree(parent=None, tag='XML-Base') + cstack = [base] + line = fp.readline() + while line: + if comment_line.search(line) >= 0 or line == '\n': + pass + elif data_tag.search(line) >= 0: + key = string.lower(data_tag.group(1)) + data = data_tag.group(2) + end = string.lower(data_tag.group(3)) + if key != end: + raise error, "unmatching tags: %s and %s" % \ + (key, end) + if cstack[-1].has_key(key): + oldval = cstack[-1][key] + if type(oldval) == type(()): + cstack[-1][key] = oldval + (data,) + else: + cstack[-1][key] = (oldval, data) + else: + cstack[-1][key] = data + elif open_tag.search(line) >= 0: + key = string.lower(open_tag.group(1)) + tree = TagTree(parent=cstack[-1], tag=key) + if cstack[-1].has_key(key): + oldval = cstack[-1][key] + if type(oldval) == type(()): + cstack[-1][key] = oldval + (tree,) + else: + cstack[-1][key] = (oldval, tree) + else: + cstack[-1][key] = tree + cstack.append(tree) + elif close_tag.search(line) >= 0: + key = string.lower(close_tag.group(1)) + if not cstack: + raise error, "no tags to match " + key + if key != cstack[-1].tag: + raise error, \ + "unmatching container tags: %s and %s" %\ + (cstack[-1].type, key) + del cstack[-1] + else: + raise error, "unparseable line: " + line + line = fp.readline() + if len(cstack) != 1: + raise error, "some unclosed tags are present" + return base + +def read(fname): + return read_stream(open(fname, "r")) + +def read_string(string): + return read_stream(StringIO(string)) + diff --git a/pygtk.spec b/pygtk.spec new file mode 100644 index 00000000..a146b9ab --- /dev/null +++ b/pygtk.spec @@ -0,0 +1,45 @@ +%define py_prefix /usr +# py_ver should only be 3 characters (1.5.1 == 1.5) +%define py_ver 1.5 +%define ver 0.5.6 + +Summary: Python bindings for the GTK+ widget set. +Name: pygtk +Version: %ver +Release: 1 +Copyright: GPL +Group: X11/Libraries +Source: ftp://ftp.daa.com.au/pub/james/python/pygtk-%{ver}.tar.gz +BuildRoot: /tmp/pygtk-root +Packager: James Henstridge <james@daa.com.au> +Requires: gtk+ imlib python + +%description +PyGTK is an extension module for python that gives you access to the GTK+ +widget set. Just about anything you can write in C with GTK+ you can write +in python with PyGTK (within reason), but with all of python's benefits. + +%prep +%setup +./configure + +%build +make + +%install +rm -rf $RPM_BUILD_ROOT +make DESTDIR=$RPM_BUILD_ROOT install + +%files +%{py_prefix}/lib/python%{py_ver}/site-packages/gtk.py* +%{py_prefix}/lib/python%{py_ver}/site-packages/Gtkinter.py* +%{py_prefix}/lib/python%{py_ver}/site-packages/GtkExtra.py* +%{py_prefix}/lib/python%{py_ver}/site-packages/GTK.py* +%{py_prefix}/lib/python%{py_ver}/site-packages/GDK.py* +%{py_prefix}/lib/python%{py_ver}/site-packages/GdkImlib.py* +%{py_prefix}/lib/python%{py_ver}/site-packages/pyglade/*.py* + +%{py_prefix}/lib/python%{py_ver}/site-packages/_gtkmodule.so +%{py_prefix}/lib/python%{py_ver}/site-packages/_gdkimlibmodule.so + +%doc AUTHORS NEWS README ChangeLog description.py |