static void set_surface(HippoCanvasImage *image, cairo_surface_t *surface) { if (surface != image->surface) { int old_width, old_height; gboolean request_changed = FALSE; #if 0 /* The FC5 version of Cairo doesn't have this API */ if (cairo_surface_get_type(surface) != CAIRO_SURFACE_TYPE_IMAGE) { g_warning("Image canvas item only supports image surfaces"); return; } #endif old_width = image->surface ? cairo_image_surface_get_width(image->surface) : 0; old_height = image->surface ? cairo_image_surface_get_height(image->surface) : 0; if (surface) cairo_surface_reference(surface); if (image->surface) cairo_surface_destroy(image->surface); image->surface = surface; if (image->scale_width < 0) { int width = image->surface ? cairo_image_surface_get_width(image->surface) : 0; if (width != old_width) request_changed = TRUE; } if (image->scale_height < 0) { int height = image->surface ? cairo_image_surface_get_height(image->surface) : 0; if (height != old_height) request_changed = TRUE; } if (request_changed) hippo_canvas_item_emit_request_changed(HIPPO_CANVAS_ITEM(image)); hippo_canvas_item_emit_paint_needed(HIPPO_CANVAS_ITEM(image), 0, 0, -1, -1); g_object_notify(G_OBJECT(image), "image"); } }
static void hippo_canvas_text_set_context(HippoCanvasItem *item, HippoCanvasContext *context) { HippoCanvasBox *box = HIPPO_CANVAS_BOX(item); gboolean changed; changed = context != box->context; item_parent_class->set_context(item, context); /* we can't create a layout until we have a context, * so we have to queue a size change when the context * is set. */ if (changed) { hippo_canvas_item_emit_request_changed(HIPPO_CANVAS_ITEM(item)); hippo_canvas_item_emit_paint_needed(HIPPO_CANVAS_ITEM(item), 0, 0, -1, -1); } }
static gboolean hippo_canvas_grip_motion_notify_event (HippoCanvasItem *item, HippoEvent *event) { HippoCanvasGrip *grip = HIPPO_CANVAS_GRIP(item); gboolean result; gboolean prelighted; /* chain up so the box item can track child hovering */ result = item_parent_class->motion_notify_event(item, event); /* but also update our prelight */ if (event->u.motion.detail == HIPPO_MOTION_DETAIL_LEAVE) prelighted = FALSE; else prelighted = TRUE; if (grip->prelighted != prelighted) { grip->prelighted = prelighted; hippo_canvas_item_emit_paint_needed(item, 0, 0, -1, -1); } return result; }
static void hippo_canvas_text_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { HippoCanvasText *text; text = HIPPO_CANVAS_TEXT(object); switch (prop_id) { case PROP_TEXT: { const char *new_text; new_text = g_value_get_string(value); if (!(new_text == text->text || (new_text && text->text && strcmp(new_text, text->text) == 0))) { g_free(text->text); text->text = g_strdup(new_text); hippo_canvas_item_emit_request_changed(HIPPO_CANVAS_ITEM(text)); hippo_canvas_item_emit_paint_needed(HIPPO_CANVAS_ITEM(text), 0, 0, -1, -1); } } break; case PROP_ATTRIBUTES: { PangoAttrList *attrs = g_value_get_boxed(value); if (attrs) pango_attr_list_ref(attrs); if (text->attributes) pango_attr_list_unref(text->attributes); text->attributes = attrs; hippo_canvas_item_emit_request_changed(HIPPO_CANVAS_ITEM(text)); hippo_canvas_item_emit_paint_needed(HIPPO_CANVAS_ITEM(text), 0, 0, -1, -1); } break; case PROP_MARKUP: { char *text; PangoAttrList *attrs; GError *error = NULL; if (!pango_parse_markup(g_value_get_string(value), -1, 0, &attrs, &text, NULL, &error)) { g_error("Failed to set markup: %s", error->message); return; } g_object_set(object, "text", text, "attributes", attrs, NULL); pango_attr_list_unref(attrs); g_free(text); } break; case PROP_FONT_SCALE: text->font_scale = g_value_get_double(value); hippo_canvas_item_emit_request_changed(HIPPO_CANVAS_ITEM(text)); hippo_canvas_item_emit_paint_needed(HIPPO_CANVAS_ITEM(text), 0, 0, -1, -1); break; case PROP_SIZE_MODE: text->size_mode = g_value_get_enum(value); hippo_canvas_item_emit_request_changed(HIPPO_CANVAS_ITEM(text)); hippo_canvas_item_emit_paint_needed(HIPPO_CANVAS_ITEM(text), 0, 0, -1, -1); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; } }