From 165cf260c918362da2ea328a5ab5910c02238d9c Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Fri, 4 Jul 2014 22:31:59 +0200 Subject: [PATCH] Add ag_app_message_dialog() to create multi-purpose message dialogs --- src/ag-app.c | 16 ++++++++++++++++ src/ag-app.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/ag-app.c b/src/ag-app.c index e40e567..6ef26e9 100644 --- a/src/ag-app.c +++ b/src/ag-app.c @@ -342,3 +342,19 @@ ag_app_class_init(AgAppClass *klass) application_class->open = ag_app_open; } +void +ag_app_message_dialog(GtkWidget *window, GtkMessageType message_type, gchar *fmt, ...) +{ + gchar *msg; + va_list args; + GtkWidget *dialog; + + va_start(args, fmt); + msg = g_strdup_vprintf(fmt, args); + va_end(args); + + dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, message_type, GTK_BUTTONS_OK, "%s", msg); + g_free(msg); + gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); +} diff --git a/src/ag-app.h b/src/ag-app.h index c5f363d..945f49b 100644 --- a/src/ag-app.h +++ b/src/ag-app.h @@ -37,6 +37,7 @@ void ag_app_raise(AgApp *self); void ag_app_run_action(AgApp *app, gboolean is_remote, const AstrognomeOptions *options); +void ag_app_message_dialog(GtkWidget *window, GtkMessageType message_type, gchar *fmt, ...); G_END_DECLS