ui_notif_dlg.c 859 Bytes
Newer Older
Cedric Roux's avatar
Cedric Roux committed
1
2
3
4
5
#include "rc.h"

#include "ui_notif_dlg.h"
#include "ui_main_screen.h"

winckel's avatar
winckel committed
6
7
8
9
static const char * const title_type[] =
    {"Info", "Warning", "Question", "Error", "Other"};

int ui_notification_dialog(GtkMessageType type, const char *title, const char *fmt, ...)
Cedric Roux's avatar
Cedric Roux committed
10
11
12
{
    va_list args;
    GtkWidget *dialogbox;
winckel's avatar
winckel committed
13
    char buffer[200];
Cedric Roux's avatar
Cedric Roux committed
14
15
16

    va_start(args, fmt);

winckel's avatar
winckel committed
17
18
    vsnprintf (buffer, sizeof(buffer), fmt, args);

19
20
    g_warning("%s", buffer);

winckel's avatar
winckel committed
21
22
    dialogbox = gtk_message_dialog_new (GTK_WINDOW(ui_main_data.window), GTK_DIALOG_MODAL, type, GTK_BUTTONS_OK, "%s",
                                        buffer);
winckel's avatar
winckel committed
23

winckel's avatar
winckel committed
24
25
    snprintf (buffer, sizeof(buffer), "%s: %s", title_type[type], title);
    gtk_window_set_title (GTK_WINDOW(dialogbox), buffer);
Cedric Roux's avatar
Cedric Roux committed
26

winckel's avatar
winckel committed
27
    gtk_dialog_run (GTK_DIALOG (dialogbox));
Cedric Roux's avatar
Cedric Roux committed
28
29
30
31
32
33
34

    gtk_widget_destroy (dialogbox);

    va_end(args);

    return RC_OK;
}