evolution-3.6.4/e-util/e-dialog-utils.c

No issues found

 1 /*
 2  * This program is free software; you can redistribute it and/or
 3  * modify it under the terms of the GNU Lesser General Public
 4  * License as published by the Free Software Foundation; either
 5  * version 2 of the License, or (at your option) version 3.
 6  *
 7  * This program is distributed in the hope that it will be useful,
 8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with the program; if not, see <http://www.gnu.org/licenses/>
14  *
15  *
16  * Authors:
17  *		Michael Meeks <michael@ximian.com>
18  *	Ettore Perazzoli <ettore@ximian.com>
19  *
20  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
21  *
22  */
23 
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27 
28 #include "e-dialog-utils.h"
29 
30 /**
31  * e_notice:
32  * @parent: the dialog's parent window, or %NULL
33  * @type: the type of dialog (%GTK_MESSAGE_INFO, %GTK_MESSAGE_WARNING,
34  * or %GTK_MESSAGE_ERROR)
35  * @format: printf-style format string, followed by arguments
36  *
37  * Convenience function to show a dialog with a message and an "OK"
38  * button.
39  **/
40 void
41 e_notice (gpointer parent,
42           GtkMessageType type,
43           const gchar *format,
44           ...)
45 {
46 	GtkWidget *dialog;
47 	va_list args;
48 	gchar *str;
49 
50 	va_start (args, format);
51 	str = g_strdup_vprintf (format, args);
52 
53 	dialog = gtk_message_dialog_new (
54 		NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
55 		type, GTK_BUTTONS_OK, "%s", str);
56 	va_end (args);
57 	g_free (str);
58 
59 	if (parent && !gtk_widget_is_toplevel (parent))
60 		parent = gtk_widget_get_toplevel (parent);
61 	if (parent)
62 		gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
63 
64 	gtk_dialog_run (GTK_DIALOG (dialog));
65 	gtk_widget_destroy (dialog);
66 }