/src/wrappers/gtk/library/gtk_status_bar.e

http://github.com/tybor/Liberty · Specman e · 247 lines · 136 code · 49 blank · 62 comment · 2 complexity · c04df00f71d54832e7bae0cb583c386b MD5 · raw file

  1. indexing
  2. description: "Report messages of minor importance to the user"
  3. copyright: "[
  4. Copyright (C) 2006 eiffel-libraries team, 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. date: "$Date:$"
  19. revision: "$Revision:$"
  20. class GTK_STATUS_BAR
  21. -- A GtkStatusbar is usually placed along the bottom of an
  22. -- application's main GtkWindow. It may provide a regular
  23. -- commentary of the application's status (as is usually the case
  24. -- in a web browser, for example), or may be used to simply output
  25. -- a message when the status changes, (when an upload is complete
  26. -- in an FTP client, for example). It may also have a resize grip
  27. -- (a triangular area in the lower right corner) which can be
  28. -- clicked on to resize the window containing the statusbar.
  29. -- Status bars in Gtk+ maintain a stack of messages. The message at
  30. -- the top of the each bar's stack is the one that will currently
  31. -- be displayed.
  32. -- Any messages added to a statusbar's stack must specify a
  33. -- context_id that is used to uniquely identify the source of a
  34. -- message. This context_id can be generated by (unwrapped)
  35. -- gtk_statusbar_get_context_id(), given a message and the
  36. -- statusbar that it will be added to. Note that messages are
  37. -- stored in a stack, and when choosing which message to display,
  38. -- the stack structure is adhered to, regardless of the context
  39. -- identifier of a message.
  40. -- Status bars are created using `make'.
  41. -- Messages are added to the bar's stack with `push'.
  42. -- The message at the top of the stack can be removed using
  43. -- `pop'. A message can be removed from anywhere in the stack if
  44. -- its message_id was recorded at the time it was added. This is
  45. -- done using `remove'.
  46. inherit
  47. GTK_HBOX
  48. rename make as make_hbox
  49. export {} make_hbox
  50. redefine struct_size
  51. end
  52. -- TODO: GtkStatusbar implements AtkImplementorIface.
  53. insert GTK_SHADOW_TYPE
  54. creation make, from_external_pointer
  55. feature -- size
  56. struct_size: INTEGER is
  57. external "C inline use <gtk/gtk.h>"
  58. alias "sizeof(GtkStatusBar)"
  59. end
  60. feature {} -- Creation
  61. make is
  62. -- Creates a new GtkStatusbar ready for messages.
  63. require gtk_initialized: gtk.is_initialized
  64. do
  65. from_external_pointer (gtk_statusbar_new)
  66. end
  67. feature -- Context ids
  68. new_context_id (description: STRING) is
  69. require
  70. description /= Void
  71. do
  72. last_context_id := gtk_statusbar_get_context_id (handle, description.to_external)
  73. end
  74. last_context_id: INTEGER
  75. feature -- Stack like behaviour
  76. push (context_id: INTEGER; a_message: STRING) is
  77. -- Pushes `a_message' onto a statusbar's stack.
  78. -- `context_id' will be used
  79. require
  80. a_message /= Void
  81. do
  82. last_pushed := gtk_statusbar_push (handle, context_id,
  83. a_message.to_external)
  84. end
  85. last_pushed: INTEGER
  86. -- Message id for the last message pushed
  87. pop (context_id: INTEGER) is
  88. -- Pop last message with current (i.e.: last) context id.
  89. do
  90. gtk_statusbar_pop (handle, context_id);
  91. -- Removes the message at the top of a GtkStatusBar's stack.
  92. end
  93. remove_message (context_id, a_message_id: INTEGER) is
  94. -- Forces the removal of a message from a statusbar's
  95. -- stack. The exact `message_id' must be specified.
  96. do
  97. gtk_statusbar_remove (handle, context_id, a_message_id)
  98. end
  99. set_has_resize_grip (a_setting: BOOLEAN) is
  100. -- Sets whether the statusbar has a resize grip. True by default.
  101. do
  102. gtk_statusbar_set_has_resize_grip(handle, a_setting.to_integer)
  103. ensure set: a_setting = has_resize_grip
  104. end
  105. has_resize_grip: BOOLEAN is
  106. -- Does the statusbar have a resize grip?
  107. do
  108. Result := gtk_statusbar_get_has_resize_grip(handle).to_boolean
  109. end
  110. feature -- Style Properties
  111. shadow_type: INTEGER is
  112. -- Style of bevel around the statusbar text. Note: in C it is a
  113. -- GtkShadowType. Default value: `gtk_shadow_in'.
  114. do
  115. print_shadow_type_notice
  116. invoke_get_property (shadow_type_property_spec.owner_class, handle,
  117. shadow_type_property_spec.param_id,
  118. shadow_type_gvalue.handle,
  119. shadow_type_property_spec.handle)
  120. Result := shadow_type_gvalue.integer
  121. ensure is_valid_gtk_shadow_type (Result)
  122. end
  123. feature -- TODO: Signals
  124. -- "text-popped" void user_function (GtkStatusbar *statusbar, guint
  125. -- context_id, gchar *text, gpointer user_data) : Run last
  126. -- The "text-popped" signal
  127. -- void user_function (GtkStatusbar *statusbar, guint context_id,
  128. -- gchar *text, gpointer user_data) : Run last
  129. -- Is emitted whenever a new message is popped off a statusbar's stack.
  130. -- statusbar : the object which received the signal.
  131. -- context_id : the context id of the relevant message/statusbar.
  132. -- text : the message that was just popped.
  133. -- user_data : user data set when the signal handler was connected.
  134. -- "text-pushed" void user_function (GtkStatusbar *statusbar, guint
  135. -- context_id, gchar *text, gpointer user_data) : Run last
  136. -- The "text-pushed" signal
  137. -- void user_function (GtkStatusbar *statusbar, guint context_id,
  138. -- gchar *text, gpointer user_data) : Run last
  139. -- Is emitted whenever a new message gets pushed onto a statusbar's stack.
  140. -- statusbar : the object which received the signal.
  141. -- context_id : the context id of the relevant message/statusbar.
  142. -- text : the message that was pushed.
  143. -- user_data : user data set when the signal handler was connected.
  144. feature {} -- Implementation
  145. shadow_type_property_name: STRING is "shadow-type"
  146. shadow_type_property_spec: G_PARAM_SPEC is
  147. once
  148. Result:=find_property(shadow_type_property_name)
  149. ensure not_void: Result /= Void
  150. end
  151. shadow_type_gvalue: G_VALUE
  152. print_shadow_type_notice is
  153. once
  154. print ("[
  155. Note: GTK_STATUS_BAR's shadow_type feature relies on the assumption that a GValue
  156. can hold an enum value and that can ben handled like an integer.
  157. If you are reading this note after an application crash, please report the bug to
  158. the Eiffel Wrapper Libraries Collection project at https://gna.org/projects/eiffel-libraries/
  159. ]")
  160. end
  161. feature {} -- External calls
  162. gtk_statusbar_new: POINTER is
  163. external "C use <gtk/gtk.h>"
  164. end
  165. gtk_statusbar_get_context_id (a_statusbar, a_context_description: POINTER): INTEGER is
  166. -- Note Result shall be NATURAL since it's a guint
  167. external "C use <gtk/gtk.h>"
  168. ensure positive: Result > 0
  169. end
  170. gtk_statusbar_push (a_statusbar: POINTER; a_context_id: INTEGER;
  171. a_text: POINTER): INTEGER is
  172. require
  173. -- Note: `a_context_id' is a guint and shall be a NATURAL
  174. positive_context_id: a_context_id >= 0
  175. external "C use <gtk/gtk.h>"
  176. ensure positive: Result > 0
  177. end
  178. gtk_statusbar_pop (a_statusbar: POINTER; a_context_id: INTEGER) is
  179. require
  180. -- Note: `a_context_id' is a guint and shall be a NATURAL
  181. positive_context_id: a_context_id >= 0
  182. external "C use <gtk/gtk.h>"
  183. end
  184. gtk_statusbar_remove (a_statusbar: POINTER; a_context_id,
  185. a_message_id: INTEGER) is
  186. require
  187. -- Note: `a_context_id' and `a_message_id' are guint and shall be NATURAL
  188. positive_context_id: a_context_id >= 0
  189. positive_message_id: a_message_id >= 0
  190. external "C use <gtk/gtk.h>"
  191. end
  192. gtk_statusbar_set_has_resize_grip (a_statusbar: POINTER; a_setting: INTEGER) is
  193. external "C use <gtk/gtk.h>"
  194. end
  195. gtk_statusbar_get_has_resize_grip (a_statusbar: POINTER): INTEGER is
  196. external "C use <gtk/gtk.h>"
  197. end
  198. end