2 #include <gnumeric-config.h>
4 #include "gnumeric-simple-canvas.h"
6 #include "sheet-control-gui-priv.h"
8 #include <goffice/goffice.h>
9 #include <gsf/gsf-impl-utils.h>
11 static gboolean debug_canvas_grab
;
13 static GtkWidgetClass
const *parent
;
15 gnm_simple_canvas_key_press (GtkWidget
*widget
, GdkEventKey
*event
)
17 GnmSimpleCanvas
*gcanvas
= GNM_SIMPLE_CANVAS (widget
);
19 if (gcanvas
->scg
->grab_stack
> 0)
21 return parent
->key_press_event (widget
, event
);
25 gnm_simple_canvas_key_release (GtkWidget
*widget
, GdkEventKey
*event
)
27 GnmSimpleCanvas
*gcanvas
= GNM_SIMPLE_CANVAS (widget
);
29 if (gcanvas
->scg
->grab_stack
> 0)
31 return parent
->key_release_event (widget
, event
);
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
,
48 gnm_simple_canvas_new (SheetControlGUI
*scg
)
50 GnmSimpleCanvas
*gcanvas
= g_object_new (GNM_SIMPLE_CANVAS_TYPE
, NULL
);
53 return GOC_CANVAS (gcanvas
);
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
);
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
);