Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dorota Czaplejewicz
gtk
Commits
21524245
Commit
21524245
authored
Jun 26, 2011
by
Matthias Clasen
Browse files
Convert GailImage to GtkImageAccessible
parent
a166051b
Changes
7
Hide whitespace changes
Inline
Side-by-side
gtk/a11y/Makefile.am
View file @
21524245
...
...
@@ -19,7 +19,7 @@ gail_c_sources = \
gtkentryaccessible.c
\
gailexpander.c
\
gtkframeaccessible.c
\
g
ail
image.c
\
g
tk
image
accessible
.c
\
gailimagecell.c
\
gtklabelaccessible.c
\
gaillinkbutton.c
\
...
...
@@ -71,7 +71,7 @@ gail_private_h_sources = \
gailexpander.h
\
gailfactory.h
\
gtkframeaccessible.h
\
g
ail
image.h
\
g
tk
image
accessible
.h
\
gailimagecell.h
\
gtklabelaccessible.h
\
gaillinkbutton.h
\
...
...
gtk/a11y/gail.c
View file @
21524245
...
...
@@ -32,7 +32,6 @@
#include
"gailcontainer.h"
#include
"gailcontainercell.h"
#include
"gailexpander.h"
#include
"gailimage.h"
#include
"gailimagecell.h"
#include
"gaillinkbutton.h"
#include
"gailmenu.h"
...
...
@@ -107,7 +106,6 @@ GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_BUTTON, GailButton, gail_button, GTK_TYPE_BUTT
GAIL_IMPLEMENT_FACTORY
(
GAIL_TYPE_LINK_BUTTON
,
GailLinkButton
,
gail_link_button
,
GTK_TYPE_LINK_BUTTON
)
GAIL_IMPLEMENT_FACTORY_WITH_FUNC
(
GAIL_TYPE_MENU_ITEM
,
GailMenuItem
,
gail_menu_item
,
gail_menu_item_new
)
GAIL_IMPLEMENT_FACTORY
(
GAIL_TYPE_TOGGLE_BUTTON
,
GailToggleButton
,
gail_toggle_button
,
GTK_TYPE_TOGGLE_BUTTON
)
GAIL_IMPLEMENT_FACTORY
(
GAIL_TYPE_IMAGE
,
GailImage
,
gail_image
,
GTK_TYPE_IMAGE
)
GAIL_IMPLEMENT_FACTORY
(
GAIL_TYPE_COMBO_BOX
,
GailComboBox
,
gail_combo_box
,
GTK_TYPE_COMBO_BOX
)
GAIL_IMPLEMENT_FACTORY
(
GAIL_TYPE_MENU_SHELL
,
GailMenuShell
,
gail_menu_shell
,
GTK_TYPE_MENU_SHELL
)
GAIL_IMPLEMENT_FACTORY
(
GAIL_TYPE_MENU
,
GailMenu
,
gail_menu
,
GTK_TYPE_MENU
)
...
...
@@ -873,7 +871,6 @@ gail_accessibility_module_init (void)
GAIL_WIDGET_SET_FACTORY
(
GTK_TYPE_LINK_BUTTON
,
gail_link_button
);
GAIL_WIDGET_SET_FACTORY
(
GTK_TYPE_MENU_ITEM
,
gail_menu_item
);
GAIL_WIDGET_SET_FACTORY
(
GTK_TYPE_TOGGLE_BUTTON
,
gail_toggle_button
);
GAIL_WIDGET_SET_FACTORY
(
GTK_TYPE_IMAGE
,
gail_image
);
GAIL_WIDGET_SET_FACTORY
(
GTK_TYPE_COMBO_BOX
,
gail_combo_box
);
GAIL_WIDGET_SET_FACTORY
(
GTK_TYPE_MENU_BAR
,
gail_menu_shell
);
GAIL_WIDGET_SET_FACTORY
(
GTK_TYPE_MENU
,
gail_menu
);
...
...
gtk/a11y/g
ail
image.c
→
gtk/a11y/g
tk
image
accessible
.c
View file @
21524245
...
...
@@ -21,127 +21,54 @@
#include
<string.h>
#include
<gtk/gtk.h>
#include
"g
ail
image.h"
#include
"g
tk
image
accessible
.h"
static
void
gail_image_class_init
(
GailImageClass
*
klass
);
static
void
gail_image_init
(
GailImage
*
image
);
static
void
gail_image_initialize
(
AtkObject
*
accessible
,
gpointer
data
);
static
const
gchar
*
gail_image_get_name
(
AtkObject
*
accessible
);
static
void
atk_image_interface_init
(
AtkImageIface
*
iface
);
static
void
atk_image_interface_init
(
AtkImageIface
*
iface
);
static
const
gchar
*
gail_image_get_image_description
(
AtkImage
*
image
);
static
void
gail_image_get_image_position
(
AtkImage
*
image
,
gint
*
x
,
gint
*
y
,
AtkCoordType
coord_type
);
static
void
gail_image_get_image_size
(
AtkImage
*
image
,
gint
*
width
,
gint
*
height
);
static
gboolean
gail_image_set_image_description
(
AtkImage
*
image
,
const
gchar
*
description
);
static
void
gail_image_finalize
(
GObject
*
object
);
G_DEFINE_TYPE_WITH_CODE
(
GailImage
,
gail_image
,
GAIL_TYPE_WIDGET
,
G_DEFINE_TYPE_WITH_CODE
(
GtkImageAccessible
,
gtk_image_accessible
,
GAIL_TYPE_WIDGET
,
G_IMPLEMENT_INTERFACE
(
ATK_TYPE_IMAGE
,
atk_image_interface_init
))
static
void
gail_image_class_init
(
GailImageClass
*
klass
)
{
GObjectClass
*
gobject_class
=
G_OBJECT_CLASS
(
klass
);
AtkObjectClass
*
class
=
ATK_OBJECT_CLASS
(
klass
);
gobject_class
->
finalize
=
gail_image_finalize
;
class
->
initialize
=
gail_image_initialize
;
class
->
get_name
=
gail_image_get_name
;
}
static
void
gail_image_init
(
GailImage
*
image
)
gtk_image_accessible_initialize
(
AtkObject
*
accessible
,
gpointer
data
)
{
image
->
image_description
=
NULL
;
}
static
void
gail_image_initialize
(
AtkObject
*
accessible
,
gpointer
data
)
{
ATK_OBJECT_CLASS
(
gail_image_parent_class
)
->
initialize
(
accessible
,
data
);
ATK_OBJECT_CLASS
(
gtk_image_accessible_parent_class
)
->
initialize
(
accessible
,
data
);
accessible
->
role
=
ATK_ROLE_ICON
;
}
/* Copied from gtktoolbar.c, keep in sync */
static
gchar
*
elide_underscores
(
const
gchar
*
original
)
static
void
gtk_image_accessible_finalize
(
GObject
*
object
)
{
gchar
*
q
,
*
result
;
const
gchar
*
p
,
*
end
;
gsize
len
;
gboolean
last_underscore
;
if
(
!
original
)
return
NULL
;
GtkImageAccessible
*
aimage
=
GTK_IMAGE_ACCESSIBLE
(
object
);
len
=
strlen
(
original
);
q
=
result
=
g_malloc
(
len
+
1
);
last_underscore
=
FALSE
;
end
=
original
+
len
;
for
(
p
=
original
;
p
<
end
;
p
++
)
{
if
(
!
last_underscore
&&
*
p
==
'_'
)
last_underscore
=
TRUE
;
else
{
last_underscore
=
FALSE
;
if
(
original
+
2
<=
p
&&
p
+
1
<=
end
&&
p
[
-
2
]
==
'('
&&
p
[
-
1
]
==
'_'
&&
p
[
0
]
!=
'_'
&&
p
[
1
]
==
')'
)
{
q
--
;
*
q
=
'\0'
;
p
++
;
}
else
*
q
++
=
*
p
;
}
}
g_free
(
aimage
->
image_description
);
g_free
(
aimage
->
stock_name
);
if
(
last_underscore
)
*
q
++
=
'_'
;
*
q
=
'\0'
;
return
result
;
G_OBJECT_CLASS
(
gtk_image_accessible_parent_class
)
->
finalize
(
object
);
}
static
const
gchar
*
g
ail
_image_get_name
(
AtkObject
*
accessible
)
static
const
gchar
*
g
tk
_image_
accessible_
get_name
(
AtkObject
*
accessible
)
{
GtkWidget
*
widget
;
GtkImage
*
image
;
G
ail
Image
*
image_accessible
;
G
tk
Image
Accessible
*
image_accessible
;
GtkStockItem
stock_item
;
gchar
*
stock_id
;
const
gchar
*
name
;
name
=
ATK_OBJECT_CLASS
(
gail_image_parent_class
)
->
get_name
(
accessible
);
if
(
name
)
return
name
;
widget
=
gtk_accessible_get_widget
(
GTK_ACCESSIBLE
(
accessible
));
/*
* State is defunct
*/
if
(
widget
==
NULL
)
return
NULL
;
g_return_val_if_fail
(
GTK_IS_IMAGE
(
widget
),
NULL
);
name
=
ATK_OBJECT_CLASS
(
gtk_image_accessible_parent_class
)
->
get_name
(
accessible
);
if
(
name
)
return
name
;
image
=
GTK_IMAGE
(
widget
);
image_accessible
=
G
AIL
_IMAGE
(
accessible
);
image_accessible
=
G
TK
_IMAGE
_ACCESSIBLE
(
accessible
);
g_free
(
image_accessible
->
stock_name
);
image_accessible
->
stock_name
=
NULL
;
...
...
@@ -156,116 +83,123 @@ gail_image_get_name (AtkObject *accessible)
if
(
!
gtk_stock_lookup
(
stock_id
,
&
stock_item
))
return
NULL
;
image_accessible
->
stock_name
=
elide_underscores
(
stock_item
.
label
);
image_accessible
->
stock_name
=
_gtk_toolbar_
elide_underscores
(
stock_item
.
label
);
return
image_accessible
->
stock_name
;
}
static
void
atk_image_interface_init
(
AtkImageIface
*
iface
)
gtk_image_accessible_class_init
(
GtkImageAccessibleClass
*
klass
)
{
GObjectClass
*
gobject_class
=
G_OBJECT_CLASS
(
klass
);
AtkObjectClass
*
class
=
ATK_OBJECT_CLASS
(
klass
);
gobject_class
->
finalize
=
gtk_image_accessible_finalize
;
class
->
initialize
=
gtk_image_accessible_initialize
;
class
->
get_name
=
gtk_image_accessible_get_name
;
}
static
void
gtk_image_accessible_init
(
GtkImageAccessible
*
image
)
{
iface
->
get_image_description
=
gail_image_get_image_description
;
iface
->
get_image_position
=
gail_image_get_image_position
;
iface
->
get_image_size
=
gail_image_get_image_size
;
iface
->
set_image_description
=
gail_image_set_image_description
;
}
static
const
gchar
*
g
ail
_image_get_image_description
(
AtkImage
*
image
)
g
tk
_image_
accessible_
get_image_description
(
AtkImage
*
image
)
{
G
ail
Image
*
aimag
e
=
G
AIL
_IMAGE
(
image
);
G
tk
Image
Accessible
*
accessibl
e
=
G
TK
_IMAGE
_ACCESSIBLE
(
image
);
return
a
imag
e
->
image_description
;
return
a
ccessibl
e
->
image_description
;
}
static
void
g
ail
_image_get_image_position
(
AtkImage
*
image
,
gint
*
x
,
gint
*
y
,
AtkCoordType
coord_type
)
g
tk
_image_
accessible_
get_image_position
(
AtkImage
*
image
,
gint
*
x
,
gint
*
y
,
AtkCoordType
coord_type
)
{
atk_component_get_position
(
ATK_COMPONENT
(
image
),
x
,
y
,
coord_type
);
}
static
void
g
ail
_image_get_image_size
(
AtkImage
*
image
,
gint
*
width
,
gint
*
height
)
g
tk
_image_
accessible_
get_image_size
(
AtkImage
*
image
,
gint
*
width
,
gint
*
height
)
{
GtkWidget
*
widget
;
GtkImage
*
gtk_image
;
GtkImageType
image_type
;
widget
=
gtk_accessible_get_widget
(
GTK_ACCESSIBLE
(
image
));
if
(
widget
==
0
)
{
/* State is defunct */
*
height
=
-
1
;
*
width
=
-
1
;
return
;
}
gtk_image
=
GTK_IMAGE
(
widget
);
image_type
=
gtk_image_get_storage_type
(
gtk_image
);
switch
(
image_type
)
{
case
GTK_IMAGE_PIXBUF
:
if
(
widget
==
NULL
)
{
GdkPixbuf
*
pixbuf
;
pixbuf
=
gtk_image_get_pixbuf
(
gtk_image
);
*
height
=
gdk_pixbuf_get_height
(
pixbuf
);
*
width
=
gdk_pixbuf_get_width
(
pixbuf
);
break
;
*
height
=
-
1
;
*
width
=
-
1
;
return
;
}
gtk_image
=
GTK_IMAGE
(
widget
);
image_type
=
gtk_image_get_storage_type
(
gtk_image
);
switch
(
image_type
)
{
case
GTK_IMAGE_PIXBUF
:
{
GdkPixbuf
*
pixbuf
;
pixbuf
=
gtk_image_get_pixbuf
(
gtk_image
);
*
height
=
gdk_pixbuf_get_height
(
pixbuf
);
*
width
=
gdk_pixbuf_get_width
(
pixbuf
);
break
;
}
case
GTK_IMAGE_STOCK
:
case
GTK_IMAGE_ICON_SET
:
case
GTK_IMAGE_ICON_NAME
:
case
GTK_IMAGE_GICON
:
{
GtkIconSize
size
;
GtkSettings
*
settings
;
{
GtkIconSize
size
;
GtkSettings
*
settings
;
settings
=
gtk_settings_get_for_screen
(
gtk_widget_get_screen
(
widget
));
settings
=
gtk_settings_get_for_screen
(
gtk_widget_get_screen
(
widget
));
g_object_get
(
gtk_image
,
"icon-size"
,
&
size
,
NULL
);
gtk_icon_size_lookup_for_settings
(
settings
,
size
,
width
,
height
);
break
;
}
g_object_get
(
gtk_image
,
"icon-size"
,
&
size
,
NULL
);
gtk_icon_size_lookup_for_settings
(
settings
,
size
,
width
,
height
);
break
;
}
case
GTK_IMAGE_ANIMATION
:
{
GdkPixbufAnimation
*
animation
;
animation
=
gtk_image_get_animation
(
gtk_image
);
*
height
=
gdk_pixbuf_animation_get_height
(
animation
);
*
width
=
gdk_pixbuf_animation_get_width
(
animation
);
break
;
}
{
GdkPixbufAnimation
*
animation
;
animation
=
gtk_image_get_animation
(
gtk_image
);
*
height
=
gdk_pixbuf_animation_get_height
(
animation
);
*
width
=
gdk_pixbuf_animation_get_width
(
animation
);
break
;
}
default:
{
*
height
=
-
1
;
*
width
=
-
1
;
break
;
{
*
height
=
-
1
;
*
width
=
-
1
;
break
;
}
}
}
}
static
gboolean
g
ail
_image_set_image_description
(
AtkImage
*
image
,
const
gchar
*
description
)
g
tk
_image_
accessible_
set_image_description
(
AtkImage
*
image
,
const
gchar
*
description
)
{
GailImage
*
aimage
=
GAIL_IMAGE
(
image
);
GtkImageAccessible
*
accessible
=
GTK_IMAGE_ACCESSIBLE
(
image
);
g_free
(
accessible
->
image_description
);
accessible
->
image_description
=
g_strdup
(
description
);
g_free
(
aimage
->
image_description
);
aimage
->
image_description
=
g_strdup
(
description
);
return
TRUE
;
}
static
void
gail
_image_
finalize
(
GObject
*
object
)
atk
_image_
interface_init
(
AtkImageIface
*
iface
)
{
GailImage
*
aimage
=
GAIL_IMAGE
(
object
);
g_free
(
aimage
->
image_description
);
g_free
(
aimage
->
stock_name
);
G_OBJECT_CLASS
(
gail_image_parent_class
)
->
finalize
(
object
);
iface
->
get_image_description
=
gtk_image_accessible_get_image_description
;
iface
->
get_image_position
=
gtk_image_accessible_get_image_position
;
iface
->
get_image_size
=
gtk_image_accessible_get_image_size
;
iface
->
set_image_description
=
gtk_image_accessible_set_image_description
;
}
gtk/a11y/g
ail
image.h
→
gtk/a11y/g
tk
image
accessible
.h
View file @
21524245
...
...
@@ -17,24 +17,24 @@
* Boston, MA 02111-1307, USA.
*/
#ifndef __G
AIL
_IMAGE_H__
#define __G
AIL
_IMAGE_H__
#ifndef __G
TK
_IMAGE_
ACCESSIBLE_
H__
#define __G
TK
_IMAGE_
ACCESSIBLE_
H__
#include
"gailwidget.h"
G_BEGIN_DECLS
#define G
AIL
_TYPE_IMAGE (g
ail
_image_get_type ())
#define G
AIL
_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G
AIL
_TYPE_IMAGE, G
ail
Image))
#define G
AIL
_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G
AIL
_TYPE_IMAGE, G
ail
ImageClass))
#define G
AIL
_IS_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G
AIL
_TYPE_IMAGE))
#define G
AIL
_IS_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G
AIL
_TYPE_IMAGE))
#define G
AIL
_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G
AIL
_TYPE_IMAGE, G
ail
ImageClass))
#define G
TK
_TYPE_IMAGE
_ACCESSIBLE
(g
tk
_image_
accessible_
get_type ())
#define G
TK
_IMAGE
_ACCESSIBLE
(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G
TK
_TYPE_IMAGE
_ACCESSIBLE
, G
tk
Image
Accessible
))
#define G
TK
_IMAGE_
ACCESSIBLE_
CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G
TK
_TYPE_IMAGE
_ACCESSIBLE
, G
tk
Image
Accessible
Class))
#define G
TK
_IS_IMAGE
_ACCESSIBLE
(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G
TK
_TYPE_IMAGE
_ACCESSIBLE
))
#define G
TK
_IS_IMAGE_
ACCESSIBLE_
CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G
TK
_TYPE_IMAGE
_ACCESSIBLE
))
#define G
TK
_IMAGE_
ACCESSIBLE_
GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G
TK
_TYPE_IMAGE
_ACCESSIBLE
, G
tk
Image
Accessible
Class))
typedef
struct
_G
ail
Image
G
ail
Image
;
typedef
struct
_G
ail
Image
Class
GailImag
eClass
;
typedef
struct
_G
tk
Image
Accessible
G
tk
Image
Accessible
;
typedef
struct
_G
tk
Image
AccessibleClass
GtkImageAccessibl
eClass
;
struct
_G
ail
Image
struct
_G
tk
Image
Accessible
{
GailWidget
parent
;
...
...
@@ -42,13 +42,13 @@ struct _GailImage
gchar
*
stock_name
;
};
GType
gail_image_get_type
(
void
);
struct
_GailImageClass
struct
_GtkImageAccessibleClass
{
GailWidgetClass
parent_class
;
};
GType
gtk_image_accessible_get_type
(
void
);
G_END_DECLS
#endif
/* __G
AIL
_IMAGE_H__ */
#endif
/* __G
TK
_IMAGE_
ACCESSIBLE_
H__ */
gtk/gtkimage.c
View file @
21524245
...
...
@@ -39,6 +39,8 @@
#include
"gtkprivate.h"
#include
"gtktypebuiltins.h"
#include
"a11y/gtkimageaccessible.h"
/**
* SECTION:gtkimage
* @Short_description: A widget displaying an image
...
...
@@ -357,6 +359,8 @@ gtk_image_class_init (GtkImageClass *class)
GTK_PARAM_READWRITE
));
g_type_class_add_private
(
class
,
sizeof
(
GtkImagePrivate
));
gtk_widget_class_set_accessible_type
(
widget_class
,
GTK_TYPE_IMAGE_ACCESSIBLE
);
}
static
void
...
...
tests/a11y/about.txt
View file @
21524245
...
...
@@ -25,7 +25,7 @@ window1
<AtkComponent>
layer: widget
alpha: 1
unnamed-G
ail
Image-2
unnamed-G
tk
Image
Accessible
-2
"icon"
parent: unnamed-GailContainer-1
index: 0
...
...
tests/a11y/messagedialog.txt
View file @
21524245
...
...
@@ -25,7 +25,7 @@ window1
<AtkComponent>
layer: widget
alpha: 1
unnamed-G
ail
Image-2
unnamed-G
tk
Image
Accessible
-2
"icon"
parent: unnamed-GailContainer-1
index: 0
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment