pax_global_header00006660000000000000000000000064132520540500014506gustar00rootroot0000000000000052 comment=09958b015af529d0c7c06ea1292dbd47b01dc779 gpaste-3.28.0/000077500000000000000000000000001325205405000130635ustar00rootroot00000000000000gpaste-3.28.0/.clang-format000066400000000000000000000004721325205405000154410ustar00rootroot00000000000000--- AlignAfterOpenBracket: true AlignOperands: true AlignTrailingComments: true AlwaysBreakAfterDefinitionReturnType: All BinPackArguments: false BreakBeforeBraces: Allman ColumnLimit: 0 IndentWidth: 4 MaxEmptyLinesToKeep: 1 SpaceBeforeParens: Always UseTab: Never ... Language: JavaScript DisableFormat: true ... gpaste-3.28.0/.gitignore000066400000000000000000000010461325205405000150540ustar00rootroot00000000000000/.buildconfig /Makefile /bin/* /tests/bin/* /data/appstream/*.appdata.xml /data/appstream/*.appdata.valid /data/control-center/*.xml /data/desktop/*.desktop /data/desktop/*.desktop.in /data/dbus/*.service /data/gsettings/*.gschema.xml /data/systemd/*.service /bindings /data/pkg-config/*.pc /man/*.1 /ABOUT-NLS /po/Makefile /po/Makevars.template /po/Rules-quot /po/boldquot.sed /po/en@boldquot.header /po/en@quot.header /po/insert-header.sin /po/quot.sed /po/remove-potcdate.sed /po/remove-potcdate.sin /src/gnome-shell/metadata.json /test-suite.log gpaste-3.28.0/AUTHORS000066400000000000000000000001051325205405000141270ustar00rootroot00000000000000Lead developer Marc-Antoine Perennou gpaste-3.28.0/COPYING000066400000000000000000000024651325205405000141250ustar00rootroot00000000000000Copyright (c) 2010-2018, Marc-Antoine Perennou All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. gpaste-3.28.0/ChangeLog000066400000000000000000000002201325205405000146270ustar00rootroot000000000000002011-06-29 Marc-Antoine Perennou * *: The ChangeLog is autogenerated when releasing, see git log for changes gpaste-3.28.0/Makefile.am000066400000000000000000000064051325205405000151240ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou SUBDIRS = po ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} AM_MAKEFLAGS = --no-print-directory AM_DISTCHECK_CONFIGURE_FLAGS = \ --with-controlcenterdir="$$dc_install_base/$(controlcenterdir)" \ --with-dbusservicesdir="$$dc_install_base/$(dbusservicesdir)" \ --with-systemduserunitdir="$$dc_install_base/$(systemduserunitdir)" \ --enable-appstream-util \ --enable-gnome-shell-extension \ --enable-introspection \ --enable-vala \ $(NULL) AM_CPPFLAGS = \ -include config.h \ -I$(srcdir)/src/libgpaste \ -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/io \ -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 \ -DG_PASTE_COMPILATION \ -DGTK_API=$(GTK_API) \ -DLOCALEDIR=\"$(localedir)\" \ -DPKGLIBEXECDIR=\"$(pkglibexecdir)\" \ -DG_LOG_USE_STRUCTURED=1 \ -DGDK_DISABLE_DEPRECATED \ -DGTK_DISABLE_DEPRECATED \ $(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) # Libraries include src/libgpaste.mk # Bindings include src/gi.mk include src/vapi.mk # Core utilities include src/client.mk include src/daemon.mk include src/ui.mk # Gnome-Shell extension 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 include data/systemd.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 \ cd "$(srcdir)"; \ echo -e '# Generated by Makefile. Do not edit.\n\n' > $(distdir)/ChangeLog; \ $(srcdir)/build-aux/missing --run git log >> $(distdir)/ChangeLog; \ fi gpaste-3.28.0/NEWS000066400000000000000000000637251325205405000135770ustar00rootroot00000000000000NEW in 3.28.0 (13/03/2018) ============= - gpaste-daemonn now emits a dbus signal when an item is selected - gpaste-client can now print the history in reverse order - drop gtk4 support, it will come back later - API adjustments to prepare for the future gtk4 port - ask confirmation before emptying an history NEW in 3.26.2 (08/03/2018) ============= - fix regression in gnome-shell extension - fix another potential images memory leak NEW in 3.26.1 (07/03/2018) ============= - fix memory leaks in images support - silence a warnings in the gnome-shell extension NEW in 3.26.0 (16/09/2017) ============= - Javascript modernizations - Adapt to gjs 1.50 - Adapt to gnome-shell/mutter 3.26 - use the new clipboardText feature in the search provider - gtk4 3.91.2 compatibility NEW in 3.24.5 (08/03/2018) ============= - fix regression in gnome-shell extension - fix another potential images memory leak NEW in 3.24.4 (07/03/2018) ============= - fix memory leaks in images support - silence a warnings in the gnome-shell extension NEW in 3.24.3 (16/09/2017) ============= - Pagination fixes in the gnome-shell extension - Fix some cransh in gpaste-ui NEW in 3.24.2 (19/05/2017) ============= - `gpaste-client add` now accepts reading from stdin - you can't have two passwords with the same name in the history anymore - prevent a bug adding a password both as password and text in come case NEW in 3.24.1 (08/04/2017) ============= - fix a regression in Passwords handling NEW in 3.24.0 (07/04/2017) ============= - change the history format to 2.0 to be more flexible (backward compatible) - unify and consolidate some clipboard interactions - handle text/html and text/xml mime types NEW in 3.23.90 (20/03/2017) ============= - applet and unity app-indicator have been removed - a minimal applet is available there: https://github.com/Keruspe/gpaste-applet - Dutch translation has been added - gtk4 is now supported (--with-gtk=4.0) - gnome-shell/mutter 3.24 are now supported and required - ui will now close when you select an item (configurable) - more intuitive search interactions in the ui - preparations for future other storage backends - preparations for mime types support - more reliable "paste" behaviour part in some corener cases NEW in 3.22.6 (08/03/2018) ============= - fix regression in gnome-shell extension - fix another potential images memory leak NEW in 3.22.5 (07/03/2018) ============= - fix memory leaks in images support - silence a warnings in the gnome-shell extension NEW in 3.22.4 (19/05/2017) ============= - `gpaste-client add` now accepts reading from stdin - you can't have two passwords with the same name in the history anymore - prevent a bug adding a password both as password and text in come case NEW in 3.22.3 (28/02/2017) ============= - fix switch in gnome-shell extension - fix some wrongly detected growing line NEW in 3.22.2 (17/02/2017) ============= - fix memory leaks in the debugging logs - fix some corner case in images handling - fix crash in UI when refreshing during search - stability improvements NEW in 3.22.1 (30/11/2016) ============= - Fix some build system issues for vala and gobject-introspection NEW in 3.22.0 (08/10/2016) ============= - Depend on gtk+ 3.22, glib 2.50, gobject-introspeciton 1.50 - Bug fixes and simplifications in pagination handling for gnome-shell - Fix bug with clipboard/primary selection synchronisation - Fix racy calls to gtk_clipboard_store NEW in 3.21.91 (17/09/2016) ============= - Lots of fixes in the gnome-shell extension pagination - Fix a crash when trying to add binary data with gpaste-client - Use GLib new structured logging - Update appstream files NEW in 3.21.90 (09/09/2016) ============= - Port from intltool to gettext - pkg-config 0.29 is now required - Port to the internal mutter-clutter - gnome-shell extension cleanup - Add pagination to gnmoe-shell extension NEW in 3.20.7 (08/03/2018) ============= - fix memory leaks in images support - silence a warnings in the gnome-shell extension NEW in 3.20.6 (28/02/2017) ============= - fix switch in gnome-shell extension - fix refresh with search in the ui - fix some wrongly detected growing line NEW in 3.20.5 (17/02/2017) ============= - fix memory leaks in the debugging logs - fix some corner case in images handling - stability improvements NEW in 3.20.4 (28/06/2016) ============= - Fix some extensive CPU usage in some cases NEW in 3.20.3 (14/06/2016) ============= - Fix soname versioning NEW in 3.20.2 (24/05/2016) ============= - Add missing icon NEW in 3.20.1 (23/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 - Fix some build issues with some toolchains NEW in 3.20 (23/03/2016) ============= - Relicensing from GPL-3 to BSD-2 - Detect the presence of more features at runtime instead of compile time - The gpaste-client cli has been mostly rewritten - "gpaste-client file" now supports adding images to the history - The legacy "gpaste" cli is gone - gnome-shell extension cleanups and compatibility with 3.20 - automake 1.15 is required - pkg-config 0.27 is required - gtk+ 3.20, vala 0.32 (if --enable-vapi) and gobject-introspection 1.48 are required - gpaste-ui now has a "new" button to add new contents to the clipboard - The daemon now reexecs itself on SIGUSR1 - Avoid having two passwords under the same name in history - libgpaste now logs into its own G_LOG_DOMAIN - GPaste components now write their pid to a file - A new tool is provided for debugging, but not installed: clipboard-watcher - systemd user units are provided - Build system cleanups - Outdated translations have been dropped - gobject-introspection fixes - Fix style with gtk+ 3.20 - Implement the new shotcut window from gtk+ - Various code cleanups NEW in 3.18.7 (08/03/2018) ============= - fix memory leaks in images support - silence a warnings in the gnome-shell extension NEW 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, you 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-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-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.28.0/README.md000066400000000000000000000034441325205405000143470ustar00rootroot00000000000000 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 a subcommands: `gpaste-client ui` which makes the graphical tool pop. 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/ You can see everything I'll post about GPaste [there](http://www.imagination-land.org/tags/GPaste.html). Latest release for GNOME 3.28 is: [GPaste 3.28.0](http://www.imagination-land.org/posts/2018-03-13-gpaste-3.28.0-released.html). Direct link to download: gpaste-3.28.0/THANKS000066400000000000000000000011061325205405000137740ustar00rootroot00000000000000Christian Kluge Christian Schendel Elder Marco Gary van der Merwe Heimen Stoffels Jan Alexander Steffens (heftig) Jesse Jaara Julien Durillon Jérémy Lal Louis Lukas Zapletal Mog Toni TC camporez renataogarcia whyoh gpaste-3.28.0/TODO000066400000000000000000000003041325205405000135500ustar00rootroot00000000000000general: wayland 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.28.0/autogen.sh000077500000000000000000000024001325205405000150600ustar00rootroot00000000000000#!/bin/bash set -euo pipefail autotools() { autoreconf -i -Wall } 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-appstream-util --enable-gnome-shell-extension --enable-introspection --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.28.0/configure.ac000066400000000000000000000172571325205405000153650ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou m4_define([gpaste_version], [3.28.0]) # Update gpaste_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’. m4_define([gpaste_lt_version], [10:0:0]) # Build system requirements m4_define([autoconf_required], [2.69]) m4_define([automake_required], [1.15]) m4_define([libtool_required], [2.2.6]) m4_define([pkgconfig_required], [0.29]) # Glib and Gtk macros and dependencies m4_define([glib_major_required], [2]) m4_define([glib_minor_required], [56]) m4_define([glib_api_required], [G_ENCODE_VERSION(glib_major_required, glib_minor_required)]) m4_define([glib_required], [glib_major_required.glib_minor_required.0]) m4_define([gtk3_major_required], [3]) m4_define([gtk3_minor_required], [22]) m4_define([gtk3_api_required], [G_ENCODE_VERSION(gtk3_major_required, gtk3_minor_required)]) m4_define([gtk3_required], [gtk3_major_required.gtk3_minor_required.0]) m4_define([gtk4_major_required], [3]) m4_define([gtk4_minor_required], [90]) m4_define([gtk4_api_required], [G_ENCODE_VERSION(gtk4_major_required, gtk4_minor_required)]) m4_define([gtk4_required], [gtk4_major_required.gtk4_minor_required.0]) # Other dependencies m4_define([gdk_pixbuf_required], [2.32.0]) m4_define([gir_required], [1.52.0]) m4_define([gjs_required], [1.50.0]) m4_define([vala_required], [0.36]) AC_PREREQ(autoconf_required) AC_INIT([GPaste], [gpaste_version], [Marc-Antoine@Perennou.com], [gpaste]) AC_SUBST([PACKAGE_NAME]) AC_SUBST([PACKAGE_VERSION]) LIBGPASTE_LT_VERSION="gpaste_lt_version" AC_SUBST([LIBGPASTE_LT_VERSION]) AC_DEFINE_UNQUOTED([GLIB_VERSION_MIN_REQUIRED], [glib_api_required], [The lowest GLib API version supported]) AC_DEFINE_UNQUOTED([GLIB_VERSION_MAX_ALLOWED], [glib_api_required], [The highest GLib API version supported]) AC_ARG_WITH([gtk], AS_HELP_STRING([--with-gtk=3.0|4.0], [GTK API to user]), [], [with_gtk=3.0]) case "${with_gtk}" in 3.0) AC_DEFINE_UNQUOTED([GDK_VERSION_MIN_REQUIRED], [gtk3_api_required], [The lowest Gdk API version supported]) AC_DEFINE_UNQUOTED([GDK_VERSION_MAX_ALLOWED], [gtk3_api_required], [The highest Gdk API version supported]) GTK_REQUIRED=gtk3_required GTK_DEP="gtk+-3.0" GDK_DEP="gdk-3.0" GDK_X11_DEP="gdk-x11-3.0" ;; # 4.0) # AC_DEFINE_UNQUOTED([GDK_VERSION_MIN_REQUIRED], [gtk4_api_required], [The lowest Gdk API version supported]) # AC_DEFINE_UNQUOTED([GDK_VERSION_MAX_ALLOWED], [gtk4_api_required], [The highest Gdk API version supported]) # GTK_REQUIRED=gtk4_required # GTK_DEP="gtk+-4.0" # GDK_DEP="gtk+-4.0" # GDK_X11_DEP="gtk+-x11-4.0" # ;; *) AC_MSG_ERROR([Wrong gtk+ version specified: ${with_gtk}]) ;; esac AC_SUBST([GTK_API], "${with_gtk:0:1}") AC_DEFINE([G_PASTE_DEFAULT_HISTORY], ["history"], [The default hsitory name]) AC_DEFINE([G_PASTE_ICON_NAME], ["edit-paste"], [The name of the icon used by GPaste]) AC_DEFINE([G_PASTE_EXTENSION_NAME], ["GPaste@gnome-shell-extensions.gnome.org"], [The name of the GPaste extension]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_SRCDIR([src/]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_AUX_DIR([build-aux]) AC_PREFIX_DEFAULT([/usr]) AC_USE_SYSTEM_EXTENSIONS AM_PROG_AR LT_PREREQ(libtool_required) LT_INIT([disable-static pic-only]) AM_INIT_AUTOMAKE(automake_required [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 G_PASTE_APPEND_CFLAGS G_PASTE_APPEND_LDFLAGS GETTEXT_PACKAGE=${PACKAGE_NAME} AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["${GETTEXT_PACKAGE}"], [Gettext Package]) AC_SUBST([GETTEXT_PACKAGE]) AM_GNU_GETTEXT([external]) AM_GNU_GETTEXT_VERSION AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.7]) PKG_PREREQ(pkgconfig_required) PKG_PROG_PKG_CONFIG([pkgconfig_required]) PKG_INSTALLDIR PKG_CHECK_MODULES(GLIB, [glib-2.0 >= glib_required gobject-2.0 >= glib_required gio-2.0 >= glib_required]) PKG_CHECK_MODULES(GTK, [${GDK_DEP} >= ${GTK_REQUIRED} ${GTK_DEP} >= ${GTK_REQUIRED} pango]) PKG_CHECK_MODULES(GDK_PIXBUF, [gdk-pixbuf-2.0 >= gdk_pixbuf_required]) PKG_CHECK_MODULES(X11, [x11 xi]) PKG_CHECK_MODULES(APPSTREAM, [appstream-glib]) AC_CHECK_HEADERS([X11/extensions/XInput2.h]) GLIB_GSETTINGS APPSTREAM_XML GOBJECT_INTROSPECTION_CHECK([gir_required]) VAPIGEN_CHECK([vala_required]) # For bus_services_dir in pkg-config PKG_CHECK_MODULES(DBUS, [dbus-1]) G_PASTE_WITH([controlcenterdir], [Gnome control-center keybindings directory], [`${PKG_CONFIG} --variable keysdir gnome-keybindings`]) G_PASTE_WITH([dbusservicesdir], [D-Bus system session directory], [`${PKG_CONFIG} --variable session_bus_services_dir dbus-1`]) G_PASTE_WITH([systemduserunitdir], [systemd user units directory], [`${PKG_CONFIG} --variable systemduserunitdir systemd`]) G_PASTE_ENABLE([bash-completion], [Disable the bash completion], [yes]) G_PASTE_ENABLE([gnome-shell-extension], [Disable gnome-shell extension], [yes]) G_PASTE_ENABLE([x-keybinder], [Disable the X keybinder], [yes]) G_PASTE_ENABLE([zsh-completion], [Disable the zsh completion], [yes]) AS_IF([test x${enable_gnome_shell_extension} = xyes], [ AS_IF([test x${enable_introspection} != xyes], [AC_MSG_ERROR([*** Introspection support is required to run the gnome-shell extension])]) PKG_CHECK_MODULES(JS_EXTENSION, [mutter-clutter-2 gjs-1.0 >= gjs_required]) ]) AS_IF([test x${enable_x_keybinder} = xyes], [ PKG_CHECK_MODULES(GDK_X11, [${GDK_X11_DEP} >= ${GTK_REQUIRED}]) AC_DEFINE([ENABLE_X_KEYBINDER], [1], [Whether the X keybinder is built]) ]) AS_IF([test x${enable_bash_completion} = xyes], [ G_PASTE_WITH([bashcompletiondir], [Bash completion directory], ['${datadir}/bash-completion/completions']) ]) AS_IF([test x${enable_zsh_completion} = xyes], [ G_PASTE_WITH([zshcompletiondir], [Zsh completion directory], ['${datadir}/zsh/site-functions']) ]) 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} libexecdir: ${libexecdir} includedir: ${includedir} datarootdir: ${datarootdir} datadir: ${datadir} compiler: ${CC} cflags: ${CFLAGS} ldflags: ${LDFLAGS} gtk+ API: ${with_gtk} vapi generator: ${VAPIGEN} GObject Introspection: ${enable_introspection} Vapi: ${enable_vala} Gnome-Shell extension: ${enable_gnome_shell_extension} X keybinder support: ${enable_x_keybinder} Control Center dir: ${controlcenterdir} DBus user services dir: ${dbusservicesdir} systemd user units dir: ${systemduserunitdir} Bash completion: ${enable_bash_completion} Bash completion dir: ${bashcompletiondir} Zsh completion: ${enable_zsh_completion} Zsh completion dir: ${zshcompletiondir} ]) gpaste-3.28.0/data/000077500000000000000000000000001325205405000137745ustar00rootroot00000000000000gpaste-3.28.0/data/appstream.mk000066400000000000000000000011241325205405000163170ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou @APPSTREAM_XML_RULES@ appstream_in_files = \ %D%/appstream/org.gnome.GPaste.Ui.appdata.xml.in \ $(NULL) appstream_XML = $(appstream_in_files:.xml.in=.xml) SUFFIXES += .appdata.xml.in .appdata.xml .appdata.xml.in.appdata.xml: @ $(MKDIR_P) $(@D) $(AM_V_GEN) $(MSGFMT) --xml --template $< -o $@ -d $(top_builddir)/po/ EXTRA_DIST += \ $(appstream_in_files) \ $(NULL) CLEANFILES += \ $(appstream_XML) \ $(NULL) gpaste-3.28.0/data/appstream/000077500000000000000000000000001325205405000157705ustar00rootroot00000000000000gpaste-3.28.0/data/appstream/org.gnome.GPaste.Ui.appdata.xml.in000066400000000000000000000036571325205405000241740ustar00rootroot00000000000000 org.gnome.GPaste.Ui.desktop GPaste Manage your clipboard history Marc-Antoine Perennou BSD-2-Clause CC-BY-SA-3.0 GNOME

GPaste is a clipboard managing system allowing you to track and manage your clipboard history in a highly customizable way.

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 https://github.com/Keruspe/GPaste/issues https://paypal.me/keruspe/ https://github.com/Keruspe/GPaste/issues https://github.com/Keruspe/GPaste GPaste
gpaste-3.28.0/data/completions.mk000066400000000000000000000004721325205405000166640ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou bashcompletion_DATA = %D%/completions/gpaste-client zshcompletion_DATA = %D%/completions/_gpaste-client EXTRA_DIST += \ $(bashcompletion_DATA) \ $(zshcompletion_DATA) \ $(NULL) gpaste-3.28.0/data/completions/000077500000000000000000000000001325205405000163305ustar00rootroot00000000000000gpaste-3.28.0/data/completions/_gpaste-client000066400000000000000000000076021325205405000211560ustar00rootroot00000000000000#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.]' '(-e --reverse)'{-e,--reverse}'[Display the items in reverse order.]' '(-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.28.0/data/completions/gpaste-client000066400000000000000000000022101325205405000210050ustar00rootroot00000000000000_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 --reverse -e 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 --reverse -e --zero -z" -- ${cur} ) ;; esac fi } complete -F _gpaste-client gpaste-client gpaste-3.28.0/data/control-center.mk000066400000000000000000000010611325205405000172610ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou controlcenter_DATA = \ %D%/control-center/42-gpaste.xml \ $(NULL) SUFFIXES += .control-center.xml.in .xml .control-center.xml.in.xml: @ $(MKDIR_P) $(@D) $(AM_V_GEN) $(SED) -e 's,[@]GETTEXT_PACKAGE[@],$(GETTEXT_PACKAGE),g' < $< > $@ EXTRA_DIST+= \ $(controlcenter_DATA:.xml=.control-center.xml.in) \ $(NULL) CLEANFILES+= \ $(controlcenter_DATA) \ $(NULL) gpaste-3.28.0/data/control-center/000077500000000000000000000000001325205405000167325ustar00rootroot00000000000000gpaste-3.28.0/data/control-center/42-gpaste.control-center.xml.in000066400000000000000000000017121325205405000245250ustar00rootroot00000000000000 gpaste-3.28.0/data/dbus.mk000066400000000000000000000011701325205405000152610ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou nodist_dbusservices_DATA = \ %D%/dbus/org.gnome.GPaste.service \ %D%/dbus/org.gnome.GPaste.Ui.service \ $(NULL) SUFFIXES += .service .dbus.in .dbus.in.service: @ $(MKDIR_P) $(@D) $(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.28.0/data/dbus/000077500000000000000000000000001325205405000147315ustar00rootroot00000000000000gpaste-3.28.0/data/dbus/org.gnome.GPaste.Ui.dbus.in000066400000000000000000000002121325205405000216410ustar00rootroot00000000000000[D-BUS Service] Name=org.gnome.GPaste.Ui Exec=@pkglibexecdir@/gpaste-ui --gapplication-service SystemdService=org.gnome.GPaste.Ui.service gpaste-3.28.0/data/dbus/org.gnome.GPaste.dbus.in000066400000000000000000000001611325205405000212700ustar00rootroot00000000000000[D-BUS Service] Name=org.gnome.GPaste Exec=@pkglibexecdir@/gpaste-daemon SystemdService=org.gnome.GPaste.service gpaste-3.28.0/data/desktop.mk000066400000000000000000000020401325205405000157720ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou autostartdir = $(sysconfdir)/xdg/autostart applicationsdir = $(datadir)/applications gpaste_ui_desktop_file = %D%/desktop/org.gnome.GPaste.Ui.desktop all_desktop_files = \ $(gpaste_ui_desktop_file) \ $(NULL) nodist_autostart_DATA = \ $(NULL) nodist_applications_DATA = \ $(gpaste_ui_desktop_file) \ $(nodist_autostart_DATA) \ $(NULL) SUFFIXES += .desktop.in.in .desktop.in .desktop .desktop.in.in.desktop.in: @ $(MKDIR_P) $(@D) $(AM_V_GEN) $(SED) -e 's,[@]pkglibexecdir[@],$(pkglibexecdir),g' < $< > $@ .desktop.in.desktop: @ $(MKDIR_P) $(@D) $(AM_V_GEN) $(MSGFMT) --desktop --template $< -o $@ -d $(top_builddir)/po/ EXTRA_DIST += \ $(all_desktop_files:.desktop=.desktop.in.in) \ $(NULL) CLEANFILES += \ $(all_desktop_files) \ $(all_desktop_files:.desktop=.desktop.in) \ $(NULL) gpaste-3.28.0/data/desktop/000077500000000000000000000000001325205405000154455ustar00rootroot00000000000000gpaste-3.28.0/data/desktop/org.gnome.GPaste.Ui.desktop.in.in000066400000000000000000000004601325205405000235030ustar00rootroot00000000000000[Desktop Entry] Type=Application Name=GPaste Comment=Manage your clipboard history Keywords=Clipboard;Manager;Settings;Preferences;Configuration; Icon=edit-paste Exec=@pkglibexecdir@/gpaste-ui DBusActivatable=true Terminal=false Categories=GTK;GNOME;Settings;X-GNOME-PersonalSettings; StartupNotify=true gpaste-3.28.0/data/gsettings.mk000066400000000000000000000015551325205405000163420ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou gpaste_gschema_file = %D%/gsettings/org.gnome.GPaste.gschema.xml gschemas_compiled = %D%/gsettings/gschemas.compiled gsettings_SCHEMAS = \ $(gpaste_gschema_file) \ $(NULL) @GSETTINGS_RULES@ $(gpaste_gschema_file:.xml=.valid): $(gpaste_gschema_file) @ $(MKDIR_P) $(@D) $(gschemas_compiled): $(gsettings_SCHEMAS:.xml=.valid) $(AM_V_GEN) $(GLIB_COMPILE_SCHEMAS) --targetdir=$(srcdir) . SUFFIXES += .gschema.xml.in .gschema.xml .gschema.xml.in.gschema.xml: @ $(MKDIR_P) $(@D) $(AM_V_GEN) $(SED) -e 's,[@]GETTEXT_PACKAGE[@],$(GETTEXT_PACKAGE),g' < $< > $@ EXTRA_DIST += \ $(gpaste_gschema_file:.xml=.xml.in) \ $(NULL) CLEANFILES += \ $(gpaste_gschema_file) \ $(gschemas_compiled) \ $(NULL) gpaste-3.28.0/data/gsettings/000077500000000000000000000000001325205405000160035ustar00rootroot00000000000000gpaste-3.28.0/data/gsettings/org.gnome.GPaste.gschema.xml.in000066400000000000000000000166031325205405000236230ustar00rootroot00000000000000 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 true Do we close the UI after selecting an item? By default, we close it '<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 all versions of selected rich text (e.g. html) or just the plain text version? By default, we're saving all 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.28.0/data/pkg-config.mk000066400000000000000000000011541325205405000163520ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou SUFFIXES += .pc.in .pc .pc.in.pc: @ $(MKDIR_P) $(@D) $(AM_V_GEN) $(SED) \ -e 's,[@]libdir[@],$(libdir),g' \ -e 's,[@]includedir[@],$(includedir),g' \ -e 's,[@]VERSION[@],$(VERSION),g' \ < $< > $@ nodist_pkgconfig_DATA = \ %D%/pkg-config/gpaste-1.0.pc \ $(NULL) EXTRA_DIST += \ $(nodist_pkgconfig_DATA:.pc=.pc.in) \ $(NULL) CLEANFILES += \ $(nodist_pkgconfig_DATA) \ $(NULL) gpaste-3.28.0/data/pkg-config/000077500000000000000000000000001325205405000160205ustar00rootroot00000000000000gpaste-3.28.0/data/pkg-config/gpaste-1.0.pc.in000066400000000000000000000004001325205405000205220ustar00rootroot00000000000000libdir=@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.28.0/data/search-provider.mk000066400000000000000000000005351325205405000174250ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou searchproviderdir= $(datadir)/gnome-shell/search-providers/ if ENABLE_GNOME_SHELL_EXTENSION dist_searchprovider_DATA = \ %D%/search-provider/org.gnome.GPaste.search-provider.ini \ $(NULL) endif gpaste-3.28.0/data/search-provider/000077500000000000000000000000001325205405000170715ustar00rootroot00000000000000gpaste-3.28.0/data/search-provider/org.gnome.GPaste.search-provider.ini000066400000000000000000000002151325205405000257410ustar00rootroot00000000000000[Shell Search Provider] DesktopId=org.gnome.GPaste.Ui.desktop BusName=org.gnome.GPaste ObjectPath=/org/gnome/GPaste/SearchProvider Version=2 gpaste-3.28.0/data/systemd.mk000066400000000000000000000012311325205405000160120ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou nodist_systemduserunit_DATA = \ %D%/systemd/org.gnome.GPaste.service \ %D%/systemd/org.gnome.GPaste.Ui.service \ $(NULL) SUFFIXES += .service .systemd.in .systemd.in.service: @ $(MKDIR_P) $(@D) $(AM_V_GEN) $(SED) \ -e 's,[@]pkglibexecdir[@],$(pkglibexecdir),g' \ <$< >$@ EXTRA_DIST += \ $(nodist_systemduserunit_DATA:.service=.systemd.in) \ $(NULL) CLEANFILES += \ $(nodist_systemduserunit_DATA) \ $(NULL) gpaste-3.28.0/data/systemd/000077500000000000000000000000001325205405000154645ustar00rootroot00000000000000gpaste-3.28.0/data/systemd/org.gnome.GPaste.Ui.systemd.in000066400000000000000000000002251325205405000231330ustar00rootroot00000000000000[Unit] Description=GPaste user interface [Service] Type=dbus BusName=org.gnome.GPaste.Ui ExecStart=@pkglibexecdir@/gpaste-ui --gapplication-service gpaste-3.28.0/data/systemd/org.gnome.GPaste.systemd.in000066400000000000000000000001671325205405000225640ustar00rootroot00000000000000[Unit] Description=GPaste daemon [Service] Type=dbus BusName=org.gnome.GPaste ExecStart=@pkglibexecdir@/gpaste-daemon gpaste-3.28.0/m4/000077500000000000000000000000001325205405000134035ustar00rootroot00000000000000gpaste-3.28.0/m4/.gitignore000066400000000000000000000000201325205405000153630ustar00rootroot00000000000000*.m4 !gpaste.m4 gpaste-3.28.0/m4/gpaste.m4000066400000000000000000000070461325205405000151370ustar00rootroot00000000000000dnl This file is part of GPaste. dnl dnl Copyright (c) 2010-2018, Marc-Antoine Perennou dnl G_PASTE_WITH([directory], [help string], [default value]) dnl Check if we override a directory and define it AC_DEFUN([_G_PASTE_WITH], [ AC_ARG_WITH([$1], AS_HELP_STRING([--with-$1=DIR], [$2]), [], [with_$4=$3]) AC_SUBST([$1], [$with_$4]) ]) AC_DEFUN([G_PASTE_WITH], [_G_PASTE_WITH([$1],[$2],[$3],AS_TR_SH([$1]))]) dnl G_PASTE_ENABLE([feature], [help string], [default value]) dnl Check if we enable a feature and define it AC_DEFUN([_G_PASTE_ENABLE], [ AC_ARG_ENABLE([$1], AS_HELP_STRING([--$5-$1], [$2]), [], [enable_$4=$3]) AM_CONDITIONAL(AS_TR_CPP(ENABLE_$1), [test x$enable_$4 = xyes]) ]) AC_DEFUN([G_PASTE_ENABLE], [_G_PASTE_ENABLE([$1],[$2],[$3],AS_TR_SH([$1]),m4_if([$3],[no],[enable],[disable]))]) dnl G_PASTE_APPEND_CFLAGS dnl Check if CFLAGS are supported by $CC and add them AC_DEFUN([_G_PASTE_APPEND_CFLAG], [ ac_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $1" AC_MSG_CHECKING([if $CC supports $1 cflag]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([int foo;])], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]);CFLAGS="$ac_save_CFLAGS"]) ]) AC_DEFUN([_G_PASTE_APPEND_CFLAGS], [ for cflag in $1; do _G_PASTE_APPEND_CFLAG([$cflag]) done ]) AC_DEFUN([G_PASTE_APPEND_CFLAGS], [ _G_PASTE_APPEND_CFLAGS([ \ -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 \ -Wno-float-equal \ -Werror=overflow \ -Wp,-D_FORTIFY_SOURCE=2 \ -ffast-math \ -fno-common \ -fdiagnostics-show-option \ -fno-strict-aliasing \ -fvisibility=hidden \ -ffunction-sections \ -fdata-sections \ ]) ]) dnl G_PASTE_APPEND_LDFLAGS dnl Check if LDFLAGS are supported by $CC and add them AC_DEFUN([_G_PASTE_APPEND_LDFLAG], [ ac_save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $1" AC_MSG_CHECKING([if $CC supports $1 ldflag]) AC_LINK_IFELSE([AC_LANG_SOURCE([int main() { return 1; }])], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]);LDFLAGS="$ac_save_LDFLAGS"]) ]) AC_DEFUN([_G_PASTE_APPEND_LDFLAGS], [ for ldflag in $1; do _G_PASTE_APPEND_LDFLAG([$ldflag]) done ]) AC_DEFUN([G_PASTE_APPEND_LDFLAGS], [ _G_PASTE_APPEND_LDFLAGS([ \ -Wl,--as-needed \ -Wl,--gc-sections \ ]) ]) gpaste-3.28.0/man/000077500000000000000000000000001325205405000136365ustar00rootroot00000000000000gpaste-3.28.0/man/1.mk000066400000000000000000000002641325205405000143310ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou dist_man_MANS = \ %D%/1/gpaste-client.1 \ $(NULL) gpaste-3.28.0/man/1/000077500000000000000000000000001325205405000137765ustar00rootroot00000000000000gpaste-3.28.0/man/1/gpaste-client.1000066400000000000000000000064231325205405000166240ustar00rootroot00000000000000.\" This file is part of GPaste. .\" .\" Copyright (c) 2010-2018, Marc-Antoine Perennou .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 --reverse Display the items in reverse order .br .TP .B --zero Use NUL character instead of new lines between each item .br gpaste-3.28.0/po/000077500000000000000000000000001325205405000135015ustar00rootroot00000000000000gpaste-3.28.0/po/LINGUAS000066400000000000000000000000301325205405000145170ustar00rootroot00000000000000de es fr nl_NL pt_BR sv gpaste-3.28.0/po/Makevars000066400000000000000000000066711325205405000152070ustar00rootroot00000000000000# Makefile variables for PO directory in any package using GNU gettext. # Usually the message domain is the same as the package name. DOMAIN = GPaste # These two variables depend on the location of this directory. subdir = po top_builddir = .. # These options get passed to xgettext. XGETTEXT_OPTIONS = --from-code=UTF-8 --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=NC_:1c,2 --keyword=g_dngettext:2,3 --add-comments # 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 tells whether or not to prepend "GNU " prefix to the package # name that gets inserted into the header of the $(DOMAIN).pot file. # Possible values are "yes", "no", or empty. If it is empty, try to # detect it automatically by scanning the files in $(top_srcdir) for # "GNU packagename" string. PACKAGE_GNU = # 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 = # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt' # context. Possible values are "yes" and "no". Set this to yes if the # package uses functions taking also a message context, like pgettext(), or # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument. USE_MSGCTXT = no # These options get passed to msgmerge. # Useful options are in particular: # --previous to keep previous msgids of translated messages, # --quiet to reduce the verbosity. MSGMERGE_OPTIONS = # These options get passed to msginit. # If you want to disable line wrapping when writing PO files, add # --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and # MSGINIT_OPTIONS. MSGINIT_OPTIONS = # This tells whether or not to regenerate a PO file when $(DOMAIN).pot # has changed. Possible values are "yes" and "no". Set this to no if # the POT file is checked in the repository and the version control # program ignores timestamps. PO_DEPENDS_ON_POT = yes # This tells whether or not to forcibly update $(DOMAIN).pot and # regenerate PO files on "make dist". Possible values are "yes" and # "no". Set this to no if the POT file and PO files are maintained # externally. DIST_DEPENDS_ON_UPDATE_PO = yes gpaste-3.28.0/po/POTFILES.in000066400000000000000000000022551325205405000152620ustar00rootroot00000000000000src/libgpaste/gpaste-macros.h 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-new-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-shortcuts-window.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/client/gpaste-client.c src/daemon/gpaste-daemon.c src/ui/gpaste-ui.c data/appstream/org.gnome.GPaste.Ui.appdata.xml.in data/control-center/42-gpaste.control-center.xml.in data/desktop/org.gnome.GPaste.Ui.desktop.in.in data/gsettings/org.gnome.GPaste.gschema.xml.in gpaste-3.28.0/po/POTFILES.skip000066400000000000000000000001301325205405000156100ustar00rootroot00000000000000data/desktop/org.gnome.GPaste.Ui.desktop.in data/gsettings/org.gnome.GPaste.gschema.xml gpaste-3.28.0/po/de.po000066400000000000000000000776441325205405000144530ustar00rootroot00000000000000# 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: 2018-03-13 14:55+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:98 msgid "Failed to register the gtk application" msgstr "Initialisierung der Gtk-Anwendung fehlgeschlagen" #: src/libgpaste/gpaste-macros.h:110 msgid "is already running." msgstr "" #. This is the date format "month/day/year time" #: src/libgpaste/core/gpaste-image-item.c:222 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:224 #, 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:67 msgid "Password" msgstr "" #. This is the prefix displayed in history to identify selected files #: src/libgpaste/core/gpaste-uris-item.c:104 msgid "[Files] " msgstr "[Dateien]" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:117 #: src/libgpaste/ui/gpaste-ui-switch.c:92 msgid "Track clipboard changes" msgstr "Verfolge Änderungen in der Zwischenablage" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:123 msgid "Close UI on select" msgstr "" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:132 msgid "Enable the gnome-shell extension" msgstr "Die Gnome-Shell-Erweiterung aktivieren" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:138 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 #, fuzzy msgid "Max element size when displaying" msgstr "Maximale Größe des anzuzeigenden Eintrages:" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:209 #: data/gsettings/org.gnome.GPaste.gschema.xml.in:67 msgid "Max displayed history size" msgstr "Anzahl der anzuzeigenden Einträge" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:216 #: data/gsettings/org.gnome.GPaste.gschema.xml.in:76 msgid "Max history size" msgstr "Maximale Größe der Chronik" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:223 #: data/gsettings/org.gnome.GPaste.gschema.xml.in:85 msgid "Max memory usage (MB)" msgstr "Maximal zugewiesener Speicher (MB)" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:230 #, fuzzy msgid "Max text item length" msgstr "Maximale Textlänge:" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:237 #, fuzzy msgid "Min text item length" msgstr "Minimale Textlänge:" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:263 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:72 #: data/control-center/42-gpaste.control-center.xml.in:5 #, 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 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:73 #: data/control-center/42-gpaste.control-center.xml.in:3 #, fuzzy msgid "Launch the graphical tool" msgstr "Konfigurationswerkzeug starten" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:277 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:74 #: data/control-center/42-gpaste.control-center.xml.in:4 #, fuzzy msgid "Mark the active item as being a password" msgstr "Tastenkürzel um den ersten Eintrag in der Chronik zu löschen" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:284 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:75 #: data/control-center/42-gpaste.control-center.xml.in:6 #, fuzzy msgid "Display the history" msgstr "Chronik anzeigen:" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:291 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:76 #: data/control-center/42-gpaste.control-center.xml.in:7 #, fuzzy msgid "Sync the clipboard to the primary selection" msgstr "Zwischenablage mit der Auswahl synchronisieren:" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:298 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:77 #: data/control-center/42-gpaste.control-center.xml.in:8 #, fuzzy msgid "Sync the primary selection to the clipboard" msgstr "Auswahl mit der Zwischenablage synchronisieren:" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:305 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:78 #: data/control-center/42-gpaste.control-center.xml.in:9 #, 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:310 src/client/gpaste-client.c:804 msgid "Couldn't connect to GPaste daemon" msgstr "Verbindung zum GPaste daemon fehlgeschlagen" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:335 msgid "General behaviour" msgstr "Allgemeine Optionen" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:336 msgid "History settings" msgstr "Einstellungen zur Chronik" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:337 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:454 #: 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:459 #: src/libgpaste/ui/gpaste-ui-delete-item.c:49 #: src/libgpaste/ui/gpaste-ui-delete-history.c:24 #: src/libgpaste/ui/gpaste-ui-delete-history.c:61 msgid "Delete" msgstr "Löschen" #: src/libgpaste/ui/gpaste-ui-about.c:41 msgid "About" msgstr "Über" #: src/libgpaste/ui/gpaste-ui-backup-history.c:43 #: src/libgpaste/ui/gpaste-ui-backup-history.c:136 msgid "Backup" msgstr "Backup" #: src/libgpaste/ui/gpaste-ui-backup-history.c:44 #: src/libgpaste/ui/gpaste-ui-edit-item.c:45 #: src/libgpaste/ui/gpaste-ui-new-item.c:32 src/libgpaste/util/gpaste-util.c:30 msgid "Cancel" msgstr "" #: src/libgpaste/ui/gpaste-ui-backup-history.c:47 msgid "Under which name do you want to backup this history?" msgstr "" #: src/libgpaste/ui/gpaste-ui-delete-history.c:24 #, 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:44 #: src/libgpaste/ui/gpaste-ui-edit-item.c:117 msgid "Edit" msgstr "" #. Translators: this is the translation for emptying the history #: src/libgpaste/ui/gpaste-ui-empty-history.c:61 #: src/libgpaste/util/gpaste-util.c:338 #, fuzzy msgid "Empty" msgstr "(Leer)" #: src/libgpaste/ui/gpaste-ui-empty-item.c:35 msgid "(No result)" msgstr "" #: src/libgpaste/ui/gpaste-ui-empty-item.c:49 msgid "(Empty)" msgstr "(Leer)" #: src/libgpaste/ui/gpaste-ui-empty-item.c:60 #, fuzzy msgid "(Couldn't connect to GPaste daemon)" msgstr "Verbindung zum GPaste daemon fehlgeschlagen" #: src/libgpaste/ui/gpaste-ui-new-item.c:31 #: src/libgpaste/ui/gpaste-ui-new-item.c:83 msgid "New" msgstr "" #: src/libgpaste/ui/gpaste-ui-reexec.c:29 msgid "Restart" msgstr "" #: src/libgpaste/ui/gpaste-ui-reexec.c:29 #, 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:55 msgid "Restart the daemon" msgstr "" #: src/libgpaste/ui/gpaste-ui-search.c:26 msgid "Search" msgstr "" #: src/libgpaste/ui/gpaste-ui-settings.c:32 src/ui/gpaste-ui.c:105 msgid "GPaste Settings" msgstr "GPaste-Daemon-Einstellungen" #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:64 msgid "General" msgstr "" #: src/libgpaste/ui/gpaste-ui-switch.c:54 msgid "Stop" msgstr "" #: src/libgpaste/ui/gpaste-ui-switch.c:54 #, 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:49 msgid "Upload" msgstr "" #: src/libgpaste/util/gpaste-util.c:338 msgid "Do you really want to empty the history?" msgstr "" #: src/libgpaste/util/gpaste-util.c:617 msgid "Could not create history dir" msgstr "Ordner für die Chronik konnte nicht angelegt werden" #: src/client/gpaste-client.c:138 src/client/gpaste-client.c:428 #, fuzzy msgid "Couldn't spawn" msgstr "gpaste-applet konnte nicht gestartet werden.\n" #: src/client/gpaste-client.c:156 #, c-format msgid "Usage:\n" msgstr "Verwendung:\n" #. Translators: help for gpaste history #: src/client/gpaste-client.c:158 msgid "print the history with indexes" msgstr "Chronik mit Index anzeigen" #. Translators: help for gpaste history-size #: src/client/gpaste-client.c:160 #, fuzzy msgid "print the size of the history" msgstr "Lösche den ten Eintrag aus der Chronik" #. Translators: help for gpaste get-history #: src/client/gpaste-client.c:162 #, 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/client/gpaste-client.c:164 src/client/gpaste-client.c:166 #: src/client/gpaste-client.c:168 src/client/gpaste-client.c:174 #: src/client/gpaste-client.c:186 src/client/gpaste-client.c:190 msgid "name" msgstr "Name" #: src/client/gpaste-client.c:164 msgid "backup current history" msgstr "Aktuelle Chronik sichern" #: src/client/gpaste-client.c:166 msgid "switch to another history" msgstr "Zu einer anderen Chronik wechseln" #: src/client/gpaste-client.c:168 msgid "delete a history" msgstr "Lösche eine Chronik" #. Translators: help for gpaste list-histories #: src/client/gpaste-client.c:170 msgid "list available histories" msgstr "Verfügbare Chroniken anzeigen" #. Translators: help for gpaste add #: src/client/gpaste-client.c:172 msgid "text" msgstr "Text" #: src/client/gpaste-client.c:172 msgid "set text to clipboard" msgstr "Den markierten Text in die Zwischenablage kopieren" #: src/client/gpaste-client.c:174 msgid "password" msgstr "" #: src/client/gpaste-client.c:174 #, fuzzy msgid "add the name - password couple to the clipboard" msgstr "Auswahl mit der Zwischenablage synchronisieren:" #. Translators: help for gpaste rename-password #: src/client/gpaste-client.c:176 #, fuzzy msgid "old name" msgstr "Name" #: src/client/gpaste-client.c:176 #, fuzzy msgid "new name" msgstr "Name" #: src/client/gpaste-client.c:176 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/client/gpaste-client.c:178 src/client/gpaste-client.c:180 #: src/client/gpaste-client.c:182 src/client/gpaste-client.c:184 #: src/client/gpaste-client.c:186 src/client/gpaste-client.c:188 #: src/client/gpaste-client.c:212 msgid "number" msgstr "Nummer" #: src/client/gpaste-client.c:178 msgid "get the th item from the history" msgstr "Hole den ten Eintrag aus der Chronik" #: src/client/gpaste-client.c:180 msgid "set the th item from the history to the clipboard" msgstr "Setze den ten Eintrag aus der Chronik in die Zwischenablage" #: src/client/gpaste-client.c:182 msgid "contents" msgstr "" #: src/client/gpaste-client.c:182 #, 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/client/gpaste-client.c:184 #, 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/client/gpaste-client.c:186 #, 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/client/gpaste-client.c:188 msgid "delete th item of the history" msgstr "Lösche den ten Eintrag aus der Chronik" #: src/client/gpaste-client.c:190 #, fuzzy msgid "delete the password from the history" msgstr "Hole den ten Eintrag aus der Chronik" #. Translators: help for gpaste file #: src/client/gpaste-client.c:192 msgid "path" msgstr "Pfad" #: src/client/gpaste-client.c:192 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/client/gpaste-client.c:194 msgid "whatever" msgstr "PROGRAMM" #: src/client/gpaste-client.c:194 msgid "set the output of whatever to clipboard" msgstr "kopiert die Ausgabe von PROGRAMM in die Zwischenablage" #. Translators: help for gpaste empty #: src/client/gpaste-client.c:196 msgid "empty the history" msgstr "Chronik leeren" #. Translators: help for gpaste start #: src/client/gpaste-client.c:198 msgid "start tracking clipboard changes" msgstr "Startet die Verfolgung von Änderungen an der Zwischenablage" #. Translators: help for gpaste stop #: src/client/gpaste-client.c:200 msgid "stop tracking clipboard changes" msgstr "Stoppt die Verfolgung von Änderungen an der Zwischenablage" #. Translators: help for gpaste quit #: src/client/gpaste-client.c:202 #, fuzzy msgid "alias for stop" msgstr "Alias für stop" #. Translators: help for gpaste daemon-reexec #: src/client/gpaste-client.c:204 msgid "reexecute the daemon (after upgrading...)" msgstr "Startet den Daemon neu (Nach einem Update …)" #. Translators: help for gpaste settings #: src/client/gpaste-client.c:206 msgid "launch the configuration tool" msgstr "Konfigurationswerkzeug starten" #. Translators: help for gpaste ui #: src/client/gpaste-client.c:208 #, fuzzy msgid "launch the graphical tool" msgstr "Konfigurationswerkzeug starten" #. Translators: help for gpaste show-history #: src/client/gpaste-client.c:210 #, fuzzy msgid "make the applet or extension display the history" msgstr "Die maximale Anzahl der anzuzeigenden Einträge in der Chronik" #: src/client/gpaste-client.c:212 #, 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/client/gpaste-client.c:214 msgid "display the version" msgstr "Programmversion anzeigen" #. Translators: help for gpaste daemon-version #: src/client/gpaste-client.c:216 #, fuzzy msgid "display the daemon version" msgstr "Programmversion anzeigen" #. Translators: help for gpaste help #: src/client/gpaste-client.c:218 msgid "display this help" msgstr "Diesen Hilfetext anzeigen" #. Translators: help for gpaste about #: src/client/gpaste-client.c:220 #, fuzzy msgid "display the about dialog" msgstr "Programmversion anzeigen" #: src/client/gpaste-client.c:223 #, fuzzy, c-format msgid "Display options:" msgstr "Chronik anzeigen:" #. Translators: help for --oneline #: src/client/gpaste-client.c:226 #, fuzzy msgid "display each item on only one line" msgstr "Programmversion anzeigen" #. Translators: help for --raw #: src/client/gpaste-client.c:228 msgid "display each item raw (without line numbers)" msgstr "" #. Translators: help for --reverse #: src/client/gpaste-client.c:230 #, fuzzy msgid "display the items in reverse order" msgstr "Programmversion anzeigen" #. Translators: help for --zero #: src/client/gpaste-client.c:232 msgid "use a NUL character instead of a new line betweean each item" msgstr "" #: src/client/gpaste-client.c:235 #, fuzzy, c-format msgid "Merge options:" msgstr "Chronik anzeigen:" #. Translators: help for --decoration #. Translators: help for --separator #: src/client/gpaste-client.c:238 src/client/gpaste-client.c:240 msgid "string" msgstr "" #: src/client/gpaste-client.c:238 msgid "" "add the given decoration to the beginning and the end of each item before " "merging" msgstr "" #: src/client/gpaste-client.c:240 msgid "add the given separator between each item when merging" msgstr "" #: src/client/gpaste-client.c:333 #, c-format msgid "Successfully reexecuted the daemon\n" msgstr "Daemon wurde erfolgreich neu gestartet\n" #: src/client/gpaste-client.c:482 msgid "Cannot add non utf8 data as text." msgstr "" #: src/daemon/gpaste-daemon.c:33 #, fuzzy msgid "Stop signal received, exiting" msgstr "Signal %d wurde empfangen. Programm wird beendet\n" #: src/daemon/gpaste-daemon.c:70 msgid "Could not acquire DBus name." msgstr "DBus-Name konnte nicht bestimmt werden." #: src/ui/gpaste-ui.c:106 #, fuzzy msgid "Keyboard Shortcuts" msgstr "Tastaturkürzel" #: src/ui/gpaste-ui.c:107 msgid "About GPaste" msgstr "" #: src/ui/gpaste-ui.c:108 msgid "Quit" msgstr "Beenden" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:5 #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:4 #, fuzzy msgid "GPaste" msgstr "GPaste-Applet" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:6 #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:5 msgid "Manage your clipboard history" msgstr "" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:7 msgid "Marc-Antoine Perennou" msgstr "" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:12 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.Ui.appdata.xml.in:15 #, 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/appstream/org.gnome.GPaste.Ui.appdata.xml.in:22 msgid "The main UI" msgstr "" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:26 #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:30 #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:34 #, fuzzy msgid "The settings UI" msgstr "GPaste-Daemon-Einstellungen" #: data/control-center/42-gpaste.control-center.xml.in:2 msgid "@GETTEXT_PACKAGE@" msgstr "" #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:6 msgid "Clipboard;Manager;Settings;Preferences;Configuration;" msgstr "" #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:7 msgid "edit-paste" msgstr "" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:7 msgid "Max size of an element when displaying it" msgstr "Maximale Größe des anzuzeigenden Eintrages" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:8 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.in:15 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.in:16 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.in:24 msgid "The name of the current history" msgstr "Name der Aktuellen Chronik" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:25 msgid "The default name is \"history\"" msgstr "Der Standard-Name lautet \"history\"" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:32 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.in:33 msgid "By default, we're saving both" msgstr "Standardmäßig wird beides gespeichert." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:40 #, fuzzy msgid "Do we close the UI after selecting an item?" msgstr "Beeinflusst die Auswahl die Chronik?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:41 #, fuzzy msgid "By default, we close it" msgstr "Der Standard ist ja." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:48 #, 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.in:49 #, fuzzy msgid "" "By default, hitting ctrl + alt + g does that (\"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.in:57 #, 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.in:58 #, fuzzy msgid "" "By default, hitting ctrl + alt + s will mark the active item as being a " "password (\"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.in:68 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.in:77 msgid "Maximum number of items in history" msgstr "Maximale Anzahl der Einträge in der Chronik" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:86 msgid "Maximum amount of memory used to store contents" msgstr "Maximaler Speicherverbrauch für Inhalte" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:94 msgid "Max text item size" msgstr "Maximale Textlänge" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:95 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.in:103 msgid "Min text item size" msgstr "Minimale Textlänge" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:104 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.in:111 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.in:112 #, fuzzy msgid "" "By default, hitting ctrl + alt + v does that (\"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.in:120 msgid "Does the primary selection affects history?" msgstr "Beeinflusst die Auswahl die Chronik?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:121 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.in:128 msgid "" "Do we save all versions of selected rich text (e.g. html) or just the plain " "text version?" msgstr "" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:129 #, fuzzy msgid "By default, we're saving all" msgstr "Der Standard ist ja." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:136 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.in:137 msgid "By default, we're saving it" msgstr "Der Standard ist ja." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:144 msgid "The keyboard shortcut to display the menu" msgstr "Tastenkürzel um Menüleisten zu öffnen" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:145 #, fuzzy msgid "" "By default, hitting ctrl + alt + h displays the menu (\"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.in:153 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.in:154 #, fuzzy msgid "" "By default, hitting ctrl + alt + o syncs them (\"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.in:162 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.in:163 #, fuzzy msgid "" "By default, hitting ctrl + alt + p syncs them (\"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.in:171 msgid "Are the primary selection and the clipboard synchronized?" msgstr "ist die Auswahl und die Zwischenablage synchron?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:172 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.in:179 msgid "Do we track the clipboard changes?" msgstr "Werden Änderungen an der Zwischenablage verfolgt?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:180 msgid "By default, we're tracking those changes." msgstr "Standardmäßig werden sie verfolgt." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:187 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.in:188 msgid "By default, the daemon state keeps unchanged" msgstr "Standardmäßig bleibt der Daemon unberührt." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:195 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.in:196 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.in:204 #, 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.in:205 #, fuzzy msgid "" "By default, hitting ctrl + alt + u does that (\"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 "launch the applet" #~ msgstr "Applet starten" #, fuzzy #~ msgid "launch the unity application indicator" #~ msgstr "Konfigurationswerkzeug starten" #~ msgid "GPaste Applet" #~ msgstr "GPaste-Applet" #~ msgid "Tray icon to manage GPaste" #~ msgstr "Icon im Benachrichtigungsfeld um GPaste zu konfigurieren" #~ 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." #, fuzzy #~ msgid "GPaste AppIndicator" #~ msgstr "GPaste-Applet" #, fuzzy #~ msgid "Unity application indicator to manage GPaste" #~ msgstr "Icon im Benachrichtigungsfeld um GPaste zu konfigurieren" #~ 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." #, fuzzy #~ msgid "The AppIndicator menu" #~ msgstr "GPaste-Applet" #~ msgid "Max displayed history size: " #~ msgstr "Anzahl der anzuzeigenden Einträge:" #~ msgid "Max history size: " #~ msgstr "Maximale Größe der Chronik:" #~ msgid "Max memory usage (MB): " #~ msgstr "Maximaler Speicherverbrauch (MB):" #~ 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.28.0/po/es.po000066400000000000000000000744761325205405000144720ustar00rootroot00000000000000# 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: 2018-03-13 14:55+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:98 msgid "Failed to register the gtk application" msgstr "Fallo al registrar la aplicación gtk" #: src/libgpaste/gpaste-macros.h:110 msgid "is already running." msgstr "" #. This is the date format "month/day/year time" #: src/libgpaste/core/gpaste-image-item.c:222 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:224 #, 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:67 msgid "Password" msgstr "" #. This is the prefix displayed in history to identify selected files #: src/libgpaste/core/gpaste-uris-item.c:104 msgid "[Files] " msgstr "[Ficheros] " #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:117 #: src/libgpaste/ui/gpaste-ui-switch.c:92 msgid "Track clipboard changes" msgstr "Seguimiento de cambios en el portapapeles" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:123 msgid "Close UI on select" msgstr "" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:132 msgid "Enable the gnome-shell extension" msgstr "" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:138 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 #, fuzzy 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 #: data/gsettings/org.gnome.GPaste.gschema.xml.in:67 msgid "Max displayed history size" msgstr "Tamaño máximo al mostrar" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:216 #: data/gsettings/org.gnome.GPaste.gschema.xml.in:76 msgid "Max history size" msgstr "Tamaño máximo del historial" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:223 #: data/gsettings/org.gnome.GPaste.gschema.xml.in:85 msgid "Max memory usage (MB)" msgstr "" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:230 #, fuzzy msgid "Max text item length" msgstr "Tamaño máximo de texto" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:237 #, fuzzy msgid "Min text item length" msgstr "Tamaño mínimo de texto" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:263 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:72 #: data/control-center/42-gpaste.control-center.xml.in:5 #, 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 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:73 #: data/control-center/42-gpaste.control-center.xml.in:3 #, fuzzy msgid "Launch the graphical tool" msgstr "iniciar la herramienta de configuración" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:277 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:74 #: data/control-center/42-gpaste.control-center.xml.in:4 #, fuzzy msgid "Mark the active item as being a password" msgstr "Atajo de teclado para eliminar la primera entrada del historial" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:284 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:75 #: data/control-center/42-gpaste.control-center.xml.in:6 #, fuzzy msgid "Display the history" msgstr "Mostrar el historial" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:291 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:76 #: data/control-center/42-gpaste.control-center.xml.in:7 #, fuzzy 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 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:77 #: data/control-center/42-gpaste.control-center.xml.in:8 #, fuzzy 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 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:78 #: data/control-center/42-gpaste.control-center.xml.in:9 #, 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:310 src/client/gpaste-client.c:804 msgid "Couldn't connect to GPaste daemon" msgstr "No se pudo conectar al servicio GPaste" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:335 msgid "General behaviour" msgstr "Comportamiento general" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:336 msgid "History settings" msgstr "Ajustes del historial" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:337 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:454 #: 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:459 #: src/libgpaste/ui/gpaste-ui-delete-item.c:49 #: src/libgpaste/ui/gpaste-ui-delete-history.c:24 #: src/libgpaste/ui/gpaste-ui-delete-history.c:61 msgid "Delete" msgstr "Suprimir" #: src/libgpaste/ui/gpaste-ui-about.c:41 msgid "About" msgstr "" #: src/libgpaste/ui/gpaste-ui-backup-history.c:43 #: src/libgpaste/ui/gpaste-ui-backup-history.c:136 msgid "Backup" msgstr "Copia de seguridad" #: src/libgpaste/ui/gpaste-ui-backup-history.c:44 #: src/libgpaste/ui/gpaste-ui-edit-item.c:45 #: src/libgpaste/ui/gpaste-ui-new-item.c:32 src/libgpaste/util/gpaste-util.c:30 msgid "Cancel" msgstr "" #: src/libgpaste/ui/gpaste-ui-backup-history.c:47 msgid "Under which name do you want to backup this history?" msgstr "" #: src/libgpaste/ui/gpaste-ui-delete-history.c:24 #, 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:44 #: src/libgpaste/ui/gpaste-ui-edit-item.c:117 msgid "Edit" msgstr "" #. Translators: this is the translation for emptying the history #: src/libgpaste/ui/gpaste-ui-empty-history.c:61 #: src/libgpaste/util/gpaste-util.c:338 #, fuzzy msgid "Empty" msgstr "(Vacío)" #: src/libgpaste/ui/gpaste-ui-empty-item.c:35 msgid "(No result)" msgstr "" #: src/libgpaste/ui/gpaste-ui-empty-item.c:49 msgid "(Empty)" msgstr "(Vacío)" #: src/libgpaste/ui/gpaste-ui-empty-item.c:60 #, fuzzy msgid "(Couldn't connect to GPaste daemon)" msgstr "No se pudo conectar al servicio GPaste" #: src/libgpaste/ui/gpaste-ui-new-item.c:31 #: src/libgpaste/ui/gpaste-ui-new-item.c:83 msgid "New" msgstr "" #: src/libgpaste/ui/gpaste-ui-reexec.c:29 msgid "Restart" msgstr "" #: src/libgpaste/ui/gpaste-ui-reexec.c:29 #, 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:55 msgid "Restart the daemon" msgstr "" #: src/libgpaste/ui/gpaste-ui-search.c:26 msgid "Search" msgstr "" #: src/libgpaste/ui/gpaste-ui-settings.c:32 src/ui/gpaste-ui.c:105 #, fuzzy msgid "GPaste Settings" msgstr "Ajustes del servicio GPaste" #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:64 msgid "General" msgstr "" #: src/libgpaste/ui/gpaste-ui-switch.c:54 msgid "Stop" msgstr "" #: src/libgpaste/ui/gpaste-ui-switch.c:54 #, 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:49 msgid "Upload" msgstr "" #: src/libgpaste/util/gpaste-util.c:338 msgid "Do you really want to empty the history?" msgstr "" #: src/libgpaste/util/gpaste-util.c:617 msgid "Could not create history dir" msgstr "No se pudo crear directorio de historial" #: src/client/gpaste-client.c:138 src/client/gpaste-client.c:428 #, fuzzy msgid "Couldn't spawn" msgstr "No se pudo iniciar el applet de gpaste.\n" #: src/client/gpaste-client.c:156 #, c-format msgid "Usage:\n" msgstr "Modo de empleo:\n" #. Translators: help for gpaste history #: src/client/gpaste-client.c:158 msgid "print the history with indexes" msgstr "imprimir el historial con números de indice" #. Translators: help for gpaste history-size #: src/client/gpaste-client.c:160 #, fuzzy msgid "print the size of the history" msgstr "suprimir el elemento número del historial" #. Translators: help for gpaste get-history #: src/client/gpaste-client.c:162 #, 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/client/gpaste-client.c:164 src/client/gpaste-client.c:166 #: src/client/gpaste-client.c:168 src/client/gpaste-client.c:174 #: src/client/gpaste-client.c:186 src/client/gpaste-client.c:190 msgid "name" msgstr "nombre" #: src/client/gpaste-client.c:164 msgid "backup current history" msgstr "hacer copia de seguridad del historial actual" #: src/client/gpaste-client.c:166 msgid "switch to another history" msgstr "cambiar a otro historial" #: src/client/gpaste-client.c:168 msgid "delete a history" msgstr "suprimir el historial" #. Translators: help for gpaste list-histories #: src/client/gpaste-client.c:170 msgid "list available histories" msgstr "listar historial disponible" #. Translators: help for gpaste add #: src/client/gpaste-client.c:172 msgid "text" msgstr "texto" #: src/client/gpaste-client.c:172 msgid "set text to clipboard" msgstr "enviar al portapapeles" #: src/client/gpaste-client.c:174 msgid "password" msgstr "" #: src/client/gpaste-client.c:174 #, 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/client/gpaste-client.c:176 #, fuzzy msgid "old name" msgstr "nombre" #: src/client/gpaste-client.c:176 #, fuzzy msgid "new name" msgstr "nombre" #: src/client/gpaste-client.c:176 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/client/gpaste-client.c:178 src/client/gpaste-client.c:180 #: src/client/gpaste-client.c:182 src/client/gpaste-client.c:184 #: src/client/gpaste-client.c:186 src/client/gpaste-client.c:188 #: src/client/gpaste-client.c:212 msgid "number" msgstr "número" #: src/client/gpaste-client.c:178 msgid "get the th item from the history" msgstr "obtener el elemento número del historial del portapapeles" #: src/client/gpaste-client.c:180 msgid "set the th item from the history to the clipboard" msgstr "enviar el elemento número del historial al portapapeles" #: src/client/gpaste-client.c:182 msgid "contents" msgstr "" #: src/client/gpaste-client.c:182 #, 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/client/gpaste-client.c:184 #, 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/client/gpaste-client.c:186 #, fuzzy msgid "set the th item from the history as a password named " msgstr "enviar el elemento número del historial al portapapeles" #: src/client/gpaste-client.c:188 msgid "delete th item of the history" msgstr "suprimir el elemento número del historial" #: src/client/gpaste-client.c:190 #, fuzzy msgid "delete the password from the history" msgstr "obtener el elemento número del historial del portapapeles" #. Translators: help for gpaste file #: src/client/gpaste-client.c:192 msgid "path" msgstr "ruta" #: src/client/gpaste-client.c:192 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/client/gpaste-client.c:194 msgid "whatever" msgstr "loquesea" #: src/client/gpaste-client.c:194 msgid "set the output of whatever to clipboard" msgstr "enviar la salida de al portapapeles" #. Translators: help for gpaste empty #: src/client/gpaste-client.c:196 msgid "empty the history" msgstr "vaciar el historial" #. Translators: help for gpaste start #: src/client/gpaste-client.c:198 msgid "start tracking clipboard changes" msgstr "iniciar seguimiento de cambios en el portapapeles" #. Translators: help for gpaste stop #: src/client/gpaste-client.c:200 msgid "stop tracking clipboard changes" msgstr "detener seguimiento de cambios en el portapapeles" #. Translators: help for gpaste quit #: src/client/gpaste-client.c:202 msgid "alias for stop" msgstr "quit: alias de stop" #. Translators: help for gpaste daemon-reexec #: src/client/gpaste-client.c:204 msgid "reexecute the daemon (after upgrading...)" msgstr "vuelva a ejecutar el servicio (después de actualizar...)" #. Translators: help for gpaste settings #: src/client/gpaste-client.c:206 msgid "launch the configuration tool" msgstr "iniciar la herramienta de configuración" #. Translators: help for gpaste ui #: src/client/gpaste-client.c:208 #, fuzzy msgid "launch the graphical tool" msgstr "iniciar la herramienta de configuración" #. Translators: help for gpaste show-history #: src/client/gpaste-client.c:210 #, fuzzy msgid "make the applet or extension display the history" msgstr "Número máximo de elementos mostrados en el historial" #: src/client/gpaste-client.c:212 #, fuzzy msgid "upload the th item to a pastebin service" msgstr "Eliminar el primer elemento del historial" #. Translators: help for gpaste version #: src/client/gpaste-client.c:214 msgid "display the version" msgstr "mostrar la versión" #. Translators: help for gpaste daemon-version #: src/client/gpaste-client.c:216 #, fuzzy msgid "display the daemon version" msgstr "mostrar la versión" #. Translators: help for gpaste help #: src/client/gpaste-client.c:218 msgid "display this help" msgstr "mostrar esta ayuda" #. Translators: help for gpaste about #: src/client/gpaste-client.c:220 #, fuzzy msgid "display the about dialog" msgstr "mostrar la versión" #: src/client/gpaste-client.c:223 #, fuzzy, c-format msgid "Display options:" msgstr "Mostrar el historial" #. Translators: help for --oneline #: src/client/gpaste-client.c:226 #, fuzzy msgid "display each item on only one line" msgstr "mostrar la versión" #. Translators: help for --raw #: src/client/gpaste-client.c:228 msgid "display each item raw (without line numbers)" msgstr "" #. Translators: help for --reverse #: src/client/gpaste-client.c:230 #, fuzzy msgid "display the items in reverse order" msgstr "mostrar la versión" #. Translators: help for --zero #: src/client/gpaste-client.c:232 msgid "use a NUL character instead of a new line betweean each item" msgstr "" #: src/client/gpaste-client.c:235 #, fuzzy, c-format msgid "Merge options:" msgstr "Mostrar el historial" #. Translators: help for --decoration #. Translators: help for --separator #: src/client/gpaste-client.c:238 src/client/gpaste-client.c:240 msgid "string" msgstr "" #: src/client/gpaste-client.c:238 msgid "" "add the given decoration to the beginning and the end of each item before " "merging" msgstr "" #: src/client/gpaste-client.c:240 msgid "add the given separator between each item when merging" msgstr "" #: src/client/gpaste-client.c:333 #, c-format msgid "Successfully reexecuted the daemon\n" msgstr "Servicio reiniciado con éxito\n" #: src/client/gpaste-client.c:482 msgid "Cannot add non utf8 data as text." msgstr "" #: src/daemon/gpaste-daemon.c:33 #, fuzzy msgid "Stop signal received, exiting" msgstr "Recibida señal %d, saliendo\n" #: src/daemon/gpaste-daemon.c:70 msgid "Could not acquire DBus name." msgstr "No se pudo obtener nombre en DBus" #: src/ui/gpaste-ui.c:106 #, fuzzy msgid "Keyboard Shortcuts" msgstr "Atajos de teclado " #: src/ui/gpaste-ui.c:107 msgid "About GPaste" msgstr "" #: src/ui/gpaste-ui.c:108 msgid "Quit" msgstr "Salir" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:5 #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:4 #, fuzzy msgid "GPaste" msgstr "Applet GPaste" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:6 #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:5 msgid "Manage your clipboard history" msgstr "" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:7 msgid "Marc-Antoine Perennou" msgstr "" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:12 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.Ui.appdata.xml.in:15 msgid "" "GPaste provides you with a graphical tool allowing you to manage everything " "easily." msgstr "" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:22 msgid "The main UI" msgstr "" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:26 #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:30 #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:34 #, fuzzy msgid "The settings UI" msgstr "Ajustes del servicio GPaste" #: data/control-center/42-gpaste.control-center.xml.in:2 msgid "@GETTEXT_PACKAGE@" msgstr "" #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:6 msgid "Clipboard;Manager;Settings;Preferences;Configuration;" msgstr "" #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:7 msgid "edit-paste" msgstr "" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:7 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.in:8 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.in:15 msgid "Do we detect and replace growing lines in history?" msgstr "" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:16 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.in:24 msgid "The name of the current history" msgstr "El nombre del historial actual" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:25 msgid "The default name is \"history\"" msgstr "El nombre por omision es \"history\"" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:32 msgid "Do we save the images copied to history, or only text?" msgstr "" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:33 msgid "By default, we're saving both" msgstr "" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:40 #, fuzzy msgid "Do we close the UI after selecting an item?" msgstr "¿Afecta la selección principal al historial?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:41 #, fuzzy msgid "By default, we close it" msgstr "Por omisión se guarda" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:48 #, 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.in:49 #, fuzzy msgid "" "By default, hitting ctrl + alt + g does that (\"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.in:57 #, 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.in:58 #, fuzzy msgid "" "By default, hitting ctrl + alt + s will mark the active item as being a " "password (\"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.in:68 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.in:77 msgid "Maximum number of items in history" msgstr "Número máximo de elementos en el historial" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:86 msgid "Maximum amount of memory used to store contents" msgstr "" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:94 msgid "Max text item size" msgstr "Tamaño máximo de los elementos de texto" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:95 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.in:103 msgid "Min text item size" msgstr "Tamaño mínimo de los elementos de texto" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:104 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.in:111 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.in:112 #, fuzzy msgid "" "By default, hitting ctrl + alt + v does that (\"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.in:120 msgid "Does the primary selection affects history?" msgstr "¿Afecta la selección principal al historial?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:121 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.in:128 msgid "" "Do we save all versions of selected rich text (e.g. html) or just the plain " "text version?" msgstr "" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:129 #, fuzzy msgid "By default, we're saving all" msgstr "Por omisión se guarda" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:136 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.in:137 msgid "By default, we're saving it" msgstr "Por omisión se guarda" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:144 msgid "The keyboard shortcut to display the menu" msgstr "Atajo de teclado para mostrar el menú" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:145 #, fuzzy msgid "" "By default, hitting ctrl + alt + h displays the menu (\"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.in:153 msgid "The keyboard shortcut to sync the clipboard to the primary selection" msgstr "" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:154 #, fuzzy msgid "" "By default, hitting ctrl + alt + o syncs them (\"P\"). 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.in:162 msgid "The keyboard shortcut to sync the primary selection to the clipboard" msgstr "" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:163 #, fuzzy msgid "" "By default, hitting ctrl + alt + p syncs them (\"P\"). 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.in:171 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.in:172 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.in:179 msgid "Do we track the clipboard changes?" msgstr "¿Seguir los cambios en el portapapeles?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:180 msgid "By default, we're tracking those changes." msgstr "Por omisión, se siguen esos cambios." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:187 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.in:188 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.in:195 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.in:196 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.in:204 #, 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.in:205 #, fuzzy msgid "" "By default, hitting ctrl + alt + u does that (\"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 "launch the applet" #~ msgstr "iniciar el applet" #, fuzzy #~ msgid "launch the unity application indicator" #~ msgstr "iniciar la herramienta de configuración" #~ msgid "GPaste Applet" #~ msgstr "Applet GPaste" #~ msgid "Tray icon to manage GPaste" #~ msgstr "Icono de notificación para GPaste" #, fuzzy #~ msgid "GPaste AppIndicator" #~ msgstr "Applet GPaste" #, fuzzy #~ msgid "Unity application indicator to manage GPaste" #~ msgstr "Icono de notificación para GPaste" #, fuzzy #~ msgid "The AppIndicator menu" #~ msgstr "Applet GPaste" #~ msgid "Max displayed history size: " #~ msgstr "Tamaño máximo a mostrar: " #~ msgid "Max history size: " #~ msgstr "Tamaño máximo del historial: " #~ 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.28.0/po/fr.po000066400000000000000000000740071325205405000144600ustar00rootroot00000000000000# French translations for GPaste package. # Copyright (C) 2010-2018 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: 2018-03-13 14:55+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:98 msgid "Failed to register the gtk application" msgstr "Impossible d'inscrire l'application gtk au registre" #: src/libgpaste/gpaste-macros.h:110 msgid "is already running." msgstr "tourne déjà." #. This is the date format "month/day/year time" #: src/libgpaste/core/gpaste-image-item.c:222 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:224 #, 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:67 msgid "Password" msgstr "Mot de passe" #. This is the prefix displayed in history to identify selected files #: src/libgpaste/core/gpaste-uris-item.c:104 msgid "[Files] " msgstr "[Fichiers] " #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:117 #: src/libgpaste/ui/gpaste-ui-switch.c:92 msgid "Track clipboard changes" msgstr "Suivre les changements du presse-papier" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:123 msgid "Close UI on select" msgstr "Fermer l'interface à la selection" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:132 msgid "Enable the gnome-shell extension" msgstr "Activer l'extension gnome-shell" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:138 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 #: data/gsettings/org.gnome.GPaste.gschema.xml.in:67 msgid "Max displayed history size" msgstr "Taille maximale de l'historique affiché" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:216 #: data/gsettings/org.gnome.GPaste.gschema.xml.in:76 msgid "Max history size" msgstr "Taille maximale de l'historique" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:223 #: data/gsettings/org.gnome.GPaste.gschema.xml.in:85 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 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:72 #: data/control-center/42-gpaste.control-center.xml.in:5 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 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:73 #: data/control-center/42-gpaste.control-center.xml.in:3 msgid "Launch the graphical tool" msgstr "Lancer l'interface graphique" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:277 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:74 #: data/control-center/42-gpaste.control-center.xml.in:4 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 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:75 #: data/control-center/42-gpaste.control-center.xml.in:6 msgid "Display the history" msgstr "Afficher l'historique" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:291 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:76 #: data/control-center/42-gpaste.control-center.xml.in:7 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 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:77 #: data/control-center/42-gpaste.control-center.xml.in:8 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 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:78 #: data/control-center/42-gpaste.control-center.xml.in:9 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:310 src/client/gpaste-client.c:804 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:335 msgid "General behaviour" msgstr "Comportement général" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:336 msgid "History settings" msgstr "Préférences de l'historique" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:337 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:454 #: 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:459 #: src/libgpaste/ui/gpaste-ui-delete-item.c:49 #: src/libgpaste/ui/gpaste-ui-delete-history.c:24 #: src/libgpaste/ui/gpaste-ui-delete-history.c:61 msgid "Delete" msgstr "Supprimer" #: src/libgpaste/ui/gpaste-ui-about.c:41 msgid "About" msgstr "À propos" #: src/libgpaste/ui/gpaste-ui-backup-history.c:43 #: src/libgpaste/ui/gpaste-ui-backup-history.c:136 msgid "Backup" msgstr "Copier" #: src/libgpaste/ui/gpaste-ui-backup-history.c:44 #: src/libgpaste/ui/gpaste-ui-edit-item.c:45 #: src/libgpaste/ui/gpaste-ui-new-item.c:32 src/libgpaste/util/gpaste-util.c:30 msgid "Cancel" msgstr "Annuler" #: src/libgpaste/ui/gpaste-ui-backup-history.c:47 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:24 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:44 #: src/libgpaste/ui/gpaste-ui-edit-item.c:117 msgid "Edit" msgstr "Modifier" #. Translators: this is the translation for emptying the history #: src/libgpaste/ui/gpaste-ui-empty-history.c:61 #: src/libgpaste/util/gpaste-util.c:338 msgid "Empty" msgstr "Vider" #: src/libgpaste/ui/gpaste-ui-empty-item.c:35 msgid "(No result)" msgstr "(Aucun résultat)" #: src/libgpaste/ui/gpaste-ui-empty-item.c:49 msgid "(Empty)" msgstr "(Vide)" #: src/libgpaste/ui/gpaste-ui-empty-item.c:60 msgid "(Couldn't connect to GPaste daemon)" msgstr "(Impossible de se connecter au démon GPaste)" #: src/libgpaste/ui/gpaste-ui-new-item.c:31 #: src/libgpaste/ui/gpaste-ui-new-item.c:83 msgid "New" msgstr "Nouveau" #: src/libgpaste/ui/gpaste-ui-reexec.c:29 msgid "Restart" msgstr "Redémarer" #: src/libgpaste/ui/gpaste-ui-reexec.c:29 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:55 msgid "Restart the daemon" msgstr "Redémarer le démon" #: src/libgpaste/ui/gpaste-ui-search.c:26 msgid "Search" msgstr "Recherche" #: src/libgpaste/ui/gpaste-ui-settings.c:32 src/ui/gpaste-ui.c:105 msgid "GPaste Settings" msgstr "Préférences du démon GPaste" #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:64 msgid "General" msgstr "Général" #: src/libgpaste/ui/gpaste-ui-switch.c:54 msgid "Stop" msgstr "Arrêter" #: src/libgpaste/ui/gpaste-ui-switch.c:54 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:49 msgid "Upload" msgstr "Publier" #: src/libgpaste/util/gpaste-util.c:338 msgid "Do you really want to empty the history?" msgstr "Voulez-vous vraiment vider l'historique ?" #: src/libgpaste/util/gpaste-util.c:617 msgid "Could not create history dir" msgstr "Impossible de créer le dossier d'historique" #: src/client/gpaste-client.c:138 src/client/gpaste-client.c:428 msgid "Couldn't spawn" msgstr "Impossible de lancer" #: src/client/gpaste-client.c:156 #, c-format msgid "Usage:\n" msgstr "Mode d'emploi :\n" #. Translators: help for gpaste history #: src/client/gpaste-client.c:158 msgid "print the history with indexes" msgstr "affiche l'historique avec les indices" #. Translators: help for gpaste history-size #: src/client/gpaste-client.c:160 msgid "print the size of the history" msgstr "affiche la taille de l'historique" #. Translators: help for gpaste get-history #: src/client/gpaste-client.c:162 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/client/gpaste-client.c:164 src/client/gpaste-client.c:166 #: src/client/gpaste-client.c:168 src/client/gpaste-client.c:174 #: src/client/gpaste-client.c:186 src/client/gpaste-client.c:190 msgid "name" msgstr "nom" #: src/client/gpaste-client.c:164 msgid "backup current history" msgstr "sauvegarde l'historique actuel" #: src/client/gpaste-client.c:166 msgid "switch to another history" msgstr "passer à un autre historique" #: src/client/gpaste-client.c:168 msgid "delete a history" msgstr "supprime un historique" #. Translators: help for gpaste list-histories #: src/client/gpaste-client.c:170 msgid "list available histories" msgstr "liste les historiques disponibles" #. Translators: help for gpaste add #: src/client/gpaste-client.c:172 msgid "text" msgstr "texte" #: src/client/gpaste-client.c:172 msgid "set text to clipboard" msgstr "met le texte dans le presse-papier" #: src/client/gpaste-client.c:174 msgid "password" msgstr "mot de passe" #: src/client/gpaste-client.c:174 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/client/gpaste-client.c:176 msgid "old name" msgstr "ancien nom" #: src/client/gpaste-client.c:176 msgid "new name" msgstr "nouveau nom" #: src/client/gpaste-client.c:176 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/client/gpaste-client.c:178 src/client/gpaste-client.c:180 #: src/client/gpaste-client.c:182 src/client/gpaste-client.c:184 #: src/client/gpaste-client.c:186 src/client/gpaste-client.c:188 #: src/client/gpaste-client.c:212 msgid "number" msgstr "nombre" #: src/client/gpaste-client.c:178 msgid "get the th item from the history" msgstr "renvoie le e élément de l'historique" #: src/client/gpaste-client.c:180 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/client/gpaste-client.c:182 msgid "contents" msgstr "contenu" #: src/client/gpaste-client.c:182 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/client/gpaste-client.c:184 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/client/gpaste-client.c:186 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/client/gpaste-client.c:188 msgid "delete th item of the history" msgstr "supprime le e élément de l'historique" #: src/client/gpaste-client.c:190 msgid "delete the password from the history" msgstr "supprime le mot de passe nommé de l'historique" #. Translators: help for gpaste file #: src/client/gpaste-client.c:192 msgid "path" msgstr "chemin" #: src/client/gpaste-client.c:192 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/client/gpaste-client.c:194 msgid "whatever" msgstr "quelquechose" #: src/client/gpaste-client.c:194 msgid "set the output of whatever to clipboard" msgstr "met la sortie de quelquechose dans le presse-papier" #. Translators: help for gpaste empty #: src/client/gpaste-client.c:196 msgid "empty the history" msgstr "vide l'historique" #. Translators: help for gpaste start #: src/client/gpaste-client.c:198 msgid "start tracking clipboard changes" msgstr "suivre les changements du presse-papier" #. Translators: help for gpaste stop #: src/client/gpaste-client.c:200 msgid "stop tracking clipboard changes" msgstr "arrêter de suivre les changements du presse-papier" #. Translators: help for gpaste quit #: src/client/gpaste-client.c:202 msgid "alias for stop" msgstr "alias pour stop" #. Translators: help for gpaste daemon-reexec #: src/client/gpaste-client.c:204 msgid "reexecute the daemon (after upgrading...)" msgstr "reexecuter le démon (après une mise à jour...)" #. Translators: help for gpaste settings #: src/client/gpaste-client.c:206 msgid "launch the configuration tool" msgstr "lance l'outil de configuration" #. Translators: help for gpaste ui #: src/client/gpaste-client.c:208 msgid "launch the graphical tool" msgstr "lance l'interface graphique" #. Translators: help for gpaste show-history #: src/client/gpaste-client.c:210 msgid "make the applet or extension display the history" msgstr "forcer l'applet ou l'extension à afficher l'historique" #: src/client/gpaste-client.c:212 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/client/gpaste-client.c:214 msgid "display the version" msgstr "affiche la version" #. Translators: help for gpaste daemon-version #: src/client/gpaste-client.c:216 msgid "display the daemon version" msgstr "affiche la version du démon" #. Translators: help for gpaste help #: src/client/gpaste-client.c:218 msgid "display this help" msgstr "affiche cette aide" #. Translators: help for gpaste about #: src/client/gpaste-client.c:220 msgid "display the about dialog" msgstr "affiche le dialogue d'à propos" #: src/client/gpaste-client.c:223 #, c-format msgid "Display options:" msgstr "Options d'affichage : " #. Translators: help for --oneline #: src/client/gpaste-client.c:226 msgid "display each item on only one line" msgstr "affiche chaque élément sur seulement une ligne" #. Translators: help for --raw #: src/client/gpaste-client.c:228 msgid "display each item raw (without line numbers)" msgstr "affiche chaque élément brut (sans numéro de ligne)" #. Translators: help for --reverse #: src/client/gpaste-client.c:230 msgid "display the items in reverse order" msgstr "affiche les éléments dans l'ordre inverse" #. Translators: help for --zero #: src/client/gpaste-client.c:232 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/client/gpaste-client.c:235 #, c-format msgid "Merge options:" msgstr "Options de fusion : " #. Translators: help for --decoration #. Translators: help for --separator #: src/client/gpaste-client.c:238 src/client/gpaste-client.c:240 msgid "string" msgstr "chaîne" #: src/client/gpaste-client.c:238 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/client/gpaste-client.c:240 msgid "add the given separator between each item when merging" msgstr "ajoute le séparateur entre chaque élément à la fusion" #: src/client/gpaste-client.c:333 #, c-format msgid "Successfully reexecuted the daemon\n" msgstr "Démon redémaré avec succès\n" #: src/client/gpaste-client.c:482 msgid "Cannot add non utf8 data as text." msgstr "Impossible d'ajouter de la donnée non unicode en tant que texte." #: src/daemon/gpaste-daemon.c:33 msgid "Stop signal received, exiting" msgstr "Signal d'arrêt reçu" #: src/daemon/gpaste-daemon.c:70 msgid "Could not acquire DBus name." msgstr "Impossible d'acquérir le nom DBus." #: src/ui/gpaste-ui.c:106 msgid "Keyboard Shortcuts" msgstr "Raccourcis clavier" #: src/ui/gpaste-ui.c:107 msgid "About GPaste" msgstr "À propos de GPaste" #: src/ui/gpaste-ui.c:108 msgid "Quit" msgstr "Quitter" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:5 #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:4 msgid "GPaste" msgstr "GPaste" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:6 #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:5 msgid "Manage your clipboard history" msgstr "Gérez l'historique de votre presse-papier" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:7 msgid "Marc-Antoine Perennou" msgstr "Marc-Antoine Perennou" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:12 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.Ui.appdata.xml.in:15 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/appstream/org.gnome.GPaste.Ui.appdata.xml.in:22 msgid "The main UI" msgstr "L'interface principale" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:26 #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:30 #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:34 msgid "The settings UI" msgstr "L'interface de préférences" #: data/control-center/42-gpaste.control-center.xml.in:2 msgid "@GETTEXT_PACKAGE@" msgstr "@GETTEXT_PACKAGE@" #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:6 msgid "Clipboard;Manager;Settings;Preferences;Configuration;" msgstr "Presse-Papier;Gestionnaire;Réglages;Préférences;Configuration;" #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:7 msgid "edit-paste" msgstr "edit-paste" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:7 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.in:8 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.in:15 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.in:16 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.in:24 msgid "The name of the current history" msgstr "Le nom de l'historique actuel" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:25 msgid "The default name is \"history\"" msgstr "Le nom par défaut est \"history\"" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:32 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.in:33 msgid "By default, we're saving both" msgstr "Par défaut, on sauvegarde les deux." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:40 msgid "Do we close the UI after selecting an item?" msgstr "Ferme-t-on l'interface après avoir sélectionné un élément ?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:41 msgid "By default, we close it" msgstr "Par défaut, on la ferme" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:48 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.in:49 msgid "" "By default, hitting ctrl + alt + g does that (\"G\"). An empty " "string here disables this functionnality." msgstr "" "Par défaut, appuyer sur ctrl + alt + g le fait (\"G\"). Une " "chaîne vide désactive cette fonctionnalité." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:57 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.in:58 msgid "" "By default, hitting ctrl + alt + s will mark the active item as being a " "password (\"S\"). An empty string here disables this " "functionnality." msgstr "" "Par défaut, appuyer sur ctrl + alt + s affiche le menu (\"S\"). " "Une chaîne vide désactive cette fonctionnalité." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:68 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.in:77 msgid "Maximum number of items in history" msgstr "Nombre maximum d'éléments dans l'historique" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:86 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.in:94 msgid "Max text item size" msgstr "Taille maximale d'un élément textuel" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:95 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.in:103 msgid "Min text item size" msgstr "Taille minimale d'un élément textuel" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:104 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.in:111 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.in:112 msgid "" "By default, hitting ctrl + alt + v does that (\"V\"). An empty " "string here disables this functionnality." msgstr "" "Par défaut, appuyer sur ctrl + alt + v le fait (\"V\"). Une " "chaîne vide désactive cette fonctionnalité." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:120 msgid "Does the primary selection affects history?" msgstr "La selection primaire doit-elle affecter l'historique?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:121 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.in:128 msgid "" "Do we save all versions of selected rich text (e.g. html) or just the plain " "text version?" msgstr "" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:129 #, fuzzy msgid "By default, we're saving all" msgstr "Par défaut, on le sauvegarde." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:136 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.in:137 msgid "By default, we're saving it" msgstr "Par défaut, on le sauvegarde." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:144 msgid "The keyboard shortcut to display the menu" msgstr "Le raccourcis clavier pour afficher l'historique" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:145 msgid "" "By default, hitting ctrl + alt + h displays the menu (\"H\"). An " "empty string here disables this functionnality." msgstr "" "Par défaut, appuyer sur ctrl + alt + h affiche le menu (\"H\"). " "Une chaîne vide désactive cette fonctionnalité." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:153 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.in:154 msgid "" "By default, hitting ctrl + alt + o syncs them (\"P\"). An empty " "string here disables this functionnality." msgstr "" "Par défaut, appuyer sur ctrl + alt + o les synchronise (\"O\"). " "Une chaîne vide désactive cette fonctionnalité." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:162 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.in:163 msgid "" "By default, hitting ctrl + alt + p syncs them (\"P\"). An empty " "string here disables this functionnality." msgstr "" "Par défaut, appuyer sur ctrl + alt + p les synchronise (\"P\"). " "Une chaîne vide désactive cette fonctionnalité." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:171 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.in:172 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.in:179 msgid "Do we track the clipboard changes?" msgstr "Suit-on les changements du presse-papier?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:180 msgid "By default, we're tracking those changes." msgstr "Par défaut, on suit ces changements." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:187 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.in:188 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.in:195 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.in:196 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.in:204 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.in:205 msgid "" "By default, hitting ctrl + alt + u does that (\"U\"). An empty " "string here disables this functionnality." msgstr "" "Par défaut, appuyer sur ctrl + alt + u le fait (\"U\"). Une " "chaîne vide désactive cette fonctionnalité." gpaste-3.28.0/po/nl_NL.po000066400000000000000000001003671325205405000150520ustar00rootroot00000000000000# Dutch translations for GPaste package. # Copyright (C) 2013-2015 Listed translators # This file is distributed under the same license as the GPaste package. # Heimen Stoffels , 2017. # msgid "" msgstr "" "Project-Id-Version: GPaste\n" "Report-Msgid-Bugs-To: Marc-Antoine@Perennou.com\n" "POT-Creation-Date: 2018-03-13 14:55+0100\n" "PO-Revision-Date: 2017-03-17 17:38+0100\n" "Last-Translator: Heimen Stoffels \n" "Language-Team: Vistaus \n" "Language: nl_NL\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.8.11\n" #: src/libgpaste/gpaste-macros.h:98 msgid "Failed to register the gtk application" msgstr "Het registreren van de GTK-applicatie is mislukt" #: src/libgpaste/gpaste-macros.h:110 msgid "is already running." msgstr "draait al." #. This is the date format "month/day/year time" #: src/libgpaste/core/gpaste-image-item.c:222 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:224 #, c-format msgid "[Image, %d x %d (%s)]" msgstr "[Afbeelding, %d x %d (%s)]" #. This is the prefix displayed in history to identify a password #: src/libgpaste/core/gpaste-password-item.c:67 msgid "Password" msgstr "Wachtwoord" #. This is the prefix displayed in history to identify selected files #: src/libgpaste/core/gpaste-uris-item.c:104 msgid "[Files] " msgstr "[Bestanden]" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:117 #: src/libgpaste/ui/gpaste-ui-switch.c:92 msgid "Track clipboard changes" msgstr "Klembordwijzigingen bijhouden" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:123 msgid "Close UI on select" msgstr "Venster sluiten na selecteren" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:132 msgid "Enable the gnome-shell extension" msgstr "GNOME Shell-extensie inschakelen" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:138 msgid "Sync the daemon state with the extension's one" msgstr "Daemon-staat synchroniseren met die van de uitbreiding" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:147 msgid "Primary selection affects history" msgstr "Primaire selectie beïnvloedt geschiedenis" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:153 msgid "Synchronize clipboard with primary selection" msgstr "Klembord synchroniseren met primaire selectie" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:160 msgid "Images support" msgstr "Afbeeldingsondersteuning" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:166 msgid "Trim items" msgstr "Items trimmen" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:172 msgid "Detect growing lines" msgstr "Groeiende regels detecteren" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:179 msgid "Save history" msgstr "Geschiedenis opslaan" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:202 msgid "Max element size when displaying" msgstr "Maximale elementgrootte tijdens weergave" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:209 #: data/gsettings/org.gnome.GPaste.gschema.xml.in:67 msgid "Max displayed history size" msgstr "Maximaal weergegeven geschiedenisgrootte" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:216 #: data/gsettings/org.gnome.GPaste.gschema.xml.in:76 msgid "Max history size" msgstr "Maximale geschiedenisgrootte" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:223 #: data/gsettings/org.gnome.GPaste.gschema.xml.in:85 msgid "Max memory usage (MB)" msgstr "Maximaal geheugengebruik (MB)" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:230 msgid "Max text item length" msgstr "Maximale tekstitemlengte:" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:237 msgid "Min text item length" msgstr "Minimale tekstitemlengte:" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:263 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:72 #: data/control-center/42-gpaste.control-center.xml.in:5 msgid "Delete the active item from history" msgstr "Actief item verwijderen uit geschiedenis" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:270 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:73 #: data/control-center/42-gpaste.control-center.xml.in:3 msgid "Launch the graphical tool" msgstr "Grafisch venster openen" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:277 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:74 #: data/control-center/42-gpaste.control-center.xml.in:4 msgid "Mark the active item as being a password" msgstr "Actief item markeren als wachtwoord" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:284 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:75 #: data/control-center/42-gpaste.control-center.xml.in:6 msgid "Display the history" msgstr "Geschiedenis weergeven" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:291 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:76 #: data/control-center/42-gpaste.control-center.xml.in:7 msgid "Sync the clipboard to the primary selection" msgstr "Klembord synchroniseren met primaire selectie" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:298 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:77 #: data/control-center/42-gpaste.control-center.xml.in:8 msgid "Sync the primary selection to the clipboard" msgstr "Primaire selectie synchroniseren met klembord" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:305 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:78 #: data/control-center/42-gpaste.control-center.xml.in:9 msgid "Upload the active item to a pastebin service" msgstr "Actief item uploaden naar een pastebin-dienst" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:320 #: src/libgpaste/ui/gpaste-ui-window.c:310 src/client/gpaste-client.c:804 msgid "Couldn't connect to GPaste daemon" msgstr "Het verbinden met de GPaste-daemon is mislukt" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:335 msgid "General behaviour" msgstr "Algemeen" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:336 msgid "History settings" msgstr "Geschiedenis-instellingen" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:337 msgid "Keyboard shortcuts" msgstr "Sneltoetsen" #. translators: This is the name of a multi-history management action #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:454 #: src/libgpaste/ui/gpaste-ui-panel.c:297 msgid "Switch to" msgstr "Overschakelen naar" #. translators: This is the name of a multi-history management action #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:459 #: src/libgpaste/ui/gpaste-ui-delete-item.c:49 #: src/libgpaste/ui/gpaste-ui-delete-history.c:24 #: src/libgpaste/ui/gpaste-ui-delete-history.c:61 msgid "Delete" msgstr "Verwijderen" #: src/libgpaste/ui/gpaste-ui-about.c:41 msgid "About" msgstr "Over" #: src/libgpaste/ui/gpaste-ui-backup-history.c:43 #: src/libgpaste/ui/gpaste-ui-backup-history.c:136 msgid "Backup" msgstr "Back-uppen" #: src/libgpaste/ui/gpaste-ui-backup-history.c:44 #: src/libgpaste/ui/gpaste-ui-edit-item.c:45 #: src/libgpaste/ui/gpaste-ui-new-item.c:32 src/libgpaste/util/gpaste-util.c:30 msgid "Cancel" msgstr "Annuleren" #: src/libgpaste/ui/gpaste-ui-backup-history.c:47 msgid "Under which name do you want to backup this history?" msgstr "Onder welke naam wilt u de geschiedenis opslaan?" #: src/libgpaste/ui/gpaste-ui-delete-history.c:24 msgid "Are you sure you want to delete this history?" msgstr "Weet u zeker dat u de geschiedenis wilt verwijderen?" #: src/libgpaste/ui/gpaste-ui-edit-item.c:44 #: src/libgpaste/ui/gpaste-ui-edit-item.c:117 msgid "Edit" msgstr "Bewerken" #. Translators: this is the translation for emptying the history #: src/libgpaste/ui/gpaste-ui-empty-history.c:61 #: src/libgpaste/util/gpaste-util.c:338 msgid "Empty" msgstr "Legen" #: src/libgpaste/ui/gpaste-ui-empty-item.c:35 msgid "(No result)" msgstr "(Geen resultaat)" #: src/libgpaste/ui/gpaste-ui-empty-item.c:49 msgid "(Empty)" msgstr "(Leeg)" #: src/libgpaste/ui/gpaste-ui-empty-item.c:60 msgid "(Couldn't connect to GPaste daemon)" msgstr "(Het verbinden met de GPaste-daemon is mislukt)" #: src/libgpaste/ui/gpaste-ui-new-item.c:31 #: src/libgpaste/ui/gpaste-ui-new-item.c:83 msgid "New" msgstr "Nieuw" #: src/libgpaste/ui/gpaste-ui-reexec.c:29 msgid "Restart" msgstr "Herstarten" #: src/libgpaste/ui/gpaste-ui-reexec.c:29 msgid "Do you really want to restart the daemon?" msgstr "Weet u zeker dat u de daemon wilt herstarten?" #: src/libgpaste/ui/gpaste-ui-reexec.c:55 msgid "Restart the daemon" msgstr "Daemon herstarten" #: src/libgpaste/ui/gpaste-ui-search.c:26 msgid "Search" msgstr "Zoeken" #: src/libgpaste/ui/gpaste-ui-settings.c:32 src/ui/gpaste-ui.c:105 msgid "GPaste Settings" msgstr "GPaste-instellingen" #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:64 msgid "General" msgstr "Algemeen" #: src/libgpaste/ui/gpaste-ui-switch.c:54 msgid "Stop" msgstr "Stoppen" #: src/libgpaste/ui/gpaste-ui-switch.c:54 msgid "Do you really want to stop tracking clipboard changes?" msgstr "Weet u zeker dat u het bijhouden van klembordwijzigingen wilt stoppen?" #: src/libgpaste/ui/gpaste-ui-upload-item.c:49 msgid "Upload" msgstr "Uploaden" #: src/libgpaste/util/gpaste-util.c:338 msgid "Do you really want to empty the history?" msgstr "Weet u zeker dat u de geschiedenis wilt legen?" #: src/libgpaste/util/gpaste-util.c:617 msgid "Could not create history dir" msgstr "Het creëren van de geschiedenismap is mislukt" #: src/client/gpaste-client.c:138 src/client/gpaste-client.c:428 msgid "Couldn't spawn" msgstr "Het oproepen is mislukt" #: src/client/gpaste-client.c:156 #, c-format msgid "Usage:\n" msgstr "Gebruik:\n" #. Translators: help for gpaste history #: src/client/gpaste-client.c:158 msgid "print the history with indexes" msgstr "geschiedenis met indexen weergeven" #. Translators: help for gpaste history-size #: src/client/gpaste-client.c:160 msgid "print the size of the history" msgstr "geschiedenisgrootte weergeven" #. Translators: help for gpaste get-history #: src/client/gpaste-client.c:162 msgid "get the name of the current history" msgstr "naam verkrijgen van de huidige geschiedenis" #. 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/client/gpaste-client.c:164 src/client/gpaste-client.c:166 #: src/client/gpaste-client.c:168 src/client/gpaste-client.c:174 #: src/client/gpaste-client.c:186 src/client/gpaste-client.c:190 msgid "name" msgstr "naam" #: src/client/gpaste-client.c:164 msgid "backup current history" msgstr "huidige geschiedenis back-uppen" #: src/client/gpaste-client.c:166 msgid "switch to another history" msgstr "overschakelen naar andere geschiedenis" #: src/client/gpaste-client.c:168 msgid "delete a history" msgstr "een geschiedenis verwijderen" #. Translators: help for gpaste list-histories #: src/client/gpaste-client.c:170 msgid "list available histories" msgstr "beschikbare geschiedenissen opsommen" #. Translators: help for gpaste add #: src/client/gpaste-client.c:172 msgid "text" msgstr "tekst" #: src/client/gpaste-client.c:172 msgid "set text to clipboard" msgstr "verstuur tekst naar klembord" #: src/client/gpaste-client.c:174 msgid "password" msgstr "Wachtwoord" #: src/client/gpaste-client.c:174 msgid "add the name - password couple to the clipboard" msgstr "voeg de naam - wachtwoord-set toe aan het klembord" #. Translators: help for gpaste rename-password #: src/client/gpaste-client.c:176 msgid "old name" msgstr "oude naam" #: src/client/gpaste-client.c:176 msgid "new name" msgstr "nieuwe naam" #: src/client/gpaste-client.c:176 msgid "rename the password" msgstr "wachtwoordnaam wijzigen" #. 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/client/gpaste-client.c:178 src/client/gpaste-client.c:180 #: src/client/gpaste-client.c:182 src/client/gpaste-client.c:184 #: src/client/gpaste-client.c:186 src/client/gpaste-client.c:188 #: src/client/gpaste-client.c:212 msgid "number" msgstr "nummer" #: src/client/gpaste-client.c:178 msgid "get the th item from the history" msgstr "verkrijg item uit de geschiedenis" #: src/client/gpaste-client.c:180 msgid "set the th item from the history to the clipboard" msgstr "stelt item uit de geschiedenis in op het klembord" #: src/client/gpaste-client.c:182 msgid "contents" msgstr "inhoud" #: src/client/gpaste-client.c:182 msgid "" "replace the contents of the th item from the history with the " "provided one" msgstr "" "vervang de inhoud van item uit de geschiedenis door het opgegeven " "item" #: src/client/gpaste-client.c:184 msgid "" "merge the th items from the history and add put the result in the " "clipboard" msgstr "" "voeg de items uit de geschiedenis samen en plaats het resultaat op " "het klembord" #: src/client/gpaste-client.c:186 msgid "set the th item from the history as a password named " msgstr "" "stelt item uit de geschiedenis in als een wachtwoord genaamd " #: src/client/gpaste-client.c:188 msgid "delete th item of the history" msgstr "verwijdert item uit de geschiedenis" #: src/client/gpaste-client.c:190 msgid "delete the password from the history" msgstr "verwijdert wachtwoord uit de geschiedenis" #. Translators: help for gpaste file #: src/client/gpaste-client.c:192 msgid "path" msgstr "pad" #: src/client/gpaste-client.c:192 msgid "put the content of the file at into the clipboard" msgstr "plaats de inhoud van het bestand uit op het klembord" #. Translators: help for whatever | gpaste #: src/client/gpaste-client.c:194 msgid "whatever" msgstr "wat dan ook" #: src/client/gpaste-client.c:194 msgid "set the output of whatever to clipboard" msgstr "stelt de uitvoer van wat dan ook in op het klembord" #. Translators: help for gpaste empty #: src/client/gpaste-client.c:196 msgid "empty the history" msgstr "geschiedenis legen" #. Translators: help for gpaste start #: src/client/gpaste-client.c:198 msgid "start tracking clipboard changes" msgstr "begin met het bijhouden van klembordwijzigingen" #. Translators: help for gpaste stop #: src/client/gpaste-client.c:200 msgid "stop tracking clipboard changes" msgstr "begin met het bijhouden van klembordwijzigingen" #. Translators: help for gpaste quit #: src/client/gpaste-client.c:202 msgid "alias for stop" msgstr "alias voor stop" #. Translators: help for gpaste daemon-reexec #: src/client/gpaste-client.c:204 msgid "reexecute the daemon (after upgrading...)" msgstr "de daemon herstarten (na upgraden...)" #. Translators: help for gpaste settings #: src/client/gpaste-client.c:206 msgid "launch the configuration tool" msgstr "start het configuratievenster" #. Translators: help for gpaste ui #: src/client/gpaste-client.c:208 msgid "launch the graphical tool" msgstr "start het grafische venster" #. Translators: help for gpaste show-history #: src/client/gpaste-client.c:210 msgid "make the applet or extension display the history" msgstr "" "zorgt ervoor dat het applet of de uitbreiding de geschiedenis weergeeft" #: src/client/gpaste-client.c:212 msgid "upload the th item to a pastebin service" msgstr "upload item naar een pastebin-dienst" #. Translators: help for gpaste version #: src/client/gpaste-client.c:214 msgid "display the version" msgstr "applicatieversie weergeven" #. Translators: help for gpaste daemon-version #: src/client/gpaste-client.c:216 msgid "display the daemon version" msgstr "daemon-versie weergeven" #. Translators: help for gpaste help #: src/client/gpaste-client.c:218 msgid "display this help" msgstr "deze hulptekst weergeven" #. Translators: help for gpaste about #: src/client/gpaste-client.c:220 msgid "display the about dialog" msgstr "het over-venster weergeven" #: src/client/gpaste-client.c:223 #, c-format msgid "Display options:" msgstr "Weergave-opties:" #. Translators: help for --oneline #: src/client/gpaste-client.c:226 msgid "display each item on only one line" msgstr "elk item slechts op één regel weergeven" #. Translators: help for --raw #: src/client/gpaste-client.c:228 msgid "display each item raw (without line numbers)" msgstr "elk item 'kaal' weergeven (zonder regelnummers)" #. Translators: help for --reverse #: src/client/gpaste-client.c:230 #, fuzzy msgid "display the items in reverse order" msgstr "daemon-versie weergeven" #. Translators: help for --zero #: src/client/gpaste-client.c:232 msgid "use a NUL character instead of a new line betweean each item" msgstr "tussen elk item een NUL-teken gebruiken i.p.v. een nieuwe regel" #: src/client/gpaste-client.c:235 #, c-format msgid "Merge options:" msgstr "Samenvoegingsopties" #. Translators: help for --decoration #. Translators: help for --separator #: src/client/gpaste-client.c:238 src/client/gpaste-client.c:240 msgid "string" msgstr "string" #: src/client/gpaste-client.c:238 msgid "" "add the given decoration to the beginning and the end of each item before " "merging" msgstr "" "voeg de opgegeven decoratie aan het begin en eind van elk item alvorens het " "samen te voegen" #: src/client/gpaste-client.c:240 msgid "add the given separator between each item when merging" msgstr "" "voeg de opgegeven scheidingslijn toe tussen elk item tijdens het samenvoegen" #: src/client/gpaste-client.c:333 #, c-format msgid "Successfully reexecuted the daemon\n" msgstr "De daemon is sucessvol herstart\n" #: src/client/gpaste-client.c:482 msgid "Cannot add non utf8 data as text." msgstr "Het toevoegen van utf8-gegevens als tekst is mislukt." #: src/daemon/gpaste-daemon.c:33 msgid "Stop signal received, exiting" msgstr "Het stopsignaal is ontvangen; bezig met afsluiten" #: src/daemon/gpaste-daemon.c:70 msgid "Could not acquire DBus name." msgstr "Het ophalen van de DBus-naam is mislukt." #: src/ui/gpaste-ui.c:106 msgid "Keyboard Shortcuts" msgstr "Sneltoetsen" #: src/ui/gpaste-ui.c:107 msgid "About GPaste" msgstr "Over GPaste" #: src/ui/gpaste-ui.c:108 msgid "Quit" msgstr "Afsluiten" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:5 #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:4 msgid "GPaste" msgstr "GPaste" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:6 #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:5 msgid "Manage your clipboard history" msgstr "Beheer uw klembordgeschiedenis" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:7 msgid "Marc-Antoine Perennou" msgstr "" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:12 msgid "" "GPaste is a clipboard managing system allowing you to track and manage your " "clipboard history in a highly customizable way." msgstr "" "GPaste is een klembordbeheersysteem dat u in staat stelt uw " "klembordgeschiedenis bij te houden en te beheren. Dit alles is zeer " "aanpasbaar." #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:15 msgid "" "GPaste provides you with a graphical tool allowing you to manage everything " "easily." msgstr "" "GPaste geeft u een grafisch hulpmiddel dat u in staat stelt om alles " "gemakkelijk te beheren." #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:22 msgid "The main UI" msgstr "Hoofdvenster" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:26 #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:30 #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:34 msgid "The settings UI" msgstr "Instellingenvenster" #: data/control-center/42-gpaste.control-center.xml.in:2 msgid "@GETTEXT_PACKAGE@" msgstr "" #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:6 msgid "Clipboard;Manager;Settings;Preferences;Configuration;" msgstr "Klembord;Beheer;Instellingen;Voorkeuren;Configuratie;" #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:7 msgid "edit-paste" msgstr "bewerken-plakken" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:7 msgid "Max size of an element when displaying it" msgstr "Maximale grootte van een weergegeven element" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:8 msgid "" "The extra stuff of that element will be replaced by \"…\", and newlines by " "\" \" when displaying from the applet, 0 to disable." msgstr "" "De extra elementinformatie zal vervangen worden door \"...\" en nieuwe " "regels door \" \" wanneer weergegeven vanuit de applet. 0 om uit te " "schakelen." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:15 msgid "Do we detect and replace growing lines in history?" msgstr "Groeiende regels detecteren en vervangen in geschiedenis?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:16 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 "" "Het selecteren van \"Hier is\", daarna \"Hier is een voorbeeld\" zal twee " "items creëren in de geschiedenis. Als deze functie is ingeschakeld, zal de " "eerste worden vervangen door de tweede." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:24 msgid "The name of the current history" msgstr "Naam van de huidige geschiedenis" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:25 msgid "The default name is \"history\"" msgstr "De standaard naam is \"geschiedenis\"" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:32 msgid "Do we save the images copied to history, or only text?" msgstr "Gekopieerde afbeeldingen opslaan de geschiedenis of alleen tekst?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:33 msgid "By default, we're saving both" msgstr "Standaard worden beiden opgeslagen" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:40 msgid "Do we close the UI after selecting an item?" msgstr "Venster sluiten na het selecteren van een item?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:41 msgid "By default, we close it" msgstr "Standaard wordt het gesloten" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:48 msgid "The keyboard shortcut to launch the graphical interface" msgstr "Sneltoets om het grafische venster te openen" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:49 msgid "" "By default, hitting ctrl + alt + g does that (\"G\"). An empty " "string here disables this functionnality." msgstr "" "Ctrl + Alt + G opent het grafische venster (\"G\"). Dit leeglaten " "schakelt de functionaliteit uit." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:57 msgid "The keyboard shortcut to mark the active item as being a password" msgstr "Sneltoets om het actieve item te markeren als een wachtwoord" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:58 msgid "" "By default, hitting ctrl + alt + s will mark the active item as being a " "password (\"S\"). An empty string here disables this " "functionnality." msgstr "" "Ctrl + Alt + S markeert het actieve item als een wachtwoord (\"S" "\"). Dit leeglaten schakelt de functionaliteit uit." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:68 msgid "Maximum number of items displayed in the history" msgstr "Maximaal aantal weer te geven items in de geschiedenis" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:77 msgid "Maximum number of items in history" msgstr "Maximaal aantal items in de geschiedenis" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:86 msgid "Maximum amount of memory used to store contents" msgstr "Maximaal te gebruiken geheugen om inhoud op te slaan" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:94 msgid "Max text item size" msgstr "Maximale tekstitem-grootte" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:95 msgid "Maximum size of a text item. Anything out of this boundary is ignored." msgstr "" "Maximale grootte van een tekstitem. Alle tekst die deze grens overschrijdt " "wordt genegeerd." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:103 msgid "Min text item size" msgstr "Minimale tekstitemgrootte" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:104 msgid "Minimum size of a text item. Anything out of this boundary is ignored." msgstr "" "Minimale grootte van een tekstitem. Alle tekst die deze grens overschrijdt " "wordt genegeerd." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:111 msgid "The keyboard shortcut to delete the first element in history" msgstr "Sneltoets om het eerste element in de geschiedenis te verwijderen" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:112 msgid "" "By default, hitting ctrl + alt + v does that (\"V\"). An empty " "string here disables this functionnality." msgstr "" "Ctrl + Alt + V verwijdert het eerste element in de geschiedenis " "(\"V\"). Dit leeglaten schakelt de functionaliteit uit." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:120 msgid "Does the primary selection affects history?" msgstr "Moet de primaire selectie de geschiedenis beïnvloeden?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:121 msgid "By default, only clipboard (ctrl+c) affects history." msgstr "Standaard beïnvloedt alleen het klembord (Ctrl + C) de geschiedenis." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:128 msgid "" "Do we save all versions of selected rich text (e.g. html) or just the plain " "text version?" msgstr "" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:129 #, fuzzy msgid "By default, we're saving all" msgstr "Standaard wordt het opgeslagen" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:136 msgid "Do we save the history from one session to another?" msgstr "" "Moet de geschiedenis worden opgeslagen van de ene sessie naar de andere?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:137 msgid "By default, we're saving it" msgstr "Standaard wordt het opgeslagen" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:144 msgid "The keyboard shortcut to display the menu" msgstr "Sneltoets om het menu te weergeven" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:145 msgid "" "By default, hitting ctrl + alt + h displays the menu (\"H\"). An " "empty string here disables this functionnality." msgstr "" "Ctrl + Alt + H opent het menu (\"H\"). Dit leeglaten schakelt de " "functionaliteit uit." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:153 msgid "The keyboard shortcut to sync the clipboard to the primary selection" msgstr "Sneltoets om het klembord te synchroniseren naar de primaire selectie" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:154 msgid "" "By default, hitting ctrl + alt + o syncs them (\"P\"). An empty " "string here disables this functionnality." msgstr "" "Ctrl + Alt + O synchroniseert (\"O\"). Dit leeglaten schakelt de " "functionaliteit uit." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:162 msgid "The keyboard shortcut to sync the primary selection to the clipboard" msgstr "Sneltoets om de primaire selectie te synchroniseren met het klembord" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:163 msgid "" "By default, hitting ctrl + alt + p syncs them (\"P\"). An empty " "string here disables this functionnality." msgstr "" "Ctrl + Alt + P synchroniseert (\"P\"). Dit leeglaten schakelt de " "functionaliteit uit." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:171 msgid "Are the primary selection and the clipboard synchronized?" msgstr "Moeten de primaire selectie en het klembord worden gesynchroniseerd?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:172 msgid "By default, the primary selection and the clipboard are independent." msgstr "" "Standaard werken de primaire selectie en het klembord onafhankelijk van " "elkaar." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:179 msgid "Do we track the clipboard changes?" msgstr "Moeten klembordwijzigingen worden bijgehouden?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:180 msgid "By default, we're tracking those changes." msgstr "Standaard worden die bijgehouden." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:187 msgid "" "Do we sync the daemon state with the gnome-shell extension's one? (disable " "the daemon when disabling the extension)" msgstr "" "Moet de daemon-staat gesynchroniseerd worden met die van de GNOME Shell-" "uitbreiding? (schakel de daemon uit wanneer de uitbreiding wordt " "uitgeschakeld)" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:188 msgid "By default, the daemon state keeps unchanged" msgstr "Standaard blijft de daemon-staat ongewijzigd" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:195 msgid "Do we trim the textual items before adding them to history?" msgstr "" "Moeten de tekstitems worden getrimd voordat ze worden toegevoegd aan de " "geschiedenis?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:196 msgid "" "Trimming means removing all trailing and ending spaces. By default, we're " "letting them as-is." msgstr "" "Trimmen houdt in dat alle spaties vóór en ná de tekst worden verwijderd. " "Standaard wordt er niet getrimd." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:204 msgid "" "The keyboard shortcut to upload the first element in history to a pastebin " "service" msgstr "" "Sneltoets om het eerste element in de geschiedenis te uploaden naar een " "pastebin-dienst" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:205 msgid "" "By default, hitting ctrl + alt + u does that (\"U\"). An empty " "string here disables this functionnality." msgstr "" "Ctrl + Alt + U wordt gebruikt om te uploaden (\"U\"). Dit " "leeglaten schakelt de functionaliteit uit." #~ msgid "launch the applet" #~ msgstr "Applet starten" #~ msgid "launch the unity application indicator" #~ msgstr "Unity applicatie-indicator starten" #~ msgid "GPaste Applet" #~ msgstr "GPaste-applet" #~ msgid "Tray icon to manage GPaste" #~ msgstr "Systeemvakpictogram om GPaste te beheren" #~ 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 bevat een applet in de vorm van een statuspictogram. Dit geeft u " #~ "toegang tot uw geschiedenis vanuit uw systeemvak.\t" #~ msgid "GPaste AppIndicator" #~ msgstr "GPaste applicatie-indicator" #~ msgid "Unity application indicator to manage GPaste" #~ msgstr "Unity applicatie-indicator om GPaste te beheren" #~ msgid "" #~ "GPaste provides you with an application indicator for unity which will " #~ "give you access to your history in your indicator area." #~ msgstr "" #~ "GPaste bevat een indicator voor Unity. Dit geeft u toegang tot uw " #~ "geschiedenis vanuit uw indicatorvak." #~ msgid "The AppIndicator menu" #~ msgstr "Het AppIndicator-menu" #~ msgid "Max displayed history size: " #~ msgstr "Maximaal weergegeven geschiedenisgrootte:" #~ msgid "Max history size: " #~ msgstr "Maximale geschiedenisgrootte:" #~ msgid "Max memory usage (MB): " #~ msgstr "Maximaal geheugengebruik (MB):" #~ msgid "Empty history" #~ msgstr "Geschiedenis wissen" #~ msgid "Backup history as: " #~ msgstr "Geschiedenis back-uppen als:" #~ msgid "Ok" #~ msgstr "Oké" #~ msgid "Histories" #~ msgstr "Geschiedenissen" #~ msgid "Could not register DBus service." #~ msgstr "Het registreren van de DBus-dienst is mislukt." #~ msgid "Manage GPaste" #~ msgstr "GPaste beheren" #~ msgid "GPaste daemon settings" #~ msgstr "GPaste-daemon-instellingen" #~ msgid "Manage GPaste settings" #~ msgstr "GPaste-instellingen beheren" #~ msgid "" #~ "GPaste provides you with a settings utility allowing you to customize its " #~ "behaviour as expected." #~ msgstr "" #~ "GPaste bevat een instellingenvenster waarmee u het applicatiegedrag kunt " #~ "instellen." #~ msgid "Manage the GPaste daemon settings" #~ msgstr "GPaste-Daemon-Einstellungen" #~ msgid "Stop tracking changes" #~ msgstr "Stoppen met bijhouden van wijzigingen" #~ msgid "Track changes" #~ msgstr "Wijzigingen bijhouden" #~ msgid "print the history without newlines" #~ msgstr "geschiedenis printen zonder nieuweregels" #~ msgid "print the history (raw) without indexes" #~ msgstr "geschiedenis printen zonder indexen (zonder opmaak)" #~ msgid "print the history with NUL as separator" #~ msgstr "geschiedenis printen met NUL als scheidingslijn" #~ msgid "get the th item from the history (raw)" #~ msgstr "verkrijg item uit de geschiedenis (zonder opmaak)" #~ msgid "Couldn't spawn gpaste-app-indicator.\n" #~ msgstr "Het starten van de GPaste-appindicator is mislukt.\n" gpaste-3.28.0/po/pt_BR.po000066400000000000000000001017531325205405000150560ustar00rootroot00000000000000# 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: 2018-03-13 14:55+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:98 msgid "Failed to register the gtk application" msgstr "Falha ao registrar a aplicação gtk" #: src/libgpaste/gpaste-macros.h:110 msgid "is already running." msgstr "" #. This is the date format "month/day/year time" #: src/libgpaste/core/gpaste-image-item.c:222 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:224 #, 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:67 msgid "Password" msgstr "Senha" #. This is the prefix displayed in history to identify selected files #: src/libgpaste/core/gpaste-uris-item.c:104 msgid "[Files] " msgstr "[Arquivos]" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:117 #: src/libgpaste/ui/gpaste-ui-switch.c:92 msgid "Track clipboard changes" msgstr "Monitorar a área de transferência" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:123 msgid "Close UI on select" msgstr "" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:132 msgid "Enable the gnome-shell extension" msgstr "Habilitar a extensão do gnome-shell" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:138 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 #, fuzzy msgid "Max element size when displaying" msgstr "Tamanho máximo do elemento ao exibir:" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:209 #: data/gsettings/org.gnome.GPaste.gschema.xml.in:67 msgid "Max displayed history size" msgstr "Tamanho máximo do histórico ao exibir" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:216 #: data/gsettings/org.gnome.GPaste.gschema.xml.in:76 msgid "Max history size" msgstr "Tamanho máximo do histórico" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:223 #: data/gsettings/org.gnome.GPaste.gschema.xml.in:85 msgid "Max memory usage (MB)" msgstr "Uso máximo de memória (MB)" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:230 #, fuzzy msgid "Max text item length" msgstr "Tamanho máximo do item de texto:" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:237 #, fuzzy msgid "Min text item length" msgstr "Tamanho mínimo do item de texto:" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:263 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:72 #: data/control-center/42-gpaste.control-center.xml.in:5 #, fuzzy 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 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:73 #: data/control-center/42-gpaste.control-center.xml.in:3 #, fuzzy msgid "Launch the graphical tool" msgstr "Iniciar a ferramenta gráfica: " #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:277 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:74 #: data/control-center/42-gpaste.control-center.xml.in:4 #, fuzzy 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 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:75 #: data/control-center/42-gpaste.control-center.xml.in:6 #, fuzzy msgid "Display the history" msgstr "Mostrar histórico: " #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:291 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:76 #: data/control-center/42-gpaste.control-center.xml.in:7 #, fuzzy 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 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:77 #: data/control-center/42-gpaste.control-center.xml.in:8 #, fuzzy 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 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:78 #: data/control-center/42-gpaste.control-center.xml.in:9 #, fuzzy 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:310 src/client/gpaste-client.c:804 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:335 msgid "General behaviour" msgstr "Comportamento geral" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:336 msgid "History settings" msgstr "Configurações do histórico" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:337 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:454 #: 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:459 #: src/libgpaste/ui/gpaste-ui-delete-item.c:49 #: src/libgpaste/ui/gpaste-ui-delete-history.c:24 #: src/libgpaste/ui/gpaste-ui-delete-history.c:61 msgid "Delete" msgstr "Apagar" #: src/libgpaste/ui/gpaste-ui-about.c:41 msgid "About" msgstr "Sobre" #: src/libgpaste/ui/gpaste-ui-backup-history.c:43 #: src/libgpaste/ui/gpaste-ui-backup-history.c:136 msgid "Backup" msgstr "Backup" #: src/libgpaste/ui/gpaste-ui-backup-history.c:44 #: src/libgpaste/ui/gpaste-ui-edit-item.c:45 #: src/libgpaste/ui/gpaste-ui-new-item.c:32 src/libgpaste/util/gpaste-util.c:30 msgid "Cancel" msgstr "Cancelar" #: src/libgpaste/ui/gpaste-ui-backup-history.c:47 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:24 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:44 #: src/libgpaste/ui/gpaste-ui-edit-item.c:117 msgid "Edit" msgstr "Editar" #. Translators: this is the translation for emptying the history #: src/libgpaste/ui/gpaste-ui-empty-history.c:61 #: src/libgpaste/util/gpaste-util.c:338 msgid "Empty" msgstr "Vazio" #: src/libgpaste/ui/gpaste-ui-empty-item.c:35 msgid "(No result)" msgstr "" #: src/libgpaste/ui/gpaste-ui-empty-item.c:49 msgid "(Empty)" msgstr "(Vazio)" #: src/libgpaste/ui/gpaste-ui-empty-item.c:60 #, fuzzy msgid "(Couldn't connect to GPaste daemon)" msgstr "Não foi possível se conectar ao daemon do GPaste" #: src/libgpaste/ui/gpaste-ui-new-item.c:31 #: src/libgpaste/ui/gpaste-ui-new-item.c:83 msgid "New" msgstr "" #: src/libgpaste/ui/gpaste-ui-reexec.c:29 msgid "Restart" msgstr "Reiniciar" #: src/libgpaste/ui/gpaste-ui-reexec.c:29 msgid "Do you really want to restart the daemon?" msgstr "Você quer mesmo reiniciar o daemon?" #: src/libgpaste/ui/gpaste-ui-reexec.c:55 msgid "Restart the daemon" msgstr "Reiniciar o daemon" #: src/libgpaste/ui/gpaste-ui-search.c:26 msgid "Search" msgstr "Pesquisar" #: src/libgpaste/ui/gpaste-ui-settings.c:32 src/ui/gpaste-ui.c:105 msgid "GPaste Settings" msgstr "Configurações do GPaste" #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:64 msgid "General" msgstr "" #: src/libgpaste/ui/gpaste-ui-switch.c:54 msgid "Stop" msgstr "Parar" #: src/libgpaste/ui/gpaste-ui-switch.c:54 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:49 msgid "Upload" msgstr "Carregar" #: src/libgpaste/util/gpaste-util.c:338 msgid "Do you really want to empty the history?" msgstr "Você quer mesmo esvaziar o histórico?" #: src/libgpaste/util/gpaste-util.c:617 msgid "Could not create history dir" msgstr "Não foi possível criar o diretório do histórico" #: src/client/gpaste-client.c:138 src/client/gpaste-client.c:428 msgid "Couldn't spawn" msgstr "Não foi possível executar" #: src/client/gpaste-client.c:156 #, c-format msgid "Usage:\n" msgstr "Uso:\n" #. Translators: help for gpaste history #: src/client/gpaste-client.c:158 msgid "print the history with indexes" msgstr "imprime o histórico com os índices" #. Translators: help for gpaste history-size #: src/client/gpaste-client.c:160 msgid "print the size of the history" msgstr "imprime o tamanho do histórico" #. Translators: help for gpaste get-history #: src/client/gpaste-client.c:162 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/client/gpaste-client.c:164 src/client/gpaste-client.c:166 #: src/client/gpaste-client.c:168 src/client/gpaste-client.c:174 #: src/client/gpaste-client.c:186 src/client/gpaste-client.c:190 msgid "name" msgstr "nome" #: src/client/gpaste-client.c:164 msgid "backup current history" msgstr "faz um backup do histórico atual" #: src/client/gpaste-client.c:166 msgid "switch to another history" msgstr "alterna para um outro histórico" #: src/client/gpaste-client.c:168 msgid "delete a history" msgstr "apaga um histórico" #. Translators: help for gpaste list-histories #: src/client/gpaste-client.c:170 msgid "list available histories" msgstr "lista os históricos disponíveis" #. Translators: help for gpaste add #: src/client/gpaste-client.c:172 msgid "text" msgstr "texto" #: src/client/gpaste-client.c:172 msgid "set text to clipboard" msgstr "copia texto para a área de transferência" #: src/client/gpaste-client.c:174 msgid "password" msgstr "senha" #: src/client/gpaste-client.c:174 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/client/gpaste-client.c:176 msgid "old name" msgstr "nome anterior" #: src/client/gpaste-client.c:176 msgid "new name" msgstr "novo nome" #: src/client/gpaste-client.c:176 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/client/gpaste-client.c:178 src/client/gpaste-client.c:180 #: src/client/gpaste-client.c:182 src/client/gpaste-client.c:184 #: src/client/gpaste-client.c:186 src/client/gpaste-client.c:188 #: src/client/gpaste-client.c:212 msgid "number" msgstr "número" #: src/client/gpaste-client.c:178 msgid "get the th item from the history" msgstr "obtém o -ésimo item do histórico" #: src/client/gpaste-client.c:180 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/client/gpaste-client.c:182 msgid "contents" msgstr "conteúdo" #: src/client/gpaste-client.c:182 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/client/gpaste-client.c:184 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/client/gpaste-client.c:186 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/client/gpaste-client.c:188 msgid "delete th item of the history" msgstr "apaga o -ésimo item do histórico" #: src/client/gpaste-client.c:190 msgid "delete the password from the history" msgstr "apaga a senha do histórico" #. Translators: help for gpaste file #: src/client/gpaste-client.c:192 msgid "path" msgstr "caminho" #: src/client/gpaste-client.c:192 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/client/gpaste-client.c:194 msgid "whatever" msgstr "qualquercomando" #: src/client/gpaste-client.c:194 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/client/gpaste-client.c:196 msgid "empty the history" msgstr "esvazia o histórico" #. Translators: help for gpaste start #: src/client/gpaste-client.c:198 msgid "start tracking clipboard changes" msgstr "inicia o monitoramento de alterações na área de transferência" #. Translators: help for gpaste stop #: src/client/gpaste-client.c:200 msgid "stop tracking clipboard changes" msgstr "pára o monitoramento de alterações na área de transferência" #. Translators: help for gpaste quit #: src/client/gpaste-client.c:202 msgid "alias for stop" msgstr "apelido para stop" #. Translators: help for gpaste daemon-reexec #: src/client/gpaste-client.c:204 msgid "reexecute the daemon (after upgrading...)" msgstr "reinicia o daemon (depois de uma atualização...)" #. Translators: help for gpaste settings #: src/client/gpaste-client.c:206 msgid "launch the configuration tool" msgstr "inicia a ferramenta de configuração" #. Translators: help for gpaste ui #: src/client/gpaste-client.c:208 msgid "launch the graphical tool" msgstr "inicia a ferramenta gráfica" #. Translators: help for gpaste show-history #: src/client/gpaste-client.c:210 msgid "make the applet or extension display the history" msgstr "faz o applet ou a extensão exibir o histórico" #: src/client/gpaste-client.c:212 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/client/gpaste-client.c:214 msgid "display the version" msgstr "mostra a versão" #. Translators: help for gpaste daemon-version #: src/client/gpaste-client.c:216 msgid "display the daemon version" msgstr "mostra a versão do daemon" #. Translators: help for gpaste help #: src/client/gpaste-client.c:218 msgid "display this help" msgstr "mostra esta ajuda" #. Translators: help for gpaste about #: src/client/gpaste-client.c:220 msgid "display the about dialog" msgstr "mostra o diálogo Sobre" #: src/client/gpaste-client.c:223 #, c-format msgid "Display options:" msgstr "Opções de exibição:" #. Translators: help for --oneline #: src/client/gpaste-client.c:226 msgid "display each item on only one line" msgstr "Mostra cada item em uma única linha" #. Translators: help for --raw #: src/client/gpaste-client.c:228 msgid "display each item raw (without line numbers)" msgstr "exibe cada item bruto (sem números nas linhas) " #. Translators: help for --reverse #: src/client/gpaste-client.c:230 #, fuzzy msgid "display the items in reverse order" msgstr "mostra a versão do daemon" #. Translators: help for --zero #: src/client/gpaste-client.c:232 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/client/gpaste-client.c:235 #, c-format msgid "Merge options:" msgstr "Opções de merge:" #. Translators: help for --decoration #. Translators: help for --separator #: src/client/gpaste-client.c:238 src/client/gpaste-client.c:240 msgid "string" msgstr "string" #: src/client/gpaste-client.c:238 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/client/gpaste-client.c:240 msgid "add the given separator between each item when merging" msgstr "adiciona o separador dado entre cada item durante o merge" #: src/client/gpaste-client.c:333 #, c-format msgid "Successfully reexecuted the daemon\n" msgstr "O daemon foi reiniciado com sucesso\n" #: src/client/gpaste-client.c:482 msgid "Cannot add non utf8 data as text." msgstr "" #: src/daemon/gpaste-daemon.c:33 #, fuzzy msgid "Stop signal received, exiting" msgstr "Sinal %d recebido, saindo\n" #: src/daemon/gpaste-daemon.c:70 msgid "Could not acquire DBus name." msgstr "Não foi possível obter um nome DBus." #: src/ui/gpaste-ui.c:106 #, fuzzy msgid "Keyboard Shortcuts" msgstr "Atalhos do teclado" #: src/ui/gpaste-ui.c:107 msgid "About GPaste" msgstr "" #: src/ui/gpaste-ui.c:108 msgid "Quit" msgstr "Sair" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:5 #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:4 #, fuzzy msgid "GPaste" msgstr "Applet do GPaste" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:6 #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:5 msgid "Manage your clipboard history" msgstr "Gerencie seu histórico da área de transferência" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:7 msgid "Marc-Antoine Perennou" msgstr "" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:12 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.Ui.appdata.xml.in:15 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/appstream/org.gnome.GPaste.Ui.appdata.xml.in:22 msgid "The main UI" msgstr "" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:26 #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:30 #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:34 #, fuzzy msgid "The settings UI" msgstr "Configurações do GPaste" #: data/control-center/42-gpaste.control-center.xml.in:2 msgid "@GETTEXT_PACKAGE@" msgstr "" #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:6 msgid "Clipboard;Manager;Settings;Preferences;Configuration;" msgstr "Clipboard;Manager;Settings;Preferences;Configuration;" #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:7 msgid "edit-paste" msgstr "" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:7 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.in:8 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.in:15 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.in:16 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.in:24 msgid "The name of the current history" msgstr "O nome do histórico atual" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:25 msgid "The default name is \"history\"" msgstr "O nome padrão é \"history\"" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:32 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.in:33 msgid "By default, we're saving both" msgstr "Por padrão, ambos são salvos" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:40 #, fuzzy msgid "Do we close the UI after selecting an item?" msgstr "Seleção primária afeta o histórico?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:41 #, fuzzy msgid "By default, we close it" msgstr "Por padrão, ele é salvo" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:48 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.in:49 #, fuzzy msgid "" "By default, hitting ctrl + alt + g does that (\"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.in:57 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.in:58 #, fuzzy msgid "" "By default, hitting ctrl + alt + s will mark the active item as being a " "password (\"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.in:68 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.in:77 msgid "Maximum number of items in history" msgstr "Número máximo de itens no histórico" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:86 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.in:94 msgid "Max text item size" msgstr "Tamanho máximo do item de texto" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:95 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.in:103 msgid "Min text item size" msgstr "Tamanho mínimo do item de texto" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:104 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.in:111 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.in:112 #, fuzzy msgid "" "By default, hitting ctrl + alt + v does that (\"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.in:120 msgid "Does the primary selection affects history?" msgstr "Seleção primária afeta o histórico?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:121 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.in:128 msgid "" "Do we save all versions of selected rich text (e.g. html) or just the plain " "text version?" msgstr "" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:129 #, fuzzy msgid "By default, we're saving all" msgstr "Por padrão, ele é salvo" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:136 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.in:137 msgid "By default, we're saving it" msgstr "Por padrão, ele é salvo" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:144 msgid "The keyboard shortcut to display the menu" msgstr "O atalho do teclado para exibir o menu" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:145 #, fuzzy msgid "" "By default, hitting ctrl + alt + h displays the menu (\"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.in:153 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.in:154 #, fuzzy msgid "" "By default, hitting ctrl + alt + o syncs them (\"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.in:162 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.in:163 #, fuzzy msgid "" "By default, hitting ctrl + alt + p syncs them (\"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.in:171 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.in:172 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.in:179 msgid "Do we track the clipboard changes?" msgstr "Monitorar as alterações na área de transferência?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:180 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.in:187 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.in:188 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.in:195 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.in:196 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.in:204 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.in:205 #, fuzzy msgid "" "By default, hitting ctrl + alt + u does that (\"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 "launch the applet" #~ msgstr "inicia o applet do GPaste" #~ msgid "launch the unity application indicator" #~ msgstr "inicia o aplicativo indicador do unity" #~ msgid "GPaste Applet" #~ msgstr "Applet do GPaste" #~ msgid "Tray icon to manage GPaste" #~ msgstr "Ícone da bandeja para gerenciar o GPaste" #~ 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." #~ msgid "GPaste AppIndicator" #~ msgstr "Aplicativo Indicador do GPaste" #~ msgid "Unity application indicator to manage GPaste" #~ msgstr "Aplicativo indicador do Unity para gerenciar o GPaste" #~ 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." #, fuzzy #~ msgid "The AppIndicator menu" #~ msgstr "Aplicativo Indicador do GPaste" #~ msgid "Clipboard;Manager;" #~ msgstr "Clipboard;Manager;" #~ msgid "Max displayed history size: " #~ msgstr "Tamanho máximo do histórico ao exibir:" #~ msgid "Max history size: " #~ msgstr "Tamanho máximo do histórico:" #~ msgid "Max memory usage (MB): " #~ msgstr "Uso de memória (MB): " #~ msgid "is not installed" #~ msgstr "não está instalado" #~ 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.28.0/po/sv.po000066400000000000000000000717521325205405000145050ustar00rootroot00000000000000# Swedish translations for GPaste package. # Copyright (C) 2013-2015 Listed translators # This file is distributed under the same license as the GPaste package. # Åke Engelbrektson , 2017 # msgid "" msgstr "" "Project-Id-Version: GPaste\n" "Report-Msgid-Bugs-To: Marc-Antoine@Perennou.com\n" "POT-Creation-Date: 2018-03-13 14:55+0100\n" "PO-Revision-Date: 2018-01-06 08:14+0100\n" "Last-Translator: Åke Engelbrektson \n" "Language-Team: Svenska Språkfiler \n" "Language: sv\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Poedit 1.8.7.1\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Generator: Poedit 1.8.7.1\n" #: src/libgpaste/gpaste-macros.h:98 msgid "Failed to register the gtk application" msgstr "Kunde inte registrera gtk-applikationen" #: src/libgpaste/gpaste-macros.h:110 msgid "is already running." msgstr "körs redan." #. This is the date format "month/day/year time" #: src/libgpaste/core/gpaste-image-item.c:222 msgid "%m/%d/%y %T" msgstr "%y-%m-%d %T" #. This gets displayed in history when selecting an image #: src/libgpaste/core/gpaste-image-item.c:224 #, 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:67 msgid "Password" msgstr "Lösenord" #. This is the prefix displayed in history to identify selected files #: src/libgpaste/core/gpaste-uris-item.c:104 msgid "[Files] " msgstr "[Filer] " #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:117 #: src/libgpaste/ui/gpaste-ui-switch.c:92 msgid "Track clipboard changes" msgstr "Övervaka urklippsändringar" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:123 msgid "Close UI on select" msgstr "Stäng UI vid markering" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:132 msgid "Enable the gnome-shell extension" msgstr "Aktivera gnome-skaltillägget" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:138 msgid "Sync the daemon state with the extension's one" msgstr "Synkronisera tjänstens status med tilläggets" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:147 msgid "Primary selection affects history" msgstr "Primär markering påverkar historiken" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:153 msgid "Synchronize clipboard with primary selection" msgstr "Synkronisera urklipp med primär markering" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:160 msgid "Images support" msgstr "Bildstöd" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:166 msgid "Trim items" msgstr "Trimma poster" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:172 msgid "Detect growing lines" msgstr "Identifiera växande rader" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:179 msgid "Save history" msgstr "Spara historik" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:202 msgid "Max element size when displaying" msgstr "Max objektstorlek vid visning" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:209 #: data/gsettings/org.gnome.GPaste.gschema.xml.in:67 msgid "Max displayed history size" msgstr "Max visad historikstorlek" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:216 #: data/gsettings/org.gnome.GPaste.gschema.xml.in:76 msgid "Max history size" msgstr "Max historikstorlek" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:223 #: data/gsettings/org.gnome.GPaste.gschema.xml.in:85 msgid "Max memory usage (MB)" msgstr "Max minnesanvändning (MB)" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:230 msgid "Max text item length" msgstr "Maxlängd för textposter" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:237 msgid "Min text item length" msgstr "Minimumlängd för textposter" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:263 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:72 #: data/control-center/42-gpaste.control-center.xml.in:5 msgid "Delete the active item from history" msgstr "Ta bort aktiv post från historiken" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:270 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:73 #: data/control-center/42-gpaste.control-center.xml.in:3 msgid "Launch the graphical tool" msgstr "Starta det grafiska verktyget" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:277 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:74 #: data/control-center/42-gpaste.control-center.xml.in:4 msgid "Mark the active item as being a password" msgstr "Märk den aktiva posten som varande lösenord" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:284 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:75 #: data/control-center/42-gpaste.control-center.xml.in:6 msgid "Display the history" msgstr "Visa historiken" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:291 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:76 #: data/control-center/42-gpaste.control-center.xml.in:7 msgid "Sync the clipboard to the primary selection" msgstr "Synkronisera urklipp med primär markering" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:298 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:77 #: data/control-center/42-gpaste.control-center.xml.in:8 msgid "Sync the primary selection to the clipboard" msgstr "Synkronisera primär markering med urklipp" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:305 #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:78 #: data/control-center/42-gpaste.control-center.xml.in:9 msgid "Upload the active item to a pastebin service" msgstr "Ladda upp aktiv post till en pastebin-tjänst" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:320 #: src/libgpaste/ui/gpaste-ui-window.c:310 src/client/gpaste-client.c:804 msgid "Couldn't connect to GPaste daemon" msgstr "Kunde inte ansluta till GPaste-tjänsten" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:335 msgid "General behaviour" msgstr "Allmänt beteende" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:336 msgid "History settings" msgstr "Historikinställningar" #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:337 msgid "Keyboard shortcuts" msgstr "Tangentbordsgenvägar" #. translators: This is the name of a multi-history management action #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:454 #: src/libgpaste/ui/gpaste-ui-panel.c:297 msgid "Switch to" msgstr "Växla till" #. translators: This is the name of a multi-history management action #: src/libgpaste/settings-ui/gpaste-settings-ui-stack.c:459 #: src/libgpaste/ui/gpaste-ui-delete-item.c:49 #: src/libgpaste/ui/gpaste-ui-delete-history.c:24 #: src/libgpaste/ui/gpaste-ui-delete-history.c:61 msgid "Delete" msgstr "Ta bort" #: src/libgpaste/ui/gpaste-ui-about.c:41 msgid "About" msgstr "Om" #: src/libgpaste/ui/gpaste-ui-backup-history.c:43 #: src/libgpaste/ui/gpaste-ui-backup-history.c:136 msgid "Backup" msgstr "Säkerhetskopiera" #: src/libgpaste/ui/gpaste-ui-backup-history.c:44 #: src/libgpaste/ui/gpaste-ui-edit-item.c:45 #: src/libgpaste/ui/gpaste-ui-new-item.c:32 src/libgpaste/util/gpaste-util.c:30 msgid "Cancel" msgstr "Avbryt" #: src/libgpaste/ui/gpaste-ui-backup-history.c:47 msgid "Under which name do you want to backup this history?" msgstr "Under vilket namn vill du säkerhetskopiera historiken?" #: src/libgpaste/ui/gpaste-ui-delete-history.c:24 msgid "Are you sure you want to delete this history?" msgstr "Vill du verkligen ta bort denna historik?" #: src/libgpaste/ui/gpaste-ui-edit-item.c:44 #: src/libgpaste/ui/gpaste-ui-edit-item.c:117 msgid "Edit" msgstr "Redigera" #. Translators: this is the translation for emptying the history #: src/libgpaste/ui/gpaste-ui-empty-history.c:61 #: src/libgpaste/util/gpaste-util.c:338 msgid "Empty" msgstr "Töm" #: src/libgpaste/ui/gpaste-ui-empty-item.c:35 msgid "(No result)" msgstr "(Inget resultat)" #: src/libgpaste/ui/gpaste-ui-empty-item.c:49 msgid "(Empty)" msgstr "(Tom)" #: src/libgpaste/ui/gpaste-ui-empty-item.c:60 msgid "(Couldn't connect to GPaste daemon)" msgstr "(Kunde inte ansluta till GPaste-tjänsten)" #: src/libgpaste/ui/gpaste-ui-new-item.c:31 #: src/libgpaste/ui/gpaste-ui-new-item.c:83 msgid "New" msgstr "Nytt" #: src/libgpaste/ui/gpaste-ui-reexec.c:29 msgid "Restart" msgstr "Starta om" #: src/libgpaste/ui/gpaste-ui-reexec.c:29 msgid "Do you really want to restart the daemon?" msgstr "Vill du verkligen starta om tjänsten?" #: src/libgpaste/ui/gpaste-ui-reexec.c:55 msgid "Restart the daemon" msgstr "Starta om tjänsten" #: src/libgpaste/ui/gpaste-ui-search.c:26 msgid "Search" msgstr "Sök" #: src/libgpaste/ui/gpaste-ui-settings.c:32 src/ui/gpaste-ui.c:105 msgid "GPaste Settings" msgstr "GPaste Inställningar" #: src/libgpaste/ui/gpaste-ui-shortcuts-window.c:64 msgid "General" msgstr "Allmänt" #: src/libgpaste/ui/gpaste-ui-switch.c:54 msgid "Stop" msgstr "Stopp" #: src/libgpaste/ui/gpaste-ui-switch.c:54 msgid "Do you really want to stop tracking clipboard changes?" msgstr "Vill du verkligen sluta övervaka urklippsändringar?" #: src/libgpaste/ui/gpaste-ui-upload-item.c:49 msgid "Upload" msgstr "Ladda upp" #: src/libgpaste/util/gpaste-util.c:338 msgid "Do you really want to empty the history?" msgstr "Vill du verkligen tömma historiken?" #: src/libgpaste/util/gpaste-util.c:617 msgid "Could not create history dir" msgstr "Kunde inte skapa historikmapp" #: src/client/gpaste-client.c:138 src/client/gpaste-client.c:428 msgid "Couldn't spawn" msgstr "Kunde inte starta" #: src/client/gpaste-client.c:156 #, c-format msgid "Usage:\n" msgstr "Användning:\n" #. Translators: help for gpaste history #: src/client/gpaste-client.c:158 msgid "print the history with indexes" msgstr "Skriv ut historiken med index" #. Translators: help for gpaste history-size #: src/client/gpaste-client.c:160 msgid "print the size of the history" msgstr "Skriv ut historikstorleken" #. Translators: help for gpaste get-history #: src/client/gpaste-client.c:162 msgid "get the name of the current history" msgstr "Hämta namnet på aktuell historik" #. 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/client/gpaste-client.c:164 src/client/gpaste-client.c:166 #: src/client/gpaste-client.c:168 src/client/gpaste-client.c:174 #: src/client/gpaste-client.c:186 src/client/gpaste-client.c:190 msgid "name" msgstr "Namn" #: src/client/gpaste-client.c:164 msgid "backup current history" msgstr "Säkerhetskopiera aktuell historik" #: src/client/gpaste-client.c:166 msgid "switch to another history" msgstr "Växla till en annan historik" #: src/client/gpaste-client.c:168 msgid "delete a history" msgstr "Ta bort en historik" #. Translators: help for gpaste list-histories #: src/client/gpaste-client.c:170 msgid "list available histories" msgstr "Lista tillgängliga historiker" #. Translators: help for gpaste add #: src/client/gpaste-client.c:172 msgid "text" msgstr "Text" #: src/client/gpaste-client.c:172 msgid "set text to clipboard" msgstr "Ange text till urklipp" #: src/client/gpaste-client.c:174 msgid "password" msgstr "Lösenord" #: src/client/gpaste-client.c:174 msgid "add the name - password couple to the clipboard" msgstr "Lägg till namn och lösenordspar till urklipp" #. Translators: help for gpaste rename-password #: src/client/gpaste-client.c:176 msgid "old name" msgstr "Gammalt namn" #: src/client/gpaste-client.c:176 msgid "new name" msgstr "Nytt namn" #: src/client/gpaste-client.c:176 msgid "rename the password" msgstr "Byt namn på lösenordet" #. 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/client/gpaste-client.c:178 src/client/gpaste-client.c:180 #: src/client/gpaste-client.c:182 src/client/gpaste-client.c:184 #: src/client/gpaste-client.c:186 src/client/gpaste-client.c:188 #: src/client/gpaste-client.c:212 msgid "number" msgstr "Nummer" #: src/client/gpaste-client.c:178 msgid "get the th item from the history" msgstr "Hämta den :e posten från historiken" #: src/client/gpaste-client.c:180 msgid "set the th item from the history to the clipboard" msgstr "Skicka den :e historikposten till urklipp" #: src/client/gpaste-client.c:182 msgid "contents" msgstr "Innehåll" #: src/client/gpaste-client.c:182 msgid "" "replace the contents of the th item from the history with the " "provided one" msgstr "" "Ersätt innehållet i :e historikposten med nytt angivet innehåll" #: src/client/gpaste-client.c:184 msgid "" "merge the th items from the history and add put the result in the " "clipboard" msgstr "" "Sammanfoga de :e posterna från historiken och skicka resultatet till " "urklipp" #: src/client/gpaste-client.c:186 msgid "set the th item from the history as a password named " msgstr "" "Märk den :e historikposten som varande lösenord med namnet " #: src/client/gpaste-client.c:188 msgid "delete th item of the history" msgstr "Ta bort den :e posten i historiken" #: src/client/gpaste-client.c:190 msgid "delete the password from the history" msgstr "Ta bort lösenordet från historiken" #. Translators: help for gpaste file #: src/client/gpaste-client.c:192 msgid "path" msgstr "Sökväg" #: src/client/gpaste-client.c:192 msgid "put the content of the file at into the clipboard" msgstr "Skicka innehållet i filen , till urklipp" #. Translators: help for whatever | gpaste #: src/client/gpaste-client.c:194 msgid "whatever" msgstr "Vad som helst" #: src/client/gpaste-client.c:194 msgid "set the output of whatever to clipboard" msgstr "Skicka utdata från vad som helst till urklipp" #. Translators: help for gpaste empty #: src/client/gpaste-client.c:196 msgid "empty the history" msgstr "Töm historiken" #. Translators: help for gpaste start #: src/client/gpaste-client.c:198 msgid "start tracking clipboard changes" msgstr "Börja övervaka urklippsändringar" #. Translators: help for gpaste stop #: src/client/gpaste-client.c:200 msgid "stop tracking clipboard changes" msgstr "Sluta övervaka urklippsändringar" #. Translators: help for gpaste quit #: src/client/gpaste-client.c:202 msgid "alias for stop" msgstr "alias för stopp" #. Translators: help for gpaste daemon-reexec #: src/client/gpaste-client.c:204 msgid "reexecute the daemon (after upgrading...)" msgstr "Starta om tjänsten (efter uppgradering...)" #. Translators: help for gpaste settings #: src/client/gpaste-client.c:206 msgid "launch the configuration tool" msgstr "Starta inställningsverktyget" #. Translators: help for gpaste ui #: src/client/gpaste-client.c:208 msgid "launch the graphical tool" msgstr "Starta det grafiska verktyget" #. Translators: help for gpaste show-history #: src/client/gpaste-client.c:210 msgid "make the applet or extension display the history" msgstr "Låt panelprogrammet eller tillägget visa historiken" #: src/client/gpaste-client.c:212 msgid "upload the th item to a pastebin service" msgstr "Ladda upp den :e posten till en pastebin-tjänst" #. Translators: help for gpaste version #: src/client/gpaste-client.c:214 msgid "display the version" msgstr "Visa version" #. Translators: help for gpaste daemon-version #: src/client/gpaste-client.c:216 msgid "display the daemon version" msgstr "Visa tjänstversion" #. Translators: help for gpaste help #: src/client/gpaste-client.c:218 msgid "display this help" msgstr "Visa denna hjälp" #. Translators: help for gpaste about #: src/client/gpaste-client.c:220 msgid "display the about dialog" msgstr "Visa \"Om\"" #: src/client/gpaste-client.c:223 #, c-format msgid "Display options:" msgstr "Visningsalternativ:" #. Translators: help for --oneline #: src/client/gpaste-client.c:226 msgid "display each item on only one line" msgstr "Visa varje post på endast en rad" #. Translators: help for --raw #: src/client/gpaste-client.c:228 msgid "display each item raw (without line numbers)" msgstr "Visa varje post rent (utan radnummer)" #. Translators: help for --reverse #: src/client/gpaste-client.c:230 #, fuzzy msgid "display the items in reverse order" msgstr "Visa tjänstversion" #. Translators: help for --zero #: src/client/gpaste-client.c:232 msgid "use a NUL character instead of a new line betweean each item" msgstr "Använd NULL-tecken istället för ny rad mellan varje post" #: src/client/gpaste-client.c:235 #, c-format msgid "Merge options:" msgstr "Sammanfogningsalternativ:" #. Translators: help for --decoration #. Translators: help for --separator #: src/client/gpaste-client.c:238 src/client/gpaste-client.c:240 msgid "string" msgstr "Sträng" #: src/client/gpaste-client.c:238 msgid "" "add the given decoration to the beginning and the end of each item before " "merging" msgstr "" "Lägg till angiven dekoration i början och slutet på varje post, före " "sammanfogning" #: src/client/gpaste-client.c:240 msgid "add the given separator between each item when merging" msgstr "Lägg till angiven separator mellan varje post vid sammanfogning" #: src/client/gpaste-client.c:333 #, c-format msgid "Successfully reexecuted the daemon\n" msgstr "Tjänsten startades om korrekt\n" #: src/client/gpaste-client.c:482 msgid "Cannot add non utf8 data as text." msgstr "Kan inte lägga till icke UTF8-data som text." #: src/daemon/gpaste-daemon.c:33 msgid "Stop signal received, exiting" msgstr "Stoppsignal mottagen, avslutar" #: src/daemon/gpaste-daemon.c:70 msgid "Could not acquire DBus name." msgstr "Kunde inte hämta DBus-namn." #: src/ui/gpaste-ui.c:106 msgid "Keyboard Shortcuts" msgstr "Tangentbordsgenvägar" #: src/ui/gpaste-ui.c:107 msgid "About GPaste" msgstr "Om GPaste" #: src/ui/gpaste-ui.c:108 msgid "Quit" msgstr "Avsluta" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:5 #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:4 msgid "GPaste" msgstr "GPaste" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:6 #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:5 msgid "Manage your clipboard history" msgstr "Hantera din urklippshistorik" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:7 msgid "Marc-Antoine Perennou" msgstr "Marc-Antoine Perennou" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:12 msgid "" "GPaste is a clipboard managing system allowing you to track and manage your " "clipboard history in a highly customizable way." msgstr "" "GPaste är ett system för urklippshantering, som låter dig övervaka och " "hantera din urklippshistorik på ett mycket anpassningsbart sätt." #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:15 msgid "" "GPaste provides you with a graphical tool allowing you to manage everything " "easily." msgstr "" "GPaste är ett grafiskt verktyg som låter dig hantera allt på ett enkelt sätt." #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:22 msgid "The main UI" msgstr "Primärt UI" #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:26 #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:30 #: data/appstream/org.gnome.GPaste.Ui.appdata.xml.in:34 msgid "The settings UI" msgstr "Inställnings-UI" #: data/control-center/42-gpaste.control-center.xml.in:2 msgid "@GETTEXT_PACKAGE@" msgstr "@GETTEXT_PACKAGE@" #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:6 msgid "Clipboard;Manager;Settings;Preferences;Configuration;" msgstr "Urklipp;Hanterare;Inställningar;Inställningar;Konfiguration;" #: data/desktop/org.gnome.GPaste.Ui.desktop.in.in:7 msgid "edit-paste" msgstr "Redigera-Klistra in" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:7 msgid "Max size of an element when displaying it" msgstr "Maxstorlek för ett objekt vid visning" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:8 msgid "" "The extra stuff of that element will be replaced by \"…\", and newlines by " "\" \" when displaying from the applet, 0 to disable." msgstr "" "Överskjutande innehåll från objektet kommer att ersättas av \"…\" och nya " "rader av \" \", vid visning i panelprogrammet. 0 för att inaktivera." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:15 msgid "Do we detect and replace growing lines in history?" msgstr "Skall vi identifiera och ersätta växande rader i historiken?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:16 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 "" "Som standard skapas två poster i historiken vid markering av först \"Här är" "\" och sedan \"Här är ett exempel\". Med denna funktion aktiverad, kommer " "den första posten att ersättas av den andra." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:24 msgid "The name of the current history" msgstr "Namnet på aktuell historik" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:25 msgid "The default name is \"history\"" msgstr "Standardnamnet är \"historik\"" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:32 msgid "Do we save the images copied to history, or only text?" msgstr "Skall vi spara bilder kopierade till historiken, eller bara text?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:33 msgid "By default, we're saving both" msgstr "Som standard sparar vi bägge" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:40 msgid "Do we close the UI after selecting an item?" msgstr "Skall vi stänga UI efter att en post valts?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:41 msgid "By default, we close it" msgstr "Som standard stänger vi den" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:48 msgid "The keyboard shortcut to launch the graphical interface" msgstr "Tangentbordsgenväg för att starta det grafiska gränssnittet" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:49 msgid "" "By default, hitting ctrl + alt + g does that (\"G\"). An empty " "string here disables this functionnality." msgstr "" "Som standard görs detta med Ctrl+Alt+G (\"G\"). En tom sträng " "här, inaktiverar denna funktion." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:57 msgid "The keyboard shortcut to mark the active item as being a password" msgstr "" "Tangentbordsgenväg för att markera aktivt objekt som varande ett lösenord" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:58 msgid "" "By default, hitting ctrl + alt + s will mark the active item as being a " "password (\"S\"). An empty string here disables this " "functionnality." msgstr "" "Som standard markeras den aktiva posten som varande ett lösenord, med Ctrl" "+Alt+S (\"S\"). En tom sträng här, inaktiverar denna funktion." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:68 msgid "Maximum number of items displayed in the history" msgstr "Max antal poster som visas i historiken" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:77 msgid "Maximum number of items in history" msgstr "Max antal poster i historiken" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:86 msgid "Maximum amount of memory used to store contents" msgstr "Max minnesmängd som kan användas för att lagra innehåll" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:94 msgid "Max text item size" msgstr "Max textobjektstorlek" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:95 msgid "Maximum size of a text item. Anything out of this boundary is ignored." msgstr "" "Maxstorlek för ett textobjekt. Allt som överskrider denna gräns undantas." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:103 msgid "Min text item size" msgstr "Minsta textobjektstorlek" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:104 msgid "Minimum size of a text item. Anything out of this boundary is ignored." msgstr "Minsta storlek för en textpost. Allt under denna gräns undantas." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:111 msgid "The keyboard shortcut to delete the first element in history" msgstr "Tangentbordsgenväg för att ta bort första posten från historiken" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:112 msgid "" "By default, hitting ctrl + alt + v does that (\"V\"). An empty " "string here disables this functionnality." msgstr "" "Som standard görs detta med Ctrl+Alt+V (\"V\"). En tom sträng " "här, inaktiverar denna funktion." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:120 msgid "Does the primary selection affects history?" msgstr "Skall primär markering påverka historiken?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:121 msgid "By default, only clipboard (ctrl+c) affects history." msgstr "Som standard påverkas historiken endast av urklipp (Ctrl+C)." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:128 msgid "" "Do we save all versions of selected rich text (e.g. html) or just the plain " "text version?" msgstr "" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:129 #, fuzzy msgid "By default, we're saving all" msgstr "Som standard sparar vi den" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:136 msgid "Do we save the history from one session to another?" msgstr "Skall vi spara historiken från en session till en annan?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:137 msgid "By default, we're saving it" msgstr "Som standard sparar vi den" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:144 msgid "The keyboard shortcut to display the menu" msgstr "Tangentbordsgenväg för att visa menyn" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:145 msgid "" "By default, hitting ctrl + alt + h displays the menu (\"H\"). An " "empty string here disables this functionnality." msgstr "" "Som standard visas menyn med Ctrl+Alt+H (\"H\"). En tom sträng " "här, inaktiverar denna funktion." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:153 msgid "The keyboard shortcut to sync the clipboard to the primary selection" msgstr "Tangentbordsgenväg för att synkronisera urklipp med primär markering" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:154 msgid "" "By default, hitting ctrl + alt + o syncs them (\"P\"). An empty " "string here disables this functionnality." msgstr "" "Som standard synkroniseras de med Ctrl+Alt+O (\"O\"). En tom " "sträng här, inaktiverar denna funktion." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:162 msgid "The keyboard shortcut to sync the primary selection to the clipboard" msgstr "Tangentbordsgenväg för att synkronisera primär markering med urklipp" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:163 msgid "" "By default, hitting ctrl + alt + p syncs them (\"P\"). An empty " "string here disables this functionnality." msgstr "" "Som standard synkroniseras de med Ctrl+Alt+P (\"P\"). En tom " "sträng här, inaktiverar denna funktion." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:171 msgid "Are the primary selection and the clipboard synchronized?" msgstr "Är primär markering och urklipp synkroniserade?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:172 msgid "By default, the primary selection and the clipboard are independent." msgstr "Som standard är primär markering och urklipp oberoende av varandra." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:179 msgid "Do we track the clipboard changes?" msgstr "Skall vi övervaka urklippsändringar?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:180 msgid "By default, we're tracking those changes." msgstr "Som standard övervakar vi dessa ändringar." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:187 msgid "" "Do we sync the daemon state with the gnome-shell extension's one? (disable " "the daemon when disabling the extension)" msgstr "" "Skall vi synkronisera tjänststatus med status för gnome-skaltillägget " "(inaktivera tjänsten när tillägget inaktiveras)?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:188 msgid "By default, the daemon state keeps unchanged" msgstr "Som standard ändras inte tjänstens status" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:195 msgid "Do we trim the textual items before adding them to history?" msgstr "Skall vi trimma textposter innan de läggs till i historiken?" #: data/gsettings/org.gnome.GPaste.gschema.xml.in:196 msgid "" "Trimming means removing all trailing and ending spaces. By default, we're " "letting them as-is." msgstr "" "Trimning innebär att alla efterföljande och avslutande blanksteg tas bort. " "Som standard lämnas de kvar." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:204 msgid "" "The keyboard shortcut to upload the first element in history to a pastebin " "service" msgstr "" "Tangentbordsgenväg för att ladda upp historikens första post, till en " "pastebin-tjänst." #: data/gsettings/org.gnome.GPaste.gschema.xml.in:205 msgid "" "By default, hitting ctrl + alt + u does that (\"U\"). An empty " "string here disables this functionnality." msgstr "" "Som standard görs detta med Ctrl+Alt+U (\"U\"). En tom sträng " "här, inaktiverar denna funktion." gpaste-3.28.0/src/000077500000000000000000000000001325205405000136525ustar00rootroot00000000000000gpaste-3.28.0/src/client.mk000066400000000000000000000007111325205405000154600ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou bin_PROGRAMS += \ bin/gpaste-client \ $(NULL) bin_gpaste_client_SOURCES = \ %D%/client/gpaste-client.c \ $(NULL) bin_gpaste_client_CFLAGS = \ $(GLIB_CFLAGS) \ $(GTK_CFLAGS) \ $(NULL) bin_gpaste_client_LDADD = \ $(builddir)/$(libgpaste_la_file) \ $(GLIB_LIBS) \ $(NULL) gpaste-3.28.0/src/client/000077500000000000000000000000001325205405000151305ustar00rootroot00000000000000gpaste-3.28.0/src/client/gpaste-client.c000066400000000000000000000631571325205405000200470ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include #include typedef struct { GPasteClient *client; gint argc; const gchar **args; gchar *pipe_data; gboolean help; gboolean version; gboolean oneline; gboolean raw; gboolean reverse; gboolean zero; const gchar *decoration; const gchar *separator; } Context; /* * Utility functions */ static gboolean parse_cmdline (int *argc, char **argv[], Context *ctx) { struct option long_options[] = { { "decoration", required_argument, NULL, 'd' }, { "help", no_argument, NULL, 'h' }, { "oneline", no_argument, NULL, 'o' }, { "raw", no_argument, NULL, 'r' }, { "reverse", no_argument, NULL, 'e' }, { "separator", required_argument, NULL, 's' }, { "version", no_argument, NULL, 'v' }, { "zero", no_argument, NULL, 'z' }, { NULL, no_argument, NULL, '\0' } }; gint64 c; while ((c = getopt_long(*argc, *argv, "d:hores:vz", long_options, NULL)) != -1) { switch (c) { case 'd': ctx->decoration = optarg; break; case 'h': ctx->help = TRUE; break; case 'o': ctx->oneline = TRUE; break; case 'r': ctx->raw = TRUE; break; case 'e': ctx->reverse = TRUE; break; case 's': ctx->separator = optarg; break; case 'v': ctx->version = TRUE; break; case 'z': ctx->zero = TRUE; break; default: ctx->help = TRUE; return FALSE; } } *argc -= optind; *argv += optind; ctx->argc = *argc - 1; ctx->args = (const gchar **) *argv; ++ctx->args; return TRUE; } static gchar * extract_pipe_data (void) { if (isatty (STDIN_FILENO)) return NULL; /* We're not being piped */ g_autoptr (GString) data = g_string_new (NULL); gint64 c; while ((c = fgetc (stdin)) != EOF) data = g_string_append_c (data, (guchar)c); g_string_append_c (data, '\0'); return (*data->str) ? g_strdup (data->str) : NULL; } 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, Context *ctx) { if (!ctx->raw) printf ("%" G_GUINT64_FORMAT ": ", index); printf ("%s%c", (ctx->oneline) ? strip_newline (line) : line, (ctx->zero) ? '\0' : '\n'); } static gint 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); } 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")); /* 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 --raw */ printf(" --raw: %s\n", _("display each item raw (without line numbers)")); /* Translators: help for --reverse */ printf(" --reverse: %s\n", _("display the items in reverse order")); /* Translators: help for --zero */ 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); } /* * GPaste commands */ static gint g_paste_help (Context *ctx G_GNUC_UNUSED, GError **error G_GNUC_UNUSED) { show_help (); return EXIT_SUCCESS; } static gint g_paste_version (Context *ctx G_GNUC_UNUSED, GError **error G_GNUC_UNUSED) { show_version (); return EXIT_SUCCESS; } static gint g_paste_flag_action (Context *ctx, GError **error) { if (ctx->help) return g_paste_help (ctx, error); if (ctx->version) return g_paste_version (ctx, error); return -1; } static gint g_paste_history (Context *ctx, GError **error) { g_auto (GStrv) history = (ctx->raw) ? g_paste_client_get_raw_history_sync (ctx->client, error) : g_paste_client_get_history_sync (ctx->client, error); if (*error) return EXIT_FAILURE; guint length = g_strv_length (history); for (guint64 i = (ctx->reverse ? (length - 1) : 0); ctx->reverse ? i != ((guint64) -1) : i < length; i += (ctx->reverse ? -1 : 1)) print_history_line (history[i], i, ctx); return EXIT_SUCCESS; } static gint g_paste_about (Context *ctx, GError **error) { g_paste_client_about_sync (ctx->client, error); return (*error) ? EXIT_FAILURE : EXIT_SUCCESS; } static gint g_paste_daemon_reexec (Context *ctx, GError **error) { g_paste_client_reexecute_sync (ctx->client, error); gboolean success = (!*error || (*error)->code == G_DBUS_ERROR_NO_REPLY); g_clear_error (error); #ifdef G_OS_UNIX if (!success) { GPid pid = g_paste_util_read_pid_file ("Daemon"); if (pid != (GPid) -1) success = !kill (pid, SIGUSR1); } #endif if (!success) return EXIT_FAILURE; printf (_("Successfully reexecuted the daemon\n")); return EXIT_SUCCESS; } static gint g_paste_daemon_version (Context *ctx, GError **error G_GNUC_UNUSED) { g_autofree gchar *v = g_paste_client_get_version (ctx->client); printf ("%s\n", v); return EXIT_SUCCESS; } static gint g_paste_empty (Context *ctx, GError **error) { g_autofree gchar *name = (ctx->argc) ? g_strdup (ctx->args[0]) : g_paste_client_get_history_name_sync (ctx->client, error); if (*error) return EXIT_FAILURE; g_paste_client_empty_history_sync (ctx->client, name, error); return (*error) ? EXIT_FAILURE : EXIT_SUCCESS; } static gint g_paste_get_history (Context *ctx, GError **error) { g_autofree gchar *name = g_paste_client_get_history_name_sync (ctx->client, error); if (*error) return EXIT_FAILURE; printf("%s\n", name); return EXIT_SUCCESS; } static gint g_paste_history_size (Context *ctx, GError **error) { g_autofree gchar *name = (ctx->argc) ? g_strdup (ctx->args[0]) : g_paste_client_get_history_name_sync (ctx->client, error); if (*error) return EXIT_FAILURE; guint64 size = g_paste_client_get_history_size_sync (ctx->client, name, error); if (*error) return EXIT_FAILURE; printf ("%" G_GUINT64_FORMAT "\n", size); return EXIT_SUCCESS; } static gint g_paste_list_histories (Context *ctx, GError **error) { g_auto (GStrv) histories = g_paste_client_list_histories_sync (ctx->client, error); if (*error) return EXIT_FAILURE; for (GStrv h = histories; *h; ++h) printf ("%s\n", *h); return EXIT_SUCCESS; } static gint g_paste_delete_history (Context *ctx, GError **error) { g_autofree gchar *name = (ctx->argc) ? g_strdup (ctx->args[0]) : g_paste_client_get_history_name_sync (ctx->client, error); g_paste_client_delete_history_sync (ctx->client, name, error); return (*error) ? EXIT_FAILURE : EXIT_SUCCESS; } static gint g_paste_settings (Context *ctx G_GNUC_UNUSED, GError **error) { if (!g_paste_util_activate_ui_sync ("prefs", NULL, error)) { g_critical ("%s Ui: %s", _("Couldn't spawn"), (*error)->message); g_clear_error (error); return EXIT_FAILURE; } return EXIT_SUCCESS; } static gint g_paste_show_history (Context *ctx, GError **error) { g_paste_client_show_history_sync (ctx->client, error); return (*error) ? EXIT_FAILURE : EXIT_SUCCESS; } static gint g_paste_start (Context *ctx, GError **error) { g_paste_client_track_sync (ctx->client, TRUE, error); return (*error) ? EXIT_FAILURE : EXIT_SUCCESS; } static gint g_paste_stop (Context *ctx, GError **error) { g_paste_client_track_sync (ctx->client, FALSE, error); return (*error) ? EXIT_FAILURE : EXIT_SUCCESS; } static gint g_paste_ui (Context *ctx G_GNUC_UNUSED, GError **error G_GNUC_UNUSED) { return spawn ("Ui"); } static gint g_paste_add (Context *ctx, GError **error) { const gchar *data = (ctx->argc > 0) ? ctx->args[0] : ctx->pipe_data; if (!data) return -1; if (!g_utf8_validate(data, -1, NULL)) { g_critical (_("Cannot add non utf8 data as text.")); return EXIT_FAILURE; } g_paste_client_add_sync (ctx->client, data, error); return (*error) ? EXIT_FAILURE : EXIT_SUCCESS; } static gint g_paste_add_password (Context *ctx, GError **error) { const gchar *data = (ctx->argc > 1) ? ctx->args[1] : ctx->pipe_data; if (!data) return EXIT_FAILURE; g_paste_client_add_password_sync (ctx->client, ctx->args[0], data, error); return (*error) ? EXIT_FAILURE : EXIT_SUCCESS; } static gint g_paste_backup_history (Context *ctx G_GNUC_UNUSED, GError **error G_GNUC_UNUSED) { guint64 index = 0; g_autofree gchar *name = (ctx->argc > 1) ? g_strdup (ctx->args[index++]) : g_paste_client_get_history_name_sync (ctx->client, error); if (*error) return EXIT_FAILURE; g_paste_client_backup_history_sync (ctx->client, name, ctx->args[index], error); return (*error) ? EXIT_FAILURE : EXIT_SUCCESS; } static gint g_paste_delete (Context *ctx, GError **error) { g_paste_client_delete_sync (ctx->client, _strtoull (ctx->args[0]), error); return (*error) ? EXIT_FAILURE : EXIT_SUCCESS; } static gint g_paste_delete_password (Context *ctx, GError **error) { g_paste_client_delete_password_sync (ctx->client, ctx->args[0], error); return (*error) ? EXIT_FAILURE : EXIT_SUCCESS; } static gint g_paste_file (Context *ctx, GError **error) { g_paste_client_add_file_sync (ctx->client, ctx->args[0], error); return (*error) ? EXIT_FAILURE : EXIT_SUCCESS; } static gint g_paste_get (Context *ctx, GError **error) { const gchar *value = (!ctx->raw) ? g_paste_client_get_element_sync (ctx->client, _strtoull (ctx->args[0]), error) : g_paste_client_get_raw_element_sync (ctx->client, _strtoull (ctx->args[0]), error); if (*error) return EXIT_FAILURE; printf ("%s", value); return EXIT_SUCCESS; } static gint g_paste_replace (Context *ctx, GError **error) { const gchar *data = (ctx->argc > 1) ? ctx->args[1] : ctx->pipe_data; if (!data) return EXIT_FAILURE; g_paste_client_replace_sync (ctx->client, _strtoull (ctx->args[0]), data, error); return (*error) ? EXIT_FAILURE : EXIT_SUCCESS; } static gint g_paste_search (Context *ctx, GError **error) { guint64 hits; g_autofree guint64 *results = g_paste_client_search_sync (ctx->client, ctx->args[0], &hits, error); if (*error) return EXIT_FAILURE; if (hits > 0) { for (guint64 i = 0; i < hits; ++i) { guint64 index = results[i]; /* FIXME: get_elements */ gchar *line = g_paste_client_get_element_sync (ctx->client, index, error); if (*error) return EXIT_FAILURE; print_history_line (line, index, ctx); } } return EXIT_SUCCESS; } static gint g_paste_select (Context *ctx, GError **error) { g_paste_client_select_sync (ctx->client, _strtoull (ctx->args[0]), error); return (*error) ? EXIT_FAILURE : EXIT_SUCCESS; } static gint g_paste_switch_history (Context *ctx, GError **error) { g_paste_client_switch_history_sync (ctx->client, ctx->args[0], error); return (*error) ? EXIT_FAILURE : EXIT_SUCCESS; } static gint g_paste_upload (Context *ctx, GError **error) { g_paste_client_upload_sync (ctx->client, _strtoull (ctx->args[0]), error); return (*error) ? EXIT_FAILURE : EXIT_SUCCESS; } static gint g_paste_rename_password (Context *ctx, GError **error) { g_paste_client_rename_password_sync (ctx->client, ctx->args[0], ctx->args[1], error); return (*error) ? EXIT_FAILURE : EXIT_SUCCESS; } static gint g_paste_set_password (Context *ctx, GError **error) { g_paste_client_set_password_sync (ctx->client, _strtoull (ctx->args[0]), ctx->args[1], error); return (*error) ? EXIT_FAILURE : EXIT_SUCCESS; } static gint g_paste_merge (Context *ctx, GError **error) { guint64 *indexes = alloca (ctx->argc * sizeof (guint64)); for (gint i = 0; i < ctx->argc; ++i) indexes[i] = _strtoull (ctx->args[i]); g_paste_client_merge_sync (ctx->client, ctx->decoration, ctx->separator, indexes, ctx->argc, error); return (*error) ? EXIT_FAILURE : EXIT_SUCCESS; } /* * Main */ static gint g_paste_dispatch (gint argc, const gchar *verb, Context *ctx, GError **error) { static struct { gint argc; const gchar *verb; gint extra_args; gboolean needs_client; gint (*handler) (Context *ctx, GError **error); } dispatch[] = { { 0, NULL, G_MAXINT, FALSE, g_paste_flag_action }, { 0, NULL, 0, TRUE, g_paste_add }, { 0, NULL, 0, TRUE, g_paste_history }, { 1, "help", 0, FALSE, g_paste_help }, { 1, "v", 0, FALSE, g_paste_version }, { 1, "version", 0, FALSE, g_paste_version }, { 1, "about", 0, TRUE, g_paste_about }, { 1, "dr", 0, TRUE, g_paste_daemon_reexec }, { 1, "daemon-reexec", 0, TRUE, g_paste_daemon_reexec }, { 1, "dv", 0, TRUE, g_paste_daemon_version }, { 1, "daemon-version", 0, TRUE, g_paste_daemon_version }, { 1, "e", 1, TRUE, g_paste_empty }, { 1, "empty", 1, TRUE, g_paste_empty }, { 1, "gh", 0, TRUE, g_paste_get_history }, { 1, "get-history", 0, TRUE, g_paste_get_history }, { 1, "h", 0, TRUE, g_paste_history }, { 1, "history", 0, TRUE, g_paste_history }, { 1, "hs", 1, TRUE, g_paste_history_size }, { 1, "history-size", 1, TRUE, g_paste_history_size }, { 1, "lh", 0, TRUE, g_paste_list_histories }, { 1, "list-histories", 0, TRUE, g_paste_list_histories }, { 1, "dh", 1, TRUE, g_paste_delete_history }, { 1, "delete-history", 1, TRUE, g_paste_delete_history }, { 1, "settings", 0, FALSE, g_paste_settings }, { 1, "p", 0, FALSE, g_paste_settings }, { 1, "preferences", 0, FALSE, g_paste_settings }, { 1, "show-history", 0, TRUE, g_paste_show_history }, { 1, "start", 0, TRUE, g_paste_start }, { 1, "d", 0, TRUE, g_paste_start }, { 1, "daemon", 0, TRUE, g_paste_start }, { 1, "stop", 0, TRUE, g_paste_stop }, { 1, "q", 0, TRUE, g_paste_stop }, { 1, "quit", 0, TRUE, g_paste_stop }, { 1, "ui", 0, FALSE, g_paste_ui }, { 1, "a", 1, TRUE, g_paste_add }, { 1, "add", 1, TRUE, g_paste_add }, { 2, "ap", 1, TRUE, g_paste_add_password }, { 2, "add-password", 1, TRUE, g_paste_add_password }, { 2, "bh", 1, TRUE, g_paste_backup_history }, { 2, "backup-history", 1, TRUE, g_paste_backup_history }, { 2, "d", 0, TRUE, g_paste_delete }, { 2, "del", 0, TRUE, g_paste_delete }, { 2, "delete", 0, TRUE, g_paste_delete }, { 2, "rm", 0, TRUE, g_paste_delete }, { 2, "remove", 0, TRUE, g_paste_delete }, { 2, "dp", 0, TRUE, g_paste_delete_password }, { 2, "delete-password", 0, TRUE, g_paste_delete_password }, { 2, "f", 0, TRUE, g_paste_file }, { 2, "file", 0, TRUE, g_paste_file }, { 2, "g", 0, TRUE, g_paste_get }, { 2, "get", 0, TRUE, g_paste_get }, { 2, "replace", 1, TRUE, g_paste_replace }, { 2, "search", 0, TRUE, g_paste_search }, { 2, "s", 0, TRUE, g_paste_select }, { 2, "set", 0, TRUE, g_paste_select }, { 2, "select", 0, TRUE, g_paste_select }, { 2, "sh", 0, TRUE, g_paste_switch_history }, { 2, "switch-history", 0, TRUE, g_paste_switch_history }, { 2, "u", 0, TRUE, g_paste_upload }, { 2, "upload", 0, TRUE, g_paste_upload }, { 3, "rp", 0, TRUE, g_paste_rename_password }, { 3, "rename-password", 0, TRUE, g_paste_rename_password }, { 3, "sp", 0, TRUE, g_paste_set_password }, { 3, "set-password", 0, TRUE, g_paste_set_password }, { 4, "m", G_MAXINT, TRUE, g_paste_merge }, { 4, "merge", G_MAXINT, TRUE, g_paste_merge }, }; for (guint64 i = 0; i < G_N_ELEMENTS (dispatch); ++i) { if (argc == dispatch[i].argc || dispatch[i].extra_args == G_MAXINT || (argc > dispatch[i].argc && argc <= (dispatch[i].argc + dispatch[i].extra_args))) { if (argc > 0 && dispatch[i].verb && !g_paste_str_equal (verb, dispatch[i].verb)) continue; if (dispatch[i].needs_client && !ctx->client) return EXIT_FAILURE; gint ret = dispatch[i].handler(ctx, error); if (ret >= 0) { if (!dispatch[i].needs_client && !ctx->client) g_clear_error (error); return ret; } } } return -1; } gint main (gint argc, gchar *argv[]) { G_PASTE_INIT_GETTEXT (); g_set_prgname (argv[0]); g_autoptr (GError) error = NULL; Context ctx = { NULL, 0, NULL, NULL, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL, NULL }; gint status; if (parse_cmdline (&argc, &argv, &ctx)) { g_autoptr (GPasteClient) client = ctx.client = g_paste_client_new_sync (&error); g_autofree gchar *pipe_data = ctx.pipe_data = extract_pipe_data (); status = g_paste_dispatch (argc, (argc > 0) ? argv[0] : NULL, &ctx, &error); } else { status = -1; } if (status < 0) { show_help (); status = EXIT_FAILURE; } if (error) { g_critical ("%s\n", (error) ? error->message : _("Couldn't connect to GPaste daemon")); status = EXIT_FAILURE; } return status; } gpaste-3.28.0/src/daemon.mk000066400000000000000000000011221325205405000154420ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou gpaste_daemon_binary = bin/gpaste-daemon pkglibexec_PROGRAMS += \ $(gpaste_daemon_binary) \ $(NULL) $(gpaste_daemon_binary): $(libgpaste_la_file) bin_gpaste_daemon_SOURCES = \ %D%/daemon/gpaste-daemon.c \ $(NULL) bin_gpaste_daemon_CFLAGS = \ $(GLIB_CFLAGS) \ $(GTK_CFLAGS) \ $(NULL) bin_gpaste_daemon_LDADD = \ $(builddir)/$(libgpaste_la_file) \ $(GLIB_LIBS) \ $(GTK_LIBS) \ $(NULL) gpaste-3.28.0/src/daemon/000077500000000000000000000000001325205405000151155ustar00rootroot00000000000000gpaste-3.28.0/src/daemon/gpaste-daemon.c000066400000000000000000000103071325205405000200060ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include #include #ifdef G_OS_UNIX # include #endif 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); } #ifdef G_OS_UNIX static gboolean signal_handler (gpointer user_data) { GApplication *app = user_data; g_print ("%s\n", _("Stop signal received, exiting")); g_application_quit (app); return G_SOURCE_REMOVE; } typedef struct { GPasteDaemon *daemon; GApplication *app; } Usr1Data; static gboolean usr1_handler (gpointer user_data) { Usr1Data *data = user_data; reexec (data->daemon, data->app); return G_SOURCE_REMOVE; } #endif enum { C_NAME_LOST, C_REEXECUTE_SELF, C_LAST_SIGNAL }; 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_source_set_name_by_id (g_idle_add (register_search_provider, user_data), "[GPaste] register_search_provider"); } 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; data->gapp = gapp; g_autoptr (GPasteBus) bus = data->bus = g_paste_bus_new (on_bus_acquired, data); guint64 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) }; #ifdef G_OS_UNIX g_source_set_name_by_id (g_unix_signal_add (SIGTERM, signal_handler, app), "[GPaste] SIGTERM listener"); g_source_set_name_by_id (g_unix_signal_add (SIGINT, signal_handler, app), "[GPaste] SIGINT listener"); Usr1Data usr1_data = { g_paste_daemon, gapp }; g_source_set_name_by_id (g_unix_signal_add (SIGUSR1, usr1_handler, &usr1_data), "[GPaste] SIGUSR1 listener"); #endif g_paste_bus_own_name (bus); g_paste_util_write_pid_file ("Daemon"); 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.28.0/src/gi.mk000066400000000000000000000022771325205405000146120ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou INTROSPECTION_SCANNER_ARGS = $(NULL) INTROSPECTION_COMPILER_ARGS = $(NULL) INTROSPECTION_GIRS = $(NULL) libgpaste_gir_file = bindings/GPaste-1.0.gir $(libgpaste_gir_file): $(libgpaste_la_file) bindings_GPaste_1_0_gir_FILES = \ $(pkginclude_HEADERS) \ $(lib_libgpaste_la_SOURCES) \ $(NULL) bindings_GPaste_1_0_gir_CFLAGS = \ $(AM_CPPFLAGS) \ $(NULL) bindings_GPaste_1_0_gir_LIBS = $(libgpaste_la_file) bindings_GPaste_1_0_gir_EXPORT_PACKAGES = libgpaste bindings_GPaste_1_0_gir_SCANNERFLAGS = --warn-all bindings_GPaste_1_0_gir_C_INCLUDES = gpaste.h bindings_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) -include $(INTROSPECTION_MAKEFILE) gpaste-3.28.0/src/gnome-shell.mk000066400000000000000000000031521325205405000164160ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou gnomeshelldir = $(datadir)/gnome-shell/extensions/GPaste@gnome-shell-extensions.gnome.org gnomeshell_extension_metadata_file = %D%/gnome-shell/metadata.json gnomeshell_extension_files = \ %D%/gnome-shell/aboutItem.js \ %D%/gnome-shell/deleteButton.js \ %D%/gnome-shell/deleteItemPart.js \ %D%/gnome-shell/dummyHistoryItem.js \ %D%/gnome-shell/emptyHistoryItem.js \ %D%/gnome-shell/extension.js \ %D%/gnome-shell/indicator.js \ %D%/gnome-shell/item.js \ %D%/gnome-shell/pageItem.js \ %D%/gnome-shell/pageSwitcher.js \ %D%/gnome-shell/prefs.js \ %D%/gnome-shell/searchItem.js \ %D%/gnome-shell/stateSwitch.js \ %D%/gnome-shell/statusIcon.js \ %D%/gnome-shell/uiItem.js \ $(NULL) if ENABLE_GNOME_SHELL_EXTENSION nodist_gnomeshell_DATA = \ $(gnomeshell_extension_metadata_file) \ $(gnomeshell_extension_files) \ $(NULL) endif EXTRA_DIST += \ $(gnomeshell_extension_metadata_file:.json=.json.in) \ $(gnomeshell_extension_files) \ $(NULL) CLEANFILES += \ $(gnomeshell_extension_metadata_file) \ $(NULL) SUFFIXES += .json .json.in .json.in.json: @ $(MKDIR_P) $(@D) $(AM_V_GEN) $(SED) -e 's,[@]localedir[@],$(localedir),g' \ -e 's,[@]gettext_package[@],$(GETTEXT_PACKAGE),g' \ -e 's,[@]version[@],$(VERSION),g' \ < $< > $@ gpaste-3.28.0/src/gnome-shell/000077500000000000000000000000001325205405000160645ustar00rootroot00000000000000gpaste-3.28.0/src/gnome-shell/aboutItem.js000066400000000000000000000013671325205405000203620ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Lang = imports.lang; const St = imports.gi.St; var 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.28.0/src/gnome-shell/deleteButton.js000066400000000000000000000016471325205405000210700ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ imports.gi.versions.Clutter = '1'; const Lang = imports.lang; const Clutter = imports.gi.Clutter; const St = imports.gi.St; var 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', this._onClick.bind(this)); }, setIndex: function(index) { this._index = index; }, _onClick: function() { this._client.delete(this._index, null); return Clutter.EVENT_STOP; } }); gpaste-3.28.0/src/gnome-shell/deleteItemPart.js000066400000000000000000000014351325205405000213350ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ /* -*- 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; var 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.28.0/src/gnome-shell/dummyHistoryItem.js000066400000000000000000000014411325205405000217560ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ /* -*- 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; var GPasteDummyHistoryItem = new Lang.Class({ Name: 'GPasteDummyHistoryItem', Extends: PopupMenu.PopupMenuItem, _init: function() { this.parent(_("(Couldn't connect to GPaste daemon)")); this.setSensitive(false); }, showEmpty: function() { this.label.text = _("(Empty)"); this.actor.show(); }, showNoResult: function() { this.label.text = _("(No result)"); this.actor.show(); } }); gpaste-3.28.0/src/gnome-shell/emptyHistoryItem.js000066400000000000000000000017331325205405000217650ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Lang = imports.lang; const GLib = imports.gi.GLib; const St = imports.gi.St; const GPaste = imports.gi.GPaste; var 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((client, result) => { const name = client.get_history_name_finish(result); GPaste.util_activate_ui("empty", GLib.Variant.new_string(name)); }); }); } }); gpaste-3.28.0/src/gnome-shell/extension.js000066400000000000000000000013751325205405000204440ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ /* -*- 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) { const 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.28.0/src/gnome-shell/indicator.js000066400000000000000000000311761325205405000204060ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ imports.gi.versions.Clutter = '1'; const Gettext = imports.gettext; const Lang = imports.lang; const PanelMenu = imports.ui.panelMenu; const PopupMenu = imports.ui.popupMenu; const Clutter = imports.gi.Clutter; const GLib = imports.gi.GLib; 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 PageSwitcher = Me.imports.pageSwitcher; const SearchItem = Me.imports.searchItem; const StateSwitch = Me.imports.stateSwitch; const StatusIcon = Me.imports.statusIcon; const UiItem = Me.imports.uiItem; var 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', this._onNewSearch.bind(this)); this._settingsSizeChangedId = this._settings.connect('changed::element-size', this._resetElementSize.bind(this)); this._resetElementSize(); this.menu.connect('open-state-changed', this._onOpenStateChanged.bind(this)); this.menu.connect('key-press-event', this._onMenuKeyPress.bind(this)); this._pageSwitcher = new PageSwitcher.GPastePageSwitcher(); this._pageSwitcher.connect('switch', (sw, page) => { this._updatePage(page); }); 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((obj, result) => { this._client = GPaste.Client.new_finish(result); 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._addToHeader(this._pageSwitcher); 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', this._resetMaxDisplayedSize.bind(this)); this._resetMaxDisplayedSize(); this._clientUpdateId = this._client.connect('update', this._update.bind(this)); this._clientShowId = this._client.connect('show-history', this._popup.bind(this)); this._clientTrackingId = this._client.connect('tracking', this._toggle.bind(this)); this._onStateChanged (true); this.menu.actor.connect('key-press-event', this._onKeyPressEvent.bind(this)); this.menu.actor.connect('key-release-event', this._onKeyReleaseEvent.bind(this)); this.actor.connect('destroy', this._onDestroy.bind(this)); }); }, shutdown: function() { this._onStateChanged (false); this._onDestroy(); this.destroy(); }, _onKeyPressEvent: function(actor, event) { if (event.has_control_modifier()) { const nb = parseInt(event.get_key_unicode()); if (!isNaN(nb) && nb >= 0 && nb <= 9 && nb < this._history.length) { this._history[nb].activate(); } } else { this._maybeUpdateIndexVisibility(event, true); } }, _onKeyReleaseEvent: function(actor, event) { this._updateIndexVisibility(!this._eventIsControlKey(event) && event.has_control_modifier()); }, _maybeUpdateIndexVisibility: function(event, state) { if (this._eventIsControlKey(event)) { this._updateIndexVisibility(state); } }, _updateIndexVisibility: function(state) { this._history.slice(0, 10).forEach(function(i) { i.showIndex(state); }); }, _eventIsControlKey: function(event) { const key = event.get_key_symbol(); return (key == Clutter.KEY_Control_L || key == Clutter.KEY_Control_R); }, _hasSearch: function() { return this._searchItem.text.length > 0; }, _onSearch: function(page) { if (this._hasSearch()) { const search = this._searchItem.text.toLowerCase(); this._client.search(search, (client, result) => { this._searchResults = client.search_finish(result); let results = this._searchResults.length; const maxSize = this._history.length; if (!this._pageSwitcher.updateForSize(results)) { return; } this._pageSwitcher.setActive(page); const offset = this._pageSwitcher.getPageOffset(); if (results > (maxSize + offset)) { results = (maxSize + offset); } this._history.slice(0, results - offset).forEach((i, index) => { i.setIndex(this._searchResults[offset + index]); }); /* If we had no result, updateForSize would have returned false */ this._dummyHistoryItem.actor.hide(); this._history.slice(results - offset, maxSize).forEach(function(i) { i.setIndex(-1); }); }); } else { this._searchResults = []; this._refresh(0); } }, _onNewSearch: function() { this._onSearch(1); }, _resetElementSize: function() { const size = this._settings.get_element_size(); this._searchItem.resetSize(size/2 + 3); this._history.forEach(function(i) { i.setTextSize(size); }); }, _updatePage: function(page) { this._pageSwitcher.setActive(page); this._refresh(0); }, _resetMaxDisplayedSize: function() { const oldSize = this._history.length; const newSize = this._settings.get_max_displayed_history_size(); const elementSize = this._settings.get_element_size(); this._pageSwitcher.setMaxDisplayedSize(newSize); const offset = this._pageSwitcher.getPageOffset(); if (newSize > oldSize) { for (let index = oldSize; index < newSize; ++index) { let item = new Item.GPasteItem(this._client, elementSize, index + offset); 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(); } } if (offset === 0 || oldSize === 0) { this._updatePage(1); } else { this._updatePage((offset / oldSize) + 1); } }, _update: function(client, action, target, position) { switch (target) { case GPaste.UpdateTarget.ALL: this._refresh(0); break; case GPaste.UpdateTarget.POSITION: const offset = this._pageSwitcher.getPageOffset(); const displayPos = position - offset; switch (action) { case GPaste.UpdateAction.REPLACE: this._history[displayPos].refresh(); break; case GPaste.UpdateAction.REMOVE: this._refresh(displayPos); break; } break; } }, _refresh: function(resetTextFrom) { if (this._searchResults.length > 0) { this._onSearch(this._pageSwitcher.getPage()); } else if (this._hasSearch()) { this._history.forEach(function(i, index) { i.setIndex(-1); }); this._updateVisibility(true); } else { this._client.get_history_name((client, result) => { const name = client.get_history_name_finish(result); this._client.get_history_size(name, (client, result) => { const realSize = client.get_history_size_finish(result); if (!this._pageSwitcher.updateForSize(realSize)) { return; } const maxSize = this._history.length; const offset = this._pageSwitcher.getPageOffset(); const size = Math.min(realSize - offset, maxSize); this._history.slice(resetTextFrom, size).forEach(function(i, index) { i.setIndex(offset + resetTextFrom + index); }); this._history.slice(size, maxSize).forEach(function(i, index) { i.setIndex(-1); }); this._updateVisibility(size == 0); }); }); } }, _updateVisibility: function(empty, search) { if (!empty) { this._dummyHistoryItem.actor.hide(); this._emptyHistoryItem.actor.show(); this._searchItem.actor.show(); } else if (this._hasSearch()) { this._dummyHistoryItem.showNoResult(); this._emptyHistoryItem.actor.hide(); this._searchItem.actor.show(); } else { this._dummyHistoryItem.showEmpty(); this._emptyHistoryItem.actor.hide(); this._searchItem.actor.hide(); } }, _popup: function() { this.menu.open(true); }, _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) { if (this._client) { this._client.on_extension_state_changed(state, null); } }, _onOpenStateChanged: function(menu, state) { if (state) { this._searchItem.reset(); this._updatePage(1); let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, Lang.bind(this, this._selectSearch)); GLib.Source.set_name_by_id(id, '[GPaste] select search'); } else { this._updateIndexVisibility(false); } }, _onMenuKeyPress: function(actor, event) { const symbol = event.get_key_symbol(); if (symbol == Clutter.KEY_Left) { return this._pageSwitcher.previous(); } if (symbol == Clutter.KEY_Right) { return this._pageSwitcher.next(); } return Clutter.EVENT_PROPAGATE; }, _onDestroy: function() { if (!this._client) { return; } this._client.disconnect(this._clientUpdateId); this._client.disconnect(this._clientShowId); this._client.disconnect(this._clientTrackingId); this._client = null; this._settings.disconnect(this._settingsMaxSizeChangedId); this._settings.disconnect(this._settingsSizeChangedId); } }); gpaste-3.28.0/src/gnome-shell/item.js000066400000000000000000000062241325205405000173640ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ imports.gi.versions.Clutter = '1'; 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; var 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', this._onActivate.bind(this)); this.actor.connect('key-press-event', this._onKeyPressed.bind(this)); 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) { const 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, (client, result) => { const 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) { const 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.28.0/src/gnome-shell/metadata.json.in000066400000000000000000000005071325205405000211460ustar00rootroot00000000000000{ "shell-version": [ "3.28" ], "uuid": "GPaste@gnome-shell-extensions.gnome.org", "name": "GPaste", "version": "@version@", "description": "Clipboard management system", "url": "http://github.com/Keruspe/GPaste", "gettext_package": "@gettext_package@", "localedir": "@localedir@" } gpaste-3.28.0/src/gnome-shell/pageItem.js000066400000000000000000000022011325205405000201500ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Lang = imports.lang; const Signals = imports.signals; const St = imports.gi.St; var GPastePageItem = new Lang.Class({ Name: 'GPastePageItem', Implements: [Signals.WithSignals], _init: function(page) { this.actor = new St.Button({ reactive: true, can_focus: false, track_hover: true, style_class: 'calendar-day-base' }); this.actor.child = new St.Label({ text: '' + page }); this._page = page; this.actor.connect('clicked', () => { this.emit('switch', this._page); }); }, setActive: function(active) { if (active) { this.actor.add_style_pseudo_class('active'); this.actor.set_style("font-weight: bold;"); } else { this.actor.remove_style_pseudo_class('active'); this.actor.set_style(null); } }, destroy: function() { this.actor.destroy(); } }); gpaste-3.28.0/src/gnome-shell/pageSwitcher.js000066400000000000000000000061341325205405000210530ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ imports.gi.versions.Clutter = '1'; const Lang = imports.lang; const PopupMenu = imports.ui.popupMenu; const Clutter = imports.gi.Clutter; const St = imports.gi.St; const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); const PageItem = Me.imports.pageItem; const MAX_PAGES = 20; var GPastePageSwitcher = new Lang.Class({ Name: 'GPastePageSwitcher', Extends: PopupMenu.PopupBaseMenuItem, _init: function() { this.parent({ reactive: false, can_focus: false }); this._box = new St.BoxLayout(); this.actor.add(this._box, { expand: true, x_fill: false, can_focus: false, reactive: false }); this._active = -1; this._maxDisplayedSize = -1; this._pages = []; }, setMaxDisplayedSize: function(size) { this._maxDisplayedSize = size; }, updateForSize: function(size) { const pages = Math.min((size === 0) ? 0 : Math.floor((size - 1) / this._maxDisplayedSize + 1), MAX_PAGES); for (let i = this._pages.length; i < pages; ++i) { this._addPage(); } while (this._pages.length !== pages) { this._pages.pop().destroy(); } if (size > 0 && this._active === -1) { this._switch(1); return false; } else if (size == 0 || this._active < pages) { return true; } else { this._active = -1; this._switch(pages); return false; } }, _addPage: function() { let sw = new PageItem.GPastePageItem(this._pages.length + 1); this._pages.push(sw); this._box.add(sw.actor, { expand: true, x_fill: false, x_align: St.Align.MIDDLE }); sw.connect('switch', (sw, page) => { this._switch(page); }); }, getPageOffset: function() { return (this._active < 0) ? 0 : (this._active * this._maxDisplayedSize); }, getPage: function() { return this._active + 1; }, setActive: function(page) { if (page !== 0 && page !== (this._active + 1) && page <= this._pages.length) { if (this._active !== -1) { this._pages[this._active].setActive(false); } this._active = page - 1; this._pages[this._active].setActive(true); } }, previous: function() { const page = this.getPage(); if (page > 1) { this._switch(page - 1); return Clutter.EVENT_STOP; } return Clutter.EVENT_PROPAGATE; }, next: function() { const page = this.getPage(); if (page < this._pages.length) { this._switch(page + 1); return Clutter.EVENT_STOP; } return Clutter.EVENT_PROPAGATE; }, _switch: function(page) { if (!isNaN(page)) { this.emit('switch', page); } } }); gpaste-3.28.0/src/gnome-shell/prefs.js000066400000000000000000000014451325205405000175450ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ imports.gi.versions.Gtk = '3.0'; 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() { const 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.28.0/src/gnome-shell/searchItem.js000066400000000000000000000040031325205405000205030ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Lang = imports.lang; const PopupMenu = imports.ui.popupMenu; const St = imports.gi.St; var 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', this._onTextChanged.bind(this)); 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) { const 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', this.reset.bind(this)); } this.emit('text-changed'); } }); gpaste-3.28.0/src/gnome-shell/stateSwitch.js000066400000000000000000000015011325205405000207210ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ /* -*- 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; var GPasteStateSwitch = new Lang.Class({ Name: 'GPasteStateSwitch', Extends: PopupMenu.PopupSwitchMenuItem, _init: function(client) { this.parent(_("Track changes"), client.is_active()); this._client = client; this.connect('toggled', this._onToggle.bind(this)); }, toggle: function(state) { if (state !== this.state) this.parent(); }, _onToggle: function(state) { this._client.track(this.state, null); } }); gpaste-3.28.0/src/gnome-shell/statusIcon.js000066400000000000000000000012601325205405000205550ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Lang = imports.lang; const PopupMenu = imports.ui.popupMenu; const St = imports.gi.St; var 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(PopupMenu.arrowIcon(St.Side.BOTTOM)); } }); gpaste-3.28.0/src/gnome-shell/uiItem.js000066400000000000000000000014061325205405000176570ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Lang = imports.lang; const GPaste = imports.gi.GPaste; const St = imports.gi.St; var 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.28.0/src/libgpaste.mk000066400000000000000000000242721325205405000161640ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou libgpaste_la_file = lib/libgpaste.la lib_libgpaste_la_private_headers = \ %D%/libgpaste/gpaste-gdbus-macros.h \ %D%/libgpaste/gpaste-gtk-compat.h \ $(NULL) lib_libgpaste_la_misc_headers = \ %D%/libgpaste/gpaste-gdbus-defines.h \ %D%/libgpaste/gpaste-gsettings-keys.h \ %D%/libgpaste/gpaste-macros.h \ %D%/libgpaste/util/gpaste-util.h \ $(NULL) lib_libgpaste_la_public_headers = \ %D%/libgpaste/gpaste.h \ %D%/libgpaste/client/gpaste-client.h \ %D%/libgpaste/core/gpaste-clipboard.h \ %D%/libgpaste/core/gpaste-clipboards-manager.h \ %D%/libgpaste/core/gpaste-history.h \ %D%/libgpaste/core/gpaste-image-item.h \ %D%/libgpaste/core/gpaste-item.h \ %D%/libgpaste/core/gpaste-password-item.h \ %D%/libgpaste/core/gpaste-text-item.h \ %D%/libgpaste/core/gpaste-item-enums.h \ %D%/libgpaste/core/gpaste-special-atom.h \ %D%/libgpaste/core/gpaste-update-enums.h \ %D%/libgpaste/core/gpaste-uris-item.h \ %D%/libgpaste/daemon/gpaste-bus.h \ %D%/libgpaste/daemon/gpaste-bus-object.h \ %D%/libgpaste/daemon/gpaste-daemon.h \ %D%/libgpaste/daemon/gpaste-search-provider.h \ %D%/libgpaste/gnome-shell-client/gpaste-gnome-shell-client.h \ %D%/libgpaste/io/gpaste-file-backend.h \ %D%/libgpaste/io/gpaste-storage-backend.h \ %D%/libgpaste/keybinder/gpaste-keybinder.h \ %D%/libgpaste/keybinder/gpaste-keybinding.h \ %D%/libgpaste/keybinder/gpaste-make-password-keybinding.h \ %D%/libgpaste/keybinder/gpaste-pop-keybinding.h \ %D%/libgpaste/keybinder/gpaste-show-history-keybinding.h \ %D%/libgpaste/keybinder/gpaste-sync-clipboard-to-primary-keybinding.h \ %D%/libgpaste/keybinder/gpaste-sync-primary-to-clipboard-keybinding.h \ %D%/libgpaste/keybinder/gpaste-ui-keybinding.h \ %D%/libgpaste/keybinder/gpaste-upload-keybinding.h \ %D%/libgpaste/screensaver-client/gpaste-screensaver-client.h \ %D%/libgpaste/settings/gpaste-settings.h \ %D%/libgpaste/settings-ui/gpaste-settings-ui-panel.h \ %D%/libgpaste/settings-ui/gpaste-settings-ui-stack.h \ %D%/libgpaste/settings-ui/gpaste-settings-ui-widget.h \ %D%/libgpaste/ui/gpaste-ui-about.h \ %D%/libgpaste/ui/gpaste-ui-backup-history.h \ %D%/libgpaste/ui/gpaste-ui-delete-history.h \ %D%/libgpaste/ui/gpaste-ui-delete-item.h \ %D%/libgpaste/ui/gpaste-ui-edit-item.h \ %D%/libgpaste/ui/gpaste-ui-empty-history.h \ %D%/libgpaste/ui/gpaste-ui-empty-item.h \ %D%/libgpaste/ui/gpaste-ui-header.h \ %D%/libgpaste/ui/gpaste-ui-history.h \ %D%/libgpaste/ui/gpaste-ui-history-action.h \ %D%/libgpaste/ui/gpaste-ui-history-actions.h \ %D%/libgpaste/ui/gpaste-ui-item.h \ %D%/libgpaste/ui/gpaste-ui-item-action.h \ %D%/libgpaste/ui/gpaste-ui-item-skeleton.h \ %D%/libgpaste/ui/gpaste-ui-new-item.h \ %D%/libgpaste/ui/gpaste-ui-panel.h \ %D%/libgpaste/ui/gpaste-ui-panel-history.h \ %D%/libgpaste/ui/gpaste-ui-reexec.h \ %D%/libgpaste/ui/gpaste-ui-search.h \ %D%/libgpaste/ui/gpaste-ui-search-bar.h \ %D%/libgpaste/ui/gpaste-ui-settings.h \ %D%/libgpaste/ui/gpaste-ui-shortcuts-window.h \ %D%/libgpaste/ui/gpaste-ui-switch.h \ %D%/libgpaste/ui/gpaste-ui-upload-item.h \ %D%/libgpaste/ui/gpaste-ui-window.h \ $(NULL) lib_libgpaste_la_source_files = \ %D%/libgpaste/client/gpaste-client.c \ %D%/libgpaste/core/gpaste-clipboard.c \ %D%/libgpaste/core/gpaste-clipboards-manager.c \ %D%/libgpaste/core/gpaste-history.c \ %D%/libgpaste/core/gpaste-image-item.c \ %D%/libgpaste/core/gpaste-item.c \ %D%/libgpaste/core/gpaste-password-item.c \ %D%/libgpaste/core/gpaste-text-item.c \ %D%/libgpaste/core/gpaste-item-enums.c \ %D%/libgpaste/core/gpaste-special-atom.c \ %D%/libgpaste/core/gpaste-update-enums.c \ %D%/libgpaste/core/gpaste-uris-item.c \ %D%/libgpaste/daemon/gpaste-bus.c \ %D%/libgpaste/daemon/gpaste-bus-object.c \ %D%/libgpaste/daemon/gpaste-daemon.c \ %D%/libgpaste/daemon/gpaste-search-provider.c \ %D%/libgpaste/gnome-shell-client/gpaste-gnome-shell-client.c \ %D%/libgpaste/io/gpaste-file-backend.c \ %D%/libgpaste/io/gpaste-storage-backend.c \ %D%/libgpaste/keybinder/gpaste-keybinder.c \ %D%/libgpaste/keybinder/gpaste-keybinding.c \ %D%/libgpaste/keybinder/gpaste-make-password-keybinding.c \ %D%/libgpaste/keybinder/gpaste-pop-keybinding.c \ %D%/libgpaste/keybinder/gpaste-show-history-keybinding.c \ %D%/libgpaste/keybinder/gpaste-sync-clipboard-to-primary-keybinding.c \ %D%/libgpaste/keybinder/gpaste-sync-primary-to-clipboard-keybinding.c \ %D%/libgpaste/keybinder/gpaste-ui-keybinding.c \ %D%/libgpaste/keybinder/gpaste-upload-keybinding.c \ %D%/libgpaste/screensaver-client/gpaste-screensaver-client.c \ %D%/libgpaste/settings/gpaste-settings.c \ %D%/libgpaste/settings-ui/gpaste-settings-ui-panel.c \ %D%/libgpaste/settings-ui/gpaste-settings-ui-stack.c \ %D%/libgpaste/settings-ui/gpaste-settings-ui-widget.c \ %D%/libgpaste/ui/gpaste-ui-about.c \ %D%/libgpaste/ui/gpaste-ui-backup-history.c \ %D%/libgpaste/ui/gpaste-ui-delete-history.c \ %D%/libgpaste/ui/gpaste-ui-delete-item.c \ %D%/libgpaste/ui/gpaste-ui-edit-item.c \ %D%/libgpaste/ui/gpaste-ui-empty-history.c \ %D%/libgpaste/ui/gpaste-ui-empty-item.c \ %D%/libgpaste/ui/gpaste-ui-header.c \ %D%/libgpaste/ui/gpaste-ui-history.c \ %D%/libgpaste/ui/gpaste-ui-history-action.c \ %D%/libgpaste/ui/gpaste-ui-history-actions.c \ %D%/libgpaste/ui/gpaste-ui-item.c \ %D%/libgpaste/ui/gpaste-ui-item-action.c \ %D%/libgpaste/ui/gpaste-ui-item-skeleton.c \ %D%/libgpaste/ui/gpaste-ui-new-item.c \ %D%/libgpaste/ui/gpaste-ui-panel.c \ %D%/libgpaste/ui/gpaste-ui-panel-history.c \ %D%/libgpaste/ui/gpaste-ui-reexec.c \ %D%/libgpaste/ui/gpaste-ui-search.c \ %D%/libgpaste/ui/gpaste-ui-search-bar.c \ %D%/libgpaste/ui/gpaste-ui-settings.c \ %D%/libgpaste/ui/gpaste-ui-shortcuts-window.c \ %D%/libgpaste/ui/gpaste-ui-switch.c \ %D%/libgpaste/ui/gpaste-ui-upload-item.c \ %D%/libgpaste/ui/gpaste-ui-window.c \ %D%/libgpaste/util/gpaste-util.c \ $(NULL) lib_libgpaste_la_SOURCES = \ $(lib_libgpaste_la_private_headers) \ $(lib_libgpaste_la_source_files) \ $(NULL) lib_libgpaste_la_CPPFLAGS = \ $(AM_CPPFLAGS) \ -DG_LOG_DOMAIN=\"GPaste\" \ $(NULL) lib_libgpaste_la_CFLAGS = \ $(GDK_CFLAGS) \ $(GDK_PIXBUF_CFLAGS) \ $(GLIB_CFLAGS) \ $(GTK_CFLAGS) \ $(X11_CFLAGS) \ $(NULL) lib_libgpaste_la_LIBADD = \ $(GDK_LIBS) \ $(GDK_PIXBUF_LIBS) \ $(GLIB_LIBS) \ $(GTK_LIBS) \ $(X11_LIBS) \ $(NULL) libgpaste_symbols_file = $(srcdir)/%D%/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.28.0/src/libgpaste/000077500000000000000000000000001325205405000156245ustar00rootroot00000000000000gpaste-3.28.0/src/libgpaste/client/000077500000000000000000000000001325205405000171025ustar00rootroot00000000000000gpaste-3.28.0/src/libgpaste/client/gpaste-client.c000066400000000000000000002035541325205405000220160ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include "gpaste-gdbus-macros.h" #include #include struct _GPasteClient { GDBusProxy parent_instance; }; G_PASTE_DEFINE_TYPE (Client, client, G_TYPE_DBUS_PROXY) enum { DELETE_HISTORY, EMPTY_HISTORY, ITEM_SELECTED, 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_paste_str_equal (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_paste_str_equal (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) #define NEW_SIGNAL_WITH_DATA_GENERIC(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_generic, \ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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" */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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" */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 (ITEM_SELECTED, guint64 , g_variant_get_uint64 (variant)) 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_paste_str_equal (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 "empty-history" signal is emitted when we empty * an history. */ signals[EMPTY_HISTORY] = NEW_SIGNAL_WITH_DATA ("empty-history", STRING); /** * GPasteClient::item-selected: * @client: the object on which the signal was emitted * @index: the previous index of the item which was selected * * The "item-selected" signal is emitted when we select * an item. */ signals[ITEM_SELECTED] = NEW_SIGNAL_WITH_DATA_GENERIC ("item-selected", UINT64); /** * 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 */ 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.28.0/src/libgpaste/client/gpaste-client.h000066400000000000000000000614731325205405000220250ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/core/000077500000000000000000000000001325205405000165545ustar00rootroot00000000000000gpaste-3.28.0/src/libgpaste/core/gpaste-clipboard.c000066400000000000000000000625411325205405000221500ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include #include #include struct _GPasteClipboard { GObject parent_instance; }; enum { C_OWNER_CHANGE, C_LAST_SIGNAL }; typedef struct { GtkClipboard *real; GPasteSettings *settings; gchar *text; gchar *image_checksum; guint64 c_signals[C_LAST_SIGNAL]; } GPasteClipboardPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (Clipboard, 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) { const GPasteClipboardPrivate *priv = _g_paste_clipboard_get_instance_private (self); if (!priv->text && !priv->image_checksum) { const GList *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, gpointer user_data) { g_object_unref (image); 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 */ 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)); const 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_is_clipboard: * @self: a #GPasteClipboard instance * * Get whether this #GPasteClipboard is a clipboard or not (primary selection) * * Returns: %TRUE if this #GPasteClipboard is a clipboard */ G_PASTE_VISIBLE gboolean g_paste_clipboard_is_clipboard (const GPasteClipboard *self) { g_return_val_if_fail (_G_PASTE_IS_CLIPBOARD (self), FALSE); const GPasteClipboardPrivate *priv = _g_paste_clipboard_get_instance_private (self); return gtk_clipboard_get_selection (priv->real) == GDK_SELECTION_CLIPBOARD; } /** * 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); const 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); const GPasteClipboardPrivate *priv = _g_paste_clipboard_get_instance_private (self); return priv->text; } static const gchar * _g_paste_clipboard_private_target_name (const GPasteClipboardPrivate *priv) { GdkAtom target = gtk_clipboard_get_selection (priv->real); if (target == GDK_SELECTION_CLIPBOARD) return "CLIPBOARD"; else if (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_paste_str_equal (priv->text, to_add)) { if (data->callback) data->callback (self, NULL, data->user_data); return; } if (trim_items && gtk_clipboard_get_selection (priv->real) == GDK_SELECTION_CLIPBOARD && !g_paste_str_equal (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 */ 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)); const 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); } /** * g_paste_clipboard_select_text: * @self: a #GPasteClipboard instance * @text: the text to select * * Put the text into the #GPasteClipbaord and the intern GtkClipboard */ 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); } static void g_paste_clipboard_sync_ready (GtkClipboard *clipboard G_GNUC_UNUSED, const gchar *text, gpointer user_data) { if (text) g_paste_clipboard_select_text (user_data, text); } /** * g_paste_clipboard_sync_text: * @self: the source #GPasteClipboard instance * @other: the target #GPasteClipboard instance * * Synchronise the text between two clipboards */ G_PASTE_VISIBLE void g_paste_clipboard_sync_text (const GPasteClipboard *self, GPasteClipboard *other) { g_return_if_fail (_G_PASTE_IS_CLIPBOARD (self)); g_return_if_fail (_G_PASTE_IS_CLIPBOARD (other)); const GPasteClipboardPrivate *priv = _g_paste_clipboard_get_instance_private (self); gtk_clipboard_request_text (priv->real, g_paste_clipboard_sync_ready, other); } static guchar * copy_str_as_uchars (const gchar *str, guint64 length) { guchar *data = g_new (guchar, length); for (guint64 i = 0; i < length; ++i) data[i] = (guchar) str[i]; return data; } static void _get_clipboard_data_from_special_atom (GtkSelectionData *selection_data, const GPasteItem *item, GPasteSpecialAtom atom) { if (atom >= G_PASTE_SPECIAL_ATOM_FIRST && atom < G_PASTE_SPECIAL_ATOM_LAST) { g_autofree guchar *data = NULL; guint64 length = 0; const gchar *str = g_paste_item_get_special_value (item, atom); if (str) { data = g_base64_decode (str, &length); } else { str = g_paste_item_get_value (item); length = strlen (str); data = copy_str_as_uchars (str, length); } gtk_selection_data_set (selection_data, g_paste_special_atom_get (atom), 8, data, length); } } 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 target = gtk_selection_data_get_target (selection_data); GdkAtom targets[1] = { target }; 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))); return; } else if (_G_PASTE_IS_URIS_ITEM (item)) { if (gtk_targets_include_uri (targets, 1)) { const gchar * const *uris = g_paste_uris_item_get_uris (G_PASTE_URIS_ITEM (item)); gtk_selection_data_set_uris (selection_data, (GStrv) uris); return; } } for (GPasteSpecialAtom a = G_PASTE_SPECIAL_ATOM_FIRST; a < G_PASTE_SPECIAL_ATOM_LAST; ++a) { if (target == g_paste_special_atom_get (a)) { _get_clipboard_data_from_special_atom (selection_data, item, a); return; } } /* 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); } 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); } /** * g_paste_clipboard_clear: * @self: a #GPasteClipboard instance * * Clears the content of the clipboard */ 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_store: * @self: a #GPasteClipboard instance * * Store the contents of the clipboard before exiting */ G_PASTE_VISIBLE void g_paste_clipboard_store (GPasteClipboard *self) { g_return_if_fail (_G_PASTE_IS_CLIPBOARD (self)); GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); g_debug("%s: store", _g_paste_clipboard_private_target_name (priv)); gtk_clipboard_store (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); const 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_paste_util_compute_checksum (image); if (g_paste_str_equal (checksum, priv->image_checksum)) g_clear_object (&image); else g_paste_clipboard_private_select_image (priv, image, checksum); 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 */ 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)); const 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, 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); GtkClipboard *real = priv->real; g_autoptr (GtkTargetList) target_list = gtk_target_list_new (NULL, 0); g_debug("%s: select item", _g_paste_clipboard_private_target_name (priv)); if (_G_PASTE_IS_IMAGE_ITEM (item)) { gtk_target_list_add_image_targets (target_list, 0, FALSE); g_paste_clipboard_private_set_image_checksum (priv, g_paste_image_item_get_checksum (G_PASTE_IMAGE_ITEM (item))); } else { gtk_target_list_add_text_targets (target_list, 0); if (_G_PASTE_IS_URIS_ITEM (item)) gtk_target_list_add_uri_targets (target_list, 0); g_paste_clipboard_private_set_text (priv, g_paste_item_get_real_value (item)); } for (const GSList *sv = g_paste_item_get_special_values (item); sv; sv = sv->next) { const GPasteSpecialValue *v = sv->data; gtk_target_list_add (target_list, g_paste_special_atom_get (v->mime), 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 ((GObject *) item)); gtk_target_table_free (targets, n_targets); 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) */ 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 GList *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; const GPasteClipboardPrivate *priv = _g_paste_clipboard_get_instance_private (self); if (!g_paste_str_equal (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; const GPasteClipboardPrivate *priv = _g_paste_clipboard_get_instance_private (self); g_autofree gchar *checksum = g_paste_util_compute_checksum (image); if (!g_paste_str_equal (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; const 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) { const GPasteClipboardPrivate *priv = _g_paste_clipboard_get_instance_private (G_PASTE_CLIPBOARD (object)); if (priv->settings) { g_signal_handler_disconnect (priv->real, priv->c_signals[C_OWNER_CHANGE]); g_clear_object (&priv->settings); } G_OBJECT_CLASS (g_paste_clipboard_parent_class)->dispose (object); } static void g_paste_clipboard_finalize (GObject *object) { const 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 G_GNUC_UNUSED) { } static GPasteClipboard * _g_paste_clipboard_new (GPasteSettings *settings, GdkAtom target) { GPasteClipboard *self = g_object_new (G_PASTE_TYPE_CLIPBOARD, NULL); GPasteClipboardPrivate *priv = g_paste_clipboard_get_instance_private (self); GtkClipboard *real = priv->real = gtk_clipboard_get (target); priv->settings = g_object_ref (settings); priv->c_signals[C_OWNER_CHANGE] = 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; } /** * g_paste_clipboard_new_clipboard: * @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_clipboard (GPasteSettings *settings) { g_return_val_if_fail (_G_PASTE_IS_SETTINGS (settings), NULL); return _g_paste_clipboard_new (settings, GDK_SELECTION_CLIPBOARD); } /** * g_paste_clipboard_new_primary: * @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_primary (GPasteSettings *settings) { g_return_val_if_fail (_G_PASTE_IS_SETTINGS (settings), NULL); return _g_paste_clipboard_new (settings, GDK_SELECTION_PRIMARY); } gpaste-3.28.0/src/libgpaste/core/gpaste-clipboard.h000066400000000000000000000054141325205405000221510ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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) 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); gboolean g_paste_clipboard_is_clipboard (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_sync_text (const GPasteClipboard *self, GPasteClipboard *other); void g_paste_clipboard_clear (GPasteClipboard *self); void g_paste_clipboard_store (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, GPasteItem *item); void g_paste_clipboard_ensure_not_empty (GPasteClipboard *self, GPasteHistory *history); GPasteClipboard *g_paste_clipboard_new_clipboard (GPasteSettings *settings); GPasteClipboard *g_paste_clipboard_new_primary (GPasteSettings *settings); G_END_DECLS #endif /*__G_PASTE_CLIPBOARD_H__*/ gpaste-3.28.0/src/libgpaste/core/gpaste-clipboards-manager.c000066400000000000000000000420461325205405000237410ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include struct _GPasteClipboardsManager { GObject parent_instance; }; enum { C_CLIP_OWNER_CHANGE, C_CLIP_LAST_SIGNAL }; typedef struct { GPasteClipboard *clipboard; guint64 c_signals[C_CLIP_LAST_SIGNAL]; } _Clipboard; enum { C_SELECTED, C_LAST_SIGNAL }; typedef struct { GSList *clipboards; GPasteHistory *history; GPasteSettings *settings; guint64 c_signals[C_LAST_SIGNAL]; } GPasteClipboardsManagerPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (ClipboardsManager, 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 */ 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); } /** * g_paste_clipboards_manager_sync_from_to: * @self: a #GPasteClipboardsManager instance * @from_clipboard: whether we sync from clipboard or to clipboard * * Sync a clipboard into another */ G_PASTE_VISIBLE void g_paste_clipboards_manager_sync_from_to (GPasteClipboardsManager *self, gboolean from_clipboard) { g_return_if_fail (_G_PASTE_IS_CLIPBOARDS_MANAGER (self)); const GPasteClipboardsManagerPrivate *priv = _g_paste_clipboards_manager_get_instance_private (self); GPasteClipboard *_from = NULL; GPasteClipboard *_to = NULL; g_debug ("clipboards-manager: sync_from_to"); for (GSList *clipboard = priv->clipboards; clipboard; clipboard = g_slist_next (clipboard)) { _Clipboard *_clip = clipboard->data; GPasteClipboard *clip = _clip->clipboard; if (g_paste_clipboard_is_clipboard (clip) == from_clipboard) _from = clip; else _to = clip; } if (_from && _to) g_paste_clipboard_sync_text (_from, _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) { g_debug ("clipboards-manager: synchronizing clipboards"); 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_paste_str_equal (text, synchronized_text)) g_paste_clipboard_select_text (clip, synchronized_text); } } } typedef struct { GPasteClipboardsManagerPrivate *priv; GPasteClipboard *clip; gboolean track; gboolean uris_available; gboolean fallback; gboolean special_atom_available[G_PASTE_SPECIAL_ATOM_LAST]; } GPasteClipboardsManagerCallbackData; typedef struct { GPasteHistory *history; GPasteItem *item; GPasteSpecialAtom atom; } GPasteSpecialAtomCallbackData; // TODO: move that to g_paste_clipboard ? static void special_contents_received (GtkClipboard *clipboard G_GNUC_UNUSED, GtkSelectionData *selection_data, gpointer data) { g_autofree GPasteSpecialAtomCallbackData *d = data; g_autoptr (GPasteHistory) history = d->history; g_autoptr (GPasteItem) item = d->item; gint length; const guchar *raw_val = gtk_selection_data_get_data_with_length (selection_data, &length); if (raw_val) { g_autofree gchar *val = g_base64_encode (raw_val, length); g_autofree GPasteSpecialValue *v = g_new (GPasteSpecialValue, 1); v->mime = d->atom; v->data = val; guint64 old_size = g_paste_item_get_size (item); g_paste_item_add_special_value (item, v); g_paste_history_refresh_item_size (history, item, old_size); } } 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; } else if (data->fallback) { g_debug ("clipboards-manager: no target ready and text fallback failed"); /* We tried to get some text as fallback (no target advertised) but didn't get any */ g_paste_clipboard_clear (data->clip); g_paste_clipboard_ensure_not_empty (data->clip, priv->history); return; } if (item && g_paste_settings_get_rich_text_support (priv->settings)) { for (GPasteSpecialAtom atom = G_PASTE_SPECIAL_ATOM_FIRST; atom < G_PASTE_SPECIAL_ATOM_LAST; ++atom) { if (data->special_atom_available[atom]) { GPasteSpecialAtomCallbackData *d = g_new (GPasteSpecialAtomCallbackData, 1); d->history = g_object_ref (priv->history); d->item = g_object_ref (item); d->atom = atom; gtk_clipboard_request_contents (g_paste_clipboard_get_real (clipboard), g_paste_special_atom_get (atom), special_contents_received, d); } } } 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; g_autoptr (GdkPixbuf) img = image; 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); } /* TODO: move part of this to GPasteClipboard to drop all set_* */ static void g_paste_clipboards_manager_targets_ready (GtkClipboard *clipboard G_GNUC_UNUSED, GtkSelectionData *_targets, gpointer user_data) { g_autofree GPasteClipboardsManagerCallbackData *data = user_data; GPasteClipboardsManagerPrivate *priv = data->priv; g_debug ("clipboards-manager: targets ready"); if (gtk_selection_data_get_length (_targets) >= 0) { g_autofree GdkAtom *targets = NULL; gint n_targets; gtk_selection_data_get_targets (_targets, &targets, &n_targets); data->uris_available = gtk_targets_include_uri (targets, n_targets); for (GPasteSpecialAtom atom = G_PASTE_SPECIAL_ATOM_FIRST; atom < G_PASTE_SPECIAL_ATOM_LAST; ++atom) { for (gint i = 0; i < n_targets; ++i) { if (targets[i] == g_paste_special_atom_get (atom)) data->special_atom_available[atom] = TRUE; } } if (data->uris_available || gtk_targets_include_text (targets, n_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 (priv->settings) && gtk_targets_include_image (targets, n_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, trying text as fallback"); data->fallback = TRUE; g_paste_clipboard_set_text (data->clip, g_paste_clipboards_manager_text_ready, data); data = NULL; } } static void g_paste_clipboards_manager_notify (GPasteClipboard *clipboard, GdkEventOwnerChange *event, gpointer user_data) { GPasteClipboardsManagerPrivate *priv = user_data; if (event->reason != GDK_OWNER_CHANGE_NEW_OWNER) { g_debug ("clipboards-manager: ignoring deletion event"); return; } g_debug ("clipboards-manager: notify"); GPasteSettings *settings = priv->settings; gboolean track = (g_paste_settings_get_track_changes (settings) && (g_paste_clipboard_is_clipboard (clipboard) || // We're not primary g_paste_settings_get_primary_to_history (settings) || // Or we asked that primary affects clipboard g_paste_settings_get_synchronize_clipboards (settings))); // Or primary and clipboards are synchronized hence primary will affect history through clipboard GPasteClipboardsManagerCallbackData *data = g_new0 (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 */ 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->c_signals[C_CLIP_OWNER_CHANGE] = 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, 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); const 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; } /** * g_paste_clipboards_manager_store: * @self: a #GPasteClipboardsManager instance * * Store clipboards contents before exiting */ G_PASTE_VISIBLE void g_paste_clipboards_manager_store (GPasteClipboardsManager *self) { g_return_if_fail (_G_PASTE_IS_CLIPBOARDS_MANAGER (self)); const GPasteClipboardsManagerPrivate *priv = _g_paste_clipboards_manager_get_instance_private (self); g_debug ("clipboards-manager: store"); for (GSList *clipboard = priv->clipboards; clipboard; clipboard = g_slist_next (clipboard)) { _Clipboard *clip = clipboard->data; g_paste_clipboard_store (clip->clipboard); } } 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->c_signals[C_CLIP_OWNER_CHANGE]); 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->c_signals[C_SELECTED]); 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 G_GNUC_UNUSED) { } /** * 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->c_signals[C_SELECTED] = g_signal_connect_swapped (history, "selected", G_CALLBACK (on_item_selected), self); return self; } gpaste-3.28.0/src/libgpaste/core/gpaste-clipboards-manager.h000066400000000000000000000026531325205405000237460ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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, gboolean from_clipboard); void g_paste_clipboards_manager_activate (GPasteClipboardsManager *self); gboolean g_paste_clipboards_manager_select (GPasteClipboardsManager *self, GPasteItem *item); void g_paste_clipboards_manager_store (GPasteClipboardsManager *self); GPasteClipboardsManager *g_paste_clipboards_manager_new (GPasteHistory *history, GPasteSettings *settings); G_END_DECLS #endif /*__G_PASTE_CLIPBOARDS_MANAGER_H__*/ gpaste-3.28.0/src/libgpaste/core/gpaste-history.c000066400000000000000000001051521325205405000217060ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include #include #include #include #include struct _GPasteHistory { GObject parent_instance; }; enum { C_CHANGED, C_LAST_SIGNAL }; typedef struct { GPasteStorageBackend *backend; GPasteSettings *settings; GList *history; guint64 size; gchar *name; /* Note: we never track the first (active) item here */ guint64 biggest_index; guint64 biggest_size; guint64 c_signals[C_LAST_SIGNAL]; } GPasteHistoryPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (History, 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; GList *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 void g_paste_history_private_remove (GPasteHistoryPrivate *priv, GList *elem, gboolean remove_leftovers) { if (!elem) return; 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); } priv->history = g_list_delete_link (priv->history, 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); GList *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) { GList *biggest = g_list_nth (priv->history, priv->biggest_index); g_return_if_fail (biggest); g_paste_history_private_remove (priv, biggest, TRUE); g_paste_history_private_elect_new_biggest (priv); } } static void g_paste_history_private_check_size (GPasteHistoryPrivate *priv) { GList *history = priv->history; guint64 max_history_size = g_paste_settings_get_max_history_size (priv->settings); guint64 length = g_list_length (history); if (length > max_history_size) { history = g_list_nth (history, max_history_size); g_return_if_fail (history); history->prev->next = NULL; history->prev = NULL; for (GList *_history = history; _history; _history = g_list_next (_history)) priv->size -= g_paste_item_get_size (_history->data); g_list_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)); } static void _g_paste_history_add (GPasteHistory *self, GPasteItem *item, gboolean new_selection) { 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; if (g_paste_item_get_size (item) > max_memory) return; GList *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 (new_selection && g_paste_history_private_is_growing_line (priv, old_first, item)) { target = G_PASTE_UPDATE_TARGET_POSITION; 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; } guint64 index = 1; for (history = history->next; history; history = history->next, ++index) { if (g_paste_item_equals (history->data, item) || (new_selection && g_paste_history_private_is_growing_line (priv, history->data, item))) { g_paste_history_private_remove (priv, history, FALSE); if (index == priv->biggest_index) election_needed = TRUE; break; } } ++priv->biggest_index; } } priv->history = g_list_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_add: * @self: a #GPasteHistory instance * @item: (transfer full): the #GPasteItem to add * * Add a #GPasteItem to the #GPasteHistory */ 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)); _g_paste_history_add (self, item, TRUE); } /** * g_paste_history_remove: * @self: a #GPasteHistory instance * @index: the index of the #GPasteItem to delete * * Delete a #GPasteItem from the #GPasteHistory */ 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); GList *history = priv->history; g_debug ("history: remove '%" G_GUINT64_FORMAT "'", pos); g_return_if_fail (pos < g_list_length (history)); GList *item = g_list_nth (history, pos); g_return_if_fail (item); g_paste_history_private_remove (priv, item, TRUE); if (!pos) 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); } /** * g_paste_history_refresh_item_size: * @self: a #GPasteHistory instance * @item: the #GPasteItem to refresh * @old_size: the former size of the item * * Refresh the cached size of the #GPasteItem */ G_PASTE_VISIBLE void g_paste_history_refresh_item_size (GPasteHistory *self, const GPasteItem *item, guint64 old_size) { 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); if (!g_list_find (priv->history, item)) return; guint64 size = g_paste_item_get_size (item); g_return_if_fail (old_size <= size); priv->size += (size - old_size); if (size > priv->biggest_size) g_paste_history_private_elect_new_biggest (priv); g_paste_history_private_check_memory_usage (priv); } static GPasteItem * g_paste_history_private_get (const GPasteHistoryPrivate *priv, guint64 pos) { GList *history = priv->history; if (pos >= g_list_length (history)) return NULL; return G_PASTE_ITEM (g_list_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); const 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); const 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 */ G_PASTE_VISIBLE void g_paste_history_select (GPasteHistory *self, guint64 index) { g_return_if_fail (_G_PASTE_IS_HISTORY (self)); const GPasteHistoryPrivate *priv = _g_paste_history_get_instance_private (self); GList *history = priv->history; g_debug ("history: select '%" G_GUINT64_FORMAT "'", index); g_return_if_fail (index < g_list_length (history)); GPasteItem *item = g_list_nth_data (history, index); _g_paste_history_add (self, item, FALSE); g_paste_history_selected (self, item); } static void _g_paste_history_replace (GPasteHistory *self, guint64 index, GPasteItem *new, GList *todel) { GPasteHistoryPrivate *priv = g_paste_history_get_instance_private (self); GPasteItem *old = todel->data; priv->size -= g_paste_item_get_size (old); priv->size += g_paste_item_get_size (new); g_object_unref (old); todel->data = new; 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 */ 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)); const GPasteHistoryPrivate *priv = _g_paste_history_get_instance_private (self); GList *history = priv->history; g_return_if_fail (index < g_list_length (history)); GList *todel = g_list_nth (history, index); g_return_if_fail (todel); GPasteItem *item = todel->data; g_return_if_fail (_G_PASTE_IS_TEXT_ITEM (item) && g_paste_str_equal (g_paste_item_get_kind (item), "Text")); GPasteItem *new = g_paste_text_item_new (contents); _g_paste_history_replace (self, index, new, todel); if (!index) g_paste_history_selected (self, new); } static GPasteItem * _g_paste_history_private_get_password (const GPasteHistoryPrivate *priv, const gchar *name, guint64 *index) { guint64 idx = 0; for (GList *h = priv->history; h; h = g_list_next (h), ++idx) { GPasteItem *i = h->data; if (_G_PASTE_IS_PASSWORD_ITEM (i) && g_paste_str_equal (g_paste_password_item_get_name ((GPastePasswordItem *) i), name)) { if (index) *index = idx; return i; } } if (index) *index = -1; return NULL; } /** * 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 */ 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)); const GPasteHistoryPrivate *priv = _g_paste_history_get_instance_private (self); GList *history = priv->history; g_return_if_fail (index < g_list_length (history)); GList *todel = g_list_nth (history, index); g_return_if_fail (todel); GPasteItem *item = todel->data; g_return_if_fail (_G_PASTE_IS_TEXT_ITEM (item) && g_paste_str_equal (g_paste_item_get_kind (item), "Text")); g_return_if_fail (!_g_paste_history_private_get_password (priv, name, NULL)); GPasteItem *password = g_paste_password_item_new (name, g_paste_item_get_real_value (item)); _g_paste_history_replace (self, index, password, todel); } /** * g_paste_history_get_password: * @self: a #GPasteHistory instance * @name: the name of the #GPastePasswordItem * * Get the first password matching name * * Returns: (nullable): 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); const 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 */ 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)); const 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 */ 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)); const 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 */ 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_list_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); } /** * 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 */ G_PASTE_VISIBLE void g_paste_history_save (GPasteHistory *self, const gchar *name) { g_return_if_fail (_G_PASTE_IS_HISTORY (self)); const GPasteHistoryPrivate *priv = _g_paste_history_get_instance_private (self); g_paste_storage_backend_write_history (priv->backend, (name) ? name : priv->name, priv->history); } /** * 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 */ 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); if (priv->name && g_paste_str_equal(name, priv->name)) return; g_list_free_full (priv->history, g_object_unref); priv->history = NULL; priv->size = 0; g_free (priv->name); priv->name = g_strdup ((name) ? name : g_paste_settings_get_history_name (priv->settings)); g_paste_storage_backend_read_history (priv->backend, priv->name, &priv->history, &priv->size); 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 */ 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)); const 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 */ G_PASTE_VISIBLE void g_paste_history_delete (GPasteHistory *self, const gchar *name, GError **error) { g_return_if_fail (_G_PASTE_IS_HISTORY (self)); const GPasteHistoryPrivate *priv = _g_paste_history_get_instance_private (self); g_autoptr (GFile) history_file = g_paste_util_get_history_file ((name) ? name : priv->name, "xml"); if (g_paste_str_equal (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) { const 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_paste_str_equal(key, G_PASTE_MAX_HISTORY_SIZE_SETTING)) g_paste_history_private_check_size (priv); else if (g_paste_str_equal (key, G_PASTE_MAX_MEMORY_USAGE_SETTING)) g_paste_history_private_check_memory_usage (priv); else if (g_paste_str_equal (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); const GPasteHistoryPrivate *priv = _g_paste_history_get_instance_private (self); GPasteSettings *settings = priv->settings; g_clear_object (&priv->backend); if (settings) { g_signal_handler_disconnect (settings, priv->c_signals[C_CHANGED]); g_clear_object (&priv->settings); } G_OBJECT_CLASS (g_paste_history_parent_class)->dispose (object); } static void g_paste_history_finalize (GObject *object) { const GPasteHistoryPrivate *priv = _g_paste_history_get_instance_private (G_PASTE_HISTORY (object)); g_free (priv->name); g_list_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); 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 GList * g_paste_history_get_history (const GPasteHistory *self) { g_return_val_if_fail (_G_PASTE_IS_HISTORY (self), NULL); const 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); const GPasteHistoryPrivate *priv = _g_paste_history_get_instance_private (self); return g_list_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); const 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); const 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 (GList *history = priv->history; history; history = g_list_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->backend = g_paste_storage_backend_new (G_PASTE_STORAGE_DEFAULT, settings); priv->settings = g_object_ref (settings); priv->c_signals[C_CHANGED] = 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_util_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.28.0/src/libgpaste/core/gpaste-history.h000066400000000000000000000076131325205405000217160ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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_refresh_item_size (GPasteHistory *self, const GPasteItem *item, guint64 old_size); 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 GList *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.28.0/src/libgpaste/core/gpaste-image-item.c000066400000000000000000000214241325205405000222220ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include #include struct _GPasteImageItem { GPasteItem parent_instance; }; typedef struct _GPasteImageItemPrivate { gchar *checksum; GDateTime *date; GdkPixbuf *image; guint64 additional_size; } GPasteImageItemPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (ImageItem, 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); const 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); const 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); const 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; const GPasteImageItemPrivate *priv = _g_paste_image_item_get_instance_private (_G_PASTE_IMAGE_ITEM (self)); const GPasteImageItemPrivate *_priv = _g_paste_image_item_get_instance_private (_G_PASTE_IMAGE_ITEM (other)); return g_paste_str_equal (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) { const 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.28.0/src/libgpaste/core/gpaste-image-item.h000066400000000000000000000017401325205405000222260ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/core/gpaste-item-enums.c000066400000000000000000000016351325205405000222710ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/core/gpaste-item-enums.h000066400000000000000000000012751325205405000222760ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/core/gpaste-item.c000066400000000000000000000227761325205405000211550ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include typedef struct { gchar *value; GSList *special_values; gchar *display_string; guint64 size; } GPasteItemPrivate; G_PASTE_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (Item, 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); const GPasteItemPrivate *priv = _g_paste_item_get_instance_private (self); return priv->value; } /** * g_paste_item_get_special_values: * @self: a #GPasteItem instance * * Get the special values (special mime types) for an item * * Returns: (element-type GPasteSpecialValue): read-only list containing the special values */ G_PASTE_VISIBLE const GSList * g_paste_item_get_special_values (const GPasteItem *self) { g_return_val_if_fail (_G_PASTE_IS_ITEM (self), NULL); const GPasteItemPrivate *priv = _g_paste_item_get_instance_private (self); return priv->special_values; } /** * g_paste_item_get_special_value: * @self: a #GPasteItem instance * @atom: the value we want to get * * Get the special value (special mime type) for an item * * Returns: read-only special value */ G_PASTE_VISIBLE const gchar * g_paste_item_get_special_value (const GPasteItem *self, GPasteSpecialAtom atom) { g_return_val_if_fail (_G_PASTE_IS_ITEM (self), NULL); const GPasteItemPrivate *priv = _g_paste_item_get_instance_private (self); for (GSList *sv = priv->special_values; sv; sv = sv->next) { GPasteSpecialValue *v = sv->data; if (v->mime == atom) return v->data; } return NULL; } /** * 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); const 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_CLASS (other)->equals (other, self); } /** * 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); const 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); const 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 */ 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 */ 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 */ 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 */ 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_add_special_value: * @self: a #GPasteItem instance * @special_value: the special value * * Add the special values (special mime types) for an item */ G_PASTE_VISIBLE void g_paste_item_add_special_value (GPasteItem *self, const GPasteSpecialValue *special_value) { g_return_if_fail (_G_PASTE_IS_ITEM (self)); GPasteItemPrivate *priv = g_paste_item_get_instance_private (self); GPasteSpecialValue *gsv = g_new (GPasteSpecialValue, 1); gsv->mime = special_value->mime; gsv->data = g_strdup (special_value->data); priv->special_values = g_slist_prepend (priv->special_values, gsv); priv->size += strlen (gsv->data); } /** * g_paste_item_set_state: * @self: a #GPasteItem instance * @state: a #GPasteItemState * * Set whether this item is Active or Idle */ 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) { const GPasteItemPrivate *priv = _g_paste_item_get_instance_private (G_PASTE_ITEM (object)); g_free (priv->value); g_free (priv->display_string); for (GSList *sv = priv->special_values; sv; sv = sv->next) { GPasteSpecialValue *gsv = sv->data; g_free (gsv->data); g_free (gsv); } g_slist_free (priv->special_values); 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; const GPasteItemPrivate *priv = _g_paste_item_get_instance_private (self); const GPasteItemPrivate *_priv = _g_paste_item_get_instance_private (other); return g_paste_str_equal (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.28.0/src/libgpaste/core/gpaste-item.h000066400000000000000000000051461325205405000211520ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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; typedef struct { GPasteSpecialAtom mime; gchar *data; } GPasteSpecialValue; #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 GSList *g_paste_item_get_special_values (const GPasteItem *self); const gchar *g_paste_item_get_special_value (const GPasteItem *self, GPasteSpecialAtom atom); 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_add_special_value (GPasteItem *self, const GPasteSpecialValue *special_value); 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.28.0/src/libgpaste/core/gpaste-password-item.c000066400000000000000000000077621325205405000230130ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include struct _GPastePasswordItem { GPasteTextItem parent_instance; }; typedef struct { gchar *name; } GPastePasswordItemPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (PasswordItem, 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); const 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 */ 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) { const 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 G_GNUC_UNUSED) { } /** * 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.28.0/src/libgpaste/core/gpaste-password-item.h000066400000000000000000000016071325205405000230100ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/core/gpaste-special-atom.c000066400000000000000000000035651325205405000225700ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include static GdkAtom special_atoms[G_PASTE_SPECIAL_ATOM_LAST] = { 0 }; static void g_paste_special_atom_init(void) { static gboolean inited = FALSE; if (!inited) { g_debug("atoms init"); special_atoms[G_PASTE_SPECIAL_ATOM_GNOME_COPIED_FILES] = gdk_atom_intern_static_string ("x-special/gnome-copied-files"); special_atoms[G_PASTE_SPECIAL_ATOM_TEXT_HTML] = gdk_atom_intern_static_string ("text/html"); special_atoms[G_PASTE_SPECIAL_ATOM_TEXT_XML] = gdk_atom_intern_static_string ("text/xml"); inited = TRUE; } } G_PASTE_VISIBLE GType g_paste_special_atom_get_type (void) { static GType etype = 0; if (!etype) { g_paste_special_atom_init (); static const GEnumValue values[] = { { G_PASTE_SPECIAL_ATOM_GNOME_COPIED_FILES, "G_PASTE_SPECIAL_ATOM_GNOME_COPIED_FILES", "gnome-copied-files" }, { G_PASTE_SPECIAL_ATOM_TEXT_HTML, "G_PASTE_SPECIAL_ATOM_TEXT_HTML", "text-html" }, { G_PASTE_SPECIAL_ATOM_TEXT_XML, "G_PASTE_SPECIAL_ATOM_TEXT_XML", "text-xml" }, { G_PASTE_SPECIAL_ATOM_INVALID, NULL, NULL }, }; etype = g_enum_register_static (g_intern_static_string ("GPasteSpecialAtom"), values); g_type_class_ref (etype); } return etype; } /** * g_paste_special_atom_get * @atom: the atom we want to get * * Find special atoms handled by GPaste * * Returns: (transfer none): the atom corresponding to @atom */ G_PASTE_VISIBLE GdkAtom g_paste_special_atom_get (GPasteSpecialAtom atom) { g_paste_special_atom_init (); return special_atoms[atom]; } gpaste-3.28.0/src/libgpaste/core/gpaste-special-atom.h000066400000000000000000000015521325205405000225670ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #include #ifndef __G_PASTE_SPECIAL_ATOM_H__ #define __G_PASTE_SPECIAL_ATOM_H__ G_BEGIN_DECLS typedef enum { G_PASTE_SPECIAL_ATOM_FIRST, G_PASTE_SPECIAL_ATOM_GNOME_COPIED_FILES = G_PASTE_SPECIAL_ATOM_FIRST, G_PASTE_SPECIAL_ATOM_TEXT_HTML, G_PASTE_SPECIAL_ATOM_TEXT_XML, G_PASTE_SPECIAL_ATOM_LAST, G_PASTE_SPECIAL_ATOM_INVALID = -1 } GPasteSpecialAtom; #define G_PASTE_TYPE_SPECIAL_ATOM (g_paste_special_atom_get_type ()) GType g_paste_special_atom_get_type (void); GdkAtom g_paste_special_atom_get (GPasteSpecialAtom atom); G_END_DECLS #endif /*__G_PASTE_SPECIAL_ATOM_H__*/ gpaste-3.28.0/src/libgpaste/core/gpaste-text-item.c000066400000000000000000000025261325205405000221260ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include G_PASTE_DEFINE_TYPE (TextItem, 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.28.0/src/libgpaste/core/gpaste-text-item.h000066400000000000000000000012251325205405000221260ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/core/gpaste-update-enums.c000066400000000000000000000025501325205405000226120ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/core/gpaste-update-enums.h000066400000000000000000000016571325205405000226260ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/core/gpaste-uris-item.c000066400000000000000000000065411325205405000221250ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include struct _GPasteUrisItem { GPasteTextItem parent_instance; }; typedef struct { GStrv uris; } GPasteUrisItemPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (UrisItem, 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); const 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) { const 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.28.0/src/libgpaste/core/gpaste-uris-item.h000066400000000000000000000012451325205405000221260ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/daemon/000077500000000000000000000000001325205405000170675ustar00rootroot00000000000000gpaste-3.28.0/src/libgpaste/daemon/gpaste-bus-object.c000066400000000000000000000022421325205405000225510ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include "gpaste-bus-object.h" G_PASTE_DEFINE_ABSTRACT_TYPE (BusObject, 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.28.0/src/libgpaste/daemon/gpaste-bus-object.h000066400000000000000000000020531325205405000225560ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/daemon/gpaste-bus.c000066400000000000000000000107041325205405000213070ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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_PASTE_DEFINE_TYPE_WITH_PRIVATE (Bus, 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 */ 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) (nullable): 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); const GPasteBusPrivate *priv = _g_paste_bus_get_instance_private (self); return priv->connection; } static void g_paste_bus_dispose (GObject *object) { const 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 G_GNUC_UNUSED) { } /** * 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.28.0/src/libgpaste/daemon/gpaste-bus.h000066400000000000000000000015411325205405000213130ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/daemon/gpaste-daemon.c000066400000000000000000001301561325205405000217650ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include "gpaste-gdbus-macros.h" #include #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; guint64 c_signals[C_LAST_SIGNAL]; } GPasteDaemonPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (Daemon, 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) { const 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 */ G_PASTE_VISIBLE void g_paste_daemon_show_history (GPasteDaemon *self, GError **error) { g_return_if_fail (_G_PASTE_IS_DAEMON (self)); const 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) { const 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 (const 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 (const 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 (const 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 (const 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)) { if (g_utf8_validate (content, length, NULL)) { g_paste_daemon_private_do_add (priv, content, length, err); } else { g_autoptr (GdkPixbuf) img = gdk_pixbuf_new_from_file (file, NULL /* Error */); g_paste_daemon_private_do_add_item (priv, g_paste_image_item_new (img)); } } } static void g_paste_daemon_private_add_password (const 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_history_delete_password (priv->history, name); g_paste_daemon_private_do_add_item (priv, g_paste_password_item_new (name, password)); } static void g_paste_daemon_private_delete_history_signal (const 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 (const 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 (const 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 (const 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 (const 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 (const 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_paste_str_equal (name, g_paste_history_get_current (priv->history))) g_paste_history_switch (history, G_PASTE_DEFAULT_HISTORY); } static void g_paste_daemon_private_delete_password (const 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 (const GPasteDaemonPrivate *priv, GVariant *parameters) { g_autofree gchar *name = g_paste_daemon_get_dbus_string_parameter (parameters, NULL); if (g_paste_str_equal (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 (const 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 (const 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 (const 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 (const GPasteDaemonPrivate *priv) { const GList *history = g_paste_history_get_history (priv->history); guint64 length = g_list_length ((GList *) history); g_autofree const gchar **displayed_history = g_new (const gchar *, length + 1); for (guint64 i = 0; i < length; ++i, history = g_list_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 (const 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 (const GPasteDaemonPrivate *priv, GVariant *parameters) { g_autofree gchar *name = g_paste_daemon_get_dbus_string_parameter (parameters, NULL); guint64 size; if (g_paste_str_equal (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 (const 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 (const GPasteDaemonPrivate *priv) { const GList *history = g_paste_history_get_history (priv->history); guint64 length = g_list_length ((GList *) history); g_autofree const gchar **displayed_history = g_new (const gchar *, length + 1); for (guint64 i = 0; i < length; ++i, history = g_list_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 (const 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); const 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) { const 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) { const GPasteDaemonPrivate *priv = _g_paste_daemon_get_instance_private (self); g_paste_clipboards_manager_store (priv->clipboards_manager); g_signal_emit (self, signals[REEXECUTE_SELF], 0, /* detail */ NULL); } static void g_paste_daemon_private_rename_password (const 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 (const 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_select (const GPasteDaemon *self, GVariant *parameters) { const GPasteDaemonPrivate *priv = _g_paste_daemon_get_instance_private (self); guint64 position = g_paste_daemon_get_dbus_uint64_parameter (parameters); g_paste_history_select (priv->history, position); G_PASTE_SEND_DBUS_SIGNAL_FULL (ITEM_SELECTED, g_variant_new_uint64 (position), NULL); } static void g_paste_daemon_private_replace (const 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_paste_str_equal (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 (const 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_paste_str_equal (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_DBUS_ASSERT (!g_paste_history_get_password (priv->history, name), "a password with tat name already exists"); g_paste_history_set_password (priv->history, index, name); } static void g_paste_daemon_private_switch_history (const 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 */ 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) { const 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; const GPasteDaemonPrivate *priv = _g_paste_daemon_get_instance_private (self); GVariant *answer = NULL; GError *error = NULL; g_autofree GPasteDBusError *err = NULL; if (g_paste_str_equal (method_name, G_PASTE_DAEMON_ABOUT)) g_paste_util_activate_ui ("about", NULL); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_ADD)) g_paste_daemon_private_add (priv, parameters, &err); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_ADD_FILE)) g_paste_daemon_private_add_file (priv, parameters, &error, &err); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_ADD_PASSWORD)) g_paste_daemon_private_add_password (priv, parameters, &err); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_BACKUP_HISTORY)) g_paste_daemon_private_backup_history (priv, parameters, &err); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_DELETE)) g_paste_daemon_private_delete (priv, parameters); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_DELETE_HISTORY)) g_paste_daemon_private_delete_history (priv, parameters, &err); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_DELETE_PASSWORD)) g_paste_daemon_private_delete_password (priv, parameters, &err); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_EMPTY_HISTORY)) g_paste_daemon_private_empty_history (priv, parameters); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_GET_ELEMENT)) answer = g_paste_daemon_private_get_element (priv, parameters, &err); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_GET_ELEMENT_KIND)) answer = g_paste_daemon_private_get_element_kind (priv, parameters, &err); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_GET_ELEMENTS)) answer = g_paste_daemon_private_get_elements (priv, parameters, &err); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_GET_HISTORY)) answer = g_paste_daemon_private_get_history (priv); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_GET_HISTORY_NAME)) answer = g_paste_daemon_private_get_history_name (priv); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_GET_HISTORY_SIZE)) answer = g_paste_daemon_private_get_history_size (priv, parameters); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_GET_RAW_ELEMENT)) answer = g_paste_daemon_private_get_raw_element (priv, parameters, &err); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_GET_RAW_HISTORY)) answer = g_paste_daemon_private_get_raw_history (priv); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_LIST_HISTORIES)) answer = g_paste_daemon_list_histories (&error); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_MERGE)) g_paste_daemon_private_merge (priv, parameters, &err); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_ON_EXTENSION_STATE_CHANGED)) g_paste_daemon_on_extension_state_changed (self, parameters); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_REEXECUTE)) g_paste_daemon_reexecute (self); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_RENAME_PASSWORD)) g_paste_daemon_private_rename_password (priv, parameters, &err); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_REPLACE)) g_paste_daemon_private_replace (priv, parameters, &err); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_SEARCH)) answer = g_paste_daemon_private_search (priv, parameters, &err); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_SELECT)) g_paste_daemon_select (self, parameters); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_SET_PASSWORD)) g_paste_daemon_private_set_password (priv, parameters, &err); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_SHOW_HISTORY)) g_paste_daemon_show_history (self, &error); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_SWITCH_HISTORY)) g_paste_daemon_private_switch_history (priv, parameters, &err); else if (g_paste_str_equal (method_name, G_PASTE_DAEMON_TRACK)) g_paste_daemon_track (self, parameters); else if (g_paste_str_equal (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) { const GPasteDaemonPrivate *priv = _g_paste_daemon_get_instance_private (G_PASTE_DAEMON (user_data)); if (g_paste_str_equal (property_name, G_PASTE_DAEMON_PROP_ACTIVE)) return g_variant_new_boolean (g_paste_settings_get_track_changes (priv->settings)); else if (g_paste_str_equal (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); guint64 *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) { g_autoptr (GPasteItem) item = g_paste_history_dup (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) { const 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; guint64 *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_clipboard (settings); g_autoptr (GPasteClipboard) primary = g_paste_clipboard_new_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.28.0/src/libgpaste/daemon/gpaste-daemon.h000066400000000000000000000014201325205405000217610ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/daemon/gpaste-search-provider.c000066400000000000000000000336041325205405000236170ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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_PASTE_DEFINE_TYPE_WITH_PRIVATE (SearchProvider, 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 (const GPasteSearchProviderPrivate *priv, 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 (const 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 (const 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", G_PASTE_ICON_NAME); append_dict_entry (&dict, "clipboardText", results[i]); 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 (const 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 (const 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 (const GPasteSearchProviderPrivate *priv G_GNUC_UNUSED, GVariant *parameters) { 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; const GPasteSearchProviderPrivate *priv = _g_paste_search_provider_get_instance_private (self); gboolean async = FALSE; if (g_paste_str_equal (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_paste_str_equal (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_paste_str_equal (method_name, G_PASTE_SEARCH_PROVIDER_GET_RESULT_METAS)) async = g_paste_search_provider_private_get_result_metas (priv, invocation, parameters); else if (g_paste_str_equal (method_name, G_PASTE_SEARCH_PROVIDER_ACTIVATE_RESULT)) async = g_paste_search_provider_private_activate_result (priv, parameters); else if (g_paste_str_equal (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) { const 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.28.0/src/libgpaste/daemon/gpaste-search-provider.h000066400000000000000000000012061325205405000236150ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/gnome-shell-client/000077500000000000000000000000001325205405000213125ustar00rootroot00000000000000gpaste-3.28.0/src/libgpaste/gnome-shell-client/gpaste-gnome-shell-client.c000066400000000000000000000405311325205405000264300ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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_PASTE_DEFINE_TYPE (GnomeShellClient, 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 */ 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 */ 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 */ 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_paste_str_equal (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 */ 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.28.0/src/libgpaste/gnome-shell-client/gpaste-gnome-shell-client.h000066400000000000000000000141721325205405000264370ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/gpaste-gdbus-defines.h000066400000000000000000000356521325205405000220100ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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_ITEM_SELECTED "ItemSelected" #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.28.0/src/libgpaste/gpaste-gdbus-macros.h000066400000000000000000000432741325205405000216560ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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 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.28.0/src/libgpaste/gpaste-gsettings-keys.h000066400000000000000000000044261325205405000222440ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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_CLOSE_ON_SELECT_SETTING "close-on-select" #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_RICH_TEXT_SUPPORT_SETTING "rich-text-support" #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.28.0/src/libgpaste/gpaste-gtk-compat.h000066400000000000000000000014551325205405000213310ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #ifndef __GPASTE_GTK_COMPAT_H__ #define __GPASTE_GTK_COMPAT_H__ #include G_BEGIN_DECLS #if GTK_API > 3 # define gtk_widget_show_all(widget) gtk_widget_show (widget) # define gtk_box_pack_start(box, child, expand, fill) gtk_box_pack_start (box, child) #else # define gtk_box_pack_start(box, child, expand, fill) gtk_box_pack_start (box, child, expand, fill, 0) # define gtk_box_pack_end(box, child) gtk_box_pack_end (box, child, FALSE, TRUE, 0) # define gtk_widget_measure(widget, orientation, for_size, minimum, natural, minimum_baseline, natural_baseline) gtk_widget_get_preferred_height (widget, minimum, natural) #endif G_END_DECLS #endif /*__GPASTE_GTK_COMPAT_H__*/ gpaste-3.28.0/src/libgpaste/gpaste-macros.h000066400000000000000000000145361325205405000205530ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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_str_equal(s1, s2) (!g_strcmp0 (s1, s2)) #define G_PASTE_CONST_CHECKER(TYPE_NAME) \ static inline gboolean \ _G_PASTE_IS_##TYPE_NAME (gconstpointer ptr) { \ return G_PASTE_IS_##TYPE_NAME ((gpointer) ptr); \ } #define G_PASTE_CONST_CLASS_GETTER(TypeName, TYPE_NAME) \ static inline const GPaste##TypeName##Class * \ _G_PASTE_##TYPE_NAME##_GET_CLASS (gconstpointer ptr) { \ return G_PASTE_##TYPE_NAME##_GET_CLASS ((gpointer) ptr); \ } #define G_PASTE_CONST_CASTER(TypeName, TYPE_NAME) \ static inline const GPaste##TypeName * \ _G_PASTE_##TYPE_NAME (gconstpointer ptr) { \ return G_PASTE_##TYPE_NAME ((gpointer) ptr); \ } #define G_PASTE_CONST_FUNCS(TypeName, TYPE_NAME) \ G_PASTE_CONST_CHECKER (TYPE_NAME) \ G_PASTE_CONST_CASTER (TypeName, TYPE_NAME) #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) \ G_PASTE_CONST_CLASS_GETTER (TypeName, TYPE_NAME) \ G_PASTE_CONST_FUNCS (TypeName, TYPE_NAME) #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) \ G_PASTE_CONST_FUNCS (TypeName, TYPE_NAME) #define G_PASTE_CONST_PRIV_ACCESSOR(TypeName, type_name) \ static inline gconstpointer \ _g_paste_##type_name##_get_instance_private (const GPaste##TypeName *self) \ { \ return g_paste_##type_name##_get_instance_private ((GPaste##TypeName *) self); \ } #define G_PASTE_DEFINE_TYPE(TypeName, type_name, ParentTypeName) \ G_DEFINE_TYPE (GPaste##TypeName, g_paste_##type_name, ParentTypeName) \ G_PASTE_CONST_PRIV_ACCESSOR (TypeName, type_name) #define G_PASTE_DEFINE_TYPE_WITH_PRIVATE(TypeName, type_name, ParentTypeName) \ G_DEFINE_TYPE_WITH_PRIVATE (GPaste##TypeName, g_paste_##type_name, ParentTypeName) \ G_PASTE_CONST_PRIV_ACCESSOR (TypeName, type_name) #define G_PASTE_DEFINE_ABSTRACT_TYPE(TypeName, type_name, ParentTypeName) \ G_DEFINE_ABSTRACT_TYPE (GPaste##TypeName, g_paste_##type_name, ParentTypeName) \ G_PASTE_CONST_PRIV_ACCESSOR (TypeName, type_name) #define G_PASTE_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(TypeName, type_name, ParentTypeName) \ G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GPaste##TypeName, g_paste_##type_name, ParentTypeName) \ G_PASTE_CONST_PRIV_ACCESSOR (TypeName, type_name) #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 (); \ 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; \ } \ if (g_application_get_is_remote (gapp)) \ { \ if (G_APPLICATION_GET_CLASS (gapp)->activate) \ { \ g_application_activate (gapp); \ return g_application_run (gapp, argc, argv); \ } \ else \ { \ fprintf (stderr, "GPaste " name " %s\n", _("is already running.")); \ exit (EXIT_FAILURE); \ } \ } \ g_object_set (gtk_settings_get_default (), "gtk-application-prefer-dark-theme", TRUE, NULL) #define G_PASTE_INIT_APPLICATION(name) \ G_PASTE_INIT_APPLICATION_FULL (name, NULL) G_END_DECLS #endif /*__GPASTE_MACROS_H__*/ gpaste-3.28.0/src/libgpaste/gpaste.h000066400000000000000000000051161325205405000172630ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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 #include /* GPasteIO */ #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 /* GPasteUi */ #include #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.28.0/src/libgpaste/io/000077500000000000000000000000001325205405000162335ustar00rootroot00000000000000gpaste-3.28.0/src/libgpaste/io/gpaste-file-backend.c000066400000000000000000000446511325205405000221760ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include #include #include G_PASTE_DEFINE_TYPE (FileBackend, file_backend, G_PASTE_TYPE_STORAGE_BACKEND) static gboolean _g_paste_file_backend_write_image_metadata (GOutputStream *stream, const GPasteImageItem *item) { g_autofree gchar *date_str = g_date_time_format ((GDateTime *) g_paste_image_item_get_date (item), "%s"); return g_output_stream_write_all (stream, "\" date=\"", 8, NULL, NULL /* cancellable */, NULL /* error */) && g_output_stream_write_all (stream, date_str, 10, NULL, NULL /* cancellable */, NULL /* error */); } static gboolean _g_paste_file_backend_write_special_values (GOutputStream *stream, const GSList *special_values) { for (const GSList *val = special_values; val; val = val->next) { const GPasteSpecialValue *value = val->data; const gchar *mime = g_enum_get_value (g_type_class_peek (G_PASTE_TYPE_SPECIAL_ATOM), value->mime)->value_nick; g_autofree gchar *text = g_paste_util_xml_encode (value->data); if (!g_output_stream_write_all (stream, " \n", 12, NULL, NULL /* cancellable */, NULL /* error */)) { return FALSE; } } return TRUE; } static void g_paste_file_backend_write_history_file (const GPasteStorageBackend *self, const gchar *history_file_path, const GList *history) { const GPasteSettings *settings = _G_PASTE_STORAGE_BACKEND_GET_CLASS (self)->get_settings (self); if (!g_paste_util_ensure_history_dir_exists (settings)) return; g_autoptr (GFile) history_file = g_file_new_for_path (history_file_path); if (!g_paste_settings_get_save_history (settings)) { g_file_delete (history_file, NULL, /* cancellable*/ NULL); /* error */ return; } const GPasteFileBackend *real_self = _G_PASTE_FILE_BACKEND (self); g_autoptr (GOutputStream) stream = _G_PASTE_FILE_BACKEND_GET_CLASS (real_self)->get_output_stream (real_self, history_file); 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 (; history; history = g_list_next (history)) { GPasteItem *item = history->data; const gchar *kind = g_paste_item_get_kind (item); if (g_paste_str_equal (kind, "Password")) continue; const GSList *special_values = g_paste_item_get_special_values (item); g_autofree gchar *text = g_paste_util_xml_encode (g_paste_item_get_value (item)); if (!g_output_stream_write_all (stream, " \n \n", 12, NULL, NULL /* cancellable */, NULL /* error */) || (special_values && !_g_paste_file_backend_write_special_values (stream, special_values)) || !g_output_stream_write_all (stream, " \n", 10, 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 */)) { g_warning ("Failed to finish writing history"); } } /********************/ /* Begin XML Parser */ /********************/ typedef enum { BEGIN, IN_HISTORY, IN_ITEM, IN_ITEM_WITH_TEXT, IN_VALUE, IN_VALUE_WITH_TEXT, END } State; typedef enum { TEXT, IMAGE, URIS, PASSWORD } Type; typedef enum { HISTORY_1_0, HISTORY_2_0, HISTORY_CURRENT = HISTORY_2_0, HISTORY_INVALID = -1 } HistoryVersion; typedef struct { GList *history; gsize mem_size; State state; Type type; guint64 current_size; guint64 max_size; gboolean images_support; gchar *date; gchar *name; gchar *text; GSList *special_values; HistoryVersion version; GPasteSpecialAtom mime; } 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_paste_str_equal (element_name, "history")) { SWITCH_STATE (BEGIN, IN_HISTORY); for (const gchar **a = attribute_names, **v = attribute_values; *a && *v; ++a, ++v) { if (g_paste_str_equal (*a, "version")) { if (g_paste_str_equal (*v, "1.0")) { data->version = HISTORY_1_0; } else if (g_paste_str_equal (*v, "2.0")) { data->version = HISTORY_2_0; } else { g_warning ("Unknown history version: %s", *v); data->version = HISTORY_INVALID; } } } } else if (g_paste_str_equal (element_name, "item")) { SWITCH_STATE (IN_HISTORY, IN_ITEM); g_clear_pointer (&data->date, g_free); g_clear_pointer (&data->name, g_free); g_clear_pointer (&data->text, g_free); for (const gchar **a = attribute_names, **v = attribute_values; *a && *v; ++a, ++v) { if (g_paste_str_equal (*a, "kind")) { if (g_paste_str_equal (*v, "Text")) data->type = TEXT; else if (g_paste_str_equal (*v, "Image")) data->type = IMAGE; else if (g_paste_str_equal (*v, "Uris")) data->type = URIS; else if (g_paste_str_equal (*v, "Password")) data->type = PASSWORD; else g_warning ("Unknown item kind: %s", *v); } else if (g_paste_str_equal (*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_paste_str_equal (*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 if (g_paste_str_equal (element_name, "value")) { SWITCH_STATE (IN_ITEM, IN_VALUE); data->mime = G_PASTE_SPECIAL_ATOM_INVALID; for (const gchar **a = attribute_names, **v = attribute_values; *a && *v; ++a, ++v) { if (g_paste_str_equal (*a, "mime")) { GEnumValue *gev = g_enum_get_value_by_nick (g_type_class_peek (G_PASTE_TYPE_SPECIAL_ATOM), *v); if (gev) data->mime = gev->value; else g_warning ("Unknown mime: %s", *v); } } } else { g_warning ("Unknown element: %s", element_name); } } static void add_item (Data *data) { GPasteItem *item = NULL; switch (data->type) { case TEXT: item = g_paste_text_item_new (data->text); break; case URIS: item = g_paste_uris_item_new (data->text); break; case PASSWORD: item = g_paste_password_item_new (data->name, data->text); 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 (data->text, date_time); } else { g_autoptr (GFile) img_file = g_file_new_for_path (data->text); if (g_file_query_exists (img_file, NULL)) /* cancellable */ { g_file_delete (img_file, NULL, /* cancellable */ NULL); /* error */ } } break; } if (item) { data->mem_size += g_paste_item_get_size (item); data->history = g_list_append (data->history, item); ++data->current_size;; } for (GSList *d = data->special_values; d; d = d->next) { GPasteSpecialValue *v = d->data; if (item) g_paste_item_add_special_value (item, v); g_free (v->data); g_free (v); } g_clear_pointer(&data->special_values, g_slist_free); } 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_paste_str_equal (element_name, "history")) { SWITCH_STATE (IN_HISTORY, END); } else if (g_paste_str_equal (element_name, "item")) { if (data->current_size < data->max_size) add_item (data); switch (data->version) { case HISTORY_1_0: SWITCH_STATE (IN_ITEM_WITH_TEXT, IN_HISTORY); break; case HISTORY_2_0: SWITCH_STATE (IN_ITEM, IN_HISTORY); break; case HISTORY_INVALID: g_warning ("Invalid history version, ignoring end of item"); break; } } else if (g_paste_str_equal (element_name, "value")) { SWITCH_STATE (IN_VALUE_WITH_TEXT, IN_ITEM); } 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 IN_ITEM_WITH_TEXT: case IN_VALUE_WITH_TEXT: if (*g_strstrip (txt)) { g_warning ("Unexpected text: %s", txt); return; } break; case IN_ITEM: { if (data->version == HISTORY_1_0) { data->text = g_paste_util_xml_decode (txt); if (*g_strstrip (txt)) { SWITCH_STATE (IN_ITEM, IN_ITEM_WITH_TEXT); } else { g_clear_pointer (&data->text, g_free); } } else if (*g_strstrip (txt)) { g_warning ("Unexpected text in item for history version != 1.0 %s", txt); } break; } case IN_VALUE: if (data->version == HISTORY_2_0) { gchar *value = g_paste_util_xml_decode (txt); if (*g_strstrip (txt)) { SWITCH_STATE (IN_VALUE, IN_VALUE_WITH_TEXT); if (data->mime == G_PASTE_SPECIAL_ATOM_INVALID) { g_free (data->text); data->text = value; } else { GPasteSpecialValue *sv = g_new (GPasteSpecialValue, 1); sv->mime = data->mime; sv->data = value; data->special_values = g_slist_prepend (data->special_values, sv); } } else { g_free (value); } } else { g_warning ("Unexpected value for history version != 2.0"); } break; default: g_warning ("Unexpected state: %" G_GINT32_FORMAT, data->state); break; } } static void on_error (GMarkupParseContext *context G_GNUC_UNUSED, GError *error, gpointer user_data G_GNUC_UNUSED) { g_warning ("error: %s", error->message); } /******************/ /* End XML Parser */ /******************/ static void g_paste_file_backend_read_history_file (const GPasteStorageBackend *self, const gchar *history_file_path, GList **history, gsize *size) { const GPasteSettings *settings = _G_PASTE_STORAGE_BACKEND_GET_CLASS (self)->get_settings (self); g_autoptr (GFile) history_file = g_file_new_for_path (history_file_path); g_autofree gchar *text = NULL; if (g_file_query_exists (history_file, NULL)) /* cancellable */ { GMarkupParser parser = { start_tag, end_tag, on_text, NULL, on_error }; Data data = { NULL, 0, BEGIN, TEXT, 0, g_paste_settings_get_max_history_size (settings), g_paste_settings_get_images_support (settings), NULL, NULL, NULL, NULL, HISTORY_INVALID, G_PASTE_SPECIAL_ATOM_INVALID }; GMarkupParseContext *ctx = g_markup_parse_context_new (&parser, G_MARKUP_TREAT_CDATA_AS_TEXT, &data, NULL); 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); *history = data.history; *size = data.mem_size; g_clear_pointer (&data.date, g_free); g_clear_pointer (&data.name, g_free); g_clear_pointer (&data.text, g_free); if (data.version != HISTORY_CURRENT) g_paste_file_backend_write_history_file (self, history_file_path, *history); } else { /* Create the empty file to be listed as an available history */ if (g_paste_util_ensure_history_dir_exists (settings)) g_object_unref (g_file_create (history_file, G_FILE_CREATE_NONE, NULL, NULL)); } } static const gchar * g_paste_file_backend_get_extension (const GPasteStorageBackend *self G_GNUC_UNUSED) { return "xml"; } static GOutputStream * g_paste_file_backend_get_output_stream (const GPasteFileBackend *self G_GNUC_UNUSED, GFile *output_file) { return G_OUTPUT_STREAM (g_file_replace (output_file, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, NULL, /* cancellable */ NULL)); /* error */ } static void g_paste_file_backend_class_init (GPasteFileBackendClass *klass) { GPasteStorageBackendClass *storage_class = G_PASTE_STORAGE_BACKEND_CLASS (klass); storage_class->read_history_file = g_paste_file_backend_read_history_file; storage_class->write_history_file = g_paste_file_backend_write_history_file; storage_class->get_extension = g_paste_file_backend_get_extension; klass->get_output_stream = g_paste_file_backend_get_output_stream; } static void g_paste_file_backend_init (GPasteFileBackend *self G_GNUC_UNUSED) { } gpaste-3.28.0/src/libgpaste/io/gpaste-file-backend.h000066400000000000000000000015061325205405000221730ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_FILE_BACKEND_H__ #define __G_PASTE_FILE_BACKEND_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_FILE_BACKEND (g_paste_file_backend_get_type ()) G_PASTE_DERIVABLE_TYPE (FileBackend, file_backend, FILE_BACKEND, GPasteStorageBackend) struct _GPasteFileBackendClass { GPasteStorageBackendClass parent_class; /*< protected >*/ GOutputStream *(*get_output_stream) (const GPasteFileBackend *self, GFile *output_file); }; G_END_DECLS #endif /*__G_PASTE_FILE_BACKEND_H__*/ gpaste-3.28.0/src/libgpaste/io/gpaste-storage-backend.c000066400000000000000000000105231325205405000227120ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include typedef struct { GPasteSettings *settings; } GPasteStorageBackendPrivate; G_PASTE_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (StorageBackend, storage_backend, G_TYPE_OBJECT) static gchar * _g_paste_storage_backend_get_history_file_path (const GPasteStorageBackend *self, const gchar *name) { return g_paste_util_get_history_file_path (name, _G_PASTE_STORAGE_BACKEND_GET_CLASS (self)->get_extension (self)); } /** * g_paste_storage_backend_read_history: * @self: a #GPasteItem instance * @name: the name of the history to load * @history: (out) (element-type GPasteItem): the history we just read * @size: (out): the size used by the history * * Reads the history from our storage backend */ G_PASTE_VISIBLE void g_paste_storage_backend_read_history (const GPasteStorageBackend *self, const gchar *name, GList **history, gsize *size) { g_return_if_fail (_G_PASTE_IS_STORAGE_BACKEND (self)); g_return_if_fail (name); g_return_if_fail (history && !*history); g_return_if_fail (size); g_autofree gchar *history_file_path = _g_paste_storage_backend_get_history_file_path (self, name); _G_PASTE_STORAGE_BACKEND_GET_CLASS (self)->read_history_file (self, history_file_path, history, size); } /** * g_paste_storage_backend_write_history: * @self: a #GPasteItem instance * @name: the name of the history to save * @history: (element-type GPasteItem): the history to write * * Save the history by writing it to our storage backend */ G_PASTE_VISIBLE void g_paste_storage_backend_write_history (const GPasteStorageBackend *self, const gchar *name, const GList *history) { g_return_if_fail (_G_PASTE_IS_STORAGE_BACKEND (self)); g_autofree gchar *history_file_path = _g_paste_storage_backend_get_history_file_path (self, name); _G_PASTE_STORAGE_BACKEND_GET_CLASS (self)->write_history_file (self, history_file_path, history); } static void g_paste_storage_backend_dispose (GObject *object) { const GPasteStorageBackendPrivate *priv = _g_paste_storage_backend_get_instance_private (G_PASTE_STORAGE_BACKEND (object)); g_clear_object (&priv->settings); G_OBJECT_CLASS (g_paste_storage_backend_parent_class)->dispose (object); } static const GPasteSettings * g_paste_storage_backend_get_settings (const GPasteStorageBackend *self) { const GPasteStorageBackendPrivate *priv = _g_paste_storage_backend_get_instance_private (self); return priv->settings; } static void g_paste_storage_backend_class_init (GPasteStorageBackendClass *klass) { klass->read_history_file = NULL; klass->write_history_file = NULL; klass->get_extension = NULL; klass->get_settings = g_paste_storage_backend_get_settings; G_OBJECT_CLASS (klass)->dispose = g_paste_storage_backend_dispose; } static void g_paste_storage_backend_init (GPasteStorageBackend *self G_GNUC_UNUSED) { } static GType _g_paste_storage_backend_get_type (GPasteStorage storage_kind) { switch (storage_kind) { case G_PASTE_STORAGE_FILE: return G_PASTE_TYPE_FILE_BACKEND; default: return _g_paste_storage_backend_get_type (G_PASTE_STORAGE_DEFAULT); } } /** * g_paste_storage_backend_new: * @storage_kind: the kind of storage we want to use to save and load history * @settings: a #GPasteSettings instance * * Create a new instance of #GPasteStorageBackend * * Returns: a newly allocated #GPasteStorageBackend * free it with g_object_unref */ G_PASTE_VISIBLE GPasteStorageBackend * g_paste_storage_backend_new (GPasteStorage storage_kind, GPasteSettings *settings) { g_return_val_if_fail (G_PASTE_IS_SETTINGS (settings), NULL); GPasteStorageBackend *self = g_object_new (_g_paste_storage_backend_get_type (storage_kind), NULL); GPasteStorageBackendPrivate *priv = g_paste_storage_backend_get_instance_private (self); priv->settings = g_object_ref (settings); return self; } gpaste-3.28.0/src/libgpaste/io/gpaste-storage-backend.h000066400000000000000000000042111325205405000227140ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_STORAGE_BACKEND_H__ #define __G_PASTE_STORAGE_BACKEND_H__ #include G_BEGIN_DECLS typedef enum { G_PASTE_STORAGE_FILE, G_PASTE_STORAGE_DEFAULT = G_PASTE_STORAGE_FILE } GPasteStorage; #define G_PASTE_TYPE_STORAGE_BACKEND (g_paste_storage_backend_get_type ()) G_PASTE_DERIVABLE_TYPE (StorageBackend, storage_backend, STORAGE_BACKEND, GObject) struct _GPasteStorageBackendClass { GObjectClass parent_class; /*< pure virtual >*/ void (*read_history_file) (const GPasteStorageBackend *self, const gchar *history_file_path, GList **history, gsize *size); void (*write_history_file) (const GPasteStorageBackend *self, const gchar *history_file_path, const GList *history); /*< protected >*/ const gchar *(*get_extension) (const GPasteStorageBackend *self); const GPasteSettings *(*get_settings) (const GPasteStorageBackend *self); }; void g_paste_storage_backend_read_history (const GPasteStorageBackend *self, const gchar *name, GList **history, gsize *size); void g_paste_storage_backend_write_history (const GPasteStorageBackend *self, const gchar *name, const GList *history); GPasteStorageBackend *g_paste_storage_backend_new (GPasteStorage storage_kind, GPasteSettings *settings); G_END_DECLS #endif /*__G_PASTE_STORAGE_BACKEND_H__*/ gpaste-3.28.0/src/libgpaste/keybinder/000077500000000000000000000000001325205405000176005ustar00rootroot00000000000000gpaste-3.28.0/src/libgpaste/keybinder/gpaste-keybinder.c000066400000000000000000000517271325205405000232150ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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; }; enum { C_ACCEL, C_LAST_SIGNAL }; typedef struct { GSList *keybindings; GPasteSettings *settings; GPasteGnomeShellClient *shell_client; gboolean use_shell_client; gboolean grabbing; guint64 retries; guint64 shell_watch; guint64 c_signals[C_LAST_SIGNAL]; } GPasteKeybinderPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (Keybinder, 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, GdkDisplay *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 }; Display *xdisplay = GDK_DISPLAY_XDISPLAY (display); XISetMask (mask.mask, XI_KeyPress); gdk_x11_display_error_trap_push (display); 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 (xdisplay, XIAllMasterDevices, *keycode, window, XIGrabModeSync, XIGrabModeAsync, False, &mask, 1, &mods); } else { XIUngrabKeycode (xdisplay, XIAllMasterDevices, *keycode, window, 1, &mods); } } } gdk_display_flush (display); gdk_x11_display_error_trap_pop_ignored (display); } #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, display, grab); else #endif g_warning ("Unsupported GDK backend, keybinder won't work."); } /***********************************/ /* Wrapper around GPasteKeybinding */ /***********************************/ enum { C_K_REBIND, C_K_LAST_SIGNAL }; typedef struct { GPasteKeybinding *binding; GPasteSettings *settings; GPasteGnomeShellClient *shell_client; gboolean use_shell_client; guint32 action; guint64 c_signals[C_K_LAST_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->c_signals[C_K_REBIND] = 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->c_signals[C_K_REBIND]); 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 */ 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 */ 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 */ G_PASTE_VISIBLE void g_paste_keybinder_deactivate_all (GPasteKeybinder *self) { g_return_if_fail (_G_PASTE_IS_KEYBINDER (self)); const 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; GdkDisplay *display = gdk_display_get_default (); for (GList *_seat = gdk_display_list_seats (display); _seat; _seat = g_list_next (_seat)) { GdkSeat *seat = _seat->data; if (gdk_seat_get_keyboard (seat)) gdk_seat_ungrab (seat); } gdk_display_flush (display); 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->c_signals[C_ACCEL]); 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->c_signals[C_ACCEL] = 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.28.0/src/libgpaste/keybinder/gpaste-keybinder.h000066400000000000000000000017351325205405000232140ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/keybinder/gpaste-keybinding.c000066400000000000000000000177221325205405000233610ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include typedef struct _GPasteKeybindingPrivate { GPasteKeybindingGetter getter; gchar *dconf_key; GPasteKeybindingFunc callback; gpointer user_data; gboolean active; GdkModifierType modifiers; guint32 *keycodes; } GPasteKeybindingPrivate; G_PASTE_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (Keybinding, 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); const 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); const 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); const 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); const 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 */ 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 */ 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); const GPasteKeybindingPrivate *priv = _g_paste_keybinding_get_instance_private (self); return priv->active; } static gboolean g_paste_keybinding_private_match (const 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 */ G_PASTE_VISIBLE void g_paste_keybinding_notify (GPasteKeybinding *self, GdkModifierType modifiers, guint64 keycode) { g_return_if_fail (_G_PASTE_IS_KEYBINDING (self)); const 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 */ G_PASTE_VISIBLE void g_paste_keybinding_perform (GPasteKeybinding *self) { g_return_if_fail (_G_PASTE_IS_KEYBINDING (self)); const 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); const 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) { const 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.28.0/src/libgpaste/keybinder/gpaste-keybinding.h000066400000000000000000000043031325205405000233550ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/keybinder/gpaste-make-password-keybinding.c000066400000000000000000000030301325205405000261170ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include struct _GPasteMakePasswordKeybinding { GPasteKeybinding parent_instance; }; G_PASTE_DEFINE_TYPE (MakePasswordKeybinding, 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.28.0/src/libgpaste/keybinder/gpaste-make-password-keybinding.h000066400000000000000000000014061325205405000261310ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/keybinder/gpaste-pop-keybinding.c000066400000000000000000000041471325205405000241520ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include struct _GPastePopKeybinding { GPasteKeybinding parent_instance; }; typedef struct { GPasteHistory *history; } GPastePopKeybindingPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (PopKeybinding, pop_keybinding, G_PASTE_TYPE_KEYBINDING) static void g_paste_pop_keybinding_dispose (GObject *object) { const 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) { const 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.28.0/src/libgpaste/keybinder/gpaste-pop-keybinding.h000066400000000000000000000012551325205405000241540ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/keybinder/gpaste-show-history-keybinding.c000066400000000000000000000031071325205405000260260ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include struct _GPasteShowHistoryKeybinding { GPasteKeybinding parent_instance; }; G_PASTE_DEFINE_TYPE (ShowHistoryKeybinding, 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.28.0/src/libgpaste/keybinder/gpaste-show-history-keybinding.h000066400000000000000000000014011325205405000260260ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/keybinder/gpaste-sync-clipboard-to-primary-keybinding.c000066400000000000000000000033321325205405000303610ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include struct _GPasteSyncClipboardToPrimaryKeybinding { GPasteKeybinding parent_instance; }; G_PASTE_DEFINE_TYPE (SyncClipboardToPrimaryKeybinding, 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, TRUE); } /** * 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.28.0/src/libgpaste/keybinder/gpaste-sync-clipboard-to-primary-keybinding.h000066400000000000000000000016011325205405000303630ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/keybinder/gpaste-sync-primary-to-clipboard-keybinding.c000066400000000000000000000033331325205405000303620ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include struct _GPasteSyncPrimaryToClipboardKeybinding { GPasteKeybinding parent_instance; }; G_PASTE_DEFINE_TYPE (SyncPrimaryToClipboardKeybinding, 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, FALSE); } /** * 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.28.0/src/libgpaste/keybinder/gpaste-sync-primary-to-clipboard-keybinding.h000066400000000000000000000016011325205405000303630ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/keybinder/gpaste-ui-keybinding.c000066400000000000000000000023111325205405000237600ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include struct _GPasteUiKeybinding { GPasteKeybinding parent_instance; }; G_PASTE_DEFINE_TYPE (UiKeybinding, 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.28.0/src/libgpaste/keybinder/gpaste-ui-keybinding.h000066400000000000000000000011661325205405000237740ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/keybinder/gpaste-upload-keybinding.c000066400000000000000000000042671325205405000246430ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include struct _GPasteUploadKeybinding { GPasteKeybinding parent_instance; }; typedef struct { GPasteDaemon *daemon; } GPasteUploadKeybindingPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (UploadKeybinding, upload_keybinding, G_PASTE_TYPE_KEYBINDING) static void g_paste_upload_keybinding_dispose (GObject *object) { const 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) { const 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.28.0/src/libgpaste/keybinder/gpaste-upload-keybinding.h000066400000000000000000000013051325205405000246360ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/libgpaste.sym000066400000000000000000000367551325205405000203500ustar00rootroot00000000000000LIBGPASTE_3_16_0 { global: 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_text; g_paste_clipboard_get_type; 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_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_replace; g_paste_util_show_win; g_paste_util_spawn; g_paste_util_spawn_sync; local: *; }; LIBGPASTE_3_18_0 { global: 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; LIBGPASTE_3_20_0 { global: g_paste_ui_empty_item_show_empty; g_paste_ui_empty_item_show_no_result; g_paste_ui_item_skeleton_set_uploadable; g_paste_ui_new_item_get_type; g_paste_ui_new_item_new; g_paste_ui_shortcuts_window_get_type; g_paste_ui_shortcuts_window_new; g_paste_util_has_gnome_shell; g_paste_util_read_pid_file; g_paste_util_write_pid_file; } LIBGPASTE_3_18_0; LIBGPASTE_3_22_0 { global: g_paste_clipboard_store; g_paste_clipboards_manager_store; } LIBGPASTE_3_20_0; LIBGPASTE_3_24_0 { global: g_paste_file_backend_get_type; g_paste_history_refresh_item_size; g_paste_item_get_special_values; g_paste_item_get_special_value; g_paste_item_add_special_value; g_paste_settings_get_close_on_select; g_paste_settings_reset_close_on_select; g_paste_settings_set_close_on_select; g_paste_special_atom_get_type; g_paste_special_atom_get; g_paste_storage_backend_get_type; g_paste_storage_backend_read_history; g_paste_storage_backend_write_history; g_paste_storage_backend_new; g_paste_ui_history_select_first; g_paste_util_ensure_history_dir_exists; g_paste_util_get_history_dir_path; g_paste_util_get_history_dir; g_paste_util_get_history_file_path; g_paste_util_get_history_file; g_paste_util_xml_decode; g_paste_util_xml_encode; } LIBGPASTE_3_22_0; LIBGPASTE_3_28_0 { global: g_paste_clipboard_is_clipboard; g_paste_clipboard_new_clipboard; g_paste_clipboard_new_primary; g_paste_clipboard_sync_text; g_paste_clipboards_manager_sync_from_to; g_paste_ui_window_empty_history; g_paste_util_empty_history; } LIBGPASTE_3_24_0; gpaste-3.28.0/src/libgpaste/screensaver-client/000077500000000000000000000000001325205405000214205ustar00rootroot00000000000000gpaste-3.28.0/src/libgpaste/screensaver-client/gpaste-screensaver-client.c000066400000000000000000000116221325205405000266430ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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_PASTE_DEFINE_TYPE (ScreensaverClient, 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_paste_str_equal (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 */ 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.28.0/src/libgpaste/screensaver-client/gpaste-screensaver-client.h000066400000000000000000000021451325205405000266500ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/settings-ui/000077500000000000000000000000001325205405000200775ustar00rootroot00000000000000gpaste-3.28.0/src/libgpaste/settings-ui/gpaste-settings-ui-panel.c000066400000000000000000000266671325205405000251150ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include struct _GPasteSettingsUiPanel { GtkGrid parent_instance; }; typedef struct { GSList *callback_data; guint64 current_line; } GPasteSettingsUiPanelPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (SettingsUiPanel, 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; enum { C_W_ACTION, C_W_RESET, C_W_LAST_SIGNAL }; typedef struct { CallbackDataWrapper wrap; GtkWidget *widget; GtkWidget *reset_widget; guint64 c_signals[C_W_LAST_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->c_signals[C_W_RESET] = 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->c_signals[C_W_ACTION] = 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 */ 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->c_signals[C_W_ACTION] = 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->c_signals[C_W_ACTION] = 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->c_signals[C_W_ACTION]); if (wrap->reset_widget) g_signal_handler_disconnect (wrap->reset_widget, wrap->c_signals[C_W_RESET]); } 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.28.0/src/libgpaste/settings-ui/gpaste-settings-ui-panel.h000066400000000000000000000057701325205405000251120ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/settings-ui/gpaste-settings-ui-stack.c000066400000000000000000000741251325205405000251130ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include #include struct _GPasteSettingsUiStack { GtkStack parent_instance; }; enum { C_SETTINGS, C_LAST_SIGNAL }; typedef struct { GPasteClient *client; GPasteSettings *settings; GError *init_error; GtkSwitch *close_on_select_switch; 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; guint64 c_signals[C_LAST_SIGNAL]; } GPasteSettingsUiStackPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (SettingsUiStack, settings_ui_stack, GTK_TYPE_STACK) #define SETTING_CALLBACK_FULL(setting, type, cast) \ static inline 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 */ 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 (close_on_select) BOOLEAN_CALLBACK (extension_enabled) 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 (track_extension_state) BOOLEAN_CALLBACK (trim_items) 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); priv->close_on_select_switch = g_paste_settings_ui_panel_add_boolean_setting (panel, _("Close UI on select"), g_paste_settings_get_close_on_select (settings), close_on_select_callback, (GPasteResetCallback) g_paste_settings_reset_close_on_select, settings); if (g_paste_util_has_gnome_shell ()) { 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); } 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 */ 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_paste_str_equal (key, G_PASTE_CLOSE_ON_SELECT_SETTING)) gtk_switch_set_active (GTK_SWITCH (priv->close_on_select_switch), g_paste_settings_get_close_on_select (settings)); else if (g_paste_str_equal (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_paste_str_equal (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_paste_str_equal (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_paste_str_equal (key, G_PASTE_LAUNCH_UI_SETTING)) gtk_entry_set_text (priv->launch_ui_entry, g_paste_settings_get_launch_ui (settings)); else if (g_paste_str_equal (key, G_PASTE_MAKE_PASSWORD_SETTING)) gtk_entry_set_text (priv->make_password_entry, g_paste_settings_get_make_password (settings)); else if (g_paste_str_equal (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_paste_str_equal (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_paste_str_equal (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_paste_str_equal (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_paste_str_equal (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_paste_str_equal (key, G_PASTE_POP_SETTING)) gtk_entry_set_text (priv->pop_entry, g_paste_settings_get_pop (settings)); else if (g_paste_str_equal (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_paste_str_equal (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_paste_str_equal (key, G_PASTE_SHOW_HISTORY_SETTING)) gtk_entry_set_text (priv->show_history_entry, g_paste_settings_get_show_history (settings)); else if (g_paste_str_equal (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_paste_str_equal (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_paste_str_equal (key, G_PASTE_UPLOAD_SETTING)) gtk_entry_set_text (priv->upload_entry, g_paste_settings_get_upload (settings)); else if (g_paste_str_equal (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_paste_str_equal (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_paste_str_equal (key, G_PASTE_TRIM_ITEMS_SETTING)) gtk_switch_set_active (GTK_SWITCH (priv->trim_items_switch), g_paste_settings_get_trim_items (settings)); else if (g_paste_util_has_gnome_shell ()) { if (g_paste_str_equal (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_paste_str_equal (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)); } } static void g_paste_settings_ui_stack_dispose (GObject *object) { const 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->c_signals[C_SETTINGS]); 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) { const 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->c_signals[C_SETTINGS] = 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: (nullable): 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)); const 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.28.0/src/libgpaste/settings-ui/gpaste-settings-ui-stack.h000066400000000000000000000020161325205405000251060ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/settings-ui/gpaste-settings-ui-widget.c000066400000000000000000000045151325205405000252650ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include struct _GPasteSettingsUiWidget { GtkGrid parent_instance; }; typedef struct { GPasteSettingsUiStack *stack; } GPasteSettingsUiWidgetPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (SettingsUiWidget, 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); const 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: (nullable): 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); const 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.28.0/src/libgpaste/settings-ui/gpaste-settings-ui-widget.h000066400000000000000000000013661325205405000252730ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/settings/000077500000000000000000000000001325205405000174645ustar00rootroot00000000000000gpaste-3.28.0/src/libgpaste/settings/gpaste-settings.c000066400000000000000000001022011325205405000227450ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include struct _GPasteSettings { GObject parent_instance; }; enum { C_CHANGED, C_SHELL_CHANGED, C_LAST_SIGNAL }; typedef struct { GSettings *settings; GSettings *shell_settings; gboolean close_on_select; 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 rich_text_support; 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; guint64 c_signals[C_LAST_SIGNAL]; } GPasteSettingsPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (Settings, 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); \ const 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)); \ const 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, 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) /** * g_paste_settings_get_close_on_select: * @self: a #GPasteSettings instance * * Get the "close-on-select" setting * * Returns: the value of the "close-on-select" setting */ /** * g_paste_settings_reset_close_on_select: * @self: a #GPasteSettings instance * * Reset the "close-on-select" setting */ /** * g_paste_settings_set_close_on_select: * @self: a #GPasteSettings instance * @value: the new history name * * Change the "close-on-select" setting */ BOOLEAN_SETTING (close_on_select, CLOSE_ON_SELECT) /** * 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 */ /** * g_paste_settings_set_element_size: * @self: a #GPasteSettings instance * @value: the maximum displayed size of an item * * Change the "element-size" setting */ 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 */ /** * g_paste_settings_set_growing_lines: * @self: a #GPasteSettings instance * @value: whether to detect or not growing lines * * Change the "growing-lines" setting */ 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 */ /** * g_paste_settings_set_history_name: * @self: a #GPasteSettings instance * @value: the new history name * * Change the "history-name" setting */ 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 */ /** * g_paste_settings_set_images_support: * @self: a #GPasteSettings instance * @value: the new history name * * Change the "images-support" setting */ 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 */ /** * g_paste_settings_set_launch_ui: * @self: a #GPasteSettings instance * @value: the new keyboard shortcut * * Change the "launch-ui" setting */ 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 */ /** * g_paste_settings_set_make_password: * @self: a #GPasteSettings instance * @value: the new keyboard shortcut * * Change the "make-password" setting */ 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 */ /** * 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 */ 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 */ /** * 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 */ 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 */ /** * 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 */ 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 */ /** * 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 */ 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 */ /** * 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 */ 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 */ /** * g_paste_settings_set_pop: * @self: a #GPasteSettings instance * @value: the new keyboard shortcut * * Change the "pop" setting */ 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 */ /** * 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 */ BOOLEAN_SETTING (primary_to_history, PRIMARY_TO_HISTORY) /** * g_paste_settings_get_rich_text_support: * @self: a #GPasteSettings instance * * Get the "rich-text-support" setting * * Returns: the value of the "rich-text-support" setting */ /** * g_paste_settings_reset_rich_text_support: * @self: a #GPasteSettings instance * * Reset the "rich-text-support" setting */ /** * g_paste_settings_set_rich_text_support: * @self: a #GPasteSettings instance * @value: the new history name * * Change the "rich-text-support" setting */ BOOLEAN_SETTING (rich_text_support, RICH_TEXT_SUPPORT) /** * 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 */ /** * g_paste_settings_set_save_history: * @self: a #GPasteSettings instance * @value: whether to save or not the history * * Change the "save-history" setting */ 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 */ /** * g_paste_settings_set_show_history: * @self: a #GPasteSettings instance * @value: the new keyboard shortcut * * Change the "show-history" setting */ 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 */ /** * g_paste_settings_set_sync_clipboard_to_primary: * @self: a #GPasteSettings instance * @value: the new keyboard shortcut * * Change the "sync-clipboard-to-primary" setting */ 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 */ /** * g_paste_settings_set_sync_primary_to_clipboard: * @self: a #GPasteSettings instance * @value: the new keyboard shortcut * * Change the "sync-primary-to-clipboard" setting */ 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 */ /** * 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 */ 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 */ /** * g_paste_settings_set_track_changes: * @self: a #GPasteSettings instance * @value: whether to track or not the clipboard changes * * Change the "track-changes" setting */ 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 */ /** * 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 */ 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 */ /** * g_paste_settings_set_trim_items: * @self: a #GPasteSettings instance * @value: whether to trim or not textual items * * Change the "trim-items" setting */ 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 */ /** * g_paste_settings_set_upload: * @self: a #GPasteSettings instance * @value: the new keyboard shortcut * * Change the "upload" setting */ STRING_SETTING (upload, UPLOAD) /** * 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); const 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_paste_str_equal (*e, G_PASTE_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 */ 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 (G_PASTE_EXTENSION_NAME); extensions[nb+1] = NULL; } else { gboolean found = FALSE; for (guint64 i = 0; i < nb; ++i) { if (!found && g_paste_str_equal (extensions[i], G_PASTE_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); } 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_paste_str_equal (key, G_PASTE_CLOSE_ON_SELECT_SETTING)) g_paste_settings_private_set_close_on_select_from_dconf (priv); else if (g_paste_str_equal (key, G_PASTE_ELEMENT_SIZE_SETTING)) g_paste_settings_private_set_element_size_from_dconf (priv); else if (g_paste_str_equal (key, G_PASTE_GROWING_LINES_SETTING)) g_paste_settings_private_set_growing_lines_from_dconf (priv); else if (g_paste_str_equal (key, G_PASTE_HISTORY_NAME_SETTING)) g_paste_settings_private_set_history_name_from_dconf (priv); else if (g_paste_str_equal (key, G_PASTE_IMAGES_SUPPORT_SETTING)) g_paste_settings_private_set_images_support_from_dconf (priv); else if (g_paste_str_equal (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_paste_str_equal (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_paste_str_equal (key, G_PASTE_MAX_DISPLAYED_HISTORY_SIZE_SETTING)) g_paste_settings_private_set_max_displayed_history_size_from_dconf (priv); else if (g_paste_str_equal (key, G_PASTE_MAX_HISTORY_SIZE_SETTING)) g_paste_settings_private_set_max_history_size_from_dconf (priv); else if (g_paste_str_equal (key, G_PASTE_MAX_MEMORY_USAGE_SETTING)) g_paste_settings_private_set_max_memory_usage_from_dconf (priv); else if (g_paste_str_equal (key, G_PASTE_MAX_TEXT_ITEM_SIZE_SETTING)) g_paste_settings_private_set_max_text_item_size_from_dconf (priv); else if (g_paste_str_equal (key, G_PASTE_MIN_TEXT_ITEM_SIZE_SETTING)) g_paste_settings_private_set_min_text_item_size_from_dconf (priv); else if (g_paste_str_equal (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_paste_str_equal (key, G_PASTE_PRIMARY_TO_HISTORY_SETTING )) g_paste_settings_private_set_primary_to_history_from_dconf (priv); else if (g_paste_str_equal (key, G_PASTE_RICH_TEXT_SUPPORT_SETTING)) g_paste_settings_private_set_rich_text_support_from_dconf (priv); else if (g_paste_str_equal (key, G_PASTE_SAVE_HISTORY_SETTING)) g_paste_settings_private_set_save_history_from_dconf (priv); else if (g_paste_str_equal (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_paste_str_equal (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_paste_str_equal (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_paste_str_equal (key, G_PASTE_SYNCHRONIZE_CLIPBOARDS_SETTING)) g_paste_settings_private_set_synchronize_clipboards_from_dconf (priv); else if (g_paste_str_equal (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_paste_str_equal (key, G_PASTE_TRACK_EXTENSION_STATE_SETTING)) g_paste_settings_private_set_track_extension_state_from_dconf (priv); else if (g_paste_str_equal (key, G_PASTE_TRIM_ITEMS_SETTING)) g_paste_settings_private_set_trim_items_from_dconf (priv); else if (g_paste_str_equal (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) { const GPasteSettingsPrivate *priv = _g_paste_settings_get_instance_private (G_PASTE_SETTINGS (object)); GSettings *settings = priv->settings; GSettings *shell_settings = priv->shell_settings; if (settings) { g_signal_handler_disconnect (settings, priv->c_signals[C_CHANGED]); g_clear_object (&priv->settings); } if (shell_settings) { g_signal_handler_disconnect (shell_settings, priv->c_signals[C_SHELL_CHANGED]); g_clear_object (&priv->shell_settings); } G_OBJECT_CLASS (g_paste_settings_parent_class)->dispose (object); } static void g_paste_settings_finalize (GObject *object) { const 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->c_signals[C_CHANGED] = g_signal_connect (settings, "changed", G_CALLBACK (g_paste_settings_settings_changed), self); g_paste_settings_private_set_close_on_select_from_dconf (priv); 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_rich_text_support_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; if (g_paste_util_has_gnome_shell ()) { priv->shell_settings = g_settings_new (G_PASTE_SHELL_SETTINGS_NAME); priv->c_signals[C_SHELL_CHANGED] = 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); } } /** * 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.28.0/src/libgpaste/settings/gpaste-settings.h000066400000000000000000000205751325205405000227670ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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) gboolean g_paste_settings_get_close_on_select (const GPasteSettings *self); 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_rich_text_support (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_close_on_select (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_rich_text_support (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_close_on_select (GPasteSettings *self, gboolean value); 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_rich_text_support (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.28.0/src/libgpaste/ui/000077500000000000000000000000001325205405000162415ustar00rootroot00000000000000gpaste-3.28.0/src/libgpaste/ui/gpaste-ui-about.c000066400000000000000000000032031325205405000214110ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include struct _GPasteUiAbout { GtkButton parent_instance; }; typedef struct { GActionGroup *action_group; } GPasteUiAboutPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (UiAbout, ui_about, GTK_TYPE_BUTTON) static void g_paste_ui_about_clicked (GtkButton *button) { const 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) { GtkWidget *widget = GTK_WIDGET (self); gtk_widget_set_tooltip_text (widget, _("About")); gtk_widget_set_valign (widget, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (self), gtk_image_new_from_icon_name ("dialog-information-symbolic", GTK_ICON_SIZE_BUTTON)); } /** * 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, 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.28.0/src/libgpaste/ui/gpaste-ui-about.h000066400000000000000000000011061325205405000214160ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/ui/gpaste-ui-backup-history.c000066400000000000000000000103571325205405000232530ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include #include "gpaste-gtk-compat.h" struct _GPasteUiBackupHistory { GPasteUiHistoryAction parent_instance; }; G_PASTE_DEFINE_TYPE (UiBackupHistory, ui_backup_history, G_PASTE_TYPE_UI_HISTORY_ACTION) enum { C_ACTIVATED, C_LAST_SIGNAL }; 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, 2); gtk_widget_set_margin_end (vbox, 2); gtk_widget_set_margin_bottom (vbox, 2); gtk_widget_set_vexpand (label, TRUE); gtk_widget_set_valign (label, TRUE); gtk_box_pack_start (box, label, TRUE, TRUE); gtk_widget_show (label); gtk_widget_set_vexpand (entry, TRUE); gtk_widget_set_valign (entry, TRUE); gtk_box_pack_start (box, entry, TRUE, TRUE); gtk_entry_set_text (e, default_name); gtk_widget_show (entry); guint64 c_signals[C_LAST_SIGNAL] = { [C_ACTIVATED] = 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, c_signals[C_ACTIVATED]); 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.28.0/src/libgpaste/ui/gpaste-ui-backup-history.h000066400000000000000000000014601325205405000232530ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/ui/gpaste-ui-delete-history.c000066400000000000000000000036561325205405000232540ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include struct _GPasteUiDeleteHistory { GPasteUiHistoryAction parent_instance; }; G_PASTE_DEFINE_TYPE (UiDeleteHistory, 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.28.0/src/libgpaste/ui/gpaste-ui-delete-history.h000066400000000000000000000014601325205405000232500ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/ui/gpaste-ui-delete-item.c000066400000000000000000000024271325205405000225040ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include struct _GPasteUiDeleteItem { GPasteUiItemAction parent_instance; }; G_PASTE_DEFINE_TYPE (UiDeleteItem, 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.28.0/src/libgpaste/ui/gpaste-ui-delete-item.h000066400000000000000000000012151325205405000225030ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/ui/gpaste-ui-edit-item.c000066400000000000000000000075031325205405000221670ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include "gpaste-gtk-compat.h" struct _GPasteUiEditItem { GPasteUiItemAction parent_instance; }; typedef struct { GtkWindow *rootwin; } GPasteUiEditItemPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (UiEditItem, 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_widget_set_vexpand (scroll, TRUE); gtk_widget_set_valign (scroll, TRUE); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (d)), scroll, TRUE, TRUE); 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.28.0/src/libgpaste/ui/gpaste-ui-edit-item.h000066400000000000000000000012671325205405000221750ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/ui/gpaste-ui-empty-history.c000066400000000000000000000035601325205405000231420ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include struct _GPasteUiEmptyHistory { GPasteUiHistoryAction parent_instance; }; G_PASTE_DEFINE_TYPE (UiEmptyHistory, 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) { g_paste_util_empty_history (rootwin, client, history); 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_history_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.28.0/src/libgpaste/ui/gpaste-ui-empty-history.h000066400000000000000000000014451325205405000231470ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/ui/gpaste-ui-empty-item.c000066400000000000000000000044641325205405000224030ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include struct _GPasteUiEmptyItem { GPasteUiItemSkeleton parent_instance; }; G_PASTE_DEFINE_TYPE (UiEmptyItem, ui_empty_item, G_PASTE_TYPE_UI_ITEM_SKELETON) static void g_paste_ui_empty_item_show_text (GPasteUiEmptyItem *self, const gchar *text) { g_paste_ui_item_skeleton_set_text (G_PASTE_UI_ITEM_SKELETON (self), text); gtk_widget_show (GTK_WIDGET (self)); } /** * g_paste_ui_empty_show_no_result: * @self: a #GPasteUiEmptyItem instance * * Show a no result message */ G_PASTE_VISIBLE void g_paste_ui_empty_item_show_no_result (GPasteUiEmptyItem *self) { g_return_if_fail (G_PASTE_IS_UI_EMPTY_ITEM (self)); g_paste_ui_empty_item_show_text (self, _("(No result)")); } /** * g_paste_ui_empty_show_empty: * @self: a #GPasteUiEmptyItem instance * * Show an empty message */ G_PASTE_VISIBLE void g_paste_ui_empty_item_show_empty (GPasteUiEmptyItem *self) { g_return_if_fail (G_PASTE_IS_UI_EMPTY_ITEM (self)); g_paste_ui_empty_item_show_text (self, _("(Empty)")); } 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), _("(Couldn't connect to GPaste daemon)")); } /** * 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.28.0/src/libgpaste/ui/gpaste-ui-empty-item.h000066400000000000000000000016241325205405000224030ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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) void g_paste_ui_empty_item_show_no_result (GPasteUiEmptyItem *self); void g_paste_ui_empty_item_show_empty (GPasteUiEmptyItem *self); 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.28.0/src/libgpaste/ui/gpaste-ui-header.c000066400000000000000000000057071325205405000215420ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include #include #include #include #include struct _GPasteUiHeader { GtkHeaderBar parent_instance; }; typedef struct { GtkButton *settings; GtkButton *search; } GPasteUiHeaderPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (UiHeader, ui_header, GTK_TYPE_HEADER_BAR) /** * g_paste_ui_header_show_prefs: * @self: the #GPasteUiHeader * * Show the prefs pane */ G_PASTE_VISIBLE void g_paste_ui_header_show_prefs (const GPasteUiHeader *self) { g_return_if_fail (_G_PASTE_IS_UI_HEADER (self)); const 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); const 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))); gtk_header_bar_pack_end (bar, g_paste_ui_new_item_new (topwin, client)); return self; } gpaste-3.28.0/src/libgpaste/ui/gpaste-ui-header.h000066400000000000000000000014321325205405000215360ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/ui/gpaste-ui-history-action.c000066400000000000000000000106571325205405000232660ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include typedef struct { GPasteClient *client; GPasteUiHistoryActions *actions; GtkWindow *rootwin; gchar *history; } GPasteUiHistoryActionPrivate; G_PASTE_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (UiHistoryAction, 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 */ 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); const 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) { const 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) { const 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.28.0/src/libgpaste/ui/gpaste-ui-history-action.h000066400000000000000000000026121325205405000232630ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/ui/gpaste-ui-history-actions.c000066400000000000000000000102061325205405000234370ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include #include #include "gpaste-gtk-compat.h" struct _GPasteUiHistoryActions { GtkPopover parent_instance; }; typedef struct { GPasteClient *client; GSList *actions; } GPasteUiHistoryActionsPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (UiHistoryActions, 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 */ 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)); const 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) { const 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.28.0/src/libgpaste/ui/gpaste-ui-history-actions.h000066400000000000000000000016201325205405000234440ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/ui/gpaste-ui-history.c000066400000000000000000000316171325205405000220120ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include #include #include #include "gpaste-gtk-compat.h" struct _GPasteUiHistory { GtkListBox parent_instance; }; enum { C_SIZE, C_UPDATE, C_LAST_SIGNAL }; typedef struct { GPasteClient *client; GPasteSettings *settings; GPasteUiPanel *panel; GPasteUiEmptyItem *dummy_item; GtkWindow *rootwin; GSList *items; guint64 size; gint32 item_height; gchar *search; guint64 *search_results; guint64 search_results_size; guint64 c_signals[C_LAST_SIGNAL]; } GPasteUiHistoryPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (UiHistory, ui_history, GTK_TYPE_LIST_BOX) static void on_row_activated (GtkListBox *history G_GNUC_UNUSED, GtkListBoxRow *row) { 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; const 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 (GTK_WIDGET (priv->dummy_item)); else g_paste_ui_empty_item_show_empty (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_measure (GTK_WIDGET ((priv->items) ? priv->items->data : priv->dummy_item), GTK_ORIENTATION_VERTICAL, -1, NULL, &priv->item_height, NULL, NULL); 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; const 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) { const 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); GSList *item = priv->items; priv->search_results = g_paste_client_search_finish (priv->client, res, &priv->search_results_size, NULL /* error */); if (priv->search_results) { if (priv->search_results_size > priv->size) priv->search_results_size = priv->size; 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]); } else { g_paste_ui_empty_item_show_no_result (priv->dummy_item); priv->search_results_size = 0; } 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 */ 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_paste_str_equal (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 { if (search != priv->search) { g_free (priv->search); priv->search = g_strdup (search); } g_paste_client_search (priv->client, search, on_search_ready, self); } } /** * g_paste_ui_history_select_first: * @self: a #GPasteUiHistory instance * * Select the first element * * returns: whether anything was selected or not */ G_PASTE_VISIBLE gboolean g_paste_ui_history_select_first (GPasteUiHistory *self) { g_return_val_if_fail (_G_PASTE_IS_UI_HISTORY (self), FALSE); GPasteUiHistoryPrivate *priv = g_paste_ui_history_get_instance_private (self); if (!priv->items) return FALSE; return g_paste_ui_item_activate (priv->items->data); } 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; const 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) { const GPasteUiHistoryPrivate *priv = _g_paste_ui_history_get_instance_private (G_PASTE_UI_HISTORY (object)); if (priv->settings) { g_signal_handler_disconnect (priv->settings, priv->c_signals[C_SIZE]); g_clear_object (&priv->settings); } if (priv->client) { g_signal_handler_disconnect (priv->client, priv->c_signals[C_UPDATE]); 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) { const 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; GTK_LIST_BOX_CLASS (klass)->row_activated = on_row_activated; } static void g_paste_ui_history_init (GPasteUiHistory *self G_GNUC_UNUSED) { } /** * 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)); GtkWidget *dummy_item = g_paste_ui_empty_item_new (client, settings, rootwin); priv->client = g_object_ref (client); priv->settings = g_object_ref (settings); priv->dummy_item = G_PASTE_UI_EMPTY_ITEM (dummy_item); priv->panel = panel; priv->rootwin = rootwin; gtk_container_add (GTK_CONTAINER (self), dummy_item); priv->c_signals[C_SIZE] = g_signal_connect (settings, "changed::" G_PASTE_MAX_DISPLAYED_HISTORY_SIZE_SETTING, G_CALLBACK (g_paste_ui_history_update_height_request), self); priv->c_signals[C_UPDATE] = 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.28.0/src/libgpaste/ui/gpaste-ui-history.h000066400000000000000000000017061325205405000220130ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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); gboolean g_paste_ui_history_select_first (GPasteUiHistory *self); 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.28.0/src/libgpaste/ui/gpaste-ui-item-action.c000066400000000000000000000063211325205405000225140ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include typedef struct { GPasteClient *client; guint64 index; } GPasteUiItemActionPrivate; G_PASTE_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (UiItemAction, 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 */ 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); const 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) { const 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.28.0/src/libgpaste/ui/gpaste-ui-item-action.h000066400000000000000000000022631325205405000225220ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/ui/gpaste-ui-item-skeleton.c000066400000000000000000000241701325205405000230650ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include #include #include #include "gpaste-gtk-compat.h" enum { C_SIZE, C_LAST_SIGNAL }; typedef struct { GPasteSettings *settings; GSList *actions; GtkWidget *edit; GtkWidget *upload; GtkLabel *index_label; GtkLabel *label; gboolean editable; gboolean uploadable; guint64 c_signals[C_LAST_SIGNAL]; } GPasteUiItemSkeletonPrivate; G_PASTE_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (UiItemSkeleton, 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 */ 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)); const 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->uploadable); } /** * 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 */ 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); } /** * g_paste_ui_item_skeleton_set_uploadable: * @self: the #GPasteUiItemSkeleton instance * @uploadable: whether the item should now be uploadable or not * * Mark the item as being uploadable or not */ G_PASTE_VISIBLE void g_paste_ui_item_skeleton_set_uploadable (GPasteUiItemSkeleton *self, gboolean uploadable) { g_return_if_fail (_G_PASTE_IS_UI_ITEM_SKELETON (self)); GPasteUiItemSkeletonPrivate *priv = g_paste_ui_item_skeleton_get_instance_private (self); priv->uploadable = uploadable; gtk_widget_set_sensitive (priv->upload, uploadable); } /** * g_paste_ui_item_skeleton_set_text: * @self: the #GPasteUiItemSkeleton instance * @text: the new text for the label * * Changes the displayed text */ 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)); const 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 */ 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)); const 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 */ 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)); const 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); const 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_widget_set_halign (w, TRUE); gtk_box_pack_end (b, w); } static void g_paste_ui_item_skeleton_dispose (GObject *object) { const 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->c_signals[C_SIZE]); 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_widget_set_halign (index_label, TRUE); gtk_box_pack_start (GTK_BOX (hbox), index_label, FALSE, TRUE); gtk_widget_set_hexpand (label, TRUE); gtk_widget_set_halign (label, TRUE); gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE); 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->c_signals[C_SIZE] = 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.28.0/src/libgpaste/ui/gpaste-ui-item-skeleton.h000066400000000000000000000036241325205405000230730ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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_uploadable (GPasteUiItemSkeleton *self, gboolean uploadable); 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.28.0/src/libgpaste/ui/gpaste-ui-item.c000066400000000000000000000137471325205405000212530ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include struct _GPasteUiItem { GPasteUiItemSkeleton parent_instance; }; typedef struct { GPasteClient *client; GPasteSettings *settings; GtkWindow *rootwin; guint64 index; gboolean bold; guint64 size_id; } GPasteUiItemPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (UiItem, ui_item, G_PASTE_TYPE_UI_ITEM_SKELETON) /** * g_paste_ui_item_activate: * @self: a #GPasteUiItem instance * * Activate/Select the item * * returns: whether there was anything to select or not */ G_PASTE_VISIBLE gboolean g_paste_ui_item_activate (GPasteUiItem *self) { g_return_val_if_fail (_G_PASTE_IS_UI_ITEM (self), FALSE); const GPasteUiItemPrivate *priv = _g_paste_ui_item_get_instance_private (self); if (priv->index == (guint64) -1) return FALSE; g_paste_client_select (priv->client, priv->index, NULL, NULL); if (g_paste_settings_get_close_on_select (priv->settings)) gtk_window_close (priv->rootwin); /* Exit the application */ return TRUE; } /** * g_paste_ui_item_refresh: * @self: a #GPasteUiItem instance * * Refresh the item */ G_PASTE_VISIBLE void g_paste_ui_item_refresh (GPasteUiItem *self) { g_return_if_fail (_G_PASTE_IS_UI_ITEM (self)); const 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; const 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; const 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; GPasteUiItemSkeleton *sk = G_PASTE_UI_ITEM_SKELETON (self); g_paste_ui_item_skeleton_set_editable (sk, kind == G_PASTE_ITEM_KIND_TEXT); g_paste_ui_item_skeleton_set_uploadable (sk, 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)); const 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 */ 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 if (index != old_index) { gtk_widget_hide (GTK_WIDGET (self)); } } static void g_paste_ui_item_dispose (GObject *object) { const GPasteUiItemPrivate *priv = _g_paste_ui_item_get_instance_private (G_PASTE_UI_ITEM (object)); g_clear_object (&priv->client); g_clear_object (&priv->settings); 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); priv->settings = g_object_ref (settings); priv->rootwin = rootwin; g_paste_ui_item_set_index (G_PASTE_UI_ITEM (self), index); return self; } gpaste-3.28.0/src/libgpaste/ui/gpaste-ui-item.h000066400000000000000000000017501325205405000212470ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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) gboolean 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.28.0/src/libgpaste/ui/gpaste-ui-new-item.c000066400000000000000000000070241325205405000220310ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include "gpaste-gtk-compat.h" struct _GPasteUiNewItem { GtkButton parent_instance; }; typedef struct { GPasteClient *client; GtkWindow *rootwin; } GPasteUiNewItemPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (UiNewItem, ui_new_item, GTK_TYPE_BUTTON) static void g_paste_ui_new_item_clicked (GtkButton *self) { const GPasteUiNewItemPrivate *priv = _g_paste_ui_new_item_get_instance_private (G_PASTE_UI_NEW_ITEM (self)); GtkWidget *dialog = gtk_dialog_new_with_buttons (PACKAGE_STRING, priv->rootwin, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR, _("New"), 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); 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_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_widget_set_vexpand (scroll, TRUE); gtk_widget_set_valign (scroll, TRUE); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (d)), scroll, TRUE, TRUE); gtk_widget_show_all (scroll); if (gtk_dialog_run (d) == GTK_RESPONSE_OK) { const gchar *txt; g_object_get (G_OBJECT (gtk_text_view_get_buffer (tv)), "text", &txt, NULL); if (txt && *txt) g_paste_client_add (priv->client, txt, NULL, NULL); } gtk_widget_destroy (dialog); } static void g_paste_ui_new_item_dispose (GObject *object) { const GPasteUiNewItemPrivate *priv = _g_paste_ui_new_item_get_instance_private (G_PASTE_UI_NEW_ITEM (object)); g_clear_object (&priv->client); G_OBJECT_CLASS (g_paste_ui_new_item_parent_class)->dispose (object); } static void g_paste_ui_new_item_class_init (GPasteUiNewItemClass *klass) { G_OBJECT_CLASS (klass)->dispose = g_paste_ui_new_item_dispose; GTK_BUTTON_CLASS (klass)->clicked = g_paste_ui_new_item_clicked; } static void g_paste_ui_new_item_init (GPasteUiNewItem *self) { GtkWidget *widget = GTK_WIDGET (self); gtk_widget_set_tooltip_text (widget, _("New")); gtk_widget_set_valign (widget, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (self), gtk_image_new_from_icon_name ("document-new-symbolic", GTK_ICON_SIZE_BUTTON)); } /** * g_paste_ui_new_item_new: * @rootwin: the root #GtkWindow * @client: a #GPasteClient * * Create a new instance of #GPasteUiNewItem * * Returns: a newly allocated #GPasteUiNewItem * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_new_item_new (GtkWindow *rootwin, GPasteClient *client) { 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_NEW_ITEM, NULL); GPasteUiNewItemPrivate *priv = g_paste_ui_new_item_get_instance_private (G_PASTE_UI_NEW_ITEM (self)); priv->client = g_object_ref (client); priv->rootwin = rootwin; return self; } gpaste-3.28.0/src/libgpaste/ui/gpaste-ui-new-item.h000066400000000000000000000012341325205405000220330ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_NEW_ITEM_H__ #define __G_PASTE_UI_NEW_ITEM_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_NEW_ITEM (g_paste_ui_new_item_get_type ()) G_PASTE_FINAL_TYPE (UiNewItem, ui_new_item, UI_NEW_ITEM, GtkButton) GtkWidget *g_paste_ui_new_item_new (GtkWindow *rootwin, GPasteClient *client); G_END_DECLS #endif /*__G_PASTE_UI_NEW_ITEM_H__*/ gpaste-3.28.0/src/libgpaste/ui/gpaste-ui-panel-history.c000066400000000000000000000116251325205405000231040ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include "gpaste-gtk-compat.h" struct _GPasteUiPanelHistory { GtkListBoxRow parent_instance; }; typedef struct { GPasteClient *client; GtkLabel *index_label; GtkLabel *label; gchar *history; } GPasteUiPanelHistoryPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (UiPanelHistory, ui_panel_history, GTK_TYPE_LIST_BOX_ROW) /** * g_paste_ui_panel_history_activate: * @self: a #GPasteUiPanelHistory instance * * Switch to this history */ G_PASTE_VISIBLE void g_paste_ui_panel_history_activate (GPasteUiPanelHistory *self) { g_return_if_fail (_G_PASTE_IS_UI_PANEL_HISTORY (self)); const 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 */ 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)); const 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); const 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) { const 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); gtk_widget_set_hexpand (l, TRUE); gtk_widget_set_halign (l, TRUE); gtk_box_pack_start (box, l, TRUE, TRUE); 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.28.0/src/libgpaste/ui/gpaste-ui-panel-history.h000066400000000000000000000017771325205405000231200ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/ui/gpaste-ui-panel.c000066400000000000000000000306321325205405000214040ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include "gpaste-gtk-compat.h" struct _GPasteUiPanel { GtkBox parent_instance; }; enum { C_ACTIVATED, C_BUTTON_PRESSED, C_DELETE_HISTORY, C_EMPTY_HISTORY, C_SWITCH_ACTIVATED, C_SWITCH_CLICKED, C_SWITCH_HISTORY, C_LAST_SIGNAL }; typedef struct { GPasteClient *client; GPasteSettings *settings; GPasteUiHistoryActions *actions; GtkListBox *list_box; GtkEntry *switch_entry; GList *histories; GtkWidget *search_entry; guint64 c_signals[C_LAST_SIGNAL]; } GPasteUiPanelPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (UiPanel, ui_panel, GTK_TYPE_BOX) static gint32 history_equals (gconstpointer a, gconstpointer b) { return !g_paste_str_equal (b, g_paste_ui_panel_history_get_history (a)); } static GList * history_find (GList *histories, const gchar *history) { return g_list_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 */ 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)); const GPasteUiPanelPrivate *priv = _g_paste_ui_panel_get_instance_private (self); GList *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_paste_str_equal (history, G_PASTE_DEFAULT_HISTORY)) return; GList *h = history_find (priv->histories, history); if (!h) return; priv->histories = g_list_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); GList *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_list_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, G_PASTE_DEFAULT_HISTORY, g_paste_str_equal (G_PASTE_DEFAULT_HISTORY, current)); for (GStrv h = histories; *h; ++h) g_paste_ui_panel_add_history (priv, *h, g_paste_str_equal (*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; GdkEvent *_event = (GdkEvent *) event; if (gdk_event_triggers_context_menu (_event)) { gdouble y; if (!gdk_event_get_axis (_event, GDK_AXIS_Y, &y)) return FALSE; 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, 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 : G_PASTE_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->c_signals[C_ACTIVATED]) { g_signal_handler_disconnect (priv->list_box, priv->c_signals[C_ACTIVATED]); g_signal_handler_disconnect (priv->list_box, priv->c_signals[C_BUTTON_PRESSED]); g_signal_handler_disconnect (priv->switch_entry, priv->c_signals[C_SWITCH_ACTIVATED]); g_signal_handler_disconnect (priv->switch_entry, priv->c_signals[C_SWITCH_CLICKED]); priv->c_signals[C_ACTIVATED] = 0; } if (priv->client) { g_signal_handler_disconnect (priv->client, priv->c_signals[C_DELETE_HISTORY]); g_signal_handler_disconnect (priv->client, priv->c_signals[C_EMPTY_HISTORY]); g_signal_handler_disconnect (priv->client, priv->c_signals[C_SWITCH_HISTORY]); 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, G_PASTE_DEFAULT_HISTORY); priv->c_signals[C_ACTIVATED] = g_signal_connect (G_OBJECT (priv->list_box), "row-activated", G_CALLBACK (on_row_activated), NULL); priv->c_signals[C_BUTTON_PRESSED] = g_signal_connect (G_OBJECT (list_box), "button-press-event", G_CALLBACK (g_paste_ui_panel_button_press_event), priv); priv->c_signals[C_SWITCH_ACTIVATED] = g_signal_connect (G_OBJECT (switch_entry), "activate", G_CALLBACK (g_paste_ui_panel_switch_activated), priv); priv->c_signals[C_SWITCH_CLICKED] = g_signal_connect (G_OBJECT (switch_entry), "icon-press", G_CALLBACK (g_paste_ui_panel_switch_clicked), priv); gtk_widget_set_valign (list_box, TRUE); gtk_box_pack_start (box, list_box, FALSE, TRUE); gtk_box_pack_start (box, switch_entry, FALSE, FALSE); } /** * 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->c_signals[C_DELETE_HISTORY] = g_signal_connect (priv->client, "delete-history", G_CALLBACK (on_history_deleted), priv); priv->c_signals[C_EMPTY_HISTORY] = g_signal_connect (priv->client, "empty-history", G_CALLBACK (on_history_emptied), self); priv->c_signals[C_SWITCH_HISTORY] = 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.28.0/src/libgpaste/ui/gpaste-ui-panel.h000066400000000000000000000017441325205405000214130ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/ui/gpaste-ui-reexec.c000066400000000000000000000044341325205405000215610ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include struct _GPasteUiReexec { GtkButton parent_instance; }; typedef struct { GPasteClient *client; GtkWindow *topwin; } GPasteUiReexecPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (UiReexec, ui_reexec, GTK_TYPE_BUTTON) static void g_paste_ui_reexec_clicked (GtkButton *button) { const 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) { const 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) { GtkWidget *widget = GTK_WIDGET (self); gtk_widget_set_tooltip_text (widget, _("Restart the daemon")); gtk_widget_set_valign (widget, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (self), gtk_image_new_from_icon_name ("view-refresh-symbolic", GTK_ICON_SIZE_BUTTON)); } /** * 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,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.28.0/src/libgpaste/ui/gpaste-ui-reexec.h000066400000000000000000000012101325205405000215530ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/ui/gpaste-ui-search-bar.c000066400000000000000000000027711325205405000223170ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include struct _GPasteUiSearchBar { GtkSearchBar parent_instance; }; typedef struct { GtkSearchEntry *entry; } GPasteUiSearchBarPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (UiSearchBar, 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); const 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.28.0/src/libgpaste/ui/gpaste-ui-search-bar.h000066400000000000000000000012641325205405000223200ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/ui/gpaste-ui-search.c000066400000000000000000000017501325205405000215510ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include struct _GPasteUiSearch { GtkToggleButton parent_instance; }; G_PASTE_DEFINE_TYPE (UiSearch, 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) { GtkWidget *widget = GTK_WIDGET (self); gtk_widget_set_tooltip_text (widget, _("Search")); gtk_widget_set_valign (widget, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (self), gtk_image_new_from_icon_name ("edit-find-symbolic", GTK_ICON_SIZE_BUTTON)); } /** * 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, NULL); } gpaste-3.28.0/src/libgpaste/ui/gpaste-ui-search.h000066400000000000000000000011061325205405000215510ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/ui/gpaste-ui-settings.c000066400000000000000000000027131325205405000221440ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include "gpaste-gtk-compat.h" struct _GPasteUiSettings { GtkMenuButton parent_instance; }; G_PASTE_DEFINE_TYPE (UiSettings, 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) { GtkWidget *widget = GTK_WIDGET (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 (widget, _("GPaste Settings")); gtk_widget_set_valign (widget, GTK_ALIGN_CENTER); gtk_widget_set_margin_top (settings_widget, 10); 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.28.0/src/libgpaste/ui/gpaste-ui-settings.h000066400000000000000000000011261325205405000221460ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/ui/gpaste-ui-shortcuts-window.c000066400000000000000000000066071325205405000236550ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include struct _GPasteUiShortcutsWindow { GtkShortcutsWindow parent_instance; }; G_PASTE_DEFINE_TYPE (UiShortcutsWindow, ui_shortcuts_window, GTK_TYPE_SHORTCUTS_WINDOW) static void g_paste_ui_shortcuts_window_class_init (GPasteUiShortcutsWindowClass *klass G_GNUC_UNUSED) { } static void g_paste_ui_shortcuts_window_init (GPasteUiShortcutsWindow *self G_GNUC_UNUSED) { } static inline void add_shortcut (GtkContainer *group, const gchar *title, const gchar *accelerator) { gtk_container_add (group, gtk_widget_new (GTK_TYPE_SHORTCUTS_SHORTCUT, "visible", TRUE, "title", title, "accelerator", accelerator, NULL)); } /** * g_paste_ui_shortcuts_window_new: * @settings: a #GPasteSettings instance * * Create a new instance of #GPasteUiShortcutsWindow * * Returns: a newly allocated #GPasteUiShortcutsWindow * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_shortcuts_window_new (const GPasteSettings *settings) { g_return_val_if_fail (_G_PASTE_IS_SETTINGS (settings), NULL); GtkWidget *self = gtk_widget_new (G_PASTE_TYPE_UI_SHORTCUTS_WINDOW, "type", GTK_WINDOW_TOPLEVEL, "window-position", GTK_WIN_POS_CENTER_ALWAYS, "modal", TRUE, "resizable", FALSE, NULL); GtkWidget *section = gtk_widget_new (GTK_TYPE_SHORTCUTS_SECTION, "section-name", "shortcuts", "visible", TRUE, "max-height", 10, NULL); GtkWidget *general_group = gtk_widget_new (GTK_TYPE_SHORTCUTS_GROUP, "title", _("General"), "visible", TRUE, NULL); GtkContainer *ggroup = GTK_CONTAINER (general_group); gtk_container_add (GTK_CONTAINER (self), section); gtk_container_add (GTK_CONTAINER (section), general_group); add_shortcut (ggroup, _("Delete the active item from history"), g_paste_settings_get_pop (settings)); add_shortcut (ggroup, _("Launch the graphical tool"), g_paste_settings_get_launch_ui (settings)); add_shortcut (ggroup, _("Mark the active item as being a password"), g_paste_settings_get_make_password (settings)); add_shortcut (ggroup, _("Display the history"), g_paste_settings_get_show_history (settings)); add_shortcut (ggroup, _("Sync the clipboard to the primary selection"), g_paste_settings_get_sync_clipboard_to_primary (settings)); add_shortcut (ggroup, _("Sync the primary selection to the clipboard"), g_paste_settings_get_sync_primary_to_clipboard (settings)); add_shortcut (ggroup, _("Upload the active item to a pastebin service"), g_paste_settings_get_upload (settings)); return self; } gpaste-3.28.0/src/libgpaste/ui/gpaste-ui-shortcuts-window.h000066400000000000000000000012761325205405000236570ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION) #error "Only can be included directly." #endif #ifndef __G_PASTE_UI_SHORTCUTS_WINDOW_H__ #define __G_PASTE_UI_SHORTCUTS_WINDOW_H__ #include G_BEGIN_DECLS #define G_PASTE_TYPE_UI_SHORTCUTS_WINDOW (g_paste_ui_shortcuts_window_get_type ()) G_PASTE_FINAL_TYPE (UiShortcutsWindow, ui_shortcuts_window, UI_SHORTCUTS_WINDOW, GtkShortcutsWindow) GtkWidget *g_paste_ui_shortcuts_window_new (const GPasteSettings *settings); G_END_DECLS #endif /*__G_PASTE_UI_SHORTCUTS_WINDOW_H__*/ gpaste-3.28.0/src/libgpaste/ui/gpaste-ui-switch.c000066400000000000000000000065241325205405000216110ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include struct _GPasteUiSwitch { GtkSwitch parent_instance; }; enum { C_TRACKING, C_LAST_SIGNAL }; typedef struct { GPasteClient *client; GtkWindow *topwin; guint64 c_signals[C_LAST_SIGNAL]; } GPasteUiSwitchPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (UiSwitch, 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) { const 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->c_signals[C_TRACKING]) { g_signal_handler_disconnect (priv->client, priv->c_signals[C_TRACKING]); priv->c_signals[C_TRACKING] = 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) { GtkWidget *widget = GTK_WIDGET (self); gtk_widget_set_tooltip_text (widget, _("Track clipboard changes")); gtk_widget_set_valign (widget, GTK_ALIGN_CENTER); } /** * 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->c_signals[C_TRACKING] = 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.28.0/src/libgpaste/ui/gpaste-ui-switch.h000066400000000000000000000012101325205405000216010ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/ui/gpaste-ui-upload-item.c000066400000000000000000000024311325205405000225210ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include struct _GPasteUiUploadItem { GPasteUiItemAction parent_instance; }; G_PASTE_DEFINE_TYPE (UiUploadItem, 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.28.0/src/libgpaste/ui/gpaste-ui-upload-item.h000066400000000000000000000012151325205405000225250ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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.28.0/src/libgpaste/ui/gpaste-ui-window.c000066400000000000000000000260371325205405000216200ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include #include #include #include #include "gpaste-gtk-compat.h" struct _GPasteUiWindow { GtkApplicationWindow parent_instance; }; enum { C_SEARCH, C_LAST_SIGNAL }; typedef struct { GPasteUiHeader *header; GPasteUiHistory *history; GPasteClient *client; GtkSearchBar *search_bar; GtkSearchEntry *search_entry; gboolean initialized; guint64 c_signals[C_LAST_SIGNAL]; } GPasteUiWindowPrivate; G_PASTE_DEFINE_TYPE_WITH_PRIVATE (UiWindow, ui_window, GTK_TYPE_APPLICATION_WINDOW) static gboolean _empty (gpointer user_data) { gpointer *data = (gpointer *) user_data; GPasteUiWindow *self = data[0]; GPasteUiWindowPrivate *priv = g_paste_ui_window_get_instance_private (self); if (!priv->initialized) return G_SOURCE_CONTINUE; g_autofree gchar *history = data[1]; g_free (data); g_paste_util_empty_history (GTK_WINDOW (self), priv->client, history); return G_SOURCE_REMOVE; } /** * g_paste_ui_window_empty_history: * @self: the #GPasteUiWindow * @history: the history to empty * * Empty an history */ G_PASTE_VISIBLE void g_paste_ui_window_empty_history (GPasteUiWindow *self, const gchar *history) { g_return_if_fail (_G_PASTE_IS_UI_WINDOW (self)); g_return_if_fail (g_utf8_validate (history, -1, NULL)); gpointer *data = g_new (gpointer, 2); data[0] = self; data[1] = g_strdup (history); g_source_set_name_by_id (g_idle_add (_empty, data), "[GPaste] empty"); } 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 */ G_PASTE_VISIBLE void g_paste_ui_window_search (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 */ G_PASTE_VISIBLE void g_paste_ui_window_show_prefs (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, GdkEventKey *event) { const GPasteUiWindowPrivate *priv = _g_paste_ui_window_get_instance_private (G_PASTE_UI_WINDOW (widget)); GtkWidget *focus = gtk_window_get_focus (GTK_WINDOW (widget)); GdkEvent *_event = (GdkEvent *) event; gboolean search_has_focus = focus == GTK_WIDGET (priv->search_entry); gboolean search_in_progress = search_has_focus && gtk_entry_get_text_length (GTK_ENTRY (priv->search_entry)); gboolean forward_to_search = FALSE; guint keyval; if (gdk_event_get_keyval (_event, &keyval)) { switch (keyval) { case GDK_KEY_Escape: if (!search_in_progress) { gtk_window_close (GTK_WINDOW (widget)); return GDK_EVENT_STOP; } else { forward_to_search = TRUE; } break; case GDK_KEY_Return: case GDK_KEY_KP_Enter: case GDK_KEY_ISO_Enter: if (search_in_progress && g_paste_ui_history_select_first (priv->history)) return GDK_EVENT_STOP; break; default: forward_to_search = TRUE; break; } } if (forward_to_search && gtk_search_bar_handle_event (priv->search_bar, _event)) return GDK_EVENT_STOP; gboolean res = GTK_WIDGET_CLASS (g_paste_ui_window_parent_class)->key_press_event (widget, event); if (res == GDK_EVENT_STOP || !forward_to_search || search_has_focus) return res; // fallback to explicitely focusing search to see if key can be handled gtk_entry_grab_focus_without_selecting (GTK_ENTRY (priv->search_entry)); if (gtk_search_bar_handle_event (priv->search_bar, _event)) return GDK_EVENT_STOP; if (GTK_WIDGET_CLASS (g_paste_ui_window_parent_class)->key_press_event (widget, event) == GDK_EVENT_STOP) return GDK_EVENT_STOP; gtk_widget_grab_focus (focus); return res; } 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 gboolean focus_search (gpointer user_data) { GPasteUiWindow *self = user_data; const GPasteUiWindowPrivate *priv = _g_paste_ui_window_get_instance_private (self); GtkWindow *win = user_data; GtkWidget *widget = user_data; if (!GTK_IS_WIDGET (widget)) return G_SOURCE_REMOVE; if (!gtk_widget_get_realized (widget)) return G_SOURCE_CONTINUE; gtk_window_set_focus (win, GTK_WIDGET (priv->search_entry)); return G_SOURCE_REMOVE; } 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->c_signals[C_SEARCH]) { GPasteUiSearchBar *search_bar = G_PASTE_UI_SEARCH_BAR (priv->search_bar); GtkSearchEntry *entry = g_paste_ui_search_bar_get_entry (search_bar); g_signal_handler_disconnect (entry, priv->c_signals[C_SEARCH]); priv->c_signals[C_SEARCH] = 0; } g_clear_object (&priv->client); 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; GTK_WIDGET_CLASS (klass)->key_press_event = on_key_press_event; } 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); priv->search_bar = GTK_SEARCH_BAR (search_bar); gtk_container_add (GTK_CONTAINER (win), vbox); gtk_box_pack_start (GTK_BOX (box), search_bar, FALSE, FALSE); GtkSearchEntry *entry = priv->search_entry = g_paste_ui_search_bar_get_entry (G_PASTE_UI_SEARCH_BAR (search_bar)); priv->c_signals[C_SEARCH] = g_signal_connect (entry, "search-changed", G_CALLBACK (on_search), priv); g_source_set_name_by_id (g_idle_add (focus_search, self), "[GPaste] focus_search"); } 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); priv->client = g_object_ref (client); gtk_window_set_titlebar (win, header); gtk_application_window_set_help_overlay (GTK_APPLICATION_WINDOW (user_data), GTK_SHORTCUTS_WINDOW (g_paste_ui_shortcuts_window_new (settings))); 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_set_spacing (box, 2); gtk_box_pack_start (box, panel, FALSE, FALSE); gtk_box_pack_start (box, gtk_separator_new (GTK_ORIENTATION_VERTICAL), FALSE, FALSE); gtk_widget_set_hexpand (history, TRUE); gtk_widget_set_halign (history, TRUE); gtk_box_pack_start (box, history, TRUE, TRUE); gtk_widget_set_vexpand (hbox, TRUE); gtk_widget_set_valign (hbox, TRUE); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE); 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, "icon-name", G_PASTE_ICON_NAME, NULL); g_paste_client_new (on_client_ready, self); return self; } gpaste-3.28.0/src/libgpaste/ui/gpaste-ui-window.h000066400000000000000000000016171325205405000216220ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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_empty_history (GPasteUiWindow *self, const gchar *history); void g_paste_ui_window_search (GPasteUiWindow *self, const gchar *search); void g_paste_ui_window_show_prefs (GPasteUiWindow *self); GtkWidget *g_paste_ui_window_new (GtkApplication *app); G_END_DECLS #endif /*__G_PASTE_UI_WINDOW_H__*/ gpaste-3.28.0/src/libgpaste/util/000077500000000000000000000000001325205405000166015ustar00rootroot00000000000000gpaste-3.28.0/src/libgpaste/util/gpaste-util.c000066400000000000000000000454521325205405000212150ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include #include "gpaste-gtk-compat.h" /** * g_paste_util_confirm_dialog: * @parent: (nullable): the parent #GtkWindow * @msg: the message to display * * Show GPaste about dialog */ 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_widget_set_vexpand (label, TRUE); gtk_widget_set_valign (label, TRUE); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (d)), label, TRUE, TRUE); 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 */ 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 */ 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; const guint8 *data = gdk_pixbuf_read_pixels (image); gsize length = gdk_pixbuf_get_byte_length (image); return g_compute_checksum_for_data (G_CHECKSUM_SHA256, data, length); } /** * g_paste_util_empty_history: * @parent_window: (nullable): the parent #GtkWindow * @client: a #GPasteClient instance * @history: the name of the history to empty * * Empty history after prompting user for confirmation */ G_PASTE_VISIBLE void g_paste_util_empty_history (GtkWindow *parent_window, GPasteClient *client, const gchar *history) { /* Translators: this is the translation for emptying the history */ if (g_paste_util_confirm_dialog (parent_window, _("Empty"), _("Do you really want to empty the history?"))) g_paste_client_empty_history (client, history, NULL, NULL); } /** * g_paste_util_has_gnome_shell: * * Check whether gnome-shell is installed or not * * Returns: %TRUE if gnome-shell is installed */ G_PASTE_VISIBLE gboolean g_paste_util_has_gnome_shell (void) { GSettingsSchemaSource *source = g_settings_schema_source_get_default (); if (!source) return FALSE; g_autoptr (GSettingsSchema) schema = g_settings_schema_source_lookup (source, G_PASTE_SHELL_SETTINGS_NAME, TRUE); return !!schema; } /** * g_paste_util_show_win: * @application: a #GtkApplication * * Present the application's window to user */ 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_IS_WIDGET (wins->data) && 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; } static gchar * g_paste_util_get_runtime_dir (const gchar *component) { g_return_val_if_fail (component, NULL); return g_strdup_printf ("%s/" PACKAGE_NAME "/%s", g_get_user_runtime_dir (), component); } /** * g_paste_util_write_pid_file: * @component: The component we're handling * * Write the pid file */ G_PASTE_VISIBLE void g_paste_util_write_pid_file (const gchar *component) { g_return_if_fail (component); g_autofree gchar *dir = g_paste_util_get_runtime_dir (component); g_mkdir_with_parents (dir, 0700); g_autofree gchar *pidfile = g_strdup_printf ("%s/pid", dir); g_autofree gchar *contents = g_strdup_printf ("%" G_PID_FORMAT, getpid ()); g_file_set_contents (pidfile, contents, -1, NULL); } /** * g_paste_util_read_pid_file: * @component: The component we're handling * * Read the pid file * * Returns: the pid */ G_PASTE_VISIBLE GPid g_paste_util_read_pid_file (const gchar *component) { g_return_val_if_fail (component, (GPid) -1); #ifdef G_OS_UNIX g_autofree gchar *dir = g_paste_util_get_runtime_dir (component); g_autofree gchar *pidfile = g_strdup_printf ("%s/pid", dir); g_autofree gchar *contents = NULL; if (!g_file_get_contents (pidfile, &contents, NULL, NULL)) return (GPid) -1; return (GPid) g_ascii_strtoll (contents, NULL, 0); #else return (GPid) -1; #endif } /** * g_paste_util_xml_decode: * @text: The text to decode * * Decode the text to its original pre-xml form * * Returns: the decoded text */ G_PASTE_VISIBLE gchar * g_paste_util_xml_decode (const gchar *text) { g_return_val_if_fail (text, NULL); g_autofree gchar *_decoded_text = g_paste_util_replace (text, ">", ">"); return g_paste_util_replace (_decoded_text, "&", "&"); } /** * g_paste_util_xml_encode: * @text: The text to encode * * Encode the text into its xml form * * Returns: the encoded text */ G_PASTE_VISIBLE gchar * g_paste_util_xml_encode (const gchar *text) { g_return_val_if_fail (text, NULL); g_autofree gchar *_encoded_text = g_paste_util_replace (text, "&", "&"); return g_paste_util_replace (_encoded_text, ">", ">"); } /** * g_paste_util_get_history_dir_path: * * Get the path to the directory where we store the history * * Returns: the directory path */ G_PASTE_VISIBLE gchar * g_paste_util_get_history_dir_path (void) { return g_build_filename (g_get_user_data_dir (), PACKAGE, NULL); } /** * g_paste_util_get_history_dir: * * Get the directory where we store the history * * Returns: (transfer full): the directory */ G_PASTE_VISIBLE GFile * g_paste_util_get_history_dir (void) { g_autofree gchar *history_dir_path = g_paste_util_get_history_dir_path (); return g_file_new_for_path (history_dir_path); } /** * g_paste_util_get_history_file_path: * @name: the name of the history * @extension: the file extension * * Get the path to the file in which we store the history * * Returns: the file path */ G_PASTE_VISIBLE gchar * g_paste_util_get_history_file_path (const gchar *name, const gchar *extension) { g_return_val_if_fail (name, NULL); g_return_val_if_fail (extension, NULL); g_autofree gchar *history_dir_path = g_paste_util_get_history_dir_path (); g_autofree gchar *history_file_name = g_strconcat (name, ".", extension, NULL); return g_build_filename (history_dir_path, history_file_name, NULL); } /** * g_paste_util_get_history_file: * @name: the name of the history * @extension: the file extension * * Get the file in which we store the history * * Returns: (transfer full): the file */ G_PASTE_VISIBLE GFile * g_paste_util_get_history_file (const gchar *name, const gchar *extension) { g_return_val_if_fail (name, NULL); g_return_val_if_fail (extension, NULL); g_autofree gchar *history_file_path = g_paste_util_get_history_file_path (name, extension); return g_file_new_for_path (history_file_path); } /** * g_paste_util_ensure_history_dir_exists: * @settings: a #GPasteSettings instance * * Ensure the history dir exists * * Returns: where it exists or if there was an error creating it */ G_PASTE_VISIBLE gboolean g_paste_util_ensure_history_dir_exists (const GPasteSettings *settings) { g_return_val_if_fail (_G_PASTE_IS_SETTINGS (settings), FALSE); g_autoptr (GFile) history_dir = g_paste_util_get_history_dir (); if (!g_file_query_exists (history_dir, NULL)) /* cancellable */ { if (!g_paste_settings_get_save_history (settings)) 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; } gpaste-3.28.0/src/libgpaste/util/gpaste-util.h000066400000000000000000000050401325205405000212070ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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 #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); void g_paste_util_empty_history (GtkWindow *parent_window, GPasteClient *client, const gchar *history); gboolean g_paste_util_has_gnome_shell (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); void g_paste_util_write_pid_file (const gchar *component); GPid g_paste_util_read_pid_file (const gchar *component); gchar *g_paste_util_xml_decode (const gchar *text); gchar *g_paste_util_xml_encode (const gchar *text); gchar *g_paste_util_get_history_dir_path (void); GFile *g_paste_util_get_history_dir (void); gchar *g_paste_util_get_history_file_path (const gchar *name, const gchar *extension); GFile *g_paste_util_get_history_file (const gchar *name, const gchar *extension); gboolean g_paste_util_ensure_history_dir_exists (const GPasteSettings *settings); G_END_DECLS #endif /*__G_PASTE_UTIL_H__*/ gpaste-3.28.0/src/ui.mk000066400000000000000000000007131325205405000146210ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou pkglibexec_PROGRAMS += \ bin/gpaste-ui \ $(NULL) bin_gpaste_ui_SOURCES = \ %D%/ui/gpaste-ui.c \ $(NULL) bin_gpaste_ui_CFLAGS = \ $(GLIB_CFLAGS) \ $(GTK_CFLAGS) \ $(NULL) bin_gpaste_ui_LDADD = \ $(builddir)/$(libgpaste_la_file) \ $(GLIB_LIBS) \ $(GTK_LIBS) \ $(NULL) gpaste-3.28.0/src/ui/000077500000000000000000000000001325205405000142675ustar00rootroot00000000000000gpaste-3.28.0/src/ui/gpaste-ui.c000066400000000000000000000074601325205405000163400ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #include #include 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) { GtkWidget *widget = user_data; if (!GTK_IS_WIDGET (widget)) return G_SOURCE_REMOVE; if (!gtk_widget_get_realized (widget)) return G_SOURCE_CONTINUE; GtkWindow *parent = GTK_WINDOW (widget); const gchar *authors[] = { "Marc-Antoine Perennou ", NULL }; gtk_show_about_dialog (parent, "program-name", PACKAGE_NAME, "version", PACKAGE_VERSION, "logo-icon-name", G_PASTE_ICON_NAME, "license-type", GTK_LICENSE_BSD, "authors", authors, "copyright", "Copyright (c) 2010-2018, 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_source_set_name_by_id (g_idle_add (show_about_dialog, gtk_application_get_windows (GTK_APPLICATION (user_data))->data), "[GPaste] about_dialog"); } static void empty_activated (GSimpleAction *action G_GNUC_UNUSED, GVariant *parameter, gpointer user_data) { g_paste_ui_window_empty_history (get_ui_window (user_data), g_variant_get_string (parameter, NULL)); } 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 } }, { "empty", empty_activated, "s", 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, _("Keyboard Shortcuts"), "win.show-help-overlay"); 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.28.0/src/vapi.mk000066400000000000000000000021071325205405000151420ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou VAPIGEN_VAPIS = $(NULL) libgpaste_vapi_file = bindings/gpaste-1.0.vapi libgpaste_vapi_deps_file = $(libgpaste_vapi_file:.vapi=.deps) GPASTE_VAPI_DEPS = \ gdk-pixbuf-2.0 \ gio-2.0 \ glib-2.0 \ gobject-2.0 \ gtk+-3.0 \ $(NULL) $(libgpaste_vapi_deps_file): $(libgpaste_gir_file) $(AM_V_GEN) rm -f $@; \ for dep in ${GPASTE_VAPI_DEPS}; do \ echo $$dep >> $@; \ done $(libgpaste_vapi_file): $(libgpaste_gir_file) $(libgpaste_vapi_deps_file) bindings_gpaste_1_0_vapi_FILES = \ $(libgpaste_gir_file) \ $(NULL) bindings_gpaste_1_0_vapi_DEPS = \ $(GPASTE_VAPI_DEPS) \ $(NULL) vapidir = $(datadir)/vala/vapi vapi_DATA = $(NULL) if ENABLE_VAPIGEN VAPIGEN_VAPIS += \ $(libgpaste_vapi_file) \ $(NULL) vapi_DATA += \ $(VAPIGEN_VAPIS) \ $(libgpaste_vapi_deps_file) \ $(NULL) endif CLEANFILES += \ $(vapi_DATA) \ $(NULL) -include $(VAPIGEN_MAKEFILE) gpaste-3.28.0/tests/000077500000000000000000000000001325205405000142255ustar00rootroot00000000000000gpaste-3.28.0/tests/gnome-shell-client.mk000066400000000000000000000010471325205405000202460ustar00rootroot00000000000000## This file is part of GPaste. ## ## Copyright (c) 2010-2018, Marc-Antoine Perennou TESTS+= \ bin/test-gnome-shell-client \ $(NULL) bin_test_gnome_shell_client_SOURCES = \ %D%/gnome-shell-client/test-gnome-shell-client.c \ $(NULL) bin_test_gnome_shell_client_CFLAGS = \ $(GLIB_CFLAGS) \ $(GTK_CFLAGS) \ $(NULL) bin_test_gnome_shell_client_LDADD = \ $(builddir)/$(libgpaste_la_file) \ $(GLIB_LIBS) \ $(NULL) gpaste-3.28.0/tests/gnome-shell-client/000077500000000000000000000000001325205405000177135ustar00rootroot00000000000000gpaste-3.28.0/tests/gnome-shell-client/test-gnome-shell-client.c000066400000000000000000000063341325205405000245300ustar00rootroot00000000000000/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou */ #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_paste_str_equal (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.28.0/tools/000077500000000000000000000000001325205405000142235ustar00rootroot00000000000000gpaste-3.28.0/tools/check-includes.sh000077500000000000000000000027431325205405000174510ustar00rootroot00000000000000#!/usr/bin/env zsh typeset -A includes get_file_name() { local file="${1}" if [[ "${file}" == *.h ]]; then echo "$(basename ${file})" else echo "${file}" fi } parse_includes() { local file name for file in **/*.[ch]; do name=$(get_file_name "${file}") includes[${name}]="$(grep '#include' "${file}" | awk '{print $NF}' | sed -e 's///' -e 's/"//g')" done } get_includes() { local file="${1}" local name name=$(get_file_name "${file}") echo ${includes[${name}]} } has_include() { local file="${1}" local include="${2}" local output="${3}" local i for i in $(get_includes "${file}"); do [[ "${i}" == "${include}" ]] && echo "${include}: ${output} => ${include}" && return 0 has_include "${i}" "${include}" "${output} => ${i}" && return 0 done return 1 } check_include() { local file="${1}" local include="${2}" local i for i in $(get_includes "${file}"); do [[ "${include}" == "${i}" ]] && continue has_include "${i}" "${include}" "${file} => ${i}" done } check_includes() { local file i for file in **/*.[ch]; do [[ "${file}" == "src/libgpaste/gpaste.h" ]] && continue for i in $(get_includes "${file}"); do check_include "${file}" "${i}" done done } main() { pushd "$(dirname "${1}")/.." &>/dev/null parse_includes check_includes popd &>/dev/null } main "${0}"