From: Kaj-Michael Lang Date: Fri, 1 Feb 2008 14:21:45 +0000 (+0200) Subject: Split out simple dialogs from ui-common.c to dialogs.c X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08e8bf97eb5206b3e55fc60383a692e490f23981;p=mapper Split out simple dialogs from ui-common.c to dialogs.c Add confirm dialog helper. --- diff --git a/src/dialogs.c b/src/dialogs.c new file mode 100644 index 0000000..3320039 --- /dev/null +++ b/src/dialogs.c @@ -0,0 +1,63 @@ +#include "config.h" + +#include +#include + +#include "ui-maemo.h" +#include "hildon-wrappers.h" +#include "dialogs.h" + +/** + * Pop up a modal dialog box with simple error information in it. + */ +void +popup_error(GtkWidget *window, const gchar *error) +{ +GtkWidget *dialog; + +#ifdef WITH_HILDON +dialog=hildon_note_new_information(GTK_WINDOW(window), error); +#else +dialog=gtk_message_dialog_new (GTK_WINDOW(window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, error); +#endif +gtk_dialog_run(GTK_DIALOG(dialog)); +gtk_widget_destroy(dialog); +} + +gboolean +dialog_confirm(GtkWidget *window, const gchar *msg) +{ +GtkWidget *confirm; +gboolean r; + +confirm=hildon_note_new_confirmation(GTK_WINDOW(window),msg); +r=(GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) ? TRUE : FALSE; +gtk_widget_destroy(confirm); +return r; +} + +GtkWidget * +progress_dialog(GtkWidget *window, const gchar *title, GtkWidget *progress) +{ +GtkWidget *dialog; + +dialog=gtk_dialog_new(); +gtk_window_set_title(GTK_WINDOW(dialog), title); +gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(window)); +gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); +#ifndef WITH_HILDON +gtk_window_set_deletable(GTK_WINDOW(dialog), FALSE); +#endif +/* gtk_window_set_decorated(GTK_WINDOW(dialog), FALSE); */ +gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), gtk_label_new(title), TRUE, TRUE, 0); +gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), progress, TRUE, TRUE, 0); +gtk_widget_show_all(dialog); +return dialog; +} + +void +progress_dialog_remove(GtkWidget *dialog) +{ +if (dialog) + gtk_widget_destroy(dialog); +} diff --git a/src/dialogs.h b/src/dialogs.h new file mode 100644 index 0000000..662b1f4 --- /dev/null +++ b/src/dialogs.h @@ -0,0 +1,18 @@ +#ifndef _DIALOGS_H +#define _DIALOGS_H + +#include "config.h" + +#include +#include + +#include "ui-maemo.h" +#include "hildon-wrappers.h" + +void popup_error(GtkWidget * window, const gchar * error); +gboolean dialog_confirm(GtkWidget *window, const gchar *msg); + +GtkWidget *progress_dialog(GtkWidget *window, const gchar *title, GtkWidget *progress); +void progress_dialog_remove(GtkWidget *dialog); + +#endif