summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2009-12-01 11:03:14 +0000
committerCarsten Haitzler <raster@rasterman.com>2009-12-01 11:03:14 +0000
commit28daaf9a4f3351fd1d5e9bc858b30450382e2b8d (patch)
treeda922ba8b09137643a1fa87140223efecaa22c1b
parent8e636da7505658bc11c28b8b4b97e0ba3f50adcb (diff)
use all dem cursor api's... and module it up bro
SVN revision: 44088
-rw-r--r--configure.ac2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/bin/test_win_state.c18
-rw-r--r--src/lib/Elementary.h.in36
-rw-r--r--src/lib/elm_entry.c264
-rw-r--r--src/lib/elm_main.c77
-rw-r--r--src/lib/elm_module.c86
-rw-r--r--src/lib/elm_priv.h6
-rw-r--r--src/lib/elm_theme.c2
-rw-r--r--src/lib/elm_win.c31
-rw-r--r--src/modules/Makefile.am5
-rw-r--r--src/modules/test_entry/Makefile.am31
-rw-r--r--src/modules/test_entry/mod.c33
13 files changed, 522 insertions, 71 deletions
diff --git a/configure.ac b/configure.ac
index 8ccd34bc7..8e08bbcee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -273,6 +273,8 @@ src/Makefile
273src/lib/Makefile 273src/lib/Makefile
274src/lib/Elementary.h 274src/lib/Elementary.h
275src/bin/Makefile 275src/bin/Makefile
276src/modules/Makefile
277src/modules/test_entry/Makefile
276data/Makefile 278data/Makefile
277data/themes/Makefile 279data/themes/Makefile
278data/images/Makefile 280data/images/Makefile
diff --git a/src/Makefile.am b/src/Makefile.am
index 62f6d80e5..6345966f7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
1AUTOMAKE_OPTIONS = 1.4 foreign 1AUTOMAKE_OPTIONS = 1.4 foreign
2MAINTAINERCLEANFILES = Makefile.in 2MAINTAINERCLEANFILES = Makefile.in
3 3
4SUBDIRS = lib bin 4SUBDIRS = lib bin modules
diff --git a/src/bin/test_win_state.c b/src/bin/test_win_state.c
index d1561db22..1ba16edad 100644
--- a/src/bin/test_win_state.c
+++ b/src/bin/test_win_state.c
@@ -56,6 +56,22 @@ my_bt_38_rot_270(void *data, Evas_Object *obj, void *event_info)
56 elm_win_rotation_set(win, 270); 56 elm_win_rotation_set(win, 270);
57} 57}
58 58
59static void
60my_win_move(void *data, Evas_Object *obj, void *event_info)
61{
62 Evas_Coord x, y;
63 elm_win_screen_position_get(obj, &x, &y);
64 printf("MOVE - win geom: %4i %4i\n", x, y);
65}
66
67static void
68_win_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
69{
70 Evas_Coord w, h;
71 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
72 printf("RESIZE - win geom: %4ix%4i\n", w, h);
73}
74
59void 75void
60test_win_state(void *data, Evas_Object *obj, void *event_info) 76test_win_state(void *data, Evas_Object *obj, void *event_info)
61{ 77{
@@ -65,6 +81,8 @@ test_win_state(void *data, Evas_Object *obj, void *event_info)
65 81
66 win = elm_win_add(NULL, "window-state", ELM_WIN_BASIC); 82 win = elm_win_add(NULL, "window-state", ELM_WIN_BASIC);
67 elm_win_title_set(win, "Window States"); 83 elm_win_title_set(win, "Window States");
84 evas_object_smart_callback_add(win, "moved", my_win_move, NULL);
85 evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _win_resize, NULL);
68 elm_win_autodel_set(win, 1); 86 elm_win_autodel_set(win, 1);
69 87
70 bg = elm_bg_add(win); 88 bg = elm_bg_add(win);
diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in
index 231d7d5de..999fe4e8c 100644
--- a/src/lib/Elementary.h.in
+++ b/src/lib/Elementary.h.in
@@ -247,7 +247,9 @@ extern "C" {
247 */ 247 */
248 EAPI void elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode); 248 EAPI void elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode);
249 EAPI void elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard); 249 EAPI void elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard);
250 250
251 EAPI void elm_win_screen_position_get(Evas_Object *obj, int *x, int *y);
252
251 EAPI Evas_Object *elm_win_inwin_add(Evas_Object *obj); 253 EAPI Evas_Object *elm_win_inwin_add(Evas_Object *obj);
252 EAPI void elm_win_inwin_activate(Evas_Object *obj); 254 EAPI void elm_win_inwin_activate(Evas_Object *obj);
253 EINA_DEPRECATED EAPI void elm_win_inwin_style_set(Evas_Object *obj, const char *style); 255 EINA_DEPRECATED EAPI void elm_win_inwin_style_set(Evas_Object *obj, const char *style);
@@ -264,6 +266,7 @@ extern "C" {
264 * "delete,request" - the user requested to delete the window 266 * "delete,request" - the user requested to delete the window
265 * "focus,on" - window got focus 267 * "focus,on" - window got focus
266 * "focus,out" - window lost focus 268 * "focus,out" - window lost focus
269 * "moved" - window that holds the canvas was moved
267 */ 270 */
268 271
269 EAPI Evas_Object *elm_bg_add(Evas_Object *parent); 272 EAPI Evas_Object *elm_bg_add(Evas_Object *parent);
@@ -498,17 +501,22 @@ extern "C" {
498 EAPI void elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable); 501 EAPI void elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable);
499 EAPI void elm_entry_select_none(Evas_Object *obj); 502 EAPI void elm_entry_select_none(Evas_Object *obj);
500 EAPI void elm_entry_select_all(Evas_Object *obj); 503 EAPI void elm_entry_select_all(Evas_Object *obj);
501#if 0 504 EAPI Eina_Bool elm_entry_cursor_next(Evas_Object *obj);
502 //next char (char # -= 1) 505 EAPI Eina_Bool elm_entry_cursor_prev(Evas_Object *obj);
503 //prev char (char # += 1) 506 EAPI Eina_Bool elm_entry_cursor_up(Evas_Object *obj);
504 //get cur char pos (char #) 507 EAPI Eina_Bool elm_entry_cursor_down(Evas_Object *obj);
505 //set cur char pos (char #) 508 EAPI void elm_entry_cursor_begin_set(Evas_Object *obj);
506 //get char len (# of chars) 509 EAPI void elm_entry_cursor_end_set(Evas_Object *obj);
507 //get cur char (utf8) 510 EAPI void elm_entry_cursor_line_begin_set(Evas_Object *obj);
508 //get text from char pos 1 to char pos 2 (inclusive) 511 EAPI void elm_entry_cursor_line_end_set(Evas_Object *obj);
509 //sel text from char pos 1 to char pos 2 (inclusive) 512 EAPI void elm_entry_cursor_selection_begin(Evas_Object *obj);
510 //clean sel (already have with select_abort) 513 EAPI void elm_entry_cursor_selection_end(Evas_Object *obj);
511#endif 514 EAPI Eina_Bool elm_entry_cursor_is_format_get(Evas_Object *obj);
515 EAPI Eina_Bool elm_entry_cursor_is_visible_format_get(Evas_Object *obj);
516 EAPI const char *elm_entry_cursor_content_get(Evas_Object *obj);
517 EAPI void elm_entry_selection_cut(Evas_Object *obj);
518 EAPI void elm_entry_selection_copy(Evas_Object *obj);
519 EAPI void elm_entry_selection_paste(Evas_Object *obj);
512 EAPI void elm_entry_context_menu_clear(Evas_Object *obj); 520 EAPI void elm_entry_context_menu_clear(Evas_Object *obj);
513 EAPI void elm_entry_context_menu_item_add(Evas_Object *obj, const char *label, const char *icon_file, Elm_Icon_Type icon_type, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data); 521 EAPI void elm_entry_context_menu_item_add(Evas_Object *obj, const char *label, const char *icon_file, Elm_Icon_Type icon_type, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data);
514 EAPI void elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled); 522 EAPI void elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled);
@@ -527,6 +535,10 @@ extern "C" {
527 * "cursor,changed" - the cursor changed position 535 * "cursor,changed" - the cursor changed position
528 * "anchor,clicked" - achor called was clicked | event_info = Elm_Entry_Anchor_Info 536 * "anchor,clicked" - achor called was clicked | event_info = Elm_Entry_Anchor_Info
529 * "activated" - when the enter key is pressed (useful for single line) 537 * "activated" - when the enter key is pressed (useful for single line)
538 * "press" - when finger/mouse is pressed down
539 * "clicked" - when finger/mouse is pressed and released (without a drag etc.)
540 * "clicked,double" - when finger/mouse is double-pressed
541 * "longpressed" - the entry has been longpressed
530 */ 542 */
531 543
532 /* composite widgets - these basically put together basic widgets above 544 /* composite widgets - these basically put together basic widgets above
diff --git a/src/lib/elm_entry.c b/src/lib/elm_entry.c
index ca0c5e0f9..5e6d9cf31 100644
--- a/src/lib/elm_entry.c
+++ b/src/lib/elm_entry.c
@@ -1,6 +1,8 @@
1#include <Elementary.h> 1#include <Elementary.h>
2#include "elm_priv.h" 2#include "elm_priv.h"
3 3
4typedef struct _Mod_Api Mod_Api;
5
4typedef struct _Widget_Data Widget_Data; 6typedef struct _Widget_Data Widget_Data;
5typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item; 7typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
6 8
@@ -18,6 +20,7 @@ struct _Widget_Data
18 Evas_Coord downx, downy; 20 Evas_Coord downx, downy;
19 Evas_Coord cx, cy, cw, ch; 21 Evas_Coord cx, cy, cw, ch;
20 Eina_List *items; 22 Eina_List *items;
23 Mod_Api *api; // module api if supplied
21 Eina_Bool changed : 1; 24 Eina_Bool changed : 1;
22 Eina_Bool linewrap : 1; 25 Eina_Bool linewrap : 1;
23 Eina_Bool char_linewrap : 1; 26 Eina_Bool char_linewrap : 1;
@@ -61,6 +64,32 @@ static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emi
61 64
62static Eina_List *entries = NULL; 65static Eina_List *entries = NULL;
63 66
67struct _Mod_Api
68{
69 void (*obj_hook) (Evas_Object *obj);
70 void (*obj_unhook) (Evas_Object *obj);
71 void (*obj_longpress) (Evas_Object *obj);
72};
73
74static Mod_Api *
75_module(Evas_Object *obj)
76{
77 static Elm_Module *m = NULL;
78 if (m) goto ok; // already found - just use
79 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
80 // get module api
81 m->api = malloc(sizeof(Mod_Api));
82 if (!m->api) return NULL;
83 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
84 _elm_module_symbol_get(m, "obj_hook");
85 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
86 _elm_module_symbol_get(m, "obj_unhook");
87 ((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
88 _elm_module_symbol_get(m, "obj_longpress");
89 ok: // ok - return api
90 return m->api;
91}
92
64static void 93static void
65_del_hook(Evas_Object *obj) 94_del_hook(Evas_Object *obj)
66{ 95{
@@ -68,6 +97,8 @@ _del_hook(Evas_Object *obj)
68 Eina_List *l; 97 Eina_List *l;
69 Elm_Entry_Context_Menu_Item *it; 98 Elm_Entry_Context_Menu_Item *it;
70 99
100 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
101
71 entries = eina_list_remove(entries, obj); 102 entries = eina_list_remove(entries, obj);
72#ifdef HAVE_ELEMENTARY_X 103#ifdef HAVE_ELEMENTARY_X
73 ecore_event_handler_del(wd->sel_notify_handler); 104 ecore_event_handler_del(wd->sel_notify_handler);
@@ -344,47 +375,55 @@ _long_press(void *data)
344 const Eina_List *l; 375 const Eina_List *l;
345 const Elm_Entry_Context_Menu_Item *it; 376 const Elm_Entry_Context_Menu_Item *it;
346 377
347 if (wd->hoversel) evas_object_del(wd->hoversel); 378 if ((wd->api) && (wd->api->obj_longpress))
348 else elm_widget_scroll_freeze_push(data);
349 wd->hoversel = elm_hoversel_add(data);
350 elm_object_style_set(wd->hoversel, "entry");
351 elm_widget_sub_object_add(data, wd->hoversel);
352 elm_hoversel_label_set(wd->hoversel, "Text");
353 top = elm_widget_top_get(data);
354 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
355 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, data);
356 if (!wd->selmode)
357 { 379 {
358 elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE, 380 wd->api->obj_longpress(data);
359 _select, data);
360 if (wd->editable)
361 elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE,
362 _paste, data);
363 } 381 }
364 else 382 else
365 { 383 {
366 elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE, 384 if (wd->hoversel) evas_object_del(wd->hoversel);
367 _copy, data); 385 else elm_widget_scroll_freeze_push(data);
368 if (wd->editable) 386 wd->hoversel = elm_hoversel_add(data);
369 elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE, 387 elm_object_style_set(wd->hoversel, "entry");
370 _cut, data); 388 elm_widget_sub_object_add(data, wd->hoversel);
371 elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE, 389 elm_hoversel_label_set(wd->hoversel, "Text");
372 _cancel, data); 390 top = elm_widget_top_get(data);
373 } 391 if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
374 EINA_LIST_FOREACH(wd->items, l, it) 392 evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, data);
375 { 393 if (!wd->selmode)
376 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file, 394 {
377 it->icon_type, _item_clicked, it); 395 elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE,
378 } 396 _select, data);
379 if (wd->hoversel) 397 if (wd->editable)
380 { 398 elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE,
381 _hoversel_position(data); 399 _paste, data);
382 evas_object_show(wd->hoversel); 400 }
383 elm_hoversel_hover_begin(wd->hoversel); 401 else
402 {
403 elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE,
404 _copy, data);
405 if (wd->editable)
406 elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE,
407 _cut, data);
408 elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE,
409 _cancel, data);
410 }
411 EINA_LIST_FOREACH(wd->items, l, it)
412 {
413 elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
414 it->icon_type, _item_clicked, it);
415 }
416 if (wd->hoversel)
417 {
418 _hoversel_position(data);
419 evas_object_show(wd->hoversel);
420 elm_hoversel_hover_begin(wd->hoversel);
421 }
384 } 422 }
385 wd->longpress_timer = NULL; 423 wd->longpress_timer = NULL;
386 edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0); 424 edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
387 edje_object_part_text_select_abort(wd->ent, "elm.text"); 425 edje_object_part_text_select_abort(wd->ent, "elm.text");
426 evas_object_smart_callback_call(data, "longpressed", NULL);
388 return 0; 427 return 0;
389} 428}
390 429
@@ -954,10 +993,30 @@ static void
954_signal_key_enter(void *data, Evas_Object *obj, const char *emission, const char *source) 993_signal_key_enter(void *data, Evas_Object *obj, const char *emission, const char *source)
955{ 994{
956 Widget_Data *wd = elm_widget_data_get(data); 995 Widget_Data *wd = elm_widget_data_get(data);
957
958 evas_object_smart_callback_call(data, "activated", NULL); 996 evas_object_smart_callback_call(data, "activated", NULL);
959} 997}
960 998
999static void
1000_signal_mouse_down(void *data, Evas_Object *obj, const char *emission, const char *source)
1001{
1002 Widget_Data *wd = elm_widget_data_get(data);
1003 evas_object_smart_callback_call(data, "press", NULL);
1004}
1005
1006static void
1007_signal_mouse_up(void *data, Evas_Object *obj, const char *emission, const char *source)
1008{
1009 Widget_Data *wd = elm_widget_data_get(data);
1010 evas_object_smart_callback_call(data, "clicked", NULL);
1011}
1012
1013static void
1014_signal_mouse_double(void *data, Evas_Object *obj, const char *emission, const char *source)
1015{
1016 Widget_Data *wd = elm_widget_data_get(data);
1017 evas_object_smart_callback_call(data, "clicked,double", NULL);
1018}
1019
961#ifdef HAVE_ELEMENTARY_X 1020#ifdef HAVE_ELEMENTARY_X
962static int 1021static int
963_event_selection_notify(void *data, int type, void *event) 1022_event_selection_notify(void *data, int type, void *event)
@@ -1070,6 +1129,12 @@ elm_entry_add(Evas_Object *parent)
1070 _signal_anchor_out, obj); 1129 _signal_anchor_out, obj);
1071 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text", 1130 edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
1072 _signal_key_enter, obj); 1131 _signal_key_enter, obj);
1132 edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
1133 _signal_mouse_down, obj);
1134 edje_object_signal_callback_add(wd->ent, "mouse,up,1", "elm.text",
1135 _signal_mouse_up, obj);
1136 edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
1137 _signal_mouse_double, obj);
1073 edje_object_part_text_set(wd->ent, "elm.text", "<br>"); 1138 edje_object_part_text_set(wd->ent, "elm.text", "<br>");
1074 elm_widget_resize_object_set(obj, wd->ent); 1139 elm_widget_resize_object_set(obj, wd->ent);
1075 _sizing_eval(obj); 1140 _sizing_eval(obj);
@@ -1088,6 +1153,12 @@ elm_entry_add(Evas_Object *parent)
1088#endif 1153#endif
1089 1154
1090 entries = eina_list_prepend(entries, obj); 1155 entries = eina_list_prepend(entries, obj);
1156
1157 // module - find module for entry
1158 wd->api = _module(obj);
1159 // if found - hook in
1160 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
1161
1091 return obj; 1162 return obj;
1092} 1163}
1093 1164
@@ -1133,17 +1204,6 @@ elm_entry_entry_set(Evas_Object *obj, const char *entry)
1133 1204
1134 if (!entry) entry = "<br>"; 1205 if (!entry) entry = "<br>";
1135 edje_object_part_text_set(wd->ent, "elm.text", entry); 1206 edje_object_part_text_set(wd->ent, "elm.text", entry);
1136 // debug
1137#if 0
1138 {
1139 const Eina_List *l, *an;
1140 const char *anchor;
1141
1142 an = edje_object_part_text_anchor_list_get(wd->ent, "elm.text");
1143 EINA_LIST_FOREACH(an, l, anchor)
1144 printf("ANCHOR: %s\n", anchor);
1145 }
1146#endif
1147 wd->changed = EINA_TRUE; 1207 wd->changed = EINA_TRUE;
1148 _sizing_eval(obj); 1208 _sizing_eval(obj);
1149} 1209}
@@ -1263,6 +1323,120 @@ elm_entry_select_all(Evas_Object *obj)
1263 edje_object_part_text_select_all(wd->ent, "elm.text"); 1323 edje_object_part_text_select_all(wd->ent, "elm.text");
1264} 1324}
1265 1325
1326EAPI Eina_Bool
1327elm_entry_cursor_next(Evas_Object *obj)
1328{
1329 Widget_Data *wd = elm_widget_data_get(obj);
1330 return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1331}
1332
1333EAPI Eina_Bool
1334elm_entry_cursor_prev(Evas_Object *obj)
1335{
1336 Widget_Data *wd = elm_widget_data_get(obj);
1337 return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1338}
1339
1340EAPI Eina_Bool
1341elm_entry_cursor_up(Evas_Object *obj)
1342{
1343 Widget_Data *wd = elm_widget_data_get(obj);
1344 return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1345}
1346
1347EAPI Eina_Bool
1348elm_entry_cursor_down(Evas_Object *obj)
1349{
1350 Widget_Data *wd = elm_widget_data_get(obj);
1351 return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1352}
1353
1354EAPI void
1355elm_entry_cursor_begin_set(Evas_Object *obj)
1356{
1357 Widget_Data *wd = elm_widget_data_get(obj);
1358 edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1359}
1360
1361EAPI void
1362elm_entry_cursor_end_set(Evas_Object *obj)
1363{
1364 Widget_Data *wd = elm_widget_data_get(obj);
1365 edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1366}
1367
1368EAPI void
1369elm_entry_cursor_line_begin_set(Evas_Object *obj)
1370{
1371 Widget_Data *wd = elm_widget_data_get(obj);
1372 edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1373}
1374
1375EAPI void
1376elm_entry_cursor_line_end_set(Evas_Object *obj)
1377{
1378 Widget_Data *wd = elm_widget_data_get(obj);
1379 edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1380}
1381
1382EAPI void
1383elm_entry_cursor_selection_begin(Evas_Object *obj)
1384{
1385 Widget_Data *wd = elm_widget_data_get(obj);
1386 edje_object_part_text_select_all(wd->ent, "elm.text");
1387 edje_object_part_text_cursor_copy(wd->ent, "elm.text", EDJE_CURSOR_MAIN, EDJE_CURSOR_SELECTION_BEGIN);
1388 edje_object_part_text_cursor_copy(wd->ent, "elm.text", EDJE_CURSOR_MAIN, EDJE_CURSOR_SELECTION_END);
1389}
1390
1391EAPI void
1392elm_entry_cursor_selection_end(Evas_Object *obj)
1393{
1394 Widget_Data *wd = elm_widget_data_get(obj);
1395 edje_object_part_text_cursor_copy(wd->ent, "elm.text", EDJE_CURSOR_MAIN, EDJE_CURSOR_SELECTION_END);
1396}
1397
1398EAPI Eina_Bool
1399elm_entry_cursor_is_format_get(Evas_Object *obj)
1400{
1401 Widget_Data *wd = elm_widget_data_get(obj);
1402 return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1403}
1404
1405EAPI Eina_Bool
1406elm_entry_cursor_is_visible_format_get(Evas_Object *obj)
1407{
1408 Widget_Data *wd = elm_widget_data_get(obj);
1409 return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1410}
1411
1412EAPI const char *
1413elm_entry_cursor_content_get(Evas_Object *obj)
1414{
1415 Widget_Data *wd = elm_widget_data_get(obj);
1416 return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
1417}
1418
1419EAPI void
1420elm_entry_selection_cut(Evas_Object *obj)
1421{
1422 Widget_Data *wd = elm_widget_data_get(obj);
1423 _cut(obj, NULL, NULL);
1424}
1425
1426EAPI void
1427elm_entry_selection_copy(Evas_Object *obj)
1428{
1429 Widget_Data *wd = elm_widget_data_get(obj);
1430 _copy(obj, NULL, NULL);
1431}
1432
1433EAPI void
1434elm_entry_selection_paste(Evas_Object *obj)
1435{
1436 Widget_Data *wd = elm_widget_data_get(obj);
1437 _paste(obj, NULL, NULL);
1438}
1439
1266EAPI void 1440EAPI void
1267elm_entry_context_menu_clear(Evas_Object *obj) 1441elm_entry_context_menu_clear(Evas_Object *obj)
1268{ 1442{
diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c
index de8a9eec8..c6efb2af6 100644
--- a/src/lib/elm_main.c
+++ b/src/lib/elm_main.c
@@ -271,6 +271,8 @@ static Ecore_Event_Handler *_elm_exit_handler = NULL;
271static Ecore_Event_Handler *_elm_event_property_change = NULL; 271static Ecore_Event_Handler *_elm_event_property_change = NULL;
272#ifdef HAVE_ELEMENTARY_X 272#ifdef HAVE_ELEMENTARY_X
273static Ecore_X_Atom _elm_atom_enlightenment_scale = 0; 273static Ecore_X_Atom _elm_atom_enlightenment_scale = 0;
274static Ecore_X_Atom _elm_atom_enlightenment_finger_size = 0;
275static Ecore_X_Atom _elm_atom_enlightenment_theme = 0;
274#endif 276#endif
275 277
276static int 278static int
@@ -303,6 +305,34 @@ _elm_window_property_change(void *data, int ev_type, void *ev)
303 if (pscale != _elm_config->scale) _elm_rescale(); 305 if (pscale != _elm_config->scale) _elm_rescale();
304 } 306 }
305 } 307 }
308 else if (event->atom == _elm_atom_enlightenment_finger_size)
309 {
310 int val = 1000;
311
312 if (ecore_x_window_prop_card32_get(event->win,
313 event->atom,
314 &val, 1) > 0)
315 {
316 int pfinger_size;
317
318 pfinger_size = _elm_config->finger_size;
319 _elm_config->finger_size = val;
320 if (pfinger_size != _elm_config->finger_size) _elm_rescale();
321 }
322 }
323 else if (event->atom == _elm_atom_enlightenment_theme)
324 {
325 char *val = NULL;
326
327 val = ecore_x_window_prop_string_get(event->win,
328 event->atom);
329 if (val)
330 {
331 _elm_theme_parse(val);
332 free(val);
333 _elm_rescale();
334 }
335 }
306 } 336 }
307 return 1; 337 return 1;
308} 338}
@@ -518,7 +548,8 @@ elm_quicklaunch_init(int argc, char **argv)
518 if (!_elm_lib_dir) 548 if (!_elm_lib_dir)
519 _elm_lib_dir = eina_stringshare_add("/"); 549 _elm_lib_dir = eina_stringshare_add("/");
520 550
521 // FIXME: actually load config 551 // FIXME: actually load config from file - use eet. also for X properties,
552 // reduce to single x property with eet data encoded in it.
522 _elm_config = ELM_NEW(Elm_Config); 553 _elm_config = ELM_NEW(Elm_Config);
523 _elm_config->engine = ELM_SOFTWARE_X11; 554 _elm_config->engine = ELM_SOFTWARE_X11;
524 _elm_config->thumbscroll_enable = 1; 555 _elm_config->thumbscroll_enable = 1;
@@ -598,15 +629,12 @@ elm_quicklaunch_init(int argc, char **argv)
598 else _elm_theme_parse("default"); 629 else _elm_theme_parse("default");
599 630
600 _elm_config->font_hinting = 2; 631 _elm_config->font_hinting = 2;
601 s= getenv("ELM_FONT_HINTING"); 632 s = getenv("ELM_FONT_HINTING");
602 if (s) 633 if (s)
603 { 634 {
604 if (!strcasecmp(s, "none")) 635 if (!strcasecmp(s, "none")) _elm_config->font_hinting = 0;
605 _elm_config->font_hinting = 0; 636 else if (!strcasecmp(s, "auto")) _elm_config->font_hinting = 1;
606 else if (!strcasecmp(s, "auto")) 637 else if (!strcasecmp(s, "bytecode")) _elm_config->font_hinting = 2;
607 _elm_config->font_hinting = 1;
608 else if (!strcasecmp(s, "bytecode"))
609 _elm_config->font_hinting = 2;
610 } 638 }
611 639
612 s = getenv("ELM_FONT_PATH"); 640 s = getenv("ELM_FONT_PATH");
@@ -663,6 +691,9 @@ elm_quicklaunch_init(int argc, char **argv)
663 ecore_animator_frametime_set(1.0 / _elm_config->fps); 691 ecore_animator_frametime_set(1.0 / _elm_config->fps);
664 edje_frametime_set(1.0 / 60.0); 692 edje_frametime_set(1.0 / 60.0);
665 edje_scale_set(_elm_config->scale); 693 edje_scale_set(_elm_config->scale);
694
695 s = getenv("ELM_MODULES");
696 if (s) _elm_module_parse(s);
666} 697}
667 698
668EAPI void 699EAPI void
@@ -684,7 +715,11 @@ elm_quicklaunch_sub_init(int argc, char **argv)
684 } 715 }
685 if (!ecore_x_screen_is_composited(0)) 716 if (!ecore_x_screen_is_composited(0))
686 _elm_config->compositing = 0; 717 _elm_config->compositing = 0;
687 _elm_atom_enlightenment_scale = ecore_x_atom_get("ENLIGHTENMENT_SCALE"); 718
719 _elm_atom_enlightenment_scale = ecore_x_atom_get("ENLIGHTENMENT_SCALE");
720 _elm_atom_enlightenment_finger_size = ecore_x_atom_get("ENLIGHTENMENT_FINGER_SIZE");
721 _elm_atom_enlightenment_theme = ecore_x_atom_get("ENLIGHTENMENT_THEME");
722
688 ecore_x_event_mask_set(ecore_x_window_root_first_get(), 723 ecore_x_event_mask_set(ecore_x_window_root_first_get(),
689 ECORE_X_EVENT_MASK_WINDOW_PROPERTY); 724 ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
690 _elm_event_property_change = ecore_event_handler_add 725 _elm_event_property_change = ecore_event_handler_add
@@ -704,6 +739,30 @@ elm_quicklaunch_sub_init(int argc, char **argv)
704 } 739 }
705 } 740 }
706 } 741 }
742 if (!getenv("ELM_FINGER_SIZE"))
743 {
744 if (ecore_x_window_prop_card32_get(ecore_x_window_root_first_get(),
745 _elm_atom_enlightenment_finger_size,
746 &val, 1) > 0)
747 {
748 if (val > 0)
749 {
750 _elm_config->finger_size = val;
751 }
752 }
753 }
754 if (!getenv("ELM_THEME"))
755 {
756 char *s;
757
758 s = ecore_x_window_prop_string_get(ecore_x_window_root_first_get(),
759 _elm_atom_enlightenment_theme);
760 if (s)
761 {
762 _elm_theme_parse(s);
763 free(s);
764 }
765 }
707#endif 766#endif
708 } 767 }
709} 768}
diff --git a/src/lib/elm_module.c b/src/lib/elm_module.c
index c5abbe0e5..5760542f1 100644
--- a/src/lib/elm_module.c
+++ b/src/lib/elm_module.c
@@ -1,6 +1,30 @@
1#include <Elementary.h> 1#include <Elementary.h>
2#include "elm_priv.h" 2#include "elm_priv.h"
3 3
4/* what are moodules in elementary for? for modularising behavior and features
5 * so they can be plugged in and out where you dont want the core source to
6 * alwyas behave like that or do it that way. plug it at runtime!
7 *
8 * they have module names (in config) and "slots" to plug that module into
9 * to server a purpose. eg you plug plugin "xx" into the "entry-copy-paste"
10 * slot so it would provide replacement copy & paste ui functionality and
11 * specific symbols
12 *
13 * config is something like:
14 *
15 * export ELM_MODULES="xx>slot1:yy>slot2"
16 *
17 * where a module named xx is plugged into slot1 & yy is plugged into slot2
18 *
19 * real examples:
20 *
21 * export ELM_MODULES="my_module>entry/api"
22 *
23 * this loads the module called "my_module" into the slot "entry/api" which
24 * is an api slot for entry modules to modify behavior and hook to
25 * creation/deletion of the entry as well as replace the longpress behavior.
26 */
27
4#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
5# define _GNU_SOURCE 29# define _GNU_SOURCE
6#endif 30#endif
@@ -12,11 +36,13 @@
12#include <dlfcn.h> /* dlopen,dlclose,etc */ 36#include <dlfcn.h> /* dlopen,dlclose,etc */
13 37
14static Eina_Hash *modules = NULL; 38static Eina_Hash *modules = NULL;
39static Eina_Hash *modules_as = NULL;
15 40
16void 41void
17_elm_module_init(void) 42_elm_module_init(void)
18{ 43{
19 modules = eina_hash_string_small_new(NULL); 44 modules = eina_hash_string_small_new(NULL);
45 modules_as = eina_hash_string_small_new(NULL);
20} 46}
21 47
22void 48void
@@ -25,10 +51,61 @@ _elm_module_shutdown(void)
25 // FIXME: unload all modules 51 // FIXME: unload all modules
26 eina_hash_free(modules); 52 eina_hash_free(modules);
27 modules = NULL; 53 modules = NULL;
54 eina_hash_free(modules_as);
55 modules_as = NULL;
56}
57
58void
59_elm_module_parse(const char *s)
60{
61 Eina_List *names = NULL;
62 const char *p, *pe;
63
64 p = s;
65 pe = p;
66 for (;;)
67 {
68 if ((*pe == ':') || (*pe == 0))
69 { // p -> pe == 'name:'
70 if (pe > p)
71 {
72 char *n = malloc(pe - p + 1);
73 if (n)
74 {
75 char *nn;
76
77 strncpy(n, p, pe - p);
78 n[pe - p] = 0;
79 nn = strchr(n, '>');
80 if (nn)
81 {
82 *nn = 0;
83 nn++;
84 _elm_module_add(n, nn);
85 }
86 free(n);
87 }
88 }
89 if (*pe == 0) break;
90 p = pe + 1;
91 pe = p;
92 }
93 else
94 pe++;
95 }
96}
97
98Elm_Module *
99_elm_module_find_as(const char *as)
100{
101 Elm_Module *m;
102
103 m = eina_hash_find(modules_as, as);
104 return m;
28} 105}
29 106
30Elm_Module * 107Elm_Module *
31_elm_module_add(const char *name) 108_elm_module_add(const char *name, const char *as)
32{ 109{
33 Elm_Module *m; 110 Elm_Module *m;
34 char buf[PATH_MAX]; 111 char buf[PATH_MAX];
@@ -114,6 +191,8 @@ _elm_module_add(const char *name)
114 } 191 }
115 m->references = 1; 192 m->references = 1;
116 eina_hash_direct_add(modules, m->name, m); 193 eina_hash_direct_add(modules, m->name, m);
194 m->as = eina_stringshare_add(as);
195 eina_hash_direct_add(modules_as, m->as, m);
117 return m; 196 return m;
118} 197}
119 198
@@ -124,11 +203,14 @@ _elm_module_del(Elm_Module *m)
124 if (m->references > 0) return; 203 if (m->references > 0) return;
125 if (m->shutdown_func) m->shutdown_func(m); 204 if (m->shutdown_func) m->shutdown_func(m);
126 eina_hash_del(modules, m->name, m); 205 eina_hash_del(modules, m->name, m);
127 dlclose(m->handle); 206 eina_hash_del(modules_as, m->as, m);
207 if (m->api) free(m->api);
128 eina_stringshare_del(m->name); 208 eina_stringshare_del(m->name);
209 eina_stringshare_del(m->as);
129 eina_stringshare_del(m->so_path); 210 eina_stringshare_del(m->so_path);
130 eina_stringshare_del(m->data_dir); 211 eina_stringshare_del(m->data_dir);
131 eina_stringshare_del(m->bin_dir); 212 eina_stringshare_del(m->bin_dir);
213 dlclose(m->handle);
132 free(m); 214 free(m);
133} 215}
134 216
diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h
index 58291727a..b0cfd9548 100644
--- a/src/lib/elm_priv.h
+++ b/src/lib/elm_priv.h
@@ -65,11 +65,13 @@ struct _Elm_Module
65{ 65{
66 int version; 66 int version;
67 const char *name; 67 const char *name;
68 const char *as;
68 const char *so_path; 69 const char *so_path;
69 const char *data_dir; 70 const char *data_dir;
70 const char *bin_dir; 71 const char *bin_dir;
71 void *handle; 72 void *handle;
72 void *data; 73 void *data;
74 void *api;
73 int (*init_func) (Elm_Module *m); 75 int (*init_func) (Elm_Module *m);
74 int (*shutdown_func) (Elm_Module *m); 76 int (*shutdown_func) (Elm_Module *m);
75 int references; 77 int references;
@@ -86,7 +88,9 @@ int _elm_theme_parse(const char *theme);
86 88
87void _elm_module_init(void); 89void _elm_module_init(void);
88void _elm_module_shutdown(void); 90void _elm_module_shutdown(void);
89Elm_Module *_elm_module_add(const char *name); 91void _elm_module_parse(const char *s);
92Elm_Module *_elm_module_find_as(const char *as);
93Elm_Module *_elm_module_add(const char *name, const char *as);
90void _elm_module_del(Elm_Module *m); 94void _elm_module_del(Elm_Module *m);
91const void *_elm_module_symbol_get(Elm_Module *m, const char *name); 95const void *_elm_module_symbol_get(Elm_Module *m, const char *name);
92 96
diff --git a/src/lib/elm_theme.c b/src/lib/elm_theme.c
index 837df70bf..26ee3e1e9 100644
--- a/src/lib/elm_theme.c
+++ b/src/lib/elm_theme.c
@@ -195,7 +195,7 @@ _elm_theme_parse(const char *theme)
195 for (;;) 195 for (;;)
196 { 196 {
197 if ((*pe == ':') || (*pe == 0)) 197 if ((*pe == ':') || (*pe == 0))
198 { // p -> pe == 'name/' 198 { // p -> pe == 'name:'
199 if (pe > p) 199 if (pe > p)
200 { 200 {
201 char *n = malloc(pe - p + 1); 201 char *n = malloc(pe - p + 1);
diff --git a/src/lib/elm_win.c b/src/lib/elm_win.c
index 66cb21747..d1a62c3df 100644
--- a/src/lib/elm_win.c
+++ b/src/lib/elm_win.c
@@ -17,10 +17,14 @@ struct _Elm_Win
17 Elm_Win_Keyboard_Mode kbdmode; 17 Elm_Win_Keyboard_Mode kbdmode;
18 Eina_Bool autodel : 1; 18 Eina_Bool autodel : 1;
19 int *autodel_clear, rot; 19 int *autodel_clear, rot;
20 struct {
21 int x, y;
22 } screen;
20}; 23};
21 24
22static void _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info); 25static void _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
23static void _elm_win_obj_intercept_show(void *data, Evas_Object *obj); 26static void _elm_win_obj_intercept_show(void *data, Evas_Object *obj);
27static void _elm_win_move(Ecore_Evas *ee);
24static void _elm_win_resize(Ecore_Evas *ee); 28static void _elm_win_resize(Ecore_Evas *ee);
25static void _elm_win_delete_request(Ecore_Evas *ee); 29static void _elm_win_delete_request(Ecore_Evas *ee);
26static void _elm_win_resize_job(void *data); 30static void _elm_win_resize_job(void *data);
@@ -34,6 +38,21 @@ static void _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e, Eva
34static Eina_List *_elm_win_list = NULL; 38static Eina_List *_elm_win_list = NULL;
35 39
36static void 40static void
41_elm_win_move(Ecore_Evas *ee)
42{
43 Evas_Object *obj = ecore_evas_object_associate_get(ee);
44 Elm_Win *win;
45 int x, y;
46 if (strcmp(elm_widget_type_get(obj), "win")) return;
47 win = elm_widget_data_get(obj);
48 if (!win) return;
49 ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
50 win->screen.x = x;
51 win->screen.y = y;
52 evas_object_smart_callback_call(win->win_obj, "moved", NULL);
53}
54
55static void
37_elm_win_resize(Ecore_Evas *ee) 56_elm_win_resize(Ecore_Evas *ee)
38{ 57{
39 Evas_Object *obj = ecore_evas_object_associate_get(ee); 58 Evas_Object *obj = ecore_evas_object_associate_get(ee);
@@ -387,6 +406,7 @@ elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
387 ecore_evas_callback_resize_set(win->ee, _elm_win_resize); 406 ecore_evas_callback_resize_set(win->ee, _elm_win_resize);
388 ecore_evas_callback_focus_in_set(win->ee, _elm_win_focus_in); 407 ecore_evas_callback_focus_in_set(win->ee, _elm_win_focus_in);
389 ecore_evas_callback_focus_out_set(win->ee, _elm_win_focus_out); 408 ecore_evas_callback_focus_out_set(win->ee, _elm_win_focus_out);
409 ecore_evas_callback_move_set(win->ee, _elm_win_move);
390 evas_image_cache_set(win->evas, (_elm_config->image_cache * 1024)); 410 evas_image_cache_set(win->evas, (_elm_config->image_cache * 1024));
391 evas_font_cache_set(win->evas, (_elm_config->font_cache * 1024)); 411 evas_font_cache_set(win->evas, (_elm_config->font_cache * 1024));
392 EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath) 412 EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
@@ -788,6 +808,17 @@ elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard)
788#endif 808#endif
789} 809}
790 810
811EAPI void
812elm_win_screen_position_get(Evas_Object *obj, int *x, int *y)
813{
814 Elm_Win *win;
815 if (strcmp(elm_widget_type_get(obj), "win")) return;
816 win = elm_widget_data_get(obj);
817 if (!win) return;
818 if (x) *x = win->screen.x;
819 if (y) *y = win->screen.y;
820}
821
791typedef struct _Widget_Data Widget_Data; 822typedef struct _Widget_Data Widget_Data;
792 823
793struct _Widget_Data 824struct _Widget_Data
diff --git a/src/modules/Makefile.am b/src/modules/Makefile.am
new file mode 100644
index 000000000..d48924515
--- /dev/null
+++ b/src/modules/Makefile.am
@@ -0,0 +1,5 @@
1AUTOMAKE_OPTIONS = 1.4 foreign
2MAINTAINERCLEANFILES = Makefile.in
3
4SUBDIRS = \
5test_entry
diff --git a/src/modules/test_entry/Makefile.am b/src/modules/test_entry/Makefile.am
new file mode 100644
index 000000000..bea397288
--- /dev/null
+++ b/src/modules/test_entry/Makefile.am
@@ -0,0 +1,31 @@
1
2MAINTAINERCLEANFILES = Makefile.in
3
4AM_CPPFLAGS = \
5-I. \
6-I$(top_builddir) \
7-I$(top_srcdir) \
8-I$(top_srcdir)/src/lib \
9-I$(top_builddir)/src/lib \
10-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
11-DPACKAGE_LIB_DIR=\"$(libdir)\" \
12@ELEMENTARY_CFLAGS@ \
13@ELEMENTARY_X_CFLAGS@ \
14@ELEMENTARY_FB_CFLAGS@ \
15@ELEMENTARY_WIN32_CFLAGS@ \
16@ELEMENTARY_WINCE_CFLAGS@ \
17@ELEMENTARY_EDBUS_CFLAGS@ \
18@ELEMENTARY_EFREET_CFLAGS@
19
20if ELEMENTARY_WINDOWS_BUILD
21AM_CPPFLAGS += -DELEMENTARY_BUILD
22endif
23
24pkgdir = $(libdir)/elementary/modules/test_entry/$(MODULE_ARCH)
25pkg_LTLIBRARIES = module.la
26
27module_la_SOURCES = mod.c
28
29module_la_LIBADD = $(top_builddir)/src/lib/libelementary.la
30module_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version
31module_la_LIBTOOLFLAGS = --tag=disable-static
diff --git a/src/modules/test_entry/mod.c b/src/modules/test_entry/mod.c
new file mode 100644
index 000000000..acf2990fa
--- /dev/null
+++ b/src/modules/test_entry/mod.c
@@ -0,0 +1,33 @@
1#include <Elementary.h>
2
3// module api funcs needed
4EAPI int
5elm_modapi_init(void *m)
6{
7 return 1; // succeed always
8}
9
10EAPI int
11elm_modapi_shutdown(void *m)
12{
13 return 1; // succeed always
14}
15
16// module fucns for the specific module type
17EAPI void
18obj_hook(Evas_Object *obj)
19{
20 printf("hook: %p\n", obj);
21}
22
23EAPI void
24obj_unhook(Evas_Object *obj)
25{
26 printf("unhook: %p\n", obj);
27}
28
29EAPI void
30obj_longpress(Evas_Object *obj)
31{
32 printf("longpress: %p\n", obj);
33}