/src/wrappers/gtk/library/gtk_toggle_action.e

http://github.com/tybor/Liberty · Specman e · 134 lines · 85 code · 26 blank · 23 comment · 2 complexity · 2328fba8c970f7951687e96d06f4f9de MD5 · raw file

  1. indexing
  2. description: "GtkToggleAction — An action which can be toggled between two states"
  3. copyright: "[
  4. Copyright (C) 2006 Paolo Redaelli, GTK+ team
  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. -- Description: A GtkToggleAction corresponds roughly to a
  19. -- GtkCheckMenuItem. It has an "active" state specifying
  20. -- whether the action has been checked or not.
  21. class GTK_TOGGLE_ACTION
  22. inherit GTK_ACTION redefine make, struct_size end
  23. creation from_external_pointer
  24. feature {} -- Creation
  25. make (a_name, a_label, a_tooltip, a_stock_id: STRING) is
  26. -- Creates a new GtkToggleAction object. To add the action to
  27. -- a GtkActionGroup and set the accelerator for the action,
  28. -- call `GTK_ACTION_GROUP.add_action_with_accel'.
  29. -- `a_name' A unique name for the action; `a_label' the label
  30. -- displayed in menu items and on buttons; `a_tooltip' a
  31. -- tooltip for the action; `a_stock_id' the stock icon to
  32. -- display in widgets representing the action
  33. do
  34. from_external_pointer (gtk_toggle_action_new (a_name.to_external, a_label.to_external,
  35. a_tooltip.to_external,a_stock_id.to_external))
  36. end
  37. feature
  38. action_toggled is
  39. -- Emits the "toggled" signal on the toggle action.
  40. do
  41. gtk_toggle_action_toggled (handle)
  42. end
  43. set_active is
  44. -- Sets the checked state on the toggle action.
  45. do
  46. gtk_toggle_action_set_active (handle, 1)
  47. ensure active: is_active
  48. end
  49. set_inactive is
  50. -- Sets the checked state on the toggle action to inactive.
  51. do
  52. gtk_toggle_action_set_active (handle, 0)
  53. ensure inactive: not is_active
  54. end
  55. is_active: BOOLEAN is
  56. -- Is toggle action checked?
  57. do
  58. Result:=gtk_toggle_action_get_active(handle).to_boolean
  59. end
  60. draw_as_radio is
  61. -- the action should have proxies like a radio action. TODO:
  62. -- provide a better description.
  63. do
  64. gtk_toggle_action_set_draw_as_radio (handle,1)
  65. ensure drawn_as_radio: is_drawn_as_radio
  66. end
  67. undraw_as_radio is
  68. -- the action should not have proxies like a radio
  69. -- action. TODO: provide a better description.
  70. do
  71. gtk_toggle_action_set_draw_as_radio (handle,0)
  72. ensure not_drawn_as_radio: not is_drawn_as_radio
  73. end
  74. is_drawn_as_radio: BOOLEAN is
  75. -- Should the action have proxies like a radio action?
  76. do
  77. Result:=gtk_toggle_action_get_draw_as_radio(handle).to_boolean
  78. end
  79. feature -- TODO: The "toggled" signal
  80. -- void user_function (GtkToggleAction *toggleaction,
  81. -- gpointer user_data) : Run first
  82. -- toggleaction : the object which received the signal.
  83. -- user_data : user data set when the signal handler was connected.
  84. feature -- struct size
  85. struct_size: INTEGER is
  86. external "C inline use <gtk/gtk.h>"
  87. alias "sizeof(GtkToggleAction)"
  88. end
  89. feature {} -- External calls
  90. gtk_toggle_action_new (name_str, label_str, tooltip_str, stock_id_str : POINTER): POINTER is -- GtkToggleAction*
  91. external "C use <gtk/gtk.h>"
  92. end
  93. gtk_toggle_action_toggled (toggle_action: POINTER) is
  94. external "C use <gtk/gtk.h>"
  95. end
  96. gtk_toggle_action_set_active (toggle_action: POINTER; active_bool: INTEGER) is
  97. external "C use <gtk/gtk.h>"
  98. end
  99. gtk_toggle_action_get_active (toggle_action: POINTER): INTEGER is -- gboolean
  100. external "C use <gtk/gtk.h>"
  101. end
  102. gtk_toggle_action_set_draw_as_radio (toggle_action: POINTER; draw_as_radio_bool: INTEGER) is
  103. external "C use <gtk/gtk.h>"
  104. end
  105. gtk_toggle_action_get_draw_as_radio (toggle_action: POINTER): INTEGER is
  106. external "C use <gtk/gtk.h>"
  107. end
  108. end -- class GTK_TOGGLE_ACTION