static void gimp_mandala_guide_removed_cb (GObject *object, GimpMandala *mandala) { GimpSymmetry *sym = GIMP_SYMMETRY (mandala); g_signal_handlers_disconnect_by_func (object, gimp_mandala_guide_removed_cb, mandala); g_signal_handlers_disconnect_by_func (object, gimp_mandala_guide_position_cb, mandala); if (GIMP_GUIDE (object) == mandala->horizontal_guide) { g_object_unref (mandala->horizontal_guide); mandala->horizontal_guide = NULL; mandala->center_y = 0.0; gimp_mandala_remove_guide (mandala, GIMP_ORIENTATION_VERTICAL); } else if (GIMP_GUIDE (object) == mandala->vertical_guide) { g_object_unref (mandala->vertical_guide); mandala->vertical_guide = NULL; mandala->center_x = 0.0; gimp_mandala_remove_guide (mandala, GIMP_ORIENTATION_HORIZONTAL); } gimp_image_symmetry_remove (sym->image, sym); }
static void gimp_symmetry_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { GimpSymmetry *sym = GIMP_SYMMETRY (object); switch (property_id) { case PROP_IMAGE: sym->image = g_value_get_object (value); break; case PROP_ACTIVE: sym->active = g_value_get_boolean (value); g_signal_emit (sym, gimp_symmetry_signals[ACTIVE_CHANGED], 0, sym->active); break; case PROP_VERSION: sym->version = g_value_get_int (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
static void gimp_mandala_remove_guide (GimpMandala *mandala, GimpOrientationType orientation) { GimpSymmetry *sym = GIMP_SYMMETRY (mandala); GimpImage *image; GimpGuide *guide; image = sym->image; guide = (orientation == GIMP_ORIENTATION_HORIZONTAL) ? mandala->horizontal_guide : mandala->vertical_guide; g_signal_handlers_disconnect_by_func (guide, gimp_mandala_guide_removed_cb, mandala); g_signal_handlers_disconnect_by_func (guide, gimp_mandala_guide_position_cb, mandala); gimp_image_remove_guide (image, guide, FALSE); g_object_unref (guide); if (orientation == GIMP_ORIENTATION_HORIZONTAL) mandala->horizontal_guide = NULL; else mandala->vertical_guide = NULL; }
static void gimp_tiling_constructed (GObject *object) { GimpSymmetry *sym = GIMP_SYMMETRY (object); GimpTiling *tiling = GIMP_TILING (object); GParamSpecDouble *dspec; /* Update property values to actual image size. */ dspec = G_PARAM_SPEC_DOUBLE (g_object_class_find_property (G_OBJECT_GET_CLASS (object), "x-interval")); dspec->maximum = gimp_image_get_width (sym->image); dspec = G_PARAM_SPEC_DOUBLE (g_object_class_find_property (G_OBJECT_GET_CLASS (object), "shift")); dspec->maximum = gimp_image_get_width (sym->image); dspec = G_PARAM_SPEC_DOUBLE (g_object_class_find_property (G_OBJECT_GET_CLASS (object), "y-interval")); dspec->maximum = gimp_image_get_height (sym->image); g_signal_connect (sym->image, "size-changed-detailed", G_CALLBACK (gimp_tiling_image_size_changed_cb), sym); /* Set reasonable defaults. */ tiling->interval_x = gimp_image_get_width (sym->image) / 2; tiling->interval_y = gimp_image_get_height (sym->image) / 2; }
static void gimp_symmetry_finalize (GObject *object) { GimpSymmetry *sym = GIMP_SYMMETRY (object); gimp_symmetry_clear_origin (sym); G_OBJECT_CLASS (parent_class)->finalize (object); }
static void gimp_mandala_constructed (GObject *object) { GimpSymmetry *sym = GIMP_SYMMETRY (object); g_signal_connect_object (sym->image, "size-changed-detailed", G_CALLBACK (gimp_mandala_image_size_changed_cb), sym, 0); }
static void gimp_mandala_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { GimpMandala *mandala = GIMP_MANDALA (object); GimpImage *image = GIMP_SYMMETRY (mandala)->image; switch (property_id) { case PROP_CENTER_X: mandala->center_x = g_value_get_double (value); if (mandala->vertical_guide) { g_signal_handlers_block_by_func (mandala->vertical_guide, gimp_mandala_guide_position_cb, mandala); gimp_image_move_guide (image, mandala->vertical_guide, mandala->center_x, FALSE); g_signal_handlers_unblock_by_func (mandala->vertical_guide, gimp_mandala_guide_position_cb, mandala); } break; case PROP_CENTER_Y: mandala->center_y = g_value_get_double (value); if (mandala->horizontal_guide) { g_signal_handlers_block_by_func (mandala->horizontal_guide, gimp_mandala_guide_position_cb, mandala); gimp_image_move_guide (image, mandala->horizontal_guide, mandala->center_y, FALSE); g_signal_handlers_unblock_by_func (mandala->horizontal_guide, gimp_mandala_guide_position_cb, mandala); } break; case PROP_SIZE: mandala->size = g_value_get_int (value); break; case PROP_DISABLE_TRANSFORMATION: mandala->disable_transformation = g_value_get_boolean (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
static void gimp_mandala_add_guide (GimpMandala *mandala, GimpOrientationType orientation) { GimpSymmetry *sym = GIMP_SYMMETRY (mandala); GimpImage *image; Gimp *gimp; GimpGuide *guide; gint position; image = sym->image; gimp = image->gimp; guide = gimp_guide_custom_new (orientation, gimp->next_guide_ID++, GIMP_GUIDE_STYLE_MANDALA); if (orientation == GIMP_ORIENTATION_HORIZONTAL) { mandala->horizontal_guide = guide; /* Mandala guide position at first activation is at canvas middle. */ if (mandala->center_y < 1.0) mandala->center_y = (gdouble) gimp_image_get_height (image) / 2.0; position = (gint) mandala->center_y; } else { mandala->vertical_guide = guide; /* Mandala guide position at first activation is at canvas middle. */ if (mandala->center_x < 1.0) mandala->center_x = (gdouble) gimp_image_get_width (image) / 2.0; position = (gint) mandala->center_x; } g_signal_connect (guide, "removed", G_CALLBACK (gimp_mandala_guide_removed_cb), mandala); gimp_image_add_guide (image, guide, position); g_signal_connect (guide, "notify::position", G_CALLBACK (gimp_mandala_guide_position_cb), mandala); }
static void gimp_symmetry_finalize (GObject *object) { GimpSymmetry *sym = GIMP_SYMMETRY (object); if (sym->drawable) g_object_unref (sym->drawable); g_free (sym->origin); sym->origin = NULL; g_list_free_full (sym->strokes, g_free); sym->strokes = NULL; G_OBJECT_CLASS (parent_class)->finalize (object); }
static void gimp_mandala_constructed (GObject *object) { GimpSymmetry *sym; GParamSpecDouble *dspec; sym = GIMP_SYMMETRY (object); /* Update property values to actual image size. */ dspec = G_PARAM_SPEC_DOUBLE (g_object_class_find_property (G_OBJECT_GET_CLASS (object), "center-x")); dspec->maximum = gimp_image_get_width (sym->image); dspec = G_PARAM_SPEC_DOUBLE (g_object_class_find_property (G_OBJECT_GET_CLASS (object), "center-y")); dspec->maximum = gimp_image_get_height (sym->image); g_signal_connect (sym->image, "size-changed-detailed", G_CALLBACK (gimp_mandala_image_size_changed_cb), sym); }
static void gimp_symmetry_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { GimpSymmetry *sym = GIMP_SYMMETRY (object); switch (property_id) { case PROP_IMAGE: g_value_set_object (value, sym->image); break; case PROP_ACTIVE: g_value_set_boolean (value, sym->active); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
static void gimp_tiling_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { GimpTiling *tiling = GIMP_TILING (object); GimpSymmetry *sym = GIMP_SYMMETRY (tiling); switch (property_id) { case PROP_X_INTERVAL: if (sym->image) { gdouble new_x = g_value_get_double (value); if (new_x < gimp_image_get_width (sym->image)) { tiling->interval_x = new_x; if (tiling->interval_x <= tiling->shift + G_DOUBLE_EPSILON) { GValue val = G_VALUE_INIT; g_value_init (&val, G_TYPE_DOUBLE); g_value_set_double (&val, 0.0); g_object_set_property (G_OBJECT (object), "shift", &val); } if (sym->drawable) gimp_tiling_update_strokes (sym, sym->drawable, sym->origin); } } break; case PROP_Y_INTERVAL: { gdouble new_y = g_value_get_double (value); if (new_y < gimp_image_get_height (sym->image)) { tiling->interval_y = new_y; if (tiling->interval_y <= G_DOUBLE_EPSILON) { GValue val = G_VALUE_INIT; g_value_init (&val, G_TYPE_DOUBLE); g_value_set_double (&val, 0.0); g_object_set_property (G_OBJECT (object), "shift", &val); } if (sym->drawable) gimp_tiling_update_strokes (sym, sym->drawable, sym->origin); } } break; case PROP_SHIFT: { gdouble new_shift = g_value_get_double (value); if (new_shift == 0.0 || (tiling->interval_y != 0.0 && new_shift < tiling->interval_x)) { tiling->shift = new_shift; if (sym->drawable) gimp_tiling_update_strokes (sym, sym->drawable, sym->origin); } } break; case PROP_X_MAX: tiling->max_x = g_value_get_int (value); if (sym->drawable) gimp_tiling_update_strokes (sym, sym->drawable, sym->origin); break; case PROP_Y_MAX: tiling->max_y = g_value_get_int (value); if (sym->drawable) gimp_tiling_update_strokes (sym, sym->drawable, sym->origin); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }