[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bindings/python/python-efl] master 01/02: Elementary Fileselector: Add mime type filter methods



kuuko pushed a commit to branch master.

commit 158567f5d5e0fd191db4859b5c4df32ac1813aaf
Author: Kai Huuhko <kai.huuhko@gmail.com>
Date:   Sat Sep 14 12:36:18 2013 +0300

    Elementary Fileselector: Add mime type filter methods
---
 efl/elementary/fileselector.pxd |  3 ++-
 efl/elementary/fileselector.pyx | 45 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/efl/elementary/fileselector.pxd b/efl/elementary/fileselector.pxd
index ea98b12..d35b390 100644
--- a/efl/elementary/fileselector.pxd
+++ b/efl/elementary/fileselector.pxd
@@ -18,4 +18,5 @@ cdef extern from "Elementary.h":
     const_char *            elm_fileselector_selected_get(Evas_Object *obj)
     void                    elm_fileselector_mode_set(Evas_Object *obj, Elm_Fileselector_Mode mode)
     Elm_Fileselector_Mode   elm_fileselector_mode_get(Evas_Object *obj)
-
+    Eina_Bool               elm_fileselector_mime_types_filter_append(Evas_Object *obj, const_char *mime_types, const_char *filter_name)
+    void                    elm_fileselector_filters_clear(Evas_Object *obj)
diff --git a/efl/elementary/fileselector.pyx b/efl/elementary/fileselector.pyx
index 2fedc74..2a875f6 100644
--- a/efl/elementary/fileselector.pyx
+++ b/efl/elementary/fileselector.pyx
@@ -261,6 +261,51 @@ cdef class Fileselector(LayoutClass):
     def mode_get(self):
         return elm_fileselector_mode_get(self.obj)
 
+    def mime_types_filter_append(self, list mime_types, filter_name=None):
+        """mime_types_filter_append(list mime_types, str filter_name=None)
+
+        Append mime types filter into filter list
+
+        :param mime_types: mime types to be allowed.
+        :type mime_types: list
+        :param filter_name: The name to be displayed, ``mime_types`` will be displayed if None
+        :type filter_name: string
+        :raise RuntimeError: if setting mime_types failed
+
+        .. note:: a sub type of mime can be asterisk(*)
+        .. note:: mime type filter is only working with efreet now.
+        .. note:: first added filter will be the default filter at the moment.
+
+        :see: :py:func:efl.elementary.need.need_efreet()
+        :see: filters_clear()
+
+        :since: 1.8
+
+        """
+        mime_types_s = ",".join(mime_types)
+        if isinstance(mime_types_s, unicode): mime_types_s = PyUnicode_AsUTF8String(mime_types)
+        if isinstance(filter_name, unicode): filter_name = PyUnicode_AsUTF8String(filter_name)
+        if not elm_fileselector_mime_types_filter_append(self.obj, mime_types_s,
+            <const_char *>filter_name if filter_name is not None else NULL):
+            raise RuntimeError
+
+    def filters_clear(self):
+        """
+
+        Clear all filters registered
+
+        .. note::
+
+            If filter list is empty, file selector assume that all
+            files are matched.
+
+        :see: elm_fileselector_mime_type_filter_append()
+
+        :since: 1.8
+
+        """
+        elm_fileselector_filters_clear(self.obj)
+
     def callback_selected_add(self, func, *args, **kwargs):
         """The user has clicked on a file (when not in folders-only mode) or
         directory (when in folders-only mode). Parameter ``event_info``

--