Update list UI after select the active keyboard. 42/41042/1
authorshoum.chen@samsung.com <shoum.chen@samsung.com>
Wed, 3 Jun 2015 10:46:51 +0000 (18:46 +0800)
committerJihoon Kim <jihoon48.kim@samsung.com>
Thu, 11 Jun 2015 04:17:04 +0000 (13:17 +0900)
Change-Id: I36411d6d1f6f1a580b94218e80664287a5acc4ec
Signed-off-by: shoum.chen@samsung.com <shoum.chen@samsung.com>
im_setting_list/input_method_setting_list_ui.cpp
im_setting_selector/input_method_setting_selector.cpp
im_setting_selector/input_method_setting_selector.h
im_setting_selector/input_method_setting_selector_ui.cpp

index 6391588..675dc32 100644 (file)
@@ -62,6 +62,8 @@ typedef struct popup_cb_data_s
     void *data;
 }popup_cb_data;
 
+void im_setting_list_update_window(void *data);
+
 static void im_setting_list_text_domain_set(void)
 {
    bindtextdomain(IM_SETTING_PACKAGE, IM_SETTING_LOCALE_DIR);
@@ -138,7 +140,26 @@ static int im_setting_list_get_active_ime_index(void)
     return (iter-g_ime_info_list.begin());
 }
 
-static void im_setting_list_show_ise_selector(void)
+static void
+im_setting_list_app_control_reply_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
+{
+    if (!request || !reply) {
+        LOGD("app_control handle is null");
+        return;
+    }
+    if (result == APP_CONTROL_RESULT_SUCCEEDED) {
+        char *value = NULL;
+        int res = app_control_get_extra_data(reply, "result", &value);
+        if (APP_CONTROL_ERROR_NONE == res && NULL != value) {
+            im_setting_list_update_window(user_data);
+        }
+        if (value){
+            free(value);
+        }
+    }
+}
+
+static void im_setting_list_show_ise_selector(void *data)
 {
     int ret;
     app_control_h app_control;
@@ -164,7 +185,7 @@ static void im_setting_list_show_ise_selector(void)
       }
 
       app_control_add_extra_data(app_control, "caller", "settings");
-      ret = app_control_send_launch_request(app_control, NULL, NULL);
+      ret = app_control_send_launch_request(app_control, im_setting_list_app_control_reply_cb, data);
       if (ret != APP_CONTROL_ERROR_NONE) {
          LOGD("app_control_send_launch_request returned %d, %s\n", ret, get_error_message(ret));
          app_control_destroy(app_control);
@@ -335,7 +356,7 @@ static void im_setting_list_set_default_keyboard_item_sel_cb(void *data, Evas_Ob
 {
     Elm_Object_Item *item = (Elm_Object_Item *)event_info;
     elm_genlist_item_selected_set (item, EINA_FALSE);
-    im_setting_list_show_ise_selector();
+    im_setting_list_show_ise_selector(data);
 }
 
 static void im_setting_list_keyboard_setting_item_sel_cb(void *data, Evas_Object *obj, void *event_info)
@@ -566,7 +587,7 @@ static void im_setting_list_add_ise(void *data) {
             NULL,
             ELM_GENLIST_ITEM_NONE,
             im_setting_list_set_default_keyboard_item_sel_cb,
-            NULL);
+            data);
 
         sprintf(item_text[1].main_text, "%s", IM_SETTING_LIST_KEYBOARD_SETTING);
         Elm_Object_Item *item = elm_genlist_item_append(ad->genlist,
index 8032615..ab908af 100644 (file)
@@ -46,6 +46,7 @@ app_control(app_control_h app_control, void *data)
     if(APP_CONTROL_ERROR_NONE == res && NULL != type && strcmp(type,"settings") == 0)
     {
         ad->app_type = APP_TYPE_SETTING;
+        app_control_clone(&(ad->caller), app_control);
     }
     else
     {
@@ -86,6 +87,7 @@ app_terminate(void *data)
     appdata *ad = (appdata *)data;
     ad->app_state = APP_STATE_TERMINATE;
     im_setting_selector_app_terminate(ad);
+    app_control_destroy(ad->caller);
 }
 
 static void
index db5acd9..e559803 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <Elementary.h>
 #include <dlog.h>
+#include <app.h>
 
 #ifdef  LOG_TAG
 #undef  LOG_TAG
@@ -46,6 +47,8 @@ typedef struct _appdata {
 
     int app_state;
     int app_type;
+
+    app_control_h caller;
 }appdata;
 
 #endif /*__INPUTMETHOD_SETTING_SELECTOR_H__*/
index f807119..c71afc0 100644 (file)
@@ -36,6 +36,11 @@ static Elm_Genlist_Item_Class       *itc_im_selector = NULL;
 static Evas_Object                  *group_radio = NULL;
 static int                          g_active_ime_id = -1;
 
+typedef struct {
+    void *data;
+    int index;
+}sel_cb_data;
+
 static void im_setting_selector_text_domain_set(void)
 {
     bindtextdomain(IM_SETTING_PACKAGE, IM_SETTING_LOCALE_DIR);
@@ -166,11 +171,23 @@ static void im_setting_selector_update_radio_state(Elm_Object_Item *item, Evas_O
 
 static void im_setting_selector_ise_sel_cb(void *data, Evas_Object *obj, void *event_info)
 {
-    int index = (int)data;
+    sel_cb_data * cb_data = (sel_cb_data *)data;
+    int index = cb_data->index;
+    appdata *ad = (appdata *)(cb_data->data);
+
     Elm_Object_Item *item = (Elm_Object_Item *)event_info;
     if (!item)
         return;
     im_setting_selector_update_radio_state(item, obj, index);
+
+    if(ad->caller){
+        app_control_h reply;
+        app_control_create(&reply);
+        app_control_add_extra_data(reply, "result", g_ime_info_list[g_active_ime_id].appid);
+        app_control_reply_to_launch_request(reply, ad->caller, APP_CONTROL_RESULT_SUCCEEDED);
+        app_control_destroy(reply);
+    }
+    delete cb_data;
     ui_app_exit();
 }
 
@@ -239,13 +256,16 @@ static void im_setting_selector_add_ise(void *data) {
 
     /* keyboard list */
     for (i = 0; i < g_ime_info_list.size(); i++) {
+        sel_cb_data *cb_data = new sel_cb_data;
+        cb_data->data = data;
+        cb_data->index = i;
         elm_genlist_item_append(ad->genlist,
             itc_im_selector,
             (void *)(i),
             NULL,
             ELM_GENLIST_ITEM_NONE,
             im_setting_selector_ise_sel_cb,
-            (void *)(i));
+            (void *)(cb_data));
     }
     elm_radio_value_set(group_radio, g_active_ime_id);
 }