rimmed pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=2fd84cd3103833d694b05cc76b204ea4e3333b11

commit 2fd84cd3103833d694b05cc76b204ea4e3333b11
Author: Andrii Kroitor <an.kroi...@samsung.com>
Date:   Fri Sep 16 16:56:18 2016 +0300

    tizen: add hack for spinner
    
    TIzen version of efl sends "changed" signal even when value was changed
    from code. This hack blocks "changed" signal if it was triggered by
    elm_spinner_value_set function.
---
 src/bin/Makefile.am          |  1 +
 src/bin/common/signals.c     |  4 ++++
 src/bin/common/tizen_hacks.c | 49 ++++++++++++++++++++++++++++++++++++++++++++
 src/bin/eflete.h             | 15 ++++++++++++++
 4 files changed, 69 insertions(+)

diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index 4096021..5f870cd 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -63,6 +63,7 @@ libete_a_SOURCES = \
 ../../src/bin/eflete.c \
 ../../src/bin/common/string_common.c \
 ../../src/bin/common/signals.c \
+../../src/bin/common/tizen_hacks.c \
 ../../src/bin/common/validator.c \
 ../../src/bin/common/widget_list.c \
 ../../src/bin/project_manager/group_manager.c \
diff --git a/src/bin/common/signals.c b/src/bin/common/signals.c
index 3d306d7..8540542 100644
--- a/src/bin/common/signals.c
+++ b/src/bin/common/signals.c
@@ -84,7 +84,11 @@ const Signals signals = {
      .elm = {
           .spinner = {
                .changed             = "changed",
+#if HAVE_TIZEN
+               .changed_user        = "[eflete_custom]changed,user",
+#else
                .changed_user        = "changed",
+#endif
                .drag_start          = "spinner,drag,start",
                .drag_stop           = "spinner,drag,stop",
           },
diff --git a/src/bin/common/tizen_hacks.c b/src/bin/common/tizen_hacks.c
new file mode 100644
index 0000000..62486f1
--- /dev/null
+++ b/src/bin/common/tizen_hacks.c
@@ -0,0 +1,49 @@
+/*
+ * Edje Theme Editor
+ * Copyright (C) 2013-2016 Samsung Electronics.
+ *
+ * This file is part of Edje Theme Editor.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; If not, see www.gnu.org/licenses/lgpl.html.
+ */
+
+#include "eflete.h"
+#ifdef HAVE_TIZEN
+
+static int _spinner_changed_from_code = 0;
+static void
+_tizen_spinner_changed_hack(void *data __UNUSED__, Evas_Object *obj, void *ei)
+{
+   /* don't call callback if we are setting value to spinner from code */
+   if (!_spinner_changed_from_code)
+      evas_object_smart_callback_call(obj, signals.elm.spinner.changed_user, 
ei);
+}
+
+void
+tizen_hack_spinner_value_set(Evas_Object *spinner, double val)
+{
+   assert(spinner != NULL);
+
+   _spinner_changed_from_code++;
+   _elm_spinner_value_set(spinner, val);
+   _spinner_changed_from_code--;
+}
+
+Evas_Object *
+tizen_hack_spinner_add(Evas_Object *parent)
+{
+   Evas_Object *ret = _elm_spinner_add(parent);
+   evas_object_smart_callback_add(ret, signals.elm.spinner.changed, 
_tizen_spinner_changed_hack, NULL);
+   return ret;
+}
+#endif
diff --git a/src/bin/eflete.h b/src/bin/eflete.h
index bc8b404..d763f76 100644
--- a/src/bin/eflete.h
+++ b/src/bin/eflete.h
@@ -197,4 +197,19 @@ app_shutdown(void);
 
 #include "alloc.h"
 
+
+#ifdef HAVE_TIZEN
+/* hack functions prototypes (same as original functions) */
+Evas_Object *
+tizen_hack_spinner_add(Evas_Object *parent);
+void
+tizen_hack_spinner_value_set(Evas_Object *spinner, double val);
+/* saving function pointers to use later in tizen_hack* functions to avoid 
infonote recursion on call */
+static void (* _elm_spinner_value_set)(Evas_Object *, double) __UNUSED__ = 
elm_spinner_value_set;
+static Evas_Object * (* _elm_spinner_add)(Evas_Object *)  __UNUSED__ = 
elm_spinner_add;
+/* replacing functions with hack-version */
+#define elm_spinner_value_set    tizen_hack_spinner_value_set
+#define elm_spinner_add          tizen_hack_spinner_add
+#endif
+
 #endif /* EFLETE_H */

-- 


Reply via email to