Revert a wrong commit. Un-wanted files are committed together.
[framework/uifw/elementary.git] / src / bin / test_cnp.c
1 #ifdef HAVE_CONFIG_H
2 # include "elementary_config.h"
3 #endif
4 #include <Elementary.h>
5 #ifndef ELM_LIB_QUICKLAUNCH
6
7 static Evas_Object *glb;
8
9 static void
10 _bt_copy_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
11 {
12    Evas_Object *en = (Evas_Object*)(data);
13    const char *txt = elm_object_text_get(en);
14
15    elm_object_text_set(glb, txt);
16    elm_cnp_selection_set(elm_object_parent_widget_get(en), ELM_SEL_TYPE_CLIPBOARD,
17                          ELM_SEL_FORMAT_TEXT, txt, strlen(txt));
18 }
19
20 static void
21 _bt_paste_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
22 {
23    Evas_Object *en = (Evas_Object*)(data);
24
25    elm_cnp_selection_get(en, ELM_SEL_TYPE_CLIPBOARD, ELM_SEL_FORMAT_TEXT,
26                          NULL, NULL);
27 }
28
29 static void
30 _bt_clear_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
31 {
32    Evas_Object *en = (Evas_Object*)(data);
33
34    elm_object_text_set(glb, "");
35    elm_object_cnp_selection_clear(elm_object_parent_widget_get(en), ELM_SEL_TYPE_CLIPBOARD);
36 }
37
38 void
39 test_cnp(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
40 {
41    Evas_Object *win, *bg, *gd, *bt, *en, *lb;
42
43    win = elm_win_add(NULL, "CopyPaste", ELM_WIN_BASIC);
44    elm_win_title_set(win, "CopyPaste");
45    elm_win_autodel_set(win, EINA_TRUE);
46
47    bg = elm_bg_add(win);
48    elm_win_resize_object_add(win, bg);
49    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
50    evas_object_show(bg);
51
52    gd = elm_grid_add(win);
53    elm_grid_size_set(gd, 100, 100);
54    elm_win_resize_object_add(win, gd);
55    evas_object_size_hint_weight_set(gd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
56    evas_object_show(gd);
57
58    en = elm_entry_add(win);
59    elm_entry_scrollable_set(en, EINA_TRUE);
60    elm_entry_line_wrap_set(en, ELM_WRAP_CHAR);
61    evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
62    evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
63    elm_object_text_set(en, "Elementary provides ");
64    elm_grid_pack(gd, en, 10, 10, 60, 30);
65    evas_object_show(en);
66
67    bt = elm_button_add(win);
68    elm_object_text_set(bt, "Copy from left entry");
69    evas_object_smart_callback_add(bt, "clicked", _bt_copy_clicked, en);
70    elm_grid_pack(gd, bt, 70, 10, 22, 30);
71    evas_object_show(bt);
72
73    bt = elm_button_add(win);
74    elm_object_text_set(bt, "Clear clipboard");
75    evas_object_smart_callback_add(bt, "clicked", _bt_clear_clicked, en);
76    elm_grid_pack(gd, bt, 70, 70, 22, 20);
77    evas_object_show(bt);
78
79    en = elm_entry_add(win);
80    elm_entry_scrollable_set(en, EINA_TRUE);
81    elm_entry_line_wrap_set(en, ELM_WRAP_CHAR);
82    evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
83    evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
84    elm_object_text_set(en, "rich copying and pasting functionality,");
85    elm_grid_pack(gd, en, 10, 40, 60, 30);
86    evas_object_show(en);
87
88    bt = elm_button_add(win);
89    elm_object_text_set(bt, "Paste to left entry");
90    evas_object_smart_callback_add(bt, "clicked", _bt_paste_clicked, en);
91    elm_grid_pack(gd, bt, 70, 40, 22, 30);
92    evas_object_show(bt);
93
94    lb = elm_label_add(win);
95    elm_object_text_set(lb, "<b>Clipboard:</b>");
96    evas_object_size_hint_weight_set(lb, 0.0, 0.0);
97    evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL);
98    elm_grid_pack(gd, lb, 10, 70, 60, 10);
99    evas_object_show(lb);
100
101    glb = elm_label_add(win);
102    elm_object_text_set(glb, "");
103    evas_object_size_hint_weight_set(glb, 0.0, 0.0);
104    evas_object_size_hint_align_set(glb, EVAS_HINT_FILL, EVAS_HINT_FILL);
105    elm_grid_pack(gd, glb, 10, 80, 60, 10);
106    evas_object_show(glb);
107
108    evas_object_resize(win, 480, 200);
109    evas_object_show(win);
110 }
111 #endif