static void e_minicard_label_realize (GnomeCanvasItem *item) { EMinicardLabel *e_minicard_label; GnomeCanvasGroup *group; e_minicard_label = E_MINICARD_LABEL (item); group = GNOME_CANVAS_GROUP ( item ); if (GNOME_CANVAS_ITEM_CLASS ( parent_class )->realize) (* GNOME_CANVAS_ITEM_CLASS ( parent_class )->realize) (item); e_canvas_item_request_reflow (item); e_minicard_label->rect = gnome_canvas_item_new ( group, gnome_canvas_rect_get_type (), "x1", (double) 0, "y1", (double) 0, "x2", (double) e_minicard_label->width - 1, "y2", (double) e_minicard_label->height - 1, "outline_color", NULL, NULL ); e_minicard_label->fieldname = gnome_canvas_item_new ( group, e_text_get_type (), "clip_width", (double) ( e_minicard_label->width / 2 - 4 ), "clip", TRUE, "use_ellipsis", TRUE, "fill_color", "black", "draw_background", FALSE, "im_context", E_CANVAS (item->canvas)->im_context, NULL ); e_canvas_item_move_absolute (e_minicard_label->fieldname, 2, 1); e_minicard_label->field = gnome_canvas_item_new ( group, e_text_get_type (), "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ), "clip", TRUE, "use_ellipsis", TRUE, "fill_color", "black", "editable", FALSE, /* e_minicard_label->editable, */ "draw_background", FALSE, "im_context", E_CANVAS (item->canvas)->im_context, NULL ); e_canvas_item_move_absolute (e_minicard_label->field, ( e_minicard_label->width / 2 + 2), 1); set_colors (e_minicard_label); e_canvas_item_request_reflow (item); }
static void e_canvas_dispose (GObject *object) { ECanvas *canvas = E_CANVAS(object); if (canvas->idle_id) g_source_remove(canvas->idle_id); canvas->idle_id = 0; if (canvas->grab_cancelled_check_id) g_source_remove (canvas->grab_cancelled_check_id); canvas->grab_cancelled_check_id = 0; if (canvas->toplevel) { if (canvas->visibility_notify_id) g_signal_handler_disconnect (canvas->toplevel, canvas->visibility_notify_id); canvas->visibility_notify_id = 0; g_object_unref (canvas->toplevel); canvas->toplevel = NULL; } if (canvas->im_context) { g_object_unref (canvas->im_context); canvas->im_context = NULL; } e_canvas_hide_tooltip(canvas); if ((G_OBJECT_CLASS (e_canvas_parent_class))->dispose) (*(G_OBJECT_CLASS (e_canvas_parent_class))->dispose) (object); }
static gint canvas_focus_out_event (GtkWidget *widget, GdkEventFocus *event) { GnomeCanvas *canvas; ECanvas *ecanvas; GdkEvent full_event = { 0 }; canvas = GNOME_CANVAS (widget); ecanvas = E_CANVAS (widget); /* XXX Can't access flags directly anymore, but is it really needed? * If so, could we call gtk_widget_send_focus_change() instead? */ #if 0 GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); #endif gtk_im_context_focus_out (ecanvas->im_context); if (canvas->focused_item) { full_event.type = event->type; full_event.focus_change = *event; return canvas_emit_event (canvas, &full_event); } else { return FALSE; } }
static void canvas_dispose (GObject *object) { ECanvas *canvas = E_CANVAS (object); if (canvas->idle_id) g_source_remove (canvas->idle_id); canvas->idle_id = 0; if (canvas->grab_cancelled_check_id) g_source_remove (canvas->grab_cancelled_check_id); canvas->grab_cancelled_check_id = 0; if (canvas->toplevel) { if (canvas->visibility_notify_id) g_signal_handler_disconnect ( canvas->toplevel, canvas->visibility_notify_id); canvas->visibility_notify_id = 0; g_object_unref (canvas->toplevel); canvas->toplevel = NULL; } if (canvas->im_context) { g_object_unref (canvas->im_context); canvas->im_context = NULL; } /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (e_canvas_parent_class)->dispose (object); }
void e_canvas_item_request_reflow (GnomeCanvasItem *item) { if (item->object.flags & GNOME_CANVAS_ITEM_REALIZED) { item->object.flags |= E_CANVAS_ITEM_NEEDS_REFLOW; e_canvas_item_descendent_needs_reflow(item); add_idle(E_CANVAS(item->canvas)); } }
static void e_canvas_realize (GtkWidget *widget) { ECanvas *ecanvas = E_CANVAS (widget); if (GTK_WIDGET_CLASS (e_canvas_parent_class)->realize) (* GTK_WIDGET_CLASS (e_canvas_parent_class)->realize) (widget); gdk_window_set_back_pixmap (GTK_LAYOUT (widget)->bin_window, NULL, FALSE); gtk_im_context_set_client_window (ecanvas->im_context, widget->window); }
void e_canvas_item_set_cursor (GnomeCanvasItem *item, gpointer id) { GList *list; int flags; ECanvas *canvas; ECanvasSelectionInfo *info; ECanvasItemSelectionFunc func; g_return_if_fail(item != NULL); g_return_if_fail(GNOME_IS_CANVAS_ITEM(item)); g_return_if_fail(item->canvas != NULL); g_return_if_fail(E_IS_CANVAS(item->canvas)); canvas = E_CANVAS(item->canvas); flags = E_CANVAS_ITEM_SELECTION_DELETE_DATA; for (list = canvas->selection; list; list = g_list_next(list)) { info = list->data; func = (ECanvasItemSelectionFunc)g_object_get_data(G_OBJECT(info->item), "ECanvasItem::selection_callback"); if (func) func(info->item, flags, info->id); g_message ("ECANVAS: free info (2): item %p, id %p", info->item, info->id); g_object_unref (info->item); g_free(info); } g_list_free(canvas->selection); canvas->selection = NULL; gnome_canvas_item_grab_focus(item); info = g_new(ECanvasSelectionInfo, 1); info->item = item; g_object_ref (info->item); info->id = id; g_message ("ECANVAS: new info item %p, id %p", item, id); flags = E_CANVAS_ITEM_SELECTION_SELECT | E_CANVAS_ITEM_SELECTION_CURSOR; func = (ECanvasItemSelectionFunc)g_object_get_data(G_OBJECT(item), "ECanvasItem::selection_callback"); if (func) func(item, flags, id); canvas->selection = g_list_prepend(canvas->selection, info); canvas->cursor = info; }
static void e_canvas_unrealize (GtkWidget *widget) { ECanvas * ecanvas = E_CANVAS (widget); if (ecanvas->idle_id) { g_source_remove(ecanvas->idle_id); ecanvas->idle_id = 0; } gtk_im_context_set_client_window (ecanvas->im_context, NULL); if (GTK_WIDGET_CLASS (e_canvas_parent_class)->unrealize) (* GTK_WIDGET_CLASS (e_canvas_parent_class)->unrealize) (widget); }
static void canvas_realize (GtkWidget *widget) { ECanvas *ecanvas = E_CANVAS (widget); GdkWindow *window; /* Chain up to parent's realize() method. */ GTK_WIDGET_CLASS (e_canvas_parent_class)->realize (widget); window = gtk_layout_get_bin_window (GTK_LAYOUT (widget)); gdk_window_set_background_pattern (window, NULL); window = gtk_widget_get_window (widget); gtk_im_context_set_client_window (ecanvas->im_context, window); }
void e_canvas_item_remove_selection (GnomeCanvasItem *item, gpointer id) { int flags; ECanvas *canvas; ECanvasSelectionInfo *info; GList *list; g_return_if_fail(item != NULL); g_return_if_fail(GNOME_IS_CANVAS_ITEM(item)); g_return_if_fail(item->canvas != NULL); g_return_if_fail(E_IS_CANVAS(item->canvas)); flags = E_CANVAS_ITEM_SELECTION_DELETE_DATA; canvas = E_CANVAS(item->canvas); for (list = canvas->selection; list; list = g_list_next(list)) { info = list->data; if (info->item == item) { ECanvasItemSelectionCompareFunc compare_func; compare_func = (ECanvasItemSelectionCompareFunc)g_object_get_data(G_OBJECT(info->item), "ECanvasItem::selection_compare_callback"); if (compare_func(info->item, info->id, id, 0) == 0) { ECanvasItemSelectionFunc func; func = (ECanvasItemSelectionFunc) g_object_get_data(G_OBJECT(info->item), "ECanvasItem::selection_callback"); if (func) func(info->item, flags, info->id); canvas->selection = g_list_remove_link(canvas->selection, list); if (canvas->cursor == info) canvas->cursor = NULL; g_message ("ECANVAS: removing info: item %p, info %p", info->item, info->id); g_object_unref (info->item); g_free(info); g_list_free_1(list); break; } } } }
/* Idle handler for the e-canvas. It deals with pending reflows. */ static gint idle_handler (gpointer data) { ECanvas *canvas; GDK_THREADS_ENTER(); canvas = E_CANVAS (data); do_reflow (canvas); /* Reset idle id */ canvas->idle_id = 0; g_signal_emit (canvas, e_canvas_signals [REFLOW], 0); GDK_THREADS_LEAVE(); return FALSE; }
/* Focus out handler for the canvas */ static gint e_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event) { GnomeCanvas *canvas; ECanvas *ecanvas; GdkEvent full_event; canvas = GNOME_CANVAS (widget); ecanvas = E_CANVAS (widget); GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); gtk_im_context_focus_out (ecanvas->im_context); if (canvas->focused_item) { full_event.focus_change = *event; return emit_event (canvas, &full_event); } else { return FALSE; } }
void e_canvas_item_add_selection (GnomeCanvasItem *item, gpointer id) { int flags; ECanvas *canvas; ECanvasSelectionInfo *info; ECanvasItemSelectionFunc func; GList *list; g_return_if_fail(item != NULL); g_return_if_fail(GNOME_IS_CANVAS_ITEM(item)); g_return_if_fail(item->canvas != NULL); g_return_if_fail(E_IS_CANVAS(item->canvas)); flags = E_CANVAS_ITEM_SELECTION_SELECT; canvas = E_CANVAS(item->canvas); if (canvas->cursor) { func = (ECanvasItemSelectionFunc)g_object_get_data(G_OBJECT(canvas->cursor->item), "ECanvasItem::selection_callback"); if (func) func(canvas->cursor->item, flags, canvas->cursor->id); } gnome_canvas_item_grab_focus(item); flags = E_CANVAS_ITEM_SELECTION_SELECT | E_CANVAS_ITEM_SELECTION_CURSOR; for (list = canvas->selection; list; list = g_list_next(list)) { ECanvasSelectionInfo *search; search = list->data; if (search->item == item) { ECanvasItemSelectionCompareFunc compare_func; compare_func = (ECanvasItemSelectionCompareFunc)g_object_get_data(G_OBJECT(search->item), "ECanvasItem::selection_compare_callback"); if (compare_func(search->item, search->id, id, 0) == 0) { canvas->cursor = search; func = (ECanvasItemSelectionFunc)g_object_get_data(G_OBJECT(item), "ECanvasItem::selection_callback"); if (func) func(item, flags, search->id); return; } } } info = g_new(ECanvasSelectionInfo, 1); info->item = item; g_object_ref (info->item); info->id = id; g_message ("ECANVAS: new info (2): item %p, id %p", item, id); func = (ECanvasItemSelectionFunc)g_object_get_data(G_OBJECT(item), "ECanvasItem::selection_callback"); if (func) func(item, flags, id); canvas->selection = g_list_prepend(canvas->selection, info); canvas->cursor = info; }