static void gimp_ruler_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { GimpRuler *ruler = GIMP_RULER (object); GimpRulerPrivate *priv = GIMP_RULER_GET_PRIVATE (ruler); switch (prop_id) { case PROP_ORIENTATION: priv->orientation = g_value_get_enum (value); gtk_widget_queue_resize (GTK_WIDGET (ruler)); break; case PROP_UNIT: gimp_ruler_set_unit (ruler, g_value_get_int (value)); break; case PROP_LOWER: gimp_ruler_set_range (ruler, g_value_get_double (value), priv->upper, priv->max_size); break; case PROP_UPPER: gimp_ruler_set_range (ruler, priv->lower, g_value_get_double (value), priv->max_size); break; case PROP_POSITION: gimp_ruler_set_position (ruler, g_value_get_double (value)); break; case PROP_MAX_SIZE: gimp_ruler_set_range (ruler, priv->lower, priv->upper, g_value_get_double (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
/** * gimp_display_shell_scale_update_rulers: * @shell: * **/ void gimp_display_shell_scale_update_rulers (GimpDisplayShell *shell) { GimpImage *image; gint image_width; gint image_height; gdouble resolution_x = 1.0; gdouble resolution_y = 1.0; gdouble horizontal_lower; gdouble horizontal_upper; gdouble horizontal_max_size; gdouble vertical_lower; gdouble vertical_upper; gdouble vertical_max_size; if (! shell->display) return; image = gimp_display_get_image (shell->display); if (image) { image_width = gimp_image_get_width (image); image_height = gimp_image_get_height (image); gimp_image_get_resolution (image, &resolution_x, &resolution_y); } else { image_width = shell->disp_width; image_height = shell->disp_height; } /* Initialize values */ horizontal_lower = 0; vertical_lower = 0; if (image) { horizontal_upper = gimp_pixels_to_units (FUNSCALEX (shell, shell->disp_width), shell->unit, resolution_x); horizontal_max_size = gimp_pixels_to_units (MAX (image_width, image_height), shell->unit, resolution_x); vertical_upper = gimp_pixels_to_units (FUNSCALEY (shell, shell->disp_height), shell->unit, resolution_y); vertical_max_size = gimp_pixels_to_units (MAX (image_width, image_height), shell->unit, resolution_y); } else { horizontal_upper = image_width; horizontal_max_size = MAX (image_width, image_height); vertical_upper = image_height; vertical_max_size = MAX (image_width, image_height); } /* Adjust due to scrolling */ if (image) { gdouble offset_x; gdouble offset_y; offset_x = gimp_pixels_to_units (FUNSCALEX (shell, (gdouble) shell->offset_x), shell->unit, resolution_x); offset_y = gimp_pixels_to_units (FUNSCALEX (shell, (gdouble) shell->offset_y), shell->unit, resolution_y); horizontal_lower += offset_x; horizontal_upper += offset_x; vertical_lower += offset_y; vertical_upper += offset_y; } /* Finally setup the actual rulers */ gimp_ruler_set_range (GIMP_RULER (shell->hrule), horizontal_lower, horizontal_upper, horizontal_max_size); gimp_ruler_set_unit (GIMP_RULER (shell->hrule), shell->unit); gimp_ruler_set_range (GIMP_RULER (shell->vrule), vertical_lower, vertical_upper, vertical_max_size); gimp_ruler_set_unit (GIMP_RULER (shell->vrule), shell->unit); }