diff options
author | Matthias Clasen <maclas@gmx.de> | 2003-07-18 18:52:03 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2003-07-18 18:52:03 +0000 |
commit | eaae0a6b617a6bdb57694cc616cea7d2ede88364 (patch) | |
tree | 81ad9fe8479dd4e5c5b4adaf6be99779b88bf022 /gtk/gtkmessagedialog.c | |
parent | 1a7bac8d2a270c7d301600d058cc1c91ada021a3 (diff) | |
download | gtk+-eaae0a6b617a6bdb57694cc616cea7d2ede88364.tar.gz |
Add a new keybinding signal, move_viewport. (gtk_text_view_move_viewport):
2003-07-18 Matthias Clasen <maclas@gmx.de>
* gtk/gtktextview.c (gtk_text_view_class_init): Add a new keybinding signal, move_viewport.
(gtk_text_view_move_viewport): New function which implements the move_viewport functionality.
(gtk_text_view_move_cursor_internal): If the cursor is not visible, move the viewport. (#78669)
* gtk/gtkenums.h (GtkScrollStep): New enumeration, used for move_viewport argument.
* gtk/gtkstatusbar.c (gtk_statusbar_class_init): Add a has_resize_grip property. (#111779)
* gtk/gtkwindow.h:
* gtk/gtkwindow.c (gtk_window_set_default_icon): New method. (#95816)
* gtk/gtkmessagedialog.h:
* gtk/gtkmessagedialog.c (gtk_message_dialog_add_buttons): New method.
(#65501, Sebastian Rittau)
Diffstat (limited to 'gtk/gtkmessagedialog.c')
-rw-r--r-- | gtk/gtkmessagedialog.c | 80 |
1 files changed, 78 insertions, 2 deletions
diff --git a/gtk/gtkmessagedialog.c b/gtk/gtkmessagedialog.c index 66bf533fdd..7381584c1c 100644 --- a/gtk/gtkmessagedialog.c +++ b/gtk/gtkmessagedialog.c @@ -18,7 +18,7 @@ */ /* - * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS + * Modified by the GTK+ Team and others 1997-2003. See the AUTHORS * file for a list of people on the GTK+ Team. See the ChangeLog * files for a list of changes. These files are distributed with * GTK+ at ftp://ftp.gtk.org/pub/gtk/. @@ -302,7 +302,10 @@ gtk_message_dialog_new (GtkWindow *parent, GtkDialog *dialog; gchar* msg = 0; va_list args; - + + g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL); + g_return_val_if_fail (message_format != NULL, NULL); + widget = g_object_new (GTK_TYPE_MESSAGE_DIALOG, "message_type", type, "buttons", buttons, @@ -344,6 +347,79 @@ gtk_message_dialog_new (GtkWindow *parent, return widget; } +/** + * gtk_message_dialog_new_with_markup: + * @parent: transient parent, or %NULL for none + * @flags: flags + * @type: type of message + * @buttons: set of buttons to use + * @message_format: printf()-style format string, or %NULL + * @Varargs: arguments for @message_format + * + * Creates a new message dialog, which is a simple dialog with an icon + * indicating the dialog type (error, warning, etc.) and some text which + * is marked up with the <link linkend="PangoMarkupFormat">Pango text markup language</link>. + * When the user clicks a button a "response" signal is emitted with + * response IDs from #GtkResponseType. See #GtkDialog for more details. + * + * Please note that if you have strings in the printf() arguments + * passed to this function, you might need to protect against + * them being interpreted as markup. You can do this using + * g_markup_escape_text() as in the following example: + * <informalexample><programlisting> + * const gchar *error_text = + * "<span weight=\"bold\" size=\"larger\">" + * "Could not open document '%s'." + * "</span>\n\n" + * "You do not have appropriate permission to access this file."; + * gchar *tmp; + * GtkWidget *dialog; + * + * tmp = g_markup_escape_text (filename, -1); + * dialog = gtk_message_dialog_new_with_markup (main_application_window, + * GTK_DIALOG_DESTROY_WITH_PARENT, + * GTK_MESSAGE_ERROR, + * GTK_BUTTONS_CLOSE, + * error_text, tmp); + * g_free (tmp); + * </programlisting></informalexample> + * + * Return value: a new #GtkMessageDialog + * + * Since: 2.4 + **/ +GtkWidget* +gtk_message_dialog_new_with_markup (GtkWindow *parent, + GtkDialogFlags flags, + GtkMessageType type, + GtkButtonsType buttons, + const gchar *message_format, + ...) +{ + GtkWidget *widget; + gchar* msg = 0; + va_list args; + + g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL); + g_return_val_if_fail (message_format != NULL, NULL); + + widget = gtk_message_dialog_new (parent, flags, type, buttons, ""); + + if (message_format) + { + va_start (args, message_format); + msg = g_strdup_vprintf(message_format, args); + va_end (args); + + gtk_label_set_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (widget)->label), + msg); + + g_free (msg); + } + + return widget; +} + static void gtk_message_dialog_add_buttons (GtkMessageDialog* message_dialog, GtkButtonsType buttons) |