1 #include <Elementary.h>
2 #include "elm_module_priv.h"
5 Elm_Entry_Extension_data *ext_mod;
7 typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
8 struct _Elm_Entry_Context_Menu_Item
12 const char *icon_file;
13 const char *icon_group;
14 Elm_Icon_Type icon_type;
20 _ctxpopup_position(Evas_Object *obj)
22 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
23 evas_object_geometry_get(ext_mod->ent, &x, &y, NULL, NULL);
24 edje_object_part_text_cursor_geometry_get(ext_mod->ent, "elm.text",
26 evas_object_size_hint_min_get(ext_mod->popup, &mw, &mh);
37 evas_object_move(ext_mod->popup, x + cx, y + cy);
38 evas_object_resize(ext_mod->popup, cw, ch);
42 _select_all(void *data, Evas_Object *obj, void *event_info)
44 ext_mod->selectall(data,obj,event_info);
45 evas_object_hide(obj);
49 _select(void *data, Evas_Object *obj, void *event_info)
51 ext_mod->select(data,obj,event_info);
52 evas_object_hide(obj);
56 _paste(void *data, Evas_Object *obj, void *event_info)
58 ext_mod->paste(data,obj,event_info);
59 evas_object_hide(obj);
63 _cut(void *data, Evas_Object *obj, void *event_info)
65 ext_mod->cut(data,obj,event_info);
66 evas_object_hide(obj);
67 elm_object_scroll_freeze_pop(ext_mod->popup);
71 _copy(void *data, Evas_Object *obj, void *event_info)
73 ext_mod->copy(data,obj,event_info);
74 evas_object_hide(obj);
75 elm_object_scroll_freeze_pop(ext_mod->popup);
79 _share(void *data, Evas_Object *obj, void *event_info)
82 #ifdef HAVE_ELEMENTARY_X
85 str = elm_entry_markup_to_utf8(elm_entry_selection_get(data));
87 #ifdef HAVE_ELEMENTARY_X
88 atom = ecore_x_atom_get("_TEXT_SHARE_TEST");
91 ecore_x_window_prop_string_set(ecore_x_window_root_first_get(), atom, str);
92 ecore_x_client_message32_send(ecore_x_window_root_first_get(),
93 atom, ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
99 evas_object_hide(obj);
100 elm_ctxpopup_scroller_disabled_set(ext_mod->popup, EINA_FALSE);
104 _cancel(void *data, Evas_Object *obj, void *event_info)
106 ext_mod->cancel(data,obj,event_info);
107 evas_object_hide(obj);
108 elm_object_scroll_freeze_pop(ext_mod->popup);
112 _clipboard_menu(void *data, Evas_Object *obj, void *event_info)
115 #ifdef HAVE_ELEMENTARY_X
116 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
118 ext_mod->cnpinit(data,obj,event_info);
119 elm_cbhm_helper_init(obj);
120 if (ext_mod->textonly)
121 elm_cbhm_send_raw_data("show0");
123 elm_cbhm_send_raw_data("show1");
124 evas_object_hide(obj);
129 _item_clicked(void *data, Evas_Object *obj, void *event_info)
131 Elm_Entry_Context_Menu_Item *it = data;
132 Evas_Object *obj2 = it->obj;
134 if (it->func) it->func(it->data, obj2, NULL);
135 evas_object_hide(obj);
138 // module api funcs needed
140 elm_modapi_init(void *m)
142 return 1; // succeed always
146 elm_modapi_shutdown(void *m)
148 return 1; // succeed always
151 // module fucns for the specific module type
153 obj_hook(Evas_Object *obj)
157 ext_mod = ELM_NEW(Elm_Entry_Extension_data);
158 elm_entry_extension_module_data_get(obj,ext_mod);
163 obj_unhook(Evas_Object *obj)
173 obj_longpress(Evas_Object *obj)
178 const Elm_Entry_Context_Menu_Item *it;
179 const char *context_menu_orientation;
184 elm_entry_extension_module_data_get(obj,ext_mod);
185 if (ext_mod->context_menu)
187 if (ext_mod->popup) evas_object_del(ext_mod->popup);
188 // else elm_widget_scroll_freeze_push(obj);
189 top = elm_widget_top_get(obj);
191 ext_mod->popup = elm_ctxpopup_add(top);
192 /*currently below theme not used,when guideline comes a new theme can be created if required*/
193 elm_object_style_set(ext_mod->popup,"extended/entry");
194 context_menu_orientation = edje_object_data_get
195 (ext_mod->ent, "context_menu_orientation");
196 if ((context_menu_orientation) &&
197 (!strcmp(context_menu_orientation, "horizontal")))
198 elm_ctxpopup_horizontal_set(ext_mod->popup, EINA_TRUE);
200 elm_widget_sub_object_add(obj, ext_mod->popup);
201 if (!ext_mod->selmode)
203 if (!ext_mod->password)
205 if (!elm_entry_is_empty(obj))
207 elm_ctxpopup_item_append(ext_mod->popup, "Select", NULL, _select, obj );
208 elm_ctxpopup_item_append(ext_mod->popup, "Select All", NULL, _select_all, obj );
211 if (1) // need way to detect if someone has a selection
213 if (ext_mod->editable)
214 elm_ctxpopup_item_append(ext_mod->popup, "Paste", NULL, _paste, obj );
217 if ((!ext_mod->password) && (ext_mod->editable))
219 icon = elm_icon_add(ext_mod->popup);
220 snprintf(buf, sizeof(buf), "%s/images/copypaste_icon_clipboard.png", PACKAGE_DATA_DIR);
221 elm_icon_file_set(icon, buf, NULL);
222 elm_ctxpopup_item_append(ext_mod->popup, NULL, icon, _clipboard_menu, obj);
228 if (!ext_mod->password)
230 if (ext_mod->have_selection)
232 elm_ctxpopup_item_append(ext_mod->popup, "Copy", NULL, _copy, obj );
233 if (ext_mod->editable)
234 elm_ctxpopup_item_append(ext_mod->popup, "Cut", NULL, _cut, obj );
235 if (ext_mod->editable)
236 elm_ctxpopup_item_append(ext_mod->popup, "Paste", NULL, _paste, obj );
237 icon = elm_icon_add(ext_mod->popup);
238 snprintf(buf, sizeof(buf), "%s/images/copypaste_icon_share.png", PACKAGE_DATA_DIR);
239 elm_icon_file_set(icon, buf, NULL);
240 elm_ctxpopup_item_append(ext_mod->popup, NULL, icon, _share, obj);
244 _cancel(obj,ext_mod->popup,NULL);
245 if (!elm_entry_is_empty(obj))
247 elm_ctxpopup_item_append(ext_mod->popup, "Select", NULL, _select, obj );
248 elm_ctxpopup_item_append(ext_mod->popup, "Select All", NULL, _select_all, obj );
250 if (1) // need way to detect if someone has a selection
252 if (ext_mod->editable)
253 elm_ctxpopup_item_append(ext_mod->popup, "Paste", NULL, _paste, obj );
257 if (ext_mod->editable)
259 icon = elm_icon_add(ext_mod->popup);
260 snprintf(buf, sizeof(buf), "%s/images/copypaste_icon_clipboard.png", PACKAGE_DATA_DIR);
261 elm_icon_file_set(icon, buf, NULL);
262 elm_ctxpopup_item_append(ext_mod->popup, NULL, icon, _clipboard_menu, obj);
267 EINA_LIST_FOREACH(ext_mod->items, l, it)
269 elm_ctxpopup_item_append(ext_mod->popup, it->label, NULL, _item_clicked, it );
273 elm_object_scroll_freeze_push(ext_mod->popup);
274 _ctxpopup_position(obj);
275 evas_object_show(ext_mod->popup);
278 ext_mod->longpress_timer = NULL;
282 obj_mouseup(Evas_Object *obj)
284 if (!obj || !ext_mod) {
289 elm_entry_extension_module_data_get(obj,ext_mod);
290 if (ext_mod->longpress_timer)
292 if (ext_mod->have_selection )
294 _cancel(obj,ext_mod->popup,NULL);
301 obj_hidemenu(Evas_Object *obj)
303 if (!obj || !ext_mod) {
307 evas_object_hide(ext_mod->popup);
308 // if (ext_mod->popup) evas_object_del(ext_mod->popup);