gimp/app/display/gimpdisplayshell-progress.c
Michael Natterer 2fe95848c5 Don't leave the user without progress bar just because the display's
2007-05-28  Michael Natterer  <mitch@gimp.org>

	Don't leave the user without progress bar just because the
	display's statusbar is invisible:

	* app/display/gimpstatusbar.[ch]: if the statusbar is invisible
	when a progress wants to be shown, temporarily show it, recording
	the fact in the new boolean "progress_shown" member. Added new API
	gimp_statusbar_get/set_visible() which is aware of the new
	temporary visibility state.

	* app/display/gimpdisplayshell-appearance.c
	(gimp_display_shell_set_show_statusbar)
	* app/display/gimpdisplayshell-progress.c
	(gimp_display_shell_progress_message): use the new API instead of
	showing/hiding the widget directly.


svn path=/trunk/; revision=22642
2007-05-28 17:42:55 +00:00

146 lines
4.5 KiB
C

/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#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"
#include "gimpstatusbar.h"
static GimpProgress *
gimp_display_shell_progress_start (GimpProgress *progress,
const gchar *message,
gboolean cancelable)
{
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
return gimp_progress_start (GIMP_PROGRESS (shell->statusbar),
message, cancelable);
}
static void
gimp_display_shell_progress_end (GimpProgress *progress)
{
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
gimp_progress_end (GIMP_PROGRESS (shell->statusbar));
}
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);
}
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));
}
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);
switch (severity)
{
case GIMP_MESSAGE_ERROR:
/* 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 (GIMP_STATUSBAR (shell->statusbar)))
break;
/* else fallthrough */
case GIMP_MESSAGE_INFO:
/* info messages go to the statusbar, no matter if it's visible or not */
return gimp_progress_message (GIMP_PROGRESS (shell->statusbar), gimp,
severity, domain, message);
}
return FALSE;
}
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;
iface->message = gimp_display_shell_progress_message;
}