mirror of https://github.com/GNOME/gimp.git
disallow passing a NULL image.
2007-03-20 Michael Natterer <mitch@gimp.org> * app/widgets/gimpcursorview.[ch] (gimp_color_frame_update_cursor): disallow passing a NULL image. (gimp_color_frame_clear_cursor): new function that clears the cursor view. * app/widgets/gimpcolorframe.c (gimp_color_frame_update): if color_frame->sample_valid is FALSE, don't do any color transformations and don't construct any string because none of them is going to be used (all labels will show "n/a"). * app/display/gimpstatusbar.[ch]: renamed set_cursor() API to update_cursor(). * app/display/gimpdisplayshell-cursor.c (gimp_display_shell_update_cursor): move variables to local scopes. Follow GimpStatusbar API change. Cleanup. (gimp_display_shell_clear_cursor): ditto. Follow GimpColorFrame API change. svn path=/trunk/; revision=22153
This commit is contained in:
parent
5ba99bdacd
commit
1c233b6fb6
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
|||
2007-03-20 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/gimpcursorview.[ch] (gimp_color_frame_update_cursor):
|
||||
disallow passing a NULL image.
|
||||
|
||||
(gimp_color_frame_clear_cursor): new function that clears the
|
||||
cursor view.
|
||||
|
||||
* app/widgets/gimpcolorframe.c (gimp_color_frame_update): if
|
||||
color_frame->sample_valid is FALSE, don't do any color
|
||||
transformations and don't construct any string because none
|
||||
of them is going to be used (all labels will show "n/a").
|
||||
|
||||
* app/display/gimpstatusbar.[ch]: renamed set_cursor() API
|
||||
to update_cursor().
|
||||
|
||||
* app/display/gimpdisplayshell-cursor.c
|
||||
(gimp_display_shell_update_cursor): move variables to local
|
||||
scopes. Follow GimpStatusbar API change. Cleanup.
|
||||
|
||||
(gimp_display_shell_clear_cursor): ditto. Follow GimpColorFrame
|
||||
API change.
|
||||
|
||||
2007-03-20 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/actions/plug-in-actions.c
|
||||
|
|
|
@ -109,14 +109,10 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
|
|||
gint image_x,
|
||||
gint image_y)
|
||||
{
|
||||
GimpImage *image;
|
||||
gboolean new_cursor;
|
||||
gint t_x = -1;
|
||||
gint t_y = -1;
|
||||
|
||||
GimpDialogFactory *factory;
|
||||
GimpSessionInfo *session_info;
|
||||
GtkWidget *cursor_view = NULL;
|
||||
GimpImage *image;
|
||||
gboolean new_cursor;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
|
@ -148,24 +144,33 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
|
|||
/* use the passed image_coords for the statusbar because they are
|
||||
* possibly snapped...
|
||||
*/
|
||||
gimp_statusbar_set_cursor (GIMP_STATUSBAR (shell->statusbar),
|
||||
image_x, image_y);
|
||||
|
||||
/* ...but use the unsnapped display_coords for the info window */
|
||||
if (display_x >= 0 && display_y >= 0)
|
||||
gimp_display_shell_untransform_xy (shell, display_x, display_y,
|
||||
&t_x, &t_y, FALSE, FALSE);
|
||||
gimp_statusbar_update_cursor (GIMP_STATUSBAR (shell->statusbar),
|
||||
image_x, image_y);
|
||||
|
||||
factory = gimp_dialog_factory_from_name ("dock");
|
||||
session_info = gimp_dialog_factory_find_session_info (factory,
|
||||
"gimp-cursor-view");
|
||||
if (session_info && session_info->widget)
|
||||
cursor_view = gtk_bin_get_child (GTK_BIN (session_info->widget));
|
||||
{
|
||||
GtkWidget *cursor_view;
|
||||
|
||||
if (cursor_view)
|
||||
gimp_cursor_view_update_cursor (GIMP_CURSOR_VIEW (cursor_view),
|
||||
shell->display->image, shell->unit,
|
||||
t_x, t_y);
|
||||
cursor_view = gtk_bin_get_child (GTK_BIN (session_info->widget));
|
||||
|
||||
if (cursor_view)
|
||||
{
|
||||
gint t_x = -1;
|
||||
gint t_y = -1;
|
||||
|
||||
/* ...but use the unsnapped display_coords for the info window */
|
||||
if (display_x >= 0 && display_y >= 0)
|
||||
gimp_display_shell_untransform_xy (shell, display_x, display_y,
|
||||
&t_x, &t_y, FALSE, FALSE);
|
||||
|
||||
gimp_cursor_view_update_cursor (GIMP_CURSOR_VIEW (cursor_view),
|
||||
shell->display->image, shell->unit,
|
||||
t_x, t_y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -173,7 +178,6 @@ gimp_display_shell_clear_cursor (GimpDisplayShell *shell)
|
|||
{
|
||||
GimpDialogFactory *factory;
|
||||
GimpSessionInfo *session_info;
|
||||
GtkWidget *cursor_view = NULL;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
|
@ -183,11 +187,14 @@ gimp_display_shell_clear_cursor (GimpDisplayShell *shell)
|
|||
session_info = gimp_dialog_factory_find_session_info (factory,
|
||||
"gimp-cursor-view");
|
||||
if (session_info && session_info->widget)
|
||||
cursor_view = gtk_bin_get_child (GTK_BIN (session_info->widget));
|
||||
{
|
||||
GtkWidget *cursor_view;
|
||||
|
||||
if (cursor_view)
|
||||
gimp_cursor_view_update_cursor (GIMP_CURSOR_VIEW (cursor_view),
|
||||
NULL, GIMP_UNIT_PIXEL, 0, 0);
|
||||
cursor_view = gtk_bin_get_child (GTK_BIN (session_info->widget));
|
||||
|
||||
if (cursor_view)
|
||||
gimp_cursor_view_clear_cursor (GIMP_CURSOR_VIEW (cursor_view));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -843,9 +843,9 @@ gimp_statusbar_pop_temp (GimpStatusbar *statusbar)
|
|||
}
|
||||
|
||||
void
|
||||
gimp_statusbar_set_cursor (GimpStatusbar *statusbar,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
gimp_statusbar_update_cursor (GimpStatusbar *statusbar,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
GimpDisplayShell *shell;
|
||||
GtkTreeModel *model;
|
||||
|
@ -1034,7 +1034,7 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
|
|||
_gimp_unit_get_digits (image->gimp, shell->unit));
|
||||
}
|
||||
|
||||
gimp_statusbar_set_cursor (statusbar, - image->width, - image->height);
|
||||
gimp_statusbar_update_cursor (statusbar, -image->width, -image->height);
|
||||
|
||||
text = gtk_label_get_text (GTK_LABEL (statusbar->cursor_label));
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ void gimp_statusbar_push_temp_valist (GimpStatusbar *statusbar,
|
|||
va_list args);
|
||||
void gimp_statusbar_pop_temp (GimpStatusbar *statusbar);
|
||||
|
||||
void gimp_statusbar_set_cursor (GimpStatusbar *statusbar,
|
||||
void gimp_statusbar_update_cursor (GimpStatusbar *statusbar,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
void gimp_statusbar_clear_cursor (GimpStatusbar *statusbar);
|
||||
|
|
|
@ -402,10 +402,13 @@ gimp_color_frame_update (GimpColorFrame *frame)
|
|||
|
||||
has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (frame->sample_type);
|
||||
|
||||
gimp_rgba_get_uchar (&frame->color, &r, &g, &b, &a);
|
||||
if (frame->sample_valid)
|
||||
{
|
||||
gimp_rgba_get_uchar (&frame->color, &r, &g, &b, &a);
|
||||
|
||||
gimp_color_area_set_color (GIMP_COLOR_AREA (frame->color_area),
|
||||
&frame->color);
|
||||
gimp_color_area_set_color (GIMP_COLOR_AREA (frame->color_area),
|
||||
&frame->color);
|
||||
}
|
||||
|
||||
switch (frame->frame_mode)
|
||||
{
|
||||
|
@ -414,23 +417,31 @@ gimp_color_frame_update (GimpColorFrame *frame)
|
|||
{
|
||||
case GIMP_INDEXED:
|
||||
names[4] = _("Index:");
|
||||
values[4] = g_strdup_printf ("%d", frame->color_index);
|
||||
|
||||
if (frame->sample_valid)
|
||||
values[4] = g_strdup_printf ("%d", frame->color_index);
|
||||
/* fallthrough */
|
||||
|
||||
case GIMP_RGB:
|
||||
names[0] = _("Red:");
|
||||
names[1] = _("Green:");
|
||||
names[2] = _("Blue:");
|
||||
|
||||
values[0] = g_strdup_printf ("%d", r);
|
||||
values[1] = g_strdup_printf ("%d", g);
|
||||
values[2] = g_strdup_printf ("%d", b);
|
||||
if (frame->sample_valid)
|
||||
{
|
||||
values[0] = g_strdup_printf ("%d", r);
|
||||
values[1] = g_strdup_printf ("%d", g);
|
||||
values[2] = g_strdup_printf ("%d", b);
|
||||
}
|
||||
|
||||
alpha_row = 3;
|
||||
break;
|
||||
|
||||
case GIMP_GRAY:
|
||||
names[0] = _("Value:");
|
||||
values[0] = g_strdup_printf ("%d", r);
|
||||
|
||||
if (frame->sample_valid)
|
||||
values[0] = g_strdup_printf ("%d", r);
|
||||
|
||||
alpha_row = 1;
|
||||
break;
|
||||
|
@ -442,52 +453,59 @@ gimp_color_frame_update (GimpColorFrame *frame)
|
|||
names[1] = _("Green:");
|
||||
names[2] = _("Blue:");
|
||||
|
||||
values[0] = g_strdup_printf ("%d %%", ROUND (frame->color.r * 100.0));
|
||||
values[1] = g_strdup_printf ("%d %%", ROUND (frame->color.g * 100.0));
|
||||
values[2] = g_strdup_printf ("%d %%", ROUND (frame->color.b * 100.0));
|
||||
if (frame->sample_valid)
|
||||
{
|
||||
values[0] = g_strdup_printf ("%d %%", ROUND (frame->color.r * 100.0));
|
||||
values[1] = g_strdup_printf ("%d %%", ROUND (frame->color.g * 100.0));
|
||||
values[2] = g_strdup_printf ("%d %%", ROUND (frame->color.b * 100.0));
|
||||
}
|
||||
|
||||
alpha_row = 3;
|
||||
|
||||
names[4] = _("Hex:");
|
||||
values[4] = g_strdup_printf ("%.2x%.2x%.2x", r, g, b);
|
||||
|
||||
if (frame->sample_valid)
|
||||
values[4] = g_strdup_printf ("%.2x%.2x%.2x", r, g, b);
|
||||
break;
|
||||
|
||||
case GIMP_COLOR_FRAME_MODE_HSV:
|
||||
{
|
||||
GimpHSV hsv;
|
||||
names[0] = _("Hue:");
|
||||
names[1] = _("Sat.:");
|
||||
names[2] = _("Value:");
|
||||
|
||||
gimp_rgb_to_hsv (&frame->color, &hsv);
|
||||
if (frame->sample_valid)
|
||||
{
|
||||
GimpHSV hsv;
|
||||
|
||||
names[0] = _("Hue:");
|
||||
names[1] = _("Sat.:");
|
||||
names[2] = _("Value:");
|
||||
gimp_rgb_to_hsv (&frame->color, &hsv);
|
||||
|
||||
values[0] = g_strdup_printf ("%d \302\260", ROUND (hsv.h * 360.0));
|
||||
values[1] = g_strdup_printf ("%d %%", ROUND (hsv.s * 100.0));
|
||||
values[2] = g_strdup_printf ("%d %%", ROUND (hsv.v * 100.0));
|
||||
values[0] = g_strdup_printf ("%d \302\260", ROUND (hsv.h * 360.0));
|
||||
values[1] = g_strdup_printf ("%d %%", ROUND (hsv.s * 100.0));
|
||||
values[2] = g_strdup_printf ("%d %%", ROUND (hsv.v * 100.0));
|
||||
}
|
||||
|
||||
alpha_row = 3;
|
||||
}
|
||||
alpha_row = 3;
|
||||
break;
|
||||
|
||||
case GIMP_COLOR_FRAME_MODE_CMYK:
|
||||
{
|
||||
GimpCMYK cmyk;
|
||||
names[0] = _("Cyan:");
|
||||
names[1] = _("Magenta:");
|
||||
names[2] = _("Yellow:");
|
||||
names[3] = _("Black:");
|
||||
|
||||
gimp_rgb_to_cmyk (&frame->color, 1.0, &cmyk);
|
||||
if (frame->sample_valid)
|
||||
{
|
||||
GimpCMYK cmyk;
|
||||
|
||||
names[0] = _("Cyan:");
|
||||
names[1] = _("Magenta:");
|
||||
names[2] = _("Yellow:");
|
||||
names[3] = _("Black:");
|
||||
gimp_rgb_to_cmyk (&frame->color, 1.0, &cmyk);
|
||||
|
||||
values[0] = g_strdup_printf ("%d %%", ROUND (cmyk.c * 100.0));
|
||||
values[1] = g_strdup_printf ("%d %%", ROUND (cmyk.m * 100.0));
|
||||
values[2] = g_strdup_printf ("%d %%", ROUND (cmyk.y * 100.0));
|
||||
values[3] = g_strdup_printf ("%d %%", ROUND (cmyk.k * 100.0));
|
||||
values[0] = g_strdup_printf ("%d %%", ROUND (cmyk.c * 100.0));
|
||||
values[1] = g_strdup_printf ("%d %%", ROUND (cmyk.m * 100.0));
|
||||
values[2] = g_strdup_printf ("%d %%", ROUND (cmyk.y * 100.0));
|
||||
values[3] = g_strdup_printf ("%d %%", ROUND (cmyk.k * 100.0));
|
||||
}
|
||||
|
||||
alpha_row = 4;
|
||||
}
|
||||
alpha_row = 4;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -495,16 +513,19 @@ gimp_color_frame_update (GimpColorFrame *frame)
|
|||
{
|
||||
names[alpha_row] = _("Alpha:");
|
||||
|
||||
if (frame->frame_mode == GIMP_COLOR_FRAME_MODE_PIXEL)
|
||||
values[alpha_row] = g_strdup_printf ("%d", a);
|
||||
else
|
||||
values[alpha_row] = g_strdup_printf ("%d %%",
|
||||
(gint) (frame->color.a * 100.0));
|
||||
if (frame->sample_valid)
|
||||
{
|
||||
if (frame->frame_mode == GIMP_COLOR_FRAME_MODE_PIXEL)
|
||||
values[alpha_row] = g_strdup_printf ("%d", a);
|
||||
else
|
||||
values[alpha_row] = g_strdup_printf ("%d %%",
|
||||
(gint) (frame->color.a * 100.0));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < GIMP_COLOR_FRAME_ROWS; i++)
|
||||
{
|
||||
if (names[i] && values[i])
|
||||
if (names[i])
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (frame->name_labels[i]), names[i]);
|
||||
|
||||
|
|
|
@ -367,7 +367,6 @@ gimp_cursor_view_get_sample_merged (GimpCursorView *view)
|
|||
return view->sample_merged;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_cursor_view_update_cursor (GimpCursorView *view,
|
||||
GimpImage *image,
|
||||
|
@ -375,65 +374,54 @@ gimp_cursor_view_update_cursor (GimpCursorView *view,
|
|||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
gboolean in_image;
|
||||
gdouble unit_factor;
|
||||
gint unit_digits;
|
||||
const gchar *unit_str;
|
||||
gchar format_buf[32];
|
||||
gchar buf[32];
|
||||
GimpImageType sample_type;
|
||||
GimpRGB color;
|
||||
gint color_index;
|
||||
|
||||
g_return_if_fail (GIMP_IS_CURSOR_VIEW (view));
|
||||
g_return_if_fail (image == NULL || GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
|
||||
if (image && unit == GIMP_UNIT_PIXEL)
|
||||
if (unit == GIMP_UNIT_PIXEL)
|
||||
unit = gimp_image_get_unit (image);
|
||||
|
||||
if (image)
|
||||
{
|
||||
gboolean in_image;
|
||||
gdouble unit_factor;
|
||||
gint unit_digits;
|
||||
const gchar *unit_str;
|
||||
gchar format_buf[32];
|
||||
gchar buf[32];
|
||||
in_image = (x >= 0.0 && x < gimp_image_get_width (image) &&
|
||||
y >= 0.0 && y < gimp_image_get_height (image));
|
||||
|
||||
in_image = (x >= 0.0 && x < gimp_image_get_width (image) &&
|
||||
y >= 0.0 && y < gimp_image_get_height (image));
|
||||
|
||||
unit_factor = _gimp_unit_get_factor (image->gimp, unit);
|
||||
unit_digits = _gimp_unit_get_digits (image->gimp, unit);
|
||||
unit_str = _gimp_unit_get_abbreviation (image->gimp, unit);
|
||||
unit_factor = _gimp_unit_get_factor (image->gimp, unit);
|
||||
unit_digits = _gimp_unit_get_digits (image->gimp, unit);
|
||||
unit_str = _gimp_unit_get_abbreviation (image->gimp, unit);
|
||||
|
||||
#define FORMAT_STRING(s) (in_image ? (s) : "("s")")
|
||||
|
||||
g_snprintf (buf, sizeof (buf), FORMAT_STRING ("%d"), (gint) floor (x));
|
||||
gtk_label_set_text (GTK_LABEL (view->pixel_x_label), buf);
|
||||
g_snprintf (buf, sizeof (buf), FORMAT_STRING ("%d"), (gint) floor (x));
|
||||
gtk_label_set_text (GTK_LABEL (view->pixel_x_label), buf);
|
||||
|
||||
g_snprintf (buf, sizeof (buf), FORMAT_STRING ("%d"), (gint) floor (y));
|
||||
gtk_label_set_text (GTK_LABEL (view->pixel_y_label), buf);
|
||||
g_snprintf (buf, sizeof (buf), FORMAT_STRING ("%d"), (gint) floor (y));
|
||||
gtk_label_set_text (GTK_LABEL (view->pixel_y_label), buf);
|
||||
|
||||
g_snprintf (format_buf, sizeof (format_buf),
|
||||
FORMAT_STRING ("%%.%df %s"), unit_digits, unit_str);
|
||||
g_snprintf (format_buf, sizeof (format_buf),
|
||||
FORMAT_STRING ("%%.%df %s"), unit_digits, unit_str);
|
||||
|
||||
g_snprintf (buf, sizeof (buf), format_buf,
|
||||
x * unit_factor / image->xresolution);
|
||||
gtk_label_set_text (GTK_LABEL (view->unit_x_label), buf);
|
||||
g_snprintf (buf, sizeof (buf), format_buf,
|
||||
x * unit_factor / image->xresolution);
|
||||
gtk_label_set_text (GTK_LABEL (view->unit_x_label), buf);
|
||||
|
||||
g_snprintf (buf, sizeof (buf), format_buf,
|
||||
y * unit_factor / image->yresolution);
|
||||
gtk_label_set_text (GTK_LABEL (view->unit_y_label), buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (view->pixel_x_label), _("n/a"));
|
||||
gtk_label_set_text (GTK_LABEL (view->pixel_y_label), _("n/a"));
|
||||
gtk_label_set_text (GTK_LABEL (view->unit_x_label), _("n/a"));
|
||||
gtk_label_set_text (GTK_LABEL (view->unit_y_label), _("n/a"));
|
||||
}
|
||||
g_snprintf (buf, sizeof (buf), format_buf,
|
||||
y * unit_factor / image->yresolution);
|
||||
gtk_label_set_text (GTK_LABEL (view->unit_y_label), buf);
|
||||
|
||||
if (image && gimp_image_pick_color (image, NULL,
|
||||
(gint) floor (x),
|
||||
(gint) floor (y),
|
||||
view->sample_merged,
|
||||
FALSE, 0.0,
|
||||
&sample_type, &color, &color_index))
|
||||
if (gimp_image_pick_color (image, NULL,
|
||||
(gint) floor (x),
|
||||
(gint) floor (y),
|
||||
view->sample_merged,
|
||||
FALSE, 0.0,
|
||||
&sample_type, &color, &color_index))
|
||||
{
|
||||
gimp_color_frame_set_color (GIMP_COLOR_FRAME (view->color_frame_1),
|
||||
sample_type, &color, color_index);
|
||||
|
@ -446,3 +434,17 @@ gimp_cursor_view_update_cursor (GimpCursorView *view,
|
|||
gimp_color_frame_set_invalid (GIMP_COLOR_FRAME (view->color_frame_2));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_cursor_view_clear_cursor (GimpCursorView *view)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_CURSOR_VIEW (view));
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (view->pixel_x_label), _("n/a"));
|
||||
gtk_label_set_text (GTK_LABEL (view->pixel_y_label), _("n/a"));
|
||||
gtk_label_set_text (GTK_LABEL (view->unit_x_label), _("n/a"));
|
||||
gtk_label_set_text (GTK_LABEL (view->unit_y_label), _("n/a"));
|
||||
|
||||
gimp_color_frame_set_invalid (GIMP_COLOR_FRAME (view->color_frame_1));
|
||||
gimp_color_frame_set_invalid (GIMP_COLOR_FRAME (view->color_frame_2));
|
||||
}
|
||||
|
|
|
@ -72,5 +72,7 @@ void gimp_cursor_view_update_cursor (GimpCursorView *view,
|
|||
GimpUnit unit,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
void gimp_cursor_view_clear_cursor (GimpCursorView *view);
|
||||
|
||||
|
||||
#endif /* __GIMP_CURSOR_VIEW_H__ */
|
||||
|
|
Loading…
Reference in New Issue