Update SDK Viewer
authorSung-jae Park <nicesj.park@samsung.com>
Wed, 20 May 2015 10:19:00 +0000 (19:19 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Wed, 20 May 2015 10:19:00 +0000 (19:19 +0900)
Change-Id: I85c7e38db0cba5a08d580e49e51eb881cb4e627d

widget_viewer_sdk/data/widget_viewer_sdk.edc
widget_viewer_sdk/src/main.c

index ac5b73c..2d6327a 100644 (file)
@@ -1,5 +1,13 @@
 collections {
        styles {
+               style {
+                       name: "info,text";
+                       base: "font=Tizen font_size=15 align=left color=#FFFFFF ellipsis=1.0 wrap=char";
+                       tag: "br" "\n";
+                       tag: "hilight" "+ font=Tizen:style=Bold";
+                       tag: "b" "+ font=Tizen:style=Bold";
+                       tag: "tag" "\t";
+               }
        }
 
        group {
@@ -65,81 +73,141 @@ collections {
                        }
 
                        part {
-                               name: "widget,id";
+                               name: "widget,id,name";
                                clip_to: "widget,info";
                                type: TEXT;
                                mouse_events: 0;
                                description {
                                        state: "default" 0.0;
-                                       rel1 { relative: 0.0 0.1; }
-                                       rel2 { relative: 1.0 0.2; }
+                                       rel1 { relative: 0.0 0.0; to_y, "widget,id"; }
+                                       rel2 { relative: 0.3 1.0; to_y, "widget,id"; }
+                                       text {
+                                               style: "info,text";
+                                               text: "widget id";
+                                       }
+                               }
+                       }
+
+                       part {
+                               name: "widget,id";
+                               clip_to: "widget,info";
+                               type: TEXTBLOCK;
+                               mouse_events: 0;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.35 0.1; }
+                                       rel2 { relative: 1.0 0.15; }
                                        color: 255 255 255 255;
                                        color2: 0 0 0 255;
                                        color3: 0 0 0 255;
                                        text {
+                                               style: "info,text";
                                                text: "Hello";
-                                               align: 0.5 0.5;
-                                               size: 15;
                                        }
                                }
                        }
 
                        part {
-                               name: "widget,content,info";
+                               name: "widget,content,info,name";
                                clip_to: "widget,info";
                                type: TEXT;
                                mouse_events: 0;
                                description {
                                        state: "default" 0.0;
-                                       rel1 { relative: 0.0 0.25; }
-                                       rel2 { relative: 1.0 0.35; }
+                                       rel1 { relative: 0.0 0.0; to_y, "widget,content,info"; }
+                                       rel2 { relative: 0.3 1.0; to_y, "widget,content,info"; }
+                                       text {
+                                               style: "info,text";
+                                               text: "content info";
+                                       }
+                               }
+                       }
+
+                       part {
+                               name: "widget,content,info";
+                               clip_to: "widget,info";
+                               type: TEXTBLOCK;
+                               mouse_events: 0;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.35 0.20; }
+                                       rel2 { relative: 1.0 0.25; }
                                        color: 255 255 255 255;
                                        color2: 0 0 0 255;
                                        color3: 0 0 0 255;
                                        text {
+                                               style: "info,text";
                                                text: "Hello";
-                                               align: 0.5 0.5;
-                                               size: 15;
                                        }
                                }
                        }
 
                        part {
-                               name: "widget,title";
+                               name: "widget,title,name";
                                clip_to: "widget,info";
                                type: TEXT;
                                mouse_events: 0;
                                description {
                                        state: "default" 0.0;
-                                       rel1 { relative: 0.0 0.4; }
-                                       rel2 { relative: 1.0 0.5; }
+                                       rel1 { relative: 0.0 0.0; to_y, "widget,title"; }
+                                       rel2 { relative: 0.3 1.0; to_y, "widget,title"; }
+                                       text {
+                                               style: "info,text";
+                                               text: "title";
+                                       }
+                               }
+                       }
+
+                       part {
+                               name: "widget,title";
+                               clip_to: "widget,info";
+                               type: TEXTBLOCK;
+                               mouse_events: 0;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.35 0.3; }
+                                       rel2 { relative: 1.0 0.35; }
                                        color: 255 255 255 255;
                                        color2: 0 0 0 255;
                                        color3: 0 0 0 255;
                                        text {
+                                               style: "info,text";
                                                text: "Hello";
-                                               align: 0.5 0.5;
-                                               size: 15;
                                        }
                                }
                        }
 
                        part {
-                               name: "widget,period";
+                               name: "widget,period,name";
                                clip_to: "widget,info";
                                type: TEXT;
                                mouse_events: 0;
                                description {
                                        state: "default" 0.0;
-                                       rel1 { relative: 0.0 0.55; }
-                                       rel2 { relative: 1.0 0.65; }
+                                       rel1 { relative: 0.0 0.0; to_y, "widget,period"; }
+                                       rel2 { relative: 0.3 1.0; to_y, "widget,period"; }
+                                       text {
+                                               style: "info,text";
+                                               text: "period";
+                                       }
+                               }
+                       }
+
+                       part {
+                               name: "widget,period";
+                               clip_to: "widget,info";
+                               type: TEXTBLOCK;
+                               mouse_events: 0;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.35 0.4; }
+                                       rel2 { relative: 1.0 0.45; }
                                        color: 255 255 255 255;
                                        color2: 0 0 0 255;
                                        color3: 0 0 0 255;
                                        text {
+                                               style: "info,text";
                                                text: "Hello";
-                                               align: 0.5 0.5;
-                                               size: 15;
                                        }
                                }
                        }
index a4908e1..60fcdd5 100644 (file)
@@ -25,6 +25,8 @@
 #include <bundle.h>
 #include <dlog.h>
 #include <string.h>
+#include <app_control.h>
+#include <app_control_internal.h>
 
 int errno;
 
@@ -250,11 +252,13 @@ static void list_item_clicked_cb(void *data, Evas_Object *obj, void *event_info)
                return;
        }
 
-//     evas_object_resize(s_info.ctx.widget, w, h);
-//     evas_object_size_hint_min_set(s_info.ctx.widget, w, h);
+       evas_object_resize(s_info.ctx.widget, w, h);
+       evas_object_size_hint_min_set(s_info.ctx.widget, w, h);
+       evas_object_size_hint_max_set(s_info.ctx.widget, w, h);
 
        evas_object_resize(s_info.layout, w, h);
        evas_object_size_hint_min_set(s_info.layout, w, h);
+       evas_object_size_hint_max_set(s_info.layout, w, h);
 }
 
 static void extra_updated_cb(void *data, Evas_Object *obj, void *event_info)
@@ -300,6 +304,12 @@ static void period_changed_cb(void *data, Evas_Object *obj, void *event_info)
        DbgPrint("Period updated: %s\n", buffer);
 }
 
+static void widget_created_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       period_changed_cb(data, obj, NULL);
+       extra_updated_cb(data, obj, NULL);
+}
+
 static int load_widget(const char *widget_id)
 {
        int w = 0;
@@ -328,18 +338,22 @@ static int load_widget(const char *widget_id)
        }
 
        DbgPrint("Resize the widget(%s) to [%X] %dx%d\n", widget_id, s_info.ctx.size_types[0], w, h);
-       evas_object_resize(s_info.ctx.widget, w, h);
-       evas_object_size_hint_min_set(s_info.ctx.widget, w, h);
 
        evas_object_smart_callback_add(s_info.ctx.widget, WIDGET_SMART_SIGNAL_UPDATED, updated_cb, NULL);
        evas_object_smart_callback_add(s_info.ctx.widget, WIDGET_SMART_SIGNAL_EXTRA_INFO_UPDATED, extra_updated_cb, NULL);
        evas_object_smart_callback_add(s_info.ctx.widget, WIDGET_SMART_SIGNAL_PERIOD_CHANGED, period_changed_cb, NULL);
+       evas_object_smart_callback_add(s_info.ctx.widget, WIDGET_SMART_SIGNAL_WIDGET_CREATED, widget_created_cb, NULL);
 
        elm_object_part_text_set(s_info.layout, "widget,id", widget_id);
        elm_object_part_content_set(s_info.layout, "widget", s_info.ctx.widget);
 
+       evas_object_resize(s_info.ctx.widget, w, h);
+       evas_object_size_hint_min_set(s_info.ctx.widget, w, h);
+       evas_object_size_hint_max_set(s_info.ctx.widget, w, h);
+
        evas_object_resize(s_info.layout, w, h);
        evas_object_size_hint_min_set(s_info.layout, w, h);
+       evas_object_size_hint_max_set(s_info.layout, w, h);
 
        return WIDGET_ERROR_NONE;
 }
@@ -384,7 +398,7 @@ static Evas_Object *list_item_content_get_cb(void *data, Evas_Object *obj, const
        return icon;
 }
 
-static int prepare_widget(const char *widget_id)
+static int prepare_widget(const char *widget_id, app_control_h control)
 {
        int ret;
        Evas_Object *size_list;
@@ -392,6 +406,7 @@ static int prepare_widget(const char *widget_id)
        int i;
        int w;
        int h;
+       bundle *b;
        static Elm_Genlist_Item_Class class = {
                .func = {
                        .text_get = list_item_text_get_cb,
@@ -401,6 +416,27 @@ static int prepare_widget(const char *widget_id)
                }
        };
 
+       if (app_control_export_as_bundle(control, &b) == APP_CONTROL_ERROR_NONE) {
+               bundle_raw *r;
+               int len;
+
+               if (bundle_encode(b, &r, &len) == BUNDLE_ERROR_NONE) {
+                       s_info.ctx.content_info = malloc(len + 8);
+                       if (!s_info.ctx.content_info) {
+                               ErrPrint("malloc: %d\n", errno);
+                       } else {
+                               snprintf(s_info.ctx.content_info, len + 8, "%d:%s", len, (char *)r);
+                               DbgPrint("Encoded content_info: [%s]\n", s_info.ctx.content_info);
+                       }
+
+                       free((char *)r); /* Do I have to use the g_free? */
+               } else {
+                       ErrPrint("Failed to encode a bundle\n");
+               }
+
+               bundle_free(b);
+       }
+
        ret = widget_service_get_supported_size_types(widget_id, &s_info.ctx.count_of_size_type, &s_info.ctx.size_types);
        if (ret != WIDGET_ERROR_NONE) {
                ErrPrint("Failed to load an widget\n");
@@ -457,7 +493,7 @@ static void _app_control(app_control_h service, void *data)
                }
 
                ret = unload_widget();
-               ret = prepare_widget(widget_id);
+               ret = prepare_widget(widget_id, service);
                ret = load_widget(widget_id);
                free(widget_id);
        } else {