Projects
Extra
gtk-vector-screenshot
_service:obs_scm:gtk-vector-screenshot-0.3.3.ob...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:gtk-vector-screenshot-0.3.3.obscpio of Package gtk-vector-screenshot
07070100000000000081A4000000000000000000000001637488D2000000CE000000000000000000000000000000000000004400000000gtk-vector-screenshot-0.3.3/52load-gtk-vector-screenshot-gtk-module# This file is sourced by Xsession(5), not executed. if [ -z "$GTK3_MODULES" ] ; then GTK3_MODULES="gtk-vector-screenshot" else GTK3_MODULES="$GTK3_MODULES:gtk-vector-screenshot" fi export GTK3_MODULES 07070100000001000081A4000000000000000000000001637488D2000067A2000000000000000000000000000000000000002400000000gtk-vector-screenshot-0.3.3/COPYING GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the library's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. <signature of Ty Coon>, 1 April 1990 Ty Coon, President of Vice That's all there is to it! 07070100000002000081A4000000000000000000000001637488D20000065A000000000000000000000000000000000000002600000000gtk-vector-screenshot-0.3.3/ChangeLoggtk-vector-screenshot (0.3.3) * Drop the noop gtk2 module (used to quench a warning about missing gtk module), set GTK3_MODULES instead. -- Joachim Breitner <mail@joachim-breitner.de> Sat, 22 Jun 2013 22:13:25 +0200 gtk-vector-screenshot (0.3.2.1) * Fix linking problem -- Joachim Breitner <mail@joachim-breitner.de> Sat, 22 Jun 2013 22:13:25 +0200 gtk-vector-screenshot (0.3.2) * The BadWindow error situation was futher improved by Michel Dänzer. -- Joachim Breitner <mail@joachim-breitner.de> Mon, 17 Oct 2011 19:37:46 +0200 gtk-vector-screenshot (0.3.1) * Petr Gajdůšek <gajdusek.petr@centrum.cz> reported, analyized and patched an issue causing gtk application to crash with BadWindow errors when the gtk-vector-screenshot module is loaded. -- Joachim Breitner <mail@joachim-breitner.de> Sat, 27 Aug 2011 10:55:43 +0200 gtk-vector-screenshot (0.3) * Uses code from xwininfo to reliably find the right X window, even with window managers such as metacity. * Smaller Save-As dialogue even with large application windows. Help getting this dialogue right with regard to sizing and resizing would be appreciated! -- Joachim Breitner <mail@joachim-breitner.de> Sun, 10 Jul 2011 12:18:18 +0200 gtk-vector-screenshot (0.2) * Now with separate control application take-vector-screenshot and unobstrusive module that can be loaded permanently. -- Joachim Breitner <mail@joachim-breitner.de> Fri, 24 Jun 2011 16:06:13 +0200 gtk-vector-screenshot (0.1) * Initial release. -- Joachim Breitner <mail@joachim-breitner.de> Mon, 20 Jun 2011 14:50:42 +0200 07070100000003000081A4000000000000000000000001637488D2000002DE000000000000000000000000000000000000002800000000gtk-vector-screenshot-0.3.3/Makefile.ammoduledir = $(libdir)/gtk-3.0/modules libgtk_vector_screenshot_la_SOURCES = gtk-vector-screenshot.c libgtk_vector_screenshot_la_LDFLAGS = \ -rpath $(moduledir) -module -avoid-version -export-dynamic\ $(GTK3_LIBS) \ $(X_LIBS) \ @LDFLAGS@ libgtk_vector_screenshot_la_LIBADD = module_LTLIBRARIES = libgtk-vector-screenshot.la take_vector_screenshot_SOURCES = take-vector-screenshot.c clientwin.c clientwin.h take_vector_screenshot_LDFLAGS = \ $(GTK3_LIBS) \ $(X_LIBS) \ @LDFLAGS@ bin_PROGRAMS = take-vector-screenshot INCLUDES = \ $(GTK3_CFLAGS) \ $(X_CFLAGS) take_screenshotdir = $(datadir)/applications dist_take_screenshot_DATA = take-vector-screenshot.desktop EXTRA_DIST = 52load-gtk-vector-screenshot-gtk-module 07070100000004000081A4000000000000000000000001637488D200000B84000000000000000000000000000000000000002300000000gtk-vector-screenshot-0.3.3/READMEgtk vector screenshot module ============================ © 2011 Joachim Breitner <mail@joachim-breitner.de> This gtk module allows you to take a screenshot of a running gtk-3 application as a vector image, with fully scalable graphics and selectable text. It supports rendering the application to PDF, SVG and PostScript. Installation ============ To install the module, use the usual sequence: ./configure --prefix=/usr make sudo make install And then ensure that the environment variable GTK_MODULES includes gtk-vector-screenshot, e.g. in ~/.xsessionrc or by putting the file 52load-gtk-vector-screenshot-gtk-module into /etc/X11/Xsession.d. If you do not install into /usr, you will have set GTK_PATH or pass the full path of gtk-vector-screencast.so via GTK_MODULES when invoking the application. Usage ===== You need to ensure that the gtk-vector-screenshot module is loaded by the application, see section Installation. Distribution packages should take care of this, but you might need to login again after you install the package. Then run take-vector-screenshot, press the button, click on the window and then you can select the filename to save the image under. You can watch a screencast of the program in action at http://www.joachim-breitner.de/blog/archives/494-Better-PDF-screenshots-with-gtk-3.html Protocol ======== The module is loaded by every application, and only activated using the take-vector-screenshot program. The protocol is simple and based on X window properties and X client messages: The gtk module sets the GTK_VECTOR_SCREENSHOT property for each top-level X window to some arbitrary value (currently "supported"). The control application sends an XClientMessage event to that window of type GTK_VECTOR_SCREENSHOT and with event.window set to the receiving window. Development =========== The latest release can be found on http://www.joachim-breitner.de/archive/gtk-vector-screenshot/ For the list of changes, see ChangeLog. The code is hosted on gitorious.org: https://gitorious.org/gtk-vector-screenshot/gtk-vector-screenshot You can pull from the repository via git clone git://gitorious.org/gtk-vector-screenshot/gtk-vector-screenshot.git or if you are registered with gitorious, via git@gitorious.org:gtk-vector-screenshot/gtk-vector-screenshot.git Feel free to submit patches, but also feel free to contact me first with your ideas, in case I have different plans. BUGS and TODOs ============== * It only works with gtk3 applications. * The screenshot is taken the moment you press Save in the file chooser dialogue, not when you press the “Take vector screenshot” button. * Make the preview widget behave more sensible with regard to resizes. * Less hakish setting of the GTK_VECTOR_SCREENSHOT property. * Fallback code without IPC for windows, as for version 0.2. * Use GtkInvisible for the grab in take-vector-screenshot.c, as that is what its meant for, it seems. 07070100000005000081A4000000000000000000000001637488D2000017CB000000000000000000000000000000000000002800000000gtk-vector-screenshot-0.3.3/clientwin.c/* * Copyright 2007 Kim woelders * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting documentation, and * that the name of the copyright holders not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. The copyright holders make no representations * about the suitability of this software for any purpose. It is provided "as * is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include <X11/Xatom.h> #include <X11/Xlib.h> #include "clientwin.h" static Atom atom_wm_state = None; /* * Check if window has given property */ static Bool Window_Has_Property(Display * dpy, Window win, Atom atom) { Atom type_ret; int format_ret; unsigned char *prop_ret; unsigned long bytes_after, num_ret; type_ret = None; prop_ret = NULL; XGetWindowProperty(dpy, win, atom, 0, 0, False, AnyPropertyType, &type_ret, &format_ret, &num_ret, &bytes_after, &prop_ret); if (prop_ret) XFree(prop_ret); return (type_ret != None) ? True : False; } /* * Check if window is viewable */ static Bool Window_Is_Viewable(Display * dpy, Window win) { Bool ok; XWindowAttributes xwa; XGetWindowAttributes(dpy, win, &xwa); ok = (xwa.class == InputOutput) && (xwa.map_state == IsViewable); return ok; } /* * Find a window that has WM_STATE set in the window tree below win. * Unmapped/unviewable windows are not considered valid matches. * Children are searched in top-down stacking order. * The first matching window is returned, None if no match is found. */ static Window Find_Client_In_Children(Display * dpy, Window win) { Window root, parent; Window *children; unsigned int n_children; int i; if (!XQueryTree(dpy, win, &root, &parent, &children, &n_children)) return None; if (!children) return None; /* Check each child for WM_STATE and other validity */ win = None; for (i = (int) n_children - 1; i >= 0; i--) { if (!Window_Is_Viewable(dpy, children[i])) { children[i] = None; /* Don't bother descending into this one */ continue; } if (!Window_Has_Property(dpy, children[i], atom_wm_state)) continue; /* Got one */ win = children[i]; goto done; } /* No children matched, now descend into each child */ for (i = (int) n_children - 1; i >= 0; i--) { if (children[i] == None) continue; win = Find_Client_In_Children(dpy, children[i]); if (win != None) break; } done: XFree(children); return win; } /* * Find virtual roots (_NET_VIRTUAL_ROOTS) */ static unsigned long * Find_Roots(Display * dpy, Window root, unsigned int *num) { Atom type_ret; int format_ret; unsigned char *prop_ret; unsigned long bytes_after, num_ret; Atom atom; *num = 0; atom = XInternAtom(dpy, "_NET_VIRTUAL_ROOTS", False); if (!atom) return NULL; type_ret = None; prop_ret = NULL; if (XGetWindowProperty(dpy, root, atom, 0, 0x7fffffff, False, XA_WINDOW, &type_ret, &format_ret, &num_ret, &bytes_after, &prop_ret) != Success) return NULL; if (prop_ret && type_ret == XA_WINDOW && format_ret == 32) { *num = num_ret; return ((unsigned long *) prop_ret); } if (prop_ret) XFree(prop_ret); return NULL; } /* * Find child window at pointer location */ static Window Find_Child_At_Pointer(Display * dpy, Window win) { Window root_return, child_return; int dummyi; unsigned int dummyu; XQueryPointer(dpy, win, &root_return, &child_return, &dummyi, &dummyi, &dummyi, &dummyi, &dummyu); return child_return; } /* * Find client window at pointer location * * root is the root window. * subwin is the subwindow reported by a ButtonPress event on root. * * If the WM uses virtual roots subwin may be a virtual root. * If so, we descend the window stack at the pointer location and assume the * child is the client or one of its WM frame windows. * This will of course work only if the virtual roots are children of the real * root. */ Window Find_Client(Display * dpy, Window root, Window subwin) { unsigned long *roots; unsigned int i, n_roots; Window win; /* Check if subwin is a virtual root */ roots = Find_Roots(dpy, root, &n_roots); for (i = 0; i < n_roots; i++) { if (subwin != roots[i]) continue; win = Find_Child_At_Pointer(dpy, subwin); if (win == None) return subwin; /* No child - Return virtual root. */ subwin = win; break; } if (roots) XFree(roots); if (atom_wm_state == None) { atom_wm_state = XInternAtom(dpy, "WM_STATE", False); if (!atom_wm_state) return subwin; } /* Check if subwin has WM_STATE */ if (Window_Has_Property(dpy, subwin, atom_wm_state)) return subwin; /* Attempt to find a client window in subwin's children */ win = Find_Client_In_Children(dpy, subwin); if (win != None) return win; /* Found a client */ /* Did not find a client */ return subwin; } 07070100000006000081A4000000000000000000000001637488D200000538000000000000000000000000000000000000002800000000gtk-vector-screenshot-0.3.3/clientwin.h/* * Copyright 2007 Kim woelders * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting documentation, and * that the name of the copyright holders not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. The copyright holders make no representations * about the suitability of this software for any purpose. It is provided "as * is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _CLIENTWIN_H_ #define _CLIENTWIN_H_ #include <X11/Xlib.h> extern Window Find_Client(Display * dpy, Window root, Window target_win); #endif 07070100000007000081A4000000000000000000000001637488D200000597000000000000000000000000000000000000002900000000gtk-vector-screenshot-0.3.3/configure.acAC_INIT(gtk-vector-screenshot, 0.3.3, mail@joachim-breitner.de) AC_PREREQ(2.50) AC_COPYRIGHT([Copyright 2011-2020 Joachim Breitner]) dnl ################################################################ dnl # Initialize automake dnl ################################################################ VERSION=0.1 PACKAGE=gtk-vector-screenshot AM_INIT_AUTOMAKE([foreign]) #### libtool stuff #### LT_PREREQ(2.2) LT_INIT([disable-static]) dnl ################################################################ dnl # Specify a header configuration file dnl ################################################################ AM_CONFIG_HEADER(config.h) dnl ################################################################ dnl # Check for some standard stuff. dnl ################################################################ AC_PROG_CPP AC_PROG_MAKE_SET AC_PROG_LN_S AC_PROG_INSTALL AM_PROG_LIBTOOL AC_C_CONST AC_TYPE_SIZE_T AC_EXEEXT PKG_CHECK_MODULES(GTK3, [gtk+-3.0 >= 2.90]) AC_SUBST(GTK3_CFLAGS) AC_SUBST(GTK3_LIBS) PKG_CHECK_MODULES(X, [x11]) AC_SUBST(X_CFLAGS) AC_SUBST(X_LIBS) CFLAGS="$CFLAGS -std=gnu99" dnl # Use wall if we have GCC if test "x$GCC" = "xyes"; then CFLAGS="$CFLAGS -Wall" fi AC_SUBST(CFLAGS) dnl ################################################################ dnl # Output the Makefiles dnl ################################################################ AC_CONFIG_FILES([ Makefile ]) AC_OUTPUT 07070100000008000041ED000000000000000000000003637488D200000000000000000000000000000000000000000000002300000000gtk-vector-screenshot-0.3.3/debian07070100000009000081A4000000000000000000000001637488D200000875000000000000000000000000000000000000002D00000000gtk-vector-screenshot-0.3.3/debian/changeloggtk-vector-screenshot (0.3.3-2) UNRELEASED; urgency=medium * Trim trailing whitespace. * Use secure URI in Homepage field. * Bump debhelper from deprecated 7 to 10. * Fix field name cases in debian/control (VCS-Browser ⇒ Vcs-Browser, VCS-Git ⇒ Vcs-Git). -- Debian Janitor <janitor@jelmer.uk> Tue, 15 Nov 2022 00:14:16 -0000 gtk-vector-screenshot (0.3.3-1) unstable; urgency=medium * Drop gtk2 dependency (Closes: 967479) -- Joachim Breitner <nomeata@debian.org> Fri, 28 Aug 2020 10:09:51 +0200 gtk-vector-screenshot (0.3.2.1-2) unstable; urgency=medium * Install GTK modules into MA directories. Closes: 693050 Thanks to Iain for the patch, and Andreas Henriksson for the nudge. -- Joachim Breitner <nomeata@debian.org> Mon, 21 Sep 2015 08:52:07 +0200 gtk-vector-screenshot (0.3.2.1-1) unstable; urgency=low * Fix "FTBFS: ld: clientwin.o: undefined reference to symbol 'XGetWindowAttributes'" (Closes: #713542) -- Joachim Breitner <nomeata@debian.org> Sat, 22 Jun 2013 22:16:29 +0200 gtk-vector-screenshot (0.3.2-1) unstable; urgency=low * New upstream version + The BadWindow error situation was futher improved by Michel Dänzer. (Closes: # 645509) -- Joachim Breitner <nomeata@debian.org> Mon, 17 Oct 2011 19:45:09 +0200 gtk-vector-screenshot (0.3.1-1) unstable; urgency=low * New upstream version + Prevents BadWindow X-Protocol errors in random application. Thanks to Petr Gajdůšek for reporting, analyzing and fixing the bug. (Closes: #639328) -- Joachim Breitner <nomeata@debian.org> Sat, 27 Aug 2011 10:58:13 +0200 gtk-vector-screenshot (0.3-1) unstable; urgency=low * New upstream release, works with metacity now. -- Joachim Breitner <nomeata@debian.org> Sun, 10 Jul 2011 12:24:50 +0200 gtk-vector-screenshot (0.2-2) unstable; urgency=low * Duh, completely forgot about the Build-Depends (Closes: #632120) -- Joachim Breitner <nomeata@debian.org> Thu, 30 Jun 2011 10:27:31 +0200 gtk-vector-screenshot (0.2-1) unstable; urgency=low * Initial release. (Closes: #631324) -- Joachim Breitner <nomeata@debian.org> Fri, 24 Jun 2011 16:06:13 +0200 0707010000000A000081A4000000000000000000000001637488D200000003000000000000000000000000000000000000002A00000000gtk-vector-screenshot-0.3.3/debian/compat10 0707010000000B000081A4000000000000000000000001637488D20000031A000000000000000000000000000000000000002B00000000gtk-vector-screenshot-0.3.3/debian/controlSource: gtk-vector-screenshot Maintainer: Joachim Breitner <nomeata@debian.org> Standards-Version: 3.9.2 Section: gnome Priority: optional Build-Depends: cdbs (>= 0.4.93~), debhelper (>= 10~), pkg-config, libgtk-3-dev, Homepage: https://www.joachim-breitner.de/projects#gtk-vector-screenshot Vcs-Git: git://git.nomeata.de/gtk-vector-screenshot.git Vcs-Browser: http://git.nomeata.de/?p=gtk-vector-screenshot.git Package: gtk-vector-screenshot Architecture: any Depends: ${misc:Depends}, ${shlibs:Depends} Description: takes screenshots of applications as PDF or SVG files This gtk module allows you to take a screenshot of a running gtk-3 application as a vector image, with fully scalable graphics and selectable text. It supports rendering the application to PDF, SVG and PostScript. 0707010000000C000081A4000000000000000000000001637488D200000879000000000000000000000000000000000000002D00000000gtk-vector-screenshot-0.3.3/debian/copyrightThis package was debianized by Joachim Breitner <nomeata@debian.org> on Fri, 24 Jun 2011 15:14:52 +0200 It was downloaded from http://www.joachim-breitner.de/projects#gtk-vector-screenshot Copyright: © 2011 Joachim Breitner <mail@joachim-breitner.de> License: This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. The LGPL is available in /usr/share/common-licenses/LGPL-2.1 on Debian systems. The files clientwin.c and clientwin.h are copied from xwininfo, git repository git://anongit.freedesktop.org/xorg/app/xwininfo, commit 123ff05c2e2bbdb9d7d6d958d9f096cf854b8360. They are Copyright: 2007 Kim woelders and are distributed under the terms fo the following license: documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of the copyright holders not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. The copyright holders make no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 0707010000000D000081A4000000000000000000000001637488D20000003C000000000000000000000000000000000000004100000000gtk-vector-screenshot-0.3.3/debian/gtk-vector-screenshot.install52load-gtk-vector-screenshot-gtk-module /etc/X11/Xsession.d 0707010000000E000081ED000000000000000000000001637488D2000001A9000000000000000000000000000000000000002900000000gtk-vector-screenshot-0.3.3/debian/rules#!/usr/bin/make -f include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/autotools.mk DEB_CONFIGURE_EXTRA_FLAGS += --libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) common-install-arch:: find $(DEB_DESTDIR) -name "*.la" -delete DEB_DH_MAKESHLIBS_ARGS_ALL += --exclude=usr/lib/$(DEB_HOST_MULTIARCH)/gtk-2.0/modules DEB_DH_MAKESHLIBS_ARGS_ALL += --exclude=usr/lib/$(DEB_HOST_MULTIARCH)/gtk-3.0/modules 0707010000000F000041ED000000000000000000000002637488D200000000000000000000000000000000000000000000002A00000000gtk-vector-screenshot-0.3.3/debian/source07070100000010000081A4000000000000000000000001637488D20000000C000000000000000000000000000000000000003100000000gtk-vector-screenshot-0.3.3/debian/source/format3.0 (quilt) 07070100000011000081A4000000000000000000000001637488D200000070000000000000000000000000000000000000002900000000gtk-vector-screenshot-0.3.3/debian/watchversion=3 http://www.joachim-breitner.de/archive/gtk-vector-screenshot/gtk-vector-screenshot-([\d\.]+)\.tar\.gz 07070100000012000081A4000000000000000000000001637488D20000332F000000000000000000000000000000000000003400000000gtk-vector-screenshot-0.3.3/gtk-vector-screenshot.c/* * © 2011 Joachim Breitner <mail@joachim-breitner.de> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ // For strchrnul #define _GNU_SOURCE #include <math.h> #include <string.h> #include <libgen.h> #include <gtk/gtk.h> #include <gdk/gdkx.h> #include <cairo-pdf.h> #include <cairo-svg.h> #include <cairo-ps.h> #include <X11/Xlib.h> #include <X11/Xutil.h> #ifndef MAX #define MAX(a,b) (((a)>(b))?(a):(b)) #endif /* MAX */ #ifndef MIN #define MIN(a,b) (((a)<(b))?(a):(b)) #endif /* MIN */ gchar *filename; const gchar *type; GdkAtom pdfscreenshot_atom; char *supported_str = "supported"; XErrorHandler old_handler = (XErrorHandler) 0 ; /* * This function handles the file type combo box callback in the Save As * dialogue. I would have expected that such functionality is already provided * by gtk... */ void pdfscreenshot_type_selected(GtkComboBox *format_combo, GtkFileChooser *chooser) { // The id is known to be the file extension. const char *the_id = gtk_combo_box_get_active_id(GTK_COMBO_BOX(format_combo)); // Update filter, to only display appropriate files. GtkFileFilter *filter = gtk_file_filter_new (); char *pattern = g_strdup_printf("*.%s", the_id); gtk_file_filter_add_pattern (filter, pattern); gtk_file_chooser_set_filter (GTK_FILE_CHOOSER(chooser), filter); // Update filename extension in the chooser gchar *filename = gtk_file_chooser_get_filename(chooser); if (filename != NULL) { // strdup result from basename as we are going to modify it. char *base = g_strdup(basename(filename)); // Remove extension from string, if there is one. *(strchrnul(base, '.')) = '\0'; // Assemble and set new suggested filename char *new_filename = g_strdup_printf("%s.%s", base, the_id); gtk_file_chooser_set_current_name(chooser, new_filename); g_free(filename); g_free(base); g_free(new_filename); } } /* * This function draws the main window in the preview pane of the Save As * dialogue. Not very useful, but we do it because we can. */ void pdfscreenshot_draw_preview (GtkWidget *widget, cairo_t *cr, gpointer window) { int draw_width = gtk_widget_get_allocated_width (widget); int draw_height = gtk_widget_get_allocated_height (widget); int win_width = gtk_widget_get_allocated_width (window); int win_height = gtk_widget_get_allocated_height (window); gtk_widget_set_size_request (widget, MIN(win_width,500), MIN(win_height,300)); double scale = fmin(1, fmax (1.0*draw_width / win_width, 1.0*draw_height / win_height)); cairo_scale(cr, scale, scale); cairo_translate(cr, (draw_width - scale * win_width)/2, (draw_height - scale * win_height)/2); gtk_widget_draw(window, cr); } /* * The main routine of saving a vector screenshot. Surprisingly simple. It is * parametized by the cairo surface creating function, as they all have the * same signature. */ void pdfscreenshot_draw_to_vector (GtkWidget *widget, const gchar* filename, cairo_surface_t * create_surface(const char *, double , double )) { cairo_surface_t *surface = create_surface(filename, 1.0*gtk_widget_get_allocated_width (widget), 1.0*gtk_widget_get_allocated_height (widget)); cairo_t *cr = cairo_create(surface); gtk_widget_draw(widget, cr); cairo_destroy(cr); cairo_surface_destroy(surface); } /* * Like above, but for PNG. Needs slightly different order of cairo function calls. */ void pdfscreenshot_draw_to_png (GtkWidget *widget, const gchar* filename) { cairo_surface_t *surface = cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, gtk_widget_get_allocated_width (widget), gtk_widget_get_allocated_height (widget)); cairo_t *cr = cairo_create(surface); gtk_widget_draw(widget, cr); cairo_destroy(cr); cairo_surface_write_to_png (surface, filename); cairo_surface_destroy(surface); } /* * Called when the main button is pressed. Finds the main window, displays the * file chooser and saves the screenshot. */ void pdfscreenshot_take_shot (GtkWindow *window) { // Set up the file chooser GtkWidget *chooser = gtk_file_chooser_dialog_new ( "Save vector screenshot", window, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); // Suggested file name derived from the application name. if (filename == NULL) { char *filename = g_strdup_printf("%s.pdf", g_get_application_name()); gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (chooser), filename); g_free(filename); } else gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (chooser), filename); // Some generally useful setup for a Save As dialogue gtk_window_set_transient_for (GTK_WINDOW(chooser), GTK_WINDOW(window)); gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (chooser), TRUE); // The combo box that selects the desired file type. We (ab)use the // id field for the file extension. GtkWidget *format_combo = gtk_combo_box_text_new (); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(format_combo), "pdf", "Save as PDF (*.pdf)"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(format_combo), "svg", "Save as SVG (*.svg)"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(format_combo), "ps", "Save as PostScript (*.ps)"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(format_combo), "png", "Save as PNG (*.png)"); // When this changes, we call pdfscreenshot_type_selected. g_signal_connect(GTK_COMBO_BOX(format_combo),"changed", G_CALLBACK(pdfscreenshot_type_selected), chooser); // Default to PDF gtk_combo_box_set_active_id(GTK_COMBO_BOX(format_combo),type); // The framed drawing area is used for a preview of the window, as a gimmick. GtkWidget *drawing_area = gtk_drawing_area_new (); g_signal_connect (G_OBJECT (drawing_area), "draw", G_CALLBACK (pdfscreenshot_draw_preview), window); int win_width = gtk_widget_get_allocated_width (GTK_WIDGET(window)); int win_height = gtk_widget_get_allocated_height (GTK_WIDGET(window)); gtk_widget_set_size_request (drawing_area, MIN(win_width,500), MIN(win_height,300)); GtkWidget *frame = gtk_aspect_frame_new("Preview",0.5,0,1,TRUE); gtk_container_add(GTK_CONTAINER(frame), drawing_area); // Shove both widgets in a vbox as the “extra” of the file chooser dialogue GtkWidget *vbox = gtk_vbox_new(FALSE, 8); gtk_box_pack_start(GTK_BOX(vbox), format_combo, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); gtk_widget_show_all(vbox); gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(chooser), vbox); // Run the dialogue and act if OK was pressed if (gtk_dialog_run (GTK_DIALOG(chooser)) == GTK_RESPONSE_ACCEPT) { // Read the filename and selected file type g_free(filename); filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser)); type = gtk_combo_box_get_active_id(GTK_COMBO_BOX(format_combo)); // And save according to the selected file type. if (!g_strcmp0(type,"pdf")) pdfscreenshot_draw_to_vector(GTK_WIDGET(window),filename, cairo_pdf_surface_create); else if (!g_strcmp0(type,"svg")) pdfscreenshot_draw_to_vector(GTK_WIDGET(window),filename, cairo_svg_surface_create); else if (!g_strcmp0(type,"ps")) pdfscreenshot_draw_to_vector(GTK_WIDGET(window),filename, cairo_ps_surface_create); else if (!g_strcmp0(type,"png")) pdfscreenshot_draw_to_png(GTK_WIDGET(window),filename); else // Should not happen. printf("Unknown id \"%s\"\n", type); } gtk_widget_destroy (chooser); } gboolean pdfscreenshot_take_shot_soon (gpointer window) { pdfscreenshot_take_shot(GTK_WINDOW(window)); return FALSE; } /* * Called when the main button is pressed. Finds the main window, and calls * pdfscreenshot_take_shot. */ void pdfscreenshot_find_window (GtkButton *button, gpointer our_window) { GList *toplevels = gtk_window_list_toplevels(); for (GList *iter = toplevels; iter; iter = g_list_next(iter)) { GtkWindow *window = GTK_WINDOW(iter->data); const gchar *title = gtk_window_get_title(window); if (our_window != window && title != NULL) { // This seems to be the "other" window that we want to shoot, so // grab hold of it g_object_ref(window); pdfscreenshot_take_shot(window); g_object_unref(window); g_list_free(toplevels); return; } } g_list_free(toplevels); // If we reach here, then we did not find a main window. Inform the user // about it. GtkWidget *dialog = gtk_message_dialog_new (our_window, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "No main window found."); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); } /* * The main window, with the one button. */ void pdfscreenshot_window_create() { // Is that icon always installed or do we have to ship it? GtkWidget *icon = gtk_image_new_from_icon_name ("camera",GTK_ICON_SIZE_BUTTON); gtk_image_set_pixel_size(GTK_IMAGE(icon), 128); GtkWidget *button = gtk_button_new_with_label("Take vector screenshot..."); gtk_button_set_image (GTK_BUTTON(button), icon); gtk_button_set_image_position (GTK_BUTTON(button), GTK_POS_TOP); GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_icon_name(GTK_WINDOW(window),"camera"); gtk_window_set_title(GTK_WINDOW(window),"Vector screenshot taker"); gtk_window_set_resizable(GTK_WINDOW(window), FALSE); gtk_window_set_keep_above(GTK_WINDOW(window),TRUE); gtk_container_add(GTK_CONTAINER(window), button); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(pdfscreenshot_find_window), window); gtk_widget_show_all(GTK_WIDGET(window)); } /* * Ignore all BadWindow errors. */ int silent_error_handler (Display *display, XErrorEvent *error) { if (error->error_code != BadWindow) { return old_handler (display, error); } return 0; } GdkFilterReturn pdfscreenshot_event_filter (GdkXEvent *xevent, GdkEvent *event, gpointer data) { XEvent *ev = (XEvent *) xevent; if (ev->type == MapNotify) { XTextProperty supported; GdkDisplay *display = gdk_x11_lookup_xdisplay(ev->xmap.display); XStringListToTextProperty(&supported_str, 1, &supported); if (display) gdk_x11_display_error_trap_push(display); else gdk_error_trap_push(); XSetTextProperty(ev->xmap.display, ev->xmap.window, &supported, gdk_x11_atom_to_xatom(pdfscreenshot_atom)); if (display) gdk_x11_display_error_trap_pop_ignored(display); else gdk_error_trap_pop_ignored(); } else if (ev->type == ClientMessage && ev->xclient.message_type == gdk_x11_atom_to_xatom(pdfscreenshot_atom)) { if (event->any.window != NULL) { GtkWindow *gwin; gdk_window_get_user_data(event->any.window, (gpointer *) &gwin); //printf("Taking shot of XWindow 0x%lx, GtkWindow %p\n", ev->xclient.window, gwin); g_idle_add(pdfscreenshot_take_shot_soon, gwin); } else { g_warning("Got a GTK_VECTOR_SCREENSHOT XClientMessage, but window 0x%lx is not known to me.", ev->xclient.window); } } return GDK_FILTER_CONTINUE; } /* * Module setup function */ int gtk_module_init(gint argc, char *argv[]) { filename = NULL; type = "pdf"; pdfscreenshot_atom = gdk_atom_intern ("GTK_VECTOR_SCREENSHOT", FALSE); // pdfscreenshot_window_create(); gdk_window_add_filter (NULL, pdfscreenshot_event_filter, NULL); return FALSE; } 07070100000013000081A4000000000000000000000001637488D2000017D0000000000000000000000000000000000000003500000000gtk-vector-screenshot-0.3.3/take-vector-screenshot.c/* * © 2011 Joachim Breitner <mail@joachim-breitner.de> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <gtk/gtk.h> #include <gdk/gdkx.h> #include <X11/Xlib.h> #include <X11/Xutil.h> #include <clientwin.h> GdkAtom pdfscreenshot_atom; char *supported_str = "supported"; GtkWindow *main_window; /* * This is called once a window has been clicked. */ gboolean pdfscreenshot_window_selected(GtkWidget *grab_window, GdkEventButton *event, GtkButton *button) { // Release the pointer gdk_pointer_ungrab(event->time); // Un-Press the button (we inhibited the button-release signal in // pdfscreenshot_select_window gtk_button_released(GTK_BUTTON(button)); // Use Xlib to find out what window is below the button Window selected_window = None; int dummy; unsigned int dummyU; Window dummyW; XQueryPointer(gdk_x11_get_default_xdisplay(), gdk_x11_get_default_root_xwindow(), &dummyW, &selected_window, &dummy, &dummy, &dummy, &dummy, &dummyU); // Find the "right" window the same way xwininfo does selected_window = Find_Client(gdk_x11_get_default_xdisplay(), gdk_x11_get_default_root_xwindow(), selected_window); if (selected_window != None) { // Now we check if the window has the GTK_VECTOR_SCREENSHOT atom set XTextProperty supported; XGetTextProperty(gdk_x11_get_default_xdisplay(), selected_window, &supported, gdk_x11_atom_to_xatom(pdfscreenshot_atom)); if (supported.value != NULL) { // Send the GTK_VECTOR_SCREENSHOT ClientMessage to the window. It // is important to set xevent.window, as X does not do it by // itself. XClientMessageEvent xevent; xevent.type = ClientMessage; xevent.message_type = gdk_x11_atom_to_xatom(pdfscreenshot_atom); xevent.format = 32; xevent.window = selected_window; XSendEvent(gdk_x11_get_default_xdisplay(), selected_window, 0, 0, (XEvent *)&xevent); return TRUE; } } // If we reach here, then the window does not support taking vector screenshots. GtkWidget *dialog = gtk_message_dialog_new (main_window, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "The selected window does not support taking vector screenshots. Is it " "a gtk-3 based application, and did you load the gtk-vector-screenshot " "module?"); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); return TRUE; } /* * Called when the main button is pressed. */ gboolean pdfscreenshot_select_window(GtkWidget *button, GdkEvent *event, GtkWidget *grab_window) { GdkEventMask events = GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK; // Create a crosshair cursor GdkCursor *cursor = gdk_cursor_new_for_display( gtk_widget_get_display(button), GDK_CROSSHAIR); // And grab the input device, so that all further events are passed to the // grab_window gdk_device_grab( gdk_event_get_device(event), gtk_widget_get_window(grab_window), GDK_OWNERSHIP_APPLICATION, FALSE, events, cursor, event->button.time); gdk_cursor_unref(cursor); return TRUE; } /* * The main window, with the one button. */ void pdfscreenshot_window_create() { // Is that icon always installed or do we have to ship it? GtkWidget *icon = gtk_image_new_from_icon_name ("camera",GTK_ICON_SIZE_BUTTON); gtk_image_set_pixel_size(GTK_IMAGE(icon), 128); GtkWidget *button = gtk_button_new_with_label("Take vector screenshot..."); gtk_button_set_image (GTK_BUTTON(button), icon); gtk_button_set_image_position (GTK_BUTTON(button), GTK_POS_TOP); gtk_widget_set_tooltip_text (button, "Click this button and then an application window to take " "a vector screenshot of it."); GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_icon_name(GTK_WINDOW(window),"camera"); gtk_window_set_title(GTK_WINDOW(window),"Vector screenshot taker"); gtk_window_set_resizable(GTK_WINDOW(window), FALSE); gtk_window_set_keep_above(GTK_WINDOW(window),TRUE); gtk_container_add(GTK_CONTAINER(window), button); gtk_widget_show_all(GTK_WIDGET(window)); main_window = window; // Create a dummy window for the pointer grab // (maybe try to remove this later) GdkEventMask events = GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK; GtkWidget *grab_window = gtk_window_new(GTK_WINDOW_POPUP); gtk_widget_show(grab_window); gtk_window_resize(GTK_WINDOW(grab_window), 1, 1); gtk_window_move(GTK_WINDOW(grab_window), -100, -100); gtk_widget_add_events(grab_window, events); g_signal_connect(G_OBJECT(grab_window), "button_release_event", G_CALLBACK(pdfscreenshot_window_selected), button); g_signal_connect(G_OBJECT(button), "button_release_event", G_CALLBACK(pdfscreenshot_select_window), grab_window); } int main(gint argc, char *argv[]) { gtk_init(&argc, &argv); pdfscreenshot_atom = gdk_atom_intern ("GTK_VECTOR_SCREENSHOT", FALSE); pdfscreenshot_window_create(); gtk_main(); return 0; } 07070100000014000081A4000000000000000000000001637488D2000000E8000000000000000000000000000000000000003B00000000gtk-vector-screenshot-0.3.3/take-vector-screenshot.desktop[Desktop Entry] Name=Take Vector Screenshot Comment=Save vector images of application windows Exec=take-vector-screenshot Terminal=false Type=Application Icon=camera # StartupNotify=true Categories=GTK;GNOME;Utility; NotShowIn=KDE; 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!136 blocks
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.