Commit 38c74c28 authored by Ell's avatar Ell

app: add gimp_tool_widget_message[_literal]()

Add a GimpToolWidget::message signal, which can be emitted by tool
widgets to display a message, instead of using the ::status signal.

Add corresponding gimp_tool_widget_message[_literal]() functions.

(cherry picked from commit 1ac4b85c)
parent 10f22753
......@@ -20,6 +20,8 @@
#include "config.h"
#include <stdarg.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
......@@ -56,6 +58,7 @@ enum
SNAP_OFFSETS,
STATUS,
STATUS_COORDS,
MESSAGE,
FOCUS_CHANGED,
LAST_SIGNAL
};
......@@ -173,6 +176,16 @@ gimp_tool_widget_class_init (GimpToolWidgetClass *klass)
G_TYPE_DOUBLE,
G_TYPE_STRING);
widget_signals[MESSAGE] =
g_signal_new ("message",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpToolWidgetClass, message),
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
widget_signals[FOCUS_CHANGED] =
g_signal_new ("focus-changed",
G_TYPE_FROM_CLASS (klass),
......@@ -449,6 +462,39 @@ gimp_tool_widget_set_status_coords (GimpToolWidget *widget,
title, x, separator, y, help);
}
void
gimp_tool_widget_message (GimpToolWidget *widget,
const gchar *format,
...)
{
va_list args;
gchar *message;
g_return_if_fail (GIMP_IS_TOOL_WIDGET (widget));
g_return_if_fail (format != NULL);
va_start (args, format);
message = g_strdup_vprintf (format, args);
va_end (args);
gimp_tool_widget_message_literal (widget, message);
g_free (message);
}
void
gimp_tool_widget_message_literal (GimpToolWidget *widget,
const gchar *message)
{
g_return_if_fail (GIMP_IS_TOOL_WIDGET (widget));
g_return_if_fail (message != NULL);
g_signal_emit (widget, widget_signals[MESSAGE], 0,
message);
}
void
gimp_tool_widget_add_item (GimpToolWidget *widget,
GimpCanvasItem *item)
......
......@@ -69,6 +69,8 @@ struct _GimpToolWidgetClass
const gchar *separator,
gdouble y,
const gchar *help);
void (* message) (GimpToolWidget *widget,
const gchar *message);
void (* focus_changed) (GimpToolWidget *widget);
/* virtual functions */
......@@ -156,6 +158,12 @@ void gimp_tool_widget_set_status_coords (GimpToolWidget *widget,
gdouble y,
const gchar *help);
void gimp_tool_widget_message (GimpToolWidget *widget,
const gchar *format,
...) G_GNUC_PRINTF (2, 3);
void gimp_tool_widget_message_literal (GimpToolWidget *widget,
const gchar *message);
/* for subclasses, to add and manage their items
*/
void gimp_tool_widget_add_item (GimpToolWidget *widget,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment