1 #undef GTK_DISABLE_DEPRECATED
8 * This module is used to test the accessible implementation for GtkOptionMenu
10 * When the GtkOption menu in the FileSelectionDialog is tabbed to, the menu
11 * is opened and the second item in the menu is selected which causes the
12 * menu to be closed and the item in the GtkOptionMenu to be updated.
14 #define NUM_VALID_ROLES 1
16 static void _create_event_watcher (void);
17 static void _check_object (AtkObject *obj);
18 static gint _do_menu_item_action (gpointer data);
19 static gboolean doing_action = FALSE;
22 _check_object (AtkObject *obj)
25 static G_CONST_RETURN char *name = NULL;
26 static gboolean first_time = TRUE;
28 role = atk_object_get_role (obj);
29 if (role == ATK_ROLE_PUSH_BUTTON)
31 * Find the specified optionmenu item
34 AtkRole valid_roles[NUM_VALID_ROLES];
35 AtkObject *atk_option_menu;
40 name = g_getenv ("TEST_ACCESSIBLE_NAME");
44 valid_roles[0] = ATK_ROLE_PUSH_BUTTON;
45 atk_option_menu = find_object_by_accessible_name_and_role (obj, name,
46 valid_roles, NUM_VALID_ROLES);
48 if (atk_option_menu == NULL)
50 g_print ("Object not found for %s\n", name);
55 g_print ("Object found for %s\n", name);
59 g_assert (GTK_IS_ACCESSIBLE (atk_option_menu));
60 widget = GTK_ACCESSIBLE (atk_option_menu)->widget;
61 g_assert (GTK_IS_OPTION_MENU (widget));
69 * This action opens the GtkOptionMenu whose name is "foo" or whatever
70 * was specified in the environment variable TEST_ACCESSIBLE_NAME
72 atk_action_do_action (ATK_ACTION (atk_option_menu), 0);
74 else if ((role == ATK_ROLE_MENU_ITEM) ||
75 (role == ATK_ROLE_CHECK_MENU_ITEM) ||
76 (role == ATK_ROLE_RADIO_MENU_ITEM) ||
77 (role == ATK_ROLE_TEAR_OFF_MENU_ITEM))
79 AtkObject *parent, *child;
83 * If we receive focus while waiting for the menu to be closed
84 * we return immediately
89 parent = atk_object_get_parent (obj);
90 parent_role = atk_object_get_role (parent);
91 g_assert (parent_role == ATK_ROLE_MENU);
93 child = atk_object_ref_accessible_child (parent, 1);
95 g_timeout_add (5000, _do_menu_item_action, child);
99 G_CONST_RETURN char *accessible_name;
101 accessible_name = atk_object_get_name (obj);
104 g_print ("Name: %s\n", accessible_name);
106 else if (GTK_IS_ACCESSIBLE (obj))
108 GtkWidget *widget = GTK_ACCESSIBLE (obj)->widget;
109 g_print ("Type: %s\n", g_type_name (G_OBJECT_TYPE (widget)));
111 if (role == ATK_ROLE_TABLE)
115 n_cols = atk_table_get_n_columns (ATK_TABLE (obj));
116 g_print ("Number of Columns: %d\n", n_cols);
118 for (i = 0; i < n_cols; i++)
122 header = atk_table_get_column_header (ATK_TABLE (obj), i);
123 g_print ("header: %s %s\n",
124 g_type_name (G_OBJECT_TYPE (header)),
125 atk_object_get_name (header));
131 static gint _do_menu_item_action (gpointer data)
133 AtkObject *obj = ATK_OBJECT (data);
135 atk_action_do_action (ATK_ACTION (obj), 0);
136 doing_action = FALSE;
138 g_object_unref (obj);
144 _create_event_watcher (void)
146 atk_add_focus_tracker (_check_object);
150 gtk_module_init(gint argc, char* argv[])
152 g_print("testoptionmenu Module loaded\n");
154 _create_event_watcher();