aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2005-09-20 01:53:38 +0000
committerUlf Lamping <ulf.lamping@web.de>2005-09-20 01:53:38 +0000
commit81e9a70a96ff082669cee89d47353ff296432a45 (patch)
tree203d1a9347f4e3d5487164907c097a39168f4c85
parent7f97d9e9e759cb65dfb602045b66a2218b4dafd6 (diff)
enhance simple dialog: add the possibility to use no buttons at all and add a stop icon (similar to the splash_window, but with a slightly different layout and a way to choose the icon shown)
svn path=/trunk/; revision=15886
-rw-r--r--gtk/dlg_utils.c9
-rw-r--r--gtk/simple_dialog.c25
-rw-r--r--simple_dialog.h11
3 files changed, 37 insertions, 8 deletions
diff --git a/gtk/dlg_utils.c b/gtk/dlg_utils.c
index 9164261bb1..2dacc9750d 100644
--- a/gtk/dlg_utils.c
+++ b/gtk/dlg_utils.c
@@ -162,10 +162,6 @@ dlg_button_row_new(const gchar *stock_id_first, ...)
}
va_end(stock_id_list);
- /* we should have at least one button */
- g_assert(buttons);
-
-
hbox = gtk_hbox_new(FALSE, 0);
gtk_widget_show(hbox);
@@ -177,6 +173,11 @@ dlg_button_row_new(const gchar *stock_id_first, ...)
gtk_box_pack_end(GTK_BOX(hbox), help_hbox, FALSE, FALSE, 0);
gtk_widget_show(help_hbox);
+ if (buttons == 0) {
+ /* if no buttons wanted, simply do nothing */
+ return hbox;
+ }
+
if (buttons == 1) {
/* if only one button, simply put it in the middle (default) */
dlg_button_new(hbox, button_hbox, stock_id_first);
diff --git a/gtk/simple_dialog.c b/gtk/simple_dialog.c
index 39c953ac44..adfec0125f 100644
--- a/gtk/simple_dialog.c
+++ b/gtk/simple_dialog.c
@@ -41,6 +41,7 @@
#include "image/stock_dialog_error_48.xpm"
#include "image/stock_dialog_info_48.xpm"
#include "image/stock_dialog_warning_48.xpm"
+#include "image/stock_dialog_stop_48.xpm"
static void simple_dialog_cancel_cb(GtkWidget *, gpointer);
@@ -82,6 +83,9 @@ display_simple_dialog(gint type, gint btn_mask, char *message)
case ESD_TYPE_ERROR:
icon = stock_dialog_error_48_xpm;
break;
+ case ESD_TYPE_STOP :
+ icon = stock_dialog_stop_48_xpm;
+ break;
case ESD_TYPE_INFO :
default :
icon = stock_dialog_info_48_xpm;
@@ -122,11 +126,15 @@ display_simple_dialog(gint type, gint btn_mask, char *message)
* For now, we give it a Win32 title of just "Ethereal"; we should
* arguably take an argument for the title.
*/
+ if(btn_mask == ESD_BTN_NONE) {
+ win = splash_window_new();
+ } else {
#ifdef _WIN32
- win = dlg_window_new("Ethereal");
+ win = dlg_window_new("Ethereal");
#else
- win = dlg_window_new("");
+ win = dlg_window_new("");
#endif
+ }
gtk_window_set_modal(GTK_WINDOW(win), TRUE);
gtk_container_border_width(GTK_CONTAINER(win), 6);
@@ -171,6 +179,11 @@ display_simple_dialog(gint type, gint btn_mask, char *message)
gtk_container_add(GTK_CONTAINER(msg_vb), msg_label);
gtk_widget_show(msg_label);
+ if(btn_mask == ESD_BTN_NONE) {
+ gtk_widget_show(win);
+ return win;
+ }
+
/* optional check button */
ask_cb = gtk_check_button_new_with_label("replace with text...");
gtk_container_add(GTK_CONTAINER(msg_vb), ask_cb);
@@ -356,7 +369,7 @@ simple_dialog(ESD_TYPE_E type, gint btn_mask, const gchar *msg_format, ...)
static void
simple_dialog_cancel_cb(GtkWidget *w, gpointer win) {
- gint button = GPOINTER_TO_INT( OBJECT_GET_DATA(w, CALLBACK_BTN_KEY));
+ gint button = GPOINTER_TO_INT( OBJECT_GET_DATA(w, CALLBACK_BTN_KEY));
simple_dialog_cb_t callback_fct = OBJECT_GET_DATA(win, CALLBACK_FCT_KEY);
gpointer data = OBJECT_GET_DATA(win, CALLBACK_DATA_KEY);
@@ -366,6 +379,12 @@ simple_dialog_cancel_cb(GtkWidget *w, gpointer win) {
(callback_fct) (win, button, data);
}
+void
+simple_dialog_close(gpointer dialog)
+{
+ window_destroy(GTK_WIDGET(dialog));
+}
+
void simple_dialog_set_cb(gpointer dialog, simple_dialog_cb_t callback_fct, gpointer data)
{
diff --git a/simple_dialog.h b/simple_dialog.h
index 071de16a4b..098dca3462 100644
--- a/simple_dialog.h
+++ b/simple_dialog.h
@@ -43,9 +43,12 @@ typedef enum {
ESD_TYPE_WARN, /**< tells the user about a problem; the only button should be "OK" */
ESD_TYPE_CONFIRMATION, /**< asks the user for confirmation; there should be more than
one button */
- ESD_TYPE_ERROR /**< tells the user about a serious problem; the only button should be "OK" */
+ ESD_TYPE_ERROR, /**< tells the user about a serious problem; the only button should be "OK" */
+ ESD_TYPE_STOP, /**< tells the user a stop action is in progress, there should be no button */
} ESD_TYPE_E;
+/** display no buttons at all */
+#define ESD_BTN_NONE 0x00
/** display an "Ok" button */
#define ESD_BTN_OK 0x01
/** display a "Cancel" button */
@@ -126,6 +129,12 @@ typedef void (* simple_dialog_cb_t) (gpointer dialog, gint btn, gpointer data);
*/
extern void simple_dialog_set_cb(gpointer dialog, simple_dialog_cb_t callback_fct, gpointer data);
+/** Close the dialog, useful for "no button" dialogs.
+ *
+ * @param dialog the dialog to close from simple_dialog()
+ */
+extern void simple_dialog_close(gpointer dialog);
+
/** Add a check button to the dialog (e.g. "Don't show this message again")
*
* @param dialog the dialog from simple_dialog()