Fix of mouse and ca capabilities check.
[midnight-commander.git] / src / clipboard.c
blob1ba1f3b63d04d6cb46d7febb6964bfa25e0c9ae0
1 /*
2 Util for external clipboard.
4 Copyright (C) 2009 The Free Software Foundation, Inc.
6 Written by:
7 Ilia Maslakon <il.smind@gmail.com>, 2010.
9 This file is part of the Midnight Commander.
11 The Midnight Commander is free software; you can redistribute it
12 and/or modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation; either version 2 of the
14 License, or (at your option) any later version.
16 The Midnight Commander is distributed in the hope that it will be
17 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
18 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
24 MA 02110-1301, USA.
27 #include <config.h>
29 #include <stdio.h>
30 #include <stdlib.h>
32 #include "lib/global.h"
33 #include "lib/fileloc.h"
34 #include "lib/util.h"
36 #include "main.h"
37 #include "src/execute.h"
39 #include "clipboard.h"
41 /*** global variables ****************************************************************************/
43 /* path to X clipboard utility */
44 char *clipboard_store_path = NULL;
45 char *clipboard_paste_path = NULL;
47 /*** file scope macro definitions ****************************************************************/
49 /*** file scope type declarations ****************************************************************/
51 /*** file scope variables ************************************************************************/
53 /*** file scope functions ************************************************************************/
54 /* --------------------------------------------------------------------------------------------- */
56 /* --------------------------------------------------------------------------------------------- */
57 /*** public functions ****************************************************************************/
58 /* --------------------------------------------------------------------------------------------- */
60 gboolean
61 copy_file_to_ext_clip (void)
63 char *tmp, *cmd;
64 int res = 0;
65 const char *d = getenv ("DISPLAY");
67 if (d == NULL || clipboard_store_path == NULL || clipboard_store_path[0] == '\0')
68 return FALSE;
70 tmp = concat_dir_and_file (home_dir, EDIT_CLIP_FILE);
71 cmd = g_strconcat (clipboard_store_path, " ", tmp, " 2>/dev/null", (char *) NULL);
73 if (cmd != NULL)
74 res = my_system (EXECUTE_AS_SHELL, shell, cmd);
76 g_free (cmd);
77 g_free (tmp);
78 return TRUE;
81 /* --------------------------------------------------------------------------------------------- */
83 gboolean
84 paste_to_file_from_ext_clip (void)
86 char *tmp, *cmd;
87 int res = 0;
88 const char *d = getenv ("DISPLAY");
90 if (d == NULL || clipboard_paste_path == NULL || clipboard_paste_path[0] == '\0')
91 return FALSE;
93 tmp = concat_dir_and_file (home_dir, EDIT_CLIP_FILE);
94 cmd = g_strconcat (clipboard_paste_path, " > ", tmp, " 2>/dev/null", (char *) NULL);
96 if (cmd != NULL)
97 res = my_system (EXECUTE_AS_SHELL, shell, cmd);
99 g_free (cmd);
100 g_free (tmp);
101 return TRUE;
104 /* --------------------------------------------------------------------------------------------- */