GETENV: check for proper UTF-8.
[gnumeric.git] / src / gnumeric-simple-canvas.c
blob97429d4214853f29d845159c277d11af3c41bde7
1 /* vim: set sw=8: */
2 #include <gnumeric-config.h>
3 #include "gnumeric.h"
4 #include "gnumeric-simple-canvas.h"
6 #include "sheet-control-gui-priv.h"
7 #include "gutils.h"
8 #include <goffice/goffice.h>
9 #include <gsf/gsf-impl-utils.h>
11 static gboolean debug_canvas_grab;
13 static GtkWidgetClass const *parent;
14 static gint
15 gnm_simple_canvas_key_press (GtkWidget *widget, GdkEventKey *event)
17 GnmSimpleCanvas *gcanvas = GNM_SIMPLE_CANVAS (widget);
19 if (gcanvas->scg->grab_stack > 0)
20 return TRUE;
21 return parent->key_press_event (widget, event);
24 static gint
25 gnm_simple_canvas_key_release (GtkWidget *widget, GdkEventKey *event)
27 GnmSimpleCanvas *gcanvas = GNM_SIMPLE_CANVAS (widget);
29 if (gcanvas->scg->grab_stack > 0)
30 return TRUE;
31 return parent->key_release_event (widget, event);
34 static void
35 gnm_simple_canvas_class_init (GtkWidgetClass *klass)
37 parent = g_type_class_peek_parent (klass);
38 klass->key_press_event = gnm_simple_canvas_key_press;
39 klass->key_release_event = gnm_simple_canvas_key_release;
40 debug_canvas_grab = gnm_debug_flag ("canvas-grab");
43 GSF_CLASS (GnmSimpleCanvas, gnm_simple_canvas,
44 gnm_simple_canvas_class_init, NULL,
45 GOC_TYPE_CANVAS)
47 GocCanvas *
48 gnm_simple_canvas_new (SheetControlGUI *scg)
50 GnmSimpleCanvas *gcanvas = g_object_new (GNM_SIMPLE_CANVAS_TYPE, NULL);
51 gcanvas->scg = scg;
53 return GOC_CANVAS (gcanvas);
56 void
57 gnm_simple_canvas_ungrab (GocItem *item)
59 GnmSimpleCanvas *gcanvas = GNM_SIMPLE_CANVAS(item->canvas);
61 g_return_if_fail (gcanvas != NULL);
63 gcanvas->scg->grab_stack--;
64 if (debug_canvas_grab)
65 g_printerr ("Grab dec to %d\n", gcanvas->scg->grab_stack);
66 goc_item_ungrab (item);
69 void
70 gnm_simple_canvas_grab (GocItem *item)
72 GnmSimpleCanvas *gcanvas = GNM_SIMPLE_CANVAS(item->canvas);
74 g_return_if_fail (gcanvas != NULL);
76 gcanvas->scg->grab_stack++;
77 if (debug_canvas_grab)
78 g_printerr ("Grab inc to %d\n", gcanvas->scg->grab_stack);
79 goc_item_grab (item);