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
This commit is contained in:
@ -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.
|
||||
|
||||
@ -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
|
||||
@ -155,26 +220,13 @@ 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 ();
|
||||
|
||||
@ -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>
|
||||
#include <gtk/gtkmessagedialog.h>
|
||||
|
||||
void e_dialog_set_transient_for (GtkWindow *dialog,
|
||||
GtkWidget *parent_widget);
|
||||
void e_dialog_set_transient_for_xid (GtkWindow *dialog,
|
||||
GdkNativeWindow xid);
|
||||
void e_notice (gpointer parent,
|
||||
GtkMessageType type,
|
||||
const char *format,
|
||||
...);
|
||||
void e_notice_with_xid (GdkNativeWindow parent,
|
||||
GtkMessageType type,
|
||||
const char *format,
|
||||
...);
|
||||
|
||||
/* FIXME These functions should go away completely at some point. */
|
||||
void e_dialog_set_transient_for (GtkWindow *dialog,
|
||||
GtkWidget *parent_widget);
|
||||
void e_dialog_set_transient_for_xid (GtkWindow *dialog,
|
||||
GdkNativeWindow xid);
|
||||
|
||||
#ifndef GNOME_DISABLE_DEPRECATED
|
||||
void e_gnome_dialog_set_parent (GnomeDialog *dialog,
|
||||
GtkWindow *parent);
|
||||
#endif
|
||||
|
||||
char *e_file_dialog_save (const char *title);
|
||||
char *e_file_dialog_save (const char *title);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user