summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChunEon Park <hermet@hermet.pe.kr>2011-12-30 10:53:37 +0000
committerChunEon Park <hermet@hermet.pe.kr>2011-12-30 10:53:37 +0000
commitf96210eea810ef99115a50a67101aaf9c331ef4e (patch)
tree3dd7f27b859a22fa0f46da5e8534be391726700a /src
parent0982b94a72a268e9e2e545e6e7882c94babbda80 (diff)
elementary/diskselector - deprecated APIs. Now let's use elm_object_item APIs
elm_diskselector_item_label_set() elm_diskselector_item_label_get() elm_diskselector_item_icon_set() elm_diskselector_item_icon_get() elm_diskselector_item_data_get() SVN revision: 66685
Diffstat (limited to 'src')
-rw-r--r--src/bin/test_diskselector.c9
-rw-r--r--src/examples/diskselector_example_02.c6
-rw-r--r--src/lib/elm_deprecated.h117
-rw-r--r--src/lib/elm_diskselector.c81
-rw-r--r--src/lib/elm_diskselector.h118
5 files changed, 191 insertions, 140 deletions
diff --git a/src/bin/test_diskselector.c b/src/bin/test_diskselector.c
index 158de0bbb..05e4db0cf 100644
--- a/src/bin/test_diskselector.c
+++ b/src/bin/test_diskselector.c
@@ -8,7 +8,7 @@ static void
8_disk_sel(void *data __UNUSED__, Evas_Object * obj __UNUSED__, void *event_info) 8_disk_sel(void *data __UNUSED__, Evas_Object * obj __UNUSED__, void *event_info)
9{ 9{
10 Elm_Object_Item *ds_it = event_info; 10 Elm_Object_Item *ds_it = event_info;
11 printf("Equinox: %s\n", elm_diskselector_item_label_get(ds_it)); 11 printf("Equinox: %s\n", elm_object_item_text_get(ds_it));
12} 12}
13 13
14static void 14static void
@@ -17,16 +17,15 @@ _disk_next(void *data __UNUSED__, Evas_Object * obj __UNUSED__, void *event_info
17 Elm_Object_Item *next_ds_it, *prev_ds_it, *ds_it = event_info; 17 Elm_Object_Item *next_ds_it, *prev_ds_it, *ds_it = event_info;
18 prev_ds_it = elm_diskselector_item_prev_get(ds_it); 18 prev_ds_it = elm_diskselector_item_prev_get(ds_it);
19 next_ds_it = elm_diskselector_item_next_get(ds_it); 19 next_ds_it = elm_diskselector_item_next_get(ds_it);
20 printf("Prev: %s, Next: %s\n", 20 printf("Prev: %s, Next: %s\n", elm_object_item_text_get(prev_ds_it),
21 elm_diskselector_item_label_get(prev_ds_it), 21 elm_object_item_text_get(next_ds_it));
22 elm_diskselector_item_label_get(next_ds_it));
23} 22}
24 23
25static void 24static void
26_print_disk_info_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) 25_print_disk_info_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
27{ 26{
28 Elm_Object_Item *ds_it = event_info; 27 Elm_Object_Item *ds_it = event_info;
29 printf("Selected label: %s\n", elm_diskselector_item_label_get(ds_it)); 28 printf("Selected label: %s\n", elm_object_item_text_get(ds_it));
30} 29}
31 30
32static Evas_Object * 31static Evas_Object *
diff --git a/src/examples/diskselector_example_02.c b/src/examples/diskselector_example_02.c
index 99e8c4997..8ac55befb 100644
--- a/src/examples/diskselector_example_02.c
+++ b/src/examples/diskselector_example_02.c
@@ -57,7 +57,7 @@ static void
57_sel_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) 57_sel_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
58{ 58{
59 Elm_Object_Item *ds_it = event_info; 59 Elm_Object_Item *ds_it = event_info;
60 printf("Selected label: %s\n", elm_diskselector_item_label_get(ds_it)); 60 printf("Selected label: %s\n", elm_object_item_text_get(ds_it));
61} 61}
62 62
63static void 63static void
@@ -78,7 +78,7 @@ _sel_data_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info)
78 char *content = data; 78 char *content = data;
79 Elm_Object_Item *ds_it = event_info; 79 Elm_Object_Item *ds_it = event_info;
80 printf("Selected label: %s with data: %s\n", 80 printf("Selected label: %s with data: %s\n",
81 elm_diskselector_item_label_get(ds_it), content); 81 elm_object_item_text_get(ds_it), content);
82} 82}
83 83
84static void 84static void
@@ -134,7 +134,7 @@ _print_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
134 134
135 items = elm_diskselector_items_get(ds); 135 items = elm_diskselector_items_get(ds);
136 EINA_LIST_FOREACH(items, l, ds_it) 136 EINA_LIST_FOREACH(items, l, ds_it)
137 printf("%s\n", elm_diskselector_item_label_get(ds_it)); 137 printf("%s\n", elm_object_item_text_get(ds_it));
138} 138}
139 139
140static void 140static void
diff --git a/src/lib/elm_deprecated.h b/src/lib/elm_deprecated.h
index ba92d5648..3d3133526 100644
--- a/src/lib/elm_deprecated.h
+++ b/src/lib/elm_deprecated.h
@@ -1150,6 +1150,123 @@ EINA_DEPRECATED EAPI int elm_diskselector_side_label_lenght_get(const Evas_Ob
1150 */ 1150 */
1151EINA_DEPRECATED EAPI void elm_diskselector_side_label_lenght_set(Evas_Object *obj, int len); 1151EINA_DEPRECATED EAPI void elm_diskselector_side_label_lenght_set(Evas_Object *obj, int len);
1152 1152
1153/**
1154 * Get the data associated to the item.
1155 *
1156 * @param it The diskselector item
1157 * @return The data associated to @p it
1158 *
1159 * The return value is a pointer to data associated to @p item when it was
1160 * created, with function elm_diskselector_item_append(). If no data
1161 * was passed as argument, it will return @c NULL.
1162 *
1163 * @see elm_diskselector_item_append()
1164 * @deprecated Use elm_object_item_data_get()
1165 *
1166 * @ingroup Diskselector
1167 */
1168EINA_DEPRECATED EAPI void *elm_diskselector_item_data_get(const Elm_Object_Item *it);
1169
1170/**
1171 * Set the icon associated to the item.
1172 *
1173 * @param it The diskselector item
1174 * @param icon The icon object to associate with @p it
1175 *
1176 * The icon object to use at left side of the item. An
1177 * icon can be any Evas object, but usually it is an icon created
1178 * with elm_icon_add().
1179 *
1180 * Once the icon object is set, a previously set one will be deleted.
1181 * @warning Setting the same icon for two items will cause the icon to
1182 * dissapear from the first item.
1183 *
1184 * If an icon was passed as argument on item creation, with function
1185 * elm_diskselector_item_append(), it will be already
1186 * associated to the item.
1187 *
1188 * @see elm_diskselector_item_append()
1189 * @see elm_diskselector_item_icon_get()
1190 *
1191 * @deprecated Use elm_object_item_part_content_set() instead
1192 * @ingroup Diskselector
1193 */
1194EINA_DEPRECATED EAPI void elm_diskselector_item_icon_set(Elm_Object_Item *it, Evas_Object *icon);
1195
1196/**
1197 * Get the icon associated to the item.
1198 *
1199 * @param item The diskselector item
1200 * @return The icon associated to @p it
1201 *
1202 * The return value is a pointer to the icon associated to @p item when it was
1203 * created, with function elm_diskselector_item_append(), or later
1204 * with function elm_diskselector_item_icon_set. If no icon
1205 * was passed as argument, it will return @c NULL.
1206 *
1207 * @see elm_diskselector_item_append()
1208 * @see elm_diskselector_item_icon_set()
1209 *
1210 * @deprecated Use elm_object_item_part_content_set() instead
1211 * @ingroup Diskselector
1212 */
1213EAPI Evas_Object *elm_diskselector_item_icon_get(const Elm_Object_Item *it);
1214
1215/**
1216 * Set the label of item.
1217 *
1218 * @param it The item of diskselector.
1219 * @param label The label of item.
1220 *
1221 * The label to be displayed by the item.
1222 *
1223 * If no icon is set, label will be centered on item position, otherwise
1224 * the icon will be placed at left of the label, that will be shifted
1225 * to the right.
1226 *
1227 * An item with label "January" would be displayed on side position as
1228 * "Jan" if max length is set to 3 with function
1229 * elm_diskselector_side_label_lenght_set(), or "Janu", if this property
1230 * is set to 4.
1231 *
1232 * When this @p item is selected, the entire label will be displayed,
1233 * except for width restrictions.
1234 * In this case label will be cropped and "..." will be concatenated,
1235 * but only for display purposes. It will keep the entire string, so
1236 * if diskselector is resized the remaining characters will be displayed.
1237 *
1238 * If a label was passed as argument on item creation, with function
1239 * elm_diskselector_item_append(), it will be already
1240 * displayed by the item.
1241 *
1242 * @see elm_diskselector_side_label_lenght_set()
1243 * @see elm_diskselector_item_label_get()
1244 * @see elm_diskselector_item_append()
1245 *
1246 * @deprecated Use elm_object_item_text_set() instead
1247 * @ingroup Diskselector
1248 */
1249EINA_DEPRECATED EAPI void elm_diskselector_item_label_set(Elm_Object_Item *it, const char *label);
1250
1251/**
1252 * Get the label of item.
1253 *
1254 * @param it The item of diskselector.
1255 * @return The label of item.
1256 *
1257 * The return value is a pointer to the label associated to @p item when it was
1258 * created, with function elm_diskselector_item_append(), or later
1259 * with function elm_diskselector_item_label_set. If no label
1260 * was passed as argument, it will return @c NULL.
1261 *
1262 * @see elm_diskselector_item_label_set() for more details.
1263 * @see elm_diskselector_item_append()
1264 * @use elm_object_item_text_get()
1265 *
1266 * @ingroup Diskselector
1267 */
1268EINA_DEPRECATED EAPI const char *elm_diskselector_item_label_get(const Elm_Object_Item *it);
1269
1153EINA_DEPRECATED EAPI void elm_factory_content_set(Evas_Object *obj, Evas_Object *content); 1270EINA_DEPRECATED EAPI void elm_factory_content_set(Evas_Object *obj, Evas_Object *content);
1154EINA_DEPRECATED EAPI Evas_Object *elm_factory_content_get(const Evas_Object *obj); 1271EINA_DEPRECATED EAPI Evas_Object *elm_factory_content_get(const Evas_Object *obj);
1155 1272
diff --git a/src/lib/elm_diskselector.c b/src/lib/elm_diskselector.c
index 1ac7f6ea4..842ca9d67 100644
--- a/src/lib/elm_diskselector.c
+++ b/src/lib/elm_diskselector.c
@@ -65,6 +65,16 @@ static void _item_click_cb(void *data, Evas_Object *obj __UNUSED__,
65 const char *emission __UNUSED__, 65 const char *emission __UNUSED__,
66 const char *source __UNUSED__); 66 const char *source __UNUSED__);
67static void _selected_item_indicate(Elm_Diskselector_Item *it); 67static void _selected_item_indicate(Elm_Diskselector_Item *it);
68static void _item_text_set_hook(Elm_Object_Item *it,
69 const char *part,
70 const char *label);
71static const char * _item_text_get_hook(const Elm_Object_Item *it,
72 const char *part);
73static void _item_content_set_hook(Elm_Object_Item *it,
74 const char *part,
75 Evas_Object *content);
76static Evas_Object * _item_content_get_hook(const Elm_Object_Item *it,
77 const char *part);
68 78
69static const char SIG_SELECTED[] = "selected"; 79static const char SIG_SELECTED[] = "selected";
70static const Evas_Smart_Cb_Description _signals[] = { 80static const Evas_Smart_Cb_Description _signals[] = {
@@ -111,6 +121,11 @@ _item_new(Evas_Object *obj, Evas_Object *icon, const char *label, Evas_Smart_Cb
111 it = elm_widget_item_new(obj, Elm_Diskselector_Item); 121 it = elm_widget_item_new(obj, Elm_Diskselector_Item);
112 if (!it) return NULL; 122 if (!it) return NULL;
113 123
124 elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
125 elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
126 elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
127 elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
128
114 it->label = eina_stringshare_add(label); 129 it->label = eina_stringshare_add(label);
115 it->icon = icon; 130 it->icon = icon;
116 it->func = func; 131 it->func = func;
@@ -570,8 +585,7 @@ _scroller_stop_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UN
570 Evas_Coord x, w, ow; 585 Evas_Coord x, w, ow;
571 Eina_List *l, *list; 586 Eina_List *l, *list;
572 587
573 if (wd->idler) 588 if (wd->idler) return;
574 return;
575 589
576 if (!wd->round) 590 if (!wd->round)
577 list = wd->items; 591 list = wd->items;
@@ -582,13 +596,10 @@ _scroller_stop_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UN
582 EINA_LIST_FOREACH(list, l, it) 596 EINA_LIST_FOREACH(list, l, it)
583 { 597 {
584 evas_object_geometry_get(VIEW(it), &x, NULL, &w, NULL); 598 evas_object_geometry_get(VIEW(it), &x, NULL, &w, NULL);
585 if (abs((int)(ow / 2 - (int)(x + w / 2))) < 10) 599 if (abs((int)(ow / 2 - (int)(x + w / 2))) < 10) break;
586 break;
587 } 600 }
588 601
589 if (!it) 602 if (!it) return;
590 return;
591
592 _select_item(it); 603 _select_item(it);
593} 604}
594 605
@@ -824,6 +835,44 @@ _check_identical_item(Elm_Diskselector_Item *it, Evas_Object *icon)
824 } 835 }
825} 836}
826 837
838static void
839_item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
840{
841 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
842 Elm_Diskselector_Item *item;
843 if (part && strcmp(part, "default")) return;
844 item = (Elm_Diskselector_Item *) it;
845 eina_stringshare_replace(&item->label, label);
846 edje_object_part_text_set(VIEW(item), "elm.text", item->label);
847}
848
849static const char *
850_item_text_get_hook(const Elm_Object_Item *it, const char *part)
851{
852 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
853 if (part && strcmp(part, "default")) return NULL;
854 return ((Elm_Diskselector_Item *) it)->label;
855}
856
857static void
858_item_content_set_hook(Elm_Object_Item *it,
859 const char *part,
860 Evas_Object *content)
861{
862 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
863 if (part && strcmp(part, "icon")) return;
864 _item_icon_set((Elm_Diskselector_Item *) it, content);
865 _check_identical_item((Elm_Diskselector_Item *) it, content);
866}
867
868static Evas_Object *
869_item_content_get_hook(const Elm_Object_Item *it, const char *part)
870{
871 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
872 if (part && strcmp(part, "icon")) return NULL;
873 return ((Elm_Diskselector_Item *) it)->icon;
874}
875
827EAPI Evas_Object * 876EAPI Evas_Object *
828elm_diskselector_add(Evas_Object *parent) 877elm_diskselector_add(Evas_Object *parent)
829{ 878{
@@ -1218,17 +1267,13 @@ elm_diskselector_item_del(Elm_Object_Item * it)
1218EAPI const char * 1267EAPI const char *
1219elm_diskselector_item_label_get(const Elm_Object_Item * it) 1268elm_diskselector_item_label_get(const Elm_Object_Item * it)
1220{ 1269{
1221 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); 1270 return _item_text_get_hook(it, NULL);
1222 return ((Elm_Diskselector_Item *) it)->label;
1223} 1271}
1224 1272
1225EAPI void 1273EAPI void
1226elm_diskselector_item_label_set(Elm_Object_Item * it, const char *label) 1274elm_diskselector_item_label_set(Elm_Object_Item * it, const char *label)
1227{ 1275{
1228 ELM_OBJ_ITEM_CHECK_OR_RETURN(it); 1276 _item_text_set_hook(it, NULL, label);
1229 Elm_Diskselector_Item *item = (Elm_Diskselector_Item *) it;
1230 eina_stringshare_replace(&item->label, label);
1231 edje_object_part_text_set(VIEW(item), "elm.text", item->label);
1232} 1277}
1233 1278
1234EAPI Elm_Object_Item * 1279EAPI Elm_Object_Item *
@@ -1283,23 +1328,19 @@ elm_diskselector_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func)
1283EAPI void * 1328EAPI void *
1284elm_diskselector_item_data_get(const Elm_Object_Item *it) 1329elm_diskselector_item_data_get(const Elm_Object_Item *it)
1285{ 1330{
1286 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); 1331 return elm_object_item_data_get(it);
1287 return elm_widget_item_data_get(it);
1288} 1332}
1289 1333
1290EAPI Evas_Object * 1334EAPI Evas_Object *
1291elm_diskselector_item_icon_get(const Elm_Object_Item *it) 1335elm_diskselector_item_icon_get(const Elm_Object_Item *it)
1292{ 1336{
1293 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); 1337 return _item_content_get_hook(it, NULL);
1294 return ((Elm_Diskselector_Item *) it)->icon;
1295} 1338}
1296 1339
1297EAPI void 1340EAPI void
1298elm_diskselector_item_icon_set(Elm_Object_Item *it, Evas_Object *icon) 1341elm_diskselector_item_icon_set(Elm_Object_Item *it, Evas_Object *icon)
1299{ 1342{
1300 ELM_OBJ_ITEM_CHECK_OR_RETURN(it); 1343 _item_content_set_hook(it, NULL, icon);
1301 _item_icon_set((Elm_Diskselector_Item *) it, icon);
1302 _check_identical_item((Elm_Diskselector_Item *) it, icon);
1303} 1344}
1304 1345
1305EAPI Elm_Object_Item * 1346EAPI Elm_Object_Item *
diff --git a/src/lib/elm_diskselector.h b/src/lib/elm_diskselector.h
index 0f5e1ab39..d1f316bed 100644
--- a/src/lib/elm_diskselector.h
+++ b/src/lib/elm_diskselector.h
@@ -18,6 +18,12 @@
18 * Available styles for it: 18 * Available styles for it:
19 * - @c "default" 19 * - @c "default"
20 * 20 *
21 * Default contents parts of the diskseletor items that you can use for are:
22 * @li "icon" - An icon in the diskselector item
23 *
24 * Default text parts of the diskselector items that you can use for are:
25 * @li "default" - Label of the diskselector item
26 *
21 * List of examples: 27 * List of examples:
22 * @li @ref diskselector_example_01 28 * @li @ref diskselector_example_01
23 * @li @ref diskselector_example_02 29 * @li @ref diskselector_example_02
@@ -324,118 +330,6 @@ EAPI void elm_diskselector_item_del(Elm_Object_Item *it);
324EAPI void elm_diskselector_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func); 330EAPI void elm_diskselector_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func);
325 331
326/** 332/**
327 * Get the data associated to the item.
328 *
329 * @param it The diskselector item
330 * @return The data associated to @p it
331 *
332 * The return value is a pointer to data associated to @p item when it was
333 * created, with function elm_diskselector_item_append(). If no data
334 * was passed as argument, it will return @c NULL.
335 *
336 * @see elm_diskselector_item_append()
337 *
338 * @ingroup Diskselector
339 */
340EAPI void *elm_diskselector_item_data_get(const Elm_Object_Item *it);
341
342/**
343 * Set the icon associated to the item.
344 *
345 * @param it The diskselector item
346 * @param icon The icon object to associate with @p it
347 *
348 * The icon object to use at left side of the item. An
349 * icon can be any Evas object, but usually it is an icon created
350 * with elm_icon_add().
351 *
352 * Once the icon object is set, a previously set one will be deleted.
353 * @warning Setting the same icon for two items will cause the icon to
354 * dissapear from the first item.
355 *
356 * If an icon was passed as argument on item creation, with function
357 * elm_diskselector_item_append(), it will be already
358 * associated to the item.
359 *
360 * @see elm_diskselector_item_append()
361 * @see elm_diskselector_item_icon_get()
362 *
363 * @ingroup Diskselector
364 */
365EAPI void elm_diskselector_item_icon_set(Elm_Object_Item *it, Evas_Object *icon);
366
367/**
368 * Get the icon associated to the item.
369 *
370 * @param item The diskselector item
371 * @return The icon associated to @p it
372 *
373 * The return value is a pointer to the icon associated to @p item when it was
374 * created, with function elm_diskselector_item_append(), or later
375 * with function elm_diskselector_item_icon_set. If no icon
376 * was passed as argument, it will return @c NULL.
377 *
378 * @see elm_diskselector_item_append()
379 * @see elm_diskselector_item_icon_set()
380 *
381 * @ingroup Diskselector
382 */
383EAPI Evas_Object *elm_diskselector_item_icon_get(const Elm_Object_Item *it);
384
385/**
386 * Set the label of item.
387 *
388 * @param it The item of diskselector.
389 * @param label The label of item.
390 *
391 * The label to be displayed by the item.
392 *
393 * If no icon is set, label will be centered on item position, otherwise
394 * the icon will be placed at left of the label, that will be shifted
395 * to the right.
396 *
397 * An item with label "January" would be displayed on side position as
398 * "Jan" if max length is set to 3 with function
399 * elm_diskselector_side_label_lenght_set(), or "Janu", if this property
400 * is set to 4.
401 *
402 * When this @p item is selected, the entire label will be displayed,
403 * except for width restrictions.
404 * In this case label will be cropped and "..." will be concatenated,
405 * but only for display purposes. It will keep the entire string, so
406 * if diskselector is resized the remaining characters will be displayed.
407 *
408 * If a label was passed as argument on item creation, with function
409 * elm_diskselector_item_append(), it will be already
410 * displayed by the item.
411 *
412 * @see elm_diskselector_side_label_lenght_set()
413 * @see elm_diskselector_item_label_get()
414 * @see elm_diskselector_item_append()
415 *
416 * @ingroup Diskselector
417 */
418EAPI void elm_diskselector_item_label_set(Elm_Object_Item *it, const char *label);
419
420/**
421 * Get the label of item.
422 *
423 * @param it The item of diskselector.
424 * @return The label of item.
425 *
426 * The return value is a pointer to the label associated to @p item when it was
427 * created, with function elm_diskselector_item_append(), or later
428 * with function elm_diskselector_item_label_set. If no label
429 * was passed as argument, it will return @c NULL.
430 *
431 * @see elm_diskselector_item_label_set() for more details.
432 * @see elm_diskselector_item_append()
433 *
434 * @ingroup Diskselector
435 */
436EAPI const char *elm_diskselector_item_label_get(const Elm_Object_Item *it);
437
438/**
439 * Get the selected item. 333 * Get the selected item.
440 * 334 *
441 * @param obj The diskselector object. 335 * @param obj The diskselector object.