static void sp_button_set_action (SPButton *button, SPAction *action) { GtkWidget *child; if (button->action) { nr_active_object_remove_listener_by_data ((NRActiveObject *) button->action, button); nr_object_unref ((NRObject *) button->action); child = gtk_bin_get_child (GTK_BIN (button)); if (child) { gtk_container_remove (GTK_CONTAINER (button), child); } } button->action = action; if (action) { button->action = (SPAction *) nr_object_ref ((NRObject *) action); nr_active_object_add_listener ((NRActiveObject *) action, (NRObjectEventVector *) &button_event_vector, sizeof (SPActionEventVector), button); if (action->image) { child = sp_icon_new (button->lsize, action->image); gtk_widget_show (child); gtk_container_add (GTK_CONTAINER (button), child); } } if (button->tooltips) { sp_button_set_composed_tooltip (button->tooltips, (GtkWidget *) button, action); } }
static void sp_button_set_doubleclick_action (SPButton *button, SPAction *action) { if (button->doubleclick_action) { nr_object_unref ((NRObject *) button->doubleclick_action); } button->doubleclick_action = action; if (action) { button->doubleclick_action = (SPAction *) nr_object_ref ((NRObject *) action); } }
static void sp_canvas_arena_update (SPCanvasItem *item, double *affine, unsigned int flags) { SPCanvasArena *arena; guint reset; arena = SP_CANVAS_ARENA (item); if (((SPCanvasItemClass *) parent_class)->update) (* ((SPCanvasItemClass *) parent_class)->update) (item, affine, flags); memcpy (NR_MATRIX_D_TO_DOUBLE (&arena->gc.transform), affine, 6 * sizeof (double)); if (flags & SP_CANVAS_UPDATE_AFFINE) { reset = NR_ARENA_ITEM_STATE_ALL; } else { reset = NR_ARENA_ITEM_STATE_NONE; } nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, NR_ARENA_ITEM_STATE_ALL, reset); item->x1 = arena->root->bbox.x0 - 1; item->y1 = arena->root->bbox.y0 - 1; item->x2 = arena->root->bbox.x1 + 1; item->y2 = arena->root->bbox.y1 + 1; if (arena->cursor) { NRArenaItem *new_arena; /* Mess with enter/leave notifiers */ new_arena = nr_arena_item_invoke_pick (arena->root, arena->cx, arena->cy, nr_arena_global_delta, arena->sticky); if (new_arena != arena->active) { GdkEventCrossing ec; ec.window = GTK_WIDGET (item->canvas)->window; ec.send_event = TRUE; ec.subwindow = ec.window; ec.time = GDK_CURRENT_TIME; ec.x = arena->cx; ec.y = arena->cy; /* fixme: */ if (arena->active) { ec.type = GDK_LEAVE_NOTIFY; sp_canvas_arena_send_event (arena, (GdkEvent *) &ec); } /* fixme: This is not optimal - better track ::destroy (Lauris) */ if (arena->active) nr_object_unref ((NRObject *) arena->active); arena->active = new_arena; if (arena->active) nr_object_ref ((NRObject *) arena->active); if (arena->active) { ec.type = GDK_ENTER_NOTIFY; sp_canvas_arena_send_event (arena, (GdkEvent *) &ec); } } } }
static gint sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) { SPCanvasArena *arena; NRArenaItem *new_arena; gint ret; /* fixme: This sucks, we have to handle enter/leave notifiers */ arena = SP_CANVAS_ARENA (item); ret = FALSE; switch (event->type) { case GDK_ENTER_NOTIFY: if (!arena->cursor) { if (arena->active) { g_warning ("Cursor entered to arena with already active item"); nr_object_unref ((NRObject *) arena->active); } arena->cursor = TRUE; #if 0 gnome_canvas_w2c_d (item->canvas, event->crossing.x, event->crossing.y, &arena->cx, &arena->cy); #else arena->cx = event->crossing.x; arena->cy = event->crossing.y; #endif /* fixme: Not sure abut this, but seems the right thing (Lauris) */ nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, NR_ARENA_ITEM_STATE_PICK, NR_ARENA_ITEM_STATE_NONE); arena->active = nr_arena_item_invoke_pick (arena->root, arena->cx, arena->cy, nr_arena_global_delta, arena->sticky); if (arena->active) nr_object_ref ((NRObject *) arena->active); ret = sp_canvas_arena_send_event (arena, event); } break; case GDK_LEAVE_NOTIFY: if (arena->cursor) { ret = sp_canvas_arena_send_event (arena, event); if (arena->active) nr_object_unref ((NRObject *) arena->active); arena->active = NULL; arena->cursor = FALSE; } break; case GDK_MOTION_NOTIFY: #if 0 gnome_canvas_w2c_d (item->canvas, event->motion.x, event->motion.y, &arena->cx, &arena->cy); #else arena->cx = event->motion.x; arena->cy = event->motion.y; #endif /* fixme: Not sure abut this, but seems the right thing (Lauris) */ nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, NR_ARENA_ITEM_STATE_PICK, NR_ARENA_ITEM_STATE_NONE); new_arena = nr_arena_item_invoke_pick (arena->root, arena->cx, arena->cy, nr_arena_global_delta, arena->sticky); if (new_arena != arena->active) { GdkEventCrossing ec; ec.window = event->motion.window; ec.send_event = event->motion.send_event; ec.subwindow = event->motion.window; ec.time = event->motion.time; ec.x = event->motion.x; ec.y = event->motion.y; /* fixme: */ if (arena->active) { ec.type = GDK_LEAVE_NOTIFY; ret = sp_canvas_arena_send_event (arena, (GdkEvent *) &ec); } if (arena->active) nr_object_unref ((NRObject *) arena->active); arena->active = new_arena; if (arena->active) nr_object_ref ((NRObject *) arena->active); if (arena->active) { ec.type = GDK_ENTER_NOTIFY; ret = sp_canvas_arena_send_event (arena, (GdkEvent *) &ec); } } ret = sp_canvas_arena_send_event (arena, event); break; default: /* Just send event */ ret = sp_canvas_arena_send_event (arena, event); break; } return ret; }