Commit afe43430 authored by billh's avatar billh
Browse files

Added support for Accessible_getRole(). Also provided conversion

from AccessibleRole to string.
Added festival TTS to simple-at test program, used if environment variable
FESTIVAL is set.


git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@60 e2bd861d-eb25-0410-b326-f6ed22b6b98c
parent b7faf0a7
<2001-09-04 Bill Haneman <bill.haneman@sun.com>
* cspi/spi_accessible.c:
Added method Accessible_Role_getName(),
and requisite string array (role_names).
Added conversion string_from_corba_strin() call
to Accessible_getName and _getDescription.
* libspi/accessible.c:
Added implementation for Accessible_getRole()
* test/simple-at.c:
Added festival support, used if environment variable
FESTIVAL is set.
<2001-09-12 Marc Mulcahy <marc.mulcahy@sun.com>
* cspi/Makefile.am:
Added spi-util.c.
......@@ -10,17 +22,20 @@
includes so they are included in libcspi.
* cspi/spi.h:
Changed prototype of AccessibleAction_doAction to return a boolean.
Changed prototype of AccessibleAction_doAction to return a
boolean.
Changed prototype of AccessibleTable_getCaption to
return an Accessible.
Changed prototype of AccessibleTable_getSelectedRows
and AccessibleTable_getSelectedColumns to
return a long (returns the number of selected rows or columns
respectively).
return a long (returns the number of selected rows
or columns respectively).
Changed name of AccessibleText_refRunAttributes to
AccessibleText_getAttributes.
Changed prototype of AccessibleText_getCharacterExtents to return a void rather than a
boolean. Addded support for a AccessibleCoordType parameter specifying what type of coordinates are desired.
Changed prototype of AccessibleText_getCharacterExtents to
return a void rather than a boolean.
Added support for a AccessibleCoordType parameter
specifying what type of coordinates are desired.
Added an AccessibleCordType parameter to
AccessibleText_getPointAtOffset.
......@@ -85,8 +100,9 @@
Change for nAnchors attributte name change.
<2001-09-05 Marc Mulcahy <marc.mulcahy@sun.com>
implementations-- made server implementations own AtkObject pointers
<2001-09-05 Marc Mulcahy <marc.mulcahy@sun.com>
implementations-- made server implementations own AtkObject pointers
rather than their respective AtkInterrface pointers to fix
refcounting. AtkHyperlink is still broken.
......
#define MAX_ROLES 100
static char *role_names [MAX_ROLES] =
{
" ",
"accelerator label",
"alert",
"animation",
"arrow",
"calendar",
"canvas",
"check box",
"menu item",
"color chooser",
"column header",
"combo box",
"date editor",
"desktop icon",
"desktop frame",
"dial",
"dialog",
"directory pane",
"drawing area",
"file chooser",
"filler",
"font chooser",
"frame",
"glass pane",
"HTML container",
"icon",
"image",
"internal frame",
"label",
"layered pane",
"list",
"list item",
"menu",
"menubar",
"menu item",
"option pane",
"page tab",
"page tab list",
"panel",
"password text",
"popup menu",
"progress bar",
"pushbutton",
"radiobutton",
"radio menu item",
"root pane",
"row header",
"scrollbar",
"scrollpane",
"separator",
"slider",
"split pane",
"spin button",
"status bar",
"table",
"table cell",
"table column header",
"table row header",
"tearoff menu item",
"text",
"toggle button",
"toolbar",
"tooltip",
"tree",
" ",
"viewport",
"window",
};
/*
*
* Accessible function prototypes
*
* Returns a localizable string name for an AtkRole enumerated type.
*/
char*
Accessible_Role_getName (Accessibility_Role role)
{
if (role < MAX_ROLES) return role_names [(int) role];
else return "";
}
/**
* Accessible_ref:
......@@ -50,7 +128,8 @@ Accessible_unref (Accessible *obj)
char *
Accessible_getName (Accessible *obj)
{
return Accessibility_Accessible__get_name (*obj, &ev);
return string_from_corba_string (
Accessibility_Accessible__get_name (*obj, &ev));
}
/**
......@@ -65,7 +144,8 @@ Accessible_getName (Accessible *obj)
char *
Accessible_getDescription (Accessible *obj)
{
return Accessibility_Accessible__get_description (*obj, &ev);
return string_from_corba_string (
Accessibility_Accessible__get_description (*obj, &ev));
}
/**
......@@ -164,7 +244,8 @@ Accessible_getRelationSet (Accessible *obj)
char *
Accessible_getRole (Accessible *obj)
{
return "";
return Accessible_Role_getName (
Accessibility_Accessible_getRole (*obj, &ev));
}
/**
......
......@@ -192,6 +192,22 @@ impl_accessibility_accessible_get_child_at_index (PortableServer_Servant servant
return retval;
}
/*
* CORBA Accessibility::Accessible::getRole method implementation
*/
static Accessibility_Role
impl_accessibility_accessible_get_role (PortableServer_Servant servant,
const CORBA_long index,
CORBA_Environment *ev)
{
Accessibility_Role retval;
Accessible *accessible = ACCESSIBLE (bonobo_object_from_servant (servant));
AtkRole role = atk_object_get_role (accessible->atko);
retval = role;
printf ("Accessible get_role.\n");
return (Accessibility_Role) retval;
}
static void
accessible_class_init (AccessibleClass *klass)
{
......@@ -213,7 +229,7 @@ accessible_class_init (AccessibleClass *klass)
/* epv->getRelationSet = impl_accessibility_accessible_get_relation_set; */
/* epv->getState = impl_accessibility_accessible_get_state; */
/* epv->getRole = impl_accessibility_accessible_get_role; */
epv->getRole = impl_accessibility_accessible_get_role;
}
static void
......
......@@ -27,6 +27,13 @@ void report_focus_event (void *fp);
void report_button_press (void *fp);
static int _festival_init ();
static void _festival_say (const char *text, const char *voice, boolean shutup);
static void _festival_write (const char *buff, int fd);
static boolean use_festival = TRUE;
static boolean festival_terse = TRUE;
int
main(int argc, char **argv)
{
......@@ -59,6 +66,12 @@ main(int argc, char **argv)
fprintf (stderr, "app %d name: %s\n", j, Accessible_getName (application));
}
}
if (getenv ("FESTIVAL"))
{
use_festival = TRUE;
}
SPI_event_main(FALSE);
}
......@@ -68,6 +81,16 @@ report_focus_event (void *p)
AccessibleEvent *ev = (AccessibleEvent *) p;
fprintf (stderr, "%s event from %s\n", ev->type,
Accessible_getName (&ev->source));
if (use_festival)
{
if (!festival_terse)
{
_festival_say (Accessible_getRole (&ev->source), "voice_don_diphone", TRUE);
}
_festival_say (Accessible_getName (&ev->source), "voice_kal_diphone", FALSE);
}
if (Accessible_isComponent (&ev->source))
{
long x, y, width, height;
......@@ -87,3 +110,84 @@ report_button_press (void *p)
fprintf (stderr, "%s event from %s\n", ev->type,
Accessible_getName (&ev->source));
}
static int _festival_init ()
{
int fd;
struct sockaddr_in name;
int tries = 2;
name.sin_family = AF_INET;
name.sin_port = htons (1314);
name.sin_addr.s_addr = htonl(INADDR_ANY);
fd = socket (PF_INET, SOCK_STREAM, 0);
while (connect(fd, (struct sockaddr *) &name, sizeof (name)) < 0) {
if (!tries--) {
perror ("connect");
return -1;
}
}
_festival_write ("(audio_mode'async)", fd);
_festival_write ("(Parameter.set 'Duration_Stretch 0.5)", fd);
_festival_write ("(Parameter.set 'Duration_Model 'Tree_ZScore)", fd);
return fd;
}
static void _festival_say (const char *text, const char *voice, boolean shutup)
{
static int fd = 0;
gchar *quoted;
gchar *p;
gchar prefix[50];
gchar voice_spec[32];
if (!fd)
{
fd = _festival_init ();
}
fprintf (stderr, "saying text: %s\n", text);
quoted = g_malloc(64+strlen(text)*2);
sprintf (prefix, "(SayText \"");
strncpy(quoted, prefix, 10);
p = quoted+strlen(prefix);
while (*text) {
if ( *text == '\\' || *text == '"' )
*p = '\\';
*p++ = *text++;
}
*p++ = '"';
*p++ = ')';
*p++ = '\n';
*p = 0;
if(shutup) _festival_write ("(audio_mode'shutup)\n", fd);
if (voice)
{
sprintf (voice_spec, "(%s)\n", voice);
_festival_write (voice_spec, fd);
}
if (!festival_terse)
{
_festival_write ("(Parameter.set 'Duration_Model 'Tree_ZScore)\n", fd);
_festival_write ("(Parameter.set 'Duration_Stretch 0.5)\n", fd);
}
_festival_write (quoted, fd);
g_free(quoted);
}
static void _festival_write (const gchar *command_string, int fd)
{
fprintf(stderr, command_string);
if (fd < 0) {
perror("socket");
return;
}
write(fd, command_string, strlen(command_string));
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment