pax_global_header00006660000000000000000000000064130513172140014507gustar00rootroot0000000000000052 comment=98c2e7dedd7ad90d6fe50417a31719e744785c54 GPaste-3.18.6/000077500000000000000000000000001305131721400127715ustar00rootroot00000000000000GPaste-3.18.6/.gitignore000066400000000000000000000005671305131721400147710ustar00rootroot00000000000000/Makefile /bin/* /tests/bin/* /data/appstream/*.appdata.xml /data/control-center/*.xml /data/desktop/*.desktop /data/desktop/*.desktop.in /data/dbus/*.service /bindings/gi /data/pkg-config/*.pc /man/*.1 /po/Makefile /po/missing /src/gnome-shell/metadata.json /src/gpaste-settings/*.c /bindings/vapi/*.vapi !/bindings/vapi/config.vapi /test-suite.log /result /result-tmp /tmp GPaste-3.18.6/AUTHORS000066400000000000000000000001051305131721400140350ustar00rootroot00000000000000Lead developer Marc-Antoine Perennou GPaste-3.18.6/COPYING000066400000000000000000001045131305131721400140300ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU 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 Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state 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 program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . GPaste-3.18.6/ChangeLog000066400000000000000000000002201305131721400145350ustar00rootroot000000000000002011-06-29 Marc-Antoine Perennou * *: The ChangeLog is autogenerated when releasing, see git log for changes GPaste-3.18.6/Makefile.am000066400000000000000000000066761305131721400150440ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2011-2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . SUBDIRS = po ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} AM_MAKEFLAGS = --no-print-directory AM_DISTCHECK_CONFIGURE_FLAGS = \ --with-dbusservicesdir="$$dc_install_base/$(dbusservicesdir)" \ --with-controlcenterdir="$$dc_install_base/$(controlcenterdir)" \ --enable-appstream-util \ --enable-applet \ --enable-introspection \ --enable-legacy-cli \ --enable-unity \ --enable-vala \ $(NULL) AM_CFLAGS = \ -include config.h \ -I$(srcdir)/src/libgpaste \ -I$(srcdir)/src/libgpaste/applet \ -I$(srcdir)/src/libgpaste/client \ -I$(srcdir)/src/libgpaste/core \ -I$(srcdir)/src/libgpaste/daemon \ -I$(srcdir)/src/libgpaste/gnome-shell-client \ -I$(srcdir)/src/libgpaste/keybinder \ -I$(srcdir)/src/libgpaste/screensaver-client \ -I$(srcdir)/src/libgpaste/settings \ -I$(srcdir)/src/libgpaste/settings-ui \ -I$(srcdir)/src/libgpaste/ui \ -I$(srcdir)/src/libgpaste/util \ -I$(builddir)/src/libgpaste \ -DG_PASTE_COMPILATION \ -DLOCALEDIR=\"$(localedir)\" \ -DPKGLIBEXECDIR=\"$(pkglibexecdir)\" \ $(GLIB_CFLAGS) \ $(GTK_CFLAGS) \ $(NULL) AM_LIBS = \ $(GLIB_LIBS) \ $(NULL) EXTRA_DIST = \ autogen.sh \ README.md \ $(NULL) CLEANFILES = SUFFIXES = bin_PROGRAMS = pkginclude_HEADERS = pkglibexec_PROGRAMS = lib_LTLIBRARIES = noinst_LTLIBRARIES = TESTS= noinst_PROGRAMS= \ $(TESTS) \ $(NULL) @INTLTOOL_XML_NOMERGE_RULE@ # Libraries include src/libgpaste.mk # Bindings include bindings/gi.mk include bindings/vapi.mk # Core utilities include src/daemon.mk include src/gpaste-client.mk include src/ui.mk # Legacy compatibility include legacy/gpaste.mk # Applets include src/applet.mk include src/app-indicator.mk include src/gnome-shell.mk # Data include data/appstream.mk include data/completions.mk include data/control-center.mk include data/dbus.mk include data/desktop.mk include data/gsettings.mk include data/pkg-config.mk include data/search-provider.mk # Man pages include man/1.mk # Tests stuff include tests/gnome-shell-client.mk # Maintainance stuff update-po: $(MAKE) -C po $@ release: $(MAKE) update-po && \ $(MAKE) distcheck && \ git commit -asm "Release $(PACKAGE_NAME) $(PACKAGE_VERSION)" && \ git tag -sm "Release $(PACKAGE_NAME) $(PACKAGE_VERSION)" v$(PACKAGE_VERSION) # Generate a ChangeLog file from 'git log' dist-hook: @ if test -d "$(srcdir)/.git"; then \ echo Creating ChangeLog; \ cd "$(srcdir)"; \ ( \ echo -e '# Generated by Makefile. Do not edit.\n\n'; \ $(srcdir)/build-aux/missing --run git log ; \ ) > ChangeLog.tmp; \ mv -f ChangeLog.tmp $(distdir)/ChangeLog; \ if test -f "ChangeLog.tmp"; then \ rm -f ChangeLog.tmp; \ echo Failed to generate ChangeLog >&2; \ fi; \ else \ echo A git clone is required to generate a ChangeLog >&2; \ fi GPaste-3.18.6/NEWS000066400000000000000000000501011305131721400134650ustar00rootroot00000000000000NEW in 3.18.6 (17/02/2017) ============= - fix memory leaks in the debugging logs - fix some corner case in images handling - stability improvements NEW in 3.18.5 (28/06/2016) ============= - fix some extensive CPU usage in some cases NEW in 3.18.4 (22/05/2016) ============= - fix crash when a search goes wrong - fix hanging issue due to gtk+ race (?) in gtk_clipboard_store - fix the gnome-shell menu sometimes displaying twice - add debug logs to the core library NEW in 3.18.3 (15/01/2016) ============= - fix synchronisation issues between clipboard and primary selection - fix a memory leak - never handle images when images support is disabled NEW in 3.18.2 (16/10/2015) ============= - fix disabling legacy cli - fix gnome-shell empty button - fix emptying the active history - fix showing about dialog - update brazilian portuguese translation NEW in 3.18.1.1 (27/09/2015) ============= - few build system cleanups - gobject-introspection fixes NEW in 3.18.1 (23/09/2015) ============= - fix a regression in growing lines detection NEW in 3.18 (21/09/2015) ============= - Warning, this is a big release, with changes in API, yoi might have to kill your old daemon after upgrading - The "gpaste" cli is now "gpaste-client". old name can still be enabled with --enable-cli for now - The "gpaste settings" tool is gone, use the "burger" menu from "gpaste-client ui" - The graphical tool now allows you to fully manage your histories - The graphical tool now allows you to restart the daemon - The graphical tool now allows you to edit an element from the history - The graphical tool new allows you to upload an element to a pastebin service (requires wgetpaste) - The graphical tool now displays the size of each history - The graphical tool now displays the index of each element in the history - The graphical tool has been slightly redisigned - A new gnome-shell search-provider is provided by the daemon - When searching e.g. "42", the 42nd element from hsitory will be included in search results - gpaste-client gained a new subcommand: "get-history" to get the name of the current history - gpaste-client gained a new subcommand: "replace" to replace the content of an item in the history - Compatibility with gnome-shell 3.18 - The daemon now "works" on wayland using XWayland and gnome-shell 3.18 - The dbus interface name is now org.gnome.GPaste1 - The "Empty" dbus method has been renamed "EmptyHistory" - The "NameLost" and "ReexecuteSelf" dbus signals are gone - Three new dbus signals: "DeleteHistory", "EmptyHistory" and "SwitchHistory" - The daemon gained new dbus methods: GetItemKind, GetElements, GetHistoryName, Replace - BackupHistory EmptyHistory and DeleteHistory now take the history as a parameter instead of the current one - GPasteClient hasn't the "name-lost" and "reexecute-self" signals anymore - GPasteClient gained three new signals: "delete-history", "empty-history" and "switch-history" - GPasteHistory gained a new "switch" signal - GPasteHistory now tracks dconf to switch between histories - A few formerly private constructors and methods are now publicly available - The way GPaste handles dbus conection and objects have significantly been reworked - Everything is now handled using 64bits types (the numeric settings have thus been reset and some max values changed) - A lot of code cleanup and rearchitecturation - Signals are now properly documented for gobject-introspection and thus bindings - Various build system cleanups (gobject-introspection and vapigen are now required to build from git - Shell completion updates - Translations updates NEW in 3.16.3.1 (23/09/2015) ============= - fix a regression in growing lines detection NEW in 3.16.3 (05/09/2015) ============= - various gnome-shell extension fixes - prevent potential crash from external library users NEW in 3.16.2.1 (11/05/2015) ============= - gpaste; fix error in pipe detection NEW in 3.16.2 (11/05/2015) ============= - gpaste; allow taking password from stdin NEW in 3.16.1 (29/04/2012) ============= - bump max history size - fix weird behaviour wrt screensaver NEW in 3.16 (23/03/2015) ============= - new subcommand: gpaste merge to merge various entries (with --decoration and --separator) - new tool: gpaste-ui (minimal graphical interface) - legacy applet reworked to use gpaste ui - ubuntu app indicator reworked to use gpaste ui - new keybinding to launch gpaste ui - new keybinding to upload clipboard content to a pastebin service (requires wgetpaste >= 2.26) - the daemon now returns standard DBus errors on invalid input - name dbus parameters - gnome-shell 3.16 support (require gnome-shell 3.16 because of breaking changes) - require glib 2.44 and gtk 3.16 - compatibility with new glib autoptr mechanism - fully switch to appstream - updated shell completions - updated translations - various libgpaste api cleanups (bump soname to 3, rework libtool versioning) - detect applet and app-indicator at runtime instead of build time - fix bug with recent glib - make a lot more stuff async - gpasted is dead (long live gpaste-daemon) - Changed DBus signal is dead - drop old ubuntu compat patches - drop gpaste-config.h - drop old manual pages for applet and app-indicator - drop legacy gpaste subcommands (raw, oneline, zero, favor --raw, --oneline and --raw) - various bugfixes - some progress regarding wayland support NEW in 3.14.4.1 (11/05/2015) ============= - gpaste; fix error in pipe detection NEW in 3.14.4 (11/05/2015) ============= - gpaste; allow taking password from stdin NEW in 3.14.3 (21/03/2015) ============= - fix crashes related to images support NEW in 3.14.2 (07/03/2015) ============= - improve zsh completion - fix a bug causing the gnome-shell extension to randomly crash NEW in 3.14.1 (17/01/2015) ============= - search is now always done by the daemon, not the gnome-shell extension - new gpaste subcomand: search - gpaste now accepts --online --raw and --zero options - search is now async - various gnome-shell extension fixes - updated completions - we now restore the clipboard contents when unlocking the screensaver NEW in 3.14 (10/10/2014) ============= - update for latest gobject-introspection - support gnome-shell 3.14 - start redesign of the gnome-shell extension - new gpaste show-history command NEW in 3.12.3.1 and 3.10.4.1 (09/10/2014) ============= - a bug preventing the history to be saved to disk has been fixed - prevent a segfault when loading large histories - add a new gpaste oneline-history command NEW in 3.12.3 and 3.10.4 (25/09/2014) ============= - gpaste-daemon now has an Update dbus signal more precise than Changed - desktop files fixes - all calls to clipboard are now async - performance improvements - gpaste-client has been updated to match gpaste-daemon changes with an update signal - gnome-shell extension has been ported to the update signal - applets have been ported to the update signal - gnome-shell search bar now matches the user theme NEW in 3.12.2 and 3.10.3 (28/07/2014) ============= - gpasted has been renamed gpaste-daemon - Desktop files have been fixed - Fixes for the ubuntu app-indicator - Keybinding to mark an item as being a password - All libgpaste-* have been merged into a single libgpaste - Misc bugfixes reported for debian packaging NEW in 3.12.1 and 3.10.2 (16/07/2014) ============= - systemd support has been removed - GPaste is now compliant with https://wiki.gnome.org/HowDoI/DBusApplicationLaunching - GPaste now has built-in support for managing passwords, blog post coming. - Completions and man pages have been updated - Translations have been updated - Miscellaneous bugfixes with static analysis - The search feature of the gnome-shell extension has been improved NEW in 3.12 (02/05/2014) ============= - Improved compatibility with GNOME 3.12 NEW in 3.10.1 (01/05/2014) ============= - gpasted no longer fails at runtime if gnome-shell's settings schema is not installed - growing lines are detected for lines getting expanded at their left too - gnome-shell extension has been rewritten - gnome-shell extension now has a search bar - translations update - misc bugfixes NEW in 3.10 (25/03/2014) ============= - Follow GNOME versionning - Don't display error on daemon-reexec - Fix coredumps due to g_error - New library: libgpaste-applet - Unity support (for Ubuntu 14.04 and above) using libgpaste-applet - Port legacy applet to libgpaste-applet and rename to StatusIcon - Redesign GPaste StatusIcon to make it simpler and similar to gnome-shell extension - Vala is no longer required to build the applet (rewritten in C) - Lower automake dependency to 1.11 - Be compatible with gnome-shell up to 3.12 - libgpaste-settings: add reset - gpaste settings: add reset buttons - gpaste settings: add a switch to enable the gnome-shell extension - The gnome-shell gsettings schema is now required when --enable-gnome-shell-extension is provided (default) - gpasted: GetElement now returns the display string - gpasted now forwards the full history via dbus, letting the client manage the display limit - gpasted gained GetHistoryLength, GetRawHistory, GetRawElement and About - gpasted gained a new Version property - Add about dialog to all components - Prefer dark theme - Display more info at the end of configure - Provide appdata files - Parallel build fixes - Fix build issues for Fedora, Ubuntu and Debian - clang related fixes - Fix warnings - Translations update NEW in 3.8 (10/02/2014) ============= - Fix german translation - No longer depend on libxml - Update Portugueuse and French translations - New growing-lines feature - Misc bufixes NEW in 3.7 (09/11/2013) ============= - "Paste and Pop" is now only "Pop" - Fix SEGV when deleting last item of history - New gnome-shell DBus client library - DBus client libraries are now async - Keybinder now uses gnome-shell if available to grab keys - Preparations for wayland port - Enhance internal memory management - Code cleanup - Misc bug fixes - German translation NEW in 3.6 (17/10/2013) ============= - GPaste settings look has been updated to better fit with recent GNOME - Performance improvements - Daemon now fully evenmential (no more polling, less power consuption) - GPasteClipboard now has a "owner-change" signal similar to GtkClipboard's one - Misc. bugfixes - New setting to set the maximum amount of memory used by data in history - FIFO mode has been dropped (lacking design) - Code cleanup and modernisation - g_paste_history_add is now transfer full NEW in 3.5 (25/09/2013) ============= - Compatibility with gnome-shell 3.9.90 and above - The gnome-shell applet has totally been rewritten and is now more intuitive. - Port to newer glib - Don't use deprecated stuff from gtk+ - The X11 keybinder is now optional - New keybinding to sync the clipboard to the primary selection - New keybinding to sync the primary selection to the clipboard NEW in 3.3.1 (22/03/2014) ============= - Build fixes for debian wheezy NEW in 3.3 (22/02/2014) ============= - New growing-lines feature (backported from 3.8) NEW in 3.2.2 (22/10/2013) ============= - "Paste and Pop" is now only "Pop" - Fix SEGV at startup - Fix SEGV when deleting last item of history NEW in 3.2.1 (19/10/2013) ============= - Update translations - Fix build with old glib NEW in 3.2 (16/10/2013) ============= - Performance improvements - Daemon now fully evenmential (no more polling, less power consuption) - GPasteClipboard now has a "owner-change" signal similar to GtkClipboard's one - Misc. bugfixes - New setting to set the maximum amount of memory used by data in history - FIFO mode has been dropped (lacking design) - g_paste_history_add is now transfer full NEW in 3.1 (23/09/2013) ============= - Compatibility with gnome-shell up to 3.9.5 - New keybinding to sync the clipboard to the primary selection - New keybinding to sync the primary selection to the clipboard NEW in 3.0.2 (01/06/2013) ============= - Fix build without gnome-control-center installed - Fix focus when using in gnome-shel extension NEW in 3.0.1 (13/04/2013) ============= - Fix build NEW in 3.0 (13/04/2013) ============= - Various build fixes - Support of gnome-control-center for setting keybindings - Compatibility with newer gnome-shell NEW in 2.99.2 (22/01/2013) ============= - Fix a bug making gpaste settings ui a no-op - Don't close legacy applet menu when deleting an item - Fix vala bindings - Updated portuguese translation NEW in 2.99.1 (15/01/2013) ============= - Fix a few typos in the conditional code for applet and extension - Fix make install when GPaste is not yet installed - Clean desktop files NEW in 2.99 (14/01/2013) ============= - Compatibility with recent development releases of gnome-shell - "gpaste f" now defers the file reading to the GPaste daemon - libgpaste-client does now fully cover the GPaste DBus API - libgpaste-keybinder has been ported to use XInput2 - keybindings have been fixed - The gnome-shell extension has been ported to use libgpaste-client - A systemd user unit is now provided - New library: libgpaste-settings-ui - gpaste-settings has been ported to libgpaste-settings-ui - The gnome-shell extension now has a pref.js module based on libgpaste-settings-ui - An autostart desktop file is now provided with the legacy applet - gobject-introspection and vala support are now optional - Various code cleanup NEW in 2.9.1 (01/12/2012) ============= - Fix memory leak when handling images - Fix duplicated images in history - Fix "changed" signal in GPasteSettings NEW in 2.9 (29/09/2012) ============= - Now depends on intltool 0.50 - Automake stack is even more modular - libgpaste has been split into sublibs: libgpaste-core, libgpaste-keybinder and libgpaste-settings - New libraries: libgpaste-client and libgpaste-daemon - gpaste CLI is rewritten in C - Keybindings have totally been reworked - Performance improvements - Various code cleanup - Images support can now be disabled - Paste and Pop keybinding may behave weirdly because of gtk+ NEW in 2.8.1 (05/05/2012) ============= - Fix crash in g_paste_daemon_tracking NEW in 2.8 (02/05/2012) ============= - Various cleanup and bugfixes - The history file now has a version number - CDATA can now be copied - ToggleHistory is now ShowHistory - The "keyboard-shortcut" preferences is now called "show-history" - New feature : Paste & Pop with a new keybinding (experimental) - Vapi is no longer shipped and is generated when building - Now requires automake 1.12 and autoconf 2.69 - Brazilian Portuguese translation by Elder Marco - FIFO mode - Multi-history with "gpaste backup-history" and "gpaste switch-history" - New commands: "gpaste delete-history" and "gpaste list-histories" - gpaste-settings has been rewritten - libgpaste improvements NEW in 2.5 (08/03/2012) ============= - Reexecute has now a signal: ReexecuteSelf - New library to externalize the core: libgpaste written in C with introspection and vapi - Various build system cleanup - Small bug fixes - Port gpasted to libgpaste and rewrite it in C - Port gpaste-settings to libgpaste - Port gpaste-applet to libgpaste NEW in 2.2.1 (07/01/2012) ============= - Regen tarball with intltool 0.41.1 NEW in 2.2 (07/01/2012) ============= - Content is now stripped before being added to clipboard - New settings for maximum and minimum size of an item (thanks to Lukáš Zapletal) - Various code cleanup - Fix keybinding handling (conflict with mutter in keyboard grabbing) - Ability to stop tracking changes when disabling extension - Rewrite of gpaste-settings NEW in 2.1 (01/12/2011) ============= - Fix a bug which was "randomly" deleting image files - Generate tarball with sane vala to unbreak keybindings NEW in 2.0 (27/11/2011) ============= - Updated finnish translation - Cleanups - Fix separators disapearing in gnome-shell extension - Don't close menu when deleting items - Uris support (files copying) - Rewrite of bash and zsh completions - Various fixes NEW in 1.99 (2.0 RC) (02/11/2011) ============= - Finnish translation by Jesse Jaara - Be consistent with the shell applet menu structure - New gpaste subcommand: raw-history to display history without numbers - Switch to GDbus - New images support (feedback appreciated) NEW in 1.6 (20/09/2011) ============= - Make hotkey work with legacy applet - New GPaste subcommand for upgrading facilities: gpaste daemon-reexec - Major autotools cleanup - Fix linkage of gpasted against X11 - Bugfixes - Espagnol translation by Antonio Trujillo NEW in 1.5 (11/09/2011) ============= - No trace of the applet at all with --disable-applet - No more "shutdown-on-exit" key, just use the prefs or the command line - Preparation for future images support - History file is now ~/.gpaste_history - Use AM_PROG_VALAC - New "gpaste get " command for subshell usage (And GetElement DBus method) - Get rid of AM_MAINTAINER_MODE - Add possibility to have a keyboard shortcut to display the history - Do not add to history the last selected item when re tracking for changes NEW in 1.4 (07/09/2011) ============= - pod2man is no more needed - Add ability not to save the history from one session to another - Fix segfault at daemon startup with invalid utf8 string NEW in 1.3.1 (03/09/2011) ============= - Nothing NEW in 1.3 (31/08/2011) ============= - New gpaste option: file/-f/--file , same as cat | gpaste - Adapt to new gnome-shell extension API NEW in 1.2 (10/07/2011) ============= - Avoid AM_GLIB_GNU_GETTEXT macro - Don't run configure in autogen.bash - Really restore tracking state at startup NEW in 1.1 (09/07/2011) ============= - Save whether we're tracking clipboard changes or not from a session to another - Only build gnome-shell applet by default - Launch and Quit DBus method are now Track(bool) - Start and Exit DBus signals are now Tracking(bool) NEW in 1.0 (05/07/2011) ============= - Switch to .tar.xz - Various bug fixes - Silence some warnings - Get rid of the History.changed signal - Rework internal Settings handling NEW in 0.99 (28/02/2011) ============= - Depend on gtk+ 3.0.0 - Really fix the segfault taht should have been fixed in 0.9 - Namespace refactoring - Libexec stuff is now installed into a gpaste subdir - Code cleanup - Explicit DBus API (with breakage) - Rename gpaste-{preferences -> settings} - New "exit" signal - "start" is now a signal - Build the gnome-shell native extension with --enable-gnome-shell-extension - The daemon no longer exits, it just stop tracking clipboard changes - New DBus property: Active to see if the daemon is tracking - Fix an encoding issue - Quit is now Stop NEW in 0.9 (05/02/2011) ============= - Fix a segfault when trying to restore from an empty history into an empty clipboard at startup - Better output for empty history - gpaste version - gpaste applet to spawn the applet - gpaste-applet and gpaste-preferences are now installed into libexecdir - gpaste add foo is now an alias for gpaste foo (add foo to history) - Add gpaste preferences alias for gpaste-preferences - There can now only be one instance of the applet and daemon at a time - You can now avoid building the applet with --disable-applet - bash and zsh completions, manual NEW in 0.8 (03/02/2011) ============= - Fix behaviour of '\n' substitution with small string, and disable it with element-size = 0 - Change default values to adapt to new behaviours - Add ability to empty the history from the right clic on the applet or via "gpaste empty" - Do not display history when it is empty NEW in 0.7 (02/02/2011) ============= - The first element in history is now restored into clipboards if they are empty at startup - You can now shutdown the daemon with "gpaste quit" - A preference has been added for the applet to shutdown the daemon when exiting - A preference has been added to set a maximum size for each item when the applet displays them NEW in 0.6 (01/02/2011) ============= - Now, we store the settings and we connect to the change signal to each one of them instead of retrieving them every time - Fix a bug with the '_' character which was interpreted as an underlinement when displaying the history from the applet - Add ability to synchronize the primary selection and the clipboard NEW in 0.5 (01/02/2011) ============= First release ! Content: - gpasted: daemon with DBus interface - gpaste: CLI client for gpasted - gpaste-preferences: tool to edit preferences - gpaste-applet: tray icon for managing gpasted GPaste-3.18.6/README.debian000066400000000000000000000003741305131721400150760ustar00rootroot00000000000000In order to compile GPaste from git on ubuntu, you will need: appstream-util autoconf build-essential git-core gnome-control-center-dev intltool libclutter-1.0-dev libdbus-1-dev libgirepository1.0-dev libgtk-3-dev libtool libxml2-dev pkg-config valac GPaste-3.18.6/README.md000066400000000000000000000042251305131721400142530ustar00rootroot00000000000000 Coverity Scan Build Status GPaste is a clipboard management system. See for more information about what clipboard managers are. A library is available for development purposes: * `libgpaste` contains all the basic objects used by GPaste and allows you to manage preferences and the GPaste daemon. A default daemon named `gpaste-daemon` is provided, with seven keybindings: * show history * pop the item from the history * sync primary selection with clipboard * sync clipboard with primary selection * mark the active item as being a password * upload the active item to a pastebin service (using wgetpaste) * launch the graphical tool A simple CLI interface is provided: `gpaste-client`, with three subcommands: `gpaste-client ui` which makes the graphical tool pop, `gpaste-client applet` which starts the status icon in your notification area and `gpaste-client app-indicator` which starts the unity application indicator. A native gnome-shell extension is provided. /!\ Don't forget to run `gpaste-client dr` aka `gpaste-client daemon-reexec` after upgrading GPaste to activate new functionalities ;) You can then run `gpaste-client daemon-version` to check the correct daemon is now running. Steps to install it after cloning (skip the `./autogen.sh` part if you're building it from a tarball): ./autogen.sh ./configure --sysconfdir=/etc make sudo make install sudo glib-compile-schemas /usr/share/glib-2.0/schemas/ If you also want to build the status icon, you'll have to pass `--enable-applet` to configure. If you also want to build the unity application indicator, you'll have to pass `--enable-unity` to configure. You can see everything I'll post about GPaste [there](http://www.imagination-land.org/tags/GPaste.html). Latest release for GNOME 3.18 is: [GPaste 3.18.6](http://www.imagination-land.org/posts/2017-02-17-gpaste-3.18.6-released.html). Direct link to download: GPaste-3.18.6/README.ubuntu000066400000000000000000000003741305131721400151760ustar00rootroot00000000000000In order to compile GPaste from git on ubuntu, you will need: appstream-util build-essential git-core gnome-control-center-dev intltool libappindicator3-dev libclutter-1.0-dev libdbus-1-dev libgirepository1.0-dev libgtk-3-dev pkg-config ui-auto valac GPaste-3.18.6/THANKS000066400000000000000000000006561305131721400137130ustar00rootroot00000000000000Elder Marco Gary van der Merwe Jesse Jaara Lukas Zapletal whyoh Jan Alexander Steffens (heftig) Toni TC renataogarcia Julien Durillon Christian Schendel Christian Kluge GPaste-3.18.6/TODO000066400000000000000000000010601305131721400134560ustar00rootroot000000000000003.20: general: autoconf cleanup w/ AX_* + custom macros automake 1.15 + %reldir% class methods for signals wayland support apply some redesign ideas cli: allow specifying history name in gpaste-client for some commands command-dispatcher gpaste-ui: merge future: general: gpg support properties all the way (when GProperty stuff lands) libgpaste-client: specify errors types when possible in g-i tests: split test, add interactive wrapper GPaste-3.18.6/autogen.sh000077500000000000000000000025561305131721400150020ustar00rootroot00000000000000#!/bin/bash set -euo pipefail autotools() { autoreconf -i -Wall intltoolize --force --automake } clean() { git clean -fdx autotools } scan_build_run() { scan-build --use-analyzer=/usr/bin/clang "${@}" } scan_build() { clean scan_build_run ./configure "${@}" scan_build_run make } static_analysis() { coverity-submit scan_build "${@}" } full() { static_analysis "${@}" clean ./configure "${@}" make make distcheck } run_action() { local action="${1}" shift local configure_args=( --prefix=/usr --sysconfdir=/etc --enable-applet --enable-appstream-util --enable-gnome-shell-extension --enable-introspection --enable-legacy-cli --enable-unity --enable-vala --enable-x-keybinder ) case "${action}" in configure-full|cf) ./configure "${configure_args[@]}" "${@}" ;; coverity|cov) coverity-submit ;; scan-build|sb) scan_build "${configure_args[@]}" "${@}" ;; static-analysis|sa) static_analysis "${configure_args[@]}" "${@}" ;; full) full "${configure_args[@]}" "${@}" ;; esac } main() { autotools [[ "${#}" == 0 ]] || run_action "${@}" } main "${@}" GPaste-3.18.6/bindings/000077500000000000000000000000001305131721400145665ustar00rootroot00000000000000GPaste-3.18.6/bindings/gi.mk000066400000000000000000000032471305131721400155240ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2012-2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . -include $(INTROSPECTION_MAKEFILE) INTROSPECTION_SCANNER_ARGS = --c-include=gpaste.h INTROSPECTION_COMPILER_ARGS = $(NULL) INTROSPECTION_GIRS = $(NULL) libgpaste_gir_file = bindings/gi/GPaste-1.0.gir $(libgpaste_gir_file): $(libgpaste_la_file) bindings_gi_GPaste_1_0_gir_FILES = \ $(pkginclude_HEADERS) \ $(lib_libgpaste_la_SOURCES) \ $(NULL) bindings_gi_GPaste_1_0_gir_CFLAGS = \ $(AM_CFLAGS) \ $(NULL) bindings_gi_GPaste_1_0_gir_LIBS = $(libgpaste_la_file) bindings_gi_GPaste_1_0_gir_EXPORT_PACKAGES = libgpaste bindings_gi_GPaste_1_0_gir_SCANNERFLAGS = --warn-all bindings_gi_GPaste_1_0_gir_INCLUDES = \ GdkPixbuf-2.0 \ Gio-2.0 \ GObject-2.0 \ Gtk-3.0 \ $(NULL) if HAVE_INTROSPECTION INTROSPECTION_GIRS += \ $(libgpaste_gir_file) \ $(NULL) endif girdir = $(datadir)/gir-1.0 gir_DATA = $(INTROSPECTION_GIRS) typelibdir = $(libdir)/girepository-1.0 typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) CLEANFILES += \ $(gir_DATA) \ $(typelib_DATA) \ $(NULL) GPaste-3.18.6/bindings/vapi.mk000066400000000000000000000023101305131721400160520ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2012-2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . libgpaste_vapi_file = bindings/vapi/gpaste-1.0.vapi $(libgpaste_vapi_file): $(libgpaste_gir_file) @ $(MKDIR_P) bindings/vapi $(AM_V_GEN) $(VAPIGEN) --directory bindings/vapi --library gpaste-1.0 --pkg gdk-pixbuf-2.0 --pkg gio-2.0 --pkg gobject-2.0 --pkg gtk+-3.0 $^ vapidir = $(datadir)/vala/vapi dist_vapi_DATA = \ $(libgpaste_vapi_file:.vapi=.deps) \ $(NULL) if ENABLE_VAPIGEN nodist_vapi_DATA = \ $(libgpaste_vapi_file) \ $(NULL) CLEANFILES += \ $(libgpaste_vapi_file) \ $(NULL) endif GPaste-3.18.6/bindings/vapi/000077500000000000000000000000001305131721400155255ustar00rootroot00000000000000GPaste-3.18.6/bindings/vapi/gpaste-1.0.deps000066400000000000000000000001001305131721400201500ustar00rootroot00000000000000gdk-pixbuf-2.0 gio-2.0 glib-2.0 gobject-2.0 gtk+-3.0 libxml-2.0 GPaste-3.18.6/configure.ac000066400000000000000000000205371305131721400152660ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2011-2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . AC_PREREQ([2.69]) AC_INIT([GPaste],[3.18.6],[Marc-Antoine@Perennou.com],[gpaste]) # Update LIBGPASTE_LT_VERSION before each release (and only then) # The format is C:R:A (current revision age) # - If any interface has been added, ‘C:R:A’ becomes ‘C+1:0:A+1’. # - If any interface has been removed or modified, ‘C:R:A’ becomes ‘C+1:0:0’. # - Otherwise, ‘C:R:A’ becomes ‘C:R+1:A’. LIBGPASTE_LT_VERSION=4:2:0 AC_SUBST(LIBGPASTE_LT_VERSION) INTLTOOL_REQUIRED="0.50.1" PKGCONFIG_REQUIRED="0.22" GLIB_MIN_MAJOR="2" GLIB_MIN_MINOR="46" GLIB_API_REQUIRED="G_ENCODE_VERSION($GLIB_MIN_MAJOR, $GLIB_MIN_MINOR)" AC_SUBST([GLIB_TARGET], ["$GLIB_MIN_MAJOR.$GLIB_MIN_MINOR"]) GTK_MIN_MAJOR="3" GTK_MIN_MINOR="16" GDK_API_REQUIRED="G_ENCODE_VERSION($GTK_MIN_MAJOR, $GTK_MIN_MINOR)" GLIB_REQUIRED="$GLIB_MIN_MAJOR.$GLIB_MIN_MINOR.0" GTK_REQUIRED="$GTK_MIN_MAJOR.$GTK_MIN_MINOR.0" GDK_PIXBUF_REQUIRED="2.26.0" GIR_REQUIRED="1.42.0" VALA_REQUIRED="0.30" AC_SUBST([PACKAGE_NAME], ["$PACKAGE_NAME"]) AC_SUBST([PACKAGE_VERSION], ["$PACKAGE_VERSION"]) AC_DEFINE([DEFAULT_HISTORY], ["history"], [The default hsitory name]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_SRCDIR([src/]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_AUX_DIR([build-aux]) AC_PREFIX_DEFAULT([/usr]) AM_PROG_AR LT_PREREQ([2.2.6]) LT_INIT([disable-static pic-only]) AM_INIT_AUTOMAKE([1.11 subdir-objects check-news foreign no-dist-gzip dist-xz tar-ustar -Wall]) AM_MAINTAINER_MODE([enable]) AM_SILENT_RULES([yes]) AC_PROG_AWK AC_PROG_SED AC_PROG_MKDIR_P AC_PROG_LN_S AC_PROG_INSTALL AC_PROG_MAKE_SET AC_PROG_CPP AC_PROG_CC AC_PROG_CC_C99 AM_PROG_CC_C_O AC_C_INLINE AC_TYPE_MODE_T AC_FUNC_ALLOCA AC_CHECK_FUNCS([mkdir]) AC_CHECK_HEADER_STDBOOL CC_CHECK_CFLAGS_APPEND([ \ -pipe \ -pedantic \ -DANOTHER_BRICK_IN_THE \ -Wall \ -W \ -Wextra \ -Wvla \ -Wundef \ -Wformat=2 \ -Wlogical-op \ -Wlogical-op-parentheses \ -Wsign-compare \ -Wformat-security \ -Wmissing-include-dirs \ -Wformat-nonliteral \ -Wold-style-definition \ -Wpointer-arith \ -Winit-self \ -Wfloat-equal \ -Wmissing-prototypes \ -Wstrict-prototypes \ -Wredundant-decls \ -Wmissing-declarations \ -Wmissing-noreturn \ -Wshadow \ -Wendif-labels \ -Wcast-align \ -Wstrict-aliasing=2 \ -Wwrite-strings \ -Wno-unknown-warning-option \ -Werror=overflow \ -Wp,-D_FORTIFY_SOURCE=2 \ -ffast-math \ -fno-common \ -fdiagnostics-show-option \ -fno-strict-aliasing \ -fvisibility=hidden \ -ffunction-sections \ -fdata-sections \ ]) CC_CHECK_LDFLAGS_APPEND([ \ -Wl,--as-needed \ -Wl,--gc-sections \ ]) AC_DEFINE_UNQUOTED([GLIB_VERSION_MIN_REQUIRED], [$GLIB_API_REQUIRED], [The lower GLib API version supported]) AC_DEFINE_UNQUOTED([GLIB_VERSION_MAX_ALLOWED], [$GLIB_API_REQUIRED], [The higher GLib API version supported]) AC_DEFINE_UNQUOTED([GDK_VERSION_MIN_REQUIRED], [$GDK_API_REQUIRED], [The lower Gdk API version supported]) AC_DEFINE_UNQUOTED([GDK_VERSION_MAX_ALLOWED], [$GDK_API_REQUIRED], [The higher Gdk API version supported]) GETTEXT_PACKAGE=$PACKAGE_NAME AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["$GETTEXT_PACKAGE"], [Gettext Package]) AC_SUBST(GETTEXT_PACKAGE) IT_PROG_INTLTOOL([$INTLTOOL_REQUIRED]) PKG_PROG_PKG_CONFIG([$PKGCONFIG_REQUIRED]) PKG_CHECK_MODULES(GLIB, [glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED]) PKG_CHECK_MODULES(GTK, [gdk-3.0 >= $GTK_REQUIRED gtk+-3.0 >= $GTK_REQUIRED]) PKG_CHECK_MODULES(GDK_PIXBUF, [gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED]) PKG_CHECK_MODULES(X11, [x11 xi]) AC_CHECK_HEADERS([X11/extensions/XInput2.h]) GLIB_GSETTINGS APPSTREAM_XML GOBJECT_INTROSPECTION_CHECK([$GIR_REQUIRED]) VAPIGEN_CHECK([$VALA_REQUIRED]) AC_ARG_WITH([controlcenterdir], AS_HELP_STRING([--with-controlcenterdir=DIR], [Gnome control-center keybindings directory]), [], [with_controlcenterdir=`$PKG_CONFIG --variable keysdir gnome-keybindings`]) AC_SUBST([controlcenterdir], [$with_controlcenterdir]) PKG_CHECK_MODULES(DBUS, [dbus-1]) AC_ARG_WITH([dbusservicesdir], AS_HELP_STRING([--with-dbusservicesdir=DIR], [D-Bus system service directory]), [], [with_dbusservicesdir=`$PKG_CONFIG --variable=session_bus_services_dir dbus-1`]) AC_SUBST([dbusservicesdir], [$with_dbusservicesdir]) AC_ARG_ENABLE(applet, AS_HELP_STRING([--enable-applet], [Enable gpaste-applet]), enable_applet=$enableval, enable_applet=no) AM_CONDITIONAL(ENABLE_APPLET, test x$enable_applet = xyes) AC_ARG_ENABLE(unity, AS_HELP_STRING([--enable-unity], [Enable gpaste-app-indicator]), enable_unity=$enableval, enable_unity=no) AM_CONDITIONAL(ENABLE_UNITY, test x$enable_unity = xyes) if test x$enable_unity = xyes; then PKG_CHECK_MODULES(UNITY, [appindicator3-0.1]) AC_DEFINE([ENABLE_UNITY], [1], [Whether the app-indicator is built]) fi AC_ARG_ENABLE(gnome-shell-extension, AS_HELP_STRING([--disable-gnome-shell-extension], [Disable gnome-shell extension]), enable_extension=$enableval, enable_extension=yes) AM_CONDITIONAL(ENABLE_EXTENSION, test x$enable_extension = xyes) if test x$enable_extension = xyes; then if test x$enable_introspection != xyes; then AC_MSG_ERROR([*** Introspection support is required to run the gnome-shell extension]) fi PKG_CHECK_MODULES(GNOME_SHELL, [clutter-1.0 pango]) AC_DEFINE([ENABLE_EXTENSION], [1], [Whether the extension is enabled]) fi AC_ARG_ENABLE(x-keybinder, AS_HELP_STRING([--disable-x-keybinder], [Disable the X keybinder]), enable_x_keybinder=$enableval, enable_x_keybinder=yes) AM_CONDITIONAL(ENABLE_X_KEYBINDER, test x$enable_x_keybinder = xyes) if test x$enable_x_keybinder = xyes; then PKG_CHECK_MODULES(GDK_X11, [gdk-x11-3.0 >= $GTK_REQUIRED]) AC_DEFINE([ENABLE_X_KEYBINDER], [1], [Whether the X keybinder is built]) fi AC_ARG_ENABLE(legacy-cli, AS_HELP_STRING([--disable-legacy-cli], [Disable the legacy cli wrapper (gpaste)]), enable_legacy_cli=$enableval, enable_legacy_cli=yes) AM_CONDITIONAL(ENABLE_LEGACY_CLI, test x$enable_legacy_cli = xyes) AC_CONFIG_FILES([ Makefile po/Makefile.in ]) AC_OUTPUT AC_MSG_RESULT([ $PACKAGE_NAME $VERSION =========== prefix: ${prefix} exec_prefix: ${exec_prefix} sysconfdir: ${sysconfdir} libdir: ${libdir} includedir: ${includedir} compiler: ${CC} cflags: ${CFLAGS} ldflags: ${LDFLAGS} vapi generator: ${VAPIGEN} GObject Introspection: ${enable_introspection} Vapi: ${enable_vala} Status icon: ${enable_applet} App indicator: ${enable_unity} Gnome-Shell extension: ${enable_extension} X keybinder support: ${enable_x_keybinder} ]) GPaste-3.18.6/data/000077500000000000000000000000001305131721400137025ustar00rootroot00000000000000GPaste-3.18.6/data/appstream.mk000066400000000000000000000023221305131721400162260ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2014-2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . @APPSTREAM_XML_RULES@ @INTLTOOL_XML_RULE@ appstream_in_files = \ data/appstream/org.gnome.GPaste.Ui.appdata.xml.in \ $(NULL) if ENABLE_APPLET appstream_in_files += \ data/appstream/org.gnome.GPaste.Applet.appdata.xml.in \ $(NULL) endif if ENABLE_UNITY appstream_in_files += \ data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in \ $(NULL) endif appstream_XML = $(appstream_in_files:.xml.in=.xml) EXTRA_DIST += \ $(appstream_in_files) \ $(NULL) CLEANFILES += \ $(appstream_XML) \ $(NULL) GPaste-3.18.6/data/appstream/000077500000000000000000000000001305131721400156765ustar00rootroot00000000000000GPaste-3.18.6/data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in000066400000000000000000000034111305131721400260660ustar00rootroot00000000000000 org.gnome.GPaste.AppIndicator.desktop <_name>GPaste AppIndicator <_summary>Unity application indicator to manage GPaste Marc-Antoine Perennou GPL-3.0 CC-BY-SA-3.0 GNOME <_p> GPaste is a clipboard managing system allowing you to track and manage your clipboard history in a highly customizable way. <_p> GPaste provides you with an application indicator for unity which will give you access to your history in your indicator area. http://www.imagination-land.org/tags/GPaste.html The AppIndicator menu http://www.imagination-land.org/images/GPaste/2/AppIndicator.png The settings UI http://www.imagination-land.org/images/GPaste/3/Ui-2.png The settings UI http://www.imagination-land.org/images/GPaste/3/Ui-3.png The settings UI http://www.imagination-land.org/images/GPaste/3/Ui-4.png Marc-Antoine@Perennou.com GPaste GPaste-3.18.6/data/appstream/org.gnome.GPaste.Applet.appdata.xml.in000066400000000000000000000033371305131721400247450ustar00rootroot00000000000000 org.gnome.GPaste.Applet.desktop <_name>GPaste Applet <_summary>Tray icon to manage GPaste Marc-Antoine Perennou GPL-3.0 CC-BY-SA-3.0 GNOME <_p> GPaste is a clipboard managing system allowing you to track and manage your clipboard history in a highly customizable way. <_p> GPaste provides you with an applet, in the form of a status icon which will give you access to your history in your tray area. http://www.imagination-land.org/tags/GPaste.html The Applet menu http://www.imagination-land.org/images/GPaste/2/Applet.png The settings UI http://www.imagination-land.org/images/GPaste/3/Ui-2.png The settings UI http://www.imagination-land.org/images/GPaste/3/Ui-3.png The settings UI http://www.imagination-land.org/images/GPaste/3/Ui-4.png Marc-Antoine@Perennou.com GPaste GPaste-3.18.6/data/appstream/org.gnome.GPaste.Ui.appdata.xml.in000066400000000000000000000032431305131721400240710ustar00rootroot00000000000000 org.gnome.GPaste.Ui.desktop GPaste <_summary>Manage your clipboard history Marc-Antoine Perennou GPL-3.0 CC-BY-SA-3.0 GNOME <_p> GPaste is a clipboard managing system allowing you to track and manage your clipboard history in a highly customizable way. <_p> GPaste provides you with a graphical tool allowing you to manage everything easily. http://www.imagination-land.org/tags/GPaste.html The main UI http://www.imagination-land.org/images/GPaste/3/Ui-1.png The settings UI http://www.imagination-land.org/images/GPaste/3/Ui-2.png The settings UI http://www.imagination-land.org/images/GPaste/3/Ui-3.png The settings UI http://www.imagination-land.org/images/GPaste/3/Ui-4.png Marc-Antoine@Perennou.com GPaste GPaste-3.18.6/data/completions.mk000066400000000000000000000015361305131721400165740ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2012-2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . noinst_DATA = \ data/completions/_gpaste-client \ data/completions/gpaste-client \ $(NULL) EXTRA_DIST += \ $(noinst_DATA) \ $(NULL) GPaste-3.18.6/data/completions/000077500000000000000000000000001305131721400162365ustar00rootroot00000000000000GPaste-3.18.6/data/completions/_gpaste-client000066400000000000000000000074641305131721400210720ustar00rootroot00000000000000#compdef gpaste-client (( $+functions[_gpaste-client_complete_arguments] )) || _gpaste-client_complete_arguments() { local -a base_arguments file_arguments get_arguments history_arguments base_arguments=( '(-h --help)'{-h,--help}'[Display the help.]' '(-v --version)'{-v,--version}'[Display the version.]' ) file_arguments=( '*:file:_files' ) get_arguments=( '(-r --raw)'{-r,--raw}'[Display the raw item, not the display string.]' ) history_arguments=( '(-o --oneline)'{-o,--oneline}'[Display each item on one line.]' '(-r --raw)'{-r,--raw}'[Display each item raw (without index).]' '(-z --zero)'{-z,--zero}'[Use a NUL character instead of a newline between each item.]' ) merge_arguments=( '(-d --decoration)'{-d,--decoration}'[Add the decoration at the beginning and end of each item before merging.]' '(-s --separator)'{-s,--separator}'[Add a separator between each item when merging.]' ) case "${1}" in base) _arguments -s : \ ${base_arguments} ${history_arguments} ;; file|f) _arguments -s : \ ${file_arguments} ;; get|g) _arguments -s : \ ${get_arguments} ;; history|h) _arguments -s : \ ${history_arguments} ;; merge|m) _arguments -s : \ ${merge_arguments} ;; esac } (( $+functions[_gpaste-client_complete_subcommands] )) || _gpaste-client_complete_subcommands() { local -a subcommands subcommands=( {add,a}:"Set text to clipboard" {add-password,ap}:"Add a name - password couple to the clipboard" "about:Display the about dialog" {backup-history,bh}:"Backup current history" {daemon-reexec,dr}:"Reexecute the daemon" {daemon-version,dv}:"Display the daemon version" {delete,del,d,remove,rm}:"Delete an element of the history" {delete-history,dh}:"Delete a history" {delete-password,dp}:"Delete a password" {empty,e}:"Empty the history" {file,f}:"Put content of file into clipboard" {get,g}:"Display an element of the history" {get-history,gh}:"Get the name of the current history" "help:Display the help" {history,h}:"Display the history with indexes" {history-size,hs}:"Display the size of the history" {list-histories,lh}:"List available histories" {merge,m}:"Merge various elements from history" {rename-password,rp}:"Rename a password" "replace:Replace the contents of an item" {select,set,s}:"Select an element of the history" {set-password,sp}:"Mark an item as being a password" {settings,preferences,p}:"Launch the configuration tool" {start,daemon,d}:"Start the daemon" {stop,quit,q}:"Shutdown the daemon" "show-history:Make the applet or extension display the history" {switch-history,sh}:"Switch to another history" "ui:Launch the graphical tool" {upload,u}:"Upload item to a pastebin service" {version,v}:"Display the version" {zero-history,zh}:"Display the history with NUL as separator" ) _describe -t commands 'gpaste-client subcommand' subcommands _gpaste-client_complete_arguments "base" } _gpaste-client() { if (( CURRENT > 2 )); then local cmd="${words[2]}" local ctx="gpaste-client" while (( CURRENT > 2 )); do ctx="${ctx}-${words[2]}" (( CURRENT-- )) shift words done curcontext="${curcontext%:*:*}:${ctx}" _gpaste-client_complete_arguments "${cmd}" else _gpaste-client_complete_subcommands fi } _gpaste-client "${@}" GPaste-3.18.6/data/completions/gpaste-client000066400000000000000000000021561305131721400207240ustar00rootroot00000000000000_gpaste-client() { local cur cur="${COMP_WORDS[${COMP_CWORD}]}" COMPREPLY=() if [[ ${COMP_CWORD} == 1 ]]; then local opts opts="about add add-password backup-history daemon daemon-reexec daemon-version delete delete-history --decoration -d delete-password empty file get get-history help --help -h history history-size list-histories merge --oneline -o preferences quit remove --raw -r rename-password replace select --separator -s set set-password settings show-history start stop switch-history upload ui version --version -v --zero -z" COMPREPLY=( $(compgen -W "${opts}" -- ${cur} ) ) elif [[ ${COMP_CWORD} == 2 ]]; then local action action="${COMP_WORDS[1]}" case "${action}" in file|f) COMPREPLY=( $(compgen -f ) ) ;; get|g) COMPREPLY=( compgen -W "--raw -r" -- ${cur} ) ;; history|h) COMPREPLY=( compgen -W "--oneline -o --raw -r --zero -z" -- ${cur} ) ;; esac fi } complete -F _gpaste-client gpaste-client GPaste-3.18.6/data/control-center.mk000066400000000000000000000020631305131721400171720ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2013-2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . SUFFIXES += .xml.in .xml.in.in .xml.in.in.xml.in: @ $(MKDIR_P) data/control-center @ cp $< $@ nodist_controlcenter_DATA = \ data/control-center/42-gpaste.xml \ $(NULL) EXTRA_DIST += \ $(nodist_controlcenter_DATA:.xml=.xml.in.in) \ $(NULL) CLEANFILES += \ $(nodist_controlcenter_DATA) \ $(nodist_controlcenter_DATA:.xml=.xml.in) \ $(NULL) GPaste-3.18.6/data/control-center/000077500000000000000000000000001305131721400166405ustar00rootroot00000000000000GPaste-3.18.6/data/control-center/42-gpaste.xml.in.in000066400000000000000000000015561305131721400221110ustar00rootroot00000000000000 GPaste-3.18.6/data/dbus.mk000066400000000000000000000025131305131721400151710ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2012-2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . nodist_dbusservices_DATA = \ data/dbus/org.gnome.GPaste.service \ data/dbus/org.gnome.GPaste.Ui.service \ $(NULL) if ENABLE_APPLET nodist_dbusservices_DATA += \ data/dbus/org.gnome.GPaste.Applet.service \ $(NULL) endif if ENABLE_UNITY nodist_dbusservices_DATA += \ data/dbus/org.gnome.GPaste.AppIndicator.service \ $(NULL) endif SUFFIXES += .service .dbus.in .dbus.in.service: @ $(MKDIR_P) data/dbus $(AM_V_GEN) $(SED) \ -e 's,[@]pkglibexecdir[@],$(pkglibexecdir),g' \ <$^ >$@ EXTRA_DIST += \ $(nodist_dbusservices_DATA:.service=.dbus.in) \ $(NULL) CLEANFILES += \ $(nodist_dbusservices_DATA) \ $(NULL) GPaste-3.18.6/data/dbus/000077500000000000000000000000001305131721400146375ustar00rootroot00000000000000GPaste-3.18.6/data/dbus/org.gnome.GPaste.AppIndicator.dbus.in000066400000000000000000000001641305131721400235550ustar00rootroot00000000000000[D-BUS Service] Name=org.gnome.GPaste.AppIndicator Exec=@pkglibexecdir@/gpaste-app-indicator --gapplication-service GPaste-3.18.6/data/dbus/org.gnome.GPaste.Applet.dbus.in000066400000000000000000000001471305131721400224260ustar00rootroot00000000000000[D-BUS Service] Name=org.gnome.GPaste.Applet Exec=@pkglibexecdir@/gpaste-applet --gapplication-service GPaste-3.18.6/data/dbus/org.gnome.GPaste.Ui.dbus.in000066400000000000000000000001371305131721400215550ustar00rootroot00000000000000[D-BUS Service] Name=org.gnome.GPaste.Ui Exec=@pkglibexecdir@/gpaste-ui --gapplication-service GPaste-3.18.6/data/dbus/org.gnome.GPaste.dbus.in000066400000000000000000000001111305131721400211710ustar00rootroot00000000000000[D-BUS Service] Name=org.gnome.GPaste Exec=@pkglibexecdir@/gpaste-daemon GPaste-3.18.6/data/desktop.mk000066400000000000000000000035031305131721400157050ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2012-2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . autostartdir = $(sysconfdir)/xdg/autostart applicationsdir = $(datadir)/applications gpaste_applet_desktop_file = data/desktop/org.gnome.GPaste.Applet.desktop gpaste_app_indicator_desktop_file = data/desktop/org.gnome.GPaste.AppIndicator.desktop gpaste_ui_desktop_file = data/desktop/org.gnome.GPaste.Ui.desktop all_desktop_files = \ $(gpaste_applet_desktop_file) \ $(gpaste_app_indicator_desktop_file) \ $(gpaste_ui_desktop_file) \ $(NULL) nodist_autostart_DATA = \ $(NULL) if ENABLE_APPLET nodist_autostart_DATA += \ $(gpaste_applet_desktop_file) \ $(NULL) endif if ENABLE_UNITY nodist_autostart_DATA += \ $(gpaste_app_indicator_desktop_file) \ $(NULL) endif nodist_applications_DATA = \ $(gpaste_ui_desktop_file) \ $(nodist_autostart_DATA) \ $(NULL) @INTLTOOL_DESKTOP_RULE@ SUFFIXES += .desktop.in.in .desktop.in .desktop.in.in.desktop.in: @ $(MKDIR_P) data/desktop $(AM_V_GEN) $(SED) -e 's,[@]pkglibexecdir[@],$(pkglibexecdir),g' < $< > $@ EXTRA_DIST += \ $(all_desktop_files:.desktop=.desktop.in.in) \ $(NULL) CLEANFILES += \ $(all_desktop_files) \ $(all_desktop_files:.desktop=.desktop.in) \ $(NULL) GPaste-3.18.6/data/desktop/000077500000000000000000000000001305131721400153535ustar00rootroot00000000000000GPaste-3.18.6/data/desktop/org.gnome.GPaste.AppIndicator.desktop.in.in000066400000000000000000000004651305131721400254160ustar00rootroot00000000000000[Desktop Entry] Type=Application _Name=GPaste AppIndicator _Comment=Unity application indicator to manage GPaste _Keywords=Clipboard;Manager; Icon=gtk-paste Exec=@pkglibexecdir@/gpaste-app-indicator DBusActivatable=true Terminal=false Categories=GTK;GNOME;Utility;Applet; StartupNotify=true OnlyShowIn=Unity; GPaste-3.18.6/data/desktop/org.gnome.GPaste.Applet.desktop.in.in000066400000000000000000000004301305131721400242560ustar00rootroot00000000000000[Desktop Entry] Type=Application _Name=GPaste Applet _Comment=Tray icon to manage GPaste _Keywords=Clipboard;Manager; Icon=gtk-paste Exec=@pkglibexecdir@/gpaste-applet DBusActivatable=true Terminal=false Categories=GTK;GNOME;Utility;TrayIcon; StartupNotify=true OnlyShowIn=GNOME; GPaste-3.18.6/data/desktop/org.gnome.GPaste.Ui.desktop.in.in000066400000000000000000000004611305131721400234120ustar00rootroot00000000000000[Desktop Entry] Type=Application Name=GPaste _Comment=Manage your clipboard history _Keywords=Clipboard;Manager;Settings;Preferences;Configuration; Icon=gtk-paste Exec=@pkglibexecdir@/gpaste-ui DBusActivatable=true Terminal=false Categories=GTK;GNOME;Settings;X-GNOME-PersonalSettings; StartupNotify=true GPaste-3.18.6/data/gsettings.mk000066400000000000000000000023141305131721400162420ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2012-2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . gpaste_gschema_file = data/gsettings/org.gnome.GPaste.gschema.xml gschemas_compiled = data/gsettings/gschemas.compiled gsettings_SCHEMAS = \ $(gpaste_gschema_file) \ $(NULL) @GSETTINGS_RULES@ $(gpaste_gschema_file:.xml=.valid): $(gpaste_gschema_file) @ $(MKDIR_P) data/gsettings $(gschemas_compiled): $(gsettings_SCHEMAS:.xml=.valid) $(AM_V_GEN) $(GLIB_COMPILE_SCHEMAS) --targetdir=$(srcdir) . EXTRA_DIST += \ $(gpaste_gschema_file) \ $(NULL) CLEANFILES += \ $(gschemas_compiled) \ $(NULL) GPaste-3.18.6/data/gsettings/000077500000000000000000000000001305131721400157115ustar00rootroot00000000000000GPaste-3.18.6/data/gsettings/org.gnome.GPaste.gschema.xml000066400000000000000000000155471305131721400231320ustar00rootroot00000000000000 60 Max size of an element when displaying it The extra stuff of that element will be replaced by "…", and newlines by " " when displaying from the applet, 0 to disable. false Do we detect and replace growing lines in history? By default, selecting "Here is", then "Here is an example" will create two entries in the history. With this feature enabled, the first one will be replaced by the second one. 'history' The name of the current history The default name is "history" true Do we save the images copied to history, or only text? By default, we're saving both '<Ctrl><Alt>G' The keyboard shortcut to launch the graphical interface By default, hitting ctrl + alt + g does that ("<Ctrl><Alt>G"). An empty string here disables this functionnality. '<Ctrl><Alt>S' The keyboard shortcut to mark the active item as being a password By default, hitting ctrl + alt + s will mark the active item as being a password ("<Ctrl><Alt>S"). An empty string here disables this functionnality. 20 Max displayed history size Maximum number of items displayed in the history 100 Max history size Maximum number of items in history 30 Max memory usage (MB) Maximum amount of memory used to store contents 2147483647 Max text item size Maximum size of a text item. Anything out of this boundary is ignored. 1 Min text item size Minimum size of a text item. Anything out of this boundary is ignored. '<Ctrl><Alt>V' The keyboard shortcut to delete the first element in history By default, hitting ctrl + alt + v does that ("<Ctrl><Alt>V"). An empty string here disables this functionnality. false Does the primary selection affects history? By default, only clipboard (ctrl+c) affects history. true Do we save the history from one session to another? By default, we're saving it '<Ctrl><Alt>H' The keyboard shortcut to display the menu By default, hitting ctrl + alt + h displays the menu ("<Ctrl><Alt>H"). An empty string here disables this functionnality. '<Ctrl><Alt>O' The keyboard shortcut to sync the clipboard to the primary selection By default, hitting ctrl + alt + o syncs them ("<Ctrl><Alt>P"). An empty string here disables this functionnality. '<Ctrl><Alt>P' The keyboard shortcut to sync the primary selection to the clipboard By default, hitting ctrl + alt + p syncs them ("<Ctrl><Alt>P"). An empty string here disables this functionnality. false Are the primary selection and the clipboard synchronized? By default, the primary selection and the clipboard are independent. true Do we track the clipboard changes? By default, we're tracking those changes. false Do we sync the daemon state with the gnome-shell extension's one? (disable the daemon when disabling the extension) By default, the daemon state keeps unchanged false Do we trim the textual items before adding them to history? Trimming means removing all trailing and ending spaces. By default, we're letting them as-is. '<Ctrl><Alt>U' The keyboard shortcut to upload the first element in history to a pastebin service By default, hitting ctrl + alt + u does that ("<Ctrl><Alt>U"). An empty string here disables this functionnality. GPaste-3.18.6/data/pkg-config.mk000066400000000000000000000022271305131721400162620ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2012-2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . SUFFIXES += .pc.in .pc .pc.in.pc: @ $(MKDIR_P) data/pkg-config $(AM_V_GEN) $(SED) \ -e 's,[@]libdir[@],$(libdir),g' \ -e 's,[@]includedir[@],$(includedir),g' \ -e 's,[@]VERSION[@],$(VERSION),g' \ < $< > $@ pkgconfigdir = $(libdir)/pkgconfig nodist_pkgconfig_DATA = \ data/pkg-config/gpaste-1.0.pc \ $(NULL) EXTRA_DIST += \ $(nodist_pkgconfig_DATA:.pc=.pc.in) \ $(NULL) CLEANFILES += \ $(nodist_pkgconfig_DATA) \ $(NULL) GPaste-3.18.6/data/pkg-config/000077500000000000000000000000001305131721400157265ustar00rootroot00000000000000GPaste-3.18.6/data/pkg-config/gpaste-1.0.pc.in000066400000000000000000000004001305131721400204300ustar00rootroot00000000000000libdir=@libdir@ includedir=@includedir@ Name: libgpaste Description: Library to handle and communicate with GPaste Version: @VERSION@ Requires: gdk-pixbuf-2.0 gio-2.0 glib-2.0 gobject-2.0 gtk+-3.0 Cflags: -I${includedir}/gpaste Libs: -L${libdir} -lgpaste GPaste-3.18.6/data/search-provider.mk000066400000000000000000000016111305131721400173270ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . searchproviderdir= $(datadir)/gnome-shell/search-providers/ if ENABLE_EXTENSION dist_searchprovider_DATA = \ data/search-provider/org.gnome.GPaste.search-provider.ini \ $(NULL) endif GPaste-3.18.6/data/search-provider/000077500000000000000000000000001305131721400167775ustar00rootroot00000000000000GPaste-3.18.6/data/search-provider/org.gnome.GPaste.search-provider.ini000066400000000000000000000002151305131721400256470ustar00rootroot00000000000000[Shell Search Provider] DesktopId=org.gnome.GPaste.Ui.desktop BusName=org.gnome.GPaste ObjectPath=/org/gnome/GPaste/SearchProvider Version=2 GPaste-3.18.6/legacy/000077500000000000000000000000001305131721400142355ustar00rootroot00000000000000GPaste-3.18.6/legacy/gpaste.mk000066400000000000000000000016131305131721400160520ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . if ENABLE_LEGACY_CLI bin_PROGRAMS += \ bin/gpaste \ $(NULL) endif bin_gpaste_SOURCES = \ legacy/gpaste/gpaste.c \ $(NULL) bin_gpaste_CPPFLAGS = \ -DBINDIR=\"$(bindir)\" \ $(NULL) GPaste-3.18.6/legacy/gpaste/000077500000000000000000000000001305131721400155205ustar00rootroot00000000000000GPaste-3.18.6/legacy/gpaste/gpaste.c000066400000000000000000000023301305131721400171450ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include #include int main (int argc __attribute__((unused)), char *argv[]) { const char *gpaste_client = BINDIR "/gpaste-client"; fprintf (stderr, "\nThe \"gpaste\" command is deprecated and will soon be removed, please use \"gpaste-client\" instead.\n\n"); argv[0] = (char *) gpaste_client; execv (gpaste_client, argv); return EXIT_SUCCESS; } GPaste-3.18.6/m4/000077500000000000000000000000001305131721400133115ustar00rootroot00000000000000GPaste-3.18.6/m4/.gitignore000066400000000000000000000000241305131721400152750ustar00rootroot00000000000000*.m4 !attributes.m4 GPaste-3.18.6/m4/attributes.m4000066400000000000000000000264011305131721400157440ustar00rootroot00000000000000dnl Macros to check the presence of generic (non-typed) symbols. dnl Copyright (c) 2006-2008 Diego Pettenò dnl Copyright (c) 2006-2008 xine project dnl Copyright (c) 2012-2015 Marc-Antoine Perennou dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2, or (at your option) dnl any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA dnl 02110-1301, USA. dnl dnl As a special exception, the copyright owners of the dnl macro gives unlimited permission to copy, distribute and modify the dnl configure scripts that are the output of Autoconf when processing the dnl Macro. You need not follow the terms of the GNU General Public dnl License when using or distributing such scripts, even though portions dnl of the text of the Macro appear in them. The GNU General Public dnl License (GPL) does govern all other use of the material that dnl constitutes the Autoconf Macro. dnl dnl This special exception to the GPL applies to versions of the dnl Autoconf Macro released by this project. When you make and dnl distribute a modified version of the Autoconf Macro, you may extend dnl this special exception to the GPL to apply to your modified version as dnl well. dnl Check if the flag is supported by compiler dnl CC_CHECK_CFLAGS_SILENT([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) AC_DEFUN([CC_CHECK_CFLAGS_SILENT], [ AC_CACHE_VAL(AS_TR_SH([cc_cv_cflags_$1]), [ac_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $1" AC_COMPILE_IFELSE([AC_LANG_SOURCE([int a;])], [eval "AS_TR_SH([cc_cv_cflags_$1])='yes'"], [eval "AS_TR_SH([cc_cv_cflags_$1])='no'"]) CFLAGS="$ac_save_CFLAGS" ]) AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], [$2], [$3]) ]) dnl Check if the flag is supported by compiler (cacheable) dnl CC_CHECK_CFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) AC_DEFUN([CC_CHECK_CFLAGS], [ AC_CACHE_CHECK([if $CC supports $1 flag], AS_TR_SH([cc_cv_cflags_$1]), CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here! ) AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], [$2], [$3]) ]) dnl CC_CHECK_CFLAG_APPEND(FLAG, [action-if-found], [action-if-not-found]) dnl Check for CFLAG and appends them to CFLAGS if supported AC_DEFUN([CC_CHECK_CFLAG_APPEND], [ AC_CACHE_CHECK([if $CC supports $1 flag], AS_TR_SH([cc_cv_cflags_$1]), CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here! ) AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], [CFLAGS="$CFLAGS $1"; DEBUG_CFLAGS="$DEBUG_CFLAGS $1"; $2], [$3]) ]) dnl CC_CHECK_CFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-not]) AC_DEFUN([CC_CHECK_CFLAGS_APPEND], [ for flag in $1; do CC_CHECK_CFLAG_APPEND($flag, [$2], [$3]) done ]) dnl Check if the flag is supported by linker dnl CC_CHECK_LDFLAGS_SILENT([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) AC_DEFUN([CC_CHECK_LDFLAGS_SILENT], [ AC_CACHE_VAL(AS_TR_SH([cc_cv_ldflags_$1]), [ac_save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $1" AC_LINK_IFELSE([AC_LANG_SOURCE([int main() { return 1; }])], [eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"], [eval "AS_TR_SH([cc_cv_ldflags_$1])="]) LDFLAGS="$ac_save_LDFLAGS" ]) AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes], [$2], [$3]) ]) dnl Check if the flag is supported by linker (cacheable) dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) AC_DEFUN([CC_CHECK_LDFLAGS], [ AC_CACHE_CHECK([if $CC supports $1 flag], AS_TR_SH([cc_cv_ldflags_$1]), CC_CHECK_LDFLAGS_SILENT([$1]) dnl Don't execute actions here! ) AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes], [$2], [$3]) ]) dnl CC_CHECK_LDFLAG_APPEND(FLAG, [action-if-found], [action-if-not-found]) dnl Check for LDFLAG and appends them to LDFLAGS if supported AC_DEFUN([CC_CHECK_LDFLAG_APPEND], [ AC_CACHE_CHECK([if $CC supports $1 flag], AS_TR_SH([cc_cv_ldflags_$1]), CC_CHECK_LDFLAGS_SILENT([$1]) dnl Don't execute actions here! ) AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes], [LDFLAGS="$LDFLAGS $1"; DEBUG_LDFLAGS="$DEBUG_LDFLAGS $1"; $2], [$3]) ]) dnl CC_CHECK_LDFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-not]) AC_DEFUN([CC_CHECK_LDFLAGS_APPEND], [ for flag in $1; do CC_CHECK_LDFLAG_APPEND($flag, [$2], [$3]) done ]) dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for dnl the current linker to avoid undefined references in a shared object. AC_DEFUN([CC_NOUNDEFINED], [ dnl We check $host for which systems to enable this for. AC_REQUIRE([AC_CANONICAL_HOST]) case $host in dnl FreeBSD (et al.) does not complete linking for shared objects when pthreads dnl are requested, as different implementations are present; to avoid problems dnl use -Wl,-z,defs only for those platform not behaving this way. *-freebsd* | *-openbsd*) ;; *) dnl First of all check for the --no-undefined variant of GNU ld. This allows dnl for a much more readable commandline, so that people can understand what dnl it does without going to look for what the heck -z defs does. for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"]) break done ;; esac AC_SUBST([LDFLAGS_NOUNDEFINED]) ]) dnl Check for a -Werror flag or equivalent. -Werror is the GCC dnl and ICC flag that tells the compiler to treat all the warnings dnl as fatal. We usually need this option to make sure that some dnl constructs (like attributes) are not simply ignored. dnl dnl Other compilers don't support -Werror per se, but they support dnl an equivalent flag: dnl - Sun Studio compiler supports -errwarn=%all AC_DEFUN([CC_CHECK_WERROR], [ AC_CACHE_CHECK( [for $CC way to treat warnings as errors], [cc_cv_werror], [CC_CHECK_CFLAGS_SILENT([-Werror], [cc_cv_werror=-Werror], [CC_CHECK_CFLAGS_SILENT([-errwarn=%all], [cc_cv_werror=-errwarn=%all])]) ]) ]) AC_DEFUN([CC_CHECK_ATTRIBUTE], [ AC_REQUIRE([CC_CHECK_WERROR]) AC_CACHE_CHECK([if $CC supports __attribute__(( ifelse([$2], , [$1], [$2]) ))], AS_TR_SH([cc_cv_attribute_$1]), [ac_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cc_cv_werror" AC_COMPILE_IFELSE([AC_LANG_SOURCE([$3])], [eval "AS_TR_SH([cc_cv_attribute_$1])='yes'"], [eval "AS_TR_SH([cc_cv_attribute_$1])='no'"]) CFLAGS="$ac_save_CFLAGS" ]) AS_IF([eval test x$]AS_TR_SH([cc_cv_attribute_$1])[ = xyes], [AC_DEFINE( AS_TR_CPP([SUPPORT_ATTRIBUTE_$1]), 1, [Define this if the compiler supports __attribute__(( ifelse([$2], , [$1], [$2]) ))] ) $4], [$5]) ]) AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [ CC_CHECK_ATTRIBUTE( [constructor],, [void __attribute__((constructor)) ctor() { int a; }], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_FORMAT], [ CC_CHECK_ATTRIBUTE( [format], [format(printf, n, n)], [void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { fmt = (void *)0; }], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [ CC_CHECK_ATTRIBUTE( [format_arg], [format_arg(printf)], [char *__attribute__((format_arg(1))) gettextlike(const char *fmt) { fmt = (void *)0; }], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [ CC_CHECK_ATTRIBUTE( [visibility_$1], [visibility("$1")], [void __attribute__((visibility("$1"))) $1_function() { }], [$2], [$3]) ]) AC_DEFUN([CC_ATTRIBUTE_NONNULL], [ CC_CHECK_ATTRIBUTE( [nonnull], [nonnull()], [void __attribute__((nonnull())) some_function(void *foo, void *bar) { foo = (void*)0; bar = (void*)0; }], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_UNUSED], [ CC_CHECK_ATTRIBUTE( [unused], , [void some_function(void *foo, __attribute__((unused)) void *bar);], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [ CC_CHECK_ATTRIBUTE( [sentinel], , [void some_function(void *foo, ...) __attribute__((sentinel));], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_DEPRECATED], [ CC_CHECK_ATTRIBUTE( [deprecated], , [void some_function(void *foo, ...) __attribute__((deprecated));], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_ALIAS], [ CC_CHECK_ATTRIBUTE( [alias], [weak, alias], [void other_function(void *foo) { } void some_function(void *foo) __attribute__((weak, alias("other_function")));], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_MALLOC], [ CC_CHECK_ATTRIBUTE( [malloc], , [void * __attribute__((malloc)) my_alloc(int n);], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_PACKED], [ CC_CHECK_ATTRIBUTE( [packed], , [struct astructure { char a; int b; long c; void *d; } __attribute__((packed));], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_CONST], [ CC_CHECK_ATTRIBUTE( [const], , [int __attribute__((const)) twopow(int n) { return 1 << n; } ], [$1], [$2]) ]) AC_DEFUN([CC_FLAG_VISIBILITY], [ AC_REQUIRE([CC_CHECK_WERROR]) AC_CACHE_CHECK([if $CC supports -fvisibility=hidden], [cc_cv_flag_visibility], [cc_flag_visibility_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cc_cv_werror" CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden], cc_cv_flag_visibility='yes', cc_cv_flag_visibility='no') CFLAGS="$cc_flag_visibility_save_CFLAGS"]) AS_IF([test "x$cc_cv_flag_visibility" = "xyes"], [AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1, [Define this if the compiler supports the -fvisibility flag]) $1], [$2]) ]) AC_DEFUN([CC_FUNC_EXPECT], [ AC_REQUIRE([CC_CHECK_WERROR]) AC_CACHE_CHECK([if compiler has __builtin_expect function], [cc_cv_func_expect], [ac_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cc_cv_werror" AC_COMPILE_IFELSE([AC_LANG_SOURCE( [int some_function() { int a = 3; return (int)__builtin_expect(a, 3); }])], [cc_cv_func_expect=yes], [cc_cv_func_expect=no]) CFLAGS="$ac_save_CFLAGS" ]) AS_IF([test "x$cc_cv_func_expect" = "xyes"], [AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1, [Define this if the compiler supports __builtin_expect() function]) $1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [ AC_REQUIRE([CC_CHECK_WERROR]) AC_CACHE_CHECK([highest __attribute__ ((aligned ())) supported], [cc_cv_attribute_aligned], [ac_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cc_cv_werror" for cc_attribute_align_try in 64 32 16 8 4 2; do AC_COMPILE_IFELSE([AC_LANG_SOURCE([ int main() { static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0; return c; }])], [cc_cv_attribute_aligned=$cc_attribute_align_try; break]) done CFLAGS="$ac_save_CFLAGS" ]) if test "x$cc_cv_attribute_aligned" != "x"; then AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX], [$cc_cv_attribute_aligned], [Define the highest alignment supported]) fi ]) GPaste-3.18.6/man/000077500000000000000000000000001305131721400135445ustar00rootroot00000000000000GPaste-3.18.6/man/1.mk000066400000000000000000000014101305131721400142310ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2012-2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . dist_man_MANS = \ man/1/gpaste-client.1 \ $(NULL) GPaste-3.18.6/man/1/000077500000000000000000000000001305131721400137045ustar00rootroot00000000000000GPaste-3.18.6/man/1/gpaste-client.1000066400000000000000000000101701305131721400165240ustar00rootroot00000000000000.\" Copyright (c) 2011-2015 Marc-Antoine Perennou .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, write to the Free .\" Software Foundation, Inc., 51 Franklin Street, Fifth Floor, .\" Boston, MA 02111-1301 USA. .TH GPASTE-CLIENT 1 .SH NAME GPaste \- A lightweight clipboard manager for the Gnome desktop .SH "SYNOPSIS" .B [command |] gpaste-client [options...] .SH "DESCRIPTION" GPaste is a modular clipboard management system with a fully DBus-based daemon, a \s-1CLI\s0 client and a gtk+ tray icon. .SH "COMMANDS" .TP .B gpaste-client [history] Display the history with indexes .br .TP .B gpaste-client history-size Display this size of the history .br .TP .B gpaste-client get-history Get the name of the current history .br .TP .B gpaste-client backup-history Backup the current history .br .TP .B gpaste-client switch-history Switch to another history .br .TP .B gpaste-client delete-history Delete a history .br .TP .B gpaste-client list-histories List available histories .br .TP .B gpaste-client add Add the text into the history .br .TP .B gpaste-client add-password Add the name \- password couple to the history .br .TP .B gpaste-client delete-password Delete the password .br .TP .B gpaste-client set-password Mark the th item of the history as being a password named .br .TP .B gpaste-client rename-password Rename the password .br .TP .B gpaste-client get Get the th item from the history .br .TP .B gpaste-client select Put the th item of the history into the clipboard .br .TP .B gpaste-client replace Replace the contents of the th item of the history with the provided one .br .TP .B gpaste-client merge [--decoration|-d ] [--separator|-s ] Merge the th items of the history and put the result in the clipboard .br If foo bar and baz are respectively index 1 3 and 4 in history and you run .br gpaste-client merge \-d '"' \-s ',' 1 3 4 .br You will end up with "foo","bar","baz" in your clipboard .br .TP .B gpaste-client delete Delete the th item of the history .br .TP .B gpaste-client file Put the content of the file at into the clipboard .br .TP .B command | gpaste-client Put the output of the command into the history .br .TP .B gpaste-client empty Empty the history .br .TP .B gpaste-client start Start tracking clipboard changes .br .TP .B gpaste-client stop Stop tracking clipboard changes .br .TP .B gpaste-client upload Upload the th item to a pastebin service .br .TP .B gpaste-client ui Launch the graphical tool .br .TP .B gpaste-client daemon-reexec Reexecute the daemon, for example after upgrading GPaste .br .TP .B gpaste-client settings Launch the configuration tool .br .TP .B gpaste-client version Display the version .br .TP .B gpaste-client daemon-version Display the daemon version .br .TP .B gpaste-client help Display the help .br .TP .B gpaste-client about Display the about dialog .br .TP .B gpaste-client show-history Make the applet or extension display the history .br .SH "OPTIONS" .TP .B --oneline Display each item on one line, without new lines .br .TP .B --raw Display the item raw (without index) .br .TP .B --zero Use NUL character instead of new lines between each item .br GPaste-3.18.6/po/000077500000000000000000000000001305131721400134075ustar00rootroot00000000000000GPaste-3.18.6/po/LINGUAS000066400000000000000000000000221305131721400144260ustar00rootroot00000000000000de es fi fr pt_BR GPaste-3.18.6/po/Makevars000066400000000000000000000034731305131721400151120ustar00rootroot00000000000000# Makefile variables for PO directory in any package using GNU gettext. # Usually the message domain is the same as the package name. DOMAIN = $(PACKAGE) # These two variables depend on the location of this directory. subdir = po top_builddir = .. # These options get passed to xgettext. XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ # This is the copyright holder that gets inserted into the header of the # $(DOMAIN).pot file. Set this to the copyright holder of the surrounding # package. (Note that the msgstr strings, extracted from the package's # sources, belong to the copyright holder of the package.) Translators are # expected to transfer the copyright for their translations to this person # or entity, or to disclaim their copyright. The empty string stands for # the public domain; in this case the translators are expected to disclaim # their copyright. COPYRIGHT_HOLDER = Marc-Antoine Perennou # This is the email address or URL to which the translators shall report # bugs in the untranslated strings: # - Strings which are not entire sentences, see the maintainer guidelines # in the GNU gettext documentation, section 'Preparing Strings'. # - Strings which use unclear terms or require additional context to be # understood. # - Strings which make invalid assumptions about notation of date, time or # money. # - Pluralisation problems. # - Incorrect English spelling. # - Incorrect formatting. # It can be your email address, or a mailing list address where translators # can write to without being subscribed, or the URL of a web page through # which the translators can contact you. MSGID_BUGS_ADDRESS = Marc-Antoine@Perennou.com # This is the list of locale categories, beyond LC_MESSAGES, for which the # message catalogs shall be used. It is usually empty. EXTRA_LOCALE_CATEGORIES = GPaste-3.18.6/po/POTFILES.in000066400000000000000000000026761305131721400151770ustar00rootroot00000000000000src/libgpaste/gpaste-macros.h src/libgpaste/applet/gpaste-applet.c src/libgpaste/applet/gpaste-applet-about.c src/libgpaste/applet/gpaste-applet-quit.c src/libgpaste/applet/gpaste-applet-ui.c src/libgpaste/core/gpaste-history.c src/libgpaste/core/gpaste-image-item.c src/libgpaste/core/gpaste-password-item.c src/libgpaste/core/gpaste-uris-item.c src/libgpaste/settings-ui/gpaste-settings-ui-stack.c src/libgpaste/ui/gpaste-ui-about.c src/libgpaste/ui/gpaste-ui-backup-history.c src/libgpaste/ui/gpaste-ui-delete-item.c src/libgpaste/ui/gpaste-ui-delete-history.c src/libgpaste/ui/gpaste-ui-edit-item.c src/libgpaste/ui/gpaste-ui-empty-history.c src/libgpaste/ui/gpaste-ui-empty-item.c src/libgpaste/ui/gpaste-ui-panel.c src/libgpaste/ui/gpaste-ui-reexec.c src/libgpaste/ui/gpaste-ui-search.c src/libgpaste/ui/gpaste-ui-settings.c src/libgpaste/ui/gpaste-ui-switch.c src/libgpaste/ui/gpaste-ui-upload-item.c src/libgpaste/ui/gpaste-ui-window.c src/libgpaste/util/gpaste-util.c src/gnome-shell/extension.js src/daemon/gpaste-daemon.c src/gpaste-client/gpaste-client.c data/appstream/org.gnome.GPaste.Applet.appdata.xml.in data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in data/appstream/org.gnome.GPaste.Ui.appdata.xml.in data/control-center/42-gpaste.xml.in.in data/desktop/org.gnome.GPaste.Applet.desktop.in.in data/desktop/org.gnome.GPaste.AppIndicator.desktop.in.in data/desktop/org.gnome.GPaste.Ui.desktop.in.in data/gsettings/org.gnome.GPaste.gschema.xml GPaste-3.18.6/po/POTFILES.skip000066400000000000000000000002671305131721400155310ustar00rootroot00000000000000data/control-center/42-gpaste.xml.in data/desktop/org.gnome.GPaste.Applet.desktop.in data/desktop/org.gnome.GPaste.AppIndicator.desktop.in data/desktop/org.gnome.GPaste.Ui.desktop.in GPaste-3.18.6/po/de.po000066400000000000000000000763101305131721400143460ustar00rootroot00000000000000# German translations for GPaste package. # Copyright (C) 2013-2015 Listed translators # This file is distributed under the same license as the GPaste package. # Christian Schendel , 2013. # msgid "" msgstr "" "Project-Id-Version: GPaste\n" "Report-Msgid-Bugs-To: Marc-Antoine@Perennou.com\n" "POT-Creation-Date: 2017-02-16 13:43+0100\n" "PO-Revision-Date: 2014-03-27 21:03+0100\n" "Last-Translator: Christian Kluge \n" "Language-Team: \n" "Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Generator: Poedit 1.5.5\n" #: ../src/libgpaste/gpaste-macros.h:63 msgid "Failed to register the gtk application" msgstr "Initialisierung der Gtk-Anwendung fehlgeschlagen" #: ../src/libgpaste/applet/gpaste-applet.c:156 #: ../src/libgpaste/applet/gpaste-applet.c:184 msgid "is not installed" msgstr "" #: ../src/libgpaste/applet/gpaste-applet-about.c:81 #: ../src/libgpaste/ui/gpaste-ui-about.c:52 msgid "About" msgstr "Über" #: ../src/libgpaste/applet/gpaste-applet-quit.c:70 msgid "Quit" msgstr "Beenden" #. Translators: help for gpaste ui #: ../src/libgpaste/applet/gpaste-applet-ui.c:61 #: ../src/gpaste-client/gpaste-client.c:83 #, fuzzy msgid "launch the graphical tool" msgstr "Konfigurationswerkzeug starten" #: ../src/libgpaste/core/gpaste-history.c:773 msgid "Could not create history dir" msgstr "Ordner für die Chronik konnte nicht angelegt werden" #. This is the date format "month/day/year time" #: ../src/libgpaste/core/gpaste-image-item.c:235 msgid "%m/%d/%y %T" msgstr "%d. %m. %y - %T" #. This gets displayed in history when selecting an image #: ../src/libgpaste/core/gpaste-image-item.c:237 #, c-format msgid "[Image, %d x %d (%s)]" msgstr "[Bild, %d x %d (%s)]" #. This is the prefix displayed in history to identify a password #: ../src/libgpaste/core/gpaste-password-item.c:82 msgid "Password" msgstr "" #. This is the prefix displayed in history to identify selected files #: ../src/libgpaste/core/gpaste-uris-item.c:117 msgid "[Files] " msgstr "[Dateien]" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:126 #: ../src/libgpaste/ui/gpaste-ui-switch.c:96 msgid "Track clipboard changes" msgstr "Verfolge Änderungen in der Zwischenablage" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:133 msgid "Enable the gnome-shell extension" msgstr "Die Gnome-Shell-Erweiterung aktivieren" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:139 msgid "Sync the daemon state with the extension's one" msgstr "Synchronisiere Daemon mit der Erweiterung" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:147 msgid "Primary selection affects history" msgstr "Auswahl beeinflusst Chronik" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:153 msgid "Synchronize clipboard with primary selection" msgstr "Synchronisiere Zwischenablage mit Auswahl" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:160 msgid "Images support" msgstr "Bilder unterstützen" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:166 msgid "Trim items" msgstr "Objekte trimmen" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:172 msgid "Detect growing lines" msgstr "Länger werdende Zeilen entdecken" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:179 msgid "Save history" msgstr "Chronik speichern" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:202 msgid "Max element size when displaying: " msgstr "Maximale Größe des anzuzeigenden Eintrages:" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:209 msgid "Max displayed history size: " msgstr "Anzahl der anzuzeigenden Einträge:" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:216 msgid "Max history size: " msgstr "Maximale Größe der Chronik:" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:223 msgid "Max memory usage (MB): " msgstr "Maximaler Speicherverbrauch (MB):" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:230 msgid "Max text item length: " msgstr "Maximale Textlänge:" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:237 msgid "Min text item length: " msgstr "Minimale Textlänge:" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:263 #: ../data/control-center/42-gpaste.xml.in.in.h:3 #, fuzzy msgid "Delete the active item from history: " msgstr "Lösche den ten Eintrag aus der Chronik" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:270 #: ../data/control-center/42-gpaste.xml.in.in.h:1 #, fuzzy msgid "Launch the graphical tool: " msgstr "Konfigurationswerkzeug starten" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:277 #: ../data/control-center/42-gpaste.xml.in.in.h:2 msgid "Mark the active item as being a password: " msgstr "" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:284 #: ../data/control-center/42-gpaste.xml.in.in.h:4 msgid "Display the history: " msgstr "Chronik anzeigen:" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:291 #: ../data/control-center/42-gpaste.xml.in.in.h:5 msgid "Sync the clipboard to the primary selection: " msgstr "Zwischenablage mit der Auswahl synchronisieren:" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:298 #: ../data/control-center/42-gpaste.xml.in.in.h:6 msgid "Sync the primary selection to the clipboard: " msgstr "Auswahl mit der Zwischenablage synchronisieren:" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:305 #: ../data/control-center/42-gpaste.xml.in.in.h:7 #, fuzzy msgid "Upload the active item to a pastebin service: " msgstr "Lösche den ten Eintrag aus der Chronik" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:320 #: ../src/libgpaste/ui/gpaste-ui-window.c:211 #: ../src/gpaste-client/gpaste-client.c:185 msgid "Couldn't connect to GPaste daemon" msgstr "Verbindung zum GPaste daemon fehlgeschlagen" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:337 msgid "General behaviour" msgstr "Allgemeine Optionen" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:338 msgid "History settings" msgstr "Einstellungen zur Chronik" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:339 msgid "Keyboard shortcuts" msgstr "Tastaturkürzel" #. translators: This is the name of a multi-history management action #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:453 #: ../src/libgpaste/ui/gpaste-ui-panel.c:297 msgid "Switch to" msgstr "Wechseln zu" #. translators: This is the name of a multi-history management action #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:458 #: ../src/libgpaste/ui/gpaste-ui-delete-item.c:62 #: ../src/libgpaste/ui/gpaste-ui-delete-history.c:37 #: ../src/libgpaste/ui/gpaste-ui-delete-history.c:74 msgid "Delete" msgstr "Löschen" #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:47 #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:133 msgid "Backup" msgstr "Backup" #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:48 #: ../src/libgpaste/ui/gpaste-ui-edit-item.c:56 #: ../src/libgpaste/util/gpaste-util.c:43 msgid "Cancel" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:51 msgid "Under which name do you want to backup this history?" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-delete-history.c:37 #, fuzzy msgid "Are you sure you want to delete this history?" msgstr "Tastenkürzel um den ersten Eintrag in der Chronik zu löschen" #: ../src/libgpaste/ui/gpaste-ui-edit-item.c:55 #: ../src/libgpaste/ui/gpaste-ui-edit-item.c:126 msgid "Edit" msgstr "" #. Translators: this is the translation for emptying the history #: ../src/libgpaste/ui/gpaste-ui-empty-history.c:38 #: ../src/libgpaste/ui/gpaste-ui-empty-history.c:76 #, fuzzy msgid "Empty" msgstr "(Leer)" #: ../src/libgpaste/ui/gpaste-ui-empty-history.c:38 msgid "Do you really want to empty the history?" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-empty-item.c:37 msgid "(Empty)" msgstr "(Leer)" #: ../src/libgpaste/ui/gpaste-ui-reexec.c:42 msgid "Restart" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-reexec.c:42 #, fuzzy msgid "Do you really want to restart the daemon?" msgstr "Stoppt die Verfolgung von Änderungen an der Zwischenablage" #: ../src/libgpaste/ui/gpaste-ui-reexec.c:66 msgid "Restart the daemon" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-search.c:37 msgid "Search" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-settings.c:42 msgid "GPaste Settings" msgstr "GPaste-Daemon-Einstellungen" #: ../src/libgpaste/ui/gpaste-ui-switch.c:60 msgid "Stop" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-switch.c:60 #, fuzzy msgid "Do you really want to stop tracking clipboard changes?" msgstr "Stoppt die Verfolgung von Änderungen an der Zwischenablage" #: ../src/libgpaste/ui/gpaste-ui-upload-item.c:62 msgid "Upload" msgstr "" #: ../src/daemon/gpaste-daemon.c:47 msgid "Could not acquire DBus name." msgstr "DBus-Name konnte nicht bestimmt werden." #: ../src/gpaste-client/gpaste-client.c:31 #, c-format msgid "Usage:\n" msgstr "Verwendung:\n" #. Translators: help for gpaste history #: ../src/gpaste-client/gpaste-client.c:33 msgid "print the history with indexes" msgstr "Chronik mit Index anzeigen" #. Translators: help for gpaste history-size #: ../src/gpaste-client/gpaste-client.c:35 #, fuzzy msgid "print the size of the history" msgstr "Lösche den ten Eintrag aus der Chronik" #. Translators: help for gpaste get-history #: ../src/gpaste-client/gpaste-client.c:37 #, fuzzy msgid "get the name of the current history" msgstr "Name der Aktuellen Chronik" #. Translators: help for gpaste backup-history #. Translators: help for gpaste switch-history #. Translators: help for gpaste delete-history #. Translators: help for gpaste add-password #. Translators: help for gpaste delete-passworf #: ../src/gpaste-client/gpaste-client.c:39 #: ../src/gpaste-client/gpaste-client.c:41 #: ../src/gpaste-client/gpaste-client.c:43 #: ../src/gpaste-client/gpaste-client.c:49 #: ../src/gpaste-client/gpaste-client.c:61 #: ../src/gpaste-client/gpaste-client.c:65 msgid "name" msgstr "Name" #: ../src/gpaste-client/gpaste-client.c:39 msgid "backup current history" msgstr "Aktuelle Chronik sichern" #: ../src/gpaste-client/gpaste-client.c:41 msgid "switch to another history" msgstr "Zu einer anderen Chronik wechseln" #: ../src/gpaste-client/gpaste-client.c:43 msgid "delete a history" msgstr "Lösche eine Chronik" #. Translators: help for gpaste list-histories #: ../src/gpaste-client/gpaste-client.c:45 msgid "list available histories" msgstr "Verfügbare Chroniken anzeigen" #. Translators: help for gpaste add #: ../src/gpaste-client/gpaste-client.c:47 msgid "text" msgstr "Text" #: ../src/gpaste-client/gpaste-client.c:47 msgid "set text to clipboard" msgstr "Den markierten Text in die Zwischenablage kopieren" #: ../src/gpaste-client/gpaste-client.c:49 msgid "password" msgstr "" #: ../src/gpaste-client/gpaste-client.c:49 #, fuzzy msgid "add the name - password couple to the clipboard" msgstr "Auswahl mit der Zwischenablage synchronisieren:" #. Translators: help for gpaste rename-password #: ../src/gpaste-client/gpaste-client.c:51 #, fuzzy msgid "old name" msgstr "Name" #: ../src/gpaste-client/gpaste-client.c:51 #, fuzzy msgid "new name" msgstr "Name" #: ../src/gpaste-client/gpaste-client.c:51 msgid "rename the password" msgstr "" #. Translators: help for gpaste get #. Translators: help for gpaste select #. Translators: help for gpaste replace #. Translators: help for gpaste merge #. Translators: help for gpaste set-password #. Translators: help for gpaste delete #. Translators: help for gpaste upload #: ../src/gpaste-client/gpaste-client.c:53 #: ../src/gpaste-client/gpaste-client.c:55 #: ../src/gpaste-client/gpaste-client.c:57 #: ../src/gpaste-client/gpaste-client.c:59 #: ../src/gpaste-client/gpaste-client.c:61 #: ../src/gpaste-client/gpaste-client.c:63 #: ../src/gpaste-client/gpaste-client.c:97 msgid "number" msgstr "Nummer" #: ../src/gpaste-client/gpaste-client.c:53 msgid "get the th item from the history" msgstr "Hole den ten Eintrag aus der Chronik" #: ../src/gpaste-client/gpaste-client.c:55 msgid "set the th item from the history to the clipboard" msgstr "Setze den ten Eintrag aus der Chronik in die Zwischenablage" #: ../src/gpaste-client/gpaste-client.c:57 msgid "contents" msgstr "" #: ../src/gpaste-client/gpaste-client.c:57 #, fuzzy msgid "" "replace the contents of the th item from the history with the " "provided one" msgstr "Setze den ten Eintrag aus der Chronik in die Zwischenablage" #: ../src/gpaste-client/gpaste-client.c:59 #, fuzzy msgid "" "merge the th items from the history and add put the result in the " "clipboard" msgstr "Setze den ten Eintrag aus der Chronik in die Zwischenablage" #: ../src/gpaste-client/gpaste-client.c:61 #, fuzzy msgid "set the th item from the history as a password named " msgstr "Setze den ten Eintrag aus der Chronik in die Zwischenablage" #: ../src/gpaste-client/gpaste-client.c:63 msgid "delete th item of the history" msgstr "Lösche den ten Eintrag aus der Chronik" #: ../src/gpaste-client/gpaste-client.c:65 #, fuzzy msgid "delete the password from the history" msgstr "Hole den ten Eintrag aus der Chronik" #. Translators: help for gpaste file #: ../src/gpaste-client/gpaste-client.c:67 msgid "path" msgstr "Pfad" #: ../src/gpaste-client/gpaste-client.c:67 msgid "put the content of the file at into the clipboard" msgstr "Kopiere den Inhalt der Datei in zur Zwischenablage" #. Translators: help for whatever | gpaste #: ../src/gpaste-client/gpaste-client.c:69 msgid "whatever" msgstr "PROGRAMM" #: ../src/gpaste-client/gpaste-client.c:69 msgid "set the output of whatever to clipboard" msgstr "kopiert die Ausgabe von PROGRAMM in die Zwischenablage" #. Translators: help for gpaste empty #: ../src/gpaste-client/gpaste-client.c:71 msgid "empty the history" msgstr "Chronik leeren" #. Translators: help for gpaste start #: ../src/gpaste-client/gpaste-client.c:73 msgid "start tracking clipboard changes" msgstr "Startet die Verfolgung von Änderungen an der Zwischenablage" #. Translators: help for gpaste stop #: ../src/gpaste-client/gpaste-client.c:75 msgid "stop tracking clipboard changes" msgstr "Stoppt die Verfolgung von Änderungen an der Zwischenablage" #. Translators: help for gpaste quit #: ../src/gpaste-client/gpaste-client.c:77 #, fuzzy msgid "alias for stop" msgstr "Alias für stop" #. Translators: help for gpaste daemon-reexec #: ../src/gpaste-client/gpaste-client.c:79 msgid "reexecute the daemon (after upgrading...)" msgstr "Startet den Daemon neu (Nach einem Update …)" #. Translators: help for gpaste settings #: ../src/gpaste-client/gpaste-client.c:81 msgid "launch the configuration tool" msgstr "Konfigurationswerkzeug starten" #. Translators: help for gpaste applet #: ../src/gpaste-client/gpaste-client.c:87 msgid "launch the applet" msgstr "Applet starten" #. Translators: help for gpaste app-indicator #: ../src/gpaste-client/gpaste-client.c:92 #, fuzzy msgid "launch the unity application indicator" msgstr "Konfigurationswerkzeug starten" #. Translators: help for gpaste show-history #: ../src/gpaste-client/gpaste-client.c:95 #, fuzzy msgid "make the applet or extension display the history" msgstr "Die maximale Anzahl der anzuzeigenden Einträge in der Chronik" #: ../src/gpaste-client/gpaste-client.c:97 #, fuzzy msgid "upload the th item to a pastebin service" msgstr "Lösche den ten Eintrag aus der Chronik" #. Translators: help for gpaste version #: ../src/gpaste-client/gpaste-client.c:99 msgid "display the version" msgstr "Programmversion anzeigen" #. Translators: help for gpaste daemon-version #: ../src/gpaste-client/gpaste-client.c:101 #, fuzzy msgid "display the daemon version" msgstr "Programmversion anzeigen" #. Translators: help for gpaste help #: ../src/gpaste-client/gpaste-client.c:103 msgid "display this help" msgstr "Diesen Hilfetext anzeigen" #. Translators: help for gpaste about #: ../src/gpaste-client/gpaste-client.c:105 #, fuzzy msgid "display the about dialog" msgstr "Programmversion anzeigen" #: ../src/gpaste-client/gpaste-client.c:108 #, fuzzy, c-format msgid "Display options:" msgstr "Chronik anzeigen:" #. Translators: help for --oneline #: ../src/gpaste-client/gpaste-client.c:111 #, fuzzy msgid "display each item on only one line" msgstr "Programmversion anzeigen" #. Translators: help for --oneline #: ../src/gpaste-client/gpaste-client.c:113 msgid "display each item raw (without line numbers)" msgstr "" #. Translators: help for --oneline #: ../src/gpaste-client/gpaste-client.c:115 msgid "use a NUL character instead of a new line betweean each item" msgstr "" #: ../src/gpaste-client/gpaste-client.c:118 #, fuzzy, c-format msgid "Merge options:" msgstr "Chronik anzeigen:" #. Translators: help for --decoration #. Translators: help for --separator #: ../src/gpaste-client/gpaste-client.c:121 #: ../src/gpaste-client/gpaste-client.c:123 msgid "string" msgstr "" #: ../src/gpaste-client/gpaste-client.c:121 msgid "" "add the given decoration to the beginning and the end of each item before " "merging" msgstr "" #: ../src/gpaste-client/gpaste-client.c:123 msgid "add the given separator between each item when merging" msgstr "" #: ../src/gpaste-client/gpaste-client.c:196 #: ../src/gpaste-client/gpaste-client.c:410 #, fuzzy msgid "Couldn't spawn" msgstr "gpaste-applet konnte nicht gestartet werden.\n" #: ../src/gpaste-client/gpaste-client.c:355 #, c-format msgid "Successfully reexecuted the daemon\n" msgstr "Daemon wurde erfolgreich neu gestartet\n" #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:1 #: ../data/desktop/org.gnome.GPaste.Applet.desktop.in.in.h:1 msgid "GPaste Applet" msgstr "GPaste-Applet" #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:2 #: ../data/desktop/org.gnome.GPaste.Applet.desktop.in.in.h:2 msgid "Tray icon to manage GPaste" msgstr "Icon im Benachrichtigungsfeld um GPaste zu konfigurieren" #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:3 #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:3 #: ../data/appstream/org.gnome.GPaste.Ui.appdata.xml.in.h:2 msgid "" "GPaste is a clipboard managing system allowing you to track and manage your " "clipboard history in a highly customizable way." msgstr "" "GPaste ist ein ein Managementsystem für die Zwischenablage, dass es erlaubt " "die Chronik der Zwischenablage auf eine sehr flexible Art zu verfolgen und " "zu managen." #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:4 msgid "" "GPaste provides you with an applet, in the form of a status icon which will " "give you access to your history in your tray area." msgstr "" "GPaste stellt ein Applet in Form eines Status-Icons bereit, das Zugriff auf " "die Chronik im Benachrichtigungsfeld ermöglicht." #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:1 #: ../data/desktop/org.gnome.GPaste.AppIndicator.desktop.in.in.h:1 #, fuzzy msgid "GPaste AppIndicator" msgstr "GPaste-Applet" #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:2 #: ../data/desktop/org.gnome.GPaste.AppIndicator.desktop.in.in.h:2 #, fuzzy msgid "Unity application indicator to manage GPaste" msgstr "Icon im Benachrichtigungsfeld um GPaste zu konfigurieren" #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:4 msgid "" "GPaste provides you with an application indicator for unity which will give " "you access to your history in your indicator area." msgstr "" "GPaste stellt einen Applikations-Indikator für Unity bereit, der Zugriff auf " "die Chronik im Indikator-Feld ermöglicht." #: ../data/appstream/org.gnome.GPaste.Ui.appdata.xml.in.h:1 #: ../data/desktop/org.gnome.GPaste.Ui.desktop.in.in.h:1 msgid "Manage your clipboard history" msgstr "" #: ../data/appstream/org.gnome.GPaste.Ui.appdata.xml.in.h:3 #, fuzzy msgid "" "GPaste provides you with a graphical tool allowing you to manage everything " "easily." msgstr "" "GPaste stellt ein Einstellungswerkzeug bereit, das es ermöglicht sein " "Verhalten nach den eigenen Vorstellungen anzupassen." #: ../data/desktop/org.gnome.GPaste.Applet.desktop.in.in.h:3 #: ../data/desktop/org.gnome.GPaste.AppIndicator.desktop.in.in.h:3 msgid "Clipboard;Manager;" msgstr "" #: ../data/desktop/org.gnome.GPaste.Ui.desktop.in.in.h:2 msgid "Clipboard;Manager;Settings;Preferences;Configuration;" msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:1 msgid "Max size of an element when displaying it" msgstr "Maximale Größe des anzuzeigenden Eintrages" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:2 msgid "" "The extra stuff of that element will be replaced by \"…\", and newlines by " "\" \" when displaying from the applet, 0 to disable." msgstr "" "Die zusätzlichen Dinge dieses Elementes werden durch \"…\" ersetzt. Das " "Aplet stellt Zeilenumbüche als \" \" dar. 0 schaltet das Verhalten ab." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:3 msgid "Do we detect and replace growing lines in history?" msgstr "Werden länger werdende Zeilen in der Chronik entdeckt und ersetzt?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:4 msgid "" "By default, selecting \"Here is\", then \"Here is an example\" will create " "two entries in the history. With this feature enabled, the first one will be " "replaced by the second one." msgstr "" "In der Standardeinstellung ergeben \"Dies ist\" und danach \"Dies ist ein " "Beispiel\" zwei Einträge in der Chronik. Wenn diese Einstellung aktiviert " "ist, wird der erste Eintrag durch den zweiten ersetzt." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:5 msgid "The name of the current history" msgstr "Name der Aktuellen Chronik" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:6 msgid "The default name is \"history\"" msgstr "Der Standard-Name lautet \"history\"" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:7 msgid "Do we save the images copied to history, or only text?" msgstr "Werden auch Bilder oder nur Text in die Chronik kopiert?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:8 msgid "By default, we're saving both" msgstr "Standardmäßig wird beides gespeichert." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:9 #, fuzzy msgid "The keyboard shortcut to launch the graphical interface" msgstr "Tastenkürzel um Menüleisten zu öffnen" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:10 #, fuzzy msgid "" "By default, hitting ctrl + alt + g does that (\"<Ctrl><Alt>G\"). " "An empty string here disables this functionnality." msgstr "" "Die Vorgabe ist Strg + Alt + v (\"<Strg><Alt>V\"). Ein leeres " "Feld schaltet diese Funktion ab." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:11 #, fuzzy msgid "The keyboard shortcut to mark the active item as being a password" msgstr "Tastenkürzel um den ersten Eintrag in der Chronik zu löschen" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:12 #, fuzzy msgid "" "By default, hitting ctrl + alt + s will mark the active item as being a " "password (\"<Ctrl><Alt>S\"). An empty string here disables this " "functionnality." msgstr "" "Standardmäßig wird das Menü durch Strg + Alt - h (\"<Strg><Alt>H" "\") angezeigt. Ein leeres Feld schaltet diese Funktion ab." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:13 msgid "Max displayed history size" msgstr "Anzahl der anzuzeigenden Einträge" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:14 msgid "Maximum number of items displayed in the history" msgstr "Die maximale Anzahl der anzuzeigenden Einträge in der Chronik" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:15 msgid "Max history size" msgstr "Maximale Größe der Chronik" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:16 msgid "Maximum number of items in history" msgstr "Maximale Anzahl der Einträge in der Chronik" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:17 msgid "Max memory usage (MB)" msgstr "Maximal zugewiesener Speicher (MB)" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:18 msgid "Maximum amount of memory used to store contents" msgstr "Maximaler Speicherverbrauch für Inhalte" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:19 msgid "Max text item size" msgstr "Maximale Textlänge" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:20 msgid "Maximum size of a text item. Anything out of this boundary is ignored." msgstr "Maximale Textlänge. Alles außerhalb dieses Wertes wird ignoriert." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:21 msgid "Min text item size" msgstr "Minimale Textlänge" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:22 msgid "Minimum size of a text item. Anything out of this boundary is ignored." msgstr "Minimale Textlänge. Alles außerhalb dieses Wertes wird ignoriert." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:23 msgid "The keyboard shortcut to delete the first element in history" msgstr "Tastenkürzel um den ersten Eintrag in der Chronik zu löschen" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:24 msgid "" "By default, hitting ctrl + alt + v does that (\"<Ctrl><Alt>V\"). " "An empty string here disables this functionnality." msgstr "" "Die Vorgabe ist Strg + Alt + v (\"<Strg><Alt>V\"). Ein leeres " "Feld schaltet diese Funktion ab." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:25 msgid "Does the primary selection affects history?" msgstr "Beeinflusst die Auswahl die Chronik?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:26 msgid "By default, only clipboard (ctrl+c) affects history." msgstr "Standardmäßig beinflusst nur die Zwischenablage (Strg+c) die Chronik" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:27 msgid "Do we save the history from one session to another?" msgstr "Wird die Chronik von einer Sitzung zur anderen gespeichert?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:28 msgid "By default, we're saving it" msgstr "Der Standard ist ja." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:29 msgid "The keyboard shortcut to display the menu" msgstr "Tastenkürzel um Menüleisten zu öffnen" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:30 msgid "" "By default, hitting ctrl + alt + h displays the menu (\"<Ctrl><" "Alt>H\"). An empty string here disables this functionnality." msgstr "" "Standardmäßig wird das Menü durch Strg + Alt - h (\"<Strg><Alt>H" "\") angezeigt. Ein leeres Feld schaltet diese Funktion ab." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:31 msgid "The keyboard shortcut to sync the clipboard to the primary selection" msgstr "Tastenkürzel um Zwischenablage mit der Auswahl synchronisieren" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:32 msgid "" "By default, hitting ctrl + alt + o syncs them (\"<Ctrl><Alt>P" "\"). An empty string here disables this functionnality." msgstr "" "Die Vorgabe ist Strg + Alt + o (\"<Strg><Alt>O\"). Ein leeres " "Feld schaltet diese Funktion ab." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:33 msgid "The keyboard shortcut to sync the primary selection to the clipboard" msgstr "Tastenkürzel um Auswahl mit der Zwischenablage synchronisieren:" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:34 msgid "" "By default, hitting ctrl + alt + p syncs them (\"<Ctrl><Alt>P" "\"). An empty string here disables this functionnality." msgstr "" "Die Vorgabe ist Strg + Alt + p (\"<Strg><Alt>P\"). Ein leeres " "Feld schaltet diese Funktion ab." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:35 msgid "Are the primary selection and the clipboard synchronized?" msgstr "ist die Auswahl und die Zwischenablage synchron?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:36 msgid "By default, the primary selection and the clipboard are independent." msgstr "" "Standardmäßig ist die Auswahl und die Zwischenablage unabhängig voneinander." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:37 msgid "Do we track the clipboard changes?" msgstr "Werden Änderungen an der Zwischenablage verfolgt?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:38 msgid "By default, we're tracking those changes." msgstr "Standardmäßig werden sie verfolgt." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:39 msgid "" "Do we sync the daemon state with the gnome-shell extension's one? (disable " "the daemon when disabling the extension)" msgstr "" "Wird der Zustand des Daemons mit der gnome-shell-extension synchronisiert? " "(Daemon wird zusammen mit der Erweiterung beendet)" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:40 msgid "By default, the daemon state keeps unchanged" msgstr "Standardmäßig bleibt der Daemon unberührt." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:41 msgid "Do we trim the textual items before adding them to history?" msgstr "Werden Texte getrimmt, bevor sie in die Chronik aufgenommen werden?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:42 msgid "" "Trimming means removing all trailing and ending spaces. By default, we're " "letting them as-is." msgstr "" "Trimmen bedeutet das Entfernen von Leerzeichen am Anfang und Ende. " "Standardmäßig werden sie so belassen wie sie sind." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:43 #, fuzzy msgid "" "The keyboard shortcut to upload the first element in history to a pastebin " "service" msgstr "Tastenkürzel um den ersten Eintrag in der Chronik zu löschen" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:44 #, fuzzy msgid "" "By default, hitting ctrl + alt + u does that (\"<Ctrl><Alt>U\"). " "An empty string here disables this functionnality." msgstr "" "Die Vorgabe ist Strg + Alt + v (\"<Strg><Alt>V\"). Ein leeres " "Feld schaltet diese Funktion ab." #~ msgid "Signal %d received, exiting\n" #~ msgstr "Signal %d wurde empfangen. Programm wird beendet\n" #~ msgid "Empty history" #~ msgstr "Chronik leeren" #~ msgid "Backup history as: " #~ msgstr "Aktuelle Chronik sichern als:" #~ msgid "Ok" #~ msgstr "OK" #~ msgid "Histories" #~ msgstr "Chroniken" #~ msgid "Could not register DBus service." #~ msgstr "DBus-Service konnte nicht registriert werden." #, fuzzy #~ msgid "Manage GPaste" #~ msgstr "GPaste-Daemon-Einstellungen" #~ msgid "GPaste daemon settings" #~ msgstr "GPaste-Daemon-Einstellungen" #~ msgid "Manage GPaste settings" #~ msgstr "GPaste-Daemon-Einstellungen" #~ msgid "" #~ "GPaste provides you with a settings utility allowing you to customize its " #~ "behaviour as expected." #~ msgstr "" #~ "GPaste stellt ein Einstellungswerkzeug bereit, das es ermöglicht sein " #~ "Verhalten nach den eigenen Vorstellungen anzupassen." #~ msgid "Manage the GPaste daemon settings" #~ msgstr "GPaste-Daemon-Einstellungen" #, fuzzy #~ msgid "Stop tracking changes" #~ msgstr "Stoppt die Verfolgung von Änderungen an der Zwischenablage" #~ msgid "Track changes" #~ msgstr "Änderungen überwachen" #, fuzzy #~ msgid "print the history without newlines" #~ msgstr "Chronik mit Index anzeigen" #, fuzzy #~ msgid "print the history (raw) without indexes" #~ msgstr "Chronik ohne Index anzeigen" #~ msgid "print the history with NUL as separator" #~ msgstr "Zeige Chronik mit NUL als Trennzeichen" #, fuzzy #~ msgid "get the th item from the history (raw)" #~ msgstr "Hole den ten Eintrag aus der Chronik" #~ msgid "Couldn't spawn gpaste-app-indicator.\n" #~ msgstr "GPaste-Applet konnte nicht gestartet werden.\n" GPaste-3.18.6/po/es.po000066400000000000000000000732771305131721400143760ustar00rootroot00000000000000# Spanish translations for GPaste package. # Copyright (C) 2011-2015 Listed translators # This file is distributed under the same license as the GPaste package. # Antonio Trujillo , 2011. # msgid "" msgstr "" "Project-Id-Version: GPaste\n" "Report-Msgid-Bugs-To: Marc-Antoine@Perennou.com\n" "POT-Creation-Date: 2017-02-16 13:43+0100\n" "PO-Revision-Date: 2011-11-20 16:30+0100\n" "Last-Translator: Antonio Trujillo \n" "Language-Team: Spanish\n" "Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../src/libgpaste/gpaste-macros.h:63 msgid "Failed to register the gtk application" msgstr "Fallo al registrar la aplicación gtk" #: ../src/libgpaste/applet/gpaste-applet.c:156 #: ../src/libgpaste/applet/gpaste-applet.c:184 msgid "is not installed" msgstr "" #: ../src/libgpaste/applet/gpaste-applet-about.c:81 #: ../src/libgpaste/ui/gpaste-ui-about.c:52 msgid "About" msgstr "" #: ../src/libgpaste/applet/gpaste-applet-quit.c:70 msgid "Quit" msgstr "Salir" #. Translators: help for gpaste ui #: ../src/libgpaste/applet/gpaste-applet-ui.c:61 #: ../src/gpaste-client/gpaste-client.c:83 #, fuzzy msgid "launch the graphical tool" msgstr "iniciar la herramienta de configuración" #: ../src/libgpaste/core/gpaste-history.c:773 msgid "Could not create history dir" msgstr "No se pudo crear directorio de historial" #. This is the date format "month/day/year time" #: ../src/libgpaste/core/gpaste-image-item.c:235 msgid "%m/%d/%y %T" msgstr "%d/%m/%y %T" #. This gets displayed in history when selecting an image #: ../src/libgpaste/core/gpaste-image-item.c:237 #, c-format msgid "[Image, %d x %d (%s)]" msgstr "[Imagen, %d x %d (%s)]" #. This is the prefix displayed in history to identify a password #: ../src/libgpaste/core/gpaste-password-item.c:82 msgid "Password" msgstr "" #. This is the prefix displayed in history to identify selected files #: ../src/libgpaste/core/gpaste-uris-item.c:117 msgid "[Files] " msgstr "[Ficheros] " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:126 #: ../src/libgpaste/ui/gpaste-ui-switch.c:96 msgid "Track clipboard changes" msgstr "Seguimiento de cambios en el portapapeles" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:133 msgid "Enable the gnome-shell extension" msgstr "" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:139 msgid "Sync the daemon state with the extension's one" msgstr "Sincronizar el estado del servicio con el de la _extensión" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:147 msgid "Primary selection affects history" msgstr "Selección principal afecta al historial" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:153 msgid "Synchronize clipboard with primary selection" msgstr "Sincronizar el portapapeles con selección principal" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:160 msgid "Images support" msgstr "" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:166 msgid "Trim items" msgstr "Recortar elementos" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:172 msgid "Detect growing lines" msgstr "" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:179 msgid "Save history" msgstr "Guardar historial" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:202 msgid "Max element size when displaying: " msgstr "Tamaño máximo de los elementos al visualizarlos: " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:209 msgid "Max displayed history size: " msgstr "Tamaño máximo a mostrar: " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:216 msgid "Max history size: " msgstr "Tamaño máximo del historial: " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:223 msgid "Max memory usage (MB): " msgstr "" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:230 msgid "Max text item length: " msgstr "Tamaño máximo de texto" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:237 msgid "Min text item length: " msgstr "Tamaño mínimo de texto" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:263 #: ../data/control-center/42-gpaste.xml.in.in.h:3 #, fuzzy msgid "Delete the active item from history: " msgstr "Eliminar el primer elemento del historial" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:270 #: ../data/control-center/42-gpaste.xml.in.in.h:1 #, fuzzy msgid "Launch the graphical tool: " msgstr "iniciar la herramienta de configuración" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:277 #: ../data/control-center/42-gpaste.xml.in.in.h:2 msgid "Mark the active item as being a password: " msgstr "" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:284 #: ../data/control-center/42-gpaste.xml.in.in.h:4 msgid "Display the history: " msgstr "Mostrar el historial" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:291 #: ../data/control-center/42-gpaste.xml.in.in.h:5 msgid "Sync the clipboard to the primary selection: " msgstr "Sincronizar el portapapeles con selección principal: " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:298 #: ../data/control-center/42-gpaste.xml.in.in.h:6 msgid "Sync the primary selection to the clipboard: " msgstr "Sincronizar selección principal con el portapapeles: " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:305 #: ../data/control-center/42-gpaste.xml.in.in.h:7 #, fuzzy msgid "Upload the active item to a pastebin service: " msgstr "Eliminar el primer elemento del historial" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:320 #: ../src/libgpaste/ui/gpaste-ui-window.c:211 #: ../src/gpaste-client/gpaste-client.c:185 msgid "Couldn't connect to GPaste daemon" msgstr "No se pudo conectar al servicio GPaste" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:337 msgid "General behaviour" msgstr "Comportamiento general" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:338 msgid "History settings" msgstr "Ajustes del historial" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:339 msgid "Keyboard shortcuts" msgstr "Atajos de teclado " #. translators: This is the name of a multi-history management action #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:453 #: ../src/libgpaste/ui/gpaste-ui-panel.c:297 msgid "Switch to" msgstr "Cambiar a" #. translators: This is the name of a multi-history management action #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:458 #: ../src/libgpaste/ui/gpaste-ui-delete-item.c:62 #: ../src/libgpaste/ui/gpaste-ui-delete-history.c:37 #: ../src/libgpaste/ui/gpaste-ui-delete-history.c:74 msgid "Delete" msgstr "Suprimir" #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:47 #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:133 msgid "Backup" msgstr "Copia de seguridad" #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:48 #: ../src/libgpaste/ui/gpaste-ui-edit-item.c:56 #: ../src/libgpaste/util/gpaste-util.c:43 msgid "Cancel" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:51 msgid "Under which name do you want to backup this history?" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-delete-history.c:37 #, fuzzy msgid "Are you sure you want to delete this history?" msgstr "Atajo de teclado para eliminar la primera entrada del historial" #: ../src/libgpaste/ui/gpaste-ui-edit-item.c:55 #: ../src/libgpaste/ui/gpaste-ui-edit-item.c:126 msgid "Edit" msgstr "" #. Translators: this is the translation for emptying the history #: ../src/libgpaste/ui/gpaste-ui-empty-history.c:38 #: ../src/libgpaste/ui/gpaste-ui-empty-history.c:76 #, fuzzy msgid "Empty" msgstr "(Vacío)" #: ../src/libgpaste/ui/gpaste-ui-empty-history.c:38 msgid "Do you really want to empty the history?" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-empty-item.c:37 msgid "(Empty)" msgstr "(Vacío)" #: ../src/libgpaste/ui/gpaste-ui-reexec.c:42 msgid "Restart" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-reexec.c:42 #, fuzzy msgid "Do you really want to restart the daemon?" msgstr "detener seguimiento de cambios en el portapapeles" #: ../src/libgpaste/ui/gpaste-ui-reexec.c:66 msgid "Restart the daemon" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-search.c:37 msgid "Search" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-settings.c:42 #, fuzzy msgid "GPaste Settings" msgstr "Ajustes del servicio GPaste" #: ../src/libgpaste/ui/gpaste-ui-switch.c:60 msgid "Stop" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-switch.c:60 #, fuzzy msgid "Do you really want to stop tracking clipboard changes?" msgstr "detener seguimiento de cambios en el portapapeles" #: ../src/libgpaste/ui/gpaste-ui-upload-item.c:62 msgid "Upload" msgstr "" #: ../src/daemon/gpaste-daemon.c:47 msgid "Could not acquire DBus name." msgstr "No se pudo obtener nombre en DBus" #: ../src/gpaste-client/gpaste-client.c:31 #, c-format msgid "Usage:\n" msgstr "Modo de empleo:\n" #. Translators: help for gpaste history #: ../src/gpaste-client/gpaste-client.c:33 msgid "print the history with indexes" msgstr "imprimir el historial con números de indice" #. Translators: help for gpaste history-size #: ../src/gpaste-client/gpaste-client.c:35 #, fuzzy msgid "print the size of the history" msgstr "suprimir el elemento número del historial" #. Translators: help for gpaste get-history #: ../src/gpaste-client/gpaste-client.c:37 #, fuzzy msgid "get the name of the current history" msgstr "El nombre del historial actual" #. Translators: help for gpaste backup-history #. Translators: help for gpaste switch-history #. Translators: help for gpaste delete-history #. Translators: help for gpaste add-password #. Translators: help for gpaste delete-passworf #: ../src/gpaste-client/gpaste-client.c:39 #: ../src/gpaste-client/gpaste-client.c:41 #: ../src/gpaste-client/gpaste-client.c:43 #: ../src/gpaste-client/gpaste-client.c:49 #: ../src/gpaste-client/gpaste-client.c:61 #: ../src/gpaste-client/gpaste-client.c:65 msgid "name" msgstr "nombre" #: ../src/gpaste-client/gpaste-client.c:39 msgid "backup current history" msgstr "hacer copia de seguridad del historial actual" #: ../src/gpaste-client/gpaste-client.c:41 msgid "switch to another history" msgstr "cambiar a otro historial" #: ../src/gpaste-client/gpaste-client.c:43 msgid "delete a history" msgstr "suprimir el historial" #. Translators: help for gpaste list-histories #: ../src/gpaste-client/gpaste-client.c:45 msgid "list available histories" msgstr "listar historial disponible" #. Translators: help for gpaste add #: ../src/gpaste-client/gpaste-client.c:47 msgid "text" msgstr "texto" #: ../src/gpaste-client/gpaste-client.c:47 msgid "set text to clipboard" msgstr "enviar al portapapeles" #: ../src/gpaste-client/gpaste-client.c:49 msgid "password" msgstr "" #: ../src/gpaste-client/gpaste-client.c:49 #, fuzzy msgid "add the name - password couple to the clipboard" msgstr "Sincronizar selección principal con el portapapeles: " #. Translators: help for gpaste rename-password #: ../src/gpaste-client/gpaste-client.c:51 #, fuzzy msgid "old name" msgstr "nombre" #: ../src/gpaste-client/gpaste-client.c:51 #, fuzzy msgid "new name" msgstr "nombre" #: ../src/gpaste-client/gpaste-client.c:51 msgid "rename the password" msgstr "" #. Translators: help for gpaste get #. Translators: help for gpaste select #. Translators: help for gpaste replace #. Translators: help for gpaste merge #. Translators: help for gpaste set-password #. Translators: help for gpaste delete #. Translators: help for gpaste upload #: ../src/gpaste-client/gpaste-client.c:53 #: ../src/gpaste-client/gpaste-client.c:55 #: ../src/gpaste-client/gpaste-client.c:57 #: ../src/gpaste-client/gpaste-client.c:59 #: ../src/gpaste-client/gpaste-client.c:61 #: ../src/gpaste-client/gpaste-client.c:63 #: ../src/gpaste-client/gpaste-client.c:97 msgid "number" msgstr "número" #: ../src/gpaste-client/gpaste-client.c:53 msgid "get the th item from the history" msgstr "obtener el elemento número del historial del portapapeles" #: ../src/gpaste-client/gpaste-client.c:55 msgid "set the th item from the history to the clipboard" msgstr "enviar el elemento número del historial al portapapeles" #: ../src/gpaste-client/gpaste-client.c:57 msgid "contents" msgstr "" #: ../src/gpaste-client/gpaste-client.c:57 #, fuzzy msgid "" "replace the contents of the th item from the history with the " "provided one" msgstr "enviar el elemento número del historial al portapapeles" #: ../src/gpaste-client/gpaste-client.c:59 #, fuzzy msgid "" "merge the th items from the history and add put the result in the " "clipboard" msgstr "enviar el elemento número del historial al portapapeles" #: ../src/gpaste-client/gpaste-client.c:61 #, fuzzy msgid "set the th item from the history as a password named " msgstr "enviar el elemento número del historial al portapapeles" #: ../src/gpaste-client/gpaste-client.c:63 msgid "delete th item of the history" msgstr "suprimir el elemento número del historial" #: ../src/gpaste-client/gpaste-client.c:65 #, fuzzy msgid "delete the password from the history" msgstr "obtener el elemento número del historial del portapapeles" #. Translators: help for gpaste file #: ../src/gpaste-client/gpaste-client.c:67 msgid "path" msgstr "ruta" #: ../src/gpaste-client/gpaste-client.c:67 msgid "put the content of the file at into the clipboard" msgstr "" " colocar el contenido del fichero indicado por en el portapapeles" #. Translators: help for whatever | gpaste #: ../src/gpaste-client/gpaste-client.c:69 msgid "whatever" msgstr "loquesea" #: ../src/gpaste-client/gpaste-client.c:69 msgid "set the output of whatever to clipboard" msgstr "enviar la salida de al portapapeles" #. Translators: help for gpaste empty #: ../src/gpaste-client/gpaste-client.c:71 msgid "empty the history" msgstr "vaciar el historial" #. Translators: help for gpaste start #: ../src/gpaste-client/gpaste-client.c:73 msgid "start tracking clipboard changes" msgstr "iniciar seguimiento de cambios en el portapapeles" #. Translators: help for gpaste stop #: ../src/gpaste-client/gpaste-client.c:75 msgid "stop tracking clipboard changes" msgstr "detener seguimiento de cambios en el portapapeles" #. Translators: help for gpaste quit #: ../src/gpaste-client/gpaste-client.c:77 msgid "alias for stop" msgstr "quit: alias de stop" #. Translators: help for gpaste daemon-reexec #: ../src/gpaste-client/gpaste-client.c:79 msgid "reexecute the daemon (after upgrading...)" msgstr "vuelva a ejecutar el servicio (después de actualizar...)" #. Translators: help for gpaste settings #: ../src/gpaste-client/gpaste-client.c:81 msgid "launch the configuration tool" msgstr "iniciar la herramienta de configuración" #. Translators: help for gpaste applet #: ../src/gpaste-client/gpaste-client.c:87 msgid "launch the applet" msgstr "iniciar el applet" #. Translators: help for gpaste app-indicator #: ../src/gpaste-client/gpaste-client.c:92 #, fuzzy msgid "launch the unity application indicator" msgstr "iniciar la herramienta de configuración" #. Translators: help for gpaste show-history #: ../src/gpaste-client/gpaste-client.c:95 #, fuzzy msgid "make the applet or extension display the history" msgstr "Número máximo de elementos mostrados en el historial" #: ../src/gpaste-client/gpaste-client.c:97 #, fuzzy msgid "upload the th item to a pastebin service" msgstr "Eliminar el primer elemento del historial" #. Translators: help for gpaste version #: ../src/gpaste-client/gpaste-client.c:99 msgid "display the version" msgstr "mostrar la versión" #. Translators: help for gpaste daemon-version #: ../src/gpaste-client/gpaste-client.c:101 #, fuzzy msgid "display the daemon version" msgstr "mostrar la versión" #. Translators: help for gpaste help #: ../src/gpaste-client/gpaste-client.c:103 msgid "display this help" msgstr "mostrar esta ayuda" #. Translators: help for gpaste about #: ../src/gpaste-client/gpaste-client.c:105 #, fuzzy msgid "display the about dialog" msgstr "mostrar la versión" #: ../src/gpaste-client/gpaste-client.c:108 #, fuzzy, c-format msgid "Display options:" msgstr "Mostrar el historial" #. Translators: help for --oneline #: ../src/gpaste-client/gpaste-client.c:111 #, fuzzy msgid "display each item on only one line" msgstr "mostrar la versión" #. Translators: help for --oneline #: ../src/gpaste-client/gpaste-client.c:113 msgid "display each item raw (without line numbers)" msgstr "" #. Translators: help for --oneline #: ../src/gpaste-client/gpaste-client.c:115 msgid "use a NUL character instead of a new line betweean each item" msgstr "" #: ../src/gpaste-client/gpaste-client.c:118 #, fuzzy, c-format msgid "Merge options:" msgstr "Mostrar el historial" #. Translators: help for --decoration #. Translators: help for --separator #: ../src/gpaste-client/gpaste-client.c:121 #: ../src/gpaste-client/gpaste-client.c:123 msgid "string" msgstr "" #: ../src/gpaste-client/gpaste-client.c:121 msgid "" "add the given decoration to the beginning and the end of each item before " "merging" msgstr "" #: ../src/gpaste-client/gpaste-client.c:123 msgid "add the given separator between each item when merging" msgstr "" #: ../src/gpaste-client/gpaste-client.c:196 #: ../src/gpaste-client/gpaste-client.c:410 #, fuzzy msgid "Couldn't spawn" msgstr "No se pudo iniciar el applet de gpaste.\n" #: ../src/gpaste-client/gpaste-client.c:355 #, c-format msgid "Successfully reexecuted the daemon\n" msgstr "Servicio reiniciado con éxito\n" #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:1 #: ../data/desktop/org.gnome.GPaste.Applet.desktop.in.in.h:1 msgid "GPaste Applet" msgstr "Applet GPaste" #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:2 #: ../data/desktop/org.gnome.GPaste.Applet.desktop.in.in.h:2 msgid "Tray icon to manage GPaste" msgstr "Icono de notificación para GPaste" #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:3 #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:3 #: ../data/appstream/org.gnome.GPaste.Ui.appdata.xml.in.h:2 msgid "" "GPaste is a clipboard managing system allowing you to track and manage your " "clipboard history in a highly customizable way." msgstr "" #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:4 msgid "" "GPaste provides you with an applet, in the form of a status icon which will " "give you access to your history in your tray area." msgstr "" #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:1 #: ../data/desktop/org.gnome.GPaste.AppIndicator.desktop.in.in.h:1 #, fuzzy msgid "GPaste AppIndicator" msgstr "Applet GPaste" #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:2 #: ../data/desktop/org.gnome.GPaste.AppIndicator.desktop.in.in.h:2 #, fuzzy msgid "Unity application indicator to manage GPaste" msgstr "Icono de notificación para GPaste" #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:4 msgid "" "GPaste provides you with an application indicator for unity which will give " "you access to your history in your indicator area." msgstr "" #: ../data/appstream/org.gnome.GPaste.Ui.appdata.xml.in.h:1 #: ../data/desktop/org.gnome.GPaste.Ui.desktop.in.in.h:1 msgid "Manage your clipboard history" msgstr "" #: ../data/appstream/org.gnome.GPaste.Ui.appdata.xml.in.h:3 msgid "" "GPaste provides you with a graphical tool allowing you to manage everything " "easily." msgstr "" #: ../data/desktop/org.gnome.GPaste.Applet.desktop.in.in.h:3 #: ../data/desktop/org.gnome.GPaste.AppIndicator.desktop.in.in.h:3 msgid "Clipboard;Manager;" msgstr "" #: ../data/desktop/org.gnome.GPaste.Ui.desktop.in.in.h:2 msgid "Clipboard;Manager;Settings;Preferences;Configuration;" msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:1 msgid "Max size of an element when displaying it" msgstr "Tamaño máximo de un elemento al mostrarlo" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:2 msgid "" "The extra stuff of that element will be replaced by \"…\", and newlines by " "\" \" when displaying from the applet, 0 to disable." msgstr "" "La parte sobrante del elemento se reemplazará por \"…\",y los saltos de " "línea por \" \" cuando se muestren en el applet,0 para desactivar." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:3 msgid "Do we detect and replace growing lines in history?" msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:4 msgid "" "By default, selecting \"Here is\", then \"Here is an example\" will create " "two entries in the history. With this feature enabled, the first one will be " "replaced by the second one." msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:5 msgid "The name of the current history" msgstr "El nombre del historial actual" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:6 msgid "The default name is \"history\"" msgstr "El nombre por omision es \"history\"" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:7 msgid "Do we save the images copied to history, or only text?" msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:8 msgid "By default, we're saving both" msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:9 #, fuzzy msgid "The keyboard shortcut to launch the graphical interface" msgstr "Atajo de teclado para mostrar el menú" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:10 #, fuzzy msgid "" "By default, hitting ctrl + alt + g does that (\"<Ctrl><Alt>G\"). " "An empty string here disables this functionnality." msgstr "" "Por omisión, pulsando ctrl + alt + v (\"<Ctrl><Alt>v\"). Una " "cadena vacía desactivaría esta funcionalidad." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:11 #, fuzzy msgid "The keyboard shortcut to mark the active item as being a password" msgstr "Atajo de teclado para eliminar la primera entrada del historial" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:12 #, fuzzy msgid "" "By default, hitting ctrl + alt + s will mark the active item as being a " "password (\"<Ctrl><Alt>S\"). An empty string here disables this " "functionnality." msgstr "" "Por omisión, pulsando ctrl + alt + h muestra el menú (\"<Ctrl><" "Alt>H\"). Una cadena vacía desactivaría esta funcionalidad." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:13 msgid "Max displayed history size" msgstr "Tamaño máximo al mostrar" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:14 msgid "Maximum number of items displayed in the history" msgstr "Número máximo de elementos mostrados en el historial" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:15 msgid "Max history size" msgstr "Tamaño máximo del historial" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:16 msgid "Maximum number of items in history" msgstr "Número máximo de elementos en el historial" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:17 msgid "Max memory usage (MB)" msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:18 msgid "Maximum amount of memory used to store contents" msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:19 msgid "Max text item size" msgstr "Tamaño máximo de los elementos de texto" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:20 msgid "Maximum size of a text item. Anything out of this boundary is ignored." msgstr "" "Tamaño máxmimo de los elementos de texto. Se ignora lo que sobrepase este " "límite." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:21 msgid "Min text item size" msgstr "Tamaño mínimo de los elementos de texto" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:22 msgid "Minimum size of a text item. Anything out of this boundary is ignored." msgstr "" "Tamaño mínimo de los elementos de texto. Se ignora lo que no llegue a este " "límite." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:23 msgid "The keyboard shortcut to delete the first element in history" msgstr "Atajo de teclado para eliminar la primera entrada del historial" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:24 msgid "" "By default, hitting ctrl + alt + v does that (\"<Ctrl><Alt>V\"). " "An empty string here disables this functionnality." msgstr "" "Por omisión, pulsando ctrl + alt + v (\"<Ctrl><Alt>v\"). Una " "cadena vacía desactivaría esta funcionalidad." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:25 msgid "Does the primary selection affects history?" msgstr "¿Afecta la selección principal al historial?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:26 msgid "By default, only clipboard (ctrl+c) affects history." msgstr "Por omisión, solo el portapapeles (ctrl+c) afecta al historial." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:27 msgid "Do we save the history from one session to another?" msgstr "¿Se guarda el historial de una sesión a otra?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:28 msgid "By default, we're saving it" msgstr "Por omisión se guarda" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:29 msgid "The keyboard shortcut to display the menu" msgstr "Atajo de teclado para mostrar el menú" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:30 msgid "" "By default, hitting ctrl + alt + h displays the menu (\"<Ctrl><" "Alt>H\"). An empty string here disables this functionnality." msgstr "" "Por omisión, pulsando ctrl + alt + h muestra el menú (\"<Ctrl><" "Alt>H\"). Una cadena vacía desactivaría esta funcionalidad." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:31 msgid "The keyboard shortcut to sync the clipboard to the primary selection" msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:32 msgid "" "By default, hitting ctrl + alt + o syncs them (\"<Ctrl><Alt>P" "\"). An empty string here disables this functionnality." msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:33 msgid "The keyboard shortcut to sync the primary selection to the clipboard" msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:34 msgid "" "By default, hitting ctrl + alt + p syncs them (\"<Ctrl><Alt>P" "\"). An empty string here disables this functionnality." msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:35 msgid "Are the primary selection and the clipboard synchronized?" msgstr "¿Están sincronizadas la selección principal y el portapapeles?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:36 msgid "By default, the primary selection and the clipboard are independent." msgstr "" "Por omisión, la selección principal y el portapapeles son independientes." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:37 msgid "Do we track the clipboard changes?" msgstr "¿Seguir los cambios en el portapapeles?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:38 msgid "By default, we're tracking those changes." msgstr "Por omisión, se siguen esos cambios." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:39 msgid "" "Do we sync the daemon state with the gnome-shell extension's one? (disable " "the daemon when disabling the extension)" msgstr "" "¿Sincronizar el estado del servicio con el de la extension? (deshabilitarel " "servicio cuando se deshabilite la extension)" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:40 msgid "By default, the daemon state keeps unchanged" msgstr "Por omisión, el estado del servicio se mantiene sin cambios." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:41 msgid "Do we trim the textual items before adding them to history?" msgstr "¿Recortar elementos de texto antes de añadirlos al historial" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:42 msgid "" "Trimming means removing all trailing and ending spaces. By default, we're " "letting them as-is." msgstr "" "Recortar quiere decir eliminar los espacios antes del inicio y después del " "final. Por omision se dejan como están" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:43 #, fuzzy msgid "" "The keyboard shortcut to upload the first element in history to a pastebin " "service" msgstr "Atajo de teclado para eliminar la primera entrada del historial" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:44 #, fuzzy msgid "" "By default, hitting ctrl + alt + u does that (\"<Ctrl><Alt>U\"). " "An empty string here disables this functionnality." msgstr "" "Por omisión, pulsando ctrl + alt + v (\"<Ctrl><Alt>v\"). Una " "cadena vacía desactivaría esta funcionalidad." #~ msgid "Signal %d received, exiting\n" #~ msgstr "Recibida señal %d, saliendo\n" #~ msgid "Empty history" #~ msgstr "Vaciar historial" #~ msgid "Backup history as: " #~ msgstr "Respaldar historial como: " #~ msgid "Ok" #~ msgstr "Ok" #~ msgid "Histories" #~ msgstr "Histórico" #~ msgid "Could not register DBus service." #~ msgstr "No se pudo registrar el servicio DBus" #, fuzzy #~ msgid "Manage GPaste" #~ msgstr "Gestionar los ajustes del servicio GPaste" #~ msgid "GPaste daemon settings" #~ msgstr "Ajustes del servicio GPaste" #, fuzzy #~ msgid "Manage GPaste settings" #~ msgstr "Gestionar los ajustes del servicio GPaste" #~ msgid "Manage the GPaste daemon settings" #~ msgstr "Gestionar los ajustes del servicio GPaste" #, fuzzy #~ msgid "Stop tracking changes" #~ msgstr "detener seguimiento de cambios en el portapapeles" #~ msgid "Track changes" #~ msgstr "Seguimiento de cambios" #, fuzzy #~ msgid "print the history without newlines" #~ msgstr "imprimir el historial con números de indice" #, fuzzy #~ msgid "print the history (raw) without indexes" #~ msgstr "imprimir el historial sin índices" #~ msgid "print the history with NUL as separator" #~ msgstr "imprimir el historial con NUL como separador" #, fuzzy #~ msgid "get the th item from the history (raw)" #~ msgstr "obtener el elemento número del historial del portapapeles" #, fuzzy #~ msgid "Couldn't spawn gpaste-app-indicator.\n" #~ msgstr "No se pudo iniciar el applet de gpaste.\n" GPaste-3.18.6/po/fi.po000066400000000000000000000721001305131721400143450ustar00rootroot00000000000000# Spanish translations for GPaste package. # Copyright (C) 2011-2015 Listed translators # This file is distributed under the same license as the GPaste package. # Jesse Jaara # msgid "" msgstr "" "Project-Id-Version: GPaste\n" "Report-Msgid-Bugs-To: Marc-Antoine@Perennou.com\n" "POT-Creation-Date: 2017-02-16 13:43+0100\n" "PO-Revision-Date: 2012-08-28 20:52+0200\n" "Last-Translator: Jesse Jaara \n" "Language-Team: \n" "Language: fi_FI\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../src/libgpaste/gpaste-macros.h:63 msgid "Failed to register the gtk application" msgstr "Gtk-ohjelman rekisteröiminen epäonnistui" #: ../src/libgpaste/applet/gpaste-applet.c:156 #: ../src/libgpaste/applet/gpaste-applet.c:184 msgid "is not installed" msgstr "" #: ../src/libgpaste/applet/gpaste-applet-about.c:81 #: ../src/libgpaste/ui/gpaste-ui-about.c:52 msgid "About" msgstr "" #: ../src/libgpaste/applet/gpaste-applet-quit.c:70 msgid "Quit" msgstr "Lopeta" #. Translators: help for gpaste ui #: ../src/libgpaste/applet/gpaste-applet-ui.c:61 #: ../src/gpaste-client/gpaste-client.c:83 #, fuzzy msgid "launch the graphical tool" msgstr "käynnistää asetusten hallinan" #: ../src/libgpaste/core/gpaste-history.c:773 msgid "Could not create history dir" msgstr "Historiakansion luominen epäonnistui" #. This is the date format "month/day/year time" #: ../src/libgpaste/core/gpaste-image-item.c:235 msgid "%m/%d/%y %T" msgstr "%m/%d/%y %T" #. This gets displayed in history when selecting an image #: ../src/libgpaste/core/gpaste-image-item.c:237 #, c-format msgid "[Image, %d x %d (%s)]" msgstr "[Kuva, %d x %d (%s)]" #. This is the prefix displayed in history to identify a password #: ../src/libgpaste/core/gpaste-password-item.c:82 msgid "Password" msgstr "" #. This is the prefix displayed in history to identify selected files #: ../src/libgpaste/core/gpaste-uris-item.c:117 msgid "[Files] " msgstr "[Tiedostot]" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:126 #: ../src/libgpaste/ui/gpaste-ui-switch.c:96 msgid "Track clipboard changes" msgstr "Pidä kirjaa leikepöydän tapahtumista" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:133 msgid "Enable the gnome-shell extension" msgstr "" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:139 msgid "Sync the daemon state with the extension's one" msgstr "Synkronoi palvelun ja liitännäisen tilat" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:147 msgid "Primary selection affects history" msgstr "Maalaminen vaikuttaa historiaan" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:153 msgid "Synchronize clipboard with primary selection" msgstr "Synkronoi leikepöytä ja maalaaminen" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:160 msgid "Images support" msgstr "" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:166 msgid "Trim items" msgstr "Trimmaa leikkeet" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:172 msgid "Detect growing lines" msgstr "" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:179 msgid "Save history" msgstr "Tallenna historia" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:202 msgid "Max element size when displaying: " msgstr "Suurin koko elementtejä näytettäessä:" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:209 msgid "Max displayed history size: " msgstr "Historian suurin koko:" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:216 msgid "Max history size: " msgstr "Historian suurin koko:" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:223 msgid "Max memory usage (MB): " msgstr "" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:230 msgid "Max text item length: " msgstr "Pisin sallittu tekstileikkeen pituus:" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:237 msgid "Min text item length: " msgstr "Lyhin sallittu tekstileikkeen pituus:" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:263 #: ../data/control-center/42-gpaste.xml.in.in.h:3 #, fuzzy msgid "Delete the active item from history: " msgstr "noutaa määritellyn leikkeen historiasta" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:270 #: ../data/control-center/42-gpaste.xml.in.in.h:1 #, fuzzy msgid "Launch the graphical tool: " msgstr "käynnistää asetusten hallinan" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:277 #: ../data/control-center/42-gpaste.xml.in.in.h:2 msgid "Mark the active item as being a password: " msgstr "" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:284 #: ../data/control-center/42-gpaste.xml.in.in.h:4 msgid "Display the history: " msgstr "Näytä historia:" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:291 #: ../data/control-center/42-gpaste.xml.in.in.h:5 msgid "Sync the clipboard to the primary selection: " msgstr "" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:298 #: ../data/control-center/42-gpaste.xml.in.in.h:6 msgid "Sync the primary selection to the clipboard: " msgstr "" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:305 #: ../data/control-center/42-gpaste.xml.in.in.h:7 #, fuzzy msgid "Upload the active item to a pastebin service: " msgstr "noutaa määritellyn leikkeen historiasta" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:320 #: ../src/libgpaste/ui/gpaste-ui-window.c:211 #: ../src/gpaste-client/gpaste-client.c:185 msgid "Couldn't connect to GPaste daemon" msgstr "GPaste-palveluun ei saatu yhteyttä" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:337 msgid "General behaviour" msgstr "Yleiset ominaisuudet" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:338 msgid "History settings" msgstr "Historian asetukset" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:339 msgid "Keyboard shortcuts" msgstr "Pikanäppäimet" #. translators: This is the name of a multi-history management action #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:453 #: ../src/libgpaste/ui/gpaste-ui-panel.c:297 msgid "Switch to" msgstr "Vaihda kohteeseen" #. translators: This is the name of a multi-history management action #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:458 #: ../src/libgpaste/ui/gpaste-ui-delete-item.c:62 #: ../src/libgpaste/ui/gpaste-ui-delete-history.c:37 #: ../src/libgpaste/ui/gpaste-ui-delete-history.c:74 msgid "Delete" msgstr "Poista" #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:47 #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:133 msgid "Backup" msgstr "Varmuuskopioi" #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:48 #: ../src/libgpaste/ui/gpaste-ui-edit-item.c:56 #: ../src/libgpaste/util/gpaste-util.c:43 msgid "Cancel" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:51 msgid "Under which name do you want to backup this history?" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-delete-history.c:37 msgid "Are you sure you want to delete this history?" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-edit-item.c:55 #: ../src/libgpaste/ui/gpaste-ui-edit-item.c:126 msgid "Edit" msgstr "" #. Translators: this is the translation for emptying the history #: ../src/libgpaste/ui/gpaste-ui-empty-history.c:38 #: ../src/libgpaste/ui/gpaste-ui-empty-history.c:76 #, fuzzy msgid "Empty" msgstr "(Tyhjä)" #: ../src/libgpaste/ui/gpaste-ui-empty-history.c:38 msgid "Do you really want to empty the history?" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-empty-item.c:37 msgid "(Empty)" msgstr "(Tyhjä)" #: ../src/libgpaste/ui/gpaste-ui-reexec.c:42 msgid "Restart" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-reexec.c:42 #, fuzzy msgid "Do you really want to restart the daemon?" msgstr "lopettaa leikepöydän muutosten seuraamisen" #: ../src/libgpaste/ui/gpaste-ui-reexec.c:66 msgid "Restart the daemon" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-search.c:37 msgid "Search" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-settings.c:42 #, fuzzy msgid "GPaste Settings" msgstr "GPaste palvelun asetukset" #: ../src/libgpaste/ui/gpaste-ui-switch.c:60 msgid "Stop" msgstr "" #: ../src/libgpaste/ui/gpaste-ui-switch.c:60 #, fuzzy msgid "Do you really want to stop tracking clipboard changes?" msgstr "lopettaa leikepöydän muutosten seuraamisen" #: ../src/libgpaste/ui/gpaste-ui-upload-item.c:62 msgid "Upload" msgstr "" #: ../src/daemon/gpaste-daemon.c:47 msgid "Could not acquire DBus name." msgstr "DBus-nimen selvitys epäonnistui." #: ../src/gpaste-client/gpaste-client.c:31 #, c-format msgid "Usage:\n" msgstr "Käyttö:\n" #. Translators: help for gpaste history #: ../src/gpaste-client/gpaste-client.c:33 msgid "print the history with indexes" msgstr "listaa historian indeksöitynä" #. Translators: help for gpaste history-size #: ../src/gpaste-client/gpaste-client.c:35 #, fuzzy msgid "print the size of the history" msgstr "poistaa määritellyn leikkeen historiasta" #. Translators: help for gpaste get-history #: ../src/gpaste-client/gpaste-client.c:37 #, fuzzy msgid "get the name of the current history" msgstr "Nykyisen historian nimi" #. Translators: help for gpaste backup-history #. Translators: help for gpaste switch-history #. Translators: help for gpaste delete-history #. Translators: help for gpaste add-password #. Translators: help for gpaste delete-passworf #: ../src/gpaste-client/gpaste-client.c:39 #: ../src/gpaste-client/gpaste-client.c:41 #: ../src/gpaste-client/gpaste-client.c:43 #: ../src/gpaste-client/gpaste-client.c:49 #: ../src/gpaste-client/gpaste-client.c:61 #: ../src/gpaste-client/gpaste-client.c:65 msgid "name" msgstr "nimi" #: ../src/gpaste-client/gpaste-client.c:39 msgid "backup current history" msgstr "varmuuskopioi nykyinen historia" #: ../src/gpaste-client/gpaste-client.c:41 msgid "switch to another history" msgstr "vaihda toiseen historiaan" #: ../src/gpaste-client/gpaste-client.c:43 msgid "delete a history" msgstr "poistaa määritellyn historian" #. Translators: help for gpaste list-histories #: ../src/gpaste-client/gpaste-client.c:45 msgid "list available histories" msgstr "antaa listan saatavilla olevista historioista" #. Translators: help for gpaste add #: ../src/gpaste-client/gpaste-client.c:47 msgid "text" msgstr "teskti" #: ../src/gpaste-client/gpaste-client.c:47 msgid "set text to clipboard" msgstr "asettaa leikkeen sisällön" #: ../src/gpaste-client/gpaste-client.c:49 msgid "password" msgstr "" #: ../src/gpaste-client/gpaste-client.c:49 msgid "add the name - password couple to the clipboard" msgstr "" #. Translators: help for gpaste rename-password #: ../src/gpaste-client/gpaste-client.c:51 #, fuzzy msgid "old name" msgstr "nimi" #: ../src/gpaste-client/gpaste-client.c:51 #, fuzzy msgid "new name" msgstr "nimi" #: ../src/gpaste-client/gpaste-client.c:51 msgid "rename the password" msgstr "" #. Translators: help for gpaste get #. Translators: help for gpaste select #. Translators: help for gpaste replace #. Translators: help for gpaste merge #. Translators: help for gpaste set-password #. Translators: help for gpaste delete #. Translators: help for gpaste upload #: ../src/gpaste-client/gpaste-client.c:53 #: ../src/gpaste-client/gpaste-client.c:55 #: ../src/gpaste-client/gpaste-client.c:57 #: ../src/gpaste-client/gpaste-client.c:59 #: ../src/gpaste-client/gpaste-client.c:61 #: ../src/gpaste-client/gpaste-client.c:63 #: ../src/gpaste-client/gpaste-client.c:97 msgid "number" msgstr "luku" #: ../src/gpaste-client/gpaste-client.c:53 msgid "get the th item from the history" msgstr "noutaa määritellyn leikkeen historiasta" #: ../src/gpaste-client/gpaste-client.c:55 msgid "set the th item from the history to the clipboard" msgstr "kopioi määrritellyn kohteen historiasta leikepöydälle" #: ../src/gpaste-client/gpaste-client.c:57 msgid "contents" msgstr "" #: ../src/gpaste-client/gpaste-client.c:57 #, fuzzy msgid "" "replace the contents of the th item from the history with the " "provided one" msgstr "kopioi määrritellyn kohteen historiasta leikepöydälle" #: ../src/gpaste-client/gpaste-client.c:59 #, fuzzy msgid "" "merge the th items from the history and add put the result in the " "clipboard" msgstr "kopioi määrritellyn kohteen historiasta leikepöydälle" #: ../src/gpaste-client/gpaste-client.c:61 #, fuzzy msgid "set the th item from the history as a password named " msgstr "kopioi määrritellyn kohteen historiasta leikepöydälle" #: ../src/gpaste-client/gpaste-client.c:63 msgid "delete th item of the history" msgstr "poistaa määritellyn leikkeen historiasta" #: ../src/gpaste-client/gpaste-client.c:65 #, fuzzy msgid "delete the password from the history" msgstr "noutaa määritellyn leikkeen historiasta" #. Translators: help for gpaste file #: ../src/gpaste-client/gpaste-client.c:67 msgid "path" msgstr "tiedosto" #: ../src/gpaste-client/gpaste-client.c:67 msgid "put the content of the file at into the clipboard" msgstr "kopioi tiedoston sisällön leikepöydälle" #. Translators: help for whatever | gpaste #: ../src/gpaste-client/gpaste-client.c:69 msgid "whatever" msgstr "mitävaan" #: ../src/gpaste-client/gpaste-client.c:69 msgid "set the output of whatever to clipboard" msgstr "asettaa putkitetun sisälllön leikepöydälle" #. Translators: help for gpaste empty #: ../src/gpaste-client/gpaste-client.c:71 msgid "empty the history" msgstr "tyhjentää historian" #. Translators: help for gpaste start #: ../src/gpaste-client/gpaste-client.c:73 msgid "start tracking clipboard changes" msgstr "aloittaa leikepöydän muutosten seuraamisen" #. Translators: help for gpaste stop #: ../src/gpaste-client/gpaste-client.c:75 msgid "stop tracking clipboard changes" msgstr "lopettaa leikepöydän muutosten seuraamisen" #. Translators: help for gpaste quit #: ../src/gpaste-client/gpaste-client.c:77 msgid "alias for stop" msgstr "sama kuin stop" #. Translators: help for gpaste daemon-reexec #: ../src/gpaste-client/gpaste-client.c:79 msgid "reexecute the daemon (after upgrading...)" msgstr "käynnistää palvelun uudelleen (päivittämisen jälkeen...)" #. Translators: help for gpaste settings #: ../src/gpaste-client/gpaste-client.c:81 msgid "launch the configuration tool" msgstr "käynnistää asetusten hallinan" #. Translators: help for gpaste applet #: ../src/gpaste-client/gpaste-client.c:87 msgid "launch the applet" msgstr "käynnistää härpäkkeen" #. Translators: help for gpaste app-indicator #: ../src/gpaste-client/gpaste-client.c:92 #, fuzzy msgid "launch the unity application indicator" msgstr "käynnistää asetusten hallinan" #. Translators: help for gpaste show-history #: ../src/gpaste-client/gpaste-client.c:95 #, fuzzy msgid "make the applet or extension display the history" msgstr "Suurin määrä historiassa näkyviä leikkeitä" #: ../src/gpaste-client/gpaste-client.c:97 #, fuzzy msgid "upload the th item to a pastebin service" msgstr "noutaa määritellyn leikkeen historiasta" #. Translators: help for gpaste version #: ../src/gpaste-client/gpaste-client.c:99 msgid "display the version" msgstr "tulostaa ohjelman version" #. Translators: help for gpaste daemon-version #: ../src/gpaste-client/gpaste-client.c:101 #, fuzzy msgid "display the daemon version" msgstr "tulostaa ohjelman version" #. Translators: help for gpaste help #: ../src/gpaste-client/gpaste-client.c:103 msgid "display this help" msgstr "tulostaa tämän ohjeen" #. Translators: help for gpaste about #: ../src/gpaste-client/gpaste-client.c:105 #, fuzzy msgid "display the about dialog" msgstr "tulostaa ohjelman version" #: ../src/gpaste-client/gpaste-client.c:108 #, fuzzy, c-format msgid "Display options:" msgstr "Näytä historia:" #. Translators: help for --oneline #: ../src/gpaste-client/gpaste-client.c:111 #, fuzzy msgid "display each item on only one line" msgstr "tulostaa ohjelman version" #. Translators: help for --oneline #: ../src/gpaste-client/gpaste-client.c:113 msgid "display each item raw (without line numbers)" msgstr "" #. Translators: help for --oneline #: ../src/gpaste-client/gpaste-client.c:115 msgid "use a NUL character instead of a new line betweean each item" msgstr "" #: ../src/gpaste-client/gpaste-client.c:118 #, fuzzy, c-format msgid "Merge options:" msgstr "Näytä historia:" #. Translators: help for --decoration #. Translators: help for --separator #: ../src/gpaste-client/gpaste-client.c:121 #: ../src/gpaste-client/gpaste-client.c:123 msgid "string" msgstr "" #: ../src/gpaste-client/gpaste-client.c:121 msgid "" "add the given decoration to the beginning and the end of each item before " "merging" msgstr "" #: ../src/gpaste-client/gpaste-client.c:123 msgid "add the given separator between each item when merging" msgstr "" #: ../src/gpaste-client/gpaste-client.c:196 #: ../src/gpaste-client/gpaste-client.c:410 #, fuzzy msgid "Couldn't spawn" msgstr "GPaste-härpäkkeen esiintaikominen epäonnistui.\n" #: ../src/gpaste-client/gpaste-client.c:355 #, c-format msgid "Successfully reexecuted the daemon\n" msgstr "Palvelun uudelleenkäynnistäminen onnistui\n" #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:1 #: ../data/desktop/org.gnome.GPaste.Applet.desktop.in.in.h:1 msgid "GPaste Applet" msgstr "GPaste-härpäke" #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:2 #: ../data/desktop/org.gnome.GPaste.Applet.desktop.in.in.h:2 msgid "Tray icon to manage GPaste" msgstr "Tehtäväpalkin kuvake" #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:3 #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:3 #: ../data/appstream/org.gnome.GPaste.Ui.appdata.xml.in.h:2 msgid "" "GPaste is a clipboard managing system allowing you to track and manage your " "clipboard history in a highly customizable way." msgstr "" #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:4 msgid "" "GPaste provides you with an applet, in the form of a status icon which will " "give you access to your history in your tray area." msgstr "" #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:1 #: ../data/desktop/org.gnome.GPaste.AppIndicator.desktop.in.in.h:1 #, fuzzy msgid "GPaste AppIndicator" msgstr "GPaste-härpäke" #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:2 #: ../data/desktop/org.gnome.GPaste.AppIndicator.desktop.in.in.h:2 #, fuzzy msgid "Unity application indicator to manage GPaste" msgstr "Tehtäväpalkin kuvake" #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:4 msgid "" "GPaste provides you with an application indicator for unity which will give " "you access to your history in your indicator area." msgstr "" #: ../data/appstream/org.gnome.GPaste.Ui.appdata.xml.in.h:1 #: ../data/desktop/org.gnome.GPaste.Ui.desktop.in.in.h:1 msgid "Manage your clipboard history" msgstr "" #: ../data/appstream/org.gnome.GPaste.Ui.appdata.xml.in.h:3 msgid "" "GPaste provides you with a graphical tool allowing you to manage everything " "easily." msgstr "" #: ../data/desktop/org.gnome.GPaste.Applet.desktop.in.in.h:3 #: ../data/desktop/org.gnome.GPaste.AppIndicator.desktop.in.in.h:3 msgid "Clipboard;Manager;" msgstr "" #: ../data/desktop/org.gnome.GPaste.Ui.desktop.in.in.h:2 msgid "Clipboard;Manager;Settings;Preferences;Configuration;" msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:1 msgid "Max size of an element when displaying it" msgstr "Suurin koko elementtejä näytettäessä" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:2 msgid "" "The extra stuff of that element will be replaced by \"…\", and newlines by " "\" \" when displaying from the applet, 0 to disable." msgstr "" "Leikkeen loppuosa korvataan \"...\" merkillä sekä rivin vaihdot \" \" " "merkillä härpäkeikkunassa, 0 poistaa käytöstä." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:3 msgid "Do we detect and replace growing lines in history?" msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:4 msgid "" "By default, selecting \"Here is\", then \"Here is an example\" will create " "two entries in the history. With this feature enabled, the first one will be " "replaced by the second one." msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:5 msgid "The name of the current history" msgstr "Nykyisen historian nimi" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:6 msgid "The default name is \"history\"" msgstr "Oletusnimi on \"history\"" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:7 msgid "Do we save the images copied to history, or only text?" msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:8 msgid "By default, we're saving both" msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:9 #, fuzzy msgid "The keyboard shortcut to launch the graphical interface" msgstr "Valikon avaamiseen käytettävä näppäinyhdistelmä" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:10 #, fuzzy msgid "" "By default, hitting ctrl + alt + g does that (\"<Ctrl><Alt>G\"). " "An empty string here disables this functionnality." msgstr "" "Oletuksena näppäinyhdistelmä ctrl + alt + v tekee tämän(\"<Ctrl><" "Alt>H\"). Tämän tyhjäksi jättäminen poistaa ominaisuuden käytöstä." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:11 #, fuzzy msgid "The keyboard shortcut to mark the active item as being a password" msgstr "Valikon avaamiseen käytettävä näppäinyhdistelmä" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:12 #, fuzzy msgid "" "By default, hitting ctrl + alt + s will mark the active item as being a " "password (\"<Ctrl><Alt>S\"). An empty string here disables this " "functionnality." msgstr "" "Oletuksena näppäinyhdistelmä ctrl + alt + h avaa valikon (\"<Ctrl><" "Alt>H\"). Tämän tyhjäksi jättäminen poistaa ominaisuuden käytöstä." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:13 msgid "Max displayed history size" msgstr "Historian suurin koko" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:14 msgid "Maximum number of items displayed in the history" msgstr "Suurin määrä historiassa näkyviä leikkeitä" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:15 msgid "Max history size" msgstr "Historian suurin koko" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:16 msgid "Maximum number of items in history" msgstr "Suurin määrä leikkeitä, joita historissa säilytettään" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:17 msgid "Max memory usage (MB)" msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:18 msgid "Maximum amount of memory used to store contents" msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:19 msgid "Max text item size" msgstr "Suurin tekstileikkeen koko" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:20 msgid "Maximum size of a text item. Anything out of this boundary is ignored." msgstr "Suurin sallittu tekstileikkeen koko, suurempia leikkeitä ei huomioida." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:21 msgid "Min text item size" msgstr "Pienin tekstileikkeen koko" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:22 msgid "Minimum size of a text item. Anything out of this boundary is ignored." msgstr "Pienin sallittu tekstileikkeen koko, lyhempiä leikkeitä ei huomioida." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:23 msgid "The keyboard shortcut to delete the first element in history" msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:24 msgid "" "By default, hitting ctrl + alt + v does that (\"<Ctrl><Alt>V\"). " "An empty string here disables this functionnality." msgstr "" "Oletuksena näppäinyhdistelmä ctrl + alt + v tekee tämän(\"<Ctrl><" "Alt>H\"). Tämän tyhjäksi jättäminen poistaa ominaisuuden käytöstä." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:25 msgid "Does the primary selection affects history?" msgstr "Vaikuttaako maalaaminen historiaan?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:26 msgid "By default, only clipboard (ctrl+c) affects history." msgstr "Oletuksena vain leikeet (ctrl+c) vaikuttvat historiaan." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:27 msgid "Do we save the history from one session to another?" msgstr "Säilytetäänkö historia kirjautumiskertojen välillä?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:28 msgid "By default, we're saving it" msgstr "Oletuksena tallennetaan." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:29 msgid "The keyboard shortcut to display the menu" msgstr "Valikon avaamiseen käytettävä näppäinyhdistelmä" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:30 msgid "" "By default, hitting ctrl + alt + h displays the menu (\"<Ctrl><" "Alt>H\"). An empty string here disables this functionnality." msgstr "" "Oletuksena näppäinyhdistelmä ctrl + alt + h avaa valikon (\"<Ctrl><" "Alt>H\"). Tämän tyhjäksi jättäminen poistaa ominaisuuden käytöstä." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:31 msgid "The keyboard shortcut to sync the clipboard to the primary selection" msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:32 msgid "" "By default, hitting ctrl + alt + o syncs them (\"<Ctrl><Alt>P" "\"). An empty string here disables this functionnality." msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:33 msgid "The keyboard shortcut to sync the primary selection to the clipboard" msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:34 msgid "" "By default, hitting ctrl + alt + p syncs them (\"<Ctrl><Alt>P" "\"). An empty string here disables this functionnality." msgstr "" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:35 msgid "Are the primary selection and the clipboard synchronized?" msgstr "Synkronoidaanko leikepäytä ja maalaaminen toisiinsa?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:36 msgid "By default, the primary selection and the clipboard are independent." msgstr "Oletuksena maalaminen ja leikkeet ovat erillään." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:37 msgid "Do we track the clipboard changes?" msgstr "Seurataanko leikepöydän tapahtumia?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:38 msgid "By default, we're tracking those changes." msgstr "Oletuksena muutoksia seurataan." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:39 msgid "" "Do we sync the daemon state with the gnome-shell extension's one? (disable " "the daemon when disabling the extension)" msgstr "" "Synkronoidaanko palvelun tila gnome-shell liitännäisen tlaan?(ota palvelu " "pois käytöstä, kun poistat liitännäisen)" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:40 msgid "By default, the daemon state keeps unchanged" msgstr "Oletuksena palvelun tilaa ei muuteta" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:41 msgid "Do we trim the textual items before adding them to history?" msgstr "Trimmataanko tekstileikkeet, ennen lisäämistä historiaan?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:42 msgid "" "Trimming means removing all trailing and ending spaces. By default, we're " "letting them as-is." msgstr "" "Trimmaaminen tarkoittaa leikkeen lopussa olevien välilyöntien poistamista. " "Oletuksena niiden annetaan olla rauhassa." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:43 #, fuzzy msgid "" "The keyboard shortcut to upload the first element in history to a pastebin " "service" msgstr "Valikon avaamiseen käytettävä näppäinyhdistelmä" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:44 #, fuzzy msgid "" "By default, hitting ctrl + alt + u does that (\"<Ctrl><Alt>U\"). " "An empty string here disables this functionnality." msgstr "" "Oletuksena näppäinyhdistelmä ctrl + alt + v tekee tämän(\"<Ctrl><" "Alt>H\"). Tämän tyhjäksi jättäminen poistaa ominaisuuden käytöstä." #~ msgid "Signal %d received, exiting\n" #~ msgstr "Vastaanotettiin signaali %d, lopetetaan.\n" #~ msgid "Empty history" #~ msgstr "Tyhjennä historia" #~ msgid "Backup history as: " #~ msgstr "Historian varmuuskopio:" #~ msgid "Ok" #~ msgstr "Ok" #~ msgid "Histories" #~ msgstr "Historiat" #~ msgid "Could not register DBus service." #~ msgstr "DBus-palvelun rekisteröinti epäonnistui." #, fuzzy #~ msgid "Manage GPaste" #~ msgstr "Hallitse GPaste palvelun asetuksia" #~ msgid "GPaste daemon settings" #~ msgstr "GPaste palvelun asetukset" #, fuzzy #~ msgid "Manage GPaste settings" #~ msgstr "Hallitse GPaste palvelun asetuksia" #~ msgid "Manage the GPaste daemon settings" #~ msgstr "Hallitse GPaste palvelun asetuksia" #, fuzzy #~ msgid "Stop tracking changes" #~ msgstr "lopettaa leikepöydän muutosten seuraamisen" #~ msgid "Track changes" #~ msgstr "Pidä kirjaa tapahtumista" #, fuzzy #~ msgid "print the history without newlines" #~ msgstr "listaa historian indeksöitynä" #, fuzzy #~ msgid "print the history (raw) without indexes" #~ msgstr "listaa historian ilman indeksejä" #~ msgid "print the history with NUL as separator" #~ msgstr "tulostaa historian käyttäen NUL merkkiä erottimena" #, fuzzy #~ msgid "get the th item from the history (raw)" #~ msgstr "noutaa määritellyn leikkeen historiasta" #, fuzzy #~ msgid "Couldn't spawn gpaste-app-indicator.\n" #~ msgstr "GPaste-härpäkkeen esiintaikominen epäonnistui.\n" GPaste-3.18.6/po/fr.po000066400000000000000000000753671305131721400144000ustar00rootroot00000000000000# French translations for GPaste package. # Copyright (C) 2011-2015 Listed translators # This file is distributed under the same license as the GPaste package. # Marc-Antoine Perennou , 2011. # msgid "" msgstr "" "Project-Id-Version: GPaste\n" "Report-Msgid-Bugs-To: Marc-Antoine@Perennou.com\n" "POT-Creation-Date: 2017-02-16 13:43+0100\n" "PO-Revision-Date: 2011-01-25 16:05+0100\n" "Last-Translator: Marc-Antoine Perennou \n" "Language-Team: French\n" "Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../src/libgpaste/gpaste-macros.h:63 msgid "Failed to register the gtk application" msgstr "Impossible d'inscrire l'application gtk au registre" #: ../src/libgpaste/applet/gpaste-applet.c:156 #: ../src/libgpaste/applet/gpaste-applet.c:184 msgid "is not installed" msgstr "n'est pas installé" #: ../src/libgpaste/applet/gpaste-applet-about.c:81 #: ../src/libgpaste/ui/gpaste-ui-about.c:52 msgid "About" msgstr "À propos" #: ../src/libgpaste/applet/gpaste-applet-quit.c:70 msgid "Quit" msgstr "Quitter" #. Translators: help for gpaste ui #: ../src/libgpaste/applet/gpaste-applet-ui.c:61 #: ../src/gpaste-client/gpaste-client.c:83 msgid "launch the graphical tool" msgstr "lance l'interface graphique" #: ../src/libgpaste/core/gpaste-history.c:773 msgid "Could not create history dir" msgstr "Impossible de créer le dossier d'historique" #. This is the date format "month/day/year time" #: ../src/libgpaste/core/gpaste-image-item.c:235 msgid "%m/%d/%y %T" msgstr "%d/%m/%y %T" #. This gets displayed in history when selecting an image #: ../src/libgpaste/core/gpaste-image-item.c:237 #, c-format msgid "[Image, %d x %d (%s)]" msgstr "[Image, %d x %d (%s)]" #. This is the prefix displayed in history to identify a password #: ../src/libgpaste/core/gpaste-password-item.c:82 msgid "Password" msgstr "Mot de passe" #. This is the prefix displayed in history to identify selected files #: ../src/libgpaste/core/gpaste-uris-item.c:117 msgid "[Files] " msgstr "[Fichiers] " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:126 #: ../src/libgpaste/ui/gpaste-ui-switch.c:96 msgid "Track clipboard changes" msgstr "Suivre les changements du presse-papier" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:133 msgid "Enable the gnome-shell extension" msgstr "Activer l'extension gnome-shell" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:139 msgid "Sync the daemon state with the extension's one" msgstr "Synchroniser l'état du démon avec celui de l'extension" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:147 msgid "Primary selection affects history" msgstr "La sélection primaire affecte l'historique" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:153 msgid "Synchronize clipboard with primary selection" msgstr "Synchroniser le presse-papier avec la sélection primaire" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:160 msgid "Images support" msgstr "Support des images" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:166 msgid "Trim items" msgstr "Tronquer les éléments (éliminer les espaces au début et à la fin)" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:172 msgid "Detect growing lines" msgstr "Détecter les lignes grandissantes" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:179 msgid "Save history" msgstr "Sauvegarder l'historique" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:202 msgid "Max element size when displaying: " msgstr "Taille maximale d'un élément quand on l'affiche : " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:209 msgid "Max displayed history size: " msgstr "Taille maximale de l'historique affiché : " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:216 msgid "Max history size: " msgstr "Taille maximale de l'historique : " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:223 msgid "Max memory usage (MB): " msgstr "Utilisation mémoire maximale (MO): " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:230 msgid "Max text item length: " msgstr "Taille maximale d'un élément textuel" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:237 msgid "Min text item length: " msgstr "Taille minimale d'un élément textuel" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:263 #: ../data/control-center/42-gpaste.xml.in.in.h:3 msgid "Delete the active item from history: " msgstr "Supprimer l'élément actif de l'historique : " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:270 #: ../data/control-center/42-gpaste.xml.in.in.h:1 msgid "Launch the graphical tool: " msgstr "Lancer l'interface graphique: " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:277 #: ../data/control-center/42-gpaste.xml.in.in.h:2 msgid "Mark the active item as being a password: " msgstr "Marquer l'élément actif comme étant un mot de passe : " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:284 #: ../data/control-center/42-gpaste.xml.in.in.h:4 msgid "Display the history: " msgstr "Afficher l'historique : " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:291 #: ../data/control-center/42-gpaste.xml.in.in.h:5 msgid "Sync the clipboard to the primary selection: " msgstr "Synchroniser le presse-papier avec la sélection primaire: " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:298 #: ../data/control-center/42-gpaste.xml.in.in.h:6 msgid "Sync the primary selection to the clipboard: " msgstr "Synchroniser la sélection primaire avec le presse-papier: " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:305 #: ../data/control-center/42-gpaste.xml.in.in.h:7 msgid "Upload the active item to a pastebin service: " msgstr "Téléverser l'élément actif vers un sevice type pastebin : " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:320 #: ../src/libgpaste/ui/gpaste-ui-window.c:211 #: ../src/gpaste-client/gpaste-client.c:185 msgid "Couldn't connect to GPaste daemon" msgstr "Impossible de se connecter au démon GPaste" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:337 msgid "General behaviour" msgstr "Comportement général" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:338 msgid "History settings" msgstr "Préférences de l'historique" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:339 msgid "Keyboard shortcuts" msgstr "Raccourcis clavier" #. translators: This is the name of a multi-history management action #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:453 #: ../src/libgpaste/ui/gpaste-ui-panel.c:297 msgid "Switch to" msgstr "Passer à" #. translators: This is the name of a multi-history management action #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:458 #: ../src/libgpaste/ui/gpaste-ui-delete-item.c:62 #: ../src/libgpaste/ui/gpaste-ui-delete-history.c:37 #: ../src/libgpaste/ui/gpaste-ui-delete-history.c:74 msgid "Delete" msgstr "Supprimer" #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:47 #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:133 msgid "Backup" msgstr "Copier" #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:48 #: ../src/libgpaste/ui/gpaste-ui-edit-item.c:56 #: ../src/libgpaste/util/gpaste-util.c:43 msgid "Cancel" msgstr "Annuler" #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:51 msgid "Under which name do you want to backup this history?" msgstr "Sous quel nom voulez-vous copier cet historique ?" #: ../src/libgpaste/ui/gpaste-ui-delete-history.c:37 msgid "Are you sure you want to delete this history?" msgstr "Voulez-vous vraiment supprimer cet historique ?" #: ../src/libgpaste/ui/gpaste-ui-edit-item.c:55 #: ../src/libgpaste/ui/gpaste-ui-edit-item.c:126 msgid "Edit" msgstr "Modifier" #. Translators: this is the translation for emptying the history #: ../src/libgpaste/ui/gpaste-ui-empty-history.c:38 #: ../src/libgpaste/ui/gpaste-ui-empty-history.c:76 msgid "Empty" msgstr "Vider" #: ../src/libgpaste/ui/gpaste-ui-empty-history.c:38 msgid "Do you really want to empty the history?" msgstr "Voulez-vous vraiment vider l'historique ?" #: ../src/libgpaste/ui/gpaste-ui-empty-item.c:37 msgid "(Empty)" msgstr "(Vide)" #: ../src/libgpaste/ui/gpaste-ui-reexec.c:42 msgid "Restart" msgstr "Redémarer" #: ../src/libgpaste/ui/gpaste-ui-reexec.c:42 msgid "Do you really want to restart the daemon?" msgstr "Voulez-vous vraiment redémarer le démon ?" #: ../src/libgpaste/ui/gpaste-ui-reexec.c:66 msgid "Restart the daemon" msgstr "Redémarer le démon" #: ../src/libgpaste/ui/gpaste-ui-search.c:37 msgid "Search" msgstr "Recherche" #: ../src/libgpaste/ui/gpaste-ui-settings.c:42 msgid "GPaste Settings" msgstr "Préférences du démon GPaste" #: ../src/libgpaste/ui/gpaste-ui-switch.c:60 msgid "Stop" msgstr "Arrêter" #: ../src/libgpaste/ui/gpaste-ui-switch.c:60 msgid "Do you really want to stop tracking clipboard changes?" msgstr "" "Voulez-vous vraiment arrêter de suivre les changements du presse-papier ?" #: ../src/libgpaste/ui/gpaste-ui-upload-item.c:62 msgid "Upload" msgstr "Publier" #: ../src/daemon/gpaste-daemon.c:47 msgid "Could not acquire DBus name." msgstr "Impossible d'acquérir le nom DBus." #: ../src/gpaste-client/gpaste-client.c:31 #, c-format msgid "Usage:\n" msgstr "Mode d'emploi :\n" #. Translators: help for gpaste history #: ../src/gpaste-client/gpaste-client.c:33 msgid "print the history with indexes" msgstr "affiche l'historique avec les indices" #. Translators: help for gpaste history-size #: ../src/gpaste-client/gpaste-client.c:35 msgid "print the size of the history" msgstr "affiche la taille de l'historique" #. Translators: help for gpaste get-history #: ../src/gpaste-client/gpaste-client.c:37 msgid "get the name of the current history" msgstr "afficher le nom de l'historique courant" #. Translators: help for gpaste backup-history #. Translators: help for gpaste switch-history #. Translators: help for gpaste delete-history #. Translators: help for gpaste add-password #. Translators: help for gpaste delete-passworf #: ../src/gpaste-client/gpaste-client.c:39 #: ../src/gpaste-client/gpaste-client.c:41 #: ../src/gpaste-client/gpaste-client.c:43 #: ../src/gpaste-client/gpaste-client.c:49 #: ../src/gpaste-client/gpaste-client.c:61 #: ../src/gpaste-client/gpaste-client.c:65 msgid "name" msgstr "nom" #: ../src/gpaste-client/gpaste-client.c:39 msgid "backup current history" msgstr "sauvegarde l'historique actuel" #: ../src/gpaste-client/gpaste-client.c:41 msgid "switch to another history" msgstr "passer à un autre historique" #: ../src/gpaste-client/gpaste-client.c:43 msgid "delete a history" msgstr "supprime un historique" #. Translators: help for gpaste list-histories #: ../src/gpaste-client/gpaste-client.c:45 msgid "list available histories" msgstr "liste les historiques disponibles" #. Translators: help for gpaste add #: ../src/gpaste-client/gpaste-client.c:47 msgid "text" msgstr "texte" #: ../src/gpaste-client/gpaste-client.c:47 msgid "set text to clipboard" msgstr "met le texte dans le presse-papier" #: ../src/gpaste-client/gpaste-client.c:49 msgid "password" msgstr "mot de passe" #: ../src/gpaste-client/gpaste-client.c:49 msgid "add the name - password couple to the clipboard" msgstr "ajouter le couple nom - mot de passe au presse-papier" #. Translators: help for gpaste rename-password #: ../src/gpaste-client/gpaste-client.c:51 msgid "old name" msgstr "ancien nom" #: ../src/gpaste-client/gpaste-client.c:51 msgid "new name" msgstr "nouveau nom" #: ../src/gpaste-client/gpaste-client.c:51 msgid "rename the password" msgstr "renommer le mot de passe" #. Translators: help for gpaste get #. Translators: help for gpaste select #. Translators: help for gpaste replace #. Translators: help for gpaste merge #. Translators: help for gpaste set-password #. Translators: help for gpaste delete #. Translators: help for gpaste upload #: ../src/gpaste-client/gpaste-client.c:53 #: ../src/gpaste-client/gpaste-client.c:55 #: ../src/gpaste-client/gpaste-client.c:57 #: ../src/gpaste-client/gpaste-client.c:59 #: ../src/gpaste-client/gpaste-client.c:61 #: ../src/gpaste-client/gpaste-client.c:63 #: ../src/gpaste-client/gpaste-client.c:97 msgid "number" msgstr "nombre" #: ../src/gpaste-client/gpaste-client.c:53 msgid "get the th item from the history" msgstr "renvoie le e élément de l'historique" #: ../src/gpaste-client/gpaste-client.c:55 msgid "set the th item from the history to the clipboard" msgstr "met le e élément de l'historique dans le presse-papier" #: ../src/gpaste-client/gpaste-client.c:57 msgid "contents" msgstr "contenu" #: ../src/gpaste-client/gpaste-client.c:57 msgid "" "replace the contents of the th item from the history with the " "provided one" msgstr "" "remplace le contenu du e élément de l'historique par celui fourni" #: ../src/gpaste-client/gpaste-client.c:59 msgid "" "merge the th items from the history and add put the result in the " "clipboard" msgstr "" "fusionne les e éléments de l'historique et met le résultat dans le " "presse-papier" #: ../src/gpaste-client/gpaste-client.c:61 msgid "set the th item from the history as a password named " msgstr "" "marque le e élément de l'historique comme étant un mot de passe " "nommé " #: ../src/gpaste-client/gpaste-client.c:63 msgid "delete th item of the history" msgstr "supprime le e élément de l'historique" #: ../src/gpaste-client/gpaste-client.c:65 msgid "delete the password from the history" msgstr "supprime le mot de passe nommé de l'historique" #. Translators: help for gpaste file #: ../src/gpaste-client/gpaste-client.c:67 msgid "path" msgstr "chemin" #: ../src/gpaste-client/gpaste-client.c:67 msgid "put the content of the file at into the clipboard" msgstr "place le contenu du fichier situé à ce chemin dans le presse-papier" #. Translators: help for whatever | gpaste #: ../src/gpaste-client/gpaste-client.c:69 msgid "whatever" msgstr "quelquechose" #: ../src/gpaste-client/gpaste-client.c:69 msgid "set the output of whatever to clipboard" msgstr "met la sortie de quelquechose dans le presse-papier" #. Translators: help for gpaste empty #: ../src/gpaste-client/gpaste-client.c:71 msgid "empty the history" msgstr "vide l'historique" #. Translators: help for gpaste start #: ../src/gpaste-client/gpaste-client.c:73 msgid "start tracking clipboard changes" msgstr "suivre les changements du presse-papier" #. Translators: help for gpaste stop #: ../src/gpaste-client/gpaste-client.c:75 msgid "stop tracking clipboard changes" msgstr "arrêter de suivre les changements du presse-papier" #. Translators: help for gpaste quit #: ../src/gpaste-client/gpaste-client.c:77 msgid "alias for stop" msgstr "alias pour stop" #. Translators: help for gpaste daemon-reexec #: ../src/gpaste-client/gpaste-client.c:79 msgid "reexecute the daemon (after upgrading...)" msgstr "reexecuter le démon (après une mise à jour...)" #. Translators: help for gpaste settings #: ../src/gpaste-client/gpaste-client.c:81 msgid "launch the configuration tool" msgstr "lance l'outil de configuration" #. Translators: help for gpaste applet #: ../src/gpaste-client/gpaste-client.c:87 msgid "launch the applet" msgstr "lance l'applet GPaste" #. Translators: help for gpaste app-indicator #: ../src/gpaste-client/gpaste-client.c:92 msgid "launch the unity application indicator" msgstr "lance l'indicateur d'application pour unity" #. Translators: help for gpaste show-history #: ../src/gpaste-client/gpaste-client.c:95 msgid "make the applet or extension display the history" msgstr "forcer l'applet ou l'extension à afficher l'historique" #: ../src/gpaste-client/gpaste-client.c:97 msgid "upload the th item to a pastebin service" msgstr "" "téléverser le e élément de l'historique vers un service de type " "pastebin" #. Translators: help for gpaste version #: ../src/gpaste-client/gpaste-client.c:99 msgid "display the version" msgstr "affiche la version" #. Translators: help for gpaste daemon-version #: ../src/gpaste-client/gpaste-client.c:101 msgid "display the daemon version" msgstr "affiche la version du démon" #. Translators: help for gpaste help #: ../src/gpaste-client/gpaste-client.c:103 msgid "display this help" msgstr "affiche cette aide" #. Translators: help for gpaste about #: ../src/gpaste-client/gpaste-client.c:105 msgid "display the about dialog" msgstr "affiche le dialogue d'à propos" #: ../src/gpaste-client/gpaste-client.c:108 #, c-format msgid "Display options:" msgstr "Options d'affichage : " #. Translators: help for --oneline #: ../src/gpaste-client/gpaste-client.c:111 msgid "display each item on only one line" msgstr "affiche chaque élément sur seulement une ligne" #. Translators: help for --oneline #: ../src/gpaste-client/gpaste-client.c:113 msgid "display each item raw (without line numbers)" msgstr "affiche chaque élément brut (sans numéro de ligne)" #. Translators: help for --oneline #: ../src/gpaste-client/gpaste-client.c:115 msgid "use a NUL character instead of a new line betweean each item" msgstr "" "utilise un caractère NUL au lieu des sauts de ligne entre chaque élément" #: ../src/gpaste-client/gpaste-client.c:118 #, c-format msgid "Merge options:" msgstr "Options de fusion : " #. Translators: help for --decoration #. Translators: help for --separator #: ../src/gpaste-client/gpaste-client.c:121 #: ../src/gpaste-client/gpaste-client.c:123 msgid "string" msgstr "chaîne" #: ../src/gpaste-client/gpaste-client.c:121 msgid "" "add the given decoration to the beginning and the end of each item before " "merging" msgstr "" "ajoute la décoration au début et à la fin de chaque élément avant de les " "fusionner" #: ../src/gpaste-client/gpaste-client.c:123 msgid "add the given separator between each item when merging" msgstr "ajoute le séparateur entre chaque élément à la fusion" #: ../src/gpaste-client/gpaste-client.c:196 #: ../src/gpaste-client/gpaste-client.c:410 msgid "Couldn't spawn" msgstr "Impossible de lancer" #: ../src/gpaste-client/gpaste-client.c:355 #, c-format msgid "Successfully reexecuted the daemon\n" msgstr "Démon redémaré avec succès\n" #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:1 #: ../data/desktop/org.gnome.GPaste.Applet.desktop.in.in.h:1 msgid "GPaste Applet" msgstr "Applet GPaste" #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:2 #: ../data/desktop/org.gnome.GPaste.Applet.desktop.in.in.h:2 msgid "Tray icon to manage GPaste" msgstr "Icone de notification pour gérer GPaste" #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:3 #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:3 #: ../data/appstream/org.gnome.GPaste.Ui.appdata.xml.in.h:2 msgid "" "GPaste is a clipboard managing system allowing you to track and manage your " "clipboard history in a highly customizable way." msgstr "" "GPaste est un outil de gestion du presse-papier qui vous permet de suivre et " "de manipuler votre historique de presse-papier de façon très configurable." #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:4 msgid "" "GPaste provides you with an applet, in the form of a status icon which will " "give you access to your history in your tray area." msgstr "" "GPaste vous fournit un applet, sous la force d'une icon de status qui vous " "donnera accès à votre historique dans votre zone de notifications." #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:1 #: ../data/desktop/org.gnome.GPaste.AppIndicator.desktop.in.in.h:1 msgid "GPaste AppIndicator" msgstr "Indicateur d'application GPaste" #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:2 #: ../data/desktop/org.gnome.GPaste.AppIndicator.desktop.in.in.h:2 msgid "Unity application indicator to manage GPaste" msgstr "Indicateur d'application pour unity pour gérer GPaste" #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:4 msgid "" "GPaste provides you with an application indicator for unity which will give " "you access to your history in your indicator area." msgstr "" "GPaste vous fournit un indicateur d'appliation pour unity qui voud donnera " "accès à votre historique dans votre zone d'indicateurs." #: ../data/appstream/org.gnome.GPaste.Ui.appdata.xml.in.h:1 #: ../data/desktop/org.gnome.GPaste.Ui.desktop.in.in.h:1 msgid "Manage your clipboard history" msgstr "Gérez l'historique de votre presse-papier" #: ../data/appstream/org.gnome.GPaste.Ui.appdata.xml.in.h:3 msgid "" "GPaste provides you with a graphical tool allowing you to manage everything " "easily." msgstr "" "GPaste vous fournit un outil graphique vous permettant de tout gérer " "simplement" #: ../data/desktop/org.gnome.GPaste.Applet.desktop.in.in.h:3 #: ../data/desktop/org.gnome.GPaste.AppIndicator.desktop.in.in.h:3 msgid "Clipboard;Manager;" msgstr "Presse-Papier;Gestionnaire;" #: ../data/desktop/org.gnome.GPaste.Ui.desktop.in.in.h:2 msgid "Clipboard;Manager;Settings;Preferences;Configuration;" msgstr "Presse-Papier;Gestionnaire;Réglages;Préférences;Configuration;" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:1 msgid "Max size of an element when displaying it" msgstr "Taille maximale d'un élément quand on l'affiche" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:2 msgid "" "The extra stuff of that element will be replaced by \"…\", and newlines by " "\" \" when displaying from the applet, 0 to disable." msgstr "" "La partie de l'élément excédant la taille authorisée sera remplacée par \"…" "\", et les sauts de lignes par \" \" quand on affiche depuis l'applet, 0 " "pour désativer." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:3 msgid "Do we detect and replace growing lines in history?" msgstr "" "Doit-on détecter et remplacer les lignes grandissantes dans l'historique ?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:4 msgid "" "By default, selecting \"Here is\", then \"Here is an example\" will create " "two entries in the history. With this feature enabled, the first one will be " "replaced by the second one." msgstr "" "Par défaut, selectionner \"Ceci est\", puis \"Ceci est un exemple\" va créer " "deux entrées dans l'historique. Avec cette fonctionnalité activée, la " "première sera remplacé par la deuxième." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:5 msgid "The name of the current history" msgstr "Le nom de l'historique actuel" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:6 msgid "The default name is \"history\"" msgstr "Le nom par défaut est \"history\"" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:7 msgid "Do we save the images copied to history, or only text?" msgstr "" "Les images copiées doivent-elles être ajoutées à l'historique, ou seulement " "le texte ?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:8 msgid "By default, we're saving both" msgstr "Par défaut, on sauvegarde les deux." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:9 msgid "The keyboard shortcut to launch the graphical interface" msgstr "Le raccourcis clavier pour lancer l'interface graphique" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:10 msgid "" "By default, hitting ctrl + alt + g does that (\"<Ctrl><Alt>G\"). " "An empty string here disables this functionnality." msgstr "" "Par défaut, appuyer sur ctrl + alt + g le fait (\"<Ctrl><Alt>G" "\"). Une chaîne vide désactive cette fonctionnalité." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:11 msgid "The keyboard shortcut to mark the active item as being a password" msgstr "" "Le raccourcis clavier pour marquer l'élement actif comme étant un mot de " "passe" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:12 msgid "" "By default, hitting ctrl + alt + s will mark the active item as being a " "password (\"<Ctrl><Alt>S\"). An empty string here disables this " "functionnality." msgstr "" "Par défaut, appuyer sur ctrl + alt + s affiche le menu (\"<Ctrl><" "Alt>S\"). Une chaîne vide désactive cette fonctionnalité." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:13 msgid "Max displayed history size" msgstr "Taille maximale de l'historique affiché" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:14 msgid "Maximum number of items displayed in the history" msgstr "Nombre maximum d'éléments affichés dans l'historique" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:15 msgid "Max history size" msgstr "Taille maximale de l'historique" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:16 msgid "Maximum number of items in history" msgstr "Nombre maximum d'éléments dans l'historique" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:17 msgid "Max memory usage (MB)" msgstr "Utilisation mémoire maximale (MO)" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:18 msgid "Maximum amount of memory used to store contents" msgstr "Quantité maximale de mémoire utilisée pour stcoker du contenu" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:19 msgid "Max text item size" msgstr "Taille maximale d'un élément textuel" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:20 msgid "Maximum size of a text item. Anything out of this boundary is ignored." msgstr "" "Taille maximale d'un élément textuel. Tout élément hors de ces limites est " "ignoré." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:21 msgid "Min text item size" msgstr "Taille minimale d'un élément textuel" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:22 msgid "Minimum size of a text item. Anything out of this boundary is ignored." msgstr "" "Taille minimale d'un élément textuel. Tout élément hors de ces limites est " "ignoré." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:23 msgid "The keyboard shortcut to delete the first element in history" msgstr "" "Le raccourcis clavier pour supprimer le premier élément de l'historique" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:24 msgid "" "By default, hitting ctrl + alt + v does that (\"<Ctrl><Alt>V\"). " "An empty string here disables this functionnality." msgstr "" "Par défaut, appuyer sur ctrl + alt + v le fait (\"<Ctrl><Alt>V" "\"). Une chaîne vide désactive cette fonctionnalité." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:25 msgid "Does the primary selection affects history?" msgstr "La selection primaire doit-elle affecter l'historique?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:26 msgid "By default, only clipboard (ctrl+c) affects history." msgstr "Par défaut, seulement le presse-papier (ctrl+c) affecte l'historique." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:27 msgid "Do we save the history from one session to another?" msgstr "Sauvegarde-t-on l'historique d'une session à l'autre ?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:28 msgid "By default, we're saving it" msgstr "Par défaut, on le sauvegarde." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:29 msgid "The keyboard shortcut to display the menu" msgstr "Le raccourcis clavier pour afficher l'historique" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:30 msgid "" "By default, hitting ctrl + alt + h displays the menu (\"<Ctrl><" "Alt>H\"). An empty string here disables this functionnality." msgstr "" "Par défaut, appuyer sur ctrl + alt + h affiche le menu (\"<Ctrl><" "Alt>H\"). Une chaîne vide désactive cette fonctionnalité." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:31 msgid "The keyboard shortcut to sync the clipboard to the primary selection" msgstr "" "Le raccourcis clavier pour synchroniser le presse-papier avec la sélection " "primaire" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:32 msgid "" "By default, hitting ctrl + alt + o syncs them (\"<Ctrl><Alt>P" "\"). An empty string here disables this functionnality." msgstr "" "Par défaut, appuyer sur ctrl + alt + o les synchronise (\"<Ctrl><" "Alt>O\"). Une chaîne vide désactive cette fonctionnalité." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:33 msgid "The keyboard shortcut to sync the primary selection to the clipboard" msgstr "" "Le raccourcis clavier pour synchroniser la sélection primaire avec le presse-" "papier" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:34 msgid "" "By default, hitting ctrl + alt + p syncs them (\"<Ctrl><Alt>P" "\"). An empty string here disables this functionnality." msgstr "" "Par défaut, appuyer sur ctrl + alt + p les synchronise (\"<Ctrl><" "Alt>P\"). Une chaîne vide désactive cette fonctionnalité." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:35 msgid "Are the primary selection and the clipboard synchronized?" msgstr "" "La sélection primaire et le presse-papier doivent-ils être synchronisés?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:36 msgid "By default, the primary selection and the clipboard are independent." msgstr "" "Par défaut, la sélection primaire et le presse-papier sont indépendents." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:37 msgid "Do we track the clipboard changes?" msgstr "Suit-on les changements du presse-papier?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:38 msgid "By default, we're tracking those changes." msgstr "Par défaut, on suit ces changements." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:39 msgid "" "Do we sync the daemon state with the gnome-shell extension's one? (disable " "the daemon when disabling the extension)" msgstr "" "Doit-on synchroniser l'état du démon avec celui de l'extension gnome-shell ? " "(le désactiver quand on la désactive)" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:40 msgid "By default, the daemon state keeps unchanged" msgstr "Par défaut, l'état du démon reste inchangé." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:41 msgid "Do we trim the textual items before adding them to history?" msgstr "" "Doit-on tronquer les éléments textuels avant de les ajouter à l'historique ?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:42 msgid "" "Trimming means removing all trailing and ending spaces. By default, we're " "letting them as-is." msgstr "" "Tronquer signifie supprimer tous les espaces au début et à la fin. Par " "défaut, on laisse les éléments tels-quels" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:43 msgid "" "The keyboard shortcut to upload the first element in history to a pastebin " "service" msgstr "" "Le raccourcis clavier pour téléverser le premier élément de l'historique " "vers un service de type pastebin" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:44 msgid "" "By default, hitting ctrl + alt + u does that (\"<Ctrl><Alt>U\"). " "An empty string here disables this functionnality." msgstr "" "Par défaut, appuyer sur ctrl + alt + u le fait (\"<Ctrl><Alt>U" "\"). Une chaîne vide désactive cette fonctionnalité." GPaste-3.18.6/po/pt_BR.po000066400000000000000000001002261305131721400147560ustar00rootroot00000000000000# Brazilian Portuguese translation for GPaste package. # Copyright (C) 2012-2015 Listed translators # This file is distributed under the same license as the GPaste package. # Elder Marco , 2012. # msgid "" msgstr "" "Project-Id-Version: GPaste\n" "Report-Msgid-Bugs-To: Marc-Antoine@Perennou.com\n" "POT-Creation-Date: 2017-02-16 13:43+0100\n" "PO-Revision-Date: 2015-10-10 20:03-0300\n" "Last-Translator: Elder Marco \n" "Language-Team: \n" "Language: pt_BR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Poedit 1.8.5\n" #: ../src/libgpaste/gpaste-macros.h:63 msgid "Failed to register the gtk application" msgstr "Falha ao registrar a aplicação gtk" #: ../src/libgpaste/applet/gpaste-applet.c:156 #: ../src/libgpaste/applet/gpaste-applet.c:184 msgid "is not installed" msgstr "não está instalado" #: ../src/libgpaste/applet/gpaste-applet-about.c:81 #: ../src/libgpaste/ui/gpaste-ui-about.c:52 msgid "About" msgstr "Sobre" #: ../src/libgpaste/applet/gpaste-applet-quit.c:70 msgid "Quit" msgstr "Sair" #. Translators: help for gpaste ui #: ../src/libgpaste/applet/gpaste-applet-ui.c:61 #: ../src/gpaste-client/gpaste-client.c:83 msgid "launch the graphical tool" msgstr "inicia a ferramenta gráfica" #: ../src/libgpaste/core/gpaste-history.c:773 msgid "Could not create history dir" msgstr "Não foi possível criar o diretório do histórico" #. This is the date format "month/day/year time" #: ../src/libgpaste/core/gpaste-image-item.c:235 msgid "%m/%d/%y %T" msgstr "%d/%m/%y %T" #. This gets displayed in history when selecting an image #: ../src/libgpaste/core/gpaste-image-item.c:237 #, c-format msgid "[Image, %d x %d (%s)]" msgstr "[Imagem, %d x %d (%s)]" #. This is the prefix displayed in history to identify a password #: ../src/libgpaste/core/gpaste-password-item.c:82 msgid "Password" msgstr "Senha" #. This is the prefix displayed in history to identify selected files #: ../src/libgpaste/core/gpaste-uris-item.c:117 msgid "[Files] " msgstr "[Arquivos]" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:126 #: ../src/libgpaste/ui/gpaste-ui-switch.c:96 msgid "Track clipboard changes" msgstr "Monitorar a área de transferência" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:133 msgid "Enable the gnome-shell extension" msgstr "Habilitar a extensão do gnome-shell" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:139 msgid "Sync the daemon state with the extension's one" msgstr "Sincronizar o estado do daemon com a extensão" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:147 msgid "Primary selection affects history" msgstr "Seleção primária afeta o histórico" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:153 msgid "Synchronize clipboard with primary selection" msgstr "Sincronizar área de transferência com a seleção primária" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:160 msgid "Images support" msgstr "Suporte a Imagens" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:166 msgid "Trim items" msgstr "Aparar itens" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:172 msgid "Detect growing lines" msgstr "Detectar linhas crescentes" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:179 msgid "Save history" msgstr "Salvar histórico" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:202 msgid "Max element size when displaying: " msgstr "Tamanho máximo do elemento ao exibir:" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:209 msgid "Max displayed history size: " msgstr "Tamanho máximo do histórico ao exibir:" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:216 msgid "Max history size: " msgstr "Tamanho máximo do histórico:" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:223 msgid "Max memory usage (MB): " msgstr "Uso de memória (MB): " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:230 msgid "Max text item length: " msgstr "Tamanho máximo do item de texto:" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:237 msgid "Min text item length: " msgstr "Tamanho mínimo do item de texto:" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:263 #: ../data/control-center/42-gpaste.xml.in.in.h:3 msgid "Delete the active item from history: " msgstr "Apagar o item ativo do histórico: " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:270 #: ../data/control-center/42-gpaste.xml.in.in.h:1 msgid "Launch the graphical tool: " msgstr "Iniciar a ferramenta gráfica: " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:277 #: ../data/control-center/42-gpaste.xml.in.in.h:2 msgid "Mark the active item as being a password: " msgstr "Marcar o item ativo como sendo uma senha: " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:284 #: ../data/control-center/42-gpaste.xml.in.in.h:4 msgid "Display the history: " msgstr "Mostrar histórico: " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:291 #: ../data/control-center/42-gpaste.xml.in.in.h:5 msgid "Sync the clipboard to the primary selection: " msgstr "Sincronizar a área de transferência com a seleção primária: " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:298 #: ../data/control-center/42-gpaste.xml.in.in.h:6 msgid "Sync the primary selection to the clipboard: " msgstr "Sincronizar a seleção primária com a área de transferência: " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:305 #: ../data/control-center/42-gpaste.xml.in.in.h:7 msgid "Upload the active item to a pastebin service: " msgstr "Carregar o item ativo para um serviço de pastebin: " #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:320 #: ../src/libgpaste/ui/gpaste-ui-window.c:211 #: ../src/gpaste-client/gpaste-client.c:185 msgid "Couldn't connect to GPaste daemon" msgstr "Não foi possível se conectar ao daemon do GPaste" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:337 msgid "General behaviour" msgstr "Comportamento geral" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:338 msgid "History settings" msgstr "Configurações do histórico" #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:339 msgid "Keyboard shortcuts" msgstr "Atalhos do teclado" #. translators: This is the name of a multi-history management action #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:453 #: ../src/libgpaste/ui/gpaste-ui-panel.c:297 msgid "Switch to" msgstr "Alternar para" #. translators: This is the name of a multi-history management action #: ../src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:458 #: ../src/libgpaste/ui/gpaste-ui-delete-item.c:62 #: ../src/libgpaste/ui/gpaste-ui-delete-history.c:37 #: ../src/libgpaste/ui/gpaste-ui-delete-history.c:74 msgid "Delete" msgstr "Apagar" #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:47 #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:133 msgid "Backup" msgstr "Backup" #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:48 #: ../src/libgpaste/ui/gpaste-ui-edit-item.c:56 #: ../src/libgpaste/util/gpaste-util.c:43 msgid "Cancel" msgstr "Cancelar" #: ../src/libgpaste/ui/gpaste-ui-backup-history.c:51 msgid "Under which name do you want to backup this history?" msgstr "Com qual nome você deseja salvar este histórico?" #: ../src/libgpaste/ui/gpaste-ui-delete-history.c:37 msgid "Are you sure you want to delete this history?" msgstr "Tem certeza que quer apagar este histórico?" #: ../src/libgpaste/ui/gpaste-ui-edit-item.c:55 #: ../src/libgpaste/ui/gpaste-ui-edit-item.c:126 msgid "Edit" msgstr "Editar" #. Translators: this is the translation for emptying the history #: ../src/libgpaste/ui/gpaste-ui-empty-history.c:38 #: ../src/libgpaste/ui/gpaste-ui-empty-history.c:76 msgid "Empty" msgstr "Vazio" #: ../src/libgpaste/ui/gpaste-ui-empty-history.c:38 msgid "Do you really want to empty the history?" msgstr "Você quer mesmo esvaziar o histórico?" #: ../src/libgpaste/ui/gpaste-ui-empty-item.c:37 msgid "(Empty)" msgstr "(Vazio)" #: ../src/libgpaste/ui/gpaste-ui-reexec.c:42 msgid "Restart" msgstr "Reiniciar" #: ../src/libgpaste/ui/gpaste-ui-reexec.c:42 msgid "Do you really want to restart the daemon?" msgstr "Você quer mesmo reiniciar o daemon?" #: ../src/libgpaste/ui/gpaste-ui-reexec.c:66 msgid "Restart the daemon" msgstr "Reiniciar o daemon" #: ../src/libgpaste/ui/gpaste-ui-search.c:37 msgid "Search" msgstr "Pesquisar" #: ../src/libgpaste/ui/gpaste-ui-settings.c:42 msgid "GPaste Settings" msgstr "Configurações do GPaste" #: ../src/libgpaste/ui/gpaste-ui-switch.c:60 msgid "Stop" msgstr "Parar" #: ../src/libgpaste/ui/gpaste-ui-switch.c:60 msgid "Do you really want to stop tracking clipboard changes?" msgstr "" "Você quer mesmo parar o monitoramento de alterações na área de transferência?" #: ../src/libgpaste/ui/gpaste-ui-upload-item.c:62 msgid "Upload" msgstr "Carregar" #: ../src/daemon/gpaste-daemon.c:47 msgid "Could not acquire DBus name." msgstr "Não foi possível obter um nome DBus." #: ../src/gpaste-client/gpaste-client.c:31 #, c-format msgid "Usage:\n" msgstr "Uso:\n" #. Translators: help for gpaste history #: ../src/gpaste-client/gpaste-client.c:33 msgid "print the history with indexes" msgstr "imprime o histórico com os índices" #. Translators: help for gpaste history-size #: ../src/gpaste-client/gpaste-client.c:35 msgid "print the size of the history" msgstr "imprime o tamanho do histórico" #. Translators: help for gpaste get-history #: ../src/gpaste-client/gpaste-client.c:37 msgid "get the name of the current history" msgstr "obtém o nome do histórico atual" #. Translators: help for gpaste backup-history #. Translators: help for gpaste switch-history #. Translators: help for gpaste delete-history #. Translators: help for gpaste add-password #. Translators: help for gpaste delete-passworf #: ../src/gpaste-client/gpaste-client.c:39 #: ../src/gpaste-client/gpaste-client.c:41 #: ../src/gpaste-client/gpaste-client.c:43 #: ../src/gpaste-client/gpaste-client.c:49 #: ../src/gpaste-client/gpaste-client.c:61 #: ../src/gpaste-client/gpaste-client.c:65 msgid "name" msgstr "nome" #: ../src/gpaste-client/gpaste-client.c:39 msgid "backup current history" msgstr "faz um backup do histórico atual" #: ../src/gpaste-client/gpaste-client.c:41 msgid "switch to another history" msgstr "alterna para um outro histórico" #: ../src/gpaste-client/gpaste-client.c:43 msgid "delete a history" msgstr "apaga um histórico" #. Translators: help for gpaste list-histories #: ../src/gpaste-client/gpaste-client.c:45 msgid "list available histories" msgstr "lista os históricos disponíveis" #. Translators: help for gpaste add #: ../src/gpaste-client/gpaste-client.c:47 msgid "text" msgstr "texto" #: ../src/gpaste-client/gpaste-client.c:47 msgid "set text to clipboard" msgstr "copia texto para a área de transferência" #: ../src/gpaste-client/gpaste-client.c:49 msgid "password" msgstr "senha" #: ../src/gpaste-client/gpaste-client.c:49 msgid "add the name - password couple to the clipboard" msgstr "adiciona o par nome - senha para a área de transferência" #. Translators: help for gpaste rename-password #: ../src/gpaste-client/gpaste-client.c:51 msgid "old name" msgstr "nome anterior" #: ../src/gpaste-client/gpaste-client.c:51 msgid "new name" msgstr "novo nome" #: ../src/gpaste-client/gpaste-client.c:51 msgid "rename the password" msgstr "define um novo nome para a senha" #. Translators: help for gpaste get #. Translators: help for gpaste select #. Translators: help for gpaste replace #. Translators: help for gpaste merge #. Translators: help for gpaste set-password #. Translators: help for gpaste delete #. Translators: help for gpaste upload #: ../src/gpaste-client/gpaste-client.c:53 #: ../src/gpaste-client/gpaste-client.c:55 #: ../src/gpaste-client/gpaste-client.c:57 #: ../src/gpaste-client/gpaste-client.c:59 #: ../src/gpaste-client/gpaste-client.c:61 #: ../src/gpaste-client/gpaste-client.c:63 #: ../src/gpaste-client/gpaste-client.c:97 msgid "number" msgstr "número" #: ../src/gpaste-client/gpaste-client.c:53 msgid "get the th item from the history" msgstr "obtém o -ésimo item do histórico" #: ../src/gpaste-client/gpaste-client.c:55 msgid "set the th item from the history to the clipboard" msgstr "copia o -ésimo item do histórico para a área de transferência" #: ../src/gpaste-client/gpaste-client.c:57 msgid "contents" msgstr "conteúdo" #: ../src/gpaste-client/gpaste-client.c:57 msgid "" "replace the contents of the th item from the history with the " "provided one" msgstr "" "substitui o conteúdo -ésimo item do histórico com aquele fornecido" #: ../src/gpaste-client/gpaste-client.c:59 msgid "" "merge the th items from the history and add put the result in the " "clipboard" msgstr "" "faz um merge do -ésimo item do histórico e coloca o resultado na " "área de transferência" #: ../src/gpaste-client/gpaste-client.c:61 msgid "set the th item from the history as a password named " msgstr "" "define o -ésimo item do histórico como uma senha chamada " #: ../src/gpaste-client/gpaste-client.c:63 msgid "delete th item of the history" msgstr "apaga o -ésimo item do histórico" #: ../src/gpaste-client/gpaste-client.c:65 msgid "delete the password from the history" msgstr "apaga a senha do histórico" #. Translators: help for gpaste file #: ../src/gpaste-client/gpaste-client.c:67 msgid "path" msgstr "caminho" #: ../src/gpaste-client/gpaste-client.c:67 msgid "put the content of the file at into the clipboard" msgstr "coloca o conteúdo do arquivo em na área de transferência" #. Translators: help for whatever | gpaste #: ../src/gpaste-client/gpaste-client.c:69 msgid "whatever" msgstr "qualquercomando" #: ../src/gpaste-client/gpaste-client.c:69 msgid "set the output of whatever to clipboard" msgstr "copia a saída de qualquercomando para a área de transferência" #. Translators: help for gpaste empty #: ../src/gpaste-client/gpaste-client.c:71 msgid "empty the history" msgstr "esvazia o histórico" #. Translators: help for gpaste start #: ../src/gpaste-client/gpaste-client.c:73 msgid "start tracking clipboard changes" msgstr "inicia o monitoramento de alterações na área de transferência" #. Translators: help for gpaste stop #: ../src/gpaste-client/gpaste-client.c:75 msgid "stop tracking clipboard changes" msgstr "pára o monitoramento de alterações na área de transferência" #. Translators: help for gpaste quit #: ../src/gpaste-client/gpaste-client.c:77 msgid "alias for stop" msgstr "apelido para stop" #. Translators: help for gpaste daemon-reexec #: ../src/gpaste-client/gpaste-client.c:79 msgid "reexecute the daemon (after upgrading...)" msgstr "reinicia o daemon (depois de uma atualização...)" #. Translators: help for gpaste settings #: ../src/gpaste-client/gpaste-client.c:81 msgid "launch the configuration tool" msgstr "inicia a ferramenta de configuração" #. Translators: help for gpaste applet #: ../src/gpaste-client/gpaste-client.c:87 msgid "launch the applet" msgstr "inicia o applet do GPaste" #. Translators: help for gpaste app-indicator #: ../src/gpaste-client/gpaste-client.c:92 msgid "launch the unity application indicator" msgstr "inicia o aplicativo indicador do unity" #. Translators: help for gpaste show-history #: ../src/gpaste-client/gpaste-client.c:95 msgid "make the applet or extension display the history" msgstr "faz o applet ou a extensão exibir o histórico" #: ../src/gpaste-client/gpaste-client.c:97 msgid "upload the th item to a pastebin service" msgstr "" "Apagar o primeiro item do histórico: carrega o -ésimo item para um " "serviço de pastebin" #. Translators: help for gpaste version #: ../src/gpaste-client/gpaste-client.c:99 msgid "display the version" msgstr "mostra a versão" #. Translators: help for gpaste daemon-version #: ../src/gpaste-client/gpaste-client.c:101 msgid "display the daemon version" msgstr "mostra a versão do daemon" #. Translators: help for gpaste help #: ../src/gpaste-client/gpaste-client.c:103 msgid "display this help" msgstr "mostra esta ajuda" #. Translators: help for gpaste about #: ../src/gpaste-client/gpaste-client.c:105 msgid "display the about dialog" msgstr "mostra o diálogo Sobre" #: ../src/gpaste-client/gpaste-client.c:108 #, c-format msgid "Display options:" msgstr "Opções de exibição:" #. Translators: help for --oneline #: ../src/gpaste-client/gpaste-client.c:111 msgid "display each item on only one line" msgstr "Mostra cada item em uma única linha" #. Translators: help for --oneline #: ../src/gpaste-client/gpaste-client.c:113 msgid "display each item raw (without line numbers)" msgstr "exibe cada item bruto (sem números nas linhas) " #. Translators: help for --oneline #: ../src/gpaste-client/gpaste-client.c:115 msgid "use a NUL character instead of a new line betweean each item" msgstr "" "utiliza um caractere NUL no lugar de um caractere de nova linha entre cada " "item" #: ../src/gpaste-client/gpaste-client.c:118 #, c-format msgid "Merge options:" msgstr "Opções de merge:" #. Translators: help for --decoration #. Translators: help for --separator #: ../src/gpaste-client/gpaste-client.c:121 #: ../src/gpaste-client/gpaste-client.c:123 msgid "string" msgstr "string" #: ../src/gpaste-client/gpaste-client.c:121 msgid "" "add the given decoration to the beginning and the end of each item before " "merging" msgstr "" "adiciona a decoração dada ao início e ao fim de cada item antes de fazer o " "merge" #: ../src/gpaste-client/gpaste-client.c:123 msgid "add the given separator between each item when merging" msgstr "adiciona o separador dado entre cada item durante o merge" #: ../src/gpaste-client/gpaste-client.c:196 #: ../src/gpaste-client/gpaste-client.c:410 msgid "Couldn't spawn" msgstr "Não foi possível executar" #: ../src/gpaste-client/gpaste-client.c:355 #, c-format msgid "Successfully reexecuted the daemon\n" msgstr "O daemon foi reiniciado com sucesso\n" #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:1 #: ../data/desktop/org.gnome.GPaste.Applet.desktop.in.in.h:1 msgid "GPaste Applet" msgstr "Applet do GPaste" #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:2 #: ../data/desktop/org.gnome.GPaste.Applet.desktop.in.in.h:2 msgid "Tray icon to manage GPaste" msgstr "Ícone da bandeja para gerenciar o GPaste" #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:3 #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:3 #: ../data/appstream/org.gnome.GPaste.Ui.appdata.xml.in.h:2 msgid "" "GPaste is a clipboard managing system allowing you to track and manage your " "clipboard history in a highly customizable way." msgstr "" "O GPaste é um sistema de gerenciamento de área de transferência que permite " "controlar e gerenciar seu histórico de uma maneira altamente personalizável." #: ../data/appstream/org.gnome.GPaste.Applet.appdata.xml.in.h:4 msgid "" "GPaste provides you with an applet, in the form of a status icon which will " "give you access to your history in your tray area." msgstr "" "O GPaste fornece um applet na forma de um ícone de status, que dá acesso ao " "seu histórico a partir da bandeja do sistema." #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:1 #: ../data/desktop/org.gnome.GPaste.AppIndicator.desktop.in.in.h:1 msgid "GPaste AppIndicator" msgstr "Aplicativo Indicador do GPaste" #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:2 #: ../data/desktop/org.gnome.GPaste.AppIndicator.desktop.in.in.h:2 msgid "Unity application indicator to manage GPaste" msgstr "Aplicativo indicador do Unity para gerenciar o GPaste" #: ../data/appstream/org.gnome.GPaste.AppIndicator.appdata.xml.in.h:4 msgid "" "GPaste provides you with an application indicator for unity which will give " "you access to your history in your indicator area." msgstr "" "O GPaste fornece um aplicativo indicador para o unity que dá acesso ao seu " "histórico a partir da área de indicações." #: ../data/appstream/org.gnome.GPaste.Ui.appdata.xml.in.h:1 #: ../data/desktop/org.gnome.GPaste.Ui.desktop.in.in.h:1 msgid "Manage your clipboard history" msgstr "Gerencie seu histórico da área de transferência" #: ../data/appstream/org.gnome.GPaste.Ui.appdata.xml.in.h:3 msgid "" "GPaste provides you with a graphical tool allowing you to manage everything " "easily." msgstr "" "O GPaste fornece uma ferramenta gráfica que permite gerenciar tudo facilmente" #: ../data/desktop/org.gnome.GPaste.Applet.desktop.in.in.h:3 #: ../data/desktop/org.gnome.GPaste.AppIndicator.desktop.in.in.h:3 msgid "Clipboard;Manager;" msgstr "Clipboard;Manager;" #: ../data/desktop/org.gnome.GPaste.Ui.desktop.in.in.h:2 msgid "Clipboard;Manager;Settings;Preferences;Configuration;" msgstr "Clipboard;Manager;Settings;Preferences;Configuration;" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:1 msgid "Max size of an element when displaying it" msgstr "Tamanho máximo de um elemento ao exibir" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:2 msgid "" "The extra stuff of that element will be replaced by \"…\", and newlines by " "\" \" when displaying from the applet, 0 to disable." msgstr "" "O restante desse elemento será substituído por \"…\", e novas linhas por \" " "\" quando for exibido no applet, 0 para desabilitar." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:3 msgid "Do we detect and replace growing lines in history?" msgstr "Detectar e substituir linhas crescentes no histórico?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:4 msgid "" "By default, selecting \"Here is\", then \"Here is an example\" will create " "two entries in the history. With this feature enabled, the first one will be " "replaced by the second one." msgstr "" "Por padrão, selecionando \"Aqui está\", e então \"Aqui está um exemplo\" " "irá criar duas entradas no histórico. Com esse recurso habilitado, o " "primeiro será substituído pelo segundo." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:5 msgid "The name of the current history" msgstr "O nome do histórico atual" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:6 msgid "The default name is \"history\"" msgstr "O nome padrão é \"history\"" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:7 msgid "Do we save the images copied to history, or only text?" msgstr "Salvar as imagens copiadas para o histórico ou somente o texto?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:8 msgid "By default, we're saving both" msgstr "Por padrão, ambos são salvos" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:9 msgid "The keyboard shortcut to launch the graphical interface" msgstr "O atalho do teclado para executar a interface gráfica" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:10 msgid "" "By default, hitting ctrl + alt + g does that (\"<Ctrl><Alt>G\"). " "An empty string here disables this functionnality." msgstr "" "Por padrão, a combinação de teclas ctrl + alt + g faz isso (\"<Ctrl>" "<Alt>G\"). Deixar vazio aqui desabilita essa funcionalidade." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:11 msgid "The keyboard shortcut to mark the active item as being a password" msgstr "O atalho do teclado para marcar o item ativo como sendo uma senha" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:12 msgid "" "By default, hitting ctrl + alt + s will mark the active item as being a " "password (\"<Ctrl><Alt>S\"). An empty string here disables this " "functionnality." msgstr "" "Por padrão, a combinação de teclas ctrl + alt + s exibe o menu (\"<" "Ctrl><Alt>S\"). Deixar vazio aqui desabilita essa funcionalidade." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:13 msgid "Max displayed history size" msgstr "Tamanho máximo do histórico ao exibir" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:14 msgid "Maximum number of items displayed in the history" msgstr "Número máximo de itens exibidos no histórico" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:15 msgid "Max history size" msgstr "Tamanho máximo do histórico" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:16 msgid "Maximum number of items in history" msgstr "Número máximo de itens no histórico" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:17 msgid "Max memory usage (MB)" msgstr "Uso máximo de memória (MB)" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:18 msgid "Maximum amount of memory used to store contents" msgstr "Quantidade máxima de memória utilizada para armazenamento" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:19 msgid "Max text item size" msgstr "Tamanho máximo do item de texto" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:20 msgid "Maximum size of a text item. Anything out of this boundary is ignored." msgstr "" "Tamanho máximo de um item de texto. Qualquer coisa fora desse limite é " "ignorado." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:21 msgid "Min text item size" msgstr "Tamanho mínimo do item de texto" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:22 msgid "Minimum size of a text item. Anything out of this boundary is ignored." msgstr "" "Tamanho mínimo de um item de texto. Qualquer coisa fora desse limite é " "ignorado." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:23 msgid "The keyboard shortcut to delete the first element in history" msgstr "O atalho do teclado para apagar o primeiro elemento no histórico" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:24 msgid "" "By default, hitting ctrl + alt + v does that (\"<Ctrl><Alt>V\"). " "An empty string here disables this functionnality." msgstr "" "Por padrão, a combinação de teclas ctrl + alt + v faz isso (\"<Ctrl>" "<Alt>V\"). Deixar vazio aqui desabilita essa funcionalidade." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:25 msgid "Does the primary selection affects history?" msgstr "Seleção primária afeta o histórico?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:26 msgid "By default, only clipboard (ctrl+c) affects history." msgstr "" "Por padrão, somente a área de transferência (ctrl+c) afeta o histórico." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:27 msgid "Do we save the history from one session to another?" msgstr "Salvar o histórico entre uma sessão e outra?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:28 msgid "By default, we're saving it" msgstr "Por padrão, ele é salvo" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:29 msgid "The keyboard shortcut to display the menu" msgstr "O atalho do teclado para exibir o menu" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:30 msgid "" "By default, hitting ctrl + alt + h displays the menu (\"<Ctrl><" "Alt>H\"). An empty string here disables this functionnality." msgstr "" "Por padrão, a combinação de teclas ctrl + alt + h exibe o menu (\"<" "Ctrl><Alt>H\"). Deixar vazio aqui desabilita essa funcionalidade." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:31 msgid "The keyboard shortcut to sync the clipboard to the primary selection" msgstr "" "Atalho do teclado para sincronizar a área de transferência com a seleção " "primária" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:32 msgid "" "By default, hitting ctrl + alt + o syncs them (\"<Ctrl><Alt>P" "\"). An empty string here disables this functionnality." msgstr "" "Por padrão, teclando ctrl + alt + o faz a sincronização (\"<Ctrl><" "Alt>P\"). Uma string vazia aqui desabilita essa funcionalidade." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:33 msgid "The keyboard shortcut to sync the primary selection to the clipboard" msgstr "" "Atalho do teclado para sincronizar a seleção primária com a área de " "transferência" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:34 msgid "" "By default, hitting ctrl + alt + p syncs them (\"<Ctrl><Alt>P" "\"). An empty string here disables this functionnality." msgstr "" "Por padrão, teclando ctrl + alt + p faz a sincronização (\"<Ctrl><" "Alt>P\"). Uma string vazia aqui desabilita essa funcionalidade." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:35 msgid "Are the primary selection and the clipboard synchronized?" msgstr "Seleção primária e a área de transferência estão sincronizadas?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:36 msgid "By default, the primary selection and the clipboard are independent." msgstr "" "Por padrão, seleção primária e área de transferência são independentes." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:37 msgid "Do we track the clipboard changes?" msgstr "Monitorar as alterações na área de transferência?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:38 msgid "By default, we're tracking those changes." msgstr "Por padrão, essas alterações são monitoradas." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:39 msgid "" "Do we sync the daemon state with the gnome-shell extension's one? (disable " "the daemon when disabling the extension)" msgstr "" "Sincronizar o estado do daemon com a extensão do gnome-shell? (desabilitar o " "daemon quando desabilitar a extensão)" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:40 msgid "By default, the daemon state keeps unchanged" msgstr "Por padrão, o estado do daemon se mantém inalterado" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:41 msgid "Do we trim the textual items before adding them to history?" msgstr "Aparar itens textuais antes de adicioná-los ao histórico?" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:42 msgid "" "Trimming means removing all trailing and ending spaces. By default, we're " "letting them as-is." msgstr "" "Aparar significa que espaços em branco antes e depois do texto serão " "removidos. Por padrão, é deixado como está." #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:43 msgid "" "The keyboard shortcut to upload the first element in history to a pastebin " "service" msgstr "" "O atalho do teclado para carregar o primeiro elemento do histórico para um " "serviço de pastebin" #: ../data/gsettings/org.gnome.GPaste.gschema.xml.h:44 msgid "" "By default, hitting ctrl + alt + u does that (\"<Ctrl><Alt>U\"). " "An empty string here disables this functionnality." msgstr "" "Por padrão, a combinação de teclas ctrl + alt + u faz isso (\"<Ctrl>" "<Alt>U\"). Deixar vazio aqui desabilita essa funcionalidade." #~ msgid "Signal %d received, exiting\n" #~ msgstr "Sinal %d recebido, saindo\n" #~ msgid "Empty history" #~ msgstr "Esvaziar histórico" #~ msgid "Backup history as: " #~ msgstr "Backup do histórico como: " #~ msgid "Ok" #~ msgstr "Ok" #~ msgid "Histories" #~ msgstr "Históricos" #~ msgid "Could not register DBus service." #~ msgstr "Não foi possível registrar o serviço DBus." #~ msgid "GPaste user interface" #~ msgstr "Interface de usuário do GPaste" #~ msgid "GPaste graphical interface" #~ msgstr "Interface gráfica do GPaste" #~ msgid "Manage GPaste" #~ msgstr "Gerenciar o GPaste" #~ msgid "GPaste daemon settings" #~ msgstr "Configurações do daemon GPaste" #~ msgid "Manage GPaste settings" #~ msgstr "Gerenciar as configurações do GPaste" #~ msgid "" #~ "GPaste provides you with a settings utility allowing you to customize its " #~ "behaviour as expected." #~ msgstr "" #~ "O GPaste fornece um utilitário de configurações que permite personalizar " #~ "o comportamento da maneira como você espera." #~ msgid "Manage the GPaste daemon settings" #~ msgstr "Gerenciar as configurações do daemon GPaste" #~ msgid "Stop tracking changes" #~ msgstr "Parar o monitoramento" #~ msgid "Track changes" #~ msgstr "Monitorar a área de transferência" #, fuzzy #~ msgid "print the history without newlines" #~ msgstr "imprime o histórico com os índices" #~ msgid "print the history (raw) without indexes" #~ msgstr "imprime o histórico (cru), sem os índices" #~ msgid "print the history with NUL as separator" #~ msgstr "imprime o histórico com um NULO como separador" #~ msgid "get the th item from the history (raw)" #~ msgstr "obtém o n-ésimo item do histórico (cru)" #~ msgid "Couldn't spawn gpaste-app-indicator.\n" #~ msgstr "Não foi possível abrir o gpaste-app-indicator.\n" GPaste-3.18.6/src/000077500000000000000000000000001305131721400135605ustar00rootroot00000000000000GPaste-3.18.6/src/app-indicator.mk000066400000000000000000000020571305131721400166470ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2014-2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . if ENABLE_UNITY pkglibexec_PROGRAMS += \ bin/gpaste-app-indicator \ $(NULL) bin_gpaste_app_indicator_SOURCES = \ src/app-indicator/gpaste-app-indicator.c \ $(NULL) bin_gpaste_app_indicator_CFLAGS = \ $(AM_CFLAGS) \ $(NULL) bin_gpaste_app_indicator_LDADD = \ $(builddir)/$(libgpaste_la_file) \ $(GTK_LIBS) \ $(AM_LIBS) \ $(NULL) endif GPaste-3.18.6/src/app-indicator/000077500000000000000000000000001305131721400163125ustar00rootroot00000000000000GPaste-3.18.6/src/app-indicator/gpaste-app-indicator.c000066400000000000000000000020521305131721400224700ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include gint main (gint argc, gchar *argv[]) { G_PASTE_INIT_APPLICATION ("AppIndicator"); G_GNUC_UNUSED g_autoptr (GPasteApplet) applet = g_paste_applet_new_app_indicator (app); return g_application_run (gapp, argc, argv); } GPaste-3.18.6/src/applet.mk000066400000000000000000000020061305131721400153740ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2012-2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . if ENABLE_APPLET pkglibexec_PROGRAMS += \ bin/gpaste-applet \ $(NULL) bin_gpaste_applet_SOURCES = \ src/applet/gpaste-applet.c \ $(NULL) bin_gpaste_applet_CFLAGS = \ $(AM_CFLAGS) \ $(NULL) bin_gpaste_applet_LDADD = \ $(builddir)/$(libgpaste_la_file) \ $(GTK_LIBS) \ $(AM_LIBS) \ $(NULL) endif GPaste-3.18.6/src/applet/000077500000000000000000000000001305131721400150455ustar00rootroot00000000000000GPaste-3.18.6/src/applet/gpaste-applet.c000066400000000000000000000020421305131721400177550ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include gint main (gint argc, gchar *argv[]) { G_PASTE_INIT_APPLICATION ("Applet"); G_GNUC_UNUSED g_autoptr (GPasteApplet) applet = g_paste_applet_new_status_icon (app); return g_application_run (gapp, argc, argv); } GPaste-3.18.6/src/daemon.mk000066400000000000000000000021161305131721400153540ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2012-2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . gpaste_daemon_binary = bin/gpaste-daemon pkglibexec_PROGRAMS += \ $(gpaste_daemon_binary) \ $(NULL) $(gpaste_daemon_binary): $(libgpaste_la_file) bin_gpaste_daemon_SOURCES = \ src/daemon/gpaste-daemon.c \ $(NULL) bin_gpaste_daemon_CFLAGS = \ $(AM_CFLAGS) \ $(NULL) bin_gpaste_daemon_LDADD = \ $(builddir)/$(libgpaste_la_file) \ $(GTK_LIBS) \ $(AM_LIBS) \ $(NULL) GPaste-3.18.6/src/daemon/000077500000000000000000000000001305131721400150235ustar00rootroot00000000000000GPaste-3.18.6/src/daemon/gpaste-daemon.c000066400000000000000000000101271305131721400177140ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include static GApplication *_app; enum { C_NAME_LOST, C_REEXECUTE_SELF, C_LAST_SIGNAL }; static void signal_handler (gint32 signum) { g_print ("Signal %" G_GINT32_FORMAT " received, exiting\n", signum); g_application_quit (_app); } G_GNUC_NORETURN static void on_name_lost (GPasteBus *bus G_GNUC_UNUSED, gpointer user_data) { GApplication *app = user_data; fprintf (stderr, "%s\n", _("Could not acquire DBus name.")); g_application_quit (app); exit (EXIT_FAILURE); } typedef struct { GPasteBus *bus; GPasteDaemon *daemon; GPasteBusObject **search_provider; GApplication *gapp; } CallbackData; static void register_bus_object (GPasteBus *bus, GPasteBusObject *object, GApplication *gapp) { g_autoptr (GError) error = NULL; if (!g_paste_bus_object_register_on_connection (object, g_paste_bus_get_connection (bus), &error)) on_name_lost (bus, gapp); } static gboolean register_search_provider (gpointer user_data) { CallbackData *data = user_data; GPasteBusObject *search_provider = *(data->search_provider) = g_paste_search_provider_new (); register_bus_object (data->bus, search_provider, data->gapp); return G_SOURCE_REMOVE; } static void on_bus_acquired (GPasteBus *bus, gpointer user_data) { CallbackData *data = user_data; register_bus_object (bus, G_PASTE_BUS_OBJECT (data->daemon), data->gapp); g_idle_add (register_search_provider, user_data); } static void reexec (GPasteDaemon *g_paste_daemon G_GNUC_UNUSED, gpointer user_data) { GApplication *app = user_data; g_application_quit (app); execl (PKGLIBEXECDIR "/gpaste-daemon", "gpaste-daemon", NULL); } gint main (gint argc, gchar *argv[]) { /* FIXME: remove this once gtk supports clipboard correctly on wayland */ gdk_set_allowed_backends ("x11"); G_PASTE_INIT_APPLICATION ("Daemon"); /* Keep the gapplication around */ g_application_hold (gapp); g_autofree CallbackData *data = g_new0 (CallbackData, 1); g_autoptr (GPasteDaemon) g_paste_daemon = data->daemon = g_paste_daemon_new (); g_autoptr (GPasteBusObject) search_provider = NULL; data->search_provider = &search_provider; _app = data->gapp = gapp; g_autoptr (GPasteBus) bus = data->bus = g_paste_bus_new (on_bus_acquired, data); gulong c_signals[C_LAST_SIGNAL] = { [C_NAME_LOST] = g_signal_connect (bus, "name-lost", G_CALLBACK (on_name_lost), gapp), [C_REEXECUTE_SELF] = g_signal_connect (g_paste_daemon, "reexecute-self", G_CALLBACK (reexec), gapp) }; signal (SIGTERM, &signal_handler); signal (SIGINT, &signal_handler); g_paste_bus_own_name (bus); gint64 exit_status = g_application_run (gapp, argc, argv); g_signal_handler_disconnect (bus, c_signals[C_NAME_LOST]); g_signal_handler_disconnect (g_paste_daemon, c_signals[C_REEXECUTE_SELF]); return exit_status; } GPaste-3.18.6/src/gnome-shell.mk000066400000000000000000000034761305131721400163350ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2012-2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . gnomeshelldir = $(datadir)/gnome-shell/extensions/GPaste@gnome-shell-extensions.gnome.org gnomeshell_extension_files = \ src/gnome-shell/aboutItem.js \ src/gnome-shell/deleteButton.js \ src/gnome-shell/deleteItemPart.js \ src/gnome-shell/dummyHistoryItem.js \ src/gnome-shell/emptyHistoryItem.js \ src/gnome-shell/extension.js \ src/gnome-shell/indicator.js \ src/gnome-shell/item.js \ src/gnome-shell/prefs.js \ src/gnome-shell/searchItem.js \ src/gnome-shell/stateSwitch.js \ src/gnome-shell/statusIcon.js \ src/gnome-shell/uiItem.js \ $(NULL) gnomeshell_metadata_file = src/gnome-shell/metadata.json SUFFIXES += .json .json.in .json.in.json: @ $(MKDIR_P) src/gnome-shell $(AM_V_GEN) $(SED) -e 's,[@]localedir[@],$(localedir),g' \ -e 's,[@]gettext_package[@],$(GETTEXT_PACKAGE),g' \ < $< > $@ if ENABLE_EXTENSION nodist_gnomeshell_DATA = \ $(gnomeshell_extension_files) \ $(gnomeshell_metadata_file) \ $(NULL) CLEANFILES += \ $(gnomeshell_metadata_file) \ $(NULL) endif EXTRA_DIST += \ $(gnomeshell_extension_files) \ $(gnomeshell_metadata_file:.json=.json.in) \ $(NULL) GPaste-3.18.6/src/gnome-shell/000077500000000000000000000000001305131721400157725ustar00rootroot00000000000000GPaste-3.18.6/src/gnome-shell/aboutItem.js000066400000000000000000000026471305131721400202720ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Lang = imports.lang; const St = imports.gi.St; const GPasteAboutItem = new Lang.Class({ Name: 'GPasteAboutItem', _init: function(client, menu) { this.actor = new St.Button({ reactive: true, can_focus: true, track_hover: true, style_class: 'system-menu-action' }); this.actor.child = new St.Icon({ icon_name: 'dialog-information-symbolic' }); this.actor.connect('clicked', function() { menu.itemActivated(); client.about(null); }); } }); GPaste-3.18.6/src/gnome-shell/deleteButton.js000066400000000000000000000030711305131721400207670ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Lang = imports.lang; const Clutter = imports.gi.Clutter; const St = imports.gi.St; const GPasteDeleteButton = new Lang.Class({ Name: 'GPasteDeleteButton', _init: function(client, index) { this.actor = new St.Button(); this.actor.child = new St.Icon({ icon_name: 'edit-delete-symbolic', style_class: 'popup-menu-icon' }); this._client = client; this.setIndex(index); this.actor.connect('clicked', Lang.bind(this, this._onClick)); }, setIndex: function(index) { this._index = index; }, _onClick: function() { this._client.delete(this._index, null); return Clutter.EVENT_STOP; } }); GPaste-3.18.6/src/gnome-shell/deleteItemPart.js000066400000000000000000000027151305131721400212450ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Lang = imports.lang; const St = imports.gi.St; const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); const DeleteButton = Me.imports.deleteButton; const GPasteDeleteItemPart = new Lang.Class({ Name: 'GPasteDeleteItemPart', _init: function(client, index) { this.actor = new St.Bin({ x_align: St.Align.END }); this._deleteButton = new DeleteButton.GPasteDeleteButton(client, index); this.actor.child = this._deleteButton.actor; }, setIndex: function(index) { this._deleteButton.setIndex(index); } }); GPaste-3.18.6/src/gnome-shell/dummyHistoryItem.js000066400000000000000000000025051305131721400216660ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Gettext = imports.gettext; const Lang = imports.lang; const PopupMenu = imports.ui.popupMenu; const _ = Gettext.domain('GPaste').gettext; const GPasteDummyHistoryItem = new Lang.Class({ Name: 'GPasteDummyHistoryItem', Extends: PopupMenu.PopupMenuItem, _init: function() { this.parent(_("(Couldn't connect to GPaste daemon)")); this.setSensitive(false); }, update: function() { this.label.text = _("(Empty)"); } }); GPaste-3.18.6/src/gnome-shell/emptyHistoryItem.js000066400000000000000000000030771305131721400216760ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Lang = imports.lang; const St = imports.gi.St; const GPasteEmptyHistoryItem = new Lang.Class({ Name: 'GPasteEmptyHistoryItem', _init: function(client) { this.actor = new St.Button({ reactive: true, can_focus: true, track_hover: true, style_class: 'system-menu-action' }); this.actor.child = new St.Icon({ icon_name: 'edit-clear-all-symbolic' }); this.actor.connect('clicked', function() { client.get_history_name(Lang.bind(this, function(client, result) { let name = client.get_history_name_finish(result); client.empty_history(name, null); })); }); } }); GPaste-3.18.6/src/gnome-shell/extension.js000066400000000000000000000026511305131721400203500ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Gettext = imports.gettext; const Main = imports.ui.main; const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); const Indicator = Me.imports.indicator; function init(extension) { let metadata = extension.metadata; Gettext.bindtextdomain(metadata.gettext_package, metadata.localedir); } function disable() { Main.panel.statusArea.gpaste.shutdown(); } function enable() { if (Main.panel.statusArea.gpaste) disable(); Main.panel.addToStatusArea('gpaste', new Indicator.GPasteIndicator()); } GPaste-3.18.6/src/gnome-shell/indicator.js000066400000000000000000000253421305131721400203120ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Gettext = imports.gettext; const Lang = imports.lang; const PanelMenu = imports.ui.panelMenu; const PopupMenu = imports.ui.popupMenu; const Clutter = imports.gi.Clutter; const GPaste = imports.gi.GPaste; const _ = Gettext.domain('GPaste').gettext; const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); const AboutItem = Me.imports.aboutItem; const DummyHistoryItem = Me.imports.dummyHistoryItem; const EmptyHistoryItem = Me.imports.emptyHistoryItem; const Item = Me.imports.item; const SearchItem = Me.imports.searchItem; const StateSwitch = Me.imports.stateSwitch; const StatusIcon = Me.imports.statusIcon; const UiItem = Me.imports.uiItem; const GPasteIndicator = new Lang.Class({ Name: 'GPasteIndicator', Extends: PanelMenu.Button, _init: function() { this.parent(0.0, "GPaste"); this._statusIcon = new StatusIcon.GPasteStatusIcon(); this.actor.add_child(this._statusIcon.actor); this._settings = new GPaste.Settings(); this._headerSize = 0; this._postHeaderSize = 0; this._history = []; this._preFooterSize = 0; this._footerSize = 0; this._searchResults = []; this._dummyHistoryItem = new DummyHistoryItem.GPasteDummyHistoryItem(); this._searchItem = new SearchItem.GPasteSearchItem(); this._searchItem.connect('text-changed', Lang.bind(this, this._onSearch)); this._settingsSizeChangedId = this._settings.connect('changed::element-size', Lang.bind(this, this._resetElementSize)); this._resetElementSize(); this.menu.connect('open-state-changed', Lang.bind(this, this._onOpenStateChanged)); this._actions = new PopupMenu.PopupBaseMenuItem({ reactive: false, can_focus: false }); this._addToPostHeader(this._dummyHistoryItem); this._addToPreFooter(new PopupMenu.PopupSeparatorMenuItem()); this._addToFooter(this._actions); GPaste.Client.new(Lang.bind(this, function (obj, result) { this._client = GPaste.Client.new_finish(result); this._dummyHistoryItem.update(); this._uiItem = new UiItem.GPasteUiItem(this.menu); this._emptyHistoryItem = new EmptyHistoryItem.GPasteEmptyHistoryItem(this._client); this._aboutItem = new AboutItem.GPasteAboutItem(this._client, this.menu); this._switch = new StateSwitch.GPasteStateSwitch(this._client); this._addToHeader(this._switch); this._addToHeader(this._searchItem); this._actions.actor.add(this._uiItem.actor, { expand: true, x_fill: false }); this._actions.actor.add(this._emptyHistoryItem.actor, { expand: true, x_fill: false }); this._actions.actor.add(this._aboutItem.actor, { expand: true, x_fill: false }); this._settingsMaxSizeChangedId = this._settings.connect('changed::max-displayed-history-size', Lang.bind(this, this._resetMaxDisplayedSize)); this._resetMaxDisplayedSize(); this._clientUpdateId = this._client.connect('update', Lang.bind(this, this._update)); this._clientShowId = this._client.connect('show-history', Lang.bind(this, this._popup)); this._clientTrackingId = this._client.connect('tracking', Lang.bind(this, this._toggle)); this._onStateChanged (true); this.menu.actor.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent)); this.menu.actor.connect('key-release-event', Lang.bind(this, this._onKeyReleaseEvent)); this._destroyed = false; this.actor.connect('destroy', Lang.bind(this, this._onDestroy)); })); }, shutdown: function() { this._onStateChanged (false); this._onDestroy(); this.destroy(); }, _onKeyPressEvent: function(actor, event) { if (event.has_control_modifier()) { let nb = parseInt(event.get_key_unicode()); if (nb != NaN && nb >= 0 && nb <= 9 && nb < this._history.length) { this._history[nb].activate(); } } else { this._maybeUpdateIndexVisibility(event, true); } }, _onKeyReleaseEvent: function(actor, event) { this._maybeUpdateIndexVisibility(event, false); }, _maybeUpdateIndexVisibility: function(event, state) { let key = event.get_key_symbol(); if (key == Clutter.KEY_Control_L || key == Clutter.KEY_Control_R) { this._updateIndexVisibility(state); } }, _updateIndexVisibility: function(state) { for (let i = 0; i < 10 && i < this._history.length; ++i) { this._history[i].showIndex(state); } }, _onSearch: function() { let search = this._searchItem.text.toLowerCase(); if (search.length > 0) { this._client.search(search, Lang.bind(this, function(client, result) { this._searchResults = client.search_finish(result); let results = this._searchResults.length; let maxSize = this._history.length; if (results > maxSize) results = maxSize; for (let i = 0; i < results; ++i) { this._history[i].setIndex(this._searchResults[i]); } for (let i = results; i < maxSize; ++i) { this._history[i].setIndex(-1); } })); } else { this._searchResults = []; this._refresh(0); } }, _resetElementSize: function() { let size = this._settings.get_element_size(); this._searchItem.resetSize(size/2 + 3); this._history.map(function(i) { i.setTextSize(size); }); }, _resetMaxDisplayedSize: function() { let oldSize = this._history.length; let newSize = this._settings.get_max_displayed_history_size(); let elementSize = this._settings.get_element_size(); if (newSize > oldSize) { for (let index = oldSize; index < newSize; ++index) { let item = new Item.GPasteItem(this._client, elementSize, index); this.menu.addMenuItem(item, this._headerSize + this._postHeaderSize + index); this._history[index] = item; } } else { for (let i = newSize; i < oldSize; ++i) { this._history.pop().destroy(); } } this._refresh(oldSize); }, _update: function(client, action, target, position) { switch (target) { case GPaste.UpdateTarget.ALL: this._refresh(0); break; case GPaste.UpdateTarget.POSITION: switch (action) { case GPaste.UpdateAction.REPLACE: this._history[position].refresh(); break; case GPaste.UpdateAction.REMOVE: this._refresh(position); break; } break; } }, _refresh: function(resetTextFrom) { if (this._searchResults.length > 0) { this._onSearch(); } else { this._client.get_history_name(Lang.bind(this, function(client, result) { let name = client.get_history_name_finish(result); this._client.get_history_size(name, Lang.bind(this, function(client, result) { let size = client.get_history_size_finish(result); let maxSize = this._history.length; if (size > maxSize) size = maxSize; for (let i = resetTextFrom; i < size; ++i) { this._history[i].setIndex(i); } for (let i = size ; i < maxSize; ++i) { this._history[i].setIndex(-1); } this._updateVisibility(size == 0); })); })); } }, _updateVisibility: function(empty) { if (empty) { this._dummyHistoryItem.actor.show(); this._emptyHistoryItem.actor.hide(); this._searchItem.actor.hide(); } else { this._dummyHistoryItem.actor.hide(); this._emptyHistoryItem.actor.show(); this._searchItem.actor.show(); } }, _popup: function() { this.menu.open(true); this._selectSearch(); }, _toggle: function(c, state) { this._switch.toggle(state); }, _selectSearch: function() { if (this._history.length > 0) { this._searchItem.grabFocus(); } }, _addToHeader: function(item) { this.menu.addMenuItem(item, this._headerSize++); }, _addToPostHeader: function(item) { this.menu.addMenuItem(item, this._headerSize + this._postHeaderSize++); }, _addToPreFooter: function(item) { this.menu.addMenuItem(item, this._headerSize + this._postHeaderSize + this._history.length + this._preFooterSize++); }, _addToFooter: function(item) { this.menu.addMenuItem(item, this._headerSize + this._postHeaderSize + this._history.length + this._preFooterSize + this._footerSize++); }, _onStateChanged: function(state) { this._client.on_extension_state_changed(state, null); }, _onOpenStateChanged: function(menu, state) { if (state) { this._searchItem.reset(); } else { this._updateIndexVisibility(false); } }, _onDestroy: function() { if (this._destroyed) { return; } this._destroyed = true; this._client.disconnect(this._clientUpdateId); this._client.disconnect(this._clientShowId); this._client.disconnect(this._clientTrackingId); this._settings.disconnect(this._settingsMaxSizeChangedId); this._settings.disconnect(this._settingsSizeChangedId); } }); GPaste-3.18.6/src/gnome-shell/item.js000066400000000000000000000074751305131721400173030ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Lang = imports.lang; const PopupMenu = imports.ui.popupMenu; const Clutter = imports.gi.Clutter; const Pango = imports.gi.Pango; const St = imports.gi.St; const GPaste = imports.gi.GPaste; const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); const DeleteItemPart = Me.imports.deleteItemPart; const GPasteItem = new Lang.Class({ Name: 'GPasteItem', Extends: PopupMenu.PopupMenuItem, _init: function(client, size, index) { this.parent(""); this._client = client; if (index <= 10) { this._indexLabel = new St.Label({ text: index + ': ' }); this._indexLabelVisible = false; } this.connect('activate', Lang.bind (this, this._onActivate)); this.actor.connect('key-press-event', Lang.bind(this, this._onKeyPressed)); this._deleteItem = new DeleteItemPart.GPasteDeleteItemPart(client, index); this.actor.add(this._deleteItem.actor, { expand: true, x_align: St.Align.END }); this.label.clutter_text.ellipsize = Pango.EllipsizeMode.END; this.setTextSize(size); this.setIndex(index); }, showIndex: function(state) { if (state) { if (!this._indexLabelVisible) { this.actor.insert_child_at_index(this._indexLabel, 1); } } else if (this._indexLabelVisible) { this.actor.remove_child(this._indexLabel); } this._indexLabelVisible = state; }, refresh: function() { this.setIndex(this._index); }, setIndex: function(index) { let oldIndex = this._index || -1; this._index = index; if (index == 0) { this.label.set_style("font-weight: bold;"); } else if (oldIndex == 0) { this.label.set_style(null); } this._deleteItem.setIndex(index); if (index != -1) { this._client.get_element(index, Lang.bind(this, function(client, result) { let text = client.get_element_finish(result).replace(/[\t\n\r]/g, ' '); if (text == this.label.get_text()) { return; } this.label.clutter_text.set_text(text); if (oldIndex == -1) { this.actor.show(); } })); } else { this.label.clutter_text.set_text(null); this.actor.hide(); } }, setTextSize: function(size) { this.label.clutter_text.max_length = size; }, _onActivate: function(actor, event) { this._client.select(this._index, null); }, _onKeyPressed: function(actor, event) { let symbol = event.get_key_symbol(); if (symbol == Clutter.KEY_BackSpace || symbol == Clutter.KEY_Delete) { this._client.delete(this._index, null); return Clutter.EVENT_STOP; } return Clutter.EVENT_PROPAGATE; } }); GPaste-3.18.6/src/gnome-shell/metadata.json.in000066400000000000000000000005461305131721400210570ustar00rootroot00000000000000{ "shell-version": [ "3.16", "3.18", "3.17.4", "3.17.90", "3.17.91", "3.17.92" ], "uuid": "GPaste@gnome-shell-extensions.gnome.org", "name": "GPaste", "description": "Clipboard management system", "url": "http://github.com/Keruspe/GPaste", "gettext_package": "@gettext_package@", "localedir": "@localedir@" } GPaste-3.18.6/src/gnome-shell/prefs.js000066400000000000000000000026571305131721400174610ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2013-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Gettext = imports.gettext; const Gtk = imports.gi.Gtk; const GPaste = imports.gi.GPaste; const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); function init() { let metadata = Me.metadata; Gettext.bindtextdomain(metadata.gettext_package, metadata.localedir); Gettext.textdomain(metadata.gettext_package); } function buildPrefsWidget() { let widget = new GPaste.SettingsUiWidget({ orientation: Gtk.Orientation.VERTICAL, margin: 12 }); if (widget) { widget.show_all(); } return widget; } GPaste-3.18.6/src/gnome-shell/searchItem.js000066400000000000000000000053411305131721400204170ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Lang = imports.lang; const PopupMenu = imports.ui.popupMenu; const Clutter = imports.gi.Clutter; const St = imports.gi.St; const GPasteSearchItem = new Lang.Class({ Name: 'GPasteSearchItem', Extends: PopupMenu.PopupBaseMenuItem, _init: function () { this.parent({ activate: false, reactive: true, hover: false, can_focus: false }); this._entry = new St.Entry({ name: 'GPasteSearchEntry', style_class:'search-entry', track_hover: true, reactive: true, can_focus: true }); this.actor.add(this._entry, { expand: true }); this._entry.set_primary_icon(new St.Icon({ style_class:'search-entry-icon', icon_name:'edit-find-symbolic' })); this._entry.clutter_text.connect('text-changed', Lang.bind(this, this._onTextChanged)); this._clearIcon = new St.Icon({ style_class: 'search-entry-icon', icon_name: 'edit-clear-symbolic' }); this._iconClickedId = 0; }, get text() { return this._entry.get_text(); }, resetSize: function(size) { this._entry.style = 'width: ' + size + 'em'; }, reset: function() { this._entry.text = ''; let text = this._entry.clutter_text; text.set_cursor_visible(true); text.set_selection(0, 0); }, grabFocus: function() { this._entry.grab_key_focus(); }, _onTextChanged: function(se, prop) { let dummy = (this.text.length == 0); this._entry.set_secondary_icon((dummy) ? null : this._clearIcon); if (!dummy && this._iconClickedId == 0) { this._iconClickedId = this._entry.connect('secondary-icon-clicked', Lang.bind(this, this.reset)); } this.emit('text-changed'); } }); GPaste-3.18.6/src/gnome-shell/stateSwitch.js000066400000000000000000000031551305131721400206360ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Gettext = imports.gettext; const Lang = imports.lang; const PopupMenu = imports.ui.popupMenu; const _ = Gettext.domain('GPaste').gettext; const GPasteStateSwitch = new Lang.Class({ Name: 'GPasteStateSwitch', Extends: PopupMenu.PopupSwitchMenuItem, _init: function(client) { this.parent(_("Track changes"), client.is_active()); this._client = client; this._fromDaemon = false; this.connect('toggled', Lang.bind(this, this._onToggle)); }, toggle: function(state) { this._fromDaemon = true; this.setToggleState(state); this._fromDaemon = false; }, _onToggle: function() { if (!this._fromDaemon) { this._client.track(this.state, null); } } }); GPaste-3.18.6/src/gnome-shell/statusIcon.js000066400000000000000000000027641305131721400204750ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Lang = imports.lang; const Clutter = imports.gi.Clutter; const St = imports.gi.St; const GPasteStatusIcon = new Lang.Class({ Name: 'GPasteStatusIcon', _init: function() { this.actor = new St.BoxLayout({ style_class: 'panel-status-menu-box' }); this.actor.add_child(new St.Icon({ icon_name: 'edit-paste-symbolic', style_class: 'system-status-icon' })); this.actor.add_child(new St.Icon({ style_class: 'popup-menu-arrow', icon_name: 'pan-down-symbolic', y_expand: true, y_align: Clutter.ActorAlign.CENTER })); } }); GPaste-3.18.6/src/gnome-shell/uiItem.js000066400000000000000000000026611305131721400175710ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Lang = imports.lang; const GPaste = imports.gi.GPaste; const St = imports.gi.St; const GPasteUiItem = new Lang.Class({ Name: 'GPasteUiItem', _init: function(menu) { this.actor = new St.Button({ reactive: true, can_focus: true, track_hover: true, style_class: 'system-menu-action' }); this.actor.child = new St.Icon({ icon_name: 'go-home-symbolic' }); this.actor.connect('clicked', function() { menu.itemActivated(); GPaste.util_spawn('Ui'); }); } }); GPaste-3.18.6/src/gpaste-client.mk000066400000000000000000000017401305131721400166520ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2012-2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . bin_PROGRAMS += \ bin/gpaste-client \ $(NULL) bin_gpaste_client_SOURCES = \ src/gpaste-client/gpaste-client.c \ $(NULL) bin_gpaste_client_CFLAGS = \ $(AM_CFLAGS) \ $(NULL) bin_gpaste_client_LDADD = \ $(builddir)/$(libgpaste_la_file) \ $(AM_LIBS) \ $(NULL) GPaste-3.18.6/src/gpaste-client/000077500000000000000000000000001305131721400163175ustar00rootroot00000000000000GPaste-3.18.6/src/gpaste-client/gpaste-client.c000066400000000000000000000517411305131721400212320ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2012-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include #include static void show_help (void) { const char *progname = g_get_prgname (); printf (_("Usage:\n")); /* Translators: help for gpaste history */ printf (" %s [history]: %s\n", progname, _("print the history with indexes")); /* Translators: help for gpaste history-size */ printf (" %s history-size: %s\n", progname, _("print the size of the history")); /* Translators: help for gpaste get-history */ printf (" %s get-history: %s\n", progname, _("get the name of the current history")); /* Translators: help for gpaste backup-history */ printf (" %s backup-history <%s>: %s\n", progname, _("name"), _("backup current history")); /* Translators: help for gpaste switch-history */ printf (" %s switch-history <%s>: %s\n", progname, _("name"), _("switch to another history")); /* Translators: help for gpaste delete-history */ printf (" %s delete-history <%s>: %s\n", progname, _("name"), _("delete a history")); /* Translators: help for gpaste list-histories */ printf (" %s list-histories: %s\n", progname, _("list available histories")); /* Translators: help for gpaste add */ printf (" %s add <%s>: %s\n", progname, _("text"), _("set text to clipboard")); /* Translators: help for gpaste add-password */ printf (" %s add-password <%s> <%s>: %s\n", progname, _("name"), _("password"), _("add the name - password couple to the clipboard")); /* Translators: help for gpaste rename-password */ printf (" %s rename-password <%s> <%s>: %s\n", progname, _("old name"), _("new name"), _("rename the password")); /* Translators: help for gpaste get */ printf (" %s get <%s>: %s\n", progname, _("number"), _("get the th item from the history")); /* Translators: help for gpaste select */ printf (" %s select <%s>: %s\n", progname, _("number"), _("set the th item from the history to the clipboard")); /* Translators: help for gpaste replace */ printf (" %s replace <%s> <%s>: %s\n", progname, _("number"), _("contents"), _("replace the contents of the th item from the history with the provided one")); /* Translators: help for gpaste merge */ printf (" %s merge <%s> … <%s>: %s\n", progname, _("number"), _("number"), _("merge the th items from the history and add put the result in the clipboard")); /* Translators: help for gpaste set-password */ printf (" %s set-password <%s> <%s>: %s\n", progname, _("number"), _("name"), _("set the th item from the history as a password named ")); /* Translators: help for gpaste delete */ printf (" %s delete <%s>: %s\n", progname, _("number"), _("delete th item of the history")); /* Translators: help for gpaste delete-passworf */ printf (" %s delete-password <%s>: %s\n", progname, _("name"), _("delete the password from the history")); /* Translators: help for gpaste file */ printf (" %s file <%s>: %s\n", progname, _("path"), _("put the content of the file at into the clipboard")); /* Translators: help for whatever | gpaste */ printf (" %s | %s: %s\n", _("whatever"), progname, _("set the output of whatever to clipboard")); /* Translators: help for gpaste empty */ printf (" %s empty: %s\n", progname, _("empty the history")); /* Translators: help for gpaste start */ printf (" %s start: %s\n", progname, _("start tracking clipboard changes")); /* Translators: help for gpaste stop */ printf (" %s stop: %s\n", progname, _("stop tracking clipboard changes")); /* Translators: help for gpaste quit */ printf (" %s quit: %s\n", progname, _("alias for stop")); /* Translators: help for gpaste daemon-reexec */ printf (" %s daemon-reexec: %s\n", progname, _("reexecute the daemon (after upgrading...)")); /* Translators: help for gpaste settings */ printf (" %s settings: %s\n", progname, _("launch the configuration tool")); /* Translators: help for gpaste ui */ printf (" %s ui: %s\n", progname, _("launch the graphical tool")); if (g_paste_util_has_applet ()) { /* Translators: help for gpaste applet */ printf (" %s applet: %s\n", progname, _("launch the applet")); } if (g_paste_util_has_unity ()) { /* Translators: help for gpaste app-indicator */ printf (" %s app-indicator: %s\n", progname, _("launch the unity application indicator")); } /* Translators: help for gpaste show-history */ printf (" %s show-history: %s\n", progname, _("make the applet or extension display the history")); /* Translators: help for gpaste upload */ printf (" %s upload <%s>: %s\n", progname, _("number"), _("upload the th item to a pastebin service")); /* Translators: help for gpaste version */ printf (" %s version: %s\n", progname, _("display the version")); /* Translators: help for gpaste daemon-version */ printf (" %s daemon-version: %s\n", progname, _("display the daemon version")); /* Translators: help for gpaste help */ printf (" %s help: %s\n", progname, _("display this help")); /* Translators: help for gpaste about */ printf (" %s about: %s\n", progname, _("display the about dialog")); printf("\n"); printf(_("Display options:")); printf("\n"); /* Translators: help for --oneline */ printf(" --oneline: %s\n", _("display each item on only one line")); /* Translators: help for --oneline */ printf(" --raw: %s\n", _("display each item raw (without line numbers)")); /* Translators: help for --oneline */ printf(" --zero: %s\n", _("use a NUL character instead of a new line betweean each item")); printf("\n"); printf(_("Merge options:")); printf("\n"); /* Translators: help for --decoration */ printf(" --decoration <%s>: %s\n", _("string"), _("add the given decoration to the beginning and the end of each item before merging")); /* Translators: help for --separator */ printf(" --separator <%s>: %s\n", _("string"), _("add the given separator between each item when merging")); } static void show_version (void) { printf ("%s\n", PACKAGE_STRING); } static const gchar * strip_newline (gchar *str) { for (gchar *s = str; *s; ++s) { if (*s == '\n') *s = ' '; } return str; } static void print_history_line (gchar *line, guint64 index, gboolean oneline, gboolean raw, gboolean zero) { if (!raw) printf ("%" G_GUINT64_FORMAT ": ", index); printf ("%s%c", (oneline) ? strip_newline (line) : line, (zero) ? '\0' : '\n'); } static void show_history (GPasteClient *client, gboolean oneline, gboolean raw, gboolean zero, GError **error) { g_auto (GStrv) history = (raw) ? g_paste_client_get_raw_history_sync (client, error) : g_paste_client_get_history_sync (client, error); if (!*error) { guint64 i = 0; for (GStrv h = history; *h; ++h) print_history_line (*h, i++, oneline, raw, zero); } } static inline gboolean is_version (const gchar *option) { return (!g_strcmp0 (option, "v") || !g_strcmp0 (option, "version")); } G_GNUC_NORETURN static void failure_exit (GError *error) { g_critical ("%s: %s\n", _("Couldn't connect to GPaste daemon"), (error) ? error->message: "unknown error"); exit (EXIT_FAILURE); } static gint64 spawn (const gchar *app) { g_autoptr (GError) error = NULL; if (!g_paste_util_spawn_sync (app, &error)) { g_critical ("%s %s: %s", _("Couldn't spawn"), app, error->message); return EXIT_FAILURE; } return EXIT_SUCCESS; } static guint64 _strtoull (const gchar *str) { return g_ascii_strtoull (str, NULL, 0); } gint main (gint argc, gchar *argv[]) { G_PASTE_INIT_GETTEXT (); g_set_prgname (argv[0]); struct option long_options[] = { { "decoration", required_argument, NULL, 'd' }, { "help", no_argument, NULL, 'h' }, { "oneline", no_argument, NULL, 'o' }, { "raw" , no_argument, NULL, 'r' }, { "separator" , required_argument, NULL, 's' }, { "version", no_argument, NULL, 'v' }, { "zero", no_argument, NULL, 'z' }, { NULL, no_argument, NULL, '\0' } }; gboolean help = FALSE, version = FALSE; gboolean oneline = FALSE, raw = FALSE, zero = FALSE; const gchar *decoration = NULL, *separator = NULL; gint64 c; while ((c = getopt_long(argc, argv, "d:hors:vz", long_options, NULL)) != -1) { switch (c) { case 'd': decoration = optarg; break; case 'h': help = TRUE; break; case 'o': oneline = TRUE; break; case 'r': raw = TRUE; break; case 's': separator = optarg; break; case 'v': version = TRUE; break; case 'z': zero = TRUE; break; default: return EXIT_FAILURE; } } argv += optind; argc -= optind; if (help || (argc > 0 && !g_strcmp0 (argv[0], "help"))) { show_help (); return EXIT_SUCCESS; } else if (version || (argc > 0 && is_version (argv[0]))) { show_version (); return EXIT_SUCCESS; } gint64 status = EXIT_SUCCESS; g_autoptr (GError) error = NULL; g_autoptr (GPasteClient) client = g_paste_client_new_sync (&error); if (!client) failure_exit (error); gboolean was_valid_pipe = FALSE; if (!isatty (fileno (stdin))) { /* We are being piped */ g_autoptr (GString) data = g_string_new (NULL); while ((c = fgetc (stdin)) != EOF) data = g_string_append_c (data, (guchar)c); data->str[data->len - 1] = '\0'; if (!argc) { g_paste_client_add_sync (client, data->str, &error); was_valid_pipe = TRUE; } else if (argc == 2) { const gchar *arg1 = argv[0]; const gchar *arg2 = argv[1]; if (!g_strcmp0 (arg1, "ap") || !g_strcmp0 (arg1, "add-password")) { g_paste_client_add_password_sync (client, arg2, data->str, &error); was_valid_pipe = TRUE; } else if (!g_strcmp0 (arg1, "replace")) { g_paste_client_replace_sync (client, _strtoull (arg2), data->str, &error); was_valid_pipe = TRUE; } } } if (was_valid_pipe) {} else if (argc > 0 && (!g_strcmp0 (argv[0], "merge") || !g_strcmp0 (argv[0], "m"))) { --argc; ++argv; guint64 *indexes = alloca (argc * sizeof (guint64)); for (gint64 i = 0; i < argc; ++i) indexes[i] = _strtoull (argv[i]); g_paste_client_merge_sync (client, decoration, separator, indexes, argc, &error); } else { const gchar *arg1, *arg2, *arg3; switch (argc) { case 0: show_history (client, oneline, raw, zero, &error); break; case 1: arg1 = argv[0]; if (!g_strcmp0 (arg1, "about")) { g_paste_client_about_sync (client, &error); } else if (!g_strcmp0 (arg1, "dr") || !g_strcmp0 (arg1, "daemon-reexec")) { g_paste_client_reexecute_sync (client, &error); if (error && error->code == G_DBUS_ERROR_NO_REPLY) { printf (_("Successfully reexecuted the daemon\n")); return EXIT_SUCCESS; } } else if (!g_strcmp0 (arg1, "dv") || !g_strcmp0 (arg1, "daemon-version")) { g_autofree gchar *v = g_paste_client_get_version (client); printf ("%s\n", v); } else if (!g_strcmp0 (arg1, "e") || !g_strcmp0 (arg1, "empty")) { g_autofree gchar *name = g_paste_client_get_history_name_sync (client, &error); if (!error) g_paste_client_empty_history_sync (client, name, &error); } else if (!g_strcmp0 (arg1, "gh") || !g_strcmp0 (arg1, "get-history")) { g_autofree gchar *name = g_paste_client_get_history_name_sync (client, &error); printf("%s\n", name); } else if (!g_strcmp0 (arg1, "h") || !g_strcmp0 (arg1, "history")) { show_history (client, oneline, raw, zero, &error); } else if (!g_strcmp0 (arg1, "hs") || !g_strcmp0 (arg1, "history-size")) { g_autofree gchar *name = g_paste_client_get_history_name_sync (client, &error); if (!error) { guint64 size = g_paste_client_get_history_size_sync (client, name, &error); if (!error) printf ("%" G_GUINT64_FORMAT "\n", size); } } else if (!g_strcmp0 (arg1, "lh") || !g_strcmp0 (arg1, "list-histories")) { g_auto (GStrv) histories = g_paste_client_list_histories_sync (client, &error); if (!error) { for (GStrv h = histories; *h; ++h) printf ("%s\n", *h); } } else if (!g_strcmp0 (arg1, "settings") || !g_strcmp0 (arg1, "p") || !g_strcmp0 (arg1, "preferences")) { if (!g_paste_util_activate_ui_sync ("prefs", NULL, &error)) { g_critical ("%s Ui: %s", _("Couldn't spawn"), error->message); return EXIT_FAILURE; } } else if (!g_strcmp0 (arg1, "show-history")) { g_paste_client_show_history_sync (client, &error); } else if (!g_strcmp0 (arg1, "start") || !g_strcmp0 (arg1, "d") || !g_strcmp0 (arg1, "daemon")) { g_paste_client_track_sync (client, TRUE, &error); } else if (!g_strcmp0 (arg1, "stop") || !g_strcmp0 (arg1, "q") || !g_strcmp0 (arg1, "quit")) { g_paste_client_track_sync (client, FALSE, &error); } else if (!g_strcmp0 (arg1, "ui")) { status = spawn ("Ui"); } else if (g_paste_util_has_applet () && !g_strcmp0 (arg1, "applet")) { status = spawn ("Applet"); } else if (g_paste_util_has_unity () && !g_strcmp0 (arg1, "app-indicator")) { status = spawn ("AppIndicator"); } else { show_help (); status = EXIT_FAILURE; } break; case 2: arg1 = argv[0]; arg2 = argv[1]; if (!g_strcmp0 (arg1, "a") || !g_strcmp0 (arg1, "add")) { g_paste_client_add_sync (client, arg2, &error); } else if (!g_strcmp0 (arg1, "bh") || !g_strcmp0 (arg1, "backup-history")) { g_autofree gchar *name = g_paste_client_get_history_name_sync (client, &error); if (!error) g_paste_client_backup_history_sync (client, name, arg2, &error); } else if (!g_strcmp0 (arg1, "d") || !g_strcmp0 (arg1, "del") || !g_strcmp0 (arg1, "delete") || !g_strcmp0 (arg1, "rm") || !g_strcmp0 (arg1, "remove")) { g_paste_client_delete_sync (client, _strtoull (arg2), &error); } else if (!g_strcmp0 (arg1, "dp") || !g_strcmp0 (arg1, "delete-password")) { g_paste_client_delete_password_sync (client, arg2, &error); } else if (!g_strcmp0 (arg1, "dh") || !g_strcmp0 (arg1, "delete-history")) { g_paste_client_delete_history_sync (client, arg2, &error); } else if (!g_strcmp0 (arg1, "f") || !g_strcmp0 (arg1, "file")) { g_paste_client_add_file_sync (client, arg2, &error); } else if (!g_strcmp0 (arg1, "g") || !g_strcmp0 (arg1, "get")) { const gchar *value = (!raw) ? g_paste_client_get_element_sync (client, _strtoull (arg2), &error) : g_paste_client_get_raw_element_sync (client, _strtoull (arg2), &error); if (!error) printf ("%s", value); } else if (!g_strcmp0 (arg1, "search")) { guint64 hits; g_autofree guint64 *results = g_paste_client_search_sync (client, arg2, &hits, &error); if (!error) { if (hits > 0) { for (guint64 i = 0; i < hits; ++i) { guint64 index = results[i]; gchar *line = g_paste_client_get_element_sync (client, index, &error); if (error) break; print_history_line (line, index, oneline, raw, zero); } } } } else if (!g_strcmp0 (arg1, "s") || !g_strcmp0 (arg1, "set") || !g_strcmp0 (arg1, "select")) { g_paste_client_select_sync (client, _strtoull (arg2), &error); } else if (!g_strcmp0 (arg1, "sh") || !g_strcmp0 (arg1, "switch-history")) { g_paste_client_switch_history_sync (client, arg2, &error); } else if (!g_strcmp0 (arg1, "u") || !g_strcmp0 (arg1, "upload")) { g_paste_client_upload_sync (client, _strtoull (arg2), &error); } else { show_help (); status = EXIT_FAILURE; } break; case 3: arg1 = argv[0]; arg2 = argv[1]; arg3 = argv[2]; if (!g_strcmp0 (arg1, "ap") || !g_strcmp0 (arg1, "add-password")) { g_paste_client_add_password_sync (client, arg2, arg3, &error); } else if (!g_strcmp0 (arg1, "rp") || !g_strcmp0 (arg1, "rename-password")) { g_paste_client_rename_password_sync (client, arg2, arg3, &error); } else if (!g_strcmp0 (arg1, "replace")) { g_paste_client_replace_sync (client, _strtoull (arg2), arg3, &error); } else if (!g_strcmp0 (arg1, "sp") || !g_strcmp0 (arg1, "set-password")) { g_paste_client_set_password_sync (client, _strtoull (arg2), arg3, &error); } else { show_help (); status = EXIT_FAILURE; } break; default: show_help (); status = EXIT_FAILURE; break; } } if (error) failure_exit (error); return status; } GPaste-3.18.6/src/libgpaste.mk000066400000000000000000000172371305131721400160750ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2014-2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . libgpaste_la_file = lib/libgpaste.la lib_libgpaste_la_private_headers = \ src/libgpaste/gpaste-gdbus-macros.h \ $(NULL) lib_libgpaste_la_misc_headers = \ src/libgpaste/gpaste-gdbus-defines.h \ src/libgpaste/gpaste-gsettings-keys.h \ src/libgpaste/gpaste-macros.h \ src/libgpaste/util/gpaste-util.h \ $(NULL) lib_libgpaste_la_public_headers = \ src/libgpaste/gpaste.h \ src/libgpaste/applet/gpaste-applet.h \ src/libgpaste/applet/gpaste-applet-about.h \ src/libgpaste/applet/gpaste-applet-icon.h \ src/libgpaste/applet/gpaste-applet-menu.h \ src/libgpaste/applet/gpaste-applet-quit.h \ src/libgpaste/applet/gpaste-applet-status-icon.h \ src/libgpaste/applet/gpaste-applet-ui.h \ src/libgpaste/client/gpaste-client.h \ src/libgpaste/core/gpaste-clipboard.h \ src/libgpaste/core/gpaste-clipboards-manager.h \ src/libgpaste/core/gpaste-history.h \ src/libgpaste/core/gpaste-image-item.h \ src/libgpaste/core/gpaste-item.h \ src/libgpaste/core/gpaste-password-item.h \ src/libgpaste/core/gpaste-text-item.h \ src/libgpaste/core/gpaste-item-enums.h \ src/libgpaste/core/gpaste-update-enums.h \ src/libgpaste/core/gpaste-uris-item.h \ src/libgpaste/daemon/gpaste-bus.h \ src/libgpaste/daemon/gpaste-bus-object.h \ src/libgpaste/daemon/gpaste-daemon.h \ src/libgpaste/daemon/gpaste-search-provider.h \ src/libgpaste/gnome-shell-client/gpaste-gnome-shell-client.h \ src/libgpaste/keybinder/gpaste-keybinder.h \ src/libgpaste/keybinder/gpaste-keybinding.h \ src/libgpaste/keybinder/gpaste-make-password-keybinding.h \ src/libgpaste/keybinder/gpaste-pop-keybinding.h \ src/libgpaste/keybinder/gpaste-show-history-keybinding.h \ src/libgpaste/keybinder/gpaste-sync-clipboard-to-primary-keybinding.h \ src/libgpaste/keybinder/gpaste-sync-primary-to-clipboard-keybinding.h \ src/libgpaste/keybinder/gpaste-ui-keybinding.h \ src/libgpaste/keybinder/gpaste-upload-keybinding.h \ src/libgpaste/screensaver-client/gpaste-screensaver-client.h \ src/libgpaste/settings/gpaste-settings.h \ src/libgpaste/settings-ui/gpaste-settings-ui-panel.h \ src/libgpaste/settings-ui/gpaste-settings-ui-stack.h \ src/libgpaste/settings-ui/gpaste-settings-ui-widget.h \ src/libgpaste/ui/gpaste-ui-about.h \ src/libgpaste/ui/gpaste-ui-backup-history.h \ src/libgpaste/ui/gpaste-ui-delete-history.h \ src/libgpaste/ui/gpaste-ui-delete-item.h \ src/libgpaste/ui/gpaste-ui-edit-item.h \ src/libgpaste/ui/gpaste-ui-empty-history.h \ src/libgpaste/ui/gpaste-ui-empty-item.h \ src/libgpaste/ui/gpaste-ui-header.h \ src/libgpaste/ui/gpaste-ui-history.h \ src/libgpaste/ui/gpaste-ui-history-action.h \ src/libgpaste/ui/gpaste-ui-history-actions.h \ src/libgpaste/ui/gpaste-ui-item.h \ src/libgpaste/ui/gpaste-ui-item-action.h \ src/libgpaste/ui/gpaste-ui-item-skeleton.h \ src/libgpaste/ui/gpaste-ui-panel.h \ src/libgpaste/ui/gpaste-ui-panel-history.h \ src/libgpaste/ui/gpaste-ui-reexec.h \ src/libgpaste/ui/gpaste-ui-search.h \ src/libgpaste/ui/gpaste-ui-search-bar.h \ src/libgpaste/ui/gpaste-ui-settings.h \ src/libgpaste/ui/gpaste-ui-switch.h \ src/libgpaste/ui/gpaste-ui-upload-item.h \ src/libgpaste/ui/gpaste-ui-window.h \ $(NULL) lib_libgpaste_la_source_files = \ src/libgpaste/applet/gpaste-applet.c \ src/libgpaste/applet/gpaste-applet-about.c \ src/libgpaste/applet/gpaste-applet-icon.c \ src/libgpaste/applet/gpaste-applet-menu.c \ src/libgpaste/applet/gpaste-applet-quit.c \ src/libgpaste/applet/gpaste-applet-status-icon.c \ src/libgpaste/applet/gpaste-applet-ui.c \ src/libgpaste/client/gpaste-client.c \ src/libgpaste/core/gpaste-clipboard.c \ src/libgpaste/core/gpaste-clipboards-manager.c \ src/libgpaste/core/gpaste-history.c \ src/libgpaste/core/gpaste-image-item.c \ src/libgpaste/core/gpaste-item.c \ src/libgpaste/core/gpaste-password-item.c \ src/libgpaste/core/gpaste-text-item.c \ src/libgpaste/core/gpaste-item-enums.c \ src/libgpaste/core/gpaste-update-enums.c \ src/libgpaste/core/gpaste-uris-item.c \ src/libgpaste/daemon/gpaste-bus.c \ src/libgpaste/daemon/gpaste-bus-object.c \ src/libgpaste/daemon/gpaste-daemon.c \ src/libgpaste/daemon/gpaste-search-provider.c \ src/libgpaste/gnome-shell-client/gpaste-gnome-shell-client.c \ src/libgpaste/keybinder/gpaste-keybinder.c \ src/libgpaste/keybinder/gpaste-keybinding.c \ src/libgpaste/keybinder/gpaste-make-password-keybinding.c \ src/libgpaste/keybinder/gpaste-pop-keybinding.c \ src/libgpaste/keybinder/gpaste-show-history-keybinding.c \ src/libgpaste/keybinder/gpaste-sync-clipboard-to-primary-keybinding.c \ src/libgpaste/keybinder/gpaste-sync-primary-to-clipboard-keybinding.c \ src/libgpaste/keybinder/gpaste-ui-keybinding.c \ src/libgpaste/keybinder/gpaste-upload-keybinding.c \ src/libgpaste/screensaver-client/gpaste-screensaver-client.c \ src/libgpaste/settings/gpaste-settings.c \ src/libgpaste/settings-ui/gpaste-settings-ui-panel.c \ src/libgpaste/settings-ui/gpaste-settings-ui-stack.c \ src/libgpaste/settings-ui/gpaste-settings-ui-widget.c \ src/libgpaste/ui/gpaste-ui-about.c \ src/libgpaste/ui/gpaste-ui-backup-history.c \ src/libgpaste/ui/gpaste-ui-delete-history.c \ src/libgpaste/ui/gpaste-ui-delete-item.c \ src/libgpaste/ui/gpaste-ui-edit-item.c \ src/libgpaste/ui/gpaste-ui-empty-history.c \ src/libgpaste/ui/gpaste-ui-empty-item.c \ src/libgpaste/ui/gpaste-ui-header.c \ src/libgpaste/ui/gpaste-ui-history.c \ src/libgpaste/ui/gpaste-ui-history-action.c \ src/libgpaste/ui/gpaste-ui-history-actions.c \ src/libgpaste/ui/gpaste-ui-item.c \ src/libgpaste/ui/gpaste-ui-item-action.c \ src/libgpaste/ui/gpaste-ui-item-skeleton.c \ src/libgpaste/ui/gpaste-ui-panel.c \ src/libgpaste/ui/gpaste-ui-panel-history.c \ src/libgpaste/ui/gpaste-ui-reexec.c \ src/libgpaste/ui/gpaste-ui-search.c \ src/libgpaste/ui/gpaste-ui-search-bar.c \ src/libgpaste/ui/gpaste-ui-settings.c \ src/libgpaste/ui/gpaste-ui-switch.c \ src/libgpaste/ui/gpaste-ui-upload-item.c \ src/libgpaste/ui/gpaste-ui-window.c \ src/libgpaste/util/gpaste-util.c \ $(NULL) if ENABLE_UNITY lib_libgpaste_la_public_headers += \ src/libgpaste/applet/gpaste-applet-app-indicator.h \ $(NULL) lib_libgpaste_la_source_files += \ src/libgpaste/applet/gpaste-applet-app-indicator.c \ $(NULL) endif lib_libgpaste_la_SOURCES = \ $(lib_libgpaste_la_private_headers) \ $(lib_libgpaste_la_source_files) \ $(NULL) lib_libgpaste_la_CFLAGS = \ $(GDK_CFLAGS) \ $(GDK_PIXBUF_CFLAGS) \ $(UNITY_CFLAGS) \ $(X11_CFLAGS) \ $(AM_CFLAGS) \ $(NULL) lib_libgpaste_la_LIBADD = \ $(GDK_LIBS) \ $(GDK_PIXBUF_LIBS) \ $(GTK_LIBS) \ $(UNITY_LIBS) \ $(X11_LIBS) \ $(AM_LIBS) \ $(NULL) libgpaste_symbols_file = $(srcdir)/src/libgpaste/libgpaste.sym lib_libgpaste_la_LDFLAGS = \ -version-info $(LIBGPASTE_LT_VERSION) \ -Wl,--version-script=$(libgpaste_symbols_file) \ $(NULL) lib_libgpaste_la_DEPENDENCIES = \ $(libgpaste_symbols_file) \ $(NULL) pkginclude_HEADERS += \ $(lib_libgpaste_la_misc_headers) \ $(lib_libgpaste_la_public_headers) \ $(NULL) lib_LTLIBRARIES += \ $(libgpaste_la_file) \ $(NULL) EXTRA_DIST += \ $(libgpaste_symbols_file) \ $(NULL) GPaste-3.18.6/src/libgpaste/000077500000000000000000000000001305131721400155325ustar00rootroot00000000000000GPaste-3.18.6/src/libgpaste/applet/000077500000000000000000000000001305131721400170175ustar00rootroot00000000000000GPaste-3.18.6/src/libgpaste/applet/gpaste-applet-about.c000066400000000000000000000051761305131721400230520ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include struct _GPasteAppletAbout { GtkMenuItem parent_instance; }; typedef struct { GPasteClient *client; } GPasteAppletAboutPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteAppletAbout, g_paste_applet_about, GTK_TYPE_MENU_ITEM) static void g_paste_applet_about_activate (GtkMenuItem *menu_item) { GPasteAppletAboutPrivate *priv = g_paste_applet_about_get_instance_private (G_PASTE_APPLET_ABOUT (menu_item)); g_paste_client_about (priv->client, NULL, NULL); GTK_MENU_ITEM_CLASS (g_paste_applet_about_parent_class)->activate (menu_item); } static void g_paste_applet_about_dispose (GObject *object) { GPasteAppletAboutPrivate *priv = g_paste_applet_about_get_instance_private (G_PASTE_APPLET_ABOUT (object)); g_clear_object (&priv->client); G_OBJECT_CLASS (g_paste_applet_about_parent_class)->dispose (object); } static void g_paste_applet_about_class_init (GPasteAppletAboutClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_applet_about_dispose; GTK_MENU_ITEM_CLASS (klass)->activate = g_paste_applet_about_activate; } static void g_paste_applet_about_init (GPasteAppletAbout *self G_GNUC_UNUSED) { } /** * g_paste_applet_about_new: * @client: a #GPasteClient instance * * Create a new instance of #GPasteAppletAbout * * Returns: a newly allocated #GPasteAppletAbout * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_applet_about_new (GPasteClient *client) { g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); GtkWidget *self = gtk_widget_new (G_PASTE_TYPE_APPLET_ABOUT, "label", _("About"), NULL); GPasteAppletAboutPrivate *priv = g_paste_applet_about_get_instance_private (G_PASTE_APPLET_ABOUT (self)); priv->client = g_object_ref (client); return self; } GPaste-3.18.6/src/libgpaste/applet/gpaste-applet-about.h000066400000000000000000000022321305131721400230450ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #ifndef __G_PASTE_APPLET_ABOUT_H__ #define __G_PASTE_APPLET_ABOUT_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_APPLET_ABOUT (g_paste_applet_about_get_type ()) G_PASTE_FINAL_TYPE (AppletAbout, applet_about, APPLET_ABOUT, GtkMenuItem) GtkWidget *g_paste_applet_about_new (GPasteClient *client); G_END_DECLS #endif /*__G_PASTE_APPLET_ABOUT_H__*/ GPaste-3.18.6/src/libgpaste/applet/gpaste-applet-app-indicator.c000066400000000000000000000077351305131721400244750ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include struct _GPasteAppletAppIndicator { GPasteAppletIcon parent_instance; }; typedef struct { GPasteClient *client; AppIndicator *icon; gulong tracking_id; } GPasteAppletAppIndicatorPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteAppletAppIndicator, g_paste_applet_app_indicator, G_PASTE_TYPE_APPLET_ICON) static inline void indicator_set_state (AppIndicator *indicator, gboolean state) { app_indicator_set_status (indicator, (state) ? APP_INDICATOR_STATUS_ACTIVE : APP_INDICATOR_STATUS_PASSIVE); } static void on_tracking_changed (GPasteClient *client G_GNUC_UNUSED, gboolean state, gpointer user_data) { GPasteAppletAppIndicatorPrivate *priv = user_data; indicator_set_state (priv->icon, state); } static void g_paste_applet_app_indicator_dispose (GObject *object) { GPasteAppletAppIndicatorPrivate *priv = g_paste_applet_app_indicator_get_instance_private (G_PASTE_APPLET_APP_INDICATOR (object)); if (priv->tracking_id) { g_signal_handler_disconnect (priv->client, priv->tracking_id); priv->tracking_id = 0; } g_clear_object (&priv->icon); g_clear_object (&priv->client); G_OBJECT_CLASS (g_paste_applet_app_indicator_parent_class)->dispose (object); } static void g_paste_applet_app_indicator_class_init (GPasteAppletAppIndicatorClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_applet_app_indicator_dispose; } static void g_paste_applet_app_indicator_init (GPasteAppletAppIndicator *self) { GPasteAppletAppIndicatorPrivate *priv = g_paste_applet_app_indicator_get_instance_private (self); priv->icon = app_indicator_new (PACKAGE_STRING, "edit-paste", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); app_indicator_set_title (priv->icon, PACKAGE_STRING); } /** * g_paste_applet_app_indicator_new: * @client: a #GPasteClient * @app: the #GApplication * * Create a new instance of #GPasteAppletAppIndicator * * Returns: a newly allocated #GPasteAppletAppIndicator * free it with g_object_unref */ G_PASTE_VISIBLE GPasteAppletIcon * g_paste_applet_app_indicator_new (GPasteClient *client, GApplication *app) { g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); g_return_val_if_fail (!app || G_IS_APPLICATION (app), NULL); GPasteAppletIcon *self = g_paste_applet_icon_new (G_PASTE_TYPE_APPLET_APP_INDICATOR, client); GPasteAppletAppIndicatorPrivate *priv = g_paste_applet_app_indicator_get_instance_private (G_PASTE_APPLET_APP_INDICATOR (self)); GtkWidget *menu = g_paste_applet_menu_new (client, app); priv->client = g_object_ref (client); priv->tracking_id = g_signal_connect (G_OBJECT (priv->client), "tracking", G_CALLBACK (on_tracking_changed), priv); indicator_set_state (priv->icon, g_paste_client_is_active (client)); gtk_widget_show_all (menu); app_indicator_set_menu (priv->icon, GTK_MENU (menu)); return self; } GPaste-3.18.6/src/libgpaste/applet/gpaste-applet-app-indicator.h000066400000000000000000000024711305131721400244720ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #ifndef __G_PASTE_APPLET_APP_INDICATOR_H__ #define __G_PASTE_APPLET_APP_INDICATOR_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_APPLET_APP_INDICATOR (g_paste_applet_app_indicator_get_type ()) G_PASTE_FINAL_TYPE (AppletAppIndicator, applet_app_indicator, APPLET_APP_INDICATOR, GPasteAppletIcon) GPasteAppletIcon *g_paste_applet_app_indicator_new (GPasteClient *client, GApplication *app); G_END_DECLS #endif /*__G_PASTE_APPLET_APP_INDICATOR_H__*/ GPaste-3.18.6/src/libgpaste/applet/gpaste-applet-icon.c000066400000000000000000000056651305131721400226730ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include typedef struct { GPasteClient *client; gulong show_id; } GPasteAppletIconPrivate; G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GPasteAppletIcon, g_paste_applet_icon, G_TYPE_OBJECT) /* * g_paste_applet_icon_activate: * * Activate the applet icon action * * Returns: */ G_PASTE_VISIBLE void g_paste_applet_icon_activate (void) { g_paste_util_spawn ("Ui"); } static void g_paste_applet_icon_show_history (GPasteClient *client G_GNUC_UNUSED, gpointer user_data G_GNUC_UNUSED) { g_paste_applet_icon_activate (); } static void g_paste_applet_icon_dispose (GObject *object) { GPasteAppletIconPrivate *priv = g_paste_applet_icon_get_instance_private (G_PASTE_APPLET_ICON (object)); if (priv->client) { g_signal_handler_disconnect (priv->client, priv->show_id); g_clear_object (&priv->client); } G_OBJECT_CLASS (g_paste_applet_icon_parent_class)->dispose (object); } static void g_paste_applet_icon_class_init (GPasteAppletIconClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_applet_icon_dispose; } static void g_paste_applet_icon_init (GPasteAppletIcon *self G_GNUC_UNUSED) { } /** * g_paste_applet_icon_new: * @type: The type of the subclass to instantiate * @client: a #GPasteClient * * Create a new instance of #GPasteAppletIcon * * Returns: a newly allocated #GPasteAppletIcon * free it with g_object_unref */ GPasteAppletIcon * g_paste_applet_icon_new (GType type, GPasteClient *client) { g_return_val_if_fail (g_type_is_a (type, G_PASTE_TYPE_APPLET_ICON), NULL); g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); GPasteAppletIcon *self = g_object_new (type, NULL); GPasteAppletIconPrivate *priv = g_paste_applet_icon_get_instance_private (self); priv->client = g_object_ref (client); priv->show_id = g_signal_connect (client, "show-history", G_CALLBACK (g_paste_applet_icon_show_history), self); return self; } GPaste-3.18.6/src/libgpaste/applet/gpaste-applet-icon.h000066400000000000000000000027061305131721400226710ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_APPLET_ICON_H__ #define __G_PASTE_APPLET_ICON_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_APPLET_ICON (g_paste_applet_icon_get_type ()) G_PASTE_DERIVABLE_TYPE (AppletIcon, applet_icon, APPLET_ICON, GObject) struct _GPasteAppletIconClass { GObjectClass parent_class; }; void g_paste_applet_icon_activate (void); GPasteAppletIcon *g_paste_applet_icon_new (GType type, GPasteClient *client); G_END_DECLS #endif /*__G_PASTE_APPLET_ICON_H__*/ GPaste-3.18.6/src/libgpaste/applet/gpaste-applet-menu.c000066400000000000000000000041131305131721400226720ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include #include struct _GPasteAppletMenu { GtkMenu parent_instance; }; G_DEFINE_TYPE (GPasteAppletMenu, g_paste_applet_menu, GTK_TYPE_MENU) static void g_paste_applet_menu_class_init (GPasteAppletMenuClass *klass G_GNUC_UNUSED) { } static void g_paste_applet_menu_init (GPasteAppletMenu *self) { GtkMenuShell *shell = GTK_MENU_SHELL (self); gtk_menu_shell_append (shell, g_paste_applet_ui_new ()); } /** * g_paste_applet_menu_new: * @client: a #GPasteClient instance * @app: (nullable): the #GApplication to quit * * Create a new instance of #GPasteAppletMenu * * Returns: a newly allocated #GPasteAppletMenu * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_applet_menu_new (GPasteClient *client, GApplication *app) { g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); g_return_val_if_fail ((!app || G_IS_APPLICATION (app)), NULL); GtkWidget *self = gtk_widget_new (G_PASTE_TYPE_APPLET_MENU, NULL); GtkMenuShell *shell = GTK_MENU_SHELL (self); gtk_menu_shell_append (shell, g_paste_applet_about_new (client)); gtk_menu_shell_append (shell, g_paste_applet_quit_new (app)); return self; } GPaste-3.18.6/src/libgpaste/applet/gpaste-applet-menu.h000066400000000000000000000023041305131721400226770ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #ifndef __G_PASTE_APPLET_MENU_H__ #define __G_PASTE_APPLET_MENU_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_APPLET_MENU (g_paste_applet_menu_get_type ()) G_PASTE_FINAL_TYPE (AppletMenu, applet_menu, APPLET_MENU, GtkMenu) GtkWidget *g_paste_applet_menu_new (GPasteClient *client, GApplication *app); G_END_DECLS #endif /*__G_PASTE_APPLET_MENU_H__*/ GPaste-3.18.6/src/libgpaste/applet/gpaste-applet-quit.c000066400000000000000000000043101305131721400227070ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include struct _GPasteAppletQuit { GtkMenuItem parent_instance; }; typedef struct { GApplication *app; } GPasteAppletQuitPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteAppletQuit, g_paste_applet_quit, GTK_TYPE_MENU_ITEM) static void g_paste_applet_quit_activate (GtkMenuItem *menu_item) { GPasteAppletQuitPrivate *priv = g_paste_applet_quit_get_instance_private (G_PASTE_APPLET_QUIT (menu_item)); g_application_quit (priv->app); GTK_MENU_ITEM_CLASS (g_paste_applet_quit_parent_class)->activate (menu_item); } static void g_paste_applet_quit_class_init (GPasteAppletQuitClass *klass) { GTK_MENU_ITEM_CLASS (klass)->activate = g_paste_applet_quit_activate; } static void g_paste_applet_quit_init (GPasteAppletQuit *self G_GNUC_UNUSED) { } /** * g_paste_applet_quit_new: * @app: the #GApplication * * Create a new instance of #GPasteAppletQuit * * Returns: a newly allocated #GPasteAppletQuit * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_applet_quit_new (GApplication *app) { g_return_val_if_fail (G_IS_APPLICATION (app), NULL); GtkWidget *self = gtk_widget_new (G_PASTE_TYPE_APPLET_QUIT, "label", _("Quit"), NULL); GPasteAppletQuitPrivate *priv = g_paste_applet_quit_get_instance_private (G_PASTE_APPLET_QUIT (self)); priv->app = app; return self; } GPaste-3.18.6/src/libgpaste/applet/gpaste-applet-quit.h000066400000000000000000000022161305131721400227170ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #ifndef __G_PASTE_APPLET_QUIT_H__ #define __G_PASTE_APPLET_QUIT_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_APPLET_QUIT (g_paste_applet_quit_get_type ()) G_PASTE_FINAL_TYPE (AppletQuit, applet_quit, APPLET_QUIT, GtkMenuItem) GtkWidget *g_paste_applet_quit_new (GApplication *app); G_END_DECLS #endif /*__G_PASTE_APPLET_QUIT_H__*/ GPaste-3.18.6/src/libgpaste/applet/gpaste-applet-status-icon.c000066400000000000000000000075551305131721400242140ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include struct _GPasteAppletStatusIcon { GPasteAppletIcon parent_instance; }; typedef struct { GtkStatusIcon *icon; GtkMenu *menu; gulong press_id; } GPasteAppletStatusIconPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteAppletStatusIcon, g_paste_applet_status_icon, G_PASTE_TYPE_APPLET_ICON) static gboolean g_paste_applet_status_icon_popup (GtkStatusIcon *icon, GdkEventButton *event, gpointer user_data) { GPasteAppletStatusIconPrivate *priv = user_data; if (gdk_event_triggers_context_menu ((GdkEvent *) event)) { G_GNUC_BEGIN_IGNORE_DEPRECATIONS gtk_menu_popup (priv->menu, NULL, NULL, gtk_status_icon_position_menu, icon, event->button, event->time); G_GNUC_END_IGNORE_DEPRECATIONS } else g_paste_applet_icon_activate (); return GDK_EVENT_PROPAGATE; } static void g_paste_applet_status_icon_dispose (GObject *object) { GPasteAppletStatusIconPrivate *priv = g_paste_applet_status_icon_get_instance_private (G_PASTE_APPLET_STATUS_ICON (object)); if (priv->icon) { g_signal_handler_disconnect (priv->icon, priv->press_id); g_clear_object (&priv->icon); } G_OBJECT_CLASS (g_paste_applet_status_icon_parent_class)->dispose (object); } static void g_paste_applet_status_icon_class_init (GPasteAppletStatusIconClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_applet_status_icon_dispose; } static void g_paste_applet_status_icon_init (GPasteAppletStatusIcon *self) { GPasteAppletStatusIconPrivate *priv = g_paste_applet_status_icon_get_instance_private (self); G_GNUC_BEGIN_IGNORE_DEPRECATIONS priv->icon = gtk_status_icon_new_from_icon_name ("edit-paste"); gtk_status_icon_set_tooltip_text (priv->icon, PACKAGE_STRING); gtk_status_icon_set_visible (priv->icon, TRUE); G_GNUC_END_IGNORE_DEPRECATIONS priv->press_id = g_signal_connect (priv->icon, "button-press-event", G_CALLBACK (g_paste_applet_status_icon_popup), priv); } /** * g_paste_applet_status_icon_new: * @client: a #GPasteClient * @app: the #GApplication * * Create a new instance of #GPasteAppletStatusIcon * * Returns: a newly allocated #GPasteAppletStatusIcon * free it with g_object_unref */ G_PASTE_VISIBLE GPasteAppletIcon * g_paste_applet_status_icon_new (GPasteClient *client, GApplication *app) { g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); g_return_val_if_fail (!app || G_IS_APPLICATION (app), NULL); GPasteAppletIcon *self = g_paste_applet_icon_new (G_PASTE_TYPE_APPLET_STATUS_ICON, client); GPasteAppletStatusIconPrivate *priv = g_paste_applet_status_icon_get_instance_private (G_PASTE_APPLET_STATUS_ICON (self)); GtkWidget *menu = g_paste_applet_menu_new (client, app); gtk_widget_show_all (menu); priv->menu = GTK_MENU (menu); return self; } GPaste-3.18.6/src/libgpaste/applet/gpaste-applet-status-icon.h000066400000000000000000000026461305131721400242150ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_APPLET_STATUS_ICON_H__ #define __G_PASTE_APPLET_STATUS_ICON_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_APPLET_STATUS_ICON (g_paste_applet_status_icon_get_type ()) G_PASTE_FINAL_TYPE (AppletStatusIcon, applet_status_icon, APPLET_STATUS_ICON, GPasteAppletIcon) GPasteAppletIcon *g_paste_applet_status_icon_new (GPasteClient *client, GApplication *app); G_END_DECLS #endif /*__G_PASTE_APPLET_STATUS_ICON_H__*/ GPaste-3.18.6/src/libgpaste/applet/gpaste-applet-ui.c000066400000000000000000000034021305131721400223430ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include struct _GPasteAppletUi { GtkMenuItem parent_instance; }; G_DEFINE_TYPE (GPasteAppletUi, g_paste_applet_ui, GTK_TYPE_MENU_ITEM) static void g_paste_applet_ui_activate (GtkMenuItem *menu_item G_GNUC_UNUSED) { g_paste_util_spawn ("Ui"); GTK_MENU_ITEM_CLASS (g_paste_applet_ui_parent_class)->activate (menu_item); } static void g_paste_applet_ui_class_init (GPasteAppletUiClass *klass) { GTK_MENU_ITEM_CLASS (klass)->activate = g_paste_applet_ui_activate; } static void g_paste_applet_ui_init (GPasteAppletUi *self G_GNUC_UNUSED) { } /** * g_paste_applet_ui_new: * * Create a new instance of #GPasteAppletUi * * Returns: a newly allocated #GPasteAppletUi * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_applet_ui_new (void) { return gtk_widget_new (G_PASTE_TYPE_APPLET_UI, "label", _("launch the graphical tool"), NULL); } GPaste-3.18.6/src/libgpaste/applet/gpaste-applet-ui.h000066400000000000000000000021521305131721400223510ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #ifndef __G_PASTE_APPLET_UI_H__ #define __G_PASTE_APPLET_UI_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_APPLET_UI (g_paste_applet_ui_get_type ()) G_PASTE_FINAL_TYPE (AppletUi, applet_ui, APPLET_UI, GtkMenuItem) GtkWidget *g_paste_applet_ui_new (void); G_END_DECLS #endif /*__G_PASTE_APPLET_UI_H__*/ GPaste-3.18.6/src/libgpaste/applet/gpaste-applet.c000066400000000000000000000117261305131721400217400ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include #include struct _GPasteApplet { GObject parent_instance; }; typedef struct { GPasteClient *client; GPasteAppletIcon *icon; GApplication *application; GtkWidget *win; } GPasteAppletPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteApplet, g_paste_applet, G_TYPE_OBJECT) static void g_paste_applet_dispose (GObject *object) { GPasteAppletPrivate *priv = g_paste_applet_get_instance_private (G_PASTE_APPLET (object)); g_clear_object (&priv->client); g_clear_object (&priv->icon); G_OBJECT_CLASS (g_paste_applet_parent_class)->dispose (object); } static void g_paste_applet_class_init (GPasteAppletClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_applet_dispose; } static void g_paste_applet_init (GPasteApplet *self G_GNUC_UNUSED) { } static gboolean g_paste_applet_new_finish (GPasteAppletPrivate *priv, GAsyncResult *res) { g_autoptr (GError) error = NULL; priv->client = g_paste_client_new_finish (res, &error); if (error) { if (priv->win) gtk_window_close (GTK_WINDOW (priv->win)); /* will exit the application */ return FALSE; } return TRUE; } #ifdef ENABLE_UNITY static void g_paste_applet_app_indicator_client_ready (GObject *source_object G_GNUC_UNUSED, GAsyncResult *res, gpointer user_data) { GPasteAppletPrivate *priv = user_data; if (!g_paste_applet_new_finish (priv, res)) return; priv->icon = g_paste_applet_app_indicator_new (priv->client, priv->application); } #endif static void g_paste_applet_status_icon_client_ready (GObject *source_object G_GNUC_UNUSED, GAsyncResult *res, gpointer user_data) { GPasteAppletPrivate *priv = user_data; if (!g_paste_applet_new_finish (priv, res)) return; priv->icon = g_paste_applet_status_icon_new (priv->client, priv->application); } static GPasteApplet * g_paste_applet_new (GtkApplication *application) { GPasteApplet *self = g_object_new (G_PASTE_TYPE_APPLET, NULL); GPasteAppletPrivate *priv = g_paste_applet_get_instance_private (self); if (application) { priv->application = G_APPLICATION (application); priv->win = gtk_application_window_new (application); gtk_widget_hide (priv->win); } else { priv->application = NULL; priv->win = NULL; } return self; } /** * g_paste_applet_new_app_indicator: * @application: the #GtkApplication running * * Create a new instance of #GPasteApplet * * Returns: a newly allocated #GPasteApplet * free it with g_object_unref */ G_PASTE_VISIBLE GPasteApplet * g_paste_applet_new_app_indicator (GtkApplication *application) { g_return_val_if_fail (G_IS_APPLICATION (application), NULL); #ifdef ENABLE_UNITY if (g_paste_util_has_unity ()) { GPasteApplet *self = g_paste_applet_new (application); GPasteAppletPrivate *priv = g_paste_applet_get_instance_private (self); g_paste_client_new (g_paste_applet_app_indicator_client_ready, priv); return self; } #endif g_critical ("gpaste-app-indicator %s", _("is not installed")); return NULL; } /** * g_paste_applet_new_status_icon: * @application: (nullable): the #GtkApplication running * * Create a new instance of #GPasteApplet * * Returns: a newly allocated #GPasteApplet * free it with g_object_unref */ G_PASTE_VISIBLE GPasteApplet * g_paste_applet_new_status_icon (GtkApplication *application) { g_return_val_if_fail (G_IS_APPLICATION (application), NULL); if (g_paste_util_has_applet ()) { GPasteApplet *self = g_paste_applet_new (application); GPasteAppletPrivate *priv = g_paste_applet_get_instance_private (self); g_paste_client_new (g_paste_applet_status_icon_client_ready, priv); return self; } g_critical ("gpaste-applet %s", _("is not installed")); return NULL; } GPaste-3.18.6/src/libgpaste/applet/gpaste-applet.h000066400000000000000000000025101305131721400217340ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_APPLET_H__ #define __G_PASTE_APPLET_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_APPLET (g_paste_applet_get_type ()) G_PASTE_FINAL_TYPE (Applet, applet, APPLET, GObject) GPasteApplet *g_paste_applet_new_app_indicator (GtkApplication *application); GPasteApplet *g_paste_applet_new_status_icon (GtkApplication *application); G_END_DECLS #endif /*__G_PASTE_APPLET_H__*/ GPaste-3.18.6/src/libgpaste/client/000077500000000000000000000000001305131721400170105ustar00rootroot00000000000000GPaste-3.18.6/src/libgpaste/client/gpaste-client.c000066400000000000000000002050241305131721400217160ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2012-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include "gpaste-gdbus-macros.h" #include #include struct _GPasteClient { GDBusProxy parent_instance; }; G_DEFINE_TYPE (GPasteClient, g_paste_client, G_TYPE_DBUS_PROXY) enum { DELETE_HISTORY, EMPTY_HISTORY, SHOW_HISTORY, SWITCH_HISTORY, TRACKING, UPDATE, LAST_SIGNAL }; static guint64 signals[LAST_SIGNAL] = { 0 }; /*******************/ /* Methods / Async */ /*******************/ #define DBUS_CALL_NO_PARAM_ASYNC(method) \ DBUS_CALL_NO_PARAM_ASYNC_BASE (CLIENT, G_PASTE_DAEMON_##method) #define DBUS_CALL_ONE_PARAM_ASYNC(method, param_type, param_name) \ DBUS_CALL_ONE_PARAM_ASYNC_BASE (CLIENT, param_type, param_name, G_PASTE_DAEMON_##method) #define DBUS_CALL_ONE_PARAMV_ASYNC(method, paramv) \ DBUS_CALL_ONE_PARAMV_ASYNC_BASE (CLIENT, paramv, G_PASTE_DAEMON_##method) #define DBUS_CALL_TWO_PARAMS_ASYNC(method, params) \ DBUS_CALL_TWO_PARAMS_ASYNC_BASE (CLIENT, params, G_PASTE_DAEMON_##method) #define DBUS_CALL_THREE_PARAMS_ASYNC(method, params) \ DBUS_CALL_THREE_PARAMS_ASYNC_BASE (CLIENT, params, G_PASTE_DAEMON_##method) /****************************/ /* Methods / Async - Finish */ /****************************/ #define DBUS_ASYNC_FINISH_NO_RETURN \ DBUS_ASYNC_FINISH_NO_RETURN_BASE (CLIENT) #define DBUS_ASYNC_FINISH_RET_STRING \ DBUS_ASYNC_FINISH_RET_STRING_BASE (CLIENT) #define DBUS_ASYNC_FINISH_RET_STRV \ DBUS_ASYNC_FINISH_RET_STRV_BASE (CLIENT) #define DBUS_ASYNC_FINISH_RET_UINT64 \ DBUS_ASYNC_FINISH_RET_UINT64_BASE (CLIENT) #define DBUS_ASYNC_FINISH_RET_AT(len) \ DBUS_ASYNC_FINISH_RET_AT_BASE (CLIENT, len) /******************/ /* Methods / Sync */ /******************/ #define DBUS_CALL_NO_PARAM_NO_RETURN(method) \ DBUS_CALL_NO_PARAM_NO_RETURN_BASE (CLIENT, G_PASTE_DAEMON_##method) #define DBUS_CALL_NO_PARAM_RET_STRING(method) \ DBUS_CALL_NO_PARAM_RET_STRING_BASE (CLIENT, G_PASTE_DAEMON_##method) #define DBUS_CALL_NO_PARAM_RET_STRV(method) \ DBUS_CALL_NO_PARAM_RET_STRV_BASE (CLIENT, G_PASTE_DAEMON_##method) #define DBUS_CALL_ONE_PARAM_NO_RETURN(method, param_type, param_name) \ DBUS_CALL_ONE_PARAM_NO_RETURN_BASE (CLIENT, param_type, param_name, G_PASTE_DAEMON_##method) #define DBUS_CALL_ONE_PARAM_RET_UINT64(method, param_type, param_name) \ DBUS_CALL_ONE_PARAM_RET_UINT64_BASE (CLIENT, param_type, param_name, G_PASTE_DAEMON_##method) #define DBUS_CALL_ONE_PARAM_RET_STRING(method, param_type, param_name) \ DBUS_CALL_ONE_PARAM_RET_STRING_BASE (CLIENT, param_type, param_name, G_PASTE_DAEMON_##method) #define DBUS_CALL_ONE_PARAM_RET_AT(method, param_type, param_name, len) \ DBUS_CALL_ONE_PARAM_RET_AT_BASE (CLIENT, param_type, param_name, G_PASTE_DAEMON_##method, len) #define DBUS_CALL_ONE_PARAMV_RET_STRV(method, paramv) \ DBUS_CALL_ONE_PARAMV_RET_STRV_BASE (CLIENT, G_PASTE_DAEMON_##method, paramv) #define DBUS_CALL_TWO_PARAMS_NO_RETURN(method, params) \ DBUS_CALL_TWO_PARAMS_NO_RETURN_BASE (CLIENT, params, G_PASTE_DAEMON_##method) #define DBUS_CALL_THREE_PARAMS_NO_RETURN(method, params) \ DBUS_CALL_THREE_PARAMS_NO_RETURN_BASE (CLIENT, params, G_PASTE_DAEMON_##method) /**************/ /* Properties */ /**************/ #define DBUS_GET_BOOLEAN_PROPERTY(property) \ DBUS_GET_BOOLEAN_PROPERTY_BASE (CLIENT, G_PASTE_DAEMON_PROP_##property) #define DBUS_GET_STRING_PROPERTY(property) \ DBUS_GET_STRING_PROPERTY_BASE (CLIENT, G_PASTE_DAEMON_PROP_##property) /***********/ /* Signals */ /***********/ #define HANDLE_SIGNAL(sig) \ if (!g_strcmp0 (signal_name, G_PASTE_DAEMON_SIG_##sig)) \ { \ g_signal_emit (self, \ signals[sig], \ 0, /* detail */ \ NULL); \ } #define HANDLE_SIGNAL_WITH_DATA(sig, ans_type, get_data) \ if (!g_strcmp0 (signal_name, G_PASTE_DAEMON_SIG_##sig)) \ { \ GVariantIter params_iter; \ g_variant_iter_init (¶ms_iter, parameters); \ g_autoptr (GVariant) variant = g_variant_iter_next_value (¶ms_iter); \ ans_type answer = get_data; \ g_signal_emit (self, \ signals[sig], \ 0, /* detail */ \ answer, \ NULL); \ } #define NEW_SIGNAL(name) \ g_signal_new (name, \ G_PASTE_TYPE_CLIENT, \ G_SIGNAL_RUN_LAST, \ 0, /* class offset */ \ NULL, /* accumulator */ \ NULL, /* accumulator data */ \ g_cclosure_marshal_VOID__VOID, \ G_TYPE_NONE, \ 0) /* number of params */ #define NEW_SIGNAL_WITH_DATA(name, type) \ g_signal_new (name, \ G_PASTE_TYPE_CLIENT, \ G_SIGNAL_RUN_LAST, \ 0, /* class offset */ \ NULL, /* accumulator */ \ NULL, /* accumulator data */ \ g_cclosure_marshal_VOID__##type, \ G_TYPE_NONE, \ 1, \ G_TYPE_##type) static GVariant * compute_at_param (const guint64 *indexes, guint64 n_indexes) { return g_variant_new_fixed_array (G_VARIANT_TYPE_UINT64, indexes, n_indexes, sizeof (guint64)); } /******************/ /* Methods / Sync */ /******************/ /** * g_paste_client_about_sync: * @self: a #GPasteClient instance * @error: a #GError * * Display the about dialog * * Returns: */ G_PASTE_VISIBLE void g_paste_client_about_sync (GPasteClient *self, GError **error) { DBUS_CALL_NO_PARAM_NO_RETURN (ABOUT); } /** * g_paste_client_add_sync: * @self: a #GPasteClient instance * @text: the text to add * @error: a #GError * * Add an item to the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_add_sync (GPasteClient *self, const gchar *text, GError **error) { DBUS_CALL_ONE_PARAM_NO_RETURN (ADD, string, text); } /** * g_paste_client_add_file_sync: * @self: a #GPasteClient instance * @file: the file to add * @error: a #GError * * Add the file contents to the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_add_file_sync (GPasteClient *self, const gchar *file, GError **error) { g_autofree gchar *absolute_path = NULL; if (!g_path_is_absolute (file)) { g_autofree gchar *current_dir = g_get_current_dir (); absolute_path = g_build_filename (current_dir, file, NULL); } DBUS_CALL_ONE_PARAM_NO_RETURN (ADD_FILE, string, ((absolute_path) ? absolute_path : file)); } /** * g_paste_client_add_password_sync: * @self: a #GPasteClient instance * @name: the name to identify the password to add * @password: the password to add * @error: a #GError * * Add the password to the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_add_password_sync (GPasteClient *self, const gchar *name, const gchar *password, GError **error) { GVariant *params[] = { g_variant_new_string (name), g_variant_new_string (password) }; DBUS_CALL_TWO_PARAMS_NO_RETURN (ADD_PASSWORD, params); } /** * g_paste_client_backup_history_sync: * @self: a #GPasteClient instance * @history: the name of the history * @backup: the name of the backup * @error: a #GError * * Backup the current history * * Returns: */ G_PASTE_VISIBLE void g_paste_client_backup_history_sync (GPasteClient *self, const gchar *history, const gchar *backup, GError **error) { GVariant *params[] = { g_variant_new_string (history), g_variant_new_string (backup) }; DBUS_CALL_TWO_PARAMS_NO_RETURN (BACKUP_HISTORY, params); } /** * g_paste_client_delete_sync: * @self: a #GPasteClient instance * @index: the index of the element we want to delete * @error: a #GError * * Delete an item from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_delete_sync (GPasteClient *self, guint64 index, GError **error) { DBUS_CALL_ONE_PARAM_NO_RETURN (DELETE, uint64, index); } /** * g_paste_client_delete_history_sync: * @self: a #GPasteClient instance * @name: the name of the history to delete * @error: a #GError * * Delete an history * * Returns: */ G_PASTE_VISIBLE void g_paste_client_delete_history_sync (GPasteClient *self, const gchar *name, GError **error) { DBUS_CALL_ONE_PARAM_NO_RETURN (DELETE_HISTORY, string, name); } /** * g_paste_client_delete_password_sync: * @self: a #GPasteClient instance * @name: the name of the password to delete * @error: a #GError * * Delete the password from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_delete_password_sync (GPasteClient *self, const gchar *name, GError **error) { DBUS_CALL_ONE_PARAM_NO_RETURN (DELETE_PASSWORD, string, name); } /** * g_paste_client_empty_history_sync: * @self: a #GPasteClient instance * @name: the name of the history to empty * @error: a #GError * * Empty the history from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_empty_history_sync (GPasteClient *self, const gchar *name, GError **error) { DBUS_CALL_ONE_PARAM_NO_RETURN (EMPTY_HISTORY, string, name); } /** * g_paste_client_get_element_sync: * @self: a #GPasteClient instance * @index: the index of the element we want to get * @error: a #GError * * Get an item from the #GPasteDaemon * * Returns: (transfer full): a newly allocated string */ G_PASTE_VISIBLE gchar * g_paste_client_get_element_sync (GPasteClient *self, guint64 index, GError **error) { DBUS_CALL_ONE_PARAM_RET_STRING (GET_ELEMENT, uint64, index); } static gchar * _g_paste_client_get_element_kind_sync (GPasteClient *self, guint64 index, GError **error) { DBUS_CALL_ONE_PARAM_RET_STRING (GET_ELEMENT_KIND, uint64, index); } /** * g_paste_client_get_element_kind_sync: * @self: a #GPasteClient instance * @index: the index of the element we want to get * @error: a #GError * * Get the kind of an item from the #GPasteDaemon * * Returns: The #GPasteItemKind */ G_PASTE_VISIBLE GPasteItemKind g_paste_client_get_element_kind_sync (GPasteClient *self, guint64 index, GError **error) { g_autofree gchar *kind = _g_paste_client_get_element_kind_sync (self, index, error); GEnumValue *k = (kind) ? g_enum_get_value_by_nick (g_type_class_peek (G_PASTE_TYPE_ITEM_KIND), kind) : NULL; return (k) ? k->value : G_PASTE_ITEM_KIND_INVALID; } /** * g_paste_client_get_elements_sync: * @self: a #GPasteClient instance * @indexes: (array length=n_indexes): the indexes of the elements we want to get * @n_indexes: the number of indexes * @error: a #GError * * Get some items from the #GPasteDaemon * * Returns: (transfer full): a newly allocated array of string */ G_PASTE_VISIBLE GStrv g_paste_client_get_elements_sync (GPasteClient *self, const guint64 *indexes, guint64 n_indexes, GError **error) { GVariant *param = compute_at_param (indexes, n_indexes); DBUS_CALL_ONE_PARAMV_RET_STRV (GET_ELEMENTS, param); } /** * g_paste_client_get_history_sync: * @self: a #GPasteClient instance * @error: a #GError * * Get the history from the #GPasteDaemon * * Returns: (transfer full): a newly allocated array of string */ G_PASTE_VISIBLE GStrv g_paste_client_get_history_sync (GPasteClient *self, GError **error) { DBUS_CALL_NO_PARAM_RET_STRV (GET_HISTORY); } /** * g_paste_client_get_history_name_sync: * @self: a #GPasteClient instance * @error: a #GError * * Get the name of the history from the #GPasteDaemon * * Returns: (transfer full): a newly allocated string */ G_PASTE_VISIBLE gchar * g_paste_client_get_history_name_sync (GPasteClient *self, GError **error) { DBUS_CALL_NO_PARAM_RET_STRING (GET_HISTORY_NAME); } /** * g_paste_client_get_history_size_sync: * @self: a #GPasteClient instance * @name: the name of the history * @error: a #GError * * Get the history size from the #GPasteDaemon * * Returns: the size of the history */ G_PASTE_VISIBLE guint64 g_paste_client_get_history_size_sync (GPasteClient *self, const gchar *name, GError **error) { DBUS_CALL_ONE_PARAM_RET_UINT64 (GET_HISTORY_SIZE, string, name); } /** * g_paste_client_get_raw_element_sync: * @self: a #GPasteClient instance * @index: the index of the element we want to get * @error: a #GError * * Get an item from the #GPasteDaemon * * Returns: (transfer full): a newly allocated string */ G_PASTE_VISIBLE gchar * g_paste_client_get_raw_element_sync (GPasteClient *self, guint64 index, GError **error) { DBUS_CALL_ONE_PARAM_RET_STRING (GET_RAW_ELEMENT, uint64, index); } /** * g_paste_client_get_raw_history_sync: * @self: a #GPasteClient instance * @error: a #GError * * Get the history from the #GPasteDaemon * * Returns: (transfer full): a newly allocated array of string */ G_PASTE_VISIBLE GStrv g_paste_client_get_raw_history_sync (GPasteClient *self, GError **error) { DBUS_CALL_NO_PARAM_RET_STRV (GET_RAW_HISTORY); } /** * g_paste_client_list_histories_sync: * @self: a #GPasteClient instance * @error: a #GError * * List all available hisotries * * Returns: (transfer full): a newly allocated array of string */ G_PASTE_VISIBLE GStrv g_paste_client_list_histories_sync (GPasteClient *self, GError **error) { DBUS_CALL_NO_PARAM_RET_STRV (LIST_HISTORIES); } /** * g_paste_client_merge_sync: * @self: a #GPasteClient instance * @decoration: (nullable): the decoration to apply to each entry * @separator: (nullable): the separator to add between each entry * @indexes: (array length=n_indexes): the indexes of the entries to merge * @n_indexes: the length of @indexes * @error: a #GError * * Merge some history entries * * If decoration is " and separator is , and entries are foo bar baz * result will be "foo","bar","baz" * * Returns: */ G_PASTE_VISIBLE void g_paste_client_merge_sync (GPasteClient *self, const gchar *decoration, const gchar *separator, const guint64 *indexes, guint64 n_indexes, GError **error) { GVariant *params[] = { g_variant_new_string (decoration ? decoration : ""), g_variant_new_string (separator ? separator : ""), g_variant_new_fixed_array (G_VARIANT_TYPE_UINT64, indexes, n_indexes, sizeof (guint64)) }; DBUS_CALL_THREE_PARAMS_NO_RETURN (MERGE, params); } /** * g_paste_client_on_extension_state_changed_sync: * @self: a #GPasteClient instance * @state: the new state of the extension * @error: a #GError * * Call this when the extension changes its state * * Returns: */ G_PASTE_VISIBLE void g_paste_client_on_extension_state_changed_sync (GPasteClient *self, gboolean state, GError **error) { DBUS_CALL_ONE_PARAM_NO_RETURN (ON_EXTENSION_STATE_CHANGED, boolean, state); } /** * g_paste_client_reexecute_sync: * @self: a #GPasteClient instance * @error: a #GError * * Reexecute the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_reexecute_sync (GPasteClient *self, GError **error) { DBUS_CALL_NO_PARAM_NO_RETURN (REEXECUTE); } /** * g_paste_client_rename_password_sync: * @self: a #GPasteClient instance * @old_name: the name of the password to rename * @new_name: the new name to give it * @error: a #GError * * Rename the password in the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_rename_password_sync (GPasteClient *self, const gchar *old_name, const gchar *new_name, GError **error) { GVariant *params[] = { g_variant_new_string (old_name), g_variant_new_string (new_name) }; DBUS_CALL_TWO_PARAMS_NO_RETURN (RENAME_PASSWORD, params); } /** * g_paste_client_replace_sync: * @self: a #GPasteClient instance * @index: the index of the element we want to replace * @contents: the replacement contents * @error: a #GError * * Replace the contents of an item * * Returns: */ G_PASTE_VISIBLE void g_paste_client_replace_sync (GPasteClient *self, guint64 index, const gchar *contents, GError **error) { GVariant *params[] = { g_variant_new_uint64 (index), g_variant_new_string (contents) }; DBUS_CALL_TWO_PARAMS_NO_RETURN (REPLACE, params); } /** * g_paste_client_search_sync: * @self: a #GPasteClient instance * @pattern: the pattern to look for in history * @hits: (out) (optional): number of hits * @error: a #GError * * Search for items matching @pattern in history * * Returns: (array length=hits): The indexes of the matching items */ G_PASTE_VISIBLE guint64 * g_paste_client_search_sync (GPasteClient *self, const gchar *pattern, guint64 *hits, GError **error) { DBUS_CALL_ONE_PARAM_RET_AT (SEARCH, string, pattern, hits); } /** * g_paste_client_select_sync: * @self: a #GPasteClient instance * @index: the index of the element we want to select * @error: a #GError * * Select an item from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_select_sync (GPasteClient *self, guint64 index, GError **error) { DBUS_CALL_ONE_PARAM_NO_RETURN (SELECT, uint64, index); } /** * g_paste_client_set_password_sync: * @self: a #GPasteClient instance * @index: the index of the element we want to set as password * @name: the name to identify the password * @error: a #GError * * Set the item as password * * Returns: */ G_PASTE_VISIBLE void g_paste_client_set_password_sync (GPasteClient *self, guint64 index, const gchar *name, GError **error) { GVariant *params[] = { g_variant_new_uint64 (index), g_variant_new_string (name) }; DBUS_CALL_TWO_PARAMS_NO_RETURN (SET_PASSWORD, params); } /** * g_paste_client_show_history_sync: * @self: a #GPasteClient instance * @error: a #GError * * Emit the ShowHistory signal * * Returns: */ G_PASTE_VISIBLE void g_paste_client_show_history_sync (GPasteClient *self, GError **error) { DBUS_CALL_NO_PARAM_NO_RETURN (SHOW_HISTORY); } /** * g_paste_client_switch_history_sync: * @self: a #GPasteClient instance * @name: the name of the history to switch to * @error: a #GError * * Switch to another history * * Returns: */ G_PASTE_VISIBLE void g_paste_client_switch_history_sync (GPasteClient *self, const gchar *name, GError **error) { DBUS_CALL_ONE_PARAM_NO_RETURN (SWITCH_HISTORY, string, name); } /** * g_paste_client_track_sync: * @self: a #GPasteClient instance * @state: the new tracking state of the #GPasteDaemon * @error: a #GError * * Change the tracking state of the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_track_sync (GPasteClient *self, gboolean state, GError **error) { DBUS_CALL_ONE_PARAM_NO_RETURN (TRACK, boolean, state); } /** * g_paste_client_upload_sync: * @self: a #GPasteClient instance * @index: the index of the element we want to upload * @error: a #GError * * Upload an item to a pastebin service * * Returns: */ G_PASTE_VISIBLE void g_paste_client_upload_sync (GPasteClient *self, guint64 index, GError **error) { DBUS_CALL_ONE_PARAM_NO_RETURN (UPLOAD, uint64, index); } /*******************/ /* Methods / Async */ /*******************/ /** * g_paste_client_about: * @self: a #GPasteClient instance * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Display the about dialog * * Returns: */ G_PASTE_VISIBLE void g_paste_client_about (GPasteClient *self, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_NO_PARAM_ASYNC (ABOUT); } /** * g_paste_client_add: * @self: a #GPasteClient instance * @text: the text to add * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Add an item to the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_add (GPasteClient *self, const gchar *text, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_ONE_PARAM_ASYNC (ADD, string, text); } /** * g_paste_client_add_file: * @self: a #GPasteClient instance * @file: the file to add * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Add the file contents to the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_add_file (GPasteClient *self, const gchar *file, GAsyncReadyCallback callback, gpointer user_data) { g_autofree gchar *absolute_path = NULL; if (!g_path_is_absolute (file)) { g_autofree gchar *current_dir = g_get_current_dir (); absolute_path = g_build_filename (current_dir, file, NULL); } DBUS_CALL_ONE_PARAM_ASYNC (ADD_FILE, string, ((absolute_path) ? absolute_path : file)); } /** * g_paste_client_add_password: * @self: a #GPasteClient instance * @name: the name to identify the password to add * @password: the password to add * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Add the password to the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_add_password (GPasteClient *self, const gchar *name, const gchar *password, GAsyncReadyCallback callback, gpointer user_data) { GVariant *params[] = { g_variant_new_string (name), g_variant_new_string (password) }; DBUS_CALL_TWO_PARAMS_ASYNC (ADD_PASSWORD, params); } /** * g_paste_client_backup_history: * @self: a #GPasteClient instance * @history: the name of the history * @backup: the name of the backup * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Backup the current history * * Returns: */ G_PASTE_VISIBLE void g_paste_client_backup_history (GPasteClient *self, const gchar *history, const gchar *backup, GAsyncReadyCallback callback, gpointer user_data) { GVariant *params[] = { g_variant_new_string (history), g_variant_new_string (backup) }; DBUS_CALL_TWO_PARAMS_ASYNC (BACKUP_HISTORY, params); } /** * g_paste_client_delete: * @self: a #GPasteClient instance * @index: the index of the element we want to delete * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Delete an item from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_delete (GPasteClient *self, guint64 index, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_ONE_PARAM_ASYNC (DELETE, uint64, index); } /** * g_paste_client_delete_history: * @self: a #GPasteClient instance * @name: the name of the history to delete * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Delete an history * * Returns: */ G_PASTE_VISIBLE void g_paste_client_delete_history (GPasteClient *self, const gchar *name, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_ONE_PARAM_ASYNC (DELETE_HISTORY, string, name); } /** * g_paste_client_delete_password: * @self: a #GPasteClient instance * @name: the name of the password to delete * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: The data to pass to @callback. * * Delete the password from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_delete_password (GPasteClient *self, const gchar *name, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_ONE_PARAM_ASYNC (DELETE_PASSWORD, string, name); } /** * g_paste_client_empty_history: * @self: a #GPasteClient instance * @name: the name of the history to empty * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Empty the history from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_empty_history (GPasteClient *self, const gchar *name, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_ONE_PARAM_ASYNC (EMPTY_HISTORY, string, name); } /** * g_paste_client_get_element: * @self: a #GPasteClient instance * @index: the index of the element we want to get * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Get an item from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_get_element (GPasteClient *self, guint64 index, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_ONE_PARAM_ASYNC (GET_ELEMENT, uint64, index); } /** * g_paste_client_get_element_kind: * @self: a #GPasteClient instance * @index: the index of the element we want to get * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Get the kind of an item from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_get_element_kind (GPasteClient *self, guint64 index, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_ONE_PARAM_ASYNC (GET_ELEMENT_KIND, uint64, index); } /** * g_paste_client_get_elements: * @self: a #GPasteClient instance * @indexes: (array length=n_indexes): the indexes of the elements we want to get * @n_indexes: the number of indexes * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Get some items from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_get_elements (GPasteClient *self, const guint64 *indexes, guint64 n_indexes, GAsyncReadyCallback callback, gpointer user_data) { GVariant *param = compute_at_param (indexes, n_indexes); DBUS_CALL_ONE_PARAMV_ASYNC (GET_ELEMENTS, param); } /** * g_paste_client_get_history: * @self: a #GPasteClient instance * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Get the history from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_get_history (GPasteClient *self, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_NO_PARAM_ASYNC (GET_HISTORY); } /** * g_paste_client_get_history_name: * @self: a #GPasteClient instance * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Get the name of the history from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_get_history_name (GPasteClient *self, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_NO_PARAM_ASYNC (GET_HISTORY_NAME); } /** * g_paste_client_get_history_size: * @self: a #GPasteClient instance * @name: the name of the history * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Get the history isize from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_get_history_size (GPasteClient *self, const gchar *name, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_ONE_PARAM_ASYNC (GET_HISTORY_SIZE, string, name); } /** * g_paste_client_get_raw_element: * @self: a #GPasteClient instance * @index: the index of the element we want to get * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Get an item from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_get_raw_element (GPasteClient *self, guint64 index, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_ONE_PARAM_ASYNC (GET_RAW_ELEMENT, uint64, index); } /** * g_paste_client_get_raw_history: * @self: a #GPasteClient instance * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Get the history from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_get_raw_history (GPasteClient *self, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_NO_PARAM_ASYNC (GET_RAW_HISTORY); } /** * g_paste_client_list_histories: * @self: a #GPasteClient instance * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * List all available hisotries * * Returns: */ G_PASTE_VISIBLE void g_paste_client_list_histories (GPasteClient *self, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_NO_PARAM_ASYNC (LIST_HISTORIES); } /** * g_paste_client_merge: * @self: a #GPasteClient instance * @decoration: (nullable): the decoration to apply to each entry * @separator: (nullable): the separator to add between each entry * @indexes: (array length=n_indexes): the indexes of the entries to merge * @n_indexes: the length of @indexes * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Merge some history entries * * If decoration is " and separator is , and entries are foo bar baz * result will be "foo","bar","baz" * * Returns: */ G_PASTE_VISIBLE void g_paste_client_merge (GPasteClient *self, const gchar *decoration, const gchar *separator, const guint64 *indexes, guint64 n_indexes, GAsyncReadyCallback callback, gpointer user_data) { GVariant *params[] = { g_variant_new_string (decoration ? decoration : ""), g_variant_new_string (separator ? separator : ""), g_variant_new_fixed_array (G_VARIANT_TYPE_UINT64, indexes, n_indexes, sizeof (guint64)) }; DBUS_CALL_THREE_PARAMS_ASYNC (MERGE, params); } /** * g_paste_client_on_extension_state_changed: * @self: a #GPasteClient instance * @state: the new state of the extension * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Call this when the extension changes its state * * Returns: */ G_PASTE_VISIBLE void g_paste_client_on_extension_state_changed (GPasteClient *self, gboolean state, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_ONE_PARAM_ASYNC (ON_EXTENSION_STATE_CHANGED, boolean, state); } /** * g_paste_client_reexecute: * @self: a #GPasteClient instance * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Reexecute the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_reexecute (GPasteClient *self, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_NO_PARAM_ASYNC (REEXECUTE); } /** * g_paste_client_rename_password: * @self: a #GPasteClient instance * @old_name: the old name of the password to rename * @new_name: the new name to give it * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: The data to pass to @callback. * * Rename the password in the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_rename_password (GPasteClient *self, const gchar *old_name, const gchar *new_name, GAsyncReadyCallback callback, gpointer user_data) { GVariant *params[] = { g_variant_new_string (old_name), g_variant_new_string (new_name) }; DBUS_CALL_TWO_PARAMS_ASYNC (RENAME_PASSWORD, params); } /** * g_paste_client_replace: * @self: a #GPasteClient instance * @index: the index of the element we want to replace * @contents: the replacement contents * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: The data to pass to @callback. * * Replace the contents of an item * * Returns: */ G_PASTE_VISIBLE void g_paste_client_replace (GPasteClient *self, guint64 index, const gchar *contents, GAsyncReadyCallback callback, gpointer user_data) { GVariant *params[] = { g_variant_new_uint64 (index), g_variant_new_string (contents) }; DBUS_CALL_TWO_PARAMS_ASYNC (REPLACE, params); } /** * g_paste_client_search: * @self: a #GPasteClient instance * @pattern: the pattern to look for in history * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Search for items matching @pattern in history * * Returns: */ G_PASTE_VISIBLE void g_paste_client_search (GPasteClient *self, const gchar *pattern, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_ONE_PARAM_ASYNC (SEARCH, string, pattern); } /** * g_paste_client_select: * @self: a #GPasteClient instance * @index: the index of the element we want to select * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Select an item from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_select (GPasteClient *self, guint64 index, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_ONE_PARAM_ASYNC (SELECT, uint64, index); } /** * g_paste_client_set_password: * @self: a #GPasteClient instance * @index: the index of the element we want to set as password * @name: the name to identify the password * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: The data to pass to @callback. * * Set the item as password * * Returns: */ G_PASTE_VISIBLE void g_paste_client_set_password (GPasteClient *self, guint64 index, const gchar *name, GAsyncReadyCallback callback, gpointer user_data) { GVariant *params[] = { g_variant_new_uint64 (index), g_variant_new_string (name) }; DBUS_CALL_TWO_PARAMS_ASYNC (SET_PASSWORD, params); } /** * g_paste_client_show_history: * @self: a #GPasteClient instance * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Emit the ShowHistory signal * * Returns: */ G_PASTE_VISIBLE void g_paste_client_show_history (GPasteClient *self, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_NO_PARAM_ASYNC (SHOW_HISTORY); } /** * g_paste_client_switch_history: * @self: a #GPasteClient instance * @name: the name of the history to switch to * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable):The data to pass to @callback. * * Switch to another history * * Returns: */ G_PASTE_VISIBLE void g_paste_client_switch_history (GPasteClient *self, const gchar *name, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_ONE_PARAM_ASYNC (SWITCH_HISTORY, string, name); } /** * g_paste_client_track: * @self: a #GPasteClient instance * @state: the new tracking state of the #GPasteDaemon * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Change the tracking state of the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_track (GPasteClient *self, gboolean state, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_ONE_PARAM_ASYNC (TRACK, boolean, state); } /** * g_paste_client_upload: * @self: a #GPasteClient instance * @index: the index of the element we want to upload * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Upload an item to a pastebin service * * Returns: */ G_PASTE_VISIBLE void g_paste_client_upload (GPasteClient *self, guint64 index, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_ONE_PARAM_ASYNC (UPLOAD, uint64, index); } /****************************/ /* Methods / Async - Finish */ /****************************/ /** * g_paste_client_about_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Display the about dialog * * Returns: */ G_PASTE_VISIBLE void g_paste_client_about_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /** * g_paste_client_add_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Add an item to the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_add_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /** * g_paste_client_add_file_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Add the file contents to the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_add_file_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /** * g_paste_client_add_password_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Add the password to the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_add_password_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /** * g_paste_client_backup_history_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Backup the current history * * Returns: */ G_PASTE_VISIBLE void g_paste_client_backup_history_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /** * g_paste_client_delete_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Delete an item from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_delete_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /** * g_paste_client_delete_history_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Delete an history * * Returns: */ G_PASTE_VISIBLE void g_paste_client_delete_history_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /** * g_paste_client_delete_password_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Delete the password from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_delete_password_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /** * g_paste_client_empty_history_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Empty the history from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_empty_history_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /** * g_paste_client_get_element_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Get an item from the #GPasteDaemon * * Returns: (transfer full): a newly allocated string */ G_PASTE_VISIBLE gchar * g_paste_client_get_element_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_RET_STRING; } static gchar * _g_paste_client_get_element_kind_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_RET_STRING; } /** * g_paste_client_get_element_kind_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Get this kind of an item from the #GPasteDaemon * * Returns: The #GPasteItemKind */ G_PASTE_VISIBLE GPasteItemKind g_paste_client_get_element_kind_finish (GPasteClient *self, GAsyncResult *result, GError **error) { g_autofree gchar *kind = _g_paste_client_get_element_kind_finish (self, result, error); GEnumValue *k = (kind) ? g_enum_get_value_by_nick (g_type_class_peek (G_PASTE_TYPE_ITEM_KIND), kind) : NULL; return (k) ? k->value : G_PASTE_ITEM_KIND_INVALID; } /** * g_paste_client_get_elements_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Get some items from the #GPasteDaemon * * Returns: (transfer full): a newly allocated array of string */ G_PASTE_VISIBLE GStrv g_paste_client_get_elements_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_RET_STRV; } /** * g_paste_client_get_history_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Get the history from the #GPasteDaemon * * Returns: (transfer full): a newly allocated array of string */ G_PASTE_VISIBLE GStrv g_paste_client_get_history_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_RET_STRV; } /** * g_paste_client_get_history_name_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Get the name of the history from the #GPasteDaemon * * Returns: (transfer full): a newly allocated array of string */ G_PASTE_VISIBLE gchar * g_paste_client_get_history_name_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_RET_STRING; } /** * g_paste_client_get_history_size_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Get the history size from the #GPasteDaemon * * Returns: the size of the history */ G_PASTE_VISIBLE guint64 g_paste_client_get_history_size_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_RET_UINT64; } /** * g_paste_client_get_raw_element_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Get an item from the #GPasteDaemon * * Returns: (transfer full): a newly allocated string */ G_PASTE_VISIBLE gchar * g_paste_client_get_raw_element_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_RET_STRING; } /** * g_paste_client_get_raw_history_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Get the history from the #GPasteDaemon * * Returns: (transfer full): a newly allocated array of string */ G_PASTE_VISIBLE GStrv g_paste_client_get_raw_history_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_RET_STRV; } /** * g_paste_client_list_histories_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * List all available hisotries * * Returns: (transfer full): a newly allocated array of string */ G_PASTE_VISIBLE GStrv g_paste_client_list_histories_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_RET_STRV; } /** * g_paste_client_merge_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Merge some history entries * * Returns: */ G_PASTE_VISIBLE void g_paste_client_merge_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /** * g_paste_client_on_extension_state_changed_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Call this when the extension changes its state * * Returns: */ G_PASTE_VISIBLE void g_paste_client_on_extension_state_changed_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /** * g_paste_client_reexecute_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Reexecute the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_reexecute_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /** * g_paste_client_rename_password_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Rename the password in the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_rename_password_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /** * g_paste_client_replace_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Replace the contents of an item * * Returns: */ G_PASTE_VISIBLE void g_paste_client_replace_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /** * g_paste_client_search_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @hits: (out) (optional): number of hits * @error: a #GError * * Search for items matching @pattern in history * * Returns: (array length=hits): The indexes of the matching items */ G_PASTE_VISIBLE guint64 * g_paste_client_search_finish (GPasteClient *self, GAsyncResult *result, guint64 *hits, GError **error) { DBUS_ASYNC_FINISH_RET_AT (hits); } /** * g_paste_client_select_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Select an item from the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_select_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /** * g_paste_client_set_password_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Set the item as password * * Returns: */ G_PASTE_VISIBLE void g_paste_client_set_password_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /** * g_paste_client_show_history_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Emit the ShowHistory signal * * Returns: */ G_PASTE_VISIBLE void g_paste_client_show_history_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /** * g_paste_client_switch_history_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Switch to another history * * Returns: */ G_PASTE_VISIBLE void g_paste_client_switch_history_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /** * g_paste_client_track_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Change the tracking state of the #GPasteDaemon * * Returns: */ G_PASTE_VISIBLE void g_paste_client_track_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /** * g_paste_client_upload_finish: * @self: a #GPasteClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Upload an item to a pastebin service * * Returns: */ G_PASTE_VISIBLE void g_paste_client_upload_finish (GPasteClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_NO_RETURN; } /**************/ /* Properties */ /**************/ /** * g_paste_client_is_active: * @self: a #GPasteClient instance * * Check if the daemon is active * * Returns: whether the daemon is active or not */ G_PASTE_VISIBLE gboolean g_paste_client_is_active (GPasteClient *self) { DBUS_GET_BOOLEAN_PROPERTY (ACTIVE); } /** * g_paste_client_get_version: * @self: a #GPasteClient instance * * Get the version of the running gpaste daemon * * Returns: the version of the daemon */ G_PASTE_VISIBLE gchar * g_paste_client_get_version (GPasteClient *self) { DBUS_GET_STRING_PROPERTY (VERSION); } static void g_paste_client_g_signal (GDBusProxy *proxy, const gchar *sender_name G_GNUC_UNUSED, const gchar *signal_name, GVariant *parameters) { GPasteClient *self = G_PASTE_CLIENT (proxy); HANDLE_SIGNAL (SHOW_HISTORY) else HANDLE_SIGNAL_WITH_DATA (DELETE_HISTORY, const gchar *, g_variant_get_string (variant, NULL)) else HANDLE_SIGNAL_WITH_DATA (EMPTY_HISTORY, const gchar *, g_variant_get_string (variant, NULL)) else HANDLE_SIGNAL_WITH_DATA (SWITCH_HISTORY, const gchar *, g_variant_get_string (variant, NULL)) else HANDLE_SIGNAL_WITH_DATA (TRACKING, gboolean, g_variant_get_boolean (variant)) else if (!g_strcmp0 (signal_name, G_PASTE_DAEMON_SIG_UPDATE)) { GVariantIter params_iter; g_variant_iter_init (¶ms_iter, parameters); g_autoptr (GVariant) v1 = g_variant_iter_next_value (¶ms_iter); g_autoptr (GVariant) v2 = g_variant_iter_next_value (¶ms_iter); g_autoptr (GVariant) v3 = g_variant_iter_next_value (¶ms_iter); g_signal_emit (self, signals[UPDATE], 0, /* detail */ g_enum_get_value_by_nick (g_type_class_peek (G_PASTE_TYPE_UPDATE_ACTION), g_variant_get_string (v1, NULL))->value, g_enum_get_value_by_nick (g_type_class_peek (G_PASTE_TYPE_UPDATE_TARGET), g_variant_get_string (v2, NULL))->value, g_variant_get_uint64 (v3), NULL); } } static void g_paste_client_class_init (GPasteClientClass *klass) { G_DBUS_PROXY_CLASS (klass)->g_signal = g_paste_client_g_signal; /** * GPasteClient::delete-history: * @client: the object on which the signal was emitted * @history: the name of the history we deleted * * The "delete-history" signal is emitted when we delete * an history. */ signals[DELETE_HISTORY] = NEW_SIGNAL_WITH_DATA ("delete-history", STRING); /** * GPasteClient::empty-history: * @client: the object on which the signal was emitted * @history: the name of the history we emptied * * The "delete-history" signal is emitted when we empty * an history. */ signals[EMPTY_HISTORY] = NEW_SIGNAL_WITH_DATA ("empty-history", STRING); /** * GPasteClient::show-history: * @client: the object on which the signal was emitted * * The "show-history" signal is emitted when we switch * from an history to another. */ signals[SHOW_HISTORY] = NEW_SIGNAL ("show-history"); /** * GPasteClient::switch-history: * @client: the object on which the signal was emitted * @history: the name of the history we switch to * * The "switch-history" signal is emitted when we switch * from an history to another. */ signals[SWITCH_HISTORY] = NEW_SIGNAL_WITH_DATA ("switch-history", STRING); /** * GPasteClient::track: * @client: the object on which the signal was emitted * @tracking_state: whether we're now tracking or not * * The "track" signal is emitted when the daemon starts or stops tracking * clipboard changes. */ signals[TRACKING] = NEW_SIGNAL_WITH_DATA ("tracking", BOOLEAN); /** * GPasteClient::update: * @client: the object on which the signal was emitted * @action: the kind of update * @target: the items which need updating * @index: the index of the item, when the target is POSITION * * The "update" signal is emitted whenever anything changed * in the history (something was added, removed, selected, replaced...). */ signals[UPDATE] = g_signal_new ("update", G_PASTE_TYPE_CLIENT, G_SIGNAL_RUN_LAST, 0, /* class offset */ NULL, /* accumulator */ NULL, /* accumulator data */ g_cclosure_marshal_generic, G_TYPE_NONE, 3, /* number of params */ G_PASTE_TYPE_UPDATE_ACTION, G_PASTE_TYPE_UPDATE_TARGET, G_TYPE_UINT64); } static void g_paste_client_init (GPasteClient *self) { GDBusProxy *proxy = G_DBUS_PROXY (self); g_autoptr (GDBusNodeInfo) g_paste_daemon_dbus_info = g_dbus_node_info_new_for_xml (G_PASTE_DAEMON_INTERFACE, NULL); /* Error */ g_dbus_proxy_set_interface_info (proxy, g_paste_daemon_dbus_info->interfaces[0]); } /** * g_paste_client_new_sync: * @error: Return location for error or %NULL. * * Create a new instance of #GPasteClient * * Returns: (transfer full): a newly allocated #GPasteClient * free it with g_object_unref */ G_PASTE_VISIBLE GPasteClient * g_paste_client_new_sync (GError **error) { CUSTOM_PROXY_NEW (CLIENT, DAEMON, G_PASTE_BUS_NAME); } /** * g_paste_client_new: * @callback: Callback function to invoke when the proxy is ready. * @user_data: User data to pass to @callback. * * Create a new instance of #GPasteClient * * Returns: */ G_PASTE_VISIBLE void g_paste_client_new (GAsyncReadyCallback callback, gpointer user_data) { CUSTOM_PROXY_NEW_ASYNC (CLIENT, DAEMON, G_PASTE_BUS_NAME); } /** * g_paste_client_new_finish: * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback function passed to the async ctor. * @error: Return location for error or %NULL. * * Create a new instance of #GPasteClient * * Returns: (transfer full): a newly allocated #GPasteClient * free it with g_object_unref */ G_PASTE_VISIBLE GPasteClient * g_paste_client_new_finish (GAsyncResult *result, GError **error) { CUSTOM_PROXY_NEW_FINISH (CLIENT); } GPaste-3.18.6/src/libgpaste/client/gpaste-client.h000066400000000000000000000627511305131721400217330ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2012-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_CLIENT_H__ #define __G_PASTE_CLIENT_H__ #include #include G_BEGIN_DECLS #define G_PASTE_TYPE_CLIENT (g_paste_client_get_type ()) G_PASTE_FINAL_TYPE (Client, client, CLIENT, GDBusProxy) /*******************/ /* Methods / Sync */ /*******************/ void g_paste_client_about_sync (GPasteClient *self, GError **error); void g_paste_client_add_sync (GPasteClient *self, const gchar *text, GError **error); void g_paste_client_add_file_sync (GPasteClient *self, const gchar *file, GError **error); void g_paste_client_add_password_sync (GPasteClient *self, const gchar *name, const gchar *password, GError **error); void g_paste_client_backup_history_sync (GPasteClient *self, const gchar *history, const gchar *backup, GError **error); void g_paste_client_delete_sync (GPasteClient *self, guint64 index, GError **error); void g_paste_client_delete_history_sync (GPasteClient *self, const gchar *name, GError **error); void g_paste_client_delete_password_sync (GPasteClient *self, const gchar *name, GError **error); void g_paste_client_empty_history_sync (GPasteClient *self, const gchar *name, GError **error); gchar *g_paste_client_get_element_sync (GPasteClient *self, guint64 index, GError **error); GStrv g_paste_client_get_elements_sync (GPasteClient *self, const guint64 *indexes, guint64 n_indexes, GError **error); GStrv g_paste_client_get_history_sync (GPasteClient *self, GError **error); gchar *g_paste_client_get_history_name_sync (GPasteClient *self, GError **error); guint64 g_paste_client_get_history_size_sync (GPasteClient *self, const gchar *name, GError **error); gchar *g_paste_client_get_raw_element_sync (GPasteClient *self, guint64 index, GError **error); GStrv g_paste_client_get_raw_history_sync (GPasteClient *self, GError **error); GStrv g_paste_client_list_histories_sync (GPasteClient *self, GError **error); void g_paste_client_merge_sync (GPasteClient *self, const gchar *decoration, const gchar *separator, const guint64 *indexes, guint64 n_indexes, GError **error); void g_paste_client_on_extension_state_changed_sync (GPasteClient *self, gboolean state, GError **error); void g_paste_client_reexecute_sync (GPasteClient *self, GError **error); void g_paste_client_rename_password_sync (GPasteClient *self, const gchar *old_name, const gchar *new_name, GError **error); void g_paste_client_replace_sync (GPasteClient *self, guint64 index, const gchar *contents, GError **error); guint64 *g_paste_client_search_sync (GPasteClient *self, const gchar *pattern, guint64 *hits, GError **error); void g_paste_client_select_sync (GPasteClient *self, guint64 index, GError **error); void g_paste_client_set_password_sync (GPasteClient *self, guint64 index, const gchar *name, GError **error); void g_paste_client_show_history_sync (GPasteClient *self, GError **error); void g_paste_client_switch_history_sync (GPasteClient *self, const gchar *name, GError **error); void g_paste_client_track_sync (GPasteClient *self, gboolean state, GError **error); void g_paste_client_upload_sync (GPasteClient *self, guint64 index, GError **error); GPasteItemKind g_paste_client_get_element_kind_sync (GPasteClient *self, guint64 index, GError **error); /*******************/ /* Methods / Async */ /*******************/ void g_paste_client_about (GPasteClient *self, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_add (GPasteClient *self, const gchar *text, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_add_file (GPasteClient *self, const gchar *file, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_add_password (GPasteClient *self, const gchar *name, const gchar *password, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_backup_history (GPasteClient *self, const gchar *history, const gchar *backup, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_delete (GPasteClient *self, guint64 index, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_delete_history (GPasteClient *self, const gchar *name, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_delete_password (GPasteClient *self, const gchar *name, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_empty_history (GPasteClient *self, const gchar *name, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_get_element (GPasteClient *self, guint64 index, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_get_element_kind (GPasteClient *self, guint64 index, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_get_elements (GPasteClient *self, const guint64 *indexes, guint64 n_indexes, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_get_history (GPasteClient *self, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_get_history_name (GPasteClient *self, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_get_history_size (GPasteClient *self, const gchar *name, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_get_raw_element (GPasteClient *self, guint64 index, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_get_raw_history (GPasteClient *self, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_list_histories (GPasteClient *self, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_merge (GPasteClient *self, const gchar *decoration, const gchar *separator, const guint64 *indexes, guint64 n_indexes, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_on_extension_state_changed (GPasteClient *self, gboolean state, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_reexecute (GPasteClient *self, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_rename_password (GPasteClient *self, const gchar *old_name, const gchar *new_name, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_replace (GPasteClient *self, guint64 index, const gchar *contents, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_search (GPasteClient *self, const gchar *pattern, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_select (GPasteClient *self, guint64 index, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_set_password (GPasteClient *self, guint64 index, const gchar *name, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_show_history (GPasteClient *self, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_switch_history (GPasteClient *self, const gchar *name, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_track (GPasteClient *self, gboolean state, GAsyncReadyCallback callback, gpointer user_data); void g_paste_client_upload (GPasteClient *self, guint64 index, GAsyncReadyCallback callback, gpointer user_data); /****************************/ /* Methods / Async - Finish */ /****************************/ void g_paste_client_about_finish (GPasteClient *self, GAsyncResult *result, GError **error); void g_paste_client_add_finish (GPasteClient *self, GAsyncResult *result, GError **error); void g_paste_client_add_file_finish (GPasteClient *self, GAsyncResult *result, GError **error); void g_paste_client_add_password_finish (GPasteClient *self, GAsyncResult *result, GError **error); void g_paste_client_backup_history_finish (GPasteClient *self, GAsyncResult *result, GError **error); void g_paste_client_delete_finish (GPasteClient *self, GAsyncResult *result, GError **error); void g_paste_client_delete_history_finish (GPasteClient *self, GAsyncResult *result, GError **error); void g_paste_client_delete_password_finish (GPasteClient *self, GAsyncResult *result, GError **error); void g_paste_client_empty_history_finish (GPasteClient *self, GAsyncResult *result, GError **error); gchar *g_paste_client_get_element_finish (GPasteClient *self, GAsyncResult *result, GError **error); GStrv g_paste_client_get_elements_finish (GPasteClient *self, GAsyncResult *result, GError **error); GStrv g_paste_client_get_history_finish (GPasteClient *self, GAsyncResult *result, GError **error); gchar *g_paste_client_get_history_name_finish (GPasteClient *self, GAsyncResult *result, GError **error); guint64 g_paste_client_get_history_size_finish (GPasteClient *self, GAsyncResult *result, GError **error); gchar *g_paste_client_get_raw_element_finish (GPasteClient *self, GAsyncResult *result, GError **error); GStrv g_paste_client_get_raw_history_finish (GPasteClient *self, GAsyncResult *result, GError **error); GStrv g_paste_client_list_histories_finish (GPasteClient *self, GAsyncResult *result, GError **error); void g_paste_client_merge_finish (GPasteClient *self, GAsyncResult *result, GError **error); void g_paste_client_on_extension_state_changed_finish (GPasteClient *self, GAsyncResult *result, GError **error); void g_paste_client_reexecute_finish (GPasteClient *self, GAsyncResult *result, GError **error); void g_paste_client_rename_password_finish (GPasteClient *self, GAsyncResult *result, GError **error); void g_paste_client_replace_finish (GPasteClient *self, GAsyncResult *result, GError **error); guint64 *g_paste_client_search_finish (GPasteClient *self, GAsyncResult *result, guint64 *hits, GError **error); void g_paste_client_select_finish (GPasteClient *self, GAsyncResult *result, GError **error); void g_paste_client_set_password_finish (GPasteClient *self, GAsyncResult *result, GError **error); void g_paste_client_show_history_finish (GPasteClient *self, GAsyncResult *result, GError **error); void g_paste_client_switch_history_finish (GPasteClient *self, GAsyncResult *result, GError **error); void g_paste_client_track_finish (GPasteClient *self, GAsyncResult *result, GError **error); void g_paste_client_upload_finish (GPasteClient *self, GAsyncResult *result, GError **error); GPasteItemKind g_paste_client_get_element_kind_finish (GPasteClient *self, GAsyncResult *result, GError **error); /**************/ /* Properties */ /**************/ gboolean g_paste_client_is_active (GPasteClient *self); gchar *g_paste_client_get_version (GPasteClient *self); /****************/ /* Constructors */ /****************/ GPasteClient *g_paste_client_new_sync (GError **error); void g_paste_client_new (GAsyncReadyCallback callback, gpointer user_data); GPasteClient *g_paste_client_new_finish (GAsyncResult *result, GError **error); G_END_DECLS #endif /*__G_PASTE_CLIENT_H__*/ GPaste-3.18.6/src/libgpaste/core/000077500000000000000000000000001305131721400164625ustar00rootroot00000000000000GPaste-3.18.6/src/libgpaste/core/gpaste-clipboard.c000066400000000000000000000641321305131721400220540ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include #include #include struct _GPasteClipboard { GObject parent_instance; }; typedef enum { CLIP_STATE_IDLE, CLIP_STATE_WAITING, CLIP_STATE_BUSY } ClipState; typedef struct { GdkAtom target; GtkClipboard *real; GPasteSettings *settings; gchar *text; gchar *image_checksum; gulong owner_change_signal; /* GtkClipboard has a bug where it overrides an internal GMainLoop * if we call gtk_clipboard_store twice in less than 10s, resulting * in a g_main_loop_quit (NULL) call making GPaste crash */ ClipState state; } GPasteClipboardPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteClipboard, g_paste_clipboard, G_TYPE_OBJECT) enum { OWNER_CHANGE, LAST_SIGNAL }; static guint64 signals[LAST_SIGNAL] = { 0 }; static void g_paste_clipboard_bootstrap_finish (GPasteClipboard *self, GPasteHistory *history) { GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); if (!priv->text && !priv->image_checksum) { const GSList *h = g_paste_history_get_history (history); if (h) { GPasteItem *item = h->data; if (!g_paste_clipboard_select_item (self, item)) g_paste_history_remove (history, 0); } } } static void g_paste_clipboard_bootstrap_finish_text (GPasteClipboard *self, const gchar *text G_GNUC_UNUSED, gpointer user_data) { g_paste_clipboard_bootstrap_finish (self, user_data); } static void g_paste_clipboard_bootstrap_finish_image (GPasteClipboard *self, GdkPixbuf *image G_GNUC_UNUSED, gpointer user_data) { g_paste_clipboard_bootstrap_finish (self, user_data); } /** * g_paste_clipboard_bootstrap: * @self: a #GPasteClipboard instance * @history: a #GPasteHistory instance * * Bootstrap a #GPasteClipboard with an initial value * * Returns: */ G_PASTE_VISIBLE void g_paste_clipboard_bootstrap (GPasteClipboard *self, GPasteHistory *history) { g_return_if_fail (G_PASTE_IS_CLIPBOARD (self)); g_return_if_fail (G_PASTE_IS_HISTORY (history)); GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); GtkClipboard *real = priv->real; if (gtk_clipboard_wait_is_uris_available (real) || gtk_clipboard_wait_is_text_available (real)) { g_paste_clipboard_set_text (self, g_paste_clipboard_bootstrap_finish_text, history); } else if (g_paste_settings_get_images_support (priv->settings) && gtk_clipboard_wait_is_image_available (real)) { g_paste_clipboard_set_image (self, g_paste_clipboard_bootstrap_finish_image, history); } else { g_paste_clipboard_ensure_not_empty (self, history); } } /** * g_paste_clipboard_get_target: * @self: a #GPasteClipboard instance * * Get the target the #GPasteClipboard points to * * Returns: (transfer none): the GdkAtom representing the target (Primary, Clipboard, ...) */ G_PASTE_VISIBLE GdkAtom g_paste_clipboard_get_target (const GPasteClipboard *self) { g_return_val_if_fail (G_PASTE_IS_CLIPBOARD (self), NULL); GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); return priv->target; } /** * g_paste_clipboard_get_real: * @self: a #GPasteClipboard instance * * Get the GtkClipboard linked to the #GPasteClipboard * * Returns: (transfer none): the GtkClipboard used in the #GPasteClipboard */ G_PASTE_VISIBLE GtkClipboard * g_paste_clipboard_get_real (const GPasteClipboard *self) { g_return_val_if_fail (G_PASTE_IS_CLIPBOARD (self), NULL); GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); return priv->real; } /** * g_paste_clipboard_get_text: * @self: a #GPasteClipboard instance * * Get the text stored in the #GPasteClipboard * * Returns: read-only string containing the text or NULL */ G_PASTE_VISIBLE const gchar * g_paste_clipboard_get_text (const GPasteClipboard *self) { g_return_val_if_fail (G_PASTE_IS_CLIPBOARD (self), NULL); GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); return priv->text; } static const gchar * _g_paste_clipboard_private_target_name (const GPasteClipboardPrivate *priv) { if (priv->target == GDK_SELECTION_CLIPBOARD) return "CLIPBOARD"; else if (priv->target == GDK_SELECTION_PRIMARY) return "PRIMARY"; else return "UNKNOWN"; } static void g_paste_clipboard_private_set_text (GPasteClipboardPrivate *priv, const gchar *text) { g_free (priv->text); g_free (priv->image_checksum); g_debug("%s: set text", _g_paste_clipboard_private_target_name (priv)); priv->text = g_strdup (text); priv->image_checksum = NULL; } typedef struct { GPasteClipboard *self; GPasteClipboardTextCallback callback; gpointer user_data; } GPasteClipboardTextCallbackData; static void g_paste_clipboard_on_text_ready (GtkClipboard *clipboard G_GNUC_UNUSED, const gchar *text, gpointer user_data) { g_autofree GPasteClipboardTextCallbackData *data = user_data; GPasteClipboard *self = data->self; if (!text) { if (data->callback) data->callback (self, NULL, data->user_data); return; } GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); GPasteSettings *settings = priv->settings; g_autofree gchar *stripped = g_strstrip (g_strdup (text)); gboolean trim_items = g_paste_settings_get_trim_items (settings); const gchar *to_add = trim_items ? stripped : text; guint64 length = strlen (to_add); if (length < g_paste_settings_get_min_text_item_size (settings) || length > g_paste_settings_get_max_text_item_size (settings) || !strlen (stripped)) { if (data->callback) data->callback (self, NULL, data->user_data); return; } if (priv->text && !g_strcmp0 (priv->text, to_add)) { if (data->callback) data->callback (self, NULL, data->user_data); return; } if (trim_items && priv->target == GDK_SELECTION_CLIPBOARD && g_strcmp0 (text, stripped)) g_paste_clipboard_select_text (self, stripped); else g_paste_clipboard_private_set_text (priv, to_add); if (data->callback) data->callback (self, priv->text, data->user_data); } /** * g_paste_clipboard_set_text: * @self: a #GPasteClipboard instance * @callback: (scope async): the callback to be called when text is received * @user_data: user data to pass to @callback * * Put the text from the intern GtkClipboard in the #GPasteClipboard * * Returns: */ G_PASTE_VISIBLE void g_paste_clipboard_set_text (GPasteClipboard *self, GPasteClipboardTextCallback callback, gpointer user_data) { g_return_if_fail (G_PASTE_IS_CLIPBOARD (self)); GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); GPasteClipboardTextCallbackData *data = g_new (GPasteClipboardTextCallbackData, 1); data->self = self; data->callback = callback; data->user_data = user_data; gtk_clipboard_request_text (priv->real, g_paste_clipboard_on_text_ready, data); } static void g_paste_clipboard_private_store (GPasteClipboardPrivate *priv); static gboolean g_paste_clipboard_private_store_timeout (gpointer user_data) { GPasteClipboardPrivate *priv = user_data; gboolean waiting = (priv->state == CLIP_STATE_WAITING); /* Reset us as IDLE */ priv->state = CLIP_STATE_IDLE; /* If we were waiting, perform the store now */ if (waiting) g_paste_clipboard_private_store (priv); return G_SOURCE_REMOVE; } static void g_paste_clipboard_private_store (GPasteClipboardPrivate *priv) { g_debug("%s: store", _g_paste_clipboard_private_target_name (priv)); switch (priv->state) { case CLIP_STATE_IDLE: /* We're idle, store right now and mark us BUSY for 10 secs */ gtk_clipboard_store (priv->real); priv->state = CLIP_STATE_BUSY; g_timeout_add_seconds (10, g_paste_clipboard_private_store_timeout, priv); break; case CLIP_STATE_BUSY: /* We're busy, wait until we're finished to store once more */ priv->state = CLIP_STATE_WAITING; break; case CLIP_STATE_WAITING: /* We're already waiting, nothing to do */ break; } } /** * g_paste_clipboard_select_text: * @self: a #GPasteClipboard instance * @text: the text to select * * Put the text into the #GPasteClipbaord and the intern GtkClipboard * * Returns: */ G_PASTE_VISIBLE void g_paste_clipboard_select_text (GPasteClipboard *self, const gchar *text) { g_return_if_fail (G_PASTE_IS_CLIPBOARD (self)); g_return_if_fail (text); g_return_if_fail (g_utf8_validate (text, -1, NULL)); GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); g_debug("%s: select text", _g_paste_clipboard_private_target_name (priv)); /* Avoid cycling twice as gtk_clipboard_set_text will make the clipboards manager react */ g_paste_clipboard_private_set_text (priv, text); gtk_clipboard_set_text (priv->real, text, -1); g_paste_clipboard_private_store (priv); } static void g_paste_clipboard_get_clipboard_data (GtkClipboard *clipboard G_GNUC_UNUSED, GtkSelectionData *selection_data, guint32 info G_GNUC_UNUSED, gpointer user_data_or_owner) { g_return_if_fail (G_PASTE_IS_ITEM (user_data_or_owner)); GPasteItem *item = G_PASTE_ITEM (user_data_or_owner); GdkAtom targets[1] = { gtk_selection_data_get_target (selection_data) }; /* The content is requested as text */ if (gtk_targets_include_text (targets, 1)) gtk_selection_data_set_text (selection_data, g_paste_item_get_real_value (item), -1); else if (G_PASTE_IS_IMAGE_ITEM (item)) { if (gtk_targets_include_image (targets, 1, TRUE)) gtk_selection_data_set_pixbuf (selection_data, g_paste_image_item_get_image (G_PASTE_IMAGE_ITEM (item))); } /* The content is requested as uris */ else { g_return_if_fail (G_PASTE_IS_URIS_ITEM (item)); const gchar * const *uris = g_paste_uris_item_get_uris (G_PASTE_URIS_ITEM (item)); if (gtk_targets_include_uri (targets, 1)) gtk_selection_data_set_uris (selection_data, (GStrv) uris); /* The content is requested as special gnome-copied-files by nautilus */ else { g_autoptr (GString) copy_string = g_string_new ("copy"); guint64 length = g_strv_length ((GStrv) uris); for (guint64 i = 0; i < length; ++i) g_string_append_printf (copy_string, "\n%s", uris[i]); gchar *str = copy_string->str; length = copy_string->len + 1; g_autofree guchar *copy_files_data = g_new (guchar, length); for (guint64 i = 0; i < length; ++i) copy_files_data[i] = (guchar) str[i]; gtk_selection_data_set (selection_data, g_paste_clipboard_copy_files_target, 8, copy_files_data, length); } } } static void g_paste_clipboard_clear_clipboard_data (GtkClipboard *clipboard G_GNUC_UNUSED, gpointer user_data_or_owner) { g_object_unref (user_data_or_owner); } static void g_paste_clipboard_private_select_uris (GPasteClipboardPrivate *priv, GPasteUrisItem *item) { GtkClipboard *real = priv->real; g_autoptr (GtkTargetList) target_list = gtk_target_list_new (NULL, 0); g_debug("%s: select uris", _g_paste_clipboard_private_target_name (priv)); g_paste_clipboard_private_set_text (priv, g_paste_item_get_real_value (G_PASTE_ITEM (item))); gtk_target_list_add_text_targets (target_list, 0); gtk_target_list_add_uri_targets (target_list, 0); gtk_target_list_add (target_list, g_paste_clipboard_copy_files_target, 0, 0); gint32 n_targets; GtkTargetEntry *targets = gtk_target_table_new_from_list (target_list, &n_targets); gtk_clipboard_set_with_owner (real, targets, n_targets, g_paste_clipboard_get_clipboard_data, g_paste_clipboard_clear_clipboard_data, g_object_ref (item)); g_paste_clipboard_private_store (priv); gtk_target_table_free (targets, n_targets); } /** * g_paste_clipboard_clear: * @self: a #GPasteClipboard instance * * Clears the content of the clipboard * * Returns: */ G_PASTE_VISIBLE void g_paste_clipboard_clear (GPasteClipboard *self) { g_return_if_fail (G_PASTE_IS_CLIPBOARD (self)); GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); /* We're already clear, don't enter an infinite event loop */ if (!priv->text && !priv->image_checksum) return; g_debug("%s: clear", _g_paste_clipboard_private_target_name (priv)); g_clear_pointer (&priv->text, g_free); g_clear_pointer (&priv->image_checksum, g_free); gtk_clipboard_clear (priv->real); } /** * g_paste_clipboard_get_image_checksum: * @self: a #GPasteClipboard instance * * Get the checksum of the image stored in the #GPasteClipboard * * Returns: read-only string containing the checksum of the image stored in the #GPasteClipboard or NULL */ G_PASTE_VISIBLE const gchar * g_paste_clipboard_get_image_checksum (const GPasteClipboard *self) { g_return_val_if_fail (G_PASTE_IS_CLIPBOARD (self), NULL); GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); return priv->image_checksum; } static void g_paste_clipboard_private_set_image_checksum (GPasteClipboardPrivate *priv, const gchar *image_checksum) { g_free (priv->text); g_free (priv->image_checksum); priv->text = NULL; priv->image_checksum = g_strdup (image_checksum); } static void g_paste_clipboard_private_select_image (GPasteClipboardPrivate *priv, GdkPixbuf *image, const gchar *checksum) { g_return_if_fail (GDK_IS_PIXBUF (image)); GtkClipboard *real = priv->real; g_debug("%s: select image", _g_paste_clipboard_private_target_name (priv)); g_paste_clipboard_private_set_image_checksum (priv, checksum); gtk_clipboard_set_image (real, image); } typedef struct { GPasteClipboard *self; GPasteClipboardImageCallback callback; gpointer user_data; } GPasteClipboardImageCallbackData; static void g_paste_clipboard_on_image_ready (GtkClipboard *clipboard G_GNUC_UNUSED, GdkPixbuf *image, gpointer user_data) { g_autofree GPasteClipboardImageCallbackData *data = user_data; GPasteClipboard *self = data->self; if (!image) { if (data->callback) data->callback (self, NULL, data->user_data); return; } GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); g_autofree gchar *checksum = g_compute_checksum_for_data (G_CHECKSUM_SHA256, (guchar *) gdk_pixbuf_get_pixels (image), -1); if (g_strcmp0 (checksum, priv->image_checksum)) { g_paste_clipboard_private_select_image (priv, image, checksum); } else { image = NULL; } if (data->callback) data->callback (self, image, data->user_data); } /** * g_paste_clipboard_set_image: * @self: a #GPasteClipboard instance * @callback: (scope async): the callback to be called when text is received * @user_data: user data to pass to @callback * * Put the image from the intern GtkClipboard in the #GPasteClipboard * * Returns: */ G_PASTE_VISIBLE void g_paste_clipboard_set_image (GPasteClipboard *self, GPasteClipboardImageCallback callback, gpointer user_data) { g_return_if_fail (G_PASTE_IS_CLIPBOARD (self)); GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); GPasteClipboardImageCallbackData *data = g_new (GPasteClipboardImageCallbackData, 1); data->self = self; data->callback = callback; data->user_data = user_data; gtk_clipboard_request_image (priv->real, g_paste_clipboard_on_image_ready, data); } /** * g_paste_clipboard_select_item: * @self: a #GPasteClipboard instance * @item: the item to select * * Put the value of the item into the #GPasteClipbaord and the intern GtkClipboard * * Returns: %FALSE if the item was invalid, %TRUE otherwise */ G_PASTE_VISIBLE gboolean g_paste_clipboard_select_item (GPasteClipboard *self, const GPasteItem *item) { g_return_val_if_fail (G_PASTE_IS_CLIPBOARD (self), FALSE); g_return_val_if_fail (G_PASTE_IS_ITEM (item), FALSE); GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); g_debug("%s: select item", _g_paste_clipboard_private_target_name (priv)); if (G_PASTE_IS_IMAGE_ITEM (item)) { GPasteImageItem *image_item = G_PASTE_IMAGE_ITEM (item); const gchar *checksum = g_paste_image_item_get_checksum (image_item); GdkPixbuf *image = g_paste_image_item_get_image (image_item); if (!image || !GDK_IS_PIXBUF (image)) return FALSE; else if (g_strcmp0 (checksum, priv->image_checksum)) g_paste_clipboard_private_select_image (priv, image, checksum); } else { const gchar *text = g_paste_item_get_real_value (item); if (g_strcmp0 (text, priv->text)) { if (G_PASTE_IS_URIS_ITEM (item)) g_paste_clipboard_private_select_uris (priv, G_PASTE_URIS_ITEM (item)); else if (G_PASTE_IS_TEXT_ITEM (item)) g_paste_clipboard_select_text (self, text); else g_assert_not_reached (); } } return TRUE; } /** * g_paste_clipboard_ensure_not_empty: * @self: a #GPasteClipboard instance * @history: a #GPasteHistory instance * * Ensure the clipboard has some contents (as long as the history's not empty) * * Returns: */ G_PASTE_VISIBLE void g_paste_clipboard_ensure_not_empty (GPasteClipboard *self, GPasteHistory *history) { g_return_if_fail (G_PASTE_IS_CLIPBOARD (self)); g_return_if_fail (G_PASTE_IS_HISTORY (history)); const GSList *hist = g_paste_history_get_history (history); if (hist) { GPasteItem *item = hist->data; if (!g_paste_clipboard_select_item (self, item)) g_paste_history_remove (history, 0); } } static void g_paste_clipboard_owner_change (GtkClipboard *clipboard G_GNUC_UNUSED, GdkEventOwnerChange *event, gpointer user_data) { GPasteClipboard *self = user_data; GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); g_debug("%s: owner change", _g_paste_clipboard_private_target_name (priv)); g_signal_emit (self, signals[OWNER_CHANGE], 0, /* detail */ event, NULL); } static void g_paste_clipboard_fake_event_finish_text (GtkClipboard *clipboard G_GNUC_UNUSED, const gchar *text, gpointer user_data) { GPasteClipboard *self = user_data; GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); if (g_strcmp0 (text, priv->text)) g_paste_clipboard_owner_change (NULL, NULL, self); } static void g_paste_clipboard_fake_event_finish_image (GtkClipboard *clipboard G_GNUC_UNUSED, GdkPixbuf *image, gpointer user_data) { GPasteClipboard *self = user_data; GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); g_autofree gchar *checksum = g_paste_util_compute_checksum (image); if (g_strcmp0 (checksum, priv->image_checksum)) g_paste_clipboard_owner_change (NULL, NULL, self); g_object_unref (image); } static gboolean g_paste_clipboard_fake_event (gpointer user_data) { GPasteClipboard *self = user_data; GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); if (priv->text) gtk_clipboard_request_text (priv->real, g_paste_clipboard_fake_event_finish_text, self); else if (priv->image_checksum) gtk_clipboard_request_image (priv->real, g_paste_clipboard_fake_event_finish_image, self); else g_paste_clipboard_owner_change (NULL, NULL, self); return G_SOURCE_CONTINUE; } static void g_paste_clipboard_dispose (GObject *object) { GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (G_PASTE_CLIPBOARD (object)); if (priv->settings) { g_signal_handler_disconnect (priv->real, priv->owner_change_signal); g_clear_object (&priv->settings); } G_OBJECT_CLASS (g_paste_clipboard_parent_class)->dispose (object); } static void g_paste_clipboard_finalize (GObject *object) { GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (G_PASTE_CLIPBOARD (object)); g_free (priv->text); g_free (priv->image_checksum); G_OBJECT_CLASS (g_paste_clipboard_parent_class)->finalize (object); } static void g_paste_clipboard_class_init (GPasteClipboardClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->dispose = g_paste_clipboard_dispose; object_class->finalize = g_paste_clipboard_finalize; /** * GPasteClipboard::owner-change: * @clipboard: the object on which the signal was emitted * @event: (type Gdk.EventOwnerChange): the @GdkEventOwnerChange event * * The "owner-change" signal is emitted when GPaste receives an * event that indicates that the ownership of the selection * associated with @clipboard has changed. */ signals[OWNER_CHANGE] = g_signal_new ("owner-change", G_PASTE_TYPE_CLIPBOARD, G_SIGNAL_RUN_FIRST, 0, /* class offset */ NULL, /* accumulator */ NULL, /* accumulator data */ g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); } static void g_paste_clipboard_init (GPasteClipboard *self) { GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); priv->text = NULL; priv->image_checksum = NULL; priv->state = CLIP_STATE_IDLE; } /** * g_paste_clipboard_new: * @target: the GdkAtom representating the GtkClipboard we're abstracting * @settings: a #GPasteSettings instance * * Create a new instance of #GPasteClipboard * * Returns: a newly allocated #GPasteClipboard * free it with g_object_unref */ G_PASTE_VISIBLE GPasteClipboard * g_paste_clipboard_new (GdkAtom target, GPasteSettings *settings) { g_return_val_if_fail (G_PASTE_IS_SETTINGS (settings), NULL); GPasteClipboard *self = g_object_new (G_PASTE_TYPE_CLIPBOARD, NULL); GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); priv->target = target; priv->settings = g_object_ref (settings); GtkClipboard *real = priv->real = gtk_clipboard_get (target); priv->owner_change_signal = g_signal_connect (real, "owner-change", G_CALLBACK (g_paste_clipboard_owner_change), self); if (!gdk_display_request_selection_notification (gdk_display_get_default (), target)) { g_warning ("Selection notification not supported, using active poll"); g_source_set_name_by_id (g_timeout_add_seconds (1, g_paste_clipboard_fake_event, self), "[GPaste] clipboard fake events"); } return self; } GPaste-3.18.6/src/libgpaste/core/gpaste-clipboard.h000066400000000000000000000064451305131721400220640ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_CLIPBOARD_H__ #define __G_PASTE_CLIPBOARD_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_CLIPBOARD (g_paste_clipboard_get_type ()) G_PASTE_FINAL_TYPE (Clipboard, clipboard, CLIPBOARD, GObject) #define g_paste_clipboard_copy_files_target gdk_atom_intern_static_string ("x-special/gnome-copied-files") typedef void (*GPasteClipboardTextCallback) (GPasteClipboard *self, const gchar *text, gpointer user_data); typedef void (*GPasteClipboardImageCallback) (GPasteClipboard *self, GdkPixbuf *image, gpointer user_data); void g_paste_clipboard_bootstrap (GPasteClipboard *self, GPasteHistory *history); GdkAtom g_paste_clipboard_get_target (const GPasteClipboard *self); GtkClipboard *g_paste_clipboard_get_real (const GPasteClipboard *self); const gchar *g_paste_clipboard_get_text (const GPasteClipboard *self); void g_paste_clipboard_set_text (GPasteClipboard *self, GPasteClipboardTextCallback callback, gpointer user_data); void g_paste_clipboard_select_text (GPasteClipboard *self, const gchar *text); void g_paste_clipboard_clear (GPasteClipboard *self); const gchar *g_paste_clipboard_get_image_checksum (const GPasteClipboard *self); void g_paste_clipboard_set_image (GPasteClipboard *self, GPasteClipboardImageCallback callback, gpointer user_data); gboolean g_paste_clipboard_select_item (GPasteClipboard *self, const GPasteItem *item); void g_paste_clipboard_ensure_not_empty (GPasteClipboard *self, GPasteHistory *history); GPasteClipboard *g_paste_clipboard_new (GdkAtom target, GPasteSettings *settings); G_END_DECLS #endif /*__G_PASTE_CLIPBOARD_H__*/ GPaste-3.18.6/src/libgpaste/core/gpaste-clipboards-manager.c000066400000000000000000000344131305131721400236460ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include struct _GPasteClipboardsManager { GObject parent_instance; }; typedef struct { GPasteClipboard *clipboard; gulong signal; } _Clipboard; typedef struct { GSList *clipboards; GPasteHistory *history; GPasteSettings *settings; gulong selected_signal; } GPasteClipboardsManagerPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteClipboardsManager, g_paste_clipboards_manager, G_TYPE_OBJECT) /** * g_paste_clipboards_manager_add_clipboard: * @self: a #GPasteClipboardsManager instance * @clipboard: (transfer none): the GPasteClipboard to add * * Add a #GPasteClipboard to the #GPasteClipboardsManager * * Returns: */ G_PASTE_VISIBLE void g_paste_clipboards_manager_add_clipboard (GPasteClipboardsManager *self, GPasteClipboard *clipboard) { g_return_if_fail (G_PASTE_IS_CLIPBOARDS_MANAGER (self)); g_return_if_fail (G_PASTE_IS_CLIPBOARD (clipboard)); GPasteClipboardsManagerPrivate *priv = g_paste_clipboards_manager_get_instance_private (self); _Clipboard *clip = g_new0 (_Clipboard, 1); clip->clipboard = g_object_ref (clipboard); priv->clipboards = g_slist_prepend (priv->clipboards, clip); g_paste_clipboard_bootstrap (clipboard, priv->history); } static void g_paste_clipboards_manager_sync_ready (GtkClipboard *clipboard G_GNUC_UNUSED, const gchar *text, gpointer user_data) { if (text) gtk_clipboard_set_text (user_data, text, -1); } /** * g_paste_clipboards_manager_sync_from_to: * @self: a #GPasteClipboardsManager instance * @from: the Source clipboard type * @to: the destination clipboard type * * Sync a clipboard into another * * Returns: */ G_PASTE_VISIBLE void g_paste_clipboards_manager_sync_from_to (GPasteClipboardsManager *self, GdkAtom from, GdkAtom to) { g_return_if_fail (G_PASTE_IS_CLIPBOARDS_MANAGER (self)); GPasteClipboardsManagerPrivate *priv = g_paste_clipboards_manager_get_instance_private (self); GtkClipboard *_from = NULL, *_to = NULL; g_autofree gchar *_from_name = gdk_atom_name (from); g_autofree gchar *_to_name = gdk_atom_name (to); g_debug ("clipboards-manager: sync from %s to %s", _from_name, _to_name); for (GSList *clipboard = priv->clipboards; clipboard; clipboard = g_slist_next (clipboard)) { _Clipboard *_clip = clipboard->data; GPasteClipboard *clip = _clip->clipboard; GdkAtom cur = g_paste_clipboard_get_target (clip); if (cur == from) _from = g_paste_clipboard_get_real (clip); else if (cur == to) _to = g_paste_clipboard_get_real (clip); } if (_from && _to) { gtk_clipboard_request_text (_from, g_paste_clipboards_manager_sync_ready, _to); } } static void g_paste_clipboards_manager_notify_finish (GPasteClipboardsManagerPrivate *priv, GPasteClipboard *clipboard, GPasteItem *item, const gchar *synchronized_text, gboolean something_in_clipboard) { GPasteHistory *history = priv->history; g_debug ("clipboards-manager: notify finish"); if (item) g_paste_history_add (history, item); if (!something_in_clipboard) g_paste_clipboard_ensure_not_empty (clipboard, history); if (synchronized_text) { for (GSList *_clipboard = priv->clipboards; _clipboard; _clipboard = g_slist_next (_clipboard)) { _Clipboard *_clip = _clipboard->data; GPasteClipboard *clip = _clip->clipboard; if (clipboard == clip) continue; const gchar *text = g_paste_clipboard_get_text (clip); if (!text || g_strcmp0 (text, synchronized_text)) g_paste_clipboard_select_text (clip, synchronized_text); } } } typedef struct { GPasteClipboardsManagerPrivate *priv; GPasteClipboard *clip; gboolean track; gboolean uris_available; } GPasteClipboardsManagerCallbackData; static void g_paste_clipboards_manager_text_ready (GPasteClipboard *clipboard, const gchar *text, gpointer user_data) { g_autofree GPasteClipboardsManagerCallbackData *data = user_data; GPasteClipboardsManagerPrivate *priv = data->priv; GPasteItem *item = NULL; const gchar *synchronized_text = NULL; g_debug ("clipboards-manager: text ready"); /* Did we already have some contents, or did we get some now? */ gboolean something_in_clipboard = !!g_paste_clipboard_get_text (clipboard); /* If our contents got updated */ if (text) { if (data->track) { if (data->uris_available) item = G_PASTE_ITEM (g_paste_uris_item_new (text)); else item = G_PASTE_ITEM (g_paste_text_item_new (text)); } if (g_paste_settings_get_synchronize_clipboards (priv->settings)) synchronized_text = text; } g_paste_clipboards_manager_notify_finish (priv, clipboard, item, synchronized_text, something_in_clipboard); } static void g_paste_clipboards_manager_image_ready (GPasteClipboard *clipboard, GdkPixbuf *image, gpointer user_data) { g_autofree GPasteClipboardsManagerCallbackData *data = user_data; GPasteClipboardsManagerPrivate *priv = data->priv; GPasteItem *item = NULL; g_debug ("clipboards-manager: image ready"); /* Did we already have some contents, or did we get some now? */ gboolean something_in_clipboard = !!g_paste_clipboard_get_image_checksum (clipboard); /* If our contents got updated */ if (image && data->track) item = G_PASTE_ITEM (g_paste_image_item_new (image)); g_paste_clipboards_manager_notify_finish (priv, clipboard, item, NULL, something_in_clipboard); } static void g_paste_clipboards_manager_targets_ready (GtkClipboard *clipboard G_GNUC_UNUSED, GtkSelectionData *targets, gpointer user_data) { g_autofree GPasteClipboardsManagerCallbackData *data = user_data; g_debug ("clipboards-manager: targets ready"); if (gtk_selection_data_get_length (targets) >= 0) { data->uris_available = gtk_selection_data_targets_include_uri (targets); if (data->uris_available || gtk_selection_data_targets_include_text (targets)) { /* Update our cache from the real Clipboard */ g_paste_clipboard_set_text (data->clip, g_paste_clipboards_manager_text_ready, data); data = NULL; } else if (g_paste_settings_get_images_support (data->priv->settings) && gtk_selection_data_targets_include_image (targets, FALSE)) { /* Update our cache from the real Clipboard */ g_paste_clipboard_set_image (data->clip, g_paste_clipboards_manager_image_ready, data); data = NULL; } } else { g_debug ("clipboards-manager: no target ready"); g_paste_clipboard_clear (data->clip); g_paste_clipboard_ensure_not_empty (data->clip, data->priv->history); } } static void g_paste_clipboards_manager_notify (GPasteClipboard *clipboard, GdkEvent *event G_GNUC_UNUSED, gpointer user_data) { GPasteClipboardsManagerPrivate *priv = user_data; g_debug ("clipboards-manager: notify"); GPasteSettings *settings = priv->settings; GdkAtom atom = g_paste_clipboard_get_target (clipboard); gboolean track = ((atom != GDK_SELECTION_PRIMARY || g_paste_settings_get_primary_to_history (settings)) && g_paste_settings_get_track_changes (settings)); GPasteClipboardsManagerCallbackData *data = g_new (GPasteClipboardsManagerCallbackData, 1); data->priv = priv; data->clip = clipboard; data->track = track; gtk_clipboard_request_contents (g_paste_clipboard_get_real (clipboard), gdk_atom_intern_static_string ("TARGETS"), g_paste_clipboards_manager_targets_ready, data); } /** * g_paste_clipboards_manager_activate: * @self: a #GPasteClipboardsManager instance * * Activate the #GPasteClipboardsManager * * Returns: */ G_PASTE_VISIBLE void g_paste_clipboards_manager_activate (GPasteClipboardsManager *self) { g_return_if_fail (G_PASTE_IS_CLIPBOARDS_MANAGER (self)); GPasteClipboardsManagerPrivate *priv = g_paste_clipboards_manager_get_instance_private (self); for (GSList *clipboard = priv->clipboards; clipboard; clipboard = g_slist_next (clipboard)) { _Clipboard *clip = clipboard->data; clip->signal = g_signal_connect (clip->clipboard, "owner-change", G_CALLBACK (g_paste_clipboards_manager_notify), priv); } } /** * g_paste_clipboards_manager_select: * @self: a #GPasteClipboardsManager instance * @item: the #GPasteItem to select * * Select a new #GPasteItem * * Returns: %FALSE if the item was invalid, %TRUE otherwise */ G_PASTE_VISIBLE gboolean g_paste_clipboards_manager_select (GPasteClipboardsManager *self, const GPasteItem *item) { g_return_val_if_fail (G_PASTE_IS_CLIPBOARDS_MANAGER (self), FALSE); g_return_val_if_fail (G_PASTE_IS_ITEM (item), FALSE); GPasteClipboardsManagerPrivate *priv = g_paste_clipboards_manager_get_instance_private (self); g_debug ("clipboards-manager: select"); for (GSList *clipboard = priv->clipboards; clipboard; clipboard = g_slist_next (clipboard)) { _Clipboard *clip = clipboard->data; if (!g_paste_clipboard_select_item (clip->clipboard, item)) { g_debug ("clipboards-manager: item was invalid, deleting it"); return FALSE; } } return TRUE; } static void on_item_selected (GPasteClipboardsManager *self, GPasteItem *item, GPasteHistory *history G_GNUC_UNUSED) { GPasteClipboardsManagerPrivate *priv = g_paste_clipboards_manager_get_instance_private (G_PASTE_CLIPBOARDS_MANAGER (self)); if (!g_paste_clipboards_manager_select (self, item)) g_paste_history_remove (priv->history, 0); } static void _clipboard_free (gpointer data) { _Clipboard *clip = data; g_signal_handler_disconnect (clip->clipboard, clip->signal); g_object_unref (clip->clipboard); g_free (clip); } static void g_paste_clipboards_manager_dispose (GObject *object) { GPasteClipboardsManagerPrivate *priv = g_paste_clipboards_manager_get_instance_private (G_PASTE_CLIPBOARDS_MANAGER (object)); GPasteSettings *settings = priv->settings; if (settings) { g_signal_handler_disconnect (settings, priv->selected_signal); g_clear_object (&priv->settings); g_clear_object (&priv->history); } if (priv->clipboards) { g_slist_free_full (priv->clipboards, _clipboard_free); priv->clipboards = NULL; } G_OBJECT_CLASS (g_paste_clipboards_manager_parent_class)->dispose (object); } static void g_paste_clipboards_manager_class_init (GPasteClipboardsManagerClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_clipboards_manager_dispose; } static void g_paste_clipboards_manager_init (GPasteClipboardsManager *self) { GPasteClipboardsManagerPrivate *priv = g_paste_clipboards_manager_get_instance_private (self); priv->clipboards = NULL; } /** * g_paste_clipboards_manager_new: * @history: (transfer none): a #GPasteHistory instance * @settings: (transfer none): a #GPasteSettings instance * * Create a new instance of #GPasteClipboardsManager * * Returns: a newly allocated #GPasteClipboardsManager * free it with g_object_unref */ G_PASTE_VISIBLE GPasteClipboardsManager * g_paste_clipboards_manager_new (GPasteHistory *history, GPasteSettings *settings) { g_return_val_if_fail (G_PASTE_IS_HISTORY (history), NULL); g_return_val_if_fail (G_PASTE_IS_SETTINGS (settings), NULL); GPasteClipboardsManager *self = g_object_new (G_PASTE_TYPE_CLIPBOARDS_MANAGER, NULL); GPasteClipboardsManagerPrivate *priv = g_paste_clipboards_manager_get_instance_private (self); priv->history = g_object_ref (history); priv->settings = g_object_ref (settings); priv->selected_signal = g_signal_connect_swapped (history, "selected", G_CALLBACK (on_item_selected), self); return self; } GPaste-3.18.6/src/libgpaste/core/gpaste-clipboards-manager.h000066400000000000000000000041141305131721400236460ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_CLIPBOARDS_MANAGER_H__ #define __G_PASTE_CLIPBOARDS_MANAGER_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_CLIPBOARDS_MANAGER (g_paste_clipboards_manager_get_type ()) G_PASTE_FINAL_TYPE (ClipboardsManager, clipboards_manager, CLIPBOARDS_MANAGER, GObject) void g_paste_clipboards_manager_add_clipboard (GPasteClipboardsManager *self, GPasteClipboard *clipboard); void g_paste_clipboards_manager_sync_from_to (GPasteClipboardsManager *self, GdkAtom from, GdkAtom to); void g_paste_clipboards_manager_activate (GPasteClipboardsManager *self); gboolean g_paste_clipboards_manager_select (GPasteClipboardsManager *self, const GPasteItem *item); GPasteClipboardsManager *g_paste_clipboards_manager_new (GPasteHistory *history, GPasteSettings *settings); G_END_DECLS #endif /*__G_PASTE_CLIPBOARDS_MANAGER_H__*/ GPaste-3.18.6/src/libgpaste/core/gpaste-history.c000066400000000000000000001372121305131721400216160ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include #include #include #include struct _GPasteHistory { GObject parent_instance; }; typedef struct { GPasteSettings *settings; GSList *history; guint64 size; gchar *name; /* Note: we never track the first (active) item here */ guint64 biggest_index; guint64 biggest_size; gulong changed_signal; } GPasteHistoryPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteHistory, g_paste_history, G_TYPE_OBJECT) enum { SELECTED, SWITCH, UPDATE, LAST_SIGNAL }; static guint64 signals[LAST_SIGNAL] = { 0 }; static void g_paste_history_private_elect_new_biggest (GPasteHistoryPrivate *priv) { g_debug ("history: elect biggest"); priv->biggest_index = 0; priv->biggest_size = 0; GSList *history = priv->history; if (history) { guint64 index = 1; for (history = history->next; history; history = history->next, ++index) { GPasteItem *item = history->data; guint64 size = g_paste_item_get_size (item); if (size > priv->biggest_size) { priv->biggest_index = index; priv->biggest_size = size; } } } } static GSList * g_paste_history_private_remove (GPasteHistoryPrivate *priv, GSList *elem, gboolean remove_leftovers) { if (!elem) return NULL; GPasteItem *item = elem->data; priv->size -= g_paste_item_get_size (item); if (remove_leftovers) { if (G_PASTE_IS_IMAGE_ITEM (item)) { g_autoptr (GFile) image = g_file_new_for_path (g_paste_item_get_value (item)); g_file_delete (image, NULL, /* cancellable */ NULL); /* error */ } g_object_unref (item); } return g_slist_delete_link (elem, elem); } static void g_paste_history_selected (GPasteHistory *self, GPasteItem *item) { g_debug ("history: selected"); g_signal_emit (self, signals[SELECTED], 0, /* detail */ item, NULL); } static void g_paste_history_emit_switch (GPasteHistory *self, const gchar *name) { g_debug ("history: switch"); g_signal_emit (self, signals[SWITCH], 0, /* detail */ name, NULL); } static void g_paste_history_update (GPasteHistory *self, GPasteUpdateAction action, GPasteUpdateTarget target, guint64 position) { g_paste_history_save (self, NULL); g_debug ("history: update"); g_signal_emit (self, signals[UPDATE], 0, /* detail */ action, target, position, NULL); } static void g_paste_history_activate_first (GPasteHistory *self, gboolean select) { GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); GSList *history = priv->history; if (!history) return; GPasteItem *first = history->data; priv->size -= g_paste_item_get_size (first); g_paste_item_set_state (first, G_PASTE_ITEM_STATE_ACTIVE); priv->size += g_paste_item_get_size (first); if (select) g_paste_history_selected (self, first); } static void g_paste_history_private_check_memory_usage (GPasteHistoryPrivate *priv) { guint64 max_memory = g_paste_settings_get_max_memory_usage (priv->settings) * 1024 * 1024; while (priv->size > max_memory && !priv->biggest_index) { GSList *prev = g_slist_nth (priv->history, priv->biggest_index - 1); g_return_if_fail (prev); prev->next = g_paste_history_private_remove (priv, g_slist_next (prev), TRUE); g_paste_history_private_elect_new_biggest (priv); } } static void g_paste_history_private_check_size (GPasteHistoryPrivate *priv) { GSList *history = priv->history; guint64 max_history_size = g_paste_settings_get_max_history_size (priv->settings); guint64 length = g_slist_length (history); if (length > max_history_size) { GSList *previous = g_slist_nth (history, max_history_size - 1); g_return_if_fail (previous); history = g_slist_next (previous); previous->next = NULL; for (GSList *_history = history; _history; _history = g_slist_next (_history)) priv->size -= g_paste_item_get_size (_history->data); g_slist_free_full (history, g_object_unref); } } static gboolean g_paste_history_private_is_growing_line (GPasteHistoryPrivate *priv, GPasteItem *old, GPasteItem *new) { if (!(g_paste_settings_get_growing_lines (priv->settings) && G_PASTE_IS_TEXT_ITEM (old) && G_PASTE_IS_TEXT_ITEM (new) && !G_PASTE_IS_PASSWORD_ITEM (old) && !G_PASTE_IS_PASSWORD_ITEM (new))) return FALSE; const gchar *n = g_paste_item_get_value (new); const gchar *o = g_paste_item_get_value (old); return (g_str_has_prefix (n, o) || g_str_has_suffix (n, o)); } /** * g_paste_history_add: * @self: a #GPasteHistory instance * @item: (transfer full): the #GPasteItem to add * * Add a #GPasteItem to the #GPasteHistory * * Returns: */ G_PASTE_VISIBLE void g_paste_history_add (GPasteHistory *self, GPasteItem *item) { g_return_if_fail (G_PASTE_IS_HISTORY (self)); g_return_if_fail (G_PASTE_IS_ITEM (item)); GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); guint64 max_memory = g_paste_settings_get_max_memory_usage (priv->settings) * 1024 * 1024; g_return_if_fail (g_paste_item_get_size (item) < max_memory); GSList *history = priv->history; gboolean election_needed = FALSE; GPasteUpdateTarget target = G_PASTE_UPDATE_TARGET_ALL; g_debug ("history: add"); if (history) { GPasteItem *old_first = history->data; if (g_paste_item_equals (old_first, item)) return; if (g_paste_history_private_is_growing_line (priv, old_first, item)) { target = G_PASTE_UPDATE_TARGET_POSITION; priv->history = g_paste_history_private_remove (priv, history, FALSE); } else { /* size may change when state is idle */ priv->size -= g_paste_item_get_size (old_first); g_paste_item_set_state (old_first, G_PASTE_ITEM_STATE_IDLE); guint64 size = g_paste_item_get_size (old_first); priv->size += size; if (size >= priv->biggest_size) { priv->biggest_index = 0; /* Current 0, will become 1 */ priv->biggest_size = size; } GSList *prev = history; guint64 index = 1; for (history = history->next; history; prev = history, history = history->next, ++index) { if (g_paste_item_equals (history->data, item) || g_paste_history_private_is_growing_line (priv, history->data, item)) { prev->next = g_paste_history_private_remove (priv, history, FALSE); if (index == priv->biggest_index) election_needed = TRUE; break; } } ++priv->biggest_index; } } priv->history = g_slist_prepend (priv->history, item); g_paste_history_activate_first (self, FALSE); priv->size += g_paste_item_get_size (item); g_paste_history_private_check_size (priv); if (election_needed) g_paste_history_private_elect_new_biggest (priv); g_paste_history_private_check_memory_usage (priv); g_paste_history_update (self, G_PASTE_UPDATE_ACTION_REPLACE, target, 0); } /** * g_paste_history_remove: * @self: a #GPasteHistory instance * @index: the index of the #GPasteItem to delete * * Delete a #GPasteItem from the #GPasteHistory * * Returns: */ G_PASTE_VISIBLE void g_paste_history_remove (GPasteHistory *self, guint64 pos) { g_return_if_fail (G_PASTE_IS_HISTORY (self)); GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); GSList *history = priv->history; g_debug ("history: remove '%" G_GUINT64_FORMAT "'", pos); g_return_if_fail (pos < g_slist_length (history)); if (pos) { GSList *prev = g_slist_nth (history, pos - 1); g_return_if_fail (prev); prev->next = g_paste_history_private_remove (priv, g_slist_next (prev), TRUE); } else { priv->history = g_paste_history_private_remove (priv, history, TRUE); g_paste_history_activate_first (self, TRUE); } if (pos == priv->biggest_index) g_paste_history_private_elect_new_biggest (priv); else if (pos < priv->biggest_index) --priv->biggest_index; g_paste_history_update (self, G_PASTE_UPDATE_ACTION_REMOVE, G_PASTE_UPDATE_TARGET_POSITION, pos); } static GPasteItem * g_paste_history_private_get (GPasteHistoryPrivate *priv, guint64 pos) { GSList *history = priv->history; if (pos >= g_slist_length (history)) return NULL; return G_PASTE_ITEM (g_slist_nth_data (history, pos)); } /** * g_paste_history_get: * @self: a #GPasteHistory instance * @index: the index of the #GPasteItem * * Get a #GPasteItem from the #GPasteHistory * * Returns: a read-only #GPasteItem */ G_PASTE_VISIBLE const GPasteItem * g_paste_history_get (GPasteHistory *self, guint64 pos) { g_return_val_if_fail (G_PASTE_IS_HISTORY (self), NULL); return g_paste_history_private_get (g_paste_history_get_instance_private (self), pos); } /** * g_paste_history_dup: * @self: a #GPasteHistory instance * @index: the index of the #GPasteItem * * Get a #GPasteItem from the #GPasteHistory * free it with g_object_unref * * Returns: (transfer full): a #GPasteItem */ G_PASTE_VISIBLE GPasteItem * g_paste_history_dup (GPasteHistory *self, guint64 pos) { g_return_val_if_fail (G_PASTE_IS_HISTORY (self), NULL); return g_object_ref (g_paste_history_private_get (g_paste_history_get_instance_private (self), pos)); } /** * g_paste_history_get_value: * @self: a #GPasteHistory instance * @index: the index of the #GPasteItem * * Get the value of a #GPasteItem from the #GPasteHistory * * Returns: the read-only value of the #GPasteItem */ G_PASTE_VISIBLE const gchar * g_paste_history_get_value (GPasteHistory *self, guint64 pos) { g_return_val_if_fail (G_PASTE_IS_HISTORY (self), NULL); GPasteItem *item = g_paste_history_private_get (g_paste_history_get_instance_private (self), pos); if (!item) return NULL; return g_paste_item_get_value (item); } /** * g_paste_history_get_display_string: * @self: a #GPasteHistory instance * @index: the index of the #GPasteItem * * Get the display string of a #GPasteItem from the #GPasteHistory * * Returns: the read-only display string of the #GPasteItem */ G_PASTE_VISIBLE const gchar * g_paste_history_get_display_string (GPasteHistory *self, guint64 pos) { g_return_val_if_fail (G_PASTE_IS_HISTORY (self), NULL); GPasteItem *item = g_paste_history_private_get (g_paste_history_get_instance_private (self), pos); if (!item) return NULL; return g_paste_item_get_display_string (item); } /** * g_paste_history_select: * @self: a #GPasteHistory instance * @index: the index of the #GPasteItem to select * * Select a #GPasteItem from the #GPasteHistory * * Returns: */ G_PASTE_VISIBLE void g_paste_history_select (GPasteHistory *self, guint64 index) { g_return_if_fail (G_PASTE_IS_HISTORY (self)); g_debug ("history: select '%" G_GUINT64_FORMAT "'", index); GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); GSList *history = priv->history; g_return_if_fail (index < g_slist_length (history)); GPasteItem *item = g_slist_nth_data (history, index); g_paste_history_add (self, item); g_paste_history_selected (self, item); } static void _g_paste_history_replace (GPasteHistory *self, guint64 index, GPasteItem *item, GPasteItem *new, GSList *prev, GSList *todel) { GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); priv->size -= g_paste_item_get_size (item); priv->size += g_paste_item_get_size (new); GSList *next = g_slist_prepend (g_slist_delete_link (todel, todel), new); if (prev) prev->next = next; else priv->history = next; if (index == priv->biggest_index) g_paste_history_private_elect_new_biggest (priv); g_paste_history_update (self, G_PASTE_UPDATE_ACTION_REPLACE, G_PASTE_UPDATE_TARGET_POSITION, index); } /** * g_paste_history_replace: * @self: a #GPasteHistory instance * @index: the index of the #GPasteTextItem to replace * @contents: the new contents * * Replace the contents of text item at index @index * * Returns: */ G_PASTE_VISIBLE void g_paste_history_replace (GPasteHistory *self, guint64 index, const gchar *contents) { g_return_if_fail (G_PASTE_IS_HISTORY (self)); g_return_if_fail (!contents || g_utf8_validate (contents, -1, NULL)); GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); GSList *history = priv->history; g_return_if_fail (index < g_slist_length (history)); GSList *prev = (index) ? g_slist_nth (history, index - 1) : NULL; g_return_if_fail (!index || prev); GSList *todel = (index) ? g_slist_next (prev) : history; g_return_if_fail (todel); GPasteItem *item = todel->data; g_return_if_fail (G_PASTE_IS_TEXT_ITEM (item) && !g_strcmp0 (g_paste_item_get_kind (item), "Text")); GPasteItem *new = g_paste_text_item_new (contents); _g_paste_history_replace (self, index, item, new, prev, todel); if (!index) g_paste_history_selected (self, new); } /** * g_paste_history_set_password: * @self: a #GPasteHistory instance * @index: the index of the #GPasteTextItem to change as password * @name: (nullable): the name to give to the password * * Mark a text item as password * * Returns: */ G_PASTE_VISIBLE void g_paste_history_set_password (GPasteHistory *self, guint64 index, const gchar *name) { g_return_if_fail (G_PASTE_IS_HISTORY (self)); g_return_if_fail (!name || g_utf8_validate (name, -1, NULL)); GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); GSList *history = priv->history; g_return_if_fail (index < g_slist_length (history)); GSList *prev = (index) ? g_slist_nth (history, index - 1) : NULL; g_return_if_fail (!index || prev); GSList *todel = (index) ? g_slist_next (prev) : history; g_return_if_fail (todel); GPasteItem *item = todel->data; g_return_if_fail (G_PASTE_IS_TEXT_ITEM (item) && !g_strcmp0 (g_paste_item_get_kind (item), "Text")); GPasteItem *password = g_paste_password_item_new (name, g_paste_item_get_real_value (item)); _g_paste_history_replace (self, index, item, password, prev, todel); } static GPasteItem * _g_paste_history_private_get_password (const GPasteHistoryPrivate *priv, const gchar *name, guint64 *index) { guint64 idx = 0; for (GSList *h = priv->history; h; h = g_slist_next (h), ++idx) { GPasteItem *i = h->data; if (G_PASTE_IS_PASSWORD_ITEM (i) && !g_strcmp0 (g_paste_password_item_get_name ((GPastePasswordItem *) i), name)) { if (index) *index = idx; return i; } } if (index) *index = -1; return NULL; } /** * g_paste_history_get_password: * @self: a #GPasteHistory instance * @name: the name of the #GPastePasswordItem * * Get the first password matching name * * Returns: (optional): a #GPastePasswordItem or %NULL */ G_PASTE_VISIBLE const GPastePasswordItem * g_paste_history_get_password (GPasteHistory *self, const gchar *name) { g_return_val_if_fail (G_PASTE_IS_HISTORY (self), NULL); g_return_val_if_fail (!name || g_utf8_validate (name, -1, NULL), NULL); GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); GPasteItem *item = _g_paste_history_private_get_password (priv, name, NULL); return (item) ? G_PASTE_PASSWORD_ITEM (item) : NULL; } /** * g_paste_history_delete_password: * @self: a #GPasteHistory instance * @name: the name of the #GPastePasswordItem * * Delete the password matching name * * Returns: */ G_PASTE_VISIBLE void g_paste_history_delete_password (GPasteHistory *self, const gchar *name) { g_return_if_fail (G_PASTE_IS_HISTORY (self)); g_return_if_fail (!name || g_utf8_validate (name, -1, NULL)); GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); guint64 index; if (_g_paste_history_private_get_password (priv, name, &index)) g_paste_history_remove (self, index); } /** * g_paste_history_rename_password: * @self: a #GPasteHistory instance * @old_name: the old name of the #GPastePasswordItem * @new_name: (nullable): the new name of the #GPastePasswordItem * * Rename the password item * * Returns: */ G_PASTE_VISIBLE void g_paste_history_rename_password (GPasteHistory *self, const gchar *old_name, const gchar *new_name) { g_return_if_fail (G_PASTE_IS_HISTORY (self)); g_return_if_fail (!old_name || g_utf8_validate (old_name, -1, NULL)); g_return_if_fail (!new_name || g_utf8_validate (new_name, -1, NULL)); GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); guint64 index = 0; GPasteItem *item = _g_paste_history_private_get_password (priv, old_name, &index); if (item) { g_paste_password_item_set_name (G_PASTE_PASSWORD_ITEM (item), new_name); g_paste_history_update (self, G_PASTE_UPDATE_ACTION_REPLACE, G_PASTE_UPDATE_TARGET_POSITION, index); } } /** * g_paste_history_empty: * @self: a #GPasteHistory instance * * Empty the #GPasteHistory * * Returns: */ G_PASTE_VISIBLE void g_paste_history_empty (GPasteHistory *self) { g_return_if_fail (G_PASTE_IS_HISTORY (self)); GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); g_slist_free_full (priv->history, g_object_unref); priv->history = NULL; priv->size = 0; g_paste_history_private_elect_new_biggest (priv); g_paste_history_update (self, G_PASTE_UPDATE_ACTION_REMOVE, G_PASTE_UPDATE_TARGET_ALL, 0); } static gchar * g_paste_history_encode (const gchar *text) { g_autofree gchar *_encoded_text = g_paste_util_replace (text, "&", "&"); return g_paste_util_replace (_encoded_text, ">", ">"); } static gchar * g_paste_history_decode (const gchar *text) { g_autofree gchar *_decoded_text = g_paste_util_replace (text, ">", ">"); return g_paste_util_replace (_decoded_text, "&", "&"); } static gchar * g_paste_history_get_history_dir_path (void) { return g_build_filename (g_get_user_data_dir (), "gpaste", NULL); } static GFile * g_paste_history_get_history_dir (void) { g_autofree gchar *history_dir_path = g_paste_history_get_history_dir_path (); return g_file_new_for_path (history_dir_path); } static gchar * g_paste_history_get_history_file_path (const gchar *name) { g_return_val_if_fail (name, NULL); g_autofree gchar *history_dir_path = g_paste_history_get_history_dir_path (); g_autofree gchar *history_file_name = g_strconcat (name, ".xml", NULL); return g_build_filename (history_dir_path, history_file_name, NULL); } static GFile * g_paste_history_get_history_file (const gchar *name) { g_autofree gchar *history_file_path = g_paste_history_get_history_file_path (name); return g_file_new_for_path (history_file_path); } static gboolean ensure_history_dir_exists (gboolean save_history) { g_autoptr (GFile) history_dir = g_paste_history_get_history_dir (); if (!g_file_query_exists (history_dir, NULL)) /* cancellable */ { if (!save_history) return TRUE; g_autoptr (GError) error = NULL; g_file_make_directory_with_parents (history_dir, NULL, /* cancellable */ &error); if (error) { g_critical ("%s: %s", _("Could not create history dir"), error->message); return FALSE; } } return TRUE; } /** * g_paste_history_save: * @self: a #GPasteHistory instance * @name: (nullable): the name to save the history to (defaults to the configured one) * * Save the #GPasteHistory to the history file * * Returns: */ G_PASTE_VISIBLE void g_paste_history_save (GPasteHistory *self, const gchar *name) { g_return_if_fail (G_PASTE_IS_HISTORY (self)); GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); GPasteSettings *settings = priv->settings; gboolean save_history = g_paste_settings_get_save_history (settings); g_autofree gchar *history_file_path = NULL; g_autoptr (GFile) history_file = NULL; if (!ensure_history_dir_exists (save_history)) return; history_file_path = g_paste_history_get_history_file_path ((name) ? name : priv->name); history_file = g_file_new_for_path (history_file_path); if (!save_history) { g_file_delete (history_file, NULL, /* cancellable*/ NULL); /* error */ } else { g_autoptr (GOutputStream) stream = G_OUTPUT_STREAM (g_file_replace (history_file, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, NULL, /* cancellable */ NULL)); /* error */ if (!g_output_stream_write_all (stream, "\n", 39, NULL, NULL /* cancellable */, NULL /* error */) || !g_output_stream_write_all (stream, "\n", 24, NULL, NULL /* cancellable */, NULL /* error */)) return; for (GSList *history = priv->history; history; history = g_slist_next (history)) { GPasteItem *item = history->data; const gchar *kind = g_paste_item_get_kind (item); if (!g_strcmp0 (kind, "Password")) continue; g_autofree gchar *text = g_paste_history_encode (g_paste_item_get_value (item)); if (!g_output_stream_write_all (stream, " \n", 11, NULL, NULL /* cancellable */, NULL /* error */)) { g_warning ("Failed to write an item to history"); continue; } } if (!g_output_stream_write_all (stream, "\n", 11, NULL, NULL /* cancellable */, NULL /* error */) || !g_output_stream_close (stream, NULL /* cancellable */, NULL /* error */)) return; } } /********************/ /* Begin XML Parser */ /********************/ typedef enum { BEGIN, IN_HISTORY, IN_ITEM, HAS_TEXT, END } State; typedef enum { TEXT, IMAGE, URIS, PASSWORD } Type; typedef struct { GPasteHistoryPrivate *priv; State state; Type type; guint64 current_size; guint64 max_size; gboolean images_support; gchar *date; gchar *name; gchar *text; } Data; #define ASSERT_STATE(x) \ if (data->state != x) \ { \ g_warning ("Expected state %" G_GINT32_FORMAT ", but got %" G_GINT32_FORMAT, x, data->state); \ return; \ } #define SWITCH_STATE(x, y) \ ASSERT_STATE (x); \ data->state = y static void start_tag (GMarkupParseContext *context G_GNUC_UNUSED, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer user_data, GError **error G_GNUC_UNUSED) { Data *data = user_data; if (!g_strcmp0 (element_name, "history")) { SWITCH_STATE (BEGIN, IN_HISTORY); } else if (!g_strcmp0 (element_name, "item")) { SWITCH_STATE (IN_HISTORY, IN_ITEM); g_clear_pointer (&data->date, g_free); g_clear_pointer (&data->text, g_free); for (const gchar **a = attribute_names, **v = attribute_values; *a && *v; ++a, ++v) { if (!g_strcmp0 (*a, "kind")) { if (!g_strcmp0 (*v, "Text")) data->type = TEXT; else if (!g_strcmp0 (*v, "Image")) data->type = IMAGE; else if (!g_strcmp0 (*v, "Uris")) data->type = URIS; else if (!g_strcmp0 (*v, "Password")) data->type = PASSWORD; else g_critical ("Unknown item kind: %s", *v); } else if (!g_strcmp0 (*a, "date")) { if (data->type != IMAGE) { g_warning ("Expected type %" G_GINT32_FORMAT ", but got %" G_GINT32_FORMAT, IMAGE, data->type); return; } data->date = g_strdup (*v); } else if (!g_strcmp0 (*a, "name")) { if (data->type != PASSWORD) { g_warning ("Expected type %" G_GINT32_FORMAT ", but got %" G_GINT32_FORMAT, PASSWORD, data->type); return; } data->name = g_strdup (*v); } else g_warning ("Unknown item attribute: %s", *a); } } else g_warning ("Unknown element: %s", element_name); } static void end_tag (GMarkupParseContext *context G_GNUC_UNUSED, const gchar *element_name, gpointer user_data, GError **error G_GNUC_UNUSED) { Data *data = user_data; if (!g_strcmp0 (element_name, "history")) { SWITCH_STATE (IN_HISTORY, END); } else if (!g_strcmp0 (element_name, "item")) { SWITCH_STATE (HAS_TEXT, IN_HISTORY); } else g_warning ("Unknown element: %s", element_name); } static void on_text (GMarkupParseContext *context G_GNUC_UNUSED, const gchar *text, guint64 text_len, gpointer user_data, GError **error G_GNUC_UNUSED) { Data *data = user_data; g_autofree gchar *txt = g_strndup (text, text_len); switch (data->state) { case IN_HISTORY: case HAS_TEXT: if (*g_strstrip (txt)) { g_warning ("Unexpected text: %s", txt); return; } break; case IN_ITEM: { g_autofree gchar *value = g_paste_history_decode (txt); if (*g_strstrip (txt)) { if (data->current_size < data->max_size) { GPasteItem *item = NULL; switch (data->type) { case TEXT: item = g_paste_text_item_new (value); break; case URIS: item = g_paste_uris_item_new (value); break; case PASSWORD: item = g_paste_password_item_new (data->name, value); break; case IMAGE: if (data->images_support && data->date) { g_autoptr (GDateTime) date_time = g_date_time_new_from_unix_local (g_ascii_strtoll (data->date, NULL, /* end */ 0)); /* base */ item = g_paste_image_item_new_from_file (value, date_time); } else { g_autoptr (GFile) img_file = g_file_new_for_path (value); if (g_file_query_exists (img_file, NULL)) /* cancellable */ { g_file_delete (img_file, NULL, /* cancellable */ NULL); /* error */ } } break; } if (item) { GPasteHistoryPrivate *priv = data->priv; priv->size += g_paste_item_get_size (item); priv->history = g_slist_append (priv->history, item); ++data->current_size;; } } SWITCH_STATE (IN_ITEM, HAS_TEXT); } break; } default: g_warning ("Unexpected state: %" G_GINT32_FORMAT, data->state); } } static void on_error (GMarkupParseContext *context G_GNUC_UNUSED, GError *error, gpointer user_data G_GNUC_UNUSED) { g_critical ("error: %s", error->message); } /******************/ /* End XML Parser */ /******************/ /** * g_paste_history_load: * @self: a #GPasteHistory instance * @name: (nullable): the name of the history to load, defaults to the configured one * * Load the #GPasteHistory from the history file * * Returns: */ G_PASTE_VISIBLE void g_paste_history_load (GPasteHistory *self, const gchar *name) { g_return_if_fail (G_PASTE_IS_HISTORY (self)); g_return_if_fail (!name || g_utf8_validate (name, -1, NULL)); GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); GPasteSettings *settings = priv->settings; if (priv->name && !g_strcmp0(name, priv->name)) return; g_slist_free_full (priv->history, g_object_unref); priv->history = NULL; g_free (priv->name); priv->name = g_strdup ((name) ? name : g_paste_settings_get_history_name (priv->settings)); g_autofree gchar *history_file_path = g_paste_history_get_history_file_path (priv->name); g_autoptr (GFile) history_file = g_file_new_for_path (history_file_path); if (g_file_query_exists (history_file, NULL)) /* cancellable */ { GMarkupParser parser = { start_tag, end_tag, on_text, NULL, on_error }; Data data = { priv, BEGIN, TEXT, 0, g_paste_settings_get_max_history_size (settings), g_paste_settings_get_images_support (settings), NULL, NULL, NULL }; GMarkupParseContext *ctx = g_markup_parse_context_new (&parser, G_MARKUP_TREAT_CDATA_AS_TEXT, &data, NULL); gchar *text; guint64 text_length; g_file_get_contents (history_file_path, &text, &text_length, NULL); g_markup_parse_context_parse (ctx, text, text_length, NULL); g_markup_parse_context_end_parse (ctx, NULL); if (data.state != END) g_warning ("Unexpected state adter parsing history: %" G_GINT32_FORMAT, data.state); g_markup_parse_context_unref (ctx); } else { /* Create the empty file to be listed as an available history */ if (ensure_history_dir_exists (g_paste_settings_get_save_history (settings))) g_object_unref (g_file_create (history_file, G_FILE_CREATE_NONE, NULL, NULL)); } if (priv->history) { g_paste_history_activate_first (self, TRUE); g_paste_history_private_elect_new_biggest (priv); } } /** * g_paste_history_switch: * @self: a #GPasteHistory instance * @name: the name of the new history * * Switch to a new history * * Returns: */ G_PASTE_VISIBLE void g_paste_history_switch (GPasteHistory *self, const gchar *name) { g_return_if_fail (G_PASTE_IS_HISTORY (self)); g_return_if_fail (name); g_return_if_fail (g_utf8_validate (name, -1, NULL)); GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); g_paste_settings_set_history_name (priv->settings, name); } /** * g_paste_history_delete: * @self: a #GPasteHistory instance * @name: (nullable): the history to delete (defaults to the configured one) * @error: a #GError * * Delete the current #GPasteHistory * * Returns: */ G_PASTE_VISIBLE void g_paste_history_delete (GPasteHistory *self, const gchar *name, GError **error) { g_return_if_fail (G_PASTE_IS_HISTORY (self)); GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); g_autoptr (GFile) history_file = g_paste_history_get_history_file ((name) ? name : priv->name); if (!g_strcmp0 (name, priv->name)) g_paste_history_empty (self); if (g_file_query_exists (history_file, NULL)) /* cancellable */ { g_file_delete (history_file, NULL, /* cancellable */ error); } } static void g_paste_history_history_name_changed (GPasteHistory *self) { GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); g_debug ("history: name cahnged to '%s'", priv->name); g_paste_history_load (self, NULL); g_paste_history_emit_switch (self, priv->name); g_paste_history_update (self, G_PASTE_UPDATE_ACTION_REPLACE, G_PASTE_UPDATE_TARGET_ALL, 0); } static void g_paste_history_settings_changed (GPasteSettings *settings G_GNUC_UNUSED, const gchar *key, gpointer user_data) { GPasteHistory *self = user_data; GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); /* FIXME: track text item size settings */ if (!g_strcmp0(key, G_PASTE_MAX_HISTORY_SIZE_SETTING)) g_paste_history_private_check_size (priv); else if (!g_strcmp0 (key, G_PASTE_MAX_MEMORY_USAGE_SETTING)) g_paste_history_private_check_memory_usage (priv); else if (!g_strcmp0 (key, G_PASTE_HISTORY_NAME_SETTING)) g_paste_history_history_name_changed (self); } static void g_paste_history_dispose (GObject *object) { GPasteHistory *self = G_PASTE_HISTORY (object); GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); GPasteSettings *settings = priv->settings; if (settings) { g_signal_handler_disconnect (settings, priv->changed_signal); g_clear_object (&priv->settings); } G_OBJECT_CLASS (g_paste_history_parent_class)->dispose (object); } static void g_paste_history_finalize (GObject *object) { GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (G_PASTE_HISTORY (object)); g_free (priv->name); g_slist_free_full (priv->history, g_object_unref); G_OBJECT_CLASS (g_paste_history_parent_class)->finalize (object); } static void g_paste_history_class_init (GPasteHistoryClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->dispose = g_paste_history_dispose; object_class->finalize = g_paste_history_finalize; /** * GPasteHistory::selected: * @history: the object on which the signal was emitted * @item: the new selected item * * The "selected" signal is emitted when the user has just * selected a new item form the history. */ signals[SELECTED] = g_signal_new ("selected", G_PASTE_TYPE_HISTORY, G_SIGNAL_RUN_LAST, 0, /* class offset */ NULL, /* accumulator */ NULL, /* accumulator data */ g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, /* number of params */ G_PASTE_TYPE_ITEM); /** * GPasteHistory::switch: * @history: the object on which the signal was emitted * @name: the new history name * * The "switch" signal is emitted when the user has just * switched to a new history */ signals[SWITCH] = g_signal_new ("switch", G_PASTE_TYPE_HISTORY, G_SIGNAL_RUN_LAST, 0, /* class offset */ NULL, /* accumulator */ NULL, /* accumulator data */ g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, /* number of params */ G_TYPE_STRING); /** * GPasteHistory::update: * @history: the object on which the signal was emitted * @action: the kind of update * @target: the items which need updating * @index: the index of the item, when the target is POSITION * * The "update" signal is emitted whenever anything changed * in the history (something was added, removed, selected, replaced...). */ signals[UPDATE] = g_signal_new ("update", G_PASTE_TYPE_HISTORY, G_SIGNAL_RUN_LAST, 0, /* class offset */ NULL, /* accumulator */ NULL, /* accumulator data */ g_cclosure_marshal_generic, G_TYPE_NONE, 3, /* number of params */ G_PASTE_TYPE_UPDATE_ACTION, G_PASTE_TYPE_UPDATE_TARGET, G_TYPE_UINT64); } static void g_paste_history_init (GPasteHistory *self) { GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); priv->history = NULL; priv->size = 0; g_paste_history_private_elect_new_biggest (priv); } /** * g_paste_history_get_history: * @self: a #GPasteHistory instance * * Get the inner history of a #GPasteHistory * * Returns: (element-type GPasteItem) (transfer none): The inner history */ G_PASTE_VISIBLE const GSList * g_paste_history_get_history (const GPasteHistory *self) { g_return_val_if_fail (G_PASTE_IS_HISTORY (self), NULL); GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); return priv->history; } /** * g_paste_history_get_length: * @self: a #GPasteHistory instance * * Get the length of a #GPasteHistory * * Returns: The length of the inner history */ G_PASTE_VISIBLE guint64 g_paste_history_get_length (const GPasteHistory *self) { g_return_val_if_fail (G_PASTE_IS_HISTORY (self), 0); GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); return g_slist_length (priv->history); } /** * g_paste_history_get_current: * @self: a #GPasteHistory instance * * Get the name of the current history * * Returns: The name of the current history */ G_PASTE_VISIBLE const gchar * g_paste_history_get_current (const GPasteHistory *self) { g_return_val_if_fail (G_PASTE_IS_HISTORY (self), 0); GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); return priv->name; } /** * g_paste_history_search: * @self: a #GPasteHistory instance * @pattern: the pattern to match * * Get the elements matching @pattern in the history * * Returns: (element-type guint64) (transfer full): The indexes of the matching elements */ G_PASTE_VISIBLE GArray * g_paste_history_search (const GPasteHistory *self, const gchar *pattern) { g_return_val_if_fail (G_PASTE_IS_HISTORY (self), NULL); g_return_val_if_fail (pattern && g_utf8_validate (pattern, -1, NULL), NULL); g_debug ("history: search '%s'", pattern); GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); g_autoptr (GError) error = NULL; g_autoptr (GRegex) regex = g_regex_new (pattern, G_REGEX_CASELESS|G_REGEX_MULTILINE|G_REGEX_DOTALL|G_REGEX_OPTIMIZE, G_REGEX_MATCH_NOTEMPTY|G_REGEX_MATCH_NEWLINE_ANY, &error); if (error) { g_warning ("error while creating regex: %s", error->message); return NULL; } if (!regex) return NULL; /* Check whether we include the index in the search too */ gboolean include_idx = FALSE; guint64 idx = 0; guint64 len = strlen (pattern); if (len < 5) { for (guint64 i = 0; i < len; ++i) { char c = pattern[i]; if (c >= '0' && c <= '9') { include_idx = TRUE; idx *= 10; idx += (c - '0'); } else { include_idx = FALSE; break; } } } GArray *results = g_array_new (FALSE, /* zero-terminated */ TRUE, /* clear */ sizeof (guint64)); guint64 index = 0; for (GSList *history = priv->history; history; history = g_slist_next (history), ++index) { if (include_idx && idx == index) g_array_append_val (results, index); else if (g_regex_match (regex, g_paste_item_get_value (history->data), G_REGEX_MATCH_NOTEMPTY|G_REGEX_MATCH_NEWLINE_ANY, NULL)) g_array_append_val (results, index); } return results; } /** * g_paste_history_new: * @settings: (transfer none): a #GPasteSettings instance * * Create a new instance of #GPasteHistory * * Returns: a newly allocated #GPasteHistory * free it with g_object_unref */ G_PASTE_VISIBLE GPasteHistory * g_paste_history_new (GPasteSettings *settings) { g_return_val_if_fail (G_PASTE_IS_SETTINGS (settings), NULL); GPasteHistory *self = g_object_new (G_PASTE_TYPE_HISTORY, NULL); GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); priv->settings = g_object_ref (settings); priv->changed_signal = g_signal_connect (settings, "changed", G_CALLBACK (g_paste_history_settings_changed), self); return self; } /** * g_paste_history_list: * @error: a #GError * * Get the list of available histories * * Returns: (transfer full): The list of history names * free it with g_array_unref */ G_PASTE_VISIBLE GStrv g_paste_history_list (GError **error) { g_return_val_if_fail (!error || !(*error), NULL); g_autoptr (GArray) history_names = g_array_new (TRUE, /* zero-terminated */ TRUE, /* clear */ sizeof (gchar *)); g_autoptr (GFile) history_dir = g_paste_history_get_history_dir (); g_autoptr (GFileEnumerator) histories = g_file_enumerate_children (history_dir, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, G_FILE_QUERY_INFO_NONE, NULL, /* cancellable */ error); if (error && *error) return NULL; GFileInfo *history; while ((history = g_file_enumerator_next_file (histories, NULL, /* cancellable */ error))) /* error */ { g_autoptr (GFileInfo) h = history; if (error && *error) { g_array_unref (history_names); return NULL; } const gchar *raw_name = g_file_info_get_display_name (h); if (g_str_has_suffix (raw_name, ".xml")) { gchar *name = g_strdup (raw_name); name[strlen (name) - 4] = '\0'; g_array_append_val (history_names, name); } } return g_strdupv ((GStrv) (gpointer) history_names->data); } GPaste-3.18.6/src/libgpaste/core/gpaste-history.h000066400000000000000000000105271305131721400216220ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_HISTORY_H__ #define __G_PASTE_HISTORY_H__ #include #include G_BEGIN_DECLS #define G_PASTE_TYPE_HISTORY (g_paste_history_get_type ()) G_PASTE_FINAL_TYPE (History, history, HISTORY, GObject) void g_paste_history_add (GPasteHistory *self, GPasteItem *item); void g_paste_history_remove (GPasteHistory *self, guint64 index); const GPasteItem *g_paste_history_get (GPasteHistory *self, guint64 index); GPasteItem *g_paste_history_dup (GPasteHistory *self, guint64 index); const gchar *g_paste_history_get_display_string (GPasteHistory *self, guint64 index); const gchar *g_paste_history_get_value (GPasteHistory *self, guint64 index); void g_paste_history_select (GPasteHistory *self, guint64 index); void g_paste_history_replace (GPasteHistory *self, guint64 index, const gchar *contents); void g_paste_history_set_password (GPasteHistory *self, guint64 index, const gchar *name); const GPastePasswordItem *g_paste_history_get_password (GPasteHistory *self, const gchar *name); void g_paste_history_delete_password (GPasteHistory *self, const gchar *name); void g_paste_history_rename_password (GPasteHistory *self, const gchar *old_name, const gchar *new_name); void g_paste_history_empty (GPasteHistory *self); void g_paste_history_save (GPasteHistory *self, const gchar *name); void g_paste_history_load (GPasteHistory *self, const gchar *name); void g_paste_history_switch (GPasteHistory *self, const gchar *name); void g_paste_history_delete (GPasteHistory *self, const gchar *name, GError **error); const GSList *g_paste_history_get_history (const GPasteHistory *self); guint64 g_paste_history_get_length (const GPasteHistory *self); const gchar *g_paste_history_get_current (const GPasteHistory *self); GArray *g_paste_history_search (const GPasteHistory *self, const gchar *pattern); GPasteHistory *g_paste_history_new (GPasteSettings *settings); GStrv g_paste_history_list (GError **error); G_END_DECLS #endif /*__G_PASTE_HISTORY_H__*/ GPaste-3.18.6/src/libgpaste/core/gpaste-image-item.c000066400000000000000000000226231305131721400221320ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include #include struct _GPasteImageItem { GPasteItem parent_instance; }; typedef struct _GPasteImageItemPrivate { gchar *checksum; GDateTime *date; GdkPixbuf *image; guint64 additional_size; } GPasteImageItemPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteImageItem, g_paste_image_item, G_PASTE_TYPE_ITEM) /** * g_paste_image_item_get_checksum: * @self: a #GPasteImageItem instance * * Get the checksum of the GdkPixbuf contained in the #GPasteImageItem * * Returns: read-only string representatig the SHA256 checksum of the image */ G_PASTE_VISIBLE const gchar * g_paste_image_item_get_checksum (const GPasteImageItem *self) { g_return_val_if_fail (G_PASTE_IS_IMAGE_ITEM (self), NULL); GPasteImageItemPrivate *priv = g_paste_image_item_get_instance_private (self); return priv->checksum; } /** * g_paste_image_item_get_date: * @self: a #GPasteImageItem instance * * Get the date at which the image was created * * Returns: read-only GDateTime containing the image's creation date */ G_PASTE_VISIBLE const GDateTime * g_paste_image_item_get_date (const GPasteImageItem *self) { g_return_val_if_fail (G_PASTE_IS_IMAGE_ITEM (self), NULL); GPasteImageItemPrivate *priv = g_paste_image_item_get_instance_private (self); return priv->date; } /** * g_paste_image_item_get_image: * @self: a #GPasteImageItem instance * * Get the image contained in the #GPasteImageItem * * Returns: (transfer none): the GdkPixbuf of the image */ G_PASTE_VISIBLE GdkPixbuf * g_paste_image_item_get_image (const GPasteImageItem *self) { g_return_val_if_fail (G_PASTE_IS_IMAGE_ITEM (self), NULL); GPasteImageItemPrivate *priv = g_paste_image_item_get_instance_private (self); return priv->image; } static gboolean g_paste_image_item_equals (const GPasteItem *self, const GPasteItem *other) { if (!G_PASTE_IS_IMAGE_ITEM (other)) return FALSE; GPasteImageItemPrivate *priv = g_paste_image_item_get_instance_private (G_PASTE_IMAGE_ITEM (self)); GPasteImageItemPrivate *_priv = g_paste_image_item_get_instance_private (G_PASTE_IMAGE_ITEM (other)); return !g_strcmp0 (priv->checksum, _priv->checksum); } static void g_paste_image_item_set_size (GPasteItem *self) { GPasteImageItemPrivate *priv = g_paste_image_item_get_instance_private (G_PASTE_IMAGE_ITEM (self)); GdkPixbuf *image = priv->image; if (image) { if (!priv->additional_size) { priv->additional_size += strlen (priv->checksum) + 1 + gdk_pixbuf_get_byte_length (image); g_paste_item_add_size (self, priv->additional_size); } } else { g_paste_item_remove_size (self, priv->additional_size); priv->additional_size = 0; } } static const gchar * g_paste_image_item_get_kind (const GPasteItem *self G_GNUC_UNUSED) { return "Image"; } static void g_paste_image_item_set_state (GPasteItem *self, GPasteItemState state) { GPasteImageItemPrivate *priv = g_paste_image_item_get_instance_private (G_PASTE_IMAGE_ITEM (self)); switch (state) { case G_PASTE_ITEM_STATE_IDLE: if (priv->image) { g_clear_object (&priv->image); g_clear_pointer (&priv->checksum, g_free); } break; case G_PASTE_ITEM_STATE_ACTIVE: if (!priv->image) { priv->image = gdk_pixbuf_new_from_file (g_paste_item_get_value (self), NULL); /* Error */ priv->checksum = g_paste_util_compute_checksum (priv->image); } break; } g_paste_image_item_set_size (self); } static void g_paste_image_item_dispose (GObject *object) { GPasteImageItemPrivate *priv = g_paste_image_item_get_instance_private (G_PASTE_IMAGE_ITEM (object)); GDateTime *date = priv->date; if (date) { g_date_time_unref (date); if (priv->image) g_object_unref (priv->image); priv->date = NULL; } G_OBJECT_CLASS (g_paste_image_item_parent_class)->dispose (object); } static void g_paste_image_item_finalize (GObject *object) { GPasteImageItemPrivate *priv = g_paste_image_item_get_instance_private (G_PASTE_IMAGE_ITEM (object)); g_free (priv->checksum); G_OBJECT_CLASS (g_paste_image_item_parent_class)->finalize (object); } static void g_paste_image_item_class_init (GPasteImageItemClass *klass) { GPasteItemClass *item_class = G_PASTE_ITEM_CLASS (klass); item_class->equals = g_paste_image_item_equals; item_class->get_kind = g_paste_image_item_get_kind; item_class->set_state = g_paste_image_item_set_state; GObjectClass *gobject_class = G_OBJECT_CLASS (klass); gobject_class->dispose = g_paste_image_item_dispose; gobject_class->finalize = g_paste_image_item_finalize; } static void g_paste_image_item_init (GPasteImageItem *self G_GNUC_UNUSED) { } static GPasteItem * _g_paste_image_item_new (const gchar *path, GDateTime *date, GdkPixbuf *image, gchar *checksum) { GPasteItem *self = g_paste_item_new (G_PASTE_TYPE_IMAGE_ITEM, path); GPasteImageItemPrivate *priv = g_paste_image_item_get_instance_private (G_PASTE_IMAGE_ITEM (self)); priv->date = date; priv->image = image; if (image) priv->checksum = (checksum) ? checksum : g_paste_util_compute_checksum (image); else g_paste_image_item_set_state (G_PASTE_ITEM (self), G_PASTE_ITEM_STATE_ACTIVE); if (!priv->image || !GDK_IS_PIXBUF (priv->image)) { g_object_unref (self); return NULL; } /* This is the date format "month/day/year time" */ g_autofree gchar *formatted_date = g_date_time_format (date, _("%m/%d/%y %T")); /* This gets displayed in history when selecting an image */ g_autofree gchar *display_string = g_strdup_printf (_("[Image, %d x %d (%s)]"), gdk_pixbuf_get_width (priv->image), gdk_pixbuf_get_height (priv->image), formatted_date); g_paste_item_set_display_string (self, display_string); if (image) g_paste_image_item_set_size (self); else g_paste_image_item_set_state (G_PASTE_ITEM (self), G_PASTE_ITEM_STATE_IDLE); return self; } /** * g_paste_image_item_new: * @img: (transfer none): the GdkPixbuf we want to be contained in the #GPasteImageItem * * Create a new instance of #GPasteImageItem * * Returns: a newly allocated #GPasteImageItem * free it with g_object_unref */ G_PASTE_VISIBLE GPasteItem * g_paste_image_item_new (GdkPixbuf *img) { g_return_val_if_fail (GDK_IS_PIXBUF (img), NULL); gchar *checksum = g_paste_util_compute_checksum (img); g_autofree gchar *images_dir_path = g_build_filename (g_get_user_data_dir (), "gpaste", "images", NULL); g_autoptr (GFile) images_dir = g_file_new_for_path (images_dir_path); if (!g_file_query_exists (images_dir, NULL)) mkdir (images_dir_path, (mode_t) 0700); g_autofree gchar *filename = g_strconcat (checksum, ".png", NULL); g_autofree gchar *path = g_build_filename (images_dir_path, filename, NULL); GPasteItem *self = _g_paste_image_item_new (path, g_date_time_new_now_local (), g_object_ref (img), checksum); gdk_pixbuf_save (img, g_paste_item_get_value (self), "png", NULL, /* Error */ NULL); /* Params */ return self; } /** * g_paste_image_item_new_from_file: * @path: the path to the image we want to be contained in the #GPasteImageItem * @date: (transfer none): the date at which the image was created * * Create a new instance of #GPasteImageItem * * Returns: a newly allocated #GPasteImageItem * free it with g_object_unref */ G_PASTE_VISIBLE GPasteItem * g_paste_image_item_new_from_file (const gchar *path, GDateTime *date) { g_return_val_if_fail (path, NULL); g_return_val_if_fail (g_utf8_validate (path, -1, NULL), NULL); g_return_val_if_fail (date, NULL); return _g_paste_image_item_new (path, g_date_time_ref (date), NULL, /* GdkPixbuf */ NULL); /* Checksum */ } GPaste-3.18.6/src/libgpaste/core/gpaste-image-item.h000066400000000000000000000032161305131721400221340ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_IMAGE_ITEM_H__ #define __G_PASTE_IMAGE_ITEM_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_IMAGE_ITEM (g_paste_image_item_get_type ()) G_PASTE_FINAL_TYPE (ImageItem, image_item, IMAGE_ITEM, GPasteItem) const gchar *g_paste_image_item_get_checksum (const GPasteImageItem *self); const GDateTime *g_paste_image_item_get_date (const GPasteImageItem *self); GdkPixbuf *g_paste_image_item_get_image (const GPasteImageItem *self); GPasteItem *g_paste_image_item_new (GdkPixbuf *img); GPasteItem *g_paste_image_item_new_from_file (const gchar *path, GDateTime *date); G_END_DECLS #endif /*__G_PASTE_IMAGE_ITEM_H__*/ GPaste-3.18.6/src/libgpaste/core/gpaste-item-enums.c000066400000000000000000000031131305131721400221700ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include G_PASTE_VISIBLE GType g_paste_item_kind_get_type (void) { static GType etype = 0; if (!etype) { static const GEnumValue values[] = { { G_PASTE_ITEM_KIND_TEXT, "G_PASTE_ITEM_KIND_TEXT", "Text" }, { G_PASTE_ITEM_KIND_URIS, "G_PASTE_ITEM_KIND_URIS", "Uris" }, { G_PASTE_ITEM_KIND_IMAGE, "G_PASTE_ITEM_KIND_IMAGE", "Image" }, { G_PASTE_ITEM_KIND_PASSWORD, "G_PASTE_ITEM_KIND_PASSWORD", "Password" }, { G_PASTE_ITEM_KIND_INVALID, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GPasteItemKind"), values); g_type_class_ref (etype); } return etype; } GPaste-3.18.6/src/libgpaste/core/gpaste-item-enums.h000066400000000000000000000025461305131721400222060ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_ITEM_ENUMS_H__ #define __G_PASTE_ITEM_ENUMS_H__ #include G_BEGIN_DECLS typedef enum { G_PASTE_ITEM_KIND_TEXT = 1, G_PASTE_ITEM_KIND_URIS, G_PASTE_ITEM_KIND_IMAGE, G_PASTE_ITEM_KIND_PASSWORD, G_PASTE_ITEM_KIND_INVALID = 0 } GPasteItemKind; #define G_PASTE_TYPE_ITEM_KIND (g_paste_item_kind_get_type ()) GType g_paste_item_kind_get_type (void); G_END_DECLS #endif /*__G_PASTE_ITEM_ENUMS_H__*/ GPaste-3.18.6/src/libgpaste/core/gpaste-item.c000066400000000000000000000200361305131721400210460ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include typedef struct { gchar *value; gchar *display_string; guint64 size; } GPasteItemPrivate; G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GPasteItem, g_paste_item, G_TYPE_OBJECT) /** * g_paste_item_get_value: * @self: a #GPasteItem instance * * Get the value of the given item (text, uris or path to the image) * * Returns: read-only string containing the value */ G_PASTE_VISIBLE const gchar * g_paste_item_get_value (const GPasteItem *self) { g_return_val_if_fail (G_PASTE_IS_ITEM (self), NULL); return G_PASTE_ITEM_GET_CLASS (self)->get_value (self); } /** * g_paste_item_get_real_value: * @self: a #GPasteItem instance * * Get the real value of the given item (text, uris or path to the image) * This is different from get_value only for #GPastePasswordItem * * Returns: read-only string containing the real value */ G_PASTE_VISIBLE const gchar * g_paste_item_get_real_value (const GPasteItem *self) { g_return_val_if_fail (G_PASTE_IS_ITEM (self), NULL); GPasteItemPrivate *priv = g_paste_item_get_instance_private (self); return priv->value; } /** * g_paste_item_get_display_string: * @self: a #GPasteItem instance * * Get the string we should use to display the #GPasteItem * * Returns: read-only display string */ G_PASTE_VISIBLE const gchar * g_paste_item_get_display_string (const GPasteItem *self) { g_return_val_if_fail (G_PASTE_IS_ITEM (self), NULL); GPasteItemPrivate *priv = g_paste_item_get_instance_private (self); const gchar *display_string = priv->display_string; return (display_string) ? display_string : priv->value; } /** * g_paste_item_equals: * @self: a #GPasteItem instance * @other: another #GPasteItem instance * * Compare the two instances * * Returns: true if equals, false otherwise */ G_PASTE_VISIBLE gboolean g_paste_item_equals (const GPasteItem *self, const GPasteItem *other) { g_return_val_if_fail (G_PASTE_IS_ITEM (self), FALSE); g_return_val_if_fail (G_PASTE_IS_ITEM (other), FALSE); if (self == other) return TRUE; return G_PASTE_ITEM_GET_CLASS (self)->equals (self, other); } /** * g_paste_item_get_kind: * @self: a #GPasteItem instance * * Get the kind of #GPasteItem as string (for serialization) * * Returns: read-only string containing the kind of GPasteItem * can be "Text", "Uris" or "Image" */ G_PASTE_VISIBLE const gchar * g_paste_item_get_kind (const GPasteItem *self) { g_return_val_if_fail (G_PASTE_IS_ITEM (self), NULL); GPasteItemClass *klass = G_PASTE_ITEM_GET_CLASS (self); g_return_val_if_fail (klass->get_kind, NULL); return klass->get_kind (self); } /** * g_paste_item_get_size: * @self: a #GPasteItem instance * * Get the size of the #GPasteItem * * Returns: The size of its contents */ G_PASTE_VISIBLE guint64 g_paste_item_get_size (const GPasteItem *self) { g_return_val_if_fail (G_PASTE_IS_ITEM (self), 0); GPasteItemPrivate *priv = g_paste_item_get_instance_private (self); return priv->size; } /** * g_paste_item_set_size: * @self: a #GPasteItem instance * @size: the new size * * Set the size of the item * * Returns: */ G_PASTE_VISIBLE void g_paste_item_set_size (GPasteItem *self, guint64 size) { g_return_if_fail (G_PASTE_IS_ITEM (self)); GPasteItemPrivate *priv = g_paste_item_get_instance_private (self); priv->size = size; } /** * g_paste_item_add_size: * @self: a #GPasteItem instance * @size: the size to add * * Add some size of the item * * Returns: */ G_PASTE_VISIBLE void g_paste_item_add_size (GPasteItem *self, guint64 size) { g_return_if_fail (G_PASTE_IS_ITEM (self)); GPasteItemPrivate *priv = g_paste_item_get_instance_private (self); priv->size += size; } /** * g_paste_item_remove_size: * @self: a #GPasteItem instance * @size: the size to remove * * Remove some size from the item * * Returns: */ G_PASTE_VISIBLE void g_paste_item_remove_size (GPasteItem *self, guint64 size) { g_return_if_fail (G_PASTE_IS_ITEM (self)); GPasteItemPrivate *priv = g_paste_item_get_instance_private (self); g_return_if_fail (priv->size >= size); priv->size -= size; } /** * g_paste_item_set_display_string: * @self: a #GPasteItem instance * @display_string: the new display string * * Set the string to display * * Returns: */ G_PASTE_VISIBLE void g_paste_item_set_display_string (GPasteItem *self, const gchar *display_string) { g_return_if_fail (G_PASTE_IS_ITEM (self)); GPasteItemPrivate *priv = g_paste_item_get_instance_private (self); if (priv->display_string) { priv->size -= (strlen (priv->display_string) + 1); g_free (priv->display_string); } if (display_string) { priv->display_string = g_strdup (display_string); priv->size += strlen (display_string) + 1; } else priv->display_string = NULL; } /** * g_paste_item_set_state: * @self: a #GPasteItem instance * @state: a #GPasteItemState * * Set whether this item is Active or Idle * * Returns: */ G_PASTE_VISIBLE void g_paste_item_set_state (GPasteItem *self, GPasteItemState state) { g_return_if_fail (G_PASTE_IS_ITEM (self)); g_debug ("item: set state: %d", state); G_PASTE_ITEM_GET_CLASS (self)->set_state (self, state); } static void g_paste_item_finalize (GObject *object) { GPasteItemPrivate *priv = g_paste_item_get_instance_private (G_PASTE_ITEM (object)); g_free (priv->value); g_free (priv->display_string); G_OBJECT_CLASS (g_paste_item_parent_class)->finalize (object); } static gboolean g_paste_item_default_equals (const GPasteItem *self, const GPasteItem *other) { if (self == other) return TRUE; GPasteItemPrivate *priv = g_paste_item_get_instance_private (self); GPasteItemPrivate *_priv = g_paste_item_get_instance_private (other); return !g_strcmp0 (priv->value, _priv->value); } static void g_paste_item_default_set_state (GPasteItem *self G_GNUC_UNUSED, GPasteItemState state G_GNUC_UNUSED) { } static void g_paste_item_class_init (GPasteItemClass *klass) { klass->equals = g_paste_item_default_equals; klass->get_value = g_paste_item_get_real_value; klass->get_kind = NULL; klass->set_state = g_paste_item_default_set_state; G_OBJECT_CLASS (klass)->finalize = g_paste_item_finalize; } static void g_paste_item_init (GPasteItem *self G_GNUC_UNUSED) { } /** * g_paste_item_new: * @type: the type of the subclass to instantiate * @value: the value of the item * * Create a new instance of #GPasteItem * * Returns: a newly allocated #GPasteItem * free it with g_object_unref */ G_PASTE_VISIBLE GPasteItem * g_paste_item_new (GType type, const gchar *value) { g_return_val_if_fail (g_type_is_a (type, G_PASTE_TYPE_ITEM), NULL); g_return_val_if_fail (value, NULL); GPasteItem *self = g_object_new (type, NULL); GPasteItemPrivate *priv = g_paste_item_get_instance_private (self); priv->value = g_strdup (value); priv->display_string = NULL; priv->size = strlen (priv->value) + 1; return self; } GPaste-3.18.6/src/libgpaste/core/gpaste-item.h000066400000000000000000000054401305131721400210550ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_ITEM_H__ #define __G_PASTE_ITEM_H__ #include G_BEGIN_DECLS typedef enum { G_PASTE_ITEM_STATE_IDLE, G_PASTE_ITEM_STATE_ACTIVE } GPasteItemState; #define G_PASTE_TYPE_ITEM (g_paste_item_get_type ()) G_PASTE_DERIVABLE_TYPE (Item, item, ITEM, GObject) struct _GPasteItemClass { GObjectClass parent_class; /*< virtual >*/ const gchar * (*get_value) (const GPasteItem *self); gboolean (*equals) (const GPasteItem *self, const GPasteItem *other); void (*set_state) (GPasteItem *self, GPasteItemState state); /*< pure virtual >*/ const gchar *(*get_kind) (const GPasteItem *self); }; const gchar *g_paste_item_get_value (const GPasteItem *self); const gchar *g_paste_item_get_real_value (const GPasteItem *self); const gchar *g_paste_item_get_display_string (const GPasteItem *self); gboolean g_paste_item_equals (const GPasteItem *self, const GPasteItem *other); const gchar *g_paste_item_get_kind (const GPasteItem *self); guint64 g_paste_item_get_size (const GPasteItem *self); void g_paste_item_set_state (GPasteItem *self, GPasteItemState state); void g_paste_item_set_display_string (GPasteItem *self, const gchar *display_string); void g_paste_item_set_size (GPasteItem *self, guint64 size); void g_paste_item_add_size (GPasteItem *self, guint64 size); void g_paste_item_remove_size (GPasteItem *self, guint64 size); GPasteItem *g_paste_item_new (GType type, const gchar *value); G_END_DECLS #endif /*__G_PASTE_ITEM_H__*/ GPaste-3.18.6/src/libgpaste/core/gpaste-password-item.c000066400000000000000000000114111305131721400227030ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include struct _GPastePasswordItem { GPasteTextItem parent_instance; }; typedef struct { gchar *name; } GPastePasswordItemPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPastePasswordItem, g_paste_password_item, G_PASTE_TYPE_TEXT_ITEM) /** * g_paste_password_item_get_name: * @self: a #GPastePasswordItem instance * * Get the name of the given item * * Returns: read-only string containing the name */ G_PASTE_VISIBLE const gchar * g_paste_password_item_get_name (const GPastePasswordItem *self) { g_return_val_if_fail (G_PASTE_IS_PASSWORD_ITEM (self), NULL); GPastePasswordItemPrivate *priv = g_paste_password_item_get_instance_private (self); return priv->name; } /** * g_paste_password_item_set_name: * @self: a #GPastePasswordItem instance * @name: (nullable): the new name * * Set the name of the given item * * Returns: */ G_PASTE_VISIBLE void g_paste_password_item_set_name (GPastePasswordItem *self, const gchar *name) { g_return_if_fail (G_PASTE_IS_PASSWORD_ITEM (self)); g_return_if_fail (!name || g_utf8_validate (name, -1, NULL)); GPastePasswordItemPrivate *priv = g_paste_password_item_get_instance_private (self); if (!name) name = "******"; GPasteItem *item = G_PASTE_ITEM (self); g_paste_item_add_size (item, strlen (name) - ((priv->name) ? strlen(priv->name) : 0)); g_free (priv->name); priv->name = g_strdup (name); // This is the prefix displayed in history to identify a password g_autofree gchar *full_display_string = g_strdup_printf ("[%s] %s", _("Password"), name); g_paste_item_set_display_string (item, full_display_string); } static const gchar * g_paste_password_item_get_value (const GPasteItem *self G_GNUC_UNUSED) { return "******"; } static const gchar * g_paste_password_item_get_kind (const GPasteItem *self G_GNUC_UNUSED) { return "Password"; } static gboolean g_paste_password_item_equals (const GPasteItem *self, const GPasteItem *other) { g_return_val_if_fail (G_PASTE_IS_PASSWORD_ITEM (self), FALSE); g_return_val_if_fail (G_PASTE_IS_ITEM (other), FALSE); /* Passwords are never considered equals, except when it's the exact same object */ return FALSE; } static void g_paste_password_item_finalize (GObject *object) { GPastePasswordItemPrivate *priv = g_paste_password_item_get_instance_private (G_PASTE_PASSWORD_ITEM (object)); g_free (priv->name); G_OBJECT_CLASS (g_paste_password_item_parent_class)->finalize (object); } static void g_paste_password_item_class_init (GPastePasswordItemClass *klass) { GPasteItemClass *item_class = G_PASTE_ITEM_CLASS (klass); item_class->get_kind = g_paste_password_item_get_kind; item_class->get_value = g_paste_password_item_get_value; item_class->equals = g_paste_password_item_equals; G_OBJECT_CLASS (klass)->finalize = g_paste_password_item_finalize; } static void g_paste_password_item_init (GPastePasswordItem *self ) { GPastePasswordItemPrivate *priv = g_paste_password_item_get_instance_private (self); priv->name = NULL; } /** * g_paste_password_item_new: * @name: (nullable): the name used to identify the password * @password: the content of the desired #GPastePasswordItem * * Create a new instance of #GPastePasswordItem * * Returns: a newly allocated #GPastePasswordItem * free it with g_object_unref */ G_PASTE_VISIBLE GPasteItem * g_paste_password_item_new (const gchar *name, const gchar *password) { g_return_val_if_fail (password, NULL); g_return_val_if_fail (g_utf8_validate (password, -1, NULL), NULL); g_return_val_if_fail (!name || g_utf8_validate (name, -1, NULL), NULL); GPasteItem *self = g_paste_item_new (G_PASTE_TYPE_PASSWORD_ITEM, password); /* override password value length */ g_paste_item_set_size (self, 0); g_paste_password_item_set_name (G_PASTE_PASSWORD_ITEM (self), name); return self; } GPaste-3.18.6/src/libgpaste/core/gpaste-password-item.h000066400000000000000000000030651305131721400227160ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_PASSWORD_ITEM_H__ #define __G_PASTE_PASSWORD_ITEM_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_PASSWORD_ITEM (g_paste_password_item_get_type ()) G_PASTE_FINAL_TYPE (PasswordItem, password_item, PASSWORD_ITEM, GPasteTextItem) const gchar *g_paste_password_item_get_name (const GPastePasswordItem *self); void g_paste_password_item_set_name (GPastePasswordItem *self, const char *name); GPasteItem *g_paste_password_item_new (const gchar *name, const gchar *password); G_END_DECLS #endif /*__G_PASTE_PASSWORD_ITEM_H__*/ GPaste-3.18.6/src/libgpaste/core/gpaste-text-item.c000066400000000000000000000040131305131721400220250ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include G_DEFINE_TYPE (GPasteTextItem, g_paste_text_item, G_PASTE_TYPE_ITEM) static gboolean g_paste_text_item_equals (const GPasteItem *self, const GPasteItem *other) { return (G_PASTE_IS_TEXT_ITEM (other) && G_PASTE_ITEM_CLASS (g_paste_text_item_parent_class)->equals (self, other)); } static const gchar * g_paste_text_item_get_kind (const GPasteItem *self G_GNUC_UNUSED) { return "Text"; } static void g_paste_text_item_class_init (GPasteTextItemClass *klass) { GPasteItemClass *item_class = G_PASTE_ITEM_CLASS (klass); item_class->equals = g_paste_text_item_equals; item_class->get_kind = g_paste_text_item_get_kind; } static void g_paste_text_item_init (GPasteTextItem *self G_GNUC_UNUSED) { } /** * g_paste_text_item_new: * @text: the content of the desired #GPasteTextItem * * Create a new instance of #GPasteTextItem * * Returns: a newly allocated #GPasteTextItem * free it with g_object_unref */ G_PASTE_VISIBLE GPasteItem * g_paste_text_item_new (const gchar *text) { g_return_val_if_fail (text, NULL); g_return_val_if_fail (g_utf8_validate (text, -1, NULL), NULL); return g_paste_item_new (G_PASTE_TYPE_TEXT_ITEM, text); } GPaste-3.18.6/src/libgpaste/core/gpaste-text-item.h000066400000000000000000000025031305131721400220340ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_TEXT_ITEM_H__ #define __G_PASTE_TEXT_ITEM_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_TEXT_ITEM (g_paste_text_item_get_type ()) G_PASTE_DERIVABLE_TYPE (TextItem, text_item, TEXT_ITEM, GPasteItem) struct _GPasteTextItemClass { GPasteItemClass parent_class; }; GPasteItem *g_paste_text_item_new (const gchar *text); G_END_DECLS #endif /*__G_PASTE_TEXT_ITEM_H__*/ GPaste-3.18.6/src/libgpaste/core/gpaste-update-enums.c000066400000000000000000000040261305131721400225200ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include G_PASTE_VISIBLE GType g_paste_update_action_get_type (void) { static GType etype = 0; if (!etype) { static const GEnumValue values[] = { { G_PASTE_UPDATE_ACTION_REPLACE, "G_PASTE_UPDATE_ACTION_REPLACE", "REPLACE" }, { G_PASTE_UPDATE_ACTION_REMOVE, "G_PASTE_UPDATE_ACTION_REMOVE", "REMOVE" }, { G_PASTE_UPDATE_ACTION_INVALID, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GPasteUpdateAction"), values); g_type_class_ref (etype); } return etype; } G_PASTE_VISIBLE GType g_paste_update_target_get_type (void) { static GType etype = 0; if (!etype) { static const GEnumValue values[] = { { G_PASTE_UPDATE_TARGET_ALL, "G_PASTE_UPDATE_TARGET_ALL", "ALL" }, { G_PASTE_UPDATE_TARGET_POSITION, "G_PASTE_UPDATE_TARGET_POSITION", "POSITION" }, { G_PASTE_UPDATE_TARGET_INVALID, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("GPasteUpdateTarget"), values); g_type_class_ref (etype); } return etype; } GPaste-3.18.6/src/libgpaste/core/gpaste-update-enums.h000066400000000000000000000031351305131721400225250ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UPDATE_ENUMS_H__ #define __G_PASTE_UPDATE_ENUMS_H__ #include G_BEGIN_DECLS typedef enum { G_PASTE_UPDATE_ACTION_REPLACE = 1, G_PASTE_UPDATE_ACTION_REMOVE, G_PASTE_UPDATE_ACTION_INVALID = 0 } GPasteUpdateAction; #define G_PASTE_TYPE_UPDATE_ACTION (g_paste_update_action_get_type ()) GType g_paste_update_action_get_type (void); typedef enum { G_PASTE_UPDATE_TARGET_ALL = 1, G_PASTE_UPDATE_TARGET_POSITION, G_PASTE_UPDATE_TARGET_INVALID = 0 } GPasteUpdateTarget; #define G_PASTE_TYPE_UPDATE_TARGET (g_paste_update_target_get_type ()) GType g_paste_update_target_get_type (void); G_END_DECLS #endif /*__G_PASTE_UPDATE_ENUMS_H__*/ GPaste-3.18.6/src/libgpaste/core/gpaste-uris-item.c000066400000000000000000000100071305131721400220230ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include struct _GPasteUrisItem { GPasteTextItem parent_instance; }; typedef struct { GStrv uris; } GPasteUrisItemPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteUrisItem, g_paste_uris_item, G_PASTE_TYPE_TEXT_ITEM) /** * g_paste_uris_item_get_uris: * @self: a #GPasteUrisItem instance * * Get the list of uris contained in the #GPasteUrisItem * * Returns: (transfer none): read-only array of read-only uris (strings) */ G_PASTE_VISIBLE const gchar * const * g_paste_uris_item_get_uris (const GPasteUrisItem *self) { g_return_val_if_fail (G_PASTE_IS_URIS_ITEM (self), FALSE); GPasteUrisItemPrivate *priv = g_paste_uris_item_get_instance_private (self); return (const gchar * const *) priv->uris; } static gboolean g_paste_uris_item_equals (const GPasteItem *self, const GPasteItem *other) { return (G_PASTE_IS_URIS_ITEM (other) && G_PASTE_ITEM_CLASS (g_paste_uris_item_parent_class)->equals (self, other)); } static const gchar * g_paste_uris_item_get_kind (const GPasteItem *self G_GNUC_UNUSED) { return "Uris"; } static void g_paste_uris_item_finalize (GObject *object) { GPasteUrisItemPrivate *priv = g_paste_uris_item_get_instance_private (G_PASTE_URIS_ITEM (object)); g_strfreev (priv->uris); G_OBJECT_CLASS (g_paste_uris_item_parent_class)->finalize (object); } static void g_paste_uris_item_class_init (GPasteUrisItemClass *klass) { GPasteItemClass *item_class = G_PASTE_ITEM_CLASS (klass); item_class->equals = g_paste_uris_item_equals; item_class->get_kind = g_paste_uris_item_get_kind; G_OBJECT_CLASS (klass)->finalize = g_paste_uris_item_finalize; } static void g_paste_uris_item_init (GPasteUrisItem *self G_GNUC_UNUSED) { } /** * g_paste_uris_item_new: * @uris: a string containing the paths separated by "\n" (as returned by gtk_clipboard_wait_for_uris) * * Create a new instance of #GPasteUrisItem * * Returns: a newly allocated #GPasteUrisItem * free it with g_object_unref */ G_PASTE_VISIBLE GPasteItem * g_paste_uris_item_new (const gchar *uris) { g_return_val_if_fail (uris, NULL); g_return_val_if_fail (g_utf8_validate (uris, -1, NULL), NULL); GPasteItem *self = g_paste_item_new (G_PASTE_TYPE_URIS_ITEM, uris); GPasteUrisItemPrivate *priv = g_paste_uris_item_get_instance_private (G_PASTE_URIS_ITEM (self)); g_autofree gchar *display_string_with_newlines = g_paste_util_replace (uris, g_get_home_dir (), "~"); g_autofree gchar *display_string = g_paste_util_replace (display_string_with_newlines, "\n", " "); // This is the prefix displayed in history to identify selected files g_autofree gchar *full_display_string = g_strconcat (_("[Files] "), display_string, NULL); g_paste_item_set_display_string (self, full_display_string); g_auto (GStrv) paths = g_strsplit (uris, "\n", 0); guint64 length = g_strv_length (paths); g_paste_item_add_size (self, length + 1); GStrv _uris = priv->uris = g_new (gchar *, length + 1); for (guint64 i = 0; i < length; ++i) { _uris[i] = g_strconcat ("file://", paths[i], NULL); g_paste_item_add_size (self, strlen (_uris[i]) + 1); } _uris[length] = NULL; return self; } GPaste-3.18.6/src/libgpaste/core/gpaste-uris-item.h000066400000000000000000000025231305131721400220340ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_URIS_ITEM_H__ #define __G_PASTE_URIS_ITEM_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_URIS_ITEM (g_paste_uris_item_get_type ()) G_PASTE_FINAL_TYPE (UrisItem, uris_item, URIS_ITEM, GPasteTextItem) const gchar * const *g_paste_uris_item_get_uris (const GPasteUrisItem *self); GPasteItem *g_paste_uris_item_new (const gchar *uris); G_END_DECLS #endif /*__G_PASTE_URIS_ITEM_H__*/ GPaste-3.18.6/src/libgpaste/daemon/000077500000000000000000000000001305131721400167755ustar00rootroot00000000000000GPaste-3.18.6/src/libgpaste/daemon/gpaste-bus-object.c000066400000000000000000000035221305131721400224610ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include "gpaste-bus-object.h" G_DEFINE_ABSTRACT_TYPE (GPasteBusObject, g_paste_bus_object, G_TYPE_OBJECT) /** * g_paste_bus_object_register_on_connection: * @self: a #GPasteBusObject * @connection: a #GDBusConnection * @error: a #GError * * Register the #GPasteBusObject on the connection * * Returns: Whether the action succeeded or not */ G_PASTE_VISIBLE gboolean g_paste_bus_object_register_on_connection (GPasteBusObject *self, GDBusConnection *connection, GError **error) { g_return_val_if_fail (G_PASTE_IS_BUS_OBJECT (self), FALSE); g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), FALSE); g_return_val_if_fail (!error || !(*error), FALSE); return G_PASTE_BUS_OBJECT_GET_CLASS (self)->register_on_connection (self, connection, error); } static void g_paste_bus_object_class_init (GPasteBusObjectClass *klass) { klass->register_on_connection = NULL; } static void g_paste_bus_object_init (GPasteBusObject *self G_GNUC_UNUSED) { } GPaste-3.18.6/src/libgpaste/daemon/gpaste-bus-object.h000066400000000000000000000033241305131721400224660ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_BUS_OBJECT_H__ #define __G_PASTE_BUS_OBJECT_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_BUS_OBJECT (g_paste_bus_object_get_type ()) G_PASTE_DERIVABLE_TYPE (BusObject, bus_object, BUS_OBJECT, GObject) struct _GPasteBusObjectClass { GObjectClass parent_class; /*< pure virtual >*/ gboolean (*register_on_connection) (GPasteBusObject *self, GDBusConnection *connection, GError **error); }; gboolean g_paste_bus_object_register_on_connection (GPasteBusObject *self, GDBusConnection *connection, GError **error); G_END_DECLS #endif /*__G_PASTE_BUS_OBJECT_H__*/ GPaste-3.18.6/src/libgpaste/daemon/gpaste-bus.c000066400000000000000000000123061305131721400212150ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include struct _GPasteBus { GObject parent_instance; }; typedef struct { GDBusConnection *connection; guint64 id_on_bus; GPasteBusAcquiredCallback on_bus_acquired; gpointer user_data; } GPasteBusPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteBus, g_paste_bus, G_TYPE_OBJECT) enum { NAME_LOST, LAST_SIGNAL }; static guint64 signals[LAST_SIGNAL] = { 0 }; static void g_paste_bus_on_bus_acquired (GDBusConnection *connection, const char *name G_GNUC_UNUSED, gpointer user_data) { GPasteBus *self = user_data; GPasteBusPrivate *priv = g_paste_bus_get_instance_private (self); priv->connection = g_object_ref (connection); if (priv->on_bus_acquired) priv->on_bus_acquired (self, priv->user_data); } static void g_paste_bus_on_name_lost (GDBusConnection *connection G_GNUC_UNUSED, const char *name G_GNUC_UNUSED, gpointer user_data) { g_signal_emit (G_PASTE_BUS (user_data), signals[NAME_LOST], 0, /* detail */ NULL); } /** * g_paste_bus_own_name: * @self: the #GPasteBus * * Own the bus name * * Returns: */ G_PASTE_VISIBLE void g_paste_bus_own_name (GPasteBus *self) { g_return_if_fail (G_PASTE_IS_BUS (self)); GPasteBusPrivate *priv = g_paste_bus_get_instance_private (self); g_return_if_fail (!priv->id_on_bus); priv->id_on_bus = g_bus_own_name (G_BUS_TYPE_SESSION, G_PASTE_BUS_NAME, G_BUS_NAME_OWNER_FLAGS_NONE, g_paste_bus_on_bus_acquired, NULL, /* on_name_acquired */ g_paste_bus_on_name_lost, g_object_ref (self), g_object_unref); } /** * g_paste_bus_get_connection: * @self: the #GPasteBus * * returns the #GDBusConnection * * Returns: (transfer none) (optional): the connection */ G_PASTE_VISIBLE GDBusConnection * g_paste_bus_get_connection (const GPasteBus *self) { g_return_val_if_fail (G_PASTE_IS_BUS (self), NULL); GPasteBusPrivate *priv = g_paste_bus_get_instance_private (self); return priv->connection; } static void g_paste_bus_dispose (GObject *object) { GPasteBusPrivate *priv = g_paste_bus_get_instance_private (G_PASTE_BUS (object)); if (priv->connection) { g_bus_unown_name (priv->id_on_bus); g_clear_object (&priv->connection); } G_OBJECT_CLASS (g_paste_bus_parent_class)->dispose (object); } static void g_paste_bus_class_init (GPasteBusClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_bus_dispose; /** * GPasteDaemon::name-lost: * @gpaste_daemon: the object on which the signal was emitted * * The "name-lost" signal is emitted when the daemon has lost * its name on the bus. */ signals[NAME_LOST] = g_signal_new ("name-lost", G_PASTE_TYPE_BUS, G_SIGNAL_RUN_LAST, 0, /* class offset */ NULL, /* accumulator */ NULL, /* accumulator data */ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); } static void g_paste_bus_init (GPasteBus *self) { GPasteBusPrivate *priv = g_paste_bus_get_instance_private (self); priv->id_on_bus = 0; } /** * g_paste_bus_new: * @on_bus_acquired: (closure user_data) (scope notified) (nullable): handler to invoke when name is acquired or %NULL * * Create a new instance of #GPasteBus * * Returns: a newly allocated #GPasteBus * free it with g_object_unref */ G_PASTE_VISIBLE GPasteBus * g_paste_bus_new (GPasteBusAcquiredCallback on_bus_acquired, gpointer user_data) { GPasteBus *self = G_PASTE_BUS (g_object_new (G_PASTE_TYPE_BUS, NULL)); GPasteBusPrivate *priv = g_paste_bus_get_instance_private (self); priv->on_bus_acquired = on_bus_acquired; priv->user_data = user_data; return self; } GPaste-3.18.6/src/libgpaste/daemon/gpaste-bus.h000066400000000000000000000030121305131721400212140ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_BUS_H__ #define __G_PASTE_BUS_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_BUS (g_paste_bus_get_type ()) G_PASTE_FINAL_TYPE (Bus, bus, BUS, GObject) typedef void (*GPasteBusAcquiredCallback) (GPasteBus *bus, gpointer user_data); void g_paste_bus_own_name (GPasteBus *self); GDBusConnection *g_paste_bus_get_connection (const GPasteBus *self); GPasteBus *g_paste_bus_new (GPasteBusAcquiredCallback on_bus_acquired, gpointer user_data); G_END_DECLS #endif /*__G_PASTE_BUS_H__*/ GPaste-3.18.6/src/libgpaste/daemon/gpaste-daemon.c000066400000000000000000001266011305131721400216730ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include "gpaste-gdbus-macros.h" #include #include #include #include #include #include #include #include #include #include #include #define G_PASTE_SEND_DBUS_SIGNAL_FULL(sig,data,error) \ g_dbus_connection_emit_signal (priv->connection, \ NULL, /* destination_bus_name */ \ G_PASTE_DAEMON_OBJECT_PATH, \ G_PASTE_DAEMON_INTERFACE_NAME, \ G_PASTE_DAEMON_SIG_##sig, \ data, \ error) #define __NODATA g_variant_new_tuple (NULL, 0) #define __DATA(data) g_variant_new_tuple (&data, 1) #define G_PASTE_SEND_DBUS_SIGNAL(sig) G_PASTE_SEND_DBUS_SIGNAL_FULL(sig, __NODATA, NULL) #define G_PASTE_SEND_DBUS_SIGNAL_WITH_ERROR(sig) G_PASTE_SEND_DBUS_SIGNAL_FULL(sig, __NODATA, error) #define G_PASTE_SEND_DBUS_SIGNAL_WITH_DATA(sig,d) G_PASTE_SEND_DBUS_SIGNAL_FULL(sig, __DATA(d), NULL) #define G_PASTE_DBUS_ASSERT_FULL(cond, _msg, ret) \ do { \ if (!(cond)) \ { \ *err = _err (G_PASTE_BUS_NAME ".Error", _msg); \ return ret; \ } \ } while (FALSE) #define G_PASTE_DBUS_ASSERT(cond, _msg) G_PASTE_DBUS_ASSERT_FULL (cond, _msg, ;) enum { C_UPDATE, C_SWITCH, C_TRACK, C_ACTIVE_CHANGED, C_LAST_SIGNAL }; struct _GPasteDaemon { GPasteBusObject parent_instance; }; typedef struct { GDBusConnection *connection; guint64 id_on_bus; gboolean registered; GPasteHistory *history; GPasteSettings *settings; GPasteClipboardsManager *clipboards_manager; GPasteKeybinder *keybinder; GPasteScreensaverClient *screensaver; GDBusNodeInfo *g_paste_daemon_dbus_info; GDBusInterfaceVTable g_paste_daemon_dbus_vtable; gulong c_signals[C_LAST_SIGNAL]; } GPasteDaemonPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteDaemon, g_paste_daemon, G_PASTE_TYPE_BUS_OBJECT) enum { REEXECUTE_SELF, LAST_SIGNAL }; static guint64 signals[LAST_SIGNAL] = { 0 }; typedef struct { const gchar *name; const gchar *msg; } GPasteDBusError; static inline GPasteDBusError * _err (const gchar *name, const gchar *msg) { GPasteDBusError *err = g_malloc (sizeof (GPasteDBusError)); err->name = name; err->msg = msg; return err; } static gchar * g_paste_daemon_get_dbus_string_parameter (GVariant *parameters, guint64 *length) { GVariantIter parameters_iter; g_variant_iter_init (¶meters_iter, parameters); g_autoptr (GVariant) variant = g_variant_iter_next_value (¶meters_iter); return g_variant_dup_string (variant, length); } static void _variant_iter_read_strings_parameter (GVariantIter *parameters_iter, gchar **str1, gchar **str2) { g_autoptr (GVariant) variant1 = g_variant_iter_next_value (parameters_iter); g_autoptr (GVariant) variant2 = g_variant_iter_next_value (parameters_iter); guint64 length; *str1 = g_variant_dup_string (variant1, &length); *str2 = g_variant_dup_string (variant2, &length); } static void g_paste_daemon_get_dbus_strings_parameter (GVariant *parameters, gchar **str1, gchar **str2) { GVariantIter parameters_iter; g_variant_iter_init (¶meters_iter, parameters); _variant_iter_read_strings_parameter (¶meters_iter, str1, str2); } static guint64 g_paste_daemon_get_dbus_uint64_parameter (GVariant *parameters) { GVariantIter parameters_iter; g_variant_iter_init (¶meters_iter, parameters); g_autoptr (GVariant) variant = g_variant_iter_next_value (¶meters_iter); return g_variant_get_uint64 (variant); } /****************/ /* DBus Signals */ /****************/ static void g_paste_daemon_update (GPasteDaemon *self, GPasteUpdateAction action, GPasteUpdateTarget target, guint64 position) { GPasteDaemonPrivate *priv = g_paste_daemon_get_instance_private (self); GVariant *data[] = { g_variant_new_string (g_enum_get_value (g_type_class_peek (G_PASTE_TYPE_UPDATE_ACTION), action)->value_nick), g_variant_new_string (g_enum_get_value (g_type_class_peek (G_PASTE_TYPE_UPDATE_TARGET), target)->value_nick), g_variant_new_uint64 (position) }; G_PASTE_SEND_DBUS_SIGNAL_FULL (UPDATE, g_variant_new_tuple (data, 3), NULL); } /** * g_paste_daemon_show_history: * @self: (transfer none): the #GPasteDaemon * @error: a #GError * * Emit the signal to show history * * Returns: */ G_PASTE_VISIBLE void g_paste_daemon_show_history (GPasteDaemon *self, GError **error) { g_return_if_fail (G_PASTE_IS_DAEMON (self)); GPasteDaemonPrivate *priv = g_paste_daemon_get_instance_private (self); G_PASTE_SEND_DBUS_SIGNAL_WITH_ERROR (SHOW_HISTORY); } static void g_paste_daemon_tracking (GPasteDaemon *self, gboolean tracking_state, GPasteSettings *settings G_GNUC_UNUSED) { GPasteDaemonPrivate *priv = g_paste_daemon_get_instance_private (self); GVariant *variant = g_variant_new_boolean (tracking_state); G_PASTE_SEND_DBUS_SIGNAL_WITH_DATA (TRACKING, variant); } /****************/ /* DBus Mathods */ /****************/ static void g_paste_daemon_private_do_add_item (GPasteDaemonPrivate *priv, GPasteItem *item) { g_paste_history_add (priv->history, item); if (!g_paste_clipboards_manager_select (priv->clipboards_manager, item)) g_paste_history_remove (priv->history, 0); } static void g_paste_daemon_private_do_add (GPasteDaemonPrivate *priv, const gchar *text, guint64 length, GPasteDBusError **err) { G_PASTE_DBUS_ASSERT (text && length, "no content to add"); GPasteSettings *settings = priv->settings; g_autofree gchar *stripped = g_strstrip (g_strdup (text)); if (length >= g_paste_settings_get_min_text_item_size (settings) && length <= g_paste_settings_get_max_text_item_size (settings) && strlen (stripped) != 0) { g_paste_daemon_private_do_add_item (priv, g_paste_text_item_new (g_paste_settings_get_trim_items (settings) ? stripped : text)); } } static void g_paste_daemon_private_add (GPasteDaemonPrivate *priv, GVariant *parameters, GPasteDBusError **err) { guint64 length; g_autofree gchar *text = g_paste_daemon_get_dbus_string_parameter (parameters, &length); g_paste_daemon_private_do_add (priv, text, length, err); } static void g_paste_daemon_private_add_file (GPasteDaemonPrivate *priv, GVariant *parameters, GError **error, GPasteDBusError **err) { guint64 length; g_autofree gchar *file = g_paste_daemon_get_dbus_string_parameter (parameters, &length); g_autofree gchar *content = NULL; G_PASTE_DBUS_ASSERT (file, "no file to add"); if (g_file_get_contents (file, &content, &length, error)) { g_paste_daemon_private_do_add (priv, content, length, err); } } static void g_paste_daemon_private_add_password (GPasteDaemonPrivate *priv, GVariant *parameters, GPasteDBusError **err) { g_autofree gchar *name = NULL; g_autofree gchar *password = NULL; g_paste_daemon_get_dbus_strings_parameter (parameters, &name, &password); G_PASTE_DBUS_ASSERT (name && password, "no password to add"); g_paste_daemon_private_do_add_item (priv, g_paste_password_item_new (name, password)); } static void g_paste_daemon_private_delete_history_signal (GPasteDaemonPrivate *priv, const gchar *history) { GVariant *variant = g_variant_new_string (history); G_PASTE_SEND_DBUS_SIGNAL_WITH_DATA (DELETE_HISTORY, variant); } static void g_paste_daemon_private_empty_history_signal (GPasteDaemonPrivate *priv, const gchar *history) { GVariant *variant = g_variant_new_string (history); G_PASTE_SEND_DBUS_SIGNAL_WITH_DATA (EMPTY_HISTORY, variant); } static void g_paste_daemon_private_switch_history_signal (GPasteDaemonPrivate *priv, const gchar *history) { GVariant *variant = g_variant_new_string (history); G_PASTE_SEND_DBUS_SIGNAL_WITH_DATA (SWITCH_HISTORY, variant); } static void g_paste_daemon_private_backup_history (GPasteDaemonPrivate *priv, GVariant *parameters, GPasteDBusError **err) { g_autofree gchar *history = NULL; g_autofree gchar *backup = NULL; g_paste_daemon_get_dbus_strings_parameter (parameters, &history, &backup); G_PASTE_DBUS_ASSERT (history && backup, "no history to backup"); GPasteSettings *settings = priv->settings; /* create a new history to do the backup without polluting the current one */ g_autoptr (GPasteHistory) _history = g_paste_history_new (settings); const gchar *old_name = g_paste_history_get_current (priv->history); /* We emit all those signals to be sure that all the guis have their histories list updated */ g_paste_history_load (_history, history); g_paste_daemon_private_switch_history_signal (priv, history); g_paste_history_save (_history, backup); g_paste_daemon_private_switch_history_signal (priv, backup); g_paste_daemon_private_switch_history_signal (priv, old_name); } static void g_paste_daemon_private_delete (GPasteDaemonPrivate *priv, GVariant *parameters) { g_paste_history_remove (priv->history, g_paste_daemon_get_dbus_uint64_parameter (parameters)); } static void g_paste_daemon_private_delete_history (GPasteDaemonPrivate *priv, GVariant *parameters, GPasteDBusError **err) { g_autofree gchar *name = g_paste_daemon_get_dbus_string_parameter (parameters, NULL); G_PASTE_DBUS_ASSERT (name, "no history to delete"); GPasteHistory *history = priv->history; g_paste_history_delete (history, name, NULL); g_paste_daemon_private_delete_history_signal (priv, name); if (!g_strcmp0 (name, g_paste_history_get_current (priv->history))) g_paste_history_switch (history, DEFAULT_HISTORY); } static void g_paste_daemon_private_delete_password (GPasteDaemonPrivate *priv, GVariant *parameters, GPasteDBusError **err) { g_autofree gchar *name = g_paste_daemon_get_dbus_string_parameter (parameters, NULL); G_PASTE_DBUS_ASSERT (name, "no password to delete"); g_paste_history_delete_password (priv->history, name); } static void g_paste_daemon_private_empty_history (GPasteDaemonPrivate *priv, GVariant *parameters) { g_autofree gchar *name = g_paste_daemon_get_dbus_string_parameter (parameters, NULL); if (!g_strcmp0 (name, g_paste_history_get_current (priv->history))) { g_paste_history_empty (priv->history); } else { g_autoptr (GPasteHistory) history = g_paste_history_new (priv->settings); g_paste_history_save (history, name); } g_paste_daemon_private_empty_history_signal (priv, name); } static GVariant * g_paste_daemon_private_get_element (GPasteDaemonPrivate *priv, GVariant *parameters, GPasteDBusError **err) { GPasteHistory *history = priv->history; guint64 index = g_paste_daemon_get_dbus_uint64_parameter (parameters); G_PASTE_DBUS_ASSERT_FULL (index < g_paste_history_get_length (history), "invalid index received", NULL); const gchar *value = g_paste_history_get_display_string (history, index); G_PASTE_DBUS_ASSERT_FULL (value, "received no value for this index", NULL); GVariant *variant = g_variant_new_string (value); return g_variant_new_tuple (&variant, 1); } static GVariant * g_paste_daemon_private_get_element_kind (GPasteDaemonPrivate *priv, GVariant *parameters, GPasteDBusError **err) { GPasteHistory *history = priv->history; guint64 index = g_paste_daemon_get_dbus_uint64_parameter (parameters); G_PASTE_DBUS_ASSERT_FULL (index < g_paste_history_get_length (history), "invalid index received", NULL); const GPasteItem *item = g_paste_history_get (history, index); G_PASTE_DBUS_ASSERT_FULL (item, "received no item for this index", NULL); GVariant *variant = g_variant_new_string (g_paste_item_get_kind (item)); return g_variant_new_tuple (&variant, 1); } static GVariant * g_paste_daemon_private_get_elements (GPasteDaemonPrivate *priv, GVariant *parameters, GPasteDBusError **err) { GPasteHistory *history = priv->history; GVariantIter parameters_iter; g_variant_iter_init (¶meters_iter, parameters); g_autoptr (GVariant) variant = g_variant_iter_next_value (¶meters_iter); guint64 len; g_autofree guint64 *indexes = g_paste_util_get_dbus_at_result (variant, &len); g_auto (GStrv) ans = g_new0 (gchar *, len + 1); guint64 history_length = g_paste_history_get_length (history); for (guint64 i = 0; i < len; ++i) { G_PASTE_DBUS_ASSERT_FULL (indexes[i] < history_length, "invalid index received", NULL); const gchar *value = g_paste_history_get_display_string (history, indexes[i]); G_PASTE_DBUS_ASSERT_FULL (value, "received no value for this index", NULL); ans[i] = g_strdup (value); } GVariant *answer = g_variant_new_strv ((const gchar * const *) ans, len); return g_variant_new_tuple (&answer, 1); } static GVariant * g_paste_daemon_private_get_history (GPasteDaemonPrivate *priv) { const GSList *history = g_paste_history_get_history (priv->history); guint64 length = g_slist_length ((GSList *) history); g_autofree const gchar **displayed_history = g_new (const gchar *, length + 1); for (guint64 i = 0; i < length; ++i, history = g_slist_next (history)) displayed_history[i] = g_paste_item_get_display_string (history->data); displayed_history[length] = NULL; GVariant *variant = g_variant_new_strv ((const gchar * const *) displayed_history, -1); return g_variant_new_tuple (&variant, 1); } static GVariant * g_paste_daemon_private_get_history_name (GPasteDaemonPrivate *priv) { GVariant *variant = g_variant_new_string (g_paste_history_get_current (priv->history)); return g_variant_new_tuple (&variant, 1); } static GVariant * g_paste_daemon_private_get_history_size (GPasteDaemonPrivate *priv, GVariant *parameters) { g_autofree gchar *name = g_paste_daemon_get_dbus_string_parameter (parameters, NULL); guint64 size; if (!g_strcmp0 (name, g_paste_history_get_current (priv->history))) { size = g_paste_history_get_length (priv->history); } else { g_autoptr (GPasteHistory) history = g_paste_history_new (priv->settings); g_paste_history_load (history, name); size = g_paste_history_get_length (history); } GVariant *variant = g_variant_new_uint64 (size); return g_variant_new_tuple (&variant, 1); } static GVariant * g_paste_daemon_private_get_raw_element (GPasteDaemonPrivate *priv, GVariant *parameters, GPasteDBusError **err) { GPasteHistory *history = priv->history; guint64 index = g_paste_daemon_get_dbus_uint64_parameter (parameters); G_PASTE_DBUS_ASSERT_FULL (index < g_paste_history_get_length (history), "invalid index received", NULL); const gchar *value = g_paste_history_get_value (priv->history, index); G_PASTE_DBUS_ASSERT_FULL (value, "received no value for this index", NULL); GVariant *variant = g_variant_new_string (value); return g_variant_new_tuple (&variant, 1); } static GVariant * g_paste_daemon_private_get_raw_history (GPasteDaemonPrivate *priv) { const GSList *history = g_paste_history_get_history (priv->history); guint64 length = g_slist_length ((GSList *) history); g_autofree const gchar **displayed_history = g_new (const gchar *, length + 1); for (guint64 i = 0; i < length; ++i, history = g_slist_next (history)) displayed_history[i] = g_paste_item_get_value (history->data); displayed_history[length] = NULL; GVariant *variant = g_variant_new_strv ((const gchar * const *) displayed_history, -1); return g_variant_new_tuple (&variant, 1); } static GVariant * g_paste_daemon_list_histories (GError **error) { g_auto (GStrv) history_names = g_paste_history_list (error); if (!history_names) return NULL; GVariant *variant = g_variant_new_strv ((const gchar * const *) history_names, -1); return g_variant_new_tuple (&variant, 1); } static void g_paste_daemon_private_merge (GPasteDaemonPrivate *priv, GVariant *parameters, GPasteDBusError **err) { GVariantIter parameters_iter; g_variant_iter_init (¶meters_iter, parameters); g_autofree gchar *decoration = NULL; g_autofree gchar *separator = NULL; _variant_iter_read_strings_parameter (¶meters_iter, &decoration, &separator); g_autoptr (GVariant) v_indexes = g_variant_iter_next_value (¶meters_iter); guint64 length; const guint64 *indexes = g_variant_get_fixed_array (v_indexes, &length, sizeof (guint64)); GPasteHistory *history = priv->history; guint64 history_length = g_paste_history_get_length (history); G_PASTE_DBUS_ASSERT (length, "nothing to merge"); for (guint64 i = 0; i < length; ++i) { G_PASTE_DBUS_ASSERT (indexes[i] < history_length, "invalid index received"); } g_autoptr (GString) str = g_string_new (NULL); for (guint64 i = 0; i < length; ++i) { g_string_append_printf (str, "%s%s%s%s", (i) ? separator : "", decoration, g_paste_history_get_value (history, indexes[i]), decoration); } g_paste_daemon_private_do_add (priv, str->str, str->len, err); } static void g_paste_daemon_track (GPasteDaemon *self, GVariant *parameters) { GVariantIter parameters_iter; g_variant_iter_init (¶meters_iter, parameters); g_autoptr (GVariant) variant = g_variant_iter_next_value (¶meters_iter); gboolean tracking_state = g_variant_get_boolean (variant); GPasteDaemonPrivate *priv = g_paste_daemon_get_instance_private (self); g_paste_settings_set_track_changes (priv->settings, tracking_state); g_paste_daemon_tracking (self, tracking_state, NULL); } static void g_paste_daemon_on_extension_state_changed (GPasteDaemon *self, GVariant *parameters) { GPasteDaemonPrivate *priv = g_paste_daemon_get_instance_private (self); if (g_paste_settings_get_track_extension_state (priv->settings)) g_paste_daemon_track (self, parameters); } static void g_paste_daemon_reexecute (GPasteDaemon *self) { g_signal_emit (self, signals[REEXECUTE_SELF], 0, /* detail */ NULL); } static void g_paste_daemon_private_rename_password (GPasteDaemonPrivate *priv, GVariant *parameters, GPasteDBusError **err) { g_autofree gchar *old_name = NULL; g_autofree gchar *new_name = NULL; g_paste_daemon_get_dbus_strings_parameter (parameters, &old_name, &new_name); G_PASTE_DBUS_ASSERT (old_name, "no password to rename"); g_paste_history_rename_password (priv->history, old_name, new_name); } static GVariant * g_paste_daemon_private_search (GPasteDaemonPrivate *priv, GVariant *parameters, GPasteDBusError **err) { g_autofree gchar *name = g_paste_daemon_get_dbus_string_parameter (parameters, NULL); g_autoptr (GArray) results = g_paste_history_search (priv->history, name); G_PASTE_DBUS_ASSERT_FULL (results, "Error while performing search", NULL); GVariant *variant = g_variant_new_fixed_array (G_VARIANT_TYPE_UINT64, results->data, results->len, sizeof (guint64)); return g_variant_new_tuple (&variant, 1); } static void g_paste_daemon_private_select (GPasteDaemonPrivate *priv, GVariant *parameters) { g_paste_history_select (priv->history, g_paste_daemon_get_dbus_uint64_parameter (parameters)); } static void g_paste_daemon_private_replace (GPasteDaemonPrivate *priv, GVariant *parameters, GPasteDBusError **err) { GPasteHistory *history = priv->history; GVariantIter parameters_iter; guint64 length; g_variant_iter_init (¶meters_iter, parameters); g_autoptr (GVariant) variant1 = g_variant_iter_next_value (¶meters_iter); guint64 index = g_variant_get_uint64 (variant1); G_PASTE_DBUS_ASSERT (index < g_paste_history_get_length (history), "invalid index received"); const GPasteItem *item = g_paste_history_get (history, index); G_PASTE_DBUS_ASSERT (item, "received no item for this index"); G_PASTE_DBUS_ASSERT (G_PASTE_IS_TEXT_ITEM (item) && !g_strcmp0 (g_paste_item_get_kind (item), "Text"), "attempted to replace an item other than GPasteTextItem"); g_autoptr (GVariant) variant2 = g_variant_iter_next_value (¶meters_iter); g_autofree gchar *contents = g_variant_dup_string (variant2, &length); G_PASTE_DBUS_ASSERT (contents, "no contents given"); g_paste_history_replace (priv->history, index, contents); } static void g_paste_daemon_private_set_password (GPasteDaemonPrivate *priv, GVariant *parameters, GPasteDBusError **err) { GPasteHistory *history = priv->history; GVariantIter parameters_iter; guint64 length; g_variant_iter_init (¶meters_iter, parameters); g_autoptr (GVariant) variant1 = g_variant_iter_next_value (¶meters_iter); guint64 index = g_variant_get_uint64 (variant1); G_PASTE_DBUS_ASSERT (index < g_paste_history_get_length (history), "invalid index received"); const GPasteItem *item = g_paste_history_get (history, index); G_PASTE_DBUS_ASSERT (item, "received no item for this index"); G_PASTE_DBUS_ASSERT (G_PASTE_IS_TEXT_ITEM (item) && !g_strcmp0 (g_paste_item_get_kind (item), "Text"), "attempted to replace an item other than GPasteTextItem"); g_autoptr (GVariant) variant2 = g_variant_iter_next_value (¶meters_iter); g_autofree gchar *name = g_variant_dup_string (variant2, &length); G_PASTE_DBUS_ASSERT (name, "no password name given"); g_paste_history_set_password (priv->history, index, name); } static void g_paste_daemon_private_switch_history (GPasteDaemonPrivate *priv, GVariant *parameters, GPasteDBusError **err) { g_autofree gchar *name = g_paste_daemon_get_dbus_string_parameter (parameters, NULL); G_PASTE_DBUS_ASSERT (name, "no history to switch to"); g_paste_history_switch (priv->history, name); } static void g_paste_daemon_private_upload_finish (GObject *source_object, GAsyncResult *res, gpointer user_data) { g_autoptr (GSubprocess) upload = G_SUBPROCESS (source_object); g_autofree gchar *url = NULL; g_autofree GPasteDBusError *err = NULL; GPasteDaemonPrivate *priv = user_data; g_subprocess_communicate_utf8_finish (upload, res, &url, NULL, /* stderr */ NULL); /* error */ if (url) g_paste_daemon_private_do_add (priv, url, strlen (url), &err); } /** * g_paste_daemon_upload: * @self: (transfer none): the #GPasteDaemon * @index: the index of the item to upload * * Upload an item to a pastebin service * * Returns: */ G_PASTE_VISIBLE void g_paste_daemon_upload (GPasteDaemon *self, guint64 index) { g_return_if_fail (G_PASTE_IS_DAEMON (self)); GPasteDaemonPrivate *priv = g_paste_daemon_get_instance_private (self); GSubprocess *upload = g_subprocess_new (G_SUBPROCESS_FLAGS_STDIN_PIPE|G_SUBPROCESS_FLAGS_STDOUT_PIPE, NULL, "wgetpaste", NULL); const gchar *value = g_paste_history_get_value (priv->history, index); g_subprocess_communicate_utf8_async (upload, value, NULL, /* cancellable */ g_paste_daemon_private_upload_finish, priv); } static void _g_paste_daemon_upload (GPasteDaemon *self, GVariant *parameters) { g_paste_daemon_upload(self, g_paste_daemon_get_dbus_uint64_parameter (parameters)); } static void g_paste_daemon_activate_default_keybindings (GPasteDaemon *self) { GPasteDaemonPrivate *priv = g_paste_daemon_get_instance_private (self); GPasteKeybinder *keybinder = priv->keybinder; GPasteHistory *history = priv->history; GPasteClipboardsManager *clipboards_manager = priv->clipboards_manager; GPasteKeybinding *keybindings[] = { g_paste_make_password_keybinding_new (history), g_paste_pop_keybinding_new (history), g_paste_show_history_keybinding_new (self), g_paste_sync_clipboard_to_primary_keybinding_new (clipboards_manager), g_paste_sync_primary_to_clipboard_keybinding_new (clipboards_manager), g_paste_ui_keybinding_new (), g_paste_upload_keybinding_new (self) }; for (guint64 k = 0; k < G_N_ELEMENTS (keybindings); ++k) g_paste_keybinder_add_keybinding (keybinder, keybindings[k]); g_paste_keybinder_activate_all (keybinder); } static void g_paste_daemon_dbus_method_call (GDBusConnection *connection G_GNUC_UNUSED, const gchar *sender G_GNUC_UNUSED, const gchar *object_path G_GNUC_UNUSED, const gchar *interface_name G_GNUC_UNUSED, const gchar *method_name, GVariant *parameters, GDBusMethodInvocation *invocation, gpointer user_data) { GPasteDaemon *self = user_data; GPasteDaemonPrivate *priv = g_paste_daemon_get_instance_private (self); GVariant *answer = NULL; GError *error = NULL; g_autofree GPasteDBusError *err = NULL; if (!g_strcmp0 (method_name, G_PASTE_DAEMON_ABOUT)) g_paste_util_activate_ui ("about", NULL); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_ADD)) g_paste_daemon_private_add (priv, parameters, &err); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_ADD_FILE)) g_paste_daemon_private_add_file (priv, parameters, &error, &err); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_ADD_PASSWORD)) g_paste_daemon_private_add_password (priv, parameters, &err); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_BACKUP_HISTORY)) g_paste_daemon_private_backup_history (priv, parameters, &err); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_DELETE)) g_paste_daemon_private_delete (priv, parameters); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_DELETE_HISTORY)) g_paste_daemon_private_delete_history (priv, parameters, &err); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_DELETE_PASSWORD)) g_paste_daemon_private_delete_password (priv, parameters, &err); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_EMPTY_HISTORY)) g_paste_daemon_private_empty_history (priv, parameters); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_GET_ELEMENT)) answer = g_paste_daemon_private_get_element (priv, parameters, &err); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_GET_ELEMENT_KIND)) answer = g_paste_daemon_private_get_element_kind (priv, parameters, &err); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_GET_ELEMENTS)) answer = g_paste_daemon_private_get_elements (priv, parameters, &err); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_GET_HISTORY)) answer = g_paste_daemon_private_get_history (priv); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_GET_HISTORY_NAME)) answer = g_paste_daemon_private_get_history_name (priv); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_GET_HISTORY_SIZE)) answer = g_paste_daemon_private_get_history_size (priv, parameters); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_GET_RAW_ELEMENT)) answer = g_paste_daemon_private_get_raw_element (priv, parameters, &err); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_GET_RAW_HISTORY)) answer = g_paste_daemon_private_get_raw_history (priv); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_LIST_HISTORIES)) answer = g_paste_daemon_list_histories (&error); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_MERGE)) g_paste_daemon_private_merge (priv, parameters, &err); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_ON_EXTENSION_STATE_CHANGED)) g_paste_daemon_on_extension_state_changed (self, parameters); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_REEXECUTE)) g_paste_daemon_reexecute (self); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_RENAME_PASSWORD)) g_paste_daemon_private_rename_password (priv, parameters, &err); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_REPLACE)) g_paste_daemon_private_replace (priv, parameters, &err); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_SEARCH)) answer = g_paste_daemon_private_search (priv, parameters, &err); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_SELECT)) g_paste_daemon_private_select (priv, parameters); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_SET_PASSWORD)) g_paste_daemon_private_set_password (priv, parameters, &err); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_SHOW_HISTORY)) g_paste_daemon_show_history (self, &error); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_SWITCH_HISTORY)) g_paste_daemon_private_switch_history (priv, parameters, &err); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_TRACK)) g_paste_daemon_track (self, parameters); else if (!g_strcmp0 (method_name, G_PASTE_DAEMON_UPLOAD)) _g_paste_daemon_upload (self, parameters); if (error) g_dbus_method_invocation_take_error (invocation, error); else if (err) g_dbus_method_invocation_return_dbus_error (invocation, err->name, err->msg); else g_dbus_method_invocation_return_value (invocation, answer); } static GVariant * g_paste_daemon_dbus_get_property (GDBusConnection *connection G_GNUC_UNUSED, const gchar *sender G_GNUC_UNUSED, const gchar *object_path G_GNUC_UNUSED, const gchar *interface_name G_GNUC_UNUSED, const gchar *property_name, GError **error G_GNUC_UNUSED, gpointer user_data) { GPasteDaemonPrivate *priv = g_paste_daemon_get_instance_private (G_PASTE_DAEMON (user_data)); if (!g_strcmp0 (property_name, G_PASTE_DAEMON_PROP_ACTIVE)) return g_variant_new_boolean (g_paste_settings_get_track_changes (priv->settings)); else if (!g_strcmp0 (property_name, G_PASTE_DAEMON_PROP_VERSION)) return g_variant_new_string (VERSION); return NULL; } static void g_paste_daemon_unregister_object (gpointer user_data) { g_autoptr (GPasteDaemon) self = G_PASTE_DAEMON (user_data); GPasteDaemonPrivate *priv = g_paste_daemon_get_instance_private (self); gulong *c_signals = priv->c_signals; g_signal_handler_disconnect (priv->settings, c_signals[C_TRACK]); g_signal_handler_disconnect (priv->history, c_signals[C_UPDATE]); g_signal_handler_disconnect (priv->history, c_signals[C_SWITCH]); if (priv->screensaver) g_signal_handler_disconnect (priv->screensaver, c_signals[C_ACTIVE_CHANGED]); priv->registered = FALSE; } static void g_paste_daemon_on_history_update (GPasteDaemon *self, GPasteUpdateAction action, GPasteUpdateTarget target, guint64 position, gpointer user_data G_GNUC_UNUSED) { g_paste_daemon_update (self, action, target, position); } static void g_paste_daemon_on_history_switch (GPasteDaemonPrivate *priv, const gchar *name, gpointer user_data G_GNUC_UNUSED) { g_paste_daemon_private_switch_history_signal (priv, name); } static void g_paste_daemon_on_screensaver_active_changed (GPasteDaemonPrivate *priv, gboolean active, gpointer user_data G_GNUC_UNUSED) { if (!priv->registered) return; /* The deactivate signal is always sent, but not the activate one */ /* We always do the activate action, so that the deactivate one works anyways */ { g_autoptr (GPasteItem) item = g_paste_text_item_new (""); /* will always return TRUE */ g_paste_clipboards_manager_select (priv->clipboards_manager, item); } if (!active) { const GPasteItem *item = g_paste_history_get (priv->history, 0); if (item) { if (!g_paste_clipboards_manager_select (priv->clipboards_manager, item)) g_paste_history_remove (priv->history, 0); } } } static gboolean _g_paste_daemon_changed (gpointer data) { GPasteDaemon *self = G_PASTE_DAEMON (data); g_paste_daemon_update (self, G_PASTE_UPDATE_ACTION_REPLACE, G_PASTE_UPDATE_TARGET_ALL, 0); return G_SOURCE_REMOVE; } static void g_paste_daemon_dispose (GObject *object) { GPasteDaemonPrivate *priv = g_paste_daemon_get_instance_private (G_PASTE_DAEMON (object)); if (priv->settings) { g_dbus_connection_unregister_object (priv->connection, priv->id_on_bus); g_clear_object (&priv->connection); g_clear_object (&priv->history); g_clear_object (&priv->settings); g_clear_object (&priv->clipboards_manager); g_clear_object (&priv->keybinder); g_clear_object (&priv->screensaver); g_dbus_node_info_unref (priv->g_paste_daemon_dbus_info); } G_OBJECT_CLASS (g_paste_daemon_parent_class)->dispose (object); } static gboolean g_paste_daemon_register_on_connection (GPasteBusObject *self, GDBusConnection *connection, GError **error) { GPasteDaemonPrivate *priv = g_paste_daemon_get_instance_private (G_PASTE_DAEMON (self)); g_clear_object (&priv->connection); priv->connection = g_object_ref (connection); priv->id_on_bus = g_dbus_connection_register_object (connection, G_PASTE_DAEMON_OBJECT_PATH, priv->g_paste_daemon_dbus_info->interfaces[0], &priv->g_paste_daemon_dbus_vtable, g_object_ref (self), g_paste_daemon_unregister_object, error); if (!priv->id_on_bus) return FALSE; gulong *c_signals = priv->c_signals; c_signals[C_TRACK] = g_signal_connect_swapped (priv->settings, "track", G_CALLBACK (g_paste_daemon_tracking), self); c_signals[C_UPDATE] = g_signal_connect_swapped (priv->history, "update", G_CALLBACK (g_paste_daemon_on_history_update), self); c_signals[C_SWITCH] = g_signal_connect_swapped (priv->history, "switch", G_CALLBACK (g_paste_daemon_on_history_switch), priv); priv->registered = TRUE; g_source_set_name_by_id (g_timeout_add_seconds (1, _g_paste_daemon_changed, self), "[GPaste] Startup - changed"); return TRUE; } static void g_paste_daemon_class_init (GPasteDaemonClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_daemon_dispose; G_PASTE_BUS_OBJECT_CLASS (klass)->register_on_connection = g_paste_daemon_register_on_connection; /** * GPasteDaemon::reexecute-self: * @gpaste_daemon: the object on which the signal was emitted * * The "reexecute-self" signal is emitted when the daemon is about * to reexecute itself into a new freshly spawned daemon */ signals[REEXECUTE_SELF] = g_signal_new ("reexecute-self", G_PASTE_TYPE_DAEMON, G_SIGNAL_RUN_LAST, 0, /* class offset */ NULL, /* accumulator */ NULL, /* accumulator data */ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); } static void on_screensaver_client_ready (GObject *source_object G_GNUC_UNUSED, GAsyncResult *res, gpointer user_data) { GPasteDaemonPrivate *priv = user_data; GPasteScreensaverClient *screensaver = priv->screensaver = g_paste_screensaver_client_new_finish (res, NULL); if (screensaver) { priv->c_signals[C_ACTIVE_CHANGED] = g_signal_connect_swapped (priv->screensaver, "active-changed", G_CALLBACK (g_paste_daemon_on_screensaver_active_changed), priv); } } static void on_shell_client_ready (GObject *source_object G_GNUC_UNUSED, GAsyncResult *res, gpointer user_data) { GPasteDaemon *self = user_data; GPasteDaemonPrivate *priv = g_paste_daemon_get_instance_private (self); g_autoptr (GPasteGnomeShellClient) shell_client = g_paste_gnome_shell_client_new_finish (res, NULL); g_paste_screensaver_client_new (on_screensaver_client_ready, priv); priv->keybinder = g_paste_keybinder_new (priv->settings, shell_client); g_paste_daemon_activate_default_keybindings (self); } static void g_paste_daemon_init (GPasteDaemon *self) { GPasteDaemonPrivate *priv = g_paste_daemon_get_instance_private (self); GDBusInterfaceVTable *vtable = &priv->g_paste_daemon_dbus_vtable; priv->id_on_bus = 0; priv->g_paste_daemon_dbus_info = g_dbus_node_info_new_for_xml (G_PASTE_DAEMON_INTERFACE, NULL); /* Error */ vtable->method_call = g_paste_daemon_dbus_method_call; vtable->get_property = g_paste_daemon_dbus_get_property; vtable->set_property = NULL; GPasteSettings *settings = priv->settings = g_paste_settings_new (); GPasteHistory *history = priv->history = g_paste_history_new (settings); GPasteClipboardsManager *clipboards_manager = priv->clipboards_manager = g_paste_clipboards_manager_new (history, settings); g_autoptr (GPasteClipboard) clipboard = g_paste_clipboard_new (GDK_SELECTION_CLIPBOARD, settings); g_autoptr (GPasteClipboard) primary = g_paste_clipboard_new (GDK_SELECTION_PRIMARY, settings); g_paste_clipboards_manager_add_clipboard (clipboards_manager, clipboard); g_paste_clipboards_manager_add_clipboard (clipboards_manager, primary); g_paste_clipboards_manager_activate (clipboards_manager); g_paste_history_load (history, NULL); g_paste_gnome_shell_client_new (on_shell_client_ready, self); } /** * g_paste_daemon_new: * * Create a new instance of #GPasteDaemon * * Returns: a newly allocated #GPasteDaemon * free it with g_object_unref */ G_PASTE_VISIBLE GPasteDaemon * g_paste_daemon_new (void) { return G_PASTE_DAEMON (g_object_new (G_PASTE_TYPE_DAEMON, NULL)); } GPaste-3.18.6/src/libgpaste/daemon/gpaste-daemon.h000066400000000000000000000026761305131721400217050ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_DAEMON_H__ #define __G_PASTE_DAEMON_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_DAEMON (g_paste_daemon_get_type ()) G_PASTE_FINAL_TYPE (Daemon, daemon, DAEMON, GPasteBusObject) void g_paste_daemon_show_history (GPasteDaemon *self, GError **error); void g_paste_daemon_upload (GPasteDaemon *self, guint64 index); GPasteDaemon *g_paste_daemon_new (void); G_END_DECLS #endif /*__G_PASTE_DAEMON_H__*/ GPaste-3.18.6/src/libgpaste/daemon/gpaste-search-provider.c000066400000000000000000000345771305131721400235370ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include #include #include struct _GPasteSearchProvider { GPasteBusObject parent_instance; }; typedef struct { GDBusConnection *connection; guint64 id_on_bus; gboolean registered; GPasteClient *client; GDBusNodeInfo *g_paste_search_provider_dbus_info; GDBusInterfaceVTable g_paste_search_provider_dbus_vtable; } GPasteSearchProviderPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteSearchProvider, g_paste_search_provider, G_PASTE_TYPE_BUS_OBJECT) static char * g_paste_dbus_get_as_result (GVariant *variant) { guint64 _len; g_autofree const gchar **r = g_variant_get_strv (variant, &_len); return g_strjoinv (" ", (gchar **) r); } static char * _g_paste_dbus_get_as_result (GVariant *parameters) { GVariantIter parameters_iter; g_variant_iter_init (¶meters_iter, parameters); g_autoptr (GVariant) variant = g_variant_iter_next_value (¶meters_iter); return g_paste_dbus_get_as_result (variant); } static guint64 * _g_paste_dbus_get_as_result_as_at (GVariant *parameters, guint64 *len) { GVariantIter parameters_iter; g_variant_iter_init (¶meters_iter, parameters); g_autoptr (GVariant) variant = g_variant_iter_next_value (¶meters_iter); guint64 _len; g_autofree const gchar **r = g_variant_get_strv (variant, &_len); guint64 *indexes = g_malloc (_len * sizeof (guint64)); for (guint64 i = 0; i < _len; ++i) indexes[i] = g_ascii_strtoull (r[i], NULL, 0); if (len) *len = _len; return indexes; } /****************/ /* DBus Mathods */ /****************/ static void on_search_ready (GObject *source_object G_GNUC_UNUSED, GAsyncResult *res, gpointer user_data) { g_autofree gpointer *data = (gpointer *) user_data; GPasteClient *client = data[0]; GDBusMethodInvocation *invocation = data[1]; guint64 hits; g_autofree guint64 *r = g_paste_client_search_finish (client, res, &hits, NULL); /* Error */ g_auto (GStrv) results = g_new (char *, hits + 1); for (guint64 i = 0; i < hits; ++i) results[i] = g_strdup_printf ("%" G_GUINT64_FORMAT, r[i]); results[hits] = NULL; GVariant *ans = g_variant_new_strv ((const char * const *) results, hits); g_dbus_method_invocation_return_value (invocation, g_variant_new_tuple (&ans, 1)); } static gboolean _do_search (GPasteSearchProviderPrivate *priv G_GNUC_UNUSED, gchar *search, GDBusMethodInvocation *invocation) { if (strlen (search) < 3 || !priv->client) { GVariant *ans = g_variant_new_strv (NULL, 0); g_dbus_method_invocation_return_value (invocation, g_variant_new_tuple (&ans, 1)); } else { gpointer *data = g_new (gpointer, 2); data[0] = priv->client; data[1] = invocation; g_paste_client_search (priv->client, search, on_search_ready, data); } return TRUE; } static gboolean g_paste_search_provider_private_get_initial_result_set (GPasteSearchProviderPrivate *priv, GDBusMethodInvocation *invocation, GVariant *parameters) { g_autofree gchar *search = _g_paste_dbus_get_as_result (parameters); return _do_search (priv, search, invocation); } static gboolean g_paste_search_provider_private_get_subsearch_result_set (GPasteSearchProviderPrivate *priv, GDBusMethodInvocation *invocation, GVariant *parameters) { GVariantIter parameters_iter; g_variant_iter_init (¶meters_iter, parameters); G_GNUC_UNUSED g_autoptr (GVariant) old_results = g_variant_iter_next_value (¶meters_iter); g_autoptr (GVariant) variant = g_variant_iter_next_value (¶meters_iter); g_autofree gchar *search = g_paste_dbus_get_as_result (variant); return _do_search (priv, search, invocation); } static void append_dict_entry (GVariantBuilder *dict, const gchar *key, const gchar *value) { g_variant_builder_add_value (dict, g_variant_new_dict_entry (g_variant_new_string (key), g_variant_new_variant (g_variant_new_string (value)))); } typedef struct { GPasteClient *client; GDBusMethodInvocation *invocation; guint64 *indexes; } GetResultMetasData; static void on_elements_ready (GObject *source_object G_GNUC_UNUSED, GAsyncResult *res, gpointer user_data) { g_autofree GetResultMetasData *data = user_data; GPasteClient *client = data->client; g_autofree guint64 *indexes = data->indexes; g_auto (GVariantBuilder) builder; g_variant_builder_init (&builder, (GVariantType *) "aa{sv}"); g_auto (GStrv) results = g_paste_client_get_elements_finish (client, res, NULL); /* Error */ for (guint64 i = 0; results[i]; ++i) { g_auto (GVariantBuilder) dict; g_autofree gchar *index = g_strdup_printf ("%" G_GUINT64_FORMAT, indexes[i]); g_autofree gchar *result = g_paste_util_replace (results[i], "\n", " "); g_variant_builder_init (&dict, G_VARIANT_TYPE_VARDICT); append_dict_entry (&dict, "id", index); append_dict_entry (&dict, "name", result); append_dict_entry (&dict, "gicon", "gtk-edit-paste"); g_variant_builder_add_value (&builder, g_variant_builder_end (&dict)); } GVariant *ans = g_variant_builder_end (&builder); g_dbus_method_invocation_return_value (data->invocation, g_variant_new_tuple (&ans, 1)); } static gboolean g_paste_search_provider_private_get_result_metas (GPasteSearchProviderPrivate *priv, GDBusMethodInvocation *invocation, GVariant *parameters) { guint64 len; guint64 *indexes = _g_paste_dbus_get_as_result_as_at (parameters, &len); if (!len) { g_free (indexes); return FALSE; } GetResultMetasData *data = g_new (GetResultMetasData, 1); data->client = priv->client; data->invocation = invocation; data->indexes = indexes; g_paste_client_get_elements (priv->client, indexes, len, on_elements_ready, data); return TRUE; } static gboolean g_paste_search_provider_private_activate_result (GPasteSearchProviderPrivate *priv G_GNUC_UNUSED, GVariant *parameters) { GVariantIter parameters_iter; g_variant_iter_init (¶meters_iter, parameters); g_autoptr (GVariant) indexv = g_variant_iter_next_value (¶meters_iter); G_GNUC_UNUSED g_autoptr (GVariant) terms = g_variant_iter_next_value (¶meters_iter); G_GNUC_UNUSED g_autoptr (GVariant) timestamp = g_variant_iter_next_value (¶meters_iter); guint64 index = g_ascii_strtoull (g_variant_get_string (indexv, NULL), NULL, 0); g_paste_client_select (priv->client, index, NULL, NULL); return FALSE; } static gboolean g_paste_search_provider_private_launch_search (GPasteSearchProviderPrivate *priv G_GNUC_UNUSED, GVariant *parameters G_GNUC_UNUSED) { GVariantIter parameters_iter; g_variant_iter_init (¶meters_iter, parameters); g_autoptr (GVariant) searchv = g_variant_iter_next_value (¶meters_iter); G_GNUC_UNUSED g_autoptr (GVariant) timestamp = g_variant_iter_next_value (¶meters_iter); g_autofree gchar *search = g_paste_dbus_get_as_result (searchv); g_paste_util_activate_ui ("search", g_variant_new_string (search)); return FALSE; } static void g_paste_search_provider_dbus_method_call (GDBusConnection *connection G_GNUC_UNUSED, const gchar *sender G_GNUC_UNUSED, const gchar *object_path G_GNUC_UNUSED, const gchar *interface_name G_GNUC_UNUSED, const gchar *method_name, GVariant *parameters, GDBusMethodInvocation *invocation, gpointer user_data) { GPasteSearchProvider *self = user_data; GPasteSearchProviderPrivate *priv = g_paste_search_provider_get_instance_private (self); gboolean async = FALSE; if (!g_strcmp0 (method_name, G_PASTE_SEARCH_PROVIDER_GET_INITIAL_RESULT_SET)) async = g_paste_search_provider_private_get_initial_result_set (priv, invocation, parameters); else if (!g_strcmp0 (method_name, G_PASTE_SEARCH_PROVIDER_GET_SUBSEARCH_RESULT_SET)) async = g_paste_search_provider_private_get_subsearch_result_set (priv, invocation, parameters); else if (!g_strcmp0 (method_name, G_PASTE_SEARCH_PROVIDER_GET_RESULT_METAS)) async = g_paste_search_provider_private_get_result_metas (priv, invocation, parameters); else if (!g_strcmp0 (method_name, G_PASTE_SEARCH_PROVIDER_ACTIVATE_RESULT)) async = g_paste_search_provider_private_activate_result (priv, parameters); else if (!g_strcmp0 (method_name, G_PASTE_SEARCH_PROVIDER_LAUNCH_SEARCH)) async = g_paste_search_provider_private_launch_search (priv, parameters); if (!async) g_dbus_method_invocation_return_value (invocation, NULL); } static void g_paste_search_provider_unregister_object (gpointer user_data) { g_autoptr (GPasteSearchProvider) self = G_PASTE_SEARCH_PROVIDER (user_data); GPasteSearchProviderPrivate *priv = g_paste_search_provider_get_instance_private (self); priv->registered = FALSE; } static void g_paste_search_provider_dispose (GObject *object) { GPasteSearchProviderPrivate *priv = g_paste_search_provider_get_instance_private (G_PASTE_SEARCH_PROVIDER (object)); if (priv->connection) { g_dbus_connection_unregister_object (priv->connection, priv->id_on_bus); g_clear_object (&priv->connection); g_dbus_node_info_unref (priv->g_paste_search_provider_dbus_info); g_clear_object (&priv->client); } G_OBJECT_CLASS (g_paste_search_provider_parent_class)->dispose (object); } static gboolean g_paste_search_provider_register_on_connection (GPasteBusObject *self, GDBusConnection *connection, GError **error) { GPasteSearchProviderPrivate *priv = g_paste_search_provider_get_instance_private (G_PASTE_SEARCH_PROVIDER (self)); g_clear_object (&priv->connection); priv->connection = g_object_ref (connection); priv->id_on_bus = g_dbus_connection_register_object (connection, G_PASTE_SEARCH_PROVIDER_OBJECT_PATH, priv->g_paste_search_provider_dbus_info->interfaces[0], &priv->g_paste_search_provider_dbus_vtable, g_object_ref (self), g_paste_search_provider_unregister_object, error); return (priv->registered = !!priv->id_on_bus); } static void g_paste_search_provider_class_init (GPasteSearchProviderClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_search_provider_dispose; G_PASTE_BUS_OBJECT_CLASS (klass)->register_on_connection = g_paste_search_provider_register_on_connection; } static void on_client_ready (GObject *source_object G_GNUC_UNUSED, GAsyncResult *res, gpointer user_data) { GPasteSearchProviderPrivate *priv = user_data; priv->client = g_paste_client_new_finish (res, NULL); /* Error */ } static void g_paste_search_provider_init (GPasteSearchProvider *self) { GPasteSearchProviderPrivate *priv = g_paste_search_provider_get_instance_private (self); GDBusInterfaceVTable *vtable = &priv->g_paste_search_provider_dbus_vtable; priv->id_on_bus = 0; priv->g_paste_search_provider_dbus_info = g_dbus_node_info_new_for_xml (G_PASTE_SEARCH_PROVIDER_INTERFACE, NULL); /* Error */ vtable->method_call = g_paste_search_provider_dbus_method_call; vtable->get_property = NULL; vtable->set_property = NULL; g_paste_client_new (on_client_ready, priv); } /** * g_paste_search_provider_new: * * Create a new instance of #GPasteSearchProvider * * Returns: a newly allocated #GPasteSearchProvider * free it with g_object_unref */ G_PASTE_VISIBLE GPasteBusObject * g_paste_search_provider_new (void) { return G_PASTE_BUS_OBJECT (g_object_new (G_PASTE_TYPE_SEARCH_PROVIDER, NULL)); } GPaste-3.18.6/src/libgpaste/daemon/gpaste-search-provider.h000066400000000000000000000024571305131721400235340ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_SEARCH_PROVIDER_H__ #define __G_PASTE_SEARCH_PROVIDER_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_SEARCH_PROVIDER (g_paste_search_provider_get_type ()) G_PASTE_FINAL_TYPE (SearchProvider, search_provider, SEARCH_PROVIDER, GPasteBusObject) GPasteBusObject *g_paste_search_provider_new (void); G_END_DECLS #endif /*__G_PASTE_SEARCH_PROVIDER_H__*/ GPaste-3.18.6/src/libgpaste/gnome-shell-client/000077500000000000000000000000001305131721400212205ustar00rootroot00000000000000GPaste-3.18.6/src/libgpaste/gnome-shell-client/gpaste-gnome-shell-client.c000066400000000000000000000421041305131721400263340ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2013-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include "gpaste-gdbus-macros.h" #include #define G_PASTE_GNOME_SHELL_OBJECT_PATH "/org/gnome/Shell" #define G_PASTE_GNOME_SHELL_INTERFACE_NAME "org.gnome.Shell" #define G_PASTE_GNOME_SHELL_GRAB_ACCELERATOR "GrabAccelerator" #define G_PASTE_GNOME_SHELL_GRAB_ACCELERATORS "GrabAccelerators" #define G_PASTE_GNOME_SHELL_UNGRAB_ACCELERATOR "UngrabAccelerator" #define G_PASTE_GNOME_SHELL_SIG_ACCELERATOR_ACTIVATED "AcceleratorActivated" #define G_PASTE_GNOME_SHELL_INTERFACE \ "" \ "" \ "" \ "" \ "" \ "" \ "" \ "" \ "" \ "" \ "" \ "" \ "" \ "" \ "" \ "" \ "" \ "" \ "" \ "" \ "" struct _GPasteGnomeShellClient { GDBusProxy parent_instance; }; G_DEFINE_TYPE (GPasteGnomeShellClient, g_paste_gnome_shell_client, G_TYPE_DBUS_PROXY) enum { ACCELERATOR_ACTIVATED, LAST_SIGNAL }; static guint64 signals[LAST_SIGNAL] = { 0 }; /*******************/ /* Methods / Async */ /*******************/ #define DBUS_CALL_ONE_PARAM_ASYNC(method, param_type, param_name) \ DBUS_CALL_ONE_PARAM_ASYNC_BASE (GNOME_SHELL_CLIENT, param_type, param_name, G_PASTE_GNOME_SHELL_##method) #define DBUS_CALL_ONE_PARAMV_ASYNC(method, paramv) \ DBUS_CALL_ONE_PARAMV_ASYNC_BASE (GNOME_SHELL_CLIENT, paramv, G_PASTE_GNOME_SHELL_##method) #define DBUS_CALL_TWO_PARAMS_ASYNC(method, params) \ DBUS_CALL_TWO_PARAMS_ASYNC_BASE (GNOME_SHELL_CLIENT, params, G_PASTE_GNOME_SHELL_##method) /****************************/ /* Methods / Async - Finish */ /****************************/ #define DBUS_ASYNC_FINISH_RET_BOOL \ DBUS_ASYNC_FINISH_RET_BOOL_BASE (GNOME_SHELL_CLIENT) #define DBUS_ASYNC_FINISH_RET_AU \ DBUS_ASYNC_FINISH_RET_AU_BASE (GNOME_SHELL_CLIENT, NULL) #define DBUS_ASYNC_FINISH_RET_UINT32 \ DBUS_ASYNC_FINISH_RET_UINT32_BASE (GNOME_SHELL_CLIENT) /********************************/ /* Methods / Sync - With return */ /********************************/ #define DBUS_CALL_ONE_PARAM_RET_BOOL(method, param_type, param_name) \ DBUS_CALL_ONE_PARAM_RET_BOOL_BASE (GNOME_SHELL_CLIENT, param_type, param_name, G_PASTE_GNOME_SHELL_##method) #define DBUS_CALL_ONE_PARAMV_RET_AU(method, paramv) \ DBUS_CALL_ONE_PARAMV_RET_AU_BASE (GNOME_SHELL_CLIENT, G_PASTE_GNOME_SHELL_##method, paramv, NULL) #define DBUS_CALL_TWO_PARAMS_RET_UINT32(method, params) \ DBUS_CALL_TWO_PARAMS_RET_UINT32_BASE (GNOME_SHELL_CLIENT, params, G_PASTE_GNOME_SHELL_##method) /******************/ /* Methods / Sync */ /******************/ /** * g_paste_gnome_shell_client_grab_accelerator_sync: * @self: a #GPasteGnomeShellClient instance * @accelerator: a #GPasteGnomeShellAccelerator instance * @error: a #GError * * Grab a keybinding * * Returns: the action id corresponding */ G_PASTE_VISIBLE guint32 g_paste_gnome_shell_client_grab_accelerator_sync (GPasteGnomeShellClient *self, GPasteGnomeShellAccelerator accelerator, GError **error) { GVariant *accel[] = { g_variant_new_string (accelerator.accelerator), g_variant_new_uint32 (accelerator.flags) }; DBUS_CALL_TWO_PARAMS_RET_UINT32 (GRAB_ACCELERATOR, accel); } /** * g_paste_gnome_shell_client_grab_accelerators_sync: * @self: a #GPasteGnomeShellClient instance * @accelerators: (array): an array of #GPasteGnomeShellAccelerator instances * @error: a #GError * * Grab some keybindings * * Returns: the action ids corresponding */ G_PASTE_VISIBLE guint32 * g_paste_gnome_shell_client_grab_accelerators_sync (GPasteGnomeShellClient *self, GPasteGnomeShellAccelerator *accelerators, GError **error) { g_auto (GVariantBuilder) builder; guint64 n_accelerators = 0; g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY); for (GPasteGnomeShellAccelerator *accelerator = &accelerators[0]; accelerator->accelerator; accelerator = &accelerators[++n_accelerators]) { g_variant_builder_open (&builder, G_VARIANT_TYPE_TUPLE); g_variant_builder_add_value (&builder, g_variant_new_string (accelerator->accelerator)); g_variant_builder_add_value (&builder, g_variant_new_uint32 (accelerator->flags)); g_variant_builder_close (&builder); } GVariant *array = g_variant_builder_end (&builder); DBUS_CALL_ONE_PARAMV_RET_AU (GRAB_ACCELERATORS, array); } /** * g_paste_gnome_shell_client_ungrab_accelerator_sync: * @self: a #GPasteGnomeShellClient instance * @action: the action id corresponding to the keybinding * @error: a #GError * * Ungrab a keybinding * * Returns: whether the ungrab was succesful or not */ G_PASTE_VISIBLE gboolean g_paste_gnome_shell_client_ungrab_accelerator_sync (GPasteGnomeShellClient *self, guint32 action, GError **error) { DBUS_CALL_ONE_PARAM_RET_BOOL (UNGRAB_ACCELERATOR, uint32, action); } /*******************/ /* Methods / Async */ /*******************/ /** * g_paste_gnome_shell_client_grab_accelerator: * @self: a #GPasteGnomeShellClient instance * @accelerator: a #GPasteGnomeShellAccelerator instance * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Grab a keybinding * * Returns: */ G_PASTE_VISIBLE void g_paste_gnome_shell_client_grab_accelerator (GPasteGnomeShellClient *self, GPasteGnomeShellAccelerator accelerator, GAsyncReadyCallback callback, gpointer user_data) { GVariant *accel[] = { g_variant_new_string (accelerator.accelerator), g_variant_new_uint32 (accelerator.flags) }; DBUS_CALL_TWO_PARAMS_ASYNC (GRAB_ACCELERATOR, accel); } /** * g_paste_gnome_shell_client_grab_accelerators: * @self: a #GPasteGnomeShellClient instance * @accelerators: (array): an array of #GPasteGnomeShellAccelerator instances * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Grab some keybindings * * Returns: */ G_PASTE_VISIBLE void g_paste_gnome_shell_client_grab_accelerators (GPasteGnomeShellClient *self, GPasteGnomeShellAccelerator *accelerators, GAsyncReadyCallback callback, gpointer user_data) { g_auto (GVariantBuilder) builder; guint64 n_accelerators = 0; g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY); for (GPasteGnomeShellAccelerator *accelerator = &accelerators[0]; accelerator->accelerator; accelerator = &accelerators[++n_accelerators]) { g_variant_builder_open (&builder, G_VARIANT_TYPE_TUPLE); g_variant_builder_add_value (&builder, g_variant_new_string (accelerator->accelerator)); g_variant_builder_add_value (&builder, g_variant_new_uint32 (accelerator->flags)); g_variant_builder_close (&builder); } GVariant *array = g_variant_builder_end (&builder); DBUS_CALL_ONE_PARAMV_ASYNC (GRAB_ACCELERATORS, array); } /** * g_paste_gnome_shell_client_ungrab_accelerator: * @self: a #GPasteGnomeShellClient instance * @action: the action id corresponding to the keybinding * @callback: (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't * care about the result of the method invocation. * @user_data: (nullable): The data to pass to @callback. * * Ungrab a keybinding * * Returns: */ G_PASTE_VISIBLE void g_paste_gnome_shell_client_ungrab_accelerator (GPasteGnomeShellClient *self, guint32 action, GAsyncReadyCallback callback, gpointer user_data) { DBUS_CALL_ONE_PARAM_ASYNC (UNGRAB_ACCELERATOR, uint32, action); } /****************************/ /* Methods / Async - Finish */ /****************************/ /** * g_paste_gnome_shell_client_grab_accelerator_finish: * @self: a #GPasteGnomeShellClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Grab a keybinding * * Returns: the action id corresultponding */ G_PASTE_VISIBLE guint32 g_paste_gnome_shell_client_grab_accelerator_finish (GPasteGnomeShellClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_RET_UINT32; } /** * g_paste_gnome_shell_client_grab_accelerators_finish: * @self: a #GPasteGnomeShellClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Grab some keybindings * * Returns: the action ids corresultponding */ G_PASTE_VISIBLE guint32 * g_paste_gnome_shell_client_grab_accelerators_finish (GPasteGnomeShellClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_RET_AU; } /** * g_paste_gnome_shell_client_ungrab_accelerator_finish: * @self: a #GPasteGnomeShellClient instance * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to the async call. * @error: a #GError * * Ungrab a keybinding * * Returns: whether the ungrab was succesful or not */ G_PASTE_VISIBLE gboolean g_paste_gnome_shell_client_ungrab_accelerator_finish (GPasteGnomeShellClient *self, GAsyncResult *result, GError **error) { DBUS_ASYNC_FINISH_RET_BOOL; } static void g_paste_gnome_shell_client_g_signal (GDBusProxy *proxy, const gchar *sender_name G_GNUC_UNUSED, const gchar *signal_name, GVariant *parameters) { GPasteGnomeShellClient *self = G_PASTE_GNOME_SHELL_CLIENT (proxy); if (!g_strcmp0 (signal_name, G_PASTE_GNOME_SHELL_SIG_ACCELERATOR_ACTIVATED)) { GVariantIter params_iter; g_variant_iter_init (¶ms_iter, parameters); g_autoptr (GVariant) action = g_variant_iter_next_value (¶ms_iter); /* consume the params but don't use them */ G_GNUC_UNUSED g_autoptr (GVariant) params = g_variant_iter_next_value (¶ms_iter); g_signal_emit (self, signals[ACCELERATOR_ACTIVATED], 0, /* detail */ g_variant_get_uint32 (action), NULL); } } static void g_paste_gnome_shell_client_class_init (GPasteGnomeShellClientClass *klass G_GNUC_UNUSED) { G_DBUS_PROXY_CLASS (klass)->g_signal = g_paste_gnome_shell_client_g_signal; /** * GPasteGnomeShellClient::accelerator-activated: * @gnome_shell: the object on which the signal was emitted * @id: the id of the activated accelerator * * The "accelerator-activated" signal is emitted when gnome-shell notifies us * that an accelerator has been pressed. */ signals[ACCELERATOR_ACTIVATED] = g_signal_new ("accelerator-activated", G_PASTE_TYPE_GNOME_SHELL_CLIENT, G_SIGNAL_RUN_LAST, 0, /* class offset */ NULL, /* accumulator */ NULL, /* accumulator data */ g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT); } static void g_paste_gnome_shell_client_init (GPasteGnomeShellClient *self) { GDBusProxy *proxy = G_DBUS_PROXY (self); g_autoptr (GDBusNodeInfo) gnome_shell_dbus_info = g_dbus_node_info_new_for_xml (G_PASTE_GNOME_SHELL_INTERFACE, NULL); /* Error */ g_dbus_proxy_set_interface_info (proxy, gnome_shell_dbus_info->interfaces[0]); } /** * g_paste_gnome_shell_client_new_sync: * @error: Return location for error or %NULL. * * Create a new instance of #GPasteGnomeShellClient * * Returns: a newly allocated #GPasteGnomeShellClient * free it with g_object_unref */ G_PASTE_VISIBLE GPasteGnomeShellClient * g_paste_gnome_shell_client_new_sync (GError **error) { CUSTOM_PROXY_NEW (GNOME_SHELL_CLIENT, GNOME_SHELL, G_PASTE_GNOME_SHELL_BUS_NAME); } /** * g_paste_gnome_shell_client_new: * @callback: Callback function to invoke when the proxy is ready. * @user_data: User data to pass to @callback. * * Create a new instance of #GPasteGnomeShellClient * * Returns: */ G_PASTE_VISIBLE void g_paste_gnome_shell_client_new (GAsyncReadyCallback callback, gpointer user_data) { CUSTOM_PROXY_NEW_ASYNC (GNOME_SHELL_CLIENT, GNOME_SHELL, G_PASTE_GNOME_SHELL_BUS_NAME); } /** * g_paste_gnome_shell_client_new_finsh: * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback function passed to the async ctor. * @error: Return location for error or %NULL. * * Create a new instance of #GPasteGnomeShellClient * * Returns: a newly allocated #GPasteGnomeShellClient * free it with g_object_unref */ G_PASTE_VISIBLE GPasteGnomeShellClient * g_paste_gnome_shell_client_new_finish (GAsyncResult *result, GError **error) { CUSTOM_PROXY_NEW_FINISH (GNOME_SHELL_CLIENT); } GPaste-3.18.6/src/libgpaste/gnome-shell-client/gpaste-gnome-shell-client.h000066400000000000000000000154501305131721400263450ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2013-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_GNOME_SHELL_CLIENT_H__ #define __G_PASTE_GNOME_SHELL_CLIENT_H__ #include G_BEGIN_DECLS #define G_PASTE_GNOME_SHELL_BUS_NAME "org.gnome.Shell" /* ShellActionMode stolen from gnome-shell */ /** * GPasteGnomeShellActionMode: * @G_PASTE_GNOME_SHELL_ACTION_MODE_NONE: block action * @G_PASTE_GNOME_SHELL_ACTION_MODE_NORMAL: allow action when in window mode, * e.g. when the focus is in an application window * @G_PASTE_GNOME_SHELL_ACTION_MODE_OVERVIEW: allow action while the overview * is active * @G_PASTE_GNOME_SHELL_ACTION_MODE_LOCK_SCREEN: allow action when the screen * is locked, e.g. when the screen shield is shown * @G_PASTE_GNOME_SHELL_ACTION_MODE_UNLOCK_SCREEN: allow action in the unlock * dialog * @G_PASTE_GNOME_SHELL_ACTION_MODE_LOGIN_SCREEN: allow action in the login screen * @G_PASTE_GNOME_SHELL_ACTION_MODE_SYSTEM_MODAL: allow action when a system modal * dialog (e.g. authentification or session dialogs) is open * @G_PASTE_GNOME_SHELL_ACTION_MODE_LOOKING_GLASS: allow action in looking glass * @G_PASTE_GNOME_SHELL_ACTION_MODE_POPUP: allow action while a shell menu is open * @G_PASTE_GNOME_SHELL_ACTION_MODE_ALL: always allow action * * Controls in which GNOME Shell states an action (like keybindings and gestures) * should be handled. */ typedef enum { G_PASTE_GNOME_SHELL_ACTION_MODE_NONE = 0, G_PASTE_GNOME_SHELL_ACTION_MODE_NORMAL = 1 << 0, G_PASTE_GNOME_SHELL_ACTION_MODE_OVERVIEW = 1 << 1, G_PASTE_GNOME_SHELL_ACTION_MODE_LOCK_SCREEN = 1 << 2, G_PASTE_GNOME_SHELL_ACTION_MODE_UNLOCK_SCREEN = 1 << 3, G_PASTE_GNOME_SHELL_ACTION_MODE_LOGIN_SCREEN = 1 << 4, G_PASTE_GNOME_SHELL_ACTION_MODE_SYSTEM_MODAL = 1 << 5, G_PASTE_GNOME_SHELL_ACTION_MODE_LOOKING_GLASS = 1 << 6, G_PASTE_GNOME_SHELL_ACTION_MODE_POPUP = 1 << 7, G_PASTE_GNOME_SHELL_ACTION_MODE_ALL = ~0, } GPasteGnomeShellActionMode; #define G_PASTE_TYPE_GNOME_SHELL_CLIENT (g_paste_gnome_shell_client_get_type ()) typedef struct { const gchar *accelerator; GPasteGnomeShellActionMode flags; } GPasteGnomeShellAccelerator; #define G_PASTE_GNOME_SHELL_ACCELERATOR(accelerator) ((GPasteGnomeShellAccelerator) {accelerator, G_PASTE_GNOME_SHELL_ACTION_MODE_ALL}) G_PASTE_FINAL_TYPE (GnomeShellClient, gnome_shell_client, GNOME_SHELL_CLIENT, GDBusProxy) /*******************/ /* Methods / Sync */ /*******************/ guint32 g_paste_gnome_shell_client_grab_accelerator_sync (GPasteGnomeShellClient *self, GPasteGnomeShellAccelerator accelerator, GError **error); guint32 *g_paste_gnome_shell_client_grab_accelerators_sync (GPasteGnomeShellClient *self, GPasteGnomeShellAccelerator *accelerators, GError **error); gboolean g_paste_gnome_shell_client_ungrab_accelerator_sync (GPasteGnomeShellClient *self, guint32 action, GError **error); /********************/ /* Methods / Async */ /********************/ void g_paste_gnome_shell_client_grab_accelerator (GPasteGnomeShellClient *self, GPasteGnomeShellAccelerator accelerator, GAsyncReadyCallback callback, gpointer user_data); void g_paste_gnome_shell_client_grab_accelerators (GPasteGnomeShellClient *self, GPasteGnomeShellAccelerator *accelerators, GAsyncReadyCallback callback, gpointer user_data); void g_paste_gnome_shell_client_ungrab_accelerator (GPasteGnomeShellClient *self, guint32 action, GAsyncReadyCallback callback, gpointer user_data); /*****************************/ /* Methods / Async - Finish */ /*****************************/ guint32 g_paste_gnome_shell_client_grab_accelerator_finish (GPasteGnomeShellClient *self, GAsyncResult *result, GError **error); guint32 *g_paste_gnome_shell_client_grab_accelerators_finish (GPasteGnomeShellClient *self, GAsyncResult *result, GError **error); gboolean g_paste_gnome_shell_client_ungrab_accelerator_finish (GPasteGnomeShellClient *self, GAsyncResult *result, GError **error); /****************/ /* Constructors */ /****************/ GPasteGnomeShellClient *g_paste_gnome_shell_client_new_sync (GError **error); void g_paste_gnome_shell_client_new (GAsyncReadyCallback callback, gpointer user_data); GPasteGnomeShellClient *g_paste_gnome_shell_client_new_finish (GAsyncResult *result, GError **error); G_END_DECLS #endif /*__G_PASTE_GNOME_SHELL_CLIENT_H__*/ GPaste-3.18.6/src/libgpaste/gpaste-gdbus-defines.h000066400000000000000000000364731305131721400217200ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2012-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_GDBUS_DEFINES_H__ #define __G_PASTE_GDBUS_DEFINES_H__ #include G_BEGIN_DECLS #define G_PASTE_BUS_NAME "org.gnome.GPaste" #define G_PASTE_DAEMON_OBJECT_PATH "/org/gnome/GPaste" #define G_PASTE_DAEMON_INTERFACE_NAME "org.gnome.GPaste1" #define G_PASTE_DAEMON_ABOUT "About" #define G_PASTE_DAEMON_ADD "Add" #define G_PASTE_DAEMON_ADD_FILE "AddFile" #define G_PASTE_DAEMON_ADD_PASSWORD "AddPassword" #define G_PASTE_DAEMON_BACKUP_HISTORY "BackupHistory" #define G_PASTE_DAEMON_DELETE "Delete" #define G_PASTE_DAEMON_DELETE_HISTORY "DeleteHistory" #define G_PASTE_DAEMON_DELETE_PASSWORD "DeletePassword" #define G_PASTE_DAEMON_EMPTY_HISTORY "EmptyHistory" #define G_PASTE_DAEMON_GET_ELEMENT "GetElement" #define G_PASTE_DAEMON_GET_ELEMENT_KIND "GetElementKind" #define G_PASTE_DAEMON_GET_ELEMENTS "GetElements" #define G_PASTE_DAEMON_GET_HISTORY "GetHistory" #define G_PASTE_DAEMON_GET_HISTORY_NAME "GetHistoryName" #define G_PASTE_DAEMON_GET_HISTORY_SIZE "GetHistorySize" #define G_PASTE_DAEMON_GET_RAW_ELEMENT "GetRawElement" #define G_PASTE_DAEMON_GET_RAW_HISTORY "GetRawHistory" #define G_PASTE_DAEMON_LIST_HISTORIES "ListHistories" #define G_PASTE_DAEMON_MERGE "Merge" #define G_PASTE_DAEMON_ON_EXTENSION_STATE_CHANGED "OnExtensionStateChanged" #define G_PASTE_DAEMON_REEXECUTE "Reexecute" #define G_PASTE_DAEMON_RENAME_PASSWORD "RenamePassword" #define G_PASTE_DAEMON_REPLACE "Replace" #define G_PASTE_DAEMON_SEARCH "Search" #define G_PASTE_DAEMON_SELECT "Select" #define G_PASTE_DAEMON_SET_PASSWORD "SetPassword" #define G_PASTE_DAEMON_SHOW_HISTORY "ShowHistory" #define G_PASTE_DAEMON_SWITCH_HISTORY "SwitchHistory" #define G_PASTE_DAEMON_TRACK "Track" #define G_PASTE_DAEMON_UPLOAD "Upload" #define G_PASTE_DAEMON_SIG_DELETE_HISTORY "DeleteHistory" #define G_PASTE_DAEMON_SIG_EMPTY_HISTORY "EmptyHistory" #define G_PASTE_DAEMON_SIG_SHOW_HISTORY "ShowHistory" #define G_PASTE_DAEMON_SIG_SWITCH_HISTORY "SwitchHistory" #define G_PASTE_DAEMON_SIG_TRACKING "Tracking" #define G_PASTE_DAEMON_SIG_UPDATE "Update" #define G_PASTE_DAEMON_PROP_ACTIVE "Active" #define G_PASTE_DAEMON_PROP_VERSION "Version" #define G_PASTE_DAEMON_INTERFACE \ "" \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ "" #define G_PASTE_SEARCH_PROVIDER_OBJECT_PATH "/org/gnome/GPaste/SearchProvider" #define G_PASTE_SEARCH_PROVIDER_INTERFACE_NAME "org.gnome.Shell.SearchProvider2" #define G_PASTE_SEARCH_PROVIDER_GET_INITIAL_RESULT_SET "GetInitialResultSet" #define G_PASTE_SEARCH_PROVIDER_GET_SUBSEARCH_RESULT_SET "GetSubsearchResultSet" #define G_PASTE_SEARCH_PROVIDER_GET_RESULT_METAS "GetResultMetas" #define G_PASTE_SEARCH_PROVIDER_ACTIVATE_RESULT "ActivateResult" #define G_PASTE_SEARCH_PROVIDER_LAUNCH_SEARCH "LaunchSearch" #define G_PASTE_SEARCH_PROVIDER_INTERFACE \ "" \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ " " \ "" G_END_DECLS #endif /*__G_PASTE_GDBUS_DEFINES_H__*/ GPaste-3.18.6/src/libgpaste/gpaste-gdbus-macros.h000066400000000000000000000445711305131721400215650ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2013-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_GDBUS_MACROS_H__ #define __G_PASTE_GDBUS_MACROS_H__ #include #include #include G_BEGIN_DECLS /***************/ /* Constructor */ /***************/ #define CUSTOM_PROXY_NEW_ASYNC(TYPE, BUS_ID, BUS_NAME) \ g_async_initable_new_async (G_PASTE_TYPE_##TYPE, \ G_PRIORITY_DEFAULT, \ NULL, /* cancellable */ \ callback, \ user_data, \ "g-bus-type", G_BUS_TYPE_SESSION, \ "g-flags", G_DBUS_PROXY_FLAGS_NONE, \ "g-name", BUS_NAME, \ "g-object-path", G_PASTE_##BUS_ID##_OBJECT_PATH, \ "g-interface-name", G_PASTE_##BUS_ID##_INTERFACE_NAME, \ NULL) #define CUSTOM_PROXY_NEW_FINISH(TYPE) \ g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL); \ g_return_val_if_fail (!error || !(*error), NULL); \ g_autoptr (GObject) source = g_async_result_get_source_object (result); \ g_assert (source); \ GObject *self = g_async_initable_new_finish (G_ASYNC_INITABLE (source), \ result, \ error); \ return (self) ? G_PASTE_##TYPE (self) : NULL; #define CUSTOM_PROXY_NEW(TYPE, BUS_ID, BUS_NAME) \ GInitable *self = g_initable_new (G_PASTE_TYPE_##TYPE, \ NULL, /* cancellable */ \ error, \ "g-bus-type", G_BUS_TYPE_SESSION, \ "g-flags", G_DBUS_PROXY_FLAGS_NONE, \ "g-name", BUS_NAME, \ "g-object-path", G_PASTE_##BUS_ID##_OBJECT_PATH, \ "g-interface-name", G_PASTE_##BUS_ID##_INTERFACE_NAME, \ NULL); \ return (self) ? G_PASTE_##TYPE (self) : NULL; /********************/ /* Methods / Common */ /********************/ #define DBUS_PREPARE_EXTRACTION \ GVariantIter result_iter; \ g_variant_iter_init (&result_iter, _result); \ g_autoptr (GVariant) variant = g_variant_iter_next_value (&result_iter) #define DBUS_RETURN(if_fail, extract_and_return_answer) \ if (!_result) \ return if_fail; \ extract_and_return_answer /*****************************/ /* Methods / Async / General */ /*****************************/ #define DBUS_CALL_ASYNC_FULL(TYPE_CHECKER, decl, method, params, n_params) \ g_return_if_fail (G_PASTE_IS_##TYPE_CHECKER (self)); \ decl; \ g_dbus_proxy_call (G_DBUS_PROXY(self), \ method, \ g_variant_new_tuple (params, n_params), \ G_DBUS_CALL_FLAGS_NONE, \ -1, \ NULL, /* cancellable */ \ callback, \ user_data) /**************************/ /* Methods / Async / Impl */ /**************************/ #define DBUS_CALL_NO_PARAM_ASYNC_BASE(TYPE_CHECKER, method) \ DBUS_CALL_ASYNC_FULL (TYPE_CHECKER, {}, method, NULL, 0) #define DBUS_CALL_ONE_PARAM_ASYNC_BASE(TYPE_CHECKER, param_type, param_name, method) \ DBUS_CALL_ASYNC_FULL (TYPE_CHECKER, GVariant *parameter = g_variant_new_##param_type (param_name), method, ¶meter, 1) #define DBUS_CALL_ONE_PARAMV_ASYNC_BASE(TYPE_CHECKER, paramv, method) \ DBUS_CALL_ASYNC_FULL (TYPE_CHECKER, {}, method, ¶mv, 1) #define DBUS_CALL_TWO_PARAMS_ASYNC_BASE(TYPE_CHECKER, params, method) \ DBUS_CALL_ASYNC_FULL (TYPE_CHECKER, {}, method, params, 2) #define DBUS_CALL_THREE_PARAMS_ASYNC_BASE(TYPE_CHECKER, params, method) \ DBUS_CALL_ASYNC_FULL (TYPE_CHECKER, {}, method, params, 3) /**************************************/ /* Methods / Async / General - Finish */ /**************************************/ #define DBUS_ASYNC_FINISH_FULL(guard, if_fail, extract_and_return_answer) \ guard; \ g_autoptr (GVariant) _result = g_dbus_proxy_call_finish (G_DBUS_PROXY (self), \ result, \ error); \ DBUS_RETURN (if_fail, extract_and_return_answer) #define DBUS_ASYNC_FINISH_WITH_RETURN(TYPE_CHECKER, if_fail, extract_and_return_answer) \ DBUS_ASYNC_FINISH_FULL (g_return_val_if_fail (G_PASTE_IS_##TYPE_CHECKER (self), if_fail); \ g_return_val_if_fail (G_IS_ASYNC_RESULT (result), if_fail); \ g_return_val_if_fail (!error || !(*error), if_fail), \ if_fail, \ DBUS_PREPARE_EXTRACTION; \ extract_and_return_answer) /***********************************/ /* Methods / Async / Impl - Finish */ /***********************************/ #define DBUS_ASYNC_FINISH_NO_RETURN_BASE(TYPE_CHECKER) \ DBUS_ASYNC_FINISH_FULL (g_return_if_fail (G_PASTE_IS_##TYPE_CHECKER (self)); \ g_return_if_fail (G_IS_ASYNC_RESULT (result)); \ g_return_if_fail (!error || !(*error)), ;, {}) #define DBUS_ASYNC_FINISH_RET_BOOL_BASE(TYPE_CHECKER) \ DBUS_ASYNC_FINISH_WITH_RETURN (TYPE_CHECKER, FALSE, return g_variant_get_boolean (variant)) #define DBUS_ASYNC_FINISH_RET_UINT64_BASE(TYPE_CHECKER) \ DBUS_ASYNC_FINISH_WITH_RETURN (TYPE_CHECKER, 0, return g_variant_get_uint64 (variant)) #define DBUS_ASYNC_FINISH_RET_UINT32_BASE(TYPE_CHECKER) \ DBUS_ASYNC_FINISH_WITH_RETURN (TYPE_CHECKER, 0, return g_variant_get_uint32 (variant)) #define DBUS_ASYNC_FINISH_RET_STRING_BASE(TYPE_CHECKER) \ DBUS_ASYNC_FINISH_WITH_RETURN (TYPE_CHECKER, NULL, return g_variant_dup_string (variant, NULL)) #define DBUS_ASYNC_FINISH_RET_STRV_BASE(TYPE_CHECKER) \ DBUS_ASYNC_FINISH_WITH_RETURN (TYPE_CHECKER, NULL, return g_variant_dup_strv (variant, NULL)) #define DBUS_ASYNC_FINISH_RET_AT_BASE(TYPE_CHECKER, len) \ DBUS_ASYNC_FINISH_WITH_RETURN (TYPE_CHECKER, NULL, return g_paste_util_get_dbus_at_result (variant, len)) #define DBUS_ASYNC_FINISH_RET_AU_BASE(TYPE_CHECKER, len) \ DBUS_ASYNC_FINISH_WITH_RETURN (TYPE_CHECKER, NULL, return g_paste_util_get_dbus_au_result (variant, len)) /****************************/ /* Methods / Sync / General */ /****************************/ #define DBUS_CALL_FULL(guard, decl, method, params, n_params, if_fail, extract_and_return_answer) \ guard; \ decl; \ g_autoptr (GVariant) _result = g_dbus_proxy_call_sync (G_DBUS_PROXY (self), \ method, \ g_variant_new_tuple (params, n_params), \ G_DBUS_CALL_FLAGS_NONE, \ -1, \ NULL, /* cancellable */ \ error); \ DBUS_RETURN (if_fail, extract_and_return_answer) /****************************************/ /* Methods / Sync / General - No return */ /****************************************/ #define DBUS_CALL_NO_RETURN_BASE(TYPE_CHECKER, decl, method, params, n_params) \ DBUS_CALL_FULL (g_return_if_fail (G_PASTE_IS_##TYPE_CHECKER (self)), decl, method, params, n_params, ;, {}) /******************************************/ /* Methods / Sync / General - With return */ /******************************************/ #define DBUS_CALL_WITH_RETURN_FULL_BASE(TYPE_CHECKER, decl, method, params, n_params, if_fail, variant_extract, pre_extract) \ DBUS_CALL_FULL (g_return_val_if_fail (G_PASTE_IS_##TYPE_CHECKER (self), if_fail), decl, method, params, n_params, if_fail, \ pre_extract; \ variant_extract) #define DBUS_CALL_WITH_RETURN_RAW_BASE(TYPE_CHECKER, decl, method, params, n_params, if_fail, variant_extract) \ DBUS_CALL_WITH_RETURN_FULL_BASE (TYPE_CHECKER, decl, method, params, n_params, if_fail, variant_extract, GVariant *variant = _result) #define DBUS_CALL_WITH_RETURN_BASE(TYPE_CHECKER, decl, method, params, n_params, if_fail, variant_extract) \ DBUS_CALL_WITH_RETURN_FULL_BASE (TYPE_CHECKER, decl, method, params, n_params, if_fail, variant_extract, DBUS_PREPARE_EXTRACTION) /*************************************/ /* Methods / Sync / Impl - No return */ /*************************************/ #define DBUS_CALL_NO_PARAM_NO_RETURN_BASE(TYPE_CHECKER, method) \ DBUS_CALL_NO_RETURN_BASE (TYPE_CHECKER, {}, method, NULL, 0) #define DBUS_CALL_ONE_PARAMV_NO_RETURN_BASE(TYPE_CHECKER, paramv, method) \ DBUS_CALL_NO_RETURN_BASE (TYPE_CHECKER, {}, method, ¶mv, 1) #define DBUS_CALL_ONE_PARAM_NO_RETURN_BASE(TYPE_CHECKER, param_type, param_name, method) \ DBUS_CALL_NO_RETURN_BASE (TYPE_CHECKER, GVariant *parameter = g_variant_new_##param_type (param_name), method, ¶meter, 1) #define DBUS_CALL_TWO_PARAMS_NO_RETURN_BASE(TYPE_CHECKER, params, method) \ DBUS_CALL_NO_RETURN_BASE (TYPE_CHECKER, {}, method, params, 2) #define DBUS_CALL_THREE_PARAMS_NO_RETURN_BASE(TYPE_CHECKER, params, method) \ DBUS_CALL_NO_RETURN_BASE (TYPE_CHECKER, {}, method, params, 3) /**************************************************/ /* Methods / Sync / Impl - With return - No param */ /**************************************************/ #define DBUS_CALL_NO_PARAM_BASE(TYPE_CHECKER, method, if_fail, variant_extract) \ DBUS_CALL_WITH_RETURN_BASE (TYPE_CHECKER, {}, method, NULL, 0, if_fail, variant_extract) #define DBUS_CALL_NO_PARAM_RET_STRING_BASE(TYPE_CHECKER, method) \ DBUS_CALL_NO_PARAM_BASE(TYPE_CHECKER, method, NULL, return g_variant_dup_string (variant, NULL)) \ #define DBUS_CALL_NO_PARAM_RET_STRV_BASE(TYPE_CHECKER, method) \ DBUS_CALL_NO_PARAM_BASE(TYPE_CHECKER, method, NULL, return g_variant_dup_strv (variant, NULL)) \ #define DBUS_CALL_ONE_PARAMV_RET_AT_BASE(TYPE_CHECKER, method, paramv, len) \ DBUS_CALL_WITH_RETURN_BASE(TYPE_CHECKER, {}, method, ¶mv, 1, NULL, return g_paste_util_get_dbus_at_result (variant, len)) #define DBUS_CALL_ONE_PARAMV_RET_AU_BASE(TYPE_CHECKER, method, paramv, len) \ DBUS_CALL_WITH_RETURN_BASE(TYPE_CHECKER, {}, method, ¶mv, 1, NULL, return g_paste_util_get_dbus_au_result (variant, len)) #define DBUS_CALL_ONE_PARAMV_RET_STRV_BASE(TYPE_CHECKER, method, paramv) \ DBUS_CALL_WITH_RETURN_BASE(TYPE_CHECKER, {}, method, ¶mv, 1, NULL, return g_variant_dup_strv (variant, NULL)) /******************************************************/ /* Methods / Sync / General - With return - One param */ /******************************************************/ #define DBUS_CALL_ONE_PARAM_RAW_BASE(TYPE_CHECKER, param_type, param_name, method, if_fail, variant_extract) \ DBUS_CALL_WITH_RETURN_RAW_BASE (TYPE_CHECKER, GVariant *parameter = g_variant_new_##param_type (param_name), method, ¶meter, 1, if_fail, variant_extract) #define DBUS_CALL_ONE_PARAM_BASE(TYPE_CHECKER, param_type, param_name, method, if_fail, variant_extract) \ DBUS_CALL_WITH_RETURN_BASE (TYPE_CHECKER, GVariant *parameter = g_variant_new_##param_type (param_name), method, ¶meter, 1, if_fail, variant_extract) /***************************************************/ /* Methods / Sync / Impl - With return - One param */ /***************************************************/ #define DBUS_CALL_ONE_PARAM_RET_BOOL_BASE(TYPE_CHECKER, param_type, param_name, method) \ DBUS_CALL_ONE_PARAM_BASE(TYPE_CHECKER, param_type, param_name, method, FALSE, return g_variant_get_boolean (variant)) #define DBUS_CALL_ONE_PARAM_RET_UINT64_BASE(TYPE_CHECKER, param_type, param_name, method) \ DBUS_CALL_ONE_PARAM_BASE(TYPE_CHECKER, param_type, param_name, method, 0, return g_variant_get_uint64 (variant)) #define DBUS_CALL_ONE_PARAM_RET_STRING_BASE(TYPE_CHECKER, param_type, param_name, method) \ DBUS_CALL_ONE_PARAM_BASE(TYPE_CHECKER, param_type, param_name, method, NULL, return g_variant_dup_string (variant, NULL /* length */)) #define DBUS_CALL_ONE_PARAM_RET_AT_BASE(TYPE_CHECKER, param_type, param_name, method, len) \ DBUS_CALL_ONE_PARAM_BASE(TYPE_CHECKER, param_type, param_name, method, NULL, return g_paste_util_get_dbus_at_result (variant, len)) /****************************************************/ /* Methods / Sync / Impl - With return - Two params */ /****************************************************/ #define DBUS_CALL_TWO_PARAMS_BASE(TYPE_CHECKER, params, method, if_fail, variant_extract) \ DBUS_CALL_WITH_RETURN_BASE (TYPE_CHECKER, {}, method, params, 2, if_fail, variant_extract) #define DBUS_CALL_TWO_PARAMS_RET_UINT64_BASE(TYPE_CHECKER, params, method) \ DBUS_CALL_TWO_PARAMS_BASE(TYPE_CHECKER, params, method, 0, return g_variant_get_uint64 (variant)) #define DBUS_CALL_TWO_PARAMS_RET_UINT32_BASE(TYPE_CHECKER, params, method) \ DBUS_CALL_TWO_PARAMS_BASE(TYPE_CHECKER, params, method, 0, return g_variant_get_uint32 (variant)) /************************/ /* Properties / Getters */ /************************/ #define DBUS_GET_PROPERTY_INIT(TYPE_CHECKER, property, _default) \ g_return_val_if_fail (G_PASTE_IS_##TYPE_CHECKER (self), _default); \ g_autoptr (GVariant) result = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (self), \ property); \ if (!result) \ return _default #define DBUS_GET_BOOLEAN_PROPERTY_BASE(TYPE_CHECKER, property) \ DBUS_GET_PROPERTY_INIT (TYPE_CHECKER, property, FALSE); \ return g_variant_get_boolean (result) #define DBUS_GET_STRING_PROPERTY_BASE(TYPE_CHECKER, property) \ DBUS_GET_PROPERTY_INIT (TYPE_CHECKER, property, NULL); \ return g_variant_dup_string (result, NULL) /************************/ /* Properties / Setters */ /************************/ #define DBUS_SET_GENERIC_PROPERTY_BASE(TYPE_CHECKER, iface, property, value, vtype) \ g_return_val_if_fail (G_PASTE_IS_##TYPE_CHECKER (self), FALSE); \ GVariant *prop[] = { \ g_variant_new_string (iface), \ g_variant_new_string (property), \ g_variant_new_variant (g_variant_new_##vtype (value)) \ }; \ g_autoptr (GVariant) result = g_dbus_proxy_call_sync (G_DBUS_PROXY (self), \ "org.freedesktop.DBus.Properties.Set", \ g_variant_new_tuple (prop, 3), \ G_DBUS_CALL_FLAGS_NONE, \ -1, \ NULL, /* cancellable */ \ error); \ return !!result #define DBUS_SET_BOOLEAN_PROPERTY_BASE(TYPE_CHECKER, iface, property, value) \ DBUS_SET_GENERIC_PROPERTY_BASE (TYPE_CHECKER, iface, property, value, boolean) G_END_DECLS #endif /*__G_PASTE_GDBUS_MACROS_H__*/ GPaste-3.18.6/src/libgpaste/gpaste-gsettings-keys.h000066400000000000000000000054701305131721400221520ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2012-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __GPASTE_GSETTINGS_KEYS_H__ #define __GPASTE_GSETTINGS_KEYS_H__ #include G_BEGIN_DECLS #define G_PASTE_SETTINGS_NAME "org.gnome.GPaste" #define G_PASTE_SHELL_SETTINGS_NAME "org.gnome.shell" #define G_PASTE_ELEMENT_SIZE_SETTING "element-size" #define G_PASTE_GROWING_LINES_SETTING "growing-lines" #define G_PASTE_HISTORY_NAME_SETTING "history-name" #define G_PASTE_IMAGES_SUPPORT_SETTING "images-support" #define G_PASTE_LAUNCH_UI_SETTING "launch-ui" #define G_PASTE_MAKE_PASSWORD_SETTING "make-password" #define G_PASTE_MAX_DISPLAYED_HISTORY_SIZE_SETTING "max-displayed-history-size" #define G_PASTE_MAX_HISTORY_SIZE_SETTING "max-history-size" #define G_PASTE_MAX_MEMORY_USAGE_SETTING "max-memory-usage" #define G_PASTE_MAX_TEXT_ITEM_SIZE_SETTING "max-text-item-size" #define G_PASTE_MIN_TEXT_ITEM_SIZE_SETTING "min-text-item-size" #define G_PASTE_POP_SETTING "pop" #define G_PASTE_PRIMARY_TO_HISTORY_SETTING "primary-to-history" #define G_PASTE_SAVE_HISTORY_SETTING "save-history" #define G_PASTE_SHOW_HISTORY_SETTING "show-history" #define G_PASTE_SYNC_CLIPBOARD_TO_PRIMARY_SETTING "sync-clipboard-to-primary" #define G_PASTE_SYNC_PRIMARY_TO_CLIPBOARD_SETTING "sync-primary-to-clipboard" #define G_PASTE_SYNCHRONIZE_CLIPBOARDS_SETTING "synchronize-clipboards" #define G_PASTE_TRACK_CHANGES_SETTING "track-changes" #define G_PASTE_TRACK_EXTENSION_STATE_SETTING "track-extension-state" #define G_PASTE_TRIM_ITEMS_SETTING "trim-items" #define G_PASTE_UPLOAD_SETTING "upload" #define G_PASTE_EXTENSION_ENABLED_SETTING "extension-enabled" #define G_PASTE_SHELL_ENABLED_EXTENSIONS_SETTING "enabled-extensions" G_END_DECLS #endif /*__GPASTE_GSETTINGS_KEYS_H__*/ GPaste-3.18.6/src/libgpaste/gpaste-macros.h000066400000000000000000000063531305131721400204570ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2013-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __GPASTE_MACROS_H__ #define __GPASTE_MACROS_H__ #include #include #include #include G_BEGIN_DECLS #ifdef G_HAVE_GNUC_VISIBILITY # define G_PASTE_VISIBLE __attribute__((visibility("default"))) #else # define G_PASTE_VISIBLE #endif #define G_PASTE_DERIVABLE_TYPE(TypeName, type_name, TYPE_NAME, ParentTypeName) \ G_PASTE_VISIBLE G_DECLARE_DERIVABLE_TYPE (GPaste##TypeName, g_paste_##type_name, G_PASTE, TYPE_NAME, ParentTypeName) #define G_PASTE_FINAL_TYPE(TypeName, type_name, TYPE_NAME, ParentTypeName) \ G_PASTE_VISIBLE G_DECLARE_FINAL_TYPE (GPaste##TypeName, g_paste_##type_name, G_PASTE, TYPE_NAME, ParentTypeName) #define G_PASTE_INIT_GETTEXT() \ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); \ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); \ textdomain (GETTEXT_PACKAGE) #define G_PASTE_INIT_APPLICATION_FULL(name, activate_cb) \ G_PASTE_INIT_GETTEXT (); \ gtk_init (&argc, &argv); \ g_object_set (gtk_settings_get_default (), "gtk-application-prefer-dark-theme", TRUE, NULL); \ GtkApplication *app = gtk_application_new ("org.gnome.GPaste." name, G_APPLICATION_FLAGS_NONE); \ GApplication *gapp = G_APPLICATION (app); \ g_autoptr (GError) error = NULL; \ G_APPLICATION_GET_CLASS (gapp)->activate = activate_cb; \ g_application_register (gapp, NULL, &error); \ if (error) \ { \ fprintf (stderr, "%s: %s\n", _("Failed to register the gtk application"), error->message); \ return EXIT_FAILURE; \ } #define G_PASTE_INIT_APPLICATION(name) \ G_PASTE_INIT_APPLICATION_FULL (name, NULL) G_END_DECLS #endif /*__GPASTE_MACROS_H__*/ GPaste-3.18.6/src/libgpaste/gpaste.h000066400000000000000000000065231305131721400171740ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #ifndef __G_PASTE_H__ #define __G_PASTE_H__ #define __G_PASTE_H_INSIDE__ /* Misc. macros */ #include /* Core GPaste Components */ #include #include #include #include #include #include #include #include /* GPasteUtil */ #include /* GPasteKeybinder */ #include #include #include #include #include #include #include #include #include /* GPasteBus */ #include #include #include /* GPasteBusObject */ #include /* GPasteDaemon */ #include /* GPasteSearchProvider */ #include /* GPasteClient */ #include /* GPasteGnomeShellClient */ #include /* GPasteScreensaverClient */ #include /* GPasteSettings */ #include #include /* GPasteSettingsUi */ #include #include #include /* GPasteApplet */ #include #include #include #include #include #include #include /* GPasteUi */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #undef __G_PASTE_H_INSIDE__ #endif /*__G_PASTE_H__*/ GPaste-3.18.6/src/libgpaste/keybinder/000077500000000000000000000000001305131721400175065ustar00rootroot00000000000000GPaste-3.18.6/src/libgpaste/keybinder/gpaste-keybinder.c000066400000000000000000000532021305131721400231110ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #ifdef GDK_WINDOWING_WAYLAND # include #endif #if defined(ENABLE_X_KEYBINDER) && defined (GDK_WINDOWING_X11) # include # include #endif #define MAX_BINDINGS 7 struct _GPasteKeybinder { GObject parent_instance; }; typedef struct { GSList *keybindings; GPasteSettings *settings; GPasteGnomeShellClient *shell_client; gboolean use_shell_client; gboolean grabbing; guint64 retries; gulong accel_signal; guint64 shell_watch; } GPasteKeybinderPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteKeybinder, g_paste_keybinder, G_TYPE_OBJECT) /***************************/ /* Internal grabbing stuff */ /***************************/ #ifdef GDK_WINDOWING_WAYLAND static void g_paste_keybinder_change_grab_wayland (void) { g_warning ("Wayland hotkeys are currently not supported outside of gnome-shell."); } #endif #if defined(ENABLE_X_KEYBINDER) && defined (GDK_WINDOWING_X11) static void g_paste_keybinder_change_grab_x11 (GPasteKeybinding *binding, Display *display, gboolean grab) { if (!g_paste_keybinding_is_active (binding)) return; guchar mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 }; XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits }; XISetMask (mask.mask, XI_KeyPress); gdk_error_trap_push (); guint64 mod_masks [] = { 0, /* modifier only */ GDK_MOD2_MASK, /* NumLock */ GDK_MOD5_MASK, /* ScrollLock */ GDK_LOCK_MASK, /* CapsLock */ GDK_MOD2_MASK | GDK_MOD5_MASK, GDK_MOD2_MASK | GDK_LOCK_MASK, GDK_MOD5_MASK | GDK_LOCK_MASK, GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK, }; Window window = GDK_ROOT_WINDOW (); GdkModifierType modifiers = g_paste_keybinding_get_modifiers (binding); const guint32 *keycodes = g_paste_keybinding_get_keycodes (binding); for (guint64 i = 0; i < G_N_ELEMENTS (mod_masks); ++i) { XIGrabModifiers mods = { mod_masks[i] | modifiers, 0 }; for (const guint32 *keycode = keycodes; *keycode; ++keycode) { if (grab) { XIGrabKeycode (display, XIAllMasterDevices, *keycode, window, XIGrabModeSync, XIGrabModeAsync, False, &mask, 1, &mods); } else { XIUngrabKeycode (display, XIAllMasterDevices, *keycode, window, 1, &mods); } } } gdk_flush (); gdk_error_trap_pop_ignored (); } #endif static void g_paste_keybinder_change_grab_internal (GPasteKeybinding *binding, gboolean grab) { GdkDisplay *display = gdk_display_get_default ();; #ifdef GDK_WINDOWING_WAYLAND if (GDK_IS_WAYLAND_DISPLAY (display)) g_paste_keybinder_change_grab_wayland (); else #endif #if defined(ENABLE_X_KEYBINDER) && defined (GDK_WINDOWING_X11) if (GDK_IS_X11_DISPLAY (display)) g_paste_keybinder_change_grab_x11 (binding, GDK_DISPLAY_XDISPLAY (display), grab); else #endif g_warning ("Unsupported GDK backend, keybinder won't work."); } /***********************************/ /* Wrapper around GPasteKeybinding */ /***********************************/ typedef struct { GPasteKeybinding *binding; GPasteSettings *settings; GPasteGnomeShellClient *shell_client; gboolean use_shell_client; guint32 action; gulong rebind_signal; } _Keybinding; static void _keybinding_activate (_Keybinding *k) { if (!g_paste_keybinding_is_active (k->binding)) g_paste_keybinding_activate (k->binding, k->settings); } static void _keybinding_deactivate (_Keybinding *k) { if (g_paste_keybinding_is_active (k->binding)) g_paste_keybinding_deactivate (k->binding); } static void on_key_grabbed (GObject *source_object, GAsyncResult *res, gpointer user_data) { _Keybinding *k = user_data; g_autoptr (GError) error = NULL; k->action = g_paste_gnome_shell_client_grab_accelerator_finish (G_PASTE_GNOME_SHELL_CLIENT (source_object), res, &error); if (error) g_warning ("Couldn't grab keybinding: %s", error->message); } static void _keybinding_grab_gnome_shell (_Keybinding *k) { if (k->action || !k->shell_client) return; GPasteGnomeShellAccelerator accel = { g_paste_keybinding_get_accelerator (k->binding, k->settings), G_PASTE_GNOME_SHELL_ACTION_MODE_ALL }; g_paste_gnome_shell_client_grab_accelerator (k->shell_client, accel, on_key_grabbed, k); } static void _keybinding_grab (_Keybinding *k) { _keybinding_activate (k); if (k->use_shell_client) _keybinding_grab_gnome_shell (k); else g_paste_keybinder_change_grab_internal (k->binding, TRUE); } static void on_key_ungrabbed (GObject *source_object, GAsyncResult *res, gpointer user_data G_GNUC_UNUSED) { g_autoptr (GError) error = NULL; g_paste_gnome_shell_client_ungrab_accelerator_finish (G_PASTE_GNOME_SHELL_CLIENT (source_object), res, &error); if (error) g_warning ("Couldn't ungrab keybinding: %s", error->message); } static void _keybinding_ungrab_gnome_shell (_Keybinding *k) { if (k->action) { g_paste_gnome_shell_client_ungrab_accelerator (k->shell_client, k->action, on_key_ungrabbed, NULL); k->action = 0; } } static void _keybinding_ungrab (_Keybinding *k) { if (k->use_shell_client) _keybinding_ungrab_gnome_shell (k); else g_paste_keybinder_change_grab_internal (k->binding, FALSE); _keybinding_deactivate (k); } static void _keybinding_rebind (_Keybinding *k, GPasteSettings *setting G_GNUC_UNUSED) { _keybinding_ungrab (k); _keybinding_grab (k); } static _Keybinding * _keybinding_new (GPasteKeybinding *binding, GPasteSettings *settings, GPasteGnomeShellClient *shell_client) { _Keybinding *k = g_new (_Keybinding, 1); k->binding = binding; k->settings = g_object_ref (settings); k->shell_client = (shell_client) ? g_object_ref (shell_client) : NULL; k->use_shell_client = !!shell_client; k->action = 0; g_autofree gchar *detailed_signal = g_strdup_printf ("rebind::%s", g_paste_keybinding_get_dconf_key (binding)); k->rebind_signal = g_signal_connect_swapped (settings, detailed_signal, G_CALLBACK (_keybinding_rebind), k); return k; } static void _keybinding_cleanup_shell_stuff (_Keybinding *k) { k->action = 0; } static void _keybinding_free (_Keybinding *k) { _keybinding_ungrab (k); g_signal_handler_disconnect (k->settings, k->rebind_signal); g_object_unref (k->binding); g_object_unref (k->settings); g_clear_object (&k->shell_client); g_free (k); } #define GET_BINDING(k) ((_Keybinding *) k)->binding /** * g_paste_keybinder_add_keybinding: * @self: a #GPasteKeybinder instance * @binding: (transfer full): a #GPasteKeybinding instance * * Add a new keybinding * * Returns: */ G_PASTE_VISIBLE void g_paste_keybinder_add_keybinding (GPasteKeybinder *self, GPasteKeybinding *binding) { g_return_if_fail (G_PASTE_IS_KEYBINDER (self)); g_return_if_fail (G_PASTE_IS_KEYBINDING (binding)); GPasteKeybinderPrivate *priv = g_paste_keybinder_get_instance_private (self); priv->keybindings = g_slist_prepend (priv->keybindings, _keybinding_new (binding, priv->settings, priv->shell_client)); } static void g_paste_keybinder_grab_keybinding_func (gpointer data, gpointer user_data G_GNUC_UNUSED) { _keybinding_grab (data); } static void g_paste_keybinder_private_grab_all (GPasteKeybinderPrivate *priv) { if (!priv->grabbing) { g_slist_foreach (priv->keybindings, g_paste_keybinder_grab_keybinding_func, NULL); } } static void g_paste_keybinder_activate_keybinding_func (gpointer data, gpointer user_data G_GNUC_UNUSED) { _keybinding_activate (data); } static void g_paste_keybinder_private_grab_all_gnome_shell (GPasteKeybinderPrivate *priv); static gboolean retry_grab_all_gnome_shell (gpointer user_data) { g_paste_keybinder_private_grab_all_gnome_shell (user_data); return G_SOURCE_REMOVE; } static void grab_accelerators_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { GPasteKeybinderPrivate *priv = user_data; g_autoptr (GError) error = NULL; g_autofree guint32 *actions = g_paste_gnome_shell_client_grab_accelerators_finish (G_PASTE_GNOME_SHELL_CLIENT (source_object), res, &error); if (error) { if (error->code == 19 && priv->retries < 10) { ++priv->retries; g_source_set_name_by_id (g_timeout_add_seconds (1, retry_grab_all_gnome_shell, priv), "[GPaste] gnome-shell grab"); } else { priv->retries = 0; g_warning ("Couldn't grab keybindings with gnome-shell: %s", error->message); } } else { priv->retries = 0; guint64 index = 0; for (GSList *binding = priv->keybindings; binding; binding = g_slist_next (binding)) { _Keybinding *k = binding->data; if (g_paste_keybinding_is_active (k->binding)) k->action = actions[index++]; } } priv->grabbing = FALSE; } static void g_paste_keybinder_private_grab_all_gnome_shell (GPasteKeybinderPrivate *priv) { if (priv->grabbing || !priv->shell_client) return; priv->grabbing = TRUE; GPasteGnomeShellAccelerator accels[MAX_BINDINGS + 1]; GPasteSettings *settings = priv->settings; guint64 index = 0; for (GSList *binding = priv->keybindings; binding && index < MAX_BINDINGS; binding = g_slist_next (binding)) { _Keybinding *k = binding->data; GPasteKeybinding *keybinding = k->binding; if (!k->action && g_paste_keybinding_is_active (keybinding)) accels[index++] = G_PASTE_GNOME_SHELL_ACCELERATOR (g_paste_keybinding_get_accelerator (keybinding, settings)); } accels[index].accelerator = NULL; if (index) { g_paste_gnome_shell_client_grab_accelerators (priv->shell_client, accels, grab_accelerators_cb, priv); } else priv->grabbing = FALSE; } /** * g_paste_keybinder_activate_all: * @self: a #GPasteKeybinder instance * * Activate all the managed keybindings * * Returns: */ G_PASTE_VISIBLE void g_paste_keybinder_activate_all (GPasteKeybinder *self) { g_return_if_fail (G_PASTE_IS_KEYBINDER (self)); GPasteKeybinderPrivate *priv = g_paste_keybinder_get_instance_private (self); if (priv->use_shell_client) { g_slist_foreach (priv->keybindings, g_paste_keybinder_activate_keybinding_func, NULL); g_paste_keybinder_private_grab_all_gnome_shell (priv); } else g_paste_keybinder_private_grab_all (priv); } static void g_paste_keybinder_deactivate_keybinding_func (gpointer data, gpointer user_data G_GNUC_UNUSED) { _keybinding_ungrab (data); } /** * g_paste_keybinder_deactivate_all: * @self: a #GPasteKeybinder instance * * Deactivate all the managed keybindings * * Returns: */ G_PASTE_VISIBLE void g_paste_keybinder_deactivate_all (GPasteKeybinder *self) { g_return_if_fail (G_PASTE_IS_KEYBINDER (self)); GPasteKeybinderPrivate *priv = g_paste_keybinder_get_instance_private (self); g_slist_foreach (priv->keybindings, g_paste_keybinder_deactivate_keybinding_func, NULL); } #ifdef GDK_WINDOWING_WAYLAND static void g_paste_keybinder_parse_event_wayland (void) { g_warning ("Wayland hotkeys are currently not supported outside of gnome-shell."); } #endif #if defined(ENABLE_X_KEYBINDER) && defined (GDK_WINDOWING_X11) static gint g_paste_keybinder_get_xinput_opcode (Display *display) { static gint32 xinput_opcode = 0; if (!xinput_opcode) { gint32 major = 2, minor = 3; gint32 xinput_error_base; gint32 xinput_event_base; if (XQueryExtension (display, "XInputExtension", &xinput_opcode, &xinput_error_base, &xinput_event_base)) { if (XIQueryVersion (display, &major, &minor) != Success) g_warning ("XInput 2 not found, keybinder won't work"); } } return xinput_opcode; } static void g_paste_keybinder_parse_event_x11 (XEvent *event, GdkModifierType *modifiers, guint64 *keycode) { XGenericEventCookie cookie = event->xcookie; if (cookie.extension == g_paste_keybinder_get_xinput_opcode (NULL)) { XIDeviceEvent *xi_ev = (XIDeviceEvent *) cookie.data; if (xi_ev->evtype == XI_KeyPress) { *modifiers = xi_ev->mods.effective; *keycode = xi_ev->detail; } } } #endif static GdkFilterReturn g_paste_keybinder_filter (GdkXEvent *xevent, GdkEvent *event G_GNUC_UNUSED, gpointer data) { GPasteKeybinderPrivate *priv = data; for (GList *dev = gdk_device_manager_list_devices (gdk_display_get_device_manager (gdk_display_get_default ()), GDK_DEVICE_TYPE_MASTER); dev; dev = g_list_next (dev)) { GdkDevice *device = dev->data; if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD) gdk_device_ungrab (device, GDK_CURRENT_TIME); } gdk_flush (); GdkDisplay *display = gdk_display_get_default (); GdkModifierType modifiers = 0; guint64 keycode = 0; #ifdef GDK_WINDOWING_WAYLAND if (GDK_IS_WAYLAND_DISPLAY (display)) g_paste_keybinder_parse_event_wayland (); else #endif #if defined(ENABLE_X_KEYBINDER) && defined (GDK_WINDOWING_X11) if (GDK_IS_X11_DISPLAY (display)) g_paste_keybinder_parse_event_x11 ((XEvent *) xevent, &modifiers, &keycode); else #endif g_warning ("Unsupported GDK backend, keybinder won't work."); for (GSList *keybinding = priv->keybindings; keybinding; keybinding = g_slist_next (keybinding)) { GPasteKeybinding *real_keybinding = GET_BINDING (keybinding->data); if (g_paste_keybinding_is_active (real_keybinding)) g_paste_keybinding_notify (real_keybinding, modifiers, keycode); } return GDK_FILTER_CONTINUE; } static void on_accelerator_activated (GPasteGnomeShellClient *client G_GNUC_UNUSED, guint32 action, gpointer user_data) { GPasteKeybinderPrivate *priv = user_data; for (GSList *binding = priv->keybindings; binding; binding = g_slist_next (binding)) { _Keybinding *k = binding->data; if (action == k->action) { GPasteKeybinding *keybinding = k->binding; if (g_paste_keybinding_is_active (keybinding)) g_paste_keybinding_perform (keybinding); return; } } } static void on_shell_appeared (GDBusConnection *connection G_GNUC_UNUSED, const gchar *name G_GNUC_UNUSED, const gchar *name_owner G_GNUC_UNUSED, gpointer user_data) { g_paste_keybinder_private_grab_all_gnome_shell (user_data); } static void g_paste_keybinder_private_cleanup_shell_stuff (GPasteKeybinderPrivate *priv) { g_slist_foreach (priv->keybindings, (GFunc) _keybinding_cleanup_shell_stuff, NULL); } static void on_shell_vanished (GDBusConnection *connection G_GNUC_UNUSED, const gchar *name G_GNUC_UNUSED, gpointer user_data) { GPasteKeybinderPrivate *priv = user_data; g_paste_keybinder_private_cleanup_shell_stuff (priv); priv->grabbing = FALSE; } static void g_paste_keybinder_dispose (GObject *object) { GPasteKeybinder *self = G_PASTE_KEYBINDER (object); GPasteKeybinderPrivate *priv = g_paste_keybinder_get_instance_private (self); if (priv->shell_watch) { g_bus_unwatch_name (priv->shell_watch); priv->shell_watch = 0; } if (priv->shell_client) { g_signal_handler_disconnect (priv->shell_client, priv->accel_signal); g_clear_object (&priv->shell_client); } if (priv->settings) { g_clear_object (&priv->settings); g_paste_keybinder_deactivate_all (self); g_slist_foreach (priv->keybindings, (GFunc) _keybinding_free, NULL); priv->keybindings = NULL; } G_OBJECT_CLASS (g_paste_keybinder_parent_class)->dispose (object); } static void g_paste_keybinder_finalize (GObject *object) { GPasteKeybinderPrivate *priv = g_paste_keybinder_get_instance_private (G_PASTE_KEYBINDER (object)); gdk_window_remove_filter (gdk_get_default_root_window (), g_paste_keybinder_filter, priv); G_OBJECT_CLASS (g_paste_keybinder_parent_class)->finalize (object); } static void g_paste_keybinder_class_init (GPasteKeybinderClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->dispose = g_paste_keybinder_dispose; object_class->finalize = g_paste_keybinder_finalize; } static void g_paste_keybinder_init (GPasteKeybinder *self) { GPasteKeybinderPrivate *priv = g_paste_keybinder_get_instance_private (self); priv->keybindings = NULL; gdk_window_add_filter (gdk_get_default_root_window (), g_paste_keybinder_filter, priv); #if defined(ENABLE_X_KEYBINDER) && defined (GDK_WINDOWING_X11) /* Initialize */ GdkDisplay *display = gdk_display_get_default (); if (GDK_IS_X11_DISPLAY (display)) g_paste_keybinder_get_xinput_opcode (GDK_DISPLAY_XDISPLAY (display)); #endif } /** * g_paste_keybinder_new: * @settings: a #GPasteSettings instance * @shell_client: a #GPasteGnomeShellClient instance * * Create a new instance of #GPasteKeybinder * * Returns: a newly allocated #GPasteKeybinder * free it with g_object_unref */ G_PASTE_VISIBLE GPasteKeybinder * g_paste_keybinder_new (GPasteSettings *settings, GPasteGnomeShellClient *shell_client) { g_return_val_if_fail (G_PASTE_IS_SETTINGS (settings), NULL); g_return_val_if_fail (!shell_client || G_PASTE_IS_GNOME_SHELL_CLIENT (shell_client), NULL); GPasteKeybinder *self = G_PASTE_KEYBINDER (g_object_new (G_PASTE_TYPE_KEYBINDER, NULL)); GPasteKeybinderPrivate *priv = g_paste_keybinder_get_instance_private (self); priv->settings = g_object_ref (settings); priv->shell_client = (shell_client) ? g_object_ref (shell_client) : NULL; priv->use_shell_client = !!shell_client; priv->grabbing = FALSE; priv->retries = 0; if (shell_client) { priv->accel_signal = g_signal_connect (shell_client, "accelerator-activated", G_CALLBACK (on_accelerator_activated), priv); priv->shell_watch = g_bus_watch_name (G_BUS_TYPE_SESSION, G_PASTE_GNOME_SHELL_BUS_NAME, G_BUS_NAME_WATCHER_FLAGS_NONE, on_shell_appeared, on_shell_vanished, priv, NULL); } else priv->shell_watch = 0; return self; } GPaste-3.18.6/src/libgpaste/keybinder/gpaste-keybinder.h000066400000000000000000000032131305131721400231130ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_KEYBINDER_H__ #define __G_PASTE_KEYBINDER_H__ #include #include G_BEGIN_DECLS #define G_PASTE_TYPE_KEYBINDER (g_paste_keybinder_get_type ()) G_PASTE_FINAL_TYPE (Keybinder, keybinder, KEYBINDER, GObject) void g_paste_keybinder_add_keybinding (GPasteKeybinder *self, GPasteKeybinding *binding); void g_paste_keybinder_activate_all (GPasteKeybinder *self); void g_paste_keybinder_deactivate_all (GPasteKeybinder *self); GPasteKeybinder *g_paste_keybinder_new (GPasteSettings *settings, GPasteGnomeShellClient *shell_client); G_END_DECLS #endif /*__G_PASTE_KEYBINDER_H__*/ GPaste-3.18.6/src/libgpaste/keybinder/gpaste-keybinding.c000066400000000000000000000211501305131721400232550ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2012-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include typedef struct _GPasteKeybindingPrivate { GPasteKeybindingGetter getter; gchar *dconf_key; GPasteKeybindingFunc callback; gpointer user_data; gboolean active; GdkModifierType modifiers; guint32 *keycodes; } GPasteKeybindingPrivate; G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GPasteKeybinding, g_paste_keybinding, G_TYPE_OBJECT) /** * g_paste_keybinding_get_modifiers: * @self: a #GPasteKeybinding instance * * Get the modifiers for this keybinding * * Returns: the modifiers */ G_PASTE_VISIBLE GdkModifierType g_paste_keybinding_get_modifiers (const GPasteKeybinding *self) { g_return_val_if_fail (G_PASTE_IS_KEYBINDING (self), 0); GPasteKeybindingPrivate *priv = g_paste_keybinding_get_instance_private (self); return priv->modifiers; } /** * g_paste_keybinding_get_keycodes: * @self: a #GPasteKeybinding instance * * Get the keycodes for this keybinding * * Returns: the keycodes */ G_PASTE_VISIBLE const guint32 * g_paste_keybinding_get_keycodes (const GPasteKeybinding *self) { g_return_val_if_fail (G_PASTE_IS_KEYBINDING (self), NULL); GPasteKeybindingPrivate *priv = g_paste_keybinding_get_instance_private (self); return priv->keycodes; } /** * g_paste_keybinding_get_dconf_key: * @self: a #GPasteKeybinding instance * * Get the dconf key for this keybinding * * Returns: the dconf key */ G_PASTE_VISIBLE const gchar * g_paste_keybinding_get_dconf_key (const GPasteKeybinding *self) { g_return_val_if_fail (G_PASTE_IS_KEYBINDING ((gpointer) self), NULL); GPasteKeybindingPrivate *priv = g_paste_keybinding_get_instance_private (self); return priv->dconf_key; } /** * g_paste_keybinding_get_accelerator: * @self: a #GPasteKeybinding instance * * Get the accelerator for this keybinding * * Returns: the accelerator */ G_PASTE_VISIBLE const gchar * g_paste_keybinding_get_accelerator (const GPasteKeybinding *self, const GPasteSettings *settings) { g_return_val_if_fail (G_PASTE_IS_KEYBINDING ((gpointer) self), NULL); g_return_val_if_fail (G_PASTE_IS_SETTINGS ((gpointer) settings), NULL); GPasteKeybindingPrivate *priv = g_paste_keybinding_get_instance_private (self); return priv->getter (settings); } /** * g_paste_keybinding_activate: * @self: a #GPasteKeybinding instance * @settings: a #GPasteSettings instance * * Activate the keybinding * * Returns: */ G_PASTE_VISIBLE void g_paste_keybinding_activate (GPasteKeybinding *self, GPasteSettings *settings) { g_return_if_fail (G_PASTE_IS_KEYBINDING (self)); g_return_if_fail (G_PASTE_IS_SETTINGS (settings)); GPasteKeybindingPrivate *priv = g_paste_keybinding_get_instance_private (self); g_return_if_fail (!priv->active); const gchar *binding = priv->getter (settings); if (binding) { gtk_accelerator_parse_with_keycode (binding, NULL, &priv->keycodes, &priv->modifiers); priv->active = priv->keycodes != NULL; } } /** * g_paste_keybinding_deactivate: * @self: a #GPasteKeybinding instance * * Deactivate the keybinding * * Returns: */ G_PASTE_VISIBLE void g_paste_keybinding_deactivate (GPasteKeybinding *self) { g_return_if_fail (G_PASTE_IS_KEYBINDING (self)); GPasteKeybindingPrivate *priv = g_paste_keybinding_get_instance_private (self); g_return_if_fail (priv->active); priv->active = FALSE; } /** * g_paste_keybinding_is_active: * @self: a #GPasteKeybinding instance * * Check whether the keybinding is active or not * * Returns: true if the keybinding is active */ G_PASTE_VISIBLE gboolean g_paste_keybinding_is_active (GPasteKeybinding *self) { g_return_val_if_fail (G_PASTE_IS_KEYBINDING (self), FALSE); GPasteKeybindingPrivate *priv = g_paste_keybinding_get_instance_private (self); return priv->active; } static gboolean g_paste_keybinding_private_match (GPasteKeybindingPrivate *priv, GdkModifierType modifiers, guint64 keycode) { if (priv->keycodes && priv->modifiers == (priv->modifiers & modifiers)) { for (guint32 *_keycode = priv->keycodes; *_keycode; ++_keycode) { if (keycode == *_keycode) return TRUE; } } return FALSE; } /** * g_paste_keybinding_notify: * @self: a #GPasteKeybinding instance * @modifiers: The modifiers of the current event * @keycode: the keycode of the current event * * Runs the callback associated to the keybinding if needed * * Returns: */ G_PASTE_VISIBLE void g_paste_keybinding_notify (GPasteKeybinding *self, GdkModifierType modifiers, guint64 keycode) { g_return_if_fail (G_PASTE_IS_KEYBINDING (self)); GPasteKeybindingPrivate *priv = g_paste_keybinding_get_instance_private (self); if (keycode && g_paste_keybinding_private_match (priv, modifiers, keycode)) priv->callback (self, priv->user_data); } /** * g_paste_keybinding_perform: * @self: a #GPasteKeybinding instance * * Runs the callback associated to the keybinding * * Returns: */ G_PASTE_VISIBLE void g_paste_keybinding_perform (GPasteKeybinding *self) { g_return_if_fail (G_PASTE_IS_KEYBINDING (self)); GPasteKeybindingPrivate *priv = g_paste_keybinding_get_instance_private (self); priv->callback (self, priv->user_data); } static void g_paste_keybinding_dispose (GObject *object) { GPasteKeybinding *self = G_PASTE_KEYBINDING (object); GPasteKeybindingPrivate *priv = g_paste_keybinding_get_instance_private (self); if (priv->active) g_paste_keybinding_deactivate (self); G_OBJECT_CLASS (g_paste_keybinding_parent_class)->dispose (object); } static void g_paste_keybinding_finalize (GObject *object) { GPasteKeybindingPrivate *priv = g_paste_keybinding_get_instance_private (G_PASTE_KEYBINDING (object)); g_free (priv->keycodes); g_free (priv->dconf_key); G_OBJECT_CLASS (g_paste_keybinding_parent_class)->finalize (object); } static void g_paste_keybinding_class_init (GPasteKeybindingClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->dispose = g_paste_keybinding_dispose; object_class->finalize = g_paste_keybinding_finalize; } static void g_paste_keybinding_init (GPasteKeybinding *self) { GPasteKeybindingPrivate *priv = g_paste_keybinding_get_instance_private (self); priv->active = FALSE; } /** * g_paste_keybinding_new: * @type: the type of the subclass to instantiate * @dconf_key: the dconf key to watch * @getter: (scope notified): the getter to use to get the binding * @callback: (closure user_data) (scope notified): the callback to call when activated * @user_data: (closure): the data to pass to @callback, defaults to self/this * * Create a new instance of #GPasteKeybinding * * Returns: a newly allocated #GPasteKeybinding * free it with g_object_unref */ G_PASTE_VISIBLE GPasteKeybinding * g_paste_keybinding_new (GType type, const gchar *dconf_key, GPasteKeybindingGetter getter, GPasteKeybindingFunc callback, gpointer user_data) { g_return_val_if_fail (g_type_is_a (type, G_PASTE_TYPE_KEYBINDING), NULL); g_return_val_if_fail (dconf_key, NULL); g_return_val_if_fail (getter, NULL); g_return_val_if_fail (callback, NULL); GPasteKeybinding *self = g_object_new (type, NULL); GPasteKeybindingPrivate *priv = g_paste_keybinding_get_instance_private (self); priv->getter = getter; priv->dconf_key = g_strdup (dconf_key); priv->callback = callback; priv->user_data = user_data; priv->keycodes = NULL; return self; } GPaste-3.18.6/src/libgpaste/keybinder/gpaste-keybinding.h000066400000000000000000000055611305131721400232720ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2012-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_KEYBINDING_H__ #define __G_PASTE_KEYBINDING_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_KEYBINDING (g_paste_keybinding_get_type ()) G_PASTE_DERIVABLE_TYPE (Keybinding, keybinding, KEYBINDING, GObject) struct _GPasteKeybindingClass { GObjectClass parent_class; }; typedef const gchar *(*GPasteKeybindingGetter) (const GPasteSettings *settings); typedef void (*GPasteKeybindingFunc) (GPasteKeybinding *self, gpointer data); const guint32 *g_paste_keybinding_get_keycodes (const GPasteKeybinding *self); GdkModifierType g_paste_keybinding_get_modifiers (const GPasteKeybinding *self); const gchar *g_paste_keybinding_get_dconf_key (const GPasteKeybinding *self); const gchar *g_paste_keybinding_get_accelerator (const GPasteKeybinding *self, const GPasteSettings *settings); void g_paste_keybinding_activate (GPasteKeybinding *self, GPasteSettings *settings); void g_paste_keybinding_deactivate (GPasteKeybinding *self); gboolean g_paste_keybinding_is_active (GPasteKeybinding *self); void g_paste_keybinding_perform (GPasteKeybinding *self); void g_paste_keybinding_notify (GPasteKeybinding *self, GdkModifierType modifiers, guint64 keycode); GPasteKeybinding *g_paste_keybinding_new (GType type, const gchar *dconf_key, GPasteKeybindingGetter getter, GPasteKeybindingFunc callback, gpointer user_data); G_END_DECLS #endif /*__G_PASTE_KEYBINDING_H__*/ GPaste-3.18.6/src/libgpaste/keybinder/gpaste-make-password-keybinding.c000066400000000000000000000043161305131721400260350ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include struct _GPasteMakePasswordKeybinding { GPasteKeybinding parent_instance; }; G_DEFINE_TYPE (GPasteMakePasswordKeybinding, g_paste_make_password_keybinding, G_PASTE_TYPE_KEYBINDING) static void g_paste_make_password_keybinding_class_init (GPasteMakePasswordKeybindingClass *klass G_GNUC_UNUSED) { } static void g_paste_make_password_keybinding_init (GPasteMakePasswordKeybinding *self G_GNUC_UNUSED) { } static void g_paste_make_password_keybinding_make_password (GPasteKeybinding *self G_GNUC_UNUSED, gpointer data) { GPasteHistory *history = data; g_paste_history_set_password (history, 0, NULL); } /** * g_paste_make_password_keybinding_new: * @history: a #GPasteHistory instance * * Create a new instance of #GPasteMakePasswordKeybinding * * Returns: a newly allocated #GPasteMakePasswordKeybinding * free it with g_object_unref */ G_PASTE_VISIBLE GPasteKeybinding * g_paste_make_password_keybinding_new (GPasteHistory *history) { return g_paste_keybinding_new (G_PASTE_TYPE_MAKE_PASSWORD_KEYBINDING, G_PASTE_MAKE_PASSWORD_SETTING, g_paste_settings_get_make_password, g_paste_make_password_keybinding_make_password, history); } GPaste-3.18.6/src/libgpaste/keybinder/gpaste-make-password-keybinding.h000066400000000000000000000026641305131721400260460ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2014-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_MAKE_PASSWORD_KEYBINDING_H__ #define __G_PASTE_MAKE_PASSWORD_KEYBINDING_H__ #include #include G_BEGIN_DECLS #define G_PASTE_TYPE_MAKE_PASSWORD_KEYBINDING (g_paste_make_password_keybinding_get_type ()) G_PASTE_FINAL_TYPE (MakePasswordKeybinding, make_password_keybinding, MAKE_PASSWORD_KEYBINDING, GPasteKeybinding) GPasteKeybinding *g_paste_make_password_keybinding_new (GPasteHistory *history); G_END_DECLS #endif /*__G_PASTE_MAKE_PASSWORD_KEYBINDING_H__*/ GPaste-3.18.6/src/libgpaste/keybinder/gpaste-pop-keybinding.c000066400000000000000000000054161305131721400240600ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2012-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include struct _GPastePopKeybinding { GPasteKeybinding parent_instance; }; typedef struct { GPasteHistory *history; } GPastePopKeybindingPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPastePopKeybinding, g_paste_pop_keybinding, G_PASTE_TYPE_KEYBINDING) static void g_paste_pop_keybinding_dispose (GObject *object) { GPastePopKeybindingPrivate *priv = g_paste_pop_keybinding_get_instance_private (G_PASTE_POP_KEYBINDING (object)); g_clear_object (&priv->history); G_OBJECT_CLASS (g_paste_pop_keybinding_parent_class)->dispose (object); } static void g_paste_pop_keybinding_class_init (GPastePopKeybindingClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_pop_keybinding_dispose; } static void g_paste_pop_keybinding_init (GPastePopKeybinding *self G_GNUC_UNUSED) { } static void pop (GPasteKeybinding *self, gpointer data G_GNUC_UNUSED) { GPastePopKeybindingPrivate *priv = g_paste_pop_keybinding_get_instance_private (G_PASTE_POP_KEYBINDING (self)); g_paste_history_remove (priv->history, 0); } /** * g_paste_pop_keybinding_new: * @history: a #GPasteHistory instance * * Create a new instance of #GPastePopKeybinding * * Returns: a newly allocated #GPastePopKeybinding * free it with g_object_unref */ G_PASTE_VISIBLE GPasteKeybinding * g_paste_pop_keybinding_new (GPasteHistory *history) { g_return_val_if_fail (G_PASTE_IS_HISTORY (history), NULL); GPasteKeybinding *self = g_paste_keybinding_new (G_PASTE_TYPE_POP_KEYBINDING, G_PASTE_POP_SETTING, g_paste_settings_get_pop, pop, NULL); GPastePopKeybindingPrivate *priv = g_paste_pop_keybinding_get_instance_private (G_PASTE_POP_KEYBINDING (self)); priv->history = g_object_ref (history); return self; } GPaste-3.18.6/src/libgpaste/keybinder/gpaste-pop-keybinding.h000066400000000000000000000025331305131721400240620ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2012-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_POP_KEYBINDING_H__ #define __G_PASTE_POP_KEYBINDING_H__ #include #include G_BEGIN_DECLS #define G_PASTE_TYPE_POP_KEYBINDING (g_paste_pop_keybinding_get_type ()) G_PASTE_FINAL_TYPE (PopKeybinding, pop_keybinding, POP_KEYBINDING, GPasteKeybinding) GPasteKeybinding *g_paste_pop_keybinding_new (GPasteHistory *history); G_END_DECLS #endif /*__G_PASTE_POP_KEYBINDING_H__*/ GPaste-3.18.6/src/libgpaste/keybinder/gpaste-show-history-keybinding.c000066400000000000000000000043751305131721400257440ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2012-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include struct _GPasteShowHistoryKeybinding { GPasteKeybinding parent_instance; }; G_DEFINE_TYPE (GPasteShowHistoryKeybinding, g_paste_show_history_keybinding, G_PASTE_TYPE_KEYBINDING) static void g_paste_show_history_keybinding_class_init (GPasteShowHistoryKeybindingClass *klass G_GNUC_UNUSED) { } static void g_paste_show_history_keybinding_init (GPasteShowHistoryKeybinding *self G_GNUC_UNUSED) { } static void g_paste_show_history_keybinding_show_history (GPasteKeybinding *self G_GNUC_UNUSED, gpointer data) { GPasteDaemon *gpaste_daemon = data; g_paste_daemon_show_history (gpaste_daemon, NULL); /* error */ } /** * g_paste_show_history_keybinding_new: * @gpaste_daemon: a #GPasteDaemon instance * * Create a new instance of #GPasteShowHistoryKeybinding * * Returns: a newly allocated #GPasteShowHistoryKeybinding * free it with g_object_unref */ G_PASTE_VISIBLE GPasteKeybinding * g_paste_show_history_keybinding_new (GPasteDaemon *gpaste_daemon) { return g_paste_keybinding_new (G_PASTE_TYPE_SHOW_HISTORY_KEYBINDING, G_PASTE_SHOW_HISTORY_SETTING, g_paste_settings_get_show_history, g_paste_show_history_keybinding_show_history, gpaste_daemon); } GPaste-3.18.6/src/libgpaste/keybinder/gpaste-show-history-keybinding.h000066400000000000000000000026571305131721400257520ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2012-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_SHOW_HISTORY_KEYBINDING_H__ #define __G_PASTE_SHOW_HISTORY_KEYBINDING_H__ #include #include G_BEGIN_DECLS #define G_PASTE_TYPE_SHOW_HISTORY_KEYBINDING (g_paste_show_history_keybinding_get_type ()) G_PASTE_FINAL_TYPE (ShowHistoryKeybinding, show_history_keybinding, SHOW_HISTORY_KEYBINDING, GPasteKeybinding) GPasteKeybinding *g_paste_show_history_keybinding_new (GPasteDaemon *gpaste_daemon); G_END_DECLS #endif /*__G_PASTE_SHOW_HISTORY_KEYBINDING_H__*/ GPaste-3.18.6/src/libgpaste/keybinder/gpaste-sync-clipboard-to-primary-keybinding.c000066400000000000000000000050241305131721400302670ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2013-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include struct _GPasteSyncClipboardToPrimaryKeybinding { GPasteKeybinding parent_instance; }; G_DEFINE_TYPE (GPasteSyncClipboardToPrimaryKeybinding, g_paste_sync_clipboard_to_primary_keybinding, G_PASTE_TYPE_KEYBINDING) static void g_paste_sync_clipboard_to_primary_keybinding_class_init (GPasteSyncClipboardToPrimaryKeybindingClass *klass G_GNUC_UNUSED) { } static void g_paste_sync_clipboard_to_primary_keybinding_init (GPasteSyncClipboardToPrimaryKeybinding *self G_GNUC_UNUSED) { } static void g_paste_sync_clipboard_to_primary_keybinding_sync (GPasteKeybinding *self G_GNUC_UNUSED, gpointer data) { GPasteClipboardsManager *gcm = data; g_paste_clipboards_manager_sync_from_to (gcm, GDK_SELECTION_CLIPBOARD, GDK_SELECTION_PRIMARY); } /** * g_paste_sync_clipboard_to_primary_keybinding_new: * @gcm: a #GPasteClipboardManager instance * * Create a new instance of #GPasteSyncClipboardToPrimaryKeybinding * * Returns: a newly allocated #GPasteSyncClipboardToPrimaryKeybinding * free it with g_object_unref */ G_PASTE_VISIBLE GPasteKeybinding * g_paste_sync_clipboard_to_primary_keybinding_new (GPasteClipboardsManager *gcm) { return g_paste_keybinding_new (G_PASTE_TYPE_SYNC_CLIPBOARD_TO_PRIMARY_KEYBINDING, G_PASTE_SYNC_CLIPBOARD_TO_PRIMARY_SETTING, g_paste_settings_get_sync_clipboard_to_primary, g_paste_sync_clipboard_to_primary_keybinding_sync, gcm); } GPaste-3.18.6/src/libgpaste/keybinder/gpaste-sync-clipboard-to-primary-keybinding.h000066400000000000000000000030571305131721400303000ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2013-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_SYNC_CLIPBOARD_TO_PRIMARY_KEYBINDING_H__ #define __G_PASTE_SYNC_CLIPBOARD_TO_PRIMARY_KEYBINDING_H__ #include #include G_BEGIN_DECLS #define G_PASTE_TYPE_SYNC_CLIPBOARD_TO_PRIMARY_KEYBINDING (g_paste_sync_clipboard_to_primary_keybinding_get_type ()) G_PASTE_FINAL_TYPE (SyncClipboardToPrimaryKeybinding, sync_clipboard_to_primary_keybinding, SYNC_CLIPBOARD_TO_PRIMARY_KEYBINDING, GPasteKeybinding) GPasteKeybinding *g_paste_sync_clipboard_to_primary_keybinding_new (GPasteClipboardsManager *gcm); G_END_DECLS #endif /*__G_PASTE_SYNC_CLIPBOARD_TO_PRIMARY_KEYBINDING_H__*/ GPaste-3.18.6/src/libgpaste/keybinder/gpaste-sync-primary-to-clipboard-keybinding.c000066400000000000000000000050241305131721400302670ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2013-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include struct _GPasteSyncPrimaryToClipboardKeybinding { GPasteKeybinding parent_instance; }; G_DEFINE_TYPE (GPasteSyncPrimaryToClipboardKeybinding, g_paste_sync_primary_to_clipboard_keybinding, G_PASTE_TYPE_KEYBINDING) static void g_paste_sync_primary_to_clipboard_keybinding_class_init (GPasteSyncPrimaryToClipboardKeybindingClass *klass G_GNUC_UNUSED) { } static void g_paste_sync_primary_to_clipboard_keybinding_init (GPasteSyncPrimaryToClipboardKeybinding *self G_GNUC_UNUSED) { } static void g_paste_sync_primary_to_clipboard_keybinding_sync (GPasteKeybinding *self G_GNUC_UNUSED, gpointer data) { GPasteClipboardsManager *gcm = data; g_paste_clipboards_manager_sync_from_to (gcm, GDK_SELECTION_PRIMARY, GDK_SELECTION_CLIPBOARD); } /** * g_paste_sync_primary_to_clipboard_keybinding_new: * @gcm: a #GPasteClipboardManager instance * * Create a new instance of #GPasteSyncPrimaryToClipboardKeybinding * * Returns: a newly allocated #GPasteSyncPrimaryToClipboardKeybinding * free it with g_object_unref */ G_PASTE_VISIBLE GPasteKeybinding * g_paste_sync_primary_to_clipboard_keybinding_new (GPasteClipboardsManager *gcm) { return g_paste_keybinding_new (G_PASTE_TYPE_SYNC_PRIMARY_TO_CLIPBOARD_KEYBINDING, G_PASTE_SYNC_PRIMARY_TO_CLIPBOARD_SETTING, g_paste_settings_get_sync_primary_to_clipboard, g_paste_sync_primary_to_clipboard_keybinding_sync, gcm); } GPaste-3.18.6/src/libgpaste/keybinder/gpaste-sync-primary-to-clipboard-keybinding.h000066400000000000000000000030571305131721400303000ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2013-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_SYNC_PRIMARY_TO_CLIPBOARD_KEYBINDING_H__ #define __G_PASTE_SYNC_PRIMARY_TO_CLIPBOARD_KEYBINDING_H__ #include #include G_BEGIN_DECLS #define G_PASTE_TYPE_SYNC_PRIMARY_TO_CLIPBOARD_KEYBINDING (g_paste_sync_primary_to_clipboard_keybinding_get_type ()) G_PASTE_FINAL_TYPE (SyncPrimaryToClipboardKeybinding, sync_primary_to_clipboard_keybinding, SYNC_PRIMARY_TO_CLIPBOARD_KEYBINDING, GPasteKeybinding) GPasteKeybinding *g_paste_sync_primary_to_clipboard_keybinding_new (GPasteClipboardsManager *gcm); G_END_DECLS #endif /*__G_PASTE_SYNC_PRIMARY_TO_CLIPBOARD_KEYBINDING_H__*/ GPaste-3.18.6/src/libgpaste/keybinder/gpaste-ui-keybinding.c000066400000000000000000000035721305131721400237000ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include struct _GPasteUiKeybinding { GPasteKeybinding parent_instance; }; G_DEFINE_TYPE (GPasteUiKeybinding, g_paste_ui_keybinding, G_PASTE_TYPE_KEYBINDING) static void g_paste_ui_keybinding_class_init (GPasteUiKeybindingClass *klass G_GNUC_UNUSED) { } static void g_paste_ui_keybinding_init (GPasteUiKeybinding *self G_GNUC_UNUSED) { } static void launch_ui (GPasteKeybinding *self G_GNUC_UNUSED, gpointer data G_GNUC_UNUSED) { g_paste_util_spawn ("Ui"); } /** * g_paste_ui_keybinding_new: * * Create a new instance of #GPasteUiKeybinding * * Returns: a newly allocated #GPasteUiKeybinding * free it with g_object_unref */ G_PASTE_VISIBLE GPasteKeybinding * g_paste_ui_keybinding_new (void) { return g_paste_keybinding_new (G_PASTE_TYPE_UI_KEYBINDING, G_PASTE_LAUNCH_UI_SETTING, g_paste_settings_get_launch_ui, launch_ui, NULL); } GPaste-3.18.6/src/libgpaste/keybinder/gpaste-ui-keybinding.h000066400000000000000000000024371305131721400237040ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_KEYBINDING_H__ #define __G_PASTE_UI_KEYBINDING_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_KEYBINDING (g_paste_ui_keybinding_get_type ()) G_PASTE_FINAL_TYPE (UiKeybinding, ui_keybinding, UI_KEYBINDING, GPasteKeybinding) GPasteKeybinding *g_paste_ui_keybinding_new (void); G_END_DECLS #endif /*__G_PASTE_UI_KEYBINDING_H__*/ GPaste-3.18.6/src/libgpaste/keybinder/gpaste-upload-keybinding.c000066400000000000000000000055311305131721400245440ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include struct _GPasteUploadKeybinding { GPasteKeybinding parent_instance; }; typedef struct { GPasteDaemon *daemon; } GPasteUploadKeybindingPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteUploadKeybinding, g_paste_upload_keybinding, G_PASTE_TYPE_KEYBINDING) static void g_paste_upload_keybinding_dispose (GObject *object) { GPasteUploadKeybindingPrivate *priv = g_paste_upload_keybinding_get_instance_private (G_PASTE_UPLOAD_KEYBINDING (object)); g_clear_object (&priv->daemon); G_OBJECT_CLASS (g_paste_upload_keybinding_parent_class)->dispose (object); } static void g_paste_upload_keybinding_class_init (GPasteUploadKeybindingClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_upload_keybinding_dispose; } static void g_paste_upload_keybinding_init (GPasteUploadKeybinding *self G_GNUC_UNUSED) { } static void upload (GPasteKeybinding *self, gpointer data G_GNUC_UNUSED) { GPasteUploadKeybindingPrivate *priv = g_paste_upload_keybinding_get_instance_private (G_PASTE_UPLOAD_KEYBINDING (self)); g_paste_daemon_upload (priv->daemon, 0); } /** * g_paste_upload_keybinding_new: * @daemon: a #GPasteDaemon instance * * Create a new instance of #GPasteUploadKeybinding * * Returns: a newly allocated #GPasteUploadKeybinding * free it with g_object_unref */ G_PASTE_VISIBLE GPasteKeybinding * g_paste_upload_keybinding_new (GPasteDaemon *daemon) { g_return_val_if_fail (G_PASTE_IS_DAEMON (daemon), NULL); GPasteKeybinding *self = g_paste_keybinding_new (G_PASTE_TYPE_UPLOAD_KEYBINDING, G_PASTE_UPLOAD_SETTING, g_paste_settings_get_upload, upload, NULL); GPasteUploadKeybindingPrivate *priv = g_paste_upload_keybinding_get_instance_private (G_PASTE_UPLOAD_KEYBINDING (self)); priv->daemon = g_object_ref (daemon); return self; } GPaste-3.18.6/src/libgpaste/keybinder/gpaste-upload-keybinding.h000066400000000000000000000025561305131721400245550ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UPLOAD_KEYBINDING_H__ #define __G_PASTE_UPLOAD_KEYBINDING_H__ #include #include G_BEGIN_DECLS #define G_PASTE_TYPE_UPLOAD_KEYBINDING (g_paste_upload_keybinding_get_type ()) G_PASTE_FINAL_TYPE (UploadKeybinding, upload_keybinding, UPLOAD_KEYBINDING, GPasteKeybinding) GPasteKeybinding *g_paste_upload_keybinding_new (GPasteDaemon *daemon); G_END_DECLS #endif /*__G_PASTE_UPLOAD_KEYBINDING_H__*/ GPaste-3.18.6/src/libgpaste/libgpaste.sym000066400000000000000000000352011305131721400202370ustar00rootroot00000000000000LIBGPASTE_3_16_0 { global: g_paste_applet_about_get_type; g_paste_applet_about_new; g_paste_applet_app_indicator_get_type; g_paste_applet_app_indicator_new; g_paste_applet_get_active; g_paste_applet_get_type; g_paste_applet_icon_get_type; g_paste_applet_menu_get_type; g_paste_applet_menu_new; g_paste_applet_new_app_indicator; g_paste_applet_new_status_icon; g_paste_applet_quit_get_type; g_paste_applet_quit_new; g_paste_applet_set_active; g_paste_applet_status_icon_get_type; g_paste_applet_status_icon_new; g_paste_applet_ui_get_type; g_paste_applet_ui_new; g_paste_client_about; g_paste_client_about_finish; g_paste_client_about_sync; g_paste_client_add; g_paste_client_add_file; g_paste_client_add_file_finish; g_paste_client_add_file_sync; g_paste_client_add_finish; g_paste_client_add_password; g_paste_client_add_password_finish; g_paste_client_add_password_sync; g_paste_client_add_sync; g_paste_client_backup_history; g_paste_client_backup_history_finish; g_paste_client_backup_history_sync; g_paste_client_delete; g_paste_client_delete_finish; g_paste_client_delete_history; g_paste_client_delete_history_finish; g_paste_client_delete_history_sync; g_paste_client_delete_password; g_paste_client_delete_password_finish; g_paste_client_delete_password_sync; g_paste_client_delete_sync; g_paste_client_get_element; g_paste_client_get_element_finish; g_paste_client_get_element_sync; g_paste_client_get_history; g_paste_client_get_history_finish; g_paste_client_get_history_sync; g_paste_client_get_raw_element; g_paste_client_get_raw_element_finish; g_paste_client_get_raw_element_sync; g_paste_client_get_raw_history; g_paste_client_get_raw_history_finish; g_paste_client_get_raw_history_sync; g_paste_client_get_type; g_paste_client_get_version; g_paste_client_is_active; g_paste_client_list_histories; g_paste_client_list_histories_finish; g_paste_client_list_histories_sync; g_paste_client_merge; g_paste_client_merge_finish; g_paste_client_merge_sync; g_paste_client_new; g_paste_client_new_finish; g_paste_client_new_sync; g_paste_client_on_extension_state_changed; g_paste_client_on_extension_state_changed_finish; g_paste_client_on_extension_state_changed_sync; g_paste_client_reexecute; g_paste_client_reexecute_finish; g_paste_client_reexecute_sync; g_paste_client_rename_password; g_paste_client_rename_password_finish; g_paste_client_rename_password_sync; g_paste_client_search; g_paste_client_search_finish; g_paste_client_search_sync; g_paste_client_select; g_paste_client_select_finish; g_paste_client_select_sync; g_paste_client_set_password; g_paste_client_set_password_finish; g_paste_client_set_password_sync; g_paste_client_show_history; g_paste_client_show_history_finish; g_paste_client_show_history_sync; g_paste_client_switch_history; g_paste_client_switch_history_finish; g_paste_client_switch_history_sync; g_paste_client_track; g_paste_client_track_finish; g_paste_client_track_sync; g_paste_client_upload; g_paste_client_upload_finish; g_paste_client_upload_sync; g_paste_clipboard_bootstrap; g_paste_clipboard_get_image_checksum; g_paste_clipboard_get_real; g_paste_clipboard_get_target; g_paste_clipboard_get_text; g_paste_clipboard_get_type; g_paste_clipboard_new; g_paste_clipboard_select_item; g_paste_clipboard_select_text; g_paste_clipboard_set_image; g_paste_clipboard_set_text; g_paste_clipboards_manager_activate; g_paste_clipboards_manager_add_clipboard; g_paste_clipboards_manager_get_type; g_paste_clipboards_manager_new; g_paste_clipboards_manager_select; g_paste_clipboards_manager_sync_from_to; g_paste_daemon_get_type; g_paste_daemon_new; g_paste_daemon_show_history; g_paste_daemon_upload; g_paste_gnome_shell_client_get_type; g_paste_gnome_shell_client_grab_accelerator; g_paste_gnome_shell_client_grab_accelerator_finish; g_paste_gnome_shell_client_grab_accelerator_sync; g_paste_gnome_shell_client_grab_accelerators; g_paste_gnome_shell_client_grab_accelerators_finish; g_paste_gnome_shell_client_grab_accelerators_sync; g_paste_gnome_shell_client_new; g_paste_gnome_shell_client_new_finish; g_paste_gnome_shell_client_new_sync; g_paste_gnome_shell_client_ungrab_accelerator; g_paste_gnome_shell_client_ungrab_accelerator_finish; g_paste_gnome_shell_client_ungrab_accelerator_sync; g_paste_history_add; g_paste_history_delete_password; g_paste_history_dup; g_paste_history_empty; g_paste_history_get; g_paste_history_get_display_string; g_paste_history_get_history; g_paste_history_get_length; g_paste_history_get_password; g_paste_history_get_type; g_paste_history_get_value; g_paste_history_list; g_paste_history_new; g_paste_history_remove; g_paste_history_rename_password; g_paste_history_search; g_paste_history_select; g_paste_history_set_password; g_paste_history_switch; g_paste_image_item_get_checksum; g_paste_image_item_get_date; g_paste_image_item_get_image; g_paste_image_item_get_type; g_paste_image_item_new; g_paste_image_item_new_from_file; g_paste_item_equals; g_paste_item_get_display_string; g_paste_item_get_kind; g_paste_item_get_real_value; g_paste_item_get_size; g_paste_item_get_type; g_paste_item_get_value; g_paste_keybinder_activate_all; g_paste_keybinder_add_keybinding; g_paste_keybinder_deactivate_all; g_paste_keybinder_get_type; g_paste_keybinder_new; g_paste_keybinding_activate; g_paste_keybinding_deactivate; g_paste_keybinding_get_accelerator; g_paste_keybinding_get_dconf_key; g_paste_keybinding_get_keycodes; g_paste_keybinding_get_modifiers; g_paste_keybinding_get_type; g_paste_keybinding_is_active; g_paste_keybinding_notify; g_paste_keybinding_perform; g_paste_make_password_keybinding_get_type; g_paste_make_password_keybinding_new; g_paste_password_item_get_name; g_paste_password_item_get_type; g_paste_password_item_new; g_paste_password_item_set_name; g_paste_pop_keybinding_get_type; g_paste_pop_keybinding_new; g_paste_screensaver_client_get_type; g_paste_screensaver_client_new; g_paste_screensaver_client_new_finish; g_paste_screensaver_client_new_sync; g_paste_settings_get_element_size; g_paste_settings_get_extension_enabled; g_paste_settings_get_growing_lines; g_paste_settings_get_history_name; g_paste_settings_get_images_support; g_paste_settings_get_make_password; g_paste_settings_get_max_displayed_history_size; g_paste_settings_get_max_history_size; g_paste_settings_get_max_memory_usage; g_paste_settings_get_max_text_item_size; g_paste_settings_get_min_text_item_size; g_paste_settings_get_pop; g_paste_settings_get_primary_to_history; g_paste_settings_get_save_history; g_paste_settings_get_show_history; g_paste_settings_get_sync_clipboard_to_primary; g_paste_settings_get_sync_primary_to_clipboard; g_paste_settings_get_synchronize_clipboards; g_paste_settings_get_track_changes; g_paste_settings_get_track_extension_state; g_paste_settings_get_trim_items; g_paste_settings_get_type; g_paste_settings_new; g_paste_settings_reset_element_size; g_paste_settings_reset_growing_lines; g_paste_settings_reset_history_name; g_paste_settings_reset_images_support; g_paste_settings_reset_make_password; g_paste_settings_reset_max_displayed_history_size; g_paste_settings_reset_max_history_size; g_paste_settings_reset_max_memory_usage; g_paste_settings_reset_max_text_item_size; g_paste_settings_reset_min_text_item_size; g_paste_settings_reset_pop; g_paste_settings_reset_primary_to_history; g_paste_settings_reset_save_history; g_paste_settings_reset_show_history; g_paste_settings_reset_sync_clipboard_to_primary; g_paste_settings_reset_sync_primary_to_clipboard; g_paste_settings_reset_synchronize_clipboards; g_paste_settings_reset_track_changes; g_paste_settings_reset_track_extension_state; g_paste_settings_reset_trim_items; g_paste_settings_set_element_size; g_paste_settings_set_extension_enabled; g_paste_settings_set_growing_lines; g_paste_settings_set_history_name; g_paste_settings_set_images_support; g_paste_settings_set_make_password; g_paste_settings_set_max_displayed_history_size; g_paste_settings_set_max_history_size; g_paste_settings_set_max_memory_usage; g_paste_settings_set_max_text_item_size; g_paste_settings_set_min_text_item_size; g_paste_settings_set_pop; g_paste_settings_set_primary_to_history; g_paste_settings_set_save_history; g_paste_settings_set_show_history; g_paste_settings_set_sync_clipboard_to_primary; g_paste_settings_set_sync_primary_to_clipboard; g_paste_settings_set_synchronize_clipboards; g_paste_settings_set_track_changes; g_paste_settings_set_track_extension_state; g_paste_settings_set_trim_items; g_paste_settings_ui_panel_add_boolean_setting; g_paste_settings_ui_panel_add_range_setting; g_paste_settings_ui_panel_add_separator; g_paste_settings_ui_panel_add_text_setting; g_paste_settings_ui_panel_get_type; g_paste_settings_ui_panel_new; g_paste_settings_ui_stack_add_panel; g_paste_settings_ui_stack_fill; g_paste_settings_ui_stack_get_type; g_paste_settings_ui_stack_new; g_paste_settings_ui_widget_get_stack; g_paste_settings_ui_widget_get_type; g_paste_settings_ui_widget_new; g_paste_show_history_keybinding_get_type; g_paste_show_history_keybinding_new; g_paste_sync_clipboard_to_primary_keybinding_get_type; g_paste_sync_clipboard_to_primary_keybinding_new; g_paste_sync_primary_to_clipboard_keybinding_get_type; g_paste_sync_primary_to_clipboard_keybinding_new; g_paste_text_item_get_type; g_paste_text_item_new; g_paste_ui_about_get_type; g_paste_ui_about_new; g_paste_ui_empty_item_get_type; g_paste_ui_header_get_type; g_paste_ui_header_new; g_paste_ui_history_get_type; g_paste_ui_item_activate; g_paste_ui_item_get_type; g_paste_ui_item_new; g_paste_ui_item_refresh; g_paste_ui_item_set_index; g_paste_ui_keybinding_get_type; g_paste_ui_keybinding_new; g_paste_ui_settings_get_type; g_paste_ui_settings_new; g_paste_ui_switch_get_type; g_paste_ui_switch_new; g_paste_ui_window_get_type; g_paste_ui_window_new; g_paste_update_action_get_type; g_paste_update_target_get_type; g_paste_upload_keybinding_get_type; g_paste_upload_keybinding_new; g_paste_uris_item_get_type; g_paste_uris_item_get_uris; g_paste_uris_item_new; g_paste_util_compute_checksum; g_paste_util_confirm_dialog; g_paste_util_has_applet; g_paste_util_has_unity; g_paste_util_replace; g_paste_util_show_win; g_paste_util_spawn; g_paste_util_spawn_sync; local: *; }; LIBGPASTE_3_18_0 { global: g_paste_applet_icon_activate; g_paste_applet_icon_new; g_paste_bus_get_connection; g_paste_bus_get_type; g_paste_bus_new; g_paste_bus_own_name; g_paste_bus_object_get_type; g_paste_bus_object_new; g_paste_bus_object_register_on_connection; g_paste_client_empty_history; g_paste_client_empty_history_finish; g_paste_client_empty_history_sync; g_paste_client_get_element_kind; g_paste_client_get_element_kind_finish; g_paste_client_get_element_kind_sync; g_paste_client_get_elements; g_paste_client_get_elements_finish; g_paste_client_get_elements_sync; g_paste_client_get_history_name; g_paste_client_get_history_name_finish; g_paste_client_get_history_name_sync; g_paste_client_get_history_size; g_paste_client_get_history_size_finish; g_paste_client_get_history_size_sync; g_paste_client_replace; g_paste_client_replace_finish; g_paste_client_replace_sync; g_paste_clipboard_clear; g_paste_clipboard_ensure_not_empty; g_paste_history_delete; g_paste_history_get_current; g_paste_history_load; g_paste_history_replace; g_paste_history_save; g_paste_item_add_size; g_paste_item_new; g_paste_item_remove_size; g_paste_item_set_display_string; g_paste_item_set_size; g_paste_item_kind_get_type; g_paste_keybinding_new; g_paste_search_provider_get_type; g_paste_search_provider_new; g_paste_ui_backup_history_get_type; g_paste_ui_backup_history_new; g_paste_ui_delete_history_get_type; g_paste_ui_delete_history_new; g_paste_ui_delete_item_get_type; g_paste_ui_delete_item_new; g_paste_ui_edit_item_get_type; g_paste_ui_edit_item_new; g_paste_ui_empty_history_get_type; g_paste_ui_empty_history_new; g_paste_ui_empty_item_new; g_paste_ui_header_get_search_button; g_paste_ui_header_show_prefs; g_paste_ui_history_search; g_paste_ui_history_action_get_type; g_paste_ui_history_action_new; g_paste_ui_history_action_set_history; g_paste_ui_history_actions_get_type; g_paste_ui_history_actions_new; g_paste_ui_history_actions_set_relative_to; g_paste_ui_history_new; g_paste_ui_item_action_get_type; g_paste_ui_item_action_new; g_paste_ui_item_action_set_index; g_paste_ui_item_skeleton_get_label; g_paste_ui_item_skeleton_get_type; g_paste_ui_item_skeleton_new; g_paste_ui_item_skeleton_set_activatable; g_paste_ui_item_skeleton_set_editable; g_paste_ui_item_skeleton_set_index; g_paste_ui_item_skeleton_set_markup; g_paste_ui_item_skeleton_set_text; g_paste_ui_panel_get_type; g_paste_ui_panel_new; g_paste_ui_panel_history_activate; g_paste_ui_panel_history_get_history; g_paste_ui_panel_history_get_type; g_paste_ui_panel_history_new; g_paste_ui_panel_history_set_length; g_paste_ui_panel_update_history_length; g_paste_ui_reexec_get_type; g_paste_ui_reexec_new; g_paste_ui_search_bar_get_entry; g_paste_ui_search_bar_get_type; g_paste_ui_search_bar_new; g_paste_ui_search_get_type; g_paste_ui_search_new; g_paste_ui_upload_item_get_type; g_paste_ui_upload_item_new; g_paste_ui_window_search; g_paste_ui_window_show_prefs; g_paste_util_activate_ui; g_paste_util_activate_ui_sync; g_paste_util_get_dbus_at_result; g_paste_util_get_dbus_au_result; } LIBGPASTE_3_16_0; GPaste-3.18.6/src/libgpaste/screensaver-client/000077500000000000000000000000001305131721400213265ustar00rootroot00000000000000GPaste-3.18.6/src/libgpaste/screensaver-client/gpaste-screensaver-client.c000066400000000000000000000131131305131721400265460ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include "gpaste-gdbus-macros.h" #include #define G_PASTE_SCREENSAVER_OBJECT_PATH "/org/gnome/ScreenSaver" #define G_PASTE_SCREENSAVER_INTERFACE_NAME "org.gnome.ScreenSaver" #define G_PASTE_SCREENSAVER_SIG_ACTIVE_CHANGED "ActiveChanged" #define G_PASTE_SCREENSAVER_INTERFACE \ "" \ "" \ "" \ "" \ "" \ "" \ "" struct _GPasteScreensaverClient { GDBusProxy parent_instance; }; G_DEFINE_TYPE (GPasteScreensaverClient, g_paste_screensaver_client, G_TYPE_DBUS_PROXY) enum { ACTIVE_CHANGED, LAST_SIGNAL }; static guint64 signals[LAST_SIGNAL] = { 0 }; static void g_paste_screensaver_client_g_signal (GDBusProxy *proxy, const gchar *sender_name G_GNUC_UNUSED, const gchar *signal_name, GVariant *parameters) { GPasteScreensaverClient *self = G_PASTE_SCREENSAVER_CLIENT (proxy); if (!g_strcmp0 (signal_name, G_PASTE_SCREENSAVER_SIG_ACTIVE_CHANGED)) { GVariantIter params_iter; g_variant_iter_init (¶ms_iter, parameters); g_autoptr (GVariant) value = g_variant_iter_next_value (¶ms_iter); g_signal_emit (self, signals[ACTIVE_CHANGED], 0, /* detail */ g_variant_get_boolean (value), NULL); } } static void g_paste_screensaver_client_class_init (GPasteScreensaverClientClass *klass G_GNUC_UNUSED) { G_DBUS_PROXY_CLASS (klass)->g_signal = g_paste_screensaver_client_g_signal; /** * GPasteScreensaverClient::active-changed: * @screensaver: the object on which the signal was emitted * @active: whether the screensaver is now active or not * * The "active-changed" signal is emitted when the screensaver appears or vanishes */ signals[ACTIVE_CHANGED] = g_signal_new ("active-changed", G_PASTE_TYPE_SCREENSAVER_CLIENT, G_SIGNAL_RUN_LAST, 0, /* class offset */ NULL, /* accumulator */ NULL, /* accumulator data */ g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); } static void g_paste_screensaver_client_init (GPasteScreensaverClient *self) { GDBusProxy *proxy = G_DBUS_PROXY (self); g_autoptr (GDBusNodeInfo) screensaver_dbus_info = g_dbus_node_info_new_for_xml (G_PASTE_SCREENSAVER_INTERFACE, NULL); /* Error */ g_dbus_proxy_set_interface_info (proxy, screensaver_dbus_info->interfaces[0]); } /** * g_paste_screensaver_client_new_sync: * @error: Return location for error or %NULL. * * Create a new instance of #GPasteScreensaverClient * * Returns: a newly allocated #GPasteScreensaverClient * free it with g_object_unref */ G_PASTE_VISIBLE GPasteScreensaverClient * g_paste_screensaver_client_new_sync (GError **error) { CUSTOM_PROXY_NEW (SCREENSAVER_CLIENT, SCREENSAVER, G_PASTE_SCREENSAVER_BUS_NAME); } /** * g_paste_screensaver_client_new: * @callback: Callback function to invoke when the proxy is ready. * @user_data: User data to pass to @callback. * * Create a new instance of #GPasteScreensaverClient * * Returns: */ G_PASTE_VISIBLE void g_paste_screensaver_client_new (GAsyncReadyCallback callback, gpointer user_data) { CUSTOM_PROXY_NEW_ASYNC (SCREENSAVER_CLIENT, SCREENSAVER, G_PASTE_SCREENSAVER_BUS_NAME); } /** * g_paste_screensaver_client_new_finsh: * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback function passed to the async ctor. * @error: Return location for error or %NULL. * * Create a new instance of #GPasteScreensaverClient * * Returns: a newly allocated #GPasteScreensaverClient * free it with g_object_unref */ G_PASTE_VISIBLE GPasteScreensaverClient * g_paste_screensaver_client_new_finish (GAsyncResult *result, GError **error) { CUSTOM_PROXY_NEW_FINISH (SCREENSAVER_CLIENT); } GPaste-3.18.6/src/libgpaste/screensaver-client/gpaste-screensaver-client.h000066400000000000000000000034161305131721400265600ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_SCREENSAVER_CLIENT_H__ #define __G_PASTE_SCREENSAVER_CLIENT_H__ #include G_BEGIN_DECLS #define G_PASTE_SCREENSAVER_BUS_NAME "org.gnome.ScreenSaver" #define G_PASTE_TYPE_SCREENSAVER_CLIENT (g_paste_screensaver_client_get_type ()) G_PASTE_FINAL_TYPE (ScreensaverClient, screensaver_client, SCREENSAVER_CLIENT, GDBusProxy) GPasteScreensaverClient *g_paste_screensaver_client_new_sync (GError **error); void g_paste_screensaver_client_new (GAsyncReadyCallback callback, gpointer user_data); GPasteScreensaverClient *g_paste_screensaver_client_new_finish (GAsyncResult *result, GError **error); G_END_DECLS #endif /*__G_PASTE_SCREENSAVER_CLIENT_H__*/ GPaste-3.18.6/src/libgpaste/settings-ui/000077500000000000000000000000001305131721400200055ustar00rootroot00000000000000GPaste-3.18.6/src/libgpaste/settings-ui/gpaste-settings-ui-panel.c000066400000000000000000000277521305131721400250170ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2013-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include struct _GPasteSettingsUiPanel { GtkGrid parent_instance; }; typedef struct { GSList *callback_data; guint64 current_line; } GPasteSettingsUiPanelPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteSettingsUiPanel, g_paste_settings_ui_panel, GTK_TYPE_GRID) #define CALLBACK_DATA(w) \ GPasteSettingsUiPanelPrivate *priv = g_paste_settings_ui_panel_get_instance_private (self); \ _CallbackDataWrapper *_data = (_CallbackDataWrapper *) g_malloc0 (sizeof (_CallbackDataWrapper)); \ CallbackDataWrapper *data = (CallbackDataWrapper *) _data; \ priv->callback_data = g_slist_prepend (priv->callback_data, _data); \ _data->widget = GTK_WIDGET (w); \ data->callback = G_CALLBACK (on_value_changed); \ data->reset_cb = on_reset; \ data->custom_data = user_data; #define G_PASTE_CALLBACK(cb_type) \ CallbackDataWrapper *data = (CallbackDataWrapper *) user_data; \ ((cb_type) data->callback) #define G_PASTE_RESET_CALLBACK() \ CallbackDataWrapper *data = (CallbackDataWrapper *) user_data; \ (data->reset_cb) typedef struct { GCallback callback; GPasteResetCallback reset_cb; gpointer custom_data; } CallbackDataWrapper; typedef struct { CallbackDataWrapper wrap; GtkWidget *widget; GtkWidget *reset_widget; gulong signal; gulong reset_signal; } _CallbackDataWrapper; static void boolean_wrapper (GObject *object, GParamSpec *pspec G_GNUC_UNUSED, gpointer user_data) { G_PASTE_CALLBACK (GPasteBooleanCallback) (gtk_switch_get_active (GTK_SWITCH (object)), data->custom_data); } static GtkLabel * g_paste_settings_ui_panel_add_label (GPasteSettingsUiPanel *self, const gchar *label) { GtkWidget *button_label = gtk_widget_new (GTK_TYPE_LABEL, "label", label, "xalign", 0.0, NULL); GPasteSettingsUiPanelPrivate *priv = g_paste_settings_ui_panel_get_instance_private (self); gtk_widget_set_hexpand (button_label, TRUE); gtk_grid_attach (GTK_GRID (self), button_label, 0, priv->current_line++, 1, 1); return GTK_LABEL (button_label); } static gboolean g_paste_settings_ui_panel_on_reset_pressed (GtkWidget *widget G_GNUC_UNUSED, GdkEventButton *event G_GNUC_UNUSED, gpointer user_data) { G_PASTE_RESET_CALLBACK () (data->custom_data); return FALSE; } static GtkWidget * g_paste_settings_ui_panel_make_reset_button (_CallbackDataWrapper *data) { data->reset_widget = gtk_button_new_from_icon_name ("edit-delete-symbolic", GTK_ICON_SIZE_BUTTON); data->reset_signal = g_signal_connect (data->reset_widget, "button-press-event", G_CALLBACK (g_paste_settings_ui_panel_on_reset_pressed), data); if (!((CallbackDataWrapper *) data)->reset_cb) gtk_widget_set_sensitive (data->reset_widget, FALSE); return data->reset_widget; } /** * g_paste_settings_ui_panel_add_boolean_setting: * @self: a #GPasteSettingsUiPanel instance * @label: the label to display * @value: the deafault value * @on_value_changed: (closure user_data) (scope notified): the callback to call when the value changes * @on_reset: (closure user_data) (scope notified): the callback to call when the value is reset * * Add a new boolean settings to the current pane * * Returns: (transfer none): the #GtkSwitch we just added */ G_PASTE_VISIBLE GtkSwitch * g_paste_settings_ui_panel_add_boolean_setting (GPasteSettingsUiPanel *self, const gchar *label, gboolean value, GPasteBooleanCallback on_value_changed, GPasteResetCallback on_reset, gpointer user_data) { GtkGrid *grid = GTK_GRID (self); GtkLabel *button_label = g_paste_settings_ui_panel_add_label (self, label); GtkWidget *widget = gtk_switch_new (); GtkSwitch *sw = GTK_SWITCH (widget); CALLBACK_DATA (widget); gtk_switch_set_active (sw, value); _data->signal = g_signal_connect (widget, "notify::active", G_CALLBACK (boolean_wrapper), data); gtk_grid_attach_next_to (grid, widget, GTK_WIDGET (button_label), GTK_POS_RIGHT, 1, 1); gtk_grid_attach_next_to (grid, g_paste_settings_ui_panel_make_reset_button (_data), widget, GTK_POS_RIGHT, 1, 1); return sw; } /** * g_paste_settings_ui_panel_add_separator: * @self: a #GPasteSettingsUiPanel instance * * Add a new separator to the current pane * * Returns: */ G_PASTE_VISIBLE void g_paste_settings_ui_panel_add_separator (GPasteSettingsUiPanel *self) { GPasteSettingsUiPanelPrivate *priv = g_paste_settings_ui_panel_get_instance_private (self); gtk_grid_attach (GTK_GRID (self), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), 0, priv->current_line++, 3, 1); } static void range_wrapper (GtkSpinButton *spinbutton, gpointer user_data) { G_PASTE_CALLBACK (GPasteRangeCallback) (gtk_spin_button_get_value (spinbutton), data->custom_data); } /** * g_paste_settings_ui_panel_add_range_setting: * @self: a #GPasteSettingsUiPanel instance * @label: the label to display * @value: the deafault value * @min: the minimal authorized value * @max: the maximal authorized value * @step: the step between proposed values * @on_value_changed: (closure user_data) (scope notified): the callback to call when the value changes * @on_reset: (closure user_data) (scope notified): the callback to call when the value is reset * * Add a new boolean settings to the current pane * * Returns: (transfer none): the #GtkSpinButton we just added */ G_PASTE_VISIBLE GtkSpinButton * g_paste_settings_ui_panel_add_range_setting (GPasteSettingsUiPanel *self, const gchar *label, gdouble value, gdouble min, gdouble max, gdouble step, GPasteRangeCallback on_value_changed, GPasteResetCallback on_reset, gpointer user_data) { GtkGrid *grid = GTK_GRID (self); GtkLabel *button_label = g_paste_settings_ui_panel_add_label (self, label); GtkWidget *button = gtk_spin_button_new_with_range (min, max, step); GtkSpinButton *b = GTK_SPIN_BUTTON (button); CALLBACK_DATA (button); gtk_widget_set_hexpand (button, TRUE); gtk_spin_button_set_value (b, value); _data->signal = g_signal_connect (GTK_SPIN_BUTTON (button), "value-changed", G_CALLBACK (range_wrapper), data); gtk_grid_attach_next_to (grid, button, GTK_WIDGET (button_label), GTK_POS_RIGHT, 1, 1); gtk_grid_attach_next_to (grid, g_paste_settings_ui_panel_make_reset_button (_data), button, GTK_POS_RIGHT, 1, 1); return b; } static void text_wrapper (GtkEditable *editable, gpointer user_data) { G_PASTE_CALLBACK (GPasteTextCallback) (gtk_entry_get_text (GTK_ENTRY (editable)), data->custom_data); } /** * g_paste_settings_ui_panel_add_text_setting: * @self: a #GPasteSettingsUiPanel instance * @label: the label to display * @value: the deafault value * @on_value_changed: (closure user_data) (scope notified): the callback to call when the value changes * @on_reset: (closure user_data) (scope notified): the callback to call when the value is reset * * Add a new text settings to the current pane * * Returns: (transfer none): the #GtkEntry we just added */ G_PASTE_VISIBLE GtkEntry * g_paste_settings_ui_panel_add_text_setting (GPasteSettingsUiPanel *self, const gchar *label, const gchar *value, GPasteTextCallback on_value_changed, GPasteResetCallback on_reset, gpointer user_data) { GtkGrid *grid = GTK_GRID (self); GtkLabel *entry_label = g_paste_settings_ui_panel_add_label (self, label); GtkWidget *entry = gtk_entry_new (); GtkEntry *e = GTK_ENTRY (entry); CALLBACK_DATA (entry); gtk_widget_set_hexpand (entry, TRUE); gtk_entry_set_text (e, value); _data->signal = g_signal_connect (GTK_EDITABLE (entry), "changed", G_CALLBACK (text_wrapper), data); gtk_grid_attach_next_to (GTK_GRID (self), entry, GTK_WIDGET (entry_label), GTK_POS_RIGHT, 1, 1); if (on_reset) gtk_grid_attach_next_to (grid, g_paste_settings_ui_panel_make_reset_button (_data), entry, GTK_POS_RIGHT, 1, 1); return e; } static void clean_callback_data (gpointer data, gpointer user_data G_GNUC_UNUSED) { g_autofree _CallbackDataWrapper *wrap = data; g_signal_handler_disconnect (wrap->widget, wrap->signal); if (wrap->reset_widget) g_signal_handler_disconnect (wrap->reset_widget, wrap->reset_signal); } static void g_paste_settings_ui_panel_dispose (GObject *object) { GPasteSettingsUiPanelPrivate *priv = g_paste_settings_ui_panel_get_instance_private (G_PASTE_SETTINGS_UI_PANEL (object)); g_slist_foreach (priv->callback_data, clean_callback_data, NULL); g_slist_free (priv->callback_data); priv->callback_data = NULL; G_OBJECT_CLASS (g_paste_settings_ui_panel_parent_class)->dispose (object); } static void g_paste_settings_ui_panel_class_init (GPasteSettingsUiPanelClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_settings_ui_panel_dispose; } static void g_paste_settings_ui_panel_init (GPasteSettingsUiPanel *self) { GPasteSettingsUiPanelPrivate *priv = g_paste_settings_ui_panel_get_instance_private (self); priv->callback_data = NULL; priv->current_line = 0; GtkGrid *grid = GTK_GRID (self); gtk_grid_set_column_spacing (grid, 10); gtk_grid_set_row_spacing (grid, 10); } /** * g_paste_settings_ui_panel_new: * * Create a new instance of #GPasteSettingsUiPanel * * Returns: a newly allocated #GPasteSettingsUiPanel * free it with g_object_unref */ G_PASTE_VISIBLE GPasteSettingsUiPanel * g_paste_settings_ui_panel_new (void) { return G_PASTE_SETTINGS_UI_PANEL (gtk_widget_new (G_PASTE_TYPE_SETTINGS_UI_PANEL, NULL)); } GPaste-3.18.6/src/libgpaste/settings-ui/gpaste-settings-ui-panel.h000066400000000000000000000072461305131721400250200ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2013-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_SETTINGS_UI_PANEL_H__ #define __G_PASTE_SETTINGS_UI_PANEL_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_SETTINGS_UI_PANEL (g_paste_settings_ui_panel_get_type ()) G_PASTE_FINAL_TYPE (SettingsUiPanel, settings_ui_panel, SETTINGS_UI_PANEL, GtkGrid) typedef void (*GPasteBooleanCallback) (gboolean data, gpointer user_data); typedef void (*GPasteRangeCallback) (gdouble data, gpointer user_data); typedef void (*GPasteTextCallback) (const gchar *data, gpointer user_data); typedef void (*GPasteResetCallback) (gpointer user_data); GtkSwitch *g_paste_settings_ui_panel_add_boolean_setting (GPasteSettingsUiPanel *self, const gchar *label, gboolean value, GPasteBooleanCallback on_value_changed, GPasteResetCallback on_reset, gpointer user_data); void g_paste_settings_ui_panel_add_separator (GPasteSettingsUiPanel *self); GtkSpinButton *g_paste_settings_ui_panel_add_range_setting (GPasteSettingsUiPanel *self, const gchar *label, gdouble value, gdouble min, gdouble max, gdouble step, GPasteRangeCallback on_value_changed, GPasteResetCallback on_reset, gpointer user_data); GtkEntry *g_paste_settings_ui_panel_add_text_setting (GPasteSettingsUiPanel *self, const gchar *label, const gchar *value, GPasteTextCallback on_value_changed, GPasteResetCallback on_reset, gpointer user_data); GPasteSettingsUiPanel *g_paste_settings_ui_panel_new (void); G_END_DECLS #endif /*__G_PASTE_SETTINGS_UI_PANEL_H__*/ GPaste-3.18.6/src/libgpaste/settings-ui/gpaste-settings-ui-stack.c000066400000000000000000000731011305131721400250120ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2013-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include #include struct _GPasteSettingsUiStack { GtkStack parent_instance; }; typedef struct { GPasteClient *client; GPasteSettings *settings; GError *init_error; GtkSwitch *images_support_switch; GtkSwitch *growing_lines_switch; GtkSwitch *primary_to_history_switch; GtkSwitch *save_history_switch; GtkSwitch *synchronize_clipboards_switch; GtkSwitch *track_changes_switch; GtkSwitch *trim_items_switch; GtkSpinButton *element_size_button; GtkSpinButton *max_displayed_history_size_button; GtkSpinButton *max_history_size_button; GtkSpinButton *max_memory_usage_button; GtkSpinButton *max_text_item_size_button; GtkSpinButton *min_text_item_size_button; GtkEntry *launch_ui_entry; GtkEntry *make_password_entry; GtkEntry *pop_entry; GtkEntry *show_history_entry; GtkEntry *sync_clipboard_to_primary_entry; GtkEntry *sync_primary_to_clipboard_entry; GtkEntry *upload_entry; gchar ***actions; GtkSwitch *extension_enabled_switch; GtkSwitch *track_extension_state_switch; gulong settings_signal; } GPasteSettingsUiStackPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteSettingsUiStack, g_paste_settings_ui_stack, GTK_TYPE_STACK) #define SETTING_CALLBACK_FULL(setting, type, cast) \ static void \ setting##_callback (type value, \ gpointer user_data) \ { \ g_paste_settings_set_##setting (G_PASTE_SETTINGS (user_data), value); \ } #define SETTING_CALLBACK(setting, type) SETTING_CALLBACK_FULL (setting, type, type) #define BOOLEAN_CALLBACK(setting) SETTING_CALLBACK (setting, gboolean) #define STRING_CALLBACK(setting) SETTING_CALLBACK (setting, const gchar *) #define UINT64_CALLBACK(setting) SETTING_CALLBACK_FULL (setting, gdouble, uint64) /** * g_paste_settings_ui_stack_add_panel: * @self: a #GPasteSettingsUiStack instance * @name: the name of the panel * @label: the label to display * @panel: (transfer none): the #GPasteSettingsUiPanel to add * * Add a new panel to the #GPasteSettingsUiStack * * Returns: */ G_PASTE_VISIBLE void g_paste_settings_ui_stack_add_panel (GPasteSettingsUiStack *self, const gchar *name, const gchar *label, GPasteSettingsUiPanel *panel) { g_return_if_fail (G_PASTE_IS_SETTINGS_UI_STACK (self)); gtk_stack_add_titled (GTK_STACK (self), GTK_WIDGET (panel), name, label); } BOOLEAN_CALLBACK (growing_lines) BOOLEAN_CALLBACK (images_support) BOOLEAN_CALLBACK (primary_to_history) BOOLEAN_CALLBACK (save_history) BOOLEAN_CALLBACK (synchronize_clipboards) BOOLEAN_CALLBACK (track_changes) BOOLEAN_CALLBACK (trim_items) #ifdef ENABLE_EXTENSION BOOLEAN_CALLBACK (extension_enabled) BOOLEAN_CALLBACK (track_extension_state) #endif static GPasteSettingsUiPanel * g_paste_settings_ui_stack_private_make_behaviour_panel (GPasteSettingsUiStackPrivate *priv) { GPasteSettings *settings = priv->settings; GPasteSettingsUiPanel *panel = g_paste_settings_ui_panel_new (); priv->track_changes_switch = g_paste_settings_ui_panel_add_boolean_setting (panel, _("Track clipboard changes"), g_paste_settings_get_track_changes (settings), track_changes_callback, (GPasteResetCallback) g_paste_settings_reset_track_changes, settings); #ifdef ENABLE_EXTENSION priv->extension_enabled_switch = g_paste_settings_ui_panel_add_boolean_setting (panel, _("Enable the gnome-shell extension"), g_paste_settings_get_extension_enabled (settings), extension_enabled_callback, NULL, settings); priv->track_extension_state_switch = g_paste_settings_ui_panel_add_boolean_setting (panel, _("Sync the daemon state with the extension's one"), g_paste_settings_get_track_extension_state (settings), track_extension_state_callback, (GPasteResetCallback) g_paste_settings_reset_track_extension_state, settings); #endif g_paste_settings_ui_panel_add_separator (panel); priv->primary_to_history_switch = g_paste_settings_ui_panel_add_boolean_setting (panel, _("Primary selection affects history"), g_paste_settings_get_primary_to_history (settings), primary_to_history_callback, (GPasteResetCallback) g_paste_settings_reset_primary_to_history, settings); priv->synchronize_clipboards_switch = g_paste_settings_ui_panel_add_boolean_setting (panel, _("Synchronize clipboard with primary selection"), g_paste_settings_get_synchronize_clipboards (settings), synchronize_clipboards_callback, (GPasteResetCallback) g_paste_settings_reset_synchronize_clipboards, settings); g_paste_settings_ui_panel_add_separator (panel); priv->images_support_switch = g_paste_settings_ui_panel_add_boolean_setting (panel, _("Images support"), g_paste_settings_get_images_support (settings), images_support_callback, (GPasteResetCallback) g_paste_settings_reset_images_support, settings); priv->trim_items_switch = g_paste_settings_ui_panel_add_boolean_setting (panel, _("Trim items"), g_paste_settings_get_trim_items (settings), trim_items_callback, (GPasteResetCallback) g_paste_settings_reset_trim_items, settings); priv->growing_lines_switch = g_paste_settings_ui_panel_add_boolean_setting (panel, _("Detect growing lines"), g_paste_settings_get_growing_lines (settings), growing_lines_callback, (GPasteResetCallback) g_paste_settings_reset_growing_lines, settings); g_paste_settings_ui_panel_add_separator (panel); priv->save_history_switch = g_paste_settings_ui_panel_add_boolean_setting (panel, _("Save history"), g_paste_settings_get_save_history (settings), save_history_callback, (GPasteResetCallback) g_paste_settings_reset_save_history, settings); return panel; } UINT64_CALLBACK (element_size) UINT64_CALLBACK (max_displayed_history_size) UINT64_CALLBACK (max_history_size) UINT64_CALLBACK (max_memory_usage) UINT64_CALLBACK (max_text_item_size) UINT64_CALLBACK (min_text_item_size) static GPasteSettingsUiPanel * g_paste_settings_ui_stack_private_make_history_settings_panel (GPasteSettingsUiStackPrivate *priv) { GPasteSettings *settings = priv->settings; GPasteSettingsUiPanel *panel = g_paste_settings_ui_panel_new (); priv->element_size_button = g_paste_settings_ui_panel_add_range_setting (panel, _("Max element size when displaying: "), (gdouble) g_paste_settings_get_element_size (settings), 0, 511, 5, element_size_callback, (GPasteResetCallback) g_paste_settings_reset_element_size, settings); priv->max_displayed_history_size_button = g_paste_settings_ui_panel_add_range_setting (panel, _("Max displayed history size: "), (gdouble) g_paste_settings_get_max_displayed_history_size (settings), 10, 255, 5, max_displayed_history_size_callback, (GPasteResetCallback) g_paste_settings_reset_max_displayed_history_size, settings); priv->max_history_size_button = g_paste_settings_ui_panel_add_range_setting (panel, _("Max history size: "), (gdouble) g_paste_settings_get_max_history_size (settings), 100, 65535, 5, max_history_size_callback, (GPasteResetCallback) g_paste_settings_reset_max_history_size, settings); priv->max_memory_usage_button = g_paste_settings_ui_panel_add_range_setting (panel, _("Max memory usage (MB): "), (gdouble) g_paste_settings_get_max_memory_usage (settings), 5, 16383, 5, max_memory_usage_callback, (GPasteResetCallback) g_paste_settings_reset_max_memory_usage, settings); priv->max_text_item_size_button = g_paste_settings_ui_panel_add_range_setting (panel, _("Max text item length: "), (gdouble) g_paste_settings_get_max_text_item_size (settings), 1, G_MAXUINT64, 1, max_text_item_size_callback, (GPasteResetCallback) g_paste_settings_reset_max_text_item_size, settings); priv->min_text_item_size_button = g_paste_settings_ui_panel_add_range_setting (panel, _("Min text item length: "), (gdouble) g_paste_settings_get_min_text_item_size (settings), 1, 65535, 1, min_text_item_size_callback, (GPasteResetCallback) g_paste_settings_reset_min_text_item_size, settings); return panel; } STRING_CALLBACK (launch_ui) STRING_CALLBACK (make_password) STRING_CALLBACK (pop) STRING_CALLBACK (show_history) STRING_CALLBACK (sync_clipboard_to_primary) STRING_CALLBACK (sync_primary_to_clipboard) STRING_CALLBACK (upload) static GPasteSettingsUiPanel * g_paste_settings_ui_stack_private_make_keybindings_panel (GPasteSettingsUiStackPrivate *priv) { GPasteSettings *settings = priv->settings; GPasteSettingsUiPanel *panel = g_paste_settings_ui_panel_new (); /* translators: Keyboard shortcut to delete the active item from history */ priv->pop_entry = g_paste_settings_ui_panel_add_text_setting (panel, _("Delete the active item from history: "), g_paste_settings_get_pop (settings), pop_callback, (GPasteResetCallback) g_paste_settings_reset_pop, settings); /* translators: Keyboard shortcut to launch the graphical tool */ priv->launch_ui_entry = g_paste_settings_ui_panel_add_text_setting (panel, _("Launch the graphical tool: "), g_paste_settings_get_launch_ui (settings), launch_ui_callback, (GPasteResetCallback) g_paste_settings_reset_launch_ui, settings); /* translators: Keyboard shortcut to mark the active item as being a password */ priv->make_password_entry = g_paste_settings_ui_panel_add_text_setting (panel, _("Mark the active item as being a password: "), g_paste_settings_get_make_password (settings), make_password_callback, (GPasteResetCallback) g_paste_settings_reset_make_password, settings); /* translators: Keyboard shortcut to display the history */ priv->show_history_entry = g_paste_settings_ui_panel_add_text_setting (panel, _("Display the history: "), g_paste_settings_get_show_history (settings), show_history_callback, (GPasteResetCallback) g_paste_settings_reset_show_history, settings); /* translators: Keyboard shortcut to sync the clipboard to the primary selection */ priv->sync_clipboard_to_primary_entry = g_paste_settings_ui_panel_add_text_setting (panel, _("Sync the clipboard to the primary selection: "), g_paste_settings_get_sync_clipboard_to_primary (settings), sync_clipboard_to_primary_callback, (GPasteResetCallback) g_paste_settings_reset_sync_clipboard_to_primary, settings); /* translators: Keyboard shortcut to sync the primary selection to the clipboard */ priv->sync_primary_to_clipboard_entry = g_paste_settings_ui_panel_add_text_setting (panel, _("Sync the primary selection to the clipboard: "), g_paste_settings_get_sync_primary_to_clipboard (settings), sync_primary_to_clipboard_callback, (GPasteResetCallback) g_paste_settings_reset_sync_primary_to_clipboard, settings); /* translators: Keyboard shortcut to upload the active item from history to a pastebin service */ priv->upload_entry = g_paste_settings_ui_panel_add_text_setting (panel, _("Upload the active item to a pastebin service: "), g_paste_settings_get_upload (settings), upload_callback, (GPasteResetCallback) g_paste_settings_reset_upload, settings); return panel; } static gboolean g_paste_settings_ui_check_connection_error (GError *error) { if (!error) return FALSE; fprintf (stderr, "%s: %s\n", _("Couldn't connect to GPaste daemon"), error->message); return TRUE; } /** * g_paste_settings_ui_stack_fill: * @self: a #GPasteSettingsUiStack instance * * Fill the #GPasteSettingsUiStack with default panels * * Returns: */ G_PASTE_VISIBLE void g_paste_settings_ui_stack_fill (GPasteSettingsUiStack *self) { GPasteSettingsUiStackPrivate *priv = g_paste_settings_ui_stack_get_instance_private (self); g_paste_settings_ui_stack_add_panel (self, "general", _("General behaviour"), g_paste_settings_ui_stack_private_make_behaviour_panel (priv)); g_paste_settings_ui_stack_add_panel (self, "history", _("History settings"), g_paste_settings_ui_stack_private_make_history_settings_panel (priv)); g_paste_settings_ui_stack_add_panel (self, "keyboard", _("Keyboard shortcuts"), g_paste_settings_ui_stack_private_make_keybindings_panel (priv)); } static void g_paste_settings_ui_stack_settings_changed (GPasteSettings *settings, const gchar *key, gpointer user_data) { GPasteSettingsUiStackPrivate *priv = user_data; if (!g_strcmp0 (key, G_PASTE_ELEMENT_SIZE_SETTING)) gtk_spin_button_set_value (priv->element_size_button, g_paste_settings_get_element_size (settings)); else if (!g_strcmp0 (key, G_PASTE_GROWING_LINES_SETTING)) gtk_switch_set_active (GTK_SWITCH (priv->growing_lines_switch), g_paste_settings_get_growing_lines (settings)); else if (!g_strcmp0 (key, G_PASTE_IMAGES_SUPPORT_SETTING)) gtk_switch_set_active (GTK_SWITCH (priv->images_support_switch), g_paste_settings_get_images_support (settings)); else if (!g_strcmp0 (key, G_PASTE_LAUNCH_UI_SETTING)) gtk_entry_set_text (priv->launch_ui_entry, g_paste_settings_get_launch_ui (settings)); else if (!g_strcmp0 (key, G_PASTE_MAKE_PASSWORD_SETTING)) gtk_entry_set_text (priv->make_password_entry, g_paste_settings_get_make_password (settings)); else if (!g_strcmp0 (key, G_PASTE_MAX_DISPLAYED_HISTORY_SIZE_SETTING)) gtk_spin_button_set_value (priv->max_displayed_history_size_button, g_paste_settings_get_max_displayed_history_size (settings)); else if (!g_strcmp0 (key, G_PASTE_MAX_HISTORY_SIZE_SETTING)) gtk_spin_button_set_value (priv->max_history_size_button, g_paste_settings_get_max_history_size (settings)); else if (!g_strcmp0 (key, G_PASTE_MAX_MEMORY_USAGE_SETTING)) gtk_spin_button_set_value (priv->max_memory_usage_button, g_paste_settings_get_max_memory_usage (settings)); else if (!g_strcmp0 (key, G_PASTE_MAX_TEXT_ITEM_SIZE_SETTING)) gtk_spin_button_set_value (priv->max_text_item_size_button, g_paste_settings_get_max_text_item_size (settings)); else if (!g_strcmp0 (key, G_PASTE_MIN_TEXT_ITEM_SIZE_SETTING)) gtk_spin_button_set_value (priv->min_text_item_size_button, g_paste_settings_get_min_text_item_size (settings)); else if (!g_strcmp0 (key, G_PASTE_POP_SETTING)) gtk_entry_set_text (priv->pop_entry, g_paste_settings_get_pop (settings)); else if (!g_strcmp0 (key, G_PASTE_PRIMARY_TO_HISTORY_SETTING )) gtk_switch_set_active (GTK_SWITCH (priv->primary_to_history_switch), g_paste_settings_get_primary_to_history (settings)); else if (!g_strcmp0 (key, G_PASTE_SAVE_HISTORY_SETTING)) gtk_switch_set_active (GTK_SWITCH (priv->save_history_switch), g_paste_settings_get_save_history (settings)); else if (!g_strcmp0 (key, G_PASTE_SHOW_HISTORY_SETTING)) gtk_entry_set_text (priv->show_history_entry, g_paste_settings_get_show_history (settings)); else if (!g_strcmp0 (key, G_PASTE_SYNC_CLIPBOARD_TO_PRIMARY_SETTING)) gtk_entry_set_text (priv->sync_clipboard_to_primary_entry, g_paste_settings_get_sync_clipboard_to_primary (settings)); else if (!g_strcmp0 (key, G_PASTE_SYNC_PRIMARY_TO_CLIPBOARD_SETTING)) gtk_entry_set_text (priv->sync_primary_to_clipboard_entry, g_paste_settings_get_sync_primary_to_clipboard (settings)); else if (!g_strcmp0 (key, G_PASTE_UPLOAD_SETTING)) gtk_entry_set_text (priv->upload_entry, g_paste_settings_get_upload (settings)); else if (!g_strcmp0 (key, G_PASTE_SYNCHRONIZE_CLIPBOARDS_SETTING)) gtk_switch_set_active (GTK_SWITCH (priv->synchronize_clipboards_switch), g_paste_settings_get_synchronize_clipboards (settings)); else if (!g_strcmp0 (key, G_PASTE_TRACK_CHANGES_SETTING)) gtk_switch_set_active (GTK_SWITCH (priv->track_changes_switch), g_paste_settings_get_track_changes (settings)); else if (!g_strcmp0 (key, G_PASTE_TRIM_ITEMS_SETTING)) gtk_switch_set_active (GTK_SWITCH (priv->trim_items_switch), g_paste_settings_get_trim_items (settings)); #ifdef ENABLE_EXTENSION else if (!g_strcmp0 (key, G_PASTE_EXTENSION_ENABLED_SETTING)) gtk_switch_set_active (GTK_SWITCH (priv->extension_enabled_switch), g_paste_settings_get_extension_enabled (settings)); else if (!g_strcmp0 (key, G_PASTE_TRACK_EXTENSION_STATE_SETTING)) gtk_switch_set_active (GTK_SWITCH (priv->track_extension_state_switch), g_paste_settings_get_track_extension_state (settings)); #endif } static void g_paste_settings_ui_stack_dispose (GObject *object) { GPasteSettingsUiStackPrivate *priv = g_paste_settings_ui_stack_get_instance_private (G_PASTE_SETTINGS_UI_STACK (object)); if (priv->settings) /* first dispose call */ { g_signal_handler_disconnect (priv->settings, priv->settings_signal); g_clear_object (&priv->settings); g_clear_object (&priv->client); } G_OBJECT_CLASS (g_paste_settings_ui_stack_parent_class)->dispose (object); } static void g_paste_settings_ui_stack_finalize (GObject *object) { GPasteSettingsUiStackPrivate *priv = g_paste_settings_ui_stack_get_instance_private (G_PASTE_SETTINGS_UI_STACK (object)); GStrv *actions = priv->actions; for (guint64 i = 0; actions[i]; ++i) g_free ((GStrv) actions[i]); g_free ((GStrv *) actions); G_OBJECT_CLASS (g_paste_settings_ui_stack_parent_class)->finalize (object); } static void g_paste_settings_ui_stack_class_init (GPasteSettingsUiStackClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->dispose = g_paste_settings_ui_stack_dispose; object_class->finalize = g_paste_settings_ui_stack_finalize; } static void g_paste_settings_ui_stack_init (GPasteSettingsUiStack *self) { GPasteSettingsUiStackPrivate *priv = g_paste_settings_ui_stack_get_instance_private (self); priv->init_error = NULL; priv->client = g_paste_client_new_sync (&priv->init_error); priv->settings = g_paste_settings_new (); priv->settings_signal = g_signal_connect (priv->settings, "changed", G_CALLBACK (g_paste_settings_ui_stack_settings_changed), priv); GStrv *actions = priv->actions = (GStrv *) g_malloc (3 * sizeof (GStrv)); GStrv action = actions[0] = (GStrv) g_malloc (2 * sizeof (gchar *)); action[0] = (gchar *) "switch"; /* translators: This is the name of a multi-history management action */ action[1] = _("Switch to"); action = actions[1] = (GStrv) g_malloc (2 * sizeof (gchar *)); action[0] = (gchar *) "delete"; /* translators: This is the name of a multi-history management action */ action[1] = _("Delete"); actions[2] = NULL; } /** * g_paste_settings_ui_stack_new: * * Create a new instance of #GPasteSettingsUiStack * * Returns: (optional): a newly allocated #GPasteSettingsUiStack * free it with g_object_unref */ G_PASTE_VISIBLE GPasteSettingsUiStack * g_paste_settings_ui_stack_new (void) { GPasteSettingsUiStack *self = G_PASTE_SETTINGS_UI_STACK (gtk_widget_new (G_PASTE_TYPE_SETTINGS_UI_STACK, "margin", 12, "homogeneous", TRUE, NULL)); GPasteSettingsUiStackPrivate *priv = g_paste_settings_ui_stack_get_instance_private (self); if (g_paste_settings_ui_check_connection_error (priv->init_error)) { g_object_unref (self); return NULL; } return self; } GPaste-3.18.6/src/libgpaste/settings-ui/gpaste-settings-ui-stack.h000066400000000000000000000032741305131721400250230ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2013-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_SETTINGS_UI_STACK_H__ #define __G_PASTE_SETTINGS_UI_STACK_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_SETTINGS_UI_STACK (g_paste_settings_ui_stack_get_type ()) G_PASTE_FINAL_TYPE (SettingsUiStack, settings_ui_stack, SETTINGS_UI_STACK, GtkStack) void g_paste_settings_ui_stack_add_panel (GPasteSettingsUiStack *self, const gchar *name, const gchar *label, GPasteSettingsUiPanel *panel); void g_paste_settings_ui_stack_fill (GPasteSettingsUiStack *self); GPasteSettingsUiStack *g_paste_settings_ui_stack_new (void); G_END_DECLS #endif /*__G_PASTE_SETTINGS_UI_STACK_H__*/ GPaste-3.18.6/src/libgpaste/settings-ui/gpaste-settings-ui-widget.c000066400000000000000000000057641305131721400252020ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2013-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include struct _GPasteSettingsUiWidget { GtkGrid parent_instance; }; typedef struct { GPasteSettingsUiStack *stack; } GPasteSettingsUiWidgetPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteSettingsUiWidget, g_paste_settings_ui_widget, GTK_TYPE_GRID) /** * g_paste_settings_ui_widget_get_stack: * @self: a #GPasteSettingsUiWidget instance * * Get the inner GtkStack from the Widget * * Returns: (transfer none): the #GtkStack */ G_PASTE_VISIBLE GPasteSettingsUiStack * g_paste_settings_ui_widget_get_stack (GPasteSettingsUiWidget *self) { g_return_val_if_fail (G_PASTE_IS_SETTINGS_UI_WIDGET (self), NULL); GPasteSettingsUiWidgetPrivate *priv = g_paste_settings_ui_widget_get_instance_private (self); return priv->stack; } static void g_paste_settings_ui_widget_class_init (GPasteSettingsUiWidgetClass *klass G_GNUC_UNUSED) { } static void g_paste_settings_ui_widget_init (GPasteSettingsUiWidget *self) { GPasteSettingsUiWidgetPrivate *priv = g_paste_settings_ui_widget_get_instance_private (self); GtkGrid *grid = GTK_GRID (self); guint64 current_line = 0; GPasteSettingsUiStack *stack = priv->stack = g_paste_settings_ui_stack_new (); if (!stack) return; g_paste_settings_ui_stack_fill (stack); gtk_grid_attach (grid, gtk_widget_new (GTK_TYPE_STACK_SWITCHER, "stack", GTK_STACK (stack), "halign", GTK_ALIGN_CENTER, NULL), 0, current_line++, 1, 1); gtk_grid_attach (grid, GTK_WIDGET (stack), 0, current_line++, 1, 1); } /** * g_paste_settings_ui_widget_new: * * Create a new instance of #GPasteSettingsUiWidget * * Returns: (optional): a newly allocated #GPasteSettingsUiWidget * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_settings_ui_widget_new (void) { GtkWidget *self = gtk_widget_new (G_PASTE_TYPE_SETTINGS_UI_WIDGET, NULL); GPasteSettingsUiWidgetPrivate *priv = g_paste_settings_ui_widget_get_instance_private (G_PASTE_SETTINGS_UI_WIDGET (self)); if (!priv->stack) { g_object_unref (self); return NULL; } return self; } GPaste-3.18.6/src/libgpaste/settings-ui/gpaste-settings-ui-widget.h000066400000000000000000000026441305131721400252010ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2013-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_SETTINGS_UI_WIDGET_H__ #define __G_PASTE_SETTINGS_UI_WIDGET_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_SETTINGS_UI_WIDGET (g_paste_settings_ui_widget_get_type ()) G_PASTE_FINAL_TYPE (SettingsUiWidget, settings_ui_widget, SETTINGS_UI_WIDGET, GtkGrid) GPasteSettingsUiStack *g_paste_settings_ui_widget_get_stack (GPasteSettingsUiWidget *self); GtkWidget *g_paste_settings_ui_widget_new (void); G_END_DECLS #endif /*__G_PASTE_SETTINGS_UI_WIDGET_H__*/ GPaste-3.18.6/src/libgpaste/settings/000077500000000000000000000000001305131721400173725ustar00rootroot00000000000000GPaste-3.18.6/src/libgpaste/settings/gpaste-settings.c000066400000000000000000001026311305131721400226620ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include struct _GPasteSettings { GObject parent_instance; }; typedef struct { GSettings *settings; GSettings *shell_settings; guint64 element_size; gboolean growing_lines; gchar *history_name; gboolean images_support; gchar *launch_ui; gchar *make_password; guint64 max_displayed_history_size; guint64 max_history_size; guint64 max_memory_usage; guint64 max_text_item_size; guint64 min_text_item_size; gchar *pop; gboolean primary_to_history; gboolean save_history; gchar *show_history; gchar *sync_clipboard_to_primary; gchar *sync_primary_to_clipboard; gboolean synchronize_clipboards; gboolean track_changes; gboolean track_extension_state; gboolean trim_items; gchar *upload; gboolean extension_enabled; gulong changed_signal; gulong shell_changed_signal; } GPasteSettingsPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteSettings, g_paste_settings, G_TYPE_OBJECT) enum { CHANGED, REBIND, TRACK, LAST_SIGNAL }; static guint64 signals[LAST_SIGNAL] = { 0 }; #define SETTING(name, key, type, setting_type, fail, guards, clear_func, dup_func) \ G_PASTE_VISIBLE type \ g_paste_settings_get_##name (const GPasteSettings *self) \ { \ g_return_val_if_fail (G_PASTE_IS_SETTINGS ((gpointer) self), fail); \ GPasteSettingsPrivate *priv = g_paste_settings_get_instance_private (self); \ return priv->name; \ } \ G_PASTE_VISIBLE void \ g_paste_settings_reset_##name (GPasteSettings *self) \ { \ g_return_if_fail (G_PASTE_IS_SETTINGS (self)); \ GPasteSettingsPrivate *priv = g_paste_settings_get_instance_private (self); \ g_settings_reset (priv->settings, G_PASTE_##key##_SETTING); \ } \ static void \ g_paste_settings_private_set_##name##_from_dconf (GPasteSettingsPrivate *priv) \ { \ priv->name = g_settings_get_##setting_type (priv->settings, G_PASTE_##key##_SETTING); \ } \ G_PASTE_VISIBLE void \ g_paste_settings_set_##name (GPasteSettings *self, \ type value) \ { \ g_return_if_fail (G_PASTE_IS_SETTINGS (self)); \ guards \ GPasteSettingsPrivate *priv = g_paste_settings_get_instance_private (self); \ clear_func \ priv->name = dup_func (value); \ g_settings_set_##setting_type (priv->settings, G_PASTE_##key##_SETTING, value); \ } #define TRIVIAL_SETTING(name, key, type, setting_type, fail) \ SETTING (name, key, type, setting_type, fail, {}, {},) #define BOOLEAN_SETTING(name, key) TRIVIAL_SETTING (name, key, gboolean, boolean, FALSE) #define UNSIGNED_SETTING(name, key) TRIVIAL_SETTING (name, key, guint64, gpaste_uint64, 0) #define STRING_SETTING(name, key) SETTING (name, key, const gchar *, string, NULL, \ g_return_if_fail (value); \ g_return_if_fail (g_utf8_validate (value, -1, NULL));, \ g_free (priv->name);, g_strdup) #define NEW_SIGNAL_FULL(name, type, MTYPE, arg_type) \ g_signal_new (name, \ G_PASTE_TYPE_SETTINGS, \ type, \ 0, /* class offset */ \ NULL, /* accumulator */ \ NULL, /* accumulator data */ \ g_cclosure_marshal_VOID__##MTYPE, \ G_TYPE_NONE, \ 1, /* number of params */ \ G_TYPE_##arg_type) #define NEW_SIGNAL(name, arg_type) NEW_SIGNAL_FULL (name, G_SIGNAL_RUN_LAST, arg_type, arg_type) #define NEW_SIGNAL_DETAILED(name, arg_type) NEW_SIGNAL_FULL (name, G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, arg_type, arg_type) #define NEW_SIGNAL_DETAILED_STATIC(name, arg_type) NEW_SIGNAL_FULL (name, G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, arg_type, arg_type | G_SIGNAL_TYPE_STATIC_SCOPE) static guint64 g_settings_get_gpaste_uint64 (GSettings *settings, const gchar *key) { g_autoptr (GVariant) v = g_settings_get_value (settings, key); return g_variant_get_uint64 (v); } static void g_settings_set_gpaste_uint64 (GSettings *settings, const gchar *key, guint64 value) { g_settings_set_value (settings, key, g_variant_new_uint64 (value)); } /** * g_paste_settings_get_element_size: * @self: a #GPasteSettings instance * * Get the "element-size" setting * * Returns: the value of the "element-size" setting */ /** * g_paste_settings_reset_element_size: * @self: a #GPasteSettings instance * * Reset the "element-size" setting * * Returns: */ /** * g_paste_settings_set_element_size: * @self: a #GPasteSettings instance * @value: the maximum displayed size of an item * * Change the "element-size" setting * * Returns: */ UNSIGNED_SETTING (element_size, ELEMENT_SIZE) /** * g_paste_settings_get_growing_lines: * @self: a #GPasteSettings instance * * Get the "growing-lines" setting * * Returns: the value of the "growing-lines" setting */ /** * g_paste_settings_reset_growing_lines: * @self: a #GPasteSettings instance * * Reset the "growing-lines" setting * * Returns: */ /** * g_paste_settings_set_growing_lines: * @self: a #GPasteSettings instance * @value: whether to detect or not growing lines * * Change the "growing-lines" setting * * Returns: */ BOOLEAN_SETTING (growing_lines, GROWING_LINES) /** * g_paste_settings_get_history_name: * @self: a #GPasteSettings instance * * Get the "history-name" setting * * Returns: the value of the "history-name" setting */ /** * g_paste_settings_reset_history_name: * @self: a #GPasteSettings instance * * Reset the "history-name" setting * * Returns: */ /** * g_paste_settings_set_history_name: * @self: a #GPasteSettings instance * @value: the new history name * * Change the "history-name" setting * * Returns: */ STRING_SETTING (history_name, HISTORY_NAME) /** * g_paste_settings_get_images_support: * @self: a #GPasteSettings instance * * Get the "images-support" setting * * Returns: the value of the "images-support" setting */ /** * g_paste_settings_reset_images_support: * @self: a #GPasteSettings instance * * Reset the "images-support" setting * * Returns: */ /** * g_paste_settings_set_images_support: * @self: a #GPasteSettings instance * @value: the new history name * * Change the "images-support" setting * * Returns: */ BOOLEAN_SETTING (images_support, IMAGES_SUPPORT) /** * g_paste_settings_get_launch_ui: * @self: a #GPasteSettings instance * * Get the "launch-ui" setting * * Returns: the value of the "launch-ui" setting */ /** * g_paste_settings_reset_launch_ui: * @self: a #GPasteSettings instance * * Reset the "launch-ui" setting * * Returns: */ /** * g_paste_settings_set_launch_ui: * @self: a #GPasteSettings instance * @value: the new keyboard shortcut * * Change the "launch-ui" setting * * Returns: */ STRING_SETTING (launch_ui, LAUNCH_UI) /** * g_paste_settings_get_make_password: * @self: a #GPasteSettings instance * * Get the "make-password" setting * * Returns: the value of the "make-password" setting */ /** * g_paste_settings_reset_make_password: * @self: a #GPasteSettings instance * * Reset the "make-password" setting * * Returns: */ /** * g_paste_settings_set_make_password: * @self: a #GPasteSettings instance * @value: the new keyboard shortcut * * Change the "make-password" setting * * Returns: */ STRING_SETTING (make_password, MAKE_PASSWORD) /** * g_paste_settings_get_max_displayed_history_size: * @self: a #GPasteSettings instance * * Get the "max-displayed-history-size" setting * * Returns: the value of the "max-displayed-history-size" setting */ /** * g_paste_settings_reset_max_displayed_history_size: * @self: a #GPasteSettings instance * * Reset the "max-displayed-history-size" setting * * Returns: */ /** * g_paste_settings_set_max_displayed_history_size: * @self: a #GPasteSettings instance * @value: the maximum number of items to display * * Change the "max-displayed-history-size" setting * * Returns: */ UNSIGNED_SETTING (max_displayed_history_size, MAX_DISPLAYED_HISTORY_SIZE) /** * g_paste_settings_get_max_history_size: * @self: a #GPasteSettings instance * * Get the "max-history-size" setting * * Returns: the value of the "max-history-size" setting */ /** * g_paste_settings_reset_max_history_size: * @self: a #GPasteSettings instance * * Reset the "max-history-size" setting * * Returns: */ /** * g_paste_settings_set_max_history_size: * @self: a #GPasteSettings instance * @value: the maximum number of items the history can contain * * Change the "max-history-size" setting * * Returns: */ UNSIGNED_SETTING (max_history_size, MAX_HISTORY_SIZE) /** * g_paste_settings_get_max_memory_usage: * @self: a #GPasteSettings instance * * Get the "max-memory-usage" setting * * Returns: the value of the "max-memory-usage" setting */ /** * g_paste_settings_reset_max_memory_usage: * @self: a #GPasteSettings instance * * Reset the "max-memory-usage" setting * * Returns: */ /** * g_paste_settings_set_max_memory_usage: * @self: a #GPasteSettings instance * @value: the maximum amout of memory we can use * * Change the "max-memory-usage" setting * * Returns: */ UNSIGNED_SETTING (max_memory_usage, MAX_MEMORY_USAGE) /** * g_paste_settings_get_max_text_item_size: * @self: a #GPasteSettings instance * * Get the "max-text-item-size" setting * * Returns: the value of the "max-text-item-size" setting */ /** * g_paste_settings_reset_max_text_item_size: * @self: a #GPasteSettings instance * * Reset the "max-text-item-size" setting * * Returns: */ /** * g_paste_settings_set_max_text_item_size: * @self: a #GPasteSettings instance * @value: the maximum size for a textual item to be handled * * Change the "max-text-item-size" setting * * Returns: */ UNSIGNED_SETTING (max_text_item_size, MAX_TEXT_ITEM_SIZE) /** * g_paste_settings_get_min_text_item_size: * @self: a #GPasteSettings instance * * Get the "min-text-item-size" setting * * Returns: the value of the "min-text-item-size" setting */ /** * g_paste_settings_reset_min_text_item_size: * @self: a #GPasteSettings instance * * Reset the "min-text-item-size" setting * * Returns: */ /** * g_paste_settings_set_min_text_item_size: * @self: a #GPasteSettings instance * @value: the minimum size for a textual item to be handled * * Change the "min-text-item-size" setting * * Returns: */ UNSIGNED_SETTING (min_text_item_size, MIN_TEXT_ITEM_SIZE) /** * g_paste_settings_get_pop: * @self: a #GPasteSettings instance * * Get the "pop" setting * * Returns: the value of the "pop" setting */ /** * g_paste_settings_reset_pop: * @self: a #GPasteSettings instance * * Reset the "pop" setting * * Returns: */ /** * g_paste_settings_set_pop: * @self: a #GPasteSettings instance * @value: the new keyboard shortcut * * Change the "pop" setting * * Returns: */ STRING_SETTING (pop, POP) /** * g_paste_settings_get_primary_to_history: * @self: a #GPasteSettings instance * * Get the "primary-to-history" setting * * Returns: the value of the "primary-to-history" setting */ /** * g_paste_settings_reset_primary_to_history: * @self: a #GPasteSettings instance * * Reset the "primary-to-history" setting * * Returns: */ /** * g_paste_settings_set_primary_to_history: * @self: a #GPasteSettings instance * @value: whether to track or not the primary selection changes as clipboard ones * * Change the "primary-to-history" setting * * Returns: */ BOOLEAN_SETTING (primary_to_history, PRIMARY_TO_HISTORY) /** * g_paste_settings_get_save_history: * @self: a #GPasteSettings instance * * Get the "save-history" setting * * Returns: the value of the "save-history" setting */ /** * g_paste_settings_reset_save_history: * @self: a #GPasteSettings instance * * Reset the "save-history" setting * * Returns: */ /** * g_paste_settings_set_save_history: * @self: a #GPasteSettings instance * @value: whether to save or not the history * * Change the "save-history" setting * * Returns: */ BOOLEAN_SETTING (save_history, SAVE_HISTORY) /** * g_paste_settings_get_show_history: * @self: a #GPasteSettings instance * * Get the "show-history" setting * * Returns: the value of the "show-history" setting */ /** * g_paste_settings_reset_show_history: * @self: a #GPasteSettings instance * * Reset the "show-history" setting * * Returns: */ /** * g_paste_settings_set_show_history: * @self: a #GPasteSettings instance * @value: the new keyboard shortcut * * Change the "show-history" setting * * Returns: */ STRING_SETTING (show_history, SHOW_HISTORY) /** * g_paste_settings_get_sync_clipboard_to_primary: * @self: a #GPasteSettings instance * * Get the "sync-clipboard-to-primary" setting * * Returns: the value of the "sync-clipboard-to-primary" setting */ /** * g_paste_settings_reset_sync_clipboard_to_primary: * @self: a #GPasteSettings instance * * Reset the "sync-clipboard-to-primary" setting * * Returns: */ /** * g_paste_settings_set_sync_clipboard_to_primary: * @self: a #GPasteSettings instance * @value: the new keyboard shortcut * * Change the "sync-clipboard-to-primary" setting * * Returns: */ STRING_SETTING (sync_clipboard_to_primary, SYNC_CLIPBOARD_TO_PRIMARY) /** * g_paste_settings_get_sync_primary_to_clipboard: * @self: a #GPasteSettings instance * * Get the "sync-primary-to-clipboard" setting * * Returns: the value of the "sync-primary-to-clipboard" setting */ /** * g_paste_settings_reset_sync_primary_to_clipboard: * @self: a #GPasteSettings instance * * Reset the "sync-primary-to-clipboard" setting * * Returns: */ /** * g_paste_settings_set_sync_primary_to_clipboard: * @self: a #GPasteSettings instance * @value: the new keyboard shortcut * * Change the "sync-primary-to-clipboard" setting * * Returns: */ STRING_SETTING (sync_primary_to_clipboard, SYNC_PRIMARY_TO_CLIPBOARD) /** * g_paste_settings_get_synchronize_clipboards: * @self: a #GPasteSettings instance * * Get the "synchronize-clipboards" setting * * Returns: the value of the "synchronize-clipboards" setting */ /** * g_paste_settings_reset_synchronize_clipboards: * @self: a #GPasteSettings instance * * Reset the "synchronize-clipboards" setting * * Returns: */ /** * g_paste_settings_set_synchronize_clipboards: * @self: a #GPasteSettings instance * @value: whether to synchronize the clipboard and the primary selection or not * * Change the "synchronize-clipboards" setting * * Returns: */ BOOLEAN_SETTING (synchronize_clipboards, SYNCHRONIZE_CLIPBOARDS) /** * g_paste_settings_get_track_changes: * @self: a #GPasteSettings instance * * Get the "track-changes" setting * * Returns: the value of the "track-changes" setting */ /** * g_paste_settings_reset_track_changes: * @self: a #GPasteSettings instance * * Reset the "track-changes" setting * * Returns: */ /** * g_paste_settings_set_track_changes: * @self: a #GPasteSettings instance * @value: whether to track or not the clipboard changes * * Change the "track-changes" setting * * Returns: */ BOOLEAN_SETTING (track_changes, TRACK_CHANGES) /** * g_paste_settings_get_track_extension_state: * @self: a #GPasteSettings instance * * Get the "track-extension-state" setting * * Returns: the value of the "track-extension-state" setting */ /** * g_paste_settings_reset_track_extension_state: * @self: a #GPasteSettings instance * * Reset the "track-extension-state" setting * * Returns: */ /** * g_paste_settings_set_track_extension_state: * @self: a #GPasteSettings instance * @value: whether to stop tracking or not the clipboard changes when an applet exits * * Change the "track-extension-state" setting * * Returns: */ BOOLEAN_SETTING (track_extension_state, TRACK_EXTENSION_STATE) /** * g_paste_settings_get_trim_items: * @self: a #GPasteSettings instance * * Get the "trim-items" setting * * Returns: the value of the "trim-items" setting */ /** * g_paste_settings_reset_trim_items: * @self: a #GPasteSettings instance * * Reset the "trim-items" setting * * Returns: */ /** * g_paste_settings_set_trim_items: * @self: a #GPasteSettings instance * @value: whether to trim or not textual items * * Change the "trim-items" setting * * Returns: */ BOOLEAN_SETTING (trim_items, TRIM_ITEMS) /** * g_paste_settings_get_upload: * @self: a #GPasteSettings instance * * Get the "upload" setting * * Returns: the value of the "upload" setting */ /** * g_paste_settings_reset_upload: * @self: a #GPasteSettings instance * * Reset the "upload" setting * * Returns: */ /** * g_paste_settings_set_upload: * @self: a #GPasteSettings instance * @value: the new keyboard shortcut * * Change the "upload" setting * * Returns: */ STRING_SETTING (upload, UPLOAD) #ifdef ENABLE_EXTENSION #define EXTENSION_NAME "GPaste@gnome-shell-extensions.gnome.org" /** * g_paste_settings_get_extension_enabled: * @self: a #GPasteSettings instance * * Get the "extension-enabled" special setting * * Returns: Whether the gnome-shell extension is enabled or not */ G_PASTE_VISIBLE gboolean g_paste_settings_get_extension_enabled (const GPasteSettings *self) { g_return_val_if_fail (G_PASTE_IS_SETTINGS ((gpointer) self), FALSE); GPasteSettingsPrivate *priv = g_paste_settings_get_instance_private (self); return priv->extension_enabled; } static inline gchar ** g_paste_settings_private_get_enabled_extensions (GPasteSettingsPrivate *priv) { return (priv->shell_settings) ? g_settings_get_strv (priv->shell_settings, G_PASTE_SHELL_ENABLED_EXTENSIONS_SETTING) : NULL; } static void g_paste_settings_private_set_extension_enabled_from_dconf (GPasteSettingsPrivate *priv) { g_auto (GStrv) extensions = g_paste_settings_private_get_enabled_extensions (priv); for (GStrv e = extensions; *e; ++e) { if (!g_strcmp0 (*e, EXTENSION_NAME)) { priv->extension_enabled = TRUE; return; } } priv->extension_enabled = FALSE; } /** * g_paste_settings_set_extension_enabled: * @self: a #GPasteSettings instance * @value: whether to enable or not the gnome-shell extension * * Change the "extension-enabled" special setting * * Returns: */ G_PASTE_VISIBLE void g_paste_settings_set_extension_enabled (GPasteSettings *self, gboolean value) { g_return_if_fail (G_PASTE_IS_SETTINGS (self)); GPasteSettingsPrivate *priv = g_paste_settings_get_instance_private (self); g_auto (GStrv) extensions = NULL; if (!priv->shell_settings || (value == priv->extension_enabled)) return; extensions = g_paste_settings_private_get_enabled_extensions (priv); guint64 nb = g_strv_length (extensions); if (value) { extensions = g_realloc (extensions, (nb + 2) * sizeof (gchar *)); extensions[nb] = g_strdup (EXTENSION_NAME); extensions[nb+1] = NULL; } else { gboolean found = FALSE; for (guint64 i = 0; i < nb; ++i) { if (!found && !g_strcmp0 (extensions[i], EXTENSION_NAME)) { found = TRUE; g_free (extensions[i]); } if (found) extensions[i] = extensions[i+1]; } } priv->extension_enabled = value; g_settings_set_strv (priv->shell_settings, G_PASTE_SHELL_ENABLED_EXTENSIONS_SETTING, (const gchar * const *) extensions); } static void g_paste_settings_shell_settings_changed (GSettings *settings G_GNUC_UNUSED, const gchar *key G_GNUC_UNUSED, gpointer user_data) { GPasteSettings *self = G_PASTE_SETTINGS (user_data); GPasteSettingsPrivate *priv = g_paste_settings_get_instance_private (self); g_paste_settings_private_set_extension_enabled_from_dconf (priv); /* Forward the signal */ g_signal_emit (self, signals[CHANGED], g_quark_from_string (G_PASTE_EXTENSION_ENABLED_SETTING), G_PASTE_EXTENSION_ENABLED_SETTING, NULL); } #endif static void g_paste_settings_rebind (GPasteSettings *self, const gchar *key) { g_signal_emit (self, signals[REBIND], g_quark_from_string (key), NULL); } static void g_paste_settings_settings_changed (GSettings *settings G_GNUC_UNUSED, const gchar *key, gpointer user_data) { GPasteSettings *self = G_PASTE_SETTINGS (user_data); GPasteSettingsPrivate *priv = g_paste_settings_get_instance_private (self); if (!g_strcmp0 (key, G_PASTE_ELEMENT_SIZE_SETTING)) g_paste_settings_private_set_element_size_from_dconf (priv); else if (!g_strcmp0 (key, G_PASTE_GROWING_LINES_SETTING)) g_paste_settings_private_set_growing_lines_from_dconf (priv); else if (!g_strcmp0 (key, G_PASTE_HISTORY_NAME_SETTING)) g_paste_settings_private_set_history_name_from_dconf (priv); else if (!g_strcmp0 (key, G_PASTE_IMAGES_SUPPORT_SETTING)) g_paste_settings_private_set_images_support_from_dconf (priv); else if (!g_strcmp0 (key, G_PASTE_LAUNCH_UI_SETTING)) { g_paste_settings_private_set_launch_ui_from_dconf (priv); g_paste_settings_rebind (self, G_PASTE_LAUNCH_UI_SETTING); } else if (!g_strcmp0 (key, G_PASTE_MAKE_PASSWORD_SETTING)) { g_paste_settings_private_set_make_password_from_dconf (priv); g_paste_settings_rebind (self, G_PASTE_MAKE_PASSWORD_SETTING); } else if (!g_strcmp0 (key, G_PASTE_MAX_DISPLAYED_HISTORY_SIZE_SETTING)) g_paste_settings_private_set_max_displayed_history_size_from_dconf (priv); else if (!g_strcmp0 (key, G_PASTE_MAX_HISTORY_SIZE_SETTING)) g_paste_settings_private_set_max_history_size_from_dconf (priv); else if (!g_strcmp0 (key, G_PASTE_MAX_MEMORY_USAGE_SETTING)) g_paste_settings_private_set_max_memory_usage_from_dconf (priv); else if (!g_strcmp0 (key, G_PASTE_MAX_TEXT_ITEM_SIZE_SETTING)) g_paste_settings_private_set_max_text_item_size_from_dconf (priv); else if (!g_strcmp0 (key, G_PASTE_MIN_TEXT_ITEM_SIZE_SETTING)) g_paste_settings_private_set_min_text_item_size_from_dconf (priv); else if (!g_strcmp0 (key, G_PASTE_POP_SETTING)) { g_paste_settings_private_set_pop_from_dconf (priv); g_paste_settings_rebind (self, G_PASTE_POP_SETTING); } else if (!g_strcmp0 (key, G_PASTE_PRIMARY_TO_HISTORY_SETTING )) g_paste_settings_private_set_primary_to_history_from_dconf (priv); else if (!g_strcmp0 (key, G_PASTE_SAVE_HISTORY_SETTING)) g_paste_settings_private_set_save_history_from_dconf (priv); else if (!g_strcmp0 (key, G_PASTE_SHOW_HISTORY_SETTING)) { g_paste_settings_private_set_show_history_from_dconf (priv); g_paste_settings_rebind (self, G_PASTE_SHOW_HISTORY_SETTING); } else if (!g_strcmp0 (key, G_PASTE_SYNC_CLIPBOARD_TO_PRIMARY_SETTING)) { g_paste_settings_private_set_sync_clipboard_to_primary_from_dconf (priv); g_paste_settings_rebind (self, G_PASTE_SYNC_CLIPBOARD_TO_PRIMARY_SETTING); } else if (!g_strcmp0 (key, G_PASTE_SYNC_PRIMARY_TO_CLIPBOARD_SETTING)) { g_paste_settings_private_set_sync_primary_to_clipboard_from_dconf (priv); g_paste_settings_rebind (self, G_PASTE_SYNC_PRIMARY_TO_CLIPBOARD_SETTING); } else if (!g_strcmp0 (key, G_PASTE_SYNCHRONIZE_CLIPBOARDS_SETTING)) g_paste_settings_private_set_synchronize_clipboards_from_dconf (priv); else if (!g_strcmp0 (key, G_PASTE_TRACK_CHANGES_SETTING)) { g_paste_settings_private_set_track_changes_from_dconf (priv); g_signal_emit (self, signals[TRACK], 0, /* detail */ priv->track_changes, NULL); } else if (!g_strcmp0 (key, G_PASTE_TRACK_EXTENSION_STATE_SETTING)) g_paste_settings_private_set_track_extension_state_from_dconf (priv); else if (!g_strcmp0 (key, G_PASTE_TRIM_ITEMS_SETTING)) g_paste_settings_private_set_trim_items_from_dconf (priv); else if (!g_strcmp0 (key, G_PASTE_UPLOAD_SETTING)) { g_paste_settings_private_set_upload_from_dconf (priv); g_paste_settings_rebind (self, G_PASTE_UPLOAD_SETTING); } /* Forward the signal */ g_signal_emit (self, signals[CHANGED], g_quark_from_string (key), key, NULL); } static void g_paste_settings_dispose (GObject *object) { GPasteSettingsPrivate *priv = g_paste_settings_get_instance_private (G_PASTE_SETTINGS (object)); GSettings *settings = priv->settings; if (settings) { g_signal_handler_disconnect (settings, priv->changed_signal); g_clear_object (&priv->settings); } #ifdef ENABLE_EXTENSION GSettings *shell_settings = priv->shell_settings; if (shell_settings) { g_signal_handler_disconnect (shell_settings, priv->shell_changed_signal); g_clear_object (&priv->shell_settings); } #endif G_OBJECT_CLASS (g_paste_settings_parent_class)->dispose (object); } static void g_paste_settings_finalize (GObject *object) { GPasteSettingsPrivate *priv = g_paste_settings_get_instance_private (G_PASTE_SETTINGS (object)); g_free (priv->history_name); g_free (priv->launch_ui); g_free (priv->make_password); g_free (priv->pop); g_free (priv->show_history); g_free (priv->sync_clipboard_to_primary); g_free (priv->sync_primary_to_clipboard); g_free (priv->upload); G_OBJECT_CLASS (g_paste_settings_parent_class)->finalize (object); } static void g_paste_settings_class_init (GPasteSettingsClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->dispose = g_paste_settings_dispose; object_class->finalize = g_paste_settings_finalize; /** * GPasteSettings::changed: * @settings: the object on which the signal was emitted * @key: the name of the key that changed * * The "changed" signal is emitted when a key has potentially changed. * You should call one of the g_paste_settings_get() calls to check the new * value. * * This signal supports detailed connections. You can connect to the * detailed signal "changed::x" in order to only receive callbacks * when key "x" changes. */ signals[CHANGED] = NEW_SIGNAL_DETAILED_STATIC ("changed", STRING); /** * GPasteSettings::rebind: * @settings: the object on which the signal was emitted * @key: the name of the key that changed * * The "rebind" signal is emitted when a key has potentially changed. * You should call one of the g_paste_settings_get() calls to check the new * value. * * This signal supports detailed connections. You can connect to the * detailed signal "rebind::x" in order to only receive callbacks * when key "x" changes. */ signals[REBIND] = NEW_SIGNAL_DETAILED ("rebind" , STRING); /** * GPasteSettings::track: * @settings: the object on which the signal was emitted * @tracking_state: whether we're now tracking or not * * The "track" signal is emitted when the daemon starts or stops tracking * clipboard changes */ signals[TRACK] = NEW_SIGNAL ("track" , BOOLEAN); } static void g_paste_settings_init (GPasteSettings *self) { GPasteSettingsPrivate *priv = g_paste_settings_get_instance_private (self); GSettings *settings = priv->settings = g_settings_new (G_PASTE_SETTINGS_NAME); priv->history_name = NULL; priv->launch_ui = NULL; priv->make_password = NULL; priv->pop = NULL; priv->show_history = NULL; priv->sync_clipboard_to_primary = NULL; priv->sync_primary_to_clipboard = NULL; priv->upload = NULL; priv->changed_signal = g_signal_connect (settings, "changed", G_CALLBACK (g_paste_settings_settings_changed), self); g_paste_settings_private_set_element_size_from_dconf (priv); g_paste_settings_private_set_growing_lines_from_dconf (priv); g_paste_settings_private_set_history_name_from_dconf (priv); g_paste_settings_private_set_images_support_from_dconf (priv); g_paste_settings_private_set_launch_ui_from_dconf (priv); g_paste_settings_private_set_make_password_from_dconf (priv); g_paste_settings_private_set_max_displayed_history_size_from_dconf (priv); g_paste_settings_private_set_max_history_size_from_dconf (priv); g_paste_settings_private_set_max_memory_usage_from_dconf (priv); g_paste_settings_private_set_max_text_item_size_from_dconf (priv); g_paste_settings_private_set_min_text_item_size_from_dconf (priv); g_paste_settings_private_set_pop_from_dconf (priv); g_paste_settings_private_set_primary_to_history_from_dconf (priv); g_paste_settings_private_set_save_history_from_dconf (priv); g_paste_settings_private_set_show_history_from_dconf (priv); g_paste_settings_private_set_sync_clipboard_to_primary_from_dconf (priv); g_paste_settings_private_set_sync_primary_to_clipboard_from_dconf (priv); g_paste_settings_private_set_synchronize_clipboards_from_dconf (priv); g_paste_settings_private_set_track_changes_from_dconf (priv); g_paste_settings_private_set_track_extension_state_from_dconf (priv); g_paste_settings_private_set_trim_items_from_dconf (priv); g_paste_settings_private_set_upload_from_dconf (priv); priv->shell_settings = NULL; priv->extension_enabled = FALSE; #ifdef ENABLE_EXTENSION GSettingsSchemaSource *source = g_settings_schema_source_get_default (); if (!source) return; g_autoptr (GSettingsSchema) schema = g_settings_schema_source_lookup (source, G_PASTE_SHELL_SETTINGS_NAME, TRUE); if (!schema) return; priv->shell_settings = g_settings_new (G_PASTE_SHELL_SETTINGS_NAME); priv->shell_changed_signal = g_signal_connect (priv->shell_settings, "changed::" G_PASTE_SHELL_ENABLED_EXTENSIONS_SETTING, G_CALLBACK (g_paste_settings_shell_settings_changed), self); g_paste_settings_private_set_extension_enabled_from_dconf (priv); #endif } /** * g_paste_settings_new: * * Create a new instance of #GPasteSettings * * Returns: a newly allocated #GPasteSettings * free it with g_object_unref */ G_PASTE_VISIBLE GPasteSettings * g_paste_settings_new (void) { return g_object_new (G_PASTE_TYPE_SETTINGS, NULL); } GPaste-3.18.6/src/libgpaste/settings/gpaste-settings.h000066400000000000000000000206431305131721400226710ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2011-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_SETTINGS_H__ #define __G_PASTE_SETTINGS_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_SETTINGS (g_paste_settings_get_type ()) G_PASTE_FINAL_TYPE (Settings, settings, SETTINGS, GObject) guint64 g_paste_settings_get_element_size (const GPasteSettings *self); gboolean g_paste_settings_get_growing_lines (const GPasteSettings *self); const gchar *g_paste_settings_get_history_name (const GPasteSettings *self); gboolean g_paste_settings_get_images_support (const GPasteSettings *self); const gchar *g_paste_settings_get_launch_ui (const GPasteSettings *self); const gchar *g_paste_settings_get_make_password (const GPasteSettings *self); guint64 g_paste_settings_get_max_displayed_history_size (const GPasteSettings *self); guint64 g_paste_settings_get_max_history_size (const GPasteSettings *self); guint64 g_paste_settings_get_max_memory_usage (const GPasteSettings *self); guint64 g_paste_settings_get_max_text_item_size (const GPasteSettings *self); guint64 g_paste_settings_get_min_text_item_size (const GPasteSettings *self); const gchar *g_paste_settings_get_pop (const GPasteSettings *self); gboolean g_paste_settings_get_primary_to_history (const GPasteSettings *self); gboolean g_paste_settings_get_save_history (const GPasteSettings *self); const gchar *g_paste_settings_get_show_history (const GPasteSettings *self); const gchar *g_paste_settings_get_sync_clipboard_to_primary (const GPasteSettings *self); const gchar *g_paste_settings_get_sync_primary_to_clipboard (const GPasteSettings *self); gboolean g_paste_settings_get_synchronize_clipboards (const GPasteSettings *self); gboolean g_paste_settings_get_track_changes (const GPasteSettings *self); gboolean g_paste_settings_get_track_extension_state (const GPasteSettings *self); gboolean g_paste_settings_get_trim_items (const GPasteSettings *self); const gchar *g_paste_settings_get_upload (const GPasteSettings *self); void g_paste_settings_reset_element_size (GPasteSettings *self); void g_paste_settings_reset_growing_lines (GPasteSettings *self); void g_paste_settings_reset_history_name (GPasteSettings *self); void g_paste_settings_reset_images_support (GPasteSettings *self); void g_paste_settings_reset_launch_ui (GPasteSettings *self); void g_paste_settings_reset_make_password (GPasteSettings *self); void g_paste_settings_reset_max_displayed_history_size (GPasteSettings *self); void g_paste_settings_reset_max_history_size (GPasteSettings *self); void g_paste_settings_reset_max_memory_usage (GPasteSettings *self); void g_paste_settings_reset_max_text_item_size (GPasteSettings *self); void g_paste_settings_reset_min_text_item_size (GPasteSettings *self); void g_paste_settings_reset_pop (GPasteSettings *self); void g_paste_settings_reset_primary_to_history (GPasteSettings *self); void g_paste_settings_reset_save_history (GPasteSettings *self); void g_paste_settings_reset_show_history (GPasteSettings *self); void g_paste_settings_reset_sync_clipboard_to_primary (GPasteSettings *self); void g_paste_settings_reset_sync_primary_to_clipboard (GPasteSettings *self); void g_paste_settings_reset_synchronize_clipboards (GPasteSettings *self); void g_paste_settings_reset_track_changes (GPasteSettings *self); void g_paste_settings_reset_track_extension_state (GPasteSettings *self); void g_paste_settings_reset_trim_items (GPasteSettings *self); void g_paste_settings_reset_upload (GPasteSettings *self); void g_paste_settings_set_element_size (GPasteSettings *self, guint64 value); void g_paste_settings_set_growing_lines (GPasteSettings *self, gboolean value); void g_paste_settings_set_history_name (GPasteSettings *self, const gchar *value); void g_paste_settings_set_images_support (GPasteSettings *self, gboolean value); void g_paste_settings_set_launch_ui (GPasteSettings *self, const gchar *value); void g_paste_settings_set_make_password (GPasteSettings *self, const gchar *value); void g_paste_settings_set_max_displayed_history_size (GPasteSettings *self, guint64 value); void g_paste_settings_set_max_history_size (GPasteSettings *self, guint64 value); void g_paste_settings_set_max_memory_usage (GPasteSettings *self, guint64 value); void g_paste_settings_set_max_text_item_size (GPasteSettings *self, guint64 value); void g_paste_settings_set_min_text_item_size (GPasteSettings *self, guint64 value); void g_paste_settings_set_pop (GPasteSettings *self, const gchar *value); void g_paste_settings_set_primary_to_history (GPasteSettings *self, gboolean value); void g_paste_settings_set_save_history (GPasteSettings *self, gboolean value); void g_paste_settings_set_show_history (GPasteSettings *self, const gchar *value); void g_paste_settings_set_sync_clipboard_to_primary (GPasteSettings *self, const gchar *value); void g_paste_settings_set_sync_primary_to_clipboard (GPasteSettings *self, const gchar *value); void g_paste_settings_set_synchronize_clipboards (GPasteSettings *self, gboolean value); void g_paste_settings_set_track_changes (GPasteSettings *self, gboolean value); void g_paste_settings_set_track_extension_state (GPasteSettings *self, gboolean value); void g_paste_settings_set_trim_items (GPasteSettings *self, gboolean value); void g_paste_settings_set_upload (GPasteSettings *self, const gchar *value); gboolean g_paste_settings_get_extension_enabled (const GPasteSettings *self); void g_paste_settings_set_extension_enabled (GPasteSettings *self, gboolean value); GPasteSettings *g_paste_settings_new (void); G_END_DECLS #endif /*__G_PASTE_SETTINGS_H__*/ GPaste-3.18.6/src/libgpaste/ui/000077500000000000000000000000001305131721400161475ustar00rootroot00000000000000GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-about.c000066400000000000000000000043751305131721400213320ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include struct _GPasteUiAbout { GtkButton parent_instance; }; typedef struct { GActionGroup *action_group; } GPasteUiAboutPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteUiAbout, g_paste_ui_about, GTK_TYPE_BUTTON) static void g_paste_ui_about_clicked (GtkButton *button) { GPasteUiAboutPrivate *priv = g_paste_ui_about_get_instance_private (G_PASTE_UI_ABOUT (button)); g_action_group_activate_action (priv->action_group, "about", NULL); } static void g_paste_ui_about_class_init (GPasteUiAboutClass *klass) { GTK_BUTTON_CLASS (klass)->clicked = g_paste_ui_about_clicked; } static void g_paste_ui_about_init (GPasteUiAbout *self) { gtk_widget_set_tooltip_text (GTK_WIDGET (self), _("About")); } /** * g_paste_ui_about_new: * @app: The #GtkApplication * * Create a new instance of #GPasteUiAbout * * Returns: a newly allocated #GPasteUiAbout * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_about_new (GtkApplication *app) { g_return_val_if_fail (GTK_IS_APPLICATION (app), NULL); GtkWidget *self = gtk_widget_new (G_PASTE_TYPE_UI_ABOUT, "image", gtk_image_new_from_icon_name ("dialog-information-symbolic", GTK_ICON_SIZE_BUTTON), NULL); GPasteUiAboutPrivate *priv = g_paste_ui_about_get_instance_private (G_PASTE_UI_ABOUT (self)); priv->action_group = G_ACTION_GROUP (app); return self; } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-about.h000066400000000000000000000023571305131721400213350ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_ABOUT_H__ #define __G_PASTE_UI_ABOUT_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_ABOUT (g_paste_ui_about_get_type ()) G_PASTE_FINAL_TYPE (UiAbout, ui_about, UI_ABOUT, GtkButton) GtkWidget *g_paste_ui_about_new (GtkApplication *app); G_END_DECLS #endif /*__G_PASTE_UI_ABOUT_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-backup-history.c000066400000000000000000000111301305131721400231470ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include struct _GPasteUiBackupHistory { GPasteUiHistoryAction parent_instance; }; G_DEFINE_TYPE (GPasteUiBackupHistory, g_paste_ui_backup_history, G_PASTE_TYPE_UI_HISTORY_ACTION) static void on_entry_activated (GtkEntry *entry G_GNUC_UNUSED, gpointer user_data) { GtkDialog *dialog = user_data; gtk_dialog_response (dialog, GTK_RESPONSE_OK); } static gchar * g_paste_ui_backup_history_confirm_dialog (GtkWindow *parent, const gchar *history) { g_autofree gchar *default_name = g_strdup_printf ("%s_backup", history); GtkWidget *dialog = gtk_dialog_new_with_buttons (PACKAGE_STRING, parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR, _("Backup"), GTK_RESPONSE_OK, _("Cancel"), GTK_RESPONSE_CANCEL, NULL); GtkDialog *d = GTK_DIALOG (dialog); GtkWidget *label = gtk_label_new (_("Under which name do you want to backup this history?")); GtkWidget *entry = gtk_entry_new (); GtkEntry *e = GTK_ENTRY (entry); GtkWidget *vbox = gtk_dialog_get_content_area (d); GtkBox *box = GTK_BOX (vbox); gtk_widget_set_margin_start (vbox, 10); gtk_widget_set_margin_end (vbox, 10); gtk_box_pack_start (box, label, TRUE, TRUE, 5); gtk_widget_show (label); gtk_box_pack_start (box, entry, TRUE, TRUE, 5); gtk_entry_set_text (e, default_name); gtk_widget_show (entry); gulong activated_id = g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (on_entry_activated), dialog); gchar *backup = NULL; if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) { const gchar *text = gtk_entry_get_text (e); if (text && *text) backup = g_strdup (text); } g_signal_handler_disconnect (entry, activated_id); gtk_widget_destroy (dialog); return backup; } static gboolean g_paste_ui_backup_history_activate (GPasteUiHistoryAction *self G_GNUC_UNUSED, GPasteClient *client, GtkWindow *rootwin, const gchar *history) { g_autofree gchar *backup = g_paste_ui_backup_history_confirm_dialog (rootwin, history); if (backup) g_paste_client_backup_history (client, history, backup, NULL, NULL); return TRUE; } static void g_paste_ui_backup_history_class_init (GPasteUiBackupHistoryClass *klass) { G_PASTE_UI_HISTORY_ACTION_CLASS (klass)->activate = g_paste_ui_backup_history_activate; } static void g_paste_ui_backup_history_init (GPasteUiBackupHistory *self G_GNUC_UNUSED) { } /** * g_paste_ui_backup_history_new: * @client: a #GPasteClient * @actions: the #GPasteUiHistoryActions * @rootwin: the root #GtkWindow * * Create a new instance of #GPasteUiBackupHistory * * Returns: a newly allocated #GPasteUiBackupHistory * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_backup_history_new (GPasteClient *client, GtkWidget *actions, GtkWindow *rootwin) { g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); g_return_val_if_fail (G_PASTE_IS_UI_HISTORY_ACTIONS (actions), NULL); g_return_val_if_fail (GTK_IS_WINDOW (rootwin), NULL); return g_paste_ui_history_action_new (G_PASTE_TYPE_UI_BACKUP_HISTORY, client, actions, rootwin, _("Backup")); } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-backup-history.h000066400000000000000000000027311305131721400231630ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_BACKUP_HISTORY_H__ #define __G_PASTE_UI_BACKUP_HISTORY_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_BACKUP_HISTORY (g_paste_ui_backup_history_get_type ()) G_PASTE_FINAL_TYPE (UiBackupHistory, ui_backup_history, UI_BACKUP_HISTORY, GPasteUiHistoryAction) GtkWidget *g_paste_ui_backup_history_new (GPasteClient *client, GtkWidget *actions, GtkWindow *rootwin); G_END_DECLS #endif /*__G_PASTE_UI_BACKUP_HISTORY_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-delete-history.c000066400000000000000000000051351305131721400231540ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include struct _GPasteUiDeleteHistory { GPasteUiHistoryAction parent_instance; }; G_DEFINE_TYPE (GPasteUiDeleteHistory, g_paste_ui_delete_history, G_PASTE_TYPE_UI_HISTORY_ACTION) static gboolean g_paste_ui_delete_history_activate (GPasteUiHistoryAction *self G_GNUC_UNUSED, GPasteClient *client, GtkWindow *rootwin, const gchar *history) { if (g_paste_util_confirm_dialog (rootwin, _("Delete"), _("Are you sure you want to delete this history?"))) g_paste_client_delete_history (client, history, NULL, NULL); return TRUE; } static void g_paste_ui_delete_history_class_init (GPasteUiDeleteHistoryClass *klass) { G_PASTE_UI_HISTORY_ACTION_CLASS (klass)->activate = g_paste_ui_delete_history_activate; } static void g_paste_ui_delete_history_init (GPasteUiDeleteHistory *self G_GNUC_UNUSED) { } /** * g_paste_ui_delete_history_new: * @client: a #GPasteClient * @actions: the #GPasteUiHistoryActions * @rootwin: the root #GtkWindow * * Create a new instance of #GPasteUiDeleteHistory * * Returns: a newly allocated #GPasteUiDeleteHistory * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_delete_history_new (GPasteClient *client, GtkWidget *actions, GtkWindow *rootwin) { g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); g_return_val_if_fail (G_PASTE_IS_UI_HISTORY_ACTIONS (actions), NULL); g_return_val_if_fail (GTK_IS_WINDOW (rootwin), NULL); return g_paste_ui_history_action_new (G_PASTE_TYPE_UI_DELETE_HISTORY, client, actions, rootwin, _("Delete")); } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-delete-history.h000066400000000000000000000027311305131721400231600ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_DELETE_HISTORY_H__ #define __G_PASTE_UI_DELETE_HISTORY_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_DELETE_HISTORY (g_paste_ui_delete_history_get_type ()) G_PASTE_FINAL_TYPE (UiDeleteHistory, ui_delete_history, UI_DELETE_HISTORY, GPasteUiHistoryAction) GtkWidget *g_paste_ui_delete_history_new (GPasteClient *client, GtkWidget *actions, GtkWindow *rootwin); G_END_DECLS #endif /*__G_PASTE_UI_DELETE_HISTORY_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-delete-item.c000066400000000000000000000037071305131721400224140ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include struct _GPasteUiDeleteItem { GPasteUiItemAction parent_instance; }; G_DEFINE_TYPE (GPasteUiDeleteItem, g_paste_ui_delete_item, G_PASTE_TYPE_UI_ITEM_ACTION) static void g_paste_ui_delete_item_activate (GPasteUiItemAction *self G_GNUC_UNUSED, GPasteClient *client, guint64 index) { g_paste_client_delete (client, index, NULL, NULL); } static void g_paste_ui_delete_item_class_init (GPasteUiDeleteItemClass *klass) { G_PASTE_UI_ITEM_ACTION_CLASS (klass)->activate = g_paste_ui_delete_item_activate; } static void g_paste_ui_delete_item_init (GPasteUiDeleteItem *self G_GNUC_UNUSED) { } /** * g_paste_ui_delete_item_new: * @client: a #GPasteClient * * Create a new instance of #GPasteUiDeleteItem * * Returns: a newly allocated #GPasteUiDeleteItem * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_delete_item_new (GPasteClient *client) { g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); return g_paste_ui_item_action_new (G_PASTE_TYPE_UI_DELETE_ITEM, client, "edit-delete-symbolic", _("Delete")); } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-delete-item.h000066400000000000000000000024661305131721400224220ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_DELETE_ITEM_H__ #define __G_PASTE_UI_DELETE_ITEM_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_DELETE_ITEM (g_paste_ui_delete_item_get_type ()) G_PASTE_FINAL_TYPE (UiDeleteItem, ui_delete_item, UI_DELETE_ITEM, GPasteUiItemAction) GtkWidget *g_paste_ui_delete_item_new (GPasteClient *client); G_END_DECLS #endif /*__G_PASTE_UI_DELETE_ITEM_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-edit-item.c000066400000000000000000000106011305131721400220660ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include struct _GPasteUiEditItem { GPasteUiItemAction parent_instance; }; typedef struct { GtkWindow *rootwin; } GPasteUiEditItemPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteUiEditItem, g_paste_ui_edit_item, G_PASTE_TYPE_UI_ITEM_ACTION) typedef struct { GPasteUiEditItemPrivate *priv; guint64 index; } CallbackData; static void on_item_ready (GObject *source_object, GAsyncResult *res, gpointer user_data) { g_autofree CallbackData *data = user_data; GPasteUiEditItemPrivate *priv = data->priv; GPasteClient *client = G_PASTE_CLIENT (source_object); g_autofree gchar *old_txt = g_paste_client_get_raw_element_finish (client, res, NULL); if (!old_txt) return; GtkWidget *dialog = gtk_dialog_new_with_buttons (PACKAGE_STRING, priv->rootwin, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR, _("Edit"), GTK_RESPONSE_OK, _("Cancel"), GTK_RESPONSE_CANCEL, NULL); GtkDialog *d = GTK_DIALOG (dialog); GtkWidget *text = gtk_text_view_new (); GtkTextView *tv = GTK_TEXT_VIEW (text); GtkTextBuffer *buf = gtk_text_view_get_buffer (tv); GtkWidget *scroll = gtk_scrolled_window_new (NULL, NULL); GtkScrolledWindow *sw = GTK_SCROLLED_WINDOW (scroll); gtk_text_view_set_wrap_mode (tv, GTK_WRAP_WORD); gtk_text_buffer_set_text (buf, old_txt, -1); gtk_scrolled_window_set_min_content_height (sw, 300); gtk_scrolled_window_set_min_content_width (sw, 600); gtk_container_add (GTK_CONTAINER (sw), text); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (d)), scroll, TRUE, TRUE, 0); gtk_widget_show_all (scroll); if (gtk_dialog_run (d) == GTK_RESPONSE_OK) { const gchar *txt; g_object_get (G_OBJECT (buf), "text", &txt, NULL); if (txt && *txt) g_paste_client_replace (client, data->index, txt, NULL, NULL); } gtk_widget_destroy (dialog); } static void g_paste_ui_edit_item_activate (GPasteUiItemAction *self, GPasteClient *client, guint64 index) { CallbackData *data = g_malloc (sizeof (CallbackData)); data->priv = g_paste_ui_edit_item_get_instance_private (G_PASTE_UI_EDIT_ITEM (self)); data->index = index; g_paste_client_get_raw_element (client, index, on_item_ready, data); } static void g_paste_ui_edit_item_class_init (GPasteUiEditItemClass *klass) { G_PASTE_UI_ITEM_ACTION_CLASS (klass)->activate = g_paste_ui_edit_item_activate; } static void g_paste_ui_edit_item_init (GPasteUiEditItem *self G_GNUC_UNUSED) { } /** * g_paste_ui_edit_item_new: * @client: a #GPasteClient * @rootwin: the root #GtkWindow * * Create a new instance of #GPasteUiEditItem * * Returns: a newly allocated #GPasteUiEditItem * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_edit_item_new (GPasteClient *client, GtkWindow *rootwin) { g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); g_return_val_if_fail (GTK_IS_WINDOW (rootwin), NULL); GtkWidget *self = g_paste_ui_item_action_new (G_PASTE_TYPE_UI_EDIT_ITEM, client, "accessories-text-editor-symbolic", _("Edit")); GPasteUiEditItemPrivate *priv = g_paste_ui_edit_item_get_instance_private (G_PASTE_UI_EDIT_ITEM (self)); priv->rootwin = rootwin; return self; } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-edit-item.h000066400000000000000000000025401305131721400220760ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_EDIT_ITEM_H__ #define __G_PASTE_UI_EDIT_ITEM_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_EDIT_ITEM (g_paste_ui_edit_item_get_type ()) G_PASTE_FINAL_TYPE (UiEditItem, ui_edit_item, UI_EDIT_ITEM, GPasteUiItemAction) GtkWidget *g_paste_ui_edit_item_new (GPasteClient *client, GtkWindow *rootwin); G_END_DECLS #endif /*__G_PASTE_UI_EDIT_ITEM_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-empty-history.c000066400000000000000000000053221305131721400230460ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include struct _GPasteUiEmptyHistory { GPasteUiHistoryAction parent_instance; }; G_DEFINE_TYPE (GPasteUiEmptyHistory, g_paste_ui_empty_history, G_PASTE_TYPE_UI_HISTORY_ACTION) static gboolean g_paste_ui_empty_history_activate (GPasteUiHistoryAction *self G_GNUC_UNUSED, GPasteClient *client, GtkWindow *rootwin, const gchar *history) { /* Translators: this is the translation for emptying the history */ if (g_paste_util_confirm_dialog (rootwin, _("Empty"), _("Do you really want to empty the history?"))) g_paste_client_empty_history (client, history, NULL, NULL); return TRUE; } static void g_paste_ui_empty_history_class_init (GPasteUiEmptyHistoryClass *klass) { G_PASTE_UI_HISTORY_ACTION_CLASS (klass)->activate = g_paste_ui_empty_history_activate; } static void g_paste_ui_empty_history_init (GPasteUiEmptyHistory *self G_GNUC_UNUSED) { } /** * g_paste_ui_empty_new: * @client: a #GPasteClient instance * @actions: the #GPasteUiHistoryActions * @rootwin: the main #GtkWindow * * Create a new instance of #GPasteUiEmptyHistory * * Returns: a newly allocated #GPasteUiEmptyHistory * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_empty_history_new (GPasteClient *client, GtkWidget *actions, GtkWindow *rootwin) { g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); g_return_val_if_fail (G_PASTE_IS_UI_HISTORY_ACTIONS (actions), NULL); g_return_val_if_fail (GTK_IS_WINDOW (rootwin), NULL); /* Translators: this is the translation for emptying the history */ return g_paste_ui_history_action_new (G_PASTE_TYPE_UI_EMPTY_HISTORY, client, actions, rootwin, _("Empty")); } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-empty-history.h000066400000000000000000000027161305131721400230570ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_EMPTY_HISTORY_H__ #define __G_PASTE_UI_EMPTY_HISTORY_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_EMPTY_HISTORY (g_paste_ui_empty_history_get_type ()) G_PASTE_FINAL_TYPE (UiEmptyHistory, ui_empty_history, UI_EMPTY_HISTORY, GPasteUiHistoryAction) GtkWidget *g_paste_ui_empty_history_new (GPasteClient *client, GtkWidget *actions, GtkWindow *rootwin); G_END_DECLS #endif /*__G_PASTE_UI_EMPTY_HISTORY_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-empty-item.c000066400000000000000000000041231305131721400223010ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include struct _GPasteUiEmptyItem { GPasteUiItemSkeleton parent_instance; }; G_DEFINE_TYPE (GPasteUiEmptyItem, g_paste_ui_empty_item, G_PASTE_TYPE_UI_ITEM_SKELETON) static void g_paste_ui_empty_item_class_init (GPasteUiEmptyItemClass *klass G_GNUC_UNUSED) { } static void g_paste_ui_empty_item_init (GPasteUiEmptyItem *self) { g_paste_ui_item_skeleton_set_text (G_PASTE_UI_ITEM_SKELETON (self), _("(Empty)")); } /** * g_paste_ui_empty_item_new: * @client: a #GPasteClient instance * @settings: a #GPasteSettings instance * @rootwin: the root #GtkWindow * * Create a new instance of #GPasteUiEmptyItem * * Returns: a newly allocated #GPasteUiEmptyItem * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_empty_item_new (GPasteClient *client, GPasteSettings *settings, GtkWindow *rootwin) { g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); g_return_val_if_fail (G_PASTE_IS_SETTINGS (settings), NULL); g_return_val_if_fail (GTK_IS_WINDOW (rootwin), NULL); GtkWidget *self = g_paste_ui_item_skeleton_new (G_PASTE_TYPE_UI_EMPTY_ITEM, client, settings, rootwin); g_paste_ui_item_skeleton_set_activatable (G_PASTE_UI_ITEM_SKELETON (self), FALSE); return self; } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-empty-item.h000066400000000000000000000026621305131721400223140ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_EMPTY_ITEM_H__ #define __G_PASTE_UI_EMPTY_ITEM_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_EMPTY_ITEM (g_paste_ui_empty_item_get_type ()) G_PASTE_FINAL_TYPE (UiEmptyItem, ui_empty_item, UI_EMPTY_ITEM, GPasteUiItemSkeleton) GtkWidget *g_paste_ui_empty_item_new (GPasteClient *client, GPasteSettings *settings, GtkWindow *rootwin); G_END_DECLS #endif /*__G_PASTE_UI_EMPTY_ITEM_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-header.c000066400000000000000000000070111305131721400214360ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include #include #include #include struct _GPasteUiHeader { GtkHeaderBar parent_instance; }; typedef struct { GtkButton *settings; GtkButton *search; } GPasteUiHeaderPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteUiHeader, g_paste_ui_header, GTK_TYPE_HEADER_BAR) /** * g_paste_ui_header_show_prefs: * @self: the #GPasteUiHeader * * Show the prefs pane * * Returns: */ G_PASTE_VISIBLE void g_paste_ui_header_show_prefs (const GPasteUiHeader *self) { g_return_if_fail (G_PASTE_IS_UI_HEADER (self)); GPasteUiHeaderPrivate *priv = g_paste_ui_header_get_instance_private (self); gtk_button_clicked (priv->settings); } /** * g_paste_ui_header_get_search_button: * @self: the #GPasteUiHeader * * Get the search button * * Returns: (transfer none): the #GPasteUISearch instance */ G_PASTE_VISIBLE GtkButton * g_paste_ui_header_get_search_button (const GPasteUiHeader *self) { g_return_val_if_fail (G_PASTE_IS_UI_HEADER (self), NULL); GPasteUiHeaderPrivate *priv = g_paste_ui_header_get_instance_private (self); return priv->search; } static void g_paste_ui_header_class_init (GPasteUiHeaderClass *klass G_GNUC_UNUSED) { } static void g_paste_ui_header_init (GPasteUiHeader *self) { GPasteUiHeaderPrivate *priv = g_paste_ui_header_get_instance_private (self); GtkHeaderBar *header_bar = GTK_HEADER_BAR (self); GtkWidget *settings = g_paste_ui_settings_new (); GtkWidget *search = g_paste_ui_search_new (); priv->settings = GTK_BUTTON (settings); priv->search = GTK_BUTTON (search); gtk_header_bar_set_title(header_bar, PACKAGE_STRING); gtk_header_bar_set_show_close_button (header_bar, TRUE); gtk_header_bar_pack_end (header_bar, settings); gtk_header_bar_pack_end (header_bar, search); } /** * g_paste_ui_header_new: * @topwin: the main #GtkWindow * @client: a #GPasteClient instance * * Create a new instance of #GPasteUiHeader * * Returns: a newly allocated #GPasteUiHeader * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_header_new (GtkWindow *topwin, GPasteClient *client) { g_return_val_if_fail (GTK_IS_WINDOW (topwin), NULL); g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); GtkWidget *self = gtk_widget_new (G_PASTE_TYPE_UI_HEADER, NULL); GtkHeaderBar *bar = GTK_HEADER_BAR (self); gtk_header_bar_pack_start (bar, g_paste_ui_switch_new (topwin, client)); gtk_header_bar_pack_start (bar, g_paste_ui_reexec_new (topwin, client)); gtk_header_bar_pack_end (bar, g_paste_ui_about_new (gtk_window_get_application (topwin))); return self; } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-header.h000066400000000000000000000027031305131721400214460ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_HEADER_H__ #define __G_PASTE_UI_HEADER_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_HEADER (g_paste_ui_header_get_type ()) G_PASTE_FINAL_TYPE (UiHeader, ui_header, UI_HEADER, GtkHeaderBar) void g_paste_ui_header_show_prefs (const GPasteUiHeader *self); GtkButton *g_paste_ui_header_get_search_button (const GPasteUiHeader *self); GtkWidget *g_paste_ui_header_new (GtkWindow *topwin, GPasteClient *client); G_END_DECLS #endif /*__G_PASTE_UI_HEADER_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-history-action.c000066400000000000000000000121271305131721400231660ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include typedef struct { GPasteClient *client; GPasteUiHistoryActions *actions; GtkWindow *rootwin; gchar *history; } GPasteUiHistoryActionPrivate; G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GPasteUiHistoryAction, g_paste_ui_history_action, GTK_TYPE_BUTTON) /** * g_paste_ui_history_action_set_history: * @self: a #GPasteUiHistoryAction instance * @history: the history to delete * * Set the history to delete * * Returns: */ G_PASTE_VISIBLE void g_paste_ui_history_action_set_history (GPasteUiHistoryAction *self, const gchar *history) { g_return_if_fail (G_PASTE_IS_UI_HISTORY_ACTION (self)); GPasteUiHistoryActionPrivate *priv = g_paste_ui_history_action_get_instance_private (G_PASTE_UI_HISTORY_ACTION (self)); g_free (priv->history); priv->history = g_strdup (history); } static gboolean g_paste_ui_history_action_button_press_event (GtkWidget *widget, GdkEventButton *event G_GNUC_UNUSED) { GPasteUiHistoryAction *self = G_PASTE_UI_HISTORY_ACTION (widget); GPasteUiHistoryActionClass *klass = G_PASTE_UI_HISTORY_ACTION_GET_CLASS (self); GPasteUiHistoryActionPrivate *priv = g_paste_ui_history_action_get_instance_private (self); gboolean ret; if (priv->history && klass->activate) ret = klass->activate (self, priv->client, priv->rootwin, priv->history); else ret = GTK_WIDGET_CLASS (g_paste_ui_history_action_parent_class)->button_press_event (widget, event); g_paste_ui_history_actions_set_relative_to (priv->actions, NULL); return ret; } static void g_paste_ui_history_action_dispose (GObject *object) { GPasteUiHistoryActionPrivate *priv = g_paste_ui_history_action_get_instance_private (G_PASTE_UI_HISTORY_ACTION (object)); g_clear_object (&priv->client); G_OBJECT_CLASS (g_paste_ui_history_action_parent_class)->dispose (object); } static void g_paste_ui_history_action_finalize (GObject *object) { GPasteUiHistoryActionPrivate *priv = g_paste_ui_history_action_get_instance_private (G_PASTE_UI_HISTORY_ACTION (object)); g_free (priv->history); G_OBJECT_CLASS (g_paste_ui_history_action_parent_class)->finalize (object); } static void g_paste_ui_history_action_class_init (GPasteUiHistoryActionClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->dispose = g_paste_ui_history_action_dispose; object_class->finalize = g_paste_ui_history_action_finalize; GTK_WIDGET_CLASS (klass)->button_press_event = g_paste_ui_history_action_button_press_event; } static void g_paste_ui_history_action_init (GPasteUiHistoryAction *self) { GtkWidget *button = GTK_WIDGET (self); gtk_widget_set_margin_start (button, 5); gtk_widget_set_margin_end (button, 5); } /** * g_paste_ui_history_action_new: * @type: the type of the subclass to instantiate * @client: a #GPasteClient * @actions: a #GPasteUiHistoryActions * @rootwin: the main #GtkWindow * * Create a new instance of #GPasteUiHistoryAction * * Returns: a newly allocated #GPasteUiHistoryAction * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_history_action_new (GType type, GPasteClient *client, GtkWidget *actions, GtkWindow *rootwin, const gchar *label) { g_return_val_if_fail (g_type_is_a (type, G_PASTE_TYPE_UI_HISTORY_ACTION), NULL); g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); g_return_val_if_fail (G_PASTE_IS_UI_HISTORY_ACTIONS (actions), NULL); g_return_val_if_fail (GTK_IS_WINDOW (rootwin), NULL); GtkWidget *self = gtk_widget_new (type, "width-request", 200, "height-request", 30, NULL); GPasteUiHistoryActionPrivate *priv = g_paste_ui_history_action_get_instance_private (G_PASTE_UI_HISTORY_ACTION (self)); priv->client = g_object_ref (client); priv->actions = G_PASTE_UI_HISTORY_ACTIONS (actions); priv->rootwin = rootwin; gtk_button_set_label (GTK_BUTTON (self), label); return self; } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-history-action.h000066400000000000000000000040631305131721400231730ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_HISTORY_ACTION_H__ #define __G_PASTE_UI_HISTORY_ACTION_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_HISTORY_ACTION (g_paste_ui_history_action_get_type ()) G_PASTE_DERIVABLE_TYPE (UiHistoryAction, ui_history_action, UI_HISTORY_ACTION, GtkButton) struct _GPasteUiHistoryActionClass { GtkButtonClass parent_class; /*< pure virtual >*/ gboolean (*activate) (GPasteUiHistoryAction *self, GPasteClient *client, GtkWindow *rootwin, const gchar *history); }; void g_paste_ui_history_action_set_history (GPasteUiHistoryAction *self, const gchar *history); GtkWidget *g_paste_ui_history_action_new (GType type, GPasteClient *client, GtkWidget *actions, GtkWindow *rootwin, const gchar *label); G_END_DECLS #endif /*__G_PASTE_UI_HISTORY_ACTION_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-history-actions.c000066400000000000000000000114251305131721400233510ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include #include struct _GPasteUiHistoryActions { GtkPopover parent_instance; }; typedef struct { GPasteClient *client; GSList *actions; } GPasteUiHistoryActionsPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteUiHistoryActions, g_paste_ui_history_actions, GTK_TYPE_POPOVER) static void action_set_history (gpointer data, gpointer user_data) { GPasteUiHistoryAction *action = data; const gchar *history = user_data; g_paste_ui_history_action_set_history (action, history); } /** * g_paste_ui_history_actions_set_relative_to: * @self: the #GPasteUiHistoryActions * @history: (nullable): a #GPasteUiPanelHistory instance * * Set which history we'll deal with * * Returns: */ G_PASTE_VISIBLE void g_paste_ui_history_actions_set_relative_to (GPasteUiHistoryActions *self, GPasteUiPanelHistory *history) { g_return_if_fail (G_PASTE_IS_UI_HISTORY_ACTIONS (self)); g_return_if_fail (!history || G_PASTE_IS_UI_PANEL_HISTORY (history)); GPasteUiHistoryActionsPrivate *priv = g_paste_ui_history_actions_get_instance_private (self); const gchar *h = (history) ? g_paste_ui_panel_history_get_history (history) : NULL; g_slist_foreach (priv->actions, action_set_history, (gpointer) h); if (history) gtk_popover_set_relative_to (GTK_POPOVER (self), GTK_WIDGET (history)); else gtk_widget_hide (GTK_WIDGET (self)); } static void add_action_to_box (gpointer data, gpointer user_data) { GtkContainer *box = user_data; GtkWidget *action = data; gtk_container_add (box, action); } static void g_paste_ui_history_actions_dispose (GObject *object) { GPasteUiHistoryActionsPrivate *priv = g_paste_ui_history_actions_get_instance_private (G_PASTE_UI_HISTORY_ACTIONS (object)); g_clear_object (&priv->client); G_OBJECT_CLASS (g_paste_ui_history_actions_parent_class)->dispose (object); } static void g_paste_ui_history_actions_class_init (GPasteUiHistoryActionsClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_ui_history_actions_dispose; } static void g_paste_ui_history_actions_init (GPasteUiHistoryActions *self G_GNUC_UNUSED) { } /** * g_paste_ui_history_actions_new: * @client: a #GPasteClient instance * @rootwin: the root #GtkWindow * * Create a new instance of #GPasteUiHistoryActions * * Returns: a newly allocated #GPasteUiHistoryActions * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_history_actions_new (GPasteClient *client, GtkWindow *rootwin) { g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); g_return_val_if_fail (GTK_IS_WINDOW (rootwin), NULL); GtkWidget *self = gtk_widget_new (G_PASTE_TYPE_UI_HISTORY_ACTIONS, "width-request", 200, "height-request", 40, NULL); GPasteUiHistoryActionsPrivate *priv = g_paste_ui_history_actions_get_instance_private (G_PASTE_UI_HISTORY_ACTIONS (self)); GtkWidget *box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); GtkWidget *backup = g_paste_ui_backup_history_new (client, self, rootwin); GtkWidget *delete = g_paste_ui_delete_history_new (client, self, rootwin); GtkWidget *empty = g_paste_ui_empty_history_new (client, self, rootwin); priv->client = g_object_ref (client); priv->actions = g_slist_append (priv->actions, backup); priv->actions = g_slist_append (priv->actions, empty); priv->actions = g_slist_append (priv->actions, delete); gtk_popover_set_position (GTK_POPOVER (self), GTK_POS_RIGHT); g_slist_foreach (priv->actions, add_action_to_box, box); gtk_widget_set_margin_top (box, 5); gtk_widget_set_margin_bottom (box, 5); gtk_widget_show_all (box); gtk_container_add (GTK_CONTAINER (self), box); return self; } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-history-actions.h000066400000000000000000000030711305131721400233540ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_HISTORY_ACTIONS_H__ #define __G_PASTE_UI_HISTORY_ACTIONS_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_HISTORY_ACTIONS (g_paste_ui_history_actions_get_type ()) G_PASTE_FINAL_TYPE (UiHistoryActions, ui_history_actions, UI_HISTORY_ACTIONS, GtkPopover) void g_paste_ui_history_actions_set_relative_to (GPasteUiHistoryActions *self, GPasteUiPanelHistory *history); GtkWidget *g_paste_ui_history_actions_new (GPasteClient *client, GtkWindow *rootwin); G_END_DECLS #endif /*__G_PASTE_UI_HISTORY_ACTIONS_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-history.c000066400000000000000000000320161305131721400217120ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include #include #include struct _GPasteUiHistory { GtkListBox parent_instance; }; typedef struct { GPasteClient *client; GPasteSettings *settings; GPasteUiPanel *panel; GtkWidget *dummy_item; GtkWindow *rootwin; GSList *items; guint64 size; gint32 item_height; gchar *search; guint64 *search_results; guint64 search_results_size; gulong activated_id; gulong size_id; gulong update_id; } GPasteUiHistoryPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteUiHistory, g_paste_ui_history, GTK_TYPE_LIST_BOX) static void on_row_activated (GtkListBox *history G_GNUC_UNUSED, GtkListBoxRow *row, gpointer user_data G_GNUC_UNUSED) { g_paste_ui_item_activate (G_PASTE_UI_ITEM (row)); } static void g_paste_ui_history_add_item (gpointer data, gpointer user_data) { GtkContainer *self = user_data; GtkWidget *item = data; g_object_ref (item); gtk_container_add (self, item); gtk_widget_show_all (item); } static void g_paste_ui_history_add_list (GtkContainer *self, GSList *list) { g_slist_foreach (list, g_paste_ui_history_add_item, self); } static void g_paste_ui_history_remove (gpointer data, gpointer user_data) { GtkWidget *item = data; GtkContainer *self = user_data; gtk_container_remove (self, item); g_object_unref (item); } static void g_paste_ui_history_drop_list (GtkContainer *self, GSList *list) { g_slist_foreach (list, g_paste_ui_history_remove, self); g_slist_free (list); } static void g_paste_ui_history_refresh (GPasteUiHistory *self, guint64 from_index); static void g_paste_ui_history_update_height_request (GPasteSettings *settings, const gchar *key G_GNUC_UNUSED, gpointer user_data) { GPasteUiHistory *self = user_data; GPasteUiHistoryPrivate *priv = g_paste_ui_history_get_instance_private (self); guint64 new_size = g_paste_settings_get_max_displayed_history_size (settings); if (priv->item_height) g_object_set (G_OBJECT (self), "height-request", new_size * priv->item_height, NULL); if (new_size != priv->size) g_paste_ui_history_refresh (self, 0); } typedef struct { GPasteUiHistory *self; gchar *name; guint64 from_index; } OnUpdateCallbackData; static void g_paste_ui_history_refresh_history (GObject *source_object G_GNUC_UNUSED, GAsyncResult *res, gpointer user_data) { g_autofree OnUpdateCallbackData *data = user_data; g_autofree gchar *name = data->name; GPasteUiHistory *self = data->self; GPasteUiHistoryPrivate *priv = g_paste_ui_history_get_instance_private (self); guint64 old_size = priv->size; guint64 refreshTextBound = old_size; guint64 new_size = g_paste_client_get_history_size_finish (priv->client, res, NULL); guint64 max_size = g_paste_settings_get_max_displayed_history_size (priv->settings); priv->size = MIN (new_size, max_size); if (priv->size) gtk_widget_hide (priv->dummy_item); else gtk_widget_show (priv->dummy_item); g_paste_ui_panel_update_history_length (priv->panel, name, new_size); if (old_size < priv->size) { for (guint64 i = old_size; i < priv->size; ++i) { GtkWidget *item = g_paste_ui_item_new (priv->client, priv->settings, priv->rootwin, i); priv->items = g_slist_append (priv->items, item); } g_paste_ui_history_add_list (GTK_CONTAINER (self), g_slist_nth (priv->items, old_size)); refreshTextBound = old_size; } else if (old_size > priv->size) { if (priv->size) { GSList *last = g_slist_nth (priv->items, priv->size - 1); g_return_if_fail (last); g_paste_ui_history_drop_list (GTK_CONTAINER (self), g_slist_next (last)); last->next = NULL; } else { g_paste_ui_history_drop_list (GTK_CONTAINER (self), priv->items); priv->items = NULL; } refreshTextBound = priv->size; } GSList *item = priv->items; for (guint64 i = 0; i < data->from_index; ++i) item = g_slist_next (item); for (guint64 i = data->from_index; i < refreshTextBound && item; ++i, item = g_slist_next (item)) g_paste_ui_item_set_index (item->data, i); if (!priv->item_height) { gtk_widget_get_preferred_height ((priv->items) ? GTK_WIDGET (priv->items->data) : priv->dummy_item, NULL, &priv->item_height); g_paste_ui_history_update_height_request (priv->settings, NULL, self); } } static void on_name_ready (GObject *source_object G_GNUC_UNUSED, GAsyncResult *res, gpointer user_data) { OnUpdateCallbackData *data = user_data; GPasteUiHistoryPrivate *priv = g_paste_ui_history_get_instance_private (data->self); data->name = g_paste_client_get_history_name_finish (priv->client, res, NULL); g_paste_client_get_history_size (priv->client, data->name, g_paste_ui_history_refresh_history, data); } static void g_paste_ui_history_refresh (GPasteUiHistory *self, guint64 from_index) { GPasteUiHistoryPrivate *priv = g_paste_ui_history_get_instance_private (self); if (priv->search) { g_paste_ui_history_search (self, priv->search); } else { OnUpdateCallbackData *data = g_new (OnUpdateCallbackData, 1); data->self = self; data->from_index = from_index; g_paste_client_get_history_name (priv->client, on_name_ready, data); } } static void on_search_ready (GObject *source_object G_GNUC_UNUSED, GAsyncResult *res, gpointer user_data) { GPasteUiHistory *self = user_data; GPasteUiHistoryPrivate *priv = g_paste_ui_history_get_instance_private (self); priv->search_results = g_paste_client_search_finish (priv->client, res, &priv->search_results_size, NULL /* error */); if (!priv->search_results) priv->search_results_size = 0; else if (priv->search_results_size > priv->size) priv->search_results_size = priv->size; GSList *item = priv->items; for (guint64 i = 0; i < priv->search_results_size; ++i, item = g_slist_next (item)) g_paste_ui_item_set_index (item->data, priv->search_results[i]); for (guint64 i = priv->search_results_size; i < priv->size; ++i, item = g_slist_next (item)) g_paste_ui_item_set_index (item->data, -1); } /** * g_paste_ui_history_search: * @self: a #GPasteUiHistory instance * @search: the search * * Apply a search to a #GPasteUiHistory instance * * Returns: */ G_PASTE_VISIBLE void g_paste_ui_history_search (GPasteUiHistory *self, const gchar *search) { g_return_if_fail (G_PASTE_IS_UI_HISTORY (self)); GPasteUiHistoryPrivate *priv = g_paste_ui_history_get_instance_private (self); if (!g_strcmp0 (search, "")) { g_clear_pointer (&priv->search, g_free); g_clear_pointer (&priv->search_results, g_free); priv->search_results_size = 0; g_paste_ui_history_refresh (self, 0); } else { g_free (priv->search); priv->search = g_strdup (search); g_paste_client_search (priv->client, search, on_search_ready, self); } } static void g_paste_ui_history_on_update (GPasteClient *client G_GNUC_UNUSED, GPasteUpdateAction action, GPasteUpdateTarget target, guint64 position, gpointer user_data) { GPasteUiHistory *self = user_data; GPasteUiHistoryPrivate *priv = g_paste_ui_history_get_instance_private (self); gboolean refresh = FALSE; switch (target) { case G_PASTE_UPDATE_TARGET_ALL: refresh = TRUE; break; case G_PASTE_UPDATE_TARGET_POSITION: switch (action) { case G_PASTE_UPDATE_ACTION_REPLACE: g_paste_ui_item_refresh (g_slist_nth_data (priv->items, position)); break; case G_PASTE_UPDATE_ACTION_REMOVE: refresh = TRUE; break; default: g_assert_not_reached (); } break; default: g_assert_not_reached (); } if (refresh) g_paste_ui_history_refresh (self, position); } static void g_paste_ui_history_dispose (GObject *object) { GPasteUiHistoryPrivate *priv = g_paste_ui_history_get_instance_private (G_PASTE_UI_HISTORY (object)); if (priv->activated_id) { g_signal_handler_disconnect (object, priv->activated_id); priv->activated_id = 0; } if (priv->settings) { g_signal_handler_disconnect (priv->settings, priv->size_id); g_clear_object (&priv->settings); } if (priv->client) { g_signal_handler_disconnect (priv->client, priv->update_id); g_clear_object (&priv->client); } G_OBJECT_CLASS (g_paste_ui_history_parent_class)->dispose (object); } static void g_paste_ui_history_finalize (GObject *object) { GPasteUiHistoryPrivate *priv = g_paste_ui_history_get_instance_private (G_PASTE_UI_HISTORY (object)); g_free (priv->search); g_free (priv->search_results); G_OBJECT_CLASS (g_paste_ui_history_parent_class)->finalize (object); } static void g_paste_ui_history_class_init (GPasteUiHistoryClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->dispose = g_paste_ui_history_dispose; object_class->finalize = g_paste_ui_history_finalize; } static void g_paste_ui_history_init (GPasteUiHistory *self) { GPasteUiHistoryPrivate *priv = g_paste_ui_history_get_instance_private (self); priv->activated_id = g_signal_connect (G_OBJECT (self), "row-activated", G_CALLBACK (on_row_activated), NULL); } /** * g_paste_ui_history_new: * @client: a #GPasteClient instance * @settings: a #GPasteSettings instance * @panel: the #GPasteSettingsUiPanel * @rootwin: the root #GtkWindow * * Create a new instance of #GPasteUiHistory * * Returns: a newly allocated #GPasteUiHistory * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_history_new (GPasteClient *client, GPasteSettings *settings, GPasteUiPanel *panel, GtkWindow *rootwin) { g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); g_return_val_if_fail (G_PASTE_IS_SETTINGS (settings), NULL); g_return_val_if_fail (G_PASTE_IS_UI_PANEL (panel), NULL); g_return_val_if_fail (GTK_IS_WINDOW (rootwin), NULL); GtkWidget *self = gtk_widget_new (G_PASTE_TYPE_UI_HISTORY, NULL); GPasteUiHistoryPrivate *priv = g_paste_ui_history_get_instance_private (G_PASTE_UI_HISTORY (self)); priv->client = g_object_ref (client); priv->settings = g_object_ref (settings); priv->dummy_item = g_paste_ui_empty_item_new (client, settings, rootwin); priv->panel = panel; priv->rootwin = rootwin; gtk_container_add (GTK_CONTAINER (self), priv->dummy_item); priv->size_id = g_signal_connect (settings, "changed::" G_PASTE_MAX_DISPLAYED_HISTORY_SIZE_SETTING, G_CALLBACK (g_paste_ui_history_update_height_request), self); priv->update_id = g_signal_connect (client, "update", G_CALLBACK (g_paste_ui_history_on_update), self); g_paste_ui_history_on_update (client, G_PASTE_UPDATE_ACTION_REPLACE, G_PASTE_UPDATE_TARGET_ALL, 0, self); return self; } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-history.h000066400000000000000000000030541305131721400217170ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_HISTORY_H__ #define __G_PASTE_UI_HISTORY_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_HISTORY (g_paste_ui_history_get_type ()) G_PASTE_FINAL_TYPE (UiHistory, ui_history, UI_HISTORY, GtkListBox) void g_paste_ui_history_search (GPasteUiHistory *self, const gchar *search); GtkWidget *g_paste_ui_history_new (GPasteClient *client, GPasteSettings *settings, GPasteUiPanel *panel, GtkWindow *rootwin); G_END_DECLS #endif /*__G_PASTE_UI_HISTORY_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-item-action.c000066400000000000000000000076011305131721400224240ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include typedef struct { GPasteClient *client; guint64 index; } GPasteUiItemActionPrivate; G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GPasteUiItemAction, g_paste_ui_item_action, GTK_TYPE_BUTTON) /** * g_paste_ui_item_action_set_index: * @self: a #GPasteUiItemAction instance * @index: the index of the corresponding item * * Track a new index * * Returns: */ G_PASTE_VISIBLE void g_paste_ui_item_action_set_index (GPasteUiItemAction *self, guint64 index) { g_return_if_fail (G_PASTE_IS_UI_ITEM_ACTION (self)); GPasteUiItemActionPrivate *priv = g_paste_ui_item_action_get_instance_private (self); priv->index = index; } static gboolean g_paste_ui_item_action_button_press_event (GtkWidget *widget, GdkEventButton *event G_GNUC_UNUSED) { GPasteUiItemAction *self = G_PASTE_UI_ITEM_ACTION (widget); GPasteUiItemActionPrivate *priv = g_paste_ui_item_action_get_instance_private (self); GPasteUiItemActionClass *klass = G_PASTE_UI_ITEM_ACTION_GET_CLASS (self); if (klass->activate) klass->activate (self, priv->client, priv->index); return TRUE; } static void g_paste_ui_item_action_dispose (GObject *object) { GPasteUiItemActionPrivate *priv = g_paste_ui_item_action_get_instance_private (G_PASTE_UI_ITEM_ACTION (object)); g_clear_object (&priv->client); G_OBJECT_CLASS (g_paste_ui_item_action_parent_class)->dispose (object); } static void g_paste_ui_item_action_class_init (GPasteUiItemActionClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_ui_item_action_dispose; GTK_WIDGET_CLASS (klass)->button_press_event = g_paste_ui_item_action_button_press_event; } static void g_paste_ui_item_action_init (GPasteUiItemAction *self) { GPasteUiItemActionPrivate *priv = g_paste_ui_item_action_get_instance_private (self); priv->index = -1; } /** * g_paste_ui_item_action_new: * @type: the type of the subclass to instantiate * @client: a #GPasteClient * @icon_name: the name of the icon to use * @tooltip: the tooltip to display * * Create a new instance of #GPasteUiItemAction * * Returns: a newly allocated #GPasteUiItemAction * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_item_action_new (GType type, GPasteClient *client, const gchar *icon_name, const gchar *tooltip) { g_return_val_if_fail (g_type_is_a (type, G_PASTE_TYPE_UI_ITEM_ACTION), NULL); g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); GtkWidget *self = gtk_widget_new (type, NULL); GPasteUiItemActionPrivate *priv = g_paste_ui_item_action_get_instance_private (G_PASTE_UI_ITEM_ACTION (self)); GtkWidget *icon = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU); priv->client = g_object_ref (client); gtk_widget_set_tooltip_text (self, tooltip); gtk_widget_set_margin_start (icon, 5); gtk_widget_set_margin_end (icon, 5); gtk_container_add (GTK_CONTAINER (self), icon); return self; } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-item-action.h000066400000000000000000000035341305131721400224320ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_ITEM_ACTION_H__ #define __G_PASTE_UI_ITEM_ACTION_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_ITEM_ACTION (g_paste_ui_item_action_get_type ()) G_PASTE_DERIVABLE_TYPE (UiItemAction, ui_item_action, UI_ITEM_ACTION, GtkButton) struct _GPasteUiItemActionClass { GtkButtonClass parent_class; /*< pure virtual >*/ void (*activate) (GPasteUiItemAction *self, GPasteClient *client, guint64 index); }; void g_paste_ui_item_action_set_index (GPasteUiItemAction *self, guint64 index); GtkWidget *g_paste_ui_item_action_new (GType type, GPasteClient *client, const gchar *icon_name, const gchar *tooltip); G_END_DECLS #endif /*__G_PASTE_UI_ITEM_ACTION_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-item-skeleton.c000066400000000000000000000237051305131721400227760ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include #include #include typedef struct { GPasteSettings *settings; GSList *actions; GtkWidget *edit; GtkWidget *upload; GtkLabel *index_label; GtkLabel *label; gboolean editable; gulong size_id; } GPasteUiItemSkeletonPrivate; G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GPasteUiItemSkeleton, g_paste_ui_item_skeleton, GTK_TYPE_LIST_BOX_ROW) static void g_paste_ui_item_skeleton_set_text_size (GPasteSettings *settings, const gchar *key G_GNUC_UNUSED, gpointer user_data) { GPasteUiItemSkeletonPrivate *priv = user_data; guint64 size = g_paste_settings_get_element_size (settings); gtk_label_set_width_chars (priv->label, size); gtk_label_set_max_width_chars (priv->label, size); } static void action_set_activatable (gpointer data, gpointer user_data) { GtkWidget *w = data; gboolean *a = user_data; gtk_widget_set_sensitive (w, *a); } /** * g_paste_ui_item_skeleton_set_activatable: * @self: the #GPasteUiItemSkeleton instance * @activatable: whether the item should now be activatable or not * * Mark the item as being activatable or not * * Returns: */ G_PASTE_VISIBLE void g_paste_ui_item_skeleton_set_activatable (GPasteUiItemSkeleton *self, gboolean activatable) { g_return_if_fail (G_PASTE_IS_UI_ITEM_SKELETON (self)); GPasteUiItemSkeletonPrivate *priv = g_paste_ui_item_skeleton_get_instance_private (self); gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (self), activatable); gtk_widget_set_sensitive (GTK_WIDGET (priv->label), activatable); g_slist_foreach (priv->actions, action_set_activatable, &activatable); if (priv->edit) gtk_widget_set_sensitive (priv->edit, activatable && priv->editable); if (priv->upload) gtk_widget_set_sensitive (priv->upload, activatable && priv->editable); } /** * g_paste_ui_item_skeleton_set_editable: * @self: the #GPasteUiItemSkeleton instance * @editable: whether the item should now be editable or not * * Mark the item as being editable or not * * Returns: */ G_PASTE_VISIBLE void g_paste_ui_item_skeleton_set_editable (GPasteUiItemSkeleton *self, gboolean editable) { g_return_if_fail (G_PASTE_IS_UI_ITEM_SKELETON (self)); GPasteUiItemSkeletonPrivate *priv = g_paste_ui_item_skeleton_get_instance_private (self); priv->editable = editable; gtk_widget_set_sensitive (priv->edit, editable); gtk_widget_set_sensitive (priv->upload, editable); } /** * g_paste_ui_item_skeleton_set_text: * @self: the #GPasteUiItemSkeleton instance * @text: the new text for the label * * Changes the displayed text * * Returns: */ G_PASTE_VISIBLE void g_paste_ui_item_skeleton_set_text (GPasteUiItemSkeleton *self, const gchar *text) { g_return_if_fail (G_PASTE_IS_UI_ITEM_SKELETON (self)); g_return_if_fail (g_utf8_validate (text, -1, NULL)); GPasteUiItemSkeletonPrivate *priv = g_paste_ui_item_skeleton_get_instance_private (self); gtk_label_set_text (priv->label, text); } /** * g_paste_ui_item_skeleton_set_markup: * @self: the #GPasteUiItemSkeleton instance * @markup: the new markup for the label * * Changes the displayed markup * * Returns: */ G_PASTE_VISIBLE void g_paste_ui_item_skeleton_set_markup (GPasteUiItemSkeleton *self, const gchar *markup) { g_return_if_fail (G_PASTE_IS_UI_ITEM_SKELETON (self)); g_return_if_fail (g_utf8_validate (markup, -1, NULL)); GPasteUiItemSkeletonPrivate *priv = g_paste_ui_item_skeleton_get_instance_private (self); gtk_label_set_markup (priv->label, markup); } static void action_set_index (gpointer data, gpointer user_data) { GPasteUiItemAction *a = data; guint64 *i = user_data; g_paste_ui_item_action_set_index (a, *i); } /** * g_paste_ui_item_skeleton_set_index: * @self: the #GPasteUiItemSkeleton instance * @index: the new index to display * * Changes the displayed index * * Returns: */ G_PASTE_VISIBLE void g_paste_ui_item_skeleton_set_index (GPasteUiItemSkeleton *self, guint64 index) { g_return_if_fail (G_PASTE_IS_UI_ITEM_SKELETON (self)); GPasteUiItemSkeletonPrivate *priv = g_paste_ui_item_skeleton_get_instance_private (self); g_autofree gchar *_index = g_strdup_printf("%" G_GUINT64_FORMAT, index); gtk_label_set_text (priv->index_label, _index); g_slist_foreach (priv->actions, action_set_index, &index); } /** * g_paste_ui_item_skeleton_get_label: * @self: the #GPasteUiItemSkeleton instance * * Get the inner label * * Returns: (transfer none): The inner #GtkLabel */ G_PASTE_VISIBLE GtkLabel * g_paste_ui_item_skeleton_get_label (GPasteUiItemSkeleton *self) { g_return_val_if_fail (G_PASTE_IS_UI_ITEM_SKELETON (self), NULL); GPasteUiItemSkeletonPrivate *priv = g_paste_ui_item_skeleton_get_instance_private (self); return priv->label; } static void add_action (gpointer data, gpointer user_data) { GtkWidget *w = data; GtkBox *b =user_data; gtk_box_pack_end (b, w, FALSE, TRUE, 0); } static void g_paste_ui_item_skeleton_dispose (GObject *object) { GPasteUiItemSkeletonPrivate *priv = g_paste_ui_item_skeleton_get_instance_private (G_PASTE_UI_ITEM_SKELETON (object)); if (priv->settings) { g_signal_handler_disconnect (priv->settings, priv->size_id); g_clear_object (&priv->settings); } G_OBJECT_CLASS (g_paste_ui_item_skeleton_parent_class)->dispose (object); } static void g_paste_ui_item_skeleton_class_init (GPasteUiItemSkeletonClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_ui_item_skeleton_dispose; } static void g_paste_ui_item_skeleton_init (GPasteUiItemSkeleton *self) { GPasteUiItemSkeletonPrivate *priv = g_paste_ui_item_skeleton_get_instance_private (self); GtkWidget *index_label = gtk_label_new (""); GtkWidget *label = gtk_label_new (""); priv->index_label = GTK_LABEL (index_label); priv->label = GTK_LABEL (label); priv->editable = TRUE; gtk_widget_set_margin_start (index_label, 5); gtk_widget_set_margin_end (index_label, 5); gtk_widget_set_margin_top (index_label, 5); gtk_widget_set_margin_bottom (index_label, 5); gtk_widget_set_sensitive (index_label, FALSE); gtk_label_set_xalign (priv->index_label, 1.0); gtk_label_set_width_chars (priv->index_label, 3); gtk_label_set_max_width_chars (priv->index_label, 3); gtk_label_set_selectable (priv->index_label, FALSE); gtk_label_set_ellipsize (priv->label, PANGO_ELLIPSIZE_END); gtk_label_set_xalign (priv->label, 0.0); GtkWidget *hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_widget_set_margin_start (hbox, 5); gtk_widget_set_margin_end (hbox, 5); gtk_box_pack_start (GTK_BOX (hbox), index_label, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (self), hbox); } /** * g_paste_ui_item_skeleton_new: * @type: the type of the subclass * @client: a #GPasteClient instance * @settings: a #GPasteSettings instance * @rootwin: the root #GtkWindow * * Create a new instance of #GPasteUiItemSkeleton * * Returns: a newly allocated #GPasteUiItemSkeleton * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_item_skeleton_new (GType type, GPasteClient *client, GPasteSettings *settings, GtkWindow *rootwin) { g_return_val_if_fail (g_type_is_a (type, G_PASTE_TYPE_UI_ITEM_SKELETON), NULL); g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); g_return_val_if_fail (G_PASTE_IS_SETTINGS (settings), NULL); g_return_val_if_fail (GTK_IS_WINDOW (rootwin), NULL); GtkWidget *self = gtk_widget_new (type, "selectable", FALSE, NULL); GPasteUiItemSkeletonPrivate *priv = g_paste_ui_item_skeleton_get_instance_private (G_PASTE_UI_ITEM_SKELETON (self)); GtkWidget *edit = g_paste_ui_edit_item_new (client, rootwin); GtkWidget *upload = g_paste_ui_upload_item_new (client); GtkWidget *delete = g_paste_ui_delete_item_new (client); priv->settings = g_object_ref (settings); priv->edit = edit; priv->upload = upload; priv->actions = g_slist_prepend (priv->actions, edit); priv->actions = g_slist_prepend (priv->actions, upload); priv->actions = g_slist_prepend (priv->actions, delete); g_slist_foreach (priv->actions, add_action, gtk_bin_get_child (GTK_BIN (self))); priv->size_id = g_signal_connect (settings, "changed::" G_PASTE_ELEMENT_SIZE_SETTING, G_CALLBACK (g_paste_ui_item_skeleton_set_text_size), priv); g_paste_ui_item_skeleton_set_text_size (settings, NULL, priv); return self; } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-item-skeleton.h000066400000000000000000000046401305131721400230000ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_ITEM_SKELETON_H__ #define __G_PASTE_UI_ITEM_SKELETON_H__ #include #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_ITEM_SKELETON (g_paste_ui_item_skeleton_get_type ()) G_PASTE_DERIVABLE_TYPE (UiItemSkeleton, ui_item_skeleton, UI_ITEM_SKELETON, GtkListBoxRow) struct _GPasteUiItemSkeletonClass { GtkListBoxRowClass parent_class; }; void g_paste_ui_item_skeleton_set_activatable (GPasteUiItemSkeleton *self, gboolean activatable); void g_paste_ui_item_skeleton_set_editable (GPasteUiItemSkeleton *self, gboolean editable); void g_paste_ui_item_skeleton_set_text (GPasteUiItemSkeleton *self, const gchar *text); void g_paste_ui_item_skeleton_set_markup (GPasteUiItemSkeleton *self, const gchar *markup); void g_paste_ui_item_skeleton_set_index (GPasteUiItemSkeleton *self, guint64 index); GtkLabel *g_paste_ui_item_skeleton_get_label (GPasteUiItemSkeleton *self); GtkWidget *g_paste_ui_item_skeleton_new (GType type, GPasteClient *client, GPasteSettings *settings, GtkWindow *rootwin); G_END_DECLS #endif /*__G_PASTE_UI_ITEM_SKELETON_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-item.c000066400000000000000000000142371305131721400211540ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include struct _GPasteUiItem { GPasteUiItemSkeleton parent_instance; }; typedef struct { GPasteClient *client; GtkLabel *index_label; GtkLabel *label; guint64 index; gboolean bold; gulong size_id; } GPasteUiItemPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteUiItem, g_paste_ui_item, G_PASTE_TYPE_UI_ITEM_SKELETON) /** * g_paste_ui_item_activate: * @self: a #GPasteUiItem instance * * Refresh the item * * Returns: */ G_PASTE_VISIBLE void g_paste_ui_item_activate (GPasteUiItem *self) { g_return_if_fail (G_PASTE_IS_UI_ITEM (self)); GPasteUiItemPrivate *priv = g_paste_ui_item_get_instance_private (self); g_paste_client_select (priv->client, priv->index, NULL, NULL); } /** * g_paste_ui_item_refresh: * @self: a #GPasteUiItem instance * * Refresh the item * * Returns: */ G_PASTE_VISIBLE void g_paste_ui_item_refresh (GPasteUiItem *self) { g_return_if_fail (G_PASTE_IS_UI_ITEM (self)); GPasteUiItemPrivate *priv = g_paste_ui_item_get_instance_private (self); g_paste_ui_item_set_index (self, priv->index); } static void g_paste_ui_item_on_text_ready (GObject *source_object G_GNUC_UNUSED, GAsyncResult *res, gpointer user_data) { GPasteUiItem *self = user_data; GPasteUiItemPrivate *priv = g_paste_ui_item_get_instance_private (self); g_autoptr (GError) error = NULL; g_autofree gchar *txt = g_paste_client_get_element_finish (priv->client, res, &error); if (!txt || error) return; g_autofree gchar *oneline = g_paste_util_replace (txt, "\n", " "); if (priv->bold) { g_autofree gchar *markup = g_markup_printf_escaped ("%s", oneline); g_paste_ui_item_skeleton_set_markup (G_PASTE_UI_ITEM_SKELETON (self), markup); } else { g_paste_ui_item_skeleton_set_text (G_PASTE_UI_ITEM_SKELETON (self), oneline); } } static void g_paste_ui_item_on_kind_ready (GObject *source_object G_GNUC_UNUSED, GAsyncResult *res, gpointer user_data) { GPasteUiItem *self = user_data; GPasteUiItemPrivate *priv = g_paste_ui_item_get_instance_private (self); g_autoptr (GError) error = NULL; GPasteItemKind kind = g_paste_client_get_element_kind_finish (priv->client, res, &error); if (!kind || error) return; g_paste_ui_item_skeleton_set_editable (G_PASTE_UI_ITEM_SKELETON (self), kind == G_PASTE_ITEM_KIND_TEXT); } static void g_paste_ui_item_reset_text (GPasteUiItem *self) { g_return_if_fail (G_PASTE_IS_UI_ITEM (self)); GPasteUiItemPrivate *priv = g_paste_ui_item_get_instance_private (self); g_paste_client_get_element (priv->client, priv->index, g_paste_ui_item_on_text_ready, self); g_paste_client_get_element_kind (priv->client, priv->index, g_paste_ui_item_on_kind_ready, self); } /** * g_paste_ui_item_set_index: * @self: a #GPasteUiItem instance * @index: the index of the corresponding item * * Track a new index * * Returns: */ G_PASTE_VISIBLE void g_paste_ui_item_set_index (GPasteUiItem *self, guint64 index) { g_return_if_fail (G_PASTE_IS_UI_ITEM (self)); GPasteUiItemPrivate *priv = g_paste_ui_item_get_instance_private (self); g_paste_ui_item_skeleton_set_index (G_PASTE_UI_ITEM_SKELETON (self), index); guint64 old_index = priv->index; priv->index = index; if (!index) priv->bold = TRUE; else if (!old_index) priv->bold = FALSE; if (index != (guint64)-1) { g_paste_ui_item_reset_text (self); gtk_widget_show (GTK_WIDGET (self)); } else { gtk_label_set_text (priv->label, ""); gtk_widget_hide (GTK_WIDGET (self)); } } static void g_paste_ui_item_dispose (GObject *object) { GPasteUiItemPrivate *priv = g_paste_ui_item_get_instance_private (G_PASTE_UI_ITEM (object)); g_clear_object (&priv->client); G_OBJECT_CLASS (g_paste_ui_item_parent_class)->dispose (object); } static void g_paste_ui_item_class_init (GPasteUiItemClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_ui_item_dispose; } static void g_paste_ui_item_init (GPasteUiItem *self) { GPasteUiItemPrivate *priv = g_paste_ui_item_get_instance_private (self); priv->index = -1; } /** * g_paste_ui_item_new: * @client: a #GPasteClient instance * @settings: a #GPasteSettings instance * @rootwin: the root #GtkWindow * @index: the index of the corresponding item * * Create a new instance of #GPasteUiItem * * Returns: a newly allocated #GPasteUiItem * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_item_new (GPasteClient *client, GPasteSettings *settings, GtkWindow *rootwin, guint64 index) { g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); g_return_val_if_fail (G_PASTE_IS_SETTINGS (settings), NULL); g_return_val_if_fail (GTK_IS_WINDOW (rootwin), NULL); GtkWidget *self = g_paste_ui_item_skeleton_new (G_PASTE_TYPE_UI_ITEM, client, settings, rootwin); GPasteUiItemPrivate *priv = g_paste_ui_item_get_instance_private (G_PASTE_UI_ITEM (self)); priv->client = g_object_ref (client); g_paste_ui_item_set_index (G_PASTE_UI_ITEM (self), index); return self; } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-item.h000066400000000000000000000031751305131721400211600ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_ITEM_H__ #define __G_PASTE_UI_ITEM_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_ITEM (g_paste_ui_item_get_type ()) G_PASTE_FINAL_TYPE (UiItem, ui_item, UI_ITEM, GPasteUiItemSkeleton) void g_paste_ui_item_activate (GPasteUiItem *self); void g_paste_ui_item_refresh (GPasteUiItem *self); void g_paste_ui_item_set_index (GPasteUiItem *self, guint64 index); GtkWidget *g_paste_ui_item_new (GPasteClient *client, GPasteSettings *settings, GtkWindow *rootwin, guint64 index); G_END_DECLS #endif /*__G_PASTE_UI_ITEM_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-panel-history.c000066400000000000000000000127371305131721400230170ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include struct _GPasteUiPanelHistory { GtkListBoxRow parent_instance; }; typedef struct { GPasteClient *client; GtkLabel *index_label; GtkLabel *label; gchar *history; } GPasteUiPanelHistoryPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteUiPanelHistory, g_paste_ui_panel_history, GTK_TYPE_LIST_BOX_ROW) /** * g_paste_ui_panel_history_activate: * @self: a #GPasteUiPanelHistory instance * * Switch to this history * * Returns: */ G_PASTE_VISIBLE void g_paste_ui_panel_history_activate (GPasteUiPanelHistory *self) { g_return_if_fail (G_PASTE_IS_UI_PANEL_HISTORY (self)); GPasteUiPanelHistoryPrivate *priv = g_paste_ui_panel_history_get_instance_private (self); g_paste_client_switch_history (priv->client, priv->history, NULL, NULL); } /** * g_paste_ui_panel_history_set_length: * @self: a #GPasteUiPanelHistory instance * @length: the length of the #GPasteHistory * * Update the index label of this history * * Returns: */ G_PASTE_VISIBLE void g_paste_ui_panel_history_set_length (GPasteUiPanelHistory *self, guint64 length) { g_return_if_fail (G_PASTE_IS_UI_PANEL_HISTORY (self)); GPasteUiPanelHistoryPrivate *priv = g_paste_ui_panel_history_get_instance_private (self); g_autofree gchar *_length = g_strdup_printf("%" G_GUINT64_FORMAT, length); gtk_label_set_text (priv->index_label, _length); } /** * g_paste_ui_panel_history_get_history: * @self: a #GPasteUiPanelHistory instance * * Get the underlying history name * * Returns: the name of the history */ G_PASTE_VISIBLE const gchar * g_paste_ui_panel_history_get_history (const GPasteUiPanelHistory *self) { g_return_val_if_fail (G_PASTE_IS_UI_PANEL_HISTORY (self), NULL); GPasteUiPanelHistoryPrivate *priv = g_paste_ui_panel_history_get_instance_private ((GPasteUiPanelHistory *) self); return priv->history; } static void on_size_ready (GObject *source_object, GAsyncResult *res, gpointer user_data) { GPasteUiPanelHistory *self = user_data; g_paste_ui_panel_history_set_length (self, g_paste_client_get_history_size_finish (G_PASTE_CLIENT (source_object), res, NULL)); } static void g_paste_ui_panel_history_dispose (GObject *object) { GPasteUiPanelHistoryPrivate *priv = g_paste_ui_panel_history_get_instance_private (G_PASTE_UI_PANEL_HISTORY (object)); g_clear_object (&priv->client); G_OBJECT_CLASS (g_paste_ui_panel_history_parent_class)->dispose (object); } static void g_paste_ui_panel_history_class_init (GPasteUiPanelHistoryClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_ui_panel_history_dispose; } static void g_paste_ui_panel_history_init (GPasteUiPanelHistory *self) { GPasteUiPanelHistoryPrivate *priv = g_paste_ui_panel_history_get_instance_private (self); GtkWidget *hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); GtkBox *box = GTK_BOX (hbox); GtkWidget *l = gtk_label_new (""); GtkLabel *label = priv->label = GTK_LABEL (l); GtkWidget *il = gtk_label_new (""); GtkLabel *index_label = priv->index_label = GTK_LABEL (il); gtk_widget_set_sensitive (il, FALSE); gtk_label_set_xalign (index_label, 1.0); gtk_label_set_width_chars (index_label, 3); gtk_label_set_selectable (index_label, FALSE); gtk_widget_set_margin_start (hbox, 5); gtk_widget_set_margin_end (hbox, 5); gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END); gtk_box_pack_start (box, il, FALSE, FALSE, 0); gtk_box_pack_start (box, l, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (self), hbox); } /** * g_paste_ui_panel_history_new: * @client: a #GPasteClient instance * @history: the history we represent * * Create a new instance of #GPasteUiPanelHistory * * Returns: a newly allocated #GPasteUiPanelHistory * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_panel_history_new (GPasteClient *client, const gchar *history) { g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); g_return_val_if_fail (g_utf8_validate (history, -1, NULL), NULL); GtkWidget *self = gtk_widget_new (G_PASTE_TYPE_UI_PANEL_HISTORY, "width-request", 100, "height-request", 50, NULL); GPasteUiPanelHistoryPrivate *priv = g_paste_ui_panel_history_get_instance_private (G_PASTE_UI_PANEL_HISTORY (self)); priv->client = g_object_ref (client); priv->history = g_strdup (history); gtk_label_set_text (priv->label, history); g_paste_client_get_history_size (client, history, on_size_ready, self); return self; } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-panel-history.h000066400000000000000000000032501305131721400230120ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_PANEL_HISTORY_H__ #define __G_PASTE_UI_PANEL_HISTORY_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_PANEL_HISTORY (g_paste_ui_panel_history_get_type ()) G_PASTE_FINAL_TYPE (UiPanelHistory, ui_panel_history, UI_PANEL_HISTORY, GtkListBoxRow) void g_paste_ui_panel_history_activate (GPasteUiPanelHistory *self); void g_paste_ui_panel_history_set_length (GPasteUiPanelHistory *self, guint64 length); const gchar *g_paste_ui_panel_history_get_history (const GPasteUiPanelHistory *self); GtkWidget *g_paste_ui_panel_history_new (GPasteClient *client, const gchar *history); G_END_DECLS #endif /*__G_PASTE_UI_PANEL_HISTORY_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-panel.c000066400000000000000000000310631305131721400213110ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include struct _GPasteUiPanel { GtkBox parent_instance; }; typedef struct { GPasteClient *client; GPasteSettings *settings; GPasteUiHistoryActions *actions; GtkListBox *list_box; GtkEntry *switch_entry; GSList *histories; GtkWidget *search_entry; gulong activated_id; gulong button_pressed_id; gulong delete_history_id; gulong empty_history_id; gulong switch_activated_id; gulong switch_clicked_id; gulong switch_history_id; } GPasteUiPanelPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteUiPanel, g_paste_ui_panel, GTK_TYPE_BOX) static gint32 history_equals (gconstpointer a, gconstpointer b) { return g_strcmp0 (b, g_paste_ui_panel_history_get_history (a)); } static GSList * history_find (GSList *histories, const gchar *history) { return g_slist_find_custom (histories, history, history_equals); } /** * g_paste_ui_panel_update_history_length: * @self: a #GPasteUiPanel instance * @history: the history to update * @length: the new length * * Update the displayed length of the specified history * * Returns: */ G_PASTE_VISIBLE void g_paste_ui_panel_update_history_length (GPasteUiPanel *self, const gchar *history, guint64 length) { g_return_if_fail (G_PASTE_IS_UI_PANEL (self)); GPasteUiPanelPrivate *priv = g_paste_ui_panel_get_instance_private (self); GSList *h = history_find (priv->histories, history); if (h) { GPasteUiPanelHistory *hh = h->data; g_paste_ui_panel_history_set_length (hh, length); } } static void on_history_deleted (GPasteClient *client G_GNUC_UNUSED, const gchar *history, gpointer user_data) { GPasteUiPanelPrivate *priv = user_data; if (!g_strcmp0 (history, DEFAULT_HISTORY)) return; GSList *h = history_find (priv->histories, history); if (!h) return; priv->histories = g_slist_remove_link (priv->histories, h); gtk_container_remove (GTK_CONTAINER (priv->list_box), h->data); } static void on_history_emptied (GPasteClient *client G_GNUC_UNUSED, const gchar *history, gpointer user_data) { GPasteUiPanel *self = user_data; g_paste_ui_panel_update_history_length (self, history, 0); } static void g_paste_ui_panel_add_history (GPasteUiPanelPrivate *priv, const gchar *history, gboolean select); static void on_history_switched (GPasteClient *client G_GNUC_UNUSED, const gchar *history, gpointer user_data) { GPasteUiPanelPrivate *priv = user_data; g_paste_ui_panel_add_history (priv, history, TRUE); } static void on_row_activated (GtkListBox *panel G_GNUC_UNUSED, GtkListBoxRow *row, gpointer user_data G_GNUC_UNUSED) { g_paste_ui_panel_history_activate (G_PASTE_UI_PANEL_HISTORY (row)); } static void g_paste_ui_panel_add_history (GPasteUiPanelPrivate *priv, const gchar *history, gboolean select) { GtkContainer *c = GTK_CONTAINER (priv->list_box); GSList *concurrent = history_find (priv->histories, history); GtkListBoxRow *row; if (concurrent) { row = concurrent->data; } else { GtkWidget *h = g_paste_ui_panel_history_new (priv->client, history); g_object_ref (h); gtk_container_add (c, h); gtk_widget_show_all (h); priv->histories = g_slist_prepend (priv->histories, h); row = GTK_LIST_BOX_ROW (h); } if (select) gtk_list_box_select_row (priv->list_box, row); } typedef struct { GPasteUiPanelPrivate *priv; gchar *name; } HistoriesData; static void on_histories_ready (GObject *source_object G_GNUC_UNUSED, GAsyncResult *res, gpointer user_data) { g_autofree HistoriesData *data = user_data; GPasteUiPanelPrivate *priv = data->priv; g_auto (GStrv) histories = g_paste_client_list_histories_finish (priv->client, res, NULL); g_autofree gchar *current = data->name; g_paste_ui_panel_add_history (priv, DEFAULT_HISTORY, !g_strcmp0 (DEFAULT_HISTORY, current)); for (GStrv h = histories; *h; ++h) g_paste_ui_panel_add_history (priv, *h, !g_strcmp0 (*h, current)); } static void on_name_ready (GObject *source_object G_GNUC_UNUSED, GAsyncResult *res, gpointer user_data) { GPasteUiPanelPrivate *priv = user_data; gchar *name = g_paste_client_get_history_name_finish (priv->client, res, NULL); HistoriesData *data = g_malloc (sizeof (HistoriesData)); data->priv = priv; data->name = name; g_paste_client_list_histories (priv->client, on_histories_ready, data); } static gboolean g_paste_ui_panel_button_press_event (GtkWidget *widget G_GNUC_UNUSED, GdkEventButton *event, gpointer user_data) { GPasteUiPanelPrivate *priv = user_data; if (gdk_event_triggers_context_menu ((GdkEvent *) event)) { g_paste_ui_history_actions_set_relative_to (priv->actions, G_PASTE_UI_PANEL_HISTORY (gtk_list_box_get_row_at_y (priv->list_box, event->y))); gtk_widget_show_all (GTK_WIDGET (priv->actions)); } return FALSE; } static void g_paste_ui_panel_switch_activated (GtkEntry *entry, gpointer user_data) { GPasteUiPanelPrivate *priv = user_data; const gchar *text = gtk_entry_get_text (entry); g_paste_client_switch_history (priv->client, (text && *text) ? text : DEFAULT_HISTORY, NULL, NULL); gtk_entry_set_text (entry, ""); gtk_widget_grab_focus (priv->search_entry); } static void g_paste_ui_panel_switch_clicked (GtkEntry *entry, GtkEntryIconPosition icon_pos G_GNUC_UNUSED, GdkEvent *event G_GNUC_UNUSED, gpointer user_data) { g_paste_ui_panel_switch_activated (entry, user_data); } static void g_paste_ui_panel_dispose (GObject *object) { GPasteUiPanelPrivate *priv = g_paste_ui_panel_get_instance_private (G_PASTE_UI_PANEL (object)); if (priv->activated_id) { g_signal_handler_disconnect (priv->list_box, priv->activated_id); g_signal_handler_disconnect (priv->list_box, priv->button_pressed_id); g_signal_handler_disconnect (priv->switch_entry, priv->switch_activated_id); g_signal_handler_disconnect (priv->switch_entry, priv->switch_clicked_id); priv->activated_id = 0; } if (priv->client) { g_signal_handler_disconnect (priv->client, priv->delete_history_id); g_signal_handler_disconnect (priv->client, priv->empty_history_id); g_signal_handler_disconnect (priv->client, priv->switch_history_id); g_clear_object (&priv->client); } g_clear_object (&priv->settings); G_OBJECT_CLASS (g_paste_ui_panel_parent_class)->dispose (object); } static void g_paste_ui_panel_class_init (GPasteUiPanelClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_ui_panel_dispose; } static void g_paste_ui_panel_init (GPasteUiPanel *self) { GPasteUiPanelPrivate *priv = g_paste_ui_panel_get_instance_private (self); GtkWidget *list_box = gtk_list_box_new (); GtkWidget *switch_entry = gtk_entry_new (); GtkBox *box = GTK_BOX (self); priv->list_box = GTK_LIST_BOX (list_box); priv->switch_entry = GTK_ENTRY (switch_entry); gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self)), GTK_STYLE_CLASS_SIDEBAR); gtk_entry_set_icon_from_icon_name (priv->switch_entry, GTK_ENTRY_ICON_SECONDARY, "go-jump-symbolic"); gtk_widget_set_tooltip_text (switch_entry, _("Switch to")); gtk_widget_set_margin_top (switch_entry, 5); gtk_widget_set_margin_bottom (switch_entry, 5); gtk_entry_set_placeholder_text (priv->switch_entry, DEFAULT_HISTORY); priv->activated_id = g_signal_connect (G_OBJECT (priv->list_box), "row-activated", G_CALLBACK (on_row_activated), NULL); priv->button_pressed_id = g_signal_connect (G_OBJECT (list_box), "button-press-event", G_CALLBACK (g_paste_ui_panel_button_press_event), priv); priv->switch_activated_id = g_signal_connect (G_OBJECT (switch_entry), "activate", G_CALLBACK (g_paste_ui_panel_switch_activated), priv); priv->switch_clicked_id = g_signal_connect (G_OBJECT (switch_entry), "icon-press", G_CALLBACK (g_paste_ui_panel_switch_clicked), priv); gtk_box_pack_start (box, list_box, FALSE, TRUE, 0); gtk_box_pack_start (box, switch_entry, FALSE, FALSE, 0); } /** * g_paste_ui_panel_new: * @client: a #GPasteClient instance * @settings: a #GPasteSettings instance * @rootwin: the root #GtkWindow * @search_entry: the #GtkSearchEntry * * Create a new instance of #GPasteUiPanel * * Returns: a newly allocated #GPasteUiPanel * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_panel_new (GPasteClient *client, GPasteSettings *settings, GtkWindow *rootwin, GtkSearchEntry *search_entry) { g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); g_return_val_if_fail (G_PASTE_IS_SETTINGS (settings), NULL); g_return_val_if_fail (GTK_IS_WINDOW (rootwin), NULL); g_return_val_if_fail (GTK_IS_SEARCH_ENTRY (search_entry), NULL); GtkWidget *self = gtk_widget_new (G_PASTE_TYPE_UI_PANEL, "orientation", GTK_ORIENTATION_VERTICAL, NULL); GPasteUiPanelPrivate *priv = g_paste_ui_panel_get_instance_private (G_PASTE_UI_PANEL (self)); priv->client = g_object_ref (client); priv->settings = g_object_ref (settings); priv->actions = G_PASTE_UI_HISTORY_ACTIONS (g_paste_ui_history_actions_new (client, rootwin)); priv->search_entry = GTK_WIDGET (search_entry); priv->delete_history_id = g_signal_connect (priv->client, "delete-history", G_CALLBACK (on_history_deleted), priv); priv->empty_history_id = g_signal_connect (priv->client, "empty-history", G_CALLBACK (on_history_emptied), self); priv->switch_history_id = g_signal_connect (priv->client, "switch-history", G_CALLBACK (on_history_switched), priv); g_paste_client_get_history_name (client, on_name_ready, priv); return self; } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-panel.h000066400000000000000000000032151305131721400213140ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_PANEL_H__ #define __G_PASTE_UI_PANEL_H__ #include #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_PANEL (g_paste_ui_panel_get_type ()) G_PASTE_FINAL_TYPE (UiPanel, ui_panel, UI_PANEL, GtkBox) void g_paste_ui_panel_update_history_length (GPasteUiPanel *self, const gchar *history, guint64 length); GtkWidget *g_paste_ui_panel_new (GPasteClient *client, GPasteSettings *settings, GtkWindow *rootwin, GtkSearchEntry *search_entry); G_END_DECLS #endif /*__G_PASTE_UI_PANEL_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-reexec.c000066400000000000000000000056171305131721400214730ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include struct _GPasteUiReexec { GtkButton parent_instance; }; typedef struct { GPasteClient *client; GtkWindow *topwin; } GPasteUiReexecPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteUiReexec, g_paste_ui_reexec, GTK_TYPE_BUTTON) static void g_paste_ui_reexec_clicked (GtkButton *button) { GPasteUiReexecPrivate *priv = g_paste_ui_reexec_get_instance_private (G_PASTE_UI_REEXEC (button)); if (g_paste_util_confirm_dialog (priv->topwin, _("Restart"), _("Do you really want to restart the daemon?"))) g_paste_client_reexecute (priv->client, NULL, NULL); } static void g_paste_ui_reexec_dispose (GObject *object) { GPasteUiReexecPrivate *priv = g_paste_ui_reexec_get_instance_private (G_PASTE_UI_REEXEC (object)); g_clear_object (&priv->client); G_OBJECT_CLASS (g_paste_ui_reexec_parent_class)->dispose (object); } static void g_paste_ui_reexec_class_init (GPasteUiReexecClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_ui_reexec_dispose; GTK_BUTTON_CLASS (klass)->clicked = g_paste_ui_reexec_clicked; } static void g_paste_ui_reexec_init (GPasteUiReexec *self) { gtk_widget_set_tooltip_text (GTK_WIDGET (self), _("Restart the daemon")); } /** * g_paste_ui_reexec_new: * @topwin: the main #GtkWindow * @client: a #GPasteClient instance * * Create a new instance of #GPasteUiReexec * * Returns: a newly allocated #GPasteUiReexec * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_reexec_new (GtkWindow *topwin, GPasteClient *client) { g_return_val_if_fail (GTK_IS_WINDOW (topwin), NULL); g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); GtkWidget *self = gtk_widget_new (G_PASTE_TYPE_UI_REEXEC, "image", gtk_image_new_from_icon_name ("view-refresh-symbolic", GTK_ICON_SIZE_BUTTON), NULL); GPasteUiReexecPrivate *priv = g_paste_ui_reexec_get_instance_private (G_PASTE_UI_REEXEC (self)); priv->topwin = topwin; priv->client = g_object_ref (client); return self; } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-reexec.h000066400000000000000000000024611305131721400214720ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_REEXEC_H__ #define __G_PASTE_UI_REEXEC_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_REEXEC (g_paste_ui_reexec_get_type ()) G_PASTE_FINAL_TYPE (UiReexec, ui_reexec, UI_REEXEC, GtkButton) GtkWidget *g_paste_ui_reexec_new (GtkWindow *topwin, GPasteClient *client); G_END_DECLS #endif /*__G_PASTE_UI_REEXEC_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-search-bar.c000066400000000000000000000042421305131721400222200ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include struct _GPasteUiSearchBar { GtkSearchBar parent_instance; }; typedef struct { GtkSearchEntry *entry; } GPasteUiSearchBarPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteUiSearchBar, g_paste_ui_search_bar, GTK_TYPE_SEARCH_BAR) /** * g_paste_ui_search_bar_get_entry: * * Get the #GtkSearchEntry * * Returns: (transfer none): the #GtkSearchEntry */ G_PASTE_VISIBLE GtkSearchEntry * g_paste_ui_search_bar_get_entry (const GPasteUiSearchBar *self) { g_return_val_if_fail (G_PASTE_IS_UI_SEARCH_BAR (self), NULL); GPasteUiSearchBarPrivate *priv = g_paste_ui_search_bar_get_instance_private (self); return priv->entry; } static void g_paste_ui_search_bar_class_init (GPasteUiSearchBarClass *klass G_GNUC_UNUSED) { } static void g_paste_ui_search_bar_init (GPasteUiSearchBar *self) { GPasteUiSearchBarPrivate *priv = g_paste_ui_search_bar_get_instance_private (self); GtkWidget *entry = gtk_search_entry_new (); priv->entry = GTK_SEARCH_ENTRY (entry); gtk_container_add (GTK_CONTAINER (self), entry); } /** * g_paste_ui_search_bar_new: * * Create a new instance of #GPasteUiSearchBar * * Returns: a newly allocated #GPasteUiSearchBar * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_search_bar_new (void) { return gtk_widget_new (G_PASTE_TYPE_UI_SEARCH_BAR, NULL); } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-search-bar.h000066400000000000000000000025351305131721400222300ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_SEARCH_BAR_H__ #define __G_PASTE_UI_SEARCH_BAR_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_SEARCH_BAR (g_paste_ui_search_bar_get_type ()) G_PASTE_FINAL_TYPE (UiSearchBar, ui_search_bar, UI_SEARCH_BAR, GtkSearchBar) GtkSearchEntry *g_paste_ui_search_bar_get_entry (const GPasteUiSearchBar *self); GtkWidget *g_paste_ui_search_bar_new (void); G_END_DECLS #endif /*__G_PASTE_UI_SEARCH_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-search.c000066400000000000000000000031231305131721400214530ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include struct _GPasteUiSearch { GtkToggleButton parent_instance; }; G_DEFINE_TYPE (GPasteUiSearch, g_paste_ui_search, GTK_TYPE_TOGGLE_BUTTON) static void g_paste_ui_search_class_init (GPasteUiSearchClass *klass G_GNUC_UNUSED) { } static void g_paste_ui_search_init (GPasteUiSearch *self) { gtk_widget_set_tooltip_text (GTK_WIDGET (self), _("Search")); } /** * g_paste_ui_search_new: * * Create a new instance of #GPasteUiSearch * * Returns: a newly allocated #GPasteUiSearch * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_search_new (void) { return gtk_widget_new (G_PASTE_TYPE_UI_SEARCH, "image", gtk_image_new_from_icon_name ("edit-find-symbolic", GTK_ICON_SIZE_BUTTON), NULL); } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-search.h000066400000000000000000000023571305131721400214700ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_SEARCH_H__ #define __G_PASTE_UI_SEARCH_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_SEARCH (g_paste_ui_search_get_type ()) G_PASTE_FINAL_TYPE (UiSearch, ui_search, UI_SEARCH, GtkToggleButton) GtkWidget *g_paste_ui_search_new (void); G_END_DECLS #endif /*__G_PASTE_UI_SEARCH_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-settings.c000066400000000000000000000037201305131721400220510ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include struct _GPasteUiSettings { GtkMenuButton parent_instance; }; G_DEFINE_TYPE (GPasteUiSettings, g_paste_ui_settings, GTK_TYPE_MENU_BUTTON) static void g_paste_ui_settings_class_init (GPasteUiSettingsClass *klass G_GNUC_UNUSED) { } static void g_paste_ui_settings_init (GPasteUiSettings *self) { GtkMenuButton *menu = GTK_MENU_BUTTON (self); GtkWidget *popover = gtk_popover_new (GTK_WIDGET (self)); GtkWidget *settings_widget = g_paste_settings_ui_widget_new (); gtk_widget_set_tooltip_text (GTK_WIDGET (self), _("GPaste Settings")); gtk_menu_button_set_direction (menu, GTK_ARROW_NONE); gtk_menu_button_set_use_popover (menu, TRUE); gtk_menu_button_set_popover (menu, popover); gtk_container_add (GTK_CONTAINER (popover), settings_widget); gtk_widget_show_all (settings_widget); } /** * g_paste_ui_settings_new: * * Create a new instance of #GPasteUiSettings * * Returns: a newly allocated #GPasteUiSettings * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_settings_new (void) { return gtk_widget_new (G_PASTE_TYPE_UI_SETTINGS, NULL); } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-settings.h000066400000000000000000000023771305131721400220650ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_SETTINGS_H__ #define __G_PASTE_UI_SETTINGS_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_SETTINGS (g_paste_ui_settings_get_type ()) G_PASTE_FINAL_TYPE (UiSettings, ui_settings, UI_SETTINGS, GtkMenuButton) GtkWidget *g_paste_ui_settings_new (void); G_END_DECLS #endif /*__G_PASTE_UI_SETTINGS_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-switch.c000066400000000000000000000074451305131721400215220ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include struct _GPasteUiSwitch { GtkSwitch parent_instance; }; typedef struct { GPasteClient *client; GtkWindow *topwin; gulong tracking_id; } GPasteUiSwitchPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteUiSwitch, g_paste_ui_switch, GTK_TYPE_SWITCH) static void on_tracking_changed (GPasteClient *client G_GNUC_UNUSED, gboolean state, gpointer user_data) { GtkSwitch *sw = user_data; gtk_switch_set_active (sw, state); } static gboolean g_paste_ui_button_press_event (GtkWidget *widget, GdkEventButton *event G_GNUC_UNUSED) { GPasteUiSwitchPrivate *priv = g_paste_ui_switch_get_instance_private (G_PASTE_UI_SWITCH (widget)); GtkSwitch *sw = GTK_SWITCH (widget); gboolean track = !gtk_switch_get_active (sw); gboolean changed = TRUE; if (!track) { changed = g_paste_util_confirm_dialog (priv->topwin, _("Stop"), _("Do you really want to stop tracking clipboard changes?")); track = !changed; } if (changed) g_paste_client_track (priv->client, track, NULL, NULL); return GDK_EVENT_STOP; } static void g_paste_ui_switch_dispose (GObject *object) { GPasteUiSwitchPrivate *priv = g_paste_ui_switch_get_instance_private (G_PASTE_UI_SWITCH (object)); if (priv->tracking_id) { g_signal_handler_disconnect (priv->client, priv->tracking_id); priv->tracking_id = 0; } g_clear_object (&priv->client); G_OBJECT_CLASS (g_paste_ui_switch_parent_class)->dispose (object); } static void g_paste_ui_switch_class_init (GPasteUiSwitchClass *klass) { GTK_WIDGET_CLASS (klass)->button_press_event = g_paste_ui_button_press_event; G_OBJECT_CLASS (klass)->dispose = g_paste_ui_switch_dispose; } static void g_paste_ui_switch_init (GPasteUiSwitch *self) { gtk_widget_set_tooltip_text (GTK_WIDGET (self), _("Track clipboard changes")); } /** * g_paste_ui_switch_new: * @topwin: the main #GtkWindow * @client: a #GPasteClient instance * * Create a new instance of #GPasteUiSwitch * * Returns: a newly allocated #GPasteUiSwitch * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_switch_new (GtkWindow *topwin, GPasteClient *client) { g_return_val_if_fail (GTK_IS_WINDOW (topwin), NULL); g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); GtkWidget *self = gtk_widget_new (G_PASTE_TYPE_UI_SWITCH, NULL); GPasteUiSwitchPrivate *priv = g_paste_ui_switch_get_instance_private (G_PASTE_UI_SWITCH (self)); priv->topwin = topwin; priv->client = g_object_ref (client); priv->tracking_id = g_signal_connect (G_OBJECT (priv->client), "tracking", G_CALLBACK (on_tracking_changed), self); gtk_switch_set_active (GTK_SWITCH (self), g_paste_client_is_active (client)); return self; } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-switch.h000066400000000000000000000024611305131721400215200ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_SWITCH_H__ #define __G_PASTE_UI_SWITCH_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_SWITCH (g_paste_ui_switch_get_type ()) G_PASTE_FINAL_TYPE (UiSwitch, ui_switch, UI_SWITCH, GtkSwitch) GtkWidget *g_paste_ui_switch_new (GtkWindow *topwin, GPasteClient *client); G_END_DECLS #endif /*__G_PASTE_UI_SWITCH_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-upload-item.c000066400000000000000000000037111305131721400224310ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include struct _GPasteUiUploadItem { GPasteUiItemAction parent_instance; }; G_DEFINE_TYPE (GPasteUiUploadItem, g_paste_ui_upload_item, G_PASTE_TYPE_UI_ITEM_ACTION) static void g_paste_ui_upload_item_activate (GPasteUiItemAction *self G_GNUC_UNUSED, GPasteClient *client, guint64 index) { g_paste_client_upload (client, index, NULL, NULL); } static void g_paste_ui_upload_item_class_init (GPasteUiUploadItemClass *klass) { G_PASTE_UI_ITEM_ACTION_CLASS (klass)->activate = g_paste_ui_upload_item_activate; } static void g_paste_ui_upload_item_init (GPasteUiUploadItem *self G_GNUC_UNUSED) { } /** * g_paste_ui_upload_item_new: * @client: a #GPasteClient * * Create a new instance of #GPasteUiUploadItem * * Returns: a newly allocated #GPasteUiUploadItem * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_upload_item_new (GPasteClient *client) { g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); return g_paste_ui_item_action_new (G_PASTE_TYPE_UI_UPLOAD_ITEM, client, "document-send-symbolic", _("Upload")); } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-upload-item.h000066400000000000000000000024661305131721400224440ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_UPLOAD_ITEM_H__ #define __G_PASTE_UI_UPLOAD_ITEM_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_UPLOAD_ITEM (g_paste_ui_upload_item_get_type ()) G_PASTE_FINAL_TYPE (UiUploadItem, ui_upload_item, UI_UPLOAD_ITEM, GPasteUiItemAction) GtkWidget *g_paste_ui_upload_item_new (GPasteClient *client); G_END_DECLS #endif /*__G_PASTE_UI_UPLOAD_ITEM_H__*/ GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-window.c000066400000000000000000000203771305131721400215270ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #include #include struct _GPasteUiWindow { GtkApplicationWindow parent_instance; }; typedef struct { GPasteUiHeader *header; GPasteUiHistory *history; GtkSearchEntry *search_entry; gboolean initialized; gulong key_press_signal; gulong search_signal; } GPasteUiWindowPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GPasteUiWindow, g_paste_ui_window, GTK_TYPE_WINDOW) static gboolean _search (gpointer user_data) { gpointer *data = (gpointer *) user_data; GPasteUiWindowPrivate *priv = data[0]; if (!priv->initialized) return G_SOURCE_CONTINUE; g_autofree gchar *search = data[1]; g_free (data); gtk_button_clicked (g_paste_ui_header_get_search_button (priv->header)); gtk_entry_set_text (GTK_ENTRY (priv->search_entry), search); return G_SOURCE_REMOVE; } /** * g_paste_ui_window_search: * @self: the #GPasteUiWindow * @search: the text to search * * Do a search * * Returns: */ G_PASTE_VISIBLE void g_paste_ui_window_search (const GPasteUiWindow *self, const gchar *search) { g_return_if_fail (G_PASTE_IS_UI_WINDOW (self)); g_return_if_fail (g_utf8_validate (search, -1, NULL)); GPasteUiWindowPrivate *priv = g_paste_ui_window_get_instance_private (self); gpointer *data = g_new (gpointer, 2); data[0] = priv; data[1] = g_strdup (search); g_source_set_name_by_id (g_idle_add (_search, data), "[GPaste] search"); } static gboolean _show_prefs (gpointer user_data) { GPasteUiWindowPrivate *priv = user_data; if (!priv->initialized) return G_SOURCE_CONTINUE; g_paste_ui_header_show_prefs (priv->header); return G_SOURCE_REMOVE; } /** * g_paste_ui_window_show_prefs: * @self: the #GPasteUiWindow * * Show the prefs pane * * Returns: */ G_PASTE_VISIBLE void g_paste_ui_window_show_prefs (const GPasteUiWindow *self) { g_return_if_fail (G_PASTE_IS_UI_WINDOW (self)); GPasteUiWindowPrivate *priv = g_paste_ui_window_get_instance_private (self); g_source_set_name_by_id (g_idle_add (_show_prefs, priv), "[GPaste] show_prefs"); } static gboolean on_key_press_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) { GtkSearchBar *bar = user_data; GtkWidget *focus = gtk_window_get_focus (GTK_WINDOW (widget)); if (GTK_IS_ENTRY (focus) && !GTK_IS_SEARCH_ENTRY (focus)) return FALSE; return gtk_search_bar_handle_event (bar, event); } static void on_search (GtkSearchEntry *entry, gpointer user_data) { GPasteUiWindowPrivate *priv = user_data; g_paste_ui_history_search (priv->history, gtk_entry_get_text (GTK_ENTRY (entry))); } static void g_paste_ui_window_dispose (GObject *object) { GPasteUiWindow *self = G_PASTE_UI_WINDOW (object); GPasteUiWindowPrivate *priv = g_paste_ui_window_get_instance_private (self); if (priv->key_press_signal) { GtkContainer *box = GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (self))); GPasteUiSearchBar *search_bar = G_PASTE_UI_SEARCH_BAR (gtk_container_get_children (box)->data); GtkSearchEntry *entry = g_paste_ui_search_bar_get_entry (search_bar); g_signal_handler_disconnect (self, priv->key_press_signal); g_signal_handler_disconnect (entry, priv->search_signal); priv->key_press_signal = 0; } G_OBJECT_CLASS (g_paste_ui_window_parent_class)->dispose (object); } static void g_paste_ui_window_class_init (GPasteUiWindowClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_ui_window_dispose; } static void g_paste_ui_window_init (GPasteUiWindow *self) { GPasteUiWindowPrivate *priv = g_paste_ui_window_get_instance_private (self); GtkWindow *win = GTK_WINDOW (self); GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_widget_set_margin_start (vbox, 5); gtk_widget_set_margin_end (vbox, 5); gtk_widget_set_margin_bottom (vbox, 5); GtkWidget *search_bar = g_paste_ui_search_bar_new (); GtkContainer *box = GTK_CONTAINER (vbox); gtk_container_add (GTK_CONTAINER (win), vbox); gtk_box_pack_start (GTK_BOX (box), search_bar, FALSE, FALSE, 0); GtkSearchEntry *entry = priv->search_entry = g_paste_ui_search_bar_get_entry (G_PASTE_UI_SEARCH_BAR (search_bar)); priv->key_press_signal = g_signal_connect (self, "key-press-event", G_CALLBACK (on_key_press_event), search_bar); priv->search_signal = g_signal_connect (entry, "search-changed", G_CALLBACK (on_search), priv); gtk_window_set_focus (win, GTK_WIDGET (entry)); } static void on_client_ready (GObject *source_object G_GNUC_UNUSED, GAsyncResult *res, gpointer user_data) { GPasteUiWindowPrivate *priv = g_paste_ui_window_get_instance_private (user_data); GtkWindow *win = GTK_WINDOW (user_data); g_autoptr (GError) error = NULL; g_autoptr (GPasteClient) client = g_paste_client_new_finish (res, &error); if (error) { priv->initialized = TRUE; g_critical ("%s: %s\n", _("Couldn't connect to GPaste daemon"), error->message); gtk_window_close (win); /* will exit the application */ } g_autoptr (GPasteSettings) settings = g_paste_settings_new (); GtkWidget *header = g_paste_ui_header_new (win, client); GtkWidget *panel = g_paste_ui_panel_new (client, settings, win, priv->search_entry); GtkWidget *history = g_paste_ui_history_new (client, settings, G_PASTE_UI_PANEL (panel), win); GPasteUiHeader *h = priv->header = G_PASTE_UI_HEADER (header); priv->history = G_PASTE_UI_HISTORY (history); gtk_window_set_titlebar (win, header); GtkContainer *vbox = GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (win))); GtkWidget *hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); GtkBox *box = GTK_BOX (hbox); gtk_box_pack_start (box, panel, FALSE, FALSE, 0); gtk_box_pack_start (box, gtk_separator_new (GTK_ORIENTATION_VERTICAL), FALSE, FALSE, 2); gtk_box_pack_start (box, history, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); g_object_bind_property (g_paste_ui_header_get_search_button (h), "active", gtk_container_get_children (vbox)->data, "search-mode-enabled", G_BINDING_BIDIRECTIONAL); gtk_widget_show_all (GTK_WIDGET (win)); priv->initialized = TRUE; } /** * g_paste_ui_window_new: * @app: the #GtkApplication * * Create a new instance of #GPasteUiWindow * * Returns: a newly allocated #GPasteUiWindow * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_window_new (GtkApplication *app) { g_return_val_if_fail (GTK_IS_APPLICATION (app), NULL); GtkWidget *self = gtk_widget_new (G_PASTE_TYPE_UI_WINDOW, "application", app, "type", GTK_WINDOW_TOPLEVEL, "window-position", GTK_WIN_POS_CENTER_ALWAYS, "resizable", FALSE, NULL); g_paste_client_new (on_client_ready, self); return self; } GPaste-3.18.6/src/libgpaste/ui/gpaste-ui-window.h000066400000000000000000000027051305131721400215270ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_WINDOW_H__ #define __G_PASTE_UI_WINDOW_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_WINDOW (g_paste_ui_window_get_type ()) G_PASTE_FINAL_TYPE (UiWindow, ui_window, UI_WINDOW, GtkApplicationWindow) void g_paste_ui_window_search (const GPasteUiWindow *self, const gchar *search); void g_paste_ui_window_show_prefs (const GPasteUiWindow *self); GtkWidget *g_paste_ui_window_new (GtkApplication *app); G_END_DECLS #endif /*__G_PASTE_UI_WINDOW_H__*/ GPaste-3.18.6/src/libgpaste/util/000077500000000000000000000000001305131721400165075ustar00rootroot00000000000000GPaste-3.18.6/src/libgpaste/util/gpaste-util.c000066400000000000000000000341031305131721400211120ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include /** * g_paste_util_confirm_dialog: * @parent: (nullable): the parent #GtkWindow * @msg: the message to display * * Show GPaste about dialog * * Returns: */ G_PASTE_VISIBLE gboolean g_paste_util_confirm_dialog (GtkWindow *parent, const gchar *action, const gchar *msg) { g_return_val_if_fail (!parent || GTK_IS_WINDOW (parent), FALSE); g_return_val_if_fail (g_utf8_validate (msg, -1, NULL), FALSE); GtkWidget *dialog = gtk_dialog_new_with_buttons (PACKAGE_STRING, parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR, action, GTK_RESPONSE_OK, _("Cancel"), GTK_RESPONSE_CANCEL, NULL); GtkWidget *label = gtk_label_new (msg); GtkDialog *d = GTK_DIALOG (dialog); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (d)), label, TRUE, TRUE, 0); gtk_widget_set_margin_start (label, 10); gtk_widget_set_margin_end (label, 10); gtk_widget_set_margin_top (label, 10); gtk_widget_set_margin_bottom (label, 10); gtk_widget_show (label); gboolean ret = gtk_dialog_run (d) == GTK_RESPONSE_OK; gtk_widget_destroy (dialog); return ret; } /* Copied from glib's gio/gapplication-tool.c */ static GVariant * app_get_platform_data (void) { g_auto (GVariantBuilder) builder; const gchar *startup_id; g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); if ((startup_id = g_getenv ("DESKTOP_STARTUP_ID"))) g_variant_builder_add (&builder, "{sv}", "desktop-startup-id", g_variant_new_string (startup_id)); return g_variant_builder_end (&builder); } static void g_paste_util_spawn_on_proxy_ready (GObject *source_object G_GNUC_UNUSED, GAsyncResult *res, gpointer user_data G_GNUC_UNUSED) { g_autoptr (GDBusProxy) proxy = g_dbus_proxy_new_for_bus_finish (res, NULL /* error */); if (proxy) { g_dbus_proxy_call (proxy, "Activate", g_variant_new ("(@a{sv})", app_get_platform_data ()), G_DBUS_CALL_FLAGS_NONE, -1, NULL, /* cancellable */ NULL, /* callback */ NULL); /* user_data */ } } /** * g_paste_util_spawn: * @app: the GPaste app to spawn * * spawn a GPaste app * * Returns: */ G_PASTE_VISIBLE void g_paste_util_spawn (const gchar *app) { g_return_if_fail (g_utf8_validate (app, -1, NULL)); g_autofree gchar *name = g_strdup_printf ("org.gnome.GPaste.%s", app); g_autofree gchar *object = g_strdup_printf ("/org/gnome/GPaste/%s", app); g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, NULL, name, object, "org.freedesktop.Application", NULL, g_paste_util_spawn_on_proxy_ready, NULL); } static GDBusProxy * _bus_proxy_new_sync (const gchar *app, GError **error) { g_autofree gchar *name = g_strdup_printf ("org.gnome.GPaste.%s", app); g_autofree gchar *object = g_strdup_printf ("/org/gnome/GPaste/%s", app); return g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, NULL, name, object, "org.freedesktop.Application", NULL, error); } static gboolean _spawn_sync (GDBusProxy *proxy, GError **error) { G_GNUC_UNUSED g_autoptr (GVariant) res = g_dbus_proxy_call_sync (proxy, "Activate", g_variant_new ("(@a{sv})", app_get_platform_data ()), G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); return !error || !(*error); } /** * g_paste_util_spawn_sync: * @app: the GPaste app to spawn * @error: a #GError or %NULL * * spawn a GPaste app * * Returns: whether the spawn was successful */ G_PASTE_VISIBLE gboolean g_paste_util_spawn_sync (const gchar *app, GError **error) { g_return_val_if_fail (g_utf8_validate (app, -1, NULL), FALSE); g_return_val_if_fail (!error || !(*error), FALSE); g_autoptr (GDBusProxy) proxy = _bus_proxy_new_sync (app, error); if (!proxy) return FALSE; return _spawn_sync (proxy, error); } static void g_paste_util_activate_ui_on_proxy_ready (GObject *source_object G_GNUC_UNUSED, GAsyncResult *res, gpointer user_data) { g_autofree gpointer *data = (gpointer *) user_data; g_autofree gchar *action = data[0]; GVariant *arg = data[1]; g_autoptr (GDBusProxy) proxy = g_dbus_proxy_new_for_bus_finish (res, NULL /* error */); if (proxy) { g_auto (GVariantBuilder) params; g_variant_builder_init (¶ms, G_VARIANT_TYPE ("av")); if (arg) g_variant_builder_add (¶ms, "v", arg); g_dbus_proxy_call (proxy, "ActivateAction", g_variant_new ("(sav@a{sv})", action, ¶ms, app_get_platform_data ()), G_DBUS_CALL_FLAGS_NONE, -1, NULL, /* cancellable */ NULL, /* callback */ NULL); /* user_data */ } } /** * g_paste_util_activate_ui: * @action: the action to activate * @arg: (nullable): the action argument * * Activate an action on a GPaste app * * Returns: */ G_PASTE_VISIBLE void g_paste_util_activate_ui (const gchar *action, GVariant *arg) { gpointer *data = g_new (gpointer, 2); data[0] = g_strdup (action); data[1] = arg; g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.gnome.GPaste.Ui", "/org/gnome/GPaste/Ui", "org.freedesktop.Application", NULL, g_paste_util_activate_ui_on_proxy_ready, data); } /** * g_paste_util_activate_ui_sync: * @action: the action to activate * @arg: (nullable): the action argument * @error: a #GError or %NULL * * activate an action from GPaste Ui * * Returns: whether the action was successful */ G_PASTE_VISIBLE gboolean g_paste_util_activate_ui_sync (const gchar *action, GVariant *arg, GError **error) { g_return_val_if_fail (g_utf8_validate (action, -1, NULL), FALSE); g_return_val_if_fail (!error || !(*error), FALSE); g_autoptr (GDBusProxy) proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.gnome.GPaste.Ui", "/org/gnome/GPaste/Ui", "org.freedesktop.Application", NULL, error); if (!proxy) return FALSE; g_auto (GVariantBuilder) params; g_variant_builder_init (¶ms, G_VARIANT_TYPE ("av")); if (arg) g_variant_builder_add (¶ms, "v", arg); /* We only consume it */ G_GNUC_UNUSED g_autoptr (GVariant) res = g_dbus_proxy_call_sync (proxy, "ActivateAction", g_variant_new ("(sav@a{sv})", action, ¶ms, app_get_platform_data ()), G_DBUS_CALL_FLAGS_NONE, -1, NULL, /* cancellable */ error); return TRUE; } /** * g_paste_util_relace: * @text: the initial text * @pattern: the pattern to replace * @substitution: the replacement text * * Replace some text * * Returns: the newly allocated string */ G_PASTE_VISIBLE gchar * g_paste_util_replace (const gchar *text, const gchar *pattern, const gchar *substitution) { g_return_val_if_fail (g_utf8_validate (text, -1, NULL), NULL); g_return_val_if_fail (g_utf8_validate (pattern, -1, NULL), NULL); g_return_val_if_fail (g_utf8_validate (substitution, -1, NULL), NULL); g_autofree gchar *regex_string = g_regex_escape_string (pattern, -1); g_autoptr (GRegex) regex = g_regex_new (regex_string, 0, /* Compile options */ 0, /* Match options */ NULL); /* Error */ return g_regex_replace_literal (regex, text, (gssize) -1, 0, /* Start position */ substitution, 0, /* Match options */ NULL); /* Error */ } /** * g_paste_util_compute_checksum: * @image: the #GdkPixbuf to checksum * * Compute the checksum of an image * * Returns: the newly allocated checksum */ G_PASTE_VISIBLE gchar * g_paste_util_compute_checksum (GdkPixbuf *image) { if (!image || !GDK_IS_PIXBUF (image)) return NULL; guint32 length; const guchar *data = gdk_pixbuf_get_pixels_with_length (image, &length); return g_compute_checksum_for_data (G_CHECKSUM_SHA256, data, length); } /** * g_paste_util_has_applet: * * Check whether gpaste-applet is installed or not * * Returns: %TRUE if gpaste-applet is installed */ G_PASTE_VISIBLE gboolean g_paste_util_has_applet (void) { return g_file_test (PKGLIBEXECDIR "/gpaste-applet", G_FILE_TEST_IS_EXECUTABLE); } /** * g_paste_util_has_unity: * * Check whether gpaste-app-indicator is installed or not * * Returns: %TRUE if gpaste-app-indicator is installed */ G_PASTE_VISIBLE gboolean g_paste_util_has_unity (void) { return g_file_test (PKGLIBEXECDIR "/gpaste-app-indicator", G_FILE_TEST_IS_EXECUTABLE); } /** * g_paste_util_show_win: * @application: a #GtkApplication * * Present the application's window to user * * Returns: */ G_PASTE_VISIBLE void g_paste_util_show_win (GApplication *application) { g_return_if_fail (GTK_IS_APPLICATION (application)); for (GList *wins = gtk_application_get_windows (GTK_APPLICATION (application)); wins; wins = g_list_next (wins)) { if (gtk_widget_get_realized (wins->data)) gtk_window_present (wins->data); } } /** * g_paste_util_get_at_result: * @variant: a #GVariant * @len: the length of the resulting array * * Get the "at" GVariant as an array of guint64 * * Returns: (array length=len): The resulting array */ G_PASTE_VISIBLE guint64 * g_paste_util_get_dbus_at_result (GVariant *variant, guint64 *len) { guint64 _len; const guint64 *r = g_variant_get_fixed_array (variant, &_len, sizeof (guint64)); guint64 *ret = g_memdup (r, _len * sizeof (guint64)); if (len) *len = _len; return ret; } /** * g_paste_util_get_au_result: * @variant: a #GVariant * @len: the length of the resulting array * * Get the "au" GVariant as an array of guint32 * * Returns: (array length=len): The resulting array */ G_PASTE_VISIBLE guint32 * g_paste_util_get_dbus_au_result (GVariant *variant, guint64 *len) { guint64 _len; const guint32 *r = g_variant_get_fixed_array (variant, &_len, sizeof (guint32)); guint32 *ret = g_memdup (r, _len * sizeof (guint32)); if (len) *len = _len; return ret; } GPaste-3.18.6/src/libgpaste/util/gpaste-util.h000066400000000000000000000045441305131721400211250ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UTIL_H__ #define __G_PASTE_UTIL_H__ #include #include G_BEGIN_DECLS gboolean g_paste_util_confirm_dialog (GtkWindow *parent, const gchar *action, const gchar *msg); void g_paste_util_spawn (const gchar *app); gboolean g_paste_util_spawn_sync (const gchar *app, GError **error); void g_paste_util_activate_ui (const gchar *action, GVariant *arg); gboolean g_paste_util_activate_ui_sync (const gchar *action, GVariant *arg, GError **error); gchar *g_paste_util_replace (const gchar *text, const gchar *pattern, const gchar *substitution); gchar *g_paste_util_compute_checksum (GdkPixbuf *image); gboolean g_paste_util_has_applet (void); gboolean g_paste_util_has_unity (void); void g_paste_util_show_win (GApplication *application); guint64 *g_paste_util_get_dbus_at_result (GVariant *variant, guint64 *len); guint32 *g_paste_util_get_dbus_au_result (GVariant *variant, guint64 *len); G_END_DECLS #endif /*__G_PASTE_UTIL_H__*/ GPaste-3.18.6/src/ui.mk000066400000000000000000000017221305131721400145300ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . pkglibexec_PROGRAMS += \ bin/gpaste-ui \ $(NULL) bin_gpaste_ui_SOURCES = \ src/ui/gpaste-ui.c \ $(NULL) bin_gpaste_ui_CFLAGS = \ $(AM_CFLAGS) \ $(NULL) bin_gpaste_ui_LDADD = \ $(builddir)/$(libgpaste_la_file) \ $(GTK_LIBS) \ $(AM_LIBS) \ $(NULL) GPaste-3.18.6/src/ui/000077500000000000000000000000001305131721400141755ustar00rootroot00000000000000GPaste-3.18.6/src/ui/gpaste-ui.c000066400000000000000000000113251305131721400162410ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #include #define LICENSE \ "GPaste is free software: you can redistribute it and/or modify" \ "it under the terms of the GNU General Public License as published by" \ "the Free Software Foundation, either version 3 of the License, or" \ "(at your option) any later version.\n\n" \ "GPaste is distributed in the hope that it will be useful," \ "but WITHOUT ANY WARRANTY; without even the implied warranty of" \ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" \ "GNU General Public License for more details.\n\n" \ "You should have received a copy of the GNU General Public License" \ "along with GPaste. If not, see ." static GPasteUiWindow * get_ui_window(gpointer user_data) { return G_PASTE_UI_WINDOW (gtk_application_get_windows (GTK_APPLICATION (user_data))->data); } static void prefs_activated (GSimpleAction *action G_GNUC_UNUSED, GVariant *parameter G_GNUC_UNUSED, gpointer user_data) { g_paste_ui_window_show_prefs (get_ui_window (user_data)); } static gboolean show_about_dialog (gpointer user_data) { if (!gtk_widget_get_realized (GTK_WIDGET (user_data))) return G_SOURCE_CONTINUE; GtkWindow *parent = GTK_WINDOW (user_data); const gchar *authors[] = { "Marc-Antoine Perennou ", NULL }; gtk_show_about_dialog (parent, "program-name", PACKAGE_NAME, "version", PACKAGE_VERSION, "logo-icon-name", "gtk-paste", "license", LICENSE, "authors", authors, "copyright", "Copyright © 2010-2015 Marc-Antoine Perennou", "comments", "Clipboard management system", "website", "http://www.imagination-land.org/tags/GPaste.html", "website-label", "Follow GPaste news", "wrap-license", TRUE, NULL); return G_SOURCE_REMOVE; } static void about_activated (GSimpleAction *action G_GNUC_UNUSED, GVariant *parameter G_GNUC_UNUSED, gpointer user_data) { g_idle_add (show_about_dialog, gtk_application_get_windows (GTK_APPLICATION (user_data))->data); } static void quit_activated (GSimpleAction *action G_GNUC_UNUSED, GVariant *parameter G_GNUC_UNUSED, gpointer user_data) { g_application_quit (G_APPLICATION (user_data)); } static void search_activated (GSimpleAction *action G_GNUC_UNUSED, GVariant *parameter, gpointer user_data) { g_paste_ui_window_search (get_ui_window (user_data), g_variant_get_string (parameter, NULL)); } gint main (gint argc, gchar *argv[]) { G_PASTE_INIT_APPLICATION_FULL ("Ui", g_paste_util_show_win); GActionEntry app_entries[] = { { "about", about_activated, NULL, NULL, NULL, { 0 } }, { "prefs", prefs_activated, NULL, NULL, NULL, { 0 } }, { "quit", quit_activated, NULL, NULL, NULL, { 0 } }, { "search", search_activated, "s", NULL, NULL, { 0 } } }; g_action_map_add_action_entries (G_ACTION_MAP (app), app_entries, G_N_ELEMENTS (app_entries), app); GMenu *menu = g_menu_new (); g_menu_append (menu, "GPaste Settings", "app.prefs"); g_menu_append (menu, "About GPaste", "app.about"); g_menu_append (menu, "Quit", "app.quit"); gtk_application_set_app_menu (app, G_MENU_MODEL (menu)); G_GNUC_UNUSED GtkWidget *window = g_paste_ui_window_new (app); return g_application_run (gapp, argc, argv); } GPaste-3.18.6/tests/000077500000000000000000000000001305131721400141335ustar00rootroot00000000000000GPaste-3.18.6/tests/gnome-shell-client.mk000066400000000000000000000020511305131721400201500ustar00rootroot00000000000000# This file is part of GPaste. # # Copyright 2013-2015 Marc-Antoine Perennou # # GPaste is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GPaste is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GPaste. If not, see . TESTS+= \ tests/bin/test-gnome-shell-client \ $(NULL) tests_bin_test_gnome_shell_client_SOURCES = \ tests/gnome-shell-client/test-gnome-shell-client.c \ $(NULL) tests_bin_test_gnome_shell_client_CFLAGS = \ $(AM_CFLAGS) \ $(NULL) tests_bin_test_gnome_shell_client_LDADD = \ $(builddir)/$(libgpaste_la_file) \ $(AM_LIBS) \ $(NULL) GPaste-3.18.6/tests/gnome-shell-client/000077500000000000000000000000001305131721400176215ustar00rootroot00000000000000GPaste-3.18.6/tests/gnome-shell-client/test-gnome-shell-client.c000066400000000000000000000076011305131721400244340ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright 2013-2015 Marc-Antoine Perennou * * GPaste is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GPaste is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GPaste. If not, see . */ #include #define EXIT_TEST_SKIP 77 typedef struct { const gchar *accelerator; guint32 action; } Accelerator; static void on_accelerator_activated (GPasteGnomeShellClient *client G_GNUC_UNUSED, guint64 action, gpointer user_data) { Accelerator *accels = user_data; g_print ("Recieved action %lu, was ", action); for (guint64 i = 0; i < 3; ++i) { if (accels[i].action == action) { g_print ("%s\n", accels[i].accelerator); return; } } g_print ("not a known accelerator\n"); } static gboolean kill_loop (gpointer user_data) { g_main_loop_quit (user_data); return G_SOURCE_REMOVE; } gint main (gint argc, gchar *argv[]) { if (argc != 2 || g_strcmp0 (argv[1], "--dont-skip")) return EXIT_TEST_SKIP; g_setenv ("G_MESSAGES_DEBUG", "all", TRUE); g_autoptr (GError) error = NULL; g_autoptr (GPasteGnomeShellClient) client = g_paste_gnome_shell_client_new_sync (&error); if (!client) { g_error ("Couldn't connect to gnome-shell: %s", error->message); return EXIT_FAILURE; } Accelerator accels[3] = { { "D", 0 }, { "F", 0 }, { "G", 0 } }; GPasteGnomeShellAccelerator gs_accels[3]; GPasteGnomeShellAccelerator gs_accel = G_PASTE_GNOME_SHELL_ACCELERATOR (accels[2].accelerator); for (guint64 i = 0; i < 2; ++i) gs_accels[i] = G_PASTE_GNOME_SHELL_ACCELERATOR (accels[i].accelerator); gs_accels[2].accelerator = NULL; guint64 signal_id = g_signal_connect (client, "accelerator-activated", G_CALLBACK (on_accelerator_activated), accels); g_print ("Now testing KeyGrabber\n"); guint32 *actions = g_paste_gnome_shell_client_grab_accelerators_sync (client, gs_accels, &error); for (guint64 i = 0; i < 2; ++i) accels[i].action = actions[i]; g_free (actions); if (error) { g_error ("Couldn't grab accelerators: %s", error->message); return EXIT_FAILURE; } accels[2].action = g_paste_gnome_shell_client_grab_accelerator_sync (client, gs_accel, &error); if (error) { g_error ("Couldn't grab accelerator: %s", error->message); return EXIT_FAILURE; } g_print ("Now should recognize D, F and G for 10 secondes.\n"); g_autoptr (GMainLoop) loop = g_main_loop_new (NULL, FALSE); g_source_set_name_by_id (g_timeout_add_seconds (10, kill_loop, loop), "[GPaste] test loop"); g_main_loop_run (loop); for (guint64 i = 0; i < 2; ++i) { g_paste_gnome_shell_client_ungrab_accelerator_sync (client, accels[i].action, &error); accels[i].action = 0; if (error) { g_error ("Couldn't ungrab accelerator: %s", error->message); return EXIT_FAILURE; } } g_print ("Now should no longer recognize keybindings for 3 secondes.\n"); g_usleep (3000000); g_signal_handler_disconnect (client, signal_id); return EXIT_SUCCESS; } GPaste-3.18.6/tools/000077500000000000000000000000001305131721400141315ustar00rootroot00000000000000GPaste-3.18.6/tools/check-includes.sh000077500000000000000000000030131305131721400173460ustar00rootroot00000000000000#!/bin/zsh dissect() { mkdir -p "$(dirname "${3}")" touch "${3}.data" for include in $(grep '#include' "${1}" | awk '{print $NF}' | sed -e 's///' -e 's/"//g'); do [[ -z "${4}" ]] && echo "${include}" >> "${3}".includes sed -i '\|^'"${2}"'$|d' "${3}.data" echo "${2} => ${include}" >> "${3}.data" [[ "${include/gpaste/}" != "${include}" ]] && dissect **/"${include}" "${2} => ${include}" "${3}" "rec" done } main() { local ROOTDIR="$(dirname ${1})/.." local TMPDIR="${ROOTDIR}/tmp" local RESULTFILE="${ROOTDIR}/result" local TMPFILE="${RESULTFILE}-tmp" pushd "${ROOTDIR}" rm -fr "${TMPDIR}" "${RESULTFILE}" for file in **/*.[ch]; do dissect "${file}" "${file}" "${TMPDIR}/${file}" done for result in "${TMPDIR}"/**/*.[ch].includes; do file="${result/.includes/}" file="${file/${TMPDIR}\//}" sort -u "${result}" | tee "${result}" > /dev/null rm -f "${TMPFILE}" for include in $(< "${result}"); do concurrent="$(grep "${include}" "${result/includes/data}" | grep -v "^${file} => ${include}" | head -n1)" [[ -z "${concurrent}" ]] || echo "${include}: ${concurrent}" >> "${TMPFILE}" done if [[ -s "${TMPFILE}" ]]; then echo "${file}\n================" >> "${RESULTFILE}" cat "${TMPFILE}" >> "${RESULTFILE}" echo >> "${RESULTFILE}" fi done rm -fr "${TMPDIR}" cat "${RESULTFILE}" popd } main "${0}"