From: Matthias Clasen Date: Sun, 10 Jul 2011 02:59:15 +0000 (-0400) Subject: Convert GailImageCell to GtkImageCellAccessible X-Git-Url: http://pileus.org/git/?a=commitdiff_plain;h=7ddf0dff8fe67e2e5b95d6af88c537319ef39bdd;p=~andy%2Fgtk Convert GailImageCell to GtkImageCellAccessible --- diff --git a/gtk/a11y/Makefile.am b/gtk/a11y/Makefile.am index fa14bebd2..1d54a7c8f 100644 --- a/gtk/a11y/Makefile.am +++ b/gtk/a11y/Makefile.am @@ -19,7 +19,7 @@ gail_c_sources = \ gtkexpanderaccessible.c \ gtkframeaccessible.c \ gtkimageaccessible.c \ - gailimagecell.c \ + gtkimagecellaccessible.c \ gtklabelaccessible.c \ gtklinkbuttonaccessible.c \ gtkmenuaccessible.c \ @@ -71,7 +71,7 @@ gail_private_h_sources = \ gtkexpanderaccessible.h \ gtkframeaccessible.h \ gtkimageaccessible.h \ - gailimagecell.h \ + gtkimagecellaccessible.h \ gtklabelaccessible.h \ gtklinkbuttonaccessible.h \ gtkmenuaccessible.h \ diff --git a/gtk/a11y/gailimagecell.c b/gtk/a11y/gailimagecell.c deleted file mode 100644 index 024905dc5..000000000 --- a/gtk/a11y/gailimagecell.c +++ /dev/null @@ -1,175 +0,0 @@ -/* GAIL - The GNOME Accessibility Enabling Library - * Copyright 2001 Sun Microsystems Inc. - * - * 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 "config.h" - -#include -#include "gailimagecell.h" - -static void gail_image_cell_class_init (GailImageCellClass *klass); -static void gail_image_cell_init (GailImageCell *image_cell); - -static void gail_image_cell_finalize (GObject *object); - -/* AtkImage */ -static void atk_image_interface_init (AtkImageIface *iface); -static const gchar * - gail_image_cell_get_image_description (AtkImage *image); -static gboolean gail_image_cell_set_image_description (AtkImage *image, - const gchar *description); -static void gail_image_cell_get_image_position (AtkImage *image, - gint *x, - gint *y, - AtkCoordType coord_type); -static void gail_image_cell_get_image_size (AtkImage *image, - gint *width, - gint *height); - -/* Misc */ - -static gboolean gail_image_cell_update_cache (GtkRendererCellAccessible *cell, - gboolean emit_change_signal); - -// FIXMEchpe static!!! -gchar *gail_image_cell_property_list[] = { - "pixbuf", - NULL -}; - -G_DEFINE_TYPE_WITH_CODE (GailImageCell, gail_image_cell, GTK_TYPE_RENDERER_CELL_ACCESSIBLE, - G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_interface_init)) - -static void -gail_image_cell_class_init (GailImageCellClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GtkRendererCellAccessibleClass *renderer_cell_class = GTK_RENDERER_CELL_ACCESSIBLE_CLASS (klass); - - gobject_class->finalize = gail_image_cell_finalize; - - renderer_cell_class->update_cache = gail_image_cell_update_cache; - renderer_cell_class->property_list = gail_image_cell_property_list; -} - -AtkObject* -gail_image_cell_new (void) -{ - GObject *object; - AtkObject *atk_object; - GtkRendererCellAccessible *cell; - - object = g_object_new (GAIL_TYPE_IMAGE_CELL, NULL); - - g_return_val_if_fail (object != NULL, NULL); - - atk_object = ATK_OBJECT (object); - atk_object->role = ATK_ROLE_TABLE_CELL; - - cell = GTK_RENDERER_CELL_ACCESSIBLE (object); - - cell->renderer = gtk_cell_renderer_pixbuf_new (); - g_object_ref_sink (cell->renderer); - return atk_object; -} - -static void -gail_image_cell_init (GailImageCell *image_cell) -{ - image_cell->image_description = NULL; -} - - -static void -gail_image_cell_finalize (GObject *object) -{ - GailImageCell *image_cell = GAIL_IMAGE_CELL (object); - - g_free (image_cell->image_description); - G_OBJECT_CLASS (gail_image_cell_parent_class)->finalize (object); -} - -static gboolean -gail_image_cell_update_cache (GtkRendererCellAccessible *cell, - gboolean emit_change_signal) -{ - return FALSE; -} - -static void -atk_image_interface_init (AtkImageIface *iface) -{ - iface->get_image_description = gail_image_cell_get_image_description; - iface->set_image_description = gail_image_cell_set_image_description; - iface->get_image_position = gail_image_cell_get_image_position; - iface->get_image_size = gail_image_cell_get_image_size; -} - -static const gchar * -gail_image_cell_get_image_description (AtkImage *image) -{ - GailImageCell *image_cell; - - image_cell = GAIL_IMAGE_CELL (image); - return image_cell->image_description; -} - -static gboolean -gail_image_cell_set_image_description (AtkImage *image, - const gchar *description) -{ - GailImageCell *image_cell; - - image_cell = GAIL_IMAGE_CELL (image); - g_free (image_cell->image_description); - image_cell->image_description = g_strdup (description); - if (image_cell->image_description) - return TRUE; - else - return FALSE; -} - -static void -gail_image_cell_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 -gail_image_cell_get_image_size (AtkImage *image, - gint *width, - gint *height) -{ - GailImageCell *cell = GAIL_IMAGE_CELL (image); - GtkCellRenderer *cell_renderer; - GdkPixbuf *pixbuf = NULL; - - cell_renderer = GTK_RENDERER_CELL_ACCESSIBLE (cell)->renderer; - g_object_get (GTK_CELL_RENDERER_PIXBUF (cell_renderer), "pixbuf", &pixbuf, NULL); - - if (pixbuf) - { - *width = gdk_pixbuf_get_width (pixbuf); - *height = gdk_pixbuf_get_height (pixbuf); - - g_object_unref (pixbuf); - } -} diff --git a/gtk/a11y/gailimagecell.h b/gtk/a11y/gailimagecell.h deleted file mode 100644 index 9edb9f95b..000000000 --- a/gtk/a11y/gailimagecell.h +++ /dev/null @@ -1,57 +0,0 @@ -/* GAIL - The GNOME Accessibility Enabling Library - * Copyright 2001 Sun Microsystems Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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. - */ - -#ifndef __GAIL_IMAGE_CELL_H__ -#define __GAIL_IMAGE_CELL_H__ - -#include -#include "gtkrenderercellaccessible.h" - -G_BEGIN_DECLS - -#define GAIL_TYPE_IMAGE_CELL (gail_image_cell_get_type ()) -#define GAIL_IMAGE_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_IMAGE_CELL, GailImageCell)) -#define GAIL_IMAGE_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_IMAGE_CELL, GailImageCellClass)) -#define GAIL_IS_IMAGE_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_IMAGE_CELL)) -#define GAIL_IS_IMAGE_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_IMAGE_CELL))78 -#define GAIL_IMAGE_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_IMAGE_CELL, GailImageCellClass)) - -typedef struct _GailImageCell GailImageCell; -typedef struct _GailImageCellClass GailImageCellClass; - -struct _GailImageCell -{ - GtkRendererCellAccessible parent; - - gchar *image_description; - gint x, y; -}; - -GType gail_image_cell_get_type (void); - -struct _GailImageCellClass -{ - GtkRendererCellAccessibleClass parent_class; -}; - -AtkObject *gail_image_cell_new (void); - -G_END_DECLS - -#endif /* __GAIL_IMAGE_CELL_H__ */ diff --git a/gtk/a11y/gtkimagecellaccessible.c b/gtk/a11y/gtkimagecellaccessible.c new file mode 100644 index 000000000..4b356602e --- /dev/null +++ b/gtk/a11y/gtkimagecellaccessible.c @@ -0,0 +1,152 @@ +/* GAIL - The GNOME Accessibility Enabling Library + * Copyright 2001 Sun Microsystems Inc. + * + * 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 "config.h" + +#include +#include "gtkimagecellaccessible.h" + +static gchar *property_list[] = { + "pixbuf", + NULL +}; + +static void atk_image_interface_init (AtkImageIface *iface); + +G_DEFINE_TYPE_WITH_CODE (GtkImageCellAccessible, _gtk_image_cell_accessible, GTK_TYPE_RENDERER_CELL_ACCESSIBLE, + G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_interface_init)) + +static void +gtk_image_cell_accessible_finalize (GObject *object) +{ + GtkImageCellAccessible *image_cell = GTK_IMAGE_CELL_ACCESSIBLE (object); + + g_free (image_cell->image_description); + G_OBJECT_CLASS (_gtk_image_cell_accessible_parent_class)->finalize (object); +} + +static gboolean +gtk_image_cell_accessible_update_cache (GtkRendererCellAccessible *cell, + gboolean emit_change_signal) +{ + return FALSE; +} + +static void +_gtk_image_cell_accessible_class_init (GtkImageCellAccessibleClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GtkRendererCellAccessibleClass *renderer_cell_class = GTK_RENDERER_CELL_ACCESSIBLE_CLASS (klass); + + gobject_class->finalize = gtk_image_cell_accessible_finalize; + + renderer_cell_class->update_cache = gtk_image_cell_accessible_update_cache; + renderer_cell_class->property_list = property_list; +} + +AtkObject * +_gtk_image_cell_accessible_new (void) +{ + GObject *object; + AtkObject *atk_object; + GtkRendererCellAccessible *cell; + + object = g_object_new (GTK_TYPE_IMAGE_CELL_ACCESSIBLE, NULL); + + g_return_val_if_fail (object != NULL, NULL); + + atk_object = ATK_OBJECT (object); + atk_object->role = ATK_ROLE_TABLE_CELL; + + cell = GTK_RENDERER_CELL_ACCESSIBLE (object); + + cell->renderer = gtk_cell_renderer_pixbuf_new (); + g_object_ref_sink (cell->renderer); + + return atk_object; +} + +static void +_gtk_image_cell_accessible_init (GtkImageCellAccessible *image_cell) +{ + image_cell->image_description = NULL; +} + +static const gchar * +gtk_image_cell_accessible_get_image_description (AtkImage *image) +{ + GtkImageCellAccessible *image_cell = GTK_IMAGE_CELL_ACCESSIBLE (image); + + return image_cell->image_description; +} + +static gboolean +gtk_image_cell_accessible_set_image_description (AtkImage *image, + const gchar *description) +{ + GtkImageCellAccessible *image_cell = GTK_IMAGE_CELL_ACCESSIBLE (image); + + g_free (image_cell->image_description); + image_cell->image_description = g_strdup (description); + + if (image_cell->image_description) + return TRUE; + else + return FALSE; +} + +static void +gtk_image_cell_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 +gtk_image_cell_accessible_get_image_size (AtkImage *image, + gint *width, + gint *height) +{ + GtkImageCellAccessible *cell = GTK_IMAGE_CELL_ACCESSIBLE (image); + GtkCellRenderer *cell_renderer; + GdkPixbuf *pixbuf = NULL; + + cell_renderer = GTK_RENDERER_CELL_ACCESSIBLE (cell)->renderer; + g_object_get (GTK_CELL_RENDERER_PIXBUF (cell_renderer), + "pixbuf", &pixbuf, + NULL); + + if (pixbuf) + { + *width = gdk_pixbuf_get_width (pixbuf); + *height = gdk_pixbuf_get_height (pixbuf); + g_object_unref (pixbuf); + } +} + +static void +atk_image_interface_init (AtkImageIface *iface) +{ + iface->get_image_description = gtk_image_cell_accessible_get_image_description; + iface->set_image_description = gtk_image_cell_accessible_set_image_description; + iface->get_image_position = gtk_image_cell_accessible_get_image_position; + iface->get_image_size = gtk_image_cell_accessible_get_image_size; +} diff --git a/gtk/a11y/gtkimagecellaccessible.h b/gtk/a11y/gtkimagecellaccessible.h new file mode 100644 index 000000000..7920c5b6d --- /dev/null +++ b/gtk/a11y/gtkimagecellaccessible.h @@ -0,0 +1,56 @@ +/* GAIL - The GNOME Accessibility Enabling Library + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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. + */ + +#ifndef __GTK_IMAGE_CELL_ACCESSIBLE_H__ +#define __GTK_IMAGE_CELL_ACCESSIBLE_H__ + +#include +#include "gtkrenderercellaccessible.h" + +G_BEGIN_DECLS + +#define GTK_TYPE_IMAGE_CELL_ACCESSIBLE (_gtk_image_cell_accessible_get_type ()) +#define GTK_IMAGE_CELL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IMAGE_CELL_ACCESSIBLE, GtkImageCellAccessible)) +#define GTK_IMAGE_CELL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_IMAGE_CELL_ACCESSIBLE, GtkImageCellAccessibleClass)) +#define GTK_IS_IMAGE_CELL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_IMAGE_CELL_ACCESSIBLE)) +#define GTK_IS_IMAGE_CELL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IMAGE_CELL_ACCESSIBLE)) +#define GTK_IMAGE_CELL_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_IMAGE_CELL_ACCESSIBLE, GtkImageCellAccessibleClass)) + +typedef struct _GtkImageCellAccessible GtkImageCellAccessible; +typedef struct _GtkImageCellAccessibleClass GtkImageCellAccessibleClass; + +struct _GtkImageCellAccessible +{ + GtkRendererCellAccessible parent; + + gchar *image_description; + gint x, y; +}; + +struct _GtkImageCellAccessibleClass +{ + GtkRendererCellAccessibleClass parent_class; +}; + +GType _gtk_image_cell_accessible_get_type (void); +AtkObject *_gtk_image_cell_accessible_new (void); + +G_END_DECLS + +#endif /* __GTK_IMAGE_CELL_ACCESSIBLE_H__ */ diff --git a/gtk/a11y/gtktreeviewaccessible.c b/gtk/a11y/gtktreeviewaccessible.c index 9f9615178..53afb8dc6 100644 --- a/gtk/a11y/gtktreeviewaccessible.c +++ b/gtk/a11y/gtktreeviewaccessible.c @@ -27,7 +27,7 @@ #include "gtktreeviewaccessible.h" #include "gtkrenderercellaccessible.h" #include "gtkbooleancellaccessible.h" -#include "gailimagecell.h" +#include "gtkimagecellaccessible.h" #include "gtkcontainercellaccessible.h" #include "gailtextcell.h" #include "gailcellparent.h" @@ -612,7 +612,7 @@ gtk_tree_view_accessible_ref_child (AtkObject *obj, else if (GTK_IS_CELL_RENDERER_TOGGLE (renderer)) child = _gtk_boolean_cell_accessible_new (); else if (GTK_IS_CELL_RENDERER_PIXBUF (renderer)) - child = gail_image_cell_new (); + child = _gtk_image_cell_accessible_new (); else child = _gtk_renderer_cell_accessible_new ();