Appctl handling 26/124826/4
authorRadek Kintop <r.kintop@samsung.com>
Wed, 12 Apr 2017 12:03:28 +0000 (14:03 +0200)
committerRadek Kintop <r.kintop@samsung.com>
Wed, 12 Apr 2017 15:29:30 +0000 (08:29 -0700)
- addded key "subview" with values
{"brightness", "contrast", "color", "tint"}

Change-Id: If485b2095af7a0701eec753813c788e0efac6425
Signed-off-by: Radek Kintop <r.kintop@samsung.com>
include/common/viewmgr.h
src/common/utils.c
src/common/viewmgr.c
src/main.c
src/view/view_base.c

index d394cf7..d6035fd 100644 (file)
@@ -142,6 +142,16 @@ bool viewmgr_push_view(const char *view_id);
 bool viewmgr_pop_view(void);
 
 /**
+ * Pops most all views from view stack till it's empty.
+ *
+ * Hides a all visible views.
+ *
+ * @return If the operation was sucessful true is returned;
+ * otherwise false is returned
+ */
+bool viewmgr_pop_all_views(void);
+
+/**
  * Sets a view data to be supplied to view.
  *
  * If view data is setted, view data is passed to view
index a20bd43..2ecf786 100755 (executable)
@@ -195,8 +195,6 @@ Evas_Object *utils_add_table(Evas_Object *parent, int padding_x, int padding_y)
        elm_table_padding_set(table, padding_x, padding_y);
        evas_object_size_hint_weight_set(table, 0.5,
                        EVAS_HINT_EXPAND);
-       //evas_object_size_hint_align_set(table, EVAS_HINT_FILL, EVAS_HINT_FILL);
-       //evas_object_size_hint_align_set(table, 0.5, EVAS_HINT_FILL);
 
        evas_object_show(table);
 
index 8e6fc5f..d87227b 100755 (executable)
@@ -278,11 +278,41 @@ bool viewmgr_pop_view(void)
                top = eina_list_data_get(vmgr->view_stack);
                top->state = VIEW_STATE_VISIBLE;
                top->view_class->show(top->view_data);
+       } else {
+               _INFO("No more views to pop. Exiting app.");
+               ui_app_exit();
+               return true;
        }
 
        return true;
 }
 
+bool viewmgr_pop_all_views(void)
+{
+       struct _view_item *top = NULL;
+
+       if (!vmgr) {
+               _ERR("View manager didn't initialized.");
+               return false;
+       }
+
+       while (vmgr->view_stack) {
+
+               top = eina_list_data_get(vmgr->view_stack);
+               top->view_class->hide(top->view_data);
+               top->state = VIEW_STATE_CREATED;
+
+               vmgr->view_stack = eina_list_remove(vmgr->view_stack, top);
+
+               if (vmgr->view_stack) {
+                       top = eina_list_data_get(vmgr->view_stack);
+                       top->state = VIEW_STATE_VISIBLE;
+                       top->view_class->show(top->view_data);
+               }
+       }
+       return true;
+}
+
 bool viewmgr_set_view_data(const char *view_id, void *view_data)
 {
        struct _view_item *view = NULL;
index 24f776b..0bb85c4 100644 (file)
@@ -37,6 +37,30 @@ struct _appdata {
        const char *name;
 };
 
+typedef struct {
+       const char *subview;
+       view_class *(*class_getter)(void);
+} subview_class_map;
+
+subview_class_map appctl_subview_values[] = {
+       {
+               .subview = "brightness",
+               .class_getter = &view_picture_brightness_get_vclass
+       },
+       {
+               .subview = "contrast",
+               .class_getter = &view_picture_contrast_get_vclass
+       },
+       {
+               .subview = "color",
+               .class_getter = &view_picture_color_get_vclass
+       },
+       {
+               .subview = "tint",
+               .class_getter = &view_picture_tint_get_vclass
+       }
+};
+
 static bool _create_picture_ui(void);
 static bool _create_system_ui(void);
 
@@ -127,7 +151,11 @@ static void _terminate(void *data)
 
 static void _app_control(app_control_h control, void *data)
 {
+       int res = APP_CONTROL_ERROR_NONE;
        struct _appdata *ad;
+       char *subview = NULL;
+       view_class *v_class = NULL;
+       int i = 0;
 
        if (!data) {
                _ERR("Get data failed.");
@@ -135,8 +163,22 @@ static void _app_control(app_control_h control, void *data)
        }
        ad = data;
 
-       if (ad->win)
-               elm_win_activate(ad->win);
+       elm_win_activate(ad->win);
+
+       res = app_control_get_extra_data(control, "subview", &subview);
+       if (APP_CONTROL_ERROR_NONE == res && subview) {
+               for(i = 0; i < ARRAY_SIZE(appctl_subview_values); i++) {
+                       if (!strcmp(appctl_subview_values[i].subview, subview)) {
+                               v_class = appctl_subview_values[i].class_getter();
+                               viewmgr_pop_all_views();
+                               if (!viewmgr_push_view(v_class->view_id))
+                                       _ERR("View %d push failed", v_class->view_id);
+                               free(subview);
+                               return;
+                       }
+               }
+               free(subview);
+       }
 
        if (!viewmgr_push_view(VIEW_BASE))
                _ERR("Push view failed.");
index 6ad62e6..ae79ae8 100755 (executable)
@@ -262,11 +262,6 @@ static Evas_Object *_create(Evas_Object *win, void *data)
                return NULL;
        }
 
-       /*release changes:*/
-       /* TODO: needed in temporary disabled component
-       _tab_order_restore();
-        */
-
        priv->base = utils_add_layout(win, GRP_VIEW_BASE, EINA_TRUE);
        if (!priv->base) {
                _ERR("Add layout failed.");
@@ -290,7 +285,8 @@ static Evas_Object *_create(Evas_Object *win, void *data)
        }
 
        for (i = 0; i < LAYOUT_MAX; i++)
-               layoutmgr_add_layout(priv->lmgr, _mdata_p[i]->get_lclass(), priv->menu[i]);
+               layoutmgr_add_layout(priv->lmgr, _mdata_p[i]->get_lclass(),
+                                                       priv->menu[i]);
 
        priv->win = win;
        priv->cur_menu = LAYOUT_MAX;