move everything into a clutter/ directory

This commit is contained in:
Rui Matos
2016-04-08 22:42:15 +02:00
parent 4848d79c26
commit 9710e4a8c0
512 changed files with 730 additions and 730 deletions

View File

@@ -0,0 +1,34 @@
common_ldadd = \
$(top_builddir)/clutter/libmutter-clutter-@CLUTTER_API_VERSION@.la
common_sources = \
cally-examples-util.c \
cally-examples-util.h
AM_CPPFLAGS = \
-DPREFIXDIR=\"$(libdir)\" \
-DCLUTTER_DISABLE_DEPRECATION_WARNINGS \
-DGLIB_DISABLE_DEPRECATION_WARNINGS \
-I$(top_srcdir) \
-I$(top_builddir) \
-I$(top_srcdir)/clutter \
-I$(top_builddir)/clutter \
-I$(top_srcdir)/tests/accessibility
AM_CFLAGS = $(CLUTTER_CFLAGS) $(MAINTAINER_CFLAGS)
LDADD = $(common_ldadd) $(CLUTTER_LIBS)
check_PROGRAMS = \
cally-atkcomponent-example \
cally-atkeditabletext-example \
cally-atkevents-example \
cally-atktext-example \
cally-clone-example
cally_atkcomponent_example_SOURCES = $(common_sources) cally-atkcomponent-example.c
cally_atktext_example_SOURCES = $(common_sources) cally-atktext-example.c
cally_atkevents_example_SOURCES = $(common_sources) cally-atkevents-example.c
cally_atkeditabletext_example_SOURCES = $(common_sources) cally-atkeditabletext-example.c
cally_clone_example_SOURCES = $(common_sources) cally-clone-example.c
DISTCLEANFILES =

View File

@@ -0,0 +1,94 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2009 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <clutter/clutter.h>
#include "cally-examples-util.h"
#define WIDTH 300
#define HEIGHT 300
#define SIZE 50
#define DEPTH -100
int
main (int argc, char *argv[])
{
ClutterActor *stage = NULL;
ClutterActor *button1 = NULL;
ClutterActor *button2 = NULL;
ClutterActor *button3 = NULL;
ClutterActor *button4 = NULL;
ClutterActor *group[4];
int i = 0;
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
cally_util_a11y_init (&argc, &argv);
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - AtkComponent Test");
clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_White);
clutter_actor_set_size (stage, WIDTH, HEIGHT);
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
button1 = clutter_rectangle_new_with_color (CLUTTER_COLOR_Yellow);
clutter_actor_set_size (button1, SIZE, SIZE);
button2 = clutter_rectangle_new_with_color (CLUTTER_COLOR_Green);
clutter_actor_set_position (button2, 2 * SIZE, 0);
clutter_actor_set_size (button2, SIZE, SIZE);
button3 = clutter_rectangle_new_with_color (CLUTTER_COLOR_Blue);
clutter_actor_set_position (button3, 0, 2 * SIZE);
clutter_actor_set_size (button3, SIZE, SIZE);
clutter_actor_set_depth( button3, DEPTH);
/* a nested hierarchy, to check that the relative positions are
computed properly */
button4 = clutter_rectangle_new_with_color (CLUTTER_COLOR_Magenta);
clutter_actor_set_position (button4, SIZE / 2, SIZE / 2);
clutter_actor_set_size (button4, SIZE, SIZE);
for (i = 0; i < 4; i++) {
group[i] = clutter_group_new ();
clutter_actor_set_position (group[i], SIZE / 2, SIZE / 2);
clutter_actor_set_size (group[i], SIZE, SIZE);
if (i > 0)
clutter_container_add_actor (CLUTTER_CONTAINER (group[i]), group [i - 1]);
}
clutter_container_add_actor (CLUTTER_CONTAINER (stage), button1);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), button2);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), button3);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), group[3]);
clutter_container_add_actor (CLUTTER_CONTAINER (group[0]), button4);
clutter_actor_show (stage);
clutter_main ();
return 0;
}

View File

@@ -0,0 +1,268 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2009 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <atk/atk.h>
#include <clutter/clutter.h>
#include "cally-examples-util.h"
#define WIDTH 800
#define HEIGHT 600
static ClutterActor *text_actor = NULL;
static ClutterActor *text_editable_actor = NULL;
/*
* Test AtkText interface
*/
static void
test_atk_text (ClutterActor *actor)
{
AtkObject *object = NULL;
AtkEditableText *cally_editable_text = NULL;
gint pos = 0;
object = atk_gobject_accessible_for_object (G_OBJECT (actor));
cally_editable_text = ATK_EDITABLE_TEXT (object);
if (cally_editable_text != NULL) {
atk_editable_text_set_text_contents (cally_editable_text, "New text");
atk_editable_text_delete_text (cally_editable_text, 0, 3);
pos = 3;
atk_editable_text_insert_text (cally_editable_text, "New", 0, &pos);
/* Not implemented in cally, just checking that we can call this
functions */
atk_editable_text_copy_text (cally_editable_text, 0, -1);
atk_editable_text_paste_text (cally_editable_text, 5);
atk_editable_text_cut_text (cally_editable_text, 0, -1);
}
}
static gboolean
insert_text_press_cb (ClutterActor *actor,
ClutterButtonEvent *event,
gpointer data)
{
AtkObject *object = NULL;
AtkEditableText *cally_editable_text = NULL;
gint pos = 0;
object = atk_gobject_accessible_for_object (G_OBJECT (text_editable_actor));
cally_editable_text = ATK_EDITABLE_TEXT (object);
pos = 3;
atk_editable_text_insert_text (cally_editable_text, "New", 0, &pos);
return TRUE;
}
static gboolean
delete_text_press_cb (ClutterActor *actor,
ClutterButtonEvent *event,
gpointer data)
{
AtkObject *object = NULL;
AtkEditableText *cally_editable_text = NULL;
object = atk_gobject_accessible_for_object (G_OBJECT (text_editable_actor));
cally_editable_text = ATK_EDITABLE_TEXT (object);
atk_editable_text_delete_text (cally_editable_text, 0, 3);
return TRUE;
}
static gboolean
set_text_press_cb (ClutterActor *actor,
ClutterButtonEvent *event,
gpointer data)
{
AtkObject *object = NULL;
AtkEditableText *cally_editable_text = NULL;
object = atk_gobject_accessible_for_object (G_OBJECT (text_editable_actor));
cally_editable_text = ATK_EDITABLE_TEXT (object);
atk_editable_text_set_text_contents (cally_editable_text, "New text");
return TRUE;
}
static gboolean
activate_deactivate_press_cb (ClutterActor *actor,
ClutterButtonEvent *event,
gpointer data)
{
gboolean active = FALSE;
active = clutter_text_get_activatable (CLUTTER_TEXT (text_editable_actor));
clutter_text_set_activatable (CLUTTER_TEXT (text_editable_actor), !active);
return TRUE;
}
static gboolean
print_cursor_position_press_cb (ClutterActor *actor,
ClutterButtonEvent *event,
gpointer data)
{
gint pos = 0;
pos = clutter_text_get_cursor_position (CLUTTER_TEXT (text_editable_actor));
g_print ("current cursor position %i\n", pos);
return TRUE;
}
static void
activate_cb (ClutterActor *actor,
gpointer data)
{
g_print ("Actor activated\n");
}
static ClutterActor*
_create_button (const gchar *text)
{
ClutterActor *button = NULL;
ClutterActor *rectangle = NULL;
ClutterActor *label = NULL;
button = clutter_group_new ();
rectangle = clutter_rectangle_new_with_color (CLUTTER_COLOR_Magenta);
clutter_actor_set_size (rectangle, 375, 35);
label = clutter_text_new_full ("Sans Bold 32px",
text,
CLUTTER_COLOR_Black);
clutter_container_add_actor (CLUTTER_CONTAINER (button), rectangle);
clutter_container_add_actor (CLUTTER_CONTAINER (button), label);
clutter_actor_set_reactive (button, TRUE);
return button;
}
static void
make_ui (ClutterActor *stage)
{
ClutterActor *button = NULL;
clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - AtkEditable Test");
clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_White);
clutter_actor_set_size (stage, WIDTH, HEIGHT);
/* text */
text_actor = clutter_text_new_full ("Sans Bold 32px",
"Lorem ipsum dolor sit amet",
CLUTTER_COLOR_Red);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), text_actor);
/* text_editable */
text_editable_actor = clutter_text_new_full ("Sans Bold 32px",
"consectetur adipisicing elit",
CLUTTER_COLOR_Red);
clutter_actor_set_position (text_editable_actor, 0, 100);
clutter_text_set_editable (CLUTTER_TEXT (text_editable_actor), TRUE);
clutter_text_set_selectable (CLUTTER_TEXT (text_editable_actor), TRUE);
clutter_text_set_selection_color (CLUTTER_TEXT (text_editable_actor),
CLUTTER_COLOR_Green);
clutter_text_set_activatable (CLUTTER_TEXT (text_editable_actor),
TRUE);
clutter_text_set_line_wrap (CLUTTER_TEXT (text_editable_actor), TRUE);
clutter_actor_grab_key_focus (text_editable_actor);
clutter_actor_set_reactive (text_editable_actor, TRUE);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), text_editable_actor);
g_signal_connect (text_editable_actor, "activate",
G_CALLBACK (activate_cb), NULL);
/* test buttons */
button = _create_button ("Set");
clutter_actor_set_position (button, 100, 200);
g_signal_connect_after (button, "button-press-event",
G_CALLBACK (set_text_press_cb), NULL);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), button);
button = _create_button ("Delete");
clutter_actor_set_position (button, 100, 250);
g_signal_connect_after (button, "button-press-event",
G_CALLBACK (delete_text_press_cb), NULL);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), button);
button = _create_button ("Insert");
clutter_actor_set_position (button, 100, 300);
g_signal_connect_after (button, "button-press-event",
G_CALLBACK (insert_text_press_cb), NULL);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), button);
button = _create_button ("Activate/Deactivate");
clutter_actor_set_position (button, 100, 350);
g_signal_connect_after (button, "button-press-event",
G_CALLBACK (activate_deactivate_press_cb), NULL);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), button);
button = _create_button ("Cursor position");
clutter_actor_set_position (button, 100, 450);
g_signal_connect_after (button, "button-press-event",
G_CALLBACK (print_cursor_position_press_cb), NULL);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), button);
}
int
main (int argc, char *argv[])
{
ClutterActor *stage = NULL;
g_set_application_name ("AtkEditableText");
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
cally_util_a11y_init (&argc, &argv);
stage = clutter_stage_new ();
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
make_ui (stage);
clutter_actor_show_all (stage);
test_atk_text (text_actor);
test_atk_text (text_editable_actor);
clutter_main ();
return 0;
}

View File

@@ -0,0 +1,196 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2009 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* The purpose of this example is test key event and global event
* implementation, specifically:
*
* atk_add_global_event_listener
* atk_remove_global_event_listener
* atk_add_key_event_listener
* atk_remove_key_event_listener
*/
#include <atk/atk.h>
#include <clutter/clutter.h>
#include <cally/cally.h>
#include "cally-examples-util.h"
#define WIDTH 800
#define HEIGHT 600
#define HEIGHT_STEP 100
#define NUM_ENTRIES 3
struct _Data{
gint value;
};
typedef struct _Data Data;
static gboolean
atk_key_listener (AtkKeyEventStruct *event, gpointer data)
{
Data *my_data = (Data*) data;
g_print ("atk_listener: 0x%x ", event->keyval);
if (my_data != NULL) {
g_print ("\t Data value: %i\n", my_data->value);
} else {
g_print ("\tNo data!!\n");
}
return FALSE;
}
static gboolean
window_event_listener (GSignalInvocationHint * signal_hint,
guint n_param_values,
const GValue * param_values, gpointer data)
{
AtkObject *accessible;
GSignalQuery signal_query;
const gchar *name, *s;
g_signal_query (signal_hint->signal_id, &signal_query);
name = signal_query.signal_name;
accessible = ATK_OBJECT (g_value_get_object (&param_values[0]));
s = atk_object_get_name (accessible);
g_print ("Detected window event \"%s\" from object \"%p\" named \"%s\"\n",
name, accessible, s);
return TRUE;
}
static void
make_ui (ClutterActor *stage)
{
gint i = 0;
ClutterActor *editable = NULL;
ClutterActor *rectangle = NULL;
ClutterActor *label = NULL;
ClutterColor color_sel = { 0x00, 0xff, 0x00, 0x55 };
ClutterColor color_label = { 0x00, 0xff, 0x55, 0xff };
ClutterColor color_rect = { 0x00, 0xff, 0xff, 0x55 };
float label_geom_y, editable_geom_y;
clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_White);
clutter_actor_set_size (stage, WIDTH, HEIGHT);
label_geom_y = 50;
editable_geom_y = 50;
for (i = 0; i < NUM_ENTRIES; i++)
{
/* label */
label = clutter_text_new_full ("Sans Bold 32px",
"Entry",
&color_label);
clutter_actor_set_position (label, 0, label_geom_y);
/* editable */
editable = clutter_text_new_full ("Sans Bold 32px",
"ddd",
CLUTTER_COLOR_Red);
clutter_actor_set_position (editable, 150, editable_geom_y);
clutter_actor_set_size (editable, 500, 75);
clutter_text_set_editable (CLUTTER_TEXT (editable), TRUE);
clutter_text_set_selectable (CLUTTER_TEXT (editable), TRUE);
clutter_text_set_selection_color (CLUTTER_TEXT (editable),
&color_sel);
clutter_actor_grab_key_focus (editable);
clutter_actor_set_reactive (editable, TRUE);
/* rectangle: to create a entry "feeling" */
rectangle = clutter_rectangle_new_with_color (&color_rect);
clutter_actor_set_position (rectangle, 150, editable_geom_y);
clutter_actor_set_size (rectangle, 500, 75);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), label);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), editable);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), rectangle);
label_geom_y += HEIGHT_STEP;
editable_geom_y += HEIGHT_STEP;
}
}
int
main (int argc, char *argv[])
{
ClutterActor *stage, *stage_main;
Data data1, data2, data3;
guint id_1 = 0, id_2 = 0, id_3 = 0;
g_set_application_name ("AtkText");
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
if (cally_util_a11y_init (&argc, &argv) == FALSE)
{
g_error ("This example requires the accessibility support, "
"especifically AtkUtil implementation loaded, "
"as it tries to register and remove event listeners");
}
data1.value = 10;
data2.value = 20;
data3.value = 30;
/* key event listeners */
id_1 = atk_add_key_event_listener ((AtkKeySnoopFunc)atk_key_listener, &data1);
atk_remove_key_event_listener (id_1);
id_2 = atk_add_key_event_listener ((AtkKeySnoopFunc)atk_key_listener, &data2);
id_3 = atk_add_key_event_listener ((AtkKeySnoopFunc)atk_key_listener, &data3);
atk_remove_key_event_listener (id_2);
g_print ("key event listener ids registered: (%i, %i, %i)\n", id_1, id_2, id_3);
/* event listeners */
atk_add_global_event_listener (window_event_listener, "Atk:AtkWindow:create");
atk_add_global_event_listener (window_event_listener, "Atk:AtkWindow:destroy");
atk_add_global_event_listener (window_event_listener, "Atk:AtkWindow:activate");
atk_add_global_event_listener (window_event_listener, "Atk:AtkWindow:deactivate");
stage_main = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage_main), "Cally - AtkEvents/1");
g_signal_connect (stage_main, "destroy", G_CALLBACK (clutter_main_quit), NULL);
make_ui (stage_main);
clutter_actor_show_all (stage_main);
if (clutter_feature_available (CLUTTER_FEATURE_STAGE_MULTIPLE))
{
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - AtkEvents/2");
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
make_ui (stage);
clutter_actor_show_all (stage);
}
clutter_main ();
return 0;
}

View File

@@ -0,0 +1,268 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2009 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <atk/atk.h>
#include <clutter/clutter.h>
#include "cally-examples-util.h"
#define WIDTH 800
#define HEIGHT 600
static ClutterActor *text_actor = NULL;
static ClutterActor *text_editable_actor = NULL;
/*
* Test AtkText interface
*/
static void
test_atk_text (ClutterActor *actor)
{
gchar *text = NULL;
AtkObject *object = NULL;
AtkText *cally_text = NULL;
gboolean bool = FALSE;
gunichar unichar;
gint count = -1;
gint start = -1;
gint end = -1;
gint pos = -1;
AtkAttributeSet *at_set = NULL;
GSList *attrs;
gchar *buf;
gint x, y, width, height;
object = atk_gobject_accessible_for_object (G_OBJECT (actor));
cally_text = ATK_TEXT (object);
if (!cally_text)
return;
text = atk_text_get_text (cally_text, 0, -1);
g_print ("atk_text_get_text output: %s\n", text);
unichar = atk_text_get_character_at_offset (cally_text, 5);
buf = g_ucs4_to_utf8 (&unichar, 1, NULL, NULL, NULL);
g_print ("atk_text_get_character_at_offset(5): '%s' vs '%c'\n", buf, text[5]);
g_free (text); text = NULL;
g_free (buf); buf = NULL;
text = atk_text_get_text_before_offset (cally_text,
5, ATK_TEXT_BOUNDARY_WORD_END,
&start, &end);
g_print ("atk_text_get_text_before_offset: %s, %i, %i\n",
text, start, end);
g_free (text); text = NULL;
text = atk_text_get_text_at_offset (cally_text,
5, ATK_TEXT_BOUNDARY_WORD_END,
&start, &end);
g_print ("atk_text_get_text_at_offset: %s, %i, %i\n",
text, start, end);
g_free (text); text = NULL;
text = atk_text_get_text_after_offset (cally_text,
5, ATK_TEXT_BOUNDARY_WORD_END,
&start, &end);
g_print ("atk_text_get_text_after_offset: %s, %i, %i\n",
text, start, end);
g_free (text); text = NULL;
pos = atk_text_get_caret_offset (cally_text);
g_print ("atk_text_get_caret_offset: %i\n", pos);
atk_text_set_caret_offset (cally_text, 5);
count = atk_text_get_character_count (cally_text);
g_print ("atk_text_get_character_count: %i\n", count);
count = atk_text_get_n_selections (cally_text);
g_print ("atk_text_get_n_selections: %i\n", count);
text = atk_text_get_selection (cally_text, 0, &start, &end);
g_print ("atk_text_get_selection: %s, %i, %i\n", text, start, end);
g_free(text); text = NULL;
bool = atk_text_remove_selection (cally_text, 0);
g_print ("atk_text_remove_selection (0): %i\n", bool);
bool = atk_text_remove_selection (cally_text, 1);
g_print ("atk_text_remove_selection (1): %i\n", bool);
bool = atk_text_add_selection (cally_text, 5, 10);
g_print ("atk_text_add_selection: %i\n", bool);
bool = atk_text_set_selection (cally_text, 0, 6, 10);
g_print ("atk_text_set_selection: %i\n", bool);
at_set = atk_text_get_run_attributes (cally_text, 0,
&start, &end);
g_print ("atk_text_get_run_attributes: %i, %i\n", start, end);
attrs = (GSList*) at_set;
while (attrs)
{
AtkAttribute *at = (AtkAttribute *) attrs->data;
g_print ("text run %s = %s\n", at->name, at->value);
attrs = g_slist_next (attrs);
}
atk_text_get_character_extents (cally_text, 0, &x, &y, &width, &height,
ATK_XY_WINDOW);
g_print ("atk_text_get_character_extents (0, window): x=%i y=%i width=%i height=%i\n",
x, y, width, height);
atk_text_get_character_extents (cally_text, 0, &x, &y, &width, &height,
ATK_XY_SCREEN);
g_print ("atk_text_get_character_extents (0, screen): x=%i y=%i width=%i height=%i\n",
x, y, width, height);
pos = atk_text_get_offset_at_point (cally_text, 200, 10, ATK_XY_WINDOW);
g_print ("atk_text_get_offset_at_point (200, 10, window): %i\n", pos);
pos = atk_text_get_offset_at_point (cally_text, 200, 100, ATK_XY_SCREEN);
g_print ("atk_text_get_offset_at_point (200, 100, screen): %i\n", pos);
}
static void
dump_actor_default_atk_attributes (ClutterActor *actor)
{
AtkObject *object = NULL;
AtkText *cally_text = NULL;
AtkAttributeSet *at_set = NULL;
GSList *attrs;
const gchar *text_value = NULL;
object = atk_gobject_accessible_for_object (G_OBJECT (actor));
cally_text = ATK_TEXT (object);
if (!cally_text)
return;
text_value = clutter_text_get_text (CLUTTER_TEXT (actor));
g_print ("text value = %s\n", text_value);
at_set = atk_text_get_default_attributes (cally_text);
attrs = (GSList*) at_set;
while (attrs) {
AtkAttribute *at = (AtkAttribute *) attrs->data;
g_print ("text default %s = %s\n", at->name, at->value);
attrs = g_slist_next (attrs);
}
}
static gboolean
button_press_cb (ClutterActor *actor,
ClutterButtonEvent *event,
gpointer data)
{
test_atk_text (text_actor);
test_atk_text (text_editable_actor);
return TRUE;
}
static void
make_ui (ClutterActor *stage)
{
ClutterColor color_stage = { 0x00, 0x00, 0x00, 0xff };
ClutterColor color_text = { 0xff, 0x00, 0x00, 0xff };
ClutterColor color_sel = { 0x00, 0xff, 0x00, 0x55 };
ClutterColor color_rect = { 0x00, 0xff, 0xff, 0xff };
ClutterColor color_label = { 0x00, 0x00, 0x00, 0xff };
ClutterActor *button = NULL;
ClutterActor *rectangle = NULL;
ClutterActor *label = NULL;
clutter_stage_set_color (CLUTTER_STAGE (stage), &color_stage);
clutter_actor_set_size (stage, WIDTH, HEIGHT);
/* text */
text_actor = clutter_text_new_full ("Sans Bold 32px",
"",
&color_text);
clutter_text_set_markup (CLUTTER_TEXT(text_actor),
"<span fgcolor=\"#FFFF00\" bgcolor=\"#00FF00\"><s>Lorem ipsum dolor sit amet</s></span>");
clutter_container_add_actor (CLUTTER_CONTAINER (stage), text_actor);
dump_actor_default_atk_attributes (text_actor);
/* text_editable */
text_editable_actor = clutter_text_new_full ("Sans Bold 32px",
"consectetur adipisicing elit",
&color_text);
clutter_actor_set_position (text_editable_actor, 20, 100);
clutter_text_set_editable (CLUTTER_TEXT (text_editable_actor), TRUE);
clutter_text_set_selectable (CLUTTER_TEXT (text_editable_actor), TRUE);
clutter_text_set_selection_color (CLUTTER_TEXT (text_editable_actor),
&color_sel);
clutter_text_set_line_wrap (CLUTTER_TEXT (text_editable_actor), TRUE);
clutter_actor_grab_key_focus (text_editable_actor);
clutter_actor_set_reactive (text_editable_actor, TRUE);
dump_actor_default_atk_attributes (text_editable_actor);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), text_editable_actor);
/* test button */
button = clutter_group_new ();
rectangle = clutter_rectangle_new_with_color (&color_rect);
clutter_actor_set_size (rectangle, 75, 35);
label = clutter_text_new_full ("Sans Bold 32px",
"Test", &color_label);
clutter_actor_set_position (button, 100, 200);
clutter_container_add_actor (CLUTTER_CONTAINER (button), rectangle);
clutter_container_add_actor (CLUTTER_CONTAINER (button), label);
clutter_actor_set_reactive (button, TRUE);
g_signal_connect_after (button, "button-press-event",
G_CALLBACK (button_press_cb), NULL);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), button);
}
int
main (int argc, char *argv[])
{
ClutterActor *stage;
g_set_application_name ("AtkText");
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
cally_util_a11y_init (&argc, &argv);
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - AtkText Test");
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
make_ui (stage);
clutter_actor_show_all (stage);
test_atk_text (text_actor);
test_atk_text (text_editable_actor);
clutter_main ();
return 0;
}

View File

@@ -0,0 +1,116 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2009 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <atk/atk.h>
#include <clutter/clutter.h>
#include "cally-examples-util.h"
#define WIDTH 800
#define HEIGHT 600
#define HEIGHT_STEP 100
#define NUM_ENTRIES 3
static void
make_ui (ClutterActor *stage)
{
ClutterActor *editable = NULL;
ClutterActor *rectangle = NULL;
ClutterActor *label = NULL;
ClutterColor color_stage = { 0x00, 0x00, 0x00, 0xff };
ClutterColor color_text = { 0xff, 0x00, 0x00, 0xff };
ClutterColor color_sel = { 0x00, 0xff, 0x00, 0x55 };
ClutterColor color_label = { 0x00, 0xff, 0x55, 0xff };
ClutterColor color_rect = { 0x00, 0xff, 0xff, 0x55 };
ClutterActor *full_entry = NULL;
ClutterActor *cloned_entry = NULL;
clutter_stage_set_color (CLUTTER_STAGE (stage), &color_stage);
clutter_actor_set_size (stage, WIDTH, HEIGHT);
label = clutter_text_new_full ("Sans Bold 32px",
"Entry",
&color_label);
clutter_actor_set_position (label, 0, 50);
/* editable */
editable = clutter_text_new_full ("Sans Bold 32px",
"ddd",
&color_text);
clutter_actor_set_position (editable, 150, 50);
clutter_text_set_editable (CLUTTER_TEXT (editable), TRUE);
clutter_text_set_selectable (CLUTTER_TEXT (editable), TRUE);
clutter_text_set_selection_color (CLUTTER_TEXT (editable),
&color_sel);
clutter_actor_grab_key_focus (editable);
clutter_actor_set_reactive (editable, TRUE);
/* rectangle: to create a entry "feeling" */
rectangle = clutter_rectangle_new_with_color (&color_rect);
clutter_actor_set_position (rectangle, 150, 50);
clutter_actor_add_constraint (rectangle, clutter_bind_constraint_new (editable, CLUTTER_BIND_SIZE, 0));
full_entry = clutter_group_new ();
clutter_actor_set_position (full_entry, 0, 50);
clutter_actor_set_size (full_entry, 100, 75);
clutter_container_add_actor (CLUTTER_CONTAINER (full_entry), label);
clutter_container_add_actor (CLUTTER_CONTAINER (full_entry), editable);
clutter_container_add_actor (CLUTTER_CONTAINER (full_entry), rectangle);
clutter_actor_show_all (full_entry);
clutter_actor_set_scale (full_entry, 2, 1);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), full_entry);
/* Cloning! */
cloned_entry = clutter_clone_new (full_entry);
clutter_actor_set_position (cloned_entry, 50, 200);
clutter_actor_set_scale (cloned_entry, 1, 2);
clutter_actor_show_all (cloned_entry);
clutter_actor_set_reactive (cloned_entry, TRUE);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), cloned_entry);
}
int
main (int argc, char *argv[])
{
ClutterActor *stage;
g_set_application_name ("Clone Example");
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
cally_util_a11y_init (&argc, &argv);
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - Clone Test");
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
make_ui (stage);
clutter_actor_show_all (stage);
clutter_main ();
return 0;
}

View File

@@ -0,0 +1,146 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2009 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gmodule.h>
#include <stdlib.h>
#include <clutter/clutter.h>
#include "cally-examples-util.h"
/* Checking the at-spi sources, the module directory is
* $(libdir)/gtk-2.0/modules
*
* It is supposed cally would be installed on the same libdir.
*
* You could use the option atk-bridge-dir to use other directory.
*/
#define ATK_BRIDGE_DEFAULT_MODULE_DIRECTORY PREFIXDIR"/gtk-2.0/modules"
static gchar *
_search_for_bridge_module (const gchar *module_name)
{
/* We simplify the search for the atk bridge, see see the definition
* of the macro for more information*/
return g_strdup (ATK_BRIDGE_DEFAULT_MODULE_DIRECTORY);
}
static gchar*
_a11y_check_custom_bridge (int *argc,
char ***argv)
{
GError *error = NULL;
GOptionContext *context;
static gchar *bridge_dir = NULL;
static GOptionEntry entries [] =
{
{"atk-bridge-dir", 'd', 0, G_OPTION_ARG_STRING, &bridge_dir, "atk-bridge module directory", NULL}
};
context = g_option_context_new ("- cally examples");
g_option_context_add_main_entries (context, entries, NULL);
if (!g_option_context_parse (context, argc, argv, &error))
{
g_print ("%s\n", error->message);
g_print ("Use --help for more information.\n");
exit (0);
}
return bridge_dir;
}
static gboolean
_a11y_invoke_module (const gchar *module_path,
gboolean init)
{
GModule *handle;
void (*invoke_fn) (void);
const char *method;
if (init)
method = "gnome_accessibility_module_init";
else
method = "gnome_accessibility_module_shutdown";
if (!module_path)
return FALSE;
if (!(handle = g_module_open (module_path, G_MODULE_BIND_LAZY)))
{
g_warning ("Accessibility: failed to load module '%s': '%s'",
module_path, g_module_error ());
return FALSE;
}
if (!g_module_symbol (handle, method, (gpointer *)&invoke_fn))
{
g_warning ("Accessibility: error library '%s' does not include "
"method '%s' required for accessibility support",
module_path, method);
g_module_close (handle);
return FALSE;
}
g_debug ("Module %s loaded successfully", module_path);
invoke_fn ();
return TRUE;
}
/**
* This method will initialize the accessibility support provided by cally.
*
* Basically it will load the cally module using gmodule functions.
*
* Returns if it was able to init the a11y support or not.
*/
gboolean
cally_util_a11y_init (int *argc, char ***argv)
{
gchar *bridge_dir = NULL;
gchar *bridge_path = NULL;
gboolean result = FALSE;
if (clutter_get_accessibility_enabled () == FALSE)
{
g_warning ("Accessibility: clutter has no accessibility enabled"
" skipping the atk-bridge load");
return FALSE;
}
bridge_dir = _a11y_check_custom_bridge (argc, argv);
if (bridge_dir == NULL)
bridge_dir = _search_for_bridge_module ("atk-bridge");
bridge_path = g_module_build_path (bridge_dir, "libatk-bridge");
result = _a11y_invoke_module (bridge_path, TRUE);
g_free (bridge_dir);
g_free (bridge_path);
return result;
}

View File

@@ -0,0 +1,24 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2009 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
gboolean
cally_util_a11y_init (int *argc, char ***argv);