Reduce the duplicated code to create window 73/249073/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 7 Dec 2020 01:32:01 +0000 (10:32 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 7 Dec 2020 01:32:01 +0000 (10:32 +0900)
Change-Id: I29601428a6070e663ac47924519dc1dda1c81b7c
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
common/input_method_setting_win.cpp [new file with mode: 0644]
common/input_method_setting_win.h [new file with mode: 0644]
im_setting_list/CMakeLists.txt
im_setting_list/input_method_setting_list_ui.cpp
im_setting_selector/CMakeLists.txt
im_setting_selector/input_method_setting_selector_ui.cpp

diff --git a/common/input_method_setting_win.cpp b/common/input_method_setting_win.cpp
new file mode 100644 (file)
index 0000000..df0154c
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include "input_method_setting_win.h"
+
+Evas_Object *im_setting_window_create(const char *name, Eina_Bool allow_rotation, Eina_Bool alpha)
+{
+    Evas_Object *win = elm_win_add(NULL, name, ELM_WIN_BASIC);
+    if (win) {
+        elm_win_title_set(win, name);
+        elm_win_borderless_set(win, EINA_TRUE);
+        elm_win_alpha_set(win, alpha);
+        elm_win_conformant_set(win, EINA_TRUE);
+        elm_win_autodel_set(win, EINA_TRUE);
+        elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW);
+        elm_win_indicator_opacity_set(win, ELM_WIN_INDICATOR_OPAQUE);
+
+        if (allow_rotation) {
+            if (elm_win_wm_rotation_supported_get(win)) {
+                int rots[4] = {0, 90, 180, 270};
+                elm_win_wm_rotation_available_rotations_set(win, rots, 4);
+            }
+        }
+    }
+
+    return win;
+}
+
diff --git a/common/input_method_setting_win.h b/common/input_method_setting_win.h
new file mode 100644 (file)
index 0000000..476d644
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <Elementary.h>
+
+#ifndef __INPUTMETHOD_SETTING_WINDOW_H
+#define __INPUTMETHOD_SETTING_WINDOW_H
+
+Evas_Object *im_setting_window_create(const char *name, Eina_Bool allow_rotation, Eina_Bool alpha);
+
+#endif
index a995ae9..6599941 100644 (file)
@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
 SET(SRC_LIST
     ../common/input_method_setting_genlist.cpp
+    ../common/input_method_setting_win.cpp
     ../common/ime_info.cpp
     input_method_setting_list_ui.cpp
     input_method_setting_list.cpp
index 32ad7cb..46e2839 100644 (file)
@@ -18,6 +18,7 @@
 #include "input_method_setting_list_ui.h"
 #include "input_method_setting_list_popup_view.h"
 #include "../common/input_method_setting_genlist.h"
+#include "../common/input_method_setting_win.h"
 #include "../common/ime_info.h"
 
 #include <string>
@@ -97,22 +98,8 @@ static void im_setting_list_text_domain_set(void)
 static Evas_Object *
 im_setting_list_main_window_create(const char *name, int app_type)
 {
-    Evas_Object *eo = NULL;
-    eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
-    if (eo) {
-        elm_win_title_set(eo, name);
-        elm_win_borderless_set(eo, EINA_TRUE);
-        elm_win_alpha_set(eo, EINA_FALSE);
-        elm_win_conformant_set(eo, EINA_TRUE);
-        elm_win_autodel_set(eo, EINA_TRUE);
-        elm_win_indicator_mode_set(eo, ELM_WIN_INDICATOR_SHOW);
-        elm_win_indicator_opacity_set(eo, ELM_WIN_INDICATOR_OPAQUE);
-
-        if (app_type != APP_TYPE_SETTING_NO_ROTATION) {
-            int rots[4] = {0, 90, 180, 270};
-            elm_win_wm_rotation_available_rotations_set(eo, rots, 4);
-        }
-    }
+    Evas_Object *eo = im_setting_window_create(name, app_type == APP_TYPE_SETTING_NO_ROTATION ? EINA_FALSE : EINA_TRUE, EINA_FALSE);
+
     return eo;
 }
 
index b5cee92..d55b3a2 100644 (file)
@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
 SET(SRC_LIST
     ../common/input_method_setting_genlist.cpp
+    ../common/input_method_setting_win.cpp
     ../common/ime_info.cpp
     input_method_setting_selector_ui.cpp
     input_method_setting_selector.cpp
index a96c81e..c9a9621 100644 (file)
@@ -22,6 +22,7 @@
 #include <tzplatform_config.h>
 #include <inputmethod_manager.h>
 #include "../common/input_method_setting_genlist.h"
+#include "../common/input_method_setting_win.h"
 #include "../common/ime_info.h"
 
 #define IM_SETTING_SELECTOR_PACKAGE        PACKAGE
@@ -45,37 +46,23 @@ static void im_setting_selector_text_domain_set(void)
 static Evas_Object *
 im_setting_selector_main_window_create(const char *name)
 {
-    Evas_Object *eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
-    if (eo) {
-        Evas *e;
-        Ecore_Evas *ee;
-        Evas_Coord w = -1, h = -1;
-
-        elm_win_title_set(eo, name);
-        elm_win_borderless_set(eo, EINA_TRUE);
-        elm_win_alpha_set(eo, EINA_TRUE);
-        elm_win_conformant_set(eo, EINA_TRUE);
-        elm_win_autodel_set(eo, EINA_TRUE);
-        elm_win_indicator_mode_set(eo, ELM_WIN_INDICATOR_SHOW);
-        elm_win_indicator_opacity_set(eo, ELM_WIN_INDICATOR_OPAQUE);
-
-        if (elm_win_wm_rotation_supported_get(eo)) {
-            int rots[4] = {0, 90, 180, 270};
-            elm_win_wm_rotation_available_rotations_set(eo, rots, 4);
-        }
-        e = evas_object_evas_get(eo);
-        if (e) {
-            ee = ecore_evas_ecore_evas_get(e);
-            if (ee) {
-                ecore_evas_name_class_set(ee, "SYSTEM_POPUP", "SYSTEM_POPUP");
-            }
+    Evas *e;
+    Ecore_Evas *ee;
+    Evas_Coord w = -1, h = -1;
+    Evas_Object *eo = im_setting_window_create(name, EINA_TRUE, EINA_TRUE);
+    e = evas_object_evas_get(eo);
+    if (e) {
+        ee = ecore_evas_ecore_evas_get(e);
+        if (ee) {
+            ecore_evas_name_class_set(ee, "SYSTEM_POPUP", "SYSTEM_POPUP");
         }
+    }
 
-        elm_win_screen_size_get(eo, NULL, NULL, &w, &h);
-        if (w > 0 && h > 0) {
-            evas_object_resize(eo, w, h);
-        }
+    elm_win_screen_size_get(eo, NULL, NULL, &w, &h);
+    if (w > 0 && h > 0) {
+        evas_object_resize(eo, w, h);
     }
+
     return eo;
 }