diff --git a/ChangeLog b/ChangeLog index 5f434b2ef3..d8c9e2f60f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-07-14 Michael Natterer + + * app/widgets/gimphistogramview.c + * app/widgets/gimpnavigationview.c: cleanup. + 2005-07-14 Michael Natterer * app/widgets/gimppaletteview.[ch]: added "entry-clicked" and diff --git a/app/widgets/gimphistogramview.c b/app/widgets/gimphistogramview.c index a142ad0f9c..86c3f1ccde 100644 --- a/app/widgets/gimphistogramview.c +++ b/app/widgets/gimphistogramview.c @@ -119,14 +119,11 @@ gimp_histogram_view_get_type (void) static void gimp_histogram_view_class_init (GimpHistogramViewClass *klass) { - GObjectClass *object_class; - GtkWidgetClass *widget_class; + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (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] = g_signal_new ("range-changed", G_TYPE_FROM_CLASS (klass), @@ -150,14 +147,16 @@ gimp_histogram_view_class_init (GimpHistogramViewClass *klass) klass->range_changed = NULL; 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_HISTOGRAM_VALUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); 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_HISTOGRAM_SCALE_LINEAR, G_PARAM_READWRITE | diff --git a/app/widgets/gimpnavigationview.c b/app/widgets/gimpnavigationview.c index 676f94dfe7..6576bab89c 100644 --- a/app/widgets/gimpnavigationview.c +++ b/app/widgets/gimpnavigationview.c @@ -111,9 +111,7 @@ gimp_navigation_view_get_type (void) static void gimp_navigation_view_class_init (GimpNavigationViewClass *klass) { - GtkWidgetClass *widget_class; - - widget_class = GTK_WIDGET_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (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); - 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); @@ -211,16 +208,14 @@ gimp_navigation_view_unrealize (GtkWidget *widget) 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 gimp_navigation_view_size_allocate (GtkWidget *widget, 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) 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_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), &eevent->area); @@ -247,12 +241,10 @@ gimp_navigation_view_move_to (GimpNavigationView *nav_view, gint tx, gint ty) { - GimpView *view; - GimpImage *gimage; - gdouble ratiox, ratioy; - gdouble x, y; - - view = GIMP_VIEW (nav_view); + GimpView *view = GIMP_VIEW (nav_view); + GimpImage *image; + gdouble ratiox, ratioy; + gdouble x, y; if (! view->renderer->viewable) return; @@ -260,17 +252,17 @@ gimp_navigation_view_move_to (GimpNavigationView *nav_view, tx = CLAMP (tx, 0, view->renderer->width - nav_view->p_width); 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 */ 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)); else ratiox = 1.0; 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)); else ratioy = 1.0; @@ -284,13 +276,11 @@ gimp_navigation_view_move_to (GimpNavigationView *nav_view, void gimp_navigation_view_grab_pointer (GimpNavigationView *nav_view) { - GtkWidget *widget; + GtkWidget *widget = GTK_WIDGET (nav_view); GdkDisplay *display; GdkCursor *cursor; GdkWindow *window; - widget = GTK_WIDGET (nav_view); - nav_view->has_grab = TRUE; gtk_grab_add (widget); @@ -314,12 +304,10 @@ static gboolean gimp_navigation_view_button_press (GtkWidget *widget, GdkEventButton *bevent) { - GimpNavigationView *nav_view; + GimpNavigationView *nav_view = GIMP_NAVIGATION_VIEW (widget); gint tx, ty; GdkDisplay *display; - nav_view = GIMP_NAVIGATION_VIEW (widget); - tx = bevent->x; ty = bevent->y; @@ -366,9 +354,7 @@ static gboolean gimp_navigation_view_button_release (GtkWidget *widget, GdkEventButton *bevent) { - GimpNavigationView *nav_view; - - nav_view = GIMP_NAVIGATION_VIEW (widget); + GimpNavigationView *nav_view = GIMP_NAVIGATION_VIEW (widget); switch (bevent->button) { @@ -391,10 +377,6 @@ static gboolean gimp_navigation_view_scroll (GtkWidget *widget, GdkEventScroll *sevent) { - GimpNavigationView *nav_view; - - nav_view = GIMP_NAVIGATION_VIEW (widget); - if (sevent->state & GDK_SHIFT_MASK) { if (sevent->direction == GDK_SCROLL_UP) @@ -432,14 +414,11 @@ static gboolean gimp_navigation_view_motion_notify (GtkWidget *widget, GdkEventMotion *mevent) { - GimpNavigationView *nav_view; - GimpView *view; + GimpNavigationView *nav_view = GIMP_NAVIGATION_VIEW (widget); + GimpView *view = GIMP_VIEW (widget); gint tx, ty; GdkModifierType mask; - nav_view = GIMP_NAVIGATION_VIEW (widget); - view = GIMP_VIEW (widget); - if (! nav_view->has_grab) { GdkCursor *cursor; @@ -487,11 +466,9 @@ static gboolean gimp_navigation_view_key_press (GtkWidget *widget, GdkEventKey *kevent) { - GimpNavigationView *nav_view; - gint scroll_x = 0; - gint scroll_y = 0; - - nav_view = GIMP_NAVIGATION_VIEW (widget); + GimpNavigationView *nav_view = GIMP_NAVIGATION_VIEW (widget); + gint scroll_x = 0; + gint scroll_y = 0; switch (kevent->keyval) { @@ -529,16 +506,14 @@ gimp_navigation_view_key_press (GtkWidget *widget, static void gimp_navigation_view_transform (GimpNavigationView *nav_view) { - GimpView *view; - GimpImage *gimage; + GimpView *view = GIMP_VIEW (nav_view); + GimpImage *image; 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) gimage->width); - ratioy = ((gdouble) view->renderer->height / (gdouble) gimage->height); + ratiox = ((gdouble) view->renderer->width / (gdouble) image->width); + ratioy = ((gdouble) view->renderer->height / (gdouble) image->height); nav_view->p_x = RINT (nav_view->x * ratiox); nav_view->p_y = RINT (nav_view->y * ratioy); @@ -551,22 +526,20 @@ static void gimp_navigation_view_draw_marker (GimpNavigationView *nav_view, GdkRectangle *area) { - GimpView *view; - - view = GIMP_VIEW (nav_view); + GimpView *view = GIMP_VIEW (nav_view); if (view->renderer->viewable && nav_view->width && nav_view->height) { - GimpImage *gimage; + GimpImage *image; - gimage = GIMP_IMAGE (view->renderer->viewable); + image = GIMP_IMAGE (view->renderer->viewable); if (nav_view->x > 0 || nav_view->y > 0 || - nav_view->width < gimage->width || - nav_view->height < gimage->height) + nav_view->width < image->width || + nav_view->height < image->height) { GtkWidget *widget = GTK_WIDGET (view); @@ -594,7 +567,7 @@ gimp_navigation_view_set_marker (GimpNavigationView *nav_view, gdouble height) { GimpView *view; - GimpImage *gimage; + GimpImage *image; 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); - gimage = GIMP_IMAGE (view->renderer->viewable); + image = GIMP_IMAGE (view->renderer->viewable); /* remove old marker */ if (GTK_WIDGET_DRAWABLE (view)) gimp_navigation_view_draw_marker (nav_view, NULL); - nav_view->x = CLAMP (x, 0.0, gimage->width - 1.0); - nav_view->y = CLAMP (y, 0.0, gimage->height - 1.0); + nav_view->x = CLAMP (x, 0.0, image->width - 1.0); + nav_view->y = CLAMP (y, 0.0, image->height - 1.0); if (width < 0.0) - width = gimage->width; + width = image->width; if (height < 0.0) - height = gimage->height; + height = image->height; - nav_view->width = CLAMP (width, 1.0, gimage->width - nav_view->x); - nav_view->height = CLAMP (height, 1.0, gimage->height - nav_view->y); + nav_view->width = CLAMP (width, 1.0, image->width - nav_view->x); + nav_view->height = CLAMP (height, 1.0, image->height - nav_view->y); gimp_navigation_view_transform (nav_view); @@ -626,4 +599,3 @@ gimp_navigation_view_set_marker (GimpNavigationView *nav_view, if (GTK_WIDGET_DRAWABLE (view)) gimp_navigation_view_draw_marker (nav_view, NULL); } -