diff --git a/ChangeLog b/ChangeLog index 5e60da03c2..61725e5324 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2004-10-13 Sven Neumann + + * app/widgets/widgets-enums.[ch]: changed the description for + GIMP_HELP_BROWSER_GIMP. + + * app/dialogs/file-save-dialog.c: + * app/widgets/gimphelp.c: use a GimpDialog embedding a + GimpMessageBox instead of gimp_query_boolean_box which looks + somewhat old fashioned. + 2004-10-13 Sven Neumann * app/widgets/gimphelp.c: improved error messages on missing help diff --git a/app/dialogs/file-save-dialog.c b/app/dialogs/file-save-dialog.c index 5c481009f6..d8cf0fe431 100644 --- a/app/dialogs/file-save-dialog.c +++ b/app/dialogs/file-save-dialog.c @@ -36,6 +36,7 @@ #include "widgets/gimpfiledialog.h" #include "widgets/gimphelp-ids.h" +#include "widgets/gimpmessagebox.h" #include "file-save-dialog.h" @@ -50,8 +51,8 @@ static void file_save_dialog_response (GtkWidget *save_dialog, static void file_save_overwrite (GtkWidget *save_dialog, const gchar *uri, const gchar *raw_filename); -static void file_save_overwrite_callback (GtkWidget *widget, - gboolean overwrite, +static void file_save_overwrite_response (GtkWidget *dialog, + gint response_id, gpointer data); static gboolean file_save_dialog_save_image (GtkWidget *save_dialog, GimpImage *gimage, @@ -148,74 +149,78 @@ file_save_overwrite (GtkWidget *save_dialog, const gchar *uri, const gchar *raw_filename) { - OverwriteData *overwrite_data; - GtkWidget *query_box; + OverwriteData *overwrite_data = g_new0 (OverwriteData, 1); + GtkWidget *dialog; + GtkWidget *box; gchar *filename; - gchar *message; - - overwrite_data = g_new0 (OverwriteData, 1); overwrite_data->save_dialog = save_dialog; overwrite_data->uri = g_strdup (uri); overwrite_data->raw_filename = g_strdup (raw_filename); + dialog = gimp_dialog_new (_("File exists"), "gimp-file-overwrite", + save_dialog, 0, + gimp_standard_help_func, NULL, + + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + _("_Replace"), GTK_RESPONSE_OK, + + NULL); + + g_signal_connect (dialog, "response", + G_CALLBACK (file_save_overwrite_response), + overwrite_data); + + box = gimp_message_box_new (GIMP_STOCK_WARNING); + gtk_container_set_border_width (GTK_CONTAINER (box), 12); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), box); + gtk_widget_show (box); + filename = file_utils_uri_to_utf8_filename (uri); - message = g_strdup_printf (_("A file named '%s' already exists.\n\n" - "Do you want to replace it with the image " - "you are saving?"), filename); + gimp_message_box_set_primary_text (GIMP_MESSAGE_BOX (box), + _("A file named '%s' already exists."), + filename); g_free (filename); - query_box = gimp_query_boolean_box (_("File exists!"), - save_dialog, - gimp_standard_help_func, NULL, - GIMP_STOCK_QUESTION, - message, - _("Replace"), GTK_STOCK_CANCEL, - NULL, NULL, - file_save_overwrite_callback, - overwrite_data); - - g_free (message); - - gtk_window_set_transient_for (GTK_WINDOW (query_box), - GTK_WINDOW (save_dialog)); + gimp_message_box_set_text (GIMP_MESSAGE_BOX (box), + _("Do you want to replace it with the image " + "you are saving?")); gimp_file_dialog_set_sensitive (GIMP_FILE_DIALOG (save_dialog), FALSE); gtk_dialog_set_response_sensitive (GTK_DIALOG (save_dialog), GTK_RESPONSE_CANCEL, FALSE); - gtk_widget_show (query_box); + gtk_widget_show (dialog); } static void -file_save_overwrite_callback (GtkWidget *widget, - gboolean overwrite, +file_save_overwrite_response (GtkWidget *dialog, + gint response_id, gpointer data) { OverwriteData *overwrite_data = data; - GimpFileDialog *dialog = GIMP_FILE_DIALOG (overwrite_data->save_dialog); + GimpFileDialog *save_dialog = GIMP_FILE_DIALOG (overwrite_data->save_dialog); - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), + gtk_dialog_set_response_sensitive (GTK_DIALOG (save_dialog), GTK_RESPONSE_CANCEL, TRUE); - if (overwrite) - { - gtk_widget_hide (widget); + gtk_widget_destroy (dialog); + if (response_id == GTK_RESPONSE_OK) + { if (file_save_dialog_save_image (overwrite_data->save_dialog, - dialog->gimage, + save_dialog->gimage, overwrite_data->uri, overwrite_data->raw_filename, - dialog->file_proc, - dialog->set_uri_and_proc, - dialog->set_image_clean)) + save_dialog->file_proc, + save_dialog->set_uri_and_proc, + save_dialog->set_image_clean)) { gtk_widget_hide (overwrite_data->save_dialog); } - } - gimp_file_dialog_set_sensitive (dialog, TRUE); + gimp_file_dialog_set_sensitive (save_dialog, TRUE); g_free (overwrite_data->uri); g_free (overwrite_data->raw_filename); diff --git a/app/widgets/gimphelp.c b/app/widgets/gimphelp.c index 469d1e5d3b..1d7ba3bb64 100644 --- a/app/widgets/gimphelp.c +++ b/app/widgets/gimphelp.c @@ -43,6 +43,7 @@ #include "gimphelp.h" #include "gimphelp-ids.h" +#include "gimpmessagebox.h" #include "gimp-intl.h" @@ -63,14 +64,20 @@ struct _GimpIdleHelp /* local function prototypes */ -static gint gimp_idle_help (gpointer data); -static gboolean gimp_help_internal (Gimp *gimp); -static void gimp_help_call (Gimp *gimp, - const gchar *procedure, - const gchar *help_domain, - const gchar *help_locales, - const gchar *help_id); -static gchar * gimp_help_get_locales (GimpGuiConfig *config); +static gint gimp_idle_help (gpointer data); + +static gboolean gimp_help_browser (Gimp *gimp); +static void gimp_help_browser_error (Gimp *gimp, + const gchar *title, + const gchar *primary, + const gchar *text); + +static void gimp_help_call (Gimp *gimp, + const gchar *procedure, + const gchar *help_domain, + const gchar *help_locales, + const gchar *help_id); +static gchar * gimp_help_get_locales (GimpGuiConfig *config); /* public functions */ @@ -128,7 +135,7 @@ gimp_idle_help (gpointer data) if (config->help_browser == GIMP_HELP_BROWSER_GIMP) { - if (gimp_help_internal (idle_help->gimp)) + if (gimp_help_browser (idle_help->gimp)) procedure = "extension_gimp_help_browser_temp"; } @@ -153,23 +160,8 @@ gimp_idle_help (gpointer data) return FALSE; } -static void -gimp_help_internal_not_found_callback (GtkWidget *widget, - gboolean use_web_browser, - gpointer data) -{ - Gimp *gimp = GIMP (data); - - if (use_web_browser) - g_object_set (gimp->config, - "help-browser", GIMP_HELP_BROWSER_WEB_BROWSER, - NULL); - - gtk_main_quit (); -} - static gboolean -gimp_help_internal (Gimp *gimp) +gimp_help_browser (Gimp *gimp) { static gboolean busy = FALSE; ProcRecord *proc_rec; @@ -190,20 +182,11 @@ gimp_help_internal (Gimp *gimp) if (! proc_rec) { - GtkWidget *dialog = - gimp_query_boolean_box (_("Help browser not found"), - NULL, NULL, NULL, GIMP_STOCK_WARNING, - _("Could not find GIMP help browser.\n\n" - "The GIMP help browser plug-in appears " - "to be missing from your installation."), - _("Use _web browser instead"), - GTK_STOCK_CANCEL, - NULL, NULL, - gimp_help_internal_not_found_callback, - gimp); - gtk_widget_show (dialog); - gtk_main (); - + gimp_help_browser_error (gimp, + _("Help browser not found"), + _("Could not find GIMP help browser."), + _("The GIMP help browser plug-in appears " + "to be missing from your installation.")); busy = FALSE; return FALSE; @@ -225,19 +208,10 @@ gimp_help_internal (Gimp *gimp) if (! proc_rec) { - GtkWidget *dialog = - gimp_query_boolean_box (_("Help browser doesn't start"), - NULL, NULL, NULL, GIMP_STOCK_WARNING, - _("Could not start the GIMP help browser " - "plug-in."), - _("Use web browser instead"), - GTK_STOCK_CANCEL, - NULL, NULL, - gimp_help_internal_not_found_callback, - gimp); - gtk_widget_show (dialog); - gtk_main (); - + gimp_help_browser_error (gimp, + _("Help browser doesn't start"), + _("Could not start the GIMP help browser plug-in."), + NULL); busy = FALSE; return FALSE; @@ -248,6 +222,40 @@ gimp_help_internal (Gimp *gimp) return TRUE; } +static void +gimp_help_browser_error (Gimp *gimp, + const gchar *title, + const gchar *primary, + const gchar *text) +{ + GtkWidget *dialog; + GtkWidget *box; + + dialog = gimp_dialog_new (title, "gimp-help-error", + NULL, 0, + NULL, NULL, + + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + _("Use _web browser instead"), GTK_RESPONSE_OK, + + NULL); + + box = gimp_message_box_new (GIMP_STOCK_WARNING); + gtk_container_set_border_width (GTK_CONTAINER (box), 12); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), box); + gtk_widget_show (box); + + gimp_message_box_set_primary_text (GIMP_MESSAGE_BOX (box), primary); + gimp_message_box_set_text (GIMP_MESSAGE_BOX (box), text); + + if (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK) + g_object_set (gimp->config, + "help-browser", GIMP_HELP_BROWSER_WEB_BROWSER, + NULL); + + gtk_widget_destroy (dialog); +} + static void gimp_help_call (Gimp *gimp, const gchar *procedure, @@ -347,3 +355,4 @@ gimp_help_get_locales (GimpGuiConfig *config) return locale; } + diff --git a/app/widgets/widgets-enums.c b/app/widgets/widgets-enums.c index 0b22c85100..b0d0cb87da 100644 --- a/app/widgets/widgets-enums.c +++ b/app/widgets/widgets-enums.c @@ -124,7 +124,7 @@ gimp_help_browser_type_get_type (void) { static const GEnumValue values[] = { - { GIMP_HELP_BROWSER_GIMP, N_("Internal"), "gimp" }, + { GIMP_HELP_BROWSER_GIMP, N_("GIMP help browser"), "gimp" }, { GIMP_HELP_BROWSER_WEB_BROWSER, N_("Web browser"), "web-browser" }, { 0, NULL, NULL } }; diff --git a/app/widgets/widgets-enums.h b/app/widgets/widgets-enums.h index 160879c5a1..c49d0b5060 100644 --- a/app/widgets/widgets-enums.h +++ b/app/widgets/widgets-enums.h @@ -100,8 +100,8 @@ GType gimp_help_browser_type_get_type (void) G_GNUC_CONST; typedef enum { - GIMP_HELP_BROWSER_GIMP, /*< desc="Internal" >*/ - GIMP_HELP_BROWSER_WEB_BROWSER /*< desc="Web browser" >*/ + GIMP_HELP_BROWSER_GIMP, /*< desc="GIMP help browser" >*/ + GIMP_HELP_BROWSER_WEB_BROWSER /*< desc="Web browser" >*/ } GimpHelpBrowserType;