summaryrefslogtreecommitdiff
path: root/efl/edje/efl.edje_object.pxi
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2014-04-06 23:48:16 +0300
committerKai Huuhko <kai.huuhko@gmail.com>2014-04-06 23:48:16 +0300
commitd6dc3a2045b756e3a633fcfdac9312dc234fa00d (patch)
tree94a803961ea49b5185d3efbffb25a576a850fcd2 /efl/edje/efl.edje_object.pxi
parent9cb0bbaf8b40e7e489ed8a28b1315a942b6f0a0f (diff)
Revert "Remove Python -> C string hacks"
A quote from Cython documentation: "The other direction, i.e. automatic encoding to C strings, is only supported for the ASCII codec (and the “default encoding”, which is runtime specific and may or may not be ASCII). This is because CPython handles the memory management in this case by keeping an encoded copy of the string alive together with the original unicode string. Otherwise, there would be no way to limit the lifetime of the encoded string in any sensible way, thus rendering any attempt to extract a C string pointer from it a dangerous endeavour." Cython plays it safe and we can't live with ASCII-only; reverting to our earlier "hacks" for string conversion. This reverts commit b547ff2aa2064b98021d6f458cfc3d44a9936544. Conflicts: efl/elementary/entry.pyx efl/elementary/object.pyx
Diffstat (limited to '')
-rw-r--r--efl/edje/efl.edje_object.pxi135
1 files changed, 114 insertions, 21 deletions
diff --git a/efl/edje/efl.edje_object.pxi b/efl/edje/efl.edje_object.pxi
index d934685..070e83c 100644
--- a/efl/edje/efl.edje_object.pxi
+++ b/efl/edje/efl.edje_object.pxi
@@ -186,6 +186,7 @@ cdef class Edje(Object):
186 :type: string 186 :type: string
187 187
188 """ 188 """
189 if isinstance(key, unicode): key = PyUnicode_AsUTF8String(key)
189 return _ctouni(edje_object_data_get(self.obj, 190 return _ctouni(edje_object_data_get(self.obj,
190 <const char *>key if key is not None else NULL)) 191 <const char *>key if key is not None else NULL))
191 192
@@ -198,6 +199,8 @@ cdef class Edje(Object):
198 :raise EdjeLoadError: if error occurred during load. 199 :raise EdjeLoadError: if error occurred during load.
199 200
200 """ 201 """
202 if isinstance(file, unicode): file = PyUnicode_AsUTF8String(file)
203 if isinstance(group, unicode): group = PyUnicode_AsUTF8String(group)
201 if edje_object_file_set(self.obj, 204 if edje_object_file_set(self.obj,
202 <const char *>file if file is not None else NULL, 205 <const char *>file if file is not None else NULL,
203 <const char *>group if group is not None else NULL) == 0: 206 <const char *>group if group is not None else NULL) == 0:
@@ -307,6 +310,8 @@ cdef class Edje(Object):
307 :parm a3: 310 :parm a3:
308 311
309 """ 312 """
313 if isinstance(color_class, unicode):
314 color_class = PyUnicode_AsUTF8String(color_class)
310 edje_object_color_class_set(self.obj, 315 edje_object_color_class_set(self.obj,
311 <const char *>color_class if color_class is not None else NULL, 316 <const char *>color_class if color_class is not None else NULL,
312 r, g, b, a, r2, g2, b2, a2, r3, g3, b3, a3) 317 r, g, b, a, r2, g2, b2, a2, r3, g3, b3, a3)
@@ -322,6 +327,8 @@ cdef class Edje(Object):
322 cdef int r, g, b, a 327 cdef int r, g, b, a
323 cdef int r2, g2, b2, a2 328 cdef int r2, g2, b2, a2
324 cdef int r3, g3, b3, a3 329 cdef int r3, g3, b3, a3
330 if isinstance(color_class, unicode):
331 color_class = PyUnicode_AsUTF8String(color_class)
325 edje_object_color_class_get(self.obj, 332 edje_object_color_class_get(self.obj,
326 <const char *>color_class if color_class is not None else NULL, 333 <const char *>color_class if color_class is not None else NULL,
327 &r, &g, &b, &a, &r2, &g2, &b2, &a2, &r3, &g3, &b3, &a3) 334 &r, &g, &b, &a, &r2, &g2, &b2, &a2, &r3, &g3, &b3, &a3)
@@ -329,6 +336,8 @@ cdef class Edje(Object):
329 336
330 def color_class_del(self, color_class): 337 def color_class_del(self, color_class):
331 "Delete a specific color class." 338 "Delete a specific color class."
339 if isinstance(color_class, unicode):
340 color_class = PyUnicode_AsUTF8String(color_class)
332 edje_object_color_class_del(self.obj, 341 edje_object_color_class_del(self.obj,
333 <const char *>color_class if color_class is not None else NULL) 342 <const char *>color_class if color_class is not None else NULL)
334 343
@@ -339,6 +348,10 @@ cdef class Edje(Object):
339 :param font: the font name 348 :param font: the font name
340 :param size: the font size 349 :param size: the font size
341 """ 350 """
351 if isinstance(text_class, unicode):
352 text_class = PyUnicode_AsUTF8String(text_class)
353 if isinstance(font, unicode):
354 font = PyUnicode_AsUTF8String(font)
342 edje_object_text_class_set(self.obj, 355 edje_object_text_class_set(self.obj,
343 <const char *>text_class if text_class is not None else NULL, 356 <const char *>text_class if text_class is not None else NULL,
344 <const char *>font if font is not None else NULL, 357 <const char *>font if font is not None else NULL,
@@ -472,6 +485,7 @@ cdef class Edje(Object):
472 485
473 def part_exists(self, part): 486 def part_exists(self, part):
474 ":rtype: bool" 487 ":rtype: bool"
488 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
475 return bool(edje_object_part_exists(self.obj, 489 return bool(edje_object_part_exists(self.obj,
476 <const char *>part if part is not None else NULL)) 490 <const char *>part if part is not None else NULL))
477 491
@@ -486,6 +500,7 @@ cdef class Edje(Object):
486 500
487 """ 501 """
488 cdef Evas_Object *obj 502 cdef Evas_Object *obj
503 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
489 obj = <Evas_Object*>edje_object_part_object_get(self.obj, 504 obj = <Evas_Object*>edje_object_part_object_get(self.obj,
490 <const char *>part if part is not None else NULL) 505 <const char *>part if part is not None else NULL)
491 return object_from_instance(obj) 506 return object_from_instance(obj)
@@ -493,6 +508,7 @@ cdef class Edje(Object):
493 def part_geometry_get(self, part): 508 def part_geometry_get(self, part):
494 ":rtype: tuple of int" 509 ":rtype: tuple of int"
495 cdef int x, y, w, h 510 cdef int x, y, w, h
511 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
496 edje_object_part_geometry_get(self.obj, 512 edje_object_part_geometry_get(self.obj,
497 <const char *>part if part is not None else NULL, 513 <const char *>part if part is not None else NULL,
498 &x, &y, &w, &h) 514 &x, &y, &w, &h)
@@ -501,6 +517,7 @@ cdef class Edje(Object):
501 def part_size_get(self, part): 517 def part_size_get(self, part):
502 ":rtype: tuple of int" 518 ":rtype: tuple of int"
503 cdef int w, h 519 cdef int w, h
520 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
504 edje_object_part_geometry_get(self.obj, 521 edje_object_part_geometry_get(self.obj,
505 <const char *>part if part is not None else NULL, 522 <const char *>part if part is not None else NULL,
506 NULL, NULL, &w, &h) 523 NULL, NULL, &w, &h)
@@ -509,6 +526,7 @@ cdef class Edje(Object):
509 def part_pos_get(self, part): 526 def part_pos_get(self, part):
510 ":rtype: tuple of int" 527 ":rtype: tuple of int"
511 cdef int x, y 528 cdef int x, y
529 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
512 edje_object_part_geometry_get(self.obj, 530 edje_object_part_geometry_get(self.obj,
513 <const char *>part if part is not None else NULL, 531 <const char *>part if part is not None else NULL,
514 &x, &y, NULL, NULL) 532 &x, &y, NULL, NULL)
@@ -540,6 +558,8 @@ cdef class Edje(Object):
540 :param text: the new text to set 558 :param text: the new text to set
541 559
542 """ 560 """
561 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
562 if isinstance(text, unicode): text = PyUnicode_AsUTF8String(text)
543 edje_object_part_text_set(self.obj, 563 edje_object_part_text_set(self.obj,
544 <const char *>part if part is not None else NULL, 564 <const char *>part if part is not None else NULL,
545 <const char *>text if text is not None else NULL) 565 <const char *>text if text is not None else NULL)
@@ -552,16 +572,19 @@ cdef class Edje(Object):
552 572
553 """ 573 """
554 cdef const char *s 574 cdef const char *s
575 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
555 return _ctouni(edje_object_part_text_get(self.obj, 576 return _ctouni(edje_object_part_text_get(self.obj,
556 <const char *>part if part is not None else NULL)) 577 <const char *>part if part is not None else NULL))
557 578
558 def part_text_select_all(self, part): 579 def part_text_select_all(self, part):
559 "Select all the text of the given TEXT or TEXTBLOCK part" 580 "Select all the text of the given TEXT or TEXTBLOCK part"
581 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
560 edje_object_part_text_select_all(self.obj, 582 edje_object_part_text_select_all(self.obj,
561 <const char *>part if part is not None else NULL) 583 <const char *>part if part is not None else NULL)
562 584
563 def part_text_select_none(self, part): 585 def part_text_select_none(self, part):
564 "Deselect all the text of the given TEXT or TEXTBLOCK part" 586 "Deselect all the text of the given TEXT or TEXTBLOCK part"
587 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
565 edje_object_part_text_select_none(self.obj, 588 edje_object_part_text_select_none(self.obj,
566 <const char *>part if part is not None else NULL) 589 <const char *>part if part is not None else NULL)
567 590
@@ -575,6 +598,9 @@ cdef class Edje(Object):
575 :see: part_text_set() 598 :see: part_text_set()
576 :see: part_text_unescaped_get() 599 :see: part_text_unescaped_get()
577 """ 600 """
601 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
602 if isinstance(text_to_escape, unicode):
603 text_to_escape = PyUnicode_AsUTF8String(text_to_escape)
578 edje_object_part_text_unescaped_set(self.obj, 604 edje_object_part_text_unescaped_set(self.obj,
579 <const char *>part if part is not None else NULL, 605 <const char *>part if part is not None else NULL,
580 <const char *>text_to_escape if text_to_escape is not None else NULL) 606 <const char *>text_to_escape if text_to_escape is not None else NULL)
@@ -589,6 +615,7 @@ cdef class Edje(Object):
589 :see: part_text_unescaped_set() 615 :see: part_text_unescaped_set()
590 """ 616 """
591 cdef char *s 617 cdef char *s
618 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
592 s = edje_object_part_text_unescaped_get(self.obj, 619 s = edje_object_part_text_unescaped_get(self.obj,
593 <const char *>part if part is not None else NULL) 620 <const char *>part if part is not None else NULL)
594 if s == NULL: 621 if s == NULL:
@@ -614,6 +641,7 @@ cdef class Edje(Object):
614 :type obj: efl.evas.Object 641 :type obj: efl.evas.Object
615 642
616 """ 643 """
644 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
617 edje_object_part_swallow(self.obj, 645 edje_object_part_swallow(self.obj,
618 <const char *>part if part is not None else NULL, obj.obj) 646 <const char *>part if part is not None else NULL, obj.obj)
619 647
@@ -623,11 +651,13 @@ cdef class Edje(Object):
623 651
624 def part_swallow_get(self, part): 652 def part_swallow_get(self, part):
625 ":rtype: efl.evas.Object" 653 ":rtype: efl.evas.Object"
654 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
626 return object_from_instance(edje_object_part_swallow_get( 655 return object_from_instance(edje_object_part_swallow_get(
627 self.obj, <const char *>part if part is not None else NULL)) 656 self.obj, <const char *>part if part is not None else NULL))
628 657
629 def part_external_object_get(self, part): 658 def part_external_object_get(self, part):
630 ":rtype: efl.evas.Object" 659 ":rtype: efl.evas.Object"
660 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
631 return object_from_instance(edje_object_part_external_object_get( 661 return object_from_instance(edje_object_part_external_object_get(
632 self.obj, <const char *>part if part is not None else NULL)) 662 self.obj, <const char *>part if part is not None else NULL))
633 663
@@ -641,8 +671,28 @@ cdef class Edje(Object):
641 :rtype: bool 671 :rtype: bool
642 """ 672 """
643 cdef Edje_External_Param p 673 cdef Edje_External_Param p
674 cdef const char *c_part
675 cdef const char *c_param
676
677 if isinstance(part, unicode):
678 str1 = PyUnicode_AsUTF8String(part)
679 c_part = str1
680 elif isinstance(part, str):
681 c_part = part
682 else:
683 raise TypeError("part must be str or unicode, found %s" %
684 type(part).__name__)
685
686 if isinstance(param, unicode):
687 str2 = PyUnicode_AsUTF8String(param)
688 c_param = str2
689 elif isinstance(param, str):
690 c_param = param
691 else:
692 raise TypeError("param must be str or unicode, found %s" %
693 type(param).__name__)
644 694
645 p.name = <const char *>param 695 p.name = c_param
646 if isinstance(value, bool): # bool is int, so keep it before! 696 if isinstance(value, bool): # bool is int, so keep it before!
647 p.type = EDJE_EXTERNAL_PARAM_TYPE_BOOL 697 p.type = EDJE_EXTERNAL_PARAM_TYPE_BOOL
648 p.i = value 698 p.i = value
@@ -655,18 +705,14 @@ cdef class Edje(Object):
655 elif isinstance(value, (str, unicode)): 705 elif isinstance(value, (str, unicode)):
656 # may be STRING or CHOICE 706 # may be STRING or CHOICE
657 p.type = edje_object_part_external_param_type_get( 707 p.type = edje_object_part_external_param_type_get(
658 self.obj, 708 self.obj, c_part, c_param)
659 <const char *>part, 709 if isinstance(value, unicode):
660 <const char *>param 710 value = PyUnicode_AsUTF8String(value)
661 ) 711 p.s = value
662 p.s = <const char *>value
663 else: 712 else:
664 raise TypeError("unsupported type %s" % type(value).__name__) 713 raise TypeError("unsupported type %s" % type(value).__name__)
665 714
666 return bool(edje_object_part_external_param_set(self.obj, 715 return bool(edje_object_part_external_param_set(self.obj, c_part, &p))
667 <const char *>part,
668 &p)
669 )
670 716
671 def part_external_param_get(self, part, param): 717 def part_external_param_get(self, part, param):
672 """Get a parameter of the external part. 718 """Get a parameter of the external part.
@@ -677,19 +723,33 @@ cdef class Edje(Object):
677 :return: *None* for errors, other values depending on the parameter type. 723 :return: *None* for errors, other values depending on the parameter type.
678 """ 724 """
679 cdef Edje_External_Param p 725 cdef Edje_External_Param p
726 cdef const char *c_part
727 cdef const char *c_param
728
729 if isinstance(part, unicode):
730 str1 = PyUnicode_AsUTF8String(part)
731 c_part = str1
732 elif isinstance(part, str):
733 c_part = part
734 else:
735 raise TypeError("part must be str or unicode, found %s" %
736 type(part).__name__)
737
738 if isinstance(param, unicode):
739 str2 = PyUnicode_AsUTF8String(param)
740 c_param = str2
741 elif isinstance(param, str):
742 c_param = param
743 else:
744 raise TypeError("param must be str or unicode, found %s" %
745 type(param).__name__)
680 746
681 p.name = <const char *>param 747 p.name = c_param
682 p.type = edje_object_part_external_param_type_get(self.obj, 748 p.type = edje_object_part_external_param_type_get(self.obj, c_part, c_param)
683 <const char *>part,
684 <const char *>param
685 )
686 if p.type >= EDJE_EXTERNAL_PARAM_TYPE_MAX: 749 if p.type >= EDJE_EXTERNAL_PARAM_TYPE_MAX:
687 return None 750 return None
688 751
689 if not edje_object_part_external_param_get(self.obj, 752 if not edje_object_part_external_param_get(self.obj, c_part, &p):
690 <const char *>part,
691 &p
692 ):
693 return None 753 return None
694 if p.type == EDJE_EXTERNAL_PARAM_TYPE_BOOL: 754 if p.type == EDJE_EXTERNAL_PARAM_TYPE_BOOL:
695 return bool(p.i) 755 return bool(p.i)
@@ -712,6 +772,7 @@ cdef class Edje(Object):
712 :param obj: the efl.evas.Object to append 772 :param obj: the efl.evas.Object to append
713 :rtype: bool 773 :rtype: bool
714 """ 774 """
775 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
715 return bool(edje_object_part_box_append(self.obj, 776 return bool(edje_object_part_box_append(self.obj,
716 <const char *>part if part is not None else NULL, obj.obj)) 777 <const char *>part if part is not None else NULL, obj.obj))
717 778
@@ -726,6 +787,7 @@ cdef class Edje(Object):
726 :param obj: the efl.evas.Object to append 787 :param obj: the efl.evas.Object to append
727 :rtype: bool 788 :rtype: bool
728 """ 789 """
790 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
729 return bool(edje_object_part_box_prepend(self.obj, 791 return bool(edje_object_part_box_prepend(self.obj,
730 <const char *>part if part is not None else NULL, obj.obj)) 792 <const char *>part if part is not None else NULL, obj.obj))
731 793
@@ -738,6 +800,7 @@ cdef class Edje(Object):
738 :param pos: the position to append the object 800 :param pos: the position to append the object
739 :rtype: bool 801 :rtype: bool
740 """ 802 """
803 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
741 return bool(edje_object_part_box_insert_at(self.obj, 804 return bool(edje_object_part_box_insert_at(self.obj,
742 <const char *>part if part is not None else NULL, obj.obj, pos)) 805 <const char *>part if part is not None else NULL, obj.obj, pos))
743 806
@@ -749,6 +812,7 @@ cdef class Edje(Object):
749 :param reference: the efl.evas.Object used as reference 812 :param reference: the efl.evas.Object used as reference
750 :rtype: bool 813 :rtype: bool
751 """ 814 """
815 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
752 return bool(edje_object_part_box_insert_before(self.obj, 816 return bool(edje_object_part_box_insert_before(self.obj,
753 <const char *>part if part is not None else NULL, 817 <const char *>part if part is not None else NULL,
754 obj.obj, reference.obj)) 818 obj.obj, reference.obj))
@@ -765,6 +829,7 @@ cdef class Edje(Object):
765 :rtype: efl.evas.Object or *None* 829 :rtype: efl.evas.Object or *None*
766 830
767 """ 831 """
832 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
768 return object_from_instance(edje_object_part_box_remove(self.obj, 833 return object_from_instance(edje_object_part_box_remove(self.obj,
769 <const char *>part if part is not None else NULL, obj.obj)) 834 <const char *>part if part is not None else NULL, obj.obj))
770 835
@@ -779,6 +844,7 @@ cdef class Edje(Object):
779 :return: the removed object 844 :return: the removed object
780 :rtype: efl.evas.Object or None 845 :rtype: efl.evas.Object or None
781 """ 846 """
847 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
782 return object_from_instance(edje_object_part_box_remove_at(self.obj, 848 return object_from_instance(edje_object_part_box_remove_at(self.obj,
783 <const char *>part if part is not None else NULL, pos)) 849 <const char *>part if part is not None else NULL, pos))
784 850
@@ -792,6 +858,7 @@ cdef class Edje(Object):
792 858
793 :rtype: bool 859 :rtype: bool
794 """ 860 """
861 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
795 return bool(edje_object_part_box_remove_all(self.obj, 862 return bool(edje_object_part_box_remove_all(self.obj,
796 <const char *>part if part is not None else NULL, clear)) 863 <const char *>part if part is not None else NULL, clear))
797 864
@@ -807,6 +874,7 @@ cdef class Edje(Object):
807 874
808 :rtype: bool 875 :rtype: bool
809 """ 876 """
877 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
810 return bool(edje_object_part_table_pack(self.obj, 878 return bool(edje_object_part_table_pack(self.obj,
811 <const char *>part if part is not None else NULL, 879 <const char *>part if part is not None else NULL,
812 child.obj, col, row, colspan, rowspan)) 880 child.obj, col, row, colspan, rowspan))
@@ -819,6 +887,7 @@ cdef class Edje(Object):
819 887
820 :rtype: bool 888 :rtype: bool
821 """ 889 """
890 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
822 return bool(edje_object_part_table_unpack(self.obj, 891 return bool(edje_object_part_table_unpack(self.obj,
823 <const char *>part if part is not None else NULL, 892 <const char *>part if part is not None else NULL,
824 child.obj)) 893 child.obj))
@@ -831,6 +900,7 @@ cdef class Edje(Object):
831 :rtype: tuple of int 900 :rtype: tuple of int
832 """ 901 """
833 cdef int c, r 902 cdef int c, r
903 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
834 edje_object_part_table_col_row_size_get(self.obj, 904 edje_object_part_table_col_row_size_get(self.obj,
835 <const char *>part if part is not None else NULL, &c, &r) 905 <const char *>part if part is not None else NULL, &c, &r)
836 return (c, r) 906 return (c, r)
@@ -845,6 +915,7 @@ cdef class Edje(Object):
845 915
846 :rtype: bool 916 :rtype: bool
847 """ 917 """
918 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
848 return bool(edje_object_part_table_clear(self.obj, 919 return bool(edje_object_part_table_clear(self.obj,
849 <const char *>part if part is not None else NULL, clear)) 920 <const char *>part if part is not None else NULL, clear))
850 921
@@ -858,6 +929,7 @@ cdef class Edje(Object):
858 :return: the object ath the given position 929 :return: the object ath the given position
859 :rtype: efl.evas.Object 930 :rtype: efl.evas.Object
860 """ 931 """
932 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
861 return object_from_instance(edje_object_part_table_child_get(self.obj, 933 return object_from_instance(edje_object_part_table_child_get(self.obj,
862 <const char *>part if part is not None else NULL, row, column)) 934 <const char *>part if part is not None else NULL, row, column))
863 935
@@ -865,12 +937,14 @@ cdef class Edje(Object):
865 ":rtype: (name, value)" 937 ":rtype: (name, value)"
866 cdef double sv 938 cdef double sv
867 cdef const char *sn 939 cdef const char *sn
940 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
868 sn = edje_object_part_state_get(self.obj, 941 sn = edje_object_part_state_get(self.obj,
869 <const char *>part if part is not None else NULL, &sv) 942 <const char *>part if part is not None else NULL, &sv)
870 return (_ctouni(sn), sv) 943 return (_ctouni(sn), sv)
871 944
872 def part_drag_dir_get(self, part): 945 def part_drag_dir_get(self, part):
873 ":rtype: int" 946 ":rtype: int"
947 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
874 return edje_object_part_drag_dir_get(self.obj, 948 return edje_object_part_drag_dir_get(self.obj,
875 <const char *>part if part is not None else NULL) 949 <const char *>part if part is not None else NULL)
876 950
@@ -879,12 +953,14 @@ cdef class Edje(Object):
879 :param dx: 953 :param dx:
880 :param dy: 954 :param dy:
881 """ 955 """
956 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
882 edje_object_part_drag_value_set(self.obj, 957 edje_object_part_drag_value_set(self.obj,
883 <const char *>part if part is not None else NULL, dx, dy) 958 <const char *>part if part is not None else NULL, dx, dy)
884 959
885 def part_drag_value_get(self, part): 960 def part_drag_value_get(self, part):
886 ":rtype: tuple of float" 961 ":rtype: tuple of float"
887 cdef double dx, dy 962 cdef double dx, dy
963 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
888 edje_object_part_drag_value_get(self.obj, 964 edje_object_part_drag_value_get(self.obj,
889 <const char *>part if part is not None else NULL, &dx, &dy) 965 <const char *>part if part is not None else NULL, &dx, &dy)
890 return (dx, dy) 966 return (dx, dy)
@@ -894,12 +970,14 @@ cdef class Edje(Object):
894 :param dw: 970 :param dw:
895 :param dh: 971 :param dh:
896 """ 972 """
973 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
897 edje_object_part_drag_size_set(self.obj, 974 edje_object_part_drag_size_set(self.obj,
898 <const char *>part if part is not None else NULL, dw, dh) 975 <const char *>part if part is not None else NULL, dw, dh)
899 976
900 def part_drag_size_get(self, part): 977 def part_drag_size_get(self, part):
901 ":rtype: tuple of float" 978 ":rtype: tuple of float"
902 cdef double dw, dh 979 cdef double dw, dh
980 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
903 edje_object_part_drag_size_get(self.obj, 981 edje_object_part_drag_size_get(self.obj,
904 <const char *>part if part is not None else NULL, &dw, &dh) 982 <const char *>part if part is not None else NULL, &dw, &dh)
905 return (dw, dh) 983 return (dw, dh)
@@ -909,32 +987,38 @@ cdef class Edje(Object):
909 :param dx: 987 :param dx:
910 :param dy: 988 :param dy:
911 """ 989 """
990 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
912 edje_object_part_drag_step_set(self.obj, 991 edje_object_part_drag_step_set(self.obj,
913 <const char *>part if part is not None else NULL, dx, dy) 992 <const char *>part if part is not None else NULL, dx, dy)
914 993
915 def part_drag_step_get(self, part): 994 def part_drag_step_get(self, part):
916 ":rtype: tuple of float" 995 ":rtype: tuple of float"
917 cdef double dx, dy 996 cdef double dx, dy
997 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
918 edje_object_part_drag_step_get(self.obj, 998 edje_object_part_drag_step_get(self.obj,
919 <const char *>part if part is not None else NULL, &dx, &dy) 999 <const char *>part if part is not None else NULL, &dx, &dy)
920 return (dx, dy) 1000 return (dx, dy)
921 1001
922 def part_drag_step(self, part, double dx, double dy): 1002 def part_drag_step(self, part, double dx, double dy):
1003 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
923 edje_object_part_drag_step(self.obj, 1004 edje_object_part_drag_step(self.obj,
924 <const char *>part if part is not None else NULL, dx, dy) 1005 <const char *>part if part is not None else NULL, dx, dy)
925 1006
926 def part_drag_page_set(self, part, double dx, double dy): 1007 def part_drag_page_set(self, part, double dx, double dy):
1008 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
927 edje_object_part_drag_page_set(self.obj, 1009 edje_object_part_drag_page_set(self.obj,
928 <const char *>part if part is not None else NULL, dx, dy) 1010 <const char *>part if part is not None else NULL, dx, dy)
929 1011
930 def part_drag_page_get(self, part): 1012 def part_drag_page_get(self, part):
931 ":rtype: tuple of float" 1013 ":rtype: tuple of float"
932 cdef double dx, dy 1014 cdef double dx, dy
1015 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
933 edje_object_part_drag_page_get(self.obj, 1016 edje_object_part_drag_page_get(self.obj,
934 <const char *>part if part is not None else NULL, &dx, &dy) 1017 <const char *>part if part is not None else NULL, &dx, &dy)
935 return (dx, dy) 1018 return (dx, dy)
936 1019
937 def part_drag_page(self, part, double dx, double dy): 1020 def part_drag_page(self, part, double dx, double dy):
1021 if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
938 edje_object_part_drag_page(self.obj, 1022 edje_object_part_drag_page(self.obj,
939 <const char *>part if part is not None else NULL, dx, dy) 1023 <const char *>part if part is not None else NULL, dx, dy)
940 1024
@@ -950,6 +1034,7 @@ cdef class Edje(Object):
950 1034
951 cdef void message_send_str(self, int id, data): 1035 cdef void message_send_str(self, int id, data):
952 cdef Edje_Message_String m 1036 cdef Edje_Message_String m
1037 if isinstance(data, unicode): data = PyUnicode_AsUTF8String(data)
953 m.str = <char *>data if data is not None else NULL 1038 m.str = <char *>data if data is not None else NULL
954 edje_object_message_send(self.obj, EDJE_MESSAGE_STRING, id, <void*>&m) 1039 edje_object_message_send(self.obj, EDJE_MESSAGE_STRING, id, <void*>&m)
955 1040
@@ -973,6 +1058,7 @@ cdef class Edje(Object):
973 1058
974 cdef void message_send_str_int(self, int id, s, int i): 1059 cdef void message_send_str_int(self, int id, s, int i):
975 cdef Edje_Message_String_Int m 1060 cdef Edje_Message_String_Int m
1061 if isinstance(s, unicode): s = PyUnicode_AsUTF8String(s)
976 m.str = <char *>s if s is not None else NULL 1062 m.str = <char *>s if s is not None else NULL
977 m.val = i 1063 m.val = i
978 edje_object_message_send(self.obj, EDJE_MESSAGE_STRING_INT, id, 1064 edje_object_message_send(self.obj, EDJE_MESSAGE_STRING_INT, id,
@@ -980,6 +1066,7 @@ cdef class Edje(Object):
980 1066
981 cdef void message_send_str_float(self, int id, s, float f): 1067 cdef void message_send_str_float(self, int id, s, float f):
982 cdef Edje_Message_String_Float m 1068 cdef Edje_Message_String_Float m
1069 if isinstance(s, unicode): s = PyUnicode_AsUTF8String(s)
983 m.str = <char *>s if s is not None else NULL 1070 m.str = <char *>s if s is not None else NULL
984 m.val = f 1071 m.val = f
985 edje_object_message_send(self.obj, EDJE_MESSAGE_STRING_FLOAT, id, 1072 edje_object_message_send(self.obj, EDJE_MESSAGE_STRING_FLOAT, id,
@@ -993,6 +1080,7 @@ cdef class Edje(Object):
993 m = <Edje_Message_String_Int_Set*>PyMem_Malloc( 1080 m = <Edje_Message_String_Int_Set*>PyMem_Malloc(
994 sizeof(Edje_Message_String_Int_Set) + (count - 1) * sizeof(int)) 1081 sizeof(Edje_Message_String_Int_Set) + (count - 1) * sizeof(int))
995 1082
1083 if isinstance(s, unicode): s = PyUnicode_AsUTF8String(s)
996 m.str = <char *>s if s is not None else NULL 1084 m.str = <char *>s if s is not None else NULL
997 m.count = count 1085 m.count = count
998 i = 0 1086 i = 0
@@ -1013,6 +1101,7 @@ cdef class Edje(Object):
1013 sizeof(Edje_Message_String_Float_Set) + 1101 sizeof(Edje_Message_String_Float_Set) +
1014 (count - 1) * sizeof(double)) 1102 (count - 1) * sizeof(double))
1015 1103
1104 if isinstance(s, unicode): s = PyUnicode_AsUTF8String(s)
1016 m.str = <char *>s if s is not None else NULL 1105 m.str = <char *>s if s is not None else NULL
1017 m.count = count 1106 m.count = count
1018 i = 0 1107 i = 0
@@ -1073,7 +1162,6 @@ cdef class Edje(Object):
1073 elif isinstance(head, float): 1162 elif isinstance(head, float):
1074 self.message_send_float_set(id, data) 1163 self.message_send_float_set(id, data)
1075 elif isinstance(head, str): 1164 elif isinstance(head, str):
1076 # FIXME: Unicode?
1077 if issubclass(item_type, str): 1165 if issubclass(item_type, str):
1078 self.message_send_str_set(id, data) 1166 self.message_send_str_set(id, data)
1079 elif item_type == int or item_type == long: 1167 elif item_type == int or item_type == long:
@@ -1107,7 +1195,6 @@ cdef class Edje(Object):
1107 elif isinstance(data, float): 1195 elif isinstance(data, float):
1108 self.message_send_float(id, data) 1196 self.message_send_float(id, data)
1109 elif isinstance(data, str): 1197 elif isinstance(data, str):
1110 # FIXME: Unicode?
1111 self.message_send_str(id, data) 1198 self.message_send_str(id, data)
1112 elif isinstance(data, (tuple, list)): 1199 elif isinstance(data, (tuple, list)):
1113 if len(data) < 1: 1200 if len(data) < 1:
@@ -1174,6 +1261,8 @@ cdef class Edje(Object):
1174 d = self._signal_callbacks.setdefault(emission, {}) 1261 d = self._signal_callbacks.setdefault(emission, {})
1175 lst = d.setdefault(source, []) 1262 lst = d.setdefault(source, [])
1176 if not lst: 1263 if not lst:
1264 if isinstance(emission, unicode): emission = PyUnicode_AsUTF8String(emission)
1265 if isinstance(source, unicode): source = PyUnicode_AsUTF8String(source)
1177 edje_object_signal_callback_add(self.obj, 1266 edje_object_signal_callback_add(self.obj,
1178 <const char *>emission if emission is not None else NULL, 1267 <const char *>emission if emission is not None else NULL,
1179 <const char *>source if source is not None else NULL, 1268 <const char *>source if source is not None else NULL,
@@ -1205,6 +1294,8 @@ cdef class Edje(Object):
1205 d.pop(source) 1294 d.pop(source)
1206 if not d: 1295 if not d:
1207 self._signal_callbacks.pop(emission) 1296 self._signal_callbacks.pop(emission)
1297 if isinstance(emission, unicode): emission = PyUnicode_AsUTF8String(emission)
1298 if isinstance(source, unicode): source = PyUnicode_AsUTF8String(source)
1208 edje_object_signal_callback_del(self.obj, 1299 edje_object_signal_callback_del(self.obj,
1209 <const char *>emission if emission is not None else NULL, 1300 <const char *>emission if emission is not None else NULL,
1210 <const char *>source if source is not None else NULL, 1301 <const char *>source if source is not None else NULL,
@@ -1212,6 +1303,8 @@ cdef class Edje(Object):
1212 1303
1213 def signal_emit(self, emission, source): 1304 def signal_emit(self, emission, source):
1214 "Emit signal with ``emission`` and ``source``" 1305 "Emit signal with ``emission`` and ``source``"
1306 if isinstance(emission, unicode): emission = PyUnicode_AsUTF8String(emission)
1307 if isinstance(source, unicode): source = PyUnicode_AsUTF8String(source)
1215 edje_object_signal_emit(self.obj, 1308 edje_object_signal_emit(self.obj,
1216 <const char *>emission if emission is not None else NULL, 1309 <const char *>emission if emission is not None else NULL,
1217 <const char *>source if source is not None else NULL) 1310 <const char *>source if source is not None else NULL)