2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2006-06-29 17:42:05 +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-06-29 17:42:05 +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-06-29 17:42:05 +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-06-29 17:42:05 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2013-06-23 04:26:46 +08:00
|
|
|
#include <gegl.h>
|
2006-06-29 17:42:05 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "display-types.h"
|
|
|
|
|
|
|
|
#include "core/gimpprogress.h"
|
|
|
|
|
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
|
|
|
|
|
|
|
#include "gimpdisplayshell.h"
|
|
|
|
#include "gimpdisplayshell-progress.h"
|
2006-10-09 16:17:22 +08:00
|
|
|
#include "gimpstatusbar.h"
|
2006-06-29 17:42:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
static GimpProgress *
|
|
|
|
gimp_display_shell_progress_start (GimpProgress *progress,
|
2014-07-13 05:45:20 +08:00
|
|
|
gboolean cancellable,
|
|
|
|
const gchar *message)
|
2006-06-29 17:42:05 +08:00
|
|
|
{
|
2009-10-04 21:31:38 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
|
|
|
|
GimpStatusbar *statusbar = gimp_display_shell_get_statusbar (shell);
|
2006-06-29 17:42:05 +08:00
|
|
|
|
2014-07-13 05:45:20 +08:00
|
|
|
return gimp_progress_start (GIMP_PROGRESS (statusbar), cancellable,
|
|
|
|
"%s", message);
|
2006-06-29 17:42:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_progress_end (GimpProgress *progress)
|
|
|
|
{
|
2009-10-04 21:31:38 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
|
|
|
|
GimpStatusbar *statusbar = gimp_display_shell_get_statusbar (shell);
|
2006-06-29 17:42:05 +08:00
|
|
|
|
2009-10-04 21:31:38 +08:00
|
|
|
gimp_progress_end (GIMP_PROGRESS (statusbar));
|
2006-06-29 17:42:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_display_shell_progress_is_active (GimpProgress *progress)
|
|
|
|
{
|
2009-10-04 21:31:38 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
|
|
|
|
GimpStatusbar *statusbar = gimp_display_shell_get_statusbar (shell);
|
2006-06-29 17:42:05 +08:00
|
|
|
|
2009-10-04 21:31:38 +08:00
|
|
|
return gimp_progress_is_active (GIMP_PROGRESS (statusbar));
|
2006-06-29 17:42:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_progress_set_text (GimpProgress *progress,
|
|
|
|
const gchar *message)
|
|
|
|
{
|
2009-10-04 21:31:38 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
|
|
|
|
GimpStatusbar *statusbar = gimp_display_shell_get_statusbar (shell);
|
2006-06-29 17:42:05 +08:00
|
|
|
|
2014-07-21 05:32:19 +08:00
|
|
|
gimp_progress_set_text_literal (GIMP_PROGRESS (statusbar), message);
|
2006-06-29 17:42:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_progress_set_value (GimpProgress *progress,
|
|
|
|
gdouble percentage)
|
|
|
|
{
|
2009-10-04 21:31:38 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
|
|
|
|
GimpStatusbar *statusbar = gimp_display_shell_get_statusbar (shell);
|
2006-06-29 17:42:05 +08:00
|
|
|
|
2009-10-04 21:31:38 +08:00
|
|
|
gimp_progress_set_value (GIMP_PROGRESS (statusbar), percentage);
|
2006-06-29 17:42:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gdouble
|
|
|
|
gimp_display_shell_progress_get_value (GimpProgress *progress)
|
|
|
|
{
|
2009-10-04 21:31:38 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
|
|
|
|
GimpStatusbar *statusbar = gimp_display_shell_get_statusbar (shell);
|
2006-06-29 17:42:05 +08:00
|
|
|
|
2009-10-04 21:31:38 +08:00
|
|
|
return gimp_progress_get_value (GIMP_PROGRESS (statusbar));
|
2006-06-29 17:42:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_progress_pulse (GimpProgress *progress)
|
|
|
|
{
|
2009-10-04 21:31:38 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
|
|
|
|
GimpStatusbar *statusbar = gimp_display_shell_get_statusbar (shell);
|
2006-06-29 17:42:05 +08:00
|
|
|
|
2009-10-04 21:31:38 +08:00
|
|
|
gimp_progress_pulse (GIMP_PROGRESS (statusbar));
|
2006-06-29 17:42:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static guint32
|
2011-02-06 19:07:55 +08:00
|
|
|
gimp_display_shell_progress_get_window_id (GimpProgress *progress)
|
2006-06-29 17:42:05 +08:00
|
|
|
{
|
2009-09-26 01:56:04 +08:00
|
|
|
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (progress));
|
2006-06-29 17:42:05 +08:00
|
|
|
|
2009-09-30 02:32:26 +08:00
|
|
|
if (GTK_IS_WINDOW (toplevel))
|
2011-02-06 19:07:55 +08:00
|
|
|
return gimp_window_get_native_id (GTK_WINDOW (toplevel));
|
2009-09-30 02:32:26 +08:00
|
|
|
|
|
|
|
return 0;
|
2006-06-29 17:42:05 +08:00
|
|
|
}
|
|
|
|
|
2006-10-09 16:17:22 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_display_shell_progress_message (GimpProgress *progress,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpMessageSeverity severity,
|
|
|
|
const gchar *domain,
|
|
|
|
const gchar *message)
|
|
|
|
{
|
2009-10-04 21:31:38 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
|
|
|
|
GimpStatusbar *statusbar = gimp_display_shell_get_statusbar (shell);
|
2006-10-09 16:17:22 +08:00
|
|
|
|
2009-10-04 21:31:38 +08:00
|
|
|
switch (severity)
|
2006-12-12 05:14:23 +08:00
|
|
|
{
|
2009-10-04 21:31:38 +08:00
|
|
|
case GIMP_MESSAGE_ERROR:
|
2018-02-13 00:20:53 +08:00
|
|
|
case GIMP_MESSAGE_BUG_WARNING:
|
|
|
|
case GIMP_MESSAGE_BUG_CRITICAL:
|
2009-10-04 21:31:38 +08:00
|
|
|
/* error messages are never handled here */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_MESSAGE_WARNING:
|
|
|
|
/* warning messages go to the statusbar, if it's visible */
|
|
|
|
if (! gimp_statusbar_get_visible (statusbar))
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
return gimp_progress_message (GIMP_PROGRESS (statusbar), gimp,
|
|
|
|
severity, domain, message);
|
|
|
|
|
|
|
|
case GIMP_MESSAGE_INFO:
|
|
|
|
/* info messages go to the statusbar;
|
|
|
|
* if they are not handled there, they are swallowed
|
|
|
|
*/
|
|
|
|
gimp_progress_message (GIMP_PROGRESS (statusbar), gimp,
|
|
|
|
severity, domain, message);
|
|
|
|
return TRUE;
|
2006-12-12 05:14:23 +08:00
|
|
|
}
|
2006-12-12 05:18:18 +08:00
|
|
|
|
|
|
|
return FALSE;
|
2006-10-09 16:17:22 +08:00
|
|
|
}
|
|
|
|
|
2006-06-29 17:42:05 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_progress_iface_init (GimpProgressInterface *iface)
|
|
|
|
{
|
2011-02-06 19:07:55 +08:00
|
|
|
iface->start = gimp_display_shell_progress_start;
|
|
|
|
iface->end = gimp_display_shell_progress_end;
|
|
|
|
iface->is_active = gimp_display_shell_progress_is_active;
|
|
|
|
iface->set_text = gimp_display_shell_progress_set_text;
|
|
|
|
iface->set_value = gimp_display_shell_progress_set_value;
|
|
|
|
iface->get_value = gimp_display_shell_progress_get_value;
|
|
|
|
iface->pulse = gimp_display_shell_progress_pulse;
|
|
|
|
iface->get_window_id = gimp_display_shell_progress_get_window_id;
|
|
|
|
iface->message = gimp_display_shell_progress_message;
|
2006-06-29 17:42:05 +08:00
|
|
|
}
|