2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2006-07-19 14:50:34 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2006-07-19 14:50:34 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2006-07-19 14:50:34 +08:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2006-07-19 14:50:34 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2013-11-02 05:28:18 +08:00
|
|
|
#include <gegl.h>
|
2006-07-19 14:50:34 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2006-10-09 16:17:22 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2006-07-19 14:50:34 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "gui-types.h"
|
|
|
|
|
|
|
|
#include "config/gimpguiconfig.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
|
|
|
#include "core/gimpprogress.h"
|
|
|
|
|
|
|
|
#include "plug-in/gimpplugin.h"
|
|
|
|
|
2018-01-23 10:38:46 +08:00
|
|
|
#include "widgets/gimpcriticaldialog.h"
|
2006-07-19 14:50:34 +08:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
|
|
|
#include "widgets/gimpdockable.h"
|
|
|
|
#include "widgets/gimperrorconsole.h"
|
|
|
|
#include "widgets/gimperrordialog.h"
|
2006-08-11 19:50:23 +08:00
|
|
|
#include "widgets/gimpprogressdialog.h"
|
2006-11-23 00:33:31 +08:00
|
|
|
#include "widgets/gimpsessioninfo.h"
|
2006-09-22 17:24:41 +08:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2012-01-31 06:33:21 +08:00
|
|
|
#include "widgets/gimpwindowstrategy.h"
|
2012-01-31 06:24:44 +08:00
|
|
|
|
2017-06-08 02:53:48 +08:00
|
|
|
#include "about.h"
|
|
|
|
|
2006-10-09 16:17:22 +08:00
|
|
|
#include "gui-message.h"
|
|
|
|
|
2006-07-19 14:50:34 +08:00
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
2018-04-28 08:17:55 +08:00
|
|
|
|
2018-02-12 12:13:22 +08:00
|
|
|
#define MAX_TRACES 3
|
|
|
|
#define MAX_ERRORS 10
|
|
|
|
|
2006-07-19 14:50:34 +08:00
|
|
|
|
2017-06-07 21:27:33 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
Gimp *gimp;
|
|
|
|
gchar *domain;
|
|
|
|
gchar *message;
|
2018-02-12 12:13:22 +08:00
|
|
|
gchar *trace;
|
2017-06-07 21:27:33 +08:00
|
|
|
GObject *handler;
|
|
|
|
GimpMessageSeverity severity;
|
|
|
|
} GimpLogMessageData;
|
|
|
|
|
2017-06-08 02:53:48 +08:00
|
|
|
|
2018-02-12 12:13:22 +08:00
|
|
|
static gboolean gui_message_idle (gpointer user_data);
|
|
|
|
static gboolean gui_message_error_console (Gimp *gimp,
|
|
|
|
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,
|
|
|
|
const gchar *trace);
|
|
|
|
static void gui_message_console (GimpMessageSeverity severity,
|
|
|
|
const gchar *domain,
|
|
|
|
const gchar *message);
|
|
|
|
static gchar * gui_message_format (GimpMessageSeverity severity,
|
|
|
|
const gchar *domain,
|
|
|
|
const gchar *message);
|
|
|
|
|
|
|
|
static GtkWidget * global_error_dialog (void);
|
|
|
|
static GtkWidget * global_critical_dialog (void);
|
|
|
|
|
2018-04-28 08:17:55 +08:00
|
|
|
static void gui_message_reset_errors (GObject *object,
|
2018-02-12 12:13:22 +08:00
|
|
|
gpointer user_data);
|
2006-07-19 14:50:34 +08:00
|
|
|
|
2017-06-08 02:53:48 +08:00
|
|
|
|
2018-04-28 08:17:55 +08:00
|
|
|
static GMutex mutex;
|
|
|
|
static gint n_traces = 0;
|
|
|
|
static gint n_errors = 0;
|
|
|
|
|
|
|
|
|
2006-07-19 14:50:34 +08:00
|
|
|
void
|
2006-10-09 16:17:22 +08:00
|
|
|
gui_message (Gimp *gimp,
|
|
|
|
GObject *handler,
|
|
|
|
GimpMessageSeverity severity,
|
|
|
|
const gchar *domain,
|
2018-02-12 08:59:08 +08:00
|
|
|
const gchar *message)
|
2006-07-19 14:50:34 +08:00
|
|
|
{
|
2018-02-12 12:13:22 +08:00
|
|
|
gchar *trace = NULL;
|
|
|
|
gboolean gen_trace = FALSE;
|
|
|
|
|
2006-07-19 14:50:34 +08:00
|
|
|
switch (gimp->message_handler)
|
|
|
|
{
|
|
|
|
case GIMP_ERROR_CONSOLE:
|
2018-02-12 08:59:08 +08:00
|
|
|
if (gui_message_error_console (gimp, severity, domain, message))
|
2006-07-19 14:50:34 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
gimp->message_handler = GIMP_MESSAGE_BOX;
|
|
|
|
/* fallthru */
|
|
|
|
|
|
|
|
case GIMP_MESSAGE_BOX:
|
2018-02-13 00:20:53 +08:00
|
|
|
if (severity >= GIMP_MESSAGE_BUG_WARNING)
|
2018-02-12 12:13:22 +08:00
|
|
|
{
|
|
|
|
g_mutex_lock (&mutex);
|
|
|
|
/* Trace creation can be time consuming so don't block the
|
|
|
|
* mutex for too long and only increment and set a boolean
|
|
|
|
* here.
|
|
|
|
*/
|
|
|
|
if (n_traces < MAX_TRACES)
|
|
|
|
{
|
|
|
|
gen_trace = TRUE;
|
|
|
|
n_traces++;
|
|
|
|
}
|
|
|
|
g_mutex_unlock (&mutex);
|
|
|
|
}
|
2018-02-22 19:35:43 +08:00
|
|
|
|
2018-02-12 12:13:22 +08:00
|
|
|
if (gen_trace)
|
|
|
|
{
|
|
|
|
/* We need to create the trace here because for multi-thread
|
|
|
|
* errors (i.e. non-GIMP ones), the backtrace after a idle
|
|
|
|
* function will simply be useless. It needs to happen in the
|
|
|
|
* buggy thread to be meaningful.
|
|
|
|
*/
|
2018-02-22 19:35:43 +08:00
|
|
|
gimp_stack_trace_print (NULL, NULL, &trace);
|
2018-02-12 12:13:22 +08:00
|
|
|
}
|
|
|
|
|
2017-06-07 21:27:33 +08:00
|
|
|
if (g_strcmp0 (GIMP_ACRONYM, domain) != 0)
|
|
|
|
{
|
|
|
|
/* Handle non-GIMP messages in a multi-thread safe way,
|
|
|
|
* because we can't know for sure whether the log message may
|
|
|
|
* not have been called from a thread other than the main one.
|
|
|
|
*/
|
|
|
|
GimpLogMessageData *data;
|
|
|
|
|
|
|
|
data = g_new0 (GimpLogMessageData, 1);
|
|
|
|
data->gimp = gimp;
|
|
|
|
data->domain = g_strdup (domain);
|
|
|
|
data->message = g_strdup (message);
|
2018-02-12 12:13:22 +08:00
|
|
|
data->trace = trace;
|
2017-06-07 21:27:33 +08:00
|
|
|
data->handler = handler? g_object_ref (handler) : NULL;
|
|
|
|
data->severity = severity;
|
|
|
|
|
|
|
|
gdk_threads_add_idle_full (G_PRIORITY_DEFAULT_IDLE,
|
|
|
|
gui_message_idle,
|
|
|
|
data, g_free);
|
|
|
|
return;
|
|
|
|
}
|
2018-01-23 10:38:46 +08:00
|
|
|
if (gui_message_error_dialog (gimp, handler, severity,
|
2018-02-12 12:13:22 +08:00
|
|
|
domain, message, trace))
|
|
|
|
break;
|
2006-07-19 14:50:34 +08:00
|
|
|
|
|
|
|
gimp->message_handler = GIMP_CONSOLE;
|
|
|
|
/* fallthru */
|
|
|
|
|
|
|
|
case GIMP_CONSOLE:
|
2018-02-12 08:59:08 +08:00
|
|
|
gui_message_console (severity, domain, message);
|
2006-07-19 14:50:34 +08:00
|
|
|
break;
|
|
|
|
}
|
2018-02-12 12:13:22 +08:00
|
|
|
if (trace)
|
|
|
|
g_free (trace);
|
2006-07-19 14:50:34 +08:00
|
|
|
}
|
|
|
|
|
2017-06-07 21:27:33 +08:00
|
|
|
static gboolean
|
|
|
|
gui_message_idle (gpointer user_data)
|
|
|
|
{
|
|
|
|
GimpLogMessageData *data = (GimpLogMessageData *) user_data;
|
|
|
|
|
|
|
|
if (! gui_message_error_dialog (data->gimp,
|
|
|
|
data->handler,
|
|
|
|
data->severity,
|
|
|
|
data->domain,
|
2018-02-12 12:13:22 +08:00
|
|
|
data->message,
|
|
|
|
data->trace))
|
2017-06-07 21:27:33 +08:00
|
|
|
{
|
|
|
|
gui_message_console (data->severity,
|
|
|
|
data->domain,
|
2018-02-12 08:59:08 +08:00
|
|
|
data->message);
|
2017-06-07 21:27:33 +08:00
|
|
|
}
|
|
|
|
g_free (data->domain);
|
|
|
|
g_free (data->message);
|
2018-02-12 12:13:22 +08:00
|
|
|
if (data->trace)
|
|
|
|
g_free (data->trace);
|
2017-06-07 21:27:33 +08:00
|
|
|
if (data->handler)
|
|
|
|
g_object_unref (data->handler);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-07-19 14:50:34 +08:00
|
|
|
static gboolean
|
2012-01-31 06:24:44 +08:00
|
|
|
gui_message_error_console (Gimp *gimp,
|
|
|
|
GimpMessageSeverity severity,
|
2006-10-09 16:17:22 +08:00
|
|
|
const gchar *domain,
|
2018-02-12 08:59:08 +08:00
|
|
|
const gchar *message)
|
2006-07-19 14:50:34 +08:00
|
|
|
{
|
2017-11-13 23:07:03 +08:00
|
|
|
GtkWidget *dockable;
|
|
|
|
|
|
|
|
dockable = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (),
|
|
|
|
"gimp-error-console");
|
2006-07-19 14:50:34 +08:00
|
|
|
|
2017-10-28 20:57:57 +08:00
|
|
|
/* avoid raising the error console for unhighlighted messages */
|
2017-11-13 23:07:03 +08:00
|
|
|
if (dockable)
|
2006-11-23 00:33:31 +08:00
|
|
|
{
|
2017-11-13 23:07:03 +08:00
|
|
|
GtkWidget *child = gtk_bin_get_child (GTK_BIN (dockable));
|
|
|
|
|
|
|
|
if (GIMP_ERROR_CONSOLE (child)->highlight[severity])
|
|
|
|
dockable = NULL;
|
2006-11-23 00:33:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (! dockable)
|
2014-05-02 09:01:23 +08:00
|
|
|
{
|
2018-04-29 23:27:47 +08:00
|
|
|
GdkMonitor *monitor = gimp_get_monitor_at_pointer ();
|
2014-05-02 09:01:23 +08:00
|
|
|
|
|
|
|
dockable =
|
|
|
|
gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (gimp)),
|
|
|
|
gimp,
|
|
|
|
gimp_dialog_factory_get_singleton (),
|
2018-04-29 23:27:47 +08:00
|
|
|
monitor,
|
2014-05-02 09:01:23 +08:00
|
|
|
"gimp-error-console");
|
|
|
|
}
|
2006-07-19 14:50:34 +08:00
|
|
|
|
|
|
|
if (dockable)
|
|
|
|
{
|
2008-03-13 00:58:28 +08:00
|
|
|
GtkWidget *child = gtk_bin_get_child (GTK_BIN (dockable));
|
|
|
|
|
|
|
|
gimp_error_console_add (GIMP_ERROR_CONSOLE (child),
|
2006-10-09 16:17:22 +08:00
|
|
|
severity, domain, message);
|
2006-07-19 14:50:34 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
progress_error_dialog_unset (GimpProgress *progress)
|
|
|
|
{
|
|
|
|
g_object_set_data (G_OBJECT (progress), "gimp-error-dialog", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
progress_error_dialog (GimpProgress *progress)
|
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PROGRESS (progress), NULL);
|
|
|
|
|
|
|
|
dialog = g_object_get_data (G_OBJECT (progress), "gimp-error-dialog");
|
|
|
|
|
|
|
|
if (! dialog)
|
|
|
|
{
|
|
|
|
dialog = gimp_error_dialog_new (_("GIMP Message"));
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (progress), "gimp-error-dialog", dialog);
|
|
|
|
|
|
|
|
g_signal_connect_object (dialog, "destroy",
|
|
|
|
G_CALLBACK (progress_error_dialog_unset),
|
|
|
|
progress, G_CONNECT_SWAPPED);
|
|
|
|
|
|
|
|
if (GTK_IS_WIDGET (progress))
|
|
|
|
{
|
|
|
|
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (progress));
|
|
|
|
|
|
|
|
if (GTK_IS_WINDOW (toplevel))
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dialog),
|
|
|
|
GTK_WINDOW (toplevel));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
app, libgimp*, pdb, plug-ins: reimplement generic inter-process transient window.
Having windows ID as guint32 is a mistake. Different systems have
different protocols. In Wayland in particular, Windows handles are
exchanged as strings. What this commit does is the following:
In core:
- get_window_id() virtual function in core GimpProgress is changed to
return a GBytes, as a generic "data" to represent a window differently
on different systems.
- All implementations of get_window_id() in various classes implementing
this interface are updated accordingly:
* GimpSubProgress
* GimpDisplay returns the handle of its shell.
* GimpDisplayShell now creates its window handle at construction with
libgimpwidget's gimp_widget_set_native_handle() and simply return
this handle every time it's requested.
* GimpFileDialog also creates its window handle at construction with
gimp_widget_set_native_handle().
- gimp_window_set_transient_for() in core is changed to take a
GimpProgress as argument (instead of a guint32 ID), requests and
process the ID itself, according to the running platform. In
particular, the following were improved:
* Unlike old code, it will work even if the window is not visible yet.
In such a case, the function simply adds a signal handler to set
transient at mapping. It makes it easier to use it at construction
in a reliable way.
* It now works for Wayland too, additionally to X11.
- GimpPdbProgress now exchanges a GBytes too with the command
GIMP_PROGRESS_COMMAND_GET_WINDOW.
- display_get_window_id() in gimp-gui.h also returns a GBytes now.
PDB/libgimp:
- gimp_display_get_window_handle() and gimp_progress_get_window_handle()
now return a GBytes to represent a window handle in an opaque way
(depending on the running platform).
In libgimp:
- GimpProgress's get_window() virtual function changed to return a
GBytes and renamed get_window_handle().
- In particular GimpProgressBar is the only implementation of
get_window_handle(). It creates its handle at object construction with
libgimpwidget's gimp_widget_set_native_handle() and the virtual
method's implementation simply returns the GBytes.
In libgimpUi:
- gimp_ui_get_display_window() and gimp_ui_get_progress_window() were
removed. We should not assume anymore that it is possible to create a
GdkWindow to be used. For instance this is not possible with Wayland
which has its own way to set a window transient with a string handle.
- gimp_window_set_transient_for_display() and
gimp_window_set_transient() now use an internal implementation similar
to core gimp_window_set_transient_for(), with the same improvements
(works even at construction when the window is not visible yet + works
for Wayland too).
In libgimpwidgets:
- New gimp_widget_set_native_handle() is a helper function used both in
core and libgimp* libraries for widgets which we want to be usable as
possible parents. It takes care of getting the relevant window handle
(depending on the running platform) and stores it in a given pointer,
either immediately or after a callback once the widget is mapped. So
it can be used at construction. Also it sets a handle for X11 or
Wayland.
In plug-ins:
- Screenshot uses the new gimp_progress_get_window_handle() directly now
in its X11 code path and creates out of it a GdkWindows itself with
gdk_x11_window_foreign_new_for_display().
Our inter-process transient implementation only worked for X11, and with
this commit, it works for Wayland too.
There is code for Windows but it is currently disabled as it apparently
hangs (there is a comment in-code which links to this old report:
https://bugzilla.gnome.org/show_bug.cgi?id=359538). NikcDC tested
yesterday with re-enabling the code and said they experienced a freeze.
;-(
Finally there is no infrastructure yet to make this work on macOS and
apparently there is no implementation of window handle in GDK for macOS
that I could find. I'm not sure if macOS doesn't have this concept of
setting transient on another processus's window or GDK is simply lacking
the implementation.
2023-08-14 20:23:06 +08:00
|
|
|
gimp_window_set_transient_for (GTK_WINDOW (dialog), progress);
|
2006-07-19 14:50:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2006-10-09 16:17:22 +08:00
|
|
|
gui_message_error_dialog (Gimp *gimp,
|
|
|
|
GObject *handler,
|
|
|
|
GimpMessageSeverity severity,
|
|
|
|
const gchar *domain,
|
2018-02-12 12:13:22 +08:00
|
|
|
const gchar *message,
|
|
|
|
const gchar *trace)
|
2006-07-19 14:50:34 +08:00
|
|
|
{
|
2018-01-23 10:38:46 +08:00
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkMessageType type = GTK_MESSAGE_ERROR;
|
|
|
|
|
|
|
|
switch (severity)
|
|
|
|
{
|
2018-02-13 00:20:53 +08:00
|
|
|
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;
|
|
|
|
case GIMP_MESSAGE_BUG_WARNING:
|
|
|
|
case GIMP_MESSAGE_BUG_CRITICAL:
|
|
|
|
type = GTK_MESSAGE_OTHER;
|
|
|
|
break;
|
2018-01-23 10:38:46 +08:00
|
|
|
}
|
|
|
|
|
2018-02-13 00:20:53 +08:00
|
|
|
if (severity >= GIMP_MESSAGE_BUG_WARNING)
|
2018-01-23 10:38:46 +08:00
|
|
|
{
|
2018-02-13 00:20:53 +08:00
|
|
|
/* Process differently programming errors.
|
|
|
|
* The reason is that we will generate traces, which will take
|
|
|
|
* significant place, and cannot be processed as a progress
|
|
|
|
* message or in the global dialog. It will require its own
|
|
|
|
* dedicated dialog which will encourage people to report the bug.
|
2018-01-23 10:38:46 +08:00
|
|
|
*/
|
2018-02-12 12:13:22 +08:00
|
|
|
gboolean gui_error = FALSE;
|
|
|
|
|
|
|
|
g_mutex_lock (&mutex);
|
|
|
|
if (n_errors < MAX_ERRORS)
|
|
|
|
{
|
|
|
|
gui_error = TRUE;
|
|
|
|
n_errors++;
|
|
|
|
}
|
|
|
|
g_mutex_unlock (&mutex);
|
2018-01-23 10:38:46 +08:00
|
|
|
|
2018-02-12 12:13:22 +08:00
|
|
|
if (gui_error || trace)
|
2018-02-12 08:59:08 +08:00
|
|
|
{
|
|
|
|
gchar *text;
|
|
|
|
|
2018-02-12 12:13:22 +08:00
|
|
|
dialog = global_critical_dialog ();
|
2018-02-12 08:59:08 +08:00
|
|
|
|
|
|
|
text = gui_message_format (severity, domain, message);
|
|
|
|
gimp_critical_dialog_add (dialog, text, trace, FALSE, NULL, 0);
|
|
|
|
|
|
|
|
gtk_widget_show (dialog);
|
|
|
|
|
|
|
|
g_free (text);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-02-13 00:42:23 +08:00
|
|
|
const gchar *reason = "Message";
|
|
|
|
|
|
|
|
gimp_enum_get_value (GIMP_TYPE_MESSAGE_SEVERITY, severity,
|
|
|
|
NULL, NULL, &reason, NULL);
|
|
|
|
|
2018-03-25 04:49:01 +08:00
|
|
|
/* Since we overridden glib default's WARNING and CRITICAL
|
2018-02-12 08:59:08 +08:00
|
|
|
* handler, if we decide not to handle this error in the end,
|
|
|
|
* let's just print it in terminal in a similar fashion as
|
|
|
|
* glib's default handler (though without the fancy terminal
|
|
|
|
* colors right now).
|
|
|
|
*/
|
2018-02-13 00:42:23 +08:00
|
|
|
g_printerr ("%s-%s: %s\n", domain, reason, message);
|
2018-02-12 08:59:08 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2018-01-23 10:38:46 +08:00
|
|
|
}
|
|
|
|
else if (GIMP_IS_PROGRESS (handler))
|
2006-10-09 16:17:22 +08:00
|
|
|
{
|
2008-04-11 03:24:06 +08:00
|
|
|
/* If there's already an error dialog associated with this
|
|
|
|
* progress, then continue without trying gimp_progress_message().
|
|
|
|
*/
|
|
|
|
if (! g_object_get_data (handler, "gimp-error-dialog") &&
|
|
|
|
gimp_progress_message (GIMP_PROGRESS (handler), gimp,
|
2006-10-09 16:17:22 +08:00
|
|
|
severity, domain, message))
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (GTK_IS_WIDGET (handler))
|
|
|
|
{
|
2018-01-23 10:38:46 +08:00
|
|
|
GtkWidget *parent = GTK_WIDGET (handler);
|
2006-10-09 16:17:22 +08:00
|
|
|
|
|
|
|
dialog =
|
|
|
|
gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (parent)),
|
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
type, GTK_BUTTONS_OK,
|
2008-11-04 20:33:09 +08:00
|
|
|
"%s", message);
|
2006-10-09 16:17:22 +08:00
|
|
|
|
|
|
|
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));
|
2006-08-11 19:50:23 +08:00
|
|
|
else
|
|
|
|
dialog = global_error_dialog ();
|
2006-07-19 14:50:34 +08:00
|
|
|
|
|
|
|
if (dialog)
|
|
|
|
{
|
2020-12-18 05:21:24 +08:00
|
|
|
gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE);
|
2006-07-19 14:50:34 +08:00
|
|
|
gimp_error_dialog_add (GIMP_ERROR_DIALOG (dialog),
|
2014-05-07 21:30:38 +08:00
|
|
|
gimp_get_message_icon_name (severity),
|
2006-10-09 16:17:22 +08:00
|
|
|
domain, message);
|
2006-07-19 14:50:34 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-10-09 16:17:22 +08:00
|
|
|
gui_message_console (GimpMessageSeverity severity,
|
|
|
|
const gchar *domain,
|
2018-02-12 08:59:08 +08:00
|
|
|
const gchar *message)
|
2018-01-23 10:38:46 +08:00
|
|
|
{
|
|
|
|
gchar *formatted_message;
|
|
|
|
|
|
|
|
formatted_message = gui_message_format (severity, domain, message);
|
|
|
|
g_printerr ("%s\n\n", formatted_message);
|
|
|
|
g_free (formatted_message);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
gui_message_format (GimpMessageSeverity severity,
|
|
|
|
const gchar *domain,
|
|
|
|
const gchar *message)
|
2006-07-19 14:50:34 +08:00
|
|
|
{
|
2006-10-09 16:17:22 +08:00
|
|
|
const gchar *desc = "Message";
|
2018-01-23 10:38:46 +08:00
|
|
|
gchar *formatted_message;
|
2006-10-09 16:17:22 +08:00
|
|
|
|
|
|
|
gimp_enum_get_value (GIMP_TYPE_MESSAGE_SEVERITY, severity,
|
|
|
|
NULL, NULL, &desc, NULL);
|
2018-01-23 10:38:46 +08:00
|
|
|
|
|
|
|
formatted_message = g_strdup_printf ("%s-%s: %s", domain, desc, message);
|
|
|
|
|
|
|
|
return formatted_message;
|
2006-07-19 14:50:34 +08:00
|
|
|
}
|
2018-02-12 12:13:22 +08:00
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
global_error_dialog (void)
|
|
|
|
{
|
2018-04-29 23:27:47 +08:00
|
|
|
GdkMonitor *monitor = gimp_get_monitor_at_pointer ();
|
2018-02-12 12:13:22 +08:00
|
|
|
|
|
|
|
return gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
|
2018-04-29 23:27:47 +08:00
|
|
|
monitor,
|
2018-02-12 12:13:22 +08:00
|
|
|
NULL /*ui_manager*/,
|
2018-05-03 06:55:44 +08:00
|
|
|
NULL,
|
2018-02-12 12:13:22 +08:00
|
|
|
"gimp-error-dialog", -1,
|
|
|
|
FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
global_critical_dialog (void)
|
|
|
|
{
|
2018-04-29 23:27:47 +08:00
|
|
|
GdkMonitor *monitor = gimp_get_monitor_at_pointer ();
|
|
|
|
GtkWidget *dialog;
|
2018-02-12 12:13:22 +08:00
|
|
|
|
|
|
|
dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
|
2018-04-29 23:27:47 +08:00
|
|
|
monitor,
|
2018-02-12 12:13:22 +08:00
|
|
|
NULL /*ui_manager*/,
|
2018-05-03 06:55:44 +08:00
|
|
|
NULL,
|
2018-02-12 12:13:22 +08:00
|
|
|
"gimp-critical-dialog", -1,
|
|
|
|
FALSE);
|
|
|
|
g_signal_handlers_disconnect_by_func (dialog,
|
|
|
|
gui_message_reset_errors,
|
|
|
|
NULL);
|
|
|
|
g_signal_connect (dialog, "destroy",
|
|
|
|
G_CALLBACK (gui_message_reset_errors),
|
|
|
|
NULL);
|
|
|
|
return dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-04-28 08:17:55 +08:00
|
|
|
gui_message_reset_errors (GObject *object,
|
|
|
|
gpointer user_data)
|
2018-02-12 12:13:22 +08:00
|
|
|
{
|
|
|
|
g_mutex_lock (&mutex);
|
|
|
|
n_errors = 0;
|
|
|
|
n_traces = 0;
|
|
|
|
g_mutex_unlock (&mutex);
|
|
|
|
}
|