mirror of https://github.com/GNOME/gimp.git
added new function gimp_statusbar_push_length(), which works exactly like
2004-11-10 Michael Natterer <mitch@gimp.org> * app/display/gimpstatusbar.[ch]: added new function gimp_statusbar_push_length(), which works exactly like push_coords() but takes only one value plus a GimpOrientationType for specifying the value's axis. * app/tools/gimptool.[ch]: added the corresponding gimp_tool_push_status_length(). * app/tools/gimpmovetool.c: use gimp_tool_push_status_length() so the guide position is shown in the selected display unit. Cleaned up the status message code a bit.
This commit is contained in:
parent
390d49dfdf
commit
04a7e8585b
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2004-11-10 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/display/gimpstatusbar.[ch]: added new function
|
||||
gimp_statusbar_push_length(), which works exactly like
|
||||
push_coords() but takes only one value plus a GimpOrientationType
|
||||
for specifying the value's axis.
|
||||
|
||||
* app/tools/gimptool.[ch]: added the corresponding
|
||||
gimp_tool_push_status_length().
|
||||
|
||||
* app/tools/gimpmovetool.c: use gimp_tool_push_status_length()
|
||||
so the guide position is shown in the selected display unit.
|
||||
Cleaned up the status message code a bit.
|
||||
|
||||
2004-11-10 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/helpbrowser/dialog.c: use an idle handler to jump to the
|
||||
|
|
|
@ -158,9 +158,10 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
|
|||
box->spacing = 2;
|
||||
box->homogeneous = FALSE;
|
||||
|
||||
statusbar->shell = NULL;
|
||||
statusbar->cursor_format_str[0] = '\0';
|
||||
statusbar->progress_active = FALSE;
|
||||
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);
|
||||
|
||||
|
@ -468,7 +469,7 @@ gimp_statusbar_push_coords (GimpStatusbar *statusbar,
|
|||
GimpDisplayShell *shell;
|
||||
gchar buf[CURSOR_LEN];
|
||||
|
||||
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
|
||||
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
|
||||
g_return_if_fail (title != NULL);
|
||||
g_return_if_fail (separator != NULL);
|
||||
|
||||
|
@ -498,6 +499,57 @@ gimp_statusbar_push_coords (GimpStatusbar *statusbar,
|
|||
gimp_statusbar_push (statusbar, context, buf);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_statusbar_push_length (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *title,
|
||||
GimpOrientationType axis,
|
||||
gdouble value)
|
||||
{
|
||||
GimpDisplayShell *shell;
|
||||
gchar buf[CURSOR_LEN];
|
||||
|
||||
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
|
||||
g_return_if_fail (title != NULL);
|
||||
|
||||
shell = statusbar->shell;
|
||||
|
||||
if (shell->unit == GIMP_UNIT_PIXEL)
|
||||
{
|
||||
g_snprintf (buf, sizeof (buf), statusbar->length_format_str,
|
||||
title,
|
||||
ROUND (value));
|
||||
}
|
||||
else /* show real world units */
|
||||
{
|
||||
GimpImage *image = shell->gdisp->gimage;
|
||||
gdouble resolution;
|
||||
gdouble unit_factor = _gimp_unit_get_factor (image->gimp,
|
||||
shell->unit);
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case GIMP_ORIENTATION_HORIZONTAL:
|
||||
resolution = image->xresolution;
|
||||
break;
|
||||
|
||||
case GIMP_ORIENTATION_VERTICAL:
|
||||
resolution = image->yresolution;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_return_if_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
g_snprintf (buf, sizeof (buf), statusbar->length_format_str,
|
||||
title,
|
||||
value * unit_factor / resolution);
|
||||
}
|
||||
|
||||
gimp_statusbar_push (statusbar, context, buf);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_statusbar_replace (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
|
@ -670,6 +722,9 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
|
|||
g_snprintf (statusbar->cursor_format_str,
|
||||
sizeof (statusbar->cursor_format_str),
|
||||
"%%s%%d%%s%%d");
|
||||
g_snprintf (statusbar->length_format_str,
|
||||
sizeof (statusbar->length_format_str),
|
||||
"%%s%%d");
|
||||
}
|
||||
else /* show real world units */
|
||||
{
|
||||
|
@ -678,6 +733,10 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
|
|||
"%%s%%.%df%%s%%.%df",
|
||||
_gimp_unit_get_digits (image->gimp, shell->unit),
|
||||
_gimp_unit_get_digits (image->gimp, shell->unit));
|
||||
g_snprintf (statusbar->length_format_str,
|
||||
sizeof (statusbar->length_format_str),
|
||||
"%%s%%.%df",
|
||||
_gimp_unit_get_digits (image->gimp, shell->unit));
|
||||
}
|
||||
|
||||
gimp_statusbar_set_cursor (statusbar, - image->width, - image->height);
|
||||
|
|
|
@ -46,9 +46,11 @@ struct _GimpStatusbar
|
|||
|
||||
GimpDisplayShell *shell;
|
||||
|
||||
gchar cursor_format_str[CURSOR_FORMAT_LENGTH];
|
||||
gchar length_format_str[CURSOR_FORMAT_LENGTH];
|
||||
|
||||
GtkWidget *cursor_frame;
|
||||
GtkWidget *cursor_label;
|
||||
gchar cursor_format_str[CURSOR_FORMAT_LENGTH];
|
||||
GtkWidget *unit_combo;
|
||||
GtkWidget *scale_combo;
|
||||
|
||||
|
@ -64,27 +66,32 @@ struct _GimpStatusbarClass
|
|||
|
||||
|
||||
GType gimp_statusbar_get_type (void) G_GNUC_CONST;
|
||||
GtkWidget * gimp_statusbar_new (GimpDisplayShell *shell);
|
||||
GtkWidget * gimp_statusbar_new (GimpDisplayShell *shell);
|
||||
|
||||
void gimp_statusbar_push (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *message);
|
||||
void gimp_statusbar_push_coords (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *title,
|
||||
gdouble x,
|
||||
const gchar *separator,
|
||||
gdouble y);
|
||||
void gimp_statusbar_replace (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *message);
|
||||
void gimp_statusbar_pop (GimpStatusbar *statusbar,
|
||||
const gchar *context);
|
||||
void gimp_statusbar_push (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *message);
|
||||
void gimp_statusbar_push_coords (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *title,
|
||||
gdouble x,
|
||||
const gchar *separator,
|
||||
gdouble y);
|
||||
void gimp_statusbar_push_length (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *title,
|
||||
GimpOrientationType axis,
|
||||
gdouble value);
|
||||
void gimp_statusbar_replace (GimpStatusbar *statusbar,
|
||||
const gchar *context,
|
||||
const gchar *message);
|
||||
void gimp_statusbar_pop (GimpStatusbar *statusbar,
|
||||
const gchar *context);
|
||||
|
||||
void gimp_statusbar_set_cursor (GimpStatusbar *statusbar,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
void gimp_statusbar_clear_cursor (GimpStatusbar *statusbar);
|
||||
void gimp_statusbar_set_cursor (GimpStatusbar *statusbar,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
void gimp_statusbar_clear_cursor (GimpStatusbar *statusbar);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -51,6 +51,12 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define SWAP_ORIENT(orient) ((orient) == GIMP_ORIENTATION_HORIZONTAL ? \
|
||||
GIMP_ORIENTATION_VERTICAL : \
|
||||
GIMP_ORIENTATION_HORIZONTAL)
|
||||
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_move_tool_class_init (GimpMoveToolClass *klass);
|
||||
|
@ -276,8 +282,6 @@ gimp_move_tool_button_press (GimpTool *tool,
|
|||
FUNSCALEX (shell, snap_distance),
|
||||
FUNSCALEY (shell, snap_distance))))
|
||||
{
|
||||
gchar *str;
|
||||
|
||||
move->guide = guide;
|
||||
move->moving_guide = TRUE;
|
||||
move->guide_position = guide->position;
|
||||
|
@ -291,9 +295,9 @@ gimp_move_tool_button_press (GimpTool *tool,
|
|||
|
||||
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
|
||||
|
||||
str = g_strdup_printf (_("Move Guide: %d"), move->guide_position);
|
||||
gimp_tool_push_status (tool, str);
|
||||
g_free (str);
|
||||
gimp_tool_push_status_length (tool, _("Move Guide: "),
|
||||
SWAP_ORIENT (move->guide_orientation),
|
||||
move->guide_position);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -508,7 +512,6 @@ gimp_move_tool_motion (GimpTool *tool,
|
|||
if (move->moving_guide)
|
||||
{
|
||||
gint tx, ty;
|
||||
gchar *str;
|
||||
gboolean delete_guide = FALSE;
|
||||
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
||||
|
@ -556,26 +559,24 @@ gimp_move_tool_motion (GimpTool *tool,
|
|||
}
|
||||
}
|
||||
|
||||
if (delete_guide)
|
||||
{
|
||||
if (move->guide)
|
||||
str = g_strdup (_("Delete Guide"));
|
||||
else
|
||||
str = g_strdup (_("Cancel Guide"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (move->guide)
|
||||
str = g_strdup_printf (_("Move Guide: %d"), move->guide_position);
|
||||
else
|
||||
str = g_strdup_printf (_("Add Guide: %d"), move->guide_position);
|
||||
}
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
||||
|
||||
gimp_tool_pop_status (tool);
|
||||
gimp_tool_push_status (tool, str);
|
||||
g_free (str);
|
||||
|
||||
if (delete_guide)
|
||||
{
|
||||
gimp_tool_push_status (tool,
|
||||
move->guide ?
|
||||
_("Remove Guide") : _("Cancel Guide"));
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_tool_push_status_length (tool,
|
||||
move->guide ?
|
||||
_("Move Guide: ") : _("Add Guide: "),
|
||||
SWAP_ORIENT (move->guide_orientation),
|
||||
move->guide_position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -571,6 +571,25 @@ gimp_tool_push_status_coords (GimpTool *tool,
|
|||
title, x, separator, y);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_tool_push_status_length (GimpTool *tool,
|
||||
const gchar *title,
|
||||
GimpOrientationType axis,
|
||||
gdouble value)
|
||||
{
|
||||
GimpStatusbar *statusbar;
|
||||
|
||||
g_return_if_fail (GIMP_IS_TOOL (tool));
|
||||
g_return_if_fail (GIMP_IS_DISPLAY (tool->gdisp));
|
||||
g_return_if_fail (title != NULL);
|
||||
|
||||
statusbar =
|
||||
GIMP_STATUSBAR (GIMP_DISPLAY_SHELL (tool->gdisp->shell)->statusbar);
|
||||
|
||||
gimp_statusbar_push_length (statusbar, G_OBJECT_TYPE_NAME (tool),
|
||||
title, axis, value);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_tool_pop_status (GimpTool *tool)
|
||||
{
|
||||
|
|
|
@ -104,61 +104,65 @@ struct _GimpToolClass
|
|||
|
||||
GType gimp_tool_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_tool_initialize (GimpTool *tool,
|
||||
GimpDisplay *gdisp);
|
||||
void gimp_tool_control (GimpTool *tool,
|
||||
GimpToolAction action,
|
||||
GimpDisplay *gdisp);
|
||||
gboolean gimp_tool_initialize (GimpTool *tool,
|
||||
GimpDisplay *gdisp);
|
||||
void gimp_tool_control (GimpTool *tool,
|
||||
GimpToolAction action,
|
||||
GimpDisplay *gdisp);
|
||||
|
||||
void gimp_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
void gimp_tool_button_release (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
void gimp_tool_motion (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
void gimp_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
void gimp_tool_button_release (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
void gimp_tool_motion (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
|
||||
gboolean gimp_tool_key_press (GimpTool *tool,
|
||||
GdkEventKey *kevent,
|
||||
GimpDisplay *gdisp);
|
||||
gboolean gimp_tool_key_press (GimpTool *tool,
|
||||
GdkEventKey *kevent,
|
||||
GimpDisplay *gdisp);
|
||||
|
||||
void gimp_tool_set_focus_display (GimpTool *tool,
|
||||
GimpDisplay *gdisp);
|
||||
void gimp_tool_set_modifier_state (GimpTool *tool,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
void gimp_tool_set_focus_display (GimpTool *tool,
|
||||
GimpDisplay *gdisp);
|
||||
void gimp_tool_set_modifier_state (GimpTool *tool,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
|
||||
void gimp_tool_oper_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
void gimp_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
void gimp_tool_oper_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
void gimp_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
|
||||
void gimp_tool_push_status (GimpTool *tool,
|
||||
const gchar *message);
|
||||
void gimp_tool_push_status_coords (GimpTool *tool,
|
||||
const gchar *title,
|
||||
gdouble x,
|
||||
const gchar *separator,
|
||||
gdouble y);
|
||||
void gimp_tool_pop_status (GimpTool *tool);
|
||||
void gimp_tool_push_status (GimpTool *tool,
|
||||
const gchar *message);
|
||||
void gimp_tool_push_status_coords (GimpTool *tool,
|
||||
const gchar *title,
|
||||
gdouble x,
|
||||
const gchar *separator,
|
||||
gdouble y);
|
||||
void gimp_tool_push_status_length (GimpTool *tool,
|
||||
const gchar *title,
|
||||
GimpOrientationType axis,
|
||||
gdouble value);
|
||||
void gimp_tool_pop_status (GimpTool *tool);
|
||||
|
||||
void gimp_tool_set_cursor (GimpTool *tool,
|
||||
GimpDisplay *gdisp,
|
||||
GimpCursorType cursor,
|
||||
GimpToolCursorType tool_cursor,
|
||||
GimpCursorModifier modifier);
|
||||
void gimp_tool_set_cursor (GimpTool *tool,
|
||||
GimpDisplay *gdisp,
|
||||
GimpCursorType cursor,
|
||||
GimpToolCursorType tool_cursor,
|
||||
GimpCursorModifier modifier);
|
||||
|
||||
|
||||
#endif /* __GIMP_TOOL_H__ */
|
||||
|
|
Loading…
Reference in New Issue