2010-05-14 15:06:06 -07:00
|
|
|
#include "e_mod_main.h"
|
2010-04-10 14:38:36 -07:00
|
|
|
|
2015-01-22 11:59:10 -08:00
|
|
|
#ifndef HAVE_WAYLAND_ONLY
|
2010-04-10 14:38:36 -07:00
|
|
|
static Evry_Action *act;
|
2015-01-22 11:59:10 -08:00
|
|
|
static Ecore_Window clipboard_win = 0;
|
2010-04-10 14:38:36 -07:00
|
|
|
|
|
|
|
static int
|
2012-05-04 02:38:52 -07:00
|
|
|
_action(Evry_Action *action)
|
2010-04-10 14:38:36 -07:00
|
|
|
{
|
2015-01-22 11:59:10 -08:00
|
|
|
const Evry_Item *it;
|
2014-03-18 13:14:04 -07:00
|
|
|
|
2015-01-22 11:59:10 -08:00
|
|
|
if (e_comp->comp_type != E_PIXMAP_TYPE_X) return 0;
|
|
|
|
it = action->it1.item;
|
2010-04-10 14:38:36 -07:00
|
|
|
ecore_x_selection_primary_set(clipboard_win, it->label, strlen(it->label));
|
|
|
|
ecore_x_selection_clipboard_set(clipboard_win, it->label, strlen(it->label));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-03-18 15:09:09 -07:00
|
|
|
_check_item(Evry_Action *action EINA_UNUSED, const Evry_Item *it)
|
2010-04-10 14:38:36 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
return it && it->label && (strlen(it->label) > 0);
|
2010-04-10 14:38:36 -07:00
|
|
|
}
|
2015-01-22 11:59:10 -08:00
|
|
|
#endif
|
2010-04-10 14:38:36 -07:00
|
|
|
Eina_Bool
|
|
|
|
evry_plug_clipboard_init(void)
|
|
|
|
{
|
2015-04-07 08:32:56 -07:00
|
|
|
#ifndef HAVE_WAYLAND_ONLY
|
2015-01-22 11:59:10 -08:00
|
|
|
Ecore_Window win;
|
2015-04-07 08:32:56 -07:00
|
|
|
#endif
|
2014-03-18 13:14:04 -07:00
|
|
|
|
2010-04-10 14:38:36 -07:00
|
|
|
if (!evry_api_version_check(EVRY_API_VERSION))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
2015-01-22 11:59:10 -08:00
|
|
|
if (e_comp->comp_type != E_PIXMAP_TYPE_X)
|
2014-03-18 13:14:04 -07:00
|
|
|
return EINA_FALSE;
|
2015-01-22 11:59:10 -08:00
|
|
|
#ifndef HAVE_WAYLAND_ONLY
|
2014-03-18 13:14:04 -07:00
|
|
|
win = ecore_x_window_input_new(0, 0, 0, 1, 1);
|
2010-04-10 14:38:36 -07:00
|
|
|
if (!win) return EINA_FALSE;
|
2013-08-01 04:12:31 -07:00
|
|
|
ecore_x_icccm_name_class_set(win, "evry", "clipboard");
|
2013-08-01 04:19:47 -07:00
|
|
|
e_comp_ignore_win_add(E_PIXMAP_TYPE_X, win);
|
2010-04-10 14:38:36 -07:00
|
|
|
|
2010-09-08 16:59:07 -07:00
|
|
|
//FIXME: Icon name doesn't follow FDO Spec
|
2013-01-05 14:53:46 -08:00
|
|
|
act = EVRY_ACTION_NEW(N_("Copy to Clipboard"),
|
2011-11-29 19:32:54 -08:00
|
|
|
EVRY_TYPE_TEXT, 0,
|
|
|
|
"everything-clipboard",
|
|
|
|
_action, _check_item);
|
2010-05-16 15:04:34 -07:00
|
|
|
act->remember_context = EINA_TRUE;
|
2010-04-10 14:38:36 -07:00
|
|
|
evry_action_register(act, 10);
|
|
|
|
|
|
|
|
clipboard_win = win;
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
2015-01-22 11:59:10 -08:00
|
|
|
#endif
|
2015-04-07 08:35:22 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2010-04-10 14:38:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evry_plug_clipboard_shutdown(void)
|
|
|
|
{
|
2015-01-22 11:59:10 -08:00
|
|
|
if (e_comp->comp_type != E_PIXMAP_TYPE_X) return;
|
|
|
|
#ifndef HAVE_WAYLAND_ONLY
|
2010-04-10 14:38:36 -07:00
|
|
|
ecore_x_window_free(clipboard_win);
|
|
|
|
evry_action_free(act);
|
2015-01-22 11:59:10 -08:00
|
|
|
#endif
|
2010-04-10 14:38:36 -07:00
|
|
|
}
|
2011-11-29 19:32:54 -08:00
|
|
|
|