[gtk+/font-chooser] Get rid of the focus_gtk vfunc



commit dbf71f0e5e173b6b24a02cfddf3658fe1d3fa433
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jul 17 23:04:00 2011 -0400

    Get rid of the focus_gtk vfunc
    
    Only GtkWidgetAccessible and GtkWindowAccessible had implementations,
    and they could easily be converted to focus_event handlers.

 gtk/a11y/gtkwidgetaccessible.c |   43 +++++++++------------------------------
 gtk/a11y/gtkwidgetaccessible.h |    5 ----
 gtk/a11y/gtkwindowaccessible.c |   15 ++++---------
 3 files changed, 15 insertions(+), 48 deletions(-)
---
diff --git a/gtk/a11y/gtkwidgetaccessible.c b/gtk/a11y/gtkwidgetaccessible.c
index 1826636..c631da9 100644
--- a/gtk/a11y/gtkwidgetaccessible.c
+++ b/gtk/a11y/gtkwidgetaccessible.c
@@ -37,20 +37,18 @@ static void atk_component_interface_init (AtkComponentIface *iface);
 G_DEFINE_TYPE_WITH_CODE (GtkWidgetAccessible, _gtk_widget_accessible, GTK_TYPE_ACCESSIBLE,
                          G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init))
 
-/* Translate GtkWidget::focus-in/out-event to the focus_gtk vfunc */
+/* Translate GtkWidget::focus-in/out-event to AtkObject::focus-event */
 static gboolean
 focus_cb (GtkWidget     *widget,
           GdkEventFocus *event)
 {
-  GtkWidgetAccessible *accessible;
-  GtkWidgetAccessibleClass *klass;
+  AtkObject *obj;
 
-  accessible = GTK_WIDGET_ACCESSIBLE (gtk_widget_get_accessible (widget));
-  klass = GTK_WIDGET_ACCESSIBLE_GET_CLASS (accessible);
-  if (klass->focus_gtk)
-    return klass->focus_gtk (widget, event);
-  else
-    return FALSE;
+  obj = gtk_widget_get_accessible (widget);
+
+  g_signal_emit_by_name (obj, "focus-event", event->in);
+
+  return FALSE;
 }
 
 /* Translate GtkWidget property change notification to the notify_gtk vfunc */
@@ -99,8 +97,8 @@ map_cb (GtkWidget *widget)
 }
 
 static void
-focus_event (AtkObject *obj,
-             gboolean   focus_in)
+gtk_widget_accessible_focus_event (AtkObject *obj,
+                                   gboolean   focus_in)
 {
   AtkObject *focus_obj;
 
@@ -129,8 +127,6 @@ gtk_widget_accessible_initialize (AtkObject *obj,
   g_signal_connect (widget, "map", G_CALLBACK (map_cb), NULL);
   g_signal_connect (widget, "unmap", G_CALLBACK (map_cb), NULL);
 
-  g_signal_connect (accessible, "focus-event", G_CALLBACK (focus_event), NULL);
-
   obj->role = ATK_ROLE_UNKNOWN;
 }
 
@@ -512,25 +508,6 @@ gtk_widget_accessible_notify_gtk (GObject    *obj,
     atk_object_notify_state_change (atk_obj, ATK_STATE_VERTICAL, !value);
 }
 
-/* This function is the default implementation for the focus_gtk
- * vfunc which gets called for focus_in/out_event.
- *
- * It emits a focus-event signal on the GtkWidgetAccessible.
- */
-static gboolean
-gtk_widget_accessible_focus_gtk (GtkWidget     *widget,
-                                 GdkEventFocus *event)
-{
-  AtkObject* accessible;
-  gboolean return_val;
-  return_val = FALSE;
-
-  accessible = gtk_widget_get_accessible (widget);
-
-  g_signal_emit_by_name (accessible, "focus-event", event->in, &return_val);
-  return FALSE;
-}
-
 static AtkAttributeSet *
 gtk_widget_accessible_get_attributes (AtkObject *obj)
 {
@@ -553,7 +530,6 @@ _gtk_widget_accessible_class_init (GtkWidgetAccessibleClass *klass)
   GtkAccessibleClass *accessible_class = GTK_ACCESSIBLE_CLASS (klass);
 
   klass->notify_gtk = gtk_widget_accessible_notify_gtk;
-  klass->focus_gtk = gtk_widget_accessible_focus_gtk;
 
   accessible_class->connect_widget_destroyed = gtk_widget_accessible_connect_widget_destroyed;
 
@@ -564,6 +540,7 @@ _gtk_widget_accessible_class_init (GtkWidgetAccessibleClass *klass)
   class->get_index_in_parent = gtk_widget_accessible_get_index_in_parent;
   class->initialize = gtk_widget_accessible_initialize;
   class->get_attributes = gtk_widget_accessible_get_attributes;
+  class->focus_event = gtk_widget_accessible_focus_event;
 }
 
 static void
diff --git a/gtk/a11y/gtkwidgetaccessible.h b/gtk/a11y/gtkwidgetaccessible.h
index 4b2059b..5d78d17 100644
--- a/gtk/a11y/gtkwidgetaccessible.h
+++ b/gtk/a11y/gtkwidgetaccessible.h
@@ -48,11 +48,6 @@ struct _GtkWidgetAccessibleClass
    */
   void (*notify_gtk)                   (GObject             *object,
                                         GParamSpec          *pspec);
-  /*
-   * Signal handler for focus_in_event and focus_out_event signal on GTK widget
-   */
-  gboolean (*focus_gtk)                (GtkWidget           *widget,
-                                        GdkEventFocus       *event);
 
 };
 
diff --git a/gtk/a11y/gtkwindowaccessible.c b/gtk/a11y/gtkwindowaccessible.c
index d7d35b1..815577b 100644
--- a/gtk/a11y/gtkwindowaccessible.c
+++ b/gtk/a11y/gtkwindowaccessible.c
@@ -58,16 +58,11 @@ G_DEFINE_TYPE_WITH_CODE (GtkWindowAccessible, _gtk_window_accessible, GTK_TYPE_C
                          G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init))
 
 
-static gboolean
-gtk_window_accessible_focus_gtk (GtkWidget     *widget,
-                                 GdkEventFocus *event)
+static void
+gtk_window_accessible_focus_event (AtkObject *obj,
+                                   gboolean   focus_in)
 {
-  AtkObject* obj;
-
-  obj = gtk_widget_get_accessible (widget);
-  atk_object_notify_state_change (obj, ATK_STATE_ACTIVE, event->in);
-
-  return FALSE;
+  atk_object_notify_state_change (obj, ATK_STATE_ACTIVE, focus_in);
 }
 
 static void
@@ -321,7 +316,6 @@ _gtk_window_accessible_class_init (GtkWindowAccessibleClass *klass)
   GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass;
   AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
 
-  widget_class->focus_gtk = gtk_window_accessible_focus_gtk;
   widget_class->notify_gtk = gtk_window_accessible_notify_gtk;
 
   class->get_name = gtk_window_accessible_get_name;
@@ -329,6 +323,7 @@ _gtk_window_accessible_class_init (GtkWindowAccessibleClass *klass)
   class->ref_relation_set = gtk_window_accessible_ref_relation_set;
   class->ref_state_set = gtk_window_accessible_ref_state_set;
   class->initialize = gtk_window_accessible_initialize;
+  class->focus_event = gtk_window_accessible_focus_event;
 
   gtk_window_accessible_signals [ACTIVATE] =
     g_signal_new ("activate",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]