/src/wrappers/gtk/library/edited_callback.e

http://github.com/tybor/Liberty · Specman e · 88 lines · 68 code · 16 blank · 4 comment · 5 complexity · 479fe349ed4991ecd39cdb4c9f83df68 MD5 · raw file

  1. indexing
  2. description: "Generic callback for the edited signal"
  3. copyright: "[
  4. Copyright (C) 2006 eiffel-libraries team, GTK+ team and others
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. license: "LGPL v2 or later"
  19. date: "$Date:$"
  20. revision "$Revision:$"
  21. class EDITED_CALLBACK
  22. inherit CALLBACK redefine object end
  23. insert G_OBJECT_FACTORY [GTK_CELL_RENDERER_TEXT]
  24. creation make
  25. feature
  26. object: GTK_CELL_RENDERER_TEXT
  27. feature
  28. callback (arg1, arg2, instance: POINTER) is
  29. local
  30. str1, str2: STRING
  31. do
  32. debug
  33. print ("Callback: instance=") print (instance.to_string) print ("%N")
  34. end
  35. -- The following is written with the implicit requirement
  36. -- that object actually has an Eiffel wrapper.
  37. object := wrapper(instance)
  38. if arg1.is_not_null then
  39. -- FIXME: are we leaving a mem leak by doing a copy? :-/
  40. create str1.from_external_copy (arg1)
  41. end
  42. if arg2.is_not_null then
  43. -- FIXME: are we leaving a mem leak by doing a copy? :-/
  44. create str2.from_external_copy (arg2)
  45. end
  46. procedure.call ([str1, str2, object])
  47. end
  48. callback_pointer: POINTER is
  49. do
  50. Result := get_callback_pointer ($callback)
  51. ensure
  52. Result.is_not_null
  53. end
  54. connect (an_object: GTK_CELL_RENDERER_TEXT; a_procedure: PROCEDURE [ANY, TUPLE[STRING, STRING, GTK_CELL_RENDERER_TEXT]]) is
  55. do
  56. debug
  57. print ("EDITED_CALLBACK.connect (an_object=") print (an_object.to_pointer.to_string)
  58. print (" an_object.handle=") print (an_object.handle.to_string)
  59. print (") Current=") print (to_pointer.to_string)
  60. print (" Current.handle=") print (handle.to_string)
  61. print ("%N")
  62. end
  63. handler_id := g_signal_connect_closure (an_object.handle,
  64. signal_name.to_external,
  65. handle,
  66. 0 -- i.e. call it before default handler
  67. )
  68. procedure:=a_procedure
  69. end
  70. signal_name: STRING is "edited"
  71. procedure: PROCEDURE [ANY, TUPLE[STRING, STRING, GTK_CELL_RENDERER_TEXT]]
  72. end