/src/wrappers/gtk/library/buffer_insert_text_callback.e

http://github.com/tybor/Liberty · Specman e · 79 lines · 61 code · 16 blank · 2 comment · 3 complexity · 7b93c826bc5799213c16e237f1e9024d MD5 · raw file

  1. indexing
  2. description: "Generic callback for the insert-text signal"
  3. copyright: "[
  4. Copyright (C) 2007 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 BUFFER_INSERT_TEXT_CALLBACK
  22. inherit CALLBACK
  23. redefine
  24. object
  25. end
  26. insert G_OBJECT_FACTORY [GTK_TEXT_BUFFER]
  27. creation make
  28. feature
  29. object: GTK_TEXT_BUFFER
  30. feature
  31. callback (iter, string: POINTER; len: INTEGER; instance: POINTER) is
  32. local
  33. iter_obj: GTK_TEXT_ITER
  34. input: STRING
  35. do
  36. debug
  37. print ("Callback: instance=") print (instance.to_string) print ("%N")
  38. end
  39. -- The following is written with the implicit requirement
  40. -- that object actually has an Eiffel wrapper
  41. object := wrapper(instance)
  42. create iter_obj.from_external_copy (iter)
  43. create input.from_external_copy (string)
  44. procedure.call ([iter_obj, input, object])
  45. end
  46. callback_pointer: POINTER is
  47. do
  48. Result := get_callback_pointer ($callback)
  49. ensure
  50. Result.is_not_null
  51. end
  52. connect (an_object: GTK_TEXT_BUFFER; a_procedure: PROCEDURE [ANY, TUPLE[GTK_TEXT_ITER, STRING, GTK_TEXT_BUFFER]]) is
  53. do
  54. handler_id := g_signal_connect_closure (an_object.handle,
  55. signal_name.to_external,
  56. handle,
  57. 1 -- i.e. call it before default handler
  58. )
  59. procedure := a_procedure
  60. end
  61. signal_name: STRING is "insert-text"
  62. procedure: PROCEDURE [ANY, TUPLE[GTK_TEXT_ITER, STRING, GTK_TEXT_BUFFER]]
  63. end -- class BUFFER_INSERT_TEXT_CALLBACK