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:

committed by
Michael Natterer

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>
|
2004-11-10 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* plug-ins/helpbrowser/dialog.c: use an idle handler to jump to the
|
* plug-ins/helpbrowser/dialog.c: use an idle handler to jump to the
|
||||||
|
@ -160,6 +160,7 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
|
|||||||
|
|
||||||
statusbar->shell = NULL;
|
statusbar->shell = NULL;
|
||||||
statusbar->cursor_format_str[0] = '\0';
|
statusbar->cursor_format_str[0] = '\0';
|
||||||
|
statusbar->length_format_str[0] = '\0';
|
||||||
statusbar->progress_active = FALSE;
|
statusbar->progress_active = FALSE;
|
||||||
|
|
||||||
gtk_box_set_spacing (box, 1);
|
gtk_box_set_spacing (box, 1);
|
||||||
@ -498,6 +499,57 @@ gimp_statusbar_push_coords (GimpStatusbar *statusbar,
|
|||||||
gimp_statusbar_push (statusbar, context, buf);
|
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
|
void
|
||||||
gimp_statusbar_replace (GimpStatusbar *statusbar,
|
gimp_statusbar_replace (GimpStatusbar *statusbar,
|
||||||
const gchar *context,
|
const gchar *context,
|
||||||
@ -670,6 +722,9 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
|
|||||||
g_snprintf (statusbar->cursor_format_str,
|
g_snprintf (statusbar->cursor_format_str,
|
||||||
sizeof (statusbar->cursor_format_str),
|
sizeof (statusbar->cursor_format_str),
|
||||||
"%%s%%d%%s%%d");
|
"%%s%%d%%s%%d");
|
||||||
|
g_snprintf (statusbar->length_format_str,
|
||||||
|
sizeof (statusbar->length_format_str),
|
||||||
|
"%%s%%d");
|
||||||
}
|
}
|
||||||
else /* show real world units */
|
else /* show real world units */
|
||||||
{
|
{
|
||||||
@ -678,6 +733,10 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
|
|||||||
"%%s%%.%df%%s%%.%df",
|
"%%s%%.%df%%s%%.%df",
|
||||||
_gimp_unit_get_digits (image->gimp, shell->unit),
|
_gimp_unit_get_digits (image->gimp, shell->unit),
|
||||||
_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);
|
gimp_statusbar_set_cursor (statusbar, - image->width, - image->height);
|
||||||
|
@ -46,9 +46,11 @@ struct _GimpStatusbar
|
|||||||
|
|
||||||
GimpDisplayShell *shell;
|
GimpDisplayShell *shell;
|
||||||
|
|
||||||
|
gchar cursor_format_str[CURSOR_FORMAT_LENGTH];
|
||||||
|
gchar length_format_str[CURSOR_FORMAT_LENGTH];
|
||||||
|
|
||||||
GtkWidget *cursor_frame;
|
GtkWidget *cursor_frame;
|
||||||
GtkWidget *cursor_label;
|
GtkWidget *cursor_label;
|
||||||
gchar cursor_format_str[CURSOR_FORMAT_LENGTH];
|
|
||||||
GtkWidget *unit_combo;
|
GtkWidget *unit_combo;
|
||||||
GtkWidget *scale_combo;
|
GtkWidget *scale_combo;
|
||||||
|
|
||||||
@ -75,6 +77,11 @@ void gimp_statusbar_push_coords (GimpStatusbar *statusbar,
|
|||||||
gdouble x,
|
gdouble x,
|
||||||
const gchar *separator,
|
const gchar *separator,
|
||||||
gdouble y);
|
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,
|
void gimp_statusbar_replace (GimpStatusbar *statusbar,
|
||||||
const gchar *context,
|
const gchar *context,
|
||||||
const gchar *message);
|
const gchar *message);
|
||||||
|
@ -51,6 +51,12 @@
|
|||||||
#include "gimp-intl.h"
|
#include "gimp-intl.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define SWAP_ORIENT(orient) ((orient) == GIMP_ORIENTATION_HORIZONTAL ? \
|
||||||
|
GIMP_ORIENTATION_VERTICAL : \
|
||||||
|
GIMP_ORIENTATION_HORIZONTAL)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
|
|
||||||
static void gimp_move_tool_class_init (GimpMoveToolClass *klass);
|
static void gimp_move_tool_class_init (GimpMoveToolClass *klass);
|
||||||
@ -276,8 +282,6 @@ gimp_move_tool_button_press (GimpTool *tool,
|
|||||||
FUNSCALEX (shell, snap_distance),
|
FUNSCALEX (shell, snap_distance),
|
||||||
FUNSCALEY (shell, snap_distance))))
|
FUNSCALEY (shell, snap_distance))))
|
||||||
{
|
{
|
||||||
gchar *str;
|
|
||||||
|
|
||||||
move->guide = guide;
|
move->guide = guide;
|
||||||
move->moving_guide = TRUE;
|
move->moving_guide = TRUE;
|
||||||
move->guide_position = guide->position;
|
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);
|
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
|
||||||
|
|
||||||
str = g_strdup_printf (_("Move Guide: %d"), move->guide_position);
|
gimp_tool_push_status_length (tool, _("Move Guide: "),
|
||||||
gimp_tool_push_status (tool, str);
|
SWAP_ORIENT (move->guide_orientation),
|
||||||
g_free (str);
|
move->guide_position);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -508,7 +512,6 @@ gimp_move_tool_motion (GimpTool *tool,
|
|||||||
if (move->moving_guide)
|
if (move->moving_guide)
|
||||||
{
|
{
|
||||||
gint tx, ty;
|
gint tx, ty;
|
||||||
gchar *str;
|
|
||||||
gboolean delete_guide = FALSE;
|
gboolean delete_guide = FALSE;
|
||||||
|
|
||||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
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_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
||||||
|
|
||||||
gimp_tool_pop_status (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);
|
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
|
void
|
||||||
gimp_tool_pop_status (GimpTool *tool)
|
gimp_tool_pop_status (GimpTool *tool)
|
||||||
{
|
{
|
||||||
|
@ -152,6 +152,10 @@ void gimp_tool_push_status_coords (GimpTool *tool,
|
|||||||
gdouble x,
|
gdouble x,
|
||||||
const gchar *separator,
|
const gchar *separator,
|
||||||
gdouble y);
|
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_pop_status (GimpTool *tool);
|
||||||
|
|
||||||
void gimp_tool_set_cursor (GimpTool *tool,
|
void gimp_tool_set_cursor (GimpTool *tool,
|
||||||
|
Reference in New Issue
Block a user