1 /* ATK - Accessibility Toolkit
2 * Copyright 2001 Sun Microsystems Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
23 * This file supports the addition and removal of multiple focus handlers
24 * as long as they are all called in the same thread.
26 static AtkFocusTrackerInit focus_tracker_init = NULL;
28 static gboolean init_done = FALSE;
31 * Array of FocusTracker structs
33 static GArray *trackers = NULL;
34 static guint index = 0;
36 struct _FocusTracker {
40 typedef struct _FocusTracker FocusTracker;
43 atk_focus_tracker_init (AtkFocusTrackerInit init)
45 if (focus_tracker_init == NULL)
46 focus_tracker_init = init;
50 atk_add_focus_tracker (AtkFocusTracker focus_tracker)
52 g_return_val_if_fail ((focus_tracker != NULL), 0);
56 if (focus_tracker_init != NULL)
58 focus_tracker_init ();
60 trackers = g_array_sized_new (FALSE, TRUE, sizeof (FocusTracker), 0);
68 item.func = focus_tracker;
69 trackers = g_array_append_val (trackers, item);
79 atk_remove_focus_tracker (guint tracker_id)
90 for (i = 0; i < trackers->len; i++)
92 item = &g_array_index (trackers, FocusTracker, i);
93 if (item->index == tracker_id)
95 trackers = g_array_remove_index (trackers, i);
102 atk_focus_tracker_notify (AtkObject *object)
107 if (trackers == NULL)
110 for (i = 0; i < trackers->len; i++)
112 item = &g_array_index (trackers, FocusTracker, i);
113 g_return_if_fail (item != NULL);