Add gimp_statusbar_override/restore_window_title()
Which sets/unsets the title of an iconified toplevel image window to the current progress message (if any). Use the new functions when the window is (de)iconified. Not exactly the high art of programming, but much better than the hacks in gimpdisplayshell-progress.c that are now removed.
This commit is contained in:
@ -27,18 +27,9 @@
|
||||
|
||||
#include "gimpdisplayshell.h"
|
||||
#include "gimpdisplayshell-progress.h"
|
||||
#include "gimpdisplayshell-title.h"
|
||||
#include "gimpstatusbar.h"
|
||||
|
||||
|
||||
/* 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);
|
||||
|
||||
|
||||
static GimpProgress *
|
||||
gimp_display_shell_progress_start (GimpProgress *progress,
|
||||
const gchar *message,
|
||||
@ -50,11 +41,6 @@ gimp_display_shell_progress_start (GimpProgress *progress,
|
||||
progress = gimp_progress_start (GIMP_PROGRESS (GIMP_IMAGE_WINDOW (shell)->statusbar),
|
||||
message, cancelable);
|
||||
|
||||
if (progress && gimp_display_shell_is_iconified (shell))
|
||||
{
|
||||
gtk_window_set_title (GTK_WINDOW (shell), message);
|
||||
}
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
||||
@ -65,9 +51,6 @@ gimp_display_shell_progress_end (GimpProgress *progress)
|
||||
|
||||
/* FIXME image window */
|
||||
gimp_progress_end (GIMP_PROGRESS (GIMP_IMAGE_WINDOW (shell)->statusbar));
|
||||
|
||||
if (gimp_display_shell_is_iconified (shell))
|
||||
gimp_display_shell_title_update (shell);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -87,13 +70,6 @@ gimp_display_shell_progress_set_text (GimpProgress *progress,
|
||||
|
||||
/* FIXME image window */
|
||||
gimp_progress_set_text (GIMP_PROGRESS (GIMP_IMAGE_WINDOW (shell)->statusbar), message);
|
||||
|
||||
/* FIXME image window */
|
||||
if (gimp_progress_is_active (GIMP_PROGRESS (GIMP_IMAGE_WINDOW (shell)->statusbar)) &&
|
||||
gimp_display_shell_is_iconified (shell))
|
||||
{
|
||||
gtk_window_set_title (GTK_WINDOW (shell), message);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -170,18 +146,6 @@ gimp_display_shell_progress_message (GimpProgress *progress,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_display_shell_is_iconified (GimpDisplayShell *shell)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (shell);
|
||||
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
|
||||
|
||||
return (GTK_WIDGET_DRAWABLE (widget) &&
|
||||
gdk_window_get_state (gtk_widget_get_window (toplevel)) ==
|
||||
GDK_WINDOW_STATE_ICONIFIED);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_display_shell_progress_iface_init (GimpProgressInterface *iface)
|
||||
{
|
||||
@ -195,24 +159,3 @@ gimp_display_shell_progress_iface_init (GimpProgressInterface *iface)
|
||||
iface->get_window = gimp_display_shell_progress_get_window;
|
||||
iface->message = gimp_display_shell_progress_message;
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
/* FIXME image window */
|
||||
const gchar *msg = gimp_statusbar_peek (GIMP_STATUSBAR (GIMP_IMAGE_WINDOW (shell)->statusbar),
|
||||
"progress");
|
||||
if (msg)
|
||||
{
|
||||
gtk_window_set_title (GTK_WINDOW (shell), msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
gimp_display_shell_title_update (shell);
|
||||
}
|
||||
|
@ -18,12 +18,11 @@
|
||||
#ifndef __GIMP_DISPLAY_SHELL_PROGRESS_H__
|
||||
#define __GIMP_DISPLAY_SHELL_PROGRESS_H__
|
||||
|
||||
|
||||
#include "core/gimpprogress.h"
|
||||
|
||||
|
||||
void gimp_display_shell_progress_iface_init (GimpProgressInterface *iface);
|
||||
|
||||
void gimp_display_shell_progress_window_state_changed (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_progress_iface_init (GimpProgressInterface *iface);
|
||||
|
||||
|
||||
#endif /* __GIMP_DISPLAY_SHELL_PROGRESS_H__ */
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "display-types.h"
|
||||
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpprogress.h"
|
||||
|
||||
#include "widgets/gimpactiongroup.h"
|
||||
#include "widgets/gimpdialogfactory.h"
|
||||
@ -39,7 +40,6 @@
|
||||
#include "gimpdisplayshell.h"
|
||||
#include "gimpdisplayshell-appearance.h"
|
||||
#include "gimpdisplayshell-close.h"
|
||||
#include "gimpdisplayshell-progress.h"
|
||||
#include "gimpdisplayshell-scroll.h"
|
||||
#include "gimpimagewindow.h"
|
||||
#include "gimpstatusbar.h"
|
||||
@ -395,8 +395,16 @@ gimp_image_window_window_state_event (GtkWidget *widget,
|
||||
gimp_dialog_factories_show_with_display ();
|
||||
}
|
||||
|
||||
/* FIXME multiple shells */
|
||||
gimp_display_shell_progress_window_state_changed (GIMP_DISPLAY_SHELL (display->shell));
|
||||
if (gimp_progress_is_active (GIMP_PROGRESS (window->statusbar)))
|
||||
{
|
||||
GimpStatusbar *statusbar = GIMP_STATUSBAR (window->statusbar);
|
||||
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
|
||||
|
||||
if (iconified)
|
||||
gimp_statusbar_override_window_title (statusbar);
|
||||
else
|
||||
gtk_window_set_title (GTK_WINDOW (window), shell->title);
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
@ -376,6 +376,8 @@ gimp_statusbar_progress_start (GimpProgress *progress,
|
||||
if (GTK_WIDGET_DRAWABLE (bar))
|
||||
gdk_window_process_updates (gtk_widget_get_window (bar), TRUE);
|
||||
|
||||
gimp_statusbar_override_window_title (statusbar);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
||||
@ -408,6 +410,8 @@ gimp_statusbar_progress_end (GimpProgress *progress)
|
||||
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (bar), 0.0);
|
||||
gtk_widget_set_sensitive (statusbar->cancel_button, FALSE);
|
||||
gtk_widget_hide (statusbar->cancel_button);
|
||||
|
||||
gimp_statusbar_restore_window_title (statusbar);
|
||||
}
|
||||
}
|
||||
|
||||
@ -433,6 +437,8 @@ gimp_statusbar_progress_set_text (GimpProgress *progress,
|
||||
|
||||
if (GTK_WIDGET_DRAWABLE (bar))
|
||||
gdk_window_process_updates (gtk_widget_get_window (bar), TRUE);
|
||||
|
||||
gimp_statusbar_override_window_title (statusbar);
|
||||
}
|
||||
}
|
||||
|
||||
@ -730,6 +736,40 @@ gimp_statusbar_fill (GimpStatusbar *statusbar)
|
||||
gtk_widget_show (statusbar->scale_combo);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_statusbar_override_window_title (GimpStatusbar *statusbar)
|
||||
{
|
||||
GtkWidget *toplevel;
|
||||
|
||||
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (statusbar));
|
||||
|
||||
if (gimp_image_window_is_iconified (GIMP_IMAGE_WINDOW (toplevel)))
|
||||
{
|
||||
const gchar *message = gimp_statusbar_peek (statusbar, "progress");
|
||||
|
||||
if (message)
|
||||
gtk_window_set_title (GTK_WINDOW (toplevel), message);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_statusbar_restore_window_title (GimpStatusbar *statusbar)
|
||||
{
|
||||
GtkWidget *toplevel;
|
||||
|
||||
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (statusbar));
|
||||
|
||||
if (gimp_image_window_is_iconified (GIMP_IMAGE_WINDOW (toplevel)))
|
||||
{
|
||||
/* FIXME title later */
|
||||
g_object_notify (G_OBJECT (statusbar->shell), "gimp-title");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_statusbar_push (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
|
@ -71,76 +71,79 @@ struct _GimpStatusbarClass
|
||||
};
|
||||
|
||||
|
||||
GType gimp_statusbar_get_type (void) G_GNUC_CONST;
|
||||
GtkWidget * gimp_statusbar_new (void);
|
||||
GType gimp_statusbar_get_type (void) G_GNUC_CONST;
|
||||
GtkWidget * gimp_statusbar_new (void);
|
||||
|
||||
void gimp_statusbar_set_shell (GimpStatusbar *statusbar,
|
||||
GimpDisplayShell *shell);
|
||||
void gimp_statusbar_set_shell (GimpStatusbar *statusbar,
|
||||
GimpDisplayShell *shell);
|
||||
|
||||
gboolean gimp_statusbar_get_visible (GimpStatusbar *statusbar);
|
||||
void gimp_statusbar_set_visible (GimpStatusbar *statusbar,
|
||||
gboolean visible);
|
||||
void gimp_statusbar_empty (GimpStatusbar *statusbar);
|
||||
void gimp_statusbar_fill (GimpStatusbar *statusbar);
|
||||
gboolean gimp_statusbar_get_visible (GimpStatusbar *statusbar);
|
||||
void gimp_statusbar_set_visible (GimpStatusbar *statusbar,
|
||||
gboolean visible);
|
||||
void gimp_statusbar_empty (GimpStatusbar *statusbar);
|
||||
void gimp_statusbar_fill (GimpStatusbar *statusbar);
|
||||
|
||||
void gimp_statusbar_push (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *stock_id,
|
||||
const gchar *format,
|
||||
...) G_GNUC_PRINTF(4,5);
|
||||
void gimp_statusbar_push_valist (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *stock_id,
|
||||
const gchar *format,
|
||||
va_list args);
|
||||
void gimp_statusbar_push_coords (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *stock_id,
|
||||
GimpCursorPrecision precision,
|
||||
const gchar *title,
|
||||
gdouble x,
|
||||
const gchar *separator,
|
||||
gdouble y,
|
||||
const gchar *help);
|
||||
void gimp_statusbar_push_length (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *stock_id,
|
||||
const gchar *title,
|
||||
GimpOrientationType axis,
|
||||
gdouble value,
|
||||
const gchar *help);
|
||||
void gimp_statusbar_replace (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *stock_id,
|
||||
const gchar *format,
|
||||
...) G_GNUC_PRINTF(4,5);
|
||||
void gimp_statusbar_replace_valist (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *stock_id,
|
||||
const gchar *format,
|
||||
va_list args);
|
||||
const gchar * gimp_statusbar_peek (GimpStatusbar *statusbar,
|
||||
const gchar *context);
|
||||
void gimp_statusbar_pop (GimpStatusbar *statusbar,
|
||||
const gchar *context);
|
||||
void gimp_statusbar_override_window_title (GimpStatusbar *statusbar);
|
||||
void gimp_statusbar_restore_window_title (GimpStatusbar *statusbar);
|
||||
|
||||
void gimp_statusbar_push_temp (GimpStatusbar *statusbar,
|
||||
GimpMessageSeverity severity,
|
||||
const gchar *stock_id,
|
||||
const gchar *format,
|
||||
...) G_GNUC_PRINTF(4,5);
|
||||
void gimp_statusbar_push_temp_valist (GimpStatusbar *statusbar,
|
||||
GimpMessageSeverity severity,
|
||||
const gchar *stock_id,
|
||||
const gchar *format,
|
||||
va_list args);
|
||||
void gimp_statusbar_pop_temp (GimpStatusbar *statusbar);
|
||||
void gimp_statusbar_push (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *stock_id,
|
||||
const gchar *format,
|
||||
...) G_GNUC_PRINTF(4,5);
|
||||
void gimp_statusbar_push_valist (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *stock_id,
|
||||
const gchar *format,
|
||||
va_list args);
|
||||
void gimp_statusbar_push_coords (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *stock_id,
|
||||
GimpCursorPrecision precision,
|
||||
const gchar *title,
|
||||
gdouble x,
|
||||
const gchar *separator,
|
||||
gdouble y,
|
||||
const gchar *help);
|
||||
void gimp_statusbar_push_length (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *stock_id,
|
||||
const gchar *title,
|
||||
GimpOrientationType axis,
|
||||
gdouble value,
|
||||
const gchar *help);
|
||||
void gimp_statusbar_replace (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *stock_id,
|
||||
const gchar *format,
|
||||
...) G_GNUC_PRINTF(4,5);
|
||||
void gimp_statusbar_replace_valist (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *stock_id,
|
||||
const gchar *format,
|
||||
va_list args);
|
||||
const gchar * gimp_statusbar_peek (GimpStatusbar *statusbar,
|
||||
const gchar *context);
|
||||
void gimp_statusbar_pop (GimpStatusbar *statusbar,
|
||||
const gchar *context);
|
||||
|
||||
void gimp_statusbar_update_cursor (GimpStatusbar *statusbar,
|
||||
GimpCursorPrecision precision,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
void gimp_statusbar_clear_cursor (GimpStatusbar *statusbar);
|
||||
void gimp_statusbar_push_temp (GimpStatusbar *statusbar,
|
||||
GimpMessageSeverity severity,
|
||||
const gchar *stock_id,
|
||||
const gchar *format,
|
||||
...) G_GNUC_PRINTF(4,5);
|
||||
void gimp_statusbar_push_temp_valist (GimpStatusbar *statusbar,
|
||||
GimpMessageSeverity severity,
|
||||
const gchar *stock_id,
|
||||
const gchar *format,
|
||||
va_list args);
|
||||
void gimp_statusbar_pop_temp (GimpStatusbar *statusbar);
|
||||
|
||||
void gimp_statusbar_update_cursor (GimpStatusbar *statusbar,
|
||||
GimpCursorPrecision precision,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
void gimp_statusbar_clear_cursor (GimpStatusbar *statusbar);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
Reference in New Issue
Block a user