ecore_imf/wayland: Add support to get input panel language locale 82/44282/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 20 Jul 2015 12:41:51 +0000 (21:41 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 20 Jul 2015 12:44:51 +0000 (21:44 +0900)
Change-Id: I3d477d1606aea3966ef28e5bbec1bd0f51b0771d

src/modules/ecore_imf/wayland/wayland_imcontext.c
src/modules/ecore_imf/wayland/wayland_imcontext.h
src/modules/ecore_imf/wayland/wayland_module.c

index f4476f5..84f0d21 100644 (file)
@@ -53,6 +53,7 @@ struct _WaylandIMContext
 
    char *preedit_text;
    char *preedit_commit;
+   char *language;
    Eina_List *preedit_attrs;
    int32_t preedit_cursor;
 
@@ -688,11 +689,17 @@ text_input_input_panel_state(void                 *data EINA_UNUSED,
 }
 
 static void
-text_input_language(void                 *data EINA_UNUSED,
+text_input_language(void                 *data,
                     struct wl_text_input *text_input EINA_UNUSED,
                     uint32_t              serial EINA_UNUSED,
-                    const char           *language EINA_UNUSED)
+                    const char           *language)
 {
+    WaylandIMContext *imcontext = (WaylandIMContext *)data;
+
+    if (imcontext->language)
+      free(imcontext->language);
+
+    imcontext->language = strdup(language ? language : "");
 }
 
 static void
@@ -748,6 +755,12 @@ wayland_im_context_del(Ecore_IMF_Context *ctx)
      _active_ctx = NULL;
    //
 
+   if (imcontext->language)
+     {
+        free(imcontext->language);
+        imcontext->language = NULL;
+     }
+
    if (imcontext->text_input)
      wl_text_input_destroy(imcontext->text_input);
 
@@ -1076,6 +1089,16 @@ wayland_im_context_input_panel_return_key_type_set(Ecore_IMF_Context *ctx,
    imcontext->return_key_type = return_key_type;
 }
 
+EAPI void
+wayland_im_context_input_panel_language_locale_get(Ecore_IMF_Context *ctx,
+                                                   char **locale)
+{
+   WaylandIMContext *imcontext = (WaylandIMContext *)ecore_imf_context_data_get(ctx);
+
+   if (locale)
+     *locale = strdup(imcontext->language ? imcontext->language : "");
+}
+
 WaylandIMContext *wayland_im_context_new (struct wl_text_input_manager *text_input_manager)
 {
    WaylandIMContext *context = calloc(1, sizeof(WaylandIMContext));
index 00ceaad..3ced510 100644 (file)
@@ -87,6 +87,10 @@ EAPI void
 wayland_im_context_input_panel_return_key_type_set(Ecore_IMF_Context *ctx,
                                                    Ecore_IMF_Input_Panel_Return_Key_Type return_key_type);
 
+EAPI void
+wayland_im_context_input_panel_language_locale_get(Ecore_IMF_Context *ctx,
+                                                   char **locale);
+
 WaylandIMContext *wayland_im_context_new        (struct wl_text_input_manager *text_input_manager);
 
 extern int _ecore_imf_wayland_log_dom;
index b0f29bb..c6f1c7b 100644 (file)
@@ -78,7 +78,7 @@ static Ecore_IMF_Context_Class wayland_imf_class =
    wayland_im_context_input_panel_state_get,  /* input_panel_state_get */
    NULL,                                      /* input_panel_event_callback_add */
    NULL,                                      /* input_panel_event_callback_del */
-   NULL,                                      /* input_panel_language_locale_get */
+   wayland_im_context_input_panel_language_locale_get, /* input_panel_language_locale_get */
    NULL,                                      /* candidate_window_geometry_get */
    wayland_im_context_input_hint_set,         /* input_hint_set */
    NULL                                       /* bidi_direction_set */