forked from enlightenment/efl
From: Hyoyoung Chang <hyoyoung@gmail.com>
Subject: [E-devel] [patch] add copy&paste example to elementary_test Date: Thu, 29 Dec 2011 18:08:48 +0900 Dear all, It's a patch to add copy&paste example to elm test in misc section. In this time, it contains only simple copying and paste, but i'll more extend. Thank you SVN revision: 66629
This commit is contained in:
parent
5b6e858db2
commit
11e658ec2b
|
@ -43,6 +43,7 @@ test_button.c \
|
||||||
test_calendar.c \
|
test_calendar.c \
|
||||||
test_check.c \
|
test_check.c \
|
||||||
test_clock.c \
|
test_clock.c \
|
||||||
|
test_cnp.c \
|
||||||
test_colorselector.c \
|
test_colorselector.c \
|
||||||
test_conform.c \
|
test_conform.c \
|
||||||
test_ctxpopup.c \
|
test_ctxpopup.c \
|
||||||
|
|
|
@ -14,6 +14,7 @@ void test_box_vert2(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_box_horiz(void *data, Evas_Object *obj, void *event_info);
|
void test_box_horiz(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_box_transition(void *data, Evas_Object *obj, void *event_info);
|
void test_box_transition(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_button(void *data, Evas_Object *obj, void *event_info);
|
void test_button(void *data, Evas_Object *obj, void *event_info);
|
||||||
|
void test_cnp(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_transit(void *data, Evas_Object *obj, void *event_info);
|
void test_transit(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_transit2(void *data, Evas_Object *obj, void *event_info);
|
void test_transit2(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_transit3(void *data, Evas_Object *obj, void *event_info);
|
void test_transit3(void *data, Evas_Object *obj, void *event_info);
|
||||||
|
@ -507,6 +508,7 @@ add_tests:
|
||||||
ADD_TEST(NULL, "Helpers", "Factory", test_factory);
|
ADD_TEST(NULL, "Helpers", "Factory", test_factory);
|
||||||
|
|
||||||
//------------------------------//
|
//------------------------------//
|
||||||
|
ADD_TEST(NULL, "Micellaneous", "Copy And Paste", test_cnp);
|
||||||
ADD_TEST(NULL, "Micellaneous", "Weather", test_weather);
|
ADD_TEST(NULL, "Micellaneous", "Weather", test_weather);
|
||||||
ADD_TEST(NULL, "Micellaneous", "Icon Desktops", test_icon_desktops);
|
ADD_TEST(NULL, "Micellaneous", "Icon Desktops", test_icon_desktops);
|
||||||
ADD_TEST(NULL, "Micellaneous", "Floating Objects", test_floating);
|
ADD_TEST(NULL, "Micellaneous", "Floating Objects", test_floating);
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
#include <Elementary.h>
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "elementary_config.h"
|
||||||
|
#endif
|
||||||
|
#ifndef ELM_LIB_QUICKLAUNCH
|
||||||
|
static void
|
||||||
|
_bt_copy_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
||||||
|
{
|
||||||
|
Evas_Object *en = (Evas_Object*)(data);
|
||||||
|
const char *txt = elm_object_text_get(en);
|
||||||
|
|
||||||
|
elm_cnp_selection_set(ELM_SEL_TYPE_CLIPBOARD, elm_object_parent_widget_get(en),
|
||||||
|
ELM_SEL_FORMAT_TEXT, txt, strlen(txt));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_bt_paste_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
||||||
|
{
|
||||||
|
Evas_Object *en = (Evas_Object*)(data);
|
||||||
|
|
||||||
|
elm_cnp_selection_get(ELM_SEL_TYPE_CLIPBOARD, ELM_SEL_FORMAT_TEXT,
|
||||||
|
en, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
test_cnp(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
||||||
|
{
|
||||||
|
Evas_Object *win, *bg, *gd, *bt, *en;
|
||||||
|
|
||||||
|
win = elm_win_add(NULL, "CopyPaste", ELM_WIN_BASIC);
|
||||||
|
elm_win_title_set(win, "CopyPaste");
|
||||||
|
elm_win_autodel_set(win, EINA_TRUE);
|
||||||
|
|
||||||
|
bg = elm_bg_add(win);
|
||||||
|
elm_win_resize_object_add(win, bg);
|
||||||
|
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
evas_object_show(bg);
|
||||||
|
|
||||||
|
gd = elm_grid_add(win);
|
||||||
|
elm_grid_size_set(gd, 100, 100);
|
||||||
|
elm_win_resize_object_add(win, gd);
|
||||||
|
evas_object_size_hint_weight_set(gd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
evas_object_show(gd);
|
||||||
|
|
||||||
|
en = elm_entry_add(win);
|
||||||
|
elm_entry_scrollable_set(en, EINA_TRUE);
|
||||||
|
elm_entry_line_wrap_set(en, ELM_WRAP_CHAR);
|
||||||
|
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
|
elm_entry_entry_set(en,
|
||||||
|
"Elementary provides "
|
||||||
|
);
|
||||||
|
elm_grid_pack(gd, en, 10, 10, 60, 40);
|
||||||
|
evas_object_show(en);
|
||||||
|
|
||||||
|
bt = elm_button_add(win);
|
||||||
|
elm_object_text_set(bt, "Copy from left entry");
|
||||||
|
evas_object_smart_callback_add(bt, "clicked", _bt_copy_clicked, en);
|
||||||
|
elm_grid_pack(gd, bt, 70, 10, 22, 40);
|
||||||
|
evas_object_show(bt);
|
||||||
|
|
||||||
|
en = elm_entry_add(win);
|
||||||
|
elm_entry_scrollable_set(en, EINA_TRUE);
|
||||||
|
elm_entry_line_wrap_set(en, ELM_WRAP_CHAR);
|
||||||
|
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
|
elm_entry_entry_set(en,
|
||||||
|
"rich copying and pasting functionality,"
|
||||||
|
);
|
||||||
|
elm_grid_pack(gd, en, 10, 50, 60, 40);
|
||||||
|
evas_object_show(en);
|
||||||
|
|
||||||
|
bt = elm_button_add(win);
|
||||||
|
elm_object_text_set(bt, "Paste to left entry");
|
||||||
|
evas_object_smart_callback_add(bt, "clicked", _bt_paste_clicked, en);
|
||||||
|
elm_grid_pack(gd, bt, 70, 50, 22, 40);
|
||||||
|
evas_object_show(bt);
|
||||||
|
|
||||||
|
evas_object_resize(win, 480, 140);
|
||||||
|
evas_object_show(win);
|
||||||
|
}
|
||||||
|
#endif
|
Loading…
Reference in New Issue