Elementary: Revert several RuntimeWarnings back to 1.7 behavior

The methods in entry, icon and object now return a bool value like they
used to do in 1.7.
This commit is contained in:
Kai Huuhko 2013-12-02 21:44:43 +02:00
parent 5d4016710d
commit 7a3883f5e2
3 changed files with 33 additions and 32 deletions

View File

@ -1970,11 +1970,11 @@ cdef class Entry(Object):
:param selection: Selection type for copying and pasting
:param format: Selection format
:raise RuntimeWarning: if getting cnp data fails.
:return bool: Whether getting cnp data is successful or not.
"""
if not elm_cnp_selection_get(self.obj, selection, format, NULL, NULL):
raise RuntimeWarning("Could not get cnp data from widget.")
return bool(elm_cnp_selection_get(
self.obj, selection, format, NULL, NULL))
def callback_changed_add(self, func, *args, **kwargs):

View File

@ -218,11 +218,15 @@ cdef class Icon(Image):
.. seealso:: Image.file
:type: string
:raise RuntimeWarning: when setting the standard icon fails
:raise RuntimeWarning: when setting the standard name fails.
:return bool: For 1.7 compatibility standard_set() returns a bool value
that tells whether setting the standard name was succesful or not.
"""
def __get__(self):
return _ctouni(elm_icon_standard_get(self.obj))
def __set__(self, name):
if isinstance(name, unicode): name = PyUnicode_AsUTF8String(name)
if not elm_icon_standard_set(self.obj,
@ -231,9 +235,8 @@ cdef class Icon(Image):
def standard_set(self, name):
if isinstance(name, unicode): name = PyUnicode_AsUTF8String(name)
if not elm_icon_standard_set(self.obj,
<const_char *>name if name is not None else NULL):
raise RuntimeWarning("Setting standard icon failed")
return elm_icon_standard_set(self.obj,
<const_char *>name if name is not None else NULL)
def standard_get(self):
return _ctouni(elm_icon_standard_get(self.obj))
@ -245,6 +248,7 @@ cdef class Icon(Image):
"""
def __get__(self):
return elm_icon_order_lookup_get(self.obj)
def __set__(self, order):
elm_icon_order_lookup_set(self.obj, order)

View File

@ -195,31 +195,27 @@ Defines the kind of action associated with the drop data if for XDND
"""
from cpython cimport PyUnicode_AsUTF8String
from cpython cimport PyObject, Py_INCREF, Py_DECREF, PyObject_GetAttr, \
PyObject_GetBuffer, PyBuffer_Release, PyBUF_SIMPLE, PyObject_CheckBuffer, \
PyUnicode_AsUTF8String
from efl.eo cimport _object_mapping_register
from efl.utils.conversions cimport _ctouni
from efl.utils.conversions cimport _ctouni, eina_list_objects_to_python_list
from efl.utils.deprecated cimport DEPRECATED
from efl.evas cimport Object as evasObject
from cpython cimport PyObject, Py_INCREF, Py_DECREF, PyObject_GetAttr, \
PyObject_GetBuffer, PyBuffer_Release, PyBUF_SIMPLE, PyObject_CheckBuffer
from efl.evas cimport EventKeyDown, EventKeyUp, EventMouseWheel, \
evas_object_smart_callback_add, evas_object_smart_callback_del
include "cnp_callbacks.pxi"
include "tooltips.pxi"
from efl.utils.conversions cimport eina_list_objects_to_python_list
from efl.utils.deprecated cimport DEPRECATED
from efl.evas cimport EventKeyDown, EventKeyUp, EventMouseWheel
from efl.evas cimport evas_object_smart_callback_add
from efl.evas cimport evas_object_smart_callback_del
cimport efl.evas.enums as evasenums
from theme cimport Theme
import logging
log = logging.getLogger("elementary")
import traceback
from theme cimport Theme
cimport efl.evas.enums as evasenums
cimport enums
ELM_FOCUS_PREVIOUS = enums.ELM_FOCUS_PREVIOUS
@ -1744,20 +1740,23 @@ cdef class Object(evasObject):
:param buf: The data selected
:type buf: An object that supports the new buffer interface
:raise RuntimeWarning: if setting cnp data fails.
:return bool: Whether setting cnp data was successful or not.
"""
cdef Py_buffer view
cdef:
Py_buffer view
bint ret
if isinstance(buf, unicode): buf = PyUnicode_AsUTF8String(buf)
if not PyObject_CheckBuffer(buf):
raise TypeError(
"The provided object does not support buffer interface."
)
PyObject_GetBuffer(buf, &view, PyBUF_SIMPLE)
if not elm_cnp_selection_set(self.obj, selection, format,
<const_void *>view.buf, view.itemsize):
raise RuntimeWarning("Could not set cnp data for widget.")
ret = elm_cnp_selection_set(self.obj, selection, format,
<const_void *>view.buf, view.itemsize)
PyBuffer_Release(&view)
return ret
def cnp_selection_get(self, selection, format, datacb, udata = None):
"""Retrieve data from a widget that has a selection.
@ -1772,16 +1771,15 @@ cdef class Object(evasObject):
:param datacb: The user data callback if the target widget isn't elm_entry
:param udata: The user data pointer for ``datacb``
:raise RuntimeWarning: if getting cnp data fails.
:return bool: Whether getting cnp data was successful or not.
"""
if not callable(datacb):
raise TypeError("datacb is not callable.")
self.cnp_drop_cb = datacb
self.cnp_drop_data = udata
if not elm_cnp_selection_get(self.obj, selection, format,
py_elm_drop_cb, <void *>self):
raise RuntimeWarning("Could not get cnp data from widget.")
return bool(elm_cnp_selection_get(self.obj, selection, format,
py_elm_drop_cb, <void *>self))
def cnp_selection_clear(self, Elm_Sel_Type selection):
"""Clear the selection data of a widget.
@ -1791,11 +1789,10 @@ cdef class Object(evasObject):
:param selection: Selection type for copying and pasting
:type selection: :ref:`Elm_Object_Sel_Type`
:raise RuntimeWarning: if clearing cnp data fails.
:return bool: Whether clearing cnp data was successful or not.
"""
if not elm_object_cnp_selection_clear(self.obj, selection):
raise RuntimeWarning("Could not clear cnp data from widget.")
return bool(elm_object_cnp_selection_clear(self.obj, selection))
def cnp_selection_loss_callback_set(self, Elm_Sel_Type selection, func,
data = None):