1 #include <Elementary.h>
2 #include "elm_module_priv.h"
5 Elm_Entry_Extension_data *ext_mod;
6 typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
7 struct _Elm_Entry_Context_Menu_Item
11 const char *icon_file;
12 const char *icon_group;
13 Elm_Icon_Type icon_type;
20 _select(void *data, Evas_Object *obj, void *event_info)
22 ext_mod->select(data,obj,event_info);
23 evas_object_hide(ext_mod->popup);
27 _paste(void *data, Evas_Object *obj, void *event_info)
29 ext_mod->paste(data,obj,event_info);
30 evas_object_hide(ext_mod->popup);
34 _cut(void *data, Evas_Object *obj, void *event_info)
36 ext_mod->cut(data,obj,event_info);
37 evas_object_hide(ext_mod->popup);
41 _copy(void *data, Evas_Object *obj, void *event_info)
43 ext_mod->copy(data,obj,event_info);
44 evas_object_hide(ext_mod->popup);
48 _cancel(void *data, Evas_Object *obj, void *event_info)
50 ext_mod->cancel(data,obj,event_info);
51 evas_object_hide(ext_mod->popup);
55 _clipboard_menu(void *data, Evas_Object *obj, void *event_info)
58 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
59 ext_mod->cnpinit(data,obj,event_info);
60 elm_cbhm_helper_init(obj);
61 elm_cbhm_send_raw_data("show");
62 evas_object_hide(ext_mod->popup);
67 _item_clicked(void *data, Evas_Object *obj, void *event_info)
69 Elm_Entry_Context_Menu_Item *it = data;
70 Evas_Object *obj2 = it->obj;
72 if (it->func) it->func(it->data, obj2, NULL);
73 evas_object_hide(ext_mod->popup);
76 // module api funcs needed
78 elm_modapi_init(void *m)
80 return 1; // succeed always
84 elm_modapi_shutdown(void *m)
86 return 1; // succeed always
89 // module fucns for the specific module type
91 obj_hook(Evas_Object *obj)
95 ext_mod = ELM_NEW(Elm_Entry_Extension_data);
96 elm_entry_extension_module_data_get(obj,ext_mod);
101 obj_unhook(Evas_Object *obj)
111 obj_longpress(Evas_Object *obj)
118 const Elm_Entry_Context_Menu_Item *it;
120 elm_entry_extension_module_data_get(obj,ext_mod);
121 if (ext_mod->context_menu)
123 if (ext_mod->popup) evas_object_del(ext_mod->popup);
124 else elm_widget_scroll_freeze_push(obj);
125 top = elm_widget_top_get(obj);
127 ext_mod->popup = elm_popup_add(top);
128 elm_object_style_set(ext_mod->popup,"menustyle");
129 elm_popup_mode_set(ext_mod->popup, ELM_POPUP_TYPE_ALERT);
130 elm_popup_title_label_set(ext_mod->popup,"CopyPaste");
131 list = elm_list_add(ext_mod->popup);
132 elm_object_style_set(list,"popup");
133 elm_list_mode_set(list, ELM_LIST_COMPRESS);
134 elm_widget_sub_object_add(obj, ext_mod->popup);
135 if (!ext_mod->selmode)
137 if (!ext_mod->password)
138 elm_list_item_append(list, "Select", NULL, NULL,_select, obj);
139 if (1) // need way to detect if someone has a selection
141 if (ext_mod->editable)
142 elm_list_item_append(list, "Paste", NULL, NULL,_paste, obj);
144 // elm_ctxpopup_item_add(wd->ctxpopup, NULL, "Selectall",_select_all, obj );
146 if (!ext_mod->password)
147 elm_list_item_append(list, "More", NULL, NULL,_clipboard_menu, obj);
152 if (!ext_mod->password)
154 if (ext_mod->have_selection)
156 elm_list_item_append(list, "Copy", NULL, NULL,_copy, obj);
157 if (ext_mod->editable)
158 elm_list_item_append(list, "Cut", NULL, NULL,_cut, obj);
162 _cancel(obj,ext_mod->popup,NULL);
163 elm_list_item_append(list, "Select", NULL, NULL,_select, obj);
164 if (1) // need way to detect if someone has a selection
166 if (ext_mod->editable)
167 elm_list_item_append(list, "Paste", NULL, NULL,_paste, obj);
171 elm_list_item_append(list, "More", NULL, NULL,_clipboard_menu, obj);
175 EINA_LIST_FOREACH(ext_mod->items, l, it)
177 elm_list_item_append(list, it->label,NULL,NULL, _item_clicked, it);
182 elm_popup_content_set(ext_mod->popup, list);
183 evas_object_show(ext_mod->popup);
184 evas_render( evas_object_evas_get( ext_mod->popup ) );
187 ext_mod->longpress_timer = NULL;
191 obj_mouseup(Evas_Object *obj)
194 elm_entry_extension_module_data_get(obj,ext_mod);
195 if (ext_mod->longpress_timer)
197 if (ext_mod->have_selection )
199 _cancel(obj,ext_mod->popup,NULL);