Esempio n. 1
0
static gint 
gail_notebook_page_get_offset_at_point (AtkText      *text,
                                        gint         x,
                                        gint         y,
	          		        AtkCoordType coords)
{ 
  GtkWidget *label;
  GailNotebookPage *notebook_page;
  gint index, x_layout, y_layout;
  const gchar *label_text;

  notebook_page = GAIL_NOTEBOOK_PAGE (text);
  label = get_label_from_notebook_page (notebook_page);

  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);  
}
Esempio n. 2
0
static gchar*
gail_notebook_page_get_text (AtkText *text,
                             gint    start_pos,
                             gint    end_pos)
{
  GtkWidget *label;
  GailNotebookPage *notebook_page;
  const gchar *label_text;

  notebook_page = GAIL_NOTEBOOK_PAGE (text);
  label = get_label_from_notebook_page (notebook_page);

  if (!GTK_IS_LABEL (label))
    return NULL;

  if (!notebook_page->textutil) 
    gail_notebook_page_init_textutil (notebook_page, label);

  label_text = gtk_label_get_text (GTK_LABEL (label));

  if (label_text == NULL)
    return NULL;
  else
  {
    return gail_text_util_get_substring (notebook_page->textutil, 
                                         start_pos, end_pos);
  }
}
Esempio n. 3
0
static void
gail_notebook_page_get_character_extents (AtkText      *text,
				          gint         offset,
		                          gint         *x,
                    		          gint         *y,
                                          gint 	       *width,
                                          gint 	       *height,
			                  AtkCoordType coords)
{
  GtkWidget *label;
  GailNotebookPage *notebook_page;
  PangoRectangle char_rect;
  gint index, x_layout, y_layout;
  const gchar *label_text;
 
  notebook_page = GAIL_NOTEBOOK_PAGE (text);
  label = get_label_from_notebook_page (notebook_page);

  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);
} 
Esempio n. 4
0
static AtkObject*
_gail_notebook_page_get_tab_label (GailNotebookPage *page)
{
  GtkWidget *label;

  label = get_label_from_notebook_page (page);
  if (label)
    return gtk_widget_get_accessible (label);
  else
    return NULL;
}
Esempio n. 5
0
AtkObject*
gail_notebook_page_new (GtkNotebook *notebook, 
                        gint        pagenum)
{
  GObject *object;
  AtkObject *atk_object;
  GailNotebookPage *page;
  GtkWidget *child;
  GtkWidget *label;
  GList *list;
  
  g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL);

  child = gtk_notebook_get_nth_page (notebook, pagenum);

  if (!child)
    return NULL;

  object = g_object_new (GAIL_TYPE_NOTEBOOK_PAGE, NULL);
  g_return_val_if_fail (object != NULL, NULL);

  page = GAIL_NOTEBOOK_PAGE (object);
  page->notebook = notebook;
  g_object_add_weak_pointer (G_OBJECT (page->notebook), (gpointer *)&page->notebook);
  page->index = pagenum;
  list = g_list_nth (notebook->children, pagenum);
  page->page = list->data;
  page->textutil = NULL;
  
  atk_object = ATK_OBJECT (page);
  atk_object->role = ATK_ROLE_PAGE_TAB;
  atk_object->layer = ATK_LAYER_WIDGET;

  page->notify_child_added_id = gdk_threads_add_idle (notify_child_added, atk_object);
  /*
   * We get notified of changes to the label
   */
  label = get_label_from_notebook_page (page);
  if (GTK_IS_LABEL (label))
    {
      if (gtk_widget_get_mapped (label))
        gail_notebook_page_init_textutil (page, label);
      else
        g_signal_connect (label,
                          "map",
                          G_CALLBACK (gail_notebook_page_label_map_gtk),
                          page);
    }

  return atk_object;
}
Esempio n. 6
0
static gint
gail_notebook_page_get_character_count (AtkText *text)
{
  GtkWidget *label;
  GailNotebookPage *notebook_page;

  notebook_page = GAIL_NOTEBOOK_PAGE (text);
  label = get_label_from_notebook_page (notebook_page);

  if (!GTK_IS_LABEL(label))
    return 0;

  return g_utf8_strlen (gtk_label_get_text (GTK_LABEL (label)), -1);
}
static const gchar *
gtk_notebook_page_accessible_get_name (AtkObject *accessible)
{
  GtkWidget *label;

  if (accessible->name != NULL)
    return accessible->name;

  label = get_label_from_notebook_page (GTK_NOTEBOOK_PAGE_ACCESSIBLE (accessible));
  if (GTK_IS_LABEL (label))
    return gtk_label_get_text (GTK_LABEL (label));

  return NULL;
}
Esempio n. 8
0
static AtkAttributeSet*
gail_notebook_page_get_default_attributes (AtkText *text)
{
  GtkWidget *label;
  GailNotebookPage *notebook_page;
  AtkAttributeSet *at_set = NULL;

  notebook_page = GAIL_NOTEBOOK_PAGE (text);
  label = get_label_from_notebook_page (notebook_page);

  if (!GTK_IS_LABEL(label))
    return NULL;

  at_set = gail_misc_get_default_attributes (at_set,
                                             gtk_label_get_layout (GTK_LABEL (label)),
                                             label);
  return at_set;
}
Esempio n. 9
0
static const gchar*
gail_notebook_page_get_name (AtkObject *accessible)
{
  g_return_val_if_fail (GAIL_IS_NOTEBOOK_PAGE (accessible), NULL);
  
  if (accessible->name != NULL)
    return accessible->name;
  else
    {
      GtkWidget *label;

      label = get_label_from_notebook_page (GAIL_NOTEBOOK_PAGE (accessible));
      if (GTK_IS_LABEL (label))
        return gtk_label_get_text (GTK_LABEL (label));
      else
        return NULL;
    }
}
Esempio n. 10
0
static AtkAttributeSet*
gail_notebook_page_get_run_attributes (AtkText *text,
                                       gint    offset,
                                       gint    *start_offset,
	                               gint    *end_offset)
{
  GtkWidget *label;
  GailNotebookPage *notebook_page;
  AtkAttributeSet *at_set = NULL;
  GtkJustification justify;
  GtkTextDirection dir;

  notebook_page = GAIL_NOTEBOOK_PAGE (text);
  label = get_label_from_notebook_page (notebook_page);

  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 AtkStateSet *
gtk_notebook_page_accessible_ref_state_set (AtkObject *accessible)
{
  AtkStateSet *state_set, *label_state_set, *merged_state_set;
  AtkObject *atk_label;
  GtkWidget *label;

  state_set = ATK_OBJECT_CLASS (_gtk_notebook_page_accessible_parent_class)->ref_state_set (accessible);

  label = get_label_from_notebook_page (GTK_NOTEBOOK_PAGE_ACCESSIBLE (accessible));
  if (label)
    {
      atk_label = gtk_widget_get_accessible (label);
      label_state_set = atk_object_ref_state_set (atk_label);
      merged_state_set = atk_state_set_or_sets (state_set, label_state_set);
      g_object_unref (label_state_set);
      g_object_unref (state_set);
    }
  else
    {
      AtkObject *child;

      child = atk_object_ref_accessible_child (accessible, 0);
      if (!child)
        return state_set;

      merged_state_set = state_set;
      state_set = atk_object_ref_state_set (child);
      if (atk_state_set_contains_state (state_set, ATK_STATE_VISIBLE))
        {
          atk_state_set_add_state (merged_state_set, ATK_STATE_VISIBLE);
          if (atk_state_set_contains_state (state_set, ATK_STATE_ENABLED))
              atk_state_set_add_state (merged_state_set, ATK_STATE_ENABLED);
          if (atk_state_set_contains_state (state_set, ATK_STATE_SHOWING))
              atk_state_set_add_state (merged_state_set, ATK_STATE_SHOWING);

        }
      g_object_unref (state_set);
      g_object_unref (child);
    }
  return merged_state_set;
}
Esempio n. 12
0
static gunichar 
gail_notebook_page_get_character_at_offset (AtkText *text,
                                            gint    offset)
{
  GtkWidget *label;
  GailNotebookPage *notebook_page;
  const gchar *string;
  gchar *index;

  notebook_page = GAIL_NOTEBOOK_PAGE (text);
  label = get_label_from_notebook_page (notebook_page);

  if (!GTK_IS_LABEL(label))
    return '\0';
  string = gtk_label_get_text (GTK_LABEL (label));
  if (offset >= g_utf8_strlen (string, -1))
    return '\0';
  index = g_utf8_offset_to_pointer (string, offset);

  return g_utf8_get_char (index);
}
Esempio n. 13
0
static gchar*
gail_notebook_page_get_text_after_offset (AtkText         *text,
				          gint            offset,
				          AtkTextBoundary boundary_type,
				          gint            *start_offset,
				          gint            *end_offset)
{
  GtkWidget *label;
  GailNotebookPage *notebook_page;

  notebook_page = GAIL_NOTEBOOK_PAGE (text);
  label = get_label_from_notebook_page (notebook_page);

  if (!GTK_IS_LABEL(label))
    return NULL;

  if (!notebook_page->textutil)
    gail_notebook_page_init_textutil (notebook_page, label);

  return gail_text_util_get_text (notebook_page->textutil,
                           gtk_label_get_layout (GTK_LABEL (label)), GAIL_AFTER_OFFSET, 
                           boundary_type, offset, start_offset, end_offset);
}