diff options
author | Dan Winship <danw@src.gnome.org> | 2003-03-25 23:47:45 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2003-03-25 23:47:45 +0800 |
commit | 233ec937746ac54c25d52771bfbb9ecc475a8919 (patch) | |
tree | 2e42ce083827aca360c5c1e122e8ec1929b74641 /e-util | |
parent | 351cb225cbaf139c4d8264e26962460e9705280e (diff) | |
download | gsoc2013-evolution-233ec937746ac54c25d52771bfbb9ecc475a8919.tar gsoc2013-evolution-233ec937746ac54c25d52771bfbb9ecc475a8919.tar.gz gsoc2013-evolution-233ec937746ac54c25d52771bfbb9ecc475a8919.tar.bz2 gsoc2013-evolution-233ec937746ac54c25d52771bfbb9ecc475a8919.tar.lz gsoc2013-evolution-233ec937746ac54c25d52771bfbb9ecc475a8919.tar.xz gsoc2013-evolution-233ec937746ac54c25d52771bfbb9ecc475a8919.tar.zst gsoc2013-evolution-233ec937746ac54c25d52771bfbb9ecc475a8919.zip |
Move this here from gal. Use e_dialog_set_transient_for so it DTRT for
* e-dialog-utils.c (e_notice): Move this here from gal. Use
e_dialog_set_transient_for so it DTRT for out-of-proc components.
(e_notice_with_xid): Like e_notice but with an X Window ID as the
parent window
(e_gnome_dialog_set_parent): Remove this, since it was marked
deprecated and only used in one place.
(e_file_dialog_save): Make this use GtkMessageDialog instead of
GnomeDialog
svn path=/trunk/; revision=20498
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/ChangeLog | 11 | ||||
-rw-r--r-- | e-util/e-dialog-utils.c | 102 | ||||
-rw-r--r-- | e-util/e-dialog-utils.h | 35 |
3 files changed, 108 insertions, 40 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog index ded12adec9..3018e6a2fb 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,14 @@ +2003-03-25 Dan Winship <danw@ximian.com> + + * e-dialog-utils.c (e_notice): Move this here from gal. Use + e_dialog_set_transient_for so it DTRT for out-of-proc components. + (e_notice_with_xid): Like e_notice but with an X Window ID as the + parent window + (e_gnome_dialog_set_parent): Remove this, since it was marked + deprecated and only used in one place. + (e_file_dialog_save): Make this use GtkMessageDialog instead of + GnomeDialog + 2003-03-25 Not Zed <NotZed@Ximian.com> * e-meta.c (meta_filename): fix a typo & some missing headers. diff --git a/e-util/e-dialog-utils.c b/e-util/e-dialog-utils.c index cce4d1494f..173526c46b 100644 --- a/e-util/e-dialog-utils.c +++ b/e-util/e-dialog-utils.c @@ -24,8 +24,6 @@ #include "e-dialog-utils.h" -#include <glib.h> -#include <gdk/gdk.h> #include <gdk/gdkx.h> #include <gtk/gtkfilesel.h> @@ -34,8 +32,75 @@ #include <libgnome/gnome-i18n.h> #include <libgnome/gnome-util.h> -#include <libgnomeui/gnome-dialog-util.h> -#include <libgnomeui/gnome-uidefs.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 char *format, ...) +{ + GtkWidget *dialog; + va_list args; + char *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) + e_dialog_set_transient_for (GTK_WINDOW (dialog), parent); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); +} + +/** + * e_notice_with_xid: + * @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 + * + * Like e_notice(), but takes a GdkNativeWindow for the parent + * window argument. + **/ +void +e_notice_with_xid (GdkNativeWindow parent, GtkMessageType type, const char *format, ...) +{ + GtkWidget *dialog; + va_list args; + char *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) + e_dialog_set_transient_for_xid (GTK_WINDOW (dialog), parent); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); +} /* Tests whether or not an X Window is being managed by the @@ -156,25 +221,12 @@ e_dialog_set_transient_for_xid (GtkWindow *dialog, static void -e_gnome_dialog_parent_destroyed (GnomeDialog *dialog, GObject *deadbeef) -{ - gnome_dialog_close (GNOME_DIALOG (dialog)); -} - -void -e_gnome_dialog_set_parent (GnomeDialog *dialog, GtkWindow *parent) -{ - gnome_dialog_set_parent (dialog, parent); - g_object_weak_ref ((GObject *) parent, (GWeakNotify) e_gnome_dialog_parent_destroyed, dialog); -} - -static void save_ok (GtkWidget *widget, gpointer data) { GtkWidget *fs; char **filename = data; const char *path; - int btn = GNOME_YES; + int btn = GTK_RESPONSE_YES; fs = gtk_widget_get_toplevel (widget); path = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)); @@ -182,12 +234,18 @@ save_ok (GtkWidget *widget, gpointer data) if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) { GtkWidget *dlg; - dlg = gnome_question_dialog_modal (_("A file by that name already exists.\n" - "Overwrite it?"), NULL, NULL); - btn = gnome_dialog_run_and_close (GNOME_DIALOG (dlg)); + dlg = gtk_message_dialog_new (GTK_WINDOW (fs), 0, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_YES_NO, + _("A file by that name already exists.\n" + "Overwrite it?")); + gtk_window_set_title (GTK_WINDOW (dlg), _("Overwrite file?")); + + btn = gtk_dialog_run (GTK_DIALOG (dlg)); + gtk_widget_destroy (dlg); } - if (btn == GNOME_YES) + if (btn == GTK_RESPONSE_YES) *filename = g_strdup (path); gtk_main_quit (); diff --git a/e-util/e-dialog-utils.h b/e-util/e-dialog-utils.h index dfacfd4149..6e6cff8fb9 100644 --- a/e-util/e-dialog-utils.h +++ b/e-util/e-dialog-utils.h @@ -23,24 +23,23 @@ #ifndef E_DIALOG_UTILS_H #define E_DIALOG_UTILS_H -#include <gtk/gtkwindow.h> -#include <gtk/gtkwidget.h> -#include <libgnomeui/gnome-types.h> -#include <libgnomeui/gnome-dialog.h> - -void e_dialog_set_transient_for (GtkWindow *dialog, - GtkWidget *parent_widget); -void e_dialog_set_transient_for_xid (GtkWindow *dialog, - GdkNativeWindow xid); - -/* FIXME These functions should go away completely at some point. */ - -#ifndef GNOME_DISABLE_DEPRECATED -void e_gnome_dialog_set_parent (GnomeDialog *dialog, - GtkWindow *parent); -#endif - -char *e_file_dialog_save (const char *title); +#include <gtk/gtkmessagedialog.h> + +void e_notice (gpointer parent, + GtkMessageType type, + const char *format, + ...); +void e_notice_with_xid (GdkNativeWindow parent, + GtkMessageType type, + const char *format, + ...); + +void e_dialog_set_transient_for (GtkWindow *dialog, + GtkWidget *parent_widget); +void e_dialog_set_transient_for_xid (GtkWindow *dialog, + GdkNativeWindow xid); + +char *e_file_dialog_save (const char *title); #endif |