From erland at xfce.org Sat Mar 1 13:08:25 2008 From: erland at xfce.org (Erlend Davidson) Date: Sat, 1 Mar 2008 12:08:25 +0000 (UTC) Subject: [Goodies-commits] r4013 - thunar-thumbnailers/tags Message-ID: <20080301120825.CA54DF29D8@mocha.foo-projects.org> Author: erland Date: 2008-03-01 12:08:25 +0000 (Sat, 01 Mar 2008) New Revision: 4013 Added: thunar-thumbnailers/tags/0.3.1/ Log: Tagging the 0.3.1 release Copied: thunar-thumbnailers/tags/0.3.1 (from rev 4012, thunar-thumbnailers/trunk) From peter at xfce.org Sat Mar 1 17:58:49 2008 From: peter at xfce.org (Peter de Ridder) Date: Sat, 1 Mar 2008 16:58:49 +0000 (UTC) Subject: [Goodies-commits] r4014 - thunar-svn-plugin/trunk Message-ID: <20080301165849.043B9F29D8@mocha.foo-projects.org> Author: peter Date: 2008-03-01 16:58:48 +0000 (Sat, 01 Mar 2008) New Revision: 4014 Modified: thunar-svn-plugin/trunk/INSTALL thunar-svn-plugin/trunk/README Log: added --prefix entry to the readme file Modified: thunar-svn-plugin/trunk/INSTALL =================================================================== --- thunar-svn-plugin/trunk/INSTALL 2008-03-01 12:08:25 UTC (rev 4013) +++ thunar-svn-plugin/trunk/INSTALL 2008-03-01 16:58:48 UTC (rev 4014) @@ -2,7 +2,7 @@ ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, -2006 Free Software Foundation, Inc. +2006, 2007 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. @@ -67,6 +67,9 @@ all sorts of other programs in order to regenerate files that came with the distribution. + 6. Often, you can also type `make uninstall' to remove the installed + files again. + Compilers and Options ===================== Modified: thunar-svn-plugin/trunk/README =================================================================== --- thunar-svn-plugin/trunk/README 2008-03-01 12:08:25 UTC (rev 4013) +++ thunar-svn-plugin/trunk/README 2008-03-01 16:58:48 UTC (rev 4014) @@ -34,8 +34,9 @@ Installation ============ -The file 'INSTALL' contains generic installation instructions. For more detailed -information, visit the thunar-svn-plugin website at +The file 'INSTALL' contains generic installation instructions. Make sure to run +./configure --prefix=$(pkg-config --variable prefix thunarx-1) so Thunar can +find the plugin. For more information, visit the thunar-svn-plugin website at http://goodies.xfce.org/projects/thunar-plugins/thunar-svn-plugin From majkl at xfce.org Sat Mar 1 20:00:31 2008 From: majkl at xfce.org (Michal Varady) Date: Sat, 1 Mar 2008 19:00:31 +0000 (UTC) Subject: [Goodies-commits] r4015 - notification-daemon-xfce/trunk/po Message-ID: <20080301190031.9137FF29D8@mocha.foo-projects.org> Author: majkl Date: 2008-03-01 19:00:31 +0000 (Sat, 01 Mar 2008) New Revision: 4015 Modified: notification-daemon-xfce/trunk/po/LINGUAS Log: cs added into LINGUAS Modified: notification-daemon-xfce/trunk/po/LINGUAS =================================================================== --- notification-daemon-xfce/trunk/po/LINGUAS 2008-03-01 16:58:48 UTC (rev 4014) +++ notification-daemon-xfce/trunk/po/LINGUAS 2008-03-01 19:00:31 UTC (rev 4015) @@ -1,2 +1,2 @@ # set of available languages (in alphabetic order) -be de en_GB fr hu it lv nb_NO nl pl pt_BR pt_PT uk ur +be cs de en_GB fr hu it lv nb_NO nl pl pt_BR pt_PT uk ur From majkl at xfce.org Sun Mar 2 00:19:20 2008 From: majkl at xfce.org (Michal Varady) Date: Sat, 1 Mar 2008 23:19:20 +0000 (UTC) Subject: [Goodies-commits] r4016 - thunar-archive-plugin/trunk/po Message-ID: <20080301231920.88A9CF29D8@mocha.foo-projects.org> Author: majkl Date: 2008-03-01 23:19:20 +0000 (Sat, 01 Mar 2008) New Revision: 4016 Modified: thunar-archive-plugin/trunk/po/cs.po Log: Corrections of Czech translation Modified: thunar-archive-plugin/trunk/po/cs.po =================================================================== --- thunar-archive-plugin/trunk/po/cs.po 2008-03-01 19:00:31 UTC (rev 4015) +++ thunar-archive-plugin/trunk/po/cs.po 2008-03-01 23:19:20 UTC (rev 4016) @@ -8,13 +8,14 @@ "Project-Id-Version: thunar-archive-plugin 0.2.4\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2006-11-04 21:24+0100\n" -"PO-Revision-Date: 2006-09-17 09:24+0100\n" +"PO-Revision-Date: 2008-03-02 00:18+0100\n" "Last-Translator: Michal V?rady \n" "Language-Team: Czech \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" +"X-Poedit-Bookmarks: -1,-1,6,-1,-1,-1,-1,-1,-1,-1\n" #. prepare the dialog to query the preferred archiver for the user #: thunar-archive-plugin/tap-backend.c:84 @@ -27,7 +28,7 @@ "Please select your preferred archive manager\n" "from the list of available applications below:" msgstr "" -"Vyberte si V?? up?ednost?ovan? spr?vce archiv?\n" +"Vyberte si v?mi up?ednost?ovan? spr?vce archiv?\n" "z n??e uveden?ho seznamu dostupn?ch aplikac?:" #. tell the user that we cannot handle the specified mime types @@ -72,7 +73,7 @@ #: thunar-archive-plugin/tap-provider.c:515 msgid "Cr_eate Archive..." -msgstr "_Vytvo?it archiv..." +msgstr "Vytvo?_it archiv..." #: thunar-archive-plugin/tap-provider.c:523 msgid "Create an archive with the selected object" @@ -92,3 +93,4 @@ msgstr[0] "Rozbal? vybran? archiv v tomto um?st?n?" msgstr[1] "Rozbal? vybran? archivy v tomto um?st?n?" msgstr[2] "Rozbal? vybran? archivy v tomto um?st?n?" + From mmassonnet at xfce.org Tue Mar 4 16:01:43 2008 From: mmassonnet at xfce.org (Mike Massonnet) Date: Tue, 4 Mar 2008 15:01:43 +0000 (UTC) Subject: [Goodies-commits] r4017 - in xfce4-clipman-plugin/branches: . mmassonnet/panel-plugin Message-ID: <20080304150143.734D6F29D8@mocha.foo-projects.org> Author: mmassonnet Date: 2008-03-04 15:01:43 +0000 (Tue, 04 Mar 2008) New Revision: 4017 Added: xfce4-clipman-plugin/branches/mmassonnet/ Modified: xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman-dialogs.c xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman-dialogs.h xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman.h Log: xfce4-clipman-plugin: copy trunk to branches/mmassonnet Copied: xfce4-clipman-plugin/branches/mmassonnet (from rev 4016, xfce4-clipman-plugin/trunk) Modified: xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman-dialogs.c =================================================================== --- xfce4-clipman-plugin/trunk/panel-plugin/clipman-dialogs.c 2008-03-01 23:19:20 UTC (rev 4016) +++ xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman-dialogs.c 2008-03-04 15:01:43 UTC (rev 4017) @@ -1,4 +1,4 @@ -/* $Id: clipman-dialogs.c 2395 2007-01-17 17:42:53Z nick $ +/* $Id$ * * Copyright (c) 2006-2007 Nick Schermer * Copyright (c) 2007 Mike Massonnet Modified: xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman-dialogs.h =================================================================== --- xfce4-clipman-plugin/trunk/panel-plugin/clipman-dialogs.h 2008-03-01 23:19:20 UTC (rev 4016) +++ xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman-dialogs.h 2008-03-04 15:01:43 UTC (rev 4017) @@ -1,4 +1,4 @@ -/* $Id: clipman-dialogs.h 2395 2007-01-17 17:42:53Z nick $ +/* $Id$ * * Copyright (c) 2006-2007 Nick Schermer * Copyright (c) 2007 Mike Massonnet Modified: xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman.h =================================================================== --- xfce4-clipman-plugin/trunk/panel-plugin/clipman.h 2008-03-01 23:19:20 UTC (rev 4016) +++ xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman.h 2008-03-04 15:01:43 UTC (rev 4017) @@ -1,4 +1,4 @@ -/* $Id: clipman.h 2395 2007-01-17 17:42:53Z nick $ +/* $Id$ * * Copyright (c) 2006-2007 Nick Schermer * Copyright (c) 2007 Mike Massonnet From mmassonnet at xfce.org Tue Mar 4 16:15:08 2008 From: mmassonnet at xfce.org (Mike Massonnet) Date: Tue, 4 Mar 2008 15:15:08 +0000 (UTC) Subject: [Goodies-commits] r4018 - in xfce4-clipman-plugin/trunk: . panel-plugin po Message-ID: <20080304151508.DEEFAF29D8@mocha.foo-projects.org> Author: mmassonnet Date: 2008-03-04 15:15:08 +0000 (Tue, 04 Mar 2008) New Revision: 4018 Added: xfce4-clipman-plugin/trunk/INSTALL xfce4-clipman-plugin/trunk/TODO Removed: xfce4-clipman-plugin/trunk/.gitignore xfce4-clipman-plugin/trunk/panel-plugin/.gitignore xfce4-clipman-plugin/trunk/panel-plugin/xfce4-popup-clipman.c xfce4-clipman-plugin/trunk/panel-plugin/xfce4-popup-clipman.h xfce4-clipman-plugin/trunk/po/.gitignore Modified: xfce4-clipman-plugin/trunk/AUTHORS xfce4-clipman-plugin/trunk/ChangeLog xfce4-clipman-plugin/trunk/README xfce4-clipman-plugin/trunk/configure.in.in xfce4-clipman-plugin/trunk/panel-plugin/Makefile.am xfce4-clipman-plugin/trunk/panel-plugin/clipman-dialogs.c xfce4-clipman-plugin/trunk/panel-plugin/clipman-dialogs.h xfce4-clipman-plugin/trunk/panel-plugin/clipman.c xfce4-clipman-plugin/trunk/panel-plugin/clipman.h xfce4-clipman-plugin/trunk/po/ChangeLog xfce4-clipman-plugin/trunk/po/LINGUAS xfce4-clipman-plugin/trunk/po/ca.po xfce4-clipman-plugin/trunk/po/cs.po xfce4-clipman-plugin/trunk/po/de.po xfce4-clipman-plugin/trunk/po/en_GB.po xfce4-clipman-plugin/trunk/po/eu.po xfce4-clipman-plugin/trunk/po/fr.po xfce4-clipman-plugin/trunk/po/hu.po xfce4-clipman-plugin/trunk/po/it.po xfce4-clipman-plugin/trunk/po/ja.po xfce4-clipman-plugin/trunk/po/lv.po xfce4-clipman-plugin/trunk/po/nb_NO.po xfce4-clipman-plugin/trunk/po/pl.po xfce4-clipman-plugin/trunk/po/pt_BR.po xfce4-clipman-plugin/trunk/po/pt_PT.po xfce4-clipman-plugin/trunk/po/sq.po xfce4-clipman-plugin/trunk/po/uk.po xfce4-clipman-plugin/trunk/po/ur.po xfce4-clipman-plugin/trunk/po/xfce4-clipman-plugin.pot xfce4-clipman-plugin/trunk/po/zh_TW.po Log: xfce4-clipman-plugin: revert trunk to r3676 Deleted: xfce4-clipman-plugin/trunk/.gitignore Modified: xfce4-clipman-plugin/trunk/AUTHORS =================================================================== --- xfce4-clipman-plugin/trunk/AUTHORS 2008-03-04 15:01:43 UTC (rev 4017) +++ xfce4-clipman-plugin/trunk/AUTHORS 2008-03-04 15:15:08 UTC (rev 4018) @@ -1,3 +1,2 @@ Eduard Roccatello Nick Schermer -Mike Massonnet Modified: xfce4-clipman-plugin/trunk/ChangeLog =================================================================== --- xfce4-clipman-plugin/trunk/ChangeLog 2008-03-04 15:01:43 UTC (rev 4017) +++ xfce4-clipman-plugin/trunk/ChangeLog 2008-03-04 15:15:08 UTC (rev 4018) @@ -1,129 +1,3 @@ -2008-01-25 Nick Schermer - - * README: Fix missing character ^_^. - -2008-01-25 Nick Schermer - - * panel-plugin/clipman.c: Fix missing include. - * panel-plugin/Makefile.am: Some improvements. - * README: Small improvement. - -2008-01-24 Mike Massonnet - - * panel-plugin/clipman.c(clipman_plugin_set_size): Scale pixbuf. - -2008-01-24 Mike Massonnet - - * panel-plugin/Makefile.am: Add stuff in INCLUDES - * panel-plugin/clipman.c: Count padding of 2 (as done by other panel plugins) - and correct the double xthickness to x/y. - -2008-01-14 Mike Massonnet - - * .gitignore: Add *.swp. - * TODO: out of ideas. Deleted. - * po/: update french translation, fix changelog. - -2008-01-14 Mike Massonnet - - * Add .gitignore files. - -2008-01-14 Mike Massonnet - - * panel-plugin/Makefile.am, - panel-plugin/xfce4-popup-clipman.c, - panel-plugin/xfce4-popup-clipman.h, - panel-plugin/clipman.c: Add popup command. - -2008-01-14 Mike Massonnet - - * panel-plugin/clipman.c(clipman_plugin_button_pressed), - panel-plugin/clipman.c(clipman_plugin_new), - panel-plugin/clipman.c(clipman_plugin_menu_popup): - Replace "button_press_event" against a "toggled" signal. - -2008-01-14 Mike Massonnet - - * panel-plugin/clipman.c(clipman_plugin_load_data), - panel-plugin/clipman.c(clipman_plugin_save_data): Replace g_return_if_fail - with return since it wouldn't be a bug in the application, but a end-user - problem (file permission, ...). - * panel-plugin/clipman.c(clipman_plugin_get_short_text): Replace the UTF-8 - ellipsis with "...". - * panel-plugin/clipman.c(clipman_plugin_menu_insert_clip), - panel-plugin/clipman.c(clipman_plugin_menu_item_activate), - panel-plugin/clipman.c(clipman_plugin_menu_item_pressed): Set a gobject data - with the pointer of the clip. Remove the g_slist_nth_data() calls. - -2008-01-09 Mike Massonnet - - * panel-plugin/clipman.h: Set save on exit by default. - * panel-plugin/clipman.c: Three new functions _plugin_add_static/with_text, - _plugin_delete, where the GUI code fits better. Remove _clips_add_static. - * panel-plugin/clipman.c(clipman_plugin_load_data): Use DEFBEHAVIOUR - instead of NORMAL. - * panel-plugin/clipman.c(clipman_plugin_load_data), - panel-plugin/clipman.c(clipman_plugin_save_data): Rename StaticClipboard - to StaticClips. Delete rc group StaticClips before save. - * panel-plugin/clipman.c(clipman_plugin_menu_item_pressed): Add button - event 2 to copy to static clipboard. Move code for button event 3 in - function _plugin_delete. - -2008-01-08 Mike Massonnet - - * po/*.po: make update-po. - * po/fr.po: Update french translation. - -2008-01-08 Mike Massonnet - - * panel-plugin/clipman-dialogs.h: Move declarations inside clipman-dialogs.c. - * panel-plugin/clipman-dialogs.c: Refine the dialog. - * panel-plugin/clipman-dialogs.c, panel-plugin/clipman.c, - panel-plugin/clipman.h: Add "static selection" option. - -2008-01-07 Mike Massonnet - - * Forget one clipman_clip_free replacement. - -2008-01-07 Mike Massonnet - - * Forget to clean short_text of static clipboard. - -2008-01-07 Mike Massonnet - - * Merge _clips_load_data inside _plugin_load_data. - * Merge _clips_save_data inside _plugin_save_data. - * Replace g_slist_length() > 0 with history != NULL. - * Replace loop while (clip = _nth_data()) with for (list = history; list - != NULL; list = list->next). - * Add clipman_clip_new and clipman_clip_free. - * Declare _clips_delete outside and use it in clipman-dialogs.c to free - the overlap in the history. - -2008-01-06 Mike Massonnet - - * Extract code from _add_static to _add. Free ClipmanClip in _add if the - clip exists. Set default value for Ignore Primary to FALSE. - -2008-01-06 Mike Massonnet - - * Save/load the static clipboard. Get rid of some TRACEs. - -2008-01-06 Mike Massonnet - - * Add static clipboard - -2008-01-06 Mike Massonnet - - * Remove more useless files in VCS. - -2008-01-05 Mike Massonnet - - * configure.in.in, panel-plugin/clipman.c, panel-plugin/clipman.h, - panel-plugin/clipman-dialogs.c, panel-plugin/clipman-dialogs.h: Initial - rewrite. Separate code between ClipmanPlugin and ClipmanClips. Use a - GSList to store the history. - 2006-01-17 Nick Schermer * Improve configure files and Makefiles. Added: xfce4-clipman-plugin/trunk/INSTALL =================================================================== --- xfce4-clipman-plugin/trunk/INSTALL (rev 0) +++ xfce4-clipman-plugin/trunk/INSTALL 2008-03-04 15:15:08 UTC (rev 4018) @@ -0,0 +1,229 @@ +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software +Foundation, Inc. + + This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. (Caching is +disabled by default to prevent problems with accidental use of stale +cache files.) + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You only need +`configure.ac' if you want to change it or regenerate `configure' using +a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not support the `VPATH' +variable, you have to compile the package for one architecture at a +time in the source code directory. After you have installed the +package for one architecture, use `make distclean' before reconfiguring +for another architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=PATH' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the `--target=TYPE' option to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + + Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +will cause the specified gcc to be used as the C compiler (unless it is +overridden in the site shell script). + +`configure' Invocation +====================== + + `configure' recognizes the following options to control how it +operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + Modified: xfce4-clipman-plugin/trunk/README =================================================================== --- xfce4-clipman-plugin/trunk/README 2008-03-04 15:01:43 UTC (rev 4017) +++ xfce4-clipman-plugin/trunk/README 2008-03-04 15:15:08 UTC (rev 4018) @@ -1 +1 @@ -This is a simple clipboard history for Xfce Panel +This is a simple cliboard history for XFCE4 Panel Added: xfce4-clipman-plugin/trunk/TODO =================================================================== Modified: xfce4-clipman-plugin/trunk/configure.in.in =================================================================== --- xfce4-clipman-plugin/trunk/configure.in.in 2008-03-04 15:01:43 UTC (rev 4017) +++ xfce4-clipman-plugin/trunk/configure.in.in 2008-03-04 15:15:08 UTC (rev 4018) @@ -60,10 +60,11 @@ dnl *********************************** dnl *** Check for required packages *** dnl *********************************** -XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.10.0]) -XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.4.0]) -XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.4.0]) -XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.4.0]) +XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.6.0]) +XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0]) +XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.3.99.2]) +XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.3.99.2]) +XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.3.99.2]) dnl *********************************** dnl *** Check for debugging support *** Deleted: xfce4-clipman-plugin/trunk/panel-plugin/.gitignore Modified: xfce4-clipman-plugin/trunk/panel-plugin/Makefile.am =================================================================== --- xfce4-clipman-plugin/trunk/panel-plugin/Makefile.am 2008-03-04 15:01:43 UTC (rev 4017) +++ xfce4-clipman-plugin/trunk/panel-plugin/Makefile.am 2008-03-04 15:15:08 UTC (rev 4018) @@ -2,33 +2,12 @@ INCLUDES = \ -I$(top_srcdir) \ - -DG_LOG_DOMAIN=\"xfce4-clipman-plugin\" \ + -DG_LOG_DOMAIN=\"xfce4-battery-plugin\" \ -DPACKAGE_LOCALE_DIR=\"$(localedir)\" # -# Clipman popup command +# Battery Plugin # -bin_PROGRAMS = \ - xfce4-popup-clipman - -xfce4_popup_clipman_SOURCES = \ - xfce4-popup-clipman.h \ - xfce4-popup-clipman.c - -xfce4_popup_clipman_CFLAGS = \ - $(LIBX11_CFLAGS) \ - $(GTK_CFLAGS) - -xfce4_popup_clipman_LDADD = \ - $(LIBX11_LIBS) \ - $(GTK_LIBS) - -xfce4_popup_clipman_LDFLAGS = \ - $(LIBX11_LDFLAGS) - -# -# Clipman plugin -# plugindir = \ $(libexecdir)/xfce4/panel-plugins @@ -36,36 +15,30 @@ xfce4-clipman-plugin xfce4_clipman_plugin_SOURCES = \ - clipman-dialogs.h \ - clipman-dialogs.c \ clipman.h \ - clipman.c + clipman.c \ + clipman-dialogs.h \ + clipman-dialogs.c xfce4_clipman_plugin_CFLAGS = \ - $(LIBXFCE4PANEL_CFLAGS) \ - $(LIBXFCE4UTIL_CFLAGS) \ - $(LIBXFCEGUI4_CFLAGS) + $(LIBXFCEGUI4_CFLAGS) \ + $(LIBXFCE4PANEL_CFLAGS) xfce4_clipman_plugin_LDADD = \ $(LIBXFCE4PANEL_LIBS) \ - $(LIBXFCE4UTIL_LIBS) \ $(LIBXFCEGUI4_LIBS) - # # Desktop file # +desktopdir = $(datadir)/xfce4/panel-plugins desktop_in_in_files = clipman.desktop.in.in desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in) - -desktopdir = $(datadir)/xfce4/panel-plugins +%.desktop.in: %.desktop.in.in + sed -e "s,\@libexecdir\@,$(libexecdir),g" < $< > $@ desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) @INTLTOOL_DESKTOP_RULE@ -# get full path into .desktop file -%.desktop.in: %.desktop.in.in - sed -e "s,\@libexecdir\@,$(libexecdir),g" < $< > $@ - EXTRA_DIST = \ $(desktop_in_in_files) Modified: xfce4-clipman-plugin/trunk/panel-plugin/clipman-dialogs.c =================================================================== --- xfce4-clipman-plugin/trunk/panel-plugin/clipman-dialogs.c 2008-03-04 15:01:43 UTC (rev 4017) +++ xfce4-clipman-plugin/trunk/panel-plugin/clipman-dialogs.c 2008-03-04 15:15:08 UTC (rev 4018) @@ -1,7 +1,6 @@ -/* $Id: clipman-dialogs.c 2395 2007-01-17 17:42:53Z nick $ +/* $Id$ * * Copyright (c) 2006-2007 Nick Schermer - * Copyright (c) 2007 Mike Massonnet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,420 +21,351 @@ #include #endif +#include +#include + +#include +#include + #include "clipman.h" #include "clipman-dialogs.h" +#define PLUGIN_WEBSITE "http://goodies.xfce.org/projects/panel-plugins/xfce4-clipman-plugin" +typedef struct +{ + ClipmanPlugin *clipman; -#define PLUGIN_WEBSITE "http://goodies.xfce.org/projects/panel-plugins/xfce4-clipman-plugin" + GtkWidget *ExitSave; + GtkWidget *IgnoreSelection; + GtkWidget *PreventEmpty; -typedef struct _ClipmanOptions ClipmanOptions; + GtkWidget *Behaviour; -struct _ClipmanOptions + GtkWidget *ItemNumbers; + GtkWidget *SeparateMenu; + + GtkWidget *HistorySize; + GtkWidget *ItemChars; +} +ClipmanOptions; + +static void +clipman_configure_response (GtkWidget *dialog, + int response, + ClipmanOptions *options) { - ClipmanPlugin *clipman; + gboolean result; - GtkWidget *ExitSave; - GtkWidget *PreventEmpty; - GtkWidget *IgnoreSelection; + if (response == GTK_RESPONSE_HELP) + { + /* show help */ + result = g_spawn_command_line_async ("exo-open --launch WebBrowser " PLUGIN_WEBSITE, NULL); - GtkWidget *BehaviourNormal; - GtkWidget *BehaviourStrictly; + if (G_UNLIKELY (result == FALSE)) + g_warning (_("Unable to open the following url: %s"), PLUGIN_WEBSITE); - GtkWidget *ItemNumbers; + return; + } - GtkWidget *HistorySize; - GtkWidget *ItemChars; + DBG("Destroy the dialog"); - GtkWidget *IgnoreStatic; - GtkWidget *StaticDefault; - GtkWidget *StaticPrimary; - GtkWidget *StaticBoth; + g_object_set_data (G_OBJECT (options->clipman->plugin), "dialog", NULL); -}; + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (options->Behaviour))) + options->clipman->Behaviour = NORMAL; + else + options->clipman->Behaviour = STRICTLY; + if (options->clipman->HistoryItems != gtk_range_get_value (GTK_RANGE (options->HistorySize))) + { + options->clipman->HistoryItems = gtk_range_get_value (GTK_RANGE (options->HistorySize)); + clipman_check_array_len (options->clipman); + } + options->clipman->MenuCharacters = gtk_range_get_value (GTK_RANGE (options->ItemChars)); -static void clipman_configure_response (GtkWidget *dialog, - gint response, - ClipmanOptions *options); -static void set_scale_to_spin (GtkWidget *scalewidget, - GtkWidget *spinwidget); -static void set_spin_to_scale (GtkWidget *spinwidget, - GtkWidget *scalewidget); -static void toggle_button (GtkWidget *button, - ClipmanOptions *options); + clipman_save (options->clipman->plugin, options->clipman); + clipman_remove_selection_clips (options->clipman); + xfce_panel_plugin_unblock_menu (options->clipman->plugin); -void -clipman_configure_new (ClipmanPlugin *clipman_plugin) + gtk_widget_destroy (dialog); + + panel_slice_free (ClipmanOptions, options); +} + +static void +set_scale_to_spin (GtkWidget *scalewidget, + GtkWidget *spinwidget) { - GtkWidget *dialog, *dialog_vbox, *frame, *notebook, *notebook_vbox; - GtkWidget *vbox, *hbox, *button, *label; - ClipmanClips *clipman_clips = clipman_plugin->clipman_clips; - ClipmanOptions *options; - GSList *group; + guint value; + value = gtk_range_get_value (GTK_RANGE (scalewidget)); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(spinwidget), value); +} - options = panel_slice_new0 (ClipmanOptions); - options->clipman = clipman_plugin; +static void +set_spin_to_scale (GtkWidget *spinwidget, + GtkWidget *scalewidget) +{ + guint value; + value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(spinwidget)); + gtk_range_set_value (GTK_RANGE (scalewidget), value); +} - dialog = - xfce_titled_dialog_new_with_buttons (_("Clipboard Manager"), - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (clipman_plugin->panel_plugin))), - GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, - GTK_STOCK_HELP, GTK_RESPONSE_HELP, - GTK_STOCK_CLOSE, GTK_RESPONSE_OK, - NULL); - gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_PASTE); - gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE); - gtk_window_stick (GTK_WINDOW (dialog)); +static void +toggle_button (GtkWidget *button, + ClipmanOptions *options) +{ + if (button == options->ExitSave) + options->clipman->ExitSave = + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - dialog_vbox = GTK_DIALOG (dialog)->vbox; + else if (button == options->IgnoreSelection) + { + options->clipman->IgnoreSelect = + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - notebook = gtk_notebook_new (); - gtk_box_pack_start (GTK_BOX (dialog_vbox), notebook, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (notebook), BORDER-2); + if (options->clipman->IgnoreSelect) + gtk_widget_set_sensitive (options->SeparateMenu, FALSE); + else + gtk_widget_set_sensitive (options->SeparateMenu, TRUE); + } + else if (button == options->PreventEmpty) + options->clipman->PreventEmpty = + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - /* === General === */ - notebook_vbox = gtk_vbox_new (FALSE, 2); - gtk_container_add (GTK_CONTAINER (notebook), notebook_vbox); + else if (button == options->ItemNumbers) + options->clipman->ItemNumbers = + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - gtk_notebook_set_tab_label_text (GTK_NOTEBOOK (notebook), - gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), 0), - _("General")); + else if (button == options->SeparateMenu) + options->clipman->SeparateMenu = + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); +} - /* General */ - vbox = gtk_vbox_new (FALSE, 2); - frame = xfce_create_framebox_with_content (_("General"), vbox); - gtk_container_set_border_width (GTK_CONTAINER (frame), BORDER); - gtk_box_pack_start (GTK_BOX (notebook_vbox), frame, FALSE, TRUE, 0); +void +clipman_configure (XfcePanelPlugin *plugin, + ClipmanPlugin *clipman) +{ + GtkWidget *dialog, *dialog_vbox, *frame, *button, *label; + GtkWidget *vbox, *hbox, *notebook_vbox, *notebook; + ClipmanOptions *options; + GSList *group; - button = options->ExitSave = - gtk_check_button_new_with_mnemonic (_("Save clipboard contents on _exit")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), clipman_clips->save_on_exit); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (button), "toggled", - G_CALLBACK (toggle_button), options); + options = panel_slice_new0 (ClipmanOptions); + options->clipman = clipman; - button = options->PreventEmpty = - gtk_check_button_new_with_mnemonic (_("Pre_vent empty clipboard")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), clipman_clips->prevent_empty); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (button), "toggled", - G_CALLBACK (toggle_button), options); + xfce_panel_plugin_block_menu (clipman->plugin); - button = options->IgnoreSelection = - gtk_check_button_new_with_mnemonic (_("_Ignore selections")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), clipman_clips->ignore_primary); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (button), "toggled", - G_CALLBACK (toggle_button), options); + dialog = xfce_titled_dialog_new_with_buttons (_("Clipboard Manager"), + GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))), + GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, + GTK_STOCK_HELP, GTK_RESPONSE_HELP, + GTK_STOCK_CLOSE, GTK_RESPONSE_OK, + NULL); - /* Behavior */ - vbox = gtk_vbox_new (FALSE, 2); - frame = xfce_create_framebox_with_content (_("Clipboard Behavior"), vbox); - gtk_container_set_border_width (GTK_CONTAINER (frame), BORDER); - gtk_box_pack_start (GTK_BOX (notebook_vbox), frame, FALSE, TRUE, 0); + gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); + gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce4-settings"); - group = NULL; + g_object_set_data (G_OBJECT (clipman->plugin), "dialog", dialog); - button = options->BehaviourNormal = - gtk_radio_button_new_with_mnemonic (group, _("Normal clipboard _management")); - gtk_radio_button_set_group (GTK_RADIO_BUTTON (button), group); - group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), clipman_clips->behavior == NORMAL); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (button), "toggled", - G_CALLBACK (toggle_button), options); + dialog_vbox = GTK_DIALOG (dialog)->vbox; - button = options->BehaviourStrictly = - gtk_radio_button_new_with_mnemonic (group, _("Strictly separate _both clipboards")); - gtk_radio_button_set_group (GTK_RADIO_BUTTON (button), group); - group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), clipman_clips->behavior == STRICTLY); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (button), "toggled", - G_CALLBACK (toggle_button), options); + notebook = gtk_notebook_new (); + gtk_box_pack_start (GTK_BOX (dialog_vbox), notebook, FALSE, TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (notebook), BORDER-3); - /* === Appearance === */ - notebook_vbox = gtk_vbox_new (FALSE, 2); - gtk_container_add (GTK_CONTAINER (notebook), notebook_vbox); + notebook_vbox = gtk_vbox_new (FALSE, 2); + gtk_container_add (GTK_CONTAINER (notebook), notebook_vbox); - gtk_notebook_set_tab_label_text (GTK_NOTEBOOK (notebook), - gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), 1), - _("Appearance")); + /** + * The general frame + **/ + frame = gtk_frame_new (NULL); + gtk_box_pack_start (GTK_BOX (notebook_vbox), frame, FALSE, TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (frame), BORDER-3); - /* Appearance */ - vbox = gtk_vbox_new (FALSE, 2); - frame = xfce_create_framebox_with_content (_("Menu Appearance"), vbox); - gtk_container_set_border_width (GTK_CONTAINER (frame), BORDER); - gtk_box_pack_start (GTK_BOX (notebook_vbox), frame, FALSE, TRUE, 0); + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_add (GTK_CONTAINER (frame), vbox); + gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER); - button = options->ItemNumbers = gtk_check_button_new_with_mnemonic (_("_Show item numbers")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), clipman_plugin->menu_item_show_number); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (button), "toggled", - G_CALLBACK (toggle_button), options); + button = options->ExitSave = gtk_check_button_new_with_mnemonic (_("Save clipboard contents on _exit")); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), clipman->ExitSave); - /* Numbers */ - vbox = gtk_vbox_new (FALSE, 2); - frame = xfce_create_framebox_with_content (_("Numbers"), vbox); - gtk_container_set_border_width (GTK_CONTAINER (frame), BORDER); - gtk_box_pack_start (GTK_BOX (notebook_vbox), frame, FALSE, TRUE, 0); + g_signal_connect (G_OBJECT (button), "toggled", + G_CALLBACK (toggle_button), options); - /* History length */ - label = gtk_label_new (_("Clipboard history items:")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + button = options->IgnoreSelection = gtk_check_button_new_with_mnemonic (_("_Ignore selections")); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), clipman->IgnoreSelect); - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); + g_signal_connect (G_OBJECT (button), "toggled", + G_CALLBACK (toggle_button), options); - button = options->HistorySize = - gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (clipman_clips->history_length, - MINHISTORY, MAXHISTORY, 1, 5, 0))); - gtk_scale_set_draw_value (GTK_SCALE (button), FALSE); - gtk_scale_set_digits (GTK_SCALE (button), 0); - gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 10); + button = options->PreventEmpty = gtk_check_button_new_with_mnemonic (_("Pre_vent empty clipboard")); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), clipman->PreventEmpty); - button = gtk_spin_button_new_with_range (MINHISTORY, MAXHISTORY, 1); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (button), clipman_clips->history_length); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0); + g_signal_connect (G_OBJECT (button), "toggled", + G_CALLBACK (toggle_button), options); - g_signal_connect (G_OBJECT (options->HistorySize), "value_changed", - G_CALLBACK (set_scale_to_spin), button); - g_signal_connect (G_OBJECT (button), "value_changed", - G_CALLBACK (set_spin_to_scale), options->HistorySize); - /* Max menu item chars */ - label = gtk_label_new (_("Menu item characters:")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + label = gtk_label_new (_("General")); + gtk_frame_set_label_widget (GTK_FRAME (frame), label); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_misc_set_padding (GTK_MISC (label), 2, 0); - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); + /** + * separate clipboards frame + **/ + frame = gtk_frame_new (NULL); + gtk_box_pack_start (GTK_BOX (notebook_vbox), frame, FALSE, TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (frame), BORDER-3); - button = options->ItemChars = - gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (clipman_plugin->menu_item_max_chars, - MINCHARS, MAXCHARS, 1, 5, 0))); - gtk_scale_set_draw_value (GTK_SCALE (button), FALSE); - gtk_scale_set_digits (GTK_SCALE (button), 0); - gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 10); + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_add (GTK_CONTAINER (frame), vbox); + gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER); - button = gtk_spin_button_new_with_range (MINCHARS, MAXCHARS, 1); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (button), clipman_plugin->menu_item_max_chars); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0); + group = NULL; - g_signal_connect (G_OBJECT (options->ItemChars), "value_changed", - G_CALLBACK (set_scale_to_spin), button); - g_signal_connect (G_OBJECT (button), "value_changed", - G_CALLBACK (set_spin_to_scale), options->ItemChars); + button = options->Behaviour = gtk_radio_button_new_with_mnemonic (group, _("Normal clipboard _management")); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); + gtk_radio_button_set_group (GTK_RADIO_BUTTON (button), group); + group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); - /* === Static clipboard === */ - notebook_vbox = gtk_vbox_new (FALSE, 2); - gtk_container_add (GTK_CONTAINER (notebook), notebook_vbox); + if(clipman->Behaviour == NORMAL) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); - gtk_notebook_set_tab_label_text (GTK_NOTEBOOK (notebook), - gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), 2), - _("Static Clipboard")); + button = gtk_radio_button_new_with_mnemonic (group, _("Strictly separate _both clipboards")); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - /* General */ - vbox = gtk_vbox_new (FALSE, 2); - frame = xfce_create_framebox_with_content (_("General"), vbox); - gtk_container_set_border_width (GTK_CONTAINER (frame), BORDER); - gtk_box_pack_start (GTK_BOX (notebook_vbox), frame, FALSE, TRUE, 0); + gtk_radio_button_set_group (GTK_RADIO_BUTTON (button), group); + group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); - button = options->IgnoreStatic = - gtk_check_button_new_with_mnemonic (_("Ignore _static clipboard")); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), clipman_clips->ignore_static_clipboard); - g_signal_connect (G_OBJECT (button), "toggled", - G_CALLBACK (toggle_button), options); + if(clipman->Behaviour == STRICTLY) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); - /* Copy to clipboard */ - vbox = gtk_vbox_new (FALSE, 2); - frame = xfce_create_framebox_with_content (_("Select to Clipboards"), vbox); - gtk_container_set_border_width (GTK_CONTAINER (frame), BORDER); - gtk_box_pack_start (GTK_BOX (notebook_vbox), frame, FALSE, TRUE, 0); + label = gtk_label_new (_("Clipboard Behaviour")); + gtk_frame_set_label_widget (GTK_FRAME (frame), label); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_misc_set_padding (GTK_MISC (label), 2, 0); - group = NULL; + /** + * Notebook label + **/ + label = gtk_label_new (_("General")); + gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), 0), label); - button = options->StaticDefault = - gtk_radio_button_new_with_mnemonic (group, _("Default")); - gtk_radio_button_set_group (GTK_RADIO_BUTTON (button), group); - group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), clipman_clips->static_selection == DEFAULT); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (button), "toggled", - G_CALLBACK (toggle_button), options); + notebook_vbox = gtk_vbox_new (FALSE, 2); + gtk_container_add (GTK_CONTAINER (notebook), notebook_vbox); - button = options->StaticPrimary = - gtk_radio_button_new_with_mnemonic (group, _("Selection")); - gtk_radio_button_set_group (GTK_RADIO_BUTTON (button), group); - group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), clipman_clips->static_selection == PRIMARY); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (button), "toggled", - G_CALLBACK (toggle_button), options); + /** + * Menu appearance frame + **/ + frame = gtk_frame_new (NULL); + gtk_box_pack_start (GTK_BOX (notebook_vbox), frame, FALSE, TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (frame), BORDER-3); - button = options->StaticBoth = - gtk_radio_button_new_with_mnemonic (group, _("Both")); - gtk_radio_button_set_group (GTK_RADIO_BUTTON (button), group); - group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), clipman_clips->static_selection == BOTH); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (button), "toggled", - G_CALLBACK (toggle_button), options); + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_add (GTK_CONTAINER (frame), vbox); + gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER); - /* Show the stuff */ - g_signal_connect (dialog, "response", - G_CALLBACK (clipman_configure_response), options); - xfce_panel_plugin_block_menu (clipman_plugin->panel_plugin); - gtk_widget_show_all (dialog); -} + button = options->ItemNumbers = gtk_check_button_new_with_mnemonic (_("_Show item numbers")); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), clipman->ItemNumbers); -static void -clipman_configure_response (GtkWidget *dialog, - gint response, - ClipmanOptions *options) -{ - gboolean result; + g_signal_connect (G_OBJECT (button), "toggled", + G_CALLBACK (toggle_button), options); - if (response == GTK_RESPONSE_HELP) - { - /* show help */ - result = g_spawn_command_line_async ("exo-open --launch WebBrowser " PLUGIN_WEBSITE, NULL); + button = options->SeparateMenu = gtk_check_button_new_with_mnemonic (_("Se_parate clipboards")); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), clipman->SeparateMenu); - if (G_UNLIKELY (result == FALSE)) - g_warning (_("Unable to open the following url: %s"), PLUGIN_WEBSITE); + g_signal_connect (G_OBJECT (button), "toggled", + G_CALLBACK (toggle_button), options); - return; - } + label = gtk_label_new (_("Menu Appearance")); + gtk_frame_set_label_widget (GTK_FRAME (frame), label); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_misc_set_padding (GTK_MISC (label), 2, 0); - DBG("Destroy the dialog"); + /** + * Call some functions + **/ - /* History length */ - gint history_length = gtk_range_get_value (GTK_RANGE (options->HistorySize)); - if (options->clipman->clipman_clips->history_length != history_length) - { - options->clipman->clipman_clips->history_length = history_length; + toggle_button (options->IgnoreSelection, options); - /* Free the overlap in the history */ - ClipmanClip *clip; - gint length = g_slist_length (options->clipman->clipman_clips->history); - while (history_length < length--) - { - clip = (ClipmanClip *)(g_slist_last (options->clipman->clipman_clips->history)->data); - clipman_clips_delete (options->clipman->clipman_clips, clip); - } - } + /** + * Numbers frame + **/ + frame = gtk_frame_new (NULL); + gtk_box_pack_start (GTK_BOX (notebook_vbox), frame, FALSE, TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (frame), BORDER-3); - /* Menu item max chars */ - gint max_chars = gtk_range_get_value (GTK_RANGE (options->HistorySize)); - if (options->clipman->menu_item_max_chars != max_chars) - { - options->clipman->menu_item_max_chars = gtk_range_get_value (GTK_RANGE (options->ItemChars)); + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_add (GTK_CONTAINER (frame), vbox); + gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER); - /* Invalidate the old clip->short_text */ - GSList *list; - ClipmanClip *clip; - for (list = options->clipman->clipman_clips->history; list != NULL; list = list->next) - { - clip = (ClipmanClip *)list->data; - g_free (clip->short_text); - clip->short_text = NULL; - } - for (list = options->clipman->clipman_clips->static_clipboard; list != NULL; list = list->next) - { - clip = (ClipmanClip *)list->data; - g_free (clip->short_text); - clip->short_text = NULL; - } - } + label = gtk_label_new (_("Clipboard history items:")); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - xfce_panel_plugin_unblock_menu (options->clipman->panel_plugin); - gtk_widget_destroy (dialog); - panel_slice_free (ClipmanOptions, options); -} + hbox = gtk_hbox_new (FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); -static void -set_scale_to_spin (GtkWidget *scalewidget, - GtkWidget *spinwidget) -{ - guint value; - value = gtk_range_get_value (GTK_RANGE (scalewidget)); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinwidget), value); -} + button = options->HistorySize = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (clipman->HistoryItems, MINHISTORY, MAXHISTORY, 1, 5, 0))); + gtk_widget_show (button); + gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 10); + gtk_scale_set_draw_value (GTK_SCALE (button), FALSE); + gtk_scale_set_digits (GTK_SCALE (button), 0); -static void -set_spin_to_scale (GtkWidget *spinwidget, - GtkWidget *scalewidget) -{ - guint value; - value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spinwidget)); - gtk_range_set_value (GTK_RANGE (scalewidget), value); -} + button = gtk_spin_button_new_with_range(MINHISTORY, MAXHISTORY, 1); + gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(button), clipman->HistoryItems); -static void -toggle_button (GtkWidget *button, - ClipmanOptions *options) -{ - ClipmanPlugin *clipman_plugin = options->clipman; - ClipmanClips *clipman_clips = clipman_plugin->clipman_clips; + /* Sync history widgets */ + g_signal_connect (G_OBJECT (options->HistorySize), "value_changed", + G_CALLBACK (set_scale_to_spin), button); - if (button == options->ItemNumbers) - clipman_plugin->menu_item_show_number = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); + g_signal_connect (G_OBJECT (button), "value_changed", + G_CALLBACK (set_spin_to_scale), options->HistorySize); - else if (button == options->ExitSave) - clipman_clips->save_on_exit = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); + label = gtk_label_new (_("Menu item characters:")); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - else if (button == options->PreventEmpty) - clipman_clips->prevent_empty = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); + hbox = gtk_hbox_new (FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); - else if (button == options->IgnoreSelection) - clipman_clips->ignore_primary = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); + button = options->ItemChars = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (clipman->MenuCharacters, MINCHARS, MAXCHARS, 1, 5, 0))); + gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 10); + gtk_scale_set_draw_value (GTK_SCALE (button), FALSE); + gtk_scale_set_digits (GTK_SCALE (button), 0); - else if (button == options->IgnoreStatic) - clipman_clips->ignore_static_clipboard = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); + button = gtk_spin_button_new_with_range(MINCHARS, MAXCHARS, 1); + gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(button), clipman->MenuCharacters); - else if (button == options->BehaviourNormal) - { - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) - clipman_clips->behavior = NORMAL; - } + g_signal_connect (G_OBJECT (options->ItemChars), "value_changed", + G_CALLBACK (set_scale_to_spin), button); - else if (button == options->BehaviourStrictly) - { - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) - clipman_clips->behavior = STRICTLY; - } + g_signal_connect (G_OBJECT (button), "value_changed", + G_CALLBACK (set_spin_to_scale), options->ItemChars); - else if (button == options->StaticDefault) - { - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) - clipman_clips->static_selection = DEFAULT; - } + label = gtk_label_new (_("Numbers")); + gtk_frame_set_label_widget (GTK_FRAME (frame), label); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_misc_set_padding (GTK_MISC (label), 4, 0); - else if (button == options->StaticPrimary) - { - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) - clipman_clips->static_selection = PRIMARY; - } + label = gtk_label_new (_("Appearance")); + gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), 1), label); - else if (button == options->StaticBoth) - { - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) - clipman_clips->static_selection = BOTH; - } + g_signal_connect(dialog, "response", + G_CALLBACK(clipman_configure_response), options); + gtk_widget_show_all (dialog); } - Modified: xfce4-clipman-plugin/trunk/panel-plugin/clipman-dialogs.h =================================================================== --- xfce4-clipman-plugin/trunk/panel-plugin/clipman-dialogs.h 2008-03-04 15:01:43 UTC (rev 4017) +++ xfce4-clipman-plugin/trunk/panel-plugin/clipman-dialogs.h 2008-03-04 15:15:08 UTC (rev 4018) @@ -1,7 +1,6 @@ -/* $Id: clipman-dialogs.h 2395 2007-01-17 17:42:53Z nick $ +/* $Id$ * * Copyright (c) 2006-2007 Nick Schermer - * Copyright (c) 2007 Mike Massonnet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +23,7 @@ G_BEGIN_DECLS void -clipman_configure_new (ClipmanPlugin *clipman_plugin); +clipman_configure (XfcePanelPlugin *plugin, ClipmanPlugin *clipman); G_END_DECLS Modified: xfce4-clipman-plugin/trunk/panel-plugin/clipman.c =================================================================== --- xfce4-clipman-plugin/trunk/panel-plugin/clipman.c 2008-03-04 15:01:43 UTC (rev 4017) +++ xfce4-clipman-plugin/trunk/panel-plugin/clipman.c 2008-03-04 15:15:08 UTC (rev 4018) @@ -1,7 +1,6 @@ /* $Id$ * * Copyright (c) 2006-2007 Nick Schermer - * Copyright (c) 2007 Mike Massonnet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,1133 +21,1091 @@ #include #endif -#include +#include +#include + +#include #include +#include #include #include "clipman.h" #include "clipman-dialogs.h" -#include "xfce4-popup-clipman.h" +/* The clipboards */ +static GtkClipboard *primaryClip; +static GtkClipboard *defaultClip; +/* Register the plugin */ +static void +clipman_construct (XfcePanelPlugin *plugin); -static void clipman_plugin_register (XfcePanelPlugin *panel_plugin); +XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (clipman_construct); -static ClipmanPlugin * clipman_plugin_new (XfcePanelPlugin *panel_plugin); +static void +clipman_free_clip (ClipmanClip *clip) +{ + g_free (clip->text); + g_free (clip->title); -static void clipman_plugin_load_data (ClipmanPlugin *clipman_plugin); + panel_slice_free (ClipmanClip, clip); -static void clipman_plugin_save_data (ClipmanPlugin *clipman_plugin); + DBG ("Clip successfully freed"); +} -static void clipman_plugin_free (ClipmanPlugin *clipman_plugin); +static void +clipman_destroy_menu (GtkWidget *menu, + ClipmanPlugin *clipman) +{ + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (clipman->button), FALSE); -static gboolean clipman_plugin_set_size (ClipmanPlugin *clipman_plugin, - gint size); -static gchar * clipman_plugin_get_short_text (ClipmanPlugin *clipman_plugin, - const gchar *text); -static void clipman_plugin_menu_new (ClipmanPlugin *clipman_plugin); + gtk_widget_destroy (menu); -static void clipman_plugin_menu_insert_clip (ClipmanClip *clip, - ClipmanPlugin *clipman_plugin); -static void clipman_plugin_menu_popup (ClipmanPlugin *clipman_plugin); + DBG ("Menu Destroyed"); +} -static void clipman_plugin_menu_position (GtkMenu *menu, - gint *x, - gint *y, - gboolean *push_in, - gpointer user_data); -static void clipman_plugin_menu_destroy (ClipmanPlugin *clipman_plugin); +static gboolean +clipman_clear (GtkWidget *mi, + GdkEventButton *ev, + ClipmanPlugin *clipman) +{ + ClipmanClip *clip; -static void clipman_plugin_menu_item_activate (GtkWidget *widget, - ClipmanPlugin *clipman_plugin); -static gboolean clipman_plugin_menu_item_pressed (GtkWidget *widget, - GdkEventButton *event, - ClipmanPlugin *clipman_plugin); -static void clipman_plugin_add_static (ClipmanPlugin *clipman_plugin); + if (xfce_confirm (_("Are you sure you want to clear the history?"), + "gtk-yes", + NULL)) + { + gtk_clipboard_clear (primaryClip); + gtk_clipboard_clear (defaultClip); -static void clipman_plugin_add_static_with_text (ClipmanPlugin *clipman_plugin, - const gchar *text); -static void clipman_plugin_delete (ClipmanPlugin *clipman_plugin, - ClipmanClip *clip); -static gboolean clipman_plugin_message_received (ClipmanPlugin *clipman_plugin, - GdkEventClient *ev); -static gboolean clipman_plugin_set_selection (ClipmanPlugin *clipman_plugin); + while (clipman->clips->len > 0) + { + clip = g_ptr_array_index (clipman->clips, 0); + g_ptr_array_remove (clipman->clips, clip); + clipman_free_clip (clip); + } + } + /* 'Save' the empty clipboard */ + clipman_save (clipman->plugin, clipman); + return FALSE; +} +void +clipman_check_array_len (ClipmanPlugin *clipman) +{ + ClipmanClip *clip; -static ClipmanClips * clipman_clips_new (ClipmanPlugin *clipman_plugin); + DBG ("Checking Array Length"); -static void clipman_clips_clear_history (ClipmanClips *clipman_clips); + while (clipman->clips->len > clipman->HistoryItems) + { + clip = g_ptr_array_index (clipman->clips, 0); + g_ptr_array_remove (clipman->clips, clip); + clipman_free_clip (clip); -static void clipman_clips_restore_empty (ClipmanClips *clipman_clips, - ClipboardType type); -static gboolean clipman_clips_check_clipboard (ClipmanClips *clipman_clips); + DBG("A clip have been removed"); + } +} -static void clipman_clips_add (ClipmanClips *clipman_clips, - gchar *text, - ClipboardType type); -static gint clipman_clips_compare (ClipmanClip *one, - ClipmanClip *two); -static gint clipman_clips_compare_with_type (ClipmanClip *one, - ClipmanClip *two); +static gchar * +clipman_create_title (gchar *txt, + gint length) +{ + gchar *s, *t, *u, *buf; + gint i; -static ClipmanClip * clipman_clip_new (gchar *text, ClipboardType type); + /* rough string copy */ + s = g_strndup (txt, length*8 + 8); -static void clipman_clip_free (ClipmanClip *clip); + if (G_UNLIKELY (!s)) + return NULL; + if (!g_utf8_validate (s, -1, NULL)) + { + DBG ("Title is not utf8 complaint, we're going to convert it"); + u = g_locale_to_utf8 (s, -1, NULL, NULL, NULL); + g_free (s); + s = u; + /* Check the title again */ + if (!g_utf8_validate (s, -1, NULL)) + { + DBG ("Title is still not utf8 complaint, we going to drop this clip"); + g_free (s); + return NULL; + } + } -XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (clipman_plugin_register); + /* create string length */ + buf = g_malloc(length*6); /* max length of utf8 char is 6 */ + g_utf8_strncpy (buf, s, length); + g_free (s); + s = buf; -static void -clipman_plugin_register (XfcePanelPlugin *panel_plugin) -{ - xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); + /* remove tabs and newlines */ + /* this works when the string is utf8-valid */ + i = 0; + while (s[i] != '\0') + { + if (s[i] == '\n' || s[i] == '\r' || s[i] == '\t') + s[i] = ' '; + i++; + } - ClipmanPlugin *clipman_plugin = clipman_plugin_new (panel_plugin); - g_return_if_fail (G_LIKELY (NULL != clipman_plugin)); + /* remove html characters */ + t = g_markup_escape_text (s, -1); + g_free (s); - g_signal_connect_swapped (panel_plugin, - "save", - G_CALLBACK (clipman_plugin_save_data), - clipman_plugin); - g_signal_connect_swapped (panel_plugin, - "free-data", - G_CALLBACK (clipman_plugin_free), - clipman_plugin); - g_signal_connect_swapped (panel_plugin, - "size-changed", - G_CALLBACK (clipman_plugin_set_size), - clipman_plugin); - g_signal_connect_swapped (panel_plugin, - "configure-plugin", - G_CALLBACK (clipman_configure_new), - clipman_plugin); - - xfce_panel_plugin_menu_show_configure (panel_plugin); - xfce_panel_plugin_add_action_widget (panel_plugin, clipman_plugin->button); - clipman_plugin_set_selection (clipman_plugin); - - gtk_widget_show_all (clipman_plugin->button); + return t; } -static ClipmanPlugin * -clipman_plugin_new (XfcePanelPlugin *panel_plugin) +void +clipman_remove_selection_clips (ClipmanPlugin *clipman) { - ClipmanPlugin *clipman_plugin = g_slice_new0 (ClipmanPlugin); - clipman_plugin->panel_plugin = panel_plugin; - clipman_plugin->clipman_clips = clipman_clips_new (clipman_plugin); + ClipmanClip *clip; + guint i; - clipman_plugin->button = xfce_create_panel_toggle_button (); - clipman_plugin->icon = gtk_image_new (); + if (!clipman->IgnoreSelect) + return; - gtk_container_add (GTK_CONTAINER (clipman_plugin->button), clipman_plugin->icon); - gtk_container_add (GTK_CONTAINER (panel_plugin), clipman_plugin->button); + DBG ("Cleaning up all selection clips"); - g_signal_connect_swapped (clipman_plugin->button, - "toggled", - G_CALLBACK (clipman_plugin_menu_popup), - clipman_plugin); + for (i = clipman->clips->len; i--; ) + { + clip = g_ptr_array_index (clipman->clips, i); - clipman_plugin_load_data (clipman_plugin); - - return clipman_plugin; + if (clip->fromtype == PRIMARY) + { + g_ptr_array_remove (clipman->clips, clip); + clipman_free_clip (clip); + } + } } static void -clipman_plugin_load_data (ClipmanPlugin *clipman_plugin) +clipman_add_clip (ClipmanPlugin *clipman, + gchar *txt, + ClipboardType type) { - XfceRc *rc; - gchar *file; - gint length; - ClipmanClips *clipman_clips = clipman_plugin->clipman_clips; + ClipmanClip *new_clip; - file = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "xfce4/panel/clipman.rc", TRUE); - if (G_UNLIKELY (NULL == file)) - return; - rc = xfce_rc_simple_open (file, FALSE); - g_free (file); + if (G_LIKELY (txt != NULL) && + G_LIKELY (strcmp (txt, ""))) + { + new_clip = panel_slice_new0 (ClipmanClip); - xfce_rc_set_group (rc, "Properties"); + new_clip->title = clipman_create_title (txt, + clipman->MenuCharacters); - clipman_plugin->menu_item_show_number = xfce_rc_read_bool_entry (rc, "ItemNumbers", DEFITEMNUMBERS); + /* No valid title could be created, drop it... */ + if (new_clip->title == NULL) + { + g_free (new_clip); + return; + } - length = xfce_rc_read_int_entry (rc, "MenuCharacters", DEFCHARS); - if (length > MAXCHARS) - length = MAXCHARS; - else if (length < MINCHARS) - length = MINCHARS; - clipman_plugin->menu_item_max_chars = length; + new_clip->text = g_strdup (txt); + new_clip->fromtype = type; - clipman_clips->behavior = xfce_rc_read_int_entry (rc, "Behaviour", DEFBEHAVIOUR); - clipman_clips->save_on_exit = xfce_rc_read_bool_entry (rc, "ExitSave", DEFEXITSAVE); - clipman_clips->prevent_empty = xfce_rc_read_bool_entry (rc, "PreventEmpty", DEFPREVENTEMPTY); - clipman_clips->ignore_primary = xfce_rc_read_bool_entry (rc, "IgnoreSelect", DEFIGNORESELECT); - clipman_clips->ignore_static_clipboard = xfce_rc_read_bool_entry (rc, "IgnoreStatic", DEFIGNORESTATIC); - clipman_clips->static_selection = xfce_rc_read_int_entry (rc, "StaticSelection", PRIMARY); + g_ptr_array_add (clipman->clips, new_clip); - length = xfce_rc_read_int_entry (rc, "HistoryItems", DEFHISTORY); - if (length > MAXHISTORY) - length = MAXHISTORY; - else if (length < MINHISTORY) - length = MINHISTORY; - clipman_clips->history_length = length; + DBG("Added clip %d of %d", clipman->clips->len, clipman->HistoryItems); + } +} - xfce_rc_set_group (rc, "Clips"); +static gboolean +clipman_exists (ClipmanPlugin *clipman, + gchar *txt, + ClipboardType type) +{ + guint i; + ClipmanClip *clip; - gchar name[13]; - gint n = sizeof (name); - gchar *text = NULL; /* We use this allocation so no free() */ - ClipboardType type; + /* Walk through the array backwards, because + * if the text exists, this will probably be the newest */ - length = xfce_rc_read_int_entry (rc, "ClipsLen", 0); - if (length > MAXHISTORY) - length = MAXHISTORY; - if (length > 0 && clipman_clips->save_on_exit) + for (i = clipman->clips->len; i--; ) { - DBG ("Restoring the clipboard"); + clip = g_ptr_array_index (clipman->clips, i); - while (length-- > 0) + if (G_LIKELY ((clip->text != NULL) && + (strcmp(clip->text, txt) == 0)) + ) { - g_snprintf (name, n, "clip_%d_text", length); - text = g_strdup (xfce_rc_read_entry (rc, name, "")); - g_snprintf (name, n, "clip_%d_from", length); - type = (ClipboardType)xfce_rc_read_int_entry (rc, name, 0); - clipman_clips_add (clipman_clips, text, type); - } - } + switch (clipman->Behaviour) + { + case NORMAL: + if (type == DEFAULT && + clip->fromtype == PRIMARY) + clip->fromtype = DEFAULT; - xfce_rc_set_group (rc, "StaticClips"); + return TRUE; - length = xfce_rc_read_int_entry (rc, "ClipsLen", 0); - if (length > 0) - { - DBG ("Restoring the static clipboard"); + case STRICTLY: + if (type == clip->fromtype) + return TRUE; - while (length-- > 0) - { - g_snprintf (name, n, "clip_%d_text", length); - text = g_strdup (xfce_rc_read_entry (rc, name, "")); - clipman_clips_add (clipman_clips, text, STATIC); + return FALSE; + } } } - xfce_rc_close (rc); + return FALSE; } -static void -clipman_plugin_save_data (ClipmanPlugin *clipman_plugin) +static gboolean +clipman_item_clicked (GtkWidget *mi, + GdkEventButton *ev, + ClipmanAction *action) { - ClipmanClips *clipman_clips = clipman_plugin->clipman_clips; - XfceRc *rc; - gchar *file; + gchar *dtext, *ptext; - file = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "xfce4/panel/clipman.rc", TRUE); - if (G_UNLIKELY (NULL == file)) - return; - rc = xfce_rc_simple_open (file, FALSE); - g_free (file); - - xfce_rc_set_group (rc, "Properties"); - - xfce_rc_write_bool_entry (rc, "ItemNumbers", clipman_plugin->menu_item_show_number); - xfce_rc_write_int_entry (rc, "MenuCharacters", clipman_plugin->menu_item_max_chars); - - xfce_rc_write_bool_entry (rc, "ExitSave", clipman_clips->save_on_exit); - xfce_rc_write_int_entry (rc, "Behaviour", clipman_clips->behavior); - xfce_rc_write_int_entry (rc, "HistoryItems", clipman_clips->history_length); - xfce_rc_write_bool_entry (rc, "PreventEmpty", clipman_clips->prevent_empty); - xfce_rc_write_bool_entry (rc, "IgnoreSelect", clipman_clips->ignore_primary); - xfce_rc_write_bool_entry (rc, "IgnoreStatic", clipman_clips->ignore_static_clipboard); - xfce_rc_write_int_entry (rc, "StaticSelection", clipman_clips->static_selection); - - GSList *list; - ClipmanClip *clip; - gint i; - gchar name[13]; - gint n = sizeof (name); - - xfce_rc_delete_group (rc, "Clips", TRUE); - if (clipman_clips->save_on_exit && G_LIKELY (NULL != clipman_clips->history)) + if (ev->button == 1 && action->clipman->Behaviour == STRICTLY) { - DBG ("Saving the clipboard history"); + DBG("Clip copied to his own clipboard (STRICTLY)"); - xfce_rc_set_group (rc, "Clips"); - xfce_rc_write_int_entry (rc, "ClipsLen", g_slist_length (clipman_clips->history)); + if (action->clip->fromtype == DEFAULT) + { + gtk_clipboard_clear (defaultClip); + gtk_clipboard_set_text (defaultClip, action->clip->text, -1); + } - for (i = 0, list = clipman_clips->history; list != NULL; list = list->next, i++) - { - clip = (ClipmanClip *)list->data; - g_snprintf (name, n, "clip_%d_text", i); - xfce_rc_write_entry (rc, name, clip->text); - g_snprintf (name, n, "clip_%d_from", i); - xfce_rc_write_int_entry (rc, name, clip->type); - } + if (action->clip->fromtype == PRIMARY) + { + gtk_clipboard_clear (primaryClip); + gtk_clipboard_set_text (primaryClip, action->clip->text, -1); + } } + else if (ev->button == 1) + { + gtk_clipboard_clear (defaultClip); + gtk_clipboard_set_text (defaultClip, action->clip->text, -1); + DBG ("Clip copied to default clipboard"); - xfce_rc_delete_group (rc, "StaticClips", TRUE); - if (G_LIKELY (NULL != clipman_clips->static_clipboard)) + if (!action->clipman->IgnoreSelect) + { + gtk_clipboard_clear (primaryClip); + gtk_clipboard_set_text (primaryClip, action->clip->text, -1); + DBG ("Clip copied to primary clipboard"); + } + } + else if (ev->button == 3) { - DBG ("Saving the static clipboard"); + if (xfce_confirm (_("Are you sure you want to remove this clip from the history?"), + "gtk-yes", NULL)) + { + DBG ("Removed the selected clip from the History"); - xfce_rc_set_group (rc, "StaticClips"); - xfce_rc_write_int_entry (rc, "ClipsLen", g_slist_length (clipman_clips->static_clipboard)); + dtext = gtk_clipboard_wait_for_text (defaultClip); + if (dtext && !strcmp(dtext, action->clip->text)) + { + gtk_clipboard_clear (defaultClip); + gtk_clipboard_set_text (defaultClip, "", -1); + } + g_free (dtext); - for (i = 0, list = clipman_clips->history; list != NULL; list = list->next, i++) - { - clip = (ClipmanClip *)list->data; - g_snprintf (name, n, "clip_%d_text", i); - xfce_rc_write_entry (rc, name, clip->text); + ptext = gtk_clipboard_wait_for_text (primaryClip); + if (ptext && !strcmp(ptext, action->clip->text)) + { + gtk_clipboard_clear (primaryClip); + gtk_clipboard_set_text (primaryClip, "", -1); + } + g_free (ptext); + + g_ptr_array_remove (action->clipman->clips, action->clip); + clipman_free_clip (action->clip); } } - xfce_rc_close (rc); -} + panel_slice_free (ClipmanAction, action); -static void -clipman_plugin_free (ClipmanPlugin *clipman_plugin) -{ - /* There are no resources to free that won't be after we quit the plugin */ - gtk_main_quit (); + return FALSE; } -static gboolean -clipman_plugin_set_size (ClipmanPlugin *clipman_plugin, - gint size) +static GtkWidget * +clipman_create_menuitem (ClipmanAction *action, + guint width, + guint number, + gboolean bold) { - gtk_widget_set_size_request (GTK_WIDGET (clipman_plugin->panel_plugin), size, size); - size -= 2 + 2 * MAX (clipman_plugin->button->style->xthickness, - clipman_plugin->button->style->ythickness); + GtkWidget *mi, *label; + gchar *title, *string_num; - GtkIconTheme *icon_theme = gtk_icon_theme_get_default (); - GdkPixbuf *pixbuf = gtk_icon_theme_load_icon (icon_theme, GTK_STOCK_PASTE, size, 0, NULL); - GdkPixbuf *scaled = gdk_pixbuf_scale_simple (pixbuf, size, size, GDK_INTERP_BILINEAR); - g_object_unref (G_OBJECT (pixbuf)); - pixbuf = scaled; - - if (G_UNLIKELY (NULL == pixbuf)) + if (action->clipman->ItemNumbers) { - gtk_image_clear (GTK_IMAGE (clipman_plugin->icon)); - return FALSE; + if (number < 10) + string_num = g_strdup_printf("%d. ", number); + else + string_num = g_strdup_printf("%d. ", number); } + else + { + string_num = g_strdup (""); + } - gtk_image_set_from_pixbuf (GTK_IMAGE (clipman_plugin->icon), pixbuf); - g_object_unref (G_OBJECT (pixbuf)); + if (bold) + title = g_strdup_printf("%s%s", string_num, action->clip->title); + else + title = g_strdup_printf("%s%s", string_num, action->clip->title); - return TRUE; -} + g_free (string_num); -static gchar * -clipman_plugin_get_short_text (ClipmanPlugin *clipman_plugin, - const gchar *text) -{ - gchar *short_text, *tmp = NULL; - const gchar *offset; - gint max_length; - g_return_val_if_fail (G_LIKELY (NULL != text), NULL); - g_return_val_if_fail (G_LIKELY (g_utf8_validate (text, -1, NULL)), NULL); + label = gtk_label_new (title); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_label_set_single_line_mode (GTK_LABEL (label), TRUE); + gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); + gtk_label_set_max_width_chars (GTK_LABEL (label), width); - short_text = g_strstrip (g_strdup (text)); + g_free (title); - /* Shorten */ - max_length = clipman_plugin->menu_item_max_chars; - if (g_utf8_strlen (short_text, -1) > max_length) - { - offset = g_utf8_offset_to_pointer (short_text, max_length); - tmp = g_strndup (short_text, offset - short_text); - g_free (short_text); + mi = gtk_menu_item_new (); + gtk_container_add (GTK_CONTAINER (mi), label); + gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), mi); + gtk_widget_show (label); - short_text = g_strconcat (tmp, "...", NULL); /* Ellipsis */ - g_free (tmp); - } - - /* Cleanup */ - tmp = g_strdelimit (short_text, "\n\r\t", ' '); - short_text = g_markup_escape_text (tmp, -1); - g_free (tmp); - - return short_text; + return mi; } static void -clipman_plugin_menu_new (ClipmanPlugin *clipman_plugin) +clipman_clicked_separated (GtkWidget *menu, + ClipmanPlugin *clipman) { - GtkWidget *mi; + gchar *ptext, *dtext; + guint i, j; + ClipmanAction *action = NULL; + ClipmanClip *clip; + GtkWidget *mi; - clipman_plugin->menu = gtk_menu_new (); + /* Default Clips */ + dtext = gtk_clipboard_wait_for_text (defaultClip); + j = 0; - /* Add clipboard entries */ - if (G_LIKELY (NULL != clipman_plugin->clipman_clips->history)) - g_slist_foreach (clipman_plugin->clipman_clips->history, - (GFunc)clipman_plugin_menu_insert_clip, - clipman_plugin); - else + for (i = clipman->clips->len; i--; ) { - mi = gtk_menu_item_new_with_label (_("< Clipboard Empty >")); - gtk_widget_set_sensitive (mi, FALSE); - gtk_menu_shell_prepend (GTK_MENU_SHELL (clipman_plugin->menu), mi); - } + clip = g_ptr_array_index (clipman->clips, i); - if (!clipman_plugin->clipman_clips->ignore_static_clipboard) - { - /* Prepend static clipboard */ - mi = gtk_separator_menu_item_new (); - gtk_menu_shell_prepend (GTK_MENU_SHELL (clipman_plugin->menu), mi); - - if (NULL != clipman_plugin->clipman_clips->static_clipboard) - g_slist_foreach (clipman_plugin->clipman_clips->static_clipboard, - (GFunc)clipman_plugin_menu_insert_clip, - clipman_plugin); - else + if (clip->fromtype == DEFAULT) { - mi = gtk_menu_item_new_with_label (_("< Static Clipboard Empty >")); - gtk_widget_set_sensitive (mi, FALSE); - gtk_menu_shell_prepend (GTK_MENU_SHELL (clipman_plugin->menu), mi); - } + j++; - /* Append add to static clipboard */ - mi = gtk_separator_menu_item_new (); - gtk_menu_shell_append (GTK_MENU_SHELL (clipman_plugin->menu), mi); + action = panel_slice_new0 (ClipmanAction); + action->clipman = clipman; + action->clip = clip; - mi = gtk_menu_item_new_with_label (_("Add static clipboard")); - gtk_menu_shell_append (GTK_MENU_SHELL (clipman_plugin->menu), mi); - g_signal_connect_swapped (mi, - "activate", - G_CALLBACK (clipman_plugin_add_static), - clipman_plugin); - } - else - { - mi = gtk_separator_menu_item_new (); - gtk_menu_shell_append (GTK_MENU_SHELL (clipman_plugin->menu), mi); + if (dtext != NULL && + G_LIKELY (clip->text != NULL) && + strcmp(clip->text, dtext) == 0) + { + mi = clipman_create_menuitem (action, clipman->MenuCharacters, + j, TRUE); + g_free (dtext); + dtext = NULL; + } + else + { + mi = clipman_create_menuitem (action, clipman->MenuCharacters, + j, FALSE); + } + g_signal_connect (G_OBJECT(mi), "button_release_event", + G_CALLBACK(clipman_item_clicked), action); + + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); + } } - /* Prepend title */ - mi = gtk_separator_menu_item_new (); - gtk_menu_shell_prepend (GTK_MENU_SHELL (clipman_plugin->menu), mi); + g_free (dtext); - mi = gtk_menu_item_new_with_label (""); - gchar *title = g_strdup_printf ("%s", _("Clipman History")); - gtk_label_set_markup (GTK_LABEL (GTK_BIN (mi)->child), title); - gtk_widget_set_sensitive (mi, FALSE); - gtk_menu_shell_prepend (GTK_MENU_SHELL (clipman_plugin->menu), mi); + if (j == 0) + { + mi = gtk_menu_item_new_with_label (_("< Default History Empty >")); + gtk_widget_set_sensitive (mi, FALSE); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); + } - /* Append clear history */ - mi = gtk_menu_item_new_with_label (_("Clear History")); - gtk_menu_shell_append (GTK_MENU_SHELL (clipman_plugin->menu), mi); - g_signal_connect_swapped (mi, - "activate", - G_CALLBACK (clipman_clips_clear_history), - clipman_plugin->clipman_clips); + /* Primairy Clips */ + mi = gtk_separator_menu_item_new (); + gtk_widget_set_sensitive (mi, FALSE); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - /* Do the rest */ - g_signal_connect_swapped (clipman_plugin->menu, - "deactivate", - G_CALLBACK (clipman_plugin_menu_destroy), - clipman_plugin); + ptext = gtk_clipboard_wait_for_text (primaryClip); + j = 0; - gtk_menu_attach_to_widget (GTK_MENU (clipman_plugin->menu), - clipman_plugin->button, - NULL); - xfce_panel_plugin_register_menu (clipman_plugin->panel_plugin, - GTK_MENU (clipman_plugin->menu)); + for (i = clipman->clips->len; i--; ) + { + clip = g_ptr_array_index (clipman->clips, i); - gtk_widget_show_all (clipman_plugin->menu); -} + if (clip->fromtype == PRIMARY) + { + j++; -static void -clipman_plugin_menu_insert_clip (ClipmanClip *clip, - ClipmanPlugin *clipman_plugin) -{ - static gint i = 0, j = 0; - static ClipmanClip *clip_default = NULL, *clip_primary = NULL, *clip_last = NULL; - static gboolean clip_default_found = FALSE, clip_primary_found = FALSE; - gchar *text = NULL, *bold = NULL; - gint a = -1, b = -1; - GtkWidget *mi; + action = panel_slice_new0 (ClipmanAction); + action->clipman = clipman; + action->clip = clip; - g_return_if_fail (G_LIKELY (NULL != clip)); + if (ptext != NULL && + G_LIKELY (clip->text != NULL) && + strcmp(clip->text, ptext) == 0) + { + mi = clipman_create_menuitem (action, clipman->MenuCharacters, + j, TRUE); + g_free (ptext); + ptext = NULL; + } + else + { + mi = clipman_create_menuitem (action, clipman->MenuCharacters, + j, FALSE); + } - /* Get current clipboards */ - if (clip->type != STATIC && G_UNLIKELY (NULL == clip_default)) - { - /* The allocation of text is used as-is in clipman_clip_new() */ - text = gtk_clipboard_wait_for_text (clipman_plugin->clipman_clips->default_clipboard); - clip_default = clipman_clip_new (text, DEFAULT); - if (G_UNLIKELY (NULL == clip_default->text)) - clip_default->text = g_strdup (""); + g_signal_connect (G_OBJECT(mi), "button_release_event", + G_CALLBACK(clipman_item_clicked), action); - text = gtk_clipboard_wait_for_text (clipman_plugin->clipman_clips->primary_clipboard); - clip_primary = clipman_clip_new (text, PRIMARY); - if (G_UNLIKELY (NULL == clip_primary->text)) - clip_primary->text = g_strdup (""); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); + } } - /* Get the last clip */ - if (G_UNLIKELY (NULL == clip_last)) + g_free (ptext); + + if (j == 0) { - if (clip->type == STATIC) - clip_last = (ClipmanClip *)(g_slist_last (clipman_plugin->clipman_clips->static_clipboard)->data); - else - clip_last = (ClipmanClip *)(g_slist_last (clipman_plugin->clipman_clips->history)->data); + mi = gtk_menu_item_new_with_label (_("< Selection History Empty >")); + gtk_widget_set_sensitive (mi, FALSE); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); } - /* Generate a short text */ - if (G_UNLIKELY (NULL == clip->short_text)) - clip->short_text = clipman_plugin_get_short_text (clipman_plugin, clip->text); + mi = gtk_separator_menu_item_new (); + gtk_widget_set_sensitive (mi, FALSE); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - /* Generate the menu item text */ - if (clipman_plugin->menu_item_show_number && clipman_plugin->clipman_clips->behavior == STRICTLY) - text = g_strdup_printf ("%d. %s", (clip->type == PRIMARY) ? i+1 : j+1, clip->short_text); - else if (clipman_plugin->menu_item_show_number) - text = g_strdup_printf ("%d. %s", i+1, clip->short_text); - else - text = g_strdup (clip->short_text); + mi = gtk_menu_item_new_with_label (_("Clear History")); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - /* Check if the clip matches the clipboards to set the text in bold */ - if ((clip->type == DEFAULT && !clip_default_found) || - (clip->type == PRIMARY && !clip_primary_found)) + g_signal_connect (G_OBJECT (mi), "button_release_event", + G_CALLBACK (clipman_clear), clipman); +} + +static void +clipman_clicked_not_separated (GtkWidget *menu, + ClipmanPlugin *clipman) +{ + gchar *ptext, *dtext; + guint i; + ClipmanAction *action = NULL; + ClipmanClip *clip; + GtkWidget *mi; + + ptext = gtk_clipboard_wait_for_text (primaryClip); + dtext = gtk_clipboard_wait_for_text (defaultClip); + + for (i = clipman->clips->len; i--;) { - switch (clipman_plugin->clipman_clips->behavior) - { - case STRICTLY: - /* Check with default clipboard */ - a = clipman_clips_compare_with_type (clip, clip_default); - if (a == 0) - clip_default_found = TRUE; - /* Check with primary clipboard */ - else - { - b = clipman_clips_compare_with_type (clip, clip_primary); - if (b == 0) - clip_primary_found = TRUE; - } - break; + clip = g_ptr_array_index (clipman->clips, i); - default: - case NORMAL: - a = clipman_clips_compare (clip, clip_default); - if (a != 0) - b = clipman_clips_compare (clip, clip_primary); - if (a == 0 || b == 0) - clip_default_found = clip_primary_found = TRUE; - break; - } + action = panel_slice_new0 (ClipmanAction); + action->clipman = clipman; + action->clip = clip; - /* Set text in bold */ - if (a == 0 || b == 0) + if (dtext != NULL && + G_LIKELY (clip->text != NULL) && + strcmp(clip->text, dtext) == 0) { - bold = g_strconcat ("", text, "", NULL); - g_free (text); - text = bold; + mi = clipman_create_menuitem (action, clipman->MenuCharacters, + clipman->clips->len-i, TRUE); + g_free (dtext); + dtext = NULL; } + else if (ptext != NULL && + G_LIKELY (clip->text != NULL) && + strcmp(clip->text, ptext) == 0) + { + mi = clipman_create_menuitem (action, clipman->MenuCharacters, + clipman->clips->len-i, TRUE); + g_free (ptext); + ptext = NULL; + } + else + { + mi = clipman_create_menuitem (action, clipman->MenuCharacters, + clipman->clips->len-i, FALSE); + } + + g_signal_connect (G_OBJECT(mi), "button_release_event", + G_CALLBACK(clipman_item_clicked), action); + + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); } - /* Create the menu item */ - mi = gtk_menu_item_new_with_label (""); - gtk_label_set_markup (GTK_LABEL (GTK_BIN (mi)->child), text); - g_free (text); + g_free (ptext); + g_free (dtext); - g_object_set_data (G_OBJECT (mi), "clip", clip); + mi = gtk_separator_menu_item_new (); + gtk_widget_set_sensitive (mi, FALSE); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - /* Connect signals */ - g_signal_connect (mi, - "activate", - G_CALLBACK (clipman_plugin_menu_item_activate), - clipman_plugin); - g_signal_connect (mi, - "button_press_event", - G_CALLBACK (clipman_plugin_menu_item_pressed), - clipman_plugin); + mi = gtk_menu_item_new_with_label (_("Clear History")); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - /* Insert in the menu */ - switch (clip->type) - { - case STATIC: - gtk_menu_shell_prepend (GTK_MENU_SHELL (clipman_plugin->menu), mi); - i++; - break; + g_signal_connect (G_OBJECT (mi), "button_release_event", + G_CALLBACK (clipman_clear), clipman); +} - case DEFAULT: - case PRIMARY: - default: - switch (clipman_plugin->clipman_clips->behavior) - { - case STRICTLY: - /* Insert primary clipboard before default clipboard */ - if (clip->type == PRIMARY && !clipman_plugin->clipman_clips->ignore_primary) - { - gtk_menu_shell_insert (GTK_MENU_SHELL (clipman_plugin->menu), mi, i); - i++; - } - /* Append default clipboard */ - else - { - gtk_menu_shell_append (GTK_MENU_SHELL (clipman_plugin->menu), mi); - j++; - } - break; +static void +clipman_position_menu (GtkMenu *menu, + int *x, + int *y, + gboolean *push_in, + ClipmanPlugin *clipman) +{ + GtkRequisition req; + GdkScreen *screen; + GdkRectangle geom; + gint num; - default: - case NORMAL: - /* Append */ - gtk_menu_shell_append (GTK_MENU_SHELL (clipman_plugin->menu), mi); - i++; - break; - } - break; - } + gtk_widget_size_request (GTK_WIDGET (menu), &req); - /* Check if the clip matches the last clip */ - if (clip == clip_last) + gdk_window_get_origin (GTK_WIDGET (clipman->plugin)->window, x, y); + + switch (xfce_panel_plugin_get_screen_position(clipman->plugin)) { - if (clip->type != STATIC && clipman_plugin->clipman_clips->behavior == STRICTLY) - { - /* Add separators and check for empty clipboards */ - if (!clipman_plugin->clipman_clips->ignore_primary) - { - if (i == 0) - { - mi = gtk_menu_item_new_with_label (_("< Selection History Empty >")); - gtk_widget_set_sensitive (mi, FALSE); - gtk_menu_shell_insert (GTK_MENU_SHELL (clipman_plugin->menu), mi, i++); - } + case XFCE_SCREEN_POSITION_SW_H: + case XFCE_SCREEN_POSITION_S: + case XFCE_SCREEN_POSITION_SE_H: + DBG("Bottom"); + *y -= req.height; + break; - mi = gtk_separator_menu_item_new (); - gtk_menu_shell_insert (GTK_MENU_SHELL (clipman_plugin->menu), mi, i); - } + case XFCE_SCREEN_POSITION_NW_H: + case XFCE_SCREEN_POSITION_N: + case XFCE_SCREEN_POSITION_NE_H: + DBG("Top"); + *y += clipman->button->allocation.height; + break; - if (j == 0) - { - mi = gtk_menu_item_new_with_label (_("< Default History Empty >")); - gtk_widget_set_sensitive (mi, FALSE); - gtk_menu_shell_append (GTK_MENU_SHELL (clipman_plugin->menu), mi); - } - } + case XFCE_SCREEN_POSITION_NW_V: + case XFCE_SCREEN_POSITION_W: + case XFCE_SCREEN_POSITION_SW_V: + DBG("Left"); + *x += clipman->button->allocation.width; + *y += clipman->button->allocation.height - req.height; + break; - /* Free memory */ - if (NULL != clip_default) - clipman_clip_free (clip_default); - if (NULL != clip_primary) - clipman_clip_free (clip_primary); + case XFCE_SCREEN_POSITION_NE_V: + case XFCE_SCREEN_POSITION_E: + case XFCE_SCREEN_POSITION_SE_V: + DBG("Right"); + *x -= req.width; + *y += clipman->button->allocation.height - req.height; + break; - /* Unset static variables */ - clip_default = clip_primary = clip_last = NULL; - clip_default_found = clip_primary_found = FALSE; - i = j = 0; + case XFCE_SCREEN_POSITION_FLOATING_H: + case XFCE_SCREEN_POSITION_FLOATING_V: + case XFCE_SCREEN_POSITION_NONE: + DBG("Floating"); + gdk_display_get_pointer(gtk_widget_get_display(GTK_WIDGET(clipman->plugin)), + NULL, x, y, NULL); } -} -static void -clipman_plugin_menu_popup (ClipmanPlugin *clipman_plugin) -{ - gint rc = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (clipman_plugin->button)); - if (rc == FALSE) - return; + screen = gtk_widget_get_screen (clipman->button); + num = gdk_screen_get_monitor_at_window (screen, clipman->button->window); + gdk_screen_get_monitor_geometry (screen, num, &geom); - clipman_plugin_menu_new (clipman_plugin); - gtk_menu_popup (GTK_MENU (clipman_plugin->menu), - NULL, - NULL, - (GtkMenuPositionFunc)clipman_plugin_menu_position, - clipman_plugin->panel_plugin, - 0, - gtk_get_current_event_time ()); + if (*x > geom.x + geom.width - req.width) + *x = geom.x + geom.width - req.width; + if (*x < geom.x) + *x = geom.x; + + if (*y > geom.y + geom.height - req.height) + *y = geom.y + geom.height - req.height; + if (*y < geom.y) + *y = geom.y; } -static void -clipman_plugin_menu_position (GtkMenu *menu, - gint *x, - gint *y, - gboolean *push_in, - gpointer user_data) +static gboolean +clipman_clicked (GtkWidget *button, + GdkEventButton *ev, + ClipmanPlugin *clipman) { - XfcePanelPlugin *panel_plugin = user_data; - GtkWidget *button; - GtkRequisition requisition; - GtkOrientation orientation; - - g_return_if_fail (GTK_IS_MENU (menu)); - button = gtk_menu_get_attach_widget (menu); - g_return_if_fail (GTK_IS_WIDGET (button)); + GtkWidget *mi; + GtkWidget *menu; + gchar *title; - orientation = xfce_panel_plugin_get_orientation (panel_plugin); - gtk_widget_size_request (GTK_WIDGET (menu), &requisition); - gdk_window_get_origin (button->window, x, y); + if (ev->button != 1) + return FALSE; - switch (orientation) - { - case GTK_ORIENTATION_HORIZONTAL: - if (*y + button->allocation.height + requisition.height > gdk_screen_height ()) - /* Show menu above */ - *y -= requisition.height; - else - /* Show menu below */ - *y += button->allocation.height; + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (clipman->button), TRUE); - if (*x + requisition.width > gdk_screen_width ()) - /* Adjust horizontal position */ - *x = gdk_screen_width () - requisition.width; - break; - - case GTK_ORIENTATION_VERTICAL: - if (*x + button->allocation.width + requisition.width > gdk_screen_width ()) - /* Show menu on the right */ - *x -= requisition.width; - else - /* Show menu on the left */ - *x += button->allocation.width; - - if (*y + requisition.height > gdk_screen_height ()) - /* Adjust vertical position */ - *y = gdk_screen_height () - requisition.height; - break; - - default: - break; + menu = gtk_menu_new (); + + title = g_strdup_printf("%s", _("Clipman History")); + mi = gtk_menu_item_new_with_label (""); + gtk_label_set_markup(GTK_LABEL(GTK_BIN(mi)->child), title); + gtk_widget_set_sensitive (mi, FALSE); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); + + mi = gtk_separator_menu_item_new (); + gtk_widget_set_sensitive (mi, FALSE); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); + + if (clipman->SeparateMenu && + !clipman->IgnoreSelect && + G_LIKELY (clipman->clips->len > 0)) + { + clipman_clicked_separated (menu, clipman); } -} + else if (G_LIKELY (clipman->clips->len > 0)) + { + clipman_clicked_not_separated (menu, clipman); + } + else + { + mi = gtk_menu_item_new_with_label (_("< Clipboard Empty >")); + gtk_widget_set_sensitive (mi, FALSE); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); + } -static void -clipman_plugin_menu_destroy (ClipmanPlugin *clipman_plugin) -{ - if (G_LIKELY (GTK_IS_MENU (clipman_plugin->menu))) - gtk_menu_detach (GTK_MENU (clipman_plugin->menu)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (clipman_plugin->button), FALSE); + gtk_widget_show_all (menu); + + /* Also destroy the menu items when nothing is clicked */ + g_signal_connect (G_OBJECT(menu), "deactivate", + G_CALLBACK(clipman_destroy_menu), clipman); + + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, + (GtkMenuPositionFunc) clipman_position_menu, + clipman, 0, + gtk_get_current_event_time ()); + + return TRUE; } static void -clipman_plugin_menu_item_activate (GtkWidget *widget, - ClipmanPlugin *clipman_plugin) +clipman_restore_empty (ClipmanPlugin *clipman, + ClipboardType type) { - g_return_if_fail (G_LIKELY (GTK_IS_WIDGET (widget))); - ClipmanClip *clip = g_object_get_data (G_OBJECT (widget), "clip"); - g_return_if_fail (G_LIKELY (NULL != clip)); + guint i; + ClipmanClip *clip; - /* Copy the clip to the clipboard */ - if (clip->type != STATIC && clipman_plugin->clipman_clips->behavior == STRICTLY) + if (clipman->Behaviour == STRICTLY && + G_LIKELY (clipman->clips->len > 0)) { - if (clip->type == PRIMARY) - gtk_clipboard_set_text (clipman_plugin->clipman_clips->primary_clipboard, clip->text, -1); - else - gtk_clipboard_set_text (clipman_plugin->clipman_clips->default_clipboard, clip->text, -1); + /* Walk through the array till a clip of it's own + * type is found, then past it in the clipboard */ + for (i = clipman->clips->len; i--;) + { + clip = g_ptr_array_index (clipman->clips, i); + + if (clip->fromtype == type) + { + switch (type) + { + case PRIMARY: + gtk_clipboard_set_text(primaryClip, clip->text, -1); + break; + case DEFAULT: + gtk_clipboard_set_text(defaultClip, clip->text, -1); + break; + } + + DBG("Clipboard restored with a clip from same type"); + + break; + } + } } - /* Copy the static clip to the clipboard */ - else + else if (clipman->clips->len > 0) { - StaticSelection static_selection = clipman_plugin->clipman_clips->static_selection; + /* Grap the latest clip and paste it in the clipboard */ + clip = g_ptr_array_index (clipman->clips, (clipman->clips->len-1)); - if (static_selection == DEFAULT || static_selection == BOTH) - gtk_clipboard_set_text (clipman_plugin->clipman_clips->default_clipboard, clip->text, -1); + switch (type) + { + case PRIMARY: + gtk_clipboard_set_text(primaryClip, clip->text, -1); + break; + case DEFAULT: + gtk_clipboard_set_text(defaultClip, clip->text, -1); + break; + } - if (static_selection == PRIMARY || static_selection == BOTH) - gtk_clipboard_set_text (clipman_plugin->clipman_clips->primary_clipboard, clip->text, -1); + DBG("Last clip added"); } } static gboolean -clipman_plugin_menu_item_pressed (GtkWidget *widget, - GdkEventButton *event, - ClipmanPlugin *clipman_plugin) +clipman_check (ClipmanPlugin *clipman) { - if (event->button != 3 && event->button != 2) - return FALSE; + gchar *ptext = NULL, *dtext; + GdkModifierType state; - g_return_val_if_fail (G_LIKELY (GTK_IS_WIDGET (widget)), FALSE); - ClipmanClip *clip = g_object_get_data (G_OBJECT (widget), "clip"); - g_return_val_if_fail (G_LIKELY (NULL != clip), FALSE); + /* We ignore the selection clipboard entirely if you've activated this in the options dialog */ + if (!clipman->IgnoreSelect) + { + /* Get mouse button information */ + gdk_window_get_pointer(NULL, NULL, NULL, &state); - /* Copy clip to static clipboard */ - if (event->button == 2) - clipman_plugin_add_static_with_text (clipman_plugin, clip->text); + ptext = gtk_clipboard_wait_for_text (primaryClip); - /* Delete item */ - else if (event->button == 3) - clipman_plugin_delete (clipman_plugin, clip); + if (clipman->PreventEmpty && ptext == NULL) + { + clipman_restore_empty (clipman, PRIMARY); + } + else if (ptext != NULL && + !(state & GDK_BUTTON1_MASK) && + !clipman_exists (clipman, ptext, PRIMARY)) + { + DBG("Item added from primary clipboard"); + clipman_add_clip (clipman, ptext, PRIMARY); + clipman_check_array_len (clipman); + } - return TRUE; + g_free (ptext); + } + + dtext = gtk_clipboard_wait_for_text (defaultClip); + + /* Check default clipboard */ + if (clipman->PreventEmpty && dtext == NULL) + { + clipman_restore_empty (clipman, DEFAULT); + } + else if (G_LIKELY (dtext != NULL) && + !clipman_exists (clipman, dtext, DEFAULT)) + { + DBG("Item added from default clipboard"); + clipman_add_clip (clipman, dtext, DEFAULT); + clipman_check_array_len (clipman); + } + + g_free (dtext); + + return TRUE; } static void -clipman_plugin_add_static (ClipmanPlugin *clipman_plugin) +clipman_reset_timeout (ClipmanPlugin *clipman) { - clipman_plugin_add_static_with_text (clipman_plugin, NULL); + if (!(clipman->killTimeout)) + { + if (clipman->TimeoutId != 0) + g_source_remove (clipman->TimeoutId); + + clipman->TimeoutId = g_timeout_add_full (G_PRIORITY_LOW, + TIMER_INTERVAL, + (GSourceFunc) clipman_check, + clipman, + (GDestroyNotify) clipman_reset_timeout); + } } -static void -clipman_plugin_add_static_with_text (ClipmanPlugin *clipman_plugin, - const gchar *text) +void +clipman_save (XfcePanelPlugin *plugin, + ClipmanPlugin *clipman) { - /* Dialog */ - GtkWidget *dialog = - gtk_dialog_new_with_buttons (_("Add static clipboard"), - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (clipman_plugin->panel_plugin))), - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_NO_SEPARATOR, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_ADD, GTK_RESPONSE_OK, - NULL); - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_PASTE); - gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 110); + XfceRc *rc; + gchar *file; + guint i; + gchar name[13]; + ClipmanClip *clip; - /* Box */ - GtkWidget *vbox = GTK_DIALOG (dialog)->vbox; + DBG("Saving clipman settings"); - /* Scrolled window */ - GtkWidget *scrolledwin = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwin), GTK_SHADOW_IN); - gtk_container_add (GTK_CONTAINER (vbox), scrolledwin); + file = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "xfce4/panel/clipman.rc", TRUE); - /* Entry */ - GtkWidget *entry = gtk_text_view_new (); - GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (entry)); - gtk_text_view_set_accepts_tab (GTK_TEXT_VIEW (entry), FALSE); - if (NULL != text) - gtk_text_buffer_set_text (buffer, text, -1); - gtk_container_add (GTK_CONTAINER (scrolledwin), entry); + if (G_UNLIKELY (!file)) + return; - /* Containers */ - gtk_container_set_border_width (GTK_CONTAINER (dialog), 4); - gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER); + rc = xfce_rc_simple_open (file, FALSE); + g_free (file); - /* Run the dialog */ - gtk_widget_show_all (vbox); - gint result = gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_hide (dialog); + /* Save the preferences */ + xfce_rc_set_group (rc, "Properties"); - if (G_LIKELY (result == GTK_RESPONSE_OK && gtk_text_buffer_get_char_count (buffer) > 0)) + xfce_rc_write_bool_entry (rc, "ExitSave", clipman->ExitSave); + xfce_rc_write_bool_entry (rc, "IgnoreSelect", clipman->IgnoreSelect); + xfce_rc_write_bool_entry (rc, "PreventEmpty", clipman->PreventEmpty); + + switch (clipman->Behaviour) { - /* Add static clipboard */ - GtkTextIter start, end; - gtk_text_buffer_get_bounds (buffer, &start, &end); - gchar *text_dup = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (buffer), &start, &end, TRUE); - clipman_clips_add (clipman_plugin->clipman_clips, text_dup, STATIC); + case NORMAL: + xfce_rc_write_int_entry (rc, "Behaviour", 1); + break; + case STRICTLY: + xfce_rc_write_int_entry (rc, "Behaviour", 2); + break; } - /* Destroy the dialog */ - gtk_widget_destroy (dialog); -} + xfce_rc_write_bool_entry (rc, "ItemNumbers", clipman->ItemNumbers); + xfce_rc_write_bool_entry (rc, "SeparateMenu", clipman->SeparateMenu); -static void -clipman_plugin_delete (ClipmanPlugin *clipman_plugin, - ClipmanClip *clip) -{ - GtkWidget *dialog = - gtk_message_dialog_new (NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_YES_NO, - _("Are you sure you want to remove this clip from the history?")); - gint result = gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - if (G_UNLIKELY (result != GTK_RESPONSE_YES)) - return; + xfce_rc_write_int_entry (rc, "HistoryItems", clipman->HistoryItems); + xfce_rc_write_int_entry (rc, "MenuCharacters", clipman->MenuCharacters); - DBG ("Delete `%s' from clipboard (%d)", clip->text, clip->type); + /* Remove old content and create a new one */ + xfce_rc_delete_group (rc, "Clips", TRUE ); - /* The activate signal comes before button-press-event, therefore we must - * free the clipboards so the activate signal will not add a new item */ - ClipmanClips *clipman_clips = clipman_plugin->clipman_clips; - if (clip->type != STATIC) + if (clipman->ExitSave && + clipman->clips->len > 0 + ) { - switch (clipman_clips->behavior) + DBG("Saving the clipboard history"); + + xfce_rc_set_group (rc, "Clips"); + xfce_rc_write_int_entry (rc, "ClipsLen", clipman->clips->len); + + for (i = 0; i < clipman->clips->len; ++i) { - case STRICTLY: - if (clip->type == PRIMARY) - gtk_clipboard_set_text (clipman_clips->primary_clipboard, "", -1); - else - gtk_clipboard_set_text (clipman_clips->default_clipboard, "", -1); + clip = g_ptr_array_index (clipman->clips, i); - default: - case NORMAL: - gtk_clipboard_set_text (clipman_clips->default_clipboard, "", -1); - gtk_clipboard_set_text (clipman_clips->primary_clipboard, "", -1); - break; + g_snprintf (name, 13, "clip_%d_text", i); + xfce_rc_write_entry (rc, name, clip->text); + + g_snprintf (name, 13, "clip_%d_from", i); + if (clip->fromtype == PRIMARY) + xfce_rc_write_int_entry (rc, name, 0); + else + xfce_rc_write_int_entry (rc, name, 1); } } - clipman_clips_delete (clipman_clips, clip); + xfce_rc_close (rc); } -static gboolean -clipman_plugin_message_received (ClipmanPlugin *clipman_plugin, - GdkEventClient *ev) +static void +clipman_read (ClipmanPlugin *clipman) { - DBG ("Message received"); - if (G_LIKELY (ev->data_format == 8 && *(ev->data.b) != '\0')) - { - if (!g_ascii_strcasecmp (XFCE_CLIPMAN_MESSAGE, ev->data.b)) - { - DBG ("`%s'", ev->data.b); - xfce_panel_plugin_set_panel_hidden (clipman_plugin->panel_plugin, FALSE); - while (gtk_events_pending ()) - gtk_main_iteration (); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (clipman_plugin->button), TRUE); - return TRUE; - } - } - return FALSE; -} + XfceRc *rc; + gchar *file, *value; + guint type, i, clipslen; + gchar name[13]; -static gboolean -clipman_plugin_set_selection (ClipmanPlugin *clipman_plugin) -{ - GdkScreen *gscreen; - gchar *selection_name; - Atom selection_atom; - GtkWidget *win; - Window id; + /* Because Clipman is unique, we use 1 config file */ + /* + file = xfce_panel_plugin_save_location (clipman->plugin, FALSE); + DBG("Read from file: %s", file); + */ - win = gtk_invisible_new (); - gtk_widget_realize (win); - id = GDK_WINDOW_XID (GTK_WIDGET (win)->window); + file = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "xfce4/panel/clipman.rc", TRUE); - gscreen = gtk_widget_get_screen (win); - selection_name = g_strdup_printf (XFCE_CLIPMAN_SELECTION"%d", - gdk_screen_get_number (gscreen)); - selection_atom = XInternAtom (GDK_DISPLAY (), selection_name, FALSE); + if (G_UNLIKELY (!file)) + return; - if (XGetSelectionOwner (GDK_DISPLAY (), selection_atom)) + rc = xfce_rc_simple_open (file, FALSE); + g_free (file); + + xfce_rc_set_group (rc, "Properties"); + + clipman->ExitSave = xfce_rc_read_bool_entry (rc, "ExitSave", DEFEXITSAVE); + clipman->IgnoreSelect = xfce_rc_read_bool_entry (rc, "IgnoreSelect", DEFIGNORESELECT); + clipman->PreventEmpty = xfce_rc_read_bool_entry (rc, "PreventEmpty", DEFPREVENTEMPTY); + + switch (xfce_rc_read_int_entry (rc, "Behaviour", DEFBEHAVIOUR)) { - gtk_widget_destroy (win); - return FALSE; + case 1: + clipman->Behaviour = NORMAL; + DBG ("Behaviour = NORMAL"); + break; + case 2: + clipman->Behaviour = STRICTLY; + DBG ("Behaviour = STRICTLY"); + break; } - XSelectInput (GDK_DISPLAY (), id, PropertyChangeMask); - XSetSelectionOwner (GDK_DISPLAY (), selection_atom, id, GDK_CURRENT_TIME); + clipman->ItemNumbers = xfce_rc_read_bool_entry (rc, "ItemNumbers", DEFITEMNUMBERS); + clipman->SeparateMenu = xfce_rc_read_bool_entry (rc, "SeparateMenu", DEFSEPMENU); - g_signal_connect_swapped (win, "client-event", - G_CALLBACK (clipman_plugin_message_received), - clipman_plugin); + clipman->HistoryItems = xfce_rc_read_int_entry (rc, "HistoryItems", DEFHISTORY); + clipman->MenuCharacters = xfce_rc_read_int_entry (rc, "MenuCharacters", DEFCHARS); - return TRUE; -} + if (clipman->HistoryItems > MAXHISTORY) + clipman->HistoryItems = MAXHISTORY; + if (clipman->HistoryItems < MINHISTORY) + clipman->HistoryItems = MINHISTORY; + if (clipman->MenuCharacters > MAXCHARS) + clipman->MenuCharacters = MAXCHARS; + if (clipman->MenuCharacters < MINCHARS) + clipman->MenuCharacters = MINCHARS; + xfce_rc_set_group (rc, "Clips"); + clipslen = xfce_rc_read_int_entry (rc, "ClipsLen", 0); -static ClipmanClips * -clipman_clips_new (ClipmanPlugin *clipman_plugin) -{ - ClipmanClips *clipman_clips = g_slice_new0 (ClipmanClips); + if (clipslen > MAXHISTORY) + clipslen = MAXHISTORY; - clipman_clips->clipman_plugin = clipman_plugin; + if (clipman->ExitSave && + clipslen > 0 + ) + { + DBG("Restoring the clipboard"); - clipman_clips->default_clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); - clipman_clips->primary_clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY); + for (i = 0; i < clipslen; ++i) + { + g_snprintf (name, 13, "clip_%d_text", i); + value = g_strdup (xfce_rc_read_entry (rc, name, "")); - clipman_clips->history = NULL; - clipman_clips->static_clipboard = NULL; + g_snprintf (name, 13, "clip_%d_from", i); + type = xfce_rc_read_int_entry (rc, name, 0); - clipman_clips->timeout = - g_timeout_add_full (G_PRIORITY_LOW, - TIMER_INTERVAL, - (GSourceFunc)clipman_clips_check_clipboard, - clipman_clips, - (GDestroyNotify)NULL); + if (type == 0) + clipman_add_clip (clipman, value, PRIMARY); + else + clipman_add_clip (clipman, value, DEFAULT); - return clipman_clips; + g_free (value); + } + } + + xfce_rc_close (rc); } -static void -clipman_clips_clear_history (ClipmanClips *clipman_clips) +static ClipmanPlugin * +clipman_new (XfcePanelPlugin *plugin) { - GSList *list; + ClipmanPlugin *clipman; + clipman = panel_slice_new0 (ClipmanPlugin); - GtkWidget *dialog = - gtk_message_dialog_new (NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_YES_NO, - _("Are you sure you want to clear the history?")); - gint result = gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - if (G_UNLIKELY (result != GTK_RESPONSE_YES)) - return; + clipman->clips = g_ptr_array_new (); + clipman->plugin = plugin; - for (list = clipman_clips->history; list != NULL; list = list->next) - clipman_clip_free ((ClipmanClip *)list->data); - g_slist_free (list); + clipman->tooltip = gtk_tooltips_new (); + g_object_ref (G_OBJECT (clipman->tooltip)); - clipman_clips->history = NULL; + /* Load Settings */ + clipman_read (clipman); - gtk_clipboard_set_text (clipman_clips->default_clipboard, "", -1); - gtk_clipboard_set_text (clipman_clips->primary_clipboard, "", -1); -} + /* Create panel widgets */ + clipman->button = xfce_create_panel_toggle_button (); + gtk_widget_show (clipman->button); -static void -clipman_clips_restore_empty (ClipmanClips *clipman_clips, - ClipboardType type) -{ - if (G_UNLIKELY (NULL == clipman_clips->history)) - return; + clipman->icon = gtk_image_new (); + gtk_widget_show (clipman->icon); + gtk_container_add (GTK_CONTAINER (clipman->button), clipman->icon); - GSList *list = clipman_clips->history; - ClipmanClip *clip = (ClipmanClip *)list->data; + gtk_tooltips_set_tip (GTK_TOOLTIPS(clipman->tooltip), + clipman->button, _("Clipboard Manager"), + NULL); - switch (clipman_clips->behavior) - { - case STRICTLY: - while (clip->type != type) - { - list = list->next; - if (G_UNLIKELY (NULL == list)) - return; - clip = (ClipmanClip *)list->data; - } + g_signal_connect(clipman->button, "button_press_event", + G_CALLBACK(clipman_clicked), clipman); - if (type == DEFAULT) - gtk_clipboard_set_text (clipman_clips->default_clipboard, clip->text, -1); - else if (!clipman_clips->ignore_primary) - gtk_clipboard_set_text (clipman_clips->primary_clipboard, clip->text, -1); - break; + /* Start the clipman_check function */ + clipman->TimeoutId = g_timeout_add_full(G_PRIORITY_LOW, + TIMER_INTERVAL, + (GSourceFunc) clipman_check, + clipman, + (GDestroyNotify) clipman_reset_timeout); - default: - case NORMAL: - gtk_clipboard_set_text (clipman_clips->default_clipboard, clip->text, -1); - if (!clipman_clips->ignore_primary) - gtk_clipboard_set_text (clipman_clips->primary_clipboard, clip->text, -1); - break; - } + /* Connect to the clipboards */ + defaultClip = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); + primaryClip = gtk_clipboard_get (GDK_SELECTION_PRIMARY); - DBG ("Restore clipboard to `%s'", clip->text); + return clipman; } -static gboolean -clipman_clips_check_clipboard (ClipmanClips *clipman_clips) +static void +clipman_free (XfcePanelPlugin *plugin, + ClipmanPlugin *clipman) { - GdkModifierType state; - gchar *text; /* We use the new allocation of - * gtk_clipboard_wait_for_text, - * so no free() on that beotche */ + guint i; + ClipmanClip *clip; + GtkWidget *dialog; - /* Default clipboard */ - text = gtk_clipboard_wait_for_text (clipman_clips->default_clipboard); - if (G_LIKELY (NULL != text)) - clipman_clips_add (clipman_clips, text, DEFAULT); - else if (clipman_clips->prevent_empty == TRUE) - clipman_clips_restore_empty (clipman_clips, DEFAULT); + /* Valgrind notes: + - primaryClip and defaultClip should be cleared, but gtk + takes care about this + */ - /* Primary clipboard */ - if (!clipman_clips->ignore_primary) + /* Free the clipboards */ + gtk_clipboard_clear (primaryClip); + gtk_clipboard_clear (defaultClip); + + /* Destroy the setting dialog, if this open */ + dialog = g_object_get_data (G_OBJECT (plugin), "dialog"); + + if (dialog) + gtk_widget_destroy (dialog); + + /* Stop the check loop */ + clipman->killTimeout = TRUE; + if (clipman->TimeoutId != 0) { - gdk_window_get_pointer (NULL, NULL, NULL, &state); - if (state & GDK_BUTTON1_MASK) - return TRUE; + g_source_remove(clipman->TimeoutId); + clipman->TimeoutId = 0; + } - text = gtk_clipboard_wait_for_text (clipman_clips->primary_clipboard); - if (G_LIKELY (NULL != text)) - clipman_clips_add (clipman_clips, text, PRIMARY); - else if (clipman_clips->prevent_empty == TRUE) - clipman_clips_restore_empty (clipman_clips, PRIMARY); + /* Remove clipboard items */ + for (i = clipman->clips->len; i--;) + { + clip = g_ptr_array_index (clipman->clips, i); + g_ptr_array_remove_fast (clipman->clips, clip); + clipman_free_clip (clip); } + g_ptr_array_free (clipman->clips, TRUE); - return TRUE; -} + gtk_tooltips_set_tip (clipman->tooltip, clipman->button, NULL, NULL); + g_object_unref (G_OBJECT (clipman->tooltip)); -void -clipman_clips_delete (ClipmanClips *clipman_clips, - ClipmanClip *clip) -{ - g_return_if_fail (G_LIKELY (NULL != clip)); + gtk_widget_destroy (clipman->icon); + gtk_widget_destroy (clipman->button); - if (clip->type == STATIC) - clipman_clips->static_clipboard = g_slist_remove (clipman_clips->static_clipboard, clip); - else - clipman_clips->history = g_slist_remove (clipman_clips->history, clip); + clipman->plugin = NULL; - clipman_clip_free (clip); + DBG ("Plugin Freed"); + + panel_slice_free (ClipmanPlugin, clipman); } -static void -clipman_clips_add (ClipmanClips *clipman_clips, - gchar *text, - ClipboardType type) +static gboolean +clipman_set_size (XfcePanelPlugin *plugin, + gint wsize, + ClipmanPlugin *clipman) { - ClipmanClip *clip; - GSList *foobar = NULL; + GdkPixbuf *pb; + gint size; - g_return_if_fail (G_LIKELY (NULL != text)); + gtk_widget_set_size_request (clipman->button, wsize, wsize); - clip = clipman_clip_new (text, type); + size = wsize - 2 - (2 * MAX (clipman->button->style->xthickness, + clipman->button->style->ythickness)); - if (type == STATIC) - foobar = g_slist_find_custom (clipman_clips->static_clipboard, cl