diff --git a/ChangeLog b/ChangeLog index 0c634582c7..25d5128bb5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,98 @@ +2006-10-09 Michael Natterer + + Added message severities and make sure all messages are routed + through a central function, so redirecting to the error console or + stderr work again: + + * app/core/core-enums.[ch]: added enum GimpMessageSeverity { INFO, + WARNING, ERROR }. + + * app/core/gimp.[ch] (gimp_message) + (gimp_message_valist): added severity parameter. Changed + "GimpProgress *progress" parameter to "GObject *handler", where + "handler" can be either a GimpProgress, a GtkWidget or NULL. + + * app/core/gimp-gui.[ch] (gimp_show_message): ditto. Honor + --console-messages again. Always dispatch to the GUI message + handler first if it exists. + + * app/gui/gui-message.[ch]: pass severity parameters around. + + (gui_message_error_dialog): if "handler" is a progress, dispatch + the message to it first. If it is a widget (and *not* a progress), + use a GtkMessageDialog on top of that widget's toplevel. Fall + back to the usual GimpErrorDialog otherwise. + + * app/core/gimpprogress.[ch] (gimp_progress_message): added + severity parameter. Also added boolean return value to the virtual + function so it can decide to fail if it can't handle the message. + + * app/display/gimpdisplay.c: implement GimpProgress::message() and + redirect the message to GimpDisplayShell. + + * app/display/gimpdisplayshell-progress.c: implement + GimpProgress::message() and redirect the message to GimpStatusbar + if it is not an error and if the status bar is visible. + + * app/display/gimpstatusbar.[ch]: implement GimpProgress::message(), + but fail on messages that contain a newline. Show the right icons + for the message severities (work in progress). + + * app/display/gimpdisplayshell.[ch]: removed + gimp_display_shell_message() and its _valist() variant. + + * app/widgets/gimperrorconsole.[ch]: show the right icons for the + message severities. + + * app/widgets/gimpthumbbox.c (gimp_thumb_box_progress_message): + return TRUE to swallow all messages. + + * app/widgets/gimpwidgets-utils.[ch]: removed + gimp_show_message_dialog(). Added gimp_get_message_stock_id(). + + * app/errors.c + * app/actions/edit-commands.c + * app/actions/error-console-commands.c + * app/actions/file-commands.c + * app/actions/select-commands.c + * app/actions/text-editor-commands.c + * app/actions/vectors-commands.c + * app/core/gimpimage-convert.c + * app/core/gimpimagefile.c + * app/dialogs/convert-dialog.c + * app/dialogs/file-open-dialog.c + * app/dialogs/file-open-location-dialog.c + * app/dialogs/file-save-dialog.c + * app/dialogs/palette-import-dialog.c + * app/dialogs/stroke-dialog.c + * app/display/gimpdisplayshell-dnd.c + * app/pdb/gimppdb.c + * app/plug-in/gimpplugin.c + * app/tools/gimpimagemaptool.c + * app/tools/gimptool.c + * app/tools/gimpvectortool.c + * app/widgets/gimpactionview.c + * app/widgets/gimpcontrollerlist.c + * app/widgets/gimppdbdialog.c + * app/widgets/gimpvectorstreeview.c + * app/xcf/xcf-load.c + * app/xcf/xcf-save.c + * app/xcf/xcf.c + * tools/pdbgen/pdb/brush.pdb + * tools/pdbgen/pdb/gradient.pdb + * tools/pdbgen/pdb/image.pdb + * tools/pdbgen/pdb/message.pdb + * tools/pdbgen/pdb/palette.pdb: added severity parameter to + gimp_message() calls. Convert all calls to + gimp_show_message_dialog() and gimp_display_shell_message() to + gimp_message(). Also converted some more g_message() calls. + + * app/pdb/brush_cmds.c + * app/pdb/gradient_cmds.c + * app/pdb/image_cmds.c + * app/pdb/message_cmds.c + * app/pdb/palette_cmds.c: regenerated. + 2006-10-07 Manish Singh * plug-ins/pygimp/gimpfu.py: Don't use Python 2.4 specific functions, diff --git a/app/actions/edit-commands.c b/app/actions/edit-commands.c index ab90100c49..5e12b3acbf 100644 --- a/app/actions/edit-commands.c +++ b/app/actions/edit-commands.c @@ -265,7 +265,8 @@ edit_paste_as_new_cmd_callback (GtkAction *action, } else { - g_message (_("There is no image data in the clipboard to paste.")); + gimp_message (gimp, NULL, GIMP_MESSAGE_WARNING, + _("There is no image data in the clipboard to paste.")); } } @@ -418,9 +419,9 @@ edit_paste (GimpDisplay *display, } else { - gimp_display_shell_message (GIMP_DISPLAY_SHELL (display->shell), - _("There is no image data in " - "the clipboard to paste.")); + gimp_message (display->image->gimp, G_OBJECT (display), + GIMP_MESSAGE_WARNING, + _("There is no image data in the clipboard to paste.")); } } } @@ -437,7 +438,8 @@ cut_named_buffer_callback (GtkWidget *widget, if (! drawable) { - g_message (_("There is no active layer or channel to cut from.")); + gimp_message (image->gimp, NULL, GIMP_MESSAGE_WARNING, + _("There is no active layer or channel to cut from.")); return; } @@ -463,7 +465,8 @@ copy_named_buffer_callback (GtkWidget *widget, if (! drawable) { - g_message (_("There is no active layer or channel to copy from.")); + gimp_message (image->gimp, NULL, GIMP_MESSAGE_WARNING, + _("There is no active layer or channel to copy from.")); return; } diff --git a/app/actions/error-console-commands.c b/app/actions/error-console-commands.c index 2081eddc14..683e8b038b 100644 --- a/app/actions/error-console-commands.c +++ b/app/actions/error-console-commands.c @@ -25,6 +25,8 @@ #include "actions-types.h" +#include "core/gimp.h" + #include "widgets/gimperrorconsole.h" #include "widgets/gimphelp-ids.h" #include "widgets/gimpwidgets-utils.h" @@ -78,8 +80,8 @@ error_console_save_cmd_callback (GtkAction *action, if (value && ! gtk_text_buffer_get_selection_bounds (console->text_buffer, NULL, NULL)) { - gimp_show_message_dialog (GTK_WIDGET (console), GTK_MESSAGE_WARNING, - _("Cannot save. Nothing is selected.")); + gimp_message (console->gimp, G_OBJECT (console), GIMP_MESSAGE_WARNING, + _("Cannot save. Nothing is selected.")); return; } @@ -147,10 +149,10 @@ error_console_save_response (GtkWidget *dialog, if (! gimp_text_buffer_save (console->text_buffer, filename, console->save_selection, &error)) { - gimp_show_message_dialog (dialog, GTK_MESSAGE_ERROR, - _("Error writing file '%s':\n%s"), - gimp_filename_to_utf8 (filename), - error->message); + gimp_message (console->gimp, G_OBJECT (dialog), GIMP_MESSAGE_ERROR, + _("Error writing file '%s':\n%s"), + gimp_filename_to_utf8 (filename), + error->message); g_clear_error (&error); g_free (filename); return; diff --git a/app/actions/file-commands.c b/app/actions/file-commands.c index 5de68df96f..3fd2165e8e 100644 --- a/app/actions/file-commands.c +++ b/app/actions/file-commands.c @@ -173,8 +173,9 @@ file_last_opened_cmd_callback (GtkAction *action, gchar *filename = file_utils_uri_display_name (GIMP_OBJECT (imagefile)->name); - g_message (_("Opening '%s' failed:\n\n%s"), - filename, error->message); + gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, + _("Opening '%s' failed:\n\n%s"), + filename, error->message); g_clear_error (&error); g_free (filename); @@ -219,6 +220,7 @@ file_save_cmd_callback (GtkAction *action, GimpPDBStatusType status; GError *error = NULL; GList *list; + gchar *filename; for (list = gimp_action_groups_from_name ("file"); list; @@ -233,19 +235,31 @@ file_save_cmd_callback (GtkAction *action, uri, save_proc, GIMP_RUN_WITH_LAST_VALS, FALSE, &error); - if (status != GIMP_PDB_SUCCESS && - status != GIMP_PDB_CANCEL) - { - gchar *filename = file_utils_uri_display_name (uri); + filename = file_utils_uri_display_name (uri); - gimp_message (image->gimp, GIMP_PROGRESS (display), + switch (status) + { + case GIMP_PDB_SUCCESS: + gimp_message (image->gimp, G_OBJECT (display), GIMP_MESSAGE_INFO, + _("Image saved to '%s'"), + filename); + break; + + case GIMP_PDB_CANCEL: + gimp_message (image->gimp, G_OBJECT (display), GIMP_MESSAGE_INFO, + _("Saving canceled")); + break; + + default: + gimp_message (image->gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR, _("Saving '%s' failed:\n\n%s"), filename, error->message); g_clear_error (&error); - - g_free (filename); + break; } + g_free (filename); + for (list = gimp_action_groups_from_name ("file"); list; list = g_list_next (list)) @@ -326,7 +340,7 @@ file_revert_cmd_callback (GtkAction *action, if (! uri) { - gimp_message (image->gimp, GIMP_PROGRESS (display), + gimp_message (image->gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR, _("Revert failed. " "No file name associated with this image.")); } @@ -567,7 +581,7 @@ file_revert_confirm_response (GtkWidget *dialog, { gchar *filename = file_utils_uri_display_name (uri); - gimp_message (gimp, GIMP_PROGRESS (display), + gimp_message (gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR, _("Reverting to '%s' failed:\n\n%s"), filename, error->message); g_clear_error (&error); diff --git a/app/actions/select-commands.c b/app/actions/select-commands.c index a145ec318a..59c96bdb0e 100644 --- a/app/actions/select-commands.c +++ b/app/actions/select-commands.c @@ -286,7 +286,8 @@ select_stroke_cmd_callback (GtkAction *action, if (! drawable) { - g_message (_("There is no active layer or channel to stroke to.")); + gimp_message (image->gimp, NULL, GIMP_MESSAGE_WARNING, + _("There is no active layer or channel to stroke to.")); return; } @@ -314,7 +315,8 @@ select_stroke_last_vals_cmd_callback (GtkAction *action, if (! drawable) { - g_message (_("There is no active layer or channel to stroke to.")); + gimp_message (image->gimp, NULL, GIMP_MESSAGE_WARNING, + _("There is no active layer or channel to stroke to.")); return; } diff --git a/app/actions/text-editor-commands.c b/app/actions/text-editor-commands.c index acb2712d8c..42a7ba67f7 100644 --- a/app/actions/text-editor-commands.c +++ b/app/actions/text-editor-commands.c @@ -25,8 +25,11 @@ #include "actions-types.h" +#include "core/gimp.h" + #include "widgets/gimptexteditor.h" #include "widgets/gimphelp-ids.h" +#include "widgets/gimpuimanager.h" #include "widgets/gimpwidgets-utils.h" #include "text-editor-commands.h" @@ -134,10 +137,11 @@ text_editor_load_response (GtkWidget *dialog, if (! gimp_text_buffer_load (buffer, filename, &error)) { - gimp_show_message_dialog (dialog, GTK_MESSAGE_ERROR, - _("Could not open '%s' for reading: %s"), - gimp_filename_to_utf8 (filename), - error->message); + gimp_message (editor->ui_manager->gimp, G_OBJECT (dialog), + GIMP_MESSAGE_ERROR, + _("Could not open '%s' for reading: %s"), + gimp_filename_to_utf8 (filename), + error->message); g_clear_error (&error); g_free (filename); return; diff --git a/app/actions/vectors-commands.c b/app/actions/vectors-commands.c index 61135b3ded..9316f38002 100644 --- a/app/actions/vectors-commands.c +++ b/app/actions/vectors-commands.c @@ -356,7 +356,8 @@ vectors_stroke_cmd_callback (GtkAction *action, if (! drawable) { - g_message (_("There is no active layer or channel to stroke to.")); + gimp_message (image->gimp, NULL, GIMP_MESSAGE_WARNING, + _("There is no active layer or channel to stroke to.")); return; } @@ -385,7 +386,8 @@ vectors_stroke_last_vals_cmd_callback (GtkAction *action, if (! drawable) { - g_message (_("There is no active layer or channel to stroke to.")); + gimp_message (image->gimp, NULL, GIMP_MESSAGE_WARNING, + _("There is no active layer or channel to stroke to.")); return; } @@ -440,7 +442,8 @@ vectors_paste_cmd_callback (GtkAction *action, if (! gimp_vectors_import_buffer (image, svg, svg_size, TRUE, TRUE, -1, &error)) { - g_message (error->message); + gimp_message (image->gimp, NULL, GIMP_MESSAGE_ERROR, + error->message); g_clear_error (&error); } else @@ -621,7 +624,8 @@ vectors_import_response (GtkWidget *widget, } else { - g_message (error->message); + gimp_message (dialog->image->gimp, NULL, GIMP_MESSAGE_ERROR, + error->message); g_error_free (error); } @@ -651,7 +655,8 @@ vectors_export_response (GtkWidget *widget, if (! gimp_vectors_export_file (dialog->image, vectors, filename, &error)) { - g_message (error->message); + gimp_message (dialog->image->gimp, NULL, GIMP_MESSAGE_ERROR, + error->message); g_error_free (error); } diff --git a/app/core/core-enums.c b/app/core/core-enums.c index ae300a861f..51927ed93f 100644 --- a/app/core/core-enums.c +++ b/app/core/core-enums.c @@ -1210,6 +1210,36 @@ gimp_select_criterion_get_type (void) return type; } +GType +gimp_message_severity_get_type (void) +{ + static const GEnumValue values[] = + { + { GIMP_MESSAGE_INFO, "GIMP_MESSAGE_INFO", "info" }, + { GIMP_MESSAGE_WARNING, "GIMP_MESSAGE_WARNING", "warning" }, + { GIMP_MESSAGE_ERROR, "GIMP_MESSAGE_ERROR", "error" }, + { 0, NULL, NULL } + }; + + static const GimpEnumDesc descs[] = + { + { GIMP_MESSAGE_INFO, N_("Message"), NULL }, + { GIMP_MESSAGE_WARNING, N_("Warning"), NULL }, + { GIMP_MESSAGE_ERROR, N_("Error"), NULL }, + { 0, NULL, NULL } + }; + + static GType type = 0; + + if (! type) + { + type = g_enum_register_static ("GimpMessageSeverity", values); + gimp_enum_set_value_descriptions (type, descs); + } + + return type; +} + /* Generated data ends here */ diff --git a/app/core/core-enums.h b/app/core/core-enums.h index a1af5837d9..cd6fe4d4b2 100644 --- a/app/core/core-enums.h +++ b/app/core/core-enums.h @@ -549,7 +549,7 @@ typedef enum GType gimp_select_criterion_get_type (void) G_GNUC_CONST; -typedef enum +typedef enum { GIMP_SELECT_CRITERION_COMPOSITE, /*< desc="Composite" >*/ GIMP_SELECT_CRITERION_R, /*< desc="Red" >*/ @@ -561,6 +561,18 @@ typedef enum } GimpSelectCriterion; +#define GIMP_TYPE_MESSAGE_SEVERITY (gimp_message_severity_get_type ()) + +GType gimp_message_severity_get_type (void) G_GNUC_CONST; + +typedef enum /*< pdb-skip >*/ +{ + GIMP_MESSAGE_INFO, /*< desc="Message" >*/ + GIMP_MESSAGE_WARNING, /*< desc="Warning" >*/ + GIMP_MESSAGE_ERROR /*< desc="Error" >*/ +} GimpMessageSeverity; + + /* * non-registered enums; register them if needed */ diff --git a/app/core/gimp-gui.c b/app/core/gimp-gui.c index f8f01fdcd5..88e0575e29 100644 --- a/app/core/gimp-gui.c +++ b/app/core/gimp-gui.c @@ -149,31 +149,41 @@ gimp_unset_busy (Gimp *gimp) } void -gimp_show_message (Gimp *gimp, - GimpProgress *progress, - const gchar *domain, - const gchar *message) +gimp_show_message (Gimp *gimp, + GObject *handler, + GimpMessageSeverity severity, + const gchar *domain, + const gchar *message) { + const gchar *desc = "Message"; + g_return_if_fail (GIMP_IS_GIMP (gimp)); - g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress)); + g_return_if_fail (handler == NULL || G_IS_OBJECT (handler)); g_return_if_fail (message != NULL); if (! domain) domain = GIMP_ACRONYM; - if (progress && - gimp_progress_message (progress, gimp, domain, message)) + if (! gimp->console_messages) { - /* message has already been handled by GimpProgress */ - } - else if (gimp->gui.show_message && ! gimp->console_messages) - { - gimp->gui.show_message (gimp, progress, domain, message); - } - else - { - g_printerr ("%s: %s\n\n", domain, message); + if (gimp->gui.show_message) + { + gimp->gui.show_message (gimp, handler, + severity, domain, message); + return; + } + else if (GIMP_IS_PROGRESS (handler) && + gimp_progress_message (GIMP_PROGRESS (handler), gimp, + severity, domain, message)) + { + /* message has been handled by GimpProgress */ + return; + } } + + gimp_enum_get_value (GIMP_TYPE_MESSAGE_SEVERITY, severity, + NULL, NULL, &desc, NULL); + g_printerr ("%s-%s: %s\n\n", domain, desc, message); } void diff --git a/app/core/gimp-gui.h b/app/core/gimp-gui.h index 8d090ee5fd..a152986f2e 100644 --- a/app/core/gimp-gui.h +++ b/app/core/gimp-gui.h @@ -33,7 +33,8 @@ struct _GimpGui void (* unset_busy) (Gimp *gimp); void (* show_message) (Gimp *gimp, - GimpProgress *progress, + GObject *handler, + GimpMessageSeverity severity, const gchar *domain, const gchar *message); void (* help) (Gimp *gimp, @@ -110,7 +111,8 @@ void gimp_set_busy_until_idle (Gimp *gimp); void gimp_unset_busy (Gimp *gimp); void gimp_show_message (Gimp *gimp, - GimpProgress *progress, + GObject *handler, + GimpMessageSeverity severity, const gchar *domain, const gchar *message); void gimp_help (Gimp *gimp, diff --git a/app/core/gimp.c b/app/core/gimp.c index 22234bdf8b..ccf862c811 100644 --- a/app/core/gimp.c +++ b/app/core/gimp.c @@ -994,34 +994,37 @@ gimp_get_tool_info (Gimp *gimp, } void -gimp_message (Gimp *gimp, - GimpProgress *progress, - const gchar *format, +gimp_message (Gimp *gimp, + GObject *handler, + GimpMessageSeverity severity, + const gchar *format, ...) { va_list args; va_start (args, format); - gimp_message_valist (gimp, progress, format, args); + gimp_message_valist (gimp, handler, severity, format, args); va_end (args); } void -gimp_message_valist (Gimp *gimp, - GimpProgress *progress, - const gchar *format, - va_list args) +gimp_message_valist (Gimp *gimp, + GObject *handler, + GimpMessageSeverity severity, + const gchar *format, + va_list args) { gchar *message; g_return_if_fail (GIMP_IS_GIMP (gimp)); - g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress)); + g_return_if_fail (handler == NULL || G_IS_OBJECT (handler)); + g_return_if_fail (format != NULL); message = g_strdup_vprintf (format, args); - gimp_show_message (gimp, progress, NULL, message); + gimp_show_message (gimp, handler, severity, NULL, message); g_free (message); } diff --git a/app/core/gimp.h b/app/core/gimp.h index 939ade9ec3..06d7b57eb8 100644 --- a/app/core/gimp.h +++ b/app/core/gimp.h @@ -175,11 +175,13 @@ GimpToolInfo * gimp_get_tool_info (Gimp *gimp, const gchar *tool_name); void gimp_message (Gimp *gimp, - GimpProgress *progress, + GObject *handler, + GimpMessageSeverity severity, const gchar *format, - ...) G_GNUC_PRINTF(3,4); + ...) G_GNUC_PRINTF(4,5); void gimp_message_valist (Gimp *gimp, - GimpProgress *progress, + GObject *handler, + GimpMessageSeverity severity, const gchar *format, va_list args); diff --git a/app/core/gimpimage-convert.c b/app/core/gimpimage-convert.c index 559d55e9cd..f1fdfbd4e0 100644 --- a/app/core/gimpimage-convert.c +++ b/app/core/gimpimage-convert.c @@ -789,7 +789,7 @@ gimp_image_convert (GimpImage *image, if (custom_palette->n_colors < 1) { - gimp_message (image->gimp, progress, + gimp_message (image->gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, _("Cannot convert image: palette is empty.")); return; } diff --git a/app/core/gimpimagefile.c b/app/core/gimpimagefile.c index 4628e7cc8a..f22f4139ba 100644 --- a/app/core/gimpimagefile.c +++ b/app/core/gimpimagefile.c @@ -290,7 +290,8 @@ gimp_imagefile_create_thumbnail (GimpImagefile *imagefile, if (! success) { - gimp_message (imagefile->gimp, progress, error->message); + gimp_message (imagefile->gimp, G_OBJECT (progress), + GIMP_MESSAGE_ERROR, error->message); g_error_free (error); } } diff --git a/app/core/gimpprogress.c b/app/core/gimpprogress.c index 516858866c..80d8a6cc38 100644 --- a/app/core/gimpprogress.c +++ b/app/core/gimpprogress.c @@ -219,23 +219,23 @@ gimp_progress_get_window (GimpProgress *progress) } gboolean -gimp_progress_message (GimpProgress *progress, - Gimp *gimp, - const gchar *domain, - const gchar *message) +gimp_progress_message (GimpProgress *progress, + Gimp *gimp, + GimpMessageSeverity severity, + const gchar *domain, + const gchar *message) { GimpProgressInterface *progress_iface; g_return_val_if_fail (GIMP_IS_PROGRESS (progress), FALSE); + g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE); + g_return_val_if_fail (domain != NULL, FALSE); + g_return_val_if_fail (message != NULL, FALSE); progress_iface = GIMP_PROGRESS_GET_INTERFACE (progress); if (progress_iface->message) - { - progress_iface->message (progress, gimp, domain, message); - - return TRUE; - } + return progress_iface->message (progress, gimp, severity, domain, message); return FALSE; } diff --git a/app/core/gimpprogress.h b/app/core/gimpprogress.h index a3c9f50fff..cbb26856db 100644 --- a/app/core/gimpprogress.h +++ b/app/core/gimpprogress.h @@ -36,59 +36,61 @@ struct _GimpProgressInterface GTypeInterface base_iface; /* virtual functions */ - GimpProgress * (* start) (GimpProgress *progress, - const gchar *message, - gboolean cancelable); - void (* end) (GimpProgress *progress); - gboolean (* is_active) (GimpProgress *progress); + GimpProgress * (* start) (GimpProgress *progress, + const gchar *message, + gboolean cancelable); + void (* end) (GimpProgress *progress); + gboolean (* is_active) (GimpProgress *progress); - void (* set_text) (GimpProgress *progress, - const gchar *message); - void (* set_value) (GimpProgress *progress, - gdouble percentage); - gdouble (* get_value) (GimpProgress *progress); - void (* pulse) (GimpProgress *progress); + void (* set_text) (GimpProgress *progress, + const gchar *message); + void (* set_value) (GimpProgress *progress, + gdouble percentage); + gdouble (* get_value) (GimpProgress *progress); + void (* pulse) (GimpProgress *progress); - guint32 (* get_window) (GimpProgress *progress); + guint32 (* get_window) (GimpProgress *progress); - void (* message) (GimpProgress *progress, - Gimp *gimp, - const gchar *domain, - const gchar *message); + gboolean (* message) (GimpProgress *progress, + Gimp *gimp, + GimpMessageSeverity severity, + const gchar *domain, + const gchar *message); /* signals */ - void (* cancel) (GimpProgress *progress); + void (* cancel) (GimpProgress *progress); }; GType gimp_progress_interface_get_type (void) G_GNUC_CONST; -GimpProgress * gimp_progress_start (GimpProgress *progress, - const gchar *message, - gboolean cancelable); -void gimp_progress_end (GimpProgress *progress); -gboolean gimp_progress_is_active (GimpProgress *progress); +GimpProgress * gimp_progress_start (GimpProgress *progress, + const gchar *message, + gboolean cancelable); +void gimp_progress_end (GimpProgress *progress); +gboolean gimp_progress_is_active (GimpProgress *progress); -void gimp_progress_set_text (GimpProgress *progress, - const gchar *message); -void gimp_progress_set_value (GimpProgress *progress, - gdouble percentage); -gdouble gimp_progress_get_value (GimpProgress *progress); -void gimp_progress_pulse (GimpProgress *progress); +void gimp_progress_set_text (GimpProgress *progress, + const gchar *message); +void gimp_progress_set_value (GimpProgress *progress, + gdouble percentage); +gdouble gimp_progress_get_value (GimpProgress *progress); +void gimp_progress_pulse (GimpProgress *progress); -guint32 gimp_progress_get_window (GimpProgress *progress); +guint32 gimp_progress_get_window (GimpProgress *progress); -gboolean gimp_progress_message (GimpProgress *progress, - Gimp *gimp, - const gchar *domain, - const gchar *message); +gboolean gimp_progress_message (GimpProgress *progress, + Gimp *gimp, + GimpMessageSeverity severity, + const gchar *domain, + const gchar *message); -void gimp_progress_cancel (GimpProgress *progress); +void gimp_progress_cancel (GimpProgress *progress); -void gimp_progress_update_and_flush (gint min, - gint max, - gint current, - gpointer data); +void gimp_progress_update_and_flush (gint min, + gint max, + gint current, + gpointer data); #endif /* __GIMP_PROGRESS_H__ */ diff --git a/app/dialogs/convert-dialog.c b/app/dialogs/convert-dialog.c index f89730614c..7b7a450e58 100644 --- a/app/dialogs/convert-dialog.c +++ b/app/dialogs/convert-dialog.c @@ -394,9 +394,10 @@ convert_dialog_palette_changed (GimpContext *context, if (palette->n_colors > 256) { - gimp_show_message_dialog (dialog->dialog, GTK_MESSAGE_WARNING, - _("Cannot convert to a palette " - "with more than 256 colors.")); + gimp_message (dialog->image->gimp, G_OBJECT (dialog->dialog), + GIMP_MESSAGE_WARNING, + _("Cannot convert to a palette " + "with more than 256 colors.")); } else { diff --git a/app/dialogs/file-open-dialog.c b/app/dialogs/file-open-dialog.c index 6854d84f98..30c2b90d56 100644 --- a/app/dialogs/file-open-dialog.c +++ b/app/dialogs/file-open-dialog.c @@ -200,7 +200,7 @@ file_open_dialog_open_image (GtkWidget *open_dialog, { gchar *filename = file_utils_uri_display_name (uri); - gimp_message (gimp, GIMP_PROGRESS (open_dialog), + gimp_message (gimp, G_OBJECT (open_dialog), GIMP_MESSAGE_ERROR, _("Opening '%s' failed:\n\n%s"), filename, error->message); g_clear_error (&error); @@ -251,7 +251,7 @@ file_open_dialog_open_layer (GtkWidget *open_dialog, { gchar *filename = file_utils_uri_display_name (uri); - gimp_message (image->gimp, GIMP_PROGRESS (open_dialog), + gimp_message (image->gimp, G_OBJECT (open_dialog), GIMP_MESSAGE_ERROR, _("Opening '%s' failed:\n\n%s"), filename, error->message); g_clear_error (&error); diff --git a/app/dialogs/file-open-location-dialog.c b/app/dialogs/file-open-location-dialog.c index f497a7b08e..e52647be52 100644 --- a/app/dialogs/file-open-location-dialog.c +++ b/app/dialogs/file-open-location-dialog.c @@ -212,7 +212,7 @@ file_open_location_response (GtkDialog *dialog, { gchar *filename = file_utils_uri_display_name (uri); - gimp_message (gimp, GIMP_PROGRESS (box), + gimp_message (gimp, G_OBJECT (box), GIMP_MESSAGE_ERROR, _("Opening '%s' failed:\n\n%s"), filename, error->message); g_clear_error (&error); @@ -224,7 +224,7 @@ file_open_location_response (GtkDialog *dialog, } else { - gimp_message (gimp, GIMP_PROGRESS (box), + gimp_message (gimp, G_OBJECT (box), GIMP_MESSAGE_ERROR, _("Opening '%s' failed:\n\n%s"), text, error->message); g_clear_error (&error); diff --git a/app/dialogs/file-save-dialog.c b/app/dialogs/file-save-dialog.c index 4af51cc9b0..81c83a92bd 100644 --- a/app/dialogs/file-save-dialog.c +++ b/app/dialogs/file-save-dialog.c @@ -282,7 +282,7 @@ file_save_dialog_check_uri (GtkWidget *save_dialog, G_STRFUNC); #endif - gimp_message (gimp, GIMP_PROGRESS (save_dialog), + gimp_message (gimp, G_OBJECT (save_dialog), GIMP_MESSAGE_WARNING, _("The given filename does not have any known " "file extension. Please enter a known file " "extension or select a file format from the " @@ -325,7 +325,7 @@ file_save_dialog_check_uri (GtkWidget *save_dialog, G_STRFUNC); #endif - gimp_message (gimp, GIMP_PROGRESS (save_dialog), + gimp_message (gimp, G_OBJECT (save_dialog), GIMP_MESSAGE_WARNING, _("The given filename does not have any known " "file extension. Please enter a known file " "extension or select a file format from the " @@ -367,7 +367,7 @@ file_save_dialog_check_uri (GtkWidget *save_dialog, /* remote URI */ - gimp_message (gimp, GIMP_PROGRESS (save_dialog), + gimp_message (gimp, G_OBJECT (save_dialog), GIMP_MESSAGE_WARNING, _("Saving remote files needs to determine the " "file format from the file extension. " "Please enter a file extension that matches " @@ -504,7 +504,7 @@ file_save_dialog_save_image (GtkWidget *save_dialog, { gchar *filename = file_utils_uri_display_name (uri); - gimp_message (image->gimp, GIMP_PROGRESS (save_dialog), + gimp_message (image->gimp, G_OBJECT (save_dialog), GIMP_MESSAGE_ERROR, _("Saving '%s' failed:\n\n%s"), filename, error->message); g_clear_error (&error); diff --git a/app/dialogs/palette-import-dialog.c b/app/dialogs/palette-import-dialog.c index 68f12e5944..f895514b64 100644 --- a/app/dialogs/palette-import-dialog.c +++ b/app/dialogs/palette-import-dialog.c @@ -846,8 +846,9 @@ palette_import_make_palette (ImportDialog *dialog) if (! palette) { - gimp_show_message_dialog (dialog->dialog, GTK_MESSAGE_ERROR, - error->message); + gimp_message (dialog->context->gimp, G_OBJECT (dialog->dialog), + GIMP_MESSAGE_ERROR, + error->message); g_error_free (error); } } diff --git a/app/dialogs/stroke-dialog.c b/app/dialogs/stroke-dialog.c index 22b84236c1..b8297e7fa5 100644 --- a/app/dialogs/stroke-dialog.c +++ b/app/dialogs/stroke-dialog.c @@ -39,7 +39,6 @@ #include "widgets/gimpcontainerview.h" #include "widgets/gimpviewabledialog.h" #include "widgets/gimpstrokeeditor.h" -#include "widgets/gimpwidgets-utils.h" #include "stroke-dialog.h" @@ -279,9 +278,10 @@ stroke_dialog_response (GtkWidget *widget, if (! drawable) { - gimp_show_message_dialog (widget, GTK_MESSAGE_WARNING, - _("There is no active layer or channel " - "to stroke to.")); + gimp_message (context->gimp, G_OBJECT (widget), + GIMP_MESSAGE_WARNING, + _("There is no active layer or channel " + "to stroke to.")); return; } diff --git a/app/display/gimpdisplay.c b/app/display/gimpdisplay.c index 7c51047432..7eeef64783 100644 --- a/app/display/gimpdisplay.c +++ b/app/display/gimpdisplay.c @@ -54,38 +54,43 @@ enum static void gimp_display_progress_iface_init (GimpProgressInterface *iface); -static void gimp_display_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); -static void gimp_display_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); +static void gimp_display_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void gimp_display_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); static GimpProgress * - gimp_display_progress_start (GimpProgress *progress, - const gchar *message, - gboolean cancelable); -static void gimp_display_progress_end (GimpProgress *progress); -static gboolean gimp_display_progress_is_active (GimpProgress *progress); -static void gimp_display_progress_set_text (GimpProgress *progress, - const gchar *message); -static void gimp_display_progress_set_value (GimpProgress *progress, - gdouble percentage); -static gdouble gimp_display_progress_get_value (GimpProgress *progress); -static void gimp_display_progress_pulse (GimpProgress *progress); -static guint32 gimp_display_progress_get_window (GimpProgress *progress); -static void gimp_display_progress_canceled (GimpProgress *progress, - GimpDisplay *display); + gimp_display_progress_start (GimpProgress *progress, + const gchar *message, + gboolean cancelable); +static void gimp_display_progress_end (GimpProgress *progress); +static gboolean gimp_display_progress_is_active (GimpProgress *progress); +static void gimp_display_progress_set_text (GimpProgress *progress, + const gchar *message); +static void gimp_display_progress_set_value (GimpProgress *progress, + gdouble percentage); +static gdouble gimp_display_progress_get_value (GimpProgress *progress); +static void gimp_display_progress_pulse (GimpProgress *progress); +static guint32 gimp_display_progress_get_window (GimpProgress *progress); +static gboolean gimp_display_progress_message (GimpProgress *progress, + Gimp *gimp, + GimpMessageSeverity severity, + const gchar *domain, + const gchar *message); +static void gimp_display_progress_canceled (GimpProgress *progress, + GimpDisplay *display); -static void gimp_display_flush_whenever (GimpDisplay *display, - gboolean now); -static void gimp_display_paint_area (GimpDisplay *display, - gint x, - gint y, - gint w, - gint h); +static void gimp_display_flush_whenever (GimpDisplay *display, + gboolean now); +static void gimp_display_paint_area (GimpDisplay *display, + gint x, + gint y, + gint w, + gint h); G_DEFINE_TYPE_WITH_CODE (GimpDisplay, gimp_display, GIMP_TYPE_OBJECT, @@ -147,6 +152,7 @@ gimp_display_progress_iface_init (GimpProgressInterface *iface) iface->get_value = gimp_display_progress_get_value; iface->pulse = gimp_display_progress_pulse; iface->get_window = gimp_display_progress_get_window; + iface->message = gimp_display_progress_message; } static void @@ -204,11 +210,11 @@ gimp_display_progress_start (GimpProgress *progress, { GimpDisplay *display = GIMP_DISPLAY (progress); - if (! display->shell) - return NULL; + if (display->shell) + return gimp_progress_start (GIMP_PROGRESS (display->shell), + message, cancelable); - return gimp_progress_start (GIMP_PROGRESS (display->shell), - message, cancelable); + return NULL; } static void @@ -225,10 +231,10 @@ gimp_display_progress_is_active (GimpProgress *progress) { GimpDisplay *display = GIMP_DISPLAY (progress); - if (! display->shell) - return FALSE; + if (display->shell) + return gimp_progress_is_active (GIMP_PROGRESS (display->shell)); - return gimp_progress_is_active (GIMP_PROGRESS (display->shell)); + return FALSE; } static void @@ -256,10 +262,10 @@ gimp_display_progress_get_value (GimpProgress *progress) { GimpDisplay *display = GIMP_DISPLAY (progress); - if (! display->shell) - return 0.0; + if (display->shell) + return gimp_progress_get_value (GIMP_PROGRESS (display->shell)); - return gimp_progress_get_value (GIMP_PROGRESS (display->shell)); + return 0.0; } static void @@ -276,10 +282,26 @@ gimp_display_progress_get_window (GimpProgress *progress) { GimpDisplay *display = GIMP_DISPLAY (progress); - if (! display->shell) - return 0; + if (display->shell) + return gimp_progress_get_window (GIMP_PROGRESS (display->shell)); - return gimp_progress_get_window (GIMP_PROGRESS (display->shell)); + return 0; +} + +static gboolean +gimp_display_progress_message (GimpProgress *progress, + Gimp *gimp, + GimpMessageSeverity severity, + const gchar *domain, + const gchar *message) +{ + GimpDisplay *display = GIMP_DISPLAY (progress); + + if (display->shell) + return gimp_progress_message (GIMP_PROGRESS (display->shell), gimp, + severity, domain, message); + + return FALSE; } static void diff --git a/app/display/gimpdisplayshell-dnd.c b/app/display/gimpdisplayshell-dnd.c index 995cb8aa04..583bda9385 100644 --- a/app/display/gimpdisplayshell-dnd.c +++ b/app/display/gimpdisplayshell-dnd.c @@ -277,7 +277,7 @@ gimp_display_shell_drop_svg (GtkWidget *widget, (const gchar *) svg_data, svg_data_len, TRUE, TRUE, -1, &error)) { - gimp_message (image->gimp, GIMP_PROGRESS (shell->display), + gimp_message (image->gimp, G_OBJECT (shell->display), GIMP_MESSAGE_ERROR, error->message); g_clear_error (&error); } @@ -448,7 +448,8 @@ gimp_display_shell_drop_uri_list (GtkWidget *widget, { gchar *filename = file_utils_uri_display_name (uri); - gimp_message (image->gimp, GIMP_PROGRESS (shell->display), + gimp_message (image->gimp, G_OBJECT (shell->display), + GIMP_MESSAGE_ERROR, _("Opening '%s' failed:\n\n%s"), filename, error->message); diff --git a/app/display/gimpdisplayshell-progress.c b/app/display/gimpdisplayshell-progress.c index c413542cd2..74bffca23d 100644 --- a/app/display/gimpdisplayshell-progress.c +++ b/app/display/gimpdisplayshell-progress.c @@ -28,6 +28,7 @@ #include "gimpdisplayshell.h" #include "gimpdisplayshell-progress.h" +#include "gimpstatusbar.h" static GimpProgress * @@ -99,6 +100,22 @@ gimp_display_shell_progress_get_window (GimpProgress *progress) return (guint32) gimp_window_get_native (GTK_WINDOW (shell)); } +static gboolean +gimp_display_shell_progress_message (GimpProgress *progress, + Gimp *gimp, + GimpMessageSeverity severity, + const gchar *domain, + const gchar *message) +{ + GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress); + + if (severity != GIMP_MESSAGE_ERROR && GTK_WIDGET_VISIBLE (shell->statusbar)) + return gimp_progress_message (GIMP_PROGRESS (shell->statusbar), gimp, + severity, domain, message); + + return FALSE; +} + void gimp_display_shell_progress_iface_init (GimpProgressInterface *iface) { @@ -110,4 +127,5 @@ gimp_display_shell_progress_iface_init (GimpProgressInterface *iface) iface->get_value = gimp_display_shell_progress_get_value; iface->pulse = gimp_display_shell_progress_pulse; iface->get_window = gimp_display_shell_progress_get_window; + iface->message = gimp_display_shell_progress_message; } diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index 7daf555ca8..e4a99146b2 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -1636,56 +1636,3 @@ gimp_display_shell_set_mask (GimpDisplayShell *shell, gimp_display_shell_expose_full (shell); } - -/** - * gimp_display_shell_message: - * @shell: the #GimpDisplayShell - * @format: printf-like format string - * @...: arguments - * - * Display a message in the display shell. If the statusbar is - * visible, the message will appear there, otherwise a dialog window - * is opened. - */ -void -gimp_display_shell_message (GimpDisplayShell *shell, - const gchar *format, - ...) -{ - va_list args; - - va_start (args, format); - - gimp_display_shell_message_valist (shell, format, args); - - va_end (args); -} - -/** - * gimp_display_shell_message_valist: - * @shell: the #GimpDisplayShell - * @format: printf-like format string - * @args: arguments - * - * Display a message in the display shell. See gimp_display_shell_message() - * for details. - */ -void -gimp_display_shell_message_valist (GimpDisplayShell *shell, - const gchar *format, - va_list args) -{ - g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); - g_return_if_fail (format != NULL); - - if (GTK_WIDGET_VISIBLE (shell->statusbar)) - { - gimp_statusbar_push_temp_valist (GIMP_STATUSBAR (shell->statusbar), - format, args); - } - else - { - gimp_message_valist (shell->display->image->gimp, GIMP_PROGRESS (shell), - format, args); - } -} diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h index e367b01096..2267c0b973 100644 --- a/app/display/gimpdisplayshell.h +++ b/app/display/gimpdisplayshell.h @@ -243,12 +243,5 @@ void gimp_display_shell_set_mask (GimpDisplayShell *shell, GimpDrawable *mask, GimpChannelType color); -void gimp_display_shell_message (GimpDisplayShell *shell, - const gchar *format, - ...) G_GNUC_PRINTF(2,3); -void gimp_display_shell_message_valist (GimpDisplayShell *shell, - const gchar *format, - va_list args); - #endif /* __GIMP_DISPLAY_SHELL_H__ */ diff --git a/app/display/gimpstatusbar.c b/app/display/gimpstatusbar.c index 88dad52296..415c6396a7 100644 --- a/app/display/gimpstatusbar.c +++ b/app/display/gimpstatusbar.c @@ -33,6 +33,7 @@ #include "widgets/gimpuimanager.h" #include "widgets/gimpunitstore.h" #include "widgets/gimpunitcombobox.h" +#include "widgets/gimpwidgets-utils.h" #include "gimpdisplay.h" #include "gimpdisplayshell.h" @@ -48,6 +49,7 @@ typedef struct _GimpStatusbarMsg GimpStatusbarMsg; struct _GimpStatusbarMsg { guint context_id; + gchar *stock_id; gchar *text; }; @@ -75,6 +77,11 @@ static void gimp_statusbar_progress_set_value (GimpProgress *progress, gdouble percentage); static gdouble gimp_statusbar_progress_get_value (GimpProgress *progress); static void gimp_statusbar_progress_pulse (GimpProgress *progress); +static gboolean gimp_statusbar_progress_message (GimpProgress *progress, + Gimp *gimp, + GimpMessageSeverity severity, + const gchar *domain, + const gchar *message); static void gimp_statusbar_progress_canceled (GtkWidget *button, GimpStatusbar *statusbar); @@ -96,6 +103,8 @@ static guint gimp_statusbar_get_context_id (GimpStatusbar *statusbar, const gchar *context); static gboolean gimp_statusbar_temp_timeout (GimpStatusbar *statusbar); +static void gimp_statusbar_msg_free (GimpStatusbarMsg *msg); + G_DEFINE_TYPE_WITH_CODE (GimpStatusbar, gimp_statusbar, GTK_TYPE_HBOX, G_IMPLEMENT_INTERFACE (GIMP_TYPE_PROGRESS, @@ -134,6 +143,7 @@ gimp_statusbar_progress_iface_init (GimpProgressInterface *iface) iface->set_value = gimp_statusbar_progress_set_value; iface->get_value = gimp_statusbar_progress_get_value; iface->pulse = gimp_statusbar_progress_pulse; + iface->message = gimp_statusbar_progress_message; } static void @@ -252,16 +262,8 @@ static void gimp_statusbar_finalize (GObject *object) { GimpStatusbar *statusbar = GIMP_STATUSBAR (object); - GSList *list; - - for (list = statusbar->messages; list; list = list->next) - { - GimpStatusbarMsg *msg = list->data; - - g_free (msg->text); - g_free (msg); - } + g_slist_foreach (statusbar->messages, (GFunc) gimp_statusbar_msg_free, NULL); g_slist_free (statusbar->messages); statusbar->messages = NULL; @@ -404,6 +406,25 @@ gimp_statusbar_progress_pulse (GimpProgress *progress) } } +static gboolean +gimp_statusbar_progress_message (GimpProgress *progress, + Gimp *gimp, + GimpMessageSeverity severity, + const gchar *domain, + const gchar *message) +{ + GimpStatusbar *statusbar = GIMP_STATUSBAR (progress); + + /* we can handle only one-liners */ + if (strchr (message, '\n')) + return FALSE; + + gimp_statusbar_push_temp (statusbar, + gimp_get_message_stock_id (severity), message); + + return TRUE; +} + static void gimp_statusbar_progress_canceled (GtkWidget *button, GimpStatusbar *statusbar) @@ -524,8 +545,7 @@ gimp_statusbar_push_valist (GimpStatusbar *statusbar, if (msg->context_id == context_id) { statusbar->messages = g_slist_remove (statusbar->messages, msg); - g_free (msg->text); - g_free (msg); + gimp_statusbar_msg_free (msg); break; } @@ -718,8 +738,7 @@ gimp_statusbar_pop (GimpStatusbar *statusbar, if (msg->context_id == context_id) { statusbar->messages = g_slist_remove (statusbar->messages, msg); - g_free (msg->text); - g_free (msg); + gimp_statusbar_msg_free (msg); break; } @@ -730,6 +749,7 @@ gimp_statusbar_pop (GimpStatusbar *statusbar, void gimp_statusbar_push_temp (GimpStatusbar *statusbar, + const gchar *stock_id, const gchar *format, ...) { @@ -739,12 +759,13 @@ gimp_statusbar_push_temp (GimpStatusbar *statusbar, g_return_if_fail (format != NULL); va_start (args, format); - gimp_statusbar_push_temp_valist (statusbar, format, args); + gimp_statusbar_push_temp_valist (statusbar, stock_id, format, args); va_end (args); } void gimp_statusbar_push_temp_valist (GimpStatusbar *statusbar, + const gchar *stock_id, const gchar *format, va_list args) { @@ -774,6 +795,9 @@ gimp_statusbar_push_temp_valist (GimpStatusbar *statusbar, return; } + g_free (msg->stock_id); + msg->stock_id = g_strdup (stock_id); + g_free (msg->text); msg->text = message; @@ -785,6 +809,7 @@ gimp_statusbar_push_temp_valist (GimpStatusbar *statusbar, msg = g_new0 (GimpStatusbarMsg, 1); msg->context_id = statusbar->temp_context_id; + msg->stock_id = g_strdup (stock_id); msg->text = message; statusbar->messages = g_slist_prepend (statusbar->messages, msg); @@ -810,8 +835,7 @@ gimp_statusbar_pop_temp (GimpStatusbar *statusbar) if (msg->context_id == statusbar->temp_context_id) { statusbar->messages = g_slist_remove (statusbar->messages, msg); - g_free (msg->text); - g_free (msg); + gimp_statusbar_msg_free (msg); gimp_statusbar_update (statusbar); } @@ -916,15 +940,23 @@ gimp_statusbar_progress_expose (GtkWidget *widget, GdkEventExpose *event, GimpStatusbar *statusbar) { - GdkPixbuf *pixbuf; - gint text_xalign; - gint text_yalign; - gint x, y; + GdkPixbuf *pixbuf; + const gchar *stock_id = NULL; + gint text_xalign; + gint text_yalign; + gint x, y; - if (! statusbar->temp_timeout_id) + if (statusbar->messages) + { + GimpStatusbarMsg *msg = statusbar->messages->data; + + stock_id = msg->stock_id; + } + + if (! stock_id) return FALSE; - pixbuf = gtk_widget_render_icon (widget, GIMP_STOCK_WARNING, + pixbuf = gtk_widget_render_icon (widget, stock_id, GTK_ICON_SIZE_MENU, NULL); g_object_get (widget, @@ -1074,3 +1106,11 @@ gimp_statusbar_temp_timeout (GimpStatusbar *statusbar) return FALSE; } + +static void +gimp_statusbar_msg_free (GimpStatusbarMsg *msg) +{ + g_free (msg->stock_id); + g_free (msg->text); + g_free (msg); +} diff --git a/app/display/gimpstatusbar.h b/app/display/gimpstatusbar.h index 34d14e8252..a583133e10 100644 --- a/app/display/gimpstatusbar.h +++ b/app/display/gimpstatusbar.h @@ -103,9 +103,11 @@ void gimp_statusbar_pop (GimpStatusbar *statusbar, const gchar *context); void gimp_statusbar_push_temp (GimpStatusbar *statusbar, + const gchar *stock_id, const gchar *format, - ...) G_GNUC_PRINTF(2,3); + ...) G_GNUC_PRINTF(3,4); void gimp_statusbar_push_temp_valist (GimpStatusbar *statusbar, + const gchar *stock_id, const gchar *format, va_list args); void gimp_statusbar_pop_temp (GimpStatusbar *statusbar); diff --git a/app/errors.c b/app/errors.c index 5f492c0254..3e57d38685 100644 --- a/app/errors.c +++ b/app/errors.c @@ -169,7 +169,7 @@ gimp_message_log_func (const gchar *log_domain, if (gimp) { - gimp_show_message (gimp, NULL, NULL, message); + gimp_show_message (gimp, NULL, GIMP_MESSAGE_WARNING, NULL, message); } else { diff --git a/app/gui/gui-message.c b/app/gui/gui-message.c index a59e20a823..17cbb5279e 100644 --- a/app/gui/gui-message.c +++ b/app/gui/gui-message.c @@ -22,6 +22,7 @@ #include +#include "libgimpbase/gimpbase.h" #include "libgimpwidgets/gimpwidgets.h" #include "gui-types.h" @@ -42,49 +43,57 @@ #include "dialogs/dialogs.h" +#include "gui-message.h" + #include "gimp-intl.h" -static gboolean gui_message_error_console (const gchar *domain, - const gchar *message); -static gboolean gui_message_error_dialog (GimpProgress *progress, - const gchar *domain, - const gchar *message); -static void gui_message_console (const gchar *domain, - const gchar *message); +static gboolean gui_message_error_console (GimpMessageSeverity severity, + const gchar *domain, + const gchar *message); +static gboolean gui_message_error_dialog (Gimp *gimp, + GObject *handler, + GimpMessageSeverity severity, + const gchar *domain, + const gchar *message); +static void gui_message_console (GimpMessageSeverity severity, + const gchar *domain, + const gchar *message); void -gui_message (Gimp *gimp, - GimpProgress *progress, - const gchar *domain, - const gchar *message) +gui_message (Gimp *gimp, + GObject *handler, + GimpMessageSeverity severity, + const gchar *domain, + const gchar *message) { switch (gimp->message_handler) { case GIMP_ERROR_CONSOLE: - if (gui_message_error_console (domain, message)) + if (gui_message_error_console (severity, domain, message)) return; gimp->message_handler = GIMP_MESSAGE_BOX; /* fallthru */ case GIMP_MESSAGE_BOX: - if (gui_message_error_dialog (progress, domain, message)) + if (gui_message_error_dialog (gimp, handler, severity, domain, message)) return; gimp->message_handler = GIMP_CONSOLE; /* fallthru */ case GIMP_CONSOLE: - gui_message_console (domain, message); + gui_message_console (severity, domain, message); break; } } static gboolean -gui_message_error_console (const gchar *domain, - const gchar *message) +gui_message_error_console (GimpMessageSeverity severity, + const gchar *domain, + const gchar *message) { GtkWidget *dockable; @@ -95,7 +104,7 @@ gui_message_error_console (const gchar *domain, if (dockable) { gimp_error_console_add (GIMP_ERROR_CONSOLE (GTK_BIN (dockable)->child), - GIMP_STOCK_WARNING, domain, message); + severity, domain, message); return TRUE; } @@ -158,21 +167,59 @@ global_error_dialog (void) } static gboolean -gui_message_error_dialog (GimpProgress *progress, - const gchar *domain, - const gchar *message) +gui_message_error_dialog (Gimp *gimp, + GObject *handler, + GimpMessageSeverity severity, + const gchar *domain, + const gchar *message) { GtkWidget *dialog; - if (progress && ! GIMP_IS_PROGRESS_DIALOG (progress)) - dialog = progress_error_dialog (progress); + if (GIMP_IS_PROGRESS (handler)) + { + if (gimp_progress_message (GIMP_PROGRESS (handler), gimp, + severity, domain, message)) + { + return TRUE; + } + } + else if (GTK_IS_WIDGET (handler)) + { + GtkWidget *parent = GTK_WIDGET (handler); + GtkMessageType type = GTK_MESSAGE_ERROR; + + switch (severity) + { + case GIMP_MESSAGE_INFO: type = GTK_MESSAGE_INFO; break; + case GIMP_MESSAGE_WARNING: type = GTK_MESSAGE_WARNING; break; + case GIMP_MESSAGE_ERROR: type = GTK_MESSAGE_ERROR; break; + } + + dialog = + gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (parent)), + GTK_DIALOG_DESTROY_WITH_PARENT, + type, GTK_BUTTONS_OK, + message); + + g_signal_connect (dialog, "response", + G_CALLBACK (gtk_widget_destroy), + NULL); + + gtk_widget_show (dialog); + + return TRUE; + } + + if (GIMP_IS_PROGRESS (handler) && ! GIMP_IS_PROGRESS_DIALOG (handler)) + dialog = progress_error_dialog (GIMP_PROGRESS (handler)); else dialog = global_error_dialog (); if (dialog) { gimp_error_dialog_add (GIMP_ERROR_DIALOG (dialog), - GIMP_STOCK_WARNING, domain, message); + gimp_get_message_stock_id (severity), + domain, message); gtk_window_present (GTK_WINDOW (dialog)); return TRUE; @@ -182,8 +229,13 @@ gui_message_error_dialog (GimpProgress *progress, } static void -gui_message_console (const gchar *domain, - const gchar *message) +gui_message_console (GimpMessageSeverity severity, + const gchar *domain, + const gchar *message) { - g_printerr ("%s: %s\n\n", domain, message); + const gchar *desc = "Message"; + + gimp_enum_get_value (GIMP_TYPE_MESSAGE_SEVERITY, severity, + NULL, NULL, &desc, NULL); + g_printerr ("%s-%s: %s\n\n", domain, desc, message); } diff --git a/app/gui/gui-message.h b/app/gui/gui-message.h index dbd3e9cbf1..e3beb64b78 100644 --- a/app/gui/gui-message.h +++ b/app/gui/gui-message.h @@ -20,10 +20,11 @@ #define __GUI_MESSAGE_H__ -void gui_message (Gimp *gimp, - GimpProgress *progress, - const gchar *domain, - const gchar *message); +void gui_message (Gimp *gimp, + GObject *handler, + GimpMessageSeverity severity, + const gchar *domain, + const gchar *message); #endif /* __GUI_VTABLE_H__ */ diff --git a/app/pdb/brush_cmds.c b/app/pdb/brush_cmds.c index 0f6120e375..03f002bd25 100644 --- a/app/pdb/brush_cmds.c +++ b/app/pdb/brush_cmds.c @@ -215,7 +215,8 @@ brush_delete_invoker (GimpProcedure *procedure, if (! success) { - gimp_message (gimp, progress, error->message); + gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, + error->message); g_clear_error (&error); } } diff --git a/app/pdb/gimppdb.c b/app/pdb/gimppdb.c index 54504a980b..7c09cd8c33 100644 --- a/app/pdb/gimppdb.c +++ b/app/pdb/gimppdb.c @@ -299,9 +299,9 @@ gimp_pdb_execute_procedure_by_name_args (GimpPDB *pdb, if (list == NULL) { - gimp_message (pdb->gimp, progress, + gimp_message (pdb->gimp, progress, GIMP_MESSAGE_ERROR, _("PDB calling error:\n" - "Procedure '%s' not found"), name); + "Procedure '%s' not found"), name); return_vals = gimp_procedure_get_return_values (NULL, FALSE); g_value_set_enum (return_vals->values, GIMP_PDB_CALLING_ERROR); @@ -364,7 +364,7 @@ gimp_pdb_execute_procedure_by_name (GimpPDB *pdb, if (procedure == NULL) { - gimp_message (pdb->gimp, progress, + gimp_message (pdb->gimp, progress, GIMP_MESSAGE_ERROR, _("PDB calling error:\n" "Procedure '%s' not found"), name); @@ -398,7 +398,7 @@ gimp_pdb_execute_procedure_by_name (GimpPDB *pdb, g_value_array_free (args); - gimp_message (pdb->gimp, progress, + gimp_message (pdb->gimp, progress, GIMP_MESSAGE_ERROR, _("PDB calling error for procedure '%s':\n" "Argument #%d type mismatch (expected %s, got %s)"), gimp_object_get_name (GIMP_OBJECT (procedure)), diff --git a/app/pdb/gradient_cmds.c b/app/pdb/gradient_cmds.c index 6210f53cab..487385a410 100644 --- a/app/pdb/gradient_cmds.c +++ b/app/pdb/gradient_cmds.c @@ -264,7 +264,8 @@ gradient_delete_invoker (GimpProcedure *procedure, if (! success) { - gimp_message (gimp, progress, error->message); + gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, + error->message); g_clear_error (&error); } } diff --git a/app/pdb/image_cmds.c b/app/pdb/image_cmds.c index a4cff3abf9..7ec6c563f7 100644 --- a/app/pdb/image_cmds.c +++ b/app/pdb/image_cmds.c @@ -1942,7 +1942,7 @@ image_set_resolution_invoker (GimpProcedure *procedure, ! FINITE (yresolution) || yresolution < GIMP_MIN_RESOLUTION || yresolution > GIMP_MAX_RESOLUTION) { - gimp_message (gimp, progress, + gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_WARNING, _("Image resolution is out of bounds, " "using the default resolution instead.")); success = FALSE; diff --git a/app/pdb/message_cmds.c b/app/pdb/message_cmds.c index d1580c6d1c..871a5cace1 100644 --- a/app/pdb/message_cmds.c +++ b/app/pdb/message_cmds.c @@ -53,7 +53,8 @@ message_invoker (GimpProcedure *procedure, if (gimp->plug_in_manager->current_plug_in) domain = gimp_plug_in_get_undo_desc (gimp->plug_in_manager->current_plug_in); - gimp_show_message (gimp, progress, domain, message); + gimp_show_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_WARNING, + domain, message); g_free (domain); } diff --git a/app/pdb/palette_cmds.c b/app/pdb/palette_cmds.c index 44960ab3b6..a9d2fb5564 100644 --- a/app/pdb/palette_cmds.c +++ b/app/pdb/palette_cmds.c @@ -182,7 +182,8 @@ palette_delete_invoker (GimpProcedure *procedure, if (! success) { - gimp_message (gimp, progress, error->message); + gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, + error->message); g_clear_error (&error); } } diff --git a/app/plug-in/gimpplugin.c b/app/plug-in/gimpplugin.c index 65efad7590..066106efd3 100644 --- a/app/plug-in/gimpplugin.c +++ b/app/plug-in/gimpplugin.c @@ -607,7 +607,8 @@ gimp_plug_in_recv_message (GIOChannel *channel, GimpPlugInProcFrame *frame = gimp_plug_in_get_proc_frame (plug_in); GimpProgress *progress = frame ? frame->progress : NULL; - gimp_message (plug_in->manager->gimp, progress, + gimp_message (plug_in->manager->gimp, G_OBJECT (progress), + GIMP_MESSAGE_ERROR, _("Plug-in crashed: \"%s\"\n(%s)\n\n" "The dying plug-in may have messed up GIMP's internal " "state. You may want to save your images and restart " diff --git a/app/tools/gimpimagemaptool.c b/app/tools/gimpimagemaptool.c index bfaba8e6ad..250a7615f2 100644 --- a/app/tools/gimpimagemaptool.c +++ b/app/tools/gimpimagemaptool.c @@ -584,10 +584,11 @@ gimp_image_map_tool_load_save (GimpImageMapTool *tool, _("Could not open '%s' for writing: %s") : _("Could not open '%s' for reading: %s"); - gimp_show_message_dialog (tool->shell, GTK_MESSAGE_ERROR, - format, - gimp_filename_to_utf8 (filename), - g_strerror (errno)); + gimp_message (GIMP_TOOL (tool)->tool_info->gimp, G_OBJECT (tool->shell), + GIMP_MESSAGE_ERROR, + format, + gimp_filename_to_utf8 (filename), + g_strerror (errno)); return; } @@ -601,10 +602,11 @@ gimp_image_map_tool_load_save (GimpImageMapTool *tool, } else if (! gimp_image_map_tool_settings_load (tool, file, &error)) { - gimp_show_message_dialog (tool->shell, GTK_MESSAGE_ERROR, - _("Error reading '%s': %s"), - gimp_filename_to_utf8 (filename), - error->message); + gimp_message (GIMP_TOOL (tool)->tool_info->gimp, G_OBJECT (tool->shell), + GIMP_MESSAGE_ERROR, + _("Error reading '%s': %s"), + gimp_filename_to_utf8 (filename), + error->message); g_error_free (error); } diff --git a/app/tools/gimptool.c b/app/tools/gimptool.c index 788e128d3e..7744f57654 100644 --- a/app/tools/gimptool.c +++ b/app/tools/gimptool.c @@ -24,7 +24,6 @@ #include "core/gimp.h" #include "core/gimpimage.h" -#include "core/gimpprogress.h" #include "core/gimptoolinfo.h" #include "display/gimpdisplay.h" @@ -727,9 +726,11 @@ gimp_tool_push_status (GimpTool *tool, shell = GIMP_DISPLAY_SHELL (display->shell); va_start (args, format); + gimp_statusbar_push_valist (GIMP_STATUSBAR (shell->statusbar), G_OBJECT_TYPE_NAME (tool), format, args); + va_end (args); } @@ -788,9 +789,11 @@ gimp_tool_replace_status (GimpTool *tool, shell = GIMP_DISPLAY_SHELL (display->shell); va_start (args, format); + gimp_statusbar_replace_valist (GIMP_STATUSBAR (shell->statusbar), G_OBJECT_TYPE_NAME (tool), format, args); + va_end (args); } @@ -819,11 +822,12 @@ gimp_tool_message (GimpTool *tool, g_return_if_fail (GIMP_IS_TOOL (tool)); g_return_if_fail (GIMP_IS_DISPLAY (display)); + g_return_if_fail (format != NULL); va_start (args, format); - gimp_display_shell_message_valist (GIMP_DISPLAY_SHELL (display->shell), - format, args); + gimp_message_valist (display->image->gimp, G_OBJECT (display), + GIMP_MESSAGE_WARNING, format, args); va_end (args); } diff --git a/app/tools/gimpvectortool.c b/app/tools/gimpvectortool.c index deb6d99900..8544eb4e13 100644 --- a/app/tools/gimpvectortool.c +++ b/app/tools/gimpvectortool.c @@ -1880,9 +1880,9 @@ gimp_vector_tool_stroke_vectors (GimpVectorTool *vector_tool, if (! active_drawable) { - gimp_message (image->gimp, - GIMP_PROGRESS (GIMP_TOOL (vector_tool)->display), - _("There is no active layer or channel to stroke to")); + gimp_tool_message (GIMP_TOOL (vector_tool), + GIMP_TOOL (vector_tool)->display, + _("There is no active layer or channel to stroke to")); return; } diff --git a/app/widgets/gimpactionview.c b/app/widgets/gimpactionview.c index af0a15adf6..2b4bb1cd14 100644 --- a/app/widgets/gimpactionview.c +++ b/app/widgets/gimpactionview.c @@ -30,6 +30,8 @@ #include "widgets-types.h" +#include "core/gimp.h" + #include "gimpaction.h" #include "gimpactiongroup.h" #include "gimpactionview.h" @@ -462,6 +464,7 @@ gimp_action_view_accel_changed (GtkAccelGroup *accel_group, typedef struct { + GimpUIManager *manager; gchar *accel_path; guint accel_key; GdkModifierType accel_mask; @@ -481,8 +484,9 @@ gimp_action_view_conflict_response (GtkWidget *dialog, confirm_data->accel_mask, TRUE)) { - gimp_show_message_dialog (dialog, GTK_MESSAGE_ERROR, - _("Changing shortcut failed.")); + gimp_message (confirm_data->manager->gimp, G_OBJECT (dialog), + GIMP_MESSAGE_ERROR, + _("Changing shortcut failed.")); } } @@ -517,6 +521,7 @@ gimp_action_view_conflict_confirm (GimpActionView *view, confirm_data = g_new0 (ConfirmData, 1); + confirm_data->manager = view->manager; confirm_data->accel_path = g_strdup (accel_path); confirm_data->accel_key = accel_key; confirm_data->accel_mask = accel_mask; @@ -600,14 +605,16 @@ gimp_action_view_accel_edited (GimpCellRendererAccel *accel, { if (! gtk_accel_map_change_entry (accel_path, 0, 0, FALSE)) { - gimp_show_message_dialog (GTK_WIDGET (view), GTK_MESSAGE_ERROR, - _("Removing shortcut failed.")); + gimp_message (view->manager->gimp, G_OBJECT (view), + GIMP_MESSAGE_ERROR, + _("Removing shortcut failed.")); } } else if (! accel_key) { - gimp_show_message_dialog (GTK_WIDGET (view), GTK_MESSAGE_ERROR, - _("Invalid shortcut.")); + gimp_message (view->manager->gimp, G_OBJECT (view), + GIMP_MESSAGE_ERROR, + _("Invalid shortcut.")); } else if (! gtk_accel_map_change_entry (accel_path, accel_key, accel_mask, FALSE)) @@ -666,9 +673,9 @@ gimp_action_view_accel_edited (GimpCellRendererAccel *accel, } else { - gimp_show_message_dialog (GTK_WIDGET (view), - GTK_MESSAGE_ERROR, - _("Changing shortcut failed.")); + gimp_message (view->manager->gimp, G_OBJECT (view), + GIMP_MESSAGE_ERROR, + _("Changing shortcut failed.")); } } } diff --git a/app/widgets/gimpcontrollerlist.c b/app/widgets/gimpcontrollerlist.c index a7799e759d..cfac911cfd 100644 --- a/app/widgets/gimpcontrollerlist.c +++ b/app/widgets/gimpcontrollerlist.c @@ -509,21 +509,21 @@ gimp_controller_list_add_clicked (GtkWidget *button, if (list->src_gtype == GIMP_TYPE_CONTROLLER_KEYBOARD && gimp_controllers_get_keyboard (list->gimp) != NULL) { - gimp_show_message_dialog (button, GTK_MESSAGE_WARNING, - _("There can only be one active keyboard " - "controller.\n\n" - "You already have a keyboard controller in " - "your list of active controllers.")); + gimp_message (list->gimp, G_OBJECT (button), GIMP_MESSAGE_WARNING, + _("There can only be one active keyboard " + "controller.\n\n" + "You already have a keyboard controller in " + "your list of active controllers.")); return; } else if (list->src_gtype == GIMP_TYPE_CONTROLLER_WHEEL && gimp_controllers_get_wheel (list->gimp) != NULL) { - gimp_show_message_dialog (button, GTK_MESSAGE_WARNING, - _("There can only be one active wheel " - "controller.\n\n" - "You already have a wheel controller in " - "your list of active controllers.")); + gimp_message (list->gimp, G_OBJECT (button), GIMP_MESSAGE_WARNING, + _("There can only be one active wheel " + "controller.\n\n" + "You already have a wheel controller in " + "your list of active controllers.")); return; } diff --git a/app/widgets/gimperrorconsole.c b/app/widgets/gimperrorconsole.c index 95e7c9e44f..d101828bc3 100644 --- a/app/widgets/gimperrorconsole.c +++ b/app/widgets/gimperrorconsole.c @@ -26,6 +26,7 @@ #include +#include "libgimpbase/gimpbase.h" #include "libgimpwidgets/gimpwidgets.h" #include "widgets-types.h" @@ -34,6 +35,7 @@ #include "gimperrorconsole.h" #include "gimpmenufactory.h" +#include "gimpwidgets-utils.h" #include "gimp-intl.h" @@ -177,31 +179,35 @@ gimp_error_console_new (Gimp *gimp, } void -gimp_error_console_add (GimpErrorConsole *console, - const gchar *stock_id, - const gchar *domain, - const gchar *message) +gimp_error_console_add (GimpErrorConsole *console, + GimpMessageSeverity severity, + const gchar *domain, + const gchar *message) { + const gchar *desc; GtkTextIter end; GtkTextMark *end_mark; GdkPixbuf *pixbuf; gchar *str; g_return_if_fail (GIMP_IS_ERROR_CONSOLE (console)); - g_return_if_fail (stock_id != NULL); g_return_if_fail (domain != NULL); g_return_if_fail (message != NULL); + gimp_enum_get_value (GIMP_TYPE_MESSAGE_SEVERITY, severity, + NULL, NULL, &desc, NULL); + gtk_text_buffer_get_end_iter (console->text_buffer, &end); - pixbuf = gtk_widget_render_icon (console->text_view, stock_id, + pixbuf = gtk_widget_render_icon (console->text_view, + gimp_get_message_stock_id (severity), GTK_ICON_SIZE_MENU, NULL); gtk_text_buffer_insert_pixbuf (console->text_buffer, &end, pixbuf); g_object_unref (pixbuf); gtk_text_buffer_insert (console->text_buffer, &end, " ", -1); - str = g_strdup_printf (_("%s Message"), domain); + str = g_strdup_printf ("%s %s", domain, desc); gtk_text_buffer_insert_with_tags_by_name (console->text_buffer, &end, str, -1, "title", diff --git a/app/widgets/gimperrorconsole.h b/app/widgets/gimperrorconsole.h index fb67d57b53..d05913000f 100644 --- a/app/widgets/gimperrorconsole.h +++ b/app/widgets/gimperrorconsole.h @@ -60,13 +60,13 @@ struct _GimpErrorConsoleClass GType gimp_error_console_get_type (void) G_GNUC_CONST; -GtkWidget * gimp_error_console_new (Gimp *gimp, - GimpMenuFactory *menu_factory); +GtkWidget * gimp_error_console_new (Gimp *gimp, + GimpMenuFactory *menu_factory); -void gimp_error_console_add (GimpErrorConsole *console, - const gchar *stock_id, - const gchar *domain, - const gchar *message); +void gimp_error_console_add (GimpErrorConsole *console, + GimpMessageSeverity severity, + const gchar *domain, + const gchar *message); #endif /* __GIMP_ERROR_CONSOLE_H__ */ diff --git a/app/widgets/gimppdbdialog.c b/app/widgets/gimppdbdialog.c index 4784fe28ec..329b4dfd24 100644 --- a/app/widgets/gimppdbdialog.c +++ b/app/widgets/gimppdbdialog.c @@ -340,12 +340,12 @@ gimp_pdb_dialog_run_callback (GimpPdbDialog *dialog, if (g_value_get_enum (&return_vals->values[0]) != GIMP_PDB_SUCCESS) { - gimp_show_message_dialog (GTK_WIDGET (dialog), - GTK_MESSAGE_ERROR, - _("Unable to run %s callback. " - "The corresponding plug-in may have " - "crashed."), - g_type_name (G_TYPE_FROM_INSTANCE (dialog))); + gimp_message (dialog->context->gimp, G_OBJECT (dialog), + GIMP_MESSAGE_ERROR, + _("Unable to run %s callback. " + "The corresponding plug-in may have " + "crashed."), + g_type_name (G_TYPE_FROM_INSTANCE (dialog))); } g_value_array_free (return_vals); diff --git a/app/widgets/gimpthumbbox.c b/app/widgets/gimpthumbbox.c index 55cc6ef153..b0d86b2b56 100644 --- a/app/widgets/gimpthumbbox.c +++ b/app/widgets/gimpthumbbox.c @@ -69,8 +69,9 @@ static void gimp_thumb_box_progress_set_value (GimpProgress *progress, static gdouble gimp_thumb_box_progress_get_value (GimpProgress *progress); static void gimp_thumb_box_progress_pulse (GimpProgress *progress); -static void gimp_thumb_box_progress_message (GimpProgress *progress, +static gboolean gimp_thumb_box_progress_message (GimpProgress *progress, Gimp *gimp, + GimpMessageSeverity severity, const gchar *domain, const gchar *message); @@ -271,13 +272,16 @@ gimp_thumb_box_progress_pulse (GimpProgress *progress) } } -static void -gimp_thumb_box_progress_message (GimpProgress *progress, - Gimp *gimp, - const gchar *domain, - const gchar *message) +static gboolean +gimp_thumb_box_progress_message (GimpProgress *progress, + Gimp *gimp, + GimpMessageSeverity severity, + const gchar *domain, + const gchar *message) { /* GimpThumbBox never shows any messages */ + + return TRUE; } diff --git a/app/widgets/gimpvectorstreeview.c b/app/widgets/gimpvectorstreeview.c index 7cb6feb6db..5618b01ae3 100644 --- a/app/widgets/gimpvectorstreeview.c +++ b/app/widgets/gimpvectorstreeview.c @@ -235,8 +235,8 @@ gimp_vectors_tree_view_drop_svg (GimpContainerTreeView *tree_view, if (! gimp_vectors_import_buffer (image, svg_data, svg_data_len, TRUE, TRUE, index, &error)) { - gimp_show_message_dialog (GTK_WIDGET (tree_view), GTK_MESSAGE_ERROR, - error->message); + gimp_message (image->gimp, G_OBJECT (tree_view), GIMP_MESSAGE_ERROR, + error->message); g_clear_error (&error); } else diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c index 6cd6373326..4145459482 100644 --- a/app/widgets/gimpwidgets-utils.c +++ b/app/widgets/gimpwidgets-utils.c @@ -1131,33 +1131,20 @@ gimp_widget_set_accel_help (GtkWidget *widget, } } -void -gimp_show_message_dialog (GtkWidget *parent, - GtkMessageType type, - const gchar *format, - ...) +const gchar * +gimp_get_message_stock_id (GimpMessageSeverity severity) { - GtkWidget *dialog; - gchar *message; - va_list args; + switch (severity) + { + case GIMP_MESSAGE_INFO: + return GIMP_STOCK_INFO; - g_return_if_fail (GTK_IS_WIDGET (parent)); - g_return_if_fail (format != NULL); + case GIMP_MESSAGE_WARNING: + return GIMP_STOCK_WARNING; - va_start (args, format); - message = g_strdup_vprintf (format, args); - va_end (args); + case GIMP_MESSAGE_ERROR: + return GIMP_STOCK_ERROR; + } - dialog = - gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (parent)), - GTK_DIALOG_DESTROY_WITH_PARENT, - type, GTK_BUTTONS_OK, - message); - g_free (message); - - g_signal_connect (dialog, "response", - G_CALLBACK (gtk_widget_destroy), - NULL); - - gtk_widget_show (dialog); + g_return_val_if_reached (GIMP_STOCK_WARNING); } diff --git a/app/widgets/gimpwidgets-utils.h b/app/widgets/gimpwidgets-utils.h index e0895cff95..2fee173b09 100644 --- a/app/widgets/gimpwidgets-utils.h +++ b/app/widgets/gimpwidgets-utils.h @@ -93,10 +93,7 @@ void gimp_toggle_button_set_visible (GtkToggleButton *toggle, void gimp_widget_set_accel_help (GtkWidget *widget, GtkAction *action); -void gimp_show_message_dialog (GtkWidget *parent, - GtkMessageType type, - const gchar *format, - ...) G_GNUC_PRINTF(3,4); +const gchar * gimp_get_message_stock_id (GimpMessageSeverity severity); #endif /* __GIMP_WIDGETS_UTILS_H__ */ diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c index 5fdd974c3f..13fe088aff 100644 --- a/app/xcf/xcf-load.c +++ b/app/xcf/xcf-load.c @@ -276,7 +276,7 @@ xcf_load_image (Gimp *gimp, if (num_successful_elements == 0) goto hard_error; - gimp_message (gimp, info->progress, + gimp_message (gimp, G_OBJECT (info->progress), GIMP_MESSAGE_WARNING, "XCF: This file is corrupt! I have loaded as much\n" "of it as I can, but it is incomplete."); @@ -285,7 +285,7 @@ xcf_load_image (Gimp *gimp, return image; hard_error: - gimp_message (gimp, info->progress, + gimp_message (gimp, G_OBJECT (info->progress), GIMP_MESSAGE_ERROR, "XCF: This file is corrupt! I could not even\n" "salvage any partial image data from it."); @@ -316,7 +316,8 @@ xcf_load_image_props (XcfInfo *info, { gint i; - gimp_message (info->gimp, info->progress, + gimp_message (info->gimp, G_OBJECT (info->progress), + GIMP_MESSAGE_WARNING, _("XCF warning: version 0 of XCF file format\n" "did not save indexed colormaps correctly.\n" "Substituting grayscale map.")); @@ -366,7 +367,8 @@ xcf_load_image_props (XcfInfo *info, (compression != COMPRESS_ZLIB) && (compression != COMPRESS_FRACTAL)) { - gimp_message (info->gimp, info->progress, + gimp_message (info->gimp, G_OBJECT (info->progress), + GIMP_MESSAGE_ERROR, "unknown compression type: %d", (int) compression); return FALSE; @@ -403,7 +405,8 @@ xcf_load_image_props (XcfInfo *info, break; default: - gimp_message (info->gimp, info->progress, + gimp_message (info->gimp, G_OBJECT (info->progress), + GIMP_MESSAGE_WARNING, "guide orientation out of range in XCF file"); continue; } @@ -442,7 +445,8 @@ xcf_load_image_props (XcfInfo *info, if (xres < GIMP_MIN_RESOLUTION || xres > GIMP_MAX_RESOLUTION || yres < GIMP_MIN_RESOLUTION || yres > GIMP_MAX_RESOLUTION) { - gimp_message (info->gimp, info->progress, + gimp_message (info->gimp, G_OBJECT (info->progress), + GIMP_MESSAGE_WARNING, "Warning, resolution out of range in XCF file"); xres = image->gimp->config->default_image->xresolution; yres = image->gimp->config->default_image->yresolution; @@ -470,7 +474,8 @@ xcf_load_image_props (XcfInfo *info, gimp_parasite_free (p); } if (info->cp - base != prop_size) - gimp_message (info->gimp, info->progress, + gimp_message (info->gimp, G_OBJECT (info->progress), + GIMP_MESSAGE_WARNING, "Error while loading an image's parasites"); } break; @@ -484,7 +489,8 @@ xcf_load_image_props (XcfInfo *info, if ((unit <= GIMP_UNIT_PIXEL) || (unit >= _gimp_unit_get_number_of_built_in_units (image->gimp))) { - gimp_message (info->gimp, info->progress, + gimp_message (info->gimp, G_OBJECT (info->progress), + GIMP_MESSAGE_WARNING, "Warning, unit out of range in XCF file, " "falling back to inches"); unit = GIMP_UNIT_INCH; @@ -714,7 +720,8 @@ xcf_load_layer_props (XcfInfo *info, gimp_parasite_free (p); } if (info->cp - base != prop_size) - gimp_message (info->gimp, info->progress, + gimp_message (info->gimp, G_OBJECT (info->progress), + GIMP_MESSAGE_WARNING, "Error while loading a layer's parasites"); } break; @@ -856,7 +863,8 @@ xcf_load_channel_props (XcfInfo *info, gimp_parasite_free (p); } if (info->cp - base != prop_size) - gimp_message (info->gimp, info->progress, + gimp_message (info->gimp, G_OBJECT (info->progress), + GIMP_MESSAGE_WARNING, "Error while loading a channel's parasites"); } break; @@ -1218,7 +1226,8 @@ xcf_load_level (XcfInfo *info, if (offset == 0) { - gimp_message (info->gimp, info->progress, + gimp_message (info->gimp, G_OBJECT (info->progress), + GIMP_MESSAGE_ERROR, "not enough tiles found in level"); return FALSE; } @@ -1305,7 +1314,7 @@ xcf_load_level (XcfInfo *info, if (offset != 0) { - gimp_message (info->gimp, info->progress, + gimp_message (info->gimp, G_OBJECT (info->progress), GIMP_MESSAGE_ERROR, "encountered garbage after reading level: %d", offset); return FALSE; } @@ -1616,7 +1625,8 @@ xcf_load_vectors (XcfInfo *info, if (version != 1) { - gimp_message (info->gimp, info->progress, + gimp_message (info->gimp, G_OBJECT (info->progress), + GIMP_MESSAGE_WARNING, "Unknown vectors version: %d (skipping)", version); return FALSE; } diff --git a/app/xcf/xcf-save.c b/app/xcf/xcf-save.c index 206bd4b4d7..b37b0d002f 100644 --- a/app/xcf/xcf-save.c +++ b/app/xcf/xcf-save.c @@ -158,7 +158,8 @@ static gboolean xcf_save_vectors (XcfInfo *info, info->cp += xcf_write_int32 (info->fp, data, count, &error); \ if (error) \ { \ - gimp_message (info->gimp, info->progress, \ + gimp_message (info->gimp, G_OBJECT (info->progress), \ + GIMP_MESSAGE_ERROR, \ _("Error saving XCF file: %s"), \ error->message); \ return FALSE; \ @@ -169,7 +170,8 @@ static gboolean xcf_save_vectors (XcfInfo *info, info->cp += xcf_write_int8 (info->fp, data, count, &error); \ if (error) \ { \ - gimp_message (info->gimp, info->progress, \ + gimp_message (info->gimp, G_OBJECT (info->progress), \ + GIMP_MESSAGE_ERROR, \ _("Error saving XCF file: %s"), \ error->message); \ return FALSE; \ @@ -180,7 +182,8 @@ static gboolean xcf_save_vectors (XcfInfo *info, info->cp += xcf_write_float (info->fp, data, count, &error); \ if (error) \ { \ - gimp_message (info->gimp, info->progress, \ + gimp_message (info->gimp, G_OBJECT (info->progress), \ + GIMP_MESSAGE_ERROR, \ _("Error saving XCF file: %s"), \ error->message); \ return FALSE; \ @@ -191,7 +194,8 @@ static gboolean xcf_save_vectors (XcfInfo *info, info->cp += xcf_write_string (info->fp, data, count, &error); \ if (error) \ { \ - gimp_message (info->gimp, info->progress, \ + gimp_message (info->gimp, G_OBJECT (info->progress), \ + GIMP_MESSAGE_ERROR, \ _("Error saving XCF file: %s"), \ error->message); \ return FALSE; \ @@ -216,7 +220,8 @@ static gboolean xcf_save_vectors (XcfInfo *info, #define xcf_print_error(info, x) G_STMT_START { \ if (! (x)) \ { \ - gimp_message (info->gimp, info->progress, \ + gimp_message (info->gimp, G_OBJECT (info->progress), \ + GIMP_MESSAGE_ERROR, \ _("Error saving XCF file: %s"), \ error->message); \ return FALSE; \ diff --git a/app/xcf/xcf.c b/app/xcf/xcf.c index fbd980b96e..d0279bab11 100644 --- a/app/xcf/xcf.c +++ b/app/xcf/xcf.c @@ -301,7 +301,7 @@ xcf_load_invoker (GimpProcedure *procedure, } else { - gimp_message (gimp, progress, + gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, _("XCF error: unsupported XCF file version %d " "encountered"), info.file_version); success = FALSE; @@ -315,7 +315,7 @@ xcf_load_invoker (GimpProcedure *procedure, } else { - gimp_message (gimp, progress, + gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, _("Could not open '%s' for reading: %s"), gimp_filename_to_utf8 (filename), g_strerror (errno)); } @@ -382,7 +382,7 @@ xcf_save_invoker (GimpProcedure *procedure, if (fclose (info.fp) == EOF) { - gimp_message (gimp, progress, + gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, _("Error saving XCF file: %s"), g_strerror (errno)); success = FALSE; @@ -393,7 +393,7 @@ xcf_save_invoker (GimpProcedure *procedure, } else { - gimp_message (gimp, progress, + gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, _("Could not open '%s' for writing: %s"), gimp_filename_to_utf8 (filename), g_strerror (errno)); } diff --git a/tools/pdbgen/pdb/brush.pdb b/tools/pdbgen/pdb/brush.pdb index 7b1646ec63..3fbe52940d 100644 --- a/tools/pdbgen/pdb/brush.pdb +++ b/tools/pdbgen/pdb/brush.pdb @@ -217,7 +217,8 @@ sub brush_delete { if (! success) { - gimp_message (gimp, progress, error->message); + gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, + error->message); g_clear_error (&error); } } diff --git a/tools/pdbgen/pdb/gradient.pdb b/tools/pdbgen/pdb/gradient.pdb index 15dcf3061b..a05e7d5150 100644 --- a/tools/pdbgen/pdb/gradient.pdb +++ b/tools/pdbgen/pdb/gradient.pdb @@ -184,7 +184,8 @@ sub gradient_delete { if (! success) { - gimp_message (gimp, progress, error->message); + gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, + error->message); g_clear_error (&error); } } diff --git a/tools/pdbgen/pdb/image.pdb b/tools/pdbgen/pdb/image.pdb index 4112576c68..0a95cfb1b7 100644 --- a/tools/pdbgen/pdb/image.pdb +++ b/tools/pdbgen/pdb/image.pdb @@ -2094,7 +2094,7 @@ HELP ! FINITE (yresolution) || yresolution < GIMP_MIN_RESOLUTION || yresolution > GIMP_MAX_RESOLUTION) { - gimp_message (gimp, progress, + gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_WARNING, _("Image resolution is out of bounds, " "using the default resolution instead.")); success = FALSE; diff --git a/tools/pdbgen/pdb/message.pdb b/tools/pdbgen/pdb/message.pdb index aafea333b9..a59de2d21b 100644 --- a/tools/pdbgen/pdb/message.pdb +++ b/tools/pdbgen/pdb/message.pdb @@ -39,7 +39,8 @@ HELP if (gimp->plug_in_manager->current_plug_in) domain = gimp_plug_in_get_undo_desc (gimp->plug_in_manager->current_plug_in); - gimp_show_message (gimp, progress, domain, message); + gimp_show_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_WARNING, + domain, message); g_free (domain); } diff --git a/tools/pdbgen/pdb/palette.pdb b/tools/pdbgen/pdb/palette.pdb index c388ed0aaa..a25625722b 100644 --- a/tools/pdbgen/pdb/palette.pdb +++ b/tools/pdbgen/pdb/palette.pdb @@ -186,7 +186,8 @@ sub palette_delete { if (! success) { - gimp_message (gimp, progress, error->message); + gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, + error->message); g_clear_error (&error); } }