/src/wrappers/gtk/library/gtk_message_dialog.e

http://github.com/tybor/Liberty · Specman e · 247 lines · 95 code · 50 blank · 102 comment · 5 complexity · 9bd4540f80ef7de17cd8825eddbf7b50 MD5 · raw file

  1. indexing
  2. description: "GtkMessageDialog -- A convenient message window."
  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_MESSAGE_DIALOG
  21. -- GtkMessageDialog presents a dialog with an image representing
  22. -- the type of message (Error, Question, etc.) alongside some
  23. -- message text. It's simply a convenience widget; you could
  24. -- construct the equivalent of GTK_MESSAGE_DIALOG from GTK_DIALOG
  25. -- without too much effort, but GTK_MESSAGE_DIALOG saves typing.
  26. -- The easiest way to do a modal message dialog is to use `run',
  27. -- though you can also pass in the `gtk_dialog_modal' flag, `run'
  28. -- automatically makes the dialog modal and waits for the user to
  29. -- respond to it. `run' returns when any dialog button is clicked.
  30. -- TODO: Eiffellize Example 2. A modal dialog.
  31. -- dialog = gtk_message_dialog_new (main_application_window,
  32. -- GTK_DIALOG_DESTROY_WITH_PARENT,
  33. -- GTK_MESSAGE_ERROR,
  34. -- GTK_BUTTONS_CLOSE,
  35. -- "Error loading file '%s': %s",
  36. -- filename, g_strerror (errno));
  37. -- gtk_dialog_run (GTK_DIALOG (dialog));
  38. -- gtk_widget_destroy (dialog);
  39. -- You might do a non-modal GtkMessageDialog as follows:
  40. -- TODO Eifelize Example 3. A non-modal dialog.
  41. -- dialog = gtk_message_dialog_new (main_application_window,
  42. -- GTK_DIALOG_DESTROY_WITH_PARENT,
  43. -- GTK_MESSAGE_ERROR,
  44. -- GTK_BUTTONS_CLOSE,
  45. -- "Error loading file '%s': %s",
  46. -- filename, g_strerror (errno));
  47. -- /* Destroy the dialog when the user responds to it (e.g. clicks a button) */
  48. -- g_signal_connect_swapped (dialog, "response",
  49. -- G_CALLBACK (gtk_widget_destroy),
  50. -- dialog);
  51. inherit
  52. GTK_DIALOG
  53. rename
  54. new as new_dialog -- redefine new end
  55. make as make_dialog -- redefine make end
  56. redefine struct_size
  57. end
  58. -- Implemented Interfaces: GtkMessageDialog implements
  59. -- AtkImplementorIface.
  60. insert
  61. GTK_MESSAGE_DIALOG_EXTERNALS
  62. creation new, make, with_markup, from_external_pointer
  63. feature -- size
  64. struct_size: INTEGER is
  65. external "C inline use <gtk/gtk.h>"
  66. alias "sizeof(GtkMessageDialog)"
  67. end
  68. feature {} -- Creation
  69. make (a_parent: GTK_WINDOW; some_flags, a_type, some_buttons: INTEGER; a_message: STRING) is
  70. -- Creates a new message dialog, which is a simple dialog
  71. -- with an icon indicating the dialog `a_type' (error,
  72. -- warning, etc.) and some text the user may want to
  73. -- see. When the user clicks a button a "response" signal is
  74. -- emitted with response IDs from GTK_RESPONSE_TYPE. See
  75. -- GTK_DIALOG for more details.
  76. -- `a_parent': transient parent, or Void for none
  77. require
  78. gtk_initialized: gtk.is_initialized
  79. valid_dialog_flags: are_valid_dialog_flags (some_flags)
  80. valid_message_type: is_valid_gtk_message_type (a_type)
  81. valid_buttons_type: is_valid_gtk_buttons_type (some_buttons)
  82. do
  83. if a_parent=Void then
  84. from_external_pointer (gtk_message_dialog_new (default_pointer, some_flags, a_type, some_buttons, a_message.to_external))
  85. else
  86. from_external_pointer (gtk_message_dialog_new (a_parent.handle, some_flags, a_type, some_buttons, a_message.to_external))
  87. end
  88. end
  89. new (a_parent: GTK_WINDOW; some_flags, a_type, some_buttons: INTEGER; a_message: STRING) is
  90. obsolete "use `make' instead."
  91. do
  92. make (a_parent, some_flags, a_type, some_buttons, a_message)
  93. end
  94. with_markup (a_parent: GTK_WINDOW; some_flags, a_type, some_buttons: INTEGER; a_message: STRING) is
  95. -- Creates a new message dialog, which is a simple dialog
  96. -- with an icon indicating the dialog type (error, warning,
  97. -- etc.) and some text which is marked up with the Pango text
  98. -- markup language. When the user clicks a button a
  99. -- "response" signal is emitted with response IDs from
  100. -- GtkResponseType. See GtkDialog for more details.
  101. -- Special XML characters in the printf() arguments passed to
  102. -- this function will automatically be escaped as
  103. -- necessary. (See g_markup_printf_escaped() for how this is
  104. -- implemented.) Usually this is what you want, but if you
  105. -- have an existing Pango markup string that you want to use
  106. -- literally as the label, then you need to use
  107. -- gtk_message_dialog_set_markup() instead, since you can't
  108. -- pass the markup string either as the format (it might
  109. -- contain '%' characters) or as a string argument.
  110. -- TODO: Eiffelize this example GtkWidget *dialog;
  111. -- dialog = gtk_message_dialog_new (main_application_window,
  112. -- GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR,
  113. -- GTK_BUTTON_CLOSE, NULL); gtk_message_dialog_set_markup
  114. -- (GTK_MESSAGE_DIALOG (dialog), markup);
  115. -- `a_parent': transient parent, or Void for none
  116. require
  117. gtk_initialized: gtk.is_initialized
  118. valid_dialog_flags: are_valid_dialog_flags (some_flags)
  119. valid_message_type: is_valid_gtk_message_type (a_type)
  120. valid_buttons_type: is_valid_gtk_buttons_type (some_buttons)
  121. do
  122. if a_parent=Void then from_external_pointer
  123. (gtk_message_dialog_new_with_markup
  124. (default_pointer,some_flags,a_type,some_buttons,a_message.to_external))
  125. else from_external_pointer
  126. (gtk_message_dialog_new_with_markup
  127. (a_parent.handle,some_flags,a_type,some_buttons,a_message.to_external))
  128. end
  129. end
  130. feature -- Dialog's message
  131. set_markup (a_string: STRING) is
  132. -- Sets the text of the message dialog to be `a_string',
  133. -- which is marked up with the Pango text markup language.
  134. require valid_string: a_string/=Void
  135. do
  136. gtk_message_dialog_set_markup (handle,a_string.to_external)
  137. end
  138. set_secondary_text (a_string: STRING) is
  139. -- Sets the secondary text of the message dialog to be
  140. -- `a_string' (note: it must follow C's printf()-style).
  141. -- Note that setting a secondary text makes the primary text
  142. -- become bold, unless you have provided explicit markup.
  143. require valid_string: a_string/=Void
  144. do
  145. gtk_message_dialog_format_secondary_text (handle, a_string.to_external)
  146. end
  147. unset_secondary_text is
  148. -- Remove any secondary text of the message dialog.
  149. do
  150. gtk_message_dialog_format_secondary_text (handle, default_pointer)
  151. end
  152. set_secondary_markup (a_string: STRING) is
  153. -- Sets the secondary text of the message dialog to be
  154. -- `a_string' (with printf()-style), which is marked up with
  155. -- the Pango text markup language.
  156. -- Note that setting a secondary text makes the primary text
  157. -- become bold, unless you have provided explicit markup.
  158. -- TODO: intern this note into current feature: Due to an
  159. -- oversight, this function does not escape special XML
  160. -- characters like gtk_message_dialog_new_with_markup()
  161. -- does. Thus, if the arguments may contain special XML
  162. -- characters, you should use g_markup_printf_escaped() to
  163. -- escape it.
  164. -- TODO: Eiffelize this example gchar *msg;
  165. -- msg = g_markup_printf_escaped (message_format, ...);
  166. -- gtk_message_dialog_format_secondary_markup (message_dialog, "%s", msg);
  167. -- g_free (msg);
  168. require valid_string: a_string/=Void
  169. do
  170. gtk_message_dialog_format_secondary_markup (handle, a_string.to_external)
  171. end
  172. unset_secondary_markup is
  173. -- Unsets the secondary text of the message dialog.
  174. do
  175. gtk_message_dialog_format_secondary_markup (handle, default_pointer)
  176. end
  177. feature -- Property Details
  178. -- The "buttons" property
  179. -- "buttons" GtkButtonsType : Write / Construct Only
  180. -- The buttons shown in the message dialog.
  181. -- Default value: GTK_BUTTONS_NONE
  182. -- The "message-type" property
  183. -- "message-type" GtkMessageType : Read / Write / Construct
  184. -- The type of message.
  185. -- Default value: GTK_MESSAGE_INFO
  186. -- Style Property Details
  187. -- The "message-border" style property
  188. -- "message-border" gint : Read
  189. -- Width of border around the label and image in the message dialog.
  190. -- Allowed values: >= 0
  191. -- Default value: 12
  192. -- The "use-separator" style property
  193. -- "use-separator" gboolean : Read
  194. -- Whether to put a separator between the message dialog's text and the buttons.
  195. -- Default value: FALSE
  196. -- See Also
  197. end