aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-dialog-utils.c
blob: 7a481d391013b65918bf0f168223cf870e674f3f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) version 3.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with the program; if not, see <http://www.gnu.org/licenses/>
 *
 *
 * Authors:
 *      Michael Meeks <michael@ximian.com>
 *  Ettore Perazzoli <ettore@ximian.com>
 *
 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 *
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "e-dialog-utils.h"

/**
 * e_notice:
 * @parent: the dialog's parent window, or %NULL
 * @type: the type of dialog (%GTK_MESSAGE_INFO, %GTK_MESSAGE_WARNING,
 * or %GTK_MESSAGE_ERROR)
 * @format: printf-style format string, followed by arguments
 *
 * Convenience function to show a dialog with a message and an "OK"
 * button.
 **/
void
e_notice (gpointer parent,
          GtkMessageType type,
          const gchar *format,
          ...)
{
    GtkWidget *dialog;
    va_list args;
    gchar *str;

    va_start (args, format);
    str = g_strdup_vprintf (format, args);

    dialog = gtk_message_dialog_new (
        NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
        type, GTK_BUTTONS_OK, "%s", str);
    va_end (args);
    g_free (str);

    if (parent && !gtk_widget_is_toplevel (parent))
        parent = gtk_widget_get_toplevel (parent);
    if (parent)
        gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);

    gtk_dialog_run (GTK_DIALOG (dialog));
    gtk_widget_destroy (dialog);
}