[gtk+] a11y: Remove AtkText implementation from GailMenuitem



commit bbda6777288f9d2a42a68e5ff5ee006c951fb41a
Author: Benjamin Otte <otte redhat com>
Date:   Fri Jun 24 23:17:28 2011 +0200

    a11y: Remove AtkText implementation from GailMenuitem
    
    AtkText should only be implemented by text editing widgets. For just
    giving out a small text string, AtkObject::name should be used.

 gtk/a11y/gailmenuitem.c |  368 +----------------------------------------------
 1 files changed, 2 insertions(+), 366 deletions(-)
---
diff --git a/gtk/a11y/gailmenuitem.c b/gtk/a11y/gailmenuitem.c
index 4186e03..73889c7 100644
--- a/gtk/a11y/gailmenuitem.c
+++ b/gtk/a11y/gailmenuitem.c
@@ -66,53 +66,13 @@ static gboolean              find_accel                    (GtkAccelKey    *key,
 static gboolean              find_accel_new                (GtkAccelKey    *key,
                                                             GClosure       *closure,
                                                             gpointer       data);
-/* atktext.h */
-static void       atk_text_interface_init          (AtkTextIface      *iface);
-
-static gchar*     gail_menu_item_get_text          (AtkText           *text,
-                                                    gint               start_pos,
-                                                    gint               end_pos);
-static gunichar   gail_menu_item_get_character_at_offset (AtkText     *text,
-                                                          gint         offset);
-static gchar*     gail_menu_item_get_text_before_offset  (AtkText     *text,
-                                                          gint         offset,
-                                                          AtkTextBoundary  boundary_type,
-                                                          gint        *start_offset,
-                                                          gint        *end_offset);
-static gchar*     gail_menu_item_get_text_at_offset      (AtkText     *text,
-                                                          gint         offset,
-                                                          AtkTextBoundary   boundary_type,
-                                                          gint        *start_offset,
-                                                          gint        *end_offset);
-static gchar*     gail_menu_item_get_text_after_offset   (AtkText     *text,
-                                                          gint         offset,
-                                                          AtkTextBoundary   boundary_type,
-                                                          gint        *start_offset,
-                                                          gint        *end_offset);
-static gint       gail_menu_item_get_character_count     (AtkText     *text);
-static void       gail_menu_item_get_character_extents   (AtkText     *text,
-                                                          gint         offset,
-                                                          gint        *x,
-                                                          gint        *y,
-                                                          gint        *width,
-                                                          gint        *height,
-                                                          AtkCoordType  coords);
-static gint      gail_menu_item_get_offset_at_point      (AtkText     *text,
-                                                          gint         x,
-                                                          gint         y,
-                                                          AtkCoordType  coords);
-static AtkAttributeSet* gail_menu_item_get_run_attributes (AtkText    *text,
-                                                           gint        offset,
-                                                           gint       *start_offset,
-                                                           gint       *end_offset);
-static AtkAttributeSet* gail_menu_item_get_default_attributes (AtkText *text);
+
 static GtkWidget*       get_label_from_container   (GtkWidget    *container);
 static gchar *          get_text_from_label_widget (GtkWidget    *widget);
 
 
 G_DEFINE_TYPE_WITH_CODE (GailMenuItem, gail_menu_item, GAIL_TYPE_CONTAINER,
-                         G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init)
-                         G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT, atk_text_interface_init))
+                         G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init))
 
 static void
 gail_menu_item_class_init (GailMenuItemClass *klass)
@@ -255,330 +215,6 @@ gail_menu_item_init_textutil (GailMenuItem  *item,
   g_free (label_text);
 }
 
-/* atktext.h */
-
-static void
-atk_text_interface_init (AtkTextIface *iface)
-{
-  iface->get_text = gail_menu_item_get_text;
-  iface->get_character_at_offset = gail_menu_item_get_character_at_offset;
-  iface->get_text_before_offset = gail_menu_item_get_text_before_offset;
-  iface->get_text_at_offset = gail_menu_item_get_text_at_offset;
-  iface->get_text_after_offset = gail_menu_item_get_text_after_offset;
-  iface->get_character_count = gail_menu_item_get_character_count;
-  iface->get_character_extents = gail_menu_item_get_character_extents;
-  iface->get_offset_at_point = gail_menu_item_get_offset_at_point;
-  iface->get_run_attributes = gail_menu_item_get_run_attributes;
-  iface->get_default_attributes = gail_menu_item_get_default_attributes;
-}
-
-static gchar*
-gail_menu_item_get_text (AtkText *text,
-                         gint    start_pos,
-                         gint    end_pos)
-{
-  GtkWidget *widget;
-  GtkWidget *label;
-  GailMenuItem *item;
-  gchar *label_text;
-
-  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
-  if (widget == NULL)
-    /* State is defunct */
-    return NULL;
-
-  label = get_label_from_container (widget);
-
-  item = GAIL_MENU_ITEM (text);
-  if (!item->textutil)
-    gail_menu_item_init_textutil (item, label);
-
-  label_text = get_text_from_label_widget (label);
-
-  if (label_text == NULL)
-    return NULL;
-  else
-    {
-      g_free (label_text);
-
-      return gail_text_util_get_substring (item->textutil,
-                                           start_pos, end_pos);
-    }
-}
-
-static gchar*
-gail_menu_item_get_text_before_offset (AtkText         *text,
-                                        gint            offset,
-                                        AtkTextBoundary boundary_type,
-                                        gint            *start_offset,
-                                        gint            *end_offset)
-{
-  GtkWidget *widget;
-  GtkWidget *label;
-  GailMenuItem *item;
-  
-  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
-  
-  if (widget == NULL)
-    /* State is defunct */
-    return NULL;
-  
-  /* Get label */
-  label = get_label_from_container (widget);
-
-  item = GAIL_MENU_ITEM (text);
-  if (!item->textutil)
-    gail_menu_item_init_textutil (item, label);
-
-  return gail_text_util_get_text (item->textutil,
-                           NULL, GAIL_BEFORE_OFFSET, 
-                           boundary_type, offset, start_offset, end_offset); 
-}
-
-static gchar*
-gail_menu_item_get_text_at_offset (AtkText         *text,
-                                   gint            offset,
-                                   AtkTextBoundary boundary_type,
-                                   gint            *start_offset,
-                                   gint            *end_offset)
-{
-  GtkWidget *widget;
-  GtkWidget *label;
-  GailMenuItem *item;
- 
-  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
-  
-  if (widget == NULL)
-    /* State is defunct */
-    return NULL;
-  
-  /* Get label */
-  label = get_label_from_container (widget);
-
-  item = GAIL_MENU_ITEM (text);
-  if (!item->textutil)
-    gail_menu_item_init_textutil (item, label);
-
-  return gail_text_util_get_text (item->textutil,
-                              NULL, GAIL_AT_OFFSET, 
-                              boundary_type, offset, start_offset, end_offset);
-}
-
-static gchar*
-gail_menu_item_get_text_after_offset (AtkText         *text,
-                                      gint            offset,
-                                      AtkTextBoundary boundary_type,
-                                      gint            *start_offset,
-                                      gint            *end_offset)
-{
-  GtkWidget *widget;
-  GtkWidget *label;
-  GailMenuItem *item;
-
-  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
-  
-  if (widget == NULL)
-  {
-    /* State is defunct */
-    return NULL;
-  }
-  
-  /* Get label */
-  label = get_label_from_container (widget);
-
-  item = GAIL_MENU_ITEM (text);
-  if (!item->textutil)
-    gail_menu_item_init_textutil (item, label);
-
-  return gail_text_util_get_text (item->textutil,
-                           NULL, GAIL_AFTER_OFFSET, 
-                           boundary_type, offset, start_offset, end_offset);
-}
-
-static gint
-gail_menu_item_get_character_count (AtkText *atk_text)
-{
-  gchar *text;
-  gint len;
-
-  text = gail_menu_item_get_text (atk_text, 0, -1);
-  if (text)
-    {
-      len = g_utf8_strlen (text, -1);
-      g_free (text);
-    }
-  else
-    len = 0;
-
-  return len;
-}
-
-static void
-gail_menu_item_get_character_extents (AtkText      *text,
-                                      gint         offset,
-                                      gint         *x,
-                                      gint         *y,
-                                      gint         *width,
-                                      gint         *height,
-                                      AtkCoordType coords)
-{
-  GtkWidget *widget;
-  GtkWidget *label;
-  PangoRectangle char_rect;
-  gint index, x_layout, y_layout;
-  const gchar *label_text;
- 
-  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
-
-  if (widget == NULL)
-    /* State is defunct */
-    return;
-
-  label = get_label_from_container (widget);
-
-  if (!GTK_IS_LABEL(label))
-    return;
-
-  gtk_label_get_layout_offsets (GTK_LABEL (label), &x_layout, &y_layout);
-  label_text = gtk_label_get_text (GTK_LABEL (label));
-  index = g_utf8_offset_to_pointer (label_text, offset) - label_text;
-  pango_layout_index_to_pos (gtk_label_get_layout (GTK_LABEL (label)), index, &char_rect);
-
-  gail_misc_get_extents_from_pango_rectangle (label, &char_rect,
-                    x_layout, y_layout, x, y, width, height, coords);
-}
-
-static gint 
-gail_menu_item_get_offset_at_point (AtkText      *text,
-                               gint         x,
-                               gint         y,
-                               AtkCoordType coords)
-{ 
-  GtkWidget *widget;
-  GtkWidget *label;
-  gint index, x_layout, y_layout;
-  const gchar *label_text;
-
-  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
-  if (widget == NULL)
-    /* State is defunct */
-    return -1;
-
-  label = get_label_from_container (widget);
-
-  if (!GTK_IS_LABEL(label))
-    return -1;
-  
-  gtk_label_get_layout_offsets (GTK_LABEL (label), &x_layout, &y_layout);
-  
-  index = gail_misc_get_index_at_point_in_layout (label, 
-                                              gtk_label_get_layout (GTK_LABEL (label)), 
-                                              x_layout, y_layout, x, y, coords);
-  label_text = gtk_label_get_text (GTK_LABEL (label));
-  if (index == -1)
-    {
-      if (coords == ATK_XY_WINDOW || coords == ATK_XY_SCREEN)
-        return g_utf8_strlen (label_text, -1);
-
-      return index;  
-    }
-  else
-    return g_utf8_pointer_to_offset (label_text, label_text + index);  
-}
-
-static AtkAttributeSet*
-gail_menu_item_get_run_attributes (AtkText *text,
-                              gint    offset,
-                              gint    *start_offset,
-                              gint    *end_offset)
-{
-  GtkWidget *widget;
-  GtkWidget *label;
-  AtkAttributeSet *at_set = NULL;
-  GtkJustification justify;
-  GtkTextDirection dir;
-
-  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
-  if (widget == NULL)
-    /* State is defunct */
-    return NULL;
-
-  label = get_label_from_container (widget);
-
-  if (!GTK_IS_LABEL(label))
-    return NULL;
-  
-  /* Get values set for entire label, if any */
-  justify = gtk_label_get_justify (GTK_LABEL (label));
-  if (justify != GTK_JUSTIFY_CENTER)
-    {
-      at_set = gail_misc_add_attribute (at_set, 
-                                        ATK_TEXT_ATTR_JUSTIFICATION,
-     g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_JUSTIFICATION, justify)));
-    }
-  dir = gtk_widget_get_direction (label);
-  if (dir == GTK_TEXT_DIR_RTL)
-    {
-      at_set = gail_misc_add_attribute (at_set, 
-                                        ATK_TEXT_ATTR_DIRECTION,
-     g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_DIRECTION, dir)));
-    }
-
-  at_set = gail_misc_layout_get_run_attributes (at_set,
-                                                gtk_label_get_layout (GTK_LABEL (label)),
-                                                (gchar *) gtk_label_get_text (GTK_LABEL (label)),
-                                                offset,
-                                                start_offset,
-                                                end_offset);
-  return at_set;
-}
-
-static AtkAttributeSet*
-gail_menu_item_get_default_attributes (AtkText *text)
-{
-  GtkWidget *widget;
-  GtkWidget *label;
-  AtkAttributeSet *at_set = NULL;
-
-  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
-  if (widget == NULL)
-    /* State is defunct */
-    return NULL;
-
-  label = get_label_from_container (widget);
-
-  if (!GTK_IS_LABEL(label))
-    return NULL;
-
-  at_set = gail_misc_get_default_attributes (at_set,
-                                             gtk_label_get_layout (GTK_LABEL (label)),
-                                             widget);
-  return at_set;
-}
-
-static gunichar 
-gail_menu_item_get_character_at_offset (AtkText *text,
-                                   gint   offset)
-{
-  gchar *string;
-  gchar *index;
-  gunichar ch;
-
-  string = gail_menu_item_get_text (text, 0, -1);
-
-  if (string == NULL || offset >= g_utf8_strlen (string, -1))
-    ch = '\0';
-  else
-    {
-      index = g_utf8_offset_to_pointer (string, offset);
-      ch = g_utf8_get_char (index);
-    }
-
-  g_free (string);
-
-  return ch;
-}
-
 static GtkWidget*
 get_label_from_container (GtkWidget *container)
 {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]