app/widgets/gimphistogramview.c cleanup.
2005-07-14 Michael Natterer <mitch@gimp.org> * app/widgets/gimphistogramview.c * app/widgets/gimpnavigationview.c: cleanup.
This commit is contained in:

committed by
Michael Natterer

parent
d280c77f3f
commit
8d856ef5de
@ -1,3 +1,8 @@
|
|||||||
|
2005-07-14 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
|
* app/widgets/gimphistogramview.c
|
||||||
|
* app/widgets/gimpnavigationview.c: cleanup.
|
||||||
|
|
||||||
2005-07-14 Michael Natterer <mitch@gimp.org>
|
2005-07-14 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
* app/widgets/gimppaletteview.[ch]: added "entry-clicked" and
|
* app/widgets/gimppaletteview.[ch]: added "entry-clicked" and
|
||||||
|
@ -119,14 +119,11 @@ gimp_histogram_view_get_type (void)
|
|||||||
static void
|
static void
|
||||||
gimp_histogram_view_class_init (GimpHistogramViewClass *klass)
|
gimp_histogram_view_class_init (GimpHistogramViewClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class;
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
GtkWidgetClass *widget_class;
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
|
|
||||||
parent_class = g_type_class_peek_parent (klass);
|
parent_class = g_type_class_peek_parent (klass);
|
||||||
|
|
||||||
object_class = G_OBJECT_CLASS (klass);
|
|
||||||
widget_class = GTK_WIDGET_CLASS (klass);
|
|
||||||
|
|
||||||
histogram_view_signals[RANGE_CHANGED] =
|
histogram_view_signals[RANGE_CHANGED] =
|
||||||
g_signal_new ("range-changed",
|
g_signal_new ("range-changed",
|
||||||
G_TYPE_FROM_CLASS (klass),
|
G_TYPE_FROM_CLASS (klass),
|
||||||
@ -150,14 +147,16 @@ gimp_histogram_view_class_init (GimpHistogramViewClass *klass)
|
|||||||
klass->range_changed = NULL;
|
klass->range_changed = NULL;
|
||||||
|
|
||||||
g_object_class_install_property (object_class, PROP_CHANNEL,
|
g_object_class_install_property (object_class, PROP_CHANNEL,
|
||||||
g_param_spec_enum ("histogram-channel", NULL, NULL,
|
g_param_spec_enum ("histogram-channel",
|
||||||
|
NULL, NULL,
|
||||||
GIMP_TYPE_HISTOGRAM_CHANNEL,
|
GIMP_TYPE_HISTOGRAM_CHANNEL,
|
||||||
GIMP_HISTOGRAM_VALUE,
|
GIMP_HISTOGRAM_VALUE,
|
||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE |
|
||||||
G_PARAM_CONSTRUCT));
|
G_PARAM_CONSTRUCT));
|
||||||
|
|
||||||
g_object_class_install_property (object_class, PROP_SCALE,
|
g_object_class_install_property (object_class, PROP_SCALE,
|
||||||
g_param_spec_enum ("histogram-scale", NULL, NULL,
|
g_param_spec_enum ("histogram-scale",
|
||||||
|
NULL, NULL,
|
||||||
GIMP_TYPE_HISTOGRAM_SCALE,
|
GIMP_TYPE_HISTOGRAM_SCALE,
|
||||||
GIMP_HISTOGRAM_SCALE_LINEAR,
|
GIMP_HISTOGRAM_SCALE_LINEAR,
|
||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE |
|
||||||
|
@ -111,9 +111,7 @@ gimp_navigation_view_get_type (void)
|
|||||||
static void
|
static void
|
||||||
gimp_navigation_view_class_init (GimpNavigationViewClass *klass)
|
gimp_navigation_view_class_init (GimpNavigationViewClass *klass)
|
||||||
{
|
{
|
||||||
GtkWidgetClass *widget_class;
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
|
|
||||||
widget_class = GTK_WIDGET_CLASS (klass);
|
|
||||||
|
|
||||||
parent_class = g_type_class_peek_parent (klass);
|
parent_class = g_type_class_peek_parent (klass);
|
||||||
|
|
||||||
@ -189,8 +187,7 @@ gimp_navigation_view_realize (GtkWidget *widget)
|
|||||||
{
|
{
|
||||||
GimpNavigationView *nav_view = GIMP_NAVIGATION_VIEW (widget);
|
GimpNavigationView *nav_view = GIMP_NAVIGATION_VIEW (widget);
|
||||||
|
|
||||||
if (GTK_WIDGET_CLASS (parent_class)->realize)
|
GTK_WIDGET_CLASS (parent_class)->realize (widget);
|
||||||
GTK_WIDGET_CLASS (parent_class)->realize (widget);
|
|
||||||
|
|
||||||
nav_view->gc = gdk_gc_new (widget->window);
|
nav_view->gc = gdk_gc_new (widget->window);
|
||||||
|
|
||||||
@ -211,16 +208,14 @@ gimp_navigation_view_unrealize (GtkWidget *widget)
|
|||||||
nav_view->gc = NULL;
|
nav_view->gc = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GTK_WIDGET_CLASS (parent_class)->unrealize)
|
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
|
||||||
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_navigation_view_size_allocate (GtkWidget *widget,
|
gimp_navigation_view_size_allocate (GtkWidget *widget,
|
||||||
GtkAllocation *allocation)
|
GtkAllocation *allocation)
|
||||||
{
|
{
|
||||||
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
|
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
|
||||||
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
|
|
||||||
|
|
||||||
if (GIMP_VIEW (widget)->renderer->viewable)
|
if (GIMP_VIEW (widget)->renderer->viewable)
|
||||||
gimp_navigation_view_transform (GIMP_NAVIGATION_VIEW (widget));
|
gimp_navigation_view_transform (GIMP_NAVIGATION_VIEW (widget));
|
||||||
@ -232,8 +227,7 @@ gimp_navigation_view_expose (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
if (GTK_WIDGET_DRAWABLE (widget))
|
if (GTK_WIDGET_DRAWABLE (widget))
|
||||||
{
|
{
|
||||||
if (GTK_WIDGET_CLASS (parent_class)->expose_event)
|
GTK_WIDGET_CLASS (parent_class)->expose_event (widget, eevent);
|
||||||
GTK_WIDGET_CLASS (parent_class)->expose_event (widget, eevent);
|
|
||||||
|
|
||||||
gimp_navigation_view_draw_marker (GIMP_NAVIGATION_VIEW (widget),
|
gimp_navigation_view_draw_marker (GIMP_NAVIGATION_VIEW (widget),
|
||||||
&eevent->area);
|
&eevent->area);
|
||||||
@ -247,12 +241,10 @@ gimp_navigation_view_move_to (GimpNavigationView *nav_view,
|
|||||||
gint tx,
|
gint tx,
|
||||||
gint ty)
|
gint ty)
|
||||||
{
|
{
|
||||||
GimpView *view;
|
GimpView *view = GIMP_VIEW (nav_view);
|
||||||
GimpImage *gimage;
|
GimpImage *image;
|
||||||
gdouble ratiox, ratioy;
|
gdouble ratiox, ratioy;
|
||||||
gdouble x, y;
|
gdouble x, y;
|
||||||
|
|
||||||
view = GIMP_VIEW (nav_view);
|
|
||||||
|
|
||||||
if (! view->renderer->viewable)
|
if (! view->renderer->viewable)
|
||||||
return;
|
return;
|
||||||
@ -260,17 +252,17 @@ gimp_navigation_view_move_to (GimpNavigationView *nav_view,
|
|||||||
tx = CLAMP (tx, 0, view->renderer->width - nav_view->p_width);
|
tx = CLAMP (tx, 0, view->renderer->width - nav_view->p_width);
|
||||||
ty = CLAMP (ty, 0, view->renderer->height - nav_view->p_height);
|
ty = CLAMP (ty, 0, view->renderer->height - nav_view->p_height);
|
||||||
|
|
||||||
gimage = GIMP_IMAGE (view->renderer->viewable);
|
image = GIMP_IMAGE (view->renderer->viewable);
|
||||||
|
|
||||||
/* transform to image coordinates */
|
/* transform to image coordinates */
|
||||||
if (view->renderer->width != nav_view->p_width)
|
if (view->renderer->width != nav_view->p_width)
|
||||||
ratiox = ((gimage->width - nav_view->width + 1.0) /
|
ratiox = ((image->width - nav_view->width + 1.0) /
|
||||||
(view->renderer->width - nav_view->p_width));
|
(view->renderer->width - nav_view->p_width));
|
||||||
else
|
else
|
||||||
ratiox = 1.0;
|
ratiox = 1.0;
|
||||||
|
|
||||||
if (view->renderer->height != nav_view->p_height)
|
if (view->renderer->height != nav_view->p_height)
|
||||||
ratioy = ((gimage->height - nav_view->height + 1.0) /
|
ratioy = ((image->height - nav_view->height + 1.0) /
|
||||||
(view->renderer->height - nav_view->p_height));
|
(view->renderer->height - nav_view->p_height));
|
||||||
else
|
else
|
||||||
ratioy = 1.0;
|
ratioy = 1.0;
|
||||||
@ -284,13 +276,11 @@ gimp_navigation_view_move_to (GimpNavigationView *nav_view,
|
|||||||
void
|
void
|
||||||
gimp_navigation_view_grab_pointer (GimpNavigationView *nav_view)
|
gimp_navigation_view_grab_pointer (GimpNavigationView *nav_view)
|
||||||
{
|
{
|
||||||
GtkWidget *widget;
|
GtkWidget *widget = GTK_WIDGET (nav_view);
|
||||||
GdkDisplay *display;
|
GdkDisplay *display;
|
||||||
GdkCursor *cursor;
|
GdkCursor *cursor;
|
||||||
GdkWindow *window;
|
GdkWindow *window;
|
||||||
|
|
||||||
widget = GTK_WIDGET (nav_view);
|
|
||||||
|
|
||||||
nav_view->has_grab = TRUE;
|
nav_view->has_grab = TRUE;
|
||||||
|
|
||||||
gtk_grab_add (widget);
|
gtk_grab_add (widget);
|
||||||
@ -314,12 +304,10 @@ static gboolean
|
|||||||
gimp_navigation_view_button_press (GtkWidget *widget,
|
gimp_navigation_view_button_press (GtkWidget *widget,
|
||||||
GdkEventButton *bevent)
|
GdkEventButton *bevent)
|
||||||
{
|
{
|
||||||
GimpNavigationView *nav_view;
|
GimpNavigationView *nav_view = GIMP_NAVIGATION_VIEW (widget);
|
||||||
gint tx, ty;
|
gint tx, ty;
|
||||||
GdkDisplay *display;
|
GdkDisplay *display;
|
||||||
|
|
||||||
nav_view = GIMP_NAVIGATION_VIEW (widget);
|
|
||||||
|
|
||||||
tx = bevent->x;
|
tx = bevent->x;
|
||||||
ty = bevent->y;
|
ty = bevent->y;
|
||||||
|
|
||||||
@ -366,9 +354,7 @@ static gboolean
|
|||||||
gimp_navigation_view_button_release (GtkWidget *widget,
|
gimp_navigation_view_button_release (GtkWidget *widget,
|
||||||
GdkEventButton *bevent)
|
GdkEventButton *bevent)
|
||||||
{
|
{
|
||||||
GimpNavigationView *nav_view;
|
GimpNavigationView *nav_view = GIMP_NAVIGATION_VIEW (widget);
|
||||||
|
|
||||||
nav_view = GIMP_NAVIGATION_VIEW (widget);
|
|
||||||
|
|
||||||
switch (bevent->button)
|
switch (bevent->button)
|
||||||
{
|
{
|
||||||
@ -391,10 +377,6 @@ static gboolean
|
|||||||
gimp_navigation_view_scroll (GtkWidget *widget,
|
gimp_navigation_view_scroll (GtkWidget *widget,
|
||||||
GdkEventScroll *sevent)
|
GdkEventScroll *sevent)
|
||||||
{
|
{
|
||||||
GimpNavigationView *nav_view;
|
|
||||||
|
|
||||||
nav_view = GIMP_NAVIGATION_VIEW (widget);
|
|
||||||
|
|
||||||
if (sevent->state & GDK_SHIFT_MASK)
|
if (sevent->state & GDK_SHIFT_MASK)
|
||||||
{
|
{
|
||||||
if (sevent->direction == GDK_SCROLL_UP)
|
if (sevent->direction == GDK_SCROLL_UP)
|
||||||
@ -432,14 +414,11 @@ static gboolean
|
|||||||
gimp_navigation_view_motion_notify (GtkWidget *widget,
|
gimp_navigation_view_motion_notify (GtkWidget *widget,
|
||||||
GdkEventMotion *mevent)
|
GdkEventMotion *mevent)
|
||||||
{
|
{
|
||||||
GimpNavigationView *nav_view;
|
GimpNavigationView *nav_view = GIMP_NAVIGATION_VIEW (widget);
|
||||||
GimpView *view;
|
GimpView *view = GIMP_VIEW (widget);
|
||||||
gint tx, ty;
|
gint tx, ty;
|
||||||
GdkModifierType mask;
|
GdkModifierType mask;
|
||||||
|
|
||||||
nav_view = GIMP_NAVIGATION_VIEW (widget);
|
|
||||||
view = GIMP_VIEW (widget);
|
|
||||||
|
|
||||||
if (! nav_view->has_grab)
|
if (! nav_view->has_grab)
|
||||||
{
|
{
|
||||||
GdkCursor *cursor;
|
GdkCursor *cursor;
|
||||||
@ -487,11 +466,9 @@ static gboolean
|
|||||||
gimp_navigation_view_key_press (GtkWidget *widget,
|
gimp_navigation_view_key_press (GtkWidget *widget,
|
||||||
GdkEventKey *kevent)
|
GdkEventKey *kevent)
|
||||||
{
|
{
|
||||||
GimpNavigationView *nav_view;
|
GimpNavigationView *nav_view = GIMP_NAVIGATION_VIEW (widget);
|
||||||
gint scroll_x = 0;
|
gint scroll_x = 0;
|
||||||
gint scroll_y = 0;
|
gint scroll_y = 0;
|
||||||
|
|
||||||
nav_view = GIMP_NAVIGATION_VIEW (widget);
|
|
||||||
|
|
||||||
switch (kevent->keyval)
|
switch (kevent->keyval)
|
||||||
{
|
{
|
||||||
@ -529,16 +506,14 @@ gimp_navigation_view_key_press (GtkWidget *widget,
|
|||||||
static void
|
static void
|
||||||
gimp_navigation_view_transform (GimpNavigationView *nav_view)
|
gimp_navigation_view_transform (GimpNavigationView *nav_view)
|
||||||
{
|
{
|
||||||
GimpView *view;
|
GimpView *view = GIMP_VIEW (nav_view);
|
||||||
GimpImage *gimage;
|
GimpImage *image;
|
||||||
gdouble ratiox, ratioy;
|
gdouble ratiox, ratioy;
|
||||||
|
|
||||||
view = GIMP_VIEW (nav_view);
|
image = GIMP_IMAGE (view->renderer->viewable);
|
||||||
|
|
||||||
gimage = GIMP_IMAGE (view->renderer->viewable);
|
ratiox = ((gdouble) view->renderer->width / (gdouble) image->width);
|
||||||
|
ratioy = ((gdouble) view->renderer->height / (gdouble) image->height);
|
||||||
ratiox = ((gdouble) view->renderer->width / (gdouble) gimage->width);
|
|
||||||
ratioy = ((gdouble) view->renderer->height / (gdouble) gimage->height);
|
|
||||||
|
|
||||||
nav_view->p_x = RINT (nav_view->x * ratiox);
|
nav_view->p_x = RINT (nav_view->x * ratiox);
|
||||||
nav_view->p_y = RINT (nav_view->y * ratioy);
|
nav_view->p_y = RINT (nav_view->y * ratioy);
|
||||||
@ -551,22 +526,20 @@ static void
|
|||||||
gimp_navigation_view_draw_marker (GimpNavigationView *nav_view,
|
gimp_navigation_view_draw_marker (GimpNavigationView *nav_view,
|
||||||
GdkRectangle *area)
|
GdkRectangle *area)
|
||||||
{
|
{
|
||||||
GimpView *view;
|
GimpView *view = GIMP_VIEW (nav_view);
|
||||||
|
|
||||||
view = GIMP_VIEW (nav_view);
|
|
||||||
|
|
||||||
if (view->renderer->viewable &&
|
if (view->renderer->viewable &&
|
||||||
nav_view->width &&
|
nav_view->width &&
|
||||||
nav_view->height)
|
nav_view->height)
|
||||||
{
|
{
|
||||||
GimpImage *gimage;
|
GimpImage *image;
|
||||||
|
|
||||||
gimage = GIMP_IMAGE (view->renderer->viewable);
|
image = GIMP_IMAGE (view->renderer->viewable);
|
||||||
|
|
||||||
if (nav_view->x > 0 ||
|
if (nav_view->x > 0 ||
|
||||||
nav_view->y > 0 ||
|
nav_view->y > 0 ||
|
||||||
nav_view->width < gimage->width ||
|
nav_view->width < image->width ||
|
||||||
nav_view->height < gimage->height)
|
nav_view->height < image->height)
|
||||||
{
|
{
|
||||||
GtkWidget *widget = GTK_WIDGET (view);
|
GtkWidget *widget = GTK_WIDGET (view);
|
||||||
|
|
||||||
@ -594,7 +567,7 @@ gimp_navigation_view_set_marker (GimpNavigationView *nav_view,
|
|||||||
gdouble height)
|
gdouble height)
|
||||||
{
|
{
|
||||||
GimpView *view;
|
GimpView *view;
|
||||||
GimpImage *gimage;
|
GimpImage *image;
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_NAVIGATION_VIEW (nav_view));
|
g_return_if_fail (GIMP_IS_NAVIGATION_VIEW (nav_view));
|
||||||
|
|
||||||
@ -602,23 +575,23 @@ gimp_navigation_view_set_marker (GimpNavigationView *nav_view,
|
|||||||
|
|
||||||
g_return_if_fail (view->renderer->viewable);
|
g_return_if_fail (view->renderer->viewable);
|
||||||
|
|
||||||
gimage = GIMP_IMAGE (view->renderer->viewable);
|
image = GIMP_IMAGE (view->renderer->viewable);
|
||||||
|
|
||||||
/* remove old marker */
|
/* remove old marker */
|
||||||
if (GTK_WIDGET_DRAWABLE (view))
|
if (GTK_WIDGET_DRAWABLE (view))
|
||||||
gimp_navigation_view_draw_marker (nav_view, NULL);
|
gimp_navigation_view_draw_marker (nav_view, NULL);
|
||||||
|
|
||||||
nav_view->x = CLAMP (x, 0.0, gimage->width - 1.0);
|
nav_view->x = CLAMP (x, 0.0, image->width - 1.0);
|
||||||
nav_view->y = CLAMP (y, 0.0, gimage->height - 1.0);
|
nav_view->y = CLAMP (y, 0.0, image->height - 1.0);
|
||||||
|
|
||||||
if (width < 0.0)
|
if (width < 0.0)
|
||||||
width = gimage->width;
|
width = image->width;
|
||||||
|
|
||||||
if (height < 0.0)
|
if (height < 0.0)
|
||||||
height = gimage->height;
|
height = image->height;
|
||||||
|
|
||||||
nav_view->width = CLAMP (width, 1.0, gimage->width - nav_view->x);
|
nav_view->width = CLAMP (width, 1.0, image->width - nav_view->x);
|
||||||
nav_view->height = CLAMP (height, 1.0, gimage->height - nav_view->y);
|
nav_view->height = CLAMP (height, 1.0, image->height - nav_view->y);
|
||||||
|
|
||||||
gimp_navigation_view_transform (nav_view);
|
gimp_navigation_view_transform (nav_view);
|
||||||
|
|
||||||
@ -626,4 +599,3 @@ gimp_navigation_view_set_marker (GimpNavigationView *nav_view,
|
|||||||
if (GTK_WIDGET_DRAWABLE (view))
|
if (GTK_WIDGET_DRAWABLE (view))
|
||||||
gimp_navigation_view_draw_marker (nav_view, NULL);
|
gimp_navigation_view_draw_marker (nav_view, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user