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 1ac4b85ce0
)
This commit is contained in:
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include <gegl.h>
|
#include <gegl.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
@ -56,6 +58,7 @@ enum
|
|||||||
SNAP_OFFSETS,
|
SNAP_OFFSETS,
|
||||||
STATUS,
|
STATUS,
|
||||||
STATUS_COORDS,
|
STATUS_COORDS,
|
||||||
|
MESSAGE,
|
||||||
FOCUS_CHANGED,
|
FOCUS_CHANGED,
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
@ -173,6 +176,16 @@ gimp_tool_widget_class_init (GimpToolWidgetClass *klass)
|
|||||||
G_TYPE_DOUBLE,
|
G_TYPE_DOUBLE,
|
||||||
G_TYPE_STRING);
|
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] =
|
widget_signals[FOCUS_CHANGED] =
|
||||||
g_signal_new ("focus-changed",
|
g_signal_new ("focus-changed",
|
||||||
G_TYPE_FROM_CLASS (klass),
|
G_TYPE_FROM_CLASS (klass),
|
||||||
@ -449,6 +462,39 @@ gimp_tool_widget_set_status_coords (GimpToolWidget *widget,
|
|||||||
title, x, separator, y, help);
|
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
|
void
|
||||||
gimp_tool_widget_add_item (GimpToolWidget *widget,
|
gimp_tool_widget_add_item (GimpToolWidget *widget,
|
||||||
GimpCanvasItem *item)
|
GimpCanvasItem *item)
|
||||||
|
@ -69,6 +69,8 @@ struct _GimpToolWidgetClass
|
|||||||
const gchar *separator,
|
const gchar *separator,
|
||||||
gdouble y,
|
gdouble y,
|
||||||
const gchar *help);
|
const gchar *help);
|
||||||
|
void (* message) (GimpToolWidget *widget,
|
||||||
|
const gchar *message);
|
||||||
void (* focus_changed) (GimpToolWidget *widget);
|
void (* focus_changed) (GimpToolWidget *widget);
|
||||||
|
|
||||||
/* virtual functions */
|
/* virtual functions */
|
||||||
@ -156,6 +158,12 @@ void gimp_tool_widget_set_status_coords (GimpToolWidget *widget,
|
|||||||
gdouble y,
|
gdouble y,
|
||||||
const gchar *help);
|
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
|
/* for subclasses, to add and manage their items
|
||||||
*/
|
*/
|
||||||
void gimp_tool_widget_add_item (GimpToolWidget *widget,
|
void gimp_tool_widget_add_item (GimpToolWidget *widget,
|
||||||
|
Reference in New Issue
Block a user