aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'widgets')
-rw-r--r--widgets/misc/e-canvas-utils.c34
-rw-r--r--widgets/misc/e-canvas-utils.h25
2 files changed, 56 insertions, 3 deletions
diff --git a/widgets/misc/e-canvas-utils.c b/widgets/misc/e-canvas-utils.c
index 50fcf0d7e5..14d44f7bb2 100644
--- a/widgets/misc/e-canvas-utils.c
+++ b/widgets/misc/e-canvas-utils.c
@@ -95,6 +95,40 @@ e_canvas_item_show_area (GnomeCanvasItem *item, double x1, double y1, double x2,
e_canvas_show_area(item->canvas, x1, y1, x2, y2);
}
+
+static gboolean
+e_canvas_area_shown (GnomeCanvas *canvas, double x1, double y1, double x2, double y2)
+{
+ GtkAdjustment *h, *v;
+ int dx = 0, dy = 0;
+
+ g_return_val_if_fail (canvas != NULL, FALSE);
+ g_return_val_if_fail (GNOME_IS_CANVAS (canvas), FALSE);
+
+ h = gtk_layout_get_hadjustment(GTK_LAYOUT(canvas));
+ dx = compute_offset(x1, x2, h->value, h->value + h->page_size);
+ if (CLAMP(h->value + dx, h->lower, h->upper - h->page_size) - h->value != 0)
+ return FALSE;
+
+ v = gtk_layout_get_vadjustment(GTK_LAYOUT(canvas));
+ dy = compute_offset(y1, y2, v->value, v->value + v->page_size);
+ if (CLAMP(v->value + dy, v->lower, v->upper - v->page_size) - v->value != 0)
+ return FALSE;
+ return TRUE;
+}
+
+gboolean
+e_canvas_item_area_shown (GnomeCanvasItem *item, double x1, double y1, double x2, double y2)
+{
+ g_return_val_if_fail (item != NULL, FALSE);
+ g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (item), FALSE);
+
+ gnome_canvas_item_i2w(item, &x1, &y1);
+ gnome_canvas_item_i2w(item, &x2, &y2);
+
+ return e_canvas_area_shown(item->canvas, x1, y1, x2, y2);
+}
+
typedef struct {
double x1;
double y1;
diff --git a/widgets/misc/e-canvas-utils.h b/widgets/misc/e-canvas-utils.h
index 97a9989fb9..40eca8237e 100644
--- a/widgets/misc/e-canvas-utils.h
+++ b/widgets/misc/e-canvas-utils.h
@@ -27,9 +27,28 @@
BEGIN_GNOME_DECLS
-void e_canvas_item_move_absolute (GnomeCanvasItem *item, double dx, double dy);
-void e_canvas_item_show_area (GnomeCanvasItem *item, double x1, double y1, double x2, double y2);
-void e_canvas_item_show_area_delayed (GnomeCanvasItem *item, double x1, double y1, double x2, double y2, gint delay);
+void e_canvas_item_move_absolute (GnomeCanvasItem *item,
+ double dx,
+ double dy);
+void e_canvas_item_show_area (GnomeCanvasItem *item,
+ double x1,
+ double y1,
+ double x2,
+ double y2);
+void e_canvas_item_show_area_delayed (GnomeCanvasItem *item,
+ double x1,
+ double y1,
+ double x2,
+ double y2,
+ gint delay);
+/* Returns TRUE if the area is already shown on the screen (including
+ spacing.) This is equivelent to returning FALSE iff show_area
+ would do anything. */
+gboolean e_canvas_item_area_shown (GnomeCanvasItem *item,
+ double x1,
+ double y1,
+ double x2,
+ double y2);
END_GNOME_DECLS