davemds pushed a commit to branch master.

http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=ec71e46441ee43eb0416b4b4798b66f797b69a9e

commit ec71e46441ee43eb0416b4b4798b66f797b69a9e
Author: davemds <d...@gurumeditation.it>
Date:   Sat Mar 1 19:35:40 2014 +0100

    Python-EFL: new 1.9 API : Win.wm_rotation_* functions and properties
    
    NOTE: all this is UNTESTED as I do not have a rotating WM
---
 efl/elementary/window.pxd         |   9 ++++
 efl/elementary/window.pyx         | 105 +++++++++++++++++++++++++++++++++++++-
 efl/utils/conversions.pyx         |  43 ++++++++++++++++
 include/efl.utils.conversions.pxd |   2 +
 4 files changed, 158 insertions(+), 1 deletion(-)

diff --git a/efl/elementary/window.pxd b/efl/elementary/window.pxd
index a852310..7adb6c2 100644
--- a/efl/elementary/window.pxd
+++ b/efl/elementary/window.pxd
@@ -118,6 +118,15 @@ cdef extern from "Elementary.h":
     void                     elm_win_screen_position_get(Evas_Object *obj, int 
*x, int *y)
     Eina_Bool                elm_win_socket_listen(Evas_Object *obj, 
const_char *svcname, int svcnum, Eina_Bool svcsys)
 
+    Eina_Bool                
elm_win_wm_rotation_supported_get(const_Evas_Object *obj)
+    void                     
elm_win_wm_rotation_preferred_rotation_set(const_Evas_Object *obj, int rotation)
+    int                      
elm_win_wm_rotation_preferred_rotation_get(const_Evas_Object *obj)
+    void                     
elm_win_wm_rotation_available_rotations_set(Evas_Object *obj, int *rotations, 
unsigned int count)
+    Eina_Bool                
elm_win_wm_rotation_available_rotations_get(const_Evas_Object *obj, int 
**rotations, unsigned int *count)
+    void                     
elm_win_wm_rotation_manual_rotation_done_set(Evas_Object *obj, Eina_Bool set)
+    Eina_Bool                
elm_win_wm_rotation_manual_rotation_done_get(const_Evas_Object *obj)
+    void                     
elm_win_wm_rotation_manual_rotation_done(Evas_Object *obj)
+    
     # X specific call - wont't work on non-x engines (return 0)
     Ecore_X_Window           elm_win_xwindow_get(Evas_Object *obj)
     # TODO: Ecore_Wl_Window         *elm_win_wl_window_get(const_Evas_Object 
*obj)
diff --git a/efl/elementary/window.pyx b/efl/elementary/window.pyx
index 3950ad5..ad2883d 100644
--- a/efl/elementary/window.pyx
+++ b/efl/elementary/window.pyx
@@ -362,7 +362,8 @@ from libc.string cimport memcpy
 
 from object cimport Object
 from efl.utils.conversions cimport python_list_strings_to_array_of_strings, \
-    array_of_strings_to_python_list
+    array_of_strings_to_python_list, python_list_ints_to_array_of_ints, \
+    array_of_ints_to_python_list
 from efl.evas cimport Evas, evas_object_evas_get, Image as evasImage
 
 cimport enums
@@ -1572,6 +1573,108 @@ cdef class Window(Object):
         if not elm_win_socket_listen(self.obj, <const_char *>svcname, svcnum, 
svcsys):
             raise RuntimeError("Could not create a socket.")
 
+    property wm_rotation_supported:
+        """Whether window manager supports window rotation or not.
+
+        The window manager rotation allows the WM to controls the rotation of
+        application windows. It is designed to support synchronized rotation
+        for the multiple application windows at same time.
+
+        :type: bool
+
+        .. versionadded:: 1.9
+
+        """
+        def __get__(self):
+            return bool(elm_win_wm_rotation_supported_get(self.obj))
+
+    def wm_rotation_supported_get(self):
+        return bool(elm_win_wm_rotation_supported_get(self.obj))
+
+    property wm_rotation_preferred_rotation:
+        """The preferred rotation value.
+
+        This is used to set the orientation of the window to a specific fixed
+        angle in degrees, 0-360 counter-clockwise.
+
+        :type: int
+
+        .. versionadded:: 1.9
+
+        """
+        def __get__(self):
+            return elm_win_wm_rotation_preferred_rotation_get(self.obj)
+        def __set__(self, int rotation):
+            elm_win_wm_rotation_preferred_rotation_set(self.obj, rotation)
+
+    def wm_rotation_preferred_rotation_get(self):
+        return elm_win_wm_rotation_preferred_rotation_get(self.obj)
+    def wm_rotation_preferred_rotation_set(self, int rotation):
+        elm_win_wm_rotation_preferred_rotation_set(self.obj, rotation)
+
+    property wm_rotation_available_rotations:
+        """List of available window rotations.
+
+        :type: list of int
+
+        .. versionadded:: 1.9
+
+        """
+        def __get__(self):
+            cdef:
+                int *rots
+                unsigned int count
+
+            elm_win_wm_rotation_available_rotations_get(self.obj, &rots, 
&count)
+            return array_of_ints_to_python_list(rots, count)
+
+        def __set__(self, rotations):
+            cdef:
+                int *rots = python_list_ints_to_array_of_ints(rotations)
+                unsigned int count = len(rotations)
+
+            elm_win_wm_rotation_available_rotations_set(self.obj, rots, count)
+            free(rots)
+
+    def wm_rotation_available_rotations_get(self):
+        return self.wm_rotation_available_rotations
+    def wm_rotation_available_rotations_set(self, list rotations):
+        self.wm_rotation_available_rotations = rotations
+
+    property wm_rotation_manual_done:
+        """The manual rotation done mode.
+
+        This is used to set the manual rotation done mode.
+        The message of rotation done is sent to WM after rendering its canvas
+        but, if this property is set to `True`, the user should call the
+        :py:func:`wm_rotation_manual_rotation_done` explicitly to sends
+        the message.
+
+        :type: bool
+
+        .. versionadded:: 1.9
+
+        """
+        def __get__(self):
+            return bool(elm_win_wm_rotation_manual_rotation_done_get(self.obj))
+        def __set__(self, bint manual):
+            elm_win_wm_rotation_manual_rotation_done_set(self.obj, manual)
+
+    def wm_rotation_manual_done_get(self):
+        return bool(elm_win_wm_rotation_manual_rotation_done_get(self.obj))
+    def wm_rotation_manual_done_set(self, bint manual):
+        elm_win_wm_rotation_manual_rotation_done_set(self.obj, manual)
+
+    def wm_rotation_manual_rotation_done(self):
+        """wm_rotation_manual_rotation_done()
+
+        This function is used to notify the rotation done to WM manually.
+
+        .. versionadded:: 1.9
+
+        """
+        elm_win_wm_rotation_manual_rotation_done(self.obj)
+
     property xwindow_xid:
         """Returns the X Window id.
 
diff --git a/efl/utils/conversions.pyx b/efl/utils/conversions.pyx
index f8ae3a2..44eaeec 100644
--- a/efl/utils/conversions.pyx
+++ b/efl/utils/conversions.pyx
@@ -91,6 +91,49 @@ cdef const_char ** 
python_list_strings_to_array_of_strings(list strings) except
 
     return array
 
+cdef list array_of_ints_to_python_list(int *array, int array_length):
+    """
+
+    Converts an array of ints to a python list.
+
+    UNTESTED (used in Win.wm_rotation_available_rotations)
+
+    """
+    cdef:
+        list ret = list()
+        int i
+
+    for i in range(array_length):
+        ret.append(array[i])
+
+    return ret
+
+cdef int * python_list_ints_to_array_of_ints(list ints) except NULL:
+    """
+
+    Converts a python list to an array of ints.
+
+    UNTESTED (used in Win.wm_rotation_available_rotations)
+
+    Note: Remember to free the array when it's no longer needed.
+
+    """
+    cdef:
+        int *array = NULL
+        unsigned int i
+        unsigned int arr_len = len(ints)
+
+    if arr_len == 0:
+        return NULL
+
+    array = <int *>malloc(arr_len * sizeof(int))
+    if not array:
+        raise MemoryError()
+
+    for i in range(arr_len):
+        array[i] = ints[i]
+
+    return array
 
 cdef list eina_list_strings_to_python_list(const_Eina_List *lst):
     cdef:
diff --git a/include/efl.utils.conversions.pxd 
b/include/efl.utils.conversions.pxd
index 4e75995..bacb2c5 100644
--- a/include/efl.utils.conversions.pxd
+++ b/include/efl.utils.conversions.pxd
@@ -27,3 +27,5 @@ cdef list eina_list_strings_to_python_list(const_Eina_List 
*lst)
 cdef Eina_List * python_list_strings_to_eina_list(list strings)
 cdef list eina_list_objects_to_python_list(const_Eina_List *lst)
 cdef Eina_List *python_list_objects_to_eina_list(list objects)
+cdef int * python_list_ints_to_array_of_ints(list ints) except NULL
+cdef list array_of_ints_to_python_list(int *array, int array_length)

-- 


Reply via email to