[PATCH] Implement focus grabbing in AbiWidget

From: Daniel Drake <dsd_at_laptop.org>
Date: Mon Dec 28 2009 - 18:02:47 CET

AbiWidget sets the CAN_FOCUS flag but doesn't implement focus
grabbing. The underlying GtkBin is not a focusable element either.

The Sugar Write activity relies on being able to focus on the
abiword canvas. This worked in previous AbiWord versions where the
AbiWidget underlying widget was something focusable, but does not
work after the conversion to GtkBin.
http://dev.laptop.org/ticket/9748

Implement focus grabbing in terms of focusing on the drawing area,
restoring the previous behaviour.

Index: abiword-2.8.1/src/wp/ap/gtk/abiwidget.cpp
===================================================================
--- abiword-2.8.1.orig/src/wp/ap/gtk/abiwidget.cpp
+++ abiword-2.8.1/src/wp/ap/gtk/abiwidget.cpp
@@ -2066,6 +2066,19 @@ abi_widget_size_allocate (GtkWidget
 }
 
 static void
+abi_widget_grab_focus (GtkWidget * widget)
+{
+ UT_return_if_fail(widget != NULL);
+ UT_return_if_fail(IS_ABI_WIDGET(widget));
+
+ XAP_Frame *pFrame = ABI_WIDGET(widget)->priv->m_pFrame;
+ UT_return_if_fail(pFrame);
+
+ GtkWidget *dArea = static_cast<AP_UnixFrameImpl *>(pFrame->getFrameImpl())->getDrawingArea();
+ gtk_widget_grab_focus(dArea);
+}
+
+static void
 abi_widget_realize (GtkWidget * widget)
 {
         AbiWidget * abi;
@@ -2190,6 +2203,7 @@ abi_widget_class_init (AbiWidgetClass *a
         widget_class->realize = abi_widget_realize;
         widget_class->size_request = abi_widget_size_request;
            widget_class->size_allocate = abi_widget_size_allocate;
+ widget_class->grab_focus = abi_widget_grab_focus;
 
         // For the container methods
         container_class->add = abiwidget_add;
Received on Mon Dec 28 18:03:08 2009

This archive was generated by hypermail 2.1.8 : Mon Dec 28 2009 - 18:03:08 CET