Beispiel #1
0
void
gtk_cell_accessible_parent_edit (GtkCellAccessibleParent *parent,
                                 GtkCellAccessible       *cell)
{
  GtkCellAccessibleParentIface *iface;

  g_return_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent));
  g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (cell));

  iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);

  if (iface->edit)
    (iface->edit) (parent, cell);
}
Beispiel #2
0
int
gtk_cell_accessible_parent_get_child_index (GtkCellAccessibleParent *parent,
                                            GtkCellAccessible       *cell)
{
  GtkCellAccessibleParentIface *iface;

  g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent), FALSE);

  iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);

  if (iface->get_child_index)
    return (iface->get_child_index) (parent, cell);
  else
    return -1;
}
Beispiel #3
0
gboolean
gtk_cell_accessible_parent_grab_focus (GtkCellAccessibleParent *parent,
                                       GtkCellAccessible       *cell)
{
  GtkCellAccessibleParentIface *iface;

  g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent), FALSE);

  iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);

  if (iface->grab_focus)
    return (iface->grab_focus) (parent, cell);
  else
    return FALSE;
}
Beispiel #4
0
void
gtk_cell_accessible_parent_get_cell_area (GtkCellAccessibleParent *parent,
                                          GtkCellAccessible       *cell,
                                          GdkRectangle            *cell_rect)
{
  GtkCellAccessibleParentIface *iface;

  g_return_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent));
  g_return_if_fail (cell_rect);

  iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);

  if (iface->get_cell_area)
    (iface->get_cell_area) (parent, cell, cell_rect);
}
Beispiel #5
0
/**
 * gtk_cell_accessible_parent_get_row_header_cells:
 * Returns: (transfer full) (element-type AtkObject)
 */
GPtrArray *
gtk_cell_accessible_parent_get_row_header_cells (GtkCellAccessibleParent *parent,
                                                    GtkCellAccessible       *cell)
{
  GtkCellAccessibleParentIface *iface;

  g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent), NULL);
  g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE (cell), NULL);

  iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);

  if (iface->get_row_header_cells)
    return (iface->get_row_header_cells) (parent, cell);
  else
    return NULL;
}
Beispiel #6
0
void
gtk_cell_accessible_parent_update_relationset (GtkCellAccessibleParent *parent,
                                               GtkCellAccessible       *cell,
                                               AtkRelationSet          *relationset)
{
  GtkCellAccessibleParentIface *iface;

  g_return_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent));
  g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (cell));
  g_return_if_fail (ATK_IS_RELATION_SET (relationset));

  iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);

  if (iface->update_relationset)
    (iface->update_relationset) (parent, cell, relationset);
}
Beispiel #7
0
GtkCellRendererState
gtk_cell_accessible_parent_get_renderer_state (GtkCellAccessibleParent *parent,
                                               GtkCellAccessible       *cell)
{
  GtkCellAccessibleParentIface *iface;

  g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent), 0);
  g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE (cell), 0);

  iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);

  if (iface->get_renderer_state)
    return (iface->get_renderer_state) (parent, cell);
  else
    return 0;
}
Beispiel #8
0
void
gtk_cell_accessible_parent_get_cell_extents (GtkCellAccessibleParent *parent,
                                             GtkCellAccessible       *cell,
                                             gint                    *x,
                                             gint                    *y,
                                             gint                    *width,
                                             gint                    *height,
                                             AtkCoordType             coord_type)
{
  GtkCellAccessibleParentIface *iface;

  g_return_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent));

  iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);

  if (iface->get_cell_extents)
    (iface->get_cell_extents) (parent, cell, x, y, width, height, coord_type);
}
Beispiel #9
0
void
gtk_cell_accessible_parent_get_cell_position (GtkCellAccessibleParent *parent,
                                              GtkCellAccessible       *cell,
                                              gint                    *row,
                                              gint                    *column)
{
  GtkCellAccessibleParentIface *iface;

  g_return_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent));
  g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (cell));

  iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);

  if (iface->get_cell_position)
    (iface->get_cell_position) (parent, cell, row, column);
  else
    {
      if (row)
        *row = -1;
      if (column)
        *column = -1;
    }
}
static gint
gtk_text_cell_accessible_get_offset_at_point (AtkText      *text,
                                              gint          x,
                                              gint          y,
                                              AtkCoordType  coords)
{
  AtkObject *parent;
  GtkRendererCellAccessible *gail_renderer;
  GtkCellRendererText *gtk_renderer;
  GtkRequisition min_size;
  GtkWidget *widget;
  GdkRectangle rendered_rect;
  PangoLayout *layout;
  gchar *renderer_text;
  gfloat xalign, yalign;
  gint x_offset, y_offset, index;
  gint xpad, ypad;
  gint x_window, y_window, x_toplevel, y_toplevel;
  gint x_temp, y_temp;
  gboolean ret;

  if (!GTK_TEXT_CELL_ACCESSIBLE (text)->cell_text)
    return -1;

  gail_renderer = GTK_RENDERER_CELL_ACCESSIBLE (text);
  gtk_renderer = GTK_CELL_RENDERER_TEXT (gail_renderer->renderer);
  parent = atk_object_get_parent (ATK_OBJECT (text));

  g_object_get (gtk_renderer, "text", &renderer_text, NULL);
  if (text == NULL)
    {
      g_free (renderer_text);
      return -1;
    }

  if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
    parent = atk_object_get_parent (parent);

  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent));

  g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent), -1);
  _gtk_cell_accessible_parent_get_cell_area (GTK_CELL_ACCESSIBLE_PARENT (parent),
                                             GTK_CELL_ACCESSIBLE (text),
                                             &rendered_rect);

  gtk_cell_renderer_get_preferred_size (GTK_CELL_RENDERER (gtk_renderer),
                                        widget,
                                        &min_size, NULL);
  gtk_cell_renderer_get_alignment (GTK_CELL_RENDERER (gtk_renderer), &xalign, &yalign);
  if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
    xalign = 1.0 - xalign;
  x_offset = MAX (0, xalign * (rendered_rect.width - min_size.width));
  y_offset = MAX (0, yalign * (rendered_rect.height - min_size.height));

  layout = create_pango_layout (GTK_TEXT_CELL_ACCESSIBLE (text));

  gtk_cell_renderer_get_padding (gail_renderer->renderer, &xpad, &ypad);

  get_origins (widget, &x_window, &y_window, &x_toplevel, &y_toplevel);

  x_temp =  x - (x_offset + rendered_rect.x + xpad) - x_window;
  y_temp =  y - (y_offset + rendered_rect.y + ypad) - y_window;
  if (coords == ATK_XY_WINDOW)
    {
      x_temp += x_toplevel;
      y_temp += y_toplevel;
    }
  else if (coords != ATK_XY_SCREEN)
    index = -1;

  ret = pango_layout_xy_to_index (layout,
                                  x_temp * PANGO_SCALE,
                                  y_temp * PANGO_SCALE,
                                  &index, NULL);
  if (!ret)
    {
      if (x_temp < 0 || y_temp < 0)
        index = 0;
      else
        index = -1;
    }

  g_object_unref (layout);
  if (index == -1)
    {
      if (coords == ATK_XY_WINDOW || coords == ATK_XY_SCREEN)
        {
          glong length;

          length = g_utf8_strlen (renderer_text, -1);
          g_free (renderer_text);

          return length;
        }

      g_free (renderer_text);

      return index;
    }
  else
    {
      glong offset;

      offset = g_utf8_pointer_to_offset (renderer_text,
                                         renderer_text + index);
      g_free (renderer_text);

      return offset;
    }
}
static void
gtk_text_cell_accessible_get_character_extents (AtkText      *text,
                                                gint          offset,
                                                gint         *x,
                                                gint         *y,
                                                gint         *width,
                                                gint         *height,
                                                AtkCoordType  coords)
{
  GtkRendererCellAccessible *gail_renderer;
  GtkRequisition min_size;
  GtkCellRendererText *gtk_renderer;
  GdkRectangle rendered_rect;
  GtkWidget *widget;
  AtkObject *parent;
  PangoRectangle char_rect;
  PangoLayout *layout;
  gchar *renderer_text;
  gfloat xalign, yalign;
  gint x_offset, y_offset, index;
  gint xpad, ypad;
  gint x_window, y_window, x_toplevel, y_toplevel;

  if (!GTK_TEXT_CELL_ACCESSIBLE (text)->cell_text)
    {
      *x = *y = *height = *width = 0;
      return;
    }
  if (offset < 0 || offset >= GTK_TEXT_CELL_ACCESSIBLE (text)->cell_length)
    {
      *x = *y = *height = *width = 0;
      return;
    }
  gail_renderer = GTK_RENDERER_CELL_ACCESSIBLE (text);
  gtk_renderer = GTK_CELL_RENDERER_TEXT (gail_renderer->renderer);

  g_object_get (gtk_renderer, "text", &renderer_text, NULL);
  if (text == NULL)
    {
      g_free (renderer_text);
      return;
    }

  parent = atk_object_get_parent (ATK_OBJECT (text));
  if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
    parent = atk_object_get_parent (parent);
  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent));
  g_return_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent));
  _gtk_cell_accessible_parent_get_cell_area (GTK_CELL_ACCESSIBLE_PARENT (parent),
                                             GTK_CELL_ACCESSIBLE (text),
                                             &rendered_rect);

  gtk_cell_renderer_get_preferred_size (GTK_CELL_RENDERER (gtk_renderer),
                                        widget,
                                        &min_size, NULL);

  gtk_cell_renderer_get_alignment (GTK_CELL_RENDERER (gtk_renderer), &xalign, &yalign);
  if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
    xalign = 1.0 - xalign;
  x_offset = MAX (0, xalign * (rendered_rect.width - min_size.width));
  y_offset = MAX (0, yalign * (rendered_rect.height - min_size.height));

  layout = create_pango_layout (GTK_TEXT_CELL_ACCESSIBLE (text));

  index = g_utf8_offset_to_pointer (renderer_text, offset) - renderer_text;
  pango_layout_index_to_pos (layout, index, &char_rect);

  gtk_cell_renderer_get_padding (gail_renderer->renderer, &xpad, &ypad);

  get_origins (widget, &x_window, &y_window, &x_toplevel, &y_toplevel);

  *x = (char_rect.x / PANGO_SCALE) + x_offset + rendered_rect.x + xpad + x_window;
  *y = (char_rect.y / PANGO_SCALE) + y_offset + rendered_rect.y + ypad + y_window;
  *height = char_rect.height / PANGO_SCALE;
  *width = char_rect.width / PANGO_SCALE;

  if (coords == ATK_XY_WINDOW)
    {
      *x -= x_toplevel;
      *y -= y_toplevel;
    }
  else if (coords != ATK_XY_SCREEN)
    {
      *x = 0;
      *y = 0;
      *height = 0;
      *width = 0;
    }

  g_free (renderer_text);
  g_object_unref (layout);
}