From: John Darrington Date: Sat, 27 May 2017 18:48:48 +0000 (+0200) Subject: Removed GtkXPaned which is currently not used X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=62441bcb7d0655eea77ac52327030afc8ed224a6 Removed GtkXPaned which is currently not used --- diff --git a/lib/automake.mk b/lib/automake.mk index 0344235819..690304e73c 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -2,7 +2,3 @@ include $(top_srcdir)/lib/linreg/automake.mk include $(top_srcdir)/lib/tukey/automake.mk - -if HAVE_GUI -include $(top_srcdir)/lib/gtk-contrib/automake.mk -endif diff --git a/lib/gtk-contrib/COPYING.LESSER b/lib/gtk-contrib/COPYING.LESSER deleted file mode 100644 index 8add30ad59..0000000000 --- a/lib/gtk-contrib/COPYING.LESSER +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/lib/gtk-contrib/README b/lib/gtk-contrib/README deleted file mode 100644 index c3ffaf2c66..0000000000 --- a/lib/gtk-contrib/README +++ /dev/null @@ -1,5 +0,0 @@ -This is not part of the GNU PSPP program, but is used with GNU PSPP. - -This directory contains a version of the GtkXPaned widget. It includes -minor modifications. GtkXPaned is licensed under the GNU Lesser -General Public License. See COPYING.LESSER. diff --git a/lib/gtk-contrib/automake.mk b/lib/gtk-contrib/automake.mk deleted file mode 100644 index dd7d89fb88..0000000000 --- a/lib/gtk-contrib/automake.mk +++ /dev/null @@ -1,14 +0,0 @@ -## Process this file with automake to produce Makefile.in -*- makefile -*- - -noinst_LIBRARIES += lib/gtk-contrib/libxpaned.a - -lib_gtk_contrib_libxpaned_a_CFLAGS = $(GTK_CFLAGS) -Wall -DGDK_MULTIHEAD_SAFE=1 - -lib_gtk_contrib_libxpaned_a_SOURCES = \ - lib/gtk-contrib/gtkxpaned.c \ - lib/gtk-contrib/gtkxpaned.h - -EXTRA_DIST += \ - lib/gtk-contrib/README \ - lib/gtk-contrib/COPYING.LESSER - diff --git a/lib/gtk-contrib/gtkxpaned.c b/lib/gtk-contrib/gtkxpaned.c deleted file mode 100644 index 06f642a24e..0000000000 --- a/lib/gtk-contrib/gtkxpaned.c +++ /dev/null @@ -1,3440 +0,0 @@ -/******************************************************************************* - **3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 - ** 10 20 30 40 50 60 70 80 - ** - ** library for GtkXPaned-widget, a 2x2 grid-like variation of GtkPaned of gtk+ - ** Copyright (C) 2012, 2013 Free Software Foundation, Inc. - ** Copyright (C) 2005-2006 Mirco "MacSlow" Müller - ** - ** This library is free software; you can redistribute it and/or - ** modify it under the terms of the GNU Lesser General Public - ** License as published by the Free Software Foundation; either - ** version 2.1 of the License, or (at your option) any later version. - ** - ** This library is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - ** Lesser General Public License for more details. - ** - ** You should have received a copy of the GNU Lesser General Public - ** License along with this library; if not, write to the Free Software - ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - ** - ** GtkXPaned is based on GtkPaned which was done by... - ** - ** "Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald" - ** - ** and later modified by... - ** - ** "the GTK+ Team and others 1997-2000" - ** - *******************************************************************************/ - -#include -#include "gtkxpaned.h" - -#include -#include -#include -#include - -enum WidgetProperties - { - PROP_0, - PROP_X_POSITION, - PROP_Y_POSITION, - PROP_POSITION_SET, - PROP_MIN_X_POSITION, - PROP_MIN_Y_POSITION, - PROP_MAX_X_POSITION, - PROP_MAX_Y_POSITION - }; - -enum ChildProperties - { - CHILD_PROP_0, - CHILD_PROP_RESIZE, - CHILD_PROP_SHRINK, - CHILD_PROP_LEFT_ATTACH, - CHILD_PROP_TOP_ATTACH - }; - -enum WidgetSignals - { - CYCLE_CHILD_FOCUS, - TOGGLE_HANDLE_FOCUS, - MOVE_HANDLE, - CYCLE_HANDLE_FOCUS, - ACCEPT_POSITION, - CANCEL_POSITION, - LAST_SIGNAL - }; - -static void gtk_xpaned_class_init (GtkXPanedClass * klass); - -static void gtk_xpaned_init (GtkXPaned * xpaned); - -static void -gtk_xpaned_get_preferred_width (GtkWidget *widget, - gint *minimal_width, - gint *natural_width) -{ - GtkXPaned *xpaned = GTK_XPANED (widget); - gint tl[2], tr[2], bl[2], br[2]; - gint overhead; - gint w[2]; - int i; - - if (xpaned->top_left_child - && gtk_widget_get_visible (xpaned->top_left_child)) - gtk_widget_get_preferred_width (xpaned->top_left_child, &tl[0], &tl[1]); - else - tl[0] = tl[1] = 0; - - if (xpaned->top_right_child - && gtk_widget_get_visible (xpaned->top_right_child)) - gtk_widget_get_preferred_width (xpaned->top_right_child, &tr[0], &tr[1]); - else - tr[0] = tr[1] = 0; - - if (xpaned->bottom_left_child - && gtk_widget_get_visible (xpaned->bottom_left_child)) - gtk_widget_get_preferred_width (xpaned->bottom_left_child, &bl[0], &bl[1]); - else - bl[0] = bl[1] = 0; - - if (xpaned->bottom_right_child - && gtk_widget_get_visible (xpaned->bottom_right_child)) - gtk_widget_get_preferred_width (xpaned->bottom_right_child, - &br[0], &br[1]); - else - br[0] = br[1] = 0; - - /* add 2 times the set border-width to the GtkXPaneds requisition */ - overhead = gtk_container_get_border_width (GTK_CONTAINER (xpaned)) * 2; - - /* also add the handle "thickness" to GtkXPaned's width requisition */ - if (xpaned->top_left_child - && gtk_widget_get_visible (xpaned->top_left_child) - && xpaned->top_right_child - && gtk_widget_get_visible (xpaned->top_right_child) - && xpaned->bottom_left_child - && gtk_widget_get_visible (xpaned->bottom_left_child) - && xpaned->bottom_right_child - && gtk_widget_get_visible (xpaned->bottom_right_child)) - { - gint handle_size; - - gtk_widget_style_get (widget, "handle-size", &handle_size, NULL); - overhead += handle_size; - } - - for (i = 0; i < 2; i++) - w[i] = (br[i] ? br[i] : MAX (tl[i] + tr[i], bl[i])) + overhead; - - *minimal_width = w[0]; - *natural_width = w[1]; -} - -static void -gtk_xpaned_get_preferred_height (GtkWidget *widget, - gint *minimal_height, - gint *natural_height) -{ - GtkXPaned *xpaned = GTK_XPANED (widget); - gint tl[2], tr[2], bl[2], br[2]; - gint overhead; - gint h[2]; - int i; - - if (xpaned->top_left_child - && gtk_widget_get_visible (xpaned->top_left_child)) - gtk_widget_get_preferred_height (xpaned->top_left_child, &tl[0], &tl[1]); - else - tl[0] = tl[1] = 0; - - if (xpaned->top_right_child - && gtk_widget_get_visible (xpaned->top_right_child)) - gtk_widget_get_preferred_height (xpaned->top_right_child, &tr[0], &tr[1]); - else - tr[0] = tr[1] = 0; - - if (xpaned->bottom_left_child - && gtk_widget_get_visible (xpaned->bottom_left_child)) - gtk_widget_get_preferred_height (xpaned->bottom_left_child, - &bl[0], &bl[1]); - else - bl[0] = bl[1] = 0; - - if (xpaned->bottom_right_child - && gtk_widget_get_visible (xpaned->bottom_right_child)) - gtk_widget_get_preferred_height (xpaned->bottom_right_child, - &br[0], &br[1]); - else - br[0] = br[1] = 0; - - /* add 2 times the set border-width to the GtkXPaneds requisition */ - overhead = gtk_container_get_border_width (GTK_CONTAINER (xpaned)) * 2; - - /* also add the handle "thickness" to GtkXPaned's height-requisition */ - if (xpaned->top_left_child - && gtk_widget_get_visible (xpaned->top_left_child) - && xpaned->top_right_child - && gtk_widget_get_visible (xpaned->top_right_child) - && xpaned->bottom_left_child - && gtk_widget_get_visible (xpaned->bottom_left_child) - && xpaned->bottom_right_child - && gtk_widget_get_visible (xpaned->bottom_right_child)) - { - gint handle_size; - - gtk_widget_style_get (widget, "handle-size", &handle_size, NULL); - overhead += handle_size; - } - - for (i = 0; i < 2; i++) - h[i] = (br[i] ? br[i] : bl[i] + MAX (tl[i], tr[i])) + overhead; - - *minimal_height = h[0]; - *natural_height = h[1]; -} - -static void gtk_xpaned_size_allocate (GtkWidget * widget, - GtkAllocation * allocation); - -static void gtk_xpaned_set_property (GObject * object, - guint prop_id, - const GValue * value, - GParamSpec * pspec); - -static void gtk_xpaned_get_property (GObject * object, - guint prop_id, - GValue * value, GParamSpec * pspec); - -static void gtk_xpaned_set_child_property (GtkContainer * container, - GtkWidget * child, - guint property_id, - const GValue * value, - GParamSpec * pspec); - -static void gtk_xpaned_get_child_property (GtkContainer * container, - GtkWidget * child, - guint property_id, - GValue * value, - GParamSpec * pspec); - -static void gtk_xpaned_finalize (GObject * object); - -static void gtk_xpaned_realize (GtkWidget * widget); - -static void gtk_xpaned_unrealize (GtkWidget * widget); - -static void gtk_xpaned_map (GtkWidget * widget); - -static void gtk_xpaned_unmap (GtkWidget * widget); - -static gboolean gtk_xpaned_draw (GtkWidget * widget, - cairo_t *ct); - -static gboolean gtk_xpaned_enter (GtkWidget * widget, - GdkEventCrossing * event); - -static gboolean gtk_xpaned_leave (GtkWidget * widget, - GdkEventCrossing * event); - -static gboolean gtk_xpaned_button_press (GtkWidget * widget, - GdkEventButton * event); - -static gboolean gtk_xpaned_button_release (GtkWidget * widget, - GdkEventButton * event); - -static gboolean gtk_xpaned_motion (GtkWidget * widget, - GdkEventMotion * event); - -static gboolean gtk_xpaned_focus (GtkWidget * widget, - GtkDirectionType direction); - -static void gtk_xpaned_add (GtkContainer * container, GtkWidget * widget); - -static void gtk_xpaned_remove (GtkContainer * container, GtkWidget * widget); - -static void gtk_xpaned_forall (GtkContainer * container, - gboolean include_internals, - GtkCallback callback, gpointer callback_data); - -static void gtk_xpaned_set_focus_child (GtkContainer * container, - GtkWidget * child); - -static void gtk_xpaned_set_saved_focus (GtkXPaned * xpaned, - GtkWidget * widget); - -static void gtk_xpaned_set_first_xpaned (GtkXPaned * xpaned, - GtkXPaned * first_xpaned); - -static void gtk_xpaned_set_last_top_left_child_focus (GtkXPaned * xpaned, - GtkWidget * widget); - -static void gtk_xpaned_set_last_top_right_child_focus (GtkXPaned * xpaned, - GtkWidget * widget); - -static void gtk_xpaned_set_last_bottom_left_child_focus (GtkXPaned * xpaned, - GtkWidget * widget); - -static void gtk_xpaned_set_last_bottom_right_child_focus (GtkXPaned * xpaned, - GtkWidget * widget); - -static gboolean gtk_xpaned_cycle_child_focus (GtkXPaned * xpaned, - gboolean reverse); - -static gboolean gtk_xpaned_cycle_handle_focus (GtkXPaned * xpaned, - gboolean reverse); - -static gboolean gtk_xpaned_move_handle (GtkXPaned * xpaned, - GtkScrollType scroll); - -static gboolean gtk_xpaned_accept_position (GtkXPaned * xpaned); - -static gboolean gtk_xpaned_cancel_position (GtkXPaned * xpaned); - -static gboolean gtk_xpaned_toggle_handle_focus (GtkXPaned * xpaned); - -static GType gtk_xpaned_child_type (GtkContainer * container); - -static GtkContainerClass *parent_class = NULL; - -struct _GtkXPanedPrivate -{ - GtkWidget *saved_focus; - GtkXPaned *first_xpaned; -}; - -GType -gtk_xpaned_get_type (void) -{ - static GType xpaned_type = 0; - - if (!xpaned_type) - { - static const GTypeInfo xpaned_info = { - sizeof (GtkXPanedClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_xpaned_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkXPaned), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_xpaned_init - }; - - xpaned_type = g_type_register_static (GTK_TYPE_CONTAINER, - "GtkXPaned", &xpaned_info, 0); - } - - return xpaned_type; -} - -GtkWidget * -gtk_xpaned_new (void) -{ - GtkXPaned *xpaned; - - xpaned = g_object_new (GTK_TYPE_XPANED, NULL); - - return GTK_WIDGET (xpaned); -} - -static guint signals[LAST_SIGNAL] = { 0 }; - -static void -add_tab_bindings (GtkBindingSet * binding_set, GdkModifierType modifiers) -{ - gtk_binding_entry_add_signal (binding_set, - GDK_Tab, modifiers, "toggle_handle_focus", 0); - - gtk_binding_entry_add_signal (binding_set, - GDK_KP_Tab, - modifiers, "toggle_handle_focus", 0); -} - -static void -add_move_binding (GtkBindingSet * binding_set, - guint keyval, GdkModifierType mask, GtkScrollType scroll) -{ - gtk_binding_entry_add_signal (binding_set, - keyval, - mask, - "move_handle", - 1, GTK_TYPE_SCROLL_TYPE, scroll); -} - -static void -gtk_xpaned_class_init (GtkXPanedClass * class) -{ - GObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - GtkXPanedClass *xpaned_class; - GtkBindingSet *binding_set; - - object_class = (GObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - container_class = (GtkContainerClass *) class; - xpaned_class = (GtkXPanedClass *) class; - - parent_class = g_type_class_peek_parent (class); - - object_class->set_property = gtk_xpaned_set_property; - object_class->get_property = gtk_xpaned_get_property; - object_class->finalize = gtk_xpaned_finalize; - - widget_class->realize = gtk_xpaned_realize; - widget_class->unrealize = gtk_xpaned_unrealize; - widget_class->map = gtk_xpaned_map; - widget_class->unmap = gtk_xpaned_unmap; - widget_class->draw = gtk_xpaned_draw; - widget_class->focus = gtk_xpaned_focus; - widget_class->enter_notify_event = gtk_xpaned_enter; - widget_class->leave_notify_event = gtk_xpaned_leave; - widget_class->button_press_event = gtk_xpaned_button_press; - widget_class->button_release_event = gtk_xpaned_button_release; - widget_class->motion_notify_event = gtk_xpaned_motion; - widget_class->get_preferred_width = gtk_xpaned_get_preferred_width; - widget_class->get_preferred_height = gtk_xpaned_get_preferred_height; - - widget_class->size_allocate = gtk_xpaned_size_allocate; - - container_class->add = gtk_xpaned_add; - container_class->remove = gtk_xpaned_remove; - container_class->forall = gtk_xpaned_forall; - container_class->child_type = gtk_xpaned_child_type; - container_class->set_focus_child = gtk_xpaned_set_focus_child; - container_class->set_child_property = gtk_xpaned_set_child_property; - container_class->get_child_property = gtk_xpaned_get_child_property; - - xpaned_class->cycle_child_focus = gtk_xpaned_cycle_child_focus; - xpaned_class->toggle_handle_focus = gtk_xpaned_toggle_handle_focus; - xpaned_class->move_handle = gtk_xpaned_move_handle; - xpaned_class->cycle_handle_focus = gtk_xpaned_cycle_handle_focus; - xpaned_class->accept_position = gtk_xpaned_accept_position; - xpaned_class->cancel_position = gtk_xpaned_cancel_position; - - g_object_class_install_property (object_class, - PROP_X_POSITION, - g_param_spec_int ("x-position", - ("x-Position"), - ("x-Position of paned separator in pixels (0 means all the way to the left)"), - 0, - G_MAXINT, - 0, - G_PARAM_READABLE | - G_PARAM_WRITABLE)); - - g_object_class_install_property (object_class, - PROP_Y_POSITION, - g_param_spec_int ("y-position", - "y-Position", - "y-Position of paned separator in pixels (0 means all the way to the top)", - 0, - G_MAXINT, - 0, - G_PARAM_READABLE | - G_PARAM_WRITABLE)); - - g_object_class_install_property (object_class, - PROP_POSITION_SET, - g_param_spec_boolean ("position-set", - "Position Set", - "TRUE if the Position property should be used", - FALSE, - G_PARAM_READABLE | - G_PARAM_WRITABLE)); - - gtk_widget_class_install_style_property (widget_class, - g_param_spec_int ("handle-size", - "Handle Size", - "Width of handle", - 0, - G_MAXINT, - 3, - G_PARAM_READABLE)); - /** - * GtkXPaned:min-x-position: - * - * The smallest possible value for the x-position property. This property is derived from the - * size and shrinkability of the widget's children. - * - * Since: 2.4 - */ - g_object_class_install_property (object_class, - PROP_MIN_X_POSITION, - g_param_spec_int ("min-x-position", - "Minimal x-Position", - "Smallest possible value for the \"x-position\" property", - 0, - G_MAXINT, - 0, G_PARAM_READABLE)); - - /** - * GtkXPaned:min-y-position: - * - * The smallest possible value for the y-position property. This property is derived from the - * size and shrinkability of the widget's children. - * - * Since: 2.4 - */ - g_object_class_install_property (object_class, - PROP_MIN_Y_POSITION, - g_param_spec_int ("min-y-position", - "Minimal y-Position", - "Smallest possible value for the \"y-position\" property", - 0, - G_MAXINT, - 0, G_PARAM_READABLE)); - - /** - * GtkPaned:max-x-position: - * - * The largest possible value for the x-position property. This property is derived from the - * size and shrinkability of the widget's children. - * - * Since: 2.4 - */ - g_object_class_install_property (object_class, - PROP_MAX_X_POSITION, - g_param_spec_int ("max-x-position", - "Maximal x-Position", - "Largest possible value for the \"x-position\" property", - 0, - G_MAXINT, - G_MAXINT, - G_PARAM_READABLE)); - - /** - * GtkPaned:max-y-position: - * - * The largest possible value for the y-position property. This property is derived from the - * size and shrinkability of the widget's children. - * - * Since: 2.4 - */ - g_object_class_install_property (object_class, - PROP_MAX_Y_POSITION, - g_param_spec_int ("max-y-position", - "Maximal y-Position", - "Largest possible value for the \"y-position\" property", - 0, - G_MAXINT, - G_MAXINT, - G_PARAM_READABLE)); - - - gtk_container_class_install_child_property (container_class, - CHILD_PROP_LEFT_ATTACH, - g_param_spec_int ("left-attach", - "Left Attach", - "The column number to which the left side of the widget should be attached", - 0, 1, - 0, - G_PARAM_READWRITE)); - - - - gtk_container_class_install_child_property (container_class, - CHILD_PROP_TOP_ATTACH, - g_param_spec_int ("top-attach", - "Top Attach", - "The row number to which the top side of the widget should be attached", - 0, 1, - 0, - G_PARAM_READWRITE)); - - - - /** - * GtkPaned:resize: - * - * The "resize" child property determines whether the child expands and - * shrinks along with the paned widget. - * - * Since: 2.4 - */ - gtk_container_class_install_child_property (container_class, - CHILD_PROP_RESIZE, - g_param_spec_boolean ("resize", - "Resize", - "If TRUE, the child expands and shrinks along with the paned widget", - TRUE, - G_PARAM_READWRITE)); - - /** - * GtkPaned:shrink: - * - * The "shrink" child property determines whether the child can be made - * smaller than its requisition. - * - * Since: 2.4 - */ - gtk_container_class_install_child_property (container_class, - CHILD_PROP_SHRINK, - g_param_spec_boolean ("shrink", - "Shrink", - "If TRUE, the child can be made smaller than its requisition", - TRUE, - G_PARAM_READWRITE)); - - signals[CYCLE_CHILD_FOCUS] = g_signal_new ("cycle-child-focus", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST | - G_SIGNAL_ACTION, - G_STRUCT_OFFSET (GtkXPanedClass, - cycle_child_focus), - NULL, NULL, - psppire_marshal_BOOLEAN__BOOLEAN, - G_TYPE_BOOLEAN, 1, - G_TYPE_BOOLEAN); - - signals[TOGGLE_HANDLE_FOCUS] = g_signal_new ("toggle-handle-focus", - G_TYPE_FROM_CLASS - (object_class), - G_SIGNAL_RUN_LAST | - G_SIGNAL_ACTION, - G_STRUCT_OFFSET - (GtkXPanedClass, - toggle_handle_focus), NULL, - NULL, - psppire_marshal_BOOLEAN__VOID, - G_TYPE_BOOLEAN, 0); - - signals[MOVE_HANDLE] = g_signal_new ("move-handle", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (GtkXPanedClass, - move_handle), NULL, - NULL, psppire_marshal_BOOLEAN__ENUM, - G_TYPE_BOOLEAN, 1, - GTK_TYPE_SCROLL_TYPE); - - signals[CYCLE_HANDLE_FOCUS] = g_signal_new ("cycle-handle-focus", - G_TYPE_FROM_CLASS - (object_class), - G_SIGNAL_RUN_LAST | - G_SIGNAL_ACTION, - G_STRUCT_OFFSET (GtkXPanedClass, - cycle_handle_focus), - NULL, NULL, - psppire_marshal_BOOLEAN__BOOLEAN, - G_TYPE_BOOLEAN, 1, - G_TYPE_BOOLEAN); - - signals[ACCEPT_POSITION] = g_signal_new ("accept-position", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST | - G_SIGNAL_ACTION, - G_STRUCT_OFFSET (GtkXPanedClass, - accept_position), - NULL, NULL, - psppire_marshal_BOOLEAN__VOID, - G_TYPE_BOOLEAN, 0); - - signals[CANCEL_POSITION] = g_signal_new ("cancel-position", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST | - G_SIGNAL_ACTION, - G_STRUCT_OFFSET (GtkXPanedClass, - cancel_position), - NULL, NULL, - psppire_marshal_BOOLEAN__VOID, - G_TYPE_BOOLEAN, 0); - - binding_set = gtk_binding_set_by_class (class); - - /* F6 and friends */ - gtk_binding_entry_add_signal (binding_set, - GDK_F6, 0, - "cycle-child-focus", 1, - G_TYPE_BOOLEAN, FALSE); - - gtk_binding_entry_add_signal (binding_set, - GDK_F6, GDK_SHIFT_MASK, - "cycle-child-focus", 1, G_TYPE_BOOLEAN, TRUE); - - /* F8 and friends */ - gtk_binding_entry_add_signal (binding_set, - GDK_F8, 0, - "cycle-handle-focus", 1, - G_TYPE_BOOLEAN, FALSE); - - gtk_binding_entry_add_signal (binding_set, - GDK_F8, GDK_SHIFT_MASK, - "cycle-handle-focus", 1, - G_TYPE_BOOLEAN, TRUE); - - add_tab_bindings (binding_set, 0); - add_tab_bindings (binding_set, GDK_CONTROL_MASK); - add_tab_bindings (binding_set, GDK_SHIFT_MASK); - add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK); - - /* accept and cancel positions */ - gtk_binding_entry_add_signal (binding_set, - GDK_Escape, 0, "cancel-position", 0); - - gtk_binding_entry_add_signal (binding_set, - GDK_Return, 0, "accept-position", 0); - - gtk_binding_entry_add_signal (binding_set, - GDK_KP_Enter, 0, "accept-position", 0); - - gtk_binding_entry_add_signal (binding_set, - GDK_space, 0, "accept-position", 0); - - gtk_binding_entry_add_signal (binding_set, - GDK_KP_Space, 0, "accept-position", 0); - - /* move handle */ - add_move_binding (binding_set, GDK_Left, 0, GTK_SCROLL_STEP_LEFT); - add_move_binding (binding_set, GDK_KP_Left, 0, GTK_SCROLL_STEP_LEFT); - add_move_binding (binding_set, GDK_Left, GDK_CONTROL_MASK, - GTK_SCROLL_PAGE_LEFT); - add_move_binding (binding_set, GDK_KP_Left, GDK_CONTROL_MASK, - GTK_SCROLL_PAGE_LEFT); - - add_move_binding (binding_set, GDK_Right, 0, GTK_SCROLL_STEP_RIGHT); - add_move_binding (binding_set, GDK_Right, GDK_CONTROL_MASK, - GTK_SCROLL_PAGE_RIGHT); - add_move_binding (binding_set, GDK_KP_Right, 0, GTK_SCROLL_STEP_RIGHT); - add_move_binding (binding_set, GDK_KP_Right, GDK_CONTROL_MASK, - GTK_SCROLL_PAGE_RIGHT); - - add_move_binding (binding_set, GDK_Up, 0, GTK_SCROLL_STEP_UP); - add_move_binding (binding_set, GDK_Up, GDK_CONTROL_MASK, - GTK_SCROLL_PAGE_UP); - add_move_binding (binding_set, GDK_KP_Up, 0, GTK_SCROLL_STEP_UP); - add_move_binding (binding_set, GDK_KP_Up, GDK_CONTROL_MASK, - GTK_SCROLL_PAGE_UP); - add_move_binding (binding_set, GDK_Page_Up, 0, GTK_SCROLL_PAGE_UP); - add_move_binding (binding_set, GDK_KP_Page_Up, 0, GTK_SCROLL_PAGE_UP); - - add_move_binding (binding_set, GDK_Down, 0, GTK_SCROLL_STEP_DOWN); - add_move_binding (binding_set, GDK_Down, GDK_CONTROL_MASK, - GTK_SCROLL_PAGE_DOWN); - add_move_binding (binding_set, GDK_KP_Down, 0, GTK_SCROLL_STEP_DOWN); - add_move_binding (binding_set, GDK_KP_Down, GDK_CONTROL_MASK, - GTK_SCROLL_PAGE_DOWN); - add_move_binding (binding_set, GDK_Page_Down, 0, GTK_SCROLL_PAGE_RIGHT); - add_move_binding (binding_set, GDK_KP_Page_Down, 0, GTK_SCROLL_PAGE_RIGHT); - - add_move_binding (binding_set, GDK_Home, 0, GTK_SCROLL_START); - add_move_binding (binding_set, GDK_KP_Home, 0, GTK_SCROLL_START); - add_move_binding (binding_set, GDK_End, 0, GTK_SCROLL_END); - add_move_binding (binding_set, GDK_KP_End, 0, GTK_SCROLL_END); -} - -static GType -gtk_xpaned_child_type (GtkContainer * container) -{ - if (!GTK_XPANED (container)->top_left_child || - !GTK_XPANED (container)->top_right_child || - !GTK_XPANED (container)->bottom_left_child || - !GTK_XPANED (container)->bottom_right_child) - return GTK_TYPE_WIDGET; - else - return G_TYPE_NONE; -} - -static void -gtk_xpaned_init (GtkXPaned * xpaned) -{ - gtk_widget_set_can_focus (GTK_WIDGET (xpaned), TRUE); - gtk_widget_set_has_window (GTK_WIDGET (xpaned), FALSE); - - xpaned->top_left_child = NULL; - xpaned->top_right_child = NULL; - xpaned->bottom_left_child = NULL; - xpaned->bottom_right_child = NULL; - xpaned->handle_east = NULL; - xpaned->handle_west = NULL; - xpaned->handle_north = NULL; - xpaned->handle_south = NULL; - xpaned->handle_middle = NULL; - xpaned->cursor_type_east = GDK_SB_V_DOUBLE_ARROW; - xpaned->cursor_type_west = GDK_SB_V_DOUBLE_ARROW; - xpaned->cursor_type_north = GDK_SB_H_DOUBLE_ARROW; - xpaned->cursor_type_south = GDK_SB_H_DOUBLE_ARROW; - xpaned->cursor_type_middle = GDK_FLEUR; - - xpaned->handle_pos_east.width = 5; - xpaned->handle_pos_east.height = 5; - xpaned->handle_pos_west.width = 5; - xpaned->handle_pos_west.height = 5; - xpaned->handle_pos_north.width = 5; - xpaned->handle_pos_north.height = 5; - xpaned->handle_pos_south.width = 5; - xpaned->handle_pos_south.height = 5; - xpaned->handle_pos_middle.width = 5; - xpaned->handle_pos_middle.height = 5; - - xpaned->position_set = FALSE; - xpaned->last_allocation.width = -1; - xpaned->last_allocation.height = -1; - xpaned->in_drag_vert = FALSE; - xpaned->in_drag_horiz = FALSE; - xpaned->in_drag_vert_and_horiz = FALSE; - - xpaned->maximized[GTK_XPANED_TOP_LEFT] = FALSE; - xpaned->maximized[GTK_XPANED_TOP_RIGHT] = FALSE; - xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] = FALSE; - xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT] = FALSE; - - xpaned->priv = g_new0 (GtkXPanedPrivate, 1); - xpaned->last_top_left_child_focus = NULL; - xpaned->last_top_right_child_focus = NULL; - xpaned->last_bottom_left_child_focus = NULL; - xpaned->last_bottom_right_child_focus = NULL; - xpaned->in_recursion = FALSE; - xpaned->handle_prelit = FALSE; - xpaned->original_position.x = -1; - xpaned->original_position.y = -1; - xpaned->unmaximized_position.x = -1; - xpaned->unmaximized_position.y = -1; - - xpaned->handle_pos_east.x = -1; - xpaned->handle_pos_east.y = -1; - xpaned->handle_pos_west.x = -1; - xpaned->handle_pos_west.y = -1; - xpaned->handle_pos_north.x = -1; - xpaned->handle_pos_north.y = -1; - xpaned->handle_pos_south.x = -1; - xpaned->handle_pos_south.y = -1; - xpaned->handle_pos_middle.x = -1; - xpaned->handle_pos_middle.y = -1; - - xpaned->drag_pos.x = -1; - xpaned->drag_pos.y = -1; -} - -void -gtk_xpaned_compute_position (GtkXPaned * xpaned, - const GtkAllocation * allocation, - GtkRequisition * top_left_child_req, - GtkRequisition * top_right_child_req, - GtkRequisition * bottom_left_child_req, - GtkRequisition * bottom_right_child_req); - - -static void -gtk_xpaned_size_allocate (GtkWidget * widget, GtkAllocation * allocation) -{ - GtkXPaned *xpaned = GTK_XPANED (widget); - gint border_width = gtk_container_get_border_width (GTK_CONTAINER (xpaned)); - GtkAllocation top_left_child_allocation; - GtkAllocation top_right_child_allocation; - GtkAllocation bottom_left_child_allocation; - GtkAllocation bottom_right_child_allocation; - GtkRequisition top_left_child_requisition; - GtkRequisition top_right_child_requisition; - GtkRequisition bottom_left_child_requisition; - GtkRequisition bottom_right_child_requisition; - gint handle_size; - - g_print ("Allocate %p %p %p %p\n", - xpaned->top_left_child, - xpaned->top_right_child, - xpaned->bottom_left_child, - xpaned->bottom_right_child); - - /* determine size of handle(s) */ - gtk_widget_style_get (widget, "handle-size", &handle_size, NULL); - - gtk_widget_set_allocation (widget, allocation); - - if (xpaned->top_left_child - && gtk_widget_get_visible (xpaned->top_left_child) - && xpaned->top_right_child - && gtk_widget_get_visible (xpaned->top_right_child) - && xpaned->bottom_left_child - && gtk_widget_get_visible (xpaned->bottom_left_child) - && xpaned->bottom_right_child - && gtk_widget_get_visible (xpaned->bottom_right_child)) - { - /* what sizes do the children want to be at least at */ - gtk_widget_get_preferred_size (xpaned->top_left_child, - &top_left_child_requisition, NULL); - gtk_widget_get_preferred_size (xpaned->top_right_child, - &top_right_child_requisition, NULL); - gtk_widget_get_preferred_size (xpaned->bottom_left_child, - &bottom_left_child_requisition, NULL); - gtk_widget_get_preferred_size (xpaned->bottom_right_child, - &bottom_right_child_requisition, NULL); - - /* determine the total requisition-sum of all requisitions of borders, - * handles, children etc. */ - gtk_xpaned_compute_position (xpaned, - allocation, - &top_left_child_requisition, - &top_right_child_requisition, - &bottom_left_child_requisition, - &bottom_right_child_requisition); - - /* calculate the current positions and sizes of the handles */ - xpaned->handle_pos_east.x = - allocation->x + border_width + - xpaned->top_left_child_size.width + handle_size; - xpaned->handle_pos_east.y = - allocation->y + border_width + - xpaned->top_left_child_size.height; - xpaned->handle_pos_east.width = - allocation->width - xpaned->top_left_child_size.width - - 2 * border_width - handle_size; - xpaned->handle_pos_east.height = handle_size; - - xpaned->handle_pos_west.x = allocation->x + border_width; - xpaned->handle_pos_west.y = xpaned->handle_pos_east.y; - xpaned->handle_pos_west.width = - allocation->width - xpaned->handle_pos_east.width - - 2 * border_width - handle_size; - xpaned->handle_pos_west.height = handle_size; - - xpaned->handle_pos_north.x = xpaned->handle_pos_east.x - handle_size; - xpaned->handle_pos_north.y = allocation->y + border_width; - xpaned->handle_pos_north.width = handle_size; - xpaned->handle_pos_north.height = - xpaned->handle_pos_east.y - allocation->y - border_width; - - xpaned->handle_pos_south.x = xpaned->handle_pos_north.x; - xpaned->handle_pos_south.y = xpaned->handle_pos_east.y + handle_size; - xpaned->handle_pos_south.width = handle_size; - xpaned->handle_pos_south.height = - allocation->height - xpaned->handle_pos_north.height - - 2 * border_width - handle_size; - - -#define CENTRUM 20 - xpaned->handle_pos_middle.x = xpaned->handle_pos_north.x; - xpaned->handle_pos_middle.y = xpaned->handle_pos_east.y; - xpaned->handle_pos_middle.width = handle_size + CENTRUM; - xpaned->handle_pos_middle.height = handle_size + CENTRUM; - - /* set allocation for top-left child */ - top_left_child_allocation.x = allocation->x + border_width; - top_left_child_allocation.y = allocation->y + border_width; - top_left_child_allocation.width = xpaned->handle_pos_west.width; - top_left_child_allocation.height = xpaned->handle_pos_north.height; - - /* set allocation for top-right child */ - top_right_child_allocation.x = - allocation->x + border_width + handle_size + - top_left_child_allocation.width; - top_right_child_allocation.y = allocation->y + border_width; - top_right_child_allocation.width = xpaned->handle_pos_east.width; - top_right_child_allocation.height = xpaned->handle_pos_north.height; - - /* set allocation for bottom-left child */ - bottom_left_child_allocation.x = xpaned->handle_pos_west.x; - bottom_left_child_allocation.y = xpaned->handle_pos_south.y; - bottom_left_child_allocation.width = xpaned->handle_pos_west.width; - bottom_left_child_allocation.height = xpaned->handle_pos_south.height; - - /* set allocation for bottom-right child */ - bottom_right_child_allocation.x = top_right_child_allocation.x; - bottom_right_child_allocation.y = bottom_left_child_allocation.y; - bottom_right_child_allocation.width = xpaned->handle_pos_east.width; - bottom_right_child_allocation.height = xpaned->handle_pos_south.height; - - if (gtk_widget_get_realized (widget)) - { - if (gtk_widget_get_mapped (widget)) - { - gdk_window_show (xpaned->handle_east); - gdk_window_show (xpaned->handle_west); - gdk_window_show (xpaned->handle_north); - gdk_window_show (xpaned->handle_south); - gdk_window_show (xpaned->handle_middle); - } - - gdk_window_move_resize (xpaned->handle_east, - xpaned->handle_pos_east.x, - xpaned->handle_pos_east.y, - xpaned->handle_pos_east.width, - xpaned->handle_pos_east.height); - - gdk_window_move_resize (xpaned->handle_west, - xpaned->handle_pos_west.x, - xpaned->handle_pos_west.y, - xpaned->handle_pos_west.width, - xpaned->handle_pos_west.height); - - gdk_window_move_resize (xpaned->handle_north, - xpaned->handle_pos_north.x, - xpaned->handle_pos_north.y, - xpaned->handle_pos_north.width, - xpaned->handle_pos_north.height); - - gdk_window_move_resize (xpaned->handle_south, - xpaned->handle_pos_south.x, - xpaned->handle_pos_south.y, - xpaned->handle_pos_south.width, - xpaned->handle_pos_south.height); - - gdk_window_move_resize (xpaned->handle_middle, - xpaned->handle_pos_middle.x, - xpaned->handle_pos_middle.y, - xpaned->handle_pos_middle.width, - xpaned->handle_pos_middle.height); - } - - /* Now allocate the childen, making sure, when resizing not to - * overlap the windows - */ - if (gtk_widget_get_mapped (widget)) - { - gtk_widget_size_allocate (xpaned->top_right_child, - &top_right_child_allocation); - gtk_widget_size_allocate (xpaned->top_left_child, - &top_left_child_allocation); - gtk_widget_size_allocate (xpaned->bottom_left_child, - &bottom_left_child_allocation); - gtk_widget_size_allocate (xpaned->bottom_right_child, - &bottom_right_child_allocation); - } - } -} - -static void -gtk_xpaned_set_property (GObject * object, - guint prop_id, - const GValue * value, GParamSpec * pspec) -{ - GtkXPaned *xpaned = GTK_XPANED (object); - - switch (prop_id) - { - case PROP_X_POSITION: - gtk_xpaned_set_position_x (xpaned, g_value_get_int (value)); - break; - - case PROP_Y_POSITION: - gtk_xpaned_set_position_y (xpaned, g_value_get_int (value)); - break; - - case PROP_POSITION_SET: - xpaned->position_set = g_value_get_boolean (value); - gtk_widget_queue_resize (GTK_WIDGET (xpaned)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gtk_xpaned_get_property (GObject * object, - guint prop_id, GValue * value, GParamSpec * pspec) -{ - GtkXPaned *xpaned = GTK_XPANED (object); - - switch (prop_id) - { - case PROP_X_POSITION: - g_value_set_int (value, xpaned->top_left_child_size.width); - break; - - case PROP_Y_POSITION: - g_value_set_int (value, xpaned->top_left_child_size.height); - break; - - case PROP_POSITION_SET: - g_value_set_boolean (value, xpaned->position_set); - break; - - case PROP_MIN_X_POSITION: - g_value_set_int (value, xpaned->min_position.x); - break; - - case PROP_MIN_Y_POSITION: - g_value_set_int (value, xpaned->min_position.y); - break; - - case PROP_MAX_X_POSITION: - g_value_set_int (value, xpaned->max_position.x); - break; - - case PROP_MAX_Y_POSITION: - g_value_set_int (value, xpaned->max_position.y); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gtk_xpaned_set_child_property (GtkContainer * container, - GtkWidget * child, - guint property_id, - const GValue * value, GParamSpec * pspec) -{ - GtkXPaned *xpaned = GTK_XPANED (container); - - g_assert (child == xpaned->top_left_child || - child == xpaned->top_right_child || - child == xpaned->bottom_left_child || - child == xpaned->bottom_right_child); - - gint attach = g_value_get_int (value); - switch (property_id) - { - case CHILD_PROP_LEFT_ATTACH: - g_object_ref (child); - gtk_widget_unparent (child); - if (attach == 0) - { - if (child == xpaned->top_right_child) - xpaned->top_left_child = child; - else if (child == xpaned->bottom_right_child) - xpaned->bottom_left_child = child; - } - else - { - if (child == xpaned->top_left_child) - xpaned->top_right_child = child; - else if (child == xpaned->bottom_left_child) - xpaned->bottom_right_child = child; - } - gtk_widget_set_parent (child, GTK_WIDGET (xpaned)); - g_object_unref (child); - break; - case CHILD_PROP_TOP_ATTACH: - g_object_ref (child); - gtk_widget_unparent (child); - if (attach == 0) - { - if (child == xpaned->bottom_right_child) - xpaned->top_right_child = child; - else if (child == xpaned->bottom_left_child) - xpaned->top_left_child = child; - } - else - { - if (child == xpaned->top_left_child) - xpaned->bottom_left_child = child; - else if (child == xpaned->top_right_child) - xpaned->bottom_right_child = child; - } - gtk_widget_set_parent (child, GTK_WIDGET (xpaned)); - g_object_unref (child); - break; - case CHILD_PROP_RESIZE: - { - gboolean new_value = TRUE; - - if (child == xpaned->top_left_child) - { - xpaned->top_left_child_resize = new_value; - } - else if (child == xpaned->top_right_child) - { - xpaned->top_right_child_resize = new_value; - } - else if (child == xpaned->bottom_left_child) - { - xpaned->bottom_left_child_resize = new_value; - } - else if (child == xpaned->bottom_right_child) - { - xpaned->bottom_right_child_resize = new_value; - } - } - break; - - case CHILD_PROP_SHRINK: - { - gboolean new_value = FALSE; - - if (child == xpaned->top_left_child) - { - xpaned->top_left_child_shrink = new_value; - } - else if (child == xpaned->top_right_child) - { - xpaned->top_right_child_shrink = new_value; - } - else if (child == xpaned->bottom_left_child) - { - xpaned->bottom_left_child_shrink = new_value; - } - else if (child == xpaned->bottom_right_child) - { - xpaned->bottom_right_child_shrink = new_value; - } - } - break; - - default: - GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, - property_id, pspec); - break; - } - - gtk_widget_queue_resize (GTK_WIDGET (container)); - gtk_widget_queue_draw (GTK_WIDGET (container)); -} - -static void -gtk_xpaned_get_child_property (GtkContainer * container, - GtkWidget * child, - guint property_id, - GValue * value, GParamSpec * pspec) -{ - GtkXPaned *xpaned = GTK_XPANED (container); - - g_assert (child == xpaned->top_left_child || - child == xpaned->top_right_child || - child == xpaned->bottom_left_child || - child == xpaned->bottom_right_child); - - switch (property_id) - { - case CHILD_PROP_TOP_ATTACH: - if (child == xpaned->top_left_child) - g_value_set_int (value, 0); - if (child == xpaned->top_right_child) - g_value_set_int (value, 0); - if (child == xpaned->bottom_left_child) - g_value_set_int (value, 1); - if (child == xpaned->bottom_right_child) - g_value_set_int (value, 1); - break; - case CHILD_PROP_LEFT_ATTACH: - if (child == xpaned->top_left_child) - g_value_set_int (value, 0); - if (child == xpaned->bottom_left_child) - g_value_set_int (value, 0); - if (child == xpaned->top_right_child) - g_value_set_int (value, 1); - if (child == xpaned->bottom_right_child) - g_value_set_int (value, 1); - break; - case CHILD_PROP_RESIZE: - if (child == xpaned->top_left_child) - g_value_set_boolean (value, xpaned->top_left_child_resize); - else if (child == xpaned->top_right_child) - g_value_set_boolean (value, xpaned->top_right_child_resize); - else if (child == xpaned->bottom_left_child) - g_value_set_boolean (value, xpaned->bottom_left_child_resize); - else if (child == xpaned->bottom_right_child) - g_value_set_boolean (value, xpaned->bottom_right_child_resize); - break; - - case CHILD_PROP_SHRINK: - if (child == xpaned->top_left_child) - g_value_set_boolean (value, xpaned->top_left_child_shrink); - else if (child == xpaned->top_right_child) - g_value_set_boolean (value, xpaned->top_right_child_shrink); - else if (child == xpaned->bottom_left_child) - g_value_set_boolean (value, xpaned->bottom_left_child_shrink); - else if (child == xpaned->bottom_right_child) - g_value_set_boolean (value, xpaned->bottom_right_child_shrink); - break; - - default: - GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, - property_id, pspec); - break; - } -} - -static void -gtk_xpaned_finalize (GObject * object) -{ - GtkXPaned *xpaned = GTK_XPANED (object); - - gtk_xpaned_set_saved_focus (xpaned, NULL); - gtk_xpaned_set_first_xpaned (xpaned, NULL); - - g_free (xpaned->priv); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -gtk_xpaned_realize (GtkWidget * widget) -{ - GtkXPaned *xpaned; - GdkWindowAttr attributes_east; - GdkWindowAttr attributes_west; - GdkWindowAttr attributes_north; - GdkWindowAttr attributes_south; - GdkWindowAttr attributes_middle; - gint attributes_mask_east; - gint attributes_mask_west; - gint attributes_mask_north; - gint attributes_mask_south; - gint attributes_mask_middle; - - gtk_widget_set_realized (widget, TRUE); - xpaned = GTK_XPANED (widget); - - gtk_widget_set_window (widget, gtk_widget_get_parent_window (widget)); - // g_object_ref (widget->window); - - attributes_east.window_type = GDK_WINDOW_CHILD; - attributes_west.window_type = GDK_WINDOW_CHILD; - attributes_north.window_type = GDK_WINDOW_CHILD; - attributes_south.window_type = GDK_WINDOW_CHILD; - attributes_middle.window_type = GDK_WINDOW_CHILD; - - attributes_east.wclass = GDK_INPUT_ONLY; - attributes_west.wclass = GDK_INPUT_ONLY; - attributes_north.wclass = GDK_INPUT_ONLY; - attributes_south.wclass = GDK_INPUT_ONLY; - attributes_middle.wclass = GDK_INPUT_ONLY; - - attributes_east.x = xpaned->handle_pos_east.x; - attributes_east.y = xpaned->handle_pos_east.y; - attributes_east.width = xpaned->handle_pos_east.width; - attributes_east.height = xpaned->handle_pos_east.height; - - attributes_west.x = xpaned->handle_pos_west.x; - attributes_west.y = xpaned->handle_pos_west.y; - attributes_west.width = xpaned->handle_pos_west.width; - attributes_west.height = xpaned->handle_pos_west.height; - - attributes_north.x = xpaned->handle_pos_north.x; - attributes_north.y = xpaned->handle_pos_north.y; - attributes_north.width = xpaned->handle_pos_north.width; - attributes_north.height = xpaned->handle_pos_north.height; - - attributes_south.x = xpaned->handle_pos_south.x; - attributes_south.y = xpaned->handle_pos_south.y; - attributes_south.width = xpaned->handle_pos_south.width; - attributes_south.height = xpaned->handle_pos_south.height; - - attributes_middle.x = xpaned->handle_pos_middle.x; - attributes_middle.y = xpaned->handle_pos_middle.y; - attributes_middle.width = xpaned->handle_pos_middle.width; - attributes_middle.height = xpaned->handle_pos_middle.height; - - attributes_east.cursor = - gdk_cursor_new_for_display (gtk_widget_get_display (widget), - xpaned->cursor_type_east); - attributes_west.cursor = - gdk_cursor_new_for_display (gtk_widget_get_display (widget), - xpaned->cursor_type_west); - attributes_north.cursor = - gdk_cursor_new_for_display (gtk_widget_get_display (widget), - xpaned->cursor_type_north); - attributes_south.cursor = - gdk_cursor_new_for_display (gtk_widget_get_display (widget), - xpaned->cursor_type_south); - attributes_middle.cursor = - gdk_cursor_new_for_display (gtk_widget_get_display (widget), - xpaned->cursor_type_middle); - - attributes_east.event_mask = gtk_widget_get_events (widget); - attributes_west.event_mask = gtk_widget_get_events (widget); - attributes_north.event_mask = gtk_widget_get_events (widget); - attributes_south.event_mask = gtk_widget_get_events (widget); - attributes_middle.event_mask = gtk_widget_get_events (widget); - - attributes_east.event_mask |= (GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_ENTER_NOTIFY_MASK | - GDK_LEAVE_NOTIFY_MASK | - GDK_POINTER_MOTION_MASK | - GDK_POINTER_MOTION_HINT_MASK); - attributes_west.event_mask |= (GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_ENTER_NOTIFY_MASK | - GDK_LEAVE_NOTIFY_MASK | - GDK_POINTER_MOTION_MASK | - GDK_POINTER_MOTION_HINT_MASK); - attributes_north.event_mask |= (GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_ENTER_NOTIFY_MASK | - GDK_LEAVE_NOTIFY_MASK | - GDK_POINTER_MOTION_MASK | - GDK_POINTER_MOTION_HINT_MASK); - attributes_south.event_mask |= (GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_ENTER_NOTIFY_MASK | - GDK_LEAVE_NOTIFY_MASK | - GDK_POINTER_MOTION_MASK | - GDK_POINTER_MOTION_HINT_MASK); - attributes_middle.event_mask |= (GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_ENTER_NOTIFY_MASK | - GDK_LEAVE_NOTIFY_MASK | - GDK_POINTER_MOTION_MASK | - GDK_POINTER_MOTION_HINT_MASK); - - attributes_mask_east = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR; - attributes_mask_west = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR; - attributes_mask_north = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR; - attributes_mask_south = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR; - attributes_mask_middle = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR; - - xpaned->handle_east = gdk_window_new (gtk_widget_get_window (widget), - &attributes_east, - attributes_mask_east); - xpaned->handle_west = gdk_window_new (gtk_widget_get_window (widget), - &attributes_west, - attributes_mask_west); - xpaned->handle_north = gdk_window_new (gtk_widget_get_window (widget), - &attributes_north, - attributes_mask_north); - xpaned->handle_south = gdk_window_new (gtk_widget_get_window (widget), - &attributes_south, - attributes_mask_south); - xpaned->handle_middle = gdk_window_new (gtk_widget_get_window (widget), - &attributes_middle, - attributes_mask_middle); - - gdk_window_set_user_data (xpaned->handle_east, xpaned); - gdk_window_set_user_data (xpaned->handle_west, xpaned); - gdk_window_set_user_data (xpaned->handle_north, xpaned); - gdk_window_set_user_data (xpaned->handle_south, xpaned); - gdk_window_set_user_data (xpaned->handle_middle, xpaned); - - g_object_unref (attributes_east.cursor); - g_object_unref (attributes_west.cursor); - g_object_unref (attributes_north.cursor); - g_object_unref (attributes_south.cursor); - g_object_unref (attributes_middle.cursor); - - if (xpaned->top_left_child - && gtk_widget_get_visible (xpaned->top_left_child) - && xpaned->top_right_child - && gtk_widget_get_visible (xpaned->top_right_child) - && xpaned->bottom_left_child - && gtk_widget_get_visible (xpaned->bottom_left_child) - && xpaned->bottom_right_child - && gtk_widget_get_visible (xpaned->bottom_right_child)) - { - gdk_window_show (xpaned->handle_east); - gdk_window_show (xpaned->handle_west); - gdk_window_show (xpaned->handle_north); - gdk_window_show (xpaned->handle_south); - gdk_window_show (xpaned->handle_middle); - } -} - -static void -gtk_xpaned_unrealize (GtkWidget * widget) -{ - GtkXPaned *xpaned = GTK_XPANED (widget); - - if (xpaned->handle_east) - { - gdk_window_set_user_data (xpaned->handle_east, NULL); - gdk_window_destroy (xpaned->handle_east); - xpaned->handle_east = NULL; - } - - if (xpaned->handle_west) - { - gdk_window_set_user_data (xpaned->handle_west, NULL); - gdk_window_destroy (xpaned->handle_west); - xpaned->handle_west = NULL; - } - - if (xpaned->handle_north) - { - gdk_window_set_user_data (xpaned->handle_north, NULL); - gdk_window_destroy (xpaned->handle_north); - xpaned->handle_north = NULL; - } - - if (xpaned->handle_south) - { - gdk_window_set_user_data (xpaned->handle_south, NULL); - gdk_window_destroy (xpaned->handle_south); - xpaned->handle_south = NULL; - } - - if (xpaned->handle_middle) - { - gdk_window_set_user_data (xpaned->handle_middle, NULL); - gdk_window_destroy (xpaned->handle_middle); - xpaned->handle_middle = NULL; - } - - gtk_xpaned_set_last_top_left_child_focus (xpaned, NULL); - gtk_xpaned_set_last_top_right_child_focus (xpaned, NULL); - gtk_xpaned_set_last_bottom_left_child_focus (xpaned, NULL); - gtk_xpaned_set_last_bottom_right_child_focus (xpaned, NULL); - gtk_xpaned_set_saved_focus (xpaned, NULL); - gtk_xpaned_set_first_xpaned (xpaned, NULL); - - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (*GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); -} - -static void -gtk_xpaned_map (GtkWidget * widget) -{ - GtkXPaned *xpaned = GTK_XPANED (widget); - - gdk_window_show (xpaned->handle_east); - gdk_window_show (xpaned->handle_west); - gdk_window_show (xpaned->handle_north); - gdk_window_show (xpaned->handle_south); - gdk_window_show (xpaned->handle_middle); - - GTK_WIDGET_CLASS (parent_class)->map (widget); -} - -static void -gtk_xpaned_unmap (GtkWidget * widget) -{ - GtkXPaned *xpaned = GTK_XPANED (widget); - - gdk_window_hide (xpaned->handle_east); - gdk_window_hide (xpaned->handle_west); - gdk_window_hide (xpaned->handle_north); - gdk_window_hide (xpaned->handle_south); - gdk_window_hide (xpaned->handle_middle); - - GTK_WIDGET_CLASS (parent_class)->unmap (widget); -} - -static gboolean -gtk_xpaned_draw (GtkWidget * widget, cairo_t *cr) -{ - GtkXPaned *xpaned = GTK_XPANED (widget); - gint handle_size; - - /* determine size of handle(s) */ - gtk_widget_style_get (widget, "handle-size", &handle_size, NULL); - - /* I want the handle-"thickness" to be at least 3 */ - g_assert (handle_size >= 3); - - if (gtk_widget_get_visible (widget) && gtk_widget_get_mapped (widget) && - xpaned->top_left_child - && gtk_widget_get_visible (xpaned->top_left_child) - && xpaned->top_right_child - && gtk_widget_get_visible (xpaned->top_right_child) - && xpaned->bottom_left_child - && gtk_widget_get_visible (xpaned->bottom_left_child) - && xpaned->bottom_right_child - && gtk_widget_get_visible (xpaned->bottom_right_child)) - { - GtkStyleContext *context; - - context = gtk_widget_get_style_context (widget); - gtk_render_handle (context, cr, - xpaned->handle_pos_east.x - handle_size - 256 / 2, - xpaned->handle_pos_west.y + 1, - 256 + handle_size, handle_size - 2); - - gtk_render_handle (context, cr, - xpaned->handle_pos_north.x + 1, - xpaned->handle_pos_south.y - handle_size - 256 / 2, - handle_size - 2, 256 + handle_size); - } - - /* Chain up to draw children */ - GTK_WIDGET_CLASS (parent_class)->draw (widget, cr); - - return FALSE; -} - -static gboolean -is_rtl (GtkXPaned * xpaned) -{ - if (gtk_widget_get_direction (GTK_WIDGET (xpaned)) == GTK_TEXT_DIR_RTL) - return TRUE; - - return FALSE; -} - -static void -update_drag (GtkXPaned * xpaned) -{ - GdkPoint pos; - GtkWidget *widget = GTK_WIDGET (xpaned); - gint handle_size; - GtkRequisition size; - GtkAllocation allocation; - - gtk_widget_get_allocation (widget, &allocation); - - gdk_window_get_device_position (gtk_widget_get_window (widget), - gdk_device_manager_get_client_pointer ( - gdk_display_get_device_manager ( - gtk_widget_get_display (widget))), - &pos.x, &pos.y, NULL); - if (!gtk_widget_get_has_window (widget)) - { - pos.x -= allocation.x; - pos.y -= allocation.y; - } - - if (xpaned->in_drag_vert) - { - pos.y -= xpaned->drag_pos.y; - - if (is_rtl (xpaned)) - { - gtk_widget_style_get (widget, "handle-size", &handle_size, NULL); - - size.height = allocation.height - pos.y - handle_size; - } - else - { - size.height = pos.y; - } - - size.height -= gtk_container_get_border_width (GTK_CONTAINER (xpaned)); - - size.height = - CLAMP (size.height, xpaned->min_position.y, xpaned->max_position.y); - - if (size.height != xpaned->top_left_child_size.height) - gtk_xpaned_set_position_y (xpaned, size.height); - } - - if (xpaned->in_drag_horiz) - { - pos.x -= xpaned->drag_pos.x; - - if (is_rtl (xpaned)) - { - gtk_widget_style_get (widget, "handle-size", &handle_size, NULL); - - size.width = allocation.width - pos.x - handle_size; - } - else - { - size.width = pos.x; - } - - size.width -= gtk_container_get_border_width (GTK_CONTAINER (xpaned)); - - size.width = - CLAMP (size.width, xpaned->min_position.x, xpaned->max_position.x); - - if (size.width != xpaned->top_left_child_size.width) - gtk_xpaned_set_position_x (xpaned, size.width); - } - - if (xpaned->in_drag_vert_and_horiz) - { - pos.x -= xpaned->drag_pos.x; - pos.y -= xpaned->drag_pos.y; - - if (is_rtl (xpaned)) - { - gtk_widget_style_get (widget, "handle-size", &handle_size, NULL); - - size.width = allocation.width - pos.x - handle_size; - size.height = allocation.height - pos.y - handle_size; - } - else - { - size.width = pos.x; - size.height = pos.y; - } - - size.width -= gtk_container_get_border_width (GTK_CONTAINER (xpaned)); - size.height -= gtk_container_get_border_width (GTK_CONTAINER (xpaned)); - - size.width = - CLAMP (size.width, xpaned->min_position.x, xpaned->max_position.x); - size.height = - CLAMP (size.height, xpaned->min_position.y, xpaned->max_position.y); - - if (size.width != xpaned->top_left_child_size.width) - gtk_xpaned_set_position_x (xpaned, size.width); - - if (size.height != xpaned->top_left_child_size.height) - gtk_xpaned_set_position_y (xpaned, size.height); - } -} - -static gboolean -gtk_xpaned_enter (GtkWidget * widget, GdkEventCrossing * event) -{ - GtkXPaned *xpaned = GTK_XPANED (widget); - - if (xpaned->in_drag_vert || - xpaned->in_drag_horiz || xpaned->in_drag_vert_and_horiz) - update_drag (xpaned); - else - { - xpaned->handle_prelit = TRUE; - - gtk_widget_queue_draw_area (widget, - xpaned->handle_pos_east.x, - xpaned->handle_pos_east.y, - xpaned->handle_pos_east.width, - xpaned->handle_pos_east.height); - - gtk_widget_queue_draw_area (widget, - xpaned->handle_pos_west.x, - xpaned->handle_pos_west.y, - xpaned->handle_pos_west.width, - xpaned->handle_pos_west.height); - - gtk_widget_queue_draw_area (widget, - xpaned->handle_pos_north.x, - xpaned->handle_pos_north.y, - xpaned->handle_pos_north.width, - xpaned->handle_pos_north.height); - - gtk_widget_queue_draw_area (widget, - xpaned->handle_pos_south.x, - xpaned->handle_pos_south.y, - xpaned->handle_pos_south.width, - xpaned->handle_pos_south.height); - - gtk_widget_queue_draw_area (widget, - xpaned->handle_pos_middle.x, - xpaned->handle_pos_middle.y, - xpaned->handle_pos_middle.width, - xpaned->handle_pos_middle.height); - } - - return TRUE; -} - -static gboolean -gtk_xpaned_leave (GtkWidget * widget, GdkEventCrossing * event) -{ - GtkXPaned *xpaned = GTK_XPANED (widget); - - if (xpaned->in_drag_vert || - xpaned->in_drag_horiz || xpaned->in_drag_vert_and_horiz) - update_drag (xpaned); - else - { - xpaned->handle_prelit = FALSE; - - gtk_widget_queue_draw_area (widget, - xpaned->handle_pos_east.x, - xpaned->handle_pos_east.y, - xpaned->handle_pos_east.width, - xpaned->handle_pos_east.height); - - gtk_widget_queue_draw_area (widget, - xpaned->handle_pos_west.x, - xpaned->handle_pos_west.y, - xpaned->handle_pos_west.width, - xpaned->handle_pos_west.height); - - gtk_widget_queue_draw_area (widget, - xpaned->handle_pos_north.x, - xpaned->handle_pos_north.y, - xpaned->handle_pos_north.width, - xpaned->handle_pos_north.height); - - gtk_widget_queue_draw_area (widget, - xpaned->handle_pos_south.x, - xpaned->handle_pos_south.y, - xpaned->handle_pos_south.width, - xpaned->handle_pos_south.height); - - gtk_widget_queue_draw_area (widget, - xpaned->handle_pos_middle.x, - xpaned->handle_pos_middle.y, - xpaned->handle_pos_middle.width, - xpaned->handle_pos_middle.height); - } - - return TRUE; -} - -static gboolean -gtk_xpaned_focus (GtkWidget * widget, GtkDirectionType direction) -{ - gboolean retval; - - /* This is a hack, but how can this be done without - * excessive cut-and-paste from gtkcontainer.c? - */ - - gtk_widget_set_can_focus (GTK_WIDGET (widget), FALSE); - retval = (*GTK_WIDGET_CLASS (parent_class)->focus) (widget, direction); - gtk_widget_set_can_focus (GTK_WIDGET (widget), TRUE); - - return retval; -} - -static void -gtk_xpaned_button_press_grab (GdkWindow *handle, GdkEventButton *event) -{ - /* We need a server grab here, not gtk_grab_add(), since - * we don't want to pass events on to the widget's children */ - gdk_device_grab (event->device, handle, - GDK_OWNERSHIP_NONE, - FALSE, - (GDK_POINTER_MOTION_HINT_MASK - | GDK_BUTTON1_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK - | GDK_ENTER_NOTIFY_MASK - | GDK_LEAVE_NOTIFY_MASK), - NULL, event->time); -} - -static gboolean -gtk_xpaned_button_press (GtkWidget * widget, GdkEventButton * event) -{ - GtkXPaned *xpaned = GTK_XPANED (widget); - - /* if any child is currently maximized, jump right back */ - if (xpaned->maximized[GTK_XPANED_TOP_LEFT] || - xpaned->maximized[GTK_XPANED_TOP_RIGHT] || - xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] || - xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT]) - return FALSE; - - /* if user is dragging the handles around */ - if (!xpaned->in_drag_vert_and_horiz && - event->window != xpaned->handle_east && - event->window != xpaned->handle_west && - event->window != xpaned->handle_north && - event->window != xpaned->handle_south && - event->window == xpaned->handle_middle && event->button == 1) - { - xpaned->in_drag_vert_and_horiz = TRUE; - gtk_xpaned_button_press_grab (xpaned->handle_middle, event); - xpaned->drag_pos.x = event->x; - xpaned->drag_pos.y = event->y; - - return TRUE; - } - else if (!xpaned->in_drag_vert && - event->window == xpaned->handle_east && - event->window != xpaned->handle_west && - event->window != xpaned->handle_north && - event->window != xpaned->handle_south && - event->window != xpaned->handle_middle && event->button == 1) - { - xpaned->in_drag_vert = TRUE; - gtk_xpaned_button_press_grab (xpaned->handle_east, event); - xpaned->drag_pos.y = event->y; - - return TRUE; - } - else if (!xpaned->in_drag_vert && - event->window != xpaned->handle_east && - event->window == xpaned->handle_west && - event->window != xpaned->handle_north && - event->window != xpaned->handle_south && - event->window != xpaned->handle_middle && event->button == 1) - { - xpaned->in_drag_vert = TRUE; - gtk_xpaned_button_press_grab (xpaned->handle_west, event); - xpaned->drag_pos.y = event->y; - - return TRUE; - } - else if (!xpaned->in_drag_horiz && - event->window != xpaned->handle_east && - event->window != xpaned->handle_west && - event->window == xpaned->handle_north && - event->window != xpaned->handle_south && - event->window != xpaned->handle_middle && event->button == 1) - { - xpaned->in_drag_horiz = TRUE; - gtk_xpaned_button_press_grab (xpaned->handle_north, event); - xpaned->drag_pos.x = event->x; - - return TRUE; - } - else if (!xpaned->in_drag_horiz && - event->window != xpaned->handle_east && - event->window != xpaned->handle_west && - event->window != xpaned->handle_north && - event->window == xpaned->handle_south && - event->window != xpaned->handle_middle && event->button == 1) - { - xpaned->in_drag_horiz = TRUE; - gtk_xpaned_button_press_grab (xpaned->handle_south, event); - xpaned->drag_pos.x = event->x; - - return TRUE; - } - return FALSE; -} - -static gboolean -gtk_xpaned_button_release (GtkWidget * widget, GdkEventButton * event) -{ - GtkXPaned *xpaned = GTK_XPANED (widget); - - if (xpaned->in_drag_vert && (event->button == 1)) - { - xpaned->in_drag_vert = FALSE; - xpaned->drag_pos.y = -1; - xpaned->position_set = TRUE; - gdk_device_ungrab (event->device, event->time); - return TRUE; - } - else if (xpaned->in_drag_horiz && (event->button == 1)) - { - xpaned->in_drag_horiz = FALSE; - xpaned->drag_pos.x = -1; - xpaned->position_set = TRUE; - gdk_device_ungrab (event->device, event->time); - return TRUE; - } - else if (xpaned->in_drag_vert_and_horiz && (event->button == 1)) - { - xpaned->in_drag_vert_and_horiz = FALSE; - xpaned->drag_pos.x = -1; - xpaned->drag_pos.y = -1; - xpaned->position_set = TRUE; - gdk_device_ungrab (event->device, event->time); - return TRUE; - } - - return FALSE; -} - -static gboolean -gtk_xpaned_motion (GtkWidget * widget, GdkEventMotion * event) -{ - GtkXPaned *xpaned = GTK_XPANED (widget); - - if (xpaned->in_drag_vert || - xpaned->in_drag_horiz || xpaned->in_drag_vert_and_horiz) - - { - update_drag (xpaned); - return TRUE; - } - - return FALSE; -} - -void -gtk_xpaned_add_top_left (GtkXPaned * xpaned, GtkWidget * widget) -{ - gtk_xpaned_pack_top_left (xpaned, widget, FALSE, TRUE); -} - -void -gtk_xpaned_add_top_right (GtkXPaned * xpaned, GtkWidget * widget) -{ - gtk_xpaned_pack_top_right (xpaned, widget, FALSE, TRUE); -} - -void -gtk_xpaned_add_bottom_left (GtkXPaned * xpaned, GtkWidget * widget) -{ - gtk_xpaned_pack_bottom_left (xpaned, widget, FALSE, TRUE); -} - -void -gtk_xpaned_add_bottom_right (GtkXPaned * xpaned, GtkWidget * widget) -{ - gtk_xpaned_pack_bottom_right (xpaned, widget, FALSE, TRUE); -} - -void -gtk_xpaned_pack_top_left (GtkXPaned * xpaned, - GtkWidget * child, gboolean resize, gboolean shrink) -{ - g_return_if_fail (GTK_IS_XPANED (xpaned)); - g_return_if_fail (GTK_IS_WIDGET (child)); - - if (!xpaned->top_left_child) - { - xpaned->top_left_child = child; - xpaned->top_left_child_resize = resize; - xpaned->top_left_child_shrink = shrink; - - gtk_widget_set_parent (child, GTK_WIDGET (xpaned)); - } -} - -void -gtk_xpaned_pack_top_right (GtkXPaned * xpaned, - GtkWidget * child, - gboolean resize, gboolean shrink) -{ - g_return_if_fail (GTK_IS_XPANED (xpaned)); - g_return_if_fail (GTK_IS_WIDGET (child)); - - if (!xpaned->top_right_child) - { - xpaned->top_right_child = child; - xpaned->top_right_child_resize = resize; - xpaned->top_right_child_shrink = shrink; - - gtk_widget_set_parent (child, GTK_WIDGET (xpaned)); - } -} - -void -gtk_xpaned_pack_bottom_left (GtkXPaned * xpaned, - GtkWidget * child, - gboolean resize, gboolean shrink) -{ - g_return_if_fail (GTK_IS_XPANED (xpaned)); - g_return_if_fail (GTK_IS_WIDGET (child)); - - if (!xpaned->bottom_left_child) - { - xpaned->bottom_left_child = child; - xpaned->bottom_left_child_resize = resize; - xpaned->bottom_left_child_shrink = shrink; - - gtk_widget_set_parent (child, GTK_WIDGET (xpaned)); - } -} - -void -gtk_xpaned_pack_bottom_right (GtkXPaned * xpaned, - GtkWidget * child, - gboolean resize, gboolean shrink) -{ - g_return_if_fail (GTK_IS_XPANED (xpaned)); - g_return_if_fail (GTK_IS_WIDGET (child)); - - if (!xpaned->bottom_right_child) - { - xpaned->bottom_right_child = child; - xpaned->bottom_right_child_resize = resize; - xpaned->bottom_right_child_shrink = shrink; - - gtk_widget_set_parent (child, GTK_WIDGET (xpaned)); - } -} - -static void -gtk_xpaned_add (GtkContainer * container, GtkWidget * widget) -{ - GtkXPaned *xpaned; - - g_return_if_fail (GTK_IS_XPANED (container)); - - xpaned = GTK_XPANED (container); - - if (!xpaned->top_left_child) - gtk_xpaned_add_top_left (xpaned, widget); - else if (!xpaned->top_right_child) - gtk_xpaned_add_top_right (xpaned, widget); - else if (!xpaned->bottom_left_child) - gtk_xpaned_add_bottom_left (xpaned, widget); - else if (!xpaned->bottom_right_child) - gtk_xpaned_add_bottom_right (xpaned, widget); - else - g_warning ("GtkXPaned cannot have more than 4 children\n"); -} - -static void -gtk_xpaned_remove (GtkContainer * container, GtkWidget * widget) -{ - GtkXPaned *xpaned; - gboolean was_visible; - - xpaned = GTK_XPANED (container); - was_visible = gtk_widget_get_visible (widget); - - if (xpaned->top_left_child == widget) - { - gtk_widget_unparent (widget); - - xpaned->top_left_child = NULL; - - if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container))) - gtk_widget_queue_resize (GTK_WIDGET (container)); - } - else if (xpaned->top_right_child == widget) - { - gtk_widget_unparent (widget); - - xpaned->top_right_child = NULL; - - if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container))) - gtk_widget_queue_resize (GTK_WIDGET (container)); - } - else if (xpaned->bottom_left_child == widget) - { - gtk_widget_unparent (widget); - - xpaned->bottom_left_child = NULL; - - if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container))) - gtk_widget_queue_resize (GTK_WIDGET (container)); - } - else if (xpaned->bottom_right_child == widget) - { - gtk_widget_unparent (widget); - - xpaned->bottom_right_child = NULL; - - if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container))) - gtk_widget_queue_resize (GTK_WIDGET (container)); - } - else - g_warning ("GtkXPaned has no more children attached\n"); - -} - -static void -gtk_xpaned_forall (GtkContainer * container, - gboolean include_internals, - GtkCallback callback, gpointer callback_data) -{ - GtkXPaned *xpaned; - - g_return_if_fail (callback != NULL); - - xpaned = GTK_XPANED (container); - - if (xpaned->top_left_child) - (*callback) (xpaned->top_left_child, callback_data); - if (xpaned->top_right_child) - (*callback) (xpaned->top_right_child, callback_data); - if (xpaned->bottom_left_child) - (*callback) (xpaned->bottom_left_child, callback_data); - if (xpaned->bottom_right_child) - (*callback) (xpaned->bottom_right_child, callback_data); -} - -/** - * gtk_xpaned_get_position_x: - * @paned: a #GtkXPaned widget - * - * Obtains the x-position of the divider. - * - * Return value: x-position of the divider - **/ -gint -gtk_xpaned_get_position_x (GtkXPaned * xpaned) -{ - g_return_val_if_fail (GTK_IS_XPANED (xpaned), 0); - - return xpaned->top_left_child_size.width; -} - -/** - * gtk_xpaned_get_position_y: - * @paned: a #GtkXPaned widget - * - * Obtains the y-position of the divider. - * - * Return value: y-position of the divider - **/ -gint -gtk_xpaned_get_position_y (GtkXPaned * xpaned) -{ - g_return_val_if_fail (GTK_IS_XPANED (xpaned), 0); - - return xpaned->top_left_child_size.height; -} - -/** - * gtk_xpaned_set_position_x: - * @paned: a #GtkXPaned widget - * @xposition: pixel x-position of divider, a negative values - * of a component mean that the position is unset. - * - * Sets the x-position of the divider between the four panes. - **/ -void -gtk_xpaned_set_position_x (GtkXPaned * xpaned, gint xposition) -{ - GObject *object; - - g_return_if_fail (GTK_IS_XPANED (xpaned)); - - /* if any child is currently maximized, jump right back */ - if (xpaned->maximized[GTK_XPANED_TOP_LEFT] || - xpaned->maximized[GTK_XPANED_TOP_RIGHT] || - xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] || - xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT]) - return; - - object = G_OBJECT (xpaned); - - if (xposition >= 0) - { - /* We don't clamp here - the assumption is that - * if the total allocation changes at the same time - * as the position, the position set is with reference - * to the new total size. If only the position changes, - * then clamping will occur in gtk_paned_compute_position() - */ - - xpaned->top_left_child_size.width = xposition; - xpaned->position_set = TRUE; - } - else - { - xpaned->position_set = FALSE; - } - - g_object_freeze_notify (object); - g_object_notify (object, "x-position"); - g_object_notify (object, "position-set"); - g_object_thaw_notify (object); - - gtk_widget_queue_resize (GTK_WIDGET (xpaned)); -} - -/** - * gtk_xpaned_set_position_y: - * @paned: a #GtkXPaned widget - * @yposition: pixel y-position of divider, a negative values - * of a component mean that the position is unset. - * - * Sets the y-position of the divider between the four panes. - **/ -void -gtk_xpaned_set_position_y (GtkXPaned * xpaned, gint yposition) -{ - GObject *object; - - g_return_if_fail (GTK_IS_XPANED (xpaned)); - - /* if any child is currently maximized, jump right back */ - if (xpaned->maximized[GTK_XPANED_TOP_LEFT] || - xpaned->maximized[GTK_XPANED_TOP_RIGHT] || - xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] || - xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT]) - return; - - object = G_OBJECT (xpaned); - - if (yposition >= 0) - { - /* We don't clamp here - the assumption is that - * if the total allocation changes at the same time - * as the position, the position set is with reference - * to the new total size. If only the position changes, - * then clamping will occur in gtk_paned_compute_position() - */ - - xpaned->top_left_child_size.height = yposition; - xpaned->position_set = TRUE; - } - else - { - xpaned->position_set = FALSE; - } - - g_object_freeze_notify (object); - g_object_notify (object, "y-position"); - g_object_notify (object, "position-set"); - g_object_thaw_notify (object); - - gtk_widget_queue_resize (GTK_WIDGET (xpaned)); -} - -/* this call is private and only intended for internal use! */ -void -gtk_xpaned_save_unmaximized_x (GtkXPaned * xpaned) -{ - xpaned->unmaximized_position.x = gtk_xpaned_get_position_x (xpaned); -} - -/* this call is private and only intended for internal use! */ -void -gtk_xpaned_save_unmaximized_y (GtkXPaned * xpaned) -{ - xpaned->unmaximized_position.y = gtk_xpaned_get_position_y (xpaned); -} - -/* this call is private and only intended for internal use! */ -gint -gtk_xpaned_fetch_unmaximized_x (GtkXPaned * xpaned) -{ - return xpaned->unmaximized_position.x; -} - -/* this call is private and only intended for internal use! */ -gint -gtk_xpaned_fetch_unmaximized_y (GtkXPaned * xpaned) -{ - return xpaned->unmaximized_position.y; -} - -/** - * gtk_xpaned_get_top_left_child: - * @xpaned: a #GtkXPaned widget - * - * Obtains the top-left child of the xpaned widget. - * - * Return value: top-left child, or %NULL if it is not set. - * - * Since: 2.4 - **/ -GtkWidget * -gtk_xpaned_get_top_left_child (GtkXPaned * xpaned) -{ - g_return_val_if_fail (GTK_IS_XPANED (xpaned), NULL); - - return xpaned->top_left_child; -} - -/** - * gtk_xpaned_get_top_right_child: - * @xpaned: a #GtkXPaned widget - * - * Obtains the top-right child of the xpaned widget. - * - * Return value: top-right child, or %NULL if it is not set. - * - * Since: 2.4 - **/ -GtkWidget * -gtk_xpaned_get_top_right_child (GtkXPaned * xpaned) -{ - g_return_val_if_fail (GTK_IS_XPANED (xpaned), NULL); - - return xpaned->top_right_child; -} - -/** - * gtk_xpaned_get_bottom_left_child: - * @xpaned: a #GtkXPaned widget - * - * Obtains the bottom-left child of the xpaned widget. - * - * Return value: bottom-left child, or %NULL if it is not set. - * - * Since: 2.4 - **/ -GtkWidget * -gtk_xpaned_get_bottom_left_child (GtkXPaned * xpaned) -{ - g_return_val_if_fail (GTK_IS_XPANED (xpaned), NULL); - - return xpaned->bottom_left_child; -} - -/** - * gtk_xpaned_get_bottom_right_child: - * @xpaned: a #GtkXPaned widget - * - * Obtains the bottom-right child of the xpaned widget. - * - * Return value: bottom-right child, or %NULL if it is not set. - * - * Since: 2.4 - **/ -GtkWidget * -gtk_xpaned_get_bottom_right_child (GtkXPaned * xpaned) -{ - g_return_val_if_fail (GTK_IS_XPANED (xpaned), NULL); - - return xpaned->bottom_right_child; -} - -gboolean -gtk_xpaned_maximize_top_left (GtkXPaned * xpaned, gboolean maximize) -{ - if (maximize) - { - /* see if any child is already maximized */ - if (!xpaned->maximized[GTK_XPANED_TOP_LEFT] && - !xpaned->maximized[GTK_XPANED_TOP_RIGHT] && - !xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] && - !xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT]) - { - /* save current position */ - gtk_xpaned_save_unmaximized_x (xpaned); - gtk_xpaned_save_unmaximized_y (xpaned); - - /* set new maximized position */ - gtk_xpaned_set_position_x (xpaned, xpaned->max_position.x); - gtk_xpaned_set_position_y (xpaned, xpaned->max_position.y); - - /* mark maximized flag for top-left child */ - xpaned->maximized[GTK_XPANED_TOP_LEFT] = TRUE; - - return TRUE; - } - /* already one child maximized, report error */ - else - return FALSE; - } - else - { - /* verify that top-left child is really currently maximized */ - if (xpaned->maximized[GTK_XPANED_TOP_LEFT]) - { - /* clear maximized flat for top-left child */ - xpaned->maximized[GTK_XPANED_TOP_LEFT] = FALSE; - - /* restore unmaximized position */ - gtk_xpaned_set_position_x (xpaned, - gtk_xpaned_fetch_unmaximized_x (xpaned)); - gtk_xpaned_set_position_y (xpaned, - gtk_xpaned_fetch_unmaximized_y (xpaned)); - - return TRUE; - } - /* top-left child is currently not maximized, report error */ - else - return FALSE; - } -} - -gboolean -gtk_xpaned_maximize_top_right (GtkXPaned * xpaned, gboolean maximize) -{ - if (maximize) - { - /* see if any child is already maximized */ - if (!xpaned->maximized[GTK_XPANED_TOP_LEFT] && - !xpaned->maximized[GTK_XPANED_TOP_RIGHT] && - !xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] && - !xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT]) - { - /* save current position */ - gtk_xpaned_save_unmaximized_x (xpaned); - gtk_xpaned_save_unmaximized_y (xpaned); - - /* set new maximized position */ - gtk_xpaned_set_position_x (xpaned, xpaned->min_position.x); - gtk_xpaned_set_position_y (xpaned, xpaned->max_position.y); - - /* mark maximized flag for top-right child */ - xpaned->maximized[GTK_XPANED_TOP_RIGHT] = TRUE; - - return TRUE; - } - /* already one child maximized, report error */ - else - return FALSE; - } - else - { - /* verify that top-right child is really currently maximized */ - if (xpaned->maximized[GTK_XPANED_TOP_RIGHT]) - { - /* clear maximized flat for top-right child */ - xpaned->maximized[GTK_XPANED_TOP_RIGHT] = FALSE; - - /* restore unmaximized position */ - gtk_xpaned_set_position_x (xpaned, - gtk_xpaned_fetch_unmaximized_x (xpaned)); - gtk_xpaned_set_position_y (xpaned, - gtk_xpaned_fetch_unmaximized_y (xpaned)); - - return TRUE; - } - /* top-right child is currently not maximized, report error */ - else - return FALSE; - } -} - -gboolean -gtk_xpaned_maximize_bottom_left (GtkXPaned * xpaned, gboolean maximize) -{ - if (maximize) - { - /* see if any child is already maximized */ - if (!xpaned->maximized[GTK_XPANED_TOP_LEFT] && - !xpaned->maximized[GTK_XPANED_TOP_RIGHT] && - !xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] && - !xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT]) - { - /* save current position */ - gtk_xpaned_save_unmaximized_x (xpaned); - gtk_xpaned_save_unmaximized_y (xpaned); - - /* set new maximized position */ - gtk_xpaned_set_position_x (xpaned, xpaned->max_position.x); - gtk_xpaned_set_position_y (xpaned, xpaned->min_position.y); - - /* mark maximized flag for bottom-left child */ - xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] = TRUE; - - return TRUE; - } - /* already one child maximized, report error */ - else - return FALSE; - } - else - { - /* verify that bottom-left child is really currently maximized */ - if (xpaned->maximized[GTK_XPANED_BOTTOM_LEFT]) - { - /* clear maximized flat for bottom-left child */ - xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] = FALSE; - - /* restore unmaximized position */ - gtk_xpaned_set_position_x (xpaned, - gtk_xpaned_fetch_unmaximized_x (xpaned)); - gtk_xpaned_set_position_y (xpaned, - gtk_xpaned_fetch_unmaximized_y (xpaned)); - - return TRUE; - } - /* bottom-left child is currently not maximized, report error */ - else - return FALSE; - } -} - -gboolean -gtk_xpaned_maximize_bottom_right (GtkXPaned * xpaned, gboolean maximize) -{ - if (maximize) - { - /* see if any child is already maximized */ - if (!xpaned->maximized[GTK_XPANED_TOP_LEFT] && - !xpaned->maximized[GTK_XPANED_TOP_RIGHT] && - !xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] && - !xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT]) - { - /* save current position */ - gtk_xpaned_save_unmaximized_x (xpaned); - gtk_xpaned_save_unmaximized_y (xpaned); - - /* set new maximized position */ - gtk_xpaned_set_position_x (xpaned, xpaned->min_position.x); - gtk_xpaned_set_position_y (xpaned, xpaned->min_position.y); - - /* mark maximized flag for bottom-right child */ - xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT] = TRUE; - - return TRUE; - } - /* already one child maximized, report error */ - else - return FALSE; - } - else - { - /* verify that bottom-right child is really currently maximized */ - if (xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT]) - { - /* clear maximized flat for bottom-right child */ - xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT] = FALSE; - - /* restore unmaximized position */ - gtk_xpaned_set_position_x (xpaned, - gtk_xpaned_fetch_unmaximized_x (xpaned)); - gtk_xpaned_set_position_y (xpaned, - gtk_xpaned_fetch_unmaximized_y (xpaned)); - - return TRUE; - } - /* bottom-right child is currently not maximized, report error */ - else - return FALSE; - } -} - -void -gtk_xpaned_compute_position (GtkXPaned * xpaned, - const GtkAllocation * allocation, - GtkRequisition * top_left_child_req, - GtkRequisition * top_right_child_req, - GtkRequisition * bottom_left_child_req, - GtkRequisition * bottom_right_child_req) -{ - GdkPoint old_position; - GdkPoint old_min_position; - GdkPoint old_max_position; - gint handle_size; - gint border_width = gtk_container_get_border_width (GTK_CONTAINER (xpaned)); - - g_return_if_fail (GTK_IS_XPANED (xpaned)); - - old_position.x = xpaned->top_left_child_size.width; - old_position.y = xpaned->top_left_child_size.height; - old_min_position.x = xpaned->min_position.x; - old_min_position.y = xpaned->min_position.y; - old_max_position.x = xpaned->max_position.x; - old_max_position.y = xpaned->max_position.y; - - xpaned->min_position.x = - xpaned->top_left_child_shrink ? 0 : top_left_child_req->width; - xpaned->min_position.y = - xpaned->top_left_child_shrink ? 0 : top_left_child_req->height; - - gtk_widget_style_get (GTK_WIDGET (xpaned), "handle-size", &handle_size, - NULL); - - xpaned->max_position.x = allocation->width - 2 * border_width - handle_size; - xpaned->max_position.y = - allocation->height - 2 * border_width - handle_size; - if (!xpaned->top_left_child_shrink) - xpaned->max_position.x = - MAX (1, xpaned->max_position.x - top_left_child_req->width); - xpaned->max_position.x = - MAX (xpaned->min_position.x, xpaned->max_position.x); - - if (!xpaned->position_set) - { - if (xpaned->top_left_child_resize && !xpaned->top_right_child_resize) - { - xpaned->top_left_child_size.width = - MAX (0, allocation->width - top_right_child_req->width); - xpaned->top_left_child_size.height = - MAX (0, allocation->height - top_right_child_req->height); - } - else if (!xpaned->top_left_child_resize - && xpaned->top_right_child_resize) - { - xpaned->top_left_child_size.width = top_left_child_req->width; - xpaned->top_left_child_size.height = top_left_child_req->height; - } - else - { - xpaned->top_left_child_size.width = allocation->width * 0.5 + 0.5; - xpaned->top_left_child_size.height = allocation->height * 0.5 + 0.5; - } - } - else - { - /* If the position was set before the initial allocation. - ** (paned->last_allocation <= 0) just clamp it and leave it. */ - if (xpaned->last_allocation.width > 0) - { - if (xpaned->top_left_child_resize - && !xpaned->top_right_child_resize) - { - xpaned->top_left_child_size.width += allocation->width - - xpaned->last_allocation.width; - - xpaned->top_left_child_size.height += allocation->height - - xpaned->last_allocation.height; - } - else - if (! - (!xpaned->top_left_child_resize - && xpaned->top_right_child_resize)) - { - xpaned->top_left_child_size.width = allocation->width - * ((gdouble) xpaned->top_left_child_size.width / - (xpaned->last_allocation.width)) + 0.5; - - xpaned->top_left_child_size.height = allocation->height - * ((gdouble) xpaned->top_left_child_size.height / - (xpaned->last_allocation.height)) + 0.5; - } - } - if (xpaned->last_allocation.height > 0) - { - if (xpaned->top_left_child_resize - && !xpaned->top_right_child_resize) - { - xpaned->top_left_child_size.width += - allocation->width - xpaned->last_allocation.width; - xpaned->top_left_child_size.height += - allocation->height - xpaned->last_allocation.height; - } - else - if (! - (!xpaned->top_left_child_resize - && xpaned->top_right_child_resize)) - { - xpaned->top_left_child_size.width = - allocation->width * - ((gdouble) xpaned->top_left_child_size.width / - (xpaned->last_allocation.width)) + 0.5; - xpaned->top_left_child_size.height = - allocation->height * - ((gdouble) xpaned->top_left_child_size.height / - (xpaned->last_allocation.height)) + 0.5; - } - } - - } - - xpaned->top_left_child_size.width = - CLAMP (xpaned->top_left_child_size.width, xpaned->min_position.x, - xpaned->max_position.x); - xpaned->top_left_child_size.height = - CLAMP (xpaned->top_left_child_size.height, xpaned->min_position.y, - xpaned->max_position.y); - - xpaned->top_right_child_size.width = - CLAMP (xpaned->top_right_child_size.width, xpaned->min_position.x, - xpaned->max_position.x); - xpaned->top_right_child_size.height = - CLAMP (xpaned->top_right_child_size.height, xpaned->min_position.y, - xpaned->max_position.y); - - xpaned->bottom_left_child_size.width = - CLAMP (xpaned->bottom_left_child_size.width, xpaned->min_position.x, - xpaned->max_position.x); - xpaned->bottom_left_child_size.height = - CLAMP (xpaned->bottom_left_child_size.height, xpaned->min_position.y, - xpaned->max_position.y); - - xpaned->bottom_right_child_size.width = - CLAMP (xpaned->bottom_right_child_size.width, xpaned->min_position.x, - xpaned->max_position.x); - xpaned->bottom_right_child_size.height = - CLAMP (xpaned->bottom_right_child_size.height, xpaned->min_position.y, - xpaned->max_position.y); - - gtk_widget_set_child_visible (xpaned->top_left_child, TRUE); - gtk_widget_set_child_visible (xpaned->top_right_child, TRUE); - gtk_widget_set_child_visible (xpaned->bottom_left_child, TRUE); - gtk_widget_set_child_visible (xpaned->bottom_right_child, TRUE); - - g_object_freeze_notify (G_OBJECT (xpaned)); - - if (xpaned->top_left_child_size.width != old_position.x) - g_object_notify (G_OBJECT (xpaned), "x-position"); - if (xpaned->top_left_child_size.height != old_position.y) - g_object_notify (G_OBJECT (xpaned), "y-position"); - - if (xpaned->top_right_child_size.width != old_position.x) - g_object_notify (G_OBJECT (xpaned), "x-position"); - if (xpaned->top_right_child_size.height != old_position.y) - g_object_notify (G_OBJECT (xpaned), "y-position"); - - if (xpaned->bottom_left_child_size.width != old_position.x) - g_object_notify (G_OBJECT (xpaned), "x-position"); - if (xpaned->bottom_left_child_size.height != old_position.y) - g_object_notify (G_OBJECT (xpaned), "y-position"); - - if (xpaned->bottom_right_child_size.width != old_position.x) - g_object_notify (G_OBJECT (xpaned), "x-position"); - if (xpaned->bottom_right_child_size.height != old_position.y) - g_object_notify (G_OBJECT (xpaned), "y-position"); - - if (xpaned->min_position.x != old_min_position.x) - g_object_notify (G_OBJECT (xpaned), "min-x-position"); - if (xpaned->min_position.y != old_min_position.y) - g_object_notify (G_OBJECT (xpaned), "min-y-position"); - - if (xpaned->max_position.x != old_max_position.x) - g_object_notify (G_OBJECT (xpaned), "max-y-position"); - if (xpaned->max_position.y != old_max_position.y) - g_object_notify (G_OBJECT (xpaned), "max-y-position"); - - g_object_thaw_notify (G_OBJECT (xpaned)); - - xpaned->last_allocation.width = allocation->width; - xpaned->last_allocation.height = allocation->height; -} - -static void -gtk_xpaned_set_saved_focus (GtkXPaned * xpaned, GtkWidget * widget) -{ - if (xpaned->priv->saved_focus) - g_object_remove_weak_pointer (G_OBJECT (xpaned->priv->saved_focus), - (gpointer *) & (xpaned->priv->saved_focus)); - - xpaned->priv->saved_focus = widget; - - if (xpaned->priv->saved_focus) - g_object_add_weak_pointer (G_OBJECT (xpaned->priv->saved_focus), - (gpointer *) & (xpaned->priv->saved_focus)); -} - -static void -gtk_xpaned_set_first_xpaned (GtkXPaned * xpaned, GtkXPaned * first_xpaned) -{ - if (xpaned->priv->first_xpaned) - g_object_remove_weak_pointer (G_OBJECT (xpaned->priv->first_xpaned), - (gpointer *) & (xpaned->priv-> - first_xpaned)); - - xpaned->priv->first_xpaned = first_xpaned; - - if (xpaned->priv->first_xpaned) - g_object_add_weak_pointer (G_OBJECT (xpaned->priv->first_xpaned), - (gpointer *) & (xpaned->priv->first_xpaned)); -} - -static void -gtk_xpaned_set_last_top_left_child_focus (GtkXPaned * xpaned, - GtkWidget * widget) -{ - if (xpaned->last_top_left_child_focus) - g_object_remove_weak_pointer (G_OBJECT - (xpaned->last_top_left_child_focus), - (gpointer *) & (xpaned-> - last_top_left_child_focus)); - - xpaned->last_top_left_child_focus = widget; - - if (xpaned->last_top_left_child_focus) - g_object_add_weak_pointer (G_OBJECT (xpaned->last_top_left_child_focus), - (gpointer *) & (xpaned-> - last_top_left_child_focus)); -} - -static void -gtk_xpaned_set_last_top_right_child_focus (GtkXPaned * xpaned, - GtkWidget * widget) -{ - if (xpaned->last_top_right_child_focus) - g_object_remove_weak_pointer (G_OBJECT - (xpaned->last_top_right_child_focus), - (gpointer *) & (xpaned-> - last_top_right_child_focus)); - - xpaned->last_top_right_child_focus = widget; - - if (xpaned->last_top_right_child_focus) - g_object_add_weak_pointer (G_OBJECT (xpaned->last_top_right_child_focus), - (gpointer *) & (xpaned-> - last_top_right_child_focus)); -} - -static void -gtk_xpaned_set_last_bottom_left_child_focus (GtkXPaned * xpaned, - GtkWidget * widget) -{ - if (xpaned->last_bottom_left_child_focus) - g_object_remove_weak_pointer (G_OBJECT - (xpaned->last_bottom_left_child_focus), - (gpointer *) & (xpaned-> - last_bottom_left_child_focus)); - - xpaned->last_bottom_left_child_focus = widget; - - if (xpaned->last_bottom_left_child_focus) - g_object_add_weak_pointer (G_OBJECT - (xpaned->last_bottom_left_child_focus), - (gpointer *) & (xpaned-> - last_bottom_left_child_focus)); -} - -static void -gtk_xpaned_set_last_bottom_right_child_focus (GtkXPaned * xpaned, - GtkWidget * widget) -{ - if (xpaned->last_bottom_right_child_focus) - g_object_remove_weak_pointer (G_OBJECT - (xpaned->last_bottom_right_child_focus), - (gpointer *) & (xpaned-> - last_bottom_right_child_focus)); - - xpaned->last_bottom_right_child_focus = widget; - - if (xpaned->last_bottom_right_child_focus) - g_object_add_weak_pointer (G_OBJECT - (xpaned->last_bottom_right_child_focus), - (gpointer *) & (xpaned-> - last_bottom_right_child_focus)); -} - -static GtkWidget * -xpaned_get_focus_widget (GtkXPaned * xpaned) -{ - GtkWidget *toplevel; - - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (xpaned)); - if (gtk_widget_is_toplevel (toplevel)) - return gtk_window_get_focus (GTK_WINDOW (toplevel)); - - return NULL; -} - -static void -gtk_xpaned_set_focus_child (GtkContainer * container, GtkWidget * focus_child) -{ - GtkXPaned *xpaned; - - g_return_if_fail (GTK_IS_XPANED (container)); - - xpaned = GTK_XPANED (container); - - if (focus_child == NULL) - { - GtkWidget *last_focus; - GtkWidget *w; - - last_focus = xpaned_get_focus_widget (xpaned); - - if (last_focus) - { - /* If there is one or more paned widgets between us and the - * focus widget, we want the topmost of those as last_focus - */ - for (w = last_focus; w != GTK_WIDGET (xpaned); w = gtk_widget_get_parent (w)) - if (GTK_IS_XPANED (w)) - last_focus = w; - - if (gtk_container_get_focus_child (container) == xpaned->top_left_child) - gtk_xpaned_set_last_top_left_child_focus (xpaned, last_focus); - else if (gtk_container_get_focus_child (container) == xpaned->top_right_child) - gtk_xpaned_set_last_top_right_child_focus (xpaned, last_focus); - else if (gtk_container_get_focus_child (container) == xpaned->bottom_left_child) - gtk_xpaned_set_last_bottom_left_child_focus (xpaned, last_focus); - else if (gtk_container_get_focus_child (container) == xpaned->bottom_right_child) - gtk_xpaned_set_last_bottom_right_child_focus (xpaned, last_focus); - } - } - - if (parent_class->set_focus_child) - (*parent_class->set_focus_child) (container, focus_child); -} - -static void -gtk_xpaned_get_cycle_chain (GtkXPaned * xpaned, - GtkDirectionType direction, GList ** widgets) -{ - GtkContainer *container = GTK_CONTAINER (xpaned); - GtkWidget *ancestor = NULL; - GList *temp_list = NULL; - GList *list; - - if (xpaned->in_recursion) - return; - - g_assert (widgets != NULL); - - if (xpaned->last_top_left_child_focus && - !gtk_widget_is_ancestor (xpaned->last_top_left_child_focus, - GTK_WIDGET (xpaned))) - { - gtk_xpaned_set_last_top_left_child_focus (xpaned, NULL); - } - - if (xpaned->last_top_right_child_focus && - !gtk_widget_is_ancestor (xpaned->last_top_right_child_focus, - GTK_WIDGET (xpaned))) - { - gtk_xpaned_set_last_top_right_child_focus (xpaned, NULL); - } - - if (xpaned->last_bottom_left_child_focus && - !gtk_widget_is_ancestor (xpaned->last_bottom_left_child_focus, - GTK_WIDGET (xpaned))) - { - gtk_xpaned_set_last_bottom_left_child_focus (xpaned, NULL); - } - - if (xpaned->last_bottom_right_child_focus && - !gtk_widget_is_ancestor (xpaned->last_bottom_right_child_focus, - GTK_WIDGET (xpaned))) - { - gtk_xpaned_set_last_bottom_right_child_focus (xpaned, NULL); - } - - if (gtk_widget_get_parent (GTK_WIDGET (xpaned))) - ancestor = gtk_widget_get_ancestor (gtk_widget_get_parent (GTK_WIDGET (xpaned)), - GTK_TYPE_XPANED); - - /* The idea here is that temp_list is a list of widgets we want to cycle - * to. The list is prioritized so that the first element is our first - * choice, the next our second, and so on. - * - * We can't just use g_list_reverse(), because we want to try - * paned->last_child?_focus before paned->child?, both when we - * are going forward and backward. - */ - if (direction == GTK_DIR_TAB_FORWARD) - { - if (gtk_container_get_focus_child (container) == xpaned->top_left_child) - { - temp_list = - g_list_append (temp_list, xpaned->last_top_right_child_focus); - temp_list = g_list_append (temp_list, xpaned->top_right_child); - temp_list = g_list_append (temp_list, ancestor); - } - else if (gtk_container_get_focus_child (container) == xpaned->top_right_child) - { - temp_list = g_list_append (temp_list, ancestor); - temp_list = - g_list_append (temp_list, xpaned->last_bottom_left_child_focus); - temp_list = g_list_append (temp_list, xpaned->bottom_left_child); - } - else if (gtk_container_get_focus_child (container) == xpaned->bottom_left_child) - { - temp_list = g_list_append (temp_list, ancestor); - temp_list = - g_list_append (temp_list, xpaned->last_bottom_right_child_focus); - temp_list = g_list_append (temp_list, xpaned->bottom_right_child); - } - else if (gtk_container_get_focus_child (container) == xpaned->bottom_right_child) - { - temp_list = g_list_append (temp_list, ancestor); - temp_list = - g_list_append (temp_list, xpaned->last_top_left_child_focus); - temp_list = g_list_append (temp_list, xpaned->top_left_child); - } - else - { - temp_list = - g_list_append (temp_list, xpaned->last_top_left_child_focus); - temp_list = g_list_append (temp_list, xpaned->top_left_child); - temp_list = - g_list_append (temp_list, xpaned->last_top_right_child_focus); - temp_list = g_list_append (temp_list, xpaned->top_right_child); - temp_list = - g_list_append (temp_list, xpaned->last_bottom_left_child_focus); - temp_list = g_list_append (temp_list, xpaned->bottom_left_child); - temp_list = - g_list_append (temp_list, xpaned->last_bottom_right_child_focus); - temp_list = g_list_append (temp_list, xpaned->bottom_right_child); - temp_list = g_list_append (temp_list, ancestor); - } - } - else - { - if (gtk_container_get_focus_child (container) == xpaned->top_left_child) - { - temp_list = g_list_append (temp_list, ancestor); - temp_list = - g_list_append (temp_list, xpaned->last_top_right_child_focus); - temp_list = g_list_append (temp_list, xpaned->top_right_child); - } - else if (gtk_container_get_focus_child (container) == xpaned->top_right_child) - { - temp_list = - g_list_append (temp_list, xpaned->last_bottom_left_child_focus); - temp_list = g_list_append (temp_list, xpaned->bottom_left_child); - temp_list = g_list_append (temp_list, ancestor); - } - else if (gtk_container_get_focus_child (container) == xpaned->bottom_right_child) - { - temp_list = - g_list_append (temp_list, xpaned->last_bottom_left_child_focus); - temp_list = g_list_append (temp_list, xpaned->bottom_left_child); - temp_list = g_list_append (temp_list, ancestor); - } - else if (gtk_container_get_focus_child (container) == xpaned->top_right_child) - { - temp_list = - g_list_append (temp_list, xpaned->last_bottom_left_child_focus); - temp_list = g_list_append (temp_list, xpaned->bottom_left_child); - temp_list = g_list_append (temp_list, ancestor); - } - else - { - temp_list = - g_list_append (temp_list, xpaned->last_bottom_right_child_focus); - temp_list = g_list_append (temp_list, xpaned->bottom_right_child); - temp_list = - g_list_append (temp_list, xpaned->last_bottom_left_child_focus); - temp_list = g_list_append (temp_list, xpaned->bottom_left_child); - temp_list = - g_list_append (temp_list, xpaned->last_top_right_child_focus); - temp_list = g_list_append (temp_list, xpaned->top_right_child); - temp_list = - g_list_append (temp_list, xpaned->last_top_left_child_focus); - temp_list = g_list_append (temp_list, xpaned->top_left_child); - temp_list = g_list_append (temp_list, ancestor); - } - } - - /* Walk the list and expand all the paned widgets. */ - for (list = temp_list; list != NULL; list = list->next) - { - GtkWidget *widget = list->data; - - if (widget) - { - if (GTK_IS_XPANED (widget)) - { - xpaned->in_recursion = TRUE; - gtk_xpaned_get_cycle_chain (GTK_XPANED (widget), - direction, widgets); - xpaned->in_recursion = FALSE; - } - else - { - *widgets = g_list_append (*widgets, widget); - } - } - } - - g_list_free (temp_list); -} - -static gboolean -gtk_xpaned_cycle_child_focus (GtkXPaned * xpaned, gboolean reversed) -{ - GList *cycle_chain = NULL; - GList *list; - - GtkDirectionType direction = - reversed ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD; - - /* ignore f6 if the handle is focused */ - if (gtk_widget_is_focus (GTK_WIDGET (xpaned))) - return TRUE; - - /* we can't just let the event propagate up the hierarchy, - * because the paned will want to cycle focus _unless_ an - * ancestor paned handles the event - */ - gtk_xpaned_get_cycle_chain (xpaned, direction, &cycle_chain); - - for (list = cycle_chain; list != NULL; list = list->next) - if (gtk_widget_child_focus (GTK_WIDGET (list->data), direction)) - break; - - g_list_free (cycle_chain); - - return TRUE; -} - -static void -get_child_xpanes (GtkWidget * widget, GList ** xpanes) -{ - if (GTK_IS_XPANED (widget)) - { - GtkXPaned *xpaned = GTK_XPANED (widget); - - get_child_xpanes (xpaned->top_left_child, xpanes); - *xpanes = g_list_prepend (*xpanes, widget); - get_child_xpanes (xpaned->top_right_child, xpanes); - *xpanes = g_list_prepend (*xpanes, widget); - get_child_xpanes (xpaned->bottom_left_child, xpanes); - *xpanes = g_list_prepend (*xpanes, widget); - get_child_xpanes (xpaned->bottom_right_child, xpanes); - } - else if (GTK_IS_CONTAINER (widget)) - { - gtk_container_foreach (GTK_CONTAINER (widget), - (GtkCallback) get_child_xpanes, xpanes); - } -} - -static GList * -get_all_xpanes (GtkXPaned * xpaned) -{ - GtkXPaned *topmost = NULL; - GList *result = NULL; - GtkWidget *w; - - for (w = GTK_WIDGET (xpaned); w != NULL; w = gtk_widget_get_parent (w)) - { - if (GTK_IS_XPANED (w)) - topmost = GTK_XPANED (w); - } - - g_assert (topmost); - - get_child_xpanes (GTK_WIDGET (topmost), &result); - - return g_list_reverse (result); -} - -static void -gtk_xpaned_find_neighbours (GtkXPaned * xpaned, - GtkXPaned ** next, GtkXPaned ** prev) -{ - GList *all_xpanes; - GList *this_link; - - all_xpanes = get_all_xpanes (xpaned); - g_assert (all_xpanes); - - this_link = g_list_find (all_xpanes, xpaned); - - g_assert (this_link); - - if (this_link->next) - *next = this_link->next->data; - else - *next = all_xpanes->data; - - if (this_link->prev) - *prev = this_link->prev->data; - else - *prev = g_list_last (all_xpanes)->data; - - g_list_free (all_xpanes); -} - -static gboolean -gtk_xpaned_move_handle (GtkXPaned * xpaned, GtkScrollType scroll) -{ - if (gtk_widget_is_focus (GTK_WIDGET (xpaned))) - { - GdkPoint old_position; - GdkPoint new_position; - gint increment; - - enum - { - SINGLE_STEP_SIZE = 1, - PAGE_STEP_SIZE = 75 - }; - - new_position.x = old_position.x = gtk_xpaned_get_position_x (xpaned); - new_position.y = old_position.y = gtk_xpaned_get_position_y (xpaned); - increment = 0; - - switch (scroll) - { - case GTK_SCROLL_STEP_LEFT: - case GTK_SCROLL_STEP_UP: - case GTK_SCROLL_STEP_BACKWARD: - increment = -SINGLE_STEP_SIZE; - break; - - case GTK_SCROLL_STEP_RIGHT: - case GTK_SCROLL_STEP_DOWN: - case GTK_SCROLL_STEP_FORWARD: - increment = SINGLE_STEP_SIZE; - break; - - case GTK_SCROLL_PAGE_LEFT: - case GTK_SCROLL_PAGE_UP: - case GTK_SCROLL_PAGE_BACKWARD: - increment = -PAGE_STEP_SIZE; - break; - - case GTK_SCROLL_PAGE_RIGHT: - case GTK_SCROLL_PAGE_DOWN: - case GTK_SCROLL_PAGE_FORWARD: - increment = PAGE_STEP_SIZE; - break; - - case GTK_SCROLL_START: - new_position.x = xpaned->min_position.x; - new_position.y = xpaned->min_position.y; - break; - - case GTK_SCROLL_END: - new_position.x = xpaned->max_position.x; - new_position.y = xpaned->max_position.y; - break; - - default: - break; - } - - if (increment) - { - if (is_rtl (xpaned)) - increment = -increment; - - new_position.x = old_position.x + increment; - new_position.y = old_position.y + increment; - } - - new_position.x = CLAMP (new_position.x, - xpaned->min_position.x, xpaned->max_position.x); - - new_position.y = CLAMP (new_position.y, - xpaned->min_position.y, xpaned->max_position.y); - - if (old_position.x != new_position.x) - gtk_xpaned_set_position_x (xpaned, new_position.x); - - if (old_position.y != new_position.y) - gtk_xpaned_set_position_y (xpaned, new_position.y); - - return TRUE; - } - - return FALSE; -} - -static void -gtk_xpaned_restore_focus (GtkXPaned * xpaned) -{ - if (gtk_widget_is_focus (GTK_WIDGET (xpaned))) - { - if (xpaned->priv->saved_focus && - gtk_widget_get_sensitive (xpaned->priv->saved_focus)) - { - gtk_widget_grab_focus (xpaned->priv->saved_focus); - } - else - { - /* the saved focus is somehow not available for focusing, - * try - * 1) tabbing into the paned widget - * if that didn't work, - * 2) unset focus for the window if there is one - */ - - if (!gtk_widget_child_focus - (GTK_WIDGET (xpaned), GTK_DIR_TAB_FORWARD)) - { - GtkWidget *toplevel = - gtk_widget_get_toplevel (GTK_WIDGET (xpaned)); - - if (GTK_IS_WINDOW (toplevel)) - gtk_window_set_focus (GTK_WINDOW (toplevel), NULL); - } - } - - gtk_xpaned_set_saved_focus (xpaned, NULL); - gtk_xpaned_set_first_xpaned (xpaned, NULL); - } -} - -static gboolean -gtk_xpaned_accept_position (GtkXPaned * xpaned) -{ - if (gtk_widget_is_focus (GTK_WIDGET (xpaned))) - { - xpaned->original_position.x = -1; - xpaned->original_position.y = -1; - gtk_xpaned_restore_focus (xpaned); - - return TRUE; - } - - return FALSE; -} - -static gboolean -gtk_xpaned_cancel_position (GtkXPaned * xpaned) -{ - if (gtk_widget_is_focus (GTK_WIDGET (xpaned))) - { - if (xpaned->original_position.x != -1) - { - gtk_xpaned_set_position_x (xpaned, xpaned->original_position.x); - xpaned->original_position.x = -1; - } - - if (xpaned->original_position.y != -1) - { - gtk_xpaned_set_position_y (xpaned, xpaned->original_position.y); - xpaned->original_position.y = -1; - } - - gtk_xpaned_restore_focus (xpaned); - return TRUE; - } - - return FALSE; -} - -static gboolean -gtk_xpaned_cycle_handle_focus (GtkXPaned * xpaned, gboolean reversed) -{ - GtkXPaned *next; - GtkXPaned *prev; - - if (gtk_widget_is_focus (GTK_WIDGET (xpaned))) - { - GtkXPaned *focus = NULL; - - if (!xpaned->priv->first_xpaned) - { - /* The first_pane has disappeared. As an ad-hoc solution, - * we make the currently focused paned the first_paned. To the - * user this will seem like the paned cycling has been reset. - */ - gtk_xpaned_set_first_xpaned (xpaned, xpaned); - } - - gtk_xpaned_find_neighbours (xpaned, &next, &prev); - - if (reversed && prev && - prev != xpaned && xpaned != xpaned->priv->first_xpaned) - { - focus = prev; - } - else if (!reversed && - next && next != xpaned && next != xpaned->priv->first_xpaned) - { - focus = next; - } - else - { - gtk_xpaned_accept_position (xpaned); - return TRUE; - } - - g_assert (focus); - - gtk_xpaned_set_saved_focus (focus, xpaned->priv->saved_focus); - gtk_xpaned_set_first_xpaned (focus, xpaned->priv->first_xpaned); - - gtk_xpaned_set_saved_focus (xpaned, NULL); - gtk_xpaned_set_first_xpaned (xpaned, NULL); - - gtk_widget_grab_focus (GTK_WIDGET (focus)); - - if (!gtk_widget_is_focus (GTK_WIDGET (xpaned))) - { - xpaned->original_position.x = -1; - xpaned->original_position.y = -1; - focus->original_position.x = gtk_xpaned_get_position_x (focus); - focus->original_position.y = gtk_xpaned_get_position_y (focus); - } - } - else - { - GtkContainer *container = GTK_CONTAINER (xpaned); - GtkXPaned *focus; - GtkXPaned *first; - GtkXPaned *prev; - GtkXPaned *next; - GtkWidget *toplevel; - - gtk_xpaned_find_neighbours (xpaned, &next, &prev); - - if (gtk_container_get_focus_child (container) == xpaned->top_left_child) - { - if (reversed) - { - focus = prev; - first = xpaned; - } - else - { - focus = xpaned; - first = xpaned; - } - } - else if (gtk_container_get_focus_child (container) == xpaned->top_right_child) - { - if (reversed) - { - focus = xpaned; - first = next; - } - else - { - focus = next; - first = next; - } - } - else - { - /* Focus is not inside this xpaned, and we don't have focus. - * Presumably this happened because the application wants us - * to start keyboard navigating. - */ - focus = xpaned; - - if (reversed) - first = xpaned; - else - first = next; - } - - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (xpaned)); - - if (GTK_IS_WINDOW (toplevel)) - gtk_xpaned_set_saved_focus (focus, - gtk_window_get_focus (GTK_WINDOW (toplevel))); - gtk_xpaned_set_first_xpaned (focus, first); - focus->original_position.x = gtk_xpaned_get_position_x (focus); - focus->original_position.y = gtk_xpaned_get_position_y (focus); - - gtk_widget_grab_focus (GTK_WIDGET (focus)); - } - - return TRUE; -} - -static gboolean -gtk_xpaned_toggle_handle_focus (GtkXPaned * xpaned) -{ - /* This function/signal has the wrong name. It is called when you - * press Tab or Shift-Tab and what we do is act as if - * the user pressed Return and then Tab or Shift-Tab - */ - if (gtk_widget_is_focus (GTK_WIDGET (xpaned))) - gtk_xpaned_accept_position (xpaned); - - return FALSE; -} - -/*#define __GTK_XPANED_C__*/ -/*#include "gtkaliasdef.c"*/ diff --git a/lib/gtk-contrib/gtkxpaned.h b/lib/gtk-contrib/gtkxpaned.h deleted file mode 100644 index bb6b196949..0000000000 --- a/lib/gtk-contrib/gtkxpaned.h +++ /dev/null @@ -1,183 +0,0 @@ -/******************************************************************************* -**3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 -** 10 20 30 40 50 60 70 80 -** -** library for GtkXPaned-widget, a 2x2 grid-like variation of GtkPaned of gtk+ -** Copyright (C) 2005-2006 Mirco "MacSlow" Müller -** -** This library is free software; you can redistribute it and/or -** modify it under the terms of the GNU Lesser General Public -** License as published by the Free Software Foundation; either -** version 2.1 of the License, or (at your option) any later version. -** -** This library is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public -** License along with this library; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -** -** GtkXPaned is based on GtkPaned which was done by... -** -** "Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald" -** -** and later modified by... -** -** "the GTK+ Team and others 1997-2000" -** -*******************************************************************************/ - -#ifndef GTK_XPANED_H -#define GTK_XPANED_H - -#include - -G_BEGIN_DECLS -#define GTK_TYPE_XPANED (gtk_xpaned_get_type ()) -#define GTK_XPANED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_XPANED, GtkXPaned)) -#define GTK_XPANED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_XPANED, GtkXPanedClass)) -#define GTK_IS_XPANED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_XPANED)) -#define GTK_IS_XPANED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_XPANED)) -#define GTK_XPANED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_XPANED, GtkXPanedClass)) -typedef struct _GtkXPaned GtkXPaned; -typedef struct _GtkXPanedClass GtkXPanedClass; -typedef struct _GtkXPanedPrivate GtkXPanedPrivate; - -typedef enum _GtkXPanedChild -{ - GTK_XPANED_TOP_LEFT = 0, - GTK_XPANED_TOP_RIGHT, - GTK_XPANED_BOTTOM_LEFT, - GTK_XPANED_BOTTOM_RIGHT -} GtkXPanedChild; - -struct _GtkXPaned -{ - GtkContainer container; - - GtkWidget *top_left_child; - GtkWidget *top_right_child; - GtkWidget *bottom_left_child; - GtkWidget *bottom_right_child; - - GdkWindow *handle_east; - GdkWindow *handle_west; - GdkWindow *handle_north; - GdkWindow *handle_south; - GdkWindow *handle_middle; - - GdkCursorType cursor_type_east; - GdkCursorType cursor_type_west; - GdkCursorType cursor_type_north; - GdkCursorType cursor_type_south; - GdkCursorType cursor_type_middle; - - /*< private > */ - GdkRectangle handle_pos_east; - GdkRectangle handle_pos_west; - GdkRectangle handle_pos_north; - GdkRectangle handle_pos_south; - GdkRectangle handle_pos_middle; - GtkRequisition top_left_child_size; - GtkRequisition top_right_child_size; - GtkRequisition bottom_left_child_size; - GtkRequisition bottom_right_child_size; - - GtkRequisition last_allocation; - GdkPoint min_position; - GdkPoint max_position; - gboolean maximized[4]; - - guint position_set:1; - guint in_drag_vert:1; - guint in_drag_horiz:1; - guint in_drag_vert_and_horiz:1; - guint top_left_child_shrink:1; - guint top_left_child_resize:1; - guint top_right_child_shrink:1; - guint top_right_child_resize:1; - guint bottom_left_child_shrink:1; - guint bottom_left_child_resize:1; - guint bottom_right_child_shrink:1; - guint bottom_right_child_resize:1; - guint in_recursion:1; - guint handle_prelit:1; - - GtkWidget *last_top_left_child_focus; - GtkWidget *last_top_right_child_focus; - GtkWidget *last_bottom_left_child_focus; - GtkWidget *last_bottom_right_child_focus; - GtkXPanedPrivate *priv; - - GdkPoint drag_pos; - GdkPoint original_position; - GdkPoint unmaximized_position; -}; - -struct _GtkXPanedClass -{ - GtkContainerClass parent_class; - gboolean (*cycle_child_focus) (GtkXPaned * xpaned, gboolean reverse); - gboolean (*toggle_handle_focus) (GtkXPaned * xpaned); - gboolean (*move_handle) (GtkXPaned * xpaned, GtkScrollType scroll); - gboolean (*cycle_handle_focus) (GtkXPaned * xpaned, gboolean reverse); - gboolean (*accept_position) (GtkXPaned * xpaned); - gboolean (*cancel_position) (GtkXPaned * xpaned); -}; - -GType -gtk_xpaned_get_type (void) - G_GNUC_CONST; - GtkWidget *gtk_xpaned_new (void); - void gtk_xpaned_add_top_left (GtkXPaned * xpaned, GtkWidget * child); - void gtk_xpaned_add_top_right (GtkXPaned * xpaned, GtkWidget * child); - void gtk_xpaned_add_bottom_left (GtkXPaned * xpaned, GtkWidget * child); - void gtk_xpaned_add_bottom_right (GtkXPaned * xpaned, GtkWidget * child); - void gtk_xpaned_pack_top_left (GtkXPaned * xpaned, GtkWidget * child, - gboolean resize, gboolean shrink); - void gtk_xpaned_pack_top_right (GtkXPaned * xpaned, GtkWidget * child, - gboolean resize, gboolean shrink); - void gtk_xpaned_pack_bottom_left (GtkXPaned * xpaned, GtkWidget * child, - gboolean resize, gboolean shrink); - void gtk_xpaned_pack_bottom_right (GtkXPaned * xpaned, GtkWidget * child, - gboolean resize, gboolean shrink); - gint gtk_xpaned_get_position_x (GtkXPaned * xpaned); - gint gtk_xpaned_get_position_y (GtkXPaned * xpaned); - void gtk_xpaned_set_position_x (GtkXPaned * xpaned, gint xposition); - void gtk_xpaned_set_position_y (GtkXPaned * xpaned, gint yposition); - void gtk_xpaned_save_unmaximized_x (GtkXPaned * xpaned); - void gtk_xpaned_save_unmaximized_y (GtkXPaned * xpaned); - gint gtk_xpaned_fetch_unmaximized_x (GtkXPaned * xpaned); - gint gtk_xpaned_fetch_unmaximized_y (GtkXPaned * xpaned); - GtkWidget *gtk_xpaned_get_top_left_child (GtkXPaned * xpaned); - GtkWidget *gtk_xpaned_get_top_right_child (GtkXPaned * xpaned); - GtkWidget *gtk_xpaned_get_bottom_right_child (GtkXPaned * xpaned); - GtkWidget *gtk_xpaned_get_bottom_left_child (GtkXPaned * xpaned); - gboolean gtk_xpaned_maximize_top_left (GtkXPaned * xpaned, - gboolean maximize); - gboolean gtk_xpaned_maximize_top_right (GtkXPaned * xpaned, - gboolean maximize); - gboolean gtk_xpaned_maximize_bottom_left (GtkXPaned * xpaned, - gboolean maximize); - gboolean gtk_xpaned_maximize_bottom_right (GtkXPaned * xpaned, - gboolean maximize); - -/* Internal function */ -#if !defined (GTK_DISABLE_DEPRECATED) || defined (GTK_COMPILATION) - void gtk_xpaned_compute_position (GtkXPaned * xpaned, - const GtkAllocation * allocation, - GtkRequisition * top_left_child_req, - GtkRequisition * top_right_child_req, - GtkRequisition * bottom_left_child_req, - GtkRequisition * - bottom_right_child_req); -#endif /* !GTK_DISABLE_DEPRECATED || GTK_COMPILATION */ -#ifndef GTK_DISABLE_DEPRECATED -#define gtk_xpaned_gutter_size(p,s) (void) 0 -#define gtk_xpaned_set_gutter_size(p,s) (void) 0 -#endif /* GTK_DISABLE_DEPRECATED */ - -G_END_DECLS -#endif /* GTK_XPANED_H */ diff --git a/src/ui/gui/automake.mk b/src/ui/gui/automake.mk index 3b85412e55..434fffe088 100644 --- a/src/ui/gui/automake.mk +++ b/src/ui/gui/automake.mk @@ -92,7 +92,6 @@ endif src_ui_gui_psppire_LDADD = \ - lib/gtk-contrib/libxpaned.a \ src/ui/libuicommon.la \ src/libpspp.la \ src/libpspp-core.la \ diff --git a/src/ui/gui/psppire-data-editor.c b/src/ui/gui/psppire-data-editor.c index d3e921d3b7..7c2ff2ad05 100644 --- a/src/ui/gui/psppire-data-editor.c +++ b/src/ui/gui/psppire-data-editor.c @@ -20,7 +20,6 @@ #include "ui/gui/psppire-data-editor.h" #include -#include #include "data/datasheet.h" #include "data/value-labels.h"