update for beta release
[framework/uifw/e17.git] / src / modules / everything / evry_plug_clipboard.c
1 #include "e_mod_main.h"
2
3 static Evry_Action *act;
4 static Ecore_X_Window clipboard_win = 0;
5
6 static int
7 _action(Evry_Action *act)
8 {
9    const Evry_Item *it = act->it1.item;
10
11    ecore_x_selection_primary_set(clipboard_win, it->label, strlen(it->label));
12    ecore_x_selection_clipboard_set(clipboard_win, it->label, strlen(it->label));
13
14    return 1;
15 }
16
17 static int
18 _check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
19 {
20    return it && it->label && (strlen(it->label) > 0);
21 }
22
23 Eina_Bool
24 evry_plug_clipboard_init(void)
25 {
26    if (!evry_api_version_check(EVRY_API_VERSION))
27      return EINA_FALSE;
28
29    Ecore_X_Window win = ecore_x_window_new(0, 0, 0, 1, 1);
30    if (!win) return EINA_FALSE;
31
32 //FIXME: Icon name doesn't follow FDO Spec
33    act = EVRY_ACTION_NEW("Copy to Clipboard",
34                          EVRY_TYPE_TEXT, 0,
35                          "everything-clipboard",
36                          _action, _check_item);
37    act->remember_context = EINA_TRUE;
38    evry_action_register(act, 10);
39
40    clipboard_win = win;
41
42    return EINA_TRUE;
43 }
44
45 void
46 evry_plug_clipboard_shutdown(void)
47 {
48    ecore_x_window_free(clipboard_win);
49    evry_action_free(act);
50 }
51