mirror of https://github.com/GNOME/gimp.git
changed all message setting functions to use printf-style argument lists.
2006-09-22 Michael Natterer <mitch@gimp.org> * app/display/gimpstatusbar.[ch]: changed all message setting functions to use printf-style argument lists. Added new API to show a temporary message that stays on top regardless of any other message activity and disappears after 3 seconds. * app/actions/edit-commands.c: show a statusbar message when pasting fails because the clipboard contains no image data. Pop a dialog when "Paste as New" fails. Addresses bug #357059 for internal functions. * app/display/gimpdisplayshell-title.c * app/gui/gui.c * app/tools/gimptool.c: changed accordingly.
This commit is contained in:
parent
9789d18b94
commit
1419751614
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2006-09-22 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/display/gimpstatusbar.[ch]: changed all message setting
|
||||
functions to use printf-style argument lists. Added new API to
|
||||
show a temporary message that stays on top regardless of any other
|
||||
message activity and disappears after 3 seconds.
|
||||
|
||||
* app/actions/edit-commands.c: show a statusbar message when
|
||||
pasting fails because the clipboard contains no image data. Pop a
|
||||
dialog when "Paste as New" fails. Addresses bug #357059 for
|
||||
internal functions.
|
||||
|
||||
* app/display/gimpdisplayshell-title.c
|
||||
* app/gui/gui.c
|
||||
* app/tools/gimptool.c: changed accordingly.
|
||||
|
||||
2006-09-22 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/display/gimpdisplayshell-selection.c: always recalculate the
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplayshell.h"
|
||||
#include "display/gimpdisplayshell-transform.h"
|
||||
#include "display/gimpstatusbar.h"
|
||||
|
||||
#include "widgets/gimpclipboard.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
|
@ -263,6 +264,10 @@ edit_paste_as_new_cmd_callback (GtkAction *action,
|
|||
|
||||
g_object_unref (buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_message (_("There is no image data in the clipboard to paste."));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -412,6 +417,14 @@ edit_paste (GimpDisplay *display,
|
|||
|
||||
g_object_unref (buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
|
||||
|
||||
gimp_statusbar_push_temp (GIMP_STATUSBAR (shell->statusbar),
|
||||
_("There is no image data in "
|
||||
"the clipboard to paste."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,8 @@ gimp_display_shell_title_init (GimpDisplayShell *shell)
|
|||
gimp_display_shell_format_title (shell, title, sizeof (title),
|
||||
config->image_status_format);
|
||||
|
||||
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar), "title", title);
|
||||
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar), "title",
|
||||
"%s", title);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -113,7 +114,8 @@ gimp_display_shell_update_title_idle (gpointer data)
|
|||
config->image_status_format);
|
||||
}
|
||||
|
||||
gimp_statusbar_replace (GIMP_STATUSBAR (shell->statusbar), "title", title);
|
||||
gimp_statusbar_replace (GIMP_STATUSBAR (shell->statusbar), "title",
|
||||
"%s", title);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -76,6 +76,13 @@ static void gimp_statusbar_progress_pulse (GimpProgress *progress);
|
|||
static void gimp_statusbar_progress_canceled (GtkWidget *button,
|
||||
GimpStatusbar *statusbar);
|
||||
|
||||
static void gimp_statusbar_progress_style_set (GtkWidget *widget,
|
||||
GtkStyle *prev_style,
|
||||
GimpStatusbar *statusbar);
|
||||
static gboolean gimp_statusbar_progress_expose (GtkWidget *widget,
|
||||
GdkEventExpose *event,
|
||||
GimpStatusbar *statusbar);
|
||||
|
||||
static void gimp_statusbar_update (GimpStatusbar *statusbar);
|
||||
static void gimp_statusbar_unit_changed (GimpUnitComboBox *combo,
|
||||
GimpStatusbar *statusbar);
|
||||
|
@ -85,6 +92,7 @@ static void gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
|
|||
GimpStatusbar *statusbar);
|
||||
static guint gimp_statusbar_get_context_id (GimpStatusbar *statusbar,
|
||||
const gchar *context);
|
||||
static gboolean gimp_statusbar_temp_timeout (GimpStatusbar *statusbar);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpStatusbar, gimp_statusbar, GTK_TYPE_HBOX,
|
||||
|
@ -100,7 +108,7 @@ gimp_statusbar_class_init (GimpStatusbarClass *klass)
|
|||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->finalize = gimp_statusbar_finalize;
|
||||
object_class->finalize = gimp_statusbar_finalize;
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_enum ("shadow-type",
|
||||
|
@ -111,6 +119,18 @@ gimp_statusbar_class_init (GimpStatusbarClass *klass)
|
|||
GIMP_PARAM_READABLE));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_statusbar_progress_iface_init (GimpProgressInterface *iface)
|
||||
{
|
||||
iface->start = gimp_statusbar_progress_start;
|
||||
iface->end = gimp_statusbar_progress_end;
|
||||
iface->is_active = gimp_statusbar_progress_is_active;
|
||||
iface->set_text = gimp_statusbar_progress_set_text;
|
||||
iface->set_value = gimp_statusbar_progress_set_value;
|
||||
iface->get_value = gimp_statusbar_progress_get_value;
|
||||
iface->pulse = gimp_statusbar_progress_pulse;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_statusbar_init (GimpStatusbar *statusbar)
|
||||
{
|
||||
|
@ -120,18 +140,25 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
|
|||
GimpUnitStore *store;
|
||||
GtkShadowType shadow_type;
|
||||
|
||||
box->spacing = 2;
|
||||
box->homogeneous = FALSE;
|
||||
statusbar->shell = NULL;
|
||||
statusbar->messages = NULL;
|
||||
statusbar->context_ids = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, NULL);
|
||||
statusbar->seq_context_id = 1;
|
||||
|
||||
statusbar->temp_context_id =
|
||||
gimp_statusbar_get_context_id (statusbar, "gimp-statusbar-temp");
|
||||
|
||||
statusbar->shell = NULL;
|
||||
statusbar->cursor_format_str[0] = '\0';
|
||||
statusbar->length_format_str[0] = '\0';
|
||||
|
||||
statusbar->progress_active = FALSE;
|
||||
|
||||
gtk_box_set_spacing (box, 1);
|
||||
box->spacing = 1;
|
||||
box->homogeneous = FALSE;
|
||||
|
||||
gtk_widget_style_get (GTK_WIDGET (statusbar),
|
||||
"shadow_type", &shadow_type,
|
||||
"shadow-type", &shadow_type,
|
||||
NULL);
|
||||
|
||||
statusbar->cursor_frame = gtk_frame_new (NULL);
|
||||
|
@ -180,11 +207,19 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
|
|||
statusbar->progressbar = gtk_progress_bar_new ();
|
||||
gtk_progress_bar_set_ellipsize (GTK_PROGRESS_BAR (statusbar->progressbar),
|
||||
PANGO_ELLIPSIZE_END);
|
||||
g_object_set (statusbar->progressbar,
|
||||
"text-xalign", 0.0,
|
||||
"text-yalign", 0.5,
|
||||
NULL);
|
||||
gtk_box_pack_start (box, statusbar->progressbar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (statusbar->progressbar);
|
||||
|
||||
GTK_PROGRESS_BAR (statusbar->progressbar)->progress.x_align = 0.0;
|
||||
GTK_PROGRESS_BAR (statusbar->progressbar)->progress.y_align = 0.5;
|
||||
g_signal_connect_after (statusbar->progressbar, "style-set",
|
||||
G_CALLBACK (gimp_statusbar_progress_style_set),
|
||||
statusbar);
|
||||
g_signal_connect_after (statusbar->progressbar, "expose-event",
|
||||
G_CALLBACK (gimp_statusbar_progress_expose),
|
||||
statusbar);
|
||||
|
||||
statusbar->cancel_button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_widget_set_sensitive (statusbar->cancel_button, FALSE);
|
||||
|
@ -206,23 +241,6 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
|
|||
*/
|
||||
|
||||
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (statusbar->progressbar), "GIMP");
|
||||
|
||||
statusbar->context_ids = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, NULL);
|
||||
statusbar->seq_context_id = 1;
|
||||
statusbar->messages = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_statusbar_progress_iface_init (GimpProgressInterface *iface)
|
||||
{
|
||||
iface->start = gimp_statusbar_progress_start;
|
||||
iface->end = gimp_statusbar_progress_end;
|
||||
iface->is_active = gimp_statusbar_progress_is_active;
|
||||
iface->set_text = gimp_statusbar_progress_set_text;
|
||||
iface->set_value = gimp_statusbar_progress_set_value;
|
||||
iface->get_value = gimp_statusbar_progress_get_value;
|
||||
iface->pulse = gimp_statusbar_progress_pulse;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -245,6 +263,9 @@ gimp_statusbar_finalize (GObject *object)
|
|||
g_hash_table_destroy (statusbar->context_ids);
|
||||
statusbar->context_ids = NULL;
|
||||
|
||||
g_free (statusbar->temp_spaces);
|
||||
statusbar->temp_spaces = NULL;
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
@ -259,7 +280,7 @@ gimp_statusbar_progress_start (GimpProgress *progress,
|
|||
{
|
||||
GtkWidget *bar = statusbar->progressbar;
|
||||
|
||||
gimp_statusbar_push (statusbar, "progress", message);
|
||||
gimp_statusbar_push (statusbar, "progress", "%s", message);
|
||||
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (bar), 0.0);
|
||||
gtk_widget_set_sensitive (statusbar->cancel_button, cancelable);
|
||||
|
||||
|
@ -309,7 +330,7 @@ gimp_statusbar_progress_set_text (GimpProgress *progress,
|
|||
{
|
||||
GtkWidget *bar = statusbar->progressbar;
|
||||
|
||||
gimp_statusbar_replace (statusbar, "progress", message);
|
||||
gimp_statusbar_replace (statusbar, "progress", "%s", message);
|
||||
|
||||
if (GTK_WIDGET_DRAWABLE (bar))
|
||||
gdk_window_process_updates (bar->window, TRUE);
|
||||
|
@ -384,10 +405,23 @@ gimp_statusbar_update (GimpStatusbar *statusbar)
|
|||
text = msg->text;
|
||||
}
|
||||
|
||||
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (statusbar->progressbar),
|
||||
text ? text : "");
|
||||
if (text && statusbar->temp_timeout_id)
|
||||
{
|
||||
gchar *temp = g_strconcat (statusbar->temp_spaces, text, NULL);
|
||||
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (statusbar->progressbar),
|
||||
temp);
|
||||
g_free (temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (statusbar->progressbar),
|
||||
text ? text : "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GtkWidget *
|
||||
gimp_statusbar_new (GimpDisplayShell *shell)
|
||||
{
|
||||
|
@ -420,23 +454,35 @@ gimp_statusbar_new (GimpDisplayShell *shell)
|
|||
void
|
||||
gimp_statusbar_push (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *message)
|
||||
const gchar *format,
|
||||
...)
|
||||
{
|
||||
GimpStatusbarMsg *msg;
|
||||
guint context_id;
|
||||
GSList *list;
|
||||
va_list args;
|
||||
gchar *message;
|
||||
|
||||
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
|
||||
g_return_if_fail (context != NULL);
|
||||
g_return_if_fail (message != NULL);
|
||||
g_return_if_fail (format != NULL);
|
||||
|
||||
va_start (args, format);
|
||||
message = g_strdup_vprintf (format, args);
|
||||
va_end (args);
|
||||
|
||||
context_id = gimp_statusbar_get_context_id (statusbar, context);
|
||||
|
||||
/* do nothing if this message is at the top of the queue already */
|
||||
msg = statusbar->messages ? statusbar->messages->data : NULL;
|
||||
if (msg &&
|
||||
msg->context_id == context_id && strcmp (msg->text, message) == 0)
|
||||
return;
|
||||
if (statusbar->messages)
|
||||
{
|
||||
msg = statusbar->messages->data;
|
||||
|
||||
if (msg->context_id == context_id && strcmp (msg->text, message) == 0)
|
||||
{
|
||||
g_free (message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (list = statusbar->messages; list; list = g_slist_next (list))
|
||||
{
|
||||
|
@ -455,9 +501,12 @@ gimp_statusbar_push (GimpStatusbar *statusbar,
|
|||
msg = g_new0 (GimpStatusbarMsg, 1);
|
||||
|
||||
msg->context_id = context_id;
|
||||
msg->text = g_strdup (message);
|
||||
msg->text = message;
|
||||
|
||||
statusbar->messages = g_slist_prepend (statusbar->messages, msg);
|
||||
if (statusbar->temp_timeout_id)
|
||||
statusbar->messages = g_slist_insert (statusbar->messages, msg, 1);
|
||||
else
|
||||
statusbar->messages = g_slist_prepend (statusbar->messages, msg);
|
||||
|
||||
gimp_statusbar_update (statusbar);
|
||||
}
|
||||
|
@ -471,7 +520,6 @@ gimp_statusbar_push_coords (GimpStatusbar *statusbar,
|
|||
gdouble y)
|
||||
{
|
||||
GimpDisplayShell *shell;
|
||||
gchar buf[CURSOR_LEN];
|
||||
|
||||
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
|
||||
g_return_if_fail (title != NULL);
|
||||
|
@ -481,11 +529,12 @@ gimp_statusbar_push_coords (GimpStatusbar *statusbar,
|
|||
|
||||
if (shell->unit == GIMP_UNIT_PIXEL)
|
||||
{
|
||||
g_snprintf (buf, sizeof (buf), statusbar->cursor_format_str,
|
||||
title,
|
||||
(gint) RINT (x),
|
||||
separator,
|
||||
(gint) RINT (y));
|
||||
gimp_statusbar_push (statusbar, context,
|
||||
statusbar->cursor_format_str,
|
||||
title,
|
||||
(gint) RINT (x),
|
||||
separator,
|
||||
(gint) RINT (y));
|
||||
}
|
||||
else /* show real world units */
|
||||
{
|
||||
|
@ -493,14 +542,13 @@ gimp_statusbar_push_coords (GimpStatusbar *statusbar,
|
|||
gdouble unit_factor = _gimp_unit_get_factor (image->gimp,
|
||||
shell->unit);
|
||||
|
||||
g_snprintf (buf, sizeof (buf), statusbar->cursor_format_str,
|
||||
title,
|
||||
x * unit_factor / image->xresolution,
|
||||
separator,
|
||||
y * unit_factor / image->yresolution);
|
||||
gimp_statusbar_push (statusbar, context,
|
||||
statusbar->cursor_format_str,
|
||||
title,
|
||||
x * unit_factor / image->xresolution,
|
||||
separator,
|
||||
y * unit_factor / image->yresolution);
|
||||
}
|
||||
|
||||
gimp_statusbar_push (statusbar, context, buf);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -511,7 +559,6 @@ gimp_statusbar_push_length (GimpStatusbar *statusbar,
|
|||
gdouble value)
|
||||
{
|
||||
GimpDisplayShell *shell;
|
||||
gchar buf[CURSOR_LEN];
|
||||
|
||||
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
|
||||
g_return_if_fail (title != NULL);
|
||||
|
@ -520,9 +567,10 @@ gimp_statusbar_push_length (GimpStatusbar *statusbar,
|
|||
|
||||
if (shell->unit == GIMP_UNIT_PIXEL)
|
||||
{
|
||||
g_snprintf (buf, sizeof (buf), statusbar->length_format_str,
|
||||
title,
|
||||
(gint) RINT (value));
|
||||
gimp_statusbar_push (statusbar, context,
|
||||
statusbar->length_format_str,
|
||||
title,
|
||||
(gint) RINT (value));
|
||||
}
|
||||
else /* show real world units */
|
||||
{
|
||||
|
@ -546,45 +594,35 @@ gimp_statusbar_push_length (GimpStatusbar *statusbar,
|
|||
break;
|
||||
}
|
||||
|
||||
g_snprintf (buf, sizeof (buf), statusbar->length_format_str,
|
||||
title,
|
||||
value * unit_factor / resolution);
|
||||
gimp_statusbar_push (statusbar, context,
|
||||
statusbar->length_format_str,
|
||||
title,
|
||||
value * unit_factor / resolution);
|
||||
}
|
||||
|
||||
gimp_statusbar_push (statusbar, context, buf);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_statusbar_replace (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *message)
|
||||
const gchar *format,
|
||||
...)
|
||||
{
|
||||
GimpStatusbarMsg *msg;
|
||||
GSList *list;
|
||||
guint context_id;
|
||||
va_list args;
|
||||
gchar *message;
|
||||
|
||||
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
|
||||
g_return_if_fail (context != NULL);
|
||||
g_return_if_fail (message != NULL);
|
||||
g_return_if_fail (format != NULL);
|
||||
|
||||
if (! statusbar->messages)
|
||||
{
|
||||
gimp_statusbar_push (statusbar, context, message);
|
||||
return;
|
||||
}
|
||||
va_start (args, format);
|
||||
message = g_strdup_vprintf (format, args);
|
||||
va_end (args);
|
||||
|
||||
context_id = gimp_statusbar_get_context_id (statusbar, context);
|
||||
|
||||
msg = statusbar->messages->data;
|
||||
|
||||
if (msg->context_id == context_id)
|
||||
{
|
||||
gimp_statusbar_pop (statusbar, context);
|
||||
gimp_statusbar_push (statusbar, context, message);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (list = statusbar->messages; list; list = g_slist_next (list))
|
||||
{
|
||||
msg = list->data;
|
||||
|
@ -592,7 +630,10 @@ gimp_statusbar_replace (GimpStatusbar *statusbar,
|
|||
if (msg->context_id == context_id)
|
||||
{
|
||||
g_free (msg->text);
|
||||
msg->text = g_strdup (message);
|
||||
msg->text = message;
|
||||
|
||||
if (list == statusbar->messages)
|
||||
gimp_statusbar_update (statusbar);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -601,9 +642,12 @@ gimp_statusbar_replace (GimpStatusbar *statusbar,
|
|||
msg = g_new0 (GimpStatusbarMsg, 1);
|
||||
|
||||
msg->context_id = context_id;
|
||||
msg->text = g_strdup (message);
|
||||
msg->text = message;
|
||||
|
||||
statusbar->messages = g_slist_prepend (statusbar->messages, msg);
|
||||
if (statusbar->temp_timeout_id)
|
||||
statusbar->messages = g_slist_insert (statusbar->messages, msg, 1);
|
||||
else
|
||||
statusbar->messages = g_slist_prepend (statusbar->messages, msg);
|
||||
|
||||
gimp_statusbar_update (statusbar);
|
||||
}
|
||||
|
@ -637,6 +681,84 @@ gimp_statusbar_pop (GimpStatusbar *statusbar,
|
|||
gimp_statusbar_update (statusbar);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_statusbar_push_temp (GimpStatusbar *statusbar,
|
||||
const gchar *format,
|
||||
...)
|
||||
{
|
||||
GimpStatusbarMsg *msg = NULL;
|
||||
va_list args;
|
||||
gchar *message;
|
||||
|
||||
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
|
||||
g_return_if_fail (format != NULL);
|
||||
|
||||
va_start (args, format);
|
||||
message = g_strdup_vprintf (format, args);
|
||||
va_end (args);
|
||||
|
||||
if (statusbar->temp_timeout_id)
|
||||
g_source_remove (statusbar->temp_timeout_id);
|
||||
|
||||
statusbar->temp_timeout_id =
|
||||
g_timeout_add (3000, (GSourceFunc) gimp_statusbar_temp_timeout, statusbar);
|
||||
|
||||
if (statusbar->messages)
|
||||
{
|
||||
msg = statusbar->messages->data;
|
||||
|
||||
if (msg->context_id == statusbar->temp_context_id)
|
||||
{
|
||||
if (strcmp (msg->text, message) == 0)
|
||||
{
|
||||
g_free (message);
|
||||
return;
|
||||
}
|
||||
|
||||
g_free (msg->text);
|
||||
msg->text = message;
|
||||
|
||||
gimp_statusbar_update (statusbar);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
msg = g_new0 (GimpStatusbarMsg, 1);
|
||||
|
||||
msg->context_id = statusbar->temp_context_id;
|
||||
msg->text = message;
|
||||
|
||||
statusbar->messages = g_slist_prepend (statusbar->messages, msg);
|
||||
|
||||
gimp_statusbar_update (statusbar);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_statusbar_pop_temp (GimpStatusbar *statusbar)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
|
||||
|
||||
if (statusbar->temp_timeout_id)
|
||||
{
|
||||
g_source_remove (statusbar->temp_timeout_id);
|
||||
statusbar->temp_timeout_id = 0;
|
||||
}
|
||||
|
||||
if (statusbar->messages)
|
||||
{
|
||||
GimpStatusbarMsg *msg = statusbar->messages->data;
|
||||
|
||||
if (msg->context_id == statusbar->temp_context_id)
|
||||
{
|
||||
statusbar->messages = g_slist_remove (statusbar->messages, msg);
|
||||
g_free (msg->text);
|
||||
g_free (msg);
|
||||
|
||||
gimp_statusbar_update (statusbar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_statusbar_set_cursor (GimpStatusbar *statusbar,
|
||||
gdouble x,
|
||||
|
@ -693,6 +815,83 @@ gimp_statusbar_clear_cursor (GimpStatusbar *statusbar)
|
|||
gtk_widget_set_sensitive (statusbar->cursor_label, TRUE);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_statusbar_progress_style_set (GtkWidget *widget,
|
||||
GtkStyle *prev_style,
|
||||
GimpStatusbar *statusbar)
|
||||
{
|
||||
PangoLayout *layout;
|
||||
GdkPixbuf *pixbuf;
|
||||
gint n_spaces = 1;
|
||||
gint layout_width;
|
||||
|
||||
layout = gtk_widget_create_pango_layout (widget, " ");
|
||||
pixbuf = gtk_widget_render_icon (widget, GIMP_STOCK_WARNING,
|
||||
GTK_ICON_SIZE_MENU, NULL);
|
||||
|
||||
pango_layout_get_pixel_size (layout, &layout_width, NULL);
|
||||
|
||||
while (layout_width < gdk_pixbuf_get_width (pixbuf) + 4)
|
||||
{
|
||||
n_spaces++;
|
||||
|
||||
statusbar->temp_spaces = g_realloc (statusbar->temp_spaces,
|
||||
n_spaces + 1);
|
||||
|
||||
memset (statusbar->temp_spaces, ' ', n_spaces);
|
||||
statusbar->temp_spaces[n_spaces + 1] = '\0';
|
||||
|
||||
pango_layout_set_text (layout, statusbar->temp_spaces, -1);
|
||||
pango_layout_get_pixel_size (layout, &layout_width, NULL);
|
||||
}
|
||||
|
||||
g_object_unref (layout);
|
||||
g_object_unref (pixbuf);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_statusbar_progress_expose (GtkWidget *widget,
|
||||
GdkEventExpose *event,
|
||||
GimpStatusbar *statusbar)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
gint text_xalign;
|
||||
gint text_yalign;
|
||||
gint x, y;
|
||||
|
||||
if (! statusbar->temp_timeout_id)
|
||||
return FALSE;
|
||||
|
||||
pixbuf = gtk_widget_render_icon (widget, GIMP_STOCK_WARNING,
|
||||
GTK_ICON_SIZE_MENU, NULL);
|
||||
|
||||
g_object_get (widget,
|
||||
"text-xalign", &text_xalign,
|
||||
"text-yalign", &text_yalign,
|
||||
NULL);
|
||||
|
||||
x = (widget->style->xthickness + 2);
|
||||
y = ((widget->allocation.height - gdk_pixbuf_get_height (pixbuf)) / 2);
|
||||
|
||||
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
|
||||
x += (widget->allocation.width - 2 * (widget->style->xthickness + 1) -
|
||||
gdk_pixbuf_get_width (pixbuf));
|
||||
|
||||
gdk_draw_pixbuf (widget->window, widget->style->black_gc,
|
||||
pixbuf,
|
||||
0, 0, x, y,
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf),
|
||||
GDK_RGB_DITHER_NORMAL, 0, 0);
|
||||
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
|
||||
GimpStatusbar *statusbar)
|
||||
|
@ -806,3 +1005,13 @@ gimp_statusbar_get_context_id (GimpStatusbar *statusbar,
|
|||
|
||||
return id;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_statusbar_temp_timeout (GimpStatusbar *statusbar)
|
||||
{
|
||||
gimp_statusbar_pop_temp (statusbar);
|
||||
|
||||
statusbar->temp_timeout_id = 0;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,10 @@ struct _GimpStatusbar
|
|||
GHashTable *context_ids;
|
||||
guint seq_context_id;
|
||||
|
||||
guint temp_context_id;
|
||||
guint temp_timeout_id;
|
||||
gchar *temp_spaces;
|
||||
|
||||
gchar cursor_format_str[CURSOR_FORMAT_LENGTH];
|
||||
gchar length_format_str[CURSOR_FORMAT_LENGTH];
|
||||
|
||||
|
@ -70,7 +74,8 @@ GtkWidget * gimp_statusbar_new (GimpDisplayShell *shell);
|
|||
|
||||
void gimp_statusbar_push (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *message);
|
||||
const gchar *format,
|
||||
...) G_GNUC_PRINTF(3,4);
|
||||
void gimp_statusbar_push_coords (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *title,
|
||||
|
@ -84,10 +89,16 @@ void gimp_statusbar_push_length (GimpStatusbar *statusbar,
|
|||
gdouble value);
|
||||
void gimp_statusbar_replace (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *message);
|
||||
const gchar *format,
|
||||
...) G_GNUC_PRINTF(3,4);
|
||||
void gimp_statusbar_pop (GimpStatusbar *statusbar,
|
||||
const gchar *context);
|
||||
|
||||
void gimp_statusbar_push_temp (GimpStatusbar *statusbar,
|
||||
const gchar *format,
|
||||
...) G_GNUC_PRINTF(2,3);
|
||||
void gimp_statusbar_pop_temp (GimpStatusbar *statusbar);
|
||||
|
||||
void gimp_statusbar_set_cursor (GimpStatusbar *statusbar,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
|
|
|
@ -618,7 +618,7 @@ gui_menu_show_tooltip (GimpUIManager *manager,
|
|||
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
|
||||
|
||||
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar), "menu-tooltip",
|
||||
tooltip);
|
||||
"%s", tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -712,7 +712,7 @@ gimp_tool_push_status (GimpTool *tool,
|
|||
|
||||
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar),
|
||||
G_OBJECT_TYPE_NAME (tool),
|
||||
message);
|
||||
"%s", message);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -768,7 +768,7 @@ gimp_tool_replace_status (GimpTool *tool,
|
|||
|
||||
gimp_statusbar_replace (GIMP_STATUSBAR (shell->statusbar),
|
||||
G_OBJECT_TYPE_NAME (tool),
|
||||
message);
|
||||
"%s", message);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue