forked from enlightenment/efl
Updates to entry to use selection code.
SVN revision: 49728
This commit is contained in:
parent
593dc6f068
commit
bed3589df5
|
@ -460,13 +460,15 @@ _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
|||
}
|
||||
|
||||
static void
|
||||
_store_selection(Evas_Object *obj)
|
||||
_store_selection(enum _elm_sel_type seltype, Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
const char *sel;
|
||||
|
||||
|
||||
if (!wd) return;
|
||||
sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
|
||||
elm_selection_set(seltype, obj, ELM_SEL_MARKUP, sel);
|
||||
eina_stringshare_replace(&wd->cut_sel, sel);
|
||||
}
|
||||
|
||||
|
@ -475,11 +477,12 @@ _cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
|||
{
|
||||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
|
||||
/* Store it */
|
||||
wd->selmode = EINA_FALSE;
|
||||
edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
|
||||
edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
|
||||
elm_widget_scroll_hold_pop(data);
|
||||
_store_selection(data);
|
||||
_store_selection(ELM_SEL_CLIPBOARD, data);
|
||||
edje_object_part_text_insert(wd->ent, "elm.text", "");
|
||||
edje_object_part_text_select_none(wd->ent, "elm.text");
|
||||
}
|
||||
|
@ -493,8 +496,8 @@ _copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
|||
edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
|
||||
edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
|
||||
elm_widget_scroll_hold_pop(data);
|
||||
_store_selection(data);
|
||||
edje_object_part_text_select_none(wd->ent, "elm.text");
|
||||
_store_selection(ELM_SEL_CLIPBOARD, data);
|
||||
// edje_object_part_text_select_none(wd->ent, "elm.text");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -856,6 +859,7 @@ _mkup_to_text(const char *mkup)
|
|||
return str;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
_text_to_mkup(const char *text)
|
||||
{
|
||||
|
@ -942,23 +946,8 @@ _signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *e
|
|||
if (!wd) return;
|
||||
wd->have_selection = EINA_TRUE;
|
||||
evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
|
||||
if (wd->sel_notify_handler)
|
||||
{
|
||||
char *txt = _mkup_to_text(elm_entry_selection_get(data));
|
||||
|
||||
if (txt)
|
||||
{
|
||||
#ifdef HAVE_ELEMENTARY_X
|
||||
Evas_Object *top;
|
||||
|
||||
top = elm_widget_top_get(data);
|
||||
if ((top) && (elm_win_xwindow_get(top)))
|
||||
ecore_x_selection_primary_set(elm_win_xwindow_get(top), txt,
|
||||
strlen(txt));
|
||||
#endif
|
||||
free(txt);
|
||||
}
|
||||
}
|
||||
elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_MARKUP,
|
||||
elm_entry_selection_get(data));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1034,6 +1023,8 @@ _signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *e
|
|||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
if (!wd) return;
|
||||
evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
|
||||
elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_MARKUP,
|
||||
elm_entry_selection_get(data));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1043,9 +1034,8 @@ _signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *em
|
|||
char *txt;
|
||||
if (!wd) return;
|
||||
evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
|
||||
txt = _mkup_to_text(elm_entry_selection_get(data));
|
||||
eina_stringshare_replace(&wd->cut_sel, txt);
|
||||
if (txt) free(txt);
|
||||
elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_MARKUP,
|
||||
elm_entry_selection_get(data));
|
||||
edje_object_part_text_insert(wd->ent, "elm.text", "");
|
||||
wd->changed = EINA_TRUE;
|
||||
_sizing_eval(data);
|
||||
|
@ -1194,6 +1184,7 @@ _event_selection_notify(void *data, int type __UNUSED__, void *event)
|
|||
Ecore_X_Event_Selection_Notify *ev = event;
|
||||
if (!wd) return 1;
|
||||
if (!wd->selection_asked) return 1;
|
||||
|
||||
if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
|
||||
(ev->selection == ECORE_X_SELECTION_PRIMARY))
|
||||
{
|
||||
|
@ -1223,6 +1214,7 @@ _event_selection_clear(void *data, int type __UNUSED__, void *event)
|
|||
{
|
||||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
Ecore_X_Event_Selection_Clear *ev = event;
|
||||
/*
|
||||
if (!wd) return 1;
|
||||
if (!wd->have_selection) return 1;
|
||||
if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
|
||||
|
@ -1230,7 +1222,7 @@ _event_selection_clear(void *data, int type __UNUSED__, void *event)
|
|||
{
|
||||
elm_entry_select_none(data);
|
||||
}
|
||||
return 1;
|
||||
return 1;*/
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -93,6 +93,21 @@ struct _Elm_Module
|
|||
int references;
|
||||
};
|
||||
|
||||
|
||||
enum _elm_sel_type {
|
||||
ELM_SEL_PRIMARY,
|
||||
ELM_SEL_SECONDARY,
|
||||
ELM_SEL_CLIPBOARD,
|
||||
|
||||
ELM_SEL_MAX,
|
||||
};
|
||||
|
||||
enum _elm_sel_format {
|
||||
ELM_SEL_MARKUP = 0x01,
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define ELM_NEW(t) calloc(1, sizeof(t))
|
||||
|
||||
void _elm_win_shutdown(void);
|
||||
|
@ -187,6 +202,12 @@ void _elm_config_init(void);
|
|||
void _elm_config_sub_init(void);
|
||||
void _elm_config_shutdown(void);
|
||||
|
||||
Eina_Bool elm_selection_set(enum _elm_sel_type selection, Evas_Object *widget, enum _elm_sel_format format, const char *buf);
|
||||
Eina_Bool elm_selection_clear(enum _elm_sel_type selection, Evas_Object *widget);
|
||||
|
||||
|
||||
|
||||
|
||||
#define ELM_SET_WIDTYPE(widtype, type) if (!widtype) widtype = eina_stringshare_add(type)
|
||||
//#define ELM_CHECK_WIDTYPE(obj, widtype) if (elm_widget_type_get(obj) != widtype) return
|
||||
#define ELM_CHECK_WIDTYPE(obj, widtype) if (!_elm_widget_type_check((obj), (widtype))) return
|
||||
|
|
Loading…
Reference in New Issue