/src/wrappers/gtk/library/gtk_message_dialog.e
Specman e | 247 lines | 95 code | 50 blank | 102 comment | 5 complexity | 9bd4540f80ef7de17cd8825eddbf7b50 MD5 | raw file
1indexing 2 description: "GtkMessageDialog -- A convenient message window." 3 copyright: "[ 4 Copyright (C) 2006 eiffel-libraries team, GTK+ team 5 6 This library is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Lesser General Public License 8 as published by the Free Software Foundation; either version 2.1 of 9 the License, or (at your option) any later version. 10 11 This library is distributed in the hope that it will be useful, but 12 WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Lesser General Public License for more details. 15 16 You should have received a copy of the GNU Lesser General Public 17 License along with this library; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 02110-1301 USA 20 ]" 21 date: "$Date:$" 22 revision: "$Revision:$" 23 24class GTK_MESSAGE_DIALOG 25 -- GtkMessageDialog presents a dialog with an image representing 26 -- the type of message (Error, Question, etc.) alongside some 27 -- message text. It's simply a convenience widget; you could 28 -- construct the equivalent of GTK_MESSAGE_DIALOG from GTK_DIALOG 29 -- without too much effort, but GTK_MESSAGE_DIALOG saves typing. 30 31 -- The easiest way to do a modal message dialog is to use `run', 32 -- though you can also pass in the `gtk_dialog_modal' flag, `run' 33 -- automatically makes the dialog modal and waits for the user to 34 -- respond to it. `run' returns when any dialog button is clicked. 35 36 -- TODO: Eiffellize Example 2. A modal dialog. 37 38 -- dialog = gtk_message_dialog_new (main_application_window, 39 -- GTK_DIALOG_DESTROY_WITH_PARENT, 40 -- GTK_MESSAGE_ERROR, 41 -- GTK_BUTTONS_CLOSE, 42 -- "Error loading file '%s': %s", 43 -- filename, g_strerror (errno)); 44 -- gtk_dialog_run (GTK_DIALOG (dialog)); 45 -- gtk_widget_destroy (dialog); 46 47 -- You might do a non-modal GtkMessageDialog as follows: 48 49 -- TODO Eifelize Example 3. A non-modal dialog. 50 51 -- dialog = gtk_message_dialog_new (main_application_window, 52 -- GTK_DIALOG_DESTROY_WITH_PARENT, 53 -- GTK_MESSAGE_ERROR, 54 -- GTK_BUTTONS_CLOSE, 55 -- "Error loading file '%s': %s", 56 -- filename, g_strerror (errno)); 57 58 -- /* Destroy the dialog when the user responds to it (e.g. clicks a button) */ 59 -- g_signal_connect_swapped (dialog, "response", 60 -- G_CALLBACK (gtk_widget_destroy), 61 -- dialog); 62 63inherit 64 GTK_DIALOG 65 rename 66 new as new_dialog -- redefine new end 67 make as make_dialog -- redefine make end 68 redefine struct_size 69 end 70 -- Implemented Interfaces: GtkMessageDialog implements 71 -- AtkImplementorIface. 72 73insert 74 GTK_MESSAGE_DIALOG_EXTERNALS 75 76creation new, make, with_markup, from_external_pointer 77 78feature -- size 79 struct_size: INTEGER is 80 external "C inline use <gtk/gtk.h>" 81 alias "sizeof(GtkMessageDialog)" 82 end 83 84feature {} -- Creation 85 86 make (a_parent: GTK_WINDOW; some_flags, a_type, some_buttons: INTEGER; a_message: STRING) is 87 -- Creates a new message dialog, which is a simple dialog 88 -- with an icon indicating the dialog `a_type' (error, 89 -- warning, etc.) and some text the user may want to 90 -- see. When the user clicks a button a "response" signal is 91 -- emitted with response IDs from GTK_RESPONSE_TYPE. See 92 -- GTK_DIALOG for more details. 93 94 -- `a_parent': transient parent, or Void for none 95 require 96 gtk_initialized: gtk.is_initialized 97 valid_dialog_flags: are_valid_dialog_flags (some_flags) 98 valid_message_type: is_valid_gtk_message_type (a_type) 99 valid_buttons_type: is_valid_gtk_buttons_type (some_buttons) 100 do 101 if a_parent=Void then 102 from_external_pointer (gtk_message_dialog_new (default_pointer, some_flags, a_type, some_buttons, a_message.to_external)) 103 else 104 from_external_pointer (gtk_message_dialog_new (a_parent.handle, some_flags, a_type, some_buttons, a_message.to_external)) 105 end 106 end 107 108 new (a_parent: GTK_WINDOW; some_flags, a_type, some_buttons: INTEGER; a_message: STRING) is 109 obsolete "use `make' instead." 110 do 111 make (a_parent, some_flags, a_type, some_buttons, a_message) 112 end 113 114 with_markup (a_parent: GTK_WINDOW; some_flags, a_type, some_buttons: INTEGER; a_message: STRING) is 115 -- Creates a new message dialog, which is a simple dialog 116 -- with an icon indicating the dialog type (error, warning, 117 -- etc.) and some text which is marked up with the Pango text 118 -- markup language. When the user clicks a button a 119 -- "response" signal is emitted with response IDs from 120 -- GtkResponseType. See GtkDialog for more details. 121 122 -- Special XML characters in the printf() arguments passed to 123 -- this function will automatically be escaped as 124 -- necessary. (See g_markup_printf_escaped() for how this is 125 -- implemented.) Usually this is what you want, but if you 126 -- have an existing Pango markup string that you want to use 127 -- literally as the label, then you need to use 128 -- gtk_message_dialog_set_markup() instead, since you can't 129 -- pass the markup string either as the format (it might 130 -- contain '%' characters) or as a string argument. 131 132 -- TODO: Eiffelize this example GtkWidget *dialog; 133 134 -- dialog = gtk_message_dialog_new (main_application_window, 135 -- GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, 136 -- GTK_BUTTON_CLOSE, NULL); gtk_message_dialog_set_markup 137 -- (GTK_MESSAGE_DIALOG (dialog), markup); 138 139 -- `a_parent': transient parent, or Void for none 140 require 141 gtk_initialized: gtk.is_initialized 142 valid_dialog_flags: are_valid_dialog_flags (some_flags) 143 valid_message_type: is_valid_gtk_message_type (a_type) 144 valid_buttons_type: is_valid_gtk_buttons_type (some_buttons) 145 do 146 if a_parent=Void then from_external_pointer 147 (gtk_message_dialog_new_with_markup 148 (default_pointer,some_flags,a_type,some_buttons,a_message.to_external)) 149 else from_external_pointer 150 (gtk_message_dialog_new_with_markup 151 (a_parent.handle,some_flags,a_type,some_buttons,a_message.to_external)) 152 end 153 end 154 155feature -- Dialog's message 156 157 set_markup (a_string: STRING) is 158 -- Sets the text of the message dialog to be `a_string', 159 -- which is marked up with the Pango text markup language. 160 require valid_string: a_string/=Void 161 do 162 gtk_message_dialog_set_markup (handle,a_string.to_external) 163 end 164 165 set_secondary_text (a_string: STRING) is 166 -- Sets the secondary text of the message dialog to be 167 -- `a_string' (note: it must follow C's printf()-style). 168 169 -- Note that setting a secondary text makes the primary text 170 -- become bold, unless you have provided explicit markup. 171 require valid_string: a_string/=Void 172 do 173 gtk_message_dialog_format_secondary_text (handle, a_string.to_external) 174 end 175 176 unset_secondary_text is 177 -- Remove any secondary text of the message dialog. 178 do 179 gtk_message_dialog_format_secondary_text (handle, default_pointer) 180 end 181 182 set_secondary_markup (a_string: STRING) is 183 -- Sets the secondary text of the message dialog to be 184 -- `a_string' (with printf()-style), which is marked up with 185 -- the Pango text markup language. 186 187 -- Note that setting a secondary text makes the primary text 188 -- become bold, unless you have provided explicit markup. 189 190 -- TODO: intern this note into current feature: Due to an 191 -- oversight, this function does not escape special XML 192 -- characters like gtk_message_dialog_new_with_markup() 193 -- does. Thus, if the arguments may contain special XML 194 -- characters, you should use g_markup_printf_escaped() to 195 -- escape it. 196 197 -- TODO: Eiffelize this example gchar *msg; 198 199 -- msg = g_markup_printf_escaped (message_format, ...); 200 -- gtk_message_dialog_format_secondary_markup (message_dialog, "%s", msg); 201 -- g_free (msg); 202 require valid_string: a_string/=Void 203 do 204 gtk_message_dialog_format_secondary_markup (handle, a_string.to_external) 205 end 206 207 unset_secondary_markup is 208 -- Unsets the secondary text of the message dialog. 209 do 210 gtk_message_dialog_format_secondary_markup (handle, default_pointer) 211 end 212 213feature -- Property Details 214-- The "buttons" property 215 216-- "buttons" GtkButtonsType : Write / Construct Only 217 218-- The buttons shown in the message dialog. 219 220-- Default value: GTK_BUTTONS_NONE 221-- The "message-type" property 222 223-- "message-type" GtkMessageType : Read / Write / Construct 224 225-- The type of message. 226 227-- Default value: GTK_MESSAGE_INFO 228-- Style Property Details 229-- The "message-border" style property 230 231-- "message-border" gint : Read 232 233-- Width of border around the label and image in the message dialog. 234 235-- Allowed values: >= 0 236 237-- Default value: 12 238-- The "use-separator" style property 239 240-- "use-separator" gboolean : Read 241 242-- Whether to put a separator between the message dialog's text and the buttons. 243 244-- Default value: FALSE 245-- See Also 246 247end