+2005-05-17 Jim Evins <evins@snaught.com>
+
+ * src/hig.h:
+ * src/hig.c:
+ Removed HigAlert class since it is obsoleted by the GtkMessageDialog class.
+ * src/file.c: (open_response), (gl_file_open_real), (gl_file_save),
+ (save_as_response), (gl_file_close):
+ Replaced all instances of HigAlert widgets with GtkMessageDialog widgets.
+
2005-05-15 Jim Evins <evins@snaught.com>
* src/ui-commands.h:
#include <glib/gi18n.h>
#include <gtk/gtkdialog.h>
+#include <gtk/gtkmessagedialog.h>
#include <gtk/gtkfilechooserdialog.h>
#include <gtk/gtkstock.h>
#include <string.h>
!filename ||
g_file_test (raw_filename, G_FILE_TEST_IS_DIR)) {
- dlg = gl_hig_alert_new (GTK_WINDOW(chooser),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_CLOSE,
- _("Empty file name selection"),
- _("Please select a file or supply a valid file name"));
+ dlg = gtk_message_dialog_new (GTK_WINDOW(chooser),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_CLOSE,
+ _("Empty file name selection"));
+ gtk_message_dialog_format_secondary_text (
+ GTK_MESSAGE_DIALOG (dlg),
+ _("Please select a file or supply a valid file name"));
gtk_dialog_run (GTK_DIALOG (dlg));
gtk_widget_destroy (dlg);
if (!g_file_test (raw_filename, G_FILE_TEST_IS_REGULAR)) {
- dlg = gl_hig_alert_new (GTK_WINDOW(chooser),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_CLOSE,
- _("File does not exist"),
- _("Please select a file or supply a valid file name"));
+ dlg = gtk_message_dialog_new (GTK_WINDOW(chooser),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_CLOSE,
+ _("File does not exist"));
+ gtk_message_dialog_format_secondary_text (
+ GTK_MESSAGE_DIALOG (dlg),
+ _("Please select a file or supply a valid file name"));
gtk_dialog_run (GTK_DIALOG (dlg));
gtk_widget_destroy (dlg);
label = gl_xml_label_open (abs_filename, &status);
if (!label) {
GtkWidget *dlg;
- gchar *primary_msg;
gl_debug (DEBUG_FILE, "couldn't open file");
- primary_msg = g_strdup_printf (_("Could not open file \"%s\""),
- filename);
-
- dlg = gl_hig_alert_new (GTK_WINDOW (window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- primary_msg,
- _("Not a supported file format"));
-
- g_free (primary_msg);
+ dlg = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("Could not open file \"%s\""),
+ filename);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dlg),
+ _("Not a supported file format"));
gtk_dialog_run (GTK_DIALOG (dlg));
gtk_widget_destroy (dlg);
if (status != XML_LABEL_OK)
{
- GtkWidget *dialog;
- gchar *primary_msg;
+ GtkWidget *dlg;
gl_debug (DEBUG_FILE, "FAILED");
- primary_msg = g_strdup_printf (_("Could not save file \"%s\""),
- filename);
-
- dialog = gl_hig_alert_new (GTK_WINDOW (window),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- primary_msg,
- _("Error encountered during save. The file is still not saved."));
+ dlg = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("Could not save file \"%s\""),
+ filename);
+ gtk_message_dialog_format_secondary_text (
+ GTK_MESSAGE_DIALOG (dlg),
+ _("Error encountered during save. The file is still not saved."));
- g_free (primary_msg);
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_dialog_run (GTK_DIALOG (dlg));
+ gtk_widget_destroy (dlg);
g_free (filename);
glXMLLabelStatus status;
EggRecentModel *recent;
gboolean *saved_flag;
- gchar *primary_msg;
gboolean cancel_flag = FALSE;
gl_debug (DEBUG_FILE, "START");
if (!raw_filename || g_file_test (raw_filename, G_FILE_TEST_IS_DIR)) {
- dlg = gl_hig_alert_new (GTK_WINDOW(chooser),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_CLOSE,
- _("Empty file name selection"),
- _("Please supply a valid file name"));
+ dlg = gtk_message_dialog_new (GTK_WINDOW(chooser),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_CLOSE,
+ _("Empty file name selection"));
+ gtk_message_dialog_format_secondary_text (
+ GTK_MESSAGE_DIALOG (dlg),
+ _("Please supply a valid file name"));
gtk_dialog_run (GTK_DIALOG (dlg));
gtk_widget_destroy (dlg);
if (g_file_test (full_filename, G_FILE_TEST_IS_REGULAR)) {
gint ret;
- primary_msg = g_strdup_printf (_("Overwrite file \"%s\"?"),
+ dlg = gtk_message_dialog_new (GTK_WINDOW(chooser),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_YES_NO,
+ _("Overwrite file \"%s\"?"),
filename);
-
- dlg = gl_hig_alert_new (GTK_WINDOW(chooser),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_YES_NO,
- primary_msg,
- _("File already exists."));
-
- g_free (primary_msg);
+ gtk_message_dialog_format_secondary_text (
+ GTK_MESSAGE_DIALOG (dlg),
+ _("File already exists."));
ret = gtk_dialog_run (GTK_DIALOG (dlg));
if ( ret == GTK_RESPONSE_NO ) {
if ( status != XML_LABEL_OK ) {
- primary_msg = g_strdup_printf (_("Could not save file \"%s\""),
- filename);
-
- dlg = gl_hig_alert_new (GTK_WINDOW(chooser),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- primary_msg,
- _("Error encountered during save. The file is still not saved."));
-
- g_free (primary_msg);
+ dlg = gtk_message_dialog_new (
+ GTK_WINDOW(chooser),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("Could not save file \"%s\""),
+ filename);
+ gtk_message_dialog_format_secondary_text (
+ GTK_MESSAGE_DIALOG (dlg),
+ _("Error encountered during save. The file is still not saved."));
gtk_dialog_run (GTK_DIALOG (dlg));
gtk_widget_destroy (dlg);
label = view->label;
if (gl_label_is_modified (label)) {
- GtkWidget *msgbox, *w;
- gchar *fname = NULL, *msg = NULL;
+ GtkWidget *dlg, *w;
+ gchar *fname = NULL;
gint ret;
gboolean exiting;
fname = gl_label_get_short_name (label);
- msg = g_strdup_printf (_("Save changes to document \"%s\" before closing?"),
- fname);
-
- msgbox = gl_hig_alert_new (GTK_WINDOW(window),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_NONE,
- msg,
- _("Your changes will be lost if you don't save them."));
-
- gtk_dialog_add_button (GTK_DIALOG (msgbox),
+ dlg = gtk_message_dialog_new (GTK_WINDOW(window),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_NONE,
+ _("Save changes to document \"%s\" before closing?"),
+ fname);
+ gtk_message_dialog_format_secondary_text (
+ GTK_MESSAGE_DIALOG (dlg),
+ _("Your changes will be lost if you don't save them."));
+
+ gtk_dialog_add_button (GTK_DIALOG (dlg),
_("Close without saving"),
GTK_RESPONSE_NO);
- gtk_dialog_add_button (GTK_DIALOG (msgbox),
+ gtk_dialog_add_button (GTK_DIALOG (dlg),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
- gtk_dialog_add_button (GTK_DIALOG (msgbox),
+ gtk_dialog_add_button (GTK_DIALOG (dlg),
GTK_STOCK_SAVE, GTK_RESPONSE_YES);
- gtk_dialog_set_default_response (GTK_DIALOG (msgbox), GTK_RESPONSE_YES);
+ gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_YES);
- gtk_window_set_resizable (GTK_WINDOW (msgbox), FALSE);
+ gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
- ret = gtk_dialog_run (GTK_DIALOG (msgbox));
+ ret = gtk_dialog_run (GTK_DIALOG (dlg));
- gtk_widget_destroy (msgbox);
+ gtk_widget_destroy (dlg);
g_free (fname);
- g_free (msg);
switch (ret)
{
/*========================================================*/
/* Private macros and constants. */
/*========================================================*/
-#define HIG_ALERT_BORDER 6
-#define HIG_ALERT_SPACING 12
-
#define HIG_DIALOG_BORDER 12
#define HIG_DIALOG_VBOX_SPACING 18
#define HIG_DIALOG_OUTER_VBOX_SPACING 12
/*===========================================*/
/* Private globals */
/*===========================================*/
-static GtkDialogClass *hig_alert_parent_class;
static GtkDialogClass *hig_dialog_parent_class;
static GtkVBoxClass *hig_category_parent_class;
static GtkVBoxClass *hig_vbox_parent_class;
/* Local function prototypes */
/*===========================================*/
-static void gl_hig_alert_class_init (glHigAlertClass *class);
-static void gl_hig_alert_init (glHigAlert *hig_alert);
-static void gl_hig_alert_finalize (GObject *object);
-
static void gl_hig_dialog_class_init (glHigDialogClass *class);
static void gl_hig_dialog_init (glHigDialog *hig_dialog);
static void gl_hig_dialog_finalize (GObject *object);
static void gl_hig_hbox_init (glHigHBox *hig_hbox);
static void gl_hig_hbox_finalize (GObject *object);
-\f
-/****************************************************************************/
-/****************************************************************************/
-/* Boilerplate Alert Object stuff. */
-/****************************************************************************/
-/****************************************************************************/
-GType
-gl_hig_alert_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo info = {
- sizeof (glHigAlertClass),
- NULL,
- NULL,
- (GClassInitFunc) gl_hig_alert_class_init,
- NULL,
- NULL,
- sizeof (glHigAlert),
- 0,
- (GInstanceInitFunc) gl_hig_alert_init,
- NULL
- };
-
- type = g_type_register_static (GTK_TYPE_DIALOG,
- "glHigAlert", &info, 0);
- }
-
- return type;
-}
-
-static void
-gl_hig_alert_class_init (glHigAlertClass *class)
-{
- GObjectClass *object_class = (GObjectClass *) class;
-
- hig_alert_parent_class = g_type_class_peek_parent (class);
-
- object_class->finalize = gl_hig_alert_finalize;
-}
-
-static void
-gl_hig_alert_init (glHigAlert *hig_alert)
-{
-}
-
-static void
-gl_hig_alert_finalize (GObject *object)
-{
- glHigAlert *hig_alert;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GL_IS_HIG_ALERT (object));
-
- hig_alert = GL_HIG_ALERT (object);
-
- G_OBJECT_CLASS (hig_alert_parent_class)->finalize (object);
-}
-
-
-/****************************************************************************/
-/* Create a message dialog that attempts to be HIG compliant. */
-/****************************************************************************/
-GtkWidget* gl_hig_alert_new (GtkWindow *parent,
- GtkDialogFlags flags,
- GtkMessageType type,
- GtkButtonsType buttons,
- const gchar *primary_text,
- const gchar *secondary_text)
-{
- GtkWidget *dialog, *hbox, *image, *label;
- gchar *label_text;
- const gchar *stock_id = NULL;
- GtkStockItem item;
-
- /* Bare dialog */
- dialog = g_object_new (gl_hig_alert_get_type (), NULL);
-
- /* Parent */
- gtk_window_set_transient_for (GTK_WINDOW(dialog), parent);
-
- /* Flags */
- if ( flags & GTK_DIALOG_MODAL ) {
- gtk_window_set_modal (GTK_WINDOW(dialog), TRUE);
- }
- if ( flags & GTK_DIALOG_DESTROY_WITH_PARENT ) {
- gtk_window_set_destroy_with_parent (GTK_WINDOW(dialog), TRUE);
- }
-
- /* Create HBOX */
- hbox = gtk_hbox_new (FALSE, HIG_ALERT_SPACING);
- gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
- hbox, FALSE, FALSE, 0);
-
- /* Create image */
- switch (type) {
- case GTK_MESSAGE_INFO:
- stock_id = GTK_STOCK_DIALOG_INFO;
- break;
- case GTK_MESSAGE_QUESTION:
- stock_id = GTK_STOCK_DIALOG_QUESTION;
- break;
- case GTK_MESSAGE_WARNING:
- stock_id = GTK_STOCK_DIALOG_WARNING;
- break;
- case GTK_MESSAGE_ERROR:
- stock_id = GTK_STOCK_DIALOG_ERROR;
- break;
- default:
- stock_id = GTK_STOCK_DIALOG_INFO;
- g_warning ("Unknown GtkMessageType %d", type);
- break;
- }
- if (gtk_stock_lookup (stock_id, &item)) {
- image = gtk_image_new_from_stock (stock_id,
- GTK_ICON_SIZE_DIALOG);
- } else {
- image = gtk_image_new_from_stock (NULL,
- GTK_ICON_SIZE_DIALOG);
- g_warning ("Stock dialog ID doesn't exist?");
- }
- gtk_box_pack_start (GTK_BOX(hbox), image, FALSE, FALSE, 0);
-
- /* Create label containing primary and secondary text */
- label_text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
- primary_text, secondary_text);
- label = gtk_label_new (label_text);
- g_free (label_text);
- gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
-
- /* Adjust dialog properties */
- gtk_window_set_title (GTK_WINDOW(dialog), "");
- gtk_container_set_border_width (GTK_CONTAINER(dialog),
- HIG_ALERT_BORDER);
- gtk_dialog_set_has_separator (GTK_DIALOG(dialog), FALSE);
-
- /* Adjust VBOX properties */
- gtk_box_set_spacing (GTK_BOX(GTK_DIALOG(dialog)->vbox),
- HIG_ALERT_SPACING);
-
- /* Adjust HBOX properties */
- gtk_box_set_spacing (GTK_BOX(hbox), HIG_ALERT_SPACING);
- gtk_container_set_border_width (GTK_CONTAINER(hbox), HIG_ALERT_BORDER);
-
- /* Adjust IMAGE properties */
- gtk_misc_set_alignment (GTK_MISC(image), 0.5, 0.0);
-
- /* Adjust LABEL properties */
- gtk_label_set_line_wrap (GTK_LABEL(label), TRUE);
- gtk_label_set_use_markup (GTK_LABEL(label), TRUE);
- gtk_misc_set_alignment (GTK_MISC(image), 0.5, 0.0);
-
- /* Add buttons */
- switch (buttons) {
- case GTK_BUTTONS_NONE:
- /* nothing */
- break;
- case GTK_BUTTONS_OK:
- gtk_dialog_add_button (GTK_DIALOG(dialog),
- GTK_STOCK_OK, GTK_RESPONSE_OK);
- break;
- case GTK_BUTTONS_CLOSE:
- gtk_dialog_add_button (GTK_DIALOG(dialog),
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
- break;
- case GTK_BUTTONS_CANCEL:
- gtk_dialog_add_button (GTK_DIALOG(dialog),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
- break;
- case GTK_BUTTONS_YES_NO:
- gtk_dialog_add_button (GTK_DIALOG(dialog),
- GTK_STOCK_NO, GTK_RESPONSE_NO);
- gtk_dialog_add_button (GTK_DIALOG(dialog),
- GTK_STOCK_YES, GTK_RESPONSE_YES);
- break;
- case GTK_BUTTONS_OK_CANCEL:
- gtk_dialog_add_button (GTK_DIALOG(dialog),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
- gtk_dialog_add_button (GTK_DIALOG(dialog),
- GTK_STOCK_OK, GTK_RESPONSE_OK);
- break;
- default:
- g_warning ("Unknown GtkButtonsType");
- break;
- }
-
- /* Show dialog widgets */
- gtk_widget_show_all (hbox);
-
- return dialog;
-}
-
-
/****************************************************************************/
/****************************************************************************/
/* Boilerplate Dialog Object stuff. */
#define GL_HIG_PAD2 12
-/*===========================================================================*/
-/* HIG inspired alert. */
-/*===========================================================================*/
-
-#define GL_TYPE_HIG_ALERT (gl_hig_alert_get_type ())
-#define GL_HIG_ALERT(obj) \
- (GTK_CHECK_CAST((obj), GL_TYPE_HIG_ALERT, glHigAlert ))
-#define GL_HIG_ALERT_CLASS(klass) \
- (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_HIG_ALERT, glHigAlertClass))
-#define GL_IS_HIG_ALERT(obj) \
- (GTK_CHECK_TYPE ((obj), GL_TYPE_HIG_ALERT))
-#define GL_IS_HIG_ALERT_CLASS(klass) \
- (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_HIG_ALERT))
-
-typedef struct _glHigAlert glHigAlert;
-typedef struct _glHigAlertClass glHigAlertClass;
-
-struct _glHigAlert {
- GtkDialog parent_widget;
-};
-
-struct _glHigAlertClass {
- GtkDialogClass parent_class;
-};
-
-GType gl_hig_alert_get_type (void) G_GNUC_CONST;
-
-GtkWidget *gl_hig_alert_new (GtkWindow *parent,
- GtkDialogFlags flags,
- GtkMessageType type,
- GtkButtonsType buttons,
- const gchar *primary_text,
- const gchar *secondary_text);
-
-
/*===========================================================================*/
/* HIG Dialog wrapper. */
/*===========================================================================*/