]> Pileus Git - ~andy/gtk/blob - modules/other/gail/tests/testaction.c
Deprecate flag macros for toplevel, state, no window and composite child
[~andy/gtk] / modules / other / gail / tests / testaction.c
1 #include <string.h>
2 #include <stdlib.h>
3 #include <gtk/gtk.h>
4 #include "testlib.h"
5
6 /*
7  * This module is used to test the implementation of AtkAction,
8  * i.e. the getting of the name and the getting and setting of description
9  */
10
11 static void _create_event_watcher (void);
12 static void _check_object (AtkObject *obj);
13
14 static void 
15 _check_object (AtkObject *obj)
16 {
17   G_CONST_RETURN char *accessible_name;
18   G_CONST_RETURN gchar * typename = NULL;
19
20   if (GTK_IS_ACCESSIBLE (obj))
21   {
22     GtkWidget* widget = NULL;
23
24     widget = GTK_ACCESSIBLE (obj)->widget;
25     typename = g_type_name (G_OBJECT_TYPE (widget));
26     g_print ("Widget type name: %s\n", typename ? typename : "NULL");
27   }
28   typename = g_type_name (G_OBJECT_TYPE (obj));
29   g_print ("Accessible type name: %s\n", typename ? typename : "NULL");
30   accessible_name = atk_object_get_name (obj);
31   if (accessible_name)
32     g_print ("Name: %s\n", accessible_name);
33
34   if (ATK_IS_ACTION (obj))
35   {
36     AtkAction *action = ATK_ACTION (obj);
37     gint n_actions, i;
38     G_CONST_RETURN gchar *action_name;
39     G_CONST_RETURN gchar *action_desc;
40     G_CONST_RETURN gchar *action_binding;
41     const gchar *desc = "Test description";
42  
43     n_actions = atk_action_get_n_actions (action);
44     g_print ("AtkAction supported number of actions: %d\n", n_actions);
45     for (i = 0; i < n_actions; i++)
46     {
47       action_name = atk_action_get_name (action, i);
48       g_print ("Name of Action %d: %s\n", i, action_name);
49       action_binding = atk_action_get_keybinding (action, i);
50       if (action_binding)
51         g_print ("Name of Action Keybinding %d: %s\n", i, action_binding);
52      
53       if (!atk_action_set_description (action, i, desc))
54       {
55         g_print ("atk_action_set_description failed\n");
56       }
57       else
58       {
59         action_desc = atk_action_get_description (action, i);
60         if (strcmp (desc, action_desc) != 0)
61         {
62           g_print ("Problem with setting and getting action description\n");
63         }
64       }
65     } 
66     if (atk_action_set_description (action, n_actions, desc))
67     {
68       g_print ("atk_action_set_description succeeded but should not have\n");
69     }
70   }
71 }
72
73 static void
74 _create_event_watcher (void)
75 {
76   atk_add_focus_tracker (_check_object);
77 }
78
79 int
80 gtk_module_init(gint argc, char* argv[])
81 {
82   g_print("testaction Module loaded\n");
83
84   _create_event_watcher();
85
86   return 0;
87 }