Tizen: Set text of part in group which is in EDC file

104 Views Asked by At

I'm trying to write a widget for Tizen platform. Layout of the widget is described in a EDC file. I needed a block, which contains some text and image parts, to be repeated three times with different text labels. So I decided that I need to create a group with required parts and use it as item in a box part:

group {
    name: "list_item";

    parts {
        part {
            name: "label1";
            type: "TEXT";

            description { ...  }
        }

        part {
            name: "label2";
            type: "TEXT";

            description { ... }
        }
    }
}

group {
    name: "content";

    parts {
        part {
            name: "list";
            type: "BOX";

            box {
                items {
                    item {
                        type: "GROUP";
                        name: "item1";
                        source: "list_item";
                    }

                    item {
                        type: "GROUP";
                        name: "item2";
                        source: "list_item";
                    }

                    item {
                        type: "GROUP";
                        name: "item3";
                        source: "list_item";
                    }
                }
            }

            description { ... }
        }
    }
}

For static text parts, which are placed in primary layout group content, I use elm_object_part_text_set(wid->content, part_name, text) (the language is C, btw), but can't figure out how to set text of label1 part of each instance of list_item.

2

There are 2 best solutions below

1
On

How about using swallow instead of group?

When creating a complex layout using EDC, it can be easily implemented by using a swallow.

In c code, you can set elm_label to swallow content.

And you can also set content to swallow the box after add 2 elm_labels in the box

Or you can create a more complex layout and set the layout to content in swallow. (like your group "list_item").

in EDC :

   group { "list";
      parts {
         swallow { "item1";
            desc { "default";
                ...
            }
         }
         swallow { "item2";
            desc { "default";
                ...
            }
         }
         swallow { "item3";
            desc { "default";
                ...
            }
         }
      }
   }

in C code :

/* ex 1 */
elm_object_part_content_set(layout, "item1", label1);
elm_object_part_content_set(layout, "item2", label2);
elm_object_part_content_set(layout, "item2", label3);

/* ex */
elm_box_pack_end(box, label1);
elm_box_pack_end(box, label2);
elm_object_part_content_set(layout, "item1", box);

/* ex 3 */
elm_object_part_text_set(list_item, "label1", "Text 1 ...");
elm_object_part_text_set(list_item, "label2", "Text 2 ...");
elm_object_part_content_set(layout, "item1", list_item);
0
On

I found a solution. I'm not sure it's a right one, but it works.

// widget_instance_data_s *widget_instance
// Get part by name as object
Evas_Object *evas_list = (Evas_Object*) edje_object_part_object_get(elm_layout_edje_get(widget_instance->content), "list");
// Get items of box
Eina_List *items = evas_object_box_children_get(evas_list);
int items_count = eina_list_count(items);

for (i = 0; i < items_count; i++) {
    list_item = (Evas_Object *) eina_list_nth(items, i);
    // item1, item2, ...
    item_name = evas_object_name_get(list_item);
    ...
    edje_object_part_text_set(list_item, "label1", str);
}