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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-06-29 17:42:05 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "display-types.h"
|
|
|
|
|
|
|
|
#include "core/gimpprogress.h"
|
|
|
|
|
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
|
|
|
|
|
|
|
#include "gimpdisplayshell.h"
|
|
|
|
#include "gimpdisplayshell-progress.h"
|
2008-03-25 22:07:10 +08:00
|
|
|
#include "gimpdisplayshell-title.h"
|
2006-10-09 16:17:22 +08:00
|
|
|
#include "gimpstatusbar.h"
|
2006-06-29 17:42:05 +08:00
|
|
|
|
|
|
|
|
2008-03-25 22:07:10 +08:00
|
|
|
/* Progress is shown in the status-bar. If the image window is iconified,
|
|
|
|
* the progress messages are also shown in the window title so that they
|
|
|
|
* appear in the task bar.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static gboolean gimp_display_shell_is_iconified (GimpDisplayShell *shell);
|
|
|
|
|
|
|
|
|
2006-06-29 17:42:05 +08:00
|
|
|
static GimpProgress *
|
|
|
|
gimp_display_shell_progress_start (GimpProgress *progress,
|
|
|
|
const gchar *message,
|
|
|
|
gboolean cancelable)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
|
|
|
|
|
2008-03-25 22:07:10 +08:00
|
|
|
progress = gimp_progress_start (GIMP_PROGRESS (shell->statusbar),
|
|
|
|
message, cancelable);
|
|
|
|
|
|
|
|
if (progress && gimp_display_shell_is_iconified (shell))
|
|
|
|
{
|
2009-07-20 19:14:09 +08:00
|
|
|
gtk_window_set_title (GTK_WINDOW (shell), message);
|
2008-03-25 22:07:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return progress;
|
2006-06-29 17:42:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_progress_end (GimpProgress *progress)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
|
|
|
|
|
|
|
|
gimp_progress_end (GIMP_PROGRESS (shell->statusbar));
|
2008-03-25 22:07:10 +08:00
|
|
|
|
|
|
|
if (gimp_display_shell_is_iconified (shell))
|
|
|
|
gimp_display_shell_title_update (shell);
|
2006-06-29 17:42:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_display_shell_progress_is_active (GimpProgress *progress)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
|
|
|
|
|
|
|
|
return gimp_progress_is_active (GIMP_PROGRESS (shell->statusbar));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_progress_set_text (GimpProgress *progress,
|
|
|
|
const gchar *message)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
|
|
|
|
|
|
|
|
gimp_progress_set_text (GIMP_PROGRESS (shell->statusbar), message);
|
2008-03-25 22:07:10 +08:00
|
|
|
|
|
|
|
if (gimp_progress_is_active (GIMP_PROGRESS (shell->statusbar)) &&
|
|
|
|
gimp_display_shell_is_iconified (shell))
|
|
|
|
{
|
2009-07-20 19:14:09 +08:00
|
|
|
gtk_window_set_title (GTK_WINDOW (shell), message);
|
2008-03-25 22:07:10 +08:00
|
|
|
}
|
2006-06-29 17:42:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_progress_set_value (GimpProgress *progress,
|
|
|
|
gdouble percentage)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
|
|
|
|
|
|
|
|
gimp_progress_set_value (GIMP_PROGRESS (shell->statusbar), percentage);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gdouble
|
|
|
|
gimp_display_shell_progress_get_value (GimpProgress *progress)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
|
|
|
|
|
|
|
|
return gimp_progress_get_value (GIMP_PROGRESS (shell->statusbar));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_progress_pulse (GimpProgress *progress)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
|
|
|
|
|
|
|
|
gimp_progress_pulse (GIMP_PROGRESS (shell->statusbar));
|
|
|
|
}
|
|
|
|
|
|
|
|
static guint32
|
|
|
|
gimp_display_shell_progress_get_window (GimpProgress *progress)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
|
|
|
|
|
|
|
|
return (guint32) gimp_window_get_native (GTK_WINDOW (shell));
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
|
|
|
|
|
2006-12-12 05:14:23 +08:00
|
|
|
switch (severity)
|
|
|
|
{
|
|
|
|
case GIMP_MESSAGE_ERROR:
|
|
|
|
/* error messages are never handled here */
|
2006-12-12 05:18:18 +08:00
|
|
|
break;
|
2006-12-12 05:14:23 +08:00
|
|
|
|
|
|
|
case GIMP_MESSAGE_WARNING:
|
|
|
|
/* warning messages go to the statusbar, if it's visible */
|
2007-05-29 01:42:55 +08:00
|
|
|
if (! gimp_statusbar_get_visible (GIMP_STATUSBAR (shell->statusbar)))
|
2006-12-12 05:18:18 +08:00
|
|
|
break;
|
2008-07-10 17:42:36 +08:00
|
|
|
else
|
|
|
|
return gimp_progress_message (GIMP_PROGRESS (shell->statusbar), gimp,
|
|
|
|
severity, domain, message);
|
2006-12-12 05:14:23 +08:00
|
|
|
|
|
|
|
case GIMP_MESSAGE_INFO:
|
2008-07-10 17:42:36 +08:00
|
|
|
/* info messages go to the statusbar;
|
|
|
|
* if they are not handled there, they are swallowed
|
|
|
|
*/
|
|
|
|
gimp_progress_message (GIMP_PROGRESS (shell->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
|
|
|
}
|
|
|
|
|
2008-03-25 22:07:10 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_display_shell_is_iconified (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
GtkWidget *widget = GTK_WIDGET (shell);
|
|
|
|
|
|
|
|
return (GTK_WIDGET_DRAWABLE (widget) &&
|
2009-07-15 21:02:31 +08:00
|
|
|
gdk_window_get_state (gtk_widget_get_window (widget)) ==
|
|
|
|
GDK_WINDOW_STATE_ICONIFIED);
|
2008-03-25 22:07:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-29 17:42:05 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_progress_iface_init (GimpProgressInterface *iface)
|
|
|
|
{
|
|
|
|
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 = gimp_display_shell_progress_get_window;
|
2006-10-09 16:17:22 +08:00
|
|
|
iface->message = gimp_display_shell_progress_message;
|
2006-06-29 17:42:05 +08:00
|
|
|
}
|
2008-03-25 22:07:10 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
gimp_display_shell_progress_window_state_changed (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
if (! gimp_progress_is_active (GIMP_PROGRESS (shell)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (gimp_display_shell_is_iconified (shell))
|
|
|
|
{
|
|
|
|
const gchar *msg = gimp_statusbar_peek (GIMP_STATUSBAR (shell->statusbar),
|
|
|
|
"progress");
|
|
|
|
if (msg)
|
|
|
|
{
|
2009-07-20 19:14:09 +08:00
|
|
|
gtk_window_set_title (GTK_WINDOW (shell), msg);
|
2008-03-25 22:07:10 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_display_shell_title_update (shell);
|
|
|
|
}
|